mixdog 0.9.62 → 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,632 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import test from 'node:test';
|
|
3
|
-
import assert from 'node:assert/strict';
|
|
4
|
-
import { mkdtempSync, readFileSync, rmSync } from 'node:fs';
|
|
5
|
-
import { tmpdir } from 'node:os';
|
|
6
|
-
import { join } from 'node:path';
|
|
7
|
-
import { spawnSync } from 'node:child_process';
|
|
8
|
-
|
|
9
|
-
import {
|
|
10
|
-
OpenAICompatProvider,
|
|
11
|
-
OPENAI_COMPAT_PRESETS,
|
|
12
|
-
applyCompatProviderChatOptions,
|
|
13
|
-
parseToolCalls,
|
|
14
|
-
} from '../src/runtime/agent/orchestrator/providers/openai-compat.mjs';
|
|
15
|
-
import {
|
|
16
|
-
consumeCompatChatCompletionStream,
|
|
17
|
-
consumeCompatResponsesStream,
|
|
18
|
-
} from '../src/runtime/agent/orchestrator/providers/openai-compat-stream.mjs';
|
|
19
|
-
import { useXaiResponsesWebSocket } from '../src/runtime/agent/orchestrator/providers/openai-compat-xai.mjs';
|
|
20
|
-
import { classifyError } from '../src/runtime/agent/orchestrator/providers/retry-classifier.mjs';
|
|
21
|
-
import { GrokOAuthProvider } from '../src/runtime/agent/orchestrator/providers/grok-oauth.mjs';
|
|
22
|
-
import { sendViaWebSocket } from '../src/runtime/agent/orchestrator/providers/openai-oauth-ws.mjs';
|
|
23
|
-
import {
|
|
24
|
-
OpenCodeGoProvider,
|
|
25
|
-
isAnthropicGoModel,
|
|
26
|
-
openCodeGoEndpointForModel,
|
|
27
|
-
resolveOpenCodeGoBaseURLs,
|
|
28
|
-
} from '../src/runtime/agent/orchestrator/providers/opencode-go.mjs';
|
|
29
|
-
import { uncachedInputTokensForProvider } from '../src/runtime/agent/orchestrator/session/manager/usage-metrics.mjs';
|
|
30
|
-
import { resolveTraceUsageInput } from '../src/runtime/agent/orchestrator/agent-trace.mjs';
|
|
31
|
-
import {
|
|
32
|
-
billableInputTokensForProvider,
|
|
33
|
-
isInclusiveProvider,
|
|
34
|
-
} from '../src/runtime/shared/llm/cost.mjs';
|
|
35
|
-
import { createProviderAuthApi } from '../src/session-runtime/provider-auth-api.mjs';
|
|
36
|
-
import { createProviderUsage } from '../src/session-runtime/provider-usage.mjs';
|
|
37
|
-
|
|
38
|
-
function stream(events) {
|
|
39
|
-
return {
|
|
40
|
-
async *[Symbol.asyncIterator]() {
|
|
41
|
-
for (const event of events) yield event;
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
test('provider setup refresh waits for keychain readiness and bypasses stale setup state', async () => {
|
|
47
|
-
const calls = [];
|
|
48
|
-
const api = createProviderAuthApi({
|
|
49
|
-
awaitKeychainPrewarm: async () => { calls.push('prewarm'); },
|
|
50
|
-
reloadFullConfig: () => { calls.push('reload'); },
|
|
51
|
-
cachedProviderSetup: async (options) => {
|
|
52
|
-
calls.push(['setup', options]);
|
|
53
|
-
return { generation: 2 };
|
|
54
|
-
},
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
assert.deepEqual(await api.getProviderSetup({ refresh: true }), { generation: 2 });
|
|
58
|
-
assert.deepEqual(calls, ['prewarm', 'reload', ['setup', { force: true }]]);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
test('forced provider setup waits for an in-flight snapshot and then rebuilds it', async () => {
|
|
62
|
-
let releaseFirst;
|
|
63
|
-
let builds = 0;
|
|
64
|
-
const usage = createProviderUsage({
|
|
65
|
-
caches: {
|
|
66
|
-
providerSetupCache: {},
|
|
67
|
-
providerSetupQuickCache: {},
|
|
68
|
-
providerSetupPromise: null,
|
|
69
|
-
},
|
|
70
|
-
displayConfig: () => ({}),
|
|
71
|
-
providerSetup: async () => {
|
|
72
|
-
builds += 1;
|
|
73
|
-
if (builds === 1) await new Promise((resolve) => { releaseFirst = resolve; });
|
|
74
|
-
return { generation: builds };
|
|
75
|
-
},
|
|
76
|
-
getReg: () => new Map(),
|
|
77
|
-
getConfig: () => ({}),
|
|
78
|
-
getProviderSetupWarmupTimer: () => null,
|
|
79
|
-
scheduleProviderSetupWarmup() {},
|
|
80
|
-
isCloseRequested: () => false,
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
const initial = usage.cachedProviderSetup();
|
|
84
|
-
await Promise.resolve();
|
|
85
|
-
const refreshed = usage.cachedProviderSetup({ force: true });
|
|
86
|
-
releaseFirst();
|
|
87
|
-
|
|
88
|
-
assert.deepEqual(await initial, { generation: 1 });
|
|
89
|
-
assert.deepEqual(await refreshed, { generation: 2 });
|
|
90
|
-
assert.equal(builds, 2);
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
test('current vendor preset defaults and OpenCode Go protocol routes are pinned', () => {
|
|
94
|
-
assert.equal(OPENAI_COMPAT_PRESETS.xai.defaultModel, 'grok-4.5');
|
|
95
|
-
assert.equal(OPENAI_COMPAT_PRESETS.deepseek.defaultModel, 'deepseek-v4-pro');
|
|
96
|
-
assert.equal(OPENAI_COMPAT_PRESETS['opencode-go'].defaultModel, 'glm-5.2');
|
|
97
|
-
for (const model of ['minimax-m3', 'minimax-m2.7', 'qwen3.7-max', 'qwen3.6-plus']) {
|
|
98
|
-
assert.equal(isAnthropicGoModel(model), true, model);
|
|
99
|
-
}
|
|
100
|
-
for (const model of ['glm-5.2', 'kimi-k2.7-code', 'deepseek-v4-pro', 'mimo-v2.5-pro']) {
|
|
101
|
-
assert.equal(isAnthropicGoModel(model), false, model);
|
|
102
|
-
}
|
|
103
|
-
assert.deepEqual(resolveOpenCodeGoBaseURLs(), {
|
|
104
|
-
openai: 'https://opencode.ai/zen/go/v1',
|
|
105
|
-
anthropic: 'https://opencode.ai/zen/go',
|
|
106
|
-
});
|
|
107
|
-
assert.equal(
|
|
108
|
-
openCodeGoEndpointForModel('minimax-m3'),
|
|
109
|
-
'https://opencode.ai/zen/go/v1/messages',
|
|
110
|
-
);
|
|
111
|
-
assert.equal(
|
|
112
|
-
openCodeGoEndpointForModel('glm-5.2'),
|
|
113
|
-
'https://opencode.ai/zen/go/v1/chat/completions',
|
|
114
|
-
);
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
test('provider-specific thinking fields do not leak across compat contracts', () => {
|
|
118
|
-
const deepseek = applyCompatProviderChatOptions({}, 'deepseek', { effort: 'low' });
|
|
119
|
-
assert.deepEqual(deepseek, {
|
|
120
|
-
thinking: { type: 'enabled' },
|
|
121
|
-
reasoning_effort: 'high',
|
|
122
|
-
});
|
|
123
|
-
assert.deepEqual(
|
|
124
|
-
applyCompatProviderChatOptions({}, 'deepseek', { effort: 'none' }),
|
|
125
|
-
{ thinking: { type: 'disabled' } },
|
|
126
|
-
);
|
|
127
|
-
assert.deepEqual(
|
|
128
|
-
applyCompatProviderChatOptions({}, 'ollama', { effort: 'max' }),
|
|
129
|
-
{ reasoning_effort: 'max' },
|
|
130
|
-
);
|
|
131
|
-
const go = applyCompatProviderChatOptions(
|
|
132
|
-
{},
|
|
133
|
-
'opencode-go',
|
|
134
|
-
{ effort: 'high' },
|
|
135
|
-
{},
|
|
136
|
-
{ reasoningOptions: [{ type: 'effort', values: ['low', 'high'] }] },
|
|
137
|
-
);
|
|
138
|
-
assert.deepEqual(go, { reasoning_effort: 'high' });
|
|
139
|
-
assert.equal(go.thinking, undefined);
|
|
140
|
-
assert.deepEqual(
|
|
141
|
-
applyCompatProviderChatOptions({}, 'lmstudio', {}, { reasoningEffort: 'medium' }),
|
|
142
|
-
{ reasoning_effort: 'medium' },
|
|
143
|
-
);
|
|
144
|
-
assert.deepEqual(applyCompatProviderChatOptions({}, 'xai', { effort: 'none' }), {});
|
|
145
|
-
assert.deepEqual(
|
|
146
|
-
applyCompatProviderChatOptions({}, 'xai', { effort: 'high' }),
|
|
147
|
-
{ reasoning_effort: 'high' },
|
|
148
|
-
);
|
|
149
|
-
assert.deepEqual(applyCompatProviderChatOptions({}, 'deepseek'), {});
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
test('compat chat stream preserves LM Studio reasoning alias without mixing it into answer text', async () => {
|
|
153
|
-
const result = await consumeCompatChatCompletionStream(stream([
|
|
154
|
-
{ id: 'r', model: 'local', choices: [{ delta: { reasoning: 'plan ' } }] },
|
|
155
|
-
{ id: 'r', model: 'local', choices: [{ delta: { reasoning: 'done', content: 'answer' } }] },
|
|
156
|
-
{ id: 'r', model: 'local', choices: [{ delta: {}, finish_reason: 'stop' }], usage: { prompt_tokens: 2, completion_tokens: 3 } },
|
|
157
|
-
]), {
|
|
158
|
-
label: 'lmstudio',
|
|
159
|
-
parseToolCalls,
|
|
160
|
-
});
|
|
161
|
-
assert.equal(result.reasoningContent, 'plan done');
|
|
162
|
-
assert.equal(result.content, 'answer');
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
test('compat API-key auth retries 401 once but never retries entitlement 403', async () => {
|
|
166
|
-
const forbidden = Object.create(OpenAICompatProvider.prototype);
|
|
167
|
-
let forbiddenCalls = 0;
|
|
168
|
-
let reloads = 0;
|
|
169
|
-
forbidden._doSend = async () => {
|
|
170
|
-
forbiddenCalls += 1;
|
|
171
|
-
throw new Error('403 forbidden');
|
|
172
|
-
};
|
|
173
|
-
forbidden.reloadApiKey = () => { reloads += 1; };
|
|
174
|
-
await assert.rejects(() => forbidden.send([], 'm'), /403/);
|
|
175
|
-
assert.equal(forbiddenCalls, 1);
|
|
176
|
-
assert.equal(reloads, 0);
|
|
177
|
-
|
|
178
|
-
const unauthorized = Object.create(OpenAICompatProvider.prototype);
|
|
179
|
-
let unauthorizedCalls = 0;
|
|
180
|
-
unauthorized._doSend = async () => {
|
|
181
|
-
unauthorizedCalls += 1;
|
|
182
|
-
if (unauthorizedCalls === 1) throw new Error('401 unauthorized');
|
|
183
|
-
return { content: 'ok' };
|
|
184
|
-
};
|
|
185
|
-
unauthorized.reloadApiKey = () => { reloads += 1; };
|
|
186
|
-
assert.equal((await unauthorized.send([], 'm')).content, 'ok');
|
|
187
|
-
assert.equal(unauthorizedCalls, 2);
|
|
188
|
-
assert.equal(reloads, 1);
|
|
189
|
-
|
|
190
|
-
const structuredUnauthorized = Object.create(OpenAICompatProvider.prototype);
|
|
191
|
-
let structuredCalls = 0;
|
|
192
|
-
let structuredReloads = 0;
|
|
193
|
-
structuredUnauthorized._doSend = async () => {
|
|
194
|
-
structuredCalls += 1;
|
|
195
|
-
if (structuredCalls === 1) throw Object.assign(new Error('authentication rejected'), { status: 0, httpStatus: 401 });
|
|
196
|
-
return { content: 'ok' };
|
|
197
|
-
};
|
|
198
|
-
structuredUnauthorized.reloadApiKey = () => { structuredReloads += 1; };
|
|
199
|
-
assert.equal((await structuredUnauthorized.send([], 'm')).content, 'ok');
|
|
200
|
-
assert.equal(structuredCalls, 2);
|
|
201
|
-
assert.equal(structuredReloads, 1);
|
|
202
|
-
|
|
203
|
-
const structuredForbidden = Object.create(OpenAICompatProvider.prototype);
|
|
204
|
-
let structuredForbiddenCalls = 0;
|
|
205
|
-
structuredForbidden._doSend = async () => {
|
|
206
|
-
structuredForbiddenCalls += 1;
|
|
207
|
-
throw Object.assign(new Error('policy denied'), { httpStatus: 403 });
|
|
208
|
-
};
|
|
209
|
-
structuredForbidden.reloadApiKey = () => { throw new Error('must not reload'); };
|
|
210
|
-
await assert.rejects(() => structuredForbidden.send([], 'm'), /policy denied/);
|
|
211
|
-
assert.equal(structuredForbiddenCalls, 1);
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
test('OpenCode Go normalizes both route families to inclusive provider usage', async () => {
|
|
215
|
-
const anthropicRaw = {
|
|
216
|
-
content: 'ok',
|
|
217
|
-
usage: {
|
|
218
|
-
inputTokens: 60,
|
|
219
|
-
outputTokens: 5,
|
|
220
|
-
cachedTokens: 35,
|
|
221
|
-
cacheWriteTokens: 5,
|
|
222
|
-
promptTokens: 100,
|
|
223
|
-
},
|
|
224
|
-
};
|
|
225
|
-
const openaiRaw = {
|
|
226
|
-
content: 'ok',
|
|
227
|
-
usage: {
|
|
228
|
-
inputTokens: 100,
|
|
229
|
-
outputTokens: 5,
|
|
230
|
-
cachedTokens: 40,
|
|
231
|
-
cacheWriteTokens: 0,
|
|
232
|
-
promptTokens: 100,
|
|
233
|
-
},
|
|
234
|
-
};
|
|
235
|
-
const provider = Object.create(OpenCodeGoProvider.prototype);
|
|
236
|
-
provider.anthropic = { send: async () => anthropicRaw };
|
|
237
|
-
provider.openai = { send: async () => openaiRaw };
|
|
238
|
-
const anthropic = await provider.send([], 'minimax-m3', [], {});
|
|
239
|
-
assert.equal(OpenCodeGoProvider.inputExcludesCache, false);
|
|
240
|
-
assert.equal(isInclusiveProvider('opencode-go'), true);
|
|
241
|
-
assert.equal(anthropic.usage.inputTokens, 100);
|
|
242
|
-
assert.equal(anthropic.usage.promptTokens, 100);
|
|
243
|
-
assert.equal(uncachedInputTokensForProvider('opencode-go', anthropic.usage.inputTokens, 35, 5), 60);
|
|
244
|
-
assert.equal(billableInputTokensForProvider('opencode-go', 100, 35, 5), 60);
|
|
245
|
-
assert.deepEqual(resolveTraceUsageInput({
|
|
246
|
-
provider: 'opencode-go',
|
|
247
|
-
inputTokens: 60,
|
|
248
|
-
cachedTokens: 35,
|
|
249
|
-
cacheWriteTokens: 5,
|
|
250
|
-
inputTokensInclusive: false,
|
|
251
|
-
}), {
|
|
252
|
-
uncachedInputTokens: 60,
|
|
253
|
-
promptTokens: 100,
|
|
254
|
-
});
|
|
255
|
-
assert.equal(anthropic.usage.inputTokens, 100, 'context footprint is inclusive');
|
|
256
|
-
|
|
257
|
-
const openai = await provider.send([], 'glm-5.2', [], {});
|
|
258
|
-
assert.equal(openai, openaiRaw);
|
|
259
|
-
assert.equal(uncachedInputTokensForProvider('opencode-go', openai.usage.inputTokens, 40, 0), 60);
|
|
260
|
-
assert.equal(billableInputTokensForProvider('opencode-go', 100, 40, 0), 60);
|
|
261
|
-
assert.deepEqual(resolveTraceUsageInput({
|
|
262
|
-
provider: 'opencode-go',
|
|
263
|
-
inputTokens: 100,
|
|
264
|
-
cachedTokens: 40,
|
|
265
|
-
cacheWriteTokens: 0,
|
|
266
|
-
}), {
|
|
267
|
-
uncachedInputTokens: 60,
|
|
268
|
-
promptTokens: 100,
|
|
269
|
-
});
|
|
270
|
-
assert.equal(openai.usage.inputTokens, 100, 'context footprint remains inclusive');
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
test('OpenCode Go Anthropic delegation traces additive inner usage before inclusive outer normalization', (t) => {
|
|
274
|
-
const tempDir = mkdtempSync(join(tmpdir(), 'mixdog-opencode-go-trace-'));
|
|
275
|
-
const tracePath = join(tempDir, 'agent-trace.jsonl');
|
|
276
|
-
t.after(() => rmSync(tempDir, { recursive: true, force: true }));
|
|
277
|
-
|
|
278
|
-
const openCodeGoUrl = new URL('../src/runtime/agent/orchestrator/providers/opencode-go.mjs', import.meta.url).href;
|
|
279
|
-
const anthropicUrl = new URL('../src/runtime/agent/orchestrator/providers/anthropic.mjs', import.meta.url).href;
|
|
280
|
-
const traceUrl = new URL('../src/runtime/agent/orchestrator/agent-trace.mjs', import.meta.url).href;
|
|
281
|
-
const fixture = `
|
|
282
|
-
const { OpenCodeGoProvider } = await import(${JSON.stringify(openCodeGoUrl)});
|
|
283
|
-
const { AnthropicProvider } = await import(${JSON.stringify(anthropicUrl)});
|
|
284
|
-
const { drainAgentTrace } = await import(${JSON.stringify(traceUrl)});
|
|
285
|
-
|
|
286
|
-
const encoder = new TextEncoder();
|
|
287
|
-
const events = [
|
|
288
|
-
{ type: 'message_start', message: {
|
|
289
|
-
model: 'minimax-m3',
|
|
290
|
-
usage: {
|
|
291
|
-
input_tokens: 60,
|
|
292
|
-
cache_read_input_tokens: 35,
|
|
293
|
-
cache_creation_input_tokens: 5,
|
|
294
|
-
},
|
|
295
|
-
} },
|
|
296
|
-
{ type: 'message_delta', delta: { stop_reason: 'end_turn' }, usage: { output_tokens: 5 } },
|
|
297
|
-
{ type: 'message_stop' },
|
|
298
|
-
];
|
|
299
|
-
const chunks = events.map((event) => encoder.encode(
|
|
300
|
-
'event: ' + event.type + '\\ndata: ' + JSON.stringify(event) + '\\n\\n'
|
|
301
|
-
));
|
|
302
|
-
let chunkIndex = 0;
|
|
303
|
-
const response = {
|
|
304
|
-
ok: true,
|
|
305
|
-
status: 200,
|
|
306
|
-
headers: new Map(),
|
|
307
|
-
body: { getReader() {
|
|
308
|
-
return {
|
|
309
|
-
read() {
|
|
310
|
-
return chunkIndex < chunks.length
|
|
311
|
-
? Promise.resolve({ done: false, value: chunks[chunkIndex++] })
|
|
312
|
-
: Promise.resolve({ done: true, value: undefined });
|
|
313
|
-
},
|
|
314
|
-
cancel() { return Promise.resolve(); },
|
|
315
|
-
releaseLock() {},
|
|
316
|
-
};
|
|
317
|
-
} },
|
|
318
|
-
};
|
|
319
|
-
|
|
320
|
-
const inner = Object.create(AnthropicProvider.prototype);
|
|
321
|
-
inner.name = 'opencode-go';
|
|
322
|
-
inner.config = { disableBetaHeaders: true };
|
|
323
|
-
inner.fastModeBetaHeaderLatched = false;
|
|
324
|
-
inner.client = { messages: { create() {
|
|
325
|
-
return { asResponse: async () => response };
|
|
326
|
-
} } };
|
|
327
|
-
|
|
328
|
-
const outer = Object.create(OpenCodeGoProvider.prototype);
|
|
329
|
-
outer.anthropic = inner;
|
|
330
|
-
outer.openai = { send() { throw new Error('wrong OpenCode Go route'); } };
|
|
331
|
-
const result = await outer.send(
|
|
332
|
-
[{ role: 'user', content: 'fixture' }],
|
|
333
|
-
'minimax-m3',
|
|
334
|
-
[],
|
|
335
|
-
{ sessionId: 'opencode-go-additive-trace' },
|
|
336
|
-
);
|
|
337
|
-
await drainAgentTrace();
|
|
338
|
-
process.stdout.write(JSON.stringify(result.usage));
|
|
339
|
-
`;
|
|
340
|
-
const child = spawnSync(process.execPath, ['--input-type=module', '-e', fixture], {
|
|
341
|
-
cwd: new URL('..', import.meta.url),
|
|
342
|
-
encoding: 'utf8',
|
|
343
|
-
env: {
|
|
344
|
-
...process.env,
|
|
345
|
-
MIXDOG_AGENT_TRACE_DISABLE: '0',
|
|
346
|
-
MIXDOG_AGENT_TRACE_LOCAL_DISABLE: '0',
|
|
347
|
-
MIXDOG_AGENT_TRACE_PATH: tracePath,
|
|
348
|
-
},
|
|
349
|
-
});
|
|
350
|
-
assert.equal(child.status, 0, child.stderr || child.stdout);
|
|
351
|
-
|
|
352
|
-
const outerUsage = JSON.parse(child.stdout);
|
|
353
|
-
assert.deepEqual(outerUsage, {
|
|
354
|
-
inputTokens: 100,
|
|
355
|
-
outputTokens: 5,
|
|
356
|
-
cachedTokens: 35,
|
|
357
|
-
cacheWriteTokens: 5,
|
|
358
|
-
promptTokens: 100,
|
|
359
|
-
});
|
|
360
|
-
const traceRows = readFileSync(tracePath, 'utf8')
|
|
361
|
-
.trim()
|
|
362
|
-
.split(/\r?\n/)
|
|
363
|
-
.map((line) => JSON.parse(line));
|
|
364
|
-
const innerUsage = traceRows.find((row) => (
|
|
365
|
-
row.kind === 'usage_raw'
|
|
366
|
-
&& row.session_id === 'opencode-go-additive-trace'
|
|
367
|
-
));
|
|
368
|
-
assert.ok(innerUsage, 'delegated Anthropic route must emit usage_raw');
|
|
369
|
-
assert.equal(innerUsage.payload.provider, 'opencode-go');
|
|
370
|
-
assert.equal(innerUsage.input_tokens, 60);
|
|
371
|
-
assert.equal(innerUsage.cached_tokens, 35);
|
|
372
|
-
assert.equal(innerUsage.cache_write_tokens, 5);
|
|
373
|
-
assert.equal(innerUsage.uncached_input_tokens, 60);
|
|
374
|
-
assert.equal(innerUsage.prompt_tokens, 100);
|
|
375
|
-
});
|
|
376
|
-
|
|
377
|
-
test('constructing Grok OAuth is network inert', () => {
|
|
378
|
-
const provider = new GrokOAuthProvider({
|
|
379
|
-
preconnectFn: () => { throw new Error('constructor attempted outbound preconnect'); },
|
|
380
|
-
});
|
|
381
|
-
assert.ok(provider);
|
|
382
|
-
});
|
|
383
|
-
|
|
384
|
-
test('Grok OAuth end-to-end HTTP Responses path is hermetic through inner compat', async (t) => {
|
|
385
|
-
const priorFetch = globalThis.fetch;
|
|
386
|
-
globalThis.fetch = async () => {
|
|
387
|
-
throw new Error('global fetch attempted by hermetic Grok path');
|
|
388
|
-
};
|
|
389
|
-
t.after(() => { globalThis.fetch = priorFetch; });
|
|
390
|
-
|
|
391
|
-
const provider = new GrokOAuthProvider({
|
|
392
|
-
preconnect: false,
|
|
393
|
-
preconnectFn: () => {
|
|
394
|
-
throw new Error('preconnect/undici attempted by hermetic Grok path');
|
|
395
|
-
},
|
|
396
|
-
responsesTransport: 'http',
|
|
397
|
-
});
|
|
398
|
-
provider.ensureAuth = async () => ({ access_token: 'fixture-token', user_id: 'fixture-user' });
|
|
399
|
-
const ensureInner = provider._ensureInner.bind(provider);
|
|
400
|
-
let capturedInner = null;
|
|
401
|
-
let capturedParams = null;
|
|
402
|
-
provider._ensureInner = (...args) => {
|
|
403
|
-
const inner = ensureInner(...args);
|
|
404
|
-
capturedInner = inner;
|
|
405
|
-
inner.client = {
|
|
406
|
-
responses: {
|
|
407
|
-
create: async (params) => {
|
|
408
|
-
capturedParams = params;
|
|
409
|
-
return stream([
|
|
410
|
-
{ type: 'response.created', response: { id: 'resp_fixture', model: 'grok-4.5' } },
|
|
411
|
-
{ type: 'response.output_text.delta', delta: 'hermetic' },
|
|
412
|
-
{
|
|
413
|
-
type: 'response.completed',
|
|
414
|
-
response: {
|
|
415
|
-
id: 'resp_fixture',
|
|
416
|
-
model: 'grok-4.5',
|
|
417
|
-
status: 'completed',
|
|
418
|
-
output: [],
|
|
419
|
-
usage: { input_tokens: 3, output_tokens: 1 },
|
|
420
|
-
},
|
|
421
|
-
},
|
|
422
|
-
]);
|
|
423
|
-
},
|
|
424
|
-
},
|
|
425
|
-
};
|
|
426
|
-
return inner;
|
|
427
|
-
};
|
|
428
|
-
|
|
429
|
-
const result = await provider.send(
|
|
430
|
-
[{ role: 'user', content: 'fixture' }],
|
|
431
|
-
'grok-4.5',
|
|
432
|
-
[],
|
|
433
|
-
{ sessionId: 'hermetic-grok-contract', iteration: 2 },
|
|
434
|
-
);
|
|
435
|
-
assert.equal(result.content, 'hermetic');
|
|
436
|
-
assert.equal(result.usage.inputTokens, 3);
|
|
437
|
-
assert.equal(capturedInner.config.preconnect, false, 'Grok seam must propagate to inner compat');
|
|
438
|
-
assert.equal(typeof capturedInner.config.preconnectFn, 'function');
|
|
439
|
-
assert.equal(capturedInner.baseURL, 'https://cli-chat-proxy.grok.com/v1');
|
|
440
|
-
assert.equal(capturedInner.config.responsesTransport, 'http');
|
|
441
|
-
assert.equal(capturedInner.defaultHeaders['x-grok-conv-id'], undefined);
|
|
442
|
-
assert.equal(capturedInner.defaultHeaders['x-grok-session-id'], 'hermetic-grok-contract');
|
|
443
|
-
assert.match(capturedInner.defaultHeaders['x-grok-req-id'], /^[0-9a-f-]{36}$/);
|
|
444
|
-
assert.equal(capturedInner.defaultHeaders['x-grok-model-override'], 'grok-4.5');
|
|
445
|
-
assert.equal(capturedInner.defaultHeaders['x-grok-turn-idx'], '2');
|
|
446
|
-
assert.equal(capturedInner.defaultHeaders['x-grok-user-id'], 'fixture-user');
|
|
447
|
-
assert.equal(capturedParams.store, false);
|
|
448
|
-
assert.deepEqual(capturedParams.include, ['reasoning.encrypted_content']);
|
|
449
|
-
assert.equal(result.providerState.xaiResponses.store, false);
|
|
450
|
-
assert.equal(result.providerState.xaiResponses.previousResponseId, null);
|
|
451
|
-
});
|
|
452
|
-
|
|
453
|
-
test('xAI Responses defaults to HTTP and keeps WebSocket behind explicit opt-in', () => {
|
|
454
|
-
assert.equal(useXaiResponsesWebSocket({}, {}), false);
|
|
455
|
-
assert.equal(useXaiResponsesWebSocket({}, { responsesTransport: 'http' }), false);
|
|
456
|
-
assert.equal(useXaiResponsesWebSocket({}, { responsesTransport: 'websocket' }), true);
|
|
457
|
-
});
|
|
458
|
-
|
|
459
|
-
for (const event of [
|
|
460
|
-
{ type: 'response.failed', response: { error: { message: 'forbidden' } } },
|
|
461
|
-
{ type: 'error', message: 'forbidden' },
|
|
462
|
-
]) {
|
|
463
|
-
test(`xAI ${event.type} stream event is retryable 500-equivalent without changing other compat labels`, async () => {
|
|
464
|
-
const xaiError = await consumeCompatResponsesStream(stream([event]), {
|
|
465
|
-
label: 'xai:responses',
|
|
466
|
-
parseResponsesToolCalls: () => [],
|
|
467
|
-
responseOutputText: () => '',
|
|
468
|
-
}).then(() => null, (err) => err);
|
|
469
|
-
assert.equal(xaiError.httpStatus, 500);
|
|
470
|
-
assert.equal(classifyError(xaiError), 'transient');
|
|
471
|
-
|
|
472
|
-
const otherError = await consumeCompatResponsesStream(stream([event]), {
|
|
473
|
-
label: 'other-compat',
|
|
474
|
-
parseResponsesToolCalls: () => [],
|
|
475
|
-
responseOutputText: () => '',
|
|
476
|
-
}).then(() => null, (err) => err);
|
|
477
|
-
assert.equal(otherError.httpStatus, 403);
|
|
478
|
-
assert.equal(classifyError(otherError), 'auth');
|
|
479
|
-
});
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
test('Grok OAuth does not refresh/replay a 401 after visible tool dispatch', async () => {
|
|
483
|
-
const provider = Object.create(GrokOAuthProvider.prototype);
|
|
484
|
-
provider.config = { preconnect: false };
|
|
485
|
-
let authCalls = 0;
|
|
486
|
-
provider.ensureAuth = async ({ forceRefresh = false } = {}) => {
|
|
487
|
-
authCalls += 1;
|
|
488
|
-
assert.equal(forceRefresh, false);
|
|
489
|
-
return { access_token: 'fixture-token' };
|
|
490
|
-
};
|
|
491
|
-
const streamed401 = Object.assign(new Error('401 midstream'), {
|
|
492
|
-
httpStatus: 401,
|
|
493
|
-
emittedToolCall: true,
|
|
494
|
-
unsafeToRetry: true,
|
|
495
|
-
});
|
|
496
|
-
let dispatched = 0;
|
|
497
|
-
provider._ensureInner = () => ({
|
|
498
|
-
_doSend: async (_messages, _model, _tools, opts) => {
|
|
499
|
-
opts.onToolCall({ id: 'call-visible', name: 'write', arguments: { path: 'x' } });
|
|
500
|
-
dispatched += 1;
|
|
501
|
-
throw streamed401;
|
|
502
|
-
},
|
|
503
|
-
});
|
|
504
|
-
await assert.rejects(() => provider.send([], 'grok-4.5', [], {
|
|
505
|
-
onToolCall: () => {},
|
|
506
|
-
}), (err) => err === streamed401);
|
|
507
|
-
assert.equal(dispatched, 1);
|
|
508
|
-
assert.equal(authCalls, 1);
|
|
509
|
-
});
|
|
510
|
-
|
|
511
|
-
test('xAI WS to HTTP fallback preserves completed warmup usage and cost ticks', async (t) => {
|
|
512
|
-
const priorTransport = process.env.MIXDOG_OAI_TRANSPORT;
|
|
513
|
-
process.env.MIXDOG_OAI_TRANSPORT = 'auto';
|
|
514
|
-
t.after(() => {
|
|
515
|
-
if (priorTransport == null) delete process.env.MIXDOG_OAI_TRANSPORT;
|
|
516
|
-
else process.env.MIXDOG_OAI_TRANSPORT = priorTransport;
|
|
517
|
-
});
|
|
518
|
-
const provider = new OpenAICompatProvider('xai', {
|
|
519
|
-
apiKey: 'fixture',
|
|
520
|
-
preconnect: false,
|
|
521
|
-
responsesTransport: 'websocket',
|
|
522
|
-
});
|
|
523
|
-
const warmup = {
|
|
524
|
-
requestBody: { generate: false },
|
|
525
|
-
usage: { inputTokens: 10, outputTokens: 1, cachedTokens: 4, promptTokens: 10, raw: { cost_in_usd_ticks: 100 } },
|
|
526
|
-
};
|
|
527
|
-
provider._doSendXaiResponsesWebSocket = async () => {
|
|
528
|
-
const err = Object.assign(new Error('upgrade required'), { httpStatus: 426 });
|
|
529
|
-
Object.defineProperty(err, '__warmup', { value: warmup });
|
|
530
|
-
throw err;
|
|
531
|
-
};
|
|
532
|
-
provider._doSendXaiResponses = async () => ({
|
|
533
|
-
content: 'fallback',
|
|
534
|
-
usage: { inputTokens: 20, outputTokens: 2, cachedTokens: 5, promptTokens: 20, raw: { cost_in_usd_ticks: 200 }, costUsd: 0.00000002 },
|
|
535
|
-
});
|
|
536
|
-
const result = await provider._doSend([], 'grok-4.5', [], {});
|
|
537
|
-
assert.equal(result.usage.inputTokens, 30);
|
|
538
|
-
assert.equal(result.usage.mainInputTokens, 20);
|
|
539
|
-
assert.equal(result.usage.raw.cost_in_usd_ticks, 300);
|
|
540
|
-
assert.equal(result.usage.costUsd, 0.00000003);
|
|
541
|
-
});
|
|
542
|
-
|
|
543
|
-
test('xAI WS warmup billing exposes only main request usage as context', async () => {
|
|
544
|
-
let streams = 0;
|
|
545
|
-
const result = await sendViaWebSocket({
|
|
546
|
-
auth: { type: 'xai', apiKey: 'fixture' },
|
|
547
|
-
body: { model: 'grok-4.5', input: [{ role: 'user', content: 'main' }] },
|
|
548
|
-
sendOpts: {},
|
|
549
|
-
externalSignal: null,
|
|
550
|
-
poolKey: 'xai-warmup-accounting',
|
|
551
|
-
cacheKey: 'xai-warmup-accounting',
|
|
552
|
-
iteration: 1,
|
|
553
|
-
useModel: 'grok-4.5',
|
|
554
|
-
traceProvider: 'xai',
|
|
555
|
-
includeResponseId: true,
|
|
556
|
-
warmupBody: { model: 'grok-4.5', input: [], generate: false },
|
|
557
|
-
_acquireWithRetryFn: async () => ({ entry: { socket: { close() {} } }, reused: false }),
|
|
558
|
-
_sendFrameFn: async () => {},
|
|
559
|
-
_streamFn: async ({ state }) => {
|
|
560
|
-
streams += 1;
|
|
561
|
-
return state.warmup
|
|
562
|
-
? {
|
|
563
|
-
content: '',
|
|
564
|
-
model: 'grok-4.5',
|
|
565
|
-
toolCalls: [],
|
|
566
|
-
usage: { inputTokens: 10, outputTokens: 1, cachedTokens: 4, promptTokens: 10, raw: { cost_in_usd_ticks: 100 } },
|
|
567
|
-
responseId: 'warm',
|
|
568
|
-
responseItems: [],
|
|
569
|
-
}
|
|
570
|
-
: {
|
|
571
|
-
content: 'done',
|
|
572
|
-
model: 'grok-4.5',
|
|
573
|
-
toolCalls: [],
|
|
574
|
-
usage: { inputTokens: 20, outputTokens: 2, cachedTokens: 5, promptTokens: 20, raw: { cost_in_usd_ticks: 200 } },
|
|
575
|
-
responseId: 'main',
|
|
576
|
-
responseItems: [],
|
|
577
|
-
closeSocket: true,
|
|
578
|
-
};
|
|
579
|
-
},
|
|
580
|
-
_agentTraceFn: () => {},
|
|
581
|
-
_sendSpanTraceFn: () => {},
|
|
582
|
-
});
|
|
583
|
-
assert.equal(streams, 2);
|
|
584
|
-
assert.equal(result.usage.inputTokens, 30);
|
|
585
|
-
assert.equal(result.usage.mainInputTokens, 20);
|
|
586
|
-
assert.equal(result.usage.raw.cost_in_usd_ticks, 300);
|
|
587
|
-
});
|
|
588
|
-
|
|
589
|
-
test('xAI safe 401 replay carries completed warmup into the retry', async () => {
|
|
590
|
-
const provider = new OpenAICompatProvider('xai', { apiKey: 'fixture', preconnect: false });
|
|
591
|
-
const warmup = { usage: { inputTokens: 10 } };
|
|
592
|
-
let attempts = 0;
|
|
593
|
-
provider.reloadApiKey = () => {};
|
|
594
|
-
provider._doSend = async (_messages, _model, _tools, opts) => {
|
|
595
|
-
attempts += 1;
|
|
596
|
-
if (attempts === 1) {
|
|
597
|
-
const err = Object.assign(new Error('401'), { httpStatus: 401 });
|
|
598
|
-
Object.defineProperty(err, '__warmup', { value: warmup });
|
|
599
|
-
throw err;
|
|
600
|
-
}
|
|
601
|
-
assert.equal(opts._carriedWarmup, warmup);
|
|
602
|
-
return { content: 'retried' };
|
|
603
|
-
};
|
|
604
|
-
assert.equal((await provider.send([], 'grok-4.5', [], {})).content, 'retried');
|
|
605
|
-
assert.equal(attempts, 2);
|
|
606
|
-
});
|
|
607
|
-
|
|
608
|
-
for (const status of [401, 403]) {
|
|
609
|
-
test(`Grok OAuth safe ${status} replay carries completed warmup to refreshed xAI inner`, async () => {
|
|
610
|
-
const provider = Object.create(GrokOAuthProvider.prototype);
|
|
611
|
-
provider.config = { preconnect: false };
|
|
612
|
-
const warmup = { usage: { inputTokens: 10 } };
|
|
613
|
-
let authCalls = 0;
|
|
614
|
-
provider.ensureAuth = async ({ forceRefresh = false } = {}) => {
|
|
615
|
-
authCalls += 1;
|
|
616
|
-
return { access_token: forceRefresh ? 'fresh' : 'stale' };
|
|
617
|
-
};
|
|
618
|
-
provider._ensureInner = (token) => ({
|
|
619
|
-
_doSend: async (_messages, _model, _tools, opts) => {
|
|
620
|
-
if (token === 'stale') {
|
|
621
|
-
const err = Object.assign(new Error(String(status)), { httpStatus: status });
|
|
622
|
-
Object.defineProperty(err, '__warmup', { value: warmup });
|
|
623
|
-
throw err;
|
|
624
|
-
}
|
|
625
|
-
assert.equal(opts._carriedWarmup, warmup);
|
|
626
|
-
return { content: 'retried' };
|
|
627
|
-
},
|
|
628
|
-
});
|
|
629
|
-
assert.equal((await provider.send([], 'grok-4.5', [], {})).content, 'retried');
|
|
630
|
-
assert.equal(authCalls, 2);
|
|
631
|
-
});
|
|
632
|
-
}
|