@code-yeongyu/senpi 2026.8.26 → 2026.8.28-2
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 +138 -0
- package/README.md +3 -3
- package/dist/cli/args.d.ts +5 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +18 -1
- package/dist/cli/args.js.map +1 -1
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +2 -0
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +5 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +11 -1
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts +1 -0
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +3 -0
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js +67 -29
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/credential-accounts.d.ts +31 -0
- package/dist/core/credential-accounts.d.ts.map +1 -0
- package/dist/core/credential-accounts.js +135 -0
- package/dist/core/credential-accounts.js.map +1 -0
- package/dist/core/credential-pool/classify.d.ts +47 -0
- package/dist/core/credential-pool/classify.d.ts.map +1 -0
- package/dist/core/credential-pool/classify.js +92 -0
- package/dist/core/credential-pool/classify.js.map +1 -0
- package/dist/core/credential-pool/env-slots.d.ts +22 -0
- package/dist/core/credential-pool/env-slots.d.ts.map +1 -0
- package/dist/core/credential-pool/env-slots.js +37 -0
- package/dist/core/credential-pool/env-slots.js.map +1 -0
- package/dist/core/credential-pool/failover.d.ts +62 -0
- package/dist/core/credential-pool/failover.d.ts.map +1 -0
- package/dist/core/credential-pool/failover.js +124 -0
- package/dist/core/credential-pool/failover.js.map +1 -0
- package/dist/core/credential-pool/rotation-stream.d.ts +54 -0
- package/dist/core/credential-pool/rotation-stream.d.ts.map +1 -0
- package/dist/core/credential-pool/rotation-stream.js +183 -0
- package/dist/core/credential-pool/rotation-stream.js.map +1 -0
- package/dist/core/credential-pool/state-store.d.ts +89 -0
- package/dist/core/credential-pool/state-store.d.ts.map +1 -0
- package/dist/core/credential-pool/state-store.js +166 -0
- package/dist/core/credential-pool/state-store.js.map +1 -0
- package/dist/core/extensions/builtin/account/index.d.ts +9 -0
- package/dist/core/extensions/builtin/account/index.d.ts.map +1 -0
- package/dist/core/extensions/builtin/account/index.js +69 -0
- package/dist/core/extensions/builtin/account/index.js.map +1 -0
- package/dist/core/extensions/builtin/compaction/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/index.js +67 -0
- 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 +1 -0
- package/dist/core/extensions/builtin/compaction/log.js.map +1 -1
- package/dist/core/extensions/builtin/config-reload/index.js +14 -22
- package/dist/core/extensions/builtin/config-reload/index.js.map +1 -1
- package/dist/core/extensions/builtin/goal/continuation-recovery.d.ts +1 -0
- package/dist/core/extensions/builtin/goal/continuation-recovery.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/continuation-recovery.js +2 -0
- package/dist/core/extensions/builtin/goal/continuation-recovery.js.map +1 -1
- package/dist/core/extensions/builtin/goal/continuation.d.ts +8 -1
- package/dist/core/extensions/builtin/goal/continuation.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/continuation.js +15 -0
- package/dist/core/extensions/builtin/goal/continuation.js.map +1 -1
- package/dist/core/extensions/builtin/goal/direct-input-lifecycle.js +2 -2
- package/dist/core/extensions/builtin/goal/direct-input-lifecycle.js.map +1 -1
- package/dist/core/extensions/builtin/goal/format.d.ts +6 -1
- package/dist/core/extensions/builtin/goal/format.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/format.js +6 -0
- package/dist/core/extensions/builtin/goal/format.js.map +1 -1
- package/dist/core/extensions/builtin/goal/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/index.js +7 -0
- package/dist/core/extensions/builtin/goal/index.js.map +1 -1
- package/dist/core/extensions/builtin/goal/lifecycle-helpers.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/lifecycle-helpers.js +5 -2
- package/dist/core/extensions/builtin/goal/lifecycle-helpers.js.map +1 -1
- package/dist/core/extensions/builtin/goal/monitor-continuation.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/monitor-continuation.js +31 -7
- package/dist/core/extensions/builtin/goal/monitor-continuation.js.map +1 -1
- package/dist/core/extensions/builtin/goal/persistence.js +2 -0
- package/dist/core/extensions/builtin/goal/persistence.js.map +1 -1
- package/dist/core/extensions/builtin/goal/renderers.d.ts +14 -0
- package/dist/core/extensions/builtin/goal/renderers.d.ts.map +1 -0
- package/dist/core/extensions/builtin/goal/renderers.js +153 -0
- package/dist/core/extensions/builtin/goal/renderers.js.map +1 -0
- package/dist/core/extensions/builtin/goal/store.d.ts +6 -2
- package/dist/core/extensions/builtin/goal/store.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/store.js +8 -2
- package/dist/core/extensions/builtin/goal/store.js.map +1 -1
- package/dist/core/extensions/builtin/goal/tool-registration.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/tool-registration.js +16 -6
- package/dist/core/extensions/builtin/goal/tool-registration.js.map +1 -1
- package/dist/core/extensions/builtin/goal/types.d.ts +1 -0
- package/dist/core/extensions/builtin/goal/types.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/types.js.map +1 -1
- package/dist/core/extensions/builtin/imagegen/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/imagegen/index.js +10 -3
- package/dist/core/extensions/builtin/imagegen/index.js.map +1 -1
- package/dist/core/extensions/builtin/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/index.js +4 -0
- package/dist/core/extensions/builtin/index.js.map +1 -1
- package/dist/core/extensions/builtin/service-tier.d.ts.map +1 -1
- package/dist/core/extensions/builtin/service-tier.js +13 -0
- package/dist/core/extensions/builtin/service-tier.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/extension.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/extension.js +4 -2
- package/dist/core/extensions/builtin/terminal/extension.js.map +1 -1
- package/dist/core/extensions/builtin/todotools/index.js +1 -1
- package/dist/core/extensions/builtin/todotools/index.js.map +1 -1
- package/dist/core/extensions/builtin/todotools/native-todo-mirror.d.ts +1 -1
- package/dist/core/extensions/builtin/todotools/native-todo-mirror.d.ts.map +1 -1
- package/dist/core/extensions/builtin/todotools/native-todo-mirror.js +1 -1
- package/dist/core/extensions/builtin/todotools/native-todo-mirror.js.map +1 -1
- package/dist/core/hidden-stdout-log.d.ts +10 -0
- package/dist/core/hidden-stdout-log.d.ts.map +1 -1
- package/dist/core/hidden-stdout-log.js +36 -5
- package/dist/core/hidden-stdout-log.js.map +1 -1
- package/dist/core/model-config-schema.d.ts +85 -12
- package/dist/core/model-config-schema.d.ts.map +1 -1
- package/dist/core/model-config-schema.js +25 -0
- package/dist/core/model-config-schema.js.map +1 -1
- package/dist/core/model-runtime.d.ts +36 -1
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +142 -12
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/retry-fallback/chains.d.ts +23 -1
- package/dist/core/retry-fallback/chains.d.ts.map +1 -1
- package/dist/core/retry-fallback/chains.js +59 -3
- package/dist/core/retry-fallback/chains.js.map +1 -1
- package/dist/core/retry-fallback/controller.d.ts.map +1 -1
- package/dist/core/retry-fallback/controller.js +9 -2
- package/dist/core/retry-fallback/controller.js.map +1 -1
- package/dist/core/retry-fallback/settings.d.ts.map +1 -1
- package/dist/core/retry-fallback/settings.js +9 -0
- package/dist/core/retry-fallback/settings.js.map +1 -1
- package/dist/core/retry-fallback/validate.js +1 -1
- package/dist/core/retry-fallback/validate.js.map +1 -1
- package/dist/core/sdk.js +1 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.d.ts +9 -0
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +31 -0
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/tools/output-accumulator.d.ts +2 -0
- package/dist/core/tools/output-accumulator.d.ts.map +1 -1
- package/dist/core/tools/output-accumulator.js +32 -7
- 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 +7 -0
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +48 -4
- package/dist/main.js.map +1 -1
- package/dist/modes/app-server/server/account.d.ts.map +1 -1
- package/dist/modes/app-server/server/account.js +5 -5
- package/dist/modes/app-server/server/account.js.map +1 -1
- package/dist/modes/index.d.ts +1 -0
- package/dist/modes/index.d.ts.map +1 -1
- package/dist/modes/index.js +1 -0
- package/dist/modes/index.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts +11 -3
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +31 -1
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution-fallback.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution-fallback.js +82 -1
- package/dist/modes/interactive/components/tool-execution-fallback.js.map +1 -1
- package/dist/modes/interactive/grok/chrome.d.ts +4 -4
- 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/grok/footer.d.ts +3 -3
- package/dist/modes/interactive/grok/footer.d.ts.map +1 -1
- package/dist/modes/interactive/grok/footer.js.map +1 -1
- package/dist/modes/interactive/interactive-host-runtime.d.ts +44 -0
- package/dist/modes/interactive/interactive-host-runtime.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-host-runtime.js +529 -0
- package/dist/modes/interactive/interactive-host-runtime.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +340 -257
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/rpc/connection-handler.d.ts.map +1 -1
- package/dist/modes/rpc/connection-handler.js +151 -30
- package/dist/modes/rpc/connection-handler.js.map +1 -1
- package/dist/modes/rpc/host-ensure.d.ts +41 -0
- package/dist/modes/rpc/host-ensure.d.ts.map +1 -0
- package/dist/modes/rpc/host-ensure.js +245 -0
- package/dist/modes/rpc/host-ensure.js.map +1 -0
- package/dist/modes/rpc/host-lifecycle.d.ts +57 -0
- package/dist/modes/rpc/host-lifecycle.d.ts.map +1 -0
- package/dist/modes/rpc/host-lifecycle.js +491 -0
- package/dist/modes/rpc/host-lifecycle.js.map +1 -0
- package/dist/modes/rpc/host-watchdog.d.ts +33 -0
- package/dist/modes/rpc/host-watchdog.d.ts.map +1 -0
- package/dist/modes/rpc/host-watchdog.js +142 -0
- package/dist/modes/rpc/host-watchdog.js.map +1 -0
- package/dist/modes/rpc/multi-session-host.d.ts +7 -1
- package/dist/modes/rpc/multi-session-host.d.ts.map +1 -1
- package/dist/modes/rpc/multi-session-host.js +216 -32
- package/dist/modes/rpc/multi-session-host.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +115 -8
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +200 -32
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts +4 -2
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +4 -2
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +166 -3
- 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-command-router.d.ts +22 -0
- package/dist/modes/rpc/session-command-router.d.ts.map +1 -1
- package/dist/modes/rpc/session-command-router.js +165 -16
- package/dist/modes/rpc/session-command-router.js.map +1 -1
- package/dist/modes/rpc/session-event-writer.d.ts +15 -2
- package/dist/modes/rpc/session-event-writer.d.ts.map +1 -1
- package/dist/modes/rpc/session-event-writer.js +69 -25
- package/dist/modes/rpc/session-event-writer.js.map +1 -1
- package/dist/modes/rpc/session-registry.d.ts +16 -0
- package/dist/modes/rpc/session-registry.d.ts.map +1 -1
- package/dist/modes/rpc/session-registry.js +40 -3
- package/dist/modes/rpc/session-registry.js.map +1 -1
- package/docs/providers.md +48 -0
- package/docs/rpc.md +96 -5
- package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +56 -0
- package/node_modules/@code-yeongyu/senpi-codemode/package.json +4 -4
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/context-manager.ts +13 -1
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/inline-worker.ts +15 -1
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/worker-indirect-eval.js +711 -1
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/py/transport.ts +14 -1
- package/node_modules/@code-yeongyu/senpi-codemode/src/prompt/eval-prompt.ts +10 -10
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/detached-eval-result.ts +9 -3
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/eval-tool.ts +6 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/edit.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/edit.js +20 -4
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/edit.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/index.d.ts +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/index.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/index.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/post-mutate.d.ts +21 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/post-mutate.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/post-mutate.js +27 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/post-mutate.js.map +1 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/tool-context.d.ts +24 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/tool-context.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/tool-context.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/write.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/write.js +7 -2
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/write.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-tool-pairs.d.ts +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-tool-pairs.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-tool-pairs.js +46 -14
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-tool-pairs.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent.d.ts +11 -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 +30 -16
- package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/credential-store.d.ts +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/credential-store.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/credential-store.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/credential-store.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/pool/classify.d.ts +16 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/pool/classify.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/pool/classify.js +75 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/pool/classify.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/pool/failover.d.ts +45 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/pool/failover.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/pool/failover.js +81 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/pool/failover.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/pool/select.d.ts +31 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/pool/select.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/pool/select.js +65 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/pool/select.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/pool/slots.d.ts +12 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/pool/slots.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/pool/slots.js +37 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/pool/slots.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.d.ts +6 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.js +32 -6
- package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/types.d.ts +3 -2
- package/node_modules/@earendil-works/pi-ai/dist/auth/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/types.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.d.ts +6 -0
- package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.js +6 -1
- package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.d.ts +75 -0
- package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js +75 -0
- package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.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/alibaba-token-plan.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/amazon-bedrock.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/baseten.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/github-copilot.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/huggingface.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/minimax-cn.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/minimax.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/mistral.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/nvidia.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/openai-codex.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/openai.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/opengateway.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/qwen-token-plan-cn.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/qwen-token-plan.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/vercel-ai-gateway.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/dist/utils/overflow.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.js +4 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/package.json +5 -5
- 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/terminal.d.ts +5 -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 +90 -1
- package/node_modules/@earendil-works/pi-tui/dist/terminal.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/tui.js +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/tui.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/package.json +1 -1
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-tier.js","sourceRoot":"","sources":["../../../../src/core/extensions/builtin/service-tier.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAO5D,MAAM,0BAA0B,GAAG,wBAAwB,CAAC;AAC5D,MAAM,CAAC,MAAM,mBAAmB,GAAG,0BAA0B,CAAC;AAC9D,MAAM,iBAAiB,GAAG,OAAO,CAAC;AAClC,MAA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AAC,QAAQ,IAAI,WAAW,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;gBAC5F,sFAAsF;gBACtF,wFAAwF;gBACxF,uFAAuF;gBACvF,oFAAoF;gBACpF,+EAA+E;gBAC/E,MAAM,uBAAuB,GAC5B,GAAG,CAAC,KAAK,KAAK,SAAS,IAAI,GAAG,CAAC,aAAa,CAAC,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,aAAa,CAAC;gBAC1F,IACC,cAAc,KAAK,MAAM;oBACzB,aAAa,KAAK,aAAa;oBAC/B,GAAG,CAAC,WAAW,KAAK,aAAa;oBACjC,uBAAuB,EACtB,CAAC;oBACF,oBAAoB,GAAG,SAAS,CAAC;gBAClC,CAAC;qBAAM,CAAC;oBACP,oBAAoB,GAAG,GAAG,CAAC,WAAW,CAAC;gBACxC,CAAC;YACF,CAAC;QACF,CAAC;aAAM,CAAC;YACP,oBAAoB,GAAG,GAAG,CAAC,WAAW,IAAI,mBAAmB,CAAC;QAC/D,CAAC;QACD,OAAO,uBAAuB,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC;IACrF,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { Api, Model } from \"@earendil-works/pi-ai\";\nimport type { AutocompleteItem } from \"@earendil-works/pi-tui\";\nimport type { ModelRegistry } from \"../../model-registry.ts\";\nimport { SettingsManager } from \"../../settings-manager.ts\";\nimport type { ExtensionAPI, ExtensionCommandContext, ServiceTier } from \"../types.ts\";\n\nexport type { ServiceTier };\n\ntype ProviderPayload = Record<string, unknown>;\n\nconst OPENAI_CODEX_RESPONSES_API = \"openai-codex-responses\";\nexport const CODEX_RESPONSES_API = OPENAI_CODEX_RESPONSES_API;\nconst FAST_MODEL_SUFFIX = \"-fast\";\nconst PRIORITY_TIER: ServiceTier = \"priority\";\nconst SERVICE_TIER_APIS: ReadonlySet<Api> = new Set([\"openai-responses\", OPENAI_CODEX_RESPONSES_API]);\nconst FAST_ARGUMENTS = [\"on\", \"off\"] as const;\nconst FAST_USAGE = \"Usage: /fast [on|off]\";\n\ntype FastArgument = (typeof FAST_ARGUMENTS)[number];\n\nfunction isRecord(value: unknown): value is ProviderPayload {\n\treturn typeof value === \"object\" && value !== null;\n}\n\nexport function addServiceTierToPayload(api: Api | undefined, payload: unknown, serviceTier?: ServiceTier): unknown {\n\tif (!api || !SERVICE_TIER_APIS.has(api) || !serviceTier) {\n\t\treturn payload;\n\t}\n\n\tif (!isRecord(payload) || payload.service_tier !== undefined) {\n\t\treturn payload;\n\t}\n\n\treturn {\n\t\t...payload,\n\t\tservice_tier: serviceTier,\n\t};\n}\n\nfunction getRequestModelId(modelRegistry: ModelRegistry, model: Model<Api>): string {\n\treturn modelRegistry.getUpstreamModelId(model) ?? model.id;\n}\n\nfunction isCompatibleFastVariant(modelRegistry: ModelRegistry, baseModel: Model<Api>, fastModel: Model<Api>): boolean {\n\treturn (\n\t\tfastModel.provider === baseModel.provider &&\n\t\tfastModel.api === baseModel.api &&\n\t\tmodelRegistry.getServiceTier(fastModel) === \"priority\" &&\n\t\tgetRequestModelId(modelRegistry, fastModel) === getRequestModelId(modelRegistry, baseModel)\n\t);\n}\n\nfunction findBaseModel(modelRegistry: ModelRegistry, fastModel: Model<Api>): Model<Api> | undefined {\n\tif (!fastModel.id.endsWith(FAST_MODEL_SUFFIX)) {\n\t\treturn undefined;\n\t}\n\n\tconst baseModelId = fastModel.id.slice(0, -FAST_MODEL_SUFFIX.length);\n\tconst baseModel = modelRegistry.find(fastModel.provider, baseModelId);\n\treturn baseModel && isCompatibleFastVariant(modelRegistry, baseModel, fastModel) ? baseModel : undefined;\n}\n\nfunction findFastModel(modelRegistry: ModelRegistry, baseModel: Model<Api>): Model<Api> | undefined {\n\tif (baseModel.id.endsWith(FAST_MODEL_SUFFIX)) {\n\t\treturn undefined;\n\t}\n\n\tconst fastModel = modelRegistry.find(baseModel.provider, `${baseModel.id}${FAST_MODEL_SUFFIX}`);\n\treturn fastModel && isCompatibleFastVariant(modelRegistry, baseModel, fastModel) ? fastModel : undefined;\n}\n\n/**\n * The model that owns this model's persisted service-tier preference.\n *\n * A `-fast` catalog variant and its base model are one model to the user (`/fast` just swaps\n * between them), so both must read and write ONE key. Anything else can hold contradictory\n * preferences for the same choice.\n */\nexport function resolveServiceTierMemoryModel(modelRegistry: ModelRegistry, model: Model<Api>): Model<Api> {\n\treturn findBaseModel(modelRegistry, model) ?? model;\n}\n\n/** Remembered service tier for this model, normalized onto its base-model key. */\nexport function getRememberedServiceTier(\n\tsettingsManager: SettingsManager,\n\tmodelRegistry: ModelRegistry,\n\tmodel: Model<Api>,\n): ServiceTier | undefined {\n\tconst memoryModel = resolveServiceTierMemoryModel(modelRegistry, model);\n\treturn settingsManager.getModelServiceTier(memoryModel.provider, memoryModel.id);\n}\n\n/** Host capabilities `applyFastMode` needs; satisfied by an extension context plus `pi`. */\nexport interface FastModeContext {\n\tcwd: string;\n\tagentDir: string;\n\tmodel: Model<Api> | undefined;\n\tmodelRegistry: ModelRegistry;\n\t/** Tier the host resolved for the active model (scoped/favorite pin or catalog). */\n\tserviceTier: ServiceTier | undefined;\n\tisProjectTrusted(): boolean;\n\tnotify(message: string, level: \"info\" | \"warning\" | \"error\"): void;\n\tsetSessionModel(model: Model<Api>): Promise<boolean>;\n\tsetSessionFastMode(enabled: boolean): void;\n}\n\nexport interface FastModeResult {\n\t/** Fast mode state after the call; unchanged when the request was refused. */\n\tenabled: boolean;\n\t/** False when the request was refused (non-Codex model, active pin, failed model switch). */\n\tapplied: boolean;\n\t/** The just-persisted tier (or the unchanged one when refused); `\"priority\"` on, `\"auto\"` off. */\n\trecordedTier: ServiceTier;\n\tmessage: string;\n}\n\n/**\n * Whether the active model's priority tier is PINNED by the user's model selection (a scoped\n * or favorite `provider/id:priority` pattern) rather than inherited from the catalog.\n *\n * `ctx.serviceTier` merges both sources, so a priority the catalog does not explain must have\n * come from a `:priority` decorator; checking `scopedModels` alone would miss favorite pins,\n * which the session resolves the same way.\n */\nfunction hasPriorityPin(ctx: FastModeContext, model: Model<Api>): boolean {\n\tif (ctx.serviceTier !== PRIORITY_TIER) return false;\n\treturn ctx.modelRegistry.getServiceTier(model) !== PRIORITY_TIER;\n}\n\n/**\n * Single entry point for turning fast mode on/off: the `/fast` command and any other surface\n * (RPC) must go through this so persistence and `-fast` key normalization exist exactly once.\n *\n * `off` persists an explicit `\"auto\"` rather than deleting the key: deletion re-inherits the\n * catalog/global tier, which is what the user just asked to turn off.\n */\nexport async function applyFastMode(ctx: FastModeContext, enabled: boolean): Promise<FastModeResult> {\n\tconst model = ctx.model;\n\tif (model?.api !== OPENAI_CODEX_RESPONSES_API) {\n\t\tconst message = \"Fast mode is only available for OpenAI Codex models.\";\n\t\tctx.notify(message, \"warning\");\n\t\treturn { enabled: false, applied: false, recordedTier: \"auto\", message };\n\t}\n\n\tif (!enabled && hasPriorityPin(ctx, model)) {\n\t\t// The pin outranks the memory, so writing \"auto\" here would be a silent no-op on the wire.\n\t\tconst message = \"Fast mode is fixed by the active model selection's priority tier.\";\n\t\tctx.notify(message, \"info\");\n\t\t// The pin keeps the model on priority no matter what the memory says, so that is the honest\n\t\t// tier to report; nothing was written, and no caller reads this field when `applied` is false.\n\t\treturn { enabled: true, applied: false, recordedTier: PRIORITY_TIER, message };\n\t}\n\n\tconst settingsManager = SettingsManager.create(ctx.cwd, ctx.agentDir, { projectTrusted: ctx.isProjectTrusted() });\n\tconst memoryModel = resolveServiceTierMemoryModel(ctx.modelRegistry, model);\n\tconst tier: ServiceTier = enabled ? PRIORITY_TIER : \"auto\";\n\tsettingsManager.setModelServiceTier(memoryModel.provider, memoryModel.id, tier);\n\tawait settingsManager.flush();\n\n\tconst baseModel = findBaseModel(ctx.modelRegistry, model);\n\tconst targetModel = enabled ? findFastModel(ctx.modelRegistry, model) : baseModel;\n\tif (targetModel) {\n\t\tif (!(await ctx.setSessionModel(targetModel))) {\n\t\t\tconst message = `Could not switch to ${targetModel.provider}/${targetModel.id}.`;\n\t\t\tctx.notify(message, \"error\");\n\t\t\treturn { enabled: baseModel === undefined, applied: false, recordedTier: \"auto\", message };\n\t\t}\n\t}\n\n\tctx.setSessionFastMode(enabled);\n\tconst labelModel = targetModel ?? model;\n\tconst message = `Fast mode ${enabled ? \"enabled\" : \"disabled\"}: ${labelModel.id}`;\n\tctx.notify(message, \"info\");\n\treturn { enabled, applied: true, recordedTier: tier, message };\n}\n\nfunction toCompletions(values: readonly string[], prefix: string): AutocompleteItem[] | null {\n\tconst matches = values.filter((value) => value.startsWith(prefix.trim()));\n\treturn matches.length > 0 ? matches.map((value) => ({ value, label: value })) : null;\n}\n\nfunction toFastModeContext(pi: ExtensionAPI, ctx: ExtensionCommandContext): FastModeContext {\n\treturn {\n\t\tcwd: ctx.cwd,\n\t\tagentDir: ctx.agentDir,\n\t\tmodel: ctx.model,\n\t\tmodelRegistry: ctx.modelRegistry,\n\t\tserviceTier: ctx.serviceTier,\n\t\tisProjectTrusted: () => ctx.isProjectTrusted(),\n\t\tnotify: (message, level) => ctx.ui.notify(message, level),\n\t\tsetSessionModel: (model) => pi.setSessionModel(model),\n\t\tsetSessionFastMode: (enabled) => pi.setSessionFastMode(enabled),\n\t};\n}\n\nexport default function serviceTierExtension(pi: ExtensionAPI): void {\n\tlet settingsServiceTier: ServiceTier | undefined;\n\t/**\n\t * Session-level fast mode for Codex models that have no `-fast` catalog sibling.\n\t *\n\t * The catalog generator emits `-fast` priority variants only for the direct\n\t * `openai` provider, so `openai-codex` models never have a switch target. The\n\t * ChatGPT backend still offers the tier to subscriptions:\n\t * `chatgpt.com/backend-api/codex/models` advertises a `priority` service tier\n\t * labelled \"Fast\" (\"1.5x speed, increased usage\")\n\t * for gpt-5.4/5.5/5.6-*, and the first-party Codex CLI sends\n\t * `service_tier: \"priority\"` on subscription OAuth. The response echo is not a\n\t * confirmation channel — it reads `auto`/`default` whether or not a tier was\n\t * sent — so this toggle drives the request field directly. See issue #545.\n\t */\n\tlet sessionFastMode = false;\n\t/**\n\t * The per-model memory tier `/fast` last wrote or read for the active base model this\n\t * session. Lives only to suppress an inherited priority when the user turns fast off in\n\t * the SAME session: the host's resolved `ctx.serviceTier` is recomputed on model switch,\n\t * not on a memory write, so without this an in-session `/fast off` (no model swap) would\n\t * keep sending `priority` until a restart. Scoped to the active base key (re-derived on\n\t * model_select for the incoming model) so it never leaks across models.\n\t */\n\tlet liveMemoryTier: ServiceTier | undefined;\n\tlet liveMemoryKey: string | undefined;\n\n\tpi.on(\"session_start\", async (_event, ctx) => {\n\t\tconst settingsManager = SettingsManager.create(ctx.cwd, ctx.agentDir, { projectTrusted: ctx.isProjectTrusted() });\n\t\tsettingsServiceTier = settingsManager.getOpenAIServiceTier();\n\n\t\tconst model = ctx.model;\n\t\tif (model?.api !== OPENAI_CODEX_RESPONSES_API) {\n\t\t\tsessionFastMode = false;\n\t\t\tpi.setSessionFastMode(false);\n\t\t\treturn;\n\t\t}\n\n\t\t// Fast mode is remembered per model, so a new session inherits the user's last choice for\n\t\t// THIS model instead of silently starting off. A model whose catalog/scoped tier is already\n\t\t// `priority` (a models.json priority entry, or a `-fast`-less codex model) is treated as\n\t\t// fast-active when nothing is remembered; an explicit remembered `\"auto\"` (`/fast off`)\n\t\t// wins over that inheritance. Malformed values read back as undefined.\n\t\t//\n\t\t// The flag is derived from the POST-swap model: a `-fast` catalog variant swaps down to\n\t\t// its base before this reads `ctx.serviceTier`, so inheritance is judged on the model the\n\t\t// user actually ends up on.\n\t\tconst remembered = getRememberedServiceTier(settingsManager, ctx.modelRegistry, model);\n\n\t\tconst baseModel = findBaseModel(ctx.modelRegistry, model);\n\t\tif (baseModel) {\n\t\t\tawait pi.setSessionModel(baseModel);\n\t\t}\n\n\t\tsessionFastMode = remembered === PRIORITY_TIER || (remembered === undefined && ctx.serviceTier === PRIORITY_TIER);\n\t\tpi.setSessionFastMode(sessionFastMode);\n\t\tconst memoryModel = resolveServiceTierMemoryModel(ctx.modelRegistry, model);\n\t\tliveMemoryKey = `${memoryModel.provider}/${memoryModel.id}`;\n\t\tliveMemoryTier = remembered;\n\t});\n\n\tpi.on(\"model_select\", (event, ctx) => {\n\t\t// A model switch changes the base key the memory lives under, so the live tier is RE-DERIVED\n\t\t// for the incoming model instead of merely dropped: dropping it would leave a remembered\n\t\t// \"auto\" unable to suppress a catalog-inherited priority after switching away and back in one\n\t\t// session, silently re-sending the tier `/fast off` turned off. Per-key scoping is preserved —\n\t\t// each model reads ITS OWN memory, never the previous model's.\n\t\tconst settingsManager = SettingsManager.create(ctx.cwd, ctx.agentDir, { projectTrusted: ctx.isProjectTrusted() });\n\t\tconst memoryModel = resolveServiceTierMemoryModel(ctx.modelRegistry, event.model);\n\t\tliveMemoryKey = `${memoryModel.provider}/${memoryModel.id}`;\n\t\tliveMemoryTier = getRememberedServiceTier(settingsManager, ctx.modelRegistry, event.model);\n\t});\n\n\tpi.registerCommand(\"fast\", {\n\t\tdescription: \"Turn OpenAI Codex fast mode on or off for the current model\",\n\t\targumentHint: \"[on|off]\",\n\t\tgetArgumentCompletions: (prefix) => toCompletions(FAST_ARGUMENTS, prefix),\n\t\thandler: async (args, ctx) => {\n\t\t\tconst argument = args.trim().toLowerCase();\n\t\t\tif (argument !== \"\" && !FAST_ARGUMENTS.includes(argument as FastArgument)) {\n\t\t\t\tctx.ui.notify(FAST_USAGE, \"error\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// No argument keeps the established toggle UX.\n\t\t\tconst active = sessionFastMode || ctx.serviceTier === PRIORITY_TIER;\n\t\t\tconst enabled = argument === \"\" ? !active : argument === \"on\";\n\t\t\tconst result = await applyFastMode(toFastModeContext(pi, ctx), enabled);\n\t\t\tsessionFastMode = result.enabled;\n\t\t\t// Track this session's own write AFTER applyFastMode's internal model switch (which fires\n\t\t\t// model_select and clears the live tier). Keyed to the active base model so a later switch\n\t\t\t// cannot carry it across models.\n\t\t\tif (result.applied && ctx.model) {\n\t\t\t\tconst memoryModel = resolveServiceTierMemoryModel(ctx.modelRegistry, ctx.model);\n\t\t\t\tliveMemoryKey = `${memoryModel.provider}/${memoryModel.id}`;\n\t\t\t\tliveMemoryTier = result.recordedTier;\n\t\t\t}\n\t\t},\n\t});\n\n\tpi.on(\"before_provider_request\", (event, ctx) => {\n\t\tlet effectiveServiceTier: ServiceTier | undefined;\n\t\tif (ctx.model?.api === OPENAI_CODEX_RESPONSES_API) {\n\t\t\tif (sessionFastMode) {\n\t\t\t\teffectiveServiceTier = PRIORITY_TIER;\n\t\t\t} else {\n\t\t\t\tconst memoryModel = ctx.model ? resolveServiceTierMemoryModel(ctx.modelRegistry, ctx.model) : undefined;\n\t\t\t\tconst activeBaseKey = memoryModel ? `${memoryModel.provider}/${memoryModel.id}` : undefined;\n\t\t\t\t// Same-session /fast off: the host's resolved ctx.serviceTier is only recomputed on a\n\t\t\t\t// model switch, so an inherited priority would otherwise keep emitting until a restart.\n\t\t\t\t// Only a CATALOG-explained priority may be suppressed: a priority the catalog does not\n\t\t\t\t// explain is an explicit scoped/favorite `:priority` pin, which outranks the memory\n\t\t\t\t// (same discriminator `applyFastMode` uses to refuse `/fast off` under a pin).\n\t\t\t\tconst catalogExplainsPriority =\n\t\t\t\t\tctx.model !== undefined && ctx.modelRegistry.getServiceTier(ctx.model) === PRIORITY_TIER;\n\t\t\t\tif (\n\t\t\t\t\tliveMemoryTier === \"auto\" &&\n\t\t\t\t\tactiveBaseKey === liveMemoryKey &&\n\t\t\t\t\tctx.serviceTier === PRIORITY_TIER &&\n\t\t\t\t\tcatalogExplainsPriority\n\t\t\t\t) {\n\t\t\t\t\teffectiveServiceTier = undefined;\n\t\t\t\t} else {\n\t\t\t\t\teffectiveServiceTier = ctx.serviceTier;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\teffectiveServiceTier = ctx.serviceTier ?? settingsServiceTier;\n\t\t}\n\t\treturn addServiceTierToPayload(ctx.model?.api, event.payload, effectiveServiceTier);\n\t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;QAC/D,CAAC;QACD,OAAO,uBAAuB,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC;IACrF,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { Api, Model } from \"@earendil-works/pi-ai\";\nimport type { AutocompleteItem } from \"@earendil-works/pi-tui\";\nimport type { ModelRegistry } from \"../../model-registry.ts\";\nimport { SettingsManager } from \"../../settings-manager.ts\";\nimport type { ExtensionAPI, ExtensionCommandContext, ServiceTier } from \"../types.ts\";\n\nexport type { ServiceTier };\n\ntype ProviderPayload = Record<string, unknown>;\n\nconst OPENAI_CODEX_RESPONSES_API = \"openai-codex-responses\";\nexport const CODEX_RESPONSES_API = OPENAI_CODEX_RESPONSES_API;\nconst FAST_MODEL_SUFFIX = \"-fast\";\nconst PRIORITY_TIER: ServiceTier = \"priority\";\nconst SERVICE_TIER_APIS: ReadonlySet<Api> = new Set([\"openai-responses\", OPENAI_CODEX_RESPONSES_API]);\nconst FAST_ARGUMENTS = [\"on\", \"off\"] as const;\nconst FAST_USAGE = \"Usage: /fast [on|off]\";\n\ntype FastArgument = (typeof FAST_ARGUMENTS)[number];\n\nfunction isRecord(value: unknown): value is ProviderPayload {\n\treturn typeof value === \"object\" && value !== null;\n}\n\nexport function addServiceTierToPayload(api: Api | undefined, payload: unknown, serviceTier?: ServiceTier): unknown {\n\tif (!api || !SERVICE_TIER_APIS.has(api) || !serviceTier) {\n\t\treturn payload;\n\t}\n\n\tif (!isRecord(payload) || payload.service_tier !== undefined) {\n\t\treturn payload;\n\t}\n\n\treturn {\n\t\t...payload,\n\t\tservice_tier: serviceTier,\n\t};\n}\n\nfunction getRequestModelId(modelRegistry: ModelRegistry, model: Model<Api>): string {\n\treturn modelRegistry.getUpstreamModelId(model) ?? model.id;\n}\n\nfunction isCompatibleFastVariant(modelRegistry: ModelRegistry, baseModel: Model<Api>, fastModel: Model<Api>): boolean {\n\treturn (\n\t\tfastModel.provider === baseModel.provider &&\n\t\tfastModel.api === baseModel.api &&\n\t\tmodelRegistry.getServiceTier(fastModel) === \"priority\" &&\n\t\tgetRequestModelId(modelRegistry, fastModel) === getRequestModelId(modelRegistry, baseModel)\n\t);\n}\n\nfunction findBaseModel(modelRegistry: ModelRegistry, fastModel: Model<Api>): Model<Api> | undefined {\n\tif (!fastModel.id.endsWith(FAST_MODEL_SUFFIX)) {\n\t\treturn undefined;\n\t}\n\n\tconst baseModelId = fastModel.id.slice(0, -FAST_MODEL_SUFFIX.length);\n\tconst baseModel = modelRegistry.find(fastModel.provider, baseModelId);\n\treturn baseModel && isCompatibleFastVariant(modelRegistry, baseModel, fastModel) ? baseModel : undefined;\n}\n\nfunction findFastModel(modelRegistry: ModelRegistry, baseModel: Model<Api>): Model<Api> | undefined {\n\tif (baseModel.id.endsWith(FAST_MODEL_SUFFIX)) {\n\t\treturn undefined;\n\t}\n\n\tconst fastModel = modelRegistry.find(baseModel.provider, `${baseModel.id}${FAST_MODEL_SUFFIX}`);\n\treturn fastModel && isCompatibleFastVariant(modelRegistry, baseModel, fastModel) ? fastModel : undefined;\n}\n\n/**\n * The model that owns this model's persisted service-tier preference.\n *\n * A `-fast` catalog variant and its base model are one model to the user (`/fast` just swaps\n * between them), so both must read and write ONE key. Anything else can hold contradictory\n * preferences for the same choice.\n */\nexport function resolveServiceTierMemoryModel(modelRegistry: ModelRegistry, model: Model<Api>): Model<Api> {\n\treturn findBaseModel(modelRegistry, model) ?? model;\n}\n\n/** Remembered service tier for this model, normalized onto its base-model key. */\nexport function getRememberedServiceTier(\n\tsettingsManager: SettingsManager,\n\tmodelRegistry: ModelRegistry,\n\tmodel: Model<Api>,\n): ServiceTier | undefined {\n\tconst memoryModel = resolveServiceTierMemoryModel(modelRegistry, model);\n\treturn settingsManager.getModelServiceTier(memoryModel.provider, memoryModel.id);\n}\n\n/** Host capabilities `applyFastMode` needs; satisfied by an extension context plus `pi`. */\nexport interface FastModeContext {\n\tcwd: string;\n\tagentDir: string;\n\tmodel: Model<Api> | undefined;\n\tmodelRegistry: ModelRegistry;\n\t/** Tier the host resolved for the active model (scoped/favorite pin or catalog). */\n\tserviceTier: ServiceTier | undefined;\n\tisProjectTrusted(): boolean;\n\tnotify(message: string, level: \"info\" | \"warning\" | \"error\"): void;\n\tsetSessionModel(model: Model<Api>): Promise<boolean>;\n\tsetSessionFastMode(enabled: boolean): void;\n}\n\nexport interface FastModeResult {\n\t/** Fast mode state after the call; unchanged when the request was refused. */\n\tenabled: boolean;\n\t/** False when the request was refused (non-Codex model, active pin, failed model switch). */\n\tapplied: boolean;\n\t/** The just-persisted tier (or the unchanged one when refused); `\"priority\"` on, `\"auto\"` off. */\n\trecordedTier: ServiceTier;\n\tmessage: string;\n}\n\n/**\n * Whether the active model's priority tier is PINNED by the user's model selection (a scoped\n * or favorite `provider/id:priority` pattern) rather than inherited from the catalog.\n *\n * `ctx.serviceTier` merges both sources, so a priority the catalog does not explain must have\n * come from a `:priority` decorator; checking `scopedModels` alone would miss favorite pins,\n * which the session resolves the same way.\n */\nfunction hasPriorityPin(ctx: FastModeContext, model: Model<Api>): boolean {\n\tif (ctx.serviceTier !== PRIORITY_TIER) return false;\n\treturn ctx.modelRegistry.getServiceTier(model) !== PRIORITY_TIER;\n}\n\n/**\n * Single entry point for turning fast mode on/off: the `/fast` command and any other surface\n * (RPC) must go through this so persistence and `-fast` key normalization exist exactly once.\n *\n * `off` persists an explicit `\"auto\"` rather than deleting the key: deletion re-inherits the\n * catalog/global tier, which is what the user just asked to turn off.\n */\nexport async function applyFastMode(ctx: FastModeContext, enabled: boolean): Promise<FastModeResult> {\n\tconst model = ctx.model;\n\tif (model?.api !== OPENAI_CODEX_RESPONSES_API) {\n\t\tconst message = \"Fast mode is only available for OpenAI Codex models.\";\n\t\tctx.notify(message, \"warning\");\n\t\treturn { enabled: false, applied: false, recordedTier: \"auto\", message };\n\t}\n\n\tif (!enabled && hasPriorityPin(ctx, model)) {\n\t\t// The pin outranks the memory, so writing \"auto\" here would be a silent no-op on the wire.\n\t\tconst message = \"Fast mode is fixed by the active model selection's priority tier.\";\n\t\tctx.notify(message, \"info\");\n\t\t// The pin keeps the model on priority no matter what the memory says, so that is the honest\n\t\t// tier to report; nothing was written, and no caller reads this field when `applied` is false.\n\t\treturn { enabled: true, applied: false, recordedTier: PRIORITY_TIER, message };\n\t}\n\n\tconst settingsManager = SettingsManager.create(ctx.cwd, ctx.agentDir, { projectTrusted: ctx.isProjectTrusted() });\n\tconst memoryModel = resolveServiceTierMemoryModel(ctx.modelRegistry, model);\n\tconst tier: ServiceTier = enabled ? PRIORITY_TIER : \"auto\";\n\tsettingsManager.setModelServiceTier(memoryModel.provider, memoryModel.id, tier);\n\tawait settingsManager.flush();\n\n\tconst baseModel = findBaseModel(ctx.modelRegistry, model);\n\tconst targetModel = enabled ? findFastModel(ctx.modelRegistry, model) : baseModel;\n\tif (targetModel) {\n\t\tif (!(await ctx.setSessionModel(targetModel))) {\n\t\t\tconst message = `Could not switch to ${targetModel.provider}/${targetModel.id}.`;\n\t\t\tctx.notify(message, \"error\");\n\t\t\treturn { enabled: baseModel === undefined, applied: false, recordedTier: \"auto\", message };\n\t\t}\n\t}\n\n\tctx.setSessionFastMode(enabled);\n\tconst labelModel = targetModel ?? model;\n\tconst message = `Fast mode ${enabled ? \"enabled\" : \"disabled\"}: ${labelModel.id}`;\n\tctx.notify(message, \"info\");\n\treturn { enabled, applied: true, recordedTier: tier, message };\n}\n\nfunction toCompletions(values: readonly string[], prefix: string): AutocompleteItem[] | null {\n\tconst matches = values.filter((value) => value.startsWith(prefix.trim()));\n\treturn matches.length > 0 ? matches.map((value) => ({ value, label: value })) : null;\n}\n\nfunction toFastModeContext(pi: ExtensionAPI, ctx: ExtensionCommandContext): FastModeContext {\n\treturn {\n\t\tcwd: ctx.cwd,\n\t\tagentDir: ctx.agentDir,\n\t\tmodel: ctx.model,\n\t\tmodelRegistry: ctx.modelRegistry,\n\t\tserviceTier: ctx.serviceTier,\n\t\tisProjectTrusted: () => ctx.isProjectTrusted(),\n\t\tnotify: (message, level) => ctx.ui.notify(message, level),\n\t\tsetSessionModel: (model) => pi.setSessionModel(model),\n\t\tsetSessionFastMode: (enabled) => pi.setSessionFastMode(enabled),\n\t};\n}\n\nexport default function serviceTierExtension(pi: ExtensionAPI): void {\n\tlet settingsServiceTier: ServiceTier | undefined;\n\t/**\n\t * Session-level fast mode for Codex models that have no `-fast` catalog sibling.\n\t *\n\t * The catalog generator emits `-fast` priority variants only for the direct\n\t * `openai` provider, so `openai-codex` models never have a switch target. The\n\t * ChatGPT backend still offers the tier to subscriptions:\n\t * `chatgpt.com/backend-api/codex/models` advertises a `priority` service tier\n\t * labelled \"Fast\" (\"1.5x speed, increased usage\")\n\t * for gpt-5.4/5.5/5.6-*, and the first-party Codex CLI sends\n\t * `service_tier: \"priority\"` on subscription OAuth. The response echo is not a\n\t * confirmation channel — it reads `auto`/`default` whether or not a tier was\n\t * sent — so this toggle drives the request field directly. See issue #545.\n\t */\n\tlet sessionFastMode = false;\n\t/**\n\t * The per-model memory tier `/fast` last wrote or read for the active base model this\n\t * session. Lives only to suppress an inherited priority when the user turns fast off in\n\t * the SAME session: the host's resolved `ctx.serviceTier` is recomputed on model switch,\n\t * not on a memory write, so without this an in-session `/fast off` (no model swap) would\n\t * keep sending `priority` until a restart. Scoped to the active base key (re-derived on\n\t * model_select for the incoming model) so it never leaks across models.\n\t */\n\tlet liveMemoryTier: ServiceTier | undefined;\n\tlet liveMemoryKey: string | undefined;\n\n\tpi.on(\"session_start\", async (_event, ctx) => {\n\t\tconst settingsManager = SettingsManager.create(ctx.cwd, ctx.agentDir, { projectTrusted: ctx.isProjectTrusted() });\n\t\tsettingsServiceTier = settingsManager.getOpenAIServiceTier();\n\n\t\tconst model = ctx.model;\n\t\tif (model?.api !== OPENAI_CODEX_RESPONSES_API) {\n\t\t\tsessionFastMode = false;\n\t\t\tpi.setSessionFastMode(false);\n\t\t\treturn;\n\t\t}\n\n\t\t// Fast mode is remembered per model, so a new session inherits the user's last choice for\n\t\t// THIS model instead of silently starting off. A model whose catalog/scoped tier is already\n\t\t// `priority` (a models.json priority entry, or a `-fast`-less codex model) is treated as\n\t\t// fast-active when nothing is remembered; an explicit remembered `\"auto\"` (`/fast off`)\n\t\t// wins over that inheritance. Malformed values read back as undefined.\n\t\t//\n\t\t// The flag is derived from the POST-swap model: a `-fast` catalog variant swaps down to\n\t\t// its base before this reads `ctx.serviceTier`, so inheritance is judged on the model the\n\t\t// user actually ends up on.\n\t\tconst remembered = getRememberedServiceTier(settingsManager, ctx.modelRegistry, model);\n\n\t\tconst baseModel = findBaseModel(ctx.modelRegistry, model);\n\t\tif (baseModel) {\n\t\t\tawait pi.setSessionModel(baseModel);\n\t\t}\n\n\t\tsessionFastMode = remembered === PRIORITY_TIER || (remembered === undefined && ctx.serviceTier === PRIORITY_TIER);\n\t\tpi.setSessionFastMode(sessionFastMode);\n\t\tconst memoryModel = resolveServiceTierMemoryModel(ctx.modelRegistry, model);\n\t\tliveMemoryKey = `${memoryModel.provider}/${memoryModel.id}`;\n\t\tliveMemoryTier = remembered;\n\t});\n\n\tpi.on(\"model_select\", (event, ctx) => {\n\t\t// A model switch changes the base key the memory lives under, so the live tier is RE-DERIVED\n\t\t// for the incoming model instead of merely dropped: dropping it would leave a remembered\n\t\t// \"auto\" unable to suppress a catalog-inherited priority after switching away and back in one\n\t\t// session, silently re-sending the tier `/fast off` turned off. Per-key scoping is preserved —\n\t\t// each model reads ITS OWN memory, never the previous model's.\n\t\tconst settingsManager = SettingsManager.create(ctx.cwd, ctx.agentDir, { projectTrusted: ctx.isProjectTrusted() });\n\t\tconst memoryModel = resolveServiceTierMemoryModel(ctx.modelRegistry, event.model);\n\t\tliveMemoryKey = `${memoryModel.provider}/${memoryModel.id}`;\n\t\tliveMemoryTier = getRememberedServiceTier(settingsManager, ctx.modelRegistry, event.model);\n\n\t\t// `service_tier` is an OpenAI-family request field, so hopping to a non-Codex model leaves the\n\t\t// intent with nothing to act on: `before_provider_request` already refuses to emit the tier\n\t\t// there, but the session flag kept `isFastModeActive()` (and with it the RPC `fastMode` and the\n\t\t// lightning indicator) claiming fast for a model that can never be served at that tier.\n\t\t//\n\t\t// Codex -> Codex is deliberately untouched: fast mode is a SESSION intent that survives a\n\t\t// mid-session Codex switch (see service-tier-extension.test.ts \"keeps session fast mode on\n\t\t// across a mid-session switch to another Codex model\"), and an incoming model's remembered\n\t\t// \"auto\" is honored on the wire by `liveMemoryTier` below, not by clearing the flag here.\n\t\tif (sessionFastMode && event.model.api !== OPENAI_CODEX_RESPONSES_API) {\n\t\t\tsessionFastMode = false;\n\t\t\tpi.setSessionFastMode(false);\n\t\t}\n\t});\n\n\tpi.registerCommand(\"fast\", {\n\t\tdescription: \"Turn OpenAI Codex fast mode on or off for the current model\",\n\t\targumentHint: \"[on|off]\",\n\t\tgetArgumentCompletions: (prefix) => toCompletions(FAST_ARGUMENTS, prefix),\n\t\thandler: async (args, ctx) => {\n\t\t\tconst argument = args.trim().toLowerCase();\n\t\t\tif (argument !== \"\" && !FAST_ARGUMENTS.includes(argument as FastArgument)) {\n\t\t\t\tctx.ui.notify(FAST_USAGE, \"error\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// No argument keeps the established toggle UX.\n\t\t\tconst active = sessionFastMode || ctx.serviceTier === PRIORITY_TIER;\n\t\t\tconst enabled = argument === \"\" ? !active : argument === \"on\";\n\t\t\tconst result = await applyFastMode(toFastModeContext(pi, ctx), enabled);\n\t\t\tsessionFastMode = result.enabled;\n\t\t\t// Track this session's own write AFTER applyFastMode's internal model switch (which fires\n\t\t\t// model_select and clears the live tier). Keyed to the active base model so a later switch\n\t\t\t// cannot carry it across models.\n\t\t\tif (result.applied && ctx.model) {\n\t\t\t\tconst memoryModel = resolveServiceTierMemoryModel(ctx.modelRegistry, ctx.model);\n\t\t\t\tliveMemoryKey = `${memoryModel.provider}/${memoryModel.id}`;\n\t\t\t\tliveMemoryTier = result.recordedTier;\n\t\t\t}\n\t\t},\n\t});\n\n\tpi.on(\"before_provider_request\", (event, ctx) => {\n\t\tlet effectiveServiceTier: ServiceTier | undefined;\n\t\tif (ctx.model?.api === OPENAI_CODEX_RESPONSES_API) {\n\t\t\tif (sessionFastMode) {\n\t\t\t\teffectiveServiceTier = PRIORITY_TIER;\n\t\t\t} else {\n\t\t\t\tconst memoryModel = ctx.model ? resolveServiceTierMemoryModel(ctx.modelRegistry, ctx.model) : undefined;\n\t\t\t\tconst activeBaseKey = memoryModel ? `${memoryModel.provider}/${memoryModel.id}` : undefined;\n\t\t\t\t// Same-session /fast off: the host's resolved ctx.serviceTier is only recomputed on a\n\t\t\t\t// model switch, so an inherited priority would otherwise keep emitting until a restart.\n\t\t\t\t// Only a CATALOG-explained priority may be suppressed: a priority the catalog does not\n\t\t\t\t// explain is an explicit scoped/favorite `:priority` pin, which outranks the memory\n\t\t\t\t// (same discriminator `applyFastMode` uses to refuse `/fast off` under a pin).\n\t\t\t\tconst catalogExplainsPriority =\n\t\t\t\t\tctx.model !== undefined && ctx.modelRegistry.getServiceTier(ctx.model) === PRIORITY_TIER;\n\t\t\t\tif (\n\t\t\t\t\tliveMemoryTier === \"auto\" &&\n\t\t\t\t\tactiveBaseKey === liveMemoryKey &&\n\t\t\t\t\tctx.serviceTier === PRIORITY_TIER &&\n\t\t\t\t\tcatalogExplainsPriority\n\t\t\t\t) {\n\t\t\t\t\teffectiveServiceTier = undefined;\n\t\t\t\t} else {\n\t\t\t\t\teffectiveServiceTier = ctx.serviceTier;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\teffectiveServiceTier = ctx.serviceTier ?? settingsServiceTier;\n\t\t}\n\t\treturn addServiceTierToPayload(ctx.model?.api, event.payload, effectiveServiceTier);\n\t});\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/terminal/extension.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAoB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"extension.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/terminal/extension.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAoB,MAAM,gBAAgB,CAAC;AAoKrE,wBAAgB,yBAAyB,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,CAsGhE;AAED,eAAe,yBAAyB,CAAC"}
|
|
@@ -32,7 +32,7 @@ function bundleSinks(pi, state) {
|
|
|
32
32
|
onMonitorEvent: (event) => state.monitorNotifier?.notifyEvent(event),
|
|
33
33
|
onMonitorState: (snapshot) => {
|
|
34
34
|
state.statusTicker.sync(snapshot);
|
|
35
|
-
|
|
35
|
+
const payload = {
|
|
36
36
|
activeCount: snapshot.length,
|
|
37
37
|
monitors: snapshot.map((entry) => ({
|
|
38
38
|
id: entry.id,
|
|
@@ -40,7 +40,9 @@ function bundleSinks(pi, state) {
|
|
|
40
40
|
paused: entry.paused,
|
|
41
41
|
startedAtMs: entry.startedAtMs,
|
|
42
42
|
})),
|
|
43
|
-
}
|
|
43
|
+
};
|
|
44
|
+
pi.events?.emit(TERMINAL_MONITOR_STATE_EVENT, payload);
|
|
45
|
+
pi.rpc?.emit(TERMINAL_MONITOR_STATE_EVENT, payload);
|
|
44
46
|
pi.events?.emit(WAKE_SOURCE_STATE_EVENT, {
|
|
45
47
|
source: "terminal-monitors",
|
|
46
48
|
activeCount: snapshot.length,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/terminal/extension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,4B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C,CAAC;IACtE,CAAC,CAAC,CAAC;AACJ,CAAC;AAED,eAAe,yBAAyB,CAAC","sourcesContent":["import { getShellEnv } from \"../../../../utils/shell.ts\";\nimport { SettingsManager } from \"../../../settings-manager.ts\";\nimport type { ExtensionAPI, ExtensionContext } from \"../../types.ts\";\nimport { isAnthropicBashEnabled } from \"../anthropic-bash/index.ts\";\nimport { TERMINAL_MONITOR_STATE_EVENT, WAKE_SOURCE_STATE_EVENT } from \"../monitor-state-event.ts\";\nimport { MonitorNotifier } from \"./monitor-notify.ts\";\nimport { MONITOR_STATUS_KEY } from \"./monitor-status.ts\";\nimport { MonitorStatusTicker } from \"./monitor-status-ticker.ts\";\nimport { TerminalNotifier } from \"./notify.ts\";\nimport { TERMINAL_PROMPT_SECTION } from \"./prompt.ts\";\nimport type { TerminalRuntimeSession } from \"./runtime-session.ts\";\nimport {\n\tclaimParkedBundle,\n\tparkBundle,\n\ttype TerminalEventSinks,\n\tTerminalSessionBundle,\n\tteardownParkedBundle,\n} from \"./session-bundle.ts\";\nimport { loadTerminalSettings, type ResolvedTerminalSettings, TERMINAL_SETTINGS_DEFAULTS } from \"./settings.ts\";\nimport { TERMINAL_BASH_TOOL, TERMINAL_COMPANION_TOOLS } from \"./shared.ts\";\nimport { createPtyBashTool } from \"./tools/bash.ts\";\nimport { createBashInputTool } from \"./tools/bash-input.ts\";\nimport { createBashOutputTool } from \"./tools/bash-output.ts\";\nimport { createBashResizeTool } from \"./tools/bash-resize.ts\";\nimport type { TerminalToolContext } from \"./tools/context.ts\";\nimport { createKillBashTool } from \"./tools/kill-bash.ts\";\nimport { createMonitorTool } from \"./tools/monitor.ts\";\n\ninterface TerminalExtensionState {\n\tbundle: TerminalSessionBundle | null;\n\tsettings: ResolvedTerminalSettings;\n\tnotifier: TerminalNotifier | null;\n\tmonitorNotifier: MonitorNotifier | null;\n\tstatusTicker: MonitorStatusTicker;\n\tctx: ExtensionContext | undefined;\n\tshellPath: string | undefined;\n\tsteppedAside: boolean;\n\tnoticeShown: boolean;\n}\n\n/** Tests and SDK callers may hand partial contexts without a session manager. */\nfunction sessionKeyOf(ctx: ExtensionContext | undefined): string | undefined {\n\treturn ctx?.sessionManager?.getSessionId?.();\n}\n\nfunction createBundle(state: TerminalExtensionState): TerminalSessionBundle {\n\treturn new TerminalSessionBundle({\n\t\tmaxSessions: state.settings.maxSessions,\n\t\tscrollback: state.settings.scrollback,\n\t});\n}\n\n/** Sinks read the live instance state at call time, so notifier swaps need no re-bind. */\nfunction bundleSinks(pi: ExtensionAPI, state: TerminalExtensionState): TerminalEventSinks {\n\treturn {\n\t\tonMonitorEvent: (event) => state.monitorNotifier?.notifyEvent(event),\n\t\tonMonitorState: (snapshot) => {\n\t\t\tstate.statusTicker.sync(snapshot);\n\t\t\tpi.events?.emit(TERMINAL_MONITOR_STATE_EVENT, {\n\t\t\t\tactiveCount: snapshot.length,\n\t\t\t\tmonitors: snapshot.map((entry) => ({\n\t\t\t\t\tid: entry.id,\n\t\t\t\t\tdescription: entry.description,\n\t\t\t\t\tpaused: entry.paused,\n\t\t\t\t\tstartedAtMs: entry.startedAtMs,\n\t\t\t\t})),\n\t\t\t});\n\t\t\tpi.events?.emit(WAKE_SOURCE_STATE_EVENT, {\n\t\t\t\tsource: \"terminal-monitors\",\n\t\t\t\tactiveCount: snapshot.length,\n\t\t\t\tmonitors: snapshot.map((entry) => ({\n\t\t\t\t\tid: entry.id,\n\t\t\t\t\tdescription: entry.description,\n\t\t\t\t\tstartedAtMs: entry.startedAtMs,\n\t\t\t\t})),\n\t\t\t});\n\t\t},\n\t\tonBackgroundState: (snapshot) => {\n\t\t\tpi.events?.emit(WAKE_SOURCE_STATE_EVENT, {\n\t\t\t\tsource: \"terminal-background-sessions\",\n\t\t\t\tactiveCount: snapshot.length,\n\t\t\t\titems: snapshot,\n\t\t\t});\n\t\t},\n\t\tonBackgroundExit: (id, runtime) => state.notifier?.notifyCompletion(id, runtime),\n\t};\n}\n\nfunction buildToolContext(pi: ExtensionAPI, state: TerminalExtensionState): TerminalToolContext {\n\tconst requireBundle = (): TerminalSessionBundle => {\n\t\t// Lazily create a bundle so the tools work even when invoked directly (e.g. via the\n\t\t// SDK) before `session_start` initializes one. `session_start` replaces it with a\n\t\t// settings-configured bundle and tears down any earlier one.\n\t\tif (!state.bundle) {\n\t\t\tstate.bundle = createBundle(state);\n\t\t\tstate.bundle.bind(bundleSinks(pi, state));\n\t\t}\n\t\treturn state.bundle;\n\t};\n\treturn {\n\t\tget manager() {\n\t\t\treturn requireBundle().manager;\n\t\t},\n\t\tget cwd() {\n\t\t\treturn state.ctx?.cwd ?? process.cwd();\n\t\t},\n\t\tget shellPath() {\n\t\t\treturn state.shellPath;\n\t\t},\n\t\tget defaultCols() {\n\t\t\treturn state.settings.defaultCols;\n\t\t},\n\t\tget defaultRows() {\n\t\t\treturn state.settings.defaultRows;\n\t\t},\n\t\tget timeoutAction() {\n\t\t\treturn state.settings.timeoutAction;\n\t\t},\n\t\tget monitorRegistry() {\n\t\t\treturn requireBundle().monitors;\n\t\t},\n\t\tgetEnv: () => getShellEnv(),\n\t\tgetSessionContext: () => state.ctx,\n\t\t// Exit listeners registered before a reload reach the post-reload owner through the\n\t\t// shared bundle, so this must dispatch via the bundle, never the instance notifier.\n\t\tonBackgroundStart: (id: string, description: string, startedAtMs: number) => {\n\t\t\tstate.bundle?.notifyBackgroundStart(id, description, startedAtMs);\n\t\t},\n\t\tonBackgroundExit: (id: string, runtime: TerminalRuntimeSession) => {\n\t\t\tstate.bundle?.notifyBackgroundExit(id, runtime);\n\t\t},\n\t\tonMonitorRearmed: (id: string) => state.monitorNotifier?.rearm(id),\n\t};\n}\n\nfunction shouldStepAside(ctx: ExtensionContext | undefined): boolean {\n\treturn isAnthropicBashEnabled() && ctx?.model?.api === \"anthropic-messages\";\n}\n\n/**\n * Keep the tool surface consistent with anthropic-bash. When native Anthropic bash is active,\n * the provider replaces the PTY `bash` function, but the companions stay active because `monitor`\n * creates its own PTY session and bash_output/input/resize/kill operate on that shared registry.\n * Otherwise the PTY `bash` + companions are (re)activated. Re-evaluated on session_start AND\n * model_select.\n */\nfunction syncToolset(pi: ExtensionAPI, state: TerminalExtensionState): void {\n\tconst stepAside = shouldStepAside(state.ctx);\n\tconst active = new Set(pi.getActiveTools());\n\tif (stepAside) {\n\t\tfor (const companion of TERMINAL_COMPANION_TOOLS) active.add(companion);\n\t\tif (!state.noticeShown) {\n\t\t\tstate.ctx?.ui.notify(\"native Anthropic bash active — monitor sessions remain available\", \"info\");\n\t\t\tstate.noticeShown = true;\n\t\t}\n\t} else {\n\t\tactive.add(TERMINAL_BASH_TOOL);\n\t\tfor (const companion of TERMINAL_COMPANION_TOOLS) active.add(companion);\n\t\tstate.noticeShown = false;\n\t}\n\tstate.steppedAside = stepAside;\n\tpi.setActiveTools([...active]);\n}\n\nexport function registerTerminalExtension(pi: ExtensionAPI): void {\n\tconst state: TerminalExtensionState = {\n\t\tbundle: null,\n\t\tsettings: TERMINAL_SETTINGS_DEFAULTS,\n\t\tnotifier: null,\n\t\tmonitorNotifier: null,\n\t\tstatusTicker: new MonitorStatusTicker({\n\t\t\trender: (status) => {\n\t\t\t\tconst ctx = state.ctx;\n\t\t\t\tctx?.ui.setStatus(\n\t\t\t\t\tMONITOR_STATUS_KEY,\n\t\t\t\t\tstatus === undefined || ctx.mode !== \"tui\"\n\t\t\t\t\t\t? status\n\t\t\t\t\t\t: ctx.ui.theme.bg(\"selectedBg\", ctx.ui.theme.fg(\"text\", status)),\n\t\t\t\t);\n\t\t\t},\n\t\t}),\n\t\tctx: undefined,\n\t\tshellPath: undefined,\n\t\tsteppedAside: false,\n\t\tnoticeShown: false,\n\t};\n\tconst toolCtx = buildToolContext(pi, state);\n\n\tpi.registerTool(createPtyBashTool(toolCtx));\n\tpi.registerTool(createBashOutputTool(toolCtx));\n\tpi.registerTool(createBashInputTool(toolCtx));\n\tpi.registerTool(createBashResizeTool(toolCtx));\n\tpi.registerTool(createKillBashTool(toolCtx));\n\tpi.registerTool(createMonitorTool(toolCtx));\n\n\tpi.on(\"session_start\", async (event, ctx) => {\n\t\tstate.ctx = ctx;\n\t\tconst settingsManager = SettingsManager.create(ctx.cwd);\n\t\tstate.settings = loadTerminalSettings(settingsManager);\n\t\tstate.shellPath = settingsManager.getShellPath();\n\t\tstate.notifier = new TerminalNotifier({\n\t\t\tsendMessage: (message, options) => pi.sendMessage(message, options),\n\t\t\tgetContext: () => state.ctx,\n\t\t\tgetMode: () => state.settings.notify,\n\t\t});\n\t\tstate.monitorNotifier?.dispose();\n\t\tstate.monitorNotifier = new MonitorNotifier({\n\t\t\tsendMessage: (message, options) => pi.sendMessage(message, options),\n\t\t\tgetContext: () => state.ctx,\n\t\t\tgetMode: () => state.settings.notify,\n\t\t\tgetSettings: () => state.settings.monitor,\n\t\t\tpauseMonitors: () => state.bundle?.monitors.pauseAll() ?? [],\n\t\t});\n\t\tconst sessionKey = sessionKeyOf(ctx);\n\t\tif (event.reason === \"reload\") {\n\t\t\tconst claimed = sessionKey === undefined ? undefined : claimParkedBundle(sessionKey);\n\t\t\tif (claimed) {\n\t\t\t\tawait state.bundle?.teardown();\n\t\t\t\tstate.bundle = claimed;\n\t\t\t}\n\t\t} else {\n\t\t\tif (sessionKey !== undefined) await teardownParkedBundle(sessionKey);\n\t\t\tawait state.bundle?.teardown();\n\t\t\tstate.bundle = createBundle(state);\n\t\t}\n\t\tstate.bundle ??= createBundle(state);\n\t\tstate.bundle.bind(bundleSinks(pi, state));\n\t\tsyncToolset(pi, state);\n\t});\n\n\tpi.on(\"model_select\", async (event, ctx) => {\n\t\tstate.ctx = { ...ctx, model: event.model };\n\t\tsyncToolset(pi, state);\n\t});\n\n\tpi.on(\"input\", (event) => {\n\t\tif (event.source !== \"extension\") state.monitorNotifier?.noteActivity();\n\t});\n\n\tpi.on(\"tool_call\", () => {\n\t\tstate.monitorNotifier?.noteActivity();\n\t});\n\n\tpi.on(\"before_agent_start\", async (event) => {\n\t\tif (state.steppedAside) return undefined;\n\t\treturn { systemPrompt: `${event.systemPrompt}\\n${TERMINAL_PROMPT_SECTION}` };\n\t});\n\n\tpi.on(\"session_shutdown\", async (event, ctx) => {\n\t\tstate.monitorNotifier?.dispose();\n\t\tstate.monitorNotifier = null;\n\t\tstate.notifier = null;\n\t\tstate.statusTicker.stop();\n\t\tconst sessionKey = sessionKeyOf(ctx) ?? sessionKeyOf(state.ctx);\n\t\tif (event.reason === \"reload\" && state.bundle && sessionKey !== undefined) {\n\t\t\t// Keep state.bundle referenced: exit listeners captured by this instance's tool\n\t\t\t// context still route through the shared bundle after the new owner claims it.\n\t\t\tstate.bundle.park();\n\t\t\tawait parkBundle(sessionKey, state.bundle);\n\t\t\treturn;\n\t\t}\n\t\tconst bundle = state.bundle;\n\t\tstate.bundle = null;\n\t\tawait bundle?.teardown();\n\t\tif (sessionKey !== undefined) await teardownParkedBundle(sessionKey);\n\t});\n}\n\nexport default registerTerminalExtension;\n"]}
|
|
1
|
+
{"version":3,"file":"extension.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/terminal/extension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,4BAA4B,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAClG,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,EACN,iBAAiB,EACjB,UAAU,EAEV,qBAAqB,EACrB,oBAAoB,GACpB,MAA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AAC;QACzC,OAAO,EAAE,YAAY,EAAE,GAAG,KAAK,CAAC,YAAY,KAAK,uBAAuB,EAAE,EAAE,CAAC;IAC9E,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,EAAE,CAAC,kBAAkB,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;QAC9C,KAAK,CAAC,eAAe,EAAE,OAAO,EAAE,CAAC;QACjC,KAAK,CAAC,eAAe,GAAG,IAAI,CAAC;QAC7B,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC;QACtB,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC;QAC1B,MAAM,UAAU,GAAG,YAAY,CAAC,GAAG,CAAC,IAAI,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAChE,IAAI,KAAK,CAAC,MAAM,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC3E,gFAAgF;YAChF,+EAA+E;YAC/E,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;YACpB,MAAM,UAAU,CAAC,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;YAC3C,OAAO;QACR,CAAC;QACD,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;QAC5B,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC;QACpB,MAAM,MAAM,EAAE,QAAQ,EAAE,CAAC;QACzB,IAAI,UAAU,KAAK,SAAS;YAAE,MAAM,oBAAoB,CAAC,UAAU,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;AACJ,CAAC;AAED,eAAe,yBAAyB,CAAC","sourcesContent":["import { getShellEnv } from \"../../../../utils/shell.ts\";\nimport { SettingsManager } from \"../../../settings-manager.ts\";\nimport type { ExtensionAPI, ExtensionContext } from \"../../types.ts\";\nimport { isAnthropicBashEnabled } from \"../anthropic-bash/index.ts\";\nimport { TERMINAL_MONITOR_STATE_EVENT, WAKE_SOURCE_STATE_EVENT } from \"../monitor-state-event.ts\";\nimport { MonitorNotifier } from \"./monitor-notify.ts\";\nimport { MONITOR_STATUS_KEY } from \"./monitor-status.ts\";\nimport { MonitorStatusTicker } from \"./monitor-status-ticker.ts\";\nimport { TerminalNotifier } from \"./notify.ts\";\nimport { TERMINAL_PROMPT_SECTION } from \"./prompt.ts\";\nimport type { TerminalRuntimeSession } from \"./runtime-session.ts\";\nimport {\n\tclaimParkedBundle,\n\tparkBundle,\n\ttype TerminalEventSinks,\n\tTerminalSessionBundle,\n\tteardownParkedBundle,\n} from \"./session-bundle.ts\";\nimport { loadTerminalSettings, type ResolvedTerminalSettings, TERMINAL_SETTINGS_DEFAULTS } from \"./settings.ts\";\nimport { TERMINAL_BASH_TOOL, TERMINAL_COMPANION_TOOLS } from \"./shared.ts\";\nimport { createPtyBashTool } from \"./tools/bash.ts\";\nimport { createBashInputTool } from \"./tools/bash-input.ts\";\nimport { createBashOutputTool } from \"./tools/bash-output.ts\";\nimport { createBashResizeTool } from \"./tools/bash-resize.ts\";\nimport type { TerminalToolContext } from \"./tools/context.ts\";\nimport { createKillBashTool } from \"./tools/kill-bash.ts\";\nimport { createMonitorTool } from \"./tools/monitor.ts\";\n\ninterface TerminalExtensionState {\n\tbundle: TerminalSessionBundle | null;\n\tsettings: ResolvedTerminalSettings;\n\tnotifier: TerminalNotifier | null;\n\tmonitorNotifier: MonitorNotifier | null;\n\tstatusTicker: MonitorStatusTicker;\n\tctx: ExtensionContext | undefined;\n\tshellPath: string | undefined;\n\tsteppedAside: boolean;\n\tnoticeShown: boolean;\n}\n\n/** Tests and SDK callers may hand partial contexts without a session manager. */\nfunction sessionKeyOf(ctx: ExtensionContext | undefined): string | undefined {\n\treturn ctx?.sessionManager?.getSessionId?.();\n}\n\nfunction createBundle(state: TerminalExtensionState): TerminalSessionBundle {\n\treturn new TerminalSessionBundle({\n\t\tmaxSessions: state.settings.maxSessions,\n\t\tscrollback: state.settings.scrollback,\n\t});\n}\n\n/** Sinks read the live instance state at call time, so notifier swaps need no re-bind. */\nfunction bundleSinks(pi: ExtensionAPI, state: TerminalExtensionState): TerminalEventSinks {\n\treturn {\n\t\tonMonitorEvent: (event) => state.monitorNotifier?.notifyEvent(event),\n\t\tonMonitorState: (snapshot) => {\n\t\t\tstate.statusTicker.sync(snapshot);\n\t\t\tconst payload = {\n\t\t\t\tactiveCount: snapshot.length,\n\t\t\t\tmonitors: snapshot.map((entry) => ({\n\t\t\t\t\tid: entry.id,\n\t\t\t\t\tdescription: entry.description,\n\t\t\t\t\tpaused: entry.paused,\n\t\t\t\t\tstartedAtMs: entry.startedAtMs,\n\t\t\t\t})),\n\t\t\t};\n\t\t\tpi.events?.emit(TERMINAL_MONITOR_STATE_EVENT, payload);\n\t\t\tpi.rpc?.emit(TERMINAL_MONITOR_STATE_EVENT, payload);\n\t\t\tpi.events?.emit(WAKE_SOURCE_STATE_EVENT, {\n\t\t\t\tsource: \"terminal-monitors\",\n\t\t\t\tactiveCount: snapshot.length,\n\t\t\t\tmonitors: snapshot.map((entry) => ({\n\t\t\t\t\tid: entry.id,\n\t\t\t\t\tdescription: entry.description,\n\t\t\t\t\tstartedAtMs: entry.startedAtMs,\n\t\t\t\t})),\n\t\t\t});\n\t\t},\n\t\tonBackgroundState: (snapshot) => {\n\t\t\tpi.events?.emit(WAKE_SOURCE_STATE_EVENT, {\n\t\t\t\tsource: \"terminal-background-sessions\",\n\t\t\t\tactiveCount: snapshot.length,\n\t\t\t\titems: snapshot,\n\t\t\t});\n\t\t},\n\t\tonBackgroundExit: (id, runtime) => state.notifier?.notifyCompletion(id, runtime),\n\t};\n}\n\nfunction buildToolContext(pi: ExtensionAPI, state: TerminalExtensionState): TerminalToolContext {\n\tconst requireBundle = (): TerminalSessionBundle => {\n\t\t// Lazily create a bundle so the tools work even when invoked directly (e.g. via the\n\t\t// SDK) before `session_start` initializes one. `session_start` replaces it with a\n\t\t// settings-configured bundle and tears down any earlier one.\n\t\tif (!state.bundle) {\n\t\t\tstate.bundle = createBundle(state);\n\t\t\tstate.bundle.bind(bundleSinks(pi, state));\n\t\t}\n\t\treturn state.bundle;\n\t};\n\treturn {\n\t\tget manager() {\n\t\t\treturn requireBundle().manager;\n\t\t},\n\t\tget cwd() {\n\t\t\treturn state.ctx?.cwd ?? process.cwd();\n\t\t},\n\t\tget shellPath() {\n\t\t\treturn state.shellPath;\n\t\t},\n\t\tget defaultCols() {\n\t\t\treturn state.settings.defaultCols;\n\t\t},\n\t\tget defaultRows() {\n\t\t\treturn state.settings.defaultRows;\n\t\t},\n\t\tget timeoutAction() {\n\t\t\treturn state.settings.timeoutAction;\n\t\t},\n\t\tget monitorRegistry() {\n\t\t\treturn requireBundle().monitors;\n\t\t},\n\t\tgetEnv: () => getShellEnv(),\n\t\tgetSessionContext: () => state.ctx,\n\t\t// Exit listeners registered before a reload reach the post-reload owner through the\n\t\t// shared bundle, so this must dispatch via the bundle, never the instance notifier.\n\t\tonBackgroundStart: (id: string, description: string, startedAtMs: number) => {\n\t\t\tstate.bundle?.notifyBackgroundStart(id, description, startedAtMs);\n\t\t},\n\t\tonBackgroundExit: (id: string, runtime: TerminalRuntimeSession) => {\n\t\t\tstate.bundle?.notifyBackgroundExit(id, runtime);\n\t\t},\n\t\tonMonitorRearmed: (id: string) => state.monitorNotifier?.rearm(id),\n\t};\n}\n\nfunction shouldStepAside(ctx: ExtensionContext | undefined): boolean {\n\treturn isAnthropicBashEnabled() && ctx?.model?.api === \"anthropic-messages\";\n}\n\n/**\n * Keep the tool surface consistent with anthropic-bash. When native Anthropic bash is active,\n * the provider replaces the PTY `bash` function, but the companions stay active because `monitor`\n * creates its own PTY session and bash_output/input/resize/kill operate on that shared registry.\n * Otherwise the PTY `bash` + companions are (re)activated. Re-evaluated on session_start AND\n * model_select.\n */\nfunction syncToolset(pi: ExtensionAPI, state: TerminalExtensionState): void {\n\tconst stepAside = shouldStepAside(state.ctx);\n\tconst active = new Set(pi.getActiveTools());\n\tif (stepAside) {\n\t\tfor (const companion of TERMINAL_COMPANION_TOOLS) active.add(companion);\n\t\tif (!state.noticeShown) {\n\t\t\tstate.ctx?.ui.notify(\"native Anthropic bash active — monitor sessions remain available\", \"info\");\n\t\t\tstate.noticeShown = true;\n\t\t}\n\t} else {\n\t\tactive.add(TERMINAL_BASH_TOOL);\n\t\tfor (const companion of TERMINAL_COMPANION_TOOLS) active.add(companion);\n\t\tstate.noticeShown = false;\n\t}\n\tstate.steppedAside = stepAside;\n\tpi.setActiveTools([...active]);\n}\n\nexport function registerTerminalExtension(pi: ExtensionAPI): void {\n\tconst state: TerminalExtensionState = {\n\t\tbundle: null,\n\t\tsettings: TERMINAL_SETTINGS_DEFAULTS,\n\t\tnotifier: null,\n\t\tmonitorNotifier: null,\n\t\tstatusTicker: new MonitorStatusTicker({\n\t\t\trender: (status) => {\n\t\t\t\tconst ctx = state.ctx;\n\t\t\t\tctx?.ui.setStatus(\n\t\t\t\t\tMONITOR_STATUS_KEY,\n\t\t\t\t\tstatus === undefined || ctx.mode !== \"tui\"\n\t\t\t\t\t\t? status\n\t\t\t\t\t\t: ctx.ui.theme.bg(\"selectedBg\", ctx.ui.theme.fg(\"text\", status)),\n\t\t\t\t);\n\t\t\t},\n\t\t}),\n\t\tctx: undefined,\n\t\tshellPath: undefined,\n\t\tsteppedAside: false,\n\t\tnoticeShown: false,\n\t};\n\tconst toolCtx = buildToolContext(pi, state);\n\n\tpi.registerTool(createPtyBashTool(toolCtx));\n\tpi.registerTool(createBashOutputTool(toolCtx));\n\tpi.registerTool(createBashInputTool(toolCtx));\n\tpi.registerTool(createBashResizeTool(toolCtx));\n\tpi.registerTool(createKillBashTool(toolCtx));\n\tpi.registerTool(createMonitorTool(toolCtx));\n\n\tpi.on(\"session_start\", async (event, ctx) => {\n\t\tstate.ctx = ctx;\n\t\tconst settingsManager = SettingsManager.create(ctx.cwd);\n\t\tstate.settings = loadTerminalSettings(settingsManager);\n\t\tstate.shellPath = settingsManager.getShellPath();\n\t\tstate.notifier = new TerminalNotifier({\n\t\t\tsendMessage: (message, options) => pi.sendMessage(message, options),\n\t\t\tgetContext: () => state.ctx,\n\t\t\tgetMode: () => state.settings.notify,\n\t\t});\n\t\tstate.monitorNotifier?.dispose();\n\t\tstate.monitorNotifier = new MonitorNotifier({\n\t\t\tsendMessage: (message, options) => pi.sendMessage(message, options),\n\t\t\tgetContext: () => state.ctx,\n\t\t\tgetMode: () => state.settings.notify,\n\t\t\tgetSettings: () => state.settings.monitor,\n\t\t\tpauseMonitors: () => state.bundle?.monitors.pauseAll() ?? [],\n\t\t});\n\t\tconst sessionKey = sessionKeyOf(ctx);\n\t\tif (event.reason === \"reload\") {\n\t\t\tconst claimed = sessionKey === undefined ? undefined : claimParkedBundle(sessionKey);\n\t\t\tif (claimed) {\n\t\t\t\tawait state.bundle?.teardown();\n\t\t\t\tstate.bundle = claimed;\n\t\t\t}\n\t\t} else {\n\t\t\tif (sessionKey !== undefined) await teardownParkedBundle(sessionKey);\n\t\t\tawait state.bundle?.teardown();\n\t\t\tstate.bundle = createBundle(state);\n\t\t}\n\t\tstate.bundle ??= createBundle(state);\n\t\tstate.bundle.bind(bundleSinks(pi, state));\n\t\tsyncToolset(pi, state);\n\t});\n\n\tpi.on(\"model_select\", async (event, ctx) => {\n\t\tstate.ctx = { ...ctx, model: event.model };\n\t\tsyncToolset(pi, state);\n\t});\n\n\tpi.on(\"input\", (event) => {\n\t\tif (event.source !== \"extension\") state.monitorNotifier?.noteActivity();\n\t});\n\n\tpi.on(\"tool_call\", () => {\n\t\tstate.monitorNotifier?.noteActivity();\n\t});\n\n\tpi.on(\"before_agent_start\", async (event) => {\n\t\tif (state.steppedAside) return undefined;\n\t\treturn { systemPrompt: `${event.systemPrompt}\\n${TERMINAL_PROMPT_SECTION}` };\n\t});\n\n\tpi.on(\"session_shutdown\", async (event, ctx) => {\n\t\tstate.monitorNotifier?.dispose();\n\t\tstate.monitorNotifier = null;\n\t\tstate.notifier = null;\n\t\tstate.statusTicker.stop();\n\t\tconst sessionKey = sessionKeyOf(ctx) ?? sessionKeyOf(state.ctx);\n\t\tif (event.reason === \"reload\" && state.bundle && sessionKey !== undefined) {\n\t\t\t// Keep state.bundle referenced: exit listeners captured by this instance's tool\n\t\t\t// context still route through the shared bundle after the new owner claims it.\n\t\t\tstate.bundle.park();\n\t\t\tawait parkBundle(sessionKey, state.bundle);\n\t\t\treturn;\n\t\t}\n\t\tconst bundle = state.bundle;\n\t\tstate.bundle = null;\n\t\tawait bundle?.teardown();\n\t\tif (sessionKey !== undefined) await teardownParkedBundle(sessionKey);\n\t});\n}\n\nexport default registerTerminalExtension;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/todotools/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EACN,WAAW,EACX,gCAAgC,GAGhC,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,SAAS,eAAe,CAAC,GAAqB;IAC7C,OAAO,gCAAgC,CAAC,GAAG,CAAC,cAAc,CAAC,SAAS,EAAE,CAAC,CAAC;AACzE,CAAC;AAED,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EAAgB;IAC1D,IAAI,aAAa,GAAgB,EAAE,CAAC;IAEpC,MAAM,gBAAgB,GAAG,GAAgB,EAAE,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;IAEvE,MAAM,gBAAgB,GAAG,C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UAAU,EACV,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,kBAAkB,EAClB,uBAAuB,EACvB,WAAW,EACX,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,GASrB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC","sourcesContent":["import type { ExtensionAPI, ExtensionContext } from \"../../types.ts\";\nimport { registerTodoCommand } from \"./commands.ts\";\nimport { phasesFromCursorTodos } from \"./native-todo-mirror.ts\";\nimport { TASK_MANAGEMENT_SECTION } from \"./prompt.ts\";\nimport {\n\tclonePhases,\n\tgetLatestPhasesFromBranchEntries,\n\ttype TodoCompletionTransition,\n\ttype TodoPhase,\n} from \"./state.ts\";\nimport { TODO_STATE_ENTRY_TYPE } from \"./todo-types.ts\";\nimport { getTodoWidgetModel } from \"./todo-widget.ts\";\nimport { TodoWidgetComponent } from \"./todo-widget-component.ts\";\nimport { registerTodoTool } from \"./tools/todo.ts\";\n\nfunction getLatestPhases(ctx: ExtensionContext): TodoPhase[] {\n\treturn getLatestPhasesFromBranchEntries(ctx.sessionManager.getBranch());\n}\n\nexport default function todotoolsExtension(pi: ExtensionAPI): void {\n\tlet currentPhases: TodoPhase[] = [];\n\n\tconst getCurrentPhases = (): TodoPhase[] => clonePhases(currentPhases);\n\n\tconst setCurrentPhases = (phases: TodoPhase[]): void => {\n\t\tcurrentPhases = clonePhases(phases);\n\t};\n\n\tconst syncWidget = (ctx: ExtensionContext, completedTasks: readonly TodoCompletionTransition[] = []): void => {\n\t\tconst model = getTodoWidgetModel(currentPhases);\n\t\tctx.ui.setWidget(\n\t\t\t\"todo-sidebar\",\n\t\t\tmodel ? (tui, theme) => new TodoWidgetComponent(tui, theme, model, completedTasks) : undefined,\n\t\t);\n\t};\n\n\tconst syncFromSession = (ctx: ExtensionContext): void => {\n\t\tcurrentPhases = getLatestPhases(ctx);\n\t\tsyncWidget(ctx);\n\t};\n\n\tpi.on(\"session_start\", async (_event, ctx) => {\n\t\tsyncFromSession(ctx);\n\t});\n\n\tpi.on(\"session_tree\", async (_event, ctx) => {\n\t\tsyncFromSession(ctx);\n\t});\n\n\tpi.on(\"message_end\", async (event, ctx) => {\n\t\tconst message = event.message;\n\t\tif (message?.role !== \"assistant\" || !Array.isArray(message.content)) {\n\t\t\treturn;\n\t\t}\n\t\tfor (const block of message.content) {\n\t\t\tif (block.type !== \"toolCall\" || block.name !== \"todo\" || block.arguments?.op) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst phases = phasesFromCursorTodos(block.arguments?.todos);\n\t\t\tif (phases === undefined) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tsetCurrentPhases(phases);\n\t\t\tpi.appendEntry(TODO_STATE_ENTRY_TYPE, { schema: \"v2\", phases });\n\t\t\tsyncWidget(ctx);\n\t\t}\n\t});\n\n\tpi.on(\"before_agent_start\", async (event) => {\n\t\treturn {\n\t\t\tsystemPrompt: `${event.systemPrompt}\\n${TASK_MANAGEMENT_SECTION}`,\n\t\t};\n\t});\n\n\tregisterTodoTool(pi, { getCurrentPhases, setCurrentPhases, syncWidget });\n\tregisterTodoCommand(pi, { getCurrentPhases, setCurrentPhases, syncWidget });\n}\n\nexport { findPhaseFuzzy, findTaskFuzzy, registerTodoCommand, tokenizeTodoArgs } from \"./commands.ts\";\nexport { markdownToPhases, phasesToMarkdown, resolveTodoMarkdownPath } from \"./markdown.ts\";\nexport { TASK_MANAGEMENT_SECTION } from \"./prompt.ts\";\nexport {\n\tappendItems,\n\tapplyEntry,\n\tapplyOpsToPhases,\n\tapplyParams,\n\tclonePhases,\n\tcloneTask,\n\tDEFAULT_INIT_PHASE,\n\tfindPhaseByName,\n\tfindTaskByContent,\n\tformatSummary,\n\tgetCompletionTransitions,\n\tgetLatestPhasesFromBranchEntries,\n\tgetLatestTodosFromBranchEntries,\n\tgetTaskTargets,\n\tgetTodoMarker,\n\tgetTodoResultLines,\n\tgetTodoWidgetLines,\n\tinitPhases,\n\tisIncompleteTodo,\n\tisTerminalTodoStatus,\n\tisTodoItem,\n\tisTodoItemArray,\n\tisTodoPhase,\n\tisTodoPhaseArray,\n\tnextActionableTask,\n\tnormalizeInProgressTask,\n\tremoveTasks,\n\tresolvePhaseOrError,\n\tresolveTaskOrError,\n\tsanitizeTodoText,\n\tTODO_STATE_ENTRY_TYPE,\n\ttype TodoCompletionTransition,\n\ttype TodoItem,\n\ttype TodoOpEntry,\n\ttype TodoOperation,\n\ttype TodoPhase,\n\ttype TodoStateEntry,\n\ttype TodoStatus,\n\ttype TodoToolDetails,\n} from \"./state.ts\";\nexport { phaseRomanNumeral } from \"./tools/todo.ts\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native-todo-mirror.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/todotools/native-todo-mirror.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAc,MAAM,iBAAiB,CAAC;AAK7D,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"native-todo-mirror.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/todotools/native-todo-mirror.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAc,MAAM,iBAAiB,CAAC;AAK7D,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,EAAE,GAAG,SAAS,CAkB7E"}
|
|
@@ -2,7 +2,7 @@ const STATUSES = new Set(["pending", "in_progress", "completed", "abandoned"]);
|
|
|
2
2
|
const DEFAULT_PHASE_NAME = "Tasks";
|
|
3
3
|
export function phasesFromCursorTodos(todos) {
|
|
4
4
|
if (!Array.isArray(todos)) {
|
|
5
|
-
return
|
|
5
|
+
return undefined;
|
|
6
6
|
}
|
|
7
7
|
const tasks = [];
|
|
8
8
|
for (const item of todos) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native-todo-mirror.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/todotools/native-todo-mirror.ts"],"names":[],"mappings":"AAEA,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAa,CAAC,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC;AAC3F,MAAM,kBAAkB,GAAG,OAAO,CAAC;AAEnC,MAAM,UAAU,qBAAqB,CAAC,KAAc;IACnD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3B,OAAO,
|
|
1
|
+
{"version":3,"file":"native-todo-mirror.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/todotools/native-todo-mirror.ts"],"names":[],"mappings":"AAEA,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAa,CAAC,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC;AAC3F,MAAM,kBAAkB,GAAG,OAAO,CAAC;AAEnC,MAAM,UAAU,qBAAqB,CAAC,KAAc;IACnD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3B,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,MAAM,KAAK,GAAG,EAAE,CAAC;IACjB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QAC1B,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;YACvC,SAAS;QACV,CAAC;QACD,MAAM,GAAG,GAAG,IAA+C,CAAC;QAC5D,MAAM,OAAO,GAAG,OAAO,GAAG,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1E,IAAI,CAAC,OAAO,EAAE,CAAC;YACd,SAAS;QACV,CAAC;QACD,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,MAAoB,CAAC,CAAC,CAAC,CAAE,GAAG,CAAC,MAAqB,CAAC,CAAC,CAAC,SAAS,CAAC;QAC/F,KAAK,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;IACjC,CAAC;IACD,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACtE,CAAC","sourcesContent":["import type { TodoPhase, TodoStatus } from \"./todo-types.ts\";\n\nconst STATUSES = new Set<TodoStatus>([\"pending\", \"in_progress\", \"completed\", \"abandoned\"]);\nconst DEFAULT_PHASE_NAME = \"Tasks\";\n\nexport function phasesFromCursorTodos(todos: unknown): TodoPhase[] | undefined {\n\tif (!Array.isArray(todos)) {\n\t\treturn undefined;\n\t}\n\tconst tasks = [];\n\tfor (const item of todos) {\n\t\tif (!item || typeof item !== \"object\") {\n\t\t\tcontinue;\n\t\t}\n\t\tconst raw = item as { content?: unknown; status?: unknown };\n\t\tconst content = typeof raw.content === \"string\" ? raw.content.trim() : \"\";\n\t\tif (!content) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst status = STATUSES.has(raw.status as TodoStatus) ? (raw.status as TodoStatus) : \"pending\";\n\t\ttasks.push({ content, status });\n\t}\n\treturn tasks.length > 0 ? [{ name: DEFAULT_PHASE_NAME, tasks }] : [];\n}\n"]}
|
|
@@ -1,2 +1,12 @@
|
|
|
1
1
|
export declare function appendHiddenTuiStdout(text: string): void;
|
|
2
|
+
/**
|
|
3
|
+
* Record a fatal uncaught crash in the brand debug log.
|
|
4
|
+
*
|
|
5
|
+
* The interactive crash handler restores the real stderr and prints its banner to
|
|
6
|
+
* the terminal, so without this the only record of a crash is terminal scrollback —
|
|
7
|
+
* useless once the terminal is closed, and doubly so when the crash is itself an
|
|
8
|
+
* stderr/terminal failure. Callers must invoke this BEFORE the terminal handoff and
|
|
9
|
+
* must swallow any failure: writing telemetry may never alter the crash path.
|
|
10
|
+
*/
|
|
11
|
+
export declare function appendUncaughtCrashLog(origin: string, error: unknown): void;
|
|
2
12
|
//# sourceMappingURL=hidden-stdout-log.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hidden-stdout-log.d.ts","sourceRoot":"","sources":["../../src/core/hidden-stdout-log.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hidden-stdout-log.d.ts","sourceRoot":"","sources":["../../src/core/hidden-stdout-log.ts"],"names":[],"mappings":"AAgBA,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAKxD;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAE3E"}
|
|
@@ -1,17 +1,48 @@
|
|
|
1
1
|
import * as fs from "node:fs";
|
|
2
2
|
import * as path from "node:path";
|
|
3
|
+
import { inspect } from "node:util";
|
|
3
4
|
import { getDebugLogPath } from "../config.js";
|
|
4
5
|
import { redactSensitiveOutput } from "./sensitive-output.js";
|
|
5
|
-
|
|
6
|
-
if (text.length === 0) {
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
6
|
+
function appendDebugLogEntry(header, text) {
|
|
9
7
|
const debugLogPath = getDebugLogPath();
|
|
10
|
-
const prefix = `[${new Date().toISOString()}]
|
|
8
|
+
const prefix = `[${new Date().toISOString()}] ${header}\n`;
|
|
11
9
|
const redactedText = redactSensitiveOutput(text);
|
|
12
10
|
const suffix = redactedText.endsWith("\n") ? "" : "\n";
|
|
13
11
|
fs.mkdirSync(path.dirname(debugLogPath), { recursive: true });
|
|
14
12
|
fs.appendFileSync(debugLogPath, `${prefix}${redactedText}${suffix}`, { mode: 0o600 });
|
|
15
13
|
fs.chmodSync(debugLogPath, 0o600);
|
|
16
14
|
}
|
|
15
|
+
export function appendHiddenTuiStdout(text) {
|
|
16
|
+
if (text.length === 0) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
appendDebugLogEntry("hidden stdout while TUI active", text);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Record a fatal uncaught crash in the brand debug log.
|
|
23
|
+
*
|
|
24
|
+
* The interactive crash handler restores the real stderr and prints its banner to
|
|
25
|
+
* the terminal, so without this the only record of a crash is terminal scrollback —
|
|
26
|
+
* useless once the terminal is closed, and doubly so when the crash is itself an
|
|
27
|
+
* stderr/terminal failure. Callers must invoke this BEFORE the terminal handoff and
|
|
28
|
+
* must swallow any failure: writing telemetry may never alter the crash path.
|
|
29
|
+
*/
|
|
30
|
+
export function appendUncaughtCrashLog(origin, error) {
|
|
31
|
+
appendDebugLogEntry(`uncaught crash (${origin})`, describeCrash(error));
|
|
32
|
+
}
|
|
33
|
+
function describeCrash(error) {
|
|
34
|
+
if (error instanceof Error) {
|
|
35
|
+
// `stack` already starts with "Name: message" in V8, but a caller-supplied or
|
|
36
|
+
// stripped stack may not, so keep the identity line unconditionally.
|
|
37
|
+
const identity = `${error.name}: ${error.message}`;
|
|
38
|
+
const stack = typeof error.stack === "string" && error.stack.length > 0 ? error.stack : undefined;
|
|
39
|
+
return stack === undefined || stack.startsWith(identity) ? (stack ?? identity) : `${identity}\n${stack}`;
|
|
40
|
+
}
|
|
41
|
+
try {
|
|
42
|
+
return typeof error === "string" ? error : inspect(error, { depth: 3 });
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return "<unprintable crash value>";
|
|
46
|
+
}
|
|
47
|
+
}
|
|
17
48
|
//# sourceMappingURL=hidden-stdout-log.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hidden-stdout-log.js","sourceRoot":"","sources":["../../src/core/hidden-stdout-log.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAA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CAAC;IACD,mBAAmB,CAAC,gCAAgC,EAAE,IAAI,CAAC,CAAC;AAC7D,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAc,EAAE,KAAc;IACpE,mBAAmB,CAAC,mBAAmB,MAAM,GAAG,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;AACzE,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACpC,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC5B,8EAA8E;QAC9E,qEAAqE;QACrE,MAAM,QAAQ,GAAG,GAAG,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC;QACnD,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;QAClG,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,QAAQ,KAAK,KAAK,EAAE,CAAC;IAC1G,CAAC;IACD,IAAI,CAAC;QACJ,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;IACzE,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,2BAA2B,CAAC;IACpC,CAAC;AACF,CAAC","sourcesContent":["import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport { inspect } from \"node:util\";\nimport { getDebugLogPath } from \"../config.ts\";\nimport { redactSensitiveOutput } from \"./sensitive-output.ts\";\n\nfunction appendDebugLogEntry(header: string, text: string): void {\n\tconst debugLogPath = getDebugLogPath();\n\tconst prefix = `[${new Date().toISOString()}] ${header}\\n`;\n\tconst redactedText = redactSensitiveOutput(text);\n\tconst suffix = redactedText.endsWith(\"\\n\") ? \"\" : \"\\n\";\n\tfs.mkdirSync(path.dirname(debugLogPath), { recursive: true });\n\tfs.appendFileSync(debugLogPath, `${prefix}${redactedText}${suffix}`, { mode: 0o600 });\n\tfs.chmodSync(debugLogPath, 0o600);\n}\n\nexport function appendHiddenTuiStdout(text: string): void {\n\tif (text.length === 0) {\n\t\treturn;\n\t}\n\tappendDebugLogEntry(\"hidden stdout while TUI active\", text);\n}\n\n/**\n * Record a fatal uncaught crash in the brand debug log.\n *\n * The interactive crash handler restores the real stderr and prints its banner to\n * the terminal, so without this the only record of a crash is terminal scrollback —\n * useless once the terminal is closed, and doubly so when the crash is itself an\n * stderr/terminal failure. Callers must invoke this BEFORE the terminal handoff and\n * must swallow any failure: writing telemetry may never alter the crash path.\n */\nexport function appendUncaughtCrashLog(origin: string, error: unknown): void {\n\tappendDebugLogEntry(`uncaught crash (${origin})`, describeCrash(error));\n}\n\nfunction describeCrash(error: unknown): string {\n\tif (error instanceof Error) {\n\t\t// `stack` already starts with \"Name: message\" in V8, but a caller-supplied or\n\t\t// stripped stack may not, so keep the identity line unconditionally.\n\t\tconst identity = `${error.name}: ${error.message}`;\n\t\tconst stack = typeof error.stack === \"string\" && error.stack.length > 0 ? error.stack : undefined;\n\t\treturn stack === undefined || stack.startsWith(identity) ? (stack ?? identity) : `${identity}\\n${stack}`;\n\t}\n\ttry {\n\t\treturn typeof error === \"string\" ? error : inspect(error, { depth: 3 });\n\t} catch {\n\t\treturn \"<unprintable crash value>\";\n\t}\n}\n"]}
|
|
@@ -1,4 +1,26 @@
|
|
|
1
1
|
import { type Static, Type } from "typebox";
|
|
2
|
+
/** Policy defaults shared with the pool engine so schema and runtime cannot drift. */
|
|
3
|
+
export declare const CREDENTIAL_POLICY_DEFAULTS: {
|
|
4
|
+
readonly rotation: true;
|
|
5
|
+
readonly affinity: true;
|
|
6
|
+
readonly cooldownBaseMs: 60000;
|
|
7
|
+
readonly cooldownCapMs: number;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Policy only: named slots REFERENCE env vars or command values; key material
|
|
11
|
+
* itself stays in auth.json or the environment, and unknown keys (for example
|
|
12
|
+
* a literal `apiKey`) are rejected outright.
|
|
13
|
+
*/
|
|
14
|
+
declare const CredentialPolicySchema: Type.TObject<{
|
|
15
|
+
rotation: Type.TOptional<Type.TBoolean>;
|
|
16
|
+
affinity: Type.TOptional<Type.TBoolean>;
|
|
17
|
+
cooldownBaseMs: Type.TOptional<Type.TNumber>;
|
|
18
|
+
cooldownCapMs: Type.TOptional<Type.TNumber>;
|
|
19
|
+
slots: Type.TOptional<Type.TRecord<"^.*$", Type.TObject<{
|
|
20
|
+
env: Type.TOptional<Type.TString>;
|
|
21
|
+
value: Type.TOptional<Type.TString>;
|
|
22
|
+
}>>>;
|
|
23
|
+
}>;
|
|
2
24
|
declare const ModelDefinitionSchema: Type.TObject<{
|
|
3
25
|
id: Type.TString;
|
|
4
26
|
name: Type.TOptional<Type.TString>;
|
|
@@ -584,6 +606,16 @@ declare const ProviderConfigSchema: Type.TObject<{
|
|
|
584
606
|
supportsWebSearch: Type.TOptional<Type.TBoolean>;
|
|
585
607
|
}>]>>;
|
|
586
608
|
}>>>;
|
|
609
|
+
credentials: Type.TOptional<Type.TObject<{
|
|
610
|
+
rotation: Type.TOptional<Type.TBoolean>;
|
|
611
|
+
affinity: Type.TOptional<Type.TBoolean>;
|
|
612
|
+
cooldownBaseMs: Type.TOptional<Type.TNumber>;
|
|
613
|
+
cooldownCapMs: Type.TOptional<Type.TNumber>;
|
|
614
|
+
slots: Type.TOptional<Type.TRecord<"^.*$", Type.TObject<{
|
|
615
|
+
env: Type.TOptional<Type.TString>;
|
|
616
|
+
value: Type.TOptional<Type.TString>;
|
|
617
|
+
}>>>;
|
|
618
|
+
}>>;
|
|
587
619
|
}>;
|
|
588
620
|
declare const ModelsConfigSchema: Type.TObject<{
|
|
589
621
|
disabledProviders: Type.TOptional<Type.TArray<Type.TString>>;
|
|
@@ -928,6 +960,16 @@ declare const ModelsConfigSchema: Type.TObject<{
|
|
|
928
960
|
supportsWebSearch: Type.TOptional<Type.TBoolean>;
|
|
929
961
|
}>]>>;
|
|
930
962
|
}>>>;
|
|
963
|
+
credentials: Type.TOptional<Type.TObject<{
|
|
964
|
+
rotation: Type.TOptional<Type.TBoolean>;
|
|
965
|
+
affinity: Type.TOptional<Type.TBoolean>;
|
|
966
|
+
cooldownBaseMs: Type.TOptional<Type.TNumber>;
|
|
967
|
+
cooldownCapMs: Type.TOptional<Type.TNumber>;
|
|
968
|
+
slots: Type.TOptional<Type.TRecord<"^.*$", Type.TObject<{
|
|
969
|
+
env: Type.TOptional<Type.TString>;
|
|
970
|
+
value: Type.TOptional<Type.TString>;
|
|
971
|
+
}>>>;
|
|
972
|
+
}>>;
|
|
931
973
|
}>>;
|
|
932
974
|
}>;
|
|
933
975
|
export declare const validateModelsConfig: import("typebox/compile").Validator<{}, Type.TObject<{
|
|
@@ -1273,6 +1315,16 @@ export declare const validateModelsConfig: import("typebox/compile").Validator<{
|
|
|
1273
1315
|
supportsWebSearch: Type.TOptional<Type.TBoolean>;
|
|
1274
1316
|
}>]>>;
|
|
1275
1317
|
}>>>;
|
|
1318
|
+
credentials: Type.TOptional<Type.TObject<{
|
|
1319
|
+
rotation: Type.TOptional<Type.TBoolean>;
|
|
1320
|
+
affinity: Type.TOptional<Type.TBoolean>;
|
|
1321
|
+
cooldownBaseMs: Type.TOptional<Type.TNumber>;
|
|
1322
|
+
cooldownCapMs: Type.TOptional<Type.TNumber>;
|
|
1323
|
+
slots: Type.TOptional<Type.TRecord<"^.*$", Type.TObject<{
|
|
1324
|
+
env: Type.TOptional<Type.TString>;
|
|
1325
|
+
value: Type.TOptional<Type.TString>;
|
|
1326
|
+
}>>>;
|
|
1327
|
+
}>>;
|
|
1276
1328
|
}>>;
|
|
1277
1329
|
}>, {
|
|
1278
1330
|
disabledProviders?: string[] | undefined;
|
|
@@ -1395,14 +1447,14 @@ export declare const validateModelsConfig: import("typebox/compile").Validator<{
|
|
|
1395
1447
|
} | undefined;
|
|
1396
1448
|
cost?: {
|
|
1397
1449
|
tiers?: {
|
|
1398
|
-
inputTokensAbove: number;
|
|
1399
|
-
input: number;
|
|
1400
1450
|
output: number;
|
|
1451
|
+
input: number;
|
|
1452
|
+
inputTokensAbove: number;
|
|
1401
1453
|
cacheRead: number;
|
|
1402
1454
|
cacheWrite: number;
|
|
1403
1455
|
}[] | undefined;
|
|
1404
|
-
input: number;
|
|
1405
1456
|
output: number;
|
|
1457
|
+
input: number;
|
|
1406
1458
|
cacheRead: number;
|
|
1407
1459
|
cacheWrite: number;
|
|
1408
1460
|
} | undefined;
|
|
@@ -1514,14 +1566,14 @@ export declare const validateModelsConfig: import("typebox/compile").Validator<{
|
|
|
1514
1566
|
max?: string | null | undefined;
|
|
1515
1567
|
} | undefined;
|
|
1516
1568
|
cost?: {
|
|
1517
|
-
input?: number | undefined;
|
|
1518
1569
|
output?: number | undefined;
|
|
1570
|
+
input?: number | undefined;
|
|
1519
1571
|
cacheRead?: number | undefined;
|
|
1520
1572
|
cacheWrite?: number | undefined;
|
|
1521
1573
|
tiers?: {
|
|
1522
|
-
inputTokensAbove: number;
|
|
1523
|
-
input: number;
|
|
1524
1574
|
output: number;
|
|
1575
|
+
input: number;
|
|
1576
|
+
inputTokensAbove: number;
|
|
1525
1577
|
cacheRead: number;
|
|
1526
1578
|
cacheWrite: number;
|
|
1527
1579
|
}[] | undefined;
|
|
@@ -1617,6 +1669,16 @@ export declare const validateModelsConfig: import("typebox/compile").Validator<{
|
|
|
1617
1669
|
} | undefined;
|
|
1618
1670
|
thinkingLevelMapMode?: "replace" | "merge" | undefined;
|
|
1619
1671
|
}> | undefined;
|
|
1672
|
+
credentials?: {
|
|
1673
|
+
slots?: Record<string, {
|
|
1674
|
+
env?: string | undefined;
|
|
1675
|
+
value?: string | undefined;
|
|
1676
|
+
}> | undefined;
|
|
1677
|
+
cooldownBaseMs?: number | undefined;
|
|
1678
|
+
cooldownCapMs?: number | undefined;
|
|
1679
|
+
affinity?: boolean | undefined;
|
|
1680
|
+
rotation?: boolean | undefined;
|
|
1681
|
+
} | undefined;
|
|
1620
1682
|
}>;
|
|
1621
1683
|
}, {
|
|
1622
1684
|
disabledProviders?: string[] | undefined;
|
|
@@ -1739,14 +1801,14 @@ export declare const validateModelsConfig: import("typebox/compile").Validator<{
|
|
|
1739
1801
|
} | undefined;
|
|
1740
1802
|
cost?: {
|
|
1741
1803
|
tiers?: {
|
|
1742
|
-
inputTokensAbove: number;
|
|
1743
|
-
input: number;
|
|
1744
1804
|
output: number;
|
|
1805
|
+
input: number;
|
|
1806
|
+
inputTokensAbove: number;
|
|
1745
1807
|
cacheRead: number;
|
|
1746
1808
|
cacheWrite: number;
|
|
1747
1809
|
}[] | undefined;
|
|
1748
|
-
input: number;
|
|
1749
1810
|
output: number;
|
|
1811
|
+
input: number;
|
|
1750
1812
|
cacheRead: number;
|
|
1751
1813
|
cacheWrite: number;
|
|
1752
1814
|
} | undefined;
|
|
@@ -1858,14 +1920,14 @@ export declare const validateModelsConfig: import("typebox/compile").Validator<{
|
|
|
1858
1920
|
max?: string | null | undefined;
|
|
1859
1921
|
} | undefined;
|
|
1860
1922
|
cost?: {
|
|
1861
|
-
input?: number | undefined;
|
|
1862
1923
|
output?: number | undefined;
|
|
1924
|
+
input?: number | undefined;
|
|
1863
1925
|
cacheRead?: number | undefined;
|
|
1864
1926
|
cacheWrite?: number | undefined;
|
|
1865
1927
|
tiers?: {
|
|
1866
|
-
inputTokensAbove: number;
|
|
1867
|
-
input: number;
|
|
1868
1928
|
output: number;
|
|
1929
|
+
input: number;
|
|
1930
|
+
inputTokensAbove: number;
|
|
1869
1931
|
cacheRead: number;
|
|
1870
1932
|
cacheWrite: number;
|
|
1871
1933
|
}[] | undefined;
|
|
@@ -1961,11 +2023,22 @@ export declare const validateModelsConfig: import("typebox/compile").Validator<{
|
|
|
1961
2023
|
} | undefined;
|
|
1962
2024
|
thinkingLevelMapMode?: "replace" | "merge" | undefined;
|
|
1963
2025
|
}> | undefined;
|
|
2026
|
+
credentials?: {
|
|
2027
|
+
slots?: Record<string, {
|
|
2028
|
+
env?: string | undefined;
|
|
2029
|
+
value?: string | undefined;
|
|
2030
|
+
}> | undefined;
|
|
2031
|
+
cooldownBaseMs?: number | undefined;
|
|
2032
|
+
cooldownCapMs?: number | undefined;
|
|
2033
|
+
affinity?: boolean | undefined;
|
|
2034
|
+
rotation?: boolean | undefined;
|
|
2035
|
+
} | undefined;
|
|
1964
2036
|
}>;
|
|
1965
2037
|
}>;
|
|
1966
2038
|
export type ModelsJsonModel = Static<typeof ModelDefinitionSchema>;
|
|
1967
2039
|
export type ModelsJsonModelOverride = Static<typeof ModelOverrideSchema>;
|
|
1968
2040
|
export type ModelsJsonProvider = Static<typeof ProviderConfigSchema>;
|
|
2041
|
+
export type ModelsJsonCredentialPolicy = Static<typeof CredentialPolicySchema>;
|
|
1969
2042
|
export type ModelsJson = Static<typeof ModelsConfigSchema>;
|
|
1970
2043
|
export {};
|
|
1971
2044
|
//# sourceMappingURL=model-config-schema.d.ts.map
|