mixdog 0.9.63 → 0.9.64
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/README.md +3 -0
- package/package.json +9 -2
- package/scripts/code-graph-description-contract.mjs +3 -3
- package/scripts/verify-release-assets.mjs +2 -2
- package/src/runtime/agent/orchestrator/agent-runtime/agent-dispatch.mjs +11 -14
- package/src/runtime/agent/orchestrator/agent-runtime/agent-progress-watchdog.mjs +6 -6
- package/src/runtime/agent/orchestrator/agent-runtime/cache-strategy.mjs +2 -2
- package/src/runtime/agent/orchestrator/agent-trace-format.mjs +1 -0
- package/src/runtime/agent/orchestrator/config.mjs +19 -124
- package/src/runtime/agent/orchestrator/context/collect.mjs +6 -6
- package/src/runtime/agent/orchestrator/dispatch-persist.mjs +2 -2
- package/src/runtime/agent/orchestrator/internal-agents.mjs +2 -2
- package/src/runtime/agent/orchestrator/mcp/child-tree.mjs +1 -1
- package/src/runtime/agent/orchestrator/mcp/client.mjs +4 -4
- package/src/runtime/agent/orchestrator/providers/admission-scheduler.mjs +2 -2
- package/src/runtime/agent/orchestrator/providers/anthropic-betas.mjs +4 -4
- package/src/runtime/agent/orchestrator/providers/anthropic-effort.mjs +2 -2
- package/src/runtime/agent/orchestrator/providers/anthropic-max-tokens.mjs +4 -4
- package/src/runtime/agent/orchestrator/providers/anthropic-messages.mjs +333 -0
- package/src/runtime/agent/orchestrator/providers/anthropic-model-resolve.mjs +2 -2
- package/src/runtime/agent/orchestrator/providers/anthropic-oauth-credentials.mjs +4 -4
- package/src/runtime/agent/orchestrator/providers/anthropic-oauth.mjs +1 -1
- package/src/runtime/agent/orchestrator/providers/anthropic.mjs +3 -277
- package/src/runtime/agent/orchestrator/providers/codex-client-meta.mjs +2 -2
- package/src/runtime/agent/orchestrator/providers/custom-tool-wire.mjs +1 -1
- package/src/runtime/agent/orchestrator/providers/gemini-cache.mjs +2 -2
- package/src/runtime/agent/orchestrator/providers/gemini-stream.mjs +6 -6
- package/src/runtime/agent/orchestrator/providers/grok-oauth-login.mjs +196 -0
- package/src/runtime/agent/orchestrator/providers/grok-oauth-tokens.mjs +460 -0
- package/src/runtime/agent/orchestrator/providers/grok-oauth.mjs +14 -593
- package/src/runtime/agent/orchestrator/providers/lib/anthropic-request-utils.mjs +1 -1
- package/src/runtime/agent/orchestrator/providers/media-normalization.mjs +1 -1
- package/src/runtime/agent/orchestrator/providers/openai-compat-wire.mjs +1 -1
- package/src/runtime/agent/orchestrator/providers/openai-compat-xai.mjs +4 -4
- package/src/runtime/agent/orchestrator/providers/openai-oauth-ws.mjs +2 -2
- package/src/runtime/agent/orchestrator/providers/openai-oauth.mjs +5 -280
- package/src/runtime/agent/orchestrator/providers/openai-responses-payload.mjs +357 -0
- package/src/runtime/agent/orchestrator/providers/openai-ws-headers.mjs +216 -0
- package/src/runtime/agent/orchestrator/providers/openai-ws-pool.mjs +2 -188
- package/src/runtime/agent/orchestrator/providers/openai-ws-stream.mjs +2 -2
- package/src/runtime/agent/orchestrator/providers/openai-ws.mjs +2 -2
- package/src/runtime/agent/orchestrator/providers/opencode-go.mjs +1 -1
- package/src/runtime/agent/orchestrator/providers/provider-catalog-cache.mjs +1 -1
- package/src/runtime/agent/orchestrator/providers/registry.mjs +1 -1
- package/src/runtime/agent/orchestrator/providers/retry-classifier.mjs +2 -2
- package/src/runtime/agent/orchestrator/providers/statusline-route-meta.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/cache/prefetch-cache.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/cache/scoped-cache.mjs +3 -3
- package/src/runtime/agent/orchestrator/session/compact/budget.mjs +2 -2
- package/src/runtime/agent/orchestrator/session/compact/file-reattach.mjs +2 -2
- package/src/runtime/agent/orchestrator/session/compact/summary-schema.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/compact/summary.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/compact/text-utils.mjs +2 -2
- package/src/runtime/agent/orchestrator/session/context-utils.mjs +4 -4
- package/src/runtime/agent/orchestrator/session/loop/deferred-call-through.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/loop/pre-dispatch-deny.mjs +17 -0
- package/src/runtime/agent/orchestrator/session/loop/steering.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/loop/stored-tool-args.mjs +18 -26
- package/src/runtime/agent/orchestrator/session/loop/termination.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/loop/tool-classify.mjs +3 -3
- package/src/runtime/agent/orchestrator/session/manager/compaction-runner.mjs +1 -0
- package/src/runtime/agent/orchestrator/session/manager/context-meta.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/manager/delivered-completions.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/manager/status-telemetry.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/store/live-state.mjs +49 -0
- package/src/runtime/agent/orchestrator/session/store/load-cache.mjs +49 -0
- package/src/runtime/agent/orchestrator/session/store/save-worker.mjs +260 -0
- package/src/runtime/agent/orchestrator/session/store/serialize.mjs +72 -0
- package/src/runtime/agent/orchestrator/session/store/summary-cache.mjs +163 -0
- package/src/runtime/agent/orchestrator/session/store/write-guards.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/store-summary-index.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/store-summary-reader.mjs +4 -1
- package/src/runtime/agent/orchestrator/session/store.mjs +9 -561
- package/src/runtime/agent/orchestrator/session/tool-envelope.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/tool-result-offload.mjs +2 -2
- package/src/runtime/agent/orchestrator/stall-policy.mjs +11 -11
- package/src/runtime/agent/orchestrator/tools/bash-policy-scan.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/bash-session.mjs +2 -2
- package/src/runtime/agent/orchestrator/tools/builtin/advisory-lock.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/builtin/arg-guard.mjs +2 -2
- package/src/runtime/agent/orchestrator/tools/builtin/atomic-write.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/builtin/bash-tool.mjs +2 -154
- package/src/runtime/agent/orchestrator/tools/builtin/cache-layers.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/builtin/cwd-utils.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/builtin/fs-reachability.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/builtin/fuzzy-match.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/builtin/glob-walk.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/builtin/path-locks.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/builtin/path-utils.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/builtin/read-args.mjs +2 -2
- package/src/runtime/agent/orchestrator/tools/builtin/read-formatting.mjs +2 -3
- package/src/runtime/agent/orchestrator/tools/builtin/read-image-resize.mjs +4 -4
- package/src/runtime/agent/orchestrator/tools/builtin/read-open.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/builtin/read-streaming.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/builtin/rg-runner.mjs +2 -2
- package/src/runtime/agent/orchestrator/tools/builtin/search-path-diagnostics.mjs +5 -5
- package/src/runtime/agent/orchestrator/tools/builtin/shell-analysis.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/builtin/shell-job-paths.mjs +2 -2
- package/src/runtime/agent/orchestrator/tools/builtin/shell-job-process.mjs +2 -2
- package/src/runtime/agent/orchestrator/tools/builtin/shell-job-spawn.mjs +519 -0
- package/src/runtime/agent/orchestrator/tools/builtin/shell-jobs.mjs +5 -449
- package/src/runtime/agent/orchestrator/tools/builtin/snapshot-helpers.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/builtin/task-tool.mjs +212 -0
- package/src/runtime/agent/orchestrator/tools/builtin.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/code-graph/build.mjs +1 -7
- package/src/runtime/agent/orchestrator/tools/code-graph/disk-cache.mjs +9 -36
- package/src/runtime/agent/orchestrator/tools/code-graph/dispatch.mjs +15 -3
- package/src/runtime/agent/orchestrator/tools/code-graph/search-references.mjs +429 -0
- package/src/runtime/agent/orchestrator/tools/code-graph/search.mjs +2 -395
- package/src/runtime/agent/orchestrator/tools/code-graph/symbol-index.mjs +2 -2
- package/src/runtime/agent/orchestrator/tools/code-graph/text-mask.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/code-graph/trusted-roots.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/code-graph-prewarm-worker.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/code-graph-state.mjs +3 -3
- package/src/runtime/agent/orchestrator/tools/mutation-planner.mjs +5 -5
- package/src/runtime/agent/orchestrator/tools/next-call-utils.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/patch/dispatch.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/patch/matcher.mjs +7 -7
- package/src/runtime/agent/orchestrator/tools/patch/orchestrator.mjs +72 -9
- package/src/runtime/agent/orchestrator/tools/patch/parsing.mjs +4 -4
- package/src/runtime/agent/orchestrator/tools/patch/paths.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/patch/v4a-convert.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/patch-tool-defs.mjs +4 -4
- package/src/runtime/agent/orchestrator/tools/patch.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/result-compression.mjs +3 -3
- package/src/runtime/agent/orchestrator/tools/shell-command.mjs +2 -444
- package/src/runtime/agent/orchestrator/tools/shell-exec-output.mjs +505 -0
- package/src/runtime/agent/orchestrator/tools/shell-exec-policy.mjs +2 -2
- package/src/runtime/agent/orchestrator/tools/shell-snapshot.mjs +1 -1
- package/src/runtime/channels/lib/backend-dispatch.mjs +20 -5
- package/src/runtime/channels/lib/scheduler.mjs +1 -1
- package/src/runtime/channels/lib/telegram-format.mjs +1 -1
- package/src/runtime/channels/lib/voice-runtime-fetcher.mjs +4 -4
- package/src/runtime/channels/tool-defs.mjs +2 -3
- package/src/runtime/memory/index.mjs +1 -5
- package/src/runtime/memory/lib/core-memory-candidates.mjs +357 -0
- package/src/runtime/memory/lib/core-memory-store.mjs +7 -357
- package/src/runtime/memory/lib/cycle-signatures.mjs +1 -1
- package/src/runtime/memory/lib/embedding-model-config.mjs +1 -1
- package/src/runtime/memory/lib/embedding-provider.mjs +1 -5
- package/src/runtime/memory/lib/embedding-worker.mjs +1 -5
- package/src/runtime/memory/lib/ko-morph.mjs +2 -2
- package/src/runtime/memory/lib/memory-config-flags.mjs +2 -5
- package/src/runtime/memory/lib/memory-cycle-requests.mjs +3 -7
- package/src/runtime/memory/lib/memory-cycle1.mjs +4 -8
- package/src/runtime/memory/lib/memory-cycle2-gate.mjs +1 -1
- package/src/runtime/memory/lib/memory-cycle2-mutations.mjs +1 -1
- package/src/runtime/memory/lib/memory-cycle2-shared.mjs +2 -5
- package/src/runtime/memory/lib/memory-cycle3.mjs +1 -5
- package/src/runtime/memory/lib/memory-embed.mjs +2 -6
- package/src/runtime/memory/lib/memory-log.mjs +8 -0
- package/src/runtime/memory/lib/memory-ops-policy.mjs +4 -8
- package/src/runtime/memory/lib/memory-recall-scope-filter.mjs +1 -1
- package/src/runtime/memory/lib/memory-recall-store.mjs +2 -193
- package/src/runtime/memory/lib/memory-score.mjs +1 -1
- package/src/runtime/memory/lib/memory-text-utils.mjs +2 -2
- package/src/runtime/memory/lib/memory.mjs +2 -6
- package/src/runtime/memory/lib/pg/adapter.mjs +2 -6
- package/src/runtime/memory/lib/pg/process.mjs +1 -5
- package/src/runtime/memory/lib/pg/supervisor.mjs +1 -5
- package/src/runtime/memory/lib/recall-format.mjs +2 -2
- package/src/runtime/memory/lib/recall-scoring.mjs +195 -0
- package/src/runtime/memory/lib/runtime-fetcher.mjs +1 -5
- package/src/runtime/memory/lib/trace-store.mjs +2 -6
- package/src/runtime/search/lib/http-fetch.mjs +6 -6
- package/src/runtime/search/lib/web-tools.mjs +2 -2
- package/src/runtime/shared/buffered-appender.mjs +1 -1
- package/src/runtime/shared/child-guardian.mjs +1 -1
- package/src/runtime/shared/child-spawn-gate.mjs +1 -1
- package/src/runtime/shared/config.mjs +4 -4
- package/src/runtime/shared/launcher-control.mjs +9 -10
- package/src/runtime/shared/llm/index.mjs +5 -20
- package/src/runtime/shared/markdown-frontmatter.mjs +1 -1
- package/src/runtime/shared/memory-snapshot.mjs +4 -4
- package/src/runtime/shared/pristine-execution.mjs +1 -1
- package/src/runtime/shared/process-lifecycle.mjs +0 -1
- package/src/runtime/shared/process-shutdown.mjs +1 -1
- package/src/runtime/shared/resource-admission.mjs +2 -2
- package/src/runtime/shared/schedule-session-run.mjs +1 -1
- package/src/runtime/shared/schedules-db.mjs +1 -1
- package/src/runtime/shared/service-discovery.mjs +2 -2
- package/src/runtime/shared/staged-update.mjs +6 -6
- package/src/runtime/shared/tool-execution-contract.mjs +1 -1
- package/src/runtime/shared/tool-primitives.mjs +1 -1
- package/src/runtime/shared/tool-surface.mjs +2 -2
- package/src/runtime/shared/update-checker.mjs +1 -1
- package/src/runtime/shared/user-cwd.mjs +3 -3
- package/src/runtime/shared/user-data-guard.mjs +4 -4
- package/src/runtime/shared/workspace-router.mjs +5 -5
- package/src/session-runtime/config-helpers.mjs +2 -3
- package/src/session-runtime/config-lifecycle.mjs +1 -1
- package/src/session-runtime/hitch-profile.mjs +1 -1
- package/src/session-runtime/lifecycle-api.mjs +6 -4
- package/src/session-runtime/model-recency.mjs +5 -5
- package/src/session-runtime/plugin-mcp.mjs +1 -1
- package/src/session-runtime/provider-request-snapshot.mjs +338 -0
- package/src/session-runtime/session-text.mjs +4 -4
- package/src/session-runtime/tool-catalog-schema.mjs +197 -0
- package/src/session-runtime/tool-catalog.mjs +6 -483
- package/src/session-runtime/tool-defs.mjs +1 -1
- package/src/standalone/agent-task-status.mjs +1 -1
- package/src/standalone/agent-tool/helpers.mjs +2 -2
- package/src/standalone/channel-admin.mjs +4 -4
- package/src/standalone/explore-tool.mjs +3 -3
- package/src/standalone/hook-bus/config.mjs +1 -1
- package/src/standalone/hook-bus/constants.mjs +1 -1
- package/src/standalone/hook-bus/rules.mjs +1 -1
- package/src/standalone/projects.mjs +1 -1
- package/src/standalone/provider-admin.mjs +2 -2
- package/src/tui/app/app-format.mjs +2 -2
- package/src/tui/app/clipboard.mjs +3 -3
- package/src/tui/app/input-parsers.mjs +1 -1
- package/src/tui/app/text-layout.mjs +1 -1
- package/src/tui/app/transcript-row-estimate.mjs +360 -0
- package/src/tui/app/transcript-window.mjs +5 -347
- package/src/tui/app/use-mouse-input.mjs +1 -1
- package/src/tui/app/use-prompt-handlers.mjs +1 -1
- package/src/tui/components/tool-execution/surface-detail.mjs +9 -9
- package/src/tui/components/tool-execution/text-format.mjs +2 -2
- package/src/tui/components/tool-output-format.mjs +7 -7
- package/src/tui/display-width.mjs +4 -4
- package/src/tui/dist/index.mjs +63 -97
- package/src/tui/engine/agent-envelope.mjs +5 -5
- package/src/tui/engine/notification-plan.mjs +1 -1
- package/src/tui/engine/queue-helpers.mjs +3 -3
- package/src/tui/engine/render-timing.mjs +4 -5
- package/src/tui/engine/session-api-ext.mjs +3 -3
- package/src/tui/engine/tool-result-status.mjs +5 -5
- package/src/tui/engine/tool-result-text.mjs +1 -1
- package/src/tui/engine/transcript-spill.mjs +585 -0
- package/src/tui/engine/tui-steering-persist.mjs +1 -1
- package/src/tui/engine.mjs +2 -474
- package/src/tui/lib/voice-setup.mjs +1 -1
- package/src/tui/markdown/format-token.mjs +1 -1
- package/src/tui/markdown/render-ansi.mjs +1 -1
- package/src/tui/markdown/table-layout.mjs +4 -4
- package/src/tui/paste-attachments.mjs +1 -1
- package/src/tui/prompt-history-store.mjs +3 -3
- package/src/tui/statusline-ansi-bridge.mjs +2 -2
- package/src/tui/theme.mjs +1 -1
- package/src/tui/transcript-tool-failures.mjs +2 -2
- package/src/ui/ansi.mjs +0 -9
- package/src/ui/statusline-format.mjs +2 -4
- package/scripts/_bench-cwc.json +0 -20
- package/scripts/_jitter-fuzz.jsx +0 -42
- package/scripts/_jitter-fuzz2.jsx +0 -30
- package/scripts/_jitter-probe.jsx +0 -35
- package/scripts/_jp2.jsx +0 -16
- package/scripts/_smoke_wd.mjs +0 -7
- package/scripts/abort-recovery-test.mjs +0 -175
- package/scripts/agent-dispatch-abort-compose-test.mjs +0 -31
- package/scripts/agent-live-arg-guard-smoke.mjs +0 -20
- package/scripts/agent-live-path-suffix-smoke.mjs +0 -34
- package/scripts/agent-live-toolcall-args-smoke.mjs +0 -45
- package/scripts/agent-loop-policy-test.mjs +0 -37
- package/scripts/agent-model-liveness-test.mjs +0 -763
- package/scripts/agent-parallel-smoke.mjs +0 -435
- package/scripts/agent-route-batch-test.mjs +0 -40
- package/scripts/agent-tag-reuse-smoke.mjs +0 -441
- package/scripts/agent-terminal-reap-test.mjs +0 -252
- package/scripts/agent-trace-io-test.mjs +0 -133
- package/scripts/ansi-color-capability-test.mjs +0 -90
- package/scripts/anthropic-admission-retry-integration-test.mjs +0 -119
- package/scripts/anthropic-maxtokens-test.mjs +0 -119
- package/scripts/anthropic-oauth-refresh-race-test.mjs +0 -397
- package/scripts/anthropic-transport-policy-test.mjs +0 -726
- package/scripts/apply-patch-edit-smoke.mjs +0 -71
- package/scripts/arg-guard-test.mjs +0 -93
- package/scripts/async-notify-settlement-test.mjs +0 -99
- package/scripts/atomic-lock-tryonce-test.mjs +0 -125
- package/scripts/background-task-meta-smoke.mjs +0 -38
- package/scripts/bench-run.mjs +0 -508
- package/scripts/boot-smoke.mjs +0 -137
- package/scripts/build-runtime-windows.ps1 +0 -242
- package/scripts/channel-daemon-smoke.mjs +0 -1103
- package/scripts/code-graph-aggregate-cwd-test.mjs +0 -158
- package/scripts/code-graph-disk-hit-test.mjs +0 -290
- package/scripts/code-graph-dispatch-test.mjs +0 -96
- package/scripts/code-graph-root-federation-test.mjs +0 -273
- package/scripts/compact-active-turn-test.mjs +0 -68
- package/scripts/compact-file-reattach-test.mjs +0 -88
- package/scripts/compact-pressure-test.mjs +0 -788
- package/scripts/compact-prior-context-flatten-test.mjs +0 -252
- package/scripts/compact-recall-digest-test.mjs +0 -57
- package/scripts/compact-smoke.mjs +0 -1017
- package/scripts/compact-trigger-migration-smoke.mjs +0 -261
- package/scripts/compacted-placeholder-scrub-test.mjs +0 -63
- package/scripts/context-mcp-metering-test.mjs +0 -1406
- package/scripts/debounced-skills-async-save-test.mjs +0 -57
- package/scripts/deferred-tool-loading-test.mjs +0 -250
- package/scripts/desktop-session-bridge-test.mjs +0 -1013
- package/scripts/dispatch-persist-recovery-test.mjs +0 -141
- package/scripts/embedding-worker-exit-test.mjs +0 -76
- package/scripts/execution-completion-dedup-test.mjs +0 -205
- package/scripts/execution-pending-resume-kick-test.mjs +0 -151
- package/scripts/execution-resume-esc-integration-test.mjs +0 -176
- package/scripts/explore-bench-tmp.mjs +0 -36
- package/scripts/explore-bench.mjs +0 -248
- package/scripts/explore-prompt-policy-test.mjs +0 -256
- package/scripts/explore-timeout-cancel-test.mjs +0 -345
- package/scripts/find-fuzzy-hidden-test.mjs +0 -267
- package/scripts/forwarder-rebind-tail-test.mjs +0 -67
- package/scripts/freevar-smoke.mjs +0 -98
- package/scripts/gemini-provider-test.mjs +0 -1448
- package/scripts/generate-oc-icons.mjs +0 -11
- package/scripts/grok-oauth-refresh-race-test.mjs +0 -273
- package/scripts/headless-pristine-execution-test.mjs +0 -614
- package/scripts/hook-bus-test.mjs +0 -552
- package/scripts/ingest-pure-conversation-smoke.mjs +0 -175
- package/scripts/internal-comms-bench-test.mjs +0 -226
- package/scripts/internal-comms-bench.mjs +0 -853
- package/scripts/internal-comms-smoke.mjs +0 -277
- package/scripts/internal-tools-normalization-test.mjs +0 -62
- package/scripts/interrupted-turn-history-test.mjs +0 -399
- package/scripts/lead-workflow-smoke.mjs +0 -592
- package/scripts/lifecycle-api-test.mjs +0 -137
- package/scripts/live-share-test.mjs +0 -148
- package/scripts/live-worker-smoke.mjs +0 -333
- package/scripts/log-writer-guard-smoke.mjs +0 -131
- package/scripts/maintenance-default-routes-test.mjs +0 -164
- package/scripts/max-output-recovery-persist-test.mjs +0 -81
- package/scripts/max-output-recovery-test.mjs +0 -368
- package/scripts/mcp-client-normalization-test.mjs +0 -45
- package/scripts/mcp-grace-deferred-test.mjs +0 -225
- package/scripts/memory-core-input-test.mjs +0 -167
- package/scripts/memory-cycle-routing-test.mjs +0 -111
- package/scripts/memory-meta-concurrency-test.mjs +0 -20
- package/scripts/memory-pg-recovery-test.mjs +0 -59
- package/scripts/memory-rule-contract-test.mjs +0 -93
- package/scripts/model-list-sanitize-test.mjs +0 -37
- package/scripts/mouse-tracking-restore-smoke.mjs +0 -107
- package/scripts/native-edit-wire-test.mjs +0 -152
- package/scripts/notify-completion-mirror-test.mjs +0 -73
- package/scripts/openai-oauth-refresh-race-test.mjs +0 -120
- package/scripts/openai-oauth-ws-1006-retry-test.mjs +0 -954
- package/scripts/openai-ws-early-settle-test.mjs +0 -216
- package/scripts/output-style-bench.mjs +0 -292
- package/scripts/output-style-smoke.mjs +0 -145
- package/scripts/parent-abort-link-test.mjs +0 -90
- package/scripts/patch-binary-cache-test.mjs +0 -181
- package/scripts/path-suffix-test.mjs +0 -57
- package/scripts/pending-completion-drop-test.mjs +0 -239
- package/scripts/pending-messages-lock-nonblocking-test.mjs +0 -62
- package/scripts/pretool-ask-runtime-test.mjs +0 -54
- package/scripts/process-lifecycle-test.mjs +0 -461
- package/scripts/prompt-immediate-render-test.mjs +0 -89
- package/scripts/prompt-input-parity-test.mjs +0 -145
- package/scripts/provider-admission-scheduler-test.mjs +0 -681
- package/scripts/provider-contract-test.mjs +0 -632
- package/scripts/provider-stream-stall-test.mjs +0 -276
- package/scripts/provider-toolcall-test.mjs +0 -3063
- package/scripts/reactive-compact-persist-smoke.mjs +0 -203
- package/scripts/recall-bench.mjs +0 -359
- package/scripts/resource-admission-test.mjs +0 -792
- package/scripts/result-classification-test.mjs +0 -75
- package/scripts/rg-runner-test.mjs +0 -240
- package/scripts/routing-corpus-test.mjs +0 -349
- package/scripts/sanitize-tool-pairs-test.mjs +0 -260
- package/scripts/session-bench-cache-break-test.mjs +0 -102
- package/scripts/session-bench.mjs +0 -1708
- package/scripts/session-context-bench.mjs +0 -344
- package/scripts/session-heartbeat-lifecycle-test.mjs +0 -68
- package/scripts/session-ingest-compaction-smoke.mjs +0 -279
- package/scripts/session-ingest-smoke.mjs +0 -177
- package/scripts/session-orphan-sweep-test.mjs +0 -109
- package/scripts/set-effort-config-test.mjs +0 -41
- package/scripts/shell-failure-diagnostics-test.mjs +0 -280
- package/scripts/shell-hardening-test.mjs +0 -209
- package/scripts/shell-jobs-windows-hide-test.mjs +0 -164
- package/scripts/ship-mode-test.mjs +0 -98
- package/scripts/smoke-loop-failure-summary-test.mjs +0 -38
- package/scripts/smoke-loop-failure-summary.mjs +0 -16
- package/scripts/smoke-loop-report.mjs +0 -221
- package/scripts/smoke-loop.mjs +0 -202
- package/scripts/smoke-runtime-negative.ps1 +0 -106
- package/scripts/statusline-quota-hysteresis-test.mjs +0 -62
- package/scripts/steering-drain-buckets-test.mjs +0 -467
- package/scripts/steering-fold-provenance-test.mjs +0 -71
- package/scripts/streaming-tail-window-test.mjs +0 -175
- package/scripts/submit-commandbusy-race-test.mjs +0 -257
- package/scripts/task-bench.mjs +0 -205
- package/scripts/terminal-bench-isolation-guards-test.mjs +0 -102
- package/scripts/termio-input-smoke.mjs +0 -199
- package/scripts/tool-result-hook-test.mjs +0 -48
- package/scripts/tool-smoke.mjs +0 -2453
- package/scripts/tool-tui-presentation-test.mjs +0 -286
- package/scripts/toolcall-args-test.mjs +0 -239
- package/scripts/tui-ambiguous-width-test.mjs +0 -113
- package/scripts/tui-background-failure-smoke.mjs +0 -73
- package/scripts/tui-perf-run.ps1 +0 -26
- package/scripts/tui-render-smoke.mjs +0 -90
- package/scripts/tui-runtime-load-bench-entry.jsx +0 -608
- package/scripts/tui-runtime-load-bench.mjs +0 -50
- package/scripts/tui-store-frame-batch-test.mjs +0 -99
- package/scripts/tui-transcript-jitter-harness-entry.jsx +0 -383
- package/scripts/tui-transcript-perf-test.mjs +0 -934
- package/scripts/usage-metrics-epoch-smoke.mjs +0 -114
- package/scripts/verify-release-assets-test.mjs +0 -281
- package/scripts/web-fetch-routing-test.mjs +0 -158
- package/scripts/webhook-smoke.mjs +0 -201
- package/scripts/windows-hide-spawn-options-test.mjs +0 -19
- package/scripts/worker-notify-rejection-test.mjs +0 -51
- package/scripts/write-backpressure-test.mjs +0 -147
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { mkdtempSync } from 'node:fs';
|
|
3
|
-
import { join } from 'node:path';
|
|
4
|
-
import { tmpdir } from 'node:os';
|
|
5
|
-
import { estimateMessagesTokens } from '../src/runtime/agent/orchestrator/session/context-utils.mjs';
|
|
6
|
-
import { SUMMARY_PREFIX } from '../src/runtime/agent/orchestrator/session/compact.mjs';
|
|
7
|
-
|
|
8
|
-
process.env.MIXDOG_AGENT_TRACE_DISABLE = '1';
|
|
9
|
-
process.env.MIXDOG_DATA_DIR = mkdtempSync(join(tmpdir(), 'mixdog-reactive-compact-persist-'));
|
|
10
|
-
|
|
11
|
-
function assert(condition, message) {
|
|
12
|
-
if (!condition) throw new Error(message);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const { initProviders, getProvider } = await import('../src/runtime/agent/orchestrator/providers/registry.mjs');
|
|
16
|
-
const { saveSessionAsync, loadSession } = await import('../src/runtime/agent/orchestrator/session/store.mjs');
|
|
17
|
-
|
|
18
|
-
await initProviders({ 'openai-oauth': { enabled: true } });
|
|
19
|
-
const provider = getProvider('openai-oauth');
|
|
20
|
-
if (!provider || typeof provider.send !== 'function') {
|
|
21
|
-
process.stdout.write('reactive-compact-persist smoke skipped (openai-oauth unavailable)\n');
|
|
22
|
-
process.exit(0);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
let mainSendCount = 0;
|
|
26
|
-
let compactSendCount = 0;
|
|
27
|
-
provider.send = async (_sentMessages, _model, _tools, opts = {}) => {
|
|
28
|
-
if (String(opts?.sessionId || '').endsWith(':compact')) {
|
|
29
|
-
compactSendCount += 1;
|
|
30
|
-
return {
|
|
31
|
-
content: [
|
|
32
|
-
'## Goal',
|
|
33
|
-
'- continue reactive persist smoke',
|
|
34
|
-
'',
|
|
35
|
-
'## Constraints & Preferences',
|
|
36
|
-
'- (none)',
|
|
37
|
-
'',
|
|
38
|
-
'## Progress',
|
|
39
|
-
'### Done',
|
|
40
|
-
'- older turn summarized',
|
|
41
|
-
'',
|
|
42
|
-
'### In Progress',
|
|
43
|
-
'- (none)',
|
|
44
|
-
'',
|
|
45
|
-
'### Blocked',
|
|
46
|
-
'- (none)',
|
|
47
|
-
'',
|
|
48
|
-
'## Key Decisions',
|
|
49
|
-
'- (none)',
|
|
50
|
-
'',
|
|
51
|
-
'## Next Steps',
|
|
52
|
-
'- continue',
|
|
53
|
-
'',
|
|
54
|
-
'## Critical Context',
|
|
55
|
-
'- manager.mjs',
|
|
56
|
-
'',
|
|
57
|
-
'## Relevant Files',
|
|
58
|
-
'- src/runtime/agent/orchestrator/session/manager.mjs: askSession overflow persist',
|
|
59
|
-
].join('\n'),
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
mainSendCount += 1;
|
|
63
|
-
throw new Error('input tokens exceeds the context window');
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const messages = [{ role: 'system', content: 'system rules stay mandatory' }];
|
|
67
|
-
let overflowIndex = 0;
|
|
68
|
-
while (estimateMessagesTokens(messages) + 512 < 8_800) {
|
|
69
|
-
messages.push({ role: 'user', content: `older overflow request ${overflowIndex}: ${'important detail '.repeat(90)}` });
|
|
70
|
-
messages.push({ role: 'assistant', content: `older overflow answer ${overflowIndex}: ${'implementation note '.repeat(90)}` });
|
|
71
|
-
overflowIndex += 1;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const sessionId = `sess_reactive_compact_persist_${process.pid}_${Date.now()}`;
|
|
75
|
-
const session = {
|
|
76
|
-
id: sessionId,
|
|
77
|
-
provider: 'openai-oauth',
|
|
78
|
-
model: 'reactive-compact-persist-smoke',
|
|
79
|
-
messages,
|
|
80
|
-
tools: [],
|
|
81
|
-
generation: 0,
|
|
82
|
-
closed: false,
|
|
83
|
-
contextWindow: 12_000,
|
|
84
|
-
rawContextWindow: 12_000,
|
|
85
|
-
compactBoundaryTokens: 12_000,
|
|
86
|
-
// Keep this fixture on the reactive-overflow path; main/user now compacts at
|
|
87
|
-
// 75% by default, while this explicit sub-boundary limit remains authoritative.
|
|
88
|
-
autoCompactTokenLimit: 11_500,
|
|
89
|
-
compaction: { auto: true, semantic: true, type: 1, compactType: 1, lastStage: 'compacting' },
|
|
90
|
-
cwd: process.cwd(),
|
|
91
|
-
sessionStartMetaInjected: true,
|
|
92
|
-
providerState: { xaiResponses: { previousResponseId: 'stale-after-compact' } },
|
|
93
|
-
};
|
|
94
|
-
await saveSessionAsync(session, { expectedGeneration: 0 });
|
|
95
|
-
const beforeCount = messages.length;
|
|
96
|
-
|
|
97
|
-
const { askSession } = await import('../src/runtime/agent/orchestrator/session/manager.mjs');
|
|
98
|
-
|
|
99
|
-
let threw = false;
|
|
100
|
-
let thrownCode = null;
|
|
101
|
-
try {
|
|
102
|
-
await askSession(sessionId, 'current overflow task must stay verbatim', null, null, process.cwd());
|
|
103
|
-
} catch (err) {
|
|
104
|
-
threw = true;
|
|
105
|
-
thrownCode = err?.code || null;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// Non-agent sessions hard-lock to recall-fasttrack (7/3 commit). This smoke has
|
|
109
|
-
// no memory subsystem registered, so ingest_session + search both fail — the
|
|
110
|
-
// exact "memory pipeline broken" condition the fail-safe must cover. Assert the
|
|
111
|
-
// fail-safe: recall-fasttrack aborts rather than dropping head behind a false
|
|
112
|
-
// "Full history is in memory" notice, so no context is silently lost and the
|
|
113
|
-
// compaction failure is surfaced instead of being masked by an empty summary shell.
|
|
114
|
-
assert(threw, 'askSession should surface compaction failure');
|
|
115
|
-
assert(thrownCode === 'AGENT_COMPACT_FAILED', `expected AGENT_COMPACT_FAILED, got ${thrownCode}`);
|
|
116
|
-
// Recall-fasttrack aborted (memory failed), so the reactive retry never produced
|
|
117
|
-
// a smaller transcript to re-send: exactly one failing main send, no LLM compact.
|
|
118
|
-
assert(mainSendCount === 1, `expected 1 main send (reactive retry aborted by fail-safe), got ${mainSendCount}`);
|
|
119
|
-
assert(compactSendCount === 0, `expected 0 compact sends on recall-fasttrack path, got ${compactSendCount}`);
|
|
120
|
-
|
|
121
|
-
const reloaded = loadSession(sessionId);
|
|
122
|
-
assert(reloaded, 'session should reload from store after overflow');
|
|
123
|
-
// Fail-safe keeps full history for the cycle: current turn appended, nothing dropped.
|
|
124
|
-
assert(
|
|
125
|
-
(reloaded.messages || []).length === beforeCount + 1,
|
|
126
|
-
`full history should be preserved on fail-safe abort (expected ${beforeCount + 1}, got ${(reloaded.messages || []).length})`,
|
|
127
|
-
);
|
|
128
|
-
const summary = (reloaded.messages || []).find(
|
|
129
|
-
(m) => m?.role === 'user' && typeof m.content === 'string' && m.content.startsWith(SUMMARY_PREFIX),
|
|
130
|
-
);
|
|
131
|
-
assert(!summary, 'no empty summary shell should be injected when the memory pipeline fails');
|
|
132
|
-
assert(
|
|
133
|
-
!(reloaded.messages || []).some((m) => typeof m?.content === 'string' && m.content.includes('Full history is in memory')),
|
|
134
|
-
'no false "Full history is in memory" recall notice should be injected on fail-safe abort',
|
|
135
|
-
);
|
|
136
|
-
assert(
|
|
137
|
-
(reloaded.messages || []).some((m) => m?.role === 'user' && String(m.content).includes('current overflow task must stay verbatim')),
|
|
138
|
-
'current user turn should remain in persisted transcript',
|
|
139
|
-
);
|
|
140
|
-
assert(reloaded.compaction?.lastStage === 'overflow_failed', `compaction lastStage should be overflow_failed, got ${reloaded.compaction?.lastStage}`);
|
|
141
|
-
assert(reloaded.providerState?.xaiResponses?.previousResponseId === 'stale-after-compact',
|
|
142
|
-
'providerState should remain when a failed reactive compact leaves the transcript unchanged');
|
|
143
|
-
|
|
144
|
-
// Successful pre-send compaction must persist an explicit providerState clear.
|
|
145
|
-
// The following ask then proves the stale continuation is absent from the
|
|
146
|
-
// provider options, not merely absent from the first loop's local variable.
|
|
147
|
-
let successfulCompactSends = 0;
|
|
148
|
-
const nextAskStates = [];
|
|
149
|
-
provider.send = async (_sentMessages, _model, _tools, opts = {}) => {
|
|
150
|
-
if (String(opts?.sessionId || '').endsWith(':compact')) {
|
|
151
|
-
successfulCompactSends += 1;
|
|
152
|
-
return {
|
|
153
|
-
content: [
|
|
154
|
-
'## Goal',
|
|
155
|
-
'- verify provider state clear',
|
|
156
|
-
'',
|
|
157
|
-
'## Progress',
|
|
158
|
-
'### Done',
|
|
159
|
-
'- old history compacted',
|
|
160
|
-
'',
|
|
161
|
-
'## Next Steps',
|
|
162
|
-
'- continue',
|
|
163
|
-
].join('\n'),
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
nextAskStates.push(opts.providerState);
|
|
167
|
-
return { content: 'successful answer', stopReason: 'end_turn' };
|
|
168
|
-
};
|
|
169
|
-
const clearSessionId = `sess_provider_state_clear_${process.pid}_${Date.now()}`;
|
|
170
|
-
const clearMessages = [{ role: 'system', content: 'rules' }];
|
|
171
|
-
for (let i = 0; i < 10; i += 1) {
|
|
172
|
-
clearMessages.push({ role: 'user', content: `old ${i} ${'x '.repeat(500)}` });
|
|
173
|
-
clearMessages.push({ role: 'assistant', content: `answer ${i} ${'y '.repeat(500)}` });
|
|
174
|
-
}
|
|
175
|
-
await saveSessionAsync({
|
|
176
|
-
id: clearSessionId,
|
|
177
|
-
provider: 'openai-oauth',
|
|
178
|
-
model: 'provider-state-clear-smoke',
|
|
179
|
-
owner: 'agent',
|
|
180
|
-
agent: 'heavy-worker',
|
|
181
|
-
messages: clearMessages,
|
|
182
|
-
tools: [],
|
|
183
|
-
generation: 0,
|
|
184
|
-
closed: false,
|
|
185
|
-
contextWindow: 12_000,
|
|
186
|
-
rawContextWindow: 12_000,
|
|
187
|
-
compactBoundaryTokens: 12_000,
|
|
188
|
-
autoCompactTokenLimit: 4_000,
|
|
189
|
-
compaction: { auto: true, semantic: true, recallFastTrack: false, type: 1, compactType: 1 },
|
|
190
|
-
cwd: process.cwd(),
|
|
191
|
-
sessionStartMetaInjected: true,
|
|
192
|
-
providerState: { xaiResponses: { previousResponseId: 'must-clear' } },
|
|
193
|
-
}, { expectedGeneration: 0 });
|
|
194
|
-
await askSession(clearSessionId, 'first ask', null, null, process.cwd());
|
|
195
|
-
const afterClear = loadSession(clearSessionId);
|
|
196
|
-
assert(!Object.hasOwn(afterClear, 'providerState'), 'successful compact must remove providerState from persisted session');
|
|
197
|
-
await askSession(clearSessionId, 'second ask', null, null, process.cwd());
|
|
198
|
-
assert(successfulCompactSends >= 1, 'fixture must perform successful semantic compaction');
|
|
199
|
-
assert(nextAskStates.length >= 2, 'both asks must reach provider');
|
|
200
|
-
assert(nextAskStates[0] === undefined, 'post-compact send must receive cleared providerState');
|
|
201
|
-
assert(nextAskStates[1] === undefined, 'next ask must not resurrect stale providerState');
|
|
202
|
-
|
|
203
|
-
process.stdout.write('reactive-compact-persist smoke passed ✓\n');
|
package/scripts/recall-bench.mjs
DELETED
|
@@ -1,359 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// recall-bench.mjs — case-based recall quality bench against the LIVE memory
|
|
3
|
-
// DB. READ-ONLY: every case goes through handleToolCall('search_memories')
|
|
4
|
-
// which only performs SELECTs (handleSearch path). No mutation actions
|
|
5
|
-
// ('memory' tool / cycle1 / cycle2 / prune / purge / etc.) are ever invoked
|
|
6
|
-
// here — do not add any.
|
|
7
|
-
//
|
|
8
|
-
// node scripts/recall-bench.mjs [--cases scripts/recall-bench-cases.json] [--json]
|
|
9
|
-
//
|
|
10
|
-
// Loads src/runtime/memory/index.mjs in-process (same module the daemon
|
|
11
|
-
// uses), calls init() once, runs each bench case through handleToolCall,
|
|
12
|
-
// prints params/result-count/top-3/latency/PASS-WARN per case, then a
|
|
13
|
-
// summary table, then calls stop().
|
|
14
|
-
import { existsSync, readFileSync } from 'node:fs';
|
|
15
|
-
import { resolve, dirname } from 'node:path';
|
|
16
|
-
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
17
|
-
|
|
18
|
-
const __dir = dirname(fileURLToPath(import.meta.url));
|
|
19
|
-
const ROOT = resolve(__dir, '..');
|
|
20
|
-
const DEFAULT_CASES_PATH = resolve(__dir, 'recall-bench-cases.json');
|
|
21
|
-
|
|
22
|
-
function argValue(name, fallback = null) {
|
|
23
|
-
const idx = process.argv.indexOf(`--${name}`);
|
|
24
|
-
if (idx >= 0 && idx + 1 < process.argv.length) return process.argv[idx + 1];
|
|
25
|
-
const pref = `--${name}=`;
|
|
26
|
-
const hit = process.argv.find((a) => a.startsWith(pref));
|
|
27
|
-
return hit ? hit.slice(pref.length) : fallback;
|
|
28
|
-
}
|
|
29
|
-
function hasFlag(name) { return process.argv.includes(`--${name}`); }
|
|
30
|
-
|
|
31
|
-
const WARN_LATENCY_MS = 3000;
|
|
32
|
-
|
|
33
|
-
const DEFAULT_CASES = [
|
|
34
|
-
{ id: 'kw-ko', label: 'keyword query (ko)', args: { query: '\uBA54\uBAA8\uB9AC \uC7AC\uD604' }, expect: 'results' },
|
|
35
|
-
{ id: 'kw-en', label: 'keyword query (en)', args: { query: 'memory recall pipeline' }, expect: 'results' },
|
|
36
|
-
{ id: 'short-1tok', label: 'short 1-token query', args: { query: 'recall' }, expect: 'results' },
|
|
37
|
-
{ id: 'short-2tok', label: 'short 2-token query', args: { query: 'cycle1 drain' }, expect: 'results' },
|
|
38
|
-
{ id: 'browse-last', label: 'query-less recent browse (period=last)', args: { period: 'last', limit: 10 }, expect: 'browse' },
|
|
39
|
-
{ id: 'period-24h', label: 'period window 24h', args: { period: '24h', limit: 10 }, expect: 'browse' },
|
|
40
|
-
{ id: 'period-7d', label: 'period window 7d', args: { period: '7d', limit: 10 }, expect: 'browse' },
|
|
41
|
-
{ id: 'category-filter', label: 'category filter (decision)', args: { period: '30d', category: 'decision', limit: 10 }, expect: 'browse' },
|
|
42
|
-
{ id: 'id-lookup', label: 'id lookup', args: { id: 1 }, expect: 'idlookup' },
|
|
43
|
-
{ id: 'scope-project', label: 'project-scoped query', args: { query: 'recall', cwd: ROOT, limit: 10 }, expect: 'results' },
|
|
44
|
-
{ id: 'scope-all', label: 'all-scope query', args: { query: 'recall', projectScope: 'all', limit: 10 }, expect: 'results' },
|
|
45
|
-
{ id: 'raw-on', label: 'includeRaw on', args: { query: 'recall', includeRaw: true, limit: 10 }, expect: 'results' },
|
|
46
|
-
{ id: 'raw-off', label: 'includeRaw off', args: { query: 'recall', includeRaw: false, limit: 10 }, expect: 'results' },
|
|
47
|
-
];
|
|
48
|
-
|
|
49
|
-
function loadCases(path) {
|
|
50
|
-
if (path && existsSync(resolve(path))) {
|
|
51
|
-
try {
|
|
52
|
-
const parsed = JSON.parse(readFileSync(resolve(path), 'utf8'));
|
|
53
|
-
if (Array.isArray(parsed) && parsed.length) return parsed;
|
|
54
|
-
} catch (e) {
|
|
55
|
-
process.stderr.write(`[recall-bench] failed to parse cases file ${path}: ${e.message}; using built-in cases\n`);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return DEFAULT_CASES;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function textOfResult(result) {
|
|
62
|
-
if (result && typeof result === 'object' && Array.isArray(result.content)) {
|
|
63
|
-
return result.content.map((p) => (p?.type === 'text' ? p.text || '' : JSON.stringify(p))).join('\n');
|
|
64
|
-
}
|
|
65
|
-
if (result && typeof result === 'object' && typeof result.text === 'string') return result.text;
|
|
66
|
-
if (typeof result === 'string') return result;
|
|
67
|
-
return JSON.stringify(result ?? '');
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function countEntryLines(text) {
|
|
71
|
-
return resultLines(text).length;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function topN(text, n = 3, maxLen = 140) {
|
|
75
|
-
return resultLines(text)
|
|
76
|
-
.slice(0, n)
|
|
77
|
-
.map((line) => (line.length > maxLen ? `${line.slice(0, maxLen - 1)}…` : line));
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// Full ordered list of result lines (no slice), used for topNContains rank
|
|
81
|
-
// scoring. Same filtering rule as countEntryLines/topN.
|
|
82
|
-
function resultLines(text) {
|
|
83
|
-
const t = String(text || '').trim();
|
|
84
|
-
if (!t || t === '(no results)' || t === '(no valid ids)') return [];
|
|
85
|
-
return t.split('\n').filter((line) => {
|
|
86
|
-
const trimmed = line.trim();
|
|
87
|
-
return trimmed
|
|
88
|
-
&& !trimmed.startsWith('[recall truncated')
|
|
89
|
-
&& !trimmed.startsWith('note:')
|
|
90
|
-
&& !/^\[[^\]]+\]$/.test(trimmed);
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// Score expect.topNContains: for each expected substring, find the 1-indexed
|
|
95
|
-
// rank of the first result line containing it (case-insensitive), over the
|
|
96
|
-
// FULL result list (not just the topN cutoff) so we can tell "missed
|
|
97
|
-
// entirely" from "present but ranked below cutoff". hit@N/MRR are then
|
|
98
|
-
// computed against the topN cutoff.
|
|
99
|
-
function scoreTopNContains(lines, substrings, n) {
|
|
100
|
-
const lower = lines.map((l) => l.toLowerCase());
|
|
101
|
-
const perSubstring = substrings.map((needle) => {
|
|
102
|
-
const hay = String(needle || '').toLowerCase();
|
|
103
|
-
let rank = null;
|
|
104
|
-
for (let i = 0; i < lower.length; i++) {
|
|
105
|
-
if (hay && lower[i].includes(hay)) { rank = i + 1; break; }
|
|
106
|
-
}
|
|
107
|
-
const hit = rank !== null && rank <= n;
|
|
108
|
-
return { needle, rank, hit, rr: hit ? 1 / rank : 0 };
|
|
109
|
-
});
|
|
110
|
-
const total = perSubstring.length || 1;
|
|
111
|
-
const hitAtN = perSubstring.reduce((s, p) => s + (p.hit ? 1 : 0), 0) / total;
|
|
112
|
-
const mrr = perSubstring.reduce((s, p) => s + p.rr, 0) / total;
|
|
113
|
-
return { perSubstring, hitAtN, mrr, n };
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// Parse leading "[YYYY-MM-DD HH:MM]" timestamps from result lines and check
|
|
117
|
-
// they are non-increasing (newest-first). Returns null when fewer than 2
|
|
118
|
-
// lines carry a parseable timestamp (nothing to order).
|
|
119
|
-
function scoreRecencyOrdered(lines) {
|
|
120
|
-
const tsRe = /^\s*\[(\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2})/;
|
|
121
|
-
const headerRe = /^\s*##\s/;
|
|
122
|
-
const parse = (raw) => Date.parse(raw.replace(' ', 'T'));
|
|
123
|
-
// Non-increasing check within a single ordered list of {raw,ts}. Returns
|
|
124
|
-
// the first {prev,cur} pair where cur is newer than prev, else null.
|
|
125
|
-
const firstBreak = (stamps) => {
|
|
126
|
-
for (let i = 1; i < stamps.length; i++) {
|
|
127
|
-
if (Number.isFinite(stamps[i].ts) && Number.isFinite(stamps[i - 1].ts) && stamps[i].ts > stamps[i - 1].ts) {
|
|
128
|
-
return { prev: stamps[i - 1].raw, cur: stamps[i].raw };
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
return null;
|
|
132
|
-
};
|
|
133
|
-
const hasSessions = lines.some((l) => headerRe.test(l));
|
|
134
|
-
if (!hasSessions) {
|
|
135
|
-
// Ungrouped: single global non-increasing check over all timestamped lines.
|
|
136
|
-
const stamps = [];
|
|
137
|
-
for (const line of lines) {
|
|
138
|
-
const m = tsRe.exec(line);
|
|
139
|
-
if (m) stamps.push({ raw: m[1], ts: parse(m[1]) });
|
|
140
|
-
}
|
|
141
|
-
if (stamps.length < 2) return { parsed: stamps.length, groups: 0, ordered: true, firstViolation: null };
|
|
142
|
-
const b = firstBreak(stamps);
|
|
143
|
-
return { parsed: stamps.length, groups: 0, ordered: b === null, firstViolation: b };
|
|
144
|
-
}
|
|
145
|
-
// Session-grouped: partition timestamped lines by their "## session" header.
|
|
146
|
-
// Timestamps only compared WITHIN a group; groups themselves must descend by
|
|
147
|
-
// their first line's timestamp.
|
|
148
|
-
const groups = [];
|
|
149
|
-
let cur = null;
|
|
150
|
-
for (const line of lines) {
|
|
151
|
-
if (headerRe.test(line)) { cur = { stamps: [] }; groups.push(cur); continue; }
|
|
152
|
-
const m = tsRe.exec(line);
|
|
153
|
-
if (m && cur) cur.stamps.push({ raw: m[1], ts: parse(m[1]) });
|
|
154
|
-
}
|
|
155
|
-
const nonEmpty = groups.filter((g) => g.stamps.length);
|
|
156
|
-
const parsed = nonEmpty.reduce((s, g) => s + g.stamps.length, 0);
|
|
157
|
-
let firstViolation = null;
|
|
158
|
-
for (const g of nonEmpty) {
|
|
159
|
-
const b = firstBreak(g.stamps);
|
|
160
|
-
if (b) { firstViolation = { ...b, scope: 'within-session' }; break; }
|
|
161
|
-
}
|
|
162
|
-
if (!firstViolation) {
|
|
163
|
-
const heads = nonEmpty.map((g) => g.stamps[0]);
|
|
164
|
-
const b = firstBreak(heads);
|
|
165
|
-
if (b) firstViolation = { ...b, scope: 'across-sessions' };
|
|
166
|
-
}
|
|
167
|
-
return { parsed, groups: nonEmpty.length, ordered: firstViolation === null, firstViolation };
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
// Score expect.allContain: every result line must contain at least one of the
|
|
171
|
-
// given substrings (case-insensitive). Returns offending lines (matching none).
|
|
172
|
-
// Use for negative cases where rows legitimately mention the term.
|
|
173
|
-
function scoreAllContain(lines, substrings) {
|
|
174
|
-
const needles = substrings.map((s) => String(s || '').toLowerCase()).filter(Boolean);
|
|
175
|
-
const offenders = lines.filter((line) => {
|
|
176
|
-
const l = line.toLowerCase();
|
|
177
|
-
return !needles.some((n) => l.includes(n));
|
|
178
|
-
});
|
|
179
|
-
return { needles: substrings, offenders, ok: offenders.length === 0 };
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
function evaluateCase(kase, { count, ms, isError }, quality, recency, allContain) {
|
|
183
|
-
const warnings = [];
|
|
184
|
-
if (isError) warnings.push('error result');
|
|
185
|
-
if (ms > WARN_LATENCY_MS) warnings.push(`latency ${ms}ms > ${WARN_LATENCY_MS}ms`);
|
|
186
|
-
if ((kase.expect === 'browse' || kase.expect === 'idlookup') && count === 0) {
|
|
187
|
-
warnings.push('0 results for a browse/id-lookup case (expected data present)');
|
|
188
|
-
}
|
|
189
|
-
if (kase.expect === 'empty' && count > 0) {
|
|
190
|
-
warnings.push(`expected empty but got ${count} result(s) — possible filler/unrelated match`);
|
|
191
|
-
}
|
|
192
|
-
if (allContain) {
|
|
193
|
-
for (const line of allContain.offenders) {
|
|
194
|
-
warnings.push(`allContain miss: result line contains none of [${allContain.needles.join(', ')}]: "${line}"`);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
if (quality) {
|
|
198
|
-
for (const p of quality.perSubstring) {
|
|
199
|
-
if (!p.hit) {
|
|
200
|
-
warnings.push(p.rank === null
|
|
201
|
-
? `topNContains miss: "${p.needle}" not found in results`
|
|
202
|
-
: `topNContains miss: "${p.needle}" found at rank ${p.rank} > topN ${quality.n}`);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
if (recency && !recency.ordered && recency.firstViolation) {
|
|
207
|
-
const v = recency.firstViolation;
|
|
208
|
-
warnings.push(`recencyOrdered violation (${v.scope || 'global'}): ${v.cur} newer than prior ${v.prev}`);
|
|
209
|
-
}
|
|
210
|
-
const status = warnings.length ? 'WARN' : 'PASS';
|
|
211
|
-
return { status, warnings };
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
async function runCase(memoryModule, kase) {
|
|
215
|
-
const started = Date.now();
|
|
216
|
-
let result;
|
|
217
|
-
let isError = false;
|
|
218
|
-
let errMsg = null;
|
|
219
|
-
try {
|
|
220
|
-
result = await memoryModule.handleToolCall('search_memories', kase.args || {});
|
|
221
|
-
isError = Boolean(result?.isError);
|
|
222
|
-
} catch (e) {
|
|
223
|
-
isError = true;
|
|
224
|
-
errMsg = e?.message || String(e);
|
|
225
|
-
result = { text: `(error: ${errMsg})` };
|
|
226
|
-
}
|
|
227
|
-
const ms = Date.now() - started;
|
|
228
|
-
const text = textOfResult(result);
|
|
229
|
-
const count = countEntryLines(text);
|
|
230
|
-
// expect stays a plain string for legacy cases ('results'/'browse'/'idlookup').
|
|
231
|
-
// New quality cases use an object: { kind?, topNContains: [...], topN? }.
|
|
232
|
-
const expectObj = kase.expect && typeof kase.expect === 'object' ? kase.expect : null;
|
|
233
|
-
const expectKind = expectObj ? expectObj.kind : kase.expect;
|
|
234
|
-
const topNContains = expectObj && Array.isArray(expectObj.topNContains) ? expectObj.topNContains : null;
|
|
235
|
-
const cutoffN = expectObj && Number.isInteger(expectObj.topN) ? expectObj.topN : 5;
|
|
236
|
-
const quality = topNContains ? scoreTopNContains(resultLines(text), topNContains, cutoffN) : null;
|
|
237
|
-
const recency = expectObj && expectObj.recencyOrdered ? scoreRecencyOrdered(resultLines(text)) : null;
|
|
238
|
-
const allContainNeedles = expectObj && Array.isArray(expectObj.allContain) ? expectObj.allContain : null;
|
|
239
|
-
const allContain = allContainNeedles ? scoreAllContain(resultLines(text), allContainNeedles) : null;
|
|
240
|
-
const evalResult = evaluateCase({ ...kase, expect: expectKind }, { count, ms, isError }, quality, recency, allContain);
|
|
241
|
-
return {
|
|
242
|
-
id: kase.id,
|
|
243
|
-
label: kase.label,
|
|
244
|
-
args: kase.args,
|
|
245
|
-
count,
|
|
246
|
-
ms,
|
|
247
|
-
isError,
|
|
248
|
-
errMsg,
|
|
249
|
-
top3: topN(text, 3),
|
|
250
|
-
quality,
|
|
251
|
-
recency,
|
|
252
|
-
allContain,
|
|
253
|
-
status: evalResult.status,
|
|
254
|
-
warnings: evalResult.warnings,
|
|
255
|
-
};
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
function printCase(row) {
|
|
259
|
-
process.stdout.write(`\n[${row.status}] ${row.id} — ${row.label}\n`);
|
|
260
|
-
process.stdout.write(` params: ${JSON.stringify(row.args)}\n`);
|
|
261
|
-
process.stdout.write(` results: ${row.count} latency: ${row.ms}ms${row.isError ? ` ERROR: ${row.errMsg}` : ''}\n`);
|
|
262
|
-
if (row.quality) {
|
|
263
|
-
process.stdout.write(` hit@${row.quality.n}: ${row.quality.hitAtN.toFixed(2)} MRR: ${row.quality.mrr.toFixed(2)}\n`);
|
|
264
|
-
for (const p of row.quality.perSubstring) {
|
|
265
|
-
process.stdout.write(` substr "${p.needle}" -> rank ${p.rank ?? 'none'}${p.hit ? '' : ' (miss)'}\n`);
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
if (row.recency) {
|
|
269
|
-
process.stdout.write(` recency: ${row.recency.ordered ? 'ordered' : 'OUT-OF-ORDER'} (${row.recency.parsed} timestamped lines)\n`);
|
|
270
|
-
}
|
|
271
|
-
if (row.top3.length) {
|
|
272
|
-
for (const line of row.top3) process.stdout.write(` - ${line}\n`);
|
|
273
|
-
} else {
|
|
274
|
-
process.stdout.write(' (no results)\n');
|
|
275
|
-
}
|
|
276
|
-
for (const w of row.warnings) process.stdout.write(` WARN: ${w}\n`);
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
function printSummary(rows) {
|
|
280
|
-
process.stdout.write('\n=== recall-bench summary ===\n');
|
|
281
|
-
const widths = { id: 18, results: 8, ms: 8, status: 6, hit: 9, mrr: 7 };
|
|
282
|
-
process.stdout.write(
|
|
283
|
-
`${'case'.padEnd(widths.id)}${'results'.padEnd(widths.results)}${'ms'.padEnd(widths.ms)}${'status'.padEnd(widths.status)}${'hit@N'.padEnd(widths.hit)}${'MRR'.padEnd(widths.mrr)}notes\n`,
|
|
284
|
-
);
|
|
285
|
-
for (const r of rows) {
|
|
286
|
-
const hitStr = r.quality ? r.quality.hitAtN.toFixed(2) : '-';
|
|
287
|
-
const mrrStr = r.quality ? r.quality.mrr.toFixed(2) : '-';
|
|
288
|
-
process.stdout.write(
|
|
289
|
-
`${String(r.id).padEnd(widths.id)}${String(r.count).padEnd(widths.results)}${String(r.ms).padEnd(widths.ms)}${String(r.status).padEnd(widths.status)}${hitStr.padEnd(widths.hit)}${mrrStr.padEnd(widths.mrr)}${r.warnings.join('; ')}\n`,
|
|
290
|
-
);
|
|
291
|
-
}
|
|
292
|
-
const warnCount = rows.filter((r) => r.status === 'WARN').length;
|
|
293
|
-
const totalMs = rows.reduce((s, r) => s + r.ms, 0);
|
|
294
|
-
const qualityRows = rows.filter((r) => r.quality);
|
|
295
|
-
let aggLine = '';
|
|
296
|
-
if (qualityRows.length) {
|
|
297
|
-
const aggHit = qualityRows.reduce((s, r) => s + r.quality.hitAtN, 0) / qualityRows.length;
|
|
298
|
-
const aggMrr = qualityRows.reduce((s, r) => s + r.quality.mrr, 0) / qualityRows.length;
|
|
299
|
-
aggLine = ` agg_hit@N=${aggHit.toFixed(3)} agg_MRR=${aggMrr.toFixed(3)} (${qualityRows.length} scored cases)`;
|
|
300
|
-
}
|
|
301
|
-
process.stdout.write(`\ncases=${rows.length} pass=${rows.length - warnCount} warn=${warnCount} total_latency=${totalMs}ms${aggLine}\n`);
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
async function main() {
|
|
305
|
-
const casesPath = argValue('cases', DEFAULT_CASES_PATH);
|
|
306
|
-
const jsonMode = hasFlag('json');
|
|
307
|
-
const strict = hasFlag('strict');
|
|
308
|
-
const cases = loadCases(casesPath);
|
|
309
|
-
|
|
310
|
-
let memoryModule;
|
|
311
|
-
try {
|
|
312
|
-
memoryModule = await import(pathToFileURL(resolve(ROOT, 'src/runtime/memory/index.mjs')).href);
|
|
313
|
-
} catch (e) {
|
|
314
|
-
process.stderr.write(`[recall-bench] failed to load memory module: ${e?.stack || e?.message || e}\n`);
|
|
315
|
-
process.exitCode = 1;
|
|
316
|
-
return;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
try {
|
|
320
|
-
await memoryModule.init();
|
|
321
|
-
} catch (e) {
|
|
322
|
-
process.stdout.write(`recall-bench: DB unreachable / init failed — reporting clearly, no fabricated results.\n`);
|
|
323
|
-
process.stdout.write(`error: ${e?.stack || e?.message || e}\n`);
|
|
324
|
-
process.exitCode = 1;
|
|
325
|
-
return;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
const rows = [];
|
|
329
|
-
try {
|
|
330
|
-
for (const kase of cases) {
|
|
331
|
-
const row = await runCase(memoryModule, kase);
|
|
332
|
-
rows.push(row);
|
|
333
|
-
if (!jsonMode) printCase(row);
|
|
334
|
-
}
|
|
335
|
-
} finally {
|
|
336
|
-
try { await memoryModule.stop?.(); } catch {}
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
const allZero = rows.length > 0 && rows.every((r) => r.count === 0 && !r.isError);
|
|
340
|
-
if (allZero) {
|
|
341
|
-
process.stdout.write('\nNOTE: every case returned 0 results — DB is likely empty (or unreachable pool). Treat WARNs below as expected-empty, not a recall bug, until data is present.\n');
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
if (jsonMode) {
|
|
345
|
-
process.stdout.write(JSON.stringify({ cases: rows }, null, 2) + '\n');
|
|
346
|
-
} else {
|
|
347
|
-
printSummary(rows);
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
const hardErrors = rows.filter((r) => r.isError);
|
|
351
|
-
if (hardErrors.length) process.exitCode = 1;
|
|
352
|
-
// --strict: any WARN row fails the run. Default behavior (errors-only) unchanged.
|
|
353
|
-
if (strict && rows.some((r) => r.status === 'WARN')) process.exitCode = 1;
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
main().catch((e) => {
|
|
357
|
-
process.stderr.write(`${e?.stack || e?.message || e}\n`);
|
|
358
|
-
process.exitCode = 1;
|
|
359
|
-
});
|