@bastani/atomic 0.9.21-alpha.1 → 0.9.21
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 +56 -0
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +22 -0
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +292 -60
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +23 -0
- package/dist/builtin/workflows/builtin/adversarial-verification.js +3 -3
- package/dist/builtin/workflows/builtin/{chunk-cw86srkf.js → chunk-632fxeb8.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-w18kbz63.js → chunk-94f8zfz1.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-kspvwc24.js → chunk-9cm2ckq2.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-jaj27rqc.js → chunk-a1ar035d.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-wh19f5ee.js → chunk-d3xhj946.js} +5 -4
- package/dist/builtin/workflows/builtin/{chunk-crw7q5g1.js → chunk-gyjck9z8.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-maqv731g.js → chunk-hj8mh07f.js} +10 -6
- package/dist/builtin/workflows/builtin/{chunk-0nrgfbag.js → chunk-kb7s3gx2.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-73c5tayt.js → chunk-kgn5wz1c.js} +19 -1
- package/dist/builtin/workflows/builtin/{chunk-2hak3b7g.js → chunk-nkj4qhj6.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-bzdvx2xr.js → chunk-r97ndfvt.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-vkmpdat4.js → chunk-wf876n16.js} +1 -1
- package/dist/builtin/workflows/builtin/classify-and-act.js +3 -3
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize.js +3 -3
- package/dist/builtin/workflows/builtin/generate-and-filter.js +3 -3
- package/dist/builtin/workflows/builtin/goal.js +4 -4
- package/dist/builtin/workflows/builtin/index.js +12 -12
- package/dist/builtin/workflows/builtin/loop-until-done.js +3 -3
- package/dist/builtin/workflows/builtin/open-claude-design.js +3 -3
- package/dist/builtin/workflows/builtin/ralph.js +4 -4
- package/dist/builtin/workflows/builtin/steering-context.js +1 -1
- package/dist/builtin/workflows/builtin/tournament.js +3 -3
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +40 -11
- package/dist/builtin/workflows/src/index.js +9 -3
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +6 -1
- package/dist/cli/auth-command.js +5 -0
- package/dist/cli/auth-command.js.map +1 -1
- package/dist/cli/credential-print.js +2 -0
- package/dist/cli/credential-print.js.map +1 -1
- package/dist/cli/experimental/command.js +5 -2
- package/dist/cli/experimental/command.js.map +1 -1
- package/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +4 -4
- package/dist/config.js +4 -4
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
- package/dist/core/agent-session-extension-bindings.js +9 -4
- package/dist/core/agent-session-extension-bindings.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +4 -4
- package/dist/core/agent-session-methods.d.ts.map +1 -1
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session-prompt.d.ts +4 -4
- package/dist/core/agent-session-prompt.d.ts.map +1 -1
- package/dist/core/agent-session-prompt.js +38 -15
- package/dist/core/agent-session-prompt.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +14 -9
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-types.d.ts +4 -1
- package/dist/core/agent-session-types.d.ts.map +1 -1
- package/dist/core/agent-session-types.js.map +1 -1
- package/dist/core/agent-session.d.ts +1 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +140 -95
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage-backends.js +2 -3
- package/dist/core/auth-storage-backends.js.map +1 -1
- package/dist/core/auth-storage.js +4 -1
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/builtin-resource-loader.js +9 -0
- package/dist/core/builtin-resource-loader.js.map +1 -1
- package/dist/core/cache-warmer.js +8 -1
- package/dist/core/cache-warmer.js.map +1 -1
- package/dist/core/compaction/range-planner.js +6 -0
- package/dist/core/compaction/range-planner.js.map +1 -1
- package/dist/core/execution-model-router.d.ts +13 -3
- package/dist/core/execution-model-router.d.ts.map +1 -1
- package/dist/core/execution-model-router.js +227 -131
- package/dist/core/execution-model-router.js.map +1 -1
- package/dist/core/export-html/template-js/entries-navigation.js +16 -6
- package/dist/core/export-html/template-js/initialization.js +34 -11
- package/dist/core/export-html/template.css +10 -0
- package/dist/core/export-html/template.js +50 -17
- package/dist/core/extensions/context-types.d.ts +2 -0
- package/dist/core/extensions/context-types.d.ts.map +1 -1
- package/dist/core/extensions/context-types.js.map +1 -1
- package/dist/core/extensions/host-input.js +8 -4
- package/dist/core/extensions/host-input.js.map +1 -1
- package/dist/core/extensions/reactive-widget.js +1 -0
- package/dist/core/extensions/reactive-widget.js.map +1 -1
- package/dist/core/extensions/runner-context.d.ts +1 -0
- package/dist/core/extensions/runner-context.d.ts.map +1 -1
- package/dist/core/extensions/runner-context.js +4 -0
- package/dist/core/extensions/runner-context.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +1 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +48 -30
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/runtime-types.d.ts +1 -0
- package/dist/core/extensions/runtime-types.d.ts.map +1 -1
- package/dist/core/extensions/runtime-types.js.map +1 -1
- package/dist/core/extensions/workflow-activity-hub.js +9 -7
- package/dist/core/extensions/workflow-activity-hub.js.map +1 -1
- package/dist/core/footer-data-provider.js +24 -23
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/keybindings.js +1 -0
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/mandatory-resource-loader.js +4 -1
- package/dist/core/mandatory-resource-loader.js.map +1 -1
- package/dist/core/model-config.js +2 -0
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-registry.js +1 -0
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver-defaults.js +1 -1
- package/dist/core/model-resolver-defaults.js.map +1 -1
- package/dist/core/{model-routing-task.d.ts → model-routing-bytes.d.ts} +1 -4
- package/dist/core/model-routing-bytes.d.ts.map +1 -0
- package/dist/core/model-routing-bytes.js +33 -0
- package/dist/core/model-routing-bytes.js.map +1 -0
- package/dist/core/model-routing-candidates.d.ts +42 -0
- package/dist/core/model-routing-candidates.d.ts.map +1 -0
- package/dist/core/model-routing-candidates.js +309 -0
- package/dist/core/model-routing-candidates.js.map +1 -0
- package/dist/core/model-routing-constraints.d.ts +4 -0
- package/dist/core/model-routing-constraints.d.ts.map +1 -1
- package/dist/core/model-routing-constraints.js +13 -1
- package/dist/core/model-routing-constraints.js.map +1 -1
- package/dist/core/model-routing-debug.d.ts +9 -0
- package/dist/core/model-routing-debug.d.ts.map +1 -0
- package/dist/core/model-routing-debug.js +14 -0
- package/dist/core/model-routing-debug.js.map +1 -0
- package/dist/core/model-routing-evals.d.ts +50 -0
- package/dist/core/model-routing-evals.d.ts.map +1 -0
- package/dist/core/model-routing-evals.js +190 -0
- package/dist/core/model-routing-evals.js.map +1 -0
- package/dist/core/model-routing-needs.d.ts +75 -0
- package/dist/core/model-routing-needs.d.ts.map +1 -0
- package/dist/core/model-routing-needs.js +176 -0
- package/dist/core/model-routing-needs.js.map +1 -0
- package/dist/core/model-runtime-streaming.js +3 -0
- package/dist/core/model-runtime-streaming.js.map +1 -1
- package/dist/core/model-runtime.js +26 -14
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/models-store.js +2 -3
- package/dist/core/models-store.js.map +1 -1
- package/dist/core/output-guard.js +1 -0
- package/dist/core/output-guard.js.map +1 -1
- package/dist/core/package-manager-paths.d.ts +2 -1
- package/dist/core/package-manager-paths.d.ts.map +1 -1
- package/dist/core/package-manager-paths.js +4 -3
- package/dist/core/package-manager-paths.js.map +1 -1
- package/dist/core/package-manager.js +1 -0
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/resource-loader-assets.d.ts.map +1 -1
- package/dist/core/resource-loader-assets.js +9 -7
- package/dist/core/resource-loader-assets.js.map +1 -1
- package/dist/core/resource-loader-core.js +49 -0
- package/dist/core/resource-loader-core.js.map +1 -1
- package/dist/core/runtime-credentials.js +2 -1
- package/dist/core/runtime-credentials.js.map +1 -1
- package/dist/core/session-cwd.js +1 -0
- package/dist/core/session-cwd.js.map +1 -1
- package/dist/core/session-manager-archive.d.ts.map +1 -1
- package/dist/core/session-manager-archive.js +4 -2
- package/dist/core/session-manager-archive.js.map +1 -1
- package/dist/core/session-manager-core.js +11 -7
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-manager-storage.d.ts +10 -4
- package/dist/core/session-manager-storage.d.ts.map +1 -1
- package/dist/core/session-manager-storage.js +12 -6
- package/dist/core/session-manager-storage.js.map +1 -1
- package/dist/core/settings-manager-basic-accessors.d.ts +2 -1
- package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
- package/dist/core/settings-manager-basic-accessors.js +21 -0
- package/dist/core/settings-manager-basic-accessors.js.map +1 -1
- package/dist/core/settings-manager-core.js +13 -7
- package/dist/core/settings-manager-core.js.map +1 -1
- package/dist/core/settings-manager.d.ts +1 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/settings-storage.js +6 -0
- package/dist/core/settings-storage.js.map +1 -1
- package/dist/core/settings-types.d.ts +8 -0
- package/dist/core/settings-types.d.ts.map +1 -1
- package/dist/core/settings-types.js.map +1 -1
- package/dist/core/structured-output/index.d.ts.map +1 -1
- package/dist/core/structured-output/index.js +4 -1
- package/dist/core/structured-output/index.js.map +1 -1
- package/dist/core/structured-output/invalid-output.js +1 -0
- package/dist/core/structured-output/invalid-output.js.map +1 -1
- package/dist/core/tasks/agent-adapter.js +5 -3
- package/dist/core/tasks/agent-adapter.js.map +1 -1
- package/dist/core/tasks/child-command-owner.js +3 -7
- package/dist/core/tasks/child-command-owner.js.map +1 -1
- package/dist/core/tasks/completion.js +5 -1
- package/dist/core/tasks/completion.js.map +1 -1
- package/dist/core/tasks/owner-store.js +12 -8
- package/dist/core/tasks/owner-store.js.map +1 -1
- package/dist/core/tasks/supervisor.js +14 -35
- package/dist/core/tasks/supervisor.js.map +1 -1
- package/dist/core/tools/ask-user-question/state/build-questionnaire.js +13 -4
- package/dist/core/tools/ask-user-question/state/build-questionnaire.js.map +1 -1
- package/dist/core/tools/ask-user-question/state/questionnaire-session.js +11 -1
- package/dist/core/tools/ask-user-question/state/questionnaire-session.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/chat-row-view.js +1 -0
- package/dist/core/tools/ask-user-question/view/components/chat-row-view.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/multi-select-view.js +1 -0
- package/dist/core/tools/ask-user-question/view/components/multi-select-view.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/option-list-view.js +1 -0
- package/dist/core/tools/ask-user-question/view/components/option-list-view.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/markdown-content-cache.js +5 -0
- package/dist/core/tools/ask-user-question/view/components/preview/markdown-content-cache.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.js +2 -0
- package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.js +13 -8
- package/dist/core/tools/ask-user-question/view/components/preview/preview-pane.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/submit-picker.js +1 -0
- package/dist/core/tools/ask-user-question/view/components/submit-picker.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/tab-bar.js +1 -0
- package/dist/core/tools/ask-user-question/view/components/tab-bar.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/wrapping-select.js +30 -24
- package/dist/core/tools/ask-user-question/view/components/wrapping-select.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/dialog-builder.js +5 -0
- package/dist/core/tools/ask-user-question/view/dialog-builder.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/props-adapter.js +8 -0
- package/dist/core/tools/ask-user-question/view/props-adapter.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/tab-content-strategy.js +4 -4
- package/dist/core/tools/ask-user-question/view/tab-content-strategy.js.map +1 -1
- package/dist/core/tools/bash.js +5 -8
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit-batch.js +4 -0
- package/dist/core/tools/edit-batch.js.map +1 -1
- package/dist/core/tools/edit.js +2 -0
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/file-mutation-coordinator.js +9 -0
- package/dist/core/tools/file-mutation-coordinator.js.map +1 -1
- package/dist/core/tools/find.js +1 -1
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/hashline-engine/fs.js +1 -1
- package/dist/core/tools/hashline-engine/fs.js.map +1 -1
- package/dist/core/tools/hashline-engine/input.js +4 -0
- package/dist/core/tools/hashline-engine/input.js.map +1 -1
- package/dist/core/tools/hashline-engine/mismatch.js +6 -0
- package/dist/core/tools/hashline-engine/mismatch.js.map +1 -1
- package/dist/core/tools/hashline-engine/patcher.js +13 -0
- package/dist/core/tools/hashline-engine/patcher.js.map +1 -1
- package/dist/core/tools/hashline-engine/recovery.js +1 -0
- package/dist/core/tools/hashline-engine/recovery.js.map +1 -1
- package/dist/core/tools/output-accumulator.js +20 -13
- package/dist/core/tools/output-accumulator.js.map +1 -1
- package/dist/core/tools/persisted-output-file.js +9 -3
- package/dist/core/tools/persisted-output-file.js.map +1 -1
- package/dist/core/tools/resource-selectors.js +1 -0
- package/dist/core/tools/resource-selectors.js.map +1 -1
- package/dist/core/tools/write.js +1 -0
- package/dist/core/tools/write.js.map +1 -1
- package/dist/core/trust-manager.js +1 -0
- package/dist/core/trust-manager.js.map +1 -1
- package/dist/core/workflow-stage-admission.js +17 -10
- package/dist/core/workflow-stage-admission.js.map +1 -1
- package/dist/extensions/llama/client.js +2 -0
- package/dist/extensions/llama/client.js.map +1 -1
- package/dist/extensions/llama/huggingface-ui.js +17 -9
- package/dist/extensions/llama/huggingface-ui.js.map +1 -1
- package/dist/extensions/llama/huggingface.js +2 -0
- package/dist/extensions/llama/huggingface.js.map +1 -1
- package/dist/extensions/llama/ui.js +11 -3
- package/dist/extensions/llama/ui.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/modes/interactive/components/armin.js +10 -6
- package/dist/modes/interactive/components/armin.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +10 -2
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/atomic-working-status.js +10 -2
- package/dist/modes/interactive/components/atomic-working-status.js.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js +9 -4
- package/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.js +3 -0
- package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js +4 -1
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/chat-message-renderer.js +2 -1
- package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-state.js +63 -31
- package/dist/modes/interactive/components/chat-session-host-state.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.js +8 -1
- package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
- package/dist/modes/interactive/components/chat-transcript.js +24 -14
- package/dist/modes/interactive/components/chat-transcript.js.map +1 -1
- package/dist/modes/interactive/components/compaction-boundary-message.js +2 -1
- package/dist/modes/interactive/components/compaction-boundary-message.js.map +1 -1
- package/dist/modes/interactive/components/config-selector-list.js +15 -6
- package/dist/modes/interactive/components/config-selector-list.js.map +1 -1
- package/dist/modes/interactive/components/config-selector.js +7 -1
- package/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/dist/modes/interactive/components/countdown-timer.js +2 -0
- package/dist/modes/interactive/components/countdown-timer.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +21 -1
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/custom-entry.js +4 -1
- package/dist/modes/interactive/components/custom-entry.js.map +1 -1
- package/dist/modes/interactive/components/custom-message.js +9 -1
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/daxnuts.js +8 -6
- package/dist/modes/interactive/components/daxnuts.js.map +1 -1
- package/dist/modes/interactive/components/dynamic-border.js +1 -0
- package/dist/modes/interactive/components/dynamic-border.js.map +1 -1
- package/dist/modes/interactive/components/extension-editor.js +7 -1
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/extension-input.js +8 -2
- package/dist/modes/interactive/components/extension-input.js.map +1 -1
- package/dist/modes/interactive/components/extension-selector.js +9 -1
- package/dist/modes/interactive/components/extension-selector.js.map +1 -1
- package/dist/modes/interactive/components/first-time-setup.js +4 -2
- package/dist/modes/interactive/components/first-time-setup.js.map +1 -1
- package/dist/modes/interactive/components/footer.js +5 -2
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/host-input-form.js +13 -2
- package/dist/modes/interactive/components/host-input-form.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +9 -3
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +24 -12
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +12 -3
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/reserved-bottom-overlay.js +11 -2
- package/dist/modes/interactive/components/reserved-bottom-overlay.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +13 -8
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/scroll-widget.js +4 -0
- package/dist/modes/interactive/components/scroll-widget.js.map +1 -1
- package/dist/modes/interactive/components/session-selector-header.js +11 -7
- package/dist/modes/interactive/components/session-selector-header.js.map +1 -1
- package/dist/modes/interactive/components/session-selector-list.js +25 -12
- package/dist/modes/interactive/components/session-selector-list.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +23 -15
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-submenus.js +19 -1
- package/dist/modes/interactive/components/settings-selector-submenus.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +1 -0
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/show-images-selector.js +1 -0
- package/dist/modes/interactive/components/show-images-selector.js.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.js +4 -1
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
- package/dist/modes/interactive/components/startup-identity.js +8 -3
- package/dist/modes/interactive/components/startup-identity.js.map +1 -1
- package/dist/modes/interactive/components/task-completion-message.js +2 -0
- package/dist/modes/interactive/components/task-completion-message.js.map +1 -1
- package/dist/modes/interactive/components/task-detail.js +2 -0
- package/dist/modes/interactive/components/task-detail.js.map +1 -1
- package/dist/modes/interactive/components/task-inspector.js +22 -12
- package/dist/modes/interactive/components/task-inspector.js.map +1 -1
- package/dist/modes/interactive/components/task-list.js +2 -0
- package/dist/modes/interactive/components/task-list.js.map +1 -1
- package/dist/modes/interactive/components/task-live-transcript.js +8 -3
- package/dist/modes/interactive/components/task-live-transcript.js.map +1 -1
- package/dist/modes/interactive/components/task-navigation.js +5 -2
- package/dist/modes/interactive/components/task-navigation.js.map +1 -1
- package/dist/modes/interactive/components/task-row.js +2 -0
- package/dist/modes/interactive/components/task-row.js.map +1 -1
- package/dist/modes/interactive/components/theme-selector.js +2 -0
- package/dist/modes/interactive/components/theme-selector.js.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +7 -1
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +25 -10
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/transcript-follow-indicator.js +1 -0
- package/dist/modes/interactive/components/transcript-follow-indicator.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-component.js +7 -3
- package/dist/modes/interactive/components/tree-selector-component.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-help.js +1 -0
- package/dist/modes/interactive/components/tree-selector-help.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-label-input.js +6 -2
- package/dist/modes/interactive/components/tree-selector-label-input.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-list.js +4 -0
- package/dist/modes/interactive/components/tree-selector-list.js.map +1 -1
- package/dist/modes/interactive/components/trust-selector.js +6 -0
- package/dist/modes/interactive/components/trust-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.js +6 -3
- package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message.js +5 -0
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/components/working-status.js +1 -0
- package/dist/modes/interactive/components/working-status.js.map +1 -1
- package/dist/modes/interactive/interactive-autocomplete.js +2 -0
- package/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-runtime.js +1 -0
- package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.js +162 -120
- package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-helpers.js +3 -0
- package/dist/modes/interactive/interactive-mode-helpers.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts +0 -6
- package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
- package/dist/modes/interactive/interactive-resource-disclosure.js +0 -4
- package/dist/modes/interactive/interactive-resource-disclosure.js.map +1 -1
- package/dist/modes/interactive/interactive-resource-rendering.js +0 -12
- package/dist/modes/interactive/interactive-resource-rendering.js.map +1 -1
- package/dist/modes/interactive/interactive-startup-chat-container.js +1 -4
- package/dist/modes/interactive/interactive-startup-chat-container.js.map +1 -1
- package/dist/modes/interactive/model-catalog-refresh.js +1 -3
- package/dist/modes/interactive/model-catalog-refresh.js.map +1 -1
- package/dist/modes/interactive/theme/color-utils.d.ts +5 -0
- package/dist/modes/interactive/theme/color-utils.d.ts.map +1 -1
- package/dist/modes/interactive/theme/color-utils.js +11 -0
- package/dist/modes/interactive/theme/color-utils.js.map +1 -1
- package/dist/modes/interactive/theme/global-theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/global-theme.js +4 -3
- package/dist/modes/interactive/theme/global-theme.js.map +1 -1
- package/dist/modes/interactive/theme/theme-class.js +7 -0
- package/dist/modes/interactive/theme/theme-class.js.map +1 -1
- package/dist/modes/interactive/theme/theme-controller.js +9 -2
- package/dist/modes/interactive/theme/theme-controller.js.map +1 -1
- package/dist/modes/interactive-engine/activity-watchdog.js +8 -3
- package/dist/modes/interactive-engine/activity-watchdog.js.map +1 -1
- package/dist/modes/interactive-engine/engine-custom-ui.js +12 -8
- package/dist/modes/interactive-engine/engine-custom-ui.js.map +1 -1
- package/dist/modes/interactive-engine/engine-dialog-host.js +7 -3
- package/dist/modes/interactive-engine/engine-dialog-host.js.map +1 -1
- package/dist/modes/interactive-engine/engine-health.js +23 -13
- package/dist/modes/interactive-engine/engine-health.js.map +1 -1
- package/dist/modes/interactive-engine/engine-input-form.js +3 -2
- package/dist/modes/interactive-engine/engine-input-form.js.map +1 -1
- package/dist/modes/interactive-engine/engine-monitor.js +13 -1
- package/dist/modes/interactive-engine/engine-monitor.js.map +1 -1
- package/dist/modes/interactive-engine/engine-project-trust.js +2 -1
- package/dist/modes/interactive-engine/engine-project-trust.js.map +1 -1
- package/dist/modes/interactive-engine/engine-render-service.js +7 -4
- package/dist/modes/interactive-engine/engine-render-service.js.map +1 -1
- package/dist/modes/interactive-engine/engine-session-picker.js +3 -2
- package/dist/modes/interactive-engine/engine-session-picker.js.map +1 -1
- package/dist/modes/interactive-engine/input-form-host.js +5 -1
- package/dist/modes/interactive-engine/input-form-host.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js +37 -23
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
- package/dist/modes/interactive-engine/remote-command-catalog.js +4 -3
- package/dist/modes/interactive-engine/remote-command-catalog.js.map +1 -1
- package/dist/modes/interactive-engine/remote-component.js +24 -12
- package/dist/modes/interactive-engine/remote-component.js.map +1 -1
- package/dist/modes/interactive-engine/remote-frame-clamp.js +3 -3
- package/dist/modes/interactive-engine/remote-frame-clamp.js.map +1 -1
- package/dist/modes/interactive-engine/remote-model-catalog.js +5 -4
- package/dist/modes/interactive-engine/remote-model-catalog.js.map +1 -1
- package/dist/modes/interactive-engine/remote-queue-pause.js +3 -1
- package/dist/modes/interactive-engine/remote-queue-pause.js.map +1 -1
- package/dist/modes/interactive-engine/remote-renderer.js +24 -13
- package/dist/modes/interactive-engine/remote-renderer.js.map +1 -1
- package/dist/modes/interactive-engine/resource-readiness-error.js +1 -0
- package/dist/modes/interactive-engine/resource-readiness-error.js.map +1 -1
- package/dist/modes/interactive-engine/session-picker-host.js +5 -1
- package/dist/modes/interactive-engine/session-picker-host.js.map +1 -1
- package/dist/modes/interactive-engine/terminal-mode-controller.js +2 -1
- package/dist/modes/interactive-engine/terminal-mode-controller.js.map +1 -1
- package/dist/modes/rpc/queued-writer.js +13 -4
- package/dist/modes/rpc/queued-writer.js.map +1 -1
- package/dist/modes/rpc/rpc-bash-request-owners.js +2 -1
- package/dist/modes/rpc/rpc-bash-request-owners.js.map +1 -1
- package/dist/modes/rpc/rpc-client-api.d.ts +8 -4
- package/dist/modes/rpc/rpc-client-api.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client-api.js +10 -3
- package/dist/modes/rpc/rpc-client-api.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +35 -22
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.js +6 -6
- package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
- package/dist/modes/rpc/rpc-event-buffer.js +3 -1
- package/dist/modes/rpc/rpc-event-buffer.js.map +1 -1
- package/dist/modes/rpc/rpc-generation-buffer.js +1 -3
- package/dist/modes/rpc/rpc-generation-buffer.js.map +1 -1
- package/dist/modes/rpc/rpc-keybindings-reload.js +4 -1
- package/dist/modes/rpc/rpc-keybindings-reload.js.map +1 -1
- package/dist/modes/rpc/rpc-output-buffer.js +3 -4
- package/dist/modes/rpc/rpc-output-buffer.js.map +1 -1
- package/dist/modes/rpc/rpc-pending-requests.js +1 -3
- package/dist/modes/rpc/rpc-pending-requests.js.map +1 -1
- package/dist/modes/rpc/rpc-provider-auth.js +3 -1
- package/dist/modes/rpc/rpc-provider-auth.js.map +1 -1
- package/dist/modes/rpc/rpc-resource-readiness.js +4 -5
- package/dist/modes/rpc/rpc-resource-readiness.js.map +1 -1
- package/dist/modes/rpc/rpc-session-binding.js +15 -0
- package/dist/modes/rpc/rpc-session-binding.js.map +1 -1
- package/dist/modes/rpc/rpc-terminal-drain.js +3 -0
- package/dist/modes/rpc/rpc-terminal-drain.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +10 -1
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/docs/models/evals.md +883 -39
- package/docs/models/model-selection.md +7 -8
- package/docs/rpc/examples.md +1 -1
- package/docs/rpc/protocol.md +9 -3
- package/docs/sdk/structured-decisions.md +1 -1
- package/docs/sdk.md +3 -3
- package/docs/settings.md +24 -3
- package/docs/subagents/reference.md +22 -4
- package/docs/subagents.md +2 -0
- package/docs/usage.md +3 -3
- package/docs/workflows/api-reference.md +1 -1
- package/docs/workflows/authoring.md +1 -7
- package/docs/workflows/builtins.md +1 -1
- package/docs/workflows/reliable-design.md +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/test.ts +5 -5
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/rpc-client.ts +1 -1
- package/examples/rpc-extension-ui.ts +1 -1
- package/npm-shrinkwrap.json +70 -33
- package/package.json +6 -7
- package/dist/core/model-routing-task.d.ts.map +0 -1
- package/dist/core/model-routing-task.js +0 -120
- package/dist/core/model-routing-task.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc-command-handler.js","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-command-handler.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAGpE,OAAO,EAAE,+BAA+B,EAAE,MAAM,gCAAgC,CAAC;AACjF,OAAO,EAA2B,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAClF,OAAO,EACN,sBAAsB,EACtB,wBAAwB,EACxB,qBAAqB,GAErB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAoB9D,SAAS,6BAA6B,CAAC,OAAmB;IACzD,QAAQ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BACnD,OAAO,sBAAsB,CAAC,EAAE,EAAE,cAAc,CAAC,IAAI,EAAE,oBAAoB,cAAc,CAAC,IAAI,EAAE,CAAC,CAAC;YACnG,CAAC;QACF,CAAC;IACF,CAAC,CAA6B,CAAC;IAC/B,aAAa,CAAC,iBAAiB,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;IAC7D,OAAO,aAAa,CAAC;AACtB,CAAC","sourcesContent":["import type { KeyId } from \"@earendil-works/pi-tui\";\nimport type { AgentSession } from \"../../core/agent-session.js\";\nimport type { AgentSessionRuntime } from \"../../core/agent-session-runtime.ts\";\nimport { runCallback } from \"../../core/callback-activity.ts\";\nimport type { ExtensionUIContext } from \"../../core/extensions/index.js\";\nimport { KeybindingsManager } from \"../../core/keybindings.ts\";\nimport { getSkillCatalog } from \"../../core/skill-catalog.ts\";\nimport { RpcBashRequestOwners } from \"./rpc-bash-request-owners.ts\";\nimport type { RpcPendingExtensionRequests } from \"./rpc-extension-ui.ts\";\nimport type { KeybindingsReloadCoordinator } from \"./rpc-keybindings-reload.ts\";\nimport { rejectUnsupportedProviderPrompt } from \"./rpc-model-fallback-prompt.ts\";\nimport { type ProviderLoginInput, RpcProviderAuth } from \"./rpc-provider-auth.ts\";\nimport {\n\tcreateRpcErrorResponse,\n\tcreateRpcSuccessResponse,\n\tformatRpcErrorMessage,\n\ttype RpcOutput,\n} from \"./rpc-responses.ts\";\nimport type { RpcCommand, RpcResponse, RpcSessionState, RpcSlashCommand } from \"./rpc-types.ts\";\nimport { showEngineTaskInspector } from \"./task-ui-bridge.js\";\n\nexport type RpcCommandHandler = (command: RpcCommand) => Promise<RpcResponse | undefined>;\nexport type ManagedRpcCommandHandler = RpcCommandHandler & { disposeActiveBash(): Promise<void> };\n\ninterface RpcCommandHandlerOptions {\n\truntimeHost: AgentSessionRuntime;\n\tgetSession: () => AgentSession;\n\trebindSession: () => Promise<void>;\n\toutput: RpcOutput;\n\tkeybindings?: KeybindingsManager;\n\ttaskInspectorUi?: Pick<ExtensionUIContext, \"custom\">;\n\treloadCoordinator?: KeybindingsReloadCoordinator<AgentSession>;\n\tinputForm?: ProviderLoginInput;\n\tpendingExtensionRequests?: RpcPendingExtensionRequests;\n\twaitForResources?: () => Promise<void> | undefined;\n\treloadResources?: () => Promise<void>;\n\tshouldRetryResources?: () => boolean;\n}\n\nfunction canRunBeforeOptionalResources(command: RpcCommand): boolean {\n\tswitch (command.type) {\n\t\tcase \"abort\":\n\t\tcase \"abort_bash\":\n\t\tcase \"abort_compaction\":\n\t\tcase \"abort_retry\":\n\t\tcase \"cancel_login_provider\":\n\t\tcase \"clear_queue\":\n\t\tcase \"get_messages\":\n\t\tcase \"get_state\":\n\t\tcase \"pause_queued_messages\":\n\t\tcase \"resume_queued_messages\":\n\t\tcase \"set_auto_compaction\":\n\t\tcase \"set_auto_retry\":\n\t\tcase \"set_follow_up_mode\":\n\t\tcase \"set_steering_mode\":\n\t\t\treturn true;\n\t\tcase \"get_available_models\":\n\t\t\treturn command.allowPartialResources === true;\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\nexport function createRpcCommandHandler({\n\truntimeHost,\n\tgetSession,\n\trebindSession,\n\toutput,\n\tkeybindings,\n\ttaskInspectorUi,\n\treloadCoordinator,\n\tinputForm,\n\tpendingExtensionRequests,\n\twaitForResources,\n\treloadResources,\n\tshouldRetryResources,\n}: RpcCommandHandlerOptions): ManagedRpcCommandHandler {\n\tlet fallbackShortcutKeybindings: KeybindingsManager | undefined;\n\tconst providerAuth = new RpcProviderAuth(inputForm, {\n\t\toutput,\n\t\tpending: pendingExtensionRequests ?? new Map(),\n\t});\n\tconst bashOwners = new RpcBashRequestOwners(output);\n\tconst getShortcutBindings = () => {\n\t\tif (keybindings) return keybindings.getEffectiveConfig();\n\t\tif (fallbackShortcutKeybindings) fallbackShortcutKeybindings.reload();\n\t\telse fallbackShortcutKeybindings = KeybindingsManager.create(runtimeHost.services.agentDir);\n\t\treturn fallbackShortcutKeybindings.getEffectiveConfig();\n\t};\n\tconst handleCommand = (async (command: RpcCommand): Promise<RpcResponse | undefined> => {\n\t\tconst id = command.id;\n\t\tconst retryFailedResources = command.type === \"reload\" && shouldRetryResources?.() === true;\n\t\tif (command.type !== \"prompt\" && !retryFailedResources && !canRunBeforeOptionalResources(command)) {\n\t\t\tconst pendingResources = waitForResources?.();\n\t\t\tif (pendingResources) await pendingResources;\n\t\t}\n\t\tconst session = getSession();\n\t\tswitch (command.type) {\n\t\t\tcase \"open_task_inspector\": {\n\t\t\t\tif (!keybindings || !taskInspectorUi)\n\t\t\t\t\treturn createRpcErrorResponse(id, command.type, \"Task inspection requires an interactive host\");\n\t\t\t\tvoid showEngineTaskInspector(session, taskInspectorUi, command.taskId).catch((error: Error) =>\n\t\t\t\t\tsession.extensionRunner.getUIContext().notify(error.message, \"error\"),\n\t\t\t\t);\n\t\t\t\treturn createRpcSuccessResponse(id, command.type);\n\t\t\t}\n\t\t\tcase \"prompt\": {\n\t\t\t\tlet preflightSucceeded = false;\n\t\t\t\tvoid (async () => {\n\t\t\t\t\tconst pendingResources = waitForResources?.();\n\t\t\t\t\tif (pendingResources) await pendingResources;\n\t\t\t\t\tif (rejectUnsupportedProviderPrompt(runtimeHost, output, id)) return;\n\t\t\t\t\tconst promptSession = getSession();\n\t\t\t\t\tawait promptSession.prompt(command.message, {\n\t\t\t\t\t\timages: command.images,\n\t\t\t\t\t\tstreamingBehavior: command.streamingBehavior,\n\t\t\t\t\t\tsource: \"rpc\",\n\t\t\t\t\t\tpreflightResult: (didSucceed) => {\n\t\t\t\t\t\t\tif (didSucceed) {\n\t\t\t\t\t\t\t\tpreflightSucceeded = true;\n\t\t\t\t\t\t\t\toutput(createRpcSuccessResponse(id, \"prompt\"));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t})().catch((promptError: unknown) => {\n\t\t\t\t\tif (!preflightSucceeded) {\n\t\t\t\t\t\toutput(createRpcErrorResponse(id, \"prompt\", formatRpcErrorMessage(promptError), promptError));\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tcase \"steer\": {\n\t\t\t\tawait session.steer(command.message, command.images, { source: \"rpc\" });\n\t\t\t\treturn createRpcSuccessResponse(id, \"steer\");\n\t\t\t}\n\n\t\t\tcase \"follow_up\": {\n\t\t\t\tawait session.followUp(command.message, command.images, { source: \"rpc\" });\n\t\t\t\treturn createRpcSuccessResponse(id, \"follow_up\");\n\t\t\t}\n\n\t\t\tcase \"abort\": {\n\t\t\t\tawait session.abort();\n\t\t\t\treturn createRpcSuccessResponse(id, \"abort\");\n\t\t\t}\n\t\t\tcase \"new_session\": {\n\t\t\t\tconst options = command.parentSession ? { parentSession: command.parentSession } : undefined;\n\t\t\t\tconst result = await runtimeHost.newSession(options);\n\t\t\t\tif (!result.cancelled) {\n\t\t\t\t\tawait rebindSession();\n\t\t\t\t}\n\t\t\t\treturn createRpcSuccessResponse(id, \"new_session\", result);\n\t\t\t}\n\n\t\t\tcase \"get_state\": {\n\t\t\t\tconst extensionResult = session.resourceLoader.getExtensions();\n\t\t\t\tconst state: RpcSessionState = {\n\t\t\t\t\tmodel: session.model,\n\t\t\t\t\tmodelFallbackMessage: runtimeHost.modelFallbackMessage,\n\t\t\t\t\tmodelFallbackReason: runtimeHost.modelFallbackReason,\n\t\t\t\t\tthinkingLevel: session.thinkingLevel,\n\t\t\t\t\tisStreaming: session.isStreaming,\n\t\t\t\t\tisCompacting: session.isCompacting,\n\t\t\t\t\tcompactionReason: session.compactionReason,\n\t\t\t\t\tsteeringMode: session.steeringMode,\n\t\t\t\t\tfollowUpMode: session.followUpMode,\n\t\t\t\t\tsessionFile: session.sessionFile,\n\t\t\t\t\tsessionId: session.sessionId,\n\t\t\t\t\tsessionName: session.sessionName,\n\t\t\t\t\tautoCompactionEnabled: session.autoCompactionEnabled,\n\t\t\t\t\tmessageCount: session.messages.length,\n\t\t\t\t\tpendingMessageCount: session.pendingMessageCount,\n\t\t\t\t\tqueuedMessagesPaused: session.queuedMessagesPaused,\n\t\t\t\t\tprojectTrusted: session.settingsManager.isProjectTrusted?.() === true,\n\t\t\t\t\tresourceOverlaps: extensionResult.overlaps ?? [],\n\t\t\t\t\tresourceExtensions: extensionResult.extensions.map((extension) => ({\n\t\t\t\t\t\tpath: extension.path,\n\t\t\t\t\t\tsourceInfo: extension.sourceInfo,\n\t\t\t\t\t\thidden: extension.hidden === true,\n\t\t\t\t\t})),\n\t\t\t\t};\n\t\t\t\treturn createRpcSuccessResponse(id, \"get_state\", state);\n\t\t\t}\n\t\t\tcase \"set_model\": {\n\t\t\t\tconst models = await session.modelRuntime.getAvailableSnapshot();\n\t\t\t\tconst model = models.find(\n\t\t\t\t\t(candidate) => candidate.provider === command.provider && candidate.id === command.modelId,\n\t\t\t\t);\n\t\t\t\tif (!model) {\n\t\t\t\t\treturn createRpcErrorResponse(\n\t\t\t\t\t\tid,\n\t\t\t\t\t\t\"set_model\",\n\t\t\t\t\t\t`Model not found: ${command.provider}/${command.modelId}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tawait session.setModel(model, command.persist === true ? { persist: true } : {});\n\t\t\t\truntimeHost.resolveModelFallback();\n\t\t\t\treturn createRpcSuccessResponse(id, \"set_model\", session.model ?? model);\n\t\t\t}\n\t\t\tcase \"cycle_model\": {\n\t\t\t\tconst previousModel = session.model;\n\t\t\t\tconst result = await session.cycleModel(\n\t\t\t\t\tcommand.direction,\n\t\t\t\t\tcommand.persist === true ? { persist: true } : {},\n\t\t\t\t);\n\t\t\t\truntimeHost.resolveModelFallbackAfterExplicitModelSelection(previousModel, result?.model);\n\t\t\t\treturn createRpcSuccessResponse(id, \"cycle_model\", result ?? null);\n\t\t\t}\n\t\t\tcase \"get_available_models\": {\n\t\t\t\tconst models = await session.modelRuntime.getAvailableSnapshot();\n\t\t\t\treturn createRpcSuccessResponse(id, \"get_available_models\", {\n\t\t\t\t\tmodels,\n\t\t\t\t\tscopedModels: session.scopedModels,\n\t\t\t\t\tcustomAuthProviders: [],\n\t\t\t\t\toauthProviders: session.modelRuntime.getOAuthProviderMetadata(),\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tcase \"login_provider\": {\n\t\t\t\tconst result =\n\t\t\t\t\tcommand.authType === \"oauth\"\n\t\t\t\t\t\t? await providerAuth.loginOAuth(session, command.provider, command.loginId)\n\t\t\t\t\t\t: await providerAuth.login(session, command.provider, command.loginId);\n\t\t\t\treturn createRpcSuccessResponse(id, \"login_provider\", result);\n\t\t\t}\n\n\t\t\tcase \"save_provider_credential\":\n\t\t\t\treturn createRpcSuccessResponse(\n\t\t\t\t\tid,\n\t\t\t\t\t\"save_provider_credential\",\n\t\t\t\t\tawait providerAuth.save(session, command.provider, command.credential, {\n\t\t\t\t\t\trefreshCatalog: command.refreshCatalog,\n\t\t\t\t\t}),\n\t\t\t\t);\n\n\t\t\tcase \"cancel_login_provider\":\n\t\t\t\tproviderAuth.cancel(command.provider, command.loginId);\n\t\t\t\treturn createRpcSuccessResponse(id, \"cancel_login_provider\");\n\n\t\t\tcase \"logout_provider\": {\n\t\t\t\tconst result = await runtimeHost.logoutProvider(command.provider);\n\t\t\t\treturn createRpcSuccessResponse(id, \"logout_provider\", result);\n\t\t\t}\n\t\t\tcase \"refresh_models\": {\n\t\t\t\tconst controller = command.timeoutMs === undefined ? undefined : new AbortController();\n\t\t\t\tconst timedOut = Symbol(\"model refresh timed out\");\n\t\t\t\tlet timeout: ReturnType<typeof setTimeout> | undefined;\n\t\t\t\tconst timeoutResult =\n\t\t\t\t\tcontroller && command.timeoutMs !== undefined\n\t\t\t\t\t\t? new Promise<typeof timedOut>((resolve) => {\n\t\t\t\t\t\t\t\ttimeout = setTimeout(() => {\n\t\t\t\t\t\t\t\t\tcontroller.abort();\n\t\t\t\t\t\t\t\t\tresolve(timedOut);\n\t\t\t\t\t\t\t\t}, command.timeoutMs);\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t: undefined;\n\t\t\t\ttry {\n\t\t\t\t\tconst refresh = (async () => {\n\t\t\t\t\t\tawait session.modelRuntime.reloadCredentials({ refreshAvailability: false });\n\t\t\t\t\t\tif (controller?.signal.aborted) return { aborted: true, errors: new Map<string, Error>() };\n\t\t\t\t\t\treturn session.modelRuntime.refresh({\n\t\t\t\t\t\t\tallowNetwork: command.allowNetwork,\n\t\t\t\t\t\t\tforce: command.force,\n\t\t\t\t\t\t\tsignal: controller?.signal,\n\t\t\t\t\t\t});\n\t\t\t\t\t})();\n\t\t\t\t\tconst outcome = timeoutResult ? await Promise.race([refresh, timeoutResult]) : await refresh;\n\t\t\t\t\tconst result = outcome === timedOut ? { aborted: true, errors: new Map<string, Error>() } : outcome;\n\t\t\t\t\treturn createRpcSuccessResponse(id, \"refresh_models\", {\n\t\t\t\t\t\taborted: result.aborted,\n\t\t\t\t\t\terrors: [...result.errors].map(([provider, error]) => ({ provider, message: error.message })),\n\t\t\t\t\t\tmodels: session.modelRuntime.getAvailableSnapshot(),\n\t\t\t\t\t\tscopedModels: session.scopedModels,\n\t\t\t\t\t\tcustomAuthProviders: [],\n\t\t\t\t\t\toauthProviders: session.modelRuntime.getOAuthProviderMetadata(),\n\t\t\t\t\t});\n\t\t\t\t} finally {\n\t\t\t\t\tif (timeout) clearTimeout(timeout);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tcase \"set_thinking_level\": {\n\t\t\t\tsession.setThinkingLevel(command.level, command.persist === true ? { persist: true } : {});\n\t\t\t\tconst model = session.model;\n\t\t\t\treturn createRpcSuccessResponse(id, \"set_thinking_level\", {\n\t\t\t\t\tlevel: session.thinkingLevel,\n\t\t\t\t\t...(model ? { provider: model.provider, modelId: model.id } : {}),\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tcase \"cycle_thinking_level\": {\n\t\t\t\tconst level = session.cycleThinkingLevel();\n\t\t\t\treturn createRpcSuccessResponse(id, \"cycle_thinking_level\", level ? { level } : null);\n\t\t\t}\n\n\t\t\tcase \"get_available_thinking_levels\": {\n\t\t\t\treturn createRpcSuccessResponse(id, \"get_available_thinking_levels\", {\n\t\t\t\t\tlevels: session.getAvailableThinkingLevels(),\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tcase \"set_steering_mode\": {\n\t\t\t\tsession.setSteeringMode(command.mode);\n\t\t\t\treturn createRpcSuccessResponse(id, \"set_steering_mode\");\n\t\t\t}\n\n\t\t\tcase \"set_follow_up_mode\": {\n\t\t\t\tsession.setFollowUpMode(command.mode);\n\t\t\t\treturn createRpcSuccessResponse(id, \"set_follow_up_mode\");\n\t\t\t}\n\n\t\t\tcase \"compact\": {\n\t\t\t\tconst result = await session.compact();\n\t\t\t\treturn createRpcSuccessResponse(id, \"compact\", result);\n\t\t\t}\n\n\t\t\tcase \"set_auto_compaction\":\n\t\t\t\tsession.setAutoCompactionEnabled(command.enabled);\n\t\t\t\treturn createRpcSuccessResponse(id, \"set_auto_compaction\");\n\t\t\tcase \"abort_compaction\":\n\t\t\t\tsession.abortCompaction();\n\t\t\t\treturn createRpcSuccessResponse(id, \"abort_compaction\");\n\t\t\tcase \"set_auto_retry\":\n\t\t\t\tsession.setAutoRetryEnabled(command.enabled);\n\t\t\t\treturn createRpcSuccessResponse(id, \"set_auto_retry\");\n\t\t\tcase \"abort_retry\":\n\t\t\t\tsession.abortRetry();\n\t\t\t\treturn createRpcSuccessResponse(id, \"abort_retry\");\n\n\t\t\tcase \"clear_queue\": {\n\t\t\t\treturn createRpcSuccessResponse(id, \"clear_queue\", session.clearQueue());\n\t\t\t}\n\t\t\tcase \"pause_queued_messages\":\n\t\t\t\tsession.pauseQueuedMessages();\n\t\t\t\treturn createRpcSuccessResponse(id, \"pause_queued_messages\");\n\t\t\tcase \"resume_queued_messages\":\n\t\t\t\treturn createRpcSuccessResponse(id, \"resume_queued_messages\", {\n\t\t\t\t\treleased: await session.resumeQueuedMessages(),\n\t\t\t\t});\n\t\t\tcase \"bash\": {\n\t\t\t\tconst result = await bashOwners.run(\n\t\t\t\t\t{\n\t\t\t\t\t\tid,\n\t\t\t\t\t\tsession,\n\t\t\t\t\t\tcommand: command.command,\n\t\t\t\t\t\texcludeFromContext: command.excludeFromContext,\n\t\t\t\t\t\tisCurrent: () => getSession() === session,\n\t\t\t\t\t},\n\t\t\t\t\t// A `bash` command is still a user-initiated shell request, so it must\n\t\t\t\t\t// reach `user_bash` handlers (sandboxes, remote shells) exactly like the\n\t\t\t\t\t// `user_bash` command does. Ownership, streaming correlation, and result\n\t\t\t\t\t// recording stay with the owning request either way.\n\t\t\t\t\tasync (onUpdate) => {\n\t\t\t\t\t\tconst intercepted = await session.extensionRunner.emitUserBash({\n\t\t\t\t\t\t\ttype: \"user_bash\",\n\t\t\t\t\t\t\tcommand: command.command,\n\t\t\t\t\t\t\texcludeFromContext: command.excludeFromContext === true,\n\t\t\t\t\t\t\tcwd: session.sessionManager.getCwd(),\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (intercepted?.result) return intercepted.result;\n\t\t\t\t\t\treturn session.executeBash(command.command, onUpdate, {\n\t\t\t\t\t\t\texcludeFromContext: command.excludeFromContext,\n\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\toperations: intercepted?.operations,\n\t\t\t\t\t\t\temitEvent: false,\n\t\t\t\t\t\t\trecordResult: false,\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\treturn createRpcSuccessResponse(id, \"bash\", result);\n\t\t\t}\n\t\t\tcase \"user_bash\": {\n\t\t\t\tconst result = await bashOwners.run(\n\t\t\t\t\t{\n\t\t\t\t\t\tid,\n\t\t\t\t\t\tsession,\n\t\t\t\t\t\tcommand: command.command,\n\t\t\t\t\t\texcludeFromContext: command.excludeFromContext,\n\t\t\t\t\t\tisCurrent: () => getSession() === session,\n\t\t\t\t\t},\n\t\t\t\t\tasync (onUpdate) => {\n\t\t\t\t\t\tconst intercepted = await session.extensionRunner.emitUserBash({\n\t\t\t\t\t\t\ttype: \"user_bash\",\n\t\t\t\t\t\t\tcommand: command.command,\n\t\t\t\t\t\t\texcludeFromContext: command.excludeFromContext === true,\n\t\t\t\t\t\t\tcwd: session.sessionManager.getCwd(),\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (intercepted?.result) return intercepted.result;\n\t\t\t\t\t\treturn session.executeBash(command.command, onUpdate, {\n\t\t\t\t\t\t\texcludeFromContext: command.excludeFromContext,\n\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\toperations: intercepted?.operations,\n\t\t\t\t\t\t\temitEvent: false,\n\t\t\t\t\t\t\trecordResult: false,\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\treturn createRpcSuccessResponse(id, \"user_bash\", result);\n\t\t\t}\n\t\t\tcase \"abort_bash\":\n\t\t\t\tbashOwners.abort(command.requestId);\n\t\t\t\tsession.abortBash(command.requestId);\n\t\t\t\treturn createRpcSuccessResponse(id, \"abort_bash\");\n\n\t\t\tcase \"get_session_stats\": {\n\t\t\t\treturn createRpcSuccessResponse(id, \"get_session_stats\", session.getSessionStats());\n\t\t\t}\n\n\t\t\tcase \"export_html\": {\n\t\t\t\tconst path = await session.exportToHtml(command.outputPath);\n\t\t\t\treturn createRpcSuccessResponse(id, \"export_html\", { path });\n\t\t\t}\n\n\t\t\tcase \"switch_session\": {\n\t\t\t\tconst result = await runtimeHost.switchSession(command.sessionPath, { cwdOverride: command.cwdOverride });\n\t\t\t\tif (!result.cancelled) {\n\t\t\t\t\tawait rebindSession();\n\t\t\t\t}\n\t\t\t\treturn createRpcSuccessResponse(id, \"switch_session\", result);\n\t\t\t}\n\n\t\t\tcase \"import_session\": {\n\t\t\t\tconst result = await runtimeHost.importFromJsonl(command.inputPath, command.cwdOverride);\n\t\t\t\tif (!result.cancelled) await rebindSession();\n\t\t\t\treturn createRpcSuccessResponse(id, \"import_session\", result);\n\t\t\t}\n\n\t\t\tcase \"fork\": {\n\t\t\t\tconst result = await runtimeHost.fork(command.entryId);\n\t\t\t\tif (!result.cancelled) {\n\t\t\t\t\tawait rebindSession();\n\t\t\t\t}\n\t\t\t\treturn createRpcSuccessResponse(id, \"fork\", { text: result.selectedText, cancelled: result.cancelled });\n\t\t\t}\n\n\t\t\tcase \"clone\": {\n\t\t\t\tconst leafId = session.sessionManager.getLeafId();\n\t\t\t\tif (!leafId) {\n\t\t\t\t\treturn createRpcErrorResponse(id, \"clone\", \"Cannot clone session: no current entry selected\");\n\t\t\t\t}\n\t\t\t\tconst result = await runtimeHost.fork(leafId, { position: \"at\" });\n\t\t\t\tif (!result.cancelled) {\n\t\t\t\t\tawait rebindSession();\n\t\t\t\t}\n\t\t\t\treturn createRpcSuccessResponse(id, \"clone\", { cancelled: result.cancelled });\n\t\t\t}\n\n\t\t\tcase \"get_fork_messages\": {\n\t\t\t\tconst messages = session.getUserMessagesForForking();\n\t\t\t\treturn createRpcSuccessResponse(id, \"get_fork_messages\", { messages });\n\t\t\t}\n\n\t\t\tcase \"get_entries\": {\n\t\t\t\tconst sessionManager = session.sessionManager;\n\t\t\t\tlet entries = sessionManager.getEntries();\n\t\t\t\tif (command.since !== undefined) {\n\t\t\t\t\tconst sinceIndex = entries.findIndex((e) => e.id === command.since);\n\t\t\t\t\tif (sinceIndex === -1) {\n\t\t\t\t\t\treturn createRpcErrorResponse(id, \"get_entries\", `Entry not found: ${command.since}`);\n\t\t\t\t\t}\n\t\t\t\t\tentries = entries.slice(sinceIndex + 1);\n\t\t\t\t}\n\t\t\t\treturn createRpcSuccessResponse(id, \"get_entries\", { entries, leafId: sessionManager.getLeafId() });\n\t\t\t}\n\n\t\t\tcase \"get_tree\": {\n\t\t\t\tconst sessionManager = session.sessionManager;\n\t\t\t\treturn createRpcSuccessResponse(id, \"get_tree\", {\n\t\t\t\t\ttree: sessionManager.getTree(),\n\t\t\t\t\tleafId: sessionManager.getLeafId(),\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tcase \"get_last_assistant_text\": {\n\t\t\t\tconst text = session.getLastAssistantText();\n\t\t\t\treturn createRpcSuccessResponse(id, \"get_last_assistant_text\", { text });\n\t\t\t}\n\n\t\t\tcase \"set_session_name\": {\n\t\t\t\tconst name = command.name.trim();\n\t\t\t\tif (!name) {\n\t\t\t\t\treturn createRpcErrorResponse(id, \"set_session_name\", \"Session name cannot be empty\");\n\t\t\t\t}\n\t\t\t\tsession.setSessionName(name);\n\t\t\t\treturn createRpcSuccessResponse(id, \"set_session_name\");\n\t\t\t}\n\n\t\t\tcase \"navigate_tree\": {\n\t\t\t\tconst result = await session.navigateTree(command.targetId, command.options);\n\t\t\t\treturn createRpcSuccessResponse(id, \"navigate_tree\", {\n\t\t\t\t\tcancelled: result.cancelled,\n\t\t\t\t\teditorText: result.editorText,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tcase \"set_label\": {\n\t\t\t\tsession.sessionManager.appendLabelChange(command.entryId, command.label);\n\t\t\t\treturn createRpcSuccessResponse(id, \"set_label\");\n\t\t\t}\n\n\t\t\tcase \"reload\": {\n\t\t\t\tif (retryFailedResources && reloadResources) await reloadResources();\n\t\t\t\telse if (reloadCoordinator) await reloadCoordinator.reload(session);\n\t\t\t\telse await session.reload();\n\t\t\t\treturn createRpcSuccessResponse(id, \"reload\");\n\t\t\t}\n\n\t\t\tcase \"get_shortcuts\": {\n\t\t\t\tconst effectiveBindings = getShortcutBindings();\n\t\t\t\tconst shortcuts = session.extensionRunner.getShortcuts(effectiveBindings);\n\t\t\t\treturn createRpcSuccessResponse(id, \"get_shortcuts\", {\n\t\t\t\t\tshortcuts: [...shortcuts].map(([key, shortcut]) => ({ key, description: shortcut.description })),\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tcase \"invoke_shortcut\": {\n\t\t\t\tconst shortcut = session.extensionRunner.getShortcuts(getShortcutBindings()).get(command.key as KeyId);\n\t\t\t\tif (!shortcut) return createRpcErrorResponse(id, \"invoke_shortcut\", `Shortcut not found: ${command.key}`);\n\t\t\t\tawait runCallback(\n\t\t\t\t\t{ kind: \"extension.hook\", name: `shortcut:${command.key}`, sourcePath: shortcut.extensionPath },\n\t\t\t\t\t() => shortcut.handler(session.extensionRunner.createContext()),\n\t\t\t\t);\n\t\t\t\treturn createRpcSuccessResponse(id, \"invoke_shortcut\");\n\t\t\t}\n\n\t\t\tcase \"get_messages\": {\n\t\t\t\treturn createRpcSuccessResponse(id, \"get_messages\", { messages: session.messages });\n\t\t\t}\n\n\t\t\tcase \"get_command_completions\": {\n\t\t\t\tconst registeredCommand = session.extensionRunner\n\t\t\t\t\t.getRegisteredCommands()\n\t\t\t\t\t.find((candidate) => candidate.invocationName === command.commandName);\n\t\t\t\tconst getArgumentCompletions = registeredCommand?.getArgumentCompletions;\n\t\t\t\tif (registeredCommand === undefined || getArgumentCompletions === undefined) {\n\t\t\t\t\treturn createRpcSuccessResponse(id, \"get_command_completions\", { completions: null });\n\t\t\t\t}\n\t\t\t\tconst completions = await runCallback(\n\t\t\t\t\t{\n\t\t\t\t\t\tkind: \"extension.hook\",\n\t\t\t\t\t\tname: `command-completions:${command.commandName}`,\n\t\t\t\t\t\tsourcePath: registeredCommand.sourceInfo.path,\n\t\t\t\t\t},\n\t\t\t\t\t() => getArgumentCompletions(command.argumentPrefix),\n\t\t\t\t);\n\t\t\t\treturn createRpcSuccessResponse(id, \"get_command_completions\", { completions });\n\t\t\t}\n\n\t\t\tcase \"get_commands\": {\n\t\t\t\tconst commands: RpcSlashCommand[] = [];\n\n\t\t\t\tfor (const registeredCommand of session.extensionRunner.getRegisteredCommands()) {\n\t\t\t\t\tcommands.push({\n\t\t\t\t\t\tname: registeredCommand.invocationName,\n\t\t\t\t\t\tdescription: registeredCommand.description,\n\t\t\t\t\t\t...(registeredCommand.getArgumentCompletions !== undefined ? { hasArgumentCompletions: true } : {}),\n\t\t\t\t\t\tsource: \"extension\",\n\t\t\t\t\t\tsourceInfo: registeredCommand.sourceInfo,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tfor (const template of session.promptTemplates) {\n\t\t\t\t\tcommands.push({\n\t\t\t\t\t\tname: template.name,\n\t\t\t\t\t\tdescription: template.description,\n\t\t\t\t\t\tsource: \"prompt\",\n\t\t\t\t\t\tsourceInfo: template.sourceInfo,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tfor (const skillCommand of getSkillCatalog(session.resourceLoader).commands) {\n\t\t\t\t\tcommands.push({\n\t\t\t\t\t\tname: `skill:${skillCommand.name}`,\n\t\t\t\t\t\tdescription: skillCommand.description,\n\t\t\t\t\t\tsource: \"skill\",\n\t\t\t\t\t\tsourceInfo: skillCommand.sourceInfo,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\treturn createRpcSuccessResponse(id, \"get_commands\", { commands });\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tconst unknownCommand = command as { type: string };\n\t\t\t\treturn createRpcErrorResponse(id, unknownCommand.type, `Unknown command: ${unknownCommand.type}`);\n\t\t\t}\n\t\t}\n\t}) as ManagedRpcCommandHandler;\n\thandleCommand.disposeActiveBash = () => bashOwners.dispose();\n\treturn handleCommand;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"rpc-command-handler.js","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-command-handler.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAGpE,OAAO,EAAE,+BAA+B,EAAE,MAAM,gCAAgC,CAAC;AACjF,OAAO,EAA2B,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAClF,OAAO,EACN,sBAAsB,EACtB,wBAAwB,EACxB,qBAAqB,GAErB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAoB9D,SAAS,6BAA6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gBAED,OAAO,wBAAwB,CAAC,EAAE,EAAE,cAAc,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;YACnE,CAAC;YACD,SAAS,CAAC;gBACT,MAAM,cAAc,GAAG,OAA2B,CAAC;gBACnD,OAAO,sBAAsB,CAAC,EAAE,EAAE,cAAc,CAAC,IAAI,EAAE,oBAAoB,cAAc,CAAC,IAAI,EAAE,CAAC,CAAC;YACnG,CAAC;QACF,CAAC;IACF,CAAC,CAA6B,CAAC;IAC/B,aAAa,CAAC,iBAAiB,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;IAC7D,OAAO,aAAa,CAAC;AACtB,CAAC","sourcesContent":["import type { KeyId } from \"@earendil-works/pi-tui\";\nimport type { AgentSession } from \"../../core/agent-session.js\";\nimport type { AgentSessionRuntime } from \"../../core/agent-session-runtime.ts\";\nimport { runCallback } from \"../../core/callback-activity.ts\";\nimport type { ExtensionUIContext } from \"../../core/extensions/index.js\";\nimport { KeybindingsManager } from \"../../core/keybindings.ts\";\nimport { getSkillCatalog } from \"../../core/skill-catalog.ts\";\nimport { RpcBashRequestOwners } from \"./rpc-bash-request-owners.ts\";\nimport type { RpcPendingExtensionRequests } from \"./rpc-extension-ui.ts\";\nimport type { KeybindingsReloadCoordinator } from \"./rpc-keybindings-reload.ts\";\nimport { rejectUnsupportedProviderPrompt } from \"./rpc-model-fallback-prompt.ts\";\nimport { type ProviderLoginInput, RpcProviderAuth } from \"./rpc-provider-auth.ts\";\nimport {\n\tcreateRpcErrorResponse,\n\tcreateRpcSuccessResponse,\n\tformatRpcErrorMessage,\n\ttype RpcOutput,\n} from \"./rpc-responses.ts\";\nimport type { RpcCommand, RpcResponse, RpcSessionState, RpcSlashCommand } from \"./rpc-types.ts\";\nimport { showEngineTaskInspector } from \"./task-ui-bridge.js\";\n\nexport type RpcCommandHandler = (command: RpcCommand) => Promise<RpcResponse | undefined>;\nexport type ManagedRpcCommandHandler = RpcCommandHandler & { disposeActiveBash(): Promise<void> };\n\ninterface RpcCommandHandlerOptions {\n\truntimeHost: AgentSessionRuntime;\n\tgetSession: () => AgentSession;\n\trebindSession: () => Promise<void>;\n\toutput: RpcOutput;\n\tkeybindings?: KeybindingsManager;\n\ttaskInspectorUi?: Pick<ExtensionUIContext, \"custom\">;\n\treloadCoordinator?: KeybindingsReloadCoordinator<AgentSession>;\n\tinputForm?: ProviderLoginInput;\n\tpendingExtensionRequests?: RpcPendingExtensionRequests;\n\twaitForResources?: () => Promise<void> | undefined;\n\treloadResources?: () => Promise<void>;\n\tshouldRetryResources?: () => boolean;\n}\n\nfunction canRunBeforeOptionalResources(command: RpcCommand): boolean {\n\tswitch (command.type) {\n\t\tcase \"abort\":\n\t\tcase \"abort_bash\":\n\t\tcase \"abort_compaction\":\n\t\tcase \"abort_retry\":\n\t\tcase \"cancel_login_provider\":\n\t\tcase \"clear_queue\":\n\t\tcase \"get_messages\":\n\t\tcase \"get_state\":\n\t\tcase \"pause_queued_messages\":\n\t\tcase \"resume_queued_messages\":\n\t\tcase \"set_auto_compaction\":\n\t\tcase \"set_auto_retry\":\n\t\tcase \"set_follow_up_mode\":\n\t\tcase \"set_steering_mode\":\n\t\t\treturn true;\n\t\tcase \"get_available_models\":\n\t\t\treturn command.allowPartialResources === true;\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\nexport function createRpcCommandHandler({\n\truntimeHost,\n\tgetSession,\n\trebindSession,\n\toutput,\n\tkeybindings,\n\ttaskInspectorUi,\n\treloadCoordinator,\n\tinputForm,\n\tpendingExtensionRequests,\n\twaitForResources,\n\treloadResources,\n\tshouldRetryResources,\n}: RpcCommandHandlerOptions): ManagedRpcCommandHandler {\n\tlet fallbackShortcutKeybindings: KeybindingsManager | undefined;\n\tconst providerAuth = new RpcProviderAuth(inputForm, {\n\t\toutput,\n\t\tpending: pendingExtensionRequests ?? new Map(),\n\t});\n\tconst bashOwners = new RpcBashRequestOwners(output);\n\tconst getShortcutBindings = () => {\n\t\tif (keybindings) return keybindings.getEffectiveConfig();\n\t\tif (fallbackShortcutKeybindings) fallbackShortcutKeybindings.reload();\n\t\telse fallbackShortcutKeybindings = KeybindingsManager.create(runtimeHost.services.agentDir);\n\t\treturn fallbackShortcutKeybindings.getEffectiveConfig();\n\t};\n\tconst handleCommand = (async (command: RpcCommand): Promise<RpcResponse | undefined> => {\n\t\tconst id = command.id;\n\t\tconst retryFailedResources = command.type === \"reload\" && shouldRetryResources?.() === true;\n\t\tif (command.type !== \"prompt\" && !retryFailedResources && !canRunBeforeOptionalResources(command)) {\n\t\t\tconst pendingResources = waitForResources?.();\n\t\t\tif (pendingResources) await pendingResources;\n\t\t}\n\t\tconst session = getSession();\n\t\tswitch (command.type) {\n\t\t\tcase \"open_task_inspector\": {\n\t\t\t\tif (!keybindings || !taskInspectorUi)\n\t\t\t\t\treturn createRpcErrorResponse(id, command.type, \"Task inspection requires an interactive host\");\n\t\t\t\tvoid showEngineTaskInspector(session, taskInspectorUi, command.taskId).catch((error: Error) =>\n\t\t\t\t\tsession.extensionRunner.getUIContext().notify(error.message, \"error\"),\n\t\t\t\t);\n\t\t\t\treturn createRpcSuccessResponse(id, command.type);\n\t\t\t}\n\t\t\tcase \"prompt\": {\n\t\t\t\tlet preflightSucceeded = false;\n\t\t\t\tvoid (async () => {\n\t\t\t\t\tconst pendingResources = waitForResources?.();\n\t\t\t\t\tif (pendingResources) await pendingResources;\n\t\t\t\t\tif (rejectUnsupportedProviderPrompt(runtimeHost, output, id)) return;\n\t\t\t\t\tconst promptSession = getSession();\n\t\t\t\t\tawait promptSession.prompt(command.message, {\n\t\t\t\t\t\timages: command.images,\n\t\t\t\t\t\tstreamingBehavior: command.streamingBehavior,\n\t\t\t\t\t\tsource: \"rpc\",\n\t\t\t\t\t\tpreflightResult: (didSucceed, disposition) => {\n\t\t\t\t\t\t\tif (didSucceed) {\n\t\t\t\t\t\t\t\tpreflightSucceeded = true;\n\t\t\t\t\t\t\t\toutput(createRpcSuccessResponse(id, \"prompt\", { disposition }));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t})().catch((promptError: unknown) => {\n\t\t\t\t\tif (!preflightSucceeded) {\n\t\t\t\t\t\toutput(createRpcErrorResponse(id, \"prompt\", formatRpcErrorMessage(promptError), promptError));\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tcase \"steer\": {\n\t\t\t\tconst disposition = await session.steer(command.message, command.images, { source: \"rpc\" });\n\t\t\t\treturn createRpcSuccessResponse(id, \"steer\", { disposition });\n\t\t\t}\n\n\t\t\tcase \"follow_up\": {\n\t\t\t\tconst disposition = await session.followUp(command.message, command.images, { source: \"rpc\" });\n\t\t\t\treturn createRpcSuccessResponse(id, \"follow_up\", { disposition });\n\t\t\t}\n\n\t\t\tcase \"abort\": {\n\t\t\t\tawait session.abort();\n\t\t\t\treturn createRpcSuccessResponse(id, \"abort\");\n\t\t\t}\n\t\t\tcase \"new_session\": {\n\t\t\t\tconst options = command.parentSession ? { parentSession: command.parentSession } : undefined;\n\t\t\t\tconst result = await runtimeHost.newSession(options);\n\t\t\t\tif (!result.cancelled) {\n\t\t\t\t\tawait rebindSession();\n\t\t\t\t}\n\t\t\t\treturn createRpcSuccessResponse(id, \"new_session\", result);\n\t\t\t}\n\n\t\t\tcase \"get_state\": {\n\t\t\t\tconst extensionResult = session.resourceLoader.getExtensions();\n\t\t\t\tconst state: RpcSessionState = {\n\t\t\t\t\tmodel: session.model,\n\t\t\t\t\tmodelFallbackMessage: runtimeHost.modelFallbackMessage,\n\t\t\t\t\tmodelFallbackReason: runtimeHost.modelFallbackReason,\n\t\t\t\t\tthinkingLevel: session.thinkingLevel,\n\t\t\t\t\tisStreaming: session.isStreaming,\n\t\t\t\t\tisCompacting: session.isCompacting,\n\t\t\t\t\tcompactionReason: session.compactionReason,\n\t\t\t\t\tsteeringMode: session.steeringMode,\n\t\t\t\t\tfollowUpMode: session.followUpMode,\n\t\t\t\t\tsessionFile: session.sessionFile,\n\t\t\t\t\tsessionId: session.sessionId,\n\t\t\t\t\tsessionName: session.sessionName,\n\t\t\t\t\tautoCompactionEnabled: session.autoCompactionEnabled,\n\t\t\t\t\tmessageCount: session.messages.length,\n\t\t\t\t\tpendingMessageCount: session.pendingMessageCount,\n\t\t\t\t\tqueuedMessagesPaused: session.queuedMessagesPaused,\n\t\t\t\t\tprojectTrusted: session.settingsManager.isProjectTrusted?.() === true,\n\t\t\t\t\tresourceOverlaps: extensionResult.overlaps ?? [],\n\t\t\t\t\tresourceExtensions: extensionResult.extensions.map((extension) => ({\n\t\t\t\t\t\tpath: extension.path,\n\t\t\t\t\t\tsourceInfo: extension.sourceInfo,\n\t\t\t\t\t\thidden: extension.hidden === true,\n\t\t\t\t\t})),\n\t\t\t\t};\n\t\t\t\treturn createRpcSuccessResponse(id, \"get_state\", state);\n\t\t\t}\n\t\t\tcase \"set_model\": {\n\t\t\t\tconst models = await session.modelRuntime.getAvailableSnapshot();\n\t\t\t\tconst model = models.find(\n\t\t\t\t\t(candidate) => candidate.provider === command.provider && candidate.id === command.modelId,\n\t\t\t\t);\n\t\t\t\tif (!model) {\n\t\t\t\t\treturn createRpcErrorResponse(\n\t\t\t\t\t\tid,\n\t\t\t\t\t\t\"set_model\",\n\t\t\t\t\t\t`Model not found: ${command.provider}/${command.modelId}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tawait session.setModel(model, command.persist === true ? { persist: true } : {});\n\t\t\t\truntimeHost.resolveModelFallback();\n\t\t\t\treturn createRpcSuccessResponse(id, \"set_model\", session.model ?? model);\n\t\t\t}\n\t\t\tcase \"cycle_model\": {\n\t\t\t\tconst previousModel = session.model;\n\t\t\t\tconst result = await session.cycleModel(\n\t\t\t\t\tcommand.direction,\n\t\t\t\t\tcommand.persist === true ? { persist: true } : {},\n\t\t\t\t);\n\t\t\t\truntimeHost.resolveModelFallbackAfterExplicitModelSelection(previousModel, result?.model);\n\t\t\t\treturn createRpcSuccessResponse(id, \"cycle_model\", result ?? null);\n\t\t\t}\n\t\t\tcase \"get_available_models\": {\n\t\t\t\tconst models = await session.modelRuntime.getAvailableSnapshot();\n\t\t\t\treturn createRpcSuccessResponse(id, \"get_available_models\", {\n\t\t\t\t\tmodels,\n\t\t\t\t\tscopedModels: session.scopedModels,\n\t\t\t\t\tcustomAuthProviders: [],\n\t\t\t\t\toauthProviders: session.modelRuntime.getOAuthProviderMetadata(),\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tcase \"login_provider\": {\n\t\t\t\tconst result =\n\t\t\t\t\tcommand.authType === \"oauth\"\n\t\t\t\t\t\t? await providerAuth.loginOAuth(session, command.provider, command.loginId)\n\t\t\t\t\t\t: await providerAuth.login(session, command.provider, command.loginId);\n\t\t\t\treturn createRpcSuccessResponse(id, \"login_provider\", result);\n\t\t\t}\n\n\t\t\tcase \"save_provider_credential\":\n\t\t\t\treturn createRpcSuccessResponse(\n\t\t\t\t\tid,\n\t\t\t\t\t\"save_provider_credential\",\n\t\t\t\t\tawait providerAuth.save(session, command.provider, command.credential, {\n\t\t\t\t\t\trefreshCatalog: command.refreshCatalog,\n\t\t\t\t\t}),\n\t\t\t\t);\n\n\t\t\tcase \"cancel_login_provider\":\n\t\t\t\tproviderAuth.cancel(command.provider, command.loginId);\n\t\t\t\treturn createRpcSuccessResponse(id, \"cancel_login_provider\");\n\n\t\t\tcase \"logout_provider\": {\n\t\t\t\tconst result = await runtimeHost.logoutProvider(command.provider);\n\t\t\t\treturn createRpcSuccessResponse(id, \"logout_provider\", result);\n\t\t\t}\n\t\t\tcase \"refresh_models\": {\n\t\t\t\tconst controller = command.timeoutMs === undefined ? undefined : new AbortController();\n\t\t\t\tconst timedOut = Symbol(\"model refresh timed out\");\n\t\t\t\tlet timeout: ReturnType<typeof setTimeout> | undefined;\n\t\t\t\tconst timeoutResult =\n\t\t\t\t\tcontroller && command.timeoutMs !== undefined\n\t\t\t\t\t\t? new Promise<typeof timedOut>((resolve) => {\n\t\t\t\t\t\t\t\ttimeout = setTimeout(() => {\n\t\t\t\t\t\t\t\t\tcontroller.abort();\n\t\t\t\t\t\t\t\t\tresolve(timedOut);\n\t\t\t\t\t\t\t\t}, command.timeoutMs);\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t: undefined;\n\t\t\t\ttry {\n\t\t\t\t\tconst refresh = (async () => {\n\t\t\t\t\t\tawait session.modelRuntime.reloadCredentials({ refreshAvailability: false });\n\t\t\t\t\t\tif (controller?.signal.aborted) return { aborted: true, errors: new Map<string, Error>() };\n\t\t\t\t\t\treturn session.modelRuntime.refresh({\n\t\t\t\t\t\t\tallowNetwork: command.allowNetwork,\n\t\t\t\t\t\t\tforce: command.force,\n\t\t\t\t\t\t\tsignal: controller?.signal,\n\t\t\t\t\t\t});\n\t\t\t\t\t})();\n\t\t\t\t\tconst outcome = timeoutResult ? await Promise.race([refresh, timeoutResult]) : await refresh;\n\t\t\t\t\tconst result = outcome === timedOut ? { aborted: true, errors: new Map<string, Error>() } : outcome;\n\t\t\t\t\treturn createRpcSuccessResponse(id, \"refresh_models\", {\n\t\t\t\t\t\taborted: result.aborted,\n\t\t\t\t\t\terrors: [...result.errors].map(([provider, error]) => ({ provider, message: error.message })),\n\t\t\t\t\t\tmodels: session.modelRuntime.getAvailableSnapshot(),\n\t\t\t\t\t\tscopedModels: session.scopedModels,\n\t\t\t\t\t\tcustomAuthProviders: [],\n\t\t\t\t\t\toauthProviders: session.modelRuntime.getOAuthProviderMetadata(),\n\t\t\t\t\t});\n\t\t\t\t} finally {\n\t\t\t\t\tif (timeout) clearTimeout(timeout);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tcase \"set_thinking_level\": {\n\t\t\t\tsession.setThinkingLevel(command.level, command.persist === true ? { persist: true } : {});\n\t\t\t\tconst model = session.model;\n\t\t\t\treturn createRpcSuccessResponse(id, \"set_thinking_level\", {\n\t\t\t\t\tlevel: session.thinkingLevel,\n\t\t\t\t\t...(model ? { provider: model.provider, modelId: model.id } : {}),\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tcase \"cycle_thinking_level\": {\n\t\t\t\tconst level = session.cycleThinkingLevel();\n\t\t\t\treturn createRpcSuccessResponse(id, \"cycle_thinking_level\", level ? { level } : null);\n\t\t\t}\n\n\t\t\tcase \"get_available_thinking_levels\": {\n\t\t\t\treturn createRpcSuccessResponse(id, \"get_available_thinking_levels\", {\n\t\t\t\t\tlevels: session.getAvailableThinkingLevels(),\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tcase \"set_steering_mode\": {\n\t\t\t\tsession.setSteeringMode(command.mode);\n\t\t\t\treturn createRpcSuccessResponse(id, \"set_steering_mode\");\n\t\t\t}\n\n\t\t\tcase \"set_follow_up_mode\": {\n\t\t\t\tsession.setFollowUpMode(command.mode);\n\t\t\t\treturn createRpcSuccessResponse(id, \"set_follow_up_mode\");\n\t\t\t}\n\n\t\t\tcase \"compact\": {\n\t\t\t\tconst result = await session.compact();\n\t\t\t\treturn createRpcSuccessResponse(id, \"compact\", result);\n\t\t\t}\n\n\t\t\tcase \"set_auto_compaction\":\n\t\t\t\tsession.setAutoCompactionEnabled(command.enabled);\n\t\t\t\treturn createRpcSuccessResponse(id, \"set_auto_compaction\");\n\t\t\tcase \"abort_compaction\":\n\t\t\t\tsession.abortCompaction();\n\t\t\t\treturn createRpcSuccessResponse(id, \"abort_compaction\");\n\t\t\tcase \"set_auto_retry\":\n\t\t\t\tsession.setAutoRetryEnabled(command.enabled);\n\t\t\t\treturn createRpcSuccessResponse(id, \"set_auto_retry\");\n\t\t\tcase \"abort_retry\":\n\t\t\t\tsession.abortRetry();\n\t\t\t\treturn createRpcSuccessResponse(id, \"abort_retry\");\n\n\t\t\tcase \"clear_queue\": {\n\t\t\t\treturn createRpcSuccessResponse(id, \"clear_queue\", session.clearQueue());\n\t\t\t}\n\t\t\tcase \"pause_queued_messages\":\n\t\t\t\tsession.pauseQueuedMessages();\n\t\t\t\treturn createRpcSuccessResponse(id, \"pause_queued_messages\");\n\t\t\tcase \"resume_queued_messages\":\n\t\t\t\treturn createRpcSuccessResponse(id, \"resume_queued_messages\", {\n\t\t\t\t\treleased: await session.resumeQueuedMessages(),\n\t\t\t\t});\n\t\t\tcase \"bash\": {\n\t\t\t\tconst result = await bashOwners.run(\n\t\t\t\t\t{\n\t\t\t\t\t\tid,\n\t\t\t\t\t\tsession,\n\t\t\t\t\t\tcommand: command.command,\n\t\t\t\t\t\texcludeFromContext: command.excludeFromContext,\n\t\t\t\t\t\tisCurrent: () => getSession() === session,\n\t\t\t\t\t},\n\t\t\t\t\t// A `bash` command is still a user-initiated shell request, so it must\n\t\t\t\t\t// reach `user_bash` handlers (sandboxes, remote shells) exactly like the\n\t\t\t\t\t// `user_bash` command does. Ownership, streaming correlation, and result\n\t\t\t\t\t// recording stay with the owning request either way.\n\t\t\t\t\tasync (onUpdate) => {\n\t\t\t\t\t\tconst intercepted = await session.extensionRunner.emitUserBash({\n\t\t\t\t\t\t\ttype: \"user_bash\",\n\t\t\t\t\t\t\tcommand: command.command,\n\t\t\t\t\t\t\texcludeFromContext: command.excludeFromContext === true,\n\t\t\t\t\t\t\tcwd: session.sessionManager.getCwd(),\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (intercepted?.result) return intercepted.result;\n\t\t\t\t\t\treturn session.executeBash(command.command, onUpdate, {\n\t\t\t\t\t\t\texcludeFromContext: command.excludeFromContext,\n\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\toperations: intercepted?.operations,\n\t\t\t\t\t\t\temitEvent: false,\n\t\t\t\t\t\t\trecordResult: false,\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\treturn createRpcSuccessResponse(id, \"bash\", result);\n\t\t\t}\n\t\t\tcase \"user_bash\": {\n\t\t\t\tconst result = await bashOwners.run(\n\t\t\t\t\t{\n\t\t\t\t\t\tid,\n\t\t\t\t\t\tsession,\n\t\t\t\t\t\tcommand: command.command,\n\t\t\t\t\t\texcludeFromContext: command.excludeFromContext,\n\t\t\t\t\t\tisCurrent: () => getSession() === session,\n\t\t\t\t\t},\n\t\t\t\t\tasync (onUpdate) => {\n\t\t\t\t\t\tconst intercepted = await session.extensionRunner.emitUserBash({\n\t\t\t\t\t\t\ttype: \"user_bash\",\n\t\t\t\t\t\t\tcommand: command.command,\n\t\t\t\t\t\t\texcludeFromContext: command.excludeFromContext === true,\n\t\t\t\t\t\t\tcwd: session.sessionManager.getCwd(),\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (intercepted?.result) return intercepted.result;\n\t\t\t\t\t\treturn session.executeBash(command.command, onUpdate, {\n\t\t\t\t\t\t\texcludeFromContext: command.excludeFromContext,\n\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\toperations: intercepted?.operations,\n\t\t\t\t\t\t\temitEvent: false,\n\t\t\t\t\t\t\trecordResult: false,\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\treturn createRpcSuccessResponse(id, \"user_bash\", result);\n\t\t\t}\n\t\t\tcase \"abort_bash\":\n\t\t\t\tbashOwners.abort(command.requestId);\n\t\t\t\tsession.abortBash(command.requestId);\n\t\t\t\treturn createRpcSuccessResponse(id, \"abort_bash\");\n\n\t\t\tcase \"get_session_stats\": {\n\t\t\t\treturn createRpcSuccessResponse(id, \"get_session_stats\", session.getSessionStats());\n\t\t\t}\n\n\t\t\tcase \"export_html\": {\n\t\t\t\tconst path = await session.exportToHtml(command.outputPath);\n\t\t\t\treturn createRpcSuccessResponse(id, \"export_html\", { path });\n\t\t\t}\n\n\t\t\tcase \"switch_session\": {\n\t\t\t\tconst result = await runtimeHost.switchSession(command.sessionPath, { cwdOverride: command.cwdOverride });\n\t\t\t\tif (!result.cancelled) {\n\t\t\t\t\tawait rebindSession();\n\t\t\t\t}\n\t\t\t\treturn createRpcSuccessResponse(id, \"switch_session\", result);\n\t\t\t}\n\n\t\t\tcase \"import_session\": {\n\t\t\t\tconst result = await runtimeHost.importFromJsonl(command.inputPath, command.cwdOverride);\n\t\t\t\tif (!result.cancelled) await rebindSession();\n\t\t\t\treturn createRpcSuccessResponse(id, \"import_session\", result);\n\t\t\t}\n\n\t\t\tcase \"fork\": {\n\t\t\t\tconst result = await runtimeHost.fork(command.entryId);\n\t\t\t\tif (!result.cancelled) {\n\t\t\t\t\tawait rebindSession();\n\t\t\t\t}\n\t\t\t\treturn createRpcSuccessResponse(id, \"fork\", { text: result.selectedText, cancelled: result.cancelled });\n\t\t\t}\n\n\t\t\tcase \"clone\": {\n\t\t\t\tconst leafId = session.sessionManager.getLeafId();\n\t\t\t\tif (!leafId) {\n\t\t\t\t\treturn createRpcErrorResponse(id, \"clone\", \"Cannot clone session: no current entry selected\");\n\t\t\t\t}\n\t\t\t\tconst result = await runtimeHost.fork(leafId, { position: \"at\" });\n\t\t\t\tif (!result.cancelled) {\n\t\t\t\t\tawait rebindSession();\n\t\t\t\t}\n\t\t\t\treturn createRpcSuccessResponse(id, \"clone\", { cancelled: result.cancelled });\n\t\t\t}\n\n\t\t\tcase \"get_fork_messages\": {\n\t\t\t\tconst messages = session.getUserMessagesForForking();\n\t\t\t\treturn createRpcSuccessResponse(id, \"get_fork_messages\", { messages });\n\t\t\t}\n\n\t\t\tcase \"get_entries\": {\n\t\t\t\tconst sessionManager = session.sessionManager;\n\t\t\t\tlet entries = sessionManager.getEntries();\n\t\t\t\tif (command.since !== undefined) {\n\t\t\t\t\tconst sinceIndex = entries.findIndex((e) => e.id === command.since);\n\t\t\t\t\tif (sinceIndex === -1) {\n\t\t\t\t\t\treturn createRpcErrorResponse(id, \"get_entries\", `Entry not found: ${command.since}`);\n\t\t\t\t\t}\n\t\t\t\t\tentries = entries.slice(sinceIndex + 1);\n\t\t\t\t}\n\t\t\t\treturn createRpcSuccessResponse(id, \"get_entries\", { entries, leafId: sessionManager.getLeafId() });\n\t\t\t}\n\n\t\t\tcase \"get_tree\": {\n\t\t\t\tconst sessionManager = session.sessionManager;\n\t\t\t\treturn createRpcSuccessResponse(id, \"get_tree\", {\n\t\t\t\t\ttree: sessionManager.getTree(),\n\t\t\t\t\tleafId: sessionManager.getLeafId(),\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tcase \"get_last_assistant_text\": {\n\t\t\t\tconst text = session.getLastAssistantText();\n\t\t\t\treturn createRpcSuccessResponse(id, \"get_last_assistant_text\", { text });\n\t\t\t}\n\n\t\t\tcase \"set_session_name\": {\n\t\t\t\tconst name = command.name.trim();\n\t\t\t\tif (!name) {\n\t\t\t\t\treturn createRpcErrorResponse(id, \"set_session_name\", \"Session name cannot be empty\");\n\t\t\t\t}\n\t\t\t\tsession.setSessionName(name);\n\t\t\t\treturn createRpcSuccessResponse(id, \"set_session_name\");\n\t\t\t}\n\n\t\t\tcase \"navigate_tree\": {\n\t\t\t\tconst result = await session.navigateTree(command.targetId, command.options);\n\t\t\t\treturn createRpcSuccessResponse(id, \"navigate_tree\", {\n\t\t\t\t\tcancelled: result.cancelled,\n\t\t\t\t\teditorText: result.editorText,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tcase \"set_label\": {\n\t\t\t\tsession.sessionManager.appendLabelChange(command.entryId, command.label);\n\t\t\t\treturn createRpcSuccessResponse(id, \"set_label\");\n\t\t\t}\n\n\t\t\tcase \"reload\": {\n\t\t\t\tif (retryFailedResources && reloadResources) await reloadResources();\n\t\t\t\telse if (reloadCoordinator) await reloadCoordinator.reload(session);\n\t\t\t\telse await session.reload();\n\t\t\t\treturn createRpcSuccessResponse(id, \"reload\");\n\t\t\t}\n\n\t\t\tcase \"get_shortcuts\": {\n\t\t\t\tconst effectiveBindings = getShortcutBindings();\n\t\t\t\tconst shortcuts = session.extensionRunner.getShortcuts(effectiveBindings);\n\t\t\t\treturn createRpcSuccessResponse(id, \"get_shortcuts\", {\n\t\t\t\t\tshortcuts: [...shortcuts].map(([key, shortcut]) => ({ key, description: shortcut.description })),\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tcase \"invoke_shortcut\": {\n\t\t\t\tconst shortcut = session.extensionRunner.getShortcuts(getShortcutBindings()).get(command.key as KeyId);\n\t\t\t\tif (!shortcut) return createRpcErrorResponse(id, \"invoke_shortcut\", `Shortcut not found: ${command.key}`);\n\t\t\t\tawait runCallback(\n\t\t\t\t\t{ kind: \"extension.hook\", name: `shortcut:${command.key}`, sourcePath: shortcut.extensionPath },\n\t\t\t\t\t() => shortcut.handler(session.extensionRunner.createContext()),\n\t\t\t\t);\n\t\t\t\treturn createRpcSuccessResponse(id, \"invoke_shortcut\");\n\t\t\t}\n\n\t\t\tcase \"get_messages\": {\n\t\t\t\treturn createRpcSuccessResponse(id, \"get_messages\", { messages: session.messages });\n\t\t\t}\n\n\t\t\tcase \"get_command_completions\": {\n\t\t\t\tconst registeredCommand = session.extensionRunner\n\t\t\t\t\t.getRegisteredCommands()\n\t\t\t\t\t.find((candidate) => candidate.invocationName === command.commandName);\n\t\t\t\tconst getArgumentCompletions = registeredCommand?.getArgumentCompletions;\n\t\t\t\tif (registeredCommand === undefined || getArgumentCompletions === undefined) {\n\t\t\t\t\treturn createRpcSuccessResponse(id, \"get_command_completions\", { completions: null });\n\t\t\t\t}\n\t\t\t\tconst completions = await runCallback(\n\t\t\t\t\t{\n\t\t\t\t\t\tkind: \"extension.hook\",\n\t\t\t\t\t\tname: `command-completions:${command.commandName}`,\n\t\t\t\t\t\tsourcePath: registeredCommand.sourceInfo.path,\n\t\t\t\t\t},\n\t\t\t\t\t() => getArgumentCompletions(command.argumentPrefix),\n\t\t\t\t);\n\t\t\t\treturn createRpcSuccessResponse(id, \"get_command_completions\", { completions });\n\t\t\t}\n\n\t\t\tcase \"get_commands\": {\n\t\t\t\tconst commands: RpcSlashCommand[] = [];\n\n\t\t\t\tfor (const registeredCommand of session.extensionRunner.getRegisteredCommands()) {\n\t\t\t\t\tcommands.push({\n\t\t\t\t\t\tname: registeredCommand.invocationName,\n\t\t\t\t\t\tdescription: registeredCommand.description,\n\t\t\t\t\t\t...(registeredCommand.getArgumentCompletions !== undefined ? { hasArgumentCompletions: true } : {}),\n\t\t\t\t\t\tsource: \"extension\",\n\t\t\t\t\t\tsourceInfo: registeredCommand.sourceInfo,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tfor (const template of session.promptTemplates) {\n\t\t\t\t\tcommands.push({\n\t\t\t\t\t\tname: template.name,\n\t\t\t\t\t\tdescription: template.description,\n\t\t\t\t\t\tsource: \"prompt\",\n\t\t\t\t\t\tsourceInfo: template.sourceInfo,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tfor (const skillCommand of getSkillCatalog(session.resourceLoader).commands) {\n\t\t\t\t\tcommands.push({\n\t\t\t\t\t\tname: `skill:${skillCommand.name}`,\n\t\t\t\t\t\tdescription: skillCommand.description,\n\t\t\t\t\t\tsource: \"skill\",\n\t\t\t\t\t\tsourceInfo: skillCommand.sourceInfo,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\treturn createRpcSuccessResponse(id, \"get_commands\", { commands });\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tconst unknownCommand = command as { type: string };\n\t\t\t\treturn createRpcErrorResponse(id, unknownCommand.type, `Unknown command: ${unknownCommand.type}`);\n\t\t\t}\n\t\t}\n\t}) as ManagedRpcCommandHandler;\n\thandleCommand.disposeActiveBash = () => bashOwners.dispose();\n\treturn handleCommand;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc-event-buffer.js","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-event-buffer.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,cAAc;
|
|
1
|
+
{"version":3,"file":"rpc-event-buffer.js","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-event-buffer.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,cAAc;IACT,OAAO,GAAG,IAAI,GAAG,EAAoB,CAAC;IAC/C,KAAK,CAA4C;IACxC,IAAI,CAA4B;IACjD,YAAY,IAA+B;QAC1C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IAClB,CAAC;IAED;;;;;;;;OAQG;IACH,OAAO,CAAC,KAAe;QACtB,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,KAAK,uBAAuB,CAAC,CAAC,CAAC,QAAQ,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;QAC5F,IAAI,CAAC,GAAG,EAAE,CAAC;YACV,IAAI,CAAC,KAAK,EAAE,CAAC;YACb,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACjB,OAAO;QACR,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC7B,IAAI,CAAC,KAAK,KAAK,UAAU,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;IACnD,CAAC;IAED,KAAK;QACJ,IAAI,IAAI,CAAC,KAAK;YAAE,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACzC,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;QACvB,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;YAAE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC5D,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;IAED,OAAO;QACN,IAAI,CAAC,KAAK,EAAE,CAAC;IACd,CAAC;CACD","sourcesContent":["import type { RpcEvent } from \"./rpc-types.ts\";\n\nexport class RpcEventBuffer {\n\tprivate readonly updates = new Map<string, RpcEvent>();\n\tprivate timer: ReturnType<typeof setTimeout> | undefined;\n\tprivate readonly emit: (event: RpcEvent) => void;\n\tconstructor(emit: (event: RpcEvent) => void) {\n\t\tthis.emit = emit;\n\t}\n\n\t/**\n\t * Coalescing keeps only the last event per key, so a type is coalescible\n\t * only when each event supersedes the previous one. `tool_execution_update`\n\t * qualifies: each carries the full `partialResult` so far, keyed per call.\n\t *\n\t * `message_update` does not. It carries an `assistantMessageEvent` delta,\n\t * and dropping a delta drops that text permanently, so it takes the\n\t * pass-through path below.\n\t */\n\tenqueue(event: RpcEvent): void {\n\t\tconst key = event.type === \"tool_execution_update\" ? `tool:${event.toolCallId}` : undefined;\n\t\tif (!key) {\n\t\t\tthis.flush();\n\t\t\tthis.emit(event);\n\t\t\treturn;\n\t\t}\n\t\tthis.updates.set(key, event);\n\t\tthis.timer ??= setTimeout(() => this.flush(), 16);\n\t}\n\n\tflush(): void {\n\t\tif (this.timer) clearTimeout(this.timer);\n\t\tthis.timer = undefined;\n\t\tfor (const event of this.updates.values()) this.emit(event);\n\t\tthis.updates.clear();\n\t}\n\n\tdispose(): void {\n\t\tthis.flush();\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc-generation-buffer.js","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-generation-buffer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,OAAO,gBAAgB;
|
|
1
|
+
{"version":3,"file":"rpc-generation-buffer.js","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-generation-buffer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,OAAO,gBAAgB;IACpB,OAAO,GAA4C,EAAE,CAAC;IAE9D,IAAI,IAAI;QACP,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IAC5B,CAAC;IAED,IAAI,CAAC,UAAkB,EAAE,KAAQ;QAChC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;IAC1C,CAAC;IAED,wFAAwF;IACxF,KAAK,CAAC,UAAkB;QACvB,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAClB,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,KAAK,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC/F,CAAC;IAED,2DAA2D;IAC3D,cAAc,CAAC,UAAkB;QAChC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,KAAK,UAAU,CAAC,CAAC;IAChF,CAAC;IAED,KAAK;QACJ,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;IACnB,CAAC;CACD","sourcesContent":["/**\n * Host-side frame buffer tagged with the engine generation that produced it.\n *\n * The interactive host buffers custom-UI frames and extension UI requests that\n * arrive before their controller subscribes. Without generation tags a frame\n * buffered by a child that has since died would be delivered to the live host\n * afterwards, remounting exactly the UI that death teardown just removed —\n * component IDs restart at `remote_component_1` for every child, so the stale\n * frame would also collide with the replacement's own mounts.\n */\nexport class GenerationBuffer<T> {\n\tprivate entries: Array<{ generation: number; value: T }> = [];\n\n\tget size(): number {\n\t\treturn this.entries.length;\n\t}\n\n\tpush(generation: number, value: T): void {\n\t\tthis.entries.push({ generation, value });\n\t}\n\n\t/** Take the entries owned by `generation`; anything else is dropped, never requeued. */\n\tdrain(generation: number): T[] {\n\t\tconst entries = this.entries;\n\t\tthis.entries = [];\n\t\treturn entries.filter((entry) => entry.generation === generation).map((entry) => entry.value);\n\t}\n\n\t/** Forget everything a now-dead generation left behind. */\n\tdropGeneration(generation: number): void {\n\t\tthis.entries = this.entries.filter((entry) => entry.generation !== generation);\n\t}\n\n\tclear(): void {\n\t\tthis.entries = [];\n\t}\n}\n"]}
|
|
@@ -12,8 +12,11 @@ function serializeBindings(config) {
|
|
|
12
12
|
* publishes only state from a committed successful reload.
|
|
13
13
|
*/
|
|
14
14
|
export class KeybindingsReloadCoordinator {
|
|
15
|
+
tail = Promise.resolve();
|
|
16
|
+
keybindings;
|
|
17
|
+
onCommitted;
|
|
18
|
+
resolveShortcuts;
|
|
15
19
|
constructor(keybindings, onCommitted, resolveShortcuts) {
|
|
16
|
-
this.tail = Promise.resolve();
|
|
17
20
|
this.keybindings = keybindings;
|
|
18
21
|
this.onCommitted = onCommitted;
|
|
19
22
|
this.resolveShortcuts = resolveShortcuts;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc-keybindings-reload.js","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-keybindings-reload.ts"],"names":[],"mappings":"AAYA,SAAS,iBAAiB,CAAC,MAAyB;IACnD,MAAM,UAAU,GAAkC,EAAE,CAAC;IACrD,KAAK,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACrD,IAAI,OAAO,KAAK,SAAS;YAAE,UAAU,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IAC9F,CAAC;IACD,OAAO,UAAU,CAAC;AACnB,CAAC;AAOD;;;;GAIG;AACH,MAAM,OAAO,4BAA4B;
|
|
1
|
+
{"version":3,"file":"rpc-keybindings-reload.js","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-keybindings-reload.ts"],"names":[],"mappings":"AAYA,SAAS,iBAAiB,CAAC,MAAyB;IACnD,MAAM,UAAU,GAAkC,EAAE,CAAC;IACrD,KAAK,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACrD,IAAI,OAAO,KAAK,SAAS;YAAE,UAAU,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CA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CAAC;YACvD,SAAS,EAAE,IAAI,CAAC,gBAAgB,EAAE,CAAC,OAAO,EAAE,iBAAiB,CAAC,IAAI,EAAE;SACpE,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,cAAc,CAAC,OAAiB;QAC7C,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACvB,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC;YACvB,OAAO,SAAS,CAAC;QAClB,CAAC;QAED,MAAM,oBAAoB,GAAG,IAAI,CAAC,WAAW,CAAC,eAAe,EAAE,CAAC;QAChE,IAAI,kBAAkB,GAAG,KAAK,CAAC;QAC/B,IAAI,CAAC;YACJ,MAAM,OAAO,CAAC,MAAM,CAAC;gBACpB,kBAAkB,EAAE,GAAG,EAAE;oBACxB,IAAI,CAAC,WAAY,CAAC,MAAM,EAAE,CAAC;oBAC3B,kBAAkB,GAAG,IAAI,CAAC;gBAC3B,CAAC;aACD,CAAC,CAAC;YACH,OAAO,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;QAC1C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,IAAI,kBAAkB;gBAAE,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,oBAAoB,CAAC,CAAC;YAC/E,MAAM,KAAK,CAAC;QACb,CAAC;IACF,CAAC;CACD;AAED,+EAA+E;AAC/E,MAAM,CAAC,KAAK,UAAU,4BAA4B,CACjD,OAA0B,EAC1B,WAA2C,EAC3C,qBAAkC;IAElC,MAAM,WAAW,GAAG,IAAI,4BAA4B,CACnD,WAAW,EACX,qBAAqB,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,qBAAqB,EAAE,CAAC,CAAC,CAAC,SAAS,CACjE,CAAC;IACF,MAAM,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AACnC,CAAC","sourcesContent":["import type { AgentSessionReloadOptions } from \"../../core/agent-session-types.js\";\nimport type { KeybindingsConfig, KeybindingsManager } from \"../../core/keybindings.ts\";\nimport type {\n\tEngineExtensionShortcut,\n\tEngineKeybindingState,\n\tSerializableKeybindingsConfig,\n} from \"../interactive-engine/protocol.ts\";\n\nexport interface ReloadableSession {\n\treload(options?: AgentSessionReloadOptions): Promise<void>;\n}\n\nfunction serializeBindings(config: KeybindingsConfig): SerializableKeybindingsConfig {\n\tconst serialized: SerializableKeybindingsConfig = {};\n\tfor (const [key, binding] of Object.entries(config)) {\n\t\tif (binding !== undefined) serialized[key] = Array.isArray(binding) ? [...binding] : binding;\n\t}\n\treturn serialized;\n}\n\ntype ShortcutCatalogResolver<TSession extends ReloadableSession> = (\n\tsession: TSession,\n\teffectiveBindings: KeybindingsConfig,\n) => EngineExtensionShortcut[];\n\n/**\n * Serializes the full keybinding/session reload transaction for one shared\n * manager. The queue survives rejection, mutates the manager in place, and\n * publishes only state from a committed successful reload.\n */\nexport class KeybindingsReloadCoordinator<TSession extends ReloadableSession = ReloadableSession> {\n\tprivate tail: Promise<void> = Promise.resolve();\n\tprivate readonly keybindings: KeybindingsManager | undefined;\n\tprivate readonly onCommitted: ((state: EngineKeybindingState) => void) | undefined;\n\tprivate readonly resolveShortcuts: ShortcutCatalogResolver<TSession> | undefined;\n\n\tconstructor(\n\t\tkeybindings: KeybindingsManager | undefined,\n\t\tonCommitted?: (state: EngineKeybindingState) => void,\n\t\tresolveShortcuts?: ShortcutCatalogResolver<TSession>,\n\t) {\n\t\tthis.keybindings = keybindings;\n\t\tthis.onCommitted = onCommitted;\n\t\tthis.resolveShortcuts = resolveShortcuts;\n\t}\n\n\treload(session: TSession): Promise<EngineKeybindingState | undefined> {\n\t\tconst transaction = this.tail.then(\n\t\t\t() => this.runTransaction(session),\n\t\t\t() => this.runTransaction(session),\n\t\t);\n\t\tthis.tail = transaction.then(\n\t\t\t() => {},\n\t\t\t() => {},\n\t\t);\n\t\treturn transaction;\n\t}\n\n\tpublishCurrentState(session: TSession): EngineKeybindingState | undefined {\n\t\tif (!this.keybindings) return undefined;\n\t\tconst state = this.createState(session);\n\t\tthis.onCommitted?.(state);\n\t\treturn state;\n\t}\n\n\tprivate createState(session: TSession): EngineKeybindingState {\n\t\tconst effectiveBindings = this.keybindings!.getEffectiveConfig();\n\t\treturn {\n\t\t\tuserBindings: serializeBindings(this.keybindings!.getUserBindings()),\n\t\t\teffectiveBindings: serializeBindings(effectiveBindings),\n\t\t\tshortcuts: this.resolveShortcuts?.(session, effectiveBindings) ?? [],\n\t\t};\n\t}\n\n\tprivate async runTransaction(session: TSession): Promise<EngineKeybindingState | undefined> {\n\t\tif (!this.keybindings) {\n\t\t\tawait session.reload();\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst previousUserBindings = this.keybindings.getUserBindings();\n\t\tlet keybindingsApplied = false;\n\t\ttry {\n\t\t\tawait session.reload({\n\t\t\t\tbeforeSessionStart: () => {\n\t\t\t\t\tthis.keybindings!.reload();\n\t\t\t\t\tkeybindingsApplied = true;\n\t\t\t\t},\n\t\t\t});\n\t\t\treturn this.publishCurrentState(session);\n\t\t} catch (error) {\n\t\t\tif (keybindingsApplied) this.keybindings.setUserBindings(previousUserBindings);\n\t\t\tthrow error;\n\t\t}\n\t}\n}\n\n/** Compatibility helper for callers that do not share a longer-lived queue. */\nexport async function reloadSessionWithKeybindings(\n\tsession: ReloadableSession,\n\tkeybindings: KeybindingsManager | undefined,\n\tonKeybindingsReloaded?: () => void,\n): Promise<void> {\n\tconst coordinator = new KeybindingsReloadCoordinator(\n\t\tkeybindings,\n\t\tonKeybindingsReloaded ? () => onKeybindingsReloaded() : undefined,\n\t);\n\tawait coordinator.reload(session);\n}\n"]}
|
|
@@ -3,10 +3,9 @@ export function serializeRpcOutputRecord(record) {
|
|
|
3
3
|
return `${JSON.stringify(record)}\n`;
|
|
4
4
|
}
|
|
5
5
|
export class RpcOutputBuffer {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
6
|
+
updates = new Map();
|
|
7
|
+
timer;
|
|
8
|
+
output = (record) => this.enqueue(record);
|
|
10
9
|
dispose() {
|
|
11
10
|
this.flush();
|
|
12
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc-output-buffer.js","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-output-buffer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAG5D,MAAM,UAAU,wBAAwB,CAAC,MAAuB;IAC/D,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC;AACtC,CAAC;AACD,MAAM,OAAO,eAAe;
|
|
1
|
+
{"version":3,"file":"rpc-output-buffer.js","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-output-buffer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAG5D,MAAM,UAAU,wBAAwB,CAAC,MAAuB;IAC/D,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC;AACtC,CAAC;AACD,MAAM,OAAO,eAAe;IACV,OAAO,GAAG,IAAI,GAAG,EAA2B,CAAC;IACtD,KAAK,CAA4C;IAChD,MAAM,GAAc,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAE9D,OAAO;QACN,IAAI,CAAC,KAAK,EAAE,CAAC;IACd,CAAC;IAED;;;;;;;;OAQG;IACK,OAAO,CAAC,MAAuB;QACtC,MAAM,KAAK,GAAG,MAAgD,CAAC;QAC/D,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,KAAK,uBAAuB,IAAI,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;QAChH,IAAI,GAAG,EAAE,CAAC;YACT,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;YAC9B,IAAI,CAAC,KAAK,KAAK,UAAU,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;YAClD,OAAO;QACR,CAAC;QACD,IAAI,CAAC,KAAK,EAAE,CAAC;QACb,cAAc,CAAC,wBAAwB,CAAC,MAAM,CAAC,CAAC,CAAC;IAClD,CAAC;IAEO,KAAK;QACZ,IAAI,IAAI,CAAC,KAAK;YAAE,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACzC,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;QACvB,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;YAAE,cAAc,CAAC,wBAAwB,CAAC,MAAM,CAAC,CAAC,CAAC;QAC7F,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;CACD","sourcesContent":["import { writeRawStdout } from \"../../core/output-guard.ts\";\nimport type { RpcOutput, RpcOutputRecord } from \"./rpc-responses.ts\";\n\nexport function serializeRpcOutputRecord(record: RpcOutputRecord): string {\n\treturn `${JSON.stringify(record)}\\n`;\n}\nexport class RpcOutputBuffer {\n\tprivate readonly updates = new Map<string, RpcOutputRecord>();\n\tprivate timer: ReturnType<typeof setTimeout> | undefined;\n\treadonly output: RpcOutput = (record) => this.enqueue(record);\n\n\tdispose(): void {\n\t\tthis.flush();\n\t}\n\n\t/**\n\t * Coalescing keeps only the last record per key, so a type is coalescible\n\t * only when each record supersedes the previous one. `tool_execution_update`\n\t * qualifies: each carries the full `partialResult` so far, keyed per call.\n\t *\n\t * `message_update` does not. It carries an `assistantMessageEvent` delta,\n\t * and dropping a delta drops that text permanently, so it takes the\n\t * pass-through path below.\n\t */\n\tprivate enqueue(record: RpcOutputRecord): void {\n\t\tconst event = record as { type?: string; toolCallId?: string };\n\t\tconst key = event.type === \"tool_execution_update\" && event.toolCallId ? `tool:${event.toolCallId}` : undefined;\n\t\tif (key) {\n\t\t\tthis.updates.set(key, record);\n\t\t\tthis.timer ??= setTimeout(() => this.flush(), 16);\n\t\t\treturn;\n\t\t}\n\t\tthis.flush();\n\t\twriteRawStdout(serializeRpcOutputRecord(record));\n\t}\n\n\tprivate flush(): void {\n\t\tif (this.timer) clearTimeout(this.timer);\n\t\tthis.timer = undefined;\n\t\tfor (const record of this.updates.values()) writeRawStdout(serializeRpcOutputRecord(record));\n\t\tthis.updates.clear();\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc-pending-requests.js","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-pending-requests.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAUpE;;;;;;;;GAQG;AACH,MAAM,OAAO,kBAAkB;
|
|
1
|
+
{"version":3,"file":"rpc-pending-requests.js","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-pending-requests.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAUpE;;;;;;;;GAQG;AACH,MAAM,OAAO,kBAAkB;IACb,OAAO,GAAG,IAAI,GAAG,EAA0B,CAAC;IAE7D,IAAI,IAAI;QACP,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;IAC1B,CAAC;IAED,GAAG,CAAC,EAAU,EAAE,QAA0C;QACzD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,QAAQ,EAAE,CAAC,CAAC;IACxD,CAAC;IAED,GAAG,CAAC,EAAU;QACb,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC7B,CAAC;IAED,MAAM,CAAC,EAAU;QAChB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACzB,CAAC;IAED,gFAAgF;IAChF,YAAY,CAAC,EAAU;QACtB,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACrC,IAAI,OAAO;YAAE,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IACtC,CAAC;IAED,kEAAkE;IAClE,OAAO,CAAC,EAAU,EAAE,QAAqB;QACxC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACrC,IAAI,CAAC,OAAO;YAAE,OAAO,KAAK,CAAC;QAC3B,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACxB,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAC1B,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;;;;;OAMG;IACH,SAAS,CAAC,KAAY;QACrB,MAAM,QAAQ,GAAG,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;QAC5C,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACrB,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAChC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,wBAAwB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAC5E,CAAC;IACF,CAAC;CACD","sourcesContent":["import { asAcceptedRequestFailure } from \"./rpc-transport-error.ts\";\nimport type { RpcResponse } from \"./rpc-types.ts\";\n\ninterface PendingRequest {\n\t/** True once the child announced it owns this request (`engine_request_accepted`). */\n\taccepted: boolean;\n\tresolve(response: RpcResponse): void;\n\treject(error: Error): void;\n}\n\n/**\n * In-flight RPC requests and their ownership state.\n *\n * Ownership decides whether a submission may be returned to the editor after\n * the transport dies: a request the child never took is still the user's text,\n * while one it had already started may have run side effects. Output cannot\n * answer that — a command can finish, having changed the working tree, and\n * print nothing.\n */\nexport class RpcPendingRequests {\n\tprivate readonly pending = new Map<string, PendingRequest>();\n\n\tget size(): number {\n\t\treturn this.pending.size;\n\t}\n\n\tadd(id: string, handlers: Omit<PendingRequest, \"accepted\">): void {\n\t\tthis.pending.set(id, { accepted: false, ...handlers });\n\t}\n\n\thas(id: string): boolean {\n\t\treturn this.pending.has(id);\n\t}\n\n\tdelete(id: string): void {\n\t\tthis.pending.delete(id);\n\t}\n\n\t/** Record the child's admission frame for a request that is still in flight. */\n\tmarkAccepted(id: string): void {\n\t\tconst request = this.pending.get(id);\n\t\tif (request) request.accepted = true;\n\t}\n\n\t/** Deliver a response, if the request is still ours to settle. */\n\tresolve(id: string, response: RpcResponse): boolean {\n\t\tconst request = this.pending.get(id);\n\t\tif (!request) return false;\n\t\tthis.pending.delete(id);\n\t\trequest.resolve(response);\n\t\treturn true;\n\t}\n\n\t/**\n\t * Fail everything in flight after transport loss.\n\t *\n\t * Accepted requests get their own copy of the failure, marked accepted, so a\n\t * single engine exit can reject an accepted and an unaccepted request with\n\t * honest, different classifications.\n\t */\n\trejectAll(error: Error): void {\n\t\tconst requests = [...this.pending.values()];\n\t\tthis.pending.clear();\n\t\tfor (const request of requests) {\n\t\t\trequest.reject(request.accepted ? asAcceptedRequestFailure(error) : error);\n\t\t}\n\t}\n}\n"]}
|
|
@@ -2,8 +2,10 @@ import { CredentialSynchronizationError } from "../../core/model-runtime.js";
|
|
|
2
2
|
import { createAuthInteraction, isOAuthLoginCancelled } from "../../core/oauth-login.js";
|
|
3
3
|
import { createRpcOAuthCallbacks } from "./rpc-oauth-interaction.js";
|
|
4
4
|
export class RpcProviderAuth {
|
|
5
|
+
controllers = new Map();
|
|
6
|
+
inputForm;
|
|
7
|
+
oauthTransport;
|
|
5
8
|
constructor(inputForm, oauthTransport) {
|
|
6
|
-
this.controllers = new Map();
|
|
7
9
|
this.inputForm = inputForm;
|
|
8
10
|
this.oauthTransport = oauthTransport;
|
|
9
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc-provider-auth.js","sourceRoot":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;QAC1D,IAAI,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,UAAU,KAAK,UAAU;YAAE,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAChG,CAAC;IACO,OAAO,CAAC,OAAqB;QACpC,OAAO;YACN,MAAM,EAAE,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,oBAAoB,EAAE,CAAC;YACxD,YAAY,EAAE,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC;YACvC,mBAAmB,EAAE,EAAE;YACvB,cAAc,EAAE,OAAO,CAAC,YAAY,CAAC,wBAAwB,EAAE;SAC/D,CAAC;IACH,CAAC;CACD","sourcesContent":["import type { Credential } from \"@bastani/pi-ai\";\nimport type { AgentSession } from \"../../core/agent-session.js\";\nimport type { HostInputFormRequest } from \"../../core/extensions/ui-types.js\";\nimport { CredentialSynchronizationError, type SaveCredentialOptions } from \"../../core/model-runtime.js\";\nimport { createAuthInteraction, isOAuthLoginCancelled } from \"../../core/oauth-login.ts\";\nimport { createRpcOAuthCallbacks, type OAuthInteractionTransport } from \"./rpc-oauth-interaction.ts\";\nimport type { RpcLoginProviderResult, RpcModelCatalog, RpcOAuthLoginProviderResult } from \"./rpc-types.ts\";\n\nexport interface ProviderLoginInput {\n\topen(request: HostInputFormRequest, signal?: AbortSignal): Promise<Record<string, string> | undefined>;\n}\ninterface ActiveLogin {\n\tprovider: string;\n\tcontroller: AbortController;\n}\n\nexport class RpcProviderAuth {\n\tprivate readonly controllers = new Map<string, ActiveLogin>();\n\tprivate readonly inputForm: ProviderLoginInput | undefined;\n\tprivate readonly oauthTransport: OAuthInteractionTransport | undefined;\n\tconstructor(inputForm?: ProviderLoginInput, oauthTransport?: OAuthInteractionTransport) {\n\t\tthis.inputForm = inputForm;\n\t\tthis.oauthTransport = oauthTransport;\n\t}\n\n\tasync login(session: AgentSession, provider: string, loginId = provider): Promise<RpcLoginProviderResult> {\n\t\tif (!session.modelRuntime.getProvider(provider)?.auth.apiKey)\n\t\t\tthrow new Error(`Provider does not support API-key login: ${provider}`);\n\t\tif (!this.inputForm) throw new Error(\"Provider login requires an interactive input host\");\n\t\tconst controller = this.begin(provider, loginId);\n\t\ttry {\n\t\t\tconst credential = await session.modelRuntime.login(provider, \"api_key\", {\n\t\t\t\tsignal: controller.signal,\n\t\t\t\tprompt: async (prompt) => {\n\t\t\t\t\tconst values = await this.inputForm!.open(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttitle: prompt.message,\n\t\t\t\t\t\t\theading: \"PROVIDER LOGIN\",\n\t\t\t\t\t\t\tsubmitLabel: \"[ Submit ]\",\n\t\t\t\t\t\t\tfields: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tname: \"value\",\n\t\t\t\t\t\t\t\t\ttype: \"string\",\n\t\t\t\t\t\t\t\t\trequired: false,\n\t\t\t\t\t\t\t\t\tinitialValue: \"\",\n\t\t\t\t\t\t\t\t\tplaceholder: \"placeholder\" in prompt ? prompt.placeholder : undefined,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t},\n\t\t\t\t\t\tcontroller.signal,\n\t\t\t\t\t);\n\t\t\t\t\tif (!values || controller.signal.aborted) throw new Error(\"Login cancelled\");\n\t\t\t\t\treturn values.value ?? \"\";\n\t\t\t\t},\n\t\t\t\tnotify: () => {},\n\t\t\t});\n\t\t\tif (controller.signal.aborted) return { provider, cancelled: true };\n\t\t\tif (credential.type !== \"api_key\")\n\t\t\t\tthrow new Error(`Provider returned an unexpected ${credential.type} credential`);\n\t\t\t// The key came from the host's own input form; it is confirmed by type\n\t\t\t// and never sent back down the stdout pipe.\n\t\t\treturn { provider, cancelled: false, type: \"api_key\", ...this.catalog(session) };\n\t\t} catch (error) {\n\t\t\tif (error instanceof CredentialSynchronizationError) throw error;\n\t\t\tif (controller.signal.aborted || (error instanceof Error && error.message === \"Login cancelled\"))\n\t\t\t\treturn { provider, cancelled: true };\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\tthis.finish(loginId, controller);\n\t\t}\n\t}\n\n\tasync loginOAuth(session: AgentSession, provider: string, loginId = provider): Promise<RpcOAuthLoginProviderResult> {\n\t\tif (!session.modelRuntime.getProvider(provider)?.auth.oauth)\n\t\t\tthrow new Error(`Unknown OAuth provider: ${provider}`);\n\t\tif (!this.oauthTransport) throw new Error(\"OAuth login requires an interactive host\");\n\t\tconst controller = this.begin(provider, loginId);\n\t\ttry {\n\t\t\tconst callbacks = createRpcOAuthCallbacks(provider, loginId, controller.signal, this.oauthTransport);\n\t\t\ttry {\n\t\t\t\tawait session.modelRuntime.login(provider, \"oauth\", createAuthInteraction(callbacks));\n\t\t\t} catch (error) {\n\t\t\t\tif (isOAuthLoginCancelled(error, controller.signal)) return { provider, cancelled: true };\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tif (controller.signal.aborted) return { provider, cancelled: true };\n\t\t\tsession.refreshCurrentModelFromRegistry();\n\t\t\treturn { provider, cancelled: false, ...this.catalog(session) };\n\t\t} finally {\n\t\t\tthis.finish(loginId, controller);\n\t\t}\n\t}\n\n\tasync save(\n\t\tsession: AgentSession,\n\t\tprovider: string,\n\t\tcredential: Credential,\n\t\toptions: SaveCredentialOptions = {},\n\t): Promise<RpcModelCatalog> {\n\t\tawait session.modelRuntime.saveCredential(provider, credential, options);\n\t\tsession.refreshCurrentModelFromRegistry();\n\t\treturn this.catalog(session);\n\t}\n\tcancel(provider: string, loginId?: string): void {\n\t\tif (loginId !== undefined) {\n\t\t\tconst active = this.controllers.get(loginId);\n\t\t\tif (active?.provider === provider) active.controller.abort();\n\t\t\treturn;\n\t\t}\n\t\tfor (const active of this.controllers.values()) if (active.provider === provider) active.controller.abort();\n\t}\n\tprivate begin(provider: string, loginId: string): AbortController {\n\t\tif ([...this.controllers.values()].some((active) => active.provider === provider))\n\t\t\tthrow new Error(`Login already in progress: ${provider}`);\n\t\tconst controller = new AbortController();\n\t\tthis.controllers.set(loginId, { provider, controller });\n\t\treturn controller;\n\t}\n\tprivate finish(loginId: string, controller: AbortController): void {\n\t\tif (this.controllers.get(loginId)?.controller === controller) this.controllers.delete(loginId);\n\t}\n\tprivate catalog(session: AgentSession): RpcModelCatalog {\n\t\treturn {\n\t\t\tmodels: [...session.modelRuntime.getAvailableSnapshot()],\n\t\t\tscopedModels: [...session.scopedModels],\n\t\t\tcustomAuthProviders: [],\n\t\t\toauthProviders: session.modelRuntime.getOAuthProviderMetadata(),\n\t\t};\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"rpc-provider-auth.js","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-provider-auth.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,8BAA8B,EAA8B,MAAM,6BAA6B,CAAC;AACzG,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AACzF,OAAO,EAAE,uBAAuB,EAAkC,MAAM,4BAA4B,CAAC;AAWrG,MAAM,OAAO,eAAe;IACV,WAAW,GAAG,IAAI,GAAG,EAAuB,CAAC;IAC7C,SAAS,CAAiC;IAC1C,cAAc,CAAwC;IACvE,YAAY,SAA8B,EAAE,cAA0C;QACrF,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACtC,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,OAAqB,EAAE,QAAgB,EAAE,OAAO,GAAG,QAAQ;QACtE,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,MAAM;YAC3D,MAAM,IAAI,KAAK,CAAC,4CAA4C,QAAQ,EAAE,CAAC,CAAC;QACzE,IAAI,CAAC,IAAI,CAAC,SAAS;YAAE,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;QAC1F,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,OAAO,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AAG,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,KAAK,QAAQ,CAAC;YAChF,MAAM,IAAI,KAAK,CAAC,8BAA8B,QAAQ,EAAE,CAAC,CAAC;QAC3D,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;QACzC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAC;QACxD,OAAO,UAAU,CAAC;IACnB,CAAC;IACO,MAAM,CAAC,OAAe,EAAE,UAA2B;QAC1D,IAAI,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,UAAU,KAAK,UAAU;YAAE,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAChG,CAAC;IACO,OAAO,CAAC,OAAqB;QACpC,OAAO;YACN,MAAM,EAAE,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,oBAAoB,EAAE,CAAC;YACxD,YAAY,EAAE,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC;YACvC,mBAAmB,EAAE,EAAE;YACvB,cAAc,EAAE,OAAO,CAAC,YAAY,CAAC,wBAAwB,EAAE;SAC/D,CAAC;IACH,CAAC;CACD","sourcesContent":["import type { Credential } from \"@bastani/pi-ai\";\nimport type { AgentSession } from \"../../core/agent-session.js\";\nimport type { HostInputFormRequest } from \"../../core/extensions/ui-types.js\";\nimport { CredentialSynchronizationError, type SaveCredentialOptions } from \"../../core/model-runtime.js\";\nimport { createAuthInteraction, isOAuthLoginCancelled } from \"../../core/oauth-login.ts\";\nimport { createRpcOAuthCallbacks, type OAuthInteractionTransport } from \"./rpc-oauth-interaction.ts\";\nimport type { RpcLoginProviderResult, RpcModelCatalog, RpcOAuthLoginProviderResult } from \"./rpc-types.ts\";\n\nexport interface ProviderLoginInput {\n\topen(request: HostInputFormRequest, signal?: AbortSignal): Promise<Record<string, string> | undefined>;\n}\ninterface ActiveLogin {\n\tprovider: string;\n\tcontroller: AbortController;\n}\n\nexport class RpcProviderAuth {\n\tprivate readonly controllers = new Map<string, ActiveLogin>();\n\tprivate readonly inputForm: ProviderLoginInput | undefined;\n\tprivate readonly oauthTransport: OAuthInteractionTransport | undefined;\n\tconstructor(inputForm?: ProviderLoginInput, oauthTransport?: OAuthInteractionTransport) {\n\t\tthis.inputForm = inputForm;\n\t\tthis.oauthTransport = oauthTransport;\n\t}\n\n\tasync login(session: AgentSession, provider: string, loginId = provider): Promise<RpcLoginProviderResult> {\n\t\tif (!session.modelRuntime.getProvider(provider)?.auth.apiKey)\n\t\t\tthrow new Error(`Provider does not support API-key login: ${provider}`);\n\t\tif (!this.inputForm) throw new Error(\"Provider login requires an interactive input host\");\n\t\tconst controller = this.begin(provider, loginId);\n\t\ttry {\n\t\t\tconst credential = await session.modelRuntime.login(provider, \"api_key\", {\n\t\t\t\tsignal: controller.signal,\n\t\t\t\tprompt: async (prompt) => {\n\t\t\t\t\tconst values = await this.inputForm!.open(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttitle: prompt.message,\n\t\t\t\t\t\t\theading: \"PROVIDER LOGIN\",\n\t\t\t\t\t\t\tsubmitLabel: \"[ Submit ]\",\n\t\t\t\t\t\t\tfields: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tname: \"value\",\n\t\t\t\t\t\t\t\t\ttype: \"string\",\n\t\t\t\t\t\t\t\t\trequired: false,\n\t\t\t\t\t\t\t\t\tinitialValue: \"\",\n\t\t\t\t\t\t\t\t\tplaceholder: \"placeholder\" in prompt ? prompt.placeholder : undefined,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t},\n\t\t\t\t\t\tcontroller.signal,\n\t\t\t\t\t);\n\t\t\t\t\tif (!values || controller.signal.aborted) throw new Error(\"Login cancelled\");\n\t\t\t\t\treturn values.value ?? \"\";\n\t\t\t\t},\n\t\t\t\tnotify: () => {},\n\t\t\t});\n\t\t\tif (controller.signal.aborted) return { provider, cancelled: true };\n\t\t\tif (credential.type !== \"api_key\")\n\t\t\t\tthrow new Error(`Provider returned an unexpected ${credential.type} credential`);\n\t\t\t// The key came from the host's own input form; it is confirmed by type\n\t\t\t// and never sent back down the stdout pipe.\n\t\t\treturn { provider, cancelled: false, type: \"api_key\", ...this.catalog(session) };\n\t\t} catch (error) {\n\t\t\tif (error instanceof CredentialSynchronizationError) throw error;\n\t\t\tif (controller.signal.aborted || (error instanceof Error && error.message === \"Login cancelled\"))\n\t\t\t\treturn { provider, cancelled: true };\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\tthis.finish(loginId, controller);\n\t\t}\n\t}\n\n\tasync loginOAuth(session: AgentSession, provider: string, loginId = provider): Promise<RpcOAuthLoginProviderResult> {\n\t\tif (!session.modelRuntime.getProvider(provider)?.auth.oauth)\n\t\t\tthrow new Error(`Unknown OAuth provider: ${provider}`);\n\t\tif (!this.oauthTransport) throw new Error(\"OAuth login requires an interactive host\");\n\t\tconst controller = this.begin(provider, loginId);\n\t\ttry {\n\t\t\tconst callbacks = createRpcOAuthCallbacks(provider, loginId, controller.signal, this.oauthTransport);\n\t\t\ttry {\n\t\t\t\tawait session.modelRuntime.login(provider, \"oauth\", createAuthInteraction(callbacks));\n\t\t\t} catch (error) {\n\t\t\t\tif (isOAuthLoginCancelled(error, controller.signal)) return { provider, cancelled: true };\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tif (controller.signal.aborted) return { provider, cancelled: true };\n\t\t\tsession.refreshCurrentModelFromRegistry();\n\t\t\treturn { provider, cancelled: false, ...this.catalog(session) };\n\t\t} finally {\n\t\t\tthis.finish(loginId, controller);\n\t\t}\n\t}\n\n\tasync save(\n\t\tsession: AgentSession,\n\t\tprovider: string,\n\t\tcredential: Credential,\n\t\toptions: SaveCredentialOptions = {},\n\t): Promise<RpcModelCatalog> {\n\t\tawait session.modelRuntime.saveCredential(provider, credential, options);\n\t\tsession.refreshCurrentModelFromRegistry();\n\t\treturn this.catalog(session);\n\t}\n\tcancel(provider: string, loginId?: string): void {\n\t\tif (loginId !== undefined) {\n\t\t\tconst active = this.controllers.get(loginId);\n\t\t\tif (active?.provider === provider) active.controller.abort();\n\t\t\treturn;\n\t\t}\n\t\tfor (const active of this.controllers.values()) if (active.provider === provider) active.controller.abort();\n\t}\n\tprivate begin(provider: string, loginId: string): AbortController {\n\t\tif ([...this.controllers.values()].some((active) => active.provider === provider))\n\t\t\tthrow new Error(`Login already in progress: ${provider}`);\n\t\tconst controller = new AbortController();\n\t\tthis.controllers.set(loginId, { provider, controller });\n\t\treturn controller;\n\t}\n\tprivate finish(loginId: string, controller: AbortController): void {\n\t\tif (this.controllers.get(loginId)?.controller === controller) this.controllers.delete(loginId);\n\t}\n\tprivate catalog(session: AgentSession): RpcModelCatalog {\n\t\treturn {\n\t\t\tmodels: [...session.modelRuntime.getAvailableSnapshot()],\n\t\t\tscopedModels: [...session.scopedModels],\n\t\t\tcustomAuthProviders: [],\n\t\t\toauthProviders: session.modelRuntime.getOAuthProviderMetadata(),\n\t\t};\n\t}\n}\n"]}
|
|
@@ -10,11 +10,10 @@ function createResourceGate() {
|
|
|
10
10
|
}
|
|
11
11
|
/** Retryable readiness gate for deferred interactive-engine resources. */
|
|
12
12
|
export class RpcResourceReadiness {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
13
|
+
gate = createResourceGate();
|
|
14
|
+
available = false;
|
|
15
|
+
failed = false;
|
|
16
|
+
attempt;
|
|
18
17
|
wait() {
|
|
19
18
|
return this.available ? undefined : this.gate.promise;
|
|
20
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc-resource-readiness.js","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-resource-readiness.ts"],"names":[],"mappings":"AAMA,SAAS,kBAAkB;IAC1B,IAAI,OAAoB,CAAC;IACzB,IAAI,MAA+B,CAAC;IACpC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAO,CAAC,cAAc,EAAE,aAAa,EAAE,EAAE;QACnE,OAAO,GAAG,cAAc,CAAC;QACzB,MAAM,GAAG,aAAa,CAAC;IACxB,CAAC,CAAC,CAAC;IACH,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IACxB,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AACrC,CAAC;AAED,0EAA0E;AAC1E,MAAM,OAAO,oBAAoB;
|
|
1
|
+
{"version":3,"file":"rpc-resource-readiness.js","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-resource-readiness.ts"],"names":[],"mappings":"AAMA,SAAS,kBAAkB;IAC1B,IAAI,OAAoB,CAAC;IACzB,IAAI,MAA+B,CAAC;IACpC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAO,CAAC,cAAc,EAAE,aAAa,EAAE,EAAE;QACnE,OAAO,GAAG,cAAc,CAAC;QACzB,MAAM,GAAG,aAAa,CAAC;IACxB,CAAC,CAAC,CAAC;IACH,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IACxB,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AACrC,CAAC;AAED,0EAA0E;AAC1E,MAAM,OAAO,oBAAoB;IACxB,IAAI,GAAG,kBAAkB,EAAE,CAAC;IAC5B,SAAS,GAAG,KAAK,CAAC;IAClB,MAAM,GAAG,KAAK,CAAC;IACf,OAAO,CAA4B;IAE3C,IAAI;QACH,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;IACvD,CAAC;IAED,UAAU;QACT,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IAED,GAAG,CAAC,IAAyB;QAC5B,IAAI,IAAI,CAAC,SAAS;YAAE,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;QAC7C,IAAI,IAAI,CAAC,OAAO;YAAE,OAAO,IAAI,CAAC,OAAO,CAAC;QACtC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,IAAI,CAAC,IAAI,GAAG,kBAAkB,EAAE,CAAC;YACjC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACrB,CAAC;QACD,MAAM,OAAO,GAAG,IAAI,EAAE,CAAC,IAAI,CAC1B,GAAG,EAAE;YACJ,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;YACtB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QACrB,CAAC,EACD,CAAC,KAAc,EAAE,EAAE;YAClB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;YACnB,MAAM,aAAa,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YAChF,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;YAChC,MAAM,aAAa,CAAC;QACrB,CAAC,CACD,CAAC;QACF,IAAI,OAAuB,CAAC;QAC5B,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE;YAC9B,IAAI,IAAI,CAAC,OAAO,KAAK,OAAO;gBAAE,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;QACxD,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,OAAO,OAAO,CAAC;IAChB,CAAC;CACD","sourcesContent":["interface ResourceGate {\n\treadonly promise: Promise<void>;\n\tresolve(): void;\n\treject(error: Error): void;\n}\n\nfunction createResourceGate(): ResourceGate {\n\tlet resolve!: () => void;\n\tlet reject!: (error: Error) => void;\n\tconst promise = new Promise<void>((resolvePromise, rejectPromise) => {\n\t\tresolve = resolvePromise;\n\t\treject = rejectPromise;\n\t});\n\tpromise.catch(() => {});\n\treturn { promise, resolve, reject };\n}\n\n/** Retryable readiness gate for deferred interactive-engine resources. */\nexport class RpcResourceReadiness {\n\tprivate gate = createResourceGate();\n\tprivate available = false;\n\tprivate failed = false;\n\tprivate attempt: Promise<void> | undefined;\n\n\twait(): Promise<void> | undefined {\n\t\treturn this.available ? undefined : this.gate.promise;\n\t}\n\n\tneedsRetry(): boolean {\n\t\treturn this.failed;\n\t}\n\n\trun(load: () => Promise<void>): Promise<void> {\n\t\tif (this.available) return Promise.resolve();\n\t\tif (this.attempt) return this.attempt;\n\t\tif (this.failed) {\n\t\t\tthis.gate = createResourceGate();\n\t\t\tthis.failed = false;\n\t\t}\n\t\tconst attempt = load().then(\n\t\t\t() => {\n\t\t\t\tthis.available = true;\n\t\t\t\tthis.gate.resolve();\n\t\t\t},\n\t\t\t(error: unknown) => {\n\t\t\t\tthis.failed = true;\n\t\t\t\tconst resourceError = error instanceof Error ? error : new Error(String(error));\n\t\t\t\tthis.gate.reject(resourceError);\n\t\t\t\tthrow resourceError;\n\t\t\t},\n\t\t);\n\t\tlet tracked!: Promise<void>;\n\t\ttracked = attempt.finally(() => {\n\t\t\tif (this.attempt === tracked) this.attempt = undefined;\n\t\t});\n\t\tthis.attempt = tracked;\n\t\treturn tracked;\n\t}\n}\n"]}
|
|
@@ -5,6 +5,21 @@ import { toJsonEvent } from "../json-event.js";
|
|
|
5
5
|
import { createRpcExtensionUIContext } from "./rpc-extension-ui.js";
|
|
6
6
|
import { bindEngineTaskWidget } from "./task-ui-bridge.js";
|
|
7
7
|
export class RpcSessionBinding {
|
|
8
|
+
session;
|
|
9
|
+
boundRunner;
|
|
10
|
+
unsubscribe;
|
|
11
|
+
unsubscribeBackpressure;
|
|
12
|
+
unsubscribeTasks;
|
|
13
|
+
runtimeHost;
|
|
14
|
+
output;
|
|
15
|
+
pendingExtensionRequests;
|
|
16
|
+
customUi;
|
|
17
|
+
renderService;
|
|
18
|
+
sessionPicker;
|
|
19
|
+
inputForm;
|
|
20
|
+
requestShutdown;
|
|
21
|
+
reloadCoordinator;
|
|
22
|
+
footerDataProvider;
|
|
8
23
|
constructor({ runtimeHost, output, pendingExtensionRequests, requestShutdown, customUi, renderService, sessionPicker, inputForm, reloadCoordinator, }) {
|
|
9
24
|
this.runtimeHost = runtimeHost;
|
|
10
25
|
this.output = output;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc-session-binding.js","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-session-binding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAIhE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;AAK1E,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,2BAA2B,EAAoC,MAAM,uBAAuB,CAAC;AAGtG,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAc3D,MAAM,OAAO,iBAAiB;IAiB7B,YAAY,EACX,WAAW,EACX,MAAM,EACN,wBAAwB,EACxB,eAAe,EACf,QAAQ,EACR,aAAa,EACb,aAAa,EACb,SAAS,EACT,iBAAiB,GACS;QAC1B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,wBAAwB,GAAG,wBAAwB,CAAC;QACzD,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,iBAAiB,GAAG,iB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AI,EAAE,iBAAiB;oBACvB,aAAa,EAAE,cAAc,CAAC,IAAI;oBAClC,KAAK,EAAE,SAAS;oBAChB,KAAK,EAAE,cAAc,CAAC,KAAK;iBAC3B,CAAC,CAAC;YACJ,CAAC;YACD,MAAM,KAAK,CAAC;QACb,CAAC;QACD,IAAI,OAAO,KAAK,IAAI,CAAC,OAAO;YAAE,OAAO;QACrC,IAAI,CAAC,iBAAiB,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACtD,CAAC;IAED,oBAAoB;QACnB,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;QAC7B,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;QACrB,IAAI,CAAC,uBAAuB,EAAE,EAAE,CAAC;QACjC,IAAI,CAAC,gBAAgB,EAAE,EAAE,CAAC;QAC1B,IAAI,CAAC,gBAAgB,GAAG,SAAS,CAAC;QAClC,IAAI,CAAC,kBAAkB,EAAE,OAAO,EAAE,CAAC;QACnC,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;QAC7B,IAAI,CAAC,uBAAuB,GAAG,SAAS,CAAC;QACzC,IAAI,CAAC,kBAAkB,GAAG,SAAS,CAAC;IACrC,CAAC;CACD","sourcesContent":["import { setCapabilityOverrides } from \"@earendil-works/pi-tui\";\nimport type { AgentSession } from \"../../core/agent-session.js\";\nimport type { AgentSessionRuntime } from \"../../core/agent-session-runtime.ts\";\nimport type { ProjectTrustContext } from \"../../core/extensions/index.js\";\nimport { FooterDataProvider } from \"../../core/footer-data-provider.ts\";\nimport { waitForRawStdoutBackpressure } from \"../../core/output-guard.ts\";\nimport type { EngineCustomUiService } from \"../interactive-engine/engine-custom-ui.ts\";\nimport type { EngineInputFormService } from \"../interactive-engine/engine-input-form.ts\";\nimport type { EngineRenderService } from \"../interactive-engine/engine-render-service.ts\";\nimport type { EngineSessionPickerService } from \"../interactive-engine/engine-session-picker.ts\";\nimport { toJsonEvent } from \"../json-event.ts\";\nimport { createRpcExtensionUIContext, type RpcPendingExtensionRequests } from \"./rpc-extension-ui.ts\";\nimport type { KeybindingsReloadCoordinator } from \"./rpc-keybindings-reload.ts\";\nimport type { RpcOutput } from \"./rpc-responses.ts\";\nimport { bindEngineTaskWidget } from \"./task-ui-bridge.js\";\n\ninterface RpcSessionBindingOptions {\n\truntimeHost: AgentSessionRuntime;\n\toutput: RpcOutput;\n\tpendingExtensionRequests: RpcPendingExtensionRequests;\n\tcustomUi?: EngineCustomUiService;\n\trenderService?: EngineRenderService;\n\tsessionPicker?: EngineSessionPickerService;\n\tinputForm?: EngineInputFormService;\n\trequestShutdown: () => void;\n\treloadCoordinator?: KeybindingsReloadCoordinator<AgentSession>;\n}\n\nexport class RpcSessionBinding {\n\tprivate session: AgentSession;\n\tprivate boundRunner: AgentSession[\"extensionRunner\"] | undefined;\n\tprivate unsubscribe?: () => void;\n\tprivate unsubscribeBackpressure?: () => void;\n\tprivate unsubscribeTasks?: () => void;\n\tprivate readonly runtimeHost: AgentSessionRuntime;\n\tprivate readonly output: RpcOutput;\n\tprivate readonly pendingExtensionRequests: RpcPendingExtensionRequests;\n\tprivate readonly customUi: EngineCustomUiService | undefined;\n\tprivate readonly renderService: EngineRenderService | undefined;\n\tprivate readonly sessionPicker: EngineSessionPickerService | undefined;\n\tprivate readonly inputForm: EngineInputFormService | undefined;\n\tprivate readonly requestShutdown: () => void;\n\tprivate readonly reloadCoordinator: KeybindingsReloadCoordinator<AgentSession> | undefined;\n\n\tprivate footerDataProvider: FooterDataProvider | undefined;\n\tconstructor({\n\t\truntimeHost,\n\t\toutput,\n\t\tpendingExtensionRequests,\n\t\trequestShutdown,\n\t\tcustomUi,\n\t\trenderService,\n\t\tsessionPicker,\n\t\tinputForm,\n\t\treloadCoordinator,\n\t}: RpcSessionBindingOptions) {\n\t\tthis.runtimeHost = runtimeHost;\n\t\tthis.output = output;\n\t\tthis.pendingExtensionRequests = pendingExtensionRequests;\n\t\tthis.requestShutdown = requestShutdown;\n\t\tthis.customUi = customUi;\n\t\tthis.renderService = renderService;\n\t\tthis.sessionPicker = sessionPicker;\n\t\tthis.inputForm = inputForm;\n\t\tthis.reloadCoordinator = reloadCoordinator;\n\t\tthis.session = runtimeHost.session;\n\t\tthis.runtimeHost.setProjectTrustContextFactory?.((cwd) => this.createProjectTrustContext(cwd));\n\t}\n\n\tprivate createProjectTrustContext(cwd: string): ProjectTrustContext {\n\t\tconst runner = this.runtimeHost.session.extensionRunner;\n\t\tconst ui = runner.getUIContext();\n\t\tconst hasUI = this.customUi !== undefined;\n\t\treturn {\n\t\t\tcwd,\n\t\t\tmode: hasUI ? \"tui\" : \"rpc\",\n\t\t\thasUI,\n\t\t\tui: {\n\t\t\t\tselect: (title, options, opts) =>\n\t\t\t\t\thasUI\n\t\t\t\t\t\t? runner.withProjectTrustPrompt(\"select\", title, () => ui.select(title, options, opts))\n\t\t\t\t\t\t: Promise.resolve(undefined),\n\t\t\t\tconfirm: (title, message, opts) =>\n\t\t\t\t\thasUI\n\t\t\t\t\t\t? runner.withProjectTrustPrompt(\"confirm\", title, () => ui.confirm(title, message, opts))\n\t\t\t\t\t\t: Promise.resolve(false),\n\t\t\t\tinput: (title, placeholder, opts) =>\n\t\t\t\t\thasUI\n\t\t\t\t\t\t? runner.withProjectTrustPrompt(\"input\", title, () => ui.input(title, placeholder, opts))\n\t\t\t\t\t\t: Promise.resolve(undefined),\n\t\t\t\tnotify: (message, type) => ui.notify(message, type),\n\t\t\t},\n\t\t};\n\t}\n\n\tget currentSession(): AgentSession {\n\t\treturn this.session;\n\t}\n\n\tasync rebindSession(): Promise<void> {\n\t\tif (this.session === this.runtimeHost.session && this.boundRunner === this.session.extensionRunner) return;\n\t\tthis.session = this.runtimeHost.session;\n\t\tthis.disposeSubscriptions();\n\t\tconst session = this.session;\n\t\tsetCapabilityOverrides(session.settingsManager.getTerminalCapabilityOverrides());\n\t\tthis.renderService?.bindSession(session);\n\t\tthis.footerDataProvider = new FooterDataProvider(session.sessionManager.getCwd());\n\t\t// Seed the provider count from the current catalog snapshot, mirroring\n\t\t// updateProviderCountFromSnapshot() in interactive startup, so the\n\t\t// embedded footer shows the (provider) model prefix in multi-provider\n\t\t// sessions instead of defaulting to 0.\n\t\tconst models =\n\t\t\tsession.scopedModels.length > 0\n\t\t\t\t? session.scopedModels.map((scoped) => scoped.model)\n\t\t\t\t: session.modelRuntime.getAvailableSnapshot();\n\t\tthis.footerDataProvider.setAvailableProviderCount(new Set(models.map((model) => model.provider)).size);\n\n\t\ttry {\n\t\t\tawait session.bindExtensions({\n\t\t\t\tuiContext: createRpcExtensionUIContext({\n\t\t\t\t\toutput: this.output,\n\t\t\t\t\tpendingExtensionRequests: this.pendingExtensionRequests,\n\t\t\t\t\tcustomUi: this.customUi,\n\t\t\t\t\tsessionPicker: this.sessionPicker,\n\t\t\t\t\tinputForm: this.inputForm,\n\t\t\t\t\tfooterDataProvider: this.footerDataProvider,\n\t\t\t\t}),\n\t\t\t\tmode: this.customUi ? \"tui\" : \"rpc\",\n\t\t\t\tcommandContextActions: {\n\t\t\t\t\twaitForIdle: () => this.session.agent.waitForIdle(),\n\t\t\t\t\tnewSession: async (options) => this.runtimeHost.newSession(options),\n\t\t\t\t\tfork: async (entryId, forkOptions) => {\n\t\t\t\t\t\tconst result = await this.runtimeHost.fork(entryId, forkOptions);\n\t\t\t\t\t\treturn { cancelled: result.cancelled };\n\t\t\t\t\t},\n\t\t\t\t\tnavigateTree: async (targetId, options) => {\n\t\t\t\t\t\tconst result = await this.session.navigateTree(targetId, {\n\t\t\t\t\t\t\tsummarize: options?.summarize,\n\t\t\t\t\t\t\tcustomInstructions: options?.customInstructions,\n\t\t\t\t\t\t\treplaceInstructions: options?.replaceInstructions,\n\t\t\t\t\t\t\tlabel: options?.label,\n\t\t\t\t\t\t});\n\t\t\t\t\t\treturn { cancelled: result.cancelled };\n\t\t\t\t\t},\n\t\t\t\t\tswitchSession: async (sessionPath, options) => {\n\t\t\t\t\t\treturn this.runtimeHost.switchSession(sessionPath, options);\n\t\t\t\t\t},\n\t\t\t\t\treload: async () => {\n\t\t\t\t\t\tconst steeringMode = this.session.steeringMode;\n\t\t\t\t\t\tconst followUpMode = this.session.followUpMode;\n\t\t\t\t\t\tif (this.reloadCoordinator) await this.reloadCoordinator.reload(this.session);\n\t\t\t\t\t\telse await this.session.reload();\n\t\t\t\t\t\tthis.session.setSteeringMode(steeringMode);\n\t\t\t\t\t\tthis.session.setFollowUpMode(followUpMode);\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tshutdownHandler: this.requestShutdown,\n\t\t\t\tonError: (err) => {\n\t\t\t\t\tthis.output({\n\t\t\t\t\t\ttype: \"extension_error\",\n\t\t\t\t\t\textensionPath: err.extensionPath,\n\t\t\t\t\t\tevent: err.event,\n\t\t\t\t\t\terror: err.error,\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t});\n\t\t\tthis.footerDataProvider.startGitWatcher();\n\t\t} catch (error) {\n\t\t\t// Leave no partially-initialized footer state behind if extension\n\t\t\t// binding fails; dispose the provider and rethrow.\n\t\t\tthis.footerDataProvider.dispose();\n\t\t\tthis.footerDataProvider = undefined;\n\t\t\tthrow error;\n\t\t}\n\n\t\tif (this.customUi) this.unsubscribeTasks = bindEngineTaskWidget(session, session.extensionRunner.getUIContext());\n\t\tthis.unsubscribe = session.subscribe((event) => {\n\t\t\tthis.output(toJsonEvent(event));\n\t\t});\n\t\tthis.unsubscribeBackpressure = session.agent.subscribe(async () => {\n\t\t\tawait waitForRawStdoutBackpressure();\n\t\t});\n\t\tthis.reloadCoordinator?.publishCurrentState(session);\n\t\tthis.boundRunner = session.extensionRunner;\n\t}\n\n\t/** Load and atomically publish the optional resource set after the minimal interactive engine binds. */\n\tasync loadDeferredResources(): Promise<void> {\n\t\tconst session = this.session;\n\t\ttry {\n\t\t\tif (!(await this.runtimeHost.completeStartup?.())) {\n\t\t\t\tawait session.reload({ reason: \"startup\", failOnExtensionErrors: true });\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tfor (const extensionError of session.resourceLoader.getExtensions().errors) {\n\t\t\t\tthis.output({\n\t\t\t\t\ttype: \"extension_error\",\n\t\t\t\t\textensionPath: extensionError.path,\n\t\t\t\t\tevent: \"startup\",\n\t\t\t\t\terror: extensionError.error,\n\t\t\t\t});\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t\tif (session !== this.session) return;\n\t\tthis.reloadCoordinator?.publishCurrentState(session);\n\t}\n\n\tdisposeSubscriptions(): void {\n\t\tthis.boundRunner = undefined;\n\t\tthis.unsubscribe?.();\n\t\tthis.unsubscribeBackpressure?.();\n\t\tthis.unsubscribeTasks?.();\n\t\tthis.unsubscribeTasks = undefined;\n\t\tthis.footerDataProvider?.dispose();\n\t\tthis.unsubscribe = undefined;\n\t\tthis.unsubscribeBackpressure = undefined;\n\t\tthis.footerDataProvider = undefined;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"rpc-session-binding.js","sourceRoot":"","sources":["../../../src/modes/rpc/rpc-session-binding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAIhE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;AAK1E,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,2BAA2B,EAAoC,MAAM,uBAAuB,CAAC;AAGtG,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAc3D,MAAM,OAAO,iBAAiB;IACrB,OAAO,CAAe;IACtB,WAAW,CAA8C;IACzD,WAAW,CAAc;IACzB,uBAAuB,CAAc;IACrC,gBAAgB,CAAc;IACrB,WAAW,CAAsB;IACjC,MAAM,CAAY;IAClB,wBAAwB,CAA8B;IACtD,QAAQ,CAAoC;IAC5C,aAAa,CAAkC;IAC/C,aAAa,CAAyC;IACtD,SAAS,CAAqC;IAC9C,eAAe,CAAa;I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AC;QACzC,IAAI,CAAC,kBAAkB,GAAG,SAAS,CAAC;IACrC,CAAC;CACD","sourcesContent":["import { setCapabilityOverrides } from \"@earendil-works/pi-tui\";\nimport type { AgentSession } from \"../../core/agent-session.js\";\nimport type { AgentSessionRuntime } from \"../../core/agent-session-runtime.ts\";\nimport type { ProjectTrustContext } from \"../../core/extensions/index.js\";\nimport { FooterDataProvider } from \"../../core/footer-data-provider.ts\";\nimport { waitForRawStdoutBackpressure } from \"../../core/output-guard.ts\";\nimport type { EngineCustomUiService } from \"../interactive-engine/engine-custom-ui.ts\";\nimport type { EngineInputFormService } from \"../interactive-engine/engine-input-form.ts\";\nimport type { EngineRenderService } from \"../interactive-engine/engine-render-service.ts\";\nimport type { EngineSessionPickerService } from \"../interactive-engine/engine-session-picker.ts\";\nimport { toJsonEvent } from \"../json-event.ts\";\nimport { createRpcExtensionUIContext, type RpcPendingExtensionRequests } from \"./rpc-extension-ui.ts\";\nimport type { KeybindingsReloadCoordinator } from \"./rpc-keybindings-reload.ts\";\nimport type { RpcOutput } from \"./rpc-responses.ts\";\nimport { bindEngineTaskWidget } from \"./task-ui-bridge.js\";\n\ninterface RpcSessionBindingOptions {\n\truntimeHost: AgentSessionRuntime;\n\toutput: RpcOutput;\n\tpendingExtensionRequests: RpcPendingExtensionRequests;\n\tcustomUi?: EngineCustomUiService;\n\trenderService?: EngineRenderService;\n\tsessionPicker?: EngineSessionPickerService;\n\tinputForm?: EngineInputFormService;\n\trequestShutdown: () => void;\n\treloadCoordinator?: KeybindingsReloadCoordinator<AgentSession>;\n}\n\nexport class RpcSessionBinding {\n\tprivate session: AgentSession;\n\tprivate boundRunner: AgentSession[\"extensionRunner\"] | undefined;\n\tprivate unsubscribe?: () => void;\n\tprivate unsubscribeBackpressure?: () => void;\n\tprivate unsubscribeTasks?: () => void;\n\tprivate readonly runtimeHost: AgentSessionRuntime;\n\tprivate readonly output: RpcOutput;\n\tprivate readonly pendingExtensionRequests: RpcPendingExtensionRequests;\n\tprivate readonly customUi: EngineCustomUiService | undefined;\n\tprivate readonly renderService: EngineRenderService | undefined;\n\tprivate readonly sessionPicker: EngineSessionPickerService | undefined;\n\tprivate readonly inputForm: EngineInputFormService | undefined;\n\tprivate readonly requestShutdown: () => void;\n\tprivate readonly reloadCoordinator: KeybindingsReloadCoordinator<AgentSession> | undefined;\n\n\tprivate footerDataProvider: FooterDataProvider | undefined;\n\tconstructor({\n\t\truntimeHost,\n\t\toutput,\n\t\tpendingExtensionRequests,\n\t\trequestShutdown,\n\t\tcustomUi,\n\t\trenderService,\n\t\tsessionPicker,\n\t\tinputForm,\n\t\treloadCoordinator,\n\t}: RpcSessionBindingOptions) {\n\t\tthis.runtimeHost = runtimeHost;\n\t\tthis.output = output;\n\t\tthis.pendingExtensionRequests = pendingExtensionRequests;\n\t\tthis.requestShutdown = requestShutdown;\n\t\tthis.customUi = customUi;\n\t\tthis.renderService = renderService;\n\t\tthis.sessionPicker = sessionPicker;\n\t\tthis.inputForm = inputForm;\n\t\tthis.reloadCoordinator = reloadCoordinator;\n\t\tthis.session = runtimeHost.session;\n\t\tthis.runtimeHost.setProjectTrustContextFactory?.((cwd) => this.createProjectTrustContext(cwd));\n\t}\n\n\tprivate createProjectTrustContext(cwd: string): ProjectTrustContext {\n\t\tconst runner = this.runtimeHost.session.extensionRunner;\n\t\tconst ui = runner.getUIContext();\n\t\tconst hasUI = this.customUi !== undefined;\n\t\treturn {\n\t\t\tcwd,\n\t\t\tmode: hasUI ? \"tui\" : \"rpc\",\n\t\t\thasUI,\n\t\t\tui: {\n\t\t\t\tselect: (title, options, opts) =>\n\t\t\t\t\thasUI\n\t\t\t\t\t\t? runner.withProjectTrustPrompt(\"select\", title, () => ui.select(title, options, opts))\n\t\t\t\t\t\t: Promise.resolve(undefined),\n\t\t\t\tconfirm: (title, message, opts) =>\n\t\t\t\t\thasUI\n\t\t\t\t\t\t? runner.withProjectTrustPrompt(\"confirm\", title, () => ui.confirm(title, message, opts))\n\t\t\t\t\t\t: Promise.resolve(false),\n\t\t\t\tinput: (title, placeholder, opts) =>\n\t\t\t\t\thasUI\n\t\t\t\t\t\t? runner.withProjectTrustPrompt(\"input\", title, () => ui.input(title, placeholder, opts))\n\t\t\t\t\t\t: Promise.resolve(undefined),\n\t\t\t\tnotify: (message, type) => ui.notify(message, type),\n\t\t\t},\n\t\t};\n\t}\n\n\tget currentSession(): AgentSession {\n\t\treturn this.session;\n\t}\n\n\tasync rebindSession(): Promise<void> {\n\t\tif (this.session === this.runtimeHost.session && this.boundRunner === this.session.extensionRunner) return;\n\t\tthis.session = this.runtimeHost.session;\n\t\tthis.disposeSubscriptions();\n\t\tconst session = this.session;\n\t\tsetCapabilityOverrides(session.settingsManager.getTerminalCapabilityOverrides());\n\t\tthis.renderService?.bindSession(session);\n\t\tthis.footerDataProvider = new FooterDataProvider(session.sessionManager.getCwd());\n\t\t// Seed the provider count from the current catalog snapshot, mirroring\n\t\t// updateProviderCountFromSnapshot() in interactive startup, so the\n\t\t// embedded footer shows the (provider) model prefix in multi-provider\n\t\t// sessions instead of defaulting to 0.\n\t\tconst models =\n\t\t\tsession.scopedModels.length > 0\n\t\t\t\t? session.scopedModels.map((scoped) => scoped.model)\n\t\t\t\t: session.modelRuntime.getAvailableSnapshot();\n\t\tthis.footerDataProvider.setAvailableProviderCount(new Set(models.map((model) => model.provider)).size);\n\n\t\ttry {\n\t\t\tawait session.bindExtensions({\n\t\t\t\tuiContext: createRpcExtensionUIContext({\n\t\t\t\t\toutput: this.output,\n\t\t\t\t\tpendingExtensionRequests: this.pendingExtensionRequests,\n\t\t\t\t\tcustomUi: this.customUi,\n\t\t\t\t\tsessionPicker: this.sessionPicker,\n\t\t\t\t\tinputForm: this.inputForm,\n\t\t\t\t\tfooterDataProvider: this.footerDataProvider,\n\t\t\t\t}),\n\t\t\t\tmode: this.customUi ? \"tui\" : \"rpc\",\n\t\t\t\tcommandContextActions: {\n\t\t\t\t\twaitForIdle: () => this.session.agent.waitForIdle(),\n\t\t\t\t\tnewSession: async (options) => this.runtimeHost.newSession(options),\n\t\t\t\t\tfork: async (entryId, forkOptions) => {\n\t\t\t\t\t\tconst result = await this.runtimeHost.fork(entryId, forkOptions);\n\t\t\t\t\t\treturn { cancelled: result.cancelled };\n\t\t\t\t\t},\n\t\t\t\t\tnavigateTree: async (targetId, options) => {\n\t\t\t\t\t\tconst result = await this.session.navigateTree(targetId, {\n\t\t\t\t\t\t\tsummarize: options?.summarize,\n\t\t\t\t\t\t\tcustomInstructions: options?.customInstructions,\n\t\t\t\t\t\t\treplaceInstructions: options?.replaceInstructions,\n\t\t\t\t\t\t\tlabel: options?.label,\n\t\t\t\t\t\t});\n\t\t\t\t\t\treturn { cancelled: result.cancelled };\n\t\t\t\t\t},\n\t\t\t\t\tswitchSession: async (sessionPath, options) => {\n\t\t\t\t\t\treturn this.runtimeHost.switchSession(sessionPath, options);\n\t\t\t\t\t},\n\t\t\t\t\treload: async () => {\n\t\t\t\t\t\tconst steeringMode = this.session.steeringMode;\n\t\t\t\t\t\tconst followUpMode = this.session.followUpMode;\n\t\t\t\t\t\tif (this.reloadCoordinator) await this.reloadCoordinator.reload(this.session);\n\t\t\t\t\t\telse await this.session.reload();\n\t\t\t\t\t\tthis.session.setSteeringMode(steeringMode);\n\t\t\t\t\t\tthis.session.setFollowUpMode(followUpMode);\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tshutdownHandler: this.requestShutdown,\n\t\t\t\tonError: (err) => {\n\t\t\t\t\tthis.output({\n\t\t\t\t\t\ttype: \"extension_error\",\n\t\t\t\t\t\textensionPath: err.extensionPath,\n\t\t\t\t\t\tevent: err.event,\n\t\t\t\t\t\terror: err.error,\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t});\n\t\t\tthis.footerDataProvider.startGitWatcher();\n\t\t} catch (error) {\n\t\t\t// Leave no partially-initialized footer state behind if extension\n\t\t\t// binding fails; dispose the provider and rethrow.\n\t\t\tthis.footerDataProvider.dispose();\n\t\t\tthis.footerDataProvider = undefined;\n\t\t\tthrow error;\n\t\t}\n\n\t\tif (this.customUi) this.unsubscribeTasks = bindEngineTaskWidget(session, session.extensionRunner.getUIContext());\n\t\tthis.unsubscribe = session.subscribe((event) => {\n\t\t\tthis.output(toJsonEvent(event));\n\t\t});\n\t\tthis.unsubscribeBackpressure = session.agent.subscribe(async () => {\n\t\t\tawait waitForRawStdoutBackpressure();\n\t\t});\n\t\tthis.reloadCoordinator?.publishCurrentState(session);\n\t\tthis.boundRunner = session.extensionRunner;\n\t}\n\n\t/** Load and atomically publish the optional resource set after the minimal interactive engine binds. */\n\tasync loadDeferredResources(): Promise<void> {\n\t\tconst session = this.session;\n\t\ttry {\n\t\t\tif (!(await this.runtimeHost.completeStartup?.())) {\n\t\t\t\tawait session.reload({ reason: \"startup\", failOnExtensionErrors: true });\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tfor (const extensionError of session.resourceLoader.getExtensions().errors) {\n\t\t\t\tthis.output({\n\t\t\t\t\ttype: \"extension_error\",\n\t\t\t\t\textensionPath: extensionError.path,\n\t\t\t\t\tevent: \"startup\",\n\t\t\t\t\terror: extensionError.error,\n\t\t\t\t});\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t\tif (session !== this.session) return;\n\t\tthis.reloadCoordinator?.publishCurrentState(session);\n\t}\n\n\tdisposeSubscriptions(): void {\n\t\tthis.boundRunner = undefined;\n\t\tthis.unsubscribe?.();\n\t\tthis.unsubscribeBackpressure?.();\n\t\tthis.unsubscribeTasks?.();\n\t\tthis.unsubscribeTasks = undefined;\n\t\tthis.footerDataProvider?.dispose();\n\t\tthis.unsubscribe = undefined;\n\t\tthis.unsubscribeBackpressure = undefined;\n\t\tthis.footerDataProvider = undefined;\n\t}\n}\n"]}
|