pi-subagents 0.80.0 → 0.82.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.
Files changed (184) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/bundle/agents.js +18 -0
  3. package/bundle/background-work.js +16 -0
  4. package/bundle/capability-ceiling.js +22 -0
  5. package/bundle/child-tool-plan.js +11 -0
  6. package/bundle/chunk-43SCHIMD.js +57 -0
  7. package/bundle/chunk-4QFZZV3O.js +57 -0
  8. package/bundle/chunk-4SDU2BZX.js +1190 -0
  9. package/bundle/chunk-52UBALJL.js +753 -0
  10. package/bundle/chunk-5LFLVSTM.js +260 -0
  11. package/bundle/chunk-5TYMSZX3.js +235 -0
  12. package/bundle/chunk-62OCY2S4.js +14 -0
  13. package/bundle/chunk-7F6RKT6W.js +132 -0
  14. package/bundle/chunk-7IVSUMQQ.js +1337 -0
  15. package/bundle/chunk-7J4ZXMY7.js +18 -0
  16. package/bundle/chunk-7PCKZHR5.js +1234 -0
  17. package/bundle/chunk-7YMXOYEU.js +1373 -0
  18. package/bundle/chunk-B5EKXDHE.js +16870 -0
  19. package/bundle/chunk-CIZQXJ5Q.js +8619 -0
  20. package/bundle/chunk-CTPAE36Y.js +94 -0
  21. package/bundle/chunk-D4EHT5SJ.js +14 -0
  22. package/bundle/chunk-GC4DSPMH.js +946 -0
  23. package/bundle/chunk-GJECHSAR.js +179 -0
  24. package/bundle/chunk-M2CTFYT3.js +4164 -0
  25. package/bundle/chunk-MHZ4G23A.js +1296 -0
  26. package/bundle/chunk-N2BN7BF5.js +159 -0
  27. package/bundle/chunk-NF7IEKBH.js +490 -0
  28. package/bundle/chunk-NGGAFDL6.js +742 -0
  29. package/bundle/chunk-NIXWDZZV.js +9 -0
  30. package/bundle/chunk-NRQ75MGH.js +8327 -0
  31. package/bundle/chunk-OYF6AFDY.js +458 -0
  32. package/bundle/chunk-PLCCBLPY.js +526 -0
  33. package/bundle/chunk-RMQFMMAT.js +416 -0
  34. package/bundle/chunk-SIJ4S3EN.js +276 -0
  35. package/bundle/chunk-UKG4V45O.js +228 -0
  36. package/bundle/chunk-VH5OAWVG.js +4096 -0
  37. package/bundle/chunk-W2SZ22EM.js +5462 -0
  38. package/bundle/chunk-WVD4UEL4.js +9367 -0
  39. package/bundle/chunk-XSWOTIA3.js +175 -0
  40. package/bundle/chunk-YFCK7H2S.js +129 -0
  41. package/bundle/chunk-YKEWIB4M.js +380 -0
  42. package/bundle/chunk-YYREO77V.js +137 -0
  43. package/bundle/chunk-Z7KVHQHL.js +173 -0
  44. package/bundle/chunk-ZLINIYTP.js +8613 -0
  45. package/bundle/chunk-ZQGSDHL6.js +128 -0
  46. package/bundle/control-channel.js +11 -0
  47. package/bundle/delegation.js +14 -0
  48. package/bundle/external-job-provider.js +20 -0
  49. package/bundle/external-runs.js +21 -0
  50. package/bundle/index.js +30 -0
  51. package/bundle/inspectors.js +8 -0
  52. package/bundle/intercom-bridge.js +11 -0
  53. package/bundle/preflight.js +425 -0
  54. package/bundle/project-panes.js +28 -0
  55. package/bundle/required-child-extensions.js +6 -0
  56. package/bundle/shared-types.js +8 -0
  57. package/bundle/workflow-resources.js +7 -0
  58. package/docs/agents.md +31 -0
  59. package/docs/configuration.md +9 -1
  60. package/docs/extension-api.md +27 -0
  61. package/docs/observability.md +6 -2
  62. package/docs/tool-reference.md +3 -1
  63. package/docs/workflows.md +16 -0
  64. package/package.json +19 -19
  65. package/skills/pi-subagents/references/execution-controls.md +5 -4
  66. package/src/agents/agent-management.js +3 -3
  67. package/src/agents/agent-memory.js +3 -1
  68. package/src/agents/agents.js +6 -6
  69. package/src/agents/frontmatter.d.ts +4 -0
  70. package/src/agents/frontmatter.js +24 -3
  71. package/src/agents/skills.js +2 -1
  72. package/src/api/delegation.d.ts +20 -0
  73. package/src/extension/config.js +3 -0
  74. package/src/extension/herdr-pi-bridge.js +17 -10
  75. package/src/extension/index.js +109 -9
  76. package/src/extension/schemas.js +3 -3
  77. package/src/intercom/native-supervisor-channel.js +20 -0
  78. package/src/missions/lifecycle.js +7 -1
  79. package/src/runs/background/active-async-capacity.d.ts +1 -0
  80. package/src/runs/background/active-async-capacity.js +9 -3
  81. package/src/runs/background/async-execution.js +20 -10
  82. package/src/runs/background/async-job-tracker.d.ts +6 -1
  83. package/src/runs/background/async-job-tracker.js +9 -4
  84. package/src/runs/background/async-status.d.ts +2 -0
  85. package/src/runs/background/async-status.js +21 -2
  86. package/src/runs/background/await-async-run.js +3 -7
  87. package/src/runs/background/boot-id.d.ts +12 -0
  88. package/src/runs/background/boot-id.js +47 -0
  89. package/src/runs/background/interrupted-elsewhere.d.ts +22 -0
  90. package/src/runs/background/interrupted-elsewhere.js +68 -0
  91. package/src/runs/background/notify.d.ts +2 -0
  92. package/src/runs/background/notify.js +13 -0
  93. package/src/runs/background/result-delivery-ownership.d.ts +6 -0
  94. package/src/runs/background/result-delivery-ownership.js +19 -1
  95. package/src/runs/background/result-watcher.d.ts +3 -1
  96. package/src/runs/background/result-watcher.js +24 -8
  97. package/src/runs/background/run-child-session.d.ts +1 -6
  98. package/src/runs/background/run-child-session.js +19 -1
  99. package/src/runs/background/run-status.js +2 -1
  100. package/src/runs/background/stale-run-reconciler.d.ts +25 -0
  101. package/src/runs/background/stale-run-reconciler.js +54 -13
  102. package/src/runs/background/subagent-runner-bootstrap.js +3 -0
  103. package/src/runs/background/subagent-runner.d.ts +4 -0
  104. package/src/runs/background/subagent-runner.js +13 -5
  105. package/src/runs/background/subagent-wait.d.ts +1 -1
  106. package/src/runs/background/subagent-wait.js +6 -1
  107. package/src/runs/background/terminal-run-index.d.ts +1 -0
  108. package/src/runs/background/terminal-run-index.js +4 -2
  109. package/src/runs/foreground/async-stop-action.js +3 -1
  110. package/src/runs/foreground/execution.js +45 -5
  111. package/src/runs/foreground/foreground-history.d.ts +16 -2
  112. package/src/runs/foreground/foreground-history.js +133 -31
  113. package/src/runs/foreground/subagent-executor.d.ts +11 -0
  114. package/src/runs/foreground/subagent-executor.js +277 -74
  115. package/src/runs/shared/child-launch.d.ts +2 -2
  116. package/src/runs/shared/child-session.d.ts +3 -2
  117. package/src/runs/shared/child-session.js +51 -8
  118. package/src/runs/shared/child-tool-plan.d.ts +7 -0
  119. package/src/runs/shared/child-tool-plan.js +21 -6
  120. package/src/runs/shared/herdr-connection.d.ts +17 -8
  121. package/src/runs/shared/herdr-connection.js +19 -7
  122. package/src/runs/shared/herdr-external-adapters.d.ts +3 -2
  123. package/src/runs/shared/herdr-external-adapters.js +1 -1
  124. package/src/runs/shared/herdr-machine.d.ts +12 -2
  125. package/src/runs/shared/herdr-machine.js +55 -9
  126. package/src/runs/shared/herdr-pane-host.d.ts +88 -0
  127. package/src/runs/shared/herdr-pane-host.js +155 -0
  128. package/src/runs/shared/herdr-placed-run.d.ts +27 -150
  129. package/src/runs/shared/herdr-placed-run.js +48 -395
  130. package/src/runs/shared/local-machine-access.d.ts +5 -0
  131. package/src/runs/shared/local-machine-access.js +28 -0
  132. package/src/runs/shared/orca-progress-tabs.d.ts +0 -1
  133. package/src/runs/shared/orca-progress-tabs.js +1 -24
  134. package/src/runs/shared/parallel-utils.d.ts +1 -1
  135. package/src/runs/shared/placed-run-owner.d.ts +49 -0
  136. package/src/runs/shared/placed-run-owner.js +93 -0
  137. package/src/runs/shared/placement-host.d.ts +99 -0
  138. package/src/runs/shared/placement-host.js +157 -0
  139. package/src/runs/shared/rex-machine.d.ts +25 -0
  140. package/src/runs/shared/rex-machine.js +83 -0
  141. package/src/runs/shared/rex-pane-host.d.ts +62 -0
  142. package/src/runs/shared/rex-pane-host.js +327 -0
  143. package/src/runs/shared/structured-output.d.ts +1 -0
  144. package/src/runs/shared/structured-output.js +1 -0
  145. package/src/shared/accessible-dir.js +4 -1
  146. package/src/shared/completion-owner.d.ts +5 -0
  147. package/src/shared/completion-owner.js +5 -0
  148. package/src/shared/provider-diagnostics.d.ts +9 -0
  149. package/src/shared/provider-diagnostics.js +75 -0
  150. package/src/shared/session-identity.d.ts +2 -0
  151. package/src/shared/session-identity.js +26 -0
  152. package/src/shared/types.d.ts +48 -6
  153. package/src/slash/delegation-adapters.d.ts +3 -1
  154. package/src/slash/delegation-adapters.js +7 -0
  155. package/src/slash/prompt-template-bridge.js +3 -1
  156. package/src/slash/subagents-admin.d.ts +1 -0
  157. package/src/slash/subagents-admin.js +1 -1
  158. package/src/tui/fleet-layout.d.ts +20 -0
  159. package/src/tui/fleet-layout.js +17 -0
  160. package/src/tui/fleet-viewport.d.ts +12 -0
  161. package/src/tui/fleet-viewport.js +35 -0
  162. package/src/tui/fleet.d.ts +6 -6
  163. package/src/tui/fleet.js +93 -66
  164. package/src/tui/render.d.ts +6 -0
  165. package/src/tui/render.js +3 -3
  166. package/src/tui/subagent-messages.js +1 -0
  167. package/src/workflows/scripted-workflow.d.ts +1 -1
  168. package/src/workflows/structured-workflow-scripts.d.ts +1 -0
  169. package/src/workflows/structured-workflow-scripts.js +5 -4
  170. package/src/workflows/workflow-auto-resume.d.ts +32 -0
  171. package/src/workflows/workflow-auto-resume.js +102 -0
  172. package/src/workflows/workflow-launch-record.d.ts +27 -0
  173. package/src/workflows/workflow-launch-record.js +48 -0
  174. package/src/workflows/workflow-resources.js +2 -2
  175. package/src/workflows/workflow-resume-claim.d.ts +82 -0
  176. package/src/workflows/workflow-resume-claim.js +210 -0
  177. package/src/workflows/workflow-resume.d.ts +56 -0
  178. package/src/workflows/workflow-resume.js +106 -0
  179. package/src/workflows/workflow-reuse.d.ts +15 -9
  180. package/src/workflows/workflow-reuse.js +77 -14
  181. package/src/workflows/workflow-revival.d.ts +2 -0
  182. package/src/workflows/workflow-revival.js +2 -1
  183. package/src/workflows/workflow-stop-cause.d.ts +6 -0
  184. package/src/workflows/workflow-stop-cause.js +8 -0
