@bastani/atomic 0.9.38-alpha.6 → 0.9.38-alpha.8
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 +41 -0
- package/dist/builtin/intercom/package.json +2 -2
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +12 -0
- package/dist/builtin/subagents/README.md +9 -4
- package/dist/builtin/subagents/package.json +3 -3
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +143 -134
- package/dist/builtin/web-access/package.json +2 -2
- package/dist/builtin/workflows/CHANGELOG.md +25 -0
- package/dist/builtin/workflows/builtin/{chunk-q7dx7kh7.js → chunk-85mx6wcf.js} +6 -6
- package/dist/builtin/workflows/builtin/{chunk-neszcj53.js → chunk-8kkv04hz.js} +15 -15
- package/dist/builtin/workflows/builtin/{chunk-g1a4hw0s.js → chunk-8x61e0s7.js} +13 -25
- package/dist/builtin/workflows/builtin/{chunk-2qgfyvzs.js → chunk-y45tkftg.js} +7 -7
- package/dist/builtin/workflows/builtin/goal.js +2 -2
- package/dist/builtin/workflows/builtin/index.js +4 -4
- package/dist/builtin/workflows/builtin/open-claude-design.js +1 -1
- package/dist/builtin/workflows/builtin/ralph.js +2 -2
- package/dist/builtin/workflows/package.json +2 -2
- package/dist/builtin/workflows/src/durable/journal/internal.d.ts +0 -19
- package/dist/builtin/workflows/src/durable/journal/legacy-journal-tables.d.ts +42 -0
- package/dist/builtin/workflows/src/durable/journal/memory-run-journal.d.ts +3 -11
- package/dist/builtin/workflows/src/durable/journal/resolution.d.ts +15 -9
- package/dist/builtin/workflows/src/durable/journal/sql-run-journal.d.ts +3 -0
- package/dist/builtin/workflows/src/durable/journal/types.d.ts +3 -93
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +1137 -748
- package/dist/builtin/workflows/src/index.js +709 -403
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +1 -1
- package/dist/cli/args.d.ts +2 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +29 -3
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/session-picker.d.ts +1 -1
- package/dist/cli/session-picker.d.ts.map +1 -1
- package/dist/cli/session-picker.js +2 -2
- package/dist/cli/session-picker.js.map +1 -1
- package/dist/core/agent-session-events.d.ts.map +1 -1
- package/dist/core/agent-session-events.js +6 -1
- package/dist/core/agent-session-events.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts +4 -0
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +44 -4
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +1 -1
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +2 -2
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts +1 -4
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +0 -4
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/pi-summary-fallback.d.ts.map +1 -1
- package/dist/core/compaction/pi-summary-fallback.js +1 -3
- package/dist/core/compaction/pi-summary-fallback.js.map +1 -1
- package/dist/core/extensions/loader-api.js +1 -1
- package/dist/core/extensions/loader-api.js.map +1 -1
- package/dist/core/extensions/runner-context.d.ts.map +1 -1
- package/dist/core/extensions/runner-context.js +7 -1
- package/dist/core/extensions/runner-context.js.map +1 -1
- package/dist/core/fast-model-routing.js +1 -1
- package/dist/core/fast-model-routing.js.map +1 -1
- package/dist/core/model-config.d.ts +765 -0
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +46 -24
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-resolver-defaults.js +1 -1
- package/dist/core/model-resolver-defaults.js.map +1 -1
- package/dist/core/resource-loader-reload.js +1 -1
- package/dist/core/resource-loader-reload.js.map +1 -1
- package/dist/core/resource-loader-types.d.ts +1 -1
- package/dist/core/resource-loader-types.d.ts.map +1 -1
- package/dist/core/resource-loader-types.js.map +1 -1
- package/dist/core/sdk-types.d.ts +4 -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 +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +48 -19
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-lifecycle-work.d.ts +3 -0
- package/dist/core/session-lifecycle-work.d.ts.map +1 -1
- package/dist/core/session-lifecycle-work.js +2 -0
- package/dist/core/session-lifecycle-work.js.map +1 -1
- package/dist/core/session-manager-core.d.ts +7 -4
- package/dist/core/session-manager-core.d.ts.map +1 -1
- package/dist/core/session-manager-core.js +149 -41
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-manager-list.d.ts.map +1 -1
- package/dist/core/session-manager-list.js +7 -7
- package/dist/core/session-manager-list.js.map +1 -1
- package/dist/core/session-manager-storage.d.ts +2 -1
- package/dist/core/session-manager-storage.d.ts.map +1 -1
- package/dist/core/session-manager-storage.js +24 -9
- package/dist/core/session-manager-storage.js.map +1 -1
- package/dist/core/session-manager-types.d.ts +1 -1
- package/dist/core/session-manager-types.d.ts.map +1 -1
- package/dist/core/session-manager-types.js.map +1 -1
- package/dist/core/session-manager.d.ts +1 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +1 -1
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/session-resume-args.d.ts +4 -0
- package/dist/core/session-resume-args.d.ts.map +1 -0
- package/dist/core/session-resume-args.js +9 -0
- package/dist/core/session-resume-args.js.map +1 -0
- package/dist/core/session-storage.d.ts +26 -0
- package/dist/core/session-storage.d.ts.map +1 -0
- package/dist/core/session-storage.js +171 -0
- package/dist/core/session-storage.js.map +1 -0
- package/dist/core/session-store-list.d.ts +4 -0
- package/dist/core/session-store-list.d.ts.map +1 -0
- package/dist/core/session-store-list.js +28 -0
- package/dist/core/session-store-list.js.map +1 -0
- package/dist/core/settings-manager-basic-accessors.d.ts +0 -1
- package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
- package/dist/core/settings-manager-basic-accessors.js +0 -5
- package/dist/core/settings-manager-basic-accessors.js.map +1 -1
- package/dist/core/settings-merge.d.ts.map +1 -1
- package/dist/core/settings-merge.js +5 -0
- package/dist/core/settings-merge.js.map +1 -1
- package/dist/core/settings-schema.d.ts +74 -3
- package/dist/core/settings-schema.d.ts.map +1 -1
- package/dist/core/settings-schema.js +28 -14
- package/dist/core/settings-schema.js.map +1 -1
- package/dist/core/storage/errors.d.ts +1 -0
- package/dist/core/storage/errors.d.ts.map +1 -1
- package/dist/core/storage/errors.js.map +1 -1
- package/dist/core/storage/index.d.ts +4 -0
- package/dist/core/storage/index.d.ts.map +1 -1
- package/dist/core/storage/index.js +3 -0
- package/dist/core/storage/index.js.map +1 -1
- package/dist/core/storage/provider.d.ts +58 -0
- package/dist/core/storage/provider.d.ts.map +1 -0
- package/dist/core/storage/provider.js +243 -0
- package/dist/core/storage/provider.js.map +1 -0
- package/dist/core/storage/run-journal.d.ts +93 -0
- package/dist/core/storage/run-journal.d.ts.map +1 -0
- package/dist/core/storage/run-journal.js +15 -0
- package/dist/core/storage/run-journal.js.map +1 -0
- package/dist/core/storage/selection.d.ts +16 -0
- package/dist/core/storage/selection.d.ts.map +1 -0
- package/dist/core/storage/selection.js +87 -0
- package/dist/core/storage/selection.js.map +1 -0
- package/dist/core/storage/session/jsonl-session-store.d.ts +9 -1
- package/dist/core/storage/session/jsonl-session-store.d.ts.map +1 -1
- package/dist/core/storage/session/jsonl-session-store.js +82 -44
- package/dist/core/storage/session/jsonl-session-store.js.map +1 -1
- package/dist/core/storage/session/legacy-format.d.ts +20 -0
- package/dist/core/storage/session/legacy-format.d.ts.map +1 -0
- package/dist/core/storage/session/legacy-format.js +89 -0
- package/dist/core/storage/session/legacy-format.js.map +1 -0
- package/dist/core/storage/session/legacy-session-store.d.ts +60 -0
- package/dist/core/storage/session/legacy-session-store.d.ts.map +1 -0
- package/dist/core/storage/session/legacy-session-store.js +225 -0
- package/dist/core/storage/session/legacy-session-store.js.map +1 -0
- package/dist/core/storage/session/memory-session-store.d.ts +3 -1
- package/dist/core/storage/session/memory-session-store.d.ts.map +1 -1
- package/dist/core/storage/session/memory-session-store.js +9 -2
- package/dist/core/storage/session/memory-session-store.js.map +1 -1
- package/dist/core/storage/session/sql-session-store.d.ts +4 -1
- package/dist/core/storage/session/sql-session-store.d.ts.map +1 -1
- package/dist/core/storage/session/sql-session-store.js +25 -6
- package/dist/core/storage/session/sql-session-store.js.map +1 -1
- package/dist/core/storage/session/types.d.ts +4 -0
- package/dist/core/storage/session/types.d.ts.map +1 -1
- package/dist/core/storage/session/types.js.map +1 -1
- package/dist/core/tools/read-url.d.ts.map +1 -1
- package/dist/core/tools/read-url.js +6 -1
- package/dist/core/tools/read-url.js.map +1 -1
- package/dist/extensions/codemode/execute.d.ts.map +1 -1
- package/dist/extensions/codemode/execute.js +13 -0
- package/dist/extensions/codemode/execute.js.map +1 -1
- package/dist/extensions/herdr/index.d.ts.map +1 -1
- package/dist/extensions/herdr/index.js +5 -3
- package/dist/extensions/herdr/index.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/main-session.d.ts +5 -1
- package/dist/main-session.d.ts.map +1 -1
- package/dist/main-session.js +106 -45
- package/dist/main-session.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +49 -15
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.d.ts +3 -1
- package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.js +15 -7
- package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
- package/dist/modes/interactive/components/session-selector-delete.d.ts +1 -1
- package/dist/modes/interactive/components/session-selector-delete.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector-delete.js.map +1 -1
- package/dist/modes/interactive/components/session-selector-list.d.ts +4 -4
- package/dist/modes/interactive/components/session-selector-list.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector-list.js +13 -12
- package/dist/modes/interactive/components/session-selector-list.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts +1 -0
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +16 -5
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-helpers.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-helpers.js +6 -2
- package/dist/modes/interactive/interactive-mode-helpers.js.map +1 -1
- package/dist/modes/interactive/interactive-session-routing.js +19 -7
- package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-slash-commands.js +3 -1
- package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
- package/dist/modes/interactive-engine/create-isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/create-isolated-runtime.js +8 -1
- package/dist/modes/interactive-engine/create-isolated-runtime.js.map +1 -1
- package/dist/modes/interactive-engine/engine-args.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-args.js +5 -1
- package/dist/modes/interactive-engine/engine-args.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js +21 -15
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
- package/dist/modes/rpc/rpc-client-process.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client-process.js +3 -1
- package/dist/modes/rpc/rpc-client-process.js.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.js +1 -1
- package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
- package/dist/modes/rpc/rpc-terminal-drain.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-terminal-drain.js +11 -2
- package/dist/modes/rpc/rpc-terminal-drain.js.map +1 -1
- package/dist/utils/canonical-path.d.ts +5 -0
- package/dist/utils/canonical-path.d.ts.map +1 -0
- package/dist/utils/canonical-path.js +26 -0
- package/dist/utils/canonical-path.js.map +1 -0
- package/dist/utils/paths.d.ts +1 -7
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +1 -15
- package/dist/utils/paths.js.map +1 -1
- package/docs/codemode.md +2 -0
- package/docs/compaction.md +2 -2
- package/docs/docs.json +1 -0
- package/docs/environment-variables.md +6 -2
- package/docs/getting-started/installation.md +1 -1
- package/docs/models/reference.md +2 -0
- package/docs/models-configuration.md +206 -0
- package/docs/models.md +11 -1
- package/docs/providers.md +2 -2
- package/docs/reference/cli.md +4 -0
- package/docs/sdk/web-server.md +3 -3
- package/docs/sdk.md +40 -3
- package/docs/session-format.md +30 -25
- package/docs/sessions.md +43 -17
- package/docs/settings.md +31 -9
- package/docs/storage.md +85 -2
- package/docs/subagents.md +19 -6
- package/docs/workflows/api-reference.md +23 -15
- package/docs/workflows/operations.md +3 -3
- package/docs/workflows/reliable-design.md +16 -16
- package/npm-shrinkwrap.json +53 -53
- package/package.json +7 -6
- package/schemas/models.schema.json +62 -29
- package/schemas/settings.schema.json +136 -31
|
@@ -6944,7 +6944,7 @@ var require_public_api = __commonJS(function(exports) {
|
|
|
6944
6944
|
});
|
|
6945
6945
|
|
|
6946
6946
|
// dist/builtin/subagents/src/extension/index.ts
|
|
6947
|
-
import * as
|
|
6947
|
+
import * as fs21 from "node:fs";
|
|
6948
6948
|
import * as os8 from "node:os";
|
|
6949
6949
|
import * as path23 from "node:path";
|
|
6950
6950
|
import {
|
|
@@ -8539,6 +8539,7 @@ function resolveTempScopeId(options) {
|
|
|
8539
8539
|
}
|
|
8540
8540
|
var MAX_PARALLEL_TASKS = 50;
|
|
8541
8541
|
var MAX_CONCURRENCY = 3;
|
|
8542
|
+
var DEFAULT_RUNNING_CAPACITY = 4;
|
|
8542
8543
|
var TEMP_ROOT_DIR = path6.join(os4.tmpdir(), `${APP_NAME2}-subagents-${resolveTempScopeId()}`);
|
|
8543
8544
|
var TEMP_ARTIFACTS_DIR = path6.join(TEMP_ROOT_DIR, "artifacts");
|
|
8544
8545
|
var SLASH_RESULT_TYPE = "subagent-slash-result";
|
|
@@ -8556,12 +8557,14 @@ function normalizeTopLevelParallelValue(value) {
|
|
|
8556
8557
|
return parsed;
|
|
8557
8558
|
}
|
|
8558
8559
|
function resolveTopLevelParallelMaxTasks(value) {
|
|
8559
|
-
|
|
8560
|
-
return configuredMax === undefined ? MAX_PARALLEL_TASKS : Math.min(configuredMax, MAX_PARALLEL_TASKS);
|
|
8560
|
+
return normalizeTopLevelParallelValue(value) ?? MAX_PARALLEL_TASKS;
|
|
8561
8561
|
}
|
|
8562
8562
|
function resolveTopLevelParallelConcurrency(override, configValue) {
|
|
8563
8563
|
return normalizeTopLevelParallelValue(override) ?? normalizeTopLevelParallelValue(configValue) ?? MAX_CONCURRENCY;
|
|
8564
8564
|
}
|
|
8565
|
+
function resolveTopLevelParallelRunningCapacity(value) {
|
|
8566
|
+
return normalizeTopLevelParallelValue(value) ?? DEFAULT_RUNNING_CAPACITY;
|
|
8567
|
+
}
|
|
8565
8568
|
function wrapForkTask(task, preamble) {
|
|
8566
8569
|
if (preamble === false)
|
|
8567
8570
|
return task;
|
|
@@ -10781,7 +10784,7 @@ function cancelledEnvelope(session, spec, stats) {
|
|
|
10781
10784
|
progressPath: spec.progressPath,
|
|
10782
10785
|
assistantText: lastNonEmptyAssistantText(session?.messages, outputFor(session)),
|
|
10783
10786
|
toolCount: stats.toolCalls,
|
|
10784
|
-
sessionPath: session?.sessionFile ?? spec.
|
|
10787
|
+
sessionPath: session?.sessionFile ?? spec.sessionManager?.getSessionFile(),
|
|
10785
10788
|
...spec.progressArtifactPath ? { progressArtifactPath: spec.progressArtifactPath } : {},
|
|
10786
10789
|
...spec.outputArtifactPath ? { outputArtifactPath: spec.outputArtifactPath } : {}
|
|
10787
10790
|
}).text;
|
|
@@ -10874,14 +10877,14 @@ class AdmittedChild {
|
|
|
10874
10877
|
spec;
|
|
10875
10878
|
policy;
|
|
10876
10879
|
sessionDir;
|
|
10877
|
-
|
|
10880
|
+
sessionManager;
|
|
10878
10881
|
control;
|
|
10879
10882
|
constructor(input) {
|
|
10880
10883
|
this.identity = input.identity;
|
|
10881
10884
|
this.spec = input.spec;
|
|
10882
10885
|
this.policy = input.policy;
|
|
10883
10886
|
this.sessionDir = input.sessionDir;
|
|
10884
|
-
this.
|
|
10887
|
+
this.sessionManager = input.sessionManager;
|
|
10885
10888
|
this.control = input.control;
|
|
10886
10889
|
}
|
|
10887
10890
|
static create(input) {
|
|
@@ -10903,10 +10906,10 @@ class SubagentControlRuntime {
|
|
|
10903
10906
|
deliveredEnvelopes = new Map;
|
|
10904
10907
|
killedChildren = new Set;
|
|
10905
10908
|
nextAttemptId = 1;
|
|
10906
|
-
constructor(parent, sessionRoot) {
|
|
10909
|
+
constructor(parent, sessionRoot, runningCapacity) {
|
|
10907
10910
|
this.parent = { ...parent };
|
|
10908
10911
|
this.sessionRoot = trustedSessionRoot(this.parent, sessionRoot);
|
|
10909
|
-
this.native = new SubagentControl(this.parent.path);
|
|
10912
|
+
this.native = new SubagentControl(this.parent.path, runningCapacity);
|
|
10910
10913
|
}
|
|
10911
10914
|
registerAgents(agents) {
|
|
10912
10915
|
for (const agent of agents)
|
|
@@ -10926,7 +10929,7 @@ class SubagentControlRuntime {
|
|
|
10926
10929
|
return refusal(native);
|
|
10927
10930
|
const identity = native.child;
|
|
10928
10931
|
const childModePolicy = resolveChildModePolicy(spec);
|
|
10929
|
-
const sessionDir = spec.
|
|
10932
|
+
const sessionDir = spec.sessionManager?.getSessionDir() || sessionDirectory(this.sessionRoot, identity.path);
|
|
10930
10933
|
mkdirSync4(sessionDir, { recursive: true });
|
|
10931
10934
|
return {
|
|
10932
10935
|
admitted: AdmittedChild.create({
|
|
@@ -10947,7 +10950,7 @@ class SubagentControlRuntime {
|
|
|
10947
10950
|
depth: identity.depth
|
|
10948
10951
|
},
|
|
10949
10952
|
sessionDir,
|
|
10950
|
-
|
|
10953
|
+
sessionManager: spec.sessionManager,
|
|
10951
10954
|
control: this
|
|
10952
10955
|
})
|
|
10953
10956
|
};
|
|
@@ -11062,9 +11065,7 @@ class SubagentControlRuntime {
|
|
|
11062
11065
|
});
|
|
11063
11066
|
try {
|
|
11064
11067
|
const workflow = workflowMetadataFromContext(admitted.spec.parent?.orchestrationContext);
|
|
11065
|
-
|
|
11066
|
-
mkdirSync4(dirname7(admitted.sessionFile), { recursive: true });
|
|
11067
|
-
const sessionManager = admitted.sessionFile ? await SessionManager.open(admitted.sessionFile, admitted.sessionDir, admitted.policy.cwd) : await SessionManager.create(admitted.policy.cwd, admitted.sessionDir, workflow ? { internal: true, workflow } : { internal: true });
|
|
11068
|
+
const sessionManager = admitted.sessionManager ? await SessionManager.open(admitted.sessionManager.getSessionStore(), admitted.sessionManager.getSessionId(), admitted.policy.cwd) : await SessionManager.create(admitted.policy.cwd, admitted.sessionDir, workflow ? { internal: true, workflow } : { internal: true });
|
|
11068
11069
|
taskHooks?.bindTranscript?.(sessionManager);
|
|
11069
11070
|
if (workflow)
|
|
11070
11071
|
await sessionManager.markSessionInternal(workflow);
|
|
@@ -11496,17 +11497,17 @@ class SubagentControlRuntime {
|
|
|
11496
11497
|
} catch {}
|
|
11497
11498
|
}
|
|
11498
11499
|
}
|
|
11499
|
-
function createSubagentControl(parent, sessionRoot) {
|
|
11500
|
-
return new SubagentControlRuntime(parent, sessionRoot);
|
|
11500
|
+
function createSubagentControl(parent, sessionRoot, runningCapacity) {
|
|
11501
|
+
return new SubagentControlRuntime(parent, sessionRoot, runningCapacity);
|
|
11501
11502
|
}
|
|
11502
11503
|
|
|
11503
11504
|
// dist/builtin/subagents/src/runs/inprocess/control-registry.ts
|
|
11504
11505
|
var controls = new Map;
|
|
11505
|
-
function getOrCreateSubagentControl(parent, sessionRoot) {
|
|
11506
|
+
function getOrCreateSubagentControl(parent, sessionRoot, runningCapacity) {
|
|
11506
11507
|
const existing = controls.get(parent.path);
|
|
11507
11508
|
if (existing)
|
|
11508
11509
|
return existing;
|
|
11509
|
-
const control = createSubagentControl(parent, sessionRoot);
|
|
11510
|
+
const control = createSubagentControl(parent, sessionRoot, runningCapacity);
|
|
11510
11511
|
controls.set(parent.path, control);
|
|
11511
11512
|
return control;
|
|
11512
11513
|
}
|
|
@@ -12522,7 +12523,7 @@ function createExecutionBurstDispatcher(input) {
|
|
|
12522
12523
|
|
|
12523
12524
|
// dist/builtin/subagents/src/runs/foreground/subagent-executor-context.ts
|
|
12524
12525
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
12525
|
-
import * as
|
|
12526
|
+
import * as fs12 from "node:fs";
|
|
12526
12527
|
import * as path13 from "node:path";
|
|
12527
12528
|
|
|
12528
12529
|
// dist/builtin/subagents/src/agents/agent-scope.ts
|
|
@@ -12533,67 +12534,71 @@ function resolveExecutionAgentScope(scope) {
|
|
|
12533
12534
|
}
|
|
12534
12535
|
|
|
12535
12536
|
// dist/builtin/subagents/src/shared/fork-context.ts
|
|
12536
|
-
import * as fs11 from "node:fs";
|
|
12537
12537
|
import { SessionManager as SessionManager2 } from "@bastani/atomic";
|
|
12538
|
+
|
|
12539
|
+
class SubagentForkContextError extends Error {
|
|
12540
|
+
parentSessionId;
|
|
12541
|
+
reason;
|
|
12542
|
+
constructor(parentSessionId, reason, options) {
|
|
12543
|
+
super(`Cannot fork subagent session ${JSON.stringify(parentSessionId)}: ${reason}`, options);
|
|
12544
|
+
this.parentSessionId = parentSessionId;
|
|
12545
|
+
this.reason = reason;
|
|
12546
|
+
this.name = "SubagentForkContextError";
|
|
12547
|
+
}
|
|
12548
|
+
}
|
|
12538
12549
|
function resolveSubagentContext(value) {
|
|
12539
12550
|
return value === "fork" ? "fork" : "fresh";
|
|
12540
12551
|
}
|
|
12541
|
-
function createForkContextResolver(sessionManager, requestedContext
|
|
12552
|
+
function createForkContextResolver(sessionManager, requestedContext) {
|
|
12542
12553
|
if (resolveSubagentContext(requestedContext) !== "fork") {
|
|
12543
|
-
return {
|
|
12544
|
-
|
|
12545
|
-
|
|
12546
|
-
}
|
|
12547
|
-
};
|
|
12548
|
-
}
|
|
12549
|
-
const parentSessionFile = sessionManager.getSessionFile();
|
|
12550
|
-
if (!parentSessionFile) {
|
|
12551
|
-
throw new Error("Forked subagent context requires a persisted parent session.");
|
|
12554
|
+
return { sessionManagerForIndex: async () => {
|
|
12555
|
+
return;
|
|
12556
|
+
} };
|
|
12552
12557
|
}
|
|
12558
|
+
const parentSessionId = sessionManager.getSessionId();
|
|
12559
|
+
const store = sessionManager.getSessionStore();
|
|
12560
|
+
const cwd = sessionManager.getCwd();
|
|
12553
12561
|
const leafId = sessionManager.getLeafId();
|
|
12554
|
-
if (
|
|
12555
|
-
throw new
|
|
12556
|
-
|
|
12557
|
-
const openSession = options.openSession ?? sessionManager.openSession ?? ((file, dir) => SessionManager2.open(file, dir));
|
|
12558
|
-
const sessionDir = sessionManager.getSessionDir?.();
|
|
12559
|
-
const cachedSessionFiles = new Map;
|
|
12562
|
+
if (leafId === null)
|
|
12563
|
+
throw new SubagentForkContextError(parentSessionId, "no_leaf");
|
|
12564
|
+
const children = new Map;
|
|
12560
12565
|
return {
|
|
12561
|
-
|
|
12562
|
-
const cached =
|
|
12563
|
-
if (cached)
|
|
12566
|
+
sessionManagerForIndex(index = 0) {
|
|
12567
|
+
const cached = children.get(index);
|
|
12568
|
+
if (cached !== undefined)
|
|
12564
12569
|
return cached;
|
|
12565
|
-
|
|
12566
|
-
|
|
12567
|
-
|
|
12568
|
-
|
|
12569
|
-
|
|
12570
|
-
|
|
12571
|
-
|
|
12572
|
-
throw new
|
|
12573
|
-
}
|
|
12574
|
-
if (!fs11.existsSync(sessionFile)) {
|
|
12575
|
-
throw new Error(`Session manager returned a forked session file that does not exist: ${sessionFile}`);
|
|
12570
|
+
const child = (async () => {
|
|
12571
|
+
try {
|
|
12572
|
+
const source = await SessionManager2.open(store, parentSessionId, cwd);
|
|
12573
|
+
await source.createBranchedSession(leafId);
|
|
12574
|
+
return source;
|
|
12575
|
+
} catch (cause) {
|
|
12576
|
+
children.delete(index);
|
|
12577
|
+
throw new SubagentForkContextError(parentSessionId, "fork_failed", { cause });
|
|
12576
12578
|
}
|
|
12577
|
-
|
|
12578
|
-
|
|
12579
|
-
|
|
12580
|
-
const cause = error instanceof Error ? error : new Error(String(error));
|
|
12581
|
-
throw new Error(`Failed to create forked subagent session: ${cause.message}`, { cause });
|
|
12582
|
-
}
|
|
12579
|
+
})();
|
|
12580
|
+
children.set(index, child);
|
|
12581
|
+
return child;
|
|
12583
12582
|
}
|
|
12584
12583
|
};
|
|
12585
12584
|
}
|
|
12586
12585
|
|
|
12587
12586
|
// dist/builtin/subagents/src/shared/session-identity.ts
|
|
12587
|
+
class SubagentSessionIdentityError extends Error {
|
|
12588
|
+
constructor() {
|
|
12589
|
+
super("Current session identity is unavailable.");
|
|
12590
|
+
this.name = "SubagentSessionIdentityError";
|
|
12591
|
+
}
|
|
12592
|
+
}
|
|
12588
12593
|
function resolveCurrentSessionId(sessionManager) {
|
|
12589
|
-
const sessionId = sessionManager.
|
|
12590
|
-
if (
|
|
12591
|
-
throw new
|
|
12594
|
+
const sessionId = sessionManager.getSessionId();
|
|
12595
|
+
if (sessionId === undefined || sessionId === null)
|
|
12596
|
+
throw new SubagentSessionIdentityError;
|
|
12592
12597
|
return sessionId;
|
|
12593
12598
|
}
|
|
12594
12599
|
|
|
12595
12600
|
// dist/builtin/subagents/src/shared/settings.ts
|
|
12596
|
-
import * as
|
|
12601
|
+
import * as fs11 from "node:fs";
|
|
12597
12602
|
import * as path12 from "node:path";
|
|
12598
12603
|
function normalizeOutputOverride(output) {
|
|
12599
12604
|
return output === "false" ? false : output;
|
|
@@ -12633,8 +12638,8 @@ function buildReadInstruction(reads, cwd) {
|
|
|
12633
12638
|
return `[Read from: ${files.join(", ")}]`;
|
|
12634
12639
|
}
|
|
12635
12640
|
function writeInitialProgressFile(progressDir) {
|
|
12636
|
-
|
|
12637
|
-
|
|
12641
|
+
fs11.mkdirSync(progressDir, { recursive: true });
|
|
12642
|
+
fs11.writeFileSync(path12.join(progressDir, "progress.md"), INITIAL_PROGRESS_CONTENT);
|
|
12638
12643
|
}
|
|
12639
12644
|
function injectSingleProgressInstruction(task, progressDir) {
|
|
12640
12645
|
return `${task}
|
|
@@ -12750,11 +12755,9 @@ function prepareExecutionContext(input) {
|
|
|
12750
12755
|
|
|
12751
12756
|
${effectiveParams.task ?? ""}` };
|
|
12752
12757
|
}
|
|
12753
|
-
let
|
|
12754
|
-
return;
|
|
12755
|
-
};
|
|
12758
|
+
let sessionManagerForIndex;
|
|
12756
12759
|
try {
|
|
12757
|
-
|
|
12760
|
+
sessionManagerForIndex = createForkContextResolver(ctx.sessionManager, effectiveParams.context).sessionManagerForIndex;
|
|
12758
12761
|
} catch (error) {
|
|
12759
12762
|
return { error: toExecutionErrorResult(effectiveParams, error) };
|
|
12760
12763
|
}
|
|
@@ -12772,7 +12775,7 @@ ${effectiveParams.task ?? ""}` };
|
|
|
12772
12775
|
sessionRoot = path13.join(baseSessionRoot, runId);
|
|
12773
12776
|
}
|
|
12774
12777
|
try {
|
|
12775
|
-
|
|
12778
|
+
fs12.mkdirSync(sessionRoot, { recursive: true });
|
|
12776
12779
|
} catch (error) {
|
|
12777
12780
|
const message = error instanceof Error ? error.message : String(error);
|
|
12778
12781
|
return {
|
|
@@ -12780,7 +12783,6 @@ ${effectiveParams.task ?? ""}` };
|
|
|
12780
12783
|
};
|
|
12781
12784
|
}
|
|
12782
12785
|
const sessionDirForIndex = (idx) => path13.join(sessionRoot, `run-${idx ?? 0}`);
|
|
12783
|
-
const childSessionFileForIndex = async (idx) => await sessionFileForIndex(idx) ?? path13.join(sessionDirForIndex(idx), "session.jsonl");
|
|
12784
12786
|
const onUpdateWithContext = onUpdate ? (r) => onUpdate(withForkContext(r, effectiveParams.context)) : undefined;
|
|
12785
12787
|
const execData = {
|
|
12786
12788
|
params: effectiveParams,
|
|
@@ -12794,7 +12796,7 @@ ${effectiveParams.task ?? ""}` };
|
|
|
12794
12796
|
shareEnabled,
|
|
12795
12797
|
sessionRoot,
|
|
12796
12798
|
sessionDirForIndex,
|
|
12797
|
-
|
|
12799
|
+
sessionManagerForIndex,
|
|
12798
12800
|
artifactConfig,
|
|
12799
12801
|
artifactsDir,
|
|
12800
12802
|
parentDepth: depth,
|
|
@@ -12997,7 +12999,7 @@ async function routeSubagentModel(input) {
|
|
|
12997
12999
|
}
|
|
12998
13000
|
|
|
12999
13001
|
// dist/builtin/subagents/src/runs/shared/run-history.ts
|
|
13000
|
-
import * as
|
|
13002
|
+
import * as fs13 from "node:fs";
|
|
13001
13003
|
import * as os6 from "node:os";
|
|
13002
13004
|
import * as path14 from "node:path";
|
|
13003
13005
|
import { getAgentConfigPaths as getAgentConfigPaths4 } from "@bastani/atomic";
|
|
@@ -13012,14 +13014,14 @@ function recordRun(agent, task, status, durationMs) {
|
|
|
13012
13014
|
status,
|
|
13013
13015
|
duration: durationMs
|
|
13014
13016
|
};
|
|
13015
|
-
|
|
13016
|
-
|
|
13017
|
+
fs13.mkdirSync(path14.dirname(HISTORY_PATH), { recursive: true });
|
|
13018
|
+
fs13.appendFileSync(HISTORY_PATH, `${JSON.stringify(entry)}
|
|
13017
13019
|
`);
|
|
13018
13020
|
} catch {}
|
|
13019
13021
|
}
|
|
13020
13022
|
|
|
13021
13023
|
// dist/builtin/subagents/src/runs/shared/single-output.ts
|
|
13022
|
-
import * as
|
|
13024
|
+
import * as fs14 from "node:fs";
|
|
13023
13025
|
import * as path15 from "node:path";
|
|
13024
13026
|
function normalizeSingleOutputOverride(output, defaultOutput) {
|
|
13025
13027
|
if (output === false || output === "false")
|
|
@@ -13085,7 +13087,7 @@ function captureSingleOutputSnapshot(outputPath) {
|
|
|
13085
13087
|
if (!outputPath)
|
|
13086
13088
|
return;
|
|
13087
13089
|
try {
|
|
13088
|
-
const stat =
|
|
13090
|
+
const stat = fs14.statSync(outputPath);
|
|
13089
13091
|
return { exists: true, mtimeMs: stat.mtimeMs, size: stat.size };
|
|
13090
13092
|
} catch {
|
|
13091
13093
|
return { exists: false };
|
|
@@ -13095,8 +13097,8 @@ function persistSingleOutput(outputPath, fullOutput) {
|
|
|
13095
13097
|
if (!outputPath)
|
|
13096
13098
|
return {};
|
|
13097
13099
|
try {
|
|
13098
|
-
|
|
13099
|
-
|
|
13100
|
+
fs14.mkdirSync(path15.dirname(outputPath), { recursive: true });
|
|
13101
|
+
fs14.writeFileSync(outputPath, fullOutput, "utf-8");
|
|
13100
13102
|
return { savedPath: outputPath };
|
|
13101
13103
|
} catch (err) {
|
|
13102
13104
|
return { error: err instanceof Error ? err.message : String(err) };
|
|
@@ -13107,7 +13109,7 @@ function resolveSingleOutput(outputPath, fallbackOutput, beforeRun) {
|
|
|
13107
13109
|
return { fullOutput: fallbackOutput };
|
|
13108
13110
|
let changedSinceStart = false;
|
|
13109
13111
|
try {
|
|
13110
|
-
const stat =
|
|
13112
|
+
const stat = fs14.statSync(outputPath);
|
|
13111
13113
|
changedSinceStart = !beforeRun?.exists || stat.mtimeMs !== beforeRun.mtimeMs || stat.size !== beforeRun.size;
|
|
13112
13114
|
} catch (error) {
|
|
13113
13115
|
const code = error && typeof error === "object" && "code" in error ? error.code : undefined;
|
|
@@ -13120,7 +13122,7 @@ function resolveSingleOutput(outputPath, fallbackOutput, beforeRun) {
|
|
|
13120
13122
|
}
|
|
13121
13123
|
if (changedSinceStart) {
|
|
13122
13124
|
try {
|
|
13123
|
-
return { fullOutput:
|
|
13125
|
+
return { fullOutput: fs14.readFileSync(outputPath, "utf-8"), savedPath: outputPath };
|
|
13124
13126
|
} catch (error) {
|
|
13125
13127
|
return {
|
|
13126
13128
|
fullOutput: fallbackOutput,
|
|
@@ -13157,13 +13159,13 @@ ${params.saveError}`;
|
|
|
13157
13159
|
|
|
13158
13160
|
// dist/builtin/subagents/src/runs/shared/worktree.ts
|
|
13159
13161
|
import { spawnSync } from "node:child_process";
|
|
13160
|
-
import * as
|
|
13162
|
+
import * as fs17 from "node:fs";
|
|
13161
13163
|
import * as os7 from "node:os";
|
|
13162
13164
|
import * as path18 from "node:path";
|
|
13163
13165
|
import { createChildProcessEnvironment as createChildProcessEnvironment3, createGitEnvironment } from "@bastani/atomic";
|
|
13164
13166
|
|
|
13165
13167
|
// dist/builtin/subagents/src/runs/shared/worktree-post-create.ts
|
|
13166
|
-
import * as
|
|
13168
|
+
import * as fs15 from "node:fs";
|
|
13167
13169
|
import * as path16 from "node:path";
|
|
13168
13170
|
function tracked(runGit, repo, relativePath) {
|
|
13169
13171
|
return runGit(repo, ["ls-files", "--error-unmatch", "--", relativePath]).status === 0;
|
|
@@ -13182,10 +13184,10 @@ function hasTrackedPathComponent(runGit, repo, relativePath) {
|
|
|
13182
13184
|
function copySettings(runGit, mainRoot, worktreeRoot, relativePath) {
|
|
13183
13185
|
const source = path16.join(mainRoot, relativePath);
|
|
13184
13186
|
const destination = path16.join(worktreeRoot, relativePath);
|
|
13185
|
-
if (!
|
|
13187
|
+
if (!fs15.existsSync(source) || fs15.existsSync(destination) || hasTrackedPathComponent(runGit, worktreeRoot, relativePath))
|
|
13186
13188
|
return false;
|
|
13187
|
-
|
|
13188
|
-
|
|
13189
|
+
fs15.mkdirSync(path16.dirname(destination), { recursive: true });
|
|
13190
|
+
fs15.copyFileSync(source, destination);
|
|
13189
13191
|
return true;
|
|
13190
13192
|
}
|
|
13191
13193
|
function configureHooks(runGit, mainRoot) {
|
|
@@ -13193,12 +13195,12 @@ function configureHooks(runGit, mainRoot) {
|
|
|
13193
13195
|
const ordinary = path16.join(mainRoot, ".git", "hooks");
|
|
13194
13196
|
let desired;
|
|
13195
13197
|
try {
|
|
13196
|
-
if (
|
|
13198
|
+
if (fs15.statSync(husky).isDirectory())
|
|
13197
13199
|
desired = husky;
|
|
13198
13200
|
} catch {}
|
|
13199
13201
|
if (!desired) {
|
|
13200
13202
|
try {
|
|
13201
|
-
if (
|
|
13203
|
+
if (fs15.readdirSync(ordinary, { withFileTypes: true }).some((entry) => entry.isFile() && !entry.name.endsWith(".sample")))
|
|
13202
13204
|
desired = ordinary;
|
|
13203
13205
|
} catch {}
|
|
13204
13206
|
}
|
|
@@ -13212,7 +13214,7 @@ function configureHooks(runGit, mainRoot) {
|
|
|
13212
13214
|
throw new Error(result.stderr.trim() || "failed to configure shared core.hooksPath");
|
|
13213
13215
|
}
|
|
13214
13216
|
function copyIncludes(runGit, mainRoot, worktreeRoot) {
|
|
13215
|
-
if (!
|
|
13217
|
+
if (!fs15.existsSync(path16.join(mainRoot, ".worktreeinclude")))
|
|
13216
13218
|
return;
|
|
13217
13219
|
const ignored = runGit(mainRoot, ["ls-files", "--others", "--ignored", "--exclude-standard"]);
|
|
13218
13220
|
const included = runGit(mainRoot, ["ls-files", "--others", "--ignored", "--exclude-from=.worktreeinclude"]);
|
|
@@ -13225,10 +13227,10 @@ function copyIncludes(runGit, mainRoot, worktreeRoot) {
|
|
|
13225
13227
|
const source = path16.join(mainRoot, relativePath);
|
|
13226
13228
|
const destination = path16.join(worktreeRoot, relativePath);
|
|
13227
13229
|
try {
|
|
13228
|
-
if (!
|
|
13230
|
+
if (!fs15.statSync(source).isFile() || fs15.existsSync(destination))
|
|
13229
13231
|
continue;
|
|
13230
|
-
|
|
13231
|
-
|
|
13232
|
+
fs15.mkdirSync(path16.dirname(destination), { recursive: true });
|
|
13233
|
+
fs15.copyFileSync(source, destination);
|
|
13232
13234
|
} catch {}
|
|
13233
13235
|
}
|
|
13234
13236
|
}
|
|
@@ -13242,9 +13244,9 @@ function performPostCreationSetup(runGit, mainRoot, worktreeRoot) {
|
|
|
13242
13244
|
configureHooks(runGit, mainRoot);
|
|
13243
13245
|
const source = path16.join(mainRoot, "node_modules");
|
|
13244
13246
|
const destination = path16.join(worktreeRoot, "node_modules");
|
|
13245
|
-
if (
|
|
13247
|
+
if (fs15.existsSync(source) && !fs15.existsSync(destination) && !tracked(runGit, worktreeRoot, "node_modules")) {
|
|
13246
13248
|
try {
|
|
13247
|
-
|
|
13249
|
+
fs15.symlinkSync(source, destination, process.platform === "win32" ? "junction" : undefined);
|
|
13248
13250
|
synthetic.push("node_modules");
|
|
13249
13251
|
} catch {}
|
|
13250
13252
|
}
|
|
@@ -13253,19 +13255,19 @@ function performPostCreationSetup(runGit, mainRoot, worktreeRoot) {
|
|
|
13253
13255
|
}
|
|
13254
13256
|
|
|
13255
13257
|
// dist/builtin/subagents/src/runs/shared/worktree-root.ts
|
|
13256
|
-
import * as
|
|
13258
|
+
import * as fs16 from "node:fs";
|
|
13257
13259
|
import * as path17 from "node:path";
|
|
13258
13260
|
function readText(file) {
|
|
13259
13261
|
try {
|
|
13260
|
-
return
|
|
13262
|
+
return fs16.readFileSync(file, "utf8");
|
|
13261
13263
|
} catch {
|
|
13262
13264
|
return;
|
|
13263
13265
|
}
|
|
13264
13266
|
}
|
|
13265
13267
|
function samePath(left, right) {
|
|
13266
13268
|
try {
|
|
13267
|
-
const a =
|
|
13268
|
-
const b =
|
|
13269
|
+
const a = fs16.realpathSync.native(left);
|
|
13270
|
+
const b = fs16.realpathSync.native(right);
|
|
13269
13271
|
return process.platform === "win32" ? a.toLowerCase() === b.toLowerCase() : a === b;
|
|
13270
13272
|
} catch {
|
|
13271
13273
|
return false;
|
|
@@ -13274,14 +13276,14 @@ function samePath(left, right) {
|
|
|
13274
13276
|
function findGitRoot(cwd) {
|
|
13275
13277
|
let current = path17.resolve(cwd);
|
|
13276
13278
|
try {
|
|
13277
|
-
if (!
|
|
13279
|
+
if (!fs16.statSync(current).isDirectory())
|
|
13278
13280
|
current = path17.dirname(current);
|
|
13279
13281
|
} catch {
|
|
13280
13282
|
return;
|
|
13281
13283
|
}
|
|
13282
13284
|
while (true) {
|
|
13283
13285
|
try {
|
|
13284
|
-
const entry =
|
|
13286
|
+
const entry = fs16.statSync(path17.join(current, ".git"));
|
|
13285
13287
|
if (entry.isDirectory() || entry.isFile())
|
|
13286
13288
|
return current;
|
|
13287
13289
|
} catch {}
|
|
@@ -13295,7 +13297,7 @@ function resolveMainRepoRoot(repoRoot) {
|
|
|
13295
13297
|
const gitEntry = path17.join(repoRoot, ".git");
|
|
13296
13298
|
let stats;
|
|
13297
13299
|
try {
|
|
13298
|
-
stats =
|
|
13300
|
+
stats = fs16.statSync(gitEntry);
|
|
13299
13301
|
} catch {
|
|
13300
13302
|
return;
|
|
13301
13303
|
}
|
|
@@ -13382,7 +13384,7 @@ function resolveRepoState(cwd) {
|
|
|
13382
13384
|
function normalizeComparableCwd(cwd) {
|
|
13383
13385
|
const resolved = path18.resolve(cwd);
|
|
13384
13386
|
try {
|
|
13385
|
-
return
|
|
13387
|
+
return fs17.realpathSync(resolved);
|
|
13386
13388
|
} catch {
|
|
13387
13389
|
return resolved;
|
|
13388
13390
|
}
|
|
@@ -13417,8 +13419,8 @@ function buildWorktreePath(mainRoot, runId, index) {
|
|
|
13417
13419
|
}
|
|
13418
13420
|
function ensureWorktreeIgnore(mainRoot) {
|
|
13419
13421
|
const root = path18.join(mainRoot, ".atomic", "worktrees");
|
|
13420
|
-
|
|
13421
|
-
|
|
13422
|
+
fs17.mkdirSync(root, { recursive: true });
|
|
13423
|
+
fs17.writeFileSync(path18.join(root, ".gitignore"), `*
|
|
13422
13424
|
`, "utf8");
|
|
13423
13425
|
}
|
|
13424
13426
|
function resolveRepoCwdRelative(cwd) {
|
|
@@ -13454,10 +13456,10 @@ function resolveWorktreeSetupHook(repoRoot, config) {
|
|
|
13454
13456
|
} else {
|
|
13455
13457
|
throw new Error("worktree setup hook must be an absolute path or a repo-relative path");
|
|
13456
13458
|
}
|
|
13457
|
-
if (!
|
|
13459
|
+
if (!fs17.existsSync(resolvedPath)) {
|
|
13458
13460
|
throw new Error(`worktree setup hook not found: ${resolvedPath}`);
|
|
13459
13461
|
}
|
|
13460
|
-
if (
|
|
13462
|
+
if (fs17.statSync(resolvedPath).isDirectory()) {
|
|
13461
13463
|
throw new Error(`worktree setup hook must be a file, got directory: ${resolvedPath}`);
|
|
13462
13464
|
}
|
|
13463
13465
|
return {
|
|
@@ -13604,7 +13606,7 @@ function removeSyntheticPath(worktree, syntheticPath) {
|
|
|
13604
13606
|
}
|
|
13605
13607
|
let stat;
|
|
13606
13608
|
try {
|
|
13607
|
-
stat =
|
|
13609
|
+
stat = fs17.lstatSync(resolved);
|
|
13608
13610
|
} catch (error) {
|
|
13609
13611
|
const code = error && typeof error === "object" && "code" in error ? error.code : undefined;
|
|
13610
13612
|
if (code === "ENOENT")
|
|
@@ -13612,14 +13614,14 @@ function removeSyntheticPath(worktree, syntheticPath) {
|
|
|
13612
13614
|
throw error;
|
|
13613
13615
|
}
|
|
13614
13616
|
if (stat.isSymbolicLink()) {
|
|
13615
|
-
|
|
13617
|
+
fs17.unlinkSync(resolved);
|
|
13616
13618
|
return;
|
|
13617
13619
|
}
|
|
13618
13620
|
if (stat.isDirectory()) {
|
|
13619
|
-
|
|
13621
|
+
fs17.rmSync(resolved, { recursive: true, force: true });
|
|
13620
13622
|
return;
|
|
13621
13623
|
}
|
|
13622
|
-
|
|
13624
|
+
fs17.rmSync(resolved, { force: true });
|
|
13623
13625
|
}
|
|
13624
13626
|
function removeSyntheticPathsBeforeDiff(worktree) {
|
|
13625
13627
|
if (worktree.syntheticPaths.length === 0)
|
|
@@ -13668,7 +13670,7 @@ function captureWorktreeDiff(setup, worktree, agent, patchPath) {
|
|
|
13668
13670
|
const diffStat = runGitChecked(worktree.path, ["diff", "--cached", "--stat", setup.baseCommit]).trim();
|
|
13669
13671
|
const patch = runGitChecked(worktree.path, ["diff", "--cached", setup.baseCommit]);
|
|
13670
13672
|
const numstat = runGitChecked(worktree.path, ["diff", "--cached", "--numstat", setup.baseCommit]);
|
|
13671
|
-
|
|
13673
|
+
fs17.writeFileSync(patchPath, patch, "utf-8");
|
|
13672
13674
|
if (!patch.trim()) {
|
|
13673
13675
|
return emptyDiff(worktree.index, agent, worktree.branch, patchPath);
|
|
13674
13676
|
}
|
|
@@ -13686,7 +13688,7 @@ function captureWorktreeDiff(setup, worktree, agent, patchPath) {
|
|
|
13686
13688
|
}
|
|
13687
13689
|
function writeEmptyPatch(patchPath) {
|
|
13688
13690
|
try {
|
|
13689
|
-
|
|
13691
|
+
fs17.writeFileSync(patchPath, "", "utf-8");
|
|
13690
13692
|
} catch {}
|
|
13691
13693
|
}
|
|
13692
13694
|
function hasWorktreeChanges(diff) {
|
|
@@ -13709,7 +13711,7 @@ function createWorktrees(cwd, runId, count, options) {
|
|
|
13709
13711
|
}
|
|
13710
13712
|
function diffWorktrees(setup, agents, diffsDir) {
|
|
13711
13713
|
try {
|
|
13712
|
-
|
|
13714
|
+
fs17.mkdirSync(diffsDir, { recursive: true });
|
|
13713
13715
|
} catch {
|
|
13714
13716
|
return [];
|
|
13715
13717
|
}
|
|
@@ -13925,6 +13927,7 @@ async function runForegroundParallelTasks(input) {
|
|
|
13925
13927
|
const taskAgents = input.agentConfigs && agentConfig ? [agentConfig] : input.agents;
|
|
13926
13928
|
const sharedProgress = index === input.behaviors.findIndex((candidate) => candidate.progress) ? join19(input.paramsCwd, "progress.md") : undefined;
|
|
13927
13929
|
const runOptions = {
|
|
13930
|
+
runningCapacity: input.runningCapacity,
|
|
13928
13931
|
getChildSessionOptions: input.ctx.getChildSessionOptions,
|
|
13929
13932
|
resourceLoaderInheritanceSnapshot: input.resourceLoaderInheritanceSnapshot,
|
|
13930
13933
|
cwd: taskCwd,
|
|
@@ -13936,7 +13939,7 @@ async function runForegroundParallelTasks(input) {
|
|
|
13936
13939
|
runId: input.runId,
|
|
13937
13940
|
index,
|
|
13938
13941
|
sessionDir: input.sessionDirForIndex(index),
|
|
13939
|
-
|
|
13942
|
+
sessionManager: await input.sessionManagerForIndex(index),
|
|
13940
13943
|
share: input.shareEnabled,
|
|
13941
13944
|
artifactsDir: input.artifactConfig.enabled ? input.artifactsDir : undefined,
|
|
13942
13945
|
artifactConfig: input.artifactConfig,
|
|
@@ -14509,7 +14512,7 @@ async function runParallelPath(data, deps) {
|
|
|
14509
14512
|
signal,
|
|
14510
14513
|
runId,
|
|
14511
14514
|
sessionDirForIndex,
|
|
14512
|
-
|
|
14515
|
+
sessionManagerForIndex,
|
|
14513
14516
|
shareEnabled,
|
|
14514
14517
|
artifactConfig,
|
|
14515
14518
|
artifactsDir,
|
|
@@ -14525,7 +14528,12 @@ async function runParallelPath(data, deps) {
|
|
|
14525
14528
|
const parallelConcurrency = resolveTopLevelParallelConcurrency(params.concurrency, deps.config.parallel?.concurrency);
|
|
14526
14529
|
if (tasks.length > maxParallelTasks)
|
|
14527
14530
|
return {
|
|
14528
|
-
content: [
|
|
14531
|
+
content: [
|
|
14532
|
+
{
|
|
14533
|
+
type: "text",
|
|
14534
|
+
text: `Too many parallel tasks (${tasks.length} after count expansion). Maximum is ${maxParallelTasks} (configure parallel.maxTasks in ~/.atomic/agent/extensions/subagent/config.json).`
|
|
14535
|
+
}
|
|
14536
|
+
],
|
|
14529
14537
|
isError: true,
|
|
14530
14538
|
details: { mode: "parallel", results: [] }
|
|
14531
14539
|
};
|
|
@@ -14661,7 +14669,7 @@ async function runParallelPath(data, deps) {
|
|
|
14661
14669
|
signal,
|
|
14662
14670
|
runId,
|
|
14663
14671
|
sessionDirForIndex,
|
|
14664
|
-
|
|
14672
|
+
sessionManagerForIndex,
|
|
14665
14673
|
shareEnabled,
|
|
14666
14674
|
artifactConfig,
|
|
14667
14675
|
artifactsDir,
|
|
@@ -14683,6 +14691,7 @@ async function runParallelPath(data, deps) {
|
|
|
14683
14691
|
sharedAutoIntercomGroup: sharedAutoGroupForSet(params.group, tasks),
|
|
14684
14692
|
foregroundControl,
|
|
14685
14693
|
concurrencyLimit: parallelConcurrency,
|
|
14694
|
+
runningCapacity: deps.config.parallel?.runningCapacity,
|
|
14686
14695
|
parentDepth: data.parentDepth,
|
|
14687
14696
|
liveResults,
|
|
14688
14697
|
liveProgress,
|
|
@@ -14783,7 +14792,7 @@ ${worktreeSuffix}` : childContent;
|
|
|
14783
14792
|
}
|
|
14784
14793
|
|
|
14785
14794
|
// dist/builtin/subagents/src/runs/foreground/inprocess-run-sync.ts
|
|
14786
|
-
import { existsSync as
|
|
14795
|
+
import { existsSync as existsSync14, statSync as statSync9 } from "node:fs";
|
|
14787
14796
|
import { join as join20 } from "node:path";
|
|
14788
14797
|
|
|
14789
14798
|
// dist/builtin/subagents/src/runs/shared/model-candidate-filter.ts
|
|
@@ -15092,7 +15101,7 @@ function noSpawnableCandidatesResult(agent, task, skippedAttempts) {
|
|
|
15092
15101
|
}
|
|
15093
15102
|
async function runSingleInProcess(runtimeCwd, agent, task, options) {
|
|
15094
15103
|
const cwd = options.cwd ?? runtimeCwd;
|
|
15095
|
-
if (!
|
|
15104
|
+
if (!existsSync14(cwd))
|
|
15096
15105
|
return refusedResult(agent, task, `cwd does not exist: ${cwd}`);
|
|
15097
15106
|
if (!statSync9(cwd).isDirectory())
|
|
15098
15107
|
return refusedResult(agent, task, `cwd is not a directory: ${cwd}`);
|
|
@@ -15135,7 +15144,7 @@ async function runSingleInProcess(runtimeCwd, agent, task, options) {
|
|
|
15135
15144
|
...orchestrationContext ? { orchestrationContext } : {}
|
|
15136
15145
|
};
|
|
15137
15146
|
const sessionRoot = options.sessionDir ?? join20(options.artifactsDir ?? cwd, ".atomic", "subagents");
|
|
15138
|
-
const control = getOrCreateSubagentControl(parent, sessionRoot);
|
|
15147
|
+
const control = getOrCreateSubagentControl(parent, sessionRoot, resolveTopLevelParallelRunningCapacity(options.runningCapacity));
|
|
15139
15148
|
control.registerAgents([agent]);
|
|
15140
15149
|
const artifactsDir = options.artifactsDir && options.artifactConfig?.enabled !== false ? options.artifactsDir : undefined;
|
|
15141
15150
|
const artifactPaths = artifactsDir ? getArtifactPaths(artifactsDir, options.runId, agent.name, options.index) : undefined;
|
|
@@ -15153,7 +15162,7 @@ ${task}`);
|
|
|
15153
15162
|
agent,
|
|
15154
15163
|
cwd,
|
|
15155
15164
|
testSession,
|
|
15156
|
-
|
|
15165
|
+
sessionManager: options.sessionManager,
|
|
15157
15166
|
...options.progressPath ? { progressPath: options.progressPath } : {},
|
|
15158
15167
|
...options.progressArtifactPath ? { progressArtifactPath: options.progressArtifactPath } : options.progressPath && artifactsDir ? { progressArtifactPath: options.progressPath } : {},
|
|
15159
15168
|
...artifactPaths?.outputPath ? { outputArtifactPath: artifactPaths.outputPath } : {},
|
|
@@ -15398,7 +15407,7 @@ function resolveSubagentExecutorRuntimeDeps(overrides) {
|
|
|
15398
15407
|
}
|
|
15399
15408
|
|
|
15400
15409
|
// dist/builtin/subagents/src/runs/foreground/subagent-executor-single.ts
|
|
15401
|
-
import * as
|
|
15410
|
+
import * as fs18 from "node:fs";
|
|
15402
15411
|
import * as path20 from "node:path";
|
|
15403
15412
|
function formatFailedSingleRunOutput(result, displayOutput) {
|
|
15404
15413
|
const error = result.error || "Failed";
|
|
@@ -15417,7 +15426,7 @@ function cleanupTransientProgress(progressDir, artifactsEnabled) {
|
|
|
15417
15426
|
if (!progressDir || artifactsEnabled)
|
|
15418
15427
|
return;
|
|
15419
15428
|
try {
|
|
15420
|
-
|
|
15429
|
+
fs18.rmSync(progressDir, { recursive: true, force: true });
|
|
15421
15430
|
} catch {}
|
|
15422
15431
|
}
|
|
15423
15432
|
function createForwardSingleUpdate(onUpdate, foregroundControl, agent, index) {
|
|
@@ -15450,7 +15459,7 @@ async function runSinglePath(data, deps) {
|
|
|
15450
15459
|
signal,
|
|
15451
15460
|
runId,
|
|
15452
15461
|
sessionDirForIndex,
|
|
15453
|
-
|
|
15462
|
+
sessionManagerForIndex,
|
|
15454
15463
|
shareEnabled,
|
|
15455
15464
|
artifactConfig,
|
|
15456
15465
|
artifactsDir,
|
|
@@ -15537,6 +15546,7 @@ async function runSinglePath(data, deps) {
|
|
|
15537
15546
|
try {
|
|
15538
15547
|
const supervisorAuthorization = await requestSupervisorAuthorization(deps.pi.events, childIntercomTarget, ctx.getChildSessionOptions?.({ tools: agentConfig.tools }));
|
|
15539
15548
|
const runOptions = {
|
|
15549
|
+
runningCapacity: deps.config.parallel?.runningCapacity,
|
|
15540
15550
|
getChildSessionOptions: ctx.getChildSessionOptions,
|
|
15541
15551
|
resourceLoaderInheritanceSnapshot: deps.pi.getResourceLoaderInheritanceSnapshot?.(),
|
|
15542
15552
|
cwd: effectiveCwd,
|
|
@@ -15547,7 +15557,7 @@ async function runSinglePath(data, deps) {
|
|
|
15547
15557
|
intercomEvents: deps.pi.events,
|
|
15548
15558
|
runId,
|
|
15549
15559
|
sessionDir: sessionDirForIndex(0),
|
|
15550
|
-
|
|
15560
|
+
sessionManager: await sessionManagerForIndex(0),
|
|
15551
15561
|
share: shareEnabled,
|
|
15552
15562
|
artifactsDir: artifactConfig.enabled ? artifactsDir : undefined,
|
|
15553
15563
|
artifactConfig,
|
|
@@ -17515,13 +17525,13 @@ function renderSubagentResult(result, options, theme) {
|
|
|
17515
17525
|
return appendParentAskOutput(c, handoffOutput, theme);
|
|
17516
17526
|
}
|
|
17517
17527
|
// dist/builtin/subagents/src/extension/config.ts
|
|
17518
|
-
import * as
|
|
17528
|
+
import * as fs19 from "node:fs";
|
|
17519
17529
|
import { getAgentConfigPaths as getAgentConfigPaths5 } from "@bastani/atomic";
|
|
17520
17530
|
function loadConfig() {
|
|
17521
17531
|
for (const configPath of getAgentConfigPaths5("extensions", "subagent", "config.json")) {
|
|
17522
17532
|
try {
|
|
17523
|
-
if (
|
|
17524
|
-
return JSON.parse(
|
|
17533
|
+
if (fs19.existsSync(configPath)) {
|
|
17534
|
+
return JSON.parse(fs19.readFileSync(configPath, "utf-8"));
|
|
17525
17535
|
}
|
|
17526
17536
|
} catch (error) {
|
|
17527
17537
|
console.error(`Failed to load subagent config from '${configPath}':`, error);
|
|
@@ -17737,8 +17747,7 @@ var SubagentParams = Type.Object({
|
|
|
17737
17747
|
description: `Agent config for create/update. Agent: name, package (optional namespace; runtime name becomes package.name), description, scope ('user'|'project', default 'user'), systemPrompt, systemPromptMode, inheritProjectContext, inheritSkills, defaultContext ('fresh'|'fork'), model, tools (comma-separated), extensions (comma-separated), skills (comma-separated), thinking, output, reads, progress. String values must be valid JSON.`
|
|
17738
17748
|
})),
|
|
17739
17749
|
tasks: Type.Optional(Type.Array(TaskItem, {
|
|
17740
|
-
|
|
17741
|
-
description: `PARALLEL mode: [{agent, task, count?, output?, outputMode?, reads?, progress?}, ...]. Maximum ${MAX_PARALLEL_TASKS} tasks after count expansion.`
|
|
17750
|
+
description: `PARALLEL mode: [{agent, task, count?, output?, outputMode?, reads?, progress?}, ...]. Maximum tasks after count expansion is configured by parallel.maxTasks (default ${MAX_PARALLEL_TASKS}).`
|
|
17742
17751
|
})),
|
|
17743
17752
|
concurrency: Type.Optional(Type.Integer({
|
|
17744
17753
|
minimum: 1,
|
|
@@ -17859,7 +17868,7 @@ function renderSubagentToolResult(result, options, theme, context) {
|
|
|
17859
17868
|
const outcomes = response.kind === "parallel" ? response.slots.map((slot) => slot.outcome) : [response];
|
|
17860
17869
|
const labels = request && !burst ? [
|
|
17861
17870
|
...request.agent ? [{ agent: request.agent, task: request.task ?? "" }] : [],
|
|
17862
|
-
...(request.tasks ?? []).flatMap((task) => Array.from({ length: Math.
|
|
17871
|
+
...(request.tasks ?? []).flatMap((task) => Array.from({ length: Math.max(1, task.count ?? 1) }, () => task))
|
|
17863
17872
|
] : [];
|
|
17864
17873
|
const lines = outcomes.map((outcome, index) => {
|
|
17865
17874
|
if (outcome.kind === "unstarted")
|
|
@@ -17953,11 +17962,11 @@ function getApiScopedSet(pi, key) {
|
|
|
17953
17962
|
import * as path22 from "node:path";
|
|
17954
17963
|
|
|
17955
17964
|
// dist/builtin/subagents/src/runs/inprocess/runtime-support/temp-cleanup.ts
|
|
17956
|
-
import * as
|
|
17965
|
+
import * as fs20 from "node:fs";
|
|
17957
17966
|
import * as path21 from "node:path";
|
|
17958
17967
|
var SUBAGENT_RUNTIME_TEMP_DIR = path21.join(TEMP_ROOT_DIR, "nested-subagent-events");
|
|
17959
17968
|
function hasEntryNewerThan(filePath, cutoff) {
|
|
17960
|
-
const stat =
|
|
17969
|
+
const stat = fs20.statSync(filePath);
|
|
17961
17970
|
if (stat.mtimeMs >= cutoff)
|
|
17962
17971
|
return true;
|
|
17963
17972
|
if (!stat.isDirectory())
|
|
@@ -17967,14 +17976,14 @@ function hasEntryNewerThan(filePath, cutoff) {
|
|
|
17967
17976
|
function directoryHasEntryNewerThan(dirPath, cutoff) {
|
|
17968
17977
|
let entries;
|
|
17969
17978
|
try {
|
|
17970
|
-
entries =
|
|
17979
|
+
entries = fs20.readdirSync(dirPath);
|
|
17971
17980
|
} catch {
|
|
17972
17981
|
return false;
|
|
17973
17982
|
}
|
|
17974
17983
|
for (const entry of entries) {
|
|
17975
17984
|
const childPath = path21.join(dirPath, entry);
|
|
17976
17985
|
try {
|
|
17977
|
-
const stat =
|
|
17986
|
+
const stat = fs20.statSync(childPath);
|
|
17978
17987
|
if (stat.mtimeMs >= cutoff)
|
|
17979
17988
|
return true;
|
|
17980
17989
|
if (stat.isDirectory() && directoryHasEntryNewerThan(childPath, cutoff))
|
|
@@ -17986,7 +17995,7 @@ function directoryHasEntryNewerThan(dirPath, cutoff) {
|
|
|
17986
17995
|
function cleanupOldSubdirectories(root, maxAgeDays) {
|
|
17987
17996
|
let entries;
|
|
17988
17997
|
try {
|
|
17989
|
-
entries =
|
|
17998
|
+
entries = fs20.readdirSync(root);
|
|
17990
17999
|
} catch (error) {
|
|
17991
18000
|
if (error.code === "ENOENT")
|
|
17992
18001
|
return;
|
|
@@ -17997,7 +18006,7 @@ function cleanupOldSubdirectories(root, maxAgeDays) {
|
|
|
17997
18006
|
const entryPath = path21.join(root, entry);
|
|
17998
18007
|
try {
|
|
17999
18008
|
if (!hasEntryNewerThan(entryPath, cutoff))
|
|
18000
|
-
|
|
18009
|
+
fs20.rmSync(entryPath, { recursive: true, force: true });
|
|
18001
18010
|
} catch {}
|
|
18002
18011
|
}
|
|
18003
18012
|
}
|
|
@@ -18102,7 +18111,7 @@ function getSubagentSessionRoot(parentSessionFile) {
|
|
|
18102
18111
|
const sessionsDir = path23.dirname(parentSessionFile);
|
|
18103
18112
|
return path23.join(sessionsDir, baseName);
|
|
18104
18113
|
}
|
|
18105
|
-
return
|
|
18114
|
+
return fs21.mkdtempSync(path23.join(os8.tmpdir(), `${APP_NAME3}-subagent-session-`));
|
|
18106
18115
|
}
|
|
18107
18116
|
function expandTilde2(p) {
|
|
18108
18117
|
return p.startsWith("~/") ? path23.join(os8.homedir(), p.slice(2)) : p;
|