@adecore/agents 0.0.1 → 0.17.0-beta.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 (348) hide show
  1. package/LICENSE +110 -0
  2. package/README.md +33 -0
  3. package/dist/async.d.ts +2 -0
  4. package/dist/async.js +31 -0
  5. package/dist/chat/attachment-store.d.ts +10 -0
  6. package/dist/chat/attachment-store.js +93 -0
  7. package/dist/chat/backend.d.ts +214 -0
  8. package/dist/chat/backend.js +1 -0
  9. package/dist/chat/background-work.d.ts +8 -0
  10. package/dist/chat/background-work.js +33 -0
  11. package/dist/chat/bookmark-store.d.ts +25 -0
  12. package/dist/chat/bookmark-store.js +141 -0
  13. package/dist/chat/chat-core.d.ts +311 -0
  14. package/dist/chat/chat-core.js +1025 -0
  15. package/dist/chat/chat-log.d.ts +33 -0
  16. package/dist/chat/chat-log.js +163 -0
  17. package/dist/chat/chat-process.d.ts +46 -0
  18. package/dist/chat/chat-process.js +190 -0
  19. package/dist/chat/chat-session.d.ts +209 -0
  20. package/dist/chat/chat-session.js +1511 -0
  21. package/dist/chat/chat-store.d.ts +37 -0
  22. package/dist/chat/chat-store.js +202 -0
  23. package/dist/chat/chat-title.d.ts +10 -0
  24. package/dist/chat/chat-title.js +74 -0
  25. package/dist/chat/claude-backend.d.ts +35 -0
  26. package/dist/chat/claude-backend.js +214 -0
  27. package/dist/chat/claude-protocol.d.ts +41 -0
  28. package/dist/chat/claude-protocol.js +642 -0
  29. package/dist/chat/claude-title.d.ts +11 -0
  30. package/dist/chat/claude-title.js +97 -0
  31. package/dist/chat/claude-transcript.d.ts +28 -0
  32. package/dist/chat/claude-transcript.js +211 -0
  33. package/dist/chat/codex-backend.d.ts +51 -0
  34. package/dist/chat/codex-backend.js +364 -0
  35. package/dist/chat/codex-protocol.d.ts +56 -0
  36. package/dist/chat/codex-protocol.js +767 -0
  37. package/dist/chat/codex-thread.d.ts +32 -0
  38. package/dist/chat/codex-thread.js +131 -0
  39. package/dist/chat/codex-transport.d.ts +42 -0
  40. package/dist/chat/codex-transport.js +188 -0
  41. package/dist/chat/composer-preferences.d.ts +15 -0
  42. package/dist/chat/composer-preferences.js +46 -0
  43. package/dist/chat/context-breakdown.d.ts +2 -0
  44. package/dist/chat/context-breakdown.js +74 -0
  45. package/dist/chat/delta-coalescer.d.ts +12 -0
  46. package/dist/chat/delta-coalescer.js +55 -0
  47. package/dist/chat/errors.d.ts +4 -0
  48. package/dist/chat/errors.js +4 -0
  49. package/dist/chat/fake-claude.d.ts +3 -0
  50. package/dist/chat/fake-claude.js +982 -0
  51. package/dist/chat/fake-cli.d.ts +25 -0
  52. package/dist/chat/fake-cli.js +157 -0
  53. package/dist/chat/fake-codex.d.ts +10 -0
  54. package/dist/chat/fake-codex.js +502 -0
  55. package/dist/chat/fixtures/claude-2.1.285-auto-fallback.json +24 -0
  56. package/dist/chat/fixtures/claude-2.1.285-native-children.json +6600 -0
  57. package/dist/chat/fixtures/claude-2.1.285-resume-direct-compact.json +202 -0
  58. package/dist/chat/fixtures/claude-2.1.285-resume-task-notification.json +57 -0
  59. package/dist/chat/fixtures/claude-projects/-work-demo/5f1c2a9e-0b7d-4c1e-9a53-3e2f8d6b7a10/subagents/agent-a4c2e8f10b3d5a7e9.jsonl +10 -0
  60. package/dist/chat/fixtures/claude-projects/-work-demo/5f1c2a9e-0b7d-4c1e-9a53-3e2f8d6b7a10/subagents/agent-a4c2e8f10b3d5a7e9.meta.json +1 -0
  61. package/dist/chat/fixtures/claude-projects/-work-demo/5f1c2a9e-0b7d-4c1e-9a53-3e2f8d6b7a10/subagents/agent-a9b8c7d6e5f4a3b21.jsonl +2 -0
  62. package/dist/chat/fixtures/claude-projects/-work-demo/5f1c2a9e-0b7d-4c1e-9a53-3e2f8d6b7a10/subagents/agent-a9b8c7d6e5f4a3b21.meta.json +1 -0
  63. package/dist/chat/fixtures/codex-0.159.2-native-approval.json +119 -0
  64. package/dist/chat/fixtures/codex-0.159.2-native-file-approval.json +136 -0
  65. package/dist/chat/fixtures/codex-0.159.2-native-interacted.json +220 -0
  66. package/dist/chat/fixtures/codex-0.159.2-usage-windows.json +74 -0
  67. package/dist/chat/input.d.ts +19 -0
  68. package/dist/chat/input.js +71 -0
  69. package/dist/chat/limit-resume.d.ts +11 -0
  70. package/dist/chat/limit-resume.js +68 -0
  71. package/dist/chat/projector.d.ts +60 -0
  72. package/dist/chat/projector.js +860 -0
  73. package/dist/chat/request-summary.d.ts +3 -0
  74. package/dist/chat/request-summary.js +143 -0
  75. package/dist/chat/subagent-projection.d.ts +8 -0
  76. package/dist/chat/subagent-projection.js +40 -0
  77. package/dist/chat/subagent-reader.d.ts +66 -0
  78. package/dist/chat/subagent-reader.js +396 -0
  79. package/dist/chat/subagent-settlement.d.ts +6 -0
  80. package/dist/chat/subagent-settlement.js +103 -0
  81. package/dist/chat/thread.d.ts +30 -0
  82. package/dist/chat/thread.js +147 -0
  83. package/dist/chat/wake-chat.d.ts +20 -0
  84. package/dist/chat/wake-chat.js +27 -0
  85. package/dist/client-sinks.d.ts +9 -0
  86. package/dist/client-sinks.js +34 -0
  87. package/dist/coded-error.d.ts +5 -0
  88. package/dist/coded-error.js +17 -0
  89. package/dist/context/argv.d.ts +11 -0
  90. package/dist/context/argv.js +58 -0
  91. package/dist/context/refusal.d.ts +9 -0
  92. package/dist/context/refusal.js +38 -0
  93. package/dist/context/verb.d.ts +85 -0
  94. package/dist/context/verb.js +233 -0
  95. package/dist/error-text.d.ts +5 -0
  96. package/dist/error-text.js +24 -0
  97. package/dist/events.d.ts +12 -0
  98. package/dist/events.js +1 -0
  99. package/dist/fs.d.ts +9 -0
  100. package/dist/fs.js +107 -0
  101. package/dist/host/agent-host.d.ts +28 -0
  102. package/dist/host/agent-host.js +105 -0
  103. package/dist/host/environment.d.ts +7 -0
  104. package/dist/host/environment.js +22 -0
  105. package/dist/host/handlers.d.ts +30 -0
  106. package/dist/host/handlers.js +111 -0
  107. package/dist/host/memory-port.d.ts +2 -0
  108. package/dist/host/memory-port.js +25 -0
  109. package/dist/host/wiring.d.ts +40 -0
  110. package/dist/host/wiring.js +120 -0
  111. package/dist/lineage.d.ts +44 -0
  112. package/dist/lineage.js +134 -0
  113. package/dist/messages/deliver-message.d.ts +21 -0
  114. package/dist/messages/deliver-message.js +42 -0
  115. package/dist/messages/deliver-notice.d.ts +25 -0
  116. package/dist/messages/deliver-notice.js +75 -0
  117. package/dist/messages/notice-notes.d.ts +15 -0
  118. package/dist/messages/notice-notes.js +26 -0
  119. package/dist/messages/notice-store.d.ts +30 -0
  120. package/dist/messages/notice-store.js +120 -0
  121. package/dist/modes.d.ts +11 -0
  122. package/dist/modes.js +28 -0
  123. package/dist/outbox/manual-clock.d.ts +10 -0
  124. package/dist/outbox/manual-clock.js +25 -0
  125. package/dist/outbox/outbox-worker.d.ts +44 -0
  126. package/dist/outbox/outbox-worker.js +173 -0
  127. package/dist/outbox/outbox.d.ts +37 -0
  128. package/dist/outbox/outbox.js +76 -0
  129. package/dist/providers/accounts/accounts.d.ts +20 -0
  130. package/dist/providers/accounts/accounts.js +158 -0
  131. package/dist/providers/accounts/launch.d.ts +17 -0
  132. package/dist/providers/accounts/launch.js +30 -0
  133. package/dist/providers/accounts/service.d.ts +87 -0
  134. package/dist/providers/accounts/service.js +538 -0
  135. package/dist/providers/accounts/shadow-home.d.ts +8 -0
  136. package/dist/providers/accounts/shadow-home.js +70 -0
  137. package/dist/providers/accounts/status.d.ts +12 -0
  138. package/dist/providers/accounts/status.js +85 -0
  139. package/dist/providers/accounts/store.d.ts +14 -0
  140. package/dist/providers/accounts/store.js +112 -0
  141. package/dist/providers/accounts/test-accounts.d.ts +12 -0
  142. package/dist/providers/accounts/test-accounts.js +38 -0
  143. package/dist/providers/accounts/variables.d.ts +27 -0
  144. package/dist/providers/accounts/variables.js +94 -0
  145. package/dist/providers/catalog.d.ts +17 -0
  146. package/dist/providers/catalog.js +76 -0
  147. package/dist/providers/claude-models.json +114 -0
  148. package/dist/providers/claude-provider.d.ts +4 -0
  149. package/dist/providers/claude-provider.js +29 -0
  150. package/dist/providers/claude.d.ts +15 -0
  151. package/dist/providers/claude.js +105 -0
  152. package/dist/providers/codex-models.json +135 -0
  153. package/dist/providers/codex-provider.d.ts +4 -0
  154. package/dist/providers/codex-provider.js +27 -0
  155. package/dist/providers/codex-rules.d.ts +9 -0
  156. package/dist/providers/codex-rules.js +35 -0
  157. package/dist/providers/codex.d.ts +14 -0
  158. package/dist/providers/codex.js +52 -0
  159. package/dist/providers/detect.d.ts +6 -0
  160. package/dist/providers/detect.js +30 -0
  161. package/dist/providers/provider.d.ts +25 -0
  162. package/dist/providers/provider.js +1 -0
  163. package/dist/providers/registry.d.ts +28 -0
  164. package/dist/providers/registry.js +118 -0
  165. package/dist/record-directory.d.ts +27 -0
  166. package/dist/record-directory.js +114 -0
  167. package/dist/run-process.d.ts +13 -0
  168. package/dist/run-process.js +42 -0
  169. package/dist/serializer.d.ts +9 -0
  170. package/dist/serializer.js +34 -0
  171. package/dist/skills.d.ts +21 -0
  172. package/dist/skills.js +174 -0
  173. package/dist/tasks/background-limit.d.ts +16 -0
  174. package/dist/tasks/background-limit.js +55 -0
  175. package/dist/tasks/end-children.d.ts +34 -0
  176. package/dist/tasks/end-children.js +53 -0
  177. package/dist/tasks/give-task.d.ts +14 -0
  178. package/dist/tasks/give-task.js +33 -0
  179. package/dist/tasks/task-coordinator.d.ts +52 -0
  180. package/dist/tasks/task-coordinator.js +323 -0
  181. package/dist/tasks/task-store.d.ts +49 -0
  182. package/dist/tasks/task-store.js +197 -0
  183. package/dist/tasks/task-work.d.ts +47 -0
  184. package/dist/tasks/task-work.js +28 -0
  185. package/dist/tasks/waiting-child.d.ts +51 -0
  186. package/dist/tasks/waiting-child.js +143 -0
  187. package/dist/tasks/wake-parent.d.ts +19 -0
  188. package/dist/tasks/wake-parent.js +109 -0
  189. package/dist/tasks/wiring.d.ts +51 -0
  190. package/dist/tasks/wiring.js +151 -0
  191. package/dist/title-file.d.ts +2 -0
  192. package/dist/title-file.js +55 -0
  193. package/dist/usage/accounts.d.ts +15 -0
  194. package/dist/usage/accounts.js +64 -0
  195. package/dist/usage/aggregate.d.ts +12 -0
  196. package/dist/usage/aggregate.js +154 -0
  197. package/dist/usage/exchange.d.ts +16 -0
  198. package/dist/usage/exchange.js +84 -0
  199. package/dist/usage/index-file.d.ts +15 -0
  200. package/dist/usage/index-file.js +123 -0
  201. package/dist/usage/limits/monitor.d.ts +50 -0
  202. package/dist/usage/limits/monitor.js +179 -0
  203. package/dist/usage/limits/normalize.d.ts +21 -0
  204. package/dist/usage/limits/normalize.js +160 -0
  205. package/dist/usage/limits/probe.d.ts +9 -0
  206. package/dist/usage/limits/probe.js +113 -0
  207. package/dist/usage/prices-snapshot.json +1071 -0
  208. package/dist/usage/pricing.d.ts +34 -0
  209. package/dist/usage/pricing.js +186 -0
  210. package/dist/usage/projects.d.ts +17 -0
  211. package/dist/usage/projects.js +49 -0
  212. package/dist/usage/readers/claude.d.ts +3 -0
  213. package/dist/usage/readers/claude.js +59 -0
  214. package/dist/usage/readers/codex.d.ts +23 -0
  215. package/dist/usage/readers/codex.js +155 -0
  216. package/dist/usage/record.d.ts +15 -0
  217. package/dist/usage/record.js +39 -0
  218. package/dist/usage/roots.d.ts +12 -0
  219. package/dist/usage/roots.js +29 -0
  220. package/dist/usage/scanner.d.ts +30 -0
  221. package/dist/usage/scanner.js +234 -0
  222. package/dist/usage/usage-service.d.ts +35 -0
  223. package/dist/usage/usage-service.js +130 -0
  224. package/dist/watch-seam.d.ts +29 -0
  225. package/dist/watch-seam.js +78 -0
  226. package/dist/watch-test-helpers.d.ts +28 -0
  227. package/dist/watch-test-helpers.js +86 -0
  228. package/package.json +42 -3
  229. package/src/async.ts +40 -0
  230. package/src/chat/attachment-store.ts +108 -0
  231. package/src/chat/backend.ts +199 -0
  232. package/src/chat/background-work.ts +42 -0
  233. package/src/chat/bookmark-store.ts +166 -0
  234. package/src/chat/chat-core.ts +1228 -0
  235. package/src/chat/chat-log.ts +187 -0
  236. package/src/chat/chat-process.ts +237 -0
  237. package/src/chat/chat-session.ts +1723 -0
  238. package/src/chat/chat-store.ts +261 -0
  239. package/src/chat/chat-title.ts +90 -0
  240. package/src/chat/claude-backend.ts +235 -0
  241. package/src/chat/claude-protocol.ts +684 -0
  242. package/src/chat/claude-title.ts +106 -0
  243. package/src/chat/claude-transcript.ts +233 -0
  244. package/src/chat/codex-backend.ts +397 -0
  245. package/src/chat/codex-protocol.ts +872 -0
  246. package/src/chat/codex-thread.ts +162 -0
  247. package/src/chat/codex-transport.ts +224 -0
  248. package/src/chat/composer-preferences.ts +67 -0
  249. package/src/chat/context-breakdown.ts +80 -0
  250. package/src/chat/delta-coalescer.ts +62 -0
  251. package/src/chat/errors.ts +25 -0
  252. package/src/chat/fake-claude.ts +1006 -0
  253. package/src/chat/fake-cli.ts +199 -0
  254. package/src/chat/fake-codex.ts +534 -0
  255. package/src/chat/fixtures/claude-2.1.285-auto-fallback.json +24 -0
  256. package/src/chat/fixtures/claude-2.1.285-native-children.json +6600 -0
  257. package/src/chat/fixtures/claude-2.1.285-resume-direct-compact.json +202 -0
  258. package/src/chat/fixtures/claude-2.1.285-resume-task-notification.json +57 -0
  259. package/src/chat/fixtures/claude-projects/-work-demo/5f1c2a9e-0b7d-4c1e-9a53-3e2f8d6b7a10/subagents/agent-a4c2e8f10b3d5a7e9.jsonl +10 -0
  260. package/src/chat/fixtures/claude-projects/-work-demo/5f1c2a9e-0b7d-4c1e-9a53-3e2f8d6b7a10/subagents/agent-a4c2e8f10b3d5a7e9.meta.json +1 -0
  261. package/src/chat/fixtures/claude-projects/-work-demo/5f1c2a9e-0b7d-4c1e-9a53-3e2f8d6b7a10/subagents/agent-a9b8c7d6e5f4a3b21.jsonl +2 -0
  262. package/src/chat/fixtures/claude-projects/-work-demo/5f1c2a9e-0b7d-4c1e-9a53-3e2f8d6b7a10/subagents/agent-a9b8c7d6e5f4a3b21.meta.json +1 -0
  263. package/src/chat/fixtures/codex-0.159.2-native-approval.json +119 -0
  264. package/src/chat/fixtures/codex-0.159.2-native-file-approval.json +136 -0
  265. package/src/chat/fixtures/codex-0.159.2-native-interacted.json +220 -0
  266. package/src/chat/fixtures/codex-0.159.2-usage-windows.json +74 -0
  267. package/src/chat/input.ts +89 -0
  268. package/src/chat/limit-resume.ts +74 -0
  269. package/src/chat/projector.ts +969 -0
  270. package/src/chat/request-summary.ts +168 -0
  271. package/src/chat/subagent-projection.ts +45 -0
  272. package/src/chat/subagent-reader.ts +469 -0
  273. package/src/chat/subagent-settlement.ts +111 -0
  274. package/src/chat/thread.ts +167 -0
  275. package/src/chat/wake-chat.ts +45 -0
  276. package/src/client-sinks.ts +39 -0
  277. package/src/coded-error.ts +18 -0
  278. package/src/context/argv.ts +61 -0
  279. package/src/context/refusal.ts +50 -0
  280. package/src/context/verb.ts +392 -0
  281. package/src/error-text.ts +28 -0
  282. package/src/events.ts +9 -0
  283. package/src/fs.ts +118 -0
  284. package/src/host/agent-host.ts +124 -0
  285. package/src/host/environment.ts +31 -0
  286. package/src/host/handlers.ts +142 -0
  287. package/src/host/memory-port.ts +27 -0
  288. package/src/host/wiring.ts +164 -0
  289. package/src/lineage.ts +159 -0
  290. package/src/messages/deliver-message.ts +61 -0
  291. package/src/messages/deliver-notice.ts +120 -0
  292. package/src/messages/notice-notes.ts +34 -0
  293. package/src/messages/notice-store.ts +142 -0
  294. package/src/modes.ts +38 -0
  295. package/src/outbox/manual-clock.ts +31 -0
  296. package/src/outbox/outbox-worker.ts +214 -0
  297. package/src/outbox/outbox.ts +106 -0
  298. package/src/providers/accounts/accounts.ts +192 -0
  299. package/src/providers/accounts/launch.ts +55 -0
  300. package/src/providers/accounts/service.ts +632 -0
  301. package/src/providers/accounts/shadow-home.ts +85 -0
  302. package/src/providers/accounts/status.ts +106 -0
  303. package/src/providers/accounts/store.ts +158 -0
  304. package/src/providers/accounts/test-accounts.ts +48 -0
  305. package/src/providers/accounts/variables.ts +132 -0
  306. package/src/providers/catalog.ts +90 -0
  307. package/src/providers/claude-models.json +114 -0
  308. package/src/providers/claude-provider.ts +32 -0
  309. package/src/providers/claude.ts +123 -0
  310. package/src/providers/codex-models.json +135 -0
  311. package/src/providers/codex-provider.ts +30 -0
  312. package/src/providers/codex-rules.ts +54 -0
  313. package/src/providers/codex.ts +69 -0
  314. package/src/providers/detect.ts +40 -0
  315. package/src/providers/provider.ts +46 -0
  316. package/src/providers/registry.ts +150 -0
  317. package/src/record-directory.ts +136 -0
  318. package/src/run-process.ts +61 -0
  319. package/src/serializer.ts +41 -0
  320. package/src/skills.ts +199 -0
  321. package/src/tasks/background-limit.ts +72 -0
  322. package/src/tasks/end-children.ts +100 -0
  323. package/src/tasks/give-task.ts +52 -0
  324. package/src/tasks/task-coordinator.ts +384 -0
  325. package/src/tasks/task-store.ts +236 -0
  326. package/src/tasks/task-work.ts +62 -0
  327. package/src/tasks/waiting-child.ts +203 -0
  328. package/src/tasks/wake-parent.ts +142 -0
  329. package/src/tasks/wiring.ts +231 -0
  330. package/src/title-file.ts +57 -0
  331. package/src/usage/accounts.ts +86 -0
  332. package/src/usage/aggregate.ts +220 -0
  333. package/src/usage/exchange.ts +93 -0
  334. package/src/usage/index-file.ts +178 -0
  335. package/src/usage/limits/monitor.ts +239 -0
  336. package/src/usage/limits/normalize.ts +188 -0
  337. package/src/usage/limits/probe.ts +120 -0
  338. package/src/usage/prices-snapshot.json +1071 -0
  339. package/src/usage/pricing.ts +236 -0
  340. package/src/usage/projects.ts +65 -0
  341. package/src/usage/readers/claude.ts +60 -0
  342. package/src/usage/readers/codex.ts +196 -0
  343. package/src/usage/record.ts +60 -0
  344. package/src/usage/roots.ts +39 -0
  345. package/src/usage/scanner.ts +265 -0
  346. package/src/usage/usage-service.ts +161 -0
  347. package/src/watch-seam.ts +111 -0
  348. package/src/watch-test-helpers.ts +102 -0
