/** * Agent Runtime — the shared interface for agent execution. * * Both local runtimes (BridgeRuntime) and remote clients (AgentClient) * implement IAgentRuntime, allowing consumers to drive agents through * the same API regardless of where the agent runs. */ import type { AgentEvent } from "./events.js"; /** * Initial configuration passed to `IAgentRuntime.start()`. * * Sets the working directory, model, system prompt, API keys, environment variables, * and initial subagent definitions for the agent session. * * @docLink packages/types/runtime#agent-runtime-config */ export type AgentRuntimeConfig = { cwd: string; provider?: string; model?: string; maxTurns?: number; systemPrompt?: string; apiKeys?: Record; env?: Record; agentDir?: string; sessionId?: string; resumeSessionId?: string; subagents?: Record; }; /** * Definition for a named subagent that the primary agent can dispatch. * * Use full model IDs for explicit version pinning — short aliases accepted by the * SDK can drift between SDK versions. * * @docLink packages/types/runtime#subagent-definition */ export type SubagentDefinition = { description: string; prompt: string; tools?: string[]; disallowedTools?: string[]; /** * Model identifier. Use full IDs (e.g. `"claude-sonnet-4-6"`, * `"claude-opus-4-6"`) for explicit version pinning. Short aliases * (`"sonnet"`, `"opus"`, `"haiku"`, `"inherit"`) are accepted by the SDK * but their resolution can drift between SDK versions. */ model?: string; }; /** * Properties that can change while the agent is running, passed to `IAgentRuntime.configure()`. * * Used at session boot via `ConfigureCommandV2.config` and for runtime reconfiguration * without a full session restart. Includes the resume cascade fields for tier-1 native * SDK resume (v3.2.0+). * * @docLink packages/types/runtime#agent-reconfigure-options */ export type AgentReconfigureOptions = { /** Add/remove/update connected data sources. */ connectors?: ConnectorReference[]; /** Add/remove/update available skills and agent definitions. */ aiResources?: AiResourceReference[]; /** Add/remove subagent definitions. */ subagents?: Record; /** Initialize or replace shared state stores. */ sharedState?: SharedStateConfig[]; /** * Driver-level native session resume hint (Phase 3 of the resume cascade). * * When set, drivers that support native session resume (claude-sdk today) * recreate the driver with this session id so the SDK reloads its JSONL * conversation history losslessly. Drivers that do not support native * resume ignore the hint. * * Treated as a soft hint: if the driver cannot honor it (signature * mismatch, JSONL lost, model changed), the runner emits * {@link ResumeFailedEvent} and continues without resume. The platform * downgrades to tier 2 / 3 on the next wake. * * Spec: `_devlog/specs/2026-05-05-session-resume-restart-design.md` * § "Tier 1: native resume plumbing". * * @category Resume * @since 3.2.0 */ resumeSessionId?: string; /** * Capability signature the platform expects to find on the runner at * configure time, used to validate that the toolset has not drifted since * {@link resumeSessionId} was captured. Computed via * `computeCapabilitySignature` from `@skaile/workspaces/runner`. When the * signature does not match the runner's current registry, the runner * drops {@link resumeSessionId} and emits {@link ResumeFailedEvent} with * `reason: 'signature_mismatch'`. * * Optional. When omitted, the runner honors {@link resumeSessionId} * without signature validation (still subject to driver-level checks * such as model match and JSONL presence). * * @category Resume * @since 3.2.0 */ expectedCapabilitySignature?: string; /** * Platform `AIProviderConfig.id` for the AI credential provisioned into * this session. The runner stashes this in session state and passes it * as `configId` in `request_access_token { kind: 'ai-credentials' }` * when the bridge driver throws an `AuthError` against the AI provider. * * Set by the platform agent-gateway for mediated sessions; standalone * runners (CLI / forge / Claude plugin) leave it undefined. The runner's * 401-mediation handler short-circuits to surface-the-error when this * field is undefined. * * Spec: `_devlog/specs/2026-05-07-unified-credential-mediation.md` * § "Wire `aiProviderConfigId` end-to-end". * * @category Credentials * @since 3.3.0 */ aiProviderConfigId?: string; }; /** * Lightweight reference to a connector for use in `AgentReconfigureOptions.connectors`. * * @docLink packages/types/runtime#connector-reference */ export type ConnectorReference = { id: string; adapter: string; access?: "read-only" | "read-write"; auth?: string; autoMount?: boolean; mountPath?: string; params?: Record; }; /** * Lightweight reference to an AI resource (skill, flow, prompt, etc.) for use in * `AgentReconfigureOptions.aiResources`. Supports both path-based and catalog-based * deployment via the `action` field. * * @docLink packages/types/runtime#ai-resource-reference */ export type AiResourceReference = { name: string; path: string; branch?: string; dependencies?: string[]; auto_deploy?: boolean; /** Catalog-based deployment: "add" to deploy, "remove" to undeploy. */ action?: "add" | "remove"; /** Catalog entry metadata (for catalog-based deployment). */ entry?: Record; /** Root directory of ai-assets (for catalog-based deployment). */ assetsRoot?: string; /** Skill context to inject (for catalog-based deployment). */ context?: string; }; /** * Configuration for a shared state store at the protocol level. * * Used in `AgentReconfigureOptions.sharedState` to initialize XState machines, Yjs * documents, or custom adapters shared between components during a session. * * @docLink packages/types/runtime#shared-state-config */ export type SharedStateConfig = { /** Store identifier, e.g. "flow", "session" */ id: string; /** State backend adapter: "xstate", "yjs", or any registered connector adapter */ adapter: string; /** Machine definition (XState), schema (Yjs), or adapter-specific config */ definition?: unknown; /** Starting state */ initialState?: Record; }; /** * Shared interface for anything that can drive an agent execution. * * Both `BridgeRuntime` (local execution via drivers) and `AgentClient` (remote * execution via transport) implement this interface, allowing consumers to drive * agents through the same API regardless of where the agent runs. * * @docLink packages/types/runtime#i-agent-runtime */ export interface IAgentRuntime { /** Optional initial setup. BridgeRuntime creates a driver; AgentClient may connect. */ start?(config: AgentRuntimeConfig): Promise; /** Reconfigure at runtime — connectors, ai-assets, subagents, shared state. */ configure(config: AgentReconfigureOptions): Promise; /** Tear down the runtime and release resources. */ dispose(): Promise; /** Send a user message to the agent. */ prompt(message: string): Promise; /** Answer an agent question. */ reply(answer: string, question?: string, requestId?: string): Promise; /** Optional attachment support; hosts must reject unsupported structured inputs. */ promptInput?(input: import("./protocol.js").AgentPromptInput): Promise; /** Cancel the current operation. */ abort(): Promise; /** Subscribe to agent events. */ onEvent(handler: (event: AgentEvent) => void): void; /** Unsubscribe from agent events. */ offEvent(handler: (event: AgentEvent) => void): void; /** Whether the agent is currently running/connected. */ readonly isRunning: boolean; } /** * Metadata about an agent driver backend, returned by bridge driver introspection. * * @docLink packages/types/runtime#driver-info */ export type DriverInfo = { id: string; name: string; modelAgnostic: boolean; supportsInBandAbort: boolean; }; //# sourceMappingURL=runtime.d.ts.map