pi-subagent-manager 1.0.0 → 1.1.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.
@@ -39,7 +39,7 @@ function report(pi, level, message, source) {
39
39
  // historical transcript marker. No listener in a normal top-level session.
40
40
  let hosted = false;
41
41
  pi.events.emit("pi-subagent-manager:diagnostic:probe", {
42
- respond: () => { hosted = true; },
42
+ respond: (capability) => { hosted = capability?.protocol === 1 && typeof capability.version === "string"; },
43
43
  });
44
44
  if (hosted) {
45
45
  pi.events.emit("pi-subagent-manager:diagnostic", { level, message, source });
@@ -87,3 +87,12 @@ For **model-authored** progress or error reports, the existing child-only
87
87
  the task or triggering a parent turn. Use `agent_pause` when parent input is
88
88
  needed. No duplicate error-reporting tool is necessary; extension diagnostics
89
89
  are a separate host channel and do not require model tool permissions.
90
+
91
+ Since **1.1.0**, both the child diagnostic probe and the parent-session
92
+ `pi-subagent-manager:capabilities:probe` synchronously reply via
93
+ `respond({ version, protocol: 1 })`. `version` comes from this package's manifest.
94
+ Consumers must validate protocol 1 and a semver meeting their minimum version;
95
+ legacy argument-free replies are not compatible. The parent probe is available
96
+ while the manager is enabled; it does not install a child diagnostic sink.
97
+ Extensions in one session share Pi's public event bus, but each child has its own
98
+ bus. Discovery is capability detection among trusted extensions, not authentication.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-subagent-manager",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Hierarchical, steerable subagent threads for pi",
5
5
  "type": "module",
6
6
  "engines": {
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { diagnosticAgentText } from "./orch/diagnostics.ts";
1
+ import { CAPABILITY_PROBE_CHANNEL, respondDiagnosticCapability, diagnosticAgentText } from "./orch/diagnostics.ts";
2
2
  import { randomUUID } from "node:crypto";
3
3
  import { buildSessionContext, getAgentDir } from "@earendil-works/pi-coding-agent";
4
4
  import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
@@ -44,6 +44,10 @@ type RootNotification = {
44
44
  };
45
45
 
46
46
  export default function piSubagent(pi: ExtensionAPI): void {
47
+ let capabilityActive = true;
48
+ pi.events.on(CAPABILITY_PROBE_CHANNEL, (payload) => {
49
+ if (capabilityActive && limits.subagentMode !== "off") respondDiagnosticCapability(payload);
50
+ });
47
51
  let context: ExtensionContext | undefined;
48
52
  const inheritedTools = createInheritedToolSource(pi);
49
53
  let store = new ConfigStore({
@@ -698,6 +702,7 @@ export default function piSubagent(pi: ExtensionAPI): void {
698
702
  ctx.ui.notify(diagnostics.join("\n"), "warning");
699
703
  };
700
704
  pi.on("session_start", async (event, ctx) => {
705
+ capabilityActive = true;
701
706
  await attachSession(ctx, true, event.reason !== "startup");
702
707
  if (limits.subagentMode !== "off") await importAgents(ctx, true);
703
708
  });
@@ -722,6 +727,7 @@ export default function piSubagent(pi: ExtensionAPI): void {
722
727
  pi.on("session_before_switch", stopWorkingThreads);
723
728
  pi.on("session_before_fork", stopWorkingThreads);
724
729
  pi.on("session_shutdown", async () => {
730
+ capabilityActive = false;
725
731
  cancelSummary();
726
732
  housekeeping.cancelAll();
727
733
  generation++;
@@ -1,8 +1,19 @@
1
+ import { createRequire } from "node:module";
1
2
  import type { ChildDiagnostic } from "../types.ts";
2
3
 
3
4
  /** Child-local pi.events channel. Payloads are explicit, never captured from console/transcripts. */
4
5
  export const DIAGNOSTIC_CHANNEL = "pi-subagent-manager:diagnostic";
5
6
  export const DIAGNOSTIC_PROBE_CHANNEL = `${DIAGNOSTIC_CHANNEL}:probe`;
7
+ /** Session-wide discovery, not a child report channel or an authentication boundary. */
8
+ export const CAPABILITY_PROBE_CHANNEL = "pi-subagent-manager:capabilities:probe";
9
+ const packageVersion: string = createRequire(import.meta.url)("../../package.json").version;
10
+ export function respondDiagnosticCapability(payload: unknown): void {
11
+ try {
12
+ if (!payload || typeof payload !== "object") return;
13
+ const respond = (payload as { respond?: unknown }).respond;
14
+ if (typeof respond === "function") respond({ version: packageVersion, protocol: 1 });
15
+ } catch { /* Discovery callbacks must not escape into EventBus stderr. */ }
16
+ }
6
17
 
7
18
  function clean(value: string, limit: number): string {
8
19
  return value
@@ -49,6 +49,7 @@ import {
49
49
  import {
50
50
  DIAGNOSTIC_CHANNEL,
51
51
  DIAGNOSTIC_PROBE_CHANNEL,
52
+ respondDiagnosticCapability,
52
53
  diagnosticSink,
53
54
  diagnosticText,
54
55
  } from "./diagnostics.ts";
@@ -464,8 +465,7 @@ export function createDriverFactory(
464
465
  typeof payload !== "object"
465
466
  )
466
467
  return;
467
- const respond = (payload as { respond?: unknown }).respond;
468
- if (typeof respond === "function") respond();
468
+ respondDiagnosticCapability(payload);
469
469
  } catch {
470
470
  /* Untrusted callbacks cannot escape into EventBus's stderr handler. */
471
471
  }