mixdog 1.4.3 → 1.4.5
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 +1 -2
- package/src/cli.mjs +5 -1
- package/src/defaults/shipped-history.json +30 -2
- package/src/defaults/skills/browser-use/SKILL.md +148 -273
- package/src/defaults/skills/browser-use/references/devtools.md +14 -0
- package/src/defaults/skills/browser-use/references/page-flows.md +66 -0
- package/src/defaults/skills/browser-use/references/sign-in.md +70 -0
- package/src/defaults/skills/code-tidy/SKILL.md +60 -84
- package/src/defaults/skills/code-tidy/references/agent-cleanup.md +27 -2
- package/src/defaults/skills/computer-use/SKILL.md +145 -229
- package/src/defaults/skills/computer-use/references/flows.md +35 -0
- package/src/defaults/skills/computer-use/references/operations.md +22 -0
- package/src/defaults/skills/computer-use/references/platforms.md +12 -0
- package/src/defaults/skills/docx/SKILL.md +23 -31
- package/src/defaults/skills/docx/references/native-authoring.md +26 -3
- package/src/defaults/skills/docx/references/redlining.md +15 -0
- package/src/defaults/skills/image/SKILL.md +37 -77
- package/src/defaults/skills/image/references/prompt-forms.md +51 -0
- package/src/defaults/skills/image/references/text.md +6 -0
- package/src/defaults/skills/local-provider/SKILL.md +75 -105
- package/src/defaults/skills/local-provider/references/lifecycle.md +14 -0
- package/src/defaults/skills/local-provider/references/maintenance.md +19 -0
- package/src/defaults/skills/local-provider/references/recovery.md +30 -0
- package/src/defaults/skills/memory-management/SKILL.md +22 -21
- package/src/defaults/skills/pdf/SKILL.md +21 -23
- package/src/defaults/skills/pdf/references/blocks.md +20 -0
- package/src/defaults/skills/pdf/references/forms.md +12 -0
- package/src/defaults/skills/pdf/references/html.md +2 -2
- package/src/defaults/skills/pdf/references/ocr.md +7 -0
- package/src/defaults/skills/pdf/references/security.md +8 -0
- package/src/defaults/skills/pptx/SKILL.md +30 -109
- package/src/defaults/skills/pptx/references/audit.md +45 -0
- package/src/defaults/skills/pptx/references/brief-critique.md +47 -0
- package/src/defaults/skills/pptx/references/editing.md +24 -0
- package/src/defaults/skills/pptx/references/html.md +1 -1
- package/src/defaults/skills/pptx/references/script.md +33 -0
- package/src/defaults/skills/setup/SKILL.md +34 -102
- package/src/defaults/skills/setup/references/actions.md +73 -14
- package/src/defaults/skills/setup/references/surfaces.md +23 -8
- package/src/defaults/skills/setup-guide/SKILL.md +28 -115
- package/src/defaults/skills/setup-guide/references/features.md +36 -0
- package/src/defaults/skills/setup-guide/references/glossary.md +38 -0
- package/src/defaults/skills/setup-guide/references/workflow-models.md +62 -0
- package/src/defaults/skills/test-suite/SKILL.md +15 -127
- package/src/defaults/skills/test-suite/references/case-management.md +17 -9
- package/src/defaults/skills/test-suite/references/diagnose.md +23 -0
- package/src/defaults/skills/test-suite/references/prune.md +27 -0
- package/src/defaults/skills/test-suite/references/write.md +44 -0
- package/src/defaults/skills/video/SKILL.md +28 -42
- package/src/defaults/skills/video/references/prompting.md +31 -0
- package/src/defaults/skills/visualize/SKILL.md +73 -107
- package/src/defaults/skills/visualize/references/craft.md +1 -2
- package/src/defaults/skills/visualize/references/feedback.md +36 -0
- package/src/defaults/skills/visualize/references/showing.md +13 -0
- package/src/defaults/skills/xlsx/SKILL.md +23 -50
- package/src/defaults/skills/xlsx/references/editing.md +15 -0
- package/src/defaults/skills/xlsx/references/model-conventions.md +1 -1
- package/src/defaults/skills/xlsx/references/recalculation.md +37 -0
- package/src/defaults/skills/xlsx/references/report-design.md +18 -2
- package/src/lib/keychain-cjs.cjs +22 -1
- package/src/lib/rules-builder.cjs +1 -1
- package/src/rules/agent/AGENT.md +3 -0
- package/src/rules/agent-mode/MIXY.md +5 -3
- package/src/rules/lead/LEAD.md +3 -1
- package/src/runtime/agent/orchestrator/agent-runtime/cache-strategy.mjs +8 -30
- package/src/runtime/agent/orchestrator/agent-runtime/title-completion.mjs +5 -0
- package/src/runtime/agent/orchestrator/mcp/oauth-request.mjs +21 -2
- package/src/runtime/agent/orchestrator/providers/account-pool.mjs +3 -0
- package/src/runtime/agent/orchestrator/providers/admission-scheduler.mjs +4 -3
- package/src/runtime/agent/orchestrator/providers/anthropic-api-request.mjs +11 -1
- package/src/runtime/agent/orchestrator/providers/anthropic-api-transport.mjs +2 -0
- package/src/runtime/agent/orchestrator/providers/anthropic-message-threads.mjs +583 -0
- package/src/runtime/agent/orchestrator/providers/anthropic-oauth-client-version.mjs +1 -1
- package/src/runtime/agent/orchestrator/providers/anthropic-oauth.mjs +81 -19
- 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-outcome.mjs +2 -0
- package/src/runtime/agent/orchestrator/providers/anthropic-sse.mjs +180 -13
- package/src/runtime/agent/orchestrator/providers/anthropic-turn-result.mjs +2 -0
- package/src/runtime/agent/orchestrator/providers/anthropic.mjs +58 -6
- package/src/runtime/agent/orchestrator/providers/cursor-wire.mjs +4 -2
- 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-error-contract.mjs +6 -6
- package/src/runtime/agent/orchestrator/providers/gemini-model-redirect.mjs +44 -0
- package/src/runtime/agent/orchestrator/providers/gemini-reasoning-relay.mjs +5 -0
- package/src/runtime/agent/orchestrator/providers/gemini-request-body.mjs +34 -5
- package/src/runtime/agent/orchestrator/providers/gemini-response.mjs +10 -0
- package/src/runtime/agent/orchestrator/providers/gemini-schema.mjs +11 -6
- package/src/runtime/agent/orchestrator/providers/gemini-sdk-request.mjs +4 -100
- package/src/runtime/agent/orchestrator/providers/gemini-stream.mjs +3 -227
- package/src/runtime/agent/orchestrator/providers/gemini.mjs +226 -118
- package/src/runtime/agent/orchestrator/providers/lib/anthropic-request-utils.mjs +11 -1
- package/src/runtime/agent/orchestrator/providers/lib/claude-bridge-schema.mjs +15 -3
- package/src/runtime/agent/orchestrator/providers/lib/gemini-model-catalog.mjs +2 -1
- 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 +2 -0
- package/src/runtime/agent/orchestrator/providers/openai-compat-responses.mjs +10 -1
- package/src/runtime/agent/orchestrator/providers/openai-direct-request.mjs +5 -28
- 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-ws-pool.mjs +50 -28
- package/src/runtime/agent/orchestrator/providers/openai-ws-response-state.mjs +9 -2
- package/src/runtime/agent/orchestrator/providers/openai-ws-stream/socket-handlers.mjs +14 -10
- package/src/runtime/agent/orchestrator/providers/openai-ws.mjs +1 -3
- 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/stream-json-pool/worker-slots/slot-spawn.mjs +8 -3
- package/src/runtime/agent/orchestrator/providers/vertex-ai-maas.mjs +2 -2
- package/src/runtime/agent/orchestrator/runtime-core/ask-user-result.mjs +66 -0
- package/src/runtime/agent/orchestrator/runtime-core/config-helpers.mjs +4 -5
- package/src/runtime/agent/orchestrator/runtime-core/goal-tool-defs.mjs +2 -2
- package/src/runtime/agent/orchestrator/runtime-core/provider-request-tools.mjs +15 -8
- package/src/runtime/agent/orchestrator/runtime-core/session-title.mjs +1 -0
- package/src/runtime/agent/orchestrator/runtime-core/todo-list.mjs +9 -32
- package/src/runtime/agent/orchestrator/runtime-core/todo-tool-defs.mjs +4 -5
- package/src/runtime/agent/orchestrator/session/compact/summary-route.mjs +1 -3
- package/src/runtime/agent/orchestrator/session/loop/compact-policy.mjs +5 -2
- package/src/runtime/agent/orchestrator/session/loop/no-tool-turn/todo-check.mjs +2 -17
- package/src/runtime/agent/orchestrator/session/loop/usage.mjs +7 -3
- package/src/runtime/agent/orchestrator/session/manager/ask-turn-settle.mjs +9 -2
- package/src/runtime/agent/orchestrator/session/manager/runtime-liveness.mjs +8 -1
- package/src/runtime/agent/orchestrator/session/manager/session-close.mjs +26 -13
- package/src/runtime/agent/orchestrator/session/manager/session-lifecycle.mjs +4 -5
- package/src/runtime/agent/orchestrator/session/manager/usage-metrics.mjs +16 -5
- package/src/runtime/agent/orchestrator/session/store/lifecycle-barriers.mjs +22 -1
- package/src/runtime/agent/orchestrator/session/store/live-state.mjs +4 -0
- package/src/runtime/agent/orchestrator/session/store.mjs +12 -6
- package/src/runtime/agent/orchestrator/tools/builtin/cache-layers.mjs +11 -9
- package/src/runtime/agent/orchestrator/tools/builtin/grep-formatting.mjs +2 -8
- package/src/runtime/agent/orchestrator/tools/builtin/lib/search-input-helpers.mjs +1 -9
- 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/local-search-telemetry.mjs +2 -2
- package/src/runtime/agent/orchestrator/tools/builtin/native-search-client.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/builtin/runtime-capabilities.mjs +12 -3
- package/src/runtime/agent/orchestrator/tools/builtin/task-tool.mjs +12 -1
- package/src/runtime/agent/orchestrator/tools/code-graph/ast-calls.mjs +9 -2
- package/src/runtime/agent/orchestrator/tools/code-graph/build.mjs +137 -7
- package/src/runtime/agent/orchestrator/tools/code-graph/calls-cache.mjs +43 -14
- package/src/runtime/agent/orchestrator/tools/code-graph/calls-sidecar-worker.mjs +33 -0
- package/src/runtime/agent/orchestrator/tools/code-graph/disk-cache.mjs +146 -11
- package/src/runtime/agent/orchestrator/tools/code-graph/dispatch.mjs +31 -24
- package/src/runtime/agent/orchestrator/tools/code-graph/graph-binary/spawn-jsonl.mjs +172 -25
- package/src/runtime/agent/orchestrator/tools/code-graph/graph-model.mjs +100 -2
- package/src/runtime/agent/orchestrator/tools/code-graph/main-thread-slice.mjs +18 -0
- package/src/runtime/agent/orchestrator/tools/code-graph/mask-pool.mjs +219 -0
- package/src/runtime/agent/orchestrator/tools/code-graph/mask-worker.mjs +12 -0
- package/src/runtime/agent/orchestrator/tools/code-graph/memory-cache.mjs +6 -1
- package/src/runtime/agent/orchestrator/tools/code-graph/modes/calls.mjs +9 -2
- package/src/runtime/agent/orchestrator/tools/code-graph/modes/dependents.mjs +5 -1
- package/src/runtime/agent/orchestrator/tools/code-graph/modes/structure.mjs +8 -2
- package/src/runtime/agent/orchestrator/tools/code-graph/modes/symbols.mjs +14 -11
- package/src/runtime/agent/orchestrator/tools/code-graph/search-references.mjs +41 -18
- package/src/runtime/agent/orchestrator/tools/code-graph/search.mjs +391 -83
- package/src/runtime/agent/orchestrator/tools/code-graph/symbol-index.mjs +109 -9
- package/src/runtime/agent/orchestrator/tools/code-graph/text-mask.mjs +73 -29
- package/src/runtime/agent/orchestrator/tools/code-graph-prewarm-worker.mjs +6 -5
- package/src/runtime/agent/orchestrator/tools/lib/native-spawn-client.mjs +7 -3
- package/src/runtime/channels/lib/crash-log.mjs +21 -1
- package/src/runtime/channels/lib/routines-db.mjs +35 -0
- package/src/runtime/channels/lib/schedules-db.mjs +4 -0
- package/src/runtime/channels/lib/webhooks-db.mjs +4 -0
- package/src/runtime/channels/lib/worker-main.mjs +8 -25
- 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/result-canonical.mjs +6 -0
- package/src/runtime/media/jobs.mjs +5 -0
- package/src/runtime/media/store.mjs +146 -3
- package/src/runtime/memory/tool-defs.mjs +1 -1
- package/src/runtime/office/core/office-write-ledger.mjs +2 -2
- package/src/runtime/shared/agent-reap-state.mjs +19 -0
- package/src/runtime/shared/desktop-notice-host.d.mts +13 -0
- package/src/runtime/shared/desktop-notice-host.mjs +87 -0
- package/src/runtime/shared/file-lock.mjs +2 -2
- package/src/runtime/shared/heap-cap.mjs +9 -11
- package/src/runtime/shared/llm/http-agent.mjs +11 -1
- package/src/runtime/shared/llm/system-proxy.mjs +100 -25
- package/src/runtime/shared/llm/usage-accounting.mjs +121 -19
- package/src/runtime/shared/llm/usage-context.mjs +3 -3
- package/src/runtime/shared/llm/usage-ledger-quota.mjs +2 -0
- package/src/runtime/shared/llm/usage-ledger-requests.mjs +190 -0
- package/src/runtime/shared/llm/usage-ledger-rollup.mjs +7 -3
- package/src/runtime/shared/llm/usage-ledger-worker.mjs +2 -0
- package/src/runtime/shared/llm/usage-ledger.mjs +69 -1
- package/src/runtime/shared/llm/usage-request-status.mjs +48 -0
- package/src/runtime/shared/provider-accounts.mjs +22 -0
- package/src/runtime/shared/provider-auth-binding.mjs +2 -2
- package/src/runtime/shared/resource-admission.mjs +2 -2
- package/src/runtime/shared/root-async-context.mjs +51 -0
- package/src/runtime/shared/run-child.mjs +18 -1
- package/src/runtime/shared/slow-span.mjs +2 -2
- package/src/runtime/shared/tool-execution-owner.mjs +2 -2
- package/src/runtime/shared/tool-result-summary.mjs +1 -1
- package/src/runtime/shared/tool-work-units.mjs +2 -0
- package/src/runtime/shared/turn-snapshot-store.mjs +75 -18
- package/src/runtime/shared/turn-worktree-snapshot.mjs +38 -8
- package/src/runtime/shared/user-cwd.mjs +2 -2
- package/src/runtime/shared/worker-requests.mjs +3 -1
- package/src/runtime/shared/worktrees/lock.mjs +2 -2
- package/src/runtime/visualize-bridge/client.mjs +26 -4
- package/src/runtime/visualize-bridge/tool-defs.mjs +46 -5
- package/src/session-runtime/agent-home-delivery.mjs +76 -8
- package/src/session-runtime/agent-task-sessions.mjs +63 -22
- package/src/session-runtime/boot/apis.mjs +16 -0
- package/src/session-runtime/boot/begin.mjs +2 -0
- package/src/session-runtime/boot/tools.mjs +8 -2
- package/src/session-runtime/internal-tool-executor/ask-user-tool.mjs +3 -58
- package/src/session-runtime/media-api.mjs +15 -0
- package/src/session-runtime/model-route/route-persist.mjs +12 -4
- package/src/session-runtime/provider-models/row-hydration.mjs +2 -0
- package/src/session-runtime/provider-readiness.mjs +10 -2
- package/src/session-runtime/routine-owner.mjs +9 -3
- package/src/session-runtime/runtime-core.mjs +35 -8
- package/src/session-runtime/runtime-review-api.mjs +3 -1
- package/src/session-runtime/services/agent-task-status.mjs +29 -1
- package/src/session-runtime/services/agent-tool/close-flow.mjs +6 -1
- package/src/session-runtime/services/agent-tool/execute-resume.mjs +94 -0
- package/src/session-runtime/services/agent-tool/execute-send.mjs +77 -27
- package/src/session-runtime/services/agent-tool/execute-spawn.mjs +28 -7
- package/src/session-runtime/services/agent-tool/execute.mjs +6 -1
- package/src/session-runtime/services/agent-tool/helpers.mjs +11 -0
- package/src/session-runtime/services/agent-tool/job-views/job-render.mjs +13 -10
- package/src/session-runtime/services/agent-tool/job-views/session-progress.mjs +3 -0
- package/src/session-runtime/services/agent-tool/render.mjs +8 -1
- package/src/session-runtime/services/agent-tool/send-flow.mjs +1 -0
- package/src/session-runtime/services/agent-tool/spawn-flow/spawn-prep.mjs +6 -0
- package/src/session-runtime/services/agent-tool/spawn-flow/spawn-run.mjs +2 -1
- package/src/session-runtime/services/agent-tool/tag-registry/reaped-sessions.mjs +82 -0
- package/src/session-runtime/services/agent-tool/tag-registry/record-facts-worker.mjs +36 -0
- package/src/session-runtime/services/agent-tool/tag-registry.mjs +4 -0
- package/src/session-runtime/services/agent-tool/terminal-reaper/row-helpers.mjs +29 -0
- package/src/session-runtime/services/agent-tool/terminal-reaper/scan-admission.mjs +11 -3
- package/src/session-runtime/services/agent-tool/terminal-reaper/stale-rows.mjs +19 -8
- package/src/session-runtime/services/agent-tool/terminal-reaper.mjs +5 -2
- package/src/session-runtime/services/agent-tool/worker-index.mjs +1 -0
- package/src/session-runtime/services/channel-admin.mjs +44 -3
- package/src/session-runtime/services/daemon-crash-capture/daemon-exit-record.mjs +2 -2
- package/src/session-runtime/services/plugin-admin.mjs +46 -7
- package/src/session-runtime/services/provider-admin.mjs +5 -0
- package/src/session-runtime/session-create.mjs +5 -0
- package/src/session-runtime/setup-tool/agent-settings-actions.mjs +1 -1
- package/src/session-runtime/setup-tool/executor.mjs +1 -1
- package/src/session-runtime/setup-tool/extended-actions.mjs +1 -1
- package/src/session-runtime/setup-tool/settings-contract.mjs +4 -2
- package/src/session-runtime/usage-stats-api.mjs +120 -1
- package/src/session-runtime/workflow-agents-api/agent-connectors.mjs +36 -29
- package/src/session-runtime/workflow-agents-api/agent-editor.mjs +183 -23
- package/src/session-runtime/workspace/admission-gate.mjs +25 -7
- package/src/session-runtime/workspace/transitions.mjs +4 -0
- package/src/standalone/daemon-log.mjs +28 -4
- package/src/standalone/daemon-owner.mjs +41 -7
- package/src/standalone/daemon-work-gate.mjs +139 -0
- package/src/standalone/daemon.mjs +80 -11
- package/src/standalone/desktop-service-registry.mjs +11 -4
- package/src/standalone/session-client.mjs +57 -5
- package/src/standalone/session-protocol.mjs +6 -0
- package/src/standalone/session-service/agent-tree/agent-cancel.mjs +17 -1
- package/src/standalone/session-service/agent-tree.mjs +7 -0
- package/src/standalone/session-service/retention/busy.mjs +3 -2
- package/src/standalone/session-service/session-calls/session-turns.mjs +12 -5
- package/src/standalone/session-transport/call-route.mjs +10 -4
- package/src/standalone/session-transport/routes.mjs +21 -0
- package/src/standalone/session-transport/stack.mjs +3 -1
- package/src/standalone/session-transport.mjs +5 -0
- 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/dist/index.mjs +536 -484
- package/src/tui/session/session-api/integrations.mjs +3 -0
- package/src/tui/session/session-api/media.mjs +5 -0
- package/src/tui/session/tool-approval-settle.mjs +24 -4
- package/src/tui/session/tool-approval.mjs +35 -10
- package/src/tui/session/turn.mjs +13 -0
- package/src/runtime/agent/orchestrator/providers/gemini-sdk-stream/cancellation.mjs +0 -71
- package/src/runtime/agent/orchestrator/providers/gemini-sdk-stream/reader.mjs +0 -108
|
@@ -42,7 +42,11 @@ function workerLine(worker) {
|
|
|
42
42
|
const stage = worker.worker_stage || worker.stage;
|
|
43
43
|
const progress = oneLine(worker.last_progress);
|
|
44
44
|
const summary = progress.length > 60 ? `${progress.slice(0, 59)}…` : progress;
|
|
45
|
-
|
|
45
|
+
const toolSilence = oneLine(worker.tool_silent_for);
|
|
46
|
+
// The hung diagnostic carries the warning and the suggested action; other
|
|
47
|
+
// diagnostics stay out of the compact row.
|
|
48
|
+
const hung = /^tool possibly hung/.test(worker.diagnostic || '') ? oneLine(worker.diagnostic) : '';
|
|
49
|
+
return `- ${worker.tag} ${status}${stage && stage !== status ? `/${stage}` : ''}${summary ? ` ${summary}` : ''}${toolSilence ? ` tool_silent_for: ${toolSilence}` : ''}${hung ? ` ! ${hung}` : ''}`;
|
|
46
50
|
}
|
|
47
51
|
|
|
48
52
|
function jobLine(job) {
|
|
@@ -121,6 +125,7 @@ function taskDiagnosticLines(value) {
|
|
|
121
125
|
if (value.worker_stage) lines.push(`worker_stage: ${value.worker_stage}`);
|
|
122
126
|
if (value.last_progress) lines.push(`last_progress: ${value.last_progress}`);
|
|
123
127
|
if (Number.isFinite(value.silent_for)) lines.push(`silent_for: ${value.silent_for}s`);
|
|
128
|
+
if (value.tool_silent_for) lines.push(`tool_silent_for: ${value.tool_silent_for}`);
|
|
124
129
|
if (value.watchdog) lines.push(`watchdog: ${value.watchdog}`);
|
|
125
130
|
if (Number.isFinite(value.queued_followups)) lines.push(`queued_followups: ${value.queued_followups}`);
|
|
126
131
|
if (value.diagnostic) lines.push(`diagnostic: ${value.diagnostic}`);
|
|
@@ -151,6 +156,7 @@ function renderTask(value, includeDiagnostics) {
|
|
|
151
156
|
if (value.type) lines.push(`type: ${value.type}`);
|
|
152
157
|
if (value.reused) lines.push('reused: true');
|
|
153
158
|
if (value.respawned) lines.push('respawned: true');
|
|
159
|
+
if (value.resumed) lines.push('resumed: true');
|
|
154
160
|
if (value.note) lines.push(`note: ${value.note}`);
|
|
155
161
|
if (value.tag || value.sessionId) lines.push(`target: ${value.tag || '-'} ${value.sessionId || ''}`.trim());
|
|
156
162
|
if (!isStartAck) lines.push(...taskDiagnosticLines(value));
|
|
@@ -169,6 +175,7 @@ function renderQueued(value) {
|
|
|
169
175
|
return [
|
|
170
176
|
'agent message queued',
|
|
171
177
|
value.reused ? 'reused: true' : null,
|
|
178
|
+
value.resumed ? 'resumed: true' : null,
|
|
172
179
|
`target: ${value.tag || '-'} ${value.sessionId || ''}`.trim(),
|
|
173
180
|
value.agent ? `agent: ${value.agent}` : null,
|
|
174
181
|
`queueDepth: ${value.queueDepth ?? 1}`,
|
|
@@ -343,6 +343,7 @@ export function createSendFlow({
|
|
|
343
343
|
effort: session.effort || null,
|
|
344
344
|
fast: session.fast === true,
|
|
345
345
|
...(session.autoEffort === false ? { autoEffort: false } : {}),
|
|
346
|
+
...(extras.resumed === true ? { resumed: true } : {}),
|
|
346
347
|
},
|
|
347
348
|
(job, ownerNotifyContext) => runSend(prepared, ownerNotifyContext, job),
|
|
348
349
|
notifyContext
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import { presetKey, readAgentFirstResponseTimeoutMs, writeAgentStatuslineRoute } from '../helpers.mjs';
|
|
8
8
|
import { resolveAgentWatchdogPolicy } from '../../../../runtime/agent/orchestrator/agent-runtime/agent-progress-watchdog.mjs';
|
|
9
9
|
import { prepareAgentSession } from '../../../../runtime/agent/orchestrator/agent-runtime/session-builder.mjs';
|
|
10
|
+
import { prewarmGitStartupProbes } from '../../../../runtime/agent/orchestrator/tools/builtin/runtime-capabilities.mjs';
|
|
10
11
|
import { getProvider } from '../../../../runtime/agent/orchestrator/providers/registry.mjs';
|
|
11
12
|
import { resolveRouteContextState } from '../../../route-state.mjs';
|
|
12
13
|
import { contextSelectionFromState } from '../../../../runtime/agent/orchestrator/runtime-core/route-context-state.mjs';
|
|
@@ -106,10 +107,15 @@ export function createSpawnPreparer({
|
|
|
106
107
|
if (plan.preset.contextPercent || plan.preset.contextTokens) {
|
|
107
108
|
Object.assign(sessionSpec, contextSelectionFromState(resolveRouteContextState(plan.preset, null), plan.preset));
|
|
108
109
|
}
|
|
110
|
+
// Session creation composes the git startup line synchronously; its probes
|
|
111
|
+
// answer off-thread here so that composition never spawns git on the event loop.
|
|
112
|
+
const gitProbes = prewarmGitStartupProbes([sessionSpec.cwd]);
|
|
109
113
|
if (sessionSurface?.canonical === true && typeof sessionSurface.createChild === 'function') {
|
|
114
|
+
await gitProbes;
|
|
110
115
|
return sessionSurface.createChild({ spec: sessionSpec, prompt: plan.prompt, tag: plan.tag });
|
|
111
116
|
}
|
|
112
117
|
await ensureProvider(plan.config, plan.preset.provider);
|
|
118
|
+
await gitProbes;
|
|
113
119
|
if (prepState?.timedOut) {
|
|
114
120
|
throw new Error('agent spawn prep timed out before session bind');
|
|
115
121
|
}
|
|
@@ -253,7 +253,8 @@ export function createSpawnRunner({
|
|
|
253
253
|
// SubagentStop: worker finished (terminal), regardless of outcome.
|
|
254
254
|
emitSubagentEvent('stop', agent, { session_id: session.id, tag, status: finalStatus });
|
|
255
255
|
// Keep the durable session/tag for same-tag follow-ups, but release every
|
|
256
|
-
// process-local
|
|
256
|
+
// process-local shell, watchdog and tool cache immediately. Pooled
|
|
257
|
+
// provider connections stay for the follow-up's response chain.
|
|
257
258
|
try {
|
|
258
259
|
mgr.unloadSessionRuntime?.(session.id, 'agent-turn-complete');
|
|
259
260
|
} catch {}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// Sessions behind a reaped tag, for an explicit reuse of that tag only (scans
|
|
2
|
+
// never read these). A reap drops only the index row and leaves a capped,
|
|
3
|
+
// expiring tombstone; the session record stays on disk and still names its
|
|
4
|
+
// tag and owner session, and the store's own retention deletes it in time.
|
|
5
|
+
// These reads let a send or explicit spawn continue that saved session, or at
|
|
6
|
+
// least prove the tag was this owner's, once the index no longer can.
|
|
7
|
+
import { sessionPath } from '../../../../runtime/agent/orchestrator/session/store/session-paths.mjs';
|
|
8
|
+
import { resumableAfterReap } from '../../../../runtime/shared/agent-reap-state.mjs';
|
|
9
|
+
import { createWorkerRequestClient } from '../../../../runtime/shared/worker-requests.mjs';
|
|
10
|
+
import {
|
|
11
|
+
agentTagOf,
|
|
12
|
+
callerSessionForContext,
|
|
13
|
+
clean,
|
|
14
|
+
isExistingDirectory,
|
|
15
|
+
sessionMatchesContext,
|
|
16
|
+
stampMs,
|
|
17
|
+
} from '../helpers.mjs';
|
|
18
|
+
import { isLeadPoolAgent } from '../worker-rows.mjs';
|
|
19
|
+
|
|
20
|
+
// The record is read and parsed on a worker thread (record-facts-worker.mjs),
|
|
21
|
+
// started on the first resume and retired when idle.
|
|
22
|
+
const readRecordFacts = createWorkerRequestClient(new URL('./record-facts-worker.mjs', import.meta.url), {
|
|
23
|
+
idleExitMs: 30_000,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
async function storedRecordFacts(sessionId) {
|
|
27
|
+
let path;
|
|
28
|
+
try {
|
|
29
|
+
path = sessionPath(sessionId);
|
|
30
|
+
} catch {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
return readRecordFacts({ path, sessionId });
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function createReapedSessions({ mgr, getLiveSession, isReleased }) {
|
|
37
|
+
function ownedTagSession(session, tag, context) {
|
|
38
|
+
return (
|
|
39
|
+
Boolean(clean(session?.id)) &&
|
|
40
|
+
agentTagOf(session) === tag &&
|
|
41
|
+
!isLeadPoolAgent(session.agent) &&
|
|
42
|
+
sessionMatchesContext(session, context)
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** The newest session record (open or closed) the caller's owner session
|
|
47
|
+
* ran under `tag`, or null when it never used the tag. Only an owner
|
|
48
|
+
* session scopes this: a terminal pid alone proves nothing durable. */
|
|
49
|
+
function lastTagSession(tag, context = {}) {
|
|
50
|
+
const value = clean(tag);
|
|
51
|
+
if (!value || value.startsWith('sess_') || !callerSessionForContext(context)) return null;
|
|
52
|
+
let newest = null;
|
|
53
|
+
for (const session of mgr.listSessions?.({ includeClosed: true }) || []) {
|
|
54
|
+
if (!ownedTagSession(session, value, context)) continue;
|
|
55
|
+
if (!newest || stampMs(session.createdAt) > stampMs(newest.createdAt)) newest = session;
|
|
56
|
+
}
|
|
57
|
+
return newest;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Whether `sessionId` may continue under `tag` for this owner, decided by
|
|
61
|
+
* its stored record (strictly parsed off the event loop; a daemon-owned
|
|
62
|
+
* child's live descriptor carries none of these fields): still stored, not
|
|
63
|
+
* closed, carrying close provenance and not closed by its owner since its
|
|
64
|
+
* last turn (resumableAfterReap; the index's released marker counts only
|
|
65
|
+
* for its TTL), and naming this tag and owner. `{ session }` when it may
|
|
66
|
+
* continue, `{ missingCwd }` when only its working directory is gone, else
|
|
67
|
+
* null. */
|
|
68
|
+
async function resumableTagSession(tag, sessionId, context = {}) {
|
|
69
|
+
const value = clean(tag);
|
|
70
|
+
const id = clean(sessionId);
|
|
71
|
+
if (!value || !id || isReleased(id)) return null;
|
|
72
|
+
const record = await storedRecordFacts(id);
|
|
73
|
+
if (!record || record.closed === true || !resumableAfterReap(record)) return null;
|
|
74
|
+
if (!ownedTagSession(record, value, context)) return null;
|
|
75
|
+
const session = getLiveSession(id);
|
|
76
|
+
if (!session) return null;
|
|
77
|
+
const cwd = clean(record.cwd);
|
|
78
|
+
return (await isExistingDirectory(cwd)) ? { session } : { missingCwd: cwd };
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return { lastTagSession, resumableTagSession };
|
|
82
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// Worker thread: reads one stored session record and answers the few fields a
|
|
2
|
+
// reaped-tag resume decides on, so a transcript of several MB is never read or
|
|
3
|
+
// parsed on the host's event loop. Same strict parse as the store's lifecycle
|
|
4
|
+
// authority: an absent, unreadable, ambiguous or foreign record answers null.
|
|
5
|
+
import { readFile } from 'node:fs/promises';
|
|
6
|
+
import { serveWorkerRequests } from '../../../../runtime/shared/worker-requests.mjs';
|
|
7
|
+
import {
|
|
8
|
+
isLifecycleUnreadable,
|
|
9
|
+
readTopLevelLifecycleRecord,
|
|
10
|
+
} from '../../../../runtime/agent/orchestrator/session/lifecycle-scan.mjs';
|
|
11
|
+
|
|
12
|
+
serveWorkerRequests(async ({ path, sessionId }) => {
|
|
13
|
+
let text;
|
|
14
|
+
try {
|
|
15
|
+
text = await readFile(path, 'utf8');
|
|
16
|
+
} catch (error) {
|
|
17
|
+
if (error?.code === 'ENOENT' || error?.code === 'ENOTDIR') return null;
|
|
18
|
+
throw error;
|
|
19
|
+
}
|
|
20
|
+
const record = readTopLevelLifecycleRecord(text);
|
|
21
|
+
if (isLifecycleUnreadable(record) || record.id !== sessionId) return null;
|
|
22
|
+
const doc = record.doc;
|
|
23
|
+
return {
|
|
24
|
+
id: sessionId,
|
|
25
|
+
agentTag: doc.agentTag || null,
|
|
26
|
+
agent: doc.agent || null,
|
|
27
|
+
parentSessionId: doc.parentSessionId || null,
|
|
28
|
+
ownerSessionId: doc.ownerSessionId || null,
|
|
29
|
+
clientHostPid: doc.clientHostPid || null,
|
|
30
|
+
cwd: doc.cwd || '',
|
|
31
|
+
closed: doc.closed === true || doc.status === 'closed',
|
|
32
|
+
lastTurnCompletedAt: doc.lastTurnCompletedAt ?? null,
|
|
33
|
+
ownerClosedAt: doc.ownerClosedAt ?? null,
|
|
34
|
+
closeProvenance: doc.closeProvenance ?? null,
|
|
35
|
+
};
|
|
36
|
+
});
|
|
@@ -10,6 +10,7 @@ import { createTagMaps } from './tag-maps.mjs';
|
|
|
10
10
|
import { createTerminalReaper } from './terminal-reaper.mjs';
|
|
11
11
|
import { createTagLookup } from './tag-registry/tag-lookup.mjs';
|
|
12
12
|
import { createTagRefresh } from './tag-registry/tag-refresh.mjs';
|
|
13
|
+
import { createReapedSessions } from './tag-registry/reaped-sessions.mjs';
|
|
13
14
|
|
|
14
15
|
export function createTagRegistry({ dataDir, cfgMod, mgr }) {
|
|
15
16
|
const tagMaps = createTagMaps();
|
|
@@ -68,6 +69,7 @@ export function createTagRegistry({ dataDir, cfgMod, mgr }) {
|
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
const reaper = createTerminalReaper({ cfgMod, mgr, tagMaps, index, getLiveSession });
|
|
72
|
+
const reaped = createReapedSessions({ mgr, getLiveSession, isReleased: index.isReleased });
|
|
71
73
|
|
|
72
74
|
function wantsSessionScan(args = {}) {
|
|
73
75
|
return args.recover === true || args.scanSessions === true || args.scan_sessions === true;
|
|
@@ -140,6 +142,8 @@ export function createTagRegistry({ dataDir, cfgMod, mgr }) {
|
|
|
140
142
|
tombstoneTerminalSession: reaper.tombstoneTerminalSession,
|
|
141
143
|
tagTombstoneForTag: reaper.tagTombstoneForTag,
|
|
142
144
|
consumeTagTombstone: reaper.consumeTagTombstone,
|
|
145
|
+
lastTagSession: reaped.lastTagSession,
|
|
146
|
+
resumableTagSession: reaped.resumableTagSession,
|
|
143
147
|
transitionStaleNonterminalRows: reaper.transitionStaleNonterminalRows,
|
|
144
148
|
};
|
|
145
149
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// Row-level predicates shared by the terminal-reaper modules.
|
|
2
2
|
import { stampMs } from '../helpers.mjs';
|
|
3
|
+
import { ACTIVE_STAGES } from '../tool-def.mjs';
|
|
4
|
+
import { resolveAgentTerminalReapMs } from '../../../../runtime/agent/orchestrator/runtime-core/config-helpers.mjs';
|
|
3
5
|
import { isTerminalWorkerStatus, tagTombstoneKey } from '../worker-rows.mjs';
|
|
4
6
|
|
|
5
7
|
/** Latest proof of life on the session record itself. createdAt is included
|
|
@@ -18,6 +20,33 @@ export function isTerminalRow(row) {
|
|
|
18
20
|
return isTerminalWorkerStatus(row.status || row.stage);
|
|
19
21
|
}
|
|
20
22
|
|
|
23
|
+
// A settled row stays indexed this long after it finished, and in any case until
|
|
24
|
+
// its own continuation (reap) window has ended.
|
|
25
|
+
export const SETTLED_ROW_RETENTION_MS = 24 * 60 * 60 * 1000;
|
|
26
|
+
|
|
27
|
+
/** Whether a settled record has aged out of the index: past the retention
|
|
28
|
+
* floor and past its continuation deadline (`reapAt` when stamped, else the
|
|
29
|
+
* provider's resolved window). `record` is a worker row or a session: both
|
|
30
|
+
* carry the same stamp fields, so pruning a row and admitting a session scan
|
|
31
|
+
* one rule over its latest activity stamp. Decided by stamps alone. */
|
|
32
|
+
export function pastSettledRetention(config, record, now = Date.now()) {
|
|
33
|
+
const settledAtMs = sessionActivityAt(record);
|
|
34
|
+
if (!(settledAtMs > 0) || now - settledAtMs < SETTLED_ROW_RETENTION_MS) return false;
|
|
35
|
+
const stamped = stampMs(record.reapAt);
|
|
36
|
+
return now >= (stamped > 0 ? stamped : settledAtMs + resolveAgentTerminalReapMs(config, record.provider));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** In-memory proof that a session is still in use (a running or just-resumed
|
|
40
|
+
* turn, a queued delivery, a controller not yet aborted). Never loads a
|
|
41
|
+
* session record. */
|
|
42
|
+
export function sessionHasLiveWork(mgr, sessionId) {
|
|
43
|
+
if (mgr.isSessionTurnInFlight?.(sessionId) === true || mgr.hasPendingMessages?.(sessionId) === true) return true;
|
|
44
|
+
const runtime = mgr.getSessionRuntime?.(sessionId) || null;
|
|
45
|
+
if (runtime?.controller?.signal && !runtime.controller.signal.aborted) return true;
|
|
46
|
+
const stage = runtime?.stage;
|
|
47
|
+
return Boolean(stage && ACTIVE_STAGES.has(stage));
|
|
48
|
+
}
|
|
49
|
+
|
|
21
50
|
export function insertTombstone(tombstonesByKey, priorityTombstoneKeys, tombstone) {
|
|
22
51
|
const key = tagTombstoneKey(tombstone);
|
|
23
52
|
tombstonesByKey.set(key, tombstone);
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
import { clean, stampMs } from '../helpers.mjs';
|
|
4
4
|
import { isTerminalWorkerStatus } from '../worker-rows.mjs';
|
|
5
5
|
import { ACTIVE_STAGES } from '../tool-def.mjs';
|
|
6
|
-
import { sessionActivityAt } from './row-helpers.mjs';
|
|
6
|
+
import { pastSettledRetention, sessionActivityAt } from './row-helpers.mjs';
|
|
7
7
|
|
|
8
|
-
export function createScanAdmission({ mgr, index, tombstoneBlocksScan }) {
|
|
8
|
+
export function createScanAdmission({ cfgMod, mgr, index, tombstoneBlocksScan }) {
|
|
9
9
|
const { readWorkerRows, upsertWorkerSessionDeferred } = index;
|
|
10
10
|
|
|
11
11
|
function scanSessionIsTerminal(session) {
|
|
@@ -42,6 +42,14 @@ export function createScanAdmission({ mgr, index, tombstoneBlocksScan }) {
|
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
/** A settled session past its retention would be re-indexed with its frozen
|
|
46
|
+
* stamps only to be aged out again (once its tombstone expired or was
|
|
47
|
+
* capped), so a scan never admits it. */
|
|
48
|
+
function scanSessionAgedOut(session) {
|
|
49
|
+
if (!scanSessionIsTerminal(session)) return false;
|
|
50
|
+
return pastSettledRetention(cfgMod.loadConfig(), session);
|
|
51
|
+
}
|
|
52
|
+
|
|
45
53
|
// Shared session-scan admission: returns false when the scan must not
|
|
46
54
|
// resurrect this session, otherwise indexes it (terminal sessions with their
|
|
47
55
|
// own stamps).
|
|
@@ -52,5 +60,5 @@ export function createScanAdmission({ mgr, index, tombstoneBlocksScan }) {
|
|
|
52
60
|
return true;
|
|
53
61
|
}
|
|
54
62
|
|
|
55
|
-
return { scanUpsertSession };
|
|
63
|
+
return { scanUpsertSession, scanSessionAgedOut };
|
|
56
64
|
}
|
|
@@ -2,35 +2,46 @@
|
|
|
2
2
|
// last row stamp is older than the reap window becomes a tombstone so its tag is
|
|
3
3
|
// freed instead of blocking spawn forever.
|
|
4
4
|
import { clean, positiveInt } from '../helpers.mjs';
|
|
5
|
+
import { isUnnotifiedRestartFailure } from '../worker-index/row-liveness.mjs';
|
|
5
6
|
import { TAG_TOMBSTONE_TTL_MS, isLeadPoolAgent, workerRowTime } from '../worker-rows.mjs';
|
|
6
7
|
import { resolveAgentTerminalReapMs } from '../../../../runtime/agent/orchestrator/runtime-core/config-helpers.mjs';
|
|
7
|
-
import { insertTombstone, isTerminalRow } from './row-helpers.mjs';
|
|
8
|
+
import { insertTombstone, isTerminalRow, pastSettledRetention, sessionHasLiveWork } from './row-helpers.mjs';
|
|
8
9
|
|
|
9
|
-
export function createStaleRowTransition({ cfgMod, tagMaps, index, getLiveSession }) {
|
|
10
|
+
export function createStaleRowTransition({ cfgMod, mgr, tagMaps, index, getLiveSession }) {
|
|
10
11
|
const { readWorkerRows, writeWorkerRows, flushWorkerIndexMutations } = index;
|
|
11
12
|
|
|
12
13
|
function transitionStaleNonterminalRows(context = {}) {
|
|
14
|
+
const now = Date.now();
|
|
15
|
+
const config = cfgMod.loadConfig();
|
|
13
16
|
const staleRows = readWorkerRows(context).filter((row) => {
|
|
14
17
|
if (isLeadPoolAgent(row.agent)) return false;
|
|
15
|
-
|
|
18
|
+
// Settled rows age out of the index (the tombstone keeps the tag's reap
|
|
19
|
+
// note); an owed restart failure is the only record of that result, and
|
|
20
|
+
// a session still in use in this process keeps its row.
|
|
21
|
+
if (isTerminalRow(row)) {
|
|
22
|
+
if (isUnnotifiedRestartFailure(row)) return false;
|
|
23
|
+
if (!pastSettledRetention(config, row, now) || sessionHasLiveWork(mgr, clean(row.sessionId))) return false;
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
16
26
|
if (getLiveSession(clean(row.sessionId))) return false;
|
|
17
27
|
const rowTime = workerRowTime(row);
|
|
18
|
-
const reapMs = resolveAgentTerminalReapMs(
|
|
28
|
+
const reapMs = resolveAgentTerminalReapMs(config, row.provider);
|
|
19
29
|
// A row with no timestamp has no usable stamp at all. Explicitly
|
|
20
30
|
// disabled terminal reaping still gets the tombstone TTL as a finite
|
|
21
31
|
// staleness bound, so malformed/running index rows cannot block a
|
|
22
32
|
// tag forever.
|
|
23
|
-
return rowTime <= 0 ||
|
|
33
|
+
return rowTime <= 0 || now - rowTime >= (reapMs ?? TAG_TOMBSTONE_TTL_MS);
|
|
24
34
|
});
|
|
25
35
|
if (staleRows.length === 0) return false;
|
|
26
36
|
flushWorkerIndexMutations();
|
|
27
37
|
const nowIso = new Date().toISOString();
|
|
38
|
+
const reapedIds = new Set(staleRows.map((row) => clean(row.sessionId)));
|
|
28
39
|
writeWorkerRows((byKey, tombstonesByKey, priorityTombstoneKeys) => {
|
|
40
|
+
for (const [key, candidate] of byKey) {
|
|
41
|
+
if (reapedIds.has(clean(candidate.sessionId))) byKey.delete(key);
|
|
42
|
+
}
|
|
29
43
|
for (const row of staleRows) {
|
|
30
44
|
const sessionId = clean(row.sessionId);
|
|
31
|
-
for (const [key, candidate] of [...byKey.entries()]) {
|
|
32
|
-
if (clean(candidate.sessionId) === sessionId) byKey.delete(key);
|
|
33
|
-
}
|
|
34
45
|
const tombstone = {
|
|
35
46
|
tag: clean(row.tag),
|
|
36
47
|
agent: clean(row.agent) || null,
|
|
@@ -10,15 +10,18 @@ import { createStaleRowTransition } from './terminal-reaper/stale-rows.mjs';
|
|
|
10
10
|
export function createTerminalReaper({ cfgMod, mgr, tagMaps, index, getLiveSession }) {
|
|
11
11
|
const tombstones = createTagTombstones({ tagMaps, index });
|
|
12
12
|
const scan = createScanAdmission({
|
|
13
|
+
cfgMod,
|
|
13
14
|
mgr,
|
|
14
15
|
index,
|
|
15
16
|
tombstoneBlocksScan: tombstones.tombstoneBlocksScan,
|
|
16
17
|
});
|
|
17
|
-
const
|
|
18
|
+
const tombstoneBlocksScan = (session, tag, map) =>
|
|
19
|
+
scan.scanSessionAgedOut(session) || tombstones.tombstoneBlocksScan(session, tag, map);
|
|
20
|
+
const { transitionStaleNonterminalRows } = createStaleRowTransition({ cfgMod, mgr, tagMaps, index, getLiveSession });
|
|
18
21
|
|
|
19
22
|
return {
|
|
20
23
|
tagTombstoneIndex: tombstones.tagTombstoneIndex,
|
|
21
|
-
tombstoneBlocksScan
|
|
24
|
+
tombstoneBlocksScan,
|
|
22
25
|
scanUpsertSession: scan.scanUpsertSession,
|
|
23
26
|
forgetTerminalSession: tombstones.forgetTerminalSession,
|
|
24
27
|
tombstoneTerminalSession: tombstones.tombstoneTerminalSession,
|
|
@@ -110,6 +110,7 @@ export function createWorkerIndex({ dataDir, cfgMod, mgr, tags, tagAgents, tagCw
|
|
|
110
110
|
upsertWorkerRow(rowFromSession(session, fallbackTag, extra), { defer: true }),
|
|
111
111
|
removeWorkerRow,
|
|
112
112
|
markReleased,
|
|
113
|
+
isReleased: store.isReleased,
|
|
113
114
|
setAwaitingUser: awaitingUser.setAwaitingUser,
|
|
114
115
|
refreshTagsFromIndex,
|
|
115
116
|
flushActiveWorkerRows: settlement.flushActiveWorkerRows,
|
|
@@ -24,7 +24,8 @@ import {
|
|
|
24
24
|
setEndpointEnabled as dbSetEndpointEnabled,
|
|
25
25
|
} from '../../runtime/channels/lib/webhooks-db.mjs';
|
|
26
26
|
import { normalizeAutomationAttachments } from '../../runtime/shared/automation-attachments.mjs';
|
|
27
|
-
import { assertRoutineOwner, routineOwnerProblem } from '../routine-owner.mjs';
|
|
27
|
+
import { ROUTINE_OWNER_PROBLEMS, assertRoutineOwner, routineOwnerProblem } from '../routine-owner.mjs';
|
|
28
|
+
import { MIXY_BOT_ID } from '../../runtime/shared/agent-store.mjs';
|
|
28
29
|
import { assertRoutineExecutor } from '../routine-executor.mjs';
|
|
29
30
|
import { hasEnabledAutomation } from '../../runtime/shared/automation-presence.mjs';
|
|
30
31
|
import { resolveScheduleTimezone, validateScheduleCron } from '../../runtime/shared/schedule-time.mjs';
|
|
@@ -278,9 +279,13 @@ function ownerProblems() {
|
|
|
278
279
|
export async function listSchedules() {
|
|
279
280
|
const rows = await dbListSchedules();
|
|
280
281
|
const problemOf = ownerProblems();
|
|
281
|
-
|
|
282
|
+
const listed = await Promise.all(rows.map(async (row) => scheduleToDisplay(row, await problemOf(row.ownerAgentId))));
|
|
283
|
+
return listed.filter(shownRoutine);
|
|
282
284
|
}
|
|
283
285
|
|
|
286
|
+
// An archived bot's routines are hidden until it is restored (routine-owner.mjs).
|
|
287
|
+
const shownRoutine = (row) => row.ownerProblem !== 'owner-archived';
|
|
288
|
+
|
|
284
289
|
/**
|
|
285
290
|
* Run `step` (the move of schedule `name`'s row) with `name` reserved against
|
|
286
291
|
* runs in this process (the app's "Run now"). Refused when one is in flight.
|
|
@@ -380,6 +385,7 @@ export async function saveSchedule(
|
|
|
380
385
|
saved = await upsertSchedule(def);
|
|
381
386
|
}
|
|
382
387
|
automationProbe.invalidate();
|
|
388
|
+
await refuseIfOwnerDeleted(ownerAgentId);
|
|
383
389
|
return scheduleToDisplay(saved);
|
|
384
390
|
}
|
|
385
391
|
|
|
@@ -406,7 +412,7 @@ async function listWebhooks() {
|
|
|
406
412
|
const endpoints = await dbListEndpoints();
|
|
407
413
|
const problemOf = ownerProblems();
|
|
408
414
|
const problems = await Promise.all(endpoints.map((ep) => problemOf(ep.ownerAgentId)));
|
|
409
|
-
|
|
415
|
+
const listed = endpoints.map((ep, index) => ({
|
|
410
416
|
name: ep.name,
|
|
411
417
|
description: ep.description || '',
|
|
412
418
|
parser: ep.parser || 'github',
|
|
@@ -430,6 +436,7 @@ async function listWebhooks() {
|
|
|
430
436
|
hasLastPayload: ep.hasLastPayload === true,
|
|
431
437
|
...routineHealth(ep),
|
|
432
438
|
}));
|
|
439
|
+
return listed.filter(shownRoutine);
|
|
433
440
|
}
|
|
434
441
|
|
|
435
442
|
export async function saveWebhook({
|
|
@@ -483,6 +490,7 @@ export async function saveWebhook({
|
|
|
483
490
|
executorAgentId: executor,
|
|
484
491
|
});
|
|
485
492
|
automationProbe.invalidate();
|
|
493
|
+
await refuseIfOwnerDeleted(ownerAgentId);
|
|
486
494
|
return {
|
|
487
495
|
name: id,
|
|
488
496
|
owner: saved.ownerAgentId || ownerAgentId,
|
|
@@ -504,6 +512,39 @@ export async function deleteWebhook(name) {
|
|
|
504
512
|
return { name: id, deleted: true };
|
|
505
513
|
}
|
|
506
514
|
|
|
515
|
+
/**
|
|
516
|
+
* Delete every schedule and webhook `agentId` currently owns, as its bot is
|
|
517
|
+
* deleted for good (agent-editor.mjs): all of them in one statement, or none
|
|
518
|
+
* (routines-db.mjs). Resolves the names removed. Mixy is never a target.
|
|
519
|
+
* Without a PostgreSQL cluster none exists, and none is started.
|
|
520
|
+
*/
|
|
521
|
+
export async function deleteOwnedRoutines(agentId) {
|
|
522
|
+
if (!agentHomeSessionId(agentId) || agentId === MIXY_AGENT_ID || agentId === MIXY_BOT_ID) {
|
|
523
|
+
throw new Error(`the routines of "${agentId}" cannot be deleted with a bot`);
|
|
524
|
+
}
|
|
525
|
+
if (!pgClusterExists(resolvePluginData())) return { schedules: [], webhooks: [] };
|
|
526
|
+
// Loaded on use: the stores' own modules stay the only imports of every reader.
|
|
527
|
+
const { deleteRoutinesOwnedBy } = await import('../../runtime/channels/lib/routines-db.mjs');
|
|
528
|
+
const removed = await deleteRoutinesOwnedBy(agentId);
|
|
529
|
+
automationProbe.invalidate();
|
|
530
|
+
return removed;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* After a save: the owner it checked may have been deleted for good meanwhile,
|
|
535
|
+
* its routines purged before this row landed. Then the row goes the way of
|
|
536
|
+
* the bot's others (deleteOwnedRoutines) and the save is refused. The delete
|
|
537
|
+
* purges again once the bot's folder is gone, so either a purge sees this row
|
|
538
|
+
* or this check sees the bot gone. An owner archived meanwhile keeps the row,
|
|
539
|
+
* hidden with its others until a restore, as if saved just before.
|
|
540
|
+
*/
|
|
541
|
+
async function refuseIfOwnerDeleted(ownerAgentId) {
|
|
542
|
+
const problem = await routineOwnerProblem(ownerAgentId).catch(() => '');
|
|
543
|
+
if (problem !== 'owner-deleted') return;
|
|
544
|
+
await deleteOwnedRoutines(ownerAgentId);
|
|
545
|
+
throw new Error(ROUTINE_OWNER_PROBLEMS[problem]);
|
|
546
|
+
}
|
|
547
|
+
|
|
507
548
|
export async function setWebhookEnabled(name, enabled) {
|
|
508
549
|
const id = assertName(name, 'webhook name');
|
|
509
550
|
const updated = await dbSetEndpointEnabled(id, enabled !== false);
|
|
@@ -137,8 +137,8 @@ export function installDaemonExitRecorder({
|
|
|
137
137
|
});
|
|
138
138
|
|
|
139
139
|
return {
|
|
140
|
-
setReason(reason, code = 0) {
|
|
141
|
-
pending = { reason, code, error
|
|
140
|
+
setReason(reason, code = 0, error = null) {
|
|
141
|
+
pending = { reason, code, error };
|
|
142
142
|
},
|
|
143
143
|
write,
|
|
144
144
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { spawnSync } from 'node:child_process';
|
|
2
|
-
import { existsSync, mkdirSync, readdirSync, renameSync, rmSync } from 'node:fs';
|
|
2
|
+
import { chmodSync, existsSync, lstatSync, mkdirSync, readdirSync, renameSync, rmSync, unlinkSync } from 'node:fs';
|
|
3
3
|
import { basename, dirname, join, resolve } from 'node:path';
|
|
4
4
|
import { homedir } from 'node:os';
|
|
5
5
|
import { createHash, randomUUID } from 'node:crypto';
|
|
@@ -168,6 +168,45 @@ function withPluginMutation(dataDir, id, operation) {
|
|
|
168
168
|
});
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
+
// Node 24 on Windows (Electron) makes rmSync follow junctions into their targets,
|
|
172
|
+
// so every link is detached first and never chmod-ed or recursed into. It also
|
|
173
|
+
// fails with EPERM on read-only files such as git pack files; clear the read-only
|
|
174
|
+
// bit and retry once. Each entry is lstat-ed right before it is acted on, not
|
|
175
|
+
// trusted from the listing, so a directory swapped for a link after the listing
|
|
176
|
+
// is detached instead of entered. What remains is the instant between that
|
|
177
|
+
// lstat and the next readdir/chmod, which no portable fs call can close. A file
|
|
178
|
+
// with other names (link count > 1) shares its mode with them, so `onFile` is
|
|
179
|
+
// told its stat and the chmod recovery skips it.
|
|
180
|
+
function walkTree(dir, onFile) {
|
|
181
|
+
for (const name of readdirSync(dir)) {
|
|
182
|
+
const full = join(dir, name);
|
|
183
|
+
const stat = lstatSync(full, { throwIfNoEntry: false });
|
|
184
|
+
if (!stat) continue;
|
|
185
|
+
if (stat.isSymbolicLink()) unlinkSync(full);
|
|
186
|
+
else if (stat.isDirectory()) walkTree(full, onFile);
|
|
187
|
+
else onFile?.(full, stat);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function removeTree(path) {
|
|
192
|
+
const stat = lstatSync(path, { throwIfNoEntry: false });
|
|
193
|
+
if (!stat) return;
|
|
194
|
+
if (stat.isSymbolicLink()) return unlinkSync(path);
|
|
195
|
+
const options = { recursive: true, force: true };
|
|
196
|
+
if (stat.isDirectory()) walkTree(path);
|
|
197
|
+
try {
|
|
198
|
+
rmSync(path, options);
|
|
199
|
+
} catch (error) {
|
|
200
|
+
if (error?.code !== 'EPERM') throw error;
|
|
201
|
+
if (stat.isDirectory()) {
|
|
202
|
+
walkTree(path, (file, fileStat) => {
|
|
203
|
+
if (fileStat.nlink === 1) chmodSync(file, 0o666);
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
rmSync(path, options);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
171
210
|
function cleanupManagedPartials(root) {
|
|
172
211
|
const parent = dirname(root);
|
|
173
212
|
const prefix = `${basename(root)}.tmp-`;
|
|
@@ -175,7 +214,7 @@ function cleanupManagedPartials(root) {
|
|
|
175
214
|
for (const entry of readdirSync(parent)) {
|
|
176
215
|
if (!entry.startsWith(prefix)) continue;
|
|
177
216
|
try {
|
|
178
|
-
|
|
217
|
+
removeTree(join(parent, entry));
|
|
179
218
|
} catch {}
|
|
180
219
|
}
|
|
181
220
|
}
|
|
@@ -185,7 +224,7 @@ function recoverManagedPluginRoot(root) {
|
|
|
185
224
|
if (!existsSync(root) && existsSync(backupRoot)) {
|
|
186
225
|
renameSync(backupRoot, root);
|
|
187
226
|
} else if (existsSync(root) && existsSync(backupRoot)) {
|
|
188
|
-
|
|
227
|
+
removeTree(backupRoot);
|
|
189
228
|
}
|
|
190
229
|
return backupRoot;
|
|
191
230
|
}
|
|
@@ -210,7 +249,7 @@ export function _publishManagedPluginRoot(root, tempRoot) {
|
|
|
210
249
|
throw error;
|
|
211
250
|
}
|
|
212
251
|
try {
|
|
213
|
-
|
|
252
|
+
removeTree(backupRoot);
|
|
214
253
|
} catch {}
|
|
215
254
|
}
|
|
216
255
|
|
|
@@ -228,7 +267,7 @@ function materializePlugin(normalized, id, dataDir) {
|
|
|
228
267
|
_publishManagedPluginRoot(root, tempRoot);
|
|
229
268
|
} catch (error) {
|
|
230
269
|
try {
|
|
231
|
-
|
|
270
|
+
removeTree(tempRoot);
|
|
232
271
|
} catch {}
|
|
233
272
|
throw error;
|
|
234
273
|
} finally {
|
|
@@ -374,8 +413,8 @@ export function removePlugin(idOrName, { dataDir = resolvePluginData() } = {}) {
|
|
|
374
413
|
});
|
|
375
414
|
if (entry.managed !== false && entry.root) {
|
|
376
415
|
ensureInside(installRoot(dataDir), entry.root);
|
|
377
|
-
|
|
378
|
-
|
|
416
|
+
removeTree(entry.root);
|
|
417
|
+
removeTree(`${entry.root}.backup`);
|
|
379
418
|
cleanupManagedPartials(entry.root);
|
|
380
419
|
}
|
|
381
420
|
return { ...entry, removed: true };
|
|
@@ -598,6 +598,7 @@ function publicCustomModelRows(rows) {
|
|
|
598
598
|
if (out > 0) model.maxOutputTokens = Math.floor(out);
|
|
599
599
|
model.hidden = item.hidden === true;
|
|
600
600
|
model.manual = item.manual === true;
|
|
601
|
+
if (item.inherited) model.inherited = structuredClone(item.inherited);
|
|
601
602
|
for (const key of [
|
|
602
603
|
'supportsVision',
|
|
603
604
|
'supportsReasoning',
|
|
@@ -660,6 +661,7 @@ function customProviderRow(id, entry, checkSecrets = true) {
|
|
|
660
661
|
row.discovery = structuredClone(config?.discovery ?? entry.discovery ?? { newModelsHidden: false });
|
|
661
662
|
row.modelOverrides = structuredClone(config?.modelOverrides ?? entry.modelOverrides ?? {});
|
|
662
663
|
if (config?.headers) row.headers = { ...config.headers };
|
|
664
|
+
if (config?.requestBody) row.requestBody = structuredClone(config.requestBody);
|
|
663
665
|
if (config?.wires) row.wires = [...config.wires];
|
|
664
666
|
if (config?.modelWires) row.modelWires = { ...config.modelWires };
|
|
665
667
|
// Additional API keys by id only; their values never leave the keychain.
|
|
@@ -1308,6 +1310,7 @@ function withStoredSettings(input, entry) {
|
|
|
1308
1310
|
if (out.modelOverrides === undefined) out.modelOverrides = stored.modelOverrides;
|
|
1309
1311
|
// `headers: {}` clears them; an omitted field keeps the stored ones.
|
|
1310
1312
|
if (out.headers === undefined && stored.headers) out.headers = stored.headers;
|
|
1313
|
+
if (out.requestBody === undefined && stored.requestBody) out.requestBody = stored.requestBody;
|
|
1311
1314
|
// Served wires and per-model wires have no setup field yet: an edit on
|
|
1312
1315
|
// the same protocol keeps them (another protocol serves other wires).
|
|
1313
1316
|
if ((out.protocol ?? stored.protocol) === stored.protocol) {
|
|
@@ -1472,6 +1475,8 @@ const MODEL_PATCH_KEYS = new Set([
|
|
|
1472
1475
|
'maxOutputTokens',
|
|
1473
1476
|
'supportsVision',
|
|
1474
1477
|
'reasoning',
|
|
1478
|
+
'requestBody',
|
|
1479
|
+
'requestHeaders',
|
|
1475
1480
|
]);
|
|
1476
1481
|
const REASONING_PATCH_KEYS = new Set(['levels', 'wireFormat', 'wireValues', 'replay']);
|
|
1477
1482
|
|
|
@@ -8,6 +8,7 @@ import { runAbortable, throwIfAborted } from '../runtime/shared/abort-race.mjs';
|
|
|
8
8
|
import { elapsedMs, prepareRoute } from './session-create/route-prep.mjs';
|
|
9
9
|
import { materializeSession, prewarmWsTransport } from './session-create/materialize.mjs';
|
|
10
10
|
import { dispatchSessionStart } from './session-create/session-start-hook.mjs';
|
|
11
|
+
import { prewarmGitStartupProbes } from '../runtime/agent/orchestrator/tools/builtin/runtime-capabilities.mjs';
|
|
11
12
|
import { SessionClosedError } from '../runtime/agent/orchestrator/session/manager/session-errors.mjs';
|
|
12
13
|
import {
|
|
13
14
|
SessionAddressError,
|
|
@@ -67,7 +68,11 @@ export function createSessionCreator(deps, routes) {
|
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
async function buildSession(reason, signal, startedAt) {
|
|
71
|
+
// materializeSession composes the git startup line synchronously; its
|
|
72
|
+
// probes answer off-thread alongside route prep instead of blocking there.
|
|
73
|
+
const gitProbes = prewarmGitStartupProbes([rt.currentCwd]);
|
|
70
74
|
const { coreMemoryContext, providerImpl } = await prepareRoute(deps, routes, signal, startedAt);
|
|
75
|
+
await gitProbes;
|
|
71
76
|
// The fence/record may have changed during the awaits above (close during
|
|
72
77
|
// reservation prewarm): re-validate synchronously right before adoption.
|
|
73
78
|
assertAdmissionOpen(rt);
|