/** * SEP wire protocol — JSON-RPC 2.0 frames and typed method params/results. * * SEP (the Smooth Extension Protocol) is JSON-RPC 2.0 over ndjson on an extension * subprocess's stdio. The canonical schemas live in the `smooth-operator` repo at * `spec/extension/`; the types here are the TS engine host's view of that wire — * the sibling of the Rust host's `extension/protocol.rs`. Field names are * `snake_case` because they ARE the wire. * * The author-side `@smooai/smooth-extension-sdk` ships its own copy of these * shapes; the host keeps them local rather than importing the SDK, which would * invert the dependency (the engine is the lower layer the SDK's host consumers * build on). */ /** The SEP protocol version this host implements. Effective = min(host, ext). */ export declare const PROTOCOL_VERSION = 1; /** SEP method names, centralized so the host and tests never spell one wrong. */ export declare const method: { readonly INITIALIZE: "initialize"; readonly SHUTDOWN: "shutdown"; readonly PING: "ping"; readonly EVENT: "event"; readonly HOOK: "hook"; readonly TOOL_EXECUTE: "tool/execute"; readonly TOOL_UPDATE: "tool/update"; readonly COMMAND_EXECUTE: "command/execute"; readonly COMMAND_COMPLETE: "command/complete"; readonly CANCEL: "$/cancel"; readonly REGISTRY_UPDATE: "registry/update"; readonly TOOLS_SET_ACTIVE: "tools/set_active"; readonly EXEC_RUN: "exec/run"; readonly UI_REQUEST: "ui/request"; readonly LOG: "log"; readonly BUS_PUBLISH: "bus/publish"; readonly SESSION_SEND_MESSAGE: "session/send_message"; readonly SESSION_SEND_USER_MESSAGE: "session/send_user_message"; readonly SESSION_APPEND_ENTRY: "session/append_entry"; }; /** * JSON-RPC + SEP error codes (see `spec/extension/envelope.md`). Standard range * plus the SEP extensions. */ export declare const codes: { readonly ParseError: -32700; readonly InvalidRequest: -32600; readonly MethodNotFound: -32601; readonly InvalidParams: -32602; readonly InternalError: -32603; /** A hook or policy vetoed the operation. */ readonly Blocked: -32000; /** `ui/request` in a headless/uncapable frontend. */ readonly NoUI: -32001; /** Extension acted beyond its granted trust. */ readonly NotTrusted: -32002; /** Command-tier action attempted from an event-tier context. */ readonly ContextViolation: -32003; /** Method requires a capability the handshake did not enable. */ readonly CapabilityDisabled: -32004; /** Request cancelled via `$/cancel`. */ readonly Cancelled: -32800; }; /** A JSON-RPC error object. */ export interface RpcErrorObject { code: number; message: string; data?: unknown; } /** An error carrying a JSON-RPC error code, thrown/returned for a remote error. */ export declare class RpcError extends Error { readonly code: number; readonly data?: unknown | undefined; constructor(code: number, message: string, data?: unknown | undefined); toObject(): RpcErrorObject; } /** A JSON-RPC id: an integer or a string (null only on a parse-error response). */ export type Id = number | string | null; /** * The JSON-RPC 2.0 envelope. All four frame shapes share this type; which fields * are present determines the shape: * - request: `id` + `method` (+ optional `params`) * - notification: `method`, no `id` * - success response: `id` + `result` * - error response: `id` + `error` */ export interface Message { jsonrpc: '2.0'; id?: Id; method?: string; params?: unknown; result?: unknown; error?: RpcErrorObject; } /** Build a request frame. */ export declare function request(id: Exclude, methodName: string, params: unknown): Message; /** Build a notification frame (no id, no reply expected). */ export declare function notification(methodName: string, params: unknown): Message; /** Build a success response frame echoing `id`. */ export declare function success(id: Id, result: unknown): Message; /** Build an error response frame echoing `id`. */ export declare function errorResponse(id: Id, error: RpcErrorObject): Message; /** True when this frame is a request (has both `id` and `method`). */ export declare function isRequest(m: Message): boolean; /** True when this frame is a notification (has `method`, no `id`). */ export declare function isNotification(m: Message): boolean; /** True when this frame is a response (has `id`, no `method`). */ export declare function isResponse(m: Message): boolean; /** * Whether a dispatch may only observe (`event`) or may mutate the session * (`command`). Session-mutating ext→host actions require `command`. */ export type Tier = 'event' | 'command'; /** The dispatch context carried by every host→ext event/hook/tool/command. */ export interface Context { token: string; tier: Tier; } export interface HostInfo { name: string; version: string; } export interface WorkspaceInfo { root: string; trusted: boolean; } export interface InitializeParams { protocol_version: number; host: HostInfo; workspace: WorkspaceInfo; session?: { id?: string; }; mode: string; ui_capabilities?: string[]; /** Parsed values for the flags the extension declares (name → value). */ flags?: Record; capabilities_enabled?: Record; } export interface ToolRegistration { name: string; description: string; /** JSON Schema for the tool's arguments. */ parameters: Record; deferred?: boolean; } export interface CommandRegistration { name: string; description: string; } /** A keyboard shortcut an extension binds to one of its commands. */ export interface ShortcutRegistration { /** A human-typed chord, e.g. `ctrl+p`; the frontend parses it. */ key: string; /** The registered command this chord invokes (no leading `/`). */ command: string; description?: string; } export interface Registrations { tools?: ToolRegistration[]; commands?: CommandRegistration[]; flags?: string[]; shortcuts?: ShortcutRegistration[]; subscriptions?: string[]; } export interface InitializeResult { protocol_version: number; extension: { name: string; version: string; }; registrations?: Registrations; } export interface HookParams { hook: string; context: Context; input: unknown; } /** The extension's reply to a `hook`, tagged by `action`. */ export type HookOutcome = { action: 'continue'; } | { action: 'block'; reason?: string; } | { action: 'modify'; patch: unknown; }; /** * Parse an untyped `hook` reply into a {@link HookOutcome}, or throw when it is * malformed. Mirrors the Rust host's serde-tagged decode: a `modify` without a * `patch`, or an unknown `action`, is rejected (the host then treats it as a * failed hook step). */ export declare function parseHookOutcome(value: unknown): HookOutcome; export interface ToolExecuteParams { call_id: string; tool: string; arguments: unknown; context: Context; } export interface ToolExecuteResult { content: string; is_error?: boolean; details?: unknown; } export interface ToolUpdateParams { call_id: string; message?: string; progress?: number; details?: unknown; } export interface EventParams { event: string; /** Per-connection monotonic sequence; absent on the `events_lost` marker. */ seq?: number; context: Context; payload?: unknown; } export interface CommandExecuteParams { command: string; context: Context; arguments?: unknown; } export interface CommandExecuteResult { content?: string; } export interface CommandCompleteParams { command: string; context: Context; partial?: string; } export interface Completion { value: string; description?: string; } export interface CommandCompleteResult { completions: Completion[]; } /** How a `session/send_user_message` is delivered relative to the current turn. */ export type DeliverAs = 'steer' | 'follow_up' | 'next_turn'; export interface SessionSendMessageParams { context: Context; text: string; role?: 'user' | 'assistant'; } export interface SessionSendUserMessageParams { context: Context; text: string; deliver_as?: DeliverAs; } export interface SessionAppendEntryParams { context: Context; entry: unknown; } //# sourceMappingURL=protocol.d.ts.map