@arhen/pi-core-subagent 1.3.14 → 1.3.16

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 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.14",
3
+ "version": "1.3.16",
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,21 +206,34 @@ 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 — default true */
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(join(getAgentDir(), "subagents-config.json"), JSON.stringify({ autoBg: on }, null, 2)).catch(
227
+ void writeFile(join(getAgentDir(), "subagents-config.json"), JSON.stringify({ autoBg: on, autoLimit: this.autoLimit }, null, 2)).catch(
228
+ () => {},
229
+ );
230
+ return on;
231
+ }
232
+
233
+ /** Flip the auto-limit flag; persists to the agent dir. Returns the new value. */
234
+ setAutoLimit(on: boolean): boolean {
235
+ this.autoLimit = on;
236
+ void writeFile(join(getAgentDir(), "subagents-config.json"), JSON.stringify({ autoBg: this.autoBg, autoLimit: on }, null, 2)).catch(
224
237
  () => {},
225
238
  );
226
239
  return on;
@@ -230,6 +243,10 @@ export class SubagentManager {
230
243
  return this.autoBg;
231
244
  }
232
245
 
246
+ get autoLimitOn(): boolean {
247
+ return this.autoLimit;
248
+ }
249
+
233
250
  /** Any run still has queued/running tasks? */
234
251
  hasActiveRun(): boolean {
235
252
  for (const run of this.runs.values()) {
@@ -654,8 +671,8 @@ export class SubagentManager {
654
671
  const key = `${run.id}:${task.id}`;
655
672
  try {
656
673
  const subagentInstruction = run.allowIntercom
657
- ? `You are running as a subagent. Do not call subagent/delegation tools unless the parent explicitly asks. Return a concise final answer. You MAY use ask_parent only when truly blocked on information only the parent has; notify_parent for one-way updates; send_agent_message/poll_agent_messages to coordinate with siblings. Your mailbox address and siblings: ${task.roster ?? "(none)"}. Use the exact task ids (e.g. task_2) as send_agent_message targets.`
658
- : "You are running as a subagent. Do not call subagent/delegation tools unless the parent explicitly asks. Return a concise final answer for the parent agent.";
674
+ ? `You are running as a subagent. Your bash tool already executes in the project working directory — never prefix commands with \`cd\`. Do not call subagent/delegation tools unless the parent explicitly asks. Return a concise final answer. You MAY use ask_parent only when truly blocked on information only the parent has; notify_parent for one-way updates; send_agent_message/poll_agent_messages to coordinate with siblings. Your mailbox address and siblings: ${task.roster ?? "(none)"}. Use the exact task ids (e.g. task_2) as send_agent_message targets.`
675
+ : `You are running as a subagent. Your bash tool already executes in the project working directory — never prefix commands with \`cd\`. Do not call subagent/delegation tools unless the parent explicitly asks. Return a concise final answer for the parent agent.`;
659
676
 
660
677
  const loader = new DefaultResourceLoader({
661
678
  cwd: task.cwd,
@@ -733,7 +750,8 @@ export class SubagentManager {
733
750
  ),
734
751
  });
735
752
 
736
- const maxRuntimeMs = input.maxRuntimeMs ?? DEFAULT_RUNTIME_MS;
753
+ // auto-limit off = strip leader-imposed caps; tasks run unlimited until done.
754
+ const maxRuntimeMs = this.autoLimit ? (input.maxRuntimeMs ?? DEFAULT_RUNTIME_MS) : 0;
737
755
  const promptPromise = child.prompt(task.task, { source: "extension" });
738
756
  const races: Promise<unknown>[] = [promptPromise, childFailurePromise, childEndPromise, watchdog.promise];
739
757
  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: "Per-task timeout, ms. Omit for no cap (default): tasks run until done, stalled, or user-aborted.",
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(