@gotgenes/pi-subagents 1.0.2 → 3.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gotgenes/pi-subagents",
3
- "version": "1.0.2",
3
+ "version": "3.0.0",
4
4
  "description": "A pi extension that brings Claude Code-style autonomous sub-agents to pi. Friendly fork of @tintinweb/pi-subagents.",
5
5
  "author": {
6
6
  "name": "Chris Lasher"
@@ -33,7 +33,6 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@sinclair/typebox": "^0.34.49",
36
- "croner": "^10.0.1",
37
36
  "nanoid": "^5.0.0"
38
37
  },
39
38
  "engines": {
@@ -40,8 +40,8 @@ interface SpawnOptions {
40
40
  isBackground?: boolean;
41
41
  /**
42
42
  * Skip the maxConcurrent queue check for this spawn — start immediately even
43
- * if the configured concurrency limit would otherwise queue it. Used by the
44
- * scheduler so a fired job can't be deferred past its trigger window.
43
+ * if the configured concurrency limit would otherwise queue it. Useful for
44
+ * callers (e.g. cross-extension RPC) that must not be deferred by the queue.
45
45
  */
46
46
  bypassQueue?: boolean;
47
47
  /** Isolation mode — "worktree" creates a temp git worktree for the agent. */
package/src/index.ts CHANGED
@@ -12,22 +12,18 @@
12
12
 
13
13
  import { existsSync, mkdirSync, readFileSync, unlinkSync } from "node:fs";
14
14
  import { join } from "node:path";
15
- import { defineTool, type ExtensionAPI, type ExtensionCommandContext, type ExtensionContext, getAgentDir } from "@earendil-works/pi-coding-agent";
15
+ import { defineTool, type ExtensionAPI, type ExtensionCommandContext, getAgentDir } from "@earendil-works/pi-coding-agent";
16
16
  import { Text } from "@earendil-works/pi-tui";
17
17
  import { Type } from "@sinclair/typebox";
18
18
  import { AgentManager } from "./agent-manager.js";
19
19
  import { getAgentConversation, getDefaultMaxTurns, getGraceTurns, normalizeMaxTurns, setDefaultMaxTurns, setGraceTurns, steerAgent } from "./agent-runner.js";
20
20
  import { BUILTIN_TOOL_NAMES, getAgentConfig, getAllTypes, getAvailableTypes, getDefaultAgentNames, getUserAgentNames, registerAgents, resolveType } from "./agent-types.js";
21
- import { registerRpcHandlers } from "./cross-extension-rpc.js";
22
21
  import { loadCustomAgents } from "./custom-agents.js";
23
- import { GroupJoinManager } from "./group-join.js";
24
- import { resolveAgentInvocationConfig, resolveJoinMode } from "./invocation-config.js";
22
+ import { resolveAgentInvocationConfig } from "./invocation-config.js";
25
23
  import { type ModelRegistry, resolveModel } from "./model-resolver.js";
26
24
  import { createOutputFilePath, streamToOutputFile, writeInitialEntry } from "./output-file.js";
27
- import { SubagentScheduler } from "./schedule.js";
28
- import { resolveStorePath, ScheduleStore } from "./schedule-store.js";
29
25
  import { applyAndEmitLoaded, type SubagentsSettings, saveAndEmitChanged } from "./settings.js";
30
- import { type AgentConfig, type AgentInvocation, type AgentRecord, type JoinMode, type NotificationDetails, type SubagentType } from "./types.js";
26
+ import { type AgentConfig, type AgentInvocation, type AgentRecord, type NotificationDetails, type SubagentType } from "./types.js";
31
27
  import {
32
28
  type AgentActivity,
33
29
  type AgentDetails,
@@ -43,7 +39,6 @@ import {
43
39
  SPINNER,
44
40
  type UICtx,
45
41
  } from "./ui/agent-widget.js";
46
- import { showSchedulesMenu } from "./ui/schedule-menu.js";
47
42
  import { addUsage, getLifetimeTotal, getSessionContextPercent, type LifetimeUsage } from "./usage.js";
48
43
 
49
44
  // ---- Shared helpers ----
@@ -249,8 +244,7 @@ export default function (pi: ExtensionAPI) {
249
244
  return line;
250
245
  }
251
246
 
252
- const all = [d, ...(d.others ?? [])];
253
- return new Text(all.map(renderOne).join("\n"), 0, 0);
247
+ return new Text(renderOne(d), 0, 0);
254
248
  }
255
249
  );
256
250
 
@@ -310,40 +304,6 @@ export default function (pi: ExtensionAPI) {
310
304
  widget.update();
311
305
  }
312
306
 
313
- // ---- Group join manager ----
314
- const groupJoin = new GroupJoinManager(
315
- (records, partial) => {
316
- for (const r of records) { agentActivity.delete(r.id); widget.markFinished(r.id); }
317
-
318
- const groupKey = `group:${records.map(r => r.id).join(",")}`;
319
- scheduleNudge(groupKey, () => {
320
- // Re-check at send time
321
- const unconsumed = records.filter(r => !r.resultConsumed);
322
- if (unconsumed.length === 0) { widget.update(); return; }
323
-
324
- const notifications = unconsumed.map(r => formatTaskNotification(r, 300)).join('\n\n');
325
- const label = partial
326
- ? `${unconsumed.length} agent(s) finished (partial — others still running)`
327
- : `${unconsumed.length} agent(s) finished`;
328
-
329
- const [first, ...rest] = unconsumed;
330
- const details = buildNotificationDetails(first, 300, agentActivity.get(first.id));
331
- if (rest.length > 0) {
332
- details.others = rest.map(r => buildNotificationDetails(r, 300, agentActivity.get(r.id)));
333
- }
334
-
335
- pi.sendMessage<NotificationDetails>({
336
- customType: "subagent-notification",
337
- content: `Background agent group completed: ${label}\n\n${notifications}\n\nUse get_subagent_result for full output.`,
338
- display: true,
339
- details,
340
- }, { deliverAs: "followUp", triggerTurn: true });
341
- });
342
- widget.update();
343
- },
344
- 30_000,
345
- );
346
-
347
307
  /** Helper: build event data for lifecycle events from an AgentRecord. */
348
308
  function buildEventData(record: AgentRecord) {
349
309
  const durationMs = record.completedAt ? record.completedAt - record.startedAt : Date.now() - record.startedAt;
@@ -369,7 +329,7 @@ export default function (pi: ExtensionAPI) {
369
329
  };
370
330
  }
371
331
 
372
- // Background completion: route through group join or send individual nudge
332
+ // Background completion: emit lifecycle event and send individual nudge
373
333
  const manager = new AgentManager((record) => {
374
334
  // Emit lifecycle event based on terminal status
375
335
  const isError = record.status === "error" || record.status === "stopped" || record.status === "aborted";
@@ -395,19 +355,7 @@ export default function (pi: ExtensionAPI) {
395
355
  return;
396
356
  }
397
357
 
398
- // If this agent is pending batch finalization (debounce window still open),
399
- // don't send an individual nudge — finalizeBatch will pick it up retroactively.
400
- if (currentBatchAgents.some(a => a.id === record.id)) {
401
- widget.update();
402
- return;
403
- }
404
-
405
- const result = groupJoin.onAgentComplete(record);
406
- if (result === 'pass') {
407
- sendIndividualNudge(record);
408
- }
409
- // 'held' → do nothing, group will fire later
410
- // 'delivered' → group callback already fired
358
+ sendIndividualNudge(record);
411
359
  widget.update();
412
360
  }, undefined, (record) => {
413
361
  // Emit started event when agent transitions to running (including from queue)
@@ -439,61 +387,18 @@ export default function (pi: ExtensionAPI) {
439
387
  getRecord: (id: string) => manager.getRecord(id),
440
388
  };
441
389
 
442
- // --- Cross-extension RPC via pi.events ---
443
- let currentCtx: ExtensionContext | undefined;
444
-
445
- // ---- Subagent scheduler ----
446
- // Session-scoped: store is constructed inside session_start once sessionId
447
- // is available. Mirrors pi-chonky-tasks's session-scoped task store —
448
- // schedules reset on /new, restore on /resume.
449
- const scheduler = new SubagentScheduler();
450
-
451
- function startScheduler(ctx: ExtensionContext) {
452
- try {
453
- const sessionId = ctx.sessionManager?.getSessionId?.();
454
- if (!sessionId) return; // sessionId not yet available — try again on next event
455
- const path = resolveStorePath(ctx.cwd, sessionId);
456
- const store = new ScheduleStore(path);
457
- scheduler.start(pi, ctx, manager, store);
458
- pi.events.emit("subagents:scheduler_ready", { sessionId, jobCount: store.list().length });
459
- } catch (err) {
460
- // Scheduling is non-essential — log and move on so the rest of the
461
- // extension keeps working if e.g. .pi/ is unwritable.
462
- console.warn("[pi-subagents] Failed to start scheduler:", err);
463
- }
464
- }
465
-
466
- // Capture ctx from session_start for RPC spawn handler + start the scheduler.
467
- pi.on("session_start", async (_event, ctx) => {
468
- currentCtx = ctx;
390
+ pi.on("session_start", async (_event, _ctx) => {
469
391
  manager.clearCompleted();
470
- if (isSchedulingEnabled() && !scheduler.isActive()) startScheduler(ctx);
471
392
  });
472
393
 
473
394
  pi.on("session_before_switch", () => {
474
395
  manager.clearCompleted();
475
- scheduler.stop();
476
396
  });
477
397
 
478
- const { unsubPing: unsubPingRpc, unsubSpawn: unsubSpawnRpc, unsubStop: unsubStopRpc } = registerRpcHandlers({
479
- events: pi.events,
480
- pi,
481
- getCtx: () => currentCtx,
482
- manager,
483
- });
484
-
485
- // Broadcast readiness so extensions loaded after us can discover us
486
- pi.events.emit("subagents:ready", {});
487
-
488
398
  // On shutdown, abort all agents immediately and clean up.
489
399
  // If the session is going down, there's nothing left to consume agent results.
490
400
  pi.on("session_shutdown", async () => {
491
- unsubSpawnRpc();
492
- unsubStopRpc();
493
- unsubPingRpc();
494
- currentCtx = undefined;
495
401
  delete (globalThis as any)[MANAGER_KEY];
496
- scheduler.stop();
497
402
  manager.abortAll();
498
403
  for (const timer of pendingNudges.values()) clearTimeout(timer);
499
404
  pendingNudges.clear();
@@ -503,64 +408,6 @@ export default function (pi: ExtensionAPI) {
503
408
  // Live widget: show running agents above editor
504
409
  const widget = new AgentWidget(manager, agentActivity);
505
410
 
506
- // ---- Join mode configuration ----
507
- let defaultJoinMode: JoinMode = 'smart';
508
- function getDefaultJoinMode(): JoinMode { return defaultJoinMode; }
509
- function setDefaultJoinMode(mode: JoinMode) { defaultJoinMode = mode; }
510
-
511
- // Master switch for the schedule subagent feature. Defaults to enabled.
512
- // Read once at extension init (before tool registration) so the Agent tool's
513
- // param schema reflects the persisted setting. Runtime toggles via /agents
514
- // → Settings short-circuit the menu entry + the execute-time addJob path
515
- // immediately, but the schema-level removal only takes effect on next
516
- // extension load (next pi session). Documented in CHANGELOG/README.
517
- let schedulingEnabled = true;
518
- function isSchedulingEnabled(): boolean { return schedulingEnabled; }
519
- function setSchedulingEnabled(b: boolean) { schedulingEnabled = b; }
520
-
521
- // ---- Batch tracking for smart join mode ----
522
- // Collects background agent IDs spawned in the current turn for smart grouping.
523
- // Uses a debounced timer: each new agent resets the 100ms window so that all
524
- // parallel tool calls (which may be dispatched across multiple microtasks by the
525
- // framework) are captured in the same batch.
526
- let currentBatchAgents: { id: string; joinMode: JoinMode }[] = [];
527
- let batchFinalizeTimer: ReturnType<typeof setTimeout> | undefined;
528
- let batchCounter = 0;
529
-
530
- /** Finalize the current batch: if 2+ smart-mode agents, register as a group. */
531
- function finalizeBatch() {
532
- batchFinalizeTimer = undefined;
533
- const batchAgents = [...currentBatchAgents];
534
- currentBatchAgents = [];
535
-
536
- const smartAgents = batchAgents.filter(a => a.joinMode === 'smart' || a.joinMode === 'group');
537
- if (smartAgents.length >= 2) {
538
- const groupId = `batch-${++batchCounter}`;
539
- const ids = smartAgents.map(a => a.id);
540
- groupJoin.registerGroup(groupId, ids);
541
- // Retroactively process agents that already completed during the debounce window.
542
- // Their onComplete fired but was deferred (agent was in currentBatchAgents),
543
- // so we feed them into the group now.
544
- for (const id of ids) {
545
- const record = manager.getRecord(id);
546
- if (!record) continue;
547
- record.groupId = groupId;
548
- if (record.completedAt != null && !record.resultConsumed) {
549
- groupJoin.onAgentComplete(record);
550
- }
551
- }
552
- } else {
553
- // No group formed — send individual nudges for any agents that completed
554
- // during the debounce window and had their notification deferred.
555
- for (const { id } of batchAgents) {
556
- const record = manager.getRecord(id);
557
- if (record?.completedAt != null && !record.resultConsumed) {
558
- sendIndividualNudge(record);
559
- }
560
- }
561
- }
562
- }
563
-
564
411
  // Grab UI context from first tool execution + clear lingering widget on new turn
565
412
  pi.on("tool_execution_start", async (_event, ctx) => {
566
413
  widget.setUICtx(ctx.ui as UICtx);
@@ -610,36 +457,12 @@ export default function (pi: ExtensionAPI) {
610
457
  setMaxConcurrent: (n) => manager.setMaxConcurrent(n),
611
458
  setDefaultMaxTurns,
612
459
  setGraceTurns,
613
- setDefaultJoinMode,
614
- setSchedulingEnabled,
615
460
  },
616
461
  (event, payload) => pi.events.emit(event, payload),
617
462
  );
618
463
 
619
464
  // ---- Agent tool ----
620
465
 
621
- // Schedule param + its guideline are gated on `schedulingEnabled` (read once
622
- // at registration; flipping the setting later requires next pi session for
623
- // the schema to update). Defining the shape once and spreading it via Partial
624
- // preserves Type.Object's inference when present and produces a
625
- // `schedule`-free schema when absent — zero LLM-context cost in disabled mode.
626
- const scheduleParamShape = {
627
- schedule: Type.Optional(
628
- Type.String({
629
- description:
630
- 'Opt-in only — fire later instead of now. Omit to run immediately (the default, almost always correct). ' +
631
- 'Formats: 6-field cron ("0 0 9 * * 1" = 9am Mon), interval ("5m"/"1h"), one-shot ("+10m" or ISO). ' +
632
- 'Forces run_in_background; incompatible with inherit_context and resume. Returns job ID.',
633
- }),
634
- ),
635
- };
636
- const scheduleParam: Partial<typeof scheduleParamShape> =
637
- isSchedulingEnabled() ? scheduleParamShape : {};
638
-
639
- const scheduleGuideline = isSchedulingEnabled()
640
- ? `\n- Use \`schedule\` only when the user explicitly asked for scheduled / recurring / delayed execution (e.g. "every Monday", "in an hour"). Don't auto-schedule from vague intent like "monitor X" — run once now or ask.`
641
- : "";
642
-
643
466
  pi.registerTool(defineTool({
644
467
  name: "Agent",
645
468
  label: "Agent",
@@ -663,7 +486,7 @@ Guidelines:
663
486
  - Use model to specify a different model (as "provider/modelId", or fuzzy e.g. "haiku", "sonnet").
664
487
  - Use thinking to control extended thinking level.
665
488
  - Use inherit_context if the agent needs the parent conversation history.
666
- - Use isolation: "worktree" to run the agent in an isolated git worktree (safe parallel file modifications).${scheduleGuideline}`,
489
+ - Use isolation: "worktree" to run the agent in an isolated git worktree (safe parallel file modifications).`,
667
490
  parameters: Type.Object({
668
491
  prompt: Type.String({
669
492
  description: "The task for the agent to perform.",
@@ -716,7 +539,6 @@ Guidelines:
716
539
  description: 'Set to "worktree" to run the agent in a temporary git worktree (isolated copy of the repo). Changes are saved to a branch on completion.',
717
540
  }),
718
541
  ),
719
- ...scheduleParam,
720
542
  }),
721
543
 
722
544
  // ---- Custom rendering: Claude Code style ----
@@ -877,47 +699,6 @@ Guidelines:
877
699
  tags: agentTags.length > 0 ? agentTags : undefined,
878
700
  };
879
701
 
880
- // ---- Schedule: register a job, don't spawn now ----
881
- if (params.schedule) {
882
- if (!isSchedulingEnabled()) {
883
- return textResult("Scheduling is disabled in this project. Enable via /agents → Settings → Scheduling.");
884
- }
885
- if (params.resume) {
886
- return textResult("Cannot combine `schedule` with `resume` — schedules create fresh agents.");
887
- }
888
- if (params.inherit_context) {
889
- return textResult("Cannot combine `schedule` with `inherit_context` — there is no parent conversation at fire time.");
890
- }
891
- if (params.run_in_background === false) {
892
- return textResult("Cannot combine `schedule` with `run_in_background: false` — scheduled jobs always run in background.");
893
- }
894
- if (!scheduler.isActive()) {
895
- return textResult("Scheduler is not active in this session yet. Try again after the session has fully started.");
896
- }
897
- try {
898
- const job = scheduler.addJob({
899
- name: params.description as string,
900
- description: params.description as string,
901
- schedule: params.schedule as string,
902
- subagent_type: subagentType,
903
- prompt: params.prompt as string,
904
- model: params.model as string | undefined,
905
- thinking: thinking,
906
- max_turns: effectiveMaxTurns,
907
- isolated: isolated,
908
- isolation: isolation,
909
- });
910
- const next = scheduler.getNextRun(job.id);
911
- return textResult(
912
- `Scheduled "${job.name}" (id: ${job.id}, type: ${job.scheduleType}). ` +
913
- `Next run: ${next ?? "(unknown)"}. ` +
914
- `Manage via /agents → Scheduled jobs.`,
915
- );
916
- } catch (err) {
917
- return textResult(err instanceof Error ? err.message : String(err));
918
- }
919
- }
920
-
921
702
  // Resume existing agent
922
703
  if (params.resume) {
923
704
  const existing = manager.getRecord(params.resume);
@@ -971,28 +752,15 @@ Guidelines:
971
752
  return textResult(err instanceof Error ? err.message : String(err));
972
753
  }
973
754
 
974
- // Set output file + join mode synchronously after spawn, before the
755
+ // Set output file synchronously after spawn, before the
975
756
  // event loop yields — onSessionCreated is async so this is safe.
976
- const joinMode = resolveJoinMode(defaultJoinMode, true);
977
757
  const record = manager.getRecord(id);
978
- if (record && joinMode) {
979
- record.joinMode = joinMode;
758
+ if (record) {
980
759
  record.toolCallId = toolCallId;
981
760
  record.outputFile = createOutputFilePath(ctx.cwd, id, ctx.sessionManager.getSessionId());
982
761
  writeInitialEntry(record.outputFile, id, params.prompt, ctx.cwd);
983
762
  }
984
763
 
985
- if (joinMode == null || joinMode === 'async') {
986
- // Foreground/no join mode or explicit async — not part of any batch
987
- } else {
988
- // smart or group — add to current batch
989
- currentBatchAgents.push({ id, joinMode });
990
- // Debounce: reset timer on each new agent so parallel tool calls
991
- // dispatched across multiple event loop ticks are captured together
992
- if (batchFinalizeTimer) clearTimeout(batchFinalizeTimer);
993
- batchFinalizeTimer = setTimeout(finalizeBatch, 100);
994
- }
995
-
996
764
  agentActivity.set(id, bgState);
997
765
  widget.ensureTimer();
998
766
  widget.update();
@@ -1294,12 +1062,6 @@ Guidelines:
1294
1062
  options.push(`Agent types (${allNames.length})`);
1295
1063
  }
1296
1064
 
1297
- // Scheduled jobs entry (always present when scheduler is active)
1298
- if (scheduler.isActive()) {
1299
- const jobCount = scheduler.list().length;
1300
- options.push(`Scheduled jobs (${jobCount})`);
1301
- }
1302
-
1303
1065
  // Actions
1304
1066
  options.push("Create new agent");
1305
1067
  options.push("Settings");
@@ -1323,9 +1085,6 @@ Guidelines:
1323
1085
  } else if (choice.startsWith("Agent types (")) {
1324
1086
  await showAllAgentsList(ctx);
1325
1087
  await showAgentsMenu(ctx);
1326
- } else if (choice.startsWith("Scheduled jobs (")) {
1327
- await showSchedulesMenu(ctx, scheduler);
1328
- await showAgentsMenu(ctx);
1329
1088
  } else if (choice === "Create new agent") {
1330
1089
  await showCreateWizard(ctx);
1331
1090
  } else if (choice === "Settings") {
@@ -1788,8 +1547,6 @@ ${systemPrompt}
1788
1547
  // normalizeMaxTurns() in agent-runner.ts (which maps 0 → undefined).
1789
1548
  defaultMaxTurns: getDefaultMaxTurns() ?? 0,
1790
1549
  graceTurns: getGraceTurns(),
1791
- defaultJoinMode: getDefaultJoinMode(),
1792
- schedulingEnabled: isSchedulingEnabled(),
1793
1550
  };
1794
1551
  }
1795
1552
 
@@ -1798,8 +1555,6 @@ ${systemPrompt}
1798
1555
  `Max concurrency (current: ${manager.getMaxConcurrent()})`,
1799
1556
  `Default max turns (current: ${getDefaultMaxTurns() ?? "unlimited"})`,
1800
1557
  `Grace turns (current: ${getGraceTurns()})`,
1801
- `Join mode (current: ${getDefaultJoinMode()})`,
1802
- `Scheduling (current: ${isSchedulingEnabled() ? "enabled" : "disabled"})`,
1803
1558
  ]);
1804
1559
  if (!choice) return;
1805
1560
 
@@ -1839,38 +1594,6 @@ ${systemPrompt}
1839
1594
  ctx.ui.notify("Must be a positive integer.", "warning");
1840
1595
  }
1841
1596
  }
1842
- } else if (choice.startsWith("Join mode")) {
1843
- const val = await ctx.ui.select("Default join mode for background agents", [
1844
- "smart — auto-group 2+ agents in same turn (default)",
1845
- "async — always notify individually",
1846
- "group — always group background agents",
1847
- ]);
1848
- if (val) {
1849
- const mode = val.split(" ")[0] as JoinMode;
1850
- setDefaultJoinMode(mode);
1851
- notifyApplied(ctx, `Default join mode set to ${mode}`);
1852
- }
1853
- } else if (choice.startsWith("Scheduling")) {
1854
- const val = await ctx.ui.select(
1855
- "Schedule subagent feature",
1856
- [
1857
- "enabled — Agent tool accepts a `schedule` param; /agents → Scheduled jobs visible",
1858
- "disabled — `schedule` removed from Agent tool spec (no LLM-context cost); menu hidden",
1859
- ],
1860
- );
1861
- if (val) {
1862
- const enabled = val.startsWith("enabled");
1863
- if (enabled === isSchedulingEnabled()) {
1864
- ctx.ui.notify(`Scheduling already ${enabled ? "enabled" : "disabled"}.`, "info");
1865
- } else {
1866
- setSchedulingEnabled(enabled);
1867
- if (!enabled) scheduler.stop(); // immediate kill — outstanding fires stop ticking
1868
- notifyApplied(
1869
- ctx,
1870
- `Scheduling ${enabled ? "enabled" : "disabled"}. Tool spec change takes effect on next pi session.`,
1871
- );
1872
- }
1873
- }
1874
1597
  }
1875
1598
  }
1876
1599
 
@@ -1,4 +1,4 @@
1
- import type { AgentConfig, IsolationMode, JoinMode, ThinkingLevel } from "./types.js";
1
+ import type { AgentConfig, IsolationMode, ThinkingLevel } from "./types.js";
2
2
 
3
3
  interface AgentInvocationParams {
4
4
  model?: string;
@@ -34,7 +34,3 @@ export function resolveAgentInvocationConfig(
34
34
  isolation: agentConfig?.isolation ?? params.isolation,
35
35
  };
36
36
  }
37
-
38
- export function resolveJoinMode(defaultJoinMode: JoinMode, runInBackground: boolean): JoinMode | undefined {
39
- return runInBackground ? defaultJoinMode : undefined;
40
- }
package/src/settings.ts CHANGED
@@ -5,8 +5,6 @@
5
5
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
6
6
  import { dirname, join } from "node:path";
7
7
  import { getAgentDir } from "@earendil-works/pi-coding-agent";
8
- import type { JoinMode } from "./types.js";
9
-
10
8
  export interface SubagentsSettings {
11
9
  maxConcurrent?: number;
12
10
  /**
@@ -16,16 +14,6 @@ export interface SubagentsSettings {
16
14
  */
17
15
  defaultMaxTurns?: number;
18
16
  graceTurns?: number;
19
- defaultJoinMode?: JoinMode;
20
- /**
21
- * Master switch for the schedule subagent feature. Defaults to `true`.
22
- * When `false`: the `Agent` tool's `schedule` param + its guideline are
23
- * stripped from the tool spec at registration (zero LLM-context cost), the
24
- * scheduler doesn't bind to the session, and the `/agents → Scheduled jobs`
25
- * menu entry is hidden. Schema-level removal applies at extension load
26
- * (next pi session); runtime menu/runtime-fire short-circuit is immediate.
27
- */
28
- schedulingEnabled?: boolean;
29
17
  }
30
18
 
31
19
  /** Setter hooks used by applySettings to wire persisted values into in-memory state. */
@@ -33,15 +21,11 @@ export interface SettingsAppliers {
33
21
  setMaxConcurrent: (n: number) => void;
34
22
  setDefaultMaxTurns: (n: number) => void;
35
23
  setGraceTurns: (n: number) => void;
36
- setDefaultJoinMode: (mode: JoinMode) => void;
37
- setSchedulingEnabled: (b: boolean) => void;
38
24
  }
39
25
 
40
26
  /** Emit callback — a subset of `pi.events.emit` to keep helpers testable. */
41
27
  export type SettingsEmit = (event: string, payload: unknown) => void;
42
28
 
43
- const VALID_JOIN_MODES: ReadonlySet<string> = new Set<JoinMode>(["async", "group", "smart"]);
44
-
45
29
  // Sanity ceilings — prevent hand-edited configs from asking for values that
46
30
  // make no operational sense (e.g. 1e6 concurrent subagents). Permissive enough
47
31
  // that any realistic power-user setting passes through.
@@ -75,12 +59,6 @@ function sanitize(raw: unknown): SubagentsSettings {
75
59
  ) {
76
60
  out.graceTurns = r.graceTurns as number;
77
61
  }
78
- if (typeof r.defaultJoinMode === "string" && VALID_JOIN_MODES.has(r.defaultJoinMode)) {
79
- out.defaultJoinMode = r.defaultJoinMode as JoinMode;
80
- }
81
- if (typeof r.schedulingEnabled === "boolean") {
82
- out.schedulingEnabled = r.schedulingEnabled;
83
- }
84
62
  return out;
85
63
  }
86
64
 
@@ -134,8 +112,6 @@ export function applySettings(s: SubagentsSettings, appliers: SettingsAppliers):
134
112
  if (typeof s.maxConcurrent === "number") appliers.setMaxConcurrent(s.maxConcurrent);
135
113
  if (typeof s.defaultMaxTurns === "number") appliers.setDefaultMaxTurns(s.defaultMaxTurns);
136
114
  if (typeof s.graceTurns === "number") appliers.setGraceTurns(s.graceTurns);
137
- if (s.defaultJoinMode) appliers.setDefaultJoinMode(s.defaultJoinMode);
138
- if (typeof s.schedulingEnabled === "boolean") appliers.setSchedulingEnabled(s.schedulingEnabled);
139
115
  }
