pi-subagents 0.88.1 → 0.89.0
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 +36 -1
- package/bundle/agents.js +3 -3
- package/bundle/child-tool-plan.js +2 -2
- package/bundle/{chunk-VTUUOLM4.js → chunk-2I6YN6ET.js} +34 -5
- package/bundle/{chunk-7OX6O7DQ.js → chunk-443LPCRI.js} +5 -5
- package/bundle/{chunk-4QFZZV3O.js → chunk-4AL6LDBY.js} +3 -1
- package/bundle/{chunk-6CG2VAG4.js → chunk-4ALRHKGE.js} +1 -1
- package/bundle/{chunk-4ZQBZDF3.js → chunk-6JD4XCA4.js} +76 -18
- package/bundle/{chunk-LV3CPYXJ.js → chunk-7W2IQFP4.js} +4 -4
- package/bundle/{chunk-W6HIYD2Z.js → chunk-A3INCQ6Z.js} +1 -1
- package/bundle/{chunk-FLNDHNPE.js → chunk-AZW4HXNU.js} +21 -21
- package/bundle/{chunk-ZJ2BT5TI.js → chunk-CHEABMO2.js} +56 -34
- package/bundle/{chunk-CYKNHFXB.js → chunk-EPMRDKQT.js} +1 -1
- package/bundle/{chunk-RMZAAXIR.js → chunk-ETDE2VYK.js} +2 -2
- package/bundle/{chunk-4MVDMA5C.js → chunk-GHJ6BH5U.js} +13 -7
- package/bundle/{chunk-PYKBTBY6.js → chunk-HSHLPYCQ.js} +9 -9
- package/bundle/{chunk-D32H53HM.js → chunk-HZDLR73C.js} +1 -1
- package/bundle/{chunk-2DIEL4WG.js → chunk-JFACGAJT.js} +2 -2
- package/bundle/{chunk-L4YY2TOE.js → chunk-JRO2CU4D.js} +1 -1
- package/bundle/{chunk-KXW62VBU.js → chunk-KOLLMZ2X.js} +1 -1
- package/bundle/{chunk-47ZN7NKR.js → chunk-NONHDYXE.js} +1 -1
- package/bundle/{chunk-DSHQWGHO.js → chunk-NQ26PJSQ.js} +96 -96
- package/bundle/{chunk-6OWNDN7R.js → chunk-PPPAEFRA.js} +2 -2
- package/bundle/{chunk-YDZ7BZD5.js → chunk-S77ZKDLS.js} +1 -1
- package/bundle/{chunk-CPSUJHZE.js → chunk-SLLZJ5EC.js} +39 -10
- package/bundle/{chunk-N6TAAIB3.js → chunk-TGABNSG5.js} +5 -5
- package/bundle/{chunk-XIA5GSEU.js → chunk-UQT2EQ4U.js} +2 -2
- package/bundle/{chunk-5EMPFFO4.js → chunk-WW6GQBBS.js} +4 -4
- package/bundle/{chunk-PCZEQQAQ.js → chunk-X5ZOTDHO.js} +26 -15
- package/bundle/{chunk-YQSTGPEU.js → chunk-YX7R55CR.js} +74 -31
- package/bundle/{chunk-GDR2ILWY.js → chunk-ZSCIHMUI.js} +50 -22
- 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 +1 -1
- package/src/extension/herdr-pi-bridge.js +78 -22
- 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/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 +47 -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 +33 -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/workflows/workflow-child-summary.d.ts +2 -1
- package/src/workflows/workflow-child-summary.js +14 -6
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
} from "./chunk-7J4ZXMY7.js";
|
|
4
4
|
import {
|
|
5
5
|
getProjectSubagentsDir
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-S77ZKDLS.js";
|
|
7
7
|
import {
|
|
8
8
|
getPiSpawnCommand,
|
|
9
9
|
writeAtomicJson
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-GHJ6BH5U.js";
|
|
11
11
|
|
|
12
12
|
// src/inspectors/herdr/project-panes.ts
|
|
13
13
|
import * as fs from "node:fs";
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
validateCodeOwnedProfileRunner,
|
|
9
9
|
validatePermissionRules,
|
|
10
10
|
validateToolBudgetConfig
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-GHJ6BH5U.js";
|
|
12
12
|
|
|
13
13
|
// src/agents/runtime-agent-registry.ts
|
|
14
14
|
var RUNTIME_AGENT_REGISTRY_KEY = "pi-subagents.runtime-agents.v1";
|
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PLACED_RESTORE_UNSUPPORTED,
|
|
3
|
+
SocketRpcClient,
|
|
3
4
|
connectHerdrMachine,
|
|
4
|
-
|
|
5
|
+
herdrLocalEnv,
|
|
6
|
+
parseHerdrEndpoint,
|
|
5
7
|
runBoundedCommand,
|
|
8
|
+
shellScriptCommand,
|
|
6
9
|
sshMachineAccess
|
|
7
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-ZSCIHMUI.js";
|
|
8
11
|
import {
|
|
9
12
|
package_default
|
|
10
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-4ALRHKGE.js";
|
|
11
14
|
import {
|
|
12
15
|
ensureSupervisorChannelDir
|
|
13
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-EPMRDKQT.js";
|
|
14
17
|
import "./chunk-HXRB42AF.js";
|
|
15
18
|
import "./chunk-NIXWDZZV.js";
|
|
16
19
|
import {
|
|
20
|
+
HERDR_PI_MAX_ACCEPTANCE_PROMPT_BYTES,
|
|
17
21
|
HERDR_PI_MODE_ENV,
|
|
18
22
|
HERDR_PI_PROTOCOL,
|
|
19
23
|
HERDR_PI_RUNTIME_DIR_ENV,
|
|
@@ -21,20 +25,21 @@ import {
|
|
|
21
25
|
HerdrPiFrameDecoder,
|
|
22
26
|
encodeHerdrPiFrame,
|
|
23
27
|
validateHerdrPiRunId
|
|
24
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-4AL6LDBY.js";
|
|
25
29
|
import {
|
|
26
30
|
REX_BUNDLE_BIN,
|
|
27
31
|
REX_CALL_TIMEOUT_MS,
|
|
28
32
|
REX_EXIT_GONE,
|
|
29
33
|
REX_EXIT_UNREACHABLE,
|
|
30
34
|
REX_MAX_OUTPUT,
|
|
35
|
+
editsLocalDisk,
|
|
31
36
|
getAgentDir,
|
|
32
37
|
getPiSpawnCommand,
|
|
33
38
|
isRexLocalMachine,
|
|
34
39
|
resolveRexBinary,
|
|
35
40
|
rexCommandEnv,
|
|
36
41
|
rexGlobalArgs
|
|
37
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-GHJ6BH5U.js";
|
|
38
43
|
import "./chunk-JEZOSEWG.js";
|
|
39
44
|
import "./chunk-YFCK7H2S.js";
|
|
40
45
|
import "./chunk-QXASAHIA.js";
|
|
@@ -46,14 +51,48 @@ import * as net from "node:net";
|
|
|
46
51
|
import * as path5 from "node:path";
|
|
47
52
|
|
|
48
53
|
// src/runs/shared/herdr-pane-host.ts
|
|
49
|
-
import { createHash as
|
|
54
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
55
|
+
|
|
56
|
+
// src/runs/shared/local-machine-access.ts
|
|
57
|
+
import { spawnSync } from "node:child_process";
|
|
58
|
+
import * as path from "node:path";
|
|
59
|
+
var DEFAULT_TIMEOUT_MS = 15e3;
|
|
60
|
+
var DEFAULT_MAX_BUFFER = 256 * 1024;
|
|
61
|
+
function localSockets() {
|
|
62
|
+
return {
|
|
63
|
+
async forwardRemoteSocket(socketPath) {
|
|
64
|
+
if (!path.isAbsolute(socketPath)) throw new Error("Local socket path must be absolute.");
|
|
65
|
+
return { socketPath, async close() {
|
|
66
|
+
} };
|
|
67
|
+
},
|
|
68
|
+
async close() {
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function localMachineAccess(options = {}) {
|
|
73
|
+
const env = options.env ?? process.env;
|
|
74
|
+
return {
|
|
75
|
+
shellCommand: shellScriptCommand,
|
|
76
|
+
run(command, limits = {}) {
|
|
77
|
+
const spawned = spawnSync("/bin/sh", ["-c", command], { encoding: "utf8", env, timeout: limits.timeout ?? DEFAULT_TIMEOUT_MS, maxBuffer: limits.maxBuffer ?? DEFAULT_MAX_BUFFER, windowsHide: true });
|
|
78
|
+
const result = { status: spawned.status, stdout: spawned.stdout ?? "", stderr: spawned.stderr ?? "" };
|
|
79
|
+
if (spawned.error) result.error = spawned.error;
|
|
80
|
+
return result;
|
|
81
|
+
},
|
|
82
|
+
runAsync: (command, limits = {}) => runBoundedCommand("/bin/sh", ["-c", command], { env, ...limits }),
|
|
83
|
+
openSockets: localSockets
|
|
84
|
+
};
|
|
85
|
+
}
|
|
50
86
|
|
|
51
87
|
// src/runs/shared/placed-run-owner.ts
|
|
88
|
+
import { createHash } from "node:crypto";
|
|
52
89
|
import * as fs from "node:fs";
|
|
53
|
-
import * as
|
|
90
|
+
import * as path2 from "node:path";
|
|
54
91
|
var PLACED_MANIFEST_READ_SCRIPT = 'p="$1/manifest.json"; test -f "$p" && test ! -L "$p" && cat "$p"';
|
|
55
|
-
|
|
56
|
-
|
|
92
|
+
var PLACED_MANIFEST_DEADLINE_MS = 3e4;
|
|
93
|
+
async function discoverPlacedBridgeManifest(access, runId, runtimeDir, missing = "The placed Pi's pi-subagents bridge manifest is not in its runtime directory; the Pi may have exited.", deadlineMs = PLACED_MANIFEST_DEADLINE_MS) {
|
|
94
|
+
const deadline = Date.now() + deadlineMs;
|
|
95
|
+
for (; ; ) {
|
|
57
96
|
const result = await access.runAsync(access.shellCommand(PLACED_MANIFEST_READ_SCRIPT, [runtimeDir]), { timeout: 5e3, maxBuffer: 64 * 1024 });
|
|
58
97
|
if (result.error) throw new Error(`Remote bridge manifest discovery failed: ${result.error.message}`, { cause: result.error });
|
|
59
98
|
if (result.status === 0 && result.stdout.trim()) {
|
|
@@ -64,22 +103,25 @@ async function discoverPlacedBridgeManifest(access, runId, runtimeDir, missing =
|
|
|
64
103
|
throw new Error("Remote bridge manifest is malformed.");
|
|
65
104
|
}
|
|
66
105
|
const p = value;
|
|
67
|
-
if (p.runId !== runId || typeof p.socketPath !== "string" ||
|
|
106
|
+
if (p.runId !== runId || typeof p.socketPath !== "string" || path2.posix.dirname(p.socketPath) !== runtimeDir || typeof p.nativeSessionId !== "string" || typeof p.packageVersion !== "string" || typeof p.protocol !== "number") throw new Error("Remote bridge manifest identity is incomplete or outside its owned runtime directory.");
|
|
68
107
|
return { socketPath: p.socketPath, nativeSessionId: p.nativeSessionId, packageVersion: p.packageVersion, protocol: p.protocol };
|
|
69
108
|
}
|
|
109
|
+
if (Date.now() >= deadline) throw new Error(missing);
|
|
70
110
|
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
71
111
|
}
|
|
72
|
-
|
|
112
|
+
}
|
|
113
|
+
function hashedRuntimeDirName(runId) {
|
|
114
|
+
return createHash("sha256").update(runId).digest("hex").slice(0, 12);
|
|
73
115
|
}
|
|
74
116
|
async function createPlacedRuntimeDir(access, runId) {
|
|
75
117
|
const result = await access.runAsync(access.shellCommand('umask 077; mktemp -d "${TMPDIR:-/tmp}/pi-subagents-herdr-$1-XXXXXXXX"', [runId]), { timeout: 1e4, maxBuffer: 4096 });
|
|
76
118
|
if (result.error) throw new Error(`Could not provision a run-private remote bridge runtime directory: ${result.error.message}`, { cause: result.error });
|
|
77
119
|
const value = result.stdout.trim();
|
|
78
|
-
if (result.status !== 0 || !
|
|
120
|
+
if (result.status !== 0 || !path2.posix.isAbsolute(value) || value.includes("\n")) throw new Error("Could not provision a run-private remote bridge runtime directory.");
|
|
79
121
|
return value;
|
|
80
122
|
}
|
|
81
123
|
function removePlacedRuntimeDir(access, runtimeDir) {
|
|
82
|
-
const result = access.run(access.shellCommand('p=$1; case "${p##*/}" in pi-subagents-herdr-*) test -d "$p" && test ! -L "$p"
|
|
124
|
+
const result = access.run(access.shellCommand('p=$1; case "${p##*/}" in pi-subagents-herdr-*) if test -d "$p" && test ! -L "$p"; then rm -rf -- "$p"; fi; test ! -e "$p" && test ! -L "$p";; *) exit 64;; esac', [runtimeDir]), { timeout: 1e4, maxBuffer: 4096 });
|
|
83
125
|
if (result.status !== 0 || result.stdout) throw new Error(`Could not remove the exact owned remote runtime directory: ${String(result.stderr).slice(0, 512)}`);
|
|
84
126
|
}
|
|
85
127
|
var PlacedRunOwner = class {
|
|
@@ -98,13 +140,11 @@ var PlacedRunOwner = class {
|
|
|
98
140
|
};
|
|
99
141
|
#snapshot = { connection: "connected", state: "ready", revision: 0 };
|
|
100
142
|
#cleanupPromise;
|
|
101
|
-
|
|
102
|
-
constructor(machine, runId, runtimeDir, connection, host, access, removeRuntime = () => removePlacedRuntimeDir(access, runtimeDir)) {
|
|
143
|
+
constructor(machine, runId, runtimeDir, connection, host, access) {
|
|
103
144
|
this.machine = machine;
|
|
104
145
|
this.runId = runId;
|
|
105
146
|
this.runtimeDir = runtimeDir;
|
|
106
147
|
this.connection = connection;
|
|
107
|
-
this.#removeRuntime = removeRuntime;
|
|
108
148
|
this.host = host;
|
|
109
149
|
this.access = access;
|
|
110
150
|
}
|
|
@@ -153,9 +193,9 @@ var PlacedRunOwner = class {
|
|
|
153
193
|
journal(identity) {
|
|
154
194
|
this.identity = identity;
|
|
155
195
|
this.#snapshot = { ...this.#snapshot, identity };
|
|
156
|
-
const journalDir =
|
|
196
|
+
const journalDir = path2.join(getAgentDir(), "pi-subagents", "herdr-run-journal");
|
|
157
197
|
fs.mkdirSync(journalDir, { recursive: true, mode: 448 });
|
|
158
|
-
fs.writeFileSync(
|
|
198
|
+
fs.writeFileSync(path2.join(journalDir, `${this.runId}.json`), JSON.stringify({ version: 1, identity, state: "ready", updatedAt: Date.now() }), { mode: 384, flag: "wx" });
|
|
159
199
|
}
|
|
160
200
|
get snapshot() {
|
|
161
201
|
return this.#snapshot;
|
|
@@ -185,7 +225,7 @@ var PlacedRunOwner = class {
|
|
|
185
225
|
try {
|
|
186
226
|
this.#unsubscribe();
|
|
187
227
|
await this.connection.close();
|
|
188
|
-
this
|
|
228
|
+
removePlacedRuntimeDir(this.access, this.runtimeDir);
|
|
189
229
|
} catch (error) {
|
|
190
230
|
failure ??= error;
|
|
191
231
|
}
|
|
@@ -195,9 +235,9 @@ var PlacedRunOwner = class {
|
|
|
195
235
|
};
|
|
196
236
|
|
|
197
237
|
// src/runs/shared/placement-host.ts
|
|
198
|
-
import { createHash, randomBytes } from "node:crypto";
|
|
238
|
+
import { createHash as createHash2, randomBytes } from "node:crypto";
|
|
199
239
|
import * as fs2 from "node:fs";
|
|
200
|
-
import * as
|
|
240
|
+
import * as path3 from "node:path";
|
|
201
241
|
var HERDR_ALLOCATION_LOCK_TIMEOUT_MS = 1e4;
|
|
202
242
|
var HERDR_ALLOCATION_LOCK_POLL_MS = 25;
|
|
203
243
|
function herdrPaneAllocationKey(target, session, cwd) {
|
|
@@ -208,7 +248,7 @@ function assertPrivateDir(directory) {
|
|
|
208
248
|
if (!stat.isDirectory() || stat.isSymbolicLink() || (stat.mode & 511) !== 448 || typeof process.getuid === "function" && stat.uid !== process.getuid()) throw new Error("Herdr allocation path is not a mode-0700 agent-private owned directory.");
|
|
209
249
|
}
|
|
210
250
|
function ensurePrivateChild(parent, name) {
|
|
211
|
-
const directory =
|
|
251
|
+
const directory = path3.join(parent, name);
|
|
212
252
|
try {
|
|
213
253
|
fs2.mkdirSync(directory, { mode: 448 });
|
|
214
254
|
} catch (error) {
|
|
@@ -248,7 +288,7 @@ function sameOwner(left, right) {
|
|
|
248
288
|
return left.token === right.token && left.dev === right.dev && left.ino === right.ino;
|
|
249
289
|
}
|
|
250
290
|
async function withHerdrPaneAllocationLock(key, action, options = {}) {
|
|
251
|
-
const root = allocationLockRoot(), digest =
|
|
291
|
+
const root = allocationLockRoot(), digest = createHash2("sha256").update(key).digest("hex"), lockPath = path3.join(root, `${digest}.lock`), recoveryPath = path3.join(root, `${digest}.recovery`), token = randomBytes(16).toString("hex"), tempPath = path3.join(root, `.${digest}.${token}.tmp`), deadline = Date.now() + (options.timeoutMs ?? HERDR_ALLOCATION_LOCK_TIMEOUT_MS);
|
|
252
292
|
let published;
|
|
253
293
|
try {
|
|
254
294
|
fs2.writeFileSync(tempPath, JSON.stringify({ pid: process.pid, token, createdAt: Date.now() }), { mode: 384, flag: "wx" });
|
|
@@ -394,7 +434,7 @@ async function provisionHerdrPane(client, cwd, runId, runtimeDir, environment, a
|
|
|
394
434
|
return withHerdrPaneAllocationLock(allocationKey, async () => {
|
|
395
435
|
const snapshot = parseHerdrSessionSnapshot(await client.call("session.snapshot"));
|
|
396
436
|
const panes = list(snapshot, "panes").filter((item) => Boolean(item && typeof item === "object")), workspaces = list(snapshot, "workspaces").filter((item) => Boolean(item && typeof item === "object"));
|
|
397
|
-
const ownedLabel = `pi-subagents-${
|
|
437
|
+
const ownedLabel = `pi-subagents-${createHash3("sha256").update(cwd).digest("hex").slice(0, 10)}`, owned = workspaces.filter((item) => item.label === ownedLabel);
|
|
398
438
|
if (owned.length > 1) throw new Error("Herdr deterministic owned workspace identity is ambiguous.");
|
|
399
439
|
const cwdWorkspaceIds = new Set(panes.filter((item) => item.cwd === cwd || item.foreground_cwd === cwd).map((item) => item.workspace_id).filter((id) => typeof id === "string")), cwdWorkspaces = workspaces.filter((item) => typeof item.workspace_id === "string" && cwdWorkspaceIds.has(item.workspace_id));
|
|
400
440
|
const selected = owned[0] ?? (cwdWorkspaces.length === 1 ? cwdWorkspaces[0] : void 0), selectedId = selected ? idOf(selected, "workspace_id") : void 0, actual = selectedId ? panes.filter((pane) => pane.workspace_id === selectedId).length : 0;
|
|
@@ -409,12 +449,23 @@ async function provisionHerdrPane(client, cwd, runId, runtimeDir, environment, a
|
|
|
409
449
|
});
|
|
410
450
|
}
|
|
411
451
|
function provisionHerdrOwnedPane(connection, machine, runId, runtimeDir, environment) {
|
|
412
|
-
return provisionHerdrPane(connection.client, machine.cwd, runId, runtimeDir, environment, herdrPaneAllocationKey(machine.target, connection.endpoint.session, machine.cwd));
|
|
452
|
+
return provisionHerdrPane(connection.client, machine.cwd, runId, runtimeDir, environment, "target" in machine ? herdrPaneAllocationKey(machine.target, connection.endpoint.session, machine.cwd) : JSON.stringify(["local", machine.socket, connection.endpoint.session, machine.cwd]));
|
|
413
453
|
}
|
|
414
454
|
function asHerdrMachine(machine) {
|
|
415
|
-
if (machine.provider !== "herdr") throw new Error("The Herdr pane host only places runs on Herdr
|
|
455
|
+
if (machine.provider !== "herdr") throw new Error("The Herdr pane host only places runs on Herdr machines.");
|
|
416
456
|
return machine;
|
|
417
457
|
}
|
|
458
|
+
async function connectLocalHerdrMachine(machine) {
|
|
459
|
+
const result = await runBoundedCommand(process.env.HERDR_BIN ?? "herdr", ["status", "server", "--json"], { env: herdrLocalEnv(machine.socket, machine.session, process.env), timeout: 15e3 });
|
|
460
|
+
if (result.error) throw new Error(`Local Herdr discovery failed: ${result.error.message}`, { cause: result.error });
|
|
461
|
+
if (result.status !== 0) throw new Error(`Local Herdr discovery failed with code ${result.status}: ${(result.stderr || result.stdout).trim().slice(0, 512)}`);
|
|
462
|
+
const endpoint = parseHerdrEndpoint(result.stdout, machine.session);
|
|
463
|
+
if (endpoint.socket !== machine.socket) throw new Error(`Local Herdr server identity mismatch: expected socket ${machine.socket}, received ${endpoint.socket}.`);
|
|
464
|
+
return { endpoint, socketPath: machine.socket, client: new SocketRpcClient(machine.socket), ...localMachineAccess().openSockets() };
|
|
465
|
+
}
|
|
466
|
+
function herdrAccess(machine) {
|
|
467
|
+
return "target" in machine ? sshMachineAccess(machine) : localMachineAccess({ env: { ...process.env, TMPDIR: "/tmp" } });
|
|
468
|
+
}
|
|
418
469
|
async function startHerdrAgent(connection, owned, kind, name, args, options = {}) {
|
|
419
470
|
const clock = options.clock ?? { now: () => Date.now(), wait: (ms) => new Promise((resolve) => setTimeout(resolve, ms)) }, deadline = clock.now() + (options.timeoutMs ?? 5e3), pollMs = options.pollMs ?? 50;
|
|
420
471
|
let response;
|
|
@@ -453,7 +504,8 @@ async function closeOwnedHerdrPane(connection, owned, terminalId, agentName) {
|
|
|
453
504
|
}
|
|
454
505
|
var herdrPaneHost = {
|
|
455
506
|
connect(machine) {
|
|
456
|
-
|
|
507
|
+
const herdr = asHerdrMachine(machine);
|
|
508
|
+
return "target" in herdr ? connectHerdrMachine(herdr) : connectLocalHerdrMachine(herdr);
|
|
457
509
|
},
|
|
458
510
|
sessionOf(connection) {
|
|
459
511
|
return connection.endpoint.session;
|
|
@@ -490,22 +542,16 @@ var herdrPaneHost = {
|
|
|
490
542
|
reconcile: reconcileHerdrPlacedRun,
|
|
491
543
|
closeOwnedPane: closeOwnedHerdrPane
|
|
492
544
|
};
|
|
493
|
-
function createRemoteRuntimeDir(machine, runId, options = {}) {
|
|
494
|
-
return createPlacedRuntimeDir(sshMachineAccess(machine, options), runId);
|
|
495
|
-
}
|
|
496
|
-
function removeRemoteRuntimeDir(machine, runtimeDir, options = {}) {
|
|
497
|
-
removePlacedRuntimeDir(sshMachineAccess(machine, options), runtimeDir);
|
|
498
|
-
}
|
|
499
545
|
var HerdrPlacedRunOwner = class _HerdrPlacedRunOwner extends PlacedRunOwner {
|
|
500
|
-
constructor(machine, runId, runtimeDir, connection,
|
|
501
|
-
super(machine, runId, runtimeDir, connection, herdrPaneHost,
|
|
546
|
+
constructor(machine, runId, runtimeDir, connection, access) {
|
|
547
|
+
super(machine, runId, runtimeDir, connection, herdrPaneHost, access);
|
|
502
548
|
}
|
|
503
549
|
static async create(machine, runId, beforePane) {
|
|
504
|
-
const runtimeDir = await
|
|
550
|
+
const access = herdrAccess(machine), runtimeDir = await createPlacedRuntimeDir(access, "target" in machine ? runId : hashedRuntimeDirName(runId));
|
|
505
551
|
let connection;
|
|
506
552
|
try {
|
|
507
553
|
connection = await herdrPaneHost.connect(machine);
|
|
508
|
-
const owner = new _HerdrPlacedRunOwner(machine, runId, runtimeDir, connection);
|
|
554
|
+
const owner = new _HerdrPlacedRunOwner(machine, runId, runtimeDir, connection, access);
|
|
509
555
|
await beforePane?.(owner);
|
|
510
556
|
return owner;
|
|
511
557
|
} catch (error) {
|
|
@@ -516,7 +562,7 @@ var HerdrPlacedRunOwner = class _HerdrPlacedRunOwner extends PlacedRunOwner {
|
|
|
516
562
|
cleanupErrors.push(cleanupError);
|
|
517
563
|
}
|
|
518
564
|
try {
|
|
519
|
-
|
|
565
|
+
removePlacedRuntimeDir(access, runtimeDir);
|
|
520
566
|
} catch (cleanupError) {
|
|
521
567
|
cleanupErrors.push(cleanupError);
|
|
522
568
|
}
|
|
@@ -539,43 +585,9 @@ var HerdrPlacedRunOwner = class _HerdrPlacedRunOwner extends PlacedRunOwner {
|
|
|
539
585
|
};
|
|
540
586
|
|
|
541
587
|
// src/runs/shared/rex-pane-host.ts
|
|
542
|
-
import { createHash as createHash3 } from "node:crypto";
|
|
543
588
|
import * as path4 from "node:path";
|
|
544
589
|
import { Type } from "typebox";
|
|
545
590
|
import { Compile } from "typebox/compile";
|
|
546
|
-
|
|
547
|
-
// src/runs/shared/local-machine-access.ts
|
|
548
|
-
import { spawnSync } from "node:child_process";
|
|
549
|
-
import * as path3 from "node:path";
|
|
550
|
-
var DEFAULT_TIMEOUT_MS = 15e3;
|
|
551
|
-
var DEFAULT_MAX_BUFFER = 256 * 1024;
|
|
552
|
-
function localSockets() {
|
|
553
|
-
return {
|
|
554
|
-
async forwardRemoteSocket(socketPath) {
|
|
555
|
-
if (!path3.isAbsolute(socketPath)) throw new Error("Local socket path must be absolute.");
|
|
556
|
-
return { socketPath, async close() {
|
|
557
|
-
} };
|
|
558
|
-
},
|
|
559
|
-
async close() {
|
|
560
|
-
}
|
|
561
|
-
};
|
|
562
|
-
}
|
|
563
|
-
function localMachineAccess(options = {}) {
|
|
564
|
-
const env = options.env ?? process.env;
|
|
565
|
-
return {
|
|
566
|
-
shellCommand: remoteShellCommand,
|
|
567
|
-
run(command, limits = {}) {
|
|
568
|
-
const spawned = spawnSync("/bin/sh", ["-c", command], { encoding: "utf8", env, timeout: limits.timeout ?? DEFAULT_TIMEOUT_MS, maxBuffer: limits.maxBuffer ?? DEFAULT_MAX_BUFFER, windowsHide: true });
|
|
569
|
-
const result = { status: spawned.status, stdout: spawned.stdout ?? "", stderr: spawned.stderr ?? "" };
|
|
570
|
-
if (spawned.error) result.error = spawned.error;
|
|
571
|
-
return result;
|
|
572
|
-
},
|
|
573
|
-
runAsync: (command, limits = {}) => runBoundedCommand("/bin/sh", ["-c", command], { env, ...limits }),
|
|
574
|
-
openSockets: localSockets
|
|
575
|
-
};
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
// src/runs/shared/rex-pane-host.ts
|
|
579
591
|
var REX_CLOSE_POLLS = 20;
|
|
580
592
|
var REX_CLOSE_POLL_MS = 50;
|
|
581
593
|
var REX_SSH_SESSION_LABEL = "subagents";
|
|
@@ -589,7 +601,7 @@ function rexAccess() {
|
|
|
589
601
|
return localMachineAccess({ env: { ...rexCommandEnv(), TMPDIR: "/tmp" } });
|
|
590
602
|
}
|
|
591
603
|
function rexSshAccess(machine, access = sshMachineAccess(machine)) {
|
|
592
|
-
return { ...access, shellCommand: (script, args) =>
|
|
604
|
+
return { ...access, shellCommand: (script, args) => access.shellCommand(`TMPDIR=/tmp; export TMPDIR; ${script}`, args) };
|
|
593
605
|
}
|
|
594
606
|
function asRexMachine(machine) {
|
|
595
607
|
if (machine.provider !== "rex") throw new Error("The Rex pane host only places runs on Rex machines.");
|
|
@@ -775,33 +787,20 @@ var rexPaneHost = {
|
|
|
775
787
|
reconcile: reconcileRexPlacedRun,
|
|
776
788
|
closeOwnedPane: closeOwnedRexPane
|
|
777
789
|
};
|
|
778
|
-
function runtimeDirPresent(access, runtimeDir) {
|
|
779
|
-
const result = access.run(access.shellCommand('test -e "$1" || test -L "$1"', [runtimeDir]), { timeout: 1e4, maxBuffer: 4096 });
|
|
780
|
-
if (result.error) throw new Error(`Could not check the owned runtime directory: ${result.error.message}`, { cause: result.error });
|
|
781
|
-
return result.status === 0;
|
|
782
|
-
}
|
|
783
|
-
function removeRexRuntimeDir(access, runtimeDir) {
|
|
784
|
-
if (!runtimeDirPresent(access, runtimeDir)) return;
|
|
785
|
-
try {
|
|
786
|
-
removePlacedRuntimeDir(access, runtimeDir);
|
|
787
|
-
} catch (error) {
|
|
788
|
-
if (runtimeDirPresent(access, runtimeDir)) throw error;
|
|
789
|
-
}
|
|
790
|
-
}
|
|
791
790
|
var RexPlacedRunOwner = class _RexPlacedRunOwner extends PlacedRunOwner {
|
|
792
791
|
constructor(machine, runId, runtimeDir, connection, access, host) {
|
|
793
|
-
super(machine, runId, runtimeDir, connection, host, access
|
|
792
|
+
super(machine, runId, runtimeDir, connection, host, access);
|
|
794
793
|
}
|
|
795
794
|
/** A Rex SSH owner's machine carries the resolved remote cwd, and its host reconnects only to the session recorded here. */
|
|
796
795
|
static async create(machine, runId, options = {}) {
|
|
797
|
-
const hash =
|
|
796
|
+
const hash = hashedRuntimeDirName(runId);
|
|
798
797
|
if (isRexLocalMachine(machine)) {
|
|
799
798
|
const access2 = rexAccess(), runtimeDir2 = await createPlacedRuntimeDir(access2, hash);
|
|
800
799
|
try {
|
|
801
800
|
return new _RexPlacedRunOwner(machine, runId, runtimeDir2, await connectRex(machine, { access: access2 }), access2, rexPaneHost);
|
|
802
801
|
} catch (error) {
|
|
803
802
|
try {
|
|
804
|
-
|
|
803
|
+
removePlacedRuntimeDir(access2, runtimeDir2);
|
|
805
804
|
} catch (cleanupError) {
|
|
806
805
|
throw new AggregateError([error, cleanupError], "Rex owner creation failed and runtime cleanup also failed.", { cause: error });
|
|
807
806
|
}
|
|
@@ -817,7 +816,7 @@ var RexPlacedRunOwner = class _RexPlacedRunOwner extends PlacedRunOwner {
|
|
|
817
816
|
return new _RexPlacedRunOwner(placed, runId, runtimeDir, await host.connect(placed), access, host);
|
|
818
817
|
} catch (error) {
|
|
819
818
|
try {
|
|
820
|
-
|
|
819
|
+
removePlacedRuntimeDir(access, runtimeDir);
|
|
821
820
|
} catch (cleanupError) {
|
|
822
821
|
throw new AggregateError([error, cleanupError], "Rex owner creation failed and runtime cleanup also failed.", { cause: error });
|
|
823
822
|
}
|
|
@@ -860,14 +859,15 @@ function serializeHerdrPiLaunch(launch) {
|
|
|
860
859
|
if (launch.extensionPaths.length || launch.requiredExtensions?.length) throw new Error("Pane-native remote Pi cannot transfer local extension paths; install/configure pi-subagents on the remote machine.");
|
|
861
860
|
if (launch.processEnv && Object.values(launch.processEnv).some((value) => value !== void 0 && value !== "__none__")) throw new Error("Pane-native remote Pi cannot transfer local bindings, MCP selections, or process environment.");
|
|
862
861
|
if (launch.runtime.nestedRoute || launch.runtime.fanoutChild || launch.runtime.depth > 1) throw new Error("Nested delegation from a pane-native remote Pi is not supported.");
|
|
863
|
-
if (launch.excludeTools?.length || launch.runtime.permissions || launch.runtime.toolBudget || launch.runtime.requiredExtensions || launch.runtime.mcpDirectTools?.length) throw new Error("Pane-native remote Pi cannot yet represent exclusions, permission rules, tool budgets, MCP direct tools,
|
|
862
|
+
if (launch.excludeTools?.length || launch.runtime.permissions || launch.runtime.toolBudget || launch.runtime.requiredExtensions || launch.runtime.mcpDirectTools?.length || launch.runtime.structuredOutput) throw new Error("Pane-native remote Pi cannot yet represent exclusions, permission rules, tool budgets, MCP direct tools, required-extension contracts, or outputSchema; remove machine placement.");
|
|
864
863
|
const resources = launch.remoteResources;
|
|
865
864
|
if (!resources || !/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/u.test(resources.agent) || resources.skills?.some((name) => !/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/u.test(name)) || resources.toolCeiling?.some((name) => !/^[A-Za-z0-9_-]{1,64}$/u.test(name)) || resources.reads !== void 0 && resources.reads !== false && resources.reads.some((read) => typeof read !== "string" || Buffer.byteLength(read) > 4096)) throw new Error("Pane-native remote resources require bounded logical agent, skill, tool, and read names.");
|
|
865
|
+
if (resources.acceptancePrompt !== void 0 && Buffer.byteLength(resources.acceptancePrompt) > HERDR_PI_MAX_ACCEPTANCE_PROMPT_BYTES) throw new Error(`A placed Pi child's acceptance instructions exceed ${HERDR_PI_MAX_ACCEPTANCE_PROMPT_BYTES} bytes; shorten the acceptance criteria or remove machine placement.`);
|
|
866
866
|
const args = [];
|
|
867
867
|
if (launch.noSkills) args.push("--no-skills", "--no-prompt-templates");
|
|
868
868
|
if (launch.noContextFiles) args.push("--no-context-files");
|
|
869
869
|
if (launch.model) args.push("--model", launch.model);
|
|
870
|
-
return { args, resources: { agent: resources.agent, ...resources.skills ? { skills: [...resources.skills] } : {}, ...resources.toolCeiling ? { toolCeiling: [...resources.toolCeiling] } : {}, ...resources.reads !== void 0 ? { reads: resources.reads === false ? false : [...resources.reads] } : {} } };
|
|
870
|
+
return { args, resources: { agent: resources.agent, ...resources.skills ? { skills: [...resources.skills] } : {}, ...resources.toolCeiling ? { toolCeiling: [...resources.toolCeiling] } : {}, ...resources.reads !== void 0 ? { reads: resources.reads === false ? false : [...resources.reads] } : {}, ...resources.acceptancePrompt ? { acceptancePrompt: resources.acceptancePrompt } : {} } };
|
|
871
871
|
}
|
|
872
872
|
var BridgeChannel = class {
|
|
873
873
|
socket;
|
|
@@ -1259,8 +1259,8 @@ async function reconnectHerdrPiSession(session, launch, dependencies = {}) {
|
|
|
1259
1259
|
await session.replaceTransport({ ...validated, paneId: result.paneId, cursor: result.cursor, state: result.state });
|
|
1260
1260
|
}
|
|
1261
1261
|
async function createHerdrPiSession(launch) {
|
|
1262
|
-
if (!launch.machine) throw new Error("Pane-native Pi launch requires a
|
|
1263
|
-
if (launch.machine.provider !== "herdr") throw new Error("Herdr pane-native Pi launch requires a Herdr
|
|
1262
|
+
if (!launch.machine) throw new Error("Pane-native Pi launch requires a machine.");
|
|
1263
|
+
if (launch.machine.provider !== "herdr") throw new Error("Herdr pane-native Pi launch requires a Herdr machine.");
|
|
1264
1264
|
const policy = serializeHerdrPiLaunch(launch);
|
|
1265
1265
|
const runId = safeRunId(launch.runtime.runId);
|
|
1266
1266
|
return startPlacedPiSession(launch, await HerdrPlacedRunOwner.create(launch.machine, runId), policy);
|
|
@@ -1290,7 +1290,7 @@ async function startPlacedPiSession(launch, owner, policy) {
|
|
|
1290
1290
|
const missingRequired = (launch.runtime.requiredTools ?? []).filter((tool) => !configured.tools.includes(tool));
|
|
1291
1291
|
if (missingRequired.length) throw new Error(`Remote Pi agent '${policy.resources.agent}' did not activate required tools: ${missingRequired.join(", ")}.`);
|
|
1292
1292
|
if (launch.model && configured.model !== launch.model.split(":")[0]) throw new Error(`Remote Pi model '${launch.model}' did not resolve to the requested provider/model.`);
|
|
1293
|
-
const identity = { runId, machineId: machine.id, target:
|
|
1293
|
+
const identity = { runId, machineId: machine.id, target: editsLocalDisk(machine) ? machine.id : machine.target, session: owner.host.sessionOf(connection), workspaceId: owned.workspaceId, tabId: owned.tabId, paneId: owned.paneId, terminalId, agentName, nativeSessionId: manifest.nativeSessionId, cwd: machine.cwd, runtimeDir };
|
|
1294
1294
|
owner.journal(identity);
|
|
1295
1295
|
const session = new HerdrPiSession(owner, bridgeForward, bridge, configured.tools, typeof ready.model === "string" ? ready.model : void 0, launch.runtime, ready.initialGit);
|
|
1296
1296
|
reconnectSession = session;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
appendAgentRefinementOverlay
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-UQT2EQ4U.js";
|
|
4
4
|
import {
|
|
5
5
|
buildAgentMemoryInjection,
|
|
6
6
|
buildSkillInjection
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-GHJ6BH5U.js";
|
|
8
8
|
|
|
9
9
|
// src/runs/shared/effective-system-prompt.ts
|
|
10
10
|
function appendSection(prompt, section) {
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
PROJECT_SUBAGENTS_RELATIVE_DIR,
|
|
6
6
|
canonicalSessionId,
|
|
7
7
|
inspectSessionLease
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-S77ZKDLS.js";
|
|
9
9
|
import {
|
|
10
10
|
DEFAULT_FILE_SYSTEM_RETRY_DELAYS_MS,
|
|
11
11
|
DEFAULT_GLOBAL_CONCURRENCY_LIMIT,
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
withFileLease,
|
|
28
28
|
writeAtomicJson,
|
|
29
29
|
writePrivateAtomicJson
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-GHJ6BH5U.js";
|
|
31
31
|
import {
|
|
32
32
|
DIRS,
|
|
33
33
|
SUBAGENT_LIFECYCLE_ARTIFACT_VERSION,
|
|
@@ -6451,8 +6451,13 @@ async function probeWorktreeSource(tx, cwd) {
|
|
|
6451
6451
|
if (repoCheck.status !== 0 || repoCheck.stdout.trim() !== "true") throw new Error("worktree isolation requires a git repository");
|
|
6452
6452
|
const toplevel = (await tx.gitChecked(cwd, ["rev-parse", "--show-toplevel"])).trim();
|
|
6453
6453
|
const status = await tx.gitChecked(toplevel, ["status", "--porcelain", "--", `:!${PROJECT_SUBAGENTS_RELATIVE_DIR}`]);
|
|
6454
|
-
|
|
6455
|
-
|
|
6454
|
+
const changes = status.split("\n").filter((line) => line.trim().length > 0);
|
|
6455
|
+
if (changes.length > 0) {
|
|
6456
|
+
const shown = changes.slice(0, 10).map((line) => ` ${line}`);
|
|
6457
|
+
if (changes.length > shown.length) shown.push(` \u2026 and ${changes.length - shown.length} more`);
|
|
6458
|
+
throw new Error(`worktree isolation requires a clean git working tree: ${toplevel} has ${changes.length} uncommitted change(s):
|
|
6459
|
+
${shown.join("\n")}
|
|
6460
|
+
Commit or stash them first.`);
|
|
6456
6461
|
}
|
|
6457
6462
|
return toplevel;
|
|
6458
6463
|
}
|
|
@@ -7103,6 +7108,7 @@ function cleanupSingleWorktree(setup, worktree, intent) {
|
|
|
7103
7108
|
const errors = [];
|
|
7104
7109
|
let worktreeRemoved = false;
|
|
7105
7110
|
let branchRemoved = false;
|
|
7111
|
+
let keptBranchTip;
|
|
7106
7112
|
if (intent.kind === "preserve" && intent.cleanupBlocker) {
|
|
7107
7113
|
return {
|
|
7108
7114
|
index: worktree.index,
|
|
@@ -7201,11 +7207,29 @@ function cleanupSingleWorktree(setup, worktree, intent) {
|
|
|
7201
7207
|
errors.push(`worktree removal failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
7202
7208
|
}
|
|
7203
7209
|
if (worktreeRemoved) {
|
|
7204
|
-
|
|
7205
|
-
|
|
7206
|
-
|
|
7207
|
-
|
|
7208
|
-
|
|
7210
|
+
let deleteBranch = true;
|
|
7211
|
+
if (intent.kind === "preserve") {
|
|
7212
|
+
try {
|
|
7213
|
+
const tip = runGitChecked(setup.cwd, ["rev-parse", "--verify", `refs/heads/${worktree.branch}^{commit}`]).trim();
|
|
7214
|
+
if (tip !== setup.baseCommit) {
|
|
7215
|
+
const containing = runGitChecked(setup.cwd, ["for-each-ref", "--contains", tip, "--format=%(refname)", "refs/heads", "refs/remotes", "refs/tags"]);
|
|
7216
|
+
if (!containing.split("\n").some((ref) => ref && ref !== `refs/heads/${worktree.branch}`)) {
|
|
7217
|
+
keptBranchTip = tip;
|
|
7218
|
+
deleteBranch = false;
|
|
7219
|
+
}
|
|
7220
|
+
}
|
|
7221
|
+
} catch (error) {
|
|
7222
|
+
deleteBranch = false;
|
|
7223
|
+
errors.push(`branch check failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
7224
|
+
}
|
|
7225
|
+
}
|
|
7226
|
+
if (deleteBranch) {
|
|
7227
|
+
try {
|
|
7228
|
+
runGitChecked(setup.cwd, ["branch", "-D", worktree.branch]);
|
|
7229
|
+
branchRemoved = true;
|
|
7230
|
+
} catch (error) {
|
|
7231
|
+
errors.push(`branch removal failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
7232
|
+
}
|
|
7209
7233
|
}
|
|
7210
7234
|
}
|
|
7211
7235
|
return {
|
|
@@ -7217,6 +7241,7 @@ function cleanupSingleWorktree(setup, worktree, intent) {
|
|
|
7217
7241
|
...worktree.recordedBaseDir ? { recordedBaseDir: worktree.recordedBaseDir } : {},
|
|
7218
7242
|
worktreeRemoved,
|
|
7219
7243
|
branchRemoved,
|
|
7244
|
+
...keptBranchTip ? { keptBranchTip } : {},
|
|
7220
7245
|
...errors.length ? { errors } : {}
|
|
7221
7246
|
};
|
|
7222
7247
|
}
|
|
@@ -7417,6 +7442,9 @@ function diffWorktrees(setup, agents, diffsDir) {
|
|
|
7417
7442
|
setup.capturedDiffs = diffs;
|
|
7418
7443
|
return diffs;
|
|
7419
7444
|
}
|
|
7445
|
+
function isWorktreeCleanupTaskDone(task) {
|
|
7446
|
+
return task.worktreeRemoved && (task.branchRemoved || task.keptBranchTip !== void 0);
|
|
7447
|
+
}
|
|
7420
7448
|
function cleanupWorktrees(setup, intent = { kind: "preserve", ...setup.capturedDiffs ? { capturedDiffs: setup.capturedDiffs } : {} }) {
|
|
7421
7449
|
assertWorktreeMutationAllowed();
|
|
7422
7450
|
const tasks = [];
|
|
@@ -7432,7 +7460,7 @@ function cleanupWorktrees(setup, intent = { kind: "preserve", ...setup.capturedD
|
|
|
7432
7460
|
} catch (error) {
|
|
7433
7461
|
errors.push(`worktree prune failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
7434
7462
|
}
|
|
7435
|
-
const state = tasks.every(
|
|
7463
|
+
const state = tasks.every(isWorktreeCleanupTaskDone) && pruned ? "complete" : "partial";
|
|
7436
7464
|
return {
|
|
7437
7465
|
state,
|
|
7438
7466
|
tasks,
|
|
@@ -7626,6 +7654,7 @@ export {
|
|
|
7626
7654
|
resolveExpectedWorktreeAgentCwd,
|
|
7627
7655
|
createWorktrees,
|
|
7628
7656
|
diffWorktrees,
|
|
7657
|
+
isWorktreeCleanupTaskDone,
|
|
7629
7658
|
cleanupWorktrees,
|
|
7630
7659
|
formatWorktreeDiffSummary,
|
|
7631
7660
|
validateModelResponseAliases
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
projectTimeoutRecovery,
|
|
9
9
|
readAsyncRecoveryDescriptor,
|
|
10
10
|
utf8Tail
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-6JD4XCA4.js";
|
|
12
12
|
import {
|
|
13
13
|
MAX_ARGS_BYTES,
|
|
14
14
|
MAX_ARGS_DEPTH,
|
|
@@ -21,10 +21,10 @@ import {
|
|
|
21
21
|
resultFilePath,
|
|
22
22
|
resultPayloadMatchesSessionRun,
|
|
23
23
|
resultPayloadPathForSessionRun
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-SLLZJ5EC.js";
|
|
25
25
|
import {
|
|
26
26
|
PROJECT_SUBAGENTS_RELATIVE_DIR
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-S77ZKDLS.js";
|
|
28
28
|
import {
|
|
29
29
|
listBackgroundWorkWakeChannels,
|
|
30
30
|
snapshotBackgroundWork
|
|
@@ -50,7 +50,7 @@ import {
|
|
|
50
50
|
waitToolName,
|
|
51
51
|
withSettingsFileLease,
|
|
52
52
|
writePrivateAtomicJson
|
|
53
|
-
} from "./chunk-
|
|
53
|
+
} from "./chunk-GHJ6BH5U.js";
|
|
54
54
|
import {
|
|
55
55
|
DIRS,
|
|
56
56
|
INTERCOM_DETACH_REQUEST_EVENT,
|
|
@@ -906,7 +906,7 @@ var SubagentParamProperties = {
|
|
|
906
906
|
usageBudget: Type2.Optional(UsageBudgetOverride),
|
|
907
907
|
agentScope: Type2.Optional(Type2.String({ description: "user/project/both (default); project wins collisions." })),
|
|
908
908
|
cwd: Type2.Optional(Type2.String({ description: "Execution/project-pane directory." })),
|
|
909
|
-
machine: Type2.Optional(Type2.String({ minLength: 1, maxLength: 128, description: 'Herdr saved machine id or label (runs an external CLI agent), a Rex host named in settings (runs a Pi child), or "local" (a Pi child in a Rex
|
|
909
|
+
machine: Type2.Optional(Type2.String({ minLength: 1, maxLength: 128, description: 'Herdr saved machine id or label (runs an external CLI agent), a Rex host named in settings (runs a Pi child), or "local" (a Pi child in a new tab of the Herdr or Rex session this Pi runs in). On another machine, cwd is a directory there.' })),
|
|
910
910
|
requireLauncher: Type2.Optional(Type2.Object({
|
|
911
911
|
name: Type2.String({ pattern: RUNNER_LAUNCHER_NAME_PATTERN.source }),
|
|
912
912
|
definitionDigest: Type2.String({ pattern: "^[0-9a-f]{64}$" })
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getProjectSubagentsDir
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-S77ZKDLS.js";
|
|
4
4
|
import {
|
|
5
5
|
discoverAgents,
|
|
6
6
|
formatUnknownAgentError,
|
|
7
7
|
resolveAgentName,
|
|
8
8
|
unknownAgentDiagnosticContext
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-GHJ6BH5U.js";
|
|
10
10
|
|
|
11
11
|
// src/agents/agent-refinements.ts
|
|
12
12
|
import { createHash, randomUUID } from "node:crypto";
|