@markusylisiurunen/tau 0.3.99 → 0.3.101
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/core/code_mode/agents.js +62 -14
- package/dist/core/code_mode/agents.js.map +1 -1
- package/dist/core/code_mode/history.js +7 -0
- package/dist/core/code_mode/history.js.map +1 -1
- package/dist/core/code_mode/models.js.map +1 -1
- package/dist/core/code_mode/web.js.map +1 -1
- package/dist/core/config/content_loader.js.map +1 -1
- package/dist/core/config/index.js +2 -1
- package/dist/core/config/index.js.map +1 -1
- package/dist/core/config/ownership.js +71 -0
- package/dist/core/config/ownership.js.map +1 -0
- package/dist/core/config/runtime.js +22 -10
- package/dist/core/config/runtime.js.map +1 -1
- package/dist/core/config/runtime_config_snapshot.js +2 -2
- package/dist/core/config/runtime_config_snapshot.js.map +1 -1
- package/dist/core/config/schema.js +3 -2
- package/dist/core/config/schema.js.map +1 -1
- package/dist/core/history/agent_history_recorder.js +64 -0
- package/dist/core/history/agent_history_recorder.js.map +1 -0
- package/dist/core/history/cli.js +2 -2
- package/dist/core/history/cli.js.map +1 -1
- package/dist/core/history/config.js.map +1 -1
- package/dist/core/history/history_manager.js +14 -29
- package/dist/core/history/history_manager.js.map +1 -1
- package/dist/core/history/local_history_store.js +43 -10
- package/dist/core/history/local_history_store.js.map +1 -1
- package/dist/core/history/migrations.js +1 -1
- package/dist/core/history/migrations.js.map +1 -1
- package/dist/core/history/remote_history_client.js +2 -0
- package/dist/core/history/remote_history_client.js.map +1 -1
- package/dist/core/history/setup.js +10 -8
- package/dist/core/history/setup.js.map +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/runtime/agent_model.js.map +1 -1
- package/dist/core/runtime/chat_runtime.js +6 -5
- package/dist/core/runtime/chat_runtime.js.map +1 -1
- package/dist/core/runtime/session_prompt_composer.js +2 -6
- package/dist/core/runtime/session_prompt_composer.js.map +1 -1
- package/dist/core/static/code_mode/history/documentation.md +22 -4
- package/dist/core/static/index.js +22 -11
- package/dist/core/static/index.js.map +1 -1
- package/dist/core/static/prompts/subagent-prefix.md +13 -5
- package/dist/core/static/tau_docs/code-mode.md +2 -2
- package/dist/core/static/tau_docs/config-reference.md +23 -9
- package/dist/core/static/tau_docs/configuration.md +13 -2
- package/dist/core/static/tau_docs/credentials.md +1 -1
- package/dist/core/static/tau_docs/history.md +44 -4
- package/dist/core/static/tau_docs/image-generation.md +27 -20
- package/dist/core/static/tau_docs/models.md +1 -1
- package/dist/core/static/tau_docs/node-sdk.md +10 -10
- package/dist/core/static/tau_docs/ownership-and-scope.md +7 -5
- package/dist/core/static/tau_docs/personas.md +2 -2
- package/dist/core/static/tau_docs/prompts-and-project-context.md +2 -2
- package/dist/core/static/tau_docs/remote-sessions.md +3 -2
- package/dist/core/static/tau_docs/security.md +11 -3
- package/dist/core/static/tau_docs/session-protocol-methods.md +50 -2
- package/dist/core/static/tau_docs/session-protocol.md +41 -12
- package/dist/core/static/tau_docs/sessions.md +5 -3
- package/dist/core/static/tau_docs/subagents.md +69 -52
- package/dist/core/static/tau_docs/telegram-projects.md +62 -4
- package/dist/core/static/tau_docs/telegram.md +9 -6
- package/dist/core/static/tau_docs/tools.md +1 -1
- package/dist/core/static/tau_docs/troubleshooting.md +8 -6
- package/dist/core/static/tau_docs/tui.md +28 -11
- package/dist/core/subagents/agent_supervisor.js +196 -15
- package/dist/core/subagents/agent_supervisor.js.map +1 -1
- package/dist/core/subagents/claude_code_runner.mjs +52 -51
- package/dist/core/subagents/native_subagent_runtime.js +43 -14
- package/dist/core/subagents/native_subagent_runtime.js.map +1 -1
- package/dist/core/subagents/prompt.js.map +1 -1
- package/dist/core/subagents/registry.js +1 -0
- package/dist/core/subagents/registry.js.map +1 -1
- package/dist/core/subagents/runtime.js.map +1 -1
- package/dist/core/subagents/types.js +2 -1
- package/dist/core/subagents/types.js.map +1 -1
- package/dist/core/telegram/adapter.js +17 -20
- package/dist/core/telegram/adapter.js.map +1 -1
- package/dist/core/telegram/cli.js +24 -12
- package/dist/core/telegram/cli.js.map +1 -1
- package/dist/core/telegram/config.js +2 -0
- package/dist/core/telegram/config.js.map +1 -1
- package/dist/core/telegram/local_session_client.js +2 -2
- package/dist/core/telegram/local_session_client.js.map +1 -1
- package/dist/core/telegram/runtime.js +10 -1
- package/dist/core/telegram/runtime.js.map +1 -1
- package/dist/core/telegram/session_manager.js +12 -0
- package/dist/core/telegram/session_manager.js.map +1 -1
- package/dist/core/telegram/workspace.js +21 -0
- package/dist/core/telegram/workspace.js.map +1 -1
- package/dist/core/tool/cli.js +1 -1
- package/dist/core/tool/image_generate.js +6 -2
- package/dist/core/tool/image_generate.js.map +1 -1
- package/dist/core/tools/catalog.js +24 -14
- package/dist/core/tools/catalog.js.map +1 -1
- package/dist/core/tools/wait_for_agents.js.map +1 -1
- package/dist/core/utils/model_notices.js.map +1 -1
- package/dist/core/utils/speech_to_text_keywords.js +10 -4
- package/dist/core/utils/speech_to_text_keywords.js.map +1 -1
- package/dist/core/version.js +2 -2
- package/dist/core/version.js.map +1 -1
- package/dist/diff_tool/app/dist/assets/andromeeda-DW8vo71h.js +1 -0
- package/dist/diff_tool/app/dist/assets/aurora-x-rMvKqtYI.js +1 -0
- package/dist/diff_tool/app/dist/assets/ayu-dark-CwczpL8O.js +1 -0
- package/dist/diff_tool/app/dist/assets/ayu-light-DSh22xiD.js +1 -0
- package/dist/diff_tool/app/dist/assets/ayu-mirage-JE6hAyHG.js +1 -0
- package/dist/diff_tool/app/dist/assets/catppuccin-frappe-pyXErRRU.js +1 -0
- package/dist/diff_tool/app/dist/assets/catppuccin-latte-BILSUICr.js +1 -0
- package/dist/diff_tool/app/dist/assets/catppuccin-macchiato-Ck60ZZQE.js +1 -0
- package/dist/diff_tool/app/dist/assets/catppuccin-mocha-C_2G67cS.js +1 -0
- package/dist/diff_tool/app/dist/assets/{core-D8lOlLN2.js → core-CXVpaOO1.js} +1 -1
- package/dist/diff_tool/app/dist/assets/dark-plus-CHgc6GYj.js +1 -0
- package/dist/diff_tool/app/dist/assets/dracula-Cf1PG3MT.js +1 -0
- package/dist/diff_tool/app/dist/assets/dracula-soft-DXuNm1Kq.js +1 -0
- package/dist/diff_tool/app/dist/assets/engine-oniguruma-Rz_7DPcV.js +1 -0
- package/dist/diff_tool/app/dist/assets/everforest-dark-CjdfwUBe.js +1 -0
- package/dist/diff_tool/app/dist/assets/everforest-light-CfVwwCBP.js +1 -0
- package/dist/diff_tool/app/dist/assets/github-dark-BL6HSl_n.js +1 -0
- package/dist/diff_tool/app/dist/assets/github-dark-default-zacuWV-M.js +1 -0
- package/dist/diff_tool/app/dist/assets/github-dark-dimmed-Mc0P9idi.js +1 -0
- package/dist/diff_tool/app/dist/assets/github-dark-high-contrast-IMKX2AVF.js +1 -0
- package/dist/diff_tool/app/dist/assets/github-light-default-DVlCqP3X.js +1 -0
- package/dist/diff_tool/app/dist/assets/github-light-high-contrast-Dj6zTyWR.js +1 -0
- package/dist/diff_tool/app/dist/assets/github-light-mYhEBkPo.js +1 -0
- package/dist/diff_tool/app/dist/assets/gruvbox-dark-hard-QTgQQZn-.js +1 -0
- package/dist/diff_tool/app/dist/assets/gruvbox-dark-medium-9d5YdCTx.js +1 -0
- package/dist/diff_tool/app/dist/assets/gruvbox-dark-soft-XCkqeBhR.js +1 -0
- package/dist/diff_tool/app/dist/assets/gruvbox-light-hard--5-nXqNp.js +1 -0
- package/dist/diff_tool/app/dist/assets/gruvbox-light-medium-COA1PZW2.js +1 -0
- package/dist/diff_tool/app/dist/assets/gruvbox-light-soft-CIJpzjAO.js +1 -0
- package/dist/diff_tool/app/dist/assets/highlights-DuJNYjEh.js +7 -0
- package/dist/diff_tool/app/dist/assets/horizon-Ba2cwkSy.js +1 -0
- package/dist/diff_tool/app/dist/assets/horizon-bright-DaEDgBmR.js +1 -0
- package/dist/diff_tool/app/dist/assets/houston-B6x0XVpU.js +1 -0
- package/dist/diff_tool/app/dist/assets/index-F9is7PUw.js +221 -0
- package/dist/diff_tool/app/dist/assets/kanagawa-dragon-DhTFvBMT.js +1 -0
- package/dist/diff_tool/app/dist/assets/kanagawa-lotus--m8sdOxn.js +1 -0
- package/dist/diff_tool/app/dist/assets/kanagawa-wave-D-tTv4k2.js +1 -0
- package/dist/diff_tool/app/dist/assets/langs-CTftvgbb.js +1 -0
- package/dist/diff_tool/app/dist/assets/laserwave-HSLx0L75.js +1 -0
- package/dist/diff_tool/app/dist/assets/lib-BKZ5ZaMU.js +1 -0
- package/dist/diff_tool/app/dist/assets/light-plus-CUjWrTSi.js +1 -0
- package/dist/diff_tool/app/dist/assets/loader-bi21_x0K.js +1 -0
- package/dist/diff_tool/app/dist/assets/material-theme-CnthUGfg.js +1 -0
- package/dist/diff_tool/app/dist/assets/material-theme-darker-DUi03Qre.js +1 -0
- package/dist/diff_tool/app/dist/assets/material-theme-lighter-D2-qr5Vw.js +1 -0
- package/dist/diff_tool/app/dist/assets/material-theme-ocean-CWR-LogA.js +1 -0
- package/dist/diff_tool/app/dist/assets/material-theme-palenight-Cnv8m1ra.js +1 -0
- package/dist/diff_tool/app/dist/assets/min-dark-EXoM-6Xo.js +1 -0
- package/dist/diff_tool/app/dist/assets/min-light-DVOTDhnA.js +1 -0
- package/dist/diff_tool/app/dist/assets/monokai-DkggTbGy.js +1 -0
- package/dist/diff_tool/app/dist/assets/night-owl-Bdcs0PMi.js +1 -0
- package/dist/diff_tool/app/dist/assets/night-owl-light-RoU30LE0.js +1 -0
- package/dist/diff_tool/app/dist/assets/nord-u7hMircQ.js +1 -0
- package/dist/diff_tool/app/dist/assets/one-dark-pro-08PdtLzi.js +1 -0
- package/dist/diff_tool/app/dist/assets/one-light-DgvUEtgI.js +1 -0
- package/dist/diff_tool/app/dist/assets/pierre-dark-B2jZWvHG.js +1 -0
- package/dist/diff_tool/app/dist/assets/pierre-dark-protanopia-deuteranopia-CebgQdRf.js +1 -0
- package/dist/diff_tool/app/dist/assets/pierre-dark-soft-DdE7dyP3.js +1 -0
- package/dist/diff_tool/app/dist/assets/pierre-dark-tritanopia-CXimiT7X.js +1 -0
- package/dist/diff_tool/app/dist/assets/pierre-dark-vibrant-DzBsxHvQ.js +1 -0
- package/dist/diff_tool/app/dist/assets/pierre-light-Vf__O3ev.js +1 -0
- package/dist/diff_tool/app/dist/assets/pierre-light-protanopia-deuteranopia-BUtWcCQC.js +1 -0
- package/dist/diff_tool/app/dist/assets/pierre-light-soft-C3QCXKvN.js +1 -0
- package/dist/diff_tool/app/dist/assets/pierre-light-tritanopia-CKLy6XvA.js +1 -0
- package/dist/diff_tool/app/dist/assets/pierre-light-vibrant-DDuTEIhH.js +1 -0
- package/dist/diff_tool/app/dist/assets/plastic-B8mE6BxX.js +1 -0
- package/dist/diff_tool/app/dist/assets/poimandres-DUFjrgxT.js +1 -0
- package/dist/diff_tool/app/dist/assets/red-BJvdDEUx.js +1 -0
- package/dist/diff_tool/app/dist/assets/rose-pine-BSqRqUae.js +1 -0
- package/dist/diff_tool/app/dist/assets/rose-pine-dawn-U6TBE82u.js +1 -0
- package/dist/diff_tool/app/dist/assets/rose-pine-moon-CAU7u1h4.js +1 -0
- package/dist/diff_tool/app/dist/assets/shiki-D6ZyrNQD.js +2 -0
- package/dist/diff_tool/app/dist/assets/slack-dark-CMu0smFa.js +1 -0
- package/dist/diff_tool/app/dist/assets/slack-ochin-BBne7cjw.js +1 -0
- package/dist/diff_tool/app/dist/assets/snazzy-light-CV8HUEmk.js +1 -0
- package/dist/diff_tool/app/dist/assets/solarized-dark-CmYmhSgI.js +1 -0
- package/dist/diff_tool/app/dist/assets/solarized-light-CjLLwxRp.js +1 -0
- package/dist/diff_tool/app/dist/assets/{stream-tokenizer-BkuDYA48.js → stream-tokenizer-BdsyU_yB.js} +4 -4
- package/dist/diff_tool/app/dist/assets/synthwave-84-wQeDKbzQ.js +1 -0
- package/dist/diff_tool/app/dist/assets/{themes-BaMgiyFz.js → themes-9lpTYI_i.js} +2 -2
- package/dist/diff_tool/app/dist/assets/tokyo-night-D4ZgDiA7.js +1 -0
- package/dist/diff_tool/app/dist/assets/vesper-sUHevyKv.js +1 -0
- package/dist/diff_tool/app/dist/assets/vitesse-black-CfklMpOb.js +1 -0
- package/dist/diff_tool/app/dist/assets/vitesse-dark-CJkzwmKT.js +1 -0
- package/dist/diff_tool/app/dist/assets/vitesse-light-BxMp8E1Y.js +1 -0
- package/dist/diff_tool/app/dist/assets/wasm-4KdTHw0F.js +1 -0
- package/dist/diff_tool/app/dist/index.html +2 -2
- package/dist/history/worker/index.js +140 -15
- package/dist/history/worker/index.js.map +1 -1
- package/dist/history/worker/migrations/0002_parent_session.sql +3 -0
- package/dist/history/worker/viewer.css +10 -1
- package/dist/host/local_session_host.js +304 -172
- package/dist/host/local_session_host.js.map +1 -1
- package/dist/host/session_bootstrap.js +53 -0
- package/dist/host/session_bootstrap.js.map +1 -0
- package/dist/host/session_host.js +2 -0
- package/dist/host/session_host.js.map +1 -1
- package/dist/host/session_protocol_handler.js +11 -1
- package/dist/host/session_protocol_handler.js.map +1 -1
- package/dist/main.js +48 -95
- package/dist/main.js.map +1 -1
- package/dist/protocol/environment_variables.d.ts +2 -0
- package/dist/protocol/environment_variables.js +7 -0
- package/dist/protocol/environment_variables.js.map +1 -0
- package/dist/protocol/session_protocol.d.ts +27 -3
- package/dist/protocol/session_protocol.js +41 -7
- package/dist/protocol/session_protocol.js.map +1 -1
- package/dist/sdk/client.js +2 -2
- package/dist/sdk/client.js.map +1 -1
- package/dist/sdk/local_client.d.ts +2 -2
- package/dist/sdk/local_client.js +11 -66
- package/dist/sdk/local_client.js.map +1 -1
- package/dist/sdk/session.js +12 -0
- package/dist/sdk/session.js.map +1 -1
- package/dist/sdk/types.d.ts +10 -0
- package/dist/store/session_snapshot_migrations.js +40 -1
- package/dist/store/session_snapshot_migrations.js.map +1 -1
- package/dist/tui/chat_view.js +5 -0
- package/dist/tui/chat_view.js.map +1 -1
- package/dist/tui/host_diagnostic_relay.js +44 -0
- package/dist/tui/host_diagnostic_relay.js.map +1 -0
- package/dist/tui/index.js +1 -0
- package/dist/tui/index.js.map +1 -1
- package/dist/tui/listen_capture.js +7 -9
- package/dist/tui/listen_capture.js.map +1 -1
- package/dist/tui/session_chat_app.js +2 -2
- package/dist/tui/session_chat_app.js.map +1 -1
- package/dist/tui/session_chat_controller.js +89 -13
- package/dist/tui/session_chat_controller.js.map +1 -1
- package/dist/tui/terminal.js +13 -2
- package/dist/tui/terminal.js.map +1 -1
- package/dist/tui/ui/subagent_panel.js +45 -14
- package/dist/tui/ui/subagent_panel.js.map +1 -1
- package/package.json +11 -11
- package/dist/diff_tool/app/dist/assets/andromeeda-BJLMrMlp.js +0 -1
- package/dist/diff_tool/app/dist/assets/aurora-x-BCChoRpm.js +0 -1
- package/dist/diff_tool/app/dist/assets/ayu-dark-DzFZPuMV.js +0 -1
- package/dist/diff_tool/app/dist/assets/ayu-light-DSkcX_XD.js +0 -1
- package/dist/diff_tool/app/dist/assets/ayu-mirage-DSve0zuE.js +0 -1
- package/dist/diff_tool/app/dist/assets/catppuccin-frappe-DbLkF0J2.js +0 -1
- package/dist/diff_tool/app/dist/assets/catppuccin-latte-b6208YQK.js +0 -1
- package/dist/diff_tool/app/dist/assets/catppuccin-macchiato-CNNBbV1L.js +0 -1
- package/dist/diff_tool/app/dist/assets/catppuccin-mocha-DHkNF0Mp.js +0 -1
- package/dist/diff_tool/app/dist/assets/dark-plus-BVZ_4wTZ.js +0 -1
- package/dist/diff_tool/app/dist/assets/dracula-BoZgXveB.js +0 -1
- package/dist/diff_tool/app/dist/assets/dracula-soft-D-Kgh5gw.js +0 -1
- package/dist/diff_tool/app/dist/assets/everforest-dark-Y6tr-2zD.js +0 -1
- package/dist/diff_tool/app/dist/assets/everforest-light-CA0Ol4Qu.js +0 -1
- package/dist/diff_tool/app/dist/assets/github-dark-C895GGrm.js +0 -1
- package/dist/diff_tool/app/dist/assets/github-dark-default-CM8LCIj6.js +0 -1
- package/dist/diff_tool/app/dist/assets/github-dark-dimmed-jPx1V1fR.js +0 -1
- package/dist/diff_tool/app/dist/assets/github-dark-high-contrast-UN5YjL_Z.js +0 -1
- package/dist/diff_tool/app/dist/assets/github-light-B4HDwToD.js +0 -1
- package/dist/diff_tool/app/dist/assets/github-light-default-CfC59JYV.js +0 -1
- package/dist/diff_tool/app/dist/assets/github-light-high-contrast-C3edEHcK.js +0 -1
- package/dist/diff_tool/app/dist/assets/gruvbox-dark-hard-BdGOuxq8.js +0 -1
- package/dist/diff_tool/app/dist/assets/gruvbox-dark-medium-CmygtSMi.js +0 -1
- package/dist/diff_tool/app/dist/assets/gruvbox-dark-soft-BJH4XuY9.js +0 -1
- package/dist/diff_tool/app/dist/assets/gruvbox-light-hard-BkSILF4E.js +0 -1
- package/dist/diff_tool/app/dist/assets/gruvbox-light-medium-DiZUfgdz.js +0 -1
- package/dist/diff_tool/app/dist/assets/gruvbox-light-soft-CRCTnbIj.js +0 -1
- package/dist/diff_tool/app/dist/assets/highlights-B80gocb2.js +0 -3
- package/dist/diff_tool/app/dist/assets/horizon-DUI96lQn.js +0 -1
- package/dist/diff_tool/app/dist/assets/horizon-bright-COxh1lHf.js +0 -1
- package/dist/diff_tool/app/dist/assets/houston-DduE73P7.js +0 -1
- package/dist/diff_tool/app/dist/assets/index-DSKn9aHV.js +0 -205
- package/dist/diff_tool/app/dist/assets/kanagawa-dragon-BHDhSKDf.js +0 -1
- package/dist/diff_tool/app/dist/assets/kanagawa-lotus-NJjGXXql.js +0 -1
- package/dist/diff_tool/app/dist/assets/kanagawa-wave-DsGe2Uqk.js +0 -1
- package/dist/diff_tool/app/dist/assets/langs-Cb6u03GG.js +0 -1
- package/dist/diff_tool/app/dist/assets/laserwave-DYV0fvJ_.js +0 -1
- package/dist/diff_tool/app/dist/assets/lib-BFrBoEqQ.js +0 -9
- package/dist/diff_tool/app/dist/assets/light-plus-FTnIShls.js +0 -1
- package/dist/diff_tool/app/dist/assets/loader-DYYMIDWx.js +0 -1
- package/dist/diff_tool/app/dist/assets/material-theme-IcIb8QNx.js +0 -1
- package/dist/diff_tool/app/dist/assets/material-theme-darker-B_f2vxdL.js +0 -1
- package/dist/diff_tool/app/dist/assets/material-theme-lighter-CR2Q-4Hp.js +0 -1
- package/dist/diff_tool/app/dist/assets/material-theme-ocean-BX6hAJ_y.js +0 -1
- package/dist/diff_tool/app/dist/assets/material-theme-palenight-B6DWAotd.js +0 -1
- package/dist/diff_tool/app/dist/assets/min-dark-DECtZcqS.js +0 -1
- package/dist/diff_tool/app/dist/assets/min-light-qRIVcaqf.js +0 -1
- package/dist/diff_tool/app/dist/assets/monokai-CLmrJ-8t.js +0 -1
- package/dist/diff_tool/app/dist/assets/night-owl-eR4AsyAP.js +0 -1
- package/dist/diff_tool/app/dist/assets/night-owl-light-C74n5ti-.js +0 -1
- package/dist/diff_tool/app/dist/assets/nord-D4wy7NEP.js +0 -1
- package/dist/diff_tool/app/dist/assets/one-dark-pro-28TLzoS8.js +0 -1
- package/dist/diff_tool/app/dist/assets/one-light-C0UY_Fh7.js +0 -1
- package/dist/diff_tool/app/dist/assets/pierre-dark-fPlffE7i.js +0 -1
- package/dist/diff_tool/app/dist/assets/pierre-dark-protanopia-deuteranopia-BmjibgrW.js +0 -1
- package/dist/diff_tool/app/dist/assets/pierre-dark-soft-Cng2SYKc.js +0 -1
- package/dist/diff_tool/app/dist/assets/pierre-dark-tritanopia-DneQ5i7L.js +0 -1
- package/dist/diff_tool/app/dist/assets/pierre-dark-vibrant-BUK9Y-N_.js +0 -1
- package/dist/diff_tool/app/dist/assets/pierre-light-BvcXQJIj.js +0 -1
- package/dist/diff_tool/app/dist/assets/pierre-light-protanopia-deuteranopia-Cd5nk0bp.js +0 -1
- package/dist/diff_tool/app/dist/assets/pierre-light-soft-BvU23vks.js +0 -1
- package/dist/diff_tool/app/dist/assets/pierre-light-tritanopia-BSHccQzI.js +0 -1
- package/dist/diff_tool/app/dist/assets/pierre-light-vibrant-BgMZEwQI.js +0 -1
- package/dist/diff_tool/app/dist/assets/plastic-B2V_PDVk.js +0 -1
- package/dist/diff_tool/app/dist/assets/poimandres-DB9-pI6r.js +0 -1
- package/dist/diff_tool/app/dist/assets/red-CqYzoXtd.js +0 -1
- package/dist/diff_tool/app/dist/assets/rose-pine-C3zjVKxG.js +0 -1
- package/dist/diff_tool/app/dist/assets/rose-pine-dawn-C72QYfqa.js +0 -1
- package/dist/diff_tool/app/dist/assets/rose-pine-moon-CSM8ewhO.js +0 -1
- package/dist/diff_tool/app/dist/assets/shiki-DaptjTao.js +0 -2
- package/dist/diff_tool/app/dist/assets/slack-dark-Dtzi51su.js +0 -1
- package/dist/diff_tool/app/dist/assets/slack-ochin-Bb7oPExa.js +0 -1
- package/dist/diff_tool/app/dist/assets/snazzy-light-DXgiwzKu.js +0 -1
- package/dist/diff_tool/app/dist/assets/solarized-dark-BKOT3ICq.js +0 -1
- package/dist/diff_tool/app/dist/assets/solarized-light--Lk5pOfE.js +0 -1
- package/dist/diff_tool/app/dist/assets/synthwave-84-BJJFg-sc.js +0 -1
- package/dist/diff_tool/app/dist/assets/tokyo-night-DvpptEDd.js +0 -1
- package/dist/diff_tool/app/dist/assets/vesper-C1rBZbON.js +0 -1
- package/dist/diff_tool/app/dist/assets/vitesse-black-Sqvrs2Sw.js +0 -1
- package/dist/diff_tool/app/dist/assets/vitesse-dark-BWf_ZQtP.js +0 -1
- package/dist/diff_tool/app/dist/assets/vitesse-light-Cqenv4Qv.js +0 -1
- package/dist/diff_tool/app/dist/assets/wasm-BnjxR4X6.js +0 -1
|
@@ -2,7 +2,7 @@ import { randomUUID } from "node:crypto";
|
|
|
2
2
|
import { resolve } from "node:path";
|
|
3
3
|
import { isDeepStrictEqual } from "node:util";
|
|
4
4
|
import { resolvePromptTemplateWithBackend } from "../core/config/index.js";
|
|
5
|
-
import {
|
|
5
|
+
import { AgentHistoryRecorder } from "../core/history/agent_history_recorder.js";
|
|
6
6
|
import { McpManager } from "../core/mcp/manager.js";
|
|
7
7
|
import { resolvePersonaSelection } from "../core/persona_selection.js";
|
|
8
8
|
import { ChatRuntime } from "../core/runtime/chat_runtime.js";
|
|
@@ -10,32 +10,32 @@ import { getEffectiveAutoCompactThresholdTokens, } from "../core/session/auto_co
|
|
|
10
10
|
import { buildToolRunPresentation, TOOL_UI_FACET_VERSION } from "../core/tools/presentation.js";
|
|
11
11
|
import { appendUsageLogEntry, getUsageCostTotal, getUsageTotals, } from "../core/usage/logs.js";
|
|
12
12
|
import { filterProjectPathAutocompleteEntries, loadProjectPathAutocompleteEntriesWithBackend, } from "../core/utils/project_files.js";
|
|
13
|
-
import { applySessionProtocolDelta, createSessionProtocolDeltaMessage, createSessionProtocolEphemeralMessage, createSessionProtocolSubagentActivitiesMessage, parseAutoCompactThresholdTokens, parseSessionAttributes, projectSessionProtocolNoticePresentation, projectSessionProtocolSubagentActivity, SESSION_PROTOCOL_MAX_SUBAGENT_ACTIVITIES, } from "../protocol/session_protocol.js";
|
|
13
|
+
import { applySessionProtocolDelta, createSessionProtocolDeltaMessage, createSessionProtocolEphemeralMessage, createSessionProtocolSubagentActivitiesMessage, parseAutoCompactThresholdTokens, parseSessionAttributes, projectSessionProtocolNoticePresentation, projectSessionProtocolSubagentActivity, SESSION_PROTOCOL_MAX_RETENTION_MS, SESSION_PROTOCOL_MAX_SUBAGENT_ACTIVITIES, } from "../protocol/session_protocol.js";
|
|
14
14
|
import { isIntermediateSystemMessage, } from "../protocol/system_message.js";
|
|
15
15
|
import { LEGACY_SESSION_MODEL_CONTEXT_KEY } from "../store/session_snapshot_migrations.js";
|
|
16
16
|
import { ClientToolBroker } from "./client_tool_broker.js";
|
|
17
17
|
import { createExecutionEnvironmentSubagentPromptResolver } from "./execution_runtime.js";
|
|
18
18
|
import { HostedEphemeralAgentSession } from "./hosted_ephemeral_agent_session.js";
|
|
19
|
-
import { SessionExecBusyError, SessionRetryUnavailableError, } from "./session_host.js";
|
|
19
|
+
import { SessionExecBusyError, SessionRetryUnavailableError, SessionRuntimeNotLoadedError, } from "./session_host.js";
|
|
20
20
|
const PATH_AUTOCOMPLETE_CACHE_TTL_MS = 5_000;
|
|
21
21
|
const HISTORY_UNAVAILABLE_NOTICE_ID = "notice-history-unavailable";
|
|
22
22
|
export class LocalSessionHost {
|
|
23
23
|
sessions = new Set();
|
|
24
24
|
sessionReferences = new Map();
|
|
25
|
-
sessionEvictions = new
|
|
25
|
+
sessionEvictions = new Map();
|
|
26
|
+
disposalFailures = new Map();
|
|
27
|
+
retention = new Map();
|
|
26
28
|
sessionRecoveryPromises = new Map();
|
|
27
29
|
store;
|
|
28
30
|
history;
|
|
29
31
|
historyRemote;
|
|
30
32
|
onShutdown;
|
|
31
33
|
clientToolBroker = new ClientToolBroker();
|
|
32
|
-
mcp;
|
|
33
34
|
sessionOptions;
|
|
34
35
|
shutdownPromise;
|
|
35
36
|
shuttingDown = false;
|
|
36
37
|
constructor(options) {
|
|
37
|
-
const { store, history, historyRemote,
|
|
38
|
-
this.mcp = new McpManager(mcpServers);
|
|
38
|
+
const { store, history, historyRemote, onShutdown, ...sessionOptions } = options;
|
|
39
39
|
this.store = store;
|
|
40
40
|
this.history = history;
|
|
41
41
|
this.historyRemote = historyRemote;
|
|
@@ -131,11 +131,20 @@ export class LocalSessionHost {
|
|
|
131
131
|
await hostedSession.dispose();
|
|
132
132
|
}
|
|
133
133
|
else {
|
|
134
|
-
await
|
|
134
|
+
await this.disposeRecoveredEnvironment(snapshot.sessionId, executionEnvironment);
|
|
135
135
|
}
|
|
136
136
|
throw error;
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
|
+
async disposeRecoveredEnvironment(sessionId, executionEnvironment) {
|
|
140
|
+
try {
|
|
141
|
+
await executionEnvironment.dispose();
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
this.disposalFailures.set(sessionId, error);
|
|
145
|
+
throw error;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
139
148
|
async createLocalSessionHandle(executionEnvironment, committedSnapshot, createParams, forceNextSnapshotRevision = false) {
|
|
140
149
|
const remoteCatalog = this.sessionOptions.getRemoteModelCatalog();
|
|
141
150
|
const bootstrap = await this.resolveSessionBootstrap(executionEnvironment, remoteCatalog, committedSnapshot !== undefined);
|
|
@@ -150,16 +159,27 @@ export class LocalSessionHost {
|
|
|
150
159
|
discoveredSkills: bootstrap.discoveredSkills,
|
|
151
160
|
includeAgentContext: this.sessionOptions.includeAgentContext,
|
|
152
161
|
});
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
162
|
+
const mcp = new McpManager(executionEnvironment.snapshot().kind === "local" ? bootstrap.config.mcpServers : {});
|
|
163
|
+
const mcpState = executionEnvironment.snapshot().kind === "local"
|
|
164
|
+
? {
|
|
165
|
+
status: "available",
|
|
166
|
+
servers: mcp
|
|
167
|
+
.listServers()
|
|
168
|
+
.map(({ name }) => name)
|
|
169
|
+
.sort(),
|
|
170
|
+
}
|
|
171
|
+
: { status: "unavailable", reason: "remote-execution" };
|
|
172
|
+
const catalog = createContentCatalogSnapshot(bootstrap, mcpState);
|
|
173
|
+
return this.createLocalSessionHandleFromRuntimeContext(executionEnvironment, runtimeContext, bootstrap, catalog, mcp, remoteCatalog, committedSnapshot, createParams, forceNextSnapshotRevision);
|
|
174
|
+
}
|
|
175
|
+
async createLocalSessionHandleFromRuntimeContext(executionEnvironment, runtimeContext, bootstrap, catalog, mcp, remoteCatalog, committedSnapshot, createParams, forceNextSnapshotRevision = false) {
|
|
160
176
|
let hostedSession;
|
|
161
177
|
const sessionId = committedSnapshot?.sessionId ?? randomUUID();
|
|
162
178
|
const createdAt = committedSnapshot?.createdAt ?? this.sessionOptions.environment.now();
|
|
179
|
+
const attributes = committedSnapshot?.attributes ?? createParams?.attributes;
|
|
180
|
+
if (!attributes) {
|
|
181
|
+
throw new Error("session attributes are required");
|
|
182
|
+
}
|
|
163
183
|
const runtime = ChatRuntime.create({
|
|
164
184
|
sessionId,
|
|
165
185
|
createdAt,
|
|
@@ -178,11 +198,24 @@ export class LocalSessionHost {
|
|
|
178
198
|
eventSink: async (event) => await hostedSession.enqueueRuntimeEvent(event),
|
|
179
199
|
subagentEventSink: async (event) => await hostedSession.recordSubagentEvent(event),
|
|
180
200
|
history: this.history.query(this.historyRemote),
|
|
181
|
-
|
|
201
|
+
openSubagentHistory: (child) => {
|
|
202
|
+
const recorder = new AgentHistoryRecorder(this.history.openSession({
|
|
203
|
+
sessionId: child.sessionId,
|
|
204
|
+
parentSessionId: child.parentSessionId,
|
|
205
|
+
attributes: { ...attributes, cwd: child.workingDirectory },
|
|
206
|
+
createdAt: child.createdAt,
|
|
207
|
+
}, this.historyRemote));
|
|
208
|
+
return async (event) => {
|
|
209
|
+
const failure = recorder.record(event);
|
|
210
|
+
if (failure)
|
|
211
|
+
await hostedSession.recordSubagentHistoryFailure(failure);
|
|
212
|
+
};
|
|
213
|
+
},
|
|
214
|
+
mcp,
|
|
182
215
|
initialPromptComposition: committedSnapshot
|
|
183
216
|
? promptCompositionFromSnapshot(committedSnapshot)
|
|
184
217
|
: undefined,
|
|
185
|
-
config: bootstrap.config
|
|
218
|
+
config: bootstrap.config,
|
|
186
219
|
recordUsage: this.sessionOptions.recordUsage,
|
|
187
220
|
deps: this.sessionOptions.deps,
|
|
188
221
|
});
|
|
@@ -191,21 +224,13 @@ export class LocalSessionHost {
|
|
|
191
224
|
: createParams?.autoCompactThresholdTokens !== undefined
|
|
192
225
|
? createParams.autoCompactThresholdTokens
|
|
193
226
|
: (bootstrap.initialAutoCompactThresholdTokens ?? null));
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
hostedSession = new LocalHostedSessionHandle(runtime, runtimeContext.promptBootstrap, catalog, bootstrap, remoteCatalog, this.sessionOptions.getRemoteModelCatalog, this.sessionOptions.includeAgentContext, executionEnvironment, this.store, this.history, this.historyRemote, attributes, createdAt, committedSnapshot, forceNextSnapshotRevision, this.sessionOptions.recordUsage ?? appendUsageLogEntry, (session) => {
|
|
227
|
+
const historyWriter = this.history.openSession({ sessionId, attributes, createdAt }, this.historyRemote);
|
|
228
|
+
hostedSession = new LocalHostedSessionHandle(runtime, runtimeContext.promptBootstrap, catalog, mcp, bootstrap, remoteCatalog, this.sessionOptions.getRemoteModelCatalog, this.sessionOptions.includeAgentContext, executionEnvironment, this.store, new AgentHistoryRecorder(historyWriter), attributes, createdAt, committedSnapshot, forceNextSnapshotRevision, this.sessionOptions.recordUsage ?? appendUsageLogEntry, (session, error) => {
|
|
229
|
+
if (error)
|
|
230
|
+
this.disposalFailures.set(session.sessionId, error);
|
|
199
231
|
this.sessions.delete(session);
|
|
200
232
|
this.sessionReferences.delete(session);
|
|
201
|
-
this.history.forgetSession(session.sessionId);
|
|
202
233
|
});
|
|
203
|
-
const historyFailure = this.history.registerSession({
|
|
204
|
-
sessionId: committedSnapshot?.sessionId ?? hostedSession.sessionId,
|
|
205
|
-
attributes,
|
|
206
|
-
createdAt,
|
|
207
|
-
}, this.historyRemote);
|
|
208
|
-
await hostedSession.recordHistoryFailure(historyFailure);
|
|
209
234
|
this.sessions.add(hostedSession);
|
|
210
235
|
return hostedSession;
|
|
211
236
|
}
|
|
@@ -256,11 +281,6 @@ export class LocalSessionHost {
|
|
|
256
281
|
if (liveSession) {
|
|
257
282
|
return this.retainSession(liveSession);
|
|
258
283
|
}
|
|
259
|
-
await this.refreshStore();
|
|
260
|
-
const refreshedLiveSession = this.findLiveSession(sessionId);
|
|
261
|
-
if (refreshedLiveSession) {
|
|
262
|
-
return this.retainSession(refreshedLiveSession);
|
|
263
|
-
}
|
|
264
284
|
const existingRecovery = this.sessionRecoveryPromises.get(sessionId);
|
|
265
285
|
if (existingRecovery) {
|
|
266
286
|
const recovered = await existingRecovery;
|
|
@@ -279,6 +299,7 @@ export class LocalSessionHost {
|
|
|
279
299
|
}
|
|
280
300
|
}
|
|
281
301
|
async recoverSession(sessionId) {
|
|
302
|
+
await this.refreshStore();
|
|
282
303
|
if (this.shuttingDown) {
|
|
283
304
|
return undefined;
|
|
284
305
|
}
|
|
@@ -292,12 +313,12 @@ export class LocalSessionHost {
|
|
|
292
313
|
}
|
|
293
314
|
const executionEnvironment = await this.sessionOptions.executionEnvironmentResolver.restore(snapshot.executionEnvironment);
|
|
294
315
|
if (this.shuttingDown) {
|
|
295
|
-
await
|
|
316
|
+
await this.disposeRecoveredEnvironment(sessionId, executionEnvironment);
|
|
296
317
|
return undefined;
|
|
297
318
|
}
|
|
298
319
|
const restoredLiveSession = this.findLiveSession(sessionId);
|
|
299
320
|
if (restoredLiveSession) {
|
|
300
|
-
await
|
|
321
|
+
await this.disposeRecoveredEnvironment(sessionId, executionEnvironment);
|
|
301
322
|
return restoredLiveSession;
|
|
302
323
|
}
|
|
303
324
|
return await this.createRecoveredSession(snapshot, executionEnvironment);
|
|
@@ -329,26 +350,99 @@ export class LocalSessionHost {
|
|
|
329
350
|
return;
|
|
330
351
|
}
|
|
331
352
|
this.sessionReferences.delete(hostedSession);
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
353
|
+
this.scheduleEviction(hostedSession);
|
|
354
|
+
}
|
|
355
|
+
setRetention(sessionId, durationMs) {
|
|
356
|
+
this.assertHostActive();
|
|
357
|
+
if (durationMs !== null &&
|
|
358
|
+
(!Number.isInteger(durationMs) ||
|
|
359
|
+
durationMs < 1 ||
|
|
360
|
+
durationMs > SESSION_PROTOCOL_MAX_RETENTION_MS)) {
|
|
361
|
+
throw new Error("invalid retention duration");
|
|
362
|
+
}
|
|
363
|
+
const session = this.findLiveSession(sessionId);
|
|
364
|
+
if (!session) {
|
|
365
|
+
if (durationMs === null)
|
|
366
|
+
return { retainedUntil: null };
|
|
367
|
+
throw new SessionRuntimeNotLoadedError("session runtime is not loaded");
|
|
368
|
+
}
|
|
369
|
+
const previous = this.retention.get(session);
|
|
370
|
+
if (previous)
|
|
371
|
+
clearTimeout(previous.timer);
|
|
372
|
+
this.retention.delete(session);
|
|
373
|
+
if (durationMs === null) {
|
|
374
|
+
this.scheduleEviction(session);
|
|
375
|
+
return { retainedUntil: null };
|
|
376
|
+
}
|
|
377
|
+
const until = Date.now() + durationMs;
|
|
378
|
+
const timer = setTimeout(() => {
|
|
379
|
+
this.retention.delete(session);
|
|
380
|
+
this.scheduleEviction(session);
|
|
381
|
+
}, durationMs);
|
|
382
|
+
timer.unref();
|
|
383
|
+
this.retention.set(session, { until, timer });
|
|
384
|
+
return { retainedUntil: until };
|
|
385
|
+
}
|
|
386
|
+
async collectSession(sessionId) {
|
|
387
|
+
this.assertHostActive();
|
|
388
|
+
if (this.sessionRecoveryPromises.has(sessionId))
|
|
389
|
+
return { disposed: false };
|
|
390
|
+
const session = this.findLiveSession(sessionId);
|
|
391
|
+
if (session) {
|
|
392
|
+
if (this.isHeld(session) || session.hasActiveWork)
|
|
393
|
+
return { disposed: false };
|
|
394
|
+
this.scheduleEviction(session);
|
|
395
|
+
}
|
|
396
|
+
while (true) {
|
|
397
|
+
const evictions = [...this.sessionEvictions]
|
|
398
|
+
.filter(([candidate]) => candidate.sessionId === sessionId)
|
|
399
|
+
.map(([, promise]) => promise);
|
|
400
|
+
if (evictions.length === 0)
|
|
401
|
+
break;
|
|
402
|
+
await Promise.all(evictions);
|
|
403
|
+
}
|
|
404
|
+
if (this.disposalFailures.has(sessionId))
|
|
405
|
+
throw this.disposalFailures.get(sessionId);
|
|
406
|
+
return {
|
|
407
|
+
disposed: !this.findLiveSession(sessionId) && !this.sessionRecoveryPromises.has(sessionId),
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
isHeld(session) {
|
|
411
|
+
return ((this.sessionReferences.get(session) ?? 0) > 0 ||
|
|
412
|
+
(this.retention.get(session)?.until ?? 0) > Date.now());
|
|
413
|
+
}
|
|
414
|
+
scheduleEviction(session) {
|
|
415
|
+
if (this.sessionEvictions.has(session) || this.isHeld(session) || this.shuttingDown)
|
|
416
|
+
return;
|
|
417
|
+
const eviction = this.evictReleasedSession(session);
|
|
418
|
+
this.sessionEvictions.set(session, eviction);
|
|
419
|
+
void eviction.then(() => {
|
|
420
|
+
this.sessionEvictions.delete(session);
|
|
421
|
+
if (this.sessions.has(session) && !session.isDisposed)
|
|
422
|
+
this.scheduleEviction(session);
|
|
423
|
+
}, () => this.sessionEvictions.delete(session));
|
|
335
424
|
}
|
|
336
425
|
async evictReleasedSession(session) {
|
|
337
|
-
|
|
338
|
-
await session.waitForActiveWork().catch(() => undefined);
|
|
426
|
+
while (true) {
|
|
339
427
|
await session.runtime.jobs.waitForIdle();
|
|
428
|
+
await session.runtime.supervisor.waitForIdle();
|
|
340
429
|
await session.waitForActiveWork().catch(() => undefined);
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
430
|
+
if (this.shuttingDown || session.isDisposed || this.isHeld(session))
|
|
431
|
+
return;
|
|
432
|
+
if (session.hasActiveWork)
|
|
433
|
+
continue;
|
|
434
|
+
await session.snapshot();
|
|
435
|
+
if (this.shuttingDown || session.isDisposed || this.isHeld(session))
|
|
436
|
+
return;
|
|
437
|
+
if (!session.hasActiveWork)
|
|
438
|
+
break;
|
|
344
439
|
}
|
|
345
|
-
await session.snapshot();
|
|
346
|
-
if (this.shuttingDown || (this.sessionReferences.get(session) ?? 0) > 0)
|
|
347
|
-
return;
|
|
348
|
-
if (session.runtime.jobs.hasRunning)
|
|
349
|
-
return await this.evictReleasedSession(session);
|
|
350
440
|
this.sessions.delete(session);
|
|
351
441
|
this.sessionReferences.delete(session);
|
|
442
|
+
const retention = this.retention.get(session);
|
|
443
|
+
if (retention)
|
|
444
|
+
clearTimeout(retention.timer);
|
|
445
|
+
this.retention.delete(session);
|
|
352
446
|
await session.dispose();
|
|
353
447
|
}
|
|
354
448
|
async listSessions() {
|
|
@@ -371,6 +465,9 @@ export class LocalSessionHost {
|
|
|
371
465
|
return await this.shutdownPromise;
|
|
372
466
|
}
|
|
373
467
|
async shutdownNow() {
|
|
468
|
+
for (const hold of this.retention.values())
|
|
469
|
+
clearTimeout(hold.timer);
|
|
470
|
+
this.retention.clear();
|
|
374
471
|
const errors = [];
|
|
375
472
|
const resourceShutdown = this.onShutdown
|
|
376
473
|
? Promise.resolve()
|
|
@@ -410,19 +507,14 @@ export class LocalSessionHost {
|
|
|
410
507
|
}
|
|
411
508
|
this.sessions.clear();
|
|
412
509
|
this.sessionReferences.clear();
|
|
413
|
-
const evictionResults = await Promise.allSettled(this.sessionEvictions);
|
|
510
|
+
const evictionResults = await Promise.allSettled(this.sessionEvictions.values());
|
|
414
511
|
for (const result of evictionResults) {
|
|
415
512
|
if (result.status === "rejected") {
|
|
416
513
|
errors.push(result.reason);
|
|
417
514
|
}
|
|
418
515
|
}
|
|
419
516
|
this.sessionEvictions.clear();
|
|
420
|
-
|
|
421
|
-
await this.mcp.close();
|
|
422
|
-
}
|
|
423
|
-
catch (error) {
|
|
424
|
-
errors.push(error);
|
|
425
|
-
}
|
|
517
|
+
errors.push(...this.disposalFailures.values());
|
|
426
518
|
try {
|
|
427
519
|
await this.history.flush();
|
|
428
520
|
}
|
|
@@ -437,7 +529,7 @@ export class LocalSessionHost {
|
|
|
437
529
|
}
|
|
438
530
|
await resourceShutdown;
|
|
439
531
|
if (errors.length > 0) {
|
|
440
|
-
throw new AggregateError(errors, "failed to shut down local session host");
|
|
532
|
+
throw new AggregateError([...new Set(errors)], "failed to shut down local session host");
|
|
441
533
|
}
|
|
442
534
|
}
|
|
443
535
|
async refreshStore() {
|
|
@@ -466,14 +558,14 @@ class LocalHostedSessionHandle {
|
|
|
466
558
|
runtime;
|
|
467
559
|
promptBootstrap;
|
|
468
560
|
catalog;
|
|
561
|
+
mcp;
|
|
469
562
|
bootstrap;
|
|
470
563
|
remoteCatalog;
|
|
471
564
|
getLatestRemoteModelCatalog;
|
|
472
565
|
includeAgentContext;
|
|
473
566
|
executionEnvironment;
|
|
474
567
|
store;
|
|
475
|
-
|
|
476
|
-
historyRemote;
|
|
568
|
+
historyRecorder;
|
|
477
569
|
attributes;
|
|
478
570
|
createdAt;
|
|
479
571
|
recordUsage;
|
|
@@ -508,26 +600,28 @@ class LocalHostedSessionHandle {
|
|
|
508
600
|
disposePromise;
|
|
509
601
|
disposing = false;
|
|
510
602
|
costTotal = 0;
|
|
603
|
+
boundMcpServers;
|
|
511
604
|
forceNextSnapshotRevision;
|
|
512
605
|
projectionFailure;
|
|
513
606
|
disposed = false;
|
|
514
|
-
constructor(runtime, promptBootstrap, catalog, bootstrap, remoteCatalog, getLatestRemoteModelCatalog, includeAgentContext, executionEnvironment, store,
|
|
607
|
+
constructor(runtime, promptBootstrap, catalog, mcp, bootstrap, remoteCatalog, getLatestRemoteModelCatalog, includeAgentContext, executionEnvironment, store, historyRecorder, attributes, createdAt, committedSnapshot, forceNextSnapshotRevision, recordUsage, removeFromHost) {
|
|
515
608
|
this.runtime = runtime;
|
|
516
609
|
this.promptBootstrap = promptBootstrap;
|
|
517
610
|
this.catalog = catalog;
|
|
611
|
+
this.mcp = mcp;
|
|
518
612
|
this.bootstrap = bootstrap;
|
|
519
613
|
this.remoteCatalog = remoteCatalog;
|
|
520
614
|
this.getLatestRemoteModelCatalog = getLatestRemoteModelCatalog;
|
|
521
615
|
this.includeAgentContext = includeAgentContext;
|
|
522
616
|
this.executionEnvironment = executionEnvironment;
|
|
523
617
|
this.store = store;
|
|
524
|
-
this.
|
|
525
|
-
this.historyRemote = historyRemote;
|
|
618
|
+
this.historyRecorder = historyRecorder;
|
|
526
619
|
this.attributes = attributes;
|
|
527
620
|
this.createdAt = createdAt;
|
|
528
621
|
this.recordUsage = recordUsage;
|
|
529
622
|
this.removeFromHost = removeFromHost;
|
|
530
623
|
this.session = runtime;
|
|
624
|
+
this.boundMcpServers = structuredClone(catalog.mcp.status === "available" ? bootstrap.config.mcpServers : {});
|
|
531
625
|
this.persistedSnapshot = committedSnapshot
|
|
532
626
|
? cloneSessionProtocolSnapshot(committedSnapshot)
|
|
533
627
|
: undefined;
|
|
@@ -537,6 +631,13 @@ class LocalHostedSessionHandle {
|
|
|
537
631
|
? cloneSessionProtocolSnapshot(committedSnapshot)
|
|
538
632
|
: { ...this.buildSnapshotDraft(), revision: 1 };
|
|
539
633
|
}
|
|
634
|
+
get hasActiveWork() {
|
|
635
|
+
return (Boolean(this.activeTurnPromise) ||
|
|
636
|
+
this.activeWorkPromises.size > 0 ||
|
|
637
|
+
this.runtime.isTurnRunning ||
|
|
638
|
+
this.runtime.jobs.hasRunning ||
|
|
639
|
+
this.runtime.supervisor.getActiveCount() > 0);
|
|
640
|
+
}
|
|
540
641
|
get isTurnRunning() {
|
|
541
642
|
return this.runtime.isTurnRunning;
|
|
542
643
|
}
|
|
@@ -854,98 +955,114 @@ class LocalHostedSessionHandle {
|
|
|
854
955
|
}
|
|
855
956
|
async setPersona(personaId, overrides) {
|
|
856
957
|
this.assertActive();
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
this.
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
958
|
+
return await this.trackActiveWork(async () => {
|
|
959
|
+
const runtimeConfig = await this.executionEnvironment.resolveRuntimeConfig(this.executionEnvironment.snapshot().cwd, { remoteCatalog: this.remoteCatalog });
|
|
960
|
+
const personas = runtimeConfig.personas.map(clonePersona);
|
|
961
|
+
const selectedPersona = resolvePersonaSelection(personas, runtimeConfig.config.defaultPersona, personaId, overrides);
|
|
962
|
+
const runtimeContext = await this.executionEnvironment.resolveRuntimeContext({
|
|
963
|
+
cwd: this.executionEnvironment.snapshot().cwd,
|
|
964
|
+
discoveredSkills: runtimeConfig.skills,
|
|
965
|
+
includeAgentContext: this.includeAgentContext,
|
|
966
|
+
});
|
|
967
|
+
return await this.enqueueConfigurationMutation(async () => {
|
|
968
|
+
this.runtime.setRuntimeConfig(runtimeConfig.config, runtimeConfig.bootstrap.modelResolver.resolveModel);
|
|
969
|
+
this.runtime.updatePromptContext(runtimeContext.promptBootstrap.promptContext);
|
|
970
|
+
this.runtime.setPersona(selectedPersona);
|
|
971
|
+
this.runtime.setAutoCompactThreshold(overrides?.autoCompactThresholdTokens ?? null);
|
|
972
|
+
this.bootstrap = {
|
|
973
|
+
persona: clonePersona(selectedPersona),
|
|
974
|
+
discoveredSkills: structuredClone(runtimeConfig.skills),
|
|
975
|
+
personas: personas.map(clonePersona),
|
|
976
|
+
prompts: structuredClone(runtimeConfig.prompts),
|
|
977
|
+
modelResolver: runtimeConfig.bootstrap.modelResolver.resolveModel,
|
|
978
|
+
config: runtimeConfig.config,
|
|
979
|
+
};
|
|
980
|
+
this.catalog = createContentCatalogSnapshot(this.bootstrap, this.catalog.mcp);
|
|
981
|
+
const snapshot = await this.commitSnapshot();
|
|
982
|
+
this.emitSnapshotReset("configuration", snapshot);
|
|
983
|
+
return snapshot;
|
|
984
|
+
});
|
|
882
985
|
});
|
|
883
986
|
}
|
|
884
987
|
async reload() {
|
|
885
988
|
this.assertActive();
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
this.
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
989
|
+
return await this.trackActiveWork(async () => {
|
|
990
|
+
const remoteCatalog = this.getLatestRemoteModelCatalog();
|
|
991
|
+
const runtimeConfig = await this.executionEnvironment.resolveRuntimeConfig(this.executionEnvironment.snapshot().cwd, { remoteCatalog });
|
|
992
|
+
if (runtimeConfig.personas.length === 0) {
|
|
993
|
+
throw new Error("reload failed: no personas available");
|
|
994
|
+
}
|
|
995
|
+
const personas = runtimeConfig.personas.map(clonePersona);
|
|
996
|
+
const currentPersonaId = this.runtime.persona.id.toLowerCase();
|
|
997
|
+
const nextPersona = clonePersona(personas.find((persona) => persona.id.toLowerCase() === currentPersonaId) ?? personas[0]);
|
|
998
|
+
if (nextPersona.id.toLowerCase() === currentPersonaId) {
|
|
999
|
+
nextPersona.settings = structuredClone(this.runtime.persona.settings);
|
|
1000
|
+
}
|
|
1001
|
+
const runtimeContext = await this.executionEnvironment.resolveRuntimeContext({
|
|
1002
|
+
cwd: this.executionEnvironment.snapshot().cwd,
|
|
1003
|
+
discoveredSkills: runtimeConfig.skills,
|
|
1004
|
+
includeAgentContext: this.includeAgentContext,
|
|
1005
|
+
});
|
|
1006
|
+
return await this.enqueueConfigurationMutation(async () => {
|
|
1007
|
+
this.runtime.setRuntimeConfig(runtimeConfig.config, runtimeConfig.bootstrap.modelResolver.resolveModel);
|
|
1008
|
+
this.runtime.updatePromptContext(runtimeContext.promptBootstrap.promptContext);
|
|
1009
|
+
this.runtime.setPersona(nextPersona);
|
|
1010
|
+
this.remoteCatalog = remoteCatalog;
|
|
1011
|
+
this.bootstrap = {
|
|
1012
|
+
persona: clonePersona(nextPersona),
|
|
1013
|
+
discoveredSkills: structuredClone(runtimeConfig.skills),
|
|
1014
|
+
personas: personas.map(clonePersona),
|
|
1015
|
+
prompts: structuredClone(runtimeConfig.prompts),
|
|
1016
|
+
modelResolver: runtimeConfig.bootstrap.modelResolver.resolveModel,
|
|
1017
|
+
config: runtimeConfig.config,
|
|
1018
|
+
};
|
|
1019
|
+
this.catalog = createContentCatalogSnapshot(this.bootstrap, this.catalog.mcp);
|
|
1020
|
+
const snapshot = await this.commitSnapshot();
|
|
1021
|
+
this.emitSnapshotReset("configuration", snapshot);
|
|
1022
|
+
return {
|
|
1023
|
+
snapshot,
|
|
1024
|
+
warnings: [
|
|
1025
|
+
...runtimeConfig.warnings,
|
|
1026
|
+
...(this.catalog.mcp.status === "available" &&
|
|
1027
|
+
!isDeepStrictEqual(this.boundMcpServers, runtimeConfig.config.mcpServers)
|
|
1028
|
+
? [
|
|
1029
|
+
"MCP configuration changed; new definitions take effect after this session unloads and is opened again.",
|
|
1030
|
+
]
|
|
1031
|
+
: []),
|
|
1032
|
+
],
|
|
1033
|
+
counts: {
|
|
1034
|
+
personas: runtimeConfig.personas.length,
|
|
1035
|
+
prompts: runtimeConfig.prompts.length,
|
|
1036
|
+
skills: runtimeConfig.skills.length,
|
|
1037
|
+
},
|
|
1038
|
+
};
|
|
1039
|
+
});
|
|
927
1040
|
});
|
|
928
1041
|
}
|
|
929
1042
|
async resolvePrompt(promptId) {
|
|
930
1043
|
this.assertActive();
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
1044
|
+
return await this.trackActiveWork(async () => {
|
|
1045
|
+
const executionSnapshot = this.executionEnvironment.snapshot();
|
|
1046
|
+
const prompt = await resolvePromptTemplateWithBackend({
|
|
1047
|
+
backend: this.executionEnvironment.getToolExecutionBackend(),
|
|
1048
|
+
cwd: executionSnapshot.cwd,
|
|
1049
|
+
home: executionSnapshot.home,
|
|
1050
|
+
promptId,
|
|
1051
|
+
});
|
|
1052
|
+
if (!prompt) {
|
|
1053
|
+
throw new Error(`unknown prompt '${promptId}'`);
|
|
1054
|
+
}
|
|
1055
|
+
return { promptId: prompt.id, text: prompt.template };
|
|
937
1056
|
});
|
|
938
|
-
if (!prompt) {
|
|
939
|
-
throw new Error(`unknown prompt '${promptId}'`);
|
|
940
|
-
}
|
|
941
|
-
return { promptId: prompt.id, text: prompt.template };
|
|
942
1057
|
}
|
|
943
1058
|
async autocompletePaths(options) {
|
|
944
1059
|
this.assertActive();
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
1060
|
+
return await this.trackActiveWork(async () => {
|
|
1061
|
+
const entries = await this.getPathAutocompleteEntries();
|
|
1062
|
+
return {
|
|
1063
|
+
paths: filterProjectPathAutocompleteEntries(entries, options),
|
|
1064
|
+
};
|
|
1065
|
+
});
|
|
949
1066
|
}
|
|
950
1067
|
async getPathAutocompleteEntries() {
|
|
951
1068
|
const now = Date.now();
|
|
@@ -1009,13 +1126,20 @@ class LocalHostedSessionHandle {
|
|
|
1009
1126
|
? AbortSignal.any([externalSignal, abortController.signal])
|
|
1010
1127
|
: abortController.signal;
|
|
1011
1128
|
this.activeWorkAbortControllers.add(abortController);
|
|
1012
|
-
|
|
1129
|
+
try {
|
|
1130
|
+
return await this.trackActiveWork(() => operation(signal));
|
|
1131
|
+
}
|
|
1132
|
+
finally {
|
|
1133
|
+
this.activeWorkAbortControllers.delete(abortController);
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
async trackActiveWork(operation) {
|
|
1137
|
+
const promise = operation();
|
|
1013
1138
|
this.activeWorkPromises.add(promise);
|
|
1014
1139
|
try {
|
|
1015
1140
|
return await promise;
|
|
1016
1141
|
}
|
|
1017
1142
|
finally {
|
|
1018
|
-
this.activeWorkAbortControllers.delete(abortController);
|
|
1019
1143
|
this.activeWorkPromises.delete(promise);
|
|
1020
1144
|
}
|
|
1021
1145
|
}
|
|
@@ -1167,17 +1291,23 @@ class LocalHostedSessionHandle {
|
|
|
1167
1291
|
errors.push(error);
|
|
1168
1292
|
}
|
|
1169
1293
|
try {
|
|
1170
|
-
await this.
|
|
1294
|
+
await this.mcp.close();
|
|
1171
1295
|
}
|
|
1172
1296
|
catch (error) {
|
|
1173
1297
|
errors.push(error);
|
|
1174
1298
|
}
|
|
1175
|
-
|
|
1176
|
-
this.
|
|
1299
|
+
try {
|
|
1300
|
+
await this.executionEnvironment.dispose();
|
|
1177
1301
|
}
|
|
1178
|
-
|
|
1179
|
-
|
|
1302
|
+
catch (error) {
|
|
1303
|
+
errors.push(error);
|
|
1180
1304
|
}
|
|
1305
|
+
const error = errors.length > 0
|
|
1306
|
+
? new AggregateError(errors, "failed to dispose hosted session")
|
|
1307
|
+
: undefined;
|
|
1308
|
+
this.removeFromHost(this, error);
|
|
1309
|
+
if (error)
|
|
1310
|
+
throw error;
|
|
1181
1311
|
}
|
|
1182
1312
|
async commitSnapshot(options = {}) {
|
|
1183
1313
|
this.assertNotDisposed();
|
|
@@ -1529,7 +1659,10 @@ class LocalHostedSessionHandle {
|
|
|
1529
1659
|
await this.enqueueMutation(() => this.applySubagentEvent(event));
|
|
1530
1660
|
}
|
|
1531
1661
|
async enqueueRuntimeEvent(event) {
|
|
1532
|
-
await this.enqueueMutation(() =>
|
|
1662
|
+
await this.enqueueMutation(async () => {
|
|
1663
|
+
await this.recordRuntimeEvent(event);
|
|
1664
|
+
await this.recordHistoryFailure(this.historyRecorder.record(event));
|
|
1665
|
+
});
|
|
1533
1666
|
}
|
|
1534
1667
|
removeToolRun(tool, changes) {
|
|
1535
1668
|
this.tools.delete(tool.id);
|
|
@@ -1541,6 +1674,16 @@ class LocalHostedSessionHandle {
|
|
|
1541
1674
|
}
|
|
1542
1675
|
changes.push({ type: "tool.remove", id: tool.id }, { type: "timeline.remove", id: timelineItemId });
|
|
1543
1676
|
}
|
|
1677
|
+
async recordSubagentHistoryFailure(reason) {
|
|
1678
|
+
if (this.disposing || this.disposed)
|
|
1679
|
+
return;
|
|
1680
|
+
try {
|
|
1681
|
+
await this.enqueueMutation(() => this.recordHistoryFailure(reason));
|
|
1682
|
+
}
|
|
1683
|
+
catch {
|
|
1684
|
+
// A history diagnostic must not fail a worker when its parent is unavailable.
|
|
1685
|
+
}
|
|
1686
|
+
}
|
|
1544
1687
|
async recordHistoryFailure(reason) {
|
|
1545
1688
|
if (!reason || this.timeline.items.some((item) => item.id === HISTORY_UNAVAILABLE_NOTICE_ID)) {
|
|
1546
1689
|
return;
|
|
@@ -1571,15 +1714,13 @@ class LocalHostedSessionHandle {
|
|
|
1571
1714
|
if (tool.status === "queued" || tool.status === "running") {
|
|
1572
1715
|
throw new Error(`transcript tool call '${tool.toolCallId}' is not terminal`);
|
|
1573
1716
|
}
|
|
1574
|
-
await this.recordHistoryFailure(this.
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
}),
|
|
1582
|
-
], this.historyRemote));
|
|
1717
|
+
await this.recordHistoryFailure(this.historyRecorder.recordTool({
|
|
1718
|
+
callHistoryEntryId: tool.call.messageId,
|
|
1719
|
+
resultHistoryEntryId,
|
|
1720
|
+
call,
|
|
1721
|
+
result,
|
|
1722
|
+
outcome: tool.status,
|
|
1723
|
+
}));
|
|
1583
1724
|
}
|
|
1584
1725
|
agentStateChange() {
|
|
1585
1726
|
const state = this.session.snapshot();
|
|
@@ -1722,7 +1863,6 @@ class LocalHostedSessionHandle {
|
|
|
1722
1863
|
},
|
|
1723
1864
|
},
|
|
1724
1865
|
], { persist: true });
|
|
1725
|
-
await this.recordHistoryFailure(this.history.append(this.sessionId, [systemHistoryEntry(event.historyEntryId, event.message)], this.historyRemote));
|
|
1726
1866
|
return;
|
|
1727
1867
|
}
|
|
1728
1868
|
case "user_message": {
|
|
@@ -1755,7 +1895,6 @@ class LocalHostedSessionHandle {
|
|
|
1755
1895
|
if (turn) {
|
|
1756
1896
|
this.pendingAcceptedTurnHistoryEntryIds.delete(event.historyEntryId);
|
|
1757
1897
|
}
|
|
1758
|
-
await this.recordHistoryFailure(this.history.append(this.sessionId, [userHistoryEntry(event.historyEntryId, event.message)], this.historyRemote));
|
|
1759
1898
|
return;
|
|
1760
1899
|
}
|
|
1761
1900
|
case "history_rewound": {
|
|
@@ -1767,7 +1906,6 @@ class LocalHostedSessionHandle {
|
|
|
1767
1906
|
this.timeline.items = this.timeline.items.filter((item) => item.sequence <= cutoffSequence);
|
|
1768
1907
|
const snapshot = await this.commitSnapshot({ removeMissingAgents: true });
|
|
1769
1908
|
this.emitSnapshotReset({ type: "rewind", epoch: this.timeline.epoch, cutoffSequence }, snapshot);
|
|
1770
|
-
await this.recordHistoryFailure(this.history.truncateFromSources(this.sessionId, event.removedEntryIds, this.historyRemote));
|
|
1771
1909
|
return;
|
|
1772
1910
|
}
|
|
1773
1911
|
case "assistant_final": {
|
|
@@ -1815,7 +1953,6 @@ class LocalHostedSessionHandle {
|
|
|
1815
1953
|
: []),
|
|
1816
1954
|
...toolChanges,
|
|
1817
1955
|
]);
|
|
1818
|
-
await this.recordHistoryFailure(this.history.append(this.sessionId, assistantHistoryEntries(event.historyEntryId, event.message), this.historyRemote));
|
|
1819
1956
|
return;
|
|
1820
1957
|
}
|
|
1821
1958
|
case "tool_run_queued":
|
|
@@ -1873,7 +2010,6 @@ class LocalHostedSessionHandle {
|
|
|
1873
2010
|
},
|
|
1874
2011
|
{ type: "tool.set", tool: structuredClone(nextTool) },
|
|
1875
2012
|
]);
|
|
1876
|
-
await this.appendToolHistory(existing, event.historyEntryId, event.message);
|
|
1877
2013
|
return;
|
|
1878
2014
|
}
|
|
1879
2015
|
await this.emitPatch("tool-result", [
|
|
@@ -1903,7 +2039,6 @@ class LocalHostedSessionHandle {
|
|
|
1903
2039
|
},
|
|
1904
2040
|
},
|
|
1905
2041
|
];
|
|
1906
|
-
const historyTools = [];
|
|
1907
2042
|
for (const toolResult of event.toolResults) {
|
|
1908
2043
|
const existing = this.tools.get(toolResult.toolCallId);
|
|
1909
2044
|
if (!existing || existing.status === "streaming") {
|
|
@@ -1917,12 +2052,8 @@ class LocalHostedSessionHandle {
|
|
|
1917
2052
|
};
|
|
1918
2053
|
this.tools.set(nextTool.id, nextTool);
|
|
1919
2054
|
changes.push({ type: "tool.set", tool: structuredClone(nextTool) });
|
|
1920
|
-
historyTools.push({ tool: existing, result: toolResult });
|
|
1921
2055
|
}
|
|
1922
2056
|
await this.emitPatch({ type: "resync" }, changes);
|
|
1923
|
-
for (const { tool, result } of historyTools) {
|
|
1924
|
-
await this.appendToolHistory(tool, event.historyEntryId, result);
|
|
1925
|
-
}
|
|
1926
2057
|
return;
|
|
1927
2058
|
}
|
|
1928
2059
|
case "feedback": {
|
|
@@ -2567,10 +2698,10 @@ function cloneResolvedBootstrap(bootstrap) {
|
|
|
2567
2698
|
personas: bootstrap.personas.map(clonePersona),
|
|
2568
2699
|
prompts: structuredClone(bootstrap.prompts),
|
|
2569
2700
|
modelResolver: bootstrap.modelResolver,
|
|
2570
|
-
|
|
2701
|
+
config: structuredClone(bootstrap.config),
|
|
2571
2702
|
};
|
|
2572
2703
|
}
|
|
2573
|
-
function createContentCatalogSnapshot(bootstrap,
|
|
2704
|
+
function createContentCatalogSnapshot(bootstrap, mcp) {
|
|
2574
2705
|
return {
|
|
2575
2706
|
personas: bootstrap.personas.map(personaSnapshotFromPersona),
|
|
2576
2707
|
prompts: bootstrap.prompts.map((prompt) => ({
|
|
@@ -2582,7 +2713,8 @@ function createContentCatalogSnapshot(bootstrap, mcpServers) {
|
|
|
2582
2713
|
description: skill.description,
|
|
2583
2714
|
path: skill.path,
|
|
2584
2715
|
})),
|
|
2585
|
-
|
|
2716
|
+
mcp: structuredClone(mcp),
|
|
2717
|
+
speechVocabulary: [...bootstrap.config.speechVocabulary],
|
|
2586
2718
|
};
|
|
2587
2719
|
}
|
|
2588
2720
|
function clonePersona(persona) {
|