140
116
 
141
117
  /**
package/src/types.ts CHANGED
@@ -55,8 +55,6 @@ export interface AgentConfig {
55
55
  source?: "default" | "project" | "global";
56
56
  }
57
57
 
58
- export type JoinMode = 'async' | 'group' | 'smart';
59
-
60
58
  export interface AgentRecord {
61
59
  id: string;
62
60
  type: SubagentType;
@@ -70,8 +68,6 @@ export interface AgentRecord {
70
68
  session?: AgentSession;
71
69
  abortController?: AbortController;
72
70
  promise?: Promise<string>;
73
- groupId?: string;
74
- joinMode?: JoinMode;
75
71
  /** Set when result was already consumed via get_subagent_result — suppresses completion notification. */
76
72
  resultConsumed?: boolean;
77
73
  /** Steering messages queued before the session was ready. */
@@ -122,8 +118,7 @@ export interface NotificationDetails {
122
118
  outputFile?: string;
123
119
  error?: string;
124
120
  resultPreview: string;
125
- /** Additional agents in a group notification. */
126
- others?: NotificationDetails[];
121
+
127
122
  }
128
123
 
129
124
  export interface EnvInfo {
@@ -131,46 +126,3 @@ export interface EnvInfo {
131
126
  branch: string;
132
127
  platform: string;
133
128
  }
134
-
135
- /**
136
- * A subagent spawn registered to fire on a schedule.
137
- *
138
- * Stored at `<cwd>/.pi/subagent-schedules/<sessionId>.json`. Session-scoped:
139
- * survives `/resume` but resets on `/new`, mirroring pi-chonky-tasks.
140
- */
141
- export interface ScheduledSubagent {
142
- id: string;
143
- /** Unique within store. Defaults to `description`. */
144
- name: string;
145
- description: string;
146
- /** Raw user input — cron expr | "+10m" | ISO | "5m". */
147
- schedule: string;
148
- scheduleType: "cron" | "once" | "interval";
149
- /** Computed at create time for interval/once. */
150
- intervalMs?: number;
151
-
152
- // spawn params (subset of Agent tool params; no inherit_context, no resume)
153
- subagent_type: SubagentType;
154
- prompt: string;
155
- model?: string;
156
- thinking?: ThinkingLevel;
157
- max_turns?: number;
158
- isolated?: boolean;
159
- isolation?: IsolationMode;
160
-
161
- // state
162
- enabled: boolean;
163
- /** ISO timestamp. */
164
- createdAt: string;
165
- lastRun?: string;
166
- lastStatus?: "success" | "error" | "running";
167
- /** Refreshed on every fire and on store load. */
168
- nextRun?: string;
169
- runCount: number;
170
- }
171
-
172
- export interface ScheduleStoreData {
173
- /** For future migrations. */
174
- version: 1;
175
- jobs: ScheduledSubagent[];
176
- }