pi-herdsman 0.25.0 → 0.25.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/dist/index.js +55 -103
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -15,7 +15,7 @@ import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
|
15
15
|
// package.json
|
|
16
16
|
var package_default = {
|
|
17
17
|
name: "pi-herdsman",
|
|
18
|
-
version: "0.25.
|
|
18
|
+
version: "0.25.1",
|
|
19
19
|
type: "module",
|
|
20
20
|
description: "Asynchronous Pi subagents and agent fleet orchestration for parallel coding agents with nested delegation, background work, and supervision in herdr.",
|
|
21
21
|
license: "Apache-2.0",
|
|
@@ -6911,6 +6911,29 @@ function fsyncDirectory(directory) {
|
|
|
6911
6911
|
closeSync8(fd);
|
|
6912
6912
|
}
|
|
6913
6913
|
}
|
|
6914
|
+
function publishRecord(path, content) {
|
|
6915
|
+
const directory = dirname6(path);
|
|
6916
|
+
const temporary = join8(directory, `.${basename5(path)}.${randomUUID7()}.tmp`);
|
|
6917
|
+
let fd;
|
|
6918
|
+
try {
|
|
6919
|
+
fd = openSync8(temporary, "wx", 384);
|
|
6920
|
+
writeFileSync5(fd, content, "utf8");
|
|
6921
|
+
fsyncSync4(fd);
|
|
6922
|
+
closeSync8(fd);
|
|
6923
|
+
fd = void 0;
|
|
6924
|
+
renameSync6(temporary, path);
|
|
6925
|
+
chmodSync7(path, 384);
|
|
6926
|
+
fsyncDirectory(directory);
|
|
6927
|
+
return path;
|
|
6928
|
+
} finally {
|
|
6929
|
+
if (fd !== void 0) closeSync8(fd);
|
|
6930
|
+
try {
|
|
6931
|
+
unlinkSync6(temporary);
|
|
6932
|
+
} catch (error2) {
|
|
6933
|
+
if (error2.code !== "ENOENT") throw error2;
|
|
6934
|
+
}
|
|
6935
|
+
}
|
|
6936
|
+
}
|
|
6914
6937
|
function withChiefMessageLock(path, operation) {
|
|
6915
6938
|
const lock = `${path}.lock`;
|
|
6916
6939
|
const lease = acquireProcessLock(lock, { name: "Chief message lock" });
|
|
@@ -7553,32 +7576,13 @@ function writePeerLeadRecord(runtime, record) {
|
|
|
7553
7576
|
const live = livePeerClaim(runtime, record.piSessionId);
|
|
7554
7577
|
if (live.pid !== record.claim.pid || live.id !== record.claim.id)
|
|
7555
7578
|
throw new Error("Peer lead process-lock generation changed");
|
|
7556
|
-
|
|
7579
|
+
peerDirectory(runtime);
|
|
7557
7580
|
const path = peerLeadRecordPath(runtime, record.piSessionId);
|
|
7558
7581
|
const content = `${JSON.stringify(record)}
|
|
7559
7582
|
`;
|
|
7560
7583
|
if (Buffer.byteLength(content, "utf8") > PEER_LEAD_RECORD_MAX_BYTES)
|
|
7561
7584
|
throw new Error("Peer lead record is too large");
|
|
7562
|
-
|
|
7563
|
-
let fd;
|
|
7564
|
-
try {
|
|
7565
|
-
fd = openSync8(temporary, "wx", 384);
|
|
7566
|
-
writeFileSync5(fd, content, "utf8");
|
|
7567
|
-
fsyncSync4(fd);
|
|
7568
|
-
closeSync8(fd);
|
|
7569
|
-
fd = void 0;
|
|
7570
|
-
renameSync6(temporary, path);
|
|
7571
|
-
chmodSync7(path, 384);
|
|
7572
|
-
fsyncDirectory(directory);
|
|
7573
|
-
return path;
|
|
7574
|
-
} finally {
|
|
7575
|
-
if (fd !== void 0) closeSync8(fd);
|
|
7576
|
-
try {
|
|
7577
|
-
unlinkSync6(temporary);
|
|
7578
|
-
} catch (error2) {
|
|
7579
|
-
if (error2.code !== "ENOENT") throw error2;
|
|
7580
|
-
}
|
|
7581
|
-
}
|
|
7585
|
+
return publishRecord(path, content);
|
|
7582
7586
|
}
|
|
7583
7587
|
function removePeerLeadRecord(runtime, piSessionId, expected) {
|
|
7584
7588
|
const path = peerLeadRecordPath(runtime, piSessionId);
|
|
@@ -8296,31 +8300,12 @@ function readLeadCoordinationState(runtime, piSessionId) {
|
|
|
8296
8300
|
function writeLeadCoordinationState(runtime, state) {
|
|
8297
8301
|
if (!state.build || !validLeadState(state))
|
|
8298
8302
|
throw new Error("Invalid lead coordination state");
|
|
8299
|
-
|
|
8303
|
+
leadStateDirectory(runtime);
|
|
8300
8304
|
const path = leadCoordinationStatePath(runtime, state.piSessionId);
|
|
8301
8305
|
const content = JSON.stringify(state) + "\n";
|
|
8302
8306
|
if (Buffer.byteLength(content, "utf8") > LEAD_STATE_MAX_BYTES)
|
|
8303
8307
|
throw new Error("Lead coordination state is too large");
|
|
8304
|
-
|
|
8305
|
-
let fd;
|
|
8306
|
-
try {
|
|
8307
|
-
fd = openSync8(temporary, "wx", 384);
|
|
8308
|
-
writeFileSync5(fd, content, "utf8");
|
|
8309
|
-
fsyncSync4(fd);
|
|
8310
|
-
closeSync8(fd);
|
|
8311
|
-
fd = void 0;
|
|
8312
|
-
renameSync6(temporary, path);
|
|
8313
|
-
chmodSync7(path, 384);
|
|
8314
|
-
fsyncDirectory(directory);
|
|
8315
|
-
return path;
|
|
8316
|
-
} finally {
|
|
8317
|
-
if (fd !== void 0) closeSync8(fd);
|
|
8318
|
-
try {
|
|
8319
|
-
unlinkSync6(temporary);
|
|
8320
|
-
} catch (e) {
|
|
8321
|
-
if (e.code !== "ENOENT") throw e;
|
|
8322
|
-
}
|
|
8323
|
-
}
|
|
8308
|
+
return publishRecord(path, content);
|
|
8324
8309
|
}
|
|
8325
8310
|
function invalidateLeadCoordinationState(runtime, piSessionId, expectedInstanceId) {
|
|
8326
8311
|
const path = leadCoordinationStatePath(runtime, piSessionId);
|
|
@@ -10051,6 +10036,30 @@ function createAgentController(pi, options) {
|
|
|
10051
10036
|
return false;
|
|
10052
10037
|
}
|
|
10053
10038
|
};
|
|
10039
|
+
const recordDependencies = {
|
|
10040
|
+
persistedTranscriptReady: persistedTranscriptReady2,
|
|
10041
|
+
cascadePlan: (items, state) => managedAgentCascadePlanFromSnapshot(items, state, sameIdentity),
|
|
10042
|
+
assertCascadeSafe: (items) => assertManagedAgentCascadeSafe(items, sameIdentity),
|
|
10043
|
+
runtimeForLabel: (label) => runtimes.get(label),
|
|
10044
|
+
sameIdentity,
|
|
10045
|
+
runtimeIdentityState: (runtime) => ({
|
|
10046
|
+
version: 5,
|
|
10047
|
+
build: options.build,
|
|
10048
|
+
runId: runtime.runId,
|
|
10049
|
+
ownerSessionId: runtime.ownerSessionId,
|
|
10050
|
+
workspaceId: runtime.workspaceId,
|
|
10051
|
+
agentLabel: runtime.label,
|
|
10052
|
+
paneId: runtime.paneId,
|
|
10053
|
+
piSessionId: runtime.piSessionId ?? "",
|
|
10054
|
+
piSessionFile: runtime.piSessionFile,
|
|
10055
|
+
cwd: runtime.cwd,
|
|
10056
|
+
updatedAt: 0
|
|
10057
|
+
})
|
|
10058
|
+
};
|
|
10059
|
+
const listRecordDependencies = {
|
|
10060
|
+
...recordDependencies,
|
|
10061
|
+
persistedTranscriptReady: options.persistedTranscriptReady
|
|
10062
|
+
};
|
|
10054
10063
|
const snapshots = (context, signal, allWorkspaces = false, allowTranscriptDefinitionFallback = true) => snapshot(
|
|
10055
10064
|
context,
|
|
10056
10065
|
signal,
|
|
@@ -10096,26 +10105,7 @@ function createAgentController(pi, options) {
|
|
|
10096
10105
|
ownerSessionId,
|
|
10097
10106
|
scope,
|
|
10098
10107
|
unresolvedMailboxState,
|
|
10099
|
-
|
|
10100
|
-
persistedTranscriptReady: options.persistedTranscriptReady,
|
|
10101
|
-
cascadePlan: (items, state) => managedAgentCascadePlanFromSnapshot(items, state, sameIdentity),
|
|
10102
|
-
assertCascadeSafe: (items) => assertManagedAgentCascadeSafe(items, sameIdentity),
|
|
10103
|
-
runtimeForLabel: (label) => runtimes.get(label),
|
|
10104
|
-
sameIdentity,
|
|
10105
|
-
runtimeIdentityState: (runtime) => ({
|
|
10106
|
-
version: 5,
|
|
10107
|
-
build: options.build,
|
|
10108
|
-
runId: runtime.runId,
|
|
10109
|
-
ownerSessionId: runtime.ownerSessionId,
|
|
10110
|
-
workspaceId: runtime.workspaceId,
|
|
10111
|
-
agentLabel: runtime.label,
|
|
10112
|
-
paneId: runtime.paneId,
|
|
10113
|
-
piSessionId: runtime.piSessionId ?? "",
|
|
10114
|
-
piSessionFile: runtime.piSessionFile,
|
|
10115
|
-
cwd: runtime.cwd,
|
|
10116
|
-
updatedAt: 0
|
|
10117
|
-
})
|
|
10118
|
-
}
|
|
10108
|
+
listRecordDependencies
|
|
10119
10109
|
);
|
|
10120
10110
|
const leadTabLabel = async (context) => {
|
|
10121
10111
|
const name = pi.getSessionName() ?? context.sessionManager.getSessionName();
|
|
@@ -11043,26 +11033,7 @@ function createAgentController(pi, options) {
|
|
|
11043
11033
|
context.sessionManager.getSessionId(),
|
|
11044
11034
|
scope,
|
|
11045
11035
|
unresolved,
|
|
11046
|
-
|
|
11047
|
-
persistedTranscriptReady: persistedTranscriptReady2,
|
|
11048
|
-
cascadePlan: (items, parent) => managedAgentCascadePlanFromSnapshot(items, parent, sameIdentity),
|
|
11049
|
-
assertCascadeSafe: (items) => assertManagedAgentCascadeSafe(items, sameIdentity),
|
|
11050
|
-
runtimeForLabel: (label) => runtimes.get(label),
|
|
11051
|
-
sameIdentity,
|
|
11052
|
-
runtimeIdentityState: (runtime) => ({
|
|
11053
|
-
version: 5,
|
|
11054
|
-
build: options.build,
|
|
11055
|
-
runId: runtime.runId,
|
|
11056
|
-
ownerSessionId: runtime.ownerSessionId,
|
|
11057
|
-
workspaceId: runtime.workspaceId,
|
|
11058
|
-
agentLabel: runtime.label,
|
|
11059
|
-
paneId: runtime.paneId,
|
|
11060
|
-
piSessionId: runtime.piSessionId ?? "",
|
|
11061
|
-
piSessionFile: runtime.piSessionFile,
|
|
11062
|
-
cwd: runtime.cwd,
|
|
11063
|
-
updatedAt: 0
|
|
11064
|
-
})
|
|
11065
|
-
}
|
|
11036
|
+
recordDependencies
|
|
11066
11037
|
).available_tools;
|
|
11067
11038
|
if (!actions.includes("read_agent_transcript")) {
|
|
11068
11039
|
if (candidate.presence.kind === "unknown")
|
|
@@ -13296,26 +13267,7 @@ ${result.stderr ?? ""}`.trim(),
|
|
|
13296
13267
|
ownerSessionId,
|
|
13297
13268
|
options.scope,
|
|
13298
13269
|
unresolvedMailboxState,
|
|
13299
|
-
|
|
13300
|
-
persistedTranscriptReady: persistedTranscriptReady2,
|
|
13301
|
-
cascadePlan: (snapshot2, state) => managedAgentCascadePlanFromSnapshot(snapshot2, state, sameIdentity),
|
|
13302
|
-
assertCascadeSafe: (items) => assertManagedAgentCascadeSafe(items, sameIdentity),
|
|
13303
|
-
runtimeForLabel: (label) => runtimes.get(label),
|
|
13304
|
-
sameIdentity,
|
|
13305
|
-
runtimeIdentityState: (runtime) => ({
|
|
13306
|
-
version: 5,
|
|
13307
|
-
build: options.build,
|
|
13308
|
-
runId: runtime.runId,
|
|
13309
|
-
ownerSessionId: runtime.ownerSessionId,
|
|
13310
|
-
workspaceId: runtime.workspaceId,
|
|
13311
|
-
agentLabel: runtime.label,
|
|
13312
|
-
paneId: runtime.paneId,
|
|
13313
|
-
piSessionId: runtime.piSessionId ?? "",
|
|
13314
|
-
piSessionFile: runtime.piSessionFile,
|
|
13315
|
-
cwd: runtime.cwd,
|
|
13316
|
-
updatedAt: 0
|
|
13317
|
-
})
|
|
13318
|
-
}
|
|
13270
|
+
recordDependencies
|
|
13319
13271
|
).available_tools ?? []).flatMap((tool) => {
|
|
13320
13272
|
switch (tool) {
|
|
13321
13273
|
case "list_agents":
|