@letta-ai/letta-code 0.31.13 → 0.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/app-server-client.cjs +21 -1
  2. package/dist/app-server-client.cjs.map +3 -3
  3. package/dist/app-server-client.js +21 -1
  4. package/dist/app-server-client.js.map +3 -3
  5. package/dist/mcp-client.js +2 -2
  6. package/dist/mcp-client.js.map +1 -1
  7. package/dist/memory-constraints.js +160 -2
  8. package/dist/memory-constraints.js.map +3 -3
  9. package/dist/types/agent/memory-auth.d.ts +3 -0
  10. package/dist/types/agent/memory-auth.d.ts.map +1 -0
  11. package/dist/types/agent/memory-constraints.d.ts +2 -0
  12. package/dist/types/agent/memory-constraints.d.ts.map +1 -1
  13. package/dist/types/agent/memory-filesystem.d.ts.map +1 -1
  14. package/dist/types/agent/memory-git-hooks.d.ts +3 -1
  15. package/dist/types/agent/memory-git-hooks.d.ts.map +1 -1
  16. package/dist/types/agent/memory-git.d.ts +0 -6
  17. package/dist/types/agent/memory-git.d.ts.map +1 -1
  18. package/dist/types/app-server-client.d.ts +8 -1
  19. package/dist/types/app-server-client.d.ts.map +1 -1
  20. package/dist/types/auth/desktop-credentials.d.ts +16 -0
  21. package/dist/types/auth/desktop-credentials.d.ts.map +1 -0
  22. package/dist/types/backend/api/client.d.ts.map +1 -1
  23. package/dist/types/backend/api/request.d.ts.map +1 -1
  24. package/dist/types/cli/helpers/stream-processor.d.ts +1 -0
  25. package/dist/types/cli/helpers/stream-processor.d.ts.map +1 -1
  26. package/dist/types/cli/helpers/stream.d.ts +1 -0
  27. package/dist/types/cli/helpers/stream.d.ts.map +1 -1
  28. package/dist/types/memory-constraints.d.ts +23 -0
  29. package/dist/types/memory-constraints.d.ts.map +1 -1
  30. package/dist/types/queue/queue-runtime.d.ts +29 -0
  31. package/dist/types/queue/queue-runtime.d.ts.map +1 -1
  32. package/dist/types/tools/impl/github-pull-request-tracker.d.ts.map +1 -1
  33. package/dist/types/tools/impl/ls.d.ts.map +1 -1
  34. package/dist/types/tools/impl/process_manager.d.ts.map +1 -1
  35. package/dist/types/tools/impl/shell-env.d.ts.map +1 -1
  36. package/dist/types/types/protocol.d.ts +5 -1
  37. package/dist/types/types/protocol.d.ts.map +1 -1
  38. package/dist/types/types/protocol_v2.d.ts +6 -25
  39. package/dist/types/types/protocol_v2.d.ts.map +1 -1
  40. package/dist/types/types/queue-update-protocol.d.ts +22 -0
  41. package/dist/types/types/queue-update-protocol.d.ts.map +1 -1
  42. package/dist/types/types/task-control-protocol.d.ts +30 -0
  43. package/dist/types/types/task-control-protocol.d.ts.map +1 -0
  44. package/dist/types/utils/message-queue-bridge.d.ts +6 -0
  45. package/dist/types/utils/message-queue-bridge.d.ts.map +1 -1
  46. package/dist/types/utils/secrets-store.d.ts +4 -8
  47. package/dist/types/utils/secrets-store.d.ts.map +1 -1
  48. package/dist/types/websocket/listener/inbound-queue.d.ts.map +1 -1
  49. package/dist/types/websocket/listener/listener-constants.d.ts.map +1 -1
  50. package/dist/types/websocket/listener/protocol-outbound.d.ts.map +1 -1
  51. package/letta.js +16741 -8800
  52. package/package.json +2 -2
  53. package/scripts/isolated-unit-tests.json +10 -0
  54. package/scripts/source-file-size-baseline.json +10 -10
@@ -296,6 +296,16 @@ class AppServerClient {
296
296
  predicate: isAppServerInfoResponseMessage
297
297
  });
298
298
  }
