mixdog 0.9.172 → 0.9.173
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/package.json +3 -3
- package/scripts/code-graph-description-contract.mjs +1 -2
- package/scripts/context-renewal-live-check.mjs +1 -1
- package/scripts/coverage-query.mjs +27 -0
- package/scripts/generate-runtime-manifest.mjs +12 -16
- package/scripts/graph-parity.mjs +108 -75
- package/scripts/lib/coverage.mjs +309 -0
- package/scripts/lib/embedding-model-bench-core.mjs +4 -2
- package/scripts/lib/recall-bench-eval.mjs +4 -4
- package/scripts/lib/run-node-tests.mjs +137 -13
- package/scripts/lib/test-failure-records.mjs +46 -0
- package/scripts/lib/test-failure-summary.mjs +59 -0
- package/scripts/lib/test-summary-reporter.mjs +7 -3
- package/scripts/mouse-probe.mjs +1 -3
- package/scripts/office/build-pptx-icons.mjs +0 -1
- package/scripts/perf/transcript-runtime-probe.mjs +20 -4
- package/scripts/pg-memory-diet.mjs +2 -4
- package/scripts/routing-corpus.mjs +0 -2
- package/scripts/session-diag.mjs +0 -7
- package/scripts/session-sweep.mjs +102 -56
- package/scripts/test.mjs +113 -37
- package/scripts/tui-frame-harness.mjs +1 -1
- package/src/app.mjs +79 -74
- package/src/cli.mjs +0 -2
- package/src/defaults/skills/browser-use/SKILL.md +8 -6
- package/src/defaults/skills/code-tidy/SKILL.md +67 -17
- package/src/defaults/skills/code-tidy/references/agent-cleanup.md +26 -3
- package/src/defaults/skills/computer-use/SKILL.md +12 -5
- package/src/defaults/skills/goal-management/SKILL.md +16 -9
- package/src/defaults/skills/pdf/SKILL.md +2 -1
- package/src/defaults/skills/xlsx/SKILL.md +3 -3
- package/src/headless-exec.mjs +1 -2
- package/src/help.mjs +2 -2
- package/src/lib/rules-builder.cjs +0 -23
- package/src/repl/slash-commands.mjs +1 -5
- package/src/runtime/agent/orchestrator/agent-runtime/agent-dispatch/turn.mjs +4 -4
- package/src/runtime/agent/orchestrator/agent-runtime/cache-strategy.mjs +25 -41
- package/src/runtime/agent/orchestrator/agent-trace-format.mjs +25 -24
- package/src/runtime/agent/orchestrator/agent-trace-io.mjs +15 -22
- package/src/runtime/agent/orchestrator/agent-trace.mjs +0 -22
- package/src/runtime/agent/orchestrator/config-providers-merge.mjs +56 -0
- package/src/runtime/agent/orchestrator/config.mjs +34 -76
- package/src/runtime/agent/orchestrator/context/role-instructions.mjs +1 -1
- package/src/runtime/agent/orchestrator/providers/admission-scheduler.mjs +40 -39
- package/src/runtime/agent/orchestrator/providers/anthropic-api-recovery.mjs +75 -0
- package/src/runtime/agent/orchestrator/providers/anthropic-api-request.mjs +152 -0
- package/src/runtime/agent/orchestrator/providers/anthropic-api-transport.mjs +168 -0
- package/src/runtime/agent/orchestrator/providers/anthropic-messages.mjs +2 -1
- package/src/runtime/agent/orchestrator/providers/anthropic-midstream-recovery.mjs +248 -0
- package/src/runtime/agent/orchestrator/providers/anthropic-oauth-midstream.mjs +16 -206
- package/src/runtime/agent/orchestrator/providers/anthropic-oauth-recovery.mjs +11 -63
- package/src/runtime/agent/orchestrator/providers/anthropic-recovery-guards.mjs +86 -0
- package/src/runtime/agent/orchestrator/providers/anthropic-turn-result.mjs +88 -0
- package/src/runtime/agent/orchestrator/providers/anthropic.mjs +87 -591
- package/src/runtime/agent/orchestrator/providers/antigravity-oauth.mjs +32 -288
- package/src/runtime/agent/orchestrator/providers/antigravity-response.mjs +101 -0
- package/src/runtime/agent/orchestrator/providers/antigravity-stream.mjs +161 -0
- package/src/runtime/agent/orchestrator/providers/antigravity-transport.mjs +114 -0
- package/src/runtime/agent/orchestrator/providers/gemini-cache-policy.mjs +266 -0
- package/src/runtime/agent/orchestrator/providers/gemini-request-body.mjs +54 -0
- package/src/runtime/agent/orchestrator/providers/gemini-response.mjs +145 -0
- package/src/runtime/agent/orchestrator/providers/gemini-schema.mjs +56 -39
- package/src/runtime/agent/orchestrator/providers/gemini-sdk-request.mjs +107 -0
- package/src/runtime/agent/orchestrator/providers/gemini.mjs +23 -533
- package/src/runtime/agent/orchestrator/providers/lib/anthropic-request-utils.mjs +10 -4
- package/src/runtime/agent/orchestrator/providers/media-normalization.mjs +83 -32
- package/src/runtime/agent/orchestrator/providers/openai-compat-responses.mjs +41 -25
- package/src/runtime/agent/orchestrator/providers/openai-http-sse-response-state/response-outcome.mjs +4 -98
- package/src/runtime/agent/orchestrator/providers/openai-http-sse-response-state/response-stamps.mjs +114 -0
- package/src/runtime/agent/orchestrator/providers/openai-oauth-dispatch.mjs +258 -0
- package/src/runtime/agent/orchestrator/providers/openai-oauth.mjs +48 -214
- package/src/runtime/agent/orchestrator/providers/openai-responses-input.mjs +80 -60
- package/src/runtime/agent/orchestrator/providers/openai-ws-handshake.mjs +108 -0
- package/src/runtime/agent/orchestrator/providers/openai-ws-pool.mjs +8 -87
- package/src/runtime/agent/orchestrator/providers/openai-ws-send-outcome.mjs +52 -293
- package/src/runtime/agent/orchestrator/providers/openai-ws-send-trace.mjs +316 -0
- package/src/runtime/agent/orchestrator/providers/opencode-go-usage.mjs +76 -253
- package/src/runtime/agent/orchestrator/session/cache/scoped-cache.mjs +1 -7
- package/src/runtime/agent/orchestrator/session/compact/budget.mjs +17 -16
- package/src/runtime/agent/orchestrator/session/compact/runner.mjs +6 -4
- package/src/runtime/agent/orchestrator/session/compact/summary-schema.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/context-compaction-policy.mjs +9 -13
- package/src/runtime/agent/orchestrator/session/context-utils.mjs +1 -2
- package/src/runtime/agent/orchestrator/session/evidence-union.mjs +6 -9
- package/src/runtime/agent/orchestrator/session/loop/compact-policy.mjs +2 -3
- package/src/runtime/agent/orchestrator/session/loop/diagnostics.mjs +1 -8
- package/src/runtime/agent/orchestrator/session/loop/tool-classify.mjs +1 -3
- package/src/runtime/agent/orchestrator/session/loop/tool-exec/call-prep.mjs +1 -5
- package/src/runtime/agent/orchestrator/session/manager/ask-turn-execute.mjs +0 -1
- package/src/runtime/agent/orchestrator/session/manager/ask-turn-loop-options.mjs +4 -55
- package/src/runtime/agent/orchestrator/session/manager/ask-turn-steering-drain.mjs +63 -0
- package/src/runtime/agent/orchestrator/session/manager/compaction-runner.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/manager/foreign-pending-messages.mjs +80 -65
- package/src/runtime/agent/orchestrator/session/manager/pending-claim-ledger.mjs +68 -0
- package/src/runtime/agent/orchestrator/session/manager/pending-delivered-ledger.mjs +56 -0
- package/src/runtime/agent/orchestrator/session/manager/pending-lifecycle-epoch.mjs +84 -0
- package/src/runtime/agent/orchestrator/session/manager/pending-messages.mjs +51 -651
- package/src/runtime/agent/orchestrator/session/manager/pending-persist-queue.mjs +264 -0
- package/src/runtime/agent/orchestrator/session/manager/pending-spool-file.mjs +131 -0
- package/src/runtime/agent/orchestrator/session/manager/pending-spool-sweep.mjs +73 -0
- package/src/runtime/agent/orchestrator/session/manager/prepared-resume-cache.mjs +122 -0
- package/src/runtime/agent/orchestrator/session/manager/prompt-utils.mjs +2 -1
- package/src/runtime/agent/orchestrator/session/manager/runtime-liveness.mjs +5 -4
- package/src/runtime/agent/orchestrator/session/manager/session-close.mjs +60 -35
- package/src/runtime/agent/orchestrator/session/manager/session-crud.mjs +3 -2
- package/src/runtime/agent/orchestrator/session/manager/session-lifecycle.mjs +22 -646
- package/src/runtime/agent/orchestrator/session/manager/session-owner-liveness.mjs +135 -0
- package/src/runtime/agent/orchestrator/session/manager/session-prompt-composition.mjs +150 -0
- package/src/runtime/agent/orchestrator/session/manager/session-record.mjs +154 -0
- package/src/runtime/agent/orchestrator/session/manager/session-tool-surface.mjs +135 -0
- package/src/runtime/agent/orchestrator/session/manager/tool-resolution.mjs +4 -11
- package/src/runtime/agent/orchestrator/session/manager/turn-checkpoint-journal.mjs +0 -6
- package/src/runtime/agent/orchestrator/session/manager/usage-metrics.mjs +1 -3
- package/src/runtime/agent/orchestrator/session/pre-send-compact.mjs +11 -12
- package/src/runtime/agent/orchestrator/session/provider-prefix-guard.mjs +23 -32
- package/src/runtime/agent/orchestrator/session/store/lifecycle-barriers.mjs +275 -0
- package/src/runtime/agent/orchestrator/session/store/lifecycle-read.mjs +67 -0
- package/src/runtime/agent/orchestrator/session/store/listing.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/store/live-cache-eviction.mjs +72 -0
- package/src/runtime/agent/orchestrator/session/store/liveness-veto.mjs +53 -0
- package/src/runtime/agent/orchestrator/session/store/load-session.mjs +60 -0
- package/src/runtime/agent/orchestrator/session/store/pending-saves.mjs +55 -0
- package/src/runtime/agent/orchestrator/session/store/serialize.mjs +7 -15
- package/src/runtime/agent/orchestrator/session/store/session-delete.mjs +149 -0
- package/src/runtime/agent/orchestrator/session/store/session-observers.mjs +55 -0
- package/src/runtime/agent/orchestrator/session/store/write-admission.mjs +108 -0
- package/src/runtime/agent/orchestrator/session/store-agent-worker-rows.mjs +531 -0
- package/src/runtime/agent/orchestrator/session/store-summary-archived-agent.mjs +126 -0
- package/src/runtime/agent/orchestrator/session/store-summary-fields.mjs +24 -0
- package/src/runtime/agent/orchestrator/session/store-summary-index.mjs +2 -10
- package/src/runtime/agent/orchestrator/session/store-summary-locations.mjs +46 -0
- package/src/runtime/agent/orchestrator/session/store-summary-reader.mjs +11 -791
- package/src/runtime/agent/orchestrator/session/store-transcript-projection.mjs +126 -0
- package/src/runtime/agent/orchestrator/session/store.mjs +33 -771
- package/src/runtime/agent/orchestrator/session/tool-batch/finalize.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/tool-result-offload.mjs +13 -7
- package/src/runtime/agent/orchestrator/stable-hash-stringify.mjs +10 -0
- package/src/runtime/agent/orchestrator/tools/builtin/arg-guard.mjs +50 -75
- package/src/runtime/agent/orchestrator/tools/builtin/builtin-tools.mjs +2 -1
- package/src/runtime/agent/orchestrator/tools/builtin/cache-layers.mjs +22 -21
- package/src/runtime/agent/orchestrator/tools/builtin/external-tool-adapters.mjs +0 -2
- package/src/runtime/agent/orchestrator/tools/builtin/git-command-policy.mjs +44 -27
- package/src/runtime/agent/orchestrator/tools/builtin/git-command-tool.mjs +36 -54
- package/src/runtime/agent/orchestrator/tools/builtin/git-partial-stage.mjs +8 -5
- package/src/runtime/agent/orchestrator/tools/builtin/lib/grep-context-expander.mjs +8 -5
- package/src/runtime/agent/orchestrator/tools/builtin/lib/grep-output.mjs +18 -9
- package/src/runtime/agent/orchestrator/tools/builtin/lib/grep-request.mjs +2 -3
- package/src/runtime/agent/orchestrator/tools/builtin/lib/grep-single-file-rescue.mjs +80 -67
- package/src/runtime/agent/orchestrator/tools/builtin/lib/shell-task-output.mjs +12 -4
- package/src/runtime/agent/orchestrator/tools/builtin/native-search-client.mjs +1 -4
- package/src/runtime/agent/orchestrator/tools/builtin/path-diagnostics.mjs +61 -72
- package/src/runtime/agent/orchestrator/tools/builtin/read-formatting.mjs +0 -5
- package/src/runtime/agent/orchestrator/tools/builtin/read-office-files.mjs +3 -3
- package/src/runtime/agent/orchestrator/tools/builtin/read-range-index.mjs +11 -14
- package/src/runtime/agent/orchestrator/tools/builtin/read-single-render.mjs +3 -6
- package/src/runtime/agent/orchestrator/tools/builtin/read-special-files.mjs +1 -2
- package/src/runtime/agent/orchestrator/tools/builtin/read-streaming.mjs +124 -94
- package/src/runtime/agent/orchestrator/tools/builtin/read-tool/batch-dispatch.mjs +6 -3
- package/src/runtime/agent/orchestrator/tools/builtin/read-tool/reach-preflight.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/builtin/read-tool.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/builtin/read-windows.mjs +2 -2
- package/src/runtime/agent/orchestrator/tools/builtin/search-builders.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/builtin/search-glob-tool.mjs +6 -6
- package/src/runtime/agent/orchestrator/tools/builtin/search-grep-tool.mjs +2 -2
- package/src/runtime/agent/orchestrator/tools/builtin/shell-analysis.mjs +21 -35
- package/src/runtime/agent/orchestrator/tools/builtin/shell-jobs.mjs +0 -3
- package/src/runtime/agent/orchestrator/tools/builtin/shell-lossless-compact.mjs +1 -3
- package/src/runtime/agent/orchestrator/tools/builtin/shell-output.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/builtin/shell-runtime.mjs +0 -2
- package/src/runtime/agent/orchestrator/tools/builtin/task-tool.mjs +4 -3
- package/src/runtime/agent/orchestrator/tools/builtin/text-stats.mjs +6 -3
- package/src/runtime/agent/orchestrator/tools/builtin.mjs +0 -4
- package/src/runtime/agent/orchestrator/tools/code-graph/aggregate-roots.mjs +7 -7
- package/src/runtime/agent/orchestrator/tools/code-graph/ast-calls.mjs +0 -3
- package/src/runtime/agent/orchestrator/tools/code-graph/build-file-infos.mjs +182 -0
- package/src/runtime/agent/orchestrator/tools/code-graph/build.mjs +14 -159
- package/src/runtime/agent/orchestrator/tools/code-graph/constants.mjs +2 -3
- package/src/runtime/agent/orchestrator/tools/code-graph/dispatch.mjs +21 -8
- package/src/runtime/agent/orchestrator/tools/code-graph/graph-binary.mjs +0 -3
- package/src/runtime/agent/orchestrator/tools/code-graph/search-references.mjs +5 -3
- package/src/runtime/agent/orchestrator/tools/code-graph/search.mjs +2 -3
- package/src/runtime/agent/orchestrator/tools/code-graph/symbol-index.mjs +1 -2
- package/src/runtime/agent/orchestrator/tools/code-graph/text-mask.golden.json +1 -1
- package/src/runtime/agent/orchestrator/tools/code-graph/text-mask.mjs +0 -1
- package/src/runtime/agent/orchestrator/tools/graph-manifest.json +11 -11
- package/src/runtime/agent/orchestrator/tools/lib/shell-run-state.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/lib/shell-warm-standby.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/patch/dispatch.mjs +3 -6
- package/src/runtime/agent/orchestrator/tools/patch/mutation-output.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/patch/native-server.mjs +25 -39
- package/src/runtime/agent/orchestrator/tools/patch/parsing.mjs +9 -14
- package/src/runtime/agent/orchestrator/tools/patch/paths.mjs +11 -6
- package/src/runtime/agent/orchestrator/tools/patch/replay-capture.mjs +5 -6
- package/src/runtime/agent/orchestrator/tools/patch/text-lines.mjs +4 -4
- package/src/runtime/agent/orchestrator/tools/patch/v4a-anchors.mjs +10 -7
- package/src/runtime/agent/orchestrator/tools/patch/v4a-convert.mjs +20 -30
- package/src/runtime/agent/orchestrator/tools/patch/v4a-windows.mjs +4 -19
- package/src/runtime/agent/orchestrator/tools/patch/wave.mjs +13 -2
- package/src/runtime/agent/orchestrator/tools/patch.mjs +0 -19
- package/src/runtime/agent/orchestrator/tools/shell-command.mjs +60 -36
- package/src/runtime/agent/orchestrator/tools/shell-exec-output.mjs +0 -4
- package/src/runtime/agent/orchestrator/tools/shell-policy.mjs +6 -7
- package/src/runtime/attachments/store.mjs +13 -12
- package/src/runtime/browser-bridge/client.mjs +19 -9
- package/src/runtime/channels/index.mjs +1 -1
- package/src/runtime/channels/lib/event-pipeline.mjs +8 -8
- package/src/runtime/channels/lib/event-queue.mjs +15 -20
- package/src/runtime/channels/lib/executor.mjs +10 -7
- package/src/runtime/channels/lib/owner-heartbeat.mjs +0 -4
- package/src/runtime/channels/lib/runtime-paths.mjs +30 -33
- package/src/runtime/channels/lib/scheduler.mjs +11 -20
- package/src/runtime/channels/lib/voice-runtime-fetcher.mjs +0 -4
- package/src/runtime/channels/lib/voice-transcription.mjs +127 -104
- package/src/runtime/channels/lib/webhook/verification.mjs +33 -20
- package/src/runtime/channels/lib/worker-bootstrap.mjs +0 -2
- package/src/runtime/channels/lib/worker-main.mjs +2 -2
- package/src/runtime/computer-bridge/action-schema.mjs +20 -0
- package/src/runtime/computer-bridge/core-actions.mjs +15 -0
- package/src/runtime/github/client.mjs +2 -3
- package/src/runtime/github/commands.mjs +9 -3
- package/src/runtime/github/contract.mjs +7 -0
- package/src/runtime/local-provider/catalog.mjs +4 -3
- package/src/runtime/local-provider/hardware.mjs +7 -20
- package/src/runtime/local-provider/resumable-installations.mjs +12 -19
- package/src/runtime/media/auth.mjs +16 -13
- package/src/runtime/media/catalog.mjs +14 -6
- package/src/runtime/media/lanes.mjs +2 -1
- package/src/runtime/memory/index.mjs +5 -10
- package/src/runtime/memory/lib/core-memory-store.mjs +3 -7
- package/src/runtime/memory/lib/embedding-provider.mjs +9 -19
- package/src/runtime/memory/lib/embedding-worker.mjs +24 -28
- package/src/runtime/memory/lib/http-router/admin-routes.mjs +5 -51
- package/src/runtime/memory/lib/http-router/admin-trace-routes.mjs +65 -0
- package/src/runtime/memory/lib/memory-action-handlers/cycle-actions.mjs +18 -143
- package/src/runtime/memory/lib/memory-action-handlers/cycle-backfill-action.mjs +84 -0
- package/src/runtime/memory/lib/memory-action-handlers/cycle-rebuild-action.mjs +94 -0
- package/src/runtime/memory/lib/memory-action-handlers/manage-actions.mjs +92 -53
- package/src/runtime/memory/lib/memory-categories.mjs +13 -0
- package/src/runtime/memory/lib/memory-chunk-quality.mjs +134 -74
- package/src/runtime/memory/lib/memory-cycle-requests.mjs +64 -70
- package/src/runtime/memory/lib/memory-cycle1.mjs +17 -33
- package/src/runtime/memory/lib/memory-embed.mjs +10 -2
- package/src/runtime/memory/lib/memory-ops-policy.mjs +3 -2
- package/src/runtime/memory/lib/memory-recall-scope-filter.mjs +1 -1
- package/src/runtime/memory/lib/memory.mjs +7 -35
- package/src/runtime/memory/lib/pg/adapter.mjs +3 -4
- package/src/runtime/memory/lib/pg/process.mjs +23 -28
- package/src/runtime/memory/lib/pg/supervisor.mjs +10 -11
- package/src/runtime/memory/lib/query-hybrid-search.mjs +2 -2
- package/src/runtime/memory/lib/query-maintenance-handlers.mjs +112 -89
- package/src/runtime/memory/lib/query-ranking.mjs +8 -11
- package/src/runtime/memory/lib/recall-format.mjs +6 -12
- package/src/runtime/memory/lib/recall-hybrid/plan.mjs +1 -1
- package/src/runtime/memory/lib/runtime-fetcher.mjs +73 -65
- package/src/runtime/memory/lib/trace-store.mjs +10 -19
- package/src/runtime/memory/lib/transcript-ingest.mjs +7 -4
- package/src/runtime/memory/tool-defs.mjs +5 -8
- package/src/runtime/office/authoring/pptx-author-action.mjs +2 -2
- package/src/runtime/office/authoring/pptx-author-session.mjs +6 -9
- package/src/runtime/office/authoring/pptx-brief.mjs +11 -4
- package/src/runtime/office/authoring/pptx-receipt.mjs +79 -60
- package/src/runtime/office/bench/benchmark.mjs +102 -82
- package/src/runtime/office/capabilities-catalog.mjs +2 -0
- package/src/runtime/office/capabilities-signatures.mjs +8 -0
- package/src/runtime/office/capabilities.mjs +3 -4
- package/src/runtime/office/com/com-adapter.mjs +13 -1
- package/src/runtime/office/com/office-com-host.ps1 +63 -1
- package/src/runtime/office/core/office-actions-batch.mjs +12 -12
- package/src/runtime/office/core/office-actions-open.mjs +2 -7
- package/src/runtime/office/core/office-core.mjs +20 -1
- package/src/runtime/office/core/office-finalize/session-save.mjs +9 -6
- package/src/runtime/office/core/office-session-dispatch.mjs +86 -0
- package/src/runtime/office/core/office-sessionless-actions.mjs +115 -0
- package/src/runtime/office/core/office-sessions.mjs +2 -2
- package/src/runtime/office/core/office-transactions.mjs +2 -4
- package/src/runtime/office/core/tabular.mjs +13 -16
- package/src/runtime/office/design/composition-system.mjs +32 -28
- package/src/runtime/office/design/content-model.mjs +2 -1
- package/src/runtime/office/design/design-art-direction.mjs +17 -14
- package/src/runtime/office/design/design-creative-director.mjs +1 -1
- package/src/runtime/office/design/design-discipline.mjs +8 -0
- package/src/runtime/office/design/design-tokens.mjs +9 -5
- package/src/runtime/office/design/docx/design-docx-components.mjs +88 -156
- package/src/runtime/office/design/library/design-library-pack.mjs +11 -23
- package/src/runtime/office/design/library/design-library.mjs +15 -37
- package/src/runtime/office/design/library/design-template-index.mjs +1 -9
- package/src/runtime/office/design/library/design-template-induct.mjs +2 -1
- package/src/runtime/office/design/native-design.mjs +2 -3
- package/src/runtime/office/index.mjs +7 -160
- package/src/runtime/office/pdf/pdf-adapter.mjs +17 -2
- package/src/runtime/office/pdf/pdf-ocr.mjs +2 -1
- package/src/runtime/office/pdf/pdf-render.mjs +12 -13
- package/src/runtime/office/pdf/pdf-writer.mjs +135 -6
- package/src/runtime/office/portable/docx-revisions.mjs +5 -5
- package/src/runtime/office/portable/docx-runs.mjs +4 -7
- package/src/runtime/office/portable/docx-tracked-edits.mjs +14 -9
- package/src/runtime/office/portable/font-provisioner.mjs +2 -2
- package/src/runtime/office/portable/ooxml-validator.mjs +4 -1
- package/src/runtime/office/portable/portable-docx-edits.mjs +61 -45
- package/src/runtime/office/portable/portable-docx-operations.mjs +13 -4
- package/src/runtime/office/portable/portable-docx-parts.mjs +59 -70
- package/src/runtime/office/portable/portable-docx-xml.mjs +3 -5
- package/src/runtime/office/portable/portable-opc.mjs +63 -39
- package/src/runtime/office/portable/portable-package.mjs +5 -23
- package/src/runtime/office/portable/portable-pptx-chart.mjs +7 -6
- package/src/runtime/office/portable/portable-pptx-charts.mjs +27 -20
- package/src/runtime/office/portable/portable-pptx-core.mjs +10 -21
- package/src/runtime/office/portable/portable-pptx-deck.mjs +5 -8
- package/src/runtime/office/portable/portable-pptx-package.mjs +23 -30
- package/src/runtime/office/portable/portable-pptx-shapes.mjs +21 -57
- package/src/runtime/office/portable/portable-sheet-audits.mjs +14 -36
- package/src/runtime/office/portable/portable-sheet-page.mjs +22 -23
- package/src/runtime/office/portable/portable-sheet-parts.mjs +4 -5
- package/src/runtime/office/portable/portable-sheet-styles.mjs +11 -19
- package/src/runtime/office/portable/portable-sheet-xml.mjs +15 -7
- package/src/runtime/office/portable/portable-slide-shapes.mjs +4 -0
- package/src/runtime/office/portable/portable-snapshot-pptx.mjs +2 -2
- package/src/runtime/office/portable/portable-snapshot-shared.mjs +1 -1
- package/src/runtime/office/portable/portable-snapshot-xlsx.mjs +16 -17
- package/src/runtime/office/portable/portable-soffice.mjs +176 -13
- package/src/runtime/office/portable/portable-validation-package.mjs +16 -18
- package/src/runtime/office/portable/portable-validation.mjs +57 -31
- package/src/runtime/office/portable/portable-xlsx-cell-values.mjs +15 -0
- package/src/runtime/office/portable/portable-xlsx-charts.mjs +192 -0
- package/src/runtime/office/portable/portable-xlsx-drawings.mjs +323 -0
- package/src/runtime/office/portable/portable-xlsx-operations.mjs +29 -627
- package/src/runtime/office/portable/portable-xlsx-pivot-ops.mjs +94 -0
- package/src/runtime/office/portable/portable-xlsx-range-layout.mjs +236 -0
- package/src/runtime/office/portable/portable-xlsx-sheet-edits.mjs +19 -14
- package/src/runtime/office/portable/portable-xlsx.mjs +32 -0
- package/src/runtime/office/portable/portable-xml.mjs +9 -0
- package/src/runtime/office/portable/pptx-relations.mjs +11 -0
- package/src/runtime/office/portable/pptx-targets.mjs +2 -1
- package/src/runtime/office/portable/review-editability.mjs +4 -11
- package/src/runtime/office/portable/text-metrics.mjs +35 -55
- package/src/runtime/office/portable/xlsx-assertions.mjs +2 -15
- package/src/runtime/office/portable/xlsx-audit-support.mjs +2 -6
- package/src/runtime/office/portable/xlsx-contract.mjs +4 -0
- package/src/runtime/office/portable/xlsx-formula-audit.mjs +11 -4
- package/src/runtime/office/portable/xlsx-recalculate.mjs +1 -1
- package/src/runtime/office/portable/xlsx-sheet-hygiene.mjs +5 -1
- package/src/runtime/office/quality/assurance-rendered.mjs +3 -2
- package/src/runtime/office/quality/assurance-structure-pptx.mjs +16 -15
- package/src/runtime/office/quality/assurance-trust.mjs +25 -10
- package/src/runtime/office/quality/design-aesthetics.mjs +172 -145
- package/src/runtime/office/quality/design-deck-diversity.mjs +2 -5
- package/src/runtime/office/quality/design-review-authored.mjs +2 -2
- package/src/runtime/office/quality/design-review-critique.mjs +36 -37
- package/src/runtime/office/quality/design-review.mjs +113 -96
- package/src/runtime/office/quality/document-acceptance.mjs +10 -3
- package/src/runtime/office/quality/inline-audit.mjs +7 -2
- package/src/runtime/office/quality/pptx-deck-rubric.mjs +14 -6
- package/src/runtime/office/quality/pptx-slide-roles.mjs +7 -9
- package/src/runtime/office/quality/presentation-acceptance.mjs +2 -6
- package/src/runtime/office/quality/quality-pipeline.mjs +21 -14
- package/src/runtime/office/quality/quality-score.mjs +2 -2
- package/src/runtime/office/quality/render-air.mjs +12 -5
- package/src/runtime/shared/atomic-file.mjs +19 -8
- package/src/runtime/shared/config.mjs +7 -13
- package/src/runtime/shared/err-text.mjs +11 -6
- package/src/runtime/shared/file-lock.mjs +10 -6
- package/src/runtime/shared/inline-file-kind.mjs +51 -0
- package/src/runtime/shared/llm/usage-accounting.mjs +9 -6
- package/src/runtime/shared/llm/usage-ledger-rollup.mjs +272 -0
- package/src/runtime/shared/llm/usage-ledger.mjs +8 -218
- package/src/runtime/shared/pristine-execution.mjs +2 -6
- package/src/runtime/shared/process-lifecycle.mjs +34 -52
- package/src/runtime/shared/process-shutdown.mjs +1 -1
- package/src/runtime/shared/schedule-model-ref.mjs +14 -0
- package/src/runtime/shared/schedule-session-run.mjs +3 -13
- package/src/runtime/shared/schedules-db.mjs +16 -39
- package/src/runtime/shared/staged-child-result.mjs +2 -7
- package/src/runtime/shared/staged-update.mjs +1 -5
- package/src/runtime/shared/tool-card-model/agent-surface.mjs +8 -3
- package/src/runtime/shared/tool-card-model/card-status.mjs +2 -1
- package/src/runtime/shared/tool-card-model/displayed-result.mjs +2 -3
- package/src/runtime/shared/tool-card-model/generic-detail.mjs +5 -3
- package/src/runtime/shared/tool-card-model.golden-cases.mjs +10 -2
- package/src/runtime/shared/tool-card-model.golden.json +3 -12
- package/src/runtime/shared/tool-execution-contract.mjs +22 -26
- package/src/runtime/shared/tool-result-summary.mjs +7 -14
- package/src/runtime/shared/tool-surface.mjs +30 -33
- package/src/runtime/shared/tool-work-units.mjs +12 -8
- package/src/runtime/shared/turn-snapshot-store.mjs +2 -4
- package/src/runtime/shared/turn-worktree-snapshot.mjs +13 -16
- package/src/runtime/shared/update-checker.mjs +5 -0
- package/src/runtime/shared/user-data-guard.mjs +10 -17
- package/src/runtime/shared/webhook-session-run.mjs +3 -15
- package/src/runtime/tidy/history-comment.mjs +32 -27
- package/src/runtime/tidy/process.mjs +18 -21
- package/src/runtime/tidy/report.mjs +50 -9
- package/src/runtime/tidy/resolve.mjs +13 -14
- package/src/runtime/tidy/runners/air.mjs +2 -20
- package/src/runtime/tidy/runners/biome.mjs +4 -6
- package/src/runtime/tidy/runners/dprint.mjs +2 -23
- package/src/runtime/tidy/runners/mago.mjs +2 -20
- package/src/runtime/tidy/runners/ruff.mjs +2 -8
- package/src/runtime/tidy/runners/shared.mjs +35 -9
- package/src/runtime/tidy/runners/stylua.mjs +2 -20
- package/src/runtime/tidy/shadow.mjs +138 -0
- package/src/runtime/tidy/tool.mjs +33 -0
- package/src/runtime/tidy/worktree.mjs +114 -0
- package/src/runtime/web-search/index.mjs +64 -68
- package/src/runtime/web-search/lib/http-fetch.mjs +39 -54
- package/src/runtime/web-search/lib/ssrf-guard.mjs +19 -52
- package/src/runtime/web-search/lib/web-tools.mjs +2 -2
- package/src/session-runtime/config-helpers.mjs +9 -9
- package/src/session-runtime/context-inspection.mjs +64 -23
- package/src/session-runtime/context-status-cache.mjs +0 -2
- package/src/session-runtime/context-status-inspection.mjs +54 -25
- package/src/session-runtime/context-status-shape.mjs +1 -18
- package/src/session-runtime/goal-facade-api.mjs +15 -12
- package/src/session-runtime/goal-mutations.mjs +4 -3
- package/src/session-runtime/goal-runtime.mjs +5 -0
- package/src/session-runtime/goal-tasks.mjs +5 -10
- package/src/session-runtime/goal-text.mjs +46 -9
- package/src/session-runtime/goal-tool-defs.mjs +7 -8
- package/src/session-runtime/goal-tool-exec.mjs +1 -1
- package/src/session-runtime/goal-turns.mjs +54 -3
- package/src/session-runtime/hook-payload.mjs +2 -1
- package/src/session-runtime/inheritance-fit.mjs +3 -3
- package/src/session-runtime/lifecycle/teardown.mjs +9 -1
- package/src/session-runtime/mcp-glue/server-catalog.mjs +4 -6
- package/src/session-runtime/model-capabilities.mjs +1 -3
- package/src/session-runtime/notification-bus.mjs +30 -7
- package/src/session-runtime/plugin-mcp.mjs +0 -2
- package/src/session-runtime/provider-auth/accounts.mjs +2 -2
- package/src/session-runtime/provider-auth/login.mjs +0 -7
- package/src/session-runtime/provider-usage.mjs +1 -1
- package/src/session-runtime/runtime-paths.mjs +1 -3
- package/src/session-runtime/session-hooks.mjs +37 -96
- package/src/session-runtime/statusline-route.mjs +1 -4
- package/src/session-runtime/tool-catalog-schema.mjs +0 -6
- package/src/session-runtime/tool-catalog.mjs +10 -15
- package/src/session-runtime/workflow-ids.mjs +1 -2
- package/src/standalone/agent-task-status.mjs +1 -2
- package/src/standalone/agent-tool/close-flow/close-all.mjs +67 -0
- package/src/standalone/agent-tool/close-flow.mjs +2 -58
- package/src/standalone/agent-tool/execute-send.mjs +91 -0
- package/src/standalone/agent-tool/execute-spawn.mjs +76 -0
- package/src/standalone/agent-tool/execute.mjs +7 -147
- package/src/standalone/agent-tool/helpers.mjs +3 -6
- package/src/standalone/agent-tool/notify/early-completion.mjs +58 -0
- package/src/standalone/agent-tool/notify.mjs +7 -55
- package/src/standalone/agent-tool/provider-init.mjs +73 -64
- package/src/standalone/agent-tool/render.mjs +123 -115
- package/src/standalone/agent-tool/spawn-flow/spawn-plan.mjs +89 -0
- package/src/standalone/agent-tool/spawn-flow/spawn-prep.mjs +16 -75
- package/src/standalone/agent-tool/spawn-flow/spawn-run.mjs +1 -1
- package/src/standalone/agent-tool/worker-rows.mjs +0 -7
- package/src/standalone/channel-admin.mjs +13 -18
- package/src/standalone/channel-transport/remote-binding.mjs +10 -79
- package/src/standalone/channel-transport/remote-intent.mjs +52 -0
- package/src/standalone/channel-transport/remote-notify.mjs +15 -107
- package/src/standalone/channel-transport/remote-pointer.mjs +124 -0
- package/src/standalone/channel-transport/remote-state.mjs +47 -0
- package/src/standalone/daemon-agent-control.mjs +65 -0
- package/src/standalone/daemon-channels-loader.mjs +60 -0
- package/src/standalone/daemon-desktop-runtime.mjs +28 -0
- package/src/standalone/daemon-local-session-bridge.mjs +62 -0
- package/src/standalone/daemon-stored-session-views.mjs +55 -0
- package/src/standalone/daemon.mjs +175 -320
- package/src/standalone/desktop-service-registry.mjs +9 -7
- package/src/standalone/folder-dialog.mjs +11 -12
- package/src/standalone/hook-bus/command-handler.mjs +60 -49
- package/src/standalone/hook-bus/event-runner.mjs +7 -74
- package/src/standalone/hook-bus/handler-dispatch.mjs +75 -0
- package/src/standalone/provider-admin.mjs +14 -35
- package/src/standalone/session-client/attachment-calls.mjs +67 -0
- package/src/standalone/session-client/stream-link.mjs +85 -0
- package/src/standalone/session-client.mjs +31 -106
- package/src/standalone/session-frame-stream.mjs +4 -2
- package/src/standalone/session-protocol.mjs +0 -1
- package/src/standalone/session-runtime-agent-control-client.mjs +11 -27
- package/src/standalone/session-runtime-agent-control.mjs +85 -0
- package/src/standalone/session-runtime-host.mjs +30 -472
- package/src/standalone/session-runtime-inline-host/telemetry.mjs +38 -0
- package/src/standalone/session-runtime-inline-host.mjs +6 -37
- package/src/standalone/session-runtime-proxy.mjs +164 -0
- package/src/standalone/session-runtime-shard-router.mjs +4 -7
- package/src/standalone/session-runtime-spawn-leases.mjs +82 -0
- package/src/standalone/session-runtime-worker.mjs +27 -7
- package/src/standalone/session-service/agent-tree/agent-child.mjs +59 -0
- package/src/standalone/session-service/agent-tree/agent-turns.mjs +4 -55
- package/src/standalone/session-service/agent-tree.mjs +3 -1
- package/src/standalone/session-service/entries/disposal.mjs +72 -0
- package/src/standalone/session-service/entries/external-binding.mjs +6 -3
- package/src/standalone/session-service/entries/lifecycle.mjs +15 -59
- package/src/standalone/session-service/retention/busy.mjs +50 -0
- package/src/standalone/session-service/retention.mjs +5 -44
- package/src/standalone/session-service/session-calls/goal-recovery.mjs +44 -0
- package/src/standalone/session-service/session-calls/session-action.mjs +5 -8
- package/src/standalone/session-service/session-calls/session-turns.mjs +12 -42
- package/src/standalone/session-service/session-calls/session-views.mjs +8 -8
- package/src/standalone/session-transport/stack.mjs +131 -0
- package/src/standalone/session-transport.mjs +10 -103
- package/src/standalone/usage-dashboard.mjs +167 -165
- package/src/standalone/usage-stats-model.mjs +117 -97
- package/src/tui/App.jsx +27 -210
- package/src/tui/app/app-format.mjs +7 -0
- package/src/tui/app/app-view/floating-panel.jsx +229 -0
- package/src/tui/app/app-view/text-entry-labels.mjs +81 -0
- package/src/tui/app/app-view/transcript-viewport/trailing-bands.jsx +94 -0
- package/src/tui/app/app-view/transcript-viewport/transcript-rows.jsx +87 -0
- package/src/tui/app/app-view/transcript-viewport.jsx +74 -0
- package/src/tui/app/app-view.jsx +12 -450
- package/src/tui/app/core-memory-picker/core-rows.mjs +32 -0
- package/src/tui/app/core-memory-picker/entry-prompts.mjs +45 -0
- package/src/tui/app/core-memory-picker/list-panels.mjs +75 -0
- package/src/tui/app/core-memory-picker.mjs +26 -120
- package/src/tui/app/doctor.mjs +17 -12
- package/src/tui/app/extension-pickers/skills-pickers/project-skills.mjs +38 -0
- package/src/tui/app/extension-pickers/skills-pickers/skill-detail.mjs +80 -0
- package/src/tui/app/extension-pickers/skills-pickers/skill-items.mjs +44 -0
- package/src/tui/app/extension-pickers/skills-pickers.mjs +31 -137
- package/src/tui/app/model-picker/route-selection/context-window.mjs +47 -0
- package/src/tui/app/model-picker/route-selection/effort.mjs +87 -0
- package/src/tui/app/model-picker/route-selection/fast-parameters.mjs +84 -0
- package/src/tui/app/model-picker/route-selection/model-key.mjs +5 -0
- package/src/tui/app/model-picker/route-selection.mjs +34 -200
- package/src/tui/app/mouse-input/edge-autoscroll.mjs +53 -0
- package/src/tui/app/mouse-input/geometry.mjs +109 -0
- package/src/tui/app/mouse-input/sgr-buttons.mjs +14 -0
- package/src/tui/app/mouse-input/wheel-router.mjs +96 -0
- package/src/tui/app/panel-signature.mjs +58 -0
- package/src/tui/app/project-picker/project-service.mjs +3 -7
- package/src/tui/app/prompt-submit.mjs +2 -7
- package/src/tui/app/provider-setup/api-key-actions.mjs +7 -80
- package/src/tui/app/provider-setup/oauth-actions.mjs +2 -10
- package/src/tui/app/provider-setup/provider-items.mjs +20 -3
- package/src/tui/app/settings-picker/settings-toggles/cycled.mjs +4 -0
- package/src/tui/app/settings-picker/settings-toggles/listed-cyclers.mjs +77 -0
- package/src/tui/app/settings-picker/settings-toggles/store-toggles.mjs +61 -0
- package/src/tui/app/settings-picker/settings-toggles/theme-cycler.mjs +36 -0
- package/src/tui/app/settings-picker/settings-toggles.mjs +21 -149
- package/src/tui/app/slash-commands.mjs +14 -4
- package/src/tui/app/store-service-call.mjs +17 -0
- package/src/tui/app/text-entry-policy.mjs +1 -3
- package/src/tui/app/transcript-row-estimate.mjs +31 -91
- package/src/tui/app/transcript-window.mjs +19 -0
- package/src/tui/app/use-disabled-skills.mjs +52 -0
- package/src/tui/app/use-global-key-input/copy-first.mjs +43 -0
- package/src/tui/app/use-global-key-input/shift-arrow.mjs +30 -0
- package/src/tui/app/use-global-key-input.mjs +10 -67
- package/src/tui/app/use-model-catalog-cache.mjs +86 -0
- package/src/tui/app/use-mouse-input.mjs +64 -218
- package/src/tui/app/use-pasted-buffers.mjs +55 -81
- package/src/tui/app/use-prompt-draft-flow/draft-change.mjs +66 -0
- package/src/tui/app/use-prompt-draft-flow/prompt-cancels.mjs +40 -0
- package/src/tui/app/use-prompt-draft-flow.mjs +38 -77
- package/src/tui/app/use-prompt-queue-history/prompt-history.mjs +22 -0
- package/src/tui/app/use-prompt-queue-history/restore-to-prompt.mjs +147 -0
- package/src/tui/app/use-prompt-queue-history.mjs +20 -117
- package/src/tui/app/use-selection-focus.mjs +2 -1
- package/src/tui/app/use-selection-geometry.mjs +9 -12
- package/src/tui/app/use-selection-paint/paint-queue.mjs +90 -0
- package/src/tui/app/use-selection-paint/selection-clip.mjs +33 -0
- package/src/tui/app/use-selection-paint.mjs +31 -102
- package/src/tui/app/use-transcript-activity.mjs +1 -1
- package/src/tui/app/use-transcript-window/instance-state.mjs +1 -1
- package/src/tui/app/use-welcome-prompt-hint.mjs +1 -1
- package/src/tui/app/workflow-cycle.mjs +63 -0
- package/src/tui/components/AnsiText.jsx +47 -15
- package/src/tui/components/ItemRightHintOverprint.jsx +2 -15
- package/src/tui/components/Picker.jsx +9 -23
- package/src/tui/components/PromptInput.jsx +89 -335
- package/src/tui/components/QueuedCommands.jsx +1 -3
- package/src/tui/components/Spinner.jsx +1 -2
- package/src/tui/components/StatusLine.jsx +11 -21
- package/src/tui/components/TextEntryPanel.jsx +5 -52
- package/src/tui/components/ToolExecution.jsx +5 -14
- package/src/tui/components/TranscriptItem.jsx +0 -2
- package/src/tui/components/TurnDone.jsx +2 -14
- package/src/tui/components/prompt-input/cursor-anchor.mjs +65 -0
- package/src/tui/components/prompt-input/edit-helpers.mjs +1 -2
- package/src/tui/components/prompt-input/key-signals.mjs +122 -0
- package/src/tui/components/prompt-input/mouse-selection.mjs +114 -0
- package/src/tui/components/prompt-input/restore-policy.d.mts +0 -1
- package/src/tui/components/prompt-input/restore-policy.mjs +3 -8
- package/src/tui/components/prompt-input/selected-text.jsx +25 -0
- package/src/tui/components/prompt-input/undo-stack.mjs +75 -0
- package/src/tui/components/tool-output-format.mjs +1 -2
- package/src/tui/dist/index.mjs +2841 -2469
- package/src/tui/index.jsx +2 -2
- package/src/tui/markdown/measure-rendered-rows.mjs +8 -33
- package/src/tui/markdown/render-ansi.mjs +5 -5
- package/src/tui/markdown/table-layout/box-lines.mjs +46 -0
- package/src/tui/markdown/table-layout/cells.mjs +23 -0
- package/src/tui/markdown/table-layout/column-widths.mjs +65 -0
- package/src/tui/markdown/table-layout/vertical-lines.mjs +46 -0
- package/src/tui/markdown/table-layout.mjs +21 -151
- package/src/tui/prompt-history-store.mjs +0 -9
- package/src/tui/session/active-tool-summary.mjs +19 -27
- package/src/tui/session/agent-envelope.mjs +9 -9
- package/src/tui/session/live-share/owner.mjs +9 -7
- package/src/tui/session/live-share/retry.mjs +15 -0
- package/src/tui/session/live-share/viewer/frame-router.mjs +32 -0
- package/src/tui/session/live-share/viewer/pipe-client.mjs +108 -0
- package/src/tui/session/live-share/viewer.mjs +23 -114
- package/src/tui/session/notice-surface.mjs +1 -1
- package/src/tui/session/notice-text.mjs +21 -17
- package/src/tui/session/queue-helpers.mjs +12 -14
- package/src/tui/session/session-api/intake/submission.mjs +3 -8
- package/src/tui/session/session-api/integrations.mjs +0 -11
- package/src/tui/session/session-api/lifecycle/session-reset.mjs +76 -74
- package/src/tui/session/session-flow/drain.mjs +18 -5
- package/src/tui/session/session-flow/queue/entry-shape.mjs +53 -0
- package/src/tui/session/session-flow/queue/take-entries.mjs +82 -0
- package/src/tui/session/session-flow/queue.mjs +10 -112
- package/src/tui/session/session-flow/session-reset.mjs +2 -7
- package/src/tui/session/tool-approval.mjs +13 -17
- package/src/tui/session/tool-result-text.mjs +16 -28
- package/src/tui/session/transcript-spill.mjs +3 -7
- package/src/tui/session/transcript-store/replace-items.mjs +66 -0
- package/src/tui/session/transcript-store/streaming-tail.mjs +49 -0
- package/src/tui/session/transcript-store.mjs +16 -95
- package/src/tui/statusline-ansi-bridge.mjs +1 -40
- package/src/ui/markdown.mjs +3 -2
- package/src/ui/statusline-agents.mjs +9 -14
- package/src/ui/statusline.mjs +4 -4
- package/src/runtime/channels/lib/cli-worker-host.mjs +0 -2
- package/src/runtime/memory/lib/llm-worker-host.mjs +0 -11
- package/src/standalone/opencode-go-login.mjs +0 -140
|
@@ -73,15 +73,19 @@ function splitInjectedContext(message) {
|
|
|
73
73
|
if (typeof message.content !== 'string') return { message, injected: '' };
|
|
74
74
|
let content = message.content;
|
|
75
75
|
const injected = [];
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
const leading = /^\s*<system-reminder>[\s\S]*?<\/system-reminder>\s*/i;
|
|
77
|
+
const trailing = /\s*<system-reminder>(?:(?!<\/?system-reminder>)[\s\S])*<\/system-reminder>\s*$/i;
|
|
78
|
+
let match = leading.exec(content);
|
|
79
|
+
while (match) {
|
|
78
80
|
injected.push(match[0]);
|
|
79
81
|
content = content.slice(match[0].length);
|
|
82
|
+
match = leading.exec(content);
|
|
80
83
|
}
|
|
81
|
-
|
|
82
|
-
while (
|
|
84
|
+
match = trailing.exec(content);
|
|
85
|
+
while (match) {
|
|
83
86
|
injected.push(match[0]);
|
|
84
87
|
content = content.slice(0, match.index);
|
|
88
|
+
match = trailing.exec(content);
|
|
85
89
|
}
|
|
86
90
|
// Keep standalone reminders on the normal system-section path.
|
|
87
91
|
if (!content.trim() || !injected.length) return { message, injected: '' };
|
|
@@ -90,8 +94,8 @@ function splitInjectedContext(message) {
|
|
|
90
94
|
|
|
91
95
|
// Prompt-head manifests arrive as XML blocks with no markdown heading, so the
|
|
92
96
|
// section split glued each one onto whatever ran before it and it read as a
|
|
93
|
-
// nameless slice of the system prompt
|
|
94
|
-
//
|
|
97
|
+
// nameless slice of the system prompt. Carve them out first and give each its
|
|
98
|
+
// own name.
|
|
95
99
|
const NAMED_PROMPT_BLOCKS = [
|
|
96
100
|
{ tag: 'available-deferred-tools', label: 'Deferred tool list' },
|
|
97
101
|
{ tag: 'mcp-instructions', label: 'MCP instructions' },
|
|
@@ -273,10 +277,13 @@ function sectionDrafts(sections, index, tokens, reminder) {
|
|
|
273
277
|
const skillLabel = SKILL_SECTION_LABELS.get(heading.trim().toLowerCase());
|
|
274
278
|
let category = 'system';
|
|
275
279
|
if (bucket === 'memory') category = 'memory';
|
|
280
|
+
// A section that already knows what it holds (a skill body) files itself;
|
|
281
|
+
// the envelope it travelled in does not decide its category.
|
|
282
|
+
if (section.category) category = section.category;
|
|
276
283
|
return {
|
|
277
284
|
id: `message:${index}:section:${sectionIndex}`,
|
|
278
285
|
category,
|
|
279
|
-
group: reminder ? 'reminder' : 'instruction',
|
|
286
|
+
group: section.group || (reminder ? 'reminder' : 'instruction'),
|
|
280
287
|
label: label(section.label || skillLabel || heading),
|
|
281
288
|
tokens: shares[sectionIndex],
|
|
282
289
|
kind: 'instruction',
|
|
@@ -331,7 +338,9 @@ function toolResultDraft(message, index, tokens, toolName, ordinal) {
|
|
|
331
338
|
}
|
|
332
339
|
|
|
333
340
|
function turnDraft(message, index, tokens, { role, group, ordinal, name }) {
|
|
334
|
-
|
|
341
|
+
let category = 'assistant';
|
|
342
|
+
if (group === 'summary' || role === 'developer') category = 'system';
|
|
343
|
+
else if (role === 'system' || role === 'user') category = role;
|
|
335
344
|
return {
|
|
336
345
|
id: `message:${index}`,
|
|
337
346
|
category,
|
|
@@ -363,7 +372,10 @@ function ordinalCounter() {
|
|
|
363
372
|
function frameSections(message, text, reminder) {
|
|
364
373
|
if (reminder) {
|
|
365
374
|
const skill = latestSkillBodies([{ ...message, content: text }])[0];
|
|
366
|
-
|
|
375
|
+
// A skill body rides in as a reminder, but it is what a skill costs, not
|
|
376
|
+
// system framing: it belongs to Skills, beside the Skill tool definition,
|
|
377
|
+
// grouped as what it is — loaded on demand (user: 스킬 분류 제대로 안된거).
|
|
378
|
+
if (skill) return [{ text, label: `Skill: ${skill.name}`, category: 'skills', group: 'loaded' }];
|
|
367
379
|
if (parseTaskNotification(text)) return [{ text, label: 'Task notification' }];
|
|
368
380
|
return reminderSections(text);
|
|
369
381
|
}
|
|
@@ -472,7 +484,7 @@ function toolDrafts(tools, deferredCatalogNames) {
|
|
|
472
484
|
const drafts = tools.map((tool, index) => {
|
|
473
485
|
const bucket = toolSchemaBucket(tool);
|
|
474
486
|
// The agent tool is a built-in schema like any other; its `agents` bucket
|
|
475
|
-
// must not file it under "Custom agents"
|
|
487
|
+
// must not file it under "Custom agents".
|
|
476
488
|
const category = ['mcp', 'memory', 'skills'].includes(bucket) ? bucket : 'tools';
|
|
477
489
|
const name = String(tool.name || '');
|
|
478
490
|
let state = 'active';
|
|
@@ -510,15 +522,32 @@ function entryPreview(drafts, options, revision) {
|
|
|
510
522
|
return { id: entry.id, text: text.slice(0, PREVIEW_LIMIT), truncated: text.length > PREVIEW_LIMIT, stale: false };
|
|
511
523
|
}
|
|
512
524
|
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
) {
|
|
517
|
-
|
|
525
|
+
// The identity of one reading: the same inputs produce the same entry ids.
|
|
526
|
+
// Computed from the caller's own arrays so the transcript/tool signature memos
|
|
527
|
+
// hit, which is what lets a repeated read recognize a reading it already built.
|
|
528
|
+
export function inspectionRevision({ sessionId, provider, model, messages, tools }) {
|
|
529
|
+
return createHash('sha256')
|
|
518
530
|
.update(
|
|
519
531
|
JSON.stringify([sessionId, provider, model, contextMessagesSignature(messages), toolSchemaSignature(tools)])
|
|
520
532
|
)
|
|
521
533
|
.digest('hex');
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
// Price the whole transcript and tool surface ONCE. Previews stay as closures
|
|
537
|
+
// on the drafts, so a caller that keeps this build answers entry previews
|
|
538
|
+
// without re-pricing anything (user: 컨텍스트창 로딩이 심하지).
|
|
539
|
+
export function buildContextInspection({
|
|
540
|
+
sessionId,
|
|
541
|
+
provider,
|
|
542
|
+
model,
|
|
543
|
+
messages,
|
|
544
|
+
tools,
|
|
545
|
+
overheadTokens = 0,
|
|
546
|
+
coverage = null,
|
|
547
|
+
deferredCatalogNames = null,
|
|
548
|
+
revision = '',
|
|
549
|
+
}) {
|
|
550
|
+
const readingRevision = revision || inspectionRevision({ sessionId, provider, model, messages, tools });
|
|
522
551
|
const drafts = messageDrafts(messages);
|
|
523
552
|
const toolSurface = toolDrafts(tools, deferredCatalogNames);
|
|
524
553
|
drafts.push(...toolSurface.drafts);
|
|
@@ -544,13 +573,25 @@ export function inspectContext(
|
|
|
544
573
|
count: children.length,
|
|
545
574
|
};
|
|
546
575
|
});
|
|
547
|
-
|
|
548
|
-
revision,
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
576
|
+
return {
|
|
577
|
+
revision: readingRevision,
|
|
578
|
+
drafts,
|
|
579
|
+
result: {
|
|
580
|
+
revision: readingRevision,
|
|
581
|
+
categories,
|
|
582
|
+
entries,
|
|
583
|
+
calibration,
|
|
584
|
+
estimatedTokens: categories.reduce((sum, row) => sum + row.tokens, 0),
|
|
585
|
+
},
|
|
553
586
|
};
|
|
554
|
-
|
|
555
|
-
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
/** Answer one request from an already built reading. */
|
|
590
|
+
export function readContextInspection(built, options = {}) {
|
|
591
|
+
if (options.entryId === undefined) return built.result;
|
|
592
|
+
return { ...built.result, preview: entryPreview(built.drafts, options, built.revision) };
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
export function inspectContext(input, options = {}) {
|
|
596
|
+
return readContextInspection(buildContextInspection(input), options);
|
|
556
597
|
}
|
|
@@ -58,8 +58,6 @@ export function createContextStatusCache({ getNativeTools }) {
|
|
|
58
58
|
lastMessage,
|
|
59
59
|
lastMessageRole: lastMessage?.role || null,
|
|
60
60
|
lastMessageContent: lastMessage?.content || null,
|
|
61
|
-
toolCount: requestTools.length,
|
|
62
|
-
toolsSignature: requestToolsSignature,
|
|
63
61
|
requestProvider,
|
|
64
62
|
requestToolCount: requestTools.length,
|
|
65
63
|
requestToolsSignature,
|
|
@@ -6,13 +6,19 @@
|
|
|
6
6
|
// only — so a preview is answered from the exact revision its reader is
|
|
7
7
|
// looking at.
|
|
8
8
|
import { providerBaselineCoverage } from '../runtime/agent/orchestrator/session/loop/compact-policy.mjs';
|
|
9
|
-
import {
|
|
9
|
+
import { buildContextInspection, inspectionRevision, readContextInspection } from './context-inspection.mjs';
|
|
10
10
|
|
|
11
|
-
// How many inspected
|
|
11
|
+
// How many inspected readings stay resolvable for entry previews. One open
|
|
12
12
|
// inspector needs a single slot; the spares cover a second surface and a reader
|
|
13
13
|
// who keeps opening entries while newer readings arrive.
|
|
14
14
|
const INSPECTION_SNAPSHOT_LIMIT = 4;
|
|
15
15
|
|
|
16
|
+
// Calibration is the only input outside the revision: the provider's count for
|
|
17
|
+
// the prefix it measured can be replaced while the transcript stands still.
|
|
18
|
+
function coverageKey(coverage) {
|
|
19
|
+
return coverage ? `${coverage.count}:${coverage.tokens}` : 'none';
|
|
20
|
+
}
|
|
21
|
+
|
|
16
22
|
function deferredCatalogNames(session) {
|
|
17
23
|
return new Set(
|
|
18
24
|
[
|
|
@@ -25,37 +31,60 @@ function deferredCatalogNames(session) {
|
|
|
25
31
|
}
|
|
26
32
|
|
|
27
33
|
export function createInspectionSnapshots() {
|
|
28
|
-
const
|
|
34
|
+
const readings = new Map();
|
|
29
35
|
|
|
30
|
-
function retain(revision,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
for (const oldest of
|
|
34
|
-
if (
|
|
35
|
-
|
|
36
|
+
function retain(revision, reading) {
|
|
37
|
+
readings.delete(revision);
|
|
38
|
+
readings.set(revision, reading);
|
|
39
|
+
for (const oldest of readings.keys()) {
|
|
40
|
+
if (readings.size <= INSPECTION_SNAPSHOT_LIMIT) break;
|
|
41
|
+
readings.delete(oldest);
|
|
36
42
|
}
|
|
37
43
|
}
|
|
38
44
|
|
|
39
45
|
return function withInspection(status, messages, tools, options, session) {
|
|
40
46
|
if (options?.inspect !== true) return status;
|
|
41
47
|
const requestedRevision = options.entryId !== undefined ? String(options.revision || '') : '';
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
// A preview names the revision its entry ids came from, so it is answered
|
|
49
|
+
// from that exact reading. Every other request is identified by its live
|
|
50
|
+
// inputs: an unchanged transcript reuses the reading already built for
|
|
51
|
+
// them instead of pricing the whole conversation again on every open.
|
|
52
|
+
let reading = requestedRevision ? readings.get(requestedRevision) : null;
|
|
53
|
+
if (!reading) {
|
|
54
|
+
const revision = inspectionRevision({
|
|
55
|
+
sessionId: status.sessionId,
|
|
56
|
+
provider: status.provider,
|
|
57
|
+
model: status.model,
|
|
58
|
+
messages,
|
|
59
|
+
tools,
|
|
60
|
+
});
|
|
52
61
|
// The provider's own count for the prefix it measured lets the
|
|
53
62
|
// inspector reconcile its estimates with the gauge's headline.
|
|
54
|
-
coverage
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
63
|
+
const coverage = providerBaselineCoverage(session, messages);
|
|
64
|
+
const key = coverageKey(coverage);
|
|
65
|
+
const cached = readings.get(revision);
|
|
66
|
+
reading =
|
|
67
|
+
cached && cached.coverageKey === key
|
|
68
|
+
? cached
|
|
69
|
+
: {
|
|
70
|
+
coverageKey: key,
|
|
71
|
+
...buildContextInspection({
|
|
72
|
+
sessionId: status.sessionId,
|
|
73
|
+
provider: status.provider,
|
|
74
|
+
model: status.model,
|
|
75
|
+
// Copy both lists: the live turn pushes into its own array, and
|
|
76
|
+
// a retained revision has to keep the order its entry ids were
|
|
77
|
+
// built from.
|
|
78
|
+
messages: messages.slice(),
|
|
79
|
+
tools: tools.slice(),
|
|
80
|
+
overheadTokens: status.request.requestOverheadTokens,
|
|
81
|
+
coverage,
|
|
82
|
+
deferredCatalogNames: deferredCatalogNames(session),
|
|
83
|
+
revision,
|
|
84
|
+
}),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
retain(reading.revision, reading);
|
|
88
|
+
return { ...status, inspection: readContextInspection(reading, options) };
|
|
60
89
|
};
|
|
61
90
|
}
|
|
@@ -67,23 +67,6 @@ function sessionUsageCounters(session, lastContextTokens) {
|
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
function emptyUsageCounters() {
|
|
71
|
-
return {
|
|
72
|
-
reasoningUsage: null,
|
|
73
|
-
lastInputTokens: 0,
|
|
74
|
-
lastUncachedInputTokens: 0,
|
|
75
|
-
lastOutputTokens: 0,
|
|
76
|
-
lastCachedReadTokens: 0,
|
|
77
|
-
lastCacheWriteTokens: 0,
|
|
78
|
-
lastContextTokens: 0,
|
|
79
|
-
totalInputTokens: 0,
|
|
80
|
-
totalUncachedInputTokens: 0,
|
|
81
|
-
totalOutputTokens: 0,
|
|
82
|
-
totalCachedReadTokens: 0,
|
|
83
|
-
totalCacheWriteTokens: 0,
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
|
|
87
70
|
function emptyCompactionStatus(session, policy) {
|
|
88
71
|
return {
|
|
89
72
|
boundaryTokens: Number(session?.compactBoundaryTokens || policy?.boundaryTokens || 0) || null,
|
|
@@ -143,7 +126,7 @@ export function emptyContextStatus(session, route, env) {
|
|
|
143
126
|
requestOverheadTokens: 0,
|
|
144
127
|
reserveTokens: 0,
|
|
145
128
|
},
|
|
146
|
-
usage:
|
|
129
|
+
usage: sessionUsageCounters(null, 0),
|
|
147
130
|
};
|
|
148
131
|
}
|
|
149
132
|
|
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
import { markPendingGoalReminder } from './goal-reminder.mjs';
|
|
2
2
|
|
|
3
3
|
export function createGoalFacadeApi({ agentStatusState, createCurrentSession, getSession, getSessionId, goalRuntime }) {
|
|
4
|
+
const markGoalReminder = (reason = '') => {
|
|
5
|
+
try {
|
|
6
|
+
const pending = markPendingGoalReminder(getSession(), reason);
|
|
7
|
+
// Compaction, an objective change, or a paused-state notice all mean the
|
|
8
|
+
// delivered continuation rules are gone or no longer frame the work, so
|
|
9
|
+
// the next continuation carries them in full again.
|
|
10
|
+
const sessionId = getSessionId();
|
|
11
|
+
if (sessionId) goalRuntime.resetContinuationRules(sessionId);
|
|
12
|
+
return pending;
|
|
13
|
+
} catch {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
4
17
|
return {
|
|
5
18
|
goalStatus() {
|
|
6
19
|
const sessionId = getSessionId();
|
|
@@ -14,20 +27,10 @@ export function createGoalFacadeApi({ agentStatusState, createCurrentSession, ge
|
|
|
14
27
|
}
|
|
15
28
|
if (!sessionId) throw new Error('goal: session could not be created');
|
|
16
29
|
const result = await goalRuntime.control(sessionId, args);
|
|
17
|
-
if (result?.action === 'edit')
|
|
18
|
-
try {
|
|
19
|
-
markPendingGoalReminder(getSession(), 'objective-updated');
|
|
20
|
-
} catch {}
|
|
21
|
-
}
|
|
30
|
+
if (result?.action === 'edit') markGoalReminder('objective-updated');
|
|
22
31
|
return result;
|
|
23
32
|
},
|
|
24
|
-
markGoalReminder
|
|
25
|
-
try {
|
|
26
|
-
return markPendingGoalReminder(getSession(), reason);
|
|
27
|
-
} catch {
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
|
-
},
|
|
33
|
+
markGoalReminder,
|
|
31
34
|
goalContinuation() {
|
|
32
35
|
const sessionId = getSessionId();
|
|
33
36
|
if (!sessionId) return { run: false, reason: 'missing-session', goal: null };
|
|
@@ -239,10 +239,11 @@ export function createGoalMutations(ctx) {
|
|
|
239
239
|
const id = assertSessionId(sessionId);
|
|
240
240
|
const goal = ctx.requireGoal(id);
|
|
241
241
|
assertExpectedGoal(goal, expectedGoalId, 'abandon');
|
|
242
|
-
|
|
242
|
+
const at = now();
|
|
243
|
+
stopActiveClock(goal, at);
|
|
243
244
|
goal.status = 'stopped';
|
|
244
|
-
goal.stoppedAt =
|
|
245
|
-
goal.updatedAt =
|
|
245
|
+
goal.stoppedAt = at;
|
|
246
|
+
goal.updatedAt = at;
|
|
246
247
|
goal.blocker = '';
|
|
247
248
|
// A stopped Goal can neither resume nor be edited, so a user who confirmed
|
|
248
249
|
// the stop has nothing left to do with its chrome: retire it at once. The
|
|
@@ -64,6 +64,10 @@ export function createGoalRuntime({
|
|
|
64
64
|
// one settled-duration review. In memory on purpose: a restart is a new
|
|
65
65
|
// chance.
|
|
66
66
|
idleReviewTurns: new Map(),
|
|
67
|
+
// Session -> { goalId, revision, quietTurns }: which continuation tier this
|
|
68
|
+
// context still owes, from the rules and state already delivered into it.
|
|
69
|
+
// In memory on purpose: a restart is a fresh context that needs them again.
|
|
70
|
+
continuationTiers: new Map(),
|
|
67
71
|
closed: false,
|
|
68
72
|
};
|
|
69
73
|
Object.assign(ctx, createGoalStore(ctx));
|
|
@@ -114,6 +118,7 @@ export function createGoalRuntime({
|
|
|
114
118
|
ctx.turnStartedAt.clear();
|
|
115
119
|
ctx.observedGoals.clear();
|
|
116
120
|
ctx.idleReviewTurns.clear();
|
|
121
|
+
ctx.continuationTiers.clear();
|
|
117
122
|
listeners.clear();
|
|
118
123
|
// Accepted writes keep their ordering until they settle. Callers may
|
|
119
124
|
// await this barrier before releasing the session's backing resources.
|
|
@@ -19,6 +19,8 @@ export function optionalGoalTaskChanges({ tasks, updates } = {}) {
|
|
|
19
19
|
Array.isArray(entry) ||
|
|
20
20
|
clean(entry.id) ||
|
|
21
21
|
clean(entry.text) ||
|
|
22
|
+
// 'kind' is a retired field: stored records and frozen provider schemas
|
|
23
|
+
// still send it, so it stays accepted here and is dropped on normalize.
|
|
22
24
|
Object.keys(entry).some((key) => !['id', 'text', 'status', 'kind'].includes(key));
|
|
23
25
|
return {
|
|
24
26
|
tasks: Array.isArray(tasks) ? tasks.filter(populated) : tasks,
|
|
@@ -46,7 +48,7 @@ export function normalizeGoalTasks(input, previous = [], { strict = false } = {}
|
|
|
46
48
|
const seenText = new Set();
|
|
47
49
|
const seenIds = new Set();
|
|
48
50
|
return input.map((entry, index) => {
|
|
49
|
-
const source = typeof entry === 'string' ? { text: entry, status: 'pending'
|
|
51
|
+
const source = typeof entry === 'string' ? { text: entry, status: 'pending' } : entry;
|
|
50
52
|
if (!source || typeof source !== 'object') throw new Error(`goal task ${index + 1} is invalid`);
|
|
51
53
|
const text = clean(source.text);
|
|
52
54
|
if (!text) throw new Error('goal task text is required');
|
|
@@ -58,19 +60,11 @@ export function normalizeGoalTasks(input, previous = [], { strict = false } = {}
|
|
|
58
60
|
if (seenIds.has(id)) throw new Error(`duplicate goal task id: ${id}`);
|
|
59
61
|
seenIds.add(id);
|
|
60
62
|
const rawStatus = clean(source.status).toLowerCase();
|
|
61
|
-
const rawKind = clean(source.kind).toLowerCase();
|
|
62
63
|
if (strict && !GOAL_TASK_STATUSES.includes(rawStatus))
|
|
63
64
|
throw new Error(`goal task ${index + 1} has an invalid status`);
|
|
64
|
-
if (strict && !['work', 'verification'].includes(rawKind))
|
|
65
|
-
throw new Error(`goal task ${index + 1} has an invalid kind`);
|
|
66
65
|
let status = source.satisfied === true ? 'completed' : 'pending';
|
|
67
66
|
if (GOAL_TASK_STATUSES.includes(rawStatus)) status = rawStatus;
|
|
68
|
-
return {
|
|
69
|
-
id,
|
|
70
|
-
text,
|
|
71
|
-
status,
|
|
72
|
-
kind: rawKind === 'verification' ? 'verification' : 'work',
|
|
73
|
-
};
|
|
67
|
+
return { id, text, status };
|
|
74
68
|
});
|
|
75
69
|
}
|
|
76
70
|
|
|
@@ -109,6 +103,7 @@ export function patchGoalTasks(previous, { updates, tasks } = {}) {
|
|
|
109
103
|
if (!id || !byId.has(id)) throw new Error(`unknown Goal task id: ${id || '(missing)'}`);
|
|
110
104
|
if (seen.has(id)) throw new Error(`duplicate Goal task update: ${id}`);
|
|
111
105
|
seen.add(id);
|
|
106
|
+
// A patch carrying the retired 'kind' is accepted and ignored, not rejected.
|
|
112
107
|
if (Object.keys(patch).some((key) => !['id', 'text', 'status', 'kind'].includes(key)))
|
|
113
108
|
throw new Error(`unknown Goal task update field for ${id}`);
|
|
114
109
|
byId.set(id, { ...byId.get(id), ...patch, id });
|
|
@@ -23,9 +23,8 @@ export function goalTaskLines(tasks) {
|
|
|
23
23
|
if (list.length === 0) return ['- No durable tasks recorded yet.'];
|
|
24
24
|
return list.map((task) => {
|
|
25
25
|
const mark = TASK_MARKS[String(task?.status || '')] || ' ';
|
|
26
|
-
const kind = String(task?.kind || 'work');
|
|
27
26
|
const text = escapeGoalPromptText(task?.text).replace(/\s+/g, ' ');
|
|
28
|
-
return `- [${mark}] ${escapeGoalPromptText(task?.id)}
|
|
27
|
+
return `- [${mark}] ${escapeGoalPromptText(task?.id)}: ${text}`;
|
|
29
28
|
});
|
|
30
29
|
}
|
|
31
30
|
|
|
@@ -39,10 +38,12 @@ export function durationLabel(milliseconds) {
|
|
|
39
38
|
.join(' ');
|
|
40
39
|
}
|
|
41
40
|
|
|
41
|
+
const goalTimeLimitMs = (goal) => Math.max(0, Number(goal?.timeLimitMs) || 0);
|
|
42
|
+
|
|
42
43
|
// Both recovery and idle continuation carry the same timing facts. Exact
|
|
43
44
|
// milliseconds keep a rounded display from becoming a new duration estimate.
|
|
44
45
|
function goalTimeLines(goal) {
|
|
45
|
-
const limit =
|
|
46
|
+
const limit = goalTimeLimitMs(goal);
|
|
46
47
|
const elapsed = Math.max(0, Number(goal?.timeUsedMs) || 0);
|
|
47
48
|
const label = (ms) => `${durationLabel(ms)} (${ms} ms)`;
|
|
48
49
|
const budgetName = goal?.timeMode === 'max' ? 'Maximum time budget' : 'Requested duration';
|
|
@@ -53,8 +54,9 @@ function goalTimeLines(goal) {
|
|
|
53
54
|
];
|
|
54
55
|
}
|
|
55
56
|
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
// Every continuation carries the same durable state: the objective, the
|
|
58
|
+
// clocks, the revision and the task list the model has to move.
|
|
59
|
+
function continuationStateLines(goal) {
|
|
58
60
|
return [
|
|
59
61
|
'<system-reminder>',
|
|
60
62
|
'# Active Goal',
|
|
@@ -69,8 +71,45 @@ export function continuationPrompt(goal, { idleReview = false } = {}) {
|
|
|
69
71
|
...(goal.needsTaskReview ? ['The objective changed; reconcile the full task list with set_tasks.'] : []),
|
|
70
72
|
'',
|
|
71
73
|
'Durable tasks:',
|
|
72
|
-
|
|
74
|
+
...goalTaskLines(goal.tasks),
|
|
73
75
|
'',
|
|
76
|
+
];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// The one rule that differs by budget kind, so both prompt shapes carry it.
|
|
80
|
+
const goalTimeModeRule = (goal) =>
|
|
81
|
+
goal.timeMode === 'max'
|
|
82
|
+
? '- This is a maximum time budget, not a minimum work duration. Complete once the full objective is verified; do not invent extra work to fill the remaining time.'
|
|
83
|
+
: '- A requested duration is a full-period work commitment: continue approved implementation, verification, and improvement; do not complete early unless the user allows it.';
|
|
84
|
+
|
|
85
|
+
// Three tiers, by what the context has actually lost. The rules block is
|
|
86
|
+
// identical on every turn, so `includeRules: false` drops it and renders state
|
|
87
|
+
// with only the few rules a turn boundary itself can erode; dropping
|
|
88
|
+
// `includeState` too leaves a pointer at the work, because the objective and
|
|
89
|
+
// task list are already in the model's own goal tool results.
|
|
90
|
+
export function continuationPrompt(goal, { idleReview = false, includeRules = true, includeState = true } = {}) {
|
|
91
|
+
if (!includeRules && !includeState) {
|
|
92
|
+
return [
|
|
93
|
+
'<system-reminder>',
|
|
94
|
+
`# Active Goal (revision ${goal.revision}): carry the approved work forward against authoritative current state.`,
|
|
95
|
+
...(goalTimeLimitMs(goal) > 0 ? goalTimeLines(goal) : []),
|
|
96
|
+
'The objective, durable task list, and continuation rules delivered earlier in this Goal still apply unchanged.',
|
|
97
|
+
'</system-reminder>',
|
|
98
|
+
].join('\n');
|
|
99
|
+
}
|
|
100
|
+
if (!includeRules) {
|
|
101
|
+
return [
|
|
102
|
+
...continuationStateLines(goal),
|
|
103
|
+
'Rules: the full continuation rules were delivered earlier in this Goal and still apply unchanged. State update only:',
|
|
104
|
+
'- A turn may end while this Goal remains active. Report that turn as progress, not as completion of the whole objective.',
|
|
105
|
+
'- Finish every approved task without stepwise approval, park work that needs a user response as awaiting_approval, and pause only once nothing else can proceed.',
|
|
106
|
+
goalTimeModeRule(goal),
|
|
107
|
+
'- Complete only on an audit that proves every user condition met, and never complete or block merely because time is low or the turn is ending.',
|
|
108
|
+
'</system-reminder>',
|
|
109
|
+
].join('\n');
|
|
110
|
+
}
|
|
111
|
+
return [
|
|
112
|
+
...continuationStateLines(goal),
|
|
74
113
|
'Rules:',
|
|
75
114
|
"- The user's completion conditions decide everything: the objective, what it references, and explicit user instructions. The task list records them; it never replaces them.",
|
|
76
115
|
'- A turn may end while this Goal remains active. Report that turn as progress, not as completion of the whole objective; ending a turn does not complete the Goal.',
|
|
@@ -82,9 +121,7 @@ export function continuationPrompt(goal, { idleReview = false } = {}) {
|
|
|
82
121
|
'- Classify the previous turn as concrete progress, a verified wait, or no progress. Progress completes work, changes authoritative state, or produces evidence that determines a different next action.',
|
|
83
122
|
'- Wait only on a currently live process, job, or tool handle. An observation timeout is not termination: continue observing the same handle rather than restarting its work.',
|
|
84
123
|
'- After no progress, re-evaluate the available safe actions and execute one. Do not substitute a status report or a narrower objective for the requested work.',
|
|
85
|
-
goal
|
|
86
|
-
? '- This is a maximum time budget, not a minimum work duration. Complete once the full objective is verified; do not invent extra work to fill the remaining time.'
|
|
87
|
-
: '- A requested duration is a full-period work commitment: continue approved implementation, verification, and improvement; do not complete early unless the user allows it.',
|
|
124
|
+
goalTimeModeRule(goal),
|
|
88
125
|
// Delivered once per settled task list: the runtime waits out the rest of
|
|
89
126
|
// the duration on the deadline timer if this turn records nothing new.
|
|
90
127
|
...(idleReview
|
|
@@ -24,7 +24,6 @@ const taskFields = {
|
|
|
24
24
|
description:
|
|
25
25
|
'completed only when fully done; dropped only after user scope change; awaiting_approval for user-dependent work.',
|
|
26
26
|
},
|
|
27
|
-
kind: { type: 'string', enum: ['work', 'verification'] },
|
|
28
27
|
};
|
|
29
28
|
|
|
30
29
|
export const GOAL_TOOL_DEFS = Object.freeze([
|
|
@@ -32,8 +31,8 @@ export const GOAL_TOOL_DEFS = Object.freeze([
|
|
|
32
31
|
name: 'goal',
|
|
33
32
|
title: 'Goal',
|
|
34
33
|
description: [
|
|
35
|
-
'Durable tasks with an idle reminder for unfinished work. Create for explicit
|
|
36
|
-
'Obtain required
|
|
34
|
+
'Durable tasks with an idle reminder for unfinished work. Create for an explicit Goal request, or approved work spanning several rounds or turns: staged refactors and migrations, repeated improvement passes, open-ended objectives that must be finished, with or without a time budget. Single-turn tasks, planning or estimates alone, and unaccepted proposals do not qualify.',
|
|
35
|
+
'Obtain required approval, load the goal-management skill for lifecycle and completion policy, then create or reconcile the Goal before starting approved work. Mutations need the latest revision.',
|
|
37
36
|
].join(' '),
|
|
38
37
|
annotations: {
|
|
39
38
|
title: 'Goal',
|
|
@@ -50,7 +49,7 @@ export const GOAL_TOOL_DEFS = Object.freeze([
|
|
|
50
49
|
type: 'string',
|
|
51
50
|
enum: ['status', 'create', 'pause', 'resume', 'set_tasks', 'update_tasks', 'complete', 'block', 'abandon'],
|
|
52
51
|
description:
|
|
53
|
-
'
|
|
52
|
+
'create starts approved work once any previous Goal has ended; resume continues unfinished work with optional time and task changes; set_tasks replaces, update_tasks patches/adds; pause waits for a user answer; abandon retires superseded work.',
|
|
54
53
|
},
|
|
55
54
|
objective: { type: 'string', description: 'create: requested outcome.' },
|
|
56
55
|
time_limit_minutes: {
|
|
@@ -58,13 +57,13 @@ export const GOAL_TOOL_DEFS = Object.freeze([
|
|
|
58
57
|
minimum: 1,
|
|
59
58
|
maximum: MAX_GOAL_TIME_LIMIT_MS / 60_000,
|
|
60
59
|
description:
|
|
61
|
-
'create: approved total budget. resume: approved remaining budget from now,
|
|
60
|
+
'create: approved total budget, omitted when none was agreed. resume: approved remaining budget from now, keeping time already used; another 5-hour round sets 300. Omit to preserve the current budget.',
|
|
62
61
|
},
|
|
63
62
|
time_mode: {
|
|
64
63
|
type: 'string',
|
|
65
64
|
enum: ['max', 'duration'],
|
|
66
65
|
description:
|
|
67
|
-
'
|
|
66
|
+
'max permits verified early completion; duration commits the full period, only on explicit request. Omitted: create defaults to max, resume keeps the current mode. Change a mode only with user approval.',
|
|
68
67
|
},
|
|
69
68
|
tasks: {
|
|
70
69
|
type: 'array',
|
|
@@ -73,7 +72,7 @@ export const GOAL_TOOL_DEFS = Object.freeze([
|
|
|
73
72
|
items: {
|
|
74
73
|
type: 'object',
|
|
75
74
|
properties: taskFields,
|
|
76
|
-
required: ['text', 'status'
|
|
75
|
+
required: ['text', 'status'],
|
|
77
76
|
additionalProperties: false,
|
|
78
77
|
},
|
|
79
78
|
description: `create/set_tasks: full list; update_tasks/resume: new tasks, no ids. Max ${MAX_GOAL_TASKS} total, including completed/dropped.`,
|
|
@@ -95,7 +94,7 @@ export const GOAL_TOOL_DEFS = Object.freeze([
|
|
|
95
94
|
minLength: 1,
|
|
96
95
|
maxLength: 1_000,
|
|
97
96
|
description:
|
|
98
|
-
'pause: required user answer. block: stable description of the same external impasse, reported once per turn; runtime stops after 3
|
|
97
|
+
'pause: the required user answer. block: stable description of the same external impasse, reported once per turn; the runtime stops after 3.',
|
|
99
98
|
},
|
|
100
99
|
},
|
|
101
100
|
required: ['action'],
|
|
@@ -151,6 +151,6 @@ export async function executeGoalTool(ctx, name, args = {}, context = {}) {
|
|
|
151
151
|
const id = assertSessionId(sessionId);
|
|
152
152
|
if (name !== 'goal') throw new Error(`unknown Goal tool: ${name}`);
|
|
153
153
|
const action = validateGoalToolCall(args);
|
|
154
|
-
const handler = GOAL_TOOL_ACTIONS[action]
|
|
154
|
+
const handler = GOAL_TOOL_ACTIONS[action];
|
|
155
155
|
return handler(ctx, id, args, action);
|
|
156
156
|
}
|