attocode 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (488) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/LICENSE +21 -0
  3. package/README.md +164 -0
  4. package/dist/src/adapters.d.ts +83 -0
  5. package/dist/src/adapters.d.ts.map +1 -0
  6. package/dist/src/adapters.js +221 -0
  7. package/dist/src/adapters.js.map +1 -0
  8. package/dist/src/agent-tools/index.d.ts +7 -0
  9. package/dist/src/agent-tools/index.d.ts.map +1 -0
  10. package/dist/src/agent-tools/index.js +8 -0
  11. package/dist/src/agent-tools/index.js.map +1 -0
  12. package/dist/src/agent-tools/lsp-file-tools.d.ts +33 -0
  13. package/dist/src/agent-tools/lsp-file-tools.d.ts.map +1 -0
  14. package/dist/src/agent-tools/lsp-file-tools.js +200 -0
  15. package/dist/src/agent-tools/lsp-file-tools.js.map +1 -0
  16. package/dist/src/agent.d.ts +667 -0
  17. package/dist/src/agent.d.ts.map +1 -0
  18. package/dist/src/agent.js +2824 -0
  19. package/dist/src/agent.js.map +1 -0
  20. package/dist/src/cli.d.ts +36 -0
  21. package/dist/src/cli.d.ts.map +1 -0
  22. package/dist/src/cli.js +176 -0
  23. package/dist/src/cli.js.map +1 -0
  24. package/dist/src/commands/handler.d.ts +22 -0
  25. package/dist/src/commands/handler.d.ts.map +1 -0
  26. package/dist/src/commands/handler.js +1320 -0
  27. package/dist/src/commands/handler.js.map +1 -0
  28. package/dist/src/commands/init.d.ts +7 -0
  29. package/dist/src/commands/init.d.ts.map +1 -0
  30. package/dist/src/commands/init.js +153 -0
  31. package/dist/src/commands/init.js.map +1 -0
  32. package/dist/src/commands/types.d.ts +70 -0
  33. package/dist/src/commands/types.d.ts.map +1 -0
  34. package/dist/src/commands/types.js +8 -0
  35. package/dist/src/commands/types.js.map +1 -0
  36. package/dist/src/config.d.ts +22 -0
  37. package/dist/src/config.d.ts.map +1 -0
  38. package/dist/src/config.js +25 -0
  39. package/dist/src/config.js.map +1 -0
  40. package/dist/src/core/index.d.ts +32 -0
  41. package/dist/src/core/index.d.ts.map +1 -0
  42. package/dist/src/core/index.js +35 -0
  43. package/dist/src/core/index.js.map +1 -0
  44. package/dist/src/core/process-handlers.d.ts +43 -0
  45. package/dist/src/core/process-handlers.d.ts.map +1 -0
  46. package/dist/src/core/process-handlers.js +117 -0
  47. package/dist/src/core/process-handlers.js.map +1 -0
  48. package/dist/src/core/protocol/bridge.d.ts +117 -0
  49. package/dist/src/core/protocol/bridge.d.ts.map +1 -0
  50. package/dist/src/core/protocol/bridge.js +149 -0
  51. package/dist/src/core/protocol/bridge.js.map +1 -0
  52. package/dist/src/core/protocol/index.d.ts +8 -0
  53. package/dist/src/core/protocol/index.d.ts.map +1 -0
  54. package/dist/src/core/protocol/index.js +8 -0
  55. package/dist/src/core/protocol/index.js.map +1 -0
  56. package/dist/src/core/protocol/types.d.ts +539 -0
  57. package/dist/src/core/protocol/types.d.ts.map +1 -0
  58. package/dist/src/core/protocol/types.js +149 -0
  59. package/dist/src/core/protocol/types.js.map +1 -0
  60. package/dist/src/core/queues/atomic-counter.d.ts +36 -0
  61. package/dist/src/core/queues/atomic-counter.d.ts.map +1 -0
  62. package/dist/src/core/queues/atomic-counter.js +46 -0
  63. package/dist/src/core/queues/atomic-counter.js.map +1 -0
  64. package/dist/src/core/queues/event-queue.d.ts +126 -0
  65. package/dist/src/core/queues/event-queue.d.ts.map +1 -0
  66. package/dist/src/core/queues/event-queue.js +208 -0
  67. package/dist/src/core/queues/event-queue.js.map +1 -0
  68. package/dist/src/core/queues/index.d.ts +12 -0
  69. package/dist/src/core/queues/index.d.ts.map +1 -0
  70. package/dist/src/core/queues/index.js +15 -0
  71. package/dist/src/core/queues/index.js.map +1 -0
  72. package/dist/src/core/queues/submission-queue.d.ts +116 -0
  73. package/dist/src/core/queues/submission-queue.d.ts.map +1 -0
  74. package/dist/src/core/queues/submission-queue.js +236 -0
  75. package/dist/src/core/queues/submission-queue.js.map +1 -0
  76. package/dist/src/costs/index.d.ts +22 -0
  77. package/dist/src/costs/index.d.ts.map +1 -0
  78. package/dist/src/costs/index.js +22 -0
  79. package/dist/src/costs/index.js.map +1 -0
  80. package/dist/src/costs/model-registry.d.ts +80 -0
  81. package/dist/src/costs/model-registry.d.ts.map +1 -0
  82. package/dist/src/costs/model-registry.js +237 -0
  83. package/dist/src/costs/model-registry.js.map +1 -0
  84. package/dist/src/costs/types.d.ts +50 -0
  85. package/dist/src/costs/types.d.ts.map +1 -0
  86. package/dist/src/costs/types.js +2 -0
  87. package/dist/src/costs/types.js.map +1 -0
  88. package/dist/src/defaults.d.ts +114 -0
  89. package/dist/src/defaults.d.ts.map +1 -0
  90. package/dist/src/defaults.js +457 -0
  91. package/dist/src/defaults.js.map +1 -0
  92. package/dist/src/first-run.d.ts +35 -0
  93. package/dist/src/first-run.d.ts.map +1 -0
  94. package/dist/src/first-run.js +94 -0
  95. package/dist/src/first-run.js.map +1 -0
  96. package/dist/src/hello.d.ts +2 -0
  97. package/dist/src/hello.d.ts.map +1 -0
  98. package/dist/src/hello.js +4 -0
  99. package/dist/src/hello.js.map +1 -0
  100. package/dist/src/integrations/agent-registry.d.ts +160 -0
  101. package/dist/src/integrations/agent-registry.d.ts.map +1 -0
  102. package/dist/src/integrations/agent-registry.js +446 -0
  103. package/dist/src/integrations/agent-registry.js.map +1 -0
  104. package/dist/src/integrations/auto-compaction.d.ts +177 -0
  105. package/dist/src/integrations/auto-compaction.d.ts.map +1 -0
  106. package/dist/src/integrations/auto-compaction.js +428 -0
  107. package/dist/src/integrations/auto-compaction.js.map +1 -0
  108. package/dist/src/integrations/cancellation.d.ts +162 -0
  109. package/dist/src/integrations/cancellation.d.ts.map +1 -0
  110. package/dist/src/integrations/cancellation.js +339 -0
  111. package/dist/src/integrations/cancellation.js.map +1 -0
  112. package/dist/src/integrations/codebase-context.d.ts +319 -0
  113. package/dist/src/integrations/codebase-context.d.ts.map +1 -0
  114. package/dist/src/integrations/codebase-context.js +816 -0
  115. package/dist/src/integrations/codebase-context.js.map +1 -0
  116. package/dist/src/integrations/compaction.d.ts +192 -0
  117. package/dist/src/integrations/compaction.d.ts.map +1 -0
  118. package/dist/src/integrations/compaction.js +376 -0
  119. package/dist/src/integrations/compaction.js.map +1 -0
  120. package/dist/src/integrations/context-engineering.d.ts +246 -0
  121. package/dist/src/integrations/context-engineering.d.ts.map +1 -0
  122. package/dist/src/integrations/context-engineering.js +394 -0
  123. package/dist/src/integrations/context-engineering.js.map +1 -0
  124. package/dist/src/integrations/diff-utils.d.ts +105 -0
  125. package/dist/src/integrations/diff-utils.d.ts.map +1 -0
  126. package/dist/src/integrations/diff-utils.js +497 -0
  127. package/dist/src/integrations/diff-utils.js.map +1 -0
  128. package/dist/src/integrations/economics.d.ts +192 -0
  129. package/dist/src/integrations/economics.d.ts.map +1 -0
  130. package/dist/src/integrations/economics.js +431 -0
  131. package/dist/src/integrations/economics.js.map +1 -0
  132. package/dist/src/integrations/execution-policy.d.ts +189 -0
  133. package/dist/src/integrations/execution-policy.d.ts.map +1 -0
  134. package/dist/src/integrations/execution-policy.js +352 -0
  135. package/dist/src/integrations/execution-policy.js.map +1 -0
  136. package/dist/src/integrations/file-change-tracker.d.ts +161 -0
  137. package/dist/src/integrations/file-change-tracker.d.ts.map +1 -0
  138. package/dist/src/integrations/file-change-tracker.js +520 -0
  139. package/dist/src/integrations/file-change-tracker.js.map +1 -0
  140. package/dist/src/integrations/hierarchical-config.d.ts +212 -0
  141. package/dist/src/integrations/hierarchical-config.d.ts.map +1 -0
  142. package/dist/src/integrations/hierarchical-config.js +484 -0
  143. package/dist/src/integrations/hierarchical-config.js.map +1 -0
  144. package/dist/src/integrations/hooks.d.ts +114 -0
  145. package/dist/src/integrations/hooks.d.ts.map +1 -0
  146. package/dist/src/integrations/hooks.js +326 -0
  147. package/dist/src/integrations/hooks.js.map +1 -0
  148. package/dist/src/integrations/ignore.d.ts +143 -0
  149. package/dist/src/integrations/ignore.d.ts.map +1 -0
  150. package/dist/src/integrations/ignore.js +417 -0
  151. package/dist/src/integrations/ignore.js.map +1 -0
  152. package/dist/src/integrations/image-renderer.d.ts +119 -0
  153. package/dist/src/integrations/image-renderer.d.ts.map +1 -0
  154. package/dist/src/integrations/image-renderer.js +306 -0
  155. package/dist/src/integrations/image-renderer.js.map +1 -0
  156. package/dist/src/integrations/index.d.ts +42 -0
  157. package/dist/src/integrations/index.d.ts.map +1 -0
  158. package/dist/src/integrations/index.js +73 -0
  159. package/dist/src/integrations/index.js.map +1 -0
  160. package/dist/src/integrations/lsp.d.ts +196 -0
  161. package/dist/src/integrations/lsp.d.ts.map +1 -0
  162. package/dist/src/integrations/lsp.js +582 -0
  163. package/dist/src/integrations/lsp.js.map +1 -0
  164. package/dist/src/integrations/mcp-client.d.ts +270 -0
  165. package/dist/src/integrations/mcp-client.d.ts.map +1 -0
  166. package/dist/src/integrations/mcp-client.js +698 -0
  167. package/dist/src/integrations/mcp-client.js.map +1 -0
  168. package/dist/src/integrations/mcp-tool-search.d.ts +77 -0
  169. package/dist/src/integrations/mcp-tool-search.d.ts.map +1 -0
  170. package/dist/src/integrations/mcp-tool-search.js +220 -0
  171. package/dist/src/integrations/mcp-tool-search.js.map +1 -0
  172. package/dist/src/integrations/memory.d.ts +108 -0
  173. package/dist/src/integrations/memory.d.ts.map +1 -0
  174. package/dist/src/integrations/memory.js +288 -0
  175. package/dist/src/integrations/memory.js.map +1 -0
  176. package/dist/src/integrations/multi-agent.d.ts +150 -0
  177. package/dist/src/integrations/multi-agent.d.ts.map +1 -0
  178. package/dist/src/integrations/multi-agent.js +306 -0
  179. package/dist/src/integrations/multi-agent.js.map +1 -0
  180. package/dist/src/integrations/observability.d.ts +162 -0
  181. package/dist/src/integrations/observability.d.ts.map +1 -0
  182. package/dist/src/integrations/observability.js +406 -0
  183. package/dist/src/integrations/observability.js.map +1 -0
  184. package/dist/src/integrations/openrouter-pricing.d.ts +42 -0
  185. package/dist/src/integrations/openrouter-pricing.d.ts.map +1 -0
  186. package/dist/src/integrations/openrouter-pricing.js +124 -0
  187. package/dist/src/integrations/openrouter-pricing.js.map +1 -0
  188. package/dist/src/integrations/pending-plan.d.ts +171 -0
  189. package/dist/src/integrations/pending-plan.d.ts.map +1 -0
  190. package/dist/src/integrations/pending-plan.js +244 -0
  191. package/dist/src/integrations/pending-plan.js.map +1 -0
  192. package/dist/src/integrations/persistence.d.ts +48 -0
  193. package/dist/src/integrations/persistence.d.ts.map +1 -0
  194. package/dist/src/integrations/persistence.js +196 -0
  195. package/dist/src/integrations/persistence.js.map +1 -0
  196. package/dist/src/integrations/planning.d.ts +96 -0
  197. package/dist/src/integrations/planning.d.ts.map +1 -0
  198. package/dist/src/integrations/planning.js +338 -0
  199. package/dist/src/integrations/planning.js.map +1 -0
  200. package/dist/src/integrations/pty-shell.d.ts +169 -0
  201. package/dist/src/integrations/pty-shell.d.ts.map +1 -0
  202. package/dist/src/integrations/pty-shell.js +367 -0
  203. package/dist/src/integrations/pty-shell.js.map +1 -0
  204. package/dist/src/integrations/react.d.ts +139 -0
  205. package/dist/src/integrations/react.d.ts.map +1 -0
  206. package/dist/src/integrations/react.js +273 -0
  207. package/dist/src/integrations/react.js.map +1 -0
  208. package/dist/src/integrations/resources.d.ts +177 -0
  209. package/dist/src/integrations/resources.d.ts.map +1 -0
  210. package/dist/src/integrations/resources.js +311 -0
  211. package/dist/src/integrations/resources.js.map +1 -0
  212. package/dist/src/integrations/result-synthesizer.d.ts +389 -0
  213. package/dist/src/integrations/result-synthesizer.d.ts.map +1 -0
  214. package/dist/src/integrations/result-synthesizer.js +951 -0
  215. package/dist/src/integrations/result-synthesizer.js.map +1 -0
  216. package/dist/src/integrations/routing.d.ts +117 -0
  217. package/dist/src/integrations/routing.d.ts.map +1 -0
  218. package/dist/src/integrations/routing.js +347 -0
  219. package/dist/src/integrations/routing.js.map +1 -0
  220. package/dist/src/integrations/rules.d.ts +131 -0
  221. package/dist/src/integrations/rules.d.ts.map +1 -0
  222. package/dist/src/integrations/rules.js +284 -0
  223. package/dist/src/integrations/rules.js.map +1 -0
  224. package/dist/src/integrations/safety.d.ts +142 -0
  225. package/dist/src/integrations/safety.d.ts.map +1 -0
  226. package/dist/src/integrations/safety.js +342 -0
  227. package/dist/src/integrations/safety.js.map +1 -0
  228. package/dist/src/integrations/sandbox/basic.d.ts +74 -0
  229. package/dist/src/integrations/sandbox/basic.d.ts.map +1 -0
  230. package/dist/src/integrations/sandbox/basic.js +310 -0
  231. package/dist/src/integrations/sandbox/basic.js.map +1 -0
  232. package/dist/src/integrations/sandbox/docker.d.ts +94 -0
  233. package/dist/src/integrations/sandbox/docker.d.ts.map +1 -0
  234. package/dist/src/integrations/sandbox/docker.js +293 -0
  235. package/dist/src/integrations/sandbox/docker.js.map +1 -0
  236. package/dist/src/integrations/sandbox/index.d.ts +182 -0
  237. package/dist/src/integrations/sandbox/index.d.ts.map +1 -0
  238. package/dist/src/integrations/sandbox/index.js +382 -0
  239. package/dist/src/integrations/sandbox/index.js.map +1 -0
  240. package/dist/src/integrations/sandbox/landlock.d.ts +59 -0
  241. package/dist/src/integrations/sandbox/landlock.d.ts.map +1 -0
  242. package/dist/src/integrations/sandbox/landlock.js +326 -0
  243. package/dist/src/integrations/sandbox/landlock.js.map +1 -0
  244. package/dist/src/integrations/sandbox/seatbelt.d.ts +68 -0
  245. package/dist/src/integrations/sandbox/seatbelt.d.ts.map +1 -0
  246. package/dist/src/integrations/sandbox/seatbelt.js +298 -0
  247. package/dist/src/integrations/sandbox/seatbelt.js.map +1 -0
  248. package/dist/src/integrations/semantic-cache.d.ts +178 -0
  249. package/dist/src/integrations/semantic-cache.d.ts.map +1 -0
  250. package/dist/src/integrations/semantic-cache.js +372 -0
  251. package/dist/src/integrations/semantic-cache.js.map +1 -0
  252. package/dist/src/integrations/session-store.d.ts +183 -0
  253. package/dist/src/integrations/session-store.d.ts.map +1 -0
  254. package/dist/src/integrations/session-store.js +345 -0
  255. package/dist/src/integrations/session-store.js.map +1 -0
  256. package/dist/src/integrations/shared-blackboard.d.ts +403 -0
  257. package/dist/src/integrations/shared-blackboard.d.ts.map +1 -0
  258. package/dist/src/integrations/shared-blackboard.js +710 -0
  259. package/dist/src/integrations/shared-blackboard.js.map +1 -0
  260. package/dist/src/integrations/skills.d.ts +171 -0
  261. package/dist/src/integrations/skills.d.ts.map +1 -0
  262. package/dist/src/integrations/skills.js +403 -0
  263. package/dist/src/integrations/skills.js.map +1 -0
  264. package/dist/src/integrations/smart-decomposer.d.ts +322 -0
  265. package/dist/src/integrations/smart-decomposer.d.ts.map +1 -0
  266. package/dist/src/integrations/smart-decomposer.js +856 -0
  267. package/dist/src/integrations/smart-decomposer.js.map +1 -0
  268. package/dist/src/integrations/sourcegraph.d.ts +169 -0
  269. package/dist/src/integrations/sourcegraph.d.ts.map +1 -0
  270. package/dist/src/integrations/sourcegraph.js +379 -0
  271. package/dist/src/integrations/sourcegraph.js.map +1 -0
  272. package/dist/src/integrations/sqlite-store.d.ts +518 -0
  273. package/dist/src/integrations/sqlite-store.d.ts.map +1 -0
  274. package/dist/src/integrations/sqlite-store.js +1423 -0
  275. package/dist/src/integrations/sqlite-store.js.map +1 -0
  276. package/dist/src/integrations/streaming.d.ts +102 -0
  277. package/dist/src/integrations/streaming.d.ts.map +1 -0
  278. package/dist/src/integrations/streaming.js +362 -0
  279. package/dist/src/integrations/streaming.js.map +1 -0
  280. package/dist/src/integrations/thread-manager.d.ts +199 -0
  281. package/dist/src/integrations/thread-manager.d.ts.map +1 -0
  282. package/dist/src/integrations/thread-manager.js +357 -0
  283. package/dist/src/integrations/thread-manager.js.map +1 -0
  284. package/dist/src/main.d.ts +26 -0
  285. package/dist/src/main.d.ts.map +1 -0
  286. package/dist/src/main.js +170 -0
  287. package/dist/src/main.js.map +1 -0
  288. package/dist/src/modes/index.d.ts +10 -0
  289. package/dist/src/modes/index.d.ts.map +1 -0
  290. package/dist/src/modes/index.js +10 -0
  291. package/dist/src/modes/index.js.map +1 -0
  292. package/dist/src/modes/repl.d.ts +19 -0
  293. package/dist/src/modes/repl.d.ts.map +1 -0
  294. package/dist/src/modes/repl.js +393 -0
  295. package/dist/src/modes/repl.js.map +1 -0
  296. package/dist/src/modes/tui.d.ts +29 -0
  297. package/dist/src/modes/tui.d.ts.map +1 -0
  298. package/dist/src/modes/tui.js +272 -0
  299. package/dist/src/modes/tui.js.map +1 -0
  300. package/dist/src/modes.d.ts +179 -0
  301. package/dist/src/modes.d.ts.map +1 -0
  302. package/dist/src/modes.js +385 -0
  303. package/dist/src/modes.js.map +1 -0
  304. package/dist/src/observability/tracer.d.ts +111 -0
  305. package/dist/src/observability/tracer.d.ts.map +1 -0
  306. package/dist/src/observability/tracer.js +300 -0
  307. package/dist/src/observability/tracer.js.map +1 -0
  308. package/dist/src/observability/types.d.ts +271 -0
  309. package/dist/src/observability/types.d.ts.map +1 -0
  310. package/dist/src/observability/types.js +24 -0
  311. package/dist/src/observability/types.js.map +1 -0
  312. package/dist/src/paths.d.ts +101 -0
  313. package/dist/src/paths.d.ts.map +1 -0
  314. package/dist/src/paths.js +148 -0
  315. package/dist/src/paths.js.map +1 -0
  316. package/dist/src/persistence/index.d.ts +38 -0
  317. package/dist/src/persistence/index.d.ts.map +1 -0
  318. package/dist/src/persistence/index.js +48 -0
  319. package/dist/src/persistence/index.js.map +1 -0
  320. package/dist/src/persistence/migrator.d.ts +135 -0
  321. package/dist/src/persistence/migrator.d.ts.map +1 -0
  322. package/dist/src/persistence/migrator.js +303 -0
  323. package/dist/src/persistence/migrator.js.map +1 -0
  324. package/dist/src/persistence/schema.d.ts +101 -0
  325. package/dist/src/persistence/schema.d.ts.map +1 -0
  326. package/dist/src/persistence/schema.js +395 -0
  327. package/dist/src/persistence/schema.js.map +1 -0
  328. package/dist/src/providers/adapters/anthropic.d.ts +20 -0
  329. package/dist/src/providers/adapters/anthropic.d.ts.map +1 -0
  330. package/dist/src/providers/adapters/anthropic.js +124 -0
  331. package/dist/src/providers/adapters/anthropic.js.map +1 -0
  332. package/dist/src/providers/adapters/mock.d.ts +25 -0
  333. package/dist/src/providers/adapters/mock.d.ts.map +1 -0
  334. package/dist/src/providers/adapters/mock.js +133 -0
  335. package/dist/src/providers/adapters/mock.js.map +1 -0
  336. package/dist/src/providers/adapters/openai.d.ts +21 -0
  337. package/dist/src/providers/adapters/openai.d.ts.map +1 -0
  338. package/dist/src/providers/adapters/openai.js +126 -0
  339. package/dist/src/providers/adapters/openai.js.map +1 -0
  340. package/dist/src/providers/adapters/openrouter.d.ts +49 -0
  341. package/dist/src/providers/adapters/openrouter.d.ts.map +1 -0
  342. package/dist/src/providers/adapters/openrouter.js +363 -0
  343. package/dist/src/providers/adapters/openrouter.js.map +1 -0
  344. package/dist/src/providers/provider.d.ts +54 -0
  345. package/dist/src/providers/provider.d.ts.map +1 -0
  346. package/dist/src/providers/provider.js +111 -0
  347. package/dist/src/providers/provider.js.map +1 -0
  348. package/dist/src/providers/resilient-fetch.d.ts +99 -0
  349. package/dist/src/providers/resilient-fetch.d.ts.map +1 -0
  350. package/dist/src/providers/resilient-fetch.js +208 -0
  351. package/dist/src/providers/resilient-fetch.js.map +1 -0
  352. package/dist/src/providers/types.d.ts +227 -0
  353. package/dist/src/providers/types.d.ts.map +1 -0
  354. package/dist/src/providers/types.js +24 -0
  355. package/dist/src/providers/types.js.map +1 -0
  356. package/dist/src/session-picker.d.ts +28 -0
  357. package/dist/src/session-picker.d.ts.map +1 -0
  358. package/dist/src/session-picker.js +256 -0
  359. package/dist/src/session-picker.js.map +1 -0
  360. package/dist/src/test-sqlite.d.ts +2 -0
  361. package/dist/src/test-sqlite.d.ts.map +1 -0
  362. package/dist/src/test-sqlite.js +114 -0
  363. package/dist/src/test-sqlite.js.map +1 -0
  364. package/dist/src/tools/agent.d.ts +44 -0
  365. package/dist/src/tools/agent.d.ts.map +1 -0
  366. package/dist/src/tools/agent.js +110 -0
  367. package/dist/src/tools/agent.js.map +1 -0
  368. package/dist/src/tools/bash.d.ts +52 -0
  369. package/dist/src/tools/bash.d.ts.map +1 -0
  370. package/dist/src/tools/bash.js +141 -0
  371. package/dist/src/tools/bash.js.map +1 -0
  372. package/dist/src/tools/file.d.ts +47 -0
  373. package/dist/src/tools/file.d.ts.map +1 -0
  374. package/dist/src/tools/file.js +263 -0
  375. package/dist/src/tools/file.js.map +1 -0
  376. package/dist/src/tools/permission.d.ts +43 -0
  377. package/dist/src/tools/permission.d.ts.map +1 -0
  378. package/dist/src/tools/permission.js +216 -0
  379. package/dist/src/tools/permission.js.map +1 -0
  380. package/dist/src/tools/registry.d.ts +63 -0
  381. package/dist/src/tools/registry.d.ts.map +1 -0
  382. package/dist/src/tools/registry.js +250 -0
  383. package/dist/src/tools/registry.js.map +1 -0
  384. package/dist/src/tools/standard.d.ts +57 -0
  385. package/dist/src/tools/standard.d.ts.map +1 -0
  386. package/dist/src/tools/standard.js +113 -0
  387. package/dist/src/tools/standard.js.map +1 -0
  388. package/dist/src/tools/types.d.ts +146 -0
  389. package/dist/src/tools/types.d.ts.map +1 -0
  390. package/dist/src/tools/types.js +28 -0
  391. package/dist/src/tools/types.js.map +1 -0
  392. package/dist/src/tools/undo.d.ts +71 -0
  393. package/dist/src/tools/undo.d.ts.map +1 -0
  394. package/dist/src/tools/undo.js +123 -0
  395. package/dist/src/tools/undo.js.map +1 -0
  396. package/dist/src/tracing/cache-boundary-tracker.d.ts +189 -0
  397. package/dist/src/tracing/cache-boundary-tracker.d.ts.map +1 -0
  398. package/dist/src/tracing/cache-boundary-tracker.js +411 -0
  399. package/dist/src/tracing/cache-boundary-tracker.js.map +1 -0
  400. package/dist/src/tracing/trace-collector.d.ts +274 -0
  401. package/dist/src/tracing/trace-collector.d.ts.map +1 -0
  402. package/dist/src/tracing/trace-collector.js +727 -0
  403. package/dist/src/tracing/trace-collector.js.map +1 -0
  404. package/dist/src/tracing/types.d.ts +657 -0
  405. package/dist/src/tracing/types.d.ts.map +1 -0
  406. package/dist/src/tracing/types.js +39 -0
  407. package/dist/src/tracing/types.js.map +1 -0
  408. package/dist/src/tricks/failure-evidence.d.ts +268 -0
  409. package/dist/src/tricks/failure-evidence.d.ts.map +1 -0
  410. package/dist/src/tricks/failure-evidence.js +544 -0
  411. package/dist/src/tricks/failure-evidence.js.map +1 -0
  412. package/dist/src/tricks/json-utils.d.ts +77 -0
  413. package/dist/src/tricks/json-utils.d.ts.map +1 -0
  414. package/dist/src/tricks/json-utils.js +247 -0
  415. package/dist/src/tricks/json-utils.js.map +1 -0
  416. package/dist/src/tricks/kv-cache-context.d.ts +227 -0
  417. package/dist/src/tricks/kv-cache-context.d.ts.map +1 -0
  418. package/dist/src/tricks/kv-cache-context.js +377 -0
  419. package/dist/src/tricks/kv-cache-context.js.map +1 -0
  420. package/dist/src/tricks/recitation.d.ts +208 -0
  421. package/dist/src/tricks/recitation.d.ts.map +1 -0
  422. package/dist/src/tricks/recitation.js +374 -0
  423. package/dist/src/tricks/recitation.js.map +1 -0
  424. package/dist/src/tricks/reversible-compaction.d.ts +251 -0
  425. package/dist/src/tricks/reversible-compaction.d.ts.map +1 -0
  426. package/dist/src/tricks/reversible-compaction.js +555 -0
  427. package/dist/src/tricks/reversible-compaction.js.map +1 -0
  428. package/dist/src/tricks/serialization-diversity.d.ts +197 -0
  429. package/dist/src/tricks/serialization-diversity.d.ts.map +1 -0
  430. package/dist/src/tricks/serialization-diversity.js +460 -0
  431. package/dist/src/tricks/serialization-diversity.js.map +1 -0
  432. package/dist/src/tui/app.d.ts +42 -0
  433. package/dist/src/tui/app.d.ts.map +1 -0
  434. package/dist/src/tui/app.js +1076 -0
  435. package/dist/src/tui/app.js.map +1 -0
  436. package/dist/src/tui/components/ApprovalDialog.d.ts +28 -0
  437. package/dist/src/tui/components/ApprovalDialog.d.ts.map +1 -0
  438. package/dist/src/tui/components/ApprovalDialog.js +59 -0
  439. package/dist/src/tui/components/ApprovalDialog.js.map +1 -0
  440. package/dist/src/tui/components/InputArea.d.ts +35 -0
  441. package/dist/src/tui/components/InputArea.d.ts.map +1 -0
  442. package/dist/src/tui/components/InputArea.js +144 -0
  443. package/dist/src/tui/components/InputArea.js.map +1 -0
  444. package/dist/src/tui/components/MessageItem.d.ts +28 -0
  445. package/dist/src/tui/components/MessageItem.d.ts.map +1 -0
  446. package/dist/src/tui/components/MessageItem.js +27 -0
  447. package/dist/src/tui/components/MessageItem.js.map +1 -0
  448. package/dist/src/tui/components/ScrollableBox.d.ts +41 -0
  449. package/dist/src/tui/components/ScrollableBox.d.ts.map +1 -0
  450. package/dist/src/tui/components/ScrollableBox.js +101 -0
  451. package/dist/src/tui/components/ScrollableBox.js.map +1 -0
  452. package/dist/src/tui/components/ToolCallItem.d.ts +33 -0
  453. package/dist/src/tui/components/ToolCallItem.d.ts.map +1 -0
  454. package/dist/src/tui/components/ToolCallItem.js +91 -0
  455. package/dist/src/tui/components/ToolCallItem.js.map +1 -0
  456. package/dist/src/tui/components/index.d.ts +13 -0
  457. package/dist/src/tui/components/index.d.ts.map +1 -0
  458. package/dist/src/tui/components/index.js +15 -0
  459. package/dist/src/tui/components/index.js.map +1 -0
  460. package/dist/src/tui/event-display.d.ts +19 -0
  461. package/dist/src/tui/event-display.d.ts.map +1 -0
  462. package/dist/src/tui/event-display.js +178 -0
  463. package/dist/src/tui/event-display.js.map +1 -0
  464. package/dist/src/tui/index.d.ts +105 -0
  465. package/dist/src/tui/index.d.ts.map +1 -0
  466. package/dist/src/tui/index.js +214 -0
  467. package/dist/src/tui/index.js.map +1 -0
  468. package/dist/src/tui/input/CommandPalette.d.ts +55 -0
  469. package/dist/src/tui/input/CommandPalette.d.ts.map +1 -0
  470. package/dist/src/tui/input/CommandPalette.js +135 -0
  471. package/dist/src/tui/input/CommandPalette.js.map +1 -0
  472. package/dist/src/tui/input/index.d.ts +7 -0
  473. package/dist/src/tui/input/index.d.ts.map +1 -0
  474. package/dist/src/tui/input/index.js +7 -0
  475. package/dist/src/tui/input/index.js.map +1 -0
  476. package/dist/src/tui/theme/index.d.ts +45 -0
  477. package/dist/src/tui/theme/index.d.ts.map +1 -0
  478. package/dist/src/tui/theme/index.js +215 -0
  479. package/dist/src/tui/theme/index.js.map +1 -0
  480. package/dist/src/tui/types.d.ts +214 -0
  481. package/dist/src/tui/types.d.ts.map +1 -0
  482. package/dist/src/tui/types.js +27 -0
  483. package/dist/src/tui/types.js.map +1 -0
  484. package/dist/src/types.d.ts +905 -0
  485. package/dist/src/types.d.ts.map +1 -0
  486. package/dist/src/types.js +9 -0
  487. package/dist/src/types.js.map +1 -0
  488. package/package.json +89 -0
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Lock-free monotonic counter for generating unique submission identifiers.
3
+ * Uses bigint for virtually unlimited range without overflow concerns.
4
+ */
5
+ export declare class AtomicCounter {
6
+ private counter;
7
+ /**
8
+ * Creates a new AtomicCounter instance.
9
+ * @param initial - Optional initial value (default: 0n)
10
+ */
11
+ constructor(initial?: bigint);
12
+ /**
13
+ * Generates the next unique submission ID.
14
+ * Increments the internal counter and returns an ID in format `sub-{base36}`.
15
+ * @returns Unique string ID (e.g., 'sub-0', 'sub-1', 'sub-a', 'sub-1s')
16
+ */
17
+ next(): string;
18
+ /**
19
+ * Returns the current counter value without incrementing.
20
+ * Useful for inspection and debugging.
21
+ * @returns Current counter value as bigint
22
+ */
23
+ current(): bigint;
24
+ /**
25
+ * Resets the counter to a specified value or zero.
26
+ * Primarily useful for testing scenarios.
27
+ * @param value - Optional value to reset to (default: 0n)
28
+ */
29
+ reset(value?: bigint): void;
30
+ }
31
+ /**
32
+ * Global singleton counter instance for generating unique submission IDs
33
+ * across the application.
34
+ */
35
+ export declare const globalCounter: AtomicCounter;
36
+ //# sourceMappingURL=atomic-counter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"atomic-counter.d.ts","sourceRoot":"","sources":["../../../../src/core/queues/atomic-counter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,OAAO,CAAS;IAExB;;;OAGG;gBACS,OAAO,GAAE,MAAW;IAIhC;;;;OAIG;IACH,IAAI,IAAI,MAAM;IAMd;;;;OAIG;IACH,OAAO,IAAI,MAAM;IAIjB;;;;OAIG;IACH,KAAK,CAAC,KAAK,GAAE,MAAW,GAAG,IAAI;CAGhC;AAED;;;GAGG;AACH,eAAO,MAAM,aAAa,eAAsB,CAAC"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Lock-free monotonic counter for generating unique submission identifiers.
3
+ * Uses bigint for virtually unlimited range without overflow concerns.
4
+ */
5
+ export class AtomicCounter {
6
+ counter;
7
+ /**
8
+ * Creates a new AtomicCounter instance.
9
+ * @param initial - Optional initial value (default: 0n)
10
+ */
11
+ constructor(initial = 0n) {
12
+ this.counter = initial;
13
+ }
14
+ /**
15
+ * Generates the next unique submission ID.
16
+ * Increments the internal counter and returns an ID in format `sub-{base36}`.
17
+ * @returns Unique string ID (e.g., 'sub-0', 'sub-1', 'sub-a', 'sub-1s')
18
+ */
19
+ next() {
20
+ const id = this.counter;
21
+ this.counter += 1n;
22
+ return `sub-${id.toString(36)}`;
23
+ }
24
+ /**
25
+ * Returns the current counter value without incrementing.
26
+ * Useful for inspection and debugging.
27
+ * @returns Current counter value as bigint
28
+ */
29
+ current() {
30
+ return this.counter;
31
+ }
32
+ /**
33
+ * Resets the counter to a specified value or zero.
34
+ * Primarily useful for testing scenarios.
35
+ * @param value - Optional value to reset to (default: 0n)
36
+ */
37
+ reset(value = 0n) {
38
+ this.counter = value;
39
+ }
40
+ }
41
+ /**
42
+ * Global singleton counter instance for generating unique submission IDs
43
+ * across the application.
44
+ */
45
+ export const globalCounter = new AtomicCounter();
46
+ //# sourceMappingURL=atomic-counter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"atomic-counter.js","sourceRoot":"","sources":["../../../../src/core/queues/atomic-counter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,OAAO,aAAa;IAChB,OAAO,CAAS;IAExB;;;OAGG;IACH,YAAY,UAAkB,EAAE;QAC9B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED;;;;OAIG;IACH,IAAI;QACF,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;QACxB,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC;QACnB,OAAO,OAAO,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;IAClC,CAAC;IAED;;;;OAIG;IACH,OAAO;QACL,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,QAAgB,EAAE;QACtB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;IACvB,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,aAAa,EAAE,CAAC"}
@@ -0,0 +1,126 @@
1
+ /**
2
+ * Unbounded pub/sub event emitter for Agent to UI communication.
3
+ * Unlike SubmissionQueue, this never blocks the producer (agent).
4
+ * Uses fire-and-forget semantics with async dispatch.
5
+ */
6
+ import type { AgentEvent, EventEnvelope, SubmissionId } from '../protocol/types.js';
7
+ /**
8
+ * Generic event listener that receives all events.
9
+ */
10
+ export type EventListener = (envelope: EventEnvelope) => void;
11
+ /**
12
+ * Typed event listener that receives events of a specific type.
13
+ */
14
+ export type TypedEventListener<T extends AgentEvent> = (envelope: EventEnvelope & {
15
+ event: T;
16
+ }) => void;
17
+ /**
18
+ * Configuration for the EventQueue.
19
+ */
20
+ export interface EventQueueConfig {
21
+ /** Maximum number of recent events to store (default: 100) */
22
+ maxRecentEvents?: number;
23
+ }
24
+ /**
25
+ * Statistics about the event queue for debugging.
26
+ */
27
+ export interface EventQueueStats {
28
+ /** Number of global listeners */
29
+ globalListeners: number;
30
+ /** Number of typed listeners by event type */
31
+ typedListeners: Record<string, number>;
32
+ /** Number of recent events in buffer */
33
+ recentEventsCount: number;
34
+ }
35
+ /**
36
+ * Error thrown when a once() call times out.
37
+ */
38
+ export declare class EventTimeoutError extends Error {
39
+ constructor(eventType: string, timeout: number);
40
+ }
41
+ /**
42
+ * An unbounded pub/sub event emitter for Agent to UI communication.
43
+ *
44
+ * Features:
45
+ * - Fire-and-forget semantics (never blocks producer)
46
+ * - Typed event subscriptions
47
+ * - Recent events buffer for reconnection/replay
48
+ * - Async dispatch via queueMicrotask
49
+ */
50
+ export declare class EventQueue {
51
+ private readonly maxRecentEvents;
52
+ private readonly recentEvents;
53
+ private readonly globalListeners;
54
+ private readonly typedListeners;
55
+ /**
56
+ * Creates a new EventQueue.
57
+ * @param config - Optional configuration
58
+ */
59
+ constructor(config?: EventQueueConfig);
60
+ /**
61
+ * Emits an event to all listeners.
62
+ * Never blocks - uses fire-and-forget semantics.
63
+ *
64
+ * @param submissionId - The submission this event relates to
65
+ * @param event - The event to emit
66
+ */
67
+ emit(submissionId: SubmissionId, event: AgentEvent): void;
68
+ /**
69
+ * Subscribes to all events.
70
+ *
71
+ * @param listener - The listener to call for each event
72
+ * @returns Unsubscribe function
73
+ */
74
+ subscribe(listener: EventListener): () => void;
75
+ /**
76
+ * Subscribes to events of a specific type.
77
+ *
78
+ * @param type - The event type to listen for
79
+ * @param listener - The listener to call for matching events
80
+ * @returns Unsubscribe function
81
+ */
82
+ on<T extends AgentEvent>(type: T['type'], listener: TypedEventListener<T>): () => void;
83
+ /**
84
+ * Returns a promise that resolves with the first matching event.
85
+ *
86
+ * @param type - The event type to wait for
87
+ * @param timeout - Optional timeout in ms (rejects with EventTimeoutError)
88
+ * @returns Promise that resolves with the matching event envelope
89
+ */
90
+ once<T extends AgentEvent>(type: T['type'], timeout?: number): Promise<EventEnvelope & {
91
+ event: T;
92
+ }>;
93
+ /**
94
+ * Gets recent events, optionally filtered by timestamp.
95
+ *
96
+ * @param since - Optional timestamp to filter events after
97
+ * @returns Array of recent event envelopes
98
+ */
99
+ getRecentEvents(since?: number): EventEnvelope[];
100
+ /**
101
+ * Gets recent events filtered by submission ID.
102
+ *
103
+ * @param submissionId - The submission ID to filter by
104
+ * @returns Array of event envelopes for the submission
105
+ */
106
+ getEventsForSubmission(submissionId: SubmissionId): EventEnvelope[];
107
+ /**
108
+ * Clears all listeners and recent events.
109
+ */
110
+ clear(): void;
111
+ /**
112
+ * Returns statistics about the queue for debugging.
113
+ */
114
+ stats(): EventQueueStats;
115
+ /**
116
+ * Adds an envelope to the recent events buffer.
117
+ * Maintains circular buffer semantics.
118
+ */
119
+ private addToRecentEvents;
120
+ /**
121
+ * Notifies all listeners of an event asynchronously.
122
+ * Ignores listener errors (fire-and-forget).
123
+ */
124
+ private notifyListeners;
125
+ }
126
+ //# sourceMappingURL=event-queue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-queue.d.ts","sourceRoot":"","sources":["../../../../src/core/queues/event-queue.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpF;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,QAAQ,EAAE,aAAa,KAAK,IAAI,CAAC;AAE9D;;GAEG;AACH,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,UAAU,IAAI,CACrD,QAAQ,EAAE,aAAa,GAAG;IAAE,KAAK,EAAE,CAAC,CAAA;CAAE,KACnC,IAAI,CAAC;AAEV;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,8DAA8D;IAC9D,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,iCAAiC;IACjC,eAAe,EAAE,MAAM,CAAC;IACxB,8CAA8C;IAC9C,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,wCAAwC;IACxC,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;gBAC9B,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAI/C;AAED;;;;;;;;GAQG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;IACzC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAuB;IACpD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAiC;IACjE,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA0D;IAEzF;;;OAGG;gBACS,MAAM,CAAC,EAAE,gBAAgB;IAIrC;;;;;;OAMG;IACH,IAAI,CAAC,YAAY,EAAE,YAAY,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI;IAczD;;;;;OAKG;IACH,SAAS,CAAC,QAAQ,EAAE,aAAa,GAAG,MAAM,IAAI;IAQ9C;;;;;;OAMG;IACH,EAAE,CAAC,CAAC,SAAS,UAAU,EACrB,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,EACf,QAAQ,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAC9B,MAAM,IAAI;IAmBb;;;;;;OAMG;IACH,IAAI,CAAC,CAAC,SAAS,UAAU,EACvB,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,EACf,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,aAAa,GAAG;QAAE,KAAK,EAAE,CAAC,CAAA;KAAE,CAAC;IA8BxC;;;;;OAKG;IACH,eAAe,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,aAAa,EAAE;IAQhD;;;;;OAKG;IACH,sBAAsB,CAAC,YAAY,EAAE,YAAY,GAAG,aAAa,EAAE;IAMnE;;OAEG;IACH,KAAK,IAAI,IAAI;IAMb;;OAEG;IACH,KAAK,IAAI,eAAe;IAaxB;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IASzB;;;OAGG;IACH,OAAO,CAAC,eAAe;CA0BxB"}
@@ -0,0 +1,208 @@
1
+ /**
2
+ * Unbounded pub/sub event emitter for Agent to UI communication.
3
+ * Unlike SubmissionQueue, this never blocks the producer (agent).
4
+ * Uses fire-and-forget semantics with async dispatch.
5
+ */
6
+ /**
7
+ * Error thrown when a once() call times out.
8
+ */
9
+ export class EventTimeoutError extends Error {
10
+ constructor(eventType, timeout) {
11
+ super(`Timed out waiting for event '${eventType}' after ${timeout}ms`);
12
+ this.name = 'EventTimeoutError';
13
+ }
14
+ }
15
+ /**
16
+ * An unbounded pub/sub event emitter for Agent to UI communication.
17
+ *
18
+ * Features:
19
+ * - Fire-and-forget semantics (never blocks producer)
20
+ * - Typed event subscriptions
21
+ * - Recent events buffer for reconnection/replay
22
+ * - Async dispatch via queueMicrotask
23
+ */
24
+ export class EventQueue {
25
+ maxRecentEvents;
26
+ recentEvents = [];
27
+ globalListeners = new Set();
28
+ typedListeners = new Map();
29
+ /**
30
+ * Creates a new EventQueue.
31
+ * @param config - Optional configuration
32
+ */
33
+ constructor(config) {
34
+ this.maxRecentEvents = config?.maxRecentEvents ?? 100;
35
+ }
36
+ /**
37
+ * Emits an event to all listeners.
38
+ * Never blocks - uses fire-and-forget semantics.
39
+ *
40
+ * @param submissionId - The submission this event relates to
41
+ * @param event - The event to emit
42
+ */
43
+ emit(submissionId, event) {
44
+ const envelope = {
45
+ submissionId,
46
+ event,
47
+ timestamp: Date.now(),
48
+ };
49
+ // Store in recent events buffer (circular)
50
+ this.addToRecentEvents(envelope);
51
+ // Notify all listeners asynchronously
52
+ this.notifyListeners(envelope);
53
+ }
54
+ /**
55
+ * Subscribes to all events.
56
+ *
57
+ * @param listener - The listener to call for each event
58
+ * @returns Unsubscribe function
59
+ */
60
+ subscribe(listener) {
61
+ this.globalListeners.add(listener);
62
+ return () => {
63
+ this.globalListeners.delete(listener);
64
+ };
65
+ }
66
+ /**
67
+ * Subscribes to events of a specific type.
68
+ *
69
+ * @param type - The event type to listen for
70
+ * @param listener - The listener to call for matching events
71
+ * @returns Unsubscribe function
72
+ */
73
+ on(type, listener) {
74
+ let listeners = this.typedListeners.get(type);
75
+ if (!listeners) {
76
+ listeners = new Set();
77
+ this.typedListeners.set(type, listeners);
78
+ }
79
+ // Cast is safe because we filter by type before calling
80
+ listeners.add(listener);
81
+ return () => {
82
+ listeners.delete(listener);
83
+ // Clean up empty sets
84
+ if (listeners.size === 0) {
85
+ this.typedListeners.delete(type);
86
+ }
87
+ };
88
+ }
89
+ /**
90
+ * Returns a promise that resolves with the first matching event.
91
+ *
92
+ * @param type - The event type to wait for
93
+ * @param timeout - Optional timeout in ms (rejects with EventTimeoutError)
94
+ * @returns Promise that resolves with the matching event envelope
95
+ */
96
+ once(type, timeout) {
97
+ return new Promise((resolve, reject) => {
98
+ let timeoutId;
99
+ let unsubscribe;
100
+ const cleanup = () => {
101
+ if (timeoutId !== undefined) {
102
+ clearTimeout(timeoutId);
103
+ }
104
+ if (unsubscribe) {
105
+ unsubscribe();
106
+ }
107
+ };
108
+ // Set up listener
109
+ unsubscribe = this.on(type, (envelope) => {
110
+ cleanup();
111
+ resolve(envelope);
112
+ });
113
+ // Set up timeout if specified
114
+ if (timeout !== undefined && timeout > 0) {
115
+ timeoutId = setTimeout(() => {
116
+ cleanup();
117
+ reject(new EventTimeoutError(type, timeout));
118
+ }, timeout);
119
+ }
120
+ });
121
+ }
122
+ /**
123
+ * Gets recent events, optionally filtered by timestamp.
124
+ *
125
+ * @param since - Optional timestamp to filter events after
126
+ * @returns Array of recent event envelopes
127
+ */
128
+ getRecentEvents(since) {
129
+ if (since === undefined) {
130
+ return [...this.recentEvents];
131
+ }
132
+ return this.recentEvents.filter((envelope) => envelope.timestamp > since);
133
+ }
134
+ /**
135
+ * Gets recent events filtered by submission ID.
136
+ *
137
+ * @param submissionId - The submission ID to filter by
138
+ * @returns Array of event envelopes for the submission
139
+ */
140
+ getEventsForSubmission(submissionId) {
141
+ return this.recentEvents.filter((envelope) => envelope.submissionId === submissionId);
142
+ }
143
+ /**
144
+ * Clears all listeners and recent events.
145
+ */
146
+ clear() {
147
+ this.globalListeners.clear();
148
+ this.typedListeners.clear();
149
+ this.recentEvents.length = 0;
150
+ }
151
+ /**
152
+ * Returns statistics about the queue for debugging.
153
+ */
154
+ stats() {
155
+ const typedListeners = {};
156
+ for (const [type, listeners] of this.typedListeners) {
157
+ typedListeners[type] = listeners.size;
158
+ }
159
+ return {
160
+ globalListeners: this.globalListeners.size,
161
+ typedListeners,
162
+ recentEventsCount: this.recentEvents.length,
163
+ };
164
+ }
165
+ /**
166
+ * Adds an envelope to the recent events buffer.
167
+ * Maintains circular buffer semantics.
168
+ */
169
+ addToRecentEvents(envelope) {
170
+ this.recentEvents.push(envelope);
171
+ // Trim to maxRecentEvents (circular buffer)
172
+ while (this.recentEvents.length > this.maxRecentEvents) {
173
+ this.recentEvents.shift();
174
+ }
175
+ }
176
+ /**
177
+ * Notifies all listeners of an event asynchronously.
178
+ * Ignores listener errors (fire-and-forget).
179
+ */
180
+ notifyListeners(envelope) {
181
+ // Notify global listeners
182
+ for (const listener of this.globalListeners) {
183
+ queueMicrotask(() => {
184
+ try {
185
+ listener(envelope);
186
+ }
187
+ catch {
188
+ // Ignore listener errors - fire and forget
189
+ }
190
+ });
191
+ }
192
+ // Notify typed listeners
193
+ const typedListeners = this.typedListeners.get(envelope.event.type);
194
+ if (typedListeners) {
195
+ for (const listener of typedListeners) {
196
+ queueMicrotask(() => {
197
+ try {
198
+ listener(envelope);
199
+ }
200
+ catch {
201
+ // Ignore listener errors - fire and forget
202
+ }
203
+ });
204
+ }
205
+ }
206
+ }
207
+ }
208
+ //# sourceMappingURL=event-queue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-queue.js","sourceRoot":"","sources":["../../../../src/core/queues/event-queue.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAoCH;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAC1C,YAAY,SAAiB,EAAE,OAAe;QAC5C,KAAK,CAAC,gCAAgC,SAAS,WAAW,OAAO,IAAI,CAAC,CAAC;QACvE,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF;AAED;;;;;;;;GAQG;A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E;gBAClB,IAAI,CAAC;oBACH,QAAQ,CAAC,QAAQ,CAAC,CAAC;gBACrB,CAAC;gBAAC,MAAM,CAAC;oBACP,2CAA2C;gBAC7C,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;QAED,yBAAyB;QACzB,MAAM,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACpE,IAAI,cAAc,EAAE,CAAC;YACnB,KAAK,MAAM,QAAQ,IAAI,cAAc,EAAE,CAAC;gBACtC,cAAc,CAAC,GAAG,EAAE;oBAClB,IAAI,CAAC;wBACH,QAAQ,CAAC,QAAQ,CAAC,CAAC;oBACrB,CAAC;oBAAC,MAAM,CAAC;wBACP,2CAA2C;oBAC7C,CAAC;gBACH,CAAC,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Queue System Exports
3
+ *
4
+ * Provides the core queue infrastructure for UI/Agent communication:
5
+ * - AtomicCounter: Lock-free ID generation
6
+ * - SubmissionQueue: Bounded async queue with backpressure (UI -> Agent)
7
+ * - EventQueue: Unbounded pub/sub event emitter (Agent -> UI)
8
+ */
9
+ export { AtomicCounter, globalCounter } from './atomic-counter.js';
10
+ export { SubmissionQueue, QueueTimeoutError, QueueClosedError, type SubmissionQueueConfig, } from './submission-queue.js';
11
+ export { EventQueue, EventTimeoutError, type EventListener, type TypedEventListener, type EventQueueConfig, type EventQueueStats, } from './event-queue.js';
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/queues/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGnE,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,KAAK,qBAAqB,GAC3B,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,eAAe,GACrB,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Queue System Exports
3
+ *
4
+ * Provides the core queue infrastructure for UI/Agent communication:
5
+ * - AtomicCounter: Lock-free ID generation
6
+ * - SubmissionQueue: Bounded async queue with backpressure (UI -> Agent)
7
+ * - EventQueue: Unbounded pub/sub event emitter (Agent -> UI)
8
+ */
9
+ // Atomic counter
10
+ export { AtomicCounter, globalCounter } from './atomic-counter.js';
11
+ // Submission queue
12
+ export { SubmissionQueue, QueueTimeoutError, QueueClosedError, } from './submission-queue.js';
13
+ // Event queue
14
+ export { EventQueue, EventTimeoutError, } from './event-queue.js';
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/queues/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,iBAAiB;AACjB,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEnE,mBAAmB;AACnB,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,gBAAgB,GAEjB,MAAM,uBAAuB,CAAC;AAE/B,cAAc;AACd,OAAO,EACL,UAAU,EACV,iBAAiB,GAKlB,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,116 @@
1
+ /**
2
+ * Bounded async queue for operations from UI to Agent.
3
+ * Implements backpressure - when full, producers wait until space is available.
4
+ */
5
+ import type { Operation, Submission, SubmissionId } from '../protocol/types.js';
6
+ /**
7
+ * Configuration for the SubmissionQueue.
8
+ */
9
+ export interface SubmissionQueueConfig {
10
+ /** Maximum number of items in the queue (default: 64) */
11
+ maxSize?: number;
12
+ /** Timeout in ms for producers waiting for space (default: 30000) */
13
+ timeout?: number;
14
+ }
15
+ /**
16
+ * Error thrown when a queue operation times out.
17
+ */
18
+ export declare class QueueTimeoutError extends Error {
19
+ constructor(message?: string);
20
+ }
21
+ /**
22
+ * Error thrown when attempting to operate on a closed queue.
23
+ */
24
+ export declare class QueueClosedError extends Error {
25
+ constructor(message?: string);
26
+ }
27
+ /**
28
+ * A bounded async queue for operations from UI to Agent.
29
+ *
30
+ * Features:
31
+ * - Bounded capacity with backpressure (producers wait when full)
32
+ * - Async iterator support for consumption
33
+ * - Graceful shutdown via close()
34
+ * - Timeout handling for blocked producers
35
+ */
36
+ export declare class SubmissionQueue {
37
+ private readonly maxSize;
38
+ private readonly timeout;
39
+ private readonly counter;
40
+ private readonly queue;
41
+ private readonly producerWaiters;
42
+ private readonly consumerWaiters;
43
+ private closed;
44
+ /**
45
+ * Creates a new SubmissionQueue.
46
+ * @param config - Optional configuration
47
+ */
48
+ constructor(config?: SubmissionQueueConfig);
49
+ /**
50
+ * Submits an operation to the queue.
51
+ * Blocks if the queue is full (backpressure).
52
+ *
53
+ * @param op - The operation to submit
54
+ * @param correlationId - Optional correlation ID for request/response tracking
55
+ * @returns The submission ID
56
+ * @throws QueueClosedError if the queue is closed
57
+ * @throws QueueTimeoutError if waiting for space times out
58
+ */
59
+ submit(op: Operation, correlationId?: string): Promise<SubmissionId>;
60
+ /**
61
+ * Takes the next submission from the queue.
62
+ * Blocks if the queue is empty.
63
+ *
64
+ * @returns The next submission, or null if the queue is closed and empty
65
+ */
66
+ take(): Promise<Submission | null>;
67
+ /**
68
+ * Non-blocking version of take().
69
+ * @returns The next submission, or null if the queue is empty
70
+ */
71
+ tryTake(): Submission | null;
72
+ /**
73
+ * Returns the current queue size.
74
+ */
75
+ size(): number;
76
+ /**
77
+ * Returns true if the queue is empty.
78
+ */
79
+ isEmpty(): boolean;
80
+ /**
81
+ * Returns true if the queue is full.
82
+ */
83
+ isFull(): boolean;
84
+ /**
85
+ * Returns true if the queue is closed.
86
+ */
87
+ isClosed(): boolean;
88
+ /**
89
+ * Closes the queue.
90
+ * - Rejects all pending producer waiters
91
+ * - Resolves all pending consumer waiters with null
92
+ * - No more submissions are accepted
93
+ */
94
+ close(): void;
95
+ /**
96
+ * Async iterator for consuming submissions.
97
+ * Yields submissions until the queue is closed and empty.
98
+ */
99
+ [Symbol.asyncIterator](): AsyncIterableIterator<Submission>;
100
+ /**
101
+ * Waits for space to become available in the queue.
102
+ * @throws QueueTimeoutError if waiting times out
103
+ * @throws QueueClosedError if queue is closed while waiting
104
+ */
105
+ private waitForSpace;
106
+ /**
107
+ * Wakes a waiting producer (called when space becomes available).
108
+ */
109
+ private wakeProducer;
110
+ /**
111
+ * Wakes a waiting consumer with a submission.
112
+ * If no consumers are waiting, the submission is already in the queue.
113
+ */
114
+ private wakeConsumer;
115
+ }
116
+ //# sourceMappingURL=submission-queue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"submission-queue.d.ts","sourceRoot":"","sources":["../../../../src/core/queues/submission-queue.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGhF;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,yDAAyD;IACzD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qEAAqE;IACrE,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAUD;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;gBAC9B,OAAO,GAAE,MAAoC;CAI1D;AAED;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;gBAC7B,OAAO,GAAE,MAA0B;CAIhD;AAED;;;;;;;;GAQG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgB;IACxC,OAAO,CAAC,QAAQ,CAAC,KA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