@xzzpig/pi-subagents 0.10.0 → 0.11.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/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.11.0] - 2026-09-11
4
+
5
+ ### Added
6
+
7
+ - **Silent span marker for user-initiated dialogs (pi-notify protocol).**
8
+ The fleet inspector and the `/subagents admin` management dialogs emit the
9
+ literal `pi-notify:ui_span_silent` bus event (payload `{ reason: "fleet" |
10
+ "admin" }`) synchronously before opening their `ctx.ui.*` dialog, so the
11
+ pi-notify generic UI-prompt adapter produces no notification and no Herdr
12
+ wait entry for them. Emission is observational (bare try/catch) and uses the
13
+ literal event name with no dependency on the `@xzzpig/pi-notify` package, so
14
+ installs without pi-notify are unaffected. Both fleet open paths are wired
15
+ — the `/subagents-fleet` command and the fleet status widget — via the new
16
+ optional `FleetViewOptions.events` field; the subagent-executor agent-waiting
17
+ confirmations (worktree cleanup, authority confirmation) deliberately do not
18
+ emit the marker.
19
+
20
+
3
21
  ## [0.10.0] - 2026-09-10 (fork release)
4
22
 
5
23
  ### Added
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xzzpig/pi-subagents",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "Pi extension for single-agent delegation and scripted multi-agent workflows",
5
5
  "author": "Nico Bailon",
6
6
  "license": "MIT",
@@ -31,7 +31,7 @@ import { isStaleExtensionContextError, withCachedUiContext } from "../shared/ext
31
31
  import { currentCompletionOwnerId } from "../shared/completion-owner.ts";
32
32
  import { cleanupOldChainDirs } from "../shared/settings.ts";
33
33
  import { clearLegacyResultAnimationTimer, renderSubagentResult, renderSubagentSummary } from "../tui/render.ts";
34
- import { openSubagentFleet } from "../tui/fleet.ts";
34
+ import { openSubagentFleetFromStatus } from "../tui/fleet.ts";
35
35
  import { SubagentFleetStatus, resolveFleetViewPlacement } from "../tui/fleet-status.ts";
36
36
  import { createSubagentParamsSchema } from "./schemas.ts";
37
37
  import { createSubagentExecutor, type SubagentParamsLike } from "../runs/foreground/subagent-executor.ts";
@@ -69,7 +69,7 @@ import { disposeChildSessions } from "../runs/shared/child-session.ts";
69
69
  import { resolveCurrentSubagentCapabilityCeiling } from "../runs/shared/capability-ceiling.ts";
70
70
  import { formatDuration, shortenPath } from "../shared/formatters.ts";
71
71
  import { applyModelExclusionsConfig, loadConfig, resolveAsyncByDefault, resolveScheduledStoreRoot } from "./config.ts";
72
- import { applyInjectionBlock, renderInjectionBlock, resolveInjectableAgents, SUBAGENT_INJECTION_MARKER } from "./context-injection.ts";
72
+ import { applyInjectionBlock, renderInjectionBlock, resolveInjectableAgents } from "./context-injection.ts";
73
73
  import { buildSubagentToolDescription, buildSubagentToolPromptMetadata } from "./tool-description.ts";
74
74
  import { formatWorkflowPreflightSummary, normalizeWorkflowPreflight } from "../workflows/workflow-preflight.ts";
75
75
  import { finalizeToolResult } from "./tool-result.ts";
