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
|
@@ -11,6 +11,15 @@ export { hasGrokOAuthCredentials } from '../agent/orchestrator/providers/oauth-c
|
|
|
11
11
|
|
|
12
12
|
const XAI_BASE_URL = 'https://api.x.ai/v1';
|
|
13
13
|
|
|
14
|
+
// Built here rather than with lanes.mjs's mediaError: importing it would close
|
|
15
|
+
// an auth -> lanes -> catalog -> auth module cycle.
|
|
16
|
+
function unauthenticated(message) {
|
|
17
|
+
const err = new Error(message);
|
|
18
|
+
err.code = 'MEDIA_LANE_UNAUTHENTICATED';
|
|
19
|
+
err.status = 401;
|
|
20
|
+
return err;
|
|
21
|
+
}
|
|
22
|
+
|
|
14
23
|
/**
|
|
15
24
|
* Bearer for the xAI media endpoints. `grok-oauth` refreshes through the chat
|
|
16
25
|
* provider; `xai` uses the stored API key. Both hit the same api.x.ai routes.
|
|
@@ -18,18 +27,17 @@ const XAI_BASE_URL = 'https://api.x.ai/v1';
|
|
|
18
27
|
export async function resolveXaiAuth(laneId) {
|
|
19
28
|
if (laneId === 'xai') {
|
|
20
29
|
const key = getAgentApiKey('xai');
|
|
21
|
-
if (!key)
|
|
22
|
-
const err = new Error('xAI API key is not configured');
|
|
23
|
-
err.code = 'MEDIA_LANE_UNAUTHENTICATED';
|
|
24
|
-
err.status = 401;
|
|
25
|
-
throw err;
|
|
26
|
-
}
|
|
30
|
+
if (!key) throw unauthenticated('xAI API key is not configured');
|
|
27
31
|
return { baseURL: XAI_BASE_URL, token: key };
|
|
28
32
|
}
|
|
29
33
|
const { GrokOAuthProvider } = await import('../agent/orchestrator/providers/grok-oauth.mjs');
|
|
30
34
|
const provider = new GrokOAuthProvider({});
|
|
31
35
|
const tokens = await provider.ensureAuth();
|
|
32
|
-
|
|
36
|
+
// The bearer rotates on every refresh, so it cannot identify this credential
|
|
37
|
+
// across sessions. The account id can, exactly like Antigravity's Cloud
|
|
38
|
+
// project: without it the catalog cache re-keyed on each refresh, re-fetched
|
|
39
|
+
// on every Studio entry, and lost its own offline fallback.
|
|
40
|
+
return { baseURL: XAI_BASE_URL, token: tokens.access_token, accountId: tokens.user_id || '' };
|
|
33
41
|
}
|
|
34
42
|
|
|
35
43
|
/** Codex (ChatGPT OAuth) auth record: access token + account id for headers. */
|
|
@@ -53,11 +61,6 @@ export async function resolveAntigravityAuth() {
|
|
|
53
61
|
|
|
54
62
|
export function resolveGeminiKey() {
|
|
55
63
|
const key = getAgentApiKey('gemini');
|
|
56
|
-
if (!key)
|
|
57
|
-
const err = new Error('Gemini API key is not configured');
|
|
58
|
-
err.code = 'MEDIA_LANE_UNAUTHENTICATED';
|
|
59
|
-
err.status = 401;
|
|
60
|
-
throw err;
|
|
61
|
-
}
|
|
64
|
+
if (!key) throw unauthenticated('Gemini API key is not configured');
|
|
62
65
|
return key;
|
|
63
66
|
}
|
|
@@ -34,10 +34,15 @@ function googleLane(lane) {
|
|
|
34
34
|
return lane === 'gemini' || lane === 'antigravity-oauth';
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
// Both xAI lanes (stored API key and Grok OAuth) speak the same Imagine catalog.
|
|
38
|
+
function grokLane(lane) {
|
|
39
|
+
return lane === 'xai' || lane === 'grok-oauth';
|
|
40
|
+
}
|
|
41
|
+
|
|
37
42
|
function kindFor(lane, row, id) {
|
|
38
43
|
if (row.deprecated === true || row.disabled === true) return null;
|
|
39
44
|
if (lane === 'openai-oauth') return imageToolSupported(row, id) ? 'image' : null;
|
|
40
|
-
if (lane
|
|
45
|
+
if (grokLane(lane)) {
|
|
41
46
|
if (/^grok-imagine-image(?:-|$)/.test(id)) return 'image';
|
|
42
47
|
// This version requires a start image. Studio also permits prompt-only
|
|
43
48
|
// generation, so keep it out until the required-input contract is exposed.
|
|
@@ -79,7 +84,7 @@ function compareModels(a, b) {
|
|
|
79
84
|
/** Keep official tiers and generations intact; never infer a quality ranking. */
|
|
80
85
|
function mediaModelLabel(lane, row, id) {
|
|
81
86
|
let label = String(row.displayName || row.display || row.label || row.name || id).replace(/^models\//, '');
|
|
82
|
-
if (lane
|
|
87
|
+
if (grokLane(lane)) {
|
|
83
88
|
label = id
|
|
84
89
|
.replace(/^grok-imagine-image/, 'Grok Imagine Image')
|
|
85
90
|
.replace(/^grok-imagine-video/, 'Grok Imagine Video')
|
|
@@ -112,7 +117,7 @@ export function projectMediaModels(lane, rows) {
|
|
|
112
117
|
const kind = kindFor(lane, row, id);
|
|
113
118
|
if (!kind) continue;
|
|
114
119
|
let controls = {};
|
|
115
|
-
if ((lane
|
|
120
|
+
if (grokLane(lane) && kind === 'video') {
|
|
116
121
|
controls = { resolution: ['480p', '720p'] };
|
|
117
122
|
} else if (lane === 'gemini' && /^gemini-omni-/.test(id)) {
|
|
118
123
|
controls = { resolution: [], durations: [], maxReferences: 3 };
|
|
@@ -177,10 +182,13 @@ async function providerSource(lane) {
|
|
|
177
182
|
else if (lane === 'antigravity-oauth') auth = await resolveAntigravityAuth();
|
|
178
183
|
else auth = await resolveXaiAuth(lane);
|
|
179
184
|
// API-key and OAuth catalogs must not leak availability across credentials.
|
|
180
|
-
// Persist only a one-way scope hash, never a key or a bearer.
|
|
181
|
-
//
|
|
185
|
+
// Persist only a one-way scope hash, never a key or a bearer. OAuth bearers
|
|
186
|
+
// rotate (Antigravity hourly, Grok on every refresh), so they must never be
|
|
187
|
+
// the scope: a rotating key means a permanent cache miss AND a stale-cache
|
|
188
|
+
// fallback that can no longer find its own previous catalog. The stable
|
|
189
|
+
// account identity — Cloud project or account id — plays that role instead.
|
|
182
190
|
const scope = createHash('sha256')
|
|
183
|
-
.update(auth.projectId || auth.token)
|
|
191
|
+
.update(auth.projectId || auth.accountId || auth.token)
|
|
184
192
|
.digest('hex')
|
|
185
193
|
.slice(0, 24);
|
|
186
194
|
return {
|
|
@@ -17,8 +17,9 @@ import {
|
|
|
17
17
|
} from '../agent/orchestrator/providers/oauth-credential-probes.mjs';
|
|
18
18
|
import { loadMediaModels, projectMediaModels } from './catalog.mjs';
|
|
19
19
|
import { catalogDiagnostic } from './catalog-errors.mjs';
|
|
20
|
+
import { MEDIA_KINDS } from './tool-defs.mjs';
|
|
20
21
|
|
|
21
|
-
export
|
|
22
|
+
export { MEDIA_KINDS };
|
|
22
23
|
|
|
23
24
|
// Aspect/resolution vocabularies are lane-native: xAI takes aspect_ratio +
|
|
24
25
|
// resolution, Gemini/Codex take pixel sizes. The UI renders whatever the lane
|
|
@@ -31,7 +31,7 @@ import { TOOL_DEFS } from './tool-defs.mjs';
|
|
|
31
31
|
|
|
32
32
|
// Static import (not the dynamic one in stop()) so the sync stop is available
|
|
33
33
|
// inside a process 'exit' hook, where dynamic import() cannot run.
|
|
34
|
-
import { stopPgForShutdownSync } from './lib/pg/supervisor.mjs';
|
|
34
|
+
import { stopPgForShutdown, stopPgForShutdownSync } from './lib/pg/supervisor.mjs';
|
|
35
35
|
|
|
36
36
|
import {
|
|
37
37
|
openDatabase,
|
|
@@ -51,7 +51,6 @@ import {
|
|
|
51
51
|
shutdownEmbeddingProvider,
|
|
52
52
|
warmupEmbeddingProvider,
|
|
53
53
|
} from './lib/embedding-provider.mjs';
|
|
54
|
-
import { startLlmWorker, stopLlmWorker } from './lib/llm-worker-host.mjs';
|
|
55
54
|
import { runCycle1, runCycle2, parseInterval, flushEmbeddingDirty, flushRawEmbeddings } from './lib/memory-cycle.mjs';
|
|
56
55
|
import { callAgentDispatch } from './lib/agent-ipc.mjs';
|
|
57
56
|
import {
|
|
@@ -139,12 +138,11 @@ import {
|
|
|
139
138
|
} from '../shared/service-discovery.mjs';
|
|
140
139
|
|
|
141
140
|
const MEMORY_SERVER_PID = parsePositivePid(process.env.MIXDOG_SERVER_PID) ?? process.pid;
|
|
142
|
-
const _isPidAliveLocal = isPidAliveLocal;
|
|
143
141
|
const _memoryPortAdvertiser = createMemoryPortAdvertiser({
|
|
144
142
|
readServiceAdvert: _readServiceAdvert,
|
|
145
143
|
writeServiceAdvert: _writeServiceAdvert,
|
|
146
144
|
parsePositivePid,
|
|
147
|
-
isPidAliveLocal
|
|
145
|
+
isPidAliveLocal,
|
|
148
146
|
memoryServerPid: MEMORY_SERVER_PID,
|
|
149
147
|
log: __mixdogMemoryLog,
|
|
150
148
|
});
|
|
@@ -157,7 +155,7 @@ const _daemonLifecycle = createMemoryDaemonLifecycle({
|
|
|
157
155
|
idleTtlMs: MEMORY_IDLE_TTL_MS,
|
|
158
156
|
clientGraceMs: MEMORY_CLIENT_GRACE_MS,
|
|
159
157
|
parsePositivePid,
|
|
160
|
-
isPidAlive:
|
|
158
|
+
isPidAlive: isPidAliveLocal,
|
|
161
159
|
isStopping: () => _serviceLifecycle.isStopping(),
|
|
162
160
|
stop,
|
|
163
161
|
log: __mixdogMemoryLog,
|
|
@@ -318,9 +316,7 @@ async function _initStore() {
|
|
|
318
316
|
if (!(await isBootstrapComplete(db))) {
|
|
319
317
|
throw new Error('memory-service: bootstrap not complete after openDatabase');
|
|
320
318
|
}
|
|
321
|
-
if (memoryLlmWorkerEnabled()) {
|
|
322
|
-
startLlmWorker();
|
|
323
|
-
} else {
|
|
319
|
+
if (!memoryLlmWorkerEnabled()) {
|
|
324
320
|
__mixdogMemoryLog('[memory-service] secondary mode; skipping llm worker\n');
|
|
325
321
|
}
|
|
326
322
|
// Provider/session/agent modules live once in the daemon. Memory
|
|
@@ -673,7 +669,7 @@ async function _stopBackgroundWork() {
|
|
|
673
669
|
_stopCycles();
|
|
674
670
|
_embeddingReindexController?.abort(new Error('memory service stopping'));
|
|
675
671
|
const reindexPromise = _embeddingReindexPromise;
|
|
676
|
-
await Promise.allSettled([
|
|
672
|
+
await Promise.allSettled([reindexPromise]);
|
|
677
673
|
await shutdownEmbeddingProvider();
|
|
678
674
|
}
|
|
679
675
|
|
|
@@ -689,7 +685,6 @@ async function _stopRuntime() {
|
|
|
689
685
|
// closeDatabase() only ends the client pool; without this the child
|
|
690
686
|
// postmaster keeps running after the unified daemon exits.
|
|
691
687
|
if (!memorySecondaryMode()) {
|
|
692
|
-
const { stopPgForShutdown } = await import('./lib/pg/supervisor.mjs');
|
|
693
688
|
await stopPgForShutdown();
|
|
694
689
|
} else {
|
|
695
690
|
__mixdogMemoryLog('[memory-service] secondary mode; leaving shared PG running\n');
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { __mixdogMemoryLog } from './memory-log.mjs';
|
|
2
|
-
export { __mixdogMemoryLog };
|
|
3
2
|
|
|
4
3
|
// User-curated core memory store — native PG-backed via core_entries table.
|
|
5
4
|
// Per-project entries distinguished by project_id column (NULL = COMMON).
|
|
@@ -7,13 +6,12 @@ export { __mixdogMemoryLog };
|
|
|
7
6
|
// Generated conversation history never enters this store automatically.
|
|
8
7
|
|
|
9
8
|
import { getDatabase, embeddingToSql } from './memory.mjs';
|
|
9
|
+
import { VALID_CATEGORY } from './memory-categories.mjs';
|
|
10
10
|
import { cachedEmbedTextBatch } from './memory-embed.mjs';
|
|
11
11
|
import { checkedConnect } from './pg/adapter.mjs';
|
|
12
12
|
import { throwIfAborted } from './memory-cycle2-shared.mjs';
|
|
13
13
|
import { findCoreKeyRows } from './core-memory-uniqueness.mjs';
|
|
14
14
|
|
|
15
|
-
const VALID_CAT = new Set(['rule', 'constraint', 'decision', 'fact', 'goal', 'preference', 'task', 'issue']);
|
|
16
|
-
|
|
17
15
|
const CORE_ELEMENT_DERIVE_LENGTH = 40;
|
|
18
16
|
|
|
19
17
|
// Op aliases: the surface verbs are add/edit/delete/list/…, and a caller
|
|
@@ -63,8 +61,8 @@ export function normalizeCoreInput(input = {}, options = {}) {
|
|
|
63
61
|
if (options.requireElement && !element) errors.push('element required');
|
|
64
62
|
if (options.requireSummary && !summary) errors.push('summary required');
|
|
65
63
|
if (options.requireCategory && !suppliedCategory) errors.push('category required');
|
|
66
|
-
if (suppliedCategory && !
|
|
67
|
-
errors.push(`invalid category "${category}". Valid: ${[...
|
|
64
|
+
if (suppliedCategory && !VALID_CATEGORY.has(category)) {
|
|
65
|
+
errors.push(`invalid category "${category}". Valid: ${[...VALID_CATEGORY].join(', ')}`);
|
|
68
66
|
}
|
|
69
67
|
|
|
70
68
|
return { element, summary, category, suppliedCategory, errors };
|
|
@@ -87,8 +85,6 @@ async function _embedFor(db, element, summary) {
|
|
|
87
85
|
// Lazy repair of NULL embeddings on existing rows. Runs once per boot or
|
|
88
86
|
// whenever a NULL slips back in via direct SQL. SELECT WHERE embedding IS NULL
|
|
89
87
|
// returns 0 rows on a fully-populated table, so this is a fast no-op.
|
|
90
|
-
export { throwIfAborted };
|
|
91
|
-
|
|
92
88
|
async function _backfillNullEmbeddings(db, options = {}) {
|
|
93
89
|
const signal = options?.signal;
|
|
94
90
|
throwIfAborted(signal);
|
|
@@ -53,14 +53,6 @@ export function embeddingWorkerExecArgv(execArgv = process.execArgv) {
|
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
function cacheEmbedding(key, vector) {
|
|
57
|
-
queryEmbeddingCache.set(key, vector);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function getCachedEmbedding(key) {
|
|
61
|
-
return queryEmbeddingCache.get(key);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
56
|
function embeddingCacheKey(text, inputType, dtype = _configuredDtype) {
|
|
65
57
|
return `${MODEL_ID}\n${dtype}\n${normalizeEmbeddingInputType(inputType)}\n${text}`;
|
|
66
58
|
}
|
|
@@ -307,7 +299,7 @@ export async function embedText(text, options = {}) {
|
|
|
307
299
|
const inputType = normalizeEmbeddingInputType(options?.inputType);
|
|
308
300
|
const dtype = _configuredDtype;
|
|
309
301
|
const cacheKey = embeddingCacheKey(clean, inputType, dtype);
|
|
310
|
-
const cached =
|
|
302
|
+
const cached = queryEmbeddingCache.get(cacheKey);
|
|
311
303
|
if (cached) return [...cached];
|
|
312
304
|
|
|
313
305
|
// Interactive query embeds pass { priority: true } so the worker can
|
|
@@ -331,7 +323,7 @@ export async function embedText(text, options = {}) {
|
|
|
331
323
|
if (!Array.isArray(vector) || vector.length !== cachedDims) {
|
|
332
324
|
throw new Error(`embed vector length mismatch: expected ${cachedDims}, got ${vector?.length}`);
|
|
333
325
|
}
|
|
334
|
-
|
|
326
|
+
queryEmbeddingCache.set(cacheKey, vector);
|
|
335
327
|
_embedCallCount++;
|
|
336
328
|
if (_embedCallCount % EMBED_STEADY_SAMPLE_EVERY === 0) {
|
|
337
329
|
writeProfilePoint({
|
|
@@ -365,11 +357,13 @@ export async function embedTexts(texts, options = {}) {
|
|
|
365
357
|
const key = embeddingCacheKey(t, inputType, dtype);
|
|
366
358
|
if (!queryEmbeddingCache.has(key)) missing.push(t);
|
|
367
359
|
}
|
|
368
|
-
|
|
369
|
-
|
|
360
|
+
const cachedResults = () =>
|
|
361
|
+
cleaned.map((t) => {
|
|
370
362
|
if (!t) return [];
|
|
371
|
-
|
|
363
|
+
const cached = queryEmbeddingCache.get(embeddingCacheKey(t, inputType, dtype));
|
|
364
|
+
return cached ? [...cached] : [];
|
|
372
365
|
});
|
|
366
|
+
if (missing.length === 0) return cachedResults();
|
|
373
367
|
const result = await sendToWorker('embed-batch', { texts: missing, inputType });
|
|
374
368
|
if (!result.dims) throw new Error(`embed-batch result missing dims (model=${MODEL_ID})`);
|
|
375
369
|
const resultDims = result.dims;
|
|
@@ -389,14 +383,10 @@ export async function embedTexts(texts, options = {}) {
|
|
|
389
383
|
if (!Array.isArray(vec) || vec.length !== cachedDims) {
|
|
390
384
|
throw new Error(`embed-batch vector length mismatch at idx ${i}: expected ${cachedDims}, got ${vec?.length}`);
|
|
391
385
|
}
|
|
392
|
-
|
|
386
|
+
queryEmbeddingCache.set(embeddingCacheKey(missing[i], inputType, dtype), vec);
|
|
393
387
|
}
|
|
394
388
|
_embedCallCount += missing.length;
|
|
395
|
-
return
|
|
396
|
-
if (!t) return [];
|
|
397
|
-
const cached = queryEmbeddingCache.get(embeddingCacheKey(t, inputType, dtype));
|
|
398
|
-
return cached ? [...cached] : [];
|
|
399
|
-
});
|
|
389
|
+
return cachedResults();
|
|
400
390
|
}
|
|
401
391
|
|
|
402
392
|
export async function shutdownEmbeddingProvider() {
|
|
@@ -206,6 +206,26 @@ async function disposeLoadedExtractor(reason) {
|
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
+
function cancelIdleTimer() {
|
|
210
|
+
if (!_idleTimer) return;
|
|
211
|
+
clearTimeout(_idleTimer);
|
|
212
|
+
_idleTimer = null;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// Tear down the loaded extractor for a control op (configure/dispose). Both
|
|
216
|
+
// hold the in-flight guard, so no inference can observe the reset mid-flight.
|
|
217
|
+
async function disposeExtractorForControlOp() {
|
|
218
|
+
if (!extractorPromise) return;
|
|
219
|
+
try {
|
|
220
|
+
const ext = await extractorPromise;
|
|
221
|
+
try {
|
|
222
|
+
ext.dispose();
|
|
223
|
+
} catch {}
|
|
224
|
+
} catch {}
|
|
225
|
+
extractorPromise = null;
|
|
226
|
+
_device = 'cpu';
|
|
227
|
+
}
|
|
228
|
+
|
|
209
229
|
function resetIdleTimer() {
|
|
210
230
|
if (_idleTimer) clearTimeout(_idleTimer);
|
|
211
231
|
if (IDLE_TIMEOUT_MS <= 0) return;
|
|
@@ -498,23 +518,11 @@ async function processMessage(msg) {
|
|
|
498
518
|
return;
|
|
499
519
|
}
|
|
500
520
|
_embedInFlight = true;
|
|
501
|
-
|
|
502
|
-
clearTimeout(_idleTimer);
|
|
503
|
-
_idleTimer = null;
|
|
504
|
-
}
|
|
521
|
+
cancelIdleTimer();
|
|
505
522
|
if (msg.dtype != null) {
|
|
506
523
|
configuredDtype = normalizeEmbeddingDtype(MODEL_ID, msg.dtype);
|
|
507
524
|
}
|
|
508
|
-
|
|
509
|
-
try {
|
|
510
|
-
const ext = await extractorPromise;
|
|
511
|
-
try {
|
|
512
|
-
ext.dispose();
|
|
513
|
-
} catch {}
|
|
514
|
-
} catch {}
|
|
515
|
-
extractorPromise = null;
|
|
516
|
-
_device = 'cpu';
|
|
517
|
-
}
|
|
525
|
+
await disposeExtractorForControlOp();
|
|
518
526
|
parentPort.postMessage({ id, type: 'result' });
|
|
519
527
|
break;
|
|
520
528
|
}
|
|
@@ -524,21 +532,9 @@ async function processMessage(msg) {
|
|
|
524
532
|
return;
|
|
525
533
|
}
|
|
526
534
|
_embedInFlight = true;
|
|
527
|
-
|
|
528
|
-
clearTimeout(_idleTimer);
|
|
529
|
-
_idleTimer = null;
|
|
530
|
-
}
|
|
535
|
+
cancelIdleTimer();
|
|
531
536
|
const prevDevice = _device;
|
|
532
|
-
|
|
533
|
-
try {
|
|
534
|
-
const ext = await extractorPromise;
|
|
535
|
-
try {
|
|
536
|
-
ext.dispose();
|
|
537
|
-
} catch {}
|
|
538
|
-
} catch {}
|
|
539
|
-
extractorPromise = null;
|
|
540
|
-
_device = 'cpu';
|
|
541
|
-
}
|
|
537
|
+
await disposeExtractorForControlOp();
|
|
542
538
|
parentPort.postMessage({ id, type: 'result', prevDevice, dtype: configuredDtype });
|
|
543
539
|
break;
|
|
544
540
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { readBody, sendJson, normalizeCoreProjectId } from '../http-wire.mjs';
|
|
7
7
|
import { listCore, addCore, deleteCore } from '../core-memory-store.mjs';
|
|
8
|
-
import {
|
|
8
|
+
import { createAdminTraceRoutes } from './admin-trace-routes.mjs';
|
|
9
9
|
|
|
10
10
|
// One admin route: any thrown error becomes `{ ok:false, error }` 500.
|
|
11
11
|
const guarded = (handle) => async (req, res) => {
|
|
@@ -128,55 +128,9 @@ export function createAdminRoutes({
|
|
|
128
128
|
sendJson(res, { ok: true, deleted: preCount, core_preserved: coreCount });
|
|
129
129
|
});
|
|
130
130
|
|
|
131
|
-
//
|
|
132
|
-
//
|
|
133
|
-
const
|
|
134
|
-
const existing = getTraceDb();
|
|
135
|
-
if (existing) return existing;
|
|
136
|
-
const traceDb = await openTraceDatabase(dataDir);
|
|
137
|
-
if (!traceDb) return null;
|
|
138
|
-
setTraceDb(traceDb);
|
|
139
|
-
registerTraceExitDrain(traceDb);
|
|
140
|
-
return traceDb;
|
|
141
|
-
};
|
|
142
|
-
const traceRecord = async (req, res) => {
|
|
143
|
-
let body;
|
|
144
|
-
try {
|
|
145
|
-
body = await readBody(req);
|
|
146
|
-
} catch (e) {
|
|
147
|
-
sendJson(res, { ok: false, error: e.message }, 400);
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
if (!Array.isArray(body?.events)) {
|
|
151
|
-
sendJson(res, { ok: false, error: 'body.events must be an array' }, 400);
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
if (body.events.length > 500) {
|
|
155
|
-
sendJson(res, { ok: false, error: 'too many events (max 500)' }, 413);
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
let traceDb;
|
|
159
|
-
try {
|
|
160
|
-
traceDb = await openTraceDb();
|
|
161
|
-
} catch (e) {
|
|
162
|
-
sendJson(res, { ok: false, error: `trace DB unavailable: ${e.message}` }, 503);
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
if (!traceDb) {
|
|
166
|
-
sendJson(res, { ok: true, queued: 0, disabled: true });
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
try {
|
|
170
|
-
// Enqueue for async batched flush (100ms / 500-row window).
|
|
171
|
-
enqueueTraceEvents(traceDb, body.events);
|
|
172
|
-
// Use `queued` — events are async; `inserted` would imply durability.
|
|
173
|
-
sendJson(res, { ok: true, queued: body.events.length });
|
|
174
|
-
// Fire-and-forget into focused agent analytic tables.
|
|
175
|
-
insertAgentCalls(traceDb, body.events).catch((e) => log(`[trace] insertAgentCalls error: ${e?.message}\n`));
|
|
176
|
-
} catch (e) {
|
|
177
|
-
sendJson(res, { ok: false, error: e.message }, 500);
|
|
178
|
-
}
|
|
179
|
-
};
|
|
131
|
+
// /admin/trace-record and its lazily opened database
|
|
132
|
+
// (admin-trace-routes.mjs).
|
|
133
|
+
const traceRoutes = createAdminTraceRoutes({ dataDir, log, getTraceDb, setTraceDb });
|
|
180
134
|
|
|
181
135
|
const shutdown = (_req, res) => {
|
|
182
136
|
sendJson(res, { shutting_down: true }, 202);
|
|
@@ -207,7 +161,7 @@ export function createAdminRoutes({
|
|
|
207
161
|
'POST /admin/entries/add': addEntry,
|
|
208
162
|
'POST /admin/backfill': backfill,
|
|
209
163
|
'POST /admin/purge': purge,
|
|
210
|
-
|
|
164
|
+
...traceRoutes,
|
|
211
165
|
'POST /admin/shutdown': shutdown,
|
|
212
166
|
};
|
|
213
167
|
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* http-router/admin-trace-routes.mjs — the /admin/trace-record surface: the
|
|
3
|
+
* trace database opened lazily on the first record (and left null when tracing
|
|
4
|
+
* is disabled for this data dir), the request validation and batch size cap,
|
|
5
|
+
* the async batched enqueue, and the fire-and-forget agent-analytics insert.
|
|
6
|
+
*
|
|
7
|
+
* The database handle itself belongs to the server, which passes the
|
|
8
|
+
* getTraceDb/setTraceDb accessors, so the exit drain is registered once.
|
|
9
|
+
*/
|
|
10
|
+
import { readBody, sendJson } from '../http-wire.mjs';
|
|
11
|
+
import { openTraceDatabase, insertAgentCalls, enqueueTraceEvents, registerTraceExitDrain } from '../trace-store.mjs';
|
|
12
|
+
|
|
13
|
+
export function createAdminTraceRoutes({ dataDir, log, getTraceDb, setTraceDb }) {
|
|
14
|
+
// The trace DB opens lazily on the first record; null means tracing is
|
|
15
|
+
// disabled for this data dir.
|
|
16
|
+
const openTraceDb = async () => {
|
|
17
|
+
const existing = getTraceDb();
|
|
18
|
+
if (existing) return existing;
|
|
19
|
+
const traceDb = await openTraceDatabase(dataDir);
|
|
20
|
+
if (!traceDb) return null;
|
|
21
|
+
setTraceDb(traceDb);
|
|
22
|
+
registerTraceExitDrain(traceDb);
|
|
23
|
+
return traceDb;
|
|
24
|
+
};
|
|
25
|
+
const traceRecord = async (req, res) => {
|
|
26
|
+
let body;
|
|
27
|
+
try {
|
|
28
|
+
body = await readBody(req);
|
|
29
|
+
} catch (e) {
|
|
30
|
+
sendJson(res, { ok: false, error: e.message }, 400);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (!Array.isArray(body?.events)) {
|
|
34
|
+
sendJson(res, { ok: false, error: 'body.events must be an array' }, 400);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (body.events.length > 500) {
|
|
38
|
+
sendJson(res, { ok: false, error: 'too many events (max 500)' }, 413);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
let traceDb;
|
|
42
|
+
try {
|
|
43
|
+
traceDb = await openTraceDb();
|
|
44
|
+
} catch (e) {
|
|
45
|
+
sendJson(res, { ok: false, error: `trace DB unavailable: ${e.message}` }, 503);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (!traceDb) {
|
|
49
|
+
sendJson(res, { ok: true, queued: 0, disabled: true });
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
// Enqueue for async batched flush (100ms / 500-row window).
|
|
54
|
+
enqueueTraceEvents(traceDb, body.events);
|
|
55
|
+
// Use `queued` — events are async; `inserted` would imply durability.
|
|
56
|
+
sendJson(res, { ok: true, queued: body.events.length });
|
|
57
|
+
// Fire-and-forget into focused agent analytic tables.
|
|
58
|
+
insertAgentCalls(traceDb, body.events).catch((e) => log(`[trace] insertAgentCalls error: ${e?.message}\n`));
|
|
59
|
+
} catch (e) {
|
|
60
|
+
sendJson(res, { ok: false, error: e.message }, 500);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
return { 'POST /admin/trace-record': traceRecord };
|
|
65
|
+
}
|