@letta-ai/letta-code 0.30.7 → 0.30.8
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.
- package/dist/agent-presets.js.map +1 -1
- package/dist/app-server-client.cjs +12 -2
- package/dist/app-server-client.cjs.map +4 -4
- package/dist/app-server-client.js +12 -2
- package/dist/app-server-client.js.map +4 -4
- package/dist/channels-public.js +210 -39
- package/dist/channels-public.js.map +7 -4
- package/dist/channels-slack.js +1 -1
- package/dist/channels-slack.js.map +3 -3
- package/dist/gateway-core.js +60 -42
- package/dist/gateway-core.js.map +3 -3
- package/dist/mcp-client.js +2 -2
- package/dist/mcp-client.js.map +1 -1
- package/dist/types/agent/approval-execution.d.ts +0 -2
- package/dist/types/agent/approval-execution.d.ts.map +1 -1
- package/dist/types/agent/subagents/manager.d.ts.map +1 -1
- package/dist/types/agent/subagents/subagent-launcher.d.ts +0 -5
- package/dist/types/agent/subagents/subagent-launcher.d.ts.map +1 -1
- package/dist/types/app-server-client.d.ts +4 -1
- package/dist/types/app-server-client.d.ts.map +1 -1
- package/dist/types/channels/gateway-core.d.ts +14 -4
- package/dist/types/channels/gateway-core.d.ts.map +1 -1
- package/dist/types/channels/processor.d.ts.map +1 -1
- package/dist/types/channels/slack/presentation.d.ts.map +1 -1
- package/dist/types/cli/helpers/stream-resume.d.ts +33 -0
- package/dist/types/cli/helpers/stream-resume.d.ts.map +1 -0
- package/dist/types/cli/helpers/stream.d.ts +3 -23
- package/dist/types/cli/helpers/stream.d.ts.map +1 -1
- package/dist/types/constants.d.ts +1 -1
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/types/gateway-core.d.ts +1 -1
- package/dist/types/gateway-core.d.ts.map +1 -1
- package/dist/types/runtime-context.d.ts +0 -9
- package/dist/types/runtime-context.d.ts.map +1 -1
- package/dist/types/tools/manager.d.ts +4 -11
- package/dist/types/tools/manager.d.ts.map +1 -1
- package/dist/types/tools/tool-definitions.d.ts +0 -1
- package/dist/types/tools/tool-definitions.d.ts.map +1 -1
- package/dist/types/tools/toolset.d.ts +1 -5
- package/dist/types/tools/toolset.d.ts.map +1 -1
- package/dist/types/types/app-server-info.d.ts +1 -0
- package/dist/types/types/app-server-info.d.ts.map +1 -1
- package/dist/types/types/external-tool-protocol.d.ts +61 -0
- package/dist/types/types/external-tool-protocol.d.ts.map +1 -0
- package/dist/types/types/protocol_v2.d.ts +7 -55
- package/dist/types/types/protocol_v2.d.ts.map +1 -1
- package/dist/types/types/runtime-scope.d.ts +18 -0
- package/dist/types/types/runtime-scope.d.ts.map +1 -0
- package/letta.js +105649 -105507
- package/package.json +1 -1
- package/scripts/source-file-size-baseline.json +6 -7
- package/dist/types/channels/access-control.d.ts +0 -104
- package/dist/types/channels/access-control.d.ts.map +0 -1
- package/dist/types/channels/accounts.d.ts +0 -17
- package/dist/types/channels/accounts.d.ts.map +0 -1
- package/dist/types/channels/commands.d.ts +0 -98
- package/dist/types/channels/commands.d.ts.map +0 -1
- package/dist/types/channels/config.d.ts +0 -18
- package/dist/types/channels/config.d.ts.map +0 -1
- package/dist/types/channels/credential-store.d.ts +0 -21
- package/dist/types/channels/credential-store.d.ts.map +0 -1
- package/dist/types/channels/custom/adapter.d.ts +0 -3
- package/dist/types/channels/custom/adapter.d.ts.map +0 -1
- package/dist/types/channels/custom/plugin.d.ts +0 -10
- package/dist/types/channels/custom/plugin.d.ts.map +0 -1
- package/dist/types/channels/discord/account-display.d.ts +0 -2
- package/dist/types/channels/discord/account-display.d.ts.map +0 -1
- package/dist/types/channels/discord/adapter.d.ts +0 -3
- package/dist/types/channels/discord/adapter.d.ts.map +0 -1
- package/dist/types/channels/discord/bot-policy.d.ts +0 -19
- package/dist/types/channels/discord/bot-policy.d.ts.map +0 -1
- package/dist/types/channels/discord/channel-gating.d.ts +0 -41
- package/dist/types/channels/discord/channel-gating.d.ts.map +0 -1
- package/dist/types/channels/discord/error-reply.d.ts +0 -24
- package/dist/types/channels/discord/error-reply.d.ts.map +0 -1
- package/dist/types/channels/discord/internal-types.d.ts +0 -101
- package/dist/types/channels/discord/internal-types.d.ts.map +0 -1
- package/dist/types/channels/discord/media.d.ts +0 -47
- package/dist/types/channels/discord/media.d.ts.map +0 -1
- package/dist/types/channels/discord/message-actions.d.ts +0 -3
- package/dist/types/channels/discord/message-actions.d.ts.map +0 -1
- package/dist/types/channels/discord/plugin.d.ts +0 -3
- package/dist/types/channels/discord/plugin.d.ts.map +0 -1
- package/dist/types/channels/discord/runtime.d.ts +0 -28
- package/dist/types/channels/discord/runtime.d.ts.map +0 -1
- package/dist/types/channels/discord/setup.d.ts +0 -2
- package/dist/types/channels/discord/setup.d.ts.map +0 -1
- package/dist/types/channels/discord/utils.d.ts +0 -47
- package/dist/types/channels/discord/utils.d.ts.map +0 -1
- package/dist/types/channels/feedback.d.ts +0 -26
- package/dist/types/channels/feedback.d.ts.map +0 -1
- package/dist/types/channels/inbound-debounce.d.ts +0 -50
- package/dist/types/channels/inbound-debounce.d.ts.map +0 -1
- package/dist/types/channels/interactive.d.ts +0 -13
- package/dist/types/channels/interactive.d.ts.map +0 -1
- package/dist/types/channels/lifecycle-error-report.d.ts +0 -19
- package/dist/types/channels/lifecycle-error-report.d.ts.map +0 -1
- package/dist/types/channels/message-tool.d.ts +0 -15
- package/dist/types/channels/message-tool.d.ts.map +0 -1
- package/dist/types/channels/pairing.d.ts +0 -53
- package/dist/types/channels/pairing.d.ts.map +0 -1
- package/dist/types/channels/pending-control-requests.d.ts +0 -12
- package/dist/types/channels/pending-control-requests.d.ts.map +0 -1
- package/dist/types/channels/plugin-registry.d.ts +0 -9
- package/dist/types/channels/plugin-registry.d.ts.map +0 -1
- package/dist/types/channels/registry-commands.d.ts +0 -52
- package/dist/types/channels/registry-commands.d.ts.map +0 -1
- package/dist/types/channels/registry-controls.d.ts +0 -33
- package/dist/types/channels/registry-controls.d.ts.map +0 -1
- package/dist/types/channels/registry-events.d.ts +0 -27
- package/dist/types/channels/registry-events.d.ts.map +0 -1
- package/dist/types/channels/registry-handlers.d.ts +0 -46
- package/dist/types/channels/registry-handlers.d.ts.map +0 -1
- package/dist/types/channels/registry-inbound.d.ts +0 -19
- package/dist/types/channels/registry-inbound.d.ts.map +0 -1
- package/dist/types/channels/registry-presentation.d.ts +0 -20
- package/dist/types/channels/registry-presentation.d.ts.map +0 -1
- package/dist/types/channels/registry-routes.d.ts +0 -33
- package/dist/types/channels/registry-routes.d.ts.map +0 -1
- package/dist/types/channels/registry.d.ts +0 -130
- package/dist/types/channels/registry.d.ts.map +0 -1
- package/dist/types/channels/restore-scope.d.ts +0 -8
- package/dist/types/channels/restore-scope.d.ts.map +0 -1
- package/dist/types/channels/routing.d.ts +0 -74
- package/dist/types/channels/routing.d.ts.map +0 -1
- package/dist/types/channels/runtime-deps.d.ts +0 -25
- package/dist/types/channels/runtime-deps.d.ts.map +0 -1
- package/dist/types/channels/schema-config.d.ts +0 -33
- package/dist/types/channels/schema-config.d.ts.map +0 -1
- package/dist/types/channels/signal/account-conflicts.d.ts +0 -14
- package/dist/types/channels/signal/account-conflicts.d.ts.map +0 -1
- package/dist/types/channels/signal/adapter.d.ts +0 -40
- package/dist/types/channels/signal/adapter.d.ts.map +0 -1
- package/dist/types/channels/signal/client.d.ts +0 -51
- package/dist/types/channels/signal/client.d.ts.map +0 -1
- package/dist/types/channels/signal/inbound.d.ts +0 -25
- package/dist/types/channels/signal/inbound.d.ts.map +0 -1
- package/dist/types/channels/signal/internal-types.d.ts +0 -82
- package/dist/types/channels/signal/internal-types.d.ts.map +0 -1
- package/dist/types/channels/signal/media.d.ts +0 -35
- package/dist/types/channels/signal/media.d.ts.map +0 -1
- package/dist/types/channels/signal/message-actions.d.ts +0 -3
- package/dist/types/channels/signal/message-actions.d.ts.map +0 -1
- package/dist/types/channels/signal/plugin.d.ts +0 -3
- package/dist/types/channels/signal/plugin.d.ts.map +0 -1
- package/dist/types/channels/signal/runtime.d.ts +0 -14
- package/dist/types/channels/signal/runtime.d.ts.map +0 -1
- package/dist/types/channels/signal/setup-runtime.d.ts +0 -35
- package/dist/types/channels/signal/setup-runtime.d.ts.map +0 -1
- package/dist/types/channels/signal/setup.d.ts +0 -5
- package/dist/types/channels/signal/setup.d.ts.map +0 -1
- package/dist/types/channels/signal/target.d.ts +0 -21
- package/dist/types/channels/signal/target.d.ts.map +0 -1
- package/dist/types/channels/slack/account-display.d.ts +0 -2
- package/dist/types/channels/slack/account-display.d.ts.map +0 -1
- package/dist/types/channels/slack/adapter.d.ts +0 -12
- package/dist/types/channels/slack/adapter.d.ts.map +0 -1
- package/dist/types/channels/slack/agent-thread-tracker.d.ts +0 -13
- package/dist/types/channels/slack/agent-thread-tracker.d.ts.map +0 -1
- package/dist/types/channels/slack/approval-controller.d.ts +0 -14
- package/dist/types/channels/slack/approval-controller.d.ts.map +0 -1
- package/dist/types/channels/slack/attachment-download.d.ts +0 -20
- package/dist/types/channels/slack/attachment-download.d.ts.map +0 -1
- package/dist/types/channels/slack/attachment-stream.d.ts +0 -23
- package/dist/types/channels/slack/attachment-stream.d.ts.map +0 -1
- package/dist/types/channels/slack/attachment-task.d.ts +0 -37
- package/dist/types/channels/slack/attachment-task.d.ts.map +0 -1
- package/dist/types/channels/slack/attachment-types.d.ts +0 -27
- package/dist/types/channels/slack/attachment-types.d.ts.map +0 -1
- package/dist/types/channels/slack/bot-policy.d.ts +0 -25
- package/dist/types/channels/slack/bot-policy.d.ts.map +0 -1
- package/dist/types/channels/slack/file-upload.d.ts +0 -6
- package/dist/types/channels/slack/file-upload.d.ts.map +0 -1
- package/dist/types/channels/slack/inbound-debounce.d.ts +0 -16
- package/dist/types/channels/slack/inbound-debounce.d.ts.map +0 -1
- package/dist/types/channels/slack/ingress-controller.d.ts +0 -21
- package/dist/types/channels/slack/ingress-controller.d.ts.map +0 -1
- package/dist/types/channels/slack/media.d.ts +0 -63
- package/dist/types/channels/slack/media.d.ts.map +0 -1
- package/dist/types/channels/slack/message-actions.d.ts +0 -2
- package/dist/types/channels/slack/message-actions.d.ts.map +0 -1
- package/dist/types/channels/slack/model-picker-blocks.d.ts +0 -9
- package/dist/types/channels/slack/model-picker-blocks.d.ts.map +0 -1
- package/dist/types/channels/slack/plugin.d.ts +0 -3
- package/dist/types/channels/slack/plugin.d.ts.map +0 -1
- package/dist/types/channels/slack/proactive-accounts.d.ts +0 -15
- package/dist/types/channels/slack/proactive-accounts.d.ts.map +0 -1
- package/dist/types/channels/slack/runtime.d.ts +0 -6
- package/dist/types/channels/slack/runtime.d.ts.map +0 -1
- package/dist/types/channels/slack/setup.d.ts +0 -2
- package/dist/types/channels/slack/setup.d.ts.map +0 -1
- package/dist/types/channels/slack/target-resolution.d.ts +0 -52
- package/dist/types/channels/slack/target-resolution.d.ts.map +0 -1
- package/dist/types/channels/slack/thread-context.d.ts +0 -15
- package/dist/types/channels/slack/thread-context.d.ts.map +0 -1
- package/dist/types/channels/slack/web-api-client.d.ts +0 -2
- package/dist/types/channels/slack/web-api-client.d.ts.map +0 -1
- package/dist/types/channels/targets.d.ts +0 -17
- package/dist/types/channels/targets.d.ts.map +0 -1
- package/dist/types/channels/telegram/account-display.d.ts +0 -9
- package/dist/types/channels/telegram/account-display.d.ts.map +0 -1
- package/dist/types/channels/telegram/adapter.d.ts +0 -12
- package/dist/types/channels/telegram/adapter.d.ts.map +0 -1
- package/dist/types/channels/telegram/debounce.d.ts +0 -22
- package/dist/types/channels/telegram/debounce.d.ts.map +0 -1
- package/dist/types/channels/telegram/internal-types.d.ts +0 -98
- package/dist/types/channels/telegram/internal-types.d.ts.map +0 -1
- package/dist/types/channels/telegram/media.d.ts +0 -115
- package/dist/types/channels/telegram/media.d.ts.map +0 -1
- package/dist/types/channels/telegram/message-actions.d.ts +0 -3
- package/dist/types/channels/telegram/message-actions.d.ts.map +0 -1
- package/dist/types/channels/telegram/plugin.d.ts +0 -3
- package/dist/types/channels/telegram/plugin.d.ts.map +0 -1
- package/dist/types/channels/telegram/runtime.d.ts +0 -6
- package/dist/types/channels/telegram/runtime.d.ts.map +0 -1
- package/dist/types/channels/telegram/setup.d.ts +0 -14
- package/dist/types/channels/telegram/setup.d.ts.map +0 -1
- package/dist/types/channels/telegram/startup-helpers.d.ts +0 -10
- package/dist/types/channels/telegram/startup-helpers.d.ts.map +0 -1
- package/dist/types/channels/telegram/typing-controller.d.ts +0 -11
- package/dist/types/channels/telegram/typing-controller.d.ts.map +0 -1
- package/dist/types/channels/telegram/utils.d.ts +0 -43
- package/dist/types/channels/telegram/utils.d.ts.map +0 -1
- package/dist/types/channels/transcription/index.d.ts +0 -20
- package/dist/types/channels/transcription/index.d.ts.map +0 -1
- package/dist/types/channels/whatsapp/adapter-helpers.d.ts +0 -21
- package/dist/types/channels/whatsapp/adapter-helpers.d.ts.map +0 -1
- package/dist/types/channels/whatsapp/adapter-types.d.ts +0 -44
- package/dist/types/channels/whatsapp/adapter-types.d.ts.map +0 -1
- package/dist/types/channels/whatsapp/adapter.d.ts +0 -18
- package/dist/types/channels/whatsapp/adapter.d.ts.map +0 -1
- package/dist/types/channels/whatsapp/attachment-policy.d.ts +0 -22
- package/dist/types/channels/whatsapp/attachment-policy.d.ts.map +0 -1
- package/dist/types/channels/whatsapp/dedupe-claims.d.ts +0 -8
- package/dist/types/channels/whatsapp/dedupe-claims.d.ts.map +0 -1
- package/dist/types/channels/whatsapp/identity.d.ts +0 -29
- package/dist/types/channels/whatsapp/identity.d.ts.map +0 -1
- package/dist/types/channels/whatsapp/inbound-debounce.d.ts +0 -28
- package/dist/types/channels/whatsapp/inbound-debounce.d.ts.map +0 -1
- package/dist/types/channels/whatsapp/jid.d.ts +0 -40
- package/dist/types/channels/whatsapp/jid.d.ts.map +0 -1
- package/dist/types/channels/whatsapp/lid-store.d.ts +0 -45
- package/dist/types/channels/whatsapp/lid-store.d.ts.map +0 -1
- package/dist/types/channels/whatsapp/media.d.ts +0 -26
- package/dist/types/channels/whatsapp/media.d.ts.map +0 -1
- package/dist/types/channels/whatsapp/message-actions.d.ts +0 -3
- package/dist/types/channels/whatsapp/message-actions.d.ts.map +0 -1
- package/dist/types/channels/whatsapp/message-store.d.ts +0 -13
- package/dist/types/channels/whatsapp/message-store.d.ts.map +0 -1
- package/dist/types/channels/whatsapp/plugin.d.ts +0 -3
- package/dist/types/channels/whatsapp/plugin.d.ts.map +0 -1
- package/dist/types/channels/whatsapp/reactions.d.ts +0 -33
- package/dist/types/channels/whatsapp/reactions.d.ts.map +0 -1
- package/dist/types/channels/whatsapp/reconnect-scheduler.d.ts +0 -16
- package/dist/types/channels/whatsapp/reconnect-scheduler.d.ts.map +0 -1
- package/dist/types/channels/whatsapp/runtime.d.ts +0 -25
- package/dist/types/channels/whatsapp/runtime.d.ts.map +0 -1
- package/dist/types/channels/whatsapp/session.d.ts +0 -56
- package/dist/types/channels/whatsapp/session.d.ts.map +0 -1
- package/dist/types/channels/whatsapp/setup.d.ts +0 -2
- package/dist/types/channels/whatsapp/setup.d.ts.map +0 -1
- package/dist/types/channels/whatsapp/state.d.ts +0 -18
- package/dist/types/channels/whatsapp/state.d.ts.map +0 -1
- package/dist/types/channels/whatsapp/typing-controller.d.ts +0 -28
- package/dist/types/channels/whatsapp/typing-controller.d.ts.map +0 -1
- package/dist/types/tools/impl/message-channel.d.ts +0 -10
- package/dist/types/tools/impl/message-channel.d.ts.map +0 -1
- package/dist/types/updater/auto-update.d.ts +0 -48
- package/dist/types/updater/auto-update.d.ts.map +0 -1
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"sources": ["../src/agent/agent-tags.ts", "../src/constants.ts", "../src/agent/memory-constants.ts", "../src/agent/prompt-assets.ts", "../src/agent/memory.ts", "../src/agent/model-catalog.ts", "../src/agent/personality-presets.ts", "../src/agent/create-agent-request.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"/**\n * Tags that identify Letta Code agents and their capabilities.\n *\n * This module must stay free of Node/backend imports: it is bundled into the\n * browser-safe `@letta-ai/letta-code/agent-presets` package export.\n */\n\n/** Marks an agent as created/managed by Letta Code. */\nexport const LETTA_CODE_ORIGIN_TAG = \"origin:letta-code\";\n\n/** Marks an agent as created by a first-run onboarding flow. */\nexport const ONBOARDING_ORIGIN_TAG = \"origin:onboarding\";\n\n/** Marks an agent as a Letta Code subagent (excluded from prompt management). */\nexport const LETTA_CODE_SUBAGENT_TAG = \"role:subagent\";\n\n/** Marks an agent as using git-backed memory (MemFS). */\nexport const GIT_MEMORY_ENABLED_TAG = \"git-memory-enabled\";\n\nexport interface BuildCreatedAgentTagsOptions {\n tags?: string[] | null;\n isSubagent?: boolean;\n enableMemfs?: boolean;\n}\n\nexport function buildCreatedAgentTags(\n options: BuildCreatedAgentTagsOptions = {},\n): string[] {\n const tags = [LETTA_CODE_ORIGIN_TAG];\n if (options.isSubagent) {\n tags.push(LETTA_CODE_SUBAGENT_TAG);\n }\n if (options.enableMemfs) {\n tags.push(GIT_MEMORY_ENABLED_TAG);\n }\n if (options.tags && Array.isArray(options.tags)) {\n tags.push(...options.tags);\n }\n return Array.from(new Set(tags));\n}\n",
|
|
6
|
-
"/**\n * Application-wide constants\n */\n\n/**\n * Default model ID to use when no model is specified\n */\nexport const DEFAULT_MODEL_ID = \"auto\";\n\n/**\n * Default model handle to use for conversation compaction / summarization.\n */\nexport const DEFAULT_SUMMARIZATION_MODEL = \"letta/auto\";\n\n/**\n * Default model handle for lightweight conversation title generation.\n */\nexport const DEFAULT_TITLE_SUMMARIZATION_MODEL = \"
|
|
6
|
+
"/**\n * Application-wide constants\n */\n\n/**\n * Default model ID to use when no model is specified\n */\nexport const DEFAULT_MODEL_ID = \"auto\";\n\n/**\n * Default model handle to use for conversation compaction / summarization.\n */\nexport const DEFAULT_SUMMARIZATION_MODEL = \"letta/auto\";\n\n/**\n * Default model handle for lightweight conversation title generation.\n */\nexport const DEFAULT_TITLE_SUMMARIZATION_MODEL = \"openai/gpt-5.6-luna\";\n\n/**\n * Default agent name when creating a new agent\n */\nexport const DEFAULT_AGENT_NAME = \"Letta Code\";\n\n/**\n * Message displayed when user interrupts tool execution\n */\nexport const INTERRUPTED_BY_USER = \"Interrupted by user\";\n\n/**\n * Synthetic tool result injected when a turn ended without completing all tool calls\n * (e.g. process crash or unhandled stream error). Settled automatically at the start\n * of the next turn so the conversation history stays valid for the provider.\n */\nexport const TURN_DID_NOT_COMPLETE = \"Turn did not complete\";\n\n/**\n * XML tag used to wrap system reminder content injected into messages\n */\nexport const SYSTEM_REMINDER_TAG = \"system-reminder\";\nexport const SYSTEM_REMINDER_OPEN = `<${SYSTEM_REMINDER_TAG}>`;\nexport const SYSTEM_REMINDER_CLOSE = `</${SYSTEM_REMINDER_TAG}>`;\n// Legacy tag kept for parsing/backward compatibility with older saved messages.\nexport const SYSTEM_ALERT_TAG = \"system-alert\";\nexport const SYSTEM_ALERT_OPEN = `<${SYSTEM_ALERT_TAG}>`;\nexport const SYSTEM_ALERT_CLOSE = `</${SYSTEM_ALERT_TAG}>`;\n\n/**\n * How often (in turns) to check for memfs sync conflicts, even without\n * filesystem change events. Catches block-only changes (e.g. ADE/API edits).\n */\nexport const MEMFS_CONFLICT_CHECK_INTERVAL = 5;\n\n/**\n * Header displayed before compaction summary when conversation context is truncated\n */\nexport const COMPACTION_SUMMARY_HEADER =\n \"(Earlier messages in this conversation have been compacted to free up context, summarized below)\";\n\n/**\n * Status bar thresholds - only show indicators when values exceed these\n */\n// Show token count after 100 estimated tokens (shows exact count until 1k, then compact)\nexport const TOKEN_DISPLAY_THRESHOLD = 100;\n// Show elapsed time after 2 minutes (in ms)\nexport const ELAPSED_DISPLAY_THRESHOLD_MS = 60 * 1000;\n",
|
|
7
7
|
"export const READ_ONLY_BLOCK_LABELS = [\"memory_filesystem\"] as const;\n",
|
|
8
8
|
"// Additional system prompts for /system command\n\nimport approvalRecoveryAlert from \"./prompts/approval_recovery_alert.txt\";\nimport humanPrompt from \"./prompts/human.mdx\";\nimport humanKawaiiPrompt from \"./prompts/human_kawaii.mdx\";\nimport humanLinusPrompt from \"./prompts/human_linus.mdx\";\nimport humanMemoPrompt from \"./prompts/human_memo.mdx\";\nimport humanTutorialPrompt from \"./prompts/human_tutorial.mdx\";\nimport interruptRecoveryAlert from \"./prompts/interrupt_recovery_alert.txt\";\nimport lettaMemfsPrompt from \"./prompts/letta.md\";\nimport lettaLocalMemfsPrompt from \"./prompts/letta_local_memfs.md\";\nimport lettaNoMemfsPrompt from \"./prompts/letta_no_memfs.md\";\nimport memoryFilesystemPrompt from \"./prompts/memory_filesystem.mdx\";\nimport onboardingPrompt from \"./prompts/onboarding.mdx\";\nimport onboardingLocalPrompt from \"./prompts/onboarding_local.mdx\";\nimport personaPrompt from \"./prompts/persona.mdx\";\nimport personaBlankPrompt from \"./prompts/persona_blank.mdx\";\nimport personaKawaiiPrompt from \"./prompts/persona_kawaii.mdx\";\nimport personaLinusPrompt from \"./prompts/persona_linus.mdx\";\nimport personaMemoPrompt from \"./prompts/persona_memo.mdx\";\nimport personaTutorialPrompt from \"./prompts/persona_tutorial.mdx\";\nimport projectPrompt from \"./prompts/project.mdx\";\nimport rememberPrompt from \"./prompts/remember.md\";\nimport skillCreatorModePrompt from \"./prompts/skill_creator_mode.md\";\nimport sourceClaudePrompt from \"./prompts/source_claude.md\";\nimport sourceCodexPrompt from \"./prompts/source_codex.md\";\nimport sourceGeminiPrompt from \"./prompts/source_gemini.md\";\n\nimport stylePrompt from \"./prompts/style.mdx\";\n\nexport const SYSTEM_PROMPT = lettaNoMemfsPrompt;\n\nexport const SKILL_CREATOR_PROMPT = skillCreatorModePrompt;\nexport const REMEMBER_PROMPT = rememberPrompt;\nexport const APPROVAL_RECOVERY_PROMPT = approvalRecoveryAlert;\nexport const INTERRUPT_RECOVERY_ALERT = interruptRecoveryAlert;\n\nexport const MEMORY_PROMPTS: Record<string, string> = {\n \"persona.mdx\": personaPrompt,\n \"persona_blank.mdx\": personaBlankPrompt,\n \"persona_kawaii.mdx\": personaKawaiiPrompt,\n \"persona_linus.mdx\": personaLinusPrompt,\n \"persona_memo.mdx\": personaMemoPrompt,\n \"persona_tutorial.mdx\": personaTutorialPrompt,\n \"human.mdx\": humanPrompt,\n \"human_kawaii.mdx\": humanKawaiiPrompt,\n \"human_linus.mdx\": humanLinusPrompt,\n \"human_memo.mdx\": humanMemoPrompt,\n \"human_tutorial.mdx\": humanTutorialPrompt,\n \"project.mdx\": projectPrompt,\n\n \"memory_filesystem.mdx\": memoryFilesystemPrompt,\n \"onboarding.mdx\": onboardingPrompt,\n \"onboarding_local.mdx\": onboardingLocalPrompt,\n \"style.mdx\": stylePrompt,\n};\n\n// System prompt options for /system command\nexport interface SystemPromptOption {\n id: string;\n label: string;\n description: string;\n content: string;\n memfsContent?: string;\n localMemfsContent?: string;\n isDefault?: boolean;\n isFeatured?: boolean;\n}\n\nexport const SYSTEM_PROMPTS: SystemPromptOption[] = [\n {\n id: \"default\",\n label: \"Default\",\n description: \"Alias for letta\",\n content: lettaNoMemfsPrompt,\n memfsContent: lettaMemfsPrompt,\n localMemfsContent: lettaLocalMemfsPrompt,\n isDefault: true,\n isFeatured: true,\n },\n {\n id: \"letta\",\n label: \"Letta Code\",\n description: \"Full Letta Code system prompt\",\n content: lettaNoMemfsPrompt,\n memfsContent: lettaMemfsPrompt,\n localMemfsContent: lettaLocalMemfsPrompt,\n isFeatured: true,\n },\n {\n id: \"source-claude\",\n label: \"Claude Code\",\n description: \"Source-faithful Claude Code prompt (for benchmarking)\",\n content: sourceClaudePrompt,\n },\n {\n id: \"source-codex\",\n label: \"Codex\",\n description: \"Source-faithful OpenAI Codex prompt (for benchmarking)\",\n content: sourceCodexPrompt,\n },\n {\n id: \"source-gemini\",\n label: \"Gemini CLI\",\n description: \"Source-faithful Gemini CLI prompt (for benchmarking)\",\n content: sourceGeminiPrompt,\n },\n];\n\nexport type MemoryPromptMode = \"standard\" | \"memfs\" | \"local-memfs\";\n\nexport function getSystemPromptVariantContents(\n prompt: SystemPromptOption,\n): string[] {\n return [prompt.content, prompt.memfsContent, prompt.localMemfsContent].filter(\n (content): content is string => typeof content === \"string\",\n );\n}\n\n/**\n * Check if a preset ID exists in SYSTEM_PROMPTS.\n */\nexport function isKnownPreset(id: string): boolean {\n return SYSTEM_PROMPTS.some((p) => p.id === id);\n}\n\n/**\n * Deterministic rebuild of a system prompt from a known preset + memory mode.\n * Throws on unknown preset (prevents stale/renamed presets from silently rewriting prompts).\n */\nexport function buildSystemPrompt(\n presetId: string,\n memoryMode: MemoryPromptMode,\n): string {\n const preset = SYSTEM_PROMPTS.find((p) => p.id === presetId);\n if (!preset) {\n throw new Error(\n `Unknown preset \"${presetId}\" — cannot rebuild system prompt`,\n );\n }\n if (memoryMode === \"local-memfs\") {\n return (\n preset.localMemfsContent ??\n preset.memfsContent ??\n preset.content\n ).trim();\n }\n if (memoryMode === \"memfs\") {\n return (preset.memfsContent ?? preset.content).trim();\n }\n\n return preset.content.trim();\n}\n\n/**\n * Returns true if the agent is not on the current default preset\n * and would benefit from switching to `/system default`.\n */\nexport function shouldRecommendDefaultPrompt(\n currentPrompt: string,\n memoryMode: MemoryPromptMode,\n): boolean {\n const defaultPrompt = buildSystemPrompt(\"default\", memoryMode);\n return currentPrompt !== defaultPrompt;\n}\n",
|
|
9
9
|
"/**\n * Agent memory block management\n * Loads memory blocks from .mdx files in src/agent/prompts\n */\n\nimport type { CreateBlock } from \"@letta-ai/letta-client/resources/blocks/blocks\";\nimport { READ_ONLY_BLOCK_LABELS } from \"./memory-constants\";\nimport { MEMORY_PROMPTS } from \"./prompt-assets\";\n\n/**\n * The memory block labels every standard (non-MemFS) agent is created with.\n * Each maps to a `<label>.mdx` file in src/agent/prompts. Per-project blocks\n * (skills/loaded_skills) were removed in LET-7353 — skills are now injected\n * via system reminders, leaving only these defaults.\n */\nexport const MEMORY_BLOCK_LABELS = [\"persona\", \"human\"] as const;\n\n/**\n * Block labels that should be read-only (agent cannot modify via memory tools).\n */\nexport { READ_ONLY_BLOCK_LABELS };\n\n/**\n * Parse frontmatter and content from an .mdx file\n */\nexport function parseMdxFrontmatter(content: string): {\n frontmatter: Record<string, string>;\n body: string;\n} {\n const frontmatterRegex = /^---\\n([\\s\\S]*?)\\n---\\n([\\s\\S]*)$/;\n const match = content.match(frontmatterRegex);\n\n if (!match || !match[1] || !match[2]) {\n return { frontmatter: {}, body: content };\n }\n\n const frontmatterText = match[1];\n const body = match[2];\n const frontmatter: Record<string, string> = {};\n\n // Parse YAML-like frontmatter (simple key: value pairs)\n for (const line of frontmatterText.split(\"\\n\")) {\n const colonIndex = line.indexOf(\":\");\n if (colonIndex > 0) {\n const key = line.slice(0, colonIndex).trim();\n const value = line.slice(colonIndex + 1).trim();\n frontmatter[key] = value;\n }\n }\n\n return { frontmatter, body: body.trim() };\n}\n\n/**\n * Load memory blocks from .mdx files in src/agent/prompts\n */\nasync function loadMemoryBlocksFromMdx(): Promise<CreateBlock[]> {\n const memoryBlocks: CreateBlock[] = [];\n\n const mdxFiles = MEMORY_BLOCK_LABELS.map((label) => `${label}.mdx`);\n\n for (const filename of mdxFiles) {\n try {\n const content = MEMORY_PROMPTS[filename];\n if (!content) {\n console.warn(`Missing embedded prompt file: ${filename}`);\n continue;\n }\n const { frontmatter, body } = parseMdxFrontmatter(content);\n\n const label = frontmatter.label || filename.replace(\".mdx\", \"\");\n const block: CreateBlock = {\n label,\n value: body,\n };\n\n if (frontmatter.description) {\n block.description = frontmatter.description;\n }\n\n // Set read-only for blocks managed by specific tools (not memory tools)\n if ((READ_ONLY_BLOCK_LABELS as readonly string[]).includes(label)) {\n block.read_only = true;\n }\n\n memoryBlocks.push(block);\n } catch (error) {\n console.error(`Error loading ${filename}:`, error);\n }\n }\n\n return memoryBlocks;\n}\n\n// Cache for loaded memory blocks\nlet cachedMemoryBlocks: CreateBlock[] | null = null;\n\n/**\n * Get default starter memory blocks for new agents\n */\nexport async function getDefaultMemoryBlocks(): Promise<CreateBlock[]> {\n if (!cachedMemoryBlocks) {\n cachedMemoryBlocks = await loadMemoryBlocksFromMdx();\n }\n return cachedMemoryBlocks;\n}\n",
|
|
@@ -48,7 +48,7 @@ function isAppServerInfoResponseMessage(message) {
|
|
|
48
48
|
return false;
|
|
49
49
|
}
|
|
50
50
|
const capabilityRecord = capabilities;
|
|
51
|
-
return candidate.type === "app_server_info_response" && typeof candidate.request_id === "string" && candidate.request_id.length > 0 && candidate.success === true && (candidate.backend === "local" || candidate.backend === "api") && typeof candidate.letta_code_version === "string" && typeof candidate.protocol_version === "number" && Number.isInteger(candidate.protocol_version) && typeof capabilityRecord.agent_management === "boolean" && typeof capabilityRecord.conversation_management === "boolean" && typeof capabilityRecord.memory_management === "boolean" && typeof capabilityRecord.runtime_start === "boolean" && typeof capabilityRecord.split_channels === "boolean";
|
|
51
|
+
return candidate.type === "app_server_info_response" && typeof candidate.request_id === "string" && candidate.request_id.length > 0 && candidate.success === true && (candidate.backend === "local" || candidate.backend === "api") && typeof candidate.letta_code_version === "string" && typeof candidate.protocol_version === "number" && Number.isInteger(candidate.protocol_version) && typeof capabilityRecord.agent_management === "boolean" && typeof capabilityRecord.conversation_management === "boolean" && typeof capabilityRecord.memory_management === "boolean" && typeof capabilityRecord.runtime_start === "boolean" && (capabilityRecord.runtime_external_tools_update === undefined || typeof capabilityRecord.runtime_external_tools_update === "boolean") && typeof capabilityRecord.split_channels === "boolean";
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
// src/app-server-client.ts
|
|
@@ -296,6 +296,16 @@ class AppServerClient {
|
|
|
296
296
|
predicate: (message) => message.type === "runtime_start_response"
|
|
297
297
|
});
|
|
298
298
|
}
|
|
299
|
+
runtimeExternalToolsUpdate(command, options = {}) {
|
|
300
|
+
return this.request({
|
|
301
|
+
type: "runtime_external_tools_update",
|
|
302
|
+
request_id: command.request_id ?? this.nextRequestId("runtime-external-tools"),
|
|
303
|
+
...command
|
|
304
|
+
}, {
|
|
305
|
+
...options,
|
|
306
|
+
predicate: (message) => message.type === "runtime_external_tools_update_response"
|
|
307
|
+
});
|
|
308
|
+
}
|
|
299
309
|
sync(command, options = {}) {
|
|
300
310
|
return this.request({
|
|
301
311
|
type: "sync",
|
|
@@ -397,4 +407,4 @@ function createAppServerClient(options) {
|
|
|
397
407
|
return new AppServerClient(options);
|
|
398
408
|
}
|
|
399
409
|
|
|
400
|
-
//# debugId=
|
|
410
|
+
//# debugId=1C9ED49A42ED9CBF64756E2164756E21
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/types/app-server-info.ts", "../src/app-server-client.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
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 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 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 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 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"
|
|
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_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_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"
|
|
7
7
|
],
|
|
8
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
9
|
-
"debugId": "
|
|
8
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BO,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,gBACD,OAAO,iBAAiB,YACxB,MAAM,QAAQ,YAAY,GAC1B;AAAA,IACA,OAAO;AAAA,EACT;AAAA,EAEA,MAAM,mBAAmB;AAAA,EACzB,OACE,UAAU,SAAS,8BACnB,OAAO,UAAU,eAAe,YAChC,UAAU,WAAW,SAAS,KAC9B,UAAU,YAAY,SACrB,UAAU,YAAY,WAAW,UAAU,YAAY,UACxD,OAAO,UAAU,uBAAuB,YACxC,OAAO,UAAU,qBAAqB,YACtC,OAAO,UAAU,UAAU,gBAAgB,KAC3C,OAAO,iBAAiB,qBAAqB,aAC7C,OAAO,iBAAiB,4BAA4B,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AAW,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": "1C9ED49A42ED9CBF64756E2164756E21",
|
|
10
10
|
"names": []
|
|
11
11
|
}
|
|
@@ -9,7 +9,7 @@ function isAppServerInfoResponseMessage(message) {
|
|
|
9
9
|
return false;
|
|
10
10
|
}
|
|
11
11
|
const capabilityRecord = capabilities;
|
|
12
|
-
return candidate.type === "app_server_info_response" && typeof candidate.request_id === "string" && candidate.request_id.length > 0 && candidate.success === true && (candidate.backend === "local" || candidate.backend === "api") && typeof candidate.letta_code_version === "string" && typeof candidate.protocol_version === "number" && Number.isInteger(candidate.protocol_version) && typeof capabilityRecord.agent_management === "boolean" && typeof capabilityRecord.conversation_management === "boolean" && typeof capabilityRecord.memory_management === "boolean" && typeof capabilityRecord.runtime_start === "boolean" && typeof capabilityRecord.split_channels === "boolean";
|
|
12
|
+
return candidate.type === "app_server_info_response" && typeof candidate.request_id === "string" && candidate.request_id.length > 0 && candidate.success === true && (candidate.backend === "local" || candidate.backend === "api") && typeof candidate.letta_code_version === "string" && typeof candidate.protocol_version === "number" && Number.isInteger(candidate.protocol_version) && typeof capabilityRecord.agent_management === "boolean" && typeof capabilityRecord.conversation_management === "boolean" && typeof capabilityRecord.memory_management === "boolean" && typeof capabilityRecord.runtime_start === "boolean" && (capabilityRecord.runtime_external_tools_update === undefined || typeof capabilityRecord.runtime_external_tools_update === "boolean") && typeof capabilityRecord.split_channels === "boolean";
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
// src/app-server-client.ts
|
|
@@ -257,6 +257,16 @@ class AppServerClient {
|
|
|
257
257
|
predicate: (message) => message.type === "runtime_start_response"
|
|
258
258
|
});
|
|
259
259
|
}
|
|
260
|
+
runtimeExternalToolsUpdate(command, options = {}) {
|
|
261
|
+
return this.request({
|
|
262
|
+
type: "runtime_external_tools_update",
|
|
263
|
+
request_id: command.request_id ?? this.nextRequestId("runtime-external-tools"),
|
|
264
|
+
...command
|
|
265
|
+
}, {
|
|
266
|
+
...options,
|
|
267
|
+
predicate: (message) => message.type === "runtime_external_tools_update_response"
|
|
268
|
+
});
|
|
269
|
+
}
|
|
260
270
|
sync(command, options = {}) {
|
|
261
271
|
return this.request({
|
|
262
272
|
type: "sync",
|
|
@@ -365,4 +375,4 @@ export {
|
|
|
365
375
|
AppServerClient
|
|
366
376
|
};
|
|
367
377
|
|
|
368
|
-
//# debugId=
|
|
378
|
+
//# debugId=B2460D44F649E81C64756E2164756E21
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/types/app-server-info.ts", "../src/app-server-client.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
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 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 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 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 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"
|
|
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_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_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"
|
|
7
7
|
],
|
|
8
|
-
"mappings": ";
|
|
9
|
-
"debugId": "
|
|
8
|
+
"mappings": ";AA2BO,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,gBACD,OAAO,iBAAiB,YACxB,MAAM,QAAQ,YAAY,GAC1B;AAAA,IACA,OAAO;AAAA,EACT;AAAA,EAEA,MAAM,mBAAmB;AAAA,EACzB,OACE,UAAU,SAAS,8BACnB,OAAO,UAAU,eAAe,YAChC,UAAU,WAAW,SAAS,KAC9B,UAAU,YAAY,SACrB,U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