mixdog 1.4.0 → 1.4.2
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 +3 -2
- package/scripts/build-shipped-history.mjs +115 -33
- package/scripts/check-voice-runtime-inputs.mjs +25 -0
- package/scripts/gate-local.mjs +183 -63
- package/scripts/latest-guard.mjs +21 -9
- package/scripts/lib/gate-scheduler.mjs +138 -32
- package/scripts/lib/gate-timing-reporter.mjs +16 -0
- package/scripts/lib/isolated-test-env.mjs +10 -5
- package/scripts/lib/run-node-tests.mjs +91 -66
- package/scripts/lib/scoped-temp.d.mts +16 -0
- package/scripts/lib/scoped-temp.mjs +124 -0
- package/scripts/lib/stale-temp.mjs +44 -0
- package/scripts/lib/test-failure-records.mjs +14 -1
- package/scripts/lib/test-failure-summary.mjs +16 -4
- package/scripts/lib/test-spawn-ledger.mjs +12 -3
- package/scripts/post-release-check.mjs +1 -6
- package/scripts/pptx-kit-index.mjs +17 -5
- package/scripts/suite-health.mjs +115 -24
- package/scripts/test-data-dir.mjs +10 -7
- package/scripts/test.mjs +9 -14
- package/src/agents/advisor/AGENT.md +4 -4
- package/src/agents/advisor/agent.json +1 -1
- package/src/agents/explore/AGENT.md +22 -0
- package/src/agents/explore/agent.json +6 -0
- package/src/app.mjs +4 -0
- package/src/cli.mjs +7 -0
- package/src/defaults/agents.json +7 -0
- package/src/defaults/shipped-history.json +23 -2
- package/src/defaults/skills/browser-use/SKILL.md +10 -5
- package/src/defaults/skills/code-tidy/SKILL.md +71 -102
- package/src/defaults/skills/code-tidy/references/agent-cleanup.md +66 -114
- package/src/defaults/skills/code-tidy/references/cleanup-report.md +19 -35
- package/src/defaults/skills/code-tidy/references/dead-code.md +3 -9
- package/src/defaults/skills/code-tidy/references/test-suite-slop.md +16 -27
- package/src/defaults/skills/computer-use/SKILL.md +16 -4
- package/src/defaults/skills/goal-management/SKILL.md +1 -1
- package/src/defaults/skills/setup/references/actions.md +12 -6
- package/src/defaults/skills/setup/references/surfaces.md +2 -2
- package/src/defaults/skills/setup-guide/SKILL.md +5 -2
- package/src/defaults/skills/setup-guide/model-recommendations.json +13 -0
- package/src/defaults/skills/skill-creator/SKILL.md +85 -190
- package/src/defaults/skills/skill-creator/references/design.md +70 -162
- package/src/defaults/skills/skill-creator/references/evaluation.md +33 -92
- package/src/defaults/skills/test-suite/SKILL.md +194 -0
- package/src/defaults/skills/test-suite/references/case-management.md +51 -0
- package/src/defaults/skills/test-suite/references/flaky-policy.md +39 -0
- package/src/defaults/skills/test-suite/references/reliability.md +49 -0
- package/src/defaults/skills/test-suite/references/suite-design.md +78 -0
- package/src/defaults/skills/test-suite/scripts/inventory.mjs +335 -0
- package/src/defaults/skills/visualize/SKILL.md +6 -2
- package/src/lib/rules-builder.cjs +35 -42
- package/src/output-styles/common.md +2 -2
- package/src/output-styles/simple.md +1 -1
- package/src/rules/agent/AGENT.md +5 -4
- package/src/rules/lead/LEAD.md +12 -7
- package/src/rules/shared/10-tool-workflow.md +3 -1
- package/src/rules/shared/20-research.md +3 -6
- package/src/rules/shared/40-editing.md +1 -0
- package/src/rules/shared/45-destructive.md +0 -2
- package/src/rules/shared/50-execution.md +2 -0
- package/src/rules/shared/60-verification.md +10 -9
- package/src/rules/shared/70-delivery.md +8 -9
- package/src/runtime/agent/orchestrator/agent-runtime/agent-dispatch/abort-link.mjs +5 -1
- package/src/runtime/agent/orchestrator/agent-runtime/agent-dispatch.mjs +10 -1
- package/src/runtime/agent/orchestrator/agent-runtime/agent-progress-watchdog.mjs +156 -24
- package/src/runtime/agent/orchestrator/agent-runtime/cache-strategy.mjs +13 -0
- package/src/runtime/agent/orchestrator/agent-runtime/maintenance-route.mjs +4 -1
- package/src/runtime/agent/orchestrator/cache-break-trace.mjs +2 -0
- package/src/runtime/agent/orchestrator/config.mjs +12 -7
- package/src/runtime/agent/orchestrator/context/deferred-tools.mjs +8 -8
- package/src/runtime/agent/orchestrator/context/role-instructions.mjs +5 -26
- package/src/runtime/agent/orchestrator/context/skill-catalog.mjs +3 -1
- package/src/runtime/agent/orchestrator/internal-agents.mjs +3 -14
- package/src/runtime/agent/orchestrator/mcp/agent-connectors.mjs +122 -12
- package/src/runtime/agent/orchestrator/mcp/child-tree.mjs +5 -3
- package/src/runtime/agent/orchestrator/mcp/client-config.mjs +13 -2
- package/src/runtime/agent/orchestrator/mcp/client-transport.mjs +152 -58
- package/src/runtime/agent/orchestrator/mcp/client.mjs +51 -18
- package/src/runtime/agent/orchestrator/mcp/oauth-login.mjs +88 -54
- package/src/runtime/agent/orchestrator/mcp/oauth.mjs +42 -26
- package/src/runtime/agent/orchestrator/providers/account-pool.mjs +54 -8
- package/src/runtime/agent/orchestrator/providers/anthropic-api-recovery.mjs +1 -1
- package/src/runtime/agent/orchestrator/providers/anthropic-api-request.mjs +37 -31
- package/src/runtime/agent/orchestrator/providers/anthropic-api-transport.mjs +8 -2
- package/src/runtime/agent/orchestrator/providers/anthropic-max-tokens-recovery.mjs +6 -2
- package/src/runtime/agent/orchestrator/providers/anthropic-messages.mjs +2 -2
- package/src/runtime/agent/orchestrator/providers/anthropic-oauth-client-version.mjs +1 -1
- package/src/runtime/agent/orchestrator/providers/anthropic-oauth-credentials.mjs +31 -21
- package/src/runtime/agent/orchestrator/providers/anthropic-oauth-request/initial-status.mjs +3 -1
- package/src/runtime/agent/orchestrator/providers/anthropic-oauth.mjs +14 -3
- package/src/runtime/agent/orchestrator/providers/anthropic-sse.mjs +6 -0
- package/src/runtime/agent/orchestrator/providers/anthropic-turn-result.mjs +2 -2
- package/src/runtime/agent/orchestrator/providers/antigravity-oauth-login.mjs +3 -1
- package/src/runtime/agent/orchestrator/providers/antigravity-oauth-tokens.mjs +2 -2
- package/src/runtime/agent/orchestrator/providers/codex-client-meta.mjs +1 -1
- package/src/runtime/agent/orchestrator/providers/command-code-oauth-login.mjs +1 -10
- package/src/runtime/agent/orchestrator/providers/command-code-oauth.mjs +1 -1
- package/src/runtime/agent/orchestrator/providers/cursor.mjs +3 -0
- package/src/runtime/agent/orchestrator/providers/custom-provider-config.mjs +40 -0
- package/src/runtime/agent/orchestrator/providers/custom-provider-keys.mjs +34 -0
- package/src/runtime/agent/orchestrator/providers/custom-provider.mjs +3 -0
- package/src/runtime/agent/orchestrator/providers/devin-auth.mjs +14 -7
- package/src/runtime/agent/orchestrator/providers/devin-wire-transport.mjs +3 -2
- package/src/runtime/agent/orchestrator/providers/devin.mjs +3 -0
- package/src/runtime/agent/orchestrator/providers/gemini-response.mjs +2 -2
- package/src/runtime/agent/orchestrator/providers/gemini-stream.mjs +4 -1
- package/src/runtime/agent/orchestrator/providers/grok-oauth-login.mjs +248 -41
- package/src/runtime/agent/orchestrator/providers/lib/anthropic-prefix-trace.mjs +76 -11
- package/src/runtime/agent/orchestrator/providers/lib/anthropic-request-utils.mjs +45 -6
- package/src/runtime/agent/orchestrator/providers/lib/first-output-window.mjs +58 -0
- package/src/runtime/agent/orchestrator/providers/lib/listen-on.mjs +14 -0
- package/src/runtime/agent/orchestrator/providers/lib/oauth-page.mjs +0 -18
- package/src/runtime/agent/orchestrator/providers/lib/oauth-token-utils.mjs +138 -6
- package/src/runtime/agent/orchestrator/providers/mimo-oauth-login.mjs +1 -10
- package/src/runtime/agent/orchestrator/providers/mimo-oauth.mjs +1 -1
- package/src/runtime/agent/orchestrator/providers/model-cache.mjs +100 -33
- package/src/runtime/agent/orchestrator/providers/muse-code-oauth.mjs +1 -1
- package/src/runtime/agent/orchestrator/providers/oauth-secret-fields.fixtures.mjs +45 -0
- package/src/runtime/agent/orchestrator/providers/openai-compat-chat-send.mjs +1 -0
- package/src/runtime/agent/orchestrator/providers/openai-compat-chat-stream/chunk-events.mjs +9 -2
- package/src/runtime/agent/orchestrator/providers/openai-compat-chat-stream/stream-state.mjs +7 -0
- package/src/runtime/agent/orchestrator/providers/openai-compat-chat-stream.mjs +14 -3
- package/src/runtime/agent/orchestrator/providers/openai-compat-responses-events.mjs +4 -2
- package/src/runtime/agent/orchestrator/providers/openai-compat-responses.mjs +1 -0
- package/src/runtime/agent/orchestrator/providers/openai-compat-stream-common.mjs +5 -3
- package/src/runtime/agent/orchestrator/providers/openai-compat-stream.mjs +16 -3
- package/src/runtime/agent/orchestrator/providers/openai-compat-xai-send.mjs +1 -0
- package/src/runtime/agent/orchestrator/providers/openai-http-sse-response-state/response-events/output-items.mjs +5 -2
- package/src/runtime/agent/orchestrator/providers/openai-http-sse-response-state/response-events.mjs +13 -3
- package/src/runtime/agent/orchestrator/providers/openai-http-sse-response-state.mjs +13 -2
- package/src/runtime/agent/orchestrator/providers/openai-http-sse-watchdogs.mjs +81 -42
- package/src/runtime/agent/orchestrator/providers/openai-oauth-http-sse.mjs +8 -0
- package/src/runtime/agent/orchestrator/providers/openai-oauth-login.mjs +160 -31
- package/src/runtime/agent/orchestrator/providers/openai-ws-stream/event-switch.mjs +22 -12
- package/src/runtime/agent/orchestrator/providers/openai-ws-stream.mjs +7 -1
- package/src/runtime/agent/orchestrator/providers/openai-ws-watchdogs.mjs +49 -22
- package/src/runtime/agent/orchestrator/providers/opencode-go-oauth.mjs +1 -1
- package/src/runtime/agent/orchestrator/providers/opencode-go.mjs +3 -1
- package/src/runtime/agent/orchestrator/providers/registry.mjs +45 -2
- package/src/runtime/agent/orchestrator/providers/vertex-ai-auth.mjs +622 -0
- package/src/runtime/agent/orchestrator/providers/vertex-ai-maas.mjs +185 -0
- package/src/runtime/agent/orchestrator/providers/vertex-ai-models.mjs +445 -0
- package/src/runtime/agent/orchestrator/providers/vertex-ai.mjs +567 -0
- package/src/runtime/agent/orchestrator/runtime-core/ask-user-tool-defs.mjs +41 -13
- package/src/runtime/agent/orchestrator/runtime-core/builtin-features.mjs +2 -0
- package/src/runtime/agent/orchestrator/runtime-core/orchestration.mjs +8 -6
- package/src/runtime/agent/orchestrator/runtime-core/session-text.mjs +7 -3
- package/src/runtime/agent/orchestrator/runtime-core/tool-catalog-data.mjs +3 -0
- package/src/runtime/agent/orchestrator/runtime-core/tool-defs.mjs +6 -1
- package/src/runtime/agent/orchestrator/runtime-core/workflow/context.mjs +14 -5
- package/src/runtime/agent/orchestrator/runtime-core/workflow-ids.mjs +1 -0
- package/src/runtime/agent/orchestrator/runtime-core/workflow.mjs +5 -2
- package/src/runtime/agent/orchestrator/session/agent-room.d.mts +30 -5
- package/src/runtime/agent/orchestrator/session/agent-room.mjs +171 -37
- package/src/runtime/agent/orchestrator/session/cache/scoped-cache.mjs +1 -3
- package/src/runtime/agent/orchestrator/session/cache-warm.mjs +102 -12
- package/src/runtime/agent/orchestrator/session/catalog-db/schema.mjs +4 -1
- package/src/runtime/agent/orchestrator/session/compact/execution-tail.mjs +1 -8
- package/src/runtime/agent/orchestrator/session/compact/messages.mjs +23 -0
- package/src/runtime/agent/orchestrator/session/compact/observation-supersession.mjs +103 -23
- package/src/runtime/agent/orchestrator/session/compact/runner.mjs +160 -36
- package/src/runtime/agent/orchestrator/session/context-utils.mjs +13 -1
- package/src/runtime/agent/orchestrator/session/conversation-import/claude.mjs +164 -23
- package/src/runtime/agent/orchestrator/session/conversation-import/codex.mjs +139 -19
- package/src/runtime/agent/orchestrator/session/conversation-import/convert.mjs +38 -7
- package/src/runtime/agent/orchestrator/session/conversation-import/imported-session.mjs +3 -0
- package/src/runtime/agent/orchestrator/session/conversation-import/turns.mjs +100 -22
- package/src/runtime/agent/orchestrator/session/eager-dispatch.mjs +4 -3
- package/src/runtime/agent/orchestrator/session/human-gate/requests.mjs +36 -6
- package/src/runtime/agent/orchestrator/session/loop/compact-policy.mjs +33 -3
- package/src/runtime/agent/orchestrator/session/loop/fresh-context.mjs +9 -2
- package/src/runtime/agent/orchestrator/session/loop/pre-dispatch-deny.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/loop/provider-tool-exclusions.mjs +13 -5
- package/src/runtime/agent/orchestrator/session/loop/route-fallback.mjs +14 -0
- package/src/runtime/agent/orchestrator/session/loop/send-phase.mjs +13 -1
- package/src/runtime/agent/orchestrator/session/loop/tool-exec/before-hook.mjs +23 -4
- package/src/runtime/agent/orchestrator/session/loop/tool-exec/dispatch.mjs +2 -0
- package/src/runtime/agent/orchestrator/session/loop/tool-exec.mjs +23 -1
- package/src/runtime/agent/orchestrator/session/loop/tool-exposure-migration.mjs +39 -21
- package/src/runtime/agent/orchestrator/session/loop/turn-limits.mjs +13 -8
- package/src/runtime/agent/orchestrator/session/manager/ask-session.mjs +50 -28
- package/src/runtime/agent/orchestrator/session/manager/ask-turn-loop-options.mjs +3 -3
- package/src/runtime/agent/orchestrator/session/manager/ask-turn-settle.mjs +3 -1
- package/src/runtime/agent/orchestrator/session/manager/owner-route-fallbacks.mjs +2 -2
- package/src/runtime/agent/orchestrator/session/manager/prompt-utils.mjs +1 -0
- package/src/runtime/agent/orchestrator/session/manager/route-fallback-chain.mjs +2 -1
- package/src/runtime/agent/orchestrator/session/manager/rules-cache.mjs +30 -13
- package/src/runtime/agent/orchestrator/session/manager/runtime-liveness.mjs +63 -6
- package/src/runtime/agent/orchestrator/session/manager/session-close.mjs +7 -0
- package/src/runtime/agent/orchestrator/session/manager/session-crud.mjs +15 -0
- package/src/runtime/agent/orchestrator/session/manager/session-lifecycle.mjs +35 -13
- package/src/runtime/agent/orchestrator/session/manager/session-prompt-composition.mjs +24 -14
- package/src/runtime/agent/orchestrator/session/manager/session-scratch-environment.mjs +70 -0
- package/src/runtime/agent/orchestrator/session/manager/session-tool-surface.mjs +0 -3
- package/src/runtime/agent/orchestrator/session/manager/tool-resolution.mjs +10 -6
- package/src/runtime/agent/orchestrator/session/manager/turn-checkpoint-context.mjs +4 -0
- package/src/runtime/agent/orchestrator/session/manager/turn-checkpoint.mjs +3 -0
- package/src/runtime/agent/orchestrator/session/manager/turn-interruption.mjs +56 -29
- package/src/runtime/agent/orchestrator/session/manager/turn-reap.mjs +125 -0
- package/src/runtime/agent/orchestrator/session/mixy-name.mjs +11 -5
- package/src/runtime/agent/orchestrator/session/pre-send-compact.mjs +5 -1
- package/src/runtime/agent/orchestrator/session/prompt-cache-touch-store.mjs +30 -7
- package/src/runtime/agent/orchestrator/session/restart-prefix-parity.fixture.mjs +154 -0
- package/src/runtime/agent/orchestrator/session/store/session-delete.mjs +7 -0
- package/src/runtime/agent/orchestrator/session/store-summary-catalog.mjs +4 -0
- package/src/runtime/agent/orchestrator/session/store-summary-fields.mjs +15 -0
- package/src/runtime/agent/orchestrator/session/store-summary-index.mjs +37 -8
- package/src/runtime/agent/orchestrator/session/store-summary-reader.mjs +252 -39
- package/src/runtime/agent/orchestrator/session/store-transcript-cache.mjs +163 -64
- package/src/runtime/agent/orchestrator/session/store-transcript-projection.mjs +164 -4
- package/src/runtime/agent/orchestrator/session/store-transcript-worker.mjs +142 -18
- package/src/runtime/agent/orchestrator/session/transcript-restore/restore.mjs +61 -2
- package/src/runtime/agent/orchestrator/stall-policy.mjs +23 -0
- package/src/runtime/agent/orchestrator/tools/builtin/bash-tool/completed-result.mjs +6 -2
- package/src/runtime/agent/orchestrator/tools/builtin/bash-tool/invocation-plan.mjs +2 -2
- package/src/runtime/agent/orchestrator/tools/builtin/bash-tool/spawn-env.mjs +4 -2
- package/src/runtime/agent/orchestrator/tools/builtin/bash-tool.mjs +6 -1
- package/src/runtime/agent/orchestrator/tools/builtin/builtin-tools.mjs +46 -20
- package/src/runtime/agent/orchestrator/tools/builtin/cache-layers.mjs +7 -1
- package/src/runtime/agent/orchestrator/tools/builtin/git-command-tool.mjs +67 -31
- package/src/runtime/agent/orchestrator/tools/builtin/git-worktree-tool.mjs +25 -13
- package/src/runtime/agent/orchestrator/tools/builtin/lib/scoped-search-flight.mjs +9 -5
- package/src/runtime/agent/orchestrator/tools/builtin/lib/shell-job-records.mjs +58 -20
- package/src/runtime/agent/orchestrator/tools/builtin/read-single-stream.mjs +7 -1
- package/src/runtime/agent/orchestrator/tools/builtin/read-streaming.mjs +6 -3
- package/src/runtime/agent/orchestrator/tools/builtin/read-tool/batch-dispatch.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/builtin/read-tool/batch-publication.mjs +23 -12
- package/src/runtime/agent/orchestrator/tools/builtin/read-tool/batch-snapshot.mjs +6 -1
- package/src/runtime/agent/orchestrator/tools/builtin/read-tool.mjs +1 -8
- package/src/runtime/agent/orchestrator/tools/builtin/runtime-capabilities.mjs +20 -15
- package/src/runtime/agent/orchestrator/tools/builtin/shell-jobs.mjs +96 -20
- package/src/runtime/agent/orchestrator/tools/builtin/task-tool.mjs +59 -10
- package/src/runtime/agent/orchestrator/tools/code-graph/dispatch/federation.mjs +3 -1
- package/src/runtime/agent/orchestrator/tools/code-graph-tool-defs.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/graph-manifest.json +13 -13
- package/src/runtime/agent/orchestrator/tools/lib/isolated-test-env.mjs +4 -3
- package/src/runtime/agent/orchestrator/tools/lib/native-spawn-client.mjs +99 -2
- package/src/runtime/agent/orchestrator/tools/lib/owned-shell-trees.mjs +2 -0
- package/src/runtime/agent/orchestrator/tools/lib/shell-descendants.mjs +103 -13
- package/src/runtime/agent/orchestrator/tools/lib/shell-run-background/promote-job.mjs +3 -1
- package/src/runtime/agent/orchestrator/tools/lib/shell-run-settle.mjs +49 -15
- package/src/runtime/agent/orchestrator/tools/lib/shell-run-spawn.mjs +45 -27
- package/src/runtime/agent/orchestrator/tools/lib/shell-run-state.mjs +34 -10
- package/src/runtime/agent/orchestrator/tools/lib/shell-warm-standby.mjs +28 -4
- package/src/runtime/agent/orchestrator/tools/lib/wait-until-fixture.mjs +26 -0
- package/src/runtime/agent/orchestrator/tools/shell-command.mjs +7 -2
- package/src/runtime/agent/orchestrator/tools/spawn-manifest.json +13 -13
- package/src/runtime/channels/lib/webhook/signature.mjs +4 -1
- package/src/runtime/channels/lib/whisper-port.mjs +29 -11
- package/src/runtime/channels/lib/whisper-server.mjs +10 -1
- package/src/runtime/computer-bridge/action-schema.mjs +2 -2
- package/src/runtime/computer-bridge/core-actions.mjs +2 -2
- package/src/runtime/computer-bridge/error-recovery.mjs +5 -4
- package/src/runtime/computer-bridge/linux-action-capabilities.mjs +24 -5
- package/src/runtime/computer-bridge/linux-readiness.d.mts +7 -2
- package/src/runtime/connectors/connector-accounts-mcp.mjs +236 -103
- package/src/runtime/connectors/gmail-app-password.mjs +3 -3
- package/src/runtime/explore/explorer.mjs +93 -0
- package/src/runtime/explore/tool-defs.mjs +35 -0
- package/src/runtime/explore/tool.mjs +123 -0
- package/src/runtime/local-provider/server-process.mjs +2 -1
- package/src/runtime/media/adapters/gemini-video.mjs +4 -1
- package/src/runtime/media/adapters/xai-media.mjs +2 -1
- package/src/runtime/memory/index.mjs +4 -0
- package/src/runtime/memory/lib/embedding-provider.mjs +4 -1
- package/src/runtime/memory/lib/embedding-worker.mjs +10 -3
- package/src/runtime/memory/lib/memory-action-handlers/cycle-backfill-action.mjs +1 -7
- package/src/runtime/memory/lib/memory-chunk-quality.mjs +1 -6
- package/src/runtime/office/authoring/pdf-author-action.mjs +1 -6
- package/src/runtime/office/design/design-art-direction.mjs +29 -27
- package/src/runtime/office/pdf/pdf-writer.mjs +6 -1
- package/src/runtime/office/portable/portable-snapshot-docx.mjs +7 -1
- package/src/runtime/office/portable/portable-snapshot-shared.mjs +6 -1
- package/src/runtime/office/quality/assurance-rendered.mjs +9 -2
- package/src/runtime/office/quality/assurance-structure-docx.mjs +4 -2
- package/src/runtime/office/quality/design-review.mjs +1 -5
- package/src/runtime/office/quality/document-brief.mjs +1 -5
- package/src/runtime/office/quality/forced-break-pages.mjs +9 -6
- package/src/runtime/office/quality/quality-pipeline.mjs +1 -1
- package/src/runtime/shared/agent-route-config.mjs +17 -2
- package/src/runtime/shared/atomic-file.mjs +103 -2
- package/src/runtime/shared/background-tasks.mjs +15 -6
- package/src/runtime/shared/bot-owned-work.mjs +56 -0
- package/src/runtime/shared/connector-accounts.mjs +5 -5
- package/src/runtime/shared/connector-catalog.d.mts +11 -4
- package/src/runtime/shared/connector-catalog.mjs +60 -52
- package/src/runtime/shared/custom-provider-keys.mjs +20 -0
- package/src/runtime/shared/defaults-separation.mjs +1 -4
- package/src/runtime/shared/fetch-safe-listen.d.mts +16 -0
- package/src/runtime/shared/fetch-safe-listen.mjs +50 -0
- package/src/runtime/shared/file-has-data.mjs +26 -2
- package/src/runtime/shared/file-lock.mjs +13 -15
- package/src/runtime/shared/git-launch.d.mts +9 -0
- package/src/runtime/shared/git-launch.mjs +213 -0
- package/src/runtime/shared/git-runner-worker.mjs +2 -1
- package/src/runtime/shared/handoff-artifacts.d.mts +2 -1
- package/src/runtime/shared/handoff-artifacts.mjs +18 -8
- package/src/runtime/shared/idle-auto-clear-gate.mjs +29 -7
- package/src/runtime/shared/llm/cost.mjs +11 -2
- package/src/runtime/shared/llm/http-agent.mjs +313 -29
- package/src/runtime/shared/llm/model-catalog-projection.mjs +3 -2
- package/src/runtime/shared/llm/model-catalog.mjs +46 -6
- package/src/runtime/shared/llm/provider-catalog-registry.mjs +3 -0
- package/src/runtime/shared/llm/system-proxy.mjs +452 -0
- package/src/runtime/shared/loopback-listener.mjs +25 -2
- package/src/runtime/shared/model-route-chain.d.mts +7 -2
- package/src/runtime/shared/model-route-chain.mjs +22 -4
- package/src/runtime/shared/open-url.mjs +10 -0
- package/src/runtime/shared/provider-accounts.mjs +52 -2
- package/src/runtime/shared/session-activity-signal.mjs +14 -0
- package/src/runtime/shared/session-scratch.mjs +37 -0
- package/src/runtime/shared/staged-install-worker.mjs +5 -0
- package/src/runtime/shared/staged-update.mjs +47 -2
- package/src/runtime/shared/tool-card-model/agent-surface.mjs +1 -3
- package/src/runtime/shared/tool-card-model/card-status.mjs +15 -2
- package/src/runtime/shared/tool-result-summary.mjs +1 -1
- package/src/runtime/shared/tool-surface.mjs +113 -36
- package/src/runtime/shared/tool-work-units.mjs +6 -0
- package/src/runtime/shared/turn-snapshot-store.mjs +13 -6
- package/src/runtime/shared/turn-worktree-snapshot.mjs +414 -54
- package/src/runtime/shared/worktrees/activity-gate.mjs +215 -318
- package/src/runtime/shared/worktrees/activity-ledger-worker.mjs +56 -0
- package/src/runtime/shared/worktrees/activity-ledger.mjs +391 -0
- package/src/runtime/shared/worktrees/branch-management.mjs +9 -3
- package/src/runtime/shared/worktrees/contract.mjs +4 -1
- package/src/runtime/shared/worktrees/git.mjs +72 -0
- package/src/runtime/shared/worktrees/manager.mjs +285 -168
- package/src/runtime/shared/worktrees/test-support.mjs +6 -10
- package/src/runtime/tidy/install.mjs +95 -15
- package/src/runtime/tidy/languages.mjs +17 -15
- package/src/runtime/tidy/process.mjs +7 -4
- package/src/runtime/tidy/resolve.mjs +19 -16
- package/src/runtime/tidy/runners/biome.mjs +3 -3
- package/src/runtime/tidy/tool.mjs +1 -1
- package/src/runtime/tidy/worktree.mjs +10 -6
- package/src/runtime/visualize-bridge/client.mjs +6 -1
- package/src/runtime/visualize-bridge/tool-defs.mjs +7 -2
- package/src/runtime/web-search/index.mjs +1 -1
- package/src/session-runtime/agent-home-delivery.mjs +41 -0
- package/src/session-runtime/agent-task-sessions.mjs +458 -312
- package/src/session-runtime/agent-tool-routing.mjs +8 -41
- package/src/session-runtime/boot/tools.mjs +7 -1
- package/src/session-runtime/bot-status.mjs +107 -101
- package/src/session-runtime/bot-target.mjs +38 -0
- package/src/session-runtime/channel-config-api.mjs +6 -1
- package/src/session-runtime/connector-merge-migration.mjs +18 -15
- package/src/session-runtime/conversation-import/codex-titles.mjs +88 -0
- package/src/session-runtime/conversation-import/discovery.mjs +401 -36
- package/src/session-runtime/conversation-import/service.mjs +35 -8
- package/src/session-runtime/handoff-attachments.mjs +82 -31
- package/src/session-runtime/held-requests.mjs +3 -1
- package/src/session-runtime/internal-tool-executor/ask-user-tool.mjs +12 -13
- package/src/session-runtime/internal-tool-executor/bridge-tools.mjs +1 -0
- package/src/session-runtime/internal-tool-executor/feature-tools.mjs +2 -0
- package/src/session-runtime/internal-tool-executor/knowledge-tools.mjs +8 -0
- package/src/session-runtime/internal-tool-executor/reaction-tool.mjs +4 -1
- package/src/session-runtime/internal-tool-executor/workspace-tools.mjs +145 -112
- package/src/session-runtime/lifecycle/cold-heir.mjs +11 -6
- package/src/session-runtime/lifecycle/session-catalog.mjs +9 -1
- package/src/session-runtime/lifecycle/teardown/session-close.mjs +6 -1
- package/src/session-runtime/lifecycle/teardown.mjs +1 -1
- package/src/session-runtime/mcp-glue/server-catalog.mjs +16 -10
- package/src/session-runtime/mcp-glue/server-input.mjs +4 -1
- package/src/session-runtime/mixy-heartbeat.mjs +1 -1
- package/src/session-runtime/model-route/set-route.mjs +11 -2
- package/src/session-runtime/provider-auth/login.mjs +2 -2
- package/src/session-runtime/provider-catalog-cache.mjs +82 -36
- package/src/session-runtime/provider-models/catalog-load.mjs +23 -6
- package/src/session-runtime/provider-models.mjs +4 -2
- package/src/session-runtime/resource-mcp-api.mjs +98 -35
- package/src/session-runtime/resource-mcp-connector-accounts.mjs +44 -31
- package/src/session-runtime/resource-mcp-secrets.mjs +28 -11
- package/src/session-runtime/resource-mcp-servers.mjs +5 -4
- package/src/session-runtime/resource-recall-api.mjs +6 -1
- package/src/session-runtime/runtime-feature-gates.mjs +5 -1
- package/src/session-runtime/services/agent-tool/execute.mjs +14 -9
- package/src/session-runtime/services/agent-tool/job-views/agent-list.mjs +20 -4
- package/src/session-runtime/services/agent-tool/model-select.mjs +48 -7
- package/src/session-runtime/services/agent-tool/render.mjs +71 -17
- package/src/session-runtime/services/agent-tool/send-flow.mjs +10 -2
- package/src/session-runtime/services/agent-tool/spawn-flow/spawn-prep.mjs +8 -3
- package/src/session-runtime/services/agent-tool/spawn-flow/spawn-run.mjs +4 -1
- package/src/session-runtime/services/agent-tool/spawn-preset.mjs +6 -2
- package/src/session-runtime/services/agent-tool/tool-def.mjs +9 -9
- package/src/session-runtime/services/agent-watchdog-registry.mjs +32 -4
- package/src/session-runtime/services/channel-worker/daemon-spawn.mjs +2 -0
- package/src/session-runtime/services/daemon-candidate.mjs +4 -1
- package/src/session-runtime/services/memory-runtime-proxy/daemon-spawn.mjs +4 -0
- package/src/session-runtime/services/plugin-admin.mjs +10 -6
- package/src/session-runtime/services/provider-admin.mjs +283 -11
- package/src/session-runtime/session-turn-api.mjs +2 -0
- package/src/session-runtime/settings-builtin-tools-api.mjs +4 -1
- package/src/session-runtime/settings-system-api.mjs +1 -1
- package/src/session-runtime/setup-tool/agent-settings-actions.mjs +13 -3
- package/src/session-runtime/setup-tool/connector-widen-approval.mjs +96 -0
- package/src/session-runtime/setup-tool/executor.mjs +6 -2
- package/src/session-runtime/setup-tool/tool-defs.mjs +2 -1
- package/src/session-runtime/tool-policy/policy-stage.mjs +1 -0
- package/src/session-runtime/turn/agent-ops.mjs +23 -0
- package/src/session-runtime/workflow-agents-api/agent-connectors.mjs +49 -11
- package/src/session-runtime/workflow-agents-api/agent-editor.mjs +5 -1
- package/src/session-runtime/workflow-agents-api/agent-route.mjs +25 -5
- package/src/session-runtime/workflow-agents-api/onboarding.mjs +3 -3
- package/src/session-runtime/workspace/activity-guards.mjs +176 -0
- package/src/session-runtime/workspace/session-view.mjs +149 -0
- package/src/session-runtime/workspace/side-checkouts.mjs +203 -0
- package/src/session-runtime/workspace/transition-runner.mjs +188 -0
- package/src/session-runtime/workspace/transitions.mjs +108 -1041
- package/src/session-runtime/workspace/workspace-merge.mjs +132 -0
- package/src/session-runtime/workspace/worktree-intents.mjs +242 -0
- package/src/session-runtime/workspace/worktree-maintenance.mjs +80 -0
- package/src/session-runtime/workspace/worktree-setup.mjs +85 -0
- package/src/session-runtime/workspace/worktree-tool.mjs +73 -56
- package/src/standalone/daemon-desktop-runtime.mjs +2 -0
- package/src/standalone/daemon-session-control.mjs +169 -138
- package/src/standalone/daemon.mjs +7 -0
- package/src/standalone/desktop-service-registry.mjs +9 -0
- package/src/standalone/local-session-runtime.mjs +5 -1
- package/src/standalone/session-client/daemon-unavailable.mjs +3 -0
- package/src/standalone/session-client.mjs +5 -1
- package/src/standalone/session-frame-stream.mjs +83 -11
- package/src/standalone/session-protocol.mjs +4 -0
- package/src/standalone/session-service/agent-tree/agent-turns.mjs +16 -12
- package/src/standalone/session-service/agent-tree.mjs +45 -9
- package/src/standalone/session-service/projection/transcript-window.mjs +700 -64
- package/src/standalone/session-service/session-calls/session-action.mjs +10 -3
- package/src/standalone/session-service/session-calls/session-views.mjs +160 -104
- package/src/standalone/session-service/stored-reader.mjs +127 -40
- package/src/standalone/session-transport/client-registry/client-grace.mjs +12 -9
- package/src/tui/App.jsx +154 -164
- package/src/tui/app/app-view/floating-panel.jsx +10 -4
- package/src/tui/app/app-view/text-entry-labels.mjs +1 -0
- package/src/tui/app/clipboard.mjs +21 -10
- package/src/tui/app/model-picker/route-selection/fast-parameters.mjs +1 -3
- package/src/tui/app/model-picker/route-selection.mjs +5 -6
- package/src/tui/app/prompt-handlers/use-prompt-history-nav.mjs +1 -1
- package/src/tui/app/prompt-handlers/use-prompt-interrupt.mjs +3 -0
- package/src/tui/app/prompt-submit/provider-prompts.mjs +3 -1
- package/src/tui/app/provider-setup/api-key-actions.mjs +31 -1
- package/src/tui/app/provider-setup/oauth-actions.mjs +58 -21
- package/src/tui/app/provider-setup/provider-items.mjs +8 -2
- package/src/tui/app/provider-setup-picker.mjs +29 -18
- package/src/tui/app/shell-layout/row-budgets.mjs +12 -10
- package/src/tui/app/slash-commands.mjs +1 -0
- package/src/tui/app/slash-dispatch/session-commands.mjs +46 -0
- package/src/tui/app/slash-dispatch.mjs +1 -1
- package/src/tui/app/use-btw-panel.mjs +29 -0
- package/src/tui/app/use-context-panel-refresh.mjs +31 -0
- package/src/tui/app/use-model-catalog-cache.mjs +13 -10
- package/src/tui/app/use-mouse-input.mjs +11 -0
- package/src/tui/app/use-onboarding-start.mjs +8 -3
- package/src/tui/app/use-panel-transition.mjs +10 -1
- package/src/tui/app/use-pasted-buffers.mjs +28 -20
- package/src/tui/app/use-prompt-draft-flow.mjs +7 -0
- package/src/tui/app/use-prompt-layout-rows.mjs +3 -3
- package/src/tui/app/use-prompt-queue-history.mjs +3 -2
- package/src/tui/app/use-selection-focus.mjs +11 -2
- package/src/tui/app/use-selection-geometry.mjs +18 -9
- package/src/tui/app/use-selection-paint.mjs +4 -4
- package/src/tui/app/use-selection-stitch.mjs +3 -3
- package/src/tui/app/use-slash-palette.mjs +62 -0
- package/src/tui/app/use-terminal-chrome.mjs +2 -2
- package/src/tui/app/use-transcript-activity.mjs +47 -32
- package/src/tui/app/use-transcript-follow.mjs +12 -4
- package/src/tui/app/use-transcript-scroll.mjs +46 -17
- package/src/tui/app/use-transcript-swap-reset.mjs +27 -0
- package/src/tui/app/use-transcript-window/geometry.mjs +19 -5
- package/src/tui/app/use-transcript-window/instance-state.mjs +4 -0
- package/src/tui/app/use-transcript-window/selection-shift.mjs +5 -1
- package/src/tui/app/use-transcript-window.mjs +21 -11
- package/src/tui/app/use-tui-ready.mjs +18 -0
- package/src/tui/app/use-welcome-prompt-hint.mjs +5 -0
- package/src/tui/app/use-workflow-tab-cycle.mjs +5 -3
- package/src/tui/components/Picker.jsx +27 -3
- package/src/tui/components/QuestionPanel.jsx +13 -4
- package/src/tui/components/SignInUrl.jsx +68 -0
- package/src/tui/components/TextEntryPanel.jsx +76 -46
- package/src/tui/components/sign-in-url-layout.mjs +24 -0
- package/src/tui/dist/index.mjs +1963 -1361
- package/src/tui/session/goal-turn-state.mjs +6 -2
- package/src/tui/session/session-api/controls.mjs +4 -0
- package/src/tui/session/session-api/extensions.mjs +8 -0
- package/src/tui/session/session-api/intake/abort.mjs +2 -1
- package/src/tui/session/session-api/intake.mjs +2 -0
- package/src/tui/session/session-api/integrations.mjs +2 -2
- package/src/tui/session/session-api/routes-agent-definitions.mjs +1 -0
- package/src/tui/session/session-api/settings.mjs +2 -2
- package/src/tui/session/session-flow/queue/take-entries.mjs +11 -0
- package/src/tui/session/transcript-spill/spill-writer.mjs +15 -0
- package/src/tui/session/transcript-spill.mjs +92 -4
- package/src/tui/session/transcript-store.mjs +2 -0
- package/src/ui/statusline-agents.mjs +1 -3
- package/src/defaults/skills/skill-creator/references/source-review.md +0 -94
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
22
|
import { createRequire } from 'node:module';
|
|
23
|
+
import { BlockList, isIP } from 'node:net';
|
|
23
24
|
|
|
24
25
|
const require = createRequire(import.meta.url);
|
|
25
26
|
let _undici = null;
|
|
@@ -30,6 +31,8 @@ function undici() {
|
|
|
30
31
|
|
|
31
32
|
let _agent = null;
|
|
32
33
|
let _globalInstalled = false;
|
|
34
|
+
/** The system-proxy router (adoptPrivateProxy), installed as the global dispatcher. */
|
|
35
|
+
let _router = null;
|
|
33
36
|
|
|
34
37
|
function envInt(name, fallback) {
|
|
35
38
|
const raw = process.env[name];
|
|
@@ -57,10 +60,12 @@ function envInt(name, fallback) {
|
|
|
57
60
|
*/
|
|
58
61
|
function proxyConfigured() {
|
|
59
62
|
const env = process.env;
|
|
60
|
-
if (
|
|
63
|
+
if (PROXY_VARS.some((name) => env[name])) return true;
|
|
61
64
|
if (env.NODE_USE_ENV_PROXY) return true;
|
|
62
65
|
try {
|
|
63
66
|
const g = undici().getGlobalDispatcher?.();
|
|
67
|
+
// Our own router sends its direct origins to the shared pool below.
|
|
68
|
+
if (_router && g === _router) return false;
|
|
64
69
|
// Any non-default global dispatcher (constructor name other than the plain
|
|
65
70
|
// `Agent` undici installs by default) is treated as custom — ProxyAgent,
|
|
66
71
|
// EnvHttpProxyAgent, MockAgent, or a user subclass — and we step aside.
|
|
@@ -71,6 +76,302 @@ function proxyConfigured() {
|
|
|
71
76
|
return false;
|
|
72
77
|
}
|
|
73
78
|
|
|
79
|
+
const PROXY_VARS = ['HTTPS_PROXY', 'https_proxy', 'HTTP_PROXY', 'http_proxy'];
|
|
80
|
+
// Loopback, private (RFC 1918) and link-local IPv4.
|
|
81
|
+
const LOCAL_V4_RANGES = [
|
|
82
|
+
['127.0.0.0', '127.255.255.255'],
|
|
83
|
+
['10.0.0.0', '10.255.255.255'],
|
|
84
|
+
['172.16.0.0', '172.31.255.255'],
|
|
85
|
+
['192.168.0.0', '192.168.255.255'],
|
|
86
|
+
['169.254.0.0', '169.254.255.255'],
|
|
87
|
+
];
|
|
88
|
+
// Loopback, unique-local and link-local IPv6.
|
|
89
|
+
const LOCAL_V6_SUBNETS = [
|
|
90
|
+
['::1', 128],
|
|
91
|
+
['fc00::', 7],
|
|
92
|
+
['fe80::', 10],
|
|
93
|
+
];
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* NO_PROXY for processes that follow the proxy variables natively (children,
|
|
97
|
+
* Node's http module). NO_PROXY matching is by name, suffix or exact address;
|
|
98
|
+
* fetch has no address ranges at all and Node's http module takes `a-b`
|
|
99
|
+
* ranges, so this list is a fallback: in-process, isLocalHost decides.
|
|
100
|
+
*/
|
|
101
|
+
export const LOCAL_NO_PROXY = [
|
|
102
|
+
'localhost',
|
|
103
|
+
'127.0.0.1',
|
|
104
|
+
'::1',
|
|
105
|
+
'.local',
|
|
106
|
+
...LOCAL_V4_RANGES.map(([start, end]) => `${start}-${end}`),
|
|
107
|
+
].join(',');
|
|
108
|
+
|
|
109
|
+
let _localAddresses = null;
|
|
110
|
+
function localAddresses() {
|
|
111
|
+
if (!_localAddresses) {
|
|
112
|
+
_localAddresses = new BlockList();
|
|
113
|
+
for (const [start, end] of LOCAL_V4_RANGES) _localAddresses.addRange(start, end, 'ipv4');
|
|
114
|
+
for (const [network, prefix] of LOCAL_V6_SUBNETS) _localAddresses.addSubnet(network, prefix, 'ipv6');
|
|
115
|
+
}
|
|
116
|
+
return _localAddresses;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export function normalizeHost(hostname) {
|
|
120
|
+
return String(hostname)
|
|
121
|
+
.replace(/^\[(.*)\]$/, '$1')
|
|
122
|
+
.replace(/\.$/, '')
|
|
123
|
+
.toLowerCase();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* A host that never goes through the proxy: a loopback, private or
|
|
128
|
+
* link-local address, a dotless name (`localhost`, a LAN machine) or a
|
|
129
|
+
* `.local` / `.localhost` name — local providers and LAN services.
|
|
130
|
+
*/
|
|
131
|
+
export function isLocalHost(hostname) {
|
|
132
|
+
const host = normalizeHost(hostname);
|
|
133
|
+
const family = isIP(host);
|
|
134
|
+
if (family) return localAddresses().check(host, family === 4 ? 'ipv4' : 'ipv6');
|
|
135
|
+
return !host.includes('.') || host.endsWith('.local') || host.endsWith('.localhost');
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* `env` plus what Node needs to honour its proxy variables: NODE_USE_ENV_PROXY
|
|
140
|
+
* (Node ignores HTTPS_PROXY without it) and a local NO_PROXY. Unchanged when
|
|
141
|
+
* no proxy variable is set or the user set NODE_USE_ENV_PROXY / NO_PROXY.
|
|
142
|
+
*/
|
|
143
|
+
export function withEnvProxy(env) {
|
|
144
|
+
if (env.NODE_USE_ENV_PROXY !== undefined || !PROXY_VARS.some((name) => env[name])) return env;
|
|
145
|
+
const noProxy = env.NO_PROXY || env.no_proxy ? {} : { NO_PROXY: LOCAL_NO_PROXY };
|
|
146
|
+
return { ...env, NODE_USE_ENV_PROXY: '1', ...noProxy };
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* The global dispatcher under a proxy: local and LAN hosts (isLocalHost, which
|
|
151
|
+
* includes every dotless name) connect directly, every other host follows the
|
|
152
|
+
* proxy variables and NO_PROXY. `direct` and `proxied` replace the two inner
|
|
153
|
+
* dispatchers (tests).
|
|
154
|
+
*/
|
|
155
|
+
export function createProxyDispatcher({ direct = null, proxied = null } = {}) {
|
|
156
|
+
const { Agent, Dispatcher, EnvHttpProxyAgent } = undici();
|
|
157
|
+
class LocalBypassProxyAgent extends Dispatcher {
|
|
158
|
+
#direct = direct ?? new Agent();
|
|
159
|
+
#proxied = proxied ?? new EnvHttpProxyAgent();
|
|
160
|
+
|
|
161
|
+
dispatch(opts, handler) {
|
|
162
|
+
const { hostname } = new URL(opts.origin);
|
|
163
|
+
return (isLocalHost(hostname) ? this.#direct : this.#proxied).dispatch(opts, handler);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
async close() {
|
|
167
|
+
await Promise.all([this.#direct.close(), this.#proxied.close()]);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
async destroy(error) {
|
|
171
|
+
await Promise.all([this.#direct.destroy(error), this.#proxied.destroy(error)]);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return new LocalBypassProxyAgent();
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
let _envProxyAdopted = false;
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Honour proxy variables in this already-running process (createProxyDispatcher
|
|
181
|
+
* as the global dispatcher) and, through the inherited env, in every child it
|
|
182
|
+
* spawns. No-op without a proxy variable, when the user set NODE_USE_ENV_PROXY
|
|
183
|
+
* to anything but 1, or once adopted.
|
|
184
|
+
*/
|
|
185
|
+
export function adoptEnvProxy(env = process.env) {
|
|
186
|
+
const next = withEnvProxy(env);
|
|
187
|
+
if (_envProxyAdopted || next.NODE_USE_ENV_PROXY !== '1' || !PROXY_VARS.some((name) => next[name])) return false;
|
|
188
|
+
env.NODE_USE_ENV_PROXY = '1';
|
|
189
|
+
if (next.NO_PROXY !== undefined) env.NO_PROXY = next.NO_PROXY;
|
|
190
|
+
undici().setGlobalDispatcher(createProxyDispatcher());
|
|
191
|
+
_envProxyAdopted = true;
|
|
192
|
+
return true;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/** A request the router could not hand to a leg fails through its handler. */
|
|
196
|
+
function failDispatch(handler, error) {
|
|
197
|
+
if (typeof handler.onResponseError === 'function') handler.onResponseError(null, error);
|
|
198
|
+
else handler.onError?.(error);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
const RESPONSE_CALLBACKS = ['onRequestUpgrade', 'onResponseStart', 'onResponseData', 'onResponseEnd', 'onResponseError'];
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Start a request whose leg is not known yet: its handler gets a controller at
|
|
205
|
+
* once, so an abort while the route is looked up settles it right away instead
|
|
206
|
+
* of when the lookup answers. Returns the handler to give the leg (which binds
|
|
207
|
+
* the controller to the real request), or null once aborted. Legacy handlers
|
|
208
|
+
* (no onRequestStart) start with the leg as before.
|
|
209
|
+
*/
|
|
210
|
+
function startDeferred(handler) {
|
|
211
|
+
if (typeof handler.onRequestStart !== 'function') return () => handler;
|
|
212
|
+
let inner = null;
|
|
213
|
+
let reason = null;
|
|
214
|
+
const controller = {
|
|
215
|
+
get aborted() {
|
|
216
|
+
return inner ? inner.aborted : reason !== null;
|
|
217
|
+
},
|
|
218
|
+
get paused() {
|
|
219
|
+
return inner?.paused ?? false;
|
|
220
|
+
},
|
|
221
|
+
get reason() {
|
|
222
|
+
return inner ? inner.reason : reason;
|
|
223
|
+
},
|
|
224
|
+
get rawHeaders() {
|
|
225
|
+
return inner?.rawHeaders;
|
|
226
|
+
},
|
|
227
|
+
get rawTrailers() {
|
|
228
|
+
return inner?.rawTrailers;
|
|
229
|
+
},
|
|
230
|
+
abort(cause) {
|
|
231
|
+
if (inner) return inner.abort(cause);
|
|
232
|
+
if (reason !== null) return;
|
|
233
|
+
reason = cause ?? new (undici().errors.RequestAbortedError)();
|
|
234
|
+
handler.onResponseError?.(controller, reason);
|
|
235
|
+
},
|
|
236
|
+
pause() {
|
|
237
|
+
inner?.pause();
|
|
238
|
+
},
|
|
239
|
+
resume() {
|
|
240
|
+
inner?.resume();
|
|
241
|
+
},
|
|
242
|
+
};
|
|
243
|
+
handler.onRequestStart(controller, {});
|
|
244
|
+
const forwarded = {
|
|
245
|
+
onRequestStart(real) {
|
|
246
|
+
inner = real;
|
|
247
|
+
},
|
|
248
|
+
};
|
|
249
|
+
for (const name of RESPONSE_CALLBACKS) {
|
|
250
|
+
if (typeof handler[name] === 'function') forwarded[name] = (...args) => handler[name](...args);
|
|
251
|
+
}
|
|
252
|
+
return () => (reason === null ? forwarded : null);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* A dispatcher that routes each origin on its own: local and LAN hosts connect
|
|
257
|
+
* directly without asking, every other origin by `route(origin)` — `{ proxy }`
|
|
258
|
+
* (a proxy URL, or null for direct), or a promise of one, which the request
|
|
259
|
+
* waits for. A request aborted meanwhile settles at once and is never sent.
|
|
260
|
+
* `direct()` gives the direct leg (read per request: the pool can be replaced),
|
|
261
|
+
* `proxied(uri)` builds the leg of one proxy, kept for reuse.
|
|
262
|
+
*/
|
|
263
|
+
export function createRoutedProxyDispatcher({
|
|
264
|
+
route,
|
|
265
|
+
direct = null,
|
|
266
|
+
proxied = (uri) => new (undici().ProxyAgent)({ uri }),
|
|
267
|
+
}) {
|
|
268
|
+
const { Agent, Dispatcher } = undici();
|
|
269
|
+
let ownDirect = null;
|
|
270
|
+
const directLeg = direct ?? (() => (ownDirect ??= new Agent()));
|
|
271
|
+
class SystemProxyRouter extends Dispatcher {
|
|
272
|
+
#proxied = new Map();
|
|
273
|
+
|
|
274
|
+
#leg(decision) {
|
|
275
|
+
const uri = decision?.proxy;
|
|
276
|
+
if (!uri) return directLeg();
|
|
277
|
+
let leg = this.#proxied.get(uri);
|
|
278
|
+
if (!leg) {
|
|
279
|
+
leg = proxied(uri);
|
|
280
|
+
this.#proxied.set(uri, leg);
|
|
281
|
+
}
|
|
282
|
+
return leg;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
dispatch(opts, handler) {
|
|
286
|
+
const url = new URL(opts.origin);
|
|
287
|
+
const decided = isLocalHost(url.hostname) ? null : route(url.origin);
|
|
288
|
+
if (typeof decided?.then !== 'function') return this.#leg(decided).dispatch(opts, handler);
|
|
289
|
+
const started = startDeferred(handler);
|
|
290
|
+
decided
|
|
291
|
+
.then(
|
|
292
|
+
(decision) => decision,
|
|
293
|
+
() => null
|
|
294
|
+
)
|
|
295
|
+
.then((decision) => {
|
|
296
|
+
const legHandler = started();
|
|
297
|
+
if (!legHandler) return;
|
|
298
|
+
try {
|
|
299
|
+
this.#leg(decision).dispatch(opts, legHandler);
|
|
300
|
+
} catch (error) {
|
|
301
|
+
failDispatch(legHandler, error);
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
return true;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
async close() {
|
|
308
|
+
await Promise.all([directLeg().close(), ...[...this.#proxied.values()].map((leg) => leg.close())]);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
async destroy(error) {
|
|
312
|
+
await Promise.all([
|
|
313
|
+
directLeg().destroy(error),
|
|
314
|
+
...[...this.#proxied.values()].map((leg) => leg.destroy(error)),
|
|
315
|
+
]);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
return new SystemProxyRouter();
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Route this process's fetch per origin by a proxy decision that came from the
|
|
323
|
+
* OS rather than from the user's environment (system-proxy.mjs): `route` as in
|
|
324
|
+
* createRoutedProxyDispatcher. It lives in the dispatcher only: no proxy
|
|
325
|
+
* variable is written, so shells, tools and other CLIs this process spawns see
|
|
326
|
+
* none. Direct origins use the shared LLM pool and every proxy leg its
|
|
327
|
+
* settings. No-op once a proxy is adopted.
|
|
328
|
+
*/
|
|
329
|
+
export function adoptPrivateProxy(route) {
|
|
330
|
+
if (_envProxyAdopted) return false;
|
|
331
|
+
const router = createRoutedProxyDispatcher({
|
|
332
|
+
route,
|
|
333
|
+
direct: llmAgent,
|
|
334
|
+
proxied: (uri) => new (undici().ProxyAgent)({ ...llmAgentOptions(), uri }),
|
|
335
|
+
});
|
|
336
|
+
undici().setGlobalDispatcher(router);
|
|
337
|
+
_router = router;
|
|
338
|
+
_envProxyAdopted = true;
|
|
339
|
+
return true;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
function llmAgentOptions() {
|
|
343
|
+
return {
|
|
344
|
+
keepAliveTimeout: envInt('MIXDOG_LLM_KEEPALIVE_MS', 60_000),
|
|
345
|
+
keepAliveMaxTimeout: envInt('MIXDOG_LLM_KEEPALIVE_MAX_MS', 90_000),
|
|
346
|
+
// No per-origin socket cap by default: each streaming (SSE) response
|
|
347
|
+
// holds its HTTP/1.1 socket for the whole generation, so a cap of N
|
|
348
|
+
// queued the (N+1)th concurrent agent until another finished. Rate
|
|
349
|
+
// limiting is the server's call (429 → admission cooldown).
|
|
350
|
+
connections: envInt('MIXDOG_LLM_CONNECTIONS', null),
|
|
351
|
+
// undici defaults both of these to 300s, which beheaded the Anthropic
|
|
352
|
+
// NON-STREAMING stall fallback (2026-08-03 regex-chess probe:
|
|
353
|
+
// UND_ERR_HEADERS_TIMEOUT at exactly 300s) — a non-streaming completion
|
|
354
|
+
// sends NO response headers until generation finishes, so a long silent
|
|
355
|
+
// generation legitimately exceeds 300s of header wait. Raise both to
|
|
356
|
+
// 600s: first-byte/idle protection is owned by the app-level watchdogs
|
|
357
|
+
// (provider first-byte + semantic idle + agent stall abort), which all
|
|
358
|
+
// fire below this transport ceiling; this layer is only the last-resort
|
|
359
|
+
// dead-socket bound.
|
|
360
|
+
headersTimeout: envInt('MIXDOG_LLM_HEADERS_TIMEOUT_MS', 600_000),
|
|
361
|
+
bodyTimeout: envInt('MIXDOG_LLM_BODY_TIMEOUT_MS', 600_000),
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/** The shared LLM pool, created again once closed or destroyed. */
|
|
366
|
+
function llmAgent() {
|
|
367
|
+
if (_agent?.destroyed || _agent?.closed) {
|
|
368
|
+
_agent = null;
|
|
369
|
+
_globalInstalled = false;
|
|
370
|
+
}
|
|
371
|
+
_agent ??= new (undici().Agent)(llmAgentOptions());
|
|
372
|
+
return _agent;
|
|
373
|
+
}
|
|
374
|
+
|
|
74
375
|
/**
|
|
75
376
|
* The shared singleton dispatcher for LLM API requests. Created on first use.
|
|
76
377
|
*
|
|
@@ -81,36 +382,12 @@ function proxyConfigured() {
|
|
|
81
382
|
* Returns `undefined` when a proxy / any custom (non-default) global dispatcher
|
|
82
383
|
* is configured, so `fetch({ dispatcher: undefined })` falls back to that
|
|
83
384
|
* global dispatcher instead of bypassing it. `dispatcher: undefined` is a
|
|
84
|
-
* harmless fetch option, so call sites need no change.
|
|
385
|
+
* harmless fetch option, so call sites need no change. Under the system-proxy
|
|
386
|
+
* router (the global dispatcher) the pool is its direct leg.
|
|
85
387
|
*/
|
|
86
388
|
export function getLlmDispatcher() {
|
|
87
|
-
if (proxyConfigured()) return undefined;
|
|
88
|
-
|
|
89
|
-
_agent = null;
|
|
90
|
-
_globalInstalled = false;
|
|
91
|
-
}
|
|
92
|
-
if (!_agent) {
|
|
93
|
-
_agent = new (undici().Agent)({
|
|
94
|
-
keepAliveTimeout: envInt('MIXDOG_LLM_KEEPALIVE_MS', 60_000),
|
|
95
|
-
keepAliveMaxTimeout: envInt('MIXDOG_LLM_KEEPALIVE_MAX_MS', 90_000),
|
|
96
|
-
// No per-origin socket cap by default: each streaming (SSE) response
|
|
97
|
-
// holds its HTTP/1.1 socket for the whole generation, so a cap of N
|
|
98
|
-
// queued the (N+1)th concurrent agent until another finished. Rate
|
|
99
|
-
// limiting is the server's call (429 → admission cooldown).
|
|
100
|
-
connections: envInt('MIXDOG_LLM_CONNECTIONS', null),
|
|
101
|
-
// undici defaults both of these to 300s, which beheaded the Anthropic
|
|
102
|
-
// NON-STREAMING stall fallback (2026-08-03 regex-chess probe:
|
|
103
|
-
// UND_ERR_HEADERS_TIMEOUT at exactly 300s) — a non-streaming completion
|
|
104
|
-
// sends NO response headers until generation finishes, so a long silent
|
|
105
|
-
// generation legitimately exceeds 300s of header wait. Raise both to
|
|
106
|
-
// 600s: first-byte/idle protection is owned by the app-level watchdogs
|
|
107
|
-
// (provider first-byte + semantic idle + agent stall abort), which all
|
|
108
|
-
// fire below this transport ceiling; this layer is only the last-resort
|
|
109
|
-
// dead-socket bound.
|
|
110
|
-
headersTimeout: envInt('MIXDOG_LLM_HEADERS_TIMEOUT_MS', 600_000),
|
|
111
|
-
bodyTimeout: envInt('MIXDOG_LLM_BODY_TIMEOUT_MS', 600_000),
|
|
112
|
-
});
|
|
113
|
-
}
|
|
389
|
+
if (proxyConfigured() || _router) return undefined;
|
|
390
|
+
llmAgent();
|
|
114
391
|
// mixdog standalone: separate undici instance from Node's fetch undici, so
|
|
115
392
|
// a per-request dispatcher throws UND_ERR_INVALID_ARG. Install globally once
|
|
116
393
|
// and omit the per-request dispatcher. See port-plan D7.
|
|
@@ -138,6 +415,13 @@ export function recycleLlmDispatcher() {
|
|
|
138
415
|
_agent = null;
|
|
139
416
|
_globalInstalled = false;
|
|
140
417
|
_preconnectedAt.clear();
|
|
418
|
+
// The router asks for the pool per request, so the next one gets a new pool.
|
|
419
|
+
if (_router) {
|
|
420
|
+
try {
|
|
421
|
+
old.close().catch(() => {});
|
|
422
|
+
} catch {}
|
|
423
|
+
return true;
|
|
424
|
+
}
|
|
141
425
|
getLlmDispatcher();
|
|
142
426
|
if (undici().getGlobalDispatcher() !== _agent) {
|
|
143
427
|
const unused = _agent;
|
|
@@ -155,10 +155,11 @@ function projectLitellmRow(row) {
|
|
|
155
155
|
// litellmPricing), not just the base price.
|
|
156
156
|
for (const [field, value] of Object.entries(row)) {
|
|
157
157
|
if (
|
|
158
|
-
(/^(?:input_cost_per_token|output_cost_per_token|cache_read_input_token_cost|cache_creation_input_token_cost)(?:_above_\d+k_tokens)?(?:_priority|_ultrafast)?$/.test(
|
|
158
|
+
(/^(?:input_cost_per_token|output_cost_per_token|cache_read_input_token_cost|cache_creation_input_token_cost)(?:_above_\d+k_tokens)?(?:_priority|_ultrafast|_flex)?$/.test(
|
|
159
159
|
field
|
|
160
160
|
) ||
|
|
161
|
-
/^output_cost_per_second_\w+$/.test(field)
|
|
161
|
+
/^output_cost_per_second_\w+$/.test(field) ||
|
|
162
|
+
field === 'regional_endpoint_uplift_multiplier') &&
|
|
162
163
|
typeof value === 'number' &&
|
|
163
164
|
Number.isFinite(value)
|
|
164
165
|
)
|
|
@@ -105,6 +105,7 @@ const _CATALOG_SIMPLE_PREFIXES = [
|
|
|
105
105
|
'deepseek/',
|
|
106
106
|
'openrouter/anthropic/',
|
|
107
107
|
'openrouter/openai/',
|
|
108
|
+
'vertex_ai/',
|
|
108
109
|
];
|
|
109
110
|
// Bedrock-style variants: catalog key = <prefix><id>-v1:0
|
|
110
111
|
const _CATALOG_BEDROCK_PREFIXES = ['anthropic.', 'bedrock/anthropic.'];
|
|
@@ -123,6 +124,7 @@ const _PROVIDER_CATALOG_PREFIXES = {
|
|
|
123
124
|
xai: ['xai/'],
|
|
124
125
|
deepseek: ['deepseek/'],
|
|
125
126
|
azure: ['azure_ai/'],
|
|
127
|
+
'google-vertex': ['vertex_ai/'],
|
|
126
128
|
};
|
|
127
129
|
function _prefixesForProvider(mappedProvider, allPrefixes) {
|
|
128
130
|
if (!mappedProvider) return allPrefixes;
|
|
@@ -438,6 +440,26 @@ const PRICED_VARIANTS = Object.freeze({
|
|
|
438
440
|
}),
|
|
439
441
|
});
|
|
440
442
|
|
|
443
|
+
// Vertex AI bills Claude and generally available Gemini 3+ models on regional
|
|
444
|
+
// and multi-region endpoints 10% above the global list price (Standard and
|
|
445
|
+
// Priority alike); the provider marks those requests' SKU `<id>@regional`.
|
|
446
|
+
// https://docs.anthropic.com/en/docs/about-claude/pricing (verified 2026-10-27)
|
|
447
|
+
// https://cloud.google.com/gemini-enterprise-agent-platform/generative-ai/pricing (verified 2026-10-28)
|
|
448
|
+
const VERTEX_REGIONAL_SUFFIX = '@regional';
|
|
449
|
+
function pricedVariant(provider, id) {
|
|
450
|
+
const listed = PRICED_VARIANTS[provider]?.[id];
|
|
451
|
+
if (listed) return listed;
|
|
452
|
+
if (provider === 'vertex-ai' && id.endsWith(VERTEX_REGIONAL_SUFFIX)) {
|
|
453
|
+
// The base row's own uplift wins; the documented 10% applies where the row has none.
|
|
454
|
+
return { base: id.slice(0, -VERTEX_REGIONAL_SUFFIX.length), rateMultiplier: 1.1, rowMultiplier: 'regionalUplift' };
|
|
455
|
+
}
|
|
456
|
+
// A pinned Vertex version (claude-sonnet-4-5@20250929, @default) bills as its
|
|
457
|
+
// model when no row prices the version itself.
|
|
458
|
+
const version = provider === 'vertex-ai' ? id.indexOf('@') : -1;
|
|
459
|
+
if (version > 0) return { base: id.slice(0, version), rateMultiplier: 1 };
|
|
460
|
+
return null;
|
|
461
|
+
}
|
|
462
|
+
|
|
441
463
|
// Cursor-billed rates no catalog publishes: Cursor's first-party SKUs and Fast
|
|
442
464
|
// rates Cursor sells beyond the vendor's own catalog. `fast` is the rate of a
|
|
443
465
|
// request Cursor ran in Fast mode. Other Cursor Fast requests bill at the
|
|
@@ -486,6 +508,7 @@ const PRICING_FIELDS = Object.freeze([
|
|
|
486
508
|
'pricingTiers',
|
|
487
509
|
'fastPricing',
|
|
488
510
|
'ultrafastPricing',
|
|
511
|
+
'flexPricing',
|
|
489
512
|
'offPeakMultiplier',
|
|
490
513
|
'outputImageCostPerM',
|
|
491
514
|
'outputVideoCostPerM',
|
|
@@ -649,17 +672,27 @@ function lookupModelMetadata(originalId, provider, catalog, modelsDevCatalog, li
|
|
|
649
672
|
if (source?.relay && !hasRates(meta) && hasRates(guess)) {
|
|
650
673
|
meta = meta ? { ...meta, ...pricingFields(guess) } : pricingOnly(guess);
|
|
651
674
|
}
|
|
652
|
-
const variant =
|
|
675
|
+
const variant = pricedVariant(source?.provider || '', id);
|
|
653
676
|
if (variant && !hasRates(meta)) {
|
|
654
677
|
const base = lookupModelMetadata(variant.base, provider, catalog, modelsDevCatalog);
|
|
655
678
|
if (base && PRICING_RATE_KEYS.some((key) => base[key] != null)) {
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
...scaledRates(
|
|
659
|
-
pricingTiers: (
|
|
679
|
+
const factor = (variant.rowMultiplier && base[variant.rowMultiplier]) || variant.rateMultiplier;
|
|
680
|
+
const scaled = (rateSet) => ({
|
|
681
|
+
...scaledRates(rateSet, factor),
|
|
682
|
+
pricingTiers: (rateSet.pricingTiers || []).map((tier) => ({
|
|
660
683
|
...tier,
|
|
661
|
-
...scaledRates(tier,
|
|
684
|
+
...scaledRates(tier, factor),
|
|
662
685
|
})),
|
|
686
|
+
});
|
|
687
|
+
meta = {
|
|
688
|
+
...meta,
|
|
689
|
+
...scaled(base),
|
|
690
|
+
// The variant's premium applies to every service tier the base publishes.
|
|
691
|
+
...Object.fromEntries(
|
|
692
|
+
['fastPricing', 'ultrafastPricing', 'flexPricing']
|
|
693
|
+
.filter((key) => base[key])
|
|
694
|
+
.map((key) => [key, scaled(base[key])])
|
|
695
|
+
),
|
|
663
696
|
pricingSource: base.pricingSource,
|
|
664
697
|
supportsPromptCaching: base.supportsPromptCaching,
|
|
665
698
|
};
|
|
@@ -740,6 +773,8 @@ function _normalize(entry) {
|
|
|
740
773
|
// OpenAI's Priority processing (since renamed Fast mode) columns.
|
|
741
774
|
const fastPricing = litellmPricing(entry, '_priority');
|
|
742
775
|
const ultrafastPricing = litellmPricing(entry, '_ultrafast');
|
|
776
|
+
// Flex processing (Vertex Flex PayGo, OpenAI flex) columns.
|
|
777
|
+
const flexPricing = litellmPricing(entry, '_flex');
|
|
743
778
|
return {
|
|
744
779
|
contextWindow: entry.max_input_tokens || entry.max_tokens || null,
|
|
745
780
|
outputTokens: entry.max_output_tokens || null,
|
|
@@ -747,7 +782,12 @@ function _normalize(entry) {
|
|
|
747
782
|
...litellmMediaPricing(entry),
|
|
748
783
|
...(PRICING_RATE_KEYS.some((key) => fastPricing[key] != null) ? { fastPricing } : {}),
|
|
749
784
|
...(PRICING_RATE_KEYS.some((key) => ultrafastPricing[key] != null) ? { ultrafastPricing } : {}),
|
|
785
|
+
...(PRICING_RATE_KEYS.some((key) => flexPricing[key] != null) ? { flexPricing } : {}),
|
|
750
786
|
...(entry.off_peak_multiplier ? { offPeakMultiplier: entry.off_peak_multiplier } : {}),
|
|
787
|
+
// Vertex AI regional / multi-region endpoint premium over the global rate.
|
|
788
|
+
...(entry.regional_endpoint_uplift_multiplier > 0
|
|
789
|
+
? { regionalUplift: entry.regional_endpoint_uplift_multiplier }
|
|
790
|
+
: {}),
|
|
751
791
|
// Tri-state: true/false as declared, undefined when the row is silent.
|
|
752
792
|
supportsVision: capabilityFlag(entry.supports_vision),
|
|
753
793
|
supportsFunctionCalling: capabilityFlag(entry.supports_function_calling),
|
|
@@ -58,6 +58,9 @@ const PROVIDER_CATALOGS = Object.freeze({
|
|
|
58
58
|
anthropic: { modelsDev: 'anthropic', sameEndpoint: true, rosterFiles: ['anthropic-oauth-models.json'] },
|
|
59
59
|
// generativelanguage.googleapis.com — the endpoint models.dev `google` describes.
|
|
60
60
|
gemini: { modelsDev: 'google', sameEndpoint: true, rosterFiles: ['gemini-models.json'] },
|
|
61
|
+
// *aiplatform.googleapis.com: Gemini and Claude publisher models, priced by
|
|
62
|
+
// the LiteLLM `vertex_ai/` rows (model-catalog.mjs prefix table).
|
|
63
|
+
'vertex-ai': { modelsDev: 'google-vertex', sameEndpoint: true },
|
|
61
64
|
// cli-chat-proxy.grok.com, not api.x.ai.
|
|
62
65
|
'grok-oauth': {
|
|
63
66
|
modelsDev: 'xai',
|