@code-yeongyu/senpi 2026.8.26 → 2026.8.28
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 +76 -0
- package/README.md +3 -3
- package/dist/cli/args.d.ts +3 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +14 -1
- package/dist/cli/args.js.map +1 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +10 -1
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js +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 +125 -0
- package/dist/core/credential-accounts.js.map +1 -0
- package/dist/core/credential-pool/classify.d.ts +42 -0
- package/dist/core/credential-pool/classify.d.ts.map +1 -0
- package/dist/core/credential-pool/classify.js +75 -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 +54 -0
- package/dist/core/credential-pool/failover.d.ts.map +1 -0
- package/dist/core/credential-pool/failover.js +106 -0
- package/dist/core/credential-pool/failover.js.map +1 -0
- package/dist/core/credential-pool/rotation-stream.d.ts +43 -0
- package/dist/core/credential-pool/rotation-stream.d.ts.map +1 -0
- package/dist/core/credential-pool/rotation-stream.js +96 -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/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/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 +34 -1
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +98 -5
- package/dist/core/model-runtime.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.map +1 -1
- package/dist/main.js +38 -3
- 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 +271 -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 +65 -21
- 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 +19 -6
- 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 +206 -32
- package/dist/modes/rpc/multi-session-host.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +41 -3
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +125 -14
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts +1 -1
- package/dist/modes/rpc/rpc-mode.js +1 -1
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +6 -2
- 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.map +1 -1
- package/dist/modes/rpc/session-command-router.js +24 -6
- package/dist/modes/rpc/session-command-router.js.map +1 -1
- package/dist/modes/rpc/session-event-writer.d.ts +13 -2
- package/dist/modes/rpc/session-event-writer.d.ts.map +1 -1
- package/dist/modes/rpc/session-event-writer.js +65 -25
- package/dist/modes/rpc/session-event-writer.js.map +1 -1
- package/dist/modes/rpc/session-registry.d.ts +9 -0
- package/dist/modes/rpc/session-registry.d.ts.map +1 -1
- package/dist/modes/rpc/session-registry.js +31 -3
- package/dist/modes/rpc/session-registry.js.map +1 -1
- package/docs/providers.md +48 -0
- package/docs/rpc.md +59 -5
- package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +44 -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
|
@@ -54,6 +54,7 @@ export async function createGoal(ref, objective, tokenBudget) {
|
|
|
54
54
|
tokensUsed: 0,
|
|
55
55
|
timeUsedSeconds: 0,
|
|
56
56
|
consecutiveContinuations: 0,
|
|
57
|
+
unattendedContinuations: 0,
|
|
57
58
|
createdAt: now,
|
|
58
59
|
updatedAt: now,
|
|
59
60
|
lastStartedAt: now,
|
|
@@ -89,6 +90,7 @@ export async function updateGoal(ref, update, source = "model") {
|
|
|
89
90
|
tokensUsed: 0,
|
|
90
91
|
timeUsedSeconds: 0,
|
|
91
92
|
consecutiveContinuations: 0,
|
|
93
|
+
unattendedContinuations: 0,
|
|
92
94
|
createdAt: now,
|
|
93
95
|
updatedAt: now,
|
|
94
96
|
...(tokenBudget === undefined ? {} : { tokenBudget }),
|
|
@@ -105,6 +107,7 @@ export async function updateGoal(ref, update, source = "model") {
|
|
|
105
107
|
const next = transitionGoalStatus({ ...current, objective }, requestedStatus ?? current.status, source, update.reason, now);
|
|
106
108
|
if (next.status !== current.status) {
|
|
107
109
|
next.consecutiveContinuations = 0;
|
|
110
|
+
next.unattendedContinuations = 0;
|
|
108
111
|
delete next.lastContinuationSignature;
|
|
109
112
|
}
|
|
110
113
|
if (tokenBudget === undefined)
|
|
@@ -150,7 +153,7 @@ export async function accountGoalUsage(ref, usage, elapsedSeconds, mode = "activ
|
|
|
150
153
|
return next;
|
|
151
154
|
});
|
|
152
155
|
}
|
|
153
|
-
export async function recordContinuationDelivered(ref, signature, expectedGoalId) {
|
|
156
|
+
export async function recordContinuationDelivered(ref, signature, expectedGoalId, options = {}) {
|
|
154
157
|
return enqueueGoalMutation(ref, async () => {
|
|
155
158
|
const goal = await readGoalFile(ref);
|
|
156
159
|
if (!goal || (expectedGoalId !== undefined && goal.id !== expectedGoalId))
|
|
@@ -158,18 +161,21 @@ export async function recordContinuationDelivered(ref, signature, expectedGoalId
|
|
|
158
161
|
const next = {
|
|
159
162
|
...goal,
|
|
160
163
|
consecutiveContinuations: (goal.consecutiveContinuations ?? 0) + 1,
|
|
164
|
+
unattendedContinuations: (goal.unattendedContinuations ?? 0) + (options.countUnattended === false ? 0 : 1),
|
|
161
165
|
lastContinuationSignature: signature,
|
|
162
166
|
};
|
|
163
167
|
await writeGoalFile(ref, next);
|
|
164
168
|
return next;
|
|
165
169
|
});
|
|
166
170
|
}
|
|
167
|
-
export async function resetContinuationStreak(ref) {
|
|
171
|
+
export async function resetContinuationStreak(ref, options = {}) {
|
|
168
172
|
return enqueueGoalMutation(ref, async () => {
|
|
169
173
|
const goal = await readGoalFile(ref);
|
|
170
174
|
if (!goal)
|
|
171
175
|
return goal;
|
|
172
176
|
const next = { ...goal, consecutiveContinuations: 0 };
|
|
177
|
+
if (options.unattended === true)
|
|
178
|
+
next.unattendedContinuations = 0;
|
|
173
179
|
delete next.lastContinuationSignature;
|
|
174
180
|
await writeGoalFile(ref, next);
|
|
175
181
|
return next;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/goal/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC9F,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AASxD,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAE7F,OAAO,EAAE,YAAY,EAAE,CAAC;AAExB,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAAyB,CAAC;AAE3D,SAAS,mBAAmB,CAAI,GAAiB,EAAE,QAA0B;IAC5E,MAAM,GAAG,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;IAC9B,MAAM,QAAQ,GAAG,iBAAiB,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IACjE,MAAM,GAAG,GAAG,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACpC,MAAM,I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AI,GAAG,MAAM,YAAY,CAAC,GAAG,CAAC,CAAC;QACrC,IAAI,CAAC,IAAI;YAAE,OAAO,IAAI,CAAC;QACvB,MAAM,IAAI,GAAS,EAAE,GAAG,IAAI,EAAE,wBAAwB,EAAE,CAAC,EAAE,CAAC;QAC5D,OAAO,IAAI,CAAC,yBAAyB,CAAC;QACtC,MAAM,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC/B,OAAO,IAAI,CAAC;IACb,CAAC,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,mBAAmB,CAAC,IAAU,EAAE,IAAwB;IAChE,IAAI,IAAI,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ,CAAC;IACvD,IAAI,IAAI,KAAK,iBAAiB;QAAE,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,CAAC;IAC7F,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,KAAK,UAAU,CAAC;AAC/D,CAAC;AAED,SAAS,aAAa,CAAC,iBAAyB;IAC/C,OAAO,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,EAAE,iBAAiB,GAAG,CAAC,CAAC,CAAC;AACtD,CAAC;AAED,SAAS,UAAU;IAClB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;AACtC,CAAC","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { appendFile, mkdir, writeFile } from \"node:fs/promises\";\nimport { dirname, join } from \"node:path\";\nimport { GoalAlreadyExistsError, GoalNotFoundError } from \"./errors.ts\";\nimport { encodedThreadId, goalFilePath, readGoalFile, writeGoalFile } from \"./persistence.ts\";\nimport { transitionGoalStatus } from \"./transitions.ts\";\nimport type {\n\tGoal,\n\tGoalAccountingMode,\n\tGoalStoreRef,\n\tGoalUpdate,\n\tGoalUpdateSource,\n\tTokenUsageSnapshot,\n} from \"./types.ts\";\nimport { resolveTokenBudget, validateObjective, validateTokenBudget } from \"./validation.ts\";\n\nexport { goalFilePath };\n\nconst goalMutationTails = new Map<string, Promise<void>>();\n\nfunction enqueueGoalMutation<T>(ref: GoalStoreRef, mutation: () => Promise<T>): Promise<T> {\n\tconst key = goalFilePath(ref);\n\tconst previous = goalMutationTails.get(key) ?? Promise.resolve();\n\tconst run = previous.then(mutation);\n\tconst tail = run.then(\n\t\t() => undefined,\n\t\t() => undefined,\n\t);\n\tgoalMutationTails.set(key, tail);\n\tvoid tail.then(() => {\n\t\tif (goalMutationTails.get(key) === tail) goalMutationTails.delete(key);\n\t});\n\treturn run;\n}\n\nexport function goalHistoryFilePath(ref: GoalStoreRef): string {\n\treturn join(ref.baseDir, `${encodedThreadId(ref)}.history.jsonl`);\n}\n\nexport function objectiveFullTextFileName(ref: GoalStoreRef): string {\n\treturn `${encodedThreadId(ref)}.objective-full.txt`;\n}\n\nexport function objectiveFullTextFilePath(ref: GoalStoreRef): string {\n\treturn join(ref.baseDir, objectiveFullTextFileName(ref));\n}\n\nexport async function readGoal(ref: GoalStoreRef): Promise<Goal | null> {\n\treturn readGoalFile(ref);\n}\n\nexport async function writeGoal(ref: GoalStoreRef, goal: Goal | null): Promise<void> {\n\tawait enqueueGoalMutation(ref, () => writeGoalFile(ref, goal));\n}\n\nexport async function createGoal(ref: GoalStoreRef, objective: string, tokenBudget?: number): Promise<Goal> {\n\treturn enqueueGoalMutation(ref, async () => {\n\t\tconst validatedObjective = validateObjective(objective, objectiveFullTextFileName(ref));\n\t\tconst current = await readGoalFile(ref);\n\t\tif (current !== null && current.status !== \"complete\") {\n\t\t\tthrow new GoalAlreadyExistsError(\"cannot create a new goal because this thread already has a goal\");\n\t\t}\n\t\tif (validatedObjective.truncated) await writeFullObjectiveText(ref, objective);\n\t\tif (current?.status === \"complete\") await archiveGoal(ref, current);\n\t\tconst now = nowSeconds();\n\t\tconst goal: Goal = {\n\t\t\tid: randomUUID(),\n\t\t\tthreadId: ref.threadId,\n\t\t\tobjective: validatedObjective.objective,\n\t\t\tstatus: \"active\",\n\t\t\ttokensUsed: 0,\n\t\t\ttimeUsedSeconds: 0,\n\t\t\tconsecutiveContinuations: 0,\n\t\t\tcreatedAt: now,\n\t\t\tupdatedAt: now,\n\t\t\tlastStartedAt: now,\n\t\t\t...(tokenBudget === undefined ? {} : { tokenBudget: validateTokenBudget(tokenBudget) }),\n\t\t};\n\t\tawait writeGoalFile(ref, goal);\n\t\treturn goal;\n\t});\n}\n\nexport async function updateGoal(\n\tref: GoalStoreRef,\n\tupdate: GoalUpdate,\n\tsource: GoalUpdateSource = \"model\",\n): Promise<Goal> {\n\treturn enqueueGoalMutation(ref, async () => {\n\t\tconst current = await readGoalFile(ref);\n\t\tif (!current) throw new GoalNotFoundError(\"cannot update goal: no goal exists\");\n\n\t\tconst validatedObjective =\n\t\t\tupdate.objective === undefined\n\t\t\t\t? undefined\n\t\t\t\t: validateObjective(update.objective, objectiveFullTextFileName(ref));\n\t\tconst objective = validatedObjective?.objective ?? current.objective;\n\t\tconst tokenBudget = resolveTokenBudget(current.tokenBudget, update.tokenBudget);\n\t\tconst now = nextUpdatedAt(current.updatedAt);\n\t\tconst hasObjectiveUpdate = update.objective !== undefined;\n\t\tconst replacesGoal = hasObjectiveUpdate && (objective !== current.objective || current.status === \"complete\");\n\t\tconst requestedStatus = update.status ?? (hasObjectiveUpdate ? \"active\" : undefined);\n\n\t\tif (replacesGoal) {\n\t\t\tconst status = requestedStatus ?? \"active\";\n\t\t\tif (status === \"blocked\") throw new Error(\"objective replacement cannot create a blocked goal\");\n\t\t\tconst next: Goal = {\n\t\t\t\tid: randomUUID(),\n\t\t\t\tthreadId: ref.threadId,\n\t\t\t\tobjective,\n\t\t\t\tstatus,\n\t\t\t\ttokensUsed: 0,\n\t\t\t\ttimeUsedSeconds: 0,\n\t\t\t\tconsecutiveContinuations: 0,\n\t\t\t\tcreatedAt: now,\n\t\t\t\tupdatedAt: now,\n\t\t\t\t...(tokenBudget === undefined ? {} : { tokenBudget }),\n\t\t\t};\n\t\t\tif (status === \"active\") next.lastStartedAt = now;\n\t\t\tif (status === \"complete\") next.completedAt = now;\n\t\t\tif (validatedObjective?.truncated) await writeFullObjectiveText(ref, update.objective ?? \"\");\n\t\t\tawait writeGoalFile(ref, next);\n\t\t\treturn next;\n\t\t}\n\n\t\tconst next = transitionGoalStatus(\n\t\t\t{ ...current, objective },\n\t\t\trequestedStatus ?? current.status,\n\t\t\tsource,\n\t\t\tupdate.reason,\n\t\t\tnow,\n\t\t);\n\t\tif (next.status !== current.status) {\n\t\t\tnext.consecutiveContinuations = 0;\n\t\t\tdelete next.lastContinuationSignature;\n\t\t}\n\t\tif (tokenBudget === undefined) delete next.tokenBudget;\n\t\telse next.tokenBudget = tokenBudget;\n\t\tif (validatedObjective?.truncated) await writeFullObjectiveText(ref, update.objective ?? \"\");\n\t\tawait writeGoalFile(ref, next);\n\t\treturn next;\n\t});\n}\n\nexport async function archiveGoal(ref: GoalStoreRef, goal: Goal): Promise<void> {\n\tconst filePath = goalHistoryFilePath(ref);\n\tawait mkdir(dirname(filePath), { recursive: true });\n\tawait appendFile(filePath, `${JSON.stringify(goal)}\\n`, \"utf8\");\n}\n\nasync function writeFullObjectiveText(ref: GoalStoreRef, objective: string): Promise<void> {\n\tconst filePath = objectiveFullTextFilePath(ref);\n\tawait mkdir(dirname(filePath), { recursive: true });\n\tawait writeFile(filePath, objective, \"utf8\");\n}\n\nexport async function clearGoal(ref: GoalStoreRef): Promise<boolean> {\n\treturn enqueueGoalMutation(ref, async () => {\n\t\tconst hadGoal = (await readGoalFile(ref)) !== null;\n\t\tawait writeGoalFile(ref, null);\n\t\treturn hadGoal;\n\t});\n}\n\nexport async function accountGoalUsage(\n\tref: GoalStoreRef,\n\tusage: TokenUsageSnapshot,\n\telapsedSeconds: number,\n\tmode: GoalAccountingMode = \"active\",\n\texpectedGoalId?: string,\n): Promise<Goal | null> {\n\treturn enqueueGoalMutation(ref, async () => {\n\t\tconst goal = await readGoalFile(ref);\n\t\tif (!goal || (expectedGoalId !== undefined && goal.id !== expectedGoalId) || !canAccountGoalUsage(goal, mode)) {\n\t\t\treturn goal;\n\t\t}\n\t\tconst next: Goal = {\n\t\t\t...goal,\n\t\t\ttokensUsed: goal.tokensUsed + Math.max(0, usage.input) + Math.max(0, usage.output),\n\t\t\ttimeUsedSeconds: goal.timeUsedSeconds + Math.max(0, Math.trunc(elapsedSeconds)),\n\t\t\tupdatedAt: nextUpdatedAt(goal.updatedAt),\n\t\t};\n\t\tawait writeGoalFile(ref, next);\n\t\treturn next;\n\t});\n}\n\nexport async function recordContinuationDelivered(\n\tref: GoalStoreRef,\n\tsignature: string,\n\texpectedGoalId?: string,\n): Promise<Goal | null> {\n\treturn enqueueGoalMutation(ref, async () => {\n\t\tconst goal = await readGoalFile(ref);\n\t\tif (!goal || (expectedGoalId !== undefined && goal.id !== expectedGoalId)) return null;\n\t\tconst next: Goal = {\n\t\t\t...goal,\n\t\t\tconsecutiveContinuations: (goal.consecutiveContinuations ?? 0) + 1,\n\t\t\tlastContinuationSignature: signature,\n\t\t};\n\t\tawait writeGoalFile(ref, next);\n\t\treturn next;\n\t});\n}\n\nexport async function resetContinuationStreak(ref: GoalStoreRef): Promise<Goal | null> {\n\treturn enqueueGoalMutation(ref, async () => {\n\t\tconst goal = await readGoalFile(ref);\n\t\tif (!goal) return goal;\n\t\tconst next: Goal = { ...goal, consecutiveContinuations: 0 };\n\t\tdelete next.lastContinuationSignature;\n\t\tawait writeGoalFile(ref, next);\n\t\treturn next;\n\t});\n}\n\nfunction canAccountGoalUsage(goal: Goal, mode: GoalAccountingMode): boolean {\n\tif (mode === \"active\") return goal.status === \"active\";\n\tif (mode === \"activeOrBlocked\") return goal.status === \"active\" || goal.status === \"blocked\";\n\treturn goal.status === \"active\" || goal.status === \"complete\";\n}\n\nfunction nextUpdatedAt(previousUpdatedAt: number): number {\n\treturn Math.max(nowSeconds(), previousUpdatedAt + 1);\n}\n\nfunction nowSeconds(): number {\n\treturn Math.trunc(Date.now() / 1000);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/goal/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC9F,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AASxD,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAE7F,OAAO,EAAE,YAAY,EAAE,CAAC;AAExB,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAAyB,CAAC;AAE3D,SAAS,mBAAmB,CAAI,GAAiB,EAAE,QAA0B;IAC5E,MAAM,GAAG,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;IAC9B,MAAM,QAAQ,GAAG,iBAAiB,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IACjE,MAAM,GAAG,GAAG,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACpC,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CACpB,GAAG,EAAE,CAAC,SAAS,EACf,GAAG,EAAE,CAAC,SAAS,CACf,CAAC;IACF,iBAAiB,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACjC,KAAK,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE;QACnB,IAAI,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oC,EAAE;IAEtC,OAAO,mBAAmB,CAAC,GAAG,EAAE,KAAK,IAAI,EAAE;QAC1C,MAAM,IAAI,GAAG,MAAM,YAAY,CAAC,GAAG,CAAC,CAAC;QACrC,IAAI,CAAC,IAAI;YAAE,OAAO,IAAI,CAAC;QACvB,MAAM,IAAI,GAAS,EAAE,GAAG,IAAI,EAAE,wBAAwB,EAAE,CAAC,EAAE,CAAC;QAC5D,IAAI,OAAO,CAAC,UAAU,KAAK,IAAI;YAAE,IAAI,CAAC,uBAAuB,GAAG,CAAC,CAAC;QAClE,OAAO,IAAI,CAAC,yBAAyB,CAAC;QACtC,MAAM,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC/B,OAAO,IAAI,CAAC;IACb,CAAC,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,mBAAmB,CAAC,IAAU,EAAE,IAAwB;IAChE,IAAI,IAAI,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ,CAAC;IACvD,IAAI,IAAI,KAAK,iBAAiB;QAAE,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,CAAC;IAC7F,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,KAAK,UAAU,CAAC;AAC/D,CAAC;AAED,SAAS,aAAa,CAAC,iBAAyB;IAC/C,OAAO,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,EAAE,iBAAiB,GAAG,CAAC,CAAC,CAAC;AACtD,CAAC;AAED,SAAS,UAAU;IAClB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;AACtC,CAAC","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { appendFile, mkdir, writeFile } from \"node:fs/promises\";\nimport { dirname, join } from \"node:path\";\nimport { GoalAlreadyExistsError, GoalNotFoundError } from \"./errors.ts\";\nimport { encodedThreadId, goalFilePath, readGoalFile, writeGoalFile } from \"./persistence.ts\";\nimport { transitionGoalStatus } from \"./transitions.ts\";\nimport type {\n\tGoal,\n\tGoalAccountingMode,\n\tGoalStoreRef,\n\tGoalUpdate,\n\tGoalUpdateSource,\n\tTokenUsageSnapshot,\n} from \"./types.ts\";\nimport { resolveTokenBudget, validateObjective, validateTokenBudget } from \"./validation.ts\";\n\nexport { goalFilePath };\n\nconst goalMutationTails = new Map<string, Promise<void>>();\n\nfunction enqueueGoalMutation<T>(ref: GoalStoreRef, mutation: () => Promise<T>): Promise<T> {\n\tconst key = goalFilePath(ref);\n\tconst previous = goalMutationTails.get(key) ?? Promise.resolve();\n\tconst run = previous.then(mutation);\n\tconst tail = run.then(\n\t\t() => undefined,\n\t\t() => undefined,\n\t);\n\tgoalMutationTails.set(key, tail);\n\tvoid tail.then(() => {\n\t\tif (goalMutationTails.get(key) === tail) goalMutationTails.delete(key);\n\t});\n\treturn run;\n}\n\nexport function goalHistoryFilePath(ref: GoalStoreRef): string {\n\treturn join(ref.baseDir, `${encodedThreadId(ref)}.history.jsonl`);\n}\n\nexport function objectiveFullTextFileName(ref: GoalStoreRef): string {\n\treturn `${encodedThreadId(ref)}.objective-full.txt`;\n}\n\nexport function objectiveFullTextFilePath(ref: GoalStoreRef): string {\n\treturn join(ref.baseDir, objectiveFullTextFileName(ref));\n}\n\nexport async function readGoal(ref: GoalStoreRef): Promise<Goal | null> {\n\treturn readGoalFile(ref);\n}\n\nexport async function writeGoal(ref: GoalStoreRef, goal: Goal | null): Promise<void> {\n\tawait enqueueGoalMutation(ref, () => writeGoalFile(ref, goal));\n}\n\nexport async function createGoal(ref: GoalStoreRef, objective: string, tokenBudget?: number): Promise<Goal> {\n\treturn enqueueGoalMutation(ref, async () => {\n\t\tconst validatedObjective = validateObjective(objective, objectiveFullTextFileName(ref));\n\t\tconst current = await readGoalFile(ref);\n\t\tif (current !== null && current.status !== \"complete\") {\n\t\t\tthrow new GoalAlreadyExistsError(\"cannot create a new goal because this thread already has a goal\");\n\t\t}\n\t\tif (validatedObjective.truncated) await writeFullObjectiveText(ref, objective);\n\t\tif (current?.status === \"complete\") await archiveGoal(ref, current);\n\t\tconst now = nowSeconds();\n\t\tconst goal: Goal = {\n\t\t\tid: randomUUID(),\n\t\t\tthreadId: ref.threadId,\n\t\t\tobjective: validatedObjective.objective,\n\t\t\tstatus: \"active\",\n\t\t\ttokensUsed: 0,\n\t\t\ttimeUsedSeconds: 0,\n\t\t\tconsecutiveContinuations: 0,\n\t\t\tunattendedContinuations: 0,\n\t\t\tcreatedAt: now,\n\t\t\tupdatedAt: now,\n\t\t\tlastStartedAt: now,\n\t\t\t...(tokenBudget === undefined ? {} : { tokenBudget: validateTokenBudget(tokenBudget) }),\n\t\t};\n\t\tawait writeGoalFile(ref, goal);\n\t\treturn goal;\n\t});\n}\n\nexport async function updateGoal(\n\tref: GoalStoreRef,\n\tupdate: GoalUpdate,\n\tsource: GoalUpdateSource = \"model\",\n): Promise<Goal> {\n\treturn enqueueGoalMutation(ref, async () => {\n\t\tconst current = await readGoalFile(ref);\n\t\tif (!current) throw new GoalNotFoundError(\"cannot update goal: no goal exists\");\n\n\t\tconst validatedObjective =\n\t\t\tupdate.objective === undefined\n\t\t\t\t? undefined\n\t\t\t\t: validateObjective(update.objective, objectiveFullTextFileName(ref));\n\t\tconst objective = validatedObjective?.objective ?? current.objective;\n\t\tconst tokenBudget = resolveTokenBudget(current.tokenBudget, update.tokenBudget);\n\t\tconst now = nextUpdatedAt(current.updatedAt);\n\t\tconst hasObjectiveUpdate = update.objective !== undefined;\n\t\tconst replacesGoal = hasObjectiveUpdate && (objective !== current.objective || current.status === \"complete\");\n\t\tconst requestedStatus = update.status ?? (hasObjectiveUpdate ? \"active\" : undefined);\n\n\t\tif (replacesGoal) {\n\t\t\tconst status = requestedStatus ?? \"active\";\n\t\t\tif (status === \"blocked\") throw new Error(\"objective replacement cannot create a blocked goal\");\n\t\t\tconst next: Goal = {\n\t\t\t\tid: randomUUID(),\n\t\t\t\tthreadId: ref.threadId,\n\t\t\t\tobjective,\n\t\t\t\tstatus,\n\t\t\t\ttokensUsed: 0,\n\t\t\t\ttimeUsedSeconds: 0,\n\t\t\t\tconsecutiveContinuations: 0,\n\t\t\t\tunattendedContinuations: 0,\n\t\t\t\tcreatedAt: now,\n\t\t\t\tupdatedAt: now,\n\t\t\t\t...(tokenBudget === undefined ? {} : { tokenBudget }),\n\t\t\t};\n\t\t\tif (status === \"active\") next.lastStartedAt = now;\n\t\t\tif (status === \"complete\") next.completedAt = now;\n\t\t\tif (validatedObjective?.truncated) await writeFullObjectiveText(ref, update.objective ?? \"\");\n\t\t\tawait writeGoalFile(ref, next);\n\t\t\treturn next;\n\t\t}\n\n\t\tconst next = transitionGoalStatus(\n\t\t\t{ ...current, objective },\n\t\t\trequestedStatus ?? current.status,\n\t\t\tsource,\n\t\t\tupdate.reason,\n\t\t\tnow,\n\t\t);\n\t\tif (next.status !== current.status) {\n\t\t\tnext.consecutiveContinuations = 0;\n\t\t\tnext.unattendedContinuations = 0;\n\t\t\tdelete next.lastContinuationSignature;\n\t\t}\n\t\tif (tokenBudget === undefined) delete next.tokenBudget;\n\t\telse next.tokenBudget = tokenBudget;\n\t\tif (validatedObjective?.truncated) await writeFullObjectiveText(ref, update.objective ?? \"\");\n\t\tawait writeGoalFile(ref, next);\n\t\treturn next;\n\t});\n}\n\nexport async function archiveGoal(ref: GoalStoreRef, goal: Goal): Promise<void> {\n\tconst filePath = goalHistoryFilePath(ref);\n\tawait mkdir(dirname(filePath), { recursive: true });\n\tawait appendFile(filePath, `${JSON.stringify(goal)}\\n`, \"utf8\");\n}\n\nasync function writeFullObjectiveText(ref: GoalStoreRef, objective: string): Promise<void> {\n\tconst filePath = objectiveFullTextFilePath(ref);\n\tawait mkdir(dirname(filePath), { recursive: true });\n\tawait writeFile(filePath, objective, \"utf8\");\n}\n\nexport async function clearGoal(ref: GoalStoreRef): Promise<boolean> {\n\treturn enqueueGoalMutation(ref, async () => {\n\t\tconst hadGoal = (await readGoalFile(ref)) !== null;\n\t\tawait writeGoalFile(ref, null);\n\t\treturn hadGoal;\n\t});\n}\n\nexport async function accountGoalUsage(\n\tref: GoalStoreRef,\n\tusage: TokenUsageSnapshot,\n\telapsedSeconds: number,\n\tmode: GoalAccountingMode = \"active\",\n\texpectedGoalId?: string,\n): Promise<Goal | null> {\n\treturn enqueueGoalMutation(ref, async () => {\n\t\tconst goal = await readGoalFile(ref);\n\t\tif (!goal || (expectedGoalId !== undefined && goal.id !== expectedGoalId) || !canAccountGoalUsage(goal, mode)) {\n\t\t\treturn goal;\n\t\t}\n\t\tconst next: Goal = {\n\t\t\t...goal,\n\t\t\ttokensUsed: goal.tokensUsed + Math.max(0, usage.input) + Math.max(0, usage.output),\n\t\t\ttimeUsedSeconds: goal.timeUsedSeconds + Math.max(0, Math.trunc(elapsedSeconds)),\n\t\t\tupdatedAt: nextUpdatedAt(goal.updatedAt),\n\t\t};\n\t\tawait writeGoalFile(ref, next);\n\t\treturn next;\n\t});\n}\n\nexport async function recordContinuationDelivered(\n\tref: GoalStoreRef,\n\tsignature: string,\n\texpectedGoalId?: string,\n\toptions: { countUnattended?: boolean } = {},\n): Promise<Goal | null> {\n\treturn enqueueGoalMutation(ref, async () => {\n\t\tconst goal = await readGoalFile(ref);\n\t\tif (!goal || (expectedGoalId !== undefined && goal.id !== expectedGoalId)) return null;\n\t\tconst next: Goal = {\n\t\t\t...goal,\n\t\t\tconsecutiveContinuations: (goal.consecutiveContinuations ?? 0) + 1,\n\t\t\tunattendedContinuations: (goal.unattendedContinuations ?? 0) + (options.countUnattended === false ? 0 : 1),\n\t\t\tlastContinuationSignature: signature,\n\t\t};\n\t\tawait writeGoalFile(ref, next);\n\t\treturn next;\n\t});\n}\n\nexport async function resetContinuationStreak(\n\tref: GoalStoreRef,\n\toptions: { unattended?: boolean } = {},\n): Promise<Goal | null> {\n\treturn enqueueGoalMutation(ref, async () => {\n\t\tconst goal = await readGoalFile(ref);\n\t\tif (!goal) return goal;\n\t\tconst next: Goal = { ...goal, consecutiveContinuations: 0 };\n\t\tif (options.unattended === true) next.unattendedContinuations = 0;\n\t\tdelete next.lastContinuationSignature;\n\t\tawait writeGoalFile(ref, next);\n\t\treturn next;\n\t});\n}\n\nfunction canAccountGoalUsage(goal: Goal, mode: GoalAccountingMode): boolean {\n\tif (mode === \"active\") return goal.status === \"active\";\n\tif (mode === \"activeOrBlocked\") return goal.status === \"active\" || goal.status === \"blocked\";\n\treturn goal.status === \"active\" || goal.status === \"complete\";\n}\n\nfunction nextUpdatedAt(previousUpdatedAt: number): number {\n\treturn Math.max(nowSeconds(), previousUpdatedAt + 1);\n}\n\nfunction nowSeconds(): number {\n\treturn Math.trunc(Date.now() / 1000);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-registration.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/goal/tool-registration.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"tool-registration.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/goal/tool-registration.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAKtF,OAAO,KAAK,EAAE,IAAI,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAMzE,MAAM,MAAM,wBAAwB,GAAG;IACtC,QAAQ,CAAC,YAAY,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,YAAY,CAAC;IAC/D,QAAQ,CAAC,uBAAuB,EAAE,CAAC,GAAG,EAAE,gBAAgB,EAAE,IAAI,EAAE,kBAAkB,KAAK,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;IAC5G,QAAQ,CAAC,wBAAwB,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IACxD,QAAQ,CAAC,uBAAuB,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IACvD,QAAQ,CAAC,yBAAyB,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IACzD,QAAQ,CAAC,aAAa,EAAE,CAAC,GAAG,EAAE,gBAAgB,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,KAAK,IAAI,CAAC;CAC3E,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,wBAAwB,GAAG,IAAI,CA+FxF"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Type } from "typebox";
|
|
2
|
-
import { formatGoalToolResponse } from "./format.js";
|
|
2
|
+
import { formatGoalToolResponse, goalToolRenderDetails } from "./format.js";
|
|
3
|
+
import { renderGoalToolCall, renderGoalToolResult } from "./renderers.js";
|
|
3
4
|
import { createGoal, objectiveFullTextFileName, readGoal, updateGoal } from "./store.js";
|
|
4
5
|
import { openTodoCompletionError, openTodoTaskContents } from "./todo-gate.js";
|
|
5
6
|
import { MODEL_SETTABLE_GOAL_STATUS_VALUES } from "./types.js";
|
|
@@ -24,8 +25,13 @@ export function registerGoalTools(pi, deps) {
|
|
|
24
25
|
const goal = await createGoal(ref, params.objective);
|
|
25
26
|
deps.beginAgentGoalAccounting(goal);
|
|
26
27
|
deps.refreshGoalUi(ctx, goal);
|
|
27
|
-
|
|
28
|
+
const notice = validatedObjective.truncated
|
|
29
|
+
? objectiveTruncationNotice(objectiveFullTextFileName(ref))
|
|
30
|
+
: undefined;
|
|
31
|
+
return toolText(formatGoalToolResponse(goal, notice), goalToolRenderDetails(goal, notice));
|
|
28
32
|
},
|
|
33
|
+
renderCall: (args, theme) => renderGoalToolCall("create_goal", args, theme),
|
|
34
|
+
renderResult: (result, options, theme) => renderGoalToolResult(result, options, theme),
|
|
29
35
|
});
|
|
30
36
|
pi.registerTool({
|
|
31
37
|
name: "update_goal",
|
|
@@ -57,8 +63,10 @@ export function registerGoalTools(pi, deps) {
|
|
|
57
63
|
else
|
|
58
64
|
deps.markGoalCompletedThisTurn(goal);
|
|
59
65
|
deps.refreshGoalUi(ctx, goal);
|
|
60
|
-
return toolText(formatGoalToolResponse(goal));
|
|
66
|
+
return toolText(formatGoalToolResponse(goal), goalToolRenderDetails(goal));
|
|
61
67
|
},
|
|
68
|
+
renderCall: (args, theme) => renderGoalToolCall("update_goal", args, theme),
|
|
69
|
+
renderResult: (result, options, theme) => renderGoalToolResult(result, options, theme),
|
|
62
70
|
});
|
|
63
71
|
pi.registerTool({
|
|
64
72
|
name: "get_goal",
|
|
@@ -68,11 +76,13 @@ export function registerGoalTools(pi, deps) {
|
|
|
68
76
|
async execute(_toolCallId, _params, _signal, _onUpdate, ctx) {
|
|
69
77
|
const goal = await deps.accountCurrentAgentTurn(ctx, "active");
|
|
70
78
|
deps.refreshGoalUi(ctx, goal);
|
|
71
|
-
return toolText(formatGoalToolResponse(goal));
|
|
79
|
+
return toolText(formatGoalToolResponse(goal), goalToolRenderDetails(goal));
|
|
72
80
|
},
|
|
81
|
+
renderCall: (args, theme) => renderGoalToolCall("get_goal", args, theme),
|
|
82
|
+
renderResult: (result, options, theme) => renderGoalToolResult(result, options, theme),
|
|
73
83
|
});
|
|
74
84
|
}
|
|
75
|
-
function toolText(text) {
|
|
76
|
-
return { content: [{ type: "text", text }], details
|
|
85
|
+
function toolText(text, details) {
|
|
86
|
+
return { content: [{ type: "text", text }], details };
|
|
77
87
|
}
|
|
78
88
|
//# sourceMappingURL=tool-registration.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-registration.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/goal/tool-registration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACr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AS,EAAE,GAAG;YAC1D,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,uBAAuB,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;YAC/D,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;YAC9B,OAAO,QAAQ,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC,CAAC;QAC/C,CAAC;KACD,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,QAAQ,CAAC,IAAY;IAC7B,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AACpE,CAAC","sourcesContent":["import { Type } from \"typebox\";\nimport type { AgentToolResult, ExtensionAPI, ExtensionContext } from \"../../types.ts\";\nimport { formatGoalToolResponse } from \"./format.ts\";\nimport { createGoal, objectiveFullTextFileName, readGoal, updateGoal } from \"./store.ts\";\nimport { openTodoCompletionError, openTodoTaskContents } from \"./todo-gate.ts\";\nimport type { Goal, GoalAccountingMode, GoalStoreRef } from \"./types.ts\";\nimport { MODEL_SETTABLE_GOAL_STATUS_VALUES } from \"./types.ts\";\nimport { objectiveTruncationNotice, validateObjective } from \"./validation.ts\";\n\ntype GoalToolResult = AgentToolResult<Record<string, never>>;\n\nexport type GoalToolRegistrationDeps = {\n\treadonly goalStoreRef: (ctx: ExtensionContext) => GoalStoreRef;\n\treadonly accountCurrentAgentTurn: (ctx: ExtensionContext, mode: GoalAccountingMode) => Promise<Goal | null>;\n\treadonly beginAgentGoalAccounting: (goal: Goal) => void;\n\treadonly markGoalBlockedThisTurn: (goal: Goal) => void;\n\treadonly markGoalCompletedThisTurn: (goal: Goal) => void;\n\treadonly refreshGoalUi: (ctx: ExtensionContext, goal: Goal | null) => void;\n};\n\nexport function registerGoalTools(pi: ExtensionAPI, deps: GoalToolRegistrationDeps): void {\n\tpi.registerTool({\n\t\tname: \"create_goal\",\n\t\tlabel: \"Create Goal\",\n\t\tdescription:\n\t\t\t\"Create a goal only when explicitly requested by the user or system/developer instructions; do not infer goals from ordinary tasks.\\nObjectives are limited to 4,000 characters. For longer instructions, put the full objective in a file and refer to that file.\\nReplaces the current goal when it is complete and archives it; fails if an unfinished goal exists.\",\n\t\tparameters: Type.Object(\n\t\t\t{\n\t\t\t\tobjective: Type.String({\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t\"Required. The concrete objective to start pursuing. Limit: 4,000 characters. For longer instructions, put the full objective in a file and refer to that file.\",\n\t\t\t\t}),\n\t\t\t},\n\t\t\t{ additionalProperties: false },\n\t\t),\n\t\tasync execute(_toolCallId, params, _signal, _onUpdate, ctx) {\n\t\t\tconst ref = deps.goalStoreRef(ctx);\n\t\t\tconst current = await readGoal(ref);\n\t\t\tif (current !== null && current.status !== \"complete\") {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"cannot create a new goal because this thread already has an unfinished goal; use update_goal only when the existing goal is complete\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst validatedObjective = validateObjective(params.objective, objectiveFullTextFileName(ref));\n\t\t\tconst goal = await createGoal(ref, params.objective);\n\t\t\tdeps.beginAgentGoalAccounting(goal);\n\t\t\tdeps.refreshGoalUi(ctx, goal);\n\t\t\treturn toolText(\n\t\t\t\tformatGoalToolResponse(\n\t\t\t\t\tgoal,\n\t\t\t\t\tvalidatedObjective.truncated ? objectiveTruncationNotice(objectiveFullTextFileName(ref)) : undefined,\n\t\t\t\t),\n\t\t\t);\n\t\t},\n\t});\n\n\tpi.registerTool({\n\t\tname: \"update_goal\",\n\t\tlabel: \"Update Goal\",\n\t\tdescription:\n\t\t\t\"Update the existing goal.\\nSet status to `complete` only when the completion audit proves the objective has actually been achieved and no required work remains. Completion is rejected while the todo list has open tasks: finish or drop them first. When the audit passes, call this tool in that same turn instead of repeating that the work is done. Do not mark a goal complete merely because you are stopping work.\\nSet status to `blocked` only at a true impasse: first confirm no live monitor, subscription, background task, or other resumption channel can still deliver the change the goal is waiting on (a wait on such a channel is not an impasse - end the turn and let it wake the goal instead of blocking), the blocking condition is unmistakably clear, and it has recurred for at least 3 consecutive goal turns. If the user resumes a blocked goal, start a fresh blocked audit after resume. Never mark a goal blocked merely because the work is hard, slow, or uncertain.\\nA non-empty reason is required when blocking; reason must not be provided when completing.\\nYou cannot use this tool to pause or resume a goal; those status changes are controlled by the user or system.\\nWhen marking the goal achieved with status `complete`, report the final elapsed time and token usage from the tool result to the user.\",\n\t\tparameters: Type.Object(\n\t\t\t{\n\t\t\t\tstatus: Type.Union(\n\t\t\t\t\tMODEL_SETTABLE_GOAL_STATUS_VALUES.map((status) => Type.Literal(status)),\n\t\t\t\t\t{ description: \"Required. Set to complete when achieved or blocked with a non-empty reason.\" },\n\t\t\t\t),\n\t\t\t\treason: Type.Optional(\n\t\t\t\t\tType.String({\n\t\t\t\t\t\tdescription: \"Required and non-empty when status is blocked; rejected when status is complete.\",\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t},\n\t\t\t{ additionalProperties: false },\n\t\t),\n\t\tasync execute(_toolCallId, params, _signal, _onUpdate, ctx) {\n\t\t\tconst reason = typeof params.reason === \"string\" ? params.reason.trim() : undefined;\n\t\t\tif (params.status === \"blocked\" && (reason === undefined || reason.length === 0)) {\n\t\t\t\tthrow new Error(\"reason is required when status is blocked\");\n\t\t\t}\n\t\t\tif (params.status === \"complete\" && reason !== undefined && reason.length > 0) {\n\t\t\t\tthrow new Error(\"reason must not be provided when status is complete\");\n\t\t\t}\n\t\t\tif (params.status === \"complete\") {\n\t\t\t\tconst openTasks = openTodoTaskContents(ctx.sessionManager.getBranch());\n\t\t\t\tif (openTasks.length > 0) throw new Error(openTodoCompletionError(openTasks));\n\t\t\t}\n\t\t\tawait deps.accountCurrentAgentTurn(ctx, \"active\");\n\t\t\tconst goal = await updateGoal(\n\t\t\t\tdeps.goalStoreRef(ctx),\n\t\t\t\tparams.status === \"blocked\" ? { status: \"blocked\", reason } : { status: \"complete\" },\n\t\t\t\t\"model\",\n\t\t\t);\n\t\t\tif (goal.status === \"blocked\") deps.markGoalBlockedThisTurn(goal);\n\t\t\telse deps.markGoalCompletedThisTurn(goal);\n\t\t\tdeps.refreshGoalUi(ctx, goal);\n\t\t\treturn toolText(formatGoalToolResponse(goal));\n\t\t},\n\t});\n\n\tpi.registerTool({\n\t\tname: \"get_goal\",\n\t\tlabel: \"Get Goal\",\n\t\tdescription: \"Get the current goal for this thread, including status, token and elapsed-time usage.\",\n\t\tparameters: Type.Object({}, { additionalProperties: false }),\n\t\tasync execute(_toolCallId, _params, _signal, _onUpdate, ctx) {\n\t\t\tconst goal = await deps.accountCurrentAgentTurn(ctx, \"active\");\n\t\t\tdeps.refreshGoalUi(ctx, goal);\n\t\t\treturn toolText(formatGoalToolResponse(goal));\n\t\t},\n\t});\n}\n\nfunction toolText(text: string): GoalToolResult {\n\treturn { content: [{ type: \"text\" as const, text }], details: {} };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"tool-registration.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/goal/tool-registration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,OAAO,EAAE,sBAAsB,EAA8B,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACxG,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,yBAAyB,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACzF,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAE/E,OAAO,EAAE,iCAAiC,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAa/E,MAAM,UAAU,iBAAiB,CAAC,EAAgB,EAAE,IAA8B;IACjF,EAAE,CAAC,YAAY,CAAC;QACf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IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,UAAU;QACjB,WAAW,EAAE,uFAAuF;QACpG,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAAC;QAC5D,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG;YAC1D,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,uBAAuB,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;YAC/D,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;YAC9B,OAAO,QAAQ,CAAC,sBAAsB,CAAC,IAAI,CAAC,EAAE,qBAAqB,CAAC,IAAI,CAAC,CAAC,CAAC;QAC5E,CAAC;QACD,UAAU,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,kBAAkB,CAAC,UAAU,EAAE,IAAI,EAAE,KAAK,CAAC;QACxE,YAAY,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,oBAAoB,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC;KACtF,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,QAAQ,CAAC,IAAY,EAAE,OAA8B;IAC7D,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC;AAChE,CAAC","sourcesContent":["import { Type } from \"typebox\";\nimport type { AgentToolResult, ExtensionAPI, ExtensionContext } from \"../../types.ts\";\nimport { formatGoalToolResponse, type GoalToolRenderDetails, goalToolRenderDetails } from \"./format.ts\";\nimport { renderGoalToolCall, renderGoalToolResult } from \"./renderers.ts\";\nimport { createGoal, objectiveFullTextFileName, readGoal, updateGoal } from \"./store.ts\";\nimport { openTodoCompletionError, openTodoTaskContents } from \"./todo-gate.ts\";\nimport type { Goal, GoalAccountingMode, GoalStoreRef } from \"./types.ts\";\nimport { MODEL_SETTABLE_GOAL_STATUS_VALUES } from \"./types.ts\";\nimport { objectiveTruncationNotice, validateObjective } from \"./validation.ts\";\n\ntype GoalToolResult = AgentToolResult<GoalToolRenderDetails>;\n\nexport type GoalToolRegistrationDeps = {\n\treadonly goalStoreRef: (ctx: ExtensionContext) => GoalStoreRef;\n\treadonly accountCurrentAgentTurn: (ctx: ExtensionContext, mode: GoalAccountingMode) => Promise<Goal | null>;\n\treadonly beginAgentGoalAccounting: (goal: Goal) => void;\n\treadonly markGoalBlockedThisTurn: (goal: Goal) => void;\n\treadonly markGoalCompletedThisTurn: (goal: Goal) => void;\n\treadonly refreshGoalUi: (ctx: ExtensionContext, goal: Goal | null) => void;\n};\n\nexport function registerGoalTools(pi: ExtensionAPI, deps: GoalToolRegistrationDeps): void {\n\tpi.registerTool({\n\t\tname: \"create_goal\",\n\t\tlabel: \"Create Goal\",\n\t\tdescription:\n\t\t\t\"Create a goal only when explicitly requested by the user or system/developer instructions; do not infer goals from ordinary tasks.\\nObjectives are limited to 4,000 characters. For longer instructions, put the full objective in a file and refer to that file.\\nReplaces the current goal when it is complete and archives it; fails if an unfinished goal exists.\",\n\t\tparameters: Type.Object(\n\t\t\t{\n\t\t\t\tobjective: Type.String({\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t\"Required. The concrete objective to start pursuing. Limit: 4,000 characters. For longer instructions, put the full objective in a file and refer to that file.\",\n\t\t\t\t}),\n\t\t\t},\n\t\t\t{ additionalProperties: false },\n\t\t),\n\t\tasync execute(_toolCallId, params, _signal, _onUpdate, ctx) {\n\t\t\tconst ref = deps.goalStoreRef(ctx);\n\t\t\tconst current = await readGoal(ref);\n\t\t\tif (current !== null && current.status !== \"complete\") {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"cannot create a new goal because this thread already has an unfinished goal; use update_goal only when the existing goal is complete\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst validatedObjective = validateObjective(params.objective, objectiveFullTextFileName(ref));\n\t\t\tconst goal = await createGoal(ref, params.objective);\n\t\t\tdeps.beginAgentGoalAccounting(goal);\n\t\t\tdeps.refreshGoalUi(ctx, goal);\n\t\t\tconst notice = validatedObjective.truncated\n\t\t\t\t? objectiveTruncationNotice(objectiveFullTextFileName(ref))\n\t\t\t\t: undefined;\n\t\t\treturn toolText(formatGoalToolResponse(goal, notice), goalToolRenderDetails(goal, notice));\n\t\t},\n\t\trenderCall: (args, theme) => renderGoalToolCall(\"create_goal\", args, theme),\n\t\trenderResult: (result, options, theme) => renderGoalToolResult(result, options, theme),\n\t});\n\n\tpi.registerTool({\n\t\tname: \"update_goal\",\n\t\tlabel: \"Update Goal\",\n\t\tdescription:\n\t\t\t\"Update the existing goal.\\nSet status to `complete` only when the completion audit proves the objective has actually been achieved and no required work remains. Completion is rejected while the todo list has open tasks: finish or drop them first. When the audit passes, call this tool in that same turn instead of repeating that the work is done. Do not mark a goal complete merely because you are stopping work.\\nSet status to `blocked` only at a true impasse: first confirm no live monitor, subscription, background task, or other resumption channel can still deliver the change the goal is waiting on (a wait on such a channel is not an impasse - end the turn and let it wake the goal instead of blocking), the blocking condition is unmistakably clear, and it has recurred for at least 3 consecutive goal turns. If the user resumes a blocked goal, start a fresh blocked audit after resume. Never mark a goal blocked merely because the work is hard, slow, or uncertain.\\nA non-empty reason is required when blocking; reason must not be provided when completing.\\nYou cannot use this tool to pause or resume a goal; those status changes are controlled by the user or system.\\nWhen marking the goal achieved with status `complete`, report the final elapsed time and token usage from the tool result to the user.\",\n\t\tparameters: Type.Object(\n\t\t\t{\n\t\t\t\tstatus: Type.Union(\n\t\t\t\t\tMODEL_SETTABLE_GOAL_STATUS_VALUES.map((status) => Type.Literal(status)),\n\t\t\t\t\t{ description: \"Required. Set to complete when achieved or blocked with a non-empty reason.\" },\n\t\t\t\t),\n\t\t\t\treason: Type.Optional(\n\t\t\t\t\tType.String({\n\t\t\t\t\t\tdescription: \"Required and non-empty when status is blocked; rejected when status is complete.\",\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t},\n\t\t\t{ additionalProperties: false },\n\t\t),\n\t\tasync execute(_toolCallId, params, _signal, _onUpdate, ctx) {\n\t\t\tconst reason = typeof params.reason === \"string\" ? params.reason.trim() : undefined;\n\t\t\tif (params.status === \"blocked\" && (reason === undefined || reason.length === 0)) {\n\t\t\t\tthrow new Error(\"reason is required when status is blocked\");\n\t\t\t}\n\t\t\tif (params.status === \"complete\" && reason !== undefined && reason.length > 0) {\n\t\t\t\tthrow new Error(\"reason must not be provided when status is complete\");\n\t\t\t}\n\t\t\tif (params.status === \"complete\") {\n\t\t\t\tconst openTasks = openTodoTaskContents(ctx.sessionManager.getBranch());\n\t\t\t\tif (openTasks.length > 0) throw new Error(openTodoCompletionError(openTasks));\n\t\t\t}\n\t\t\tawait deps.accountCurrentAgentTurn(ctx, \"active\");\n\t\t\tconst goal = await updateGoal(\n\t\t\t\tdeps.goalStoreRef(ctx),\n\t\t\t\tparams.status === \"blocked\" ? { status: \"blocked\", reason } : { status: \"complete\" },\n\t\t\t\t\"model\",\n\t\t\t);\n\t\t\tif (goal.status === \"blocked\") deps.markGoalBlockedThisTurn(goal);\n\t\t\telse deps.markGoalCompletedThisTurn(goal);\n\t\t\tdeps.refreshGoalUi(ctx, goal);\n\t\t\treturn toolText(formatGoalToolResponse(goal), goalToolRenderDetails(goal));\n\t\t},\n\t\trenderCall: (args, theme) => renderGoalToolCall(\"update_goal\", args, theme),\n\t\trenderResult: (result, options, theme) => renderGoalToolResult(result, options, theme),\n\t});\n\n\tpi.registerTool({\n\t\tname: \"get_goal\",\n\t\tlabel: \"Get Goal\",\n\t\tdescription: \"Get the current goal for this thread, including status, token and elapsed-time usage.\",\n\t\tparameters: Type.Object({}, { additionalProperties: false }),\n\t\tasync execute(_toolCallId, _params, _signal, _onUpdate, ctx) {\n\t\t\tconst goal = await deps.accountCurrentAgentTurn(ctx, \"active\");\n\t\t\tdeps.refreshGoalUi(ctx, goal);\n\t\t\treturn toolText(formatGoalToolResponse(goal), goalToolRenderDetails(goal));\n\t\t},\n\t\trenderCall: (args, theme) => renderGoalToolCall(\"get_goal\", args, theme),\n\t\trenderResult: (result, options, theme) => renderGoalToolResult(result, options, theme),\n\t});\n}\n\nfunction toolText(text: string, details: GoalToolRenderDetails): GoalToolResult {\n\treturn { content: [{ type: \"text\" as const, text }], details };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/goal/types.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,sDAAuD,CAAC;AACvF,eAAO,MAAM,iCAAiC,kCAAmC,CAAC;AAElF,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;AAC7D,MAAM,MAAM,uBAAuB,GAAG,CAAC,OAAO,iCAAiC,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzF,MAAM,MAAM,YAAY,GAAG;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,iBAAiB,GAAG,kBAAkB,CAAC;AACnF,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,MAAM,CAAC;AAEhD,MAAM,MAAM,IAAI,GAAG;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,UAAU,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAA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"file":"types.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/goal/types.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,CAAU,CAAC;AACvF,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAAC,UAAU,EAAE,SAAS,CAAU,CAAC;AAoElF,MAAM,UAAU,QAAQ,CAAC,KAAc;IACtC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACpD,CAAC","sourcesContent":["export const GOAL_STATUS_VALUES = [\"active\", \"paused\", \"blocked\", \"complete\"] as const;\nexport const MODEL_SETTABLE_GOAL_STATUS_VALUES = [\"complete\", \"blocked\"] as const;\n\nexport type GoalStatus = (typeof GOAL_STATUS_VALUES)[number];\nexport type ModelSettableGoalStatus = (typeof MODEL_SETTABLE_GOAL_STATUS_VALUES)[number];\n\nexport type GoalStoreRef = {\n\tbaseDir: string;\n\tthreadId: string;\n};\n\nexport type GoalAccountingMode = \"active\" | \"activeOrBlocked\" | \"activeOrComplete\";\nexport type GoalUpdateSource = \"model\" | \"user\";\n\nexport type Goal = {\n\tid: string;\n\tthreadId: string;\n\tobjective: string;\n\tstatus: GoalStatus;\n\ttokenBudget?: number;\n\ttokensUsed: number;\n\ttimeUsedSeconds: number;\n\tconsecutiveContinuations?: number;\n\tunattendedContinuations?: number;\n\tlastContinuationSignature?: string;\n\tcreatedAt: number;\n\tupdatedAt: number;\n\tlastStartedAt?: number;\n\tblockedReason?: string;\n\tblockedAt?: number;\n\tcompletedAt?: number;\n};\n\nexport type GoalFile = {\n\tversion: 1;\n\tgoal: Goal | null;\n};\n\nexport type TokenUsageSnapshot = {\n\tinput: number;\n\toutput: number;\n\tcacheRead: number;\n\tcacheWrite: number;\n\ttotalTokens: number;\n};\n\nexport type GoalUpdate = {\n\tobjective?: string;\n\tstatus?: GoalStatus;\n\treason?: string;\n\ttokenBudget?: number | null;\n};\n\nexport type GoalToolSnapshot = {\n\tthreadId: string;\n\tobjective: string;\n\tstatus: GoalStatus;\n\ttokensUsed: number;\n\ttimeUsedSeconds: number;\n\tcreatedAt: number;\n\tupdatedAt: number;\n\tblockedReason?: string;\n\tblockedAt?: number;\n};\n\nexport type GoalToolResponse = {\n\tgoal: GoalToolSnapshot | null;\n};\n\nexport function isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/imagegen/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAoB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/imagegen/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAoB,MAAM,gBAAgB,CAAC;AAYrE,eAAO,MAAM,iBAAiB,6LAK7B,CAAC;AAmBF,wBAAgB,yBAAyB,CAAC,EAAE,EAAE,YAAY,EAAE,OAAO,SAAoB,GAAG,IAAI,CAa7F;AAED,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,CAEhE"}
|
|
@@ -5,6 +5,10 @@ import { resolveImageGenAuth } from "./auth.js";
|
|
|
5
5
|
import { imageGenRegistryOverride } from "./state.js";
|
|
6
6
|
import { generateImageTool } from "./tool.js";
|
|
7
7
|
const IMAGEGEN_BASE_DIR = dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
// Bun compile extracts imported file assets to a real path; Node dist keeps using the copied skill.
|
|
9
|
+
const embeddedSkillPath = process.versions.bun
|
|
10
|
+
? import("./skill/SKILL.md", { with: { type: "file" } }).then((module) => module.default)
|
|
11
|
+
: Promise.resolve(undefined);
|
|
8
12
|
let loggedMissingSkill = false;
|
|
9
13
|
export const IMAGE_GEN_SECTION = `
|
|
10
14
|
## Image Generation
|
|
@@ -16,13 +20,16 @@ async function isImageGenActive(ctx) {
|
|
|
16
20
|
const auth = await resolveImageGenAuth({ modelRegistry: imageGenRegistryOverride() ?? ctx.modelRegistry });
|
|
17
21
|
return auth.kind !== "none";
|
|
18
22
|
}
|
|
19
|
-
function bundledSkillPath(baseDir) {
|
|
23
|
+
async function bundledSkillPath(baseDir) {
|
|
20
24
|
const skillPath = join(baseDir, "skill", "SKILL.md");
|
|
21
25
|
if (existsSync(skillPath))
|
|
22
26
|
return skillPath;
|
|
27
|
+
const embeddedPath = await embeddedSkillPath;
|
|
28
|
+
if (baseDir === IMAGEGEN_BASE_DIR && embeddedPath !== undefined && existsSync(embeddedPath))
|
|
29
|
+
return embeddedPath;
|
|
23
30
|
if (!loggedMissingSkill) {
|
|
24
31
|
loggedMissingSkill = true;
|
|
25
|
-
console.
|
|
32
|
+
console.error(`[imagegen] bundled skill not found at ${skillPath}; skipping contribution`);
|
|
26
33
|
}
|
|
27
34
|
return undefined;
|
|
28
35
|
}
|
|
@@ -31,7 +38,7 @@ export function registerImageGenExtension(pi, baseDir = IMAGEGEN_BASE_DIR) {
|
|
|
31
38
|
pi.on("resources_discover", async (_event, ctx) => {
|
|
32
39
|
if (!(await isImageGenActive(ctx)))
|
|
33
40
|
return undefined;
|
|
34
|
-
const skillPath = bundledSkillPath(baseDir);
|
|
41
|
+
const skillPath = await bundledSkillPath(baseDir);
|
|
35
42
|
return skillPath === undefined ? undefined : { skillPaths: [skillPath] };
|
|
36
43
|
});
|
|
37
44
|
pi.on("before_agent_start", async (event, ctx) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/imagegen/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,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AAM,EAAE,GAAG,EAAE,EAAE;QACjD,IAAI,CAAC,CAAC,MAAM,gBAAgB,CAAC,GAAG,CAAC,CAAC;YAAE,OAAO,SAAS,CAAC;QACrD,MAAM,SAAS,GAAG,MAAM,gBAAgB,CAAC,OAAO,CAAC,CAAC;QAClD,OAAO,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC;IAC1E,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,EAAE,CAAC,oBAAoB,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;QAChD,IAAI,CAAC,CAAC,MAAM,gBAAgB,CAAC,GAAG,CAAC,CAAC;YAAE,OAAO,SAAS,CAAC;QACrD,OAAO,EAAE,YAAY,EAAE,GAAG,KAAK,CAAC,YAAY,KAAK,iBAAiB,EAAE,EAAE,CAAC;IACxE,CAAC,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EAAgB;IACzD,yBAAyB,CAAC,EAAE,CAAC,CAAC;AAC/B,CAAC","sourcesContent":["import { existsSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport type { ExtensionAPI, ExtensionContext } from \"../../types.ts\";\nimport { resolveImageGenAuth } from \"./auth.ts\";\nimport { imageGenRegistryOverride } from \"./state.ts\";\nimport { generateImageTool } from \"./tool.ts\";\n\nconst IMAGEGEN_BASE_DIR = dirname(fileURLToPath(import.meta.url));\n// Bun compile extracts imported file assets to a real path; Node dist keeps using the copied skill.\nconst embeddedSkillPath = process.versions.bun\n\t? import(\"./skill/SKILL.md\", { with: { type: \"file\" } }).then((module) => module.default as string)\n\t: Promise.resolve(undefined);\nlet loggedMissingSkill = false;\n\nexport const IMAGE_GEN_SECTION = `\n## Image Generation\n\nWhen image generation tooling is present, read the gpt-image-gen skill before generating.\nUse the image generation tool currently available in this session.\n`;\n\nasync function isImageGenActive(ctx: ExtensionContext): Promise<boolean> {\n\tconst auth = await resolveImageGenAuth({ modelRegistry: imageGenRegistryOverride() ?? ctx.modelRegistry });\n\treturn auth.kind !== \"none\";\n}\n\nasync function bundledSkillPath(baseDir: string): Promise<string | undefined> {\n\tconst skillPath = join(baseDir, \"skill\", \"SKILL.md\");\n\tif (existsSync(skillPath)) return skillPath;\n\tconst embeddedPath = await embeddedSkillPath;\n\tif (baseDir === IMAGEGEN_BASE_DIR && embeddedPath !== undefined && existsSync(embeddedPath)) return embeddedPath;\n\tif (!loggedMissingSkill) {\n\t\tloggedMissingSkill = true;\n\t\tconsole.error(`[imagegen] bundled skill not found at ${skillPath}; skipping contribution`);\n\t}\n\treturn undefined;\n}\n\nexport function registerImageGenExtension(pi: ExtensionAPI, baseDir = IMAGEGEN_BASE_DIR): void {\n\tpi.registerTool(generateImageTool);\n\n\tpi.on(\"resources_discover\", async (_event, ctx) => {\n\t\tif (!(await isImageGenActive(ctx))) return undefined;\n\t\tconst skillPath = await bundledSkillPath(baseDir);\n\t\treturn skillPath === undefined ? undefined : { skillPaths: [skillPath] };\n\t});\n\n\tpi.on(\"before_agent_start\", async (event, ctx) => {\n\t\tif (!(await isImageGenActive(ctx))) return undefined;\n\t\treturn { systemPrompt: `${event.systemPrompt}\\n${IMAGE_GEN_SECTION}` };\n\t});\n}\n\nexport default function imageGenExtension(pi: ExtensionAPI): void {\n\tregisterImageGenExtension(pi);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/extensions/builtin/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/extensions/builtin/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAWpD,OAAO,aAAa,MAAM,WAAW,CAAC;AACtC,OAAO,cAAc,MAAM,YAAY,CAAC;AAkBxC,OAAO,wBAAwB,MAAM,wBAAwB,CAAC;AAU9D,OAAO,YAAY,MAAM,UAAU,CAAC;AAMpC,MAAM,WAAW,uBAAuB;IACvC,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,gBAAgB,CAAC;CAC1B;AAED,eAAO,MAAM,yBAAyB,wDAAyD,CAAC;AAEhG,eAAO,MAAM,+BAA+B;;;;;CAKoC,CAAC;AAEjF,eAAO,MAAM,iBAAiB,EAAE,uBAAuB,EAqDtD,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import accountExtension from "./account/index.js";
|
|
1
2
|
import anthropicBashExtension from "./anthropic-bash/index.js";
|
|
2
3
|
import anthropicWebSearchExtension from "./anthropic-web-search/index.js";
|
|
3
4
|
import bashTimeoutExtension from "./bash-timeout/index.js";
|
|
@@ -89,6 +90,9 @@ export const builtinExtensions = [
|
|
|
89
90
|
{ id: "cache-keepalive", factory: cacheKeepAliveExtension },
|
|
90
91
|
{ id: "ttsr", factory: ttsrExtension },
|
|
91
92
|
{ id: "btw", factory: btwExtension },
|
|
93
|
+
// Provider-neutral account listing; sits before the provider lanes so their
|
|
94
|
+
// dedicated commands (claude-account, cursor accounts) keep their own names.
|
|
95
|
+
{ id: "account", factory: accountExtension },
|
|
92
96
|
{ id: "claude-sdk-oauth", factory: claudeSdkOauthExtension },
|
|
93
97
|
// Registers unconditionally and reports executable/auth state through its oauth check, so it stays beside the other provider lane.
|
|
94
98
|
{ id: "cursor-cli-oauth", factory: cursorCliOauthExtension },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/extensions/builtin/index.ts"],"names":[],"mappings":"AACA,OAAO,sBAAsB,MAAM,2BAA2B,CAAC;AAC/D,OAAO,2BAA2B,MAAM,iCAAiC,CAAC;AAC1E,OA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E;IAC7C,EAAE,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,eAAe,EAAE;IAC3C,EAAE,EAAE,EAAE,kBAAkB,EAAE,OAAO,EAAE,uBAAuB,EAAE;IAC5D,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE;IAC1C,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE;IACtC,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE;IACtC,EAAE,EAAE,EAAE,iBAAiB,EAAE,OAAO,EAAE,uBAAuB,EAAE;IAC3D,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE;IACtC,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE;IACpC,EAAE,EAAE,EAAE,kBAAkB,EAAE,OAAO,EAAE,uBAAuB,EAAE;IAC5D,mIAAmI;IACnI,EAAE,EAAE,EAAE,kBAAkB,EAAE,OAAO,EAAE,uBAAuB,EAAE;IAC5D,oIAAoI;IACpI,EAAE,EAAE,EAAE,eAAe,EAAE,OAAO,EAAE,qBAAqB,EAAE;IACvD,8GAA8G;IAC9G,EAAE,EAAE,EAAE,aAAa,EAAE,OAAO,EAAE,mBAAmB,EAAE;IACnD,iGAAiG;IACjG,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE;CACpC,CAAC","sourcesContent":["import type { ExtensionFactory } from \"../types.ts\";\nimport anthropicBashExtension from \"./anthropic-bash/index.ts\";\nimport anthropicWebSearchExtension from \"./anthropic-web-search/index.ts\";\nimport bashTimeoutExtension from \"./bash-timeout/index.ts\";\nimport btwExtension from \"./btw/index.ts\";\nimport cacheKeepAliveExtension from \"./cache-keepalive/index.ts\";\nimport claudeSdkOauthExtension from \"./claude-sdk-oauth/index.ts\";\nimport compactionExtension from \"./compaction/index.ts\";\nimport configReloadExtension from \"./config-reload/index.ts\";\nimport cursorCliOauthExtension from \"./cursor-cli-oauth/index.ts\";\nimport diffExtension from \"./diff.ts\";\nimport filesExtension from \"./files.ts\";\nimport goalExtension from \"./goal/index.ts\";\nimport gptApplyPatchExtension from \"./gpt-apply-patch/index.ts\";\nimport helpExtension from \"./help/index.ts\";\nimport historySearchExtension from \"./history-search/index.ts\";\nimport hooksExtension from \"./hooks/index.ts\";\nimport imageGenExtension from \"./imagegen/index.ts\";\nimport importReproExtension from \"./import-repro.ts\";\nimport lookAtExtension from \"./look-at/index.ts\";\nimport loopExtension from \"./loop/index.ts\";\nimport loopGuardExtension from \"./loop-guard/index.ts\";\nimport mcpExtension from \"./mcp/index.ts\";\nimport modelFallbackExtension from \"./model-fallback/index.ts\";\nimport nestedAgentsMdExtension from \"./nested-agents-md/index.ts\";\nimport openaiImageGenExtension from \"./openai-image-gen/index.ts\";\nimport openaiWebSearchExtension from \"./openai-web-search/index.ts\";\nimport permissionSystemExtension from \"./permission-system/index.ts\";\nimport promptPresetExtension from \"./prompt-preset/index.ts\";\nimport promptUrlWidgetExtension from \"./prompt-url-widget.ts\";\nimport reasoningExtension from \"./reasoning/index.ts\";\nimport recommendedModelsExtension from \"./recommended-models/index.ts\";\nimport redrawsExtension from \"./redraws.ts\";\nimport piRulesExtension from \"./rules/index.ts\";\nimport serviceTierExtension from \"./service-tier.ts\";\nimport terminalExtension from \"./terminal/index.ts\";\nimport todowriteExtension from \"./todotools/index.ts\";\nimport toolPairGuardExtension from \"./tool-pair-guard/index.ts\";\nimport toolSearchExtension from \"./tool-search/index.ts\";\nimport tpsExtension from \"./tps.ts\";\nimport ttsrExtension from \"./ttsr/index.ts\";\nimport videoInExtension from \"./video-in/index.ts\";\nimport webfetchExtension from \"./webfetch/index.ts\";\nimport websearchExtension from \"./websearch/index.ts\";\n\nexport interface BuiltinExtensionFactory {\n\tid: string;\n\tfactory: ExtensionFactory;\n}\n\nexport const globalDefaultExtensionIds = [\"diff\", \"files\", \"prompt-url-widget\", \"tps\"] as const;\n\nexport const globalDefaultExtensionFactories = {\n\tdiff: diffExtension,\n\tfiles: filesExtension,\n\t\"prompt-url-widget\": promptUrlWidgetExtension,\n\ttps: tpsExtension,\n} satisfies Record<(typeof globalDefaultExtensionIds)[number], ExtensionFactory>;\n\nexport const builtinExtensions: BuiltinExtensionFactory[] = [\n\t// Loop guard owns the first veto opportunity so repeated calls never re-run hooks or permission prompts.\n\t{ id: \"loop-guard\", factory: loopGuardExtension },\n\t{ id: \"hooks\", factory: hooksExtension },\n\t{ id: \"permission-system\", factory: permissionSystemExtension },\n\t{ id: \"gpt-apply-patch\", factory: gptApplyPatchExtension },\n\t{ id: \"imagegen\", factory: imageGenExtension },\n\t// Follows imagegen so the native injector's bypass wiring observes the registered client tool.\n\t{ id: \"openai-image-gen\", factory: openaiImageGenExtension },\n\t{ id: \"prompt-preset\", factory: promptPresetExtension },\n\t{ id: \"todowrite\", factory: todowriteExtension },\n\t{ id: \"redraws\", factory: redrawsExtension },\n\t{ id: \"anthropic-web-search\", factory: anthropicWebSearchExtension },\n\t{ id: \"anthropic-bash\", factory: anthropicBashExtension },\n\t{ id: \"openai-web-search\", factory: openaiWebSearchExtension },\n\t{ id: \"service-tier\", factory: serviceTierExtension },\n\t// Sits beside service-tier: both are capability-aware model-control commands that only read\n\t// the active model and notify; neither mutates payloads, so relative order is not load-bearing.\n\t{ id: \"reasoning\", factory: reasoningExtension },\n\t{ id: \"model-fallback\", factory: modelFallbackExtension },\n\t{ id: \"recommended-models\", factory: recommendedModelsExtension },\n\t{ id: \"bash-timeout\", factory: bashTimeoutExtension },\n\t// Terminal follows bash-timeout so its injected default reaches the PTY bash, and follows\n\t// anthropic-bash so mutual-exclusion (companion step-aside) is evaluated after it registers.\n\t{ id: \"terminal\", factory: terminalExtension },\n\t{ id: \"tool-pair-guard\", factory: toolPairGuardExtension },\n\t{ id: \"compaction\", factory: compactionExtension },\n\t{ id: \"history-search\", factory: historySearchExtension },\n\t{ id: \"help\", factory: helpExtension },\n\t{ id: \"import-repro\", factory: importReproExtension },\n\t{ id: \"websearch\", factory: websearchExtension },\n\t{ id: \"webfetch\", factory: webfetchExtension },\n\t{ id: \"video-in\", factory: videoInExtension },\n\t{ id: \"look-at\", factory: lookAtExtension },\n\t{ id: \"nested-agents-md\", factory: nestedAgentsMdExtension },\n\t{ id: \"rules\", factory: piRulesExtension },\n\t{ id: \"goal\", factory: goalExtension },\n\t{ id: \"loop\", factory: loopExtension },\n\t{ id: \"cache-keepalive\", factory: cacheKeepAliveExtension },\n\t{ id: \"ttsr\", factory: ttsrExtension },\n\t{ id: \"btw\", factory: btwExtension },\n\t{ id: \"claude-sdk-oauth\", factory: claudeSdkOauthExtension },\n\t// Registers unconditionally and reports executable/auth state through its oauth check, so it stays beside the other provider lane.\n\t{ id: \"cursor-cli-oauth\", factory: cursorCliOauthExtension },\n\t// Config reload follows settings-dependent builtins so reloads rebuild their resolved settings before catalog feeders observe them.\n\t{ id: \"config-reload\", factory: configReloadExtension },\n\t// Shared catalog wiring loads before MCP, which feeds its tools into the shared catalog as the final builtin.\n\t{ id: \"tool-search\", factory: toolSearchExtension },\n\t// Keep MCP last so its eventual provider-payload tap observes all co-resident builtin mutations.\n\t{ id: \"mcp\", factory: mcpExtension },\n];\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/extensions/builtin/index.ts"],"names":[],"mappings":"AACA,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAClD,OAAO,sBAAsB,MAAM,2BAA2B,CAAC;AAC/D,OAAO,2BAA2B,MAAM,iCAAiC,CAAC;AAC1E,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAC3D,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,uBAAuB,MAAM,4BAA4B,CAAC;AACjE,OAAO,uBAAuB,MAAM,6BAA6B,CAAC;AAClE,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AACxD,OAAO,qBAAqB,MAAM,0BAA0B,CAAC;AAC7D,OAAO,uB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E;IACtC,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE;IACtC,EAAE,EAAE,EAAE,iBAAiB,EAAE,OAAO,EAAE,uBAAuB,EAAE;IAC3D,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE;IACtC,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE;IACpC,4EAA4E;IAC5E,6EAA6E;IAC7E,EAAE,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,gBAAgB,EAAE;IAC5C,EAAE,EAAE,EAAE,kBAAkB,EAAE,OAAO,EAAE,uBAAuB,EAAE;IAC5D,mIAAmI;IACnI,EAAE,EAAE,EAAE,kBAAkB,EAAE,OAAO,EAAE,uBAAuB,EAAE;IAC5D,oIAAoI;IACpI,EAAE,EAAE,EAAE,eAAe,EAAE,OAAO,EAAE,qBAAqB,EAAE;IACvD,8GAA8G;IAC9G,EAAE,EAAE,EAAE,aAAa,EAAE,OAAO,EAAE,mBAAmB,EAAE;IACnD,iGAAiG;IACjG,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE;CACpC,CAAC","sourcesContent":["import type { ExtensionFactory } from \"../types.ts\";\nimport accountExtension from \"./account/index.ts\";\nimport anthropicBashExtension from \"./anthropic-bash/index.ts\";\nimport anthropicWebSearchExtension from \"./anthropic-web-search/index.ts\";\nimport bashTimeoutExtension from \"./bash-timeout/index.ts\";\nimport btwExtension from \"./btw/index.ts\";\nimport cacheKeepAliveExtension from \"./cache-keepalive/index.ts\";\nimport claudeSdkOauthExtension from \"./claude-sdk-oauth/index.ts\";\nimport compactionExtension from \"./compaction/index.ts\";\nimport configReloadExtension from \"./config-reload/index.ts\";\nimport cursorCliOauthExtension from \"./cursor-cli-oauth/index.ts\";\nimport diffExtension from \"./diff.ts\";\nimport filesExtension from \"./files.ts\";\nimport goalExtension from \"./goal/index.ts\";\nimport gptApplyPatchExtension from \"./gpt-apply-patch/index.ts\";\nimport helpExtension from \"./help/index.ts\";\nimport historySearchExtension from \"./history-search/index.ts\";\nimport hooksExtension from \"./hooks/index.ts\";\nimport imageGenExtension from \"./imagegen/index.ts\";\nimport importReproExtension from \"./import-repro.ts\";\nimport lookAtExtension from \"./look-at/index.ts\";\nimport loopExtension from \"./loop/index.ts\";\nimport loopGuardExtension from \"./loop-guard/index.ts\";\nimport mcpExtension from \"./mcp/index.ts\";\nimport modelFallbackExtension from \"./model-fallback/index.ts\";\nimport nestedAgentsMdExtension from \"./nested-agents-md/index.ts\";\nimport openaiImageGenExtension from \"./openai-image-gen/index.ts\";\nimport openaiWebSearchExtension from \"./openai-web-search/index.ts\";\nimport permissionSystemExtension from \"./permission-system/index.ts\";\nimport promptPresetExtension from \"./prompt-preset/index.ts\";\nimport promptUrlWidgetExtension from \"./prompt-url-widget.ts\";\nimport reasoningExtension from \"./reasoning/index.ts\";\nimport recommendedModelsExtension from \"./recommended-models/index.ts\";\nimport redrawsExtension from \"./redraws.ts\";\nimport piRulesExtension from \"./rules/index.ts\";\nimport serviceTierExtension from \"./service-tier.ts\";\nimport terminalExtension from \"./terminal/index.ts\";\nimport todowriteExtension from \"./todotools/index.ts\";\nimport toolPairGuardExtension from \"./tool-pair-guard/index.ts\";\nimport toolSearchExtension from \"./tool-search/index.ts\";\nimport tpsExtension from \"./tps.ts\";\nimport ttsrExtension from \"./ttsr/index.ts\";\nimport videoInExtension from \"./video-in/index.ts\";\nimport webfetchExtension from \"./webfetch/index.ts\";\nimport websearchExtension from \"./websearch/index.ts\";\n\nexport interface BuiltinExtensionFactory {\n\tid: string;\n\tfactory: ExtensionFactory;\n}\n\nexport const globalDefaultExtensionIds = [\"diff\", \"files\", \"prompt-url-widget\", \"tps\"] as const;\n\nexport const globalDefaultExtensionFactories = {\n\tdiff: diffExtension,\n\tfiles: filesExtension,\n\t\"prompt-url-widget\": promptUrlWidgetExtension,\n\ttps: tpsExtension,\n} satisfies Record<(typeof globalDefaultExtensionIds)[number], ExtensionFactory>;\n\nexport const builtinExtensions: BuiltinExtensionFactory[] = [\n\t// Loop guard owns the first veto opportunity so repeated calls never re-run hooks or permission prompts.\n\t{ id: \"loop-guard\", factory: loopGuardExtension },\n\t{ id: \"hooks\", factory: hooksExtension },\n\t{ id: \"permission-system\", factory: permissionSystemExtension },\n\t{ id: \"gpt-apply-patch\", factory: gptApplyPatchExtension },\n\t{ id: \"imagegen\", factory: imageGenExtension },\n\t// Follows imagegen so the native injector's bypass wiring observes the registered client tool.\n\t{ id: \"openai-image-gen\", factory: openaiImageGenExtension },\n\t{ id: \"prompt-preset\", factory: promptPresetExtension },\n\t{ id: \"todowrite\", factory: todowriteExtension },\n\t{ id: \"redraws\", factory: redrawsExtension },\n\t{ id: \"anthropic-web-search\", factory: anthropicWebSearchExtension },\n\t{ id: \"anthropic-bash\", factory: anthropicBashExtension },\n\t{ id: \"openai-web-search\", factory: openaiWebSearchExtension },\n\t{ id: \"service-tier\", factory: serviceTierExtension },\n\t// Sits beside service-tier: both are capability-aware model-control commands that only read\n\t// the active model and notify; neither mutates payloads, so relative order is not load-bearing.\n\t{ id: \"reasoning\", factory: reasoningExtension },\n\t{ id: \"model-fallback\", factory: modelFallbackExtension },\n\t{ id: \"recommended-models\", factory: recommendedModelsExtension },\n\t{ id: \"bash-timeout\", factory: bashTimeoutExtension },\n\t// Terminal follows bash-timeout so its injected default reaches the PTY bash, and follows\n\t// anthropic-bash so mutual-exclusion (companion step-aside) is evaluated after it registers.\n\t{ id: \"terminal\", factory: terminalExtension },\n\t{ id: \"tool-pair-guard\", factory: toolPairGuardExtension },\n\t{ id: \"compaction\", factory: compactionExtension },\n\t{ id: \"history-search\", factory: historySearchExtension },\n\t{ id: \"help\", factory: helpExtension },\n\t{ id: \"import-repro\", factory: importReproExtension },\n\t{ id: \"websearch\", factory: websearchExtension },\n\t{ id: \"webfetch\", factory: webfetchExtension },\n\t{ id: \"video-in\", factory: videoInExtension },\n\t{ id: \"look-at\", factory: lookAtExtension },\n\t{ id: \"nested-agents-md\", factory: nestedAgentsMdExtension },\n\t{ id: \"rules\", factory: piRulesExtension },\n\t{ id: \"goal\", factory: goalExtension },\n\t{ id: \"loop\", factory: loopExtension },\n\t{ id: \"cache-keepalive\", factory: cacheKeepAliveExtension },\n\t{ id: \"ttsr\", factory: ttsrExtension },\n\t{ id: \"btw\", factory: btwExtension },\n\t// Provider-neutral account listing; sits before the provider lanes so their\n\t// dedicated commands (claude-account, cursor accounts) keep their own names.\n\t{ id: \"account\", factory: accountExtension },\n\t{ id: \"claude-sdk-oauth\", factory: claudeSdkOauthExtension },\n\t// Registers unconditionally and reports executable/auth state through its oauth check, so it stays beside the other provider lane.\n\t{ id: \"cursor-cli-oauth\", factory: cursorCliOauthExtension },\n\t// Config reload follows settings-dependent builtins so reloads rebuild their resolved settings before catalog feeders observe them.\n\t{ id: \"config-reload\", factory: configReloadExtension },\n\t// Shared catalog wiring loads before MCP, which feeds its tools into the shared catalog as the final builtin.\n\t{ id: \"tool-search\", factory: toolSearchExtension },\n\t// Keep MCP last so its eventual provider-payload tap observes all co-resident builtin mutations.\n\t{ id: \"mcp\", factory: mcpExtension },\n];\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,gBA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EAAE,MAAM,eAAe,CAAC;AAC5F,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EACN,WAAW,EACX,UAAU,EACV,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,SAAS,EACT,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,wBAAwB,EACxB,gCAAgC,EAChC,+BAA+B,EAC/B,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,UAAU,EACV,gBAAgB,EAChB,oBAAoB,EACpB,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
|