mixdog 1.2.2 → 1.2.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/README.md +18 -0
- package/package.json +2 -1
- package/scripts/gate-local.mjs +6 -4
- package/scripts/lib/gate-scheduler.mjs +29 -11
- package/scripts/probe-provider-catalog.mjs +31 -0
- package/scripts/provider-pingpong-live.mjs +599 -0
- package/scripts/session-sweep.mjs +5 -25
- package/src/agents/advisor/AGENT.md +1 -1
- package/src/agents/advisor/agent.json +1 -1
- package/src/agents/maintainer/AGENT.md +1 -1
- package/src/agents/maintainer/agent.json +1 -1
- package/src/agents/reviewer/AGENT.md +2 -4
- package/src/agents/security/AGENT.md +1 -2
- package/src/agents/writer/AGENT.md +2 -3
- package/src/defaults/shipped-history.json +11 -1
- package/src/defaults/skills/image/SKILL.md +21 -23
- package/src/defaults/skills/setup/SKILL.md +6 -1
- package/src/defaults/skills/setup/references/actions.md +44 -22
- package/src/defaults/skills/setup/references/surfaces.md +10 -8
- package/src/headless-exec.mjs +15 -8
- package/src/lib/keychain-cjs.cjs +20 -15
- package/src/output-styles/common.md +11 -10
- package/src/rules/agent/AGENT.md +6 -4
- package/src/rules/lead/LEAD.md +7 -9
- package/src/rules/shared/45-destructive.md +4 -0
- package/src/runtime/agent/orchestrator/agent-runtime/agent-dispatch/preset.mjs +1 -0
- package/src/runtime/agent/orchestrator/agent-runtime/agent-progress-watchdog.mjs +28 -7
- package/src/runtime/agent/orchestrator/agent-runtime/cache-strategy.mjs +2 -11
- package/src/runtime/agent/orchestrator/agent-trace-io.mjs +92 -61
- package/src/runtime/agent/orchestrator/cache-mtime.mjs +10 -1
- package/src/runtime/agent/orchestrator/config-providers-merge.mjs +7 -0
- package/src/runtime/agent/orchestrator/config.mjs +5 -0
- package/src/runtime/agent/orchestrator/context/collect.mjs +1 -0
- package/src/runtime/agent/orchestrator/context/deferred-tools.mjs +26 -7
- package/src/runtime/agent/orchestrator/context/skill-catalog.mjs +112 -7
- package/src/runtime/agent/orchestrator/mcp/child-tree.mjs +101 -23
- package/src/runtime/agent/orchestrator/providers/account-pool.mjs +2 -0
- package/src/runtime/agent/orchestrator/providers/anthropic-api-key-fetch.mjs +36 -0
- package/src/runtime/agent/orchestrator/providers/anthropic-api-request.mjs +48 -20
- package/src/runtime/agent/orchestrator/providers/anthropic-error-contract.mjs +3 -1
- package/src/runtime/agent/orchestrator/providers/anthropic-max-tokens.mjs +24 -17
- package/src/runtime/agent/orchestrator/providers/anthropic-messages.mjs +9 -9
- package/src/runtime/agent/orchestrator/providers/anthropic-oauth-client-version.mjs +1 -1
- package/src/runtime/agent/orchestrator/providers/anthropic-oauth-request/gzip-post.mjs +26 -44
- package/src/runtime/agent/orchestrator/providers/anthropic-oauth.mjs +31 -15
- package/src/runtime/agent/orchestrator/providers/anthropic-sse-turn/turn-blocks.mjs +20 -1
- package/src/runtime/agent/orchestrator/providers/anthropic-sse-turn/turn-events/content-block-delta.mjs +15 -2
- package/src/runtime/agent/orchestrator/providers/anthropic-sse-turn/turn-events/content-block-start.mjs +11 -4
- package/src/runtime/agent/orchestrator/providers/anthropic-sse-turn/turn-events/message-events.mjs +3 -0
- package/src/runtime/agent/orchestrator/providers/anthropic-sse-turn/turn-events.mjs +12 -5
- package/src/runtime/agent/orchestrator/providers/anthropic-sse-turn/turn-outcome.mjs +1 -0
- package/src/runtime/agent/orchestrator/providers/anthropic-sse-turn/turn-state.mjs +14 -0
- package/src/runtime/agent/orchestrator/providers/anthropic-sse.mjs +2 -0
- package/src/runtime/agent/orchestrator/providers/anthropic-turn-result.mjs +9 -0
- package/src/runtime/agent/orchestrator/providers/anthropic.mjs +10 -0
- package/src/runtime/agent/orchestrator/providers/antigravity-oauth-catalog.mjs +41 -12
- package/src/runtime/agent/orchestrator/providers/antigravity-oauth.mjs +13 -1
- package/src/runtime/agent/orchestrator/providers/antigravity-request.mjs +131 -9
- package/src/runtime/agent/orchestrator/providers/antigravity-response.mjs +29 -10
- package/src/runtime/agent/orchestrator/providers/antigravity-retry-policy.mjs +125 -8
- package/src/runtime/agent/orchestrator/providers/antigravity-stream.mjs +12 -62
- package/src/runtime/agent/orchestrator/providers/antigravity-transport.mjs +117 -41
- package/src/runtime/agent/orchestrator/providers/codex-client-meta.mjs +1 -1
- package/src/runtime/agent/orchestrator/providers/command-code-oauth.mjs +117 -72
- package/src/runtime/agent/orchestrator/providers/compat-request-policy.mjs +78 -2
- package/src/runtime/agent/orchestrator/providers/cursor-auth.mjs +39 -5
- package/src/runtime/agent/orchestrator/providers/cursor-client-version.mjs +1 -1
- package/src/runtime/agent/orchestrator/providers/cursor-native-context.mjs +48 -0
- package/src/runtime/agent/orchestrator/providers/cursor-wire-exec.mjs +144 -34
- package/src/runtime/agent/orchestrator/providers/cursor-wire-protobuf.mjs +28 -4
- package/src/runtime/agent/orchestrator/providers/cursor-wire-request.mjs +8 -4
- package/src/runtime/agent/orchestrator/providers/cursor-wire-stream-bridge.mjs +42 -11
- package/src/runtime/agent/orchestrator/providers/cursor-wire-stream-messages.mjs +109 -6
- package/src/runtime/agent/orchestrator/providers/cursor-wire.mjs +17 -4
- package/src/runtime/agent/orchestrator/providers/cursor.mjs +22 -2
- package/src/runtime/agent/orchestrator/providers/custom-provider-config.mjs +73 -7
- package/src/runtime/agent/orchestrator/providers/custom-provider.mjs +75 -6
- package/src/runtime/agent/orchestrator/providers/custom-reasoning.mjs +34 -7
- package/src/runtime/agent/orchestrator/providers/custom-tool-wire.mjs +32 -6
- package/src/runtime/agent/orchestrator/providers/deepseek.mjs +67 -0
- package/src/runtime/agent/orchestrator/providers/effort-configuration.mjs +29 -5
- package/src/runtime/agent/orchestrator/providers/gemini-cache-policy.mjs +11 -4
- package/src/runtime/agent/orchestrator/providers/gemini-cache.mjs +36 -13
- package/src/runtime/agent/orchestrator/providers/gemini-error-contract.mjs +101 -11
- package/src/runtime/agent/orchestrator/providers/gemini-request-body.mjs +41 -5
- package/src/runtime/agent/orchestrator/providers/gemini-response.mjs +1 -0
- package/src/runtime/agent/orchestrator/providers/gemini-rest-stream/watchdogs.mjs +16 -5
- package/src/runtime/agent/orchestrator/providers/gemini-retry-policy.mjs +19 -14
- package/src/runtime/agent/orchestrator/providers/gemini-schema.mjs +371 -41
- package/src/runtime/agent/orchestrator/providers/gemini-sdk-request.mjs +1 -2
- package/src/runtime/agent/orchestrator/providers/gemini-stream.mjs +97 -49
- package/src/runtime/agent/orchestrator/providers/gemini-thinking.mjs +81 -10
- package/src/runtime/agent/orchestrator/providers/gemini.mjs +35 -8
- package/src/runtime/agent/orchestrator/providers/grok-client-version.mjs +1 -1
- package/src/runtime/agent/orchestrator/providers/grok-oauth.mjs +1 -0
- package/src/runtime/agent/orchestrator/providers/lib/action-input-contract.mjs +60 -0
- package/src/runtime/agent/orchestrator/providers/lib/anthropic-native-blocks.mjs +1 -0
- package/src/runtime/agent/orchestrator/providers/lib/anthropic-request-utils.mjs +253 -42
- package/src/runtime/agent/orchestrator/providers/lib/anthropic-server-tool-usage.mjs +18 -0
- package/src/runtime/agent/orchestrator/providers/lib/anthropic-system-blocks.mjs +27 -6
- package/src/runtime/agent/orchestrator/providers/lib/claude-bridge-schema.mjs +392 -0
- package/src/runtime/agent/orchestrator/providers/lib/inclusive-usage.mjs +54 -0
- package/src/runtime/agent/orchestrator/providers/lib/origin-bound-fetch.mjs +16 -0
- package/src/runtime/agent/orchestrator/providers/lib/request-compression.mjs +86 -0
- package/src/runtime/agent/orchestrator/providers/lib/responses-terminal-fields.mjs +11 -0
- package/src/runtime/agent/orchestrator/providers/lib/usage-primitives.mjs +8 -0
- package/src/runtime/agent/orchestrator/providers/lib/wire-pairing.mjs +50 -22
- package/src/runtime/agent/orchestrator/providers/media-normalization.mjs +133 -21
- package/src/runtime/agent/orchestrator/providers/mimo-oauth-profile.mjs +13 -15
- package/src/runtime/agent/orchestrator/providers/mimo-oauth.mjs +7 -1
- package/src/runtime/agent/orchestrator/providers/model-proxy-channel.d.mts +1 -1
- package/src/runtime/agent/orchestrator/providers/model-proxy-channel.mjs +1 -0
- package/src/runtime/agent/orchestrator/providers/model-proxy-provider.mjs +92 -16
- package/src/runtime/agent/orchestrator/providers/oauth-credential-probes.mjs +13 -13
- package/src/runtime/agent/orchestrator/providers/openai-codex-metadata.mjs +2 -0
- package/src/runtime/agent/orchestrator/providers/openai-compat-chat-send.mjs +133 -62
- package/src/runtime/agent/orchestrator/providers/openai-compat-chat-stream/chunk-events.mjs +35 -14
- package/src/runtime/agent/orchestrator/providers/openai-compat-chat-stream/stream-result.mjs +5 -2
- package/src/runtime/agent/orchestrator/providers/openai-compat-chat-stream/stream-state.mjs +39 -7
- package/src/runtime/agent/orchestrator/providers/openai-compat-chat-stream/tool-call-acc.mjs +2 -9
- package/src/runtime/agent/orchestrator/providers/openai-compat-chat-stream.mjs +5 -0
- package/src/runtime/agent/orchestrator/providers/openai-compat-error-contract.mjs +1 -1
- package/src/runtime/agent/orchestrator/providers/openai-compat-models.mjs +84 -2
- package/src/runtime/agent/orchestrator/providers/openai-compat-options.mjs +47 -25
- package/src/runtime/agent/orchestrator/providers/openai-compat-presets.mjs +5 -1
- package/src/runtime/agent/orchestrator/providers/openai-compat-reasoning-field.mjs +155 -0
- package/src/runtime/agent/orchestrator/providers/openai-compat-response-normalization.mjs +40 -24
- package/src/runtime/agent/orchestrator/providers/openai-compat-responses-events.mjs +63 -25
- package/src/runtime/agent/orchestrator/providers/openai-compat-responses-head-parity.json +2901 -0
- package/src/runtime/agent/orchestrator/providers/openai-compat-responses-parity.fixtures.mjs +183 -0
- package/src/runtime/agent/orchestrator/providers/openai-compat-responses.mjs +87 -6
- package/src/runtime/agent/orchestrator/providers/openai-compat-retry-profile.mjs +51 -3
- package/src/runtime/agent/orchestrator/providers/openai-compat-stream.mjs +7 -1
- package/src/runtime/agent/orchestrator/providers/openai-compat-trace.mjs +2 -0
- package/src/runtime/agent/orchestrator/providers/openai-compat-wire.mjs +103 -26
- package/src/runtime/agent/orchestrator/providers/openai-compat-xai-send.mjs +23 -4
- package/src/runtime/agent/orchestrator/providers/openai-compat-xai.mjs +11 -6
- package/src/runtime/agent/orchestrator/providers/openai-compat.mjs +17 -2
- package/src/runtime/agent/orchestrator/providers/openai-direct-request.mjs +15 -23
- package/src/runtime/agent/orchestrator/providers/openai-http-sse-request.mjs +64 -52
- package/src/runtime/agent/orchestrator/providers/openai-http-sse-response-state/response-events/output-items.mjs +23 -10
- package/src/runtime/agent/orchestrator/providers/openai-http-sse-response-state/response-events/terminal-frames.mjs +28 -5
- package/src/runtime/agent/orchestrator/providers/openai-http-sse-response-state/response-events.mjs +10 -0
- package/src/runtime/agent/orchestrator/providers/openai-http-sse-response-state/response-items.mjs +18 -7
- package/src/runtime/agent/orchestrator/providers/openai-http-sse-response-state/response-outcome.mjs +4 -0
- package/src/runtime/agent/orchestrator/providers/openai-http-sse-response-state/response-state.mjs +5 -0
- package/src/runtime/agent/orchestrator/providers/openai-http-sse-response-state/text-relay.mjs +9 -1
- package/src/runtime/agent/orchestrator/providers/openai-model-capabilities.mjs +80 -0
- package/src/runtime/agent/orchestrator/providers/openai-oauth-dispatch.mjs +3 -1
- package/src/runtime/agent/orchestrator/providers/openai-oauth-http-sse.mjs +7 -0
- package/src/runtime/agent/orchestrator/providers/openai-oauth.mjs +7 -1
- package/src/runtime/agent/orchestrator/providers/openai-responses-input.mjs +72 -24
- package/src/runtime/agent/orchestrator/providers/openai-responses-payload-parity.fixture.json +323 -0
- package/src/runtime/agent/orchestrator/providers/openai-responses-payload.mjs +50 -16
- package/src/runtime/agent/orchestrator/providers/openai-ws-delta.mjs +7 -19
- package/src/runtime/agent/orchestrator/providers/openai-ws-response-state/refusals.mjs +60 -0
- package/src/runtime/agent/orchestrator/providers/openai-ws-response-state/tool-calls.mjs +51 -36
- package/src/runtime/agent/orchestrator/providers/openai-ws-response-state.mjs +30 -0
- package/src/runtime/agent/orchestrator/providers/openai-ws-stream/event-switch.mjs +12 -0
- package/src/runtime/agent/orchestrator/providers/openai-ws-stream/terminal-frames.mjs +25 -6
- package/src/runtime/agent/orchestrator/providers/openai-ws.mjs +18 -9
- package/src/runtime/agent/orchestrator/providers/opencode-go-gemini.mjs +181 -0
- package/src/runtime/agent/orchestrator/providers/opencode-go.mjs +78 -70
- package/src/runtime/agent/orchestrator/providers/openrouter.mjs +74 -0
- package/src/runtime/agent/orchestrator/providers/provider-error-kind.mjs +150 -10
- package/src/runtime/agent/orchestrator/providers/registry.mjs +13 -2
- package/src/runtime/agent/orchestrator/providers/retry-classification.mjs +7 -1
- package/src/runtime/agent/orchestrator/providers/transport-scope.d.mts +6 -0
- package/src/runtime/agent/orchestrator/providers/transport-scope.mjs +28 -0
- package/src/runtime/agent/orchestrator/providers/wire-gateway.mjs +164 -0
- package/src/runtime/agent/orchestrator/providers/wire-route.mjs +522 -0
- package/src/runtime/agent/orchestrator/providers/xai-tool-search-head-parity.json +1131 -0
- package/src/runtime/agent/orchestrator/providers/xai-tool-search.fixtures.mjs +195 -0
- package/src/runtime/agent/orchestrator/runtime-core/ask-user-tool-defs.mjs +104 -0
- package/src/runtime/agent/orchestrator/runtime-core/config-helpers.mjs +8 -6
- package/src/runtime/agent/orchestrator/runtime-core/deferred-tool-availability.mjs +24 -0
- package/src/runtime/agent/orchestrator/runtime-core/effort.mjs +15 -0
- package/src/runtime/agent/orchestrator/runtime-core/goal-store.mjs +30 -2
- package/src/runtime/agent/orchestrator/runtime-core/goal-turns.mjs +3 -2
- package/src/runtime/agent/orchestrator/runtime-core/orchestration.mjs +8 -3
- package/src/runtime/agent/orchestrator/runtime-core/provider-request-snapshot.mjs +7 -3
- package/src/runtime/agent/orchestrator/runtime-core/session-title.mjs +21 -1
- package/src/runtime/agent/orchestrator/runtime-core/skill-tool-loading.mjs +16 -3
- package/src/runtime/agent/orchestrator/runtime-core/tool-bridge-contract.mjs +6 -0
- package/src/runtime/agent/orchestrator/runtime-core/tool-bridge.mjs +526 -0
- package/src/runtime/agent/orchestrator/runtime-core/tool-catalog-data.mjs +3 -0
- package/src/runtime/agent/orchestrator/runtime-core/tool-catalog-schema.mjs +10 -7
- package/src/runtime/agent/orchestrator/runtime-core/tool-catalog.mjs +178 -71
- package/src/runtime/agent/orchestrator/runtime-core/tool-defs.mjs +102 -12
- package/src/runtime/agent/orchestrator/runtime-core/tool-exposure.mjs +96 -0
- package/src/runtime/agent/orchestrator/runtime-core/workflow.mjs +10 -8
- package/src/runtime/agent/orchestrator/session/agent-loop.mjs +1 -2
- package/src/runtime/agent/orchestrator/session/agent-pool-progress.mjs +24 -0
- package/src/runtime/agent/orchestrator/session/cache/tool-result-reuse.mjs +10 -2
- package/src/runtime/agent/orchestrator/session/catalog-db/index.mjs +2 -3
- package/src/runtime/agent/orchestrator/session/catalog-db/schema.mjs +5 -11
- package/src/runtime/agent/orchestrator/session/catalog-db/worker.mjs +6 -22
- package/src/runtime/agent/orchestrator/session/compact/constants.mjs +3 -2
- package/src/runtime/agent/orchestrator/session/compact/messages.mjs +16 -93
- package/src/runtime/agent/orchestrator/session/compact/runner.mjs +16 -2
- package/src/runtime/agent/orchestrator/session/compact/summary-anchor.mjs +5 -0
- package/src/runtime/agent/orchestrator/session/compact/user-message-kind.mjs +148 -0
- package/src/runtime/agent/orchestrator/session/compaction-archive-capture.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/context-tool-schema.mjs +17 -2
- package/src/runtime/agent/orchestrator/session/context-utils.mjs +8 -4
- package/src/runtime/agent/orchestrator/session/conversation-import/claude.mjs +0 -6
- package/src/runtime/agent/orchestrator/session/conversation-import/codex.mjs +0 -6
- package/src/runtime/agent/orchestrator/session/eager-dispatch/admission.mjs +3 -2
- package/src/runtime/agent/orchestrator/session/eager-dispatch.mjs +6 -1
- package/src/runtime/agent/orchestrator/session/historical-session-closure.mjs +10 -0
- package/src/runtime/agent/orchestrator/session/loop/assistant-commit.mjs +2 -5
- package/src/runtime/agent/orchestrator/session/loop/compact-policy.mjs +89 -1
- package/src/runtime/agent/orchestrator/session/loop/completion-guards.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/loop/context-overflow.mjs +56 -0
- package/src/runtime/agent/orchestrator/session/loop/deferred-call-through.mjs +18 -8
- package/src/runtime/agent/orchestrator/session/loop/loop-state.mjs +1 -27
- package/src/runtime/agent/orchestrator/session/loop/no-tool-turn/output-limit.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/loop/no-tool-turn/segments.mjs +4 -10
- package/src/runtime/agent/orchestrator/session/loop/no-tool-turn.mjs +2 -9
- package/src/runtime/agent/orchestrator/session/loop/pre-dispatch-deny.mjs +24 -10
- package/src/runtime/agent/orchestrator/session/loop/provider-tool-exclusions.mjs +135 -0
- package/src/runtime/agent/orchestrator/session/loop/request-boundary.mjs +31 -4
- package/src/runtime/agent/orchestrator/session/loop/route-fallback.mjs +76 -0
- package/src/runtime/agent/orchestrator/session/loop/send-phase.mjs +67 -20
- package/src/runtime/agent/orchestrator/session/loop/step-auto-effort.mjs +10 -10
- package/src/runtime/agent/orchestrator/session/loop/tool-call-resolution.mjs +95 -0
- package/src/runtime/agent/orchestrator/session/loop/tool-classify.mjs +6 -0
- package/src/runtime/agent/orchestrator/session/loop/tool-exec/before-hook.mjs +30 -3
- package/src/runtime/agent/orchestrator/session/loop/tool-exec/dispatch.mjs +29 -5
- package/src/runtime/agent/orchestrator/session/loop/tool-exec.mjs +15 -1
- package/src/runtime/agent/orchestrator/session/loop/tool-exposure-migration.mjs +147 -0
- package/src/runtime/agent/orchestrator/session/loop/tool-phase.mjs +7 -5
- package/src/runtime/agent/orchestrator/session/manager/ask-session.mjs +33 -3
- package/src/runtime/agent/orchestrator/session/manager/ask-support.mjs +0 -4
- package/src/runtime/agent/orchestrator/session/manager/ask-turn-auto-effort.mjs +23 -2
- package/src/runtime/agent/orchestrator/session/manager/ask-turn-commit.mjs +34 -12
- package/src/runtime/agent/orchestrator/session/manager/ask-turn-execute.mjs +54 -13
- package/src/runtime/agent/orchestrator/session/manager/ask-turn-failure.mjs +33 -0
- package/src/runtime/agent/orchestrator/session/manager/ask-turn-loop-options.mjs +57 -25
- package/src/runtime/agent/orchestrator/session/manager/ask-turn-prepare.mjs +11 -0
- package/src/runtime/agent/orchestrator/session/manager/ask-turn-settle.mjs +22 -0
- package/src/runtime/agent/orchestrator/session/manager/ask-turn-state.mjs +57 -13
- package/src/runtime/agent/orchestrator/session/manager/compaction-runner.mjs +8 -0
- package/src/runtime/agent/orchestrator/session/manager/failed-turn-rewind.mjs +16 -0
- package/src/runtime/agent/orchestrator/session/manager/pending-messages.mjs +6 -120
- package/src/runtime/agent/orchestrator/session/manager/pending-persist-queue.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/manager/prompt-utils.mjs +231 -16
- package/src/runtime/agent/orchestrator/session/manager/runtime-liveness.mjs +42 -49
- package/src/runtime/agent/orchestrator/session/manager/runtime-state.mjs +50 -0
- package/src/runtime/agent/orchestrator/session/manager/session-close.mjs +47 -17
- package/src/runtime/agent/orchestrator/session/manager/session-crud.mjs +26 -4
- package/src/runtime/agent/orchestrator/session/manager/session-fallback-title.mjs +82 -0
- package/src/runtime/agent/orchestrator/session/manager/session-lifecycle.mjs +36 -35
- package/src/runtime/agent/orchestrator/session/manager/session-prompt-composition.mjs +29 -13
- package/src/runtime/agent/orchestrator/session/manager/session-record.mjs +6 -3
- package/src/runtime/agent/orchestrator/session/manager/tool-resolution.mjs +4 -1
- package/src/runtime/agent/orchestrator/session/manager/turn-checkpoint-recovery.mjs +45 -0
- package/src/runtime/agent/orchestrator/session/manager.mjs +4 -10
- package/src/runtime/agent/orchestrator/session/pre-send-compact.mjs +6 -0
- package/src/runtime/agent/orchestrator/session/send-instrumentation.mjs +2 -1
- package/src/runtime/agent/orchestrator/session/send-with-recovery.mjs +17 -1
- package/src/runtime/agent/orchestrator/session/side-question-store.mjs +96 -0
- package/src/runtime/agent/orchestrator/session/side-question.mjs +197 -0
- package/src/runtime/agent/orchestrator/session/store/lifecycle-barriers.mjs +22 -15
- package/src/runtime/agent/orchestrator/session/store/lifecycle-read.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/store/listing.mjs +2 -6
- package/src/runtime/agent/orchestrator/session/store/live-cache-eviction.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/store/live-state.mjs +23 -0
- package/src/runtime/agent/orchestrator/session/store/liveness-veto.mjs +46 -37
- package/src/runtime/agent/orchestrator/session/store/load-cache.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/store/load-session.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/store/session-delete.mjs +44 -37
- package/src/runtime/agent/orchestrator/session/store/session-observers.mjs +4 -2
- package/src/runtime/agent/orchestrator/session/store/session-paths.mjs +59 -0
- package/src/runtime/agent/orchestrator/session/store/summary-cache.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/store/sweep/stale-sweep.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/store/sweep/sweep-finish.mjs +27 -21
- package/src/runtime/agent/orchestrator/session/store/sweep/sweep-plan.mjs +0 -8
- package/src/runtime/agent/orchestrator/session/store/sweep/sweep-record.mjs +6 -18
- package/src/runtime/agent/orchestrator/session/store/sweep/sweep-row.mjs +33 -106
- package/src/runtime/agent/orchestrator/session/store/write-admission.mjs +4 -2
- package/src/runtime/agent/orchestrator/session/store-agent-worker-pool.mjs +5 -8
- package/src/runtime/agent/orchestrator/session/store-agent-worker-rows.mjs +136 -196
- package/src/runtime/agent/orchestrator/session/store-summary-archived-agent.mjs +34 -15
- package/src/runtime/agent/orchestrator/session/store-summary-catalog.mjs +53 -115
- package/src/runtime/agent/orchestrator/session/store-summary-fields.mjs +8 -0
- package/src/runtime/agent/orchestrator/session/store-summary-index.mjs +10 -1
- package/src/runtime/agent/orchestrator/session/store-summary-locations.mjs +3 -29
- package/src/runtime/agent/orchestrator/session/store-summary-reader-catalog-fixture.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/store-summary-reader.mjs +17 -10
- package/src/runtime/agent/orchestrator/session/store-transcript-projection.mjs +9 -20
- package/src/runtime/agent/orchestrator/session/store.mjs +22 -19
- package/src/runtime/agent/orchestrator/session/tool-batch/execute-call.mjs +12 -12
- package/src/runtime/agent/orchestrator/session/tool-batch/finalize.mjs +38 -14
- package/src/runtime/agent/orchestrator/session/tool-batch/pre-dispatch.mjs +15 -4
- package/src/runtime/agent/orchestrator/session/tool-batch/record-outcome.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/tool-batch/state.mjs +7 -1
- package/src/runtime/agent/orchestrator/session/tool-result-offload.mjs +4 -0
- package/src/runtime/agent/orchestrator/session/tool-schema-rejection.mjs +79 -0
- package/src/runtime/agent/orchestrator/session/transcript-restore/restore.mjs +72 -15
- package/src/runtime/agent/orchestrator/session/turn-failure.mjs +45 -0
- package/src/runtime/agent/orchestrator/stall-policy.mjs +50 -0
- package/src/runtime/agent/orchestrator/tools/bash-policy-scan.mjs +8 -2
- package/src/runtime/agent/orchestrator/tools/builtin/bash-tool/command-preflight.mjs +3 -3
- package/src/runtime/agent/orchestrator/tools/builtin/bash-tool/completed-result.mjs +5 -1
- package/src/runtime/agent/orchestrator/tools/builtin/bash-tool/inline-hoist.mjs +6 -2
- package/src/runtime/agent/orchestrator/tools/builtin/bash-tool.mjs +4 -1
- package/src/runtime/agent/orchestrator/tools/builtin/external-tool-adapters.mjs +218 -20
- package/src/runtime/agent/orchestrator/tools/builtin/git-command-tool.mjs +160 -39
- package/src/runtime/agent/orchestrator/tools/builtin/git-partial-stage.mjs +7 -5
- package/src/runtime/agent/orchestrator/tools/builtin/grep-formatting.mjs +14 -5
- package/src/runtime/agent/orchestrator/tools/builtin/lib/grep-context-expander.mjs +4 -3
- package/src/runtime/agent/orchestrator/tools/builtin/lib/grep-output.mjs +2 -1
- package/src/runtime/agent/orchestrator/tools/builtin/lib/grep-path-fanout.mjs +48 -44
- package/src/runtime/agent/orchestrator/tools/builtin/lib/search-input-helpers.mjs +10 -3
- package/src/runtime/agent/orchestrator/tools/builtin/lib/shell-job-records.mjs +247 -49
- package/src/runtime/agent/orchestrator/tools/builtin/lib/shell-task-output.mjs +5 -4
- package/src/runtime/agent/orchestrator/tools/builtin/read-formatting.mjs +6 -1
- package/src/runtime/agent/orchestrator/tools/builtin/runtime-capabilities.mjs +23 -1
- package/src/runtime/agent/orchestrator/tools/builtin/shell-analysis.mjs +20 -0
- package/src/runtime/agent/orchestrator/tools/builtin/shell-jobs.mjs +101 -2
- package/src/runtime/agent/orchestrator/tools/code-graph/dispatch/root-resolution.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/code-graph/search.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/code-graph-prewarm-worker.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/lib/owned-shell-trees.mjs +67 -0
- package/src/runtime/agent/orchestrator/tools/lib/process-table-fixture.mjs +50 -0
- package/src/runtime/agent/orchestrator/tools/lib/shell-descendants.mjs +303 -63
- package/src/runtime/agent/orchestrator/tools/lib/shell-run-background/promote-job.mjs +2 -0
- package/src/runtime/agent/orchestrator/tools/lib/shell-run-settle.mjs +108 -18
- package/src/runtime/agent/orchestrator/tools/lib/shell-run-spawn.mjs +77 -11
- package/src/runtime/agent/orchestrator/tools/lib/shell-run-state.mjs +81 -5
- package/src/runtime/agent/orchestrator/tools/patch/ui-diff.mjs +73 -39
- package/src/runtime/agent/orchestrator/tools/progress-message.mjs +18 -1
- package/src/runtime/agent/orchestrator/tools/shell-command.mjs +7 -4
- package/src/runtime/agent/orchestrator/tools/shell-exec-policy.mjs +88 -12
- package/src/runtime/agent/orchestrator/tools/shell-policy.mjs +2 -0
- package/src/runtime/attachments/store.d.mts +9 -0
- package/src/runtime/attachments/store.mjs +80 -9
- package/src/runtime/browser-bridge/browser-action-contract.d.mts +0 -1
- package/src/runtime/browser-bridge/browser-action-contract.mjs +0 -2
- package/src/runtime/computer-bridge/action-schema.mjs +219 -196
- package/src/runtime/computer-bridge/linux-readiness.d.mts +0 -2
- package/src/runtime/computer-bridge/linux-readiness.mjs +0 -16
- package/src/runtime/effort-judge/judge-client.mjs +21 -4
- package/src/runtime/effort-judge/judge-worker.mjs +4 -1
- package/src/runtime/github/tool.mjs +208 -17
- package/src/runtime/media/adapters/codex-image.mjs +140 -21
- package/src/runtime/media/catalog.mjs +4 -4
- package/src/runtime/media/chatgpt-usage.mjs +55 -0
- package/src/runtime/media/defaults.mjs +37 -0
- package/src/runtime/media/jobs.mjs +12 -2
- package/src/runtime/media/lanes.mjs +12 -0
- package/src/runtime/media/tool-defs.mjs +15 -4
- package/src/runtime/media/tool.mjs +41 -12
- package/src/runtime/media/upstream-error.mjs +72 -6
- package/src/runtime/memory/index.mjs +1 -0
- package/src/runtime/memory/lib/http-router/ingest-routes.mjs +22 -1
- package/src/runtime/memory/lib/ingest/transcript-offsets.mjs +2 -0
- package/src/runtime/memory/lib/ingest/transcript-rows.mjs +1 -0
- package/src/runtime/memory/lib/pg/adapter.mjs +98 -1
- package/src/runtime/memory/lib/pg/process.mjs +36 -33
- package/src/runtime/memory/lib/pg/run-child.mjs +49 -0
- package/src/runtime/memory/lib/pg/supervisor.mjs +112 -4
- package/src/runtime/memory/lib/runtime-fetcher.mjs +12 -13
- package/src/runtime/memory/lib/transcript-ingest.mjs +14 -0
- package/src/runtime/office/README.md +1 -1
- package/src/runtime/office/authoring/docx-html-runner.mjs +1 -1
- package/src/runtime/office/authoring/html-browser.mjs +18 -8
- package/src/runtime/office/authoring/html-document-author.mjs +2 -0
- package/src/runtime/office/authoring/pdf-html-runner.mjs +1 -1
- package/src/runtime/office/authoring/pptx-contact-sheet.mjs +2 -0
- package/src/runtime/office/authoring/pptx-html-measure.mjs +3 -1
- package/src/runtime/office/authoring/pptx-html-runner.mjs +2 -0
- package/src/runtime/office/authoring/xlsx-html-runner.mjs +3 -1
- package/src/runtime/office/core/office-actions-read.mjs +3 -0
- package/src/runtime/office/core/office-render-preview.mjs +2 -0
- package/src/runtime/office/core/office-session-dispatch.mjs +7 -0
- package/src/runtime/office/core/office-sessionless-actions.mjs +8 -0
- package/src/runtime/office/core/office-sessions.mjs +5 -0
- package/src/runtime/office/core/office-transactions.mjs +3 -0
- package/src/runtime/office/core/office-write-ledger.mjs +94 -0
- package/src/runtime/office/design/library/templates/mixdog-executive.mixdog-edit.pptx +0 -0
- package/src/runtime/office/index.mjs +29 -0
- package/src/runtime/office/pdf/pdf-analysis.mjs +0 -68
- package/src/runtime/office/pdf/pdf-edit-document.mjs +2 -0
- package/src/runtime/office/pdf/pdf-render.mjs +23 -7
- package/src/runtime/office/pdf/pdf-security.mjs +2 -0
- package/src/runtime/office/portable/portable-opc.mjs +4 -1
- package/src/runtime/office/quality/visual-diff.mjs +2 -0
- package/src/runtime/session-search/session-search-ingest.mjs +1 -1
- package/src/runtime/shared/agent-reap-state.mjs +13 -0
- package/src/runtime/shared/atomic-file.d.mts +1 -1
- package/src/runtime/shared/background-tasks.mjs +6 -1
- package/src/runtime/shared/bounded-file-read.mjs +13 -0
- package/src/runtime/shared/bounded-line-diff.mjs +191 -0
- package/src/runtime/shared/browser-launch.mjs +15 -0
- package/src/runtime/shared/buffered-appender.mjs +18 -0
- package/src/runtime/shared/config.mjs +78 -18
- package/src/runtime/shared/err-text.mjs +48 -4
- package/src/runtime/shared/file-lock.mjs +6 -5
- package/src/runtime/shared/file-permissions.d.mts +6 -1
- package/src/runtime/shared/file-permissions.mjs +54 -6
- package/src/runtime/shared/llm/anthropic-betas.mjs +1 -2
- package/src/runtime/shared/llm/anthropic-effort.mjs +6 -0
- package/src/runtime/shared/llm/provider-model-identities.mjs +1 -0
- package/src/runtime/shared/llm/usage-accounting.mjs +5 -2
- package/src/runtime/shared/llm/usage-ledger-rollup.mjs +3 -0
- package/src/runtime/shared/loopback-listener.mjs +9 -0
- package/src/runtime/shared/model-route-chain.d.mts +8 -0
- package/src/runtime/shared/model-route-chain.mjs +48 -0
- package/src/runtime/shared/model-route-fallback.mjs +22 -0
- package/src/runtime/shared/pid-liveness.mjs +12 -0
- package/src/runtime/shared/provider-api-key.mjs +8 -0
- package/src/runtime/shared/provider-timeout-phase.mjs +17 -0
- package/src/runtime/shared/quiet-progress.d.mts +35 -0
- package/src/runtime/shared/quiet-progress.mjs +101 -0
- package/src/runtime/shared/quota-resume-store.mjs +32 -1
- package/src/runtime/shared/read-row-numbers.mjs +44 -0
- package/src/runtime/shared/remote-intent.mjs +2 -42
- package/src/runtime/shared/review-diff.mjs +52 -0
- package/src/runtime/shared/session-sidebar-host.d.mts +4 -0
- package/src/runtime/shared/session-sidebar-host.mjs +38 -0
- package/src/runtime/shared/slow-span.mjs +121 -0
- package/src/runtime/shared/statusline/statusline-segments.mjs +52 -6
- package/src/runtime/shared/tool-card-model/card-header.mjs +7 -1
- package/src/runtime/shared/tool-card-model/generic-detail.mjs +39 -5
- package/src/runtime/shared/tool-card-model.mjs +5 -2
- package/src/runtime/shared/tool-output-budget.mjs +2 -0
- package/src/runtime/shared/tool-output-limit.mjs +4 -0
- package/src/runtime/shared/tool-primitives.mjs +13 -0
- package/src/runtime/shared/tool-result-summary.mjs +22 -1
- package/src/runtime/shared/tool-status.mjs +3 -2
- package/src/runtime/shared/tool-surface.mjs +20 -6
- package/src/runtime/shared/tool-work-units.mjs +54 -11
- package/src/runtime/shared/transcript-metadata.mjs +49 -1
- package/src/runtime/shared/transcript-turn-keys.mjs +33 -0
- package/src/runtime/shared/transcript-writer/purge.mjs +74 -0
- package/src/runtime/shared/transcript-writer/transcript-file.mjs +10 -1
- package/src/runtime/shared/transcript-writer.mjs +24 -6
- package/src/runtime/shared/turn-changes.mjs +269 -100
- package/src/runtime/shared/turn-review-reply.mjs +8 -39
- package/src/runtime/shared/turn-snapshot-store.mjs +19 -108
- package/src/runtime/shared/turn-snapshot.mjs +865 -683
- package/src/runtime/shared/turn-worktree-snapshot.mjs +183 -255
- package/src/runtime/shared/user-data-guard.mjs +262 -49
- package/src/runtime/shared/worktrees/activity-gate.mjs +175 -0
- package/src/runtime/shared/worktrees/branch-management.mjs +179 -0
- package/src/runtime/shared/worktrees/carry.mjs +533 -0
- package/src/runtime/shared/worktrees/contract.mjs +60 -0
- package/src/runtime/shared/worktrees/dependencies.mjs +456 -0
- package/src/runtime/shared/worktrees/file-recovery.mjs +84 -0
- package/src/runtime/shared/worktrees/git-head.mjs +214 -0
- package/src/runtime/shared/worktrees/git.mjs +8 -3
- package/src/runtime/shared/worktrees/include.mjs +125 -7
- package/src/runtime/shared/worktrees/lock.mjs +1 -1
- package/src/runtime/shared/worktrees/maintenance.mjs +20 -2
- package/src/runtime/shared/worktrees/manager.mjs +525 -31
- package/src/runtime/shared/worktrees/merge.mjs +31 -21
- package/src/runtime/shared/worktrees/owner.mjs +2 -1
- package/src/runtime/shared/worktrees/paths.d.mts +6 -0
- package/src/runtime/shared/worktrees/preparation-report.mjs +79 -0
- package/src/runtime/shared/worktrees/setup-commands.mjs +232 -0
- package/src/runtime/shared/worktrees/workspace-visibility.mjs +17 -0
- package/src/runtime/terminal-bridge/client.mjs +57 -20
- package/src/runtime/terminal-bridge/tool-defs.mjs +13 -6
- package/src/runtime/tidy/apply.mjs +47 -2
- package/src/runtime/tidy/run-engines.mjs +11 -5
- package/src/session-runtime/agent-tool-routing.mjs +19 -13
- package/src/session-runtime/boot/apis.mjs +20 -6
- package/src/session-runtime/boot/config.mjs +2 -0
- package/src/session-runtime/boot/facade.mjs +4 -0
- package/src/session-runtime/boot/infrastructure.mjs +6 -1
- package/src/session-runtime/boot/session.mjs +3 -3
- package/src/session-runtime/boot/tools.mjs +7 -1
- package/src/session-runtime/conversation-import/service.mjs +1 -1
- package/src/session-runtime/cwd-plugins/cwd-apply.mjs +12 -5
- package/src/session-runtime/goal-facade-api.mjs +2 -2
- package/src/session-runtime/internal-tool-executor/ask-user-tool.mjs +91 -0
- package/src/session-runtime/internal-tool-executor/bridge-tools.mjs +3 -1
- package/src/session-runtime/internal-tool-executor/knowledge-tools.mjs +15 -5
- package/src/session-runtime/internal-tool-executor/workspace-tools.mjs +137 -26
- package/src/session-runtime/internal-tool-executor.mjs +8 -2
- package/src/session-runtime/lifecycle/cold-heir.mjs +187 -0
- package/src/session-runtime/lifecycle/inheritance.mjs +71 -27
- package/src/session-runtime/lifecycle/session-catalog.mjs +25 -18
- package/src/session-runtime/lifecycle/session-switch/resume.mjs +6 -0
- package/src/session-runtime/lifecycle/session-switch/session-delete.mjs +36 -48
- package/src/session-runtime/lifecycle/session-switch.mjs +1 -1
- package/src/session-runtime/lifecycle/shared.mjs +5 -6
- package/src/session-runtime/lifecycle/teardown/session-close.mjs +6 -5
- package/src/session-runtime/lifecycle/teardown.mjs +70 -14
- package/src/session-runtime/lifecycle-api.mjs +1 -0
- package/src/session-runtime/mcp-glue/connect.mjs +17 -5
- package/src/session-runtime/media-api.mjs +8 -0
- package/src/session-runtime/model-route/route-ownership.mjs +60 -0
- package/src/session-runtime/model-route/route-persist.mjs +3 -2
- package/src/session-runtime/model-route/set-route.mjs +116 -36
- package/src/session-runtime/model-route/web-search-route.mjs +7 -2
- package/src/session-runtime/model-route-api.mjs +4 -2
- package/src/session-runtime/native-web-search/routes.mjs +37 -24
- package/src/session-runtime/native-web-search-usage.mjs +51 -0
- package/src/session-runtime/native-web-search.mjs +19 -9
- package/src/session-runtime/new-session-config.mjs +4 -2
- package/src/session-runtime/provider-auth/login.mjs +4 -0
- package/src/session-runtime/provider-auth/setup.mjs +4 -0
- package/src/session-runtime/provider-models/catalog-load.mjs +9 -0
- package/src/session-runtime/provider-models/web-search-catalog.mjs +23 -3
- package/src/session-runtime/provider-models.mjs +1 -0
- package/src/session-runtime/provider-usage.mjs +4 -0
- package/src/session-runtime/resource-scope-decorate.mjs +10 -3
- package/src/session-runtime/route-resolution.mjs +3 -1
- package/src/session-runtime/runtime-core.mjs +4 -0
- package/src/session-runtime/runtime-facade.mjs +6 -0
- package/src/session-runtime/runtime-review-api.mjs +8 -2
- package/src/session-runtime/services/agent-task-status.mjs +2 -0
- package/src/session-runtime/services/agent-tool/close-flow/close-all.mjs +0 -3
- package/src/session-runtime/services/agent-tool/close-flow.mjs +6 -7
- package/src/session-runtime/services/agent-tool/execute-send.mjs +2 -2
- package/src/session-runtime/services/agent-tool/execute-spawn.mjs +36 -3
- package/src/session-runtime/services/agent-tool/execute.mjs +9 -1
- package/src/session-runtime/services/agent-tool/helpers.mjs +30 -7
- package/src/session-runtime/services/agent-tool/index-write-queue.mjs +81 -20
- package/src/session-runtime/services/agent-tool/job-task-reconcile.mjs +7 -2
- package/src/session-runtime/services/agent-tool/job-views/session-progress.mjs +6 -3
- package/src/session-runtime/services/agent-tool/lead-worker-index/forgotten-leads.mjs +29 -0
- package/src/session-runtime/services/agent-tool/lead-worker-index/index-file.mjs +1 -1
- package/src/session-runtime/services/agent-tool/lead-worker-index/lead-rows.mjs +3 -4
- package/src/session-runtime/services/agent-tool/lead-worker-index/reap-timers.mjs +9 -3
- package/src/session-runtime/services/agent-tool/lead-worker-index/row-settlement.mjs +7 -18
- package/src/session-runtime/services/agent-tool/lead-worker-index.mjs +82 -13
- package/src/session-runtime/services/agent-tool/model-select.mjs +82 -0
- package/src/session-runtime/services/agent-tool/send-flow.mjs +24 -6
- package/src/session-runtime/services/agent-tool/spawn-flow/job-start.mjs +3 -1
- package/src/session-runtime/services/agent-tool/spawn-flow/spawn-prep.mjs +19 -5
- package/src/session-runtime/services/agent-tool/spawn-flow/spawn-run.mjs +5 -4
- package/src/session-runtime/services/agent-tool/spawn-flow.mjs +2 -1
- package/src/session-runtime/services/agent-tool/spawn-preset.mjs +3 -0
- package/src/session-runtime/services/agent-tool/tag-registry/tag-lookup.mjs +1 -3
- package/src/session-runtime/services/agent-tool/tag-registry/tag-refresh.mjs +1 -3
- package/src/session-runtime/services/agent-tool/tag-registry.mjs +18 -10
- package/src/session-runtime/services/agent-tool/terminal-reaper/scan-admission.mjs +8 -41
- package/src/session-runtime/services/agent-tool/terminal-reaper/stale-rows.mjs +3 -3
- package/src/session-runtime/services/agent-tool/terminal-reaper.mjs +6 -23
- package/src/session-runtime/services/agent-tool/terminal-trace.mjs +0 -1
- package/src/session-runtime/services/agent-tool/tool-def.mjs +7 -0
- package/src/session-runtime/services/agent-tool/worker-index/row-liveness.mjs +32 -20
- package/src/session-runtime/services/agent-tool/worker-index/row-shape.mjs +5 -2
- package/src/session-runtime/services/agent-tool/worker-index/row-store.mjs +10 -1
- package/src/session-runtime/services/agent-tool/worker-index.mjs +74 -15
- package/src/session-runtime/services/agent-tool.mjs +7 -0
- package/src/session-runtime/services/agent-watchdog-registry.mjs +2 -0
- package/src/session-runtime/services/channel-admin.mjs +19 -3
- package/src/session-runtime/services/memory-runtime-proxy/calls.mjs +4 -0
- package/src/session-runtime/services/memory-runtime-proxy.mjs +1 -0
- package/src/session-runtime/services/provider-admin.mjs +158 -15
- package/src/session-runtime/session-create/session-options.mjs +7 -5
- package/src/session-runtime/session-create/session-start-hook.mjs +2 -1
- package/src/session-runtime/session-transcript-purge.mjs +32 -0
- package/src/session-runtime/session-transcript.mjs +4 -5
- package/src/session-runtime/session-turn-api.mjs +17 -14
- package/src/session-runtime/settings-builtin-tools-api.mjs +18 -6
- package/src/session-runtime/setup-tool/executor.mjs +57 -9
- package/src/session-runtime/setup-tool/extended-actions.mjs +86 -6
- package/src/session-runtime/setup-tool/settings-contract.mjs +18 -3
- package/src/session-runtime/setup-tool/tool-defs.mjs +25 -4
- package/src/session-runtime/skills-api.mjs +3 -5
- package/src/session-runtime/tool-policy-refresh.mjs +83 -32
- package/src/session-runtime/tool-surface.mjs +5 -1
- package/src/session-runtime/turn/agent-ops.mjs +49 -2
- package/src/session-runtime/turn/compaction-gate.mjs +25 -0
- package/src/session-runtime/turn/session-ops.mjs +7 -5
- package/src/session-runtime/turn/side-question-ops.mjs +19 -0
- package/src/session-runtime/turn/turn-run/ask-callbacks.mjs +7 -1
- package/src/session-runtime/turn/turn-run/turn-prepare.mjs +12 -3
- package/src/session-runtime/turn/turn-run/turn-settle.mjs +18 -2
- package/src/session-runtime/turn/turn-run/turn-timing.mjs +4 -3
- package/src/session-runtime/turn/turn-run.mjs +26 -45
- package/src/session-runtime/usage-stats-api.mjs +46 -11
- package/src/session-runtime/workflow-agents-api/agent-route.mjs +16 -1
- package/src/session-runtime/workspace/admission-gate.mjs +44 -15
- package/src/session-runtime/workspace/project-branches.mjs +35 -41
- package/src/session-runtime/workspace/transition-steps.mjs +215 -116
- package/src/session-runtime/workspace/transitions.mjs +428 -73
- package/src/standalone/channel-transport.mjs +3 -4
- package/src/standalone/daemon-agent-control.mjs +9 -1
- package/src/standalone/daemon-desktop-runtime.mjs +32 -1
- package/src/standalone/daemon-local-session-bridge.mjs +14 -1
- package/src/standalone/daemon-owner.mjs +17 -4
- package/src/standalone/daemon-pg-stop.mjs +49 -0
- package/src/standalone/daemon-session-control.mjs +88 -0
- package/src/standalone/daemon-stop-budget.d.mts +2 -0
- package/src/standalone/daemon-stop-budget.mjs +18 -0
- package/src/standalone/daemon-stored-session-views.mjs +25 -3
- package/src/standalone/daemon-telemetry.mjs +19 -0
- package/src/standalone/daemon.mjs +63 -1
- package/src/standalone/desktop-service-registry.mjs +5 -0
- package/src/standalone/local-session-runtime.mjs +80 -30
- package/src/standalone/session-client.mjs +42 -0
- package/src/standalone/session-protocol.mjs +14 -0
- package/src/standalone/session-proxy/projection.mjs +41 -4
- package/src/standalone/session-runtime-inline-host/boot-loaders.mjs +15 -1
- package/src/standalone/session-runtime-inline-host.mjs +3 -0
- package/src/standalone/session-service/agent-tree/agent-cancel.mjs +91 -49
- package/src/standalone/session-service/agent-tree/agent-child.mjs +19 -1
- package/src/standalone/session-service/agent-tree/agent-registry.mjs +25 -0
- package/src/standalone/session-service/agent-tree/agent-turns.mjs +9 -1
- package/src/standalone/session-service/agent-tree.mjs +28 -2
- package/src/standalone/session-service/entries/session-loads.mjs +16 -5
- package/src/standalone/session-service/entries.mjs +1 -0
- package/src/standalone/session-service/projection/transcript-window.mjs +39 -0
- package/src/standalone/session-service/quota-resume.mjs +28 -13
- package/src/standalone/session-service/session-calls/session-action.mjs +18 -3
- package/src/standalone/session-service/session-calls/session-turns.mjs +17 -6
- package/src/standalone/session-service/session-calls/session-views.mjs +6 -0
- package/src/standalone/session-service-api.mjs +6 -1
- package/src/standalone/session-state-patch.d.mts +2 -1
- package/src/standalone/session-state-patch.mjs +41 -1
- package/src/standalone/session-tool-output.mjs +82 -0
- package/src/tui/App.jsx +25 -0
- package/src/tui/app/app-view/floating-panel.jsx +26 -1
- package/src/tui/app/app-view.jsx +2 -1
- package/src/tui/app/btw-controller.mjs +118 -0
- package/src/tui/app/create-app-pickers.mjs +2 -0
- package/src/tui/app/provider-setup/provider-items.mjs +8 -0
- package/src/tui/app/provider-setup-picker.mjs +15 -3
- package/src/tui/app/shell-layout/row-budgets.mjs +11 -1
- package/src/tui/app/shell-layout/surfaces.mjs +3 -1
- package/src/tui/app/slash-commands.mjs +19 -3
- package/src/tui/app/slash-dispatch/session-commands.mjs +68 -6
- package/src/tui/app/use-global-key-input/approval-shortcut.mjs +12 -0
- package/src/tui/app/use-global-key-input.mjs +5 -12
- package/src/tui/app/use-prompt-handlers.mjs +11 -0
- package/src/tui/components/BtwPanel.jsx +53 -0
- package/src/tui/components/QuestionPanel.jsx +275 -0
- package/src/tui/components/Spinner.jsx +4 -0
- package/src/tui/components/SpinnerByline.jsx +21 -2
- package/src/tui/components/question-panel-model.mjs +156 -0
- package/src/tui/components/status-line/local-line.mjs +10 -2
- package/src/tui/dist/index.mjs +2897 -1722
- package/src/tui/session/active-tool-summary.mjs +1 -1
- package/src/tui/session/context-state.mjs +4 -5
- package/src/tui/session/goal-continuation/continuation-queue.mjs +2 -3
- package/src/tui/session/goal-continuation/deadline-delivery.mjs +4 -2
- package/src/tui/session/goal-continuation/session-boundary.mjs +21 -0
- package/src/tui/session/quota-resume.mjs +140 -61
- package/src/tui/session/session-api/commands.mjs +14 -10
- package/src/tui/session/session-api/controls.mjs +14 -2
- package/src/tui/session/session-api/integrations.mjs +9 -2
- package/src/tui/session/session-api/lifecycle/dispose.mjs +3 -9
- package/src/tui/session/session-api/lifecycle/resume.mjs +2 -7
- package/src/tui/session/session-api/lifecycle.mjs +14 -11
- package/src/tui/session/session-api/media.mjs +2 -0
- package/src/tui/session/session-api/routes.mjs +81 -57
- package/src/tui/session/session-api/settings.mjs +9 -3
- package/src/tui/session/session-api/worktree.mjs +3 -2
- package/src/tui/session/session-api.mjs +1 -0
- package/src/tui/session/session-flow/auto-clear.mjs +1 -3
- package/src/tui/session/session-flow/drain.mjs +6 -4
- package/src/tui/session/session-flow/queue/entry-shape.mjs +2 -0
- package/src/tui/session/session-flow/queue/take-entries.mjs +2 -1
- package/src/tui/session/session-flow/queue.mjs +1 -1
- package/src/tui/session/tool-approval.mjs +20 -8
- package/src/tui/session/transcript-spill.mjs +14 -7
- package/src/tui/session/transcript-store/streaming-tail.mjs +1 -1
- package/src/tui/session/tui-steering-persist.mjs +3 -5
- package/src/tui/session/turn-quiet.mjs +53 -0
- package/src/tui/session/turn-stream.mjs +179 -32
- package/src/tui/session/turn.mjs +50 -36
- package/src/tui/session/worktree-setup-notice.mjs +38 -0
- package/src/tui/spinner-meta.mjs +10 -0
- package/src/tui/spinner-verbs.mjs +3 -0
- package/src/ui/statusline.mjs +13 -3
- package/src/workflows/default/WORKFLOW.md +3 -1
- package/src/runtime/agent/orchestrator/providers/model-pricing-rates.mjs +0 -1
- package/src/runtime/agent/orchestrator/session/manager/foreign-pending-messages.mjs +0 -346
- package/src/runtime/agent/orchestrator/session/manager/session-owner-liveness.mjs +0 -117
- package/src/runtime/agent/orchestrator/session/store/paths-heartbeat.mjs +0 -246
- package/src/session-runtime/services/agent-tool/terminal-reaper/reap-timers.mjs +0 -142
- package/src/session-runtime/turn/share-ops.mjs +0 -77
- package/src/tui/session/cross-surface-share.mjs +0 -406
- package/src/tui/session/live-share/delta.mjs +0 -153
- package/src/tui/session/live-share/mirror.mjs +0 -106
- package/src/tui/session/live-share/owner.mjs +0 -254
- package/src/tui/session/live-share/retry.mjs +0 -54
- package/src/tui/session/live-share/viewer/frame-router.mjs +0 -32
- package/src/tui/session/live-share/viewer/pipe-client.mjs +0 -108
- package/src/tui/session/live-share/viewer/submit-acks.mjs +0 -65
- package/src/tui/session/live-share/viewer/sync-waiters.mjs +0 -53
- package/src/tui/session/live-share/viewer.mjs +0 -99
- package/src/tui/session/live-share/wire.mjs +0 -44
- package/src/tui/session/live-share.mjs +0 -154
- package/src/tui/session/shared-dir-watch.mjs +0 -69
|
@@ -0,0 +1,526 @@
|
|
|
1
|
+
// Fixed tool bridge for sessions whose toolExposureMode is 'bridge-v1'
|
|
2
|
+
// (non-native providers, see tool-exposure.mjs): the shared load_tool
|
|
3
|
+
// describes tools by name (never loads them), and call_tool runs one target
|
|
4
|
+
// through the ordinary execution pipeline (the loop projects it into a call
|
|
5
|
+
// of the target itself, see session/loop/tool-call-resolution.mjs). The
|
|
6
|
+
// deferred roster names what exists. Discovery and description never grant
|
|
7
|
+
// execution permission; continuation tokens only carry a position and grant
|
|
8
|
+
// no authority.
|
|
9
|
+
import { createHash } from 'node:crypto';
|
|
10
|
+
import { BRIDGE_NAME_MAX_CHARS, isBridgeMetaTool } from './tool-bridge-contract.mjs';
|
|
11
|
+
import { clean } from './session-text.mjs';
|
|
12
|
+
import { isDeferredToolAvailable } from './deferred-tool-availability.mjs';
|
|
13
|
+
import {
|
|
14
|
+
deferredCatalogUnion,
|
|
15
|
+
filterSessionToolPolicy,
|
|
16
|
+
isReadonlySelectable,
|
|
17
|
+
toolSearchMatches,
|
|
18
|
+
} from './tool-catalog.mjs';
|
|
19
|
+
import { parseToolSelection, sortedCatalogByMeasuredUsage } from './tool-catalog-schema.mjs';
|
|
20
|
+
import { DEFERRED_SELECT_ALIASES } from './tool-catalog-data.mjs';
|
|
21
|
+
import { estimateTokens } from '../session/token-estimate.mjs';
|
|
22
|
+
import { preDispatchDenyForSession } from '../session/loop/pre-dispatch-deny.mjs';
|
|
23
|
+
import { resolveDeferredSelectMode } from '../session/loop/deferred-call-through.mjs';
|
|
24
|
+
import { providerToolExclusionReason, routeToolExclusionReason } from '../session/loop/provider-tool-exclusions.mjs';
|
|
25
|
+
|
|
26
|
+
export { isToolBridgeEnabled } from './tool-exposure.mjs';
|
|
27
|
+
|
|
28
|
+
export const BRIDGE_LOAD_TOOL_NAME = 'load_tool';
|
|
29
|
+
export const BRIDGE_CALL_TOOL_NAME = 'call_tool';
|
|
30
|
+
const DESCRIBE_MAX_NAMES = 8;
|
|
31
|
+
// Most definitions one request resolves to: every name an alias of the widest
|
|
32
|
+
// alias. A token naming more was not issued by this tool.
|
|
33
|
+
const MAX_ALIAS_MEMBERS = Math.max(1, ...Object.values(DEFERRED_SELECT_ALIASES).map((members) => members.length));
|
|
34
|
+
|
|
35
|
+
export const BRIDGE_LIMITS = Object.freeze({
|
|
36
|
+
nameMaxChars: BRIDGE_NAME_MAX_CHARS,
|
|
37
|
+
continuationMaxChars: 4096,
|
|
38
|
+
continuationMaxTargets: DESCRIBE_MAX_NAMES * MAX_ALIAS_MEMBERS,
|
|
39
|
+
describeMaxNames: DESCRIBE_MAX_NAMES,
|
|
40
|
+
describeMaxBytes: 16 * 1024,
|
|
41
|
+
describeMaxTokens: 4096,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// A continuation token travels in load_tool's own `names` field. Provider tool
|
|
45
|
+
// names never contain '@' or ':', so the prefix cannot name a tool.
|
|
46
|
+
export const BRIDGE_CONTINUATION_PREFIX = '@continue:';
|
|
47
|
+
|
|
48
|
+
const DESCRIBE_KEYS = new Set(['names']);
|
|
49
|
+
// What a bridge describe result tells the model to do with the definitions.
|
|
50
|
+
const DESCRIBE_NOTE =
|
|
51
|
+
'Run a deferred tool with call_tool {name, arguments}; call directly defined tools directly. When continueWith is set, call load_tool again with exactly those arguments for the rest.';
|
|
52
|
+
|
|
53
|
+
export function bridgeError(code, message) {
|
|
54
|
+
return { error: { code, message } };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function bridgeErrorText(code, message) {
|
|
58
|
+
return `Error: ${code}: ${message}`;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** Model-visible text for a bridge result object. */
|
|
62
|
+
export function formatBridgeResult(result) {
|
|
63
|
+
if (result?.error) return bridgeErrorText(result.error.code, result.error.message);
|
|
64
|
+
return JSON.stringify(result);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const isPlainObject = (value) => !!value && typeof value === 'object' && !Array.isArray(value);
|
|
68
|
+
const hashText = (text) => createHash('sha256').update(text).digest('hex').slice(0, 16);
|
|
69
|
+
|
|
70
|
+
function unknownKeysError(args, allowed, toolName) {
|
|
71
|
+
if (!isPlainObject(args)) return bridgeError('INVALID_ARGUMENTS', `${toolName} requires an arguments object.`);
|
|
72
|
+
const extra = Object.keys(args).filter((key) => !allowed.has(key));
|
|
73
|
+
if (!extra.length) return null;
|
|
74
|
+
return bridgeError('INVALID_ARGUMENTS', `${toolName} does not accept: ${extra.join(', ')}.`);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function fitsBudget(value, maxBytes, maxTokens) {
|
|
78
|
+
const text = JSON.stringify(value);
|
|
79
|
+
return Buffer.byteLength(text, 'utf8') <= maxBytes && estimateTokens(text) <= maxTokens;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// ---------------------------------------------------------------------------
|
|
83
|
+
// Continuation tokens: prefix + base64url JSON of the definitions still being
|
|
84
|
+
// paged (their indexes in the session's own available-tool list), their
|
|
85
|
+
// schema revision and the offset into the first of them. Requested, missing
|
|
86
|
+
// and blocked names never travel, so a token stays far below the decoder
|
|
87
|
+
// bound whatever names the request carried.
|
|
88
|
+
|
|
89
|
+
function encodeContinuation(indexes, revision, offset) {
|
|
90
|
+
const payload = Buffer.from(JSON.stringify({ v: 2, t: indexes, r: revision, o: offset }), 'utf8');
|
|
91
|
+
return `${BRIDGE_CONTINUATION_PREFIX}${payload.toString('base64url')}`;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Longest token a page over `count` definitions of `available` tools can emit,
|
|
95
|
+
// used to reserve room while filling it.
|
|
96
|
+
const reserveContinuation = (count, available) =>
|
|
97
|
+
encodeContinuation(Array(count).fill(available), 'f'.repeat(16), 99_999_999);
|
|
98
|
+
|
|
99
|
+
const invalidContinuation = () =>
|
|
100
|
+
bridgeError('INVALID_CONTINUATION', 'names holds a continuation token this tool did not return.');
|
|
101
|
+
|
|
102
|
+
// The token's payload, or an error; the revision is checked once the names resolve.
|
|
103
|
+
function decodeContinuation(token) {
|
|
104
|
+
if (token.length > BRIDGE_LIMITS.continuationMaxChars) return invalidContinuation();
|
|
105
|
+
let payload = null;
|
|
106
|
+
try {
|
|
107
|
+
const body = token.slice(BRIDGE_CONTINUATION_PREFIX.length);
|
|
108
|
+
const bytes = Buffer.from(body, 'base64url');
|
|
109
|
+
// Only the canonical encoding this tool emits is accepted.
|
|
110
|
+
if (bytes.toString('base64url') !== body) return invalidContinuation();
|
|
111
|
+
payload = JSON.parse(bytes.toString('utf8'));
|
|
112
|
+
} catch {
|
|
113
|
+
payload = null;
|
|
114
|
+
}
|
|
115
|
+
const indexes = payload?.t;
|
|
116
|
+
if (
|
|
117
|
+
payload?.v !== 2 ||
|
|
118
|
+
typeof payload.r !== 'string' ||
|
|
119
|
+
!isIndex(payload.o) ||
|
|
120
|
+
!Array.isArray(indexes) ||
|
|
121
|
+
!indexes.length ||
|
|
122
|
+
indexes.length > BRIDGE_LIMITS.continuationMaxTargets ||
|
|
123
|
+
!indexes.every(isIndex) ||
|
|
124
|
+
new Set(indexes).size !== indexes.length
|
|
125
|
+
) {
|
|
126
|
+
return invalidContinuation();
|
|
127
|
+
}
|
|
128
|
+
return { indexes, revision: payload.r, offset: payload.o };
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// A whole names value that is exactly one token: no padding, separators or other text.
|
|
132
|
+
const CONTINUATION_TOKEN_PATTERN = new RegExp(`^\\s*${BRIDGE_CONTINUATION_PREFIX}[A-Za-z0-9_-]+\\s*$`);
|
|
133
|
+
|
|
134
|
+
const catalogChanged = () =>
|
|
135
|
+
bridgeError(
|
|
136
|
+
'CATALOG_CHANGED',
|
|
137
|
+
'the described tools or their schemas changed since this continuation was issued; describe them again by name.'
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
// The `continueWith` arguments for the definitions still to page.
|
|
141
|
+
function continuationFor(remaining, offset, revisionOf) {
|
|
142
|
+
const token = encodeContinuation(
|
|
143
|
+
remaining.map((doc) => doc.index),
|
|
144
|
+
revisionOf(remaining),
|
|
145
|
+
offset
|
|
146
|
+
);
|
|
147
|
+
return { names: token };
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// A token's definitions in the session's current scope, or null when any is
|
|
151
|
+
// gone or now refused (the session changed; the token grants nothing).
|
|
152
|
+
function continuationTargets(session, indexes, available, mode) {
|
|
153
|
+
const eagerNames = eagerToolNames(session);
|
|
154
|
+
const tools = indexes.map((index) => available[index]);
|
|
155
|
+
if (tools.some((tool) => !tool || bridgeBlockReason(session, tool, mode, eagerNames))) return null;
|
|
156
|
+
return tools;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const isIndex = (value) => Number.isSafeInteger(value) && value >= 0;
|
|
160
|
+
|
|
161
|
+
// ---------------------------------------------------------------------------
|
|
162
|
+
// Session catalog: eager surface + deferred catalog union, current scope only.
|
|
163
|
+
|
|
164
|
+
function eagerToolNames(session) {
|
|
165
|
+
return new Set((Array.isArray(session?.tools) ? session.tools : []).map((tool) => clean(tool?.name)).filter(Boolean));
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Every tool currently available to the session (eager first wins), within
|
|
170
|
+
* its own policy: a tool its allowlist or denied tools exclude is unknown
|
|
171
|
+
* here (never described, listed or named as blocked).
|
|
172
|
+
*/
|
|
173
|
+
function availableBridgeTools(session) {
|
|
174
|
+
const eager = Array.isArray(session?.tools) ? session.tools : [];
|
|
175
|
+
const seen = new Set();
|
|
176
|
+
const out = [];
|
|
177
|
+
for (const tool of filterSessionToolPolicy([...eager, ...deferredCatalogUnion(session)], session)) {
|
|
178
|
+
const name = clean(tool?.name);
|
|
179
|
+
if (!name || seen.has(name) || !isDeferredToolAvailable(session, name)) continue;
|
|
180
|
+
seen.add(name);
|
|
181
|
+
out.push(tool);
|
|
182
|
+
}
|
|
183
|
+
return sortedCatalogByMeasuredUsage(out);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export function isBridgeReadonlySession(session, mode) {
|
|
187
|
+
return (
|
|
188
|
+
mode === 'readonly' ||
|
|
189
|
+
session?.deferredSurfaceMode === 'readonly' ||
|
|
190
|
+
resolveDeferredSelectMode(session) === 'readonly'
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// Why a currently available tool cannot run in this session, or null. Eager
|
|
195
|
+
// tools already passed the surface's own readonly filter.
|
|
196
|
+
function bridgeBlockReason(session, tool, mode, eagerNames) {
|
|
197
|
+
const name = clean(tool?.name);
|
|
198
|
+
const denial = preDispatchDenyForSession(session, { name, arguments: {} });
|
|
199
|
+
if (denial) return denial.replace(/^Error:\s*/, '');
|
|
200
|
+
// An eager tool the route never sends is not "directly available"; deferred
|
|
201
|
+
// ones run through call_tool and need no declaration.
|
|
202
|
+
const unsent = eagerNames.has(name) ? routeToolExclusionReason(session, tool) : null;
|
|
203
|
+
if (unsent) return unsent;
|
|
204
|
+
if (!eagerNames.has(name) && isBridgeReadonlySession(session, mode) && !isReadonlySelectable(tool)) {
|
|
205
|
+
return 'readonly mode';
|
|
206
|
+
}
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function lookupByName(tools, name) {
|
|
211
|
+
const key = clean(name);
|
|
212
|
+
if (!key) return null;
|
|
213
|
+
const lower = key.toLowerCase();
|
|
214
|
+
return (
|
|
215
|
+
tools.find((tool) => clean(tool?.name) === key) ||
|
|
216
|
+
tools.find((tool) => clean(tool?.name).toLowerCase() === lower) ||
|
|
217
|
+
null
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// ---------------------------------------------------------------------------
|
|
222
|
+
// load_tool (bridge mode): describe only.
|
|
223
|
+
|
|
224
|
+
const schemaRevisionOf = (document) => hashText(JSON.stringify(document));
|
|
225
|
+
|
|
226
|
+
// An offset between the halves of a surrogate pair is not a code point boundary.
|
|
227
|
+
function splitsSurrogatePair(text, offset) {
|
|
228
|
+
if (offset <= 0 || offset >= text.length) return false;
|
|
229
|
+
const before = text.charCodeAt(offset - 1);
|
|
230
|
+
const after = text.charCodeAt(offset);
|
|
231
|
+
return before >= 0xd800 && before <= 0xdbff && after >= 0xdc00 && after <= 0xdfff;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function toolDocument(tool) {
|
|
235
|
+
return {
|
|
236
|
+
name: clean(tool?.name),
|
|
237
|
+
description: typeof tool?.description === 'string' ? tool.description : '',
|
|
238
|
+
inputSchema:
|
|
239
|
+
tool?.inputSchema && typeof tool.inputSchema === 'object' ? tool.inputSchema : { type: 'object', properties: {} },
|
|
240
|
+
annotations: isPlainObject(tool?.annotations) ? tool.annotations : {},
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function describeNames(raw) {
|
|
245
|
+
if (typeof raw !== 'string' && (!Array.isArray(raw) || raw.some((item) => typeof item !== 'string'))) return null;
|
|
246
|
+
const names = [...new Set(parseToolSelection(raw))];
|
|
247
|
+
if (!names.length || names.length > BRIDGE_LIMITS.describeMaxNames) return null;
|
|
248
|
+
if (names.some((name) => name.length > BRIDGE_LIMITS.nameMaxChars)) return null;
|
|
249
|
+
return names;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// Requested names → available tools; an alias that names no tool expands to
|
|
253
|
+
// its members (existing load_tool alias compatibility).
|
|
254
|
+
function resolveDescribeTargets(session, names, mode, available) {
|
|
255
|
+
const eagerNames = eagerToolNames(session);
|
|
256
|
+
const targets = [];
|
|
257
|
+
const missing = [];
|
|
258
|
+
const blocked = [];
|
|
259
|
+
const seen = new Set();
|
|
260
|
+
const add = (tool) => {
|
|
261
|
+
const name = clean(tool?.name);
|
|
262
|
+
if (seen.has(name)) return;
|
|
263
|
+
seen.add(name);
|
|
264
|
+
const reason = bridgeBlockReason(session, tool, mode, eagerNames);
|
|
265
|
+
if (reason) blocked.push({ name, reason });
|
|
266
|
+
else targets.push(tool);
|
|
267
|
+
};
|
|
268
|
+
for (const requested of names) {
|
|
269
|
+
const tool = lookupByName(available, requested);
|
|
270
|
+
if (tool) {
|
|
271
|
+
add(tool);
|
|
272
|
+
continue;
|
|
273
|
+
}
|
|
274
|
+
const members = (DEFERRED_SELECT_ALIASES[requested.toLowerCase()] || [])
|
|
275
|
+
.map((member) => lookupByName(available, member))
|
|
276
|
+
.filter(Boolean);
|
|
277
|
+
if (members.length) members.forEach(add);
|
|
278
|
+
else missing.push(requested);
|
|
279
|
+
}
|
|
280
|
+
return { targets, missing, blocked };
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
const SEARCH_MAX_MATCHES = 20;
|
|
284
|
+
const SEARCH_DESCRIPTION_CHARS = 100;
|
|
285
|
+
|
|
286
|
+
// A requested name that is no tool is a keyword: a case-insensitive substring
|
|
287
|
+
// search over the deferred tools this session can run (the same availability,
|
|
288
|
+
// allow/deny and read-only rules as a lookup, so nothing the session cannot
|
|
289
|
+
// run is ever listed). Keywords with no hit stay in `missing`.
|
|
290
|
+
function searchKeywords(session, keywords, mode, available) {
|
|
291
|
+
const eagerNames = eagerToolNames(session);
|
|
292
|
+
const matches = [];
|
|
293
|
+
const missing = [];
|
|
294
|
+
let remaining = SEARCH_MAX_MATCHES;
|
|
295
|
+
for (const keyword of keywords) {
|
|
296
|
+
const tools = available
|
|
297
|
+
.filter((tool) => {
|
|
298
|
+
const name = clean(tool?.name);
|
|
299
|
+
return (
|
|
300
|
+
!eagerNames.has(name) &&
|
|
301
|
+
!isBridgeMetaTool(name) &&
|
|
302
|
+
toolSearchMatches(tool, keyword) &&
|
|
303
|
+
!bridgeBlockReason(session, tool, mode, eagerNames)
|
|
304
|
+
);
|
|
305
|
+
})
|
|
306
|
+
.slice(0, remaining)
|
|
307
|
+
.map((tool) => ({
|
|
308
|
+
name: clean(tool.name),
|
|
309
|
+
description: clean(tool.description).slice(0, SEARCH_DESCRIPTION_CHARS),
|
|
310
|
+
}));
|
|
311
|
+
if (!tools.length) {
|
|
312
|
+
missing.push(keyword);
|
|
313
|
+
continue;
|
|
314
|
+
}
|
|
315
|
+
remaining -= tools.length;
|
|
316
|
+
matches.push({ keyword, tools });
|
|
317
|
+
}
|
|
318
|
+
return { matches, missing };
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
// Largest code-point-aligned chunk of `text` from `offset` that keeps the page
|
|
322
|
+
// within budget; 0 when nothing more fits.
|
|
323
|
+
function largestChunk(text, offset, buildPage) {
|
|
324
|
+
const fits = (length) =>
|
|
325
|
+
fitsBudget(
|
|
326
|
+
buildPage(text.slice(offset, offset + length)),
|
|
327
|
+
BRIDGE_LIMITS.describeMaxBytes,
|
|
328
|
+
BRIDGE_LIMITS.describeMaxTokens
|
|
329
|
+
);
|
|
330
|
+
let low = 0;
|
|
331
|
+
let high = text.length - offset;
|
|
332
|
+
while (low < high) {
|
|
333
|
+
const middle = Math.ceil((low + high) / 2);
|
|
334
|
+
if (fits(middle)) low = middle;
|
|
335
|
+
else high = middle - 1;
|
|
336
|
+
}
|
|
337
|
+
// Never end a chunk between the halves of a surrogate pair (UTF-8 boundary).
|
|
338
|
+
const last = text.charCodeAt(offset + low - 1);
|
|
339
|
+
if (low > 0 && offset + low < text.length && last >= 0xd800 && last <= 0xdbff) low -= 1;
|
|
340
|
+
return low;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
export function describeBridgeTools(session, args = {}, { mode } = {}) {
|
|
344
|
+
const syntaxHint = ' Use load_tool {"names":["exact_tool_name"]}; the required key is names, not name.';
|
|
345
|
+
const invalid = unknownKeysError(args, DESCRIBE_KEYS, BRIDGE_LOAD_TOOL_NAME);
|
|
346
|
+
if (invalid) {
|
|
347
|
+
const hint = isPlainObject(args) && 'query' in args ? ' Pass exact names; the deferred tool list names them.' : '';
|
|
348
|
+
return bridgeError(invalid.error.code, `${invalid.error.message}${hint}${syntaxHint}`);
|
|
349
|
+
}
|
|
350
|
+
// A continuation token resumes an earlier request. It travels alone: names
|
|
351
|
+
// is split exactly as for a lookup, and a token beside any other value is
|
|
352
|
+
// refused rather than read as a missing name.
|
|
353
|
+
const raw = args.names;
|
|
354
|
+
let strings = [];
|
|
355
|
+
if (typeof raw === 'string') strings = [raw];
|
|
356
|
+
else if (Array.isArray(raw) && raw.every((item) => typeof item === 'string')) strings = raw;
|
|
357
|
+
let continuation = null;
|
|
358
|
+
if (strings.some((item) => item.includes(BRIDGE_CONTINUATION_PREFIX))) {
|
|
359
|
+
if (strings.length !== 1 || !CONTINUATION_TOKEN_PATTERN.test(strings[0])) {
|
|
360
|
+
return bridgeError('INVALID_ARGUMENTS', 'pass a continuation token alone in names.');
|
|
361
|
+
}
|
|
362
|
+
continuation = decodeContinuation(strings[0].trim());
|
|
363
|
+
if (continuation.error) return continuation;
|
|
364
|
+
}
|
|
365
|
+
const available = availableBridgeTools(session);
|
|
366
|
+
let targets;
|
|
367
|
+
let missing = [];
|
|
368
|
+
let blocked = [];
|
|
369
|
+
let matches = [];
|
|
370
|
+
if (continuation) {
|
|
371
|
+
targets = continuationTargets(session, continuation.indexes, available, mode);
|
|
372
|
+
if (!targets) return catalogChanged();
|
|
373
|
+
} else {
|
|
374
|
+
const names = describeNames(raw);
|
|
375
|
+
if (!names) {
|
|
376
|
+
return bridgeError(
|
|
377
|
+
'INVALID_ARGUMENTS',
|
|
378
|
+
`names must be 1-${BRIDGE_LIMITS.describeMaxNames} exact tool names of at most ${BRIDGE_LIMITS.nameMaxChars} characters.${syntaxHint}`
|
|
379
|
+
);
|
|
380
|
+
}
|
|
381
|
+
({ targets, missing, blocked } = resolveDescribeTargets(session, names, mode, available));
|
|
382
|
+
({ matches, missing } = searchKeywords(session, missing, mode, available));
|
|
383
|
+
}
|
|
384
|
+
const found = matches.length ? { matches } : {};
|
|
385
|
+
const docs = targets.map((tool) => {
|
|
386
|
+
const document = toolDocument(tool);
|
|
387
|
+
return {
|
|
388
|
+
index: available.indexOf(tool),
|
|
389
|
+
name: document.name,
|
|
390
|
+
schemaRevision: schemaRevisionOf(document),
|
|
391
|
+
value: document,
|
|
392
|
+
text: JSON.stringify(document),
|
|
393
|
+
};
|
|
394
|
+
});
|
|
395
|
+
const revisionOf = (list) => hashText(JSON.stringify(list.map((doc) => [doc.name, doc.schemaRevision])));
|
|
396
|
+
let entryIndex = 0;
|
|
397
|
+
let offset = 0;
|
|
398
|
+
if (continuation) {
|
|
399
|
+
if (continuation.revision !== revisionOf(docs)) return catalogChanged();
|
|
400
|
+
const at = continuation.offset;
|
|
401
|
+
if (at > docs[0].text.length || splitsSurrogatePair(docs[0].text, at)) return invalidContinuation();
|
|
402
|
+
offset = at;
|
|
403
|
+
}
|
|
404
|
+
const entries = [];
|
|
405
|
+
const reserve = { names: reserveContinuation(docs.length, available.length) };
|
|
406
|
+
const page = (extra) => ({
|
|
407
|
+
entries: [...entries, extra],
|
|
408
|
+
missing,
|
|
409
|
+
blocked,
|
|
410
|
+
...found,
|
|
411
|
+
note: DESCRIBE_NOTE,
|
|
412
|
+
continueWith: reserve,
|
|
413
|
+
});
|
|
414
|
+
const fits = (value) => fitsBudget(value, BRIDGE_LIMITS.describeMaxBytes, BRIDGE_LIMITS.describeMaxTokens);
|
|
415
|
+
let nextPosition = null;
|
|
416
|
+
for (; entryIndex < docs.length; entryIndex += 1, offset = 0) {
|
|
417
|
+
const doc = docs[entryIndex];
|
|
418
|
+
const head = { name: doc.name, schemaRevision: doc.schemaRevision };
|
|
419
|
+
if (offset === 0) {
|
|
420
|
+
const whole = { ...head, complete: true, document: doc.value };
|
|
421
|
+
if (fits(page(whole))) {
|
|
422
|
+
entries.push(whole);
|
|
423
|
+
continue;
|
|
424
|
+
}
|
|
425
|
+
// A document that fits on a page of its own starts the next page whole.
|
|
426
|
+
if (
|
|
427
|
+
entries.length &&
|
|
428
|
+
fits({ entries: [whole], missing, blocked, ...found, note: DESCRIBE_NOTE, continueWith: reserve })
|
|
429
|
+
) {
|
|
430
|
+
nextPosition = [entryIndex, 0];
|
|
431
|
+
break;
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
const chunkEntry = (chunk) => ({
|
|
435
|
+
...head,
|
|
436
|
+
complete: offset + chunk.length >= doc.text.length,
|
|
437
|
+
offset,
|
|
438
|
+
jsonTextChunk: chunk,
|
|
439
|
+
});
|
|
440
|
+
const length = largestChunk(doc.text, offset, (chunk) => page(chunkEntry(chunk)));
|
|
441
|
+
if (length === 0) {
|
|
442
|
+
if (!entries.length) return bridgeError('RESULT_TOO_LARGE', 'the description cannot fit in one result.');
|
|
443
|
+
nextPosition = [entryIndex, offset];
|
|
444
|
+
break;
|
|
445
|
+
}
|
|
446
|
+
const chunk = doc.text.slice(offset, offset + length);
|
|
447
|
+
entries.push(chunkEntry(chunk));
|
|
448
|
+
if (offset + length < doc.text.length) {
|
|
449
|
+
nextPosition = [entryIndex, offset + length];
|
|
450
|
+
break;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
const continueWith = nextPosition ? continuationFor(docs.slice(nextPosition[0]), nextPosition[1], revisionOf) : null;
|
|
454
|
+
// Never hand out a token the decoder would refuse.
|
|
455
|
+
if (continueWith && continueWith.names.length > BRIDGE_LIMITS.continuationMaxChars) {
|
|
456
|
+
return bridgeError(
|
|
457
|
+
'RESULT_TOO_LARGE',
|
|
458
|
+
'the remaining definitions cannot be continued; describe fewer tools at once.'
|
|
459
|
+
);
|
|
460
|
+
}
|
|
461
|
+
return { entries, missing, blocked, ...found, note: DESCRIBE_NOTE, continueWith };
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
// ---------------------------------------------------------------------------
|
|
465
|
+
// call_tool target resolution (session-scoped; rechecked at execution).
|
|
466
|
+
|
|
467
|
+
function catalogTool(session, name) {
|
|
468
|
+
return lookupByName(deferredCatalogUnion(session), name);
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* The deferred tool a call_tool request names, or an error. Policy (allow /
|
|
473
|
+
* deny, readonly, worker scoping, approvals) is left to the target's ordinary
|
|
474
|
+
* execution path so a bridged call is judged exactly like a direct one.
|
|
475
|
+
*/
|
|
476
|
+
export function resolveBridgeTarget(session, rawName) {
|
|
477
|
+
const name = typeof rawName === 'string' ? rawName.trim() : '';
|
|
478
|
+
if (!name || name.length > BRIDGE_LIMITS.nameMaxChars) {
|
|
479
|
+
return bridgeError('INVALID_ARGUMENTS', `name must be 1-${BRIDGE_LIMITS.nameMaxChars} characters.`);
|
|
480
|
+
}
|
|
481
|
+
if (isBridgeMetaTool(name)) {
|
|
482
|
+
return bridgeError('BRIDGE_RECURSION', `call_tool cannot run the bridge tool "${name}"; call it directly.`);
|
|
483
|
+
}
|
|
484
|
+
const eager = lookupByName(Array.isArray(session?.tools) ? session.tools : [], name);
|
|
485
|
+
if (eager) {
|
|
486
|
+
const direct = clean(eager.name);
|
|
487
|
+
const excluded = providerToolExclusionReason(session, direct) || routeToolExclusionReason(session, eager);
|
|
488
|
+
if (excluded) return bridgeError('TOOL_EXCLUDED', excluded);
|
|
489
|
+
return bridgeError(
|
|
490
|
+
'USE_DIRECT_TOOL',
|
|
491
|
+
`"${direct}" is directly available; call ${direct} directly instead of call_tool.`
|
|
492
|
+
);
|
|
493
|
+
}
|
|
494
|
+
const tool = catalogTool(session, name);
|
|
495
|
+
if (!tool) {
|
|
496
|
+
return bridgeError(
|
|
497
|
+
'TOOL_NOT_FOUND',
|
|
498
|
+
`no tool named "${name}" is available in this session; find tools with load_tool {names: keyword}.`
|
|
499
|
+
);
|
|
500
|
+
}
|
|
501
|
+
const canonical = clean(tool.name);
|
|
502
|
+
if (!isDeferredToolAvailable(session, canonical)) {
|
|
503
|
+
return bridgeError(
|
|
504
|
+
'TOOL_UNAVAILABLE',
|
|
505
|
+
`tool "${canonical}" is unavailable in the current session catalog; no call was sent.`
|
|
506
|
+
);
|
|
507
|
+
}
|
|
508
|
+
return { name: canonical, tool };
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
/** Execution-time recheck of a projected target (after hooks), or null. */
|
|
512
|
+
export function bridgeTargetUnavailable(session, name) {
|
|
513
|
+
const key = clean(name);
|
|
514
|
+
if (lookupByName(Array.isArray(session?.tools) ? session.tools : [], key)) return null;
|
|
515
|
+
const tool = catalogTool(session, key);
|
|
516
|
+
if (!tool) {
|
|
517
|
+
return bridgeErrorText('TOOL_NOT_FOUND', `no tool named "${key}" is available in this session; no call was sent.`);
|
|
518
|
+
}
|
|
519
|
+
if (!isDeferredToolAvailable(session, clean(tool.name))) {
|
|
520
|
+
return bridgeErrorText(
|
|
521
|
+
'TOOL_UNAVAILABLE',
|
|
522
|
+
`tool "${clean(tool.name)}" is unavailable in the current session catalog; no call was sent.`
|
|
523
|
+
);
|
|
524
|
+
}
|
|
525
|
+
return null;
|
|
526
|
+
}
|
|
@@ -74,6 +74,9 @@ export const DEFERRED_DEFAULT_LEAD_TOOLS = Object.freeze([
|
|
|
74
74
|
'shell',
|
|
75
75
|
'task',
|
|
76
76
|
'agent',
|
|
77
|
+
// Always on the Lead surface (native and bridge alike): a question is an
|
|
78
|
+
// optional move the model skips when it costs a load or call_tool hop.
|
|
79
|
+
'ask_user',
|
|
77
80
|
'Skill',
|
|
78
81
|
'load_tool',
|
|
79
82
|
]);
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
providerNativeToolPrefixCount,
|
|
8
8
|
} from './provider-request-tools.mjs';
|
|
9
9
|
import { MEASURED_TOOL_USAGE, ROUTE_TOOL_ORDER } from './tool-catalog-data.mjs';
|
|
10
|
+
import { nativeDeferredFamilyForRoute } from '../providers/wire-route.mjs';
|
|
10
11
|
|
|
11
12
|
const toolSchemaBreakdownMemo = new WeakMap();
|
|
12
13
|
|
|
@@ -78,7 +79,7 @@ export function toolSchemaBucket(tool) {
|
|
|
78
79
|
if (['shell', 'edit', 'apply_patch'].includes(name)) return 'mutation';
|
|
79
80
|
if (name === 'agent' || name === 'delegate') return 'agents';
|
|
80
81
|
if (name.includes('channel') || name.includes('webhook')) return 'channels';
|
|
81
|
-
if (name.includes('provider') || name === 'load_tool' || name === 'tool_search' || name === '
|
|
82
|
+
if (name.includes('provider') || name === 'load_tool' || name === 'tool_search' || name === 'session') return 'setup';
|
|
82
83
|
if (kind === 'control') return 'control';
|
|
83
84
|
return 'other';
|
|
84
85
|
}
|
|
@@ -171,23 +172,25 @@ export function immutableToolForSurface(tool) {
|
|
|
171
172
|
return frozen;
|
|
172
173
|
}
|
|
173
174
|
|
|
174
|
-
|
|
175
|
+
// `route` is the session's pinned wire route (session.wireRoute). The
|
|
176
|
+
// first-party Anthropic and OpenAI providers are native by name; a gateway or
|
|
177
|
+
// custom provider is native only on a route pinned with verified support
|
|
178
|
+
// (wire-route.mjs nativeDeferredFamilyForRoute), which is OFF everywhere today.
|
|
179
|
+
export function deferredProviderMode(provider, route = null) {
|
|
175
180
|
const p = clean(provider).toLowerCase();
|
|
176
181
|
if (p === 'gemini') return 'manifest';
|
|
177
|
-
if (p
|
|
178
|
-
return 'native';
|
|
179
|
-
}
|
|
182
|
+
if (nativeProviderFamily(p, route)) return 'native';
|
|
180
183
|
// xAI/Grok and every other OpenAI-compatible backend have no native
|
|
181
184
|
// tool_search/tool_search_output contract. Give them one complete canonical
|
|
182
185
|
// function array instead of a load-driven array whose bytes churn.
|
|
183
186
|
return 'canonical';
|
|
184
187
|
}
|
|
185
188
|
|
|
186
|
-
export function nativeProviderFamily(provider) {
|
|
189
|
+
export function nativeProviderFamily(provider, route = null) {
|
|
187
190
|
const p = clean(provider).toLowerCase();
|
|
188
191
|
if (p === 'openai' || p === 'openai-oauth') return 'openai';
|
|
189
192
|
if (p === 'anthropic' || p === 'anthropic-oauth') return 'anthropic';
|
|
190
|
-
return
|
|
193
|
+
return nativeDeferredFamilyForRoute(p, route);
|
|
191
194
|
}
|
|
192
195
|
|
|
193
196
|
export const ANTHROPIC_NATIVE_PROVIDERS = new Set(['anthropic', 'anthropic-oauth']);
|