@henryqw/pi-herdr 0.7.1 → 0.7.2
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/admission.js +14 -2
- package/package.json +1 -1
package/dist/admission.js
CHANGED
|
@@ -5,6 +5,18 @@ const CHANNEL = "pi-herdr:checkout-admission";
|
|
|
5
5
|
const MAIN_NON_WRITING_TOOLS = new Set([
|
|
6
6
|
"read", "grep", "find", "ffgrep", "fffind", "ls", "codegraph_explore", "subagent_status", "codemode",
|
|
7
7
|
]);
|
|
8
|
+
// A direct admission owner is the JSON array [journal, session, workflow id, token].
|
|
9
|
+
const directWorkflow = (owner) => {
|
|
10
|
+
try {
|
|
11
|
+
const parsed = JSON.parse(owner ?? "");
|
|
12
|
+
return Array.isArray(parsed) && parsed[0] === "subagent-direct-admission" && typeof parsed[2] === "string" ? parsed[2] : undefined;
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
// Main tools run from the session checkout, so admission cannot trust a path or project named in their input.
|
|
19
|
+
const scopeNote = (owner) => ` This block covers every Main tool except read-only tools, whatever path or project its input names, because Main tools run from this checkout.${directWorkflow(owner) ? ` If that direct workflow should end (for example, its result never arrived), call delegate_task with {"mode":"cancel","id":"${directWorkflow(owner)}"} to stop its workers and release the reservation.` : ""}`;
|
|
8
20
|
export function checkoutToolCanWrite(toolName, input, directCanWrite) {
|
|
9
21
|
return toolName === "delegate_task" ? directCanWrite(input) : !MAIN_NON_WRITING_TOOLS.has(toolName);
|
|
10
22
|
}
|
|
@@ -101,7 +113,7 @@ function createAdmission() {
|
|
|
101
113
|
release(event.toolCallId);
|
|
102
114
|
return {
|
|
103
115
|
block: true,
|
|
104
|
-
reason: `Checkout set ${keys.join(", ")} has ${owner ? `an admitted direct writer (${owner})` : `a Main potentially-writing call in flight (${main})`}; retry after it stops
|
|
116
|
+
reason: `Checkout set ${keys.join(", ")} has ${owner ? `an admitted direct writer (${owner})` : `a Main potentially-writing call in flight (${main})`}; retry after it stops.${owner ? scopeNote(owner) : ""}`,
|
|
105
117
|
};
|
|
106
118
|
}
|
|
107
119
|
call.keys = keys;
|
|
@@ -165,7 +177,7 @@ function createAdmission() {
|
|
|
165
177
|
?? ownerByCheckout.get(checkout)
|
|
166
178
|
?? [...calls].find(([, call]) => call.keys?.includes(checkout))?.[0];
|
|
167
179
|
if (conflict)
|
|
168
|
-
throw new Error(`Checkout ${checkout} has an active writer (${conflict}); wait until it stops
|
|
180
|
+
throw new Error(`Checkout ${checkout} has an active writer (${conflict}); wait until it stops.${scopeNote(conflict)}`);
|
|
169
181
|
durable.set(owner, [checkout]);
|
|
170
182
|
return () => { durable.delete(owner); };
|
|
171
183
|
},
|