mixdog 1.4.2 → 1.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/scripts/build-shipped-history.mjs +15 -5
- package/scripts/gate-local.mjs +65 -19
- package/scripts/graph-parity.mjs +8 -3
- package/scripts/lib/gate-scheduler.mjs +2 -1
- package/scripts/lib/run-node-tests.mjs +17 -5
- package/scripts/lib/test-failure-summary.mjs +1 -8
- package/scripts/lib/test-spawn-ledger.mjs +33 -2
- package/scripts/post-release-check.mjs +26 -16
- package/scripts/provider-pingpong-live.mjs +1 -1
- package/scripts/prune-embedding-runtime.mjs +3 -1
- package/scripts/release-paths.mjs +7 -1
- package/src/defaults/shipped-history.json +24 -0
- package/src/defaults/skills/computer-use/SKILL.md +14 -3
- package/src/defaults/skills/memory-management/SKILL.md +10 -5
- package/src/defaults/skills/setup/SKILL.md +2 -2
- package/src/defaults/skills/setup/references/actions.md +17 -4
- package/src/defaults/skills/setup/references/surfaces.md +3 -0
- package/src/defaults/skills/setup-guide/SKILL.md +6 -1
- package/src/lib/instruction-text.cjs +36 -0
- package/src/lib/rules-builder.cjs +34 -20
- package/src/orchestration/balanced.md +23 -0
- package/src/orchestration/focused.md +22 -0
- package/src/orchestration/none.md +5 -0
- package/src/orchestration/swarm.md +24 -0
- package/src/rules/agent-mode/AGENT_MODE.md +3 -1
- package/src/rules/agent-mode/MIXY.md +5 -3
- package/src/runtime/agent/orchestrator/agent-runtime/agent-dispatch/session-prep.mjs +3 -3
- package/src/runtime/agent/orchestrator/agent-runtime/agent-dispatch.mjs +0 -1
- package/src/runtime/agent/orchestrator/agent-runtime/agent-progress-watchdog.mjs +4 -2
- package/src/runtime/agent/orchestrator/agent-runtime/cache-strategy.mjs +0 -9
- package/src/runtime/agent/orchestrator/agent-runtime/heartbeat-completion.mjs +2 -2
- package/src/runtime/agent/orchestrator/agent-runtime/session-builder.mjs +67 -0
- package/src/runtime/agent/orchestrator/agent-trace-format.mjs +1 -0
- package/src/runtime/agent/orchestrator/context/role-instructions.mjs +4 -4
- package/src/runtime/agent/orchestrator/mcp/agent-connectors.mjs +3 -1
- package/src/runtime/agent/orchestrator/mcp/child-tree.mjs +199 -46
- package/src/runtime/agent/orchestrator/mcp/client-config.mjs +3 -5
- package/src/runtime/agent/orchestrator/mcp/client-transport.mjs +9 -3
- package/src/runtime/agent/orchestrator/mcp/client.mjs +3 -5
- package/src/runtime/agent/orchestrator/mcp/oauth-client.mjs +1 -1
- package/src/runtime/agent/orchestrator/mcp/oauth-credentials.mjs +8 -2
- package/src/runtime/agent/orchestrator/mcp/oauth-probe.mjs +1 -1
- package/src/runtime/agent/orchestrator/mcp/oauth-provider.mjs +14 -0
- package/src/runtime/agent/orchestrator/mcp/oauth.mjs +1 -1
- package/src/runtime/agent/orchestrator/providers/admission-scheduler.mjs +2 -1
- package/src/runtime/agent/orchestrator/providers/anthropic-api-request.mjs +11 -1
- package/src/runtime/agent/orchestrator/providers/anthropic-oauth-client-version.mjs +1 -1
- package/src/runtime/agent/orchestrator/providers/anthropic-sse-turn/turn-events/content-block-start.mjs +4 -0
- package/src/runtime/agent/orchestrator/providers/anthropic-sse-turn/turn-events/content-block-stop.mjs +3 -3
- package/src/runtime/agent/orchestrator/providers/anthropic-sse-turn/turn-outcome.mjs +2 -0
- package/src/runtime/agent/orchestrator/providers/anthropic-turn-result.mjs +2 -0
- package/src/runtime/agent/orchestrator/providers/anthropic.mjs +2 -0
- package/src/runtime/agent/orchestrator/providers/codex-client-meta.mjs +1 -1
- package/src/runtime/agent/orchestrator/providers/custom-provider-config.mjs +121 -9
- package/src/runtime/agent/orchestrator/providers/custom-provider.mjs +4 -1
- package/src/runtime/agent/orchestrator/providers/gemini-thinking.mjs +2 -2
- package/src/runtime/agent/orchestrator/providers/lib/generation-window.mjs +9 -0
- package/src/runtime/agent/orchestrator/providers/openai-compat-chat-send.mjs +9 -1
- package/src/runtime/agent/orchestrator/providers/openai-compat-chat-stream/stream-result.mjs +2 -0
- package/src/runtime/agent/orchestrator/providers/openai-compat-chat-stream/stream-state.mjs +5 -0
- package/src/runtime/agent/orchestrator/providers/openai-compat-options.mjs +3 -0
- package/src/runtime/agent/orchestrator/providers/openai-compat-response-normalization.mjs +6 -6
- package/src/runtime/agent/orchestrator/providers/openai-compat-responses-head-parity.json +2784 -2872
- package/src/runtime/agent/orchestrator/providers/openai-compat-responses.mjs +10 -1
- package/src/runtime/agent/orchestrator/providers/openai-compat-xai.mjs +5 -8
- package/src/runtime/agent/orchestrator/providers/openai-http-sse-response-state/response-events.mjs +3 -0
- package/src/runtime/agent/orchestrator/providers/openai-http-sse-response-state/response-outcome.mjs +2 -0
- package/src/runtime/agent/orchestrator/providers/openai-responses-payload-parity.fixture.json +288 -300
- package/src/runtime/agent/orchestrator/providers/openai-ws-response-state.mjs +9 -2
- package/src/runtime/agent/orchestrator/providers/openrouter-provider-routing.mjs +28 -0
- package/src/runtime/agent/orchestrator/providers/openrouter.mjs +4 -1
- package/src/runtime/agent/orchestrator/providers/registry.mjs +30 -25
- package/src/runtime/agent/orchestrator/providers/vertex-ai.mjs +10 -1
- package/src/runtime/agent/orchestrator/providers/xai-tool-search-head-parity.json +10 -30
- package/src/runtime/agent/orchestrator/runtime-core/ask-user-result.mjs +66 -0
- package/src/runtime/agent/orchestrator/runtime-core/builtin-features.mjs +30 -0
- package/src/runtime/agent/orchestrator/runtime-core/config-helpers.mjs +0 -11
- package/src/runtime/agent/orchestrator/runtime-core/deferred-tool-availability.mjs +8 -0
- package/src/runtime/agent/orchestrator/runtime-core/deferred-tool-delta.mjs +17 -3
- package/src/runtime/agent/orchestrator/runtime-core/goal-control.mjs +47 -27
- package/src/runtime/agent/orchestrator/runtime-core/goal-deadlines.mjs +141 -10
- package/src/runtime/agent/orchestrator/runtime-core/goal-mutations.mjs +26 -63
- package/src/runtime/agent/orchestrator/runtime-core/goal-reminder.mjs +28 -3
- package/src/runtime/agent/orchestrator/runtime-core/goal-runtime.mjs +36 -11
- package/src/runtime/agent/orchestrator/runtime-core/goal-state.mjs +88 -56
- package/src/runtime/agent/orchestrator/runtime-core/goal-storage.mjs +4 -1
- package/src/runtime/agent/orchestrator/runtime-core/goal-store.mjs +51 -32
- package/src/runtime/agent/orchestrator/runtime-core/goal-text.mjs +45 -145
- package/src/runtime/agent/orchestrator/runtime-core/goal-tool-defs.mjs +15 -98
- package/src/runtime/agent/orchestrator/runtime-core/goal-tool-exec.mjs +32 -99
- package/src/runtime/agent/orchestrator/runtime-core/goal-turns.mjs +23 -78
- package/src/runtime/agent/orchestrator/runtime-core/orchestration.mjs +69 -48
- package/src/runtime/agent/orchestrator/runtime-core/todo-list.mjs +367 -0
- package/src/runtime/agent/orchestrator/runtime-core/todo-tool-defs.mjs +47 -0
- package/src/runtime/agent/orchestrator/runtime-core/tool-availability.mjs +155 -0
- package/src/runtime/agent/orchestrator/runtime-core/tool-catalog-data.mjs +9 -0
- package/src/runtime/agent/orchestrator/runtime-core/tool-catalog.mjs +119 -35
- package/src/runtime/agent/orchestrator/runtime-core/tool-defs.mjs +1 -1
- package/src/runtime/agent/orchestrator/runtime-core/workflow/context.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/agent-loop.mjs +28 -22
- package/src/runtime/agent/orchestrator/session/agent-pool-progress.mjs +30 -0
- package/src/runtime/agent/orchestrator/session/attachment-preflight.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/cache-warm.mjs +2 -2
- package/src/runtime/agent/orchestrator/session/catalog-db/index.mjs +2 -2
- package/src/runtime/agent/orchestrator/session/catalog-db/schema.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/compact/execution-tail.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/compact/runner.mjs +3 -0
- package/src/runtime/agent/orchestrator/session/compact/summary-route.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/context-utils.mjs +8 -12
- package/src/runtime/agent/orchestrator/session/conversation-import/claude.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/conversation-import/codex.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/conversation-import/convert.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/conversation-import/imported-session.mjs +7 -3
- package/src/runtime/agent/orchestrator/session/human-gate/held-message.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/human-gate/requests.mjs +1 -2
- package/src/runtime/agent/orchestrator/session/human-gate/run-policy.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/image-strip-recovery.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/loop/completion-guards.mjs +11 -1
- package/src/runtime/agent/orchestrator/session/loop/context-overflow.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/loop/loop-state.mjs +8 -1
- package/src/runtime/agent/orchestrator/session/loop/no-tool-turn/todo-check.mjs +196 -0
- package/src/runtime/agent/orchestrator/session/loop/no-tool-turn.mjs +116 -50
- package/src/runtime/agent/orchestrator/session/loop/pre-dispatch-deny.mjs +8 -1
- package/src/runtime/agent/orchestrator/session/loop/provider-tool-exclusions.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/loop/route-fallback.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/loop/steering.mjs +3 -1
- package/src/runtime/agent/orchestrator/session/loop/stored-tool-args.mjs +5 -6
- package/src/runtime/agent/orchestrator/session/loop/tool-exec/before-hook.mjs +6 -1
- package/src/runtime/agent/orchestrator/session/loop/tool-exec/dispatch.mjs +16 -2
- package/src/runtime/agent/orchestrator/session/loop/turn-report.mjs +35 -0
- package/src/runtime/agent/orchestrator/session/loop/usage.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/manager/ask-session.mjs +57 -26
- package/src/runtime/agent/orchestrator/session/manager/ask-turn-auto-effort.mjs +9 -7
- package/src/runtime/agent/orchestrator/session/manager/ask-turn-execute.mjs +21 -3
- package/src/runtime/agent/orchestrator/session/manager/ask-turn-failure.mjs +27 -11
- package/src/runtime/agent/orchestrator/session/manager/ask-turn-open.mjs +37 -34
- package/src/runtime/agent/orchestrator/session/manager/ask-turn-prepare.mjs +15 -0
- package/src/runtime/agent/orchestrator/session/manager/ask-turn-settle.mjs +25 -15
- package/src/runtime/agent/orchestrator/session/manager/ask-turn-state.mjs +79 -24
- package/src/runtime/agent/orchestrator/session/manager/ask-turn-steering-drain.mjs +3 -0
- package/src/runtime/agent/orchestrator/session/manager/compaction-runner.mjs +12 -1
- package/src/runtime/agent/orchestrator/session/manager/context-meta.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/manager/idle-cleanup.mjs +6 -1
- package/src/runtime/agent/orchestrator/session/manager/pending-messages.mjs +9 -1
- package/src/runtime/agent/orchestrator/session/manager/pending-spool-path.mjs +2 -2
- package/src/runtime/agent/orchestrator/session/manager/pending-spool-shard.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/manager/prompt-settings.mjs +598 -0
- package/src/runtime/agent/orchestrator/session/manager/prompt-utils.mjs +19 -0
- package/src/runtime/agent/orchestrator/session/manager/rules-cache.mjs +19 -10
- package/src/runtime/agent/orchestrator/session/manager/runtime-liveness.mjs +8 -1
- package/src/runtime/agent/orchestrator/session/manager/session-close.mjs +5 -0
- package/src/runtime/agent/orchestrator/session/manager/session-fallback-title.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/manager/session-lifecycle.mjs +31 -0
- package/src/runtime/agent/orchestrator/session/manager/session-lock.mjs +31 -0
- package/src/runtime/agent/orchestrator/session/manager/session-prompt-composition.mjs +42 -6
- package/src/runtime/agent/orchestrator/session/manager/session-record.mjs +2 -0
- package/src/runtime/agent/orchestrator/session/manager/tool-resolution.mjs +11 -1
- package/src/runtime/agent/orchestrator/session/manager/turn-checkpoint-context.mjs +8 -9
- package/src/runtime/agent/orchestrator/session/manager/turn-checkpoint-journal.mjs +339 -88
- package/src/runtime/agent/orchestrator/session/manager/turn-checkpoint-recovery.mjs +135 -11
- package/src/runtime/agent/orchestrator/session/manager/turn-checkpoint.mjs +377 -104
- package/src/runtime/agent/orchestrator/session/manager/turn-durability.mjs +144 -0
- package/src/runtime/agent/orchestrator/session/manager/turn-interruption.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/manager/usage-metrics.mjs +4 -0
- package/src/runtime/agent/orchestrator/session/manager.mjs +6 -0
- package/src/runtime/agent/orchestrator/session/mixy-name.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/pre-send-compact.mjs +8 -1
- package/src/runtime/agent/orchestrator/session/save-session-worker.mjs +5 -1
- package/src/runtime/agent/orchestrator/session/store/canonical-reader.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/store/liveness-veto.mjs +2 -2
- package/src/runtime/agent/orchestrator/session/store/save-worker.mjs +23 -2
- package/src/runtime/agent/orchestrator/session/store/sweep/sub-agent-retention.mjs +3 -3
- package/src/runtime/agent/orchestrator/session/store/transcript-durability.mjs +88 -0
- package/src/runtime/agent/orchestrator/session/store-agent-worker-rows.mjs +5 -0
- package/src/runtime/agent/orchestrator/session/store-summary-log.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/store-transcript-projection.mjs +14 -5
- package/src/runtime/agent/orchestrator/session/store-transcript-worker.mjs +2 -2
- package/src/runtime/agent/orchestrator/session/store.mjs +17 -6
- package/src/runtime/agent/orchestrator/session/synthetic-user-envelope.mjs +7 -1
- package/src/runtime/agent/orchestrator/session/tail-reminder-rules.mjs +9 -1
- package/src/runtime/agent/orchestrator/session/transcript-restore/agent-envelope.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/transcript-restore/restore.mjs +3 -1
- package/src/runtime/agent/orchestrator/session/transcript-restore/user-text.mjs +2 -2
- package/src/runtime/agent/orchestrator/stall-policy.mjs +3 -5
- package/src/runtime/agent/orchestrator/tools/builtin/bash-tool/backgrounded-result.mjs +4 -1
- package/src/runtime/agent/orchestrator/tools/builtin/bash-tool/misuse-guard.mjs +21 -3
- package/src/runtime/agent/orchestrator/tools/builtin/bash-tool/result-format.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/builtin/bash-tool/worktree-add-guard.mjs +77 -0
- package/src/runtime/agent/orchestrator/tools/builtin/bash-tool.mjs +0 -1
- package/src/runtime/agent/orchestrator/tools/builtin/git-command-tool.mjs +7 -3
- package/src/runtime/agent/orchestrator/tools/builtin/git-worktree-tool.mjs +27 -9
- package/src/runtime/agent/orchestrator/tools/builtin/lib/search-input-helpers.mjs +2 -2
- package/src/runtime/agent/orchestrator/tools/builtin/lib/shell-output-silence.mjs +64 -0
- package/src/runtime/agent/orchestrator/tools/builtin/lib/shell-task-output.mjs +20 -6
- package/src/runtime/agent/orchestrator/tools/builtin/read-range-index.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/builtin/read-single-fast-paths.mjs +0 -1
- package/src/runtime/agent/orchestrator/tools/builtin/search-tool.mjs +0 -10
- package/src/runtime/agent/orchestrator/tools/builtin/shell-jobs.mjs +1 -2
- package/src/runtime/agent/orchestrator/tools/builtin/task-tool.mjs +12 -1
- package/src/runtime/agent/orchestrator/tools/builtin.mjs +1 -24
- package/src/runtime/agent/orchestrator/tools/code-graph/graph-binary/child-kill.mjs +4 -3
- package/src/runtime/agent/orchestrator/tools/code-graph/graph-binary.mjs +1 -2
- package/src/runtime/agent/orchestrator/tools/code-graph/modes/calls.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/code-graph/modes/symbols.mjs +2 -2
- package/src/runtime/agent/orchestrator/tools/code-graph/search.mjs +4 -5
- package/src/runtime/agent/orchestrator/tools/code-graph/symbol-index.mjs +3 -4
- package/src/runtime/agent/orchestrator/tools/code-graph.mjs +4 -22
- package/src/runtime/agent/orchestrator/tools/lib/shell-descendants.mjs +2 -2
- package/src/runtime/agent/orchestrator/tools/lib/shell-run-state.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/shell-command.mjs +0 -4
- package/src/runtime/agent/orchestrator/tools/shell-policy.mjs +0 -1
- package/src/runtime/attachments/attachment-reference.mjs +1 -1
- package/src/runtime/attachments/pdf-extract.mjs +1 -1
- package/src/runtime/attachments/store.d.mts +1 -0
- package/src/runtime/attachments/store.mjs +2 -2
- package/src/runtime/channels/lib/config-reload-watch.mjs +42 -0
- package/src/runtime/channels/lib/owned-runtime/config-reload.mjs +29 -9
- package/src/runtime/channels/lib/routines-db.mjs +35 -0
- package/src/runtime/channels/lib/scheduler.mjs +33 -0
- package/src/runtime/channels/lib/schedules-db.mjs +15 -4
- package/src/runtime/channels/lib/webhook/session-dispatch.mjs +4 -1
- package/src/runtime/channels/lib/webhooks-db.mjs +13 -3
- package/src/runtime/channels/lib/whisper-server.mjs +12 -12
- package/src/runtime/channels/lib/worker-main.mjs +9 -31
- package/src/runtime/computer-bridge/action-schema.mjs +2 -2
- package/src/runtime/computer-bridge/core-actions.mjs +16 -2
- package/src/runtime/computer-bridge/linux-readiness.mjs +10 -14
- package/src/runtime/computer-bridge/result-canonical.mjs +6 -0
- package/src/runtime/connectors/connector-accounts-mcp.mjs +169 -33
- package/src/runtime/connectors/gmail-app-password.mjs +2 -2
- package/src/runtime/connectors/google-mcp.mjs +1 -1
- package/src/runtime/effort-judge/judge-client.mjs +2 -2
- package/src/runtime/effort-judge/judge-input.mjs +4 -4
- package/src/runtime/explore/explorer.mjs +0 -5
- package/src/runtime/explore/tool.mjs +3 -3
- package/src/runtime/local-provider/hardware.mjs +1 -1
- package/src/runtime/media/adapters/codex-image.mjs +3 -3
- package/src/runtime/media/adapters/gemini-video.mjs +1 -1
- package/src/runtime/media/media-usage.mjs +1 -1
- package/src/runtime/media/store.mjs +1 -1
- package/src/runtime/memory/index.mjs +11 -1
- package/src/runtime/memory/lib/embedding-reindex.mjs +27 -0
- package/src/runtime/memory/lib/memory-embed.mjs +83 -14
- package/src/runtime/memory/lib/memory-process-lock.mjs +159 -36
- package/src/runtime/memory/lib/memory-text-utils.mjs +6 -1
- package/src/runtime/memory/lib/memory.mjs +17 -0
- package/src/runtime/memory/lib/pg/process.mjs +1 -1
- package/src/runtime/memory/lib/pg/supervisor.mjs +16 -96
- package/src/runtime/memory/lib/recall-hybrid/hybrid-sql.mjs +12 -3
- package/src/runtime/memory/tool-defs.mjs +1 -1
- package/src/runtime/office/authoring/docx-html-runner.mjs +1 -1
- package/src/runtime/office/authoring/pptx-author-action.mjs +1 -1
- package/src/runtime/office/authoring/xlsx-html-build.mjs +1 -1
- package/src/runtime/office/authoring/xlsx-html-runner.mjs +1 -1
- package/src/runtime/office/capabilities.mjs +1 -1
- package/src/runtime/office/core/office-core.mjs +1 -1
- package/src/runtime/office/design/content-model.mjs +3 -3
- package/src/runtime/office/design/docx/design-docx/section.mjs +6 -6
- package/src/runtime/office/design/xlsx/design-xlsx-components.mjs +1 -1
- package/src/runtime/office/design/xlsx/design-xlsx.mjs +1 -1
- package/src/runtime/office/pdf/ocr-engine.mjs +1 -1
- package/src/runtime/office/pdf/pdf-writer.mjs +4 -4
- package/src/runtime/office/portable/portable-docx-operations.mjs +2 -2
- package/src/runtime/office/portable/portable-soffice.mjs +8 -6
- package/src/runtime/office/portable/xlsx-contract.mjs +1 -1
- package/src/runtime/shared/atomic-file.d.mts +8 -0
- package/src/runtime/shared/background-tasks.mjs +22 -4
- package/src/runtime/shared/background-wait.mjs +66 -0
- package/src/runtime/shared/child-guardian.mjs +17 -7
- package/src/runtime/shared/config.mjs +313 -16
- package/src/runtime/shared/connector-catalog.d.mts +4 -5
- package/src/runtime/shared/connector-catalog.mjs +11 -1
- package/src/runtime/shared/file-lock.mjs +8 -3
- package/src/runtime/shared/git-runner.mjs +7 -2
- package/src/runtime/shared/idle-gc.mjs +30 -7
- package/src/runtime/shared/llm/http-agent.mjs +8 -5
- package/src/runtime/shared/llm/system-proxy.mjs +2 -1
- package/src/runtime/shared/llm/usage-accounting.mjs +110 -19
- package/src/runtime/shared/llm/usage-context.mjs +1 -1
- package/src/runtime/shared/llm/usage-ledger-quota.mjs +33 -12
- package/src/runtime/shared/llm/usage-ledger-requests.mjs +183 -0
- package/src/runtime/shared/llm/usage-ledger-rollup.mjs +90 -10
- package/src/runtime/shared/llm/usage-ledger-worker.mjs +2 -0
- package/src/runtime/shared/llm/usage-ledger.mjs +60 -1
- package/src/runtime/shared/llm/usage-request-status.mjs +48 -0
- package/src/runtime/shared/llm/usage-rollup.mjs +48 -0
- package/src/runtime/shared/maintenance-schedule.mjs +109 -0
- package/src/runtime/shared/process-runner.mjs +8 -4
- package/src/runtime/shared/routine-trigger.d.mts +13 -0
- package/src/runtime/shared/routine-trigger.mjs +34 -0
- package/src/runtime/shared/run-child.d.mts +2 -1
- package/src/runtime/shared/run-child.mjs +70 -18
- package/src/runtime/shared/session-scratch.mjs +14 -2
- package/src/runtime/shared/shipped-definitions.mjs +7 -1
- package/src/runtime/shared/tool-card-model.golden.json +3 -12
- package/src/runtime/shared/tool-execution-contract.mjs +2 -0
- package/src/runtime/shared/tool-result-summary.mjs +1 -1
- package/src/runtime/shared/tool-work-units.mjs +31 -6
- package/src/runtime/shared/turn-snapshot.mjs +26 -4
- package/src/runtime/shared/turn-worktree-snapshot.mjs +6 -11
- package/src/runtime/shared/worker-requests.mjs +17 -3
- package/src/runtime/shared/worktrees/branch-management.mjs +1 -5
- package/src/runtime/shared/worktrees/contract.mjs +16 -6
- package/src/runtime/shared/worktrees/dependencies.mjs +127 -89
- package/src/runtime/shared/worktrees/disk.mjs +79 -2
- package/src/runtime/shared/worktrees/git.mjs +44 -11
- package/src/runtime/shared/worktrees/include.mjs +6 -4
- package/src/runtime/shared/worktrees/maintenance.mjs +422 -30
- package/src/runtime/shared/worktrees/manager.mjs +772 -75
- package/src/runtime/shared/worktrees/settings.mjs +33 -7
- package/src/runtime/shared/worktrees/test-support.mjs +5 -1
- package/src/runtime/shared/worktrees/worker-snapshots.mjs +82 -0
- package/src/runtime/tidy/process.mjs +2 -1
- package/src/runtime/web-search/index.mjs +3 -22
- package/src/runtime/web-search/lib/web-tools.mjs +2 -2
- package/src/runtime/web-search/tool-defs.mjs +17 -26
- package/src/session-runtime/agent-home-delivery.mjs +76 -8
- package/src/session-runtime/agent-profile-changes.mjs +55 -4
- package/src/session-runtime/agent-task-sessions.mjs +63 -22
- package/src/session-runtime/boot/apis.mjs +42 -4
- package/src/session-runtime/boot/begin.mjs +2 -0
- package/src/session-runtime/boot/config.mjs +10 -1
- package/src/session-runtime/boot/facade.mjs +1 -0
- package/src/session-runtime/boot/providers.mjs +70 -3
- package/src/session-runtime/boot/session.mjs +2 -0
- package/src/session-runtime/boot/tools.mjs +75 -25
- package/src/session-runtime/channel-config-api.mjs +1 -0
- package/src/session-runtime/config-change-effects.mjs +179 -0
- package/src/session-runtime/config-lifecycle/config-writers.mjs +1 -0
- package/src/session-runtime/config-lifecycle.mjs +160 -24
- package/src/session-runtime/conversation-import/discovery.mjs +86 -7
- package/src/session-runtime/conversation-import/service.mjs +3 -2
- package/src/session-runtime/goal-facade-api.mjs +49 -3
- package/src/session-runtime/internal-tool-executor/ask-user-tool.mjs +5 -57
- package/src/session-runtime/internal-tool-executor/bridge-tools.mjs +3 -2
- package/src/session-runtime/internal-tool-executor/feature-tools.mjs +3 -11
- package/src/session-runtime/internal-tool-executor/workspace-tools.mjs +18 -4
- package/src/session-runtime/internal-tool-executor.mjs +12 -19
- package/src/session-runtime/lifecycle/cold-heir.mjs +7 -0
- package/src/session-runtime/lifecycle/memory-ingest.mjs +3 -3
- package/src/session-runtime/lifecycle/session-switch/session-delete.mjs +53 -5
- package/src/session-runtime/lifecycle/session-switch.mjs +13 -2
- package/src/session-runtime/lifecycle/teardown/session-close.mjs +4 -4
- package/src/session-runtime/lifecycle-api.mjs +1 -0
- package/src/session-runtime/mcp-glue/server-catalog.mjs +14 -3
- package/src/session-runtime/mcp-glue/server-connection.mjs +34 -8
- package/src/session-runtime/model-route/route-persist.mjs +12 -4
- package/src/session-runtime/model-route/set-route.mjs +40 -7
- package/src/session-runtime/native-web-search/routes.mjs +3 -3
- package/src/session-runtime/provider-auth/refresh.mjs +6 -3
- package/src/session-runtime/provider-auth/setup.mjs +1 -1
- package/src/session-runtime/provider-models/row-hydration.mjs +2 -0
- package/src/session-runtime/provider-readiness.mjs +53 -4
- package/src/session-runtime/resource-api.mjs +1 -1
- package/src/session-runtime/resource-extension-sync.mjs +4 -8
- package/src/session-runtime/resource-mcp-connector-accounts.mjs +5 -1
- package/src/session-runtime/resource-mcp-secrets.mjs +3 -3
- package/src/session-runtime/resource-plugins-api.mjs +4 -0
- package/src/session-runtime/routine-executor.mjs +152 -0
- package/src/session-runtime/routine-home-turn.mjs +46 -5
- package/src/session-runtime/routine-owner.mjs +9 -3
- package/src/session-runtime/runtime-facade.mjs +5 -0
- package/src/session-runtime/runtime-feature-gates.mjs +2 -11
- package/src/session-runtime/schedule-session-run.mjs +1 -0
- package/src/session-runtime/services/agent-task-status.mjs +29 -1
- package/src/session-runtime/services/agent-tool/job-task-reconcile.mjs +6 -1
- package/src/session-runtime/services/agent-tool/job-views/session-progress.mjs +10 -0
- package/src/session-runtime/services/agent-tool/render.mjs +6 -1
- package/src/session-runtime/services/agent-tool/send-flow.mjs +110 -6
- package/src/session-runtime/services/agent-tool/spawn-flow/job-start.mjs +12 -0
- package/src/session-runtime/services/agent-tool/spawn-flow/spawn-plan.mjs +5 -0
- package/src/session-runtime/services/agent-tool/spawn-flow/spawn-run.mjs +24 -6
- package/src/session-runtime/services/agent-tool.mjs +51 -1
- package/src/session-runtime/services/channel-admin.mjs +62 -3
- package/src/session-runtime/services/hook-bus/command-handler.mjs +7 -11
- package/src/session-runtime/services/plugin-admin.mjs +50 -7
- package/src/session-runtime/services/provider-admin.mjs +5 -0
- package/src/session-runtime/services/seeds.mjs +7 -0
- package/src/session-runtime/services/usage-stats-model.mjs +32 -11
- package/src/session-runtime/session-create/materialize.mjs +4 -2
- package/src/session-runtime/session-create/session-options.mjs +2 -0
- package/src/session-runtime/settings-builtin-tools-api.mjs +1 -9
- package/src/session-runtime/setup-tool/agent-settings-actions.mjs +1 -1
- package/src/session-runtime/setup-tool/connector-widen-approval.mjs +1 -1
- package/src/session-runtime/setup-tool/executor.mjs +9 -2
- package/src/session-runtime/setup-tool/extended-actions.mjs +3 -1
- package/src/session-runtime/setup-tool/settings-contract.mjs +30 -2
- package/src/session-runtime/setup-tool/tool-defs.mjs +26 -1
- package/src/session-runtime/tool-policy/agent-profile-fold.mjs +40 -43
- package/src/session-runtime/tool-policy/mode-switch.mjs +1 -1
- package/src/session-runtime/tool-policy/policy-stage.mjs +106 -8
- package/src/session-runtime/tool-policy/workflow-overlay.mjs +2 -1
- package/src/session-runtime/tool-policy-refresh.mjs +182 -5
- package/src/session-runtime/tool-surface.mjs +38 -1
- package/src/session-runtime/turn/agent-ops.mjs +10 -2
- package/src/session-runtime/turn/session-ops.mjs +2 -0
- package/src/session-runtime/turn/turn-run/turn-prepare.mjs +5 -0
- package/src/session-runtime/turn/turn-run.mjs +1 -1
- package/src/session-runtime/usage-stats-api.mjs +117 -1
- package/src/session-runtime/webhook-session-run.mjs +2 -0
- package/src/session-runtime/workflow-agents-api/agent-connectors.mjs +37 -33
- package/src/session-runtime/workflow-agents-api/agent-editor.mjs +183 -23
- package/src/session-runtime/workflow-agents-api/agent-route.mjs +3 -10
- package/src/session-runtime/workflow-agents-api/instruction-files.mjs +165 -0
- package/src/session-runtime/workflow-agents-api/style-and-mode.mjs +5 -4
- package/src/session-runtime/workflow-agents-api/workflow-packs.mjs +2 -3
- package/src/session-runtime/workflow-agents-api.mjs +2 -0
- package/src/session-runtime/workspace/project-branches.mjs +1 -1
- package/src/session-runtime/workspace/session-view.mjs +1 -1
- package/src/session-runtime/workspace/transitions.mjs +20 -4
- package/src/session-runtime/workspace/worktree-maintenance.mjs +126 -6
- package/src/session-runtime/workspace/worktree-setup.mjs +13 -1
- package/src/session-runtime/workspace/worktree-tool.mjs +16 -0
- package/src/standalone/daemon-agent-control.mjs +25 -8
- package/src/standalone/daemon-desktop-runtime.mjs +6 -2
- package/src/standalone/daemon-lag-profiler.mjs +7 -7
- package/src/standalone/daemon.mjs +54 -2
- package/src/standalone/local-session-runtime.mjs +16 -0
- package/src/standalone/session-client/daemon-unavailable.mjs +1 -1
- package/src/standalone/session-protocol.mjs +12 -0
- package/src/standalone/session-service/agent-route-follow.mjs +23 -20
- package/src/standalone/session-service/agent-tree/agent-turns.mjs +18 -6
- package/src/standalone/session-service/quota-resume.mjs +9 -0
- package/src/standalone/session-service/retention/busy.mjs +3 -2
- package/src/standalone/session-service/session-calls/session-action.mjs +51 -1
- package/src/standalone/session-service/session-calls/session-turns.mjs +37 -18
- package/src/standalone/session-service/session-calls/turn-gate.mjs +34 -0
- package/src/standalone/session-service/session-calls.mjs +2 -1
- package/src/tui/App.jsx +8 -0
- package/src/tui/app/clipboard.mjs +1 -1
- package/src/tui/app/create-app-pickers.mjs +2 -0
- package/src/tui/app/doctor.mjs +2 -2
- package/src/tui/app/model-picker/model-footer.mjs +1 -1
- package/src/tui/app/model-picker/provider-models-list.mjs +7 -3
- package/src/tui/app/model-picker/route-selection/fast-parameters.mjs +23 -3
- package/src/tui/app/model-picker/route-selection.mjs +1 -0
- package/src/tui/app/panel-signature.mjs +1 -1
- package/src/tui/app/settings-picker.mjs +53 -8
- package/src/tui/app/shell-layout/row-budgets.mjs +2 -2
- package/src/tui/app/slash-commands.mjs +1 -1
- package/src/tui/app/slash-dispatch/route-commands.mjs +1 -1
- package/src/tui/app/slash-dispatch/session-commands.mjs +1 -1
- package/src/tui/app/use-prompt-queue-history.mjs +2 -2
- package/src/tui/app/use-transcript-activity.mjs +1 -1
- package/src/tui/app/use-transcript-window/geometry.mjs +1 -1
- package/src/tui/components/prompt-input/escape-policy.d.mts +0 -1
- package/src/tui/components/prompt-input/escape-policy.mjs +1 -1
- package/src/tui/components/question-panel-model.mjs +4 -4
- package/src/tui/components/tool-execution/standard-card.jsx +3 -4
- package/src/tui/components/user-message-skills.mjs +1 -1
- package/src/tui/dist/index.mjs +350 -37
- package/src/tui/markdown/render-ansi.mjs +1 -1
- package/src/tui/session/agent-job-feed/notification-router.mjs +10 -0
- package/src/tui/session/agent-job-feed.mjs +2 -0
- package/src/tui/session/context-state.mjs +3 -0
- package/src/tui/session/quota-resume.mjs +1 -1
- package/src/tui/session/session-api/integrations.mjs +3 -0
- package/src/tui/session/session-api/lifecycle/dispose.mjs +1 -0
- package/src/tui/session/session-api/lifecycle/session-reset.mjs +7 -0
- package/src/tui/session/session-api/routes-agent-definitions.mjs +5 -0
- package/src/tui/session/session-api/worktree.mjs +13 -1
- package/src/tui/session/session-flow/drain.mjs +11 -14
- package/src/tui/session/tool-approval-settle.mjs +24 -4
- package/src/tui/session/tool-approval.mjs +35 -10
- package/src/tui/session/tool-card-results/grouped-result.mjs +2 -2
- package/src/tui/session/turn-quiet.mjs +1 -1
- package/src/tui/session/turn.mjs +3 -0
- package/src/tui/session/worktree-setup-notice.mjs +1 -1
- package/src/tui/spinner-meta.mjs +3 -3
- package/src/tui/spinner-verbs.mjs +2 -2
- package/src/defaults/skills/goal-management/SKILL.md +0 -169
- package/src/runtime/agent/orchestrator/runtime-core/goal-tasks.mjs +0 -156
- package/src/session-runtime/goal-tasks.mjs +0 -1
|
@@ -11,9 +11,17 @@ export const WORKTREE_NEW_TASK_DEFAULTS = Object.freeze(['branch', 'worktree']);
|
|
|
11
11
|
/**
|
|
12
12
|
* @typedef {object} WorktreeSettings
|
|
13
13
|
* @property {'branch'|'worktree'} newTaskDefault
|
|
14
|
-
* @property {string} branchPrefix Ref prefix for created branches
|
|
14
|
+
* @property {string} branchPrefix Ref prefix for created branches, ending with "/";
|
|
15
|
+
* "" (default) names the branch after the task alone.
|
|
15
16
|
* @property {number} sizeWarnBytes Repository size that asks for confirmation; 0 never asks.
|
|
16
17
|
* @property {boolean} autoCleanup Remove clean, merged worktrees when their session ends.
|
|
18
|
+
* The four settings below apply only while it is on.
|
|
19
|
+
* @property {number} maxWorktrees Keep at most this many managed worktrees (oldest
|
|
20
|
+
* activity cleaned first); 0 keeps any number.
|
|
21
|
+
* @property {number} unusedDays Clean up worktrees unused this many days; 0 never.
|
|
22
|
+
* @property {boolean} cleanupArchived Archiving a session makes its worktrees disposable.
|
|
23
|
+
* @property {boolean} deleteBranch Cleanup deletes the worktree's branch too (its tip
|
|
24
|
+
* stays under the recovery ref); off keeps the branch.
|
|
17
25
|
*/
|
|
18
26
|
|
|
19
27
|
/** @type {Readonly<WorktreeSettings>} */
|
|
@@ -22,8 +30,15 @@ export const WORKTREE_SETTINGS_DEFAULTS = Object.freeze({
|
|
|
22
30
|
branchPrefix: DEFAULT_WORKTREE_BRANCH_PREFIX,
|
|
23
31
|
sizeWarnBytes: 2 * 1024 ** 3,
|
|
24
32
|
autoCleanup: true,
|
|
33
|
+
maxWorktrees: 15,
|
|
34
|
+
unusedDays: 30,
|
|
35
|
+
cleanupArchived: true,
|
|
36
|
+
deleteBranch: false,
|
|
25
37
|
});
|
|
26
38
|
|
|
39
|
+
const WORKTREE_MAX_WORKTREES_LIMIT = 1000;
|
|
40
|
+
const WORKTREE_UNUSED_DAYS_LIMIT = 3650;
|
|
41
|
+
|
|
27
42
|
const KEYS = Object.keys(WORKTREE_SETTINGS_DEFAULTS);
|
|
28
43
|
const PREFIX_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]*(\/[A-Za-z0-9][A-Za-z0-9._-]*)*\/$/;
|
|
29
44
|
|
|
@@ -35,16 +50,27 @@ function fieldError(key, value) {
|
|
|
35
50
|
? null
|
|
36
51
|
: `must be one of ${WORKTREE_NEW_TASK_DEFAULTS.join(', ')}`;
|
|
37
52
|
case 'branchPrefix':
|
|
38
|
-
return
|
|
39
|
-
value
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
53
|
+
return value === '' ||
|
|
54
|
+
(typeof value === 'string' &&
|
|
55
|
+
value.length <= 64 &&
|
|
56
|
+
PREFIX_PATTERN.test(value) &&
|
|
57
|
+
!value.includes('..') &&
|
|
58
|
+
!/\.lock\//i.test(value))
|
|
43
59
|
? null
|
|
44
|
-
: 'must be a ref path ending with "/", e.g. "mixdog/"';
|
|
60
|
+
: 'must be empty or a ref path ending with "/", e.g. "mixdog/"';
|
|
45
61
|
case 'sizeWarnBytes':
|
|
46
62
|
return Number.isSafeInteger(value) && value >= 0 ? null : 'must be a non-negative integer';
|
|
63
|
+
case 'maxWorktrees':
|
|
64
|
+
return Number.isSafeInteger(value) && value >= 0 && value <= WORKTREE_MAX_WORKTREES_LIMIT
|
|
65
|
+
? null
|
|
66
|
+
: `must be an integer from 0 to ${WORKTREE_MAX_WORKTREES_LIMIT}`;
|
|
67
|
+
case 'unusedDays':
|
|
68
|
+
return Number.isSafeInteger(value) && value >= 0 && value <= WORKTREE_UNUSED_DAYS_LIMIT
|
|
69
|
+
? null
|
|
70
|
+
: `must be an integer from 0 to ${WORKTREE_UNUSED_DAYS_LIMIT}`;
|
|
47
71
|
case 'autoCleanup':
|
|
72
|
+
case 'cleanupArchived':
|
|
73
|
+
case 'deleteBranch':
|
|
48
74
|
return typeof value === 'boolean' ? null : 'must be a boolean';
|
|
49
75
|
default:
|
|
50
76
|
return 'is not a worktree setting';
|
|
@@ -106,7 +106,11 @@ export async function createTestWorktree(projectPath, extra = {}) {
|
|
|
106
106
|
return { entry, ...id, ...extra };
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
/** The
|
|
109
|
+
/** The branch prefix the suites configure (the default is none), so their
|
|
110
|
+
* managed branches are told apart from the repository's own. */
|
|
111
|
+
export const TEST_BRANCH_PREFIX = 'mixdog/';
|
|
112
|
+
|
|
113
|
+
/** The repository's branches under TEST_BRANCH_PREFIX. */
|
|
110
114
|
export function prefixedBranches(repo) {
|
|
111
115
|
return git(repo, 'for-each-ref', '--format=%(refname:short)', 'refs/heads/mixdog/').split('\n').filter(Boolean);
|
|
112
116
|
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// Read-only snapshot worktrees of delegated workers (`git worktree add
|
|
2
|
+
// --detach` through the git tool): the worker's session holds each one, and
|
|
3
|
+
// it is removed when that worker's turn settles (the session runtime's
|
|
4
|
+
// unload), like the Lead's turn snapshots. What a removal leaves (something
|
|
5
|
+
// still runs there, the process ends first) is the prune's and the startup
|
|
6
|
+
// reconcile's: a snapshot never outlives its holder.
|
|
7
|
+
//
|
|
8
|
+
// Dependency-free at load (the manager loads on first use) and shared through
|
|
9
|
+
// a global symbol, so every bundle copy of this module sees one ledger.
|
|
10
|
+
import { randomUUID } from 'node:crypto';
|
|
11
|
+
import { setTimeout as delay } from 'node:timers/promises';
|
|
12
|
+
|
|
13
|
+
const STATE_KEY = Symbol.for('mixdog.workerSnapshots.v1');
|
|
14
|
+
const RETRY_MS = 2_000;
|
|
15
|
+
const RETRY_LIMIT = 5;
|
|
16
|
+
|
|
17
|
+
const loadManager = () => import('./manager.mjs');
|
|
18
|
+
|
|
19
|
+
function state() {
|
|
20
|
+
globalThis[STATE_KEY] ??= { runtimeToken: `worker-snapshots-${randomUUID()}`, turns: new Map() };
|
|
21
|
+
return globalThis[STATE_KEY];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* A snapshot of `commit` in the repository at `projectPath`, held by worker
|
|
26
|
+
* session `sessionId` until its turn settles (releaseWorkerSnapshots).
|
|
27
|
+
* @param {{ sessionId: string, projectPath: string, commit: string, txId?: string, confirmLarge?: boolean, manager?: object }} input
|
|
28
|
+
*/
|
|
29
|
+
export async function createWorkerSnapshot({
|
|
30
|
+
sessionId,
|
|
31
|
+
projectPath,
|
|
32
|
+
commit,
|
|
33
|
+
txId = '',
|
|
34
|
+
confirmLarge = false,
|
|
35
|
+
manager = null,
|
|
36
|
+
}) {
|
|
37
|
+
const id = String(sessionId || '').trim();
|
|
38
|
+
if (!id) throw new Error('A worker snapshot needs the worker session.');
|
|
39
|
+
const tx = String(txId || '').trim() || `worker-snapshot-${randomUUID()}`;
|
|
40
|
+
const backend = manager || (await loadManager());
|
|
41
|
+
const entry = await backend.createSnapshotWorktree({
|
|
42
|
+
projectPath,
|
|
43
|
+
sessionId: id,
|
|
44
|
+
runtimeToken: state().runtimeToken,
|
|
45
|
+
commit,
|
|
46
|
+
txId: tx,
|
|
47
|
+
confirmLarge: confirmLarge === true,
|
|
48
|
+
});
|
|
49
|
+
const { turns } = state();
|
|
50
|
+
if (!turns.has(id)) turns.set(id, new Set());
|
|
51
|
+
turns.get(id).add(tx);
|
|
52
|
+
return entry;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The worker's turn settled: remove the snapshots it made. One a worker or
|
|
57
|
+
* background shell still runs in is retried with a doubling delay a few
|
|
58
|
+
* times; the rest stays for the prune / startup reconcile.
|
|
59
|
+
* @returns {Promise<{ removed: string[], kept: object[] }>}
|
|
60
|
+
*/
|
|
61
|
+
export async function releaseWorkerSnapshots(
|
|
62
|
+
sessionId,
|
|
63
|
+
{ manager = null, retryMs = RETRY_MS, retryLimit = RETRY_LIMIT } = {}
|
|
64
|
+
) {
|
|
65
|
+
const id = String(sessionId || '');
|
|
66
|
+
const { turns } = state();
|
|
67
|
+
const made = turns.get(id);
|
|
68
|
+
const report = { removed: [], kept: [] };
|
|
69
|
+
if (!made?.size) return report;
|
|
70
|
+
turns.delete(id);
|
|
71
|
+
const backend = manager || (await loadManager());
|
|
72
|
+
let pending = [...made];
|
|
73
|
+
for (let attempt = 0; pending.length && attempt < retryLimit; attempt++) {
|
|
74
|
+
if (attempt > 0) await delay(retryMs * 2 ** (attempt - 1), undefined, { ref: false });
|
|
75
|
+
const result = await backend.removeSessionSnapshots(id, { txIds: pending });
|
|
76
|
+
report.removed.push(...result.removed);
|
|
77
|
+
const inUse = result.kept.filter((row) => row.reason === 'in-use');
|
|
78
|
+
report.kept = result.kept;
|
|
79
|
+
pending = inUse.map((row) => row.txId);
|
|
80
|
+
}
|
|
81
|
+
return report;
|
|
82
|
+
}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
// parser.
|
|
6
6
|
import { spawn } from 'node:child_process';
|
|
7
7
|
import { existsSync, readdirSync, statSync } from 'node:fs';
|
|
8
|
+
import { spawnTreeKill } from '../agent/orchestrator/mcp/child-tree.mjs';
|
|
8
9
|
import { delimiter, extname, isAbsolute, join } from 'node:path';
|
|
9
10
|
|
|
10
11
|
const DEFAULT_PROCESS_TIMEOUT_MS = 90_000;
|
|
@@ -166,7 +167,7 @@ export function runProcess(
|
|
|
166
167
|
if (child.exitCode != null || child.signalCode != null) return;
|
|
167
168
|
try {
|
|
168
169
|
if (process.platform === 'win32' && child.pid) {
|
|
169
|
-
|
|
170
|
+
spawnTreeKill([child.pid], { root: child });
|
|
170
171
|
} else {
|
|
171
172
|
child.kill('SIGKILL');
|
|
172
173
|
}
|
|
@@ -28,7 +28,6 @@ const webSearchArgsSchema = z.object({
|
|
|
28
28
|
.union([z.string().min(1), z.array(z.string().min(1)).min(1)])
|
|
29
29
|
.describe('Search query string or array of queries.'),
|
|
30
30
|
site: z.string().optional().describe('Restrict results to a specific domain.'),
|
|
31
|
-
type: z.enum(['web', 'news', 'images']).optional().describe('Search type. Default: web.'),
|
|
32
31
|
maxResults: z.number().int().min(1).max(20).optional().describe('Maximum number of results to return (1-20).'),
|
|
33
32
|
locale: z
|
|
34
33
|
.union([
|
|
@@ -65,7 +64,7 @@ const urlArgsSchema = z.object({
|
|
|
65
64
|
cwd: z.string().optional(),
|
|
66
65
|
});
|
|
67
66
|
|
|
68
|
-
const WEB_SEARCH_EMPTY_STRING_FIELDS = ['keywords', 'site', '
|
|
67
|
+
const WEB_SEARCH_EMPTY_STRING_FIELDS = ['keywords', 'site', 'locale', 'contextSize'];
|
|
69
68
|
|
|
70
69
|
function normalizeWebSearchArgs(rawArgs) {
|
|
71
70
|
if (!rawArgs || typeof rawArgs !== 'object' || Array.isArray(rawArgs)) return rawArgs;
|
|
@@ -153,17 +152,7 @@ function dropInvalidWebSearchResults(payload) {
|
|
|
153
152
|
};
|
|
154
153
|
}
|
|
155
154
|
|
|
156
|
-
|
|
157
|
-
switch (type) {
|
|
158
|
-
case 'news':
|
|
159
|
-
return 20 * 60 * 1000;
|
|
160
|
-
case 'images':
|
|
161
|
-
return 60 * 60 * 1000;
|
|
162
|
-
// 'web' and any unknown type.
|
|
163
|
-
default:
|
|
164
|
-
return 30 * 60 * 1000;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
155
|
+
const WEB_SEARCH_CACHE_TTL_MS = 30 * 60 * 1000;
|
|
167
156
|
|
|
168
157
|
const SCRAPE_CACHE_TTL_MS = 60 * 60 * 1000;
|
|
169
158
|
|
|
@@ -207,7 +196,6 @@ function webSearchArgsForCacheKey(args) {
|
|
|
207
196
|
return {
|
|
208
197
|
keywords,
|
|
209
198
|
site: args.site || null,
|
|
210
|
-
type: args.type || 'web',
|
|
211
199
|
locale: args.locale || null,
|
|
212
200
|
contextSize: args.contextSize || 'low',
|
|
213
201
|
maxResults: clampMaxResults(args.maxResults),
|
|
@@ -222,7 +210,6 @@ function buildAgentWebSearchPrompt(args) {
|
|
|
222
210
|
'',
|
|
223
211
|
`Query: ${query}`,
|
|
224
212
|
args.site ? `Site/domain restriction: ${args.site}` : null,
|
|
225
|
-
args.type ? `Search type: ${args.type}` : null,
|
|
226
213
|
args.locale ? `Locale: ${localeLabel}` : null,
|
|
227
214
|
`Max results: ${clampMaxResults(args.maxResults)}`,
|
|
228
215
|
'',
|
|
@@ -326,7 +313,6 @@ function normalizeNativeWebSearchPayload(result, args, startedAt) {
|
|
|
326
313
|
usage: result?.usage || null,
|
|
327
314
|
results,
|
|
328
315
|
warnings,
|
|
329
|
-
type: cacheArgs.type,
|
|
330
316
|
site: cacheArgs.site,
|
|
331
317
|
locale: cacheArgs.locale,
|
|
332
318
|
},
|
|
@@ -360,12 +346,7 @@ async function _webSearchCore(args, { cacheState, nativeWebSearch, signal }) {
|
|
|
360
346
|
signal: controller.signal,
|
|
361
347
|
});
|
|
362
348
|
const payload = normalizeNativeWebSearchPayload(result, { ...args, ...cacheArgs }, startedAt);
|
|
363
|
-
const cachedEntry = setCachedEntry(
|
|
364
|
-
cacheState,
|
|
365
|
-
webSearchCacheKey,
|
|
366
|
-
payload,
|
|
367
|
-
getWebSearchCacheTtlMs(cacheArgs.type)
|
|
368
|
-
);
|
|
349
|
+
const cachedEntry = setCachedEntry(cacheState, webSearchCacheKey, payload, WEB_SEARCH_CACHE_TTL_MS);
|
|
369
350
|
flushCacheState();
|
|
370
351
|
return { ...payload, cache: buildCacheMeta(cachedEntry, false) };
|
|
371
352
|
}
|
|
@@ -67,8 +67,8 @@ function _notifyPoolWaiter() {
|
|
|
67
67
|
|
|
68
68
|
async function _acquirePoolSlot(signal) {
|
|
69
69
|
const abortError = () => signal?.reason || new Error('aborted');
|
|
70
|
-
// Waiting for a pool slot
|
|
71
|
-
// queueing until a slot
|
|
70
|
+
// Waiting for a pool slot is cancellable: otherwise an aborted tool call keeps
|
|
71
|
+
// queueing until a slot frees, then launches a page nobody was waiting for.
|
|
72
72
|
while (_poolActive >= PUPPETEER_POOL_MAX_PAGES) {
|
|
73
73
|
if (signal?.aborted) throw abortError();
|
|
74
74
|
await new Promise((resolve, reject) => {
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// Model-facing text is kept minimal: every constraint dropped from these schemas
|
|
2
|
+
// (minLength, pattern, minItems, maxItems, format) is enforced by the zod
|
|
3
|
+
// schemas in index.mjs, which trim blanks and reject empty or non-URL input.
|
|
4
|
+
// `trigger` shows only in the deferred listing, so `description` carries the
|
|
5
|
+
// when-to-use guidance itself.
|
|
3
6
|
const TOOL_DEFS_PLACEHOLDER = Symbol('web-fetch-schema');
|
|
4
7
|
|
|
5
8
|
export const TOOL_DEFS = [
|
|
@@ -7,21 +10,18 @@ export const TOOL_DEFS = [
|
|
|
7
10
|
name: 'web_search',
|
|
8
11
|
title: 'Mixdog Web Search',
|
|
9
12
|
trigger: 'Unfamiliar names, products, models, recent or external facts; search before answering from memory.',
|
|
10
|
-
description:
|
|
13
|
+
description:
|
|
14
|
+
'Search the web for recent, external or unfamiliar facts (names, products, models) before answering from memory.',
|
|
11
15
|
inputSchema: {
|
|
12
16
|
type: 'object',
|
|
13
17
|
properties: {
|
|
14
18
|
query: {
|
|
15
|
-
anyOf: [
|
|
16
|
-
|
|
17
|
-
{ type: 'array', minItems: 1, items: { type: 'string', minLength: 1, pattern: '\\S' } },
|
|
18
|
-
],
|
|
19
|
-
description: 'Non-empty query or array for lossless fan-out.',
|
|
19
|
+
anyOf: [{ type: 'string' }, { type: 'array', items: { type: 'string' } }],
|
|
20
|
+
description: 'One query, or an array run as a batch.',
|
|
20
21
|
},
|
|
21
|
-
site: { type: 'string', description: '
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
locale: { type: 'string', description: 'Optional locale hint, e.g. ko-KR or a city/region name.' },
|
|
22
|
+
site: { type: 'string', description: 'Domain filter.' },
|
|
23
|
+
maxResults: { type: 'integer', minimum: 1, maximum: 20, description: 'Default 10.' },
|
|
24
|
+
locale: { type: 'string', description: 'e.g. ko-KR.' },
|
|
25
25
|
contextSize: { type: 'string', enum: ['low', 'medium', 'high'], description: 'Default low.' },
|
|
26
26
|
},
|
|
27
27
|
required: ['query'],
|
|
@@ -39,25 +39,16 @@ export const TOOL_DEFS = [
|
|
|
39
39
|
name: 'web_fetch',
|
|
40
40
|
title: 'Mixdog Web Fetch',
|
|
41
41
|
trigger: 'Page or docs body from a known URL; not discovery (web_search).',
|
|
42
|
-
description: 'Fetch page
|
|
42
|
+
description: 'Fetch the page or docs body of known URLs; to find pages, use web_search.',
|
|
43
43
|
inputSchema: {
|
|
44
44
|
type: 'object',
|
|
45
45
|
properties: {
|
|
46
46
|
url: {
|
|
47
|
-
anyOf: [
|
|
48
|
-
|
|
49
|
-
{ type: 'array', items: { type: 'string', format: 'uri' }, minItems: 1, maxItems: 10 },
|
|
50
|
-
],
|
|
51
|
-
description:
|
|
52
|
-
'Public or loopback HTTP(S) URL, or an array of up to 10; keep loopback and public URLs in separate calls.',
|
|
53
|
-
},
|
|
54
|
-
startIndex: { type: 'integer', minimum: 0, description: 'Character offset; default 0.' },
|
|
55
|
-
maxLength: {
|
|
56
|
-
type: 'integer',
|
|
57
|
-
minimum: 0,
|
|
58
|
-
description:
|
|
59
|
-
'Maximum characters; default 20000; 0 unlimited. A cut page ends with [output capped …; startIndex:N for more].',
|
|
47
|
+
anyOf: [{ type: 'string' }, { type: 'array', items: { type: 'string' } }],
|
|
48
|
+
description: 'URL, or an array of up to 10; loopback and public URLs in separate calls.',
|
|
60
49
|
},
|
|
50
|
+
startIndex: { type: 'integer', minimum: 0, description: 'Character offset.' },
|
|
51
|
+
maxLength: { type: 'integer', minimum: 0, description: 'Default 20000; 0 unlimited.' },
|
|
61
52
|
},
|
|
62
53
|
required: ['url'],
|
|
63
54
|
additionalProperties: false,
|
|
@@ -63,6 +63,7 @@ import { readJsonState, updateJsonAtomic } from '../runtime/shared/atomic-file.m
|
|
|
63
63
|
import { endHandoff, noteHandoff } from '../runtime/shared/delegated-approval-host.mjs';
|
|
64
64
|
import { ROUTINE_LIMITS } from '../runtime/shared/routine-limits.mjs';
|
|
65
65
|
import { submissionIdsOf, submissionOutcome } from './agent-task-sessions.mjs';
|
|
66
|
+
import { HANDOFF_LIMITS } from './handoff-attachments.mjs';
|
|
66
67
|
import {
|
|
67
68
|
heldRequestMessage,
|
|
68
69
|
heldRequestNotice,
|
|
@@ -298,16 +299,70 @@ function withDequeued(doc, homeId, runIds, omitted) {
|
|
|
298
299
|
function withoutRepeatedProgress(doc, homeId, item, posted) {
|
|
299
300
|
const { progressRunId, ...report } = item;
|
|
300
301
|
if (!progressRunId) return { doc, item };
|
|
301
|
-
|
|
302
|
+
const key = answerKey(progressRunId);
|
|
303
|
+
if (posted || (doc.delivered[homeId] || []).some((runId) => answerKey(runId) === key)) {
|
|
302
304
|
const { text: _text, textChars: _textChars, ...rest } = report;
|
|
303
305
|
return { doc, item: { ...rest, text: '', answerAbove: true } };
|
|
304
306
|
}
|
|
305
307
|
const queued = doc.homes[homeId] || [];
|
|
306
|
-
if (!queued.some((row) => row.runId ===
|
|
307
|
-
const homes = { ...doc.homes, [homeId]: queued.filter((row) => row.runId !==
|
|
308
|
+
if (!queued.some((row) => answerKey(row.runId) === key)) return { doc, item: report };
|
|
309
|
+
const homes = { ...doc.homes, [homeId]: queued.filter((row) => answerKey(row.runId) !== key) };
|
|
308
310
|
return { doc: { ...doc, homes }, item: report };
|
|
309
311
|
}
|
|
310
312
|
|
|
313
|
+
/** The answer a progress row `runId` carries (`_progress_<turn id>`), '' for
|
|
314
|
+
* any other row. A row is named by its task session now and was by its send
|
|
315
|
+
* before (agent-task-sessions.mjs progressRunId); turn ids are unique, so
|
|
316
|
+
* either name of one answer's update gives the same key, and an update
|
|
317
|
+
* already posted under the old name is never posted again. */
|
|
318
|
+
function answerKey(runId) {
|
|
319
|
+
const at = String(runId || '').indexOf('_progress_');
|
|
320
|
+
return at < 0 ? '' : String(runId).slice(at);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/** Whether progress row `item` carries an answer `homeId` already holds or
|
|
324
|
+
* posted (answerKey), under whichever name. */
|
|
325
|
+
function repeatsProgress(doc, homeId, item) {
|
|
326
|
+
const key = item.status === 'working' ? answerKey(item.runId) : '';
|
|
327
|
+
if (!key) return false;
|
|
328
|
+
const held = [...(doc.homes[homeId] || []).map((row) => row.runId), ...(doc.delivered[homeId] || [])];
|
|
329
|
+
return held.some((runId) => answerKey(runId) === key);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/** `doc` with task report `item` folded into the row of the same run id
|
|
333
|
+
* still queued for `homeId` — the one card of an answer several open sends'
|
|
334
|
+
* chains reached: it names every send and lists the files each produced
|
|
335
|
+
* (the folded ones by path, at most HANDOFF_LIMITS.count, the rest counted
|
|
336
|
+
* as omitted). Null when no such row is queued. */
|
|
337
|
+
function withFoldedReport(doc, homeId, item) {
|
|
338
|
+
const list = doc.homes[homeId] || [];
|
|
339
|
+
const index = list.findIndex((row) => row.runId === item.runId);
|
|
340
|
+
if (index < 0 || item.kind !== 'agent-task') return null;
|
|
341
|
+
const row = list[index];
|
|
342
|
+
const rowSends = [row.sendId, ...(row.sendIds || [])].filter(Boolean);
|
|
343
|
+
const itemSends = [item.sendId, ...(item.sendIds || [])].filter(Boolean);
|
|
344
|
+
// The row's sends are the contributions already folded into it: a replay of
|
|
345
|
+
// one (or a file its cap dropped, whose path is not kept) adds nothing, so
|
|
346
|
+
// its omissions are never counted twice.
|
|
347
|
+
if (itemSends.length && itemSends.every((id) => rowSends.includes(id))) return null;
|
|
348
|
+
const sendIds = [...new Set([...rowSends, ...itemSends])];
|
|
349
|
+
const paths = new Set((row.files || []).map((file) => file.path));
|
|
350
|
+
const added = (item.files || [])
|
|
351
|
+
.filter((file) => !paths.has(file.path) && paths.add(file.path))
|
|
352
|
+
.map(({ id: _id, ...file }) => file);
|
|
353
|
+
const files = [...(row.files || []), ...added];
|
|
354
|
+
const omitted = (row.omitted || 0) + (item.omitted || 0) + Math.max(0, files.length - HANDOFF_LIMITS.count);
|
|
355
|
+
const folded = {
|
|
356
|
+
...row,
|
|
357
|
+
...(sendIds.length > 1 ? { sendIds } : {}),
|
|
358
|
+
...(files.length ? { files: files.slice(0, HANDOFF_LIMITS.count) } : {}),
|
|
359
|
+
...(omitted > 0 ? { omitted } : {}),
|
|
360
|
+
};
|
|
361
|
+
if (JSON.stringify(folded) === JSON.stringify(row)) return null;
|
|
362
|
+
const next = list.map((entry, at) => (at === index ? folded : entry));
|
|
363
|
+
return { ...doc, homes: { ...doc.homes, [homeId]: next } };
|
|
364
|
+
}
|
|
365
|
+
|
|
311
366
|
/** The persisted queue at `filePath`: `{ homes: { [homeSessionId]: item[] },
|
|
312
367
|
* omitted: { [homeSessionId]: { id, count } }, delivered: { [homeSessionId]:
|
|
313
368
|
* runId[] } }`. A home keeps at most `limit` items: past it the oldest drop,
|
|
@@ -477,7 +532,8 @@ export function createRoutineResultQueue(
|
|
|
477
532
|
return (await read()).omitted[homeId] || null;
|
|
478
533
|
},
|
|
479
534
|
/** Queue `item` for `homeId`; `unwatch` (run ids) drops those watches in the
|
|
480
|
-
* same write, also when the item was queued or posted before
|
|
535
|
+
* same write, also when the item was queued or posted before (a task
|
|
536
|
+
* report of a row still queued folds into it: withFoldedReport).
|
|
481
537
|
* `progressPosted`: the thread holds the progress update a final report
|
|
482
538
|
* names (withoutRepeatedProgress). `progressed` (`{ runId, turnId }`):
|
|
483
539
|
* watch `runId` reported turn `turnId` as progress — its durable mark,
|
|
@@ -485,8 +541,13 @@ export function createRoutineResultQueue(
|
|
|
485
541
|
async add(homeId, queued, { unwatch = [], progressPosted = false, progressed = null } = {}) {
|
|
486
542
|
await update((stored) => {
|
|
487
543
|
const { doc, item } = withoutRepeatedProgress(stored, homeId, queued, progressPosted);
|
|
544
|
+
// An answer's update or end that open sends converging on it each
|
|
545
|
+
// report: queued once (folded into the queued end), never reposted.
|
|
546
|
+
const folded = withFoldedReport(doc, homeId, item);
|
|
488
547
|
let next = null;
|
|
489
|
-
if (
|
|
548
|
+
if (repeatsProgress(doc, homeId, item)) next = null;
|
|
549
|
+
else if (folded) next = folded;
|
|
550
|
+
else if (item.roundTrip !== true) next = appended(doc, homeId, [item]);
|
|
490
551
|
else {
|
|
491
552
|
// A task turn's end counts one round trip, once per run id, per home
|
|
492
553
|
// and target: the user's next message in that home starts over
|
|
@@ -1191,11 +1252,18 @@ export function createAgentHomeDelivery({
|
|
|
1191
1252
|
});
|
|
1192
1253
|
return run;
|
|
1193
1254
|
}
|
|
1194
|
-
/** Whether
|
|
1255
|
+
/** Whether progress row `runId`, or another carrying the same answer
|
|
1256
|
+
* (answerKey), is in thread `homeId` (posted, saved or not). */
|
|
1195
1257
|
const postedIn = (homeId, runId) => {
|
|
1196
1258
|
const messages = loadSession(homeId)?.messages;
|
|
1197
|
-
const
|
|
1198
|
-
return
|
|
1259
|
+
const key = answerKey(runId);
|
|
1260
|
+
return (
|
|
1261
|
+
Array.isArray(messages) &&
|
|
1262
|
+
messages.some((message) => {
|
|
1263
|
+
const messageId = message?.meta?.transcript?.messageId;
|
|
1264
|
+
return messageId === messageIdOf(runId) || (key && answerKey(messageId) === key);
|
|
1265
|
+
})
|
|
1266
|
+
);
|
|
1199
1267
|
};
|
|
1200
1268
|
const intake = createHomeEnqueue(queue, drain, { postingFor, postedIn });
|
|
1201
1269
|
const { watchTask, recover } = createHomeBookkeeping({ queue, log, homeDeleted, sessionDeleted, drain });
|
|
@@ -14,6 +14,18 @@ export function subscribeAgentProfileChanges(listener) {
|
|
|
14
14
|
return { unsubscribe: () => listeners.delete(listener) };
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
/** The keys of a saved agent route its chats and reused workers follow. */
|
|
18
|
+
export const AGENT_ROUTE_KEYS = Object.freeze([
|
|
19
|
+
'provider',
|
|
20
|
+
'model',
|
|
21
|
+
'effort',
|
|
22
|
+
'fast',
|
|
23
|
+
'autoEffort',
|
|
24
|
+
'modelParameters',
|
|
25
|
+
'contextPercent',
|
|
26
|
+
'contextTokens',
|
|
27
|
+
]);
|
|
28
|
+
|
|
17
29
|
// A bot's saved model route: the hosts of its chats (the session service)
|
|
18
30
|
// move them onto it from their next turn.
|
|
19
31
|
const routeListeners = new Set();
|
|
@@ -23,11 +35,50 @@ export function subscribeAgentRouteChanges(listener) {
|
|
|
23
35
|
return { unsubscribe: () => routeListeners.delete(listener) };
|
|
24
36
|
}
|
|
25
37
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
38
|
+
// Per bot, the route every host of this process took last (recorded only once
|
|
39
|
+
// all of them took it), and the publication in flight.
|
|
40
|
+
const publishedRoutes = new Map();
|
|
41
|
+
const publishingRoutes = new Map();
|
|
42
|
+
|
|
43
|
+
/** Every host takes the route; rejects with the hosts' failures. A
|
|
44
|
+
* publication of the same route already in flight is joined, not repeated. */
|
|
45
|
+
function deliverAgentRoute(agentId, route) {
|
|
46
|
+
const key = JSON.stringify(route ?? null);
|
|
47
|
+
const inFlight = publishingRoutes.get(agentId);
|
|
48
|
+
if (inFlight?.key === key) return inFlight.done;
|
|
49
|
+
const done = Promise.allSettled(
|
|
29
50
|
[...routeListeners].map((listener) => Promise.resolve().then(() => listener(agentId, route)))
|
|
30
|
-
)
|
|
51
|
+
).then((results) => {
|
|
52
|
+
if (publishingRoutes.get(agentId)?.done === done) publishingRoutes.delete(agentId);
|
|
53
|
+
const failures = results.filter((one) => one.status === 'rejected').map((one) => one.reason);
|
|
54
|
+
if (failures.length) {
|
|
55
|
+
throw new AggregateError(
|
|
56
|
+
failures,
|
|
57
|
+
`the ${agentId} route reached ${results.length - failures.length} of ${results.length} hosts`
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
publishedRoutes.set(agentId, key);
|
|
61
|
+
});
|
|
62
|
+
publishingRoutes.set(agentId, { key, done });
|
|
63
|
+
return done;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Settles once every host has taken the route; one failing host never fails
|
|
67
|
+
* the save (the change step that follows it publishes the route again). */
|
|
68
|
+
export async function publishAgentRouteChange(agentId, route) {
|
|
69
|
+
try {
|
|
70
|
+
await deliverAgentRoute(agentId, route);
|
|
71
|
+
} catch {}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** A bot route read from a changed config (saved by another process, edited
|
|
75
|
+
* by hand, or this process's own save): every runtime of the process applies
|
|
76
|
+
* the same change, so the hosts hear each route once, unless one failed to
|
|
77
|
+
* take it. Rejects when a host failed, so the change step retries it. */
|
|
78
|
+
export function publishStoredAgentRoute(agentId, route) {
|
|
79
|
+
const inFlight = publishingRoutes.get(agentId);
|
|
80
|
+
if (!inFlight && publishedRoutes.get(agentId) === JSON.stringify(route ?? null)) return Promise.resolve();
|
|
81
|
+
return deliverAgentRoute(agentId, route);
|
|
31
82
|
}
|
|
32
83
|
|
|
33
84
|
/** Settles once every runtime has applied the edit; one failing runtime never fails the save. */
|