/** * Agent Protocol — messages exchanged between agent client and server. * * AgentCommand: sent toward the agent (client → server) * AgentEvent: sent from the agent (server → client) — defined in events.ts * * Protocol v3 (since `@skaile/workspaces/types@4.0.0`, shipped 2026-05-10) removed * the following commands from the {@link AgentCommand} union: `configure` / * `ConfigureCommandV2`, `provision_secrets`, `request_access_token`, * `add_resource`, `remove_resource`, `set_log_level`, `state_action`, * `lifecycle`, `remount_mount`, `compact`, `reconfigure_agent`. Their * semantics ride on: * - {@link SessionInitCommand} (one deterministic envelope at session * start that delivers identity, resolved config, pre-minted credentials, * secrets, capabilities, shared state, active flows, resume hints, and * logging config), and * - `host.*` / `runner.*` capability invocations (bidirectional * capability registry). * * Spec: `_devlog/specs/2026-05-10-deterministic-session-bootstrap.md`. */ import type { CapabilityApproveCommand, CapabilityDeregisterCommand, CapabilityRegisterCommand, CapabilityResultCommand } from "./capabilities.js"; import type { ConnectorContent, ConnectorOperation, ListOptions, SearchOptions } from "./events.js"; import type { ReplyRef } from "./messaging.js"; /** Text and scoped attachments; unsupported drivers must reject attachments explicitly. */ export interface AgentPromptInput { text: string; attachments?: Array<{ type: "image"; path: string; } | { type: "file"; path: string; name: string; } | { type: "skill"; path: string; name: string; }>; } /** * Discriminated union of all commands sent from client to agent server. * * Narrow via `command.type` or a `switch` statement. * * @docLink packages/types/protocol-v3#agent-command */ export type AgentCommand = { type: "prompt"; prompt: string; attachments?: AgentPromptInput["attachments"]; replyTo?: ReplyRef; messageId?: string; } | { type: "reply"; answer: string; question?: string; requestId?: string; } | { type: "cancel"; } | { type: "shutdown"; } | ConnectorRequestCommand | DebugCommand | ConnectorMutateCommand | ConnectorQueryCommand | ConnectorConfigCommand | StateUpdateCommand | CustomMessageCommand | CapabilityRegisterCommand | CapabilityDeregisterCommand | CapabilityResultCommand | CapabilityApproveCommand; /** * A resource declaration carried by `runner.add_mount` / `runner.add_connector` * capability invocations. Mirrors the `skaile.yaml` mount/connector schema * but flattened for transport. * * Used by: * - {@link ResolvedSkaileConfig.mounts} / `.connectors` (lifecycle.ts) * - `runner.add_mount.input.declaration` / `runner.add_connector.input.declaration` * * @docLink packages/types/protocol-v3#resource-declaration */ export type ResourceDeclaration = { id: string; driver: string; source: string; target?: string; access: "read-only" | "read-write"; auth?: string; /** * Identifier of the `ProviderLink` this resource is bound to when * `auth: 'backend'`. Read by the platform credential mediator to dispatch * the mint (and re-read by the runner when an `exposeAccessToken` git * mount needs to surface a managed-gitconfig credential helper). Optional * because not every backend-auth driver is provider-linked, and not every * resource uses backend auth. */ providerLinkId?: string; options?: Record; }; /** * Migration strategy carried by `runner.add_mount.input.migration` when * replacing the workspace mount of an empty project. * * @docLink packages/types/protocol-v3#resource-migration */ export type ResourceMigration = { strategy: "replace-workspace"; targetFolder?: string | null; } | { strategy: "none"; }; /** * Generic connector mutation. Routes to ConnectorManager.executeOp(id, op, payload). * Replaces the typed flow commands in Protocol 2.2 — see * MIGRATION-flow-connector.md for the per-op mapping table. * * @docLink packages/types/protocol-v3#connector-mutate-command * @since 2.2.0 */ export type ConnectorMutateCommand = { type: "connector_mutate"; /** Target connector id (matches `connectors[].id` in skaile.yaml). */ id: string; /** Operation name as declared by the adapter's describeOperations(). */ op: string; /** Operation arguments. Adapter-specific shape. Optional for nullary ops. */ payload?: Record; /** * Opt-in acknowledgement correlation (Protocol 3.7). When present the runner * MUST emit exactly one `connector_mutate_response` carrying this `requestId`. * When absent the command is fire-and-forget, byte-identical to 3.6 behaviour. */ requestId?: string; }; /** * Generic connector read. Same dispatch as connector_mutate but the result * is returned to the caller as a `connector_query_response` event correlated * by `requestId`. Use for read-only queries that should not kick a turn. * * @since 2.2.0 */ export type ConnectorQueryCommand = { type: "connector_query"; requestId: string; id: string; op: string; payload?: Record; }; /** * Query the internal state of a running agent server for diagnostics. * * @docLink packages/types/protocol-v3#debug-command */ export type DebugCommand = { type: "debug"; query: "tools" | "connectors" | "mcp" | "config" | "state" | "commands"; args?: Record; }; /** * Browse or modify connectors from the frontend. * * The wire `type:` string is `"resource_request"` for protocol stability. * The server responds with a `ConnectorResponseEvent` correlated by `requestId`. * * @docLink packages/types/protocol-v3#connector-request-command */ export type ConnectorRequestCommand = { type: "resource_request"; /** UUID for request/response correlation. */ requestId: string; /** Connector ID (e.g. "docs", "project-db"). */ connectorId: string; /** Operation to perform. */ operation: ConnectorOperation; /** Target path (directory, file, key, etc.). */ path?: string; /** Operation-specific options (ListOptions, SearchOptions). */ options?: ListOptions | SearchOptions; /** Content payload for write operations. */ content?: ConnectorContent; }; /** * Sent by the frontend to add, remove, or refresh connectors at runtime without a session restart. * * @docLink packages/types/protocol-v3#connector-config-command */ export interface ConnectorConfigCommand { type: "connector_config"; action: "add" | "remove" | "refresh"; /** Required when action === "add". */ declaration?: { id: string; driver: string; access?: "read-only" | "read-write"; options?: Record; }; /** Required when action === "remove". */ connectorId?: string; } /** * Client/component writes shared state to the runtime. * * Store namespace must start with `"app"` or `"component:"` when sent from the client. * * @docLink packages/types/protocol-v3#state-update-command */ export type StateUpdateCommand = { type: "state_update"; /** Store namespace — must start with "app" or "component:" from client. */ store: string; /** Full state snapshot (replaces previous). */ state: Record; }; /** * User-originated message with a custom type (from input extensions). * * Unlike a plain `prompt`, a custom message carries structured data * (`customType` + `customData`) alongside the text content. The agent * receives these on the `finished` event as `customType`/`customData` * fields. On the frontend, the custom message is rendered by the * matching dynamic component (or its fallback template). * * @docLink packages/types/protocol-v3#custom-message-command */ export type CustomMessageCommand = { type: "custom_message"; /** Plain-text content (backward-compatible summary). */ content: string; /** Custom message type identifier (e.g. "gif"). */ customType: string; /** Structured data for the custom message type. */ customData: Record; }; //# sourceMappingURL=protocol.d.ts.map