@spinabot/brigade 0.1.2 → 1.0.1

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 (1931) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +748 -88
  3. package/brigade.mjs +150 -73
  4. package/dist/agents/a2a-policy-canonicalize.d.ts +60 -0
  5. package/dist/agents/a2a-policy-canonicalize.d.ts.map +1 -0
  6. package/dist/agents/a2a-policy-canonicalize.js +103 -0
  7. package/dist/agents/a2a-policy-canonicalize.js.map +1 -0
  8. package/dist/agents/agent-event-bus.d.ts +221 -0
  9. package/dist/agents/agent-event-bus.d.ts.map +1 -0
  10. package/dist/agents/agent-event-bus.js +88 -0
  11. package/dist/agents/agent-event-bus.js.map +1 -0
  12. package/dist/agents/agent-events.d.ts +84 -0
  13. package/dist/agents/agent-events.d.ts.map +1 -0
  14. package/dist/agents/agent-events.js +309 -0
  15. package/dist/agents/agent-events.js.map +1 -0
  16. package/dist/agents/agent-events.types.d.ts +139 -0
  17. package/dist/agents/agent-events.types.d.ts.map +1 -0
  18. package/dist/agents/agent-events.types.js +27 -0
  19. package/dist/agents/agent-events.types.js.map +1 -0
  20. package/dist/agents/agent-loop.d.ts +145 -0
  21. package/dist/agents/agent-loop.d.ts.map +1 -0
  22. package/dist/agents/agent-loop.js +1938 -0
  23. package/dist/agents/agent-loop.js.map +1 -0
  24. package/dist/agents/agent-scope.d.ts +28 -0
  25. package/dist/agents/agent-scope.d.ts.map +1 -0
  26. package/dist/agents/agent-scope.js +39 -0
  27. package/dist/agents/agent-scope.js.map +1 -0
  28. package/dist/agents/approval-bridge.d.ts +139 -0
  29. package/dist/agents/approval-bridge.d.ts.map +1 -0
  30. package/dist/agents/approval-bridge.js +178 -0
  31. package/dist/agents/approval-bridge.js.map +1 -0
  32. package/dist/agents/carrow.d.ts +49 -0
  33. package/dist/agents/carrow.d.ts.map +1 -0
  34. package/dist/agents/carrow.js +57 -0
  35. package/dist/agents/carrow.js.map +1 -0
  36. package/dist/agents/channels/abort-triggers.d.ts +17 -0
  37. package/dist/agents/channels/abort-triggers.d.ts.map +1 -0
  38. package/dist/agents/channels/abort-triggers.js +52 -0
  39. package/dist/agents/channels/abort-triggers.js.map +1 -0
  40. package/dist/agents/channels/access-control/index.d.ts +5 -0
  41. package/dist/agents/channels/access-control/index.d.ts.map +1 -0
  42. package/dist/agents/channels/access-control/index.js +4 -0
  43. package/dist/agents/channels/access-control/index.js.map +1 -0
  44. package/dist/agents/channels/access-control/policy.d.ts +69 -0
  45. package/dist/agents/channels/access-control/policy.d.ts.map +1 -0
  46. package/dist/agents/channels/access-control/policy.js +123 -0
  47. package/dist/agents/channels/access-control/policy.js.map +1 -0
  48. package/dist/agents/channels/access-control/store.d.ts +86 -0
  49. package/dist/agents/channels/access-control/store.d.ts.map +1 -0
  50. package/dist/agents/channels/access-control/store.js +482 -0
  51. package/dist/agents/channels/access-control/store.js.map +1 -0
  52. package/dist/agents/channels/access-control/types.d.ts +52 -0
  53. package/dist/agents/channels/access-control/types.d.ts.map +1 -0
  54. package/dist/agents/channels/access-control/types.js +20 -0
  55. package/dist/agents/channels/access-control/types.js.map +1 -0
  56. package/dist/agents/channels/active-manager.d.ts +31 -0
  57. package/dist/agents/channels/active-manager.d.ts.map +1 -0
  58. package/dist/agents/channels/active-manager.js +41 -0
  59. package/dist/agents/channels/active-manager.js.map +1 -0
  60. package/dist/agents/channels/agent-switch-command.d.ts +53 -0
  61. package/dist/agents/channels/agent-switch-command.d.ts.map +1 -0
  62. package/dist/agents/channels/agent-switch-command.js +349 -0
  63. package/dist/agents/channels/agent-switch-command.js.map +1 -0
  64. package/dist/agents/channels/approval-router.d.ts +158 -0
  65. package/dist/agents/channels/approval-router.d.ts.map +1 -0
  66. package/dist/agents/channels/approval-router.js +446 -0
  67. package/dist/agents/channels/approval-router.js.map +1 -0
  68. package/dist/agents/channels/channel-entry-contract.d.ts +70 -0
  69. package/dist/agents/channels/channel-entry-contract.d.ts.map +1 -0
  70. package/dist/agents/channels/channel-entry-contract.js +48 -0
  71. package/dist/agents/channels/channel-entry-contract.js.map +1 -0
  72. package/dist/agents/channels/channel-plugin-manager.d.ts +86 -0
  73. package/dist/agents/channels/channel-plugin-manager.d.ts.map +1 -0
  74. package/dist/agents/channels/channel-plugin-manager.js +345 -0
  75. package/dist/agents/channels/channel-plugin-manager.js.map +1 -0
  76. package/dist/agents/channels/chat-type.d.ts +27 -0
  77. package/dist/agents/channels/chat-type.d.ts.map +1 -0
  78. package/dist/agents/channels/chat-type.js +33 -0
  79. package/dist/agents/channels/chat-type.js.map +1 -0
  80. package/dist/agents/channels/dedupe.d.ts +44 -0
  81. package/dist/agents/channels/dedupe.d.ts.map +1 -0
  82. package/dist/agents/channels/dedupe.js +80 -0
  83. package/dist/agents/channels/dedupe.js.map +1 -0
  84. package/dist/agents/channels/inbound-pipeline.d.ts +90 -0
  85. package/dist/agents/channels/inbound-pipeline.d.ts.map +1 -0
  86. package/dist/agents/channels/inbound-pipeline.js +721 -0
  87. package/dist/agents/channels/inbound-pipeline.js.map +1 -0
  88. package/dist/agents/channels/last-channel.d.ts +56 -0
  89. package/dist/agents/channels/last-channel.d.ts.map +1 -0
  90. package/dist/agents/channels/last-channel.js +65 -0
  91. package/dist/agents/channels/last-channel.js.map +1 -0
  92. package/dist/agents/channels/manager.d.ts +76 -0
  93. package/dist/agents/channels/manager.d.ts.map +1 -0
  94. package/dist/agents/channels/manager.js +132 -0
  95. package/dist/agents/channels/manager.js.map +1 -0
  96. package/dist/agents/channels/media-capture.d.ts +23 -0
  97. package/dist/agents/channels/media-capture.d.ts.map +1 -0
  98. package/dist/agents/channels/media-capture.js +40 -0
  99. package/dist/agents/channels/media-capture.js.map +1 -0
  100. package/dist/agents/channels/plugin-channel-manager-facade.d.ts +18 -0
  101. package/dist/agents/channels/plugin-channel-manager-facade.d.ts.map +1 -0
  102. package/dist/agents/channels/plugin-channel-manager-facade.js +52 -0
  103. package/dist/agents/channels/plugin-channel-manager-facade.js.map +1 -0
  104. package/dist/agents/channels/reply-sanitizer.d.ts +38 -0
  105. package/dist/agents/channels/reply-sanitizer.d.ts.map +1 -0
  106. package/dist/agents/channels/reply-sanitizer.js +94 -0
  107. package/dist/agents/channels/reply-sanitizer.js.map +1 -0
  108. package/dist/agents/channels/retryable-inbound.d.ts +31 -0
  109. package/dist/agents/channels/retryable-inbound.d.ts.map +1 -0
  110. package/dist/agents/channels/retryable-inbound.js +37 -0
  111. package/dist/agents/channels/retryable-inbound.js.map +1 -0
  112. package/dist/agents/channels/types.adapters.d.ts +399 -0
  113. package/dist/agents/channels/types.adapters.d.ts.map +1 -0
  114. package/dist/agents/channels/types.adapters.js +33 -0
  115. package/dist/agents/channels/types.adapters.js.map +1 -0
  116. package/dist/agents/channels/types.core.d.ts +134 -0
  117. package/dist/agents/channels/types.core.d.ts.map +1 -0
  118. package/dist/agents/channels/types.core.js +32 -0
  119. package/dist/agents/channels/types.core.js.map +1 -0
  120. package/dist/agents/channels/types.plugin.d.ts +78 -0
  121. package/dist/agents/channels/types.plugin.d.ts.map +1 -0
  122. package/dist/agents/channels/types.plugin.js +30 -0
  123. package/dist/agents/channels/types.plugin.js.map +1 -0
  124. package/dist/agents/channels/whatsapp/account-config.d.ts +50 -0
  125. package/dist/agents/channels/whatsapp/account-config.d.ts.map +1 -0
  126. package/dist/agents/channels/whatsapp/account-config.js +105 -0
  127. package/dist/agents/channels/whatsapp/account-config.js.map +1 -0
  128. package/dist/agents/channels/whatsapp/adapter.d.ts +22 -0
  129. package/dist/agents/channels/whatsapp/adapter.d.ts.map +1 -0
  130. package/dist/agents/channels/whatsapp/adapter.js +270 -0
  131. package/dist/agents/channels/whatsapp/adapter.js.map +1 -0
  132. package/dist/agents/channels/whatsapp/chunk.d.ts +26 -0
  133. package/dist/agents/channels/whatsapp/chunk.d.ts.map +1 -0
  134. package/dist/agents/channels/whatsapp/chunk.js +123 -0
  135. package/dist/agents/channels/whatsapp/chunk.js.map +1 -0
  136. package/dist/agents/channels/whatsapp/connection.d.ts +249 -0
  137. package/dist/agents/channels/whatsapp/connection.d.ts.map +1 -0
  138. package/dist/agents/channels/whatsapp/connection.js +1628 -0
  139. package/dist/agents/channels/whatsapp/connection.js.map +1 -0
  140. package/dist/agents/channels/whatsapp/convex-auth-state.d.ts +34 -0
  141. package/dist/agents/channels/whatsapp/convex-auth-state.d.ts.map +1 -0
  142. package/dist/agents/channels/whatsapp/convex-auth-state.js +168 -0
  143. package/dist/agents/channels/whatsapp/convex-auth-state.js.map +1 -0
  144. package/dist/agents/channels/whatsapp/format.d.ts +15 -0
  145. package/dist/agents/channels/whatsapp/format.d.ts.map +1 -0
  146. package/dist/agents/channels/whatsapp/format.js +66 -0
  147. package/dist/agents/channels/whatsapp/format.js.map +1 -0
  148. package/dist/agents/channels/whatsapp/inbound-extras.d.ts +30 -0
  149. package/dist/agents/channels/whatsapp/inbound-extras.d.ts.map +1 -0
  150. package/dist/agents/channels/whatsapp/inbound-extras.js +146 -0
  151. package/dist/agents/channels/whatsapp/inbound-extras.js.map +1 -0
  152. package/dist/agents/channels/whatsapp/index.d.ts +7 -0
  153. package/dist/agents/channels/whatsapp/index.d.ts.map +1 -0
  154. package/dist/agents/channels/whatsapp/index.js +7 -0
  155. package/dist/agents/channels/whatsapp/index.js.map +1 -0
  156. package/dist/agents/channels/whatsapp/media.d.ts +47 -0
  157. package/dist/agents/channels/whatsapp/media.d.ts.map +1 -0
  158. package/dist/agents/channels/whatsapp/media.js +192 -0
  159. package/dist/agents/channels/whatsapp/media.js.map +1 -0
  160. package/dist/agents/channels/whatsapp/module.d.ts +10 -0
  161. package/dist/agents/channels/whatsapp/module.d.ts.map +1 -0
  162. package/dist/agents/channels/whatsapp/module.js +17 -0
  163. package/dist/agents/channels/whatsapp/module.js.map +1 -0
  164. package/dist/agents/channels/whatsapp/plugin.d.ts +60 -0
  165. package/dist/agents/channels/whatsapp/plugin.d.ts.map +1 -0
  166. package/dist/agents/channels/whatsapp/plugin.js +238 -0
  167. package/dist/agents/channels/whatsapp/plugin.js.map +1 -0
  168. package/dist/agents/cmd-ism-guard.d.ts +47 -0
  169. package/dist/agents/cmd-ism-guard.d.ts.map +1 -0
  170. package/dist/agents/cmd-ism-guard.js +100 -0
  171. package/dist/agents/cmd-ism-guard.js.map +1 -0
  172. package/dist/agents/config-write-guard.d.ts +25 -0
  173. package/dist/agents/config-write-guard.d.ts.map +1 -0
  174. package/dist/agents/config-write-guard.js +95 -0
  175. package/dist/agents/config-write-guard.js.map +1 -0
  176. package/dist/agents/content-quality-retry.d.ts +66 -0
  177. package/dist/agents/content-quality-retry.d.ts.map +1 -0
  178. package/dist/agents/content-quality-retry.js +140 -0
  179. package/dist/agents/content-quality-retry.js.map +1 -0
  180. package/dist/agents/error-classifier.d.ts +89 -0
  181. package/dist/agents/error-classifier.d.ts.map +1 -0
  182. package/dist/agents/error-classifier.js +630 -0
  183. package/dist/agents/error-classifier.js.map +1 -0
  184. package/dist/agents/exec-gate.d.ts +113 -0
  185. package/dist/agents/exec-gate.d.ts.map +1 -0
  186. package/dist/agents/exec-gate.js +335 -0
  187. package/dist/agents/exec-gate.js.map +1 -0
  188. package/dist/agents/exec-session-allow.d.ts +30 -0
  189. package/dist/agents/exec-session-allow.d.ts.map +1 -0
  190. package/dist/agents/exec-session-allow.js +50 -0
  191. package/dist/agents/exec-session-allow.js.map +1 -0
  192. package/dist/agents/extensions/active-registry.d.ts +4 -0
  193. package/dist/agents/extensions/active-registry.d.ts.map +1 -0
  194. package/dist/agents/extensions/active-registry.js +18 -0
  195. package/dist/agents/extensions/active-registry.js.map +1 -0
  196. package/dist/agents/extensions/discovery.d.ts +84 -0
  197. package/dist/agents/extensions/discovery.d.ts.map +1 -0
  198. package/dist/agents/extensions/discovery.js +249 -0
  199. package/dist/agents/extensions/discovery.js.map +1 -0
  200. package/dist/agents/extensions/hook-runner.d.ts +67 -0
  201. package/dist/agents/extensions/hook-runner.d.ts.map +1 -0
  202. package/dist/agents/extensions/hook-runner.js +155 -0
  203. package/dist/agents/extensions/hook-runner.js.map +1 -0
  204. package/dist/agents/extensions/index.d.ts +15 -0
  205. package/dist/agents/extensions/index.d.ts.map +1 -0
  206. package/dist/agents/extensions/index.js +14 -0
  207. package/dist/agents/extensions/index.js.map +1 -0
  208. package/dist/agents/extensions/loader.d.ts +38 -0
  209. package/dist/agents/extensions/loader.d.ts.map +1 -0
  210. package/dist/agents/extensions/loader.js +142 -0
  211. package/dist/agents/extensions/loader.js.map +1 -0
  212. package/dist/agents/extensions/modules/arxiv.d.ts +28 -0
  213. package/dist/agents/extensions/modules/arxiv.d.ts.map +1 -0
  214. package/dist/agents/extensions/modules/arxiv.js +145 -0
  215. package/dist/agents/extensions/modules/arxiv.js.map +1 -0
  216. package/dist/agents/extensions/modules/brave.d.ts +28 -0
  217. package/dist/agents/extensions/modules/brave.d.ts.map +1 -0
  218. package/dist/agents/extensions/modules/brave.js +489 -0
  219. package/dist/agents/extensions/modules/brave.js.map +1 -0
  220. package/dist/agents/extensions/modules/duckduckgo.d.ts +27 -0
  221. package/dist/agents/extensions/modules/duckduckgo.d.ts.map +1 -0
  222. package/dist/agents/extensions/modules/duckduckgo.js +263 -0
  223. package/dist/agents/extensions/modules/duckduckgo.js.map +1 -0
  224. package/dist/agents/extensions/modules/exa.d.ts +19 -0
  225. package/dist/agents/extensions/modules/exa.d.ts.map +1 -0
  226. package/dist/agents/extensions/modules/exa.js +208 -0
  227. package/dist/agents/extensions/modules/exa.js.map +1 -0
  228. package/dist/agents/extensions/modules/firecrawl.d.ts +51 -0
  229. package/dist/agents/extensions/modules/firecrawl.d.ts.map +1 -0
  230. package/dist/agents/extensions/modules/firecrawl.js +280 -0
  231. package/dist/agents/extensions/modules/firecrawl.js.map +1 -0
  232. package/dist/agents/extensions/modules/github-search.d.ts +29 -0
  233. package/dist/agents/extensions/modules/github-search.d.ts.map +1 -0
  234. package/dist/agents/extensions/modules/github-search.js +197 -0
  235. package/dist/agents/extensions/modules/github-search.js.map +1 -0
  236. package/dist/agents/extensions/modules/hackernews.d.ts +17 -0
  237. package/dist/agents/extensions/modules/hackernews.d.ts.map +1 -0
  238. package/dist/agents/extensions/modules/hackernews.js +144 -0
  239. package/dist/agents/extensions/modules/hackernews.js.map +1 -0
  240. package/dist/agents/extensions/modules/index.d.ts +11 -0
  241. package/dist/agents/extensions/modules/index.d.ts.map +1 -0
  242. package/dist/agents/extensions/modules/index.js +64 -0
  243. package/dist/agents/extensions/modules/index.js.map +1 -0
  244. package/dist/agents/extensions/modules/npm-search.d.ts +15 -0
  245. package/dist/agents/extensions/modules/npm-search.d.ts.map +1 -0
  246. package/dist/agents/extensions/modules/npm-search.js +126 -0
  247. package/dist/agents/extensions/modules/npm-search.js.map +1 -0
  248. package/dist/agents/extensions/modules/ollama-search.d.ts +30 -0
  249. package/dist/agents/extensions/modules/ollama-search.d.ts.map +1 -0
  250. package/dist/agents/extensions/modules/ollama-search.js +171 -0
  251. package/dist/agents/extensions/modules/ollama-search.js.map +1 -0
  252. package/dist/agents/extensions/modules/perplexity.d.ts +19 -0
  253. package/dist/agents/extensions/modules/perplexity.d.ts.map +1 -0
  254. package/dist/agents/extensions/modules/perplexity.js +358 -0
  255. package/dist/agents/extensions/modules/perplexity.js.map +1 -0
  256. package/dist/agents/extensions/modules/searxng.d.ts +43 -0
  257. package/dist/agents/extensions/modules/searxng.d.ts.map +1 -0
  258. package/dist/agents/extensions/modules/searxng.js +191 -0
  259. package/dist/agents/extensions/modules/searxng.js.map +1 -0
  260. package/dist/agents/extensions/modules/tavily.d.ts +71 -0
  261. package/dist/agents/extensions/modules/tavily.d.ts.map +1 -0
  262. package/dist/agents/extensions/modules/tavily.js +330 -0
  263. package/dist/agents/extensions/modules/tavily.js.map +1 -0
  264. package/dist/agents/extensions/modules/web-provider-helpers.d.ts +89 -0
  265. package/dist/agents/extensions/modules/web-provider-helpers.d.ts.map +1 -0
  266. package/dist/agents/extensions/modules/web-provider-helpers.js +146 -0
  267. package/dist/agents/extensions/modules/web-provider-helpers.js.map +1 -0
  268. package/dist/agents/extensions/modules/web-search-filters.d.ts +62 -0
  269. package/dist/agents/extensions/modules/web-search-filters.d.ts.map +1 -0
  270. package/dist/agents/extensions/modules/web-search-filters.js +179 -0
  271. package/dist/agents/extensions/modules/web-search-filters.js.map +1 -0
  272. package/dist/agents/extensions/modules/wikipedia.d.ts +16 -0
  273. package/dist/agents/extensions/modules/wikipedia.d.ts.map +1 -0
  274. package/dist/agents/extensions/modules/wikipedia.js +138 -0
  275. package/dist/agents/extensions/modules/wikipedia.js.map +1 -0
  276. package/dist/agents/extensions/registry-cache.d.ts +74 -0
  277. package/dist/agents/extensions/registry-cache.d.ts.map +1 -0
  278. package/dist/agents/extensions/registry-cache.js +117 -0
  279. package/dist/agents/extensions/registry-cache.js.map +1 -0
  280. package/dist/agents/extensions/registry.d.ts +184 -0
  281. package/dist/agents/extensions/registry.d.ts.map +1 -0
  282. package/dist/agents/extensions/registry.js +512 -0
  283. package/dist/agents/extensions/registry.js.map +1 -0
  284. package/dist/agents/extensions/types.d.ts +1195 -0
  285. package/dist/agents/extensions/types.d.ts.map +1 -0
  286. package/dist/agents/extensions/types.js +28 -0
  287. package/dist/agents/extensions/types.js.map +1 -0
  288. package/dist/agents/gateway-call.d.ts +171 -0
  289. package/dist/agents/gateway-call.d.ts.map +1 -0
  290. package/dist/agents/gateway-call.js +74 -0
  291. package/dist/agents/gateway-call.js.map +1 -0
  292. package/dist/agents/heartbeat-runner.d.ts +100 -0
  293. package/dist/agents/heartbeat-runner.d.ts.map +1 -0
  294. package/dist/agents/heartbeat-runner.js +268 -0
  295. package/dist/agents/heartbeat-runner.js.map +1 -0
  296. package/dist/agents/heartbeat-scheduler.d.ts +56 -0
  297. package/dist/agents/heartbeat-scheduler.d.ts.map +1 -0
  298. package/dist/agents/heartbeat-scheduler.js +366 -0
  299. package/dist/agents/heartbeat-scheduler.js.map +1 -0
  300. package/dist/agents/heartbeat-wake.d.ts +99 -0
  301. package/dist/agents/heartbeat-wake.d.ts.map +1 -0
  302. package/dist/agents/heartbeat-wake.js +304 -0
  303. package/dist/agents/heartbeat-wake.js.map +1 -0
  304. package/dist/agents/identity-file.d.ts +26 -0
  305. package/dist/agents/identity-file.d.ts.map +1 -0
  306. package/dist/agents/identity-file.js +86 -0
  307. package/dist/agents/identity-file.js.map +1 -0
  308. package/dist/agents/identity-links.d.ts +44 -0
  309. package/dist/agents/identity-links.d.ts.map +1 -0
  310. package/dist/agents/identity-links.js +51 -0
  311. package/dist/agents/identity-links.js.map +1 -0
  312. package/dist/agents/loop/autonomous-agent.d.ts +55 -0
  313. package/dist/agents/loop/autonomous-agent.d.ts.map +1 -0
  314. package/dist/agents/loop/autonomous-agent.js +91 -0
  315. package/dist/agents/loop/autonomous-agent.js.map +1 -0
  316. package/dist/agents/loop/loop-guards.d.ts +95 -0
  317. package/dist/agents/loop/loop-guards.d.ts.map +1 -0
  318. package/dist/agents/loop/loop-guards.js +169 -0
  319. package/dist/agents/loop/loop-guards.js.map +1 -0
  320. package/dist/agents/loop/loop-runner.d.ts +72 -0
  321. package/dist/agents/loop/loop-runner.d.ts.map +1 -0
  322. package/dist/agents/loop/loop-runner.js +114 -0
  323. package/dist/agents/loop/loop-runner.js.map +1 -0
  324. package/dist/agents/memory/auto-recall.d.ts +69 -0
  325. package/dist/agents/memory/auto-recall.d.ts.map +1 -0
  326. package/dist/agents/memory/auto-recall.js +147 -0
  327. package/dist/agents/memory/auto-recall.js.map +1 -0
  328. package/dist/agents/memory/behavior-review.d.ts +68 -0
  329. package/dist/agents/memory/behavior-review.d.ts.map +1 -0
  330. package/dist/agents/memory/behavior-review.js +131 -0
  331. package/dist/agents/memory/behavior-review.js.map +1 -0
  332. package/dist/agents/memory/consolidate.d.ts +62 -0
  333. package/dist/agents/memory/consolidate.d.ts.map +1 -0
  334. package/dist/agents/memory/consolidate.js +275 -0
  335. package/dist/agents/memory/consolidate.js.map +1 -0
  336. package/dist/agents/memory/contradiction.d.ts +44 -0
  337. package/dist/agents/memory/contradiction.d.ts.map +1 -0
  338. package/dist/agents/memory/contradiction.js +86 -0
  339. package/dist/agents/memory/contradiction.js.map +1 -0
  340. package/dist/agents/memory/curator.d.ts +22 -0
  341. package/dist/agents/memory/curator.d.ts.map +1 -0
  342. package/dist/agents/memory/curator.js +52 -0
  343. package/dist/agents/memory/curator.js.map +1 -0
  344. package/dist/agents/memory/decay.d.ts +32 -0
  345. package/dist/agents/memory/decay.d.ts.map +1 -0
  346. package/dist/agents/memory/decay.js +86 -0
  347. package/dist/agents/memory/decay.js.map +1 -0
  348. package/dist/agents/memory/dream.d.ts +52 -0
  349. package/dist/agents/memory/dream.d.ts.map +1 -0
  350. package/dist/agents/memory/dream.js +192 -0
  351. package/dist/agents/memory/dream.js.map +1 -0
  352. package/dist/agents/memory/embedder-providers.d.ts +114 -0
  353. package/dist/agents/memory/embedder-providers.d.ts.map +1 -0
  354. package/dist/agents/memory/embedder-providers.js +213 -0
  355. package/dist/agents/memory/embedder-providers.js.map +1 -0
  356. package/dist/agents/memory/embedder.d.ts +84 -0
  357. package/dist/agents/memory/embedder.d.ts.map +1 -0
  358. package/dist/agents/memory/embedder.js +218 -0
  359. package/dist/agents/memory/embedder.js.map +1 -0
  360. package/dist/agents/memory/eval/asr-bench.d.ts +33 -0
  361. package/dist/agents/memory/eval/asr-bench.d.ts.map +1 -0
  362. package/dist/agents/memory/eval/asr-bench.js +129 -0
  363. package/dist/agents/memory/eval/asr-bench.js.map +1 -0
  364. package/dist/agents/memory/eval/capabilities.d.ts +97 -0
  365. package/dist/agents/memory/eval/capabilities.d.ts.map +1 -0
  366. package/dist/agents/memory/eval/capabilities.js +210 -0
  367. package/dist/agents/memory/eval/capabilities.js.map +1 -0
  368. package/dist/agents/memory/eval/gold-export.d.ts +44 -0
  369. package/dist/agents/memory/eval/gold-export.d.ts.map +1 -0
  370. package/dist/agents/memory/eval/gold-export.js +85 -0
  371. package/dist/agents/memory/eval/gold-export.js.map +1 -0
  372. package/dist/agents/memory/eval/gold-hard.d.ts +35 -0
  373. package/dist/agents/memory/eval/gold-hard.d.ts.map +1 -0
  374. package/dist/agents/memory/eval/gold-hard.js +113 -0
  375. package/dist/agents/memory/eval/gold-hard.js.map +1 -0
  376. package/dist/agents/memory/eval/gold-rich.d.ts +33 -0
  377. package/dist/agents/memory/eval/gold-rich.d.ts.map +1 -0
  378. package/dist/agents/memory/eval/gold-rich.js +82 -0
  379. package/dist/agents/memory/eval/gold-rich.js.map +1 -0
  380. package/dist/agents/memory/eval/gold-synthetic.d.ts +19 -0
  381. package/dist/agents/memory/eval/gold-synthetic.d.ts.map +1 -0
  382. package/dist/agents/memory/eval/gold-synthetic.js +65 -0
  383. package/dist/agents/memory/eval/gold-synthetic.js.map +1 -0
  384. package/dist/agents/memory/eval/gold.d.ts +73 -0
  385. package/dist/agents/memory/eval/gold.d.ts.map +1 -0
  386. package/dist/agents/memory/eval/gold.js +174 -0
  387. package/dist/agents/memory/eval/gold.js.map +1 -0
  388. package/dist/agents/memory/eval/harness.d.ts +110 -0
  389. package/dist/agents/memory/eval/harness.d.ts.map +1 -0
  390. package/dist/agents/memory/eval/harness.js +123 -0
  391. package/dist/agents/memory/eval/harness.js.map +1 -0
  392. package/dist/agents/memory/eval/metrics.d.ts +71 -0
  393. package/dist/agents/memory/eval/metrics.d.ts.map +1 -0
  394. package/dist/agents/memory/eval/metrics.js +169 -0
  395. package/dist/agents/memory/eval/metrics.js.map +1 -0
  396. package/dist/agents/memory/event-log.d.ts +52 -0
  397. package/dist/agents/memory/event-log.d.ts.map +1 -0
  398. package/dist/agents/memory/event-log.js +65 -0
  399. package/dist/agents/memory/event-log.js.map +1 -0
  400. package/dist/agents/memory/extract.d.ts +155 -0
  401. package/dist/agents/memory/extract.d.ts.map +1 -0
  402. package/dist/agents/memory/extract.js +571 -0
  403. package/dist/agents/memory/extract.js.map +1 -0
  404. package/dist/agents/memory/governance.d.ts +45 -0
  405. package/dist/agents/memory/governance.d.ts.map +1 -0
  406. package/dist/agents/memory/governance.js +113 -0
  407. package/dist/agents/memory/governance.js.map +1 -0
  408. package/dist/agents/memory/graph-export.d.ts +59 -0
  409. package/dist/agents/memory/graph-export.d.ts.map +1 -0
  410. package/dist/agents/memory/graph-export.js +181 -0
  411. package/dist/agents/memory/graph-export.js.map +1 -0
  412. package/dist/agents/memory/graph-recall.d.ts +42 -0
  413. package/dist/agents/memory/graph-recall.d.ts.map +1 -0
  414. package/dist/agents/memory/graph-recall.js +165 -0
  415. package/dist/agents/memory/graph-recall.js.map +1 -0
  416. package/dist/agents/memory/graph.d.ts +92 -0
  417. package/dist/agents/memory/graph.d.ts.map +1 -0
  418. package/dist/agents/memory/graph.js +266 -0
  419. package/dist/agents/memory/graph.js.map +1 -0
  420. package/dist/agents/memory/host-ports.d.ts +27 -0
  421. package/dist/agents/memory/host-ports.d.ts.map +1 -0
  422. package/dist/agents/memory/host-ports.js +31 -0
  423. package/dist/agents/memory/host-ports.js.map +1 -0
  424. package/dist/agents/memory/hybrid.d.ts +46 -0
  425. package/dist/agents/memory/hybrid.d.ts.map +1 -0
  426. package/dist/agents/memory/hybrid.js +184 -0
  427. package/dist/agents/memory/hybrid.js.map +1 -0
  428. package/dist/agents/memory/index.d.ts +13 -0
  429. package/dist/agents/memory/index.d.ts.map +1 -0
  430. package/dist/agents/memory/index.js +13 -0
  431. package/dist/agents/memory/index.js.map +1 -0
  432. package/dist/agents/memory/json-scan.d.ts +14 -0
  433. package/dist/agents/memory/json-scan.d.ts.map +1 -0
  434. package/dist/agents/memory/json-scan.js +47 -0
  435. package/dist/agents/memory/json-scan.js.map +1 -0
  436. package/dist/agents/memory/links.d.ts +92 -0
  437. package/dist/agents/memory/links.d.ts.map +1 -0
  438. package/dist/agents/memory/links.js +140 -0
  439. package/dist/agents/memory/links.js.map +1 -0
  440. package/dist/agents/memory/maintenance.d.ts +18 -0
  441. package/dist/agents/memory/maintenance.d.ts.map +1 -0
  442. package/dist/agents/memory/maintenance.js +66 -0
  443. package/dist/agents/memory/maintenance.js.map +1 -0
  444. package/dist/agents/memory/memory-mcp-server.d.ts +39 -0
  445. package/dist/agents/memory/memory-mcp-server.d.ts.map +1 -0
  446. package/dist/agents/memory/memory-mcp-server.js +122 -0
  447. package/dist/agents/memory/memory-mcp-server.js.map +1 -0
  448. package/dist/agents/memory/memory-mcp.d.ts +34 -0
  449. package/dist/agents/memory/memory-mcp.d.ts.map +1 -0
  450. package/dist/agents/memory/memory-mcp.js +130 -0
  451. package/dist/agents/memory/memory-mcp.js.map +1 -0
  452. package/dist/agents/memory/plugin-runtime.d.ts +133 -0
  453. package/dist/agents/memory/plugin-runtime.d.ts.map +1 -0
  454. package/dist/agents/memory/plugin-runtime.js +149 -0
  455. package/dist/agents/memory/plugin-runtime.js.map +1 -0
  456. package/dist/agents/memory/query.d.ts +50 -0
  457. package/dist/agents/memory/query.d.ts.map +1 -0
  458. package/dist/agents/memory/query.js +94 -0
  459. package/dist/agents/memory/query.js.map +1 -0
  460. package/dist/agents/memory/records.d.ts +617 -0
  461. package/dist/agents/memory/records.d.ts.map +1 -0
  462. package/dist/agents/memory/records.js +1327 -0
  463. package/dist/agents/memory/records.js.map +1 -0
  464. package/dist/agents/memory/reembed.d.ts +42 -0
  465. package/dist/agents/memory/reembed.d.ts.map +1 -0
  466. package/dist/agents/memory/reembed.js +60 -0
  467. package/dist/agents/memory/reembed.js.map +1 -0
  468. package/dist/agents/memory/relationship-extract.d.ts +259 -0
  469. package/dist/agents/memory/relationship-extract.d.ts.map +1 -0
  470. package/dist/agents/memory/relationship-extract.js +454 -0
  471. package/dist/agents/memory/relationship-extract.js.map +1 -0
  472. package/dist/agents/memory/rerank.d.ts +37 -0
  473. package/dist/agents/memory/rerank.d.ts.map +1 -0
  474. package/dist/agents/memory/rerank.js +43 -0
  475. package/dist/agents/memory/rerank.js.map +1 -0
  476. package/dist/agents/memory/scoring.d.ts +85 -0
  477. package/dist/agents/memory/scoring.d.ts.map +1 -0
  478. package/dist/agents/memory/scoring.js +139 -0
  479. package/dist/agents/memory/scoring.js.map +1 -0
  480. package/dist/agents/memory/self-improve.d.ts +56 -0
  481. package/dist/agents/memory/self-improve.d.ts.map +1 -0
  482. package/dist/agents/memory/self-improve.js +98 -0
  483. package/dist/agents/memory/self-improve.js.map +1 -0
  484. package/dist/agents/memory/self-review.d.ts +68 -0
  485. package/dist/agents/memory/self-review.d.ts.map +1 -0
  486. package/dist/agents/memory/self-review.js +109 -0
  487. package/dist/agents/memory/self-review.js.map +1 -0
  488. package/dist/agents/memory/storage.d.ts +156 -0
  489. package/dist/agents/memory/storage.d.ts.map +1 -0
  490. package/dist/agents/memory/storage.js +359 -0
  491. package/dist/agents/memory/storage.js.map +1 -0
  492. package/dist/agents/memory/tideline.d.ts +203 -0
  493. package/dist/agents/memory/tideline.d.ts.map +1 -0
  494. package/dist/agents/memory/tideline.js +189 -0
  495. package/dist/agents/memory/tideline.js.map +1 -0
  496. package/dist/agents/memory/vault.d.ts +142 -0
  497. package/dist/agents/memory/vault.d.ts.map +1 -0
  498. package/dist/agents/memory/vault.js +787 -0
  499. package/dist/agents/memory/vault.js.map +1 -0
  500. package/dist/agents/memory/write-gate.d.ts +76 -0
  501. package/dist/agents/memory/write-gate.d.ts.map +1 -0
  502. package/dist/agents/memory/write-gate.js +140 -0
  503. package/dist/agents/memory/write-gate.js.map +1 -0
  504. package/dist/agents/mid-turn-switch.d.ts +25 -0
  505. package/dist/agents/mid-turn-switch.d.ts.map +1 -0
  506. package/dist/agents/mid-turn-switch.js +103 -0
  507. package/dist/agents/mid-turn-switch.js.map +1 -0
  508. package/dist/agents/model-fallback.d.ts +50 -0
  509. package/dist/agents/model-fallback.d.ts.map +1 -0
  510. package/dist/agents/model-fallback.js +226 -0
  511. package/dist/agents/model-fallback.js.map +1 -0
  512. package/dist/agents/model-resolution.d.ts +38 -0
  513. package/dist/agents/model-resolution.d.ts.map +1 -0
  514. package/dist/agents/model-resolution.js +155 -0
  515. package/dist/agents/model-resolution.js.map +1 -0
  516. package/dist/agents/org/a2a-adapter.d.ts +49 -0
  517. package/dist/agents/org/a2a-adapter.d.ts.map +1 -0
  518. package/dist/agents/org/a2a-adapter.js +92 -0
  519. package/dist/agents/org/a2a-adapter.js.map +1 -0
  520. package/dist/agents/org/assets/mascots/README.md +34 -0
  521. package/dist/agents/org/assets/mascots/Untitled-1.png +0 -0
  522. package/dist/agents/org/assets/mascots/brigade_biceps.png +0 -0
  523. package/dist/agents/org/audit-log.d.ts +22 -0
  524. package/dist/agents/org/audit-log.d.ts.map +1 -0
  525. package/dist/agents/org/audit-log.js +37 -0
  526. package/dist/agents/org/audit-log.js.map +1 -0
  527. package/dist/agents/org/auto-derive.d.ts +22 -0
  528. package/dist/agents/org/auto-derive.d.ts.map +1 -0
  529. package/dist/agents/org/auto-derive.js +66 -0
  530. package/dist/agents/org/auto-derive.js.map +1 -0
  531. package/dist/agents/org/delivery-kind.d.ts +89 -0
  532. package/dist/agents/org/delivery-kind.d.ts.map +1 -0
  533. package/dist/agents/org/delivery-kind.js +149 -0
  534. package/dist/agents/org/delivery-kind.js.map +1 -0
  535. package/dist/agents/org/derive-graph.d.ts +34 -0
  536. package/dist/agents/org/derive-graph.d.ts.map +1 -0
  537. package/dist/agents/org/derive-graph.js +266 -0
  538. package/dist/agents/org/derive-graph.js.map +1 -0
  539. package/dist/agents/org/lints.d.ts +21 -0
  540. package/dist/agents/org/lints.d.ts.map +1 -0
  541. package/dist/agents/org/lints.js +133 -0
  542. package/dist/agents/org/lints.js.map +1 -0
  543. package/dist/agents/org/pride-html.d.ts +61 -0
  544. package/dist/agents/org/pride-html.d.ts.map +1 -0
  545. package/dist/agents/org/pride-html.js +565 -0
  546. package/dist/agents/org/pride-html.js.map +1 -0
  547. package/dist/agents/org/pride-image.d.ts +101 -0
  548. package/dist/agents/org/pride-image.d.ts.map +1 -0
  549. package/dist/agents/org/pride-image.js +210 -0
  550. package/dist/agents/org/pride-image.js.map +1 -0
  551. package/dist/agents/org/pride-taunts.d.ts +47 -0
  552. package/dist/agents/org/pride-taunts.d.ts.map +1 -0
  553. package/dist/agents/org/pride-taunts.js +411 -0
  554. package/dist/agents/org/pride-taunts.js.map +1 -0
  555. package/dist/agents/org/pride-template.d.ts +272 -0
  556. package/dist/agents/org/pride-template.d.ts.map +1 -0
  557. package/dist/agents/org/pride-template.js +892 -0
  558. package/dist/agents/org/pride-template.js.map +1 -0
  559. package/dist/agents/org/pride-themes.d.ts +80 -0
  560. package/dist/agents/org/pride-themes.d.ts.map +1 -0
  561. package/dist/agents/org/pride-themes.js +7596 -0
  562. package/dist/agents/org/pride-themes.js.map +1 -0
  563. package/dist/agents/org/structured-errors.d.ts +47 -0
  564. package/dist/agents/org/structured-errors.d.ts.map +1 -0
  565. package/dist/agents/org/structured-errors.js +97 -0
  566. package/dist/agents/org/structured-errors.js.map +1 -0
  567. package/dist/agents/org/types.d.ts +139 -0
  568. package/dist/agents/org/types.d.ts.map +1 -0
  569. package/dist/agents/org/types.js +43 -0
  570. package/dist/agents/org/types.js.map +1 -0
  571. package/dist/agents/org/validate.d.ts +36 -0
  572. package/dist/agents/org/validate.d.ts.map +1 -0
  573. package/dist/agents/org/validate.js +135 -0
  574. package/dist/agents/org/validate.js.map +1 -0
  575. package/dist/agents/path-write-guard.d.ts +82 -0
  576. package/dist/agents/path-write-guard.d.ts.map +1 -0
  577. package/dist/agents/path-write-guard.js +722 -0
  578. package/dist/agents/path-write-guard.js.map +1 -0
  579. package/dist/agents/payload-mutators.d.ts +175 -0
  580. package/dist/agents/payload-mutators.d.ts.map +1 -0
  581. package/dist/agents/payload-mutators.js +994 -0
  582. package/dist/agents/payload-mutators.js.map +1 -0
  583. package/dist/agents/pending-system-events.d.ts +76 -0
  584. package/dist/agents/pending-system-events.d.ts.map +1 -0
  585. package/dist/agents/pending-system-events.js +115 -0
  586. package/dist/agents/pending-system-events.js.map +1 -0
  587. package/dist/agents/provider-attribution.d.ts +19 -0
  588. package/dist/agents/provider-attribution.d.ts.map +1 -0
  589. package/dist/agents/provider-attribution.js +62 -0
  590. package/dist/agents/provider-attribution.js.map +1 -0
  591. package/dist/agents/quality/slop-detector.d.ts +40 -0
  592. package/dist/agents/quality/slop-detector.d.ts.map +1 -0
  593. package/dist/agents/quality/slop-detector.js +108 -0
  594. package/dist/agents/quality/slop-detector.js.map +1 -0
  595. package/dist/agents/quality/slop-index.d.ts +27 -0
  596. package/dist/agents/quality/slop-index.d.ts.map +1 -0
  597. package/dist/agents/quality/slop-index.js +124 -0
  598. package/dist/agents/quality/slop-index.js.map +1 -0
  599. package/dist/agents/retry-policy.d.ts +38 -0
  600. package/dist/agents/retry-policy.d.ts.map +1 -0
  601. package/dist/agents/retry-policy.js +276 -0
  602. package/dist/agents/retry-policy.js.map +1 -0
  603. package/dist/agents/routing/account-id.d.ts +43 -0
  604. package/dist/agents/routing/account-id.d.ts.map +1 -0
  605. package/dist/agents/routing/account-id.js +103 -0
  606. package/dist/agents/routing/account-id.js.map +1 -0
  607. package/dist/agents/routing/bindings.d.ts +20 -0
  608. package/dist/agents/routing/bindings.d.ts.map +1 -0
  609. package/dist/agents/routing/bindings.js +22 -0
  610. package/dist/agents/routing/bindings.js.map +1 -0
  611. package/dist/agents/routing/dm-scope-warning.d.ts +37 -0
  612. package/dist/agents/routing/dm-scope-warning.d.ts.map +1 -0
  613. package/dist/agents/routing/dm-scope-warning.js +110 -0
  614. package/dist/agents/routing/dm-scope-warning.js.map +1 -0
  615. package/dist/agents/routing/identity-links.d.ts +45 -0
  616. package/dist/agents/routing/identity-links.d.ts.map +1 -0
  617. package/dist/agents/routing/identity-links.js +85 -0
  618. package/dist/agents/routing/identity-links.js.map +1 -0
  619. package/dist/agents/routing/resolve-route.d.ts +91 -0
  620. package/dist/agents/routing/resolve-route.d.ts.map +1 -0
  621. package/dist/agents/routing/resolve-route.js +653 -0
  622. package/dist/agents/routing/resolve-route.js.map +1 -0
  623. package/dist/agents/routing/session-key.d.ts +168 -0
  624. package/dist/agents/routing/session-key.d.ts.map +1 -0
  625. package/dist/agents/routing/session-key.js +268 -0
  626. package/dist/agents/routing/session-key.js.map +1 -0
  627. package/dist/agents/sanitize-surrogates.d.ts +30 -0
  628. package/dist/agents/sanitize-surrogates.d.ts.map +1 -0
  629. package/dist/agents/sanitize-surrogates.js +56 -0
  630. package/dist/agents/sanitize-surrogates.js.map +1 -0
  631. package/dist/agents/session-context.d.ts +80 -0
  632. package/dist/agents/session-context.d.ts.map +1 -0
  633. package/dist/agents/session-context.js +76 -0
  634. package/dist/agents/session-context.js.map +1 -0
  635. package/dist/agents/session-event-prompt.d.ts +124 -0
  636. package/dist/agents/session-event-prompt.d.ts.map +1 -0
  637. package/dist/agents/session-event-prompt.js +179 -0
  638. package/dist/agents/session-event-prompt.js.map +1 -0
  639. package/dist/agents/session-inbox.d.ts +129 -0
  640. package/dist/agents/session-inbox.d.ts.map +1 -0
  641. package/dist/agents/session-inbox.js +492 -0
  642. package/dist/agents/session-inbox.js.map +1 -0
  643. package/dist/agents/session-registry.d.ts +148 -0
  644. package/dist/agents/session-registry.d.ts.map +1 -0
  645. package/dist/agents/session-registry.js +405 -0
  646. package/dist/agents/session-registry.js.map +1 -0
  647. package/dist/agents/session-wiring.d.ts +214 -0
  648. package/dist/agents/session-wiring.d.ts.map +1 -0
  649. package/dist/agents/session-wiring.js +278 -0
  650. package/dist/agents/session-wiring.js.map +1 -0
  651. package/dist/agents/session-write-lock.d.ts +15 -0
  652. package/dist/agents/session-write-lock.d.ts.map +1 -0
  653. package/dist/agents/session-write-lock.js +15 -0
  654. package/dist/agents/session-write-lock.js.map +1 -0
  655. package/dist/agents/skills/agent-filter.d.ts +43 -0
  656. package/dist/agents/skills/agent-filter.d.ts.map +1 -0
  657. package/dist/agents/skills/agent-filter.js +89 -0
  658. package/dist/agents/skills/agent-filter.js.map +1 -0
  659. package/dist/agents/skills/discovery.d.ts +97 -0
  660. package/dist/agents/skills/discovery.d.ts.map +1 -0
  661. package/dist/agents/skills/discovery.js +136 -0
  662. package/dist/agents/skills/discovery.js.map +1 -0
  663. package/dist/agents/skills/eligibility.d.ts +118 -0
  664. package/dist/agents/skills/eligibility.d.ts.map +1 -0
  665. package/dist/agents/skills/eligibility.js +280 -0
  666. package/dist/agents/skills/eligibility.js.map +1 -0
  667. package/dist/agents/skills/grant.d.ts +70 -0
  668. package/dist/agents/skills/grant.d.ts.map +1 -0
  669. package/dist/agents/skills/grant.js +106 -0
  670. package/dist/agents/skills/grant.js.map +1 -0
  671. package/dist/agents/skills/index.d.ts +35 -0
  672. package/dist/agents/skills/index.d.ts.map +1 -0
  673. package/dist/agents/skills/index.js +88 -0
  674. package/dist/agents/skills/index.js.map +1 -0
  675. package/dist/agents/skills/install-spec.d.ts +51 -0
  676. package/dist/agents/skills/install-spec.d.ts.map +1 -0
  677. package/dist/agents/skills/install-spec.js +21 -0
  678. package/dist/agents/skills/install-spec.js.map +1 -0
  679. package/dist/agents/skills/install.d.ts +68 -0
  680. package/dist/agents/skills/install.d.ts.map +1 -0
  681. package/dist/agents/skills/install.js +206 -0
  682. package/dist/agents/skills/install.js.map +1 -0
  683. package/dist/agents/skills/org-access.d.ts +27 -0
  684. package/dist/agents/skills/org-access.d.ts.map +1 -0
  685. package/dist/agents/skills/org-access.js +87 -0
  686. package/dist/agents/skills/org-access.js.map +1 -0
  687. package/dist/agents/skills/skill-consolidate.d.ts +76 -0
  688. package/dist/agents/skills/skill-consolidate.d.ts.map +1 -0
  689. package/dist/agents/skills/skill-consolidate.js +264 -0
  690. package/dist/agents/skills/skill-consolidate.js.map +1 -0
  691. package/dist/agents/skills/skill-curator.d.ts +91 -0
  692. package/dist/agents/skills/skill-curator.d.ts.map +1 -0
  693. package/dist/agents/skills/skill-curator.js +239 -0
  694. package/dist/agents/skills/skill-curator.js.map +1 -0
  695. package/dist/agents/skills/skill-manifest.d.ts +35 -0
  696. package/dist/agents/skills/skill-manifest.d.ts.map +1 -0
  697. package/dist/agents/skills/skill-manifest.js +82 -0
  698. package/dist/agents/skills/skill-manifest.js.map +1 -0
  699. package/dist/agents/skills/skill-review.d.ts +91 -0
  700. package/dist/agents/skills/skill-review.d.ts.map +1 -0
  701. package/dist/agents/skills/skill-review.js +271 -0
  702. package/dist/agents/skills/skill-review.js.map +1 -0
  703. package/dist/agents/skills/skill-usage.d.ts +81 -0
  704. package/dist/agents/skills/skill-usage.d.ts.map +1 -0
  705. package/dist/agents/skills/skill-usage.js +208 -0
  706. package/dist/agents/skills/skill-usage.js.map +1 -0
  707. package/dist/agents/skills/status.d.ts +68 -0
  708. package/dist/agents/skills/status.d.ts.map +1 -0
  709. package/dist/agents/skills/status.js +147 -0
  710. package/dist/agents/skills/status.js.map +1 -0
  711. package/dist/agents/skills/update-config.d.ts +32 -0
  712. package/dist/agents/skills/update-config.d.ts.map +1 -0
  713. package/dist/agents/skills/update-config.js +53 -0
  714. package/dist/agents/skills/update-config.js.map +1 -0
  715. package/dist/agents/slash-commands.d.ts +25 -0
  716. package/dist/agents/slash-commands.d.ts.map +1 -0
  717. package/dist/agents/slash-commands.js +151 -0
  718. package/dist/agents/slash-commands.js.map +1 -0
  719. package/dist/agents/smart-compaction.d.ts +105 -0
  720. package/dist/agents/smart-compaction.d.ts.map +1 -0
  721. package/dist/agents/smart-compaction.js +355 -0
  722. package/dist/agents/smart-compaction.js.map +1 -0
  723. package/dist/agents/stream-wrappers.d.ts +20 -0
  724. package/dist/agents/stream-wrappers.d.ts.map +1 -0
  725. package/dist/agents/stream-wrappers.js +307 -0
  726. package/dist/agents/stream-wrappers.js.map +1 -0
  727. package/dist/agents/subagent-abort-cascade.d.ts +31 -0
  728. package/dist/agents/subagent-abort-cascade.d.ts.map +1 -0
  729. package/dist/agents/subagent-abort-cascade.js +124 -0
  730. package/dist/agents/subagent-abort-cascade.js.map +1 -0
  731. package/dist/agents/subagent-announce-delivery.d.ts +83 -0
  732. package/dist/agents/subagent-announce-delivery.d.ts.map +1 -0
  733. package/dist/agents/subagent-announce-delivery.js +159 -0
  734. package/dist/agents/subagent-announce-delivery.js.map +1 -0
  735. package/dist/agents/subagent-budget.d.ts +36 -0
  736. package/dist/agents/subagent-budget.d.ts.map +1 -0
  737. package/dist/agents/subagent-budget.js +93 -0
  738. package/dist/agents/subagent-budget.js.map +1 -0
  739. package/dist/agents/subagent-completion-bridge.d.ts +42 -0
  740. package/dist/agents/subagent-completion-bridge.d.ts.map +1 -0
  741. package/dist/agents/subagent-completion-bridge.js +338 -0
  742. package/dist/agents/subagent-completion-bridge.js.map +1 -0
  743. package/dist/agents/subagent-lifecycle-events.d.ts +31 -0
  744. package/dist/agents/subagent-lifecycle-events.d.ts.map +1 -0
  745. package/dist/agents/subagent-lifecycle-events.js +21 -0
  746. package/dist/agents/subagent-lifecycle-events.js.map +1 -0
  747. package/dist/agents/subagent-policy.d.ts +206 -0
  748. package/dist/agents/subagent-policy.d.ts.map +1 -0
  749. package/dist/agents/subagent-policy.js +295 -0
  750. package/dist/agents/subagent-policy.js.map +1 -0
  751. package/dist/agents/subagent-registry-completion.d.ts +69 -0
  752. package/dist/agents/subagent-registry-completion.d.ts.map +1 -0
  753. package/dist/agents/subagent-registry-completion.js +128 -0
  754. package/dist/agents/subagent-registry-completion.js.map +1 -0
  755. package/dist/agents/subagent-registry.d.ts +85 -0
  756. package/dist/agents/subagent-registry.d.ts.map +1 -0
  757. package/dist/agents/subagent-registry.js +215 -0
  758. package/dist/agents/subagent-registry.js.map +1 -0
  759. package/dist/agents/subagent-registry.types.d.ts +94 -0
  760. package/dist/agents/subagent-registry.types.d.ts.map +1 -0
  761. package/dist/agents/subagent-registry.types.js +19 -0
  762. package/dist/agents/subagent-registry.types.js.map +1 -0
  763. package/dist/agents/subagent-runner.d.ts +75 -0
  764. package/dist/agents/subagent-runner.d.ts.map +1 -0
  765. package/dist/agents/subagent-runner.js +358 -0
  766. package/dist/agents/subagent-runner.js.map +1 -0
  767. package/dist/agents/subagent-spawn-abort-marker.d.ts +46 -0
  768. package/dist/agents/subagent-spawn-abort-marker.d.ts.map +1 -0
  769. package/dist/agents/subagent-spawn-abort-marker.js +81 -0
  770. package/dist/agents/subagent-spawn-abort-marker.js.map +1 -0
  771. package/dist/agents/subagent-spawn.d.ts +104 -0
  772. package/dist/agents/subagent-spawn.d.ts.map +1 -0
  773. package/dist/agents/subagent-spawn.js +358 -0
  774. package/dist/agents/subagent-spawn.js.map +1 -0
  775. package/dist/agents/thinking-fallback.d.ts +49 -0
  776. package/dist/agents/thinking-fallback.d.ts.map +1 -0
  777. package/dist/agents/thinking-fallback.js +97 -0
  778. package/dist/agents/thinking-fallback.js.map +1 -0
  779. package/dist/agents/tool-guard.d.ts +71 -0
  780. package/dist/agents/tool-guard.d.ts.map +1 -0
  781. package/dist/agents/tool-guard.js +154 -0
  782. package/dist/agents/tool-guard.js.map +1 -0
  783. package/dist/agents/tool-loop-detector.d.ts +115 -0
  784. package/dist/agents/tool-loop-detector.d.ts.map +1 -0
  785. package/dist/agents/tool-loop-detector.js +0 -0
  786. package/dist/agents/tool-loop-detector.js.map +1 -0
  787. package/dist/agents/tool-summaries.d.ts +3 -0
  788. package/dist/agents/tool-summaries.d.ts.map +1 -0
  789. package/dist/agents/tool-summaries.js +78 -0
  790. package/dist/agents/tool-summaries.js.map +1 -0
  791. package/dist/agents/tools/agents-list-tool.d.ts +51 -0
  792. package/dist/agents/tools/agents-list-tool.d.ts.map +1 -0
  793. package/dist/agents/tools/agents-list-tool.js +167 -0
  794. package/dist/agents/tools/agents-list-tool.js.map +1 -0
  795. package/dist/agents/tools/browser.d.ts +144 -0
  796. package/dist/agents/tools/browser.d.ts.map +1 -0
  797. package/dist/agents/tools/browser.js +1538 -0
  798. package/dist/agents/tools/browser.js.map +1 -0
  799. package/dist/agents/tools/common.d.ts +208 -0
  800. package/dist/agents/tools/common.d.ts.map +1 -0
  801. package/dist/agents/tools/common.js +405 -0
  802. package/dist/agents/tools/common.js.map +1 -0
  803. package/dist/agents/tools/composio-tool.d.ts +179 -0
  804. package/dist/agents/tools/composio-tool.d.ts.map +1 -0
  805. package/dist/agents/tools/composio-tool.js +474 -0
  806. package/dist/agents/tools/composio-tool.js.map +1 -0
  807. package/dist/agents/tools/cron-tool.d.ts +187 -0
  808. package/dist/agents/tools/cron-tool.d.ts.map +1 -0
  809. package/dist/agents/tools/cron-tool.js +985 -0
  810. package/dist/agents/tools/cron-tool.js.map +1 -0
  811. package/dist/agents/tools/find-tool.d.ts +55 -0
  812. package/dist/agents/tools/find-tool.d.ts.map +1 -0
  813. package/dist/agents/tools/find-tool.js +163 -0
  814. package/dist/agents/tools/find-tool.js.map +1 -0
  815. package/dist/agents/tools/generate-image-tool.d.ts +77 -0
  816. package/dist/agents/tools/generate-image-tool.d.ts.map +1 -0
  817. package/dist/agents/tools/generate-image-tool.js +421 -0
  818. package/dist/agents/tools/generate-image-tool.js.map +1 -0
  819. package/dist/agents/tools/index.d.ts +14 -0
  820. package/dist/agents/tools/index.d.ts.map +1 -0
  821. package/dist/agents/tools/index.js +12 -0
  822. package/dist/agents/tools/index.js.map +1 -0
  823. package/dist/agents/tools/manage-access-tool.d.ts +64 -0
  824. package/dist/agents/tools/manage-access-tool.d.ts.map +1 -0
  825. package/dist/agents/tools/manage-access-tool.js +188 -0
  826. package/dist/agents/tools/manage-access-tool.js.map +1 -0
  827. package/dist/agents/tools/manage-agent-tool.d.ts +50 -0
  828. package/dist/agents/tools/manage-agent-tool.d.ts.map +1 -0
  829. package/dist/agents/tools/manage-agent-tool.js +232 -0
  830. package/dist/agents/tools/manage-agent-tool.js.map +1 -0
  831. package/dist/agents/tools/manage-channel-access-tool.d.ts +44 -0
  832. package/dist/agents/tools/manage-channel-access-tool.d.ts.map +1 -0
  833. package/dist/agents/tools/manage-channel-access-tool.js +144 -0
  834. package/dist/agents/tools/manage-channel-access-tool.js.map +1 -0
  835. package/dist/agents/tools/manage-memory-tool.d.ts +30 -0
  836. package/dist/agents/tools/manage-memory-tool.d.ts.map +1 -0
  837. package/dist/agents/tools/manage-memory-tool.js +309 -0
  838. package/dist/agents/tools/manage-memory-tool.js.map +1 -0
  839. package/dist/agents/tools/manage-provider-tool.d.ts +65 -0
  840. package/dist/agents/tools/manage-provider-tool.d.ts.map +1 -0
  841. package/dist/agents/tools/manage-provider-tool.js +249 -0
  842. package/dist/agents/tools/manage-provider-tool.js.map +1 -0
  843. package/dist/agents/tools/manage-skill-tool.d.ts +121 -0
  844. package/dist/agents/tools/manage-skill-tool.d.ts.map +1 -0
  845. package/dist/agents/tools/manage-skill-tool.js +722 -0
  846. package/dist/agents/tools/manage-skill-tool.js.map +1 -0
  847. package/dist/agents/tools/memory-tools.d.ts +172 -0
  848. package/dist/agents/tools/memory-tools.d.ts.map +1 -0
  849. package/dist/agents/tools/memory-tools.js +561 -0
  850. package/dist/agents/tools/memory-tools.js.map +1 -0
  851. package/dist/agents/tools/oauth-authorize-tool.d.ts +94 -0
  852. package/dist/agents/tools/oauth-authorize-tool.d.ts.map +1 -0
  853. package/dist/agents/tools/oauth-authorize-tool.js +670 -0
  854. package/dist/agents/tools/oauth-authorize-tool.js.map +1 -0
  855. package/dist/agents/tools/org-tool.d.ts +208 -0
  856. package/dist/agents/tools/org-tool.d.ts.map +1 -0
  857. package/dist/agents/tools/org-tool.js +790 -0
  858. package/dist/agents/tools/org-tool.js.map +1 -0
  859. package/dist/agents/tools/registry.d.ts +146 -0
  860. package/dist/agents/tools/registry.d.ts.map +1 -0
  861. package/dist/agents/tools/registry.js +396 -0
  862. package/dist/agents/tools/registry.js.map +1 -0
  863. package/dist/agents/tools/send-media-tool.d.ts +92 -0
  864. package/dist/agents/tools/send-media-tool.d.ts.map +1 -0
  865. package/dist/agents/tools/send-media-tool.js +512 -0
  866. package/dist/agents/tools/send-media-tool.js.map +1 -0
  867. package/dist/agents/tools/send-message-tool.d.ts +84 -0
  868. package/dist/agents/tools/send-message-tool.d.ts.map +1 -0
  869. package/dist/agents/tools/send-message-tool.js +226 -0
  870. package/dist/agents/tools/send-message-tool.js.map +1 -0
  871. package/dist/agents/tools/sessions/history.d.ts +53 -0
  872. package/dist/agents/tools/sessions/history.d.ts.map +1 -0
  873. package/dist/agents/tools/sessions/history.js +138 -0
  874. package/dist/agents/tools/sessions/history.js.map +1 -0
  875. package/dist/agents/tools/sessions/index.d.ts +92 -0
  876. package/dist/agents/tools/sessions/index.d.ts.map +1 -0
  877. package/dist/agents/tools/sessions/index.js +125 -0
  878. package/dist/agents/tools/sessions/index.js.map +1 -0
  879. package/dist/agents/tools/sessions/list.d.ts +53 -0
  880. package/dist/agents/tools/sessions/list.d.ts.map +1 -0
  881. package/dist/agents/tools/sessions/list.js +134 -0
  882. package/dist/agents/tools/sessions/list.js.map +1 -0
  883. package/dist/agents/tools/sessions/resolve-access.d.ts +34 -0
  884. package/dist/agents/tools/sessions/resolve-access.d.ts.map +1 -0
  885. package/dist/agents/tools/sessions/resolve-access.js +67 -0
  886. package/dist/agents/tools/sessions/resolve-access.js.map +1 -0
  887. package/dist/agents/tools/sessions/send.d.ts +68 -0
  888. package/dist/agents/tools/sessions/send.d.ts.map +1 -0
  889. package/dist/agents/tools/sessions/send.js +556 -0
  890. package/dist/agents/tools/sessions/send.js.map +1 -0
  891. package/dist/agents/tools/sessions/shared.d.ts +145 -0
  892. package/dist/agents/tools/sessions/shared.d.ts.map +1 -0
  893. package/dist/agents/tools/sessions/shared.js +352 -0
  894. package/dist/agents/tools/sessions/shared.js.map +1 -0
  895. package/dist/agents/tools/sessions/spawn.d.ts +71 -0
  896. package/dist/agents/tools/sessions/spawn.d.ts.map +1 -0
  897. package/dist/agents/tools/sessions/spawn.js +132 -0
  898. package/dist/agents/tools/sessions/spawn.js.map +1 -0
  899. package/dist/agents/tools/spawn-agent-tool.d.ts +87 -0
  900. package/dist/agents/tools/spawn-agent-tool.d.ts.map +1 -0
  901. package/dist/agents/tools/spawn-agent-tool.js +189 -0
  902. package/dist/agents/tools/spawn-agent-tool.js.map +1 -0
  903. package/dist/agents/tools/spawn-agents-tool.d.ts +75 -0
  904. package/dist/agents/tools/spawn-agents-tool.d.ts.map +1 -0
  905. package/dist/agents/tools/spawn-agents-tool.js +267 -0
  906. package/dist/agents/tools/spawn-agents-tool.js.map +1 -0
  907. package/dist/agents/tools/types.d.ts +55 -0
  908. package/dist/agents/tools/types.d.ts.map +1 -0
  909. package/dist/agents/tools/types.js +28 -0
  910. package/dist/agents/tools/types.js.map +1 -0
  911. package/dist/agents/tools/web-fetch-utils.d.ts +114 -0
  912. package/dist/agents/tools/web-fetch-utils.d.ts.map +1 -0
  913. package/dist/agents/tools/web-fetch-utils.js +560 -0
  914. package/dist/agents/tools/web-fetch-utils.js.map +1 -0
  915. package/dist/agents/tools/web-fetch.d.ts +97 -0
  916. package/dist/agents/tools/web-fetch.d.ts.map +1 -0
  917. package/dist/agents/tools/web-fetch.js +369 -0
  918. package/dist/agents/tools/web-fetch.js.map +1 -0
  919. package/dist/agents/tools/web-retry.d.ts +55 -0
  920. package/dist/agents/tools/web-retry.d.ts.map +1 -0
  921. package/dist/agents/tools/web-retry.js +172 -0
  922. package/dist/agents/tools/web-retry.js.map +1 -0
  923. package/dist/agents/tools/web-search.d.ts +96 -0
  924. package/dist/agents/tools/web-search.d.ts.map +1 -0
  925. package/dist/agents/tools/web-search.js +459 -0
  926. package/dist/agents/tools/web-search.js.map +1 -0
  927. package/dist/agents/tools/web-shared.d.ts +123 -0
  928. package/dist/agents/tools/web-shared.d.ts.map +1 -0
  929. package/dist/agents/tools/web-shared.js +207 -0
  930. package/dist/agents/tools/web-shared.js.map +1 -0
  931. package/dist/assets/brigade-favicon.png +0 -0
  932. package/dist/auth/profile-cooldown.d.ts +105 -0
  933. package/dist/auth/profile-cooldown.d.ts.map +1 -0
  934. package/dist/auth/profile-cooldown.js +466 -0
  935. package/dist/auth/profile-cooldown.js.map +1 -0
  936. package/dist/auth/profiles.d.ts +93 -0
  937. package/dist/auth/profiles.d.ts.map +1 -0
  938. package/dist/auth/profiles.js +321 -0
  939. package/dist/auth/profiles.js.map +1 -0
  940. package/dist/buildstamp.json +1 -0
  941. package/dist/cli/argv.d.ts +20 -0
  942. package/dist/cli/argv.d.ts.map +1 -0
  943. package/dist/cli/argv.js +47 -0
  944. package/dist/cli/argv.js.map +1 -0
  945. package/dist/cli/commands/agent.d.ts +19 -0
  946. package/dist/cli/commands/agent.d.ts.map +1 -0
  947. package/dist/cli/commands/agent.js +297 -0
  948. package/dist/cli/commands/agent.js.map +1 -0
  949. package/dist/cli/commands/agents-bindings.d.ts +80 -0
  950. package/dist/cli/commands/agents-bindings.d.ts.map +1 -0
  951. package/dist/cli/commands/agents-bindings.js +252 -0
  952. package/dist/cli/commands/agents-bindings.js.map +1 -0
  953. package/dist/cli/commands/agents-cmd.d.ts +160 -0
  954. package/dist/cli/commands/agents-cmd.d.ts.map +1 -0
  955. package/dist/cli/commands/agents-cmd.js +1199 -0
  956. package/dist/cli/commands/agents-cmd.js.map +1 -0
  957. package/dist/cli/commands/agents-config.d.ts +102 -0
  958. package/dist/cli/commands/agents-config.d.ts.map +1 -0
  959. package/dist/cli/commands/agents-config.js +294 -0
  960. package/dist/cli/commands/agents-config.js.map +1 -0
  961. package/dist/cli/commands/agents-shared.d.ts +57 -0
  962. package/dist/cli/commands/agents-shared.d.ts.map +1 -0
  963. package/dist/cli/commands/agents-shared.js +83 -0
  964. package/dist/cli/commands/agents-shared.js.map +1 -0
  965. package/dist/cli/commands/backup.d.ts +36 -0
  966. package/dist/cli/commands/backup.d.ts.map +1 -0
  967. package/dist/cli/commands/backup.js +244 -0
  968. package/dist/cli/commands/backup.js.map +1 -0
  969. package/dist/cli/commands/channels.d.ts +106 -0
  970. package/dist/cli/commands/channels.d.ts.map +1 -0
  971. package/dist/cli/commands/channels.js +830 -0
  972. package/dist/cli/commands/channels.js.map +1 -0
  973. package/dist/cli/commands/chat.d.ts +43 -0
  974. package/dist/cli/commands/chat.d.ts.map +1 -0
  975. package/dist/cli/commands/chat.js +84 -0
  976. package/dist/cli/commands/chat.js.map +1 -0
  977. package/dist/cli/commands/config-cmd.d.ts +62 -0
  978. package/dist/cli/commands/config-cmd.d.ts.map +1 -0
  979. package/dist/cli/commands/config-cmd.js +404 -0
  980. package/dist/cli/commands/config-cmd.js.map +1 -0
  981. package/dist/cli/commands/connect.d.ts +73 -0
  982. package/dist/cli/commands/connect.d.ts.map +1 -0
  983. package/dist/cli/commands/connect.js +1952 -0
  984. package/dist/cli/commands/connect.js.map +1 -0
  985. package/dist/cli/commands/cron.d.ts +58 -0
  986. package/dist/cli/commands/cron.d.ts.map +1 -0
  987. package/dist/cli/commands/cron.js +250 -0
  988. package/dist/cli/commands/cron.js.map +1 -0
  989. package/dist/cli/commands/doctor.d.ts +25 -0
  990. package/dist/cli/commands/doctor.d.ts.map +1 -0
  991. package/dist/cli/commands/doctor.js +618 -0
  992. package/dist/cli/commands/doctor.js.map +1 -0
  993. package/dist/cli/commands/encrypt-cmd.d.ts +12 -0
  994. package/dist/cli/commands/encrypt-cmd.d.ts.map +1 -0
  995. package/dist/cli/commands/encrypt-cmd.js +119 -0
  996. package/dist/cli/commands/encrypt-cmd.js.map +1 -0
  997. package/dist/cli/commands/exec-cmd.d.ts +55 -0
  998. package/dist/cli/commands/exec-cmd.d.ts.map +1 -0
  999. package/dist/cli/commands/exec-cmd.js +253 -0
  1000. package/dist/cli/commands/exec-cmd.js.map +1 -0
  1001. package/dist/cli/commands/gateway-install.d.ts +21 -0
  1002. package/dist/cli/commands/gateway-install.d.ts.map +1 -0
  1003. package/dist/cli/commands/gateway-install.js +71 -0
  1004. package/dist/cli/commands/gateway-install.js.map +1 -0
  1005. package/dist/cli/commands/gateway-supervise.d.ts +102 -0
  1006. package/dist/cli/commands/gateway-supervise.d.ts.map +1 -0
  1007. package/dist/cli/commands/gateway-supervise.js +194 -0
  1008. package/dist/cli/commands/gateway-supervise.js.map +1 -0
  1009. package/dist/cli/commands/gateway.d.ts +58 -0
  1010. package/dist/cli/commands/gateway.d.ts.map +1 -0
  1011. package/dist/cli/commands/gateway.js +497 -0
  1012. package/dist/cli/commands/gateway.js.map +1 -0
  1013. package/dist/cli/commands/logs.d.ts +14 -0
  1014. package/dist/cli/commands/logs.d.ts.map +1 -0
  1015. package/dist/cli/commands/logs.js +93 -0
  1016. package/dist/cli/commands/logs.js.map +1 -0
  1017. package/dist/cli/commands/mcp-cmd.d.ts +4 -0
  1018. package/dist/cli/commands/mcp-cmd.d.ts.map +1 -0
  1019. package/dist/cli/commands/mcp-cmd.js +30 -0
  1020. package/dist/cli/commands/mcp-cmd.js.map +1 -0
  1021. package/dist/cli/commands/onboard-config.d.ts +23 -0
  1022. package/dist/cli/commands/onboard-config.d.ts.map +1 -0
  1023. package/dist/cli/commands/onboard-config.js +33 -0
  1024. package/dist/cli/commands/onboard-config.js.map +1 -0
  1025. package/dist/cli/commands/onboard.d.ts +48 -0
  1026. package/dist/cli/commands/onboard.d.ts.map +1 -0
  1027. package/dist/cli/commands/onboard.js +397 -0
  1028. package/dist/cli/commands/onboard.js.map +1 -0
  1029. package/dist/cli/commands/org-cmd.d.ts +87 -0
  1030. package/dist/cli/commands/org-cmd.d.ts.map +1 -0
  1031. package/dist/cli/commands/org-cmd.js +394 -0
  1032. package/dist/cli/commands/org-cmd.js.map +1 -0
  1033. package/dist/cli/commands/org-cmd.templates.d.ts +66 -0
  1034. package/dist/cli/commands/org-cmd.templates.d.ts.map +1 -0
  1035. package/dist/cli/commands/org-cmd.templates.js +145 -0
  1036. package/dist/cli/commands/org-cmd.templates.js.map +1 -0
  1037. package/dist/cli/commands/org-slash.d.ts +107 -0
  1038. package/dist/cli/commands/org-slash.d.ts.map +1 -0
  1039. package/dist/cli/commands/org-slash.js +263 -0
  1040. package/dist/cli/commands/org-slash.js.map +1 -0
  1041. package/dist/cli/commands/pairing.d.ts +33 -0
  1042. package/dist/cli/commands/pairing.d.ts.map +1 -0
  1043. package/dist/cli/commands/pairing.js +155 -0
  1044. package/dist/cli/commands/pairing.js.map +1 -0
  1045. package/dist/cli/commands/secrets-audit.d.ts +17 -0
  1046. package/dist/cli/commands/secrets-audit.d.ts.map +1 -0
  1047. package/dist/cli/commands/secrets-audit.js +109 -0
  1048. package/dist/cli/commands/secrets-audit.js.map +1 -0
  1049. package/dist/cli/commands/sessions.d.ts +22 -0
  1050. package/dist/cli/commands/sessions.d.ts.map +1 -0
  1051. package/dist/cli/commands/sessions.js +99 -0
  1052. package/dist/cli/commands/sessions.js.map +1 -0
  1053. package/dist/cli/commands/skills.d.ts +17 -0
  1054. package/dist/cli/commands/skills.d.ts.map +1 -0
  1055. package/dist/cli/commands/skills.js +100 -0
  1056. package/dist/cli/commands/skills.js.map +1 -0
  1057. package/dist/cli/commands/status.d.ts +26 -0
  1058. package/dist/cli/commands/status.d.ts.map +1 -0
  1059. package/dist/cli/commands/status.js +252 -0
  1060. package/dist/cli/commands/status.js.map +1 -0
  1061. package/dist/cli/commands/store-cmd.d.ts +36 -0
  1062. package/dist/cli/commands/store-cmd.d.ts.map +1 -0
  1063. package/dist/cli/commands/store-cmd.js +405 -0
  1064. package/dist/cli/commands/store-cmd.js.map +1 -0
  1065. package/dist/cli/flows/web-setup.d.ts +47 -0
  1066. package/dist/cli/flows/web-setup.d.ts.map +1 -0
  1067. package/dist/cli/flows/web-setup.js +324 -0
  1068. package/dist/cli/flows/web-setup.js.map +1 -0
  1069. package/dist/cli/program/build-program.d.ts +3 -0
  1070. package/dist/cli/program/build-program.d.ts.map +1 -0
  1071. package/dist/cli/program/build-program.js +1326 -0
  1072. package/dist/cli/program/build-program.js.map +1 -0
  1073. package/dist/cli/run-main.d.ts +2 -0
  1074. package/dist/cli/run-main.d.ts.map +1 -0
  1075. package/dist/cli/run-main.js +63 -0
  1076. package/dist/cli/run-main.js.map +1 -0
  1077. package/dist/config/agent-limits.d.ts +22 -0
  1078. package/dist/config/agent-limits.d.ts.map +1 -0
  1079. package/dist/config/agent-limits.js +34 -0
  1080. package/dist/config/agent-limits.js.map +1 -0
  1081. package/dist/config/io.d.ts +378 -0
  1082. package/dist/config/io.d.ts.map +1 -0
  1083. package/dist/config/io.js +602 -0
  1084. package/dist/config/io.js.map +1 -0
  1085. package/dist/config/paths.d.ts +80 -0
  1086. package/dist/config/paths.d.ts.map +1 -0
  1087. package/dist/config/paths.js +342 -0
  1088. package/dist/config/paths.js.map +1 -0
  1089. package/dist/config/types.d.ts +12 -0
  1090. package/dist/config/types.d.ts.map +1 -0
  1091. package/dist/config/types.js +12 -0
  1092. package/dist/config/types.js.map +1 -0
  1093. package/dist/core/agent-dispatcher.d.ts +91 -0
  1094. package/dist/core/agent-dispatcher.d.ts.map +1 -0
  1095. package/dist/core/agent-dispatcher.js +251 -0
  1096. package/dist/core/agent-dispatcher.js.map +1 -0
  1097. package/dist/core/agent-events-stream.d.ts +76 -0
  1098. package/dist/core/agent-events-stream.d.ts.map +1 -0
  1099. package/dist/core/agent-events-stream.js +185 -0
  1100. package/dist/core/agent-events-stream.js.map +1 -0
  1101. package/dist/core/agent-runtime-persist.d.ts +53 -0
  1102. package/dist/core/agent-runtime-persist.d.ts.map +1 -0
  1103. package/dist/core/agent-runtime-persist.js +114 -0
  1104. package/dist/core/agent-runtime-persist.js.map +1 -0
  1105. package/dist/core/auth-bridge.d.ts +8 -0
  1106. package/dist/core/auth-bridge.d.ts.map +1 -0
  1107. package/dist/core/auth-bridge.js +102 -0
  1108. package/dist/core/auth-bridge.js.map +1 -0
  1109. package/dist/core/auth-error.d.ts +49 -0
  1110. package/dist/core/auth-error.d.ts.map +1 -0
  1111. package/dist/core/auth-error.js.map +1 -0
  1112. package/dist/core/brigade-config.d.ts +205 -0
  1113. package/dist/core/brigade-config.d.ts.map +1 -0
  1114. package/dist/core/brigade-config.js +58 -6
  1115. package/dist/core/brigade-config.js.map +1 -0
  1116. package/dist/core/config.d.ts +17 -0
  1117. package/dist/core/config.d.ts.map +1 -0
  1118. package/dist/core/config.js +92 -246
  1119. package/dist/core/config.js.map +1 -0
  1120. package/dist/core/console-stream.d.ts +52 -0
  1121. package/dist/core/console-stream.d.ts.map +1 -0
  1122. package/dist/core/console-stream.js +49 -3
  1123. package/dist/core/console-stream.js.map +1 -0
  1124. package/dist/core/daemon/launchd.d.ts +19 -0
  1125. package/dist/core/daemon/launchd.d.ts.map +1 -0
  1126. package/dist/core/daemon/launchd.js +117 -0
  1127. package/dist/core/daemon/launchd.js.map +1 -0
  1128. package/dist/core/daemon/schtasks.d.ts +23 -0
  1129. package/dist/core/daemon/schtasks.d.ts.map +1 -0
  1130. package/dist/core/daemon/schtasks.js +139 -0
  1131. package/dist/core/daemon/schtasks.js.map +1 -0
  1132. package/dist/core/daemon/service.d.ts +56 -0
  1133. package/dist/core/daemon/service.d.ts.map +1 -0
  1134. package/dist/core/daemon/service.js +54 -0
  1135. package/dist/core/daemon/service.js.map +1 -0
  1136. package/dist/core/daemon/systemd.d.ts +19 -0
  1137. package/dist/core/daemon/systemd.d.ts.map +1 -0
  1138. package/dist/core/daemon/systemd.js +117 -0
  1139. package/dist/core/daemon/systemd.js.map +1 -0
  1140. package/dist/core/event-logger.d.ts +74 -0
  1141. package/dist/core/event-logger.d.ts.map +1 -0
  1142. package/dist/core/event-logger.js +299 -6
  1143. package/dist/core/event-logger.js.map +1 -0
  1144. package/dist/core/exec-approvals.d.ts +178 -0
  1145. package/dist/core/exec-approvals.d.ts.map +1 -0
  1146. package/dist/core/exec-approvals.js +591 -266
  1147. package/dist/core/exec-approvals.js.map +1 -0
  1148. package/dist/core/extension-lifecycle.d.ts +27 -0
  1149. package/dist/core/extension-lifecycle.d.ts.map +1 -0
  1150. package/dist/core/extension-lifecycle.js +45 -0
  1151. package/dist/core/extension-lifecycle.js.map +1 -0
  1152. package/dist/core/gateway-caller-impl.d.ts +42 -0
  1153. package/dist/core/gateway-caller-impl.d.ts.map +1 -0
  1154. package/dist/core/gateway-caller-impl.js +95 -0
  1155. package/dist/core/gateway-caller-impl.js.map +1 -0
  1156. package/dist/core/gateway-lock.d.ts +88 -0
  1157. package/dist/core/gateway-lock.d.ts.map +1 -0
  1158. package/dist/core/gateway-lock.js +204 -0
  1159. package/dist/core/gateway-lock.js.map +1 -0
  1160. package/dist/core/gateway-probe.d.ts +148 -0
  1161. package/dist/core/gateway-probe.d.ts.map +1 -0
  1162. package/dist/core/gateway-probe.js +319 -0
  1163. package/dist/core/gateway-probe.js.map +1 -0
  1164. package/dist/core/gateway-spawn.d.ts +40 -0
  1165. package/dist/core/gateway-spawn.d.ts.map +1 -0
  1166. package/dist/core/gateway-spawn.js +156 -0
  1167. package/dist/core/gateway-spawn.js.map +1 -0
  1168. package/dist/core/model-caps.d.ts +85 -0
  1169. package/dist/core/model-caps.d.ts.map +1 -0
  1170. package/dist/core/model-caps.js +88 -2
  1171. package/dist/core/model-caps.js.map +1 -0
  1172. package/dist/core/port-inspect.d.ts +37 -0
  1173. package/dist/core/port-inspect.d.ts.map +1 -0
  1174. package/dist/core/port-inspect.js +165 -0
  1175. package/dist/core/port-inspect.js.map +1 -0
  1176. package/dist/core/server-lanes.d.ts +25 -0
  1177. package/dist/core/server-lanes.d.ts.map +1 -0
  1178. package/dist/core/server-lanes.js +31 -0
  1179. package/dist/core/server-lanes.js.map +1 -0
  1180. package/dist/core/server-methods/cron.d.ts +104 -0
  1181. package/dist/core/server-methods/cron.d.ts.map +1 -0
  1182. package/dist/core/server-methods/cron.js +183 -0
  1183. package/dist/core/server-methods/cron.js.map +1 -0
  1184. package/dist/core/server-methods/health.d.ts +36 -0
  1185. package/dist/core/server-methods/health.d.ts.map +1 -0
  1186. package/dist/core/server-methods/health.js +51 -0
  1187. package/dist/core/server-methods/health.js.map +1 -0
  1188. package/dist/core/server-methods/org.d.ts +93 -0
  1189. package/dist/core/server-methods/org.d.ts.map +1 -0
  1190. package/dist/core/server-methods/org.js +95 -0
  1191. package/dist/core/server-methods/org.js.map +1 -0
  1192. package/dist/core/server-methods/sessions.d.ts +133 -0
  1193. package/dist/core/server-methods/sessions.d.ts.map +1 -0
  1194. package/dist/core/server-methods/sessions.js +209 -0
  1195. package/dist/core/server-methods/sessions.js.map +1 -0
  1196. package/dist/core/server.d.ts +46 -0
  1197. package/dist/core/server.d.ts.map +1 -0
  1198. package/dist/core/server.js +4716 -249
  1199. package/dist/core/server.js.map +1 -0
  1200. package/dist/core/system-prompt.d.ts +92 -0
  1201. package/dist/core/system-prompt.d.ts.map +1 -0
  1202. package/dist/core/system-prompt.js +180 -1584
  1203. package/dist/core/system-prompt.js.map +1 -0
  1204. package/dist/core/version.d.ts +4 -0
  1205. package/dist/core/version.d.ts.map +1 -0
  1206. package/dist/core/version.js +8 -13
  1207. package/dist/core/version.js.map +1 -0
  1208. package/dist/core/webhook-guards.d.ts +131 -0
  1209. package/dist/core/webhook-guards.d.ts.map +1 -0
  1210. package/dist/core/webhook-guards.js +283 -0
  1211. package/dist/core/webhook-guards.js.map +1 -0
  1212. package/dist/core/ws-subscription-filter.d.ts +9 -0
  1213. package/dist/core/ws-subscription-filter.d.ts.map +1 -0
  1214. package/dist/core/ws-subscription-filter.js +39 -0
  1215. package/dist/core/ws-subscription-filter.js.map +1 -0
  1216. package/dist/cron/active-service.d.ts +30 -0
  1217. package/dist/cron/active-service.d.ts.map +1 -0
  1218. package/dist/cron/active-service.js +48 -0
  1219. package/dist/cron/active-service.js.map +1 -0
  1220. package/dist/cron/isolated-agent/run-executor.d.ts +49 -0
  1221. package/dist/cron/isolated-agent/run-executor.d.ts.map +1 -0
  1222. package/dist/cron/isolated-agent/run-executor.js +343 -0
  1223. package/dist/cron/isolated-agent/run-executor.js.map +1 -0
  1224. package/dist/cron/isolated-agent/run.d.ts +27 -0
  1225. package/dist/cron/isolated-agent/run.d.ts.map +1 -0
  1226. package/dist/cron/isolated-agent/run.js +29 -0
  1227. package/dist/cron/isolated-agent/run.js.map +1 -0
  1228. package/dist/cron/normalize.d.ts +103 -0
  1229. package/dist/cron/normalize.d.ts.map +1 -0
  1230. package/dist/cron/normalize.js +376 -0
  1231. package/dist/cron/normalize.js.map +1 -0
  1232. package/dist/cron/parse.d.ts +27 -0
  1233. package/dist/cron/parse.d.ts.map +1 -0
  1234. package/dist/cron/parse.js +55 -0
  1235. package/dist/cron/parse.js.map +1 -0
  1236. package/dist/cron/reminder-context.d.ts +78 -0
  1237. package/dist/cron/reminder-context.d.ts.map +1 -0
  1238. package/dist/cron/reminder-context.js +167 -0
  1239. package/dist/cron/reminder-context.js.map +1 -0
  1240. package/dist/cron/run-log.d.ts +48 -0
  1241. package/dist/cron/run-log.d.ts.map +1 -0
  1242. package/dist/cron/run-log.js +225 -0
  1243. package/dist/cron/run-log.js.map +1 -0
  1244. package/dist/cron/schedule.d.ts +46 -0
  1245. package/dist/cron/schedule.d.ts.map +1 -0
  1246. package/dist/cron/schedule.js +144 -0
  1247. package/dist/cron/schedule.js.map +1 -0
  1248. package/dist/cron/service/jobs.d.ts +138 -0
  1249. package/dist/cron/service/jobs.d.ts.map +1 -0
  1250. package/dist/cron/service/jobs.js +370 -0
  1251. package/dist/cron/service/jobs.js.map +1 -0
  1252. package/dist/cron/service/locked.d.ts +46 -0
  1253. package/dist/cron/service/locked.d.ts.map +1 -0
  1254. package/dist/cron/service/locked.js +54 -0
  1255. package/dist/cron/service/locked.js.map +1 -0
  1256. package/dist/cron/service/ops.d.ts +124 -0
  1257. package/dist/cron/service/ops.d.ts.map +1 -0
  1258. package/dist/cron/service/ops.js +415 -0
  1259. package/dist/cron/service/ops.js.map +1 -0
  1260. package/dist/cron/service/state.d.ts +254 -0
  1261. package/dist/cron/service/state.d.ts.map +1 -0
  1262. package/dist/cron/service/state.js +50 -0
  1263. package/dist/cron/service/state.js.map +1 -0
  1264. package/dist/cron/service/store.d.ts +65 -0
  1265. package/dist/cron/service/store.d.ts.map +1 -0
  1266. package/dist/cron/service/store.js +350 -0
  1267. package/dist/cron/service/store.js.map +1 -0
  1268. package/dist/cron/service/timer.d.ts +113 -0
  1269. package/dist/cron/service/timer.d.ts.map +1 -0
  1270. package/dist/cron/service/timer.js +1081 -0
  1271. package/dist/cron/service/timer.js.map +1 -0
  1272. package/dist/cron/session-reaper.d.ts +62 -0
  1273. package/dist/cron/session-reaper.d.ts.map +1 -0
  1274. package/dist/cron/session-reaper.js +152 -0
  1275. package/dist/cron/session-reaper.js.map +1 -0
  1276. package/dist/cron/session-target.d.ts +56 -0
  1277. package/dist/cron/session-target.d.ts.map +1 -0
  1278. package/dist/cron/session-target.js +96 -0
  1279. package/dist/cron/session-target.js.map +1 -0
  1280. package/dist/cron/stagger.d.ts +34 -0
  1281. package/dist/cron/stagger.d.ts.map +1 -0
  1282. package/dist/cron/stagger.js +69 -0
  1283. package/dist/cron/stagger.js.map +1 -0
  1284. package/dist/cron/types.d.ts +287 -0
  1285. package/dist/cron/types.d.ts.map +1 -0
  1286. package/dist/cron/types.js +22 -0
  1287. package/dist/cron/types.js.map +1 -0
  1288. package/dist/cron/validate-timestamp.d.ts +33 -0
  1289. package/dist/cron/validate-timestamp.d.ts.map +1 -0
  1290. package/dist/cron/validate-timestamp.js +54 -0
  1291. package/dist/cron/validate-timestamp.js.map +1 -0
  1292. package/dist/entry.d.ts +2 -0
  1293. package/dist/entry.d.ts.map +1 -0
  1294. package/dist/entry.js +57 -0
  1295. package/dist/entry.js.map +1 -0
  1296. package/dist/extension-sdk.d.ts +28 -0
  1297. package/dist/extension-sdk.d.ts.map +1 -0
  1298. package/dist/extension-sdk.js +26 -0
  1299. package/dist/extension-sdk.js.map +1 -0
  1300. package/dist/identity/device.d.ts +19 -0
  1301. package/dist/identity/device.d.ts.map +1 -0
  1302. package/dist/identity/device.js +88 -0
  1303. package/dist/identity/device.js.map +1 -0
  1304. package/dist/infra/backoff.d.ts +24 -0
  1305. package/dist/infra/backoff.d.ts.map +1 -0
  1306. package/dist/infra/backoff.js +48 -0
  1307. package/dist/infra/backoff.js.map +1 -0
  1308. package/dist/infra/errors.d.ts +35 -0
  1309. package/dist/infra/errors.d.ts.map +1 -0
  1310. package/dist/infra/errors.js +54 -0
  1311. package/dist/infra/errors.js.map +1 -0
  1312. package/dist/infra/fs/atomic-rename.d.ts +31 -0
  1313. package/dist/infra/fs/atomic-rename.d.ts.map +1 -0
  1314. package/dist/infra/fs/atomic-rename.js +75 -0
  1315. package/dist/infra/fs/atomic-rename.js.map +1 -0
  1316. package/dist/infra/json-file.d.ts +25 -0
  1317. package/dist/infra/json-file.d.ts.map +1 -0
  1318. package/dist/infra/json-file.js +49 -0
  1319. package/dist/infra/json-file.js.map +1 -0
  1320. package/dist/infra/json-utf8-bytes.d.ts +14 -0
  1321. package/dist/infra/json-utf8-bytes.d.ts.map +1 -0
  1322. package/dist/infra/json-utf8-bytes.js +20 -0
  1323. package/dist/infra/json-utf8-bytes.js.map +1 -0
  1324. package/dist/infra/net/dns-pinning.d.ts +66 -0
  1325. package/dist/infra/net/dns-pinning.d.ts.map +1 -0
  1326. package/dist/infra/net/dns-pinning.js +128 -0
  1327. package/dist/infra/net/dns-pinning.js.map +1 -0
  1328. package/dist/infra/net/fetch-guard.d.ts +85 -0
  1329. package/dist/infra/net/fetch-guard.d.ts.map +1 -0
  1330. package/dist/infra/net/fetch-guard.js +439 -0
  1331. package/dist/infra/net/fetch-guard.js.map +1 -0
  1332. package/dist/infra/prototype-keys.d.ts +19 -0
  1333. package/dist/infra/prototype-keys.d.ts.map +1 -0
  1334. package/dist/infra/prototype-keys.js +22 -0
  1335. package/dist/infra/prototype-keys.js.map +1 -0
  1336. package/dist/integrations/ollama.d.ts +67 -0
  1337. package/dist/integrations/ollama.d.ts.map +1 -0
  1338. package/dist/integrations/ollama.js +53 -0
  1339. package/dist/integrations/ollama.js.map +1 -0
  1340. package/dist/integrations/provider-discovery.d.ts +66 -0
  1341. package/dist/integrations/provider-discovery.d.ts.map +1 -0
  1342. package/dist/integrations/provider-discovery.js +166 -0
  1343. package/dist/integrations/provider-discovery.js.map +1 -0
  1344. package/dist/logging/redact.d.ts +28 -0
  1345. package/dist/logging/redact.d.ts.map +1 -0
  1346. package/dist/logging/redact.js +51 -0
  1347. package/dist/logging/redact.js.map +1 -0
  1348. package/dist/logging/subsystem-logger.d.ts +77 -0
  1349. package/dist/logging/subsystem-logger.d.ts.map +1 -0
  1350. package/dist/logging/subsystem-logger.js +577 -0
  1351. package/dist/logging/subsystem-logger.js.map +1 -0
  1352. package/dist/logging/subsystem.d.ts +13 -0
  1353. package/dist/logging/subsystem.d.ts.map +1 -0
  1354. package/dist/logging/subsystem.js +12 -0
  1355. package/dist/logging/subsystem.js.map +1 -0
  1356. package/dist/process/command-queue.d.ts +152 -0
  1357. package/dist/process/command-queue.d.ts.map +1 -0
  1358. package/dist/process/command-queue.js +420 -0
  1359. package/dist/process/command-queue.js.map +1 -0
  1360. package/dist/process/lanes.d.ts +102 -0
  1361. package/dist/process/lanes.d.ts.map +1 -0
  1362. package/dist/process/lanes.js +117 -0
  1363. package/dist/process/lanes.js.map +1 -0
  1364. package/dist/process/session-lane.d.ts +31 -0
  1365. package/dist/process/session-lane.d.ts.map +1 -0
  1366. package/dist/process/session-lane.js +45 -0
  1367. package/dist/process/session-lane.js.map +1 -0
  1368. package/dist/protocol/errors.d.ts +35 -0
  1369. package/dist/protocol/errors.d.ts.map +1 -0
  1370. package/dist/protocol/errors.js +36 -0
  1371. package/dist/protocol/errors.js.map +1 -0
  1372. package/dist/protocol/handshake.d.ts +101 -0
  1373. package/dist/protocol/handshake.d.ts.map +1 -0
  1374. package/dist/protocol/handshake.js +49 -0
  1375. package/dist/protocol/handshake.js.map +1 -0
  1376. package/dist/protocol/messages.d.ts +68 -0
  1377. package/dist/protocol/messages.d.ts.map +1 -0
  1378. package/dist/protocol/messages.js +20 -0
  1379. package/dist/protocol/messages.js.map +1 -0
  1380. package/dist/protocol/methods.d.ts +312 -0
  1381. package/dist/protocol/methods.d.ts.map +1 -0
  1382. package/dist/protocol/methods.js +16 -0
  1383. package/dist/protocol/methods.js.map +1 -0
  1384. package/dist/protocol.d.ts +598 -0
  1385. package/dist/protocol.d.ts.map +1 -0
  1386. package/dist/protocol.js +12 -0
  1387. package/dist/protocol.js.map +1 -0
  1388. package/dist/providers/auth-methods.d.ts +82 -0
  1389. package/dist/providers/auth-methods.d.ts.map +1 -0
  1390. package/dist/providers/auth-methods.js +180 -0
  1391. package/dist/providers/auth-methods.js.map +1 -0
  1392. package/dist/providers/catalog.d.ts +85 -0
  1393. package/dist/providers/catalog.d.ts.map +1 -0
  1394. package/dist/providers/catalog.js +41 -0
  1395. package/dist/providers/catalog.js.map +1 -0
  1396. package/dist/providers/validate-key.d.ts +42 -0
  1397. package/dist/providers/validate-key.d.ts.map +1 -0
  1398. package/dist/providers/validate-key.js.map +1 -0
  1399. package/dist/security/external-content.d.ts +67 -0
  1400. package/dist/security/external-content.d.ts.map +1 -0
  1401. package/dist/security/external-content.js +80 -0
  1402. package/dist/security/external-content.js.map +1 -0
  1403. package/dist/security/injection-patterns.d.ts +33 -0
  1404. package/dist/security/injection-patterns.d.ts.map +1 -0
  1405. package/dist/security/injection-patterns.js +97 -0
  1406. package/dist/security/injection-patterns.js.map +1 -0
  1407. package/dist/security/media-path-guard.d.ts +25 -0
  1408. package/dist/security/media-path-guard.d.ts.map +1 -0
  1409. package/dist/security/media-path-guard.js +98 -0
  1410. package/dist/security/media-path-guard.js.map +1 -0
  1411. package/dist/security/terminal-input-sanitizer.d.ts +30 -0
  1412. package/dist/security/terminal-input-sanitizer.d.ts.map +1 -0
  1413. package/dist/security/terminal-input-sanitizer.js +70 -0
  1414. package/dist/security/terminal-input-sanitizer.js.map +1 -0
  1415. package/dist/sessions/bootstrap-marker.d.ts +5 -0
  1416. package/dist/sessions/bootstrap-marker.d.ts.map +1 -0
  1417. package/dist/sessions/bootstrap-marker.js +120 -0
  1418. package/dist/sessions/bootstrap-marker.js.map +1 -0
  1419. package/dist/sessions/session-file-repair.d.ts +12 -0
  1420. package/dist/sessions/session-file-repair.d.ts.map +1 -0
  1421. package/dist/sessions/session-file-repair.js +155 -0
  1422. package/dist/sessions/session-file-repair.js.map +1 -0
  1423. package/dist/sessions/session-key-utils.d.ts +54 -0
  1424. package/dist/sessions/session-key-utils.d.ts.map +1 -0
  1425. package/dist/sessions/session-key-utils.js +133 -0
  1426. package/dist/sessions/session-key-utils.js.map +1 -0
  1427. package/dist/sessions/session-manager-factory.d.ts +21 -0
  1428. package/dist/sessions/session-manager-factory.d.ts.map +1 -0
  1429. package/dist/sessions/session-manager-factory.js +142 -0
  1430. package/dist/sessions/session-manager-factory.js.map +1 -0
  1431. package/dist/sessions/session-store.d.ts +154 -0
  1432. package/dist/sessions/session-store.d.ts.map +1 -0
  1433. package/dist/sessions/session-store.js +498 -0
  1434. package/dist/sessions/session-store.js.map +1 -0
  1435. package/dist/sessions/session-write-lock.d.ts +10 -0
  1436. package/dist/sessions/session-write-lock.d.ts.map +1 -0
  1437. package/dist/sessions/session-write-lock.js +167 -0
  1438. package/dist/sessions/session-write-lock.js.map +1 -0
  1439. package/dist/sessions/transcript-reader.d.ts +37 -0
  1440. package/dist/sessions/transcript-reader.d.ts.map +1 -0
  1441. package/dist/sessions/transcript-reader.js +136 -0
  1442. package/dist/sessions/transcript-reader.js.map +1 -0
  1443. package/dist/sessions/transcript-repair.d.ts +16 -0
  1444. package/dist/sessions/transcript-repair.d.ts.map +1 -0
  1445. package/dist/sessions/transcript-repair.js +214 -0
  1446. package/dist/sessions/transcript-repair.js.map +1 -0
  1447. package/dist/shared/global-singleton.d.ts +27 -0
  1448. package/dist/shared/global-singleton.d.ts.map +1 -0
  1449. package/dist/shared/global-singleton.js +35 -0
  1450. package/dist/shared/global-singleton.js.map +1 -0
  1451. package/dist/shared/string-coerce.d.ts +12 -0
  1452. package/dist/shared/string-coerce.d.ts.map +1 -0
  1453. package/dist/shared/string-coerce.js +12 -0
  1454. package/dist/shared/string-coerce.js.map +1 -0
  1455. package/dist/storage/boot.d.ts +28 -0
  1456. package/dist/storage/boot.d.ts.map +1 -0
  1457. package/dist/storage/boot.js +588 -0
  1458. package/dist/storage/boot.js.map +1 -0
  1459. package/dist/storage/config-cache.d.ts +23 -0
  1460. package/dist/storage/config-cache.d.ts.map +1 -0
  1461. package/dist/storage/config-cache.js +58 -0
  1462. package/dist/storage/config-cache.js.map +1 -0
  1463. package/dist/storage/convex/auth-store.d.ts +52 -0
  1464. package/dist/storage/convex/auth-store.d.ts.map +1 -0
  1465. package/dist/storage/convex/auth-store.js +282 -0
  1466. package/dist/storage/convex/auth-store.js.map +1 -0
  1467. package/dist/storage/convex/blob-store.d.ts +20 -0
  1468. package/dist/storage/convex/blob-store.d.ts.map +1 -0
  1469. package/dist/storage/convex/blob-store.js +74 -0
  1470. package/dist/storage/convex/blob-store.js.map +1 -0
  1471. package/dist/storage/convex/channel-store.d.ts +112 -0
  1472. package/dist/storage/convex/channel-store.d.ts.map +1 -0
  1473. package/dist/storage/convex/channel-store.js +267 -0
  1474. package/dist/storage/convex/channel-store.js.map +1 -0
  1475. package/dist/storage/convex/client.d.ts +53 -0
  1476. package/dist/storage/convex/client.d.ts.map +1 -0
  1477. package/dist/storage/convex/client.js +121 -0
  1478. package/dist/storage/convex/client.js.map +1 -0
  1479. package/dist/storage/convex/config-store.d.ts +29 -0
  1480. package/dist/storage/convex/config-store.d.ts.map +1 -0
  1481. package/dist/storage/convex/config-store.js +205 -0
  1482. package/dist/storage/convex/config-store.js.map +1 -0
  1483. package/dist/storage/convex/cron-store.d.ts +86 -0
  1484. package/dist/storage/convex/cron-store.d.ts.map +1 -0
  1485. package/dist/storage/convex/cron-store.js +428 -0
  1486. package/dist/storage/convex/cron-store.js.map +1 -0
  1487. package/dist/storage/convex/exec-approval-store.d.ts +38 -0
  1488. package/dist/storage/convex/exec-approval-store.d.ts.map +1 -0
  1489. package/dist/storage/convex/exec-approval-store.js +147 -0
  1490. package/dist/storage/convex/exec-approval-store.js.map +1 -0
  1491. package/dist/storage/convex/extension-store.d.ts +28 -0
  1492. package/dist/storage/convex/extension-store.d.ts.map +1 -0
  1493. package/dist/storage/convex/extension-store.js +39 -0
  1494. package/dist/storage/convex/extension-store.js.map +1 -0
  1495. package/dist/storage/convex/index.d.ts +35 -0
  1496. package/dist/storage/convex/index.d.ts.map +1 -0
  1497. package/dist/storage/convex/index.js +141 -0
  1498. package/dist/storage/convex/index.js.map +1 -0
  1499. package/dist/storage/convex/instance-store.d.ts +37 -0
  1500. package/dist/storage/convex/instance-store.d.ts.map +1 -0
  1501. package/dist/storage/convex/instance-store.js +88 -0
  1502. package/dist/storage/convex/instance-store.js.map +1 -0
  1503. package/dist/storage/convex/log-store.d.ts +36 -0
  1504. package/dist/storage/convex/log-store.d.ts.map +1 -0
  1505. package/dist/storage/convex/log-store.js +213 -0
  1506. package/dist/storage/convex/log-store.js.map +1 -0
  1507. package/dist/storage/convex/memory-store.d.ts +50 -0
  1508. package/dist/storage/convex/memory-store.d.ts.map +1 -0
  1509. package/dist/storage/convex/memory-store.js +537 -0
  1510. package/dist/storage/convex/memory-store.js.map +1 -0
  1511. package/dist/storage/convex/message-store.d.ts +32 -0
  1512. package/dist/storage/convex/message-store.d.ts.map +1 -0
  1513. package/dist/storage/convex/message-store.js +272 -0
  1514. package/dist/storage/convex/message-store.js.map +1 -0
  1515. package/dist/storage/convex/org-store.d.ts +46 -0
  1516. package/dist/storage/convex/org-store.d.ts.map +1 -0
  1517. package/dist/storage/convex/org-store.js +101 -0
  1518. package/dist/storage/convex/org-store.js.map +1 -0
  1519. package/dist/storage/convex/session-store.d.ts +44 -0
  1520. package/dist/storage/convex/session-store.d.ts.map +1 -0
  1521. package/dist/storage/convex/session-store.js +257 -0
  1522. package/dist/storage/convex/session-store.js.map +1 -0
  1523. package/dist/storage/convex/skill-store.d.ts +49 -0
  1524. package/dist/storage/convex/skill-store.d.ts.map +1 -0
  1525. package/dist/storage/convex/skill-store.js +84 -0
  1526. package/dist/storage/convex/skill-store.js.map +1 -0
  1527. package/dist/storage/convex/subagent-store.d.ts +28 -0
  1528. package/dist/storage/convex/subagent-store.d.ts.map +1 -0
  1529. package/dist/storage/convex/subagent-store.js +83 -0
  1530. package/dist/storage/convex/subagent-store.js.map +1 -0
  1531. package/dist/storage/convex/workspace-store.d.ts +25 -0
  1532. package/dist/storage/convex/workspace-store.d.ts.map +1 -0
  1533. package/dist/storage/convex/workspace-store.js +127 -0
  1534. package/dist/storage/convex/workspace-store.js.map +1 -0
  1535. package/dist/storage/cron-cache.d.ts +17 -0
  1536. package/dist/storage/cron-cache.d.ts.map +1 -0
  1537. package/dist/storage/cron-cache.js +67 -0
  1538. package/dist/storage/cron-cache.js.map +1 -0
  1539. package/dist/storage/encryption.d.ts +69 -0
  1540. package/dist/storage/encryption.d.ts.map +1 -0
  1541. package/dist/storage/encryption.js +389 -0
  1542. package/dist/storage/encryption.js.map +1 -0
  1543. package/dist/storage/factory-reset.d.ts +7 -0
  1544. package/dist/storage/factory-reset.d.ts.map +1 -0
  1545. package/dist/storage/factory-reset.js +34 -0
  1546. package/dist/storage/factory-reset.js.map +1 -0
  1547. package/dist/storage/facts-cache.d.ts +24 -0
  1548. package/dist/storage/facts-cache.d.ts.map +1 -0
  1549. package/dist/storage/facts-cache.js +110 -0
  1550. package/dist/storage/facts-cache.js.map +1 -0
  1551. package/dist/storage/flush.d.ts +4 -0
  1552. package/dist/storage/flush.d.ts.map +1 -0
  1553. package/dist/storage/flush.js +128 -0
  1554. package/dist/storage/flush.js.map +1 -0
  1555. package/dist/storage/instance-admin.d.ts +52 -0
  1556. package/dist/storage/instance-admin.d.ts.map +1 -0
  1557. package/dist/storage/instance-admin.js +91 -0
  1558. package/dist/storage/instance-admin.js.map +1 -0
  1559. package/dist/storage/local/auth-store.d.ts +44 -0
  1560. package/dist/storage/local/auth-store.d.ts.map +1 -0
  1561. package/dist/storage/local/auth-store.js +252 -0
  1562. package/dist/storage/local/auth-store.js.map +1 -0
  1563. package/dist/storage/local/blob-store.d.ts +14 -0
  1564. package/dist/storage/local/blob-store.d.ts.map +1 -0
  1565. package/dist/storage/local/blob-store.js +87 -0
  1566. package/dist/storage/local/blob-store.js.map +1 -0
  1567. package/dist/storage/local/channel-store.d.ts +107 -0
  1568. package/dist/storage/local/channel-store.d.ts.map +1 -0
  1569. package/dist/storage/local/channel-store.js +147 -0
  1570. package/dist/storage/local/channel-store.js.map +1 -0
  1571. package/dist/storage/local/config-store.d.ts +23 -0
  1572. package/dist/storage/local/config-store.d.ts.map +1 -0
  1573. package/dist/storage/local/config-store.js +98 -0
  1574. package/dist/storage/local/config-store.js.map +1 -0
  1575. package/dist/storage/local/cron-store.d.ts +30 -0
  1576. package/dist/storage/local/cron-store.d.ts.map +1 -0
  1577. package/dist/storage/local/cron-store.js +186 -0
  1578. package/dist/storage/local/cron-store.js.map +1 -0
  1579. package/dist/storage/local/exec-approval-store.d.ts +41 -0
  1580. package/dist/storage/local/exec-approval-store.d.ts.map +1 -0
  1581. package/dist/storage/local/exec-approval-store.js +78 -0
  1582. package/dist/storage/local/exec-approval-store.js.map +1 -0
  1583. package/dist/storage/local/extension-store.d.ts +13 -0
  1584. package/dist/storage/local/extension-store.d.ts.map +1 -0
  1585. package/dist/storage/local/extension-store.js +36 -0
  1586. package/dist/storage/local/extension-store.js.map +1 -0
  1587. package/dist/storage/local/file-watcher.d.ts +24 -0
  1588. package/dist/storage/local/file-watcher.d.ts.map +1 -0
  1589. package/dist/storage/local/file-watcher.js +141 -0
  1590. package/dist/storage/local/file-watcher.js.map +1 -0
  1591. package/dist/storage/local/index.d.ts +33 -0
  1592. package/dist/storage/local/index.d.ts.map +1 -0
  1593. package/dist/storage/local/index.js +143 -0
  1594. package/dist/storage/local/index.js.map +1 -0
  1595. package/dist/storage/local/instance-store.d.ts +30 -0
  1596. package/dist/storage/local/instance-store.d.ts.map +1 -0
  1597. package/dist/storage/local/instance-store.js +83 -0
  1598. package/dist/storage/local/instance-store.js.map +1 -0
  1599. package/dist/storage/local/log-store.d.ts +27 -0
  1600. package/dist/storage/local/log-store.d.ts.map +1 -0
  1601. package/dist/storage/local/log-store.js +185 -0
  1602. package/dist/storage/local/log-store.js.map +1 -0
  1603. package/dist/storage/local/memory-store.d.ts +39 -0
  1604. package/dist/storage/local/memory-store.d.ts.map +1 -0
  1605. package/dist/storage/local/memory-store.js +258 -0
  1606. package/dist/storage/local/memory-store.js.map +1 -0
  1607. package/dist/storage/local/message-store.d.ts +27 -0
  1608. package/dist/storage/local/message-store.d.ts.map +1 -0
  1609. package/dist/storage/local/message-store.js +253 -0
  1610. package/dist/storage/local/message-store.js.map +1 -0
  1611. package/dist/storage/local/org-store.d.ts +39 -0
  1612. package/dist/storage/local/org-store.d.ts.map +1 -0
  1613. package/dist/storage/local/org-store.js +155 -0
  1614. package/dist/storage/local/org-store.js.map +1 -0
  1615. package/dist/storage/local/session-store.d.ts +30 -0
  1616. package/dist/storage/local/session-store.d.ts.map +1 -0
  1617. package/dist/storage/local/session-store.js +82 -0
  1618. package/dist/storage/local/session-store.js.map +1 -0
  1619. package/dist/storage/local/skill-store.d.ts +40 -0
  1620. package/dist/storage/local/skill-store.d.ts.map +1 -0
  1621. package/dist/storage/local/skill-store.js +121 -0
  1622. package/dist/storage/local/skill-store.js.map +1 -0
  1623. package/dist/storage/local/subagent-store.d.ts +20 -0
  1624. package/dist/storage/local/subagent-store.d.ts.map +1 -0
  1625. package/dist/storage/local/subagent-store.js +71 -0
  1626. package/dist/storage/local/subagent-store.js.map +1 -0
  1627. package/dist/storage/local/workspace-store.d.ts +22 -0
  1628. package/dist/storage/local/workspace-store.d.ts.map +1 -0
  1629. package/dist/storage/local/workspace-store.js +190 -0
  1630. package/dist/storage/local/workspace-store.js.map +1 -0
  1631. package/dist/storage/migrate.d.ts +64 -0
  1632. package/dist/storage/migrate.d.ts.map +1 -0
  1633. package/dist/storage/migrate.js +585 -0
  1634. package/dist/storage/migrate.js.map +1 -0
  1635. package/dist/storage/runtime-context.d.ts +35 -0
  1636. package/dist/storage/runtime-context.d.ts.map +1 -0
  1637. package/dist/storage/runtime-context.js +145 -0
  1638. package/dist/storage/runtime-context.js.map +1 -0
  1639. package/dist/storage/sentinel.d.ts +28 -0
  1640. package/dist/storage/sentinel.d.ts.map +1 -0
  1641. package/dist/storage/sentinel.js +98 -0
  1642. package/dist/storage/sentinel.js.map +1 -0
  1643. package/dist/storage/session-cache.d.ts +15 -0
  1644. package/dist/storage/session-cache.d.ts.map +1 -0
  1645. package/dist/storage/session-cache.js +81 -0
  1646. package/dist/storage/session-cache.js.map +1 -0
  1647. package/dist/storage/store.d.ts +745 -0
  1648. package/dist/storage/store.d.ts.map +1 -0
  1649. package/dist/storage/store.js +36 -0
  1650. package/dist/storage/store.js.map +1 -0
  1651. package/dist/storage/strict-guard.d.ts +17 -0
  1652. package/dist/storage/strict-guard.d.ts.map +1 -0
  1653. package/dist/storage/strict-guard.js +200 -0
  1654. package/dist/storage/strict-guard.js.map +1 -0
  1655. package/dist/storage/workspace-live-mirror.d.ts +33 -0
  1656. package/dist/storage/workspace-live-mirror.d.ts.map +1 -0
  1657. package/dist/storage/workspace-live-mirror.js +207 -0
  1658. package/dist/storage/workspace-live-mirror.js.map +1 -0
  1659. package/dist/system-prompt/assembler.d.ts +113 -0
  1660. package/dist/system-prompt/assembler.d.ts.map +1 -0
  1661. package/dist/system-prompt/assembler.js +649 -0
  1662. package/dist/system-prompt/assembler.js.map +1 -0
  1663. package/dist/system-prompt/bootstrap-budget.d.ts +22 -0
  1664. package/dist/system-prompt/bootstrap-budget.d.ts.map +1 -0
  1665. package/dist/system-prompt/bootstrap-budget.js +83 -0
  1666. package/dist/system-prompt/bootstrap-budget.js.map +1 -0
  1667. package/dist/system-prompt/cache-boundary.d.ts +13 -0
  1668. package/dist/system-prompt/cache-boundary.d.ts.map +1 -0
  1669. package/dist/system-prompt/cache-boundary.js +56 -0
  1670. package/dist/system-prompt/cache-boundary.js.map +1 -0
  1671. package/dist/system-prompt/cache-stability.d.ts +3 -0
  1672. package/dist/system-prompt/cache-stability.d.ts.map +1 -0
  1673. package/dist/system-prompt/cache-stability.js +18 -0
  1674. package/dist/system-prompt/cache-stability.js.map +1 -0
  1675. package/dist/system-prompt/guidance.d.ts +147 -0
  1676. package/dist/system-prompt/guidance.d.ts.map +1 -0
  1677. package/dist/system-prompt/guidance.js +352 -0
  1678. package/dist/system-prompt/guidance.js.map +1 -0
  1679. package/dist/system-prompt/identity-defaults.d.ts +50 -0
  1680. package/dist/system-prompt/identity-defaults.d.ts.map +1 -0
  1681. package/dist/system-prompt/identity-defaults.js +119 -0
  1682. package/dist/system-prompt/identity-defaults.js.map +1 -0
  1683. package/dist/system-prompt/org/escalation-inbox.d.ts +53 -0
  1684. package/dist/system-prompt/org/escalation-inbox.d.ts.map +1 -0
  1685. package/dist/system-prompt/org/escalation-inbox.js +71 -0
  1686. package/dist/system-prompt/org/escalation-inbox.js.map +1 -0
  1687. package/dist/system-prompt/org/receiver-hint.d.ts +72 -0
  1688. package/dist/system-prompt/org/receiver-hint.d.ts.map +1 -0
  1689. package/dist/system-prompt/org/receiver-hint.js +116 -0
  1690. package/dist/system-prompt/org/receiver-hint.js.map +1 -0
  1691. package/dist/system-prompt/org/render-org-block.d.ts +42 -0
  1692. package/dist/system-prompt/org/render-org-block.d.ts.map +1 -0
  1693. package/dist/system-prompt/org/render-org-block.js +57 -0
  1694. package/dist/system-prompt/org/render-org-block.js.map +1 -0
  1695. package/dist/system-prompt/org/sub-agent-anchor.d.ts +30 -0
  1696. package/dist/system-prompt/org/sub-agent-anchor.d.ts.map +1 -0
  1697. package/dist/system-prompt/org/sub-agent-anchor.js +36 -0
  1698. package/dist/system-prompt/org/sub-agent-anchor.js.map +1 -0
  1699. package/dist/system-prompt/override.d.ts +7 -0
  1700. package/dist/system-prompt/override.d.ts.map +1 -0
  1701. package/dist/system-prompt/override.js +13 -0
  1702. package/dist/system-prompt/override.js.map +1 -0
  1703. package/dist/system-prompt/pi-injection.d.ts +5 -0
  1704. package/dist/system-prompt/pi-injection.d.ts.map +1 -0
  1705. package/dist/system-prompt/pi-injection.js +33 -0
  1706. package/dist/system-prompt/pi-injection.js.map +1 -0
  1707. package/dist/system-prompt/runtime-params.d.ts +34 -0
  1708. package/dist/system-prompt/runtime-params.d.ts.map +1 -0
  1709. package/dist/system-prompt/runtime-params.js +108 -0
  1710. package/dist/system-prompt/runtime-params.js.map +1 -0
  1711. package/dist/system-prompt/sanitize.d.ts +7 -0
  1712. package/dist/system-prompt/sanitize.d.ts.map +1 -0
  1713. package/dist/system-prompt/sanitize.js +31 -0
  1714. package/dist/system-prompt/sanitize.js.map +1 -0
  1715. package/dist/system-prompt/types.d.ts +7 -0
  1716. package/dist/system-prompt/types.d.ts.map +1 -0
  1717. package/dist/system-prompt/types.js +3 -0
  1718. package/dist/system-prompt/types.js.map +1 -0
  1719. package/dist/system-prompt/workspace-loader.d.ts +12 -0
  1720. package/dist/system-prompt/workspace-loader.d.ts.map +1 -0
  1721. package/dist/system-prompt/workspace-loader.js +115 -0
  1722. package/dist/system-prompt/workspace-loader.js.map +1 -0
  1723. package/dist/tideline/advanced.d.ts +25 -0
  1724. package/dist/tideline/advanced.d.ts.map +1 -0
  1725. package/dist/tideline/advanced.js +34 -0
  1726. package/dist/tideline/advanced.js.map +1 -0
  1727. package/dist/tideline/eval.d.ts +19 -0
  1728. package/dist/tideline/eval.d.ts.map +1 -0
  1729. package/dist/tideline/eval.js +24 -0
  1730. package/dist/tideline/eval.js.map +1 -0
  1731. package/dist/tideline/host-ports.standalone.d.ts +49 -0
  1732. package/dist/tideline/host-ports.standalone.d.ts.map +1 -0
  1733. package/dist/tideline/host-ports.standalone.js +61 -0
  1734. package/dist/tideline/host-ports.standalone.js.map +1 -0
  1735. package/dist/tideline/index.d.ts +34 -0
  1736. package/dist/tideline/index.d.ts.map +1 -0
  1737. package/dist/tideline/index.js +42 -0
  1738. package/dist/tideline/index.js.map +1 -0
  1739. package/dist/tui/approval-prompt.d.ts +73 -0
  1740. package/dist/tui/approval-prompt.d.ts.map +1 -0
  1741. package/dist/tui/approval-prompt.js +272 -0
  1742. package/dist/tui/approval-prompt.js.map +1 -0
  1743. package/dist/tui/client.d.ts +89 -0
  1744. package/dist/tui/client.d.ts.map +1 -0
  1745. package/dist/tui/client.js.map +1 -0
  1746. package/dist/ui/brand-frames-cli.d.ts +19 -0
  1747. package/dist/ui/brand-frames-cli.d.ts.map +1 -0
  1748. package/dist/ui/brand-frames-cli.js +8 -13
  1749. package/dist/ui/brand-frames-cli.js.map +1 -0
  1750. package/dist/ui/brand.d.ts +41 -0
  1751. package/dist/ui/brand.d.ts.map +1 -0
  1752. package/dist/ui/brand.js +28 -6
  1753. package/dist/ui/brand.js.map +1 -0
  1754. package/dist/ui/editor.d.ts +30 -0
  1755. package/dist/ui/editor.d.ts.map +1 -0
  1756. package/dist/ui/editor.js +73 -0
  1757. package/dist/ui/editor.js.map +1 -0
  1758. package/dist/ui/format-session.d.ts +68 -0
  1759. package/dist/ui/format-session.d.ts.map +1 -0
  1760. package/dist/ui/format-session.js +181 -0
  1761. package/dist/ui/format-session.js.map +1 -0
  1762. package/dist/ui/markdown.d.ts +48 -0
  1763. package/dist/ui/markdown.d.ts.map +1 -0
  1764. package/dist/ui/markdown.js +60 -0
  1765. package/dist/ui/markdown.js.map +1 -0
  1766. package/dist/ui/onboard-storage-mode.d.ts +17 -0
  1767. package/dist/ui/onboard-storage-mode.d.ts.map +1 -0
  1768. package/dist/ui/onboard-storage-mode.js +638 -0
  1769. package/dist/ui/onboard-storage-mode.js.map +1 -0
  1770. package/dist/ui/onboarding.d.ts +97 -0
  1771. package/dist/ui/onboarding.d.ts.map +1 -0
  1772. package/dist/ui/onboarding.js +259 -111
  1773. package/dist/ui/onboarding.js.map +1 -0
  1774. package/dist/ui/searchable-select.d.ts +48 -0
  1775. package/dist/ui/searchable-select.d.ts.map +1 -0
  1776. package/dist/ui/searchable-select.js +108 -0
  1777. package/dist/ui/searchable-select.js.map +1 -0
  1778. package/dist/ui/syntax-theme.d.ts +30 -0
  1779. package/dist/ui/syntax-theme.d.ts.map +1 -0
  1780. package/dist/ui/syntax-theme.js +72 -0
  1781. package/dist/ui/syntax-theme.js.map +1 -0
  1782. package/dist/ui/terminal-cleanup.d.ts +46 -0
  1783. package/dist/ui/terminal-cleanup.d.ts.map +1 -0
  1784. package/dist/ui/terminal-cleanup.js +17 -5
  1785. package/dist/ui/terminal-cleanup.js.map +1 -0
  1786. package/dist/ui/theme.d.ts +21 -0
  1787. package/dist/ui/theme.d.ts.map +1 -0
  1788. package/dist/ui/theme.js +66 -2
  1789. package/dist/ui/theme.js.map +1 -0
  1790. package/dist/ui/tool-result.d.ts +47 -0
  1791. package/dist/ui/tool-result.d.ts.map +1 -0
  1792. package/dist/ui/tool-result.js +100 -0
  1793. package/dist/ui/tool-result.js.map +1 -0
  1794. package/dist/utils/delivery-context.d.ts +50 -0
  1795. package/dist/utils/delivery-context.d.ts.map +1 -0
  1796. package/dist/utils/delivery-context.js +82 -0
  1797. package/dist/utils/delivery-context.js.map +1 -0
  1798. package/dist/utils/message-channel.d.ts +60 -0
  1799. package/dist/utils/message-channel.d.ts.map +1 -0
  1800. package/dist/utils/message-channel.js +103 -0
  1801. package/dist/utils/message-channel.js.map +1 -0
  1802. package/dist/utils/string-coerce.d.ts +50 -0
  1803. package/dist/utils/string-coerce.d.ts.map +1 -0
  1804. package/dist/utils/string-coerce.js +101 -0
  1805. package/dist/utils/string-coerce.js.map +1 -0
  1806. package/dist/version.d.ts +20 -0
  1807. package/dist/version.d.ts.map +1 -0
  1808. package/dist/version.js +54 -0
  1809. package/dist/version.js.map +1 -0
  1810. package/dist/workspace/bootstrap.d.ts +12 -0
  1811. package/dist/workspace/bootstrap.d.ts.map +1 -0
  1812. package/dist/workspace/bootstrap.js +123 -0
  1813. package/dist/workspace/bootstrap.js.map +1 -0
  1814. package/dist/workspace/fs-utils.d.ts +2 -0
  1815. package/dist/workspace/fs-utils.d.ts.map +1 -0
  1816. package/dist/workspace/fs-utils.js +14 -0
  1817. package/dist/workspace/fs-utils.js.map +1 -0
  1818. package/dist/workspace/git-init.d.ts +5 -0
  1819. package/dist/workspace/git-init.d.ts.map +1 -0
  1820. package/dist/workspace/git-init.js +71 -0
  1821. package/dist/workspace/git-init.js.map +1 -0
  1822. package/dist/workspace/state.d.ts +13 -0
  1823. package/dist/workspace/state.d.ts.map +1 -0
  1824. package/dist/workspace/state.js +128 -0
  1825. package/dist/workspace/state.js.map +1 -0
  1826. package/dist/workspace/template-loader.d.ts +15 -0
  1827. package/dist/workspace/template-loader.d.ts.map +1 -0
  1828. package/dist/workspace/template-loader.js +214 -0
  1829. package/dist/workspace/template-loader.js.map +1 -0
  1830. package/package.json +173 -68
  1831. package/scripts/build-done.mjs +125 -0
  1832. package/scripts/run-brigade.mjs +208 -0
  1833. package/skills/1password/SKILL.md +70 -0
  1834. package/skills/1password/references/cli-examples.md +29 -0
  1835. package/skills/1password/references/get-started.md +17 -0
  1836. package/skills/apple-notes/SKILL.md +77 -0
  1837. package/skills/apple-reminders/SKILL.md +118 -0
  1838. package/skills/bear-notes/SKILL.md +107 -0
  1839. package/skills/blogwatcher/SKILL.md +69 -0
  1840. package/skills/blucli/SKILL.md +47 -0
  1841. package/skills/bluebubbles/SKILL.md +136 -0
  1842. package/skills/camsnap/SKILL.md +45 -0
  1843. package/skills/canvas/SKILL.md +204 -0
  1844. package/skills/coding-agent/SKILL.md +316 -0
  1845. package/skills/discord/SKILL.md +197 -0
  1846. package/skills/eightctl/SKILL.md +50 -0
  1847. package/skills/gemini/SKILL.md +43 -0
  1848. package/skills/gh-issues/SKILL.md +885 -0
  1849. package/skills/gifgrep/SKILL.md +79 -0
  1850. package/skills/git-commit/SKILL.md +40 -0
  1851. package/skills/github/SKILL.md +163 -0
  1852. package/skills/gog/SKILL.md +116 -0
  1853. package/skills/goplaces/SKILL.md +52 -0
  1854. package/skills/healthcheck/SKILL.md +245 -0
  1855. package/skills/himalaya/SKILL.md +257 -0
  1856. package/skills/himalaya/references/configuration.md +184 -0
  1857. package/skills/himalaya/references/message-composition.md +199 -0
  1858. package/skills/imsg/SKILL.md +122 -0
  1859. package/skills/lead-scout/SKILL.md +46 -0
  1860. package/skills/mcporter/SKILL.md +61 -0
  1861. package/skills/model-usage/SKILL.md +69 -0
  1862. package/skills/nano-pdf/SKILL.md +38 -0
  1863. package/skills/node-connect/SKILL.md +142 -0
  1864. package/skills/notion/SKILL.md +174 -0
  1865. package/skills/oauth-setup/SKILL.md +55 -0
  1866. package/skills/obsidian/SKILL.md +81 -0
  1867. package/skills/openai-whisper/SKILL.md +38 -0
  1868. package/skills/openai-whisper-api/SKILL.md +62 -0
  1869. package/skills/openai-whisper-api/scripts/transcribe.sh +88 -0
  1870. package/skills/openhue/SKILL.md +112 -0
  1871. package/skills/oracle/SKILL.md +125 -0
  1872. package/skills/ordercli/SKILL.md +78 -0
  1873. package/skills/peekaboo/SKILL.md +190 -0
  1874. package/skills/sag/SKILL.md +87 -0
  1875. package/skills/session-logs/SKILL.md +151 -0
  1876. package/skills/share-skills/SKILL.md +72 -0
  1877. package/skills/sherpa-onnx-tts/SKILL.md +109 -0
  1878. package/skills/sherpa-onnx-tts/bin/sherpa-onnx-tts +178 -0
  1879. package/skills/skill-creator/SKILL.md +372 -0
  1880. package/skills/skill-creator/license.txt +202 -0
  1881. package/skills/skill-creator/scripts/init_skill.py +378 -0
  1882. package/skills/skill-creator/scripts/package_skill.py +139 -0
  1883. package/skills/skill-creator/scripts/quick_validate.py +159 -0
  1884. package/skills/skill-creator/scripts/test_package_skill.py +160 -0
  1885. package/skills/skill-creator/scripts/test_quick_validate.py +72 -0
  1886. package/skills/slack/SKILL.md +144 -0
  1887. package/skills/songsee/SKILL.md +49 -0
  1888. package/skills/sonoscli/SKILL.md +65 -0
  1889. package/skills/spotify-player/SKILL.md +64 -0
  1890. package/skills/summarize/SKILL.md +87 -0
  1891. package/skills/taskflow/SKILL.md +149 -0
  1892. package/skills/taskflow-inbox-triage/SKILL.md +119 -0
  1893. package/skills/things-mac/SKILL.md +86 -0
  1894. package/skills/tmux/SKILL.md +170 -0
  1895. package/skills/tmux/scripts/find-sessions.sh +112 -0
  1896. package/skills/tmux/scripts/wait-for-text.sh +83 -0
  1897. package/skills/trello/SKILL.md +108 -0
  1898. package/skills/video-frames/SKILL.md +46 -0
  1899. package/skills/video-frames/scripts/frame.sh +81 -0
  1900. package/skills/voice-call/SKILL.md +45 -0
  1901. package/skills/wacli/SKILL.md +72 -0
  1902. package/skills/weather/SKILL.md +129 -0
  1903. package/skills/xurl/SKILL.md +461 -0
  1904. package/templates/workspace/AGENTS.md +223 -0
  1905. package/templates/workspace/BOOTSTRAP.md +64 -0
  1906. package/templates/workspace/HEARTBEAT.md +15 -0
  1907. package/templates/workspace/IDENTITY.md +31 -0
  1908. package/templates/workspace/SOUL.md +47 -0
  1909. package/templates/workspace/TOOLS.md +48 -0
  1910. package/templates/workspace/USER.md +25 -0
  1911. package/CHANGELOG.md +0 -48
  1912. package/SECURITY.md +0 -208
  1913. package/assets/brigade-wordmark.png +0 -0
  1914. package/dist/cli/chat-cmd.js +0 -191
  1915. package/dist/cli/config-cmd.js +0 -171
  1916. package/dist/cli/connect-cmd.js +0 -487
  1917. package/dist/cli/doctor-cmd.js +0 -387
  1918. package/dist/cli/gateway-cmd.js +0 -155
  1919. package/dist/cli.js +0 -328
  1920. package/dist/core/agent.js +0 -1123
  1921. package/dist/core/auth-label.js +0 -147
  1922. package/dist/core/cli-error.js +0 -94
  1923. package/dist/core/error-classifier.js +0 -354
  1924. package/dist/core/provider-payload-mutators.js +0 -517
  1925. package/dist/core/provider-quirks.js +0 -285
  1926. package/dist/core/smart-compaction.js +0 -209
  1927. package/dist/core/system-prompt-defaults.js +0 -264
  1928. package/dist/core/system-prompt-guidance.js +0 -271
  1929. package/dist/index.js +0 -32
  1930. package/dist/ui/brand-frames.js +0 -36
  1931. package/dist/ui/chat.js +0 -1008
