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
|
@@ -369,12 +369,40 @@ function writeAgentFiles(dir, { name, description, body, extra = {}, manifest =
|
|
|
369
369
|
writeDefinitionText(join(dir, 'AGENT.md'), serializeFrontmatterDoc({ ...meta, ...extra }, body));
|
|
370
370
|
// loadAgentDefinition prefers the manifest for name/description.
|
|
371
371
|
writeManifest(join(dir, 'agent.json'), { ...meta, ...manifest });
|
|
372
|
+
// A stray purge marker goes before the tombstone: a crash between the two
|
|
373
|
+
// must never leave a live definition under a marker.
|
|
374
|
+
rmSync(join(dir, PURGING_MARKER), { force: true });
|
|
372
375
|
rmSync(join(dir, AGENT_DELETED_MARKER), { force: true });
|
|
373
376
|
rmSync(join(dir, ARCHIVED_AGENT_FILE), { force: true });
|
|
374
377
|
}
|
|
375
378
|
|
|
379
|
+
// Per id, the tail of the queue its lifecycle changes (save, archive, restore,
|
|
380
|
+
// purge, recovery) run in, one at a time. One process owns the store, so this
|
|
381
|
+
// is enough; each change rechecks its eligibility when its turn comes.
|
|
382
|
+
const lifecycleTails = new Map();
|
|
383
|
+
function withLifecycle(dataDir, id, run) {
|
|
384
|
+
const key = `${dataDir}\0${id}`;
|
|
385
|
+
const result = (lifecycleTails.get(key) ?? Promise.resolve()).then(run);
|
|
386
|
+
const tail = result.catch(() => {});
|
|
387
|
+
lifecycleTails.set(key, tail);
|
|
388
|
+
tail.then(() => {
|
|
389
|
+
if (lifecycleTails.get(key) === tail) lifecycleTails.delete(key);
|
|
390
|
+
});
|
|
391
|
+
return result;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
// Written before a purge deletes the bot's routines, gone with its folder.
|
|
395
|
+
const PURGING_MARKER = '.purging';
|
|
396
|
+
|
|
376
397
|
const isArchivedAgent = (dataDir, id) => existsSync(join(userDir(dataDir, id), AGENT_DELETED_MARKER));
|
|
377
398
|
|
|
399
|
+
// Whether a purge of `id` is under way or was cut short: its marker with the
|
|
400
|
+
// definition archived or already gone. A marker beside a live definition
|
|
401
|
+
// (AGENT.md in place, no tombstone) proves nothing and is stale.
|
|
402
|
+
const purgePending = (dataDir, id) =>
|
|
403
|
+
existsSync(join(userDir(dataDir, id), PURGING_MARKER)) &&
|
|
404
|
+
(isArchivedAgent(dataDir, id) || !hasUserAgentFile(dataDir, id));
|
|
405
|
+
|
|
378
406
|
// A save's avatar and connectors applied to `manifest` (in place); returns the
|
|
379
407
|
// avatar update (its image writes), null when the save gives no avatar.
|
|
380
408
|
function applyManifestEdits(manifest, payload, dir, options) {
|
|
@@ -673,6 +701,8 @@ function createAgentArchiveApi({
|
|
|
673
701
|
shippedDir,
|
|
674
702
|
announceBotChange,
|
|
675
703
|
getAgentDefinition,
|
|
704
|
+
deleteOwnedRoutines,
|
|
705
|
+
reloadRoutines,
|
|
676
706
|
}) {
|
|
677
707
|
// A removed custom agent must not leave a dangling route/preset or a
|
|
678
708
|
// disabled-roster entry that would silently disable a later agent of the
|
|
@@ -687,7 +717,17 @@ function createAgentArchiveApi({
|
|
|
687
717
|
saveConfigAndAdopt(canonicalizeAgentRouteStorage(nextConfig));
|
|
688
718
|
}
|
|
689
719
|
|
|
690
|
-
|
|
720
|
+
// One id's archive, restore, purge and recovery run one at a time, each
|
|
721
|
+
// checking its eligibility on its turn (withLifecycle).
|
|
722
|
+
const locked = (agentId, run) => {
|
|
723
|
+
const id = agentEditorId(agentId);
|
|
724
|
+
return id ? withLifecycle(dataDirOf(), id, () => run(agentId)) : run(agentId);
|
|
725
|
+
};
|
|
726
|
+
const deleteAgentDefinition = (agentId) => locked(agentId, deleteUnlocked);
|
|
727
|
+
const restoreAgentDefinition = (agentId) => locked(agentId, restoreUnlocked);
|
|
728
|
+
const purgeAgentDefinition = (agentId) => locked(agentId, purgeUnlocked);
|
|
729
|
+
|
|
730
|
+
async function deleteUnlocked(agentId) {
|
|
691
731
|
const id = agentEditorId(agentId);
|
|
692
732
|
if (!id) throw new Error(`unknown agent "${agentId}"`);
|
|
693
733
|
if (isHiddenAgent(id)) throw new Error(`agent "${id}" is internal and cannot be deleted`);
|
|
@@ -714,7 +754,9 @@ function createAgentArchiveApi({
|
|
|
714
754
|
// tombstone keeps the packaged copy of a starter from coming back, and the
|
|
715
755
|
// rest (agent.json: name and face, persona, memory, its model and on/off)
|
|
716
756
|
// stays for its archived chat — until restoreAgentDefinition brings it back
|
|
717
|
-
// or purgeAgentDefinition.
|
|
757
|
+
// or purgeAgentDefinition. Its schedules and webhooks are left exactly as
|
|
758
|
+
// they are: while it is archived they neither fire nor list
|
|
759
|
+
// (routine-owner.mjs), and a restore brings them back as they were.
|
|
718
760
|
// AGENT.md always moves aside; an AGENT.md over an existing archive is
|
|
719
761
|
// refused, since the move would overwrite it. Another selected entry
|
|
720
762
|
// moves too when its own archive is free, and otherwise stays in place
|
|
@@ -726,6 +768,10 @@ function createAgentArchiveApi({
|
|
|
726
768
|
}
|
|
727
769
|
const entry = archivableEntry(dir, entryIn(dir));
|
|
728
770
|
mkdirSync(dir, { recursive: true });
|
|
771
|
+
// A stray purge marker goes before any rename: a crash after one would
|
|
772
|
+
// leave the marker with no AGENT.md and no tombstone, which reads as a
|
|
773
|
+
// purge cut short.
|
|
774
|
+
rmSync(join(dir, PURGING_MARKER), { force: true });
|
|
729
775
|
if (existsSync(agentFile)) renameSync(agentFile, agentArchive);
|
|
730
776
|
if (entry !== agentFile && existsSync(entry) && !existsSync(archivedEntryPath(entry))) {
|
|
731
777
|
renameSync(entry, archivedEntryPath(entry));
|
|
@@ -739,13 +785,18 @@ function createAgentArchiveApi({
|
|
|
739
785
|
|
|
740
786
|
/** An archived agent back as it was, under its own id: its AGENT.md moved
|
|
741
787
|
* back (a starter without a copy of its own returns to the packaged one)
|
|
742
|
-
* and the tombstone gone. Its routines
|
|
743
|
-
|
|
788
|
+
* and the tombstone gone. Its routines, never touched by the archive, list
|
|
789
|
+
* and fire again as they were. */
|
|
790
|
+
async function restoreUnlocked(agentId) {
|
|
744
791
|
const id = agentEditorId(agentId);
|
|
745
792
|
if (!id || isHiddenAgent(id) || isFixedAgent(id)) throw new Error(`unknown agent "${agentId}"`);
|
|
746
793
|
const dataDir = dataDirOf();
|
|
747
794
|
if (!isArchivedAgent(dataDir, id)) throw new Error(`agent "${id}" is not deleted`);
|
|
748
795
|
const dir = userDir(dataDir, id);
|
|
796
|
+
// Its routines may already be gone: only the purge can finish.
|
|
797
|
+
if (existsSync(join(dir, PURGING_MARKER))) {
|
|
798
|
+
throw new Error(`agent "${id}" is being deleted for good and cannot be restored; delete it again to finish`);
|
|
799
|
+
}
|
|
749
800
|
// AGENT.md.archived back to AGENT.md, and the selected entry's archive back
|
|
750
801
|
// to that entry. Nothing is overwritten: an archive whose file exists again
|
|
751
802
|
// stays as it is, and when every kept archive collides the restore is refused.
|
|
@@ -766,18 +817,47 @@ function createAgentArchiveApi({
|
|
|
766
817
|
clearAgentDefinitionCache(id);
|
|
767
818
|
// Back in the roster of the Leads that list it, from their next turn.
|
|
768
819
|
await announceBotChange(dataDir);
|
|
820
|
+
// A one-shot that came due while it was archived was skipped with no
|
|
821
|
+
// timer left: the reload re-arms it (overdue fires at once, as at start).
|
|
822
|
+
// The bot is back by now, so a failed reload is reported as such rather
|
|
823
|
+
// than as a restore that succeeded with its one-shots unarmed.
|
|
824
|
+
try {
|
|
825
|
+
await reloadRoutines();
|
|
826
|
+
} catch (error) {
|
|
827
|
+
throw new Error(
|
|
828
|
+
`agent "${id}" was restored, but its schedules could not be re-armed (${error?.message || error}); ` +
|
|
829
|
+
'they are re-armed by the next schedule reload or restart'
|
|
830
|
+
);
|
|
831
|
+
}
|
|
769
832
|
return getAgentDefinition(id);
|
|
770
833
|
}
|
|
771
834
|
|
|
772
|
-
/** Deleting an archived agent again: everything it left goes for good
|
|
773
|
-
*
|
|
774
|
-
|
|
835
|
+
/** Deleting an archived agent again: everything it left goes for good, its
|
|
836
|
+
* schedules and webhooks first (one statement, all or none): a purge that
|
|
837
|
+
* fails aborts this with the agent still archived and nothing lost, to be
|
|
838
|
+
* retried. A starter keeps only its tombstone, so its packaged copy stays
|
|
839
|
+
* gone. */
|
|
840
|
+
async function purgeUnlocked(agentId) {
|
|
775
841
|
const id = agentEditorId(agentId);
|
|
776
842
|
if (!id || isHiddenAgent(id) || isFixedAgent(id)) throw new Error(`unknown agent "${agentId}"`);
|
|
777
843
|
const dataDir = dataDirOf();
|
|
778
|
-
// Never a live agent; one deleted before archiving existed left nothing.
|
|
779
|
-
if (!isArchivedAgent(dataDir, id)) return { id, purged: false };
|
|
780
844
|
const dir = userDir(dataDir, id);
|
|
845
|
+
// Never a live agent; one deleted before archiving existed left nothing.
|
|
846
|
+
// A marker beside a live definition is only removed.
|
|
847
|
+
if (!purgePending(dataDir, id)) {
|
|
848
|
+
rmSync(join(dir, PURGING_MARKER), { force: true });
|
|
849
|
+
if (!isArchivedAgent(dataDir, id)) return { id, purged: false };
|
|
850
|
+
}
|
|
851
|
+
return purgeFiles(id, dataDir, dir);
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
/** The purge of `id` (archived, or one a crash cut short), routines first. */
|
|
855
|
+
async function purgeFiles(id, dataDir, dir) {
|
|
856
|
+
// Set before the first await and before the routines go: a restore from
|
|
857
|
+
// here on is refused (it checks in the same synchronous stretch), and a
|
|
858
|
+
// crash before the folder is removed is finished by finishUnfinishedPurges.
|
|
859
|
+
writeFileAtomicSync(join(dir, PURGING_MARKER), 'purging\n');
|
|
860
|
+
const routines = await deleteOwnedRoutines(id);
|
|
781
861
|
rmSync(dir, { recursive: true, force: true });
|
|
782
862
|
clearAgentDefinitionCache(id);
|
|
783
863
|
dropAgentRoute(id);
|
|
@@ -786,10 +866,56 @@ function createAgentArchiveApi({
|
|
|
786
866
|
writeFileAtomicSync(join(dir, AGENT_DELETED_MARKER), 'deleted\n');
|
|
787
867
|
clearAgentDefinitionCache(id);
|
|
788
868
|
}
|
|
789
|
-
|
|
869
|
+
// A save that passed its owner check before the bot was archived (an
|
|
870
|
+
// archived owner is refused) can land after the first purge: swept again
|
|
871
|
+
// now that the bot is gone (a later one is refused by the save itself,
|
|
872
|
+
// channel-admin.mjs). A failure here leaves at most such a row, listed as
|
|
873
|
+
// its bot deleted, deletable.
|
|
874
|
+
const late = await deleteOwnedRoutines(id).catch((error) => error);
|
|
875
|
+
const names = (kind) => [...routines[kind], ...(late instanceof Error ? [] : late[kind])];
|
|
876
|
+
const removed = { schedules: names('schedules'), webhooks: names('webhooks') };
|
|
877
|
+
return {
|
|
878
|
+
id,
|
|
879
|
+
purged: true,
|
|
880
|
+
...(removed.schedules.length + removed.webhooks.length > 0 ? { routines: removed } : {}),
|
|
881
|
+
...(late instanceof Error ? { routinesError: late.message } : {}),
|
|
882
|
+
};
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
/** Run at start: every purge that stopped before its folder was removed
|
|
886
|
+
* (its marker is still there) is carried through; the ids finished. */
|
|
887
|
+
async function finishUnfinishedPurges() {
|
|
888
|
+
const dataDir = dataDirOf();
|
|
889
|
+
const ids = [join(dataDir, 'agents'), dirname(botDir(dataDir, '_'))].flatMap((root) =>
|
|
890
|
+
existsSync(root) ? readdirSync(root).filter((name) => existsSync(join(root, name, PURGING_MARKER))) : []
|
|
891
|
+
);
|
|
892
|
+
const finished = [];
|
|
893
|
+
for (const id of ids) if ((await resumePurge(id)).purged) finished.push(id);
|
|
894
|
+
return finished;
|
|
790
895
|
}
|
|
791
896
|
|
|
792
|
-
|
|
897
|
+
/** Resumes only a marked purge that is still pending, checked on the id's
|
|
898
|
+
* turn: a bot archived normally meanwhile (marker gone), made live again,
|
|
899
|
+
* or already purged by another call is not a purge to finish. */
|
|
900
|
+
const resumePurge = (id) =>
|
|
901
|
+
withLifecycle(dataDirOf(), id, async () => {
|
|
902
|
+
const dataDir = dataDirOf();
|
|
903
|
+
const dir = userDir(dataDir, id);
|
|
904
|
+
if (!existsSync(join(dir, PURGING_MARKER))) return { id, purged: false };
|
|
905
|
+
if (!purgePending(dataDir, id)) {
|
|
906
|
+
rmSync(join(dir, PURGING_MARKER), { force: true });
|
|
907
|
+
return { id, purged: false };
|
|
908
|
+
}
|
|
909
|
+
return purgeFiles(id, dataDir, dir);
|
|
910
|
+
});
|
|
911
|
+
|
|
912
|
+
return {
|
|
913
|
+
dropAgentRoute,
|
|
914
|
+
deleteAgentDefinition,
|
|
915
|
+
restoreAgentDefinition,
|
|
916
|
+
purgeAgentDefinition,
|
|
917
|
+
finishUnfinishedPurges,
|
|
918
|
+
};
|
|
793
919
|
}
|
|
794
920
|
|
|
795
921
|
// Agent catalog + editor surface: fixed services stay built-in; starter and
|
|
@@ -897,7 +1023,16 @@ export function createAgentEditorApi(deps) {
|
|
|
897
1023
|
const body = String(payload.body || '').trim();
|
|
898
1024
|
if (!body) throw new Error('AGENT.md body must not be empty');
|
|
899
1025
|
const dataDir = resolveDataDir(deps);
|
|
900
|
-
const
|
|
1026
|
+
const target = resolveSaveTarget(loadAgentDefinition, payload, dataDir);
|
|
1027
|
+
return withLifecycle(dataDir, target.id, () => saveLocked(payload, options, body, dataDir, target));
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
// Runs as the id's turn in its lifecycle queue (withLifecycle): a purge ahead
|
|
1031
|
+
// of it has finished, so the id it frees is reused, and one behind it sees a live bot.
|
|
1032
|
+
async function saveLocked(payload, options, body, dataDir, { id, name, description }) {
|
|
1033
|
+
if (purgePending(dataDir, id)) {
|
|
1034
|
+
throw new Error(`agent "${id}" is being deleted for good; its id cannot be reused until that finishes`);
|
|
1035
|
+
}
|
|
901
1036
|
// Opt-in (the agent profile): without `expectedRevision` the last write
|
|
902
1037
|
// wins, as for the Workflows editor and the setup tool.
|
|
903
1038
|
if (hasOwn(payload, 'expectedRevision') && String(payload.expectedRevision) !== definitionRevision(dataDir, id)) {
|
|
@@ -963,7 +1098,13 @@ export function createAgentEditorApi(deps) {
|
|
|
963
1098
|
return getAgentDefinition(id);
|
|
964
1099
|
}
|
|
965
1100
|
|
|
966
|
-
const {
|
|
1101
|
+
const {
|
|
1102
|
+
dropAgentRoute,
|
|
1103
|
+
deleteAgentDefinition,
|
|
1104
|
+
restoreAgentDefinition,
|
|
1105
|
+
purgeAgentDefinition,
|
|
1106
|
+
finishUnfinishedPurges,
|
|
1107
|
+
} = createAgentArchiveApi(
|
|
967
1108
|
{
|
|
968
1109
|
dataDirOf: () => resolveDataDir(deps),
|
|
969
1110
|
getConfig,
|
|
@@ -972,6 +1113,10 @@ export function createAgentEditorApi(deps) {
|
|
|
972
1113
|
shippedDir,
|
|
973
1114
|
announceBotChange,
|
|
974
1115
|
getAgentDefinition,
|
|
1116
|
+
// The runtime wires the store (boot/apis.mjs); a read-only editor (the
|
|
1117
|
+
// routine owner and delivery probes) never deletes an agent.
|
|
1118
|
+
deleteOwnedRoutines: deps.deleteOwnedRoutines ?? (async () => ({ schedules: [], webhooks: [] })),
|
|
1119
|
+
reloadRoutines: deps.reloadRoutines ?? (() => {}),
|
|
975
1120
|
}
|
|
976
1121
|
);
|
|
977
1122
|
|
|
@@ -1041,17 +1186,30 @@ export function createAgentEditorApi(deps) {
|
|
|
1041
1186
|
}
|
|
1042
1187
|
// Replaces the policy (null removes the field). Every other key — avatar,
|
|
1043
1188
|
// persona, frontmatter — is kept; for Mixy only its agent.json is touched.
|
|
1044
|
-
|
|
1189
|
+
const setAgentConnectorPolicy = (agentId, connectors) => updateAgentConnectorPolicy(agentId, () => connectors);
|
|
1190
|
+
|
|
1191
|
+
// Read-modify-write of the policy as one turn of the id's lifecycle queue,
|
|
1192
|
+
// like every other writer of its definition: `derive(current)` sees the
|
|
1193
|
+
// policy as stored when that turn comes (not as it was when the call was
|
|
1194
|
+
// made) and may throw to refuse (the remote no-widen check); what it returns
|
|
1195
|
+
// is stored. Nothing awaits between `derive` and the write's start.
|
|
1196
|
+
function updateAgentConnectorPolicy(agentId, derive) {
|
|
1045
1197
|
const id = agentEditorId(agentId);
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1198
|
+
if (!id) return Promise.reject(new Error(`unknown agent "${agentId}"`));
|
|
1199
|
+
return withLifecycle(resolveDataDir(deps), id, async () => {
|
|
1200
|
+
const dataDir = resolveDataDir(deps);
|
|
1201
|
+
const next = connectorPolicyInput(derive(getAgentConnectorPolicy(id)));
|
|
1202
|
+
assertManifestWritable(join(id === LEAD_AGENT_ID ? leadDir() : userDir(dataDir, id), 'agent.json'));
|
|
1203
|
+
if (id === LEAD_AGENT_ID) setLeadConnectorPolicy(next);
|
|
1204
|
+
else {
|
|
1205
|
+
const { name, description, body } = loadAgentDefinition(dataDir, id);
|
|
1206
|
+
const payload = { id, name, description, body, connectors: next };
|
|
1207
|
+
const text = String(body || '').trim();
|
|
1208
|
+
if (!text) throw new Error('AGENT.md body must not be empty');
|
|
1209
|
+
await saveLocked(payload, undefined, text, dataDir, resolveSaveTarget(loadAgentDefinition, payload, dataDir));
|
|
1210
|
+
}
|
|
1211
|
+
return getAgentConnectorPolicy(id);
|
|
1212
|
+
});
|
|
1055
1213
|
}
|
|
1056
1214
|
|
|
1057
1215
|
return {
|
|
@@ -1059,6 +1217,7 @@ export function createAgentEditorApi(deps) {
|
|
|
1059
1217
|
migrateBotStore: () => migrateBotStore(deps),
|
|
1060
1218
|
getAgentConnectorPolicy,
|
|
1061
1219
|
setAgentConnectorPolicy,
|
|
1220
|
+
updateAgentConnectorPolicy,
|
|
1062
1221
|
listAgents,
|
|
1063
1222
|
getAgentDefinition,
|
|
1064
1223
|
getAgentAvatarImage,
|
|
@@ -1074,6 +1233,7 @@ export function createAgentEditorApi(deps) {
|
|
|
1074
1233
|
deleteAgentDefinition,
|
|
1075
1234
|
restoreAgentDefinition,
|
|
1076
1235
|
purgeAgentDefinition,
|
|
1236
|
+
finishUnfinishedPurges,
|
|
1077
1237
|
archivedAgentIdentities,
|
|
1078
1238
|
agentDefinitionPresence,
|
|
1079
1239
|
};
|
|
@@ -7,7 +7,6 @@ import { ensureProviderEnabled } from '../../runtime/agent/orchestrator/runtime-
|
|
|
7
7
|
import { resolveRouteContextState, selectionFastCapable } from '../route-state.mjs';
|
|
8
8
|
import {
|
|
9
9
|
canonicalizeAgentRouteStorage,
|
|
10
|
-
EXPLORE_AGENT_ID,
|
|
11
10
|
isAgentDisabled,
|
|
12
11
|
withAgentDisabled,
|
|
13
12
|
} from '../../runtime/shared/agent-route-config.mjs';
|
|
@@ -227,13 +226,7 @@ export function createAgentRouteApi(deps) {
|
|
|
227
226
|
return stayOff ? { ...routeToSave, id, disabled: true } : routeToSave;
|
|
228
227
|
}
|
|
229
228
|
|
|
230
|
-
// Explore's route decides whether the explore tool exists
|
|
231
|
-
//
|
|
232
|
-
|
|
233
|
-
const saved = await setAgentRoute(agentId, next);
|
|
234
|
-
if (agentEditorId(agentId) === EXPLORE_AGENT_ID) await deps.refreshEmptySessionToolPolicy?.();
|
|
235
|
-
return saved;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
return { setAgentRoute: setAgentRouteAndRefresh };
|
|
229
|
+
// Explore's route decides whether the explore tool exists; sessions take a
|
|
230
|
+
// change of it at their next turn start (reconcileTurnSettings).
|
|
231
|
+
return { setAgentRoute };
|
|
239
232
|
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { existsSync, mkdirSync, rmSync } from 'node:fs';
|
|
3
|
+
import { dirname, join } from 'node:path';
|
|
4
|
+
import { writeFileAtomicSync } from '../../runtime/shared/atomic-file.mjs';
|
|
5
|
+
import { normalizeText } from '../../runtime/shared/shipped-definitions.mjs';
|
|
6
|
+
import { decodeInstructionFile, INSTRUCTION_FILE_MAX_BYTES } from '../../lib/instruction-text.cjs';
|
|
7
|
+
import { outputStyleMetaFromMarkdown } from '../../lib/output-style-meta.cjs';
|
|
8
|
+
import {
|
|
9
|
+
readInstructionFile,
|
|
10
|
+
shippedOrchestrationPath,
|
|
11
|
+
userOrchestrationPath,
|
|
12
|
+
} from '../../runtime/agent/orchestrator/runtime-core/orchestration.mjs';
|
|
13
|
+
import { ORCHESTRATION_MODES } from '../../runtime/shared/orchestration.mjs';
|
|
14
|
+
import { publishAgentProfileChange } from '../agent-profile-changes.mjs';
|
|
15
|
+
import { STANDALONE_ROOT } from '../runtime-paths.mjs';
|
|
16
|
+
import { resolveDataDir } from './shared.mjs';
|
|
17
|
+
|
|
18
|
+
// The editable instruction texts: the four orchestration modes (delegation)
|
|
19
|
+
// and the four output-style depth levels. Each has a shipped .md file and a
|
|
20
|
+
// same-name user file in the data dir that replaces it; the set is fixed.
|
|
21
|
+
export const INSTRUCTION_FILE_CONFLICT = 'INSTRUCTION_FILE_CONFLICT';
|
|
22
|
+
|
|
23
|
+
const MODE_LABELS = { none: 'Solo', focused: 'Focused', balanced: 'Balanced', swarm: 'Swarm' };
|
|
24
|
+
const STYLES = [
|
|
25
|
+
['detailed', 'Detailed'],
|
|
26
|
+
['simple', 'Simple'],
|
|
27
|
+
['minimal', 'Minimal'],
|
|
28
|
+
['extreme-minimal', 'Extreme Minimal'],
|
|
29
|
+
];
|
|
30
|
+
const INSTRUCTION_GROUPS = Object.freeze(['delegation', 'outputStyle']);
|
|
31
|
+
|
|
32
|
+
const FRONTMATTER = /^---[ \t]*\r?\n[\s\S]*?\r?\n---[ \t]*(?:\r?\n|$)/;
|
|
33
|
+
const bodyOfStyle = (text) =>
|
|
34
|
+
String(text || '')
|
|
35
|
+
.replace(FRONTMATTER, '')
|
|
36
|
+
.trim();
|
|
37
|
+
const hashOf = (text) => createHash('sha256').update(String(text)).digest('hex').slice(0, 24);
|
|
38
|
+
|
|
39
|
+
// One item's files and the text <-> file mapping. The style editor shows and
|
|
40
|
+
// saves the file's body only: the shipped front matter (name, title,
|
|
41
|
+
// description) is kept, and common.md is not part of it.
|
|
42
|
+
function itemFor(group, id, deps) {
|
|
43
|
+
if (group === 'delegation') {
|
|
44
|
+
if (!ORCHESTRATION_MODES.includes(id))
|
|
45
|
+
throw new Error(`orchestration mode must be one of ${ORCHESTRATION_MODES.join(', ')}`);
|
|
46
|
+
return {
|
|
47
|
+
group,
|
|
48
|
+
id,
|
|
49
|
+
label: MODE_LABELS[id],
|
|
50
|
+
shipped: shippedOrchestrationPath(id),
|
|
51
|
+
user: userOrchestrationPath(id),
|
|
52
|
+
body: (text) => text,
|
|
53
|
+
file: (body) => `${body}\n`,
|
|
54
|
+
accepts: () => true,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
if (group === 'outputStyle') {
|
|
58
|
+
const style = STYLES.find(([styleId]) => styleId === id);
|
|
59
|
+
if (!style) throw new Error(`output style must be one of ${STYLES.map(([styleId]) => styleId).join(', ')}`);
|
|
60
|
+
const shipped = join(deps.rootDir ?? STANDALONE_ROOT, 'output-styles', `${id}.md`);
|
|
61
|
+
return {
|
|
62
|
+
group,
|
|
63
|
+
id,
|
|
64
|
+
label: style[1],
|
|
65
|
+
shipped,
|
|
66
|
+
user: join(resolveDataDir(deps), 'output-styles', `${id}.md`),
|
|
67
|
+
body: bodyOfStyle,
|
|
68
|
+
file: (body, shippedText) => `${(FRONTMATTER.exec(shippedText) || [''])[0].trimEnd()}\n\n${body}\n`,
|
|
69
|
+
// A file whose front matter names another style defines that one instead
|
|
70
|
+
// (the prompt builder registers it by name): it does not replace this one.
|
|
71
|
+
accepts: (text) => outputStyleMetaFromMarkdown(text, `${id}.md`)?.id === id,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
throw new Error(`instruction group must be one of ${INSTRUCTION_GROUPS.join(', ')}`);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function createInstructionFilesApi(deps) {
|
|
78
|
+
function stateOf(item) {
|
|
79
|
+
const shipped = readInstructionFile(item.shipped);
|
|
80
|
+
const defaultBody = item.body(shipped?.text ?? '');
|
|
81
|
+
const user = readInstructionFile(item.user);
|
|
82
|
+
const accepted = Boolean(user?.text) && item.accepts(user.text);
|
|
83
|
+
const userBody = accepted ? item.body(user.text) : '';
|
|
84
|
+
// An existing user file that cannot serve (empty, too large, not text, a
|
|
85
|
+
// style under another name) is passed over by the prompt builders: the
|
|
86
|
+
// built-in applies.
|
|
87
|
+
const usable = Boolean(userBody);
|
|
88
|
+
const problem = user && !usable ? (user.problem ?? (accepted ? 'empty' : 'invalid')) : undefined;
|
|
89
|
+
const body = usable ? userBody : defaultBody;
|
|
90
|
+
return {
|
|
91
|
+
group: item.group,
|
|
92
|
+
id: item.id,
|
|
93
|
+
label: item.label,
|
|
94
|
+
body,
|
|
95
|
+
defaultBody,
|
|
96
|
+
userOverride: Boolean(user),
|
|
97
|
+
modified: usable && normalizeText(userBody) !== normalizeText(defaultBody),
|
|
98
|
+
...(problem ? { problem } : {}),
|
|
99
|
+
...(user ? { path: item.user } : {}),
|
|
100
|
+
revision: hashOf(`${usable ? 'user' : 'default'}\0${problem ?? ''}\0${body}`),
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// A write or reset made against a state that has moved on is refused.
|
|
105
|
+
function assertCurrent(payloadRevision, before, item) {
|
|
106
|
+
if (payloadRevision === undefined || String(payloadRevision) === before.revision) return;
|
|
107
|
+
const conflict = new Error(`${INSTRUCTION_FILE_CONFLICT}: "${item.id}" changed since it was loaded`);
|
|
108
|
+
conflict.code = INSTRUCTION_FILE_CONFLICT;
|
|
109
|
+
throw conflict;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const get = (group, id) => stateOf(itemFor(group, id, deps));
|
|
113
|
+
|
|
114
|
+
function list() {
|
|
115
|
+
return [...ORCHESTRATION_MODES.map((id) => get('delegation', id)), ...STYLES.map(([id]) => get('outputStyle', id))];
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
async function announce() {
|
|
119
|
+
deps.invalidateContextStatusCache?.();
|
|
120
|
+
await publishAgentProfileChange();
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
async function save(payload = {}) {
|
|
124
|
+
const item = itemFor(payload.group, payload.id, deps);
|
|
125
|
+
const body = String(payload.body ?? '')
|
|
126
|
+
.replace(/\r\n/g, '\n')
|
|
127
|
+
.trim();
|
|
128
|
+
if (!body) throw new Error('instruction text must not be empty');
|
|
129
|
+
if (body.includes('\0')) throw new Error('instruction text must be plain text');
|
|
130
|
+
const before = stateOf(item);
|
|
131
|
+
assertCurrent(payload.expectedRevision, before, item);
|
|
132
|
+
if (normalizeText(body) === normalizeText(before.defaultBody)) {
|
|
133
|
+
// Equal to the shipped text: keep no copy, so it follows the shipped version.
|
|
134
|
+
rmSync(item.user, { force: true });
|
|
135
|
+
} else {
|
|
136
|
+
// The bytes that reach the disk — front matter and newline included —
|
|
137
|
+
// must pass the reader's check, or the saved file would be ignored.
|
|
138
|
+
const bytes = Buffer.from(item.file(body, readInstructionFile(item.shipped)?.text ?? ''));
|
|
139
|
+
if (bytes.length > INSTRUCTION_FILE_MAX_BYTES) throw new Error('instruction text is larger than 256 KB');
|
|
140
|
+
const problem = decodeInstructionFile(bytes).problem;
|
|
141
|
+
if (problem) throw new Error(`instruction text cannot be saved (${problem})`);
|
|
142
|
+
mkdirSync(dirname(item.user), { recursive: true });
|
|
143
|
+
writeFileAtomicSync(item.user, bytes, { backup: true, mode: 0o644 });
|
|
144
|
+
}
|
|
145
|
+
await announce();
|
|
146
|
+
return stateOf(item);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
async function reset(group, id, expectedRevision) {
|
|
150
|
+
const item = itemFor(group, id, deps);
|
|
151
|
+
if (!existsSync(item.user)) throw new Error(`"${item.id}" has no user override to reset`);
|
|
152
|
+
assertCurrent(expectedRevision, stateOf(item), item);
|
|
153
|
+
rmSync(item.user, { force: true });
|
|
154
|
+
rmSync(`${item.user}.bak`, { force: true });
|
|
155
|
+
await announce();
|
|
156
|
+
return stateOf(item);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return {
|
|
160
|
+
listInstructionFiles: list,
|
|
161
|
+
getInstructionFile: get,
|
|
162
|
+
saveInstructionFile: save,
|
|
163
|
+
resetInstructionFile: reset,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
@@ -30,7 +30,9 @@ export function createStyleAndModeApi(deps) {
|
|
|
30
30
|
scheduleOutputStyleSave(selected.id);
|
|
31
31
|
const freshStatus = { configured: selected.id, current: selected, styles: before.styles };
|
|
32
32
|
seedOutputStyleStatusCache(freshStatus);
|
|
33
|
-
|
|
33
|
+
// An empty session is rebuilt at its next turn start; a conversation is
|
|
34
|
+
// told then and folds the style in at its next cold point.
|
|
35
|
+
const appliedToCurrentSession = deps.settingsReachCurrentSession?.() ?? !getSession()?.id;
|
|
34
36
|
invalidateContextStatusCache();
|
|
35
37
|
return { ...freshStatus, appliedToCurrentSession };
|
|
36
38
|
}
|
|
@@ -53,10 +55,9 @@ export function createStyleAndModeApi(deps) {
|
|
|
53
55
|
}
|
|
54
56
|
}
|
|
55
57
|
saveConfigAndAdopt({ ...getConfig(), orchestrationMode: mode });
|
|
56
|
-
|
|
57
|
-
deps.invalidatePreSessionToolSurface?.();
|
|
58
|
+
// An empty session takes it at its next turn start (reconcileTurnSettings).
|
|
58
59
|
invalidateContextStatusCache();
|
|
59
|
-
return { mode, appliedToCurrentSession:
|
|
60
|
+
return { mode, appliedToCurrentSession: deps.settingsReachCurrentSession?.() !== false };
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
return {
|
|
@@ -66,9 +66,8 @@ export function createWorkflowPacksApi(deps) {
|
|
|
66
66
|
if (switched) return { ...switched.workflow, ...switched };
|
|
67
67
|
}
|
|
68
68
|
saveActiveWorkflow(id);
|
|
69
|
-
|
|
70
|
-
deps.
|
|
71
|
-
return { ...workflowSummary(pack), appliedToCurrentSession: applied?.appliedToCurrentSession !== false };
|
|
69
|
+
// An empty session takes it at its next turn start (reconcileTurnSettings).
|
|
70
|
+
return { ...workflowSummary(pack), appliedToCurrentSession: deps.settingsReachCurrentSession?.() !== false };
|
|
72
71
|
}
|
|
73
72
|
|
|
74
73
|
function getWorkflowPack(workflowId) {
|
|
@@ -4,6 +4,7 @@ import { createAgentConnectorsApi } from './workflow-agents-api/agent-connectors
|
|
|
4
4
|
import { createAgentRouteApi } from './workflow-agents-api/agent-route.mjs';
|
|
5
5
|
import { createWorkflowPacksApi } from './workflow-agents-api/workflow-packs.mjs';
|
|
6
6
|
import { createStyleAndModeApi } from './workflow-agents-api/style-and-mode.mjs';
|
|
7
|
+
import { createInstructionFilesApi } from './workflow-agents-api/instruction-files.mjs';
|
|
7
8
|
|
|
8
9
|
// Onboarding + agents/workflows/output-style selection surface. Stateless
|
|
9
10
|
// helpers are imported by the phase modules under workflow-agents-api/; the
|
|
@@ -20,5 +21,6 @@ export function createWorkflowAgentsApi(deps) {
|
|
|
20
21
|
...routeApi,
|
|
21
22
|
...createWorkflowPacksApi(deps),
|
|
22
23
|
...createStyleAndModeApi(deps),
|
|
24
|
+
...createInstructionFilesApi(deps),
|
|
23
25
|
};
|
|
24
26
|
}
|
|
@@ -52,7 +52,7 @@ export function createProjectBranchOps({
|
|
|
52
52
|
return {
|
|
53
53
|
// Detached: branch null and the checked-out commit in baseCommit.
|
|
54
54
|
workspace: project.currentBranch ? workspace : { ...workspace, baseCommit: project.headCommit ?? null },
|
|
55
|
-
branches: branchMenuEntries(menu.branches, menu.occupancy),
|
|
55
|
+
branches: branchMenuEntries(menu.branches, menu.occupancy, menu.committedAt),
|
|
56
56
|
occupancy: menu.occupancy,
|
|
57
57
|
retainedWorktree: null,
|
|
58
58
|
};
|
|
@@ -130,7 +130,7 @@ export function createSessionWorkspaceView({
|
|
|
130
130
|
return {
|
|
131
131
|
workspace: view,
|
|
132
132
|
pendingWorktree: pendingWorktree(),
|
|
133
|
-
branches: branchMenuEntries(menu.branches, menu.occupancy),
|
|
133
|
+
branches: branchMenuEntries(menu.branches, menu.occupancy, menu.committedAt),
|
|
134
134
|
occupancy: menu.occupancy,
|
|
135
135
|
retainedWorktree: selectedEntry ?? menu.retainedWorktree ?? null,
|
|
136
136
|
// Creation notes of the retained worktree (submodules, include entries).
|
|
@@ -62,12 +62,18 @@ async function defaultRegisteredProject(path) {
|
|
|
62
62
|
* `move` ({ from, changes }: the session left the project folder `from` for
|
|
63
63
|
* a worktree) adds the uncommitted-changes and path lines to that notice.
|
|
64
64
|
*/
|
|
65
|
-
export async function refreshWorkspacePrompt(
|
|
65
|
+
export async function refreshWorkspacePrompt(
|
|
66
|
+
session,
|
|
67
|
+
cwd,
|
|
68
|
+
{ loadCoreMemoryContext, move = null, instructionFilesMode } = {}
|
|
69
|
+
) {
|
|
66
70
|
// A new checkout invalidates observed-file snapshots as well as read/search
|
|
67
71
|
// results. Conversation text remains historical evidence, not a file cache.
|
|
68
72
|
clearReadDedupSession(session?.id);
|
|
69
73
|
resetReadStateAfterCompaction(session?.id);
|
|
70
|
-
const { environmentContext, instructionFilesContext } = buildWorkspacePromptContext(session, cwd
|
|
74
|
+
const { environmentContext, instructionFilesContext } = buildWorkspacePromptContext(session, cwd, {
|
|
75
|
+
instructionFilesMode,
|
|
76
|
+
});
|
|
71
77
|
const coreMemoryContext =
|
|
72
78
|
session?.owner === AGENT_OWNER || typeof loadCoreMemoryContext !== 'function'
|
|
73
79
|
? undefined
|
|
@@ -94,8 +100,13 @@ export function publicWorkspaceMethods(api) {
|
|
|
94
100
|
requestWorktree: (input) => api.requestWorktree(input),
|
|
95
101
|
mergeWorkspace: (input) => api.mergeWorkspace(input),
|
|
96
102
|
removeWorktree: (input) => api.removeWorktree(input),
|
|
97
|
-
|
|
98
|
-
|
|
103
|
+
// External callers get the list with its details (Settings → Worktrees).
|
|
104
|
+
listWorktrees: () => api.listWorktrees({ details: true }),
|
|
105
|
+
pruneWorktrees: (input) => api.pruneWorktrees({ repoCommonDir: input?.repoCommonDir ?? null }),
|
|
106
|
+
previewWorktreeCleanup: (input) => api.previewWorktreeCleanup({ repoCommonDir: input?.repoCommonDir ?? null }),
|
|
107
|
+
deleteWorktree: (input) => api.deleteWorktree(input),
|
|
108
|
+
getSessionWorktreeWork: (input) => api.getSessionWorktreeWork(input),
|
|
109
|
+
setArchivedSessionWorktrees: (input) => api.setArchivedSessionWorktrees(input),
|
|
99
110
|
};
|
|
100
111
|
}
|
|
101
112
|
|
|
@@ -285,7 +296,12 @@ export function createWorkspaceTransitions({
|
|
|
285
296
|
switchProject: runner.switchProject,
|
|
286
297
|
listWorktrees: worktrees.listWorktrees,
|
|
287
298
|
pruneWorktrees: worktrees.pruneWorktrees,
|
|
299
|
+
previewWorktreeCleanup: worktrees.previewWorktreeCleanup,
|
|
300
|
+
deleteWorktree: worktrees.deleteWorktree,
|
|
288
301
|
removeOrphanWorktree: worktrees.removeOrphanWorktree,
|
|
302
|
+
removeOwnedWorktree: worktrees.removeOwnedWorktree,
|
|
303
|
+
getSessionWorktreeWork: worktrees.getSessionWorktreeWork,
|
|
304
|
+
setArchivedSessionWorktrees: worktrees.setArchivedSessionWorktrees,
|
|
289
305
|
cleanupDeletedSession: worktrees.cleanupDeletedSession,
|
|
290
306
|
onWorktreeSetup: setup.onWorktreeSetup,
|
|
291
307
|
dispose: checkouts.dispose,
|