@athenaintel/react 0.55.0 → 0.56.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/README.md +13 -0
  2. package/dist/agent-runtime/src/answer-label.cjs +8 -2
  3. package/dist/agent-runtime/src/answer-label.cjs.map +1 -1
  4. package/dist/agent-runtime/src/answer-label.d.ts +10 -4
  5. package/dist/agent-runtime/src/answer-label.js +8 -2
  6. package/dist/agent-runtime/src/answer-label.js.map +1 -1
  7. package/dist/agent-runtime/src/deep-agent-transport-recipe.cjs +6 -3
  8. package/dist/agent-runtime/src/deep-agent-transport-recipe.cjs.map +1 -1
  9. package/dist/agent-runtime/src/deep-agent-transport-recipe.js +6 -3
  10. package/dist/agent-runtime/src/deep-agent-transport-recipe.js.map +1 -1
  11. package/dist/agent-runtime/src/edit-command.cjs +40 -19
  12. package/dist/agent-runtime/src/edit-command.cjs.map +1 -1
  13. package/dist/agent-runtime/src/edit-command.d.ts +2 -0
  14. package/dist/agent-runtime/src/edit-command.js +41 -20
  15. package/dist/agent-runtime/src/edit-command.js.map +1 -1
  16. package/dist/agent-runtime/src/generated/runconfig-contract.cjs +8 -0
  17. package/dist/agent-runtime/src/generated/runconfig-contract.cjs.map +1 -1
  18. package/dist/agent-runtime/src/generated/runconfig-contract.d.ts +9 -0
  19. package/dist/agent-runtime/src/generated/runconfig-contract.js +8 -0
  20. package/dist/agent-runtime/src/generated/runconfig-contract.js.map +1 -1
  21. package/dist/agent-runtime/src/history-store.cjs +426 -0
  22. package/dist/agent-runtime/src/history-store.cjs.map +1 -0
  23. package/dist/agent-runtime/src/history-store.d.ts +282 -0
  24. package/dist/agent-runtime/src/history-store.js +426 -0
  25. package/dist/agent-runtime/src/history-store.js.map +1 -0
  26. package/dist/agent-runtime/src/index.d.ts +4 -4
  27. package/dist/agent-runtime/src/message-window.cjs +43 -5
  28. package/dist/agent-runtime/src/message-window.cjs.map +1 -1
  29. package/dist/agent-runtime/src/message-window.d.ts +26 -2
  30. package/dist/agent-runtime/src/message-window.js +44 -6
  31. package/dist/agent-runtime/src/message-window.js.map +1 -1
  32. package/dist/agent-runtime/src/offline-status.cjs.map +1 -1
  33. package/dist/agent-runtime/src/offline-status.d.ts +85 -4
  34. package/dist/agent-runtime/src/offline-status.js.map +1 -1
  35. package/dist/agent-runtime/src/runtime.d.ts +1 -0
  36. package/dist/agent-runtime/src/tool-metadata.cjs +8 -0
  37. package/dist/agent-runtime/src/tool-metadata.cjs.map +1 -1
  38. package/dist/agent-runtime/src/tool-metadata.js +8 -0
  39. package/dist/agent-runtime/src/tool-metadata.js.map +1 -1
  40. package/dist/agent-runtime/src/use-deep-agent-thread.cjs +8 -16
  41. package/dist/agent-runtime/src/use-deep-agent-thread.cjs.map +1 -1
  42. package/dist/agent-runtime/src/use-deep-agent-thread.d.ts +1 -9
  43. package/dist/agent-runtime/src/use-deep-agent-thread.js +9 -17
  44. package/dist/agent-runtime/src/use-deep-agent-thread.js.map +1 -1
  45. package/dist/agent-runtime/src/use-deep-agent-window-sync.cjs +86 -79
  46. package/dist/agent-runtime/src/use-deep-agent-window-sync.cjs.map +1 -1
  47. package/dist/agent-runtime/src/use-deep-agent-window-sync.d.ts +2 -27
  48. package/dist/agent-runtime/src/use-deep-agent-window-sync.js +89 -82
  49. package/dist/agent-runtime/src/use-deep-agent-window-sync.js.map +1 -1
  50. package/dist/chat/super-grouping/CollapsibleGroup.cjs +1 -1
  51. package/dist/chat/super-grouping/CollapsibleGroup.cjs.map +1 -1
  52. package/dist/chat/super-grouping/CollapsibleGroup.d.ts +6 -5
  53. package/dist/chat/super-grouping/CollapsibleGroup.js +1 -1
  54. package/dist/chat/super-grouping/CollapsibleGroup.js.map +1 -1
  55. package/dist/chat/super-grouping/earlier-steps-button.cjs +5 -6
  56. package/dist/chat/super-grouping/earlier-steps-button.cjs.map +1 -1
  57. package/dist/chat/super-grouping/earlier-steps-button.d.ts +6 -6
  58. package/dist/chat/super-grouping/earlier-steps-button.js +5 -6
  59. package/dist/chat/super-grouping/earlier-steps-button.js.map +1 -1
  60. package/dist/chat/super-grouping/toolkit-map.cjs +1 -0
  61. package/dist/chat/super-grouping/toolkit-map.cjs.map +1 -1
  62. package/dist/chat/super-grouping/toolkit-map.js +1 -0
  63. package/dist/chat/super-grouping/toolkit-map.js.map +1 -1
  64. package/dist/chat/super-grouping/use-turn-steps.cjs +3 -3
  65. package/dist/chat/super-grouping/use-turn-steps.js +1 -1
  66. package/dist/chat-ui/thread/statewire-history-edge.cjs +0 -4
  67. package/dist/chat-ui/thread/statewire-history-edge.cjs.map +1 -1
  68. package/dist/chat-ui/thread/statewire-history-edge.d.ts +5 -7
  69. package/dist/chat-ui/thread/statewire-history-edge.js +1 -5
  70. package/dist/chat-ui/thread/statewire-history-edge.js.map +1 -1
  71. package/dist/provider/AthenaProvider.cjs +12 -11
  72. package/dist/provider/AthenaProvider.cjs.map +1 -1
  73. package/dist/provider/AthenaProvider.js +11 -10
  74. package/dist/provider/AthenaProvider.js.map +1 -1
  75. package/dist/provider/statewire-window-context.cjs.map +1 -1
  76. package/dist/provider/statewire-window-context.d.ts +8 -8
  77. package/dist/provider/statewire-window-context.js.map +1 -1
  78. package/dist/react/package.json.cjs +1 -1
  79. package/dist/react/package.json.js +1 -1
  80. package/dist/runtime/useAthenaStatewireRuntime.cjs +0 -2
  81. package/dist/runtime/useAthenaStatewireRuntime.cjs.map +1 -1
  82. package/dist/runtime/useAthenaStatewireRuntime.d.ts +5 -5
  83. package/dist/runtime/useAthenaStatewireRuntime.js +0 -2
  84. package/dist/runtime/useAthenaStatewireRuntime.js.map +1 -1
  85. package/package.json +1 -1
  86. package/dist/agent-runtime/src/history-pages.cjs +0 -279
  87. package/dist/agent-runtime/src/history-pages.cjs.map +0 -1
  88. package/dist/agent-runtime/src/history-pages.d.ts +0 -252
  89. package/dist/agent-runtime/src/history-pages.js +0 -279
  90. package/dist/agent-runtime/src/history-pages.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"runconfig-contract.js","sources":["../../../../../agent-runtime/src/generated/runconfig-contract.ts"],"sourcesContent":["// GENERATED FILE — DO NOT EDIT BY HAND.\n//\n// Source of truth (agora):\n// agora/agora/graphs/athena_deep_agent/run_config.py (_PARSED_CUSTOM_KEYS / _COMPANION_CUSTOM_KEYS / PER_SEND_CUSTOM_KEYS)\n// agora/agora/graphs/athena_deep_agent/thread_config.py (server config lane + config/* command names)\n// agora/agora/graphs/athena_deep_agent/session_asset.py (KNOWN_START_CHANNELS / DEEP_AGENT_RUNTIME_MARKER)\n// agora/agora/graphs/athena_deep_agent/client_tools.py (client-tool interrupt + result-envelope literals)\n// agora/agora/graphs/athena_deep_agent/protocol_version.py (wire-contract version negotiation)\n// agora/agora/graphs/athena_deep_agent/message_window.py (interest windows + history commands)\n// agora/agora/graphs/athena_deep_agent/history_page.py (older history by command)\n// agora/agora/type_definitions/collab_agent.py (CAPABILITIES ladder: absent mode + new-agent default)\n//\n// Regenerate:\n// cd agora && mise exec -- infisical run --command 'uv run python scripts/export_runconfig_contract.py'\n//\n// CI verifies this file matches the Python source (agora-check runs the\n// exporter with --check), so hand edits and un-regenerated key changes fail.\n\n/** `runConfig.custom` keys parsed by agora's `parse_deep_agent_run_config`. */\nexport const RUN_CONFIG_PARSED_CUSTOM_KEYS = [\n \"agent_catalog_asset_ids\",\n \"approve_changes\",\n \"catalog_asset_ids\",\n \"channel_reply_turn\",\n \"coding_worker_asset_id\",\n \"coding_workers\",\n \"compiled_subagents\",\n \"declined_toolkit_ids\",\n \"drive_mounts\",\n \"enable_interpreter\",\n \"enable_persistent_fs\",\n \"enable_sandbox\",\n \"enable_skills\",\n \"enabled_tools\",\n \"environment\",\n \"environment_id\",\n \"environment_name\",\n \"excluded_middleware\",\n \"excluded_tools\",\n \"extra_middleware\",\n \"include_citation_instructions\",\n \"interpreter_max_ptc_calls\",\n \"interpreter_mode\",\n \"interpreter_ptc\",\n \"interpreter_ptc_exclusive\",\n \"interpreter_runtime\",\n \"interpreter_subagents\",\n \"interpreter_timeout_seconds\",\n \"interrupt_on\",\n \"knowledge_base\",\n \"mcp_server_configs\",\n \"mcp_servers\",\n \"memory\",\n \"outbound_approval_allowlist\",\n \"permissions\",\n \"pre_approved_tools\",\n \"project_id\",\n \"read_only\",\n \"recursion_limit\",\n \"run_label\",\n \"sandbox_runtime\",\n \"secret_asset_ids\",\n \"session_computer\",\n \"session_machine\",\n \"session_vm_retention\",\n \"skill_asset_ids\",\n \"skills\",\n \"subagents\",\n \"system_prompt\",\n \"tool_description_overrides\",\n \"voice_update_handle\",\n \"workbench\",\n] as const;\n\n/** `runConfig.custom` keys consumed by the surrounding deep-agent request machinery rather than the capability parser. */\nexport const RUN_CONFIG_COMPANION_CUSTOM_KEYS = [\n \"addressed_agents\",\n \"agent\",\n \"agent_available_toolkits\",\n \"allowed_tab_ids\",\n \"app_id\",\n \"channel\",\n \"channel_router\",\n \"client_tools\",\n \"collab_agent_id\",\n \"collab_channel_id\",\n \"collab_entry_channel_id\",\n \"custom_tool_configs\",\n \"deterministic\",\n \"device_id\",\n \"device_toolkits\",\n \"dry_run\",\n \"enabled_toolkits\",\n \"entry_point\",\n \"from_stored_config\",\n \"frontend_available\",\n \"generative_frame_inline\",\n \"github_identity\",\n \"max_tokens\",\n \"middleware\",\n \"model\",\n \"muses_enabled\",\n \"muses_recall_enabled\",\n \"office_context\",\n \"panel_config\",\n \"posthog_session_id\",\n \"run_budget\",\n \"runtime\",\n \"session_id\",\n \"session_origin_kind\",\n \"session_tab_id\",\n \"skip_title_generation\",\n \"source_aop_id\",\n \"start_channel\",\n \"structured_output\",\n \"temperature\",\n \"tool_limit_override\",\n \"trigger_type\",\n \"workspace_id\",\n] as const;\n\n/** Every `runConfig.custom` key some deep-agent request consumer reads. A key outside this set is invisible to the run and trips agora's unknown-key telemetry. */\nexport const RUN_CONFIG_CUSTOM_KEYS = [\n \"addressed_agents\",\n \"agent\",\n \"agent_available_toolkits\",\n \"agent_catalog_asset_ids\",\n \"allowed_tab_ids\",\n \"app_id\",\n \"approve_changes\",\n \"catalog_asset_ids\",\n \"channel\",\n \"channel_reply_turn\",\n \"channel_router\",\n \"client_tools\",\n \"coding_worker_asset_id\",\n \"coding_workers\",\n \"collab_agent_id\",\n \"collab_channel_id\",\n \"collab_entry_channel_id\",\n \"compiled_subagents\",\n \"custom_tool_configs\",\n \"declined_toolkit_ids\",\n \"deterministic\",\n \"device_id\",\n \"device_toolkits\",\n \"drive_mounts\",\n \"dry_run\",\n \"enable_interpreter\",\n \"enable_persistent_fs\",\n \"enable_sandbox\",\n \"enable_skills\",\n \"enabled_toolkits\",\n \"enabled_tools\",\n \"entry_point\",\n \"environment\",\n \"environment_id\",\n \"environment_name\",\n \"excluded_middleware\",\n \"excluded_tools\",\n \"extra_middleware\",\n \"from_stored_config\",\n \"frontend_available\",\n \"generative_frame_inline\",\n \"github_identity\",\n \"include_citation_instructions\",\n \"interpreter_max_ptc_calls\",\n \"interpreter_mode\",\n \"interpreter_ptc\",\n \"interpreter_ptc_exclusive\",\n \"interpreter_runtime\",\n \"interpreter_subagents\",\n \"interpreter_timeout_seconds\",\n \"interrupt_on\",\n \"knowledge_base\",\n \"max_tokens\",\n \"mcp_server_configs\",\n \"mcp_servers\",\n \"memory\",\n \"middleware\",\n \"model\",\n \"muses_enabled\",\n \"muses_recall_enabled\",\n \"office_context\",\n \"outbound_approval_allowlist\",\n \"panel_config\",\n \"permissions\",\n \"posthog_session_id\",\n \"pre_approved_tools\",\n \"project_id\",\n \"read_only\",\n \"recursion_limit\",\n \"run_budget\",\n \"run_label\",\n \"runtime\",\n \"sandbox_runtime\",\n \"secret_asset_ids\",\n \"session_computer\",\n \"session_id\",\n \"session_machine\",\n \"session_origin_kind\",\n \"session_tab_id\",\n \"session_vm_retention\",\n \"skill_asset_ids\",\n \"skills\",\n \"skip_title_generation\",\n \"source_aop_id\",\n \"start_channel\",\n \"structured_output\",\n \"subagents\",\n \"system_prompt\",\n \"temperature\",\n \"tool_description_overrides\",\n \"tool_limit_override\",\n \"trigger_type\",\n \"voice_update_handle\",\n \"workbench\",\n \"workspace_id\",\n] as const;\n\nexport type RunConfigCustomKey = (typeof RUN_CONFIG_CUSTOM_KEYS)[number];\n\n/** Fast membership checks for builder/test assertions. */\nexport const RUN_CONFIG_CUSTOM_KEY_SET: ReadonlySet<string> = new Set(\n RUN_CONFIG_CUSTOM_KEYS,\n);\n\n/** `runConfig.custom` keys a client still carries per send on a thread with server config; every other key is dropped at dispatch. */\nexport const RUN_CONFIG_PER_SEND_CUSTOM_KEYS = [\n \"addressed_agents\",\n \"agent\",\n \"agent_available_toolkits\",\n \"allowed_tab_ids\",\n \"app_id\",\n \"channel\",\n \"channel_reply_turn\",\n \"channel_router\",\n \"client_tools\",\n \"collab_channel_id\",\n \"collab_entry_channel_id\",\n \"deterministic\",\n \"device_id\",\n \"device_toolkits\",\n \"dry_run\",\n \"entry_point\",\n \"from_stored_config\",\n \"frontend_available\",\n \"generative_frame_inline\",\n \"github_identity\",\n \"muses_enabled\",\n \"muses_recall_enabled\",\n \"office_context\",\n \"posthog_session_id\",\n \"project_id\",\n \"read_only\",\n \"run_budget\",\n \"runtime\",\n \"session_id\",\n \"session_origin_kind\",\n \"session_tab_id\",\n \"skip_title_generation\",\n \"source_aop_id\",\n \"start_channel\",\n \"structured_output\",\n \"tool_limit_override\",\n \"trigger_type\",\n \"voice_update_handle\",\n \"workspace_id\",\n] as const;\n\nexport type RunConfigPerSendCustomKey =\n (typeof RUN_CONFIG_PER_SEND_CUSTOM_KEYS)[number];\n\n/** Fast membership checks for builder/test assertions. */\nexport const RUN_CONFIG_PER_SEND_CUSTOM_KEY_SET: ReadonlySet<string> = new Set(\n RUN_CONFIG_PER_SEND_CUSTOM_KEYS,\n);\n\n/** Keys the thread's server config lane owns — changed only through the `config/*` commands, never per send. */\nexport const THREAD_CONFIG_CUSTOM_KEYS = [\n \"agent_catalog_asset_ids\",\n \"approve_changes\",\n \"catalog_asset_ids\",\n \"coding_worker_asset_id\",\n \"coding_workers\",\n \"collab_agent_id\",\n \"compiled_subagents\",\n \"custom_tool_configs\",\n \"declined_toolkit_ids\",\n \"drive_mounts\",\n \"enable_interpreter\",\n \"enable_persistent_fs\",\n \"enable_sandbox\",\n \"enable_skills\",\n \"enabled_toolkits\",\n \"enabled_tools\",\n \"environment\",\n \"environment_id\",\n \"environment_name\",\n \"excluded_middleware\",\n \"excluded_tools\",\n \"extra_middleware\",\n \"include_citation_instructions\",\n \"interpreter_max_ptc_calls\",\n \"interpreter_mode\",\n \"interpreter_ptc\",\n \"interpreter_ptc_exclusive\",\n \"interpreter_runtime\",\n \"interpreter_subagents\",\n \"interpreter_timeout_seconds\",\n \"interrupt_on\",\n \"knowledge_base\",\n \"max_tokens\",\n \"mcp_server_configs\",\n \"mcp_servers\",\n \"memory\",\n \"middleware\",\n \"model\",\n \"outbound_approval_allowlist\",\n \"permissions\",\n \"pre_approved_tools\",\n \"recursion_limit\",\n \"run_label\",\n \"sandbox_runtime\",\n \"secret_asset_ids\",\n \"session_computer\",\n \"session_machine\",\n \"session_vm_retention\",\n \"skill_asset_ids\",\n \"skills\",\n \"subagents\",\n \"system_prompt\",\n \"temperature\",\n \"tool_description_overrides\",\n \"workbench\",\n] as const;\n\nexport type ThreadConfigCustomKey = (typeof THREAD_CONFIG_CUSTOM_KEYS)[number];\n\n/** Fast membership checks for builder/test assertions. */\nexport const THREAD_CONFIG_CUSTOM_KEY_SET: ReadonlySet<string> = new Set(\n THREAD_CONFIG_CUSTOM_KEYS,\n);\n\n/** Replicated-state key of the server config lane (`{ version, custom }`). */\nexport const DEEP_AGENT_CONFIG_STATE_KEY = \"config\";\n\n/** The statewire commands that mutate the server config lane. */\nexport const DEEP_AGENT_CONFIG_COMMANDS = {\n patch: \"config/patch\",\n toolsEnable: \"config/tools/enable\",\n toolsDisable: \"config/tools/disable\",\n} as const;\n\n/** `start_channel` values the session substrate stamps as provenance; anything else clamps to \"web\". */\nexport const KNOWN_START_CHANNELS = [\n \"agent_orchestration\",\n \"api\",\n \"automation\",\n \"chrome_extension\",\n \"cli\",\n \"comment_agent\",\n \"default_voice\",\n \"desktop_app\",\n \"email\",\n \"meetings\",\n \"mobile_app\",\n \"mobile_app_voice\",\n \"office_addin\",\n \"orchestration\",\n \"programmatic\",\n \"slack\",\n \"sms\",\n \"task\",\n \"teams\",\n \"voice\",\n \"voice_memo\",\n \"web\",\n] as const;\n\nexport type KnownStartChannel = (typeof KNOWN_START_CHANNELS)[number];\n\n/** Fast membership checks for builder/test assertions. */\nexport const KNOWN_START_CHANNEL_SET: ReadonlySet<string> = new Set(\n KNOWN_START_CHANNELS,\n);\n\n/** `runConfig.custom.runtime` marker selecting the deep-agent runtime. */\nexport const DEEP_AGENT_RUNTIME_MARKER = \"athena_deep_agent\";\n\n/**\n * Collab-agent capability ladder (agent schema v3): per explicit\n * capability field, what an ABSENT value means and the value stamped on\n * a new agent. Resolved by agora's `capability_decoder` and the one agent\n * compiler on every run: `passthrough` — explicit only, absent means off;\n * `off` — absent means off under every `runtime` marker; `runtime` —\n * absent derives from the `runtime` marker (`athena_deep_agent` on, any\n * other or missing marker off).\n */\nexport const COLLAB_AGENT_CAPABILITIES = {\n deepAgentBuiltinsEnabled: { absent: \"runtime\", default: true },\n interpreterEnabled: { absent: \"off\", default: false },\n sandboxEnabled: { absent: \"passthrough\", default: false },\n skillsEnabled: { absent: \"runtime\", default: true },\n} as const;\n\nexport type CollabAgentCapabilityField = keyof typeof COLLAB_AGENT_CAPABILITIES;\n\nexport type CollabAgentCapabilityAbsentMode =\n (typeof COLLAB_AGENT_CAPABILITIES)[CollabAgentCapabilityField][\"absent\"];\n\n/** `source`/`type` stamped on client-tool interrupt payloads by agora. */\nexport const CLIENT_TOOL_INTERRUPT_SOURCE = \"client_tool\";\n\n/** `status` literals of the result envelope a client resumes a parked client-tool call with. */\nexport const CLIENT_TOOL_RESULT_STATUSES = [\"error\", \"success\"] as const;\n\nexport type ClientToolResultStatus =\n (typeof CLIENT_TOOL_RESULT_STATUSES)[number];\n\nexport const CLIENT_TOOL_RESULT_STATUS_SUCCESS = \"success\";\n\nexport const CLIENT_TOOL_RESULT_STATUS_ERROR = \"error\";\n\n/**\n * Result envelope a client resumes a parked client-tool call with,\n * keyed by interrupt id:\n * `{ client_tool_results: { <interrupt_id>: <envelope> } }`.\n * Agora relays the envelope to the model verbatim.\n */\nexport type ClientToolResultEnvelopeContract =\n | { status: typeof CLIENT_TOOL_RESULT_STATUS_SUCCESS; result: unknown }\n | { status: typeof CLIENT_TOOL_RESULT_STATUS_ERROR; error: string };\n\n/**\n * The deep-agent wire-contract version this client build speaks,\n * declared on every attach. The host records it for attach telemetry\n * and per-version behaviour; it has no minimum client version, so no\n * build is refused for the version it declares (the `protocol` state\n * lane's `minClientVersion` is the constant 1).\n */\nexport const DEEP_AGENT_PROTOCOL_VERSION = 3;\n\n/**\n * The first contract version whose host a client states `follow` to (a\n * subagent lane's steps, each its own document): a client follows a\n * lane only on a host whose `protocol` lane advertises at least this\n * version. A host that predates `follow` refuses it with\n * `invalid-interest`.\n */\nexport const DEEP_AGENT_LANE_FOLLOW_PROTOCOL_VERSION = 2;\n\n/** Attach header carrying the client's declared contract version. */\nexport const DEEP_AGENT_PROTOCOL_VERSION_HEADER =\n \"x-athena-deep-agent-protocol-version\";\n\n/** Attach header declaring the head window a fresh client wants in its hello (host-clamped). */\nexport const DEEP_AGENT_MESSAGE_WINDOW_HEADER = \"x-athena-deep-agent-window\";\n\n/**\n * Attach header carrying the view a re-attaching client holds (JSON:\n * requests, head floor, lane floors): its hello carries that view on\n * any host instance.\n */\nexport const DEEP_AGENT_MESSAGE_INTERESTS_HEADER =\n \"x-athena-deep-agent-interests\";\n\n/** The largest interests header the host reads; larger is undeclared. */\nexport const DEEP_AGENT_MAX_MESSAGE_INTERESTS_HEADER_BYTES = 8192;\n\n/** Replicated-state key of the server-advertised version lane. */\nexport const DEEP_AGENT_PROTOCOL_STATE_KEY = \"protocol\";\n\n/** Ephemeral subprotocol carrying a client's message-window interests. */\nexport const DEEP_AGENT_INTEREST_PROTOCOL = \"athena/interest\";\n\n/** Ephemeral subprotocol carrying a client's synced context document. */\nexport const DEEP_AGENT_CONTEXT_PROTOCOL = \"athena/context\";\n\n/** The only interest namespace the host resolves (the linear transcript). */\nexport const DEEP_AGENT_MAIN_NS = \"main\";\n\n/** Window size (interest `before`) a client asks for by default. */\nexport const DEEP_AGENT_DEFAULT_MESSAGE_WINDOW = 40;\n\n/** Bounds on a window size. */\nexport const DEEP_AGENT_MIN_MESSAGE_WINDOW = 8;\n\nexport const DEEP_AGENT_MAX_MESSAGE_WINDOW = 200;\n\n/** Interests one attach may hold at once (the head plus its pages). */\nexport const DEEP_AGENT_MAX_INTERESTS = 16;\n\n/**\n * Rejection code of an interest `set` whose windows resolve past the\n * attach's interest document budget: the view is as deep as one attach holds.\n */\nexport const DEEP_AGENT_OVERSIZED_INTEREST_CODE = \"oversized-interest\";\n\n/** Command returning a truncated tool output whole. */\nexport const DEEP_AGENT_HISTORY_TOOL_OUTPUT_COMMAND = \"history/tool_output\";\n\n/**\n * Command answering older history as whole turns (`{before, turns}`) or\n * one turn's steps (`{turn, before?, steps}`), outside the attach's view.\n */\nexport const DEEP_AGENT_HISTORY_PAGE_COMMAND = \"history/page\";\n\n/** The first host contract version that answers `DEEP_AGENT_HISTORY_PAGE_COMMAND`. */\nexport const DEEP_AGENT_HISTORY_PAGE_PROTOCOL_VERSION = 3;\n\n/** Turns one history page answers at most. */\nexport const DEEP_AGENT_MAX_HISTORY_PAGE_TURNS = 50;\n\n/** Steps of one turn one history page answers at most. */\nexport const DEEP_AGENT_MAX_HISTORY_PAGE_STEPS = 200;\n\n/** Command returning one stored message whole (provenance and full tool output included). */\nexport const DEEP_AGENT_HISTORY_MESSAGE_COMMAND = \"history/message\";\n\n/** Wire key marking a tool message whose content was truncated. */\nexport const DEEP_AGENT_TRUNCATED_CONTENT_KEY = \"athena_content_truncated\";\n\n/**\n * Wire key on a running `task` card whose nested transcript rides cut to its\n * newest steps: `{ messages, tool_calls }` over the whole stored transcript.\n */\nexport const DEEP_AGENT_TRUNCATED_LANE_KEY = \"athena_lane_truncated\";\n\n/**\n * Wire key on a `task` card, and on an in-eval lane's `ptc_subagents` entry,\n * carrying the whole lane's token use however much of the lane the wire\n * carries: `{ input_tokens, output_tokens, cache_read_input_tokens,\n * cache_creation_input_tokens }`, the input counting its cache reads and\n * writes. Absent while the lane's steps report no usage.\n */\nexport const DEEP_AGENT_LANE_USAGE_KEY = \"athena_lane_usage\";\n\n/**\n * The newest nested messages a cut card carries whole; the entries ahead\n * of them are the older assistant turns that requested results among\n * them, cut to those calls.\n */\nexport const DEEP_AGENT_RUNNING_LANE_WIRE_MESSAGES = 8;\n\n/**\n * Key of a followed lane's window (`follows[ns]` on a resolution whose\n * request added `follow: {before}`) naming the `task` call whose card\n * holds the lane.\n */\nexport const DEEP_AGENT_FOLLOW_TOOL_CALL_ID_KEY = \"toolCallId\";\n\n/** The most lane steps one attach follows, across every lane. */\nexport const DEEP_AGENT_MAX_FOLLOWED_STEPS = 200;\n\n/**\n * The first contract version a client declares to see a finished card cut\n * like a running one (and to follow lanes and page them through\n * `history/lane`). Below it, or declaring nothing, finished cards ride whole.\n */\nexport const DEEP_AGENT_LANE_CUT_PROTOCOL_VERSION = 2;\n\n/**\n * Last element of the key a cut finished card's document rides under:\n * `[threadId, \"main\", messageId, \"cut\"]`. A view holds that key or the\n * card's own, never both.\n */\nexport const DEEP_AGENT_CUT_LANE_DOCUMENT = \"cut\";\n\n/**\n * Command returning one page of a card's nested transcript, oldest first:\n * `{ messageId, before, at? }` answers\n * `{ messageId, toolCallId, ns, steps, more: { before }, total }`; the page\n * holds the newest `before` entries, or those strictly older than `at`.\n */\nexport const DEEP_AGENT_HISTORY_LANE_COMMAND = \"history/lane\";\n\n/** The most entries one `history/lane` page asks for. */\nexport const DEEP_AGENT_MAX_LANE_PAGE = 200;\n\n/** The most encoded characters one `history/lane` page carries (at least one entry). */\nexport const DEEP_AGENT_HISTORY_LANE_PAGE_CHARS = 1048576;\n\n/**\n * Set on the last step of a cut finished card whose text is the card's own\n * `content` (the subagent's report): the step rides with empty content, and\n * the card's `content` is its text.\n */\nexport const DEEP_AGENT_REPEATS_RESULT_KEY = \"athena_content_repeats_result\";\n\n/** Most inline-image payload characters one message carries whole on the wire. */\nexport const DEEP_AGENT_INLINE_IMAGE_WIRE_BUDGET = 4194304;\n\n/** Wire key on an image block left off the wire: `{ index, chars, mediaType }`. */\nexport const DEEP_AGENT_OMITTED_IMAGE_KEY = \"athena_image_omitted\";\n\n/** The image an omitted block carries instead of its own (a neutral PNG tile). */\nexport const DEEP_AGENT_OMITTED_IMAGE_PLACEHOLDER_URL =\n \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAAB4AQMAAABPbGssAAAABlBMVEXi6PCUo7jao11HAAAA6ElEQVR42u2UyW3DMBBF3wxogEd2EJbCElKQDRCwC3MpSRc5eLuYokgNLEUxctK/CHyanQts2vRO3QdlALVsXsBvecqxxr1ob0A5GlDJU+hICxN54p/qXAx/+FpoeeE8hTerzfvByn7ifzpaBtWCOwv6bMVMBgzRgNGKmUL9McDs4XOSyEHuoKCI76AiqOugg+y0gx6SN+YQg3QwALGk19pQSKV/reOocyoww27oU5sxhAbKUNgIqrVxrvnovJ80MFgxYy23wtTss44tmL+bAuOE2p2o0fJa3iW/6iR/lEfx8kv3TZtW6AFk5Sf3k+GTswAAAABJRU5ErkJggg==\";\n\n/**\n * Command returning one inline image of a stored message in chunks:\n * `{ messageId, index, offset? }` answers\n * `{ messageId, index, mediaType, offset, total, chunk, next }`; the\n * chunks joined in order are the image's `data:` URL, and `next` is\n * the offset to ask for next (`null` after the last chunk).\n */\nexport const DEEP_AGENT_HISTORY_IMAGE_COMMAND = \"history/image\";\n\n/**\n * Command returning one inline image of a lane step in chunks, as\n * `history/image` does a stored message's: `{ messageId | lane, step,\n * index, offset? }` answers `{ messageId, lane, step, index, mediaType,\n * offset, total, chunk, next }`, with `messageId` null for an in-eval\n * lane and `lane` null for a card.\n */\nexport const DEEP_AGENT_HISTORY_LANE_IMAGE_COMMAND = \"history/lane_image\";\n"],"names":[],"mappings":"AA0HO,MAAM,yBAAyB;AAAA,EACpC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAK8D,IAAI;AAAA,EAChE;AACF;AAGO,MAAM,kCAAkC;AAAA,EAC7C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAMuE,IAAI;AAAA,EACzE;AACF;AAGO,MAAM,4BAA4B;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAKiE,IAAI;AAAA,EACnE;AACF;AAMO,MAAM,6BAA6B;AAAA,EACxC,OAAO;AAAA,EACP,aAAa;AAAA,EACb,cAAc;AAChB;AAGO,MAAM,uBAAuB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAK4D,IAAI;AAAA,EAC9D;AACF;AA2BO,MAAM,+BAA+B;AAQrC,MAAM,oCAAoC;AAE1C,MAAM,kCAAkC;AA+BxC,MAAM,qCACX;AAGK,MAAM,mCAAmC;AAOzC,MAAM,sCACX;AAGK,MAAM,gDAAgD;AAGtD,MAAM,gCAAgC;AAGtC,MAAM,+BAA+B;AAMrC,MAAM,qBAAqB;AAG3B,MAAM,oCAAoC;AAG1C,MAAM,gCAAgC;AAEtC,MAAM,gCAAgC;AAGtC,MAAM,2BAA2B;AAMjC,MAAM,qCAAqC;AAG3C,MAAM,yCAAyC;AAM/C,MAAM,kCAAkC;AAGxC,MAAM,2CAA2C;AASjD,MAAM,qCAAqC;AAG3C,MAAM,mCAAmC;AAMzC,MAAM,gCAAgC;AAStC,MAAM,4BAA4B;AAwBlC,MAAM,uCAAuC;AAO7C,MAAM,+BAA+B;AAQrC,MAAM,kCAAkC;AAGxC,MAAM,2BAA2B;AAUjC,MAAM,gCAAgC;"}