@@ -499,7 +499,7 @@ export default function registerSubagentExtension(pi: ExtensionAPI): void {
499
499
  const ctx = withLastUiContext((current) => current);
500
500
  if (!ctx) return;
501
501
  try {
502
- await openSubagentFleet(ctx, state, { initialKey: itemKey, asyncDirRoot: DIRS.async, resultsDir: DIRS.results, fleetKeybindings: config.fleetKeybindings });
502
+ await openSubagentFleetFromStatus(ctx, state, pi, { itemKey, asyncDirRoot: DIRS.async, resultsDir: DIRS.results, fleetKeybindings: config.fleetKeybindings });
503
503
  } catch (error) {
504
504
  if (isStaleExtensionContextError(error)) {
505
505
  if (state.lastUiContext === ctx) state.lastUiContext = null;
@@ -613,6 +613,9 @@ export default function registerSubagentExtension(pi: ExtensionAPI): void {
613
613
  executorScheduled = executor.executeScheduled;
614
614
 
615
615
  pi.registerMessageRenderer<SupervisorRequestMessageDetails>(SUPERVISOR_REQUEST_MESSAGE_TYPE, renderSupervisorRequest);
616
+ // SAFETY: `registerEntryRenderer` is not part of the typed ExtensionAPI in the
617
+ // pinned dependency version; this cast pins the runtime shape of the entry
618
+ // renderer registration surface, guarded below by a typeof check.
616
619
  const registerEntryRenderer = (pi as unknown as {
617
620
  registerEntryRenderer?: (customType: string, renderer: (entry: { data?: unknown }, options: { expanded: boolean }, theme: ExtensionContext["ui"]["theme"]) => Component | undefined) => void;
618
621
  }).registerEntryRenderer;
@@ -860,7 +860,7 @@ export function registerSlashCommands(
860
860
  }
861
861
  fleetOpen = true;
862
862
  try {
863
- await openSubagentFleet(ctx, state, { asyncDirRoot: DIRS.async, resultsDir: DIRS.results, fleetKeybindings: options.fleetKeybindings });
863
+ await openSubagentFleet(ctx, state, { asyncDirRoot: DIRS.async, resultsDir: DIRS.results, fleetKeybindings: options.fleetKeybindings, events: pi.events });
864
864
  } finally {
865
865
  fleetOpen = false;
866
866
  }
@@ -11,6 +11,16 @@ import {
11
11
  type BuiltinAgentOverrideBase,
12
12
  } from "../agents/agents.ts";
13
13
  import { serializeAgent } from "../agents/agent-serializer.ts";
14
+ import { emitUiSpanSilent, type UiSpanSilentEvents } from "../ui-silent-marker.ts";
15
+
16
+ /** Event bus captured for the duration of one admin flow. */
17
+ let adminDialogEvents: UiSpanSilentEvents | undefined;
18
+
19
+ /** Claims the next dialog span as silent (pi-notify protocol). */
20
+ function markAdminDialogSilent(): void {
21
+ emitUiSpanSilent(adminDialogEvents, "admin");
22
+ }
23
+
14
24
  import { editableAgentConfig, preservedAgentFrontmatterFields } from "../agents/agent-management.ts";
15
25
  import { findModelInfo, getSupportedThinkingLevels, toModelInfo } from "../shared/model-info.ts";
16
26
  import { SelectorComponent, type SelectorItem, type SelectorResult } from "./selector.ts";
@@ -203,6 +213,7 @@ function metadataFor(agent: AgentConfig): string {
203
213
  }
204
214
 
205
215
  async function selectFromList(ctx: ExtensionContext, title: string, subtitle: string | undefined, items: SelectorItem[]): Promise<string | undefined> {
216
+ markAdminDialogSilent();
206
217
  if (typeof ctx.ui.custom === "function") {
207
218
  const result = await ctx.ui.custom<SelectorResult>(
208
219
  (tui, theme, kb, done) => new SelectorComponent(tui, theme, kb, { title, subtitle, items, done }),
@@ -257,6 +268,7 @@ async function chooseOverrideScope(ctx: ExtensionContext, agent: AgentConfig): P
257
268
  return agent.source === "project" && agent.override.scope === "user" && d.projectSettingsPath ? "project" : agent.override.scope;
258
269
  }
259
270
  if (!d.projectSettingsPath || !ctx.hasUI) return "user";
271
+ markAdminDialogSilent();
260
272
  const choice = await ctx.ui.select(`Save subagent override for ${agent.name}`, ["user", "project"]);
261
273
  return choice === "user" || choice === "project" ? choice : undefined;
262
274
  }
@@ -373,6 +385,7 @@ async function editSystemPrompt(ctx: ExtensionContext, agent: AgentConfig): Prom
373
385
  const readOnlyMessage = readOnlyAgentMessage(agent, "systemPrompt");
374
386
  if (readOnlyMessage) return readOnlyMessage;
375
387
  }
388
+ markAdminDialogSilent();
376
389
  const edited = await ctx.ui.editor(`Edit '${agent.name}' system prompt`, agent.systemPrompt ?? "");
377
390
  if (edited === undefined) return null;
378
391
  const projectOwnsLowerScopeOverride = agent.source === "project" && agent.override?.scope === "user" && discoverAgentsAll(ctx.cwd).projectSettingsPath;
@@ -383,6 +396,15 @@ async function editSystemPrompt(ctx: ExtensionContext, agent: AgentConfig): Prom
383
396
  }
384
397
 
385
398
  export async function openSubagentsAdmin(pi: ExtensionAPI, ctx: ExtensionContext, args = ""): Promise<void> {
399
+ adminDialogEvents = pi.events;
400
+ try {
401
+ return await runAdminFlow(pi, ctx, args);
402
+ } finally {
403
+ adminDialogEvents = undefined;
404
+ }
405
+ }
406
+
407
+ async function runAdminFlow(pi: ExtensionAPI, ctx: ExtensionContext, args = ""): Promise<void> {
386
408
  const selection = await selectAgent(ctx, args);
387
409
  if (selection.kind === "cancelled") return;
388
410
  if (selection.kind === "ambiguous") {
@@ -411,6 +433,7 @@ export async function openSubagentsAdmin(pi: ExtensionAPI, ctx: ExtensionContext
411
433
  else if (requestedAction === "prompt" || requestedAction === "system-prompt" || requestedAction === "edit") action = "Edit system prompt";
412
434
  else if (requestedAction === "details" || requestedAction === "info") action = "Show details";
413
435
  if (!action) {
436
+ markAdminDialogSilent();
414
437
  action = await ctx.ui.select(
415
438
  `Administer ${agent.name}\n${metadataSummary(agent)}`,
416
439
  ["Change model", "Change thinking level", "Edit system prompt", "Show details", "Done"],
package/src/tui/fleet.ts CHANGED
@@ -1,9 +1,14 @@
1
1
  import * as fs from "node:fs";
2
2
  import * as path from "node:path";
3
3
  import type { AgentToolResult } from "@earendil-works/pi-agent-core";
4
- import { getMarkdownTheme, type ExtensionContext } from "@earendil-works/pi-coding-agent";
4
+ import {
5
+ getMarkdownTheme,
6
+ type ExtensionAPI,
7
+ type ExtensionContext,
8
+ } from "@earendil-works/pi-coding-agent";
5
9
  import { matchesKey, truncateToWidth, visibleWidth, wrapTextWithAnsi, type Component, type MarkdownTheme } from "@earendil-works/pi-tui";
6
10
  import { snapshotExternalRuns, type ExternalRun } from "../api/external-runs.ts";
11
+ import { emitUiSpanSilent, type UiSpanSilentEvents } from "../ui-silent-marker.ts";
7
12
  import { getArtifactPaths, getArtifactsDir } from "../shared/artifacts.ts";
8
13
  import { formatDuration, formatModelThinking, formatTokens, formatTokenUsage, shortenPath } from "../shared/formatters.ts";
9
14
  import { DIRS, type AsyncJobState, type AsyncJobStep, type Details, type FleetKeybindingAction, type FleetKeybindingsConfig, type ForegroundChildControl, type ForegroundResumeChild, type ForegroundResumeRun, type ForegroundRunControl, type SubagentState } from "../shared/types.ts";
@@ -115,6 +120,8 @@ export interface FleetViewOptions {
115
120
  actions?: FleetActionHandlers;
116
121
  copyText?: (text: string) => Promise<void> | void;
117
122
  herdrClient?: HerdrClient;
123
+ /** Event bus used to claim the fleet dialog as a silent span. */
124
+ events?: UiSpanSilentEvents;
118
125
  }
119
126
 
120
127
  function belongsToCurrentSession(sessionId: string | undefined, currentSessionId: string | null): boolean {
@@ -1518,6 +1525,9 @@ export async function openSubagentFleet(ctx: ExtensionContext, state: SubagentSt
1518
1525
  return control.promptAuditRedo(input.index, input.guidance);
1519
1526
  },
1520
1527
  } satisfies FleetActionHandlers;
1528
+ // The fleet inspector is a user-initiated monitoring panel, not an
1529
+ // agent-waiting prompt: claim the dialog span as silent.
1530
+ emitUiSpanSilent(options.events, "fleet");
1521
1531
  try {
1522
1532
  await ctx.ui.custom<undefined>(
1523
1533
  (tui, theme, _keybindings, done) => new SubagentFleetComponent(tui, theme, state, done, { ...options, actions, copyText }),
@@ -1530,3 +1540,30 @@ export async function openSubagentFleet(ctx: ExtensionContext, state: SubagentSt
1530
1540
  state.fleetInspectorOpen = wasOpen;
1531
1541
  }
1532
1542
  }
1543
+
1544
+ export interface OpenFleetFromStatusOptions {
1545
+ itemKey?: string;
1546
+ asyncDirRoot: string;
1547
+ resultsDir: string;
1548
+ fleetKeybindings?: FleetKeybindingsConfig;
1549
+ }
1550
+
1551
+ /**
1552
+ * Opens the fleet inspector from the idle status widget, claiming the
1553
+ * dialog as a silent span (pi-notify protocol). Shared by the status-widget
1554
+ * path so the marker wiring is testable in one place.
1555
+ */
1556
+ export function openSubagentFleetFromStatus(
1557
+ ctx: ExtensionContext,
1558
+ state: SubagentState,
1559
+ pi: ExtensionAPI,
1560
+ options: OpenFleetFromStatusOptions,
1561
+ ): Promise<void> {
1562
+ return openSubagentFleet(ctx, state, {
1563
+ initialKey: options.itemKey,
1564
+ asyncDirRoot: options.asyncDirRoot,
1565
+ resultsDir: options.resultsDir,
1566
+ fleetKeybindings: options.fleetKeybindings,
1567
+ events: pi.events,
1568
+ });
1569
+ }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * pi-notify silent-span marker protocol.
3
+ *
4
+ * Dialogs that are NOT agent-waiting prompts (monitoring panels such as the
5
+ * fleet inspector, admin management dialogs) claim the next core
6
+ * `ui_prompt_start` span as silent, so pi-notify produces no notification
7
+ * and no Herdr wait entry for it. The event name is a literal on purpose:
8
+ * pi-notify may not be installed, in which case this emit is a harmless
9
+ * no-op and pi-subagents must not depend on the pi-notify package.
10
+ */
11
+ export const PI_NOTIFY_UI_SPAN_SILENT_EVENT = "pi-notify:ui_span_silent";
12
+
13
+ /** Minimal event bus accepted by `emitUiSpanSilent`. */
14
+ export interface UiSpanSilentEvents {
15
+ emit(event: string, data: unknown): void;
16
+ }
17
+
18
+ /**
19
+ * Observational emit: claims the next dialog span as silent. A missing or
20
+ * failing bus must never break the dialog flow.
21
+ */
22
+ export function emitUiSpanSilent(
23
+ events: UiSpanSilentEvents | undefined,
24
+ reason: string,
25
+ ): void {
26
+ if (!events) return;
27
+ try {
28
+ events.emit(PI_NOTIFY_UI_SPAN_SILENT_EVENT, { reason });
29
+ } catch {
30
+ // Observational only.
31
+ }
32
+ }