@arhen/pi-core-subagent 1.3.15 → 1.3.17
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/README.md +1 -0
- package/package.json +1 -1
- package/src/index.ts +16 -0
- package/src/manager.ts +25 -5
- package/src/schemas.ts +2 -1
package/README.md
CHANGED
|
@@ -263,6 +263,7 @@ Background (default) + intercom — the run returns a runId immediately; you sta
|
|
|
263
263
|
|
|
264
264
|
- `/subagents` — list runs; `/subagents peek` (or `ctrl+shift+a`) — browsable pane
|
|
265
265
|
- `/subagents auto-bg on|off` — toggle background-by-default for subagent calls (persists to `~/.pi/agent/subagents-config.json`; default on). `off` makes calls block until the run finishes, result inline in the same turn. Bare `/subagents auto-bg` shows the current state.
|
|
266
|
+
- `/subagents auto-limit on|off` — toggle leader-imposed `maxRuntimeMs` caps (persists to the same config; default on). `off` strips ALL task timeouts: tasks run unlimited until done, stalled, or aborted — only for runs where a hard bound is genuinely required is a cap kept (none, when off). Bare `/subagents auto-limit` shows the current state.
|
|
266
267
|
|
|
267
268
|
## Peek — `/subagents peek` or `ctrl+shift+a`
|
|
268
269
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arhen/pi-core-subagent",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.17",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "pi extension: fast in-process subagents with a dependency-graph scheduler (needs edges gate tasks and carry upstream output into dependent prompts), plus background runs, intercom and agent-to-agent mailbox. Leader defines agents inline.",
|
|
6
6
|
"license": "MIT",
|
package/src/index.ts
CHANGED
|
@@ -84,6 +84,22 @@ export default function (pi: ExtensionAPI) {
|
|
|
84
84
|
.trim()
|
|
85
85
|
.toLowerCase();
|
|
86
86
|
if (arg === "peek") return openPeek(ctx);
|
|
87
|
+
if (arg === "auto-limit" || arg.startsWith("auto-limit ")) {
|
|
88
|
+
const value = arg.split(/\s+/)[1];
|
|
89
|
+
if (value === "on" || value === "off") {
|
|
90
|
+
const next = manager.setAutoLimit(value === "on");
|
|
91
|
+
ctx.ui.notify(
|
|
92
|
+
`auto-limit ${next ? "on" : "off"} — ${next ? "leader-imposed" : "no"} maxRuntimeMs caps apply to tasks (off = unlimited until done).`,
|
|
93
|
+
"info",
|
|
94
|
+
);
|
|
95
|
+
} else {
|
|
96
|
+
ctx.ui.notify(
|
|
97
|
+
`auto-limit is ${manager.autoLimitOn ? "on" : "off"} — use \`/subagents auto-limit on|off\` (off = tasks run unlimited until done).`,
|
|
98
|
+
"info",
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
87
103
|
if (arg === "auto-bg" || arg.startsWith("auto-bg ")) {
|
|
88
104
|
const value = arg.split(/\s+/)[1];
|
|
89
105
|
if (value === "on" || value === "off") {
|
package/src/manager.ts
CHANGED
|
@@ -206,23 +206,38 @@ export class SubagentManager {
|
|
|
206
206
|
/** Default for `background` when the agent doesn't say — toggle via `/subagents auto-bg on|off`. */
|
|
207
207
|
private autoBg = true;
|
|
208
208
|
|
|
209
|
+
/** When false, strip leader-imposed maxRuntimeMs so tasks run unlimited — toggle via `/subagents auto-limit on|off`. */
|
|
210
|
+
private autoLimit = true;
|
|
211
|
+
|
|
209
212
|
turnActivity = false;
|
|
210
213
|
|
|
211
214
|
constructor(private readonly pi: ExtensionAPI) {
|
|
212
215
|
try {
|
|
213
216
|
const cfg = JSON.parse(readFileSync(join(getAgentDir(), "subagents-config.json"), "utf8"));
|
|
214
217
|
if (typeof cfg.autoBg === "boolean") this.autoBg = cfg.autoBg;
|
|
218
|
+
if (typeof cfg.autoLimit === "boolean") this.autoLimit = cfg.autoLimit;
|
|
215
219
|
} catch {
|
|
216
|
-
/* no config yet —
|
|
220
|
+
/* no config yet — defaults */
|
|
217
221
|
}
|
|
218
222
|
}
|
|
219
223
|
|
|
220
224
|
/** Flip the background-by-default flag; persists to the agent dir. Returns the new value. */
|
|
221
225
|
setAutoBg(on: boolean): boolean {
|
|
222
226
|
this.autoBg = on;
|
|
223
|
-
void writeFile(
|
|
224
|
-
()
|
|
225
|
-
|
|
227
|
+
void writeFile(
|
|
228
|
+
join(getAgentDir(), "subagents-config.json"),
|
|
229
|
+
JSON.stringify({ autoBg: on, autoLimit: this.autoLimit }, null, 2),
|
|
230
|
+
).catch(() => {});
|
|
231
|
+
return on;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/** Flip the auto-limit flag; persists to the agent dir. Returns the new value. */
|
|
235
|
+
setAutoLimit(on: boolean): boolean {
|
|
236
|
+
this.autoLimit = on;
|
|
237
|
+
void writeFile(
|
|
238
|
+
join(getAgentDir(), "subagents-config.json"),
|
|
239
|
+
JSON.stringify({ autoBg: this.autoBg, autoLimit: on }, null, 2),
|
|
240
|
+
).catch(() => {});
|
|
226
241
|
return on;
|
|
227
242
|
}
|
|
228
243
|
|
|
@@ -230,6 +245,10 @@ export class SubagentManager {
|
|
|
230
245
|
return this.autoBg;
|
|
231
246
|
}
|
|
232
247
|
|
|
248
|
+
get autoLimitOn(): boolean {
|
|
249
|
+
return this.autoLimit;
|
|
250
|
+
}
|
|
251
|
+
|
|
233
252
|
/** Any run still has queued/running tasks? */
|
|
234
253
|
hasActiveRun(): boolean {
|
|
235
254
|
for (const run of this.runs.values()) {
|
|
@@ -733,7 +752,8 @@ export class SubagentManager {
|
|
|
733
752
|
),
|
|
734
753
|
});
|
|
735
754
|
|
|
736
|
-
|
|
755
|
+
// auto-limit off = strip leader-imposed caps; tasks run unlimited until done.
|
|
756
|
+
const maxRuntimeMs = this.autoLimit ? (input.maxRuntimeMs ?? DEFAULT_RUNTIME_MS) : 0;
|
|
737
757
|
const promptPromise = child.prompt(task.task, { source: "extension" });
|
|
738
758
|
const races: Promise<unknown>[] = [promptPromise, childFailurePromise, childEndPromise, watchdog.promise];
|
|
739
759
|
if (maxRuntimeMs > 0) {
|
package/src/schemas.ts
CHANGED
|
@@ -51,7 +51,8 @@ export const SubagentParams = Type.Object({
|
|
|
51
51
|
),
|
|
52
52
|
maxRuntimeMs: Type.Optional(
|
|
53
53
|
Type.Number({
|
|
54
|
-
description:
|
|
54
|
+
description:
|
|
55
|
+
"Per-task timeout, ms. Omit for no cap (default): tasks run until done, stalled, or user-aborted. Do not add arbitrary caps — only set when a hard bound is genuinely required.",
|
|
55
56
|
}),
|
|
56
57
|
),
|
|
57
58
|
background: Type.Optional(
|