mixdog 0.9.63 → 0.9.65
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/turn-snapshot.mjs +184 -0
- 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/runtime-core.mjs +4 -0
- package/src/session-runtime/session-text.mjs +4 -4
- package/src/session-runtime/session-turn-api.mjs +7 -0
- 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.jsx +1 -1
- 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 +187 -99
- package/src/tui/engine/agent-envelope.mjs +5 -5
- package/src/tui/engine/live-share.mjs +100 -0
- 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 +6 -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 +29 -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,763 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import test from 'node:test';
|
|
3
|
-
import assert from 'node:assert/strict';
|
|
4
|
-
import { EventEmitter } from 'node:events';
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
_clearSessionRuntime,
|
|
8
|
-
_getRuntimeEntry,
|
|
9
|
-
getSessionProgressSnapshot,
|
|
10
|
-
markSessionAskStart,
|
|
11
|
-
markSessionStreamDelta,
|
|
12
|
-
updateSessionStage,
|
|
13
|
-
} from '../src/runtime/agent/orchestrator/session/manager/runtime-liveness.mjs';
|
|
14
|
-
import {
|
|
15
|
-
evaluateAgentWatchdogAbort,
|
|
16
|
-
resolveEffectiveToolRunningCeilingMs,
|
|
17
|
-
} from '../src/runtime/agent/orchestrator/agent-runtime/agent-progress-watchdog.mjs';
|
|
18
|
-
import {
|
|
19
|
-
buildAgentTaskProgressFields,
|
|
20
|
-
formatAgentWatchdogSummary,
|
|
21
|
-
} from '../src/standalone/agent-task-status.mjs';
|
|
22
|
-
import {
|
|
23
|
-
consumeCompatChatCompletionStream,
|
|
24
|
-
consumeCompatResponsesStream,
|
|
25
|
-
} from '../src/runtime/agent/orchestrator/providers/openai-compat-stream.mjs';
|
|
26
|
-
import { parseSSEStream } from '../src/runtime/agent/orchestrator/providers/anthropic-sse.mjs';
|
|
27
|
-
import { _streamResponse } from '../src/runtime/agent/orchestrator/providers/openai-ws-stream.mjs';
|
|
28
|
-
import { sendViaHttpSse } from '../src/runtime/agent/orchestrator/providers/openai-oauth-http-sse.mjs';
|
|
29
|
-
import { shouldFallbackTransport } from '../src/runtime/agent/orchestrator/providers/retry-classifier.mjs';
|
|
30
|
-
import {
|
|
31
|
-
PROVIDER_MAX_BEFORE_WARN_MS,
|
|
32
|
-
PROVIDER_SEMANTIC_IDLE_TIMEOUT_MS,
|
|
33
|
-
PROVIDER_WS_SEMANTIC_IDLE_TIMEOUT_MS,
|
|
34
|
-
} from '../src/runtime/agent/orchestrator/stall-policy.mjs';
|
|
35
|
-
import {
|
|
36
|
-
ProviderAdmissionScheduler,
|
|
37
|
-
wrapProviderAdmission,
|
|
38
|
-
} from '../src/runtime/agent/orchestrator/providers/admission-scheduler.mjs';
|
|
39
|
-
|
|
40
|
-
const policy = {
|
|
41
|
-
firstTransportMs: 120_000,
|
|
42
|
-
firstSemanticMs: 600_000,
|
|
43
|
-
idleStaleMs: 600_000,
|
|
44
|
-
toolRunningMs: 600_000,
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
test('OpenAI HTTP and WS semantic idle defaults share the pre-watchdog ceiling', () => {
|
|
48
|
-
assert.equal(PROVIDER_SEMANTIC_IDLE_TIMEOUT_MS, PROVIDER_MAX_BEFORE_WARN_MS);
|
|
49
|
-
assert.equal(PROVIDER_WS_SEMANTIC_IDLE_TIMEOUT_MS, PROVIDER_MAX_BEFORE_WARN_MS);
|
|
50
|
-
assert.ok(PROVIDER_WS_SEMANTIC_IDLE_TIMEOUT_MS < 300_000);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
function seededSnapshot(id, elapsedMs) {
|
|
54
|
-
markSessionAskStart(id);
|
|
55
|
-
const entry = _getRuntimeEntry(id);
|
|
56
|
-
const startedAt = Date.now() - elapsedMs;
|
|
57
|
-
entry.askStartedAt = startedAt;
|
|
58
|
-
entry.modelRequestStartedAt = startedAt;
|
|
59
|
-
entry.lastProgressAt = startedAt;
|
|
60
|
-
return { entry, snapshot: () => getSessionProgressSnapshot(id) };
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
test('independent first transport and semantic deadlines', async (t) => {
|
|
64
|
-
const id = `liveness-deadlines-${Date.now()}`;
|
|
65
|
-
t.after(() => _clearSessionRuntime(id));
|
|
66
|
-
const { entry, snapshot } = seededSnapshot(id, 121_000);
|
|
67
|
-
let err = evaluateAgentWatchdogAbort(snapshot(), Date.now(), policy);
|
|
68
|
-
assert.match(err?.message || '', /first transport stale \(120000ms\)/);
|
|
69
|
-
|
|
70
|
-
entry.lastTransportAt = Date.now();
|
|
71
|
-
err = evaluateAgentWatchdogAbort(snapshot(), entry.modelRequestStartedAt + 599_999, policy);
|
|
72
|
-
assert.equal(err, null, 'keepalive transport must not switch/reset the semantic deadline');
|
|
73
|
-
err = evaluateAgentWatchdogAbort(snapshot(), entry.modelRequestStartedAt + 600_001, policy);
|
|
74
|
-
assert.match(err?.message || '', /first semantic response stale \(600000ms\)/);
|
|
75
|
-
|
|
76
|
-
await markSessionStreamDelta(id, 'reasoning');
|
|
77
|
-
assert.equal(evaluateAgentWatchdogAbort(snapshot(), entry.modelRequestStartedAt + 700_000, policy), null);
|
|
78
|
-
assert.equal(snapshot().hasVisibleProgress, false);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
test('genuinely queued scheduler request remains outside the real watchdog clock', async (t) => {
|
|
82
|
-
const id = `liveness-admission-${Date.now()}`;
|
|
83
|
-
t.after(() => _clearSessionRuntime(id));
|
|
84
|
-
const scheduler = new ProviderAdmissionScheduler({ concurrency: 1 });
|
|
85
|
-
let releaseFirst;
|
|
86
|
-
const firstGate = new Promise((resolve) => { releaseFirst = resolve; });
|
|
87
|
-
const provider = wrapProviderAdmission({
|
|
88
|
-
async send(_messages, _model, _tools, opts) {
|
|
89
|
-
if (opts.block) return firstGate;
|
|
90
|
-
return 'queued-ok';
|
|
91
|
-
},
|
|
92
|
-
}, 'watchdog-integration', scheduler);
|
|
93
|
-
markSessionAskStart(id);
|
|
94
|
-
const entry = _getRuntimeEntry(id);
|
|
95
|
-
entry.askStartedAt = Date.now() - 900_000;
|
|
96
|
-
entry.lastProgressAt = entry.askStartedAt;
|
|
97
|
-
const first = provider.send([], 'm', [], { block: true });
|
|
98
|
-
const second = provider.send([], 'm', [], {
|
|
99
|
-
onStageChange: (stage) => updateSessionStage(id, stage),
|
|
100
|
-
});
|
|
101
|
-
await new Promise((resolve) => setImmediate(resolve));
|
|
102
|
-
assert.equal(entry.modelRequestStartedAt, null);
|
|
103
|
-
assert.equal(evaluateAgentWatchdogAbort(getSessionProgressSnapshot(id), Date.now(), policy), null);
|
|
104
|
-
releaseFirst('first');
|
|
105
|
-
await first;
|
|
106
|
-
assert.equal(await second, 'queued-ok');
|
|
107
|
-
assert.ok(entry.modelRequestStartedAt >= Date.now() - 100);
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
test('status labels distinguish transport, semantic, reasoning, text, tool, and true stall', async (t) => {
|
|
111
|
-
const id = `liveness-status-${Date.now()}`;
|
|
112
|
-
t.after(() => _clearSessionRuntime(id));
|
|
113
|
-
const { entry, snapshot } = seededSnapshot(id, 10_000);
|
|
114
|
-
const fields = () => buildAgentTaskProgressFields({
|
|
115
|
-
now: Date.now(),
|
|
116
|
-
runtimeStage: entry.stage,
|
|
117
|
-
snapshot: snapshot(),
|
|
118
|
-
runtime: entry,
|
|
119
|
-
policy,
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
assert.equal(fields().last_progress, 'awaiting model transport');
|
|
123
|
-
assert.equal(fields().watchdog, 'armed transport=120s');
|
|
124
|
-
await markSessionStreamDelta(id, 'transport');
|
|
125
|
-
assert.equal(fields().last_progress, 'transport active; awaiting first model event');
|
|
126
|
-
assert.equal(fields().watchdog, 'armed semantic=600s');
|
|
127
|
-
await markSessionStreamDelta(id, 'semantic');
|
|
128
|
-
assert.equal(fields().last_progress, 'model active (no visible output yet)');
|
|
129
|
-
await markSessionStreamDelta(id, 'reasoning');
|
|
130
|
-
assert.equal(fields().last_progress, 'model reasoning (hidden; no visible output yet)');
|
|
131
|
-
assert.equal(fields().diagnostic, 'hidden reasoning active; no visible output yet');
|
|
132
|
-
await markSessionStreamDelta(id, 'text');
|
|
133
|
-
assert.equal(fields().last_progress, 'visible model text');
|
|
134
|
-
await markSessionStreamDelta(id, 'reasoning');
|
|
135
|
-
assert.equal(fields().last_progress, 'model reasoning (hidden; visible output previously emitted)');
|
|
136
|
-
await markSessionStreamDelta(id, 'tool');
|
|
137
|
-
entry.lastVisibleTextAt = null;
|
|
138
|
-
assert.equal(fields().last_progress, 'tool protocol progress');
|
|
139
|
-
assert.equal(formatAgentWatchdogSummary(policy), 'armed transport=120s semantic=600s idle=600s tool=600s');
|
|
140
|
-
|
|
141
|
-
entry.firstSemanticAt = null;
|
|
142
|
-
entry.lastSemanticAt = null;
|
|
143
|
-
entry.lastTransportAt = Date.now();
|
|
144
|
-
entry.modelRequestStartedAt = Date.now() - 600_001;
|
|
145
|
-
assert.match(fields().diagnostic, /^stale: first semantic response stale/);
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
test('tool-running status uses the same effective self-deadline ceiling as the watchdog', () => {
|
|
149
|
-
const snapshot = {
|
|
150
|
-
stage: 'tool_running',
|
|
151
|
-
toolStartedAt: 1_000,
|
|
152
|
-
currentTool: 'shell',
|
|
153
|
-
toolSelfDeadlineMs: 900_000,
|
|
154
|
-
lastProgressAt: 1_000,
|
|
155
|
-
};
|
|
156
|
-
const toolPolicy = { ...policy, idleStaleMs: 0 };
|
|
157
|
-
assert.equal(resolveEffectiveToolRunningCeilingMs(snapshot, toolPolicy), 960_000);
|
|
158
|
-
assert.equal(formatAgentWatchdogSummary(toolPolicy, snapshot), 'armed tool=960s');
|
|
159
|
-
assert.equal(evaluateAgentWatchdogAbort(snapshot, 961_000, toolPolicy), null);
|
|
160
|
-
assert.match(
|
|
161
|
-
evaluateAgentWatchdogAbort(snapshot, 961_001, toolPolicy)?.message || '',
|
|
162
|
-
/tool running stale \(960000ms\)/,
|
|
163
|
-
);
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
function asyncEvents(events) {
|
|
167
|
-
return { async *[Symbol.asyncIterator]() { for (const event of events) yield event; } };
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
function heartbeatOnlyStream(firstEvent, heartbeatEvent, intervalMs = 10) {
|
|
171
|
-
return {
|
|
172
|
-
async *[Symbol.asyncIterator]() {
|
|
173
|
-
yield firstEvent;
|
|
174
|
-
while (true) {
|
|
175
|
-
await new Promise((resolve) => setTimeout(resolve, intervalMs));
|
|
176
|
-
yield heartbeatEvent;
|
|
177
|
-
}
|
|
178
|
-
},
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
function closablePendingStream(firstEvent, { closeError = null } = {}) {
|
|
183
|
-
let delivered = false;
|
|
184
|
-
let returnCalls = 0;
|
|
185
|
-
const iterator = {
|
|
186
|
-
next() {
|
|
187
|
-
if (!delivered) {
|
|
188
|
-
delivered = true;
|
|
189
|
-
return Promise.resolve({ done: false, value: firstEvent });
|
|
190
|
-
}
|
|
191
|
-
return new Promise(() => {});
|
|
192
|
-
},
|
|
193
|
-
return() {
|
|
194
|
-
returnCalls += 1;
|
|
195
|
-
if (closeError) return Promise.reject(closeError);
|
|
196
|
-
return Promise.resolve({ done: true });
|
|
197
|
-
},
|
|
198
|
-
};
|
|
199
|
-
return {
|
|
200
|
-
stream: { [Symbol.asyncIterator]: () => iterator },
|
|
201
|
-
returnCalls: () => returnCalls,
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
async function assertCompatIteratorCloses({ kind, mode }) {
|
|
206
|
-
const firstEvent = kind === 'chat'
|
|
207
|
-
? { choices: [{ delta: { role: 'assistant' } }] }
|
|
208
|
-
: { type: 'response.created', response: { id: 'r1', model: 'gpt' } };
|
|
209
|
-
const closeError = new Error(`${kind}-${mode} close failure`);
|
|
210
|
-
const pending = closablePendingStream(firstEvent, { closeError });
|
|
211
|
-
const controller = new AbortController();
|
|
212
|
-
const originalAbort = new Error(`${kind} original abort`);
|
|
213
|
-
const options = {
|
|
214
|
-
label: `${kind}-${mode}`,
|
|
215
|
-
signal: controller.signal,
|
|
216
|
-
semanticIdleTimeoutMs: 25,
|
|
217
|
-
...(kind === 'responses'
|
|
218
|
-
? { parseResponsesToolCalls: () => undefined, responseOutputText: () => '' }
|
|
219
|
-
: {}),
|
|
220
|
-
};
|
|
221
|
-
const consume = kind === 'chat'
|
|
222
|
-
? consumeCompatChatCompletionStream
|
|
223
|
-
: consumeCompatResponsesStream;
|
|
224
|
-
const keepAlive = setInterval(() => {}, 10);
|
|
225
|
-
try {
|
|
226
|
-
const run = consume(pending.stream, options);
|
|
227
|
-
await new Promise((resolve) => setImmediate(resolve));
|
|
228
|
-
if (mode === 'abort') controller.abort(originalAbort);
|
|
229
|
-
if (mode === 'abort') {
|
|
230
|
-
await assert.rejects(run, (err) => err === originalAbort);
|
|
231
|
-
} else {
|
|
232
|
-
await assert.rejects(run, (err) => err?.name === 'StreamStalledError');
|
|
233
|
-
}
|
|
234
|
-
assert.equal(pending.returnCalls(), 1, `${kind} ${mode} must close iterator once`);
|
|
235
|
-
} finally {
|
|
236
|
-
clearInterval(keepAlive);
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
test('compat Chat/Responses watchdog and abort rejection close iterators without masking errors', async () => {
|
|
241
|
-
for (const kind of ['chat', 'responses']) {
|
|
242
|
-
for (const mode of ['abort', 'watchdog']) {
|
|
243
|
-
await assertCompatIteratorCloses({ kind, mode });
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
test('recovered Chat tool persists eager-dispatch safety across a later stream failure', async () => {
|
|
249
|
-
const original = new Error('compat stream failed after leaked tool dispatch');
|
|
250
|
-
let step = 0;
|
|
251
|
-
const stream = {
|
|
252
|
-
[Symbol.asyncIterator]() {
|
|
253
|
-
return {
|
|
254
|
-
next() {
|
|
255
|
-
step += 1;
|
|
256
|
-
if (step === 1) {
|
|
257
|
-
return Promise.resolve({
|
|
258
|
-
done: false,
|
|
259
|
-
value: { choices: [{ delta: { content: '<invoke name="read"><parameter name="path">a.txt</parameter></invoke>' } }] },
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
return Promise.reject(original);
|
|
263
|
-
},
|
|
264
|
-
};
|
|
265
|
-
},
|
|
266
|
-
};
|
|
267
|
-
const calls = [];
|
|
268
|
-
const rejected = await consumeCompatChatCompletionStream(stream, {
|
|
269
|
-
label: 'leaked-tool-failure',
|
|
270
|
-
knownToolNames: new Set(['read']),
|
|
271
|
-
onToolCall: (call) => calls.push(call),
|
|
272
|
-
parseToolCalls: () => undefined,
|
|
273
|
-
}).then(() => null, (err) => err);
|
|
274
|
-
assert.equal(rejected, original);
|
|
275
|
-
assert.equal(calls.length, 1);
|
|
276
|
-
assert.equal(calls[0].name, 'read');
|
|
277
|
-
assert.equal(rejected.emittedToolCall, true);
|
|
278
|
-
assert.equal(rejected.unsafeToRetry, true);
|
|
279
|
-
assert.equal(shouldFallbackTransport(rejected, { enabled: true }), false);
|
|
280
|
-
|
|
281
|
-
const truncatedCalls = [];
|
|
282
|
-
const truncated = await consumeCompatChatCompletionStream(asyncEvents([
|
|
283
|
-
{ choices: [{ delta: { content: '<invoke name="read"><parameter name="path">b.txt</parameter></invoke>' } }] },
|
|
284
|
-
]), {
|
|
285
|
-
label: 'leaked-tool-truncation',
|
|
286
|
-
knownToolNames: new Set(['read']),
|
|
287
|
-
onToolCall: (call) => truncatedCalls.push(call),
|
|
288
|
-
parseToolCalls: () => undefined,
|
|
289
|
-
}).then(() => null, (err) => err);
|
|
290
|
-
assert.equal(truncatedCalls.length, 1);
|
|
291
|
-
assert.equal(truncated.emittedToolCall, true);
|
|
292
|
-
assert.equal(truncated.unsafeToRetry, true);
|
|
293
|
-
});
|
|
294
|
-
|
|
295
|
-
test('compat Chat/Responses metadata heartbeats stay transport-only and cannot rearm semantic idle', async () => {
|
|
296
|
-
const chatKinds = [];
|
|
297
|
-
await assert.rejects(
|
|
298
|
-
consumeCompatChatCompletionStream(
|
|
299
|
-
heartbeatOnlyStream(
|
|
300
|
-
{ choices: [{ delta: { role: 'assistant' } }] },
|
|
301
|
-
{ id: 'meta', model: 'gpt', choices: [] },
|
|
302
|
-
),
|
|
303
|
-
{
|
|
304
|
-
label: 'chat-heartbeat',
|
|
305
|
-
semanticIdleTimeoutMs: 45,
|
|
306
|
-
onStreamDelta: (kind) => chatKinds.push(kind),
|
|
307
|
-
},
|
|
308
|
-
),
|
|
309
|
-
(err) => err?.name === 'StreamStalledError',
|
|
310
|
-
);
|
|
311
|
-
assert.deepEqual(chatKinds.filter((kind) => kind !== 'transport'), ['semantic']);
|
|
312
|
-
const chatSemanticIndex = chatKinds.indexOf('semantic');
|
|
313
|
-
assert.ok(chatSemanticIndex >= 0);
|
|
314
|
-
assert.ok(chatKinds.slice(chatSemanticIndex + 1).every((kind) => kind === 'transport'));
|
|
315
|
-
|
|
316
|
-
const responseKinds = [];
|
|
317
|
-
await assert.rejects(
|
|
318
|
-
consumeCompatResponsesStream(
|
|
319
|
-
heartbeatOnlyStream(
|
|
320
|
-
{ type: 'response.created', response: { id: 'r1', model: 'gpt' } },
|
|
321
|
-
{ type: 'response.in_progress', response: { id: 'r1' } },
|
|
322
|
-
),
|
|
323
|
-
{
|
|
324
|
-
label: 'responses-heartbeat',
|
|
325
|
-
semanticIdleTimeoutMs: 45,
|
|
326
|
-
onStreamDelta: (kind) => responseKinds.push(kind),
|
|
327
|
-
parseResponsesToolCalls: () => undefined,
|
|
328
|
-
responseOutputText: () => '',
|
|
329
|
-
},
|
|
330
|
-
),
|
|
331
|
-
(err) => err?.name === 'StreamStalledError',
|
|
332
|
-
);
|
|
333
|
-
assert.deepEqual(responseKinds.filter((kind) => kind !== 'transport'), ['semantic']);
|
|
334
|
-
const responseSemanticIndex = responseKinds.indexOf('semantic');
|
|
335
|
-
assert.ok(responseSemanticIndex >= 0);
|
|
336
|
-
assert.ok(responseKinds.slice(responseSemanticIndex + 1).every((kind) => kind === 'transport'));
|
|
337
|
-
});
|
|
338
|
-
|
|
339
|
-
test('OpenAI compat chat and Responses classify semantic progress without exposing reasoning', async () => {
|
|
340
|
-
const chatKinds = [];
|
|
341
|
-
const chat = await consumeCompatChatCompletionStream(asyncEvents([
|
|
342
|
-
{ choices: [{ delta: { reasoning_content: 'secret' } }] },
|
|
343
|
-
{ choices: [{ delta: { content: 'hello' } }] },
|
|
344
|
-
{ choices: [{ delta: { tool_calls: [{ index: 0, id: 'call_1', function: { name: 'read', arguments: '{}' } }] }, finish_reason: 'tool_calls' }] },
|
|
345
|
-
]), {
|
|
346
|
-
label: 'test',
|
|
347
|
-
onStreamDelta: (kind) => chatKinds.push(kind),
|
|
348
|
-
parseToolCalls: () => [{ id: 'call_1', name: 'read', arguments: {} }],
|
|
349
|
-
});
|
|
350
|
-
assert.ok(chatKinds.includes('transport'));
|
|
351
|
-
assert.ok(chatKinds.includes('reasoning'));
|
|
352
|
-
assert.ok(chatKinds.includes('text'));
|
|
353
|
-
assert.ok(chatKinds.includes('tool'));
|
|
354
|
-
assert.equal(chat.content, 'hello');
|
|
355
|
-
assert.equal(chat.reasoningContent, 'secret');
|
|
356
|
-
|
|
357
|
-
const responseKinds = [];
|
|
358
|
-
await consumeCompatResponsesStream(asyncEvents([
|
|
359
|
-
{ type: 'response.created', response: { id: 'r1', model: 'gpt' } },
|
|
360
|
-
{ type: 'response.reasoning_text.delta', delta: 'secret' },
|
|
361
|
-
{ type: 'response.output_text.delta', delta: 'done' },
|
|
362
|
-
{ type: 'response.completed', response: { id: 'r1', model: 'gpt', output: [] } },
|
|
363
|
-
]), {
|
|
364
|
-
label: 'test',
|
|
365
|
-
onStreamDelta: (kind) => responseKinds.push(kind),
|
|
366
|
-
parseResponsesToolCalls: () => undefined,
|
|
367
|
-
responseOutputText: () => '',
|
|
368
|
-
});
|
|
369
|
-
assert.deepEqual(new Set(responseKinds), new Set(['transport', 'semantic', 'reasoning', 'text']));
|
|
370
|
-
});
|
|
371
|
-
|
|
372
|
-
const encoder = new TextEncoder();
|
|
373
|
-
function anthropicResponse(events) {
|
|
374
|
-
const chunks = events.map((event) => encoder.encode(
|
|
375
|
-
`event: ${event.type}\ndata: ${JSON.stringify(event)}\n\n`,
|
|
376
|
-
));
|
|
377
|
-
let index = 0;
|
|
378
|
-
return { body: { getReader: () => ({
|
|
379
|
-
read: async () => index < chunks.length
|
|
380
|
-
? { done: false, value: chunks[index++] }
|
|
381
|
-
: { done: true },
|
|
382
|
-
cancel: async () => {},
|
|
383
|
-
releaseLock: () => {},
|
|
384
|
-
}) } };
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
test('Anthropic classifies message_start, reasoning, text, and tool protocol with transport separate', async () => {
|
|
388
|
-
const kinds = [];
|
|
389
|
-
await parseSSEStream(anthropicResponse([
|
|
390
|
-
{ type: 'message_start', message: { model: 'claude', usage: {} } },
|
|
391
|
-
{ type: 'content_block_start', index: 0, content_block: { type: 'thinking' } },
|
|
392
|
-
{ type: 'content_block_delta', index: 0, delta: { type: 'thinking_delta', thinking: 'secret' } },
|
|
393
|
-
{ type: 'content_block_start', index: 1, content_block: { type: 'text' } },
|
|
394
|
-
{ type: 'content_block_delta', index: 1, delta: { type: 'text_delta', text: 'hello' } },
|
|
395
|
-
{ type: 'content_block_start', index: 2, content_block: { type: 'tool_use', id: 't1', name: 'read' } },
|
|
396
|
-
{ type: 'content_block_delta', index: 2, delta: { type: 'input_json_delta', partial_json: '{}' } },
|
|
397
|
-
{ type: 'content_block_stop', index: 2 },
|
|
398
|
-
{ type: 'message_delta', delta: { stop_reason: 'tool_use' }, usage: {} },
|
|
399
|
-
]), null, () => {}, (kind) => kinds.push(kind), () => {}, {}, null);
|
|
400
|
-
assert.ok(kinds.includes('transport'));
|
|
401
|
-
assert.ok(kinds.includes('semantic'));
|
|
402
|
-
assert.ok(kinds.includes('reasoning'));
|
|
403
|
-
assert.ok(kinds.includes('text'));
|
|
404
|
-
assert.ok(kinds.includes('tool'));
|
|
405
|
-
});
|
|
406
|
-
|
|
407
|
-
test('Anthropic redacted_thinking is private reasoning and never visible text', async () => {
|
|
408
|
-
const kinds = [];
|
|
409
|
-
const visible = [];
|
|
410
|
-
const result = await parseSSEStream(anthropicResponse([
|
|
411
|
-
{ type: 'message_start', message: { model: 'claude', usage: {} } },
|
|
412
|
-
{ type: 'content_block_start', index: 0, content_block: { type: 'redacted_thinking', data: 'opaque-secret' } },
|
|
413
|
-
{ type: 'content_block_stop', index: 0 },
|
|
414
|
-
{ type: 'message_delta', delta: { stop_reason: 'end_turn' }, usage: {} },
|
|
415
|
-
{ type: 'message_stop' },
|
|
416
|
-
]), null, () => {}, (kind) => kinds.push(kind), () => {}, {}, (text) => visible.push(text));
|
|
417
|
-
assert.ok(kinds.includes('reasoning'));
|
|
418
|
-
assert.equal(kinds.includes('text'), false);
|
|
419
|
-
assert.deepEqual(visible, []);
|
|
420
|
-
assert.equal(result.content, '');
|
|
421
|
-
assert.deepEqual(result.thinkingBlocks, [{ type: 'redacted_thinking', data: 'opaque-secret' }]);
|
|
422
|
-
});
|
|
423
|
-
|
|
424
|
-
class FakeSocket extends EventEmitter {
|
|
425
|
-
constructor() { super(); this.readyState = 1; }
|
|
426
|
-
close() {}
|
|
427
|
-
ping() {}
|
|
428
|
-
feed(events) { for (const event of events) this.emit('message', JSON.stringify(event)); }
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
function openAiHttpResponse(events) {
|
|
432
|
-
const chunks = events.map((event) => encoder.encode(
|
|
433
|
-
`event: ${event.type}\ndata: ${JSON.stringify(event)}\n\n`,
|
|
434
|
-
));
|
|
435
|
-
let index = 0;
|
|
436
|
-
return {
|
|
437
|
-
ok: true,
|
|
438
|
-
status: 200,
|
|
439
|
-
headers: new Map(),
|
|
440
|
-
body: { getReader: () => ({
|
|
441
|
-
read: async () => index < chunks.length
|
|
442
|
-
? { done: false, value: chunks[index++] }
|
|
443
|
-
: { done: true },
|
|
444
|
-
cancel: async () => {},
|
|
445
|
-
releaseLock: () => {},
|
|
446
|
-
}) },
|
|
447
|
-
};
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
test('OAuth HTTP retries refresh requesting-stage liveness for every attempt', async (t) => {
|
|
451
|
-
const id = `liveness-oauth-http-retries-${Date.now()}`;
|
|
452
|
-
t.after(() => _clearSessionRuntime(id));
|
|
453
|
-
markSessionAskStart(id);
|
|
454
|
-
const entry = _getRuntimeEntry(id);
|
|
455
|
-
const stages = [];
|
|
456
|
-
const scheduler = new ProviderAdmissionScheduler({ concurrency: 1 });
|
|
457
|
-
let fetchCalls = 0;
|
|
458
|
-
|
|
459
|
-
const provider = wrapProviderAdmission({
|
|
460
|
-
async send(_messages, _model, _tools, opts) {
|
|
461
|
-
return sendViaHttpSse({
|
|
462
|
-
auth: { type: 'openai-direct', apiKey: 'test' },
|
|
463
|
-
body: {},
|
|
464
|
-
opts: {},
|
|
465
|
-
useModel: 'gpt',
|
|
466
|
-
onStageChange: opts?.onStageChange,
|
|
467
|
-
fetchFn: async () => {
|
|
468
|
-
fetchCalls += 1;
|
|
469
|
-
if (fetchCalls <= 4) throw new Error('transient request failure');
|
|
470
|
-
return openAiHttpResponse([
|
|
471
|
-
{ type: 'response.completed', response: { id: 'r1', model: 'gpt', status: 'completed', output: [] } },
|
|
472
|
-
]);
|
|
473
|
-
},
|
|
474
|
-
_sleepFn: async () => {},
|
|
475
|
-
});
|
|
476
|
-
},
|
|
477
|
-
}, 'liveness-oauth-http-retries', scheduler);
|
|
478
|
-
await provider.send([], 'gpt', [], {
|
|
479
|
-
onStageChange: (stage, detail) => {
|
|
480
|
-
// Set a known stale value before the real ask-session liveness
|
|
481
|
-
// update. The post-send assertion therefore fails if this callback
|
|
482
|
-
// no longer refreshes lastProgressAt.
|
|
483
|
-
entry.lastProgressAt = 1;
|
|
484
|
-
updateSessionStage(id, stage);
|
|
485
|
-
stages.push({ stage, detail, lastProgressAt: entry.lastProgressAt });
|
|
486
|
-
},
|
|
487
|
-
});
|
|
488
|
-
|
|
489
|
-
assert.equal(fetchCalls, 5);
|
|
490
|
-
// Admission emits the first requesting signal, followed by one from each
|
|
491
|
-
// HTTP attempt. Keep the total explicit so stage-only consumers cannot
|
|
492
|
-
// silently dedupe the retry heartbeats.
|
|
493
|
-
const requestingStages = stages.filter(({ stage }) => stage === 'requesting');
|
|
494
|
-
assert.equal(stages.length, 7);
|
|
495
|
-
assert.deepEqual(requestingStages.map(({ stage }) => stage), Array(6).fill('requesting'));
|
|
496
|
-
assert.ok(requestingStages.every(({ lastProgressAt }) => lastProgressAt > 1));
|
|
497
|
-
assert.equal(requestingStages[0].detail, undefined);
|
|
498
|
-
assert.deepEqual(requestingStages.slice(1).map(({ detail }) => detail), [
|
|
499
|
-
{ attempt: 1, maxAttempts: 5, retry: false },
|
|
500
|
-
{ attempt: 2, maxAttempts: 5, retry: true },
|
|
501
|
-
{ attempt: 3, maxAttempts: 5, retry: true },
|
|
502
|
-
{ attempt: 4, maxAttempts: 5, retry: true },
|
|
503
|
-
{ attempt: 5, maxAttempts: 5, retry: true },
|
|
504
|
-
]);
|
|
505
|
-
});
|
|
506
|
-
|
|
507
|
-
function wedgedOpenAiHttpResponse() {
|
|
508
|
-
return {
|
|
509
|
-
ok: true,
|
|
510
|
-
status: 200,
|
|
511
|
-
headers: new Map(),
|
|
512
|
-
body: { getReader: () => ({
|
|
513
|
-
read: () => new Promise(() => {}),
|
|
514
|
-
// Deliberately never settles: sendViaHttpSse must reject its own
|
|
515
|
-
// pending read race rather than trusting cancel().
|
|
516
|
-
cancel: () => new Promise(() => {}),
|
|
517
|
-
releaseLock: () => {},
|
|
518
|
-
}) },
|
|
519
|
-
};
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
function firstEventThenWedgedOpenAiHttpResponse() {
|
|
523
|
-
const first = encoder.encode(
|
|
524
|
-
`event: response.created\ndata: ${JSON.stringify({
|
|
525
|
-
type: 'response.created',
|
|
526
|
-
response: { id: 'r1', model: 'gpt' },
|
|
527
|
-
})}\n\n`,
|
|
528
|
-
);
|
|
529
|
-
let emitted = false;
|
|
530
|
-
return {
|
|
531
|
-
ok: true,
|
|
532
|
-
status: 200,
|
|
533
|
-
headers: new Map(),
|
|
534
|
-
body: { getReader: () => ({
|
|
535
|
-
read: () => {
|
|
536
|
-
if (!emitted) {
|
|
537
|
-
emitted = true;
|
|
538
|
-
return Promise.resolve({ done: false, value: first });
|
|
539
|
-
}
|
|
540
|
-
return new Promise(() => {});
|
|
541
|
-
},
|
|
542
|
-
cancel: () => new Promise(() => {}),
|
|
543
|
-
releaseLock: () => {},
|
|
544
|
-
}) },
|
|
545
|
-
};
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
test('OAuth HTTP SSE actively rejects a wedged reader on external and semantic aborts', async () => {
|
|
549
|
-
const keepAlive = setInterval(() => {}, 10);
|
|
550
|
-
try {
|
|
551
|
-
const startedAt = Date.now();
|
|
552
|
-
const external = new AbortController();
|
|
553
|
-
const externalReason = new Error('reviewer external abort');
|
|
554
|
-
const externalRun = sendViaHttpSse({
|
|
555
|
-
auth: { type: 'openai-direct', apiKey: 'test' },
|
|
556
|
-
body: {},
|
|
557
|
-
opts: {},
|
|
558
|
-
externalSignal: external.signal,
|
|
559
|
-
useModel: 'gpt',
|
|
560
|
-
fetchFn: async () => firstEventThenWedgedOpenAiHttpResponse(),
|
|
561
|
-
});
|
|
562
|
-
setTimeout(() => external.abort(externalReason), 10);
|
|
563
|
-
await assert.rejects(externalRun, (err) => err === externalReason);
|
|
564
|
-
|
|
565
|
-
const semanticRun = sendViaHttpSse({
|
|
566
|
-
auth: { type: 'openai-direct', apiKey: 'test' },
|
|
567
|
-
body: {},
|
|
568
|
-
opts: { _semanticIdleTimeoutMs: 25 },
|
|
569
|
-
useModel: 'gpt',
|
|
570
|
-
fetchFn: async () => firstEventThenWedgedOpenAiHttpResponse(),
|
|
571
|
-
});
|
|
572
|
-
await assert.rejects(semanticRun, (err) => (
|
|
573
|
-
err?.name === 'StreamStalledError'
|
|
574
|
-
&& err?.streamStalled === true
|
|
575
|
-
));
|
|
576
|
-
assert.ok(Date.now() - startedAt < 1_000, 'wedged reads must reject near their abort deadlines');
|
|
577
|
-
} finally {
|
|
578
|
-
clearInterval(keepAlive);
|
|
579
|
-
}
|
|
580
|
-
});
|
|
581
|
-
|
|
582
|
-
test('OAuth HTTP SSE enforces first server event independently of response headers', async () => {
|
|
583
|
-
const keepAlive = setInterval(() => {}, 10);
|
|
584
|
-
try {
|
|
585
|
-
const startedAt = Date.now();
|
|
586
|
-
await assert.rejects(sendViaHttpSse({
|
|
587
|
-
auth: { type: 'openai-direct', apiKey: 'test' },
|
|
588
|
-
body: {},
|
|
589
|
-
opts: { _firstServerEventTimeoutMs: 40, _semanticIdleTimeoutMs: 5 },
|
|
590
|
-
useModel: 'gpt',
|
|
591
|
-
fetchFn: async () => wedgedOpenAiHttpResponse(),
|
|
592
|
-
}), (err) => err?.code === 'EPROVIDERTIMEOUT' && err?.firstByteTimeout === true);
|
|
593
|
-
assert.ok(Date.now() - startedAt >= 30, 'semantic idle must not shorten the first-event deadline');
|
|
594
|
-
} finally {
|
|
595
|
-
clearInterval(keepAlive);
|
|
596
|
-
}
|
|
597
|
-
});
|
|
598
|
-
|
|
599
|
-
test('completion bundles report actual reasoning/text/tool kinds across compat, WS, and OAuth SSE', async () => {
|
|
600
|
-
const output = [
|
|
601
|
-
{ type: 'reasoning', id: 'rs_1', encrypted_content: 'opaque', summary: [] },
|
|
602
|
-
{ type: 'message', content: [{ type: 'output_text', text: 'final' }] },
|
|
603
|
-
{ type: 'function_call', id: 'fc_1', call_id: 'call_1', name: 'read', arguments: '{}' },
|
|
604
|
-
];
|
|
605
|
-
|
|
606
|
-
const compatKinds = [];
|
|
607
|
-
await consumeCompatResponsesStream(asyncEvents([
|
|
608
|
-
{ type: 'response.created', response: { id: 'r1', model: 'gpt' } },
|
|
609
|
-
{ type: 'response.completed', response: { id: 'r1', model: 'gpt', status: 'completed', output } },
|
|
610
|
-
]), {
|
|
611
|
-
label: 'bundle-compat',
|
|
612
|
-
onStreamDelta: (kind) => compatKinds.push(kind),
|
|
613
|
-
parseResponsesToolCalls: () => undefined,
|
|
614
|
-
responseOutputText: () => 'final',
|
|
615
|
-
});
|
|
616
|
-
for (const kind of ['reasoning', 'text', 'tool']) assert.ok(compatKinds.includes(kind), `compat missing ${kind}`);
|
|
617
|
-
|
|
618
|
-
const wsKinds = [];
|
|
619
|
-
const socket = new FakeSocket();
|
|
620
|
-
const wsRun = _streamResponse({
|
|
621
|
-
entry: { socket },
|
|
622
|
-
state: {},
|
|
623
|
-
onStreamDelta: (kind) => wsKinds.push(kind),
|
|
624
|
-
_timeouts: { interChunkMs: 5_000, preResponseCreatedMs: 5_000, firstMeaningfulMs: 5_000 },
|
|
625
|
-
});
|
|
626
|
-
socket.feed([
|
|
627
|
-
{ type: 'response.created', response: { id: 'r1', model: 'gpt' } },
|
|
628
|
-
{ type: 'response.completed', response: { id: 'r1', model: 'gpt', output } },
|
|
629
|
-
]);
|
|
630
|
-
await wsRun;
|
|
631
|
-
for (const kind of ['reasoning', 'text', 'tool']) assert.ok(wsKinds.includes(kind), `ws missing ${kind}`);
|
|
632
|
-
|
|
633
|
-
const oauthKinds = [];
|
|
634
|
-
await sendViaHttpSse({
|
|
635
|
-
auth: { type: 'openai-direct', apiKey: 'test' },
|
|
636
|
-
body: {},
|
|
637
|
-
opts: {},
|
|
638
|
-
useModel: 'gpt',
|
|
639
|
-
onStreamDelta: (kind) => oauthKinds.push(kind),
|
|
640
|
-
fetchFn: async () => openAiHttpResponse([
|
|
641
|
-
{ type: 'response.created', response: { id: 'r1', model: 'gpt' } },
|
|
642
|
-
{ type: 'response.completed', response: { id: 'r1', model: 'gpt', status: 'completed', output } },
|
|
643
|
-
]),
|
|
644
|
-
});
|
|
645
|
-
for (const kind of ['reasoning', 'text', 'tool']) assert.ok(oauthKinds.includes(kind), `oauth missing ${kind}`);
|
|
646
|
-
});
|
|
647
|
-
|
|
648
|
-
const PURE_LEAK = '<invoke name="read"><parameter name="path">a.txt</parameter></invoke>';
|
|
649
|
-
|
|
650
|
-
test('synthesized leaked tools report tool progress without visible-text progress', async () => {
|
|
651
|
-
const compatKinds = [];
|
|
652
|
-
const compatVisible = [];
|
|
653
|
-
await consumeCompatChatCompletionStream(asyncEvents([
|
|
654
|
-
{ choices: [{ delta: { content: PURE_LEAK } }] },
|
|
655
|
-
{ choices: [{ delta: {}, finish_reason: 'stop' }] },
|
|
656
|
-
]), {
|
|
657
|
-
label: 'leak-compat',
|
|
658
|
-
knownToolNames: new Set(['read']),
|
|
659
|
-
onStreamDelta: (kind) => compatKinds.push(kind),
|
|
660
|
-
onTextDelta: (text) => compatVisible.push(text),
|
|
661
|
-
parseToolCalls: () => undefined,
|
|
662
|
-
});
|
|
663
|
-
assert.ok(compatKinds.includes('tool'));
|
|
664
|
-
assert.equal(compatKinds.includes('text'), false);
|
|
665
|
-
assert.deepEqual(compatVisible, []);
|
|
666
|
-
|
|
667
|
-
const compatResponseKinds = [];
|
|
668
|
-
const compatResponseVisible = [];
|
|
669
|
-
await consumeCompatResponsesStream(asyncEvents([
|
|
670
|
-
{ type: 'response.created', response: { id: 'r1', model: 'gpt' } },
|
|
671
|
-
{ type: 'response.output_text.delta', delta: PURE_LEAK },
|
|
672
|
-
{ type: 'response.completed', response: { id: 'r1', model: 'gpt', status: 'completed', output: [] } },
|
|
673
|
-
]), {
|
|
674
|
-
label: 'leak-compat-responses',
|
|
675
|
-
knownToolNames: new Set(['read']),
|
|
676
|
-
onStreamDelta: (kind) => compatResponseKinds.push(kind),
|
|
677
|
-
onTextDelta: (text) => compatResponseVisible.push(text),
|
|
678
|
-
parseResponsesToolCalls: () => undefined,
|
|
679
|
-
responseOutputText: () => '',
|
|
680
|
-
});
|
|
681
|
-
assert.ok(compatResponseKinds.includes('tool'));
|
|
682
|
-
assert.equal(compatResponseKinds.includes('text'), false);
|
|
683
|
-
assert.deepEqual(compatResponseVisible, []);
|
|
684
|
-
|
|
685
|
-
const anthropicKinds = [];
|
|
686
|
-
const anthropicVisible = [];
|
|
687
|
-
await parseSSEStream(anthropicResponse([
|
|
688
|
-
{ type: 'message_start', message: { model: 'claude', usage: {} } },
|
|
689
|
-
{ type: 'content_block_start', index: 0, content_block: { type: 'text' } },
|
|
690
|
-
{ type: 'content_block_delta', index: 0, delta: { type: 'text_delta', text: PURE_LEAK } },
|
|
691
|
-
{ type: 'content_block_stop', index: 0 },
|
|
692
|
-
{ type: 'message_delta', delta: { stop_reason: 'end_turn' }, usage: {} },
|
|
693
|
-
{ type: 'message_stop' },
|
|
694
|
-
]), null, () => {}, (kind) => anthropicKinds.push(kind), () => {}, {}, (text) => anthropicVisible.push(text), new Set(['read']));
|
|
695
|
-
assert.ok(anthropicKinds.includes('tool'));
|
|
696
|
-
assert.equal(anthropicKinds.includes('text'), false);
|
|
697
|
-
assert.deepEqual(anthropicVisible, []);
|
|
698
|
-
|
|
699
|
-
const wsKinds = [];
|
|
700
|
-
const wsVisible = [];
|
|
701
|
-
const socket = new FakeSocket();
|
|
702
|
-
const wsRun = _streamResponse({
|
|
703
|
-
entry: { socket },
|
|
704
|
-
state: {},
|
|
705
|
-
knownToolNames: new Set(['read']),
|
|
706
|
-
onStreamDelta: (kind) => wsKinds.push(kind),
|
|
707
|
-
onTextDelta: (text) => wsVisible.push(text),
|
|
708
|
-
_timeouts: { interChunkMs: 5_000, preResponseCreatedMs: 5_000, firstMeaningfulMs: 5_000 },
|
|
709
|
-
});
|
|
710
|
-
socket.feed([
|
|
711
|
-
{ type: 'response.created', response: { id: 'r1', model: 'gpt' } },
|
|
712
|
-
{ type: 'response.output_text.delta', delta: PURE_LEAK },
|
|
713
|
-
{ type: 'response.completed', response: { id: 'r1', model: 'gpt', output: [] } },
|
|
714
|
-
]);
|
|
715
|
-
await wsRun;
|
|
716
|
-
assert.ok(wsKinds.includes('tool'));
|
|
717
|
-
assert.equal(wsKinds.includes('text'), false);
|
|
718
|
-
assert.deepEqual(wsVisible, []);
|
|
719
|
-
|
|
720
|
-
const oauthKinds = [];
|
|
721
|
-
const oauthVisible = [];
|
|
722
|
-
await sendViaHttpSse({
|
|
723
|
-
auth: { type: 'openai-direct', apiKey: 'test' },
|
|
724
|
-
body: { tools: [{ name: 'read' }] },
|
|
725
|
-
opts: {},
|
|
726
|
-
useModel: 'gpt',
|
|
727
|
-
onStreamDelta: (kind) => oauthKinds.push(kind),
|
|
728
|
-
onTextDelta: (text) => oauthVisible.push(text),
|
|
729
|
-
fetchFn: async () => openAiHttpResponse([
|
|
730
|
-
{ type: 'response.created', response: { id: 'r1', model: 'gpt' } },
|
|
731
|
-
{ type: 'response.output_text.delta', delta: PURE_LEAK },
|
|
732
|
-
{ type: 'response.completed', response: { id: 'r1', model: 'gpt', status: 'completed', output: [] } },
|
|
733
|
-
]),
|
|
734
|
-
});
|
|
735
|
-
assert.ok(oauthKinds.includes('tool'));
|
|
736
|
-
assert.equal(oauthKinds.includes('text'), false);
|
|
737
|
-
assert.deepEqual(oauthVisible, []);
|
|
738
|
-
});
|
|
739
|
-
|
|
740
|
-
test('OpenAI WS reports transport plus semantic/reasoning/text classifications', async () => {
|
|
741
|
-
const id = `liveness-ws-${Date.now()}`;
|
|
742
|
-
const kinds = [];
|
|
743
|
-
const socket = new FakeSocket();
|
|
744
|
-
markSessionAskStart(id);
|
|
745
|
-
const p = _streamResponse({
|
|
746
|
-
entry: { socket },
|
|
747
|
-
state: { sessionId: id },
|
|
748
|
-
onStreamDelta: (kind) => kinds.push(kind),
|
|
749
|
-
_timeouts: { interChunkMs: 5_000, preResponseCreatedMs: 5_000, firstMeaningfulMs: 5_000 },
|
|
750
|
-
});
|
|
751
|
-
socket.feed([
|
|
752
|
-
{ type: 'response.created', response: { id: 'r1', model: 'gpt' } },
|
|
753
|
-
{ type: 'response.reasoning_text.delta', delta: 'secret' },
|
|
754
|
-
{ type: 'response.output_text.delta', delta: 'hello' },
|
|
755
|
-
{ type: 'response.completed', response: { id: 'r1', model: 'gpt', output: [] } },
|
|
756
|
-
]);
|
|
757
|
-
await p;
|
|
758
|
-
assert.ok(_getRuntimeEntry(id)?.lastTransportAt);
|
|
759
|
-
assert.ok(kinds.includes('semantic'));
|
|
760
|
-
assert.ok(kinds.includes('reasoning'));
|
|
761
|
-
assert.ok(kinds.includes('text'));
|
|
762
|
-
_clearSessionRuntime(id);
|
|
763
|
-
});
|