@narumitw/pi-subagents 2.1.4 → 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 (312) hide show
  1. package/README.md +187 -1228
  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 -1614
  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 -139
  179. package/docs/pi-subagents-diagrams.md +0 -183
  180. package/src/adaptive-scheduler.ts +0 -224
  181. package/src/admission-policy.ts +0 -78
  182. package/src/agent-projection.ts +0 -53
  183. package/src/agents/built-ins.ts +0 -71
  184. package/src/agents/catalog.ts +0 -241
  185. package/src/agents/discovery.ts +0 -265
  186. package/src/agents/types.ts +0 -100
  187. package/src/agents.ts +0 -51
  188. package/src/auto-transport.ts +0 -121
  189. package/src/blocking-status.ts +0 -63
  190. package/src/cached-module-loader.ts +0 -18
  191. package/src/capabilities.ts +0 -145
  192. package/src/capability-grant.ts +0 -115
  193. package/src/capability-router.ts +0 -107
  194. package/src/child-peer-bridge.ts +0 -124
  195. package/src/child-peer-tools.ts +0 -132
  196. package/src/completion-delivery.ts +0 -409
  197. package/src/completion-render.ts +0 -190
  198. package/src/completion-requirement.ts +0 -479
  199. package/src/completion-routing.ts +0 -24
  200. package/src/config-registration.ts +0 -114
  201. package/src/config-status.ts +0 -217
  202. package/src/config-ui.ts +0 -983
  203. package/src/consult-policy.ts +0 -15
  204. package/src/consult-registration.ts +0 -125
  205. package/src/consult-render.ts +0 -194
  206. package/src/consult-resources.ts +0 -51
  207. package/src/consult-tool.ts +0 -95
  208. package/src/consult.ts +0 -566
  209. package/src/context.ts +0 -126
  210. package/src/create-stateful-transport.ts +0 -157
  211. package/src/cwd-policy.ts +0 -183
  212. package/src/delegation-contract.ts +0 -463
  213. package/src/execution/budget.ts +0 -56
  214. package/src/execution/runtime-policy.ts +0 -19
  215. package/src/execution-plan.ts +0 -322
  216. package/src/execution-ui.ts +0 -259
  217. package/src/execution.ts +0 -1679
  218. package/src/in-process-transport.ts +0 -941
  219. package/src/inspect-registration.ts +0 -64
  220. package/src/inspect-render.ts +0 -334
  221. package/src/inspect-tool.ts +0 -45
  222. package/src/inspect.ts +0 -769
  223. package/src/integration-controller.ts +0 -98
  224. package/src/limits.ts +0 -75
  225. package/src/orchestration-metrics.ts +0 -116
  226. package/src/outcome.ts +0 -61
  227. package/src/panel-child-group.ts +0 -35
  228. package/src/panel-contract.ts +0 -343
  229. package/src/panel-evidence.ts +0 -59
  230. package/src/panel-execution.ts +0 -769
  231. package/src/panel-failure.ts +0 -56
  232. package/src/panel-planning.ts +0 -175
  233. package/src/panel-presets.ts +0 -3
  234. package/src/panel-prompts.ts +0 -132
  235. package/src/panel-reconciliation.ts +0 -57
  236. package/src/panel-render.ts +0 -103
  237. package/src/parallel-limit-ui.ts +0 -113
  238. package/src/params.ts +0 -278
  239. package/src/peer-communication.ts +0 -352
  240. package/src/peer-transport.ts +0 -49
  241. package/src/persistence.ts +0 -522
  242. package/src/pi-args.ts +0 -43
  243. package/src/pi-invocation.ts +0 -168
  244. package/src/process-control.ts +0 -43
  245. package/src/prompt-resources.ts +0 -38
  246. package/src/prompt-source-safety.ts +0 -48
  247. package/src/protocol.ts +0 -76
  248. package/src/registry-types.ts +0 -204
  249. package/src/registry.ts +0 -1698
  250. package/src/render-common.ts +0 -252
  251. package/src/render.ts +0 -704
  252. package/src/result-contract.ts +0 -431
  253. package/src/retained-semantic-state.ts +0 -100
  254. package/src/rpc-timeout-finalization.ts +0 -207
  255. package/src/rpc-transport-metadata.ts +0 -65
  256. package/src/rpc-transport.ts +0 -1035
  257. package/src/rpc-turn-capture.ts +0 -217
  258. package/src/runner-outcome.ts +0 -31
  259. package/src/runner-result.ts +0 -55
  260. package/src/runner-types.ts +0 -102
  261. package/src/runner-usage.ts +0 -48
  262. package/src/runner.ts +0 -866
  263. package/src/safe-text.ts +0 -67
  264. package/src/semantic-snapshot.ts +0 -214
  265. package/src/session-guidance-contract.ts +0 -399
  266. package/src/settings/inspection.ts +0 -302
  267. package/src/settings/schema.ts +0 -195
  268. package/src/settings-reader.ts +0 -215
  269. package/src/settings.ts +0 -452
  270. package/src/spawn-idempotency.ts +0 -68
  271. package/src/stateful-agent-view.ts +0 -85
  272. package/src/stateful-config.ts +0 -13
  273. package/src/stateful-guidance.ts +0 -29
  274. package/src/stateful-lifecycle.ts +0 -74
  275. package/src/stateful-limit-ui.ts +0 -249
  276. package/src/stateful-limits.ts +0 -96
  277. package/src/stateful-prompt.ts +0 -49
  278. package/src/stateful-registration.ts +0 -1320
  279. package/src/stateful-render.ts +0 -318
  280. package/src/stateful-safety.ts +0 -47
  281. package/src/stateful-tool-params.ts +0 -215
  282. package/src/stateful.ts +0 -12
  283. package/src/subagent-details.ts +0 -43
  284. package/src/subagents-extension.ts +0 -372
  285. package/src/subprocess-transport.ts +0 -145
  286. package/src/supervision.ts +0 -104
  287. package/src/task-path.ts +0 -65
  288. package/src/timeout-checkpoint.ts +0 -305
  289. package/src/timeout-finalization.ts +0 -75
  290. package/src/tool-schema-compatibility.ts +0 -73
  291. package/src/transport-types.ts +0 -74
  292. package/src/transport-ui.ts +0 -135
  293. package/src/transport.ts +0 -43
  294. package/src/turn-budget.ts +0 -109
  295. package/src/usage-format.ts +0 -42
  296. package/src/usage-recording-config.ts +0 -13
  297. package/src/usage-recording-store.ts +0 -183
  298. package/src/usage-recording.ts +0 -478
  299. package/src/verification-harness.ts +0 -516
  300. package/src/verification-policy.ts +0 -67
  301. package/src/verification-receipt.ts +0 -275
  302. package/src/verified-execution-benchmark.ts +0 -86
  303. package/src/verified-execution-contract.ts +0 -191
  304. package/src/verified-execution-schema.ts +0 -32
  305. package/src/work-item-ledger.ts +0 -1404
  306. package/src/work-item-persistence.ts +0 -254
  307. package/src/workflow-completion-controller.ts +0 -397
  308. package/src/workflow-planning.ts +0 -172
  309. package/src/workflow-tree-identity.ts +0 -289
  310. package/src/workflow-ui.ts +0 -69
  311. package/src/workflow-verification.ts +0 -296
  312. package/src/workspace.ts +0 -174