@@ -0,0 +1,173 @@
1
+ // src/runs/shared/capability-ceiling.ts
2
+ import { Buffer } from "node:buffer";
3
+ var SUBAGENT_CAPABILITY_CEILING_VERSION = 1;
4
+ var SUBAGENT_CAPABILITY_CEILING_REGISTRY_KEY = "pi-subagents.capability-ceiling.v1";
5
+ function registry() {
6
+ const key = Symbol.for(SUBAGENT_CAPABILITY_CEILING_REGISTRY_KEY);
7
+ const store = globalThis;
8
+ const existing = store[key];
9
+ if (existing instanceof Map) return existing;
10
+ const created = /* @__PURE__ */ new Map();
11
+ store[key] = created;
12
+ return created;
13
+ }
14
+ function validateText(value, field) {
15
+ if (typeof value !== "string" || !value.trim() || /[\u0000-\u001f\u007f]/u.test(value) || Buffer.byteLength(value.trim(), "utf8") > 256) {
16
+ throw new Error(`Invalid capability ceiling ${field}; expected a non-empty string without control characters (max 256 UTF-8 bytes).`);
17
+ }
18
+ return value.trim();
19
+ }
20
+ function normalizeCapabilityCeilingAllowedAgents(values) {
21
+ return normalizeCeiling({ allowedAgents: values }).allowedAgents;
22
+ }
23
+ function normalizeCeiling(ceiling) {
24
+ if (!ceiling || typeof ceiling !== "object" || Array.isArray(ceiling)) throw new Error("Invalid capability ceiling; expected an object.");
25
+ const hasAllowedTools = Object.hasOwn(ceiling, "allowedTools");
26
+ const hasAllowedAgents = Object.hasOwn(ceiling, "allowedAgents");
27
+ const hasDenyExtensions = Object.hasOwn(ceiling, "denyExtensions");
28
+ if (!hasAllowedTools && !hasAllowedAgents && !hasDenyExtensions) throw new Error("Invalid capability ceiling; expected allowedTools, allowedAgents, or denyExtensions.");
29
+ if (hasDenyExtensions && typeof ceiling.denyExtensions !== "boolean") throw new Error("Invalid capability ceiling denyExtensions; expected a boolean.");
30
+ const normalizeList = (field, pattern) => {
31
+ if (!Object.hasOwn(ceiling, field)) return void 0;
32
+ const values = ceiling[field];
33
+ if (!Array.isArray(values)) throw new Error(`Invalid capability ceiling ${field}; expected an array.`);
34
+ if (values.length > 256) throw new Error(`Invalid capability ceiling ${field}; expected at most 256 names.`);
35
+ return [...new Set(values.map((entry) => {
36
+ const name = validateText(entry, `${field} entry`);
37
+ if (!pattern.test(name)) throw new Error(`Invalid capability ceiling ${field} entry '${name}'.`);
38
+ if (Buffer.byteLength(name, "utf8") > 128) throw new Error(`Invalid capability ceiling ${field} entry '${name}'; max 128 UTF-8 bytes.`);
39
+ return name;
40
+ }))].sort();
41
+ };
42
+ const allowedTools = normalizeList("allowedTools", /^[A-Za-z0-9_.:-]+$/u);
43
+ const allowedAgents = normalizeList("allowedAgents", /^[A-Za-z0-9_.:-]+$/u);
44
+ return {
45
+ version: SUBAGENT_CAPABILITY_CEILING_VERSION,
46
+ ...allowedTools !== void 0 ? { allowedTools } : {},
47
+ ...allowedAgents !== void 0 ? { allowedAgents } : {},
48
+ denyExtensions: ceiling.denyExtensions === true,
49
+ sources: []
50
+ };
51
+ }
52
+ function parseSubagentCapabilityCeiling(value, field = "capability ceiling") {
53
+ if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error(`Invalid ${field}; expected an object.`);
54
+ const record = value;
55
+ if (record.version !== SUBAGENT_CAPABILITY_CEILING_VERSION) throw new Error(`Invalid ${field} version.`);
56
+ const normalized = normalizeCeiling(record);
57
+ const sources = record.sources;
58
+ if (!Array.isArray(sources) || sources.some((source) => typeof source !== "string")) throw new Error(`Invalid ${field} sources; expected an array of strings.`);
59
+ normalized.sources = [...new Set(sources.map((source) => validateText(source, `${field} source`)))].sort();
60
+ return normalized;
61
+ }
62
+ function registerSubagentCapabilityCeiling(options) {
63
+ const sessionId = validateText(options.sessionId, "sessionId");
64
+ const source = validateText(options.source, "source");
65
+ let normalized = normalizeCeiling(options.ceiling);
66
+ const token = Symbol(source);
67
+ const store = registry();
68
+ let session = store.get(sessionId);
69
+ if (!session) {
70
+ session = /* @__PURE__ */ new Map();
71
+ store.set(sessionId, session);
72
+ }
73
+ const setRegistration = () => {
74
+ normalized = normalizeCeiling(normalized);
75
+ normalized.sources = [source];
76
+ session.set(token, { source, ceiling: normalized });
77
+ };
78
+ setRegistration();
79
+ let disposed = false;
80
+ return {
81
+ update(ceiling) {
82
+ if (disposed) throw new Error("Cannot update a disposed capability ceiling handle.");
83
+ normalized = normalizeCeiling(ceiling);
84
+ normalized.sources = [source];
85
+ session.set(token, { source, ceiling: normalized });
86
+ },
87
+ dispose() {
88
+ if (disposed) return;
89
+ disposed = true;
90
+ session.delete(token);
91
+ if (session.size === 0) store.delete(sessionId);
92
+ }
93
+ };
94
+ }
95
+ function intersectSubagentCapabilityCeilings(...ceilings) {
96
+ const active = ceilings.filter((ceiling) => ceiling !== void 0);
97
+ if (active.length === 0) return void 0;
98
+ const intersectLists = (field) => {
99
+ const definedLists = active.filter((ceiling) => ceiling[field] !== void 0).map((ceiling) => new Set(ceiling[field]));
100
+ if (definedLists.length === 0) return void 0;
101
+ return [...definedLists[0]].filter((entry) => definedLists.every((list) => list.has(entry))).sort();
102
+ };
103
+ const allowedTools = intersectLists("allowedTools");
104
+ const allowedAgents = intersectLists("allowedAgents");
105
+ return {
106
+ version: SUBAGENT_CAPABILITY_CEILING_VERSION,
107
+ ...allowedTools !== void 0 ? { allowedTools } : {},
108
+ ...allowedAgents !== void 0 ? { allowedAgents } : {},
109
+ denyExtensions: active.some((ceiling) => ceiling.denyExtensions),
110
+ sources: [...new Set(active.flatMap((ceiling) => ceiling.sources))].sort()
111
+ };
112
+ }
113
+ function resolveSubagentCapabilityCeiling(sessionId, inherited) {
114
+ const active = [];
115
+ if (sessionId) {
116
+ const registrations = registry().get(sessionId);
117
+ if (registrations) active.push(...Array.from(registrations.values(), ({ ceiling }) => ceiling));
118
+ }
119
+ return intersectSubagentCapabilityCeilings(inherited, ...active);
120
+ }
121
+ function resolveCurrentSubagentCapabilityCeiling(sessionId) {
122
+ return resolveSubagentCapabilityCeiling(sessionId, void 0);
123
+ }
124
+ function isAgentAllowedByCapabilityCeiling(agentName, ceiling) {
125
+ return ceiling?.allowedAgents === void 0 || ceiling.allowedAgents.includes(agentName);
126
+ }
127
+ function capabilityCeilingAgentRestrictionMessage(agentName, ceiling) {
128
+ if (isAgentAllowedByCapabilityCeiling(agentName, ceiling)) return void 0;
129
+ const sources = ceiling?.sources.length ? ceiling.sources.join(", ") : "unknown source";
130
+ const allowed = ceiling?.allowedAgents?.length ? ceiling.allowedAgents.join(", ") : "(none)";
131
+ return `Capability ceiling from ${sources} does not allow agent '${agentName}'. Allowed agents: ${allowed}.`;
132
+ }
133
+ function assertAgentAllowedByCapabilityCeiling(agentName, ceiling) {
134
+ const message = capabilityCeilingAgentRestrictionMessage(agentName, ceiling);
135
+ if (message) throw new Error(message);
136
+ }
137
+ function capabilityCeilingAgentRestrictionSources(ceiling) {
138
+ return ceiling?.allowedAgents === void 0 ? void 0 : [...ceiling.sources];
139
+ }
140
+ function encodeSubagentCapabilityCeiling(ceiling) {
141
+ if (!ceiling) return void 0;
142
+ return Buffer.from(JSON.stringify(ceiling), "utf8").toString("base64url");
143
+ }
144
+ function decodeSubagentCapabilityCeiling(value) {
145
+ if (value === void 0 || value === "") return void 0;
146
+ let parsed;
147
+ try {
148
+ parsed = JSON.parse(Buffer.from(value, "base64url").toString("utf8"));
149
+ } catch (error) {
150
+ throw new Error(`Invalid inherited capability ceiling: ${error instanceof Error ? error.message : String(error)}`);
151
+ }
152
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed) || parsed.version !== SUBAGENT_CAPABILITY_CEILING_VERSION) {
153
+ throw new Error("Invalid inherited capability ceiling version.");
154
+ }
155
+ return parseSubagentCapabilityCeiling(parsed, "inherited capability ceiling");
156
+ }
157
+
158
+ export {
159
+ SUBAGENT_CAPABILITY_CEILING_VERSION,
160
+ SUBAGENT_CAPABILITY_CEILING_REGISTRY_KEY,
161
+ normalizeCapabilityCeilingAllowedAgents,
162
+ parseSubagentCapabilityCeiling,
163
+ registerSubagentCapabilityCeiling,
164
+ intersectSubagentCapabilityCeilings,
165
+ resolveSubagentCapabilityCeiling,
166
+ resolveCurrentSubagentCapabilityCeiling,
167
+ isAgentAllowedByCapabilityCeiling,
168
+ capabilityCeilingAgentRestrictionMessage,
169
+ assertAgentAllowedByCapabilityCeiling,
170
+ capabilityCeilingAgentRestrictionSources,
171
+ encodeSubagentCapabilityCeiling,
172
+ decodeSubagentCapabilityCeiling
173
+ };