mixdog 0.9.167 → 0.9.169
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/LICENSES/air-MIT.txt +21 -0
- package/LICENSES/ast-grep-MIT.txt +21 -0
- package/LICENSES/biome-MIT.txt +22 -0
- package/LICENSES/clang-format-Apache-2.0-WITH-LLVM-exception.txt +279 -0
- package/LICENSES/dprint-MIT.txt +21 -0
- package/LICENSES/gofumpt-BSD-3-Clause.txt +27 -0
- package/LICENSES/mago-MIT.txt +21 -0
- package/LICENSES/ruff-MIT.txt +430 -0
- package/LICENSES/shfmt-BSD-3-Clause.txt +27 -0
- package/LICENSES/stylua-MPL-2.0.txt +373 -0
- package/NOTICE.md +82 -0
- package/README.md +84 -11
- package/package.json +4 -2
- package/scripts/agent-lead-e2e-probe.mjs +66 -39
- package/scripts/agent-turn-trace-probe.mjs +68 -36
- package/scripts/audit-usage-ledger.mjs +102 -47
- package/scripts/build-tui.mjs +1 -4
- package/scripts/code-graph-description-contract.mjs +41 -30
- package/scripts/computer-task-cost-report.mjs +5 -19
- package/scripts/context-renewal-live-check.mjs +64 -24
- package/scripts/daemon-stub.mjs +66 -24
- package/scripts/dependency-lock-cache-key.mjs +15 -17
- package/scripts/embedding-quality-probe.mjs +42 -34
- package/scripts/fixtures/spawn-lease-fixture-worker.mjs +5 -1
- package/scripts/generate-runtime-manifest.mjs +37 -22
- package/scripts/graph-parity.mjs +1096 -0
- package/scripts/import-usage-ledger.mjs +5 -3
- package/scripts/lib/embedding-model-bench-core.mjs +126 -124
- package/scripts/lib/isolated-root-cleanup.mjs +11 -5
- package/scripts/lib/local-provider-live-scenarios.mjs +14 -5
- package/scripts/lib/recall-bench-eval.mjs +32 -18
- package/scripts/lib/stage-postgres-runtime-windows.ps1 +2 -2
- package/scripts/lib/test-timing-reporter.mjs +8 -2
- package/scripts/llm-trace-summary.mjs +48 -23
- package/scripts/local-provider-live-check.mjs +180 -79
- package/scripts/manifest-cache-key.mjs +16 -16
- package/scripts/media-image-live.mjs +123 -56
- package/scripts/memory-chunk-quality.mjs +120 -87
- package/scripts/memory-layer2-check.mjs +157 -104
- package/scripts/model-catalog-audit.mjs +22 -14
- package/scripts/mouse-probe.mjs +17 -3
- package/scripts/native-binary-arch.mjs +62 -50
- package/scripts/native-spawn-test-runtime.mjs +1 -1
- package/scripts/native-tool-download.mjs +61 -60
- package/scripts/office/aesthetics-probe.mjs +28 -7
- package/scripts/office/author-deck.mjs +48 -13
- package/scripts/office/build-pptx-icons.mjs +278 -12
- package/scripts/office-design-audit.mjs +16 -16
- package/scripts/office-live-test-plan.mjs +10 -1
- package/scripts/patch-replay.mjs +46 -16
- package/scripts/pdf-rotation-stress.mjs +8 -4
- package/scripts/perf/cold-reconnect-probe.mjs +78 -41
- package/scripts/perf/transcript-baseline.mjs +76 -47
- package/scripts/perf/transcript-runtime-probe.mjs +50 -24
- package/scripts/pg-memory-diet-apply.mjs +86 -56
- package/scripts/pg-memory-diet-verify.mjs +101 -60
- package/scripts/pg-memory-diet.mjs +208 -113
- package/scripts/prepare-native-assets.mjs +8 -19
- package/scripts/prune-desktop-runtime.mjs +136 -163
- package/scripts/prune-embedding-runtime.mjs +78 -90
- package/scripts/reduction-trace-report.mjs +18 -14
- package/scripts/release-paths.mjs +2 -12
- package/scripts/release-timing-report.mjs +38 -26
- package/scripts/routing-corpus.mjs +311 -102
- package/scripts/run-office-live-tests.mjs +4 -1
- package/scripts/runtime-dependency-cache-key.mjs +39 -39
- package/scripts/search-rg-parity.mjs +149 -97
- package/scripts/session-diag.mjs +30 -18
- package/scripts/session-sweep.mjs +235 -191
- package/scripts/smoke.mjs +9 -2
- package/scripts/suite-health.mjs +1 -2
- package/scripts/test.mjs +13 -5
- package/scripts/tidy/sync-engines-manifest.mjs +686 -0
- package/scripts/tool-efficiency-diag.mjs +36 -11
- package/scripts/tool-failures.mjs +68 -50
- package/scripts/tool-overhead-microbench.mjs +17 -11
- package/scripts/tool-stress.mjs +166 -57
- package/scripts/tui-frame-harness-shim.mjs +16 -6
- package/scripts/tui-frame-harness.mjs +171 -68
- package/scripts/tui-transcript-jitter-harness.mjs +0 -2
- package/scripts/verify-release-assets.mjs +25 -38
- package/src/app.mjs +24 -18
- package/src/cli.mjs +24 -19
- package/src/defaults/agents.json +1 -13
- package/src/defaults/skills/browser-use/SKILL.md +5 -3
- package/src/defaults/skills/code-tidy/SKILL.md +91 -0
- package/src/defaults/skills/computer-use/SKILL.md +21 -7
- package/src/defaults/skills/memory-management/SKILL.md +4 -5
- package/src/defaults/skills/pptx/scripts/qc-pages.mjs +107 -54
- package/src/defaults/skills/pptx/scripts/review-deck.mjs +102 -34
- package/src/defaults/skills/pptx/scripts/source-extract.mjs +6 -3
- package/src/defaults/skills/skill-creator/scripts/validate-skill.mjs +25 -27
- package/src/headless-command.mjs +22 -13
- package/src/headless-exec.mjs +272 -268
- package/src/headless-role.mjs +17 -31
- package/src/lib/keychain-cjs.cjs +410 -358
- package/src/lib/mixdog-debug.cjs +20 -14
- package/src/lib/output-style-meta.cjs +22 -13
- package/src/lib/rules-builder.cjs +46 -23
- package/src/lib/text-utils.cjs +44 -42
- package/src/repl.mjs +72 -57
- package/src/rules/agent/00-common.md +3 -0
- package/src/rules/agent/41-cycle2-agent.md +12 -32
- package/src/rules/lead/lead-brief.md +9 -13
- package/src/rules/shared/10-tool-workflow.md +11 -8
- package/src/rules/shared/30-exploration.md +4 -0
- package/src/rules/shared/80-memory.md +3 -3
- package/src/runtime/agent/orchestrator/activity-bus.mjs +5 -1
- package/src/runtime/agent/orchestrator/agent-owner.mjs +9 -4
- package/src/runtime/agent/orchestrator/agent-runtime/agent-dispatch.mjs +419 -382
- package/src/runtime/agent/orchestrator/agent-runtime/agent-progress-watchdog.mjs +215 -221
- package/src/runtime/agent/orchestrator/agent-runtime/cache-strategy.mjs +256 -255
- package/src/runtime/agent/orchestrator/agent-runtime/completion-text.mjs +9 -9
- package/src/runtime/agent/orchestrator/agent-runtime/maintenance-route.mjs +36 -36
- package/src/runtime/agent/orchestrator/agent-runtime/session-builder.mjs +108 -93
- package/src/runtime/agent/orchestrator/agent-runtime/title-completion.mjs +54 -48
- package/src/runtime/agent/orchestrator/agent-trace-format.mjs +702 -609
- package/src/runtime/agent/orchestrator/agent-trace-io.mjs +353 -330
- package/src/runtime/agent/orchestrator/agent-trace.mjs +295 -298
- package/src/runtime/agent/orchestrator/cache-break-trace.mjs +87 -86
- package/src/runtime/agent/orchestrator/cache-mtime.mjs +32 -21
- package/src/runtime/agent/orchestrator/config-presets.mjs +99 -63
- package/src/runtime/agent/orchestrator/config-storage.mjs +226 -194
- package/src/runtime/agent/orchestrator/config.mjs +343 -338
- package/src/runtime/agent/orchestrator/context/collect.mjs +19 -19
- package/src/runtime/agent/orchestrator/context/deferred-tools.mjs +180 -176
- package/src/runtime/agent/orchestrator/context/role-instructions.mjs +199 -194
- package/src/runtime/agent/orchestrator/context/skill-catalog.mjs +288 -288
- package/src/runtime/agent/orchestrator/context/skill-state.mjs +38 -30
- package/src/runtime/agent/orchestrator/dispatch-persist.mjs +52 -240
- package/src/runtime/agent/orchestrator/internal-agents.mjs +59 -58
- package/src/runtime/agent/orchestrator/internal-tools.mjs +57 -52
- package/src/runtime/agent/orchestrator/mcp/child-tree.mjs +222 -161
- package/src/runtime/agent/orchestrator/mcp/client.mjs +984 -904
- package/src/runtime/agent/orchestrator/mcp/reconnect-singleflight.mjs +21 -21
- package/src/runtime/agent/orchestrator/providers/account-pool.mjs +33 -17
- package/src/runtime/agent/orchestrator/providers/admission-scheduler.mjs +532 -513
- package/src/runtime/agent/orchestrator/providers/anthropic-betas.mjs +34 -32
- package/src/runtime/agent/orchestrator/providers/anthropic-effort.mjs +249 -237
- package/src/runtime/agent/orchestrator/providers/anthropic-fable-history.mjs +64 -55
- package/src/runtime/agent/orchestrator/providers/anthropic-fast-mode.mjs +32 -32
- package/src/runtime/agent/orchestrator/providers/anthropic-leaked-toolcall.mjs +297 -280
- package/src/runtime/agent/orchestrator/providers/anthropic-max-tokens.mjs +33 -33
- package/src/runtime/agent/orchestrator/providers/anthropic-messages.mjs +107 -96
- package/src/runtime/agent/orchestrator/providers/anthropic-model-resolve.mjs +117 -118
- package/src/runtime/agent/orchestrator/providers/anthropic-oauth-client-version.mjs +72 -67
- package/src/runtime/agent/orchestrator/providers/anthropic-oauth-credentials.mjs +564 -496
- package/src/runtime/agent/orchestrator/providers/anthropic-oauth.mjs +1262 -1138
- package/src/runtime/agent/orchestrator/providers/anthropic-server-fallback.mjs +24 -34
- package/src/runtime/agent/orchestrator/providers/anthropic-sse.mjs +1017 -915
- package/src/runtime/agent/orchestrator/providers/anthropic-thinking-contract.mjs +11 -7
- package/src/runtime/agent/orchestrator/providers/anthropic.mjs +745 -674
- package/src/runtime/agent/orchestrator/providers/antigravity-oauth-catalog.mjs +152 -153
- package/src/runtime/agent/orchestrator/providers/antigravity-oauth-login.mjs +361 -308
- package/src/runtime/agent/orchestrator/providers/antigravity-oauth-tokens.mjs +215 -204
- package/src/runtime/agent/orchestrator/providers/antigravity-oauth.mjs +443 -453
- package/src/runtime/agent/orchestrator/providers/antigravity-request.mjs +77 -65
- package/src/runtime/agent/orchestrator/providers/api-usage.mjs +99 -55
- package/src/runtime/agent/orchestrator/providers/codex-client-meta.mjs +59 -53
- package/src/runtime/agent/orchestrator/providers/compat-request-policy.mjs +9 -9
- package/src/runtime/agent/orchestrator/providers/cursor-auth.mjs +242 -215
- package/src/runtime/agent/orchestrator/providers/cursor-wire-guards.mjs +227 -221
- package/src/runtime/agent/orchestrator/providers/cursor-wire-interactions.mjs +68 -68
- package/src/runtime/agent/orchestrator/providers/cursor-wire-normalization.mjs +174 -156
- package/src/runtime/agent/orchestrator/providers/cursor-wire-protobuf.mjs +823 -827
- package/src/runtime/agent/orchestrator/providers/cursor-wire.mjs +1413 -1286
- package/src/runtime/agent/orchestrator/providers/cursor.mjs +614 -589
- package/src/runtime/agent/orchestrator/providers/custom-tool-wire.mjs +27 -19
- package/src/runtime/agent/orchestrator/providers/effort-configuration.mjs +120 -97
- package/src/runtime/agent/orchestrator/providers/gemini-cache.mjs +223 -231
- package/src/runtime/agent/orchestrator/providers/gemini-history-signatures.mjs +27 -21
- package/src/runtime/agent/orchestrator/providers/gemini-schema.mjs +752 -733
- package/src/runtime/agent/orchestrator/providers/gemini-stream.mjs +700 -628
- package/src/runtime/agent/orchestrator/providers/gemini-thinking.mjs +39 -39
- package/src/runtime/agent/orchestrator/providers/gemini.mjs +1055 -1002
- package/src/runtime/agent/orchestrator/providers/grok-oauth-login.mjs +149 -127
- package/src/runtime/agent/orchestrator/providers/grok-oauth-tokens.mjs +325 -268
- package/src/runtime/agent/orchestrator/providers/grok-oauth.mjs +444 -397
- package/src/runtime/agent/orchestrator/providers/lib/action-input-contract.mjs +29 -25
- package/src/runtime/agent/orchestrator/providers/lib/anthropic-image-input.mjs +101 -89
- package/src/runtime/agent/orchestrator/providers/lib/anthropic-native-blocks.mjs +7 -8
- package/src/runtime/agent/orchestrator/providers/lib/anthropic-replay-blocks.mjs +37 -36
- package/src/runtime/agent/orchestrator/providers/lib/anthropic-request-utils.mjs +387 -394
- package/src/runtime/agent/orchestrator/providers/lib/gemini-model-catalog.mjs +96 -92
- package/src/runtime/agent/orchestrator/providers/lib/grok-tool-schema.mjs +200 -176
- package/src/runtime/agent/orchestrator/providers/lib/oauth-pkce.mjs +20 -20
- package/src/runtime/agent/orchestrator/providers/lib/oauth-token-utils.mjs +22 -20
- package/src/runtime/agent/orchestrator/providers/lib/openai-tool-args.mjs +41 -42
- package/src/runtime/agent/orchestrator/providers/lib/provider-replay.mjs +40 -34
- package/src/runtime/agent/orchestrator/providers/lib/sse-framing.mjs +39 -39
- package/src/runtime/agent/orchestrator/providers/lib/stream-outcome.mjs +119 -90
- package/src/runtime/agent/orchestrator/providers/lib/wire-pairing.mjs +87 -81
- package/src/runtime/agent/orchestrator/providers/media-normalization.mjs +489 -421
- package/src/runtime/agent/orchestrator/providers/mixdog-local-wire.mjs +1 -3
- package/src/runtime/agent/orchestrator/providers/mixdog-local.mjs +24 -17
- package/src/runtime/agent/orchestrator/providers/model-cache.mjs +31 -23
- package/src/runtime/agent/orchestrator/providers/model-catalog-projection.mjs +106 -100
- package/src/runtime/agent/orchestrator/providers/model-catalog.mjs +562 -494
- package/src/runtime/agent/orchestrator/providers/model-list-sanitize.mjs +93 -39
- package/src/runtime/agent/orchestrator/providers/model-pricing-rates.mjs +50 -34
- package/src/runtime/agent/orchestrator/providers/model-service-tiers.mjs +8 -6
- package/src/runtime/agent/orchestrator/providers/oauth-credential-probes.mjs +117 -95
- package/src/runtime/agent/orchestrator/providers/oauth-usage.mjs +177 -147
- package/src/runtime/agent/orchestrator/providers/openai-codex-endpoints.mjs +1 -1
- package/src/runtime/agent/orchestrator/providers/openai-codex-metadata.mjs +186 -186
- package/src/runtime/agent/orchestrator/providers/openai-codex-model.mjs +80 -83
- package/src/runtime/agent/orchestrator/providers/openai-compat-chat-stream.mjs +317 -295
- package/src/runtime/agent/orchestrator/providers/openai-compat-presets.mjs +20 -20
- package/src/runtime/agent/orchestrator/providers/openai-compat-responses.mjs +183 -167
- package/src/runtime/agent/orchestrator/providers/openai-compat-stream-common.mjs +113 -111
- package/src/runtime/agent/orchestrator/providers/openai-compat-stream.mjs +579 -498
- package/src/runtime/agent/orchestrator/providers/openai-compat-trace.mjs +41 -43
- package/src/runtime/agent/orchestrator/providers/openai-compat-wire.mjs +367 -352
- package/src/runtime/agent/orchestrator/providers/openai-compat-xai.mjs +549 -476
- package/src/runtime/agent/orchestrator/providers/openai-compat.mjs +1132 -1106
- package/src/runtime/agent/orchestrator/providers/openai-direct-request.mjs +12 -12
- package/src/runtime/agent/orchestrator/providers/openai-oauth-catalog.mjs +81 -82
- package/src/runtime/agent/orchestrator/providers/openai-oauth-http-sse.mjs +1122 -1049
- package/src/runtime/agent/orchestrator/providers/openai-oauth-login.mjs +137 -124
- package/src/runtime/agent/orchestrator/providers/openai-oauth-tokens.mjs +257 -200
- package/src/runtime/agent/orchestrator/providers/openai-oauth-ws.mjs +1509 -1419
- package/src/runtime/agent/orchestrator/providers/openai-oauth.mjs +567 -564
- package/src/runtime/agent/orchestrator/providers/openai-responses-input.mjs +157 -158
- package/src/runtime/agent/orchestrator/providers/openai-responses-payload.mjs +197 -201
- package/src/runtime/agent/orchestrator/providers/openai-startup-prewarm.mjs +104 -100
- package/src/runtime/agent/orchestrator/providers/openai-transport-policy.mjs +76 -62
- package/src/runtime/agent/orchestrator/providers/openai-turn-state.mjs +37 -37
- package/src/runtime/agent/orchestrator/providers/openai-ws-delta.mjs +345 -336
- package/src/runtime/agent/orchestrator/providers/openai-ws-events.mjs +72 -66
- package/src/runtime/agent/orchestrator/providers/openai-ws-headers.mjs +92 -91
- package/src/runtime/agent/orchestrator/providers/openai-ws-pool.mjs +805 -665
- package/src/runtime/agent/orchestrator/providers/openai-ws-stream.mjs +1425 -1331
- package/src/runtime/agent/orchestrator/providers/openai-ws.mjs +229 -239
- package/src/runtime/agent/orchestrator/providers/opencode-go-usage.mjs +46 -34
- package/src/runtime/agent/orchestrator/providers/opencode-go.mjs +132 -140
- package/src/runtime/agent/orchestrator/providers/provider-catalog-cache.mjs +19 -11
- package/src/runtime/agent/orchestrator/providers/provider-model-identities.mjs +30 -27
- package/src/runtime/agent/orchestrator/providers/registry.mjs +383 -354
- package/src/runtime/agent/orchestrator/providers/retry-classifier.mjs +644 -537
- package/src/runtime/agent/orchestrator/providers/stream-json-pool.mjs +592 -567
- package/src/runtime/agent/orchestrator/providers/stream-json-worker.mjs +37 -37
- package/src/runtime/agent/orchestrator/providers/tool-stream-state.mjs +43 -46
- package/src/runtime/agent/orchestrator/providers/trace-utils.mjs +30 -30
- package/src/runtime/agent/orchestrator/session/abort-lookup.mjs +6 -6
- package/src/runtime/agent/orchestrator/session/agent-loop.mjs +508 -469
- package/src/runtime/agent/orchestrator/session/browser-snapshot-supersession.mjs +2 -2
- package/src/runtime/agent/orchestrator/session/cache/prefetch-cache.mjs +112 -94
- package/src/runtime/agent/orchestrator/session/cache/read-cache.mjs +260 -243
- package/src/runtime/agent/orchestrator/session/cache/scoped-cache-outcome.mjs +3 -3
- package/src/runtime/agent/orchestrator/session/cache/scoped-cache.mjs +400 -316
- package/src/runtime/agent/orchestrator/session/cache/util.mjs +45 -34
- package/src/runtime/agent/orchestrator/session/compact/budget.mjs +96 -83
- package/src/runtime/agent/orchestrator/session/compact/constants.mjs +20 -17
- package/src/runtime/agent/orchestrator/session/compact/continuation.mjs +33 -40
- package/src/runtime/agent/orchestrator/session/compact/execution-tail.mjs +117 -110
- package/src/runtime/agent/orchestrator/session/compact/messages.mjs +119 -123
- package/src/runtime/agent/orchestrator/session/compact/runner.mjs +427 -448
- package/src/runtime/agent/orchestrator/session/compact/summary-schema.mjs +223 -222
- package/src/runtime/agent/orchestrator/session/compact/summary.mjs +433 -441
- package/src/runtime/agent/orchestrator/session/compact/text-utils.mjs +217 -195
- package/src/runtime/agent/orchestrator/session/compact.mjs +19 -19
- package/src/runtime/agent/orchestrator/session/context-compaction-policy.mjs +136 -132
- package/src/runtime/agent/orchestrator/session/context-fingerprint.mjs +65 -45
- package/src/runtime/agent/orchestrator/session/context-utils.mjs +700 -682
- package/src/runtime/agent/orchestrator/session/eager-dispatch.mjs +326 -292
- package/src/runtime/agent/orchestrator/session/evidence-union.mjs +454 -452
- package/src/runtime/agent/orchestrator/session/explicit-skills.mjs +48 -39
- package/src/runtime/agent/orchestrator/session/image-strip-recovery.mjs +96 -93
- package/src/runtime/agent/orchestrator/session/lifecycle-scan.mjs +105 -88
- package/src/runtime/agent/orchestrator/session/loop/arg-schema-coerce.mjs +61 -61
- package/src/runtime/agent/orchestrator/session/loop/assistant-commit.mjs +70 -66
- package/src/runtime/agent/orchestrator/session/loop/compact-debug.mjs +17 -11
- package/src/runtime/agent/orchestrator/session/loop/compact-policy.mjs +585 -567
- package/src/runtime/agent/orchestrator/session/loop/completion-guards.mjs +26 -16
- package/src/runtime/agent/orchestrator/session/loop/context-overflow.mjs +60 -48
- package/src/runtime/agent/orchestrator/session/loop/deferred-call-through.mjs +60 -49
- package/src/runtime/agent/orchestrator/session/loop/diagnostics.mjs +54 -40
- package/src/runtime/agent/orchestrator/session/loop/fresh-context.mjs +157 -141
- package/src/runtime/agent/orchestrator/session/loop/hidden-agents.mjs +8 -6
- package/src/runtime/agent/orchestrator/session/loop/no-tool-turn.mjs +242 -218
- package/src/runtime/agent/orchestrator/session/loop/pre-dispatch-deny.mjs +71 -73
- package/src/runtime/agent/orchestrator/session/loop/request-boundary.mjs +112 -94
- package/src/runtime/agent/orchestrator/session/loop/request-projection.mjs +93 -77
- package/src/runtime/agent/orchestrator/session/loop/steering.mjs +194 -181
- package/src/runtime/agent/orchestrator/session/loop/stored-tool-args.mjs +96 -91
- package/src/runtime/agent/orchestrator/session/loop/termination.mjs +37 -44
- package/src/runtime/agent/orchestrator/session/loop/tool-classify.mjs +102 -83
- package/src/runtime/agent/orchestrator/session/loop/tool-exec.mjs +353 -309
- package/src/runtime/agent/orchestrator/session/loop/tool-helpers.mjs +175 -168
- package/src/runtime/agent/orchestrator/session/loop/transcript-repair.mjs +75 -72
- package/src/runtime/agent/orchestrator/session/loop/usage.mjs +59 -53
- package/src/runtime/agent/orchestrator/session/loop.mjs +9 -9
- package/src/runtime/agent/orchestrator/session/manager/agent-runtime-singleton.mjs +5 -5
- package/src/runtime/agent/orchestrator/session/manager/ask-session.mjs +1382 -1303
- package/src/runtime/agent/orchestrator/session/manager/compaction-runner.mjs +426 -388
- package/src/runtime/agent/orchestrator/session/manager/context-meta.mjs +180 -179
- package/src/runtime/agent/orchestrator/session/manager/delivered-completions.mjs +60 -55
- package/src/runtime/agent/orchestrator/session/manager/foreign-pending-messages.mjs +324 -316
- package/src/runtime/agent/orchestrator/session/manager/idle-cleanup.mjs +136 -125
- package/src/runtime/agent/orchestrator/session/manager/message-sanitize.mjs +112 -112
- package/src/runtime/agent/orchestrator/session/manager/pending-message-entry.mjs +242 -233
- package/src/runtime/agent/orchestrator/session/manager/pending-messages.mjs +1048 -951
- package/src/runtime/agent/orchestrator/session/manager/prefetch-bridge.mjs +214 -198
- package/src/runtime/agent/orchestrator/session/manager/prompt-utils.mjs +152 -148
- package/src/runtime/agent/orchestrator/session/manager/provider-cache-key.mjs +17 -17
- package/src/runtime/agent/orchestrator/session/manager/rules-cache.mjs +80 -58
- package/src/runtime/agent/orchestrator/session/manager/rules-source-cache.mjs +48 -48
- package/src/runtime/agent/orchestrator/session/manager/runtime-liveness.mjs +392 -389
- package/src/runtime/agent/orchestrator/session/manager/runtime-loaders.mjs +10 -10
- package/src/runtime/agent/orchestrator/session/manager/session-close.mjs +212 -169
- package/src/runtime/agent/orchestrator/session/manager/session-crud.mjs +323 -300
- package/src/runtime/agent/orchestrator/session/manager/session-errors.mjs +12 -12
- package/src/runtime/agent/orchestrator/session/manager/session-id.mjs +49 -52
- package/src/runtime/agent/orchestrator/session/manager/session-lifecycle.mjs +786 -795
- package/src/runtime/agent/orchestrator/session/manager/session-lock.mjs +54 -51
- package/src/runtime/agent/orchestrator/session/manager/status-telemetry.mjs +77 -71
- package/src/runtime/agent/orchestrator/session/manager/tool-resolution.mjs +173 -182
- package/src/runtime/agent/orchestrator/session/manager/turn-checkpoint-context.mjs +171 -171
- package/src/runtime/agent/orchestrator/session/manager/turn-checkpoint-journal.mjs +392 -385
- package/src/runtime/agent/orchestrator/session/manager/turn-checkpoint.mjs +175 -172
- package/src/runtime/agent/orchestrator/session/manager/turn-interruption.mjs +388 -399
- package/src/runtime/agent/orchestrator/session/manager/usage-metrics.mjs +371 -352
- package/src/runtime/agent/orchestrator/session/manager.mjs +60 -60
- package/src/runtime/agent/orchestrator/session/pre-send-compact.mjs +485 -430
- package/src/runtime/agent/orchestrator/session/provider-prefix-guard.mjs +144 -145
- package/src/runtime/agent/orchestrator/session/reduction-metrics.mjs +102 -104
- package/src/runtime/agent/orchestrator/session/result-classification.mjs +37 -38
- package/src/runtime/agent/orchestrator/session/save-session-worker.mjs +76 -70
- package/src/runtime/agent/orchestrator/session/send-with-recovery.mjs +680 -643
- package/src/runtime/agent/orchestrator/session/store/canonical-reader.mjs +49 -48
- package/src/runtime/agent/orchestrator/session/store/fs-probe.mjs +24 -24
- package/src/runtime/agent/orchestrator/session/store/listing.mjs +722 -655
- package/src/runtime/agent/orchestrator/session/store/live-state.mjs +104 -104
- package/src/runtime/agent/orchestrator/session/store/load-cache.mjs +124 -124
- package/src/runtime/agent/orchestrator/session/store/paths-heartbeat.mjs +119 -100
- package/src/runtime/agent/orchestrator/session/store/save-fault.mjs +147 -141
- package/src/runtime/agent/orchestrator/session/store/save-worker.mjs +711 -615
- package/src/runtime/agent/orchestrator/session/store/serialize.mjs +96 -91
- package/src/runtime/agent/orchestrator/session/store/summary-cache.mjs +159 -154
- package/src/runtime/agent/orchestrator/session/store/summary-rebuild-worker.mjs +12 -12
- package/src/runtime/agent/orchestrator/session/store/write-guards.mjs +86 -86
- package/src/runtime/agent/orchestrator/session/store-summary-index.mjs +291 -272
- package/src/runtime/agent/orchestrator/session/store-summary-reader.mjs +904 -897
- package/src/runtime/agent/orchestrator/session/store-summary-visibility.mjs +26 -28
- package/src/runtime/agent/orchestrator/session/store-transcript-cache.mjs +93 -93
- package/src/runtime/agent/orchestrator/session/store.mjs +897 -842
- package/src/runtime/agent/orchestrator/session/synthetic-user-envelope.mjs +71 -76
- package/src/runtime/agent/orchestrator/session/task-wait-control.mjs +9 -3
- package/src/runtime/agent/orchestrator/session/thinking-replay-recovery.mjs +55 -58
- package/src/runtime/agent/orchestrator/session/token-estimate-floors.mjs +25 -24
- package/src/runtime/agent/orchestrator/session/token-estimate.mjs +42 -42
- package/src/runtime/agent/orchestrator/session/tool-batch.mjs +989 -918
- package/src/runtime/agent/orchestrator/session/tool-envelope.mjs +25 -32
- package/src/runtime/agent/orchestrator/session/tool-result-offload.mjs +390 -369
- package/src/runtime/agent/orchestrator/stall-policy.mjs +184 -180
- package/src/runtime/agent/orchestrator/tool-loop-guard.mjs +4 -3
- package/src/runtime/agent/orchestrator/tools/bash-policy-scan.mjs +7 -6
- package/src/runtime/agent/orchestrator/tools/builtin/advisory-lock.mjs +166 -153
- package/src/runtime/agent/orchestrator/tools/builtin/arg-guard.mjs +859 -795
- package/src/runtime/agent/orchestrator/tools/builtin/atomic-write.mjs +234 -184
- package/src/runtime/agent/orchestrator/tools/builtin/bash-tool.mjs +772 -722
- package/src/runtime/agent/orchestrator/tools/builtin/binary-file.mjs +83 -80
- package/src/runtime/agent/orchestrator/tools/builtin/builtin-tools.mjs +336 -231
- package/src/runtime/agent/orchestrator/tools/builtin/cache-layers.mjs +444 -408
- package/src/runtime/agent/orchestrator/tools/builtin/device-paths.mjs +152 -103
- package/src/runtime/agent/orchestrator/tools/builtin/diff-utils.mjs +104 -90
- package/src/runtime/agent/orchestrator/tools/builtin/external-tool-adapters.mjs +559 -498
- package/src/runtime/agent/orchestrator/tools/builtin/fs-reachability.mjs +49 -42
- package/src/runtime/agent/orchestrator/tools/builtin/git-command-policy.mjs +169 -100
- package/src/runtime/agent/orchestrator/tools/builtin/git-command-tool.mjs +1072 -793
- package/src/runtime/agent/orchestrator/tools/builtin/git-partial-stage.mjs +215 -209
- package/src/runtime/agent/orchestrator/tools/builtin/git-repo-rw-lock.mjs +66 -66
- package/src/runtime/agent/orchestrator/tools/builtin/glob-walk.mjs +212 -173
- package/src/runtime/agent/orchestrator/tools/builtin/grep-formatting.mjs +114 -111
- package/src/runtime/agent/orchestrator/tools/builtin/hash-utils.mjs +4 -2
- package/src/runtime/agent/orchestrator/tools/builtin/lib/absolute-glob-expand.mjs +98 -86
- package/src/runtime/agent/orchestrator/tools/builtin/lib/glob-static-prefix.mjs +91 -91
- package/src/runtime/agent/orchestrator/tools/builtin/lib/grep-chunk-merge.mjs +100 -101
- package/src/runtime/agent/orchestrator/tools/builtin/lib/grep-context-expander.mjs +456 -461
- package/src/runtime/agent/orchestrator/tools/builtin/lib/grep-output.mjs +229 -182
- package/src/runtime/agent/orchestrator/tools/builtin/lib/grep-path-fanout.mjs +240 -238
- package/src/runtime/agent/orchestrator/tools/builtin/lib/grep-pattern-fanout.mjs +350 -323
- package/src/runtime/agent/orchestrator/tools/builtin/lib/grep-single-file-rescue.mjs +201 -162
- package/src/runtime/agent/orchestrator/tools/builtin/lib/list-helpers.mjs +22 -25
- package/src/runtime/agent/orchestrator/tools/builtin/lib/search-grep-chunks.mjs +124 -125
- package/src/runtime/agent/orchestrator/tools/builtin/lib/search-input-helpers.mjs +39 -43
- package/src/runtime/agent/orchestrator/tools/builtin/lib/shell-job-insights.mjs +75 -69
- package/src/runtime/agent/orchestrator/tools/builtin/lib/shell-job-records.mjs +221 -194
- package/src/runtime/agent/orchestrator/tools/builtin/list-formatting.mjs +6 -6
- package/src/runtime/agent/orchestrator/tools/builtin/list-tool.mjs +894 -868
- package/src/runtime/agent/orchestrator/tools/builtin/local-search-telemetry.mjs +52 -50
- package/src/runtime/agent/orchestrator/tools/builtin/native-search-client.mjs +128 -114
- package/src/runtime/agent/orchestrator/tools/builtin/native-search-runner.mjs +36 -34
- package/src/runtime/agent/orchestrator/tools/builtin/native-search-transport.mjs +35 -7
- package/src/runtime/agent/orchestrator/tools/builtin/path-diagnostics.mjs +217 -179
- package/src/runtime/agent/orchestrator/tools/builtin/path-locks.mjs +28 -23
- package/src/runtime/agent/orchestrator/tools/builtin/path-utils.mjs +239 -216
- package/src/runtime/agent/orchestrator/tools/builtin/read-args.mjs +52 -52
- package/src/runtime/agent/orchestrator/tools/builtin/read-batch.mjs +228 -217
- package/src/runtime/agent/orchestrator/tools/builtin/read-formatting.mjs +60 -61
- package/src/runtime/agent/orchestrator/tools/builtin/read-image-resize.mjs +217 -202
- package/src/runtime/agent/orchestrator/tools/builtin/read-image.mjs +29 -19
- package/src/runtime/agent/orchestrator/tools/builtin/read-lines.mjs +7 -7
- package/src/runtime/agent/orchestrator/tools/builtin/read-mode-tool.mjs +406 -368
- package/src/runtime/agent/orchestrator/tools/builtin/read-office-files.mjs +479 -417
- package/src/runtime/agent/orchestrator/tools/builtin/read-open.mjs +157 -148
- package/src/runtime/agent/orchestrator/tools/builtin/read-range-index.mjs +237 -214
- package/src/runtime/agent/orchestrator/tools/builtin/read-ranges.mjs +24 -23
- package/src/runtime/agent/orchestrator/tools/builtin/read-single-tool.mjs +807 -739
- package/src/runtime/agent/orchestrator/tools/builtin/read-snapshot-runtime.mjs +181 -185
- package/src/runtime/agent/orchestrator/tools/builtin/read-source-windows.mjs +76 -71
- package/src/runtime/agent/orchestrator/tools/builtin/read-special-files.mjs +231 -191
- package/src/runtime/agent/orchestrator/tools/builtin/read-streaming.mjs +553 -538
- package/src/runtime/agent/orchestrator/tools/builtin/read-tool.mjs +670 -607
- package/src/runtime/agent/orchestrator/tools/builtin/read-windows.mjs +111 -111
- package/src/runtime/agent/orchestrator/tools/builtin/runtime-capabilities.mjs +183 -180
- package/src/runtime/agent/orchestrator/tools/builtin/search-admission.mjs +7 -16
- package/src/runtime/agent/orchestrator/tools/builtin/search-builders.mjs +222 -203
- package/src/runtime/agent/orchestrator/tools/builtin/search-glob-tool.mjs +466 -438
- package/src/runtime/agent/orchestrator/tools/builtin/search-grep-tool.mjs +730 -718
- package/src/runtime/agent/orchestrator/tools/builtin/search-path-diagnostics.mjs +194 -163
- package/src/runtime/agent/orchestrator/tools/builtin/search-tool.mjs +8 -8
- package/src/runtime/agent/orchestrator/tools/builtin/shell-analysis.mjs +834 -770
- package/src/runtime/agent/orchestrator/tools/builtin/shell-direct-exe.mjs +209 -136
- package/src/runtime/agent/orchestrator/tools/builtin/shell-jobs.mjs +417 -384
- package/src/runtime/agent/orchestrator/tools/builtin/shell-lossless-compact.mjs +315 -318
- package/src/runtime/agent/orchestrator/tools/builtin/shell-output.mjs +67 -68
- package/src/runtime/agent/orchestrator/tools/builtin/shell-runtime.mjs +171 -156
- package/src/runtime/agent/orchestrator/tools/builtin/snapshot-helpers.mjs +103 -100
- package/src/runtime/agent/orchestrator/tools/builtin/snapshot-store.mjs +277 -253
- package/src/runtime/agent/orchestrator/tools/builtin/snapshot-validation.mjs +86 -85
- package/src/runtime/agent/orchestrator/tools/builtin/task-tool.mjs +226 -230
- package/src/runtime/agent/orchestrator/tools/builtin/text-stats.mjs +59 -57
- package/src/runtime/agent/orchestrator/tools/builtin/tool-output-limit.mjs +31 -34
- package/src/runtime/agent/orchestrator/tools/builtin/windows-roots.mjs +3 -3
- package/src/runtime/agent/orchestrator/tools/builtin.mjs +384 -411
- package/src/runtime/agent/orchestrator/tools/code-graph/aggregate-roots.mjs +68 -30
- package/src/runtime/agent/orchestrator/tools/code-graph/ast-calls.mjs +304 -0
- package/src/runtime/agent/orchestrator/tools/code-graph/build.mjs +259 -153
- package/src/runtime/agent/orchestrator/tools/code-graph/calls-cache.mjs +109 -0
- package/src/runtime/agent/orchestrator/tools/code-graph/constants.mjs +98 -6
- package/src/runtime/agent/orchestrator/tools/code-graph/disk-cache.mjs +206 -69
- package/src/runtime/agent/orchestrator/tools/code-graph/dispatch.mjs +536 -269
- package/src/runtime/agent/orchestrator/tools/code-graph/exact-file-graph.mjs +6 -4
- package/src/runtime/agent/orchestrator/tools/code-graph/graph-binary.mjs +450 -182
- package/src/runtime/agent/orchestrator/tools/code-graph/graph-model.mjs +25 -8
- package/src/runtime/agent/orchestrator/tools/code-graph/keyword-match.mjs +10 -3
- package/src/runtime/agent/orchestrator/tools/code-graph/lang-predicates.mjs +60 -26
- package/src/runtime/agent/orchestrator/tools/code-graph/memory-cache.mjs +6 -14
- package/src/runtime/agent/orchestrator/tools/code-graph/project-root.mjs +31 -10
- package/src/runtime/agent/orchestrator/tools/code-graph/search-references.mjs +290 -100
- package/src/runtime/agent/orchestrator/tools/code-graph/search.mjs +422 -511
- package/src/runtime/agent/orchestrator/tools/code-graph/source-access.mjs +11 -3
- package/src/runtime/agent/orchestrator/tools/code-graph/span.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/code-graph/symbol-index.mjs +148 -259
- package/src/runtime/agent/orchestrator/tools/code-graph/text-columns.mjs +79 -34
- package/src/runtime/agent/orchestrator/tools/code-graph/text-mask.mjs +20 -9
- package/src/runtime/agent/orchestrator/tools/code-graph/trusted-roots.mjs +23 -18
- package/src/runtime/agent/orchestrator/tools/code-graph-prewarm-worker.mjs +4 -9
- package/src/runtime/agent/orchestrator/tools/code-graph-state.mjs +1 -3
- package/src/runtime/agent/orchestrator/tools/code-graph-tool-defs.mjs +49 -7
- package/src/runtime/agent/orchestrator/tools/destructive-warning.mjs +247 -52
- package/src/runtime/agent/orchestrator/tools/env-scrub.mjs +93 -91
- package/src/runtime/agent/orchestrator/tools/graph-binary-fetcher.mjs +6 -5
- package/src/runtime/agent/orchestrator/tools/graph-manifest.json +11 -11
- package/src/runtime/agent/orchestrator/tools/lib/native-spawn-client.mjs +125 -81
- package/src/runtime/agent/orchestrator/tools/lib/shell-descendants.mjs +10 -3
- package/src/runtime/agent/orchestrator/tools/lib/shell-spawn-retry.mjs +18 -13
- package/src/runtime/agent/orchestrator/tools/lib/shell-warm-standby.mjs +123 -105
- package/src/runtime/agent/orchestrator/tools/next-call-utils.mjs +5 -2
- package/src/runtime/agent/orchestrator/tools/patch/dispatch.mjs +85 -53
- package/src/runtime/agent/orchestrator/tools/patch/matcher.mjs +109 -86
- package/src/runtime/agent/orchestrator/tools/patch/native-server.mjs +158 -70
- package/src/runtime/agent/orchestrator/tools/patch/orchestrator.mjs +287 -213
- package/src/runtime/agent/orchestrator/tools/patch/parsing.mjs +30 -17
- package/src/runtime/agent/orchestrator/tools/patch/paths.mjs +31 -23
- package/src/runtime/agent/orchestrator/tools/patch/v4a-anchors.mjs +17 -16
- package/src/runtime/agent/orchestrator/tools/patch/v4a-convert.mjs +71 -71
- package/src/runtime/agent/orchestrator/tools/patch/v4a-windows.mjs +23 -19
- package/src/runtime/agent/orchestrator/tools/patch-binary-fetcher.mjs +7 -7
- package/src/runtime/agent/orchestrator/tools/patch-tool-defs.mjs +11 -5
- package/src/runtime/agent/orchestrator/tools/patch.mjs +7 -1
- package/src/runtime/agent/orchestrator/tools/progress-message.mjs +83 -85
- package/src/runtime/agent/orchestrator/tools/shell-command.mjs +258 -148
- package/src/runtime/agent/orchestrator/tools/shell-exec-output.mjs +39 -29
- package/src/runtime/agent/orchestrator/tools/shell-exec-policy.mjs +23 -12
- package/src/runtime/agent/orchestrator/tools/shell-policy-danger-target.mjs +29 -8
- package/src/runtime/agent/orchestrator/tools/shell-policy.mjs +77 -33
- package/src/runtime/agent/orchestrator/tools/shell-powershell.mjs +12 -13
- package/src/runtime/agent/orchestrator/tools/shell-snapshot.mjs +112 -101
- package/src/runtime/agent/orchestrator/tools/spawn-binary-fetcher.mjs +2 -2
- package/src/runtime/agent/orchestrator/tools/tool-batch-trace.mjs +32 -27
- package/src/runtime/attachments/pdf-extract.mjs +28 -14
- package/src/runtime/attachments/pdfjs-runtime.mjs +3 -1
- package/src/runtime/attachments/store.mjs +66 -62
- package/src/runtime/bridge-discovery.mjs +7 -7
- package/src/runtime/browser-bridge/action-schema.d.mts +5 -4
- package/src/runtime/browser-bridge/action-schema.mjs +168 -134
- package/src/runtime/browser-bridge/browser-action-contract.mjs +75 -15
- package/src/runtime/browser-bridge/client.mjs +40 -39
- package/src/runtime/browser-bridge/input-fields.mjs +269 -50
- package/src/runtime/browser-bridge/timing.mjs +9 -5
- package/src/runtime/browser-bridge/tool-defs.mjs +20 -20
- package/src/runtime/channels/index.mjs +2 -2
- package/src/runtime/channels/lib/boot-profile.mjs +3 -3
- package/src/runtime/channels/lib/cli-worker-host.mjs +2 -5
- package/src/runtime/channels/lib/config.mjs +36 -54
- package/src/runtime/channels/lib/crash-log.mjs +48 -29
- package/src/runtime/channels/lib/event-pipeline.mjs +19 -19
- package/src/runtime/channels/lib/event-queue.mjs +63 -52
- package/src/runtime/channels/lib/executor.mjs +58 -61
- package/src/runtime/channels/lib/index-drop-trace.mjs +44 -24
- package/src/runtime/channels/lib/network-retry.mjs +8 -7
- package/src/runtime/channels/lib/owned-runtime.mjs +410 -376
- package/src/runtime/channels/lib/owner-heartbeat.mjs +1 -1
- package/src/runtime/channels/lib/parent-bridge.mjs +39 -17
- package/src/runtime/channels/lib/runtime-paths.mjs +202 -169
- package/src/runtime/channels/lib/scheduler.mjs +166 -128
- package/src/runtime/channels/lib/settings.mjs +3 -5
- package/src/runtime/channels/lib/state-file.mjs +7 -14
- package/src/runtime/channels/lib/status-snapshot.mjs +17 -17
- package/src/runtime/channels/lib/tool-dispatch.mjs +71 -65
- package/src/runtime/channels/lib/voice-runtime-fetcher.mjs +444 -374
- package/src/runtime/channels/lib/voice-transcription.mjs +101 -40
- package/src/runtime/channels/lib/webhook/deliveries.mjs +10 -11
- package/src/runtime/channels/lib/webhook/log.mjs +13 -12
- package/src/runtime/channels/lib/webhook/relay-tunnel.mjs +199 -110
- package/src/runtime/channels/lib/webhook/signature.mjs +14 -14
- package/src/runtime/channels/lib/webhook.mjs +173 -132
- package/src/runtime/channels/lib/whisper-language.mjs +19 -18
- package/src/runtime/channels/lib/whisper-port.mjs +20 -12
- package/src/runtime/channels/lib/whisper-server.mjs +135 -75
- package/src/runtime/channels/lib/worker-bootstrap.mjs +94 -78
- package/src/runtime/channels/lib/worker-ipc.mjs +92 -73
- package/src/runtime/channels/lib/worker-main.mjs +106 -79
- package/src/runtime/computer-bridge/action-schema.mjs +206 -142
- package/src/runtime/computer-bridge/actions.d.mts +3 -1
- package/src/runtime/computer-bridge/actions.mjs +49 -6
- package/src/runtime/computer-bridge/capture-size.d.mts +5 -0
- package/src/runtime/computer-bridge/capture-size.mjs +20 -0
- package/src/runtime/computer-bridge/client.mjs +171 -77
- package/src/runtime/computer-bridge/core-actions.mjs +33 -21
- package/src/runtime/computer-bridge/error-code.d.mts +1 -0
- package/src/runtime/computer-bridge/error-code.mjs +5 -0
- package/src/runtime/computer-bridge/error-recovery.mjs +82 -29
- package/src/runtime/computer-bridge/limits.mjs +17 -6
- package/src/runtime/computer-bridge/pending-continuation.mjs +79 -32
- package/src/runtime/computer-bridge/tool-defs.mjs +2 -5
- package/src/runtime/github/client.d.mts +5 -1
- package/src/runtime/github/client.mjs +80 -43
- package/src/runtime/github/commands.mjs +72 -31
- package/src/runtime/github/contract.d.mts +45 -11
- package/src/runtime/github/contract.mjs +62 -27
- package/src/runtime/github/tool.mjs +29 -7
- package/src/runtime/local-provider/asset-installer.mjs +66 -46
- package/src/runtime/local-provider/asset-storage.mjs +3 -1
- package/src/runtime/local-provider/catalog.mjs +20 -23
- package/src/runtime/local-provider/context-settings.mjs +2 -2
- package/src/runtime/local-provider/gguf-header.mjs +69 -18
- package/src/runtime/local-provider/hardware.mjs +84 -31
- package/src/runtime/local-provider/hugging-face.mjs +108 -33
- package/src/runtime/local-provider/input-capabilities.mjs +16 -5
- package/src/runtime/local-provider/install-progress.mjs +42 -17
- package/src/runtime/local-provider/model-maintenance.mjs +79 -35
- package/src/runtime/local-provider/model-state.mjs +21 -8
- package/src/runtime/local-provider/registered-models.mjs +23 -13
- package/src/runtime/local-provider/request-queue.mjs +31 -10
- package/src/runtime/local-provider/resumable-installations.mjs +25 -7
- package/src/runtime/local-provider/server-process.mjs +42 -16
- package/src/runtime/local-provider/server.mjs +63 -47
- package/src/runtime/media/adapters/antigravity-image.mjs +5 -4
- package/src/runtime/media/adapters/codex-image.mjs +24 -9
- package/src/runtime/media/adapters/gemini-image.mjs +17 -16
- package/src/runtime/media/adapters/gemini-video.mjs +4 -5
- package/src/runtime/media/adapters/xai-media.mjs +5 -1
- package/src/runtime/media/catalog-errors.mjs +5 -2
- package/src/runtime/media/catalog.mjs +77 -55
- package/src/runtime/media/download.mjs +12 -31
- package/src/runtime/media/jobs.mjs +17 -19
- package/src/runtime/media/lanes.mjs +24 -12
- package/src/runtime/media/renditions.mjs +94 -63
- package/src/runtime/media/store.mjs +8 -21
- package/src/runtime/media/tool-defs.mjs +38 -12
- package/src/runtime/media/tool.mjs +118 -31
- package/src/runtime/media/upstream-error.mjs +5 -1
- package/src/runtime/memory/data/runtime-manifest.json +3 -3
- package/src/runtime/memory/index.mjs +336 -316
- package/src/runtime/memory/lib/agent-ipc.mjs +122 -100
- package/src/runtime/memory/lib/compact-handoff.mjs +76 -74
- package/src/runtime/memory/lib/compact-vector-cache.mjs +34 -37
- package/src/runtime/memory/lib/core-memory-file.mjs +87 -111
- package/src/runtime/memory/lib/core-memory-index.mjs +57 -47
- package/src/runtime/memory/lib/core-memory-management.mjs +62 -0
- package/src/runtime/memory/lib/core-memory-store.mjs +223 -481
- package/src/runtime/memory/lib/core-memory-uniqueness.mjs +44 -0
- package/src/runtime/memory/lib/cycle-llm-adapters.mjs +12 -11
- package/src/runtime/memory/lib/cycle-scheduler.mjs +294 -332
- package/src/runtime/memory/lib/cycle-signatures.mjs +3 -17
- package/src/runtime/memory/lib/embedding-cache-retention.mjs +21 -31
- package/src/runtime/memory/lib/embedding-model-cache-compression.mjs +21 -33
- package/src/runtime/memory/lib/embedding-model-config.mjs +25 -26
- package/src/runtime/memory/lib/embedding-provider.mjs +230 -200
- package/src/runtime/memory/lib/embedding-reindex.mjs +30 -30
- package/src/runtime/memory/lib/embedding-worker.mjs +324 -248
- package/src/runtime/memory/lib/history-duplicates.mjs +11 -0
- package/src/runtime/memory/lib/http-router.mjs +359 -327
- package/src/runtime/memory/lib/http-wire.mjs +22 -22
- package/src/runtime/memory/lib/light-ko-morph.mjs +100 -41
- package/src/runtime/memory/lib/llm-worker-host.mjs +2 -4
- package/src/runtime/memory/lib/memory-action-handlers.mjs +364 -585
- package/src/runtime/memory/lib/memory-chunk-audit.mjs +26 -20
- package/src/runtime/memory/lib/memory-chunk-quality.mjs +314 -225
- package/src/runtime/memory/lib/memory-config-flags.mjs +27 -29
- package/src/runtime/memory/lib/memory-cycle-requests.mjs +125 -108
- package/src/runtime/memory/lib/memory-cycle.mjs +9 -10
- package/src/runtime/memory/lib/memory-cycle1.mjs +445 -355
- package/src/runtime/memory/lib/memory-cycle2-mutations.mjs +103 -624
- package/src/runtime/memory/lib/memory-cycle2-review.mjs +232 -0
- package/src/runtime/memory/lib/memory-cycle2-shared.mjs +36 -43
- package/src/runtime/memory/lib/memory-cycle2.mjs +132 -838
- package/src/runtime/memory/lib/memory-daemon-lifecycle.mjs +65 -57
- package/src/runtime/memory/lib/memory-embed.mjs +329 -292
- package/src/runtime/memory/lib/memory-extraction.mjs +4 -4
- package/src/runtime/memory/lib/memory-fingerprint.mjs +54 -0
- package/src/runtime/memory/lib/memory-maintenance-store.mjs +13 -11
- package/src/runtime/memory/lib/memory-ops-policy.mjs +114 -89
- package/src/runtime/memory/lib/memory-port-advertiser.mjs +55 -44
- package/src/runtime/memory/lib/memory-process-lock.mjs +61 -46
- package/src/runtime/memory/lib/memory-recall-id-patch.mjs +7 -7
- package/src/runtime/memory/lib/memory-recall-read-query.mjs +4 -4
- package/src/runtime/memory/lib/memory-recall-scope-filter.mjs +61 -68
- package/src/runtime/memory/lib/memory-recall-store.mjs +322 -406
- package/src/runtime/memory/lib/memory-retrievers.mjs +94 -68
- package/src/runtime/memory/lib/memory-score.mjs +21 -18
- package/src/runtime/memory/lib/memory-service-lifecycle.mjs +70 -62
- package/src/runtime/memory/lib/memory-session-merge.mjs +21 -15
- package/src/runtime/memory/lib/memory-text-utils.mjs +146 -83
- package/src/runtime/memory/lib/memory.mjs +275 -332
- package/src/runtime/memory/lib/pg/adapter.mjs +214 -199
- package/src/runtime/memory/lib/pg/compact-indexes.mjs +78 -59
- package/src/runtime/memory/lib/pg/process.mjs +434 -300
- package/src/runtime/memory/lib/pg/supervisor.mjs +217 -131
- package/src/runtime/memory/lib/project-id-resolver.mjs +1 -1
- package/src/runtime/memory/lib/query-handlers.mjs +568 -498
- package/src/runtime/memory/lib/query-maintenance-handlers.mjs +98 -67
- package/src/runtime/memory/lib/query-ranking.mjs +218 -170
- package/src/runtime/memory/lib/recall-embedding-readiness.mjs +35 -45
- package/src/runtime/memory/lib/recall-event-context.mjs +81 -72
- package/src/runtime/memory/lib/recall-format.mjs +293 -259
- package/src/runtime/memory/lib/recall-fusion.mjs +20 -28
- package/src/runtime/memory/lib/recall-limits.mjs +4 -0
- package/src/runtime/memory/lib/recall-order.mjs +12 -12
- package/src/runtime/memory/lib/recall-page-cursor.mjs +17 -17
- package/src/runtime/memory/lib/recall-scoring.mjs +25 -40
- package/src/runtime/memory/lib/recall-substring-predicate.mjs +2 -2
- package/src/runtime/memory/lib/runtime-fetcher.mjs +253 -215
- package/src/runtime/memory/lib/session-ingest-runtime.mjs +177 -155
- package/src/runtime/memory/lib/session-ingest.mjs +163 -141
- package/src/runtime/memory/lib/tool-call-handler.mjs +27 -18
- package/src/runtime/memory/lib/trace-mode.mjs +30 -34
- package/src/runtime/memory/lib/trace-store.mjs +506 -381
- package/src/runtime/memory/lib/transcript-ingest.mjs +253 -203
- package/src/runtime/memory/tool-defs.mjs +105 -23
- package/src/runtime/office/authoring/pptx-author-action.mjs +20 -11
- package/src/runtime/office/authoring/pptx-author-session.mjs +20 -18
- package/src/runtime/office/authoring/pptx-brief.mjs +80 -22
- package/src/runtime/office/authoring/pptx-contact-sheet.mjs +9 -2
- package/src/runtime/office/authoring/pptx-icons.json +265 -1
- package/src/runtime/office/authoring/pptx-icons.mjs +19 -9
- package/src/runtime/office/authoring/pptx-receipt.mjs +262 -82
- package/src/runtime/office/authoring/pptx-script-contract.mjs +5 -3
- package/src/runtime/office/authoring/pptx-script-normalize.mjs +85 -34
- package/src/runtime/office/authoring/pptx-script-runner.mjs +53 -14
- package/src/runtime/office/bench/assurance-benchmark.mjs +204 -144
- package/src/runtime/office/bench/benchmark.mjs +162 -101
- package/src/runtime/office/bench/contract-benchmark.mjs +2 -1
- package/src/runtime/office/bench/deck-bench.mjs +11 -3
- package/src/runtime/office/bench/polish-benchmark.mjs +240 -120
- package/src/runtime/office/bench/quality-live-benchmark.mjs +234 -133
- package/src/runtime/office/capabilities.mjs +1031 -243
- package/src/runtime/office/com/com-adapter.mjs +108 -70
- package/src/runtime/office/com/office-com-cleanup.ps1 +125 -116
- package/src/runtime/office/com/office-com-session-host.ps1 +820 -783
- package/src/runtime/office/com/office-session-client.mjs +36 -16
- package/src/runtime/office/com/office-word-formatting.ps1 +23 -23
- package/src/runtime/office/core/journal.mjs +2 -13
- package/src/runtime/office/core/office-actions-batch.mjs +156 -107
- package/src/runtime/office/core/office-actions-inspect.mjs +110 -85
- package/src/runtime/office/core/office-actions-lifecycle.mjs +54 -43
- package/src/runtime/office/core/office-actions-open.mjs +61 -46
- package/src/runtime/office/core/office-actions-read.mjs +18 -17
- package/src/runtime/office/core/office-actions-render.mjs +75 -72
- package/src/runtime/office/core/office-core.mjs +88 -98
- package/src/runtime/office/core/office-documents.mjs +18 -12
- package/src/runtime/office/core/office-recalculation.mjs +9 -5
- package/src/runtime/office/core/office-render-preview.mjs +90 -44
- package/src/runtime/office/core/office-sessions.mjs +183 -111
- package/src/runtime/office/core/office-transactions.mjs +73 -60
- package/src/runtime/office/core/pagination.mjs +36 -32
- package/src/runtime/office/core/pptx-page-cache.mjs +37 -17
- package/src/runtime/office/core/snapshot-contract.mjs +18 -11
- package/src/runtime/office/core/tabular.mjs +71 -42
- package/src/runtime/office/design/composition-system.mjs +155 -77
- package/src/runtime/office/design/content-model.mjs +11 -7
- package/src/runtime/office/design/design-art-direction.mjs +43 -38
- package/src/runtime/office/design/design-creative-director.mjs +12 -17
- package/src/runtime/office/design/design-discipline.mjs +50 -30
- package/src/runtime/office/design/design-system.mjs +10 -4
- package/src/runtime/office/design/design-tokens.mjs +81 -76
- package/src/runtime/office/design/docx/design-docx-components.mjs +21 -31
- package/src/runtime/office/design/docx/design-docx.mjs +25 -21
- package/src/runtime/office/design/docx/document-typography.mjs +2 -1
- package/src/runtime/office/design/library/design-library-core.mjs +15 -29
- package/src/runtime/office/design/library/design-library-pack.mjs +86 -63
- package/src/runtime/office/design/library/design-library.mjs +49 -68
- package/src/runtime/office/design/library/design-template-index.mjs +45 -47
- package/src/runtime/office/design/library/design-template-inspect.mjs +73 -85
- package/src/runtime/office/design/library/templates/mixdog-executive.pptx.mixdog.json +89 -10
- package/src/runtime/office/design/xlsx/design-xlsx-components.mjs +31 -43
- package/src/runtime/office/design/xlsx/design-xlsx.mjs +85 -91
- package/src/runtime/office/index.mjs +81 -47
- package/src/runtime/office/office-test-support.mjs +4 -4
- package/src/runtime/office/pdf/document-preview.mjs +30 -20
- package/src/runtime/office/pdf/pdf-adapter.mjs +258 -93
- package/src/runtime/office/pdf/pdf-analysis.mjs +130 -72
- package/src/runtime/office/pdf/pdf-draw.mjs +12 -6
- package/src/runtime/office/pdf/pdf-fonts.mjs +30 -23
- package/src/runtime/office/pdf/pdf-forms.mjs +47 -15
- package/src/runtime/office/pdf/pdf-render.mjs +57 -65
- package/src/runtime/office/pdf/pdf-safety.mjs +10 -13
- package/src/runtime/office/pdf/pdf-search.mjs +33 -24
- package/src/runtime/office/pdf/pdf-security.mjs +16 -17
- package/src/runtime/office/pdf/pdf-writer.mjs +184 -70
- package/src/runtime/office/portable/docx-formatting.mjs +27 -10
- package/src/runtime/office/portable/docx-revisions.mjs +75 -35
- package/src/runtime/office/portable/docx-runs.mjs +53 -21
- package/src/runtime/office/portable/docx-tracked-edits.mjs +12 -5
- package/src/runtime/office/portable/font-provisioner.mjs +11 -9
- package/src/runtime/office/portable/image-layout.mjs +7 -5
- package/src/runtime/office/portable/ooxml-validator.mjs +61 -44
- package/src/runtime/office/portable/portable-cells.mjs +33 -35
- package/src/runtime/office/portable/portable-chart-faults.mjs +30 -16
- package/src/runtime/office/portable/portable-chart.mjs +162 -131
- package/src/runtime/office/portable/portable-docx-parts.mjs +161 -138
- package/src/runtime/office/portable/portable-docx-xml.mjs +136 -95
- package/src/runtime/office/portable/portable-docx.mjs +375 -189
- package/src/runtime/office/portable/portable-ooxml.mjs +6 -5
- package/src/runtime/office/portable/portable-opc.mjs +56 -55
- package/src/runtime/office/portable/portable-package.mjs +335 -236
- package/src/runtime/office/portable/portable-pivot.mjs +159 -127
- package/src/runtime/office/portable/portable-pptx-chart.mjs +63 -44
- package/src/runtime/office/portable/portable-pptx-charts.mjs +110 -81
- package/src/runtime/office/portable/portable-pptx-core.mjs +56 -83
- package/src/runtime/office/portable/portable-pptx-deck.mjs +101 -78
- package/src/runtime/office/portable/portable-pptx-package.mjs +129 -111
- package/src/runtime/office/portable/portable-pptx-shapes.mjs +183 -120
- package/src/runtime/office/portable/portable-pptx.mjs +53 -7
- package/src/runtime/office/portable/portable-sheet-page.mjs +72 -27
- package/src/runtime/office/portable/portable-sheet-parts.mjs +55 -41
- package/src/runtime/office/portable/portable-sheet-styles.mjs +83 -34
- package/src/runtime/office/portable/portable-sheet-xml.mjs +94 -100
- package/src/runtime/office/portable/portable-slide-shapes.mjs +107 -80
- package/src/runtime/office/portable/portable-snapshot.mjs +216 -137
- package/src/runtime/office/portable/portable-soffice.mjs +85 -55
- package/src/runtime/office/portable/portable-validation.mjs +344 -167
- package/src/runtime/office/portable/portable-xlsx.mjs +416 -211
- package/src/runtime/office/portable/portable-xml.mjs +10 -26
- package/src/runtime/office/portable/pptx-relations.mjs +38 -14
- package/src/runtime/office/portable/pptx-targets.mjs +9 -4
- package/src/runtime/office/portable/review-editability.mjs +28 -6
- package/src/runtime/office/portable/text-metrics.mjs +95 -70
- package/src/runtime/office/portable/xlsx-assertions.mjs +111 -43
- package/src/runtime/office/portable/xlsx-audit-support.mjs +12 -12
- package/src/runtime/office/portable/xlsx-contract.mjs +93 -51
- package/src/runtime/office/portable/xlsx-formula-audit.mjs +98 -30
- package/src/runtime/office/portable/xlsx-sheet-hygiene.mjs +59 -14
- package/src/runtime/office/quality/assurance-checklist.mjs +23 -17
- package/src/runtime/office/quality/assurance-rendered.mjs +49 -56
- package/src/runtime/office/quality/assurance-structure.mjs +342 -265
- package/src/runtime/office/quality/assurance-trust.mjs +38 -31
- package/src/runtime/office/quality/design-aesthetics-metrics.mjs +23 -17
- package/src/runtime/office/quality/design-aesthetics.mjs +100 -101
- package/src/runtime/office/quality/design-deck-diversity.mjs +53 -37
- package/src/runtime/office/quality/design-review-authored.mjs +36 -24
- package/src/runtime/office/quality/design-review-critique.mjs +55 -22
- package/src/runtime/office/quality/design-review.mjs +148 -162
- package/src/runtime/office/quality/document-acceptance.mjs +37 -18
- package/src/runtime/office/quality/inline-audit.mjs +13 -11
- package/src/runtime/office/quality/pptx-deck-rubric.mjs +30 -12
- package/src/runtime/office/quality/pptx-slide-roles.mjs +28 -15
- package/src/runtime/office/quality/presentation-acceptance.mjs +11 -10
- package/src/runtime/office/quality/quality-pipeline.mjs +151 -88
- package/src/runtime/office/quality/quality-score.mjs +13 -20
- package/src/runtime/office/quality/render-air.mjs +59 -24
- package/src/runtime/office/quality/visual-diff.mjs +5 -2
- package/src/runtime/office/shared/values.mjs +9 -2
- package/src/runtime/office/tool-defs.mjs +108 -27
- package/src/runtime/shared/abort-controller.mjs +5 -1
- package/src/runtime/shared/abort-race.mjs +4 -2
- package/src/runtime/shared/agent-route-config.mjs +18 -21
- package/src/runtime/shared/atomic-file.d.mts +3 -3
- package/src/runtime/shared/atomic-file.mjs +81 -47
- package/src/runtime/shared/automation-attachments.mjs +10 -5
- package/src/runtime/shared/automation-workflow.mjs +4 -2
- package/src/runtime/shared/background-tasks.mjs +59 -46
- package/src/runtime/shared/boot-profile.mjs +5 -3
- package/src/runtime/shared/bounded-download.mjs +9 -13
- package/src/runtime/shared/bridge-tool-args.mjs +1 -3
- package/src/runtime/shared/buffered-appender.mjs +151 -142
- package/src/runtime/shared/child-guardian.mjs +7 -9
- package/src/runtime/shared/child-spawn-gate.mjs +40 -47
- package/src/runtime/shared/child-spawn-remote.mjs +44 -32
- package/src/runtime/shared/config.mjs +246 -210
- package/src/runtime/shared/debounced-writer.mjs +33 -31
- package/src/runtime/shared/edit-tool-dialect.mjs +6 -5
- package/src/runtime/shared/err-text.mjs +57 -32
- package/src/runtime/shared/error-presentation.mjs +67 -19
- package/src/runtime/shared/file-lock.mjs +44 -18
- package/src/runtime/shared/file-permissions.d.mts +2 -8
- package/src/runtime/shared/file-permissions.mjs +5 -1
- package/src/runtime/shared/http-request-body.mjs +26 -15
- package/src/runtime/shared/idle-gc.mjs +19 -7
- package/src/runtime/shared/json-file.mjs +5 -1
- package/src/runtime/shared/json-metrics.mjs +19 -8
- package/src/runtime/shared/keyed-serial-queue.d.mts +1 -4
- package/src/runtime/shared/keyed-serial-queue.mjs +4 -1
- package/src/runtime/shared/llm/cost.mjs +81 -63
- package/src/runtime/shared/llm/http-agent.mjs +78 -60
- package/src/runtime/shared/llm/index.mjs +13 -14
- package/src/runtime/shared/llm/usage-accounting.mjs +64 -56
- package/src/runtime/shared/llm/usage-ledger-import.mjs +169 -125
- package/src/runtime/shared/llm/usage-ledger-repair.mjs +125 -88
- package/src/runtime/shared/llm/usage-ledger.mjs +481 -325
- package/src/runtime/shared/llm/usage-log.mjs +19 -17
- package/src/runtime/shared/llm/usage-measurement.mjs +45 -28
- package/src/runtime/shared/llm/usage-pricing-refresh.mjs +15 -11
- package/src/runtime/shared/llm/usage-rollup.mjs +39 -30
- package/src/runtime/shared/llm/usage-session-history.mjs +23 -18
- package/src/runtime/shared/loopback-listener.mjs +56 -44
- package/src/runtime/shared/markdown-frontmatter.mjs +6 -2
- package/src/runtime/shared/memory-snapshot.mjs +68 -54
- package/src/runtime/shared/native-asset.mjs +54 -24
- package/src/runtime/shared/notify-trace.mjs +8 -2
- package/src/runtime/shared/open-url.mjs +3 -1
- package/src/runtime/shared/orchestration.mjs +35 -0
- package/src/runtime/shared/owner-fair-gate.mjs +47 -31
- package/src/runtime/shared/plugin-manifest.mjs +1 -3
- package/src/runtime/shared/plugin-metadata.mjs +1 -5
- package/src/runtime/shared/pristine-execution.mjs +52 -59
- package/src/runtime/shared/process-lifecycle.mjs +130 -91
- package/src/runtime/shared/process-listener-headroom.mjs +3 -2
- package/src/runtime/shared/process-shutdown.mjs +36 -24
- package/src/runtime/shared/profile-config.cjs +15 -9
- package/src/runtime/shared/provider-accounts.mjs +50 -24
- package/src/runtime/shared/provider-api-key.mjs +8 -3
- package/src/runtime/shared/provider-auth-binding.mjs +8 -7
- package/src/runtime/shared/resource-admission.mjs +47 -59
- package/src/runtime/shared/runtime-root.mjs +3 -14
- package/src/runtime/shared/safe-ipc-send.mjs +6 -2
- package/src/runtime/shared/schedule-time.mjs +1 -3
- package/src/runtime/shared/schedules-db.mjs +33 -53
- package/src/runtime/shared/schema-value-error.mjs +5 -2
- package/src/runtime/shared/service-discovery.mjs +44 -46
- package/src/runtime/shared/session-runtime-health.mjs +18 -11
- package/src/runtime/shared/shell-display.mjs +5 -5
- package/src/runtime/shared/singleton-owner.mjs +1 -5
- package/src/runtime/shared/skill-document.mjs +6 -9
- package/src/runtime/shared/skill-selection.mjs +12 -12
- package/src/runtime/shared/skill-tool-dependencies.mjs +46 -29
- package/src/runtime/shared/sleep.mjs +3 -3
- package/src/runtime/shared/staged-update.mjs +186 -46
- package/src/runtime/shared/task-notification-envelope.mjs +15 -14
- package/src/runtime/shared/time-format.mjs +1 -2
- package/src/runtime/shared/tool-card-model.mjs +283 -145
- package/src/runtime/shared/tool-execution-contract.mjs +66 -61
- package/src/runtime/shared/tool-execution-owner.mjs +4 -1
- package/src/runtime/shared/tool-primitives.mjs +43 -23
- package/src/runtime/shared/tool-result-summary.mjs +98 -42
- package/src/runtime/shared/tool-status.mjs +12 -5
- package/src/runtime/shared/tool-surface.mjs +228 -95
- package/src/runtime/shared/transcript-writer.mjs +35 -20
- package/src/runtime/shared/transport-error-text.mjs +80 -21
- package/src/runtime/shared/turn-snapshot-store.mjs +20 -11
- package/src/runtime/shared/turn-snapshot.mjs +59 -69
- package/src/runtime/shared/turn-worktree-snapshot.mjs +103 -123
- package/src/runtime/shared/update-checker.mjs +24 -64
- package/src/runtime/shared/user-cwd.mjs +68 -75
- package/src/runtime/shared/user-data-guard.mjs +33 -40
- package/src/runtime/shared/webhook-session-run.mjs +11 -2
- package/src/runtime/shared/webhooks-db.mjs +30 -28
- package/src/runtime/tidy/apply.mjs +164 -0
- package/src/runtime/tidy/core-install.mjs +444 -0
- package/src/runtime/tidy/engines-manifest.json +417 -0
- package/src/runtime/tidy/engines.mjs +306 -0
- package/src/runtime/tidy/extract.mjs +147 -0
- package/src/runtime/tidy/history-comment.mjs +277 -0
- package/src/runtime/tidy/install.mjs +258 -0
- package/src/runtime/tidy/languages.mjs +227 -0
- package/src/runtime/tidy/process.mjs +231 -0
- package/src/runtime/tidy/report.mjs +167 -0
- package/src/runtime/tidy/resolve.mjs +343 -0
- package/src/runtime/tidy/rules/__tests__/no-debugger.yml +9 -0
- package/src/runtime/tidy/rules/__tests__/no-empty-catch.yml +7 -0
- package/src/runtime/tidy/rules/__tests__/no-history-comment.yml +81 -0
- package/src/runtime/tidy/rules/__tests__/todo-marker.yml +27 -0
- package/src/runtime/tidy/rules/bash/no-history-comment.yml +9 -0
- package/src/runtime/tidy/rules/bash/todo-marker.yml +8 -0
- package/src/runtime/tidy/rules/c/no-history-comment.yml +9 -0
- package/src/runtime/tidy/rules/c/todo-marker.yml +8 -0
- package/src/runtime/tidy/rules/cpp/no-history-comment.yml +9 -0
- package/src/runtime/tidy/rules/cpp/todo-marker.yml +8 -0
- package/src/runtime/tidy/rules/csharp/no-empty-catch.yml +12 -0
- package/src/runtime/tidy/rules/csharp/no-history-comment.yml +9 -0
- package/src/runtime/tidy/rules/csharp/todo-marker.yml +8 -0
- package/src/runtime/tidy/rules/go/no-history-comment.yml +9 -0
- package/src/runtime/tidy/rules/go/todo-marker.yml +8 -0
- package/src/runtime/tidy/rules/java/no-empty-catch.yml +12 -0
- package/src/runtime/tidy/rules/java/no-history-comment.yml +12 -0
- package/src/runtime/tidy/rules/java/todo-marker.yml +11 -0
- package/src/runtime/tidy/rules/javascript/no-debugger.yml +8 -0
- package/src/runtime/tidy/rules/javascript/no-empty-catch.yml +12 -0
- package/src/runtime/tidy/rules/javascript/no-history-comment.yml +9 -0
- package/src/runtime/tidy/rules/javascript/todo-marker.yml +8 -0
- package/src/runtime/tidy/rules/kotlin/no-history-comment.yml +12 -0
- package/src/runtime/tidy/rules/kotlin/todo-marker.yml +11 -0
- package/src/runtime/tidy/rules/lua/no-history-comment.yml +9 -0
- package/src/runtime/tidy/rules/lua/todo-marker.yml +8 -0
- package/src/runtime/tidy/rules/php/no-empty-catch.yml +12 -0
- package/src/runtime/tidy/rules/php/no-history-comment.yml +9 -0
- package/src/runtime/tidy/rules/php/todo-marker.yml +8 -0
- package/src/runtime/tidy/rules/python/no-history-comment.yml +9 -0
- package/src/runtime/tidy/rules/python/todo-marker.yml +8 -0
- package/src/runtime/tidy/rules/ruby/no-history-comment.yml +9 -0
- package/src/runtime/tidy/rules/ruby/todo-marker.yml +8 -0
- package/src/runtime/tidy/rules/rust/no-history-comment.yml +12 -0
- package/src/runtime/tidy/rules/rust/todo-marker.yml +11 -0
- package/src/runtime/tidy/rules/swift/no-history-comment.yml +12 -0
- package/src/runtime/tidy/rules/swift/todo-marker.yml +11 -0
- package/src/runtime/tidy/rules/tsx/no-debugger.yml +8 -0
- package/src/runtime/tidy/rules/tsx/no-empty-catch.yml +12 -0
- package/src/runtime/tidy/rules/tsx/no-history-comment.yml +9 -0
- package/src/runtime/tidy/rules/tsx/todo-marker.yml +8 -0
- package/src/runtime/tidy/rules/typescript/no-debugger.yml +8 -0
- package/src/runtime/tidy/rules/typescript/no-empty-catch.yml +12 -0
- package/src/runtime/tidy/rules/typescript/no-history-comment.yml +9 -0
- package/src/runtime/tidy/rules/typescript/todo-marker.yml +8 -0
- package/src/runtime/tidy/run-engines.mjs +132 -0
- package/src/runtime/tidy/runners/air.mjs +50 -0
- package/src/runtime/tidy/runners/biome.mjs +425 -0
- package/src/runtime/tidy/runners/clang-format.mjs +53 -0
- package/src/runtime/tidy/runners/dotnet-format.mjs +238 -0
- package/src/runtime/tidy/runners/dprint.mjs +48 -0
- package/src/runtime/tidy/runners/eslint.mjs +51 -0
- package/src/runtime/tidy/runners/gofmt.mjs +10 -0
- package/src/runtime/tidy/runners/gofumpt.mjs +10 -0
- package/src/runtime/tidy/runners/index.mjs +43 -0
- package/src/runtime/tidy/runners/mago.mjs +110 -0
- package/src/runtime/tidy/runners/prettier.mjs +11 -0
- package/src/runtime/tidy/runners/psscriptanalyzer.mjs +138 -0
- package/src/runtime/tidy/runners/ruff.mjs +68 -0
- package/src/runtime/tidy/runners/rustfmt.mjs +72 -0
- package/src/runtime/tidy/runners/shared.mjs +177 -0
- package/src/runtime/tidy/runners/shellcheck.mjs +52 -0
- package/src/runtime/tidy/runners/shfmt.mjs +10 -0
- package/src/runtime/tidy/runners/stylua.mjs +45 -0
- package/src/runtime/tidy/structural.mjs +368 -0
- package/src/runtime/tidy/tool-defs.mjs +56 -0
- package/src/runtime/tidy/tool.mjs +380 -0
- package/src/runtime/web-search/index.mjs +296 -254
- package/src/runtime/web-search/lib/cache.mjs +92 -86
- package/src/runtime/web-search/lib/config.mjs +27 -24
- package/src/runtime/web-search/lib/document-content.mjs +139 -86
- package/src/runtime/web-search/lib/fetch-pipeline.mjs +128 -108
- package/src/runtime/web-search/lib/formatter.mjs +103 -89
- package/src/runtime/web-search/lib/http-fetch.mjs +284 -228
- package/src/runtime/web-search/lib/ssrf-guard.mjs +140 -122
- package/src/runtime/web-search/lib/state.mjs +65 -71
- package/src/runtime/web-search/lib/web-tools.mjs +213 -197
- package/src/runtime/web-search/tool-defs.mjs +47 -13
- package/src/session-runtime/agent-tool-routing.mjs +21 -19
- package/src/session-runtime/bridge-first-use-gate.mjs +18 -11
- package/src/session-runtime/builtin-features.d.mts +13 -4
- package/src/session-runtime/builtin-features.mjs +40 -30
- package/src/session-runtime/channel-config-api.mjs +4 -9
- package/src/session-runtime/config-helpers.mjs +53 -28
- package/src/session-runtime/config-lifecycle.mjs +53 -26
- package/src/session-runtime/context-status.mjs +58 -64
- package/src/session-runtime/cwd-plugins.mjs +19 -14
- package/src/session-runtime/deferred-tool-availability.mjs +9 -0
- package/src/session-runtime/deferred-tool-delta.mjs +2 -5
- package/src/session-runtime/effort.mjs +10 -8
- package/src/session-runtime/extension-scopes.mjs +10 -4
- package/src/session-runtime/fs-utils.mjs +5 -1
- package/src/session-runtime/goal-deadlines.mjs +29 -14
- package/src/session-runtime/goal-facade-api.mjs +9 -9
- package/src/session-runtime/goal-reminder.mjs +7 -11
- package/src/session-runtime/goal-runtime.mjs +211 -120
- package/src/session-runtime/goal-state.mjs +29 -26
- package/src/session-runtime/goal-storage.mjs +16 -5
- package/src/session-runtime/goal-tasks.mjs +45 -23
- package/src/session-runtime/goal-text.mjs +30 -24
- package/src/session-runtime/goal-tool-defs.mjs +91 -47
- package/src/session-runtime/hitch-profile.mjs +1 -1
- package/src/session-runtime/hook-payload.mjs +0 -1
- package/src/session-runtime/inheritance-fit.mjs +13 -15
- package/src/session-runtime/internal-tool-executor.mjs +42 -20
- package/src/session-runtime/lifecycle-api.mjs +289 -216
- package/src/session-runtime/local-model-api.mjs +9 -3
- package/src/session-runtime/local-provider-settings.mjs +19 -8
- package/src/session-runtime/mcp-glue.mjs +28 -21
- package/src/session-runtime/memory-runtime-prewarm.mjs +5 -5
- package/src/session-runtime/model-capabilities.mjs +19 -13
- package/src/session-runtime/model-recency.mjs +27 -11
- package/src/session-runtime/model-route-api.mjs +72 -55
- package/src/session-runtime/native-web-search.mjs +55 -45
- package/src/session-runtime/new-session-config.mjs +44 -0
- package/src/session-runtime/notification-bus.mjs +32 -17
- package/src/session-runtime/orchestration.mjs +27 -0
- package/src/session-runtime/output-styles.mjs +23 -8
- package/src/session-runtime/plugin-mcp.mjs +31 -27
- package/src/session-runtime/prewarm.mjs +96 -68
- package/src/session-runtime/provider-auth-api.mjs +40 -24
- package/src/session-runtime/provider-catalog-cache.mjs +25 -21
- package/src/session-runtime/provider-models.mjs +53 -42
- package/src/session-runtime/provider-readiness.mjs +1 -6
- package/src/session-runtime/provider-request-snapshot.mjs +55 -92
- package/src/session-runtime/provider-request-tools.mjs +13 -13
- package/src/session-runtime/provider-usage.mjs +13 -11
- package/src/session-runtime/quick-model-rows.mjs +19 -17
- package/src/session-runtime/quick-web-search-models.mjs +2 -6
- package/src/session-runtime/resource-api.mjs +78 -60
- package/src/session-runtime/runtime-bootstrap.mjs +5 -1
- package/src/session-runtime/runtime-core.mjs +205 -152
- package/src/session-runtime/runtime-facade.mjs +4 -0
- package/src/session-runtime/runtime-feature-gates.mjs +8 -10
- package/src/session-runtime/runtime-paths.mjs +1 -1
- package/src/session-runtime/runtime-review-api.mjs +4 -8
- package/src/session-runtime/runtime-tool-routing.mjs +11 -13
- package/src/session-runtime/runtime-tunables.mjs +18 -17
- package/src/session-runtime/self-update.mjs +11 -11
- package/src/session-runtime/session-hooks.mjs +62 -38
- package/src/session-runtime/session-lifecycle.mjs +107 -94
- package/src/session-runtime/session-route-policy.mjs +8 -7
- package/src/session-runtime/session-text.mjs +44 -26
- package/src/session-runtime/session-title.mjs +59 -49
- package/src/session-runtime/session-transcript.mjs +15 -8
- package/src/session-runtime/session-turn-api.mjs +503 -392
- package/src/session-runtime/settings-api.mjs +75 -30
- package/src/session-runtime/setup-tool/executor.mjs +152 -69
- package/src/session-runtime/setup-tool/tool-defs.mjs +96 -22
- package/src/session-runtime/skill-tool-loading.mjs +22 -17
- package/src/session-runtime/skills-api.mjs +37 -24
- package/src/session-runtime/statusline-route.mjs +1 -1
- package/src/session-runtime/tool-catalog-data.mjs +56 -11
- package/src/session-runtime/tool-catalog-schema.mjs +21 -24
- package/src/session-runtime/tool-catalog.mjs +155 -137
- package/src/session-runtime/tool-defs.mjs +19 -14
- package/src/session-runtime/tool-policy-refresh.mjs +42 -36
- package/src/session-runtime/tool-profile.mjs +19 -14
- package/src/session-runtime/tool-surface.mjs +34 -52
- package/src/session-runtime/usage-stats-api.mjs +22 -9
- package/src/session-runtime/warmup-schedulers.mjs +10 -8
- package/src/session-runtime/workflow-agents-api.mjs +102 -54
- package/src/session-runtime/workflow.mjs +86 -90
- package/src/standalone/agent-dispatch-broker.mjs +31 -23
- package/src/standalone/agent-task-status.mjs +10 -24
- package/src/standalone/agent-tool/helpers.mjs +44 -9
- package/src/standalone/agent-tool/job-task-reconcile.mjs +16 -15
- package/src/standalone/agent-tool/job-views.mjs +69 -42
- package/src/standalone/agent-tool/lead-worker-index.mjs +28 -18
- package/src/standalone/agent-tool/notify.mjs +23 -11
- package/src/standalone/agent-tool/provider-init.mjs +35 -10
- package/src/standalone/agent-tool/render.mjs +16 -9
- package/src/standalone/agent-tool/spawn-flow.mjs +132 -107
- package/src/standalone/agent-tool/spawn-preset.mjs +3 -5
- package/src/standalone/agent-tool/tag-registry.mjs +145 -3
- package/src/standalone/agent-tool/tool-def.mjs +26 -7
- package/src/standalone/agent-tool/worker-index.mjs +73 -51
- package/src/standalone/agent-tool/worker-rows.mjs +22 -7
- package/src/standalone/agent-tool.mjs +189 -184
- package/src/standalone/agent-watchdog-registry.mjs +32 -11
- package/src/standalone/boot-phase-profiler.mjs +1 -5
- package/src/standalone/channel-admin.mjs +44 -45
- package/src/standalone/channel-binding.mjs +6 -2
- package/src/standalone/channel-client.mjs +238 -151
- package/src/standalone/channel-session-router.mjs +8 -10
- package/src/standalone/channel-transport.mjs +233 -115
- package/src/standalone/channel-worker.mjs +74 -40
- package/src/standalone/daemon-boot-coordinator.mjs +2 -2
- package/src/standalone/daemon-crash-capture.mjs +81 -37
- package/src/standalone/daemon-log.mjs +34 -15
- package/src/standalone/daemon-telemetry.mjs +14 -9
- package/src/standalone/daemon.mjs +199 -117
- package/src/standalone/desktop-service-registry.mjs +28 -19
- package/src/standalone/fair-call-scheduler.mjs +18 -20
- package/src/standalone/folder-dialog.mjs +19 -10
- package/src/standalone/hook-bus/command-handler.mjs +31 -18
- package/src/standalone/hook-bus/config.mjs +22 -14
- package/src/standalone/hook-bus/constants.mjs +1 -5
- package/src/standalone/hook-bus/handlers.mjs +68 -29
- package/src/standalone/hook-bus/rules.mjs +6 -4
- package/src/standalone/hook-bus.mjs +76 -49
- package/src/standalone/memory-runtime-proxy.mjs +187 -132
- package/src/standalone/opencode-go-login.mjs +22 -7
- package/src/standalone/plugin-admin.mjs +52 -41
- package/src/standalone/projects.mjs +1 -3
- package/src/standalone/provider-admin.mjs +173 -67
- package/src/standalone/rpc-call-identity.mjs +3 -4
- package/src/standalone/seeds.mjs +18 -4
- package/src/standalone/session-attachment-pool.mjs +1 -6
- package/src/standalone/session-call-cache.mjs +62 -33
- package/src/standalone/session-client.mjs +245 -187
- package/src/standalone/session-frame-stream.mjs +44 -24
- package/src/standalone/session-protocol.mjs +4 -0
- package/src/standalone/session-proxy.mjs +152 -110
- package/src/standalone/session-runtime-agent-control-client.mjs +41 -39
- package/src/standalone/session-runtime-host-factory.mjs +11 -6
- package/src/standalone/session-runtime-host.mjs +291 -203
- package/src/standalone/session-runtime-inline-host.mjs +29 -35
- package/src/standalone/session-runtime-provider-cooldown.mjs +15 -15
- package/src/standalone/session-runtime-record.mjs +3 -1
- package/src/standalone/session-runtime-shard-router.mjs +12 -6
- package/src/standalone/session-runtime-worker.mjs +105 -74
- package/src/standalone/session-service/agent-tree.mjs +63 -70
- package/src/standalone/session-service/projection.mjs +37 -31
- package/src/standalone/session-service/stored-reader.mjs +2 -3
- package/src/standalone/session-service.mjs +130 -134
- package/src/standalone/session-state-patch.mjs +2 -7
- package/src/standalone/session-state-projection.mjs +1 -1
- package/src/standalone/session-transport.mjs +110 -89
- package/src/standalone/session-wire.mjs +8 -9
- package/src/standalone/usage-dashboard-model.mjs +170 -93
- package/src/standalone/usage-dashboard.mjs +14 -15
- package/src/standalone/usage-stats-hours.mjs +49 -13
- package/src/standalone/usage-stats-model.mjs +38 -43
- package/src/standalone/usage-stats-period.mjs +46 -11
- package/src/tui/App.jsx +167 -272
- package/src/tui/app/app-format.mjs +26 -28
- package/src/tui/app/app-view.jsx +363 -177
- package/src/tui/app/clipboard.mjs +4 -2
- package/src/tui/app/core-memory-picker.mjs +18 -22
- package/src/tui/app/create-app-pickers.mjs +10 -12
- package/src/tui/app/doctor.mjs +14 -3
- package/src/tui/app/extension-pickers.mjs +43 -20
- package/src/tui/app/input-parsers.mjs +19 -45
- package/src/tui/app/live-spinner-visibility.mjs +15 -12
- package/src/tui/app/maintenance-pickers.mjs +63 -37
- package/src/tui/app/message-selector.mjs +27 -19
- package/src/tui/app/model-options.mjs +40 -45
- package/src/tui/app/model-picker.mjs +98 -76
- package/src/tui/app/onboarding-steps.mjs +50 -33
- package/src/tui/app/panel-surface.mjs +1 -3
- package/src/tui/app/project-picker.mjs +25 -24
- package/src/tui/app/prompt-submit.mjs +143 -86
- package/src/tui/app/provider-setup-picker.mjs +66 -49
- package/src/tui/app/resume-picker.mjs +13 -11
- package/src/tui/app/route-pickers.mjs +71 -51
- package/src/tui/app/settings-picker.mjs +93 -57
- package/src/tui/app/shell-layout.mjs +78 -66
- package/src/tui/app/slash-commands.mjs +57 -11
- package/src/tui/app/slash-dispatch.mjs +80 -52
- package/src/tui/app/text-entry-policy.mjs +1 -5
- package/src/tui/app/text-layout.mjs +2 -2
- package/src/tui/app/theme-effort-pickers.mjs +36 -25
- package/src/tui/app/transcript-row-estimate.mjs +51 -23
- package/src/tui/app/transcript-window.mjs +142 -147
- package/src/tui/app/usage-context-panels.mjs +39 -28
- package/src/tui/app/use-copy-selection.mjs +44 -45
- package/src/tui/app/use-global-key-input.mjs +131 -116
- package/src/tui/app/use-mouse-input.mjs +78 -52
- package/src/tui/app/use-prompt-draft-flow.mjs +96 -75
- package/src/tui/app/use-prompt-handlers.mjs +259 -208
- package/src/tui/app/use-prompt-hint.mjs +7 -7
- package/src/tui/app/use-prompt-queue-history.mjs +109 -95
- package/src/tui/app/use-terminal-chrome.mjs +3 -1
- package/src/tui/app/use-transcript-activity.mjs +16 -7
- package/src/tui/app/use-transcript-scroll.mjs +484 -442
- package/src/tui/app/use-transcript-window.mjs +101 -84
- package/src/tui/app/use-welcome-prompt-hint.mjs +8 -3
- package/src/tui/components/AnsiText.jsx +1 -4
- package/src/tui/components/ConfirmBar.jsx +1 -5
- package/src/tui/components/ContextPanel.jsx +38 -13
- package/src/tui/components/ItemRightHintOverprint.jsx +8 -17
- package/src/tui/components/Markdown.jsx +32 -31
- package/src/tui/components/MarkdownTable.jsx +0 -1
- package/src/tui/components/Message.jsx +20 -18
- package/src/tui/components/Picker.jsx +136 -51
- package/src/tui/components/PromptInput.jsx +523 -471
- package/src/tui/components/QueuedCommands.jsx +13 -5
- package/src/tui/components/SlashCommandPalette.jsx +27 -22
- package/src/tui/components/Spinner.jsx +106 -39
- package/src/tui/components/StatusLine.jsx +143 -59
- package/src/tui/components/TextEntryPanel.jsx +219 -189
- package/src/tui/components/ToolExecution.jsx +120 -72
- package/src/tui/components/TranscriptItem.jsx +88 -16
- package/src/tui/components/TurnDone.jsx +48 -10
- package/src/tui/components/UsagePanel.jsx +38 -17
- package/src/tui/components/prompt-input/edit-helpers.mjs +4 -8
- package/src/tui/components/prompt-input/escape-policy.mjs +7 -8
- package/src/tui/components/prompt-input/restore-policy.d.mts +3 -6
- package/src/tui/components/prompt-input/restore-policy.mjs +30 -38
- package/src/tui/components/tool-execution/ResultBody.jsx +16 -16
- package/src/tui/components/tool-output-format.mjs +20 -20
- package/src/tui/dist/index.mjs +18057 -16856
- package/src/tui/index.jsx +139 -42
- package/src/tui/input-editing.mjs +6 -7
- package/src/tui/lib/voice-setup.mjs +2 -4
- package/src/tui/markdown/format-token.mjs +111 -55
- package/src/tui/markdown/measure-rendered-rows.mjs +34 -24
- package/src/tui/markdown/render-ansi.mjs +15 -15
- package/src/tui/markdown/stream-fence.mjs +6 -6
- package/src/tui/markdown/streaming-markdown.mjs +3 -8
- package/src/tui/markdown/table-layout.mjs +3 -4
- package/src/tui/paste-attachments.mjs +43 -22
- package/src/tui/paste-text-policy.mjs +4 -3
- package/src/tui/prompt-history-store.mjs +15 -18
- package/src/tui/session/agent-envelope.mjs +106 -58
- package/src/tui/session/agent-job-feed.mjs +105 -71
- package/src/tui/session/agent-response-tail.mjs +10 -8
- package/src/tui/session/boot-profile.mjs +1 -1
- package/src/tui/session/context-state.mjs +25 -19
- package/src/tui/session/goal-continuation.mjs +20 -25
- package/src/tui/session/goal-turn-state.mjs +4 -2
- package/src/tui/session/labels.mjs +3 -12
- package/src/tui/session/live-share.mjs +250 -132
- package/src/tui/session/notice-text.mjs +4 -5
- package/src/tui/session/notification-plan.mjs +10 -4
- package/src/tui/session/oauth-flows.mjs +26 -21
- package/src/tui/session/prompt-history.mjs +4 -1
- package/src/tui/session/queue-helpers.mjs +33 -31
- package/src/tui/session/render-frame-source.mjs +9 -9
- package/src/tui/session/render-timing.mjs +69 -79
- package/src/tui/session/session-api-ext.mjs +234 -148
- package/src/tui/session/session-api.mjs +142 -63
- package/src/tui/session/session-flow.mjs +216 -155
- package/src/tui/session/tool-approval.mjs +12 -4
- package/src/tui/session/tool-call-fields.mjs +2 -6
- package/src/tui/session/tool-card-results.mjs +41 -10
- package/src/tui/session/tool-result-status.mjs +34 -41
- package/src/tui/session/tool-result-text.mjs +48 -13
- package/src/tui/session/transcript-spill.mjs +73 -46
- package/src/tui/session/tui-steering-persist.mjs +105 -83
- package/src/tui/session/turn-aggregate-cards.mjs +19 -14
- package/src/tui/session/turn-deferred-cards.mjs +23 -6
- package/src/tui/session/turn.mjs +278 -120
- package/src/tui/session-local.mjs +277 -151
- package/src/tui/spinner-meta.mjs +6 -2
- package/src/tui/spinner-verbs.mjs +188 -35
- package/src/tui/statusline-ansi-bridge.mjs +10 -8
- package/src/tui/theme.mjs +9 -16
- package/src/tui/themes/catppuccin.mjs +0 -1
- package/src/tui/themes/index.mjs +85 -15
- package/src/tui/themes/nord.mjs +0 -1
- package/src/tui/themes/utils.mjs +8 -12
- package/src/tui/transcript-tool-failures.mjs +3 -1
- package/src/ui/ansi.mjs +13 -13
- package/src/ui/context-measurement.mjs +24 -15
- package/src/ui/markdown.mjs +28 -23
- package/src/ui/model-display.mjs +6 -8
- package/src/ui/statusline-agents.mjs +33 -18
- package/src/ui/statusline-format.mjs +2 -2
- package/src/ui/statusline-segments.mjs +27 -9
- package/src/ui/statusline.mjs +149 -66
- package/src/ui/streaming-markdown-heal.mjs +57 -6
- package/src/ui/tool-card.mjs +5 -1
- package/src/workflows/default/WORKFLOW.md +3 -10
- package/src/workflows/headless/WORKFLOW.md +0 -1
- package/src/defaults/cycle3-review-prompt.md +0 -144
- package/src/defaults/memory-promote-prompt.md +0 -176
- package/src/rules/agent/42-cycle3-agent.md +0 -33
- package/src/runtime/agent/orchestrator/session/manager/prompt-surface-publish.mjs +0 -35
- package/src/runtime/memory/lib/core-memory-candidates.mjs +0 -359
- package/src/runtime/memory/lib/generated-memory-management.mjs +0 -98
- package/src/runtime/memory/lib/memory-authority-review.mjs +0 -89
- package/src/runtime/memory/lib/memory-cycle2-gate.mjs +0 -792
- package/src/runtime/memory/lib/memory-cycle3-evidence.mjs +0 -117
- package/src/runtime/memory/lib/memory-cycle3-generated.mjs +0 -76
- package/src/runtime/memory/lib/memory-cycle3-guards.mjs +0 -272
- package/src/runtime/memory/lib/memory-cycle3.mjs +0 -811
- package/src/runtime/memory/lib/memory-source-evidence.mjs +0 -34
- package/src/runtime/memory/lib/phase-merge-verdicts.mjs +0 -54
- package/src/runtime/memory/lib/promotion-fingerprint.mjs +0 -50
- package/src/runtime/memory/lib/prompt-surface-file.mjs +0 -99
- package/src/workflows/solo/WORKFLOW.md +0 -16
|
@@ -14,23 +14,23 @@ import {
|
|
|
14
14
|
createIngestTurnAllocator,
|
|
15
15
|
sessionMessageContentForIngest,
|
|
16
16
|
shouldExcludeIngestMessage,
|
|
17
|
-
} from './session-ingest.mjs'
|
|
18
|
-
import { cleanMemoryText } from './memory.mjs'
|
|
19
|
-
import { flushRawEmbeddings } from './memory-cycle.mjs'
|
|
20
|
-
import { resolveProjectScope } from './project-id-resolver.mjs'
|
|
21
|
-
import crypto from 'node:crypto'
|
|
17
|
+
} from './session-ingest.mjs';
|
|
18
|
+
import { cleanMemoryText } from './memory.mjs';
|
|
19
|
+
import { flushRawEmbeddings } from './memory-cycle.mjs';
|
|
20
|
+
import { resolveProjectScope } from './project-id-resolver.mjs';
|
|
21
|
+
import crypto from 'node:crypto';
|
|
22
22
|
|
|
23
23
|
// Ingest now WAITS for its embedding flush (bounded) so freshly ingested rows
|
|
24
24
|
// are dense-searchable the moment ingest_session returns. On a cold ONNX
|
|
25
25
|
// model the flush can stall on warmup; the race below caps the wait and lets
|
|
26
26
|
// the flush finish in the background (tick fallback still sweeps stragglers).
|
|
27
|
-
const INGEST_EMBED_WAIT_MS = 15_000
|
|
27
|
+
const INGEST_EMBED_WAIT_MS = 15_000;
|
|
28
28
|
|
|
29
29
|
// Short, content-derived key for the durable untimestamped high-water map so the
|
|
30
30
|
// persisted blob stores a fixed-width hash per duplicate identity rather than raw
|
|
31
31
|
// (possibly large) message content.
|
|
32
32
|
function _identityHash(occKey) {
|
|
33
|
-
return crypto.createHash('sha256').update(occKey).digest('hex').slice(0, 24)
|
|
33
|
+
return crypto.createHash('sha256').update(occKey).digest('hex').slice(0, 24);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
export function createSessionIngestRuntime({
|
|
@@ -49,12 +49,12 @@ export function createSessionIngestRuntime({
|
|
|
49
49
|
// embedding work, while still guaranteeing every ingest's rows get their own
|
|
50
50
|
// flush pass (the old boolean guard silently SKIPPED bursts, leaving rows
|
|
51
51
|
// embedding-less until the ~60s tick — a recall (no results) window).
|
|
52
|
-
let _rawEmbedFlushChain = Promise.resolve()
|
|
52
|
+
let _rawEmbedFlushChain = Promise.resolve();
|
|
53
53
|
// Per-session ingest serialization. Concurrent ingest_session calls for the
|
|
54
54
|
// SAME session raced on MAX(source_turn) → duplicate turn allocation. Chain
|
|
55
55
|
// same-session ingests so the MAX read + insert loop for one session never
|
|
56
56
|
// overlaps another for the same session. Different sessions stay parallel.
|
|
57
|
-
const _ingestSessionChains = new Map()
|
|
57
|
+
const _ingestSessionChains = new Map();
|
|
58
58
|
// ── Untimestamped-repeat ordinal state (per session) ──────────────────────
|
|
59
59
|
// `occNext[identity]` = next FREE occurrence ordinal assigned for a
|
|
60
60
|
// (role,content) identity in this session. It disambiguates textually
|
|
@@ -73,33 +73,33 @@ export function createSessionIngestRuntime({
|
|
|
73
73
|
// re-ingest exactly and therefore never mint a duplicate row. See the
|
|
74
74
|
// DURABILITY note at the assignment site for why a persisted high-water cannot
|
|
75
75
|
// recover more than this for indistinguishable untimestamped identicals.
|
|
76
|
-
const _sessionIngestOrdinalState = new Map()
|
|
77
|
-
const _ORDINAL_STATE_MAX_SESSIONS = 2048
|
|
76
|
+
const _sessionIngestOrdinalState = new Map();
|
|
77
|
+
const _ORDINAL_STATE_MAX_SESSIONS = 2048;
|
|
78
78
|
// Touch (LRU) + create-on-miss. Re-inserting on a hit moves the entry to the
|
|
79
79
|
// Map tail; when the cap is exceeded the oldest (head) session is evicted.
|
|
80
80
|
// Eviction is safe because the state is reconstructible (see above).
|
|
81
81
|
function _touchOrdinalState(sessionId) {
|
|
82
|
-
const existing = _sessionIngestOrdinalState.get(sessionId)
|
|
82
|
+
const existing = _sessionIngestOrdinalState.get(sessionId);
|
|
83
83
|
if (existing) {
|
|
84
|
-
_sessionIngestOrdinalState.delete(sessionId)
|
|
85
|
-
_sessionIngestOrdinalState.set(sessionId, existing)
|
|
86
|
-
return existing
|
|
84
|
+
_sessionIngestOrdinalState.delete(sessionId);
|
|
85
|
+
_sessionIngestOrdinalState.set(sessionId, existing);
|
|
86
|
+
return existing;
|
|
87
87
|
}
|
|
88
|
-
const st = { occNext: new Map(), seeded: false, snapshot: [] }
|
|
89
|
-
_sessionIngestOrdinalState.set(sessionId, st)
|
|
88
|
+
const st = { occNext: new Map(), seeded: false, snapshot: [] };
|
|
89
|
+
_sessionIngestOrdinalState.set(sessionId, st);
|
|
90
90
|
while (_sessionIngestOrdinalState.size > _ORDINAL_STATE_MAX_SESSIONS) {
|
|
91
|
-
const oldest = _sessionIngestOrdinalState.keys().next().value
|
|
92
|
-
if (oldest === undefined) break
|
|
93
|
-
_sessionIngestOrdinalState.delete(oldest)
|
|
91
|
+
const oldest = _sessionIngestOrdinalState.keys().next().value;
|
|
92
|
+
if (oldest === undefined) break;
|
|
93
|
+
_sessionIngestOrdinalState.delete(oldest);
|
|
94
94
|
}
|
|
95
|
-
return st
|
|
95
|
+
return st;
|
|
96
96
|
}
|
|
97
97
|
// Ordinal assigned to a given session-message OBJECT at first sight, reused on
|
|
98
98
|
// later hydrates while the live array survives. Resume/reopen JSON-parses a new
|
|
99
99
|
// object graph even when this memory runtime remains warm, so object identity
|
|
100
100
|
// is only the fast/strong signal; the ordered snapshot fallback below handles
|
|
101
101
|
// cloned transcript replays.
|
|
102
|
-
const _ingestedMessageOrdinal = new WeakMap()
|
|
102
|
+
const _ingestedMessageOrdinal = new WeakMap();
|
|
103
103
|
// Assign/reuse the occurrence ordinal for message `m` under identity `occKey`.
|
|
104
104
|
// A re-presented object reuses its recorded ordinal AND advances the session
|
|
105
105
|
// high-water past it (rebuilding occNext from survivors after an eviction);
|
|
@@ -109,15 +109,15 @@ export function createSessionIngestRuntime({
|
|
|
109
109
|
// the cold replay only counted the survivors currently in the array.
|
|
110
110
|
function _assignOccurrence(occNext, occKey, m, floor = 0) {
|
|
111
111
|
if (_ingestedMessageOrdinal.has(m)) {
|
|
112
|
-
const ord = _ingestedMessageOrdinal.get(m)
|
|
113
|
-
if (ord + 1 > (occNext.get(occKey) ?? 0)) occNext.set(occKey, ord + 1)
|
|
114
|
-
return ord
|
|
112
|
+
const ord = _ingestedMessageOrdinal.get(m);
|
|
113
|
+
if (ord + 1 > (occNext.get(occKey) ?? 0)) occNext.set(occKey, ord + 1);
|
|
114
|
+
return ord;
|
|
115
115
|
}
|
|
116
|
-
let ord = occNext.get(occKey) ?? 0
|
|
117
|
-
if (floor > ord) ord = floor
|
|
118
|
-
occNext.set(occKey, ord + 1)
|
|
119
|
-
_ingestedMessageOrdinal.set(m, ord)
|
|
120
|
-
return ord
|
|
116
|
+
let ord = occNext.get(occKey) ?? 0;
|
|
117
|
+
if (floor > ord) ord = floor;
|
|
118
|
+
occNext.set(occKey, ord + 1);
|
|
119
|
+
_ingestedMessageOrdinal.set(m, ord);
|
|
120
|
+
return ord;
|
|
121
121
|
}
|
|
122
122
|
// Reuse an occurrence recovered from the previous ingest's content/order
|
|
123
123
|
// snapshot. Session resume/reopen JSON-parses the transcript, so every row is
|
|
@@ -125,75 +125,77 @@ export function createSessionIngestRuntime({
|
|
|
125
125
|
// stays warm. Object identity alone therefore misclassified a cloned replay
|
|
126
126
|
// as newly appended history and minted a new source_ref for every old turn.
|
|
127
127
|
function _reuseOccurrence(occNext, occKey, m, occurrence) {
|
|
128
|
-
const ord = Math.max(0, Math.floor(Number(occurrence) || 0))
|
|
129
|
-
if (ord + 1 > (occNext.get(occKey) ?? 0)) occNext.set(occKey, ord + 1)
|
|
130
|
-
_ingestedMessageOrdinal.set(m, ord)
|
|
131
|
-
return ord
|
|
128
|
+
const ord = Math.max(0, Math.floor(Number(occurrence) || 0));
|
|
129
|
+
if (ord + 1 > (occNext.get(occKey) ?? 0)) occNext.set(occKey, ord + 1);
|
|
130
|
+
_ingestedMessageOrdinal.set(m, ord);
|
|
131
|
+
return ord;
|
|
132
132
|
}
|
|
133
133
|
// Cache of legacy identity fields and full source content per message OBJECT, keyed by
|
|
134
134
|
// identity (WeakMap — entries vanish once the message is GC'd, e.g. after
|
|
135
135
|
// compaction or JSON reload replaces the array). Live-array steady-state calls
|
|
136
136
|
// reuse the cache; cloned replays recompute once and then reconcile against the
|
|
137
137
|
// ordered snapshot.
|
|
138
|
-
const _ingestIdentityFieldsCache = new WeakMap()
|
|
138
|
+
const _ingestIdentityFieldsCache = new WeakMap();
|
|
139
139
|
// Return { role, content, rawContent } for dedup identity and storage, or null if
|
|
140
140
|
// the message would be skipped by ingest (no role / excluded / empty content
|
|
141
141
|
// after cleaning). Cached per message object so repeated calls over the same
|
|
142
142
|
// (unchanged) transcript prefix never re-run the expensive clean/normalize
|
|
143
143
|
// regex pipeline.
|
|
144
144
|
function _ingestIdentityFields(m) {
|
|
145
|
-
if (_ingestIdentityFieldsCache.has(m)) return _ingestIdentityFieldsCache.get(m)
|
|
146
|
-
let fields = null
|
|
147
|
-
const role = normalizeIngestRole(m.role)
|
|
145
|
+
if (_ingestIdentityFieldsCache.has(m)) return _ingestIdentityFieldsCache.get(m);
|
|
146
|
+
let fields = null;
|
|
147
|
+
const role = normalizeIngestRole(m.role);
|
|
148
148
|
if (role && !shouldExcludeIngestMessage(m)) {
|
|
149
|
-
const rawContent = sessionMessageContentForIngest(m)
|
|
149
|
+
const rawContent = sessionMessageContentForIngest(m);
|
|
150
150
|
if (rawContent && rawContent.trim()) {
|
|
151
151
|
// Preserve existing replay identities without persisting their lossy
|
|
152
152
|
// search projection. Previously skipped code/URL-only rows get their
|
|
153
153
|
// full content as identity; there is no legacy row to collide with.
|
|
154
|
-
const content = cleanMemoryText(rawContent) || rawContent
|
|
155
|
-
fields = { role, content, rawContent }
|
|
154
|
+
const content = cleanMemoryText(rawContent) || rawContent;
|
|
155
|
+
fields = { role, content, rawContent };
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
|
-
_ingestIdentityFieldsCache.set(m, fields)
|
|
159
|
-
return fields
|
|
158
|
+
_ingestIdentityFieldsCache.set(m, fields);
|
|
159
|
+
return fields;
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
async function ingestSessionMessages(args = {}) {
|
|
163
|
-
const sessionId = String(args.sessionId || args.session_id || `session-${Date.now()}`).trim()
|
|
163
|
+
const sessionId = String(args.sessionId || args.session_id || `session-${Date.now()}`).trim();
|
|
164
164
|
// Serialize per-session so the MAX(source_turn) read + insert loop for one
|
|
165
165
|
// session never overlaps a concurrent ingest for the SAME session (they
|
|
166
166
|
// otherwise race the turn allocator and double-allocate). Distinct sessions
|
|
167
167
|
// run in parallel.
|
|
168
|
-
const prev = _ingestSessionChains.get(sessionId) ?? Promise.resolve()
|
|
169
|
-
const run = prev.catch(() => {}).then(() => _ingestSessionMessagesImpl(sessionId, args))
|
|
170
|
-
_ingestSessionChains.set(
|
|
171
|
-
|
|
168
|
+
const prev = _ingestSessionChains.get(sessionId) ?? Promise.resolve();
|
|
169
|
+
const run = prev.catch(() => {}).then(() => _ingestSessionMessagesImpl(sessionId, args));
|
|
170
|
+
_ingestSessionChains.set(
|
|
171
|
+
sessionId,
|
|
172
|
+
run.catch(() => {})
|
|
173
|
+
);
|
|
174
|
+
const tail = _ingestSessionChains.get(sessionId);
|
|
172
175
|
try {
|
|
173
|
-
return await run
|
|
176
|
+
return await run;
|
|
174
177
|
} finally {
|
|
175
178
|
// Best-effort GC: drop the map entry only if no later call chained after us.
|
|
176
|
-
if (_ingestSessionChains.get(sessionId) === tail) _ingestSessionChains.delete(sessionId)
|
|
179
|
+
if (_ingestSessionChains.get(sessionId) === tail) _ingestSessionChains.delete(sessionId);
|
|
177
180
|
}
|
|
178
181
|
}
|
|
179
182
|
|
|
180
183
|
async function _ingestSessionMessagesImpl(sessionId, args = {}) {
|
|
181
|
-
const db = getDb()
|
|
182
|
-
const messages = Array.isArray(args.messages) ? args.messages : []
|
|
184
|
+
const db = getDb();
|
|
185
|
+
const messages = Array.isArray(args.messages) ? args.messages : [];
|
|
183
186
|
// Recall fast-track hydrates the current session before compaction; allow
|
|
184
187
|
// callers to ingest the full in-memory transcript instead of silently
|
|
185
188
|
// clipping long sessions at 500 turns. Default remains conservative.
|
|
186
|
-
const limit =
|
|
187
|
-
? messages.length
|
|
188
|
-
|
|
189
|
-
const
|
|
190
|
-
|
|
191
|
-
let
|
|
192
|
-
let inserted = 0
|
|
189
|
+
const limit =
|
|
190
|
+
args.fullTranscript === true ? messages.length : Math.max(1, Math.min(5000, Number(args.limit) || 200));
|
|
191
|
+
const start = Math.max(0, messages.length - limit);
|
|
192
|
+
const projectId = resolveProjectScope(typeof args.cwd === 'string' && args.cwd ? args.cwd : null);
|
|
193
|
+
let considered = 0;
|
|
194
|
+
let inserted = 0;
|
|
193
195
|
// Ids of rows THIS call actually inserted (ON CONFLICT skips return no id).
|
|
194
196
|
// The post-ingest flush is scoped to exactly these so ingest_session never
|
|
195
197
|
// synchronously inherits other calls'/sessions' raw-embedding backlog.
|
|
196
|
-
const insertedIds = []
|
|
198
|
+
const insertedIds = [];
|
|
197
199
|
// Monotonic ingest order, independent of the current (post-compaction)
|
|
198
200
|
// array index. source_turn used to be `i+1`, but after compaction shrinks /
|
|
199
201
|
// reindexes session.messages a NEWLY appended turn gets a LOW i and thus a
|
|
@@ -203,15 +205,17 @@ export function createSessionIngestRuntime({
|
|
|
203
205
|
// new row is assigned a turn strictly greater than all previously-ingested
|
|
204
206
|
// ones (true continuation order). Re-ingested (ON CONFLICT) rows keep their
|
|
205
207
|
// original turn and do not consume a new one.
|
|
206
|
-
let prevMaxTurn = 0
|
|
208
|
+
let prevMaxTurn = 0;
|
|
207
209
|
try {
|
|
208
210
|
const maxRow = await db.query(
|
|
209
211
|
`SELECT COALESCE(MAX(source_turn), 0) AS max_turn FROM entries WHERE session_id = $1`,
|
|
210
|
-
[sessionId]
|
|
211
|
-
)
|
|
212
|
-
prevMaxTurn = Number(maxRow.rows?.[0]?.max_turn) || 0
|
|
213
|
-
} catch {
|
|
214
|
-
|
|
212
|
+
[sessionId]
|
|
213
|
+
);
|
|
214
|
+
prevMaxTurn = Number(maxRow.rows?.[0]?.max_turn) || 0;
|
|
215
|
+
} catch {
|
|
216
|
+
prevMaxTurn = 0;
|
|
217
|
+
}
|
|
218
|
+
const turnAllocator = createIngestTurnAllocator(prevMaxTurn);
|
|
215
219
|
// ── Untimestamped-repeat ordinal: re-ingest vs genuine-append distinction ─
|
|
216
220
|
// The ordinal folded into stableSessionSourceRef must satisfy BOTH: a
|
|
217
221
|
// full/subset re-ingest of the SAME messages reproduces the exact ordinal →
|
|
@@ -244,27 +248,29 @@ export function createSessionIngestRuntime({
|
|
|
244
248
|
// (unavoidable) collapse is an identical append that is ALREADY inside the
|
|
245
249
|
// cold-replay array on a compacted restart — indistinguishable from a
|
|
246
250
|
// survivor (identical content, no per-message id); it never DUPLICATES.
|
|
247
|
-
const ordinalState = _touchOrdinalState(sessionId)
|
|
248
|
-
const occNext = ordinalState.occNext
|
|
251
|
+
const ordinalState = _touchOrdinalState(sessionId);
|
|
252
|
+
const occNext = ordinalState.occNext;
|
|
249
253
|
// A first-seen turn is a genuine new append (eligible for the durable floor)
|
|
250
254
|
// only in a WARM call — one whose ordinal state was already established by an
|
|
251
255
|
// earlier ingest. In the establishing (cold) call every array message is
|
|
252
256
|
// positional-replayed, so the floor must NOT apply.
|
|
253
|
-
const warmCall = ordinalState.seeded
|
|
257
|
+
const warmCall = ordinalState.seeded;
|
|
254
258
|
if (!ordinalState.durableLoaded) {
|
|
255
259
|
// Load once per (re)established state; on LRU eviction the state is dropped
|
|
256
260
|
// and reloaded here, so the high-water survives eviction too. Best-effort.
|
|
257
|
-
ordinalState.durable = new Map()
|
|
261
|
+
ordinalState.durable = new Map();
|
|
258
262
|
try {
|
|
259
|
-
const raw = await loadOrdinalHighWater(sessionId)
|
|
263
|
+
const raw = await loadOrdinalHighWater(sessionId);
|
|
260
264
|
if (raw && typeof raw === 'object') {
|
|
261
265
|
for (const [k, v] of Object.entries(raw)) {
|
|
262
|
-
const n = Number(v)
|
|
263
|
-
if (Number.isFinite(n) && n > 0) ordinalState.durable.set(k, Math.floor(n))
|
|
266
|
+
const n = Number(v);
|
|
267
|
+
if (Number.isFinite(n) && n > 0) ordinalState.durable.set(k, Math.floor(n));
|
|
264
268
|
}
|
|
265
269
|
}
|
|
266
|
-
} catch {
|
|
267
|
-
|
|
270
|
+
} catch {
|
|
271
|
+
/* absent/corrupt state file → in-memory only (invariant 2 safe) */
|
|
272
|
+
}
|
|
273
|
+
ordinalState.durableLoaded = true;
|
|
268
274
|
}
|
|
269
275
|
// Content/order fallback for JSON-cloned transcript replays. The previous
|
|
270
276
|
// eligible sequence is indexed by a stable base source key; a greedy
|
|
@@ -273,89 +279,97 @@ export function createSessionIngestRuntime({
|
|
|
273
279
|
// stronger WeakMap occurrence and advance the cursor to that exact prior
|
|
274
280
|
// occurrence. Unmatched rows alone consume the historical high-water, so a
|
|
275
281
|
// genuine append remains distinct while a reopen/reload stays idempotent.
|
|
276
|
-
const priorSnapshot = Array.isArray(ordinalState.snapshot) ? ordinalState.snapshot : []
|
|
277
|
-
const priorByKey = new Map()
|
|
282
|
+
const priorSnapshot = Array.isArray(ordinalState.snapshot) ? ordinalState.snapshot : [];
|
|
283
|
+
const priorByKey = new Map();
|
|
278
284
|
for (let i = 0; i < priorSnapshot.length; i += 1) {
|
|
279
|
-
const item = priorSnapshot[i]
|
|
280
|
-
if (!item?.key) continue
|
|
281
|
-
if (!priorByKey.has(item.key)) priorByKey.set(item.key, [])
|
|
282
|
-
priorByKey.get(item.key).push({ index: i, occurrence: item.occurrence })
|
|
285
|
+
const item = priorSnapshot[i];
|
|
286
|
+
if (!item?.key) continue;
|
|
287
|
+
if (!priorByKey.has(item.key)) priorByKey.set(item.key, []);
|
|
288
|
+
priorByKey.get(item.key).push({ index: i, occurrence: item.occurrence });
|
|
283
289
|
}
|
|
284
|
-
const priorPointers = new Map()
|
|
285
|
-
let priorCursor = 0
|
|
290
|
+
const priorPointers = new Map();
|
|
291
|
+
let priorCursor = 0;
|
|
286
292
|
const takePrior = (key, wantedOccurrence = null) => {
|
|
287
|
-
const list = priorByKey.get(key)
|
|
288
|
-
if (!list?.length) return null
|
|
289
|
-
let p = priorPointers.get(key) ?? 0
|
|
290
|
-
while (p < list.length && list[p].index < priorCursor) p += 1
|
|
293
|
+
const list = priorByKey.get(key);
|
|
294
|
+
if (!list?.length) return null;
|
|
295
|
+
let p = priorPointers.get(key) ?? 0;
|
|
296
|
+
while (p < list.length && list[p].index < priorCursor) p += 1;
|
|
291
297
|
if (wantedOccurrence != null) {
|
|
292
|
-
while (
|
|
293
|
-
|
|
294
|
-
|
|
298
|
+
while (
|
|
299
|
+
p < list.length &&
|
|
300
|
+
list[p].index >= priorCursor &&
|
|
301
|
+
Number(list[p].occurrence) !== Number(wantedOccurrence)
|
|
302
|
+
)
|
|
303
|
+
p += 1;
|
|
295
304
|
}
|
|
296
305
|
if (p >= list.length) {
|
|
297
|
-
priorPointers.set(key, p)
|
|
298
|
-
return null
|
|
306
|
+
priorPointers.set(key, p);
|
|
307
|
+
return null;
|
|
299
308
|
}
|
|
300
|
-
const match = list[p]
|
|
301
|
-
priorPointers.set(key, p + 1)
|
|
302
|
-
priorCursor = match.index + 1
|
|
303
|
-
return match
|
|
304
|
-
}
|
|
305
|
-
const currentSnapshot = []
|
|
306
|
-
const prepared = []
|
|
309
|
+
const match = list[p];
|
|
310
|
+
priorPointers.set(key, p + 1);
|
|
311
|
+
priorCursor = match.index + 1;
|
|
312
|
+
return match;
|
|
313
|
+
};
|
|
314
|
+
const currentSnapshot = [];
|
|
315
|
+
const prepared = [];
|
|
307
316
|
for (let i = 0; i < messages.length; i += 1) {
|
|
308
|
-
const m = messages[i]
|
|
309
|
-
if (!m || typeof m !== 'object') continue
|
|
310
|
-
const fields = _ingestIdentityFields(m)
|
|
311
|
-
if (!fields) continue
|
|
312
|
-
const { role, content, rawContent } = fields
|
|
313
|
-
const occKey = `${role}\u0000${content}
|
|
314
|
-
const rawTs = m.ts ?? m.timestamp
|
|
315
|
-
const untimestamped = !(
|
|
316
|
-
|
|
317
|
-
|
|
317
|
+
const m = messages[i];
|
|
318
|
+
if (!m || typeof m !== 'object') continue;
|
|
319
|
+
const fields = _ingestIdentityFields(m);
|
|
320
|
+
if (!fields) continue;
|
|
321
|
+
const { role, content, rawContent } = fields;
|
|
322
|
+
const occKey = `${role}\u0000${content}`;
|
|
323
|
+
const rawTs = m.ts ?? m.timestamp;
|
|
324
|
+
const untimestamped = !(
|
|
325
|
+
(typeof rawTs === 'number' && Number.isFinite(rawTs)) ||
|
|
326
|
+
(typeof rawTs === 'string' && rawTs.trim())
|
|
327
|
+
);
|
|
328
|
+
const idHash = untimestamped ? _identityHash(occKey) : null;
|
|
318
329
|
// occurrence=0 makes a stable match key: timestamp/tool ids remain part
|
|
319
330
|
// of the key, while repeated untimestamped text shares a key and is
|
|
320
331
|
// disambiguated by ordered snapshot occurrences.
|
|
321
|
-
const snapshotKey = stableSessionSourceRef(sessionId, m, role, content, 0)
|
|
322
|
-
let occurrence
|
|
332
|
+
const snapshotKey = stableSessionSourceRef(sessionId, m, role, content, 0);
|
|
333
|
+
let occurrence;
|
|
323
334
|
if (_ingestedMessageOrdinal.has(m)) {
|
|
324
|
-
occurrence = _assignOccurrence(occNext, occKey, m)
|
|
325
|
-
takePrior(snapshotKey, occurrence)
|
|
335
|
+
occurrence = _assignOccurrence(occNext, occKey, m);
|
|
336
|
+
takePrior(snapshotKey, occurrence);
|
|
326
337
|
} else {
|
|
327
|
-
const prior = takePrior(snapshotKey)
|
|
338
|
+
const prior = takePrior(snapshotKey);
|
|
328
339
|
if (prior) {
|
|
329
|
-
occurrence = _reuseOccurrence(occNext, occKey, m, prior.occurrence)
|
|
340
|
+
occurrence = _reuseOccurrence(occNext, occKey, m, prior.occurrence);
|
|
330
341
|
} else {
|
|
331
|
-
const floor =
|
|
332
|
-
occurrence = _assignOccurrence(occNext, occKey, m, floor)
|
|
342
|
+
const floor = warmCall && untimestamped ? (ordinalState.durable.get(idHash) ?? 0) : 0;
|
|
343
|
+
occurrence = _assignOccurrence(occNext, occKey, m, floor);
|
|
333
344
|
}
|
|
334
345
|
}
|
|
335
346
|
if (untimestamped && occurrence >= 1) {
|
|
336
347
|
// Duplicate untimestamped identity (occurrence>0): record/raise its durable
|
|
337
348
|
// next-ordinal (write-behind persisted below). Monotonic — never regresses
|
|
338
349
|
// a loaded K, so a cold replay counting only survivors can't shrink it.
|
|
339
|
-
const cur = ordinalState.durable.get(idHash) ?? 0
|
|
340
|
-
if (occurrence + 1 > cur) {
|
|
350
|
+
const cur = ordinalState.durable.get(idHash) ?? 0;
|
|
351
|
+
if (occurrence + 1 > cur) {
|
|
352
|
+
ordinalState.durable.set(idHash, occurrence + 1);
|
|
353
|
+
ordinalState.dirty = true;
|
|
354
|
+
}
|
|
341
355
|
}
|
|
342
|
-
currentSnapshot.push({ key: snapshotKey, occurrence })
|
|
356
|
+
currentSnapshot.push({ key: snapshotKey, occurrence });
|
|
343
357
|
if (i >= start) {
|
|
344
|
-
considered += 1
|
|
345
|
-
prepared.push({ m, role, content, rawContent, occurrence, index: i, untimestamped })
|
|
358
|
+
considered += 1;
|
|
359
|
+
prepared.push({ m, role, content, rawContent, occurrence, index: i, untimestamped });
|
|
346
360
|
}
|
|
347
361
|
}
|
|
348
|
-
ordinalState.snapshot = currentSnapshot
|
|
349
|
-
ordinalState.seeded = true
|
|
362
|
+
ordinalState.snapshot = currentSnapshot;
|
|
363
|
+
ordinalState.seeded = true;
|
|
350
364
|
for (const { m, role, content, rawContent, occurrence, index, untimestamped } of prepared) {
|
|
351
|
-
const fallbackTs = Date.now() - (messages.length - index)
|
|
352
|
-
const rawTimestamp = m.ts ?? m.timestamp
|
|
353
|
-
const timeSource = untimestamped ? 'collected' : 'recorded'
|
|
354
|
-
const tsMs = untimestamped ? fallbackTs : parseTsToMs(rawTimestamp)
|
|
365
|
+
const fallbackTs = Date.now() - (messages.length - index);
|
|
366
|
+
const rawTimestamp = m.ts ?? m.timestamp;
|
|
367
|
+
const timeSource = untimestamped ? 'collected' : 'recorded';
|
|
368
|
+
const tsMs = untimestamped ? fallbackTs : parseTsToMs(rawTimestamp);
|
|
355
369
|
// Assign the next monotonic turn BEFORE building the source_ref so identical
|
|
356
370
|
// untimestamped repeats get distinct identities (peekNext is stable until a
|
|
357
371
|
// row is actually inserted → next()).
|
|
358
|
-
const assignedTurn = turnAllocator.peekNext()
|
|
372
|
+
const assignedTurn = turnAllocator.peekNext();
|
|
359
373
|
// Stable per-message identity. The previous `session:${id}#${i+1}` key was
|
|
360
374
|
// positional, so after compaction shrinks/reindexes session.messages a
|
|
361
375
|
// later turn could reuse an old index and be silently skipped by
|
|
@@ -363,19 +377,22 @@ export function createSessionIngestRuntime({
|
|
|
363
377
|
// fields (role, original ts if present, tool ids, content) — never the
|
|
364
378
|
// synthesized tsMs fallback or the loop index. For untimestamped turns the
|
|
365
379
|
// monotonic ordinal is folded in so genuine repeats persist (not collapsed).
|
|
366
|
-
const sourceRef = stableSessionSourceRef(sessionId, m, role, content, occurrence)
|
|
367
|
-
const result = await db.query(
|
|
380
|
+
const sourceRef = stableSessionSourceRef(sessionId, m, role, content, occurrence);
|
|
381
|
+
const result = await db.query(
|
|
382
|
+
`
|
|
368
383
|
INSERT INTO entries(ts, role, content, source_ref, session_id, source_turn, project_id, time_source)
|
|
369
384
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
|
|
370
385
|
ON CONFLICT DO NOTHING
|
|
371
386
|
RETURNING id
|
|
372
|
-
`,
|
|
373
|
-
|
|
387
|
+
`,
|
|
388
|
+
[tsMs, role, rawContent, sourceRef, sessionId, assignedTurn, projectId, timeSource]
|
|
389
|
+
);
|
|
390
|
+
const rowInserted = Number(result.rowCount ?? result.affectedRows ?? 0) || 0;
|
|
374
391
|
if (rowInserted > 0) {
|
|
375
|
-
inserted += rowInserted
|
|
376
|
-
const newId = result.rows?.[0]?.id
|
|
377
|
-
if (newId != null && Number.isFinite(Number(newId))) insertedIds.push(Number(newId))
|
|
378
|
-
turnAllocator.next()
|
|
392
|
+
inserted += rowInserted;
|
|
393
|
+
const newId = result.rows?.[0]?.id;
|
|
394
|
+
if (newId != null && Number.isFinite(Number(newId))) insertedIds.push(Number(newId));
|
|
395
|
+
turnAllocator.next();
|
|
379
396
|
}
|
|
380
397
|
}
|
|
381
398
|
// Write-behind persist of the durable untimestamped high-water. Not awaited:
|
|
@@ -383,11 +400,11 @@ export function createSessionIngestRuntime({
|
|
|
383
400
|
// post-restart append (never correctness of THIS call). Serialized per
|
|
384
401
|
// session by the chain, so writes cannot interleave for one session.
|
|
385
402
|
if (ordinalState.dirty) {
|
|
386
|
-
ordinalState.dirty = false
|
|
387
|
-
const snapshot = Object.fromEntries(ordinalState.durable)
|
|
403
|
+
ordinalState.dirty = false;
|
|
404
|
+
const snapshot = Object.fromEntries(ordinalState.durable);
|
|
388
405
|
Promise.resolve()
|
|
389
406
|
.then(() => saveOrdinalHighWater(sessionId, snapshot))
|
|
390
|
-
.catch((err) => log(`[ingest] untimestamped high-water persist failed: ${err?.message || err}\n`))
|
|
407
|
+
.catch((err) => log(`[ingest] untimestamped high-water persist failed: ${err?.message || err}\n`));
|
|
391
408
|
}
|
|
392
409
|
// Always-on post-ingest raw embedding: freshly ingested rows become
|
|
393
410
|
// dense-searchable immediately (autoclear/fresh-context hydration,
|
|
@@ -408,12 +425,14 @@ export function createSessionIngestRuntime({
|
|
|
408
425
|
// cap). Serialized on _rawEmbedFlushChain so bursts don't stack full
|
|
409
426
|
// backlog scans; the ~60s tick still sweeps whatever this misses.
|
|
410
427
|
if (insertedIds.length > 0) {
|
|
411
|
-
const runOwnFlush = () =>
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
428
|
+
const runOwnFlush = () =>
|
|
429
|
+
flushRawEmbeddings(db, { limit: 200, ids: insertedIds })
|
|
430
|
+
.then((r) => {
|
|
431
|
+
if (r.attempted > 0)
|
|
432
|
+
log(`[embed] post-ingest raw flush (own) attempted=${r.attempted} embedded=${r.embedded}\n`);
|
|
433
|
+
return r;
|
|
434
|
+
})
|
|
435
|
+
.catch((err) => log(`[embed] post-ingest raw flush failed: ${err?.message || err}\n`));
|
|
417
436
|
// Clear/manual-compact path opts out (embedWait:false): those rows are
|
|
418
437
|
// about to be summarized away, so dense-search immediacy is pointless and
|
|
419
438
|
// the bounded wait would only delay compaction. Enqueue the flush onto
|
|
@@ -425,13 +444,15 @@ export function createSessionIngestRuntime({
|
|
|
425
444
|
_rawEmbedFlushChain = _rawEmbedFlushChain
|
|
426
445
|
.catch(() => {})
|
|
427
446
|
.then(runOwnFlush)
|
|
428
|
-
.catch(() => {})
|
|
447
|
+
.catch(() => {});
|
|
429
448
|
} else {
|
|
430
|
-
let timer
|
|
449
|
+
let timer;
|
|
431
450
|
await Promise.race([
|
|
432
451
|
runOwnFlush(),
|
|
433
|
-
new Promise((resolve) => {
|
|
434
|
-
|
|
452
|
+
new Promise((resolve) => {
|
|
453
|
+
timer = setTimeout(resolve, INGEST_EMBED_WAIT_MS);
|
|
454
|
+
}),
|
|
455
|
+
]).finally(() => clearTimeout(timer));
|
|
435
456
|
}
|
|
436
457
|
}
|
|
437
458
|
// Background backlog sweep — kicked, never awaited. Runs even when THIS
|
|
@@ -441,12 +462,13 @@ export function createSessionIngestRuntime({
|
|
|
441
462
|
.catch(() => {}) // never let a previous flush failure poison the chain
|
|
442
463
|
.then(() => flushRawEmbeddings(db, { limit: 200 }))
|
|
443
464
|
.then((r) => {
|
|
444
|
-
if (r.attempted > 0)
|
|
445
|
-
|
|
465
|
+
if (r.attempted > 0)
|
|
466
|
+
log(`[embed] post-ingest raw flush (backlog) attempted=${r.attempted} embedded=${r.embedded}\n`);
|
|
467
|
+
return r;
|
|
446
468
|
})
|
|
447
|
-
.catch((err) => log(`[embed] post-ingest raw backlog flush failed: ${err?.message || err}\n`))
|
|
448
|
-
return { text: `ingest_session: considered=${considered} inserted=${inserted} session=${sessionId}` }
|
|
469
|
+
.catch((err) => log(`[embed] post-ingest raw backlog flush failed: ${err?.message || err}\n`));
|
|
470
|
+
return { text: `ingest_session: considered=${considered} inserted=${inserted} session=${sessionId}` };
|
|
449
471
|
}
|
|
450
472
|
|
|
451
|
-
return { ingestSessionMessages }
|
|
473
|
+
return { ingestSessionMessages };
|
|
452
474
|
}
|