The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import * as Schema from "effect/Schema"; |
| 2 | import type * as V2 from "./_generated/schema.gen.ts"; |
| 3 | |
| 4 | type Meta = AcpMeta | null; |
| 5 | type AcpMeta = NonNullable<V2.InitializeRequest["_meta"]>; |
| 6 | type KnownContentBlock<T extends V2.ContentBlock["type"]> = Extract< |
| 7 | V2.ContentBlock, |
| 8 | { readonly type: T } |
| 9 | >; |
| 10 | |
| 11 | export type ContentBlock = |
| 12 | | KnownContentBlock<"text"> |
| 13 | | KnownContentBlock<"image"> |
| 14 | | KnownContentBlock<"audio"> |
| 15 | | KnownContentBlock<"resource_link"> |
| 16 | | KnownContentBlock<"resource"> |
| 17 | | { |
| 18 | readonly type: "_t3_unknown"; |
| 19 | readonly originalType: string; |
| 20 | readonly raw: unknown; |
| 21 | }; |
| 22 | |
| 23 | export type AbsolutePath = V2.AbsolutePath; |
| 24 | export type AvailableCommand = Omit<V2.AvailableCommand, "input"> & { |
| 25 | readonly input?: Extract<V2.AvailableCommandInput, { readonly type: "text" }> | null; |
| 26 | }; |
| 27 | export type CloseSessionRequest = V2.CloseSessionRequest; |
| 28 | export type CloseSessionResponse = V2.CloseSessionResponse; |
| 29 | export type DeleteSessionRequest = V2.DeleteSessionRequest; |
| 30 | export type DeleteSessionResponse = V2.DeleteSessionResponse; |
| 31 | export type ListProvidersRequest = V2.ListProvidersRequest; |
| 32 | export type ListProvidersResponse = V2.ListProvidersResponse; |
| 33 | export type SetProviderRequest = V2.SetProviderRequest; |
| 34 | export type SetProviderResponse = V2.SetProviderResponse; |
| 35 | export type DisableProviderRequest = V2.DisableProviderRequest; |
| 36 | export type DisableProviderResponse = V2.DisableProviderResponse; |
| 37 | export type ConnectMcpRequest = V2.ConnectMcpRequest; |
| 38 | export type ConnectMcpResponse = V2.ConnectMcpResponse; |
| 39 | export type MessageMcpRequest = V2.MessageMcpRequest; |
| 40 | export type MessageMcpNotification = V2.MessageMcpNotification; |
| 41 | export type MessageMcpResponse = V2.MessageMcpResponse; |
| 42 | export type DisconnectMcpRequest = V2.DisconnectMcpRequest; |
| 43 | export type DisconnectMcpResponse = V2.DisconnectMcpResponse; |
| 44 | export type CompleteElicitationNotification = V2.CompleteElicitationNotification; |
| 45 | export type CreateElicitationRequest = V2.CreateElicitationRequest; |
| 46 | export type CreateElicitationResponse = V2.CreateElicitationResponse; |
| 47 | export type ElicitationContentValue = V2.ElicitationContentValue; |
| 48 | export type ForkSessionRequest = Omit<V2.ForkSessionRequest, "mcpServers"> & { |
| 49 | readonly mcpServers?: ReadonlyArray<McpServer>; |
| 50 | }; |
| 51 | export type ListSessionsRequest = V2.ListSessionsRequest; |
| 52 | export type ListSessionsResponse = V2.ListSessionsResponse; |
| 53 | export type LogoutResponse = V2.LogoutAuthResponse; |
| 54 | export type LogoutRequest = V2.LogoutAuthRequest; |
| 55 | export type StopReason = V2.StopReason; |
| 56 | export type Usage = V2.Usage; |
| 57 | export type TerminalExitStatus = V2.TerminalExitStatus; |
| 58 | export type ToolCallLocation = V2.ToolCallLocation; |
| 59 | export type ToolCallStatus = V2.ToolCallStatus; |
| 60 | export type ToolKind = V2.ToolKind; |
| 61 | |
| 62 | export type ClientCapabilities = { |
| 63 | readonly fs?: { readonly readTextFile?: boolean; readonly writeTextFile?: boolean }; |
| 64 | readonly terminal?: boolean; |
| 65 | readonly session?: { |
| 66 | readonly list?: Meta; |
| 67 | readonly notices?: Meta; |
| 68 | readonly compaction?: Meta; |
| 69 | } | null; |
| 70 | readonly plan?: Meta; |
| 71 | readonly auth?: { readonly terminal?: boolean }; |
| 72 | readonly elicitation?: V2.ElicitationCapabilities | null; |
| 73 | readonly _meta?: Meta; |
| 74 | }; |
| 75 | |
| 76 | export type InitializeRequest = { |
| 77 | readonly protocolVersion: number; |
| 78 | readonly clientCapabilities?: ClientCapabilities; |
| 79 | readonly clientInfo?: V2.Implementation | null; |
| 80 | readonly _meta?: Meta; |
| 81 | }; |
| 82 | |
| 83 | export type AgentCapabilities = { |
| 84 | readonly loadSession?: boolean; |
| 85 | readonly promptCapabilities?: { |
| 86 | readonly image?: boolean; |
| 87 | readonly audio?: boolean; |
| 88 | readonly embeddedContext?: boolean; |
| 89 | }; |
| 90 | readonly mcpCapabilities?: { |
| 91 | readonly stdio?: boolean; |
| 92 | readonly http?: boolean; |
| 93 | readonly sse?: boolean; |
| 94 | readonly acp?: boolean; |
| 95 | }; |
| 96 | readonly sessionCapabilities?: { |
| 97 | readonly list?: Meta; |
| 98 | readonly fork?: Meta; |
| 99 | readonly resume?: Meta; |
| 100 | readonly close?: Meta; |
| 101 | readonly delete?: Meta; |
| 102 | readonly additionalDirectories?: Meta; |
| 103 | }; |
| 104 | readonly auth?: { readonly logout?: Meta }; |
| 105 | readonly providers?: Meta; |
| 106 | readonly _meta?: Meta; |
| 107 | }; |
| 108 | |
| 109 | interface AuthMethodBase { |
| 110 | readonly id: string; |
| 111 | readonly name: string; |
| 112 | readonly description?: string | null; |
| 113 | readonly _meta?: Meta; |
| 114 | } |
| 115 | |
| 116 | export type AuthMethod = |
| 117 | | (AuthMethodBase & { |
| 118 | readonly type: "terminal"; |
| 119 | readonly args?: ReadonlyArray<string>; |
| 120 | readonly env?: Readonly<Record<string, string>>; |
| 121 | }) |
| 122 | | (AuthMethodBase & { |
| 123 | readonly type: "env_var"; |
| 124 | readonly vars: ReadonlyArray<{ readonly name: string; readonly label?: string }>; |
| 125 | readonly link?: string | null; |
| 126 | }) |
| 127 | | (AuthMethodBase & { readonly type?: "agent" }); |
| 128 | |
| 129 | export type InitializeResponse = { |
| 130 | readonly protocolVersion: number; |
| 131 | readonly agentCapabilities?: AgentCapabilities; |
| 132 | readonly authMethods?: ReadonlyArray<AuthMethod>; |
| 133 | readonly agentInfo?: V2.Implementation | null; |
| 134 | readonly _meta?: Meta; |
| 135 | }; |
| 136 | |
| 137 | export type AuthenticateRequest = V2.LoginAuthRequest; |
| 138 | export type AuthenticateResponse = V2.LoginAuthResponse; |
| 139 | export type CancelNotification = V2.CancelSessionNotification; |
| 140 | |
| 141 | export type McpServer = |
| 142 | | { |
| 143 | readonly name: string; |
| 144 | readonly command: string; |
| 145 | readonly args?: ReadonlyArray<string>; |
| 146 | readonly env?: ReadonlyArray<V2.EnvVariable>; |
| 147 | readonly _meta?: Meta; |
| 148 | } |
| 149 | | V2.McpServer; |
| 150 | |
| 151 | export type NewSessionRequest = Omit<V2.NewSessionRequest, "mcpServers"> & { |
| 152 | readonly mcpServers: ReadonlyArray<McpServer>; |
| 153 | }; |
| 154 | export type ResumeSessionRequest = Omit<V2.ResumeSessionRequest, "mcpServers"> & { |
| 155 | readonly mcpServers?: ReadonlyArray<McpServer>; |
| 156 | }; |
| 157 | export type LoadSessionRequest = Omit<ResumeSessionRequest, "replayFrom">; |
| 158 | |
| 159 | export interface SessionMode { |
| 160 | readonly id: string; |
| 161 | readonly name: string; |
| 162 | readonly description?: string | null; |
| 163 | readonly _meta?: Meta; |
| 164 | } |
| 165 | |
| 166 | export interface SessionModeState { |
| 167 | readonly currentModeId: string; |
| 168 | readonly availableModes: ReadonlyArray<SessionMode>; |
| 169 | readonly _meta?: Meta; |
| 170 | } |
| 171 | |
| 172 | export interface NewSessionResponse { |
| 173 | readonly models?: SessionModelState | null; |
| 174 | readonly sessionId: string; |
| 175 | readonly modes?: SessionModeState | null; |
| 176 | readonly configOptions?: ReadonlyArray<SessionConfigOption> | null; |
| 177 | readonly _meta?: Meta; |
| 178 | } |
| 179 | |
| 180 | export interface LoadSessionResponse { |
| 181 | readonly models?: SessionModelState | null; |
| 182 | readonly modes?: SessionModeState | null; |
| 183 | readonly configOptions?: ReadonlyArray<SessionConfigOption> | null; |
| 184 | readonly _meta?: Meta; |
| 185 | } |
| 186 | |
| 187 | export type ResumeSessionResponse = LoadSessionResponse; |
| 188 | export interface ForkSessionResponse extends NewSessionResponse {} |
| 189 | |
| 190 | export type SessionConfigSelectOption = V2.SessionConfigSelectOption; |
| 191 | export type SessionConfigSelectOptions = |
| 192 | | ReadonlyArray<SessionConfigSelectOption> |
| 193 | | ReadonlyArray<{ |
| 194 | readonly groupId: string; |
| 195 | readonly name: string; |
| 196 | readonly options: ReadonlyArray<SessionConfigSelectOption>; |
| 197 | readonly _meta?: Meta; |
| 198 | }>; |
| 199 | |
| 200 | interface SessionConfigOptionBase { |
| 201 | readonly id: string; |
| 202 | readonly name: string; |
| 203 | readonly description?: string | null; |
| 204 | readonly category?: string | null; |
| 205 | readonly _meta?: Meta; |
| 206 | } |
| 207 | |
| 208 | export type SessionConfigOption = |
| 209 | | (SessionConfigOptionBase & { |
| 210 | readonly type: "select"; |
| 211 | readonly currentValue: string; |
| 212 | readonly options: SessionConfigSelectOptions; |
| 213 | }) |
| 214 | | (SessionConfigOptionBase & { |
| 215 | readonly type: "boolean"; |
| 216 | readonly currentValue: boolean; |
| 217 | }); |
| 218 | |
| 219 | export type SetSessionConfigOptionRequest = |
| 220 | | { |
| 221 | readonly sessionId: string; |
| 222 | readonly configId: string; |
| 223 | readonly value: string; |
| 224 | readonly _meta?: Meta; |
| 225 | } |
| 226 | | { |
| 227 | readonly type: "boolean"; |
| 228 | readonly sessionId: string; |
| 229 | readonly configId: string; |
| 230 | readonly value: boolean; |
| 231 | readonly _meta?: Meta; |
| 232 | }; |
| 233 | |
| 234 | export interface SetSessionConfigOptionResponse { |
| 235 | readonly configOptions: ReadonlyArray<SessionConfigOption>; |
| 236 | readonly _meta?: Meta; |
| 237 | } |
| 238 | |
| 239 | export interface SetSessionModeResponse { |
| 240 | readonly _meta?: Meta; |
| 241 | } |
| 242 | |
| 243 | export type PromptRequest = Omit<V2.PromptRequest, "prompt"> & { |
| 244 | readonly prompt: ReadonlyArray<ContentBlock>; |
| 245 | }; |
| 246 | export interface PromptResponse { |
| 247 | readonly stopReason: StopReason; |
| 248 | readonly usage?: V2.Usage | null; |
| 249 | readonly error?: V2.Error | null; |
| 250 | readonly _meta?: Meta; |
| 251 | } |
| 252 | |
| 253 | export type ToolCallContent = |
| 254 | | { readonly type: "content"; readonly content: ContentBlock; readonly _meta?: Meta } |
| 255 | | { |
| 256 | readonly type: "diff"; |
| 257 | readonly path: string; |
| 258 | readonly oldText?: string | null; |
| 259 | readonly newText: string; |
| 260 | readonly _meta?: Meta; |
| 261 | } |
| 262 | | { |
| 263 | readonly type: "diff"; |
| 264 | readonly changes: ReadonlyArray<V2.DiffChange>; |
| 265 | readonly patch?: V2.DiffPatch | null; |
| 266 | readonly _meta?: Meta; |
| 267 | } |
| 268 | | { readonly type: "terminal"; readonly terminalId: string; readonly _meta?: Meta } |
| 269 | | { |
| 270 | readonly type: "_t3_unknown"; |
| 271 | readonly originalType: string; |
| 272 | readonly raw: unknown; |
| 273 | }; |
| 274 | |
| 275 | export interface ToolCallUpdate { |
| 276 | readonly toolCallId: string; |
| 277 | readonly name?: string | null; |
| 278 | readonly title?: string | null; |
| 279 | readonly kind?: ToolKind | null; |
| 280 | readonly status?: ToolCallStatus | null; |
| 281 | readonly content?: ReadonlyArray<ToolCallContent> | null; |
| 282 | readonly locations?: ReadonlyArray<ToolCallLocation> | null; |
| 283 | readonly rawInput?: unknown; |
| 284 | readonly rawOutput?: unknown; |
| 285 | readonly _meta?: Meta; |
| 286 | } |
| 287 | |
| 288 | type MessageChunkUpdate = { |
| 289 | readonly content: ContentBlock; |
| 290 | readonly messageId?: string | null; |
| 291 | readonly _meta?: Meta; |
| 292 | }; |
| 293 | |
| 294 | type MessageUpdate = { |
| 295 | readonly messageId: string; |
| 296 | readonly content?: ReadonlyArray<ContentBlock> | null; |
| 297 | readonly _meta?: Meta; |
| 298 | }; |
| 299 | |
| 300 | export type SessionUpdate = |
| 301 | | (MessageChunkUpdate & { readonly sessionUpdate: "user_message_chunk" }) |
| 302 | | (MessageChunkUpdate & { readonly sessionUpdate: "agent_message_chunk" }) |
| 303 | | (MessageChunkUpdate & { readonly sessionUpdate: "agent_thought_chunk" }) |
| 304 | | (MessageUpdate & { readonly sessionUpdate: "user_message" }) |
| 305 | | (MessageUpdate & { readonly sessionUpdate: "agent_message" }) |
| 306 | | (MessageUpdate & { readonly sessionUpdate: "agent_thought" }) |
| 307 | | (ToolCallUpdate & { readonly sessionUpdate: "tool_call"; readonly title: string }) |
| 308 | | (ToolCallUpdate & { readonly sessionUpdate: "tool_call_update" }) |
| 309 | | { |
| 310 | readonly sessionUpdate: "tool_call_content_chunk"; |
| 311 | readonly toolCallId: string; |
| 312 | readonly content: ToolCallContent; |
| 313 | readonly _meta?: Meta; |
| 314 | } |
| 315 | | { |
| 316 | readonly sessionUpdate: "state_update"; |
| 317 | readonly state: "running"; |
| 318 | readonly _meta?: Meta; |
| 319 | } |
| 320 | | { |
| 321 | readonly sessionUpdate: "state_update"; |
| 322 | readonly state: "idle"; |
| 323 | readonly stopReason?: StopReason | null; |
| 324 | readonly usage?: Usage | null; |
| 325 | readonly error?: V2.Error | null; |
| 326 | readonly _meta?: Meta; |
| 327 | } |
| 328 | | { |
| 329 | readonly sessionUpdate: "state_update"; |
| 330 | readonly state: "requires_action"; |
| 331 | readonly _meta?: Meta; |
| 332 | } |
| 333 | | Extract<V2.SessionUpdate, { readonly sessionUpdate: "terminal_update" }> |
| 334 | | Extract<V2.SessionUpdate, { readonly sessionUpdate: "terminal_output_chunk" }> |
| 335 | | Extract<V2.SessionUpdate, { readonly sessionUpdate: "plan_update" }> |
| 336 | | Extract<V2.SessionUpdate, { readonly sessionUpdate: "plan_removed" }> |
| 337 | | { |
| 338 | readonly sessionUpdate: "available_commands_update"; |
| 339 | readonly availableCommands: ReadonlyArray<AvailableCommand>; |
| 340 | readonly _meta?: Meta; |
| 341 | } |
| 342 | | Extract<V2.SessionUpdate, { readonly sessionUpdate: "session_info_update" }> |
| 343 | | Extract<V2.SessionUpdate, { readonly sessionUpdate: "usage_update" }> |
| 344 | | { |
| 345 | readonly sessionUpdate: "compaction_update"; |
| 346 | readonly compactionId: string; |
| 347 | readonly status: string; |
| 348 | readonly summary?: ReadonlyArray<ContentBlock> | null; |
| 349 | readonly error?: string | null; |
| 350 | readonly _meta?: Meta; |
| 351 | } |
| 352 | | { |
| 353 | readonly sessionUpdate: "compaction_summary_chunk"; |
| 354 | readonly compactionId: string; |
| 355 | readonly content: ContentBlock; |
| 356 | readonly _meta?: Meta; |
| 357 | } |
| 358 | | { |
| 359 | readonly sessionUpdate: "config_option_update"; |
| 360 | readonly configOptions: ReadonlyArray<SessionConfigOption>; |
| 361 | readonly _meta?: Meta; |
| 362 | } |
| 363 | | { readonly sessionUpdate: "plan"; readonly entries: ReadonlyArray<V2.PlanEntry> } |
| 364 | | { readonly sessionUpdate: "current_mode_update"; readonly currentModeId: string } |
| 365 | | { |
| 366 | readonly sessionUpdate: "notice"; |
| 367 | readonly severity: string; |
| 368 | readonly title: string; |
| 369 | readonly description?: string | null; |
| 370 | readonly _meta?: Meta; |
| 371 | } |
| 372 | | { |
| 373 | readonly sessionUpdate: "_t3_unknown"; |
| 374 | readonly originalSessionUpdate: string; |
| 375 | readonly raw: unknown; |
| 376 | }; |
| 377 | |
| 378 | export interface SessionNotification { |
| 379 | readonly sessionId: string; |
| 380 | readonly update: SessionUpdate; |
| 381 | readonly _meta?: Meta; |
| 382 | } |
| 383 | |
| 384 | export type RequestPermissionRequest = { |
| 385 | readonly sessionId: string; |
| 386 | readonly title?: string; |
| 387 | readonly description?: string | null; |
| 388 | readonly subject?: V2.RequestPermissionSubject | null; |
| 389 | readonly toolCall: ToolCallUpdate; |
| 390 | readonly options: ReadonlyArray<V2.PermissionOption>; |
| 391 | readonly _meta?: Meta; |
| 392 | }; |
| 393 | export type RequestPermissionResponse = V2.RequestPermissionResponse; |
| 394 | |
| 395 | export interface ReadTextFileRequest { |
| 396 | readonly sessionId: string; |
| 397 | readonly path: string; |
| 398 | readonly line?: number | null; |
| 399 | readonly limit?: number | null; |
| 400 | } |
| 401 | export interface ReadTextFileResponse { |
| 402 | readonly content: string; |
| 403 | } |
| 404 | export interface WriteTextFileRequest { |
| 405 | readonly sessionId: string; |
| 406 | readonly path: string; |
| 407 | readonly content: string; |
| 408 | } |
| 409 | export interface WriteTextFileResponse {} |
| 410 | export interface CreateTerminalRequest { |
| 411 | readonly sessionId: string; |
| 412 | readonly command: string; |
| 413 | readonly args?: ReadonlyArray<string>; |
| 414 | readonly env?: ReadonlyArray<V2.EnvVariable>; |
| 415 | readonly cwd?: string | null; |
| 416 | readonly outputByteLimit?: number | null; |
| 417 | } |
| 418 | export interface CreateTerminalResponse { |
| 419 | readonly terminalId: string; |
| 420 | } |
| 421 | interface TerminalRequest { |
| 422 | readonly sessionId: string; |
| 423 | readonly terminalId: string; |
| 424 | } |
| 425 | export type TerminalOutputRequest = TerminalRequest; |
| 426 | export interface TerminalOutputResponse { |
| 427 | readonly output: string; |
| 428 | readonly truncated: boolean; |
| 429 | readonly exitStatus?: TerminalExitStatus | null; |
| 430 | } |
| 431 | export type WaitForTerminalExitRequest = TerminalRequest; |
| 432 | export type WaitForTerminalExitResponse = TerminalExitStatus; |
| 433 | export type KillTerminalRequest = TerminalRequest; |
| 434 | export interface KillTerminalResponse {} |
| 435 | export type ReleaseTerminalRequest = TerminalRequest; |
| 436 | export interface ReleaseTerminalResponse {} |
| 437 | |
| 438 | // Older v1 agents still advertise and select models through this removed unstable API. |
| 439 | const LegacyMeta = Schema.optionalKey(Schema.NullOr(Schema.Record(Schema.String, Schema.Json))); |
| 440 | export const ModelInfo = Schema.Struct({ |
| 441 | modelId: Schema.String, |
| 442 | name: Schema.String, |
| 443 | description: Schema.optionalKey(Schema.NullOr(Schema.String)), |
| 444 | _meta: LegacyMeta, |
| 445 | }); |
| 446 | export type ModelInfo = typeof ModelInfo.Type; |
| 447 | export const SessionModelState = Schema.Struct({ |
| 448 | currentModelId: Schema.String, |
| 449 | availableModels: Schema.Array(ModelInfo), |
| 450 | _meta: LegacyMeta, |
| 451 | }); |
| 452 | export type SessionModelState = typeof SessionModelState.Type; |
| 453 | export const SetSessionModelRequest = Schema.Struct({ |
| 454 | sessionId: Schema.String, |
| 455 | modelId: Schema.String, |
| 456 | _meta: LegacyMeta, |
| 457 | }); |
| 458 | export type SetSessionModelRequest = typeof SetSessionModelRequest.Type; |
| 459 | export const SetSessionModelResponse = Schema.Struct({ _meta: LegacyMeta }); |
| 460 | export type SetSessionModelResponse = typeof SetSessionModelResponse.Type; |
| 461 | export type PermissionOption = V2.PermissionOption; |