@code-yeongyu/senpi 2026.8.29 → 2026.8.30-3
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 +172 -0
- package/dist/core/agent-session.d.ts +47 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +406 -39
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js +155 -37
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/compaction/compaction-execution.d.ts +14 -0
- package/dist/core/compaction/compaction-execution.d.ts.map +1 -0
- package/dist/core/compaction/compaction-execution.js +121 -0
- package/dist/core/compaction/compaction-execution.js.map +1 -0
- package/dist/core/compaction/compaction-settings.d.ts +17 -0
- package/dist/core/compaction/compaction-settings.d.ts.map +1 -0
- package/dist/core/compaction/compaction-settings.js +17 -0
- package/dist/core/compaction/compaction-settings.js.map +1 -0
- package/dist/core/compaction/compaction.d.ts +13 -26
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +7 -136
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/ideal-compaction-settings.d.ts +9 -0
- package/dist/core/compaction/ideal-compaction-settings.d.ts.map +1 -0
- package/dist/core/compaction/ideal-compaction-settings.js +7 -0
- package/dist/core/compaction/ideal-compaction-settings.js.map +1 -0
- package/dist/core/compaction-settings-access.d.ts +19 -0
- package/dist/core/compaction-settings-access.d.ts.map +1 -0
- package/dist/core/compaction-settings-access.js +10 -0
- package/dist/core/compaction-settings-access.js.map +1 -0
- package/dist/core/compaction-settings-resolver.d.ts +22 -0
- package/dist/core/compaction-settings-resolver.d.ts.map +1 -0
- package/dist/core/compaction-settings-resolver.js +46 -0
- package/dist/core/compaction-settings-resolver.js.map +1 -0
- package/dist/core/credential-accounts.d.ts.map +1 -1
- package/dist/core/credential-accounts.js +23 -9
- package/dist/core/credential-accounts.js.map +1 -1
- package/dist/core/credential-pool/env-slots.d.ts.map +1 -1
- package/dist/core/credential-pool/env-slots.js +2 -0
- package/dist/core/credential-pool/env-slots.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/context-pipeline.d.ts +18 -0
- package/dist/core/extensions/builtin/compaction/context-pipeline.d.ts.map +1 -0
- package/dist/core/extensions/builtin/compaction/context-pipeline.js +32 -0
- package/dist/core/extensions/builtin/compaction/context-pipeline.js.map +1 -0
- package/dist/core/extensions/builtin/compaction/deterministic-fallback.d.ts +8 -2
- package/dist/core/extensions/builtin/compaction/deterministic-fallback.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/deterministic-fallback.js +164 -48
- package/dist/core/extensions/builtin/compaction/deterministic-fallback.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/emergency-prune.d.ts +17 -0
- package/dist/core/extensions/builtin/compaction/emergency-prune.d.ts.map +1 -0
- package/dist/core/extensions/builtin/compaction/emergency-prune.js +64 -0
- package/dist/core/extensions/builtin/compaction/emergency-prune.js.map +1 -0
- package/dist/core/extensions/builtin/compaction/extension-wiring.d.ts +27 -0
- package/dist/core/extensions/builtin/compaction/extension-wiring.d.ts.map +1 -0
- package/dist/core/extensions/builtin/compaction/extension-wiring.js +84 -0
- package/dist/core/extensions/builtin/compaction/extension-wiring.js.map +1 -0
- package/dist/core/extensions/builtin/compaction/idle-retry.d.ts +1 -1
- package/dist/core/extensions/builtin/compaction/idle-retry.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/idle-retry.js +1 -1
- package/dist/core/extensions/builtin/compaction/idle-retry.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/idle.d.ts +1 -0
- package/dist/core/extensions/builtin/compaction/idle.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/idle.js +13 -2
- package/dist/core/extensions/builtin/compaction/idle.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/index.d.ts +1 -1
- package/dist/core/extensions/builtin/compaction/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/index.js +148 -150
- package/dist/core/extensions/builtin/compaction/index.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/log.d.ts +1 -1
- package/dist/core/extensions/builtin/compaction/log.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/log.js +2 -0
- package/dist/core/extensions/builtin/compaction/log.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/model-selection.d.ts +14 -0
- package/dist/core/extensions/builtin/compaction/model-selection.d.ts.map +1 -0
- package/dist/core/extensions/builtin/compaction/model-selection.js +37 -0
- package/dist/core/extensions/builtin/compaction/model-selection.js.map +1 -0
- package/dist/core/extensions/builtin/compaction/model-usability-budget.d.ts +30 -0
- package/dist/core/extensions/builtin/compaction/model-usability-budget.d.ts.map +1 -0
- package/dist/core/extensions/builtin/compaction/model-usability-budget.js +74 -0
- package/dist/core/extensions/builtin/compaction/model-usability-budget.js.map +1 -0
- package/dist/core/extensions/builtin/compaction/openai-remote-dependencies.d.ts +9 -0
- package/dist/core/extensions/builtin/compaction/openai-remote-dependencies.d.ts.map +1 -0
- package/dist/core/extensions/builtin/compaction/openai-remote-dependencies.js +2 -0
- package/dist/core/extensions/builtin/compaction/openai-remote-dependencies.js.map +1 -0
- package/dist/core/extensions/builtin/compaction/openai-remote.d.ts +3 -6
- package/dist/core/extensions/builtin/compaction/openai-remote.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/openai-remote.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/orchestration.d.ts +46 -0
- package/dist/core/extensions/builtin/compaction/orchestration.d.ts.map +1 -0
- package/dist/core/extensions/builtin/compaction/orchestration.js +103 -0
- package/dist/core/extensions/builtin/compaction/orchestration.js.map +1 -0
- package/dist/core/extensions/builtin/compaction/policy.d.ts +12 -2
- package/dist/core/extensions/builtin/compaction/policy.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/policy.js +52 -26
- package/dist/core/extensions/builtin/compaction/policy.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/retained-message-safety.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/retained-message-safety.js +31 -8
- package/dist/core/extensions/builtin/compaction/retained-message-safety.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/speculation-lead.d.ts +8 -0
- package/dist/core/extensions/builtin/compaction/speculation-lead.d.ts.map +1 -0
- package/dist/core/extensions/builtin/compaction/speculation-lead.js +17 -0
- package/dist/core/extensions/builtin/compaction/speculation-lead.js.map +1 -0
- package/dist/core/extensions/builtin/compaction/speculative-job.d.ts +22 -0
- package/dist/core/extensions/builtin/compaction/speculative-job.d.ts.map +1 -0
- package/dist/core/extensions/builtin/compaction/speculative-job.js +16 -0
- package/dist/core/extensions/builtin/compaction/speculative-job.js.map +1 -0
- package/dist/core/extensions/builtin/compaction/speculative-summary.d.ts +22 -0
- package/dist/core/extensions/builtin/compaction/speculative-summary.d.ts.map +1 -0
- package/dist/core/extensions/builtin/compaction/speculative-summary.js +131 -0
- package/dist/core/extensions/builtin/compaction/speculative-summary.js.map +1 -0
- package/dist/core/extensions/builtin/compaction/speculative.d.ts +8 -13
- package/dist/core/extensions/builtin/compaction/speculative.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/speculative.js +7 -196
- package/dist/core/extensions/builtin/compaction/speculative.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/token-budget-reminder.d.ts +24 -0
- package/dist/core/extensions/builtin/compaction/token-budget-reminder.d.ts.map +1 -0
- package/dist/core/extensions/builtin/compaction/token-budget-reminder.js +25 -0
- package/dist/core/extensions/builtin/compaction/token-budget-reminder.js.map +1 -0
- package/dist/core/extensions/builtin/compaction/tool-admission.d.ts +27 -0
- package/dist/core/extensions/builtin/compaction/tool-admission.d.ts.map +1 -0
- package/dist/core/extensions/builtin/compaction/tool-admission.js +56 -0
- package/dist/core/extensions/builtin/compaction/tool-admission.js.map +1 -0
- package/dist/core/extensions/builtin/cursor-cli-oauth/stream.d.ts.map +1 -1
- package/dist/core/extensions/builtin/cursor-cli-oauth/stream.js +8 -28
- package/dist/core/extensions/builtin/cursor-cli-oauth/stream.js.map +1 -1
- package/dist/core/extensions/builtin/permission-system/external-dir.d.ts.map +1 -1
- package/dist/core/extensions/builtin/permission-system/external-dir.js +15 -5
- package/dist/core/extensions/builtin/permission-system/external-dir.js.map +1 -1
- package/dist/core/extensions/builtin/permission-system/parsers.d.ts.map +1 -1
- package/dist/core/extensions/builtin/permission-system/parsers.js +16 -1
- package/dist/core/extensions/builtin/permission-system/parsers.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/manager.d.ts +5 -0
- package/dist/core/extensions/builtin/terminal/manager.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/manager.js +31 -3
- package/dist/core/extensions/builtin/terminal/manager.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/monitor-permission.d.ts +8 -0
- package/dist/core/extensions/builtin/terminal/monitor-permission.d.ts.map +1 -0
- package/dist/core/extensions/builtin/terminal/monitor-permission.js +16 -0
- package/dist/core/extensions/builtin/terminal/monitor-permission.js.map +1 -0
- package/dist/core/extensions/builtin/terminal/monitor-registry.d.ts +13 -0
- package/dist/core/extensions/builtin/terminal/monitor-registry.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/monitor-registry.js +403 -3
- package/dist/core/extensions/builtin/terminal/monitor-registry.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/runtime-session.d.ts +11 -0
- package/dist/core/extensions/builtin/terminal/runtime-session.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/runtime-session.js +18 -2
- package/dist/core/extensions/builtin/terminal/runtime-session.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/session-bundle.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/session-bundle.js +1 -0
- package/dist/core/extensions/builtin/terminal/session-bundle.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/kill-bash.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/kill-bash.js +5 -2
- package/dist/core/extensions/builtin/terminal/tools/kill-bash.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/monitor.d.ts +4 -0
- package/dist/core/extensions/builtin/terminal/tools/monitor.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/monitor.js +40 -2
- package/dist/core/extensions/builtin/terminal/tools/monitor.js.map +1 -1
- package/dist/core/model-resolver.js +2 -2
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +5 -0
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +10 -1
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts +15 -85
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +15 -17
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/settings-public-types.d.ts +11 -0
- package/dist/core/settings-public-types.d.ts.map +1 -0
- package/dist/core/settings-public-types.js +2 -0
- package/dist/core/settings-public-types.js.map +1 -0
- package/dist/core/settings-shapes.d.ts +36 -0
- package/dist/core/settings-shapes.d.ts.map +1 -0
- package/dist/core/settings-shapes.js +2 -0
- package/dist/core/settings-shapes.js.map +1 -0
- package/dist/core/shared-host-policy.d.ts +6 -0
- package/dist/core/shared-host-policy.d.ts.map +1 -0
- package/dist/core/shared-host-policy.js +7 -0
- package/dist/core/shared-host-policy.js.map +1 -0
- package/dist/core/terminal-settings.d.ts +22 -0
- package/dist/core/terminal-settings.d.ts.map +1 -0
- package/dist/core/terminal-settings.js +2 -0
- package/dist/core/terminal-settings.js.map +1 -0
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +97 -15
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/index.d.ts +1 -0
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +8 -0
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/output-accumulator.d.ts +1 -1
- package/dist/core/tools/output-accumulator.d.ts.map +1 -1
- package/dist/core/tools/output-accumulator.js +76 -34
- package/dist/core/tools/output-accumulator.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +17 -5
- package/dist/main.js.map +1 -1
- package/dist/modes/index.d.ts +1 -1
- package/dist/modes/index.d.ts.map +1 -1
- package/dist/modes/index.js +1 -1
- package/dist/modes/index.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts +7 -0
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +34 -8
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/grok/chrome.d.ts +2 -0
- package/dist/modes/interactive/grok/chrome.d.ts.map +1 -1
- package/dist/modes/interactive/grok/chrome.js.map +1 -1
- package/dist/modes/interactive/interactive-host-runtime.d.ts +132 -1
- package/dist/modes/interactive/interactive-host-runtime.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-host-runtime.js +633 -117
- package/dist/modes/interactive/interactive-host-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +7 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +114 -2
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/rpc/connection-handler.d.ts +8 -1
- package/dist/modes/rpc/connection-handler.d.ts.map +1 -1
- package/dist/modes/rpc/connection-handler.js +158 -49
- package/dist/modes/rpc/connection-handler.js.map +1 -1
- package/dist/modes/rpc/host-ensure.d.ts +19 -0
- package/dist/modes/rpc/host-ensure.d.ts.map +1 -1
- package/dist/modes/rpc/host-ensure.js +79 -15
- package/dist/modes/rpc/host-ensure.js.map +1 -1
- package/dist/modes/rpc/host-lifecycle.d.ts +29 -0
- package/dist/modes/rpc/host-lifecycle.d.ts.map +1 -1
- package/dist/modes/rpc/host-lifecycle.js +96 -25
- package/dist/modes/rpc/host-lifecycle.js.map +1 -1
- package/dist/modes/rpc/host-watchdog.d.ts +2 -0
- package/dist/modes/rpc/host-watchdog.d.ts.map +1 -1
- package/dist/modes/rpc/host-watchdog.js +23 -12
- package/dist/modes/rpc/host-watchdog.js.map +1 -1
- package/dist/modes/rpc/multi-session-host.js +6 -4
- package/dist/modes/rpc/multi-session-host.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +20 -4
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +76 -17
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-input-validation.d.ts +1 -0
- package/dist/modes/rpc/rpc-input-validation.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-input-validation.js +66 -0
- package/dist/modes/rpc/rpc-input-validation.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +86 -1
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/modes/rpc/session-binding.d.ts +1 -0
- package/dist/modes/rpc/session-binding.d.ts.map +1 -1
- package/dist/modes/rpc/session-binding.js +21 -1
- package/dist/modes/rpc/session-binding.js.map +1 -1
- package/dist/modes/rpc/session-command-router.d.ts.map +1 -1
- package/dist/modes/rpc/session-command-router.js +1 -0
- package/dist/modes/rpc/session-command-router.js.map +1 -1
- package/dist/modes/rpc/session-event-writer.d.ts +2 -0
- package/dist/modes/rpc/session-event-writer.d.ts.map +1 -1
- package/dist/modes/rpc/session-event-writer.js +54 -7
- package/dist/modes/rpc/session-event-writer.js.map +1 -1
- package/dist/modes/rpc/session-extension-ui-requests.d.ts +1 -0
- package/dist/modes/rpc/session-extension-ui-requests.d.ts.map +1 -1
- package/dist/modes/rpc/session-extension-ui-requests.js +5 -0
- package/dist/modes/rpc/session-extension-ui-requests.js.map +1 -1
- package/dist/modes/rpc/session-registry.d.ts +10 -2
- package/dist/modes/rpc/session-registry.d.ts.map +1 -1
- package/dist/modes/rpc/session-registry.js +58 -4
- package/dist/modes/rpc/session-registry.js.map +1 -1
- package/dist/modes/rpc/socket-event-fanout.d.ts +22 -0
- package/dist/modes/rpc/socket-event-fanout.d.ts.map +1 -0
- package/dist/modes/rpc/socket-event-fanout.js +84 -0
- package/dist/modes/rpc/socket-event-fanout.js.map +1 -0
- package/docs/rpc.md +22 -2
- package/docs/settings.md +34 -0
- package/docs/windows.md +2 -0
- package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +62 -0
- package/node_modules/@code-yeongyu/senpi-codemode/package.json +4 -4
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/worker-indirect-eval.js +139 -90
- package/node_modules/@code-yeongyu/senpi-codemode/src/prompt/eval-prompt.ts +4 -4
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.js +40 -20
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.d.ts +3 -3
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/shell-output.d.ts +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/shell-output.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/shell-output.js +28 -9
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/shell-output.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/package.json +3 -3
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +67 -38
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent/measure.d.ts +20 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent/measure.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent/measure.js +443 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent/measure.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent.d.ts +2 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent.js +2 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/index.d.ts +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/index.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/index.js +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/index.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-ai-gateway.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-workers-ai.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/fireworks.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode-go.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/together.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/zai-coding-cn.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/zai.json +1 -1
- package/node_modules/@earendil-works/pi-ai/package.json +2 -2
- package/node_modules/@earendil-works/pi-pty/dist/screen-operations.d.ts +42 -0
- package/node_modules/@earendil-works/pi-pty/dist/screen-operations.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-pty/dist/screen-operations.js +34 -0
- package/node_modules/@earendil-works/pi-pty/dist/screen-operations.js.map +1 -0
- package/node_modules/@earendil-works/pi-pty/dist/screen-text.d.ts +8 -0
- package/node_modules/@earendil-works/pi-pty/dist/screen-text.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-pty/dist/screen-text.js +51 -0
- package/node_modules/@earendil-works/pi-pty/dist/screen-text.js.map +1 -0
- package/node_modules/@earendil-works/pi-pty/dist/screen.d.ts +45 -0
- package/node_modules/@earendil-works/pi-pty/dist/screen.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-pty/dist/screen.js +178 -55
- package/node_modules/@earendil-works/pi-pty/dist/screen.js.map +1 -1
- package/node_modules/@earendil-works/pi-pty/package.json +1 -1
- package/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/editor.d.ts +7 -0
- package/node_modules/@earendil-works/pi-tui/dist/components/editor.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/editor.js +5 -0
- package/node_modules/@earendil-works/pi-tui/dist/components/editor.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/mux.d.ts +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/mux.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/mux.js +2 -2
- package/node_modules/@earendil-works/pi-tui/dist/mux.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts +1 -0
- package/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/terminal.js +19 -0
- package/node_modules/@earendil-works/pi-tui/dist/terminal.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/package.json +1 -1
- package/package.json +7 -7
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* go to `sink.writeRaw` instead of `writeRawStdout`, and the caller decides how
|
|
15
15
|
* (and whether) to end the process.
|
|
16
16
|
*/
|
|
17
|
+
import type { AgentAbortSource } from "../../core/agent-abort-provenance.ts";
|
|
17
18
|
import type { AgentSession } from "../../core/agent-session.ts";
|
|
18
19
|
import type { AgentSessionRuntime } from "../../core/agent-session-runtime.ts";
|
|
19
20
|
import type { RpcSessionState } from "./rpc-types.ts";
|
|
@@ -50,6 +51,8 @@ export interface RpcConnectionHandler {
|
|
|
50
51
|
* host polls this after each command and decides how to tear down.
|
|
51
52
|
*/
|
|
52
53
|
isShutdownRequested(): boolean;
|
|
54
|
+
/** Cancel UI requests that can no longer be answered by this connection. */
|
|
55
|
+
cancelPendingExtensionUiRequests(): void;
|
|
53
56
|
/** Tear down subscriptions and dispose the runtime. Never calls process.exit. */
|
|
54
57
|
dispose(): Promise<void>;
|
|
55
58
|
}
|
|
@@ -59,8 +62,12 @@ export interface RpcConnectionHandler {
|
|
|
59
62
|
* Shared with `open_session` (session-command-router) so both surfaces answer with the SAME
|
|
60
63
|
* fields: a second hand-rolled literal silently drifts, which is how `serviceTier`/`fastMode`
|
|
61
64
|
* would otherwise be missing from an opened session's initial state.
|
|
65
|
+
*
|
|
66
|
+
* `lastAbortSource` is passed in rather than read from the session: `session.currentAbortSource`
|
|
67
|
+
* is cleared once the turn settles, so only the caller that observed `agent_end` still knows
|
|
68
|
+
* who owned the abort.
|
|
62
69
|
*/
|
|
63
|
-
export declare function buildRpcSessionState(session: AgentSession): RpcSessionState;
|
|
70
|
+
export declare function buildRpcSessionState(session: AgentSession, lastAbortSource?: AgentAbortSource): RpcSessionState;
|
|
64
71
|
/**
|
|
65
72
|
* Create a per-connection RPC handler bound to one runtime host and one sink.
|
|
66
73
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection-handler.d.ts","sourceRoot":"","sources":["../../../src/modes/rpc/connection-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAOH,OAAO,KAAK,EAAE,YAAY,EAAqB,MAAM,6BAA6B,CAAC;AACnF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"connection-handler.d.ts","sourceRoot":"","sources":["../../../src/modes/rpc/connection-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAOH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,KAAK,EAAE,YAAY,EAAqB,MAAM,6BAA6B,CAAC;AACnF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAyC/E,OAAO,KAAK,EAYX,eAAe,EAEf,MAAM,gBAAgB,CAAC;AAGxB,kFAAkF;AAClF,MAAM,WAAW,oBAAoB;IACpC,mFAAmF;IACnF,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,iFAAiF;IACjF,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;IAC7B,0DAA0D;IAC1D,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,kFAAkF;IAClF,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IACjC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACrC;AAED,MAAM,WAAW,oBAAoB;IACpC;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,sEAAsE;IACtE,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7C;;;OAGG;IACH,mBAAmB,IAAI,OAAO,CAAC;IAC/B,4EAA4E;IAC5E,gCAAgC,IAAI,IAAI,CAAC;IACzC,iFAAiF;IACjF,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACzB;AA4BD;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,YAAY,EAAE,eAAe,CAAC,EAAE,gBAAgB,GAAG,eAAe,CAkD/G;AA4BD;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACzC,WAAW,EAAE,mBAAmB,EAChC,IAAI,EAAE,iBAAiB,EACvB,OAAO,GAAE,oBAAyB,GAChC,oBAAoB,CAyvCtB"}
|
|
@@ -25,11 +25,12 @@ import { CLAUDE_SDK_OAUTH_PROVIDER_ID } from "../../core/extensions/builtin/clau
|
|
|
25
25
|
import { isMcpControlInventoryChanged, MCP_CONTROL_INVENTORY_CHANGED_EVENT, MCP_CONTROL_INVENTORY_REQUEST_EVENT, } from "../../core/extensions/builtin/mcp/control-inventory.js";
|
|
26
26
|
import { applyFastMode, resolveServiceTierMemoryModel, } from "../../core/extensions/builtin/service-tier.js";
|
|
27
27
|
import { getSupportedThinkingLevels } from "../../core/thinking-levels.js";
|
|
28
|
+
import { ProjectTrustStore } from "../../core/trust-manager.js";
|
|
28
29
|
import { theme } from "../interactive/theme/theme.js";
|
|
29
30
|
import { buildCustomUnsupportedRequest, DEFAULT_CUSTOM_EXTENSION_LABEL, EXTENSION_EVENTS_CAPABILITY, } from "./custom-capability.js";
|
|
30
31
|
import { createRpcEventOutputBuffer } from "./event-output-buffer.js";
|
|
31
32
|
import { buildRpcCommandsForSession, createCommandsChangedEvent, rpcCommandListDigest } from "./rpc-command-surface.js";
|
|
32
|
-
import { rpcCommandShapeError, rpcMessageLengthError } from "./rpc-input-validation.js";
|
|
33
|
+
import { rpcCommandPayloadError, rpcCommandShapeError, rpcMessageLengthError } from "./rpc-input-validation.js";
|
|
33
34
|
import { SessionExtensionUiRequests } from "./session-extension-ui-requests.js";
|
|
34
35
|
function loadedExtensionName(path) {
|
|
35
36
|
const synthetic = /^<(?:builtin|inline):([^>]+)>$/.exec(path);
|
|
@@ -65,11 +66,24 @@ function loadedMcpStatus(server) {
|
|
|
65
66
|
* Shared with `open_session` (session-command-router) so both surfaces answer with the SAME
|
|
66
67
|
* fields: a second hand-rolled literal silently drifts, which is how `serviceTier`/`fastMode`
|
|
67
68
|
* would otherwise be missing from an opened session's initial state.
|
|
69
|
+
*
|
|
70
|
+
* `lastAbortSource` is passed in rather than read from the session: `session.currentAbortSource`
|
|
71
|
+
* is cleared once the turn settles, so only the caller that observed `agent_end` still knows
|
|
72
|
+
* who owned the abort.
|
|
68
73
|
*/
|
|
69
|
-
export function buildRpcSessionState(session) {
|
|
74
|
+
export function buildRpcSessionState(session, lastAbortSource) {
|
|
75
|
+
const cwd = session.sessionManager.getCwd();
|
|
76
|
+
// Trust gates project-source settings (shell prefixes, project resources), so every
|
|
77
|
+
// session state projection must have an authoritative store to consult.
|
|
78
|
+
if (!session.agentDir) {
|
|
79
|
+
throw new Error("RPC session invariant violated: agentDir is required");
|
|
80
|
+
}
|
|
81
|
+
const projectTrusted = new ProjectTrustStore(session.agentDir).get(cwd) === true;
|
|
70
82
|
return {
|
|
71
83
|
model: session.model,
|
|
72
84
|
thinkingLevel: session.thinkingLevel,
|
|
85
|
+
...(session.thinkingSelection ? { thinkingSelection: session.thinkingSelection } : {}),
|
|
86
|
+
...(lastAbortSource ? { lastAbortSource } : {}),
|
|
73
87
|
serviceTier: session.effectiveServiceTier,
|
|
74
88
|
fastMode: session.isFastModeActive(),
|
|
75
89
|
isStreaming: session.isStreaming,
|
|
@@ -81,8 +95,8 @@ export function buildRpcSessionState(session) {
|
|
|
81
95
|
sessionFile: session.sessionFile,
|
|
82
96
|
sessionId: session.sessionId,
|
|
83
97
|
sessionName: session.sessionName,
|
|
84
|
-
cwd
|
|
85
|
-
projectTrusted
|
|
98
|
+
cwd,
|
|
99
|
+
projectTrusted,
|
|
86
100
|
...(session.sessionFile &&
|
|
87
101
|
!existsSync(session.sessionFile) &&
|
|
88
102
|
session.sessionManager
|
|
@@ -99,6 +113,9 @@ export function buildRpcSessionState(session) {
|
|
|
99
113
|
messageCount: session.messages.length,
|
|
100
114
|
pendingMessageCount: session.pendingMessageCount,
|
|
101
115
|
usageTotals: session.sessionManager.getUsageTotals(),
|
|
116
|
+
contextUsage: typeof session.getContextUsage === "function" ? session.getContextUsage() : undefined,
|
|
117
|
+
favoriteModels: session.favoriteModels?.map((entry) => ({ ...entry })) ?? [],
|
|
118
|
+
scopedModels: session.scopedModels?.map((entry) => ({ ...entry })) ?? [],
|
|
102
119
|
};
|
|
103
120
|
}
|
|
104
121
|
function loadedMcpServers(snapshot) {
|
|
@@ -131,12 +148,17 @@ function loadedSurfacesFingerprint(session, extensions, mcpServers) {
|
|
|
131
148
|
export function createRpcConnectionHandler(runtimeHost, sink, options = {}) {
|
|
132
149
|
const clientCapabilities = options.capabilities;
|
|
133
150
|
const routingSessionId = options.sessionId;
|
|
151
|
+
// True only while THIS connection's own command drives a replacement; the issuer
|
|
152
|
+
// already learns the new identity from its command response.
|
|
153
|
+
let replacementIssuedHere = false;
|
|
134
154
|
let session = runtimeHost.session;
|
|
135
155
|
let unsubscribe;
|
|
136
156
|
let unsubscribeBackpressure;
|
|
137
157
|
let unsubscribeLoadedSurfaces;
|
|
138
158
|
let unsubscribeExtensionEvents;
|
|
139
159
|
let mcpWireStatus = { servers: [] };
|
|
160
|
+
/** Abort owner of the last settled turn; `session.currentAbortSource` clears on settle. */
|
|
161
|
+
let lastAbortSource;
|
|
140
162
|
let loadedSurfacesDigest;
|
|
141
163
|
let rpcCommandsDigest;
|
|
142
164
|
let suppressLoadedSurfaceEvents = false;
|
|
@@ -306,7 +328,6 @@ export function createRpcConnectionHandler(runtimeHost, sink, options = {}) {
|
|
|
306
328
|
// Hidden thinking label not supported in RPC mode - requires TUI message rendering access
|
|
307
329
|
},
|
|
308
330
|
setWidget(key, content, options) {
|
|
309
|
-
// Only support string arrays in RPC mode - factory functions are ignored
|
|
310
331
|
if (content === undefined || Array.isArray(content)) {
|
|
311
332
|
output({
|
|
312
333
|
type: "extension_ui_request",
|
|
@@ -316,8 +337,14 @@ export function createRpcConnectionHandler(runtimeHost, sink, options = {}) {
|
|
|
316
337
|
widgetLines: content,
|
|
317
338
|
widgetPlacement: options?.placement,
|
|
318
339
|
});
|
|
340
|
+
return;
|
|
319
341
|
}
|
|
320
|
-
//
|
|
342
|
+
// A component factory closes over live TUI/theme state and cannot cross
|
|
343
|
+
// the RPC boundary. Never drop it silently: an opted-in client can show
|
|
344
|
+
// the same explicit degradation notice used by ctx.ui.custom.
|
|
345
|
+
const request = buildCustomUnsupportedRequest(clientCapabilities, "widget component");
|
|
346
|
+
if (request)
|
|
347
|
+
output(request);
|
|
321
348
|
},
|
|
322
349
|
setFooter(_factory) {
|
|
323
350
|
// Custom footer not supported in RPC mode - requires TUI access
|
|
@@ -443,19 +470,60 @@ export function createRpcConnectionHandler(runtimeHost, sink, options = {}) {
|
|
|
443
470
|
}
|
|
444
471
|
};
|
|
445
472
|
runtimeHost.setRebindSession(async () => {
|
|
446
|
-
|
|
473
|
+
// AgentSessionRuntime invokes this callback while completing a replacement.
|
|
474
|
+
// Do not await extension binding here: extensions may wait for session work
|
|
475
|
+
// that the replacement still owns. The command response must acknowledge the
|
|
476
|
+
// committed replacement; derived surfaces refresh out of band afterwards.
|
|
477
|
+
await rebindSession(true);
|
|
447
478
|
});
|
|
448
|
-
const
|
|
479
|
+
const rebindAfterLocalReplacement = async () => {
|
|
480
|
+
replacementIssuedHere = true;
|
|
481
|
+
try {
|
|
482
|
+
await rebindSession();
|
|
483
|
+
}
|
|
484
|
+
finally {
|
|
485
|
+
replacementIssuedHere = false;
|
|
486
|
+
}
|
|
487
|
+
};
|
|
488
|
+
const rebindSession = async (deferRefresh = false) => {
|
|
449
489
|
unsubscribeLoadedSurfaces?.();
|
|
450
490
|
unsubscribeExtensionEvents?.();
|
|
491
|
+
const replacedSession = session !== runtimeHost.session;
|
|
451
492
|
session = runtimeHost.session;
|
|
493
|
+
if (replacedSession) {
|
|
494
|
+
lastAbortSource = undefined;
|
|
495
|
+
if (routingSessionId !== undefined || !replacementIssuedHere) {
|
|
496
|
+
// A replacement can be driven by ANY attached client, so every connection must be
|
|
497
|
+
// told the live binding moved and given the new authoritative identity. Emitted
|
|
498
|
+
// before the derived-surface refresh so a client cannot act on the old identity in
|
|
499
|
+
// the window the refresh takes.
|
|
500
|
+
outputEvent({
|
|
501
|
+
type: "session_replaced",
|
|
502
|
+
durableSessionId: session.sessionId,
|
|
503
|
+
sessionFile: session.sessionFile,
|
|
504
|
+
cwd: session.sessionManager.getCwd(),
|
|
505
|
+
sessionName: session.sessionName,
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
}
|
|
452
509
|
unsubscribeExtensionEvents = clientCapabilities?.includes(EXTENSION_EVENTS_CAPABILITY)
|
|
453
510
|
? session.extensionRunner.onRpcEvent(({ name, data }) => {
|
|
454
511
|
outputEvent({ type: "extension_event", name, data });
|
|
455
512
|
})
|
|
456
513
|
: undefined;
|
|
457
514
|
subscribeLoadedSurfaceEvents();
|
|
458
|
-
|
|
515
|
+
// Subscribe to the replaced session before its bind runs, not after. The bind
|
|
516
|
+
// is deferred by design - awaiting it would deadlock a client whose
|
|
517
|
+
// session_start handler blocks on an extension_ui_request it cannot answer
|
|
518
|
+
// while still awaiting the replacement response - and it still mutates the
|
|
519
|
+
// session it owns: pi-rules appends a durable scan entry from session_start.
|
|
520
|
+
// Those entries must reach every attached connection, and nothing else can
|
|
521
|
+
// carry them, because the session file is not written until an assistant
|
|
522
|
+
// message exists, so a client that misses the notification can never
|
|
523
|
+
// reconstruct the session it is bound to. Installing here also drops the
|
|
524
|
+
// previous session's subscription immediately instead of after the bind.
|
|
525
|
+
installSessionSubscriptions();
|
|
526
|
+
const refresh = refreshLoadedSurfacesAfter(() => session.bindExtensions({
|
|
459
527
|
uiContext: createExtensionUIContext(),
|
|
460
528
|
mode: "rpc",
|
|
461
529
|
commandContextActions: {
|
|
@@ -500,22 +568,52 @@ export function createRpcConnectionHandler(runtimeHost, sink, options = {}) {
|
|
|
500
568
|
});
|
|
501
569
|
},
|
|
502
570
|
}), true);
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
571
|
+
function installSessionSubscriptions() {
|
|
572
|
+
unsubscribe?.();
|
|
573
|
+
unsubscribeBackpressure?.();
|
|
574
|
+
unsubscribe = session.subscribe((event) => {
|
|
575
|
+
if (event.type === "skill_invocation") {
|
|
576
|
+
outputEvent(event);
|
|
577
|
+
return;
|
|
578
|
+
}
|
|
579
|
+
if (event.type === "command_invocation") {
|
|
580
|
+
outputEvent(event);
|
|
581
|
+
return;
|
|
582
|
+
}
|
|
583
|
+
if (event.type === "thinking_level_changed" || event.type === "model_changed") {
|
|
584
|
+
// Core emits the effective level only; the selection provenance lives beside it
|
|
585
|
+
// on the session and is what distinguishes an explicit choice from a default.
|
|
586
|
+
const thinkingSelection = session.thinkingSelection;
|
|
587
|
+
outputEvent(thinkingSelection === undefined ? event : { ...event, thinkingSelection });
|
|
588
|
+
return;
|
|
589
|
+
}
|
|
590
|
+
if (event.type === "agent_end") {
|
|
591
|
+
// The subscribe-path `agent_end` carries only { type, messages, willRetry };
|
|
592
|
+
// the abort provenance the extension hook receives is stripped from it. Read
|
|
593
|
+
// it from the session, which still reports the owner at this point, and retain
|
|
594
|
+
// it for `get_state` because the getter clears once the turn settles.
|
|
595
|
+
const abortSource = session.currentAbortSource;
|
|
596
|
+
if (abortSource !== undefined)
|
|
597
|
+
lastAbortSource = abortSource;
|
|
598
|
+
outputEvent(abortSource === undefined ? event : { ...event, aborted: true, abortSource });
|
|
599
|
+
return;
|
|
600
|
+
}
|
|
511
601
|
outputEvent(event);
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
602
|
+
});
|
|
603
|
+
unsubscribeBackpressure = session.agent.subscribe(async () => {
|
|
604
|
+
await waitForRpcBackpressure();
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
if (deferRefresh) {
|
|
608
|
+
// The subscription is already installed on the replaced session above, so
|
|
609
|
+
// the deferred refresh only needs its failure reported. Re-installing here
|
|
610
|
+
// would replay the settings-source selection a second time.
|
|
611
|
+
void refresh.catch((cause) => {
|
|
612
|
+
outputEvent({ type: "rpc_error", error: String(cause) });
|
|
613
|
+
});
|
|
614
|
+
return;
|
|
615
|
+
}
|
|
616
|
+
await refresh;
|
|
519
617
|
};
|
|
520
618
|
/**
|
|
521
619
|
* Drive an OAuth login for one provider as fire-command-then-subscribe.
|
|
@@ -623,6 +721,7 @@ export function createRpcConnectionHandler(runtimeHost, sink, options = {}) {
|
|
|
623
721
|
images: command.images,
|
|
624
722
|
streamingBehavior: command.streamingBehavior,
|
|
625
723
|
thinkingLevel: command.thinkingLevel,
|
|
724
|
+
sessionTitlePrompt: command.sessionTitlePrompt,
|
|
626
725
|
expandPromptTemplates: command.expandPromptTemplates,
|
|
627
726
|
source: "rpc",
|
|
628
727
|
promptDisposition: (nextDisposition) => {
|
|
@@ -648,13 +747,11 @@ export function createRpcConnectionHandler(runtimeHost, sink, options = {}) {
|
|
|
648
747
|
? { role: "user", content, timestamp: Date.now() }
|
|
649
748
|
: { role: "user", content, timestamp: Date.now() };
|
|
650
749
|
session.sessionManager.appendMessage(message);
|
|
651
|
-
session.messages.
|
|
750
|
+
session.agent.state.messages = session.sessionManager.buildSessionContext().messages;
|
|
652
751
|
return success(id, "append_user_message");
|
|
653
752
|
}
|
|
654
753
|
case "append_session_entry": {
|
|
655
|
-
session.
|
|
656
|
-
if (command.entry.type === "message")
|
|
657
|
-
session.messages.push(command.entry.message);
|
|
754
|
+
session.appendSessionEntry(command.entry);
|
|
658
755
|
return success(id, "append_session_entry");
|
|
659
756
|
}
|
|
660
757
|
case "send_custom_message": {
|
|
@@ -707,16 +804,15 @@ export function createRpcConnectionHandler(runtimeHost, sink, options = {}) {
|
|
|
707
804
|
case "new_session": {
|
|
708
805
|
const options = command.parentSession ? { parentSession: command.parentSession } : undefined;
|
|
709
806
|
const result = await runtimeHost.newSession(options);
|
|
710
|
-
if (!result.cancelled)
|
|
711
|
-
await
|
|
712
|
-
}
|
|
807
|
+
if (routingSessionId === undefined && !result.cancelled && session !== runtimeHost.session)
|
|
808
|
+
await rebindAfterLocalReplacement();
|
|
713
809
|
return success(id, "new_session", result);
|
|
714
810
|
}
|
|
715
811
|
// =================================================================
|
|
716
812
|
// State
|
|
717
813
|
// =================================================================
|
|
718
814
|
case "get_state":
|
|
719
|
-
return success(id, "get_state", buildRpcSessionState(session));
|
|
815
|
+
return success(id, "get_state", buildRpcSessionState(session, lastAbortSource));
|
|
720
816
|
// =================================================================
|
|
721
817
|
// Model
|
|
722
818
|
// =================================================================
|
|
@@ -729,8 +825,14 @@ export function createRpcConnectionHandler(runtimeHost, sink, options = {}) {
|
|
|
729
825
|
const systemPromptChange = await session.setModel(model);
|
|
730
826
|
return success(id, "set_model", { ...model, systemPromptName: systemPromptChange?.systemPromptName });
|
|
731
827
|
}
|
|
828
|
+
case "set_favorite_models":
|
|
829
|
+
session.setFavoriteModels(command.models);
|
|
830
|
+
return success(id, "set_favorite_models");
|
|
831
|
+
case "set_scoped_models":
|
|
832
|
+
session.setScopedModels(command.models);
|
|
833
|
+
return success(id, "set_scoped_models");
|
|
732
834
|
case "cycle_model": {
|
|
733
|
-
const result = await session.cycleModel();
|
|
835
|
+
const result = await session.cycleModel(command.direction);
|
|
734
836
|
if (!result) {
|
|
735
837
|
return success(id, "cycle_model", null);
|
|
736
838
|
}
|
|
@@ -861,7 +963,8 @@ export function createRpcConnectionHandler(runtimeHost, sink, options = {}) {
|
|
|
861
963
|
session.sessionManager.appendLabelChange(command.entryId, command.label);
|
|
862
964
|
return success(id, "set_label");
|
|
863
965
|
case "bash": {
|
|
864
|
-
|
|
966
|
+
if (routingSessionId !== undefined)
|
|
967
|
+
outputEvent({ type: "bash_start" });
|
|
865
968
|
try {
|
|
866
969
|
const eventResult = await session.extensionRunner.emitUserBash({
|
|
867
970
|
type: "user_bash",
|
|
@@ -877,6 +980,7 @@ export function createRpcConnectionHandler(runtimeHost, sink, options = {}) {
|
|
|
877
980
|
}
|
|
878
981
|
const result = await session.executeBash(command.command, undefined, {
|
|
879
982
|
excludeFromContext: command.excludeFromContext,
|
|
983
|
+
id: command.executionId,
|
|
880
984
|
// Functions cannot cross JSONL. Host extensions may still provide the
|
|
881
985
|
// executable operations object; client-supplied data is only a wire-safe hint.
|
|
882
986
|
operations: eventResult?.operations,
|
|
@@ -884,13 +988,17 @@ export function createRpcConnectionHandler(runtimeHost, sink, options = {}) {
|
|
|
884
988
|
return success(id, "bash", result);
|
|
885
989
|
}
|
|
886
990
|
finally {
|
|
887
|
-
|
|
991
|
+
if (routingSessionId !== undefined)
|
|
992
|
+
outputEvent({ type: "bash_end" });
|
|
888
993
|
}
|
|
889
994
|
}
|
|
890
995
|
case "abort_bash": {
|
|
891
996
|
session.abortBash();
|
|
892
997
|
return success(id, "abort_bash");
|
|
893
998
|
}
|
|
999
|
+
case "cleanup_bash_output":
|
|
1000
|
+
await session.cleanupBashOutput(command.path);
|
|
1001
|
+
return success(id, "cleanup_bash_output");
|
|
894
1002
|
// =================================================================
|
|
895
1003
|
// Session
|
|
896
1004
|
// =================================================================
|
|
@@ -899,7 +1007,7 @@ export function createRpcConnectionHandler(runtimeHost, sink, options = {}) {
|
|
|
899
1007
|
return success(id, "get_session_stats", stats);
|
|
900
1008
|
}
|
|
901
1009
|
case "export_html": {
|
|
902
|
-
const path = await session.exportToHtml(command.outputPath);
|
|
1010
|
+
const path = await session.exportToHtml(command.outputPath, { themeName: command.themeName });
|
|
903
1011
|
return success(id, "export_html", { path });
|
|
904
1012
|
}
|
|
905
1013
|
case "export_jsonl": {
|
|
@@ -907,16 +1015,14 @@ export function createRpcConnectionHandler(runtimeHost, sink, options = {}) {
|
|
|
907
1015
|
}
|
|
908
1016
|
case "switch_session": {
|
|
909
1017
|
const result = await runtimeHost.switchSession(command.sessionPath, { cwdOverride: command.cwdOverride });
|
|
910
|
-
if (!result.cancelled)
|
|
911
|
-
await
|
|
912
|
-
}
|
|
1018
|
+
if (routingSessionId === undefined && !result.cancelled && session !== runtimeHost.session)
|
|
1019
|
+
await rebindAfterLocalReplacement();
|
|
913
1020
|
return success(id, "switch_session", result);
|
|
914
1021
|
}
|
|
915
1022
|
case "fork": {
|
|
916
1023
|
const result = await runtimeHost.fork(command.entryId, { position: command.position });
|
|
917
|
-
if (!result.cancelled)
|
|
918
|
-
await
|
|
919
|
-
}
|
|
1024
|
+
if (routingSessionId === undefined && !result.cancelled && session !== runtimeHost.session)
|
|
1025
|
+
await rebindAfterLocalReplacement();
|
|
920
1026
|
return success(id, "fork", { text: result.selectedText, cancelled: result.cancelled });
|
|
921
1027
|
}
|
|
922
1028
|
case "clone": {
|
|
@@ -925,9 +1031,8 @@ export function createRpcConnectionHandler(runtimeHost, sink, options = {}) {
|
|
|
925
1031
|
return error(id, "clone", "Cannot clone session: no current entry selected");
|
|
926
1032
|
}
|
|
927
1033
|
const result = await runtimeHost.fork(leafId, { position: "at" });
|
|
928
|
-
if (!result.cancelled)
|
|
929
|
-
await
|
|
930
|
-
}
|
|
1034
|
+
if (routingSessionId === undefined && !result.cancelled && session !== runtimeHost.session)
|
|
1035
|
+
await rebindAfterLocalReplacement();
|
|
931
1036
|
return success(id, "clone", { cancelled: result.cancelled });
|
|
932
1037
|
}
|
|
933
1038
|
case "get_fork_messages": {
|
|
@@ -956,8 +1061,8 @@ export function createRpcConnectionHandler(runtimeHost, sink, options = {}) {
|
|
|
956
1061
|
}
|
|
957
1062
|
case "import_jsonl": {
|
|
958
1063
|
const result = await runtimeHost.importFromJsonl(command.inputPath, command.cwdOverride);
|
|
959
|
-
if (!result.cancelled)
|
|
960
|
-
await
|
|
1064
|
+
if (routingSessionId === undefined && !result.cancelled && session !== runtimeHost.session)
|
|
1065
|
+
await rebindAfterLocalReplacement();
|
|
961
1066
|
return success(id, "import_jsonl", result);
|
|
962
1067
|
}
|
|
963
1068
|
case "set_session_name": {
|
|
@@ -1079,9 +1184,10 @@ export function createRpcConnectionHandler(runtimeHost, sink, options = {}) {
|
|
|
1079
1184
|
return;
|
|
1080
1185
|
}
|
|
1081
1186
|
const command = parsed;
|
|
1187
|
+
const payloadError = rpcCommandPayloadError(command);
|
|
1082
1188
|
const messageLengthError = rpcMessageLengthError(command);
|
|
1083
|
-
if (messageLengthError) {
|
|
1084
|
-
output(error(command.id, command.type, messageLengthError));
|
|
1189
|
+
if (payloadError || messageLengthError) {
|
|
1190
|
+
output(error(command.id, command.type, payloadError ?? messageLengthError));
|
|
1085
1191
|
await waitForRpcBackpressure();
|
|
1086
1192
|
return;
|
|
1087
1193
|
}
|
|
@@ -1125,6 +1231,9 @@ export function createRpcConnectionHandler(runtimeHost, sink, options = {}) {
|
|
|
1125
1231
|
isShutdownRequested() {
|
|
1126
1232
|
return shutdownRequested;
|
|
1127
1233
|
},
|
|
1234
|
+
cancelPendingExtensionUiRequests() {
|
|
1235
|
+
pendingExtensionRequests.cancelAll();
|
|
1236
|
+
},
|
|
1128
1237
|
async dispose() {
|
|
1129
1238
|
await ready;
|
|
1130
1239
|
await dispose();
|