@vicary/pi-subagents 0.88.1 → 0.89.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 +51 -1
- package/bundle/agents.js +3 -3
- package/bundle/child-tool-plan.js +2 -2
- package/bundle/{chunk-4QFZZV3O.js → chunk-4AL6LDBY.js} +3 -1
- package/bundle/{chunk-5EMPFFO4.js → chunk-4FFKVLBG.js} +4 -4
- package/bundle/{chunk-L4YY2TOE.js → chunk-5TXWZB73.js} +1 -1
- package/bundle/{chunk-YDZ7BZD5.js → chunk-77VQEATI.js} +1 -1
- package/bundle/{chunk-7OX6O7DQ.js → chunk-BERAWSQQ.js} +5 -5
- package/bundle/{chunk-LV3CPYXJ.js → chunk-C22YEYFZ.js} +4 -4
- package/bundle/{chunk-AZPP3G4N.js → chunk-DVOXHOTY.js} +34 -5
- package/bundle/{chunk-2HKPEANZ.js → chunk-JLZFSOEL.js} +26 -15
- package/bundle/{chunk-CPSUJHZE.js → chunk-KCDPTXHT.js} +39 -10
- package/bundle/{chunk-4MVDMA5C.js → chunk-LWH7IGI3.js} +21 -7
- package/bundle/{chunk-DSHQWGHO.js → chunk-MIX3MCIF.js} +96 -96
- package/bundle/{chunk-BKISQ5CJ.js → chunk-NLDROUCR.js} +56 -34
- package/bundle/{chunk-2DIEL4WG.js → chunk-OUM6SEVD.js} +2 -2
- package/bundle/{chunk-XIA5GSEU.js → chunk-Q4VH72JI.js} +2 -2
- package/bundle/{chunk-D32H53HM.js → chunk-R3NH5XAL.js} +1 -1
- package/bundle/{chunk-CGWNA6EJ.js → chunk-R5XS4CVE.js} +98 -29
- package/bundle/{chunk-V7SZMS6W.js → chunk-RHMU7SXN.js} +2 -2
- package/bundle/{chunk-4ZQBZDF3.js → chunk-SG3NCWZW.js} +86 -20
- package/bundle/{chunk-KXW62VBU.js → chunk-SWGB2P5J.js} +1 -1
- package/bundle/{chunk-6CG2VAG4.js → chunk-TRN65L4F.js} +1 -1
- package/bundle/{chunk-GDR2ILWY.js → chunk-TXC7WIPL.js} +51 -22
- package/bundle/{chunk-IYT7X46U.js → chunk-UNLGCAC4.js} +5 -5
- package/bundle/{chunk-PYKBTBY6.js → chunk-URKQZHVH.js} +9 -9
- package/bundle/{chunk-W6HIYD2Z.js → chunk-UUW7P6KJ.js} +1 -1
- package/bundle/{chunk-CYKNHFXB.js → chunk-VEEUXJDO.js} +1 -1
- package/bundle/{chunk-JQTHG2ID.js → chunk-WMGQNIP7.js} +75 -32
- package/bundle/{chunk-47ZN7NKR.js → chunk-YJIU5WF4.js} +1 -1
- package/bundle/{chunk-RMZAAXIR.js → chunk-YLU5JFW2.js} +2 -2
- package/bundle/control-channel.js +2 -2
- package/bundle/index.js +2 -2
- package/bundle/intercom-bridge.js +2 -2
- package/bundle/preflight.js +8 -8
- package/bundle/project-panes.js +3 -3
- package/docs/agents.md +10 -4
- package/docs/configuration.md +2 -0
- package/docs/extension-api.md +1 -1
- package/docs/tool-reference.md +1 -1
- package/docs/workflows.md +5 -3
- package/package.json +2 -2
- package/src/extension/herdr-pi-bridge.js +79 -23
- package/src/extension/schemas.js +1 -1
- package/src/extension/subagent-options.js +5 -0
- package/src/intercom/result-intercom.js +3 -2
- package/src/runs/background/async-job-tracker.js +85 -9
- package/src/runs/background/async-status.d.ts +2 -0
- package/src/runs/background/async-status.js +8 -3
- package/src/runs/background/notify.d.ts +3 -0
- package/src/runs/background/notify.js +7 -2
- package/src/runs/background/run-status.js +3 -2
- package/src/runs/background/runner-child-launch.js +1 -0
- package/src/runs/background/subagent-runner.js +11 -8
- package/src/runs/foreground/execution.js +8 -7
- package/src/runs/foreground/subagent-executor.js +31 -5
- package/src/runs/shared/child-launch.d.ts +2 -0
- package/src/runs/shared/child-launch.js +1 -1
- package/src/runs/shared/child-session.d.ts +2 -1
- package/src/runs/shared/herdr-connection.d.ts +6 -0
- package/src/runs/shared/herdr-connection.js +11 -1
- package/src/runs/shared/herdr-machine.d.ts +2 -2
- package/src/runs/shared/herdr-machine.js +49 -22
- package/src/runs/shared/herdr-pane-host.d.ts +7 -19
- package/src/runs/shared/herdr-pane-host.js +48 -33
- package/src/runs/shared/herdr-pi-protocol.d.ts +1 -0
- package/src/runs/shared/herdr-pi-protocol.js +3 -2
- package/src/runs/shared/herdr-placed-run.d.ts +2 -12
- package/src/runs/shared/herdr-placed-run.js +10 -8
- package/src/runs/shared/kept-branch-text.d.ts +8 -0
- package/src/runs/shared/kept-branch-text.js +24 -0
- package/src/runs/shared/local-machine-access.d.ts +4 -1
- package/src/runs/shared/local-machine-access.js +6 -3
- package/src/runs/shared/mutation-evidence.d.ts +7 -1
- package/src/runs/shared/mutation-evidence.js +18 -2
- package/src/runs/shared/parallel-handoff.js +19 -7
- package/src/runs/shared/placed-run-owner.d.ts +4 -2
- package/src/runs/shared/placed-run-owner.js +15 -7
- package/src/runs/shared/rex-machine.d.ts +7 -3
- package/src/runs/shared/rex-machine.js +12 -9
- package/src/runs/shared/rex-pane-host.js +7 -27
- package/src/runs/shared/single-output.js +2 -2
- package/src/runs/shared/subagent-prompt-runtime.js +34 -0
- package/src/runs/shared/tool-availability.d.ts +4 -0
- package/src/runs/shared/tool-availability.js +7 -0
- package/src/runs/shared/worktree-cleanup-plan.js +2 -2
- package/src/runs/shared/worktree.d.ts +4 -14
- package/src/runs/shared/worktree.js +38 -8
- package/src/shared/types.d.ts +26 -2
- package/src/shared/utils.d.ts +2 -0
- package/src/shared/utils.js +9 -0
- package/src/workflows/workflow-child-summary.d.ts +2 -1
- package/src/workflows/workflow-child-summary.js +14 -6
|
@@ -10,10 +10,10 @@ import {
|
|
|
10
10
|
setInlineWorkflowCoverage,
|
|
11
11
|
setMainThinkingLevelSource,
|
|
12
12
|
widgetRenderKey
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-4FFKVLBG.js";
|
|
14
14
|
import {
|
|
15
15
|
package_default
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-TRN65L4F.js";
|
|
17
17
|
import {
|
|
18
18
|
EXTERNAL_JOB_BRIDGE_REQUEST_DIR,
|
|
19
19
|
REVIVAL_ORIGIN_FILE,
|
|
@@ -66,7 +66,7 @@ import {
|
|
|
66
66
|
takeCompactionAbort,
|
|
67
67
|
workflowResumeClaimState,
|
|
68
68
|
workflowResumeRefusal
|
|
69
|
-
} from "./chunk-
|
|
69
|
+
} from "./chunk-JLZFSOEL.js";
|
|
70
70
|
import {
|
|
71
71
|
SUBAGENT_CHILD_ENV,
|
|
72
72
|
SUBAGENT_PARENT_SESSION_ENV,
|
|
@@ -86,14 +86,14 @@ import {
|
|
|
86
86
|
resolvePiSessionId,
|
|
87
87
|
resolveWaitToolConfig,
|
|
88
88
|
setDeclarationPinning
|
|
89
|
-
} from "./chunk-
|
|
89
|
+
} from "./chunk-UNLGCAC4.js";
|
|
90
90
|
import {
|
|
91
91
|
deliverAsyncRunStop,
|
|
92
92
|
ownerConfirmedDead,
|
|
93
93
|
readSessionMessagesTail,
|
|
94
94
|
resolveSubagentRunId,
|
|
95
95
|
restoreForegroundRunHistory
|
|
96
|
-
} from "./chunk-
|
|
96
|
+
} from "./chunk-C22YEYFZ.js";
|
|
97
97
|
import {
|
|
98
98
|
ASYNC_STATUS_SNAPSHOT_KIND,
|
|
99
99
|
ASYNC_STATUS_SNAPSHOT_VERSION,
|
|
@@ -108,8 +108,9 @@ import {
|
|
|
108
108
|
resolveAsyncRunLocation,
|
|
109
109
|
resolveAsyncStatusChild,
|
|
110
110
|
runLaunchDir,
|
|
111
|
-
stopStoppableAsyncStatusChildren
|
|
112
|
-
|
|
111
|
+
stopStoppableAsyncStatusChildren,
|
|
112
|
+
summarizeAsyncStatus
|
|
113
|
+
} from "./chunk-SG3NCWZW.js";
|
|
113
114
|
import {
|
|
114
115
|
CONTACT_SUPERVISOR_TOOL_NAME,
|
|
115
116
|
NATIVE_SUPERVISOR_TOOL_NAME,
|
|
@@ -119,7 +120,7 @@ import {
|
|
|
119
120
|
parseSupervisorReplyData,
|
|
120
121
|
parseSupervisorRequestDetails,
|
|
121
122
|
topLevelSupervisorTool
|
|
122
|
-
} from "./chunk-
|
|
123
|
+
} from "./chunk-VEEUXJDO.js";
|
|
123
124
|
import {
|
|
124
125
|
MODEL_ONLY_TOOL,
|
|
125
126
|
canRenderComponents,
|
|
@@ -145,7 +146,7 @@ import {
|
|
|
145
146
|
resolveDisabledFeatureSurface,
|
|
146
147
|
resolveMaxActiveAsyncRunsPerSession,
|
|
147
148
|
resolveScheduledStoreRoot
|
|
148
|
-
} from "./chunk-
|
|
149
|
+
} from "./chunk-YLU5JFW2.js";
|
|
149
150
|
import {
|
|
150
151
|
ACTIVE_RUN_INDEX_DIR,
|
|
151
152
|
MissionNotFoundError,
|
|
@@ -196,28 +197,28 @@ import {
|
|
|
196
197
|
withWorkflowChildRunModel,
|
|
197
198
|
writeAsyncResultFile,
|
|
198
199
|
writeResultIndexForData
|
|
199
|
-
} from "./chunk-
|
|
200
|
-
import "./chunk-
|
|
200
|
+
} from "./chunk-KCDPTXHT.js";
|
|
201
|
+
import "./chunk-UUW7P6KJ.js";
|
|
201
202
|
import {
|
|
202
203
|
shouldUseNativeFsWatch
|
|
203
204
|
} from "./chunk-NIXWDZZV.js";
|
|
204
205
|
import {
|
|
205
206
|
validateIntercomBridgeConfig
|
|
206
|
-
} from "./chunk-
|
|
207
|
+
} from "./chunk-YJIU5WF4.js";
|
|
207
208
|
import "./chunk-7F6RKT6W.js";
|
|
208
|
-
import "./chunk-
|
|
209
|
+
import "./chunk-R3NH5XAL.js";
|
|
209
210
|
import "./chunk-YARY7JWU.js";
|
|
210
211
|
import {
|
|
211
212
|
listHerdrProjectPaneRoots,
|
|
212
213
|
restoreHerdrProjectPaneSnapshots
|
|
213
|
-
} from "./chunk-
|
|
214
|
+
} from "./chunk-OUM6SEVD.js";
|
|
214
215
|
import "./chunk-7J4ZXMY7.js";
|
|
215
216
|
import {
|
|
216
217
|
cleanupAllArtifactDirs,
|
|
217
218
|
cleanupOldArtifacts,
|
|
218
219
|
getArtifactPaths,
|
|
219
220
|
getArtifactsDir
|
|
220
|
-
} from "./chunk-
|
|
221
|
+
} from "./chunk-77VQEATI.js";
|
|
221
222
|
import {
|
|
222
223
|
listBackgroundWorkProviders
|
|
223
224
|
} from "./chunk-XA3DY6UG.js";
|
|
@@ -225,12 +226,12 @@ import "./chunk-YYREO77V.js";
|
|
|
225
226
|
import "./chunk-UKG4V45O.js";
|
|
226
227
|
import {
|
|
227
228
|
registerRuntimeAgentEventListener
|
|
228
|
-
} from "./chunk-
|
|
229
|
+
} from "./chunk-5TXWZB73.js";
|
|
229
230
|
import {
|
|
230
231
|
clearRuntimeAgentsForPi,
|
|
231
232
|
listRuntimeAgentConfigs,
|
|
232
233
|
mergeRuntimeAgents
|
|
233
|
-
} from "./chunk-
|
|
234
|
+
} from "./chunk-SWGB2P5J.js";
|
|
234
235
|
import {
|
|
235
236
|
DEFAULT_FILE_SYSTEM_RETRY_DELAYS_MS,
|
|
236
237
|
DEFAULT_WAIT_TOOL_NAME,
|
|
@@ -253,6 +254,7 @@ import {
|
|
|
253
254
|
getPiSpawnCommand,
|
|
254
255
|
getProjectConfigDir,
|
|
255
256
|
getSupportedThinkingLevels,
|
|
257
|
+
isStatusAccessError,
|
|
256
258
|
mergeBuiltinAgentOverride,
|
|
257
259
|
parseFrontmatter,
|
|
258
260
|
readStatus,
|
|
@@ -273,7 +275,7 @@ import {
|
|
|
273
275
|
waitToolName,
|
|
274
276
|
withSettingsFileLease,
|
|
275
277
|
writeAtomicJson
|
|
276
|
-
} from "./chunk-
|
|
278
|
+
} from "./chunk-LWH7IGI3.js";
|
|
277
279
|
import {
|
|
278
280
|
DEFAULT_ARTIFACT_CONFIG,
|
|
279
281
|
DIRS,
|
|
@@ -597,6 +599,8 @@ function createAsyncJobTracker(pi, state, asyncDirRoot, options = {}) {
|
|
|
597
599
|
const runningJobIds = /* @__PURE__ */ new Set();
|
|
598
600
|
const externalJobBridgeRuns = /* @__PURE__ */ new Set();
|
|
599
601
|
const terminalPublications = /* @__PURE__ */ new Map();
|
|
602
|
+
const unreadableStatusRuns = /* @__PURE__ */ new Set();
|
|
603
|
+
const unverifiedRuns = /* @__PURE__ */ new Set();
|
|
600
604
|
const supervisorNoticeTimers = /* @__PURE__ */ new Map();
|
|
601
605
|
let rootWatcher;
|
|
602
606
|
let nextLivenessAt = Date.now() + livenessIntervalMs;
|
|
@@ -919,9 +923,47 @@ function createAsyncJobTracker(pi, state, asyncDirRoot, options = {}) {
|
|
|
919
923
|
runningJobIds.delete(asyncId);
|
|
920
924
|
externalJobBridgeRuns.delete(asyncId);
|
|
921
925
|
terminalPublications.delete(asyncId);
|
|
926
|
+
unreadableStatusRuns.delete(asyncId);
|
|
927
|
+
unverifiedRuns.delete(asyncId);
|
|
922
928
|
clearSupervisorNotices(asyncId);
|
|
923
929
|
};
|
|
930
|
+
const forgetJob = (asyncId) => {
|
|
931
|
+
cancelCleanup(asyncId);
|
|
932
|
+
closeJobWatcher(asyncId);
|
|
933
|
+
state.asyncJobs.delete(asyncId);
|
|
934
|
+
state.fleetJobs?.delete(asyncId);
|
|
935
|
+
options.onJobCleanup?.(asyncId);
|
|
936
|
+
};
|
|
924
937
|
const refreshJob = (job) => {
|
|
938
|
+
if (unverifiedRuns.has(job.asyncId)) {
|
|
939
|
+
let stored = null;
|
|
940
|
+
let summary;
|
|
941
|
+
try {
|
|
942
|
+
stored = readStatus(job.asyncDir);
|
|
943
|
+
if (stored) summary = summarizeAsyncStatus(job.asyncDir, stored);
|
|
944
|
+
} catch (error) {
|
|
945
|
+
if (isStatusAccessError(error, job.asyncDir)) return false;
|
|
946
|
+
console.error(`[pi-subagents] Dropping restored async run '${job.asyncId}' at '${path2.join(job.asyncDir, "status.json")}': ${error instanceof Error ? error.message : String(error)}.`);
|
|
947
|
+
}
|
|
948
|
+
const owners = state.currentSessionId ? ownerSessionIds(state.currentSessionId) : void 0;
|
|
949
|
+
if (!stored || !summary || owners && !owners.has(stored.sessionId)) {
|
|
950
|
+
forgetJob(job.asyncId);
|
|
951
|
+
return true;
|
|
952
|
+
}
|
|
953
|
+
let restored;
|
|
954
|
+
try {
|
|
955
|
+
restored = summaryToJob(summary);
|
|
956
|
+
} catch (error) {
|
|
957
|
+
if (!unreadableStatusRuns.has(job.asyncId)) {
|
|
958
|
+
unreadableStatusRuns.add(job.asyncId);
|
|
959
|
+
console.error(`Cannot read async control events for '${job.asyncDir}'; keeping it as running until they are readable:`, error);
|
|
960
|
+
}
|
|
961
|
+
return false;
|
|
962
|
+
}
|
|
963
|
+
Object.assign(job, restored, { status: job.status, controlEventCursor: job.controlEventCursor ?? restored.controlEventCursor });
|
|
964
|
+
rememberFleetJob(state, job);
|
|
965
|
+
unverifiedRuns.delete(job.asyncId);
|
|
966
|
+
}
|
|
925
967
|
const widgetExpanded = withLastUiContext((ctx) => ctx.ui.getToolsExpanded?.() ?? false) ?? false;
|
|
926
968
|
const widgetStateBefore = widgetRenderKey(job, widgetExpanded);
|
|
927
969
|
let nestedRefreshFailed = false;
|
|
@@ -967,6 +1009,7 @@ function createAsyncJobTracker(pi, state, asyncDirRoot, options = {}) {
|
|
|
967
1009
|
}
|
|
968
1010
|
});
|
|
969
1011
|
const status = reconciliation.status ?? readStatus(job.asyncDir);
|
|
1012
|
+
unreadableStatusRuns.delete(job.asyncId);
|
|
970
1013
|
if (!bridgeAlreadyRequired) {
|
|
971
1014
|
const bridgeEligibility = externalJobBridgeEligibility(status?.steps);
|
|
972
1015
|
if (bridgeEligibility === "required") externalJobBridgeRuns.add(job.asyncId);
|
|
@@ -1075,6 +1118,13 @@ function createAsyncJobTracker(pi, state, asyncDirRoot, options = {}) {
|
|
|
1075
1118
|
console.error(`Failed to service external job bridge for '${job.asyncDir}':`, bridgeError);
|
|
1076
1119
|
}
|
|
1077
1120
|
}
|
|
1121
|
+
if (isStatusAccessError(error, job.asyncDir)) {
|
|
1122
|
+
if (!unreadableStatusRuns.has(job.asyncId)) {
|
|
1123
|
+
unreadableStatusRuns.add(job.asyncId);
|
|
1124
|
+
console.error(`Cannot read async status for '${job.asyncDir}'; keeping its last known state until it is readable:`, error);
|
|
1125
|
+
}
|
|
1126
|
+
return widgetRenderKey(job, widgetExpanded) !== widgetStateBefore;
|
|
1127
|
+
}
|
|
1078
1128
|
if (job.status !== "failed") {
|
|
1079
1129
|
console.error(`Failed to read async status for '${job.asyncDir}':`, error);
|
|
1080
1130
|
job.status = "failed";
|
|
@@ -1192,11 +1242,7 @@ function createAsyncJobTracker(pi, state, asyncDirRoot, options = {}) {
|
|
|
1192
1242
|
const owners = state.currentSessionId ? ownerSessionIds(state.currentSessionId) : void 0;
|
|
1193
1243
|
for (const job of state.asyncJobs.values()) {
|
|
1194
1244
|
if (owners && job.sessionId !== void 0 && !owners.has(job.sessionId)) {
|
|
1195
|
-
|
|
1196
|
-
closeJobWatcher(job.asyncId);
|
|
1197
|
-
state.asyncJobs.delete(job.asyncId);
|
|
1198
|
-
state.fleetJobs?.delete(job.asyncId);
|
|
1199
|
-
options.onJobCleanup?.(job.asyncId);
|
|
1245
|
+
forgetJob(job.asyncId);
|
|
1200
1246
|
widgetChanged = true;
|
|
1201
1247
|
continue;
|
|
1202
1248
|
}
|
|
@@ -1305,6 +1351,8 @@ function createAsyncJobTracker(pi, state, asyncDirRoot, options = {}) {
|
|
|
1305
1351
|
runningJobIds.clear();
|
|
1306
1352
|
externalJobBridgeRuns.clear();
|
|
1307
1353
|
terminalPublications.clear();
|
|
1354
|
+
unreadableStatusRuns.clear();
|
|
1355
|
+
unverifiedRuns.clear();
|
|
1308
1356
|
clearSupervisorNotices();
|
|
1309
1357
|
};
|
|
1310
1358
|
const resetJobs = (ctx) => {
|
|
@@ -1328,8 +1376,17 @@ function createAsyncJobTracker(pi, state, asyncDirRoot, options = {}) {
|
|
|
1328
1376
|
state.statusProjectionSessionId = null;
|
|
1329
1377
|
if (!state.currentSessionId) return;
|
|
1330
1378
|
let runs;
|
|
1379
|
+
const unreadable = [];
|
|
1331
1380
|
try {
|
|
1332
|
-
runs = listAsyncRuns(asyncDirRoot, {
|
|
1381
|
+
runs = listAsyncRuns(asyncDirRoot, {
|
|
1382
|
+
states: ["queued", "running"],
|
|
1383
|
+
sessionId: state.currentSessionId,
|
|
1384
|
+
resultsDir,
|
|
1385
|
+
kill: options.kill,
|
|
1386
|
+
now: options.now,
|
|
1387
|
+
adoptCompletionOwnerId: state.completionOwnerId,
|
|
1388
|
+
onUnreadableActiveRun: (runId, asyncDir) => unreadable.push({ runId, asyncDir })
|
|
1389
|
+
}, observeStatus);
|
|
1333
1390
|
} catch (error) {
|
|
1334
1391
|
console.error(`Failed to restore active async jobs from '${asyncDirRoot}':`, error);
|
|
1335
1392
|
return;
|
|
@@ -1341,8 +1398,20 @@ function createAsyncJobTracker(pi, state, asyncDirRoot, options = {}) {
|
|
|
1341
1398
|
rememberFleetJob(state, job);
|
|
1342
1399
|
watchJob(job);
|
|
1343
1400
|
}
|
|
1401
|
+
for (const { runId, asyncDir } of unreadable) {
|
|
1402
|
+
if (state.asyncJobs.has(runId)) continue;
|
|
1403
|
+
const job = { asyncId: runId, asyncDir, status: "running", sessionId: state.currentSessionId, updatedAt: Date.now() };
|
|
1404
|
+
try {
|
|
1405
|
+
job.controlEventCursor = restoredControlEventCursor(asyncDir);
|
|
1406
|
+
} catch {
|
|
1407
|
+
}
|
|
1408
|
+
state.asyncJobs.set(runId, job);
|
|
1409
|
+
runningJobIds.add(runId);
|
|
1410
|
+
unverifiedRuns.add(runId);
|
|
1411
|
+
watchJob(job);
|
|
1412
|
+
}
|
|
1344
1413
|
state.statusProjectionSessionId = state.currentSessionId;
|
|
1345
|
-
if (runs.length === 0) return;
|
|
1414
|
+
if (runs.length === 0 && unreadable.length === 0) return;
|
|
1346
1415
|
ensurePoller();
|
|
1347
1416
|
rerenderLastWidget();
|
|
1348
1417
|
};
|
|
@@ -5370,7 +5439,7 @@ function registerSlashCommands(pi, state, options = {}) {
|
|
|
5370
5439
|
}
|
|
5371
5440
|
fleetOpen = true;
|
|
5372
5441
|
try {
|
|
5373
|
-
const { openSubagentFleet } = await import("./chunk-
|
|
5442
|
+
const { openSubagentFleet } = await import("./chunk-URKQZHVH.js");
|
|
5374
5443
|
await openSubagentFleet(ctx, state, { asyncDirRoot: DIRS.async, inspectorPlugins: () => getInspectorPlugins(pi), resultsDir: DIRS.results, fleetKeybindings: options.fleetKeybindings });
|
|
5375
5444
|
} finally {
|
|
5376
5445
|
fleetOpen = false;
|
|
@@ -8784,7 +8853,7 @@ function registerSubagentExtension(pi) {
|
|
|
8784
8853
|
const ctx = withLastUiContext((current) => current);
|
|
8785
8854
|
if (!ctx) return;
|
|
8786
8855
|
try {
|
|
8787
|
-
const { openSubagentFleet } = await import("./chunk-
|
|
8856
|
+
const { openSubagentFleet } = await import("./chunk-URKQZHVH.js");
|
|
8788
8857
|
await openSubagentFleet(ctx, state, { initialKey: itemKey, asyncDirRoot: DIRS.async, resultsDir: DIRS.results, fleetKeybindings: config.fleetKeybindings, inspectorPlugins: () => getInspectorPlugins(pi) });
|
|
8789
8858
|
} catch (error) {
|
|
8790
8859
|
if (isStaleExtensionContextError(error)) {
|
|
@@ -8993,7 +9062,7 @@ function registerSubagentExtension(pi) {
|
|
|
8993
9062
|
let executor;
|
|
8994
9063
|
let executorPromise;
|
|
8995
9064
|
let executorModulePromise;
|
|
8996
|
-
const loadExecutorModule = () => executorModulePromise ??= import("./chunk-
|
|
9065
|
+
const loadExecutorModule = () => executorModulePromise ??= import("./chunk-NLDROUCR.js");
|
|
8997
9066
|
const getExecutor = () => {
|
|
8998
9067
|
executorPromise ??= loadExecutorModule().then(({ createSubagentExecutor }) => {
|
|
8999
9068
|
executor = createSubagentExecutor(executorDeps);
|
|
@@ -9007,7 +9076,7 @@ function registerSubagentExtension(pi) {
|
|
|
9007
9076
|
modulePreloadTimer = setTimeout(() => {
|
|
9008
9077
|
loadExecutorModule().catch(() => {
|
|
9009
9078
|
});
|
|
9010
|
-
if (fleetViewEnabled) import("./chunk-
|
|
9079
|
+
if (fleetViewEnabled) import("./chunk-URKQZHVH.js").catch(() => {
|
|
9011
9080
|
});
|
|
9012
9081
|
}, MODULE_PRELOAD_DELAY_MS);
|
|
9013
9082
|
modulePreloadTimer.unref?.();
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
appendAgentRefinementOverlay
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-Q4VH72JI.js";
|
|
4
4
|
import {
|
|
5
5
|
buildAgentMemoryInjection,
|
|
6
6
|
buildSkillInjection
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-LWH7IGI3.js";
|
|
8
8
|
|
|
9
9
|
// src/runs/shared/effective-system-prompt.ts
|
|
10
10
|
function appendSection(prompt, section) {
|
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
hostStepVerdictLabel,
|
|
29
29
|
isActiveAsyncState,
|
|
30
30
|
isComparablePathInside,
|
|
31
|
+
isWorktreeCleanupTaskDone,
|
|
31
32
|
normalizeParallelGroups,
|
|
32
33
|
normalizeWorktreeBaseRef,
|
|
33
34
|
parseHostStepNode,
|
|
@@ -46,10 +47,10 @@ import {
|
|
|
46
47
|
validateModelResponseAliases,
|
|
47
48
|
withWorkflowChildRunModel,
|
|
48
49
|
withWorktreeTransaction
|
|
49
|
-
} from "./chunk-
|
|
50
|
+
} from "./chunk-KCDPTXHT.js";
|
|
50
51
|
import {
|
|
51
52
|
validateIntercomBridgeConfig
|
|
52
|
-
} from "./chunk-
|
|
53
|
+
} from "./chunk-YJIU5WF4.js";
|
|
53
54
|
import {
|
|
54
55
|
stableJsonDigest
|
|
55
56
|
} from "./chunk-7F6RKT6W.js";
|
|
@@ -58,7 +59,7 @@ import {
|
|
|
58
59
|
} from "./chunk-YARY7JWU.js";
|
|
59
60
|
import {
|
|
60
61
|
missingForkCopyNote
|
|
61
|
-
} from "./chunk-
|
|
62
|
+
} from "./chunk-77VQEATI.js";
|
|
62
63
|
import {
|
|
63
64
|
DEFAULT_FILE_SYSTEM_RETRY_DELAYS_MS,
|
|
64
65
|
assertWorkflowLaneKey,
|
|
@@ -71,6 +72,7 @@ import {
|
|
|
71
72
|
intersectThinkingCeilings,
|
|
72
73
|
isDynamicParallelStep,
|
|
73
74
|
isParallelStep,
|
|
75
|
+
isStatusAccessError,
|
|
74
76
|
normalizeExtensionBindings,
|
|
75
77
|
normalizeWorkflowLaneMetadata,
|
|
76
78
|
parseThinkingLevel,
|
|
@@ -83,7 +85,7 @@ import {
|
|
|
83
85
|
validateToolBudgetConfig,
|
|
84
86
|
waitForFileSystemRetry,
|
|
85
87
|
writeAtomicJson
|
|
86
|
-
} from "./chunk-
|
|
88
|
+
} from "./chunk-LWH7IGI3.js";
|
|
87
89
|
import {
|
|
88
90
|
DIRS,
|
|
89
91
|
RUNNER_LAUNCHER_NAME_PATTERN,
|
|
@@ -545,6 +547,7 @@ function stopStoppableAsyncStatusChildren(status, stopChild, message) {
|
|
|
545
547
|
var KEY_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
|
|
546
548
|
var TERMINAL_STATES = /* @__PURE__ */ new Set(["completed", "failed", "paused", "stopped", "rejected", "detached"]);
|
|
547
549
|
var MAX_REQUIRED_ID_BYTES = 4096;
|
|
550
|
+
var MAX_SESSION_FILE_BYTES = 4096;
|
|
548
551
|
var ACTIVITY_COUNTERS = ["currentToolStartedAt", "lastActivityAt", "durationMs", "toolCount", "turnCount", "tokens", "inputTokens", "outputTokens"];
|
|
549
552
|
function workflowChildProgress(progress) {
|
|
550
553
|
return {
|
|
@@ -599,6 +602,7 @@ function workflowChildSummary(input) {
|
|
|
599
602
|
...bounded(entry.runId, 256) ? { runId: bounded(entry.runId, 256) } : {},
|
|
600
603
|
...previous?.agent ? { agent: previous.agent } : {},
|
|
601
604
|
...previous?.sessionName ? { sessionName: previous.sessionName } : {},
|
|
605
|
+
...previous?.sessionFile ? { sessionFile: previous.sessionFile } : {},
|
|
602
606
|
...previous?.model ? { model: previous.model } : {},
|
|
603
607
|
...previous?.thinking ? { thinking: previous.thinking } : {}
|
|
604
608
|
});
|
|
@@ -615,6 +619,7 @@ function workflowChildSummary(input) {
|
|
|
615
619
|
...bounded(step.runId, 256) ? { runId: bounded(step.runId, 256) } : {},
|
|
616
620
|
...launchResolved && bounded(step.agent, 256) ? { agent: bounded(step.agent, 256) } : {},
|
|
617
621
|
...bounded(step.sessionName, 256) ? { sessionName: bounded(step.sessionName, 256) } : {},
|
|
622
|
+
...bounded(step.sessionFile, MAX_SESSION_FILE_BYTES) ? { sessionFile: step.sessionFile } : {},
|
|
618
623
|
...bounded(step.model, 256) ? { model: bounded(step.model, 256) } : {},
|
|
619
624
|
...bounded(step.thinking, 32) ? { thinking: bounded(step.thinking, 32) } : {}
|
|
620
625
|
});
|
|
@@ -629,6 +634,7 @@ function workflowChildSummary(input) {
|
|
|
629
634
|
...bounded(child.runId, 256) ? { runId: bounded(child.runId, 256) } : {},
|
|
630
635
|
...bounded(child.agent, 256) ? { agent: bounded(child.agent, 256) } : {},
|
|
631
636
|
...bounded(result?.sessionName, 256) ? { sessionName: bounded(result?.sessionName, 256) } : {},
|
|
637
|
+
...bounded(result?.sessionFile, MAX_SESSION_FILE_BYTES) ? { sessionFile: result?.sessionFile } : {},
|
|
632
638
|
...bounded(result?.model, 256) ? { model: bounded(result?.model, 256) } : {},
|
|
633
639
|
...bounded(result?.thinking, 32) ? { thinking: bounded(result?.thinking, 32) } : {}
|
|
634
640
|
});
|
|
@@ -640,11 +646,14 @@ function workflowChildSummary(input) {
|
|
|
640
646
|
}
|
|
641
647
|
for (const [key, launch] of input.launches ?? []) {
|
|
642
648
|
const row = rows.get(key);
|
|
643
|
-
if (!row
|
|
649
|
+
if (!row) continue;
|
|
650
|
+
const running = row.state === "running";
|
|
644
651
|
rows.set(key, {
|
|
645
652
|
...row,
|
|
646
|
-
|
|
647
|
-
|
|
653
|
+
...running && !row.runId && bounded(launch.runId, 256) ? { runId: launch.runId } : {},
|
|
654
|
+
...running && !row.agent && bounded(launch.agent, 256) ? { agent: launch.agent } : {},
|
|
655
|
+
// Finished rows keep it too: live updates carry no child results, so this is a settled child's only transcript link until the workflow returns.
|
|
656
|
+
...!row.sessionFile && bounded(launch.sessionFile, MAX_SESSION_FILE_BYTES) ? { sessionFile: launch.sessionFile } : {}
|
|
648
657
|
});
|
|
649
658
|
}
|
|
650
659
|
for (const [key, progress] of input.progress ?? []) {
|
|
@@ -680,16 +689,16 @@ function parseWorkflowChildSummary(value) {
|
|
|
680
689
|
const children = input.children.map((row) => {
|
|
681
690
|
if (!row || typeof row !== "object" || Array.isArray(row)) throw new Error("workflowChildren child row is invalid.");
|
|
682
691
|
const child = row;
|
|
683
|
-
if (Object.keys(child).some((key) => !["childId", "runId", "agent", "sessionName", "model", "thinking", "state", "activity"].includes(key))) throw new Error("workflowChildren child row has unsupported fields.");
|
|
692
|
+
if (Object.keys(child).some((key) => !["childId", "runId", "agent", "sessionName", "sessionFile", "model", "thinking", "state", "activity"].includes(key))) throw new Error("workflowChildren child row has unsupported fields.");
|
|
684
693
|
if (typeof child.childId !== "string" || !KEY_PATTERN.test(child.childId)) throw new Error("workflowChildren childId is invalid.");
|
|
685
694
|
const state = child.state;
|
|
686
695
|
if (state !== "pending" && state !== "running" && state !== "completed" && state !== "failed" && state !== "paused" && state !== "stopped" && state !== "rejected" && state !== "detached") throw new Error("workflowChildren child state is invalid.");
|
|
687
|
-
for (const [field, maxBytes] of [["runId", 256], ["agent", 256], ["sessionName", 256], ["model", 256], ["thinking", 32]]) {
|
|
696
|
+
for (const [field, maxBytes] of [["runId", 256], ["agent", 256], ["sessionName", 256], ["sessionFile", MAX_SESSION_FILE_BYTES], ["model", 256], ["thinking", 32]]) {
|
|
688
697
|
if (child[field] !== void 0 && bounded(child[field], maxBytes) === void 0) throw new Error(`workflowChildren child ${field} is invalid.`);
|
|
689
698
|
}
|
|
690
699
|
const activity = parseActivity(child.activity);
|
|
691
700
|
if (activity && state !== "running") throw new Error("workflowChildren child activity requires running state.");
|
|
692
|
-
return { childId: child.childId, state, ...activity ? { activity } : {}, ...child.runId ? { runId: child.runId } : {}, ...child.agent ? { agent: child.agent } : {}, ...child.sessionName ? { sessionName: child.sessionName } : {}, ...child.model ? { model: child.model } : {}, ...child.thinking ? { thinking: child.thinking } : {} };
|
|
701
|
+
return { childId: child.childId, state, ...activity ? { activity } : {}, ...child.runId ? { runId: child.runId } : {}, ...child.agent ? { agent: child.agent } : {}, ...child.sessionName ? { sessionName: child.sessionName } : {}, ...child.sessionFile ? { sessionFile: child.sessionFile } : {}, ...child.model ? { model: child.model } : {}, ...child.thinking ? { thinking: child.thinking } : {} };
|
|
693
702
|
});
|
|
694
703
|
if (new Set(children.map((child) => child.childId)).size !== children.length) throw new Error("workflowChildren has duplicate childId values.");
|
|
695
704
|
if (typeof input.parentToolCallId !== "string") throw new Error("workflowChildren.parentToolCallId is invalid.");
|
|
@@ -1683,6 +1692,12 @@ async function hashFileAsync(diffPath) {
|
|
|
1683
1692
|
function splitNul(output) {
|
|
1684
1693
|
return output.split("\0").filter((part) => part.length > 0);
|
|
1685
1694
|
}
|
|
1695
|
+
function gitFailureReason(error) {
|
|
1696
|
+
const stderr = error && typeof error === "object" && "stderr" in error ? String(error.stderr ?? "") : "";
|
|
1697
|
+
if (/not a git repository/i.test(stderr)) return "not a Git work tree";
|
|
1698
|
+
const firstLine = (stderr || (error instanceof Error ? error.message : String(error))).split("\n").find((line) => line.trim().length > 0);
|
|
1699
|
+
return firstLine?.trim() ?? "git failed";
|
|
1700
|
+
}
|
|
1686
1701
|
function hashLargeDiff(cwd, relativePath) {
|
|
1687
1702
|
const tempDir = fs2.mkdtempSync(path2.join(os.tmpdir(), "pi-subagents-tracked-diff-"));
|
|
1688
1703
|
const diffPath = path2.join(tempDir, "diff.patch");
|
|
@@ -1729,7 +1744,7 @@ function snapshotTrackedMutations(cwd) {
|
|
|
1729
1744
|
for (const file of changed.paths) fingerprints[file] = fingerprintPath(cwd, file);
|
|
1730
1745
|
return { source: "tracked-files", trackedOnly: true, cwd, dirtyFiles: changed.paths, fingerprints, truncated: changed.truncated };
|
|
1731
1746
|
} catch (error) {
|
|
1732
|
-
return { source: "tracked-files", trackedOnly: true, cwd, dirtyFiles: [], fingerprints: {}, unavailable:
|
|
1747
|
+
return { source: "tracked-files", trackedOnly: true, cwd, dirtyFiles: [], fingerprints: {}, unavailable: gitFailureReason(error) };
|
|
1733
1748
|
}
|
|
1734
1749
|
}
|
|
1735
1750
|
async function fingerprintPathAsync(cwd, relativePath) {
|
|
@@ -1747,6 +1762,13 @@ async function fingerprintPathAsync(cwd, relativePath) {
|
|
|
1747
1762
|
}
|
|
1748
1763
|
}
|
|
1749
1764
|
}
|
|
1765
|
+
function remoteMutationSnapshot(cwd) {
|
|
1766
|
+
return { source: "tracked-files", trackedOnly: true, cwd, dirtyFiles: [], fingerprints: {}, unavailable: "Local Git evidence is not authoritative for a pane-native remote run." };
|
|
1767
|
+
}
|
|
1768
|
+
function remoteMutationEvidence(machine) {
|
|
1769
|
+
const changed = machine.initialGit && machine.finalGit ? machine.initialGit.head !== machine.finalGit.head || machine.initialGit.dirty !== machine.finalGit.dirty : void 0;
|
|
1770
|
+
return { source: "tracked-files", trackedOnly: true, changedFiles: [], attemptedMutation: changed === true, ...changed === void 0 ? { unavailable: "Remote Git before/after evidence was incomplete." } : {} };
|
|
1771
|
+
}
|
|
1750
1772
|
async function collectTrackedMutationEvidence(snapshot, cwd = snapshot.cwd) {
|
|
1751
1773
|
if (snapshot.unavailable) {
|
|
1752
1774
|
return { source: "tracked-files", trackedOnly: true, changedFiles: [], attemptedMutation: false, unavailable: snapshot.unavailable };
|
|
@@ -1772,7 +1794,7 @@ async function collectTrackedMutationEvidence(snapshot, cwd = snapshot.cwd) {
|
|
|
1772
1794
|
truncated: snapshot.truncated || current.truncated || void 0
|
|
1773
1795
|
};
|
|
1774
1796
|
} catch (error) {
|
|
1775
|
-
return { source: "tracked-files", trackedOnly: true, changedFiles: [], attemptedMutation: false, unavailable:
|
|
1797
|
+
return { source: "tracked-files", trackedOnly: true, changedFiles: [], attemptedMutation: false, unavailable: gitFailureReason(error) };
|
|
1776
1798
|
}
|
|
1777
1799
|
}
|
|
1778
1800
|
function formatPathList(paths) {
|
|
@@ -2151,9 +2173,11 @@ function isolateCorruptActiveRun(asyncDir, runId, error, now) {
|
|
|
2151
2173
|
}
|
|
2152
2174
|
const markerCanBeReleased = processTerminal?.state === "observed" || markerAge !== void 0 && markerAge > DEFAULT_STALE_TERMINAL_ACTIVE_MARKER_MS;
|
|
2153
2175
|
let markerAction = "active marker retained because runner liveness is unknown";
|
|
2176
|
+
let retained = true;
|
|
2154
2177
|
if (markerCanBeReleased) {
|
|
2155
2178
|
try {
|
|
2156
2179
|
releaseActiveRunIndex(asyncDir);
|
|
2180
|
+
retained = false;
|
|
2157
2181
|
markerAction = processTerminal?.state === "observed" ? "active marker released after observed process-terminal proof" : "stale active marker released";
|
|
2158
2182
|
} catch (releaseError) {
|
|
2159
2183
|
markerAction = `failed to release active marker: ${getErrorMessage(releaseError)}`;
|
|
@@ -2168,9 +2192,10 @@ function isolateCorruptActiveRun(asyncDir, runId, error, now) {
|
|
|
2168
2192
|
}
|
|
2169
2193
|
const signature = `${fileSignature}
|
|
2170
2194
|
${line}`;
|
|
2171
|
-
if (reportedCorruptStatus.get(statusPath) === signature) return;
|
|
2195
|
+
if (reportedCorruptStatus.get(statusPath) === signature) return retained;
|
|
2172
2196
|
reportedCorruptStatus.set(statusPath, signature);
|
|
2173
2197
|
console.error(line);
|
|
2198
|
+
return retained;
|
|
2174
2199
|
}
|
|
2175
2200
|
function isNotFoundError(error) {
|
|
2176
2201
|
return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
|
|
@@ -2403,6 +2428,9 @@ function statusToSummary(asyncDir, status, nestedWarnings = [], nestedRoute) {
|
|
|
2403
2428
|
...status.sessionFile ? { sessionFile: status.sessionFile } : {}
|
|
2404
2429
|
};
|
|
2405
2430
|
}
|
|
2431
|
+
function summarizeAsyncStatus(asyncDir, status) {
|
|
2432
|
+
return statusToSummary(asyncDir, status);
|
|
2433
|
+
}
|
|
2406
2434
|
function sortRuns(runs) {
|
|
2407
2435
|
const rank = (state) => {
|
|
2408
2436
|
switch (state) {
|
|
@@ -2502,7 +2530,7 @@ function listAsyncRuns(asyncDirRoot, options = {}, observeStatus) {
|
|
|
2502
2530
|
} catch (error) {
|
|
2503
2531
|
observeStatus?.(null);
|
|
2504
2532
|
if (!activeEntries.has(entry) || !isAsyncStatusIsolationError(asyncDir, error)) throw error;
|
|
2505
|
-
isolateCorruptActiveRun(asyncDir, entry, error, options.now);
|
|
2533
|
+
if (isolateCorruptActiveRun(asyncDir, entry, error, options.now) && isStatusAccessError(error, asyncDir)) options.onUnreadableActiveRun?.(entry, asyncDir);
|
|
2506
2534
|
continue;
|
|
2507
2535
|
}
|
|
2508
2536
|
if (!status) {
|
|
@@ -2745,6 +2773,30 @@ async function withRepositoryWorktreeLock(repo, action, options = {}) {
|
|
|
2745
2773
|
// src/runs/shared/parallel-handoff.ts
|
|
2746
2774
|
import * as fs5 from "node:fs";
|
|
2747
2775
|
import * as path5 from "node:path";
|
|
2776
|
+
|
|
2777
|
+
// src/runs/shared/kept-branch-text.ts
|
|
2778
|
+
var KEPT_BRANCH_LINE = /^Kept branch (\S+) at ([0-9a-f]+): its commits are on no other branch\.$/;
|
|
2779
|
+
function readKeptBranches(value) {
|
|
2780
|
+
if (!Array.isArray(value)) return [];
|
|
2781
|
+
return value.filter((entry) => typeof entry?.branch === "string" && typeof entry?.tip === "string");
|
|
2782
|
+
}
|
|
2783
|
+
function formatKeptBranchLines(keptBranches) {
|
|
2784
|
+
return keptBranches.map(({ branch, tip }) => `Kept branch ${branch} at ${tip.slice(0, 12)}: its commits are on no other branch.`);
|
|
2785
|
+
}
|
|
2786
|
+
function formatParallelHandoffLines(handoffPath, keptBranches) {
|
|
2787
|
+
return [`Parallel handoff: ${handoffPath}`, ...formatKeptBranchLines(readKeptBranches(keptBranches))];
|
|
2788
|
+
}
|
|
2789
|
+
function parseKeptBranchLines(lines) {
|
|
2790
|
+
const kept = [];
|
|
2791
|
+
for (const line of lines) {
|
|
2792
|
+
const match = line.match(KEPT_BRANCH_LINE);
|
|
2793
|
+
if (!match) break;
|
|
2794
|
+
kept.push({ branch: match[1], tip: match[2] });
|
|
2795
|
+
}
|
|
2796
|
+
return kept;
|
|
2797
|
+
}
|
|
2798
|
+
|
|
2799
|
+
// src/runs/shared/parallel-handoff.ts
|
|
2748
2800
|
function optionalIdentity(value, label) {
|
|
2749
2801
|
if (value === void 0) return void 0;
|
|
2750
2802
|
if (typeof value !== "string" || !value.trim()) throw new Error(`${label} must be a non-empty string.`);
|
|
@@ -2890,6 +2942,7 @@ function resolveRetainedWorktreeCwd(manifestPath, runId, childIndex, recordedWor
|
|
|
2890
2942
|
}
|
|
2891
2943
|
function referenceFor(manifestPath, manifest) {
|
|
2892
2944
|
const children = manifest.groups.flatMap((group) => group.children);
|
|
2945
|
+
const keptBranches = manifest.groups.flatMap((group) => group.cleanup.tasks.flatMap((task) => task.keptBranchTip ? [{ branch: task.branch, tip: task.keptBranchTip }] : []));
|
|
2893
2946
|
return {
|
|
2894
2947
|
version: 1,
|
|
2895
2948
|
path: manifestPath,
|
|
@@ -2897,6 +2950,7 @@ function referenceFor(manifestPath, manifest) {
|
|
|
2897
2950
|
childCount: children.length,
|
|
2898
2951
|
changedPatches: children.filter((child) => child.patch.changed).length,
|
|
2899
2952
|
cleanupState: manifest.groups.every((group) => group.cleanup.state === "complete") ? "complete" : "partial",
|
|
2953
|
+
...keptBranches.length ? { keptBranches } : {},
|
|
2900
2954
|
...Object.prototype.hasOwnProperty.call(manifest, "cleanupEligibility") ? { cleanupEligibility: trustedStoredCleanupEligibility(manifest) } : {}
|
|
2901
2955
|
};
|
|
2902
2956
|
}
|
|
@@ -3242,6 +3296,7 @@ function writeParallelHandoffGroupUnlocked(input) {
|
|
|
3242
3296
|
const previous = existing?.groups.flatMap((item) => item.cleanup.tasks).find((item) => item.path === task.path && item.branch === task.branch);
|
|
3243
3297
|
if (previous?.worktreeRemoved) task.worktreeRemoved = true;
|
|
3244
3298
|
if (previous?.branchRemoved) task.branchRemoved = true;
|
|
3299
|
+
if (previous?.keptBranchTip) task.keptBranchTip = previous.keptBranchTip;
|
|
3245
3300
|
if (!task.worktreeRemoved && previous?.reason?.includes("retained child resume")) {
|
|
3246
3301
|
task.preserved = true;
|
|
3247
3302
|
task.reason = previous.reason;
|
|
@@ -3349,10 +3404,15 @@ function writeWorktreeSetupHandoff(input) {
|
|
|
3349
3404
|
});
|
|
3350
3405
|
}
|
|
3351
3406
|
function formatParallelHandoffReference(reference) {
|
|
3352
|
-
|
|
3407
|
+
const patches = reference.changedPatches > 0 ? "; the work is in groups[].children[].patch, not applied to this checkout" : "";
|
|
3408
|
+
const kept = reference.cleanupState === "complete" ? "" : "; groups[].cleanup.tasks[] (reason, errors) says what stayed behind";
|
|
3409
|
+
return [
|
|
3410
|
+
`Worktree handoff: ${reference.path} (${reference.childCount} children, ${reference.changedPatches} changed patches, cleanup ${reference.cleanupState})${patches}${kept}`,
|
|
3411
|
+
...formatKeptBranchLines(reference.keptBranches ?? [])
|
|
3412
|
+
].join("\n");
|
|
3353
3413
|
}
|
|
3354
3414
|
function formatParallelHandoffError(error) {
|
|
3355
|
-
return `Worktree handoff unavailable: ${error instanceof Error ? error.message : String(error)}`;
|
|
3415
|
+
return `Worktree handoff unavailable: ${error instanceof Error ? error.message : String(error)}; check \`git worktree list\` for worktrees left behind`;
|
|
3356
3416
|
}
|
|
3357
3417
|
function discardPreservedWorktrees(...args) {
|
|
3358
3418
|
return withHandoffWriteLock(args[0], () => discardPreservedWorktreesUnlocked(...args));
|
|
@@ -3363,7 +3423,7 @@ function discardPreservedWorktreesUnlocked(manifestPath, authorization) {
|
|
|
3363
3423
|
if (!manifest) throw new Error(`Parallel handoff manifest not found: ${resolvedPath}`);
|
|
3364
3424
|
let attempted = 0;
|
|
3365
3425
|
for (const group of manifest.groups) {
|
|
3366
|
-
const pending = group.cleanup.tasks.filter((task) => task.preserved && (
|
|
3426
|
+
const pending = group.cleanup.tasks.filter((task) => task.preserved && !isWorktreeCleanupTaskDone(task));
|
|
3367
3427
|
if (pending.length === 0) continue;
|
|
3368
3428
|
attempted += pending.length;
|
|
3369
3429
|
const report = cleanupWorktrees({
|
|
@@ -3381,11 +3441,11 @@ function discardPreservedWorktreesUnlocked(manifestPath, authorization) {
|
|
|
3381
3441
|
syntheticPaths: []
|
|
3382
3442
|
}))
|
|
3383
3443
|
}, { kind: "discard", authorization });
|
|
3384
|
-
const updates = new Map(report.tasks.map((task) => [task.index, task
|
|
3444
|
+
const updates = new Map(report.tasks.map((task) => [task.index, isWorktreeCleanupTaskDone(task) ? task : { ...task, preserved: true, reason: task.reason ?? "discard cleanup remains incomplete" }]));
|
|
3385
3445
|
group.cleanup = {
|
|
3386
3446
|
state: group.cleanup.tasks.every((task) => {
|
|
3387
3447
|
const next = updates.get(task.index) ?? task;
|
|
3388
|
-
return next
|
|
3448
|
+
return isWorktreeCleanupTaskDone(next);
|
|
3389
3449
|
}) && report.pruned ? "complete" : "partial",
|
|
3390
3450
|
tasks: group.cleanup.tasks.map((task) => updates.get(task.index) ?? task),
|
|
3391
3451
|
pruned: report.pruned,
|
|
@@ -3394,7 +3454,7 @@ function discardPreservedWorktreesUnlocked(manifestPath, authorization) {
|
|
|
3394
3454
|
}
|
|
3395
3455
|
manifest.updatedAt = Date.now();
|
|
3396
3456
|
writeAtomicJson(resolvedPath, manifest);
|
|
3397
|
-
const remaining = manifest.groups.flatMap((group) => group.cleanup.tasks.map((task) => ({ group, task }))).filter(({ task }) => task.preserved && (
|
|
3457
|
+
const remaining = manifest.groups.flatMap((group) => group.cleanup.tasks.map((task) => ({ group, task }))).filter(({ task }) => task.preserved && !isWorktreeCleanupTaskDone(task));
|
|
3398
3458
|
const lines = attempted === 0 ? [`No preserved worktrees remain in ${resolvedPath}.`] : [`Discard processed ${attempted} preserved worktree${attempted === 1 ? "" : "s"}.`, `Manifest: ${resolvedPath}`];
|
|
3399
3459
|
if (remaining.length > 0) {
|
|
3400
3460
|
lines.push("", "Some worktrees remain. Inspect and remove them manually if appropriate:");
|
|
@@ -4164,6 +4224,8 @@ export {
|
|
|
4164
4224
|
projectAsyncWorkflowRows,
|
|
4165
4225
|
projectAsyncStatusSnapshot,
|
|
4166
4226
|
snapshotTrackedMutations,
|
|
4227
|
+
remoteMutationSnapshot,
|
|
4228
|
+
remoteMutationEvidence,
|
|
4167
4229
|
collectTrackedMutationEvidence,
|
|
4168
4230
|
projectTimeoutRecovery,
|
|
4169
4231
|
formatTimeoutRecoveryLines,
|
|
@@ -4173,6 +4235,7 @@ export {
|
|
|
4173
4235
|
formatWorkflowChecklistPhase,
|
|
4174
4236
|
formatWorkflowChecklistBottleneck,
|
|
4175
4237
|
formatWorkflowChecklistText,
|
|
4238
|
+
summarizeAsyncStatus,
|
|
4176
4239
|
listAsyncRuns,
|
|
4177
4240
|
formatWorkflowStageLine,
|
|
4178
4241
|
formatAsyncRunOutputPath,
|
|
@@ -4182,6 +4245,9 @@ export {
|
|
|
4182
4245
|
utf8Tail,
|
|
4183
4246
|
withHandoffWriteLock,
|
|
4184
4247
|
withRepositoryWorktreeLock,
|
|
4248
|
+
readKeptBranches,
|
|
4249
|
+
formatParallelHandoffLines,
|
|
4250
|
+
parseKeptBranchLines,
|
|
4185
4251
|
readParallelHandoffManifest,
|
|
4186
4252
|
protectRetainedWorktreeForResume,
|
|
4187
4253
|
resolveRetainedWorktreeCwd,
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
validateCodeOwnedProfileRunner,
|
|
9
9
|
validatePermissionRules,
|
|
10
10
|
validateToolBudgetConfig
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-LWH7IGI3.js";
|
|
12
12
|
|
|
13
13
|
// src/agents/runtime-agent-registry.ts
|
|
14
14
|
var RUNTIME_AGENT_REGISTRY_KEY = "pi-subagents.runtime-agents.v1";
|