@narumitw/pi-subagents 2.1.3 → 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.
Files changed (314) hide show
  1. package/README.md +181 -1250
  2. package/dist/child-communication-bridge.ts +136 -0
  3. package/dist/child-communication-bridge.ts.map +7 -0
  4. package/dist/chunks/chunk-UKTWUQRM.js +667 -0
  5. package/dist/chunks/chunk-UKTWUQRM.js.map +7 -0
  6. package/dist/index.ts +1448 -1598
  7. package/dist/index.ts.map +4 -4
  8. package/docs/design-principles.md +31 -0
  9. package/docs/ipc-transport-idea.md +103 -0
  10. package/docs/tools.md +109 -0
  11. package/package.json +11 -19
  12. package/src/broker-credentials.ts +71 -0
  13. package/src/child-communication-bridge.ts +153 -0
  14. package/src/child-communication-tools.ts +147 -0
  15. package/src/completion-renderer.ts +60 -0
  16. package/src/index.ts +1 -1
  17. package/src/message-broker.ts +628 -0
  18. package/src/model-output.ts +42 -0
  19. package/src/process.ts +688 -0
  20. package/src/runtime.ts +538 -0
  21. package/src/subagents.ts +33 -34
  22. package/src/tools.ts +416 -0
  23. package/src/types.ts +85 -0
  24. package/src/widget.ts +130 -0
  25. package/dist/chunks/auto-transport-FUUKFDIG.ts +0 -109
  26. package/dist/chunks/auto-transport-FUUKFDIG.ts.map +0 -7
  27. package/dist/chunks/capability-grant-PR72SWWS.ts +0 -19
  28. package/dist/chunks/capability-grant-PR72SWWS.ts.map +0 -7
  29. package/dist/chunks/child-peer-bridge.ts +0 -108
  30. package/dist/chunks/child-peer-bridge.ts.map +0 -7
  31. package/dist/chunks/chunk-2LMJU25E.ts +0 -1641
  32. package/dist/chunks/chunk-2LMJU25E.ts.map +0 -7
  33. package/dist/chunks/chunk-47SK2QYC.ts +0 -56
  34. package/dist/chunks/chunk-47SK2QYC.ts.map +0 -7
  35. package/dist/chunks/chunk-4AQSF7AS.ts +0 -29
  36. package/dist/chunks/chunk-4AQSF7AS.ts.map +0 -7
  37. package/dist/chunks/chunk-5DGRMKNV.ts +0 -126
  38. package/dist/chunks/chunk-5DGRMKNV.ts.map +0 -7
  39. package/dist/chunks/chunk-6H6TBBED.ts +0 -108
  40. package/dist/chunks/chunk-6H6TBBED.ts.map +0 -7
  41. package/dist/chunks/chunk-6KJ34M6S.ts +0 -159
  42. package/dist/chunks/chunk-6KJ34M6S.ts.map +0 -7
  43. package/dist/chunks/chunk-6NSJVPXX.ts +0 -480
  44. package/dist/chunks/chunk-6NSJVPXX.ts.map +0 -7
  45. package/dist/chunks/chunk-7AAJEUSL.ts +0 -238
  46. package/dist/chunks/chunk-7AAJEUSL.ts.map +0 -7
  47. package/dist/chunks/chunk-BFK2Z4ZF.ts +0 -189
  48. package/dist/chunks/chunk-BFK2Z4ZF.ts.map +0 -7
  49. package/dist/chunks/chunk-BOAXY55Y.ts +0 -153
  50. package/dist/chunks/chunk-BOAXY55Y.ts.map +0 -7
  51. package/dist/chunks/chunk-D4CR7T73.ts +0 -353
  52. package/dist/chunks/chunk-D4CR7T73.ts.map +0 -7
  53. package/dist/chunks/chunk-FEVPWRMU.ts +0 -300
  54. package/dist/chunks/chunk-FEVPWRMU.ts.map +0 -7
  55. package/dist/chunks/chunk-G6VZTCFH.ts +0 -70
  56. package/dist/chunks/chunk-G6VZTCFH.ts.map +0 -7
  57. package/dist/chunks/chunk-H3FP6DLR.ts +0 -160
  58. package/dist/chunks/chunk-H3FP6DLR.ts.map +0 -7
  59. package/dist/chunks/chunk-HA36LPCO.ts +0 -130
  60. package/dist/chunks/chunk-HA36LPCO.ts.map +0 -7
  61. package/dist/chunks/chunk-HOP5FXDT.ts +0 -27
  62. package/dist/chunks/chunk-HOP5FXDT.ts.map +0 -7
  63. package/dist/chunks/chunk-IGAMVWFN.ts +0 -139
  64. package/dist/chunks/chunk-IGAMVWFN.ts.map +0 -7
  65. package/dist/chunks/chunk-ILEQ27AL.ts +0 -45
  66. package/dist/chunks/chunk-ILEQ27AL.ts.map +0 -7
  67. package/dist/chunks/chunk-ITVWPNU4.ts +0 -819
  68. package/dist/chunks/chunk-ITVWPNU4.ts.map +0 -7
  69. package/dist/chunks/chunk-IWC32VPY.ts +0 -172
  70. package/dist/chunks/chunk-IWC32VPY.ts.map +0 -7
  71. package/dist/chunks/chunk-JSZIP73U.ts +0 -362
  72. package/dist/chunks/chunk-JSZIP73U.ts.map +0 -7
  73. package/dist/chunks/chunk-JU6LUNLP.ts +0 -380
  74. package/dist/chunks/chunk-JU6LUNLP.ts.map +0 -7
  75. package/dist/chunks/chunk-KMGKCEO4.ts +0 -38
  76. package/dist/chunks/chunk-KMGKCEO4.ts.map +0 -7
  77. package/dist/chunks/chunk-LASD73CM.ts +0 -339
  78. package/dist/chunks/chunk-LASD73CM.ts.map +0 -7
  79. package/dist/chunks/chunk-LEOYDZI3.ts +0 -22
  80. package/dist/chunks/chunk-LEOYDZI3.ts.map +0 -7
  81. package/dist/chunks/chunk-LL4LP2T7.ts +0 -737
  82. package/dist/chunks/chunk-LL4LP2T7.ts.map +0 -7
  83. package/dist/chunks/chunk-N2T5IN4X.ts +0 -18
  84. package/dist/chunks/chunk-N2T5IN4X.ts.map +0 -7
  85. package/dist/chunks/chunk-N7BLVXKK.ts +0 -73
  86. package/dist/chunks/chunk-N7BLVXKK.ts.map +0 -7
  87. package/dist/chunks/chunk-NLT67IZS.ts +0 -322
  88. package/dist/chunks/chunk-NLT67IZS.ts.map +0 -7
  89. package/dist/chunks/chunk-NTRPLF46.ts +0 -63
  90. package/dist/chunks/chunk-NTRPLF46.ts.map +0 -7
  91. package/dist/chunks/chunk-ONDTY4EL.ts +0 -91
  92. package/dist/chunks/chunk-ONDTY4EL.ts.map +0 -7
  93. package/dist/chunks/chunk-OVPHFGKO.ts +0 -1769
  94. package/dist/chunks/chunk-OVPHFGKO.ts.map +0 -7
  95. package/dist/chunks/chunk-P7OH4XMF.ts +0 -60
  96. package/dist/chunks/chunk-P7OH4XMF.ts.map +0 -7
  97. package/dist/chunks/chunk-PBZMBTNJ.ts +0 -422
  98. package/dist/chunks/chunk-PBZMBTNJ.ts.map +0 -7
  99. package/dist/chunks/chunk-PGLSFLYW.ts +0 -52
  100. package/dist/chunks/chunk-PGLSFLYW.ts.map +0 -7
  101. package/dist/chunks/chunk-RRR66UWR.ts +0 -28
  102. package/dist/chunks/chunk-RRR66UWR.ts.map +0 -7
  103. package/dist/chunks/chunk-RSUXZD6S.ts +0 -275
  104. package/dist/chunks/chunk-RSUXZD6S.ts.map +0 -7
  105. package/dist/chunks/chunk-RTCVYIZA.ts +0 -221
  106. package/dist/chunks/chunk-RTCVYIZA.ts.map +0 -7
  107. package/dist/chunks/chunk-RY2AEGMZ.ts +0 -34
  108. package/dist/chunks/chunk-RY2AEGMZ.ts.map +0 -7
  109. package/dist/chunks/chunk-SWGQLFSD.ts +0 -60
  110. package/dist/chunks/chunk-SWGQLFSD.ts.map +0 -7
  111. package/dist/chunks/chunk-TM2R67J3.ts +0 -52
  112. package/dist/chunks/chunk-TM2R67J3.ts.map +0 -7
  113. package/dist/chunks/chunk-TMZRHIIK.ts +0 -497
  114. package/dist/chunks/chunk-TMZRHIIK.ts.map +0 -7
  115. package/dist/chunks/chunk-TZ34IQ3M.ts +0 -59
  116. package/dist/chunks/chunk-TZ34IQ3M.ts.map +0 -7
  117. package/dist/chunks/chunk-UMBPMVJW.ts +0 -22
  118. package/dist/chunks/chunk-UMBPMVJW.ts.map +0 -7
  119. package/dist/chunks/chunk-VDG7LTYE.ts +0 -80
  120. package/dist/chunks/chunk-VDG7LTYE.ts.map +0 -7
  121. package/dist/chunks/chunk-X4NMONPE.ts +0 -73
  122. package/dist/chunks/chunk-X4NMONPE.ts.map +0 -7
  123. package/dist/chunks/chunk-YPJEN6NU.ts +0 -65
  124. package/dist/chunks/chunk-YPJEN6NU.ts.map +0 -7
  125. package/dist/chunks/chunk-YU53SHA7.ts +0 -328
  126. package/dist/chunks/chunk-YU53SHA7.ts.map +0 -7
  127. package/dist/chunks/completion-delivery-RSJU6BXL.ts +0 -17
  128. package/dist/chunks/completion-delivery-RSJU6BXL.ts.map +0 -7
  129. package/dist/chunks/config-status-FKGDECZ3.ts +0 -35
  130. package/dist/chunks/config-status-FKGDECZ3.ts.map +0 -7
  131. package/dist/chunks/config-ui-ABHYNGQ7.ts +0 -1212
  132. package/dist/chunks/config-ui-ABHYNGQ7.ts.map +0 -7
  133. package/dist/chunks/consult-LJU3IQY5.ts +0 -519
  134. package/dist/chunks/consult-LJU3IQY5.ts.map +0 -7
  135. package/dist/chunks/context-QDKLVQXE.ts +0 -11
  136. package/dist/chunks/context-QDKLVQXE.ts.map +0 -7
  137. package/dist/chunks/create-stateful-transport-JWC2EFYL.ts +0 -130
  138. package/dist/chunks/create-stateful-transport-JWC2EFYL.ts.map +0 -7
  139. package/dist/chunks/cwd-policy-NB6XZ5GF.ts +0 -17
  140. package/dist/chunks/cwd-policy-NB6XZ5GF.ts.map +0 -7
  141. package/dist/chunks/delegation-contract-LA56I5DT.ts +0 -24
  142. package/dist/chunks/delegation-contract-LA56I5DT.ts.map +0 -7
  143. package/dist/chunks/discovery-MIFB2U4Y.ts +0 -12
  144. package/dist/chunks/discovery-MIFB2U4Y.ts.map +0 -7
  145. package/dist/chunks/execution-Q2JZLKJA.ts +0 -4037
  146. package/dist/chunks/execution-Q2JZLKJA.ts.map +0 -7
  147. package/dist/chunks/in-process-transport-HJ6TZXC3.ts +0 -39
  148. package/dist/chunks/in-process-transport-HJ6TZXC3.ts.map +0 -7
  149. package/dist/chunks/inspect-UH2TKH6E.ts +0 -634
  150. package/dist/chunks/inspect-UH2TKH6E.ts.map +0 -7
  151. package/dist/chunks/peer-communication-KL36Z6CO.ts +0 -294
  152. package/dist/chunks/peer-communication-KL36Z6CO.ts.map +0 -7
  153. package/dist/chunks/persistence-UY3PY6E5.ts +0 -348
  154. package/dist/chunks/persistence-UY3PY6E5.ts.map +0 -7
  155. package/dist/chunks/registry-BT54L6CY.ts +0 -1445
  156. package/dist/chunks/registry-BT54L6CY.ts.map +0 -7
  157. package/dist/chunks/retained-semantic-state-GM75FZGE.ts +0 -81
  158. package/dist/chunks/retained-semantic-state-GM75FZGE.ts.map +0 -7
  159. package/dist/chunks/rpc-transport-7R7DVCEB.ts +0 -1222
  160. package/dist/chunks/rpc-transport-7R7DVCEB.ts.map +0 -7
  161. package/dist/chunks/runtime-policy-5YELCOVC.ts +0 -15
  162. package/dist/chunks/runtime-policy-5YELCOVC.ts.map +0 -7
  163. package/dist/chunks/semantic-snapshot-WPJ3UAFW.ts +0 -19
  164. package/dist/chunks/semantic-snapshot-WPJ3UAFW.ts.map +0 -7
  165. package/dist/chunks/spawn-idempotency-BNHOSMZW.ts +0 -13
  166. package/dist/chunks/spawn-idempotency-BNHOSMZW.ts.map +0 -7
  167. package/dist/chunks/stateful-lifecycle-JAR6K55H.ts +0 -15
  168. package/dist/chunks/stateful-lifecycle-JAR6K55H.ts.map +0 -7
  169. package/dist/chunks/subprocess-transport-VHZJRBTW.ts +0 -160
  170. package/dist/chunks/subprocess-transport-VHZJRBTW.ts.map +0 -7
  171. package/dist/chunks/usage-recording-store-CW3EH2SZ.ts +0 -164
  172. package/dist/chunks/usage-recording-store-CW3EH2SZ.ts.map +0 -7
  173. package/dist/chunks/workspace-WDKLN72J.ts +0 -11
  174. package/dist/chunks/workspace-WDKLN72J.ts.map +0 -7
  175. package/docs/async-runtime-protocol.md +0 -84
  176. package/docs/implementation-notes/pi-subagents-capability-matrix.md +0 -62
  177. package/docs/implementation-notes/pi-subagents-current-direction.md +0 -99
  178. package/docs/implementation-notes/pi-subagents-rpc-v1.md +0 -153
  179. package/docs/pi-subagents-diagrams.md +0 -183
  180. package/src/adaptive-scheduler.ts +0 -224
  181. package/src/admission-benchmark.ts +0 -95
  182. package/src/admission-policy.ts +0 -78
  183. package/src/agent-projection.ts +0 -53
  184. package/src/agents/built-ins.ts +0 -71
  185. package/src/agents/catalog.ts +0 -241
  186. package/src/agents/discovery.ts +0 -265
  187. package/src/agents/types.ts +0 -100
  188. package/src/agents.ts +0 -51
  189. package/src/async-subagent-benchmark.ts +0 -532
  190. package/src/auto-transport.ts +0 -121
  191. package/src/blocking-status.ts +0 -63
  192. package/src/cached-module-loader.ts +0 -18
  193. package/src/capabilities.ts +0 -145
  194. package/src/capability-grant.ts +0 -115
  195. package/src/capability-router.ts +0 -107
  196. package/src/child-peer-bridge.ts +0 -124
  197. package/src/child-peer-tools.ts +0 -132
  198. package/src/completion-delivery.ts +0 -409
  199. package/src/completion-render.ts +0 -190
  200. package/src/completion-requirement.ts +0 -479
  201. package/src/completion-routing.ts +0 -24
  202. package/src/config-registration.ts +0 -114
  203. package/src/config-status.ts +0 -217
  204. package/src/config-ui.ts +0 -983
  205. package/src/consult-policy.ts +0 -15
  206. package/src/consult-registration.ts +0 -125
  207. package/src/consult-render.ts +0 -194
  208. package/src/consult-resources.ts +0 -51
  209. package/src/consult-tool.ts +0 -95
  210. package/src/consult.ts +0 -566
  211. package/src/context.ts +0 -126
  212. package/src/create-stateful-transport.ts +0 -157
  213. package/src/cwd-policy.ts +0 -183
  214. package/src/delegation-contract.ts +0 -463
  215. package/src/execution/budget.ts +0 -56
  216. package/src/execution/runtime-policy.ts +0 -19
  217. package/src/execution-plan.ts +0 -322
  218. package/src/execution-ui.ts +0 -259
  219. package/src/execution.ts +0 -1679
  220. package/src/in-process-transport.ts +0 -941
  221. package/src/inspect-registration.ts +0 -64
  222. package/src/inspect-render.ts +0 -334
  223. package/src/inspect-tool.ts +0 -45
  224. package/src/inspect.ts +0 -769
  225. package/src/integration-controller.ts +0 -98
  226. package/src/limits.ts +0 -75
  227. package/src/orchestration-metrics.ts +0 -116
  228. package/src/outcome.ts +0 -61
  229. package/src/panel-child-group.ts +0 -35
  230. package/src/panel-contract.ts +0 -343
  231. package/src/panel-evidence.ts +0 -59
  232. package/src/panel-execution.ts +0 -769
  233. package/src/panel-failure.ts +0 -56
  234. package/src/panel-planning.ts +0 -175
  235. package/src/panel-presets.ts +0 -3
  236. package/src/panel-prompts.ts +0 -132
  237. package/src/panel-reconciliation.ts +0 -57
  238. package/src/panel-render.ts +0 -103
  239. package/src/parallel-limit-ui.ts +0 -113
  240. package/src/params.ts +0 -278
  241. package/src/peer-communication.ts +0 -352
  242. package/src/peer-transport.ts +0 -49
  243. package/src/persistence.ts +0 -522
  244. package/src/pi-args.ts +0 -43
  245. package/src/pi-invocation.ts +0 -168
  246. package/src/process-control.ts +0 -43
  247. package/src/prompt-resources.ts +0 -38
  248. package/src/prompt-source-safety.ts +0 -48
  249. package/src/protocol.ts +0 -76
  250. package/src/registry-types.ts +0 -204
  251. package/src/registry.ts +0 -1698
  252. package/src/render-common.ts +0 -252
  253. package/src/render.ts +0 -704
  254. package/src/result-contract.ts +0 -431
  255. package/src/retained-semantic-state.ts +0 -100
  256. package/src/rpc-timeout-finalization.ts +0 -207
  257. package/src/rpc-transport-metadata.ts +0 -65
  258. package/src/rpc-transport.ts +0 -1035
  259. package/src/rpc-turn-capture.ts +0 -217
  260. package/src/runner-outcome.ts +0 -31
  261. package/src/runner-result.ts +0 -55
  262. package/src/runner-types.ts +0 -102
  263. package/src/runner-usage.ts +0 -48
  264. package/src/runner.ts +0 -866
  265. package/src/safe-text.ts +0 -67
  266. package/src/semantic-snapshot.ts +0 -214
  267. package/src/session-guidance-contract.ts +0 -399
  268. package/src/settings/inspection.ts +0 -302
  269. package/src/settings/schema.ts +0 -195
  270. package/src/settings-reader.ts +0 -215
  271. package/src/settings.ts +0 -452
  272. package/src/spawn-idempotency.ts +0 -68
  273. package/src/stateful-agent-view.ts +0 -85
  274. package/src/stateful-config.ts +0 -13
  275. package/src/stateful-guidance.ts +0 -29
  276. package/src/stateful-lifecycle.ts +0 -74
  277. package/src/stateful-limit-ui.ts +0 -249
  278. package/src/stateful-limits.ts +0 -96
  279. package/src/stateful-prompt.ts +0 -49
  280. package/src/stateful-registration.ts +0 -1320
  281. package/src/stateful-render.ts +0 -318
  282. package/src/stateful-safety.ts +0 -47
  283. package/src/stateful-tool-params.ts +0 -215
  284. package/src/stateful.ts +0 -12
  285. package/src/subagent-details.ts +0 -43
  286. package/src/subagents-extension.ts +0 -355
  287. package/src/subprocess-transport.ts +0 -145
  288. package/src/supervision.ts +0 -104
  289. package/src/task-path.ts +0 -65
  290. package/src/timeout-checkpoint.ts +0 -305
  291. package/src/timeout-finalization.ts +0 -75
  292. package/src/tool-schema-compatibility.ts +0 -73
  293. package/src/transport-types.ts +0 -74
  294. package/src/transport-ui.ts +0 -135
  295. package/src/transport.ts +0 -43
  296. package/src/turn-budget.ts +0 -109
  297. package/src/usage-format.ts +0 -42
  298. package/src/usage-recording-config.ts +0 -13
  299. package/src/usage-recording-store.ts +0 -183
  300. package/src/usage-recording.ts +0 -478
  301. package/src/verification-harness.ts +0 -516
  302. package/src/verification-policy.ts +0 -67
  303. package/src/verification-receipt.ts +0 -275
  304. package/src/verified-execution-benchmark.ts +0 -86
  305. package/src/verified-execution-contract.ts +0 -191
  306. package/src/verified-execution-schema.ts +0 -32
  307. package/src/work-item-ledger.ts +0 -1404
  308. package/src/work-item-persistence.ts +0 -254
  309. package/src/workflow-completion-controller.ts +0 -397
  310. package/src/workflow-planning.ts +0 -172
  311. package/src/workflow-tree-identity.ts +0 -289
  312. package/src/workflow-ui.ts +0 -69
  313. package/src/workflow-verification.ts +0 -296
  314. package/src/workspace.ts +0 -174
