import type { LaunchProfile, McpBindingLaunchSpec, NativeEvent } from "../types.js"; /** Claude Code's first-party structured stdio surface (`--print` + stream-json). */ export declare const CLAUDE_PROTOCOL = "claude-cli-stream-json-v1"; export declare const GROUPX_MCP_SERVER_NAME = "groupx"; /** * The single unrestricted permission mode GroupX requires. It is applied through * process argv only; Claude Code's own settings files are never written. */ export declare const CLAUDE_UNRESTRICTED_PERMISSION_MODE = "bypassPermissions"; /** Fixed product argv appended after the resolved command and launcher prefix. */ export declare const CLAUDE_BASE_ARGV: readonly ["--print", "--input-format", "stream-json", "--output-format", "stream-json", "--verbose", "--include-partial-messages", "--permission-mode", "bypassPermissions"]; export interface ClaudeMcpServerConfig { type: "stdio" | "http"; command?: string; args?: string[]; url?: string; headers?: Record; } export interface ClaudeMcpConfig { mcpServers: Record; } /** * Projection of the deferred `system`/`init` frame. The native frame also lists * the user's tools, MCP servers, skills, plugins, and memory paths; GroupX * keeps only the fields its session-identity and access checks need. */ export interface ClaudeInit { sessionId: string; permissionMode: string; cwd: string; version: string | undefined; } /** * Projection of the `initialize` control response. * * The native payload also carries account, organization, model, plugin, and * command inventories. GroupX collects only the fields its access contract * needs; everything else stays outside GroupX records and diagnostics. */ export interface ClaudeHandshake { permissionMode: string; pid: number | undefined; } export interface ClaudeControlResponse { requestId: string; ok: boolean; payload: Record | undefined; error: string | undefined; } export type ClaudeTerminalKind = "completed" | "cancelled" | "failed"; export interface ClaudeResult { kind: ClaudeTerminalKind; subtype: string; terminalReason: string | undefined; isError: boolean; stopReason: string | undefined; /** Native HTTP status for an API failure. The CLI emits it as an integer. */ apiErrorStatus: number | undefined; numTurns: number | undefined; usage: unknown; } export interface ClaudeControlRequest { requestId: string; subtype: string; /** True when the request asks the client to make an interactive decision. */ interactive: boolean; } export interface ClaudeLaunchOptions { /** Preassigned id for a new session. Mutually exclusive with `resumeSessionId`. */ sessionId?: string; /** Existing native session id to resume. Mutually exclusive with `sessionId`. */ resumeSessionId?: string; mcp?: McpBindingLaunchSpec | undefined; bindingId?: string | undefined; } /** * Stable process argv for Claude Code 2.1 stream-json stdio. No model, sandbox, * or other native policy argument is accepted from configuration; the adapter * owns every argument after the launcher prefix. */ export declare function buildClaudeLaunchArgv(command: string, prefixArgs?: readonly string[], options?: ClaudeLaunchOptions): readonly [string, ...string[]]; /** * Build the one GroupX-owned Claude MCP fragment. It is passed as argv and * merges with the user's own servers; a binding id is a source correlation * handle, not an authentication token or permission grant. */ export declare function buildClaudeMcpConfig(mcp: McpBindingLaunchSpec | undefined, bindingId: string | undefined): ClaudeMcpConfig | undefined; export declare function buildClaudeUserMessage(input: { content: string; contextPacket?: string | undefined; }): Record; export declare function buildClaudeInterruptRequest(requestId: string): Record; /** * The SDK control handshake. Claude Code emits its `system`/`init` frame only * after the first user message, so this is the one exchange that proves the * native process is alive without consuming a model turn. The reported * current_permission_mode is observational; unrestricted is established by * set_permission_mode. */ export declare function buildClaudeInitializeRequest(requestId: string): Record; export declare function buildClaudeSetPermissionModeRequest(requestId: string): Record; export declare function parseClaudeHandshake(payload: Record | undefined): ClaudeHandshake; export declare function parseClaudeSetPermissionModeResult(payload: Record | undefined): string; /** * GroupX has no approval subsystem. Any interactive request is answered with a * protocol-level denial so the native process cannot stay blocked, and the Turn * fails separately with `UNEXPECTED_NATIVE_INTERACTION`. */ export declare function buildClaudeDenyPermissionResponse(requestId: string): Record; export declare function buildClaudeControlErrorResponse(requestId: string, error: string): Record; export declare function parseClaudeInit(value: unknown): ClaudeInit; export declare function parseClaudeResult(value: unknown): ClaudeResult; /** * Classify a control request the native process sent to GroupX. `can_use_tool` * is the permission decision path and is always fatal for the current Turn. */ export declare function parseClaudeControlRequest(value: unknown): ClaudeControlRequest | undefined; export declare function parseClaudeControlResponse(value: unknown): ClaudeControlResponse | undefined; export interface ClaudeStreamProjection { type: NativeEvent["type"]; payload: Record; nativeEventId?: string; } /** * Project one `stream_event` into a normalized GroupX event. Returns undefined * for frames that carry no room-visible semantics. */ export declare function normalizeClaudeStreamEvent(value: unknown): ClaudeStreamProjection | undefined; /** * Report the assistant message a `message_start` frame opens. `undefined` means * the frame is not a message_start; a present result with `messageId: undefined` * means a new message opened without an id, which must still clear the previous * id so its deltas are never attributed to the wrong message. */ export declare function readClaudeStreamMessageStart(value: unknown): { messageId: string | undefined; } | undefined; export interface ClaudeAssistantBlocks { messageId: string | undefined; text: string[]; toolUses: Array<{ toolUseId: string; toolName: string | undefined; }>; } export declare function readClaudeAssistantBlocks(value: unknown): ClaudeAssistantBlocks | undefined; export interface ClaudeToolResult { toolUseId: string; isError: boolean; } export declare function readClaudeToolResults(value: unknown): ClaudeToolResult[]; export declare function launchProfileFields(profile: LaunchProfile): Pick; export declare function isRecord(value: unknown): value is Record; //# sourceMappingURL=protocol.d.ts.map