@bastani/atomic 0.10.1 → 0.10.2
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/CHANGELOG.md +95 -0
- package/dist/builtin/intercom/CHANGELOG.md +12 -0
- package/dist/builtin/intercom/broker/watchdog.ts +4 -0
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +32 -0
- package/dist/builtin/subagents/README.md +2 -0
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/skills/subagent/SKILL.md +3 -3
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +269 -144
- package/dist/builtin/web-access/CHANGELOG.md +14 -0
- package/dist/builtin/web-access/index.bundle.mjs +9 -5
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/cli/list-models.d.ts.map +1 -1
- package/dist/cli/list-models.js +1 -14
- package/dist/cli/list-models.js.map +1 -1
- package/dist/core/agent-session-export.d.ts.map +1 -1
- package/dist/core/agent-session-export.js +13 -9
- package/dist/core/agent-session-export.js.map +1 -1
- package/dist/core/agent-session-message-queue.d.ts.map +1 -1
- package/dist/core/agent-session-message-queue.js +6 -3
- package/dist/core/agent-session-message-queue.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +3 -0
- package/dist/core/agent-session-methods.d.ts.map +1 -1
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session-nested-tools.d.ts.map +1 -1
- package/dist/core/agent-session-nested-tools.js +2 -1
- package/dist/core/agent-session-nested-tools.js.map +1 -1
- package/dist/core/agent-session-prompt.d.ts.map +1 -1
- package/dist/core/agent-session-prompt.js +12 -0
- package/dist/core/agent-session-prompt.js.map +1 -1
- package/dist/core/agent-session-state.d.ts +6 -0
- package/dist/core/agent-session-state.d.ts.map +1 -1
- package/dist/core/agent-session-state.js +71 -4
- package/dist/core/agent-session-state.js.map +1 -1
- package/dist/core/agent-session-tool-hooks.d.ts.map +1 -1
- package/dist/core/agent-session-tool-hooks.js +9 -1
- package/dist/core/agent-session-tool-hooks.js.map +1 -1
- package/dist/core/agent-session-types.d.ts +2 -0
- package/dist/core/agent-session-types.d.ts.map +1 -1
- package/dist/core/agent-session-types.js.map +1 -1
- package/dist/core/agent-session.d.ts +3 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +7 -0
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/cache-stats.d.ts +15 -0
- package/dist/core/cache-stats.d.ts.map +1 -1
- package/dist/core/cache-stats.js +40 -2
- package/dist/core/cache-stats.js.map +1 -1
- package/dist/core/diagnostic-writer.d.ts.map +1 -1
- package/dist/core/diagnostic-writer.js +2 -1
- package/dist/core/diagnostic-writer.js.map +1 -1
- package/dist/core/export-html/template.js +14 -4
- package/dist/core/extensions/context-types.d.ts +6 -0
- package/dist/core/extensions/context-types.d.ts.map +1 -1
- package/dist/core/extensions/context-types.js.map +1 -1
- package/dist/core/extensions/loader-api.d.ts.map +1 -1
- package/dist/core/extensions/loader-api.js +5 -2
- package/dist/core/extensions/loader-api.js.map +1 -1
- package/dist/core/queued-message-delivery.d.ts +100 -7
- package/dist/core/queued-message-delivery.d.ts.map +1 -1
- package/dist/core/queued-message-delivery.js +194 -4
- package/dist/core/queued-message-delivery.js.map +1 -1
- package/dist/core/resume-cache-checkpoint.d.ts +32 -0
- package/dist/core/resume-cache-checkpoint.d.ts.map +1 -0
- package/dist/core/resume-cache-checkpoint.js +67 -0
- package/dist/core/resume-cache-checkpoint.js.map +1 -0
- package/dist/core/sdk-types.d.ts +37 -0
- package/dist/core/sdk-types.d.ts.map +1 -1
- package/dist/core/sdk-types.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +57 -28
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager-core.d.ts.map +1 -1
- package/dist/core/session-manager-core.js +12 -3
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-manager-entries.d.ts +13 -0
- package/dist/core/session-manager-entries.d.ts.map +1 -1
- package/dist/core/session-manager-entries.js +38 -6
- package/dist/core/session-manager-entries.js.map +1 -1
- package/dist/core/settings-lock-directory.d.ts.map +1 -1
- package/dist/core/settings-lock-directory.js +2 -1
- package/dist/core/settings-lock-directory.js.map +1 -1
- package/dist/core/storage/node-sqlite-file-gate.d.ts +173 -0
- package/dist/core/storage/node-sqlite-file-gate.d.ts.map +1 -0
- package/dist/core/storage/node-sqlite-file-gate.js +1033 -0
- package/dist/core/storage/node-sqlite-file-gate.js.map +1 -0
- package/dist/core/storage/node-sqlite-thread.d.ts +33 -6
- package/dist/core/storage/node-sqlite-thread.d.ts.map +1 -1
- package/dist/core/storage/node-sqlite-thread.js +72 -2
- package/dist/core/storage/node-sqlite-thread.js.map +1 -1
- package/dist/core/storage/node-sqlite.d.ts.map +1 -1
- package/dist/core/storage/node-sqlite.js +216 -15
- package/dist/core/storage/node-sqlite.js.map +1 -1
- package/dist/core/storage/session/entry-structure.d.ts.map +1 -1
- package/dist/core/storage/session/entry-structure.js +39 -2
- package/dist/core/storage/session/entry-structure.js.map +1 -1
- package/dist/core/storage/session/session-resume.d.ts.map +1 -1
- package/dist/core/storage/session/session-resume.js +1 -0
- package/dist/core/storage/session/session-resume.js.map +1 -1
- package/dist/core/storage/session/session-search-index.d.ts.map +1 -1
- package/dist/core/storage/session/session-search-index.js +56 -9
- package/dist/core/storage/session/session-search-index.js.map +1 -1
- package/dist/core/storage/statement-sequence.d.ts +36 -0
- package/dist/core/storage/statement-sequence.d.ts.map +1 -0
- package/dist/core/storage/statement-sequence.js +22 -0
- package/dist/core/storage/statement-sequence.js.map +1 -0
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +13 -4
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tasks/heartbeat-notice.d.ts.map +1 -1
- package/dist/core/tasks/heartbeat-notice.js +2 -1
- package/dist/core/tasks/heartbeat-notice.js.map +1 -1
- package/dist/core/tool-loadout.d.ts +4 -2
- package/dist/core/tool-loadout.d.ts.map +1 -1
- package/dist/core/tool-loadout.js +27 -5
- package/dist/core/tool-loadout.js.map +1 -1
- package/dist/core/tools/history-regex-worker.d.ts.map +1 -1
- package/dist/core/tools/history-regex-worker.js +2 -1
- package/dist/core/tools/history-regex-worker.js.map +1 -1
- package/dist/core/tools/powershell.d.ts +22 -22
- package/dist/core/tools/sqlite-selector-connection.d.ts.map +1 -1
- package/dist/core/tools/sqlite-selector-connection.js +7 -0
- package/dist/core/tools/sqlite-selector-connection.js.map +1 -1
- package/dist/core/transformed-system-prompt.d.ts +92 -0
- package/dist/core/transformed-system-prompt.d.ts.map +1 -0
- package/dist/core/transformed-system-prompt.js +240 -0
- package/dist/core/transformed-system-prompt.js.map +1 -0
- package/dist/extensions/codemode/execute.js +1 -1
- package/dist/extensions/codemode/execute.js.map +1 -1
- package/dist/extensions/codemode/tool.d.ts.map +1 -1
- package/dist/extensions/codemode/tool.js +16 -3
- package/dist/extensions/codemode/tool.js.map +1 -1
- package/dist/extensions/llama/ui.d.ts.map +1 -1
- package/dist/extensions/llama/ui.js +13 -8
- package/dist/extensions/llama/ui.js.map +1 -1
- package/dist/extensions/mcp/config.d.ts +2 -0
- package/dist/extensions/mcp/config.d.ts.map +1 -1
- package/dist/extensions/mcp/config.js +5 -0
- package/dist/extensions/mcp/config.js.map +1 -1
- package/dist/extensions/mcp/index.d.ts +4 -0
- package/dist/extensions/mcp/index.d.ts.map +1 -1
- package/dist/extensions/mcp/index.js +289 -64
- package/dist/extensions/mcp/index.js.map +1 -1
- package/dist/extensions/mcp/runtime.d.ts +1 -1
- package/dist/extensions/mcp/runtime.d.ts.map +1 -1
- package/dist/extensions/mcp/runtime.js +2 -2
- package/dist/extensions/mcp/runtime.js.map +1 -1
- package/dist/extensions/mcp/tool-records.d.ts +58 -0
- package/dist/extensions/mcp/tool-records.d.ts.map +1 -0
- package/dist/extensions/mcp/tool-records.js +129 -0
- package/dist/extensions/mcp/tool-records.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/modes/interactive/components/agent-panel.d.ts +2 -4
- package/dist/modes/interactive/components/agent-panel.d.ts.map +1 -1
- package/dist/modes/interactive/components/agent-panel.js +65 -80
- package/dist/modes/interactive/components/agent-panel.js.map +1 -1
- package/dist/modes/interactive/components/compaction-boundary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-boundary-message.js +3 -3
- package/dist/modes/interactive/components/compaction-boundary-message.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +35 -28
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/notice-line.d.ts +16 -0
- package/dist/modes/interactive/components/notice-line.d.ts.map +1 -1
- package/dist/modes/interactive/components/notice-line.js +7 -0
- package/dist/modes/interactive/components/notice-line.js.map +1 -1
- package/dist/modes/interactive/components/prompt-slot.d.ts +1 -0
- package/dist/modes/interactive/components/prompt-slot.d.ts.map +1 -1
- package/dist/modes/interactive/components/prompt-slot.js +8 -4
- package/dist/modes/interactive/components/prompt-slot.js.map +1 -1
- package/dist/modes/interactive/components/task-board.d.ts +0 -1
- package/dist/modes/interactive/components/task-board.d.ts.map +1 -1
- package/dist/modes/interactive/components/task-board.js +6 -14
- package/dist/modes/interactive/components/task-board.js.map +1 -1
- package/dist/modes/interactive/components/task-row.d.ts.map +1 -1
- package/dist/modes/interactive/components/task-row.js +7 -6
- package/dist/modes/interactive/components/task-row.js.map +1 -1
- package/dist/modes/interactive/components/token-segment.d.ts +2 -1
- package/dist/modes/interactive/components/token-segment.d.ts.map +1 -1
- package/dist/modes/interactive/components/token-segment.js +2 -4
- package/dist/modes/interactive/components/token-segment.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-content.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector-content.js +2 -2
- package/dist/modes/interactive/components/tree-selector-content.js.map +1 -1
- package/dist/modes/interactive/components/working-run-meter.d.ts +0 -1
- package/dist/modes/interactive/components/working-run-meter.d.ts.map +1 -1
- package/dist/modes/interactive/components/working-run-meter.js +0 -9
- package/dist/modes/interactive/components/working-run-meter.js.map +1 -1
- package/dist/modes/interactive/extension-command-hold.d.ts +25 -0
- package/dist/modes/interactive/extension-command-hold.d.ts.map +1 -0
- package/dist/modes/interactive/extension-command-hold.js +45 -0
- package/dist/modes/interactive/extension-command-hold.js.map +1 -0
- package/dist/modes/interactive/interactive-agent-events.js +2 -1
- package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-context.js +18 -10
- package/dist/modes/interactive/interactive-extension-context.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-custom-ui.js +3 -0
- package/dist/modes/interactive/interactive-extension-custom-ui.js.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.js +54 -13
- package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
- package/dist/modes/interactive/interactive-model-routing.d.ts +6 -0
- package/dist/modes/interactive/interactive-model-routing.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-model-routing.js +15 -9
- package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-prompt-turn.js +4 -0
- package/dist/modes/interactive/interactive-prompt-turn.js.map +1 -1
- package/dist/modes/interactive/interactive-queueing.d.ts +7 -0
- package/dist/modes/interactive/interactive-queueing.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-queueing.js +47 -1
- package/dist/modes/interactive/interactive-queueing.js.map +1 -1
- package/dist/modes/interactive/interactive-session-routing.js +6 -0
- package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-slash-commands.js +165 -65
- package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
- package/dist/modes/interactive/screen-hold.d.ts +3 -0
- package/dist/modes/interactive/screen-hold.d.ts.map +1 -1
- package/dist/modes/interactive/screen-hold.js +9 -1
- package/dist/modes/interactive/screen-hold.js.map +1 -1
- package/dist/modes/interactive-engine/engine-health.d.ts +11 -3
- package/dist/modes/interactive-engine/engine-health.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-health.js +5 -4
- package/dist/modes/interactive-engine/engine-health.js.map +1 -1
- package/dist/modes/interactive-engine/engine-quit-intent.d.ts +7 -0
- package/dist/modes/interactive-engine/engine-quit-intent.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-quit-intent.js +19 -0
- package/dist/modes/interactive-engine/engine-quit-intent.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.d.ts +18 -0
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js +56 -4
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
- package/dist/modes/interactive-engine/protocol.d.ts +7 -0
- package/dist/modes/interactive-engine/protocol.d.ts.map +1 -1
- package/dist/modes/interactive-engine/protocol.js +1 -0
- package/dist/modes/interactive-engine/protocol.js.map +1 -1
- package/dist/modes/rpc/agent-panel-bridge.d.ts.map +1 -1
- package/dist/modes/rpc/agent-panel-bridge.js +0 -13
- package/dist/modes/rpc/agent-panel-bridge.js.map +1 -1
- package/dist/modes/rpc/rpc-client-process.d.ts +14 -1
- package/dist/modes/rpc/rpc-client-process.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client-process.js +74 -10
- package/dist/modes/rpc/rpc-client-process.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +27 -1
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +81 -5
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-event-buffer.d.ts +2 -0
- package/dist/modes/rpc/rpc-event-buffer.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-event-buffer.js +9 -0
- package/dist/modes/rpc/rpc-event-buffer.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +16 -3
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-session-binding.d.ts +7 -1
- package/dist/modes/rpc/rpc-session-binding.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-session-binding.js +10 -2
- package/dist/modes/rpc/rpc-session-binding.js.map +1 -1
- package/dist/utils/image-resize.d.ts.map +1 -1
- package/dist/utils/image-resize.js +2 -1
- package/dist/utils/image-resize.js.map +1 -1
- package/dist/utils/interactive-engine-bootstrap.d.ts +2 -0
- package/dist/utils/interactive-engine-bootstrap.d.ts.map +1 -1
- package/dist/utils/interactive-engine-bootstrap.js +1 -0
- package/dist/utils/interactive-engine-bootstrap.js.map +1 -1
- package/dist/utils/interactive-engine-env.d.ts +2 -0
- package/dist/utils/interactive-engine-env.d.ts.map +1 -1
- package/dist/utils/interactive-engine-env.js +1 -0
- package/dist/utils/interactive-engine-env.js.map +1 -1
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +2 -0
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/token-count.d.ts +8 -0
- package/dist/utils/token-count.d.ts.map +1 -0
- package/dist/utils/token-count.js +25 -0
- package/dist/utils/token-count.js.map +1 -0
- package/dist/utils/worker-threads.d.ts +18 -0
- package/dist/utils/worker-threads.d.ts.map +1 -0
- package/dist/utils/worker-threads.js +28 -0
- package/dist/utils/worker-threads.js.map +1 -0
- package/docs/background-tasks.md +13 -12
- package/docs/compaction.md +2 -2
- package/docs/development.md +1 -1
- package/docs/extensions/api-reference.md +5 -3
- package/docs/extensions/events.md +2 -0
- package/docs/mcp-servers.md +1 -1
- package/docs/settings.md +2 -0
- package/docs/storage.md +3 -1
- package/docs/subagents.md +6 -2
- package/docs/usage.md +1 -1
- package/npm-shrinkwrap.json +49 -49
- package/package.json +6 -6
|
@@ -14837,7 +14837,6 @@ var REMOVED_SUBAGENT_ACTIONS = ["kill", "interrupt"];
|
|
|
14837
14837
|
function removedSubagentActionMessage(action) {
|
|
14838
14838
|
return `The subagent action "${action}" was removed. Use { action: "quit", id } to stop a child gracefully; it stays resumable with { action: "resume", id, message? }.`;
|
|
14839
14839
|
}
|
|
14840
|
-
var DEFAULT_FORK_PREAMBLE = "You are a delegated subagent running from a fork of the parent session. " + "Treat the inherited conversation as reference-only context, not a live thread to continue. " + "Do not continue or answer prior messages as if they are waiting for a reply. " + "Your sole job is to execute the task below and return a focused result for that task using your tools.";
|
|
14841
14840
|
function normalizeTopLevelParallelValue(value) {
|
|
14842
14841
|
const parsed = typeof value === "number" ? value : typeof value === "string" ? Number(value) : NaN;
|
|
14843
14842
|
if (!Number.isInteger(parsed) || parsed < 1)
|
|
@@ -14853,18 +14852,6 @@ function resolveTopLevelParallelConcurrency(override, configValue) {
|
|
|
14853
14852
|
function resolveTopLevelParallelRunningCapacity(value) {
|
|
14854
14853
|
return normalizeTopLevelParallelValue(value) ?? DEFAULT_RUNNING_CAPACITY;
|
|
14855
14854
|
}
|
|
14856
|
-
function wrapForkTask(task, preamble) {
|
|
14857
|
-
if (preamble === false)
|
|
14858
|
-
return task;
|
|
14859
|
-
const effectivePreamble = preamble ?? DEFAULT_FORK_PREAMBLE;
|
|
14860
|
-
const wrappedPrefix = `${effectivePreamble}
|
|
14861
|
-
|
|
14862
|
-
Task:
|
|
14863
|
-
`;
|
|
14864
|
-
if (task.startsWith(wrappedPrefix))
|
|
14865
|
-
return task;
|
|
14866
|
-
return `${wrappedPrefix}${task}`;
|
|
14867
|
-
}
|
|
14868
14855
|
// dist/builtin/subagents/src/runs/shared/named-worktree.ts
|
|
14869
14856
|
import { createHash } from "node:crypto";
|
|
14870
14857
|
import { constants as fsConstants } from "node:fs";
|
|
@@ -18153,10 +18140,7 @@ import * as path11 from "node:path";
|
|
|
18153
18140
|
import { getAgentDir as getAtomicAgentDir, sliceHead as sliceHead3 } from "@bastani/atomic";
|
|
18154
18141
|
|
|
18155
18142
|
// dist/builtin/subagents/src/shared/formatters.ts
|
|
18156
|
-
import { formatModelReferenceLabel, sliceHead as sliceHead2 } from "@bastani/atomic";
|
|
18157
|
-
function formatTokens(n) {
|
|
18158
|
-
return n < 1000 ? String(n) : n < 1e4 ? `${(n / 1000).toFixed(1)}k` : `${Math.round(n / 1000)}k`;
|
|
18159
|
-
}
|
|
18143
|
+
import { formatModelReferenceLabel, formatTokenCount, sliceHead as sliceHead2 } from "@bastani/atomic";
|
|
18160
18144
|
function formatModelThinking(model, thinking) {
|
|
18161
18145
|
const explicitThinking = THINKING_LEVELS.find((level) => level === thinking?.trim());
|
|
18162
18146
|
if (!model)
|
|
@@ -18168,13 +18152,13 @@ function formatUsage(u) {
|
|
|
18168
18152
|
if (u.turns)
|
|
18169
18153
|
parts.push(`${u.turns} turn${u.turns > 1 ? "s" : ""}`);
|
|
18170
18154
|
if (u.input)
|
|
18171
|
-
parts.push(`in:${
|
|
18155
|
+
parts.push(`in:${formatTokenCount(u.input)}`);
|
|
18172
18156
|
if (u.output)
|
|
18173
|
-
parts.push(`out:${
|
|
18157
|
+
parts.push(`out:${formatTokenCount(u.output)}`);
|
|
18174
18158
|
if (u.cacheRead)
|
|
18175
|
-
parts.push(`R${
|
|
18159
|
+
parts.push(`R${formatTokenCount(u.cacheRead)}`);
|
|
18176
18160
|
if (u.cacheWrite)
|
|
18177
|
-
parts.push(`W${
|
|
18161
|
+
parts.push(`W${formatTokenCount(u.cacheWrite)}`);
|
|
18178
18162
|
if (u.cost)
|
|
18179
18163
|
parts.push(`$${u.cost.toFixed(4)}`);
|
|
18180
18164
|
return parts.join(" ");
|
|
@@ -19193,7 +19177,7 @@ import {
|
|
|
19193
19177
|
getSkillCatalog,
|
|
19194
19178
|
isPathInside as isPathInside3,
|
|
19195
19179
|
isSessionStartTimeoutError,
|
|
19196
|
-
SessionManager as
|
|
19180
|
+
SessionManager as SessionManager3,
|
|
19197
19181
|
SettingsManager,
|
|
19198
19182
|
sliceHead as sliceHead4,
|
|
19199
19183
|
spanElapsedMs as spanElapsedMs2,
|
|
@@ -20232,6 +20216,95 @@ function resolveChildModePolicy(spec) {
|
|
|
20232
20216
|
};
|
|
20233
20217
|
}
|
|
20234
20218
|
|
|
20219
|
+
// dist/builtin/subagents/src/runs/inprocess/prompt-behavior.ts
|
|
20220
|
+
import { hasRecordedTransformedPrompt, startedAsFork } from "@bastani/atomic";
|
|
20221
|
+
|
|
20222
|
+
// dist/builtin/subagents/src/shared/fork-context.ts
|
|
20223
|
+
import { SessionManager as SessionManager2 } from "@bastani/atomic";
|
|
20224
|
+
var SUBAGENT_FORK_START_TYPE = "subagent-fork-start";
|
|
20225
|
+
function subagentForkStartIndex(branch, sessionId) {
|
|
20226
|
+
return branch.findLastIndex((entry) => entry.type === "custom" && entry.customType === SUBAGENT_FORK_START_TYPE && entry.data?.sessionId === sessionId);
|
|
20227
|
+
}
|
|
20228
|
+
|
|
20229
|
+
class SubagentForkContextError extends Error {
|
|
20230
|
+
parentSessionId;
|
|
20231
|
+
reason;
|
|
20232
|
+
constructor(parentSessionId, reason, options) {
|
|
20233
|
+
super(`Cannot fork subagent session ${JSON.stringify(parentSessionId)}: ${reason}`, options);
|
|
20234
|
+
this.parentSessionId = parentSessionId;
|
|
20235
|
+
this.reason = reason;
|
|
20236
|
+
this.name = "SubagentForkContextError";
|
|
20237
|
+
}
|
|
20238
|
+
}
|
|
20239
|
+
function resolveSubagentContext(value) {
|
|
20240
|
+
return value === "fork" ? "fork" : "fresh";
|
|
20241
|
+
}
|
|
20242
|
+
function settledForkLeaf(branch, leafId) {
|
|
20243
|
+
const answered = new Set;
|
|
20244
|
+
for (let index = branch.length - 1;index >= 0; index--) {
|
|
20245
|
+
const entry = branch[index];
|
|
20246
|
+
if (entry.type !== "message")
|
|
20247
|
+
continue;
|
|
20248
|
+
const message = entry.message;
|
|
20249
|
+
if (message.role === "toolResult") {
|
|
20250
|
+
answered.add(message.toolCallId);
|
|
20251
|
+
continue;
|
|
20252
|
+
}
|
|
20253
|
+
if (message.role === "user")
|
|
20254
|
+
return leafId;
|
|
20255
|
+
if (message.role !== "assistant")
|
|
20256
|
+
continue;
|
|
20257
|
+
const inFlight = message.content.some((block) => block.type === "toolCall" && !answered.has(block.id));
|
|
20258
|
+
return inFlight ? entry.parentId : leafId;
|
|
20259
|
+
}
|
|
20260
|
+
return leafId;
|
|
20261
|
+
}
|
|
20262
|
+
function createForkContextResolver(sessionManager, requestedContext) {
|
|
20263
|
+
if (resolveSubagentContext(requestedContext) !== "fork") {
|
|
20264
|
+
return { sessionManagerForIndex: async () => {
|
|
20265
|
+
return;
|
|
20266
|
+
} };
|
|
20267
|
+
}
|
|
20268
|
+
const parentSessionId = sessionManager.getSessionId();
|
|
20269
|
+
const store = sessionManager.getSessionStore();
|
|
20270
|
+
const cwd = sessionManager.getCwd();
|
|
20271
|
+
const parentLeafId = sessionManager.getLeafId();
|
|
20272
|
+
if (parentLeafId === null)
|
|
20273
|
+
throw new SubagentForkContextError(parentSessionId, "no_leaf");
|
|
20274
|
+
const leafId = settledForkLeaf(sessionManager.getBranch(), parentLeafId);
|
|
20275
|
+
if (leafId === null)
|
|
20276
|
+
throw new SubagentForkContextError(parentSessionId, "no_leaf");
|
|
20277
|
+
const openFork = sessionManager.captureFork(leafId);
|
|
20278
|
+
const children = new Map;
|
|
20279
|
+
const opening = new Map;
|
|
20280
|
+
return {
|
|
20281
|
+
sessionManagerForIndex(index = 0) {
|
|
20282
|
+
const pending = opening.get(index);
|
|
20283
|
+
if (pending)
|
|
20284
|
+
return pending;
|
|
20285
|
+
const saved = children.get(index);
|
|
20286
|
+
const live = saved?.manager.deref();
|
|
20287
|
+
if (live)
|
|
20288
|
+
return Promise.resolve(live);
|
|
20289
|
+
const child = (async () => {
|
|
20290
|
+
try {
|
|
20291
|
+
const manager = saved ? await SessionManager2.open(store, saved.id, cwd) : await openFork();
|
|
20292
|
+
if (!saved) {
|
|
20293
|
+
await manager.appendCustomEntry(SUBAGENT_FORK_START_TYPE, { sessionId: manager.getSessionId() });
|
|
20294
|
+
}
|
|
20295
|
+
children.set(index, { id: manager.getSessionId(), manager: new WeakRef(manager) });
|
|
20296
|
+
return manager;
|
|
20297
|
+
} catch (cause) {
|
|
20298
|
+
throw new SubagentForkContextError(parentSessionId, "fork_failed", { cause });
|
|
20299
|
+
}
|
|
20300
|
+
})();
|
|
20301
|
+
opening.set(index, child);
|
|
20302
|
+
child.then(() => opening.delete(index), () => opening.delete(index));
|
|
20303
|
+
return child;
|
|
20304
|
+
}
|
|
20305
|
+
};
|
|
20306
|
+
}
|
|
20307
|
+
|
|
20235
20308
|
// dist/builtin/subagents/src/runs/inprocess/prompt-behavior.ts
|
|
20236
20309
|
var CHILD_SUBAGENT_BOUNDARY_INSTRUCTIONS = [
|
|
20237
20310
|
"You are a child subagent, not the parent orchestrator.",
|
|
@@ -20406,10 +20479,77 @@ function createInProcessChildSystemPromptTransform(policy, explicitSkillInjectio
|
|
|
20406
20479
|
${explicitSkillInjection}` : rewritten;
|
|
20407
20480
|
};
|
|
20408
20481
|
}
|
|
20409
|
-
function
|
|
20482
|
+
function createInProcessChildSystemPromptSectionsTransform(policy, explicitSkillInjection = "") {
|
|
20483
|
+
return (sections) => {
|
|
20484
|
+
const child = {
|
|
20485
|
+
subagent_boundary: policy.fanoutAuthorized ? CHILD_FANOUT_BOUNDARY_INSTRUCTIONS : CHILD_SUBAGENT_BOUNDARY_INSTRUCTIONS
|
|
20486
|
+
};
|
|
20487
|
+
for (const [name, text] of Object.entries(sections)) {
|
|
20488
|
+
let rewritten = text;
|
|
20489
|
+
if (!policy.inheritProjectContext)
|
|
20490
|
+
rewritten = stripProjectContext(rewritten);
|
|
20491
|
+
if (!policy.inheritSkills)
|
|
20492
|
+
rewritten = stripInheritedSkills(rewritten);
|
|
20493
|
+
rewritten = stripChildBoundaryInstructions(stripSubagentOrchestrationSkill(rewritten));
|
|
20494
|
+
if (rewritten.trim())
|
|
20495
|
+
child[name] = rewritten;
|
|
20496
|
+
}
|
|
20497
|
+
if (explicitSkillInjection)
|
|
20498
|
+
child.subagent_skills = explicitSkillInjection;
|
|
20499
|
+
return child;
|
|
20500
|
+
};
|
|
20501
|
+
}
|
|
20502
|
+
function forkedChildTools(tools, parentToolNames) {
|
|
20503
|
+
if (tools === undefined || tools.includes("codemode") || !parentToolNames?.includes("codemode"))
|
|
20504
|
+
return { tools: tools && [...tools], codemodeRoutingOnly: false };
|
|
20505
|
+
return { tools: [...tools, "codemode"], codemodeRoutingOnly: true };
|
|
20506
|
+
}
|
|
20507
|
+
function forkedParentSessionId(session) {
|
|
20508
|
+
const header = session.getHeader();
|
|
20509
|
+
if (header?.parentSessionId === undefined)
|
|
20510
|
+
return;
|
|
20511
|
+
const { messages } = session.buildSessionContext();
|
|
20512
|
+
if (startedAsFork(messages))
|
|
20513
|
+
return header.parentSessionId;
|
|
20514
|
+
if (hasRecordedTransformedPrompt(messages))
|
|
20515
|
+
return;
|
|
20516
|
+
const branch = session.getBranch();
|
|
20517
|
+
const forkStart = subagentForkStartIndex(branch, header.id);
|
|
20518
|
+
const ownTurns = forkStart === -1 ? messages.some((message) => message.role === "assistant" && message.timestamp > Date.parse(header.createdAt)) : branch.slice(forkStart + 1).some((entry) => entry.type === "message" && entry.message.role === "assistant");
|
|
20519
|
+
return ownTurns ? undefined : header.parentSessionId;
|
|
20520
|
+
}
|
|
20521
|
+
function forkedChildNote(tools) {
|
|
20522
|
+
return [
|
|
20523
|
+
"You are now a subagent started from the conversation above. That conversation is your parent's context: its tool calls are history, and their sessions and processes are not yours. Follow your own role and task below, and report your result to your parent.",
|
|
20524
|
+
`The tools you may call: ${tools.tools.join(", ") || "none"}. A call to any other tool declared above fails.`,
|
|
20525
|
+
...tools.throughCodemode.length > 0 ? [
|
|
20526
|
+
`Call ${tools.throughCodemode.join(", ")} through codemode as \`tools.<name>(args)\`; codemode's tool search and descriptions show their arguments.`
|
|
20527
|
+
] : []
|
|
20528
|
+
].join(`
|
|
20529
|
+
`);
|
|
20530
|
+
}
|
|
20531
|
+
function createInProcessChildPromptBehavior(policy, explicitSkillInjection = "", fork) {
|
|
20532
|
+
const systemPromptSections = {
|
|
20533
|
+
key: JSON.stringify([policy.inheritProjectContext, policy.inheritSkills, policy.fanoutAuthorized]),
|
|
20534
|
+
transform: createInProcessChildSystemPromptSectionsTransform(policy, explicitSkillInjection)
|
|
20535
|
+
};
|
|
20536
|
+
const systemPromptTransform = createInProcessChildSystemPromptTransform(policy, explicitSkillInjection);
|
|
20537
|
+
if (fork)
|
|
20538
|
+
return {
|
|
20539
|
+
systemPromptTransform,
|
|
20540
|
+
systemPromptSections: {
|
|
20541
|
+
...systemPromptSections,
|
|
20542
|
+
fork: {
|
|
20543
|
+
sessionId: fork.parentSessionId,
|
|
20544
|
+
...fork.parentHiddenTools?.length ? { hiddenTools: fork.parentHiddenTools } : {},
|
|
20545
|
+
note: forkedChildNote
|
|
20546
|
+
}
|
|
20547
|
+
}
|
|
20548
|
+
};
|
|
20410
20549
|
const project = (messages) => stripParentOnlySubagentMessages(messages, policy.fanoutAuthorized);
|
|
20411
20550
|
return {
|
|
20412
|
-
systemPromptTransform
|
|
20551
|
+
systemPromptTransform,
|
|
20552
|
+
systemPromptSections,
|
|
20413
20553
|
initialContextTransform: project,
|
|
20414
20554
|
[forkReplayFilter]: {
|
|
20415
20555
|
project,
|
|
@@ -21283,12 +21423,80 @@ function statsFor(session, fallbackSessionId) {
|
|
|
21283
21423
|
};
|
|
21284
21424
|
}
|
|
21285
21425
|
}
|
|
21286
|
-
function
|
|
21426
|
+
function attemptLaunch(manager) {
|
|
21427
|
+
const leafId = manager.getLeafId();
|
|
21428
|
+
if (leafId === null)
|
|
21429
|
+
return { leafId, leafSeq: 0 };
|
|
21430
|
+
return { leafId, leafSeq: typeof manager.getEntrySeq === "function" ? manager.getEntrySeq(leafId) : undefined };
|
|
21431
|
+
}
|
|
21432
|
+
function assistantTurns(entries) {
|
|
21433
|
+
return entries.flatMap((entry) => entry.type === "message" && entry.message.role === "assistant" ? [entry.message] : []);
|
|
21434
|
+
}
|
|
21435
|
+
function completedTurn(turn) {
|
|
21436
|
+
return turn.stopReason !== "error" && turn.stopReason !== "aborted";
|
|
21437
|
+
}
|
|
21438
|
+
function turnsSinceLaunch(manager, launch) {
|
|
21287
21439
|
const branch = manager.getBranch();
|
|
21288
|
-
const
|
|
21289
|
-
|
|
21290
|
-
|
|
21291
|
-
|
|
21440
|
+
const heldFrom = typeof manager.getHeldTail === "function" ? manager.getHeldTail().fromSeq : 1;
|
|
21441
|
+
const { leafSeq } = launch;
|
|
21442
|
+
if (leafSeq === undefined || leafSeq >= heldFrom || leafSeq === 0 && heldFrom <= 1 || typeof manager.getEntrySeq !== "function" || typeof manager.readHistory !== "function") {
|
|
21443
|
+
const launchIndex = launch.leafId === null ? -1 : branch.findIndex((entry) => entry.id === launch.leafId);
|
|
21444
|
+
if (launch.leafId !== null && launchIndex === -1)
|
|
21445
|
+
return [];
|
|
21446
|
+
return assistantTurns(branch.slice(launchIndex + 1));
|
|
21447
|
+
}
|
|
21448
|
+
const seqOf = (entry) => manager.getEntrySeq(entry.id) ?? 0;
|
|
21449
|
+
const held = assistantTurns(branch.filter((entry) => seqOf(entry) >= Math.max(heldFrom, leafSeq + 1)));
|
|
21450
|
+
let hasText = outputFor(held) !== "";
|
|
21451
|
+
let decided = held.at(-1)?.stopReason === "error" || held.some(completedTurn);
|
|
21452
|
+
const leaf = branch.at(-1);
|
|
21453
|
+
if (hasText && decided || leaf === undefined)
|
|
21454
|
+
return held;
|
|
21455
|
+
const branchLeafSeq = seqOf(leaf);
|
|
21456
|
+
return (async () => {
|
|
21457
|
+
const earlier = [];
|
|
21458
|
+
try {
|
|
21459
|
+
const pages = manager.readHistory({
|
|
21460
|
+
branchLeafSeq,
|
|
21461
|
+
fromSeq: leafSeq + 1,
|
|
21462
|
+
toSeq: heldFrom - 1,
|
|
21463
|
+
direction: "backward"
|
|
21464
|
+
});
|
|
21465
|
+
read:
|
|
21466
|
+
for await (const { items } of pages) {
|
|
21467
|
+
for (let index = items.length - 1;index >= 0; index -= 1) {
|
|
21468
|
+
const entry = await storedEntry(manager, items[index]);
|
|
21469
|
+
if (entry.type !== "message" || entry.message.role !== "assistant")
|
|
21470
|
+
continue;
|
|
21471
|
+
const turn = entry.message;
|
|
21472
|
+
if (held.length === 0 && earlier.length === 0 && turn.stopReason === "error")
|
|
21473
|
+
decided = true;
|
|
21474
|
+
earlier.push({ seq: items[index].seq, turn });
|
|
21475
|
+
hasText ||= outputFor([turn]) !== "";
|
|
21476
|
+
decided ||= completedTurn(turn);
|
|
21477
|
+
if (hasText && decided)
|
|
21478
|
+
break read;
|
|
21479
|
+
}
|
|
21480
|
+
}
|
|
21481
|
+
} catch {
|
|
21482
|
+
const known = new Map(earlier.map(({ seq, turn }) => [seq, turn]));
|
|
21483
|
+
for (const entry of branch) {
|
|
21484
|
+
const seq = seqOf(entry);
|
|
21485
|
+
if (seq > leafSeq && seq < heldFrom && entry.type === "message" && entry.message.role === "assistant")
|
|
21486
|
+
known.set(seq, entry.message);
|
|
21487
|
+
}
|
|
21488
|
+
return [...[...known].sort(([left], [right]) => left - right).map(([, turn]) => turn), ...held];
|
|
21489
|
+
}
|
|
21490
|
+
return [...earlier.reverse().map(({ turn }) => turn), ...held];
|
|
21491
|
+
})();
|
|
21492
|
+
}
|
|
21493
|
+
async function storedEntry(manager, item) {
|
|
21494
|
+
if ("entry" in item)
|
|
21495
|
+
return item.entry;
|
|
21496
|
+
const chunks = [];
|
|
21497
|
+
for await (const chunk of manager.readHistoryChunks(item))
|
|
21498
|
+
chunks.push(chunk);
|
|
21499
|
+
return JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
21292
21500
|
}
|
|
21293
21501
|
function hasPartialHistory(manager) {
|
|
21294
21502
|
if (typeof manager.hasFullHistory === "function" && !manager.hasFullHistory())
|
|
@@ -21342,17 +21550,16 @@ function finalAnswerOf(messages) {
|
|
|
21342
21550
|
function unsavedWorkCause(error, keptAnswer) {
|
|
21343
21551
|
return keptAnswer ? `The child's final answer could not be saved to its session (${error}). Its answer is kept in its result, but its session file does not hold it.` : `The child's session could not save its work (${error}).`;
|
|
21344
21552
|
}
|
|
21345
|
-
function outputFor(
|
|
21346
|
-
return lastNonEmptyAssistantText(
|
|
21553
|
+
function outputFor(ownTurns) {
|
|
21554
|
+
return lastNonEmptyAssistantText(ownTurns);
|
|
21347
21555
|
}
|
|
21348
|
-
function failedChildCause(
|
|
21349
|
-
const ownTurns = ownMessages.flatMap((message) => message.role === "assistant" ? [message] : []);
|
|
21556
|
+
function failedChildCause(ownTurns) {
|
|
21350
21557
|
const lastTurn = ownTurns.at(-1);
|
|
21351
21558
|
if (lastTurn?.stopReason === "error") {
|
|
21352
21559
|
const modelError = lastTurn.errorMessage?.trim() || "the model request failed without an error message";
|
|
21353
21560
|
return { cause: modelError, modelError };
|
|
21354
21561
|
}
|
|
21355
|
-
if (ownTurns.some(
|
|
21562
|
+
if (ownTurns.some(completedTurn))
|
|
21356
21563
|
return;
|
|
21357
21564
|
const errorMessage = ownTurns.findLast((turn) => turn.errorMessage?.trim())?.errorMessage?.trim();
|
|
21358
21565
|
return { cause: errorMessage || "Child ended without completing an assistant turn of its own." };
|
|
@@ -21390,10 +21597,10 @@ function assertStartModelAllowed(input) {
|
|
|
21390
21597
|
return;
|
|
21391
21598
|
throw new Error(`Model ${model.provider}/${model.id}${effort ? ` at ${effort} effort` : ""} would run${spec.namedModel ? ` in place of ${spec.namedModel}` : ""}, but the session's fallback policy does not allow it. No other model was used.`);
|
|
21392
21599
|
}
|
|
21393
|
-
async function cancelledEnvelope(session, spec, stats,
|
|
21600
|
+
async function cancelledEnvelope(session, spec, stats, ownTurns) {
|
|
21394
21601
|
return (await recoverCancelledChildOutput({
|
|
21395
21602
|
progressPath: spec.progressPath,
|
|
21396
|
-
assistantText: outputFor(
|
|
21603
|
+
assistantText: outputFor(ownTurns),
|
|
21397
21604
|
toolCount: stats.toolCalls,
|
|
21398
21605
|
sessionPath: session?.sessionFile ?? spec.sessionManager?.getSessionFile(),
|
|
21399
21606
|
...spec.progressArtifactPath ? { progressArtifactPath: spec.progressArtifactPath } : {},
|
|
@@ -21795,7 +22002,7 @@ class SubagentControlRuntime {
|
|
|
21795
22002
|
let session;
|
|
21796
22003
|
let restoringPaused = admitted.spec.resumePaused === true;
|
|
21797
22004
|
let parentCommandTaskOwner;
|
|
21798
|
-
let
|
|
22005
|
+
let ownTurns = () => [];
|
|
21799
22006
|
const executionEnded = new AbortController;
|
|
21800
22007
|
const turnDrainedListeners = new Set;
|
|
21801
22008
|
let termination;
|
|
@@ -21859,9 +22066,9 @@ class SubagentControlRuntime {
|
|
|
21859
22066
|
});
|
|
21860
22067
|
});
|
|
21861
22068
|
try {
|
|
21862
|
-
const canReopenFromStore = admitted.sessionManager instanceof
|
|
21863
|
-
const openOptions = typeof
|
|
21864
|
-
const opening = mkdir6(admitted.sessionDir, { recursive: true }).then(() => admitted.sessionManager ? canReopenFromStore ?
|
|
22069
|
+
const canReopenFromStore = admitted.sessionManager instanceof SessionManager3 && typeof admitted.sessionManager.getSessionStore === "function" && typeof admitted.sessionManager.getEntrySeq === typeof SessionManager3.prototype.getEntrySeq;
|
|
22070
|
+
const openOptions = typeof SessionManager3.prototype.getEntrySeq === "function" ? { history: "tail" } : undefined;
|
|
22071
|
+
const opening = mkdir6(admitted.sessionDir, { recursive: true }).then(() => admitted.sessionManager ? canReopenFromStore ? SessionManager3.open(admitted.sessionManager.getSessionStore(), admitted.sessionManager.getSessionId(), admitted.policy.cwd, openOptions) : Promise.resolve(admitted.sessionManager) : SessionManager3.create(admitted.policy.cwd, admitted.sessionDir));
|
|
21865
22072
|
let startGate;
|
|
21866
22073
|
const prepareChildSession = async () => {
|
|
21867
22074
|
const childOptions = {
|
|
@@ -21929,8 +22136,8 @@ class SubagentControlRuntime {
|
|
|
21929
22136
|
admitted.spec.onChildSession?.(childSession);
|
|
21930
22137
|
if (taskHooks !== undefined)
|
|
21931
22138
|
stopHeldPromptAttention = watchHeldPromptAttention(childSession.sessionId, (report) => taskHooks.reportActivity(report));
|
|
21932
|
-
const
|
|
21933
|
-
|
|
22139
|
+
const launch = attemptLaunch(sessionManager);
|
|
22140
|
+
ownTurns = () => turnsSinceLaunch(sessionManager, launch);
|
|
21934
22141
|
let created;
|
|
21935
22142
|
const prepared = preparing === undefined ? undefined : await beforeStartDeadline(preparing);
|
|
21936
22143
|
if (prepared === undefined) {
|
|
@@ -21952,11 +22159,13 @@ class SubagentControlRuntime {
|
|
|
21952
22159
|
throw new Error("Skills not found: subagent");
|
|
21953
22160
|
}
|
|
21954
22161
|
const skillInjection = buildSkillInjection(selectedSkills.resolved);
|
|
21955
|
-
const
|
|
21956
|
-
const
|
|
22162
|
+
const parentSessionId = forkedParentSessionId(sessionManager);
|
|
22163
|
+
const forked = parentSessionId === undefined ? undefined : forkedChildTools(inherited.tools, inherited.parentToolNames);
|
|
22164
|
+
const promptBehavior = createInProcessChildPromptBehavior(admitted.policy, skillInjection, parentSessionId === undefined ? undefined : { parentSessionId, parentHiddenTools: inherited.parentHiddenTools });
|
|
21957
22165
|
startBudget.enter("creating-session");
|
|
21958
22166
|
created = await beforeStartDeadline(createAgentSession({
|
|
21959
22167
|
...inherited,
|
|
22168
|
+
...forked ? { tools: forked.tools } : {},
|
|
21960
22169
|
...explicitEffort,
|
|
21961
22170
|
extensionBindings,
|
|
21962
22171
|
customTools: admitted.policy.customTools ?? inherited.customTools,
|
|
@@ -21965,6 +22174,7 @@ class SubagentControlRuntime {
|
|
|
21965
22174
|
onResourceAdmissionWait: (waiting) => startBudget.admissionWait(waiting),
|
|
21966
22175
|
subagentPolicy: {
|
|
21967
22176
|
...admitted.policy,
|
|
22177
|
+
...forked?.codemodeRoutingOnly ? { codemodeRoutingOnly: true } : {},
|
|
21968
22178
|
executionEnded: executionEnded.signal,
|
|
21969
22179
|
onTurnDrained: () => {
|
|
21970
22180
|
for (const listener of turnDrainedListeners)
|
|
@@ -21981,8 +22191,7 @@ class SubagentControlRuntime {
|
|
|
21981
22191
|
},
|
|
21982
22192
|
settingsManager,
|
|
21983
22193
|
sessionManager,
|
|
21984
|
-
...promptBehavior
|
|
21985
|
-
systemPromptTransform
|
|
22194
|
+
...promptBehavior
|
|
21986
22195
|
}), (late) => late.session.dispose().catch(() => {
|
|
21987
22196
|
return;
|
|
21988
22197
|
}));
|
|
@@ -22381,20 +22590,23 @@ class SubagentControlRuntime {
|
|
|
22381
22590
|
...skillReport
|
|
22382
22591
|
};
|
|
22383
22592
|
}
|
|
22593
|
+
const turns = ownTurns();
|
|
22594
|
+
const producedTurns = turns instanceof Promise ? await turns : turns;
|
|
22595
|
+
if (turns instanceof Promise)
|
|
22596
|
+
await terminating;
|
|
22384
22597
|
const unsaved = termination === undefined ? session.getPersistenceFailure() : undefined;
|
|
22385
22598
|
const finalAnswer = unsaved === undefined ? undefined : finalAnswerOf(unsaved.unsavedMessages);
|
|
22386
22599
|
if (finalAnswer !== undefined) {
|
|
22387
22600
|
unsavedAnswer = unsavedAnswerEntry(sessionManager, finalAnswer);
|
|
22388
22601
|
unsavedAnswers.set(sessionManager.getSessionId(), finalAnswer);
|
|
22389
22602
|
}
|
|
22390
|
-
const
|
|
22391
|
-
const
|
|
22392
|
-
const failure = termination === undefined ? failedChildCause(producedMessages) : undefined;
|
|
22603
|
+
const output = outputFor(finalAnswer === undefined ? producedTurns : [...producedTurns, finalAnswer]);
|
|
22604
|
+
const failure = termination === undefined ? failedChildCause(producedTurns) : undefined;
|
|
22393
22605
|
const noOutput = unsaved !== undefined ? unsavedWorkCause(unsaved.error, finalAnswer !== undefined) : failure?.modelError !== undefined && admitted.spec.namedModel !== undefined ? namedModelFailureCause(admitted.spec.namedModel, namedModelId(admitted.spec), attemptedModels, failure.modelError) : failure?.cause;
|
|
22394
22606
|
const status = noOutput === undefined ? attemptStatus(termination) : "error";
|
|
22395
22607
|
this.native.publishChildStatus(admitted.identity.path, nativeStatus(status));
|
|
22396
22608
|
this.native.finishChildAttempt(token, nativeStatus(status));
|
|
22397
|
-
const envelope = termination === PARENT_CANCEL_CAUSE ? await cancelledEnvelope(session, admitted.spec, stats,
|
|
22609
|
+
const envelope = termination === PARENT_CANCEL_CAUSE ? await cancelledEnvelope(session, admitted.spec, stats, producedTurns) : status === "interrupted" ? INTERRUPTED_ENVELOPE : boundedEnvelope(output || noOutput || termination || "(no output)", undefined);
|
|
22398
22610
|
if (status === "ok")
|
|
22399
22611
|
return {
|
|
22400
22612
|
status,
|
|
@@ -22453,7 +22665,7 @@ class SubagentControlRuntime {
|
|
|
22453
22665
|
} : {},
|
|
22454
22666
|
stats,
|
|
22455
22667
|
path: admitted.identity.path,
|
|
22456
|
-
envelope: termination === PARENT_CANCEL_CAUSE && !this.killedChildren.has(admitted.identity.path) ? await cancelledEnvelope(session, admitted.spec, stats,
|
|
22668
|
+
envelope: termination === PARENT_CANCEL_CAUSE && !this.killedChildren.has(admitted.identity.path) ? await cancelledEnvelope(session, admitted.spec, stats, await ownTurns()) : this.killedChildren.has(admitted.identity.path) ? "Killed. This child cannot be resumed." : INTERRUPTED_ENVELOPE,
|
|
22457
22669
|
sessionFile: session?.sessionFile,
|
|
22458
22670
|
...effectiveModelId === undefined ? {} : { model: effectiveModelId },
|
|
22459
22671
|
...effectiveThinking === undefined ? {} : { thinking: effectiveThinking },
|
|
@@ -30419,85 +30631,6 @@ import { randomUUID as randomUUID12 } from "node:crypto";
|
|
|
30419
30631
|
import { mkdir as mkdir10 } from "node:fs/promises";
|
|
30420
30632
|
import * as path21 from "node:path";
|
|
30421
30633
|
|
|
30422
|
-
// dist/builtin/subagents/src/shared/fork-context.ts
|
|
30423
|
-
import { SessionManager as SessionManager3 } from "@bastani/atomic";
|
|
30424
|
-
|
|
30425
|
-
class SubagentForkContextError extends Error {
|
|
30426
|
-
parentSessionId;
|
|
30427
|
-
reason;
|
|
30428
|
-
constructor(parentSessionId, reason, options) {
|
|
30429
|
-
super(`Cannot fork subagent session ${JSON.stringify(parentSessionId)}: ${reason}`, options);
|
|
30430
|
-
this.parentSessionId = parentSessionId;
|
|
30431
|
-
this.reason = reason;
|
|
30432
|
-
this.name = "SubagentForkContextError";
|
|
30433
|
-
}
|
|
30434
|
-
}
|
|
30435
|
-
function resolveSubagentContext(value) {
|
|
30436
|
-
return value === "fork" ? "fork" : "fresh";
|
|
30437
|
-
}
|
|
30438
|
-
function settledForkLeaf(branch, leafId) {
|
|
30439
|
-
const answered = new Set;
|
|
30440
|
-
for (let index = branch.length - 1;index >= 0; index--) {
|
|
30441
|
-
const entry = branch[index];
|
|
30442
|
-
if (entry.type !== "message")
|
|
30443
|
-
continue;
|
|
30444
|
-
const message = entry.message;
|
|
30445
|
-
if (message.role === "toolResult") {
|
|
30446
|
-
answered.add(message.toolCallId);
|
|
30447
|
-
continue;
|
|
30448
|
-
}
|
|
30449
|
-
if (message.role === "user")
|
|
30450
|
-
return leafId;
|
|
30451
|
-
if (message.role !== "assistant")
|
|
30452
|
-
continue;
|
|
30453
|
-
const inFlight = message.content.some((block) => block.type === "toolCall" && !answered.has(block.id));
|
|
30454
|
-
return inFlight ? entry.parentId : leafId;
|
|
30455
|
-
}
|
|
30456
|
-
return leafId;
|
|
30457
|
-
}
|
|
30458
|
-
function createForkContextResolver(sessionManager, requestedContext) {
|
|
30459
|
-
if (resolveSubagentContext(requestedContext) !== "fork") {
|
|
30460
|
-
return { sessionManagerForIndex: async () => {
|
|
30461
|
-
return;
|
|
30462
|
-
} };
|
|
30463
|
-
}
|
|
30464
|
-
const parentSessionId = sessionManager.getSessionId();
|
|
30465
|
-
const store = sessionManager.getSessionStore();
|
|
30466
|
-
const cwd = sessionManager.getCwd();
|
|
30467
|
-
const parentLeafId = sessionManager.getLeafId();
|
|
30468
|
-
if (parentLeafId === null)
|
|
30469
|
-
throw new SubagentForkContextError(parentSessionId, "no_leaf");
|
|
30470
|
-
const leafId = settledForkLeaf(sessionManager.getBranch(), parentLeafId);
|
|
30471
|
-
if (leafId === null)
|
|
30472
|
-
throw new SubagentForkContextError(parentSessionId, "no_leaf");
|
|
30473
|
-
const openFork = sessionManager.captureFork(leafId);
|
|
30474
|
-
const children = new Map;
|
|
30475
|
-
const opening = new Map;
|
|
30476
|
-
return {
|
|
30477
|
-
sessionManagerForIndex(index = 0) {
|
|
30478
|
-
const pending = opening.get(index);
|
|
30479
|
-
if (pending)
|
|
30480
|
-
return pending;
|
|
30481
|
-
const saved = children.get(index);
|
|
30482
|
-
const live = saved?.manager.deref();
|
|
30483
|
-
if (live)
|
|
30484
|
-
return Promise.resolve(live);
|
|
30485
|
-
const child = (async () => {
|
|
30486
|
-
try {
|
|
30487
|
-
const manager = saved ? await SessionManager3.open(store, saved.id, cwd) : await openFork();
|
|
30488
|
-
children.set(index, { id: manager.getSessionId(), manager: new WeakRef(manager) });
|
|
30489
|
-
return manager;
|
|
30490
|
-
} catch (cause) {
|
|
30491
|
-
throw new SubagentForkContextError(parentSessionId, "fork_failed", { cause });
|
|
30492
|
-
}
|
|
30493
|
-
})();
|
|
30494
|
-
opening.set(index, child);
|
|
30495
|
-
child.then(() => opening.delete(index), () => opening.delete(index));
|
|
30496
|
-
return child;
|
|
30497
|
-
}
|
|
30498
|
-
};
|
|
30499
|
-
}
|
|
30500
|
-
|
|
30501
30634
|
// dist/builtin/subagents/src/shared/session-identity.ts
|
|
30502
30635
|
class SubagentSessionIdentityError extends Error {
|
|
30503
30636
|
constructor() {
|
|
@@ -30842,11 +30975,6 @@ async function runParallelPath(data, deps) {
|
|
|
30842
30975
|
const progressDir = firstProgressIndex === -1 ? undefined : join23(artifactsDir, "progress", runId);
|
|
30843
30976
|
if (progressDir)
|
|
30844
30977
|
await writeInitialProgressFile(progressDir);
|
|
30845
|
-
if (params.context === "fork") {
|
|
30846
|
-
for (let i = 0;i < taskTexts.length; i++) {
|
|
30847
|
-
taskTexts[i] = wrapForkTask(taskTexts[i]);
|
|
30848
|
-
}
|
|
30849
|
-
}
|
|
30850
30978
|
const results = await runForegroundParallelTasks({
|
|
30851
30979
|
runWorktrees,
|
|
30852
30980
|
...params.heartbeatMs === undefined ? {} : { heartbeatMs: params.heartbeatMs },
|
|
@@ -31099,9 +31227,6 @@ async function runSinglePath(data, deps) {
|
|
|
31099
31227
|
const effectiveOutput = normalizeSingleOutputOverride(rawOutput, agentConfig.output);
|
|
31100
31228
|
const effectiveOutputMode = params.outputMode ?? "inline";
|
|
31101
31229
|
const progress = resolveSingleProgress(agentConfig, params.progress, task);
|
|
31102
|
-
if (params.context === "fork") {
|
|
31103
|
-
task = wrapForkTask(task);
|
|
31104
|
-
}
|
|
31105
31230
|
const cleanTask = task;
|
|
31106
31231
|
const outputPath = resolveSingleOutputPath(effectiveOutput, ctx.cwd, effectiveCwd);
|
|
31107
31232
|
const outputError = singleOutputSetupError(params, agentConfig, ctx.cwd, effectiveCwd);
|
|
@@ -32568,7 +32693,7 @@ function pulseGlyph(frame) {
|
|
|
32568
32693
|
return PULSE_FRAMES[index % PULSE_FRAMES.length];
|
|
32569
32694
|
}
|
|
32570
32695
|
// dist/builtin/subagents/src/tui/render-result.ts
|
|
32571
|
-
import { getMarkdownTheme, keyHintIfBound as keyHintIfBound3 } from "@bastani/atomic";
|
|
32696
|
+
import { formatTokenCount as formatTokenCount3, getMarkdownTheme, keyHintIfBound as keyHintIfBound3 } from "@bastani/atomic";
|
|
32572
32697
|
|
|
32573
32698
|
// dist/builtin/subagents/src/tui/render-event-formatting.ts
|
|
32574
32699
|
function modelThinkingBadge(theme, model, thinking) {
|
|
@@ -32680,7 +32805,7 @@ function stopResultAnimations() {}
|
|
|
32680
32805
|
import { formatTokenSegment, keyHintIfBound, navEntryKeyParts } from "@bastani/atomic";
|
|
32681
32806
|
|
|
32682
32807
|
// dist/builtin/subagents/src/tui/render-status-progress.ts
|
|
32683
|
-
import { sliceHead as sliceHead6 } from "@bastani/atomic";
|
|
32808
|
+
import { formatTokenCount as formatTokenCount2, sliceHead as sliceHead6 } from "@bastani/atomic";
|
|
32684
32809
|
function extractOutputTarget(task) {
|
|
32685
32810
|
const writeToMatch = task.match(/\[Write to:(?:[^\S\n]*\n)*([^\]\n]+)\]/i);
|
|
32686
32811
|
if (writeToMatch?.[1]?.trim())
|
|
@@ -32739,7 +32864,7 @@ function statJoin(theme, parts) {
|
|
|
32739
32864
|
return parts.filter(Boolean).map((part) => theme.fg("dim", part)).join(` ${theme.fg("dim", "·")} `);
|
|
32740
32865
|
}
|
|
32741
32866
|
function formatTokenStat(tokens) {
|
|
32742
|
-
return `${
|
|
32867
|
+
return `${formatTokenCount2(tokens)} token${tokens === 1 ? "" : "s"}`;
|
|
32743
32868
|
}
|
|
32744
32869
|
function formatToolUseStat(count) {
|
|
32745
32870
|
return `${count} tool use${count === 1 ? "" : "s"}`;
|
|
@@ -33150,7 +33275,7 @@ function renderSubagentResult(result, options, theme) {
|
|
|
33150
33275
|
const isRunning = r.progress?.status === "running";
|
|
33151
33276
|
const icon = isRunning ? theme.fg("warning", "running") : d.parentAskYielded ? theme.fg("warning", "yielded") : r.detached || r.status === "continued" ? theme.fg("warning", "detached") : r.status === "killed" ? theme.fg("warning", "killed (non-resumable)") : isParentCancellation(r.cause) && (r.interrupted || r.status === "interrupted") ? theme.fg("warning", "cancelled") : r.status === "ok" ? theme.fg("success", "ok") : theme.fg("error", "failed");
|
|
33152
33277
|
const output = r.truncation?.text || getSingleResultOutput(r);
|
|
33153
|
-
const progressInfo = isRunning && r.progress ? ` | ${r.progress.toolCount} tools, ${
|
|
33278
|
+
const progressInfo = isRunning && r.progress ? ` | ${r.progress.toolCount} tools, ${formatTokenCount3(r.progress.tokens)} tokens, ${formatDuration(displayProgressDurationMs(r.progress, options.now))}` : r.progressSummary ? ` | ${r.progressSummary.toolCount} tools, ${formatTokenCount3(r.progressSummary.tokens)} tokens, ${formatDuration(r.progressSummary.durationMs)}` : "";
|
|
33154
33279
|
const w = getTermWidth() - 4;
|
|
33155
33280
|
const fit = (text) => expanded ? text : truncLine(text, w);
|
|
33156
33281
|
const modelDisplay = modelThinkingBadge(theme, r.model, r.thinking);
|
|
@@ -33234,7 +33359,7 @@ function renderSubagentResult(result, options, theme) {
|
|
|
33234
33359
|
}
|
|
33235
33360
|
return acc;
|
|
33236
33361
|
}, { toolCount: 0, tokens: 0, durationMs: 0 });
|
|
33237
|
-
const summaryStr = totalSummary.toolCount || totalSummary.tokens ? ` | ${totalSummary.toolCount} tools, ${
|
|
33362
|
+
const summaryStr = totalSummary.toolCount || totalSummary.tokens ? ` | ${totalSummary.toolCount} tools, ${formatTokenCount3(totalSummary.tokens)} tokens, ${formatDuration(totalSummary.durationMs)}` : "";
|
|
33238
33363
|
const modeLabel = d.mode;
|
|
33239
33364
|
const multiLabel = buildMultiProgressLabel(d, hasRunning);
|
|
33240
33365
|
const w = getTermWidth() - 4;
|
|
@@ -33689,7 +33814,7 @@ EXECUTION (use exactly ONE mode):
|
|
|
33689
33814
|
• SINGLE: { agent, task?, progress? } - one focused task; progress:true maintains a run-scoped progress.md under isolated artifact storage without writing it into the child cwd (separate from includeProgress, which only returns runtime telemetry); omit task for self-contained agents
|
|
33690
33815
|
• PARALLEL: { tasks: [{agent,task,count?,output?,reads?,progress?,worktree?}, ...], concurrency?: number, worktree?: true } - independent concurrent tasks (worktree: true isolates each task in a temporary git worktree, removed afterwards)
|
|
33691
33816
|
• Named worktree: worktree: { branch, base?, path? } on a SINGLE call, a PARALLEL call, or a task runs the child in that branch's worktree (default path .atomic/worktrees/<branch>; a new branch starts at base, else the upstream, else HEAD). It is created before the child starts, reused when the branch is already checked out at that path, refused when the branch is checked out elsewhere or the path holds something else, and never removed. Prefer it to creating a worktree with git in the same turn: tool calls in one message run at the same time, so the launch's cwd may not exist yet.
|
|
33692
|
-
• Optional context: { context: "fresh" | "fork" } (default: if any requested agent has defaultContext: "fork", the whole invocation uses fork; otherwise "fresh"; inspect agent defaults via { action: "list" })
|
|
33817
|
+
• Optional context: { context: "fresh" | "fork" } (default: if any requested agent has defaultContext: "fork", the whole invocation uses fork; otherwise "fresh"; inspect agent defaults via { action: "list" }). Use "fork" when the child needs this conversation: it continues it as sent, so on the same model and thinking level its first request is read from this session's prompt cache, and only its role and task are new. Use "fresh" for independent work: a smaller context with only the task. A fork carries the whole conversation, including the project context and skills this session was sent; its own tool policy still applies to the tools it calls.
|
|
33693
33818
|
• group (string | true) sets the intercom group for spawned children so same-group subagents can intercom each other but stay isolated from other groups. Boolean true or the trimmed, case-insensitive string sentinel "true"/"auto" auto-generates one shared UUID group per parallel set; those names are reserved and cannot be literal group names. Defaults to the launching session's group. Only applied when the child has intercom access; contact_supervisor still reaches the supervisor across groups.
|
|
33694
33819
|
MANAGEMENT (use action field, omit agent/task/tasks):
|
|
33695
33820
|
• { action: "models" } - inspect configured models, their fullId and availableThinkingLevels
|
|
@@ -4,6 +4,20 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [0.10.2] - 2026-11-20
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- `/curator`, `/google-account` and `/websearch` save their messages in a form that every Atomic release since 0.9.38 can open, so a session that used them no longer fails with "Unsupported session format" ([#6097](https://github.com/bastani-inc/atomic/issues/6097)).
|
|
12
|
+
- Fixed reading Chromium cookies failing in a Node process started with `--input-type=module`, and the process's `--import` and `--require` preloads running again for each read ([#6079](https://github.com/bastani-inc/atomic/issues/6079)).
|
|
13
|
+
|
|
14
|
+
## [0.10.2-alpha.1] - 2026-11-20
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- `/curator`, `/google-account` and `/websearch` save their messages in a form that every Atomic release since 0.9.38 can open, so a session that used them no longer fails with "Unsupported session format" ([#6097](https://github.com/bastani-inc/atomic/issues/6097)).
|
|
19
|
+
- Fixed reading Chromium cookies failing in a Node process started with `--input-type=module`, and the process's `--import` and `--require` preloads running again for each read ([#6079](https://github.com/bastani-inc/atomic/issues/6079)).
|
|
20
|
+
|
|
7
21
|
## [0.9.90] - 2026-11-19
|
|
8
22
|
|
|
9
23
|
### Fixed
|