mixdog 1.0.11 → 1.1.0
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/NOTICE.md +20 -0
- package/README.md +75 -181
- package/package.json +9 -4
- package/scripts/build-shipped-history.mjs +131 -0
- package/scripts/check-changelog-locales.mjs +203 -0
- package/scripts/computer-task-cost-report.mjs +0 -4
- package/scripts/lib/run-node-tests.mjs +235 -13
- package/scripts/lib/test-failure-records.mjs +5 -0
- package/scripts/lib/test-failure-summary.mjs +9 -3
- package/scripts/lib/test-spawn-ledger.mjs +19 -0
- package/scripts/prune-embedding-runtime.mjs +9 -5
- package/scripts/sync-client-version-floors.mjs +100 -0
- package/scripts/test-direct.mjs +16 -1
- package/src/agents/advisor/AGENT.md +38 -0
- package/src/agents/advisor/agent.json +6 -0
- package/src/agents/reviewer/AGENT.md +5 -2
- package/src/agents/reviewer/agent.json +1 -1
- package/src/defaults/shipped-history.json +381 -0
- package/src/defaults/skills/docx/SKILL.md +7 -5
- package/src/defaults/skills/docx/references/html.md +9 -8
- package/src/defaults/skills/docx/references/native-authoring.md +28 -18
- package/src/defaults/skills/goal-management/SKILL.md +11 -5
- package/src/defaults/skills/local-provider/SKILL.md +2 -1
- package/src/defaults/skills/pdf/SKILL.md +9 -6
- package/src/defaults/skills/pdf/references/html.md +17 -12
- package/src/defaults/skills/pptx/SKILL.md +8 -6
- package/src/defaults/skills/pptx/references/composition.md +4 -4
- package/src/defaults/skills/pptx/references/concepts.md +168 -0
- package/src/defaults/skills/pptx/references/direction.md +5 -4
- package/src/defaults/skills/pptx/references/html.md +6 -29
- package/src/defaults/skills/pptx/references/kit-index.md +11 -3
- package/src/defaults/skills/pptx/references/kit.md +27 -5
- package/src/defaults/skills/pptx/references/review.md +6 -5
- package/src/defaults/skills/setup/SKILL.md +5 -8
- package/src/defaults/skills/setup/references/actions.md +61 -31
- package/src/defaults/skills/setup/references/surfaces.md +12 -10
- package/src/defaults/skills/xlsx/SKILL.md +8 -6
- package/src/defaults/skills/xlsx/references/html.md +8 -4
- package/src/defaults/skills/xlsx/references/model-conventions.md +2 -0
- package/src/defaults/skills/xlsx/references/report-design.md +32 -16
- package/src/help.mjs +1 -1
- package/src/lib/rules-builder.cjs +1 -1
- package/src/runtime/agent/orchestrator/agent-runtime/cache-strategy.mjs +3 -1
- package/src/runtime/agent/orchestrator/agent-runtime/session-builder.mjs +4 -0
- package/src/runtime/agent/orchestrator/config-presets.d.mts +1 -0
- package/src/runtime/agent/orchestrator/config-presets.mjs +44 -0
- package/src/runtime/agent/orchestrator/config-providers-merge.mjs +9 -1
- package/src/runtime/agent/orchestrator/config.mjs +102 -21
- package/src/runtime/agent/orchestrator/context/deferred-tools.mjs +3 -2
- package/src/runtime/agent/orchestrator/providers/account-pool.mjs +90 -26
- package/src/runtime/agent/orchestrator/providers/anthropic-api-request.mjs +44 -14
- package/src/runtime/agent/orchestrator/providers/anthropic-midstream-recovery.mjs +4 -4
- package/src/runtime/agent/orchestrator/providers/anthropic-oauth-client-version.mjs +5 -3
- package/src/runtime/agent/orchestrator/providers/anthropic-oauth-credentials.mjs +79 -8
- package/src/runtime/agent/orchestrator/providers/anthropic-oauth.mjs +29 -4
- package/src/runtime/agent/orchestrator/providers/anthropic-sse-turn.mjs +3 -0
- package/src/runtime/agent/orchestrator/providers/anthropic-sse.mjs +10 -1
- package/src/runtime/agent/orchestrator/providers/anthropic.mjs +11 -2
- package/src/runtime/agent/orchestrator/providers/antigravity-oauth-login.mjs +9 -5
- package/src/runtime/agent/orchestrator/providers/antigravity-oauth-tokens.mjs +9 -1
- package/src/runtime/agent/orchestrator/providers/antigravity-oauth.mjs +2 -0
- package/src/runtime/agent/orchestrator/providers/antigravity-response.mjs +30 -22
- package/src/runtime/agent/orchestrator/providers/antigravity-stream.mjs +2 -0
- package/src/runtime/agent/orchestrator/providers/auto-effort.mjs +28 -10
- package/src/runtime/agent/orchestrator/providers/codex-client-meta.mjs +14 -72
- package/src/runtime/agent/orchestrator/providers/cursor-auth.mjs +19 -3
- package/src/runtime/agent/orchestrator/providers/cursor-client-version.mjs +20 -10
- package/src/runtime/agent/orchestrator/providers/cursor-wire-stream-sink.mjs +36 -9
- package/src/runtime/agent/orchestrator/providers/cursor.mjs +11 -17
- package/src/runtime/agent/orchestrator/providers/custom-provider-config.mjs +388 -0
- package/src/runtime/agent/orchestrator/providers/custom-provider.mjs +92 -109
- package/src/runtime/agent/orchestrator/providers/custom-reasoning.mjs +107 -0
- package/src/runtime/agent/orchestrator/providers/effort-configuration.mjs +138 -30
- package/src/runtime/agent/orchestrator/providers/gemini-response.mjs +32 -15
- package/src/runtime/agent/orchestrator/providers/gemini-sdk-request.mjs +2 -0
- package/src/runtime/agent/orchestrator/providers/gemini-stream.mjs +39 -5
- package/src/runtime/agent/orchestrator/providers/gemini.mjs +9 -2
- package/src/runtime/agent/orchestrator/providers/grok-client-version.mjs +3 -2
- package/src/runtime/agent/orchestrator/providers/grok-oauth-login.mjs +6 -1
- package/src/runtime/agent/orchestrator/providers/grok-oauth-tokens.mjs +10 -1
- package/src/runtime/agent/orchestrator/providers/grok-oauth.mjs +3 -2
- package/src/runtime/agent/orchestrator/providers/lib/anthropic-request-utils.mjs +5 -1
- package/src/runtime/agent/orchestrator/providers/lib/note-error-usage.mjs +7 -0
- package/src/runtime/agent/orchestrator/providers/lib/oauth-token-utils.mjs +57 -0
- package/src/runtime/agent/orchestrator/providers/model-cache.mjs +12 -5
- package/src/runtime/agent/orchestrator/providers/npm-cli-version.mjs +20 -15
- package/src/runtime/agent/orchestrator/providers/oauth-usage.mjs +14 -9
- package/src/runtime/agent/orchestrator/providers/openai-compat-chat-send.mjs +56 -11
- package/src/runtime/agent/orchestrator/providers/openai-compat-chat-stream/stream-result.mjs +2 -1
- package/src/runtime/agent/orchestrator/providers/openai-compat-chat-stream/stream-state.mjs +28 -1
- package/src/runtime/agent/orchestrator/providers/openai-compat-chat-stream.mjs +27 -3
- package/src/runtime/agent/orchestrator/providers/openai-compat-models.mjs +7 -5
- package/src/runtime/agent/orchestrator/providers/openai-compat-options.mjs +12 -0
- package/src/runtime/agent/orchestrator/providers/openai-compat-response-normalization.mjs +23 -8
- package/src/runtime/agent/orchestrator/providers/openai-compat-responses-events.mjs +26 -6
- package/src/runtime/agent/orchestrator/providers/openai-compat-responses-state.mjs +7 -1
- package/src/runtime/agent/orchestrator/providers/openai-compat-responses.mjs +34 -15
- package/src/runtime/agent/orchestrator/providers/openai-compat-stream.mjs +16 -2
- package/src/runtime/agent/orchestrator/providers/openai-compat-wire.mjs +12 -2
- package/src/runtime/agent/orchestrator/providers/openai-compat-xai-send.mjs +0 -6
- package/src/runtime/agent/orchestrator/providers/openai-compat-xai.mjs +0 -19
- package/src/runtime/agent/orchestrator/providers/openai-compat.mjs +12 -43
- package/src/runtime/agent/orchestrator/providers/openai-direct-request.mjs +6 -0
- package/src/runtime/agent/orchestrator/providers/openai-http-sse-response-state/response-events/terminal-frames.mjs +39 -9
- package/src/runtime/agent/orchestrator/providers/openai-oauth-catalog.mjs +31 -9
- package/src/runtime/agent/orchestrator/providers/openai-oauth-dispatch.mjs +13 -38
- package/src/runtime/agent/orchestrator/providers/openai-oauth-login.mjs +5 -2
- package/src/runtime/agent/orchestrator/providers/openai-oauth-tokens.mjs +40 -9
- package/src/runtime/agent/orchestrator/providers/openai-oauth-ws.mjs +7 -39
- package/src/runtime/agent/orchestrator/providers/openai-oauth.mjs +28 -101
- package/src/runtime/agent/orchestrator/providers/openai-responses-input.mjs +8 -4
- package/src/runtime/agent/orchestrator/providers/openai-responses-payload.mjs +3 -6
- package/src/runtime/agent/orchestrator/providers/openai-service-tier.mjs +19 -0
- package/src/runtime/agent/orchestrator/providers/openai-startup-prewarm.mjs +5 -195
- package/src/runtime/agent/orchestrator/providers/openai-ws-delta.mjs +9 -18
- package/src/runtime/agent/orchestrator/providers/openai-ws-events.mjs +4 -66
- package/src/runtime/agent/orchestrator/providers/openai-ws-response-state.mjs +11 -5
- package/src/runtime/agent/orchestrator/providers/openai-ws-send/acquire-attempt.mjs +3 -15
- package/src/runtime/agent/orchestrator/providers/openai-ws-send/attempt-request.mjs +6 -56
- package/src/runtime/agent/orchestrator/providers/openai-ws-send/send-context.mjs +1 -19
- package/src/runtime/agent/orchestrator/providers/openai-ws-send-attempts/attempt-context.mjs +2 -2
- package/src/runtime/agent/orchestrator/providers/openai-ws-send-attempts/handshake-failure.mjs +2 -1
- package/src/runtime/agent/orchestrator/providers/openai-ws-send-attempts/policy.mjs +3 -0
- package/src/runtime/agent/orchestrator/providers/openai-ws-send-attempts/stream-failure-stamps.mjs +0 -1
- package/src/runtime/agent/orchestrator/providers/openai-ws-send-attempts/stream-failure.mjs +3 -1
- package/src/runtime/agent/orchestrator/providers/openai-ws-send-attempts.mjs +3 -5
- package/src/runtime/agent/orchestrator/providers/openai-ws-send-outcome.mjs +10 -89
- package/src/runtime/agent/orchestrator/providers/openai-ws-send-span.mjs +1 -1
- package/src/runtime/agent/orchestrator/providers/openai-ws-send-trace.mjs +0 -6
- package/src/runtime/agent/orchestrator/providers/openai-ws-stream/terminal-frames.mjs +34 -11
- package/src/runtime/agent/orchestrator/providers/openai-ws-stream.mjs +0 -1
- package/src/runtime/agent/orchestrator/providers/openai-ws-watchdogs.mjs +3 -7
- package/src/runtime/agent/orchestrator/providers/openai-ws.mjs +44 -19
- package/src/runtime/agent/orchestrator/providers/opencode-go.mjs +40 -12
- package/src/runtime/agent/orchestrator/providers/quota-reading.mjs +70 -0
- package/src/runtime/agent/orchestrator/providers/registry.mjs +38 -3
- package/src/runtime/agent/orchestrator/providers/retry-classification.mjs +4 -0
- package/src/runtime/agent/orchestrator/providers/retry-classifier.mjs +1 -0
- package/src/runtime/agent/orchestrator/providers/retry-executor.mjs +2 -0
- package/src/runtime/agent/orchestrator/providers/retry-midstream.mjs +11 -0
- package/src/runtime/agent/orchestrator/runtime-core/builtin-features.mjs +31 -41
- package/src/runtime/agent/orchestrator/runtime-core/effort.mjs +5 -0
- package/src/runtime/agent/orchestrator/runtime-core/goal-mutations.mjs +0 -17
- package/src/runtime/agent/orchestrator/runtime-core/goal-state.mjs +0 -3
- package/src/runtime/agent/orchestrator/runtime-core/goal-store.mjs +0 -1
- package/src/runtime/agent/orchestrator/runtime-core/goal-text.mjs +1 -1
- package/src/runtime/agent/orchestrator/runtime-core/goal-tool-defs.mjs +1 -1
- package/src/runtime/agent/orchestrator/runtime-core/goal-tool-exec.mjs +1 -2
- package/src/runtime/agent/orchestrator/runtime-core/goal-turns.mjs +18 -4
- package/src/runtime/agent/orchestrator/runtime-core/model-capabilities.mjs +8 -1
- package/src/runtime/agent/orchestrator/runtime-core/orchestration.mjs +7 -1
- package/src/runtime/agent/orchestrator/runtime-core/session-route-policy.mjs +16 -0
- package/src/runtime/agent/orchestrator/runtime-core/tool-catalog.mjs +2 -0
- package/src/runtime/agent/orchestrator/runtime-core/tool-defs.mjs +6 -2
- package/src/runtime/agent/orchestrator/runtime-core/workflow/context.mjs +7 -7
- package/src/runtime/agent/orchestrator/runtime-core/workflow.mjs +6 -0
- package/src/runtime/agent/orchestrator/session/compact/observation-supersession.mjs +45 -2
- package/src/runtime/agent/orchestrator/session/compact/runner.mjs +5 -3
- package/src/runtime/agent/orchestrator/session/eager-dispatch/entry.mjs +5 -0
- package/src/runtime/agent/orchestrator/session/loop/compact-policy.mjs +6 -13
- package/src/runtime/agent/orchestrator/session/loop/request-boundary.mjs +6 -2
- package/src/runtime/agent/orchestrator/session/loop/step-auto-effort.mjs +114 -0
- package/src/runtime/agent/orchestrator/session/loop/tool-phase.mjs +2 -0
- package/src/runtime/agent/orchestrator/session/loop/usage.mjs +5 -9
- package/src/runtime/agent/orchestrator/session/manager/ask-turn-auto-effort.mjs +51 -18
- package/src/runtime/agent/orchestrator/session/manager/ask-turn-execute.mjs +7 -4
- package/src/runtime/agent/orchestrator/session/manager/ask-turn-loop-options.mjs +3 -1
- package/src/runtime/agent/orchestrator/session/manager/ask-turn-prepare.mjs +0 -2
- package/src/runtime/agent/orchestrator/session/manager/ask-turn-settle.mjs +6 -9
- package/src/runtime/agent/orchestrator/session/manager/session-lifecycle.mjs +63 -3
- package/src/runtime/agent/orchestrator/session/manager/session-owner-liveness.mjs +10 -28
- package/src/runtime/agent/orchestrator/session/manager/session-tool-surface.mjs +4 -4
- package/src/runtime/agent/orchestrator/session/manager/status-telemetry.mjs +13 -0
- package/src/runtime/agent/orchestrator/session/manager/usage-metrics.mjs +10 -19
- package/src/runtime/agent/orchestrator/session/tool-batch/execute-call.mjs +7 -1
- package/src/runtime/agent/orchestrator/session/tool-result-offload.mjs +1 -0
- package/src/runtime/agent/orchestrator/session/transcript-restore/restore.mjs +1 -3
- package/src/runtime/agent/orchestrator/stall-policy.mjs +0 -1
- package/src/runtime/agent/orchestrator/tools/builtin/atomic-write.mjs +18 -8
- package/src/runtime/agent/orchestrator/tools/builtin/cache-layers.mjs +19 -20
- package/src/runtime/agent/orchestrator/tools/builtin/external-tool-adapters.mjs +6 -11
- package/src/runtime/agent/orchestrator/tools/builtin/file-version-test-helpers.mjs +11 -0
- package/src/runtime/agent/orchestrator/tools/builtin/file-version.mjs +13 -0
- package/src/runtime/agent/orchestrator/tools/builtin/lib/grep-single-file-rescue.mjs +8 -5
- package/src/runtime/agent/orchestrator/tools/builtin/lib/shell-task-output.mjs +25 -12
- package/src/runtime/agent/orchestrator/tools/builtin/raw-content-publication.mjs +17 -0
- package/src/runtime/agent/orchestrator/tools/builtin/read-range-index.mjs +136 -76
- package/src/runtime/agent/orchestrator/tools/builtin/read-single-render.mjs +15 -17
- package/src/runtime/agent/orchestrator/tools/builtin/read-single-tool.mjs +4 -2
- package/src/runtime/agent/orchestrator/tools/builtin/read-snapshot-runtime.mjs +11 -10
- package/src/runtime/agent/orchestrator/tools/builtin/read-source-windows.mjs +5 -3
- package/src/runtime/agent/orchestrator/tools/builtin/read-streaming.mjs +30 -16
- package/src/runtime/agent/orchestrator/tools/builtin/shell-lossless-compact.mjs +2 -2
- package/src/runtime/agent/orchestrator/tools/builtin/snapshot-helpers.mjs +4 -11
- package/src/runtime/agent/orchestrator/tools/builtin/snapshot-store.mjs +7 -3
- package/src/runtime/agent/orchestrator/tools/builtin/snapshot-validation.mjs +16 -19
- package/src/runtime/agent/orchestrator/tools/graph-manifest.json +13 -13
- package/src/runtime/agent/orchestrator/tools/lib/shell-run-background.mjs +4 -1
- package/src/runtime/agent/orchestrator/tools/lib/shell-run-settle.mjs +14 -4
- package/src/runtime/agent/orchestrator/tools/patch/apply-patch/codex-batch.mjs +58 -8
- package/src/runtime/agent/orchestrator/tools/patch/content-guard.mjs +47 -0
- package/src/runtime/agent/orchestrator/tools/patch/delete-quarantine.mjs +155 -0
- package/src/runtime/agent/orchestrator/tools/patch/dispatch/native-proofs.mjs +6 -2
- package/src/runtime/agent/orchestrator/tools/patch/dispatch/native-snapshots.mjs +6 -2
- package/src/runtime/agent/orchestrator/tools/patch/dispatch.mjs +19 -16
- package/src/runtime/agent/orchestrator/tools/patch/matcher.mjs +13 -44
- package/src/runtime/agent/orchestrator/tools/patch/orchestrator.mjs +2 -2
- package/src/runtime/agent/orchestrator/tools/patch/post-patch-excerpts.mjs +5 -2
- package/src/runtime/agent/orchestrator/tools/patch/replay-capture.mjs +47 -7
- package/src/runtime/agent/orchestrator/tools/patch/rollback-state.mjs +72 -8
- package/src/runtime/agent/orchestrator/tools/patch/section-coalesce.mjs +3 -2
- package/src/runtime/agent/orchestrator/tools/patch/sequence/run.mjs +9 -1
- package/src/runtime/agent/orchestrator/tools/patch/sequence/units.mjs +9 -1
- package/src/runtime/agent/orchestrator/tools/patch/sequence.mjs +6 -6
- package/src/runtime/agent/orchestrator/tools/patch/ui-diff.mjs +16 -4
- package/src/runtime/agent/orchestrator/tools/patch/v4a-convert.mjs +35 -14
- package/src/runtime/agent/orchestrator/tools/patch/wave.mjs +42 -4
- package/src/runtime/agent/orchestrator/tools/progress-message.mjs +2 -0
- package/src/runtime/agent/orchestrator/tools/shell-codepage.mjs +296 -0
- package/src/runtime/agent/orchestrator/tools/shell-exec-output.mjs +75 -24
- package/src/runtime/browser-bridge/tool-defs.mjs +1 -0
- package/src/runtime/channels/lib/config.mjs +3 -8
- package/src/runtime/channels/lib/voice-runtime-fetcher.mjs +7 -3
- package/src/{tui → runtime/channels}/lib/voice-setup.mjs +38 -22
- package/src/runtime/channels/lib/webhook/request-handler.mjs +42 -8
- package/src/runtime/computer-bridge/actions.mjs +2 -0
- package/src/runtime/effort-judge/judge-client.mjs +125 -25
- package/src/runtime/effort-judge/judge-input.mjs +96 -0
- package/src/runtime/effort-judge/judge-worker.mjs +52 -20
- package/src/runtime/effort-judge/model-install.mjs +74 -0
- package/src/runtime/effort-judge/model-manifest.json +21 -0
- package/src/runtime/effort-judge/previous-human-request.mjs +162 -0
- package/src/runtime/effort-judge/verified-context-input.mjs +10 -0
- package/src/runtime/github/tool.mjs +214 -14
- package/src/runtime/local-provider/context-settings.mjs +15 -6
- package/src/runtime/local-provider/gguf-header.mjs +13 -5
- package/src/runtime/local-provider/hugging-face.mjs +27 -5
- package/src/runtime/local-provider/install-progress.mjs +7 -0
- package/src/runtime/local-provider/managed-runtime.mjs +2 -1
- package/src/runtime/local-provider/model-maintenance.mjs +15 -6
- package/src/runtime/local-provider/resumable-installations.mjs +40 -1
- package/src/runtime/local-provider/server.mjs +2 -0
- package/src/runtime/memory/lib/embedding-provider.mjs +12 -0
- package/src/runtime/memory/lib/http-router/session-routes.mjs +2 -1
- package/src/runtime/memory/lib/memory-config-flags.mjs +3 -2
- package/src/runtime/memory/lib/memory-embed.mjs +5 -0
- package/src/runtime/memory/lib/pg/process.mjs +57 -5
- package/src/runtime/office/README.md +13 -7
- package/src/runtime/office/authoring/docx-html-build.mjs +4 -4
- package/src/runtime/office/authoring/docx-html-measure.mjs +60 -0
- package/src/runtime/office/authoring/pdf-author-action.mjs +6 -1
- package/src/runtime/office/authoring/pptx-brief.mjs +40 -1
- package/src/runtime/office/authoring/pptx-html-build.mjs +1 -1
- package/src/runtime/office/authoring/pptx-html-measure.mjs +1 -1
- package/src/runtime/office/bench/deck-bench.mjs +1 -1
- package/src/runtime/office/com/office-com-host.ps1 +8 -0
- package/src/runtime/office/core/office-actions-render.mjs +2 -0
- package/src/runtime/office/design/design-art-direction.mjs +10 -2
- package/src/runtime/office/design/design-discipline.mjs +4 -5
- package/src/runtime/office/design/design-tokens.mjs +20 -1
- package/src/runtime/office/design/docx/design-docx/front-matter.mjs +7 -4
- package/src/runtime/office/design/docx/design-docx/section.mjs +3 -1
- package/src/runtime/office/design/docx/design-docx/writer.mjs +1 -0
- package/src/runtime/office/design/docx/design-docx-components.mjs +19 -15
- package/src/runtime/office/design/docx/design-docx.mjs +5 -6
- package/src/runtime/office/design/docx/document-typography.mjs +20 -6
- package/src/runtime/office/design/xlsx/design-xlsx.mjs +9 -2
- package/src/runtime/office/pdf/document-preview.mjs +133 -12
- package/src/runtime/office/pdf/pdf-writer.mjs +56 -22
- package/src/runtime/office/portable/portable-snapshot-docx.mjs +46 -3
- package/src/runtime/office/portable/portable-snapshot-shared.mjs +27 -1
- package/src/runtime/office/quality/assurance-rendered.mjs +21 -5
- package/src/runtime/office/quality/assurance-structure-docx.mjs +41 -9
- package/src/runtime/office/quality/design-aesthetics.mjs +4 -2
- package/src/runtime/office/quality/design-deck-diversity.mjs +15 -3
- package/src/runtime/office/quality/design-review.mjs +13 -5
- package/src/runtime/office/quality/document-brief.mjs +8 -2
- package/src/runtime/office/quality/forced-break-pages.mjs +203 -0
- package/src/runtime/office/quality/pptx-deck-rubric.mjs +21 -3
- package/src/runtime/office/quality/quality-pipeline.mjs +14 -17
- package/src/runtime/session-search/session-search-db.mjs +183 -0
- package/src/runtime/session-search/session-search-ingest.mjs +106 -0
- package/src/runtime/shared/agent-route-config.mjs +50 -2
- package/src/runtime/shared/bounded-file-read.mjs +166 -0
- package/src/runtime/shared/builtin-grandfathering.mjs +37 -0
- package/src/runtime/shared/config.mjs +24 -4
- package/src/runtime/shared/defaults-separation.mjs +263 -0
- package/src/runtime/shared/error-presentation.mjs +8 -1
- package/src/runtime/shared/llm/anthropic-effort.mjs +4 -0
- package/src/runtime/shared/llm/cost.mjs +4 -2
- package/src/runtime/shared/llm/model-catalog-projection.mjs +1 -1
- package/src/runtime/shared/llm/model-catalog.mjs +25 -0
- package/src/runtime/shared/llm/reasoning-usage.mjs +1 -2
- package/src/runtime/shared/llm/usage-accounting.mjs +14 -4
- package/src/runtime/shared/llm/usage-context.mjs +11 -1
- package/src/runtime/shared/llm/usage-ledger-repair.mjs +3 -1
- package/src/runtime/shared/llm/usage-ledger-rollup.mjs +105 -1
- package/src/runtime/shared/llm/usage-ledger-worker.mjs +2 -1
- package/src/runtime/shared/llm/usage-ledger.mjs +72 -5
- package/src/runtime/shared/onnx-runtime-support.mjs +6 -0
- package/src/runtime/shared/orchestration.mjs +14 -6
- package/src/runtime/shared/pristine-execution-contract.json +7 -2
- package/src/runtime/shared/projects.mjs +65 -48
- package/src/runtime/shared/provider-accounts.mjs +47 -6
- package/src/runtime/shared/quota-resume-store.mjs +255 -0
- package/src/runtime/shared/shipped-definitions.mjs +275 -0
- package/src/runtime/shared/tool-card-model/agent-surface.mjs +30 -9
- package/src/runtime/shared/tool-card-model/aggregate-card.mjs +7 -3
- package/src/runtime/shared/tool-card-model/background-task.mjs +17 -1
- package/src/runtime/shared/tool-card-model/card-detail.mjs +10 -4
- package/src/runtime/shared/tool-card-model/card-header.mjs +10 -4
- package/src/runtime/shared/tool-card-model/card-status.mjs +22 -5
- package/src/runtime/shared/tool-card-model/displayed-result.mjs +6 -1
- package/src/runtime/shared/tool-card-model/media-result.mjs +53 -0
- package/src/runtime/shared/tool-card-model/terminal-status.mjs +17 -1
- package/src/runtime/shared/tool-card-model.golden-cases.mjs +1 -1
- package/src/runtime/shared/tool-card-model.golden.json +75 -66
- package/src/runtime/shared/tool-card-model.mjs +1 -0
- package/src/runtime/shared/tool-output-limit.mjs +3 -0
- package/src/runtime/shared/tool-primitives.mjs +24 -18
- package/src/runtime/shared/tool-result-summary.mjs +128 -17
- package/src/runtime/shared/tool-status.mjs +20 -7
- package/src/runtime/shared/tool-surface.mjs +105 -28
- package/src/runtime/shared/tool-work-units.mjs +221 -18
- package/src/runtime/shared/transcript-metadata.mjs +2 -0
- package/src/runtime/shared/turn-review-reply.mjs +2 -0
- package/src/runtime/shared/turn-snapshot.mjs +65 -6
- package/src/runtime/shared/turn-worktree-snapshot.mjs +202 -22
- package/src/runtime/shared/worker-requests.mjs +14 -2
- package/src/runtime/terminal-bridge/client.mjs +311 -0
- package/src/runtime/terminal-bridge/tool-defs.mjs +36 -0
- package/src/runtime/web-search/lib/ssrf-guard.mjs +12 -56
- package/src/runtime/web-search/tool-defs.mjs +2 -0
- package/src/session-runtime/boot/apis.mjs +30 -5
- package/src/session-runtime/boot/config.mjs +4 -0
- package/src/session-runtime/boot/facade.mjs +4 -1
- package/src/session-runtime/boot/infrastructure.mjs +21 -2
- package/src/session-runtime/boot/session.mjs +5 -5
- package/src/session-runtime/boot/tools.mjs +2 -0
- package/src/session-runtime/builtin-features.d.mts +1 -0
- package/src/session-runtime/channel-config-api.mjs +5 -0
- package/src/session-runtime/config-lifecycle/config-writers.mjs +3 -0
- package/src/session-runtime/config-lifecycle.mjs +31 -6
- package/src/session-runtime/goal-facade-api.mjs +4 -0
- package/src/session-runtime/internal-tool-executor/bridge-tools.mjs +15 -3
- package/src/session-runtime/lifecycle/inheritance.mjs +28 -6
- package/src/session-runtime/lifecycle/session-switch/context-switch.mjs +3 -0
- package/src/session-runtime/lifecycle/session-switch/resume.mjs +7 -1
- package/src/session-runtime/lifecycle/session-switch/session-delete.mjs +9 -0
- package/src/session-runtime/lifecycle/teardown/session-close.mjs +14 -2
- package/src/session-runtime/lifecycle/teardown.mjs +5 -0
- package/src/session-runtime/local-provider-settings.mjs +10 -0
- package/src/session-runtime/media-api.mjs +32 -22
- package/src/session-runtime/model-recency.mjs +14 -0
- package/src/session-runtime/model-route/route-persist.mjs +17 -2
- package/src/session-runtime/model-route/route-tuning.mjs +16 -5
- package/src/session-runtime/model-route/set-route.mjs +55 -22
- package/src/session-runtime/model-route/web-search-route.mjs +2 -2
- package/src/session-runtime/model-route-api.mjs +2 -1
- package/src/session-runtime/notification-bus.mjs +31 -6
- package/src/session-runtime/provider-auth/login.mjs +6 -0
- package/src/session-runtime/provider-models/catalog-load.mjs +3 -1
- package/src/session-runtime/provider-models/row-hydration.mjs +36 -10
- package/src/session-runtime/quick-model-rows/model-meta.mjs +26 -0
- package/src/session-runtime/quick-model-rows/provider-rows.mjs +40 -14
- package/src/session-runtime/resource-api.mjs +8 -1
- package/src/session-runtime/route-state.mjs +9 -0
- package/src/session-runtime/runtime-core.mjs +4 -0
- package/src/session-runtime/runtime-facade.mjs +20 -1
- package/src/session-runtime/runtime-feature-gates.mjs +2 -0
- package/src/session-runtime/runtime-review-api.mjs +12 -1
- package/src/session-runtime/services/agent-tool/helpers.mjs +14 -1
- package/src/session-runtime/services/agent-tool/index-write-queue.mjs +10 -15
- package/src/session-runtime/services/agent-tool/lead-worker-index/reap-timers.mjs +6 -1
- package/src/session-runtime/services/agent-tool/lead-worker-index.mjs +20 -2
- package/src/session-runtime/services/agent-tool/spawn-flow/spawn-prep.mjs +14 -6
- package/src/session-runtime/services/agent-tool/spawn-preset.mjs +2 -0
- package/src/session-runtime/services/agent-tool/tag-registry.mjs +12 -1
- package/src/session-runtime/services/agent-tool/worker-index.mjs +17 -1
- package/src/session-runtime/services/agent-tool.mjs +1 -0
- package/src/session-runtime/services/channel-admin.mjs +87 -13
- package/src/session-runtime/services/provider-admin.mjs +306 -66
- package/src/session-runtime/services/seeds.mjs +73 -142
- package/src/session-runtime/services/usage-dashboard-model.mjs +29 -0
- package/src/session-runtime/services/usage-dashboard.mjs +7 -0
- package/src/session-runtime/session-address.mjs +125 -0
- package/src/session-runtime/session-create.mjs +57 -2
- package/src/session-runtime/settings-api.mjs +1 -0
- package/src/session-runtime/settings-builtin-tools-api.mjs +15 -10
- package/src/session-runtime/settings-compaction-api.mjs +13 -0
- package/src/session-runtime/setup-tool/executor.mjs +93 -40
- package/src/session-runtime/setup-tool/extended-actions.mjs +64 -5
- package/src/session-runtime/setup-tool/settings-contract.mjs +46 -3
- package/src/session-runtime/setup-tool/tool-defs.mjs +14 -6
- package/src/session-runtime/tool-surface.mjs +16 -9
- package/src/session-runtime/turn/session-ops.mjs +3 -0
- package/src/session-runtime/turn/share-ops.mjs +4 -1
- package/src/session-runtime/turn/turn-run/turn-prepare.mjs +6 -0
- package/src/session-runtime/usage-stats-api.mjs +43 -3
- package/src/session-runtime/workflow-agents-api/agent-editor.mjs +31 -5
- package/src/session-runtime/workflow-agents-api/agent-route.mjs +6 -2
- package/src/session-runtime/workflow-agents-api/workflow-packs.mjs +27 -7
- package/src/standalone/daemon-boot-coordinator.mjs +10 -0
- package/src/standalone/daemon-desktop-runtime.mjs +1 -0
- package/src/standalone/daemon-drain-policy.mjs +9 -0
- package/src/standalone/daemon-stored-session-views.mjs +7 -8
- package/src/standalone/daemon.mjs +36 -8
- package/src/standalone/local-session-runtime.mjs +11 -0
- package/src/standalone/session-client.mjs +52 -7
- package/src/standalone/session-protocol.mjs +9 -0
- package/src/standalone/session-service/agent-tree/agent-child.mjs +2 -0
- package/src/standalone/session-service/entries/lifecycle.mjs +2 -0
- package/src/standalone/session-service/entries/session-loads.mjs +9 -0
- package/src/standalone/session-service/projection/revisions.mjs +28 -4
- package/src/standalone/session-service/projection.mjs +1 -0
- package/src/standalone/session-service/quota-resume.mjs +140 -0
- package/src/standalone/session-service/session-calls/session-action.mjs +2 -2
- package/src/standalone/session-service/session-calls.mjs +10 -2
- package/src/standalone/session-service/stored-reader.mjs +26 -1
- package/src/standalone/session-service.mjs +21 -0
- package/src/standalone/session-transport/routes.mjs +2 -0
- package/src/tui/app/doctor.mjs +7 -11
- package/src/tui/app/maintenance-pickers/auto-clear-picker.mjs +3 -5
- package/src/tui/app/model-picker/model-footer.mjs +2 -2
- package/src/tui/app/model-picker/route-selection/fast-parameters.mjs +21 -2
- package/src/tui/app/model-picker/route-selection.mjs +6 -1
- package/src/tui/app/settings-picker/settings-rows.mjs +4 -6
- package/src/tui/app/settings-picker/settings-toggles/store-toggles.mjs +1 -1
- package/src/tui/app/slash-commands.mjs +1 -1
- package/src/tui/app/slash-dispatch/route-commands.mjs +5 -3
- package/src/tui/app/transcript-row-estimate.mjs +17 -5
- package/src/tui/components/ContextPanel.jsx +5 -1
- package/src/tui/components/Spinner.jsx +34 -319
- package/src/tui/components/SpinnerByline.jsx +256 -0
- package/src/tui/components/tool-execution/aggregate-card.jsx +4 -2
- package/src/tui/components/tool-execution/text-format.mjs +1 -0
- package/src/tui/components/use-spinner-progress.mjs +113 -0
- package/src/tui/dist/index.mjs +15896 -14452
- package/src/tui/session/agent-job-feed/execution-delivery.mjs +13 -1
- package/src/tui/session/agent-job-feed/notification-router.mjs +3 -0
- package/src/tui/session/agent-job-feed/pending-resume.mjs +14 -1
- package/src/tui/session/agent-job-feed.mjs +4 -0
- package/src/tui/session/context-state.mjs +13 -1
- package/src/tui/session/initial-state.mjs +6 -0
- package/src/tui/session/quota-resume.mjs +263 -0
- package/src/tui/session/session-api/intake/abort.mjs +39 -35
- package/src/tui/session/session-api/intake/submission.mjs +13 -21
- package/src/tui/session/session-api/intake.mjs +3 -3
- package/src/tui/session/session-api/integrations.mjs +5 -1
- package/src/tui/session/session-api/lifecycle/dispose.mjs +1 -0
- package/src/tui/session/session-api/lifecycle/inheritance.mjs +2 -2
- package/src/tui/session/session-api/lifecycle/session-reset.mjs +4 -0
- package/src/tui/session/session-api/lifecycle.mjs +71 -2
- package/src/tui/session/session-api/media.mjs +2 -2
- package/src/tui/session/session-api/quota-resume.mjs +21 -0
- package/src/tui/session/session-api/routes.mjs +5 -2
- package/src/tui/session/session-api/settings.mjs +2 -0
- package/src/tui/session/session-api.mjs +2 -0
- package/src/tui/session/session-flow/auto-clear.mjs +14 -6
- package/src/tui/session/session-flow/drain.mjs +52 -5
- package/src/tui/session/session-flow/queue/take-entries.mjs +9 -4
- package/src/tui/session/session-flow/queue.mjs +4 -0
- package/src/tui/session/session-flow/steering.mjs +11 -0
- package/src/tui/session/session-flow.mjs +1 -0
- package/src/tui/session/tool-approval.mjs +7 -2
- package/src/tui/session/transcript-intake.mjs +1 -0
- package/src/tui/session/turn-tool-cards.mjs +4 -6
- package/src/tui/session/turn.mjs +40 -4
- package/src/vendor/statusline/bin/statusline-route.mjs +3 -2
- package/src/vendor/statusline/src/gateway/route-meta.mjs +1 -1
- package/src/runtime/agent/orchestrator/providers/openai-ws-warmup.mjs +0 -165
package/src/tui/session/turn.mjs
CHANGED
|
@@ -152,6 +152,8 @@ function promptRestoreFor(displayText, options, submittedIds, content = null) {
|
|
|
152
152
|
onCommitted: typeof options.onCommitted === 'function' ? options.onCommitted : null,
|
|
153
153
|
restorable: options.restorable !== false,
|
|
154
154
|
submittedIds,
|
|
155
|
+
// Which device submitted the prompt: only that device may get it back.
|
|
156
|
+
device: typeof options.transcriptMeta?.device === 'string' ? options.transcriptMeta.device : '',
|
|
155
157
|
reclaimed: false,
|
|
156
158
|
committed: false,
|
|
157
159
|
requeueEntries: Array.isArray(options.requeueOnAbort) ? options.requeueOnAbort.slice() : [],
|
|
@@ -190,6 +192,9 @@ function steeringItemExtras(steeringMeta) {
|
|
|
190
192
|
...(typeof steeringMeta?.transcriptMeta?.sender === 'string' && steeringMeta.transcriptMeta.sender
|
|
191
193
|
? { sender: steeringMeta.transcriptMeta.sender }
|
|
192
194
|
: {}),
|
|
195
|
+
...(typeof steeringMeta?.transcriptMeta?.device === 'string' && steeringMeta.transcriptMeta.device
|
|
196
|
+
? { device: steeringMeta.transcriptMeta.device }
|
|
197
|
+
: {}),
|
|
193
198
|
};
|
|
194
199
|
}
|
|
195
200
|
|
|
@@ -389,7 +394,7 @@ function completeTurn(ctx, result, session) {
|
|
|
389
394
|
turn.finishedNormally = true;
|
|
390
395
|
}
|
|
391
396
|
|
|
392
|
-
function failTurn(ctx, error) {
|
|
397
|
+
export function failTurn(ctx, error) {
|
|
393
398
|
const { turn, stream, cards, pushNotice } = ctx;
|
|
394
399
|
flushStreamBatch(stream); // ensure any batched text lands before the error notice
|
|
395
400
|
if (isCancelLikeError(error)) {
|
|
@@ -401,12 +406,20 @@ function failTurn(ctx, error) {
|
|
|
401
406
|
turn.failed = true;
|
|
402
407
|
cards.aggregates.finalizeToolHeaders();
|
|
403
408
|
turn.usageLimited = isUsageLimitError(error);
|
|
409
|
+
const exhausted = error?.quotaExhausted;
|
|
410
|
+
if (exhausted && typeof exhausted === 'object') {
|
|
411
|
+
turn.quota = {
|
|
412
|
+
provider: String(exhausted.provider || turn.routeMeta?.provider || ''),
|
|
413
|
+
model: String(exhausted.model || turn.routeMeta?.model || ''),
|
|
414
|
+
resetAt: Number.isFinite(exhausted.resetAt) ? exhausted.resetAt : null,
|
|
415
|
+
};
|
|
416
|
+
}
|
|
404
417
|
turn.failureDetail = toolErrorDisplay(error, 'turn').replace(/^Error:\s*/i, '');
|
|
405
418
|
turn.failureDiagnostic = safeErrorDetails(errText(error));
|
|
406
419
|
pushNotice(turn.failureDetail, 'error', { owner: 'transcript' });
|
|
407
420
|
}
|
|
408
421
|
|
|
409
|
-
function turnDoneItem({ turn, stream, cards, getState, nextId }) {
|
|
422
|
+
export function turnDoneItem({ turn, stream, cards, getState, nextId }) {
|
|
410
423
|
return {
|
|
411
424
|
kind: 'turndone',
|
|
412
425
|
id: nextId(),
|
|
@@ -421,11 +434,11 @@ function turnDoneItem({ turn, stream, cards, getState, nextId }) {
|
|
|
421
434
|
thinkingElapsedMs: stream.thinkingStartedAt ? stream.accumulatedThinkingMs : 0,
|
|
422
435
|
toolCount: cards.toolCards.length,
|
|
423
436
|
verb: turn.completionVerb,
|
|
424
|
-
...(typeof turn.askResult?.autoEffort === 'string' ? { autoEffort: turn.askResult.autoEffort } : {}),
|
|
425
437
|
at: Date.now(),
|
|
426
438
|
...(turn.failureDetail ? { detail: turn.failureDetail } : {}),
|
|
427
439
|
...(turn.failureDiagnostic ? { errorDetails: turn.failureDiagnostic } : {}),
|
|
428
440
|
...turn.routeMeta,
|
|
441
|
+
...(turn.failed && turn.quota ? { quota: turn.quota } : {}),
|
|
429
442
|
};
|
|
430
443
|
}
|
|
431
444
|
|
|
@@ -463,6 +476,14 @@ function publishTurnClose(ctx, closingItems) {
|
|
|
463
476
|
toolMode: runtime.toolMode,
|
|
464
477
|
...agentStatusState({ force: true }),
|
|
465
478
|
});
|
|
479
|
+
// Same frame as the failed turndone and busy=false: the resume is queued
|
|
480
|
+
// (and `quotaResume` published) before anything can observe the idle
|
|
481
|
+
// session, so a cancel at any later point finds it and wins.
|
|
482
|
+
if (turn.failed && turn.quota) {
|
|
483
|
+
try {
|
|
484
|
+
ctx.bag.beginQuotaSettlement?.();
|
|
485
|
+
} catch {}
|
|
486
|
+
}
|
|
466
487
|
ctx.flushDeferredExecutionPendingResumeKick();
|
|
467
488
|
}
|
|
468
489
|
|
|
@@ -503,8 +524,12 @@ async function settleTurn(ctx) {
|
|
|
503
524
|
try {
|
|
504
525
|
options.onSettled?.(detail);
|
|
505
526
|
} catch {}
|
|
527
|
+
// A quota failure suspends only a Goal that was running when it struck.
|
|
528
|
+
const quotaFailed = turn.failed && turn.quota && isCurrentTurn();
|
|
529
|
+
const goalBefore = quotaFailed ? runtime.goalStatus?.() || null : null;
|
|
530
|
+
let settledGoal = null;
|
|
506
531
|
try {
|
|
507
|
-
await bag.onGoalTurnSettled?.({
|
|
532
|
+
settledGoal = await bag.onGoalTurnSettled?.({
|
|
508
533
|
status: finalStatus,
|
|
509
534
|
error: turn.failureDiagnostic || turn.failureDetail || null,
|
|
510
535
|
usageLimited: turn.usageLimited,
|
|
@@ -521,6 +546,17 @@ async function settleTurn(ctx) {
|
|
|
521
546
|
}),
|
|
522
547
|
});
|
|
523
548
|
} catch {}
|
|
549
|
+
if (turn.failed && turn.quota) {
|
|
550
|
+
const suspended =
|
|
551
|
+
quotaFailed &&
|
|
552
|
+
!flags.disposed &&
|
|
553
|
+
goalBefore?.status === 'active' &&
|
|
554
|
+
settledGoal?.status === 'usage_limited' &&
|
|
555
|
+
settledGoal.id === goalBefore.id;
|
|
556
|
+
try {
|
|
557
|
+
bag.finishQuotaSettlement?.({ suspendedGoalId: suspended ? settledGoal.id : '' });
|
|
558
|
+
} catch {}
|
|
559
|
+
}
|
|
524
560
|
if (flags.goalSteeringAbortEpoch === turn.epoch) flags.goalSteeringAbortEpoch = null;
|
|
525
561
|
ctx.tuiDebug(
|
|
526
562
|
`runTurn end turn=${turn.index} status=${finalStatus} elapsedMs=${Date.now() - turn.startedAt} pending=${ctx.pending.length}`
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
} from '../src/gateway/route-meta.mjs';
|
|
18
18
|
import { getModelMetadataSync } from '../../../runtime/agent/orchestrator/providers/model-catalog.mjs';
|
|
19
19
|
import { resolveRuntimeRoot } from '../../../runtime/shared/runtime-root.mjs';
|
|
20
|
+
import { withDefaultPresets } from '../../../runtime/agent/orchestrator/config-presets.mjs';
|
|
20
21
|
|
|
21
22
|
function positiveInt(value) {
|
|
22
23
|
const n = parseInt(String(value || ''), 10);
|
|
@@ -142,7 +143,7 @@ function resolveConfiguredModelTarget(cfg, rawModel) {
|
|
|
142
143
|
const lower = stripped.toLowerCase();
|
|
143
144
|
const agent = cfg?.agent && typeof cfg.agent === 'object' ? cfg.agent : {};
|
|
144
145
|
const providers = agent.providers && typeof agent.providers === 'object' ? agent.providers : {};
|
|
145
|
-
const presets =
|
|
146
|
+
const presets = withDefaultPresets(agent.presets);
|
|
146
147
|
for (const p of presets) {
|
|
147
148
|
if (!p || typeof p !== 'object' || !p.provider || !p.model) continue;
|
|
148
149
|
const providerEntry = providers[p.provider];
|
|
@@ -455,7 +456,7 @@ function configuredGatewayStatus(options = {}) {
|
|
|
455
456
|
model = aliasTarget.model;
|
|
456
457
|
}
|
|
457
458
|
if (!provider || !model) return null;
|
|
458
|
-
const presets =
|
|
459
|
+
const presets = withDefaultPresets(cfg?.agent?.presets);
|
|
459
460
|
const preset = presets.find(p =>
|
|
460
461
|
p?.provider === provider &&
|
|
461
462
|
p?.model === model &&
|
|
@@ -92,7 +92,7 @@ function cleanBool(value) {
|
|
|
92
92
|
if (value === false) return false;
|
|
93
93
|
if (typeof value === 'string') {
|
|
94
94
|
const s = value.trim().toLowerCase();
|
|
95
|
-
if (['1', 'true', 'yes', 'on', 'fast', 'priority'].includes(s)) return true;
|
|
95
|
+
if (['1', 'true', 'yes', 'on', 'fast', 'priority', 'ultrafast'].includes(s)) return true;
|
|
96
96
|
if (['0', 'false', 'no', 'off', 'none'].includes(s)) return false;
|
|
97
97
|
}
|
|
98
98
|
return null;
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* openai-ws-warmup.mjs — the Codex generate:false prewarm on a fresh socket.
|
|
3
|
-
*
|
|
4
|
-
* Codex performs generate:false during session startup, then hands the live
|
|
5
|
-
* client session to the first real turn. The prewarm contains stable
|
|
6
|
-
* instructions/tools but no live user/transcript input; its response id
|
|
7
|
-
* becomes the anchor the first real request chains from.
|
|
8
|
-
*/
|
|
9
|
-
import { performance } from 'node:perf_hooks';
|
|
10
|
-
import { releaseWebSocket } from './openai-ws-pool.mjs';
|
|
11
|
-
import { _anchorResponseChain, _buildResponseCreateFrame } from './openai-ws-delta.mjs';
|
|
12
|
-
import { _metadataTrace, _withCodexWsClientMetadata } from './openai-codex-metadata.mjs';
|
|
13
|
-
|
|
14
|
-
/** Only when the session has no prior request state. A reused pooled socket
|
|
15
|
-
* with a live chain must go straight to the real request. */
|
|
16
|
-
export function startupWarmupApplies({ warmupBody, completedWarmup, attemptIndex, entry }) {
|
|
17
|
-
return (
|
|
18
|
-
Boolean(warmupBody) &&
|
|
19
|
-
typeof warmupBody === 'object' &&
|
|
20
|
-
!completedWarmup &&
|
|
21
|
-
attemptIndex === 0 &&
|
|
22
|
-
!entry.lastResponseId
|
|
23
|
-
);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Sends the prewarm frame and streams its (empty) response. Throws on any
|
|
28
|
-
* failure; the caller's stream-failure path handles it like the real send.
|
|
29
|
-
* Returns the warmup result plus what the caller records about the wire
|
|
30
|
-
* frame it produced.
|
|
31
|
-
*/
|
|
32
|
-
export async function runStartupWarmup({
|
|
33
|
-
entry,
|
|
34
|
-
warmupBody,
|
|
35
|
-
attemptIndex,
|
|
36
|
-
codexMetadataContext,
|
|
37
|
-
useCodexWsClientMetadata,
|
|
38
|
-
sendSpan,
|
|
39
|
-
externalSignal,
|
|
40
|
-
logSuppressedReasoningDeltas,
|
|
41
|
-
traceProvider,
|
|
42
|
-
poolKey,
|
|
43
|
-
iteration,
|
|
44
|
-
useModel,
|
|
45
|
-
midState,
|
|
46
|
-
streamTimeouts,
|
|
47
|
-
sendFrame,
|
|
48
|
-
streamFn,
|
|
49
|
-
agentTraceFn,
|
|
50
|
-
}) {
|
|
51
|
-
const warmupBuildStart = performance.now();
|
|
52
|
-
// Enforce the no-transcript rule at the transport boundary as well as in
|
|
53
|
-
// the OAuth caller so a future caller cannot accidentally duplicate the
|
|
54
|
-
// transcript. Keep the same request properties as the real turn; Codex
|
|
55
|
-
// changes only the input tail and adds generate:false.
|
|
56
|
-
const parityWarmupBody = {
|
|
57
|
-
...warmupBody,
|
|
58
|
-
input: Array.isArray(warmupBody.input) ? warmupBody.input : [],
|
|
59
|
-
generate: false,
|
|
60
|
-
};
|
|
61
|
-
const warmupFrame = _buildResponseCreateFrame(parityWarmupBody);
|
|
62
|
-
const warmupMetadataContext = {
|
|
63
|
-
...codexMetadataContext,
|
|
64
|
-
sendOpts: {
|
|
65
|
-
...(codexMetadataContext?.sendOpts || {}),
|
|
66
|
-
requestKind: 'prewarm',
|
|
67
|
-
codexRequestKind: 'prewarm',
|
|
68
|
-
},
|
|
69
|
-
};
|
|
70
|
-
const wireWarmupFrame = _withCodexWsClientMetadata(
|
|
71
|
-
warmupFrame,
|
|
72
|
-
entry,
|
|
73
|
-
useCodexWsClientMetadata,
|
|
74
|
-
warmupMetadataContext
|
|
75
|
-
);
|
|
76
|
-
const wireFrameHadTurnState = !!wireWarmupFrame?.client_metadata?.['x-codex-turn-state'];
|
|
77
|
-
const wireFrameMetadataTrace = _metadataTrace(wireWarmupFrame?.client_metadata);
|
|
78
|
-
sendSpan.requestBuildSerializationMs += performance.now() - warmupBuildStart;
|
|
79
|
-
await sendFrame(entry, wireWarmupFrame, sendSpan);
|
|
80
|
-
const warmupStart = Date.now();
|
|
81
|
-
const warmupState = {
|
|
82
|
-
attemptIndex,
|
|
83
|
-
sawResponseCreated: false,
|
|
84
|
-
sawCompleted: false,
|
|
85
|
-
sessionId: poolKey,
|
|
86
|
-
iteration,
|
|
87
|
-
model: useModel,
|
|
88
|
-
traceProvider,
|
|
89
|
-
warmup: true,
|
|
90
|
-
sendSpan,
|
|
91
|
-
sendStartedAt: performance.now(),
|
|
92
|
-
};
|
|
93
|
-
const warmupResult = await streamFn({
|
|
94
|
-
entry,
|
|
95
|
-
externalSignal,
|
|
96
|
-
onStreamDelta: null,
|
|
97
|
-
onToolCall: null,
|
|
98
|
-
state: warmupState,
|
|
99
|
-
logSuppressedReasoningDeltas,
|
|
100
|
-
traceProvider,
|
|
101
|
-
_timeouts: streamTimeouts,
|
|
102
|
-
});
|
|
103
|
-
// Surface warmup-time first-event timeout / send-failure flags onto the
|
|
104
|
-
// shared midState so the outer catch's classifier sees them.
|
|
105
|
-
// (warmupResult itself only resolves on success; failures throw.)
|
|
106
|
-
if (warmupState.firstByteTimeout) midState.firstByteTimeout = true;
|
|
107
|
-
if (warmupState.wsSendFailed) midState.wsSendFailed = true;
|
|
108
|
-
if (!warmupResult?.responseId) {
|
|
109
|
-
throw new Error('Responses WS warmup completed without response id');
|
|
110
|
-
}
|
|
111
|
-
const completedWarmup = {
|
|
112
|
-
requestBody: parityWarmupBody,
|
|
113
|
-
responseId: warmupResult.responseId,
|
|
114
|
-
usage: warmupResult.usage,
|
|
115
|
-
};
|
|
116
|
-
_anchorResponseChain(entry, {
|
|
117
|
-
responseId: warmupResult.responseId,
|
|
118
|
-
requestBody: parityWarmupBody,
|
|
119
|
-
responseItems: warmupResult.responseItems,
|
|
120
|
-
normalizeWarmupGenerate: useCodexWsClientMetadata,
|
|
121
|
-
});
|
|
122
|
-
try {
|
|
123
|
-
const warmupPayload = {
|
|
124
|
-
provider: traceProvider,
|
|
125
|
-
transport: 'websocket',
|
|
126
|
-
event: 'warmup_completed',
|
|
127
|
-
response_id: warmupResult.responseId,
|
|
128
|
-
elapsed_ms: Date.now() - warmupStart,
|
|
129
|
-
input_tokens: warmupResult.usage?.inputTokens || 0,
|
|
130
|
-
cached_tokens: warmupResult.usage?.cachedTokens || 0,
|
|
131
|
-
output_tokens: warmupResult.usage?.outputTokens || 0,
|
|
132
|
-
prompt_tokens: warmupResult.usage?.promptTokens || 0,
|
|
133
|
-
};
|
|
134
|
-
agentTraceFn({
|
|
135
|
-
sessionId: poolKey,
|
|
136
|
-
iteration,
|
|
137
|
-
kind: 'cache_warmup',
|
|
138
|
-
...warmupPayload,
|
|
139
|
-
payload: warmupPayload,
|
|
140
|
-
});
|
|
141
|
-
} catch {}
|
|
142
|
-
return { warmupResult, completedWarmup, wireFrameHadTurnState, wireFrameMetadataTrace };
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/** Startup callers stop after the prewarm: the pooled entry retains its
|
|
146
|
-
* response id, request snapshot and socket for the later real send. */
|
|
147
|
-
export function startupPrewarmResult({ entry, poolKey, cacheKey, warmupResult, startupWarmupResponseId, useModel }) {
|
|
148
|
-
const responseId = warmupResult?.responseId || startupWarmupResponseId || entry.lastResponseId || null;
|
|
149
|
-
if (responseId) entry.startupWarmupResponseId = responseId;
|
|
150
|
-
else releaseWebSocket({ entry, poolKey, keep: false });
|
|
151
|
-
return {
|
|
152
|
-
content: '',
|
|
153
|
-
model: warmupResult?.model || useModel,
|
|
154
|
-
toolCalls: [],
|
|
155
|
-
usage: warmupResult?.usage || {
|
|
156
|
-
inputTokens: 0,
|
|
157
|
-
outputTokens: 0,
|
|
158
|
-
cachedTokens: 0,
|
|
159
|
-
cacheWriteTokens: 0,
|
|
160
|
-
promptTokens: 0,
|
|
161
|
-
},
|
|
162
|
-
startupPrewarm: !!responseId,
|
|
163
|
-
startupPrewarmHandle: responseId ? { entry, poolKey, cacheKey } : null,
|
|
164
|
-
};
|
|
165
|
-
}
|