1
+ {"version":3,"file":"runconfig-contract.js","sources":["../../../../../agent-runtime/src/generated/runconfig-contract.ts"],"sourcesContent":["// GENERATED FILE — DO NOT EDIT BY HAND.\n//\n// Source of truth (agora):\n// agora/agora/graphs/athena_deep_agent/run_config.py (_PARSED_CUSTOM_KEYS / _COMPANION_CUSTOM_KEYS / PER_SEND_CUSTOM_KEYS)\n// agora/agora/graphs/athena_deep_agent/thread_config.py (server config lane + config/* command names)\n// agora/agora/graphs/athena_deep_agent/session_asset.py (KNOWN_START_CHANNELS / DEEP_AGENT_RUNTIME_MARKER)\n// agora/agora/graphs/athena_deep_agent/client_tools.py (client-tool interrupt + result-envelope literals)\n// agora/agora/graphs/athena_deep_agent/protocol_version.py (wire-contract version negotiation)\n// agora/agora/graphs/athena_deep_agent/message_window.py (interest windows + history commands)\n// agora/agora/graphs/athena_deep_agent/history_page.py (older history by command)\n// agora/agora/type_definitions/collab_agent.py (CAPABILITIES ladder: absent mode + new-agent default)\n//\n// Regenerate:\n// cd agora && mise exec -- infisical run --command 'uv run python scripts/export_runconfig_contract.py'\n//\n// CI verifies this file matches the Python source (agora-check runs the\n// exporter with --check), so hand edits and un-regenerated key changes fail.\n\n/** `runConfig.custom` keys parsed by agora's `parse_deep_agent_run_config`. */\nexport const RUN_CONFIG_PARSED_CUSTOM_KEYS = [\n \"agent_catalog_asset_ids\",\n \"approve_changes\",\n \"catalog_asset_ids\",\n \"channel_reply_turn\",\n \"coding_worker_asset_id\",\n \"coding_workers\",\n \"compiled_subagents\",\n \"declined_toolkit_ids\",\n \"drive_mounts\",\n \"enable_interpreter\",\n \"enable_persistent_fs\",\n \"enable_sandbox\",\n \"enable_skills\",\n \"enabled_tools\",\n \"environment\",\n \"environment_id\",\n \"environment_name\",\n \"excluded_middleware\",\n \"excluded_tools\",\n \"extra_middleware\",\n \"include_citation_instructions\",\n \"interpreter_max_ptc_calls\",\n \"interpreter_mode\",\n \"interpreter_ptc\",\n \"interpreter_ptc_exclusive\",\n \"interpreter_runtime\",\n \"interpreter_subagents\",\n \"interpreter_timeout_seconds\",\n \"interrupt_on\",\n \"knowledge_base\",\n \"mcp_server_configs\",\n \"mcp_servers\",\n \"memory\",\n \"outbound_approval_allowlist\",\n \"permissions\",\n \"pre_approved_tools\",\n \"project_id\",\n \"read_only\",\n \"recursion_limit\",\n \"run_label\",\n \"sandbox_runtime\",\n \"secret_asset_ids\",\n \"session_computer\",\n \"session_machine\",\n \"session_vm_retention\",\n \"skill_asset_ids\",\n \"skills\",\n \"subagents\",\n \"system_prompt\",\n \"tool_description_overrides\",\n \"voice_update_handle\",\n \"workbench\",\n] as const;\n\n/** `runConfig.custom` keys consumed by the surrounding deep-agent request machinery rather than the capability parser. */\nexport const RUN_CONFIG_COMPANION_CUSTOM_KEYS = [\n \"addressed_agents\",\n \"agent\",\n \"agent_available_toolkits\",\n \"allowed_tab_ids\",\n \"app_id\",\n \"channel\",\n \"channel_router\",\n \"client_tools\",\n \"collab_agent_id\",\n \"collab_channel_id\",\n \"collab_entry_channel_id\",\n \"custom_tool_configs\",\n \"deterministic\",\n \"device_id\",\n \"device_toolkits\",\n \"dry_run\",\n \"enabled_toolkits\",\n \"entry_point\",\n \"from_stored_config\",\n \"frontend_available\",\n \"generative_frame_inline\",\n \"github_identity\",\n \"max_tokens\",\n \"middleware\",\n \"model\",\n \"muses_enabled\",\n \"muses_recall_enabled\",\n \"office_context\",\n \"panel_config\",\n \"posthog_session_id\",\n \"run_budget\",\n \"runtime\",\n \"session_id\",\n \"session_origin_kind\",\n \"session_tab_id\",\n \"skip_title_generation\",\n \"source_aop_id\",\n \"start_channel\",\n \"structured_output\",\n \"temperature\",\n \"tool_limit_override\",\n \"trigger_type\",\n \"workspace_id\",\n] as const;\n\n/** Every `runConfig.custom` key some deep-agent request consumer reads. A key outside this set is invisible to the run and trips agora's unknown-key telemetry. */\nexport const RUN_CONFIG_CUSTOM_KEYS = [\n \"addressed_agents\",\n \"agent\",\n \"agent_available_toolkits\",\n \"agent_catalog_asset_ids\",\n \"allowed_tab_ids\",\n \"app_id\",\n \"approve_changes\",\n \"catalog_asset_ids\",\n \"channel\",\n \"channel_reply_turn\",\n \"channel_router\",\n \"client_tools\",\n \"coding_worker_asset_id\",\n \"coding_workers\",\n \"collab_agent_id\",\n \"collab_channel_id\",\n \"collab_entry_channel_id\",\n \"compiled_subagents\",\n \"custom_tool_configs\",\n \"declined_toolkit_ids\",\n \"deterministic\",\n \"device_id\",\n \"device_toolkits\",\n \"drive_mounts\",\n \"dry_run\",\n \"enable_interpreter\",\n \"enable_persistent_fs\",\n \"enable_sandbox\",\n \"enable_skills\",\n \"enabled_toolkits\",\n \"enabled_tools\",\n \"entry_point\",\n \"environment\",\n \"environment_id\",\n \"environment_name\",\n \"excluded_middleware\",\n \"excluded_tools\",\n \"extra_middleware\",\n \"from_stored_config\",\n \"frontend_available\",\n \"generative_frame_inline\",\n \"github_identity\",\n \"include_citation_instructions\",\n \"interpreter_max_ptc_calls\",\n \"interpreter_mode\",\n \"interpreter_ptc\",\n \"interpreter_ptc_exclusive\",\n \"interpreter_runtime\",\n \"interpreter_subagents\",\n \"interpreter_timeout_seconds\",\n \"interrupt_on\",\n \"knowledge_base\",\n \"max_tokens\",\n \"mcp_server_configs\",\n \"mcp_servers\",\n \"memory\",\n \"middleware\",\n \"model\",\n \"muses_enabled\",\n \"muses_recall_enabled\",\n \"office_context\",\n \"outbound_approval_allowlist\",\n \"panel_config\",\n \"permissions\",\n \"posthog_session_id\",\n \"pre_approved_tools\",\n \"project_id\",\n \"read_only\",\n \"recursion_limit\",\n \"run_budget\",\n \"run_label\",\n \"runtime\",\n \"sandbox_runtime\",\n \"secret_asset_ids\",\n \"session_computer\",\n \"session_id\",\n \"session_machine\",\n \"session_origin_kind\",\n \"session_tab_id\",\n \"session_vm_retention\",\n \"skill_asset_ids\",\n \"skills\",\n \"skip_title_generation\",\n \"source_aop_id\",\n \"start_channel\",\n \"structured_output\",\n \"subagents\",\n \"system_prompt\",\n \"temperature\",\n \"tool_description_overrides\",\n \"tool_limit_override\",\n \"trigger_type\",\n \"voice_update_handle\",\n \"workbench\",\n \"workspace_id\",\n] as const;\n\nexport type RunConfigCustomKey = (typeof RUN_CONFIG_CUSTOM_KEYS)[number];\n\n/** Fast membership checks for builder/test assertions. */\nexport const RUN_CONFIG_CUSTOM_KEY_SET: ReadonlySet<string> = new Set(\n RUN_CONFIG_CUSTOM_KEYS,\n);\n\n/** `runConfig.custom` keys a client still carries per send on a thread with server config; every other key is dropped at dispatch. */\nexport const RUN_CONFIG_PER_SEND_CUSTOM_KEYS = [\n \"addressed_agents\",\n \"agent\",\n \"agent_available_toolkits\",\n \"allowed_tab_ids\",\n \"app_id\",\n \"channel\",\n \"channel_reply_turn\",\n \"channel_router\",\n \"client_tools\",\n \"collab_channel_id\",\n \"collab_entry_channel_id\",\n \"deterministic\",\n \"device_id\",\n \"device_toolkits\",\n \"dry_run\",\n \"entry_point\",\n \"from_stored_config\",\n \"frontend_available\",\n \"generative_frame_inline\",\n \"github_identity\",\n \"muses_enabled\",\n \"muses_recall_enabled\",\n \"office_context\",\n \"posthog_session_id\",\n \"project_id\",\n \"read_only\",\n \"run_budget\",\n \"runtime\",\n \"session_id\",\n \"session_origin_kind\",\n \"session_tab_id\",\n \"skip_title_generation\",\n \"source_aop_id\",\n \"start_channel\",\n \"structured_output\",\n \"tool_limit_override\",\n \"trigger_type\",\n \"voice_update_handle\",\n \"workspace_id\",\n] as const;\n\nexport type RunConfigPerSendCustomKey =\n (typeof RUN_CONFIG_PER_SEND_CUSTOM_KEYS)[number];\n\n/** Fast membership checks for builder/test assertions. */\nexport const RUN_CONFIG_PER_SEND_CUSTOM_KEY_SET: ReadonlySet<string> = new Set(\n RUN_CONFIG_PER_SEND_CUSTOM_KEYS,\n);\n\n/** Keys the thread's server config lane owns — changed only through the `config/*` commands, never per send. */\nexport const THREAD_CONFIG_CUSTOM_KEYS = [\n \"agent_catalog_asset_ids\",\n \"approve_changes\",\n \"catalog_asset_ids\",\n \"coding_worker_asset_id\",\n \"coding_workers\",\n \"collab_agent_id\",\n \"compiled_subagents\",\n \"custom_tool_configs\",\n \"declined_toolkit_ids\",\n \"drive_mounts\",\n \"enable_interpreter\",\n \"enable_persistent_fs\",\n \"enable_sandbox\",\n \"enable_skills\",\n \"enabled_toolkits\",\n \"enabled_tools\",\n \"environment\",\n \"environment_id\",\n \"environment_name\",\n \"excluded_middleware\",\n \"excluded_tools\",\n \"extra_middleware\",\n \"include_citation_instructions\",\n \"interpreter_max_ptc_calls\",\n \"interpreter_mode\",\n \"interpreter_ptc\",\n \"interpreter_ptc_exclusive\",\n \"interpreter_runtime\",\n \"interpreter_subagents\",\n \"interpreter_timeout_seconds\",\n \"interrupt_on\",\n \"knowledge_base\",\n \"max_tokens\",\n \"mcp_server_configs\",\n \"mcp_servers\",\n \"memory\",\n \"middleware\",\n \"model\",\n \"outbound_approval_allowlist\",\n \"permissions\",\n \"pre_approved_tools\",\n \"recursion_limit\",\n \"run_label\",\n \"sandbox_runtime\",\n \"secret_asset_ids\",\n \"session_computer\",\n \"session_machine\",\n \"session_vm_retention\",\n \"skill_asset_ids\",\n \"skills\",\n \"subagents\",\n \"system_prompt\",\n \"temperature\",\n \"tool_description_overrides\",\n \"workbench\",\n] as const;\n\nexport type ThreadConfigCustomKey = (typeof THREAD_CONFIG_CUSTOM_KEYS)[number];\n\n/** Fast membership checks for builder/test assertions. */\nexport const THREAD_CONFIG_CUSTOM_KEY_SET: ReadonlySet<string> = new Set(\n THREAD_CONFIG_CUSTOM_KEYS,\n);\n\n/** Replicated-state key of the server config lane (`{ version, custom }`). */\nexport const DEEP_AGENT_CONFIG_STATE_KEY = \"config\";\n\n/** The statewire commands that mutate the server config lane. */\nexport const DEEP_AGENT_CONFIG_COMMANDS = {\n patch: \"config/patch\",\n toolsEnable: \"config/tools/enable\",\n toolsDisable: \"config/tools/disable\",\n} as const;\n\n/** `start_channel` values the session substrate stamps as provenance; anything else clamps to \"web\". */\nexport const KNOWN_START_CHANNELS = [\n \"agent_orchestration\",\n \"api\",\n \"automation\",\n \"chrome_extension\",\n \"cli\",\n \"comment_agent\",\n \"default_voice\",\n \"desktop_app\",\n \"email\",\n \"meetings\",\n \"mobile_app\",\n \"mobile_app_voice\",\n \"office_addin\",\n \"orchestration\",\n \"programmatic\",\n \"slack\",\n \"sms\",\n \"task\",\n \"teams\",\n \"voice\",\n \"voice_memo\",\n \"web\",\n] as const;\n\nexport type KnownStartChannel = (typeof KNOWN_START_CHANNELS)[number];\n\n/** Fast membership checks for builder/test assertions. */\nexport const KNOWN_START_CHANNEL_SET: ReadonlySet<string> = new Set(\n KNOWN_START_CHANNELS,\n);\n\n/** `runConfig.custom.runtime` marker selecting the deep-agent runtime. */\nexport const DEEP_AGENT_RUNTIME_MARKER = \"athena_deep_agent\";\n\n/**\n * Collab-agent capability ladder (agent schema v3): per explicit\n * capability field, what an ABSENT value means and the value stamped on\n * a new agent. Resolved by agora's `capability_decoder` and the one agent\n * compiler on every run: `passthrough` — explicit only, absent means off;\n * `off` — absent means off under every `runtime` marker; `runtime` —\n * absent derives from the `runtime` marker (`athena_deep_agent` on, any\n * other or missing marker off).\n */\nexport const COLLAB_AGENT_CAPABILITIES = {\n deepAgentBuiltinsEnabled: { absent: \"runtime\", default: true },\n interpreterEnabled: { absent: \"off\", default: false },\n sandboxEnabled: { absent: \"passthrough\", default: false },\n skillsEnabled: { absent: \"runtime\", default: true },\n} as const;\n\nexport type CollabAgentCapabilityField = keyof typeof COLLAB_AGENT_CAPABILITIES;\n\nexport type CollabAgentCapabilityAbsentMode =\n (typeof COLLAB_AGENT_CAPABILITIES)[CollabAgentCapabilityField][\"absent\"];\n\n/** `source`/`type` stamped on client-tool interrupt payloads by agora. */\nexport const CLIENT_TOOL_INTERRUPT_SOURCE = \"client_tool\";\n\n/** `status` literals of the result envelope a client resumes a parked client-tool call with. */\nexport const CLIENT_TOOL_RESULT_STATUSES = [\"error\", \"success\"] as const;\n\nexport type ClientToolResultStatus =\n (typeof CLIENT_TOOL_RESULT_STATUSES)[number];\n\nexport const CLIENT_TOOL_RESULT_STATUS_SUCCESS = \"success\";\n\nexport const CLIENT_TOOL_RESULT_STATUS_ERROR = \"error\";\n\n/**\n * Result envelope a client resumes a parked client-tool call with,\n * keyed by interrupt id:\n * `{ client_tool_results: { <interrupt_id>: <envelope> } }`.\n * Agora relays the envelope to the model verbatim.\n */\nexport type ClientToolResultEnvelopeContract =\n | { status: typeof CLIENT_TOOL_RESULT_STATUS_SUCCESS; result: unknown }\n | { status: typeof CLIENT_TOOL_RESULT_STATUS_ERROR; error: string };\n\n/**\n * The deep-agent wire-contract version this client build speaks,\n * declared on every attach. The host records it for attach telemetry\n * and per-version behaviour; it has no minimum client version, so no\n * build is refused for the version it declares (the `protocol` state\n * lane's `minClientVersion` is the constant 1).\n */\nexport const DEEP_AGENT_PROTOCOL_VERSION = 3;\n\n/**\n * The first contract version whose host a client states `follow` to (a\n * subagent lane's steps, each its own document): a client follows a\n * lane only on a host whose `protocol` lane advertises at least this\n * version. A host that predates `follow` refuses it with\n * `invalid-interest`.\n */\nexport const DEEP_AGENT_LANE_FOLLOW_PROTOCOL_VERSION = 2;\n\n/** Attach header carrying the client's declared contract version. */\nexport const DEEP_AGENT_PROTOCOL_VERSION_HEADER =\n \"x-athena-deep-agent-protocol-version\";\n\n/** Attach header declaring the head window a fresh client wants in its hello (host-clamped). */\nexport const DEEP_AGENT_MESSAGE_WINDOW_HEADER = \"x-athena-deep-agent-window\";\n\n/**\n * Attach header carrying the view a re-attaching client holds (JSON:\n * requests, head floor, lane floors): its hello carries that view on\n * any host instance.\n */\nexport const DEEP_AGENT_MESSAGE_INTERESTS_HEADER =\n \"x-athena-deep-agent-interests\";\n\n/** The largest interests header the host reads; larger is undeclared. */\nexport const DEEP_AGENT_MAX_MESSAGE_INTERESTS_HEADER_BYTES = 8192;\n\n/** Replicated-state key of the server-advertised version lane. */\nexport const DEEP_AGENT_PROTOCOL_STATE_KEY = \"protocol\";\n\n/** Ephemeral subprotocol carrying a client's message-window interests. */\nexport const DEEP_AGENT_INTEREST_PROTOCOL = \"athena/interest\";\n\n/** Ephemeral subprotocol carrying a client's synced context document. */\nexport const DEEP_AGENT_CONTEXT_PROTOCOL = \"athena/context\";\n\n/** The only interest namespace the host resolves (the linear transcript). */\nexport const DEEP_AGENT_MAIN_NS = \"main\";\n\n/** Window size (interest `before`) a client asks for by default. */\nexport const DEEP_AGENT_DEFAULT_MESSAGE_WINDOW = 40;\n\n/** Bounds on a window size. */\nexport const DEEP_AGENT_MIN_MESSAGE_WINDOW = 8;\n\nexport const DEEP_AGENT_MAX_MESSAGE_WINDOW = 200;\n\n/** Interests one attach may hold at once (the head plus its pages). */\nexport const DEEP_AGENT_MAX_INTERESTS = 16;\n\n/**\n * Rejection code of an interest `set` whose windows resolve past the\n * attach's interest document budget: the view is as deep as one attach holds.\n */\nexport const DEEP_AGENT_OVERSIZED_INTEREST_CODE = \"oversized-interest\";\n\n/** Command returning a truncated tool output whole. */\nexport const DEEP_AGENT_HISTORY_TOOL_OUTPUT_COMMAND = \"history/tool_output\";\n\n/**\n * Command answering older history as whole turns (`{before, turns}`) or\n * one turn's steps (`{turn, before?, steps}`), outside the attach's view.\n */\nexport const DEEP_AGENT_HISTORY_PAGE_COMMAND = \"history/page\";\n\n/** The first host contract version that answers `DEEP_AGENT_HISTORY_PAGE_COMMAND`. */\nexport const DEEP_AGENT_HISTORY_PAGE_PROTOCOL_VERSION = 3;\n\n/** Turns one history page answers at most. */\nexport const DEEP_AGENT_MAX_HISTORY_PAGE_TURNS = 50;\n\n/** Steps of one turn one history page answers at most. */\nexport const DEEP_AGENT_MAX_HISTORY_PAGE_STEPS = 200;\n\n/** Command returning one stored message whole (provenance and full tool output included). */\nexport const DEEP_AGENT_HISTORY_MESSAGE_COMMAND = \"history/message\";\n\n/** Wire key marking a tool message whose content was truncated. */\nexport const DEEP_AGENT_TRUNCATED_CONTENT_KEY = \"athena_content_truncated\";\n\n/**\n * Wire key on a running `task` card whose nested transcript rides cut to its\n * newest steps: `{ messages, tool_calls }` over the whole stored transcript.\n */\nexport const DEEP_AGENT_TRUNCATED_LANE_KEY = \"athena_lane_truncated\";\n\n/**\n * Wire key on a `task` card, and on an in-eval lane's `ptc_subagents` entry,\n * carrying the whole lane's token use however much of the lane the wire\n * carries: `{ input_tokens, output_tokens, cache_read_input_tokens,\n * cache_creation_input_tokens }`, the input counting its cache reads and\n * writes. Absent while the lane's steps report no usage.\n */\nexport const DEEP_AGENT_LANE_USAGE_KEY = \"athena_lane_usage\";\n\n/**\n * The newest nested messages a cut card carries whole; the entries ahead\n * of them are the older assistant turns that requested results among\n * them, cut to those calls.\n */\nexport const DEEP_AGENT_RUNNING_LANE_WIRE_MESSAGES = 8;\n\n/**\n * Key of a followed lane's window (`follows[ns]` on a resolution whose\n * request added `follow: {before}`) naming the `task` call whose card\n * holds the lane.\n */\nexport const DEEP_AGENT_FOLLOW_TOOL_CALL_ID_KEY = \"toolCallId\";\n\n/** The most lane steps one attach follows, across every lane. */\nexport const DEEP_AGENT_MAX_FOLLOWED_STEPS = 200;\n\n/**\n * The first contract version a client declares to see a finished card cut\n * like a running one (and to follow lanes and page them through\n * `history/lane`). Below it, or declaring nothing, finished cards ride whole.\n */\nexport const DEEP_AGENT_LANE_CUT_PROTOCOL_VERSION = 2;\n\n/**\n * Last element of the key a cut finished card's document rides under:\n * `[threadId, \"main\", messageId, \"cut\"]`. A view holds that key or the\n * card's own, never both.\n */\nexport const DEEP_AGENT_CUT_LANE_DOCUMENT = \"cut\";\n\n/**\n * Command returning one page of a card's nested transcript, oldest first:\n * `{ messageId, before, at? }` answers\n * `{ messageId, toolCallId, ns, steps, more: { before }, total }`; the page\n * holds the newest `before` entries, or those strictly older than `at`.\n */\nexport const DEEP_AGENT_HISTORY_LANE_COMMAND = \"history/lane\";\n\n/** The most entries one `history/lane` page asks for. */\nexport const DEEP_AGENT_MAX_LANE_PAGE = 200;\n\n/** The most encoded characters one `history/lane` page carries (at least one entry). */\nexport const DEEP_AGENT_HISTORY_LANE_PAGE_CHARS = 1048576;\n\n/** The most messages a paged-history head covers while it holds its floor. */\nexport const DEEP_AGENT_MAX_HELD_HEAD = 200;\n\n/**\n * Attach header by which a client says it keeps older history itself\n * (value `DEEP_AGENT_MESSAGE_HISTORY_PAGED`): its head then holds its floor\n * for at most `DEEP_AGENT_MAX_HELD_HEAD` messages.\n */\nexport const DEEP_AGENT_MESSAGE_HISTORY_HEADER = \"x-athena-deep-agent-history\";\n\nexport const DEEP_AGENT_MESSAGE_HISTORY_PAGED = \"paged\";\n\n/**\n * Set on the last step of a cut finished card whose text is the card's own\n * `content` (the subagent's report): the step rides with empty content, and\n * the card's `content` is its text.\n */\nexport const DEEP_AGENT_REPEATS_RESULT_KEY = \"athena_content_repeats_result\";\n\n/** Most inline-image payload characters one message carries whole on the wire. */\nexport const DEEP_AGENT_INLINE_IMAGE_WIRE_BUDGET = 4194304;\n\n/** Wire key on an image block left off the wire: `{ index, chars, mediaType }`. */\nexport const DEEP_AGENT_OMITTED_IMAGE_KEY = \"athena_image_omitted\";\n\n/** The image an omitted block carries instead of its own (a neutral PNG tile). */\nexport const DEEP_AGENT_OMITTED_IMAGE_PLACEHOLDER_URL =\n \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAAB4AQMAAABPbGssAAAABlBMVEXi6PCUo7jao11HAAAA6ElEQVR42u2UyW3DMBBF3wxogEd2EJbCElKQDRCwC3MpSRc5eLuYokgNLEUxctK/CHyanQts2vRO3QdlALVsXsBvecqxxr1ob0A5GlDJU+hICxN54p/qXAx/+FpoeeE8hTerzfvByn7ifzpaBtWCOwv6bMVMBgzRgNGKmUL9McDs4XOSyEHuoKCI76AiqOugg+y0gx6SN+YQg3QwALGk19pQSKV/reOocyoww27oU5sxhAbKUNgIqrVxrvnovJ80MFgxYy23wtTss44tmL+bAuOE2p2o0fJa3iW/6iR/lEfx8kv3TZtW6AFk5Sf3k+GTswAAAABJRU5ErkJggg==\";\n\n/**\n * Command returning one inline image of a stored message in chunks:\n * `{ messageId, index, offset? }` answers\n * `{ messageId, index, mediaType, offset, total, chunk, next }`; the\n * chunks joined in order are the image's `data:` URL, and `next` is\n * the offset to ask for next (`null` after the last chunk).\n */\nexport const DEEP_AGENT_HISTORY_IMAGE_COMMAND = \"history/image\";\n\n/**\n * Command returning one inline image of a lane step in chunks, as\n * `history/image` does a stored message's: `{ messageId | lane, step,\n * index, offset? }` answers `{ messageId, lane, step, index, mediaType,\n * offset, total, chunk, next }`, with `messageId` null for an in-eval\n * lane and `lane` null for a card.\n */\nexport const DEEP_AGENT_HISTORY_LANE_IMAGE_COMMAND = \"history/lane_image\";\n"],"names":[],"mappings":"AA0HO,MAAM,yBAAyB;AAAA,EACpC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAK8D,IAAI;AAAA,EAChE;AACF;AAGO,MAAM,kCAAkC;AAAA,EAC7C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAMuE,IAAI;AAAA,EACzE;AACF;AAGO,MAAM,4BAA4B;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAKiE,IAAI;AAAA,EACnE;AACF;AAMO,MAAM,6BAA6B;AAAA,EACxC,OAAO;AAAA,EACP,aAAa;AAAA,EACb,cAAc;AAChB;AAGO,MAAM,uBAAuB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAK4D,IAAI;AAAA,EAC9D;AACF;AA2BO,MAAM,+BAA+B;AAQrC,MAAM,oCAAoC;AAE1C,MAAM,kCAAkC;AA+BxC,MAAM,qCACX;AAGK,MAAM,mCAAmC;AAOzC,MAAM,sCACX;AAGK,MAAM,gDAAgD;AAGtD,MAAM,gCAAgC;AAGtC,MAAM,+BAA+B;AAMrC,MAAM,qBAAqB;AAG3B,MAAM,oCAAoC;AAG1C,MAAM,gCAAgC;AAEtC,MAAM,gCAAgC;AAGtC,MAAM,2BAA2B;AAMjC,MAAM,qCAAqC;AAG3C,MAAM,yCAAyC;AAM/C,MAAM,kCAAkC;AAGxC,MAAM,2CAA2C;AAGjD,MAAM,oCAAoC;AAG1C,MAAM,oCAAoC;AAG1C,MAAM,qCAAqC;AAG3C,MAAM,mCAAmC;AAMzC,MAAM,gCAAgC;AAStC,MAAM,4BAA4B;AAwBlC,MAAM,uCAAuC;AAO7C,MAAM,+BAA+B;AAQrC,MAAM,kCAAkC;AAGxC,MAAM,2BAA2B;AAajC,MAAM,oCAAoC;AAE1C,MAAM,mCAAmC;AAOzC,MAAM,gCAAgC;"}
@@ -0,0 +1,426 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const runconfigContract = require("./generated/runconfig-contract.cjs");
4
+ const toolNames = require("./tool-names.cjs");
5
+ const DEEP_AGENT_HISTORY_STORE_LIMIT = 8;
6
+ const DEEP_AGENT_TURN_STEPS_PAGE = 100;
7
+ const DEEP_AGENT_TURN_STEPS_KEY = "athena_turn_steps";
8
+ function toolCalls(messages) {
9
+ let tools = 0;
10
+ let delegations = 0;
11
+ for (const message of messages) {
12
+ if (message.type !== "ai") continue;
13
+ for (const call of message.tool_calls ?? []) {
14
+ if (toolNames.QUIET_TOOL_NAMES.has(call.name)) continue;
15
+ tools += 1;
16
+ if (call.name === "task") delegations += 1;
17
+ }
18
+ }
19
+ return { tools, delegations };
20
+ }
21
+ const markedCopies = /* @__PURE__ */ new WeakMap();
22
+ function withMarker(message, marker) {
23
+ const key = `${marker.thread}\0${marker.turn}\0${marker.hiddenSteps}\0${marker.hiddenTools}\0${marker.hiddenDelegations}\0${marker.before ?? ""}`;
24
+ const cached = markedCopies.get(message);
25
+ if ((cached == null ? void 0 : cached.key) === key) return cached.message;
26
+ const kwargs = message.additional_kwargs;
27
+ const marked = {
28
+ ...message,
29
+ additional_kwargs: { ...kwargs ?? {}, [DEEP_AGENT_TURN_STEPS_KEY]: marker }
30
+ };
31
+ markedCopies.set(message, { key, message: marked });
32
+ return marked;
33
+ }
34
+ function createDeepAgentHistoryStore() {
35
+ const parents = /* @__PURE__ */ new Map();
36
+ const summaries = /* @__PURE__ */ new Map();
37
+ const turnStarts = /* @__PURE__ */ new Map();
38
+ const messages = /* @__PURE__ */ new Map();
39
+ const loadingSteps = /* @__PURE__ */ new Set();
40
+ const listeners = /* @__PURE__ */ new Set();
41
+ let unserved = false;
42
+ let unservedBy;
43
+ let version = 0;
44
+ const notify = () => {
45
+ version += 1;
46
+ for (const listener of [...listeners]) listener();
47
+ };
48
+ const marker = (threadId, turn, state) => {
49
+ var _a;
50
+ const loaded = toolCalls(state.loaded);
51
+ return {
52
+ turn,
53
+ thread: threadId,
54
+ hiddenSteps: state.more ? Math.max(0, state.steps.count - state.loaded.length) : 0,
55
+ hiddenTools: Math.max(0, state.steps.tools - loaded.tools),
56
+ hiddenDelegations: Math.max(0, state.steps.delegations - loaded.delegations),
57
+ before: (_a = state.loaded[0]) == null ? void 0 : _a.id
58
+ };
59
+ };
60
+ const store = {
61
+ get unserved() {
62
+ return unserved;
63
+ },
64
+ get unservedBy() {
65
+ return unservedBy;
66
+ },
67
+ get version() {
68
+ return version;
69
+ },
70
+ markUnserved(connection) {
71
+ unservedBy = connection;
72
+ if (unserved) return;
73
+ unserved = true;
74
+ notify();
75
+ },
76
+ markServed() {
77
+ unservedBy = void 0;
78
+ if (!unserved) return;
79
+ unserved = false;
80
+ notify();
81
+ },
82
+ recordChain(ids, chainMessages, startsTranscript) {
83
+ for (let index = 0; index < ids.length; index += 1) {
84
+ const id = ids[index];
85
+ if (index > 0) parents.set(id, ids[index - 1]);
86
+ else if (startsTranscript) parents.set(id, null);
87
+ const message = chainMessages.get(id);
88
+ if (message !== void 0) messages.set(id, message);
89
+ }
90
+ },
91
+ addPage({ before, messages: page, moreBefore, summarized }) {
92
+ let changed = false;
93
+ const setParent = (id, parent) => {
94
+ if (parents.get(id) === parent) return;
95
+ parents.set(id, parent);
96
+ changed = true;
97
+ };
98
+ const ids = [];
99
+ for (const message of page) {
100
+ if (typeof message.id !== "string" || !message.id) continue;
101
+ ids.push(message.id);
102
+ if (messages.get(message.id) !== message) {
103
+ messages.set(message.id, message);
104
+ changed = true;
105
+ }
106
+ }
107
+ for (const [index, id] of ids.entries()) {
108
+ if (index > 0) setParent(id, ids[index - 1]);
109
+ else if (!moreBefore) setParent(id, null);
110
+ else if (parents.get(id) === null) {
111
+ parents.delete(id);
112
+ changed = true;
113
+ }
114
+ }
115
+ const last = ids.at(-1);
116
+ if (last !== void 0) setParent(before, last);
117
+ else if (!moreBefore) setParent(before, null);
118
+ for (const [turn, summary] of summarized ?? []) {
119
+ const held = summaries.get(turn);
120
+ if (held === void 0) {
121
+ summaries.set(turn, {
122
+ ...summary,
123
+ shownAfter: summary.resume,
124
+ loaded: [],
125
+ more: summary.steps.count > 0
126
+ });
127
+ turnStarts.set(turn, turn);
128
+ turnStarts.set(summary.resume, turn);
129
+ changed = true;
130
+ continue;
131
+ }
132
+ const oldest = held.loaded[0];
133
+ const newest = held.loaded.at(-1);
134
+ if (oldest !== void 0 && newest !== void 0) {
135
+ setParent(oldest.id, parents.get(held.shownAfter) ?? null);
136
+ setParent(held.shownAfter, newest.id);
137
+ }
138
+ }
139
+ if (unserved) {
140
+ unserved = false;
141
+ unservedBy = void 0;
142
+ changed = true;
143
+ }
144
+ if (changed) notify();
145
+ return changed;
146
+ },
147
+ addSteps({ turn, messages: steps, moreBefore }) {
148
+ const held = summaries.get(turn);
149
+ if (held === void 0) return false;
150
+ const loadedIds = new Set(held.loaded.map((message) => message.id));
151
+ const fresh = steps.filter(
152
+ (message) => typeof message.id === "string" && message.id && !loadedIds.has(message.id)
153
+ );
154
+ const more = moreBefore && fresh.length > 0;
155
+ if (fresh.length === 0) {
156
+ if (held.more === more) return false;
157
+ held.more = more;
158
+ notify();
159
+ return true;
160
+ }
161
+ const above = parents.get(held.resume);
162
+ const freshIds = fresh.map((message) => message.id);
163
+ for (const [index, id] of freshIds.entries()) {
164
+ messages.set(id, fresh[index]);
165
+ if (index > 0) parents.set(id, freshIds[index - 1]);
166
+ else if (above !== void 0) parents.set(id, above);
167
+ }
168
+ parents.set(held.resume, freshIds.at(-1));
169
+ turnStarts.delete(held.resume);
170
+ held.resume = freshIds[0];
171
+ turnStarts.set(held.resume, turn);
172
+ held.loaded = [...fresh, ...held.loaded];
173
+ held.more = more;
174
+ notify();
175
+ return true;
176
+ },
177
+ olderThan(id) {
178
+ const ids = [];
179
+ const older = [];
180
+ const seen = /* @__PURE__ */ new Set([id]);
181
+ let parent = parents.get(id);
182
+ while (typeof parent === "string" && !seen.has(parent)) {
183
+ const message = messages.get(parent);
184
+ if (message === void 0) break;
185
+ seen.add(parent);
186
+ ids.push(parent);
187
+ older.push(message);
188
+ parent = parents.get(parent);
189
+ }
190
+ ids.reverse();
191
+ older.reverse();
192
+ return { ids, messages: older, hasOlder: parent !== null };
193
+ },
194
+ parentOf(id) {
195
+ return parents.get(id);
196
+ },
197
+ turnSteps(turnId) {
198
+ var _a;
199
+ return (_a = summaries.get(turnId)) == null ? void 0 : _a.steps;
200
+ },
201
+ markTurns(threadId, transcript) {
202
+ if (summaries.size === 0) return transcript;
203
+ let marked = null;
204
+ let pending = null;
205
+ const started = /* @__PURE__ */ new Set();
206
+ for (const [index, message] of transcript.entries()) {
207
+ const id = typeof message.id === "string" ? message.id : void 0;
208
+ const turn = id === void 0 ? void 0 : turnStarts.get(id);
209
+ if (turn !== void 0 && !started.has(turn)) {
210
+ started.add(turn);
211
+ const state = summaries.get(turn);
212
+ pending = marker(threadId, turn, state);
213
+ } else if (message.type === "human") {
214
+ pending = null;
215
+ }
216
+ if (pending === null || message.type !== "ai") continue;
217
+ marked ?? (marked = [...transcript]);
218
+ marked[index] = withMarker(message, pending);
219
+ pending = null;
220
+ }
221
+ return marked ?? transcript;
222
+ },
223
+ isLoadingSteps(turn) {
224
+ return loadingSteps.has(turn);
225
+ },
226
+ async loadSteps({ send, turn, steps = DEEP_AGENT_TURN_STEPS_PAGE }) {
227
+ const held = summaries.get(turn);
228
+ if (held === void 0 || !held.more || loadingSteps.has(turn)) return;
229
+ loadingSteps.add(turn);
230
+ try {
231
+ const answer = readTurnStepsResult(await send(buildTurnStepsCommand({ turn, before: held.resume, steps })));
232
+ if (answer === null || answer.turn !== turn) {
233
+ throw new Error("history/page answered steps in a shape this client cannot read");
234
+ }
235
+ store.addSteps(answer);
236
+ } finally {
237
+ loadingSteps.delete(turn);
238
+ }
239
+ },
240
+ subscribe(listener) {
241
+ listeners.add(listener);
242
+ return () => {
243
+ listeners.delete(listener);
244
+ };
245
+ }
246
+ };
247
+ return store;
248
+ }
249
+ const HISTORY_STORES = Symbol.for("@athenaintel/agent-runtime/history-stores");
250
+ function registry() {
251
+ const host = globalThis;
252
+ return host[HISTORY_STORES] ?? (host[HISTORY_STORES] = { stores: /* @__PURE__ */ new Map(), listeners: /* @__PURE__ */ new Set(), version: 0 });
253
+ }
254
+ const notifyRegistry = () => {
255
+ const shared = registry();
256
+ shared.version += 1;
257
+ for (const listener of [...shared.listeners]) listener();
258
+ };
259
+ function deepAgentHistoryStore(threadId) {
260
+ const { stores } = registry();
261
+ let store = stores.get(threadId);
262
+ if (store !== void 0) {
263
+ stores.delete(threadId);
264
+ stores.set(threadId, store);
265
+ return store;
266
+ }
267
+ store = createDeepAgentHistoryStore();
268
+ store.subscribe(notifyRegistry);
269
+ stores.set(threadId, store);
270
+ while (stores.size > DEEP_AGENT_HISTORY_STORE_LIMIT) {
271
+ const oldest = stores.keys().next().value;
272
+ stores.delete(oldest);
273
+ }
274
+ return store;
275
+ }
276
+ function peekDeepAgentHistoryStore(threadId) {
277
+ return registry().stores.get(threadId);
278
+ }
279
+ function subscribeDeepAgentHistory(listener) {
280
+ const { listeners } = registry();
281
+ listeners.add(listener);
282
+ return () => {
283
+ listeners.delete(listener);
284
+ };
285
+ }
286
+ function deepAgentHistoryVersion() {
287
+ return registry().version;
288
+ }
289
+ function clearDeepAgentHistoryStores() {
290
+ const { stores } = registry();
291
+ if (stores.size === 0) return;
292
+ stores.clear();
293
+ notifyRegistry();
294
+ }
295
+ function loadDeepAgentTurnSteps({
296
+ send,
297
+ marker,
298
+ steps
299
+ }) {
300
+ if (marker.hiddenSteps === 0) return Promise.resolve();
301
+ const store = peekDeepAgentHistoryStore(marker.thread);
302
+ if (store === void 0) return Promise.resolve();
303
+ return store.loadSteps({ send, turn: marker.turn, ...steps !== void 0 && { steps } });
304
+ }
305
+ function hostServesHistoryPage(version) {
306
+ return typeof version === "number" && version >= runconfigContract.DEEP_AGENT_HISTORY_PAGE_PROTOCOL_VERSION;
307
+ }
308
+ function isHistoryPageUnserved(error) {
309
+ const failure = error == null ? void 0 : error.failure;
310
+ return (failure == null ? void 0 : failure.fate) === "rejected" && failure.code === "unknown-command";
311
+ }
312
+ function withDeclaredPagedHistory(headers) {
313
+ if (runconfigContract.DEEP_AGENT_MESSAGE_HISTORY_HEADER in headers) return headers;
314
+ return { ...headers, [runconfigContract.DEEP_AGENT_MESSAGE_HISTORY_HEADER]: runconfigContract.DEEP_AGENT_MESSAGE_HISTORY_PAGED };
315
+ }
316
+ const DEEP_AGENT_HISTORY_PAGE_TURNS = 10;
317
+ function buildHistoryPageCommand({
318
+ before,
319
+ turns = DEEP_AGENT_HISTORY_PAGE_TURNS
320
+ }) {
321
+ return {
322
+ type: runconfigContract.DEEP_AGENT_HISTORY_PAGE_COMMAND,
323
+ before,
324
+ turns: Math.max(1, Math.min(runconfigContract.DEEP_AGENT_MAX_HISTORY_PAGE_TURNS, Math.trunc(turns)))
325
+ };
326
+ }
327
+ function buildTurnStepsCommand({
328
+ turn,
329
+ before,
330
+ steps = DEEP_AGENT_TURN_STEPS_PAGE
331
+ }) {
332
+ return {
333
+ type: runconfigContract.DEEP_AGENT_HISTORY_PAGE_COMMAND,
334
+ turn,
335
+ ...before !== void 0 && { before },
336
+ steps: Math.max(1, Math.min(runconfigContract.DEEP_AGENT_MAX_HISTORY_PAGE_STEPS, Math.trunc(steps)))
337
+ };
338
+ }
339
+ const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
340
+ const isCount = (value) => typeof value === "number" && Number.isInteger(value) && value >= 0;
341
+ const isId = (value) => typeof value === "string" && value.length > 0;
342
+ const readTurnSteps = (value) => {
343
+ if (value === null) return null;
344
+ if (!isRecord(value)) return void 0;
345
+ const { count, tools, delegations, first, last } = value;
346
+ if (!isCount(count) || !isCount(tools) || !isCount(delegations)) return void 0;
347
+ const id = (entry) => isId(entry) ? entry : null;
348
+ return { count, tools, delegations, first: id(first), last: id(last) };
349
+ };
350
+ function readMessages(value) {
351
+ if (!Array.isArray(value)) return null;
352
+ for (const message of value) {
353
+ if (!isRecord(message) || !isId(message.id)) return null;
354
+ }
355
+ return value;
356
+ }
357
+ function readHistoryPageResult(payload, before) {
358
+ var _a, _b, _c, _d;
359
+ if (!isRecord(payload) || !Array.isArray(payload.turns) || !isRecord(payload.more)) return null;
360
+ if (typeof payload.more.before !== "boolean") return null;
361
+ const page = [];
362
+ const turns = [];
363
+ for (const turn of payload.turns) {
364
+ if (!isRecord(turn) || !isId(turn.id)) return null;
365
+ const turnMessages = readMessages(turn.messages);
366
+ if (turnMessages === null) return null;
367
+ const steps = readTurnSteps(turn.steps);
368
+ if (steps === void 0 && turn.steps !== void 0) return null;
369
+ turns.push({ id: turn.id, messages: turnMessages, steps: steps ?? null });
370
+ page.push(...turnMessages);
371
+ }
372
+ const summarized = /* @__PURE__ */ new Map();
373
+ for (const [index, turn] of turns.entries()) {
374
+ if (turn.steps === null) continue;
375
+ const shown = ((_a = turn.messages[0]) == null ? void 0 : _a.id) === turn.id ? turn.messages.slice(1) : turn.messages;
376
+ const resume = ((_b = shown[0]) == null ? void 0 : _b.id) ?? ((_d = (_c = turns[index + 1]) == null ? void 0 : _c.messages[0]) == null ? void 0 : _d.id) ?? before;
377
+ summarized.set(turn.id, { steps: turn.steps, resume });
378
+ }
379
+ return { before, messages: page, moreBefore: payload.more.before, summarized };
380
+ }
381
+ function readTurnStepsResult(payload) {
382
+ if (!isRecord(payload) || !isId(payload.turn) || !isRecord(payload.more)) return null;
383
+ if (typeof payload.more.before !== "boolean") return null;
384
+ const steps = readMessages(payload.messages);
385
+ if (steps === null) return null;
386
+ return { turn: payload.turn, messages: steps, moreBefore: payload.more.before };
387
+ }
388
+ function readTurnStepsMarker(message) {
389
+ if (!isRecord(message) || !isRecord(message.additional_kwargs)) return void 0;
390
+ const marker = message.additional_kwargs[DEEP_AGENT_TURN_STEPS_KEY];
391
+ if (!isRecord(marker) || !isId(marker.turn) || !isId(marker.thread)) return void 0;
392
+ const { hiddenSteps, hiddenTools, hiddenDelegations, before } = marker;
393
+ if (!isCount(hiddenSteps) || !isCount(hiddenTools) || !isCount(hiddenDelegations)) return void 0;
394
+ return {
395
+ turn: marker.turn,
396
+ thread: marker.thread,
397
+ hiddenSteps,
398
+ hiddenTools,
399
+ hiddenDelegations,
400
+ before: isId(before) ? before : void 0
401
+ };
402
+ }
403
+ function historyPageAsInterestRequest(command) {
404
+ return { ns: runconfigContract.DEEP_AGENT_MAIN_NS, before: command.turns, at: command.before };
405
+ }
406
+ exports.DEEP_AGENT_HISTORY_PAGE_TURNS = DEEP_AGENT_HISTORY_PAGE_TURNS;
407
+ exports.DEEP_AGENT_HISTORY_STORE_LIMIT = DEEP_AGENT_HISTORY_STORE_LIMIT;
408
+ exports.DEEP_AGENT_TURN_STEPS_KEY = DEEP_AGENT_TURN_STEPS_KEY;
409
+ exports.DEEP_AGENT_TURN_STEPS_PAGE = DEEP_AGENT_TURN_STEPS_PAGE;
410
+ exports.buildHistoryPageCommand = buildHistoryPageCommand;
411
+ exports.buildTurnStepsCommand = buildTurnStepsCommand;
412
+ exports.clearDeepAgentHistoryStores = clearDeepAgentHistoryStores;
413
+ exports.createDeepAgentHistoryStore = createDeepAgentHistoryStore;
414
+ exports.deepAgentHistoryStore = deepAgentHistoryStore;
415
+ exports.deepAgentHistoryVersion = deepAgentHistoryVersion;
416
+ exports.historyPageAsInterestRequest = historyPageAsInterestRequest;
417
+ exports.hostServesHistoryPage = hostServesHistoryPage;
418
+ exports.isHistoryPageUnserved = isHistoryPageUnserved;
419
+ exports.loadDeepAgentTurnSteps = loadDeepAgentTurnSteps;
420
+ exports.peekDeepAgentHistoryStore = peekDeepAgentHistoryStore;
421
+ exports.readHistoryPageResult = readHistoryPageResult;
422
+ exports.readTurnStepsMarker = readTurnStepsMarker;
423
+ exports.readTurnStepsResult = readTurnStepsResult;
424
+ exports.subscribeDeepAgentHistory = subscribeDeepAgentHistory;
425
+ exports.withDeclaredPagedHistory = withDeclaredPagedHistory;
426
+ //# sourceMappingURL=history-store.cjs.map