agent-relay 2.0.29 → 2.0.32

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 (894) hide show
  1. package/README.md +19 -0
  2. package/dist/index.cjs +85691 -0
  3. package/dist/src/bridge/index.d.ts.map +1 -0
  4. package/dist/src/bridge/index.js.map +1 -0
  5. package/dist/src/cli/commands/doctor.d.ts +2 -0
  6. package/dist/src/cli/commands/doctor.d.ts.map +1 -0
  7. package/dist/src/cli/commands/doctor.js +451 -0
  8. package/dist/src/cli/commands/doctor.js.map +1 -0
  9. package/dist/src/cli/index.d.ts.map +1 -0
  10. package/dist/src/cli/index.js +29 -1
  11. package/dist/src/cli/index.js.map +1 -0
  12. package/dist/src/config/relay-config.d.ts.map +1 -0
  13. package/dist/src/config/relay-config.js.map +1 -0
  14. package/dist/src/continuity/index.d.ts.map +1 -0
  15. package/dist/src/continuity/index.js.map +1 -0
  16. package/dist/src/daemon/index.d.ts.map +1 -0
  17. package/dist/src/daemon/index.js.map +1 -0
  18. package/dist/src/health-worker-manager.d.ts.map +1 -0
  19. package/dist/src/health-worker-manager.js.map +1 -0
  20. package/dist/src/health-worker.d.ts.map +1 -0
  21. package/dist/src/health-worker.js.map +1 -0
  22. package/dist/src/hooks/index.d.ts.map +1 -0
  23. package/dist/src/hooks/index.js.map +1 -0
  24. package/dist/src/index.d.ts.map +1 -0
  25. package/dist/src/index.js.map +1 -0
  26. package/dist/src/memory/index.d.ts.map +1 -0
  27. package/dist/src/memory/index.js.map +1 -0
  28. package/dist/src/policy/index.d.ts.map +1 -0
  29. package/dist/src/policy/index.js.map +1 -0
  30. package/dist/src/protocol/index.d.ts.map +1 -0
  31. package/dist/src/protocol/index.js.map +1 -0
  32. package/dist/src/resiliency/index.d.ts.map +1 -0
  33. package/dist/src/resiliency/index.js.map +1 -0
  34. package/dist/src/shared/cli-auth-config.d.ts.map +1 -0
  35. package/dist/src/shared/cli-auth-config.js.map +1 -0
  36. package/dist/src/state/index.d.ts.map +1 -0
  37. package/dist/src/state/index.js.map +1 -0
  38. package/dist/src/storage/index.d.ts.map +1 -0
  39. package/dist/src/storage/index.js.map +1 -0
  40. package/dist/src/trajectory/index.d.ts.map +1 -0
  41. package/dist/src/trajectory/index.js.map +1 -0
  42. package/dist/src/utils/index.d.ts.map +1 -0
  43. package/dist/src/utils/index.js.map +1 -0
  44. package/dist/src/wrapper/index.d.ts.map +1 -0
  45. package/dist/src/wrapper/index.js.map +1 -0
  46. package/package.json +83 -20
  47. package/packages/api-types/dist/index.d.ts.map +1 -0
  48. package/packages/api-types/dist/index.js.map +1 -0
  49. package/packages/api-types/dist/schemas/agent.d.ts.map +1 -0
  50. package/packages/api-types/dist/schemas/agent.js.map +1 -0
  51. package/packages/api-types/dist/schemas/api.d.ts.map +1 -0
  52. package/packages/api-types/dist/schemas/api.js.map +1 -0
  53. package/packages/api-types/dist/schemas/decision.d.ts.map +1 -0
  54. package/packages/api-types/dist/schemas/decision.js.map +1 -0
  55. package/packages/api-types/dist/schemas/fleet.d.ts.map +1 -0
  56. package/packages/api-types/dist/schemas/fleet.js.map +1 -0
  57. package/packages/api-types/dist/schemas/history.d.ts.map +1 -0
  58. package/packages/api-types/dist/schemas/history.js.map +1 -0
  59. package/packages/api-types/dist/schemas/index.d.ts.map +1 -0
  60. package/packages/api-types/dist/schemas/index.js.map +1 -0
  61. package/packages/api-types/dist/schemas/message.d.ts.map +1 -0
  62. package/packages/api-types/dist/schemas/message.js.map +1 -0
  63. package/packages/api-types/dist/schemas/session.d.ts.map +1 -0
  64. package/packages/api-types/dist/schemas/session.js.map +1 -0
  65. package/packages/api-types/dist/schemas/task.d.ts.map +1 -0
  66. package/packages/api-types/dist/schemas/task.js.map +1 -0
  67. package/packages/api-types/package.json +1 -1
  68. package/packages/api-types/src/index.ts +22 -0
  69. package/packages/api-types/src/schemas/agent.test.ts +164 -0
  70. package/packages/api-types/src/schemas/agent.ts +110 -0
  71. package/packages/api-types/src/schemas/api.test.ts +372 -0
  72. package/packages/api-types/src/schemas/api.ts +194 -0
  73. package/packages/api-types/src/schemas/decision.test.ts +324 -0
  74. package/packages/api-types/src/schemas/decision.ts +136 -0
  75. package/packages/api-types/src/schemas/fleet.test.ts +212 -0
  76. package/packages/api-types/src/schemas/fleet.ts +83 -0
  77. package/packages/api-types/src/schemas/history.test.ts +242 -0
  78. package/packages/api-types/src/schemas/history.ts +84 -0
  79. package/packages/api-types/src/schemas/index.ts +148 -0
  80. package/packages/api-types/src/schemas/message.test.ts +192 -0
  81. package/packages/api-types/src/schemas/message.ts +98 -0
  82. package/packages/api-types/src/schemas/session.test.ts +104 -0
  83. package/packages/api-types/src/schemas/session.ts +40 -0
  84. package/packages/api-types/src/schemas/task.test.ts +192 -0
  85. package/packages/api-types/src/schemas/task.ts +78 -0
  86. package/packages/api-types/tsconfig.json +19 -0
  87. package/packages/api-types/vitest.config.ts +9 -0
  88. package/packages/benchmark/README.md +200 -0
  89. package/packages/benchmark/datasets/coding-tasks.yaml +127 -0
  90. package/packages/benchmark/datasets/coordination-tasks.yaml +122 -0
  91. package/packages/benchmark/dist/benchmark.d.ts +47 -0
  92. package/packages/benchmark/dist/benchmark.d.ts.map +1 -0
  93. package/packages/benchmark/dist/benchmark.js +224 -0
  94. package/packages/benchmark/dist/benchmark.js.map +1 -0
  95. package/packages/benchmark/dist/cli.d.ts +8 -0
  96. package/packages/benchmark/dist/cli.d.ts.map +1 -0
  97. package/packages/benchmark/dist/cli.js +185 -0
  98. package/packages/benchmark/dist/cli.js.map +1 -0
  99. package/packages/benchmark/dist/harbor.d.ts +53 -0
  100. package/packages/benchmark/dist/harbor.d.ts.map +1 -0
  101. package/packages/benchmark/dist/harbor.js +127 -0
  102. package/packages/benchmark/dist/harbor.js.map +1 -0
  103. package/packages/benchmark/dist/index.d.ts +48 -0
  104. package/packages/benchmark/dist/index.d.ts.map +1 -0
  105. package/packages/benchmark/dist/index.js +50 -0
  106. package/packages/benchmark/dist/index.js.map +1 -0
  107. package/packages/benchmark/dist/runners/base.d.ts +63 -0
  108. package/packages/benchmark/dist/runners/base.d.ts.map +1 -0
  109. package/packages/benchmark/dist/runners/base.js +155 -0
  110. package/packages/benchmark/dist/runners/base.js.map +1 -0
  111. package/packages/benchmark/dist/runners/index.d.ts +10 -0
  112. package/packages/benchmark/dist/runners/index.d.ts.map +1 -0
  113. package/packages/benchmark/dist/runners/index.js +10 -0
  114. package/packages/benchmark/dist/runners/index.js.map +1 -0
  115. package/packages/benchmark/dist/runners/single.d.ts +19 -0
  116. package/packages/benchmark/dist/runners/single.d.ts.map +1 -0
  117. package/packages/benchmark/dist/runners/single.js +111 -0
  118. package/packages/benchmark/dist/runners/single.js.map +1 -0
  119. package/packages/benchmark/dist/runners/subagent.d.ts +32 -0
  120. package/packages/benchmark/dist/runners/subagent.d.ts.map +1 -0
  121. package/packages/benchmark/dist/runners/subagent.js +212 -0
  122. package/packages/benchmark/dist/runners/subagent.js.map +1 -0
  123. package/packages/benchmark/dist/runners/swarm.d.ts +36 -0
  124. package/packages/benchmark/dist/runners/swarm.d.ts.map +1 -0
  125. package/packages/benchmark/dist/runners/swarm.js +273 -0
  126. package/packages/benchmark/dist/runners/swarm.js.map +1 -0
  127. package/packages/benchmark/dist/types.d.ts +178 -0
  128. package/packages/benchmark/dist/types.d.ts.map +1 -0
  129. package/packages/benchmark/dist/types.js +16 -0
  130. package/packages/benchmark/dist/types.js.map +1 -0
  131. package/packages/benchmark/package.json +80 -0
  132. package/packages/benchmark/src/benchmark.ts +298 -0
  133. package/packages/benchmark/src/cli.ts +240 -0
  134. package/packages/benchmark/src/harbor.ts +170 -0
  135. package/packages/benchmark/src/index.ts +73 -0
  136. package/packages/benchmark/src/runners/base.ts +204 -0
  137. package/packages/benchmark/src/runners/index.ts +10 -0
  138. package/packages/benchmark/src/runners/single.ts +121 -0
  139. package/packages/benchmark/src/runners/subagent.ts +240 -0
  140. package/packages/benchmark/src/runners/swarm.ts +326 -0
  141. package/packages/benchmark/src/types.ts +205 -0
  142. package/packages/benchmark/tsconfig.json +20 -0
  143. package/packages/bridge/dist/index.d.ts.map +1 -0
  144. package/packages/bridge/dist/index.js.map +1 -0
  145. package/packages/bridge/dist/multi-project-client.d.ts.map +1 -0
  146. package/packages/bridge/dist/multi-project-client.js.map +1 -0
  147. package/packages/bridge/dist/shadow-cli.d.ts.map +1 -0
  148. package/packages/bridge/dist/shadow-cli.js.map +1 -0
  149. package/packages/bridge/dist/spawner.d.ts.map +1 -0
  150. package/packages/bridge/dist/spawner.js +10 -2
  151. package/packages/bridge/dist/spawner.js.map +1 -0
  152. package/packages/bridge/dist/types.d.ts.map +1 -0
  153. package/packages/bridge/dist/types.js.map +1 -0
  154. package/packages/bridge/dist/utils.d.ts.map +1 -0
  155. package/packages/bridge/dist/utils.js.map +1 -0
  156. package/packages/bridge/package.json +8 -8
  157. package/packages/bridge/src/index.ts +25 -0
  158. package/packages/bridge/src/multi-project-client.test.ts +340 -0
  159. package/packages/bridge/src/multi-project-client.ts +469 -0
  160. package/packages/bridge/src/shadow-cli.ts +95 -0
  161. package/packages/bridge/src/spawner-mcp.test.ts +505 -0
  162. package/packages/bridge/src/spawner.ts +1724 -0
  163. package/packages/bridge/src/types.ts +145 -0
  164. package/packages/bridge/src/utils.test.ts +98 -0
  165. package/packages/bridge/src/utils.ts +67 -0
  166. package/packages/bridge/tsconfig.json +29 -0
  167. package/packages/bridge/vitest.config.ts +9 -0
  168. package/packages/cli-tester/dist/index.d.ts.map +1 -0
  169. package/packages/cli-tester/dist/index.js.map +1 -0
  170. package/packages/cli-tester/dist/utils/credential-check.d.ts.map +1 -0
  171. package/packages/cli-tester/dist/utils/credential-check.js.map +1 -0
  172. package/packages/cli-tester/dist/utils/socket-client.d.ts.map +1 -0
  173. package/packages/cli-tester/dist/utils/socket-client.js.map +1 -0
  174. package/packages/cli-tester/docker/Dockerfile +61 -0
  175. package/packages/cli-tester/docker/docker-compose.yml +71 -0
  176. package/packages/cli-tester/package.json +1 -1
  177. package/packages/cli-tester/src/index.ts +40 -0
  178. package/packages/cli-tester/src/utils/credential-check.ts +284 -0
  179. package/packages/cli-tester/src/utils/socket-client.ts +211 -0
  180. package/packages/cli-tester/tests/credential-check.test.ts +56 -0
  181. package/packages/cli-tester/tsconfig.json +11 -0
  182. package/packages/config/dist/agent-config.d.ts.map +1 -0
  183. package/packages/config/dist/agent-config.js.map +1 -0
  184. package/packages/config/dist/bridge-config.d.ts.map +1 -0
  185. package/packages/config/dist/bridge-config.js.map +1 -0
  186. package/packages/config/dist/bridge-utils.d.ts.map +1 -0
  187. package/packages/config/dist/bridge-utils.js.map +1 -0
  188. package/packages/config/dist/cli-auth-config.d.ts.map +1 -0
  189. package/packages/config/dist/cli-auth-config.js.map +1 -0
  190. package/packages/config/dist/cloud-config.d.ts.map +1 -0
  191. package/packages/config/dist/cloud-config.js.map +1 -0
  192. package/packages/config/dist/index.d.ts.map +1 -0
  193. package/packages/config/dist/index.js.map +1 -0
  194. package/packages/config/dist/project-namespace.d.ts.map +1 -0
  195. package/packages/config/dist/project-namespace.js.map +1 -0
  196. package/packages/config/dist/relay-config.d.ts.map +1 -0
  197. package/packages/config/dist/relay-config.js.map +1 -0
  198. package/packages/config/dist/relay-file-writer.d.ts.map +1 -0
  199. package/packages/config/dist/relay-file-writer.js.map +1 -0
  200. package/packages/config/dist/schemas.d.ts.map +1 -0
  201. package/packages/config/dist/schemas.js.map +1 -0
  202. package/packages/config/dist/shadow-config.d.ts.map +1 -0
  203. package/packages/config/dist/shadow-config.js.map +1 -0
  204. package/packages/config/dist/teams-config.d.ts.map +1 -0
  205. package/packages/config/dist/teams-config.js.map +1 -0
  206. package/packages/config/dist/trajectory-config.d.ts.map +1 -0
  207. package/packages/config/dist/trajectory-config.js.map +1 -0
  208. package/packages/config/package.json +2 -2
  209. package/packages/config/src/agent-config.test.ts +245 -0
  210. package/packages/config/src/agent-config.ts +160 -0
  211. package/packages/config/src/bridge-config.test.ts +132 -0
  212. package/packages/config/src/bridge-config.ts +189 -0
  213. package/packages/config/src/bridge-utils.ts +59 -0
  214. package/packages/config/src/cli-auth-config.ts +548 -0
  215. package/packages/config/src/cloud-config.ts +208 -0
  216. package/packages/config/src/index.ts +12 -0
  217. package/packages/config/src/project-namespace.ts +344 -0
  218. package/packages/config/src/relay-config.test.ts +51 -0
  219. package/packages/config/src/relay-config.ts +36 -0
  220. package/packages/config/src/relay-file-writer.test.ts +351 -0
  221. package/packages/config/src/relay-file-writer.ts +508 -0
  222. package/packages/config/src/schemas.test.ts +59 -0
  223. package/packages/config/src/schemas.ts +201 -0
  224. package/packages/config/src/shadow-config.ts +205 -0
  225. package/packages/config/src/teams-config.ts +135 -0
  226. package/packages/config/src/trajectory-config.ts +222 -0
  227. package/packages/config/tsconfig.json +21 -0
  228. package/packages/config/vitest.config.ts +9 -0
  229. package/packages/continuity/dist/formatter.d.ts.map +1 -0
  230. package/packages/continuity/dist/formatter.js.map +1 -0
  231. package/packages/continuity/dist/handoff-store.d.ts.map +1 -0
  232. package/packages/continuity/dist/handoff-store.js.map +1 -0
  233. package/packages/continuity/dist/index.d.ts.map +1 -0
  234. package/packages/continuity/dist/index.js.map +1 -0
  235. package/packages/continuity/dist/ledger-store.d.ts.map +1 -0
  236. package/packages/continuity/dist/ledger-store.js.map +1 -0
  237. package/packages/continuity/dist/manager.d.ts.map +1 -0
  238. package/packages/continuity/dist/manager.js.map +1 -0
  239. package/packages/continuity/dist/parser.d.ts.map +1 -0
  240. package/packages/continuity/dist/parser.js.map +1 -0
  241. package/packages/continuity/dist/types.d.ts.map +1 -0
  242. package/packages/continuity/dist/types.js.map +1 -0
  243. package/packages/continuity/package.json +1 -1
  244. package/packages/continuity/src/formatter.ts +371 -0
  245. package/packages/continuity/src/handoff-store.ts +523 -0
  246. package/packages/continuity/src/index.ts +9 -0
  247. package/packages/continuity/src/ledger-store.ts +594 -0
  248. package/packages/continuity/src/manager.test.ts +291 -0
  249. package/packages/continuity/src/manager.ts +774 -0
  250. package/packages/continuity/src/parser.test.ts +292 -0
  251. package/packages/continuity/src/parser.ts +680 -0
  252. package/packages/continuity/src/types.ts +211 -0
  253. package/packages/continuity/tsconfig.json +21 -0
  254. package/packages/continuity/vitest.config.ts +9 -0
  255. package/packages/daemon/dist/agent-manager.d.ts.map +1 -0
  256. package/packages/daemon/dist/agent-manager.js.map +1 -0
  257. package/packages/daemon/dist/agent-registry.d.ts.map +1 -0
  258. package/packages/daemon/dist/agent-registry.js.map +1 -0
  259. package/packages/daemon/dist/agent-signing.d.ts.map +1 -0
  260. package/packages/daemon/dist/agent-signing.js.map +1 -0
  261. package/packages/daemon/dist/api.d.ts.map +1 -0
  262. package/packages/daemon/dist/api.js.map +1 -0
  263. package/packages/daemon/dist/auth.d.ts.map +1 -0
  264. package/packages/daemon/dist/auth.js.map +1 -0
  265. package/packages/daemon/dist/channel-membership-store.d.ts.map +1 -0
  266. package/packages/daemon/dist/channel-membership-store.js.map +1 -0
  267. package/packages/daemon/dist/cli-auth.d.ts.map +1 -0
  268. package/packages/daemon/dist/cli-auth.js.map +1 -0
  269. package/packages/daemon/dist/cloud-sync.d.ts.map +1 -0
  270. package/packages/daemon/dist/cloud-sync.js.map +1 -0
  271. package/packages/daemon/dist/connection.d.ts.map +1 -0
  272. package/packages/daemon/dist/connection.js.map +1 -0
  273. package/packages/daemon/dist/consensus-integration.d.ts.map +1 -0
  274. package/packages/daemon/dist/consensus-integration.js.map +1 -0
  275. package/packages/daemon/dist/consensus.d.ts.map +1 -0
  276. package/packages/daemon/dist/consensus.js.map +1 -0
  277. package/packages/daemon/dist/delivery-tracker.d.ts.map +1 -0
  278. package/packages/daemon/dist/delivery-tracker.js.map +1 -0
  279. package/packages/daemon/dist/enhanced-features.d.ts.map +1 -0
  280. package/packages/daemon/dist/enhanced-features.js.map +1 -0
  281. package/packages/daemon/dist/index.d.ts.map +1 -0
  282. package/packages/daemon/dist/index.js.map +1 -0
  283. package/packages/daemon/dist/migrations/index.d.ts.map +1 -0
  284. package/packages/daemon/dist/migrations/index.js.map +1 -0
  285. package/packages/daemon/dist/orchestrator.d.ts.map +1 -0
  286. package/packages/daemon/dist/orchestrator.js.map +1 -0
  287. package/packages/daemon/dist/rate-limiter.d.ts.map +1 -0
  288. package/packages/daemon/dist/rate-limiter.js.map +1 -0
  289. package/packages/daemon/dist/registry.d.ts.map +1 -0
  290. package/packages/daemon/dist/registry.js.map +1 -0
  291. package/packages/daemon/dist/relay-ledger.d.ts.map +1 -0
  292. package/packages/daemon/dist/relay-ledger.js.map +1 -0
  293. package/packages/daemon/dist/relay-watchdog.d.ts.map +1 -0
  294. package/packages/daemon/dist/relay-watchdog.js.map +1 -0
  295. package/packages/daemon/dist/repo-manager.d.ts.map +1 -0
  296. package/packages/daemon/dist/repo-manager.js.map +1 -0
  297. package/packages/daemon/dist/router.d.ts.map +1 -0
  298. package/packages/daemon/dist/router.js.map +1 -0
  299. package/packages/daemon/dist/server.d.ts +1 -0
  300. package/packages/daemon/dist/server.d.ts.map +1 -0
  301. package/packages/daemon/dist/server.js +46 -16
  302. package/packages/daemon/dist/server.js.map +1 -0
  303. package/packages/daemon/dist/spawn-manager.d.ts.map +1 -0
  304. package/packages/daemon/dist/spawn-manager.js.map +1 -0
  305. package/packages/daemon/dist/sync-queue.d.ts.map +1 -0
  306. package/packages/daemon/dist/sync-queue.js.map +1 -0
  307. package/packages/daemon/dist/types.d.ts.map +1 -0
  308. package/packages/daemon/dist/types.js.map +1 -0
  309. package/packages/daemon/dist/workspace-manager.d.ts.map +1 -0
  310. package/packages/daemon/dist/workspace-manager.js.map +1 -0
  311. package/packages/daemon/package.json +12 -12
  312. package/packages/daemon/src/agent-manager.ts +679 -0
  313. package/packages/daemon/src/agent-registry.ts +284 -0
  314. package/packages/daemon/src/agent-signing.ts +707 -0
  315. package/packages/daemon/src/api.ts +1012 -0
  316. package/packages/daemon/src/auth.ts +276 -0
  317. package/packages/daemon/src/channel-membership-store.ts +217 -0
  318. package/packages/daemon/src/cli-auth.ts +906 -0
  319. package/packages/daemon/src/cloud-sync.ts +902 -0
  320. package/packages/daemon/src/connection.ts +534 -0
  321. package/packages/daemon/src/consensus-integration.ts +510 -0
  322. package/packages/daemon/src/consensus.ts +848 -0
  323. package/packages/daemon/src/delivery-tracker.ts +145 -0
  324. package/packages/daemon/src/enhanced-features.ts +390 -0
  325. package/packages/daemon/src/index.ts +52 -0
  326. package/packages/daemon/src/migrations/0001_initial.sql +72 -0
  327. package/packages/daemon/src/migrations/index.test.ts +195 -0
  328. package/packages/daemon/src/migrations/index.ts +286 -0
  329. package/packages/daemon/src/orchestrator.test.ts +231 -0
  330. package/packages/daemon/src/orchestrator.ts +1376 -0
  331. package/packages/daemon/src/rate-limiter.ts +172 -0
  332. package/packages/daemon/src/registry.ts +8 -0
  333. package/packages/daemon/src/relay-ledger.test.ts +358 -0
  334. package/packages/daemon/src/relay-ledger.ts +713 -0
  335. package/packages/daemon/src/relay-watchdog.test.ts +881 -0
  336. package/packages/daemon/src/relay-watchdog.ts +785 -0
  337. package/packages/daemon/src/repo-manager.ts +468 -0
  338. package/packages/daemon/src/router.test.ts +149 -0
  339. package/packages/daemon/src/router.ts +1885 -0
  340. package/packages/daemon/src/server.ts +1871 -0
  341. package/packages/daemon/src/spawn-manager.ts +275 -0
  342. package/packages/daemon/src/sync-queue.ts +477 -0
  343. package/packages/daemon/src/types.ts +158 -0
  344. package/packages/daemon/src/workspace-manager.ts +371 -0
  345. package/packages/daemon/tsconfig.json +21 -0
  346. package/packages/hooks/dist/browser.d.ts.map +1 -0
  347. package/packages/hooks/dist/browser.js.map +1 -0
  348. package/packages/hooks/dist/emitter.d.ts.map +1 -0
  349. package/packages/hooks/dist/emitter.js.map +1 -0
  350. package/packages/hooks/dist/inbox-check/hook.d.ts.map +1 -0
  351. package/packages/hooks/dist/inbox-check/hook.js.map +1 -0
  352. package/packages/hooks/dist/inbox-check/index.d.ts.map +1 -0
  353. package/packages/hooks/dist/inbox-check/index.js.map +1 -0
  354. package/packages/hooks/dist/inbox-check/types.d.ts.map +1 -0
  355. package/packages/hooks/dist/inbox-check/types.js.map +1 -0
  356. package/packages/hooks/dist/inbox-check/utils.d.ts.map +1 -0
  357. package/packages/hooks/dist/inbox-check/utils.js.map +1 -0
  358. package/packages/hooks/dist/index.d.ts.map +1 -0
  359. package/packages/hooks/dist/index.js.map +1 -0
  360. package/packages/hooks/dist/registry.d.ts.map +1 -0
  361. package/packages/hooks/dist/registry.js.map +1 -0
  362. package/packages/hooks/dist/trajectory-hooks.d.ts.map +1 -0
  363. package/packages/hooks/dist/trajectory-hooks.js.map +1 -0
  364. package/packages/hooks/dist/types.d.ts.map +1 -0
  365. package/packages/hooks/dist/types.js.map +1 -0
  366. package/packages/hooks/package.json +4 -4
  367. package/packages/hooks/src/browser.ts +2 -0
  368. package/packages/hooks/src/emitter.ts +84 -0
  369. package/packages/hooks/src/inbox-check/hook.ts +114 -0
  370. package/packages/hooks/src/inbox-check/index.ts +8 -0
  371. package/packages/hooks/src/inbox-check/types.ts +39 -0
  372. package/packages/hooks/src/inbox-check/utils.test.ts +287 -0
  373. package/packages/hooks/src/inbox-check/utils.ts +125 -0
  374. package/packages/hooks/src/index.ts +11 -0
  375. package/packages/hooks/src/registry.ts +614 -0
  376. package/packages/hooks/src/shims.d.ts +3 -0
  377. package/packages/hooks/src/trajectory-hooks.ts +251 -0
  378. package/packages/hooks/src/types.ts +342 -0
  379. package/packages/hooks/tsconfig.json +21 -0
  380. package/packages/hooks/vitest.config.ts +9 -0
  381. package/packages/mcp/dist/bin.d.ts.map +1 -0
  382. package/packages/mcp/dist/bin.js.map +1 -0
  383. package/packages/mcp/dist/client.d.ts +9 -15
  384. package/packages/mcp/dist/client.d.ts.map +1 -0
  385. package/packages/mcp/dist/client.js +42 -74
  386. package/packages/mcp/dist/client.js.map +1 -0
  387. package/packages/mcp/dist/cloud.d.ts.map +1 -0
  388. package/packages/mcp/dist/cloud.js.map +1 -0
  389. package/packages/mcp/dist/errors.d.ts.map +1 -0
  390. package/packages/mcp/dist/errors.js.map +1 -0
  391. package/packages/mcp/dist/file-transport.d.ts.map +1 -0
  392. package/packages/mcp/dist/file-transport.js.map +1 -0
  393. package/packages/mcp/dist/hybrid-client.d.ts.map +1 -0
  394. package/packages/mcp/dist/hybrid-client.js.map +1 -0
  395. package/packages/mcp/dist/index.d.ts.map +1 -0
  396. package/packages/mcp/dist/index.js.map +1 -0
  397. package/packages/mcp/dist/install-cli.d.ts.map +1 -0
  398. package/packages/mcp/dist/install-cli.js.map +1 -0
  399. package/packages/mcp/dist/install.d.ts.map +1 -0
  400. package/packages/mcp/dist/install.js.map +1 -0
  401. package/packages/mcp/dist/prompts/index.d.ts.map +1 -0
  402. package/packages/mcp/dist/prompts/index.js.map +1 -0
  403. package/packages/mcp/dist/prompts/protocol.d.ts.map +1 -0
  404. package/packages/mcp/dist/prompts/protocol.js.map +1 -0
  405. package/packages/mcp/dist/resources/agents.d.ts.map +1 -0
  406. package/packages/mcp/dist/resources/agents.js.map +1 -0
  407. package/packages/mcp/dist/resources/inbox.d.ts.map +1 -0
  408. package/packages/mcp/dist/resources/inbox.js.map +1 -0
  409. package/packages/mcp/dist/resources/index.d.ts.map +1 -0
  410. package/packages/mcp/dist/resources/index.js.map +1 -0
  411. package/packages/mcp/dist/resources/project.d.ts.map +1 -0
  412. package/packages/mcp/dist/resources/project.js.map +1 -0
  413. package/packages/mcp/dist/server.d.ts.map +1 -0
  414. package/packages/mcp/dist/server.js.map +1 -0
  415. package/packages/mcp/dist/simple.d.ts +2 -5
  416. package/packages/mcp/dist/simple.d.ts.map +1 -0
  417. package/packages/mcp/dist/simple.js.map +1 -0
  418. package/packages/mcp/dist/tools/index.d.ts.map +1 -0
  419. package/packages/mcp/dist/tools/index.js.map +1 -0
  420. package/packages/mcp/dist/tools/relay-broadcast.d.ts.map +1 -0
  421. package/packages/mcp/dist/tools/relay-broadcast.js.map +1 -0
  422. package/packages/mcp/dist/tools/relay-channel.d.ts.map +1 -0
  423. package/packages/mcp/dist/tools/relay-channel.js.map +1 -0
  424. package/packages/mcp/dist/tools/relay-connected.d.ts.map +1 -0
  425. package/packages/mcp/dist/tools/relay-connected.js.map +1 -0
  426. package/packages/mcp/dist/tools/relay-consensus.d.ts.map +1 -0
  427. package/packages/mcp/dist/tools/relay-consensus.js.map +1 -0
  428. package/packages/mcp/dist/tools/relay-continuity.d.ts.map +1 -0
  429. package/packages/mcp/dist/tools/relay-continuity.js.map +1 -0
  430. package/packages/mcp/dist/tools/relay-health.d.ts.map +1 -0
  431. package/packages/mcp/dist/tools/relay-health.js.map +1 -0
  432. package/packages/mcp/dist/tools/relay-inbox.d.ts.map +1 -0
  433. package/packages/mcp/dist/tools/relay-inbox.js.map +1 -0
  434. package/packages/mcp/dist/tools/relay-logs.d.ts.map +1 -0
  435. package/packages/mcp/dist/tools/relay-logs.js.map +1 -0
  436. package/packages/mcp/dist/tools/relay-metrics.d.ts.map +1 -0
  437. package/packages/mcp/dist/tools/relay-metrics.js.map +1 -0
  438. package/packages/mcp/dist/tools/relay-release.d.ts.map +1 -0
  439. package/packages/mcp/dist/tools/relay-release.js.map +1 -0
  440. package/packages/mcp/dist/tools/relay-remove-agent.d.ts.map +1 -0
  441. package/packages/mcp/dist/tools/relay-remove-agent.js.map +1 -0
  442. package/packages/mcp/dist/tools/relay-send.d.ts.map +1 -0
  443. package/packages/mcp/dist/tools/relay-send.js +4 -2
  444. package/packages/mcp/dist/tools/relay-send.js.map +1 -0
  445. package/packages/mcp/dist/tools/relay-shadow.d.ts.map +1 -0
  446. package/packages/mcp/dist/tools/relay-shadow.js.map +1 -0
  447. package/packages/mcp/dist/tools/relay-spawn.d.ts.map +1 -0
  448. package/packages/mcp/dist/tools/relay-spawn.js.map +1 -0
  449. package/packages/mcp/dist/tools/relay-status.d.ts.map +1 -0
  450. package/packages/mcp/dist/tools/relay-status.js.map +1 -0
  451. package/packages/mcp/dist/tools/relay-subscribe.d.ts.map +1 -0
  452. package/packages/mcp/dist/tools/relay-subscribe.js.map +1 -0
  453. package/packages/mcp/dist/tools/relay-who.d.ts.map +1 -0
  454. package/packages/mcp/dist/tools/relay-who.js.map +1 -0
  455. package/packages/mcp/package.json +3 -3
  456. package/packages/mcp/src/bin.ts +149 -0
  457. package/packages/mcp/src/client.ts +400 -0
  458. package/packages/mcp/src/cloud.ts +523 -0
  459. package/packages/mcp/src/errors.ts +54 -0
  460. package/packages/mcp/src/file-transport.ts +268 -0
  461. package/packages/mcp/src/hybrid-client.ts +209 -0
  462. package/packages/mcp/src/index.ts +122 -0
  463. package/packages/mcp/src/install-cli.ts +210 -0
  464. package/packages/mcp/src/install.ts +745 -0
  465. package/packages/mcp/src/prompts/index.ts +1 -0
  466. package/packages/mcp/src/prompts/protocol.ts +164 -0
  467. package/packages/mcp/src/resources/agents.ts +21 -0
  468. package/packages/mcp/src/resources/inbox.ts +21 -0
  469. package/packages/mcp/src/resources/index.ts +3 -0
  470. package/packages/mcp/src/resources/project.ts +29 -0
  471. package/packages/mcp/src/server.ts +431 -0
  472. package/packages/mcp/src/simple.ts +214 -0
  473. package/packages/mcp/src/tools/index.ts +133 -0
  474. package/packages/mcp/src/tools/relay-broadcast.ts +32 -0
  475. package/packages/mcp/src/tools/relay-channel.ts +93 -0
  476. package/packages/mcp/src/tools/relay-connected.ts +52 -0
  477. package/packages/mcp/src/tools/relay-consensus.ts +92 -0
  478. package/packages/mcp/src/tools/relay-continuity.ts +127 -0
  479. package/packages/mcp/src/tools/relay-health.ts +148 -0
  480. package/packages/mcp/src/tools/relay-inbox.ts +70 -0
  481. package/packages/mcp/src/tools/relay-logs.ts +106 -0
  482. package/packages/mcp/src/tools/relay-metrics.ts +140 -0
  483. package/packages/mcp/src/tools/relay-release.ts +54 -0
  484. package/packages/mcp/src/tools/relay-remove-agent.ts +58 -0
  485. package/packages/mcp/src/tools/relay-send.ts +84 -0
  486. package/packages/mcp/src/tools/relay-shadow.ts +67 -0
  487. package/packages/mcp/src/tools/relay-spawn.ts +87 -0
  488. package/packages/mcp/src/tools/relay-status.ts +57 -0
  489. package/packages/mcp/src/tools/relay-subscribe.ts +61 -0
  490. package/packages/mcp/src/tools/relay-who.ts +59 -0
  491. package/packages/mcp/tests/client.test.ts +476 -0
  492. package/packages/mcp/tests/discover.test.ts +195 -0
  493. package/packages/mcp/tests/install.test.ts +123 -0
  494. package/packages/mcp/tests/prompts.test.ts +12 -0
  495. package/packages/mcp/tests/resources.test.ts +53 -0
  496. package/packages/mcp/tests/tools.test.ts +1242 -0
  497. package/packages/mcp/tsconfig.json +22 -0
  498. package/packages/mcp/vitest.config.ts +9 -0
  499. package/packages/memory/dist/adapters/index.d.ts.map +1 -0
  500. package/packages/memory/dist/adapters/index.js.map +1 -0
  501. package/packages/memory/dist/adapters/inmemory.d.ts.map +1 -0
  502. package/packages/memory/dist/adapters/inmemory.js.map +1 -0
  503. package/packages/memory/dist/adapters/supermemory.d.ts.map +1 -0
  504. package/packages/memory/dist/adapters/supermemory.js.map +1 -0
  505. package/packages/memory/dist/context-compaction.d.ts.map +1 -0
  506. package/packages/memory/dist/context-compaction.js.map +1 -0
  507. package/packages/memory/dist/factory.d.ts.map +1 -0
  508. package/packages/memory/dist/factory.js.map +1 -0
  509. package/packages/memory/dist/index.d.ts.map +1 -0
  510. package/packages/memory/dist/index.js.map +1 -0
  511. package/packages/memory/dist/memory-hooks.d.ts.map +1 -0
  512. package/packages/memory/dist/memory-hooks.js.map +1 -0
  513. package/packages/memory/dist/service.d.ts.map +1 -0
  514. package/packages/memory/dist/service.js.map +1 -0
  515. package/packages/memory/dist/types.d.ts.map +1 -0
  516. package/packages/memory/dist/types.js.map +1 -0
  517. package/packages/memory/package.json +2 -2
  518. package/packages/memory/src/adapters/index.ts +8 -0
  519. package/packages/memory/src/adapters/inmemory.ts +265 -0
  520. package/packages/memory/src/adapters/supermemory.ts +449 -0
  521. package/packages/memory/src/context-compaction.test.ts +660 -0
  522. package/packages/memory/src/context-compaction.ts +612 -0
  523. package/packages/memory/src/factory.ts +170 -0
  524. package/packages/memory/src/index.ts +33 -0
  525. package/packages/memory/src/memory-hooks.ts +410 -0
  526. package/packages/memory/src/service.ts +194 -0
  527. package/packages/memory/src/types.ts +211 -0
  528. package/packages/memory/tsconfig.json +21 -0
  529. package/packages/memory/vitest.config.ts +9 -0
  530. package/packages/policy/dist/agent-policy.d.ts.map +1 -0
  531. package/packages/policy/dist/agent-policy.js.map +1 -0
  532. package/packages/policy/dist/cloud-policy-fetcher.d.ts.map +1 -0
  533. package/packages/policy/dist/cloud-policy-fetcher.js.map +1 -0
  534. package/packages/policy/dist/index.d.ts.map +1 -0
  535. package/packages/policy/dist/index.js.map +1 -0
  536. package/packages/policy/package.json +2 -2
  537. package/packages/policy/src/agent-policy.ts +866 -0
  538. package/packages/policy/src/cloud-policy-fetcher.ts +78 -0
  539. package/packages/policy/src/index.ts +21 -0
  540. package/packages/policy/tsconfig.json +21 -0
  541. package/packages/policy/vitest.config.ts +9 -0
  542. package/packages/protocol/dist/channels.d.ts.map +1 -0
  543. package/packages/protocol/dist/channels.js.map +1 -0
  544. package/packages/protocol/dist/framing.d.ts.map +1 -0
  545. package/packages/protocol/dist/framing.js.map +1 -0
  546. package/packages/protocol/dist/id-generator.d.ts.map +1 -0
  547. package/packages/protocol/dist/id-generator.js.map +1 -0
  548. package/packages/protocol/dist/index.d.ts.map +1 -0
  549. package/packages/protocol/dist/index.js.map +1 -0
  550. package/packages/protocol/dist/relay-pty-schemas.d.ts +70 -2
  551. package/packages/protocol/dist/relay-pty-schemas.d.ts.map +1 -0
  552. package/packages/protocol/dist/relay-pty-schemas.js.map +1 -0
  553. package/packages/protocol/dist/types.d.ts +8 -0
  554. package/packages/protocol/dist/types.d.ts.map +1 -0
  555. package/packages/protocol/dist/types.js.map +1 -0
  556. package/packages/protocol/package.json +1 -1
  557. package/packages/protocol/src/channels.test.ts +330 -0
  558. package/packages/protocol/src/channels.ts +270 -0
  559. package/packages/protocol/src/framing.test.ts +164 -0
  560. package/packages/protocol/src/framing.ts +242 -0
  561. package/packages/protocol/src/id-generator.ts +69 -0
  562. package/packages/protocol/src/index.ts +4 -0
  563. package/packages/protocol/src/relay-pty-schemas.ts +400 -0
  564. package/packages/protocol/src/types.test.ts +271 -0
  565. package/packages/protocol/src/types.ts +846 -0
  566. package/packages/protocol/tsconfig.json +21 -0
  567. package/packages/protocol/vitest.config.ts +9 -0
  568. package/packages/resiliency/dist/cgroup-manager.d.ts.map +1 -0
  569. package/packages/resiliency/dist/cgroup-manager.js.map +1 -0
  570. package/packages/resiliency/dist/context-persistence.d.ts.map +1 -0
  571. package/packages/resiliency/dist/context-persistence.js.map +1 -0
  572. package/packages/resiliency/dist/crash-insights.d.ts.map +1 -0
  573. package/packages/resiliency/dist/crash-insights.js.map +1 -0
  574. package/packages/resiliency/dist/gossip-health.d.ts.map +1 -0
  575. package/packages/resiliency/dist/gossip-health.js.map +1 -0
  576. package/packages/resiliency/dist/health-monitor.d.ts.map +1 -0
  577. package/packages/resiliency/dist/health-monitor.js.map +1 -0
  578. package/packages/resiliency/dist/index.d.ts.map +1 -0
  579. package/packages/resiliency/dist/index.js.map +1 -0
  580. package/packages/resiliency/dist/leader-watchdog.d.ts.map +1 -0
  581. package/packages/resiliency/dist/leader-watchdog.js.map +1 -0
  582. package/packages/resiliency/dist/logger.d.ts.map +1 -0
  583. package/packages/resiliency/dist/logger.js.map +1 -0
  584. package/packages/resiliency/dist/memory-monitor.d.ts.map +1 -0
  585. package/packages/resiliency/dist/memory-monitor.js.map +1 -0
  586. package/packages/resiliency/dist/metrics.d.ts.map +1 -0
  587. package/packages/resiliency/dist/metrics.js.map +1 -0
  588. package/packages/resiliency/dist/provider-context.d.ts.map +1 -0
  589. package/packages/resiliency/dist/provider-context.js.map +1 -0
  590. package/packages/resiliency/dist/stateless-lead.d.ts.map +1 -0
  591. package/packages/resiliency/dist/stateless-lead.js.map +1 -0
  592. package/packages/resiliency/dist/supervisor.d.ts.map +1 -0
  593. package/packages/resiliency/dist/supervisor.js.map +1 -0
  594. package/packages/resiliency/package.json +1 -1
  595. package/packages/resiliency/src/cgroup-manager.ts +468 -0
  596. package/packages/resiliency/src/context-persistence.ts +538 -0
  597. package/packages/resiliency/src/crash-insights.test.ts +620 -0
  598. package/packages/resiliency/src/crash-insights.ts +660 -0
  599. package/packages/resiliency/src/gossip-health.ts +333 -0
  600. package/packages/resiliency/src/health-monitor.ts +371 -0
  601. package/packages/resiliency/src/index.ts +157 -0
  602. package/packages/resiliency/src/leader-watchdog.ts +260 -0
  603. package/packages/resiliency/src/logger.ts +320 -0
  604. package/packages/resiliency/src/memory-monitor.test.ts +637 -0
  605. package/packages/resiliency/src/memory-monitor.ts +740 -0
  606. package/packages/resiliency/src/metrics.ts +311 -0
  607. package/packages/resiliency/src/provider-context.ts +452 -0
  608. package/packages/resiliency/src/stateless-lead.ts +408 -0
  609. package/packages/resiliency/src/supervisor.ts +578 -0
  610. package/packages/resiliency/tsconfig.json +21 -0
  611. package/packages/resiliency/vitest.config.ts +9 -0
  612. package/packages/sdk/dist/client.d.ts.map +1 -0
  613. package/packages/sdk/dist/client.js.map +1 -0
  614. package/packages/sdk/dist/index.d.ts.map +1 -0
  615. package/packages/sdk/dist/index.js.map +1 -0
  616. package/packages/sdk/dist/logs.d.ts.map +1 -0
  617. package/packages/sdk/dist/logs.js.map +1 -0
  618. package/packages/sdk/dist/protocol/index.d.ts.map +1 -0
  619. package/packages/sdk/dist/protocol/index.js.map +1 -0
  620. package/packages/sdk/dist/standalone.d.ts.map +1 -0
  621. package/packages/sdk/dist/standalone.js.map +1 -0
  622. package/packages/sdk/examples/SWARM_CAPABILITIES.md +498 -0
  623. package/packages/sdk/examples/SWARM_PATTERNS.md +541 -0
  624. package/packages/sdk/package.json +2 -2
  625. package/packages/sdk/src/client.test.ts +568 -0
  626. package/packages/sdk/src/client.ts +1418 -0
  627. package/packages/sdk/src/index.ts +103 -0
  628. package/packages/sdk/src/logs.test.ts +98 -0
  629. package/packages/sdk/src/logs.ts +126 -0
  630. package/packages/sdk/src/protocol/framing.test.ts +164 -0
  631. package/packages/sdk/src/protocol/index.ts +8 -0
  632. package/packages/sdk/src/standalone.ts +176 -0
  633. package/packages/sdk/tsconfig.json +22 -0
  634. package/packages/sdk/vitest.config.ts +9 -0
  635. package/packages/spawner/.trajectories/index.json +5 -0
  636. package/packages/spawner/dist/index.d.ts.map +1 -0
  637. package/packages/spawner/dist/index.js.map +1 -0
  638. package/packages/spawner/dist/types.d.ts.map +1 -0
  639. package/packages/spawner/dist/types.js.map +1 -0
  640. package/packages/spawner/package.json +1 -1
  641. package/packages/spawner/src/index.ts +8 -0
  642. package/packages/spawner/src/types.test.ts +385 -0
  643. package/packages/spawner/src/types.ts +228 -0
  644. package/packages/spawner/tsconfig.json +19 -0
  645. package/packages/spawner/vitest.config.ts +9 -0
  646. package/packages/state/dist/agent-state.d.ts.map +1 -0
  647. package/packages/state/dist/agent-state.js.map +1 -0
  648. package/packages/state/dist/index.d.ts.map +1 -0
  649. package/packages/state/dist/index.js.map +1 -0
  650. package/packages/state/package.json +1 -1
  651. package/packages/state/src/agent-state.test.ts +335 -0
  652. package/packages/state/src/agent-state.ts +153 -0
  653. package/packages/state/src/index.ts +12 -0
  654. package/packages/state/tsconfig.json +21 -0
  655. package/packages/state/vitest.config.ts +9 -0
  656. package/packages/storage/dist/adapter.d.ts +28 -1
  657. package/packages/storage/dist/adapter.d.ts.map +1 -0
  658. package/packages/storage/dist/adapter.js +104 -10
  659. package/packages/storage/dist/adapter.js.map +1 -0
  660. package/packages/storage/dist/batched-sqlite-adapter.d.ts.map +1 -0
  661. package/packages/storage/dist/batched-sqlite-adapter.js.map +1 -0
  662. package/packages/storage/dist/dead-letter-queue.d.ts.map +1 -0
  663. package/packages/storage/dist/dead-letter-queue.js.map +1 -0
  664. package/packages/storage/dist/dlq-adapter.d.ts.map +1 -0
  665. package/packages/storage/dist/dlq-adapter.js.map +1 -0
  666. package/packages/storage/dist/index.d.ts +1 -0
  667. package/packages/storage/dist/index.d.ts.map +1 -0
  668. package/packages/storage/dist/index.js +1 -0
  669. package/packages/storage/dist/index.js.map +1 -0
  670. package/packages/storage/dist/jsonl-adapter.d.ts +77 -0
  671. package/packages/storage/dist/jsonl-adapter.d.ts.map +1 -0
  672. package/packages/storage/dist/jsonl-adapter.js +505 -0
  673. package/packages/storage/dist/jsonl-adapter.js.map +1 -0
  674. package/packages/storage/dist/sqlite-adapter.d.ts +6 -1
  675. package/packages/storage/dist/sqlite-adapter.d.ts.map +1 -0
  676. package/packages/storage/dist/sqlite-adapter.js +47 -0
  677. package/packages/storage/dist/sqlite-adapter.js.map +1 -0
  678. package/packages/storage/package.json +2 -2
  679. package/packages/storage/src/adapter.ts +438 -0
  680. package/packages/storage/src/batched-sqlite-adapter.test.ts +240 -0
  681. package/packages/storage/src/batched-sqlite-adapter.ts +239 -0
  682. package/packages/storage/src/dead-letter-queue.ts +643 -0
  683. package/packages/storage/src/dlq-adapter.test.ts +492 -0
  684. package/packages/storage/src/dlq-adapter.ts +954 -0
  685. package/packages/storage/src/index.ts +6 -0
  686. package/packages/storage/src/jsonl-adapter.test.ts +200 -0
  687. package/packages/storage/src/jsonl-adapter.ts +618 -0
  688. package/packages/storage/src/memory-adapter.test.ts +36 -0
  689. package/packages/storage/src/sqlite-adapter.test.ts +562 -0
  690. package/packages/storage/src/sqlite-adapter.ts +1058 -0
  691. package/packages/storage/tsconfig.json +21 -0
  692. package/packages/storage/vitest.config.ts +9 -0
  693. package/packages/telemetry/dist/client.d.ts.map +1 -0
  694. package/packages/telemetry/dist/client.js.map +1 -0
  695. package/packages/telemetry/dist/config.d.ts.map +1 -0
  696. package/packages/telemetry/dist/config.js.map +1 -0
  697. package/packages/telemetry/dist/events.d.ts.map +1 -0
  698. package/packages/telemetry/dist/events.js.map +1 -0
  699. package/packages/telemetry/dist/index.d.ts.map +1 -0
  700. package/packages/telemetry/dist/index.js.map +1 -0
  701. package/packages/telemetry/dist/machine-id.d.ts.map +1 -0
  702. package/packages/telemetry/dist/machine-id.js.map +1 -0
  703. package/packages/telemetry/dist/posthog-config.d.ts.map +1 -0
  704. package/packages/telemetry/dist/posthog-config.js.map +1 -0
  705. package/packages/telemetry/package.json +1 -1
  706. package/packages/telemetry/src/client.ts +158 -0
  707. package/packages/telemetry/src/config.ts +110 -0
  708. package/packages/telemetry/src/events.ts +137 -0
  709. package/packages/telemetry/src/index.ts +46 -0
  710. package/packages/telemetry/src/machine-id.ts +63 -0
  711. package/packages/telemetry/src/posthog-config.ts +39 -0
  712. package/packages/telemetry/tsconfig.json +21 -0
  713. package/packages/trajectory/dist/index.d.ts.map +1 -0
  714. package/packages/trajectory/dist/index.js.map +1 -0
  715. package/packages/trajectory/dist/integration.d.ts.map +1 -0
  716. package/packages/trajectory/dist/integration.js.map +1 -0
  717. package/packages/trajectory/package.json +2 -2
  718. package/packages/trajectory/src/index.ts +1 -0
  719. package/packages/trajectory/src/integration.ts +1268 -0
  720. package/packages/trajectory/tsconfig.json +21 -0
  721. package/packages/trajectory/vitest.config.ts +9 -0
  722. package/packages/user-directory/dist/index.d.ts.map +1 -0
  723. package/packages/user-directory/dist/index.js.map +1 -0
  724. package/packages/user-directory/dist/user-directory.d.ts.map +1 -0
  725. package/packages/user-directory/dist/user-directory.js.map +1 -0
  726. package/packages/user-directory/package.json +2 -2
  727. package/packages/user-directory/src/index.ts +12 -0
  728. package/packages/user-directory/src/user-directory.ts +393 -0
  729. package/packages/user-directory/tsconfig.json +21 -0
  730. package/packages/user-directory/vitest.config.ts +9 -0
  731. package/packages/utils/dist/cjs/client-helpers.js +127 -0
  732. package/packages/utils/dist/cjs/command-resolver.js +89 -0
  733. package/packages/utils/dist/cjs/error-tracking.js +106 -0
  734. package/packages/utils/dist/cjs/git-remote.js +120 -0
  735. package/packages/utils/dist/cjs/index.js +40 -0
  736. package/packages/utils/dist/cjs/logger.js +105 -0
  737. package/packages/utils/dist/cjs/model-mapping.js +54 -0
  738. package/packages/utils/dist/cjs/name-generator.js +179 -0
  739. package/packages/utils/dist/cjs/package.json +3 -0
  740. package/packages/utils/dist/cjs/precompiled-patterns.js +271 -0
  741. package/packages/utils/dist/cjs/relay-pty-path.js +143 -0
  742. package/packages/utils/dist/cjs/update-checker.js +185 -0
  743. package/packages/utils/dist/client-helpers.d.ts +73 -0
  744. package/packages/utils/dist/client-helpers.d.ts.map +1 -0
  745. package/packages/utils/dist/client-helpers.js +130 -0
  746. package/packages/utils/dist/client-helpers.js.map +1 -0
  747. package/packages/utils/dist/command-resolver.d.ts.map +1 -0
  748. package/packages/utils/dist/command-resolver.js.map +1 -0
  749. package/packages/utils/dist/error-tracking.d.ts.map +1 -0
  750. package/packages/utils/dist/error-tracking.js.map +1 -0
  751. package/packages/utils/dist/git-remote.d.ts.map +1 -0
  752. package/packages/utils/dist/git-remote.js.map +1 -0
  753. package/packages/utils/dist/index.d.ts +1 -0
  754. package/packages/utils/dist/index.d.ts.map +1 -0
  755. package/packages/utils/dist/index.js +1 -0
  756. package/packages/utils/dist/index.js.map +1 -0
  757. package/packages/utils/dist/logger.d.ts.map +1 -0
  758. package/packages/utils/dist/logger.js.map +1 -0
  759. package/packages/utils/dist/model-mapping.d.ts.map +1 -0
  760. package/packages/utils/dist/model-mapping.js.map +1 -0
  761. package/packages/utils/dist/name-generator.d.ts.map +1 -0
  762. package/packages/utils/dist/name-generator.js.map +1 -0
  763. package/packages/utils/dist/precompiled-patterns.d.ts.map +1 -0
  764. package/packages/utils/dist/precompiled-patterns.js.map +1 -0
  765. package/packages/utils/dist/relay-pty-path.d.ts +11 -5
  766. package/packages/utils/dist/relay-pty-path.d.ts.map +1 -0
  767. package/packages/utils/dist/relay-pty-path.js +60 -5
  768. package/packages/utils/dist/relay-pty-path.js.map +1 -0
  769. package/packages/utils/dist/update-checker.d.ts.map +1 -0
  770. package/packages/utils/dist/update-checker.js.map +1 -0
  771. package/packages/utils/package.json +37 -14
  772. package/packages/utils/scripts/build-cjs.mjs +24 -0
  773. package/packages/utils/src/client-helpers.ts +221 -0
  774. package/packages/utils/src/command-resolver.ts +82 -0
  775. package/packages/utils/src/error-tracking.ts +189 -0
  776. package/packages/utils/src/git-remote.ts +143 -0
  777. package/packages/utils/src/index.ts +10 -0
  778. package/packages/utils/src/logger.ts +107 -0
  779. package/packages/utils/src/model-mapping.test.ts +122 -0
  780. package/packages/utils/src/model-mapping.ts +58 -0
  781. package/packages/utils/src/name-generator.test.ts +259 -0
  782. package/packages/utils/src/name-generator.ts +56 -0
  783. package/packages/utils/src/precompiled-patterns.test.ts +452 -0
  784. package/packages/utils/src/precompiled-patterns.ts +395 -0
  785. package/packages/utils/src/relay-pty-path.ts +196 -0
  786. package/packages/utils/src/update-checker.test.ts +260 -0
  787. package/packages/utils/src/update-checker.ts +211 -0
  788. package/packages/utils/tsconfig.json +21 -0
  789. package/packages/utils/vitest.config.ts +9 -0
  790. package/packages/wrapper/dist/__fixtures__/claude-outputs.d.ts.map +1 -0
  791. package/packages/wrapper/dist/__fixtures__/claude-outputs.js.map +1 -0
  792. package/packages/wrapper/dist/__fixtures__/codex-outputs.d.ts.map +1 -0
  793. package/packages/wrapper/dist/__fixtures__/codex-outputs.js.map +1 -0
  794. package/packages/wrapper/dist/__fixtures__/gemini-outputs.d.ts.map +1 -0
  795. package/packages/wrapper/dist/__fixtures__/gemini-outputs.js.map +1 -0
  796. package/packages/wrapper/dist/__fixtures__/index.d.ts.map +1 -0
  797. package/packages/wrapper/dist/__fixtures__/index.js.map +1 -0
  798. package/packages/wrapper/dist/auth-detection.d.ts.map +1 -0
  799. package/packages/wrapper/dist/auth-detection.js.map +1 -0
  800. package/packages/wrapper/dist/base-wrapper.d.ts.map +1 -0
  801. package/packages/wrapper/dist/base-wrapper.js.map +1 -0
  802. package/packages/wrapper/dist/client.d.ts.map +1 -0
  803. package/packages/wrapper/dist/client.js.map +1 -0
  804. package/packages/wrapper/dist/id-generator.d.ts.map +1 -0
  805. package/packages/wrapper/dist/id-generator.js.map +1 -0
  806. package/packages/wrapper/dist/idle-detector.d.ts.map +1 -0
  807. package/packages/wrapper/dist/idle-detector.js.map +1 -0
  808. package/packages/wrapper/dist/inbox.d.ts.map +1 -0
  809. package/packages/wrapper/dist/inbox.js.map +1 -0
  810. package/packages/wrapper/dist/index.d.ts.map +1 -0
  811. package/packages/wrapper/dist/index.js.map +1 -0
  812. package/packages/wrapper/dist/parser.d.ts.map +1 -0
  813. package/packages/wrapper/dist/parser.js.map +1 -0
  814. package/packages/wrapper/dist/prompt-composer.d.ts.map +1 -0
  815. package/packages/wrapper/dist/prompt-composer.js.map +1 -0
  816. package/packages/wrapper/dist/relay-pty-orchestrator.d.ts +10 -0
  817. package/packages/wrapper/dist/relay-pty-orchestrator.d.ts.map +1 -0
  818. package/packages/wrapper/dist/relay-pty-orchestrator.js +69 -0
  819. package/packages/wrapper/dist/relay-pty-orchestrator.js.map +1 -0
  820. package/packages/wrapper/dist/shared.d.ts.map +1 -0
  821. package/packages/wrapper/dist/shared.js.map +1 -0
  822. package/packages/wrapper/dist/stuck-detector.d.ts.map +1 -0
  823. package/packages/wrapper/dist/stuck-detector.js.map +1 -0
  824. package/packages/wrapper/dist/tmux-resolver.d.ts.map +1 -0
  825. package/packages/wrapper/dist/tmux-resolver.js.map +1 -0
  826. package/packages/wrapper/dist/tmux-wrapper.d.ts.map +1 -0
  827. package/packages/wrapper/dist/tmux-wrapper.js.map +1 -0
  828. package/packages/wrapper/dist/trajectory-integration.d.ts.map +1 -0
  829. package/packages/wrapper/dist/trajectory-integration.js.map +1 -0
  830. package/packages/wrapper/dist/wrapper-types.d.ts.map +1 -0
  831. package/packages/wrapper/dist/wrapper-types.js.map +1 -0
  832. package/packages/wrapper/package.json +6 -9
  833. package/packages/wrapper/src/__fixtures__/claude-outputs.ts +471 -0
  834. package/packages/wrapper/src/__fixtures__/codex-outputs.ts +99 -0
  835. package/packages/wrapper/src/__fixtures__/gemini-outputs.ts +151 -0
  836. package/packages/wrapper/src/__fixtures__/index.ts +47 -0
  837. package/packages/wrapper/src/auth-detection.ts +244 -0
  838. package/packages/wrapper/src/base-wrapper.test.ts +589 -0
  839. package/packages/wrapper/src/base-wrapper.ts +810 -0
  840. package/packages/wrapper/src/client.test.ts +262 -0
  841. package/packages/wrapper/src/client.ts +984 -0
  842. package/packages/wrapper/src/id-generator.test.ts +71 -0
  843. package/packages/wrapper/src/id-generator.ts +69 -0
  844. package/packages/wrapper/src/idle-detector.test.ts +418 -0
  845. package/packages/wrapper/src/idle-detector.ts +384 -0
  846. package/packages/wrapper/src/inbox.test.ts +233 -0
  847. package/packages/wrapper/src/inbox.ts +89 -0
  848. package/packages/wrapper/src/index.ts +170 -0
  849. package/packages/wrapper/src/parser.regression.test.ts +251 -0
  850. package/packages/wrapper/src/parser.test.ts +1359 -0
  851. package/packages/wrapper/src/parser.ts +1477 -0
  852. package/packages/wrapper/src/prompt-composer.test.ts +219 -0
  853. package/packages/wrapper/src/prompt-composer.ts +231 -0
  854. package/packages/wrapper/src/relay-pty-orchestrator.test.ts +1204 -0
  855. package/packages/wrapper/src/relay-pty-orchestrator.ts +2626 -0
  856. package/packages/wrapper/src/shared.test.ts +322 -0
  857. package/packages/wrapper/src/shared.ts +495 -0
  858. package/packages/wrapper/src/stuck-detector.test.ts +303 -0
  859. package/packages/wrapper/src/stuck-detector.ts +511 -0
  860. package/packages/wrapper/src/tmux-resolver.test.ts +104 -0
  861. package/packages/wrapper/src/tmux-resolver.ts +207 -0
  862. package/packages/wrapper/src/tmux-wrapper.test.ts +316 -0
  863. package/packages/wrapper/src/tmux-wrapper.ts +2095 -0
  864. package/packages/wrapper/src/trajectory-detection.test.ts +151 -0
  865. package/packages/wrapper/src/trajectory-integration.ts +1261 -0
  866. package/packages/wrapper/src/wrapper-types.ts +45 -0
  867. package/packages/wrapper/tsconfig.json +19 -0
  868. package/packages/wrapper/vitest.config.ts +9 -0
  869. package/scripts/build-cjs.mjs +23 -0
  870. package/scripts/postinstall.js +132 -0
  871. package/.cursor/mcp.json +0 -11
  872. package/.gitattributes +0 -3
  873. package/.gitleaks.toml +0 -26
  874. package/.mcp.json +0 -11
  875. package/.nvmrc +0 -1
  876. package/ARCHITECTURE.md +0 -1245
  877. package/CHANGELOG.md +0 -231
  878. package/TESTING.md +0 -278
  879. package/TRAIL_GIT_AUTH_FIX.md +0 -113
  880. package/scripts/demos/README.md +0 -79
  881. package/scripts/demos/server-capacity.sh +0 -69
  882. package/scripts/demos/sprint-planning.sh +0 -73
  883. package/scripts/hooks/install.sh +0 -16
  884. package/scripts/hooks/pre-commit +0 -60
  885. package/scripts/post-publish-verify/README.md +0 -80
  886. package/scripts/post-publish-verify/run-verify.sh +0 -127
  887. package/scripts/post-publish-verify/verify-install.sh +0 -249
  888. package/scripts/stress-test-orchestrator-integration.mts +0 -1366
  889. package/scripts/stress-test-orchestrator.mjs +0 -584
  890. package/scripts/stress-test-relay-pty.sh +0 -452
  891. package/scripts/test-interactive-terminal.sh +0 -248
  892. package/specs/PRIMITIVES_ROADMAP.md +0 -2154
  893. package/tests/benchmarks/protocol.bench.ts +0 -310
  894. package/turbo.json +0 -37