@@ -1,121 +0,0 @@
1
- import { discoverAgents } from "./agents/discovery.js";
2
- import type { SubagentSettings } from "./agents/types.js";
3
- import type { AgentMailboxMessage, ManagedAgent, TurnOutcome } from "./registry.js";
4
- import { isWriteCapable } from "./stateful-safety.js";
5
- import type { SubagentTransport } from "./transport.js";
6
- import type {
7
- EffectiveSubagentTransportKind,
8
- TransportProgressCallback,
9
- } from "./transport-types.js";
10
-
11
- const BUILT_IN_TOOL_NAMES = new Set(["read", "bash", "edit", "write", "grep", "find", "ls"]);
12
-
13
- export interface AutoTransportOptions {
14
- subprocess: SubagentTransport;
15
- inProcess: SubagentTransport;
16
- rpc: SubagentTransport;
17
- getSettings?: () => SubagentSettings | undefined;
18
- }
19
-
20
- export interface AutoTransportSelection {
21
- kind: EffectiveSubagentTransportKind;
22
- reason: string;
23
- }
24
-
25
- export class AutoTransport implements SubagentTransport {
26
- readonly kind = "auto" as const;
27
- private readonly selections = new Map<string, AutoTransportSelection>();
28
-
29
- constructor(private readonly options: AutoTransportOptions) {}
30
-
31
- async runTurn(
32
- agent: ManagedAgent,
33
- task: string,
34
- signal: AbortSignal,
35
- onProgress?: TransportProgressCallback,
36
- ): Promise<TurnOutcome> {
37
- const selection = this.selections.get(agent.id) ?? this.select(agent);
38
- this.selections.set(agent.id, selection);
39
- const transport = this.transport(selection.kind);
40
- const outcome = await transport.runTurn(agent, task, signal, (progress) =>
41
- onProgress?.({ ...progress, selectionReason: selection.reason }),
42
- );
43
- return {
44
- ...outcome,
45
- telemetry: outcome.telemetry
46
- ? { ...outcome.telemetry, selectionReason: selection.reason }
47
- : outcome.telemetry,
48
- };
49
- }
50
-
51
- async deliverMessage(agent: ManagedAgent, message: AgentMailboxMessage): Promise<boolean> {
52
- const selection = this.selections.get(agent.id);
53
- if (!selection) return false;
54
- return this.transport(selection.kind).deliverMessage?.(agent, message) ?? false;
55
- }
56
-
57
- async release(agent: ManagedAgent): Promise<void> {
58
- const selection = this.selections.get(agent.id);
59
- this.selections.delete(agent.id);
60
- if (selection) await this.transport(selection.kind).release?.(agent);
61
- }
62
-
63
- async shutdown(): Promise<void> {
64
- this.selections.clear();
65
- const transports = [this.options.subprocess, this.options.inProcess, this.options.rpc];
66
- const results = await Promise.allSettled(transports.map((transport) => transport.shutdown?.()));
67
- const failures = results.flatMap((result) =>
68
- result.status === "rejected" ? [result.reason] : [],
69
- );
70
- if (failures.length > 0) {
71
- throw new AggregateError(
72
- failures,
73
- `Failed to shut down ${failures.length} auto transport(s)`,
74
- );
75
- }
76
- }
77
-
78
- selectionFor(agentId: string): AutoTransportSelection | undefined {
79
- const selection = this.selections.get(agentId);
80
- return selection ? { ...selection } : undefined;
81
- }
82
-
83
- private select(agent: ManagedAgent): AutoTransportSelection {
84
- const settings = this.options.getSettings?.();
85
- const config = discoverAgents(agent.cwd, agent.agentScope ?? "user", settings).agents.find(
86
- (candidate) => candidate.name === agent.agent,
87
- );
88
- if (!config) {
89
- throw new Error(`Automatic transport cannot resolve subagent ${agent.agent}`);
90
- }
91
- const effectiveTools = agent.executionPlan?.effectiveTools ?? config.tools;
92
- const unsupported = (effectiveTools ?? []).filter((tool) => !BUILT_IN_TOOL_NAMES.has(tool));
93
- if (unsupported.length > 0) {
94
- return {
95
- kind: "subprocess",
96
- reason: `extension/custom tools require subprocess: ${unsupported.join(", ")}`,
97
- };
98
- }
99
- if (isWriteCapable(effectiveTools)) {
100
- return {
101
- kind: "rpc",
102
- reason: "write-capable built-in tools use a persistent isolated process",
103
- };
104
- }
105
- return {
106
- kind: "in-process",
107
- reason: "read-only built-in tools use the lowest-overhead public SDK session",
108
- };
109
- }
110
-
111
- private transport(kind: EffectiveSubagentTransportKind): SubagentTransport {
112
- switch (kind) {
113
- case "subprocess":
114
- return this.options.subprocess;
115
- case "in-process":
116
- return this.options.inProcess;
117
- case "rpc":
118
- return this.options.rpc;
119
- }
120
- }
121
- }
@@ -1,63 +0,0 @@
1
- const STATUS_KEY = "subagents";
2
- const activeStatuses = new Map<string, string>();
3
-
4
- interface StatusContext {
5
- ui: { setStatus: (key: string, value: string | undefined) => void };
6
- }
7
-
8
- export function startSubagentStatus(
9
- ctx: StatusContext,
10
- toolCallId: string,
11
- status: string,
12
- ): { update(status: string): void; clear(): void } {
13
- let cleared = false;
14
- const update = (nextStatus: string) => {
15
- if (cleared) return;
16
- activeStatuses.set(toolCallId, nextStatus);
17
- publishSubagentStatus(ctx);
18
- };
19
- update(status);
20
- return {
21
- update,
22
- clear() {
23
- if (cleared) return;
24
- cleared = true;
25
- activeStatuses.delete(toolCallId);
26
- publishSubagentStatus(ctx);
27
- },
28
- };
29
- }
30
-
31
- function publishSubagentStatus(ctx: StatusContext): void {
32
- const statuses = [...activeStatuses.values()];
33
- if (statuses.length === 0) {
34
- ctx.ui.setStatus(STATUS_KEY, undefined);
35
- return;
36
- }
37
- const suffix = statuses.length > 1 ? ` +${statuses.length - 1}` : "";
38
- ctx.ui.setStatus(STATUS_KEY, `${statuses[0]}${suffix}`);
39
- }
40
-
41
- export function singleStatus(agent: string): string {
42
- return `${agent}`;
43
- }
44
-
45
- export function chainStatus(step: number, total: number, agent?: string): string {
46
- return `chain ${step}/${total}${agent ? ` ${agent}` : ""}`;
47
- }
48
-
49
- export function parallelStatus(done: number, total: number, running: number): string {
50
- return `parallel ${done}/${total} done${running > 0 ? ` ${running} running` : ""}`;
51
- }
52
-
53
- export function fanInStatus(agent: string): string {
54
- return `fan-in ${agent}`;
55
- }
56
-
57
- export function panelReviewStatus(done: number, total: number, running: number): string {
58
- return `panel review ${done}/${total}${running > 0 ? ` ${running} running` : ""}`;
59
- }
60
-
61
- export function panelSynthesisStatus(agent: string): string {
62
- return `panel synthesis ${agent}`;
63
- }
@@ -1,18 +0,0 @@
1
- export function cachedModuleLoader<Module>(load: () => Promise<Module>): () => Promise<Module> {
2
- let pending: Promise<Module> | undefined;
3
- return () => {
4
- if (!pending) {
5
- pending = load().catch((error) => {
6
- pending = undefined;
7
- throw error;
8
- });
9
- }
10
- return pending;
11
- };
12
- }
13
-
14
- export function throwIfAborted(signal: AbortSignal | undefined, message: string): void {
15
- if (!signal?.aborted) return;
16
- if (signal.reason instanceof Error) throw signal.reason;
17
- throw new DOMException(message, "AbortError");
18
- }
@@ -1,145 +0,0 @@
1
- import type { SubagentResultFormat } from "./result-contract.js";
2
- import { SUBAGENT_RESULT_FORMATS } from "./result-contract.js";
3
-
4
- export const CAPABILITY_MANIFEST_VERSION = "pi-subagents:capabilities:v1" as const;
5
- export const CAPABILITY_MODALITIES = ["text", "image", "audio"] as const;
6
- export const FILESYSTEM_AUTHORITY = ["none", "read", "write"] as const;
7
- export const EXTERNAL_AUTHORITY = ["none", "required"] as const;
8
- export const CAPABILITY_HINTS = ["low", "medium", "high"] as const;
9
- export type CapabilityHint = (typeof CAPABILITY_HINTS)[number];
10
-
11
- const MAX_ITEMS = 50;
12
- const MAX_ITEM_LENGTH = 256;
13
- const MAX_LIMITATION_LENGTH = 1024;
14
-
15
- export interface AgentAuthorityManifest {
16
- filesystem?: (typeof FILESYSTEM_AUTHORITY)[number];
17
- network?: (typeof EXTERNAL_AUTHORITY)[number];
18
- secrets?: (typeof EXTERNAL_AUTHORITY)[number];
19
- }
20
-
21
- export interface AgentCapabilityManifest {
22
- version: typeof CAPABILITY_MANIFEST_VERSION;
23
- capabilities: string[];
24
- modalities: Array<(typeof CAPABILITY_MODALITIES)[number]>;
25
- resultFormats: SubagentResultFormat[];
26
- authority?: AgentAuthorityManifest;
27
- verificationRoles: string[];
28
- contextStrengths?: string[];
29
- costHint?: CapabilityHint;
30
- latencyHint?: CapabilityHint;
31
- limitations: string[];
32
- }
33
-
34
- export function normalizeCapabilityManifest(value: unknown): AgentCapabilityManifest | undefined {
35
- if (value === undefined) return undefined;
36
- if (!isPlainObject(value) || value.version !== CAPABILITY_MANIFEST_VERSION) return undefined;
37
- const capabilities = identifiers(value.capabilities, false);
38
- const modalities = enumArray(value.modalities, CAPABILITY_MODALITIES);
39
- const resultFormats = enumArray(value.resultFormats, SUBAGENT_RESULT_FORMATS);
40
- const verificationRoles = identifiers(value.verificationRoles, false);
41
- const contextStrengths =
42
- value.contextStrengths === undefined ? undefined : identifiers(value.contextStrengths, false);
43
- const costHint = optionalEnum(value.costHint, CAPABILITY_HINTS);
44
- const latencyHint = optionalEnum(value.latencyHint, CAPABILITY_HINTS);
45
- const limitations = strings(value.limitations, MAX_LIMITATION_LENGTH);
46
- if (
47
- !capabilities ||
48
- !modalities ||
49
- !resultFormats ||
50
- !verificationRoles ||
51
- (contextStrengths === undefined && value.contextStrengths !== undefined) ||
52
- costHint === false ||
53
- latencyHint === false ||
54
- !limitations
55
- ) {
56
- return undefined;
57
- }
58
- const authority = normalizeAuthority(value.authority);
59
- if (authority === false) return undefined;
60
- return {
61
- version: CAPABILITY_MANIFEST_VERSION,
62
- capabilities,
63
- modalities,
64
- resultFormats,
65
- ...(authority === undefined ? {} : { authority }),
66
- verificationRoles,
67
- ...(contextStrengths === undefined ? {} : { contextStrengths }),
68
- ...(costHint === undefined ? {} : { costHint }),
69
- ...(latencyHint === undefined ? {} : { latencyHint }),
70
- limitations,
71
- };
72
- }
73
-
74
- export function projectCapabilityManifest(
75
- manifest: AgentCapabilityManifest | undefined,
76
- ): AgentCapabilityManifest | undefined {
77
- return manifest ? structuredClone(manifest) : undefined;
78
- }
79
-
80
- function normalizeAuthority(value: unknown): AgentAuthorityManifest | undefined | false {
81
- if (value === undefined) return undefined;
82
- if (!isPlainObject(value)) return false;
83
- const filesystem = optionalEnum(value.filesystem, FILESYSTEM_AUTHORITY);
84
- const network = optionalEnum(value.network, EXTERNAL_AUTHORITY);
85
- const secrets = optionalEnum(value.secrets, EXTERNAL_AUTHORITY);
86
- if (filesystem === false || network === false || secrets === false) return false;
87
- return {
88
- ...(filesystem === undefined ? {} : { filesystem }),
89
- ...(network === undefined ? {} : { network }),
90
- ...(secrets === undefined ? {} : { secrets }),
91
- };
92
- }
93
-
94
- function identifiers(value: unknown, required: boolean): string[] | undefined {
95
- if (value === undefined) return required ? undefined : [];
96
- return strings(value, MAX_ITEM_LENGTH, /^[a-z0-9]+(?:-[a-z0-9]+)*$/u);
97
- }
98
-
99
- function strings(value: unknown, maxLength: number, pattern?: RegExp): string[] | undefined {
100
- if (value === undefined) return [];
101
- if (!Array.isArray(value) || value.length > MAX_ITEMS) return undefined;
102
- const result: string[] = [];
103
- const seen = new Set<string>();
104
- for (const item of value) {
105
- if (typeof item !== "string") return undefined;
106
- const normalized = item.trim();
107
- if (!normalized || normalized.length > maxLength || (pattern && !pattern.test(normalized))) {
108
- return undefined;
109
- }
110
- if (seen.has(normalized)) continue;
111
- seen.add(normalized);
112
- result.push(normalized);
113
- }
114
- return result;
115
- }
116
-
117
- function enumArray<const T extends readonly string[]>(
118
- value: unknown,
119
- allowed: T,
120
- ): Array<T[number]> | undefined {
121
- if (value === undefined) return [];
122
- if (!Array.isArray(value) || value.length > MAX_ITEMS) return undefined;
123
- const result: Array<T[number]> = [];
124
- const seen = new Set<string>();
125
- for (const item of value) {
126
- if (typeof item !== "string" || !allowed.includes(item)) return undefined;
127
- if (seen.has(item)) continue;
128
- seen.add(item);
129
- result.push(item as T[number]);
130
- }
131
- return result;
132
- }
133
-
134
- function optionalEnum<const T extends readonly string[]>(
135
- value: unknown,
136
- allowed: T,
137
- ): T[number] | undefined | false {
138
- if (value === undefined) return undefined;
139
- if (typeof value !== "string" || !allowed.includes(value)) return false;
140
- return value as T[number];
141
- }
142
-
143
- function isPlainObject(value: unknown): value is Record<string, unknown> {
144
- return Boolean(value) && typeof value === "object" && !Array.isArray(value);
145
- }
@@ -1,115 +0,0 @@
1
- import { createHash } from "node:crypto";
2
- import { type ExecutionPlan, isExecutionPlan } from "./execution-plan.js";
3
-
4
- export const CAPABILITY_GRANT_VERSION = "pi-subagents:capability-grant:v1" as const;
5
-
6
- export interface CapabilityGrant {
7
- version: typeof CAPABILITY_GRANT_VERSION;
8
- id: string;
9
- executionPlanId: string;
10
- taskGeneration: number;
11
- effectiveTools?: string[];
12
- issuedAt: number;
13
- expiresAt: number;
14
- state: "active" | "revoked";
15
- revokedAt?: number;
16
- revocationReason?: string;
17
- }
18
-
19
- function grantId(projection: {
20
- executionPlanId: string;
21
- taskGeneration: number;
22
- effectiveTools?: string[];
23
- issuedAt: number;
24
- expiresAt: number;
25
- }): string {
26
- return createHash("sha256").update(JSON.stringify(projection)).digest("hex");
27
- }
28
-
29
- export function issueCapabilityGrant(
30
- plan: ExecutionPlan,
31
- issuedAt: number,
32
- lifetimeMs: number,
33
- ): CapabilityGrant {
34
- if (!Number.isFinite(issuedAt) || !Number.isFinite(lifetimeMs) || lifetimeMs <= 0) {
35
- throw new Error("Capability grant requires finite issuance and lifetime bounds");
36
- }
37
- const expiresAt = issuedAt + lifetimeMs;
38
- const projection = {
39
- executionPlanId: plan.id,
40
- taskGeneration: plan.taskGeneration,
41
- effectiveTools: plan.effectiveTools,
42
- issuedAt,
43
- expiresAt,
44
- };
45
- return {
46
- version: CAPABILITY_GRANT_VERSION,
47
- id: grantId(projection),
48
- ...projection,
49
- state: "active",
50
- };
51
- }
52
-
53
- export function revokeCapabilityGrant(
54
- grant: CapabilityGrant,
55
- reason: string,
56
- revokedAt: number,
57
- ): CapabilityGrant {
58
- if (grant.state === "revoked") throw new Error("Capability grant is already revoked");
59
- grant.state = "revoked";
60
- grant.revokedAt = revokedAt;
61
- grant.revocationReason = reason.slice(0, 256);
62
- return structuredClone(grant);
63
- }
64
-
65
- export function isCapabilityGrant(value: unknown): value is CapabilityGrant {
66
- if (!value || typeof value !== "object" || Array.isArray(value)) return false;
67
- const grant = value as Partial<CapabilityGrant>;
68
- const validShape =
69
- grant.version === CAPABILITY_GRANT_VERSION &&
70
- typeof grant.id === "string" &&
71
- /^[a-f0-9]{64}$/u.test(grant.id) &&
72
- typeof grant.executionPlanId === "string" &&
73
- /^[a-f0-9]{64}$/u.test(grant.executionPlanId) &&
74
- Number.isSafeInteger(grant.taskGeneration) &&
75
- Number(grant.taskGeneration) >= 0 &&
76
- Number.isFinite(grant.issuedAt) &&
77
- Number.isFinite(grant.expiresAt) &&
78
- Number(grant.expiresAt) >= Number(grant.issuedAt) &&
79
- (grant.state === "active" || grant.state === "revoked") &&
80
- (grant.state === "active"
81
- ? grant.revokedAt === undefined && grant.revocationReason === undefined
82
- : Number.isFinite(grant.revokedAt) &&
83
- typeof grant.revocationReason === "string" &&
84
- grant.revocationReason.length > 0) &&
85
- (grant.effectiveTools === undefined ||
86
- (Array.isArray(grant.effectiveTools) &&
87
- grant.effectiveTools.every((tool) => typeof tool === "string")));
88
- if (!validShape) return false;
89
- const validated = grant as CapabilityGrant;
90
- const expectedId = grantId({
91
- executionPlanId: validated.executionPlanId,
92
- taskGeneration: validated.taskGeneration,
93
- effectiveTools: validated.effectiveTools,
94
- issuedAt: validated.issuedAt,
95
- expiresAt: validated.expiresAt,
96
- });
97
- return validated.id === expectedId;
98
- }
99
-
100
- export function isCapabilityGrantActive(
101
- grant: CapabilityGrant,
102
- plan: ExecutionPlan,
103
- now: number,
104
- ): boolean {
105
- return (
106
- isCapabilityGrant(grant) &&
107
- isExecutionPlan(plan) &&
108
- grant.state === "active" &&
109
- grant.executionPlanId === plan.id &&
110
- grant.taskGeneration === plan.taskGeneration &&
111
- JSON.stringify(grant.effectiveTools ?? null) === JSON.stringify(plan.effectiveTools ?? null) &&
112
- now >= grant.issuedAt &&
113
- now <= grant.expiresAt
114
- );
115
- }
@@ -1,107 +0,0 @@
1
- import { type AgentConfig, resolveAgentToolNames } from "./agents/types.js";
2
- import type { CapabilityHint } from "./capabilities.js";
3
-
4
- export interface CapabilityRouteRequest {
5
- agent?: string;
6
- requiredCapabilities?: string[];
7
- requiredTools?: string[];
8
- requiredVerificationRole?: string;
9
- requiredSideEffectClass?: string;
10
- preferredCostHint?: CapabilityHint;
11
- preferredLatencyHint?: CapabilityHint;
12
- }
13
-
14
- export interface CapabilityRouteDecision {
15
- agent: AgentConfig;
16
- eligibleAgents: string[];
17
- requiredCapabilities: string[];
18
- }
19
-
20
- const HINT_RANK: Record<CapabilityHint, number> = { low: 0, medium: 1, high: 2 };
21
-
22
- export function routeByCapability(
23
- agents: readonly AgentConfig[],
24
- request: CapabilityRouteRequest,
25
- ): CapabilityRouteDecision {
26
- const requiredCapabilities = unique(request.requiredCapabilities ?? []);
27
- const requiredTools = unique(request.requiredTools ?? []);
28
- const eligible = agents.filter((agent) => {
29
- const manifest = agent.capabilityManifest;
30
- const effectiveTools = resolveAgentToolNames(agent.tools);
31
- if (!manifest) {
32
- return (
33
- requiredCapabilities.length === 0 &&
34
- requiredTools.every((tool) => effectiveTools.includes(tool)) &&
35
- request.requiredVerificationRole === undefined &&
36
- request.requiredSideEffectClass === undefined
37
- );
38
- }
39
- const sideEffectAllowed =
40
- request.requiredSideEffectClass !== "read-only" ||
41
- manifest.authority?.filesystem === "read" ||
42
- manifest.authority?.filesystem === "none";
43
- return (
44
- requiredCapabilities.every((capability) => manifest.capabilities.includes(capability)) &&
45
- requiredTools.every((tool) => effectiveTools.includes(tool)) &&
46
- (!request.requiredVerificationRole ||
47
- manifest.verificationRoles.includes(request.requiredVerificationRole)) &&
48
- sideEffectAllowed
49
- );
50
- });
51
- if (request.agent) {
52
- const named = agents.find((agent) => agent.name === request.agent);
53
- if (!named) throw new Error(`Unknown subagent ${request.agent}`);
54
- if (!eligible.includes(named)) {
55
- throw new Error(
56
- `Selected subagent ${request.agent} does not satisfy the required capability manifest`,
57
- );
58
- }
59
- return {
60
- agent: named,
61
- eligibleAgents: eligible.map((agent) => agent.name).sort(),
62
- requiredCapabilities,
63
- };
64
- }
65
- if (eligible.length === 0) {
66
- throw new Error(
67
- `No capable agent satisfies: ${
68
- [...requiredCapabilities, ...requiredTools.map((tool) => `tool:${tool}`)].join(", ") ||
69
- "the requested side-effect class"
70
- }`,
71
- );
72
- }
73
- const ranked = [...eligible].sort((left, right) => {
74
- const leftCost = hintDistance(
75
- left.capabilityManifest?.costHint ?? "medium",
76
- request.preferredCostHint,
77
- );
78
- const rightCost = hintDistance(
79
- right.capabilityManifest?.costHint ?? "medium",
80
- request.preferredCostHint,
81
- );
82
- const leftLatency = hintDistance(
83
- left.capabilityManifest?.latencyHint ?? "medium",
84
- request.preferredLatencyHint,
85
- );
86
- const rightLatency = hintDistance(
87
- right.capabilityManifest?.latencyHint ?? "medium",
88
- request.preferredLatencyHint,
89
- );
90
- return (
91
- leftCost - rightCost || leftLatency - rightLatency || left.name.localeCompare(right.name)
92
- );
93
- });
94
- return {
95
- agent: ranked[0],
96
- eligibleAgents: ranked.map((agent) => agent.name),
97
- requiredCapabilities,
98
- };
99
- }
100
-
101
- function hintDistance(actual: CapabilityHint, preferred: CapabilityHint | undefined): number {
102
- return preferred ? Math.abs(HINT_RANK[actual] - HINT_RANK[preferred]) : HINT_RANK[actual];
103
- }
104
-
105
- function unique(values: readonly string[]): string[] {
106
- return [...new Set(values.map((value) => value.trim()).filter(Boolean))].sort();
107
- }
@@ -1,124 +0,0 @@
1
- import net from "node:net";
2
- import type { ExtensionFactory } from "@earendil-works/pi-coding-agent";
3
- import { type ChildPeerClient, createChildPeerExtension } from "./child-peer-tools.js";
4
- import type { AgentMailboxMessage } from "./registry.js";
5
-
6
- const MAX_RESPONSE_BYTES = 64 * 1024;
7
- const REQUEST_TIMEOUT_MS = 2_000;
8
-
9
- const captured = captureBridgeEnvironment();
10
-
11
- const childPeerBridge: ExtensionFactory = captured
12
- ? createChildPeerExtension(createProcessPeerClient(captured))
13
- : () => undefined;
14
-
15
- export default childPeerBridge;
16
-
17
- interface CapturedBridgeEnvironment {
18
- host: "127.0.0.1";
19
- port: number;
20
- token: string;
21
- }
22
-
23
- export function captureBridgeEnvironment(): CapturedBridgeEnvironment | undefined {
24
- const host = process.env.PI_SUBAGENT_PEER_HOST;
25
- const rawPort = process.env.PI_SUBAGENT_PEER_PORT;
26
- const token = process.env.PI_SUBAGENT_PEER_TOKEN;
27
- delete process.env.PI_SUBAGENT_PEER_HOST;
28
- delete process.env.PI_SUBAGENT_PEER_PORT;
29
- delete process.env.PI_SUBAGENT_PEER_TOKEN;
30
- if (!host && !rawPort && !token) return undefined;
31
- const port = Number(rawPort);
32
- if (host !== "127.0.0.1" || !Number.isSafeInteger(port) || port < 1 || port > 65_535 || !token) {
33
- throw new Error("Invalid pi-subagents peer bridge environment");
34
- }
35
- return { host, port, token };
36
- }
37
-
38
- function createProcessPeerClient(environment: CapturedBridgeEnvironment): ChildPeerClient {
39
- const request = async (input: Record<string, unknown>): Promise<Record<string, unknown>> => {
40
- const response = await requestBridge(environment, { ...input, token: environment.token });
41
- if (response.ok !== true) {
42
- throw new Error(
43
- typeof response.error === "string"
44
- ? response.error
45
- : "Subagent peer bridge rejected the request",
46
- );
47
- }
48
- return response;
49
- };
50
- return {
51
- async send(target, message, deduplicationKey) {
52
- const response = await request({
53
- action: "send",
54
- target,
55
- message,
56
- ...(deduplicationKey ? { deduplicationKey } : {}),
57
- });
58
- if (!isMailboxMessage(response.message)) {
59
- throw new Error("Subagent peer bridge returned an invalid message receipt");
60
- }
61
- return response.message;
62
- },
63
- async list() {
64
- return (await request({ action: "list" })).peers ?? [];
65
- },
66
- async acknowledge(messageIds, completionIds) {
67
- await request({ action: "acknowledge", messageIds, completionIds });
68
- },
69
- };
70
- }
71
-
72
- function requestBridge(
73
- environment: CapturedBridgeEnvironment,
74
- request: Record<string, unknown>,
75
- ): Promise<Record<string, unknown>> {
76
- return new Promise((resolve, reject) => {
77
- const socket = net.createConnection({ host: environment.host, port: environment.port });
78
- let response = Buffer.alloc(0);
79
- let settled = false;
80
- const finish = (error?: Error, value?: Record<string, unknown>) => {
81
- if (settled) return;
82
- settled = true;
83
- clearTimeout(timer);
84
- socket.destroy();
85
- if (error) reject(error);
86
- else resolve(value ?? {});
87
- };
88
- const timer = setTimeout(
89
- () => finish(new Error("Subagent peer bridge request timed out")),
90
- REQUEST_TIMEOUT_MS,
91
- );
92
- timer.unref();
93
- socket.once("connect", () => socket.end(`${JSON.stringify(request)}\n`));
94
- socket.on("data", (chunk: Buffer) => {
95
- response = Buffer.concat([response, chunk]);
96
- if (response.byteLength > MAX_RESPONSE_BYTES) {
97
- finish(new Error("Subagent peer bridge response exceeded its size limit"));
98
- }
99
- });
100
- socket.once("error", (error) => finish(error));
101
- socket.once("close", () => {
102
- if (settled) return;
103
- try {
104
- const parsed = JSON.parse(response.toString("utf8")) as unknown;
105
- if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) throw new Error();
106
- finish(undefined, parsed as Record<string, unknown>);
107
- } catch {
108
- finish(new Error("Subagent peer bridge returned malformed JSON"));
109
- }
110
- });
111
- });
112
- }
113
-
114
- function isMailboxMessage(value: unknown): value is AgentMailboxMessage {
115
- if (!value || typeof value !== "object" || Array.isArray(value)) return false;
116
- const message = value as Record<string, unknown>;
117
- return (
118
- typeof message.id === "string" &&
119
- typeof message.senderId === "string" &&
120
- typeof message.recipientId === "string" &&
121
- typeof message.content === "string" &&
122
- typeof message.createdAt === "number"
123
- );
124
- }