299
+ stopMonitor(command, options = {}) {
300
+ return this.request({
301
+ type: "monitor_stop",
302
+ ...command,
303
+ request_id: command.request_id ?? this.nextRequestId("monitor-stop")
304
+ }, {
305
+ ...options,
306
+ predicate: (message) => message.type === "monitor_stop_response" && message.process_id === command.process_id && message.runtime.agent_id === command.runtime.agent_id && message.runtime.conversation_id === command.runtime.conversation_id
307
+ });
308
+ }
299
309
  runtimeStart(command, options = {}) {
300
310
  return this.request({
301
311
  type: "runtime_start",
@@ -336,6 +346,16 @@ class AppServerClient {
336
346
  predicate: (message) => message.type === "abort_message_response"
337
347
  });
338
348
  }
349
+ resumeQueue(command, options = {}) {
350
+ return this.request({
351
+ type: "resume_queue",
352
+ request_id: command.request_id ?? this.nextRequestId("resume-queue"),
353
+ ...command
354
+ }, {
355
+ ...options,
356
+ predicate: (message) => message.type === "resume_queue_response"
357
+ });
358
+ }
339
359
  conversationList(command = {}, options = {}) {
340
360
  return this.request({
341
361
  type: "conversation_list",
@@ -417,4 +437,4 @@ function createAppServerClient(options) {
417
437
  return new AppServerClient(options);
418
438
  }
419
439
 
420
- //# debugId=4559A8DEA89B0B8F64756E2164756E21
440
+ //# debugId=7A2FA1CDF0199CC464756E2164756E21
@@ -3,9 +3,9 @@
3
3
  "sources": ["../src/types/app-server-info.ts", "../src/app-server-client.ts"],
4
4
  "sourcesContent": [
5
5
  "export const APP_SERVER_PROTOCOL_VERSION = 1;\n\nexport interface AppServerInfoCommand {\n type: \"app_server_info\";\n /** Echoed back in the response for request correlation. */\n request_id: string;\n}\n\nexport interface AppServerInfoResponseMessage {\n type: \"app_server_info_response\";\n request_id: string;\n /** Synchronous post-auth capability discovery has no domain failure variant. */\n success: true;\n backend: \"local\" | \"api\";\n letta_code_version: string;\n /** Wire value reported by the server; clients compare it with their supported version. */\n protocol_version: number;\n capabilities: {\n agent_management: boolean;\n conversation_management: boolean;\n memory_management: boolean;\n runtime_start: boolean;\n runtime_workspace_sandbox?: boolean;\n runtime_external_tools_update?: boolean;\n split_channels: boolean;\n };\n}\n\nexport function isAppServerInfoResponseMessage(\n message: unknown,\n): message is AppServerInfoResponseMessage {\n if (!message || typeof message !== \"object\" || Array.isArray(message)) {\n return false;\n }\n\n const candidate = message as Record<string, unknown>;\n const capabilities = candidate.capabilities;\n if (\n !capabilities ||\n typeof capabilities !== \"object\" ||\n Array.isArray(capabilities)\n ) {\n return false;\n }\n\n const capabilityRecord = capabilities as Record<string, unknown>;\n return (\n candidate.type === \"app_server_info_response\" &&\n typeof candidate.request_id === \"string\" &&\n candidate.request_id.length > 0 &&\n candidate.success === true &&\n (candidate.backend === \"local\" || candidate.backend === \"api\") &&\n typeof candidate.letta_code_version === \"string\" &&\n typeof candidate.protocol_version === \"number\" &&\n Number.isInteger(candidate.protocol_version) &&\n typeof capabilityRecord.agent_management === \"boolean\" &&\n typeof capabilityRecord.conversation_management === \"boolean\" &&\n typeof capabilityRecord.memory_management === \"boolean\" &&\n typeof capabilityRecord.runtime_start === \"boolean\" &&\n (capabilityRecord.runtime_workspace_sandbox === undefined ||\n typeof capabilityRecord.runtime_workspace_sandbox === \"boolean\") &&\n (capabilityRecord.runtime_external_tools_update === undefined ||\n typeof capabilityRecord.runtime_external_tools_update === \"boolean\") &&\n typeof capabilityRecord.split_channels === \"boolean\"\n );\n}\n",
6
- "import { isAppServerInfoResponseMessage } from \"./types/app-server-info\";\n\nexport type { AppServerInfoResponseMessage } from \"./types/app-server-info\";\nexport { isAppServerInfoResponseMessage } from \"./types/app-server-info\";\n\nimport type {\n AbortMessageCommand,\n AbortMessageResponseMessage,\n AppServerInfoResponseMessage,\n ConversationListCommand,\n ConversationListResponseMessage,\n ExternalToolCallRequestMessage,\n ExternalToolCallResult,\n InputAcceptedResponseMessage,\n InputCommand,\n RuntimeExternalToolsUpdateCommand,\n RuntimeExternalToolsUpdateResponseMessage,\n RuntimeStartCommand,\n RuntimeStartResponseMessage,\n SyncCommand,\n SyncResponseMessage,\n WsProtocolCommand,\n WsProtocolMessage,\n} from \"./types/app-server-protocol\";\n\nexport type AppServerChannel = \"control\" | \"stream\";\n\nexport type AppServerRawCommand = Record<string, unknown> & {\n type: string;\n request_id?: string;\n};\n\nexport type AppServerRawResponse = Record<string, unknown> & {\n type: string;\n request_id?: string;\n};\n\nexport type AppServerSendCommand = WsProtocolCommand | AppServerRawCommand;\n\n/** Receives every parsed protocol frame from the app-server WebSocket. */\nexport type AppServerMessageHandler = (\n message: WsProtocolMessage,\n channel: AppServerChannel,\n) => void;\n\n/** Called synchronously before a typed or raw command is written to the socket. */\nexport type AppServerSendHandler = (command: AppServerSendCommand) => void;\n\nexport interface AppServerDisconnectEvent {\n channel: AppServerChannel;\n event: unknown;\n}\n\n/** Called once when the WebSocket closes before client.close(). */\nexport type AppServerDisconnectHandler = (\n disconnect: AppServerDisconnectEvent,\n) => void;\n\nexport type AppServerExternalToolCallHandler = (\n request: ExternalToolCallRequestMessage,\n) => Promise<ExternalToolCallResult> | ExternalToolCallResult;\n\nexport interface AppServerSocketLike {\n readyState: number;\n send(data: string): void;\n close(): void;\n addEventListener?(type: string, listener: (event: unknown) => void): void;\n removeEventListener?(type: string, listener: (event: unknown) => void): void;\n on?(type: string, listener: (event: unknown) => void): void;\n off?(type: string, listener: (event: unknown) => void): void;\n once?(type: string, listener: (event: unknown) => void): void;\n}\n\nexport interface AppServerSocketOptions {\n headers?: Record<string, string>;\n}\n\nexport type AppServerSocketConstructor = new (\n url: string,\n options?: AppServerSocketOptions,\n) => AppServerSocketLike;\n\nexport interface AppServerClientOptions {\n /** Base app-server URL, e.g. ws://127.0.0.1:4500 or http://127.0.0.1:4500. */\n url: string;\n /** Optional capability token sent as Authorization: Bearer <token>; requires a WebSocket implementation with header support. */\n authToken?: string;\n /** Optional WebSocket constructor for Node/tests. Browsers use globalThis.WebSocket. */\n WebSocket?: AppServerSocketConstructor;\n /** Default timeout for request_id-correlated control requests. */\n requestTimeoutMs?: number;\n}\n\nexport interface AppServerRequestOptions<TMessage extends WsProtocolMessage> {\n timeoutMs?: number;\n predicate?: (message: WsProtocolMessage) => message is TMessage;\n}\n\nexport type AppServerRequestCommand = Extract<\n WsProtocolCommand,\n { request_id?: string }\n>;\n\nexport type AppServerRequestCommandWithId = AppServerRequestCommand & {\n request_id: string;\n};\n\nexport type AppServerRequestBody = Record<string, unknown> & {\n request_id?: string;\n};\n\nexport interface AppServerRawRequestOptions<\n TResponse extends AppServerRawResponse,\n> {\n timeoutMs?: number;\n predicate: (message: unknown) => message is TResponse;\n}\n\ntype PendingRequest = {\n resolve: (message: WsProtocolMessage) => void;\n reject: (error: Error) => void;\n predicate?: (message: WsProtocolMessage) => boolean;\n timeout: ReturnType<typeof setTimeout>;\n};\n\nconst DEFAULT_REQUEST_TIMEOUT_MS = 30_000;\nconst WEBSOCKET_OPEN_STATE = 1;\n\nfunction getGlobalWebSocket(): AppServerSocketConstructor | undefined {\n return (globalThis as { WebSocket?: AppServerSocketConstructor }).WebSocket;\n}\n\nfunction normalizeBaseUrl(url: string): URL {\n const parsed = new URL(url);\n if (parsed.protocol === \"http:\") parsed.protocol = \"ws:\";\n if (parsed.protocol === \"https:\") parsed.protocol = \"wss:\";\n if (parsed.protocol !== \"ws:\" && parsed.protocol !== \"wss:\") {\n throw new Error(`Unsupported app-server URL protocol: ${parsed.protocol}`);\n }\n if (!parsed.pathname || parsed.pathname === \"/\") {\n parsed.pathname = \"/ws\";\n }\n return parsed;\n}\n\nexport function resolveAppServerUrl(url: string): string {\n const parsed = normalizeBaseUrl(url);\n parsed.searchParams.delete(\"channel\");\n return parsed.toString();\n}\n\n/**\n * @deprecated App-server uses one bidirectional WebSocket. Both historical\n * channel names resolve to that same socket URL.\n */\nexport function resolveAppServerChannelUrl(\n url: string,\n _channel: AppServerChannel,\n): string {\n return resolveAppServerUrl(url);\n}\n\nfunction attachSocketListener(\n socket: AppServerSocketLike,\n type: string,\n listener: (event: unknown) => void,\n): () => void {\n if (socket.addEventListener && socket.removeEventListener) {\n socket.addEventListener(type, listener);\n return () => socket.removeEventListener?.(type, listener);\n }\n\n if (socket.on) {\n socket.on(type, listener);\n return () => socket.off?.(type, listener);\n }\n\n throw new Error(\"WebSocket implementation does not support event listeners\");\n}\n\nfunction onceSocketEvent(\n socket: AppServerSocketLike,\n type: string,\n listener: (event: unknown) => void,\n): () => void {\n if (socket.once) {\n socket.once(type, listener);\n return () => socket.off?.(type, listener);\n }\n\n let detach = () => {};\n detach = attachSocketListener(socket, type, (event) => {\n detach();\n listener(event);\n });\n return detach;\n}\n\nfunction waitForSocketOpen(socket: AppServerSocketLike): Promise<void> {\n if (socket.readyState === WEBSOCKET_OPEN_STATE) {\n return Promise.resolve();\n }\n\n return new Promise((resolve, reject) => {\n let detachOpen = () => {};\n let detachError = () => {};\n const cleanup = () => {\n detachOpen();\n detachError();\n };\n detachOpen = onceSocketEvent(socket, \"open\", () => {\n cleanup();\n resolve();\n });\n detachError = onceSocketEvent(socket, \"error\", (event) => {\n cleanup();\n reject(\n new Error(`App-server WebSocket failed to open: ${String(event)}`),\n );\n });\n });\n}\n\nfunction rawEventData(event: unknown): unknown {\n if (event && typeof event === \"object\" && \"data\" in event) {\n return (event as { data: unknown }).data;\n }\n return event;\n}\n\nfunction messageDataToString(data: unknown): string {\n const raw = rawEventData(data);\n if (typeof raw === \"string\") return raw;\n if (raw instanceof ArrayBuffer) {\n return new TextDecoder().decode(raw);\n }\n if (raw instanceof Uint8Array) {\n return new TextDecoder().decode(raw);\n }\n if (ArrayBuffer.isView(raw)) {\n return new TextDecoder().decode(\n new Uint8Array(raw.buffer as ArrayBuffer, raw.byteOffset, raw.byteLength),\n );\n }\n return String(raw);\n}\n\nfunction parseProtocolMessage(event: unknown): WsProtocolMessage {\n return JSON.parse(messageDataToString(event)) as WsProtocolMessage;\n}\n\nfunction appServerSocketOptions(\n authToken: string | undefined,\n): AppServerSocketOptions | undefined {\n if (authToken === undefined) {\n return undefined;\n }\n const token = authToken.trim();\n if (!token) {\n throw new Error(\"app-server auth token must not be empty\");\n }\n return { headers: { Authorization: `Bearer ${token}` } };\n}\n\nexport class AppServerClient {\n readonly socket: AppServerSocketLike;\n /** @deprecated Alias for socket. */\n readonly control: AppServerSocketLike;\n /** @deprecated Alias for socket; no second stream connection is created. */\n readonly stream: AppServerSocketLike;\n\n private readonly requestTimeoutMs: number;\n private readonly pending = new Map<string, PendingRequest>();\n private readonly messageHandlers = new Set<AppServerMessageHandler>();\n private readonly sendHandlers = new Set<AppServerSendHandler>();\n private readonly disconnectHandlers = new Set<AppServerDisconnectHandler>();\n private explicitlyClosed = false;\n private disconnectNotified = false;\n private nextRequestNumber = 0;\n\n constructor(options: AppServerClientOptions) {\n const WebSocket = options.WebSocket ?? getGlobalWebSocket();\n if (!WebSocket) {\n throw new Error(\"No WebSocket implementation available\");\n }\n\n this.requestTimeoutMs =\n options.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;\n const socketOptions = appServerSocketOptions(options.authToken);\n this.socket = new WebSocket(\n resolveAppServerUrl(options.url),\n socketOptions,\n );\n this.control = this.socket;\n this.stream = this.socket;\n\n attachSocketListener(this.socket, \"message\", (event) => {\n this.handleMessage(event, \"control\");\n });\n attachSocketListener(this.socket, \"close\", (event) => {\n this.handleDisconnect(\"control\", event);\n });\n }\n\n async connect(): Promise<this> {\n await waitForSocketOpen(this.socket);\n return this;\n }\n\n close(): void {\n if (this.explicitlyClosed) return;\n this.explicitlyClosed = true;\n this.rejectAllPending(\"App-server client closed\");\n this.socket.close();\n }\n\n onMessage(handler: AppServerMessageHandler): () => void {\n this.messageHandlers.add(handler);\n return () => this.messageHandlers.delete(handler);\n }\n\n onSend(handler: AppServerSendHandler): () => void {\n this.sendHandlers.add(handler);\n return () => this.sendHandlers.delete(handler);\n }\n\n onDisconnect(handler: AppServerDisconnectHandler): () => void {\n this.disconnectHandlers.add(handler);\n return () => this.disconnectHandlers.delete(handler);\n }\n\n nextRequestId(prefix = \"req\"): string {\n this.nextRequestNumber += 1;\n return `${prefix}-${this.nextRequestNumber}`;\n }\n\n send(command: WsProtocolCommand): void {\n this.writeCommand(command);\n }\n\n private writeCommand(command: AppServerSendCommand): void {\n for (const handler of this.sendHandlers) {\n handler(command);\n }\n this.socket.send(JSON.stringify(command));\n }\n\n /**\n * Send a forward-compatible protocol command from a compatibility adapter.\n * Prefer the typed wrappers above this boundary for normal product code.\n */\n sendRaw(command: AppServerRawCommand): void {\n this.writeCommand(command);\n }\n\n /**\n * Request a forward-compatible response without mirroring the full protocol\n * union in a downstream compatibility adapter.\n */\n requestRaw<TResponse extends AppServerRawResponse>(\n command: AppServerRawCommand & { request_id: string },\n options: AppServerRawRequestOptions<TResponse>,\n ): Promise<TResponse> {\n const timeoutMs = options.timeoutMs ?? this.requestTimeoutMs;\n return new Promise((resolve, reject) => {\n const timeout = setTimeout(() => {\n this.pending.delete(command.request_id);\n reject(new Error(`Timed out waiting for ${command.request_id}`));\n }, timeoutMs);\n\n this.pending.set(command.request_id, {\n resolve: (message) => resolve(message as unknown as TResponse),\n reject,\n predicate: options.predicate,\n timeout,\n });\n\n try {\n this.sendRaw(command);\n } catch (error) {\n clearTimeout(timeout);\n this.pending.delete(command.request_id);\n reject(error instanceof Error ? error : new Error(String(error)));\n }\n });\n }\n\n request<TMessage extends WsProtocolMessage = WsProtocolMessage>(\n command: AppServerRequestCommandWithId,\n options?: AppServerRequestOptions<TMessage>,\n ): Promise<TMessage>;\n\n request<\n TType extends AppServerRequestCommand[\"type\"],\n TMessage extends WsProtocolMessage = WsProtocolMessage,\n >(\n type: TType,\n body?: AppServerRequestBody,\n options?: AppServerRequestOptions<TMessage>,\n ): Promise<TMessage>;\n\n request<TMessage extends WsProtocolMessage = WsProtocolMessage>(\n commandOrType:\n | AppServerRequestCommandWithId\n | AppServerRequestCommand[\"type\"],\n bodyOrOptions:\n | AppServerRequestBody\n | AppServerRequestOptions<TMessage> = {},\n maybeOptions: AppServerRequestOptions<TMessage> = {},\n ): Promise<TMessage> {\n const isTypeRequest = typeof commandOrType === \"string\";\n const command = isTypeRequest\n ? ({\n type: commandOrType,\n request_id:\n (bodyOrOptions as { request_id?: string }).request_id ??\n this.nextRequestId(commandOrType),\n ...(bodyOrOptions as object),\n } as AppServerRequestCommandWithId)\n : commandOrType;\n const options = isTypeRequest\n ? maybeOptions\n : (bodyOrOptions as AppServerRequestOptions<TMessage>);\n const timeoutMs = options.timeoutMs ?? this.requestTimeoutMs;\n\n return new Promise((resolve, reject) => {\n const timeout = setTimeout(() => {\n this.pending.delete(command.request_id);\n reject(new Error(`Timed out waiting for ${command.request_id}`));\n }, timeoutMs);\n\n this.pending.set(command.request_id, {\n resolve: (message) => resolve(message as TMessage),\n reject,\n predicate: options.predicate,\n timeout,\n });\n\n try {\n this.send(command);\n } catch (error) {\n clearTimeout(timeout);\n this.pending.delete(command.request_id);\n reject(error instanceof Error ? error : new Error(String(error)));\n }\n });\n }\n\n info(\n options: Omit<\n AppServerRequestOptions<AppServerInfoResponseMessage>,\n \"predicate\"\n > = {},\n ): Promise<AppServerInfoResponseMessage> {\n return this.request(\n {\n type: \"app_server_info\",\n request_id: this.nextRequestId(\"app-server-info\"),\n },\n {\n ...options,\n predicate: isAppServerInfoResponseMessage,\n },\n );\n }\n\n runtimeStart(\n command: Omit<RuntimeStartCommand, \"type\" | \"request_id\"> & {\n request_id?: string;\n },\n options: Omit<\n AppServerRequestOptions<RuntimeStartResponseMessage>,\n \"predicate\"\n > = {},\n ): Promise<RuntimeStartResponseMessage> {\n return this.request(\n {\n type: \"runtime_start\",\n request_id: command.request_id ?? this.nextRequestId(\"runtime-start\"),\n ...command,\n },\n {\n ...options,\n predicate: (message): message is RuntimeStartResponseMessage =>\n message.type === \"runtime_start_response\",\n },\n );\n }\n\n runtimeExternalToolsUpdate(\n command: Omit<RuntimeExternalToolsUpdateCommand, \"type\" | \"request_id\"> & {\n request_id?: string;\n },\n options: Omit<\n AppServerRequestOptions<RuntimeExternalToolsUpdateResponseMessage>,\n \"predicate\"\n > = {},\n ): Promise<RuntimeExternalToolsUpdateResponseMessage> {\n return this.request(\n {\n type: \"runtime_external_tools_update\",\n request_id:\n command.request_id ?? this.nextRequestId(\"runtime-external-tools\"),\n ...command,\n },\n {\n ...options,\n predicate: (\n message,\n ): message is RuntimeExternalToolsUpdateResponseMessage =>\n message.type === \"runtime_external_tools_update_response\",\n },\n );\n }\n\n sync(\n command: Omit<SyncCommand, \"type\" | \"request_id\"> & { request_id?: string },\n options: Omit<\n AppServerRequestOptions<SyncResponseMessage>,\n \"predicate\"\n > = {},\n ): Promise<SyncResponseMessage> {\n return this.request(\n {\n type: \"sync\",\n request_id: command.request_id ?? this.nextRequestId(\"sync\"),\n ...command,\n },\n {\n ...options,\n predicate: (message): message is SyncResponseMessage =>\n message.type === \"sync_response\",\n },\n );\n }\n\n abort(\n command: Omit<AbortMessageCommand, \"type\" | \"request_id\"> & {\n request_id?: string;\n },\n options: Omit<\n AppServerRequestOptions<AbortMessageResponseMessage>,\n \"predicate\"\n > = {},\n ): Promise<AbortMessageResponseMessage> {\n return this.request(\n {\n type: \"abort_message\",\n request_id: command.request_id ?? this.nextRequestId(\"abort\"),\n ...command,\n },\n {\n ...options,\n predicate: (message): message is AbortMessageResponseMessage =>\n message.type === \"abort_message_response\",\n },\n );\n }\n\n conversationList(\n command: Omit<ConversationListCommand, \"type\" | \"request_id\"> & {\n request_id?: string;\n } = {},\n options: Omit<\n AppServerRequestOptions<ConversationListResponseMessage>,\n \"predicate\"\n > = {},\n ): Promise<ConversationListResponseMessage> {\n return this.request(\n {\n type: \"conversation_list\",\n request_id:\n command.request_id ?? this.nextRequestId(\"conversation-list\"),\n ...command,\n },\n {\n ...options,\n predicate: (message): message is ConversationListResponseMessage =>\n message.type === \"conversation_list_response\",\n },\n );\n }\n\n onExternalToolCall(handler: AppServerExternalToolCallHandler): () => void {\n return this.onMessage((message, channel) => {\n if (\n channel !== \"control\" ||\n message.type !== \"external_tool_call_request\"\n ) {\n return;\n }\n\n void Promise.resolve(handler(message))\n .then((result) => {\n this.send({\n type: \"external_tool_call_response\",\n request_id: message.request_id,\n result,\n });\n })\n .catch((error) => {\n this.send({\n type: \"external_tool_call_response\",\n request_id: message.request_id,\n error: error instanceof Error ? error.message : String(error),\n });\n });\n });\n }\n\n /**\n * Submit input to a runtime. Observe progress, tool activity, approvals, and\n * terminal lifecycle events through onMessage().\n */\n input(command: Omit<InputCommand, \"type\">): void {\n this.send({ type: \"input\", ...command });\n }\n\n /**\n * Submit an input and wait only until the listener accepts it into the\n * normal dispatch/queue path. This never waits for turn completion.\n */\n submitInput(\n command: Omit<InputCommand, \"type\" | \"request_id\"> & {\n request_id?: string;\n },\n options: Omit<\n AppServerRequestOptions<InputAcceptedResponseMessage>,\n \"predicate\"\n > = {},\n ): Promise<InputAcceptedResponseMessage> {\n return this.request(\n {\n type: \"input\",\n request_id: command.request_id ?? this.nextRequestId(\"input\"),\n ...command,\n },\n {\n ...options,\n predicate: (message): message is InputAcceptedResponseMessage =>\n message.type === \"input_accepted\",\n },\n );\n }\n\n private handleMessage(event: unknown, channel: AppServerChannel): void {\n const message = parseProtocolMessage(event);\n\n for (const handler of this.messageHandlers) {\n handler(message, channel);\n }\n\n const requestId =\n message && typeof message === \"object\" && \"request_id\" in message\n ? (message as { request_id?: unknown }).request_id\n : undefined;\n if (channel !== \"control\" || typeof requestId !== \"string\") {\n return;\n }\n\n const pending = this.pending.get(requestId);\n if (!pending || (pending.predicate && !pending.predicate(message))) {\n return;\n }\n\n clearTimeout(pending.timeout);\n this.pending.delete(requestId);\n pending.resolve(message);\n }\n\n private rejectAllPending(reason: string): void {\n for (const [requestId, pending] of this.pending) {\n clearTimeout(pending.timeout);\n this.pending.delete(requestId);\n pending.reject(new Error(reason));\n }\n }\n\n private handleDisconnect(channel: AppServerChannel, event: unknown): void {\n this.rejectAllPending(\"App-server socket closed\");\n if (this.explicitlyClosed || this.disconnectNotified) return;\n this.disconnectNotified = true;\n for (const handler of this.disconnectHandlers) {\n handler({ channel, event });\n }\n }\n}\n\nexport function createAppServerClient(\n options: AppServerClientOptions,\n): AppServerClient {\n return new AppServerClient(options);\n}\n"
6
+ "import { isAppServerInfoResponseMessage } from \"./types/app-server-info\";\n\nexport type { AppServerInfoResponseMessage } from \"./types/app-server-info\";\nexport { isAppServerInfoResponseMessage } from \"./types/app-server-info\";\n\nimport type {\n AbortMessageCommand,\n AbortMessageResponseMessage,\n AppServerInfoResponseMessage,\n ConversationListCommand,\n ConversationListResponseMessage,\n ExternalToolCallRequestMessage,\n ExternalToolCallResult,\n InputAcceptedResponseMessage,\n InputCommand,\n MonitorStopCommand,\n MonitorStopResponse,\n ResumeQueueCommand,\n ResumeQueueResponseMessage,\n RuntimeExternalToolsUpdateCommand,\n RuntimeExternalToolsUpdateResponseMessage,\n RuntimeStartCommand,\n RuntimeStartResponseMessage,\n SyncCommand,\n SyncResponseMessage,\n WsProtocolCommand,\n WsProtocolMessage,\n} from \"./types/app-server-protocol\";\n\nexport type AppServerChannel = \"control\" | \"stream\";\n\nexport type AppServerRawCommand = Record<string, unknown> & {\n type: string;\n request_id?: string;\n};\n\nexport type AppServerRawResponse = Record<string, unknown> & {\n type: string;\n request_id?: string;\n};\n\nexport type AppServerSendCommand = WsProtocolCommand | AppServerRawCommand;\n\n/** Receives every parsed protocol frame from the app-server WebSocket. */\nexport type AppServerMessageHandler = (\n message: WsProtocolMessage,\n channel: AppServerChannel,\n) => void;\n\n/** Called synchronously before a typed or raw command is written to the socket. */\nexport type AppServerSendHandler = (command: AppServerSendCommand) => void;\n\nexport interface AppServerDisconnectEvent {\n channel: AppServerChannel;\n event: unknown;\n}\n\n/** Called once when the WebSocket closes before client.close(). */\nexport type AppServerDisconnectHandler = (\n disconnect: AppServerDisconnectEvent,\n) => void;\n\nexport type AppServerExternalToolCallHandler = (\n request: ExternalToolCallRequestMessage,\n) => Promise<ExternalToolCallResult> | ExternalToolCallResult;\n\nexport interface AppServerSocketLike {\n readyState: number;\n send(data: string): void;\n close(): void;\n addEventListener?(type: string, listener: (event: unknown) => void): void;\n removeEventListener?(type: string, listener: (event: unknown) => void): void;\n on?(type: string, listener: (event: unknown) => void): void;\n off?(type: string, listener: (event: unknown) => void): void;\n once?(type: string, listener: (event: unknown) => void): void;\n}\n\nexport interface AppServerSocketOptions {\n headers?: Record<string, string>;\n}\n\nexport type AppServerSocketConstructor = new (\n url: string,\n options?: AppServerSocketOptions,\n) => AppServerSocketLike;\n\nexport interface AppServerClientOptions {\n /** Base app-server URL, e.g. ws://127.0.0.1:4500 or http://127.0.0.1:4500. */\n url: string;\n /** Optional capability token sent as Authorization: Bearer <token>; requires a WebSocket implementation with header support. */\n authToken?: string;\n /** Optional WebSocket constructor for Node/tests. Browsers use globalThis.WebSocket. */\n WebSocket?: AppServerSocketConstructor;\n /** Default timeout for request_id-correlated control requests. */\n requestTimeoutMs?: number;\n}\n\nexport interface AppServerRequestOptions<TMessage extends WsProtocolMessage> {\n timeoutMs?: number;\n predicate?: (message: WsProtocolMessage) => message is TMessage;\n}\n\nexport type AppServerRequestCommand = Extract<\n WsProtocolCommand,\n { request_id?: string }\n>;\n\nexport type AppServerRequestCommandWithId = AppServerRequestCommand & {\n request_id: string;\n};\n\nexport type AppServerRequestBody = Record<string, unknown> & {\n request_id?: string;\n};\n\nexport interface AppServerRawRequestOptions<\n TResponse extends AppServerRawResponse,\n> {\n timeoutMs?: number;\n predicate: (message: unknown) => message is TResponse;\n}\n\ntype PendingRequest = {\n resolve: (message: WsProtocolMessage) => void;\n reject: (error: Error) => void;\n predicate?: (message: WsProtocolMessage) => boolean;\n timeout: ReturnType<typeof setTimeout>;\n};\n\nconst DEFAULT_REQUEST_TIMEOUT_MS = 30_000;\nconst WEBSOCKET_OPEN_STATE = 1;\n\nfunction getGlobalWebSocket(): AppServerSocketConstructor | undefined {\n return (globalThis as { WebSocket?: AppServerSocketConstructor }).WebSocket;\n}\n\nfunction normalizeBaseUrl(url: string): URL {\n const parsed = new URL(url);\n if (parsed.protocol === \"http:\") parsed.protocol = \"ws:\";\n if (parsed.protocol === \"https:\") parsed.protocol = \"wss:\";\n if (parsed.protocol !== \"ws:\" && parsed.protocol !== \"wss:\") {\n throw new Error(`Unsupported app-server URL protocol: ${parsed.protocol}`);\n }\n if (!parsed.pathname || parsed.pathname === \"/\") {\n parsed.pathname = \"/ws\";\n }\n return parsed;\n}\n\nexport function resolveAppServerUrl(url: string): string {\n const parsed = normalizeBaseUrl(url);\n parsed.searchParams.delete(\"channel\");\n return parsed.toString();\n}\n\n/**\n * @deprecated App-server uses one bidirectional WebSocket. Both historical\n * channel names resolve to that same socket URL.\n */\nexport function resolveAppServerChannelUrl(\n url: string,\n _channel: AppServerChannel,\n): string {\n return resolveAppServerUrl(url);\n}\n\nfunction attachSocketListener(\n socket: AppServerSocketLike,\n type: string,\n listener: (event: unknown) => void,\n): () => void {\n if (socket.addEventListener && socket.removeEventListener) {\n socket.addEventListener(type, listener);\n return () => socket.removeEventListener?.(type, listener);\n }\n\n if (socket.on) {\n socket.on(type, listener);\n return () => socket.off?.(type, listener);\n }\n\n throw new Error(\"WebSocket implementation does not support event listeners\");\n}\n\nfunction onceSocketEvent(\n socket: AppServerSocketLike,\n type: string,\n listener: (event: unknown) => void,\n): () => void {\n if (socket.once) {\n socket.once(type, listener);\n return () => socket.off?.(type, listener);\n }\n\n let detach = () => {};\n detach = attachSocketListener(socket, type, (event) => {\n detach();\n listener(event);\n });\n return detach;\n}\n\nfunction waitForSocketOpen(socket: AppServerSocketLike): Promise<void> {\n if (socket.readyState === WEBSOCKET_OPEN_STATE) {\n return Promise.resolve();\n }\n\n return new Promise((resolve, reject) => {\n let detachOpen = () => {};\n let detachError = () => {};\n const cleanup = () => {\n detachOpen();\n detachError();\n };\n detachOpen = onceSocketEvent(socket, \"open\", () => {\n cleanup();\n resolve();\n });\n detachError = onceSocketEvent(socket, \"error\", (event) => {\n cleanup();\n reject(\n new Error(`App-server WebSocket failed to open: ${String(event)}`),\n );\n });\n });\n}\n\nfunction rawEventData(event: unknown): unknown {\n if (event && typeof event === \"object\" && \"data\" in event) {\n return (event as { data: unknown }).data;\n }\n return event;\n}\n\nfunction messageDataToString(data: unknown): string {\n const raw = rawEventData(data);\n if (typeof raw === \"string\") return raw;\n if (raw instanceof ArrayBuffer) {\n return new TextDecoder().decode(raw);\n }\n if (raw instanceof Uint8Array) {\n return new TextDecoder().decode(raw);\n }\n if (ArrayBuffer.isView(raw)) {\n return new TextDecoder().decode(\n new Uint8Array(raw.buffer as ArrayBuffer, raw.byteOffset, raw.byteLength),\n );\n }\n return String(raw);\n}\n\nfunction parseProtocolMessage(event: unknown): WsProtocolMessage {\n return JSON.parse(messageDataToString(event)) as WsProtocolMessage;\n}\n\nfunction appServerSocketOptions(\n authToken: string | undefined,\n): AppServerSocketOptions | undefined {\n if (authToken === undefined) {\n return undefined;\n }\n const token = authToken.trim();\n if (!token) {\n throw new Error(\"app-server auth token must not be empty\");\n }\n return { headers: { Authorization: `Bearer ${token}` } };\n}\n\nexport class AppServerClient {\n readonly socket: AppServerSocketLike;\n /** @deprecated Alias for socket. */\n readonly control: AppServerSocketLike;\n /** @deprecated Alias for socket; no second stream connection is created. */\n readonly stream: AppServerSocketLike;\n\n private readonly requestTimeoutMs: number;\n private readonly pending = new Map<string, PendingRequest>();\n private readonly messageHandlers = new Set<AppServerMessageHandler>();\n private readonly sendHandlers = new Set<AppServerSendHandler>();\n private readonly disconnectHandlers = new Set<AppServerDisconnectHandler>();\n private explicitlyClosed = false;\n private disconnectNotified = false;\n private nextRequestNumber = 0;\n\n constructor(options: AppServerClientOptions) {\n const WebSocket = options.WebSocket ?? getGlobalWebSocket();\n if (!WebSocket) {\n throw new Error(\"No WebSocket implementation available\");\n }\n\n this.requestTimeoutMs =\n options.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;\n const socketOptions = appServerSocketOptions(options.authToken);\n this.socket = new WebSocket(\n resolveAppServerUrl(options.url),\n socketOptions,\n );\n this.control = this.socket;\n this.stream = this.socket;\n\n attachSocketListener(this.socket, \"message\", (event) => {\n this.handleMessage(event, \"control\");\n });\n attachSocketListener(this.socket, \"close\", (event) => {\n this.handleDisconnect(\"control\", event);\n });\n }\n\n async connect(): Promise<this> {\n await waitForSocketOpen(this.socket);\n return this;\n }\n\n close(): void {\n if (this.explicitlyClosed) return;\n this.explicitlyClosed = true;\n this.rejectAllPending(\"App-server client closed\");\n this.socket.close();\n }\n\n onMessage(handler: AppServerMessageHandler): () => void {\n this.messageHandlers.add(handler);\n return () => this.messageHandlers.delete(handler);\n }\n\n onSend(handler: AppServerSendHandler): () => void {\n this.sendHandlers.add(handler);\n return () => this.sendHandlers.delete(handler);\n }\n\n onDisconnect(handler: AppServerDisconnectHandler): () => void {\n this.disconnectHandlers.add(handler);\n return () => this.disconnectHandlers.delete(handler);\n }\n\n nextRequestId(prefix = \"req\"): string {\n this.nextRequestNumber += 1;\n return `${prefix}-${this.nextRequestNumber}`;\n }\n\n send(command: WsProtocolCommand): void {\n this.writeCommand(command);\n }\n\n private writeCommand(command: AppServerSendCommand): void {\n for (const handler of this.sendHandlers) {\n handler(command);\n }\n this.socket.send(JSON.stringify(command));\n }\n\n /**\n * Send a forward-compatible protocol command from a compatibility adapter.\n * Prefer the typed wrappers above this boundary for normal product code.\n */\n sendRaw(command: AppServerRawCommand): void {\n this.writeCommand(command);\n }\n\n /**\n * Request a forward-compatible response without mirroring the full protocol\n * union in a downstream compatibility adapter.\n */\n requestRaw<TResponse extends AppServerRawResponse>(\n command: AppServerRawCommand & { request_id: string },\n options: AppServerRawRequestOptions<TResponse>,\n ): Promise<TResponse> {\n const timeoutMs = options.timeoutMs ?? this.requestTimeoutMs;\n return new Promise((resolve, reject) => {\n const timeout = setTimeout(() => {\n this.pending.delete(command.request_id);\n reject(new Error(`Timed out waiting for ${command.request_id}`));\n }, timeoutMs);\n\n this.pending.set(command.request_id, {\n resolve: (message) => resolve(message as unknown as TResponse),\n reject,\n predicate: options.predicate,\n timeout,\n });\n\n try {\n this.sendRaw(command);\n } catch (error) {\n clearTimeout(timeout);\n this.pending.delete(command.request_id);\n reject(error instanceof Error ? error : new Error(String(error)));\n }\n });\n }\n\n request<TMessage extends WsProtocolMessage = WsProtocolMessage>(\n command: AppServerRequestCommandWithId,\n options?: AppServerRequestOptions<TMessage>,\n ): Promise<TMessage>;\n\n request<\n TType extends AppServerRequestCommand[\"type\"],\n TMessage extends WsProtocolMessage = WsProtocolMessage,\n >(\n type: TType,\n body?: AppServerRequestBody,\n options?: AppServerRequestOptions<TMessage>,\n ): Promise<TMessage>;\n\n request<TMessage extends WsProtocolMessage = WsProtocolMessage>(\n commandOrType:\n | AppServerRequestCommandWithId\n | AppServerRequestCommand[\"type\"],\n bodyOrOptions:\n | AppServerRequestBody\n | AppServerRequestOptions<TMessage> = {},\n maybeOptions: AppServerRequestOptions<TMessage> = {},\n ): Promise<TMessage> {\n const isTypeRequest = typeof commandOrType === \"string\";\n const command = isTypeRequest\n ? ({\n type: commandOrType,\n request_id:\n (bodyOrOptions as { request_id?: string }).request_id ??\n this.nextRequestId(commandOrType),\n ...(bodyOrOptions as object),\n } as AppServerRequestCommandWithId)\n : commandOrType;\n const options = isTypeRequest\n ? maybeOptions\n : (bodyOrOptions as AppServerRequestOptions<TMessage>);\n const timeoutMs = options.timeoutMs ?? this.requestTimeoutMs;\n\n return new Promise((resolve, reject) => {\n const timeout = setTimeout(() => {\n this.pending.delete(command.request_id);\n reject(new Error(`Timed out waiting for ${command.request_id}`));\n }, timeoutMs);\n\n this.pending.set(command.request_id, {\n resolve: (message) => resolve(message as TMessage),\n reject,\n predicate: options.predicate,\n timeout,\n });\n\n try {\n this.send(command);\n } catch (error) {\n clearTimeout(timeout);\n this.pending.delete(command.request_id);\n reject(error instanceof Error ? error : new Error(String(error)));\n }\n });\n }\n\n info(\n options: Omit<\n AppServerRequestOptions<AppServerInfoResponseMessage>,\n \"predicate\"\n > = {},\n ): Promise<AppServerInfoResponseMessage> {\n return this.request(\n {\n type: \"app_server_info\",\n request_id: this.nextRequestId(\"app-server-info\"),\n },\n {\n ...options,\n predicate: isAppServerInfoResponseMessage,\n },\n );\n }\n\n stopMonitor(\n command: Omit<MonitorStopCommand, \"type\" | \"request_id\"> & {\n request_id?: string;\n },\n options: Omit<\n AppServerRequestOptions<MonitorStopResponse>,\n \"predicate\"\n > = {},\n ): Promise<MonitorStopResponse> {\n return this.request(\n {\n type: \"monitor_stop\",\n ...command,\n request_id: command.request_id ?? this.nextRequestId(\"monitor-stop\"),\n },\n {\n ...options,\n predicate: (message): message is MonitorStopResponse =>\n message.type === \"monitor_stop_response\" &&\n message.process_id === command.process_id &&\n message.runtime.agent_id === command.runtime.agent_id &&\n message.runtime.conversation_id === command.runtime.conversation_id,\n },\n );\n }\n\n runtimeStart(\n command: Omit<RuntimeStartCommand, \"type\" | \"request_id\"> & {\n request_id?: string;\n },\n options: Omit<\n AppServerRequestOptions<RuntimeStartResponseMessage>,\n \"predicate\"\n > = {},\n ): Promise<RuntimeStartResponseMessage> {\n return this.request(\n {\n type: \"runtime_start\",\n request_id: command.request_id ?? this.nextRequestId(\"runtime-start\"),\n ...command,\n },\n {\n ...options,\n predicate: (message): message is RuntimeStartResponseMessage =>\n message.type === \"runtime_start_response\",\n },\n );\n }\n\n runtimeExternalToolsUpdate(\n command: Omit<RuntimeExternalToolsUpdateCommand, \"type\" | \"request_id\"> & {\n request_id?: string;\n },\n options: Omit<\n AppServerRequestOptions<RuntimeExternalToolsUpdateResponseMessage>,\n \"predicate\"\n > = {},\n ): Promise<RuntimeExternalToolsUpdateResponseMessage> {\n return this.request(\n {\n type: \"runtime_external_tools_update\",\n request_id:\n command.request_id ?? this.nextRequestId(\"runtime-external-tools\"),\n ...command,\n },\n {\n ...options,\n predicate: (\n message,\n ): message is RuntimeExternalToolsUpdateResponseMessage =>\n message.type === \"runtime_external_tools_update_response\",\n },\n );\n }\n\n sync(\n command: Omit<SyncCommand, \"type\" | \"request_id\"> & { request_id?: string },\n options: Omit<\n AppServerRequestOptions<SyncResponseMessage>,\n \"predicate\"\n > = {},\n ): Promise<SyncResponseMessage> {\n return this.request(\n {\n type: \"sync\",\n request_id: command.request_id ?? this.nextRequestId(\"sync\"),\n ...command,\n },\n {\n ...options,\n predicate: (message): message is SyncResponseMessage =>\n message.type === \"sync_response\",\n },\n );\n }\n\n abort(\n command: Omit<AbortMessageCommand, \"type\" | \"request_id\"> & {\n request_id?: string;\n },\n options: Omit<\n AppServerRequestOptions<AbortMessageResponseMessage>,\n \"predicate\"\n > = {},\n ): Promise<AbortMessageResponseMessage> {\n return this.request(\n {\n type: \"abort_message\",\n request_id: command.request_id ?? this.nextRequestId(\"abort\"),\n ...command,\n },\n {\n ...options,\n predicate: (message): message is AbortMessageResponseMessage =>\n message.type === \"abort_message_response\",\n },\n );\n }\n\n /** Release queue items parked by `abort()` without sending a new message. */\n resumeQueue(\n command: Omit<ResumeQueueCommand, \"type\" | \"request_id\"> & {\n request_id?: string;\n },\n options: Omit<\n AppServerRequestOptions<ResumeQueueResponseMessage>,\n \"predicate\"\n > = {},\n ): Promise<ResumeQueueResponseMessage> {\n return this.request(\n {\n type: \"resume_queue\",\n request_id: command.request_id ?? this.nextRequestId(\"resume-queue\"),\n ...command,\n },\n {\n ...options,\n predicate: (message): message is ResumeQueueResponseMessage =>\n message.type === \"resume_queue_response\",\n },\n );\n }\n\n conversationList(\n command: Omit<ConversationListCommand, \"type\" | \"request_id\"> & {\n request_id?: string;\n } = {},\n options: Omit<\n AppServerRequestOptions<ConversationListResponseMessage>,\n \"predicate\"\n > = {},\n ): Promise<ConversationListResponseMessage> {\n return this.request(\n {\n type: \"conversation_list\",\n request_id:\n command.request_id ?? this.nextRequestId(\"conversation-list\"),\n ...command,\n },\n {\n ...options,\n predicate: (message): message is ConversationListResponseMessage =>\n message.type === \"conversation_list_response\",\n },\n );\n }\n\n onExternalToolCall(handler: AppServerExternalToolCallHandler): () => void {\n return this.onMessage((message, channel) => {\n if (\n channel !== \"control\" ||\n message.type !== \"external_tool_call_request\"\n ) {\n return;\n }\n\n void Promise.resolve(handler(message))\n .then((result) => {\n this.send({\n type: \"external_tool_call_response\",\n request_id: message.request_id,\n result,\n });\n })\n .catch((error) => {\n this.send({\n type: \"external_tool_call_response\",\n request_id: message.request_id,\n error: error instanceof Error ? error.message : String(error),\n });\n });\n });\n }\n\n /**\n * Submit input to a runtime. Observe progress, tool activity, approvals, and\n * terminal lifecycle events through onMessage().\n */\n input(command: Omit<InputCommand, \"type\">): void {\n this.send({ type: \"input\", ...command });\n }\n\n /**\n * Submit an input and wait only until the listener accepts it into the\n * normal dispatch/queue path. This never waits for turn completion.\n */\n submitInput(\n command: Omit<InputCommand, \"type\" | \"request_id\"> & {\n request_id?: string;\n },\n options: Omit<\n AppServerRequestOptions<InputAcceptedResponseMessage>,\n \"predicate\"\n > = {},\n ): Promise<InputAcceptedResponseMessage> {\n return this.request(\n {\n type: \"input\",\n request_id: command.request_id ?? this.nextRequestId(\"input\"),\n ...command,\n },\n {\n ...options,\n predicate: (message): message is InputAcceptedResponseMessage =>\n message.type === \"input_accepted\",\n },\n );\n }\n\n private handleMessage(event: unknown, channel: AppServerChannel): void {\n const message = parseProtocolMessage(event);\n\n for (const handler of this.messageHandlers) {\n handler(message, channel);\n }\n\n const requestId =\n message && typeof message === \"object\" && \"request_id\" in message\n ? (message as { request_id?: unknown }).request_id\n : undefined;\n if (channel !== \"control\" || typeof requestId !== \"string\") {\n return;\n }\n\n const pending = this.pending.get(requestId);\n if (!pending || (pending.predicate && !pending.predicate(message))) {\n return;\n }\n\n clearTimeout(pending.timeout);\n this.pending.delete(requestId);\n pending.resolve(message);\n }\n\n private rejectAllPending(reason: string): void {\n for (const [requestId, pending] of this.pending) {\n clearTimeout(pending.timeout);\n this.pending.delete(requestId);\n pending.reject(new Error(reason));\n }\n }\n\n private handleDisconnect(channel: AppServerChannel, event: unknown): void {\n this.rejectAllPending(\"App-server socket closed\");\n if (this.explicitlyClosed || this.disconnectNotified) return;\n this.disconnectNotified = true;\n for (const handler of this.disconnectHandlers) {\n handler({ channel, event });\n }\n }\n}\n\nexport function createAppServerClient(\n options: AppServerClientOptions,\n): AppServerClient {\n return new AppServerClient(options);\n}\n"
7
7
  ],
8
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BO,SAAS,8BAA8B,CAC5C,SACyC;AAAA,EACzC,IAAI,CAAC,WAAW,OAAO,YAAY,YAAY,MAAM,QAAQ,OAAO,GAAG;AAAA,IACrE,OAAO;AAAA,EACT;AAAA,EAEA,MAAM,YAAY;AAAA,EAClB,MAAM,eAAe,UAAU;AAAA,EAC/B,IACE,CAAC,g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YAAY,gBAAgB,UACrD,QAAqC,aACtC;AAAA,IACN,IAAI,YAAY,aAAa,OAAO,cAAc,UAAU;AAAA,MAC1D;AAAA,IACF;AAAA,IAEA,MAAM,UAAU,KAAK,QAAQ,IAAI,SAAS;AAAA,IAC1C,IAAI,CAAC,WAAY,QAAQ,aAAa,CAAC,QAAQ,UAAU,OAAO,GAAI;AAAA,MAClE;AAAA,IACF;AAAA,IAEA,aAAa,QAAQ,OAAO;AAAA,IAC5B,KAAK,QAAQ,OAAO,SAAS;AAAA,IAC7B,QAAQ,QAAQ,OAAO;AAAA;AAAA,EAGjB,gBAAgB,CAAC,QAAsB;AAAA,IAC7C,YAAY,WAAW,YAAY,KAAK,SAAS;AAAA,MAC/C,aAAa,QAAQ,OAAO;AAAA,MAC5B,KAAK,QAAQ,OAAO,SAAS;AAAA,MAC7B,QAAQ,OAAO,IAAI,MAAM,MAAM,CAAC;AAAA,IAClC;AAAA;AAAA,EAGM,gBAAgB,CAAC,SAA2B,OAAsB;AAAA,IACxE,KAAK,iBAAiB,0BAA0B;AAAA,IAChD,IAAI,KAAK,oBAAoB,KAAK;AAAA,MAAoB;AAAA,IACtD,KAAK,qBAAqB;AAAA,IAC1B,WAAW,WAAW,KAAK,oBAAoB;AAAA,MAC7C,QAAQ,EAAE,SAAS,MAAM,CAAC;AAAA,IAC5B;AAAA;AAEJ;AAEO,SAAS,qBAAqB,CACnC,SACiB;AAAA,EACjB,OAAO,IAAI,gBAAgB,OAAO;AAAA;",
9
+ "debugId": "7A2FA1CDF0199CC464756E2164756E21",
10
10
  "names": []
11
11
  }
@@ -247,6 +247,16 @@ class AppServerClient {
247
247
  predicate: isAppServerInfoResponseMessage
248
248
  });
249
249
  }
250
+ stopMonitor(command, options = {}) {
251
+ return this.request({
252
+ type: "monitor_stop",
253
+ ...command,
254
+ request_id: command.request_id ?? this.nextRequestId("monitor-stop")
255
+ }, {
256
+ ...options,
257
+ predicate: (message) => message.type === "monitor_stop_response" && message.process_id === command.process_id && message.runtime.agent_id === command.runtime.agent_id && message.runtime.conversation_id === command.runtime.conversation_id
258
+ });
259
+ }
250
260
  runtimeStart(command, options = {}) {
251
261
  return this.request({
252
262
  type: "runtime_start",
@@ -287,6 +297,16 @@ class AppServerClient {
287
297
  predicate: (message) => message.type === "abort_message_response"
288
298
  });
289
299
  }
300
+ resumeQueue(command, options = {}) {
301
+ return this.request({
302
+ type: "resume_queue",
303
+ request_id: command.request_id ?? this.nextRequestId("resume-queue"),
304
+ ...command
305
+ }, {
306
+ ...options,
307
+ predicate: (message) => message.type === "resume_queue_response"
308
+ });
309
+ }
290
310
  conversationList(command = {}, options = {}) {
291
311
  return this.request({
292
312
  type: "conversation_list",
@@ -375,4 +395,4 @@ export {
375
395
  AppServerClient
376
396
  };
377
397
 
378
- //# debugId=C54C6B7A348E351D64756E2164756E21
398
+ //# debugId=447DE4754659309264756E2164756E21
@@ -3,9 +3,9 @@
3
3
  "sources": ["../src/types/app-server-info.ts", "../src/app-server-client.ts"],
4
4
  "sourcesContent": [
5
5
  "export const APP_SERVER_PROTOCOL_VERSION = 1;\n\nexport interface AppServerInfoCommand {\n type: \"app_server_info\";\n /** Echoed back in the response for request correlation. */\n request_id: string;\n}\n\nexport interface AppServerInfoResponseMessage {\n type: \"app_server_info_response\";\n request_id: string;\n /** Synchronous post-auth capability discovery has no domain failure variant. */\n success: true;\n backend: \"local\" | \"api\";\n letta_code_version: string;\n /** Wire value reported by the server; clients compare it with their supported version. */\n protocol_version: number;\n capabilities: {\n agent_management: boolean;\n conversation_management: boolean;\n memory_management: boolean;\n runtime_start: boolean;\n runtime_workspace_sandbox?: boolean;\n runtime_external_tools_update?: boolean;\n split_channels: boolean;\n };\n}\n\nexport function isAppServerInfoResponseMessage(\n message: unknown,\n): message is AppServerInfoResponseMessage {\n if (!message || typeof message !== \"object\" || Array.isArray(message)) {\n return false;\n }\n\n const candidate = message as Record<string, unknown>;\n const capabilities = candidate.capabilities;\n if (\n !capabilities ||\n typeof capabilities !== \"object\" ||\n Array.isArray(capabilities)\n ) {\n return false;\n }\n\n const capabilityRecord = capabilities as Record<string, unknown>;\n return (\n candidate.type === \"app_server_info_response\" &&\n typeof candidate.request_id === \"string\" &&\n candidate.request_id.length > 0 &&\n candidate.success === true &&\n (candidate.backend === \"local\" || candidate.backend === \"api\") &&\n typeof candidate.letta_code_version === \"string\" &&\n typeof candidate.protocol_version === \"number\" &&\n Number.isInteger(candidate.protocol_version) &&\n typeof capabilityRecord.agent_management === \"boolean\" &&\n typeof capabilityRecord.conversation_management === \"boolean\" &&\n typeof capabilityRecord.memory_management === \"boolean\" &&\n typeof capabilityRecord.runtime_start === \"boolean\" &&\n (capabilityRecord.runtime_workspace_sandbox === undefined ||\n typeof capabilityRecord.runtime_workspace_sandbox === \"boolean\") &&\n (capabilityRecord.runtime_external_tools_update === undefined ||\n typeof capabilityRecord.runtime_external_tools_update === \"boolean\") &&\n typeof capabilityRecord.split_channels === \"boolean\"\n );\n}\n",
6
- "import { isAppServerInfoResponseMessage } from \"./types/app-server-info\";\n\nexport type { AppServerInfoResponseMessage } from \"./types/app-server-info\";\nexport { isAppServerInfoResponseMessage } from \"./types/app-server-info\";\n\nimport type {\n AbortMessageCommand,\n AbortMessageResponseMessage,\n AppServerInfoResponseMessage,\n ConversationListCommand,\n ConversationListResponseMessage,\n ExternalToolCallRequestMessage,\n ExternalToolCallResult,\n InputAcceptedResponseMessage,\n InputCommand,\n RuntimeExternalToolsUpdateCommand,\n RuntimeExternalToolsUpdateResponseMessage,\n RuntimeStartCommand,\n RuntimeStartResponseMessage,\n SyncCommand,\n SyncResponseMessage,\n WsProtocolCommand,\n WsProtocolMessage,\n} from \"./types/app-server-protocol\";\n\nexport type AppServerChannel = \"control\" | \"stream\";\n\nexport type AppServerRawCommand = Record<string, unknown> & {\n type: string;\n request_id?: string;\n};\n\nexport type AppServerRawResponse = Record<string, unknown> & {\n type: string;\n request_id?: string;\n};\n\nexport type AppServerSendCommand = WsProtocolCommand | AppServerRawCommand;\n\n/** Receives every parsed protocol frame from the app-server WebSocket. */\nexport type AppServerMessageHandler = (\n message: WsProtocolMessage,\n channel: AppServerChannel,\n) => void;\n\n/** Called synchronously before a typed or raw command is written to the socket. */\nexport type AppServerSendHandler = (command: AppServerSendCommand) => void;\n\nexport interface AppServerDisconnectEvent {\n channel: AppServerChannel;\n event: unknown;\n}\n\n/** Called once when the WebSocket closes before client.close(). */\nexport type AppServerDisconnectHandler = (\n disconnect: AppServerDisconnectEvent,\n) => void;\n\nexport type AppServerExternalToolCallHandler = (\n request: ExternalToolCallRequestMessage,\n) => Promise<ExternalToolCallResult> | ExternalToolCallResult;\n\nexport interface AppServerSocketLike {\n readyState: number;\n send(data: string): void;\n close(): void;\n addEventListener?(type: string, listener: (event: unknown) => void): void;\n removeEventListener?(type: string, listener: (event: unknown) => void): void;\n on?(type: string, listener: (event: unknown) => void): void;\n off?(type: string, listener: (event: unknown) => void): void;\n once?(type: string, listener: (event: unknown) => void): void;\n}\n\nexport interface AppServerSocketOptions {\n headers?: Record<string, string>;\n}\n\nexport type AppServerSocketConstructor = new (\n url: string,\n options?: AppServerSocketOptions,\n) => AppServerSocketLike;\n\nexport interface AppServerClientOptions {\n /** Base app-server URL, e.g. ws://127.0.0.1:4500 or http://127.0.0.1:4500. */\n url: string;\n /** Optional capability token sent as Authorization: Bearer <token>; requires a WebSocket implementation with header support. */\n authToken?: string;\n /** Optional WebSocket constructor for Node/tests. Browsers use globalThis.WebSocket. */\n WebSocket?: AppServerSocketConstructor;\n /** Default timeout for request_id-correlated control requests. */\n requestTimeoutMs?: number;\n}\n\nexport interface AppServerRequestOptions<TMessage extends WsProtocolMessage> {\n timeoutMs?: number;\n predicate?: (message: WsProtocolMessage) => message is TMessage;\n}\n\nexport type AppServerRequestCommand = Extract<\n WsProtocolCommand,\n { request_id?: string }\n>;\n\nexport type AppServerRequestCommandWithId = AppServerRequestCommand & {\n request_id: string;\n};\n\nexport type AppServerRequestBody = Record<string, unknown> & {\n request_id?: string;\n};\n\nexport interface AppServerRawRequestOptions<\n TResponse extends AppServerRawResponse,\n> {\n timeoutMs?: number;\n predicate: (message: unknown) => message is TResponse;\n}\n\ntype PendingRequest = {\n resolve: (message: WsProtocolMessage) => void;\n reject: (error: Error) => void;\n predicate?: (message: WsProtocolMessage) => boolean;\n timeout: ReturnType<typeof setTimeout>;\n};\n\nconst DEFAULT_REQUEST_TIMEOUT_MS = 30_000;\nconst WEBSOCKET_OPEN_STATE = 1;\n\nfunction getGlobalWebSocket(): AppServerSocketConstructor | undefined {\n return (globalThis as { WebSocket?: AppServerSocketConstructor }).WebSocket;\n}\n\nfunction normalizeBaseUrl(url: string): URL {\n const parsed = new URL(url);\n if (parsed.protocol === \"http:\") parsed.protocol = \"ws:\";\n if (parsed.protocol === \"https:\") parsed.protocol = \"wss:\";\n if (parsed.protocol !== \"ws:\" && parsed.protocol !== \"wss:\") {\n throw new Error(`Unsupported app-server URL protocol: ${parsed.protocol}`);\n }\n if (!parsed.pathname || parsed.pathname === \"/\") {\n parsed.pathname = \"/ws\";\n }\n return parsed;\n}\n\nexport function resolveAppServerUrl(url: string): string {\n const parsed = normalizeBaseUrl(url);\n parsed.searchParams.delete(\"channel\");\n return parsed.toString();\n}\n\n/**\n * @deprecated App-server uses one bidirectional WebSocket. Both historical\n * channel names resolve to that same socket URL.\n */\nexport function resolveAppServerChannelUrl(\n url: string,\n _channel: AppServerChannel,\n): string {\n return resolveAppServerUrl(url);\n}\n\nfunction attachSocketListener(\n socket: AppServerSocketLike,\n type: string,\n listener: (event: unknown) => void,\n): () => void {\n if (socket.addEventListener && socket.removeEventListener) {\n socket.addEventListener(type, listener);\n return () => socket.removeEventListener?.(type, listener);\n }\n\n if (socket.on) {\n socket.on(type, listener);\n return () => socket.off?.(type, listener);\n }\n\n throw new Error(\"WebSocket implementation does not support event listeners\");\n}\n\nfunction onceSocketEvent(\n socket: AppServerSocketLike,\n type: string,\n listener: (event: unknown) => void,\n): () => void {\n if (socket.once) {\n socket.once(type, listener);\n return () => socket.off?.(type, listener);\n }\n\n let detach = () => {};\n detach = attachSocketListener(socket, type, (event) => {\n detach();\n listener(event);\n });\n return detach;\n}\n\nfunction waitForSocketOpen(socket: AppServerSocketLike): Promise<void> {\n if (socket.readyState === WEBSOCKET_OPEN_STATE) {\n return Promise.resolve();\n }\n\n return new Promise((resolve, reject) => {\n let detachOpen = () => {};\n let detachError = () => {};\n const cleanup = () => {\n detachOpen();\n detachError();\n };\n detachOpen = onceSocketEvent(socket, \"open\", () => {\n cleanup();\n resolve();\n });\n detachError = onceSocketEvent(socket, \"error\", (event) => {\n cleanup();\n reject(\n new Error(`App-server WebSocket failed to open: ${String(event)}`),\n );\n });\n });\n}\n\nfunction rawEventData(event: unknown): unknown {\n if (event && typeof event === \"object\" && \"data\" in event) {\n return (event as { data: unknown }).data;\n }\n return event;\n}\n\nfunction messageDataToString(data: unknown): string {\n const raw = rawEventData(data);\n if (typeof raw === \"string\") return raw;\n if (raw instanceof ArrayBuffer) {\n return new TextDecoder().decode(raw);\n }\n if (raw instanceof Uint8Array) {\n return new TextDecoder().decode(raw);\n }\n if (ArrayBuffer.isView(raw)) {\n return new TextDecoder().decode(\n new Uint8Array(raw.buffer as ArrayBuffer, raw.byteOffset, raw.byteLength),\n );\n }\n return String(raw);\n}\n\nfunction parseProtocolMessage(event: unknown): WsProtocolMessage {\n return JSON.parse(messageDataToString(event)) as WsProtocolMessage;\n}\n\nfunction appServerSocketOptions(\n authToken: string | undefined,\n): AppServerSocketOptions | undefined {\n if (authToken === undefined) {\n return undefined;\n }\n const token = authToken.trim();\n if (!token) {\n throw new Error(\"app-server auth token must not be empty\");\n }\n return { headers: { Authorization: `Bearer ${token}` } };\n}\n\nexport class AppServerClient {\n readonly socket: AppServerSocketLike;\n /** @deprecated Alias for socket. */\n readonly control: AppServerSocketLike;\n /** @deprecated Alias for socket; no second stream connection is created. */\n readonly stream: AppServerSocketLike;\n\n private readonly requestTimeoutMs: number;\n private readonly pending = new Map<string, PendingRequest>();\n private readonly messageHandlers = new Set<AppServerMessageHandler>();\n private readonly sendHandlers = new Set<AppServerSendHandler>();\n private readonly disconnectHandlers = new Set<AppServerDisconnectHandler>();\n private explicitlyClosed = false;\n private disconnectNotified = false;\n private nextRequestNumber = 0;\n\n constructor(options: AppServerClientOptions) {\n const WebSocket = options.WebSocket ?? getGlobalWebSocket();\n if (!WebSocket) {\n throw new Error(\"No WebSocket implementation available\");\n }\n\n this.requestTimeoutMs =\n options.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;\n const socketOptions = appServerSocketOptions(options.authToken);\n this.socket = new WebSocket(\n resolveAppServerUrl(options.url),\n socketOptions,\n );\n this.control = this.socket;\n this.stream = this.socket;\n\n attachSocketListener(this.socket, \"message\", (event) => {\n this.handleMessage(event, \"control\");\n });\n attachSocketListener(this.socket, \"close\", (event) => {\n this.handleDisconnect(\"control\", event);\n });\n }\n\n async connect(): Promise<this> {\n await waitForSocketOpen(this.socket);\n return this;\n }\n\n close(): void {\n if (this.explicitlyClosed) return;\n this.explicitlyClosed = true;\n this.rejectAllPending(\"App-server client closed\");\n this.socket.close();\n }\n\n onMessage(handler: AppServerMessageHandler): () => void {\n this.messageHandlers.add(handler);\n return () => this.messageHandlers.delete(handler);\n }\n\n onSend(handler: AppServerSendHandler): () => void {\n this.sendHandlers.add(handler);\n return () => this.sendHandlers.delete(handler);\n }\n\n onDisconnect(handler: AppServerDisconnectHandler): () => void {\n this.disconnectHandlers.add(handler);\n return () => this.disconnectHandlers.delete(handler);\n }\n\n nextRequestId(prefix = \"req\"): string {\n this.nextRequestNumber += 1;\n return `${prefix}-${this.nextRequestNumber}`;\n }\n\n send(command: WsProtocolCommand): void {\n this.writeCommand(command);\n }\n\n private writeCommand(command: AppServerSendCommand): void {\n for (const handler of this.sendHandlers) {\n handler(command);\n }\n this.socket.send(JSON.stringify(command));\n }\n\n /**\n * Send a forward-compatible protocol command from a compatibility adapter.\n * Prefer the typed wrappers above this boundary for normal product code.\n */\n sendRaw(command: AppServerRawCommand): void {\n this.writeCommand(command);\n }\n\n /**\n * Request a forward-compatible response without mirroring the full protocol\n * union in a downstream compatibility adapter.\n */\n requestRaw<TResponse extends AppServerRawResponse>(\n command: AppServerRawCommand & { request_id: string },\n options: AppServerRawRequestOptions<TResponse>,\n ): Promise<TResponse> {\n const timeoutMs = options.timeoutMs ?? this.requestTimeoutMs;\n return new Promise((resolve, reject) => {\n const timeout = setTimeout(() => {\n this.pending.delete(command.request_id);\n reject(new Error(`Timed out waiting for ${command.request_id}`));\n }, timeoutMs);\n\n this.pending.set(command.request_id, {\n resolve: (message) => resolve(message as unknown as TResponse),\n reject,\n predicate: options.predicate,\n timeout,\n });\n\n try {\n this.sendRaw(command);\n } catch (error) {\n clearTimeout(timeout);\n this.pending.delete(command.request_id);\n reject(error instanceof Error ? error : new Error(String(error)));\n }\n });\n }\n\n request<TMessage extends WsProtocolMessage = WsProtocolMessage>(\n command: AppServerRequestCommandWithId,\n options?: AppServerRequestOptions<TMessage>,\n ): Promise<TMessage>;\n\n request<\n TType extends AppServerRequestCommand[\"type\"],\n TMessage extends WsProtocolMessage = WsProtocolMessage,\n >(\n type: TType,\n body?: AppServerRequestBody,\n options?: AppServerRequestOptions<TMessage>,\n ): Promise<TMessage>;\n\n request<TMessage extends WsProtocolMessage = WsProtocolMessage>(\n commandOrType:\n | AppServerRequestCommandWithId\n | AppServerRequestCommand[\"type\"],\n bodyOrOptions:\n | AppServerRequestBody\n | AppServerRequestOptions<TMessage> = {},\n maybeOptions: AppServerRequestOptions<TMessage> = {},\n ): Promise<TMessage> {\n const isTypeRequest = typeof commandOrType === \"string\";\n const command = isTypeRequest\n ? ({\n type: commandOrType,\n request_id:\n (bodyOrOptions as { request_id?: string }).request_id ??\n this.nextRequestId(commandOrType),\n ...(bodyOrOptions as object),\n } as AppServerRequestCommandWithId)\n : commandOrType;\n const options = isTypeRequest\n ? maybeOptions\n : (bodyOrOptions as AppServerRequestOptions<TMessage>);\n const timeoutMs = options.timeoutMs ?? this.requestTimeoutMs;\n\n return new Promise((resolve, reject) => {\n const timeout = setTimeout(() => {\n this.pending.delete(command.request_id);\n reject(new Error(`Timed out waiting for ${command.request_id}`));\n }, timeoutMs);\n\n this.pending.set(command.request_id, {\n resolve: (message) => resolve(message as TMessage),\n reject,\n predicate: options.predicate,\n timeout,\n });\n\n try {\n this.send(command);\n } catch (error) {\n clearTimeout(timeout);\n this.pending.delete(command.request_id);\n reject(error instanceof Error ? error : new Error(String(error)));\n }\n });\n }\n\n info(\n options: Omit<\n AppServerRequestOptions<AppServerInfoResponseMessage>,\n \"predicate\"\n > = {},\n ): Promise<AppServerInfoResponseMessage> {\n return this.request(\n {\n type: \"app_server_info\",\n request_id: this.nextRequestId(\"app-server-info\"),\n },\n {\n ...options,\n predicate: isAppServerInfoResponseMessage,\n },\n );\n }\n\n runtimeStart(\n command: Omit<RuntimeStartCommand, \"type\" | \"request_id\"> & {\n request_id?: string;\n },\n options: Omit<\n AppServerRequestOptions<RuntimeStartResponseMessage>,\n \"predicate\"\n > = {},\n ): Promise<RuntimeStartResponseMessage> {\n return this.request(\n {\n type: \"runtime_start\",\n request_id: command.request_id ?? this.nextRequestId(\"runtime-start\"),\n ...command,\n },\n {\n ...options,\n predicate: (message): message is RuntimeStartResponseMessage =>\n message.type === \"runtime_start_response\",\n },\n );\n }\n\n runtimeExternalToolsUpdate(\n command: Omit<RuntimeExternalToolsUpdateCommand, \"type\" | \"request_id\"> & {\n request_id?: string;\n },\n options: Omit<\n AppServerRequestOptions<RuntimeExternalToolsUpdateResponseMessage>,\n \"predicate\"\n > = {},\n ): Promise<RuntimeExternalToolsUpdateResponseMessage> {\n return this.request(\n {\n type: \"runtime_external_tools_update\",\n request_id:\n command.request_id ?? this.nextRequestId(\"runtime-external-tools\"),\n ...command,\n },\n {\n ...options,\n predicate: (\n message,\n ): message is RuntimeExternalToolsUpdateResponseMessage =>\n message.type === \"runtime_external_tools_update_response\",\n },\n );\n }\n\n sync(\n command: Omit<SyncCommand, \"type\" | \"request_id\"> & { request_id?: string },\n options: Omit<\n AppServerRequestOptions<SyncResponseMessage>,\n \"predicate\"\n > = {},\n ): Promise<SyncResponseMessage> {\n return this.request(\n {\n type: \"sync\",\n request_id: command.request_id ?? this.nextRequestId(\"sync\"),\n ...command,\n },\n {\n ...options,\n predicate: (message): message is SyncResponseMessage =>\n message.type === \"sync_response\",\n },\n );\n }\n\n abort(\n command: Omit<AbortMessageCommand, \"type\" | \"request_id\"> & {\n request_id?: string;\n },\n options: Omit<\n AppServerRequestOptions<AbortMessageResponseMessage>,\n \"predicate\"\n > = {},\n ): Promise<AbortMessageResponseMessage> {\n return this.request(\n {\n type: \"abort_message\",\n request_id: command.request_id ?? this.nextRequestId(\"abort\"),\n ...command,\n },\n {\n ...options,\n predicate: (message): message is AbortMessageResponseMessage =>\n message.type === \"abort_message_response\",\n },\n );\n }\n\n conversationList(\n command: Omit<ConversationListCommand, \"type\" | \"request_id\"> & {\n request_id?: string;\n } = {},\n options: Omit<\n AppServerRequestOptions<ConversationListResponseMessage>,\n \"predicate\"\n > = {},\n ): Promise<ConversationListResponseMessage> {\n return this.request(\n {\n type: \"conversation_list\",\n request_id:\n command.request_id ?? this.nextRequestId(\"conversation-list\"),\n ...command,\n },\n {\n ...options,\n predicate: (message): message is ConversationListResponseMessage =>\n message.type === \"conversation_list_response\",\n },\n );\n }\n\n onExternalToolCall(handler: AppServerExternalToolCallHandler): () => void {\n return this.onMessage((message, channel) => {\n if (\n channel !== \"control\" ||\n message.type !== \"external_tool_call_request\"\n ) {\n return;\n }\n\n void Promise.resolve(handler(message))\n .then((result) => {\n this.send({\n type: \"external_tool_call_response\",\n request_id: message.request_id,\n result,\n });\n })\n .catch((error) => {\n this.send({\n type: \"external_tool_call_response\",\n request_id: message.request_id,\n error: error instanceof Error ? error.message : String(error),\n });\n });\n });\n }\n\n /**\n * Submit input to a runtime. Observe progress, tool activity, approvals, and\n * terminal lifecycle events through onMessage().\n */\n input(command: Omit<InputCommand, \"type\">): void {\n this.send({ type: \"input\", ...command });\n }\n\n /**\n * Submit an input and wait only until the listener accepts it into the\n * normal dispatch/queue path. This never waits for turn completion.\n */\n submitInput(\n command: Omit<InputCommand, \"type\" | \"request_id\"> & {\n request_id?: string;\n },\n options: Omit<\n AppServerRequestOptions<InputAcceptedResponseMessage>,\n \"predicate\"\n > = {},\n ): Promise<InputAcceptedResponseMessage> {\n return this.request(\n {\n type: \"input\",\n request_id: command.request_id ?? this.nextRequestId(\"input\"),\n ...command,\n },\n {\n ...options,\n predicate: (message): message is InputAcceptedResponseMessage =>\n message.type === \"input_accepted\",\n },\n );\n }\n\n private handleMessage(event: unknown, channel: AppServerChannel): void {\n const message = parseProtocolMessage(event);\n\n for (const handler of this.messageHandlers) {\n handler(message, channel);\n }\n\n const requestId =\n message && typeof message === \"object\" && \"request_id\" in message\n ? (message as { request_id?: unknown }).request_id\n : undefined;\n if (channel !== \"control\" || typeof requestId !== \"string\") {\n return;\n }\n\n const pending = this.pending.get(requestId);\n if (!pending || (pending.predicate && !pending.predicate(message))) {\n return;\n }\n\n clearTimeout(pending.timeout);\n this.pending.delete(requestId);\n pending.resolve(message);\n }\n\n private rejectAllPending(reason: string): void {\n for (const [requestId, pending] of this.pending) {\n clearTimeout(pending.timeout);\n this.pending.delete(requestId);\n pending.reject(new Error(reason));\n }\n }\n\n private handleDisconnect(channel: AppServerChannel, event: unknown): void {\n this.rejectAllPending(\"App-server socket closed\");\n if (this.explicitlyClosed || this.disconnectNotified) return;\n this.disconnectNotified = true;\n for (const handler of this.disconnectHandlers) {\n handler({ channel, event });\n }\n }\n}\n\nexport function createAppServerClient(\n options: AppServerClientOptions,\n): AppServerClient {\n return new AppServerClient(options);\n}\n"
6
+ "import { isAppServerInfoResponseMessage } from \"./types/app-server-info\";\n\nexport type { AppServerInfoResponseMessage } from \"./types/app-server-info\";\nexport { isAppServerInfoResponseMessage } from \"./types/app-server-info\";\n\nimport type {\n AbortMessageCommand,\n AbortMessageResponseMessage,\n AppServerInfoResponseMessage,\n ConversationListCommand,\n ConversationListResponseMessage,\n ExternalToolCallRequestMessage,\n ExternalToolCallResult,\n InputAcceptedResponseMessage,\n InputCommand,\n MonitorStopCommand,\n MonitorStopResponse,\n ResumeQueueCommand,\n ResumeQueueResponseMessage,\n RuntimeExternalToolsUpdateCommand,\n RuntimeExternalToolsUpdateResponseMessage,\n RuntimeStartCommand,\n RuntimeStartResponseMessage,\n SyncCommand,\n SyncResponseMessage,\n WsProtocolCommand,\n WsProtocolMessage,\n} from \"./types/app-server-protocol\";\n\nexport type AppServerChannel = \"control\" | \"stream\";\n\nexport type AppServerRawCommand = Record<string, unknown> & {\n type: string;\n request_id?: string;\n};\n\nexport type AppServerRawResponse = Record<string, unknown> & {\n type: string;\n request_id?: string;\n};\n\nexport type AppServerSendCommand = WsProtocolCommand | AppServerRawCommand;\n\n/** Receives every parsed protocol frame from the app-server WebSocket. */\nexport type AppServerMessageHandler = (\n message: WsProtocolMessage,\n channel: AppServerChannel,\n) => void;\n\n/** Called synchronously before a typed or raw command is written to the socket. */\nexport type AppServerSendHandler = (command: AppServerSendCommand) => void;\n\nexport interface AppServerDisconnectEvent {\n channel: AppServerChannel;\n event: unknown;\n}\n\n/** Called once when the WebSocket closes before client.close(). */\nexport type AppServerDisconnectHandler = (\n disconnect: AppServerDisconnectEvent,\n) => void;\n\nexport type AppServerExternalToolCallHandler = (\n request: ExternalToolCallRequestMessage,\n) => Promise<ExternalToolCallResult> | ExternalToolCallResult;\n\nexport interface AppServerSocketLike {\n readyState: number;\n send(data: string): void;\n close(): void;\n addEventListener?(type: string, listener: (event: unknown) => void): void;\n removeEventListener?(type: string, listener: (event: unknown) => void): void;\n on?(type: string, listener: (event: unknown) => void): void;\n off?(type: string, listener: (event: unknown) => void): void;\n once?(type: string, listener: (event: unknown) => void): void;\n}\n\nexport interface AppServerSocketOptions {\n headers?: Record<string, string>;\n}\n\nexport type AppServerSocketConstructor = new (\n url: string,\n options?: AppServerSocketOptions,\n) => AppServerSocketLike;\n\nexport interface AppServerClientOptions {\n /** Base app-server URL, e.g. ws://127.0.0.1:4500 or http://127.0.0.1:4500. */\n url: string;\n /** Optional capability token sent as Authorization: Bearer <token>; requires a WebSocket implementation with header support. */\n authToken?: string;\n /** Optional WebSocket constructor for Node/tests. Browsers use globalThis.WebSocket. */\n WebSocket?: AppServerSocketConstructor;\n /** Default timeout for request_id-correlated control requests. */\n requestTimeoutMs?: number;\n}\n\nexport interface AppServerRequestOptions<TMessage extends WsProtocolMessage> {\n timeoutMs?: number;\n predicate?: (message: WsProtocolMessage) => message is TMessage;\n}\n\nexport type AppServerRequestCommand = Extract<\n WsProtocolCommand,\n { request_id?: string }\n>;\n\nexport type AppServerRequestCommandWithId = AppServerRequestCommand & {\n request_id: string;\n};\n\nexport type AppServerRequestBody = Record<string, unknown> & {\n request_id?: string;\n};\n\nexport interface AppServerRawRequestOptions<\n TResponse extends AppServerRawResponse,\n> {\n timeoutMs?: number;\n predicate: (message: unknown) => message is TResponse;\n}\n\ntype PendingRequest = {\n resolve: (message: WsProtocolMessage) => void;\n reject: (error: Error) => void;\n predicate?: (message: WsProtocolMessage) => boolean;\n timeout: ReturnType<typeof setTimeout>;\n};\n\nconst DEFAULT_REQUEST_TIMEOUT_MS = 30_000;\nconst WEBSOCKET_OPEN_STATE = 1;\n\nfunction getGlobalWebSocket(): AppServerSocketConstructor | undefined {\n return (globalThis as { WebSocket?: AppServerSocketConstructor }).WebSocket;\n}\n\nfunction normalizeBaseUrl(url: string): URL {\n const parsed = new URL(url);\n if (parsed.protocol === \"http:\") parsed.protocol = \"ws:\";\n if (parsed.protocol === \"https:\") parsed.protocol = \"wss:\";\n if (parsed.protocol !== \"ws:\" && parsed.protocol !== \"wss:\") {\n throw new Error(`Unsupported app-server URL protocol: ${parsed.protocol}`);\n }\n if (!parsed.pathname || parsed.pathname === \"/\") {\n parsed.pathname = \"/ws\";\n }\n return parsed;\n}\n\nexport function resolveAppServerUrl(url: string): string {\n const parsed = normalizeBaseUrl(url);\n parsed.searchParams.delete(\"channel\");\n return parsed.toString();\n}\n\n/**\n * @deprecated App-server uses one bidirectional WebSocket. Both historical\n * channel names resolve to that same socket URL.\n */\nexport function resolveAppServerChannelUrl(\n url: string,\n _channel: AppServerChannel,\n): string {\n return resolveAppServerUrl(url);\n}\n\nfunction attachSocketListener(\n socket: AppServerSocketLike,\n type: string,\n listener: (event: unknown) => void,\n): () => void {\n if (socket.addEventListener && socket.removeEventListener) {\n socket.addEventListener(type, listener);\n return () => socket.removeEventListener?.(type, listener);\n }\n\n if (socket.on) {\n socket.on(type, listener);\n return () => socket.off?.(type, listener);\n }\n\n throw new Error(\"WebSocket implementation does not support event listeners\");\n}\n\nfunction onceSocketEvent(\n socket: AppServerSocketLike,\n type: string,\n listener: (event: unknown) => void,\n): () => void {\n if (socket.once) {\n socket.once(type, listener);\n return () => socket.off?.(type, listener);\n }\n\n let detach = () => {};\n detach = attachSocketListener(socket, type, (event) => {\n detach();\n listener(event);\n });\n return detach;\n}\n\nfunction waitForSocketOpen(socket: AppServerSocketLike): Promise<void> {\n if (socket.readyState === WEBSOCKET_OPEN_STATE) {\n return Promise.resolve();\n }\n\n return new Promise((resolve, reject) => {\n let detachOpen = () => {};\n let detachError = () => {};\n const cleanup = () => {\n detachOpen();\n detachError();\n };\n detachOpen = onceSocketEvent(socket, \"open\", () => {\n cleanup();\n resolve();\n });\n detachError = onceSocketEvent(socket, \"error\", (event) => {\n cleanup();\n reject(\n new Error(`App-server WebSocket failed to open: ${String(event)}`),\n );\n });\n });\n}\n\nfunction rawEventData(event: unknown): unknown {\n if (event && typeof event === \"object\" && \"data\" in event) {\n return (event as { data: unknown }).data;\n }\n return event;\n}\n\nfunction messageDataToString(data: unknown): string {\n const raw = rawEventData(data);\n if (typeof raw === \"string\") return raw;\n if (raw instanceof ArrayBuffer) {\n return new TextDecoder().decode(raw);\n }\n if (raw instanceof Uint8Array) {\n return new TextDecoder().decode(raw);\n }\n if (ArrayBuffer.isView(raw)) {\n return new TextDecoder().decode(\n new Uint8Array(raw.buffer as ArrayBuffer, raw.byteOffset, raw.byteLength),\n );\n }\n return String(raw);\n}\n\nfunction parseProtocolMessage(event: unknown): WsProtocolMessage {\n return JSON.parse(messageDataToString(event)) as WsProtocolMessage;\n}\n\nfunction appServerSocketOptions(\n authToken: string | undefined,\n): AppServerSocketOptions | undefined {\n if (authToken === undefined) {\n return undefined;\n }\n const token = authToken.trim();\n if (!token) {\n throw new Error(\"app-server auth token must not be empty\");\n }\n return { headers: { Authorization: `Bearer ${token}` } };\n}\n\nexport class AppServerClient {\n readonly socket: AppServerSocketLike;\n /** @deprecated Alias for socket. */\n readonly control: AppServerSocketLike;\n /** @deprecated Alias for socket; no second stream connection is created. */\n readonly stream: AppServerSocketLike;\n\n private readonly requestTimeoutMs: number;\n private readonly pending = new Map<string, PendingRequest>();\n private readonly messageHandlers = new Set<AppServerMessageHandler>();\n private readonly sendHandlers = new Set<AppServerSendHandler>();\n private readonly disconnectHandlers = new Set<AppServerDisconnectHandler>();\n private explicitlyClosed = false;\n private disconnectNotified = false;\n private nextRequestNumber = 0;\n\n constructor(options: AppServerClientOptions) {\n const WebSocket = options.WebSocket ?? getGlobalWebSocket();\n if (!WebSocket) {\n throw new Error(\"No WebSocket implementation available\");\n }\n\n this.requestTimeoutMs =\n options.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;\n const socketOptions = appServerSocketOptions(options.authToken);\n this.socket = new WebSocket(\n resolveAppServerUrl(options.url),\n socketOptions,\n );\n this.control = this.socket;\n this.stream = this.socket;\n\n attachSocketListener(this.socket, \"message\", (event) => {\n this.handleMessage(event, \"control\");\n });\n attachSocketListener(this.socket, \"close\", (event) => {\n this.handleDisconnect(\"control\", event);\n });\n }\n\n async connect(): Promise<this> {\n await waitForSocketOpen(this.socket);\n return this;\n }\n\n close(): void {\n if (this.explicitlyClosed) return;\n this.explicitlyClosed = true;\n this.rejectAllPending(\"App-server client closed\");\n this.socket.close();\n }\n\n onMessage(handler: AppServerMessageHandler): () => void {\n this.messageHandlers.add(handler);\n return () => this.messageHandlers.delete(handler);\n }\n\n onSend(handler: AppServerSendHandler): () => void {\n this.sendHandlers.add(handler);\n return () => this.sendHandlers.delete(handler);\n }\n\n onDisconnect(handler: AppServerDisconnectHandler): () => void {\n this.disconnectHandlers.add(handler);\n return () => this.disconnectHandlers.delete(handler);\n }\n\n nextRequestId(prefix = \"req\"): string {\n this.nextRequestNumber += 1;\n return `${prefix}-${this.nextRequestNumber}`;\n }\n\n send(command: WsProtocolCommand): void {\n this.writeCommand(command);\n }\n\n private writeCommand(command: AppServerSendCommand): void {\n for (const handler of this.sendHandlers) {\n handler(command);\n }\n this.socket.send(JSON.stringify(command));\n }\n\n /**\n * Send a forward-compatible protocol command from a compatibility adapter.\n * Prefer the typed wrappers above this boundary for normal product code.\n */\n sendRaw(command: AppServerRawCommand): void {\n this.writeCommand(command);\n }\n\n /**\n * Request a forward-compatible response without mirroring the full protocol\n * union in a downstream compatibility adapter.\n */\n requestRaw<TResponse extends AppServerRawResponse>(\n command: AppServerRawCommand & { request_id: string },\n options: AppServerRawRequestOptions<TResponse>,\n ): Promise<TResponse> {\n const timeoutMs = options.timeoutMs ?? this.requestTimeoutMs;\n return new Promise((resolve, reject) => {\n const timeout = setTimeout(() => {\n this.pending.delete(command.request_id);\n reject(new Error(`Timed out waiting for ${command.request_id}`));\n }, timeoutMs);\n\n this.pending.set(command.request_id, {\n resolve: (message) => resolve(message as unknown as TResponse),\n reject,\n predicate: options.predicate,\n timeout,\n });\n\n try {\n this.sendRaw(command);\n } catch (error) {\n clearTimeout(timeout);\n this.pending.delete(command.request_id);\n reject(error instanceof Error ? error : new Error(String(error)));\n }\n });\n }\n\n request<TMessage extends WsProtocolMessage = WsProtocolMessage>(\n command: AppServerRequestCommandWithId,\n options?: AppServerRequestOptions<TMessage>,\n ): Promise<TMessage>;\n\n request<\n TType extends AppServerRequestCommand[\"type\"],\n TMessage extends WsProtocolMessage = WsProtocolMessage,\n >(\n type: TType,\n body?: AppServerRequestBody,\n options?: AppServerRequestOptions<TMessage>,\n ): Promise<TMessage>;\n\n request<TMessage extends WsProtocolMessage = WsProtocolMessage>(\n commandOrType:\n | AppServerRequestCommandWithId\n | AppServerRequestCommand[\"type\"],\n bodyOrOptions:\n | AppServerRequestBody\n | AppServerRequestOptions<TMessage> = {},\n maybeOptions: AppServerRequestOptions<TMessage> = {},\n ): Promise<TMessage> {\n const isTypeRequest = typeof commandOrType === \"string\";\n const command = isTypeRequest\n ? ({\n type: commandOrType,\n request_id:\n (bodyOrOptions as { request_id?: string }).request_id ??\n this.nextRequestId(commandOrType),\n ...(bodyOrOptions as object),\n } as AppServerRequestCommandWithId)\n : commandOrType;\n const options = isTypeRequest\n ? maybeOptions\n : (bodyOrOptions as AppServerRequestOptions<TMessage>);\n const timeoutMs = options.timeoutMs ?? this.requestTimeoutMs;\n\n return new Promise((resolve, reject) => {\n const timeout = setTimeout(() => {\n this.pending.delete(command.request_id);\n reject(new Error(`Timed out waiting for ${command.request_id}`));\n }, timeoutMs);\n\n this.pending.set(command.request_id, {\n resolve: (message) => resolve(message as TMessage),\n reject,\n predicate: options.predicate,\n timeout,\n });\n\n try {\n this.send(command);\n } catch (error) {\n clearTimeout(timeout);\n this.pending.delete(command.request_id);\n reject(error instanceof Error ? error : new Error(String(error)));\n }\n });\n }\n\n info(\n options: Omit<\n AppServerRequestOptions<AppServerInfoResponseMessage>,\n \"predicate\"\n > = {},\n ): Promise<AppServerInfoResponseMessage> {\n return this.request(\n {\n type: \"app_server_info\",\n request_id: this.nextRequestId(\"app-server-info\"),\n },\n {\n ...options,\n predicate: isAppServerInfoResponseMessage,\n },\n );\n }\n\n stopMonitor(\n command: Omit<MonitorStopCommand, \"type\" | \"request_id\"> & {\n request_id?: string;\n },\n options: Omit<\n AppServerRequestOptions<MonitorStopResponse>,\n \"predicate\"\n > = {},\n ): Promise<MonitorStopResponse> {\n return this.request(\n {\n type: \"monitor_stop\",\n ...command,\n request_id: command.request_id ?? this.nextRequestId(\"monitor-stop\"),\n },\n {\n ...options,\n predicate: (message): message is MonitorStopResponse =>\n message.type === \"monitor_stop_response\" &&\n message.process_id === command.process_id &&\n message.runtime.agent_id === command.runtime.agent_id &&\n message.runtime.conversation_id === command.runtime.conversation_id,\n },\n );\n }\n\n runtimeStart(\n command: Omit<RuntimeStartCommand, \"type\" | \"request_id\"> & {\n request_id?: string;\n },\n options: Omit<\n AppServerRequestOptions<RuntimeStartResponseMessage>,\n \"predicate\"\n > = {},\n ): Promise<RuntimeStartResponseMessage> {\n return this.request(\n {\n type: \"runtime_start\",\n request_id: command.request_id ?? this.nextRequestId(\"runtime-start\"),\n ...command,\n },\n {\n ...options,\n predicate: (message): message is RuntimeStartResponseMessage =>\n message.type === \"runtime_start_response\",\n },\n );\n }\n\n runtimeExternalToolsUpdate(\n command: Omit<RuntimeExternalToolsUpdateCommand, \"type\" | \"request_id\"> & {\n request_id?: string;\n },\n options: Omit<\n AppServerRequestOptions<RuntimeExternalToolsUpdateResponseMessage>,\n \"predicate\"\n > = {},\n ): Promise<RuntimeExternalToolsUpdateResponseMessage> {\n return this.request(\n {\n type: \"runtime_external_tools_update\",\n request_id:\n command.request_id ?? this.nextRequestId(\"runtime-external-tools\"),\n ...command,\n },\n {\n ...options,\n predicate: (\n message,\n ): message is RuntimeExternalToolsUpdateResponseMessage =>\n message.type === \"runtime_external_tools_update_response\",\n },\n );\n }\n\n sync(\n command: Omit<SyncCommand, \"type\" | \"request_id\"> & { request_id?: string },\n options: Omit<\n AppServerRequestOptions<SyncResponseMessage>,\n \"predicate\"\n > = {},\n ): Promise<SyncResponseMessage> {\n return this.request(\n {\n type: \"sync\",\n request_id: command.request_id ?? this.nextRequestId(\"sync\"),\n ...command,\n },\n {\n ...options,\n predicate: (message): message is SyncResponseMessage =>\n message.type === \"sync_response\",\n },\n );\n }\n\n abort(\n command: Omit<AbortMessageCommand, \"type\" | \"request_id\"> & {\n request_id?: string;\n },\n options: Omit<\n AppServerRequestOptions<AbortMessageResponseMessage>,\n \"predicate\"\n > = {},\n ): Promise<AbortMessageResponseMessage> {\n return this.request(\n {\n type: \"abort_message\",\n request_id: command.request_id ?? this.nextRequestId(\"abort\"),\n ...command,\n },\n {\n ...options,\n predicate: (message): message is AbortMessageResponseMessage =>\n message.type === \"abort_message_response\",\n },\n );\n }\n\n /** Release queue items parked by `abort()` without sending a new message. */\n resumeQueue(\n command: Omit<ResumeQueueCommand, \"type\" | \"request_id\"> & {\n request_id?: string;\n },\n options: Omit<\n AppServerRequestOptions<ResumeQueueResponseMessage>,\n \"predicate\"\n > = {},\n ): Promise<ResumeQueueResponseMessage> {\n return this.request(\n {\n type: \"resume_queue\",\n request_id: command.request_id ?? this.nextRequestId(\"resume-queue\"),\n ...command,\n },\n {\n ...options,\n predicate: (message): message is ResumeQueueResponseMessage =>\n message.type === \"resume_queue_response\",\n },\n );\n }\n\n conversationList(\n command: Omit<ConversationListCommand, \"type\" | \"request_id\"> & {\n request_id?: string;\n } = {},\n options: Omit<\n AppServerRequestOptions<ConversationListResponseMessage>,\n \"predicate\"\n > = {},\n ): Promise<ConversationListResponseMessage> {\n return this.request(\n {\n type: \"conversation_list\",\n request_id:\n command.request_id ?? this.nextRequestId(\"conversation-list\"),\n ...command,\n },\n {\n ...options,\n predicate: (message): message is ConversationListResponseMessage =>\n message.type === \"conversation_list_response\",\n },\n );\n }\n\n onExternalToolCall(handler: AppServerExternalToolCallHandler): () => void {\n return this.onMessage((message, channel) => {\n if (\n channel !== \"control\" ||\n message.type !== \"external_tool_call_request\"\n ) {\n return;\n }\n\n void Promise.resolve(handler(message))\n .then((result) => {\n this.send({\n type: \"external_tool_call_response\",\n request_id: message.request_id,\n result,\n });\n })\n .catch((error) => {\n this.send({\n type: \"external_tool_call_response\",\n request_id: message.request_id,\n error: error instanceof Error ? error.message : String(error),\n });\n });\n });\n }\n\n /**\n * Submit input to a runtime. Observe progress, tool activity, approvals, and\n * terminal lifecycle events through onMessage().\n */\n input(command: Omit<InputCommand, \"type\">): void {\n this.send({ type: \"input\", ...command });\n }\n\n /**\n * Submit an input and wait only until the listener accepts it into the\n * normal dispatch/queue path. This never waits for turn completion.\n */\n submitInput(\n command: Omit<InputCommand, \"type\" | \"request_id\"> & {\n request_id?: string;\n },\n options: Omit<\n AppServerRequestOptions<InputAcceptedResponseMessage>,\n \"predicate\"\n > = {},\n ): Promise<InputAcceptedResponseMessage> {\n return this.request(\n {\n type: \"input\",\n request_id: command.request_id ?? this.nextRequestId(\"input\"),\n ...command,\n },\n {\n ...options,\n predicate: (message): message is InputAcceptedResponseMessage =>\n message.type === \"input_accepted\",\n },\n );\n }\n\n private handleMessage(event: unknown, channel: AppServerChannel): void {\n const message = parseProtocolMessage(event);\n\n for (const handler of this.messageHandlers) {\n handler(message, channel);\n }\n\n const requestId =\n message && typeof message === \"object\" && \"request_id\" in message\n ? (message as { request_id?: unknown }).request_id\n : undefined;\n if (channel !== \"control\" || typeof requestId !== \"string\") {\n return;\n }\n\n const pending = this.pending.get(requestId);\n if (!pending || (pending.predicate && !pending.predicate(message))) {\n return;\n }\n\n clearTimeout(pending.timeout);\n this.pending.delete(requestId);\n pending.resolve(message);\n }\n\n private rejectAllPending(reason: string): void {\n for (const [requestId, pending] of this.pending) {\n clearTimeout(pending.timeout);\n this.pending.delete(requestId);\n pending.reject(new Error(reason));\n }\n }\n\n private handleDisconnect(channel: AppServerChannel, event: unknown): void {\n this.rejectAllPending(\"App-server socket closed\");\n if (this.explicitlyClosed || this.disconnectNotified) return;\n this.disconnectNotified = true;\n for (const handler of this.disconnectHandlers) {\n handler({ channel, event });\n }\n }\n}\n\nexport function createAppServerClient(\n options: AppServerClientOptions,\n): AppServerClient {\n return new AppServerClient(options);\n}\n"
7
7
  ],
8
- "mappings": ";AA4BO,SAAS,8BAA8B,CAC5C,SACyC;AAAA,EACzC,IAAI,CAAC,WAAW,OAAO,YAAY,YAAY,MAAM,QAAQ,OAAO,GAAG;AAAA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AAAA,IAEA,MAAM,YACJ,WAAW,OAAO,YAAY,YAAY,gBAAgB,UACrD,QAAqC,aACtC;AAAA,IACN,IAAI,YAAY,aAAa,OAAO,cAAc,UAAU;AAAA,MAC1D;AAAA,IACF;AAAA,IAEA,MAAM,UAAU,KAAK,QAAQ,IAAI,SAAS;AAAA,IAC1C,IAAI,CAAC,WAAY,QAAQ,aAAa,CAAC,QAAQ,UAAU,OAAO,GAAI;AAAA,MAClE;AAAA,IACF;AAAA,IAEA,aAAa,QAAQ,OAAO;AAAA,IAC5B,KAAK,QAAQ,OAAO,SAAS;AAAA,IAC7B,QAAQ,QAAQ,OAAO;AAAA;AAAA,EAGjB,gBAAgB,CAAC,QAAsB;AAAA,IAC7C,YAAY,WAAW,YAAY,KAAK,SAAS;AAAA,MAC/C,aAAa,QAAQ,OAAO;AAAA,MAC5B,KAAK,QAAQ,OAAO,SAAS;AAAA,MAC7B,QAAQ,OAAO,IAAI,MAAM,MAAM,CAAC;AAAA,IAClC;AAAA;AAAA,EAGM,gBAAgB,CAAC,SAA2B,OAAsB;AAAA,IACxE,KAAK,iBAAiB,0BAA0B;AAAA,IAChD,IAAI,KAAK,oBAAoB,KAAK;AAAA,MAAoB;AAAA,IACtD,KAAK,qBAAqB;AAAA,IAC1B,WAAW,WAAW,KAAK,oBAAoB;AAAA,MAC7C,QAAQ,EAAE,SAAS,MAAM,CAAC;AAAA,IAC5B;AAAA;AAEJ;AAEO,SAAS,qBAAqB,CACnC,SACiB;AAAA,EACjB,OAAO,IAAI,gBAAgB,OAAO;AAAA;",
9
+ "debugId": "447DE4754659309264756E2164756E21",
10
10
  "names": []
11
11
  }
@@ -16867,7 +16867,7 @@ class StreamableHTTPClientTransport {
16867
16867
  // src/mcp-client.ts
16868
16868
  var DEFAULT_CLIENT_INFO = {
16869
16869
  name: "letta-code",
16870
- version: "0.31.13"
16870
+ version: "0.32.0"
16871
16871
  };
16872
16872
  async function connectMcpServer(config2, options = {}) {
16873
16873
  let client = new Client(options.clientInfo ?? DEFAULT_CLIENT_INFO);
@@ -16992,4 +16992,4 @@ export {
16992
16992
  connectMcpServer
16993
16993
  };
16994
16994
 
16995
- //# debugId=93F427F31CFF7FFF64756E2164756E21
16995
+ //# debugId=6BD0F3C4C69EE00164756E2164756E21