@@ -1,2154 +0,0 @@
1
- # Agent Relay: New Primitives Specification
2
-
3
- This document specifies new primitives to enhance Agent Relay's competitive position against frameworks like OpenAI Agents SDK, LangGraph, CrewAI, and others.
4
-
5
- ## Table of Contents
6
-
7
- 1. [Memory System](#1-memory-system)
8
- 2. [Guardrails](#2-guardrails)
9
- 3. [Tracing & Observability](#3-tracing--observability)
10
- 4. [Human-in-the-Loop](#4-human-in-the-loop)
11
- 5. [Backpressure & Flow Control](#5-backpressure--flow-control)
12
- 6. [Attachments](#6-attachments)
13
- 7. [Roles & Permissions](#7-roles--permissions)
14
- 8. [Task Queues](#8-task-queues)
15
-
16
- ---
17
-
18
- ## 1. Memory System
19
-
20
- ### Overview
21
-
22
- A structured memory system enabling agents to store, retrieve, and share knowledge across sessions and between agents. Competitors (LangGraph, CrewAI) offer sophisticated memory; we currently only have inbox + state payloads.
23
-
24
- ### Memory Types
25
-
26
- | Type | Scope | Persistence | Use Case |
27
- |------|-------|-------------|----------|
28
- | **Short-term** | Thread/session | In-memory | Current conversation context |
29
- | **Long-term** | Cross-session | SQLite/Postgres | User preferences, learned facts |
30
- | **Entity** | Global | Database | People, concepts, relationships |
31
- | **Shared** | Multi-agent | Daemon-managed | Coordination state |
32
-
33
- ### Protocol Messages
34
-
35
- #### MEMORY_SET
36
-
37
- Store a value in memory.
38
-
39
- ```typescript
40
- interface MemorySetPayload {
41
- key: string; // Namespaced key: "user:preferences", "entity:alice"
42
- value: unknown; // JSON-serializable value
43
- scope: MemoryScope; // 'short-term' | 'long-term' | 'entity' | 'shared'
44
- ttl?: number; // Time-to-live in ms (optional)
45
- tags?: string[]; // Tags for filtering/search
46
- embedding?: boolean; // Generate vector embedding for semantic search
47
- }
48
-
49
- type MemoryScope = 'short-term' | 'long-term' | 'entity' | 'shared';
50
- ```
51
-
52
- **Envelope:**
53
- ```json
54
- {
55
- "v": 1,
56
- "type": "MEMORY_SET",
57
- "id": "uuid",
58
- "ts": 1737900000000,
59
- "from": "WorkerAgent",
60
- "payload": {
61
- "key": "user:preferences",
62
- "value": { "theme": "dark", "language": "en" },
63
- "scope": "long-term",
64
- "ttl": 86400000,
65
- "tags": ["user", "settings"]
66
- }
67
- }
68
- ```
69
-
70
- #### MEMORY_GET
71
-
72
- Retrieve a value from memory.
73
-
74
- ```typescript
75
- interface MemoryGetPayload {
76
- key: string;
77
- scope?: MemoryScope; // If omitted, search all scopes
78
- }
79
-
80
- interface MemoryGetResponsePayload {
81
- key: string;
82
- value: unknown | null;
83
- scope: MemoryScope;
84
- createdAt: number;
85
- updatedAt: number;
86
- expiresAt?: number;
87
- createdBy: string; // Agent that created this memory
88
- }
89
- ```
90
-
91
- #### MEMORY_SEARCH
92
-
93
- Semantic search across memories (requires embeddings).
94
-
95
- ```typescript
96
- interface MemorySearchPayload {
97
- query: string; // Natural language query
98
- scope?: MemoryScope;
99
- tags?: string[]; // Filter by tags
100
- limit?: number; // Max results (default: 10)
101
- threshold?: number; // Similarity threshold (0-1)
102
- }
103
-
104
- interface MemorySearchResponsePayload {
105
- results: Array<{
106
- key: string;
107
- value: unknown;
108
- score: number; // Similarity score
109
- scope: MemoryScope;
110
- }>;
111
- }
112
- ```
113
-
114
- #### MEMORY_DELETE
115
-
116
- Remove a memory entry.
117
-
118
- ```typescript
119
- interface MemoryDeletePayload {
120
- key: string;
121
- scope?: MemoryScope;
122
- }
123
- ```
124
-
125
- #### MEMORY_LIST
126
-
127
- List memory keys matching a pattern.
128
-
129
- ```typescript
130
- interface MemoryListPayload {
131
- pattern?: string; // Glob pattern: "user:*", "entity:person:*"
132
- scope?: MemoryScope;
133
- tags?: string[];
134
- limit?: number;
135
- offset?: number;
136
- }
137
-
138
- interface MemoryListResponsePayload {
139
- keys: Array<{
140
- key: string;
141
- scope: MemoryScope;
142
- updatedAt: number;
143
- size: number; // Approximate size in bytes
144
- }>;
145
- total: number;
146
- }
147
- ```
148
-
149
- ### SDK API
150
-
151
- ```typescript
152
- class RelayClient {
153
- // Memory namespace
154
- memory: {
155
- // Basic operations
156
- set(key: string, value: unknown, options?: MemorySetOptions): Promise<void>;
157
- get<T = unknown>(key: string, scope?: MemoryScope): Promise<T | null>;
158
- delete(key: string, scope?: MemoryScope): Promise<boolean>;
159
- list(options?: MemoryListOptions): Promise<MemoryKey[]>;
160
-
161
- // Semantic search (requires embedding support)
162
- search(query: string, options?: MemorySearchOptions): Promise<MemorySearchResult[]>;
163
-
164
- // Convenience methods
165
- getOrSet<T>(key: string, factory: () => T | Promise<T>, options?: MemorySetOptions): Promise<T>;
166
- increment(key: string, delta?: number): Promise<number>;
167
- append(key: string, value: unknown): Promise<void>;
168
-
169
- // Namespaced helpers
170
- user: MemoryNamespace; // Scoped to current user/agent
171
- shared: MemoryNamespace; // Shared across all agents
172
- entities: EntityMemory; // Entity-specific operations
173
- };
174
- }
175
-
176
- interface MemorySetOptions {
177
- scope?: MemoryScope;
178
- ttl?: number;
179
- tags?: string[];
180
- embedding?: boolean;
181
- }
182
-
183
- interface EntityMemory {
184
- // Entity-specific operations
185
- track(type: string, id: string, attributes: Record<string, unknown>): Promise<void>;
186
- get(type: string, id: string): Promise<Entity | null>;
187
- find(type: string, query: Record<string, unknown>): Promise<Entity[]>;
188
- relate(entity1: EntityRef, relation: string, entity2: EntityRef): Promise<void>;
189
- getRelated(entity: EntityRef, relation: string): Promise<Entity[]>;
190
- }
191
- ```
192
-
193
- ### Storage Architecture
194
-
195
- ```
196
- ┌─────────────────────────────────────────────────────────────┐
197
- │ Memory Manager │
198
- ├─────────────────────────────────────────────────────────────┤
199
- │ │
200
- │ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────┐ │
201
- │ │ Short-term │ │ Long-term │ │ Entities │ │
202
- │ │ Cache │ │ Store │ │ Store │ │
203
- │ │ (In-mem) │ │ (SQLite) │ │ (SQLite + Vector) │ │
204
- │ └─────────────┘ └─────────────┘ └─────────────────────┘ │
205
- │ │ │ │ │
206
- │ └────────────────┴────────────────────┘ │
207
- │ │ │
208
- │ ┌──────▼──────┐ │
209
- │ │ Vector │ (Optional: for search) │
210
- │ │ Index │ │
211
- │ └─────────────┘ │
212
- └─────────────────────────────────────────────────────────────┘
213
- ```
214
-
215
- ### Database Schema
216
-
217
- ```sql
218
- -- Long-term and entity memory
219
- CREATE TABLE memory (
220
- id TEXT PRIMARY KEY,
221
- key TEXT NOT NULL,
222
- scope TEXT NOT NULL, -- 'short-term', 'long-term', 'entity', 'shared'
223
- value TEXT NOT NULL, -- JSON
224
- created_by TEXT NOT NULL,
225
- created_at INTEGER NOT NULL,
226
- updated_at INTEGER NOT NULL,
227
- expires_at INTEGER,
228
- tags TEXT, -- JSON array
229
- embedding BLOB, -- Vector embedding for semantic search
230
- UNIQUE(key, scope)
231
- );
232
-
233
- CREATE INDEX idx_memory_scope ON memory(scope);
234
- CREATE INDEX idx_memory_key_prefix ON memory(key);
235
- CREATE INDEX idx_memory_expires ON memory(expires_at) WHERE expires_at IS NOT NULL;
236
- CREATE INDEX idx_memory_tags ON memory(tags);
237
-
238
- -- Entity relationships
239
- CREATE TABLE entity_relations (
240
- id TEXT PRIMARY KEY,
241
- entity1_type TEXT NOT NULL,
242
- entity1_id TEXT NOT NULL,
243
- relation TEXT NOT NULL,
244
- entity2_type TEXT NOT NULL,
245
- entity2_id TEXT NOT NULL,
246
- created_at INTEGER NOT NULL,
247
- metadata TEXT, -- JSON
248
- UNIQUE(entity1_type, entity1_id, relation, entity2_type, entity2_id)
249
- );
250
- ```
251
-
252
- ### Configuration
253
-
254
- ```typescript
255
- interface MemoryConfig {
256
- enabled: boolean;
257
- storage: 'memory' | 'sqlite' | 'postgres';
258
-
259
- shortTerm: {
260
- maxSize: number; // Max entries (default: 1000)
261
- defaultTtl: number; // Default TTL in ms (default: 3600000 = 1hr)
262
- };
263
-
264
- longTerm: {
265
- maxSize: number; // Max entries (default: 100000)
266
- defaultTtl?: number; // Optional default TTL
267
- pruneInterval: number; // Cleanup interval (default: 3600000)
268
- };
269
-
270
- embedding: {
271
- enabled: boolean;
272
- provider: 'openai' | 'local' | 'none';
273
- model?: string; // e.g., 'text-embedding-3-small'
274
- dimensions?: number; // Vector dimensions
275
- };
276
- }
277
- ```
278
-
279
- ### Usage Examples
280
-
281
- ```typescript
282
- // Store user preference
283
- await client.memory.set('user:theme', 'dark', {
284
- scope: 'long-term',
285
- tags: ['preferences']
286
- });
287
-
288
- // Get with fallback
289
- const theme = await client.memory.getOrSet('user:theme', () => 'light');
290
-
291
- // Track an entity
292
- await client.memory.entities.track('person', 'alice', {
293
- name: 'Alice',
294
- role: 'developer',
295
- skills: ['typescript', 'rust']
296
- });
297
-
298
- // Create relationship
299
- await client.memory.entities.relate(
300
- { type: 'person', id: 'alice' },
301
- 'works-with',
302
- { type: 'person', id: 'bob' }
303
- );
304
-
305
- // Semantic search (with embeddings enabled)
306
- const results = await client.memory.search(
307
- 'What are Alice\'s programming skills?',
308
- { scope: 'entity', limit: 5 }
309
- );
310
-
311
- // Shared state across agents
312
- await client.memory.shared.set('project:status', {
313
- phase: 'implementation',
314
- completedTasks: 5,
315
- totalTasks: 12
316
- });
317
- ```
318
-
319
- ---
320
-
321
- ## 2. Guardrails
322
-
323
- ### Overview
324
-
325
- Input/output validation and safety checks that run before processing and before delivery. Essential for production deployments.
326
-
327
- ### Guardrail Types
328
-
329
- | Type | When | Purpose |
330
- |------|------|---------|
331
- | **Input** | Before processing incoming message | Validate/sanitize user input |
332
- | **Output** | Before sending message | Validate/filter agent output |
333
- | **Tool** | Before tool execution | Validate tool parameters |
334
- | **Action** | Before state changes | Validate proposed actions |
335
-
336
- ### Protocol Messages
337
-
338
- #### GUARDRAIL_REGISTER
339
-
340
- Register a guardrail with the daemon.
341
-
342
- ```typescript
343
- interface GuardrailRegisterPayload {
344
- id: string; // Unique guardrail ID
345
- type: GuardrailType; // 'input' | 'output' | 'tool' | 'action'
346
- name: string; // Human-readable name
347
- priority: number; // Execution order (lower = first)
348
- config: GuardrailConfig;
349
- }
350
-
351
- type GuardrailType = 'input' | 'output' | 'tool' | 'action';
352
-
353
- interface GuardrailConfig {
354
- // Rule-based checks (fast, no LLM)
355
- rules?: GuardrailRule[];
356
-
357
- // LLM-based checks (slower, semantic)
358
- llmCheck?: {
359
- enabled: boolean;
360
- prompt: string;
361
- model?: string;
362
- };
363
-
364
- // External webhook
365
- webhook?: {
366
- url: string;
367
- timeout: number;
368
- };
369
-
370
- // Built-in validators
371
- builtIn?: BuiltInGuardrail[];
372
- }
373
-
374
- interface GuardrailRule {
375
- type: 'regex' | 'length' | 'contains' | 'schema' | 'custom';
376
- params: Record<string, unknown>;
377
- action: 'block' | 'warn' | 'sanitize';
378
- message?: string;
379
- }
380
-
381
- type BuiltInGuardrail =
382
- | 'pii-detection'
383
- | 'profanity-filter'
384
- | 'jailbreak-detection'
385
- | 'sql-injection'
386
- | 'prompt-injection'
387
- | 'code-execution'
388
- | 'url-validation'
389
- | 'json-schema';
390
- ```
391
-
392
- #### GUARDRAIL_RESULT
393
-
394
- Result of guardrail check (used internally and for logging).
395
-
396
- ```typescript
397
- interface GuardrailResultPayload {
398
- guardrailId: string;
399
- messageId: string;
400
- passed: boolean;
401
- action: 'allow' | 'block' | 'sanitize' | 'warn';
402
- reason?: string;
403
- sanitizedContent?: string; // If sanitized
404
- duration: number; // Check duration in ms
405
- }
406
- ```
407
-
408
- ### SDK API
409
-
410
- ```typescript
411
- class RelayClient {
412
- guardrails: {
413
- // Register guardrails
414
- register(guardrail: GuardrailDefinition): Promise<void>;
415
- unregister(id: string): Promise<void>;
416
- list(): Promise<GuardrailInfo[]>;
417
-
418
- // Manual validation (for testing)
419
- validate(content: string, type: GuardrailType): Promise<ValidationResult>;
420
-
421
- // Built-in validators (client-side, fast)
422
- validators: {
423
- pii: PIIValidator;
424
- profanity: ProfanityValidator;
425
- schema: SchemaValidator;
426
- length: LengthValidator;
427
- };
428
- };
429
- }
430
-
431
- interface GuardrailDefinition {
432
- id: string;
433
- name: string;
434
- type: GuardrailType;
435
- priority?: number;
436
-
437
- // Sync validator (fast, runs inline)
438
- validate?: (content: string, context: GuardrailContext) => ValidationResult;
439
-
440
- // Async validator (can call external services)
441
- validateAsync?: (content: string, context: GuardrailContext) => Promise<ValidationResult>;
442
-
443
- // Built-in checks
444
- rules?: GuardrailRule[];
445
- builtIn?: BuiltInGuardrail[];
446
- }
447
-
448
- interface ValidationResult {
449
- passed: boolean;
450
- action: 'allow' | 'block' | 'sanitize' | 'warn';
451
- reason?: string;
452
- sanitized?: string;
453
- metadata?: Record<string, unknown>;
454
- }
455
-
456
- interface GuardrailContext {
457
- from: string;
458
- to: string;
459
- type: 'input' | 'output';
460
- messageId: string;
461
- thread?: string;
462
- }
463
- ```
464
-
465
- ### Built-in Guardrails
466
-
467
- ```typescript
468
- // PII Detection
469
- interface PIIDetectorConfig {
470
- types: ('email' | 'phone' | 'ssn' | 'credit_card' | 'ip_address' | 'name')[];
471
- action: 'block' | 'redact' | 'warn';
472
- redactWith?: string; // Default: '[REDACTED]'
473
- }
474
-
475
- // Profanity Filter
476
- interface ProfanityFilterConfig {
477
- level: 'strict' | 'moderate' | 'mild';
478
- customWords?: string[];
479
- action: 'block' | 'censor' | 'warn';
480
- }
481
-
482
- // Schema Validator
483
- interface SchemaValidatorConfig {
484
- schema: JSONSchema;
485
- action: 'block' | 'warn';
486
- }
487
-
488
- // Length Validator
489
- interface LengthValidatorConfig {
490
- minLength?: number;
491
- maxLength?: number;
492
- action: 'block' | 'truncate' | 'warn';
493
- }
494
-
495
- // Jailbreak Detection
496
- interface JailbreakDetectorConfig {
497
- sensitivity: 'high' | 'medium' | 'low';
498
- patterns?: string[]; // Additional regex patterns
499
- action: 'block' | 'warn';
500
- }
501
- ```
502
-
503
- ### Daemon Integration
504
-
505
- Guardrails run in the daemon's message pipeline:
506
-
507
- ```
508
- Message Received
509
-
510
-
511
- ┌──────────────────┐
512
- │ Input Guardrails │ ← Block/sanitize before processing
513
- └────────┬─────────┘
514
-
515
-
516
- ┌──────────────────┐
517
- │ Route Message │
518
- └────────┬─────────┘
519
-
520
-
521
- ┌──────────────────┐
522
- │ Output Guardrails│ ← Block/sanitize before delivery
523
- └────────┬─────────┘
524
-
525
-
526
- Deliver Message
527
- ```
528
-
529
- ### Configuration
530
-
531
- ```typescript
532
- interface GuardrailsConfig {
533
- enabled: boolean;
534
-
535
- // Default guardrails applied to all messages
536
- defaults: {
537
- input: BuiltInGuardrail[];
538
- output: BuiltInGuardrail[];
539
- };
540
-
541
- // Fail-open or fail-closed
542
- onError: 'allow' | 'block';
543
-
544
- // Timeout for async validators
545
- timeout: number; // Default: 5000ms
546
-
547
- // Logging
548
- logBlocked: boolean;
549
- logWarnings: boolean;
550
- }
551
- ```
552
-
553
- ### Usage Examples
554
-
555
- ```typescript
556
- // Register PII detection guardrail
557
- await client.guardrails.register({
558
- id: 'pii-blocker',
559
- name: 'PII Detection',
560
- type: 'output',
561
- priority: 1,
562
- builtIn: ['pii-detection'],
563
- rules: [
564
- {
565
- type: 'regex',
566
- params: { pattern: '\\b\\d{3}-\\d{2}-\\d{4}\\b' }, // SSN
567
- action: 'block',
568
- message: 'Message contains SSN'
569
- }
570
- ]
571
- });
572
-
573
- // Custom validation logic
574
- await client.guardrails.register({
575
- id: 'custom-validator',
576
- name: 'Business Rules',
577
- type: 'output',
578
- validate: (content, context) => {
579
- if (content.includes('password') && context.to !== 'SecurityAgent') {
580
- return {
581
- passed: false,
582
- action: 'block',
583
- reason: 'Cannot share password info with non-security agents'
584
- };
585
- }
586
- return { passed: true, action: 'allow' };
587
- }
588
- });
589
-
590
- // Schema validation for structured messages
591
- await client.guardrails.register({
592
- id: 'task-schema',
593
- name: 'Task Format Validator',
594
- type: 'input',
595
- rules: [{
596
- type: 'schema',
597
- params: {
598
- schema: {
599
- type: 'object',
600
- properties: {
601
- taskId: { type: 'string' },
602
- status: { enum: ['pending', 'complete', 'blocked'] }
603
- },
604
- required: ['taskId', 'status']
605
- }
606
- },
607
- action: 'block'
608
- }]
609
- });
610
- ```
611
-
612
- ---
613
-
614
- ## 3. Tracing & Observability
615
-
616
- ### Overview
617
-
618
- Deep workflow tracing with step-by-step visibility, compatible with OpenTelemetry standards.
619
-
620
- ### Trace Structure
621
-
622
- ```
623
- Trace (root span)
624
- ├── Span: receive-message
625
- │ ├── Span: input-guardrails
626
- │ └── Span: route-to-agent
627
- ├── Span: agent-processing
628
- │ ├── Span: tool-call-1
629
- │ ├── Span: tool-call-2
630
- │ └── Span: generate-response
631
- ├── Span: output-guardrails
632
- └── Span: deliver-message
633
- ```
634
-
635
- ### Protocol Messages
636
-
637
- #### TRACE_START
638
-
639
- Start a new trace or span.
640
-
641
- ```typescript
642
- interface TraceStartPayload {
643
- traceId: string; // Root trace ID
644
- spanId: string; // This span's ID
645
- parentSpanId?: string; // Parent span (if nested)
646
- name: string; // Span name
647
- kind: SpanKind; // 'internal' | 'client' | 'server' | 'producer' | 'consumer'
648
- attributes?: Record<string, SpanAttributeValue>;
649
- }
650
-
651
- type SpanKind = 'internal' | 'client' | 'server' | 'producer' | 'consumer';
652
- type SpanAttributeValue = string | number | boolean | string[] | number[];
653
- ```
654
-
655
- #### TRACE_EVENT
656
-
657
- Add an event to a span.
658
-
659
- ```typescript
660
- interface TraceEventPayload {
661
- traceId: string;
662
- spanId: string;
663
- name: string;
664
- timestamp: number;
665
- attributes?: Record<string, SpanAttributeValue>;
666
- }
667
- ```
668
-
669
- #### TRACE_END
670
-
671
- End a span.
672
-
673
- ```typescript
674
- interface TraceEndPayload {
675
- traceId: string;
676
- spanId: string;
677
- status: SpanStatus;
678
- endTime: number;
679
- attributes?: Record<string, SpanAttributeValue>;
680
- }
681
-
682
- interface SpanStatus {
683
- code: 'ok' | 'error' | 'unset';
684
- message?: string;
685
- }
686
- ```
687
-
688
- #### TRACE_QUERY
689
-
690
- Query traces.
691
-
692
- ```typescript
693
- interface TraceQueryPayload {
694
- traceId?: string; // Get specific trace
695
- agent?: string; // Filter by agent
696
- since?: number; // Start time
697
- until?: number; // End time
698
- status?: 'ok' | 'error'; // Filter by status
699
- minDuration?: number; // Min duration in ms
700
- limit?: number;
701
- }
702
-
703
- interface TraceQueryResponsePayload {
704
- traces: TraceInfo[];
705
- total: number;
706
- }
707
-
708
- interface TraceInfo {
709
- traceId: string;
710
- rootSpan: SpanInfo;
711
- spans: SpanInfo[];
712
- startTime: number;
713
- endTime: number;
714
- duration: number;
715
- status: SpanStatus;
716
- agentCount: number;
717
- }
718
-
719
- interface SpanInfo {
720
- spanId: string;
721
- parentSpanId?: string;
722
- name: string;
723
- kind: SpanKind;
724
- startTime: number;
725
- endTime: number;
726
- duration: number;
727
- status: SpanStatus;
728
- attributes: Record<string, SpanAttributeValue>;
729
- events: SpanEvent[];
730
- }
731
- ```
732
-
733
- ### SDK API
734
-
735
- ```typescript
736
- class RelayClient {
737
- tracing: {
738
- // Start a new trace
739
- startTrace(name: string, attributes?: Record<string, SpanAttributeValue>): Trace;
740
-
741
- // Get current trace context
742
- currentTrace(): Trace | null;
743
-
744
- // Query historical traces
745
- query(options: TraceQueryOptions): Promise<TraceInfo[]>;
746
-
747
- // Export to OpenTelemetry
748
- exportOTLP(endpoint: string): void;
749
- };
750
- }
751
-
752
- interface Trace {
753
- traceId: string;
754
-
755
- // Span management
756
- startSpan(name: string, options?: SpanOptions): Span;
757
- currentSpan(): Span | null;
758
-
759
- // End the trace
760
- end(status?: SpanStatus): void;
761
-
762
- // Context propagation
763
- getContext(): TraceContext;
764
- }
765
-
766
- interface Span {
767
- spanId: string;
768
-
769
- // Add events
770
- addEvent(name: string, attributes?: Record<string, SpanAttributeValue>): void;
771
-
772
- // Set attributes
773
- setAttribute(key: string, value: SpanAttributeValue): void;
774
- setAttributes(attributes: Record<string, SpanAttributeValue>): void;
775
-
776
- // Record exceptions
777
- recordException(error: Error): void;
778
-
779
- // Set status
780
- setStatus(status: SpanStatus): void;
781
-
782
- // End span
783
- end(): void;
784
- }
785
-
786
- interface TraceContext {
787
- traceId: string;
788
- spanId: string;
789
- // W3C Trace Context format
790
- traceparent: string;
791
- tracestate?: string;
792
- }
793
- ```
794
-
795
- ### OpenTelemetry Integration
796
-
797
- ```typescript
798
- // Export traces to OTLP endpoint
799
- client.tracing.exportOTLP('http://jaeger:4318/v1/traces');
800
-
801
- // Or use collector
802
- import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
803
-
804
- const exporter = new OTLPTraceExporter({
805
- url: 'http://collector:4318/v1/traces'
806
- });
807
-
808
- client.tracing.setExporter(exporter);
809
- ```
810
-
811
- ### Auto-Instrumentation
812
-
813
- The daemon automatically traces:
814
-
815
- ```typescript
816
- interface AutoInstrumentationConfig {
817
- enabled: boolean;
818
-
819
- // What to trace automatically
820
- instrument: {
821
- messages: boolean; // All message send/receive
822
- spawning: boolean; // Agent spawn/release
823
- consensus: boolean; // Proposal/vote flows
824
- channels: boolean; // Channel operations
825
- memory: boolean; // Memory operations
826
- guardrails: boolean; // Guardrail checks
827
- };
828
-
829
- // Sampling
830
- sampling: {
831
- rate: number; // 0.0 - 1.0 (default: 1.0)
832
- alwaysSampleErrors: boolean;
833
- };
834
-
835
- // Attributes to include
836
- includePayload: boolean; // Include message body (privacy concern)
837
- maxPayloadSize: number; // Truncate large payloads
838
- }
839
- ```
840
-
841
- ### Database Schema
842
-
843
- ```sql
844
- CREATE TABLE traces (
845
- trace_id TEXT PRIMARY KEY,
846
- root_span_id TEXT NOT NULL,
847
- start_time INTEGER NOT NULL,
848
- end_time INTEGER,
849
- status TEXT,
850
- agent_count INTEGER DEFAULT 1
851
- );
852
-
853
- CREATE TABLE spans (
854
- span_id TEXT PRIMARY KEY,
855
- trace_id TEXT NOT NULL REFERENCES traces(trace_id),
856
- parent_span_id TEXT,
857
- name TEXT NOT NULL,
858
- kind TEXT NOT NULL,
859
- start_time INTEGER NOT NULL,
860
- end_time INTEGER,
861
- duration INTEGER,
862
- status_code TEXT,
863
- status_message TEXT,
864
- attributes TEXT, -- JSON
865
- FOREIGN KEY (parent_span_id) REFERENCES spans(span_id)
866
- );
867
-
868
- CREATE TABLE span_events (
869
- id TEXT PRIMARY KEY,
870
- span_id TEXT NOT NULL REFERENCES spans(span_id),
871
- name TEXT NOT NULL,
872
- timestamp INTEGER NOT NULL,
873
- attributes TEXT -- JSON
874
- );
875
-
876
- CREATE INDEX idx_traces_time ON traces(start_time);
877
- CREATE INDEX idx_spans_trace ON spans(trace_id);
878
- CREATE INDEX idx_spans_parent ON spans(parent_span_id);
879
- ```
880
-
881
- ### Usage Examples
882
-
883
- ```typescript
884
- // Manual tracing
885
- const trace = client.tracing.startTrace('process-user-request', {
886
- 'user.id': 'alice',
887
- 'request.type': 'feature'
888
- });
889
-
890
- const parseSpan = trace.startSpan('parse-intent');
891
- parseSpan.setAttribute('intent', 'add-authentication');
892
- parseSpan.end();
893
-
894
- const delegateSpan = trace.startSpan('delegate-to-workers');
895
- delegateSpan.addEvent('spawning-worker', { name: 'BackendWorker' });
896
-
897
- await client.spawn({ name: 'BackendWorker', cli: 'claude', task: '...' });
898
- delegateSpan.addEvent('worker-spawned');
899
-
900
- // ... worker completes
901
-
902
- delegateSpan.end();
903
- trace.end({ code: 'ok' });
904
-
905
- // Query traces
906
- const traces = await client.tracing.query({
907
- agent: 'Lead',
908
- since: Date.now() - 3600000,
909
- minDuration: 1000 // Only slow operations
910
- });
911
- ```
912
-
913
- ---
914
-
915
- ## 4. Human-in-the-Loop
916
-
917
- ### Overview
918
-
919
- Primitives for involving humans in agent workflows: approvals, escalations, and interventions.
920
-
921
- ### Protocol Messages
922
-
923
- #### APPROVAL_REQUEST
924
-
925
- Request approval from a human or designated agent.
926
-
927
- ```typescript
928
- interface ApprovalRequestPayload {
929
- id: string; // Approval request ID
930
- action: string; // What needs approval
931
- description: string; // Human-readable description
932
- requester: string; // Agent requesting approval
933
- approvers: string[]; // Who can approve
934
- data?: unknown; // Contextual data
935
- timeout?: number; // Auto-reject after ms
936
- minApprovals?: number; // Required approval count (default: 1)
937
- allowDelegation?: boolean; // Can approvers delegate?
938
- }
939
- ```
940
-
941
- #### APPROVAL_RESPONSE
942
-
943
- Respond to an approval request.
944
-
945
- ```typescript
946
- interface ApprovalResponsePayload {
947
- requestId: string;
948
- approved: boolean;
949
- approver: string;
950
- reason?: string;
951
- delegateTo?: string; // If delegating
952
- }
953
- ```
954
-
955
- #### APPROVAL_RESULT
956
-
957
- Final result of approval process.
958
-
959
- ```typescript
960
- interface ApprovalResultPayload {
961
- requestId: string;
962
- status: 'approved' | 'rejected' | 'timeout' | 'delegated';
963
- approvals: Array<{
964
- approver: string;
965
- approved: boolean;
966
- reason?: string;
967
- timestamp: number;
968
- }>;
969
- }
970
- ```
971
-
972
- #### ESCALATION
973
-
974
- Escalate an issue to a human or supervisor.
975
-
976
- ```typescript
977
- interface EscalationPayload {
978
- id: string;
979
- severity: 'low' | 'medium' | 'high' | 'critical';
980
- type: 'error' | 'decision' | 'stuck' | 'safety' | 'custom';
981
- summary: string;
982
- details: string;
983
- context?: unknown;
984
- escalateTo: string[]; // Who to notify
985
- requiresAction: boolean; // Needs response or just FYI
986
- }
987
- ```
988
-
989
- #### INTERVENTION
990
-
991
- Human intervention in an agent's workflow.
992
-
993
- ```typescript
994
- interface InterventionPayload {
995
- targetAgent: string;
996
- type: 'pause' | 'resume' | 'stop' | 'redirect' | 'inject';
997
- reason: string;
998
- data?: unknown; // For 'redirect' or 'inject'
999
- }
1000
- ```
1001
-
1002
- ### SDK API
1003
-
1004
- ```typescript
1005
- class RelayClient {
1006
- hitl: {
1007
- // Request approval (blocks until resolved)
1008
- requestApproval(request: ApprovalRequest): Promise<ApprovalResult>;
1009
-
1010
- // Non-blocking approval request
1011
- submitApprovalRequest(request: ApprovalRequest): string; // Returns request ID
1012
- getApprovalStatus(requestId: string): Promise<ApprovalResult | null>;
1013
-
1014
- // Respond to approval requests
1015
- approve(requestId: string, reason?: string): Promise<void>;
1016
- reject(requestId: string, reason?: string): Promise<void>;
1017
- delegate(requestId: string, to: string): Promise<void>;
1018
-
1019
- // Listen for approval requests (for human agents)
1020
- onApprovalRequest?: (request: ApprovalRequest) => void;
1021
-
1022
- // Escalation
1023
- escalate(escalation: Escalation): Promise<string>;
1024
- onEscalation?: (escalation: Escalation) => void;
1025
-
1026
- // Intervention (for supervisors)
1027
- intervene(intervention: Intervention): Promise<void>;
1028
- onIntervention?: (intervention: Intervention) => void;
1029
- };
1030
- }
1031
-
1032
- interface ApprovalRequest {
1033
- action: string;
1034
- description: string;
1035
- approvers: string[];
1036
- data?: unknown;
1037
- timeout?: number;
1038
- minApprovals?: number;
1039
- }
1040
-
1041
- interface ApprovalResult {
1042
- requestId: string;
1043
- status: 'approved' | 'rejected' | 'timeout';
1044
- approvals: ApprovalRecord[];
1045
- }
1046
- ```
1047
-
1048
- ### Dashboard Integration
1049
-
1050
- The dashboard shows:
1051
-
1052
- 1. **Pending Approvals** - List of approval requests awaiting response
1053
- 2. **Escalation Queue** - Active escalations by severity
1054
- 3. **Intervention Controls** - Pause/stop/redirect buttons for each agent
1055
- 4. **Approval History** - Past approvals with audit trail
1056
-
1057
- ### Usage Examples
1058
-
1059
- ```typescript
1060
- // Request approval before deployment
1061
- const approval = await client.hitl.requestApproval({
1062
- action: 'deploy-to-production',
1063
- description: 'Deploy v1.2.3 to production environment',
1064
- approvers: ['Human', 'Lead'],
1065
- data: {
1066
- version: '1.2.3',
1067
- changes: ['Feature A', 'Bug fix B'],
1068
- testsPassed: true
1069
- },
1070
- timeout: 300000, // 5 minutes
1071
- minApprovals: 2
1072
- });
1073
-
1074
- if (approval.status === 'approved') {
1075
- await deployToProduction();
1076
- } else {
1077
- console.log('Deployment rejected:', approval.approvals);
1078
- }
1079
-
1080
- // Escalate a stuck situation
1081
- await client.hitl.escalate({
1082
- severity: 'medium',
1083
- type: 'stuck',
1084
- summary: 'Cannot resolve merge conflict',
1085
- details: 'File src/auth.ts has conflicts that require human decision',
1086
- escalateTo: ['Human', 'Lead'],
1087
- requiresAction: true
1088
- });
1089
-
1090
- // Human agent listening for approvals
1091
- client.hitl.onApprovalRequest = async (request) => {
1092
- console.log(`Approval needed: ${request.action}`);
1093
- // Show in UI, get human input
1094
- const decision = await promptHuman(request);
1095
-
1096
- if (decision.approved) {
1097
- await client.hitl.approve(request.id, decision.reason);
1098
- } else {
1099
- await client.hitl.reject(request.id, decision.reason);
1100
- }
1101
- };
1102
-
1103
- // Supervisor intervention
1104
- await client.hitl.intervene({
1105
- targetAgent: 'RogueWorker',
1106
- type: 'stop',
1107
- reason: 'Agent is in infinite loop'
1108
- });
1109
- ```
1110
-
1111
- ---
1112
-
1113
- ## 5. Backpressure & Flow Control
1114
-
1115
- ### Overview
1116
-
1117
- Prevent message loss under load with bounded queues, priority lanes, and flow control signals.
1118
-
1119
- ### Protocol Messages
1120
-
1121
- #### BUSY
1122
-
1123
- Signal that an agent cannot accept more messages.
1124
-
1125
- ```typescript
1126
- interface BusyPayload {
1127
- agent: string;
1128
- queueDepth: number;
1129
- estimatedWait: number; // Estimated ms until ready
1130
- acceptPriority?: number; // Only accept messages above this priority
1131
- }
1132
- ```
1133
-
1134
- #### READY
1135
-
1136
- Signal that an agent can accept messages again.
1137
-
1138
- ```typescript
1139
- interface ReadyPayload {
1140
- agent: string;
1141
- queueDepth: number;
1142
- }
1143
- ```
1144
-
1145
- #### NACK (Enhanced)
1146
-
1147
- Negative acknowledgment with reason.
1148
-
1149
- ```typescript
1150
- interface NackPayload {
1151
- messageId: string;
1152
- reason: NackReason;
1153
- retryAfter?: number; // Suggested retry delay in ms
1154
- }
1155
-
1156
- type NackReason =
1157
- | 'queue_full'
1158
- | 'rate_limited'
1159
- | 'agent_busy'
1160
- | 'priority_too_low'
1161
- | 'guardrail_blocked'
1162
- | 'invalid_target';
1163
- ```
1164
-
1165
- ### Configuration
1166
-
1167
- ```typescript
1168
- interface BackpressureConfig {
1169
- enabled: boolean;
1170
-
1171
- // Per-agent queue limits
1172
- maxQueuePerAgent: number; // Default: 1000
1173
-
1174
- // Priority lanes
1175
- priorityLanes: {
1176
- critical: { minPriority: 90, reservedCapacity: 0.2 };
1177
- high: { minPriority: 70, reservedCapacity: 0.3 };
1178
- normal: { minPriority: 0, reservedCapacity: 0.5 };
1179
- };
1180
-
1181
- // Rate limiting
1182
- rateLimit: {
1183
- enabled: boolean;
1184
- messagesPerSecond: number; // Per agent
1185
- burstSize: number; // Token bucket burst
1186
- };
1187
-
1188
- // Dead letter queue
1189
- deadLetter: {
1190
- enabled: boolean;
1191
- maxSize: number;
1192
- ttl: number;
1193
- };
1194
-
1195
- // Retry policy
1196
- retry: {
1197
- maxAttempts: number;
1198
- backoffMs: number;
1199
- maxBackoffMs: number;
1200
- };
1201
- }
1202
- ```
1203
-
1204
- ### SDK API
1205
-
1206
- ```typescript
1207
- class RelayClient {
1208
- // Send with priority
1209
- sendMessage(to: string, body: string, kind?: PayloadKind, data?: unknown, options?: SendOptions): boolean;
1210
-
1211
- // Check if target can receive
1212
- canSend(to: string): Promise<{ ready: boolean; queueDepth?: number; estimatedWait?: number }>;
1213
-
1214
- // Flow control events
1215
- onBusy?: (agent: string, info: BusyInfo) => void;
1216
- onReady?: (agent: string) => void;
1217
- onNack?: (messageId: string, reason: NackReason, retryAfter?: number) => void;
1218
- }
1219
-
1220
- interface SendOptions {
1221
- priority?: number; // 0-100 (higher = more urgent)
1222
- ttl?: number; // Time-to-live in ms
1223
- retryPolicy?: RetryPolicy;
1224
- deadLetterOnFail?: boolean;
1225
- }
1226
-
1227
- interface RetryPolicy {
1228
- maxAttempts: number;
1229
- backoffMs: number;
1230
- maxBackoffMs: number;
1231
- }
1232
- ```
1233
-
1234
- ### Architecture
1235
-
1236
- ```
1237
- Incoming Message
1238
-
1239
-
1240
- ┌─────────────────────┐
1241
- │ Rate Limiter │
1242
- │ (Token Bucket) │
1243
- └──────────┬──────────┘
1244
-
1245
-
1246
- ┌─────────────────────┐
1247
- │ Priority Router │
1248
- │ │
1249
- │ ┌─────────────┐ │
1250
- │ │ Critical │◄──┼── Priority >= 90
1251
- │ │ Queue │ │
1252
- │ └─────────────┘ │
1253
- │ ┌─────────────┐ │
1254
- │ │ High │◄──┼── Priority >= 70
1255
- │ │ Queue │ │
1256
- │ └─────────────┘ │
1257
- │ ┌─────────────┐ │
1258
- │ │ Normal │◄──┼── Priority < 70
1259
- │ │ Queue │ │
1260
- │ └─────────────┘ │
1261
- └──────────┬──────────┘
1262
-
1263
- ▼ (Queue full?)
1264
- ┌─────────────────────┐
1265
- │ Dead Letter │
1266
- │ Queue │
1267
- └─────────────────────┘
1268
- ```
1269
-
1270
- ### Usage Examples
1271
-
1272
- ```typescript
1273
- // Send critical message that bypasses normal queue
1274
- client.sendMessage('Lead', 'CRITICAL: Security breach detected', 'action',
1275
- { alert: true },
1276
- { priority: 100, ttl: 60000 }
1277
- );
1278
-
1279
- // Check before sending large batch
1280
- const status = await client.canSend('Worker');
1281
- if (!status.ready) {
1282
- console.log(`Worker busy, queue depth: ${status.queueDepth}`);
1283
- await sleep(status.estimatedWait);
1284
- }
1285
-
1286
- // Handle backpressure
1287
- client.onNack = (messageId, reason, retryAfter) => {
1288
- if (reason === 'queue_full' && retryAfter) {
1289
- setTimeout(() => retryMessage(messageId), retryAfter);
1290
- } else if (reason === 'rate_limited') {
1291
- slowDownSending();
1292
- }
1293
- };
1294
-
1295
- // Configure priority for all messages from this agent
1296
- client.defaultSendOptions = {
1297
- priority: 50,
1298
- retryPolicy: { maxAttempts: 3, backoffMs: 1000, maxBackoffMs: 10000 }
1299
- };
1300
- ```
1301
-
1302
- ---
1303
-
1304
- ## 6. Attachments
1305
-
1306
- ### Overview
1307
-
1308
- Support for large files beyond the 1MiB frame limit, with chunked upload/download and deduplication.
1309
-
1310
- ### Protocol Messages
1311
-
1312
- #### ATTACHMENT_UPLOAD
1313
-
1314
- Upload an attachment (or chunk).
1315
-
1316
- ```typescript
1317
- interface AttachmentUploadPayload {
1318
- id: string; // Attachment ID
1319
- filename: string;
1320
- mimeType: string;
1321
- size: number; // Total size in bytes
1322
- checksum: string; // SHA-256 of complete file
1323
-
1324
- // Chunking
1325
- chunk?: {
1326
- index: number;
1327
- total: number;
1328
- data: string; // Base64 encoded chunk
1329
- checksum: string; // SHA-256 of this chunk
1330
- };
1331
-
1332
- // For small files (< 1MB), can include inline
1333
- data?: string; // Base64 encoded complete file
1334
- }
1335
- ```
1336
-
1337
- #### ATTACHMENT_UPLOAD_COMPLETE
1338
-
1339
- Confirm all chunks received.
1340
-
1341
- ```typescript
1342
- interface AttachmentUploadCompletePayload {
1343
- id: string;
1344
- success: boolean;
1345
- error?: string;
1346
- url?: string; // URL to access attachment
1347
- }
1348
- ```
1349
-
1350
- #### ATTACHMENT_DOWNLOAD
1351
-
1352
- Request attachment download.
1353
-
1354
- ```typescript
1355
- interface AttachmentDownloadPayload {
1356
- id: string;
1357
- range?: {
1358
- start: number;
1359
- end: number;
1360
- };
1361
- }
1362
- ```
1363
-
1364
- #### ATTACHMENT_DATA
1365
-
1366
- Attachment data (response).
1367
-
1368
- ```typescript
1369
- interface AttachmentDataPayload {
1370
- id: string;
1371
- filename: string;
1372
- mimeType: string;
1373
- size: number;
1374
- data: string; // Base64 encoded
1375
- range?: {
1376
- start: number;
1377
- end: number;
1378
- total: number;
1379
- };
1380
- }
1381
- ```
1382
-
1383
- ### SDK API
1384
-
1385
- ```typescript
1386
- class RelayClient {
1387
- attachments: {
1388
- // Upload
1389
- upload(file: Buffer | Uint8Array | ReadableStream, options: UploadOptions): Promise<AttachmentRef>;
1390
- uploadFile(path: string, options?: UploadOptions): Promise<AttachmentRef>;
1391
-
1392
- // Download
1393
- download(ref: AttachmentRef): Promise<Buffer>;
1394
- downloadToFile(ref: AttachmentRef, path: string): Promise<void>;
1395
- downloadStream(ref: AttachmentRef): ReadableStream;
1396
-
1397
- // Metadata
1398
- getInfo(ref: AttachmentRef): Promise<AttachmentInfo>;
1399
-
1400
- // Cleanup
1401
- delete(ref: AttachmentRef): Promise<void>;
1402
-
1403
- // List attachments
1404
- list(options?: ListOptions): Promise<AttachmentInfo[]>;
1405
- };
1406
- }
1407
-
1408
- interface UploadOptions {
1409
- filename: string;
1410
- mimeType?: string; // Auto-detected if not provided
1411
- ttl?: number; // Time-to-live in ms
1412
- tags?: string[];
1413
- }
1414
-
1415
- interface AttachmentRef {
1416
- id: string;
1417
- checksum: string;
1418
- }
1419
-
1420
- interface AttachmentInfo {
1421
- id: string;
1422
- filename: string;
1423
- mimeType: string;
1424
- size: number;
1425
- checksum: string;
1426
- createdAt: number;
1427
- createdBy: string;
1428
- expiresAt?: number;
1429
- tags?: string[];
1430
- }
1431
- ```
1432
-
1433
- ### Message Integration
1434
-
1435
- ```typescript
1436
- // Send message with attachment
1437
- const attachment = await client.attachments.upload(buffer, {
1438
- filename: 'report.pdf',
1439
- mimeType: 'application/pdf'
1440
- });
1441
-
1442
- client.sendMessage('Analyst', 'Please review the attached report', 'action', {
1443
- attachments: [attachment]
1444
- });
1445
-
1446
- // Receive and download
1447
- client.onMessage = async (from, { body, data }) => {
1448
- if (data?.attachments) {
1449
- for (const ref of data.attachments) {
1450
- const buffer = await client.attachments.download(ref);
1451
- console.log(`Downloaded ${ref.id}: ${buffer.length} bytes`);
1452
- }
1453
- }
1454
- };
1455
- ```
1456
-
1457
- ### Storage Configuration
1458
-
1459
- ```typescript
1460
- interface AttachmentConfig {
1461
- enabled: boolean;
1462
-
1463
- // Storage backend
1464
- storage: 'local' | 's3' | 'gcs';
1465
-
1466
- // Local storage
1467
- local?: {
1468
- path: string; // Storage directory
1469
- maxSize: number; // Max total storage in bytes
1470
- };
1471
-
1472
- // S3 storage
1473
- s3?: {
1474
- bucket: string;
1475
- region: string;
1476
- prefix?: string;
1477
- };
1478
-
1479
- // Limits
1480
- maxFileSize: number; // Max single file size (default: 100MB)
1481
- maxTotalSize: number; // Max total storage per project
1482
- defaultTtl: number; // Default TTL in ms
1483
-
1484
- // Chunking
1485
- chunkSize: number; // Chunk size in bytes (default: 1MB)
1486
-
1487
- // Deduplication
1488
- deduplication: boolean; // Store identical files once
1489
- }
1490
- ```
1491
-
1492
- ### Database Schema
1493
-
1494
- ```sql
1495
- CREATE TABLE attachments (
1496
- id TEXT PRIMARY KEY,
1497
- filename TEXT NOT NULL,
1498
- mime_type TEXT NOT NULL,
1499
- size INTEGER NOT NULL,
1500
- checksum TEXT NOT NULL,
1501
- storage_path TEXT NOT NULL,
1502
- created_by TEXT NOT NULL,
1503
- created_at INTEGER NOT NULL,
1504
- expires_at INTEGER,
1505
- tags TEXT, -- JSON array
1506
- reference_count INTEGER DEFAULT 1 -- For deduplication
1507
- );
1508
-
1509
- CREATE INDEX idx_attachments_checksum ON attachments(checksum);
1510
- CREATE INDEX idx_attachments_expires ON attachments(expires_at);
1511
- ```
1512
-
1513
- ---
1514
-
1515
- ## 7. Roles & Permissions
1516
-
1517
- ### Overview
1518
-
1519
- Role-based access control for agents, defining what actions each agent can perform.
1520
-
1521
- ### Role Definitions
1522
-
1523
- ```typescript
1524
- interface RoleDefinition {
1525
- name: string;
1526
- permissions: Permission[];
1527
- inherits?: string[]; // Inherit from other roles
1528
- }
1529
-
1530
- type Permission =
1531
- // Messaging
1532
- | 'message:send'
1533
- | 'message:broadcast'
1534
- | 'message:send:any' // Can send to any agent
1535
- | 'message:send:team' // Can only send to team members
1536
-
1537
- // Channels
1538
- | 'channel:join'
1539
- | 'channel:create'
1540
- | 'channel:admin'
1541
-
1542
- // Spawning
1543
- | 'spawn:create'
1544
- | 'spawn:release'
1545
- | 'spawn:release:own' // Can only release agents you spawned
1546
-
1547
- // Consensus
1548
- | 'consensus:propose'
1549
- | 'consensus:vote'
1550
-
1551
- // Memory
1552
- | 'memory:read'
1553
- | 'memory:write'
1554
- | 'memory:write:shared'
1555
- | 'memory:delete'
1556
-
1557
- // HITL
1558
- | 'approval:request'
1559
- | 'approval:respond'
1560
- | 'escalation:create'
1561
- | 'intervention:perform'
1562
-
1563
- // Admin
1564
- | 'admin:agents' // View/manage agents
1565
- | 'admin:config' // Modify daemon config
1566
- | 'admin:guardrails' // Manage guardrails
1567
- | '*'; // All permissions
1568
- ```
1569
-
1570
- ### Protocol Messages
1571
-
1572
- #### ROLE_ASSIGN
1573
-
1574
- Assign a role to an agent.
1575
-
1576
- ```typescript
1577
- interface RoleAssignPayload {
1578
- agent: string;
1579
- role: string;
1580
- assignedBy: string;
1581
- expiresAt?: number;
1582
- }
1583
- ```
1584
-
1585
- #### ROLE_REVOKE
1586
-
1587
- Revoke a role from an agent.
1588
-
1589
- ```typescript
1590
- interface RoleRevokePayload {
1591
- agent: string;
1592
- role: string;
1593
- revokedBy: string;
1594
- reason?: string;
1595
- }
1596
- ```
1597
-
1598
- #### PERMISSION_CHECK
1599
-
1600
- Check if an agent has a permission (internal).
1601
-
1602
- ```typescript
1603
- interface PermissionCheckPayload {
1604
- agent: string;
1605
- permission: Permission;
1606
- context?: Record<string, unknown>;
1607
- }
1608
-
1609
- interface PermissionCheckResponsePayload {
1610
- allowed: boolean;
1611
- reason?: string;
1612
- }
1613
- ```
1614
-
1615
- ### SDK API
1616
-
1617
- ```typescript
1618
- class RelayClient {
1619
- roles: {
1620
- // Role management (requires admin:agents)
1621
- assign(agent: string, role: string, options?: AssignOptions): Promise<void>;
1622
- revoke(agent: string, role: string): Promise<void>;
1623
- getRoles(agent: string): Promise<string[]>;
1624
-
1625
- // Permission checking
1626
- can(permission: Permission): boolean;
1627
- canAgent(agent: string, permission: Permission): Promise<boolean>;
1628
-
1629
- // Role definitions (requires admin:config)
1630
- defineRole(definition: RoleDefinition): Promise<void>;
1631
- listRoles(): Promise<RoleDefinition[]>;
1632
- };
1633
- }
1634
-
1635
- interface AssignOptions {
1636
- expiresAt?: number;
1637
- reason?: string;
1638
- }
1639
- ```
1640
-
1641
- ### Built-in Roles
1642
-
1643
- ```typescript
1644
- const BUILT_IN_ROLES: Record<string, RoleDefinition> = {
1645
- // Full access
1646
- admin: {
1647
- name: 'admin',
1648
- permissions: ['*']
1649
- },
1650
-
1651
- // Can coordinate but not admin
1652
- lead: {
1653
- name: 'lead',
1654
- permissions: [
1655
- 'message:send:any',
1656
- 'message:broadcast',
1657
- 'channel:join',
1658
- 'channel:create',
1659
- 'spawn:create',
1660
- 'spawn:release:own',
1661
- 'consensus:propose',
1662
- 'consensus:vote',
1663
- 'memory:read',
1664
- 'memory:write',
1665
- 'approval:request',
1666
- 'approval:respond',
1667
- 'escalation:create'
1668
- ]
1669
- },
1670
-
1671
- // Standard worker
1672
- worker: {
1673
- name: 'worker',
1674
- permissions: [
1675
- 'message:send:team',
1676
- 'channel:join',
1677
- 'consensus:vote',
1678
- 'memory:read',
1679
- 'memory:write',
1680
- 'escalation:create'
1681
- ]
1682
- },
1683
-
1684
- // Read-only observer
1685
- observer: {
1686
- name: 'observer',
1687
- permissions: [
1688
- 'memory:read'
1689
- ]
1690
- },
1691
-
1692
- // Human user
1693
- human: {
1694
- name: 'human',
1695
- permissions: [
1696
- 'message:send:any',
1697
- 'approval:respond',
1698
- 'intervention:perform',
1699
- 'admin:agents'
1700
- ]
1701
- }
1702
- };
1703
- ```
1704
-
1705
- ### Configuration
1706
-
1707
- ```typescript
1708
- interface RolesConfig {
1709
- enabled: boolean;
1710
-
1711
- // Default role for new agents
1712
- defaultRole: string; // Default: 'worker'
1713
-
1714
- // Role definitions
1715
- roles: RoleDefinition[];
1716
-
1717
- // Team definitions (for 'send:team' permission)
1718
- teams: TeamDefinition[];
1719
-
1720
- // Enforcement
1721
- enforcement: 'strict' | 'warn' | 'disabled';
1722
- }
1723
-
1724
- interface TeamDefinition {
1725
- name: string;
1726
- members: string[]; // Agent names or patterns
1727
- lead?: string;
1728
- }
1729
- ```
1730
-
1731
- ### Usage Examples
1732
-
1733
- ```typescript
1734
- // Assign role when spawning
1735
- await client.spawn({
1736
- name: 'Worker1',
1737
- cli: 'claude',
1738
- task: '...',
1739
- role: 'worker'
1740
- });
1741
-
1742
- // Check permission before action
1743
- if (client.roles.can('spawn:create')) {
1744
- await client.spawn({ ... });
1745
- } else {
1746
- await client.hitl.escalate({
1747
- type: 'permission',
1748
- summary: 'Need spawn permission',
1749
- escalateTo: ['Lead']
1750
- });
1751
- }
1752
-
1753
- // Assign elevated role temporarily
1754
- await client.roles.assign('Worker1', 'lead', {
1755
- expiresAt: Date.now() + 3600000, // 1 hour
1756
- reason: 'Temporary lead role while Lead is offline'
1757
- });
1758
-
1759
- // Define custom role
1760
- await client.roles.defineRole({
1761
- name: 'security-reviewer',
1762
- permissions: [
1763
- 'message:send:any',
1764
- 'memory:read',
1765
- 'admin:guardrails'
1766
- ],
1767
- inherits: ['worker']
1768
- });
1769
- ```
1770
-
1771
- ---
1772
-
1773
- ## 8. Task Queues
1774
-
1775
- ### Overview
1776
-
1777
- Persistent task queues with claiming, priorities, and progress tracking. Beyond channels for structured work distribution.
1778
-
1779
- ### Protocol Messages
1780
-
1781
- #### TASK_PUSH
1782
-
1783
- Add a task to a queue.
1784
-
1785
- ```typescript
1786
- interface TaskPushPayload {
1787
- queue: string; // Queue name (e.g., '#frontend-tasks')
1788
- task: TaskDefinition;
1789
- }
1790
-
1791
- interface TaskDefinition {
1792
- id: string;
1793
- title: string;
1794
- description?: string;
1795
- priority: number; // 0-100
1796
- data?: unknown; // Task-specific data
1797
- dependencies?: string[]; // Task IDs that must complete first
1798
- timeout?: number; // Max processing time in ms
1799
- retryPolicy?: RetryPolicy;
1800
- assignTo?: string[]; // Preferred assignees
1801
- tags?: string[];
1802
- }
1803
- ```
1804
-
1805
- #### TASK_CLAIM
1806
-
1807
- Claim a task from a queue.
1808
-
1809
- ```typescript
1810
- interface TaskClaimPayload {
1811
- queue: string;
1812
- taskId?: string; // Specific task or next available
1813
- filter?: {
1814
- tags?: string[];
1815
- maxPriority?: number;
1816
- minPriority?: number;
1817
- };
1818
- }
1819
-
1820
- interface TaskClaimResponsePayload {
1821
- success: boolean;
1822
- task?: TaskInfo;
1823
- reason?: string; // If failed
1824
- }
1825
-
1826
- interface TaskInfo extends TaskDefinition {
1827
- status: TaskStatus;
1828
- claimedBy?: string;
1829
- claimedAt?: number;
1830
- attempts: number;
1831
- progress?: number; // 0-100
1832
- lastUpdate?: number;
1833
- }
1834
-
1835
- type TaskStatus = 'pending' | 'claimed' | 'in_progress' | 'completed' | 'failed' | 'blocked';
1836
- ```
1837
-
1838
- #### TASK_UPDATE
1839
-
1840
- Update task progress.
1841
-
1842
- ```typescript
1843
- interface TaskUpdatePayload {
1844
- queue: string;
1845
- taskId: string;
1846
- progress?: number; // 0-100
1847
- status?: TaskStatus;
1848
- message?: string;
1849
- }
1850
- ```
1851
-
1852
- #### TASK_COMPLETE
1853
-
1854
- Mark task as completed.
1855
-
1856
- ```typescript
1857
- interface TaskCompletePayload {
1858
- queue: string;
1859
- taskId: string;
1860
- result?: unknown;
1861
- metrics?: {
1862
- duration: number;
1863
- tokensUsed?: number;
1864
- };
1865
- }
1866
- ```
1867
-
1868
- #### TASK_FAIL
1869
-
1870
- Mark task as failed.
1871
-
1872
- ```typescript
1873
- interface TaskFailPayload {
1874
- queue: string;
1875
- taskId: string;
1876
- error: string;
1877
- retry?: boolean; // Should daemon retry?
1878
- }
1879
- ```
1880
-
1881
- #### TASK_RELEASE
1882
-
1883
- Release a claimed task back to the queue.
1884
-
1885
- ```typescript
1886
- interface TaskReleasePayload {
1887
- queue: string;
1888
- taskId: string;
1889
- reason?: string;
1890
- }
1891
- ```
1892
-
1893
- ### SDK API
1894
-
1895
- ```typescript
1896
- class RelayClient {
1897
- tasks: {
1898
- // Queue management
1899
- createQueue(name: string, options?: QueueOptions): Promise<void>;
1900
- deleteQueue(name: string): Promise<void>;
1901
- listQueues(): Promise<QueueInfo[]>;
1902
-
1903
- // Task operations
1904
- push(queue: string, task: TaskInput): Promise<string>; // Returns task ID
1905
- pushBatch(queue: string, tasks: TaskInput[]): Promise<string[]>;
1906
-
1907
- claim(queue: string, options?: ClaimOptions): Promise<Task | null>;
1908
- release(queue: string, taskId: string, reason?: string): Promise<void>;
1909
-
1910
- update(queue: string, taskId: string, update: TaskUpdate): Promise<void>;
1911
- complete(queue: string, taskId: string, result?: unknown): Promise<void>;
1912
- fail(queue: string, taskId: string, error: string, retry?: boolean): Promise<void>;
1913
-
1914
- // Query
1915
- get(queue: string, taskId: string): Promise<Task | null>;
1916
- list(queue: string, options?: ListOptions): Promise<Task[]>;
1917
- stats(queue: string): Promise<QueueStats>;
1918
-
1919
- // Watch for tasks (worker pattern)
1920
- watch(queue: string, handler: TaskHandler, options?: WatchOptions): TaskWatcher;
1921
- };
1922
- }
1923
-
1924
- interface QueueOptions {
1925
- maxSize?: number;
1926
- defaultPriority?: number;
1927
- defaultTimeout?: number;
1928
- retryPolicy?: RetryPolicy;
1929
- visibility?: 'public' | 'team' | 'private';
1930
- }
1931
-
1932
- interface QueueInfo {
1933
- name: string;
1934
- pending: number;
1935
- inProgress: number;
1936
- completed: number;
1937
- failed: number;
1938
- createdAt: number;
1939
- }
1940
-
1941
- interface QueueStats {
1942
- pending: number;
1943
- inProgress: number;
1944
- completed24h: number;
1945
- failed24h: number;
1946
- avgProcessingTime: number;
1947
- throughput: number; // Tasks per minute
1948
- }
1949
-
1950
- interface TaskInput {
1951
- title: string;
1952
- description?: string;
1953
- priority?: number;
1954
- data?: unknown;
1955
- dependencies?: string[];
1956
- timeout?: number;
1957
- tags?: string[];
1958
- }
1959
-
1960
- interface ClaimOptions {
1961
- taskId?: string;
1962
- filter?: {
1963
- tags?: string[];
1964
- maxPriority?: number;
1965
- minPriority?: number;
1966
- };
1967
- timeout?: number; // Wait for task if queue empty
1968
- }
1969
-
1970
- type TaskHandler = (task: Task) => Promise<unknown>;
1971
-
1972
- interface TaskWatcher {
1973
- stop(): void;
1974
- pause(): void;
1975
- resume(): void;
1976
- }
1977
-
1978
- interface WatchOptions {
1979
- concurrency?: number; // Max concurrent tasks
1980
- pollInterval?: number; // Polling interval in ms
1981
- filter?: ClaimOptions['filter'];
1982
- }
1983
- ```
1984
-
1985
- ### Database Schema
1986
-
1987
- ```sql
1988
- CREATE TABLE task_queues (
1989
- name TEXT PRIMARY KEY,
1990
- options TEXT, -- JSON
1991
- created_at INTEGER NOT NULL,
1992
- created_by TEXT NOT NULL
1993
- );
1994
-
1995
- CREATE TABLE tasks (
1996
- id TEXT PRIMARY KEY,
1997
- queue TEXT NOT NULL REFERENCES task_queues(name),
1998
- title TEXT NOT NULL,
1999
- description TEXT,
2000
- priority INTEGER NOT NULL DEFAULT 50,
2001
- data TEXT, -- JSON
2002
- dependencies TEXT, -- JSON array of task IDs
2003
- timeout INTEGER,
2004
- tags TEXT, -- JSON array
2005
- status TEXT NOT NULL DEFAULT 'pending',
2006
- claimed_by TEXT,
2007
- claimed_at INTEGER,
2008
- attempts INTEGER DEFAULT 0,
2009
- progress INTEGER DEFAULT 0,
2010
- result TEXT, -- JSON
2011
- error TEXT,
2012
- created_at INTEGER NOT NULL,
2013
- updated_at INTEGER NOT NULL,
2014
- completed_at INTEGER
2015
- );
2016
-
2017
- CREATE INDEX idx_tasks_queue_status ON tasks(queue, status);
2018
- CREATE INDEX idx_tasks_priority ON tasks(priority DESC);
2019
- CREATE INDEX idx_tasks_claimed_by ON tasks(claimed_by);
2020
- CREATE INDEX idx_tasks_dependencies ON tasks(dependencies);
2021
- ```
2022
-
2023
- ### Usage Examples
2024
-
2025
- ```typescript
2026
- // Create a task queue
2027
- await client.tasks.createQueue('#frontend-tasks', {
2028
- defaultPriority: 50,
2029
- defaultTimeout: 3600000, // 1 hour
2030
- retryPolicy: { maxAttempts: 3, backoffMs: 1000, maxBackoffMs: 30000 }
2031
- });
2032
-
2033
- // Push tasks with dependencies
2034
- const task1 = await client.tasks.push('#frontend-tasks', {
2035
- title: 'Design login page',
2036
- priority: 80,
2037
- tags: ['design', 'auth']
2038
- });
2039
-
2040
- const task2 = await client.tasks.push('#frontend-tasks', {
2041
- title: 'Implement login form',
2042
- dependencies: [task1],
2043
- tags: ['implementation', 'auth']
2044
- });
2045
-
2046
- // Worker claiming and processing
2047
- const watcher = client.tasks.watch('#frontend-tasks', async (task) => {
2048
- console.log(`Processing: ${task.title}`);
2049
-
2050
- // Update progress
2051
- await client.tasks.update('#frontend-tasks', task.id, { progress: 50 });
2052
-
2053
- // Do work...
2054
- const result = await processTask(task);
2055
-
2056
- return result; // Auto-completes the task
2057
- }, {
2058
- concurrency: 2,
2059
- filter: { tags: ['implementation'] }
2060
- });
2061
-
2062
- // Manual claim for specific work
2063
- const task = await client.tasks.claim('#frontend-tasks', {
2064
- filter: { tags: ['urgent'] },
2065
- timeout: 5000 // Wait up to 5s for a task
2066
- });
2067
-
2068
- if (task) {
2069
- try {
2070
- await processTask(task);
2071
- await client.tasks.complete('#frontend-tasks', task.id, { success: true });
2072
- } catch (error) {
2073
- await client.tasks.fail('#frontend-tasks', task.id, error.message, true);
2074
- }
2075
- }
2076
-
2077
- // Check queue stats
2078
- const stats = await client.tasks.stats('#frontend-tasks');
2079
- console.log(`Pending: ${stats.pending}, Throughput: ${stats.throughput}/min`);
2080
- ```
2081
-
2082
- ---
2083
-
2084
- ## Implementation Roadmap
2085
-
2086
- ### Phase 1: Foundation (P0)
2087
-
2088
- 1. **Memory System** - Core primitive that everything else needs
2089
- 2. **Guardrails** - Essential for production safety
2090
-
2091
- ### Phase 2: Visibility (P1)
2092
-
2093
- 3. **Tracing & Observability** - Debug and monitor
2094
- 4. **Human-in-the-Loop** - Enterprise requirement
2095
-
2096
- ### Phase 3: Scale (P2)
2097
-
2098
- 5. **Backpressure & Flow Control** - Handle load
2099
- 6. **Attachments** - Large file support
2100
-
2101
- ### Phase 4: Structure (P3)
2102
-
2103
- 7. **Roles & Permissions** - Security and governance
2104
- 8. **Task Queues** - Structured work distribution
2105
-
2106
- ### Migration Notes
2107
-
2108
- All new primitives should:
2109
-
2110
- 1. Be **opt-in** via configuration
2111
- 2. Have **feature flags** for gradual rollout
2112
- 3. Include **migration paths** from current patterns
2113
- 4. Maintain **backward compatibility** with existing SDK
2114
-
2115
- ### Protocol Versioning
2116
-
2117
- New message types will be added under protocol version 2:
2118
-
2119
- ```typescript
2120
- const PROTOCOL_VERSION = 2;
2121
-
2122
- // New message types
2123
- type MessageType =
2124
- // ... existing types
2125
- | 'MEMORY_SET' | 'MEMORY_GET' | 'MEMORY_SEARCH' | 'MEMORY_DELETE' | 'MEMORY_LIST'
2126
- | 'GUARDRAIL_REGISTER' | 'GUARDRAIL_RESULT'
2127
- | 'TRACE_START' | 'TRACE_EVENT' | 'TRACE_END' | 'TRACE_QUERY'
2128
- | 'APPROVAL_REQUEST' | 'APPROVAL_RESPONSE' | 'ESCALATION' | 'INTERVENTION'
2129
- | 'BUSY' | 'READY'
2130
- | 'ATTACHMENT_UPLOAD' | 'ATTACHMENT_DOWNLOAD' | 'ATTACHMENT_DATA'
2131
- | 'ROLE_ASSIGN' | 'ROLE_REVOKE' | 'PERMISSION_CHECK'
2132
- | 'TASK_PUSH' | 'TASK_CLAIM' | 'TASK_UPDATE' | 'TASK_COMPLETE' | 'TASK_FAIL' | 'TASK_RELEASE';
2133
- ```
2134
-
2135
- ---
2136
-
2137
- ## Competitive Differentiation
2138
-
2139
- With these primitives, Agent Relay will uniquely offer:
2140
-
2141
- | Capability | Agent Relay | OpenAI Agents | LangGraph | CrewAI |
2142
- |------------|-------------|---------------|-----------|--------|
2143
- | Sub-5ms latency | **Yes** | No | No | No |
2144
- | Native consensus | **Yes** | No | No | No |
2145
- | Shadow monitoring | **Yes** | No | No | No |
2146
- | Sync messaging | **Yes** | No | No | No |
2147
- | CLI-agnostic | **Yes** | No | No | No |
2148
- | Memory system | **Yes** (new) | Sessions | Yes | Yes |
2149
- | Guardrails | **Yes** (new) | Yes | Via LangChain | No |
2150
- | Tracing/OTEL | **Yes** (new) | Yes | Via LangSmith | No |
2151
- | HITL | **Yes** (new) | Yes | No | No |
2152
- | Task queues | **Yes** (new) | No | No | No |
2153
-
2154
- **Agent Relay: The only framework with all primitives for production multi-agent systems.**