Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970import type * as Effect from "effect/Effect";import type * as Stream from "effect/Stream";import type { ShellResult } from "../shared/shell";import type { TaskSummary } from "../shared/tasks";import type { WebResult, WebSource } from "../shared/web";import type { AgentFailure } from "../worker/agent-io";import type { CredentialFailure, ModelConfiguration,} from "../worker/model-settings";import type { PersonalAgent } from "../worker/personal-agent";import type { PersonalModels } from "../worker/personal-models";import type { OperationResult } from "../worker/operation-result";import { shellResults } from "../worker/shell-execution";import type { ShellHost } from "../worker/shell-tool";import type { TaskStore } from "../worker/task-store";import type { WebFailure } from "../worker/web-errors";import { readWebUrl } from "../worker/web-read";import { searchWeb } from "../worker/web-search";import { webSource } from "../worker/web-source";
function webContracts(ai: Ai, source: Omit<WebSource, "id" | "fetchedAt">) { const search: Effect.Effect<WebResult, WebFailure> = searchWeb( ai, "query", 3, ); const read: Effect.Effect<WebResult, WebFailure> = readWebUrl( "https://example.com", { toolCallId: "read", messages: [], context: undefined, }, ); const hashed: Effect.Effect<WebSource> = webSource(source); // @ts-expect-error Internal application operations compose as Effects. const promise: Promise<WebResult> = searchWeb(ai, "query", 3); return { search, read, hashed, promise };}
function agentContracts( tasks: TaskStore, models: PersonalModels, agent: PersonalAgent, host: ShellHost,) { const created: Effect.Effect<TaskSummary, AgentFailure> = tasks.create({}); const snapshot: Effect.Effect< { configuration: ModelConfiguration; apiKey?: string }, CredentialFailure | AgentFailure > = models.readModelConfiguration(); const shell: Stream.Stream<ShellResult> = shellResults( () => host, "echo ready", ); const rpc: Promise<TaskSummary> = agent.createTask({}); const modelRpc: Promise< OperationResult<{ configuration: ModelConfiguration; apiKey?: string; }> > = agent.readModelConfiguration(); // @ts-expect-error Native RPC never transports an Effect execution object. const effectRpc: Effect.Effect<TaskSummary, AgentFailure> = agent.createTask( {}, ); return { created, snapshot, shell, rpc, modelRpc, effectRpc };}