@@ -1,39 +0,0 @@
1
- // @generated by scripts/build-runtime.mjs; do not edit.
2
- // @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
3
- import {
4
- InProcessTransport,
5
- buildCurrentTurnPrompt,
6
- copyRegisteredProviders,
7
- createInProcessServices,
8
- createSdkChildSession,
9
- resolveChildModel,
10
- seedChildSessionManager,
11
- validateInProcessTools
12
- } from "./chunk-LL4LP2T7.ts";
13
- import "./chunk-RY2AEGMZ.ts";
14
- import "./chunk-G6VZTCFH.ts";
15
- import "./chunk-NTRPLF46.ts";
16
- import "./chunk-RTCVYIZA.ts";
17
- import "./chunk-ONDTY4EL.ts";
18
- import "./chunk-5DGRMKNV.ts";
19
- import "./chunk-LASD73CM.ts";
20
- import "./chunk-RSUXZD6S.ts";
21
- import "./chunk-D4CR7T73.ts";
22
- import "./chunk-TMZRHIIK.ts";
23
- import "./chunk-VDG7LTYE.ts";
24
- import "./chunk-4AQSF7AS.ts";
25
- import "./chunk-SWGQLFSD.ts";
26
- import "./chunk-JSZIP73U.ts";
27
- import "./chunk-H3FP6DLR.ts";
28
- import "./chunk-RRR66UWR.ts";
29
- export {
30
- InProcessTransport,
31
- buildCurrentTurnPrompt,
32
- copyRegisteredProviders,
33
- createInProcessServices,
34
- createSdkChildSession,
35
- resolveChildModel,
36
- seedChildSessionManager,
37
- validateInProcessTools
38
- };
39
- //# sourceMappingURL=in-process-transport-HJ6TZXC3.ts.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": [],
4
- "sourcesContent": [],
5
- "mappings": "",
6
- "names": []
7
- }
@@ -1,634 +0,0 @@
1
- // @generated by scripts/build-runtime.mjs; do not edit.
2
- // @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
3
- import {
4
- resolveConsultTools
5
- } from "./chunk-UMBPMVJW.ts";
6
- import {
7
- inspectSessionWorkflows
8
- } from "./chunk-OVPHFGKO.ts";
9
- import {
10
- resolvePiInvocation
11
- } from "./chunk-IGAMVWFN.ts";
12
- import {
13
- INSPECT_ACTIONS,
14
- SubagentInspectParams,
15
- registerSubagentInspect
16
- } from "./chunk-JU6LUNLP.ts";
17
- import "./chunk-HOP5FXDT.ts";
18
- import {
19
- discoverAgents,
20
- projectCapabilityManifest
21
- } from "./chunk-LASD73CM.ts";
22
- import "./chunk-RSUXZD6S.ts";
23
- import "./chunk-D4CR7T73.ts";
24
- import {
25
- inspectBlockingParallelLimitSettings,
26
- inspectCompletionDeliverySettings,
27
- inspectConsultResourceSettings,
28
- inspectCwdPolicySettings,
29
- inspectDelegationWorkflowSettings,
30
- inspectStatefulLimitSettings,
31
- inspectStatefulTransportSettings,
32
- inspectSubagentSettings,
33
- inspectUsageRecordingSettings,
34
- resolveDelegationWorkflow
35
- } from "./chunk-TMZRHIIK.ts";
36
- import "./chunk-VDG7LTYE.ts";
37
- import "./chunk-4AQSF7AS.ts";
38
- import "./chunk-BFK2Z4ZF.ts";
39
- import {
40
- boundText,
41
- boundedPrivateText,
42
- safeDisplayPath,
43
- safeTerminalLine
44
- } from "./chunk-SWGQLFSD.ts";
45
- import {
46
- DEFAULT_MAX_CONTEXT_BYTES,
47
- buildContextSnapshot
48
- } from "./chunk-H3FP6DLR.ts";
49
-
50
- // src/inspect.ts
51
- import * as path from "node:path";
52
- import { CONFIG_DIR_NAME } from "@earendil-works/pi-coding-agent";
53
- var MAX_DETAILS_LIST_BYTES = 40 * 1024;
54
- function validateInspectParams(params) {
55
- const values = parameterRecord(params);
56
- const rawAction = values.action;
57
- if (typeof rawAction !== "string" || !INSPECT_ACTIONS.includes(rawAction)) {
58
- throw new Error(`subagent_inspect action must be one of: ${INSPECT_ACTIONS.join(", ")}`);
59
- }
60
- const action = rawAction;
61
- const allowed = {
62
- list_agents: ["action", "agentScope", "limit"],
63
- get_agent: ["action", "agent", "agentScope"],
64
- list_runs: ["action", "includeClosed", "limit"],
65
- get_run: ["action", "agentId"],
66
- list_workflows: ["action", "limit"],
67
- get_workflow: ["action", "workflowId"],
68
- list_models: ["action", "limit"],
69
- preview_context: ["action", "context", "contextEntryIds"],
70
- status: ["action"],
71
- diagnose: ["action"]
72
- };
73
- const unexpected = Object.keys(values).find(
74
- (key) => values[key] !== void 0 && !allowed[action].includes(key)
75
- );
76
- if (unexpected)
77
- throw new Error(`subagent_inspect action "${action}" does not accept ${unexpected}`);
78
- if (action === "list_agents" || action === "get_agent") {
79
- const agentScope = optionalAgentScope(values.agentScope);
80
- if (action === "get_agent") {
81
- return { action, agent: requiredString(values.agent, action, "agent"), agentScope };
82
- }
83
- return { action, agentScope, limit: optionalLimit(values.limit, 32) };
84
- }
85
- if (action === "list_runs") {
86
- if (values.includeClosed !== void 0 && typeof values.includeClosed !== "boolean") {
87
- throw new Error('subagent_inspect action "list_runs" requires includeClosed to be boolean');
88
- }
89
- return {
90
- action,
91
- includeClosed: values.includeClosed === true,
92
- limit: optionalLimit(values.limit, 50)
93
- };
94
- }
95
- if (action === "get_run") {
96
- return { action, agentId: requiredString(values.agentId, action, "agentId") };
97
- }
98
- if (action === "list_workflows") {
99
- return { action, limit: optionalLimit(values.limit, 50) };
100
- }
101
- if (action === "get_workflow") {
102
- return { action, workflowId: requiredString(values.workflowId, action, "workflowId") };
103
- }
104
- if (action === "list_models") {
105
- return { action, limit: optionalLimit(values.limit, 50) };
106
- }
107
- if (action === "preview_context") {
108
- const context = optionalContextMode(values.context);
109
- const contextEntryIds = optionalStringArray(values.contextEntryIds, "contextEntryIds");
110
- return {
111
- action,
112
- context: values.context === void 0 && contextEntryIds ? "all" : context,
113
- ...contextEntryIds ? { contextEntryIds } : {}
114
- };
115
- }
116
- return { action };
117
- }
118
- async function executeSubagentInspect(params, ctx, runtime) {
119
- const operation = validateInspectParams(params);
120
- if (operation.action === "list_agents" || operation.action === "get_agent") {
121
- assertTrustedScope(operation.agentScope, ctx);
122
- const settings2 = inspectSubagentSettings().settings;
123
- const discovery = discoverAgents(ctx.cwd, operation.agentScope, settings2);
124
- const agents = [...discovery.agents].sort(
125
- (left, right) => left.name === right.name ? left.source.localeCompare(right.source) : left.name.localeCompare(right.name)
126
- );
127
- if (operation.action === "list_agents") {
128
- const selected = boundedProjection(
129
- agents,
130
- operation.limit,
131
- (agent2) => projectAgent(agent2, ctx, false)
132
- );
133
- return inspectResult({
134
- action: operation.action,
135
- agents: selected.items,
136
- returned: selected.items.length,
137
- omitted: selected.omitted + (discovery.omittedAgentDefinitions ?? 0),
138
- discoveryIncomplete: discovery.metadataDiscoveryIncomplete === true
139
- });
140
- }
141
- const agent = agents.find((candidate) => candidate.name === operation.agent);
142
- if (!agent) {
143
- throw new Error(`Unknown subagent definition: ${boundedPrivateText(operation.agent, 256)}`);
144
- }
145
- return inspectResult({ action: operation.action, agent: projectAgent(agent, ctx) });
146
- }
147
- if (operation.action === "list_runs") {
148
- const runs = runtime.listRunInspection(operation.includeClosed);
149
- const selected = boundedProjection(runs, operation.limit, projectRunSummary);
150
- return inspectResult({
151
- action: operation.action,
152
- runs: selected.items,
153
- returned: selected.items.length,
154
- omitted: selected.omitted
155
- });
156
- }
157
- if (operation.action === "get_run") {
158
- const run = runtime.getRunInspection(operation.agentId);
159
- if (!run) {
160
- throw new Error(`Unknown retained run: ${boundedPrivateText(operation.agentId, 256)}`);
161
- }
162
- return inspectResult({ action: operation.action, run: projectRun(run, ctx) });
163
- }
164
- if (operation.action === "list_workflows" || operation.action === "get_workflow") {
165
- const owner = ctx.sessionManager.getSessionId?.() ?? ctx.sessionManager.getSessionFile?.() ?? `ephemeral:${ctx.cwd}`;
166
- const inspected = inspectSessionWorkflows(owner, {
167
- maxStoredWorkflows: operation.action === "list_workflows" ? operation.limit : 64
168
- });
169
- if (operation.action === "list_workflows") {
170
- const selected = boundedProjection(
171
- inspected.workflows,
172
- operation.limit,
173
- projectWorkflowSummary
174
- );
175
- return inspectResult({
176
- action: operation.action,
177
- workflows: selected.items,
178
- returned: selected.items.length,
179
- omitted: inspected.omitted + selected.omitted,
180
- invalid: inspected.invalid
181
- });
182
- }
183
- const workflow = inspected.workflows.find(
184
- (candidate) => candidate.workflowId === operation.workflowId
185
- );
186
- if (!workflow) {
187
- throw new Error(
188
- `Unknown persisted workflow: ${boundedPrivateText(operation.workflowId, 256)}`
189
- );
190
- }
191
- return inspectResult({ action: operation.action, workflow: projectWorkflow(workflow) });
192
- }
193
- if (operation.action === "list_models") {
194
- return inspectResult({ action: operation.action, ...projectModels(ctx, operation.limit) });
195
- }
196
- if (operation.action === "preview_context") {
197
- const snapshot = buildContextSnapshot(
198
- ctx.sessionManager.getBranch(),
199
- operation.context,
200
- DEFAULT_MAX_CONTEXT_BYTES,
201
- operation.contextEntryIds
202
- );
203
- return inspectResult({
204
- action: operation.action,
205
- preview: {
206
- mode: operation.context,
207
- turns: snapshot.turns,
208
- sourceCount: snapshot.sourceIds.length,
209
- bytes: Buffer.byteLength(snapshot.text, "utf8"),
210
- truncated: snapshot.truncated
211
- }
212
- });
213
- }
214
- if (operation.action === "status") {
215
- return inspectResult({ action: operation.action, status: projectStatus(runtime) });
216
- }
217
- const settings = inspectSubagentSettings();
218
- const userDiscovery = discoverAgents(ctx.cwd, "user", settings.settings);
219
- const modelCount = availableModelCount(ctx);
220
- const runtimeStatus = runtime.getRuntimeStatus();
221
- const rpcCapability = inspectRpcCapability();
222
- const inProcessCapability = await inspectInProcessCapability();
223
- const checks = [
224
- {
225
- name: "settings",
226
- status: settings.error ? "fail" : "pass",
227
- message: settings.error ? boundedPrivateText(settings.error, 2 * 1024) : "Settings are valid or absent."
228
- },
229
- {
230
- name: "agent-discovery",
231
- status: userDiscovery.metadataDiscoveryIncomplete || (userDiscovery.omittedAgentDefinitions ?? 0) > 0 ? "warning" : "pass",
232
- message: `${userDiscovery.agents.length} user-scope definitions available.`
233
- },
234
- {
235
- name: "models",
236
- status: modelCount > 0 ? "pass" : "fail",
237
- message: `${modelCount} session-usable models available.`
238
- },
239
- {
240
- name: "runtime",
241
- status: runtimeStatus.enabled && !runtimeStatus.initialized ? "warning" : "pass",
242
- message: runtimeStatus.initialized ? "Stateful runtime initialized." : "Stateful runtime not initialized."
243
- },
244
- {
245
- name: "in-process-sdk",
246
- status: inProcessCapability.error ? "fail" : "pass",
247
- message: inProcessCapability.error ? boundedPrivateText(inProcessCapability.error, 2 * 1024) : "Required public Pi in-process session APIs are available."
248
- },
249
- {
250
- name: "rpc-cli",
251
- status: rpcCapability.error ? "fail" : "pass",
252
- message: rpcCapability.error ? boundedPrivateText(rpcCapability.error, 2 * 1024) : "The exact loaded Pi CLI is available for persistent RPC transport."
253
- },
254
- {
255
- name: "consultation",
256
- status: runtime.getBlockingEnabled() && modelCount > 0 ? "pass" : "fail",
257
- message: runtime.getBlockingEnabled() ? modelCount > 0 ? "Read-only consultation is supported." : "Consultation has no available model." : "Blocking delegation is disabled, so consultation is not registered."
258
- }
259
- ];
260
- return inspectResult({
261
- action: operation.action,
262
- checks,
263
- ok: checks.every((check) => check.status !== "fail")
264
- });
265
- }
266
- function projectAgent(agent, ctx, includeTools = true) {
267
- const tools = agent.tools === void 0 ? void 0 : projectToolNames(agent.tools);
268
- return {
269
- name: boundedPrivateText(agent.name, 256),
270
- description: boundedPrivateText(agent.description, 256),
271
- source: agent.source,
272
- scope: agent.source === "project" ? "project" : "user",
273
- path: agent.source === "project" ? safeTerminalLine(
274
- path.posix.join(CONFIG_DIR_NAME, "agents", path.basename(agent.filePath))
275
- ) : safeDisplayPath(agent.filePath, ctx.cwd),
276
- model: agent.model ? boundedPrivateText(agent.model, 256) : void 0,
277
- thinkingLevel: agent.thinkingLevel,
278
- capabilityManifest: projectCapabilityManifest(agent.capabilityManifest),
279
- ...includeTools ? { tools, toolCount: agent.tools?.length } : { toolCount: agent.tools?.length },
280
- consultTools: resolveConsultTools(agent.tools)
281
- };
282
- }
283
- function projectRunSummary(run) {
284
- return {
285
- id: boundedPrivateText(run.id, 256),
286
- agent: boundedPrivateText(run.agent, 256),
287
- state: run.state,
288
- createdAt: run.createdAt,
289
- updatedAt: run.updatedAt,
290
- historyCount: run.historyCount,
291
- unreadMessages: run.unreadMessages,
292
- turnGeneration: run.turnGeneration,
293
- pendingCompletionCount: run.pendingCompletionCount,
294
- ...run.pendingRequiredCompletionCount === void 0 ? {} : { pendingRequiredCompletionCount: run.pendingRequiredCompletionCount }
295
- };
296
- }
297
- function projectRun(run, ctx) {
298
- return {
299
- ...projectRunSummary(run),
300
- cwd: safeDisplayPath(run.cwd, ctx.cwd),
301
- workspaceMode: run.workspaceMode ?? "shared",
302
- thinkingLevel: run.thinkingLevel,
303
- timeoutMs: run.timeoutMs,
304
- currentTimeoutMs: run.currentTimeoutMs,
305
- idleTimeoutMs: run.idleTimeoutMs,
306
- currentIdleTimeoutMs: run.currentIdleTimeoutMs,
307
- maxTurns: run.maxTurns,
308
- currentMaxTurns: run.currentMaxTurns,
309
- maxToolCalls: run.maxToolCalls,
310
- currentMaxToolCalls: run.currentMaxToolCalls,
311
- context: {
312
- turns: run.contextTurns ?? 0,
313
- sources: run.contextSources ?? 0,
314
- bytes: run.contextBytes ?? 0,
315
- truncated: run.contextTruncated === true
316
- },
317
- contract: run.contract ? {
318
- version: run.contract.version,
319
- level: run.contract.level,
320
- taskId: boundedPrivateText(run.contract.taskId, 256),
321
- enforcement: run.contract.enforcement,
322
- dependencies: run.contract.dependencies.length,
323
- acceptanceCriteria: run.contract.acceptanceCriteria.length,
324
- requiredEvidence: run.contract.requiredEvidence.length
325
- } : void 0,
326
- resultFormat: run.resultFormat ?? "text",
327
- completionRequirements: (run.completionRequirements ?? []).map((requirement) => ({
328
- ...requirement
329
- })),
330
- structuredResult: run.structuredResult,
331
- termination: run.termination,
332
- outcome: run.outcome,
333
- capabilityGrant: run.capabilityGrant ? {
334
- version: run.capabilityGrant.version,
335
- id: run.capabilityGrant.id,
336
- executionPlanId: run.capabilityGrant.executionPlanId,
337
- taskGeneration: run.capabilityGrant.taskGeneration,
338
- issuedAt: run.capabilityGrant.issuedAt,
339
- expiresAt: run.capabilityGrant.expiresAt,
340
- state: run.capabilityGrant.state,
341
- revokedAt: run.capabilityGrant.revokedAt,
342
- revocationReason: run.capabilityGrant.revocationReason
343
- } : void 0,
344
- executionPlan: run.executionPlan ? {
345
- ...run.executionPlan,
346
- target: {
347
- ...run.executionPlan.target,
348
- cwd: safeDisplayPath(run.executionPlan.target.cwd, ctx.cwd),
349
- trust: { ...run.executionPlan.target.trust, sourcePath: void 0 }
350
- }
351
- } : void 0,
352
- semanticSnapshot: run.semanticSnapshot ? {
353
- version: run.semanticSnapshot.version,
354
- digest: run.semanticSnapshot.digest,
355
- components: { ...run.semanticSnapshot.components }
356
- } : void 0,
357
- semanticCompatibility: run.semanticCompatibility,
358
- telemetry: run.telemetry,
359
- currentRunId: run.currentRunId,
360
- currentTurnGeneration: run.currentTurnGeneration,
361
- currentTask: run.currentTask ? boundedPrivateText(run.currentTask, 2 * 1024) : void 0,
362
- error: run.error ? boundedPrivateText(run.error, 2 * 1024) : void 0,
363
- target: run.target ? {
364
- cwd: safeDisplayPath(run.target.cwd, ctx.cwd),
365
- boundary: run.target.boundary,
366
- trust: {
367
- kind: run.target.trust.kind,
368
- projectTrusted: run.target.trust.projectTrusted,
369
- sourcePath: run.target.trust.sourcePath ? safeDisplayPath(run.target.trust.sourcePath, ctx.cwd) : void 0,
370
- warning: run.target.trust.warning ? boundedPrivateText(run.target.trust.warning, 512) : void 0
371
- }
372
- } : void 0,
373
- policy: run.policy ? {
374
- inherited: projectToolNames(run.policy.inherited),
375
- overridden: projectToolNames(run.policy.overridden),
376
- unsupported: projectToolNames(run.policy.unsupported)
377
- } : void 0
378
- };
379
- }
380
- function projectWorkflowSummary(workflow) {
381
- return {
382
- workflowId: boundedPrivateText(workflow.workflowId, 256),
383
- generation: workflow.generation,
384
- itemCount: workflow.items.length,
385
- states: Object.fromEntries(
386
- [...new Set(workflow.items.map((item) => item.state))].sort().map((state) => [state, workflow.items.filter((item) => item.state === state).length])
387
- )
388
- };
389
- }
390
- function projectWorkflow(workflow) {
391
- const projected = boundedProjection(workflow.items, 64, (item) => ({
392
- id: boundedPrivateText(item.id, 256),
393
- state: item.state,
394
- generation: item.generation,
395
- taskGeneration: item.taskGeneration,
396
- dependencies: item.dependencies.map((value) => boundedPrivateText(value, 256)),
397
- assignedAgentId: item.assignedAgentId ? boundedPrivateText(item.assignedAgentId, 256) : void 0,
398
- acceptedExecutionPlanId: item.acceptedExecutionPlanId,
399
- artifacts: item.artifacts.map((artifact) => ({
400
- id: boundedPrivateText(artifact.id, 256),
401
- kind: boundedPrivateText(artifact.kind, 256),
402
- version: boundedPrivateText(artifact.version, 256),
403
- producerTaskId: artifact.producerTaskId ? boundedPrivateText(artifact.producerTaskId, 256) : void 0,
404
- generation: artifact.generation,
405
- verified: artifact.verified
406
- })),
407
- verificationAccepted: item.verificationAccepted,
408
- acceptanceStateVersion: item.acceptanceStateVersion,
409
- acceptanceRequired: item.acceptanceRequired,
410
- acceptanceState: item.acceptanceState,
411
- reworkCount: item.reworkCount,
412
- maxReworkCycles: item.maxReworkCycles,
413
- acceptanceReceipt: item.acceptanceReceipt ? {
414
- version: item.acceptanceReceipt.version,
415
- decision: item.acceptanceReceipt.decision,
416
- targetTaskId: boundedPrivateText(item.acceptanceReceipt.targetTaskId, 256),
417
- targetTaskGeneration: item.acceptanceReceipt.targetTaskGeneration,
418
- targetExecutionPlanId: item.acceptanceReceipt.targetExecutionPlanId,
419
- verifierTaskId: boundedPrivateText(item.acceptanceReceipt.verifierTaskId, 256),
420
- verifierTaskGeneration: item.acceptanceReceipt.verifierTaskGeneration,
421
- verifierExecutionPlanId: item.acceptanceReceipt.verifierExecutionPlanId,
422
- verifierAgent: boundedPrivateText(item.acceptanceReceipt.verifierAgent, 256),
423
- beforeTreeIdentity: item.acceptanceReceipt.beforeTreeIdentity,
424
- afterTreeIdentity: item.acceptanceReceipt.afterTreeIdentity,
425
- patchDigest: item.acceptanceReceipt.patchDigest,
426
- changedPathCount: item.acceptanceReceipt.changedPaths.length,
427
- checkCount: item.acceptanceReceipt.checks.length,
428
- requiredEvidenceCount: item.acceptanceReceipt.requiredEvidenceIds.length,
429
- createdAt: item.acceptanceReceipt.createdAt,
430
- sourceTruncated: item.acceptanceReceipt.sourceTruncated
431
- } : void 0,
432
- acceptanceReceiptHistoryCount: item.acceptanceReceiptHistory.length,
433
- stagedTreeIdentity: item.stagedTreeIdentity ? {
434
- version: item.stagedTreeIdentity.version,
435
- kind: item.stagedTreeIdentity.kind,
436
- digest: item.stagedTreeIdentity.digest
437
- } : void 0,
438
- verificationReceipt: item.verificationReceipt ? {
439
- version: item.verificationReceipt.version,
440
- decision: item.verificationReceipt.decision,
441
- targetTaskId: boundedPrivateText(item.verificationReceipt.targetTaskId, 256),
442
- targetTaskGeneration: item.verificationReceipt.targetTaskGeneration,
443
- targetExecutionPlanId: item.verificationReceipt.targetExecutionPlanId,
444
- verifierTaskId: boundedPrivateText(item.verificationReceipt.verifierTaskId, 256),
445
- verifierTaskGeneration: item.verificationReceipt.verifierTaskGeneration,
446
- verifierExecutionPlanId: item.verificationReceipt.verifierExecutionPlanId,
447
- treeIdentity: item.verificationReceipt.treeIdentity,
448
- summary: boundedPrivateText(item.verificationReceipt.summary, 8 * 1024),
449
- evidenceCount: item.verificationReceipt.evidence.length,
450
- limitationCount: item.verificationReceipt.limitations.length,
451
- createdAt: item.verificationReceipt.createdAt,
452
- truncated: item.verificationReceipt.truncated
453
- } : void 0,
454
- outcomeReason: item.outcomeReason ? boundedPrivateText(item.outcomeReason, 2 * 1024) : void 0
455
- }));
456
- return {
457
- ...projectWorkflowSummary(workflow),
458
- items: projected.items,
459
- omittedItems: projected.omitted
460
- };
461
- }
462
- function projectModels(ctx, limit) {
463
- const scoped = ctx.scopedModels ?? [];
464
- const candidates = scoped.length > 0 ? scoped : ctx.modelRegistry.getAvailable().map((model) => ({ model, thinkingLevel: void 0 }));
465
- const selected = boundedProjection(candidates, limit, ({ model, thinkingLevel }) => ({
466
- provider: boundedPrivateText(model.provider, 256),
467
- id: boundedPrivateText(model.id, 256),
468
- name: boundedPrivateText(model.name, 256),
469
- reasoning: model.reasoning,
470
- input: [...model.input],
471
- contextWindow: model.contextWindow,
472
- maxTokens: model.maxTokens,
473
- thinkingLevel,
474
- current: ctx.model?.provider === model.provider && ctx.model?.id === model.id
475
- }));
476
- return {
477
- models: selected.items,
478
- returned: selected.items.length,
479
- omitted: selected.omitted,
480
- source: scoped.length > 0 ? "session scope" : "available snapshot"
481
- };
482
- }
483
- function projectStatus(runtime) {
484
- const stateful = runtime.getRuntimeStatus();
485
- const workflow = resolveDelegationWorkflow(runtime.getBlockingEnabled(), stateful.enabled);
486
- const configured = inspectDelegationWorkflowSettings();
487
- const resources = inspectConsultResourceSettings();
488
- const cwdPolicy = inspectCwdPolicySettings();
489
- const completion = inspectCompletionDeliverySettings();
490
- const parallelLimit = inspectBlockingParallelLimitSettings();
491
- const detachedLimits = inspectStatefulLimitSettings();
492
- const transport = inspectStatefulTransportSettings();
493
- const usageRecording = inspectUsageRecordingSettings();
494
- const usageStatus = runtime.getUsageRecordingStatus?.();
495
- const configuredDetachedLimits = detachedLimits.values ? Object.fromEntries(
496
- Object.entries(detachedLimits.values).map(([field, snapshot]) => [field, snapshot.value])
497
- ) : void 0;
498
- const configuredDetachedLimitSources = detachedLimits.values ? Object.fromEntries(
499
- Object.entries(detachedLimits.values).map(([field, snapshot]) => [field, snapshot.source])
500
- ) : void 0;
501
- return {
502
- workflow,
503
- configuredWorkflow: configured.value,
504
- configuredWorkflowSource: configured.source,
505
- stateful,
506
- statefulLimits: stateful.limits,
507
- configuredTransport: transport.value,
508
- configuredTransportSource: transport.source,
509
- configuredStatefulLimits: configuredDetachedLimits,
510
- configuredStatefulLimitSources: configuredDetachedLimitSources,
511
- configuredCompletionDelivery: completion.value,
512
- configuredCompletionDeliverySource: completion.source,
513
- usageRecording: usageStatus ? {
514
- enabled: usageStatus.enabled,
515
- retentionDays: usageStatus.retentionDays,
516
- recordedEvents: usageStatus.recordedEvents,
517
- writeFailure: usageStatus.writeFailure
518
- } : { enabled: false },
519
- configuredUsageRecording: usageRecording.enabled,
520
- configuredUsageRecordingSource: usageRecording.source,
521
- maxParallelTasks: runtime.getMaxParallelTasks(),
522
- configuredMaxParallelTasks: parallelLimit.value,
523
- configuredMaxParallelTasksSource: parallelLimit.source,
524
- consultResources: runtime.getConsultResourcePolicy(),
525
- consultationCwdPolicy: runtime.getConsultationCwdPolicy(),
526
- configuredConsultationCwdPolicy: cwdPolicy.consultation.value,
527
- consultationCwdPolicySource: cwdPolicy.consultation.source,
528
- delegationCwdPolicy: runtime.getDelegationCwdPolicy(),
529
- configuredDelegationCwdPolicy: cwdPolicy.delegation.value,
530
- delegationCwdPolicySource: cwdPolicy.delegation.source,
531
- configuredConsultResources: resources.value,
532
- consultResourcesSource: resources.source,
533
- settingsPath: safeDisplayPath(resources.path, process.cwd()),
534
- settingsError: configured.error || resources.error || cwdPolicy.error || completion.error || parallelLimit.error || detachedLimits.error || transport.error || usageRecording.error ? boundedPrivateText(
535
- configured.error ?? resources.error ?? cwdPolicy.error ?? completion.error ?? parallelLimit.error ?? detachedLimits.error ?? transport.error ?? usageRecording.error ?? "",
536
- 2 * 1024
537
- ) : void 0
538
- };
539
- }
540
- async function inspectInProcessCapability() {
541
- try {
542
- const moduleSpecifier = "@earendil-works/pi-coding-agent";
543
- const core = await import(moduleSpecifier);
544
- for (const name of [
545
- "createAgentSessionServices",
546
- "createAgentSessionFromServices",
547
- "resolveCliModel"
548
- ]) {
549
- if (typeof core[name] !== "function") return { error: `Pi core does not export ${name}()` };
550
- }
551
- return {};
552
- } catch (error) {
553
- return { error: error instanceof Error ? error.message : String(error) };
554
- }
555
- }
556
- function inspectRpcCapability() {
557
- try {
558
- resolvePiInvocation(["--mode", "rpc", "--no-session"]);
559
- return {};
560
- } catch (error) {
561
- return { error: error instanceof Error ? error.message : String(error) };
562
- }
563
- }
564
- function availableModelCount(ctx) {
565
- return (ctx.scopedModels?.length ?? 0) > 0 ? ctx.scopedModels.length : ctx.modelRegistry.getAvailable().length;
566
- }
567
- function projectToolNames(tools) {
568
- return tools.slice(0, 100).map((tool) => boundedPrivateText(tool, 256));
569
- }
570
- function boundedProjection(values, limit, project) {
571
- const items = [];
572
- for (const value of values.slice(0, limit)) {
573
- const next = project(value);
574
- if (Buffer.byteLength(JSON.stringify([...items, next]), "utf8") > MAX_DETAILS_LIST_BYTES) break;
575
- items.push(next);
576
- }
577
- return { items, omitted: Math.max(0, values.length - items.length) };
578
- }
579
- function inspectResult(details) {
580
- const rendered = boundText(JSON.stringify(details, null, 2));
581
- return {
582
- content: [{ type: "text", text: rendered.text }],
583
- details: { ...details, ...rendered.truncated ? { truncated: true } : {} }
584
- };
585
- }
586
- function assertTrustedScope(scope, ctx) {
587
- if ((scope === "project" || scope === "both") && !ctx.isProjectTrusted()) {
588
- throw new Error("Project-local subagent definitions require a trusted project");
589
- }
590
- }
591
- function parameterRecord(params) {
592
- if (!params || typeof params !== "object" || Array.isArray(params)) {
593
- throw new Error("subagent_inspect parameters must be an object");
594
- }
595
- return params;
596
- }
597
- function optionalAgentScope(value) {
598
- if (value === void 0) return "user";
599
- if (value === "user" || value === "project" || value === "both") return value;
600
- throw new Error("subagent_inspect agentScope must be user, project, or both");
601
- }
602
- function requiredString(value, action, field) {
603
- if (typeof value !== "string" || value.length === 0) {
604
- throw new Error(`subagent_inspect action "${action}" requires ${field}`);
605
- }
606
- return value;
607
- }
608
- function optionalContextMode(value) {
609
- if (value === void 0) return "none";
610
- if (value === "none" || value === "all" || value === "summary") return value;
611
- if (typeof value === "number" && Number.isSafeInteger(value) && value >= 1) return value;
612
- throw new Error("subagent_inspect context must be none, all, summary, or a positive integer");
613
- }
614
- function optionalStringArray(value, field) {
615
- if (value === void 0) return void 0;
616
- if (!Array.isArray(value) || !value.every((item) => typeof item === "string" && item.length > 0)) {
617
- throw new Error(`subagent_inspect ${field} must be an array of non-empty strings`);
618
- }
619
- return [...value];
620
- }
621
- function optionalLimit(value, defaultValue) {
622
- if (value === void 0) return defaultValue;
623
- if (!Number.isSafeInteger(value) || value < 1 || value > 100) {
624
- throw new Error("subagent_inspect limit must be an integer between 1 and 100");
625
- }
626
- return value;
627
- }
628
- export {
629
- SubagentInspectParams,
630
- executeSubagentInspect,
631
- registerSubagentInspect,
632
- validateInspectParams
633
- };
634
- //# sourceMappingURL=inspect-UH2TKH6E.ts.map