mixdog 1.4.2 → 1.4.4
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/package.json +2 -2
- package/scripts/build-shipped-history.mjs +15 -5
- package/scripts/gate-local.mjs +65 -19
- package/scripts/graph-parity.mjs +8 -3
- package/scripts/lib/gate-scheduler.mjs +2 -1
- package/scripts/lib/run-node-tests.mjs +17 -5
- package/scripts/lib/test-failure-summary.mjs +1 -8
- package/scripts/lib/test-spawn-ledger.mjs +33 -2
- package/scripts/post-release-check.mjs +26 -16
- package/scripts/provider-pingpong-live.mjs +1 -1
- package/scripts/prune-embedding-runtime.mjs +3 -1
- package/scripts/release-paths.mjs +7 -1
- package/src/defaults/shipped-history.json +24 -0
- package/src/defaults/skills/computer-use/SKILL.md +14 -3
- package/src/defaults/skills/memory-management/SKILL.md +10 -5
- package/src/defaults/skills/setup/SKILL.md +2 -2
- package/src/defaults/skills/setup/references/actions.md +17 -4
- package/src/defaults/skills/setup/references/surfaces.md +3 -0
- package/src/defaults/skills/setup-guide/SKILL.md +6 -1
- package/src/lib/instruction-text.cjs +36 -0
- package/src/lib/rules-builder.cjs +34 -20
- package/src/orchestration/balanced.md +23 -0
- package/src/orchestration/focused.md +22 -0
- package/src/orchestration/none.md +5 -0
- package/src/orchestration/swarm.md +24 -0
- package/src/rules/agent-mode/AGENT_MODE.md +3 -1
- package/src/rules/agent-mode/MIXY.md +5 -3
- package/src/runtime/agent/orchestrator/agent-runtime/agent-dispatch/session-prep.mjs +3 -3
- package/src/runtime/agent/orchestrator/agent-runtime/agent-dispatch.mjs +0 -1
- package/src/runtime/agent/orchestrator/agent-runtime/agent-progress-watchdog.mjs +4 -2
- package/src/runtime/agent/orchestrator/agent-runtime/cache-strategy.mjs +0 -9
- package/src/runtime/agent/orchestrator/agent-runtime/heartbeat-completion.mjs +2 -2
- package/src/runtime/agent/orchestrator/agent-runtime/session-builder.mjs +67 -0
- package/src/runtime/agent/orchestrator/agent-trace-format.mjs +1 -0
- package/src/runtime/agent/orchestrator/context/role-instructions.mjs +4 -4
- package/src/runtime/agent/orchestrator/mcp/agent-connectors.mjs +3 -1
- package/src/runtime/agent/orchestrator/mcp/child-tree.mjs +199 -46
- package/src/runtime/agent/orchestrator/mcp/client-config.mjs +3 -5
- package/src/runtime/agent/orchestrator/mcp/client-transport.mjs +9 -3
- package/src/runtime/agent/orchestrator/mcp/client.mjs +3 -5
- package/src/runtime/agent/orchestrator/mcp/oauth-client.mjs +1 -1
- package/src/runtime/agent/orchestrator/mcp/oauth-credentials.mjs +8 -2
- package/src/runtime/agent/orchestrator/mcp/oauth-probe.mjs +1 -1
- package/src/runtime/agent/orchestrator/mcp/oauth-provider.mjs +14 -0
- package/src/runtime/agent/orchestrator/mcp/oauth.mjs +1 -1
- package/src/runtime/agent/orchestrator/providers/admission-scheduler.mjs +2 -1
- package/src/runtime/agent/orchestrator/providers/anthropic-api-request.mjs +11 -1
- package/src/runtime/agent/orchestrator/providers/anthropic-oauth-client-version.mjs +1 -1
- package/src/runtime/agent/orchestrator/providers/anthropic-sse-turn/turn-events/content-block-start.mjs +4 -0
- package/src/runtime/agent/orchestrator/providers/anthropic-sse-turn/turn-events/content-block-stop.mjs +3 -3
- package/src/runtime/agent/orchestrator/providers/anthropic-sse-turn/turn-outcome.mjs +2 -0
- package/src/runtime/agent/orchestrator/providers/anthropic-turn-result.mjs +2 -0
- package/src/runtime/agent/orchestrator/providers/anthropic.mjs +2 -0
- package/src/runtime/agent/orchestrator/providers/codex-client-meta.mjs +1 -1
- package/src/runtime/agent/orchestrator/providers/custom-provider-config.mjs +121 -9
- package/src/runtime/agent/orchestrator/providers/custom-provider.mjs +4 -1
- package/src/runtime/agent/orchestrator/providers/gemini-thinking.mjs +2 -2
- package/src/runtime/agent/orchestrator/providers/lib/generation-window.mjs +9 -0
- package/src/runtime/agent/orchestrator/providers/openai-compat-chat-send.mjs +9 -1
- package/src/runtime/agent/orchestrator/providers/openai-compat-chat-stream/stream-result.mjs +2 -0
- package/src/runtime/agent/orchestrator/providers/openai-compat-chat-stream/stream-state.mjs +5 -0
- package/src/runtime/agent/orchestrator/providers/openai-compat-options.mjs +3 -0
- package/src/runtime/agent/orchestrator/providers/openai-compat-response-normalization.mjs +6 -6
- package/src/runtime/agent/orchestrator/providers/openai-compat-responses-head-parity.json +2784 -2872
- package/src/runtime/agent/orchestrator/providers/openai-compat-responses.mjs +10 -1
- package/src/runtime/agent/orchestrator/providers/openai-compat-xai.mjs +5 -8
- package/src/runtime/agent/orchestrator/providers/openai-http-sse-response-state/response-events.mjs +3 -0
- package/src/runtime/agent/orchestrator/providers/openai-http-sse-response-state/response-outcome.mjs +2 -0
- package/src/runtime/agent/orchestrator/providers/openai-responses-payload-parity.fixture.json +288 -300
- package/src/runtime/agent/orchestrator/providers/openai-ws-response-state.mjs +9 -2
- package/src/runtime/agent/orchestrator/providers/openrouter-provider-routing.mjs +28 -0
- package/src/runtime/agent/orchestrator/providers/openrouter.mjs +4 -1
- package/src/runtime/agent/orchestrator/providers/registry.mjs +30 -25
- package/src/runtime/agent/orchestrator/providers/vertex-ai.mjs +10 -1
- package/src/runtime/agent/orchestrator/providers/xai-tool-search-head-parity.json +10 -30
- package/src/runtime/agent/orchestrator/runtime-core/ask-user-result.mjs +66 -0
- package/src/runtime/agent/orchestrator/runtime-core/builtin-features.mjs +30 -0
- package/src/runtime/agent/orchestrator/runtime-core/config-helpers.mjs +0 -11
- package/src/runtime/agent/orchestrator/runtime-core/deferred-tool-availability.mjs +8 -0
- package/src/runtime/agent/orchestrator/runtime-core/deferred-tool-delta.mjs +17 -3
- package/src/runtime/agent/orchestrator/runtime-core/goal-control.mjs +47 -27
- package/src/runtime/agent/orchestrator/runtime-core/goal-deadlines.mjs +141 -10
- package/src/runtime/agent/orchestrator/runtime-core/goal-mutations.mjs +26 -63
- package/src/runtime/agent/orchestrator/runtime-core/goal-reminder.mjs +28 -3
- package/src/runtime/agent/orchestrator/runtime-core/goal-runtime.mjs +36 -11
- package/src/runtime/agent/orchestrator/runtime-core/goal-state.mjs +88 -56
- package/src/runtime/agent/orchestrator/runtime-core/goal-storage.mjs +4 -1
- package/src/runtime/agent/orchestrator/runtime-core/goal-store.mjs +51 -32
- package/src/runtime/agent/orchestrator/runtime-core/goal-text.mjs +45 -145
- package/src/runtime/agent/orchestrator/runtime-core/goal-tool-defs.mjs +15 -98
- package/src/runtime/agent/orchestrator/runtime-core/goal-tool-exec.mjs +32 -99
- package/src/runtime/agent/orchestrator/runtime-core/goal-turns.mjs +23 -78
- package/src/runtime/agent/orchestrator/runtime-core/orchestration.mjs +69 -48
- package/src/runtime/agent/orchestrator/runtime-core/todo-list.mjs +367 -0
- package/src/runtime/agent/orchestrator/runtime-core/todo-tool-defs.mjs +47 -0
- package/src/runtime/agent/orchestrator/runtime-core/tool-availability.mjs +155 -0
- package/src/runtime/agent/orchestrator/runtime-core/tool-catalog-data.mjs +9 -0
- package/src/runtime/agent/orchestrator/runtime-core/tool-catalog.mjs +119 -35
- package/src/runtime/agent/orchestrator/runtime-core/tool-defs.mjs +1 -1
- package/src/runtime/agent/orchestrator/runtime-core/workflow/context.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/agent-loop.mjs +28 -22
- package/src/runtime/agent/orchestrator/session/agent-pool-progress.mjs +30 -0
- package/src/runtime/agent/orchestrator/session/attachment-preflight.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/cache-warm.mjs +2 -2
- package/src/runtime/agent/orchestrator/session/catalog-db/index.mjs +2 -2
- package/src/runtime/agent/orchestrator/session/catalog-db/schema.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/compact/execution-tail.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/compact/runner.mjs +3 -0
- package/src/runtime/agent/orchestrator/session/compact/summary-route.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/context-utils.mjs +8 -12
- package/src/runtime/agent/orchestrator/session/conversation-import/claude.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/conversation-import/codex.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/conversation-import/convert.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/conversation-import/imported-session.mjs +7 -3
- package/src/runtime/agent/orchestrator/session/human-gate/held-message.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/human-gate/requests.mjs +1 -2
- package/src/runtime/agent/orchestrator/session/human-gate/run-policy.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/image-strip-recovery.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/loop/completion-guards.mjs +11 -1
- package/src/runtime/agent/orchestrator/session/loop/context-overflow.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/loop/loop-state.mjs +8 -1
- package/src/runtime/agent/orchestrator/session/loop/no-tool-turn/todo-check.mjs +196 -0
- package/src/runtime/agent/orchestrator/session/loop/no-tool-turn.mjs +116 -50
- package/src/runtime/agent/orchestrator/session/loop/pre-dispatch-deny.mjs +8 -1
- package/src/runtime/agent/orchestrator/session/loop/provider-tool-exclusions.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/loop/route-fallback.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/loop/steering.mjs +3 -1
- package/src/runtime/agent/orchestrator/session/loop/stored-tool-args.mjs +5 -6
- package/src/runtime/agent/orchestrator/session/loop/tool-exec/before-hook.mjs +6 -1
- package/src/runtime/agent/orchestrator/session/loop/tool-exec/dispatch.mjs +16 -2
- package/src/runtime/agent/orchestrator/session/loop/turn-report.mjs +35 -0
- package/src/runtime/agent/orchestrator/session/loop/usage.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/manager/ask-session.mjs +57 -26
- package/src/runtime/agent/orchestrator/session/manager/ask-turn-auto-effort.mjs +9 -7
- package/src/runtime/agent/orchestrator/session/manager/ask-turn-execute.mjs +21 -3
- package/src/runtime/agent/orchestrator/session/manager/ask-turn-failure.mjs +27 -11
- package/src/runtime/agent/orchestrator/session/manager/ask-turn-open.mjs +37 -34
- package/src/runtime/agent/orchestrator/session/manager/ask-turn-prepare.mjs +15 -0
- package/src/runtime/agent/orchestrator/session/manager/ask-turn-settle.mjs +25 -15
- package/src/runtime/agent/orchestrator/session/manager/ask-turn-state.mjs +79 -24
- package/src/runtime/agent/orchestrator/session/manager/ask-turn-steering-drain.mjs +3 -0
- package/src/runtime/agent/orchestrator/session/manager/compaction-runner.mjs +12 -1
- package/src/runtime/agent/orchestrator/session/manager/context-meta.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/manager/idle-cleanup.mjs +6 -1
- package/src/runtime/agent/orchestrator/session/manager/pending-messages.mjs +9 -1
- package/src/runtime/agent/orchestrator/session/manager/pending-spool-path.mjs +2 -2
- package/src/runtime/agent/orchestrator/session/manager/pending-spool-shard.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/manager/prompt-settings.mjs +598 -0
- package/src/runtime/agent/orchestrator/session/manager/prompt-utils.mjs +19 -0
- package/src/runtime/agent/orchestrator/session/manager/rules-cache.mjs +19 -10
- package/src/runtime/agent/orchestrator/session/manager/runtime-liveness.mjs +8 -1
- package/src/runtime/agent/orchestrator/session/manager/session-close.mjs +5 -0
- package/src/runtime/agent/orchestrator/session/manager/session-fallback-title.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/manager/session-lifecycle.mjs +31 -0
- package/src/runtime/agent/orchestrator/session/manager/session-lock.mjs +31 -0
- package/src/runtime/agent/orchestrator/session/manager/session-prompt-composition.mjs +42 -6
- package/src/runtime/agent/orchestrator/session/manager/session-record.mjs +2 -0
- package/src/runtime/agent/orchestrator/session/manager/tool-resolution.mjs +11 -1
- package/src/runtime/agent/orchestrator/session/manager/turn-checkpoint-context.mjs +8 -9
- package/src/runtime/agent/orchestrator/session/manager/turn-checkpoint-journal.mjs +339 -88
- package/src/runtime/agent/orchestrator/session/manager/turn-checkpoint-recovery.mjs +135 -11
- package/src/runtime/agent/orchestrator/session/manager/turn-checkpoint.mjs +377 -104
- package/src/runtime/agent/orchestrator/session/manager/turn-durability.mjs +144 -0
- package/src/runtime/agent/orchestrator/session/manager/turn-interruption.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/manager/usage-metrics.mjs +4 -0
- package/src/runtime/agent/orchestrator/session/manager.mjs +6 -0
- package/src/runtime/agent/orchestrator/session/mixy-name.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/pre-send-compact.mjs +8 -1
- package/src/runtime/agent/orchestrator/session/save-session-worker.mjs +5 -1
- package/src/runtime/agent/orchestrator/session/store/canonical-reader.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/store/liveness-veto.mjs +2 -2
- package/src/runtime/agent/orchestrator/session/store/save-worker.mjs +23 -2
- package/src/runtime/agent/orchestrator/session/store/sweep/sub-agent-retention.mjs +3 -3
- package/src/runtime/agent/orchestrator/session/store/transcript-durability.mjs +88 -0
- package/src/runtime/agent/orchestrator/session/store-agent-worker-rows.mjs +5 -0
- package/src/runtime/agent/orchestrator/session/store-summary-log.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/store-transcript-projection.mjs +14 -5
- package/src/runtime/agent/orchestrator/session/store-transcript-worker.mjs +2 -2
- package/src/runtime/agent/orchestrator/session/store.mjs +17 -6
- package/src/runtime/agent/orchestrator/session/synthetic-user-envelope.mjs +7 -1
- package/src/runtime/agent/orchestrator/session/tail-reminder-rules.mjs +9 -1
- package/src/runtime/agent/orchestrator/session/transcript-restore/agent-envelope.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/transcript-restore/restore.mjs +3 -1
- package/src/runtime/agent/orchestrator/session/transcript-restore/user-text.mjs +2 -2
- package/src/runtime/agent/orchestrator/stall-policy.mjs +3 -5
- package/src/runtime/agent/orchestrator/tools/builtin/bash-tool/backgrounded-result.mjs +4 -1
- package/src/runtime/agent/orchestrator/tools/builtin/bash-tool/misuse-guard.mjs +21 -3
- package/src/runtime/agent/orchestrator/tools/builtin/bash-tool/result-format.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/builtin/bash-tool/worktree-add-guard.mjs +77 -0
- package/src/runtime/agent/orchestrator/tools/builtin/bash-tool.mjs +0 -1
- package/src/runtime/agent/orchestrator/tools/builtin/git-command-tool.mjs +7 -3
- package/src/runtime/agent/orchestrator/tools/builtin/git-worktree-tool.mjs +27 -9
- package/src/runtime/agent/orchestrator/tools/builtin/lib/search-input-helpers.mjs +2 -2
- package/src/runtime/agent/orchestrator/tools/builtin/lib/shell-output-silence.mjs +64 -0
- package/src/runtime/agent/orchestrator/tools/builtin/lib/shell-task-output.mjs +20 -6
- package/src/runtime/agent/orchestrator/tools/builtin/read-range-index.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/builtin/read-single-fast-paths.mjs +0 -1
- package/src/runtime/agent/orchestrator/tools/builtin/search-tool.mjs +0 -10
- package/src/runtime/agent/orchestrator/tools/builtin/shell-jobs.mjs +1 -2
- package/src/runtime/agent/orchestrator/tools/builtin/task-tool.mjs +12 -1
- package/src/runtime/agent/orchestrator/tools/builtin.mjs +1 -24
- package/src/runtime/agent/orchestrator/tools/code-graph/graph-binary/child-kill.mjs +4 -3
- package/src/runtime/agent/orchestrator/tools/code-graph/graph-binary.mjs +1 -2
- package/src/runtime/agent/orchestrator/tools/code-graph/modes/calls.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/code-graph/modes/symbols.mjs +2 -2
- package/src/runtime/agent/orchestrator/tools/code-graph/search.mjs +4 -5
- package/src/runtime/agent/orchestrator/tools/code-graph/symbol-index.mjs +3 -4
- package/src/runtime/agent/orchestrator/tools/code-graph.mjs +4 -22
- package/src/runtime/agent/orchestrator/tools/lib/shell-descendants.mjs +2 -2
- package/src/runtime/agent/orchestrator/tools/lib/shell-run-state.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/shell-command.mjs +0 -4
- package/src/runtime/agent/orchestrator/tools/shell-policy.mjs +0 -1
- package/src/runtime/attachments/attachment-reference.mjs +1 -1
- package/src/runtime/attachments/pdf-extract.mjs +1 -1
- package/src/runtime/attachments/store.d.mts +1 -0
- package/src/runtime/attachments/store.mjs +2 -2
- package/src/runtime/channels/lib/config-reload-watch.mjs +42 -0
- package/src/runtime/channels/lib/owned-runtime/config-reload.mjs +29 -9
- package/src/runtime/channels/lib/routines-db.mjs +35 -0
- package/src/runtime/channels/lib/scheduler.mjs +33 -0
- package/src/runtime/channels/lib/schedules-db.mjs +15 -4
- package/src/runtime/channels/lib/webhook/session-dispatch.mjs +4 -1
- package/src/runtime/channels/lib/webhooks-db.mjs +13 -3
- package/src/runtime/channels/lib/whisper-server.mjs +12 -12
- package/src/runtime/channels/lib/worker-main.mjs +9 -31
- package/src/runtime/computer-bridge/action-schema.mjs +2 -2
- package/src/runtime/computer-bridge/core-actions.mjs +16 -2
- package/src/runtime/computer-bridge/linux-readiness.mjs +10 -14
- package/src/runtime/computer-bridge/result-canonical.mjs +6 -0
- package/src/runtime/connectors/connector-accounts-mcp.mjs +169 -33
- package/src/runtime/connectors/gmail-app-password.mjs +2 -2
- package/src/runtime/connectors/google-mcp.mjs +1 -1
- package/src/runtime/effort-judge/judge-client.mjs +2 -2
- package/src/runtime/effort-judge/judge-input.mjs +4 -4
- package/src/runtime/explore/explorer.mjs +0 -5
- package/src/runtime/explore/tool.mjs +3 -3
- package/src/runtime/local-provider/hardware.mjs +1 -1
- package/src/runtime/media/adapters/codex-image.mjs +3 -3
- package/src/runtime/media/adapters/gemini-video.mjs +1 -1
- package/src/runtime/media/media-usage.mjs +1 -1
- package/src/runtime/media/store.mjs +1 -1
- package/src/runtime/memory/index.mjs +11 -1
- package/src/runtime/memory/lib/embedding-reindex.mjs +27 -0
- package/src/runtime/memory/lib/memory-embed.mjs +83 -14
- package/src/runtime/memory/lib/memory-process-lock.mjs +159 -36
- package/src/runtime/memory/lib/memory-text-utils.mjs +6 -1
- package/src/runtime/memory/lib/memory.mjs +17 -0
- package/src/runtime/memory/lib/pg/process.mjs +1 -1
- package/src/runtime/memory/lib/pg/supervisor.mjs +16 -96
- package/src/runtime/memory/lib/recall-hybrid/hybrid-sql.mjs +12 -3
- package/src/runtime/memory/tool-defs.mjs +1 -1
- package/src/runtime/office/authoring/docx-html-runner.mjs +1 -1
- package/src/runtime/office/authoring/pptx-author-action.mjs +1 -1
- package/src/runtime/office/authoring/xlsx-html-build.mjs +1 -1
- package/src/runtime/office/authoring/xlsx-html-runner.mjs +1 -1
- package/src/runtime/office/capabilities.mjs +1 -1
- package/src/runtime/office/core/office-core.mjs +1 -1
- package/src/runtime/office/design/content-model.mjs +3 -3
- package/src/runtime/office/design/docx/design-docx/section.mjs +6 -6
- package/src/runtime/office/design/xlsx/design-xlsx-components.mjs +1 -1
- package/src/runtime/office/design/xlsx/design-xlsx.mjs +1 -1
- package/src/runtime/office/pdf/ocr-engine.mjs +1 -1
- package/src/runtime/office/pdf/pdf-writer.mjs +4 -4
- package/src/runtime/office/portable/portable-docx-operations.mjs +2 -2
- package/src/runtime/office/portable/portable-soffice.mjs +8 -6
- package/src/runtime/office/portable/xlsx-contract.mjs +1 -1
- package/src/runtime/shared/atomic-file.d.mts +8 -0
- package/src/runtime/shared/background-tasks.mjs +22 -4
- package/src/runtime/shared/background-wait.mjs +66 -0
- package/src/runtime/shared/child-guardian.mjs +17 -7
- package/src/runtime/shared/config.mjs +313 -16
- package/src/runtime/shared/connector-catalog.d.mts +4 -5
- package/src/runtime/shared/connector-catalog.mjs +11 -1
- package/src/runtime/shared/file-lock.mjs +8 -3
- package/src/runtime/shared/git-runner.mjs +7 -2
- package/src/runtime/shared/idle-gc.mjs +30 -7
- package/src/runtime/shared/llm/http-agent.mjs +8 -5
- package/src/runtime/shared/llm/system-proxy.mjs +2 -1
- package/src/runtime/shared/llm/usage-accounting.mjs +110 -19
- package/src/runtime/shared/llm/usage-context.mjs +1 -1
- package/src/runtime/shared/llm/usage-ledger-quota.mjs +33 -12
- package/src/runtime/shared/llm/usage-ledger-requests.mjs +183 -0
- package/src/runtime/shared/llm/usage-ledger-rollup.mjs +90 -10
- package/src/runtime/shared/llm/usage-ledger-worker.mjs +2 -0
- package/src/runtime/shared/llm/usage-ledger.mjs +60 -1
- package/src/runtime/shared/llm/usage-request-status.mjs +48 -0
- package/src/runtime/shared/llm/usage-rollup.mjs +48 -0
- package/src/runtime/shared/maintenance-schedule.mjs +109 -0
- package/src/runtime/shared/process-runner.mjs +8 -4
- package/src/runtime/shared/routine-trigger.d.mts +13 -0
- package/src/runtime/shared/routine-trigger.mjs +34 -0
- package/src/runtime/shared/run-child.d.mts +2 -1
- package/src/runtime/shared/run-child.mjs +70 -18
- package/src/runtime/shared/session-scratch.mjs +14 -2
- package/src/runtime/shared/shipped-definitions.mjs +7 -1
- package/src/runtime/shared/tool-card-model.golden.json +3 -12
- package/src/runtime/shared/tool-execution-contract.mjs +2 -0
- package/src/runtime/shared/tool-result-summary.mjs +1 -1
- package/src/runtime/shared/tool-work-units.mjs +31 -6
- package/src/runtime/shared/turn-snapshot.mjs +26 -4
- package/src/runtime/shared/turn-worktree-snapshot.mjs +6 -11
- package/src/runtime/shared/worker-requests.mjs +17 -3
- package/src/runtime/shared/worktrees/branch-management.mjs +1 -5
- package/src/runtime/shared/worktrees/contract.mjs +16 -6
- package/src/runtime/shared/worktrees/dependencies.mjs +127 -89
- package/src/runtime/shared/worktrees/disk.mjs +79 -2
- package/src/runtime/shared/worktrees/git.mjs +44 -11
- package/src/runtime/shared/worktrees/include.mjs +6 -4
- package/src/runtime/shared/worktrees/maintenance.mjs +422 -30
- package/src/runtime/shared/worktrees/manager.mjs +772 -75
- package/src/runtime/shared/worktrees/settings.mjs +33 -7
- package/src/runtime/shared/worktrees/test-support.mjs +5 -1
- package/src/runtime/shared/worktrees/worker-snapshots.mjs +82 -0
- package/src/runtime/tidy/process.mjs +2 -1
- package/src/runtime/web-search/index.mjs +3 -22
- package/src/runtime/web-search/lib/web-tools.mjs +2 -2
- package/src/runtime/web-search/tool-defs.mjs +17 -26
- package/src/session-runtime/agent-home-delivery.mjs +76 -8
- package/src/session-runtime/agent-profile-changes.mjs +55 -4
- package/src/session-runtime/agent-task-sessions.mjs +63 -22
- package/src/session-runtime/boot/apis.mjs +42 -4
- package/src/session-runtime/boot/begin.mjs +2 -0
- package/src/session-runtime/boot/config.mjs +10 -1
- package/src/session-runtime/boot/facade.mjs +1 -0
- package/src/session-runtime/boot/providers.mjs +70 -3
- package/src/session-runtime/boot/session.mjs +2 -0
- package/src/session-runtime/boot/tools.mjs +75 -25
- package/src/session-runtime/channel-config-api.mjs +1 -0
- package/src/session-runtime/config-change-effects.mjs +179 -0
- package/src/session-runtime/config-lifecycle/config-writers.mjs +1 -0
- package/src/session-runtime/config-lifecycle.mjs +160 -24
- package/src/session-runtime/conversation-import/discovery.mjs +86 -7
- package/src/session-runtime/conversation-import/service.mjs +3 -2
- package/src/session-runtime/goal-facade-api.mjs +49 -3
- package/src/session-runtime/internal-tool-executor/ask-user-tool.mjs +5 -57
- package/src/session-runtime/internal-tool-executor/bridge-tools.mjs +3 -2
- package/src/session-runtime/internal-tool-executor/feature-tools.mjs +3 -11
- package/src/session-runtime/internal-tool-executor/workspace-tools.mjs +18 -4
- package/src/session-runtime/internal-tool-executor.mjs +12 -19
- package/src/session-runtime/lifecycle/cold-heir.mjs +7 -0
- package/src/session-runtime/lifecycle/memory-ingest.mjs +3 -3
- package/src/session-runtime/lifecycle/session-switch/session-delete.mjs +53 -5
- package/src/session-runtime/lifecycle/session-switch.mjs +13 -2
- package/src/session-runtime/lifecycle/teardown/session-close.mjs +4 -4
- package/src/session-runtime/lifecycle-api.mjs +1 -0
- package/src/session-runtime/mcp-glue/server-catalog.mjs +14 -3
- package/src/session-runtime/mcp-glue/server-connection.mjs +34 -8
- package/src/session-runtime/model-route/route-persist.mjs +12 -4
- package/src/session-runtime/model-route/set-route.mjs +40 -7
- package/src/session-runtime/native-web-search/routes.mjs +3 -3
- package/src/session-runtime/provider-auth/refresh.mjs +6 -3
- package/src/session-runtime/provider-auth/setup.mjs +1 -1
- package/src/session-runtime/provider-models/row-hydration.mjs +2 -0
- package/src/session-runtime/provider-readiness.mjs +53 -4
- package/src/session-runtime/resource-api.mjs +1 -1
- package/src/session-runtime/resource-extension-sync.mjs +4 -8
- package/src/session-runtime/resource-mcp-connector-accounts.mjs +5 -1
- package/src/session-runtime/resource-mcp-secrets.mjs +3 -3
- package/src/session-runtime/resource-plugins-api.mjs +4 -0
- package/src/session-runtime/routine-executor.mjs +152 -0
- package/src/session-runtime/routine-home-turn.mjs +46 -5
- package/src/session-runtime/routine-owner.mjs +9 -3
- package/src/session-runtime/runtime-facade.mjs +5 -0
- package/src/session-runtime/runtime-feature-gates.mjs +2 -11
- package/src/session-runtime/schedule-session-run.mjs +1 -0
- package/src/session-runtime/services/agent-task-status.mjs +29 -1
- package/src/session-runtime/services/agent-tool/job-task-reconcile.mjs +6 -1
- package/src/session-runtime/services/agent-tool/job-views/session-progress.mjs +10 -0
- package/src/session-runtime/services/agent-tool/render.mjs +6 -1
- package/src/session-runtime/services/agent-tool/send-flow.mjs +110 -6
- package/src/session-runtime/services/agent-tool/spawn-flow/job-start.mjs +12 -0
- package/src/session-runtime/services/agent-tool/spawn-flow/spawn-plan.mjs +5 -0
- package/src/session-runtime/services/agent-tool/spawn-flow/spawn-run.mjs +24 -6
- package/src/session-runtime/services/agent-tool.mjs +51 -1
- package/src/session-runtime/services/channel-admin.mjs +62 -3
- package/src/session-runtime/services/hook-bus/command-handler.mjs +7 -11
- package/src/session-runtime/services/plugin-admin.mjs +50 -7
- package/src/session-runtime/services/provider-admin.mjs +5 -0
- package/src/session-runtime/services/seeds.mjs +7 -0
- package/src/session-runtime/services/usage-stats-model.mjs +32 -11
- package/src/session-runtime/session-create/materialize.mjs +4 -2
- package/src/session-runtime/session-create/session-options.mjs +2 -0
- package/src/session-runtime/settings-builtin-tools-api.mjs +1 -9
- package/src/session-runtime/setup-tool/agent-settings-actions.mjs +1 -1
- package/src/session-runtime/setup-tool/connector-widen-approval.mjs +1 -1
- package/src/session-runtime/setup-tool/executor.mjs +9 -2
- package/src/session-runtime/setup-tool/extended-actions.mjs +3 -1
- package/src/session-runtime/setup-tool/settings-contract.mjs +30 -2
- package/src/session-runtime/setup-tool/tool-defs.mjs +26 -1
- package/src/session-runtime/tool-policy/agent-profile-fold.mjs +40 -43
- package/src/session-runtime/tool-policy/mode-switch.mjs +1 -1
- package/src/session-runtime/tool-policy/policy-stage.mjs +106 -8
- package/src/session-runtime/tool-policy/workflow-overlay.mjs +2 -1
- package/src/session-runtime/tool-policy-refresh.mjs +182 -5
- package/src/session-runtime/tool-surface.mjs +38 -1
- package/src/session-runtime/turn/agent-ops.mjs +10 -2
- package/src/session-runtime/turn/session-ops.mjs +2 -0
- package/src/session-runtime/turn/turn-run/turn-prepare.mjs +5 -0
- package/src/session-runtime/turn/turn-run.mjs +1 -1
- package/src/session-runtime/usage-stats-api.mjs +117 -1
- package/src/session-runtime/webhook-session-run.mjs +2 -0
- package/src/session-runtime/workflow-agents-api/agent-connectors.mjs +37 -33
- package/src/session-runtime/workflow-agents-api/agent-editor.mjs +183 -23
- package/src/session-runtime/workflow-agents-api/agent-route.mjs +3 -10
- package/src/session-runtime/workflow-agents-api/instruction-files.mjs +165 -0
- package/src/session-runtime/workflow-agents-api/style-and-mode.mjs +5 -4
- package/src/session-runtime/workflow-agents-api/workflow-packs.mjs +2 -3
- package/src/session-runtime/workflow-agents-api.mjs +2 -0
- package/src/session-runtime/workspace/project-branches.mjs +1 -1
- package/src/session-runtime/workspace/session-view.mjs +1 -1
- package/src/session-runtime/workspace/transitions.mjs +20 -4
- package/src/session-runtime/workspace/worktree-maintenance.mjs +126 -6
- package/src/session-runtime/workspace/worktree-setup.mjs +13 -1
- package/src/session-runtime/workspace/worktree-tool.mjs +16 -0
- package/src/standalone/daemon-agent-control.mjs +25 -8
- package/src/standalone/daemon-desktop-runtime.mjs +6 -2
- package/src/standalone/daemon-lag-profiler.mjs +7 -7
- package/src/standalone/daemon.mjs +54 -2
- package/src/standalone/local-session-runtime.mjs +16 -0
- package/src/standalone/session-client/daemon-unavailable.mjs +1 -1
- package/src/standalone/session-protocol.mjs +12 -0
- package/src/standalone/session-service/agent-route-follow.mjs +23 -20
- package/src/standalone/session-service/agent-tree/agent-turns.mjs +18 -6
- package/src/standalone/session-service/quota-resume.mjs +9 -0
- package/src/standalone/session-service/retention/busy.mjs +3 -2
- package/src/standalone/session-service/session-calls/session-action.mjs +51 -1
- package/src/standalone/session-service/session-calls/session-turns.mjs +37 -18
- package/src/standalone/session-service/session-calls/turn-gate.mjs +34 -0
- package/src/standalone/session-service/session-calls.mjs +2 -1
- package/src/tui/App.jsx +8 -0
- package/src/tui/app/clipboard.mjs +1 -1
- package/src/tui/app/create-app-pickers.mjs +2 -0
- package/src/tui/app/doctor.mjs +2 -2
- package/src/tui/app/model-picker/model-footer.mjs +1 -1
- package/src/tui/app/model-picker/provider-models-list.mjs +7 -3
- package/src/tui/app/model-picker/route-selection/fast-parameters.mjs +23 -3
- package/src/tui/app/model-picker/route-selection.mjs +1 -0
- package/src/tui/app/panel-signature.mjs +1 -1
- package/src/tui/app/settings-picker.mjs +53 -8
- package/src/tui/app/shell-layout/row-budgets.mjs +2 -2
- package/src/tui/app/slash-commands.mjs +1 -1
- package/src/tui/app/slash-dispatch/route-commands.mjs +1 -1
- package/src/tui/app/slash-dispatch/session-commands.mjs +1 -1
- package/src/tui/app/use-prompt-queue-history.mjs +2 -2
- package/src/tui/app/use-transcript-activity.mjs +1 -1
- package/src/tui/app/use-transcript-window/geometry.mjs +1 -1
- package/src/tui/components/prompt-input/escape-policy.d.mts +0 -1
- package/src/tui/components/prompt-input/escape-policy.mjs +1 -1
- package/src/tui/components/question-panel-model.mjs +4 -4
- package/src/tui/components/tool-execution/standard-card.jsx +3 -4
- package/src/tui/components/user-message-skills.mjs +1 -1
- package/src/tui/dist/index.mjs +350 -37
- package/src/tui/markdown/render-ansi.mjs +1 -1
- package/src/tui/session/agent-job-feed/notification-router.mjs +10 -0
- package/src/tui/session/agent-job-feed.mjs +2 -0
- package/src/tui/session/context-state.mjs +3 -0
- package/src/tui/session/quota-resume.mjs +1 -1
- package/src/tui/session/session-api/integrations.mjs +3 -0
- package/src/tui/session/session-api/lifecycle/dispose.mjs +1 -0
- package/src/tui/session/session-api/lifecycle/session-reset.mjs +7 -0
- package/src/tui/session/session-api/routes-agent-definitions.mjs +5 -0
- package/src/tui/session/session-api/worktree.mjs +13 -1
- package/src/tui/session/session-flow/drain.mjs +11 -14
- package/src/tui/session/tool-approval-settle.mjs +24 -4
- package/src/tui/session/tool-approval.mjs +35 -10
- package/src/tui/session/tool-card-results/grouped-result.mjs +2 -2
- package/src/tui/session/turn-quiet.mjs +1 -1
- package/src/tui/session/turn.mjs +3 -0
- package/src/tui/session/worktree-setup-notice.mjs +1 -1
- package/src/tui/spinner-meta.mjs +3 -3
- package/src/tui/spinner-verbs.mjs +2 -2
- package/src/defaults/skills/goal-management/SKILL.md +0 -169
- package/src/runtime/agent/orchestrator/runtime-core/goal-tasks.mjs +0 -156
- package/src/session-runtime/goal-tasks.mjs +0 -1
|
@@ -13,6 +13,35 @@ export const CUSTOM_REASONING_WIRE_FORMATS = Object.freeze(['standard', 'deepsee
|
|
|
13
13
|
export const CUSTOM_PROVIDER_AUTH_MODES = Object.freeze(['key', 'none']);
|
|
14
14
|
export const CUSTOM_MODEL_OVERRIDE_LIMIT = 500;
|
|
15
15
|
export const CUSTOM_HEADER_LIMIT = 64;
|
|
16
|
+
// Serialized size cap of one extra-request JSON object (provider or model).
|
|
17
|
+
export const CUSTOM_REQUEST_BODY_MAX_CHARS = 16384;
|
|
18
|
+
// What the Chat, Responses and Messages wires build themselves (body fields
|
|
19
|
+
// the app sets, or whose override would break replay, tool use or streaming).
|
|
20
|
+
export const CUSTOM_RESERVED_BODY_KEYS = Object.freeze(
|
|
21
|
+
new Set([
|
|
22
|
+
'model',
|
|
23
|
+
'messages',
|
|
24
|
+
'input',
|
|
25
|
+
'system',
|
|
26
|
+
'instructions',
|
|
27
|
+
'tools',
|
|
28
|
+
'tool_choice',
|
|
29
|
+
'parallel_tool_calls',
|
|
30
|
+
'stream',
|
|
31
|
+
'stream_options',
|
|
32
|
+
'previous_response_id',
|
|
33
|
+
'store',
|
|
34
|
+
'include',
|
|
35
|
+
'prompt_cache_key',
|
|
36
|
+
'max_tokens',
|
|
37
|
+
'max_output_tokens',
|
|
38
|
+
'max_completion_tokens',
|
|
39
|
+
])
|
|
40
|
+
);
|
|
41
|
+
// Transport headers the HTTP client owns; model-level headers may not set them.
|
|
42
|
+
export const CUSTOM_MODEL_REFUSED_HEADERS = Object.freeze(
|
|
43
|
+
new Set(['content-type', 'content-length', 'host', 'connection', 'transfer-encoding', 'proxy-authorization'])
|
|
44
|
+
);
|
|
16
45
|
|
|
17
46
|
const UNSAFE_KEYS = new Set(['__proto__', 'constructor', 'prototype']);
|
|
18
47
|
const MAX_MODEL_ID = 256;
|
|
@@ -74,6 +103,8 @@ const OVERRIDE_KEYS = new Set([
|
|
|
74
103
|
'maxOutputTokens',
|
|
75
104
|
'supportsVision',
|
|
76
105
|
'reasoning',
|
|
106
|
+
'requestBody',
|
|
107
|
+
'requestHeaders',
|
|
77
108
|
]);
|
|
78
109
|
const REASONING_KEYS = new Set(['levels', 'wireFormat', 'wireValues', 'replay']);
|
|
79
110
|
const DISCOVERY_KEYS = new Set(['newModelsHidden']);
|
|
@@ -93,6 +124,7 @@ const V2_TOP_LEVEL_KEYS = new Set([
|
|
|
93
124
|
'wires',
|
|
94
125
|
'modelWires',
|
|
95
126
|
'headers',
|
|
127
|
+
'requestBody',
|
|
96
128
|
'id',
|
|
97
129
|
'apiKey',
|
|
98
130
|
'apiKeyEnv',
|
|
@@ -244,6 +276,10 @@ function normalizeOverride(id, raw, protocol, legacy) {
|
|
|
244
276
|
const reasoning = normalizeReasoning(raw.reasoning, `${label}.reasoning`, protocol);
|
|
245
277
|
if (Object.keys(reasoning).length) out.reasoning = reasoning;
|
|
246
278
|
}
|
|
279
|
+
const requestBody = normalizeRequestBody(raw.requestBody, `${label}.requestBody`);
|
|
280
|
+
if (Object.keys(requestBody).length) out.requestBody = requestBody;
|
|
281
|
+
const requestHeaders = normalizeHeaders(raw.requestHeaders, `${label}.requestHeaders`, CUSTOM_MODEL_REFUSED_HEADERS);
|
|
282
|
+
if (Object.keys(requestHeaders).length) out.requestHeaders = requestHeaders;
|
|
247
283
|
return out;
|
|
248
284
|
}
|
|
249
285
|
|
|
@@ -307,31 +343,98 @@ function normalizeModelWires(raw, protocol, wires) {
|
|
|
307
343
|
// `headers`: extra HTTP headers sent with every request to the endpoint
|
|
308
344
|
// (inference, model discovery, connection test). Names are case-insensitive
|
|
309
345
|
// tokens; the credential headers belong to the API key field.
|
|
310
|
-
function normalizeHeaders(raw) {
|
|
346
|
+
function normalizeHeaders(raw, label = 'headers', refused = AUTH_HEADERS) {
|
|
311
347
|
if (raw === undefined) return {};
|
|
312
|
-
if (!isPlainObject(raw)) fail(
|
|
348
|
+
if (!isPlainObject(raw)) fail(`${label} must be an object of header names to string values`);
|
|
313
349
|
const names = Object.keys(raw);
|
|
314
|
-
if (names.length > CUSTOM_HEADER_LIMIT) fail(`at most ${CUSTOM_HEADER_LIMIT}
|
|
350
|
+
if (names.length > CUSTOM_HEADER_LIMIT) fail(`at most ${CUSTOM_HEADER_LIMIT} ${label} are allowed`);
|
|
315
351
|
const seen = new Set();
|
|
316
352
|
const entries = [];
|
|
317
353
|
for (const name of names) {
|
|
318
354
|
if (name.length > MAX_HEADER_TEXT || !HEADER_NAME.test(name))
|
|
319
|
-
fail(
|
|
355
|
+
fail(`${label} has an invalid header name: ${JSON.stringify(name.slice(0, 64))}`);
|
|
320
356
|
const lower = name.toLowerCase();
|
|
321
|
-
if (AUTH_HEADERS.has(lower)) fail(
|
|
322
|
-
if (
|
|
357
|
+
if (AUTH_HEADERS.has(lower)) fail(`${label} must not set ${name}: authentication belongs to the API key field`);
|
|
358
|
+
if (refused.has(lower)) fail(`${label} must not set ${name}: the app owns this header`);
|
|
359
|
+
if (seen.has(lower)) fail(`${label} has duplicate header: ${name}`);
|
|
323
360
|
seen.add(lower);
|
|
324
|
-
if (typeof raw[name] !== 'string') fail(
|
|
361
|
+
if (typeof raw[name] !== 'string') fail(`${label}.${name} must be a string`);
|
|
325
362
|
// Validate before trimming, and trim only HTTP whitespace (space, tab), so
|
|
326
363
|
// CR/LF is refused rather than stripped and other characters are kept.
|
|
327
|
-
if (!HEADER_VALUE.test(raw[name])) fail(
|
|
364
|
+
if (!HEADER_VALUE.test(raw[name])) fail(`${label}.${name} has an invalid value`);
|
|
328
365
|
const value = raw[name].replace(/^[ \t]+|[ \t]+$/g, '');
|
|
329
|
-
if (value.length > MAX_HEADER_TEXT) fail(
|
|
366
|
+
if (value.length > MAX_HEADER_TEXT) fail(`${label}.${name} has an invalid value`);
|
|
330
367
|
entries.push([name, value]);
|
|
331
368
|
}
|
|
332
369
|
return Object.fromEntries(entries);
|
|
333
370
|
}
|
|
334
371
|
|
|
372
|
+
// `requestBody` (provider and model): extra JSON request fields. A shallow
|
|
373
|
+
// object, size-capped; the keys the app builds the request from can never be set here.
|
|
374
|
+
function normalizeRequestBody(raw, label) {
|
|
375
|
+
if (raw === undefined) return {};
|
|
376
|
+
if (!isPlainObject(raw)) fail(`${label} must be a JSON object`);
|
|
377
|
+
let size;
|
|
378
|
+
try {
|
|
379
|
+
size = JSON.stringify(raw)?.length;
|
|
380
|
+
} catch {
|
|
381
|
+
fail(`${label} must be JSON-serializable`);
|
|
382
|
+
}
|
|
383
|
+
if (!Number.isInteger(size)) fail(`${label} must be JSON-serializable`);
|
|
384
|
+
if (size > CUSTOM_REQUEST_BODY_MAX_CHARS)
|
|
385
|
+
fail(`${label} must be at most ${CUSTOM_REQUEST_BODY_MAX_CHARS} characters`);
|
|
386
|
+
const out = {};
|
|
387
|
+
for (const key of Object.keys(raw)) {
|
|
388
|
+
if (UNSAFE_KEYS.has(key)) fail(`${label} has an unsafe key: ${key}`);
|
|
389
|
+
if (CUSTOM_RESERVED_BODY_KEYS.has(key)) fail(`${label} must not set ${key}: the app owns this field`);
|
|
390
|
+
out[key] = raw[key];
|
|
391
|
+
}
|
|
392
|
+
return out;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* The extra request fields and headers for one model of a normalized config:
|
|
397
|
+
* provider JSON, then model JSON over it (shallow); provider headers, then
|
|
398
|
+
* model headers over them. Reserved keys are stripped again here, so a stored
|
|
399
|
+
* config that somehow carries one still cannot override the app. Headers are
|
|
400
|
+
* the model layer only: the provider's ride the engine's default headers.
|
|
401
|
+
*/
|
|
402
|
+
export function resolveCustomRequestExtras(config, model) {
|
|
403
|
+
const override =
|
|
404
|
+
config?.modelOverrides && Object.hasOwn(config.modelOverrides, model) ? config.modelOverrides[model] : null;
|
|
405
|
+
const body = {};
|
|
406
|
+
for (const layer of [config?.requestBody, override?.requestBody]) {
|
|
407
|
+
for (const [key, value] of Object.entries(layer || {})) {
|
|
408
|
+
if (!CUSTOM_RESERVED_BODY_KEYS.has(key) && !UNSAFE_KEYS.has(key)) body[key] = structuredClone(value);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
const headers = {};
|
|
412
|
+
for (const [name, value] of Object.entries(override?.requestHeaders || {})) {
|
|
413
|
+
const lower = name.toLowerCase();
|
|
414
|
+
if (!AUTH_HEADERS.has(lower) && !CUSTOM_MODEL_REFUSED_HEADERS.has(lower)) headers[name] = value;
|
|
415
|
+
}
|
|
416
|
+
return { body, headers };
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/** `params` (the finished request body) with the extras layered over it; reserved keys keep the app's value. */
|
|
420
|
+
export function applyCustomRequestBody(params, config, model) {
|
|
421
|
+
const { body } = resolveCustomRequestExtras(config, model ?? params?.model);
|
|
422
|
+
for (const [key, value] of Object.entries(body)) params[key] = value;
|
|
423
|
+
return params;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
/** Per-request headers: the model's extra headers under the caller's own. */
|
|
427
|
+
export function customRequestHeaders(config, model, requestHeaders) {
|
|
428
|
+
const { headers } = resolveCustomRequestExtras(config, model);
|
|
429
|
+
if (!Object.keys(headers).length) return requestHeaders;
|
|
430
|
+
if (requestHeaders instanceof Headers || Array.isArray(requestHeaders)) {
|
|
431
|
+
const merged = new Headers(headers);
|
|
432
|
+
for (const [name, value] of new Headers(requestHeaders)) merged.set(name, value);
|
|
433
|
+
return merged;
|
|
434
|
+
}
|
|
435
|
+
return { ...headers, ...(requestHeaders || {}) };
|
|
436
|
+
}
|
|
437
|
+
|
|
335
438
|
// Legacy (pre-v2) `models: [{ id, name?, contextWindow?, maxOutputTokens? }]`
|
|
336
439
|
// become manual, visible overrides; their presence hides newly discovered ids.
|
|
337
440
|
function migrateLegacy(input) {
|
|
@@ -374,6 +477,7 @@ export function normalizeCustomProviderConfig(input) {
|
|
|
374
477
|
if (input.wires !== undefined || input.modelWires !== undefined)
|
|
375
478
|
fail('wires and modelWires require schemaVersion 2');
|
|
376
479
|
if (input.headers !== undefined) fail('headers require schemaVersion 2');
|
|
480
|
+
if (input.requestBody !== undefined) fail('requestBody requires schemaVersion 2');
|
|
377
481
|
source = migrateLegacy(input);
|
|
378
482
|
} else if (Number.isInteger(version) && version > CUSTOM_PROVIDER_SCHEMA_VERSION)
|
|
379
483
|
fail(`unsupported schemaVersion ${version}; update mixdog to use this provider`);
|
|
@@ -407,6 +511,7 @@ export function normalizeCustomProviderConfig(input) {
|
|
|
407
511
|
const wires = normalizeWires(source.wires, protocol);
|
|
408
512
|
const modelWires = normalizeModelWires(source.modelWires, protocol, wires);
|
|
409
513
|
const headers = normalizeHeaders(source.headers);
|
|
514
|
+
const requestBody = normalizeRequestBody(source.requestBody, 'requestBody');
|
|
410
515
|
return {
|
|
411
516
|
type: 'custom',
|
|
412
517
|
schemaVersion: CUSTOM_PROVIDER_SCHEMA_VERSION,
|
|
@@ -417,6 +522,7 @@ export function normalizeCustomProviderConfig(input) {
|
|
|
417
522
|
auth,
|
|
418
523
|
...(apiKeyEnv && auth === 'key' ? { apiKeyEnv } : {}),
|
|
419
524
|
...(Object.keys(headers).length ? { headers } : {}),
|
|
525
|
+
...(Object.keys(requestBody).length ? { requestBody } : {}),
|
|
420
526
|
discovery: { newModelsHidden },
|
|
421
527
|
modelOverrides: normalizeOverrides(source.modelOverrides, protocol, legacy),
|
|
422
528
|
...(wires ? { wires } : {}),
|
|
@@ -471,6 +577,12 @@ function effectiveRow(base, override, { providerId, discovered, newModelsHidden
|
|
|
471
577
|
outputTokens: ov.maxOutputTokens ?? (Number(base.outputTokens) > 0 ? Number(base.outputTokens) : null),
|
|
472
578
|
hidden,
|
|
473
579
|
manual: ov.manual === true,
|
|
580
|
+
// What the model has without its own override (a reset restores these).
|
|
581
|
+
inherited: {
|
|
582
|
+
name: base.name || base.id,
|
|
583
|
+
contextWindow: Number(base.contextWindow) > 0 ? Number(base.contextWindow) : 0,
|
|
584
|
+
maxOutputTokens: Number(base.outputTokens) > 0 ? Number(base.outputTokens) : null,
|
|
585
|
+
},
|
|
474
586
|
// An explicit override (false included) beats the catalog; unset keeps the base.
|
|
475
587
|
...(typeof ov.supportsVision === 'boolean' ? { supportsVision: ov.supportsVision } : {}),
|
|
476
588
|
supportsReasoning: levels ? levels.some((level) => level !== 'none') : base.supportsReasoning === true,
|
|
@@ -217,8 +217,11 @@ export async function createCustomProvider(id, config) {
|
|
|
217
217
|
// The bound Messages engine reads the parent's model rows, so a routed
|
|
218
218
|
// Messages request carries the same row-driven thinking/effort as the
|
|
219
219
|
// Anthropic protocol.
|
|
220
|
-
if (provider.messagesEngine)
|
|
220
|
+
if (provider.messagesEngine) {
|
|
221
221
|
provider.messagesEngine.getCachedModelInfo = (model) => provider.getCachedModelInfo(model);
|
|
222
|
+
// …and the same extra request fields and headers.
|
|
223
|
+
provider.messagesEngine.customConfig = cfg;
|
|
224
|
+
}
|
|
222
225
|
provider.customConfig = cfg;
|
|
223
226
|
provider._customKeyless = keyless;
|
|
224
227
|
provider._applyCustomRows(provider._customRows());
|
|
@@ -52,7 +52,7 @@ function budgetSpec(model) {
|
|
|
52
52
|
|
|
53
53
|
// Levels documented for models whose ladder differs from the generic wire
|
|
54
54
|
// vocabulary (a catalog ladder, when declared, still takes precedence).
|
|
55
|
-
function
|
|
55
|
+
export function geminiDocumentedThinkingLevels(model) {
|
|
56
56
|
const bare = String(model || '')
|
|
57
57
|
.replace(/^models\//i, '')
|
|
58
58
|
.toLowerCase();
|
|
@@ -105,7 +105,7 @@ export function geminiThinkingConfig(model, opts = {}, { includeThoughts, provid
|
|
|
105
105
|
}
|
|
106
106
|
config.thinkingBudget = spec.efforts[level];
|
|
107
107
|
} else if (level) {
|
|
108
|
-
const supported = catalogThinkingLevels(model, provider) ??
|
|
108
|
+
const supported = catalogThinkingLevels(model, provider) ?? geminiDocumentedThinkingLevels(model) ?? LEVELS;
|
|
109
109
|
if (!supported.includes(level)) {
|
|
110
110
|
throw new TypeError(`${model} supports thinking levels ${supported.join(', ')}; received ${level}.`);
|
|
111
111
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A stream's success result carries its own generation window: from this
|
|
3
|
+
* stream's first output to its end. Usage accounting computes speed from it
|
|
4
|
+
* (usage-accounting.mjs), so a retried, reconnected or fallen-back send is
|
|
5
|
+
* timed by the stream that answered, never by an abandoned attempt or the
|
|
6
|
+
* backoff before it. A result without one (a non-streaming recovery, a
|
|
7
|
+
* stream that showed no output start) has no speed.
|
|
8
|
+
*/
|
|
9
|
+
export const generationWindow = (firstOutputAt) => (firstOutputAt ? { generationMs: Date.now() - firstOutputAt } : {});
|
|
@@ -24,6 +24,7 @@ import { compatFirstByteWindowMs, compatRetryOptions, withCompatRetryProfile } f
|
|
|
24
24
|
import { TIMEOUT_PHASE } from '../../../shared/provider-timeout-phase.mjs';
|
|
25
25
|
import { preparePdfTextForProvider } from './media-normalization.mjs';
|
|
26
26
|
import { customWireFormat, isCustomProviderName, resolveCustomReasoning } from './custom-reasoning.mjs';
|
|
27
|
+
import { applyCustomRequestBody, customRequestHeaders } from './custom-provider-config.mjs';
|
|
27
28
|
import { geminiAcceptedTools } from './gemini-schema.mjs';
|
|
28
29
|
import { acceptedWireTools } from './lib/claude-bridge-schema.mjs';
|
|
29
30
|
import { isGeminiFamilyModel } from './gemini-family.mjs';
|
|
@@ -124,15 +125,22 @@ export async function sendCompatChat(provider, messages, useModel, tools, opts)
|
|
|
124
125
|
});
|
|
125
126
|
applyCompatProviderChatOptions(params, provider.name, opts, provider.config, modelInfo);
|
|
126
127
|
profile?.applyParams?.(params, { opts, config: provider.config, modelInfo });
|
|
128
|
+
// A custom provider's own extra JSON goes over the reasoning fields; stream
|
|
129
|
+
// flags below and the app-owned keys stay the app's.
|
|
130
|
+
if (isCustom && provider.customConfig) applyCustomRequestBody(params, provider.customConfig, useModel);
|
|
127
131
|
const firstByteTimeoutMs = profile?.firstByteTimeoutMs || PROVIDER_FIRST_BYTE_TIMEOUT_MS;
|
|
128
132
|
const totalSignal = createPassthroughSignal(signal);
|
|
129
133
|
const cacheRouting = provider.name === 'xai' ? xaiCacheRouting(opts, params, tools || [], useModel) : null;
|
|
130
134
|
const cacheRoutingKey = cacheRouting?.key || null;
|
|
131
135
|
// xAI Chat pins a conversation to the server holding its cached prefix with
|
|
132
136
|
// the x-grok-conv-id header (the Responses equivalent is prompt_cache_key).
|
|
133
|
-
const
|
|
137
|
+
const callerHeaders = cacheRoutingKey
|
|
134
138
|
? { 'x-grok-conv-id': cacheRoutingKey, ...(opts.requestHeaders || {}) }
|
|
135
139
|
: opts.requestHeaders;
|
|
140
|
+
const requestHeaders =
|
|
141
|
+
isCustom && provider.customConfig
|
|
142
|
+
? customRequestHeaders(provider.customConfig, useModel, callerHeaders)
|
|
143
|
+
: callerHeaders;
|
|
136
144
|
params.stream = true;
|
|
137
145
|
params.stream_options = { include_usage: true };
|
|
138
146
|
let assembled;
|
package/src/runtime/agent/orchestrator/providers/openai-compat-chat-stream/stream-result.mjs
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* reconstructed response, tool-call parsing and dispatch, and the result.
|
|
5
5
|
*/
|
|
6
6
|
import { dedupeToolCallList } from '../lib/leaked-toolcall.mjs';
|
|
7
|
+
import { generationWindow } from '../lib/generation-window.mjs';
|
|
7
8
|
import { truncatedCompatStreamError } from '../lib/openai-tool-args.mjs';
|
|
8
9
|
import {
|
|
9
10
|
emitCompatToolCallOnce,
|
|
@@ -104,5 +105,6 @@ export function settleCompatStream(state, { label, parseToolCalls }) {
|
|
|
104
105
|
reasoningSource: state.sawReasoningContent ? state.reasoningSource : null,
|
|
105
106
|
reasoningDetails: state.reasoningDetails.length ? state.reasoningDetails : null,
|
|
106
107
|
rawUsage: state.rawUsage,
|
|
108
|
+
...generationWindow(state.firstOutputAt),
|
|
107
109
|
};
|
|
108
110
|
}
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
import { chatCompletionUsage } from '../openai-compat-response-normalization.mjs';
|
|
15
15
|
import { noteAbandonedUsage } from '../../../../shared/llm/usage-context.mjs';
|
|
16
16
|
import { createToolCallAccumulator } from './tool-call-acc.mjs';
|
|
17
|
+
import { isVisibleStreamProgress } from '../../../../shared/stream-progress.mjs';
|
|
17
18
|
|
|
18
19
|
export function createCompatStreamState({
|
|
19
20
|
providerName,
|
|
@@ -65,6 +66,10 @@ export function reportTransport(state) {
|
|
|
65
66
|
|
|
66
67
|
export function reportProgress(state, kind) {
|
|
67
68
|
if (kind !== 'transport') state.semanticIdleDeadlineAt = Date.now() + state.idleMs;
|
|
69
|
+
// A chat stream shows output only as deltas: the first visible one starts
|
|
70
|
+
// the generation (generation-window.mjs). Usage accounting trusts it only
|
|
71
|
+
// from a provider that streams every token, reasoning included.
|
|
72
|
+
if (isVisibleStreamProgress(kind)) state.firstOutputAt ||= Date.now();
|
|
68
73
|
try {
|
|
69
74
|
state.onStreamDelta?.(kind);
|
|
70
75
|
} catch {}
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
normalizeOpencodeGoReasoningEffort,
|
|
5
5
|
} from './openai-compat-xai.mjs';
|
|
6
6
|
import { isCustomProviderName, resolveCustomReasoning } from './custom-reasoning.mjs';
|
|
7
|
+
import { openRouterProviderRouting } from './openrouter-provider-routing.mjs';
|
|
7
8
|
|
|
8
9
|
function normalizeReasoningEffort(value, allowed) {
|
|
9
10
|
const effort = String(value ?? '')
|
|
@@ -66,6 +67,8 @@ export function applyCompatProviderChatOptions(params, providerName, opts = {},
|
|
|
66
67
|
if (providerName === 'openrouter') {
|
|
67
68
|
const reasoning = openRouterReasoning(opts, config);
|
|
68
69
|
if (reasoning) params.reasoning = reasoning;
|
|
70
|
+
const routing = openRouterProviderRouting(opts);
|
|
71
|
+
if (routing) params.provider = routing;
|
|
69
72
|
return params;
|
|
70
73
|
}
|
|
71
74
|
if (providerName === 'xai') {
|
|
@@ -234,16 +234,16 @@ export function normalizeCompatChatResponse({
|
|
|
234
234
|
model: response.model || useModel,
|
|
235
235
|
toolCalls,
|
|
236
236
|
stopReason,
|
|
237
|
-
//
|
|
238
|
-
//
|
|
239
|
-
//
|
|
240
|
-
//
|
|
241
|
-
// cutoff. Flag it so loop.mjs can surface a one-line warning
|
|
242
|
-
// instead of silently treating a truncated answer as complete.
|
|
237
|
+
// A text-only completion that hit finish_reason='length' (no tool
|
|
238
|
+
// calls, so not thrown above as ProviderIncompleteError) is flagged so
|
|
239
|
+
// loop.mjs can surface a one-line warning instead of silently treating
|
|
240
|
+
// a mid-sentence cutoff as complete.
|
|
243
241
|
...(stopReason === 'length' && (assembled.content || '').length > 0 ? { truncated: true } : {}),
|
|
244
242
|
...(reasoningContent !== null ? { reasoningContent } : {}),
|
|
245
243
|
...(Object.keys(providerMetadata).length ? { providerMetadata } : {}),
|
|
246
244
|
usage: response.usage ? chatCompletionUsage(providerName, response.usage) : undefined,
|
|
245
|
+
// The answering stream's own generation window (generation-window.mjs).
|
|
246
|
+
...(assembled.generationMs != null ? { generationMs: assembled.generationMs } : {}),
|
|
247
247
|
};
|
|
248
248
|
}
|
|
249
249
|
|