@earendil-works/pi-coding-agent 0.85.0 → 0.86.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.
- package/CHANGELOG.md +104 -0
- package/README.md +2 -3
- package/dist/bun/cli.d.ts +3 -1
- package/dist/bun/cli.d.ts.map +1 -1
- package/dist/bun/cli.js +3 -12
- package/dist/bun/cli.js.map +1 -1
- package/dist/bun/sandbox-env-setup.d.ts +2 -0
- package/dist/bun/sandbox-env-setup.d.ts.map +1 -0
- package/dist/bun/sandbox-env-setup.js +4 -0
- package/dist/bun/sandbox-env-setup.js.map +1 -0
- package/dist/bundle/chunks/anthropic-messages-MYU5ZMRF.js +6 -0
- package/dist/bundle/chunks/azure-openai-responses-HUSQ3GP2.js +2 -0
- package/dist/bundle/chunks/bedrock-converse-stream.js +47 -38
- package/dist/bundle/chunks/chunk-7IOYH2SY.js +2 -0
- package/dist/bundle/chunks/chunk-7YM6BE7Y.js +1561 -0
- package/dist/bundle/chunks/chunk-A3JYRWB6.js +2 -0
- package/dist/bundle/chunks/chunk-DTD7JQ7Y.js +42 -0
- package/dist/bundle/chunks/chunk-FUXEF6JQ.js +44 -0
- package/dist/bundle/chunks/{chunk-IDDQWTHI.js → chunk-RCZIEVGO.js} +10 -1
- package/dist/bundle/chunks/chunk-S7SZN6Z3.js +2 -0
- package/dist/bundle/chunks/chunk-WIUZI2CJ.js +11 -0
- package/dist/bundle/chunks/github-copilot.js +1 -1
- package/dist/bundle/chunks/google-generative-ai-IMS5EK2Y.js +2 -0
- package/dist/bundle/chunks/google-vertex-O4YJEQUW.js +2 -0
- package/dist/bundle/chunks/jiti-loader-C3NU2SDH.js +21 -0
- package/dist/bundle/chunks/jiti-static-loader-E6ANQD5T.js +2 -0
- package/dist/bundle/chunks/mistral-conversations-NOSQHBEY.js +5 -0
- package/dist/bundle/chunks/{node-EM5FIVUN.js → node-O3RIBJRH.js} +1 -1
- package/dist/bundle/chunks/openai-codex-responses-QDSOTBBO.js +10 -0
- package/dist/bundle/chunks/openai-completions-KQPOPEVM.js +7 -0
- package/dist/bundle/chunks/openai-responses-HWEUZ6WZ.js +2 -0
- package/dist/bundle/chunks/{pi-messages-EGZIFQGG.js → pi-messages-GFKBWJHZ.js} +1 -1
- package/dist/bundle/chunks/virtual-modules-XW5APVUE.js +2 -0
- package/dist/bundle/cli.js +1 -1
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +0 -2
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/session-picker.d.ts +1 -1
- package/dist/cli/session-picker.d.ts.map +1 -1
- package/dist/cli/session-picker.js.map +1 -1
- package/dist/cli/setup.d.ts +2 -0
- package/dist/cli/setup.d.ts.map +1 -0
- package/dist/cli/setup.js +12 -0
- package/dist/cli/setup.js.map +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +3 -25
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -1
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session.d.ts +56 -6
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +293 -155
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/bug-report-upload.d.ts +12 -0
- package/dist/core/bug-report-upload.d.ts.map +1 -0
- package/dist/core/bug-report-upload.js +22 -0
- package/dist/core/bug-report-upload.js.map +1 -0
- package/dist/core/bug-report.d.ts +176 -0
- package/dist/core/bug-report.d.ts.map +1 -0
- package/dist/core/bug-report.js +292 -0
- package/dist/core/bug-report.js.map +1 -0
- package/dist/core/cache-stats.d.ts.map +1 -1
- package/dist/core/cache-stats.js +12 -1
- package/dist/core/cache-stats.js.map +1 -1
- package/dist/core/cache-warmer.d.ts +102 -0
- package/dist/core/cache-warmer.d.ts.map +1 -0
- package/dist/core/cache-warmer.js +342 -0
- package/dist/core/cache-warmer.js.map +1 -0
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +2 -2
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +2 -2
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +11 -12
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/crash-log.d.ts +22 -0
- package/dist/core/crash-log.d.ts.map +1 -0
- package/dist/core/crash-log.js +71 -0
- package/dist/core/crash-log.js.map +1 -0
- package/dist/core/experimental.d.ts +0 -4
- package/dist/core/experimental.d.ts.map +1 -1
- package/dist/core/experimental.js +0 -4
- package/dist/core/experimental.js.map +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/jiti-loader.d.ts +2 -0
- package/dist/core/extensions/jiti-loader.d.ts.map +1 -0
- package/dist/core/extensions/jiti-loader.js +4 -0
- package/dist/core/extensions/jiti-loader.js.map +1 -0
- package/dist/core/extensions/jiti-static-loader.d.ts +2 -0
- package/dist/core/extensions/jiti-static-loader.d.ts.map +1 -0
- package/dist/core/extensions/jiti-static-loader.js +4 -0
- package/dist/core/extensions/jiti-static-loader.js.map +1 -0
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +38 -51
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +10 -7
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +85 -67
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +60 -50
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/extensions/virtual-modules.d.ts +3 -0
- package/dist/core/extensions/virtual-modules.d.ts.map +1 -0
- package/dist/core/extensions/virtual-modules.js +38 -0
- package/dist/core/extensions/virtual-modules.js.map +1 -0
- package/dist/core/extensions/wrapper.d.ts.map +1 -1
- package/dist/core/extensions/wrapper.js +1 -20
- package/dist/core/extensions/wrapper.js.map +1 -1
- package/dist/core/index.d.ts +2 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/keybindings.d.ts +6 -1
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +5 -1
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js +1 -0
- package/dist/core/messages.js.map +1 -1
- package/dist/core/model-config.d.ts +101 -20
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +25 -18
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-registry.d.ts +5 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +8 -0
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +1 -1
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +5 -3
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/provider-composer.d.ts +3 -2
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +2 -0
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/radius.d.ts +3 -0
- package/dist/core/radius.d.ts.map +1 -1
- package/dist/core/radius.js +6 -0
- package/dist/core/radius.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +60 -38
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-export.d.ts +6 -2
- package/dist/core/session-export.d.ts.map +1 -1
- package/dist/core/session-export.js +14 -13
- package/dist/core/session-export.js.map +1 -1
- package/dist/core/session-manager.d.ts +29 -6
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +159 -96
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts +20 -4
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +43 -7
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +1 -0
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/system-prompt.d.ts +49 -6
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +121 -92
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/bash.d.ts +2 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +10 -4
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +1 -2
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +1 -2
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/renderers/bash.d.ts.map +1 -1
- package/dist/core/tools/renderers/bash.js +9 -1
- package/dist/core/tools/renderers/bash.js.map +1 -1
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +1 -2
- package/dist/core/tools/write.js.map +1 -1
- package/dist/core/usage-totals.d.ts +1 -1
- package/dist/core/usage-totals.d.ts.map +1 -1
- package/dist/core/usage-totals.js +5 -1
- package/dist/core/usage-totals.js.map +1 -1
- package/dist/extensions/llama/client.d.ts +2 -0
- package/dist/extensions/llama/client.d.ts.map +1 -1
- package/dist/extensions/llama/client.js +7 -3
- package/dist/extensions/llama/client.js.map +1 -1
- package/dist/extensions/llama/provider.d.ts.map +1 -1
- package/dist/extensions/llama/provider.js +20 -5
- package/dist/extensions/llama/provider.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +13 -131
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +2 -2
- package/dist/migrations.js.map +1 -1
- package/dist/modes/interactive/bug-report.d.ts +14 -0
- package/dist/modes/interactive/bug-report.d.ts.map +1 -0
- package/dist/modes/interactive/bug-report.js +209 -0
- package/dist/modes/interactive/bug-report.js.map +1 -0
- package/dist/modes/interactive/chat-viewport.d.ts.map +1 -1
- package/dist/modes/interactive/chat-viewport.js +1 -1
- package/dist/modes/interactive/chat-viewport.js.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js +12 -5
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.js +12 -5
- package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +3 -3
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/extension-input.d.ts +2 -0
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-input.js +6 -0
- package/dist/modes/interactive/components/extension-input.js.map +1 -1
- package/dist/modes/interactive/components/extension-selector.d.ts +1 -0
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-selector.js +4 -0
- package/dist/modes/interactive/components/extension-selector.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +4 -1
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +5 -5
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +8 -8
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts +5 -5
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +74 -48
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +3 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +11 -0
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.js +11 -4
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
- package/dist/modes/interactive/components/status-indicator.d.ts +2 -2
- package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
- package/dist/modes/interactive/components/status-indicator.js +7 -7
- package/dist/modes/interactive/components/status-indicator.js.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +4 -4
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +18 -9
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +2 -0
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +13 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +220 -84
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/session-share.d.ts +2 -0
- package/dist/modes/interactive/session-share.d.ts.map +1 -1
- package/dist/modes/interactive/session-share.js +8 -4
- package/dist/modes/interactive/session-share.js.map +1 -1
- package/dist/modes/interactive/tui-renderer.d.ts.map +1 -1
- package/dist/modes/interactive/tui-renderer.js +2 -2
- package/dist/modes/interactive/tui-renderer.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +2 -2
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/utils/clipboard-command.d.ts +7 -0
- package/dist/utils/clipboard-command.d.ts.map +1 -0
- package/dist/utils/clipboard-command.js +45 -0
- package/dist/utils/clipboard-command.js.map +1 -0
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-image.js +52 -69
- package/dist/utils/clipboard-image.js.map +1 -1
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +61 -125
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/zip.d.ts +7 -0
- package/dist/utils/zip.d.ts.map +1 -0
- package/dist/utils/zip.js +60 -0
- package/dist/utils/zip.js.map +1 -0
- package/docs/compaction.md +39 -13
- package/docs/containerization.md +45 -0
- package/docs/custom-provider.md +22 -13
- package/docs/development.md +23 -4
- package/docs/docs.json +4 -0
- package/docs/environment-variables.md +3 -2
- package/docs/extensions.md +57 -43
- package/docs/json.md +4 -4
- package/docs/keybindings.md +2 -1
- package/docs/models.md +34 -3
- package/docs/providers.md +2 -2
- package/docs/sdk.md +4 -2
- package/docs/security.md +1 -1
- package/docs/session-format.md +82 -40
- package/docs/sessions.md +27 -0
- package/docs/settings.md +60 -1
- package/docs/termux.md +0 -1
- package/docs/tui.md +2 -2
- package/docs/usage.md +1 -0
- package/examples/extensions/README.md +0 -1
- package/examples/extensions/custom-provider-anthropic/index.ts +18 -12
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +2 -2
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/prompt-customizer.ts +19 -67
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +425 -778
- package/package.json +22 -27
- package/dist/bundle/chunks/anthropic-messages-QAQLEQIY.js +0 -6
- package/dist/bundle/chunks/azure-openai-responses-Q7MJBRE6.js +0 -2
- package/dist/bundle/chunks/chunk-2KVJKXS2.js +0 -50
- package/dist/bundle/chunks/chunk-AXIIZGTV.js +0 -2
- package/dist/bundle/chunks/chunk-EQ6DR6XK.js +0 -5
- package/dist/bundle/chunks/chunk-GMWCTUPB.js +0 -2
- package/dist/bundle/chunks/chunk-LZKJTKCT.js +0 -2
- package/dist/bundle/chunks/chunk-OUXLLA64.js +0 -11
- package/dist/bundle/chunks/chunk-R7UUJ4C2.js +0 -42
- package/dist/bundle/chunks/chunk-UAQELI3K.js +0 -2
- package/dist/bundle/chunks/chunk-WBE4J4AU.js +0 -9
- package/dist/bundle/chunks/chunk-WZB2R5YO.js +0 -1558
- package/dist/bundle/chunks/google-generative-ai-BSMTYDAM.js +0 -2
- package/dist/bundle/chunks/google-vertex-5C3HASOJ.js +0 -2
- package/dist/bundle/chunks/mistral-conversations-4M6BZBX6.js +0 -5
- package/dist/bundle/chunks/openai-codex-responses-YJOO52RW.js +0 -10
- package/dist/bundle/chunks/openai-completions-QOT3QX7D.js +0 -7
- package/dist/bundle/chunks/openai-responses-U7LNPQN4.js +0 -2
- package/dist/bundle/client.js +0 -2
- package/dist/bundle/coordinator.js +0 -3
- package/dist/cli/experimental/cli.d.ts +0 -10
- package/dist/cli/experimental/cli.d.ts.map +0 -1
- package/dist/cli/experimental/cli.js +0 -9
- package/dist/cli/experimental/cli.js.map +0 -1
- package/dist/cli/experimental/command-options.d.ts +0 -28
- package/dist/cli/experimental/command-options.d.ts.map +0 -1
- package/dist/cli/experimental/command-options.js +0 -84
- package/dist/cli/experimental/command-options.js.map +0 -1
- package/dist/cli/experimental/command.d.ts +0 -70
- package/dist/cli/experimental/command.d.ts.map +0 -1
- package/dist/cli/experimental/command.js +0 -144
- package/dist/cli/experimental/command.js.map +0 -1
- package/dist/cli/experimental/commands/client.d.ts +0 -19
- package/dist/cli/experimental/commands/client.d.ts.map +0 -1
- package/dist/cli/experimental/commands/client.js +0 -63
- package/dist/cli/experimental/commands/client.js.map +0 -1
- package/dist/cli/experimental/commands/server.d.ts +0 -17
- package/dist/cli/experimental/commands/server.d.ts.map +0 -1
- package/dist/cli/experimental/commands/server.js +0 -44
- package/dist/cli/experimental/commands/server.js.map +0 -1
- package/dist/client/index.d.ts +0 -2
- package/dist/client/index.d.ts.map +0 -1
- package/dist/client/index.js +0 -2
- package/dist/client/index.js.map +0 -1
- package/dist/experimental/client-runtime.d.ts +0 -43
- package/dist/experimental/client-runtime.d.ts.map +0 -1
- package/dist/experimental/client-runtime.js +0 -183
- package/dist/experimental/client-runtime.js.map +0 -1
- package/dist/experimental/client-tui-chat.d.ts +0 -14
- package/dist/experimental/client-tui-chat.d.ts.map +0 -1
- package/dist/experimental/client-tui-chat.js +0 -171
- package/dist/experimental/client-tui-chat.js.map +0 -1
- package/dist/experimental/client-tui.d.ts +0 -37
- package/dist/experimental/client-tui.d.ts.map +0 -1
- package/dist/experimental/client-tui.js +0 -702
- package/dist/experimental/client-tui.js.map +0 -1
- package/dist/experimental/client.d.ts +0 -25
- package/dist/experimental/client.d.ts.map +0 -1
- package/dist/experimental/client.js +0 -99
- package/dist/experimental/client.js.map +0 -1
- package/dist/experimental/coordinator-entry.d.ts +0 -3
- package/dist/experimental/coordinator-entry.d.ts.map +0 -1
- package/dist/experimental/coordinator-entry.js +0 -11
- package/dist/experimental/coordinator-entry.js.map +0 -1
- package/dist/experimental/coordinator.d.ts +0 -38
- package/dist/experimental/coordinator.d.ts.map +0 -1
- package/dist/experimental/coordinator.js +0 -570
- package/dist/experimental/coordinator.js.map +0 -1
- package/dist/experimental/mini/main.d.ts +0 -7
- package/dist/experimental/mini/main.d.ts.map +0 -1
- package/dist/experimental/mini/main.js +0 -21
- package/dist/experimental/mini/main.js.map +0 -1
- package/dist/experimental/mini/server/entry.d.ts +0 -3
- package/dist/experimental/mini/server/entry.d.ts.map +0 -1
- package/dist/experimental/mini/server/entry.js +0 -11
- package/dist/experimental/mini/server/entry.js.map +0 -1
- package/dist/experimental/mini/server/run.d.ts +0 -13
- package/dist/experimental/mini/server/run.d.ts.map +0 -1
- package/dist/experimental/mini/server/run.js +0 -150
- package/dist/experimental/mini/server/run.js.map +0 -1
- package/dist/experimental/mini/shared/protocol.d.ts +0 -127
- package/dist/experimental/mini/shared/protocol.d.ts.map +0 -1
- package/dist/experimental/mini/shared/protocol.js +0 -13
- package/dist/experimental/mini/shared/protocol.js.map +0 -1
- package/dist/experimental/mini/shared/rpc.d.ts +0 -49
- package/dist/experimental/mini/shared/rpc.d.ts.map +0 -1
- package/dist/experimental/mini/shared/rpc.js +0 -171
- package/dist/experimental/mini/shared/rpc.js.map +0 -1
- package/dist/experimental/mini/shared/transport.d.ts +0 -35
- package/dist/experimental/mini/shared/transport.d.ts.map +0 -1
- package/dist/experimental/mini/shared/transport.js +0 -94
- package/dist/experimental/mini/shared/transport.js.map +0 -1
- package/dist/experimental/mini/tui/run.d.ts +0 -9
- package/dist/experimental/mini/tui/run.d.ts.map +0 -1
- package/dist/experimental/mini/tui/run.js +0 -62
- package/dist/experimental/mini/tui/run.js.map +0 -1
- package/dist/experimental/mini/tui/session.d.ts +0 -26
- package/dist/experimental/mini/tui/session.d.ts.map +0 -1
- package/dist/experimental/mini/tui/session.js +0 -94
- package/dist/experimental/mini/tui/session.js.map +0 -1
- package/dist/experimental/mini/tui/view.d.ts +0 -10
- package/dist/experimental/mini/tui/view.d.ts.map +0 -1
- package/dist/experimental/mini/tui/view.js +0 -459
- package/dist/experimental/mini/tui/view.js.map +0 -1
- package/dist/experimental/mini/worker/entry.d.ts +0 -3
- package/dist/experimental/mini/worker/entry.d.ts.map +0 -1
- package/dist/experimental/mini/worker/entry.js +0 -10
- package/dist/experimental/mini/worker/entry.js.map +0 -1
- package/dist/experimental/mini/worker/lane-service.d.ts +0 -44
- package/dist/experimental/mini/worker/lane-service.d.ts.map +0 -1
- package/dist/experimental/mini/worker/lane-service.js +0 -97
- package/dist/experimental/mini/worker/lane-service.js.map +0 -1
- package/dist/experimental/mini/worker/models-service.d.ts +0 -19
- package/dist/experimental/mini/worker/models-service.d.ts.map +0 -1
- package/dist/experimental/mini/worker/models-service.js +0 -136
- package/dist/experimental/mini/worker/models-service.js.map +0 -1
- package/dist/experimental/mini/worker/run.d.ts +0 -14
- package/dist/experimental/mini/worker/run.d.ts.map +0 -1
- package/dist/experimental/mini/worker/run.js +0 -88
- package/dist/experimental/mini/worker/run.js.map +0 -1
- package/dist/experimental/plugin.d.ts +0 -4
- package/dist/experimental/plugin.d.ts.map +0 -1
- package/dist/experimental/plugin.js +0 -4
- package/dist/experimental/plugin.js.map +0 -1
- package/dist/experimental/plugins/bundled.d.ts +0 -7
- package/dist/experimental/plugins/bundled.d.ts.map +0 -1
- package/dist/experimental/plugins/bundled.js +0 -48
- package/dist/experimental/plugins/bundled.js.map +0 -1
- package/dist/experimental/plugins/package.d.ts +0 -18
- package/dist/experimental/plugins/package.d.ts.map +0 -1
- package/dist/experimental/plugins/package.js +0 -113
- package/dist/experimental/plugins/package.js.map +0 -1
- package/dist/experimental/process.d.ts +0 -20
- package/dist/experimental/process.d.ts.map +0 -1
- package/dist/experimental/process.js +0 -85
- package/dist/experimental/process.js.map +0 -1
- package/dist/experimental/radius-auth.d.ts +0 -17
- package/dist/experimental/radius-auth.d.ts.map +0 -1
- package/dist/experimental/radius-auth.js +0 -52
- package/dist/experimental/radius-auth.js.map +0 -1
- package/dist/experimental/radius-relay.d.ts +0 -90
- package/dist/experimental/radius-relay.d.ts.map +0 -1
- package/dist/experimental/radius-relay.js +0 -582
- package/dist/experimental/radius-relay.js.map +0 -1
- package/dist/experimental/server.d.ts +0 -75
- package/dist/experimental/server.d.ts.map +0 -1
- package/dist/experimental/server.js +0 -682
- package/dist/experimental/server.js.map +0 -1
- package/dist/experimental/services/agent-controller-provider.d.ts +0 -4
- package/dist/experimental/services/agent-controller-provider.d.ts.map +0 -1
- package/dist/experimental/services/agent-controller-provider.js +0 -84
- package/dist/experimental/services/agent-controller-provider.js.map +0 -1
- package/dist/experimental/services/agent-controller.d.ts +0 -57
- package/dist/experimental/services/agent-controller.d.ts.map +0 -1
- package/dist/experimental/services/agent-controller.js +0 -3
- package/dist/experimental/services/agent-controller.js.map +0 -1
- package/dist/experimental/services/connection.d.ts +0 -40
- package/dist/experimental/services/connection.d.ts.map +0 -1
- package/dist/experimental/services/connection.js +0 -300
- package/dist/experimental/services/connection.js.map +0 -1
- package/dist/experimental/services/models-provider.d.ts +0 -16
- package/dist/experimental/services/models-provider.d.ts.map +0 -1
- package/dist/experimental/services/models-provider.js +0 -116
- package/dist/experimental/services/models-provider.js.map +0 -1
- package/dist/experimental/services/models.d.ts +0 -36
- package/dist/experimental/services/models.d.ts.map +0 -1
- package/dist/experimental/services/models.js +0 -3
- package/dist/experimental/services/models.js.map +0 -1
- package/dist/experimental/services/plugins.d.ts +0 -16
- package/dist/experimental/services/plugins.d.ts.map +0 -1
- package/dist/experimental/services/plugins.js +0 -4
- package/dist/experimental/services/plugins.js.map +0 -1
- package/dist/experimental/services/presentation-ui.d.ts +0 -13
- package/dist/experimental/services/presentation-ui.d.ts.map +0 -1
- package/dist/experimental/services/presentation-ui.js +0 -3
- package/dist/experimental/services/presentation-ui.js.map +0 -1
- package/dist/experimental/services/server.d.ts +0 -19
- package/dist/experimental/services/server.d.ts.map +0 -1
- package/dist/experimental/services/server.js +0 -104
- package/dist/experimental/services/server.js.map +0 -1
- package/dist/experimental/services/sessions.d.ts +0 -28
- package/dist/experimental/services/sessions.d.ts.map +0 -1
- package/dist/experimental/services/sessions.js +0 -4
- package/dist/experimental/services/sessions.js.map +0 -1
- package/dist/experimental/services/slash-commands-provider.d.ts +0 -14
- package/dist/experimental/services/slash-commands-provider.d.ts.map +0 -1
- package/dist/experimental/services/slash-commands-provider.js +0 -200
- package/dist/experimental/services/slash-commands-provider.js.map +0 -1
- package/dist/experimental/services/slash-commands.d.ts +0 -24
- package/dist/experimental/services/slash-commands.d.ts.map +0 -1
- package/dist/experimental/services/slash-commands.js +0 -3
- package/dist/experimental/services/slash-commands.js.map +0 -1
- package/dist/experimental/services/transcript-provider.d.ts +0 -12
- package/dist/experimental/services/transcript-provider.d.ts.map +0 -1
- package/dist/experimental/services/transcript-provider.js +0 -109
- package/dist/experimental/services/transcript-provider.js.map +0 -1
- package/dist/experimental/services/transcript.d.ts +0 -13
- package/dist/experimental/services/transcript.d.ts.map +0 -1
- package/dist/experimental/services/transcript.js +0 -3
- package/dist/experimental/services/transcript.js.map +0 -1
- package/dist/experimental/services/worker.d.ts +0 -28
- package/dist/experimental/services/worker.d.ts.map +0 -1
- package/dist/experimental/services/worker.js +0 -107
- package/dist/experimental/services/worker.js.map +0 -1
- package/dist/experimental/session-worker-manager.d.ts +0 -24
- package/dist/experimental/session-worker-manager.d.ts.map +0 -1
- package/dist/experimental/session-worker-manager.js +0 -691
- package/dist/experimental/session-worker-manager.js.map +0 -1
- package/dist/experimental/session-worker.d.ts +0 -188
- package/dist/experimental/session-worker.d.ts.map +0 -1
- package/dist/experimental/session-worker.js +0 -785
- package/dist/experimental/session-worker.js.map +0 -1
- package/dist/experimental/source-resolver.d.ts +0 -2
- package/dist/experimental/source-resolver.d.ts.map +0 -1
- package/dist/experimental/source-resolver.js +0 -71
- package/dist/experimental/source-resolver.js.map +0 -1
- package/dist/utils/clipboard-native.d.ts +0 -11
- package/dist/utils/clipboard-native.d.ts.map +0 -1
- package/dist/utils/clipboard-native.js +0 -20
- package/dist/utils/clipboard-native.js.map +0 -1
- package/examples/extensions/kimi-deferred-tools.ts +0 -61
|
@@ -1,702 +0,0 @@
|
|
|
1
|
-
import { resolve } from "node:path";
|
|
2
|
-
import { combineFacetLoaders, createFacetHost, defineFacet, } from "@earendil-works/chord";
|
|
3
|
-
import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
|
|
4
|
-
import { CombinedAutocompleteProvider, Container, SelectList, setKeybindings, Text, } from "@earendil-works/pi-tui";
|
|
5
|
-
import { getAgentDir } from "../config.js";
|
|
6
|
-
import { KeybindingsManager } from "../core/keybindings.js";
|
|
7
|
-
import { DefaultResourceLoader } from "../core/resource-loader.js";
|
|
8
|
-
import { SettingsManager } from "../core/settings-manager.js";
|
|
9
|
-
import { createChatViewport } from "../modes/interactive/chat-viewport.js";
|
|
10
|
-
import { CustomEditor } from "../modes/interactive/components/custom-editor.js";
|
|
11
|
-
import { getEditorTheme, setRegisteredThemes, stopThemeWatcher, theme } from "../modes/interactive/theme/theme.js";
|
|
12
|
-
import { InteractiveThemeController } from "../modes/interactive/theme/theme-controller.js";
|
|
13
|
-
import { createInteractiveTui } from "../modes/interactive/tui-renderer.js";
|
|
14
|
-
import { openClientRuntime } from "./client-runtime.js";
|
|
15
|
-
import { ExperimentalChatView } from "./client-tui-chat.js";
|
|
16
|
-
import { createPresentationFacetLoaders } from "./plugins/bundled.js";
|
|
17
|
-
import { AgentController } from "./services/agent-controller.js";
|
|
18
|
-
import { PresentationPlugins } from "./services/plugins.js";
|
|
19
|
-
import { PresentationUI } from "./services/presentation-ui.js";
|
|
20
|
-
import { SessionDirectory, SessionManagement } from "./services/sessions.js";
|
|
21
|
-
import { SlashCommands } from "./services/slash-commands.js";
|
|
22
|
-
import { createBuiltInSlashCommandsFacet, createSlashCommandsRuntimeFacet, } from "./services/slash-commands-provider.js";
|
|
23
|
-
import { Transcript } from "./services/transcript.js";
|
|
24
|
-
const selectTheme = {
|
|
25
|
-
selectedPrefix: (text) => theme.fg("accent", text),
|
|
26
|
-
selectedText: (text) => theme.fg("accent", text),
|
|
27
|
-
description: (text) => theme.fg("muted", text),
|
|
28
|
-
scrollInfo: (text) => theme.fg("dim", text),
|
|
29
|
-
noMatch: (text) => theme.fg("warning", text),
|
|
30
|
-
};
|
|
31
|
-
/** Service-only presentation driven by a replicated main-lane snapshot. */
|
|
32
|
-
export class ExperimentalClientTui {
|
|
33
|
-
#ui;
|
|
34
|
-
#requestRender;
|
|
35
|
-
#finish;
|
|
36
|
-
#documentContainer = new Container();
|
|
37
|
-
#sessionHeading = new Text("", 1, 0);
|
|
38
|
-
#pendingMessagesContainer = new Container();
|
|
39
|
-
#statusContainer = new Container();
|
|
40
|
-
#editorContainer = new Container();
|
|
41
|
-
#footerComponent = new Text("", 1, 0);
|
|
42
|
-
#layoutRoot;
|
|
43
|
-
#sharedFacets;
|
|
44
|
-
#keybindings = KeybindingsManager.create();
|
|
45
|
-
#presentationFacets;
|
|
46
|
-
#facetHost;
|
|
47
|
-
#facetReloadTail = Promise.resolve();
|
|
48
|
-
#session;
|
|
49
|
-
#slashCommands;
|
|
50
|
-
#controller;
|
|
51
|
-
#chatInput;
|
|
52
|
-
#selectList;
|
|
53
|
-
#selection;
|
|
54
|
-
#screen = "chat";
|
|
55
|
-
#selectedServerId;
|
|
56
|
-
#sessionId;
|
|
57
|
-
#status = "Starting Session…";
|
|
58
|
-
#busy = false;
|
|
59
|
-
#closed = false;
|
|
60
|
-
#closePromise;
|
|
61
|
-
#recoveryTransition = Promise.resolve();
|
|
62
|
-
#laneUnsubscribe;
|
|
63
|
-
#chatView;
|
|
64
|
-
constructor(ui, requestRender, finish, loadedFacets) {
|
|
65
|
-
this.#ui = ui;
|
|
66
|
-
this.#requestRender = requestRender;
|
|
67
|
-
this.#finish = finish;
|
|
68
|
-
this.#sharedFacets = loadedFacets;
|
|
69
|
-
setKeybindings(this.#keybindings);
|
|
70
|
-
this.#chatInput = new CustomEditor(ui, getEditorTheme(), this.#keybindings, { paddingX: 1 });
|
|
71
|
-
this.#chatInput.onSubmit = (message) => void this.#runPrompt(message);
|
|
72
|
-
this.#chatInput.onEscape = () => this.#interrupt();
|
|
73
|
-
this.#chatInput.onCtrlD = finish;
|
|
74
|
-
this.#chatInput.onAction("app.clear", finish);
|
|
75
|
-
this.#chatInput.onAction("app.model.select", () => void this.#executeSlashCommand("model", ""));
|
|
76
|
-
this.#chatInput.onAction("app.message.followUp", () => {
|
|
77
|
-
const text = this.#chatInput.getText().trim();
|
|
78
|
-
if (text.length === 0)
|
|
79
|
-
return;
|
|
80
|
-
this.#chatInput.setText("");
|
|
81
|
-
void this.#queueFollowUp(text);
|
|
82
|
-
});
|
|
83
|
-
this.#editorContainer.addChild(this.#chatInput);
|
|
84
|
-
this.#layoutRoot = createChatViewport({
|
|
85
|
-
document: this.#documentContainer,
|
|
86
|
-
pendingMessages: this.#pendingMessagesContainer,
|
|
87
|
-
status: this.#statusContainer,
|
|
88
|
-
editor: this.#editorContainer,
|
|
89
|
-
footer: this.#footerComponent,
|
|
90
|
-
scrollbarTrackStyle: (text) => theme.fg("scrollbarTrack", text),
|
|
91
|
-
scrollbarThumbStyle: (text) => theme.fg("scrollbarThumb", text),
|
|
92
|
-
}).root;
|
|
93
|
-
this.#rebuild();
|
|
94
|
-
}
|
|
95
|
-
static async create(options) {
|
|
96
|
-
const prepared = await prepareClientSession(options.command, options.servers);
|
|
97
|
-
const loadedFacets = await combineFacetLoaders(options.facetLoader === undefined ? [] : [options.facetLoader]).load();
|
|
98
|
-
const component = new ExperimentalClientTui(options.ui, options.requestRender, options.finish, loadedFacets);
|
|
99
|
-
try {
|
|
100
|
-
await component.#start(prepared);
|
|
101
|
-
await component.#openPreparedSession(prepared);
|
|
102
|
-
return component;
|
|
103
|
-
}
|
|
104
|
-
catch (error) {
|
|
105
|
-
try {
|
|
106
|
-
await component.close();
|
|
107
|
-
}
|
|
108
|
-
catch (cleanupError) {
|
|
109
|
-
throw new AggregateError([error, cleanupError], "Experimental TUI startup and cleanup failed");
|
|
110
|
-
}
|
|
111
|
-
throw error;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
get layoutRoot() {
|
|
115
|
-
return this.#layoutRoot;
|
|
116
|
-
}
|
|
117
|
-
render(width) {
|
|
118
|
-
return [
|
|
119
|
-
...this.#documentContainer.render(width),
|
|
120
|
-
...this.#pendingMessagesContainer.render(width),
|
|
121
|
-
...this.#statusContainer.render(width),
|
|
122
|
-
...this.#editorContainer.render(width),
|
|
123
|
-
...this.#footerComponent.render(width),
|
|
124
|
-
];
|
|
125
|
-
}
|
|
126
|
-
handleInput(data) {
|
|
127
|
-
if (this.#busy) {
|
|
128
|
-
if (this.#keybindings.matches(data, "app.clear") ||
|
|
129
|
-
(this.#chatInput.getText().length === 0 && this.#keybindings.matches(data, "app.exit"))) {
|
|
130
|
-
this.#finish();
|
|
131
|
-
}
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
if (this.#screen === "chat") {
|
|
135
|
-
this.#chatInput.handleInput(data);
|
|
136
|
-
this.#requestRender();
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
this.#selectList?.handleInput(data);
|
|
140
|
-
}
|
|
141
|
-
invalidate() {
|
|
142
|
-
this.#layoutRoot.invalidate();
|
|
143
|
-
}
|
|
144
|
-
dispose() {
|
|
145
|
-
void this.close().catch(() => { });
|
|
146
|
-
}
|
|
147
|
-
refreshTheme() {
|
|
148
|
-
const snapshot = this.#laneSnapshot();
|
|
149
|
-
if (snapshot !== undefined)
|
|
150
|
-
this.#chatView?.refreshTheme(snapshot);
|
|
151
|
-
this.#rebuild();
|
|
152
|
-
}
|
|
153
|
-
showError(error) {
|
|
154
|
-
this.#status = `Error: ${error}`;
|
|
155
|
-
this.#rebuild();
|
|
156
|
-
}
|
|
157
|
-
close() {
|
|
158
|
-
this.#closePromise ??= this.#close();
|
|
159
|
-
return this.#closePromise;
|
|
160
|
-
}
|
|
161
|
-
async #start(prepared) {
|
|
162
|
-
const server = prepared.server;
|
|
163
|
-
let presentationFacets = await combineFacetLoaders(createPresentationFacetLoaders(prepared.presentationPlugins)).load();
|
|
164
|
-
this.#presentationFacets = presentationFacets;
|
|
165
|
-
let facetHost;
|
|
166
|
-
const reloadPresentationPlugins = (data) => {
|
|
167
|
-
const operation = this.#facetReloadTail.then(async () => {
|
|
168
|
-
const candidate = await combineFacetLoaders(createPresentationFacetLoaders(data)).load();
|
|
169
|
-
try {
|
|
170
|
-
await facetHost.reload(candidate.facets);
|
|
171
|
-
}
|
|
172
|
-
catch (error) {
|
|
173
|
-
try {
|
|
174
|
-
await candidate.dispose();
|
|
175
|
-
}
|
|
176
|
-
catch (cleanupError) {
|
|
177
|
-
throw new AggregateError([error, cleanupError], "TUI plugin reload and cleanup failed");
|
|
178
|
-
}
|
|
179
|
-
throw error;
|
|
180
|
-
}
|
|
181
|
-
const retired = presentationFacets;
|
|
182
|
-
presentationFacets = candidate;
|
|
183
|
-
this.#presentationFacets = candidate;
|
|
184
|
-
await retired.dispose();
|
|
185
|
-
});
|
|
186
|
-
this.#facetReloadTail = operation.catch(() => { });
|
|
187
|
-
return operation;
|
|
188
|
-
};
|
|
189
|
-
const presentationBridgeFacet = defineFacet({
|
|
190
|
-
id: "@pi/presentation-bridge",
|
|
191
|
-
setup: (env) => {
|
|
192
|
-
env.provide(PresentationUI, {
|
|
193
|
-
select: (title, items, selectedValue) => this.#select(title, items.map((item) => ({ ...item })), selectedValue),
|
|
194
|
-
showStatus: (status) => {
|
|
195
|
-
this.#status = status;
|
|
196
|
-
this.#rebuild();
|
|
197
|
-
},
|
|
198
|
-
});
|
|
199
|
-
const commands = env.use(SlashCommands);
|
|
200
|
-
const controller = env.use(AgentController);
|
|
201
|
-
const transcript = env.use(Transcript);
|
|
202
|
-
const sessionFeature = {
|
|
203
|
-
serverId: server.serverId,
|
|
204
|
-
session: server.session,
|
|
205
|
-
transcript,
|
|
206
|
-
};
|
|
207
|
-
env.onActivate(() => {
|
|
208
|
-
if (this.#session !== undefined || this.#slashCommands !== undefined || this.#controller !== undefined) {
|
|
209
|
-
throw new Error("Presentation services are already active");
|
|
210
|
-
}
|
|
211
|
-
this.#session = sessionFeature;
|
|
212
|
-
this.#slashCommands = commands;
|
|
213
|
-
this.#controller = controller;
|
|
214
|
-
env.own(() => {
|
|
215
|
-
if (this.#session === sessionFeature)
|
|
216
|
-
this.#session = undefined;
|
|
217
|
-
if (this.#slashCommands === commands)
|
|
218
|
-
this.#slashCommands = undefined;
|
|
219
|
-
if (this.#controller === controller)
|
|
220
|
-
this.#controller = undefined;
|
|
221
|
-
});
|
|
222
|
-
env.own(commands.subscribe(() => this.#updateAutocomplete()));
|
|
223
|
-
if (server.radius) {
|
|
224
|
-
env.own(server.server.connection.subscribe((state) => this.#handleConnectionState(server.serverId, state)));
|
|
225
|
-
env.own(server.session.attachment.subscribe((state) => this.#handleAttachmentState(sessionFeature, state)));
|
|
226
|
-
}
|
|
227
|
-
});
|
|
228
|
-
},
|
|
229
|
-
});
|
|
230
|
-
facetHost = await createFacetHost({
|
|
231
|
-
facets: [
|
|
232
|
-
createSlashCommandsRuntimeFacet(),
|
|
233
|
-
presentationBridgeFacet,
|
|
234
|
-
createBuiltInSlashCommandsFacet({ reloadPresentationPlugins }),
|
|
235
|
-
...this.#sharedFacets.facets,
|
|
236
|
-
...presentationFacets.facets,
|
|
237
|
-
],
|
|
238
|
-
serviceSources: [server.server, server.session],
|
|
239
|
-
});
|
|
240
|
-
this.#facetHost = facetHost;
|
|
241
|
-
}
|
|
242
|
-
async #openPreparedSession(prepared) {
|
|
243
|
-
const feature = this.#session;
|
|
244
|
-
if (feature === undefined)
|
|
245
|
-
throw new Error(`No Session service is available for ${prepared.server.serverId}`);
|
|
246
|
-
await feature.session.whenAttached(prepared.summary.sessionId, BACKGROUND_CONTEXT);
|
|
247
|
-
this.#selectedServerId = feature.serverId;
|
|
248
|
-
this.#sessionId = prepared.summary.sessionId;
|
|
249
|
-
this.#updateAutocomplete();
|
|
250
|
-
await this.#openLane(feature);
|
|
251
|
-
this.#screen = "chat";
|
|
252
|
-
this.#status = "";
|
|
253
|
-
this.#rebuild();
|
|
254
|
-
}
|
|
255
|
-
async #close() {
|
|
256
|
-
this.#closed = true;
|
|
257
|
-
this.#completeSelection(undefined);
|
|
258
|
-
const errors = [];
|
|
259
|
-
try {
|
|
260
|
-
await this.#recoveryTransition;
|
|
261
|
-
await this.#closeLane();
|
|
262
|
-
await this.#facetReloadTail;
|
|
263
|
-
}
|
|
264
|
-
catch (error) {
|
|
265
|
-
errors.push(error);
|
|
266
|
-
}
|
|
267
|
-
if (this.#facetHost !== undefined) {
|
|
268
|
-
try {
|
|
269
|
-
await this.#facetHost.dispose();
|
|
270
|
-
}
|
|
271
|
-
catch (error) {
|
|
272
|
-
errors.push(error);
|
|
273
|
-
}
|
|
274
|
-
this.#facetHost = undefined;
|
|
275
|
-
}
|
|
276
|
-
const generations = [this.#presentationFacets, this.#sharedFacets].filter((generation) => generation !== undefined);
|
|
277
|
-
this.#presentationFacets = undefined;
|
|
278
|
-
const results = await Promise.allSettled(generations.map((generation) => generation.dispose()));
|
|
279
|
-
errors.push(...results.flatMap((result) => (result.status === "rejected" ? [result.reason] : [])));
|
|
280
|
-
if (errors.length === 1)
|
|
281
|
-
throw errors[0];
|
|
282
|
-
if (errors.length > 1)
|
|
283
|
-
throw new AggregateError(errors, "Failed to dispose experimental TUI facets");
|
|
284
|
-
}
|
|
285
|
-
#rebuild() {
|
|
286
|
-
this.#sessionHeading.setText(this.#sessionId === undefined || this.#selectedServerId === undefined
|
|
287
|
-
? ""
|
|
288
|
-
: theme.fg("dim", `Server: ${this.#selectedServerId}\nSession: ${this.#sessionId}`));
|
|
289
|
-
this.#statusContainer.clear();
|
|
290
|
-
if (this.#status.length > 0) {
|
|
291
|
-
this.#statusContainer.addChild(new Text(theme.fg("dim", this.#status), 1, 0));
|
|
292
|
-
}
|
|
293
|
-
if (this.#chatView !== undefined)
|
|
294
|
-
this.#statusContainer.addChild(this.#chatView.status);
|
|
295
|
-
this.#footerComponent.setText(theme.fg("dim", this.#footer()));
|
|
296
|
-
this.#editorContainer.clear();
|
|
297
|
-
if (this.#screen === "select" && this.#selection !== undefined) {
|
|
298
|
-
this.#chatInput.focused = false;
|
|
299
|
-
const selector = new Container();
|
|
300
|
-
selector.addChild(new Text(theme.bold(this.#selection.title), 1, 1));
|
|
301
|
-
const items = [...this.#selection.items];
|
|
302
|
-
this.#selectList = new SelectList(items, Math.min(Math.max(items.length, 1), 12), selectTheme);
|
|
303
|
-
const selectedIndex = items.findIndex((item) => item.value === this.#selection?.selectedValue);
|
|
304
|
-
if (selectedIndex >= 0)
|
|
305
|
-
this.#selectList.setSelectedIndex(selectedIndex);
|
|
306
|
-
this.#selectList.onSelect = (item) => this.#completeSelection(item.value);
|
|
307
|
-
this.#selectList.onCancel = () => this.#completeSelection(undefined);
|
|
308
|
-
selector.addChild(this.#selectList);
|
|
309
|
-
this.#editorContainer.addChild(selector);
|
|
310
|
-
}
|
|
311
|
-
else {
|
|
312
|
-
this.#selectList = undefined;
|
|
313
|
-
this.#chatInput.focused = !this.#busy;
|
|
314
|
-
this.#editorContainer.addChild(this.#chatInput);
|
|
315
|
-
}
|
|
316
|
-
this.#layoutRoot.invalidate();
|
|
317
|
-
this.#requestRender();
|
|
318
|
-
}
|
|
319
|
-
#select(title, items, selectedValue) {
|
|
320
|
-
if (this.#selection !== undefined)
|
|
321
|
-
throw new Error("A slash command selector is already active");
|
|
322
|
-
return new Promise((resolve) => {
|
|
323
|
-
this.#selection = { title, items, ...(selectedValue === undefined ? {} : { selectedValue }), resolve };
|
|
324
|
-
this.#screen = "select";
|
|
325
|
-
this.#rebuild();
|
|
326
|
-
});
|
|
327
|
-
}
|
|
328
|
-
#completeSelection(value) {
|
|
329
|
-
const selection = this.#selection;
|
|
330
|
-
if (selection === undefined)
|
|
331
|
-
return;
|
|
332
|
-
this.#selection = undefined;
|
|
333
|
-
this.#screen = "chat";
|
|
334
|
-
selection.resolve(value);
|
|
335
|
-
if (!this.#closed)
|
|
336
|
-
this.#rebuild();
|
|
337
|
-
}
|
|
338
|
-
#updateAutocomplete() {
|
|
339
|
-
const commands = this.#selectedSlashCommands()?.list() ?? [];
|
|
340
|
-
this.#chatInput.setAutocompleteProvider(new CombinedAutocompleteProvider(commands.map((command) => ({
|
|
341
|
-
name: command.name,
|
|
342
|
-
description: command.description,
|
|
343
|
-
...(command.argumentHint === undefined ? {} : { argumentHint: command.argumentHint }),
|
|
344
|
-
...(command.getArgumentCompletions === undefined
|
|
345
|
-
? {}
|
|
346
|
-
: {
|
|
347
|
-
getArgumentCompletions: async (prefix) => {
|
|
348
|
-
const items = await command.getArgumentCompletions(prefix);
|
|
349
|
-
return items === null ? null : [...items];
|
|
350
|
-
},
|
|
351
|
-
}),
|
|
352
|
-
})), process.cwd()));
|
|
353
|
-
this.#requestRender();
|
|
354
|
-
}
|
|
355
|
-
#selectedSlashCommands() {
|
|
356
|
-
return this.#slashCommands;
|
|
357
|
-
}
|
|
358
|
-
#handleConnectionState(serverId, state) {
|
|
359
|
-
if (this.#closed || this.#selectedServerId !== serverId)
|
|
360
|
-
return;
|
|
361
|
-
if (state.status === "connected") {
|
|
362
|
-
if (this.#laneUnsubscribe === undefined) {
|
|
363
|
-
this.#busy = true;
|
|
364
|
-
this.#status = "Reattaching Session…";
|
|
365
|
-
this.#rebuild();
|
|
366
|
-
}
|
|
367
|
-
return;
|
|
368
|
-
}
|
|
369
|
-
this.#busy = true;
|
|
370
|
-
this.#status = state.status === "connecting" ? "Reconnecting to Radius…" : "Radius disconnected; retrying…";
|
|
371
|
-
this.#queueRecovery(() => this.#closeLane());
|
|
372
|
-
this.#rebuild();
|
|
373
|
-
}
|
|
374
|
-
#handleAttachmentState(feature, state) {
|
|
375
|
-
if (this.#closed || this.#selectedServerId !== feature.serverId || this.#sessionId === undefined)
|
|
376
|
-
return;
|
|
377
|
-
if (state.status === "attached" && state.sessionId === this.#sessionId) {
|
|
378
|
-
this.#queueRecovery(async () => {
|
|
379
|
-
if (this.#laneUnsubscribe === undefined)
|
|
380
|
-
await this.#openLane(feature);
|
|
381
|
-
this.#busy = false;
|
|
382
|
-
this.#status = "";
|
|
383
|
-
this.#rebuild();
|
|
384
|
-
});
|
|
385
|
-
return;
|
|
386
|
-
}
|
|
387
|
-
if (state.status === "attaching" && state.sessionId === this.#sessionId) {
|
|
388
|
-
this.#busy = true;
|
|
389
|
-
this.#status = "Reattaching Session…";
|
|
390
|
-
this.#rebuild();
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
#queueRecovery(operation) {
|
|
394
|
-
this.#recoveryTransition = this.#recoveryTransition
|
|
395
|
-
.then(async () => {
|
|
396
|
-
if (!this.#closed)
|
|
397
|
-
await operation();
|
|
398
|
-
})
|
|
399
|
-
.catch((error) => {
|
|
400
|
-
if (this.#closed)
|
|
401
|
-
return;
|
|
402
|
-
this.#busy = true;
|
|
403
|
-
this.#status = `Reconnect error: ${message(error)}`;
|
|
404
|
-
this.#rebuild();
|
|
405
|
-
});
|
|
406
|
-
}
|
|
407
|
-
async #openLane(feature) {
|
|
408
|
-
await this.#closeLane();
|
|
409
|
-
const view = new ExperimentalChatView(this.#ui, process.cwd());
|
|
410
|
-
this.#chatView = view;
|
|
411
|
-
this.#documentContainer.addChild(this.#sessionHeading);
|
|
412
|
-
this.#documentContainer.addChild(view.transcript);
|
|
413
|
-
this.#pendingMessagesContainer.addChild(view.pendingMessages);
|
|
414
|
-
this.#laneUnsubscribe = feature.transcript.state.subscribe((value) => {
|
|
415
|
-
if (value.snapshot === null)
|
|
416
|
-
return;
|
|
417
|
-
view.apply(value.snapshot);
|
|
418
|
-
this.#rebuild();
|
|
419
|
-
});
|
|
420
|
-
if (feature.transcript.state.value?.snapshot === null || feature.transcript.state.value?.snapshot === undefined) {
|
|
421
|
-
await this.#closeLane();
|
|
422
|
-
throw new Error("Transcript has no initialized snapshot");
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
async #closeLane() {
|
|
426
|
-
this.#laneUnsubscribe?.();
|
|
427
|
-
this.#laneUnsubscribe = undefined;
|
|
428
|
-
this.#chatView?.dispose();
|
|
429
|
-
this.#chatView = undefined;
|
|
430
|
-
this.#documentContainer.clear();
|
|
431
|
-
this.#pendingMessagesContainer.clear();
|
|
432
|
-
this.#statusContainer.clear();
|
|
433
|
-
}
|
|
434
|
-
async #runPrompt(messageText) {
|
|
435
|
-
const prompt = messageText.trim();
|
|
436
|
-
if (prompt.length === 0)
|
|
437
|
-
return;
|
|
438
|
-
if (prompt.startsWith("/")) {
|
|
439
|
-
const separator = prompt.indexOf(" ");
|
|
440
|
-
const name = prompt.slice(1, separator === -1 ? undefined : separator);
|
|
441
|
-
const args = separator === -1 ? "" : prompt.slice(separator + 1).trim();
|
|
442
|
-
await this.#executeSlashCommand(name, args);
|
|
443
|
-
return;
|
|
444
|
-
}
|
|
445
|
-
this.#chatInput.setText("");
|
|
446
|
-
try {
|
|
447
|
-
await this.#submitPrompt(prompt);
|
|
448
|
-
}
|
|
449
|
-
catch (error) {
|
|
450
|
-
this.#status = `Error: ${message(error)}`;
|
|
451
|
-
this.#rebuild();
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
async #executeSlashCommand(name, args) {
|
|
455
|
-
const command = this.#selectedSlashCommands()
|
|
456
|
-
?.list()
|
|
457
|
-
.find((candidate) => candidate.name === name);
|
|
458
|
-
this.#chatInput.setText("");
|
|
459
|
-
if (command === undefined) {
|
|
460
|
-
this.#status = `Unknown slash command: /${name}`;
|
|
461
|
-
this.#rebuild();
|
|
462
|
-
return;
|
|
463
|
-
}
|
|
464
|
-
try {
|
|
465
|
-
const result = await command.run(args, BACKGROUND_CONTEXT);
|
|
466
|
-
if (result !== undefined) {
|
|
467
|
-
if ("entryId" in result)
|
|
468
|
-
this.#reportQueue(result);
|
|
469
|
-
else
|
|
470
|
-
this.#reportOperation(result);
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
catch (error) {
|
|
474
|
-
this.#status = `Error: ${message(error)}`;
|
|
475
|
-
this.#rebuild();
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
async #submitPrompt(prompt) {
|
|
479
|
-
const controller = this.#selectedController();
|
|
480
|
-
if (controller === undefined)
|
|
481
|
-
throw new Error("No Session AgentController service is available");
|
|
482
|
-
const operation = this.#laneSnapshot()?.operation;
|
|
483
|
-
const running = operation !== null && operation !== undefined;
|
|
484
|
-
this.#status = running ? "Queueing steering message…" : "Running turn…";
|
|
485
|
-
this.#rebuild();
|
|
486
|
-
if (running)
|
|
487
|
-
this.#reportQueue(await controller.steer({ message: prompt, images: null }, BACKGROUND_CONTEXT));
|
|
488
|
-
else
|
|
489
|
-
this.#reportOperation(await controller.prompt({ message: prompt, images: null }, BACKGROUND_CONTEXT));
|
|
490
|
-
}
|
|
491
|
-
async #queueFollowUp(text) {
|
|
492
|
-
const controller = this.#selectedController();
|
|
493
|
-
if (controller === undefined)
|
|
494
|
-
return;
|
|
495
|
-
try {
|
|
496
|
-
this.#status = "Queueing follow-up…";
|
|
497
|
-
this.#rebuild();
|
|
498
|
-
this.#reportQueue(await controller.followUp({ message: text, images: null }, BACKGROUND_CONTEXT));
|
|
499
|
-
}
|
|
500
|
-
catch (error) {
|
|
501
|
-
this.#status = `Error: ${message(error)}`;
|
|
502
|
-
this.#rebuild();
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
#reportOperation(response) {
|
|
506
|
-
this.#status = response.accepted
|
|
507
|
-
? response.error === null
|
|
508
|
-
? ""
|
|
509
|
-
: `Operation failed: ${response.error.message}`
|
|
510
|
-
: `Operation rejected: ${response.error.message}`;
|
|
511
|
-
this.#rebuild();
|
|
512
|
-
}
|
|
513
|
-
#reportQueue(response) {
|
|
514
|
-
this.#status = response.accepted ? `Queued ${response.entryId}.` : `Message rejected: ${response.error.message}`;
|
|
515
|
-
this.#rebuild();
|
|
516
|
-
}
|
|
517
|
-
#interrupt() {
|
|
518
|
-
const operation = this.#laneSnapshot()?.operation;
|
|
519
|
-
const controller = this.#selectedController();
|
|
520
|
-
if (operation === null || operation === undefined || controller === undefined)
|
|
521
|
-
return;
|
|
522
|
-
this.#status = `Aborting ${operation.id}…`;
|
|
523
|
-
this.#rebuild();
|
|
524
|
-
void controller.requestAbort(operation.id, BACKGROUND_CONTEXT).catch((error) => {
|
|
525
|
-
this.#status = `Error: ${message(error)}`;
|
|
526
|
-
this.#rebuild();
|
|
527
|
-
});
|
|
528
|
-
}
|
|
529
|
-
#selectedController() {
|
|
530
|
-
return this.#controller;
|
|
531
|
-
}
|
|
532
|
-
#laneSnapshot() {
|
|
533
|
-
const snapshot = this.#session?.transcript.state.value?.snapshot;
|
|
534
|
-
return snapshot === null ? undefined : snapshot;
|
|
535
|
-
}
|
|
536
|
-
#footer() {
|
|
537
|
-
const snapshot = this.#laneSnapshot();
|
|
538
|
-
if (!snapshot)
|
|
539
|
-
return "/model · /thinking · /compact · /reload";
|
|
540
|
-
return `${snapshot.configuration.model.provider}/${snapshot.configuration.model.modelId} · thinking:${snapshot.configuration.thinkingLevel} · ${snapshot.stats.messageCount} messages · /model · /thinking · /compact · /reload`;
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
async function prepareClientSession(command, servers) {
|
|
544
|
-
const opened = servers.map((server) => ({
|
|
545
|
-
server,
|
|
546
|
-
services: server.server.open({
|
|
547
|
-
services: [SessionDirectory, SessionManagement, PresentationPlugins],
|
|
548
|
-
assertAccess() { },
|
|
549
|
-
onError() { },
|
|
550
|
-
}),
|
|
551
|
-
}));
|
|
552
|
-
try {
|
|
553
|
-
const features = opened.map(({ server, services }) => ({
|
|
554
|
-
server,
|
|
555
|
-
directory: services.use(SessionDirectory),
|
|
556
|
-
management: services.use(SessionManagement),
|
|
557
|
-
plugins: services.use(PresentationPlugins),
|
|
558
|
-
}));
|
|
559
|
-
await Promise.all(opened.map(({ services }) => services.ready(BACKGROUND_CONTEXT)));
|
|
560
|
-
let selected;
|
|
561
|
-
if (command.sessionId !== undefined) {
|
|
562
|
-
const matches = features.flatMap((feature) => (feature.directory.state.value?.sessions ?? [])
|
|
563
|
-
.filter((session) => session.sessionId === command.sessionId)
|
|
564
|
-
.map((summary) => ({
|
|
565
|
-
server: feature.server,
|
|
566
|
-
management: feature.management,
|
|
567
|
-
plugins: feature.plugins,
|
|
568
|
-
summary,
|
|
569
|
-
})));
|
|
570
|
-
if (matches.length > 1)
|
|
571
|
-
throw new Error(`Session ${command.sessionId} is available from more than one server`);
|
|
572
|
-
selected = matches[0];
|
|
573
|
-
if (selected === undefined) {
|
|
574
|
-
if (command.connect?.transport === "radius") {
|
|
575
|
-
throw new Error(`Remote server does not contain Session ${command.sessionId}`);
|
|
576
|
-
}
|
|
577
|
-
const feature = requireSingleServer(features);
|
|
578
|
-
selected = {
|
|
579
|
-
server: feature.server,
|
|
580
|
-
management: feature.management,
|
|
581
|
-
plugins: feature.plugins,
|
|
582
|
-
summary: await feature.management.create({ id: command.sessionId }, BACKGROUND_CONTEXT),
|
|
583
|
-
};
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
else if (command.continue === true || command.resume === true) {
|
|
587
|
-
selected = features
|
|
588
|
-
.flatMap((feature) => (feature.directory.state.value?.sessions ?? []).map((summary) => ({
|
|
589
|
-
server: feature.server,
|
|
590
|
-
management: feature.management,
|
|
591
|
-
plugins: feature.plugins,
|
|
592
|
-
summary,
|
|
593
|
-
})))
|
|
594
|
-
.sort((left, right) => right.summary.createdAt - left.summary.createdAt ||
|
|
595
|
-
left.summary.serverId.localeCompare(right.summary.serverId) ||
|
|
596
|
-
left.summary.sessionId.localeCompare(right.summary.sessionId))[0];
|
|
597
|
-
}
|
|
598
|
-
if (selected === undefined) {
|
|
599
|
-
const feature = requireSingleServer(features);
|
|
600
|
-
selected = {
|
|
601
|
-
server: feature.server,
|
|
602
|
-
management: feature.management,
|
|
603
|
-
plugins: feature.plugins,
|
|
604
|
-
summary: await feature.management.create({}, BACKGROUND_CONTEXT),
|
|
605
|
-
};
|
|
606
|
-
}
|
|
607
|
-
const presentationPlugins = await selected.plugins.prepareSession({
|
|
608
|
-
sessionId: selected.summary.sessionId,
|
|
609
|
-
packagePaths: command.pluginPackages?.map((packagePath) => resolve(packagePath)) ?? null,
|
|
610
|
-
}, BACKGROUND_CONTEXT);
|
|
611
|
-
await selected.management.attach(selected.summary.sessionId, BACKGROUND_CONTEXT);
|
|
612
|
-
await selected.server.session.whenAttached(selected.summary.sessionId, BACKGROUND_CONTEXT);
|
|
613
|
-
return {
|
|
614
|
-
server: selected.server,
|
|
615
|
-
summary: selected.summary,
|
|
616
|
-
presentationPlugins,
|
|
617
|
-
};
|
|
618
|
-
}
|
|
619
|
-
finally {
|
|
620
|
-
await Promise.allSettled(opened.map(({ services }) => services.dispose(BACKGROUND_CONTEXT)));
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
export async function runClientTui(command, options = {}) {
|
|
624
|
-
const cwd = process.cwd();
|
|
625
|
-
const agentDir = getAgentDir();
|
|
626
|
-
const settingsManager = SettingsManager.create(cwd, agentDir);
|
|
627
|
-
const resourceLoader = new DefaultResourceLoader({
|
|
628
|
-
cwd,
|
|
629
|
-
agentDir,
|
|
630
|
-
settingsManager,
|
|
631
|
-
noExtensions: true,
|
|
632
|
-
noSkills: true,
|
|
633
|
-
noPromptTemplates: true,
|
|
634
|
-
noContextFiles: true,
|
|
635
|
-
});
|
|
636
|
-
await resourceLoader.reload();
|
|
637
|
-
setRegisteredThemes(resourceLoader.getThemes().themes);
|
|
638
|
-
const runtime = await openClientRuntime(command, options);
|
|
639
|
-
const tui = createInteractiveTui({
|
|
640
|
-
tuiMode: "fullscreen",
|
|
641
|
-
showHardwareCursor: settingsManager.getShowHardwareCursor(),
|
|
642
|
-
logDirectory: agentDir,
|
|
643
|
-
});
|
|
644
|
-
tui.setClearOnShrink(settingsManager.getClearOnShrink());
|
|
645
|
-
let component;
|
|
646
|
-
let tuiStarted = false;
|
|
647
|
-
const themeController = new InteractiveThemeController(tui, {
|
|
648
|
-
getSettingsManager: () => settingsManager,
|
|
649
|
-
showError: (error) => component?.showError(error),
|
|
650
|
-
onChanged: () => component?.refreshTheme(),
|
|
651
|
-
});
|
|
652
|
-
try {
|
|
653
|
-
let finish;
|
|
654
|
-
const finished = new Promise((resolve) => {
|
|
655
|
-
finish = () => {
|
|
656
|
-
themeController.disableAutoSync();
|
|
657
|
-
if (tuiStarted) {
|
|
658
|
-
tui.stop();
|
|
659
|
-
tuiStarted = false;
|
|
660
|
-
}
|
|
661
|
-
resolve();
|
|
662
|
-
};
|
|
663
|
-
});
|
|
664
|
-
component = await ExperimentalClientTui.create({
|
|
665
|
-
command,
|
|
666
|
-
ui: tui,
|
|
667
|
-
servers: runtime.servers.map((server) => ({
|
|
668
|
-
serverId: server.route.serverId,
|
|
669
|
-
radius: server.route.transport === "radius",
|
|
670
|
-
server: server.server,
|
|
671
|
-
session: server.session,
|
|
672
|
-
})),
|
|
673
|
-
facetLoader: options.facetLoader,
|
|
674
|
-
requestRender: () => tui.requestRender(),
|
|
675
|
-
finish,
|
|
676
|
-
});
|
|
677
|
-
tui.addChild(component);
|
|
678
|
-
tui.setLayoutRoot(component.layoutRoot);
|
|
679
|
-
tui.setFocus(component);
|
|
680
|
-
tuiStarted = true;
|
|
681
|
-
tui.start();
|
|
682
|
-
await themeController.applyFromSettings();
|
|
683
|
-
await finished;
|
|
684
|
-
}
|
|
685
|
-
finally {
|
|
686
|
-
themeController.dispose();
|
|
687
|
-
stopThemeWatcher();
|
|
688
|
-
if (tuiStarted)
|
|
689
|
-
tui.stop();
|
|
690
|
-
await component?.close();
|
|
691
|
-
await runtime.dispose();
|
|
692
|
-
}
|
|
693
|
-
}
|
|
694
|
-
function requireSingleServer(features) {
|
|
695
|
-
if (features.length !== 1)
|
|
696
|
-
throw new Error("Starting a Session requires exactly one server");
|
|
697
|
-
return features[0];
|
|
698
|
-
}
|
|
699
|
-
function message(error) {
|
|
700
|
-
return error instanceof Error ? error.message : String(error);
|
|
701
|
-
}
|
|
702
|
-
//# sourceMappingURL=client-tui.js.map
|