@@ -0,0 +1,1952 @@
1
+ /**
2
+ * `brigade connect` — TUI that talks to a running `brigade gateway`.
3
+ *
4
+ * This is the thin client. The gateway owns the Pi session, runs the full
5
+ * 6-layer wrapper composition, and broadcasts every Pi event back to us.
6
+ * Our job is only to render and to forward the user's input as typed
7
+ * requests over the WebSocket.
8
+ *
9
+ * Feature parity with `brigade chat` for the common path (send a message,
10
+ * stream the reply, see tool calls, abort with Ctrl+C, switch model, set
11
+ * thinking level, compact, exit). Inline `/provider` onboarding is NOT
12
+ * available from connect mode in v1 — onboarding writes to the gateway's
13
+ * filesystem and is out-of-band; the user runs `brigade onboard` against
14
+ * the gateway machine instead.
15
+ *
16
+ * MAINTAINER NOTE: The footer at `wireConnectUi` deliberately OMITS
17
+ * `/provider` from the slash-command list. Do NOT add it to the connect
18
+ * footer "for parity with chat" — connect cannot perform provider
19
+ * onboarding (no gateway-side filesystem access from the TUI client), and
20
+ * advertising a command we can't honour confuses users. The chat-mode
21
+ * footer (in `src/ui/chat.ts`) DOES list `/provider` because in-process
22
+ * chat owns the filesystem the wizard needs to write to.
23
+ */
24
+ import process from "node:process";
25
+ import { CancellableLoader, CombinedAutocompleteProvider, ProcessTerminal, Text, TUI, } from "@mariozechner/pi-tui";
26
+ import { BrigadeEditor } from "../../ui/editor.js";
27
+ import { sanitizeTerminalInput } from "../../security/terminal-input-sanitizer.js";
28
+ import chalk from "chalk";
29
+ // Brigade's `Markdown` is a thin Pi-TUI subclass that normalizes `_text_`
30
+ // italic spans to `*text*` so the renderer applies italic styling instead
31
+ // of leaking literal underscores. Same shape as Pi-TUI's `Markdown` — drop-in.
32
+ import { Markdown } from "../../ui/markdown.js";
33
+ import { renderBrandHeader } from "../../ui/brand.js";
34
+ import { formatCrewLabel, formatSessionLabel } from "../../ui/format-session.js";
35
+ import { markTuiActive, restoreTerminal } from "../../ui/terminal-cleanup.js";
36
+ import { brand, editorTheme, markdownTheme } from "../../ui/theme.js";
37
+ import { summarizeToolResult } from "../../ui/tool-result.js";
38
+ import { BrigadeClient } from "../../tui/client.js";
39
+ import { ApprovalPrompt } from "../../tui/approval-prompt.js";
40
+ import { computeExplain, filterGraphToSubtree, formatExplain, parseOrgSlash, renderDepartmentsOnly, } from "./org-slash.js";
41
+ import { renderPrideChartWithPins, BRIGADE_FOOTER_RULE, } from "../../agents/org/pride-template.js";
42
+ // Commander wrapper — `brigade connect` is the thin TUI client that
43
+ // connects to a running gateway. Same single-touch pattern the TUI /
44
+ // gateway commands use.
45
+ export function registerConnectCommand(program) {
46
+ program
47
+ .command("connect")
48
+ .description("Connect to a running Brigade gateway from a thin TUI client")
49
+ .option("-h, --host <host>", "gateway host (default: 127.0.0.1)")
50
+ .option("-p, --port <port>", "gateway port", (v) => parseInt(v, 10))
51
+ .option("--timeout <ms>", "request timeout in ms", (v) => parseInt(v, 10))
52
+ .action(async (opts) => {
53
+ await runConnectCommand({
54
+ host: opts.host,
55
+ port: opts.port,
56
+ requestTimeoutMs: opts.timeout,
57
+ });
58
+ await new Promise(() => { });
59
+ });
60
+ }
61
+ /**
62
+ * Should a `state` snapshot's `sessionKey` seed the connection-bound session?
63
+ *
64
+ * Yes when unbound (normal first-snapshot seed) or when the snapshot is for
65
+ * the SAME agent we're bound to. No when bound to a DIFFERENT agent than the
66
+ * snapshot — that's the `--agent X` cross-agent-session bug: the gateway's
67
+ * boot snapshot (agent `main`, session `agent:main:main`) must NOT seed the
68
+ * session for a connection bound to `marketing-lead`, or `withBinding` emits
69
+ * the incoherent pair `{agentId: marketing-lead, sessionKey: agent:main:main}`
70
+ * and the reply gets filtered to the wrong lane. Exported for regression
71
+ * testing of that exact decision.
72
+ */
73
+ export function snapshotSessionSeedable(boundAgentId, snapAgentId) {
74
+ if (boundAgentId === undefined)
75
+ return true;
76
+ return typeof snapAgentId === "string" && snapAgentId === boundAgentId;
77
+ }
78
+ /**
79
+ * Boot the connect TUI. Establishes the WebSocket connection FIRST so the
80
+ * user gets a clear "couldn't reach gateway" error instead of a blank chat.
81
+ */
82
+ export async function runConnectCommand(opts = {}) {
83
+ // Connect runs a TUI client (raw mode, alt-screen, kitty keys) — opt into
84
+ // the on-exit terminal cleanup. Non-TUI commands skip this and exit silently.
85
+ markTuiActive();
86
+ const host = opts.host ?? "127.0.0.1";
87
+ const port = opts.port ?? 7777;
88
+ const url = `ws://${host}:${port}`;
89
+ const tui = new TUI(new ProcessTerminal());
90
+ tui.start();
91
+ // Wire SIGINT BEFORE the connect attempt so Ctrl+C during a slow connect
92
+ // exits cleanly instead of hanging on the open promise. Re-arm via
93
+ // process.once after each turn-abort so handlers never stack across
94
+ // re-invocations within the same process.
95
+ let chatHandle = null;
96
+ const onSigint = () => {
97
+ if (chatHandle) {
98
+ const wasRunning = chatHandle.abort();
99
+ if (!wasRunning) {
100
+ void chatHandle.close().then(() => {
101
+ tui.stop();
102
+ // tui.stop() already runs Pi-TUI's cleanup (kitty pop on
103
+ // the happy path); restoreTerminal() is the broader safety
104
+ // net (focus, mouse, alt-screen, modifyOtherKeys) plus an
105
+ // unconditional kitty pop in case Pi-TUI's flag tracker
106
+ // missed it.
107
+ restoreTerminal();
108
+ process.exit(0);
109
+ });
110
+ return;
111
+ }
112
+ process.once("SIGINT", onSigint); // re-arm for the next Ctrl+C
113
+ return;
114
+ }
115
+ tui.stop();
116
+ restoreTerminal();
117
+ process.exit(130);
118
+ };
119
+ process.once("SIGINT", onSigint);
120
+ const client = new BrigadeClient({
121
+ url,
122
+ requestTimeoutMs: opts.requestTimeoutMs ?? 60_000,
123
+ });
124
+ try {
125
+ await client.connect();
126
+ }
127
+ catch (err) {
128
+ tui.stop();
129
+ restoreTerminal();
130
+ const msg = err instanceof Error ? err.message : String(err);
131
+ const isRefused = /ECONNREFUSED|connect.*refused/i.test(msg);
132
+ const isTimeout = /ETIMEDOUT|timed?\s*out/i.test(msg);
133
+ const isUnknownHost = /ENOTFOUND|EAI_AGAIN|getaddrinfo|temporary failure in name resolution/i.test(msg);
134
+ const isUnreachable = /EHOSTUNREACH|ENETUNREACH|network is unreachable|no route to host/i.test(msg);
135
+ // Headline: don't interpolate the raw `msg` (it can carry ENOTFOUND-style
136
+ // internal codes and getaddrinfo jargon). Just say what we tried.
137
+ console.error(chalk.red(`✗ Couldn't reach the Brigade gateway at ${url}.`));
138
+ // Differentiate the most common failure modes so users don't waste
139
+ // time debugging the wrong cause.
140
+ if (isRefused) {
141
+ console.error(chalk.dim(` Likely cause: no gateway is running on port ${port}.`));
142
+ console.error(chalk.dim(` Either start one: brigade gateway --port ${port}`));
143
+ console.error(chalk.dim(` Or, if it's on another port: brigade connect --port <that-port>`));
144
+ }
145
+ else if (isTimeout) {
146
+ console.error(chalk.dim(` Likely cause: gateway is reachable but slow to handshake.`));
147
+ console.error(chalk.dim(` Check that ${host} resolves and the port isn't blocked by a firewall.`));
148
+ }
149
+ else if (isUnknownHost) {
150
+ console.error(chalk.dim(` Couldn't resolve "${host}" — check the hostname and your DNS.`));
151
+ }
152
+ else if (isUnreachable) {
153
+ console.error(chalk.dim(` No network route to ${host}. Check your VPN / firewall / network connection.`));
154
+ }
155
+ else {
156
+ console.error(chalk.dim(` Start the gateway first: brigade gateway --port ${port}`));
157
+ console.error(chalk.dim(` Or check the host/port flags: brigade connect --host ${host} --port ${port}`));
158
+ }
159
+ // Surface the raw message only when the operator opts into debug mode.
160
+ if (process.env.BRIGADE_DEBUG === "1") {
161
+ console.error(chalk.dim(` (debug: ${msg})`));
162
+ }
163
+ process.exit(1);
164
+ }
165
+ // Startup `--agent <id>` binding. Validate against the gateway's live
166
+ // agent list BEFORE engaging the UI — an unknown id would otherwise fall
167
+ // back to the boot agent server-side (getAgentRuntime), silently routing
168
+ // the operator's turns to `main` while they believe they're talking to X.
169
+ // Mirrors the in-TUI `/agent` validation. agents.list failure is lenient
170
+ // (bind anyway; the in-TUI /agent can correct) so a transient RPC hiccup
171
+ // doesn't block launch.
172
+ let initialAgentId;
173
+ if (opts.agentId) {
174
+ try {
175
+ const known = (await client.request("agents.list"));
176
+ if (!known.some((a) => a.id === opts.agentId)) {
177
+ tui.stop();
178
+ restoreTerminal();
179
+ const available = known.map((a) => a.id).join(", ") || "(none)";
180
+ console.error(chalk.red(`✗ Unknown agent "${opts.agentId}".`));
181
+ console.error(chalk.dim(` Available: ${available}`));
182
+ console.error(chalk.dim(` (run \`brigade agents list\` to see them all)`));
183
+ process.exit(1);
184
+ }
185
+ initialAgentId = opts.agentId;
186
+ }
187
+ catch {
188
+ // Lenient: bind anyway; `/agent` inside the TUI re-validates.
189
+ initialAgentId = opts.agentId;
190
+ }
191
+ }
192
+ chatHandle = await wireConnectUi(tui, client, initialAgentId);
193
+ return chatHandle;
194
+ }
195
+ /**
196
+ * Build the live chat UI on top of an already-connected client. Split out so
197
+ * tests can inject a pre-connected client without going through CLI flag
198
+ * parsing or process.exit.
199
+ */
200
+ export async function wireConnectUi(tui, client, initialAgentId) {
201
+ // Static (last-frame) wordmark — `brigade connect` is the chat surface
202
+ // just like `brigade chat`, so we want the same still rendering here. The
203
+ // looping clip is reserved for onboarding's one-time wow moment.
204
+ renderBrandHeader(tui, { animate: false });
205
+ const header = new Text("", 0, 0);
206
+ tui.addChild(header);
207
+ const divider = new Text(brand.dim("─".repeat(80)), 0, 0);
208
+ tui.addChild(divider);
209
+ // Cumulative usage — accumulated from state snapshots so a reconnect picks
210
+ // up where we left off instead of zeroing the totals on the user's screen.
211
+ let lastSnapshot = null;
212
+ // The last text the user sent as a prompt — the replay message for a `/switch`
213
+ // (Carrow) mid-turn model handoff: abort the live turn, swap, re-run this on the new model.
214
+ let lastUserPrompt = "";
215
+ let isAgentRunning = false;
216
+ // Connection-bound agent id. Defaults to the gateway's boot agent (filled
217
+ // in from the first `state` snapshot) so legacy single-agent gateways keep
218
+ // working unchanged. The `/agent <id>` slash command rebinds the connection
219
+ // so subsequent prompt / abort / steer / set-model / set-thinking RPCs all
220
+ // target that agent without the operator having to repeat it every turn.
221
+ // Seeded from `--agent <id>` when supplied (already validated against
222
+ // agents.list in runConnectCommand); otherwise filled from the first
223
+ // `state` snapshot. A pre-set value is preserved by the snapshot handler's
224
+ // `=== undefined` guard, so the startup binding sticks.
225
+ let boundAgentId = initialAgentId;
226
+ // Wave K — connection-bound session key. Lets the operator point this
227
+ // TUI at a per-peer session (e.g. a channel-routed turn under
228
+ // `agent:main:whatsapp:<jid>`) so abort / steer / compact / set-model
229
+ // target THAT lane instead of the boot agent's `main`. Seeded from the
230
+ // first snapshot, overridden by `/session <key>`.
231
+ let boundSessionKey = undefined;
232
+ // Residual P0 (post-Wave K integration audit) — the WS broadcast filter
233
+ // at server.ts:903 keys on per-connection subscription Sets populated by
234
+ // the `subscribe` RPC. Without an explicit subscribe, the filter falls
235
+ // through to back-compat "deliver everything", so two operators each
236
+ // running /agent <id> still see each other's pi/log/approval frames.
237
+ // Track the last-committed sub pair so we can `unsubscribe` it before
238
+ // re-subscribing to the new binding (server keeps sets — leaving stale
239
+ // entries widens what the operator sees).
240
+ let lastSubscribedAgentId = undefined;
241
+ let lastSubscribedSessionKey = undefined;
242
+ // Wave N3 (bug #3) — track whether the very first `state` snapshot has
243
+ // already seeded the connection bindings AND fired an initial `subscribe`.
244
+ // Without this, the snapshot handler stamped boundAgentId/boundSessionKey
245
+ // but never called applySubscription(), so the gateway's per-connection
246
+ // filter at server.ts:903 fell through to its back-compat "deliver
247
+ // everything" branch — every operator on a multi-agent gateway saw every
248
+ // other agent's pi/log/approval frames until they manually issued /agent
249
+ // or /session. We now fire applySubscription() exactly once on the first
250
+ // non-trivial seed; subsequent snapshots are no-ops on this code path.
251
+ let seededSubscription = false;
252
+ const applySubscription = async () => {
253
+ try {
254
+ const priorParams = {};
255
+ if (lastSubscribedAgentId !== undefined)
256
+ priorParams.agentId = lastSubscribedAgentId;
257
+ if (lastSubscribedSessionKey !== undefined)
258
+ priorParams.sessionId = lastSubscribedSessionKey;
259
+ if (Object.keys(priorParams).length > 0) {
260
+ await client.request("unsubscribe", priorParams);
261
+ }
262
+ const nextParams = {};
263
+ if (boundAgentId !== undefined)
264
+ nextParams.agentId = boundAgentId;
265
+ if (boundSessionKey !== undefined)
266
+ nextParams.sessionId = boundSessionKey;
267
+ if (Object.keys(nextParams).length > 0) {
268
+ await client.request("subscribe", nextParams);
269
+ }
270
+ lastSubscribedAgentId = boundAgentId;
271
+ lastSubscribedSessionKey = boundSessionKey;
272
+ }
273
+ catch {
274
+ // Best-effort. Server falls back to the back-compat branch on
275
+ // failure (deliver everything), which matches the pre-fix surface.
276
+ }
277
+ };
278
+ // Wave N3 (bug #3) — defence-in-depth lane filter. Even with the
279
+ // server-side `subscribe` RPC engaged, a stale frame can leak during the
280
+ // gap between /agent or /session being typed and the gateway processing
281
+ // the new subscription set, or against a legacy gateway that doesn't
282
+ // honour subscribe at all. Drop any frame whose stamped agentId/sessionId
283
+ // disagrees with the operator's currently bound lane. Mirrors the
284
+ // upstream client-side gate pattern but adapted for Brigade's
285
+ // server-side subscribe (so we only drop frames that explicitly stamp a
286
+ // DIFFERENT lane — frames with no stamp at all fall through, preserving
287
+ // back-compat with older gateway builds that don't tag broadcasts yet).
288
+ const isOffLane = (frameAgentId, frameSessionId) => {
289
+ if (boundAgentId !== undefined && typeof frameAgentId === "string" && frameAgentId.length > 0) {
290
+ if (frameAgentId !== boundAgentId)
291
+ return true;
292
+ }
293
+ if (boundSessionKey !== undefined && typeof frameSessionId === "string" && frameSessionId.length > 0) {
294
+ if (frameSessionId !== boundSessionKey)
295
+ return true;
296
+ }
297
+ return false;
298
+ };
299
+ // SECURITY (render-side escape scrub). The operator's OWN input is already
300
+ // scrubbed at the submit chokepoint (`sanitizeTerminalInput` in
301
+ // `editor.onSubmit`), but every string the GATEWAY pushes — tool-result
302
+ // previews, assistant text, log lines, cron system-events, the bash command
303
+ // echoed back in an approval confirmation — is attacker-influenceable (a
304
+ // model/tool can be steered to emit control bytes) and reaches a `Text` /
305
+ // `Markdown` widget that preserves raw ANSI. Embedded ESC[ / OSC sequences
306
+ // would otherwise move the cursor, clear the screen, rewrite the window
307
+ // title, or smuggle an OSC 52 clipboard write. Funnel every server-pushed
308
+ // render string through this single helper before it hits a widget.
309
+ //
310
+ // `sanitizeTerminalInput` already strips CSI/OSC/leaked-paste/stray-ESC, but
311
+ // it does NOT strip non-ESC C0 (0x00-0x1F, minus \n/\t) or C1 (0x80-0x9F)
312
+ // control bytes — those can still drive a terminal on their own — so we
313
+ // remove them here too. Newlines and tabs are preserved (multi-line tool
314
+ // errors + the `brigade exec allow …` call-to-action must keep their
315
+ // layout). Idempotent + pure; safe to apply to already-clean text.
316
+ const scrubRenderable = (text) => {
317
+ if (!text)
318
+ return text;
319
+ // First reuse the input-side stripper (CSI/OSC/leaked-paste/stray-ESC +
320
+ // lone-surrogate repair), then drop remaining bare C0/C1 control bytes.
321
+ // eslint-disable-next-line no-control-regex
322
+ return sanitizeTerminalInput(text).replace(/[\x00-\x08\x0b-\x1f\x7f-\x9f]/g, "");
323
+ };
324
+ // Build the standard `{ agentId?, sessionKey?, ...rest }` payload shape
325
+ // every RPC uses. Keeps the call sites compact and ensures sessionKey
326
+ // is threaded uniformly so the server's per-session targeting works.
327
+ const withBinding = (extra = {}) => ({
328
+ ...(boundAgentId !== undefined ? { agentId: boundAgentId } : {}),
329
+ ...(boundSessionKey !== undefined ? { sessionKey: boundSessionKey } : {}),
330
+ ...extra,
331
+ });
332
+ // Streaming-assistant buffers keyed by sub-agent depth (Primitive #6).
333
+ // Depth 0 = top-level agent's stream; depth ≥ 1 = sub-agent at that nesting
334
+ // level. Each depth gets its own Markdown block that grows in place as
335
+ // `message_update` events arrive, so a sub-agent's multi-chunk reply
336
+ // renders as ONE growing block (not N fresh blocks). Cleared per-depth on
337
+ // `tool_execution_start` (so the next message_update at that depth
338
+ // creates a fresh block under the tool), and wholesale on `agent_end` /
339
+ // abort (turn boundary).
340
+ const activeAssistants = new Map();
341
+ let activeLoader = null;
342
+ const pendingTools = new Map();
343
+ // Streaming render coalescer. Every `setText()` on the streaming Markdown
344
+ // widget invalidates the parser cache, so each paint re-parses the FULL
345
+ // growing reply (Marked + line-wrap + ANSI styling). At 60Hz that's a
346
+ // continuous parse stall that blocks scroll events queued in the
347
+ // terminal's input buffer, causing the flicker + scroll-lock the operator
348
+ // sees on Windows Terminal. 150ms (~6–7 paints/sec while streaming) is the
349
+ // chosen default — slow enough that each paint's parse cost is small
350
+ // relative to the gap, fast enough that streaming still feels live.
351
+ // Override with `BRIGADE_STREAM_RENDER_MS` (clamped to ≥16). Raise to 250–400
352
+ // if a slow terminal still flickers; lower to 30–60 on a fast terminal
353
+ // (iTerm, Alacritty, recent Kitty) for snappier streaming.
354
+ const streamRenderMs = Math.max(16, Number(process.env.BRIGADE_STREAM_RENDER_MS) || 150);
355
+ let streamRenderTimer = null;
356
+ const scheduleStreamingRender = () => {
357
+ if (streamRenderTimer)
358
+ return;
359
+ streamRenderTimer = setTimeout(() => {
360
+ streamRenderTimer = null;
361
+ tui.requestRender();
362
+ }, streamRenderMs);
363
+ if (typeof streamRenderTimer.unref === "function")
364
+ streamRenderTimer.unref();
365
+ };
366
+ const flushStreamingRender = () => {
367
+ if (streamRenderTimer) {
368
+ clearTimeout(streamRenderTimer);
369
+ streamRenderTimer = null;
370
+ }
371
+ tui.requestRender();
372
+ };
373
+ // Elapsed-time tracker for the running agent. Started on `agent_start`,
374
+ // cleared on `agent_end`. Read by the 1s ticker below to refresh the
375
+ // header so the user can see "thinking… 12s" / "thinking… 1m 4s" instead
376
+ // of a static "thinking…". Brigade-shape (no phrase rotation, just
377
+ // clean numbers).
378
+ let agentStartedAt = null;
379
+ // Whimsical phrase rotator for the loader. Rotates in the header tail
380
+ // every 4s while the agent is busy. Pi-TUI's CancellableLoader doesn't
381
+ // expose a label setter so we pipe the phrase into the header `extra`
382
+ // slot instead.
383
+ const WHIMSICAL_PHRASES = [
384
+ "thinking",
385
+ "flibbertigibbeting",
386
+ "kerfuffling",
387
+ "dillydallying",
388
+ "twiddling thumbs",
389
+ "noodling",
390
+ "bamboozling",
391
+ "moseying",
392
+ "hobnobbing",
393
+ "pondering",
394
+ "conjuring",
395
+ ];
396
+ let whimsicalIdx = 0;
397
+ // Thinking-block visibility toggle. Default `false` matches today's UX
398
+ // (thinking blocks excluded from `extractAssistantText` filter). When
399
+ // flipped to `true` via the `/show-thinking` slash command, the
400
+ // extractor includes `{ type: "thinking" }` block text alongside the
401
+ // regular text blocks, dimmed so it stays distinct from the agent's
402
+ // final reply. Brigade uses the base Pi-TUI Editor which doesn't
403
+ // expose key handlers, so the toggle is surfaced through the slash-
404
+ // command path instead of a `Ctrl+T` binding.
405
+ let showThinking = false;
406
+ const updateHeader = (extra) => {
407
+ const provider = lastSnapshot?.provider ?? "?";
408
+ const modelId = lastSnapshot?.modelId ?? "?";
409
+ const tokens = lastSnapshot && (lastSnapshot.totalTokensIn + lastSnapshot.totalTokensOut) > 0
410
+ ? ` · ${(lastSnapshot.totalTokensIn + lastSnapshot.totalTokensOut).toLocaleString()} tok`
411
+ : "";
412
+ const cost = lastSnapshot && lastSnapshot.totalCostUsd > 0
413
+ ? ` · $${lastSnapshot.totalCostUsd.toFixed(4)}`
414
+ : "";
415
+ const usage = lastSnapshot?.contextUsagePercent ?? null;
416
+ let usageStr = "";
417
+ if (usage != null && usage >= 50) {
418
+ const pct = Math.round(usage);
419
+ const colored = pct >= 75 ? brand.amber(`${pct}% ctx`) : brand.dim(`${pct}% ctx`);
420
+ usageStr = ` · ${colored}`;
421
+ }
422
+ // Elapsed time during a running turn. Hidden when idle; shown as
423
+ // `· 12s` (under a minute) or `· 1m 4s` so the user has a sense of
424
+ // "is the model still working or has it stalled?".
425
+ let elapsed = "";
426
+ if (isAgentRunning && agentStartedAt != null) {
427
+ const ms = Date.now() - agentStartedAt;
428
+ elapsed = ` · ${formatElapsed(ms)}`;
429
+ }
430
+ const tail = extra ? ` · ${extra}` : "";
431
+ const dot = isAgentRunning ? brand.amber("●") : brand.dim("○");
432
+ // Brand mark — the 🦁 mascot always rides ahead of the persona name
433
+ // so the header reads as Brigade-branded at a glance. When the
434
+ // operator has set a `Name` in IDENTITY.md (e.g. "felix"/"molty"),
435
+ // that name takes the persona slot; otherwise fall back to the
436
+ // "Brigade" wordmark.
437
+ const personaName = lastSnapshot?.agentName?.trim();
438
+ const personaLabel = personaName || "Brigade";
439
+ // "crew <id>" badge — surfaced only when meaningful (non-default
440
+ // agent OR no persona name yet). Hides on a single-agent install
441
+ // with a persona name set so the header stays calm.
442
+ const crewLabel = formatCrewLabel({
443
+ agentId: lastSnapshot?.agentId,
444
+ personaName,
445
+ });
446
+ const crewSegment = crewLabel ? ` ${brand.dim(`· ${crewLabel}`)}` : "";
447
+ // Human-readable session label — `main` / `WhatsApp · DM` /
448
+ // `Slack · group · thread` / `sub-agent abc` instead of the raw
449
+ // `agent:<id>:<rest>` key. Falls back to the raw string when the
450
+ // key is unparseable so we never lose information.
451
+ const sessionLabel = formatSessionLabel(lastSnapshot?.sessionKey);
452
+ const sessionSegment = sessionLabel ? ` ${brand.dim(`· ${sessionLabel}`)}` : "";
453
+ header.setText(` ${dot} 🦁 ${brand.white(personaLabel)}${crewSegment}${sessionSegment} ${brand.dim(`${provider} · ${modelId}${tokens}${cost}`)}${usageStr}${brand.dim(elapsed)}${brand.dim(tail)}`);
454
+ };
455
+ /**
456
+ * Tick the elapsed-time display every second while the agent is busy.
457
+ * Cheap (one timer per connect session, not per-turn) and unref'd so it
458
+ * doesn't keep the process alive past `process.exit`. Cleared in the
459
+ * abort/close path below.
460
+ */
461
+ const elapsedTimer = setInterval(() => {
462
+ if (isAgentRunning && agentStartedAt != null) {
463
+ updateHeader();
464
+ tui.requestRender();
465
+ }
466
+ }, 1000);
467
+ if (typeof elapsedTimer.unref === "function")
468
+ elapsedTimer.unref();
469
+ // Rotate the whimsical phrase shown in the header tail every 4s. Restarts
470
+ // on each agent_start so the user sees the same phrase for the first
471
+ // few seconds (no jarring rotation right after they hit Enter).
472
+ const whimsicalTimer = setInterval(() => {
473
+ if (isAgentRunning && activeLoader) {
474
+ whimsicalIdx = (whimsicalIdx + 1) % WHIMSICAL_PHRASES.length;
475
+ const phrase = WHIMSICAL_PHRASES[whimsicalIdx];
476
+ updateHeader(phrase);
477
+ tui.requestRender();
478
+ }
479
+ }, 4000);
480
+ if (typeof whimsicalTimer.unref === "function")
481
+ whimsicalTimer.unref();
482
+ updateHeader();
483
+ const editor = new BrigadeEditor(tui, editorTheme);
484
+ tui.addChild(editor);
485
+ tui.setFocus(editor);
486
+ // Slash-command autocomplete (Pi-TUI built-in). Connect-mode list omits
487
+ // `/provider` (it can't run the wizard against the remote gateway's
488
+ // filesystem) and `/clear` (chat-only). See chat.ts for the full set.
489
+ // Pi-TUI's slash-command spec: `name` is the command WITHOUT the leading
490
+ // `/`. Pi adds the `/` itself on accept; including it here produces
491
+ // `//reasoning` instead of `/reasoning`.
492
+ const SLASH_COMMANDS = [
493
+ { name: "help", description: "show all slash commands" },
494
+ { name: "exit", description: "quit Brigade connect" },
495
+ { name: "quit", description: "quit Brigade connect" },
496
+ { name: "abort", description: "abort the in-flight turn (same as Ctrl+C)" },
497
+ { name: "usage", description: "show token totals + estimated cost so far" },
498
+ { name: "compact", description: "summarize older turns to free context" },
499
+ {
500
+ name: "memory",
501
+ description: "inspect memory — list / search <q> / inspect <id> / stats",
502
+ argumentHint: "[list | search <q> | inspect <id> | stats]",
503
+ getArgumentCompletions: (prefix) => {
504
+ const verbs = ["list", "search", "inspect", "stats"];
505
+ return verbs
506
+ .filter((v) => v.startsWith(prefix.toLowerCase()))
507
+ .map((v) => ({ value: v, label: v }));
508
+ },
509
+ },
510
+ {
511
+ name: "allow-all",
512
+ description: "on|off — skip shell approval prompts this session (guards still apply)",
513
+ argumentHint: "<on|off>",
514
+ },
515
+ {
516
+ name: "grant-skill",
517
+ description: "preview/approve a skill's declared commands (--yes to apply)",
518
+ argumentHint: "<name> [--yes]",
519
+ },
520
+ {
521
+ name: "revoke-skill",
522
+ description: "remove a skill's granted commands from the allowlist",
523
+ argumentHint: "<name>",
524
+ },
525
+ {
526
+ name: "model",
527
+ description: "switch to another configured model (no arg = picker)",
528
+ argumentHint: "[<model-id>]",
529
+ },
530
+ {
531
+ name: "thinking",
532
+ description: "set the model's reasoning effort",
533
+ argumentHint: "<off|low|medium|high|xhigh>",
534
+ getArgumentCompletions: (prefix) => {
535
+ const levels = ["off", "minimal", "low", "medium", "high", "xhigh"];
536
+ return levels
537
+ .filter((l) => l.startsWith(prefix.toLowerCase()))
538
+ .map((l) => ({ value: l, label: l }));
539
+ },
540
+ },
541
+ {
542
+ name: "reasoning",
543
+ description: "show/hide the model's thinking blocks before replies",
544
+ argumentHint: "<on|off>",
545
+ getArgumentCompletions: (prefix) => {
546
+ const opts = ["on", "off"];
547
+ return opts
548
+ .filter((o) => o.startsWith(prefix.toLowerCase()))
549
+ .map((o) => ({ value: o, label: o }));
550
+ },
551
+ },
552
+ {
553
+ name: "agent",
554
+ description: "show/bind the connection's active agent id",
555
+ argumentHint: "[<agent-id>]",
556
+ },
557
+ {
558
+ name: "session",
559
+ description: "show/bind the connection's active session key",
560
+ argumentHint: "[<session-key>]",
561
+ },
562
+ {
563
+ name: "agents",
564
+ description: "list every agent the gateway knows about",
565
+ },
566
+ {
567
+ name: "sessions",
568
+ description: "list live sessions for the bound agent (or all)",
569
+ argumentHint: "[--all]",
570
+ },
571
+ {
572
+ name: "mute",
573
+ description: "unsubscribe from an agent id or session key",
574
+ argumentHint: "<agent-id|session-key>",
575
+ },
576
+ {
577
+ name: "org",
578
+ description: "show the Pride hierarchy chart (Higher Office / Departments)",
579
+ argumentHint: "[<agent-id>|--departments|--explain <from> <to>]",
580
+ },
581
+ ];
582
+ editor.setAutocompleteProvider(new CombinedAutocompleteProvider(SLASH_COMMANDS, process.cwd()));
583
+ // Connect mode cannot run the provider-onboarding wizard (it writes to the
584
+ // gateway machine's filesystem, which we don't have). We surface that gap
585
+ // inline above the footer so users who notice `/provider` is missing aren't
586
+ // left guessing — they get the exact escape hatch.
587
+ tui.addChild(new Text(brand.dim(" connect-mode: /agent /agents /sessions · /model /thinking /reasoning · /abort /steer /compact · /usage /help (use 'brigade chat' on the gateway machine for /provider)"), 0, 0));
588
+ tui.addChild(new Text(brand.dim(" Enter to send · Ctrl+C abort · /usage /abort /reasoning · /help for full list"), 0, 0));
589
+ const insertBeforeEditor = (component) => {
590
+ const children = tui.children;
591
+ const editorIdx = children.indexOf(editor);
592
+ if (editorIdx < 0) {
593
+ tui.addChild(component);
594
+ }
595
+ else {
596
+ children.splice(editorIdx, 0, component);
597
+ tui.requestRender();
598
+ }
599
+ };
600
+ const removeChild = (component) => {
601
+ try {
602
+ tui.removeChild(component);
603
+ }
604
+ catch {
605
+ /* ignore */
606
+ }
607
+ };
608
+ /**
609
+ * Format the operator's approval choice as a multi-line confirmation
610
+ * stamped above the editor — replaces the inline card so the chat
611
+ * history shows BOTH the decision AND the command + persistence target
612
+ * even after the prompt itself is gone.
613
+ *
614
+ * Visual language:
615
+ * - Green ✓ on allow (`brand.tool`)
616
+ * - Red ✗ on deny (`brand.error`)
617
+ * - Persistent decisions ("allow always", "allow pattern") spell out
618
+ * the file we just wrote to so the operator can `cat` it to audit.
619
+ */
620
+ const decisionConfirmation = (command, resolution, subagentDepth) => {
621
+ // When the approval originated from a sub-agent (depth > 0), prefix
622
+ // every line with the same `" ".repeat(depth)` indent the tool
623
+ // indicators use. Otherwise the confirmation lands at top-level indent
624
+ // while the source `⚡ bash` indicator sits 4 spaces in — visually
625
+ // jarring and easy to misread as "the parent approved that".
626
+ const depth = typeof subagentDepth === "number" && subagentDepth > 0 ? subagentDepth : 0;
627
+ const subIndent = depth > 0 ? " ".repeat(depth) : "";
628
+ // Scrub the server-pushed bash command before echoing it back (see
629
+ // `scrubRenderable`). The command string is attacker-influenceable
630
+ // (a model can request a command containing ANSI/OSC bytes) and is
631
+ // rendered verbatim in the confirmation stamped above the editor.
632
+ const cmd = `${subIndent} ${brand.dim(scrubRenderable(command).trim())}`;
633
+ switch (resolution.decision) {
634
+ case "allow-once":
635
+ return [
636
+ `${subIndent} ${brand.tool("✓")} ${brand.tool("Allowed once")} ${brand.dim("· running now…")}`,
637
+ cmd,
638
+ ].join("\n");
639
+ case "allow-always":
640
+ return [
641
+ `${subIndent} ${brand.tool("✓")} ${brand.tool("Allowed always")} ${brand.dim("· running now…")}`,
642
+ cmd,
643
+ `${subIndent} ${brand.dim("Saved to ~/.brigade/exec-approvals.json — future calls will run without asking.")}`,
644
+ ].join("\n");
645
+ case "allow-pattern": {
646
+ const pat = resolution.pattern?.trim() ?? "";
647
+ return [
648
+ `${subIndent} ${brand.tool("✓")} ${brand.tool("Pattern saved")} ${brand.dim("· running now…")}`,
649
+ cmd,
650
+ `${subIndent} ${brand.dim(`Pattern /${pat}/ saved to ~/.brigade/exec-approvals.json — any future command matching this regex runs without asking.`)}`,
651
+ ].join("\n");
652
+ }
653
+ case "allow-session":
654
+ return [
655
+ `${subIndent} ${brand.amber("⚠")} ${brand.amber("Allow all this session")} ${brand.dim("· running now…")}`,
656
+ cmd,
657
+ `${subIndent} ${brand.dim("Shell commands run without asking for the rest of this session (safety guards still apply). /allow-all off to stop.")}`,
658
+ ].join("\n");
659
+ case "deny":
660
+ return [
661
+ `${subIndent} ${brand.error("✗")} ${brand.error("Denied")} ${brand.dim("· refused")}`,
662
+ cmd,
663
+ ].join("\n");
664
+ }
665
+ };
666
+ /**
667
+ * Extract the renderable text for an assistant message — mirrors
668
+ * chat.ts's `extractAssistantText`. See chat.ts for the full rationale.
669
+ */
670
+ const extractAssistantText = (message) => {
671
+ if (!message || !Array.isArray(message.content))
672
+ return "";
673
+ const thinkingParts = [];
674
+ const contentParts = [];
675
+ for (const b of message.content) {
676
+ if (!b || typeof b !== "object")
677
+ continue;
678
+ if (b.type === "thinking" && typeof b.thinking === "string") {
679
+ const t = b.thinking.trim();
680
+ if (t)
681
+ thinkingParts.push(t);
682
+ continue;
683
+ }
684
+ // Some forwarded shapes use `text` instead of `thinking` on the
685
+ // thinking block (gateway re-emit quirk). Honour both.
686
+ if (b.type === "thinking" && typeof b.text === "string") {
687
+ const t = b.text.trim();
688
+ if (t)
689
+ thinkingParts.push(t);
690
+ continue;
691
+ }
692
+ if (b.type === "text" && typeof b.text === "string") {
693
+ const inlineThinking = [];
694
+ const stripped = b.text.replace(/<think>([\s\S]*?)<\/think>\s*/g, (_m, inner) => {
695
+ const t = inner.trim();
696
+ if (t)
697
+ inlineThinking.push(t);
698
+ return "";
699
+ });
700
+ thinkingParts.push(...inlineThinking);
701
+ if (stripped.trim())
702
+ contentParts.push(stripped);
703
+ }
704
+ }
705
+ const thinkingText = thinkingParts.join("\n").trim();
706
+ const contentText = contentParts.join("").trim();
707
+ const parts = [];
708
+ if (showThinking && thinkingText) {
709
+ parts.push(`${brand.dim("[thinking]")}\n${brand.dim(thinkingText)}`);
710
+ }
711
+ if (contentText)
712
+ parts.push(contentText);
713
+ return parts.join("\n\n");
714
+ };
715
+ /**
716
+ * Format an elapsed-millisecond duration into a compact label for the
717
+ * status line — `12s` / `1m 4s` / `2h 3m`. Brigade keeps the loader
718
+ * Pi-TUI provides; only the elapsed counter is new (no shimmer
719
+ * animation).
720
+ */
721
+ const formatElapsed = (ms) => {
722
+ const total = Math.max(0, Math.floor(ms / 1000));
723
+ if (total < 60)
724
+ return `${total}s`;
725
+ const m = Math.floor(total / 60);
726
+ const s = total % 60;
727
+ if (m < 60)
728
+ return s === 0 ? `${m}m` : `${m}m ${s}s`;
729
+ const h = Math.floor(m / 60);
730
+ const mm = m % 60;
731
+ return mm === 0 ? `${h}h` : `${h}h ${mm}m`;
732
+ };
733
+ // No auto-kickoff. Brigade used to auto-send "Wake up, my friend!" as a
734
+ // synthetic first user turn on fresh-bootstrap workspaces; removed so
735
+ // the TUI client never auto-sends. The user types the first message
736
+ // themselves.
737
+ // State snapshots from the gateway — every mutation pushes one.
738
+ client.on("state", (snap) => {
739
+ lastSnapshot = snap;
740
+ // `snap.isAgentRunning` is AGENT-wide — it goes true when ANY session
741
+ // of this agent has a turn running (a WhatsApp chat, spawned
742
+ // sub-agents, a cron run). Taking it as-is flipped THIS lane into
743
+ // steer mode while our own session was idle, so typed messages
744
+ // bounced with "nothing to steer" and were lost. Only the CLEARING
745
+ // direction is safe from the snapshot (it reconciles a missed
746
+ // agent_end after a disconnect); the lane's own agent_start /
747
+ // agent_end events own the upward direction.
748
+ if (!snap.isAgentRunning)
749
+ isAgentRunning = false;
750
+ // Seed the connection-bound agent from the first snapshot the
751
+ // gateway pushes. The operator can override via `/agent <id>` —
752
+ // once set explicitly, snapshot updates no longer reset the binding.
753
+ if (boundAgentId === undefined && typeof snap.agentId === "string" && snap.agentId.length > 0) {
754
+ boundAgentId = snap.agentId;
755
+ }
756
+ // Wave K — seed the connection-bound session key from the first
757
+ // snapshot. Once set explicitly via `/session <key>`, snapshot
758
+ // updates no longer reset it (mirrors boundAgentId semantics).
759
+ //
760
+ // --agent guard (2026-06-11): do NOT inherit a session key from a
761
+ // snapshot whose agent differs from the one we're explicitly bound to.
762
+ // On `brigade connect --agent marketing-lead`, the gateway's first
763
+ // (boot) snapshot is for `main` with sessionKey `agent:main:main`.
764
+ // Seeding that here made `withBinding` send the incoherent pair
765
+ // {agentId: "marketing-lead", sessionKey: "agent:main:main"} — the
766
+ // turn routed to main's session and the off-lane / subscription filter
767
+ // dropped the reply (first message landed on main, "fixed" itself only
768
+ // once a marketing-lead snapshot arrived). Leaving boundSessionKey
769
+ // undefined lets the gateway resolve the bound agent's OWN default
770
+ // session from agentId alone. Once a snapshot for the bound agent
771
+ // arrives, the match passes and the real session key seeds normally.
772
+ if (boundSessionKey === undefined &&
773
+ typeof snap.sessionKey === "string" &&
774
+ snap.sessionKey.length > 0 &&
775
+ snapshotSessionSeedable(boundAgentId, snap.agentId)) {
776
+ boundSessionKey = snap.sessionKey;
777
+ }
778
+ // Wave N3 (bug #3) — fire the initial subscription as soon as we
779
+ // have a non-trivial binding from the gateway. Without this, the
780
+ // server-side broadcast filter falls through to "deliver
781
+ // everything" until the operator types /agent or /session, leaking
782
+ // other agents' frames into this TUI. Fires AT MOST ONCE per
783
+ // connection; subsequent /agent and /session bindings each fire
784
+ // their own applySubscription() from their handlers below.
785
+ if (!seededSubscription && (boundAgentId !== undefined || boundSessionKey !== undefined)) {
786
+ seededSubscription = true;
787
+ void applySubscription();
788
+ }
789
+ updateHeader();
790
+ });
791
+ // Tool-approval prompt — the gateway broadcasts an `approval-request`
792
+ // event when a gated tool (today: `bash`) needs operator consent. We
793
+ // render the inline Y/A/P/N prompt above the editor and resolve via
794
+ // the `approval-resolve` request. Persistence ("allow always" / "allow
795
+ // pattern") is handled SERVER-side in exec-gate's `applyApprovalDecision`,
796
+ // which calls `recordApproval()` and writes `~/.brigade/exec-approvals.json`
797
+ // atomically with 0o600 perms.
798
+ let activePrompt = null;
799
+ client.on("approval-request", (req) => {
800
+ // Wave N3 (bug #3) — defence-in-depth: drop approval prompts that
801
+ // don't belong to the lane this TUI is bound to. Without this, two
802
+ // operators each running /agent X and /agent Y would both render
803
+ // every approval card. Server-side subscribe should already filter
804
+ // this, but a race between /agent rebind + the next gated-tool
805
+ // frame can still leak a stale one here.
806
+ if (isOffLane(req.agentId, req.sessionId)) {
807
+ return;
808
+ }
809
+ // If another prompt is somehow already showing (shouldn't happen
810
+ // because exec-gate is serial per-turn), tear it down first so we
811
+ // don't stack prompts on the screen.
812
+ if (activePrompt) {
813
+ try {
814
+ tui.removeChild(activePrompt);
815
+ }
816
+ catch {
817
+ /* ignore */
818
+ }
819
+ activePrompt = null;
820
+ }
821
+ const prompt = new ApprovalPrompt({
822
+ tui,
823
+ request: {
824
+ id: req.id,
825
+ command: req.command,
826
+ toolName: req.toolName,
827
+ cwd: req.cwd,
828
+ ...(req.subagentLabel !== undefined ? { subagentLabel: req.subagentLabel } : {}),
829
+ ...(req.subagentDepth !== undefined ? { subagentDepth: req.subagentDepth } : {}),
830
+ ...(req.parentRunId !== undefined ? { parentRunId: req.parentRunId } : {}),
831
+ },
832
+ onResolve: (resolution) => {
833
+ // Clear the prompt and hand focus back to the editor BEFORE
834
+ // firing the resolve — so the next agent_start event (which
835
+ // will follow on allow) doesn't fight the prompt for focus.
836
+ if (activePrompt) {
837
+ try {
838
+ tui.removeChild(activePrompt);
839
+ }
840
+ catch {
841
+ /* ignore */
842
+ }
843
+ activePrompt = null;
844
+ }
845
+ tui.setFocus(editor);
846
+ const confirmation = decisionConfirmation(req.command, resolution, req.subagentDepth);
847
+ insertBeforeEditor(new Text(confirmation, 0, 0));
848
+ tui.requestRender();
849
+ void client
850
+ .request("approval-resolve", {
851
+ id: req.id,
852
+ decision: resolution.decision,
853
+ pattern: resolution.pattern,
854
+ })
855
+ .catch((err) => {
856
+ const msg = err instanceof Error ? err.message : String(err);
857
+ insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.error(`approval send failed: ${msg}`)}`, 0, 0));
858
+ });
859
+ },
860
+ });
861
+ activePrompt = prompt;
862
+ insertBeforeEditor(prompt);
863
+ tui.setFocus(prompt);
864
+ tui.requestRender();
865
+ });
866
+ // Server-side warnings/info (e.g. "primary failed, trying fallback") — the
867
+ // gateway emits these via the wrapper-chain callbacks. Mirror to the TUI
868
+ // so the user sees the same context they would in `brigade chat`.
869
+ client.on("log", (entry) => {
870
+ // Wave N3 (bug #3) — defensive lane drop. Stamped log entries from
871
+ // off-lane agents get silently dropped here, matching the same
872
+ // filter the server's subscribe applies.
873
+ if (isOffLane(entry.agentId, entry.sessionId))
874
+ return;
875
+ // Scrub the server-pushed log message before rendering (see
876
+ // `scrubRenderable`) — these can carry forwarded model/tool text.
877
+ const message = scrubRenderable(entry.message);
878
+ const tone = entry.level === "error"
879
+ ? brand.error(`✗ ${message}`)
880
+ : entry.level === "warn"
881
+ ? brand.dim(`⚠ ${message}`)
882
+ : brand.dim(`↻ ${message}`);
883
+ insertBeforeEditor(new Text(` ${tone}`, 0, 0));
884
+ });
885
+ // `system-event` — out-of-band notification the operator MUST see (today
886
+ // only emitted by the cron service's announce path). Rendered as a
887
+ // visible Brigade-side chat line, NOT in the dim log lane, so a cron
888
+ // reminder firing while the operator is connected actually surfaces.
889
+ // Bug #4 — when `payload.source === "cron"` we always render the cron
890
+ // prefix `[cron "<name>"] <summary>` and append a small delivered/not-
891
+ // delivered hint so the operator can tell whether the channel-side
892
+ // send also landed or only this TUI awareness fired.
893
+ client.on("system-event", (event) => {
894
+ // Wave N3 (bug #3) — defensive lane drop. Cron-fired events stamped
895
+ // for another agent shouldn't surface on this operator's connect TUI.
896
+ if (isOffLane(event.agentId, event.sessionId))
897
+ return;
898
+ // Scrub the server-pushed event text before rendering (see
899
+ // `scrubRenderable`). A cron `system-event` carries the cron run's
900
+ // MODEL-GENERATED reply verbatim (server enqueueSystemEvent), so this
901
+ // is an attacker-influenceable path even though it's not direct bash.
902
+ const eventText = scrubRenderable(event.text);
903
+ const isCron = event.source === "cron" || event.jobName !== undefined;
904
+ if (isCron) {
905
+ const name = event.jobName ?? "cron";
906
+ const heading = brand.amber(`🦁 [cron "${name}"]`);
907
+ let suffix = "";
908
+ if (event.delivered === true) {
909
+ suffix = ` ${brand.dim("· delivered")}`;
910
+ }
911
+ else if (event.delivered === false) {
912
+ suffix = ` ${brand.dim("· not delivered (TUI only)")}`;
913
+ }
914
+ insertBeforeEditor(new Text(`${heading} ${eventText}${suffix}`, 0, 0));
915
+ }
916
+ else {
917
+ const heading = brand.amber("🦁");
918
+ insertBeforeEditor(new Text(`${heading} ${eventText}`, 0, 0));
919
+ }
920
+ tui.requestRender();
921
+ });
922
+ // Pi events are forwarded as `{ event: <pi event>, subagentDepth? }`.
923
+ // Same render logic as src/ui/chat.ts but stripped of in-process state
924
+ // mutations. Primitive #6: when `subagentDepth > 0`, indent child events
925
+ // by `2 * depth` spaces so nested sub-agent activity is visually distinct
926
+ // from the parent's stream.
927
+ client.on("pi", (payload) => {
928
+ const { event, subagentDepth } = payload;
929
+ // Wave N3 (bug #3) — defensive lane drop. The gateway already
930
+ // filters via subscribe; this catches the gap between an /agent or
931
+ // /session rebind and the gateway's next-frame view of the new
932
+ // binding (or a legacy gateway that doesn't filter at all).
933
+ if (isOffLane(payload.agentId, payload.sessionId))
934
+ return;
935
+ const depth = typeof subagentDepth === "number" ? subagentDepth : 0;
936
+ const subIndent = depth > 0 ? " ".repeat(depth) : "";
937
+ switch (event?.type) {
938
+ case "agent_start": {
939
+ isAgentRunning = true;
940
+ agentStartedAt = Date.now();
941
+ whimsicalIdx = 0; // reset so the first phrase is always "thinking"
942
+ editor.disableSubmit = true;
943
+ updateHeader(WHIMSICAL_PHRASES[0]);
944
+ activeLoader = new CancellableLoader(tui, (s) => brand.amber(s), (s) => brand.dim(s), "thinking");
945
+ insertBeforeEditor(activeLoader);
946
+ break;
947
+ }
948
+ case "message_update":
949
+ case "message_end": {
950
+ const msg = event.message;
951
+ if (!msg || msg.role !== "assistant")
952
+ break;
953
+ // Scrub server-pushed assistant text before it reaches the
954
+ // Markdown widget (see `scrubRenderable`). The model can be
955
+ // steered to emit ANSI/OSC control bytes; the widget preserves
956
+ // raw escapes, so strip them here. The brand-coloured label
957
+ // prefix added below is Brigade-internal chalk and stays intact.
958
+ const text = scrubRenderable(extractAssistantText(msg));
959
+ if (!text)
960
+ break;
961
+ if (activeLoader) {
962
+ removeChild(activeLoader);
963
+ activeLoader = null;
964
+ }
965
+ // Label assistant turns with the agent's chosen name (from
966
+ // IDENTITY.md, exposed via state snapshot). Falls back to
967
+ // the runtime container name when the operator hasn't named
968
+ // the agent yet — same convention as the brand colour, just
969
+ // dynamic per-workspace.
970
+ const label = lastSnapshot?.agentName ?? "brigade";
971
+ const labelPrefix = depth > 0 ? "sub-agent" : label;
972
+ const renderedText = `${subIndent}${brand.agent(labelPrefix)} ${text}`;
973
+ // Per-depth streaming buffers: top-level (depth 0) and each sub-
974
+ // agent (depth ≥ 1) get their OWN Markdown block that grows in
975
+ // place. A child's message_update chunks now land in the child's
976
+ // own buffer (not appended as N fresh blocks, and not overwriting
977
+ // the parent's buffer).
978
+ const existing = activeAssistants.get(depth);
979
+ if (!existing) {
980
+ // Wave N5 (bug #6) — origin attribution. When this turn is
981
+ // running on a non-`main` session (e.g. a channel-routed
982
+ // `agent:<id>:whatsapp:direct:<peer>` lane), drop a small
983
+ // `↳ via <label>` chip ABOVE the assistant block so the
984
+ // operator can tell at a glance that the reply is the
985
+ // agent's answer to an inbound WhatsApp / Slack / cron
986
+ // message — not something they typed locally. We surface
987
+ // it only ONCE per (turn, depth), keyed off the first
988
+ // message_update arriving at this depth (when `existing`
989
+ // is undefined). The home session returns `undefined` from
990
+ // `formatSessionLabel` so the chip is silently omitted on
991
+ // the common path.
992
+ const originLabel = formatSessionLabel(payload.sessionId);
993
+ if (originLabel) {
994
+ insertBeforeEditor(new Text(`${subIndent}${brand.dim(`↳ via ${originLabel}`)}`, 0, 0));
995
+ }
996
+ const fresh = new Markdown(renderedText, 1, 0, markdownTheme);
997
+ activeAssistants.set(depth, fresh);
998
+ insertBeforeEditor(fresh);
999
+ }
1000
+ else {
1001
+ existing.setText(renderedText);
1002
+ // message_end carries the FINAL text — paint immediately so
1003
+ // the user never has to wait the debounce window for the
1004
+ // last chunk. message_update batches through the debouncer
1005
+ // so a 200-token reply paints ~12 times instead of ~200,
1006
+ // killing the flicker that blocked terminal scroll-back.
1007
+ if (event.type === "message_end") {
1008
+ flushStreamingRender();
1009
+ }
1010
+ else {
1011
+ scheduleStreamingRender();
1012
+ }
1013
+ }
1014
+ break;
1015
+ }
1016
+ case "tool_execution_start": {
1017
+ if (activeLoader) {
1018
+ removeChild(activeLoader);
1019
+ activeLoader = null;
1020
+ }
1021
+ // Close the current depth's assistant text block when a tool starts.
1022
+ // Otherwise the assistant block's position is locked at first stream-
1023
+ // chunk, and a long final answer flowing in AFTER the tools end ends
1024
+ // up rendered ABOVE them. Strictly chronological order — clearing
1025
+ // the per-depth pointer lets the next message_update at THIS depth
1026
+ // create a fresh block that lands below the most recent tool.
1027
+ // We clear ONLY this depth's buffer so a sub-agent's tool start
1028
+ // doesn't close the parent's open assistant block (separate streams).
1029
+ activeAssistants.delete(depth);
1030
+ // A tool starting is a turn-boundary for the open assistant
1031
+ // stream — flush any pending debounced paint so the assistant
1032
+ // block above renders its full text BEFORE the tool indicator
1033
+ // lands underneath.
1034
+ flushStreamingRender();
1035
+ const indicator = new Text(`${subIndent} ${brand.tool("⚡")} ${brand.tool(event.toolName)}`, 0, 0);
1036
+ pendingTools.set(event.toolCallId, indicator);
1037
+ insertBeforeEditor(indicator);
1038
+ break;
1039
+ }
1040
+ case "tool_execution_end": {
1041
+ const indicator = pendingTools.get(event.toolCallId);
1042
+ if (indicator) {
1043
+ const mark = event.isError ? brand.error("✗") : brand.tool("✓");
1044
+ // Append a short preview of what the tool produced so the
1045
+ // connect view matches `brigade chat` ("✓ bash · output").
1046
+ // Errors preserve newlines + use a bigger budget so the
1047
+ // gate's "brigade exec allow ..." call-to-action survives.
1048
+ const summary = summarizeToolResult(event.result, {
1049
+ preserveNewlines: event.isError,
1050
+ });
1051
+ // Scrub the server-pushed tool-result preview before it
1052
+ // reaches a Text widget (see `scrubRenderable`). Tool output
1053
+ // is the most direct attacker-influenceable render path —
1054
+ // a `bash`/`read` result can carry ANSI/OSC control bytes.
1055
+ // Done once here so both render branches below stay clean.
1056
+ const previewText = scrubRenderable(summary.preview);
1057
+ if (event.isError && summary.multiline) {
1058
+ indicator.setText(`${subIndent} ${mark} ${brand.tool(event.toolName)}`);
1059
+ const errIndent = `${subIndent} `;
1060
+ const indentedBody = previewText
1061
+ .split("\n")
1062
+ .map((line) => `${errIndent}${brand.dim(line)}`)
1063
+ .join("\n");
1064
+ insertBeforeEditor(new Text(indentedBody, 0, 0));
1065
+ }
1066
+ else {
1067
+ const preview = summary.hasContent ? ` ${brand.dim(`· ${previewText}`)}` : "";
1068
+ indicator.setText(`${subIndent} ${mark} ${brand.tool(event.toolName)}${preview}`);
1069
+ }
1070
+ tui.requestRender();
1071
+ pendingTools.delete(event.toolCallId);
1072
+ }
1073
+ break;
1074
+ }
1075
+ case "turn_end": {
1076
+ // Intentionally a no-op. Token totals (totalTokensIn / Out /
1077
+ // CostUsd) are accumulated SERVER-SIDE in server.ts:156-163
1078
+ // on every turn_end, then pushed to us via the very next
1079
+ // `state` event at server.ts:165. Our `state` handler above
1080
+ // stores that into `lastSnapshot` and calls updateHeader(),
1081
+ // which reads the totals from `lastSnapshot`. Doing the
1082
+ // accumulation HERE too would double-count.
1083
+ //
1084
+ // Kept as a labelled case so any future connect-only logic
1085
+ // (e.g. per-turn flash UI, telemetry hook) has a place to
1086
+ // land — and so the next audit doesn't flag this as missing.
1087
+ break;
1088
+ }
1089
+ case "compaction_start": {
1090
+ const pct = lastSnapshot?.contextUsagePercent != null
1091
+ ? `${Math.round(lastSnapshot.contextUsagePercent)}%`
1092
+ : "high";
1093
+ insertBeforeEditor(new Text(` ${brand.dim(`⚡ compacting context (was ${pct})…`)}`, 0, 0));
1094
+ break;
1095
+ }
1096
+ case "compaction_end": {
1097
+ if (event.aborted) {
1098
+ insertBeforeEditor(new Text(` ${brand.dim("compaction aborted")}`, 0, 0));
1099
+ }
1100
+ else {
1101
+ // Pi's getContextUsage returns null right after compaction by
1102
+ // design — token estimates need a fresh LLM response. Show
1103
+ // that explicitly via the snapshot's percent (server pushes
1104
+ // a fresh snapshot post-compact).
1105
+ const after = lastSnapshot?.contextUsagePercent;
1106
+ const afterStr = after != null
1107
+ ? `usage now ${Math.round(after)}%`
1108
+ : "usage refreshes after your next message";
1109
+ insertBeforeEditor(new Text(` ${brand.amber("✓")} ${brand.dim(`compacted · ${afterStr}`)}`, 0, 0));
1110
+ }
1111
+ break;
1112
+ }
1113
+ case "auto_retry_start": {
1114
+ // Pi auto-retries transient provider errors (rate limit, 5xx,
1115
+ // connection drop). Tell the user it's happening — without this,
1116
+ // a slow retry looks like the connection is just hanging.
1117
+ const attempt = event.attempt ?? 1;
1118
+ const max = event.maxAttempts ?? 1;
1119
+ const waitS = Math.round((event.delayMs ?? 0) / 100) / 10;
1120
+ insertBeforeEditor(new Text(` ${brand.dim(`↻ retrying (attempt ${attempt}/${max}, waiting ${waitS}s)…`)}`, 0, 0));
1121
+ break;
1122
+ }
1123
+ case "auto_retry_end": {
1124
+ if (event.success === false) {
1125
+ insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.error(`gave up after ${event.attempt} attempts`)}`, 0, 0));
1126
+ }
1127
+ break;
1128
+ }
1129
+ case "agent_end": {
1130
+ isAgentRunning = false;
1131
+ agentStartedAt = null;
1132
+ editor.disableSubmit = false;
1133
+ activeAssistants.clear();
1134
+ // Turn-end is the definitive flush point — even if every other
1135
+ // path missed flushing, this guarantees the last paint of the
1136
+ // turn lands before the editor re-enables for the operator.
1137
+ flushStreamingRender();
1138
+ if (activeLoader) {
1139
+ removeChild(activeLoader);
1140
+ activeLoader = null;
1141
+ }
1142
+ // Clear any tool indicators that never received a matching
1143
+ // `tool_execution_end` — a long session can accumulate these
1144
+ // when a model aborts mid-tool and they otherwise pin a Text
1145
+ // node in the children list per orphaned tool.
1146
+ pendingTools.clear();
1147
+ updateHeader();
1148
+ break;
1149
+ }
1150
+ }
1151
+ });
1152
+ // Reconnect notifications — let the user know what just happened so a
1153
+ // dropped/restored gateway doesn't look like phantom output.
1154
+ //
1155
+ // CRITICAL: on reconnect, request a fresh state snapshot AND aggressively
1156
+ // clear any "↯ tool" indicators that were waiting on a `tool_execution_end`
1157
+ // event we likely missed while the WS was disconnected. Without this, a
1158
+ // reconnect mid-tool leaves the TUI showing `↯ cron` (or any other tool)
1159
+ // forever even though the gateway has long since finished — the user sees
1160
+ // a "stuck" indicator that's purely a TUI state-staleness bug, not an
1161
+ // actual hang.
1162
+ client.on("reconnected", () => {
1163
+ insertBeforeEditor(new Text(` ${brand.dim("↻ reconnected to gateway")}`, 0, 0));
1164
+ // Re-subscription after a dropped/restored gateway. BrigadeClient opens
1165
+ // a BRAND-NEW socket on reconnect, so the gateway assigns a fresh
1166
+ // connection id whose per-connection agent/session subscription Sets are
1167
+ // EMPTY — and the broadcast filter falls through to "deliver everything",
1168
+ // losing server-side lane isolation. It also means the bound agent's
1169
+ // per-binding state snapshot (pushed only in response to a `subscribe`
1170
+ // with the agentId) is never re-sent, so a non-boot binding's header
1171
+ // reverts to the BOOT agent's snapshot. Re-issue the subscription below.
1172
+ //
1173
+ // First clear the last-committed sub mirror: the fresh connection has NO
1174
+ // prior server-side subscription, so leaving these set would make
1175
+ // applySubscription() fire a spurious `unsubscribe` for a sub this
1176
+ // connection never had. Reset → re-subscribe is the correct sequence.
1177
+ lastSubscribedAgentId = undefined;
1178
+ lastSubscribedSessionKey = undefined;
1179
+ // Fire-and-forget: ask the gateway for the current snapshot so the
1180
+ // `state` handler above updates `isAgentRunning` + the header. Errors
1181
+ // are swallowed — the next state push (any tool call / turn start)
1182
+ // will refresh anyway. The re-subscribe is appended AFTER this settles
1183
+ // (both success and failure) so ordering is deterministic and the
1184
+ // subscribe-time per-binding snapshot push lands after the get-state
1185
+ // reconcile.
1186
+ client.request("get-state").then((snap) => {
1187
+ if (!snap)
1188
+ return;
1189
+ lastSnapshot = snap;
1190
+ // Same one-way rule as the `state` handler: the agent-wide flag
1191
+ // may only CLEAR our lane's busy state, never set it.
1192
+ if (!snap.isAgentRunning)
1193
+ isAgentRunning = false;
1194
+ // If the gateway says no turn is in flight, then any tool
1195
+ // indicators we still hold are stale (their `tool_execution_end`
1196
+ // landed while we were disconnected). Mark each one as
1197
+ // completed-with-no-known-outcome so the TUI stops spinning.
1198
+ if (!snap.isAgentRunning && pendingTools.size > 0) {
1199
+ // Reconcile orphaned tool indicators by marking each as
1200
+ // completed-with-unknown-outcome. We don't know which tool's
1201
+ // `tool_execution_end` was missed during the disconnect, so we
1202
+ // can't infer the exit status; the dim ⋯ glyph signals "this
1203
+ // tool finished, but the TUI didn't see how" and stops the spin.
1204
+ for (const [, indicator] of pendingTools) {
1205
+ indicator.setText(` ${brand.dim("⋯ tool completed during disconnect")}`);
1206
+ }
1207
+ pendingTools.clear();
1208
+ }
1209
+ updateHeader();
1210
+ tui.requestRender();
1211
+ }, () => {
1212
+ /* best-effort — silently ignore */
1213
+ }).then(() => {
1214
+ // Re-subscribe the bound agent/session on the fresh connection.
1215
+ // Runs after get-state settles (the rejection handler above swallows
1216
+ // errors, so this chains in both cases) — deterministic ordering.
1217
+ // This also triggers the server's subscribe-time per-binding snapshot
1218
+ // push, restoring the correct header for a non-boot binding.
1219
+ void applySubscription();
1220
+ });
1221
+ });
1222
+ // Slash command + send wiring.
1223
+ editor.onSubmit = async (value) => {
1224
+ // SECURITY — scrub terminal escape sequences, leaked bracketed-paste markers,
1225
+ // and lone surrogates from input BEFORE it reaches command dispatch, the model
1226
+ // payload, or the echo. A hostile paste (or text the agent was told to copy
1227
+ // from a malicious page) can otherwise corrupt the terminal or smuggle control
1228
+ // bytes into the transcript. The single submit chokepoint covers every path.
1229
+ const trimmed = sanitizeTerminalInput(value).trim();
1230
+ if (!trimmed)
1231
+ return;
1232
+ // Local commands first — never reach the gateway.
1233
+ if (trimmed === "/exit" || trimmed === "/quit") {
1234
+ client.close();
1235
+ tui.stop();
1236
+ restoreTerminal();
1237
+ process.exit(0);
1238
+ }
1239
+ if (trimmed === "/help") {
1240
+ editor.setText("");
1241
+ insertBeforeEditor(new Markdown(`${brand.dim("commands")}\n` +
1242
+ `- ${chalk.bold("/exit")} or ${chalk.bold("/quit")} — disconnect & quit\n` +
1243
+ `- ${chalk.bold("/help")} — this list\n` +
1244
+ `- ${chalk.bold("/model <id>")} — switch to a configured model on the gateway\n` +
1245
+ `- ${chalk.bold("/thinking <level>")} — set reasoning effort (off|minimal|low|medium|high|xhigh)\n` +
1246
+ `- ${chalk.bold("/compact")} — summarize older turns to free up context\n` +
1247
+ `- ${chalk.bold("/allow-all <on|off>")} — skip shell-approval prompts for this session (safety guards still apply)\n` +
1248
+ `- ${chalk.bold("/grant-skill <name> [--yes]")} — preview/approve a skill's declared commands so the agent runs them without asking\n` +
1249
+ `- ${chalk.bold("/revoke-skill <name>")} — remove a skill's granted commands\n` +
1250
+ `- ${chalk.bold("/abort")} — stop the in-flight turn\n` +
1251
+ `- ${chalk.bold("/usage")} — show token + cost totals for this session\n` +
1252
+ `- ${chalk.bold("/reasoning <on|off>")} — show/hide the model's thinking blocks before replies (default: off)\n` +
1253
+ `- ${chalk.bold("/agent [<id>]")} — show/bind the connection's active agent\n` +
1254
+ `- ${chalk.bold("/session [<key>]")} — show/bind the connection's active session\n` +
1255
+ `- ${chalk.bold("/agents")} — list every agent the gateway knows about\n` +
1256
+ `- ${chalk.bold("/sessions [--all]")} — list live sessions (bound agent or all)\n` +
1257
+ `- ${chalk.bold("/mute <id|key>")} — unsubscribe from an agent id or session key\n` +
1258
+ `- ${chalk.bold("/memory")} — list recent memories\n` +
1259
+ `- ${chalk.bold("/memory search <q>")} — search memories by keyword\n` +
1260
+ `- ${chalk.bold("/memory inspect <id>")} — show a single memory by id prefix\n` +
1261
+ `- ${chalk.bold("/memory stats")} — show memory counts by segment / origin\n` +
1262
+ `- ${chalk.bold("/org")} — show the Pride hierarchy chart (Higher Office / Departments)\n` +
1263
+ `- ${chalk.bold("/org <agent-id>")} — show a sub-tree of the chart\n` +
1264
+ `- ${chalk.bold("/org --departments")} — chart without the Higher Office block\n` +
1265
+ `- ${chalk.bold("/org --explain <from> <to>")} — why this edge exists (or does not)\n` +
1266
+ `- ${chalk.bold("Ctrl+C")} — abort the current turn (same as /abort)\n` +
1267
+ `- ${chalk.bold("Ctrl+D")} — quit\n\n` +
1268
+ brand.dim("To add a new provider, run `brigade onboard` on the gateway machine."), 1, 0, markdownTheme));
1269
+ return;
1270
+ }
1271
+ // /session [key] — print or rebind the connection's bound session key.
1272
+ // Wave K — without this the TUI can only steer/abort/compact the boot
1273
+ // agent's `main` lane. With `/session agent:main:whatsapp:<jid>` an
1274
+ // operator can intervene in a runaway channel turn from the TUI.
1275
+ // No-arg form prints the current binding.
1276
+ if (trimmed === "/session" || trimmed.startsWith("/session ")) {
1277
+ editor.setText("");
1278
+ const arg = trimmed === "/session" ? "" : trimmed.slice("/session ".length).trim();
1279
+ if (!arg) {
1280
+ const cur = boundSessionKey ?? lastSnapshot?.sessionKey ?? "(unset)";
1281
+ insertBeforeEditor(new Text(` ${brand.dim("bound session:")} ${brand.amber(cur)}`, 0, 0));
1282
+ return;
1283
+ }
1284
+ boundSessionKey = arg;
1285
+ insertBeforeEditor(new Text(` ${brand.amber("✓")} ${brand.dim("bound to session")} ${brand.amber(arg)}`, 0, 0));
1286
+ updateHeader();
1287
+ void applySubscription();
1288
+ return;
1289
+ }
1290
+ // /agents — list every agent the gateway has runtime state for.
1291
+ // Wave N5 (bug #9). Pulls from the gateway via `agents.list` so the
1292
+ // list is always source-of-truth (no client-side mirror to fall out
1293
+ // of sync with set-model writes). The currently-bound agent is
1294
+ // flagged with a `←` so the operator can tell at a glance which
1295
+ // agent their typing currently targets.
1296
+ if (trimmed === "/agents") {
1297
+ editor.setText("");
1298
+ let agents;
1299
+ try {
1300
+ agents = await client.request("agents.list");
1301
+ }
1302
+ catch (err) {
1303
+ insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.error(err instanceof Error ? err.message : String(err))}`, 0, 0));
1304
+ return;
1305
+ }
1306
+ if (agents.length === 0) {
1307
+ insertBeforeEditor(new Text(` ${brand.dim("no agents configured on the gateway")}`, 0, 0));
1308
+ return;
1309
+ }
1310
+ const bound = boundAgentId ?? lastSnapshot?.agentId;
1311
+ const lines = agents.map((a) => {
1312
+ const here = a.id === bound ? " " + brand.amber("← bound") : "";
1313
+ const bootTag = a.isBoot ? " " + brand.dim("(boot)") : "";
1314
+ const persona = a.personaName ? " " + brand.dim(`· ${a.personaName}`) : "";
1315
+ return ` ${brand.white(a.id)}${persona} ${brand.dim(`${a.provider} · ${a.modelId}`)}${bootTag}${here}`;
1316
+ });
1317
+ insertBeforeEditor(new Markdown(`${brand.dim("agents on the gateway:")}\n${lines.join("\n")}\n\n${brand.dim("usage: /agent <id> to bind")}`, 1, 0, markdownTheme));
1318
+ return;
1319
+ }
1320
+ // /sessions [--all] — list live (in-flight Pi) sessions. Defaults to
1321
+ // the bound agent's sessions; `--all` returns every agent's. Wave N5
1322
+ // (bug #9). Combine with /session <key> to bind to one of them.
1323
+ if (trimmed === "/sessions" || trimmed.startsWith("/sessions ")) {
1324
+ editor.setText("");
1325
+ const arg = trimmed === "/sessions" ? "" : trimmed.slice("/sessions ".length).trim();
1326
+ const wantsAll = /\b--?all\b/i.test(arg);
1327
+ let sessions;
1328
+ try {
1329
+ const params = wantsAll
1330
+ ? { all: true }
1331
+ : boundAgentId !== undefined
1332
+ ? { agentId: boundAgentId }
1333
+ : {};
1334
+ sessions = await client.request("sessions.list", params);
1335
+ }
1336
+ catch (err) {
1337
+ insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.error(err instanceof Error ? err.message : String(err))}`, 0, 0));
1338
+ return;
1339
+ }
1340
+ if (sessions.length === 0) {
1341
+ const scope = wantsAll
1342
+ ? "no live sessions on the gateway"
1343
+ : `no live sessions for agent ${boundAgentId ?? lastSnapshot?.agentId ?? "main"}`;
1344
+ insertBeforeEditor(new Text(` ${brand.dim(scope)} ${brand.dim("(turns run between requests — try again during one)")}`, 0, 0));
1345
+ return;
1346
+ }
1347
+ const boundKey = boundSessionKey ?? lastSnapshot?.sessionKey;
1348
+ const lines = sessions.map((s) => {
1349
+ const friendly = formatSessionLabel(s.sessionKey) ?? brand.dim("(home)");
1350
+ const here = s.sessionKey === boundKey ? " " + brand.amber("← bound") : "";
1351
+ return ` ${brand.white(s.agentId)} ${friendly} ${brand.dim(s.sessionKey)}${here}`;
1352
+ });
1353
+ const scopeLine = wantsAll
1354
+ ? "live sessions (all agents):"
1355
+ : `live sessions for agent ${boundAgentId ?? lastSnapshot?.agentId ?? "main"}:`;
1356
+ insertBeforeEditor(new Markdown(`${brand.dim(scopeLine)}\n${lines.join("\n")}\n\n${brand.dim("usage: /session <key> to bind · /mute <id|key> to unsubscribe")}`, 1, 0, markdownTheme));
1357
+ return;
1358
+ }
1359
+ // /mute <id> — drop a subscription on the gateway. Accepts EITHER
1360
+ // an agentId (e.g. `ops`) or a full sessionKey (e.g.
1361
+ // `agent:main:whatsapp:direct:+91…`). Heuristic: anything starting
1362
+ // with `agent:` is treated as a sessionKey; everything else is an
1363
+ // agentId. Wave N5 (bug #9). Wires to the existing `unsubscribe`
1364
+ // RPC so the per-conn filter (server.ts:861-882) stops delivering
1365
+ // frames tagged with that lane to this connection.
1366
+ if (trimmed === "/mute" || trimmed.startsWith("/mute ")) {
1367
+ editor.setText("");
1368
+ const arg = trimmed === "/mute" ? "" : trimmed.slice("/mute ".length).trim();
1369
+ if (!arg) {
1370
+ insertBeforeEditor(new Text(` ${brand.dim("usage: /mute <agent-id|session-key>")}`, 0, 0));
1371
+ return;
1372
+ }
1373
+ const isSessionKey = arg.toLowerCase().startsWith("agent:");
1374
+ const params = isSessionKey
1375
+ ? { sessionId: arg }
1376
+ : { agentId: arg };
1377
+ try {
1378
+ await client.request("unsubscribe", params);
1379
+ // Keep our local lastSubscribed* mirror honest so a later
1380
+ // applySubscription() doesn't try to undo a subscribe we just
1381
+ // muted — only clear the mirror entry that matches the muted lane.
1382
+ if (isSessionKey && lastSubscribedSessionKey === arg) {
1383
+ lastSubscribedSessionKey = undefined;
1384
+ }
1385
+ if (!isSessionKey && lastSubscribedAgentId === arg) {
1386
+ lastSubscribedAgentId = undefined;
1387
+ }
1388
+ const kind = isSessionKey ? "session" : "agent";
1389
+ insertBeforeEditor(new Text(` ${brand.amber("✓")} ${brand.dim(`muted ${kind}`)} ${brand.amber(arg)}`, 0, 0));
1390
+ }
1391
+ catch (err) {
1392
+ const msg = err instanceof Error ? err.message : String(err);
1393
+ insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.error(msg)}`, 0, 0));
1394
+ }
1395
+ return;
1396
+ }
1397
+ // /agent [id] — print or rebind the connection's bound agent. When the
1398
+ // gateway runs multi-agent (cfg.agents.<id> with per-agent runtime),
1399
+ // the operator uses this to switch which agent their typing targets
1400
+ // without reconnecting. No-arg form prints the current binding.
1401
+ if (trimmed === "/agent" || trimmed.startsWith("/agent ")) {
1402
+ editor.setText("");
1403
+ const arg = trimmed === "/agent" ? "" : trimmed.slice("/agent ".length).trim();
1404
+ if (!arg) {
1405
+ const cur = boundAgentId ?? lastSnapshot?.agentId ?? "(unset)";
1406
+ insertBeforeEditor(new Text(` ${brand.dim("bound agent:")} ${brand.amber(cur)}`, 0, 0));
1407
+ return;
1408
+ }
1409
+ let known;
1410
+ try {
1411
+ known = await client.request("agents.list");
1412
+ }
1413
+ catch (err) {
1414
+ insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.error(`agents.list failed: ${err instanceof Error ? err.message : String(err)}`)}`, 0, 0));
1415
+ return;
1416
+ }
1417
+ if (!known.some((a) => a.id === arg)) {
1418
+ const available = known.map((a) => a.id).join(", ") || "(none)";
1419
+ insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.error(`unknown agent "${arg}"`)}\n ${brand.dim(`available: ${available}`)}\n ${brand.dim("usage: /agent <id> — try /agents to see the full list")}`, 0, 0));
1420
+ return;
1421
+ }
1422
+ boundAgentId = arg;
1423
+ insertBeforeEditor(new Text(` ${brand.amber("✓")} ${brand.dim("bound to agent")} ${brand.amber(arg)}`, 0, 0));
1424
+ updateHeader();
1425
+ void applySubscription();
1426
+ return;
1427
+ }
1428
+ // /org — Pride hierarchy chart. Calls the gateway's `org.snapshot`
1429
+ // RPC and renders the result inline. Four shapes:
1430
+ // /org → full chart (pre-rendered ANSI+emoji)
1431
+ // /org <agent-id> → re-render the subtree rooted at <id>
1432
+ // /org --departments → re-render without Higher Office
1433
+ // /org --explain <from> <to> → derived-graph edge explain
1434
+ // When cfg.org is absent the gateway returns ok=false with the
1435
+ // flat-crew redirect note; we print it verbatim (no chart frame).
1436
+ if (trimmed === "/org" || trimmed.startsWith("/org ")) {
1437
+ editor.setText("");
1438
+ const rawArgs = trimmed === "/org" ? "" : trimmed.slice("/org ".length);
1439
+ const parsed = parseOrgSlash(rawArgs);
1440
+ if (parsed.kind === "error") {
1441
+ insertBeforeEditor(new Text(` ${brand.dim(parsed.message)}`, 0, 0));
1442
+ return;
1443
+ }
1444
+ let snap;
1445
+ try {
1446
+ snap = await client.request("org.snapshot");
1447
+ }
1448
+ catch (err) {
1449
+ const msg = err instanceof Error ? err.message : String(err);
1450
+ insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.error(msg)}`, 0, 0));
1451
+ return;
1452
+ }
1453
+ if (snap.ok === false) {
1454
+ insertBeforeEditor(new Markdown(snap.redirect, 1, 0, markdownTheme));
1455
+ return;
1456
+ }
1457
+ const graph = snap.graph;
1458
+ // Read department-head pins from the snapshot graph caller side
1459
+ // is fine for re-renders — the gateway already applied them
1460
+ // when computing the pre-rendered `charts.tui` for the happy
1461
+ // path. For client-side re-render branches (subtree /
1462
+ // departments) we just pass `undefined` since the pin map
1463
+ // isn't carried in the snapshot response today. The most-
1464
+ // senior fallback path inside `flattenToThreeTiers` still
1465
+ // produces a sensible chart.
1466
+ const pins = undefined;
1467
+ if (parsed.kind === "show") {
1468
+ // Pre-shape: ensure the trailing footer rule sits on its
1469
+ // own line so the rendered Markdown widget doesn't collapse
1470
+ // it into the previous block.
1471
+ let body = snap.charts.tui;
1472
+ if (!body.endsWith("\n"))
1473
+ body += "\n";
1474
+ if (!body.includes(BRIGADE_FOOTER_RULE + "\n")) {
1475
+ body = body.replace(BRIGADE_FOOTER_RULE, BRIGADE_FOOTER_RULE + "\n");
1476
+ }
1477
+ insertBeforeEditor(new Text(body, 0, 0));
1478
+ return;
1479
+ }
1480
+ if (parsed.kind === "explain") {
1481
+ const outcome = computeExplain(graph, parsed.from, parsed.to);
1482
+ insertBeforeEditor(new Text(formatExplain(outcome), 0, 0));
1483
+ return;
1484
+ }
1485
+ if (parsed.kind === "subtree") {
1486
+ const filtered = filterGraphToSubtree(graph, parsed.agentId);
1487
+ if (!filtered) {
1488
+ insertBeforeEditor(new Text(` ${brand.error(`✗ Unknown agent "${parsed.agentId}". Run /org to see the full chart.`)}`, 0, 0));
1489
+ return;
1490
+ }
1491
+ const body = renderPrideChartWithPins(filtered, pins, {
1492
+ emoji: true,
1493
+ ansi: true,
1494
+ });
1495
+ let withFooter = body;
1496
+ if (!withFooter.endsWith("\n"))
1497
+ withFooter += "\n";
1498
+ if (!withFooter.includes(BRIGADE_FOOTER_RULE + "\n")) {
1499
+ withFooter = withFooter.replace(BRIGADE_FOOTER_RULE, BRIGADE_FOOTER_RULE + "\n");
1500
+ }
1501
+ insertBeforeEditor(new Text(withFooter, 0, 0));
1502
+ return;
1503
+ }
1504
+ // parsed.kind === "departments"
1505
+ const body = renderDepartmentsOnly(graph, pins, {
1506
+ emoji: true,
1507
+ ansi: true,
1508
+ });
1509
+ let withFooter = body;
1510
+ if (!withFooter.endsWith("\n"))
1511
+ withFooter += "\n";
1512
+ if (!withFooter.includes(BRIGADE_FOOTER_RULE + "\n")) {
1513
+ withFooter = withFooter.replace(BRIGADE_FOOTER_RULE, BRIGADE_FOOTER_RULE + "\n");
1514
+ }
1515
+ insertBeforeEditor(new Text(withFooter, 0, 0));
1516
+ return;
1517
+ }
1518
+ // /abort — explicit slash-form for the same action Ctrl+C performs.
1519
+ // Returning true from `handle.abort()` means a turn was running; the
1520
+ // chat loop's SIGINT path uses the same primitive.
1521
+ if (trimmed === "/abort") {
1522
+ editor.setText("");
1523
+ if (!isAgentRunning) {
1524
+ insertBeforeEditor(new Text(` ${brand.dim("nothing to abort — agent is idle")}`, 0, 0));
1525
+ return;
1526
+ }
1527
+ try {
1528
+ await client.request("abort", withBinding());
1529
+ insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.dim("aborted")}`, 0, 0));
1530
+ }
1531
+ catch (err) {
1532
+ const msg = err instanceof Error ? err.message : String(err);
1533
+ insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.error(msg)}`, 0, 0));
1534
+ }
1535
+ return;
1536
+ }
1537
+ // /reasoning [on|off] — toggle whether the assistant's thinking blocks
1538
+ // render before each reply. Pi pushes thinking via `pi` events
1539
+ // regardless; this is purely a local view filter applied in
1540
+ // `extractAssistantText`.
1541
+ if (trimmed === "/memory" || trimmed.startsWith("/memory ")) {
1542
+ editor.setText("");
1543
+ const rest = trimmed.slice("/memory".length).trim();
1544
+ const sp = rest.indexOf(" ");
1545
+ const verb = (sp === -1 ? rest : rest.slice(0, sp)).toLowerCase();
1546
+ const arg = sp === -1 ? "" : rest.slice(sp + 1).trim();
1547
+ let action = "list";
1548
+ let query;
1549
+ let memoryId;
1550
+ if (verb === "search") {
1551
+ action = "search";
1552
+ query = arg;
1553
+ }
1554
+ else if (verb === "inspect") {
1555
+ action = "inspect";
1556
+ memoryId = arg;
1557
+ }
1558
+ else if (verb === "stats") {
1559
+ action = "stats";
1560
+ }
1561
+ else if (verb === "list" || verb === "") {
1562
+ action = "list";
1563
+ }
1564
+ else {
1565
+ // bare "/memory <terms>" → treat the whole thing as a search
1566
+ action = "search";
1567
+ query = rest;
1568
+ }
1569
+ try {
1570
+ const res = (await client.request("memory-query", {
1571
+ ...withBinding(),
1572
+ action,
1573
+ ...(query ? { query } : {}),
1574
+ ...(memoryId ? { memoryId } : {}),
1575
+ }));
1576
+ const lines = [];
1577
+ if (res.action === "stats" && res.stats) {
1578
+ const s = res.stats;
1579
+ const segs = Object.entries(s.bySegment)
1580
+ .sort((a, b) => b[1] - a[1])
1581
+ .map(([k, v]) => `${k} ${v}`)
1582
+ .join(", ");
1583
+ lines.push(` memory — ${s.active} active (${s.total} total, ${s.archived} archived)`);
1584
+ lines.push(` by segment: ${segs || "—"}`);
1585
+ lines.push(` by origin: owner ${s.owner}, channel ${s.channel} · added last 7d: ${s.addedLast7d}`);
1586
+ }
1587
+ else if (res.facts.length === 0) {
1588
+ lines.push(" (no matching memories)");
1589
+ }
1590
+ else {
1591
+ res.facts.forEach((f, i) => {
1592
+ const sc = f.score !== undefined ? ` ·${f.score}` : "";
1593
+ const lifecycleTag = f.lifecycle && f.lifecycle !== "active"
1594
+ ? ` ${brand.dim(`[${f.lifecycle}]`)}`
1595
+ : "";
1596
+ lines.push(` ${i + 1}. ${f.content}${lifecycleTag}`);
1597
+ lines.push(` ${f.segment} · ${f.origin} · ${f.memoryId}${sc}`);
1598
+ });
1599
+ }
1600
+ insertBeforeEditor(new Text(`${lines.join("\n")}\n`, 0, 0));
1601
+ }
1602
+ catch (err) {
1603
+ insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.error(err instanceof Error ? err.message : String(err))}`, 0, 0));
1604
+ }
1605
+ return;
1606
+ }
1607
+ if (trimmed === "/reasoning" || trimmed.startsWith("/reasoning ")) {
1608
+ editor.setText("");
1609
+ const arg = trimmed === "/reasoning" ? "" : trimmed.slice("/reasoning ".length).trim().toLowerCase();
1610
+ if (arg === "on" || arg === "true" || arg === "1") {
1611
+ showThinking = true;
1612
+ }
1613
+ else if (arg === "off" || arg === "false" || arg === "0") {
1614
+ showThinking = false;
1615
+ }
1616
+ else if (arg.length === 0 || arg === "toggle") {
1617
+ showThinking = !showThinking;
1618
+ }
1619
+ else {
1620
+ insertBeforeEditor(new Text(` ${brand.dim("usage: /reasoning <on|off>")}`, 0, 0));
1621
+ return;
1622
+ }
1623
+ insertBeforeEditor(new Text(` ${brand.dim(showThinking ? "reasoning: on (model thinking will render before each reply)" : "reasoning: off")}`, 0, 0));
1624
+ return;
1625
+ }
1626
+ // /usage — render the cumulative usage block from the latest state
1627
+ // snapshot. All fields come from the server's SessionStateSnapshot
1628
+ // — no extra RPC needed.
1629
+ if (trimmed === "/usage") {
1630
+ editor.setText("");
1631
+ const snap = lastSnapshot;
1632
+ if (!snap) {
1633
+ insertBeforeEditor(new Text(` ${brand.dim("no usage yet — server hasn't sent a state snapshot")}`, 0, 0));
1634
+ return;
1635
+ }
1636
+ const tokenIn = snap.totalTokensIn.toLocaleString();
1637
+ const tokenOut = snap.totalTokensOut.toLocaleString();
1638
+ const tokenTotal = (snap.totalTokensIn + snap.totalTokensOut).toLocaleString();
1639
+ const costStr = snap.totalCostUsd > 0 ? `$${snap.totalCostUsd.toFixed(4)}` : "$0.0000";
1640
+ const ctxStr = snap.contextUsagePercent != null ? `${Math.round(snap.contextUsagePercent)}%` : "—";
1641
+ insertBeforeEditor(new Markdown(`${brand.dim("usage")}\n` +
1642
+ `- ${chalk.bold("model:")} ${snap.provider ?? "?"} · ${snap.modelId ?? "?"}\n` +
1643
+ `- ${chalk.bold("turns:")} ${snap.messageCount}\n` +
1644
+ `- ${chalk.bold("tokens:")} ${tokenIn} in · ${tokenOut} out · ${tokenTotal} total\n` +
1645
+ `- ${chalk.bold("cost:")} ${costStr}\n` +
1646
+ `- ${chalk.bold("context:")} ${ctxStr} used\n` +
1647
+ `- ${chalk.bold("thinking:")} ${snap.thinkingLevel}` +
1648
+ (snap.supportsThinking
1649
+ ? brand.dim(` (available: ${snap.availableThinkingLevels.join(", ")})`)
1650
+ : brand.dim(" (model doesn't support reasoning)")), 1, 0, markdownTheme));
1651
+ return;
1652
+ }
1653
+ // Mid-turn submit → STEER. The gateway has the same Pi semantics; queueing
1654
+ // the message lets the model see it on the next iteration without abort.
1655
+ if (isAgentRunning) {
1656
+ editor.setText("");
1657
+ try {
1658
+ await client.request("steer", withBinding({ text: trimmed }));
1659
+ insertBeforeEditor(new Markdown(`${brand.user("you")} ${trimmed}`, 1, 0, markdownTheme));
1660
+ insertBeforeEditor(new Text(` ${brand.dim("↳ queued — the model will see this on its next turn")}`, 0, 0));
1661
+ }
1662
+ catch (err) {
1663
+ const msg = err instanceof Error ? err.message : String(err);
1664
+ if (msg.includes("nothing to steer")) {
1665
+ // Stale busy flag — our lane has no live turn (it ended a beat
1666
+ // ago, or the busy signal came from another session before the
1667
+ // one-way snapshot rule existed). The operator's message must
1668
+ // never be lost: clear the flag and send it as a normal prompt.
1669
+ isAgentRunning = false;
1670
+ insertBeforeEditor(new Markdown(`${brand.user("you")} ${trimmed}`, 1, 0, markdownTheme));
1671
+ try {
1672
+ lastUserPrompt = trimmed; // remember it as the replay message for a later `/switch` (Carrow) handoff
1673
+ await client.request("prompt", withBinding({ text: trimmed }), { timeoutMs: 0 });
1674
+ }
1675
+ catch (err2) {
1676
+ const msg2 = err2 instanceof Error ? err2.message : String(err2);
1677
+ insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.error(msg2)}`, 0, 0));
1678
+ }
1679
+ return;
1680
+ }
1681
+ insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.error(msg)}`, 0, 0));
1682
+ }
1683
+ return;
1684
+ }
1685
+ // /compact — same long-run rationale as `prompt` above; compaction
1686
+ // can take a while on a big transcript, beyond the default 60s.
1687
+ if (trimmed === "/compact") {
1688
+ editor.setText("");
1689
+ insertBeforeEditor(new Text(` ${brand.dim("Compacting…")}`, 0, 0));
1690
+ try {
1691
+ await client.request("compact", withBinding(), { timeoutMs: 0 });
1692
+ insertBeforeEditor(new Text(` ${brand.amber("✓")} ${brand.dim("Compacted")}`, 0, 0));
1693
+ }
1694
+ catch (err) {
1695
+ const msg = err instanceof Error ? err.message : String(err);
1696
+ insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.error(`Compaction failed: ${msg}`)}`, 0, 0));
1697
+ }
1698
+ return;
1699
+ }
1700
+ // /allow-all <on|off> — arm/disarm session-scoped exec approval bypass.
1701
+ // Skips the shell-approval PROMPT for this session only; it can't bypass
1702
+ // the config/path-write guards or hard-deny patterns, and clears on
1703
+ // gateway restart.
1704
+ if (trimmed === "/allow-all" || trimmed.startsWith("/allow-all ")) {
1705
+ editor.setText("");
1706
+ const arg = trimmed === "/allow-all" ? "" : trimmed.slice("/allow-all ".length).trim().toLowerCase();
1707
+ if (arg !== "on" && arg !== "off") {
1708
+ insertBeforeEditor(new Markdown(`${brand.dim("usage: /allow-all on|off")}\n` +
1709
+ `Skips the shell-approval prompt for THIS session. It can't bypass the safety ` +
1710
+ `guards (writes to brigade.json / encryption.key / auth, hard-deny patterns), ` +
1711
+ `doesn't affect sub-agents, and clears on gateway restart.`, 1, 0, markdownTheme));
1712
+ return;
1713
+ }
1714
+ const enabled = arg === "on";
1715
+ try {
1716
+ const res = (await client.request("exec-allow-all", { ...withBinding(), enabled }));
1717
+ insertBeforeEditor(new Text(enabled
1718
+ ? ` ${brand.amber("⚠")} ${brand.dim(`allow-all ON for ${res?.sessionKey ?? "this session"} — shell commands run without asking (safety guards still apply). /allow-all off to disarm.`)}`
1719
+ : ` ${brand.amber("✓")} ${brand.dim("allow-all OFF — shell commands prompt for approval again.")}`, 0, 0));
1720
+ }
1721
+ catch (err) {
1722
+ const msg = err instanceof Error ? err.message : String(err);
1723
+ insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.error(`allow-all failed: ${msg}`)}`, 0, 0));
1724
+ }
1725
+ return;
1726
+ }
1727
+ // /grant-skill <name> [--yes] — preview (default) or apply a skill's
1728
+ // command grant. Preview shows the commands the skill declares; --yes
1729
+ // pre-approves them so the agent runs its own skill without prompting.
1730
+ // The grant is a SNAPSHOT — editing the skill later can't widen it.
1731
+ if (trimmed === "/grant-skill" || trimmed.startsWith("/grant-skill ")) {
1732
+ editor.setText("");
1733
+ const rest = trimmed === "/grant-skill" ? "" : trimmed.slice("/grant-skill ".length).trim();
1734
+ const apply = /(^|\s)(--yes|-y)(\s|$)/.test(rest);
1735
+ const name = rest.replace(/(^|\s)(--yes|-y)(\s|$)/g, " ").trim();
1736
+ if (!name) {
1737
+ insertBeforeEditor(new Markdown(`${brand.dim("usage: /grant-skill <name> [--yes]")}\n` +
1738
+ `Preview the shell commands a skill declares; add ${chalk.bold("--yes")} to pre-approve ` +
1739
+ `them for this agent so it stops asking. A grant is a snapshot — editing the skill ` +
1740
+ `later won't widen it. Revoke with /revoke-skill.`, 1, 0, markdownTheme));
1741
+ return;
1742
+ }
1743
+ try {
1744
+ const res = (await client.request("exec-grant-skill", {
1745
+ ...withBinding(),
1746
+ skillName: name,
1747
+ apply,
1748
+ }));
1749
+ if (!res?.found) {
1750
+ insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.error(`No skill named "${name}" is visible to this agent.`)}`, 0, 0));
1751
+ return;
1752
+ }
1753
+ if (res.emptyManifest) {
1754
+ insertBeforeEditor(new Markdown(`${brand.dim(`Skill "${res.skill}" declares no commands to grant.`)}\n` +
1755
+ `Add a ${chalk.bold("commands:")} / ${chalk.bold("command-patterns:")} block to its SKILL.md ` +
1756
+ `frontmatter, then re-run.`, 1, 0, markdownTheme));
1757
+ return;
1758
+ }
1759
+ const manifest = res.manifest ?? { commands: [], patterns: [] };
1760
+ const lines = [
1761
+ ...manifest.commands.map((c) => ` • ${c}`),
1762
+ ...manifest.patterns.map((p) => ` ~ /${p}/`),
1763
+ ].join("\n");
1764
+ if (res.applied) {
1765
+ const granted = res.granted ?? { commands: [], patterns: [] };
1766
+ const n = granted.commands.length + granted.patterns.length;
1767
+ const refused = res.refused && res.refused.length > 0
1768
+ ? `\n${brand.amber("refused (hard-deny):")} ${res.refused.join(", ")}`
1769
+ : "";
1770
+ insertBeforeEditor(new Markdown(`${brand.amber("✓")} Granted ${n} command(s) from ${chalk.bold(res.skill ?? name)} — ` +
1771
+ `the agent can now run them without prompting.\n${lines}${refused}\n` +
1772
+ `${brand.dim(`Revoke with /revoke-skill ${res.skill ?? name}`)}`, 1, 0, markdownTheme));
1773
+ }
1774
+ else {
1775
+ insertBeforeEditor(new Markdown(`${chalk.bold(res.skill ?? name)} declares these commands:\n${lines}\n\n` +
1776
+ `${brand.dim(`Approve them with: /grant-skill ${res.skill ?? name} --yes`)}`, 1, 0, markdownTheme));
1777
+ }
1778
+ }
1779
+ catch (err) {
1780
+ const msg = err instanceof Error ? err.message : String(err);
1781
+ insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.error(`grant-skill failed: ${msg}`)}`, 0, 0));
1782
+ }
1783
+ return;
1784
+ }
1785
+ // /revoke-skill <name> — remove a skill's granted commands from the allowlist.
1786
+ if (trimmed === "/revoke-skill" || trimmed.startsWith("/revoke-skill ")) {
1787
+ editor.setText("");
1788
+ const name = trimmed === "/revoke-skill" ? "" : trimmed.slice("/revoke-skill ".length).trim();
1789
+ if (!name) {
1790
+ insertBeforeEditor(new Markdown(`${brand.dim("usage: /revoke-skill <name>")}`, 1, 0, markdownTheme));
1791
+ return;
1792
+ }
1793
+ try {
1794
+ const res = (await client.request("exec-grant-skill", {
1795
+ ...withBinding(),
1796
+ skillName: name,
1797
+ revoke: true,
1798
+ }));
1799
+ if (!res?.found) {
1800
+ insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.error(`No skill named "${name}" is visible to this agent.`)}`, 0, 0));
1801
+ return;
1802
+ }
1803
+ insertBeforeEditor(new Text(` ${brand.amber("✓")} ${brand.dim(`Revoked ${res.removed ?? 0} approval(s) from skill "${res.skill ?? name}".`)}`, 0, 0));
1804
+ }
1805
+ catch (err) {
1806
+ const msg = err instanceof Error ? err.message : String(err);
1807
+ insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.error(`revoke-skill failed: ${msg}`)}`, 0, 0));
1808
+ }
1809
+ return;
1810
+ }
1811
+ // /model <id> — switch by id (the gateway resolves provider via its registry)
1812
+ if (trimmed === "/model" || trimmed.startsWith("/model ")) {
1813
+ editor.setText("");
1814
+ let models;
1815
+ try {
1816
+ models = await client.request("list-models");
1817
+ }
1818
+ catch (err) {
1819
+ insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.error(err instanceof Error ? err.message : String(err))}`, 0, 0));
1820
+ return;
1821
+ }
1822
+ const arg = trimmed === "/model" ? "" : trimmed.slice("/model ".length).trim();
1823
+ if (!arg) {
1824
+ const list = models
1825
+ .map((m) => ` ${brand.dim(m.provider)} ${brand.white(m.id)}`)
1826
+ .join("\n");
1827
+ insertBeforeEditor(new Markdown(`${brand.dim("configured models on the gateway:")}\n${list}\n\n${brand.dim("usage: /model <id>")}`, 1, 0, markdownTheme));
1828
+ return;
1829
+ }
1830
+ // Prefer current provider on tie.
1831
+ const currentProvider = lastSnapshot?.provider;
1832
+ const matches = models.filter((m) => m.id === arg);
1833
+ const target = matches.find((m) => m.provider === currentProvider) ?? matches[0];
1834
+ if (!target) {
1835
+ insertBeforeEditor(new Text(` ${brand.error(`✗ no model with id "${arg}" on the gateway.`)}`, 0, 0));
1836
+ return;
1837
+ }
1838
+ try {
1839
+ await client.request("set-model", withBinding({ provider: target.provider, modelId: target.id }));
1840
+ insertBeforeEditor(new Text(` ${brand.amber("✓")} ${brand.dim("switched to")} ${brand.white(`${target.provider} · ${target.id}`)}`, 0, 0));
1841
+ }
1842
+ catch (err) {
1843
+ const msg = err instanceof Error ? err.message : String(err);
1844
+ insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.error(msg)}`, 0, 0));
1845
+ }
1846
+ return;
1847
+ }
1848
+ // /switch <id> — Carrow cross-model handoff (vs /model = next turn): aborts an
1849
+ // in-flight gateway turn, swaps the model, and REPLAYS your last message on the
1850
+ // new one so the conversation continues across models. Idle ⇒ just sets the model.
1851
+ if (trimmed === "/switch" || trimmed.startsWith("/switch ")) {
1852
+ editor.setText("");
1853
+ const arg = trimmed === "/switch" ? "" : trimmed.slice("/switch ".length).trim();
1854
+ if (!arg) {
1855
+ insertBeforeEditor(new Markdown(`${brand.dim("usage: /switch <id> — Carrow mid-turn handoff (vs /model = next turn)")}`, 1, 0, markdownTheme));
1856
+ return;
1857
+ }
1858
+ let switchModels;
1859
+ try {
1860
+ switchModels = await client.request("list-models");
1861
+ }
1862
+ catch (err) {
1863
+ insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.error(err instanceof Error ? err.message : String(err))}`, 0, 0));
1864
+ return;
1865
+ }
1866
+ const switchMatches = switchModels.filter((m) => m.id === arg);
1867
+ const switchTarget = switchMatches.find((m) => m.provider === lastSnapshot?.provider) ?? switchMatches[0];
1868
+ if (!switchTarget) {
1869
+ insertBeforeEditor(new Text(` ${brand.error(`✗ no model with id "${arg}" on the gateway.`)}`, 0, 0));
1870
+ return;
1871
+ }
1872
+ try {
1873
+ await client.request("switch-model-mid-turn", withBinding({ provider: switchTarget.provider, modelId: switchTarget.id, replayMessage: lastUserPrompt }));
1874
+ insertBeforeEditor(new Text(` ${brand.amber("✓")} ${brand.dim("Carrow handoff →")} ${brand.white(`${switchTarget.provider} · ${switchTarget.id}`)}`, 0, 0));
1875
+ }
1876
+ catch (err) {
1877
+ insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.error(err instanceof Error ? err.message : String(err))}`, 0, 0));
1878
+ }
1879
+ return;
1880
+ }
1881
+ // /thinking [level]
1882
+ if (trimmed === "/thinking" || trimmed.startsWith("/thinking ")) {
1883
+ editor.setText("");
1884
+ const arg = trimmed === "/thinking" ? "" : trimmed.slice("/thinking ".length).trim().toLowerCase();
1885
+ if (!arg) {
1886
+ const cur = lastSnapshot?.thinkingLevel ?? "?";
1887
+ const avail = lastSnapshot?.availableThinkingLevels ?? [];
1888
+ insertBeforeEditor(new Text(` ${brand.dim("thinking is")} ${brand.amber(cur)} ${brand.dim("· available:")} ${brand.dim(avail.join(" "))}`, 0, 0));
1889
+ return;
1890
+ }
1891
+ try {
1892
+ await client.request("set-thinking", withBinding({ level: arg }));
1893
+ insertBeforeEditor(new Text(` ${brand.amber("✓")} ${brand.dim("thinking set to")} ${brand.amber(arg)}`, 0, 0));
1894
+ }
1895
+ catch (err) {
1896
+ const msg = err instanceof Error ? err.message : String(err);
1897
+ insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.error(msg)}`, 0, 0));
1898
+ }
1899
+ return;
1900
+ }
1901
+ // Default — send as a prompt. Override timeout to 0 (disabled): the
1902
+ // SERVER bounds turn duration via the 6-layer wrapper chain (heartbeat,
1903
+ // stream-timeout, length-continuation). A client-side 60s cap would
1904
+ // reject WHILE the server keeps processing, producing silent state
1905
+ // desync — next user message would interleave with the in-flight reply.
1906
+ insertBeforeEditor(new Markdown(`${brand.user("you")} ${trimmed}`, 1, 0, markdownTheme));
1907
+ editor.setText("");
1908
+ try {
1909
+ // Carry the connection's bound agentId when set so the gateway
1910
+ // routes this turn to that agent's session lane + runtime entry.
1911
+ // Legacy single-agent gateways receive the same boot agent the
1912
+ // snapshot reported, so behaviour is unchanged.
1913
+ lastUserPrompt = trimmed; // remember it as the replay message for a later `/switch` (Carrow) handoff
1914
+ await client.request("prompt", withBinding({ text: trimmed }), { timeoutMs: 0 });
1915
+ }
1916
+ catch (err) {
1917
+ const msg = err instanceof Error ? err.message : String(err);
1918
+ insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.error(msg)}`, 0, 0));
1919
+ }
1920
+ };
1921
+ tui.requestRender();
1922
+ return {
1923
+ abort: () => {
1924
+ if (!isAgentRunning)
1925
+ return false;
1926
+ void client.request("abort", withBinding()).catch(() => { });
1927
+ isAgentRunning = false;
1928
+ agentStartedAt = null;
1929
+ editor.disableSubmit = false;
1930
+ if (activeLoader) {
1931
+ removeChild(activeLoader);
1932
+ activeLoader = null;
1933
+ }
1934
+ // Hygiene on abort: clear any in-flight tool indicators (they'll
1935
+ // never get a tool_execution_end now) and drop the assistant-
1936
+ // block pointer so the NEXT turn opens a fresh block instead of
1937
+ // appending to the aborted one's stale Markdown component.
1938
+ for (const indicator of pendingTools.values()) {
1939
+ removeChild(indicator);
1940
+ }
1941
+ pendingTools.clear();
1942
+ activeAssistants.clear();
1943
+ insertBeforeEditor(new Text(` ${brand.error("✗")} ${brand.dim("aborted")}`, 0, 0));
1944
+ updateHeader();
1945
+ return true;
1946
+ },
1947
+ close: async () => {
1948
+ client.close();
1949
+ },
1950
+ };
1951
+ }
1952
+ //# sourceMappingURL=connect.js.map