import type { Clock, Effect, Option, Stream } from "effect"; import type { Chat, LanguageModel, Prompt, Tool } from "effect/unstable/ai"; import type { AgentRunState } from "./agent-run-state.js"; import type { AgentError, Event } from "./agent-event.js"; import type { AnyToolCall } from "./agent-tool-result.js"; import type { DriverInterpreter } from "../durable/driver-interpreter.js"; import type { HandoffRunState } from "./handoff-state.js"; import type { RunError, ToolSchedulingPolicy } from "./agent.js"; import type { Middleware } from "../model/model-middleware.js"; import type { ModelSelection, ModelRegistry } from "../model/model-registry.js"; import type { ModelResilience } from "../model/model-resilience.js"; import type { EventPayload as DeliveryEventPayload } from "../model/model-telemetry.js"; import type { Request } from "../tools/tool-executor.js"; import type { Registry } from "../tools/tool-registry.js"; import type { ToolContext } from "../tools/tool-context.js"; export type StaticToolServices> = Tool.HandlersFor | Exclude, ToolContext>; /** @experimental Every service one model turn requires, including the send-time clock. */ export type ModelTurnServices, R> = LanguageModel.LanguageModel | Clock.Clock | R | StaticToolServices | DriverInterpreter; export type RuntimeContext, R> = { readonly agent: { readonly name: string; readonly toolScheduling: ToolSchedulingPolicy; readonly model?: import("../model/model-registry.js").ModelSelection; }; readonly handoffStateRef?: import("effect").Ref.Ref; readonly agentModelRegistry: typeof ModelRegistry.Service | undefined; readonly agentModel: ModelSelection | undefined; readonly resilienceService: Option.Option; readonly activeModelResponse: Option.Option; readonly telemetryIdentity: { readonly current: { readonly modelCallId: string; readonly modelAttemptId: string; readonly attempt: number; } | undefined; }; readonly instrumentModel: (model: LanguageModel.Service, turn: number) => LanguageModel.Service; readonly chain: ReadonlyArray; readonly preparePrompt: (turn: number, prompt: Prompt.Prompt, overflow: boolean) => Effect.Effect<{ readonly prompt: Prompt.Prompt; readonly changed: boolean; }, RunError, LanguageModel.LanguageModel | DriverInterpreter>; readonly countTokens: (turn: number, prompt: Prompt.Prompt) => Effect.Effect; readonly syncSession: (turn: number, transcript: Prompt.Prompt) => Effect.Effect, RunError, DriverInterpreter>; readonly replayMessages: (sessionParentId: string) => Effect.Effect, RunError>; readonly emitTelemetry: (payload: DeliveryEventPayload) => Effect.Effect; readonly chat: Chat.Service; readonly compactionService: Option.Option; readonly state: AgentRunState; readonly errorMessage: (error: unknown) => string; readonly persisted: Chat.Persisted | undefined; readonly toolCallEvents: (turn: number, batch: Request["toolCallBatch"], index: number, call: AnyToolCall, messages: ReadonlyArray, registry: Registry) => Stream.Stream | DriverInterpreter>; };