@bastani/atomic 0.9.85 → 0.9.86-alpha.1
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 +20 -0
- package/dist/builtin/intercom/CHANGELOG.md +15 -0
- package/dist/builtin/intercom/README.md +10 -9
- package/dist/builtin/intercom/broker/away-asks.ts +260 -0
- package/dist/builtin/intercom/broker/broker.ts +170 -9
- package/dist/builtin/intercom/broker/client.ts +5 -3
- package/dist/builtin/intercom/broker/held-reply-targets.ts +5 -0
- package/dist/builtin/intercom/broker/multinode-router.ts +16 -7
- package/dist/builtin/intercom/broker/paths.ts +5 -0
- package/dist/builtin/intercom/broker/pending-question-index.ts +119 -0
- package/dist/builtin/intercom/broker/released-asker-replies.ts +39 -0
- package/dist/builtin/intercom/broker/send-handler.ts +44 -3
- package/dist/builtin/intercom/broker/terminal-questions.ts +2 -0
- package/dist/builtin/intercom/index.bundle.mjs +799 -177
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/intercom/retry-policy.ts +1 -1
- package/dist/builtin/intercom/skills/intercom/SKILL.md +29 -35
- package/dist/builtin/intercom/types.ts +7 -2
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +20 -0
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/skills/subagent/SKILL.md +1 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +2765 -2719
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +12 -0
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/builtin/workflows/src/authoring.d.ts +1 -1
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +371 -193
- package/dist/builtin/workflows/src/extension/local-worker-entry.mjs +358 -181
- package/dist/builtin/workflows/src/index.js +356 -183
- package/dist/builtin/workflows/src/local-worker-entry.mjs +358 -181
- package/dist/builtin/workflows/src/shared/worktree-restore-outcome.d.ts +16 -0
- package/dist/builtin/workflows/src/workers/workspace-binding.d.ts +13 -2
- package/dist/core/agent-session-methods.d.ts +1 -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-prompt.d.ts.map +1 -1
- package/dist/core/agent-session-prompt.js +2 -35
- package/dist/core/agent-session-prompt.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts +3 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +12 -5
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-state.d.ts.map +1 -1
- package/dist/core/agent-session-state.js +14 -1
- package/dist/core/agent-session-state.js.map +1 -1
- package/dist/core/agent-session.d.ts +2 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +3 -1
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/resume/index.d.ts +1 -1
- package/dist/core/resume/index.d.ts.map +1 -1
- package/dist/core/resume/index.js +1 -1
- package/dist/core/resume/index.js.map +1 -1
- package/dist/core/resume/path-mapping.d.ts +10 -0
- package/dist/core/resume/path-mapping.d.ts.map +1 -1
- package/dist/core/resume/path-mapping.js +20 -0
- package/dist/core/resume/path-mapping.js.map +1 -1
- package/dist/core/resume/session-resume.d.ts +5 -0
- package/dist/core/resume/session-resume.d.ts.map +1 -1
- package/dist/core/resume/session-resume.js +24 -9
- package/dist/core/resume/session-resume.js.map +1 -1
- package/dist/core/session-worktree-snapshots.d.ts +5 -8
- package/dist/core/session-worktree-snapshots.d.ts.map +1 -1
- package/dist/core/session-worktree-snapshots.js +34 -99
- package/dist/core/session-worktree-snapshots.js.map +1 -1
- package/dist/core/skill-catalog.d.ts +11 -0
- package/dist/core/skill-catalog.d.ts.map +1 -1
- package/dist/core/skill-catalog.js +31 -0
- package/dist/core/skill-catalog.js.map +1 -1
- package/dist/core/tasks/agent-adapter.d.ts +2 -0
- package/dist/core/tasks/agent-adapter.d.ts.map +1 -1
- package/dist/core/tasks/agent-adapter.js +5 -1
- package/dist/core/tasks/agent-adapter.js.map +1 -1
- package/dist/core/tasks/supervisor.d.ts +17 -0
- package/dist/core/tasks/supervisor.d.ts.map +1 -1
- package/dist/core/tasks/supervisor.js +12 -6
- package/dist/core/tasks/supervisor.js.map +1 -1
- package/dist/core/tasks/task-view-source.d.ts +10 -0
- package/dist/core/tasks/task-view-source.d.ts.map +1 -1
- package/dist/core/tasks/task-view-source.js +24 -1
- package/dist/core/tasks/task-view-source.js.map +1 -1
- package/dist/core/worktree-snapshot/best-restore.d.ts +45 -0
- package/dist/core/worktree-snapshot/best-restore.d.ts.map +1 -0
- package/dist/core/worktree-snapshot/best-restore.js +92 -0
- package/dist/core/worktree-snapshot/best-restore.js.map +1 -0
- package/dist/core/worktree-snapshot/git.d.ts +2 -2
- package/dist/core/worktree-snapshot/git.d.ts.map +1 -1
- package/dist/core/worktree-snapshot/git.js +2 -5
- package/dist/core/worktree-snapshot/git.js.map +1 -1
- package/dist/core/worktree-snapshot/index.d.ts +1 -0
- package/dist/core/worktree-snapshot/index.d.ts.map +1 -1
- package/dist/core/worktree-snapshot/index.js +1 -0
- package/dist/core/worktree-snapshot/index.js.map +1 -1
- package/dist/core/worktree-snapshot/restore.d.ts.map +1 -1
- package/dist/core/worktree-snapshot/restore.js +18 -2
- package/dist/core/worktree-snapshot/restore.js.map +1 -1
- package/dist/index.d.ts +3 -2
- 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/chat-autocomplete.d.ts +7 -0
- package/dist/modes/interactive/chat-autocomplete.d.ts.map +1 -0
- package/dist/modes/interactive/chat-autocomplete.js +85 -0
- package/dist/modes/interactive/chat-autocomplete.js.map +1 -0
- package/dist/modes/interactive/components/task-transcript-page.d.ts.map +1 -1
- package/dist/modes/interactive/components/task-transcript-page.js +8 -0
- package/dist/modes/interactive/components/task-transcript-page.js.map +1 -1
- package/dist/modes/interactive/interactive-autocomplete.js +3 -79
- package/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
- package/dist/modes/interactive/skill-command-autocomplete.d.ts +6 -0
- package/dist/modes/interactive/skill-command-autocomplete.d.ts.map +1 -1
- package/dist/modes/interactive/skill-command-autocomplete.js +18 -2
- package/dist/modes/interactive/skill-command-autocomplete.js.map +1 -1
- package/docs/background-tasks.md +1 -1
- package/docs/intercom/operations.md +4 -4
- package/docs/intercom/reference.md +39 -8
- package/docs/intercom.md +26 -9
- package/docs/skills.md +3 -1
- package/docs/subagents.md +2 -0
- package/docs/workflows/api-reference.md +3 -3
- package/docs/workflows/operations.md +2 -2
- package/docs/worktree-snapshots.md +10 -4
- package/npm-shrinkwrap.json +32 -32
- package/package.json +3 -3
|
@@ -905,6 +905,7 @@ class JournalProjection {
|
|
|
905
905
|
...handle.repositoryRoot !== undefined ? { repositoryRoot: handle.repositoryRoot } : existing?.handle.repositoryRoot !== undefined ? { repositoryRoot: existing.handle.repositoryRoot } : {},
|
|
906
906
|
...handle.gitWorktreeRoot !== undefined ? { gitWorktreeRoot: handle.gitWorktreeRoot } : existing?.handle.gitWorktreeRoot !== undefined ? { gitWorktreeRoot: existing.handle.gitWorktreeRoot } : {},
|
|
907
907
|
...(handle.worktreeRootMappings ?? existing?.handle.worktreeRootMappings) !== undefined ? { worktreeRootMappings: handle.worktreeRootMappings ?? existing?.handle.worktreeRootMappings } : {},
|
|
908
|
+
...(handle.worktreeRestoreOutcomes ?? existing?.handle.worktreeRestoreOutcomes) !== undefined ? { worktreeRestoreOutcomes: handle.worktreeRestoreOutcomes ?? existing?.handle.worktreeRestoreOutcomes } : {},
|
|
908
909
|
pendingStageMessages: handle.pendingStageMessages ?? existing?.handle.pendingStageMessages ?? [],
|
|
909
910
|
...handle.possibleStages !== undefined ? { possibleStages: handle.possibleStages } : existing?.handle.possibleStages !== undefined ? { possibleStages: existing.handle.possibleStages } : {},
|
|
910
911
|
...forkedFrom !== undefined ? { forkedFrom } : {},
|
|
@@ -1203,6 +1204,7 @@ class JournalProjection {
|
|
|
1203
1204
|
...h.gitWorktreeRoot !== undefined ? { gitWorktreeRoot: h.gitWorktreeRoot } : {},
|
|
1204
1205
|
...h.snapshots !== undefined ? { snapshots: h.snapshots } : {},
|
|
1205
1206
|
...h.worktreeRootMappings !== undefined ? { worktreeRootMappings: h.worktreeRootMappings } : {},
|
|
1207
|
+
...h.worktreeRestoreOutcomes !== undefined ? { worktreeRestoreOutcomes: h.worktreeRestoreOutcomes } : {},
|
|
1206
1208
|
...h.forkedFrom !== undefined ? { forkedFrom: h.forkedFrom } : {},
|
|
1207
1209
|
...h.workspace !== undefined ? { workspace: h.workspace } : {},
|
|
1208
1210
|
...h.snapshot !== undefined ? { snapshot: h.snapshot } : {},
|
|
@@ -7329,14 +7331,20 @@ var init_sqlite_run_journal = __esm(() => {
|
|
|
7329
7331
|
});
|
|
7330
7332
|
|
|
7331
7333
|
// dist/builtin/workflows/src/durable/worktree-snapshots.ts
|
|
7332
|
-
import {
|
|
7334
|
+
import { existsSync as existsSync2 } from "node:fs";
|
|
7335
|
+
import { isAbsolute as isAbsolute2, join as join3, relative, resolve, sep } from "node:path";
|
|
7333
7336
|
import {
|
|
7334
7337
|
canonicalizeWorktreePath,
|
|
7338
|
+
formatDegradedRestoreNotice,
|
|
7339
|
+
formatUnrestoredNotice,
|
|
7340
|
+
isGitUnavailableError,
|
|
7335
7341
|
isHeadOnlyAdvance,
|
|
7336
7342
|
isWorkspaceDriftError,
|
|
7343
|
+
isWorkspaceRestoreError,
|
|
7337
7344
|
isWorkspaceSnapshotError,
|
|
7338
7345
|
removeRestoredWorktree,
|
|
7339
|
-
|
|
7346
|
+
restoreBestWorktree,
|
|
7347
|
+
unrestoredRecord,
|
|
7340
7348
|
verifyWorktree,
|
|
7341
7349
|
WorkspaceDriftError
|
|
7342
7350
|
} from "@bastani/atomic";
|
|
@@ -7414,13 +7422,26 @@ function originalRoot(root, mappings) {
|
|
|
7414
7422
|
}
|
|
7415
7423
|
return root;
|
|
7416
7424
|
}
|
|
7425
|
+
function earlierBoundaryHeads(boundaries, root, mappings, snapshot) {
|
|
7426
|
+
const heads = [];
|
|
7427
|
+
for (const boundary of [...boundaries].reverse()) {
|
|
7428
|
+
if (originalRoot(boundary.root, mappings) !== root)
|
|
7429
|
+
continue;
|
|
7430
|
+
const head = boundary.snapshot.head;
|
|
7431
|
+
if (head !== snapshot.head && !heads.includes(head))
|
|
7432
|
+
heads.push(head);
|
|
7433
|
+
}
|
|
7434
|
+
return heads;
|
|
7435
|
+
}
|
|
7417
7436
|
async function resolveWorkflowSnapshotFrontier(journal, runId, options = {}) {
|
|
7418
7437
|
const mappings = options.mappings ?? [];
|
|
7438
|
+
const boundaries = await listWorkflowSnapshotBoundaries(journal, runId);
|
|
7419
7439
|
const latest = new Map;
|
|
7420
|
-
for (const boundary of
|
|
7440
|
+
for (const boundary of boundaries) {
|
|
7421
7441
|
latest.set(originalRoot(boundary.root, mappings), boundary);
|
|
7422
7442
|
}
|
|
7423
7443
|
const restored = [];
|
|
7444
|
+
const unrestored = [];
|
|
7424
7445
|
const announcements = [];
|
|
7425
7446
|
try {
|
|
7426
7447
|
for (const [root, { snapshot }] of latest) {
|
|
@@ -7431,11 +7452,16 @@ async function resolveWorkflowSnapshotFrontier(journal, runId, options = {}) {
|
|
|
7431
7452
|
await verifyWorktree(snapshot, mapped, { settings: options.settings, signal: options.signal });
|
|
7432
7453
|
continue;
|
|
7433
7454
|
} catch (error) {
|
|
7455
|
+
options.signal?.throwIfAborted();
|
|
7456
|
+
if (isGitUnavailableError(error)) {
|
|
7457
|
+
unrestored.push({ root, here: mapped, snapshot, reason: error });
|
|
7458
|
+
continue;
|
|
7459
|
+
}
|
|
7434
7460
|
if (isWorkspaceDriftError(error) && await isHeadOnlyAdvance(error, options.signal))
|
|
7435
7461
|
continue;
|
|
7436
7462
|
if (isWorkspaceDriftError(error))
|
|
7437
7463
|
drift = error;
|
|
7438
|
-
else if (isWorkspaceSnapshotError(error)) {
|
|
7464
|
+
else if (isWorkspaceSnapshotError(error) || isWorkspaceRestoreError(error)) {
|
|
7439
7465
|
drift = new WorkspaceDriftError({
|
|
7440
7466
|
root: mapped,
|
|
7441
7467
|
expectedHead: snapshot.head,
|
|
@@ -7449,11 +7475,17 @@ async function resolveWorkflowSnapshotFrontier(journal, runId, options = {}) {
|
|
|
7449
7475
|
}
|
|
7450
7476
|
let worktree;
|
|
7451
7477
|
try {
|
|
7452
|
-
|
|
7478
|
+
const best = await restoreBestWorktree(snapshot, {
|
|
7453
7479
|
blobs: journal.snapshotBlobs,
|
|
7454
7480
|
storeDir: options.storeDir,
|
|
7455
|
-
signal: options.signal
|
|
7481
|
+
signal: options.signal,
|
|
7482
|
+
candidates: earlierBoundaryHeads(boundaries, root, mappings, snapshot)
|
|
7456
7483
|
});
|
|
7484
|
+
if (best.status === "unrestored") {
|
|
7485
|
+
unrestored.push({ root, here: mapped, snapshot, reason: best.reason });
|
|
7486
|
+
continue;
|
|
7487
|
+
}
|
|
7488
|
+
worktree = best;
|
|
7457
7489
|
} catch (cause) {
|
|
7458
7490
|
options.signal?.throwIfAborted();
|
|
7459
7491
|
throw new WorkspaceDriftError({
|
|
@@ -7471,7 +7503,8 @@ async function resolveWorkflowSnapshotFrontier(journal, runId, options = {}) {
|
|
|
7471
7503
|
to: worktree.path,
|
|
7472
7504
|
snapshotId: snapshot.id,
|
|
7473
7505
|
tree: snapshot.tree,
|
|
7474
|
-
restoredAt: new Date().toISOString()
|
|
7506
|
+
restoredAt: new Date().toISOString(),
|
|
7507
|
+
...worktree.degraded === undefined ? {} : { degraded: worktree.degraded }
|
|
7475
7508
|
};
|
|
7476
7509
|
restored.push(mapping);
|
|
7477
7510
|
announcements.push({ mapping, warnings: worktree.warnings });
|
|
@@ -7501,8 +7534,52 @@ async function resolveWorkflowSnapshotFrontier(journal, runId, options = {}) {
|
|
|
7501
7534
|
for (const warning of warnings)
|
|
7502
7535
|
options.onWarning?.(warning, mapping);
|
|
7503
7536
|
}
|
|
7537
|
+
for (const checkout of unrestored)
|
|
7538
|
+
options.onUnrestored?.(checkout);
|
|
7504
7539
|
return restored;
|
|
7505
7540
|
}
|
|
7541
|
+
function within(root, path) {
|
|
7542
|
+
const suffix = relative(root, path);
|
|
7543
|
+
return suffix !== ".." && !suffix.startsWith(`..${sep}`) && !isAbsolute2(suffix);
|
|
7544
|
+
}
|
|
7545
|
+
function runWorktreeRestoreOutcomes(input) {
|
|
7546
|
+
const list = [];
|
|
7547
|
+
for (const mapping of input.restored) {
|
|
7548
|
+
if (mapping.degraded === undefined)
|
|
7549
|
+
continue;
|
|
7550
|
+
list.push({
|
|
7551
|
+
root: mapping.from,
|
|
7552
|
+
snapshotId: mapping.snapshotId,
|
|
7553
|
+
message: formatDegradedRestoreNotice(mapping, input.snapshots.get(mapping.snapshotId), [], "workflow run"),
|
|
7554
|
+
at: mapping.restoredAt,
|
|
7555
|
+
degraded: mapping.degraded
|
|
7556
|
+
});
|
|
7557
|
+
}
|
|
7558
|
+
const { continuing, launchCwd } = input;
|
|
7559
|
+
const leftHere = continuing !== undefined && input.unrestored.some((checkout) => within(canonicalizeWorktreePath(checkout.here), canonicalizeWorktreePath(continuing)));
|
|
7560
|
+
const launch = leftHere && launchCwd !== undefined && !existsSync2(continuing);
|
|
7561
|
+
const continuedIn = launch ? resolve(launchCwd) : undefined;
|
|
7562
|
+
for (const checkout of input.unrestored) {
|
|
7563
|
+
const record = unrestoredRecord(checkout.snapshot, checkout.reason, continuedIn ?? continuing ?? checkout.here, launch ? "launch" : "recorded");
|
|
7564
|
+
list.push({
|
|
7565
|
+
root: checkout.root,
|
|
7566
|
+
snapshotId: checkout.snapshot.id,
|
|
7567
|
+
message: formatUnrestoredNotice(checkout.root, record, "workflow run"),
|
|
7568
|
+
at: record.at,
|
|
7569
|
+
unrestored: record
|
|
7570
|
+
});
|
|
7571
|
+
}
|
|
7572
|
+
const fresh = [...list];
|
|
7573
|
+
const touched = new Set(list.map((outcome) => outcome.root));
|
|
7574
|
+
for (const outcome of input.previous) {
|
|
7575
|
+
if (outcome.degraded === undefined || touched.has(outcome.root))
|
|
7576
|
+
continue;
|
|
7577
|
+
const current = input.mappings.findLast((mapping) => mapping.from === outcome.root);
|
|
7578
|
+
if (current?.degraded !== undefined && current.snapshotId === outcome.snapshotId)
|
|
7579
|
+
list.push(outcome);
|
|
7580
|
+
}
|
|
7581
|
+
return continuedIn === undefined ? { list, fresh } : { list, fresh, continuedIn };
|
|
7582
|
+
}
|
|
7506
7583
|
var init_worktree_snapshots = __esm(() => {
|
|
7507
7584
|
init_types();
|
|
7508
7585
|
});
|
|
@@ -15430,7 +15507,7 @@ var init_child_invocation = __esm(() => {
|
|
|
15430
15507
|
});
|
|
15431
15508
|
|
|
15432
15509
|
// dist/builtin/workflows/src/engine/run-resume-preflight.ts
|
|
15433
|
-
import { existsSync as
|
|
15510
|
+
import { existsSync as existsSync3 } from "node:fs";
|
|
15434
15511
|
import { isAbsolute as isAbsolute3 } from "node:path";
|
|
15435
15512
|
import { JsonlSessionStore, resolveSessionStore } from "@bastani/atomic";
|
|
15436
15513
|
function describeStore(store, selectedBy) {
|
|
@@ -15466,7 +15543,7 @@ async function assertWaitingStageSessionsExist(waiting, runId, storage, rootRunI
|
|
|
15466
15543
|
checked.add(stage.sessionId);
|
|
15467
15544
|
if (await opened.store.readHeader(stage.sessionId) !== undefined)
|
|
15468
15545
|
continue;
|
|
15469
|
-
if (stage.sessionFile !== undefined && isAbsolute3(stage.sessionFile) &&
|
|
15546
|
+
if (stage.sessionFile !== undefined && isAbsolute3(stage.sessionFile) && existsSync3(stage.sessionFile))
|
|
15470
15547
|
continue;
|
|
15471
15548
|
missing.push(stage.sessionId);
|
|
15472
15549
|
}
|
|
@@ -15498,7 +15575,7 @@ var init_run_resume_preflight = __esm(() => {
|
|
|
15498
15575
|
|
|
15499
15576
|
// dist/builtin/workflows/src/shared/stage-session-store.ts
|
|
15500
15577
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
15501
|
-
import { dirname as dirname3, resolve } from "node:path";
|
|
15578
|
+
import { dirname as dirname3, resolve as resolve2 } from "node:path";
|
|
15502
15579
|
import {
|
|
15503
15580
|
assertSessionBlobStore,
|
|
15504
15581
|
copySessionBlobs,
|
|
@@ -15541,11 +15618,11 @@ async function forkStageSession(store, sessionId, cwd, options, destination = st
|
|
|
15541
15618
|
async function migrateLegacyStageSession(store, sessionId, sessionFile) {
|
|
15542
15619
|
if (sessionFile === undefined || await store.readHeader(sessionId) !== undefined)
|
|
15543
15620
|
return;
|
|
15544
|
-
const location =
|
|
15621
|
+
const location = resolve2(sessionFile);
|
|
15545
15622
|
const legacy = await JsonlSessionStore2.open(dirname3(location), { exactDirectory: true, scanExisting: false });
|
|
15546
15623
|
try {
|
|
15547
15624
|
for await (const file of legacy.scanFiles()) {
|
|
15548
|
-
if (
|
|
15625
|
+
if (resolve2(file.location) !== location || file.header.id !== sessionId)
|
|
15549
15626
|
continue;
|
|
15550
15627
|
const snapshot = await file.read();
|
|
15551
15628
|
if (await store.readHeader(sessionId) === undefined)
|
|
@@ -17532,24 +17609,11 @@ var init_factory = __esm(() => {
|
|
|
17532
17609
|
});
|
|
17533
17610
|
|
|
17534
17611
|
// dist/builtin/workflows/src/durable/run-restore-preconditions.ts
|
|
17535
|
-
|
|
17536
|
-
runRestorePreconditionError,
|
|
17537
|
-
worktreeNeedsRestore
|
|
17538
|
-
} from "@bastani/atomic";
|
|
17539
|
-
async function runRestorePreconditionFailure(journal, runId, mappings, settings, signal) {
|
|
17540
|
-
const restoring = [];
|
|
17541
|
-
for (const boundary of workflowSnapshotFrontier(await listWorkflowSnapshotBoundaries(journal, runId))) {
|
|
17542
|
-
const here = mapWorkflowWorktreePath(boundary.root, mappings);
|
|
17543
|
-
if (await worktreeNeedsRestore(boundary.snapshot, here, { settings, signal })) {
|
|
17544
|
-
restoring.push({ root: boundary.root, remotes: boundary.snapshot.remotes });
|
|
17545
|
-
}
|
|
17546
|
-
}
|
|
17547
|
-
return await runRestorePreconditionError(runId, restoring);
|
|
17548
|
-
}
|
|
17549
|
-
var restorePreconditionsChecked;
|
|
17612
|
+
var restorePreconditionsChecked, resumeLaunchCwd, recordedInvocationCwd;
|
|
17550
17613
|
var init_run_restore_preconditions = __esm(() => {
|
|
17551
|
-
init_worktree_snapshots();
|
|
17552
17614
|
restorePreconditionsChecked = Symbol("restore-preconditions-checked");
|
|
17615
|
+
resumeLaunchCwd = Symbol("resume-launch-cwd");
|
|
17616
|
+
recordedInvocationCwd = Symbol("recorded-invocation-cwd");
|
|
17553
17617
|
});
|
|
17554
17618
|
|
|
17555
17619
|
// dist/builtin/workflows/src/durable/run-result.ts
|
|
@@ -17739,11 +17803,11 @@ async function transitionDurableWorkflowStatus(backend, workflowId, expectedStat
|
|
|
17739
17803
|
}
|
|
17740
17804
|
|
|
17741
17805
|
// dist/builtin/workflows/src/durable/worktree-snapshot-recorder.ts
|
|
17742
|
-
import { isAbsolute as isAbsolute4, relative as relative2, resolve as
|
|
17806
|
+
import { isAbsolute as isAbsolute4, relative as relative2, resolve as resolve3, sep as sep2 } from "node:path";
|
|
17743
17807
|
import {
|
|
17744
17808
|
canonicalizeWorktreePath as canonicalizeWorktreePath2,
|
|
17745
17809
|
captureWorktreeSnapshot,
|
|
17746
|
-
isGitUnavailableError,
|
|
17810
|
+
isGitUnavailableError as isGitUnavailableError2,
|
|
17747
17811
|
isWorkspaceGitError,
|
|
17748
17812
|
serializeWorkspaceError,
|
|
17749
17813
|
WorkspaceSnapshotError
|
|
@@ -17791,7 +17855,7 @@ function containsDirectory(root, directory) {
|
|
|
17791
17855
|
function createWorkflowSnapshotRecorder(input) {
|
|
17792
17856
|
let gitUnavailable = false;
|
|
17793
17857
|
const report = (error) => {
|
|
17794
|
-
if (
|
|
17858
|
+
if (isGitUnavailableError2(error))
|
|
17795
17859
|
gitUnavailable = true;
|
|
17796
17860
|
input.run.snapshotUnavailable ??= serializeWorkspaceError(error);
|
|
17797
17861
|
};
|
|
@@ -17808,8 +17872,8 @@ function createWorkflowSnapshotRecorder(input) {
|
|
|
17808
17872
|
signal?.throwIfAborted();
|
|
17809
17873
|
const latest = await snapshotAncestry(journal, input.rootRunId);
|
|
17810
17874
|
const snapshots = [];
|
|
17811
|
-
const workflowCwd =
|
|
17812
|
-
for (const directory of new Set([workflowCwd, ...directories.map((path) =>
|
|
17875
|
+
const workflowCwd = resolve3(input.cwd());
|
|
17876
|
+
for (const directory of new Set([workflowCwd, ...directories.map((path) => resolve3(workflowCwd, path))])) {
|
|
17813
17877
|
try {
|
|
17814
17878
|
const physical = canonicalizeWorktreePath2(directory);
|
|
17815
17879
|
const previous = [...latest.values()].filter((snapshot) => containsDirectory(snapshot.root, physical)).sort((a, b) => b.root.length - a.root.length)[0];
|
|
@@ -18256,7 +18320,7 @@ import {
|
|
|
18256
18320
|
createChildProcessEnvironment,
|
|
18257
18321
|
createGitEnvironment,
|
|
18258
18322
|
isGitProvisionError as isGitProvisionError2,
|
|
18259
|
-
isGitUnavailableError as
|
|
18323
|
+
isGitUnavailableError as isGitUnavailableError3,
|
|
18260
18324
|
isRetryableGitProvisionError,
|
|
18261
18325
|
resolveGit,
|
|
18262
18326
|
resolveGitSync
|
|
@@ -18309,7 +18373,7 @@ async function prepareTaskGit(signal) {
|
|
|
18309
18373
|
resolveGitSync();
|
|
18310
18374
|
return;
|
|
18311
18375
|
} catch (error) {
|
|
18312
|
-
const notInstalled =
|
|
18376
|
+
const notInstalled = isGitUnavailableError3(error) && error.code === "not-installed";
|
|
18313
18377
|
if (!isGitProvisionError2(error) || !(notInstalled || isRetryableGitProvisionError(error)))
|
|
18314
18378
|
return;
|
|
18315
18379
|
}
|
|
@@ -19613,7 +19677,7 @@ var init_worktree = __esm(() => {
|
|
|
19613
19677
|
|
|
19614
19678
|
// dist/builtin/workflows/src/runs/shared/worktree-cwd.ts
|
|
19615
19679
|
import { lstatSync as lstatSync6, realpathSync as realpathSync4 } from "node:fs";
|
|
19616
|
-
import { dirname as dirname10, isAbsolute as isAbsolute9, relative as relative6, resolve as
|
|
19680
|
+
import { dirname as dirname10, isAbsolute as isAbsolute9, relative as relative6, resolve as resolve10, sep as sep7 } from "node:path";
|
|
19617
19681
|
function relativePathWithin(root, candidate) {
|
|
19618
19682
|
const path = relative6(root, candidate);
|
|
19619
19683
|
return path === ".." || path.startsWith(`..${sep7}`) || isAbsolute9(path) ? undefined : path;
|
|
@@ -19632,14 +19696,14 @@ function resolveWorktreeStageCwd(cwd, setup) {
|
|
|
19632
19696
|
if (cwd === undefined || cwd.length === 0)
|
|
19633
19697
|
return;
|
|
19634
19698
|
const absoluteInput = isAbsolute9(cwd);
|
|
19635
|
-
const candidate = absoluteInput ? cwd :
|
|
19699
|
+
const candidate = absoluteInput ? cwd : resolve10(setup.cwd, cwd);
|
|
19636
19700
|
if (!absoluteInput && relativePathWithin(setup.worktreeRoot, candidate) === undefined) {
|
|
19637
19701
|
throw new Error(`atomic-workflows: relative cwd ${cwd} escapes gitWorktreeDir ${setup.worktreeRoot}; choose a cwd inside the worktree.`);
|
|
19638
19702
|
}
|
|
19639
19703
|
const candidateRealPath = existingRealPath(candidate, "cwd");
|
|
19640
19704
|
const worktreeRelative = relativePathWithin(worktreeRoot, candidateRealPath);
|
|
19641
19705
|
if (worktreeRelative !== undefined)
|
|
19642
|
-
return
|
|
19706
|
+
return resolve10(setup.worktreeRoot, worktreeRelative);
|
|
19643
19707
|
if (!isAbsolute9(cwd)) {
|
|
19644
19708
|
throw new Error(`atomic-workflows: relative cwd ${cwd} escapes gitWorktreeDir ${setup.worktreeRoot}; choose a path that remains inside the selected worktree.`);
|
|
19645
19709
|
}
|
|
@@ -19650,7 +19714,7 @@ function resolveWorktreeStageCwd(cwd, setup) {
|
|
|
19650
19714
|
if (repositoryRelative === undefined) {
|
|
19651
19715
|
throw new Error(repositoryRoot === worktreeRoot ? `atomic-workflows: cwd ${cwd} is outside gitWorktreeDir ${setup.worktreeRoot}, which belongs to a different repository than the invoking cwd; choose a cwd inside the worktree, or omit cwd.` : `atomic-workflows: cwd ${cwd} is outside gitWorktreeDir ${setup.worktreeRoot}; use a cwd inside the invoking repository so Atomic can remap it, or omit cwd.`);
|
|
19652
19716
|
}
|
|
19653
|
-
const mappedCwd =
|
|
19717
|
+
const mappedCwd = resolve10(setup.worktreeRoot, repositoryRelative);
|
|
19654
19718
|
const mappedRealPath = existingRealPath(mappedCwd, "remapped worktree cwd");
|
|
19655
19719
|
if (relativePathWithin(worktreeRoot, mappedRealPath) === undefined) {
|
|
19656
19720
|
throw new Error(`atomic-workflows: cwd ${cwd} remaps through a path that resolves outside gitWorktreeDir ${setup.worktreeRoot}; remove the escaping symlink or omit cwd.`);
|
|
@@ -19660,8 +19724,8 @@ function resolveWorktreeStageCwd(cwd, setup) {
|
|
|
19660
19724
|
var init_worktree_cwd = () => {};
|
|
19661
19725
|
|
|
19662
19726
|
// dist/builtin/workflows/src/runs/foreground/executor-task-prompts.ts
|
|
19663
|
-
import { existsSync as
|
|
19664
|
-
import { isAbsolute as isAbsolute10, resolve as
|
|
19727
|
+
import { existsSync as existsSync6 } from "node:fs";
|
|
19728
|
+
import { isAbsolute as isAbsolute10, resolve as resolve11 } from "node:path";
|
|
19665
19729
|
function normalizeTaskContexts(previous) {
|
|
19666
19730
|
if (previous === undefined)
|
|
19667
19731
|
return [];
|
|
@@ -19714,7 +19778,7 @@ function taskPrevious(options) {
|
|
|
19714
19778
|
function resolveWorkflowPath(filePath, baseDir) {
|
|
19715
19779
|
if (isAbsolute10(filePath))
|
|
19716
19780
|
return filePath;
|
|
19717
|
-
return
|
|
19781
|
+
return resolve11(baseDir ?? process.cwd(), filePath);
|
|
19718
19782
|
}
|
|
19719
19783
|
function taskBaseDir(options) {
|
|
19720
19784
|
if (typeof options.chainDir === "string" && options.chainDir.trim().length > 0) {
|
|
@@ -19730,7 +19794,7 @@ function taskReadInstruction(options, requireFiles) {
|
|
|
19730
19794
|
return "";
|
|
19731
19795
|
const baseDir = taskBaseDir(options);
|
|
19732
19796
|
const files = options.reads.map((file) => resolveWorkflowPath(file, baseDir));
|
|
19733
|
-
const missing = requireFiles ? files.find((file) => !
|
|
19797
|
+
const missing = requireFiles ? files.find((file) => !existsSync6(file)) : undefined;
|
|
19734
19798
|
if (missing !== undefined) {
|
|
19735
19799
|
throw new Error(`atomic-workflows: referenced artifact does not exist: ${missing}`);
|
|
19736
19800
|
}
|
|
@@ -19869,7 +19933,7 @@ function taskWithSharedDefaults(taskOptions, options) {
|
|
|
19869
19933
|
var init_executor_task_prompts = () => {};
|
|
19870
19934
|
|
|
19871
19935
|
// dist/builtin/workflows/src/runs/foreground/executor-direct-helpers.ts
|
|
19872
|
-
import { isAbsolute as isAbsolute11, join as join13, resolve as
|
|
19936
|
+
import { isAbsolute as isAbsolute11, join as join13, resolve as resolve12 } from "node:path";
|
|
19873
19937
|
import { CONFIG_DIR_NAME, inheritWorkspace, WorkspaceBindingError as WorkspaceBindingError2 } from "@bastani/atomic";
|
|
19874
19938
|
function positiveConcurrency(value2) {
|
|
19875
19939
|
if (typeof value2 !== "number" || !Number.isFinite(value2) || value2 < 1)
|
|
@@ -20036,7 +20100,7 @@ function workflowInvocationMetadata(inputDefaults, workflowInvocationCwd, cache,
|
|
|
20036
20100
|
function resolvedTaskCwd(cwd, workflowInvocationCwd) {
|
|
20037
20101
|
if (cwd === undefined)
|
|
20038
20102
|
return;
|
|
20039
|
-
return isAbsolute11(cwd) ? cwd :
|
|
20103
|
+
return isAbsolute11(cwd) ? cwd : resolve12(workflowInvocationCwd, cwd);
|
|
20040
20104
|
}
|
|
20041
20105
|
function taskWorktreeOutputsRoot(runId) {
|
|
20042
20106
|
return join13(workflowArtifactRunPath(runId), "task-outputs");
|
|
@@ -20049,7 +20113,7 @@ function prepareTaskWorktrees(tasks, options, runId, scope, workflowInvocationCw
|
|
|
20049
20113
|
throw new Error("atomic-workflows: worktree and gitWorktreeDir are mutually exclusive; use gitWorktreeDir for a reusable worktree or worktree:true for temporary isolated worktrees.");
|
|
20050
20114
|
}
|
|
20051
20115
|
const explicitCwd = tasks.find((task) => typeof task.cwd === "string")?.cwd;
|
|
20052
|
-
const sharedCwd = explicitCwd === undefined ? workflowInvocationCwd : isAbsolute11(explicitCwd) ? explicitCwd :
|
|
20116
|
+
const sharedCwd = explicitCwd === undefined ? workflowInvocationCwd : isAbsolute11(explicitCwd) ? explicitCwd : resolve12(workflowInvocationCwd, explicitCwd);
|
|
20053
20117
|
const conflict = findWorktreeTaskCwdConflict(tasks.map((task) => ({ agent: task.name, cwd: resolvedTaskCwd(task.cwd, workflowInvocationCwd) })), sharedCwd);
|
|
20054
20118
|
if (conflict !== undefined)
|
|
20055
20119
|
throw new Error(formatWorktreeTaskCwdConflict(conflict, sharedCwd));
|
|
@@ -24118,13 +24182,13 @@ function raceAbort2(operation, signal) {
|
|
|
24118
24182
|
|
|
24119
24183
|
// dist/builtin/workflows/src/shared/possible-stages.ts
|
|
24120
24184
|
import { createHash as createHash3 } from "node:crypto";
|
|
24121
|
-
import { existsSync as
|
|
24122
|
-
import { dirname as dirname11, join as join14, relative as relative7, resolve as
|
|
24185
|
+
import { existsSync as existsSync7, readFileSync as readFileSync4 } from "node:fs";
|
|
24186
|
+
import { dirname as dirname11, join as join14, relative as relative7, resolve as resolve13, sep as sep8 } from "node:path";
|
|
24123
24187
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
24124
24188
|
function scanPossibleStagesFromSource(entrySourcePath, options = {}) {
|
|
24125
24189
|
const maxDepth = options.maxDepth ?? DEFAULT_MAX_DEPTH;
|
|
24126
|
-
const scanner = new PossibleStagesScanner(maxDepth,
|
|
24127
|
-
const entryPath =
|
|
24190
|
+
const scanner = new PossibleStagesScanner(maxDepth, resolve13(entrySourcePath));
|
|
24191
|
+
const entryPath = resolve13(entrySourcePath);
|
|
24128
24192
|
scanner.scanSubtree(entryPath, "", 0, [entryPath]);
|
|
24129
24193
|
scanner.noteZeroStages(entryPath);
|
|
24130
24194
|
return {
|
|
@@ -26202,7 +26266,7 @@ function resolveRelativeSpecifier(specifier, importingFile) {
|
|
|
26202
26266
|
return candidates.find((candidate) => isFileSync(candidate));
|
|
26203
26267
|
}
|
|
26204
26268
|
function isFileSync(path) {
|
|
26205
|
-
if (!
|
|
26269
|
+
if (!existsSync7(path))
|
|
26206
26270
|
return false;
|
|
26207
26271
|
try {
|
|
26208
26272
|
readFileSync4(path, { flag: "r" });
|
|
@@ -67663,7 +67727,7 @@ var init_loop_until_done = __esm(() => {
|
|
|
67663
67727
|
});
|
|
67664
67728
|
|
|
67665
67729
|
// dist/builtin/workflows/builtin/open-claude-design-images.ts
|
|
67666
|
-
import { existsSync as
|
|
67730
|
+
import { existsSync as existsSync8 } from "node:fs";
|
|
67667
67731
|
import { mkdir as mkdir4, readFile as readFile5, writeFile as writeFile8 } from "node:fs/promises";
|
|
67668
67732
|
import { dirname as dirname13, join as join24 } from "node:path";
|
|
67669
67733
|
import { AuthStorage } from "@bastani/atomic";
|
|
@@ -67862,7 +67926,7 @@ async function runReferenceImagesStep(tool, request, deps = {}) {
|
|
|
67862
67926
|
return outcome.ok ? outcome.value : { status: "failed", reason: "tool-failed", paths: [] };
|
|
67863
67927
|
}
|
|
67864
67928
|
function existingReferenceImagePaths(status) {
|
|
67865
|
-
return status.status === "generated" ? status.paths.filter((path) =>
|
|
67929
|
+
return status.status === "generated" ? status.paths.filter((path) => existsSync8(path)) : [];
|
|
67866
67930
|
}
|
|
67867
67931
|
var referenceImagesStatusSchema, REFERENCE_IMAGES_DIRNAME = "references", REFERENCE_IMAGES_TOOL_TIMEOUT_MS, IMAGE_REQUEST_TIMEOUT_MS, IMAGE_REQUEST_MAX_RETRIES = 1, IMAGE_SIZE = "1536x1024", PRODUCT_EXCERPT_CHARS = 1000, DESIGN_EXCERPT_CHARS = 1500, REFERENCES_EXCERPT_CHARS = 1500, REFERENCE_IMAGE_DIRECTIONS, SURFACE_BY_OUTPUT_TYPE, GPT_IMAGE_ID, PREFERRED_VARIANTS, LOWER_TIER_VARIANTS, PREFERRED_FALLBACK_PROVIDER = "openrouter", IMAGE_EXTENSIONS;
|
|
67868
67932
|
var init_open_claude_design_images = __esm(() => {
|
|
@@ -69529,8 +69593,8 @@ var init_ralph_models = __esm(() => {
|
|
|
69529
69593
|
});
|
|
69530
69594
|
|
|
69531
69595
|
// dist/builtin/workflows/builtin/ralph-runner.ts
|
|
69532
|
-
import { existsSync as
|
|
69533
|
-
import { join as join28, resolve as
|
|
69596
|
+
import { existsSync as existsSync9 } from "node:fs";
|
|
69597
|
+
import { join as join28, resolve as resolve14 } from "node:path";
|
|
69534
69598
|
async function runRalphWorkflow(ctx, options) {
|
|
69535
69599
|
const { prompt, acceptanceCriteria, maxLoops, comparisonBaseBranch, workflowStartCwd, createPr, runId } = options;
|
|
69536
69600
|
let latestReviewReportPath;
|
|
@@ -69542,7 +69606,7 @@ async function runRalphWorkflow(ctx, options) {
|
|
|
69542
69606
|
let finalPrReport;
|
|
69543
69607
|
const workflowCwdContext = workflowCwdContextSection(workflowStartCwd);
|
|
69544
69608
|
const workflowPrompt = prompt;
|
|
69545
|
-
const workflowResearchPath =
|
|
69609
|
+
const workflowResearchPath = resolve14(workflowStartCwd, defaultResearchPath(workflowPrompt));
|
|
69546
69610
|
const implementationNotesPath = await createImplementationNotesFile(workflowPrompt, runId);
|
|
69547
69611
|
const qaVideoPath = await createQaEvidenceVideoPath(runId);
|
|
69548
69612
|
const artifactDir = await createWorkflowArtifactDirectory(runId);
|
|
@@ -69793,7 +69857,7 @@ Read it before implementation or delegation because it is the primary current im
|
|
|
69793
69857
|
if (approved)
|
|
69794
69858
|
break;
|
|
69795
69859
|
}
|
|
69796
|
-
const qaVideoAvailable =
|
|
69860
|
+
const qaVideoAvailable = existsSync9(qaVideoPath);
|
|
69797
69861
|
const unapprovedHandoff = createPr === true && !approved;
|
|
69798
69862
|
const escalationEvidence = unapprovedHandoff ? convergence_escalation_evidence(convergenceEntries) : [];
|
|
69799
69863
|
if (createPr === true) {
|
|
@@ -70152,7 +70216,7 @@ var init_tournament_prompts = __esm(() => {
|
|
|
70152
70216
|
|
|
70153
70217
|
// dist/builtin/workflows/builtin/tournament-runner.ts
|
|
70154
70218
|
import { mkdir as mkdir6, readFile as readFile6, writeFile as writeFile10 } from "node:fs/promises";
|
|
70155
|
-
import { join as join29, isAbsolute as isAbsolute12, relative as relative9, resolve as
|
|
70219
|
+
import { join as join29, isAbsolute as isAbsolute12, relative as relative9, resolve as resolve15 } from "node:path";
|
|
70156
70220
|
import { Type as Type23 } from "typebox";
|
|
70157
70221
|
function serializableObject2(value2) {
|
|
70158
70222
|
if (value2 === null || Array.isArray(value2) || typeof value2 !== "object")
|
|
@@ -70189,8 +70253,8 @@ function criterionSlug(id) {
|
|
|
70189
70253
|
}
|
|
70190
70254
|
function judgeArtifactPath(judgesDir, job, criterionIndex) {
|
|
70191
70255
|
const filename = `judge-${job.a}-${job.b}-c${criterionIndex}-${criterionSlug(job.criterionId)}-r${job.rep}.json`;
|
|
70192
|
-
const root =
|
|
70193
|
-
const path =
|
|
70256
|
+
const root = resolve15(judgesDir);
|
|
70257
|
+
const path = resolve15(judgesDir, filename);
|
|
70194
70258
|
const fromRoot = relative9(root, path);
|
|
70195
70259
|
if (fromRoot.startsWith("..") || isAbsolute12(fromRoot)) {
|
|
70196
70260
|
throw new Error(`tournament: judge artifact escaped its directory: ${path}`);
|
|
@@ -74887,7 +74951,7 @@ var init_client = __esm(() => {
|
|
|
74887
74951
|
throw new Error(`Unknown broker message type: ${brokerMessage.type}`);
|
|
74888
74952
|
}
|
|
74889
74953
|
}
|
|
74890
|
-
async disconnect() {
|
|
74954
|
+
async disconnect(options = {}) {
|
|
74891
74955
|
if (this.connectAttempt !== undefined && this._sessionId === null) {
|
|
74892
74956
|
this.connectAttempt.abort();
|
|
74893
74957
|
return;
|
|
@@ -74921,7 +74985,7 @@ var init_client = __esm(() => {
|
|
|
74921
74985
|
socket.once("close", onClose);
|
|
74922
74986
|
socket.once("error", onError);
|
|
74923
74987
|
try {
|
|
74924
|
-
writeMessage(socket, { type: "unregister" });
|
|
74988
|
+
writeMessage(socket, { type: "unregister", ...options.resumable === true ? { resumable: true } : {} });
|
|
74925
74989
|
socket.end();
|
|
74926
74990
|
} catch {
|
|
74927
74991
|
socket.destroy();
|
|
@@ -75181,7 +75245,7 @@ var init_client = __esm(() => {
|
|
|
75181
75245
|
}
|
|
75182
75246
|
return this.restoringRecipientRequest({ type: "acknowledge_released_child_wake", childName });
|
|
75183
75247
|
}
|
|
75184
|
-
acknowledgeReleasedChildReply(reply, accepted) {
|
|
75248
|
+
acknowledgeReleasedChildReply(reply, accepted, deliverToChild = false) {
|
|
75185
75249
|
if (!this.socket || this.socket.destroyed)
|
|
75186
75250
|
return false;
|
|
75187
75251
|
this.requireBrokerProtocol("released_child_reply_ack");
|
|
@@ -75189,7 +75253,8 @@ var init_client = __esm(() => {
|
|
|
75189
75253
|
type: "released_child_reply_ack",
|
|
75190
75254
|
messageId: reply.message.id,
|
|
75191
75255
|
handoffId: reply.handoffId,
|
|
75192
|
-
accepted
|
|
75256
|
+
accepted,
|
|
75257
|
+
...deliverToChild ? { deliverToChild: true } : {}
|
|
75193
75258
|
});
|
|
75194
75259
|
return true;
|
|
75195
75260
|
}
|
|
@@ -75630,7 +75695,7 @@ var init_shared_storage_setting = __esm(() => {
|
|
|
75630
75695
|
// dist/builtin/intercom/broker/spawn.ts
|
|
75631
75696
|
import { spawn } from "child_process";
|
|
75632
75697
|
import { randomUUID as randomUUID15 } from "crypto";
|
|
75633
|
-
import { appendFileSync, chmodSync, closeSync as closeSync3, existsSync as
|
|
75698
|
+
import { appendFileSync, chmodSync, closeSync as closeSync3, existsSync as existsSync10, mkdirSync as mkdirSync8, openSync as openSync3, readFileSync as readFileSync7, readSync as readSync2, renameSync, statSync as statSync5, unlinkSync as unlinkSync4, writeFileSync as writeFileSync6 } from "fs";
|
|
75634
75699
|
import { join as join31, dirname as dirname16 } from "path";
|
|
75635
75700
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
75636
75701
|
import { createRequire as createRequire3 } from "module";
|
|
@@ -75642,7 +75707,7 @@ import {
|
|
|
75642
75707
|
processSharedStorageSelection
|
|
75643
75708
|
} from "@bastani/atomic";
|
|
75644
75709
|
function isIntercomPackageRoot(dir) {
|
|
75645
|
-
return
|
|
75710
|
+
return existsSync10(join31(dir, "package.json")) && existsSync10(join31(dir, "broker"));
|
|
75646
75711
|
}
|
|
75647
75712
|
function resolveIntercomPackageRoot(moduleHref) {
|
|
75648
75713
|
const here = dirname16(fileURLToPath5(moduleHref));
|
|
@@ -75652,7 +75717,7 @@ function resolveIntercomPackageRoot(moduleHref) {
|
|
|
75652
75717
|
}
|
|
75653
75718
|
function resolveBrokerEntrypoint(packageRoot) {
|
|
75654
75719
|
const bundled = join31(packageRoot, "broker", "broker.bundle.mjs");
|
|
75655
|
-
return
|
|
75720
|
+
return existsSync10(bundled) ? bundled : join31(packageRoot, "broker", "broker.ts");
|
|
75656
75721
|
}
|
|
75657
75722
|
function ensurePrivateDirectory(path) {
|
|
75658
75723
|
mkdirSync8(path, { recursive: true, mode: 448 });
|
|
@@ -75956,7 +76021,7 @@ async function isBrokerRunning() {
|
|
|
75956
76021
|
if (await checkSocketConnectable()) {
|
|
75957
76022
|
return true;
|
|
75958
76023
|
}
|
|
75959
|
-
if (!
|
|
76024
|
+
if (!existsSync10(getBrokerPidPath()))
|
|
75960
76025
|
return false;
|
|
75961
76026
|
try {
|
|
75962
76027
|
const pid = parseInt(readFileSync7(getBrokerPidPath(), "utf-8").trim(), 10);
|
|
@@ -76022,7 +76087,7 @@ function isProcessAlive(pid) {
|
|
|
76022
76087
|
}
|
|
76023
76088
|
}
|
|
76024
76089
|
function isSpawnLockStale(lockPath = getBrokerSpawnLockPath(), nowMs = Date.now()) {
|
|
76025
|
-
if (!
|
|
76090
|
+
if (!existsSync10(lockPath)) {
|
|
76026
76091
|
return false;
|
|
76027
76092
|
}
|
|
76028
76093
|
try {
|
|
@@ -76150,10 +76215,10 @@ var init_reply_waiter = __esm(() => {
|
|
|
76150
76215
|
});
|
|
76151
76216
|
|
|
76152
76217
|
// dist/builtin/intercom/config.ts
|
|
76153
|
-
import { existsSync as
|
|
76218
|
+
import { existsSync as existsSync11, readFileSync as readFileSync8 } from "fs";
|
|
76154
76219
|
import { getAgentConfigPaths } from "@bastani/atomic";
|
|
76155
76220
|
function loadConfig() {
|
|
76156
|
-
if (!
|
|
76221
|
+
if (!existsSync11(CONFIG_PATH)) {
|
|
76157
76222
|
return { ...defaults };
|
|
76158
76223
|
}
|
|
76159
76224
|
try {
|
|
@@ -76235,7 +76300,7 @@ var init_config = __esm(() => {
|
|
|
76235
76300
|
init_diagnostics();
|
|
76236
76301
|
init_reply_waiter();
|
|
76237
76302
|
CONFIG_PATHS = getAgentConfigPaths("intercom", "config.json");
|
|
76238
|
-
CONFIG_PATH = CONFIG_PATHS.find((path) =>
|
|
76303
|
+
CONFIG_PATH = CONFIG_PATHS.find((path) => existsSync11(path)) ?? CONFIG_PATHS[0];
|
|
76239
76304
|
DEFAULT_BROKER_ARGS = ["--no-install", "tsx"];
|
|
76240
76305
|
defaults = {
|
|
76241
76306
|
brokerCommand: DEFAULT_BROKER_COMMAND,
|
|
@@ -76970,11 +77035,22 @@ function childPlacement(shared, root, workspace) {
|
|
|
76970
77035
|
const binding = shared && isBoundWorkspace(workspace) ? bindingIdentity2(workspace) : root;
|
|
76971
77036
|
return binding === undefined ? {} : { workspaceBinding: binding };
|
|
76972
77037
|
}
|
|
76973
|
-
function placedExecution(execution, worktree) {
|
|
77038
|
+
function placedExecution(execution, worktree, partial) {
|
|
76974
77039
|
const workspace = execution.workspace;
|
|
77040
|
+
const outcomes = partial === undefined ? {} : {
|
|
77041
|
+
worktreeRestoreOutcomes: [
|
|
77042
|
+
...execution.worktreeRestoreOutcomes ?? [],
|
|
77043
|
+
partial
|
|
77044
|
+
]
|
|
77045
|
+
};
|
|
76975
77046
|
if (!isBoundWorkspace(workspace))
|
|
76976
|
-
return { ...execution, cwd: worktree };
|
|
76977
|
-
return {
|
|
77047
|
+
return { ...execution, cwd: worktree, ...outcomes };
|
|
77048
|
+
return {
|
|
77049
|
+
...execution,
|
|
77050
|
+
cwd: worktree,
|
|
77051
|
+
workspace: { ...workspace, worktree },
|
|
77052
|
+
...outcomes
|
|
77053
|
+
};
|
|
76978
77054
|
}
|
|
76979
77055
|
function carriedSnapshot(execution) {
|
|
76980
77056
|
return execution.workspaceSnapshot;
|
|
@@ -77659,14 +77735,14 @@ var UNATTRIBUTED_WRITE = "other";
|
|
|
77659
77735
|
var init_pool_coordination_stats = () => {};
|
|
77660
77736
|
|
|
77661
77737
|
// dist/builtin/workflows/src/workers/pooled-watch-trace.ts
|
|
77662
|
-
import { dirname as dirname17, join as join32, resolve as
|
|
77738
|
+
import { dirname as dirname17, join as join32, resolve as resolve16 } from "node:path";
|
|
77663
77739
|
import { appendDebugRecord, isDebugEnabled as isDebugEnabled2, reportDebug } from "@bastani/atomic";
|
|
77664
77740
|
function configurePooledWatchTrace(journal, processRole) {
|
|
77665
77741
|
journalPath = journal;
|
|
77666
77742
|
role = processRole;
|
|
77667
77743
|
}
|
|
77668
77744
|
function ownTraceFile(journal, setting) {
|
|
77669
|
-
return setting === "1" ? join32(dirname17(
|
|
77745
|
+
return setting === "1" ? join32(dirname17(resolve16(journal)), "pooled-watch-trace.jsonl") : resolve16(setting);
|
|
77670
77746
|
}
|
|
77671
77747
|
function tracePooledWatch(step, detail) {
|
|
77672
77748
|
if (!isDebugEnabled2("pooled-watch"))
|
|
@@ -78105,7 +78181,7 @@ function runsWhilePaused(command) {
|
|
|
78105
78181
|
if (command.kind !== "task")
|
|
78106
78182
|
return false;
|
|
78107
78183
|
const action = command.action.kind;
|
|
78108
|
-
return action === "cancel" || action === "output" || action === "detail" || action === "transcript";
|
|
78184
|
+
return action === "cancel" || action === "output" || action === "detail" || action === "transcript" || action === "commands";
|
|
78109
78185
|
}
|
|
78110
78186
|
|
|
78111
78187
|
// dist/builtin/workflows/src/workers/stage-watch-coalesce.ts
|
|
@@ -78467,9 +78543,9 @@ var init_worker_timing = __esm(() => {
|
|
|
78467
78543
|
// dist/builtin/workflows/src/workers/pool-coordinator.ts
|
|
78468
78544
|
import { fork } from "node:child_process";
|
|
78469
78545
|
import { randomUUID as randomUUID17 } from "node:crypto";
|
|
78470
|
-
import { existsSync as
|
|
78546
|
+
import { existsSync as existsSync12 } from "node:fs";
|
|
78471
78547
|
import { appendFile, mkdir as mkdir7, rm as rm4, rmdir as rmdir2 } from "node:fs/promises";
|
|
78472
|
-
import { delimiter, dirname as dirname19, isAbsolute as isAbsolute14, join as join33, resolve as
|
|
78548
|
+
import { delimiter, dirname as dirname19, isAbsolute as isAbsolute14, join as join33, resolve as resolve17 } from "node:path";
|
|
78473
78549
|
import { setTimeout as delay4 } from "node:timers/promises";
|
|
78474
78550
|
import { isDeepStrictEqual as isDeepStrictEqual2 } from "node:util";
|
|
78475
78551
|
import { setDebugSetting } from "@bastani/atomic";
|
|
@@ -78478,7 +78554,7 @@ function unconfirmedCleanup(groups) {
|
|
|
78478
78554
|
return new WorkerCleanupUnconfirmedError({ processGroups: groups });
|
|
78479
78555
|
}
|
|
78480
78556
|
function workerLogDirectory(journalPath, root) {
|
|
78481
|
-
return join33(dirname19(
|
|
78557
|
+
return join33(dirname19(resolve17(journalPath)), "worker-logs", encodeURIComponent(root).replaceAll(".", "%2E"));
|
|
78482
78558
|
}
|
|
78483
78559
|
function traceAnchor(options) {
|
|
78484
78560
|
return options.shared === undefined ? options.journalPath : join33(options.shared.stateDirectory, "shared-pool");
|
|
@@ -78929,7 +79005,7 @@ class PoolCoordinator {
|
|
|
78929
79005
|
if (options.shared !== undefined)
|
|
78930
79006
|
this.journal ??= await this.countedJournal(await openDurableJournal(options.durable));
|
|
78931
79007
|
else {
|
|
78932
|
-
if (options.journalShard !== undefined && !
|
|
79008
|
+
if (options.journalShard !== undefined && !existsSync12(options.journalPath))
|
|
78933
79009
|
throw new JournalShardUnavailableError2({
|
|
78934
79010
|
code: "shard-missing",
|
|
78935
79011
|
shardId: options.journalShard,
|
|
@@ -80172,7 +80248,10 @@ class PoolCoordinator {
|
|
|
80172
80248
|
slot.worktree = claimed.worktree;
|
|
80173
80249
|
for (const id of this.remoteWatches.takenOver(claimed.work.id))
|
|
80174
80250
|
this.endRemoteWatch(id, "attempt_fenced");
|
|
80175
|
-
return claimed.worktree === undefined ? claimed.work : {
|
|
80251
|
+
return claimed.worktree === undefined ? claimed.work : {
|
|
80252
|
+
...claimed.work,
|
|
80253
|
+
execution: placedExecution(claimed.work.execution, claimed.worktree, claimed.partial)
|
|
80254
|
+
};
|
|
80176
80255
|
}
|
|
80177
80256
|
const held = slot.work;
|
|
80178
80257
|
if (!held)
|
|
@@ -80341,7 +80420,14 @@ class PoolCoordinator {
|
|
|
80341
80420
|
const restore = satellite.restore;
|
|
80342
80421
|
if (!chosen.restore || binding === undefined || restore === undefined)
|
|
80343
80422
|
return worktree === undefined ? { work } : { work, worktree };
|
|
80344
|
-
|
|
80423
|
+
let partial;
|
|
80424
|
+
const restored = await this.whileHolding(queue, lease, work, leaseMs, async (signal) => {
|
|
80425
|
+
const result = await restore(binding, this.restoreOptions(satellite, signal, carriedSnapshot(work.execution)));
|
|
80426
|
+
if (typeof result === "string")
|
|
80427
|
+
return result;
|
|
80428
|
+
partial = result.partial;
|
|
80429
|
+
return result.path;
|
|
80430
|
+
}, AbortSignal.any([this.closedSignal.signal, slot.exited.signal]));
|
|
80345
80431
|
if (this.closed)
|
|
80346
80432
|
return;
|
|
80347
80433
|
if ("closed" in restored) {
|
|
@@ -80350,7 +80436,7 @@ class PoolCoordinator {
|
|
|
80350
80436
|
}
|
|
80351
80437
|
if ("path" in restored) {
|
|
80352
80438
|
await this.restoreSucceeded(satellite, backoff, binding);
|
|
80353
|
-
return { work, worktree: restored.path };
|
|
80439
|
+
return partial === undefined ? { work, worktree: restored.path } : { work, worktree: restored.path, partial };
|
|
80354
80440
|
}
|
|
80355
80441
|
satellite.placementFailed(restored.error);
|
|
80356
80442
|
await queue.releaseUnplaced(lease, work);
|
|
@@ -82172,6 +82258,10 @@ class PooledStageTaskSource {
|
|
|
82172
82258
|
followTaskTranscript(id) {
|
|
82173
82259
|
return this.records.some((task) => task.ref.taskId === id && task.kind === "agent") ? { historyOnly: true } : undefined;
|
|
82174
82260
|
}
|
|
82261
|
+
async taskCommands(id) {
|
|
82262
|
+
const reply = await this.request(id, { kind: "commands" });
|
|
82263
|
+
return reply.ok && reply.value.kind === "commands" ? reply.value.catalog : undefined;
|
|
82264
|
+
}
|
|
82175
82265
|
extensionStatuses(id) {
|
|
82176
82266
|
return this.statuses.get(id) ?? NO_STATUSES;
|
|
82177
82267
|
}
|
|
@@ -83092,8 +83182,8 @@ var init_pooled_stage_registry = __esm(() => {
|
|
|
83092
83182
|
// dist/builtin/workflows/src/workers/local-pool.ts
|
|
83093
83183
|
import { fork as fork2 } from "node:child_process";
|
|
83094
83184
|
import { randomUUID as randomUUID19 } from "node:crypto";
|
|
83095
|
-
import { existsSync as
|
|
83096
|
-
import { join as join34, resolve as
|
|
83185
|
+
import { existsSync as existsSync13 } from "node:fs";
|
|
83186
|
+
import { join as join34, resolve as resolve18 } from "node:path";
|
|
83097
83187
|
import { setTimeout as delay5 } from "node:timers/promises";
|
|
83098
83188
|
import { fileURLToPath as fileURLToPath6 } from "node:url";
|
|
83099
83189
|
import {
|
|
@@ -83337,7 +83427,7 @@ class LocalWorkerPool {
|
|
|
83337
83427
|
async prepare(root, store) {
|
|
83338
83428
|
if (this.closed)
|
|
83339
83429
|
throw new Error("Local worker pool is closed");
|
|
83340
|
-
if (this.options.journalShard !== undefined && !
|
|
83430
|
+
if (this.options.journalShard !== undefined && !existsSync13(this.options.journalPath))
|
|
83341
83431
|
throw new JournalShardUnavailableError3({
|
|
83342
83432
|
code: "shard-missing",
|
|
83343
83433
|
shardId: this.options.journalShard,
|
|
@@ -83413,7 +83503,7 @@ class LocalWorkerPool {
|
|
|
83413
83503
|
const journal = await rootRunJournal(this.backend.journal, root);
|
|
83414
83504
|
const journalPath = this.options.journalPath;
|
|
83415
83505
|
if (this.options.durable === undefined) {
|
|
83416
|
-
if (!(journal instanceof SqlRunJournal) ||
|
|
83506
|
+
if (!(journal instanceof SqlRunJournal) || resolve18(journalPath) !== resolve18(journal.path) || sqlPoolStorage(journal)?.tables.runs !== "wf_runs")
|
|
83417
83507
|
throw new Error("Local workers require the same default-prefix SQLite journal");
|
|
83418
83508
|
return journal;
|
|
83419
83509
|
}
|
|
@@ -83973,6 +84063,7 @@ class LocalWorkerPool {
|
|
|
83973
84063
|
config: options.config,
|
|
83974
84064
|
snapshots: options.snapshots,
|
|
83975
84065
|
worktreeRootMappings: options.worktreeRootMappings,
|
|
84066
|
+
worktreeRestoreOutcomes: options.worktreeRestoreOutcomes,
|
|
83976
84067
|
executionMode: options.executionMode,
|
|
83977
84068
|
workspace: options.workspace,
|
|
83978
84069
|
...childPlacement(shared, this.options.workspace, options.workspace),
|
|
@@ -84495,7 +84586,7 @@ var init_local_pool = __esm(() => {
|
|
|
84495
84586
|
var DEFAULT_POOLED_STAGE_START_MAX_LOAD_PER_CPU = 3, DEFAULT_PLACEMENT_CLAIM_WINDOW_MS = 60000;
|
|
84496
84587
|
|
|
84497
84588
|
// dist/builtin/workflows/src/workers/public-pool.ts
|
|
84498
|
-
import { resolve as
|
|
84589
|
+
import { resolve as resolve19 } from "node:path";
|
|
84499
84590
|
import { isDeepStrictEqual as isDeepStrictEqual3 } from "node:util";
|
|
84500
84591
|
import { isBoundWorkspace as isBoundWorkspace3, isWorkspace, resolveWorkspace as resolveWorkspace2 } from "@bastani/atomic";
|
|
84501
84592
|
function shown(value2) {
|
|
@@ -84569,11 +84660,11 @@ function workerResources(options, context) {
|
|
|
84569
84660
|
heartbeatMs: undefined,
|
|
84570
84661
|
maxLoadPerCpu: undefined,
|
|
84571
84662
|
maxWorkerRssBytes: undefined,
|
|
84572
|
-
definitions: options.localWorkers.definitions.map((source) => ({ ...source, path:
|
|
84663
|
+
definitions: options.localWorkers.definitions.map((source) => ({ ...source, path: resolve19(cwd, source.path) }))
|
|
84573
84664
|
};
|
|
84574
84665
|
const admission = options.admission && {
|
|
84575
84666
|
...options.admission,
|
|
84576
|
-
...options.admission.userDatabase ? { userDatabase:
|
|
84667
|
+
...options.admission.userDatabase ? { userDatabase: resolve19(cwd, options.admission.userDatabase) } : {}
|
|
84577
84668
|
};
|
|
84578
84669
|
const userDatabase = admission?.userLimits && admission.userDatabase === undefined ? context.userDatabase() : undefined;
|
|
84579
84670
|
return JSON.parse(JSON.stringify({
|
|
@@ -84590,7 +84681,7 @@ function workerResources(options, context) {
|
|
|
84590
84681
|
}));
|
|
84591
84682
|
}
|
|
84592
84683
|
function poolUserDatabase(journal) {
|
|
84593
|
-
return isLocalPoolJournal(journal) ? undefined :
|
|
84684
|
+
return isLocalPoolJournal(journal) ? undefined : resolve19(coordinationPath(poolDurableJournal(journal)));
|
|
84594
84685
|
}
|
|
84595
84686
|
async function restoreWorkerOptions(backend, options) {
|
|
84596
84687
|
const source = options.continuation?.source.id ?? options.runId;
|
|
@@ -84706,13 +84797,13 @@ async function activatePublicPool(backend, options) {
|
|
|
84706
84797
|
registerPoolJournal(backend.journal, poolJournal);
|
|
84707
84798
|
}
|
|
84708
84799
|
const cwd = options.cwd ?? process.cwd();
|
|
84709
|
-
const userDatabase = options.admission?.userDatabase ?
|
|
84710
|
-
if (durable !== undefined && options.admission?.userLimits && userDatabase !== undefined && userDatabase !==
|
|
84711
|
-
throw new Error(`admission.userDatabase must be omitted, or ${
|
|
84712
|
-
const paths = (options.localWorkers?.definitions ?? []).map((source) =>
|
|
84800
|
+
const userDatabase = options.admission?.userDatabase ? resolve19(cwd, options.admission.userDatabase) : options.admission?.userDatabase;
|
|
84801
|
+
if (durable !== undefined && options.admission?.userLimits && userDatabase !== undefined && userDatabase !== resolve19(poolPath))
|
|
84802
|
+
throw new Error(`admission.userDatabase must be omitted, or ${resolve19(poolPath)}, for a journal that is not a local SQLite file`);
|
|
84803
|
+
const paths = (options.localWorkers?.definitions ?? []).map((source) => resolve19(cwd, source.path));
|
|
84713
84804
|
const digests = new Map(await Promise.all(paths.map(async (path) => [path, await definitionDigest(path)])));
|
|
84714
84805
|
const resources = workerResources(options, {
|
|
84715
|
-
userDatabase: () => durable === undefined ? undefined :
|
|
84806
|
+
userDatabase: () => durable === undefined ? undefined : resolve19(poolPath),
|
|
84716
84807
|
digestOf: (path) => digests.get(path),
|
|
84717
84808
|
coordinator: shared !== undefined || durable === undefined || !options.localWorkers ? undefined : { host: poolHostId(durable.agentDir), database: coordinationDatabase(durable) },
|
|
84718
84809
|
...recorded === undefined ? {} : { workers: recorded.placement }
|
|
@@ -89589,7 +89680,7 @@ var init_stage_runner_controller = __esm(() => {
|
|
|
89589
89680
|
// dist/builtin/workflows/src/runs/foreground/stage-runner-output.ts
|
|
89590
89681
|
import { createHash as createHash6 } from "node:crypto";
|
|
89591
89682
|
import { mkdir as mkdir8, writeFile as writeFile11 } from "node:fs/promises";
|
|
89592
|
-
import { basename as basename5, dirname as dirname21, isAbsolute as isAbsolute16, join as join36, resolve as
|
|
89683
|
+
import { basename as basename5, dirname as dirname21, isAbsolute as isAbsolute16, join as join36, resolve as resolve20 } from "node:path";
|
|
89593
89684
|
function normalizeMaxOutput2(maxOutput) {
|
|
89594
89685
|
return {
|
|
89595
89686
|
bytes: maxOutput?.bytes ?? DEFAULT_MAX_OUTPUT_BYTES,
|
|
@@ -89697,7 +89788,7 @@ function renderTranscript(messages, fallbackOutput) {
|
|
|
89697
89788
|
`);
|
|
89698
89789
|
}
|
|
89699
89790
|
function savedOutputReference(outputPath, fullOutput, transcriptPathValue, transcriptText, transcriptAvailable, warning) {
|
|
89700
|
-
const absolutePath =
|
|
89791
|
+
const absolutePath = resolve20(outputPath);
|
|
89701
89792
|
const bytes = Buffer.byteLength(fullOutput, "utf8");
|
|
89702
89793
|
const lines = countLines(fullOutput);
|
|
89703
89794
|
const transcriptBytes = Buffer.byteLength(transcriptText, "utf8");
|
|
@@ -89712,8 +89803,8 @@ function resolveOutputPath(output, runtimeCwd, requestedCwd) {
|
|
|
89712
89803
|
return;
|
|
89713
89804
|
if (isAbsolute16(output))
|
|
89714
89805
|
return output;
|
|
89715
|
-
const baseCwd = requestedCwd === undefined ? runtimeCwd : isAbsolute16(requestedCwd) ? requestedCwd :
|
|
89716
|
-
return
|
|
89806
|
+
const baseCwd = requestedCwd === undefined ? runtimeCwd : isAbsolute16(requestedCwd) ? requestedCwd : resolve20(runtimeCwd, requestedCwd);
|
|
89807
|
+
return resolve20(baseCwd, output);
|
|
89717
89808
|
}
|
|
89718
89809
|
function degenerateWarning(fullOutput) {
|
|
89719
89810
|
return fullOutput.trim().length === 0 ? "WARNING: the stage artifact is empty; search the companion transcript for this stage's work." : undefined;
|
|
@@ -91090,11 +91181,11 @@ var init_child_workflow_failure_message = __esm(() => {
|
|
|
91090
91181
|
});
|
|
91091
91182
|
|
|
91092
91183
|
// dist/builtin/workflows/src/engine/primitives/workflow.ts
|
|
91093
|
-
import { existsSync as
|
|
91184
|
+
import { existsSync as existsSync14 } from "node:fs";
|
|
91094
91185
|
import {
|
|
91095
91186
|
acquireWorkspaceWriterLease,
|
|
91096
91187
|
isBoundWorkspace as isBoundWorkspace4,
|
|
91097
|
-
isWorkspaceRestoreError,
|
|
91188
|
+
isWorkspaceRestoreError as isWorkspaceRestoreError2,
|
|
91098
91189
|
resolveWorkspace as resolveWorkspace4,
|
|
91099
91190
|
restoreWorkspace,
|
|
91100
91191
|
workspaceChangeSet as workspaceChangeSet2
|
|
@@ -91282,7 +91373,7 @@ async function bindChildWorkspace(workspace, invocation, signal, owner, restored
|
|
|
91282
91373
|
binding = recorded;
|
|
91283
91374
|
} catch (error) {
|
|
91284
91375
|
const worktree = mapWorkflowWorktreePath(recorded.worktree, restored);
|
|
91285
|
-
if (!
|
|
91376
|
+
if (!isWorkspaceRestoreError2(error) || worktree === recorded.worktree || existsSync14(recorded.worktree))
|
|
91286
91377
|
throw error;
|
|
91287
91378
|
binding = { ...recorded, worktree };
|
|
91288
91379
|
}
|
|
@@ -92237,7 +92328,7 @@ var init_run_claims = __esm(() => {
|
|
|
92237
92328
|
// dist/builtin/workflows/src/durable/fork-run.ts
|
|
92238
92329
|
import { randomUUID as randomUUID21 } from "node:crypto";
|
|
92239
92330
|
import { statSync as statSync6 } from "node:fs";
|
|
92240
|
-
import { isAbsolute as isAbsolute17, resolve as
|
|
92331
|
+
import { isAbsolute as isAbsolute17, resolve as resolve21 } from "node:path";
|
|
92241
92332
|
import {
|
|
92242
92333
|
assertSessionBlobStore as assertSessionBlobStore2,
|
|
92243
92334
|
copySessionBlobs as copySessionBlobs2,
|
|
@@ -92264,7 +92355,7 @@ function validateForkOptions(source, runId, options) {
|
|
|
92264
92355
|
let directory = false;
|
|
92265
92356
|
if (typeof options.cwd === "string" && options.cwd.length > 0) {
|
|
92266
92357
|
try {
|
|
92267
|
-
directory = statSync6(
|
|
92358
|
+
directory = statSync6(resolve21(options.cwd)).isDirectory();
|
|
92268
92359
|
} catch (error) {
|
|
92269
92360
|
cause = error;
|
|
92270
92361
|
}
|
|
@@ -92290,7 +92381,7 @@ function validateForkOptions(source, runId, options) {
|
|
|
92290
92381
|
function forkDestinationCwd(cwd, source) {
|
|
92291
92382
|
if (cwd === undefined)
|
|
92292
92383
|
return source.invocationCwd ?? process.cwd();
|
|
92293
|
-
return isAbsolute17(cwd) ? cwd :
|
|
92384
|
+
return isAbsolute17(cwd) ? cwd : resolve21(cwd);
|
|
92294
92385
|
}
|
|
92295
92386
|
function storageScope(descriptor) {
|
|
92296
92387
|
if (descriptor === undefined)
|
|
@@ -97497,6 +97588,7 @@ import {
|
|
|
97497
97588
|
resolveWorktreeSnapshotSettings as resolveWorktreeSnapshotSettings2,
|
|
97498
97589
|
scheduleSnapshotCollection,
|
|
97499
97590
|
setUpResumedRunWorktrees,
|
|
97591
|
+
withWorktreeRestoreNotices,
|
|
97500
97592
|
withWorktreeRootMappings as withWorktreeRootMappings3
|
|
97501
97593
|
} from "@bastani/atomic";
|
|
97502
97594
|
async function run(def, inputs, opts = {}) {
|
|
@@ -97534,41 +97626,46 @@ async function run(def, inputs, opts = {}) {
|
|
|
97534
97626
|
const journal = backend.snapshotJournal;
|
|
97535
97627
|
if (previous !== undefined && journal !== undefined) {
|
|
97536
97628
|
const mappings = previous.worktreeRootMappings ?? [];
|
|
97537
|
-
if (opts[restorePreconditionsChecked] !== true)
|
|
97538
|
-
|
|
97539
|
-
throw new JournalOwnershipError(runId, (await journal.leaseState(runId))?.holderId ?? null);
|
|
97540
|
-
const precondition = await runRestorePreconditionFailure(journal, runId, mappings, previous.snapshots ?? opts.snapshots, opts.signal);
|
|
97541
|
-
if (precondition !== undefined)
|
|
97542
|
-
throw precondition;
|
|
97543
|
-
}
|
|
97629
|
+
if (opts[restorePreconditionsChecked] !== true && await backend.workflowOwnership(runId) === "foreign")
|
|
97630
|
+
throw new JournalOwnershipError(runId, (await journal.leaseState(runId))?.holderId ?? null);
|
|
97544
97631
|
let warningCount = 0;
|
|
97632
|
+
const unrestored = [];
|
|
97545
97633
|
const restored = await resolveWorkflowSnapshotFrontier(journal, runId, {
|
|
97546
97634
|
mappings,
|
|
97547
97635
|
settings: previous.snapshots ?? opts.snapshots,
|
|
97548
97636
|
signal: opts.signal,
|
|
97549
|
-
onRestore: (mapping) =>
|
|
97550
|
-
|
|
97551
|
-
|
|
97552
|
-
|
|
97553
|
-
|
|
97554
|
-
|
|
97555
|
-
|
|
97556
|
-
|
|
97557
|
-
|
|
97558
|
-
|
|
97559
|
-
|
|
97560
|
-
|
|
97561
|
-
|
|
97562
|
-
|
|
97637
|
+
onRestore: (mapping) => {
|
|
97638
|
+
if (mapping.degraded !== undefined)
|
|
97639
|
+
return;
|
|
97640
|
+
activeStore.recordNotice({
|
|
97641
|
+
id: `workflow-worktree-restore:${runId}:${mapping.snapshotId}:${mapping.restoredAt}`,
|
|
97642
|
+
runId,
|
|
97643
|
+
level: "info",
|
|
97644
|
+
message: formatWorktreeRestoreNotice(mapping),
|
|
97645
|
+
createdAt: Date.now()
|
|
97646
|
+
});
|
|
97647
|
+
},
|
|
97648
|
+
onWarning: (warning, mapping) => {
|
|
97649
|
+
if (mapping.degraded !== undefined && (warning.code === "omitted-content" || warning.code === "filters"))
|
|
97650
|
+
return;
|
|
97651
|
+
activeStore.recordNotice({
|
|
97652
|
+
id: `workflow-worktree-restore-warning:${runId}:${mapping.snapshotId}:${mapping.restoredAt}:${warningCount++}`,
|
|
97653
|
+
runId,
|
|
97654
|
+
level: "warning",
|
|
97655
|
+
message: formatWorktreeRestoreWarning(warning),
|
|
97656
|
+
createdAt: Date.now()
|
|
97657
|
+
});
|
|
97658
|
+
},
|
|
97659
|
+
onUnrestored: (checkout) => unrestored.push(checkout)
|
|
97563
97660
|
});
|
|
97661
|
+
const restoreSnapshots = mappings.length > 0 || restored.length > 0 ? new Map((await listWorkflowSnapshotBoundaries(journal, runId)).map((boundary) => [
|
|
97662
|
+
boundary.snapshot.id,
|
|
97663
|
+
boundary.snapshot
|
|
97664
|
+
])) : new Map;
|
|
97564
97665
|
if (mappings.length > 0 || restored.length > 0) {
|
|
97565
|
-
const snapshots = new Map((await listWorkflowSnapshotBoundaries(journal, runId)).map((boundary) => [
|
|
97566
|
-
boundary.snapshot.id,
|
|
97567
|
-
boundary.snapshot
|
|
97568
|
-
]));
|
|
97569
97666
|
const resumeToken = crypto.randomUUID();
|
|
97570
97667
|
let blueprintNoticeCount = 0;
|
|
97571
|
-
await setUpResumedRunWorktrees({ restored, mappings, snapshots }, {
|
|
97668
|
+
await setUpResumedRunWorktrees({ restored, mappings, snapshots: restoreSnapshots }, {
|
|
97572
97669
|
signal: opts.signal,
|
|
97573
97670
|
onNotices: (notices) => {
|
|
97574
97671
|
for (const notice of notices) {
|
|
@@ -97584,15 +97681,41 @@ async function run(def, inputs, opts = {}) {
|
|
|
97584
97681
|
});
|
|
97585
97682
|
}
|
|
97586
97683
|
const allMappings = [...mappings, ...restored];
|
|
97587
|
-
|
|
97588
|
-
|
|
97684
|
+
const recordedCwd = previous.invocationCwd ?? opts.cwd;
|
|
97685
|
+
const continuing = recordedCwd === undefined ? undefined : mapWorkflowWorktreePath(recordedCwd, allMappings);
|
|
97686
|
+
const outcomes = runWorktreeRestoreOutcomes({
|
|
97687
|
+
restored,
|
|
97688
|
+
unrestored,
|
|
97689
|
+
snapshots: restoreSnapshots,
|
|
97690
|
+
continuing,
|
|
97691
|
+
launchCwd: opts[resumeLaunchCwd] ?? opts.cwd ?? process.cwd(),
|
|
97692
|
+
previous: previous.worktreeRestoreOutcomes ?? [],
|
|
97693
|
+
mappings: allMappings
|
|
97694
|
+
});
|
|
97695
|
+
for (const outcome of outcomes.fresh) {
|
|
97696
|
+
activeStore.recordNotice({
|
|
97697
|
+
id: `workflow-worktree-restore-outcome:${runId}:${outcome.snapshotId}:${outcome.at}`,
|
|
97698
|
+
runId,
|
|
97699
|
+
level: "warning",
|
|
97700
|
+
message: outcome.message,
|
|
97701
|
+
createdAt: Date.now()
|
|
97702
|
+
});
|
|
97589
97703
|
}
|
|
97590
|
-
if (
|
|
97591
|
-
|
|
97704
|
+
if (restored.length > 0 || outcomes.list.length > 0 || (previous.worktreeRestoreOutcomes?.length ?? 0) > 0) {
|
|
97705
|
+
await backend.commitWorkflowRegistration({
|
|
97706
|
+
...previous,
|
|
97707
|
+
...allMappings.length > 0 ? { worktreeRootMappings: allMappings } : {},
|
|
97708
|
+
...outcomes.list.length > 0 || previous.worktreeRestoreOutcomes !== undefined ? { worktreeRestoreOutcomes: outcomes.list } : {}
|
|
97709
|
+
});
|
|
97710
|
+
}
|
|
97711
|
+
const cwd = outcomes.continuedIn ?? continuing;
|
|
97712
|
+
if (allMappings.length > 0 || outcomes.list.length > 0) {
|
|
97592
97713
|
opts = {
|
|
97593
97714
|
...opts,
|
|
97594
|
-
...cwd === undefined ? {} : { cwd
|
|
97595
|
-
|
|
97715
|
+
...cwd === undefined ? {} : { cwd },
|
|
97716
|
+
...outcomes.continuedIn === undefined || recordedCwd === undefined ? {} : { [recordedInvocationCwd]: recordedCwd },
|
|
97717
|
+
...allMappings.length > 0 ? { worktreeRootMappings: allMappings } : {},
|
|
97718
|
+
...outcomes.list.length > 0 ? { worktreeRestoreOutcomes: outcomes.list } : {}
|
|
97596
97719
|
};
|
|
97597
97720
|
}
|
|
97598
97721
|
}
|
|
@@ -97615,7 +97738,8 @@ async function run(def, inputs, opts = {}) {
|
|
|
97615
97738
|
bindStoreDurableBackend(activeStore, backend);
|
|
97616
97739
|
}
|
|
97617
97740
|
const admitted = () => admitWorkflowSessions(backend, { ...opts, runId }, (admittedOpts) => executeUntilSettled(def, resolvedInputs, { ...admittedOpts, store: activeStore, runId, durableBackend: backend }, evictionPolicy));
|
|
97618
|
-
|
|
97741
|
+
const restoreNotices = (opts.worktreeRestoreOutcomes ?? []).map((outcome) => outcome.message);
|
|
97742
|
+
return await withWorktreeRootMappings3(opts.worktreeRootMappings ?? [], () => withWorktreeRestoreNotices(restoreNotices, admitted));
|
|
97619
97743
|
} finally {
|
|
97620
97744
|
try {
|
|
97621
97745
|
await publicPool?.close();
|
|
@@ -97731,6 +97855,7 @@ async function executeRun(def, resolvedInputs, opts, eviction) {
|
|
|
97731
97855
|
stages: [],
|
|
97732
97856
|
toolNodes: [],
|
|
97733
97857
|
...opts.worktreeRootMappings !== undefined ? { worktreeRootMappings: opts.worktreeRootMappings } : {},
|
|
97858
|
+
...opts.worktreeRestoreOutcomes !== undefined ? { worktreeRestoreOutcomes: opts.worktreeRestoreOutcomes } : {},
|
|
97734
97859
|
pendingStageMessages: [
|
|
97735
97860
|
...pendingStageMessagesForDurableRun(rootBackend, runId, opts.parentRun?.rootRunId ?? runId)
|
|
97736
97861
|
],
|
|
@@ -97987,7 +98112,8 @@ async function executeRun(def, resolvedInputs, opts, eviction) {
|
|
|
97987
98112
|
durableBackend,
|
|
97988
98113
|
durableRootBackend: rootBackend,
|
|
97989
98114
|
snapshots: opts.snapshots,
|
|
97990
|
-
worktreeRootMappings: opts.worktreeRootMappings
|
|
98115
|
+
worktreeRootMappings: opts.worktreeRootMappings,
|
|
98116
|
+
worktreeRestoreOutcomes: opts.worktreeRestoreOutcomes
|
|
97991
98117
|
};
|
|
97992
98118
|
let evicted;
|
|
97993
98119
|
let bodySettled = false;
|
|
@@ -98569,7 +98695,8 @@ async function executeRun(def, resolvedInputs, opts, eviction) {
|
|
|
98569
98695
|
await durableBackend.commitWorkflowRegistration({
|
|
98570
98696
|
...durableRootRegistration,
|
|
98571
98697
|
modelOwner: runSnapshot.modelOwner,
|
|
98572
|
-
...workflowInvocationMetadata(inputRuntimeDefaults, workflowInvocationCwd, gitWorktreeSetupCache, runSnapshot.origin)
|
|
98698
|
+
...workflowInvocationMetadata(inputRuntimeDefaults, workflowInvocationCwd, gitWorktreeSetupCache, runSnapshot.origin),
|
|
98699
|
+
...opts[recordedInvocationCwd] === undefined ? {} : { invocationCwd: opts[recordedInvocationCwd] }
|
|
98573
98700
|
});
|
|
98574
98701
|
} else {
|
|
98575
98702
|
await durableBackend.commitWorkflowStatus(runId, "running");
|
|
@@ -99123,7 +99250,7 @@ var init_registry = () => {};
|
|
|
99123
99250
|
|
|
99124
99251
|
// dist/builtin/workflows/src/extension/discovery-loaders.ts
|
|
99125
99252
|
import { readdir as readdir2, stat as stat2 } from "node:fs/promises";
|
|
99126
|
-
import { extname, isAbsolute as isAbsolute18, join as join37, resolve as
|
|
99253
|
+
import { extname, isAbsolute as isAbsolute18, join as join37, resolve as resolve22 } from "node:path";
|
|
99127
99254
|
async function scanWorkflowDir(dir) {
|
|
99128
99255
|
try {
|
|
99129
99256
|
const entries = await readdir2(dir, { withFileTypes: true });
|
|
@@ -99167,7 +99294,7 @@ async function loadFromPaths(pathsOrMap, kind, baseCwd, diagnostics, getWorkflow
|
|
|
99167
99294
|
const all = [];
|
|
99168
99295
|
const entries = Array.isArray(pathsOrMap) ? pathsOrMap.map((p) => ({ rawPath: p })) : Object.entries(pathsOrMap).map(([name, p]) => ({ rawPath: p, configuredName: name }));
|
|
99169
99296
|
for (const { rawPath, configuredName } of entries) {
|
|
99170
|
-
const absPath = isAbsolute18(rawPath) ? rawPath :
|
|
99297
|
+
const absPath = isAbsolute18(rawPath) ? rawPath : resolve22(baseCwd, rawPath);
|
|
99171
99298
|
let pathStats;
|
|
99172
99299
|
try {
|
|
99173
99300
|
pathStats = await stat2(absPath);
|
|
@@ -99429,7 +99556,7 @@ var init_discovery = __esm(() => {
|
|
|
99429
99556
|
});
|
|
99430
99557
|
|
|
99431
99558
|
// dist/builtin/workflows/src/runs/foreground/sdk-fork.ts
|
|
99432
|
-
import { resolve as
|
|
99559
|
+
import { resolve as resolve23 } from "node:path";
|
|
99433
99560
|
function refuseAddedWorkerResources(options, saved) {
|
|
99434
99561
|
if (saved)
|
|
99435
99562
|
return;
|
|
@@ -99461,7 +99588,7 @@ function refuseChangedWorkerResources(options, handle, backend) {
|
|
|
99461
99588
|
const requested = workerResources({
|
|
99462
99589
|
localWorkers: options.localWorkers ?? saved.localWorkers,
|
|
99463
99590
|
admission: options.admission ?? saved.admission,
|
|
99464
|
-
cwd: options.cwd === undefined ? handle.invocationCwd ?? process.cwd() :
|
|
99591
|
+
cwd: options.cwd === undefined ? handle.invocationCwd ?? process.cwd() : resolve23(options.cwd)
|
|
99465
99592
|
}, {
|
|
99466
99593
|
userDatabase: () => forkUserDatabase(backend),
|
|
99467
99594
|
digestOf: (path) => digests.get(path) ?? "",
|
|
@@ -99626,23 +99753,59 @@ var init_types2 = __esm(() => {
|
|
|
99626
99753
|
|
|
99627
99754
|
// dist/builtin/workflows/src/workers/snapshot-restore.ts
|
|
99628
99755
|
import {
|
|
99629
|
-
|
|
99630
|
-
|
|
99756
|
+
formatDegradedRestoreNotice as formatDegradedRestoreNotice2,
|
|
99757
|
+
isGitUnavailableError as isGitUnavailableError4,
|
|
99758
|
+
restoreBestWorktree as restoreBestWorktree2,
|
|
99759
|
+
restoreWorktree
|
|
99631
99760
|
} from "@bastani/atomic";
|
|
99632
99761
|
function snapshotRestore(options) {
|
|
99633
|
-
const restore = options.restore ?? restoreWorktree2;
|
|
99634
99762
|
const restored = new Map;
|
|
99635
|
-
const restoreOnHost = async (binding,
|
|
99763
|
+
const restoreOnHost = async (binding, snapshot, recorded, signal) => {
|
|
99764
|
+
const shared = {
|
|
99765
|
+
blobs: options.blobs,
|
|
99766
|
+
storeDir: options.storeDir,
|
|
99767
|
+
signal,
|
|
99768
|
+
git: options.git,
|
|
99769
|
+
...options.restore === undefined ? {} : { restore: options.restore }
|
|
99770
|
+
};
|
|
99636
99771
|
try {
|
|
99637
|
-
|
|
99638
|
-
|
|
99639
|
-
|
|
99640
|
-
|
|
99641
|
-
|
|
99642
|
-
|
|
99643
|
-
|
|
99772
|
+
if (snapshot === undefined)
|
|
99773
|
+
return (await (options.restore ?? restoreWorktree)(binding, {
|
|
99774
|
+
...recorded,
|
|
99775
|
+
blobs: options.blobs,
|
|
99776
|
+
storeDir: options.storeDir,
|
|
99777
|
+
signal,
|
|
99778
|
+
git: options.git
|
|
99779
|
+
})).path;
|
|
99780
|
+
const best = await restoreBestWorktree2(snapshot, {
|
|
99781
|
+
...shared,
|
|
99782
|
+
...recorded.snapshots === undefined ? {} : { target: binding, snapshots: recorded.snapshots }
|
|
99783
|
+
});
|
|
99784
|
+
if (best.status === "unrestored")
|
|
99785
|
+
throw best.reason;
|
|
99786
|
+
if (best.degraded === undefined)
|
|
99787
|
+
return best.path;
|
|
99788
|
+
const restoredAt = new Date().toISOString();
|
|
99789
|
+
const mapping = {
|
|
99790
|
+
from: snapshot.root,
|
|
99791
|
+
to: best.path,
|
|
99792
|
+
snapshotId: snapshot.id,
|
|
99793
|
+
tree: snapshot.tree,
|
|
99794
|
+
restoredAt,
|
|
99795
|
+
degraded: best.degraded
|
|
99796
|
+
};
|
|
99797
|
+
return {
|
|
99798
|
+
path: best.path,
|
|
99799
|
+
partial: {
|
|
99800
|
+
root: snapshot.root,
|
|
99801
|
+
snapshotId: snapshot.id,
|
|
99802
|
+
message: formatDegradedRestoreNotice2(mapping, snapshot, [], "workflow run"),
|
|
99803
|
+
at: restoredAt,
|
|
99804
|
+
degraded: best.degraded
|
|
99805
|
+
}
|
|
99806
|
+
};
|
|
99644
99807
|
} catch (error) {
|
|
99645
|
-
if (signal.aborted || !
|
|
99808
|
+
if (signal.aborted || !isGitUnavailableError4(error))
|
|
99646
99809
|
throw error;
|
|
99647
99810
|
throw new WorkspaceRestoreUnavailableError("no-restore-port", workspaceBindingIdentity(binding), {
|
|
99648
99811
|
cause: error
|
|
@@ -99654,9 +99817,9 @@ function snapshotRestore(options) {
|
|
|
99654
99817
|
return restoreOnHost(binding, snapshot, {}, signal);
|
|
99655
99818
|
const key = JSON.stringify([binding.head, binding.tree]);
|
|
99656
99819
|
const snapshots = restored.get(key) ?? await options.recorded(binding);
|
|
99657
|
-
let
|
|
99820
|
+
let result;
|
|
99658
99821
|
try {
|
|
99659
|
-
|
|
99822
|
+
result = await restoreOnHost(binding, snapshots.at(-1), { snapshots }, signal);
|
|
99660
99823
|
} catch (error) {
|
|
99661
99824
|
restored.delete(key);
|
|
99662
99825
|
throw error;
|
|
@@ -99664,7 +99827,7 @@ function snapshotRestore(options) {
|
|
|
99664
99827
|
if (!restored.has(key) && restored.size >= RECORDED_SNAPSHOT_ENTRIES)
|
|
99665
99828
|
restored.clear();
|
|
99666
99829
|
restored.set(key, snapshots);
|
|
99667
|
-
return
|
|
99830
|
+
return result;
|
|
99668
99831
|
};
|
|
99669
99832
|
}
|
|
99670
99833
|
var RECORDED_SNAPSHOT_ENTRIES = 256;
|
|
@@ -99674,7 +99837,7 @@ var init_snapshot_restore = __esm(() => {
|
|
|
99674
99837
|
|
|
99675
99838
|
// dist/builtin/workflows/src/workers/worker-host.ts
|
|
99676
99839
|
import { execFile as execFile2 } from "node:child_process";
|
|
99677
|
-
import { existsSync as
|
|
99840
|
+
import { existsSync as existsSync15 } from "node:fs";
|
|
99678
99841
|
import { join as join39 } from "node:path";
|
|
99679
99842
|
import {
|
|
99680
99843
|
getAgentDir as getAgentDir9,
|
|
@@ -99752,7 +99915,7 @@ function probeGit(git) {
|
|
|
99752
99915
|
async function runnableSources(root) {
|
|
99753
99916
|
const sources = [];
|
|
99754
99917
|
for (const source of root.config.definitions) {
|
|
99755
|
-
if (!
|
|
99918
|
+
if (!existsSync15(source.path))
|
|
99756
99919
|
continue;
|
|
99757
99920
|
const digest = await definitionDigest(source.path);
|
|
99758
99921
|
if (digest === source.digest)
|
|
@@ -100026,14 +100189,24 @@ function hostRestorePort(options, git, shared, journal, agentDir) {
|
|
|
100026
100189
|
storeDir: join39(agentDir, "worktree-snapshots"),
|
|
100027
100190
|
git
|
|
100028
100191
|
});
|
|
100029
|
-
return (binding, hook) =>
|
|
100030
|
-
|
|
100031
|
-
|
|
100032
|
-
|
|
100033
|
-
|
|
100034
|
-
|
|
100035
|
-
|
|
100036
|
-
|
|
100192
|
+
return async (binding, hook) => {
|
|
100193
|
+
let result;
|
|
100194
|
+
const path = await restoreRunWorktree(hook.snapshot?.remotes, async () => {
|
|
100195
|
+
result = await restore(binding, hook);
|
|
100196
|
+
return typeof result === "string" ? result : result.path;
|
|
100197
|
+
}, {
|
|
100198
|
+
signal: hook.signal,
|
|
100199
|
+
agentDir,
|
|
100200
|
+
onNotices: (notices) => {
|
|
100201
|
+
for (const notice of notices)
|
|
100202
|
+
console.warn(`atomic-workflows: ${notice.message}`);
|
|
100203
|
+
}
|
|
100204
|
+
});
|
|
100205
|
+
if (typeof result !== "object" || result.partial === undefined)
|
|
100206
|
+
return path;
|
|
100207
|
+
console.warn(`atomic-workflows: ${result.partial.message}`);
|
|
100208
|
+
return { path, partial: result.partial };
|
|
100209
|
+
};
|
|
100037
100210
|
}
|
|
100038
100211
|
async function startWorkflowWorkerHost(options) {
|
|
100039
100212
|
validated(options);
|
|
@@ -100253,7 +100426,7 @@ __export(exports_sdk_surface, {
|
|
|
100253
100426
|
isForkSourceNotFoundError: () => isForkSourceNotFoundError,
|
|
100254
100427
|
isForkSourceOwnershipError: () => isForkSourceOwnershipError,
|
|
100255
100428
|
isForkTargetNotFoundError: () => isForkTargetNotFoundError,
|
|
100256
|
-
isGitUnavailableError: () =>
|
|
100429
|
+
isGitUnavailableError: () => isGitUnavailableError5,
|
|
100257
100430
|
isLocalWorkerOptionsError: () => isLocalWorkerOptionsError,
|
|
100258
100431
|
isLocalWorkerPoolError: () => isLocalWorkerPoolError,
|
|
100259
100432
|
isPoolAppendRefusedError: () => isPoolAppendRefusedError,
|
|
@@ -100323,7 +100496,7 @@ __export(exports_sdk_surface, {
|
|
|
100323
100496
|
isWorkspaceError: () => isWorkspaceError,
|
|
100324
100497
|
isWorkspaceGitError: () => isWorkspaceGitError3,
|
|
100325
100498
|
isWorkspacePublicationError: () => isWorkspacePublicationError,
|
|
100326
|
-
isWorkspaceRestoreError: () =>
|
|
100499
|
+
isWorkspaceRestoreError: () => isWorkspaceRestoreError3,
|
|
100327
100500
|
isWorkspaceRestoreUnavailableError: () => isWorkspaceRestoreUnavailableError,
|
|
100328
100501
|
isWorkspaceSandboxError: () => isWorkspaceSandboxError,
|
|
100329
100502
|
isWorkspaceSnapshotError: () => isWorkspaceSnapshotError2,
|
|
@@ -100402,7 +100575,7 @@ import {
|
|
|
100402
100575
|
isDecisionRequestError,
|
|
100403
100576
|
isDecisionTimeoutError,
|
|
100404
100577
|
isEventSourceError,
|
|
100405
|
-
isGitUnavailableError as
|
|
100578
|
+
isGitUnavailableError as isGitUnavailableError5,
|
|
100406
100579
|
isRetryableDecisionError,
|
|
100407
100580
|
isRetryableSubscriptionError,
|
|
100408
100581
|
isRetryableWorkspaceError,
|
|
@@ -100424,7 +100597,7 @@ import {
|
|
|
100424
100597
|
isWorkspaceError,
|
|
100425
100598
|
isWorkspaceGitError as isWorkspaceGitError3,
|
|
100426
100599
|
isWorkspacePublicationError,
|
|
100427
|
-
isWorkspaceRestoreError as
|
|
100600
|
+
isWorkspaceRestoreError as isWorkspaceRestoreError3,
|
|
100428
100601
|
isWorkspaceSandboxError,
|
|
100429
100602
|
isWorkspaceSnapshotError as isWorkspaceSnapshotError2,
|
|
100430
100603
|
isWorkspaceTimeoutError,
|
|
@@ -100515,8 +100688,8 @@ var init_workflows_host_module = __esm(() => {
|
|
|
100515
100688
|
|
|
100516
100689
|
// dist/builtin/workflows/src/workers/pool-journal.ts
|
|
100517
100690
|
import { createHash as createHash7, randomUUID as randomUUID24 } from "node:crypto";
|
|
100518
|
-
import { existsSync as
|
|
100519
|
-
import { basename as basename6, dirname as dirname22, join as join40, resolve as
|
|
100691
|
+
import { existsSync as existsSync16, mkdirSync as mkdirSync10, readFileSync as readFileSync9, writeFileSync as writeFileSync7 } from "node:fs";
|
|
100692
|
+
import { basename as basename6, dirname as dirname22, join as join40, resolve as resolve24 } from "node:path";
|
|
100520
100693
|
import { createChildProcessEnvironment as createChildProcessEnvironment6 } from "@bastani/atomic";
|
|
100521
100694
|
import { storageSelectionKey as storageSelectionKey2 } from "@bastani/atomic/storage";
|
|
100522
100695
|
function poolWorkerEnvironment(durable) {
|
|
@@ -100544,7 +100717,7 @@ function isReopenableSelection(selection) {
|
|
|
100544
100717
|
}
|
|
100545
100718
|
function encodeSelection(selection) {
|
|
100546
100719
|
if (selection.kind === "sqlite")
|
|
100547
|
-
return JSON.stringify({ ...selection, path:
|
|
100720
|
+
return JSON.stringify({ ...selection, path: resolve24(selection.path) });
|
|
100548
100721
|
return JSON.stringify({
|
|
100549
100722
|
...selection,
|
|
100550
100723
|
...selection.options === undefined ? {} : {
|
|
@@ -100590,7 +100763,7 @@ function coordinationDatabase(durable) {
|
|
|
100590
100763
|
return basename6(coordinationPath(durable), ".sqlite");
|
|
100591
100764
|
}
|
|
100592
100765
|
function openCoordinationJournal(path) {
|
|
100593
|
-
const file =
|
|
100766
|
+
const file = resolve24(path);
|
|
100594
100767
|
let opened = coordinationJournals.get(file);
|
|
100595
100768
|
if (opened === undefined) {
|
|
100596
100769
|
mkdirSync10(dirname22(file), { recursive: true });
|
|
@@ -100642,7 +100815,7 @@ async function poolJournalOf(journal) {
|
|
|
100642
100815
|
if (origin === undefined || !isReopenableSelection(origin.selection))
|
|
100643
100816
|
return journal;
|
|
100644
100817
|
const path = coordinationPath(poolDurableJournal(journal));
|
|
100645
|
-
if (!
|
|
100818
|
+
if (!existsSync16(path))
|
|
100646
100819
|
return journal;
|
|
100647
100820
|
const coordination = await openCoordinationJournal(path);
|
|
100648
100821
|
registerPoolJournal(journal, coordination);
|
|
@@ -101212,6 +101385,10 @@ async function runStageTaskAction(source, taskId, action) {
|
|
|
101212
101385
|
return { kind: "detail", detail: await source.taskDetailText(taskId) };
|
|
101213
101386
|
case "message":
|
|
101214
101387
|
return sendStageTaskMessage(source, taskId, action.text);
|
|
101388
|
+
case "commands": {
|
|
101389
|
+
const catalog = await source.taskCommands?.(taskId);
|
|
101390
|
+
return catalog === undefined ? { kind: "commands" } : { kind: "commands", catalog };
|
|
101391
|
+
}
|
|
101215
101392
|
case "transcript": {
|
|
101216
101393
|
const result = await source.readTaskTranscript(taskId, action.cursor);
|
|
101217
101394
|
const streaming = result.ok && action.cursor === undefined ? source.followTaskTranscript(taskId)?.session?.getStreamingMessage?.() : undefined;
|