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
|
@@ -5,12 +5,9 @@ import { fileURLToPath } from 'node:url';
|
|
|
5
5
|
import { safeIpcSend } from '../runtime/shared/safe-ipc-send.mjs';
|
|
6
6
|
import { hiddenSpawnOpts } from '../runtime/shared/spawn-flags.mjs';
|
|
7
7
|
import { withHeapCap } from '../runtime/shared/heap-cap.mjs';
|
|
8
|
-
import {
|
|
9
|
-
acquire as acquireMachineSpawnSlot,
|
|
10
|
-
snapshot as machineSpawnSnapshot,
|
|
11
|
-
} from '../runtime/shared/child-spawn-gate.mjs';
|
|
8
|
+
import { snapshot as machineSpawnSnapshot } from '../runtime/shared/child-spawn-gate.mjs';
|
|
12
9
|
import { createRuntimeLagTracker } from '../runtime/shared/session-runtime-health.mjs';
|
|
13
|
-
import {
|
|
10
|
+
import { ShardSpawnLeases } from './session-runtime-spawn-leases.mjs';
|
|
14
11
|
import {
|
|
15
12
|
createShardOwnership,
|
|
16
13
|
mergeProviderCooldown,
|
|
@@ -19,31 +16,10 @@ import {
|
|
|
19
16
|
runtimeRoutingKey,
|
|
20
17
|
selectShardIndex,
|
|
21
18
|
} from './session-runtime-shard-router.mjs';
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
19
|
+
import { AgentControlRouter } from './session-runtime-agent-control.mjs';
|
|
20
|
+
import { SessionRuntimeProxy } from './session-runtime-proxy.mjs';
|
|
24
21
|
import { aggregateShardWorkload } from './session-runtime-workload.mjs';
|
|
25
22
|
|
|
26
|
-
const RUNTIME_METHODS = new Set([
|
|
27
|
-
...SESSION_READ_ACTIONS,
|
|
28
|
-
...SESSION_CONFIGURE_ACTIONS,
|
|
29
|
-
'readModelMessages',
|
|
30
|
-
'reserveSession',
|
|
31
|
-
'resume',
|
|
32
|
-
'submitAsync',
|
|
33
|
-
'submitAndWait',
|
|
34
|
-
'abort',
|
|
35
|
-
'closeCanonicalSession',
|
|
36
|
-
'resolveToolApproval',
|
|
37
|
-
'dispose',
|
|
38
|
-
]);
|
|
39
|
-
|
|
40
|
-
function applyRuntimeStateFrame(previous, frame) {
|
|
41
|
-
if (frame?.full && typeof frame.full === 'object') return frame.full;
|
|
42
|
-
const patch = frame?.patch;
|
|
43
|
-
if (!patch || typeof patch !== 'object') return previous || {};
|
|
44
|
-
return applySessionStatePatch(previous, patch);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
23
|
/**
|
|
48
24
|
* One runtime child process = one shard = one event-loop failure domain.
|
|
49
25
|
*
|
|
@@ -73,7 +49,7 @@ class SessionRuntimeShard {
|
|
|
73
49
|
this.prewarmPromise = null;
|
|
74
50
|
this.failedChildren = new WeakSet();
|
|
75
51
|
// Machine-wide spawn leases held on behalf of the runtime child process.
|
|
76
|
-
this.spawnLeases = new
|
|
52
|
+
this.spawnLeases = new ShardSpawnLeases(this);
|
|
77
53
|
}
|
|
78
54
|
|
|
79
55
|
ensureChild() {
|
|
@@ -112,11 +88,11 @@ class SessionRuntimeShard {
|
|
|
112
88
|
// never outrank the replacement's revision or settle its pending calls.
|
|
113
89
|
if (child !== this.child) return;
|
|
114
90
|
if (message.type === 'spawn-lease') {
|
|
115
|
-
void this.
|
|
91
|
+
void this.spawnLeases.grant(message);
|
|
116
92
|
return;
|
|
117
93
|
}
|
|
118
94
|
if (message.type === 'spawn-release') {
|
|
119
|
-
this.
|
|
95
|
+
this.spawnLeases.settle(String(message.leaseId || ''));
|
|
120
96
|
return;
|
|
121
97
|
}
|
|
122
98
|
if (message.type === 'event-loop-lag') {
|
|
@@ -128,15 +104,15 @@ class SessionRuntimeShard {
|
|
|
128
104
|
return;
|
|
129
105
|
}
|
|
130
106
|
if (message.type === 'agent-control') {
|
|
131
|
-
void this.pool?.handleAgentControl(this, child, message);
|
|
107
|
+
void this.pool?.agentControl.handleAgentControl(this, child, message);
|
|
132
108
|
return;
|
|
133
109
|
}
|
|
134
110
|
if (message.type === 'agent-control-cancel') {
|
|
135
|
-
this.pool?.cancelAgentControl(message);
|
|
111
|
+
this.pool?.agentControl.cancelAgentControl(message);
|
|
136
112
|
return;
|
|
137
113
|
}
|
|
138
114
|
if (message.type === 'agent-control-notification') {
|
|
139
|
-
this.pool?.routeAgentControlNotification(message);
|
|
115
|
+
this.pool?.agentControl.routeAgentControlNotification(message);
|
|
140
116
|
return;
|
|
141
117
|
}
|
|
142
118
|
if (message.type === 'unhealthy') {
|
|
@@ -259,30 +235,23 @@ class SessionRuntimeShard {
|
|
|
259
235
|
const requestId = `runtime-${process.pid}-${++this.sequence}`;
|
|
260
236
|
return new Promise((resolve, reject) => {
|
|
261
237
|
const request = { id: requestId, resolve, reject, timer: null };
|
|
238
|
+
// Every local failure path settles exactly once: a response already
|
|
239
|
+
// handled by onMessage has dropped the pending entry.
|
|
240
|
+
const settleReject = (error) => {
|
|
241
|
+
if (!this.pending.delete(requestId)) return;
|
|
242
|
+
if (request.timer) clearTimeout(request.timer);
|
|
243
|
+
reject(error);
|
|
244
|
+
};
|
|
262
245
|
if (timeoutMs > 0) {
|
|
263
|
-
request.timer = setTimeout(
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
246
|
+
request.timer = setTimeout(
|
|
247
|
+
() => settleReject(new Error(`session runtime worker ${type} timed out`)),
|
|
248
|
+
timeoutMs
|
|
249
|
+
);
|
|
267
250
|
request.timer.unref?.();
|
|
268
251
|
}
|
|
269
252
|
this.pending.set(requestId, request);
|
|
270
|
-
if (
|
|
271
|
-
|
|
272
|
-
child,
|
|
273
|
-
{ type, requestId, ...payload },
|
|
274
|
-
{
|
|
275
|
-
onError: (error) => {
|
|
276
|
-
if (!this.pending.delete(requestId)) return;
|
|
277
|
-
if (request.timer) clearTimeout(request.timer);
|
|
278
|
-
reject(error);
|
|
279
|
-
},
|
|
280
|
-
}
|
|
281
|
-
)
|
|
282
|
-
) {
|
|
283
|
-
this.pending.delete(requestId);
|
|
284
|
-
if (request.timer) clearTimeout(request.timer);
|
|
285
|
-
reject(new Error('session runtime worker IPC is unavailable'));
|
|
253
|
+
if (!safeIpcSend(child, { type, requestId, ...payload }, { onError: settleReject })) {
|
|
254
|
+
settleReject(new Error('session runtime worker IPC is unavailable'));
|
|
286
255
|
}
|
|
287
256
|
});
|
|
288
257
|
}
|
|
@@ -404,64 +373,8 @@ class SessionRuntimeShard {
|
|
|
404
373
|
return this.lag.degraded;
|
|
405
374
|
}
|
|
406
375
|
|
|
407
|
-
/** Grant one machine-wide spawn lease from the daemon-side gate (the single
|
|
408
|
-
* budget authority; daemon-hosted work uses the same instance locally). */
|
|
409
|
-
async grantSpawnLease(message) {
|
|
410
|
-
const leaseId = String(message.leaseId || '');
|
|
411
|
-
if (!leaseId || this.spawnLeases.has(leaseId)) return;
|
|
412
|
-
const child = this.child;
|
|
413
|
-
const controller = new AbortController();
|
|
414
|
-
const record = { release: null, controller, settled: false };
|
|
415
|
-
this.spawnLeases.set(leaseId, record);
|
|
416
|
-
const reply = (body) => {
|
|
417
|
-
if (this.child !== child || !child || child.killed) return false;
|
|
418
|
-
return safeIpcSend(child, { type: 'spawn-lease-result', leaseId, ...body }, { onError: () => {} });
|
|
419
|
-
};
|
|
420
|
-
try {
|
|
421
|
-
const release = await acquireMachineSpawnSlot(controller.signal, message.lane, {
|
|
422
|
-
ownerKey: `runtime:${String(message.ownerKey || 'anonymous')}`,
|
|
423
|
-
waitTimeoutMs: Number(message.waitTimeoutMs) > 0 ? Number(message.waitTimeoutMs) : undefined,
|
|
424
|
-
});
|
|
425
|
-
if (record.settled || this.closed || this.child !== child) {
|
|
426
|
-
release();
|
|
427
|
-
this.spawnLeases.delete(leaseId);
|
|
428
|
-
return;
|
|
429
|
-
}
|
|
430
|
-
record.release = release;
|
|
431
|
-
if (!reply({ ok: true })) this.settleSpawnLease(leaseId);
|
|
432
|
-
} catch (error) {
|
|
433
|
-
this.spawnLeases.delete(leaseId);
|
|
434
|
-
if (!record.settled) {
|
|
435
|
-
reply({
|
|
436
|
-
ok: false,
|
|
437
|
-
error: String(error?.message || error),
|
|
438
|
-
code: error?.code || null,
|
|
439
|
-
statusCode: Number(error?.statusCode) || null,
|
|
440
|
-
});
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
settleSpawnLease(leaseId) {
|
|
446
|
-
const record = this.spawnLeases.get(leaseId);
|
|
447
|
-
if (!record || record.settled) return;
|
|
448
|
-
record.settled = true;
|
|
449
|
-
if (record.release) {
|
|
450
|
-
try {
|
|
451
|
-
record.release();
|
|
452
|
-
} catch {
|
|
453
|
-
/* idempotent */
|
|
454
|
-
}
|
|
455
|
-
this.spawnLeases.delete(leaseId);
|
|
456
|
-
return;
|
|
457
|
-
}
|
|
458
|
-
// Still queued on the machine gate: cancel the waiter; grantSpawnLease's
|
|
459
|
-
// catch path removes the record.
|
|
460
|
-
record.controller.abort(new Error('spawn lease released while queued'));
|
|
461
|
-
}
|
|
462
|
-
|
|
463
376
|
releaseAllSpawnLeases() {
|
|
464
|
-
|
|
377
|
+
this.spawnLeases.releaseAll();
|
|
465
378
|
}
|
|
466
379
|
|
|
467
380
|
async close(reason) {
|
|
@@ -513,143 +426,6 @@ class SessionRuntimeShard {
|
|
|
513
426
|
}
|
|
514
427
|
}
|
|
515
428
|
|
|
516
|
-
// Wire contract for runtime calls: the fork IPC link serializes frames
|
|
517
|
-
// as JSON, which cannot represent `undefined` and would fabricate `null` in
|
|
518
|
-
// its place — turning an omitted optional argument (e.g. `resume(id)`) into a
|
|
519
|
-
// bogus `resume(id, null)` that bypasses callee default parameters. Trim
|
|
520
|
-
// trailing `undefined` arguments before transport so an omitted argument stays
|
|
521
|
-
// omitted on the wire and worker-side defaults apply exactly as in-process.
|
|
522
|
-
// Interior `undefined` holes cannot be omitted positionally and keep their
|
|
523
|
-
// pre-existing JSON behavior.
|
|
524
|
-
function wireCallArgs(args) {
|
|
525
|
-
const out = Array.isArray(args) ? [...args] : [];
|
|
526
|
-
while (out.length > 0 && out[out.length - 1] === undefined) out.pop();
|
|
527
|
-
return out;
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
class SessionRuntimeProxy {
|
|
531
|
-
constructor(id, shard, options, routingKey = '') {
|
|
532
|
-
this.id = id;
|
|
533
|
-
this.shard = shard;
|
|
534
|
-
// Stable ownership key (sessionId when known): recovery, resume and every
|
|
535
|
-
// later view of this session resolve to the same shard. The claim is
|
|
536
|
-
// released exactly once, by whichever settle path runs first.
|
|
537
|
-
this.routingKey = String(routingKey || id);
|
|
538
|
-
this.ownershipReleased = false;
|
|
539
|
-
this.options = { ...(options || {}) };
|
|
540
|
-
this.state = {};
|
|
541
|
-
this.revision = 0;
|
|
542
|
-
this.listeners = new Set();
|
|
543
|
-
this.failure = null;
|
|
544
|
-
this.recovering = false;
|
|
545
|
-
this.isWireSafe = true;
|
|
546
|
-
for (const method of RUNTIME_METHODS) {
|
|
547
|
-
this[method] = (...args) => this.call(method, args);
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
getState() {
|
|
552
|
-
return this.state;
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
subscribe(listener) {
|
|
556
|
-
this.listeners.add(listener);
|
|
557
|
-
return () => this.listeners.delete(listener);
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
applyFrame(frame) {
|
|
561
|
-
const revision = Number(frame.revision) || 0;
|
|
562
|
-
if (revision <= this.revision) return;
|
|
563
|
-
if (frame.patch && revision !== this.revision + 1) {
|
|
564
|
-
void this.shard.request('snapshot', { runtimeId: this.id }, 5_000).catch(() => {});
|
|
565
|
-
return;
|
|
566
|
-
}
|
|
567
|
-
this.state = applyRuntimeStateFrame(this.state, frame);
|
|
568
|
-
this.revision = revision;
|
|
569
|
-
this.failure = null;
|
|
570
|
-
this.recovering = false;
|
|
571
|
-
for (const listener of [...this.listeners]) {
|
|
572
|
-
try {
|
|
573
|
-
listener();
|
|
574
|
-
} catch {}
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
fail(error) {
|
|
579
|
-
this.failure = error instanceof Error ? error : new Error(String(error));
|
|
580
|
-
this.recovering = false;
|
|
581
|
-
for (const listener of [...this.listeners]) {
|
|
582
|
-
try {
|
|
583
|
-
listener();
|
|
584
|
-
} catch {}
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
beginRecovery(error) {
|
|
589
|
-
this.failure = error instanceof Error ? error : new Error(String(error));
|
|
590
|
-
this.recovering = true;
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
async recreate() {
|
|
594
|
-
const previousSessionId = String(this.state?.sessionId || this.options.sessionId || '');
|
|
595
|
-
this.revision = 0;
|
|
596
|
-
await this.shard.requestRaw(
|
|
597
|
-
'create',
|
|
598
|
-
{
|
|
599
|
-
runtimeId: this.id,
|
|
600
|
-
options: this.options,
|
|
601
|
-
},
|
|
602
|
-
120_000
|
|
603
|
-
);
|
|
604
|
-
if (previousSessionId) {
|
|
605
|
-
const resumed = await this.shard.requestRaw(
|
|
606
|
-
'call',
|
|
607
|
-
{
|
|
608
|
-
runtimeId: this.id,
|
|
609
|
-
method: 'resume',
|
|
610
|
-
args: [previousSessionId],
|
|
611
|
-
},
|
|
612
|
-
120_000
|
|
613
|
-
);
|
|
614
|
-
if (resumed !== true) {
|
|
615
|
-
await this.shard.requestRaw(
|
|
616
|
-
'call',
|
|
617
|
-
{
|
|
618
|
-
runtimeId: this.id,
|
|
619
|
-
method: 'reserveSession',
|
|
620
|
-
args: [previousSessionId],
|
|
621
|
-
},
|
|
622
|
-
30_000
|
|
623
|
-
);
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
await this.shard.requestRaw('snapshot', { runtimeId: this.id }, 5_000);
|
|
627
|
-
this.failure = null;
|
|
628
|
-
this.recovering = false;
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
async call(method, args) {
|
|
632
|
-
if (this.recovering && this.shard.recovery) await this.shard.recovery;
|
|
633
|
-
if (this.failure) throw this.failure;
|
|
634
|
-
try {
|
|
635
|
-
const value = await this.shard.request(
|
|
636
|
-
'call',
|
|
637
|
-
{
|
|
638
|
-
runtimeId: this.id,
|
|
639
|
-
method,
|
|
640
|
-
args: wireCallArgs(args),
|
|
641
|
-
},
|
|
642
|
-
method === 'abort' ? 15_000 : 10 * 60_000
|
|
643
|
-
);
|
|
644
|
-
if (method === 'dispose') this.shard.releaseProxy(this.id);
|
|
645
|
-
return value;
|
|
646
|
-
} catch (error) {
|
|
647
|
-
if (method === 'dispose') this.shard.releaseProxy(this.id);
|
|
648
|
-
throw error;
|
|
649
|
-
}
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
|
|
653
429
|
/**
|
|
654
430
|
* Bounded multi-child shard pool.
|
|
655
431
|
*
|
|
@@ -666,14 +442,9 @@ class SessionRuntimeShardPool {
|
|
|
666
442
|
this.closed = false;
|
|
667
443
|
this.ownership = createShardOwnership();
|
|
668
444
|
this.dispatchOwners = new Map(); // dispatchId -> shard index
|
|
669
|
-
|
|
670
|
-
this.
|
|
671
|
-
this.agentTaskOwners = new Map(); // taskId -> shard index
|
|
672
|
-
this.agentTagOwners = new Map(); // ownerSessionId\0tag -> shard index
|
|
673
|
-
this.agentSessionOwners = new Map(); // agent sessionId -> shard index
|
|
674
|
-
this.agentOwnerOrigins = new Map(); // owner sessionId -> source shard index
|
|
445
|
+
// Agent placement memory and the canonical-control bridge.
|
|
446
|
+
this.agentControl = new AgentControlRouter(this, executeAgentControl);
|
|
675
447
|
this.providerCooldown = { untilMs: 0, disabledReason: null, updatedAt: 0 };
|
|
676
|
-
this.executeCanonicalAgentControl = typeof executeAgentControl === 'function' ? executeAgentControl : null;
|
|
677
448
|
this.prewarmRequested = false;
|
|
678
449
|
this.workloadCache = { refreshedAt: 0, shards: [] };
|
|
679
450
|
this.workloadRefresh = null;
|
|
@@ -759,214 +530,6 @@ class SessionRuntimeShardPool {
|
|
|
759
530
|
this.dispatchOwners.delete(String(dispatchId || ''));
|
|
760
531
|
}
|
|
761
532
|
|
|
762
|
-
agentTagKey(ownerSessionId, tag) {
|
|
763
|
-
return `${String(ownerSessionId || '')}\0${String(tag || '')}`;
|
|
764
|
-
}
|
|
765
|
-
|
|
766
|
-
rememberAgentControlResult(index, args, context, value) {
|
|
767
|
-
const text = String(value || '');
|
|
768
|
-
const ownerSessionId = String(context?.callerSessionId || '');
|
|
769
|
-
const taskId = String(args?.task_id || args?.taskId || /^agent task:\s*(\S+)/m.exec(text)?.[1] || '');
|
|
770
|
-
const target = /^target:\s*(\S+)(?:\s+(\S+))?/m.exec(text);
|
|
771
|
-
const tag = String(args?.tag || (target?.[1] && target[1] !== '-' ? target[1] : ''));
|
|
772
|
-
const sessionId = String(
|
|
773
|
-
args?.sessionId || args?.session_id || (target?.[2] && /^sess_/.test(target[2]) ? target[2] : '')
|
|
774
|
-
);
|
|
775
|
-
if (taskId) this.agentTaskOwners.set(taskId, index);
|
|
776
|
-
if (tag) this.agentTagOwners.set(this.agentTagKey(ownerSessionId, tag), index);
|
|
777
|
-
if (sessionId) this.agentSessionOwners.set(sessionId, index);
|
|
778
|
-
}
|
|
779
|
-
|
|
780
|
-
agentControlShard(originShard, args, context, controlId) {
|
|
781
|
-
const ownerSessionId = String(context?.callerSessionId || '');
|
|
782
|
-
const taskId = String(args?.task_id || args?.taskId || '');
|
|
783
|
-
const sessionId = String(args?.sessionId || args?.session_id || '');
|
|
784
|
-
const tag = String(args?.tag || '');
|
|
785
|
-
let index = taskId ? this.agentTaskOwners.get(taskId) : null;
|
|
786
|
-
if (index == null && sessionId) index = this.agentSessionOwners.get(sessionId);
|
|
787
|
-
if (index == null && tag) index = this.agentTagOwners.get(this.agentTagKey(ownerSessionId, tag));
|
|
788
|
-
if (index == null) {
|
|
789
|
-
const key = `agent:${ownerSessionId}:${tag || sessionId || controlId}`;
|
|
790
|
-
index = selectShardIndex(key, this.shards.length, (candidate) => this.isPlaceable(candidate));
|
|
791
|
-
}
|
|
792
|
-
return this.shardAt(index ?? originShard?.index ?? 0);
|
|
793
|
-
}
|
|
794
|
-
|
|
795
|
-
async aggregateAgentStatus(context, originShard) {
|
|
796
|
-
const targets = this.liveShards();
|
|
797
|
-
if (targets.length === 0 && originShard) targets.push(originShard);
|
|
798
|
-
const settled = await Promise.allSettled(
|
|
799
|
-
targets.map((shard) => shard.request('agent-control-status', { context }, 30_000))
|
|
800
|
-
);
|
|
801
|
-
const workers = new Map();
|
|
802
|
-
const jobs = new Map();
|
|
803
|
-
for (const result of settled) {
|
|
804
|
-
if (result.status !== 'fulfilled') continue;
|
|
805
|
-
for (const worker of Array.isArray(result.value?.workers) ? result.value.workers : []) {
|
|
806
|
-
const key = String(worker?.sessionId || worker?.tag || '');
|
|
807
|
-
if (key) workers.set(key, worker);
|
|
808
|
-
}
|
|
809
|
-
for (const job of Array.isArray(result.value?.jobs) ? result.value.jobs : []) {
|
|
810
|
-
const key = String(job?.task_id || job?.taskId || '');
|
|
811
|
-
if (key) jobs.set(key, job);
|
|
812
|
-
}
|
|
813
|
-
}
|
|
814
|
-
return renderAgentResult({ workers: [...workers.values()], jobs: [...jobs.values()] });
|
|
815
|
-
}
|
|
816
|
-
|
|
817
|
-
async executeAgentControl(originShard, args = {}, context = {}, controlId = randomUUID()) {
|
|
818
|
-
const type = String(args?.type || 'spawn')
|
|
819
|
-
.trim()
|
|
820
|
-
.toLowerCase();
|
|
821
|
-
const ownerSessionId = String(context?.callerSessionId || '');
|
|
822
|
-
if (ownerSessionId && originShard) {
|
|
823
|
-
this.agentOwnerOrigins.set(ownerSessionId, originShard.index);
|
|
824
|
-
}
|
|
825
|
-
if (type === 'list') return this.aggregateAgentStatus(context, originShard);
|
|
826
|
-
if (type === 'cleanup' || type === '__close_all') {
|
|
827
|
-
const targets = this.liveShards();
|
|
828
|
-
const settled = await Promise.allSettled(
|
|
829
|
-
targets.map((shard) =>
|
|
830
|
-
shard.request(
|
|
831
|
-
'agent-control-local',
|
|
832
|
-
{
|
|
833
|
-
controlId: `${controlId}:${shard.index}`,
|
|
834
|
-
args,
|
|
835
|
-
context,
|
|
836
|
-
},
|
|
837
|
-
180_000
|
|
838
|
-
)
|
|
839
|
-
)
|
|
840
|
-
);
|
|
841
|
-
return settled
|
|
842
|
-
.filter((result) => result.status === 'fulfilled' && result.value)
|
|
843
|
-
.map((result) => String(result.value))
|
|
844
|
-
.join('\n');
|
|
845
|
-
}
|
|
846
|
-
const target = this.agentControlShard(originShard, args, context, controlId);
|
|
847
|
-
this.agentControlOwners.set(controlId, target.index);
|
|
848
|
-
try {
|
|
849
|
-
let value = await target.request(
|
|
850
|
-
'agent-control-local',
|
|
851
|
-
{
|
|
852
|
-
controlId,
|
|
853
|
-
args,
|
|
854
|
-
context,
|
|
855
|
-
},
|
|
856
|
-
180_000
|
|
857
|
-
);
|
|
858
|
-
const lookup = type === 'status' || type === 'read' || type === 'cancel' || type === 'close';
|
|
859
|
-
if (lookup && /^Error:/i.test(String(value || ''))) {
|
|
860
|
-
for (const alternate of this.liveShards()) {
|
|
861
|
-
if (alternate === target) continue;
|
|
862
|
-
const candidate = await alternate.request(
|
|
863
|
-
'agent-control-local',
|
|
864
|
-
{
|
|
865
|
-
controlId: `${controlId}:${alternate.index}`,
|
|
866
|
-
args,
|
|
867
|
-
context,
|
|
868
|
-
},
|
|
869
|
-
180_000
|
|
870
|
-
);
|
|
871
|
-
if (/^Error:/i.test(String(candidate || ''))) continue;
|
|
872
|
-
value = candidate;
|
|
873
|
-
this.rememberAgentControlResult(alternate.index, args, context, value);
|
|
874
|
-
return value;
|
|
875
|
-
}
|
|
876
|
-
}
|
|
877
|
-
this.rememberAgentControlResult(target.index, args, context, value);
|
|
878
|
-
return value;
|
|
879
|
-
} finally {
|
|
880
|
-
this.agentControlOwners.delete(controlId);
|
|
881
|
-
}
|
|
882
|
-
}
|
|
883
|
-
|
|
884
|
-
handleAgentControl(originShard, originChild, message) {
|
|
885
|
-
const controlId = String(message?.controlId || '');
|
|
886
|
-
if (!controlId) return;
|
|
887
|
-
const controller = new AbortController();
|
|
888
|
-
this.agentControlRuns.set(controlId, controller);
|
|
889
|
-
const context = {
|
|
890
|
-
...(message.context || {}),
|
|
891
|
-
signal: controller.signal,
|
|
892
|
-
};
|
|
893
|
-
const ownerSessionId = String(context?.callerSessionId || '');
|
|
894
|
-
if (ownerSessionId) {
|
|
895
|
-
this.agentOwnerOrigins.set(ownerSessionId, originShard.index);
|
|
896
|
-
}
|
|
897
|
-
const execution = this.executeCanonicalAgentControl
|
|
898
|
-
? this.executeCanonicalAgentControl(message.args || {}, context)
|
|
899
|
-
: Promise.reject(new Error('canonical Agent control is unavailable'));
|
|
900
|
-
void Promise.resolve(execution)
|
|
901
|
-
.then((value) => {
|
|
902
|
-
if (originShard.child !== originChild || originChild?.killed) return;
|
|
903
|
-
safeIpcSend(
|
|
904
|
-
originChild,
|
|
905
|
-
{
|
|
906
|
-
type: 'agent-control-result',
|
|
907
|
-
controlId,
|
|
908
|
-
ok: true,
|
|
909
|
-
value,
|
|
910
|
-
},
|
|
911
|
-
{ onError: () => {} }
|
|
912
|
-
);
|
|
913
|
-
})
|
|
914
|
-
.catch((error) => {
|
|
915
|
-
if (originShard.child !== originChild || originChild?.killed) return;
|
|
916
|
-
safeIpcSend(
|
|
917
|
-
originChild,
|
|
918
|
-
{
|
|
919
|
-
type: 'agent-control-result',
|
|
920
|
-
controlId,
|
|
921
|
-
ok: false,
|
|
922
|
-
error: {
|
|
923
|
-
name: String(error?.name || 'Error'),
|
|
924
|
-
message: String(error?.message || error || 'agent control failed'),
|
|
925
|
-
stack: typeof error?.stack === 'string' ? error.stack : null,
|
|
926
|
-
code: error?.code || null,
|
|
927
|
-
},
|
|
928
|
-
},
|
|
929
|
-
{ onError: () => {} }
|
|
930
|
-
);
|
|
931
|
-
})
|
|
932
|
-
.finally(() => {
|
|
933
|
-
this.agentControlRuns.delete(controlId);
|
|
934
|
-
});
|
|
935
|
-
}
|
|
936
|
-
|
|
937
|
-
cancelAgentControl(message) {
|
|
938
|
-
const controlId = String(message?.controlId || '');
|
|
939
|
-
const canonical = this.agentControlRuns.get(controlId);
|
|
940
|
-
if (canonical) {
|
|
941
|
-
try {
|
|
942
|
-
canonical.abort(new Error(String(message?.reason || 'agent control canceled')));
|
|
943
|
-
} catch {}
|
|
944
|
-
return true;
|
|
945
|
-
}
|
|
946
|
-
const index = this.agentControlOwners.get(controlId);
|
|
947
|
-
if (index == null) return false;
|
|
948
|
-
const shard = this.shardAt(index);
|
|
949
|
-
void shard
|
|
950
|
-
.request(
|
|
951
|
-
'agent-control-local-cancel',
|
|
952
|
-
{
|
|
953
|
-
controlId,
|
|
954
|
-
reason: String(message?.reason || 'agent control canceled'),
|
|
955
|
-
},
|
|
956
|
-
5_000
|
|
957
|
-
)
|
|
958
|
-
.catch(() => {});
|
|
959
|
-
return true;
|
|
960
|
-
}
|
|
961
|
-
|
|
962
|
-
routeAgentControlNotification(message) {
|
|
963
|
-
const ownerSessionId = String(message?.ownerSessionId || '');
|
|
964
|
-
if (!ownerSessionId) return false;
|
|
965
|
-
const index = this.agentOwnerOrigins.get(ownerSessionId) ?? this.ownership.peek(ownerSessionId);
|
|
966
|
-
if (index == null) return false;
|
|
967
|
-
return this.shardAt(index).sendAgentControlNotification(message);
|
|
968
|
-
}
|
|
969
|
-
|
|
970
533
|
async prewarm() {
|
|
971
534
|
this.prewarmRequested = true;
|
|
972
535
|
// Shard 0 always exists: its readiness is the daemon's prewarm contract.
|
|
@@ -1145,25 +708,20 @@ export function createSessionRuntimeHost({
|
|
|
1145
708
|
throw new Error('canonical Agent control is unavailable');
|
|
1146
709
|
},
|
|
1147
710
|
notifySessionCompletion(ownerSessionId, text, meta = {}) {
|
|
1148
|
-
return pool.routeAgentControlNotification({
|
|
711
|
+
return pool.agentControl.routeAgentControlNotification({
|
|
1149
712
|
ownerSessionId: String(ownerSessionId || ''),
|
|
1150
713
|
text: String(text || ''),
|
|
1151
714
|
meta,
|
|
1152
715
|
});
|
|
1153
716
|
},
|
|
1154
|
-
async agentSessionAction(
|
|
1155
|
-
void sessionId;
|
|
1156
|
-
void action;
|
|
1157
|
-
void args;
|
|
717
|
+
async agentSessionAction(_sessionId, _action, _args = []) {
|
|
1158
718
|
throw new Error('Agent sessions are owned by the canonical session service');
|
|
1159
719
|
},
|
|
1160
720
|
refreshRuntimeWorkload,
|
|
1161
|
-
subscribeAgentSessionStates(
|
|
1162
|
-
void listener;
|
|
721
|
+
subscribeAgentSessionStates(_listener) {
|
|
1163
722
|
return () => {};
|
|
1164
723
|
},
|
|
1165
|
-
agentSessionState(
|
|
1166
|
-
void sessionId;
|
|
724
|
+
agentSessionState(_sessionId) {
|
|
1167
725
|
return null;
|
|
1168
726
|
},
|
|
1169
727
|
get workloads() {
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// The in-process host's telemetry shapes. Both mirror the multi-shard host's
|
|
2
|
+
// wire shape with a single implicit shard (the daemon process itself), so a
|
|
3
|
+
// caller reads one workload/status contract regardless of host mode.
|
|
4
|
+
|
|
5
|
+
export function inlineWorkloads(runtimes) {
|
|
6
|
+
const memory = process.memoryUsage();
|
|
7
|
+
return {
|
|
8
|
+
mode: 'in-process',
|
|
9
|
+
refreshedAt: Date.now(),
|
|
10
|
+
shardCount: 0,
|
|
11
|
+
shards: [],
|
|
12
|
+
worker: {
|
|
13
|
+
pid: process.pid,
|
|
14
|
+
runtimes,
|
|
15
|
+
memory: {
|
|
16
|
+
rss: memory.rss,
|
|
17
|
+
heapTotal: memory.heapTotal,
|
|
18
|
+
heapUsed: memory.heapUsed,
|
|
19
|
+
external: memory.external,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function inlineStatus(runtimes, active) {
|
|
26
|
+
return {
|
|
27
|
+
mode: 'in-process',
|
|
28
|
+
active,
|
|
29
|
+
worker: {
|
|
30
|
+
pid: process.pid,
|
|
31
|
+
pids: [process.pid],
|
|
32
|
+
runtimes,
|
|
33
|
+
},
|
|
34
|
+
shards: [],
|
|
35
|
+
shardCount: 0,
|
|
36
|
+
providerCooldown: null,
|
|
37
|
+
};
|
|
38
|
+
}
|