package/LICENSE ADDED
@@ -0,0 +1,110 @@
1
+ # Functional Source License, Version 1.1, MIT Future License
2
+
3
+ ## Abbreviation
4
+
5
+ FSL-1.1-MIT
6
+
7
+ ## Notice
8
+
9
+ Copyright 2026 Bas Milius
10
+
11
+ ## Terms and Conditions
12
+
13
+ ### Licensor ("We")
14
+
15
+ The party offering the Software under these Terms and Conditions.
16
+
17
+ ### The Software
18
+
19
+ The "Software" is each version of the software that we make available under
20
+ these Terms and Conditions, as indicated by our inclusion of these Terms and
21
+ Conditions with the Software.
22
+
23
+ ### License Grant
24
+
25
+ Subject to your compliance with this License Grant and the Patents,
26
+ Redistribution and Trademark clauses below, we hereby grant you the right to
27
+ use, copy, modify, create derivative works, publicly perform, publicly display
28
+ and redistribute the Software for any Permitted Purpose identified below.
29
+
30
+ ### Permitted Purpose
31
+
32
+ A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
33
+ means making the Software available to others in a commercial product or
34
+ service that:
35
+
36
+ 1. substitutes for the Software;
37
+
38
+ 2. substitutes for any other product or service we offer using the Software
39
+ that exists as of the date we make the Software available; or
40
+
41
+ 3. offers the same or substantially similar functionality as the Software.
42
+
43
+ Permitted Purposes specifically include using the Software:
44
+
45
+ 1. for your internal use and access;
46
+
47
+ 2. for non-commercial education;
48
+
49
+ 3. for non-commercial research; and
50
+
51
+ 4. in connection with professional services that you provide to a licensee
52
+ using the Software in accordance with these Terms and Conditions.
53
+
54
+ ### Patents
55
+
56
+ To the extent your use for a Permitted Purpose would necessarily infringe our
57
+ patents, the license grant above includes a license under our patents. If you
58
+ make a claim against any party that the Software infringes or contributes to
59
+ the infringement of any patent, then your patent license to the Software ends
60
+ immediately.
61
+
62
+ ### Redistribution
63
+
64
+ The Terms and Conditions apply to all copies, modifications and derivatives of
65
+ the Software.
66
+
67
+ If you redistribute any copies, modifications or derivatives of the Software,
68
+ you must include a copy of or a link to these Terms and Conditions and not
69
+ remove any copyright notices provided in or with the Software.
70
+
71
+ ### Disclaimer
72
+
73
+ THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
74
+ IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
75
+ PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
76
+
77
+ IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
78
+ SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
79
+ EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
80
+
81
+ ### Trademarks
82
+
83
+ Except for displaying the License Details and identifying us as the origin of
84
+ the Software, you have no right under these Terms and Conditions to use our
85
+ trademarks, trade names, service marks or product names.
86
+
87
+ ## Grant of Future License
88
+
89
+ We hereby irrevocably grant you an additional license to use the Software under
90
+ the MIT license that is effective on the second anniversary of the date we make
91
+ the Software available. On or after that date, you may use the Software under
92
+ the MIT license, in which case the following will apply:
93
+
94
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
95
+ this software and associated documentation files (the "Software"), to deal in
96
+ the Software without restriction, including without limitation the rights to
97
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
98
+ of the Software, and to permit persons to whom the Software is furnished to do
99
+ so, subject to the following conditions:
100
+
101
+ The above copyright notice and this permission notice shall be included in all
102
+ copies or substantial portions of the Software.
103
+
104
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
105
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
106
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
107
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
108
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
109
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
110
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # @adecore/agents
2
+
3
+ Agent chat hosting for Node and Bun, including an Electron utility process. Claude Code and Codex backends share a session/thread model, streamed events, persisted chats, provider accounts, usage, and durable coordination modules. A consumer supplies permissions, transport ownership, placement, context commands, and application lifecycle policy.
4
+
5
+ ```ts
6
+ import { AgentHost } from '@adecore/agents/host/agent-host';
7
+ import { cliEnvironment } from '@adecore/agents/host/environment';
8
+ import type { FramePort } from '@adecore/agent-contracts';
9
+
10
+ export async function openHost(dataDir: string, port: FramePort) {
11
+ const host = await AgentHost.open({ dataDir, env: cliEnvironment(process.env, { sessionPrefixes: ['APP'] }) });
12
+ const disconnect = host.connect(port);
13
+ return {
14
+ host,
15
+ async close(): Promise<void> {
16
+ disconnect();
17
+ await host.close();
18
+ }
19
+ };
20
+ }
21
+ ```
22
+
23
+ A chat starts a CLI on its first prompt. Choose its runtime mode explicitly: the plain core defaults to `full-access`. Install/authenticate provider CLIs separately. For checks without real providers, inject `spawn` and `detect` and use the complete [fake-provider walkthrough](https://adecore.dev/agents/getting-started).
24
+
25
+ The [documentation](https://adecore.dev/agents/) covers [transport](https://adecore.dev/agents/transport), [host hooks](https://adecore.dev/agents/host-integration), [providers/models](https://adecore.dev/agents/providers-and-models), [turns/requests](https://adecore.dev/agents/turns-and-requests), [accounts/environment](https://adecore.dev/agents/accounts-and-environment), [outbox/tasks/messages](https://adecore.dev/agents/coordination), [context commands](https://adecore.dev/agents/context-commands), [persistence/helpers](https://adecore.dev/agents/persistence-and-helpers), [testing](https://adecore.dev/agents/testing-and-troubleshooting), [subpaths](https://adecore.dev/agents/entrypoints), and [migration](https://adecore.dev/agents/migration).
26
+
27
+ `wireAgents` supplies the same services and handlers for a host protocol of your own. `ChatCore` is extensible through admission, instructions, environment, prompt notes, folders, policy, persistence, and recovery hooks. A plain host refuses placement-dependent fork/continuation requests and installs no task/message context endpoint.
28
+
29
+ Import per module, `@adecore/agents/<path under src>` without an extension; there is no root export. Existing helper and coordination subpaths remain supported. [examples/agent-port](../../examples/agent-port) checks host, React transport/client, scope, and locale loading with fakes. Run its `test` script for source exports or `test:dist` after building for Node default exports.
30
+
31
+ Build `@adecore/agent-contracts` first, then run this package's `typecheck`, `test`, and `build` scripts. Default exports use compiled JavaScript/declarations; `source` selects TypeScript. No production source requires a Bun API.
32
+
33
+ This package is private at `0.0.0`, pending publication setup, and retains FSL-1.1-MIT. See [LICENSE](./LICENSE).
@@ -0,0 +1,2 @@
1
+ export declare function wait(ms: number, signal?: AbortSignal): Promise<void>;
2
+ export declare function withTimeout<T>(promise: Promise<T>, ms: number, message: string): Promise<T>;
package/dist/async.js ADDED
@@ -0,0 +1,31 @@
1
+ /* The two waits the host does: a pause it can be woken from, and a deadline on somebody else's promise. */
2
+ /*
3
+ * Resolves after `ms`, or at once when the signal is raised. An abort ends the wait rather than
4
+ * failing it: every caller here is a loop that checks the signal itself on the next turn, and a
5
+ * rejection would only be caught and thrown away.
6
+ */
7
+ export function wait(ms, signal) {
8
+ return new Promise((resolve) => {
9
+ const timer = setTimeout(resolve, ms);
10
+ signal?.addEventListener('abort', () => {
11
+ clearTimeout(timer);
12
+ resolve();
13
+ }, { once: true });
14
+ });
15
+ }
16
+ /*
17
+ * The promise, or `message` when it takes longer than `ms`. The timer is cleared either way, so a
18
+ * call that answers at once does not hold the process for the rest of its deadline.
19
+ */
20
+ export function withTimeout(promise, ms, message) {
21
+ return new Promise((resolve, reject) => {
22
+ const timer = setTimeout(() => reject(new Error(message)), ms);
23
+ promise.then((value) => {
24
+ clearTimeout(timer);
25
+ resolve(value);
26
+ }, (e) => {
27
+ clearTimeout(timer);
28
+ reject(e instanceof Error ? e : new Error(String(e)));
29
+ });
30
+ });
31
+ }
@@ -0,0 +1,10 @@
1
+ import { type ChatAttachment, type ChatAttachmentUpload } from '@adecore/agent-contracts';
2
+ export declare function extensionFor(name: string, mime: string): string;
3
+ export declare class AttachmentStore {
4
+ readonly dir: string;
5
+ constructor(home: string);
6
+ save(chatId: string, upload: ChatAttachmentUpload): Promise<ChatAttachment>;
7
+ removeAll(chatId: string): Promise<void>;
8
+ private folder;
9
+ }
10
+ export declare function migrateInlineAttachments(chatId: string, record: unknown, store: AttachmentStore): Promise<unknown | null>;
@@ -0,0 +1,93 @@
1
+ import { randomBytes } from 'node:crypto';
2
+ import { mkdir, rm, writeFile } from 'node:fs/promises';
3
+ import { extname, join } from 'node:path';
4
+ import { attachmentImageMime } from '@adecore/agent-contracts';
5
+ // The extension the file gets on disk when its name does not carry a usable one.
6
+ const EXTENSIONS = {
7
+ 'image/png': 'png',
8
+ 'image/jpeg': 'jpg',
9
+ 'image/gif': 'gif',
10
+ 'image/webp': 'webp',
11
+ 'image/svg+xml': 'svg',
12
+ 'application/pdf': 'pdf',
13
+ 'application/json': 'json',
14
+ 'text/csv': 'csv',
15
+ 'text/markdown': 'md',
16
+ 'text/plain': 'txt'
17
+ };
18
+ const SAFE_EXTENSION = /^[A-Za-z0-9]{1,8}$/;
19
+ /* What the file is called on disk: the id, plus an extension the agent's tools can recognize. */
20
+ export function extensionFor(name, mime) {
21
+ const own = extname(name).slice(1).toLowerCase();
22
+ if (SAFE_EXTENSION.test(own)) {
23
+ return own;
24
+ }
25
+ const known = EXTENSIONS[mime.toLowerCase()];
26
+ if (known) {
27
+ return known;
28
+ }
29
+ const subtype = mime.split('/')[1]?.replace(/\+.*$/, '') ?? '';
30
+ return SAFE_EXTENSION.test(subtype) ? subtype.toLowerCase() : 'bin';
31
+ }
32
+ /*
33
+ * The files people attach to a message, under `<home>/attachments/<chatId>`. The thread keeps
34
+ * only what a row needs (name, mime, size, path); the bytes stay on disk, so a thread with a video
35
+ * in it is still a small JSON file.
36
+ */
37
+ export class AttachmentStore {
38
+ dir;
39
+ constructor(home) {
40
+ this.dir = join(home, 'attachments');
41
+ }
42
+ /* Writes one upload and answers the metadata the thread stores. */
43
+ async save(chatId, upload) {
44
+ const bytes = Buffer.from(upload.data, 'base64');
45
+ const mime = attachmentImageMime(upload) ?? upload.mime;
46
+ const id = randomBytes(8).toString('hex');
47
+ const folder = this.folder(chatId);
48
+ await mkdir(folder, { recursive: true, mode: 0o700 });
49
+ const path = join(folder, `${id}.${extensionFor(upload.name, mime)}`);
50
+ await writeFile(path, bytes, { mode: 0o600 });
51
+ return { id, name: upload.name, mime, size: bytes.byteLength, path };
52
+ }
53
+ /* Everything a chat attached; used when the chat itself is deleted. */
54
+ async removeAll(chatId) {
55
+ await rm(this.folder(chatId), { recursive: true, force: true });
56
+ }
57
+ folder(chatId) {
58
+ return join(this.dir, encodeURIComponent(chatId));
59
+ }
60
+ }
61
+ function isRecord(value) {
62
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
63
+ }
64
+ // What an attachment looked like before the files moved out of the thread: the bytes inline.
65
+ function isInline(value) {
66
+ return isRecord(value) && typeof value.name === 'string' && typeof value.mediaType === 'string' && typeof value.data === 'string';
67
+ }
68
+ /*
69
+ * Writes out the images a thread still carries inline and answers the record with metadata in their
70
+ * place, or null when there was nothing to do. Old records are migrated on the read that opens the
71
+ * chat, before the schema sees them, because the schema no longer knows the inline shape.
72
+ */
73
+ export async function migrateInlineAttachments(chatId, record, store) {
74
+ const items = isRecord(record) && Array.isArray(record.items) ? record.items : null;
75
+ if (!items) {
76
+ return null;
77
+ }
78
+ let migrated = false;
79
+ const next = await Promise.all(items.map(async (item) => {
80
+ if (!isRecord(item) || !Array.isArray(item.attachments) || !item.attachments.some(isInline)) {
81
+ return item;
82
+ }
83
+ const attachments = await Promise.all(item.attachments.map(async (attachment) => {
84
+ if (!isInline(attachment)) {
85
+ return attachment;
86
+ }
87
+ migrated = true;
88
+ return await store.save(chatId, { name: attachment.name, mime: attachment.mediaType, data: attachment.data });
89
+ }));
90
+ return { ...item, attachments };
91
+ }));
92
+ return migrated ? { ...record, items: next } : null;
93
+ }
@@ -0,0 +1,214 @@
1
+ import type { ChatAttachment, ChatFileChange, ChatQuestion, ChatSkill, ChatSubagentUsage, ChatTurnLimit, ChatWorkflow, ModelSelection, RuntimeMode } from '@adecore/agent-contracts';
2
+ import type { LimitsUpdate } from '../usage/limits/normalize.ts';
3
+ import type { SpawnChatProcess } from './chat-process.ts';
4
+ export interface BackendLaunch {
5
+ command: string[];
6
+ cwd: string;
7
+ env: Record<string, string>;
8
+ selection: ModelSelection;
9
+ modelName: string;
10
+ runtimeMode: RuntimeMode;
11
+ resume: string | null;
12
+ generation: number;
13
+ instructions: string | null;
14
+ resumeNote: string | null;
15
+ folders?: readonly string[];
16
+ spawn?: SpawnChatProcess;
17
+ }
18
+ export interface TurnInput {
19
+ promptId?: string;
20
+ text: string;
21
+ preamble: string | null;
22
+ attachments: ChatAttachment[];
23
+ mentions: string[];
24
+ skills: string[];
25
+ }
26
+ export type ApprovalDecision = 'allow' | 'allow-always' | 'deny';
27
+ export type BackendEvent = {
28
+ type: 'turn.accepted';
29
+ promptId: string;
30
+ } | {
31
+ type: 'session';
32
+ agentSessionId: string | null;
33
+ model: string | null;
34
+ slashCommands?: string[];
35
+ skills?: string[];
36
+ title?: string | null;
37
+ effectiveRuntimeMode?: RuntimeMode;
38
+ permissionMode?: string;
39
+ } | {
40
+ type: 'title';
41
+ title: string;
42
+ } | {
43
+ type: 'permissions';
44
+ permissionMode: string;
45
+ effectiveRuntimeMode?: RuntimeMode;
46
+ } | {
47
+ type: 'text.delta';
48
+ ref: string;
49
+ text: string;
50
+ } | {
51
+ type: 'text.done';
52
+ ref: string;
53
+ text: string;
54
+ parentRef?: string | null;
55
+ } | {
56
+ type: 'thinking.delta';
57
+ ref: string;
58
+ text: string;
59
+ } | {
60
+ type: 'thinking.done';
61
+ ref: string;
62
+ text: string;
63
+ } | {
64
+ type: 'tool.started';
65
+ ref: string;
66
+ name: string;
67
+ input: unknown;
68
+ parentRef: string | null;
69
+ changes?: ChatFileChange[];
70
+ } | {
71
+ type: 'tool.progress';
72
+ ref: string;
73
+ startedAt: number | null;
74
+ description: string | null;
75
+ } | {
76
+ type: 'tool.output';
77
+ ref: string;
78
+ text: string;
79
+ } | {
80
+ type: 'tool.done';
81
+ ref: string;
82
+ output: string | null;
83
+ state: 'done' | 'error';
84
+ changes?: ChatFileChange[];
85
+ } | {
86
+ type: 'approval.requested';
87
+ requestId: string;
88
+ ref: string | null;
89
+ toolName: string;
90
+ input: unknown;
91
+ description: string | null;
92
+ canAllowAlways: boolean;
93
+ background?: boolean;
94
+ allowAlways?: {
95
+ label: string;
96
+ description: string;
97
+ };
98
+ } | {
99
+ type: 'question.requested';
100
+ requestId: string;
101
+ questions: ChatQuestion[];
102
+ async?: boolean;
103
+ background?: boolean;
104
+ } | {
105
+ type: 'request.withdrawn';
106
+ requestId: string;
107
+ } | {
108
+ type: 'task.started';
109
+ ref: string;
110
+ description: string | null;
111
+ subagentType: string | null;
112
+ prompt: string | null;
113
+ background: boolean;
114
+ taskId?: string | null;
115
+ threadId?: string | null;
116
+ depth?: number;
117
+ resumed?: boolean;
118
+ } | {
119
+ type: 'task.progress';
120
+ ref: string;
121
+ taskId?: string | null;
122
+ summary: string | null;
123
+ lastTool: string | null;
124
+ usage: ChatSubagentUsage | null;
125
+ } | {
126
+ type: 'task.model';
127
+ ref: string;
128
+ model: string;
129
+ } | {
130
+ type: 'task.done';
131
+ ref: string | null;
132
+ taskId?: string | null;
133
+ summary: string | null;
134
+ ok: boolean;
135
+ usage?: ChatSubagentUsage | null;
136
+ outputFile?: string | null;
137
+ } | {
138
+ type: 'workflow.progress';
139
+ ref: string;
140
+ workflow: ChatWorkflow;
141
+ } | {
142
+ type: 'background.started';
143
+ taskId: string;
144
+ ref: string | null;
145
+ monitor: boolean;
146
+ description: string | null;
147
+ } | {
148
+ type: 'background.ended';
149
+ taskId: string;
150
+ } | {
151
+ type: 'usage';
152
+ contextTokens?: number;
153
+ contextWindow?: number;
154
+ costUsd?: number;
155
+ } | {
156
+ type: 'limits';
157
+ update: LimitsUpdate;
158
+ } | {
159
+ type: 'compaction';
160
+ preTokens: number | null;
161
+ } | {
162
+ type: 'model';
163
+ model: string;
164
+ } | {
165
+ type: 'note';
166
+ level: 'info' | 'warning' | 'error';
167
+ text: string;
168
+ } | {
169
+ type: 'turn.done';
170
+ promptId?: string;
171
+ state: 'done' | 'aborted' | 'error';
172
+ costUsd: number;
173
+ error?: string;
174
+ native?: {
175
+ turnId?: string;
176
+ lastUuid?: string;
177
+ };
178
+ limit?: ChatTurnLimit;
179
+ } | {
180
+ type: 'failed';
181
+ message: string;
182
+ processAlive?: boolean;
183
+ } | {
184
+ type: 'exit';
185
+ exitCode: number | null;
186
+ stderr?: string;
187
+ };
188
+ export interface BackendHost {
189
+ onEvent(event: BackendEvent): void;
190
+ }
191
+ export interface ChatBackend {
192
+ readonly acknowledgesTurns?: boolean;
193
+ readonly running: boolean;
194
+ readonly pid: number | null;
195
+ start(): Promise<void>;
196
+ sendTurn(input: TurnInput): void;
197
+ compact(): void;
198
+ interrupt(): void;
199
+ respondApproval(requestId: string, decision: ApprovalDecision, message?: string): boolean;
200
+ respondQuestion(requestId: string, answers: Record<string, string>): boolean;
201
+ stopTask?(taskId: string): void;
202
+ declineRequest?(requestId: string, message: string): boolean;
203
+ dismissRequest?(requestId: string): boolean;
204
+ setTitle?(title: string): void;
205
+ listSkills?(): Promise<ChatSkill[]>;
206
+ listThreadItems?(params: {
207
+ threadId: string;
208
+ cursor?: string;
209
+ limit: number;
210
+ sortDirection: 'asc' | 'desc';
211
+ }): Promise<unknown>;
212
+ stop(): void;
213
+ dispose(): Promise<void>;
214
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ import type { AgentKind, ChatBackgroundTask, ChatItem, ChatSubagentItem, ChatToolItem } from '@adecore/agent-contracts';
2
+ export type BackgroundWork = ChatSubagentItem | ChatToolItem;
3
+ export declare function isBackgroundWork(item: ChatItem): item is BackgroundWork;
4
+ export declare function runsInBackground(item: BackgroundWork): boolean;
5
+ export declare function runningInBackground(items: readonly ChatItem[]): BackgroundWork[];
6
+ export declare const BACKGROUND_COMMAND_LIMIT_MS: number;
7
+ export declare function commandLabel(task: ChatBackgroundTask): string;
8
+ export declare function reportsOnBackgroundWork(provider: AgentKind): boolean;
@@ -0,0 +1,33 @@
1
+ /*
2
+ * Work a chat's CLI goes on with after the turn that started it ended: a subagent it runs in the
3
+ * background (Claude's `run_in_background`, every agent Codex spawns) and a Claude workflow, whose call
4
+ * answers at launch. A command or a monitor sent to the background is not work of this kind but a
5
+ * `ChatBackgroundTask` in the chat's info, held to `BACKGROUND_COMMAND_LIMIT_MS`; a row the host drew for
6
+ * work it delegated itself (origin `ruimte` on the wire) is that work's own.
7
+ */
8
+ export function isBackgroundWork(item) {
9
+ return (item.kind === 'subagent' && item.background && item.origin !== 'ruimte') || (item.kind === 'tool' && item.name === 'Workflow');
10
+ }
11
+ export function runsInBackground(item) {
12
+ return item.kind === 'subagent' ? item.status === 'running' : item.state === 'running';
13
+ }
14
+ export function runningInBackground(items) {
15
+ return items.filter((item) => isBackgroundWork(item) && runsInBackground(item));
16
+ }
17
+ /*
18
+ * How long a command or a monitor still running in the background holds a child's task once nothing
19
+ * else does, since a dev server never ends. Subagents and workflows have no such limit.
20
+ */
21
+ export const BACKGROUND_COMMAND_LIMIT_MS = 30 * 60_000;
22
+ export function commandLabel(task) {
23
+ return task.command ?? (task.description === '' ? task.id : task.description);
24
+ }
25
+ /*
26
+ * Whether the CLI opens a turn of its own once its background work ended, to tell what came of it.
27
+ * Claude Code 2.1.282 does after every task notification, a command's included; a command a subagent
28
+ * started first takes that subagent up again, which then notifies the main agent. Codex 0.156.1
29
+ * reports a spawned agent completed and opens nothing.
30
+ */
31
+ export function reportsOnBackgroundWork(provider) {
32
+ return provider === 'claude';
33
+ }
@@ -0,0 +1,25 @@
1
+ import { type ChatBookmark } from '@adecore/agent-contracts';
2
+ export declare function bookmarkFileName(chatId: string): string;
3
+ export declare function isBookmarkFileName(name: string): boolean;
4
+ export type BookmarkListener = (chatId: string, bookmarks: ChatBookmark[]) => void;
5
+ export declare class BookmarkStore {
6
+ readonly dir: string;
7
+ private readonly writes;
8
+ private readonly listeners;
9
+ constructor(home: string);
10
+ listen(listener: BookmarkListener): () => void;
11
+ read(chatId: string): Promise<ChatBookmark[]>;
12
+ add(chatId: string, input: {
13
+ itemId: string;
14
+ excerpt: string;
15
+ name?: string;
16
+ }, now: number): Promise<ChatBookmark[]>;
17
+ rename(chatId: string, itemId: string, name: string): Promise<ChatBookmark[]>;
18
+ remove(chatId: string, itemId: string): Promise<ChatBookmark[]>;
19
+ removeChat(chatId: string): Promise<void>;
20
+ copyChat(fromChatId: string, toChatId: string, keep: (itemId: string) => boolean): Promise<void>;
21
+ private change;
22
+ private tell;
23
+ private readFile;
24
+ private writeFile;
25
+ }