@earendil-works/pi-coding-agent 0.84.4 → 0.85.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 +57 -5
- package/README.md +3 -1
- package/dist/bun/cli.d.ts.map +1 -1
- package/dist/bun/cli.js +10 -7
- package/dist/bun/cli.js.map +1 -1
- package/dist/bun/runtime-setup.d.ts +2 -0
- package/dist/bun/runtime-setup.d.ts.map +1 -0
- package/dist/bun/runtime-setup.js +9 -0
- package/dist/bun/runtime-setup.js.map +1 -0
- package/dist/bundle/chunks/anthropic-messages-QAQLEQIY.js +6 -0
- package/dist/bundle/chunks/{azure-openai-responses-5ENVCQ7U.js → azure-openai-responses-Q7MJBRE6.js} +1 -1
- package/dist/bundle/chunks/bedrock-converse-stream.js +1 -1
- package/dist/bundle/chunks/chunk-7ZC4UXSL.js +2 -0
- package/dist/bundle/chunks/chunk-EQ6DR6XK.js +5 -0
- package/dist/bundle/chunks/{chunk-MNAIPA3J.js → chunk-IDDQWTHI.js} +1 -1
- package/dist/bundle/chunks/chunk-LZKJTKCT.js +2 -0
- package/dist/bundle/chunks/{chunk-NBBFIJUL.js → chunk-OUXLLA64.js} +2 -2
- package/dist/bundle/chunks/chunk-R7UUJ4C2.js +42 -0
- package/dist/bundle/chunks/chunk-USJZMAIR.js +2 -0
- package/dist/bundle/chunks/chunk-WBE4J4AU.js +9 -0
- package/dist/bundle/chunks/chunk-WZB2R5YO.js +1558 -0
- package/dist/bundle/chunks/github-copilot.js +1 -1
- package/dist/bundle/chunks/{google-generative-ai-YMUPJBKR.js → google-generative-ai-BSMTYDAM.js} +1 -1
- package/dist/bundle/chunks/{google-vertex-MPWMV4OF.js → google-vertex-5C3HASOJ.js} +1 -1
- package/dist/bundle/chunks/image-resize-worker.js +1 -1
- package/dist/bundle/chunks/{mistral-conversations-Q3AWZJAZ.js → mistral-conversations-4M6BZBX6.js} +1 -1
- package/dist/bundle/chunks/node-EM5FIVUN.js +16 -0
- package/dist/bundle/chunks/node-TWVVAGPO.js +2 -0
- package/dist/bundle/chunks/openai-codex-responses-YJOO52RW.js +10 -0
- package/dist/bundle/chunks/{openai-completions-ERMU2SS7.js → openai-completions-QOT3QX7D.js} +3 -3
- package/dist/bundle/chunks/openai-responses-U7LNPQN4.js +2 -0
- package/dist/bundle/chunks/{pi-messages-TPFH44NP.js → pi-messages-EGZIFQGG.js} +1 -1
- package/dist/bundle/cli.js +1 -1
- package/dist/bundle/client.js +1 -1
- package/dist/bundle/coordinator.js +3 -0
- 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 +2 -0
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/config-selector.d.ts.map +1 -1
- package/dist/cli/config-selector.js +2 -1
- package/dist/cli/config-selector.js.map +1 -1
- package/dist/cli/experimental/cli.d.ts +7 -3
- package/dist/cli/experimental/cli.d.ts.map +1 -1
- package/dist/cli/experimental/cli.js +6 -2
- package/dist/cli/experimental/cli.js.map +1 -1
- package/dist/cli/experimental/command-options.d.ts +23 -12
- package/dist/cli/experimental/command-options.d.ts.map +1 -1
- package/dist/cli/experimental/command-options.js +69 -20
- package/dist/cli/experimental/command-options.js.map +1 -1
- package/dist/cli/experimental/command.d.ts +10 -3
- package/dist/cli/experimental/command.d.ts.map +1 -1
- package/dist/cli/experimental/command.js +28 -14
- package/dist/cli/experimental/command.js.map +1 -1
- package/dist/cli/experimental/commands/client.d.ts +8 -2
- package/dist/cli/experimental/commands/client.d.ts.map +1 -1
- package/dist/cli/experimental/commands/client.js +43 -5
- package/dist/cli/experimental/commands/client.js.map +1 -1
- package/dist/cli/experimental/commands/server.d.ts +7 -3
- package/dist/cli/experimental/commands/server.d.ts.map +1 -1
- package/dist/cli/experimental/commands/server.js +27 -8
- package/dist/cli/experimental/commands/server.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +23 -14
- package/dist/cli.js.map +1 -1
- package/dist/client/index.d.ts +1 -2
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +1 -2
- package/dist/client/index.js.map +1 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -0
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +15 -7
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session.d.ts +2 -6
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +14 -6
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts +1 -1
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +2 -1
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +1 -2
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/types.d.ts +8 -2
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/http-dispatcher.d.ts.map +1 -1
- package/dist/core/http-dispatcher.js +2 -0
- package/dist/core/http-dispatcher.js.map +1 -1
- package/dist/core/messages.d.ts +1 -1
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js.map +1 -1
- package/dist/core/model-config.d.ts +15 -0
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +3 -0
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-runtime.d.ts +1 -0
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +5 -2
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +8 -2
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/session-manager.d.ts +3 -2
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +40 -13
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/skills.d.ts +1 -1
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +4 -2
- package/dist/core/skills.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +8 -9
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +3 -117
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit.d.ts +1 -12
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +5 -163
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +4 -55
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +4 -60
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/ls.d.ts.map +1 -1
- package/dist/core/tools/ls.js +4 -49
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +4 -120
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/renderers/bash.d.ts +12 -0
- package/dist/core/tools/renderers/bash.d.ts.map +1 -0
- package/dist/core/tools/renderers/bash.js +130 -0
- package/dist/core/tools/renderers/bash.js.map +1 -0
- package/dist/core/tools/renderers/edit.d.ts +23 -0
- package/dist/core/tools/renderers/edit.d.ts.map +1 -0
- package/dist/core/tools/renderers/edit.js +167 -0
- package/dist/core/tools/renderers/edit.js.map +1 -0
- package/dist/core/tools/renderers/find.d.ts +10 -0
- package/dist/core/tools/renderers/find.d.ts.map +1 -0
- package/dist/core/tools/renderers/find.js +64 -0
- package/dist/core/tools/renderers/find.js.map +1 -0
- package/dist/core/tools/renderers/grep.d.ts +10 -0
- package/dist/core/tools/renderers/grep.d.ts.map +1 -0
- package/dist/core/tools/renderers/grep.js +69 -0
- package/dist/core/tools/renderers/grep.js.map +1 -0
- package/dist/core/tools/renderers/index.d.ts +28 -0
- package/dist/core/tools/renderers/index.d.ts.map +1 -0
- package/dist/core/tools/renderers/index.js +47 -0
- package/dist/core/tools/renderers/index.js.map +1 -0
- package/dist/core/tools/renderers/ls.d.ts +10 -0
- package/dist/core/tools/renderers/ls.d.ts.map +1 -0
- package/dist/core/tools/renderers/ls.js +58 -0
- package/dist/core/tools/renderers/ls.js.map +1 -0
- package/dist/core/tools/renderers/read.d.ts +11 -0
- package/dist/core/tools/renderers/read.d.ts.map +1 -0
- package/dist/core/tools/renderers/read.js +129 -0
- package/dist/core/tools/renderers/read.js.map +1 -0
- package/dist/core/tools/renderers/write.d.ts +10 -0
- package/dist/core/tools/renderers/write.d.ts.map +1 -0
- package/dist/core/tools/renderers/write.js +153 -0
- package/dist/core/tools/renderers/write.js.map +1 -0
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +5 -146
- package/dist/core/tools/write.js.map +1 -1
- package/dist/experimental/client-runtime.d.ts +43 -0
- package/dist/experimental/client-runtime.d.ts.map +1 -0
- package/dist/experimental/client-runtime.js +183 -0
- package/dist/experimental/client-runtime.js.map +1 -0
- package/dist/experimental/client-tui-chat.d.ts +14 -0
- package/dist/experimental/client-tui-chat.d.ts.map +1 -0
- package/dist/experimental/client-tui-chat.js +171 -0
- package/dist/experimental/client-tui-chat.js.map +1 -0
- package/dist/experimental/client-tui.d.ts +37 -0
- package/dist/experimental/client-tui.d.ts.map +1 -0
- package/dist/experimental/client-tui.js +702 -0
- package/dist/experimental/client-tui.js.map +1 -0
- package/dist/experimental/client.d.ts +25 -0
- package/dist/experimental/client.d.ts.map +1 -0
- package/dist/experimental/client.js +99 -0
- package/dist/experimental/client.js.map +1 -0
- package/dist/experimental/coordinator-entry.d.ts +3 -0
- package/dist/experimental/coordinator-entry.d.ts.map +1 -0
- package/dist/experimental/coordinator-entry.js +11 -0
- package/dist/experimental/coordinator-entry.js.map +1 -0
- package/dist/experimental/coordinator.d.ts +38 -0
- package/dist/experimental/coordinator.d.ts.map +1 -0
- package/dist/experimental/coordinator.js +570 -0
- package/dist/experimental/coordinator.js.map +1 -0
- package/dist/experimental/mini/main.d.ts +7 -0
- package/dist/experimental/mini/main.d.ts.map +1 -0
- package/dist/experimental/mini/main.js +21 -0
- package/dist/experimental/mini/main.js.map +1 -0
- package/dist/experimental/mini/server/entry.d.ts +3 -0
- package/dist/experimental/mini/server/entry.d.ts.map +1 -0
- package/dist/experimental/mini/server/entry.js +11 -0
- package/dist/experimental/mini/server/entry.js.map +1 -0
- package/dist/experimental/mini/server/run.d.ts +13 -0
- package/dist/experimental/mini/server/run.d.ts.map +1 -0
- package/dist/experimental/mini/server/run.js +150 -0
- package/dist/experimental/mini/server/run.js.map +1 -0
- package/dist/experimental/mini/shared/protocol.d.ts +127 -0
- package/dist/experimental/mini/shared/protocol.d.ts.map +1 -0
- package/dist/experimental/mini/shared/protocol.js +13 -0
- package/dist/experimental/mini/shared/protocol.js.map +1 -0
- package/dist/experimental/mini/shared/rpc.d.ts +49 -0
- package/dist/experimental/mini/shared/rpc.d.ts.map +1 -0
- package/dist/experimental/mini/shared/rpc.js +171 -0
- package/dist/experimental/mini/shared/rpc.js.map +1 -0
- package/dist/experimental/mini/shared/transport.d.ts +35 -0
- package/dist/experimental/mini/shared/transport.d.ts.map +1 -0
- package/dist/experimental/mini/shared/transport.js +94 -0
- package/dist/experimental/mini/shared/transport.js.map +1 -0
- package/dist/experimental/mini/tui/run.d.ts +9 -0
- package/dist/experimental/mini/tui/run.d.ts.map +1 -0
- package/dist/experimental/mini/tui/run.js +62 -0
- package/dist/experimental/mini/tui/run.js.map +1 -0
- package/dist/experimental/mini/tui/session.d.ts +26 -0
- package/dist/experimental/mini/tui/session.d.ts.map +1 -0
- package/dist/experimental/mini/tui/session.js +94 -0
- package/dist/experimental/mini/tui/session.js.map +1 -0
- package/dist/experimental/mini/tui/view.d.ts +10 -0
- package/dist/experimental/mini/tui/view.d.ts.map +1 -0
- package/dist/experimental/mini/tui/view.js +459 -0
- package/dist/experimental/mini/tui/view.js.map +1 -0
- package/dist/experimental/mini/worker/entry.d.ts +3 -0
- package/dist/experimental/mini/worker/entry.d.ts.map +1 -0
- package/dist/experimental/mini/worker/entry.js +10 -0
- package/dist/experimental/mini/worker/entry.js.map +1 -0
- package/dist/experimental/mini/worker/lane-service.d.ts +44 -0
- package/dist/experimental/mini/worker/lane-service.d.ts.map +1 -0
- package/dist/experimental/mini/worker/lane-service.js +97 -0
- package/dist/experimental/mini/worker/lane-service.js.map +1 -0
- package/dist/experimental/mini/worker/models-service.d.ts +19 -0
- package/dist/experimental/mini/worker/models-service.d.ts.map +1 -0
- package/dist/experimental/mini/worker/models-service.js +136 -0
- package/dist/experimental/mini/worker/models-service.js.map +1 -0
- package/dist/experimental/mini/worker/run.d.ts +14 -0
- package/dist/experimental/mini/worker/run.d.ts.map +1 -0
- package/dist/experimental/mini/worker/run.js +88 -0
- package/dist/experimental/mini/worker/run.js.map +1 -0
- package/dist/experimental/plugin.d.ts +4 -0
- package/dist/experimental/plugin.d.ts.map +1 -0
- package/dist/experimental/plugin.js +4 -0
- package/dist/experimental/plugin.js.map +1 -0
- package/dist/experimental/plugins/bundled.d.ts +7 -0
- package/dist/experimental/plugins/bundled.d.ts.map +1 -0
- package/dist/experimental/plugins/bundled.js +48 -0
- package/dist/experimental/plugins/bundled.js.map +1 -0
- package/dist/experimental/plugins/package.d.ts +18 -0
- package/dist/experimental/plugins/package.d.ts.map +1 -0
- package/dist/experimental/plugins/package.js +113 -0
- package/dist/experimental/plugins/package.js.map +1 -0
- package/dist/experimental/process.d.ts +20 -0
- package/dist/experimental/process.d.ts.map +1 -0
- package/dist/experimental/process.js +85 -0
- package/dist/experimental/process.js.map +1 -0
- package/dist/experimental/radius-auth.d.ts +17 -0
- package/dist/experimental/radius-auth.d.ts.map +1 -0
- package/dist/experimental/radius-auth.js +52 -0
- package/dist/experimental/radius-auth.js.map +1 -0
- package/dist/experimental/radius-relay.d.ts +90 -0
- package/dist/experimental/radius-relay.d.ts.map +1 -0
- package/dist/experimental/radius-relay.js +582 -0
- package/dist/experimental/radius-relay.js.map +1 -0
- package/dist/experimental/server.d.ts +75 -0
- package/dist/experimental/server.d.ts.map +1 -0
- package/dist/experimental/server.js +682 -0
- package/dist/experimental/server.js.map +1 -0
- package/dist/experimental/services/agent-controller-provider.d.ts +4 -0
- package/dist/experimental/services/agent-controller-provider.d.ts.map +1 -0
- package/dist/experimental/services/agent-controller-provider.js +84 -0
- package/dist/experimental/services/agent-controller-provider.js.map +1 -0
- package/dist/experimental/services/agent-controller.d.ts +57 -0
- package/dist/experimental/services/agent-controller.d.ts.map +1 -0
- package/dist/experimental/services/agent-controller.js +3 -0
- package/dist/experimental/services/agent-controller.js.map +1 -0
- package/dist/experimental/services/connection.d.ts +40 -0
- package/dist/experimental/services/connection.d.ts.map +1 -0
- package/dist/experimental/services/connection.js +300 -0
- package/dist/experimental/services/connection.js.map +1 -0
- package/dist/experimental/services/models-provider.d.ts +16 -0
- package/dist/experimental/services/models-provider.d.ts.map +1 -0
- package/dist/experimental/services/models-provider.js +116 -0
- package/dist/experimental/services/models-provider.js.map +1 -0
- package/dist/experimental/services/models.d.ts +36 -0
- package/dist/experimental/services/models.d.ts.map +1 -0
- package/dist/experimental/services/models.js +3 -0
- package/dist/experimental/services/models.js.map +1 -0
- package/dist/experimental/services/plugins.d.ts +16 -0
- package/dist/experimental/services/plugins.d.ts.map +1 -0
- package/dist/experimental/services/plugins.js +4 -0
- package/dist/experimental/services/plugins.js.map +1 -0
- package/dist/experimental/services/presentation-ui.d.ts +13 -0
- package/dist/experimental/services/presentation-ui.d.ts.map +1 -0
- package/dist/experimental/services/presentation-ui.js +3 -0
- package/dist/experimental/services/presentation-ui.js.map +1 -0
- package/dist/experimental/services/server.d.ts +19 -0
- package/dist/experimental/services/server.d.ts.map +1 -0
- package/dist/experimental/services/server.js +104 -0
- package/dist/experimental/services/server.js.map +1 -0
- package/dist/experimental/services/sessions.d.ts +28 -0
- package/dist/experimental/services/sessions.d.ts.map +1 -0
- package/dist/experimental/services/sessions.js +4 -0
- package/dist/experimental/services/sessions.js.map +1 -0
- package/dist/experimental/services/slash-commands-provider.d.ts +14 -0
- package/dist/experimental/services/slash-commands-provider.d.ts.map +1 -0
- package/dist/experimental/services/slash-commands-provider.js +200 -0
- package/dist/experimental/services/slash-commands-provider.js.map +1 -0
- package/dist/experimental/services/slash-commands.d.ts +24 -0
- package/dist/experimental/services/slash-commands.d.ts.map +1 -0
- package/dist/experimental/services/slash-commands.js +3 -0
- package/dist/experimental/services/slash-commands.js.map +1 -0
- package/dist/experimental/services/transcript-provider.d.ts +12 -0
- package/dist/experimental/services/transcript-provider.d.ts.map +1 -0
- package/dist/experimental/services/transcript-provider.js +109 -0
- package/dist/experimental/services/transcript-provider.js.map +1 -0
- package/dist/experimental/services/transcript.d.ts +13 -0
- package/dist/experimental/services/transcript.d.ts.map +1 -0
- package/dist/experimental/services/transcript.js +3 -0
- package/dist/experimental/services/transcript.js.map +1 -0
- package/dist/experimental/services/worker.d.ts +28 -0
- package/dist/experimental/services/worker.d.ts.map +1 -0
- package/dist/experimental/services/worker.js +107 -0
- package/dist/experimental/services/worker.js.map +1 -0
- package/dist/experimental/session-worker-manager.d.ts +24 -0
- package/dist/experimental/session-worker-manager.d.ts.map +1 -0
- package/dist/experimental/session-worker-manager.js +691 -0
- package/dist/experimental/session-worker-manager.js.map +1 -0
- package/dist/experimental/session-worker.d.ts +188 -0
- package/dist/experimental/session-worker.d.ts.map +1 -0
- package/dist/experimental/session-worker.js +785 -0
- package/dist/experimental/session-worker.js.map +1 -0
- package/dist/experimental/source-resolver.d.ts +2 -0
- package/dist/experimental/source-resolver.d.ts.map +1 -0
- package/dist/experimental/source-resolver.js +71 -0
- package/dist/experimental/source-resolver.js.map +1 -0
- package/dist/index.d.ts +1 -1
- 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 +126 -1
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/chat-viewport.d.ts +20 -0
- package/dist/modes/interactive/chat-viewport.d.ts.map +1 -0
- package/dist/modes/interactive/chat-viewport.js +28 -0
- package/dist/modes/interactive/chat-viewport.js.map +1 -0
- package/dist/modes/interactive/components/assistant-message.d.ts +1 -0
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +18 -10
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +10 -1
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +39 -1
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/index.d.ts +1 -1
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/index.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 -14
- 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 +13 -15
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +14 -10
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/status-indicator.d.ts +3 -1
- package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
- package/dist/modes/interactive/components/status-indicator.js +10 -3
- 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 +2 -2
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +21 -4
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +35 -33
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/trust-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/trust-selector.js +2 -2
- package/dist/modes/interactive/components/trust-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +8 -15
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +95 -80
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/session-share.d.ts.map +1 -1
- package/dist/modes/interactive/session-share.js +8 -12
- package/dist/modes/interactive/session-share.js.map +1 -1
- package/dist/modes/interactive/theme/dark.json +2 -1
- package/dist/modes/interactive/theme/light.json +2 -1
- package/dist/modes/interactive/theme/theme-controller.d.ts +1 -0
- package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-controller.js +5 -0
- package/dist/modes/interactive/theme/theme-controller.js.map +1 -1
- package/dist/modes/interactive/theme/theme-json.d.ts +84 -0
- package/dist/modes/interactive/theme/theme-json.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme-json.js +130 -0
- package/dist/modes/interactive/theme/theme-json.js.map +1 -0
- package/dist/modes/interactive/theme/theme-schema.json +6 -2
- package/dist/modes/interactive/theme/theme.d.ts +14 -5
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +18 -119
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/interactive/tui-renderer.d.ts +21 -0
- package/dist/modes/interactive/tui-renderer.d.ts.map +1 -0
- package/dist/modes/interactive/tui-renderer.js +66 -0
- package/dist/modes/interactive/tui-renderer.js.map +1 -0
- package/dist/utils/exif-orientation.d.ts.map +1 -1
- package/dist/utils/exif-orientation.js +2 -3
- package/dist/utils/exif-orientation.js.map +1 -1
- package/dist/utils/tools-manager.d.ts +1 -0
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +41 -19
- package/dist/utils/tools-manager.js.map +1 -1
- package/docs/environment-variables.md +2 -0
- package/docs/extensions.md +5 -2
- package/docs/keybindings.md +3 -1
- package/docs/models.md +3 -0
- package/docs/rpc.md +1 -1
- package/docs/sdk.md +5 -0
- package/docs/settings.md +5 -5
- package/docs/skills.md +1 -1
- package/docs/terminal-setup.md +15 -0
- package/docs/themes.md +8 -6
- package/docs/tui.md +20 -1
- package/examples/README.md +3 -0
- 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/package.json +1 -1
- package/examples/extensions/dynamic-resources/dynamic.json +2 -0
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- 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/examples/plugins/pi-example-plugin/README.md +38 -0
- package/examples/plugins/pi-example-plugin/package.json +10 -0
- package/examples/plugins/pi-example-plugin/src/contract.ts +13 -0
- package/examples/plugins/pi-example-plugin/src/session.ts +23 -0
- package/examples/plugins/pi-example-plugin/src/tui.ts +31 -0
- package/npm-shrinkwrap.json +523 -28
- package/package.json +12 -6
- package/dist/bun/register-bedrock.d.ts +0 -2
- package/dist/bun/register-bedrock.d.ts.map +0 -1
- package/dist/bun/register-bedrock.js +0 -4
- package/dist/bun/register-bedrock.js.map +0 -1
- package/dist/bundle/chunks/anthropic-messages-JWX2WP65.js +0 -45
- package/dist/bundle/chunks/chunk-JUUC5AZY.js +0 -2
- package/dist/bundle/chunks/chunk-OMWWHBTG.js +0 -1548
- package/dist/bundle/chunks/openai-codex-responses-GJVBJXLB.js +0 -8
- package/dist/bundle/chunks/openai-responses-BSOJMSEV.js +0 -2
- package/dist/cli/experimental/auth.d.ts +0 -16
- package/dist/cli/experimental/auth.d.ts.map +0 -1
- package/dist/cli/experimental/auth.js +0 -13
- package/dist/cli/experimental/auth.js.map +0 -1
- package/dist/cli/experimental/commands/pi.d.ts +0 -15
- package/dist/cli/experimental/commands/pi.d.ts.map +0 -1
- package/dist/cli/experimental/commands/pi.js +0 -28
- package/dist/cli/experimental/commands/pi.js.map +0 -1
- package/dist/cli/experimental/transport-address.d.ts +0 -10
- package/dist/cli/experimental/transport-address.d.ts.map +0 -1
- package/dist/cli/experimental/transport-address.js +0 -38
- package/dist/cli/experimental/transport-address.js.map +0 -1
- package/dist/client/remote-session.d.ts +0 -53
- package/dist/client/remote-session.d.ts.map +0 -1
- package/dist/client/remote-session.js +0 -340
- package/dist/client/remote-session.js.map +0 -1
- package/dist/client/transcript.d.ts +0 -12
- package/dist/client/transcript.d.ts.map +0 -1
- package/dist/client/transcript.js +0 -98
- package/dist/client/transcript.js.map +0 -1
- package/dist/server/create-harness.d.ts +0 -26
- package/dist/server/create-harness.d.ts.map +0 -1
- package/dist/server/create-harness.js +0 -106
- package/dist/server/create-harness.js.map +0 -1
|
@@ -0,0 +1,702 @@
|
|
|
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
|