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
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenRouter provider routing: the per-model `providerSort` picker parameter
|
|
3
|
+
* and the request's `provider: { sort }` field. Auto (the default) sends
|
|
4
|
+
* nothing; a stored value outside the known sorts is dropped.
|
|
5
|
+
*/
|
|
6
|
+
export const OPENROUTER_SORT_PARAMETER = 'providerSort';
|
|
7
|
+
|
|
8
|
+
const SORTS = new Set(['price', 'throughput', 'latency']);
|
|
9
|
+
|
|
10
|
+
export const OPENROUTER_SORT_OPTION = Object.freeze({
|
|
11
|
+
id: OPENROUTER_SORT_PARAMETER,
|
|
12
|
+
label: 'Routing',
|
|
13
|
+
kind: 'enum',
|
|
14
|
+
options: [
|
|
15
|
+
{ value: 'auto', label: 'Auto' },
|
|
16
|
+
{ value: 'price', label: 'Price first' },
|
|
17
|
+
{ value: 'throughput', label: 'Speed first' },
|
|
18
|
+
{ value: 'latency', label: 'Latency first' },
|
|
19
|
+
],
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
/** `{ sort }` for the request body's `provider` field, or null for Auto or an unknown value. */
|
|
23
|
+
export function openRouterProviderRouting(opts = {}) {
|
|
24
|
+
const sort = String(opts?.modelParameters?.[OPENROUTER_SORT_PARAMETER] ?? '')
|
|
25
|
+
.trim()
|
|
26
|
+
.toLowerCase();
|
|
27
|
+
return SORTS.has(sort) ? { sort } : null;
|
|
28
|
+
}
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
import { WireGatewayProvider, messagesBaseFromOpenAIBase } from './wire-gateway.mjs';
|
|
11
11
|
import { OPENAI_COMPAT_PRESETS } from './openai-compat-presets.mjs';
|
|
12
12
|
import { openRouterReasoning } from './openai-compat-options.mjs';
|
|
13
|
+
import { openRouterProviderRouting } from './openrouter-provider-routing.mjs';
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* The Claude id a routing slug stands for: an alias (`~anthropic/claude-opus-latest`)
|
|
@@ -25,12 +26,14 @@ export function openRouterCapabilityModel(model, aliasTarget = null) {
|
|
|
25
26
|
|
|
26
27
|
// Responses requests carry the same reasoning control as Chat requests
|
|
27
28
|
// (`openRouterReasoningEffort`, else the turn effort, else the configured
|
|
28
|
-
// effort; `none` disables reasoning).
|
|
29
|
+
// effort; `none` disables reasoning) and the same provider routing.
|
|
29
30
|
function openRouterResponsesParams(config) {
|
|
30
31
|
return (params, { opts }) => {
|
|
31
32
|
const reasoning = openRouterReasoning(opts, config);
|
|
32
33
|
if (reasoning) params.reasoning = reasoning;
|
|
33
34
|
else delete params.reasoning;
|
|
35
|
+
const routing = openRouterProviderRouting(opts);
|
|
36
|
+
if (routing) params.provider = routing;
|
|
34
37
|
};
|
|
35
38
|
}
|
|
36
39
|
|
|
@@ -385,29 +385,6 @@ async function _initProvidersUnsynchronized(config, signal = null, proxyChannel
|
|
|
385
385
|
if (result.sig !== null) nextSignatures.set(result.name, result.sig);
|
|
386
386
|
}
|
|
387
387
|
_providerInitErrors = nextInitErrors;
|
|
388
|
-
// Second guard: every entry was disabled. Same reasoning — keep the
|
|
389
|
-
// existing registry rather than going dark. Isolation still holds: a live
|
|
390
|
-
// instance of a provider that is now an invalid custom config is removed
|
|
391
|
-
// (the rest of the registry stays), and the recorded reasons are reported.
|
|
392
|
-
if (next.size === 0) {
|
|
393
|
-
let removed = false;
|
|
394
|
-
for (const name of nextInitErrors.keys()) {
|
|
395
|
-
removed = providers.delete(name) || removed;
|
|
396
|
-
signatures.delete(name);
|
|
397
|
-
}
|
|
398
|
-
if (removed) {
|
|
399
|
-
_providerCatalogRevision += 1;
|
|
400
|
-
_startupCatalogRefreshPromise = null;
|
|
401
|
-
// The live registry no longer reflects the last applied config.
|
|
402
|
-
_lastAppliedSig = null;
|
|
403
|
-
}
|
|
404
|
-
const reasons = [...nextInitErrors.values()];
|
|
405
|
-
throw noEnabledProvidersError(
|
|
406
|
-
`[provider] all providers disabled in config — refusing to clear registry${
|
|
407
|
-
reasons.length ? `; invalid custom providers skipped: ${reasons.join('; ')}` : ''
|
|
408
|
-
}`
|
|
409
|
-
);
|
|
410
|
-
}
|
|
411
388
|
// OAuth preservation guard. anthropic-oauth / openai-oauth are NOT stored
|
|
412
389
|
// in mixdog-config.json — buildDefaultConfig injects them at runtime by
|
|
413
390
|
// calling hasAnthropic/OpenAIOAuthCredentials(), which reads the on-disk
|
|
@@ -430,20 +407,48 @@ async function _initProvidersUnsynchronized(config, signal = null, proxyChannel
|
|
|
430
407
|
// `enabled` itself, so an explicit UI/hand-edited disable still removes the
|
|
431
408
|
// provider even while its credential file happens to be unreadable, and a
|
|
432
409
|
// logout (probe 'absent') never carries the marker at all.
|
|
410
|
+
//
|
|
411
|
+
// It runs before the all-disabled guard below: a secrets-less load
|
|
412
|
+
// (explore) marks every OAuth entry probe-unavailable, so an OAuth-only
|
|
413
|
+
// setup has no enabled entry and only its preserved instances.
|
|
433
414
|
const nextDisabled = new Set();
|
|
434
415
|
for (const [name, cfg] of entries) {
|
|
435
416
|
if (cfg?.enabled) continue;
|
|
436
417
|
if (OAUTH_PROVIDER_NAMES.has(name) && cfg?.credentialProbeUnavailable === true) continue;
|
|
437
418
|
nextDisabled.add(name);
|
|
438
419
|
}
|
|
439
|
-
_explicitlyDisabled = nextDisabled;
|
|
440
420
|
for (const name of OAUTH_PROVIDER_NAMES) {
|
|
441
421
|
if (next.has(name) || !providers.has(name)) continue;
|
|
442
|
-
if (
|
|
422
|
+
if (nextDisabled.has(name)) continue;
|
|
443
423
|
if (oauthCredentialProbeState(name) === 'absent') continue;
|
|
444
424
|
next.set(name, providers.get(name));
|
|
445
425
|
if (signatures.has(name)) nextSignatures.set(name, signatures.get(name));
|
|
446
426
|
}
|
|
427
|
+
// Second guard: every entry was disabled and nothing was preserved. Same
|
|
428
|
+
// reasoning — keep the existing registry rather than going dark. Isolation
|
|
429
|
+
// still holds: a live instance of a provider that is now an invalid custom
|
|
430
|
+
// config is removed (the rest of the registry stays), and the recorded
|
|
431
|
+
// reasons are reported.
|
|
432
|
+
if (next.size === 0) {
|
|
433
|
+
let removed = false;
|
|
434
|
+
for (const name of nextInitErrors.keys()) {
|
|
435
|
+
removed = providers.delete(name) || removed;
|
|
436
|
+
signatures.delete(name);
|
|
437
|
+
}
|
|
438
|
+
if (removed) {
|
|
439
|
+
_providerCatalogRevision += 1;
|
|
440
|
+
_startupCatalogRefreshPromise = null;
|
|
441
|
+
// The live registry no longer reflects the last applied config.
|
|
442
|
+
_lastAppliedSig = null;
|
|
443
|
+
}
|
|
444
|
+
const reasons = [...nextInitErrors.values()];
|
|
445
|
+
throw noEnabledProvidersError(
|
|
446
|
+
`[provider] all providers disabled in config — refusing to clear registry${
|
|
447
|
+
reasons.length ? `; invalid custom providers skipped: ${reasons.join('; ')}` : ''
|
|
448
|
+
}`
|
|
449
|
+
);
|
|
450
|
+
}
|
|
451
|
+
_explicitlyDisabled = nextDisabled;
|
|
447
452
|
throwIfAborted(signal);
|
|
448
453
|
// Reconfiguration opens a new catalog epoch. A provider added (or rebuilt
|
|
449
454
|
// with an empty model cache) after the startup refresh settled would
|
|
@@ -3,6 +3,7 @@ import { getLlmDispatcher } from '../../../shared/llm/http-agent.mjs';
|
|
|
3
3
|
import { sanitizeToolPairs } from '../session/context-utils.mjs';
|
|
4
4
|
import { noteRequestServiceTier } from '../../../shared/llm/usage-context.mjs';
|
|
5
5
|
import { buildGeminiRequest } from './gemini-request-body.mjs';
|
|
6
|
+
import { geminiDocumentedThinkingLevels } from './gemini-thinking.mjs';
|
|
6
7
|
import { geminiEndsWithFunctionResponse, runGeminiStreamAttempts } from './gemini-retry-policy.mjs';
|
|
7
8
|
import { consumeGeminiRestStreamResponse } from './gemini-stream.mjs';
|
|
8
9
|
import { geminiTextLeakGuardFor } from './gemini-sdk-request.mjs';
|
|
@@ -551,7 +552,15 @@ export class VertexAIProvider {
|
|
|
551
552
|
async listModels() {
|
|
552
553
|
return VERTEX_MODELS.map((model) => {
|
|
553
554
|
const tierOption = vertexTierOption(model.id);
|
|
554
|
-
|
|
555
|
+
// The picker offers effort only from a declared ladder; these models'
|
|
556
|
+
// levels are documented rather than listed by a catalog.
|
|
557
|
+
const levels = geminiDocumentedThinkingLevels(model.id);
|
|
558
|
+
return {
|
|
559
|
+
...model,
|
|
560
|
+
provider: this.name,
|
|
561
|
+
...(levels ? { supportsReasoning: true, reasoningOptions: [{ type: 'effort', values: levels }] } : {}),
|
|
562
|
+
...(tierOption ? { modelParameterOptions: [tierOption] } : {}),
|
|
563
|
+
};
|
|
555
564
|
});
|
|
556
565
|
}
|
|
557
566
|
|
|
@@ -55,9 +55,7 @@
|
|
|
55
55
|
}
|
|
56
56
|
],
|
|
57
57
|
"store": false,
|
|
58
|
-
"include": [
|
|
59
|
-
"reasoning.encrypted_content"
|
|
60
|
-
],
|
|
58
|
+
"include": ["reasoning.encrypted_content"],
|
|
61
59
|
"prompt_cache_key": "f0858c98-2db1-4764-9d18-e6e1ec2ea4c7",
|
|
62
60
|
"tools": [
|
|
63
61
|
{
|
|
@@ -148,9 +146,7 @@
|
|
|
148
146
|
}
|
|
149
147
|
],
|
|
150
148
|
"store": false,
|
|
151
|
-
"include": [
|
|
152
|
-
"reasoning.encrypted_content"
|
|
153
|
-
],
|
|
149
|
+
"include": ["reasoning.encrypted_content"],
|
|
154
150
|
"prompt_cache_key": "f0858c98-2db1-4764-9d18-e6e1ec2ea4c7",
|
|
155
151
|
"tools": [
|
|
156
152
|
{
|
|
@@ -278,9 +274,7 @@
|
|
|
278
274
|
}
|
|
279
275
|
],
|
|
280
276
|
"store": false,
|
|
281
|
-
"include": [
|
|
282
|
-
"reasoning.encrypted_content"
|
|
283
|
-
],
|
|
277
|
+
"include": ["reasoning.encrypted_content"],
|
|
284
278
|
"prompt_cache_key": "f0858c98-2db1-4764-9d18-e6e1ec2ea4c7",
|
|
285
279
|
"tools": [
|
|
286
280
|
{
|
|
@@ -400,9 +394,7 @@
|
|
|
400
394
|
}
|
|
401
395
|
],
|
|
402
396
|
"store": false,
|
|
403
|
-
"include": [
|
|
404
|
-
"reasoning.encrypted_content"
|
|
405
|
-
],
|
|
397
|
+
"include": ["reasoning.encrypted_content"],
|
|
406
398
|
"prompt_cache_key": "f0858c98-2db1-4764-9d18-e6e1ec2ea4c7",
|
|
407
399
|
"instructions": "sys",
|
|
408
400
|
"tools": [
|
|
@@ -513,9 +505,7 @@
|
|
|
513
505
|
}
|
|
514
506
|
],
|
|
515
507
|
"store": false,
|
|
516
|
-
"include": [
|
|
517
|
-
"reasoning.encrypted_content"
|
|
518
|
-
],
|
|
508
|
+
"include": ["reasoning.encrypted_content"],
|
|
519
509
|
"prompt_cache_key": "f0858c98-2db1-4764-9d18-e6e1ec2ea4c7",
|
|
520
510
|
"tools": [
|
|
521
511
|
{
|
|
@@ -626,9 +616,7 @@
|
|
|
626
616
|
}
|
|
627
617
|
],
|
|
628
618
|
"store": false,
|
|
629
|
-
"include": [
|
|
630
|
-
"reasoning.encrypted_content"
|
|
631
|
-
],
|
|
619
|
+
"include": ["reasoning.encrypted_content"],
|
|
632
620
|
"prompt_cache_key": "f0858c98-2db1-4764-9d18-e6e1ec2ea4c7",
|
|
633
621
|
"tools": [
|
|
634
622
|
{
|
|
@@ -738,9 +726,7 @@
|
|
|
738
726
|
}
|
|
739
727
|
],
|
|
740
728
|
"store": false,
|
|
741
|
-
"include": [
|
|
742
|
-
"reasoning.encrypted_content"
|
|
743
|
-
],
|
|
729
|
+
"include": ["reasoning.encrypted_content"],
|
|
744
730
|
"prompt_cache_key": "f0858c98-2db1-4764-9d18-e6e1ec2ea4c7",
|
|
745
731
|
"tools": [
|
|
746
732
|
{
|
|
@@ -865,9 +851,7 @@
|
|
|
865
851
|
}
|
|
866
852
|
],
|
|
867
853
|
"store": false,
|
|
868
|
-
"include": [
|
|
869
|
-
"reasoning.encrypted_content"
|
|
870
|
-
],
|
|
854
|
+
"include": ["reasoning.encrypted_content"],
|
|
871
855
|
"prompt_cache_key": "f0858c98-2db1-4764-9d18-e6e1ec2ea4c7",
|
|
872
856
|
"tools": [
|
|
873
857
|
{
|
|
@@ -971,9 +955,7 @@
|
|
|
971
955
|
}
|
|
972
956
|
],
|
|
973
957
|
"store": false,
|
|
974
|
-
"include": [
|
|
975
|
-
"reasoning.encrypted_content"
|
|
976
|
-
],
|
|
958
|
+
"include": ["reasoning.encrypted_content"],
|
|
977
959
|
"prompt_cache_key": "f0858c98-2db1-4764-9d18-e6e1ec2ea4c7",
|
|
978
960
|
"tools": [
|
|
979
961
|
{
|
|
@@ -1078,9 +1060,7 @@
|
|
|
1078
1060
|
}
|
|
1079
1061
|
],
|
|
1080
1062
|
"store": false,
|
|
1081
|
-
"include": [
|
|
1082
|
-
"reasoning.encrypted_content"
|
|
1083
|
-
],
|
|
1063
|
+
"include": ["reasoning.encrypted_content"],
|
|
1084
1064
|
"prompt_cache_key": "f0858c98-2db1-4764-9d18-e6e1ec2ea4c7",
|
|
1085
1065
|
"tools": [
|
|
1086
1066
|
{
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// The text an ask_user call returns to the model for the user's decision:
|
|
2
|
+
// shared by the tool (ask-user-tool.mjs) and the hand-off copies of a
|
|
3
|
+
// question (tui/session/tool-approval.mjs), whose settled card shows the same
|
|
4
|
+
// record the asking session's transcript keeps.
|
|
5
|
+
import { ASK_USER_MAX_TEXT } from './ask-user-tool-defs.mjs';
|
|
6
|
+
|
|
7
|
+
const ASK_USER_DISMISSED =
|
|
8
|
+
'User closed the questions without answering. Proceed with your best judgment; ask again only if something new depends on it.';
|
|
9
|
+
|
|
10
|
+
/** Wire answers -> array aligned with questions; invalid entries become null. */
|
|
11
|
+
function normalizeAskUserAnswers(answers, questions) {
|
|
12
|
+
const list = Array.isArray(answers) ? answers.slice(0, 4) : [];
|
|
13
|
+
return questions.map((q, i) => {
|
|
14
|
+
const entry = list[i];
|
|
15
|
+
if (!entry || typeof entry !== 'object') return null;
|
|
16
|
+
const labels = new Set(q.options.map((o) => o.label));
|
|
17
|
+
const rawSelected = entry.selected == null ? [] : entry.selected;
|
|
18
|
+
if (!Array.isArray(rawSelected) || !rawSelected.every((l) => typeof l === 'string' && labels.has(l))) return null;
|
|
19
|
+
if (entry.text != null && (typeof entry.text !== 'string' || entry.text.length > ASK_USER_MAX_TEXT)) return null;
|
|
20
|
+
const selected = q.multi_select === true ? [...new Set(rawSelected)] : rawSelected.slice(0, 1);
|
|
21
|
+
const text = typeof entry.text === 'string' ? entry.text.trim() : '';
|
|
22
|
+
if (!selected.length && !text) return null;
|
|
23
|
+
return text ? { selected, text } : { selected };
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Strings are JSON-quoted so a quote inside one cannot end it early; typed
|
|
28
|
+
// text stays apart from the picked labels (`"picked" + "typed" (typed)`).
|
|
29
|
+
function formatAskUserAnswers(questions, answers) {
|
|
30
|
+
const quote = (text) => JSON.stringify(text);
|
|
31
|
+
const parts = questions.map((q, i) => {
|
|
32
|
+
const a = answers[i];
|
|
33
|
+
if (!a) return `${quote(q.question)}=(no answer)`;
|
|
34
|
+
const picked = a.selected.length ? quote(a.selected.join(', ')) : '';
|
|
35
|
+
const typed = a.text ? `${quote(a.text)} (typed)` : '';
|
|
36
|
+
return `${quote(q.question)}=${[picked, typed].filter(Boolean).join(' + ')}`;
|
|
37
|
+
});
|
|
38
|
+
return `User has answered your questions: ${parts.join('; ')}. You can now continue with these answers in mind.`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** A composer message sent instead of (or with) picking: kept when it is a
|
|
42
|
+
* non-empty string within the typed-answer limit, else dropped. */
|
|
43
|
+
function normalizeAskUserReply(reply) {
|
|
44
|
+
if (typeof reply !== 'string' || reply.length > ASK_USER_MAX_TEXT) return '';
|
|
45
|
+
return reply.trim();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// `User replied in chat: "<reply>". ` leads, then the usual picks sentence
|
|
49
|
+
// when any question was answered, else just the closing sentence.
|
|
50
|
+
function formatAskUserResult(questions, answers, reply) {
|
|
51
|
+
if (!reply) return formatAskUserAnswers(questions, answers);
|
|
52
|
+
const lead = `User replied in chat: ${JSON.stringify(reply)}. `;
|
|
53
|
+
if (answers.some(Boolean)) return `${lead}${formatAskUserAnswers(questions, answers)}`;
|
|
54
|
+
return `${lead}You can now continue with these answers in mind.`;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** The ask_user result for `questions` (validated) and the hook's `result`
|
|
58
|
+
* (`{ approved, answers, reply }`): the answers, or the dismissal. */
|
|
59
|
+
export function askUserResultText(questions, result) {
|
|
60
|
+
if (result?.approved !== true) return ASK_USER_DISMISSED;
|
|
61
|
+
return formatAskUserResult(
|
|
62
|
+
questions,
|
|
63
|
+
normalizeAskUserAnswers(result.answers, questions),
|
|
64
|
+
normalizeAskUserReply(result.reply)
|
|
65
|
+
);
|
|
66
|
+
}
|
|
@@ -129,6 +129,36 @@ export function builtinFeatureActive(configLike, id) {
|
|
|
129
129
|
return false;
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
+
/** Every tool a settings gate of featureDisallowedToolsFor can deny (the
|
|
133
|
+
* headless `load_tool` rule derives from these and is not a setting). */
|
|
134
|
+
export const FEATURE_GATED_TOOL_NAMES = Object.freeze([
|
|
135
|
+
'web_search',
|
|
136
|
+
'web_fetch',
|
|
137
|
+
'memory',
|
|
138
|
+
'recall',
|
|
139
|
+
'git',
|
|
140
|
+
'github',
|
|
141
|
+
'browser',
|
|
142
|
+
'browser_devtools',
|
|
143
|
+
'computer',
|
|
144
|
+
'terminal',
|
|
145
|
+
'office',
|
|
146
|
+
'media',
|
|
147
|
+
'tidy',
|
|
148
|
+
'visualize',
|
|
149
|
+
'explore',
|
|
150
|
+
'react',
|
|
151
|
+
]);
|
|
152
|
+
|
|
153
|
+
/** Gated by desktop bridge presence, not a setting. */
|
|
154
|
+
const BRIDGE_GATED_TOOL_NAMES = Object.freeze(['browser', 'browser_devtools', 'computer', 'terminal']);
|
|
155
|
+
|
|
156
|
+
/** The tools a user setting turns off (react answers for itself: it gates
|
|
157
|
+
* non-model callers too). */
|
|
158
|
+
export const SETTING_GATED_TOOL_NAMES = Object.freeze(
|
|
159
|
+
FEATURE_GATED_TOOL_NAMES.filter((name) => !BRIDGE_GATED_TOOL_NAMES.includes(name) && name !== 'react')
|
|
160
|
+
);
|
|
161
|
+
|
|
132
162
|
/** The session-surface exclusion list. Session build, the empty-session policy
|
|
133
163
|
* refresh, and the deferred tool catalog all consume THIS list, so an
|
|
134
164
|
* uninstalled or disabled feature never reaches a session's tool surface.
|
|
@@ -348,17 +348,6 @@ export function resolveAutoClearIdleMs(config, provider) {
|
|
|
348
348
|
return autoClearIdleMsForProvider(provider, raw.providerIdleMs);
|
|
349
349
|
}
|
|
350
350
|
|
|
351
|
-
/** The idle auto-clear gate's settings for a thread on `provider`
|
|
352
|
-
* (idle-auto-clear-gate.mjs): `{ enabled, idleMs, minContextPercent }`. */
|
|
353
|
-
function autoClearGateSettings(config, provider) {
|
|
354
|
-
const normalized = normalizeAutoClearConfig(config?.autoClear);
|
|
355
|
-
return {
|
|
356
|
-
enabled: normalized.enabled,
|
|
357
|
-
idleMs: resolveAutoClearIdleMs(config, provider),
|
|
358
|
-
minContextPercent: normalized.minContextPercent,
|
|
359
|
-
};
|
|
360
|
-
}
|
|
361
|
-
|
|
362
351
|
export function normalizeSystemShellConfig(value = {}) {
|
|
363
352
|
const raw = value && typeof value === 'object' ? value : {};
|
|
364
353
|
const command = clean(raw.command);
|
|
@@ -14,6 +14,14 @@ export function sessionDisallows(session, name) {
|
|
|
14
14
|
);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
/** A settings gate denies `name` to the session (as last reconciled, tool-availability.mjs). */
|
|
18
|
+
export function sessionFeatureDenies(session, name) {
|
|
19
|
+
return (
|
|
20
|
+
Array.isArray(session?.featureDeniedTools) &&
|
|
21
|
+
session.featureDeniedTools.some((denied) => lowerName(denied) === lowerName(name))
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
17
25
|
/**
|
|
18
26
|
* The session's own tool policy permits `name`: discovery (load_tool by name
|
|
19
27
|
* or query) shows, selects and describes only what execution would run.
|
|
@@ -2,12 +2,15 @@ import { clean } from './session-text.mjs';
|
|
|
2
2
|
import { parseMcpToolName } from '../../../shared/tool-primitives.mjs';
|
|
3
3
|
import { mcpServerLines } from '../context/deferred-tools.mjs';
|
|
4
4
|
|
|
5
|
+
// A delta names tools; its description is a hint, the schema arrives on load.
|
|
6
|
+
export const DELTA_DESCRIPTION_MAX = 80;
|
|
7
|
+
|
|
5
8
|
function compactDescription(value) {
|
|
6
|
-
|
|
9
|
+
const text = String(value || '')
|
|
7
10
|
.replace(/\s+/g, ' ')
|
|
8
11
|
.replace(/[<>]/g, '')
|
|
9
|
-
.trim()
|
|
10
|
-
|
|
12
|
+
.trim();
|
|
13
|
+
return text.length > DELTA_DESCRIPTION_MAX ? `${text.slice(0, DELTA_DESCRIPTION_MAX - 1).trimEnd()}…` : text;
|
|
11
14
|
}
|
|
12
15
|
|
|
13
16
|
function addedEntry(entry) {
|
|
@@ -168,6 +171,17 @@ export function snapshotPendingDeferredToolDelta(session) {
|
|
|
168
171
|
};
|
|
169
172
|
}
|
|
170
173
|
|
|
174
|
+
/** Drop pending additions the prompt now lists itself (`listed`). */
|
|
175
|
+
export function dropPendingDeferredToolAdds(session, listed) {
|
|
176
|
+
const pending = session?.pendingDeferredToolDelta;
|
|
177
|
+
if (!pending || !Array.isArray(pending.added)) return;
|
|
178
|
+
const added = pending.added.filter((entry) => !listed.has(clean(entry?.name)));
|
|
179
|
+
if (added.length === pending.added.length) return;
|
|
180
|
+
if (!added.length && !(pending.removed || []).length) delete session.pendingDeferredToolDelta;
|
|
181
|
+
else session.pendingDeferredToolDelta = { ...pending, added };
|
|
182
|
+
session.updatedAt = Date.now();
|
|
183
|
+
}
|
|
184
|
+
|
|
171
185
|
export function acknowledgePendingDeferredToolDelta(session, revision) {
|
|
172
186
|
if (!session || typeof session !== 'object') return false;
|
|
173
187
|
const current = normalizedDelta(session.pendingDeferredToolDelta);
|
|
@@ -5,21 +5,20 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { durationLabel } from './goal-text.mjs';
|
|
7
7
|
import { compactSessionTitle } from './session-title.mjs';
|
|
8
|
-
import { applyGoalTaskChanges, optionalGoalTaskChanges } from './goal-tasks.mjs';
|
|
9
8
|
import {
|
|
10
9
|
NO_DEADLINE_WARNING_MS,
|
|
11
10
|
activateGoal,
|
|
12
11
|
activeElapsedMs,
|
|
13
12
|
assertSessionId,
|
|
14
13
|
clearTurnFailures,
|
|
15
|
-
goalTimeMode,
|
|
16
14
|
parseGoalDuration,
|
|
17
15
|
parseUserCommand,
|
|
16
|
+
publicGoal,
|
|
18
17
|
resumeGoalState,
|
|
19
18
|
stopActiveClock,
|
|
20
19
|
validateObjective,
|
|
21
20
|
} from './goal-state.mjs';
|
|
22
|
-
import { assertExpectedGoal, goalFinished } from './goal-mutations.mjs';
|
|
21
|
+
import { assertExpectedGoal, goalFinished, goalStalled } from './goal-mutations.mjs';
|
|
23
22
|
import { clean } from '../../../shared/clean.mjs';
|
|
24
23
|
|
|
25
24
|
/** "12m remaining" for a budgeted Goal, "3m elapsed" for an open-ended one. */
|
|
@@ -31,6 +30,9 @@ function goalTimingLabel(goal) {
|
|
|
31
30
|
|
|
32
31
|
const reply = (action, goal, message) => ({ ok: true, action, goal, message });
|
|
33
32
|
|
|
33
|
+
/** `code` of the create answer that asks the user to confirm replacing a stalled Goal. */
|
|
34
|
+
export const GOAL_REPLACE_REQUIRED = 'goal-replace-required';
|
|
35
|
+
|
|
34
36
|
const GOAL_CONTROL_ACTIONS = {
|
|
35
37
|
async stop(ctx, { id, expectedGoalId, action }) {
|
|
36
38
|
const goal = await ctx.abandonGoal(id, { expectedGoalId, archive: true });
|
|
@@ -52,34 +54,27 @@ const GOAL_CONTROL_ACTIONS = {
|
|
|
52
54
|
throw new Error('a completed Goal cannot be resumed; edit it or create a new Goal');
|
|
53
55
|
}
|
|
54
56
|
const added = args.duration ? parseGoalDuration(args.duration) : null;
|
|
55
|
-
const timeMode = goalTimeMode(args.timeMode, goal.timeMode);
|
|
56
|
-
// Empty optional fields from frozen provider schemas still mean a plain
|
|
57
|
-
// resume. Supplied changes validate before activation and share its write.
|
|
58
|
-
const taskChanges = optionalGoalTaskChanges(args);
|
|
59
|
-
const hasTaskChanges = [taskChanges.updates, taskChanges.tasks].some(
|
|
60
|
-
(value) => value != null && (!Array.isArray(value) || value.length > 0)
|
|
61
|
-
);
|
|
62
|
-
if (hasTaskChanges) applyGoalTaskChanges(goal, taskChanges, { partial: true, at });
|
|
63
57
|
resumeGoalState(goal, at, added);
|
|
64
|
-
goal.timeMode = timeMode;
|
|
65
58
|
const resumed = await ctx.commit(id, goal);
|
|
66
59
|
return reply(action, resumed, `Goal resumed · ${resumed.objective} · ${goalTimingLabel(resumed)}`);
|
|
67
60
|
},
|
|
68
61
|
async edit(ctx, { id, goal, args, at, action }) {
|
|
69
|
-
//
|
|
70
|
-
//
|
|
71
|
-
// away every completed row; re-aligning a stale list is set_tasks' job.
|
|
62
|
+
// The session's todo list is untouched by an objective edit; the
|
|
63
|
+
// objective-updated reminder asks the model to re-align it.
|
|
72
64
|
const objective = validateObjective(args.objective);
|
|
73
65
|
let timeLimitMs = goal.timeLimitMs;
|
|
74
|
-
if (args.
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
66
|
+
if (args.time_limit_minutes != null && args.time_limit_minutes !== '') {
|
|
67
|
+
const minutes = Number(args.time_limit_minutes);
|
|
68
|
+
if (!Number.isFinite(minutes) || minutes < 0) throw new Error('goal time_limit_minutes must be 0 or more');
|
|
69
|
+
timeLimitMs = minutes === 0 ? 0 : parseGoalDuration(minutes * 60_000);
|
|
70
|
+
} else if (args.timeLimitMs != null) {
|
|
71
|
+
timeLimitMs = args.timeLimitMs === 0 ? 0 : parseGoalDuration(args.timeLimitMs);
|
|
72
|
+
} else if (args.duration != null) timeLimitMs = parseGoalDuration(args.duration);
|
|
73
|
+
if (objective !== goal.objective) goal.objectiveRevision = (Number(goal.objectiveRevision) || 0) + 1;
|
|
78
74
|
goal.objective = objective;
|
|
79
75
|
goal.title = compactSessionTitle(goal.objective);
|
|
80
76
|
if (timeLimitMs !== goal.timeLimitMs) goal.deadlineWarnedMs = NO_DEADLINE_WARNING_MS;
|
|
81
77
|
goal.timeLimitMs = timeLimitMs;
|
|
82
|
-
goal.timeMode = timeMode;
|
|
83
78
|
if (goal.status === 'complete') activateGoal(goal, at);
|
|
84
79
|
else clearTurnFailures(goal);
|
|
85
80
|
goal.updatedAt = at;
|
|
@@ -106,13 +101,19 @@ const GOAL_CONTROL_ACTIONS = {
|
|
|
106
101
|
return reply(action, timed, `Goal duration · ${durationLabel(limit)}`);
|
|
107
102
|
},
|
|
108
103
|
async complete(ctx, { id, action }) {
|
|
109
|
-
const goal = await ctx.updateGoal(id, { status: 'complete' }
|
|
104
|
+
const goal = await ctx.updateGoal(id, { status: 'complete' });
|
|
110
105
|
return reply(action, goal, `Goal complete · ${goal.objective} · ${durationLabel(goal.timeUsedMs)} elapsed`);
|
|
111
106
|
},
|
|
112
|
-
async dismiss(ctx, { id, goal, at, action }) {
|
|
107
|
+
async dismiss(ctx, { id, goal, at, action, expectedGoalId }) {
|
|
108
|
+
// A stalled Goal waits for the user and nothing else retires it: dismissing
|
|
109
|
+
// it is the stop-and-archive the Stop control confirms.
|
|
110
|
+
if (goalStalled(goal)) {
|
|
111
|
+
await ctx.abandonGoal(id, { expectedGoalId, archive: true });
|
|
112
|
+
return reply(action, null, `Goal dismissed · ${goal.objective}`);
|
|
113
|
+
}
|
|
113
114
|
// The user's acknowledgement of finished work: the same archive a new
|
|
114
115
|
// prompt applies, so the chrome lets go while the record stays.
|
|
115
|
-
if (!goalFinished(goal)) throw new Error('only a finished Goal can be dismissed; stop
|
|
116
|
+
if (!goalFinished(goal)) throw new Error('only a finished or stalled Goal can be dismissed; stop it first');
|
|
116
117
|
if (!goal.archivedAt) {
|
|
117
118
|
goal.archivedAt = at;
|
|
118
119
|
goal.updatedAt = at;
|
|
@@ -129,11 +130,33 @@ export async function runGoalControl(ctx, sessionId, rawArgs = {}) {
|
|
|
129
130
|
else if (rawArgs?.command != null) args = { ...rawArgs, ...parseUserCommand(rawArgs.command) };
|
|
130
131
|
const action = clean(args?.action || 'get').toLowerCase();
|
|
131
132
|
if (action === 'create') {
|
|
133
|
+
const existing = ctx.readRecord(id).goal;
|
|
134
|
+
// Replacing a stalled Goal is the user's call: ask once, and let the same
|
|
135
|
+
// request come back with `replace` once they agree.
|
|
136
|
+
if (goalStalled(existing) && args.replace !== true) {
|
|
137
|
+
return {
|
|
138
|
+
ok: false,
|
|
139
|
+
action,
|
|
140
|
+
code: GOAL_REPLACE_REQUIRED,
|
|
141
|
+
goal: publicGoal(existing, ctx.now()),
|
|
142
|
+
message:
|
|
143
|
+
`A ${existing.status} Goal already exists · ${existing.objective}. ` +
|
|
144
|
+
`Run /goal --replace=${existing.id} followed by the new objective to replace it.`,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
// The confirmation names the Goal the user saw; it runs inside the
|
|
148
|
+
// mutation queue, so a Goal that changed since refuses instead of retiring.
|
|
149
|
+
if (args.replace === true && existing) {
|
|
150
|
+
if (goalStalled(existing) && !clean(args.expectedGoalId)) {
|
|
151
|
+
throw new Error(`a replace must name the stalled Goal to retire (--replace=${existing.id})`);
|
|
152
|
+
}
|
|
153
|
+
if (clean(args.expectedGoalId)) assertExpectedGoal(existing, args.expectedGoalId, 'replace');
|
|
154
|
+
}
|
|
132
155
|
const goal = await ctx.createGoal(id, {
|
|
133
156
|
objective: args.objective,
|
|
134
157
|
duration: args.duration,
|
|
135
158
|
timeLimitMs: args.timeLimitMs,
|
|
136
|
-
|
|
159
|
+
replace: args.replace === true,
|
|
137
160
|
});
|
|
138
161
|
return reply(action, goal, `Goal active · ${goal.objective} · ${goalTimingLabel(goal)}`);
|
|
139
162
|
}
|
|
@@ -153,9 +176,6 @@ export async function runGoalControl(ctx, sessionId, rawArgs = {}) {
|
|
|
153
176
|
const goal = ctx.requireGoal(id);
|
|
154
177
|
const expectedGoalId = clean(args.expectedGoalId);
|
|
155
178
|
assertExpectedGoal(goal, expectedGoalId, 'update');
|
|
156
|
-
if (args.revision != null && args.revision !== goal.revision) {
|
|
157
|
-
throw new Error('Goal changed while editing; reopen the editor before saving');
|
|
158
|
-
}
|
|
159
179
|
const at = ctx.now();
|
|
160
180
|
if (goal.status === 'stopped' && action !== 'dismiss') {
|
|
161
181
|
throw new Error('a stopped Goal cannot be changed; create a new Goal');
|