@twelvehart/orcats 0.0.0-seed.0 → 0.2.3

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 (275) hide show
  1. package/LICENSE +48 -0
  2. package/NOTICE +5 -0
  3. package/README.md +399 -0
  4. package/bin/orcats +4 -0
  5. package/dist/backends/acp-client.d.ts +74 -0
  6. package/dist/backends/acp-client.d.ts.map +1 -0
  7. package/dist/backends/acp-run.d.ts +31 -0
  8. package/dist/backends/acp-run.d.ts.map +1 -0
  9. package/dist/backends/claude-run.d.ts +35 -0
  10. package/dist/backends/claude-run.d.ts.map +1 -0
  11. package/dist/backends/claude-stream-json.d.ts +15 -0
  12. package/dist/backends/claude-stream-json.d.ts.map +1 -0
  13. package/dist/backends/codex-jsonl.d.ts +34 -0
  14. package/dist/backends/codex-jsonl.d.ts.map +1 -0
  15. package/dist/backends/codex-run.d.ts +40 -0
  16. package/dist/backends/codex-run.d.ts.map +1 -0
  17. package/dist/backends/codex.d.ts +5 -0
  18. package/dist/backends/codex.d.ts.map +1 -0
  19. package/dist/backends/conversation-config.d.ts +12 -0
  20. package/dist/backends/conversation-config.d.ts.map +1 -0
  21. package/dist/backends/index.d.ts +14 -0
  22. package/dist/backends/index.d.ts.map +1 -0
  23. package/dist/backends/opencode-run.d.ts +48 -0
  24. package/dist/backends/opencode-run.d.ts.map +1 -0
  25. package/dist/backends/opencode-sse.d.ts +35 -0
  26. package/dist/backends/opencode-sse.d.ts.map +1 -0
  27. package/dist/backends/pi-rpc.d.ts +21 -0
  28. package/dist/backends/pi-rpc.d.ts.map +1 -0
  29. package/dist/backends/pi-run.d.ts +21 -0
  30. package/dist/backends/pi-run.d.ts.map +1 -0
  31. package/dist/backends/select.d.ts +17 -0
  32. package/dist/backends/select.d.ts.map +1 -0
  33. package/dist/backends/subprocess-run.d.ts +68 -0
  34. package/dist/backends/subprocess-run.d.ts.map +1 -0
  35. package/dist/backends/types.d.ts +17 -0
  36. package/dist/backends/types.d.ts.map +1 -0
  37. package/dist/backends/unsupported.d.ts +9 -0
  38. package/dist/backends/unsupported.d.ts.map +1 -0
  39. package/dist/baseline/index.d.ts +56 -0
  40. package/dist/baseline/index.d.ts.map +1 -0
  41. package/dist/cli/args.d.ts +22 -0
  42. package/dist/cli/args.d.ts.map +1 -0
  43. package/dist/cli/embedded.d.ts +7 -0
  44. package/dist/cli/embedded.d.ts.map +1 -0
  45. package/dist/cli/main.d.ts +6 -0
  46. package/dist/cli/main.d.ts.map +1 -0
  47. package/dist/cli/version.d.ts +2 -0
  48. package/dist/cli/version.d.ts.map +1 -0
  49. package/dist/conversation/ask-user.d.ts +17 -0
  50. package/dist/conversation/ask-user.d.ts.map +1 -0
  51. package/dist/conversation/conversation.d.ts +46 -0
  52. package/dist/conversation/conversation.d.ts.map +1 -0
  53. package/dist/conversation/harness.d.ts +14 -0
  54. package/dist/conversation/harness.d.ts.map +1 -0
  55. package/dist/conversation/index.d.ts +5 -0
  56. package/dist/conversation/index.d.ts.map +1 -0
  57. package/dist/conversation/queue.d.ts +15 -0
  58. package/dist/conversation/queue.d.ts.map +1 -0
  59. package/dist/flow/accessors.d.ts +13 -0
  60. package/dist/flow/accessors.d.ts.map +1 -0
  61. package/dist/flow/approvals.d.ts +6 -0
  62. package/dist/flow/approvals.d.ts.map +1 -0
  63. package/dist/flow/args.d.ts +4 -0
  64. package/dist/flow/args.d.ts.map +1 -0
  65. package/dist/flow/context.d.ts +36 -0
  66. package/dist/flow/context.d.ts.map +1 -0
  67. package/dist/flow/index.d.ts +5 -0
  68. package/dist/flow/index.d.ts.map +1 -0
  69. package/dist/index.d.ts +16 -0
  70. package/dist/index.d.ts.map +1 -0
  71. package/dist/loop/builder/index.d.ts +17 -0
  72. package/dist/loop/builder/index.d.ts.map +1 -0
  73. package/dist/loop/builder/types.d.ts +97 -0
  74. package/dist/loop/builder/types.d.ts.map +1 -0
  75. package/dist/loop/context/compaction.d.ts +38 -0
  76. package/dist/loop/context/compaction.d.ts.map +1 -0
  77. package/dist/loop/context/index.d.ts +4 -0
  78. package/dist/loop/context/index.d.ts.map +1 -0
  79. package/dist/loop/context/offload.d.ts +34 -0
  80. package/dist/loop/context/offload.d.ts.map +1 -0
  81. package/dist/loop/context/types.d.ts +13 -0
  82. package/dist/loop/context/types.d.ts.map +1 -0
  83. package/dist/loop/engine/bridge.d.ts +21 -0
  84. package/dist/loop/engine/bridge.d.ts.map +1 -0
  85. package/dist/loop/engine/index.d.ts +73 -0
  86. package/dist/loop/engine/index.d.ts.map +1 -0
  87. package/dist/loop/execution.d.ts +68 -0
  88. package/dist/loop/execution.d.ts.map +1 -0
  89. package/dist/loop/fanout.d.ts +148 -0
  90. package/dist/loop/fanout.d.ts.map +1 -0
  91. package/dist/loop/firing.d.ts +54 -0
  92. package/dist/loop/firing.d.ts.map +1 -0
  93. package/dist/loop/graph/analyze.d.ts +8 -0
  94. package/dist/loop/graph/analyze.d.ts.map +1 -0
  95. package/dist/loop/graph/index.d.ts +3 -0
  96. package/dist/loop/graph/index.d.ts.map +1 -0
  97. package/dist/loop/graph/types.d.ts +35 -0
  98. package/dist/loop/graph/types.d.ts.map +1 -0
  99. package/dist/loop/index.d.ts +7 -0
  100. package/dist/loop/index.d.ts.map +1 -0
  101. package/dist/loop/io/index.d.ts +4 -0
  102. package/dist/loop/io/index.d.ts.map +1 -0
  103. package/dist/loop/io/linear.d.ts +142 -0
  104. package/dist/loop/io/linear.d.ts.map +1 -0
  105. package/dist/loop/io/sink.d.ts +47 -0
  106. package/dist/loop/io/sink.d.ts.map +1 -0
  107. package/dist/loop/io/source.d.ts +64 -0
  108. package/dist/loop/io/source.d.ts.map +1 -0
  109. package/dist/loop/serve.d.ts +97 -0
  110. package/dist/loop/serve.d.ts.map +1 -0
  111. package/dist/loop/state/index.d.ts +5 -0
  112. package/dist/loop/state/index.d.ts.map +1 -0
  113. package/dist/loop/state/manifest.d.ts +36 -0
  114. package/dist/loop/state/manifest.d.ts.map +1 -0
  115. package/dist/loop/state/port.d.ts +33 -0
  116. package/dist/loop/state/port.d.ts.map +1 -0
  117. package/dist/loop/state/snapshot.d.ts +15 -0
  118. package/dist/loop/state/snapshot.d.ts.map +1 -0
  119. package/dist/loop/state/sqlite.d.ts +31 -0
  120. package/dist/loop/state/sqlite.d.ts.map +1 -0
  121. package/dist/loop/termination-contract.d.ts +28 -0
  122. package/dist/loop/termination-contract.d.ts.map +1 -0
  123. package/dist/loop/termination.d.ts +33 -0
  124. package/dist/loop/termination.d.ts.map +1 -0
  125. package/dist/model/backend-config.d.ts +30 -0
  126. package/dist/model/backend-config.d.ts.map +1 -0
  127. package/dist/model/brand.d.ts +9 -0
  128. package/dist/model/brand.d.ts.map +1 -0
  129. package/dist/model/errors.d.ts +11 -0
  130. package/dist/model/errors.d.ts.map +1 -0
  131. package/dist/model/index.d.ts +8 -0
  132. package/dist/model/index.d.ts.map +1 -0
  133. package/dist/model/json-schema.d.ts +4 -0
  134. package/dist/model/json-schema.d.ts.map +1 -0
  135. package/dist/model/result.d.ts +3 -0
  136. package/dist/model/result.d.ts.map +1 -0
  137. package/dist/model/schemas.d.ts +435 -0
  138. package/dist/model/schemas.d.ts.map +1 -0
  139. package/dist/model/structured.d.ts +9 -0
  140. package/dist/model/structured.d.ts.map +1 -0
  141. package/dist/monitor/index.d.ts +139 -0
  142. package/dist/monitor/index.d.ts.map +1 -0
  143. package/dist/plan/index.d.ts +3 -0
  144. package/dist/plan/index.d.ts.map +1 -0
  145. package/dist/plan/persistent.d.ts +23 -0
  146. package/dist/plan/persistent.d.ts.map +1 -0
  147. package/dist/plan/verdict.d.ts +9 -0
  148. package/dist/plan/verdict.d.ts.map +1 -0
  149. package/dist/review/index.d.ts +4 -0
  150. package/dist/review/index.d.ts.map +1 -0
  151. package/dist/review/loop.d.ts +117 -0
  152. package/dist/review/loop.d.ts.map +1 -0
  153. package/dist/review/reviewers.d.ts +13 -0
  154. package/dist/review/reviewers.d.ts.map +1 -0
  155. package/dist/review/tool.d.ts +20 -0
  156. package/dist/review/tool.d.ts.map +1 -0
  157. package/dist/run-output/index.d.ts +112 -0
  158. package/dist/run-output/index.d.ts.map +1 -0
  159. package/dist/runner/index.d.ts +2 -0
  160. package/dist/runner/index.d.ts.map +1 -0
  161. package/dist/runner/typecheck.d.ts +23 -0
  162. package/dist/runner/typecheck.d.ts.map +1 -0
  163. package/dist/test-utils/fakes.d.ts +76 -0
  164. package/dist/test-utils/fakes.d.ts.map +1 -0
  165. package/dist/test-utils/fixtures.d.ts +4 -0
  166. package/dist/test-utils/fixtures.d.ts.map +1 -0
  167. package/dist/test-utils/index.d.ts +4 -0
  168. package/dist/test-utils/index.d.ts.map +1 -0
  169. package/dist/test-utils/tier2.d.ts +8 -0
  170. package/dist/test-utils/tier2.d.ts.map +1 -0
  171. package/dist/tools/fs.d.ts +11 -0
  172. package/dist/tools/fs.d.ts.map +1 -0
  173. package/dist/tools/git.d.ts +10 -0
  174. package/dist/tools/git.d.ts.map +1 -0
  175. package/dist/tools/github.d.ts +13 -0
  176. package/dist/tools/github.d.ts.map +1 -0
  177. package/dist/tools/index.d.ts +7 -0
  178. package/dist/tools/index.d.ts.map +1 -0
  179. package/dist/tools/linear.d.ts +117 -0
  180. package/dist/tools/linear.d.ts.map +1 -0
  181. package/dist/tools/process.d.ts +40 -0
  182. package/dist/tools/process.d.ts.map +1 -0
  183. package/dist/tools/terminal.d.ts +23 -0
  184. package/dist/tools/terminal.d.ts.map +1 -0
  185. package/package.json +89 -9
  186. package/src/backends/acp-client.ts +324 -0
  187. package/src/backends/acp-run.ts +636 -0
  188. package/src/backends/claude-run.ts +226 -0
  189. package/src/backends/claude-stream-json.ts +273 -0
  190. package/src/backends/codex-jsonl.ts +339 -0
  191. package/src/backends/codex-run.ts +177 -0
  192. package/src/backends/codex.ts +84 -0
  193. package/src/backends/conversation-config.ts +26 -0
  194. package/src/backends/index.ts +13 -0
  195. package/src/backends/opencode-run.ts +432 -0
  196. package/src/backends/opencode-sse.ts +360 -0
  197. package/src/backends/pi-rpc.ts +242 -0
  198. package/src/backends/pi-run.ts +154 -0
  199. package/src/backends/select.ts +77 -0
  200. package/src/backends/subprocess-run.ts +305 -0
  201. package/src/backends/types.ts +29 -0
  202. package/src/backends/unsupported.ts +48 -0
  203. package/src/baseline/index.ts +437 -0
  204. package/src/cli/args.ts +109 -0
  205. package/src/cli/embedded.ts +206 -0
  206. package/src/cli/main.ts +332 -0
  207. package/src/cli/version.ts +1 -0
  208. package/src/conversation/ask-user.ts +105 -0
  209. package/src/conversation/conversation.ts +109 -0
  210. package/src/conversation/harness.ts +39 -0
  211. package/src/conversation/index.ts +4 -0
  212. package/src/conversation/queue.ts +86 -0
  213. package/src/flow/accessors.ts +43 -0
  214. package/src/flow/approvals.ts +10 -0
  215. package/src/flow/args.ts +26 -0
  216. package/src/flow/context.ts +106 -0
  217. package/src/flow/index.ts +4 -0
  218. package/src/index.ts +17 -0
  219. package/src/loop/builder/index.ts +346 -0
  220. package/src/loop/builder/types.ts +131 -0
  221. package/src/loop/context/compaction.ts +175 -0
  222. package/src/loop/context/index.ts +3 -0
  223. package/src/loop/context/offload.ts +79 -0
  224. package/src/loop/context/types.ts +17 -0
  225. package/src/loop/engine/bridge.ts +61 -0
  226. package/src/loop/engine/index.ts +166 -0
  227. package/src/loop/execution.ts +453 -0
  228. package/src/loop/fanout.ts +444 -0
  229. package/src/loop/firing.ts +188 -0
  230. package/src/loop/graph/analyze.ts +128 -0
  231. package/src/loop/graph/index.ts +2 -0
  232. package/src/loop/graph/types.ts +45 -0
  233. package/src/loop/index.ts +11 -0
  234. package/src/loop/io/index.ts +3 -0
  235. package/src/loop/io/linear.ts +714 -0
  236. package/src/loop/io/sink.ts +170 -0
  237. package/src/loop/io/source.ts +255 -0
  238. package/src/loop/serve.ts +307 -0
  239. package/src/loop/state/index.ts +4 -0
  240. package/src/loop/state/manifest.ts +56 -0
  241. package/src/loop/state/port.ts +43 -0
  242. package/src/loop/state/snapshot.ts +129 -0
  243. package/src/loop/state/sqlite.ts +265 -0
  244. package/src/loop/termination-contract.ts +89 -0
  245. package/src/loop/termination.ts +156 -0
  246. package/src/model/backend-config.ts +34 -0
  247. package/src/model/brand.ts +11 -0
  248. package/src/model/errors.ts +28 -0
  249. package/src/model/index.ts +7 -0
  250. package/src/model/json-schema.ts +14 -0
  251. package/src/model/result.ts +28 -0
  252. package/src/model/schemas.ts +218 -0
  253. package/src/model/structured.ts +26 -0
  254. package/src/monitor/index.ts +367 -0
  255. package/src/plan/index.ts +2 -0
  256. package/src/plan/persistent.ts +98 -0
  257. package/src/plan/verdict.ts +3 -0
  258. package/src/review/index.ts +3 -0
  259. package/src/review/loop.ts +365 -0
  260. package/src/review/reviewers.ts +92 -0
  261. package/src/review/tool.ts +41 -0
  262. package/src/run-output/index.ts +319 -0
  263. package/src/runner/index.ts +1 -0
  264. package/src/runner/typecheck.ts +72 -0
  265. package/src/test-utils/fakes.ts +260 -0
  266. package/src/test-utils/fixtures.ts +33 -0
  267. package/src/test-utils/index.ts +3 -0
  268. package/src/test-utils/tier2.ts +12 -0
  269. package/src/tools/fs.ts +44 -0
  270. package/src/tools/git.ts +34 -0
  271. package/src/tools/github.ts +25 -0
  272. package/src/tools/index.ts +6 -0
  273. package/src/tools/linear.ts +428 -0
  274. package/src/tools/process.ts +156 -0
  275. package/src/tools/terminal.ts +116 -0
package/LICENSE ADDED
@@ -0,0 +1,48 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
10
+
11
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
12
+
13
+ "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent or more of the outstanding shares, or (iii) beneficial ownership of such entity.
14
+
15
+ "You" or "Your" shall mean an individual or Legal Entity exercising permissions granted by this License.
16
+
17
+ "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
18
+
19
+ "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
20
+
21
+ "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work.
22
+
23
+ "Derivative Works" shall mean any work, whether in Source or Object form, that is based on the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. Derivative Works shall not include works that remain separable from, or merely link or bind by name to the interfaces of, the Work.
24
+
25
+ "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner.
26
+
27
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
28
+
29
+ 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
30
+
31
+ 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work.
32
+
33
+ 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
34
+
35
+ (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
36
+ (b) You must cause any modified files to carry prominent notices stating that You changed the files; and
37
+ (c) You must retain all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
38
+ (d) If the Work includes a NOTICE text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file.
39
+
40
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License.
41
+
42
+ 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor.
43
+
44
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
45
+
46
+ 8. Limitation of Liability. In no event and under no legal theory shall any Contributor be liable to You for damages arising in any way out of the use of or inability to use the Work.
47
+
48
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer support, warranty, indemnity, or other liability obligations. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility.
package/NOTICE ADDED
@@ -0,0 +1,5 @@
1
+ Orca TypeScript
2
+ Copyright 2026 Ahmad Ragab
3
+
4
+ This project is a derivative TypeScript port of Orca by VirtusLab.
5
+ The original Orca project is licensed under the Apache License, Version 2.0.
package/README.md ADDED
@@ -0,0 +1,399 @@
1
+ # Orcats
2
+
3
+ Orcats is a Bun and TypeScript workflow runner for deterministic coding-agent work.
4
+
5
+ Write a direct-style TypeScript flow, choose a backend such as Claude, Codex, OpenCode, or Pi, and let Orcats provide the runtime pieces around it: a flow context, normalized conversation results, filesystem and git helpers, persistent plans, loop execution, review loops, fixtures, and a CLI runner.
6
+
7
+ Use Orcats when you want coding-agent work to be expressed as code instead of a one-off prompt.
8
+
9
+ ## Status
10
+
11
+ The package is version `0.2.3`. Install the public npm package for normal project use:
12
+
13
+ ```bash
14
+ npm i @twelvehart/orcats
15
+ ```
16
+
17
+ The package provides the TypeScript authoring API and the Bun-backed `orcats` CLI shim. GitHub Release binaries remain available when you need a standalone executable with no project `node_modules`.
18
+
19
+ Canonical repository: <https://github.com/ASRagab/orca-ts>
20
+
21
+ Documentation website: <https://ASRagab.github.io/orca-ts/>
22
+
23
+ ## Quickstart
24
+
25
+ ### Requirements
26
+
27
+ - Bun `>=1.3.0` for project installs and source development
28
+ - Git
29
+ - At least one configured backend CLI when running live flows
30
+
31
+ ### Install
32
+
33
+ Use this when you are writing and versioning flows in a project:
34
+
35
+ ```bash
36
+ npm i @twelvehart/orcats
37
+ npm i -D typescript
38
+ bunx -p @twelvehart/orcats orcats --version
39
+ ```
40
+
41
+ `typescript` is only needed for editor feedback and the CLI typecheck preflight. Bun `>=1.3.0` must be on `PATH` because the npm CLI shim runs with Bun.
42
+
43
+ Flow files import from `@twelvehart/orcats`:
44
+
45
+ ```ts
46
+ import { flow, llm, selectBackend } from "@twelvehart/orcats";
47
+ ```
48
+
49
+ Run a flow with:
50
+
51
+ ```bash
52
+ bunx -p @twelvehart/orcats orcats --backend claude hello.ts
53
+ ```
54
+
55
+ ### Optional Standalone Binary
56
+
57
+ Use this when you want to run a flow on a Unix-like machine without creating a package first:
58
+
59
+ ```bash
60
+ curl -fsSL https://github.com/ASRagab/orca-ts/releases/latest/download/install.sh | bash
61
+ ```
62
+
63
+ Pin a version or change the install directory with environment variables:
64
+
65
+ ```bash
66
+ ORCA_VERSION=0.2.3 ORCA_INSTALL_DIR="$HOME/.local/bin" \
67
+ bash <(curl -fsSL https://github.com/ASRagab/orca-ts/releases/download/v0.2.3/install.sh)
68
+ ```
69
+
70
+ The standalone binary embeds the runtime API, so it can run a flow that imports from `@twelvehart/orcats` even when the flow project has no `node_modules`. If the project has its own `@twelvehart/orcats` package dependency, that project copy wins.
71
+
72
+ ### Source Checkout
73
+
74
+ Use this for contributing to Orca itself.
75
+
76
+ ```bash
77
+ git clone https://github.com/ASRagab/orca-ts.git
78
+ cd orca-ts
79
+ bun install --frozen-lockfile
80
+ bun run verify
81
+ ```
82
+
83
+ `bun run verify` runs typecheck, unit tests, docs site build, doc-link checking, fixture validation, release metadata validation, declaration generation, the facade gate, and a compiled binary smoke test. It does not require live backend credentials.
84
+
85
+ ## Write Your First Flow
86
+
87
+ Create `hello.ts`:
88
+
89
+ ```ts
90
+ import { flow, llm, selectBackend } from "@twelvehart/orcats";
91
+
92
+ await flow()(async () => {
93
+ const selected = selectBackend({ default: "claude" });
94
+ try {
95
+ const conversation = llm().autonomous(selected.backend, {
96
+ prompt: "Say hello from an autonomous Orca flow."
97
+ });
98
+
99
+ const outcome = await conversation.awaitResult();
100
+ if (outcome.type !== "success") {
101
+ throw new Error(`Backend failed with outcome: ${outcome.type}`);
102
+ }
103
+
104
+ console.log(outcome.result.output);
105
+ } finally {
106
+ await selected.shutdown?.();
107
+ }
108
+ });
109
+ ```
110
+
111
+ Run it with the CLI:
112
+
113
+ ```bash
114
+ bunx -p @twelvehart/orcats orcats --backend claude hello.ts
115
+ ```
116
+
117
+ Inside this repository, examples import from `./src/index.ts`. Package consumers should import from `@twelvehart/orcats`.
118
+
119
+ ## Configure Backends
120
+
121
+ Orca normalizes backend output into one `Conversation` model, but each backend still needs its native CLI or server to be installed and authenticated.
122
+
123
+ | Backend | Flow constructor | Runtime requirement |
124
+ | --- | --- | --- |
125
+ | Claude | `claude()` | `claude-agent-acp` on `PATH`, or `ORCA_CLAUDE_ACP_COMMAND` set; use `ORCA_CLAUDE_TRANSPORT=stream-json` to fall back to the authenticated `claude` CLI |
126
+ | Codex | `codex()` | `codex` CLI on `PATH` and authenticated |
127
+ | OpenCode | `opencode()` | `opencode` CLI on `PATH` and authenticated; Orca manages `opencode serve` |
128
+ | Pi | `pi()` | `pi` CLI on `PATH` and authenticated |
129
+
130
+ Autonomous conversations are intended to complete without asking the human for input. If a backend needs credentials, approvals, or login setup, configure that backend before running the flow.
131
+
132
+ ### Selecting A Backend At Run Time
133
+
134
+ `selectBackend()` reads `ORCA_BACKEND` and returns the selected backend plus an optional `shutdown` hook:
135
+
136
+ ```ts
137
+ const selected = selectBackend({
138
+ default: "codex",
139
+ perBackend: {
140
+ codex: { approvalPolicy: "never" },
141
+ opencode: { model: "provider/model" }
142
+ }
143
+ });
144
+ ```
145
+
146
+ Precedence:
147
+
148
+ 1. `ORCA_BACKEND` overrides `default`.
149
+ 2. `ORCA_BACKEND_MODEL` overrides `perBackend[tag].model` and `config.model`.
150
+ 3. Flow code that calls `claude()`, `codex()`, `opencode()`, or `pi()` directly pins the backend and ignores `--backend`.
151
+
152
+ ## Loops
153
+
154
+ A loop is a flow that repeats a cycle until a measurable goal is met. Use it when the work has a progress signal: failing gates, pending tasks, open issues, confidence, or a fixed cycle count.
155
+
156
+ ```ts
157
+ import { codex, loop, untilManifestComplete, type TaskManifest } from "@twelvehart/orcats";
158
+
159
+ const result = await loop<TaskManifest>("ralph")
160
+ .reason(codex(), { prompt: "Pick the next pending task and implement it." })
161
+ .step("mark-one-task-complete", passOneTask)
162
+ .until(untilManifestComplete())
163
+ .guard({ maxIterations: 10 })
164
+ .run(manifest);
165
+ ```
166
+
167
+ Presets such as `untilManifestComplete()`, `untilGatesGreen()`, `untilNoIssues()`, `untilConfident(threshold)`, and `times(n)` supply the convergence measure. Add `.guard({ maxIterations, wallClockMs, tokenBudget })` for seatbelts. A loop with no preset or custom `.measure()` fails before it runs.
168
+
169
+ Loop execution owns recurrence, cycle reports, guards, token budgets, and optional context pressure. `fixLoop` remains the public generic convergence primitive over the same execution path; `executeLoop` is internal. Managed context is explicit: pass `context` to `.run()` when you want model-visible observations compacted/offloaded. Without it, raw reason/step observations are not captured.
170
+
171
+ Distributable loops live as import-safe modules under `.orca/loops/` and export `defineLoop({ name, source, sink, onTrigger })`. Use `orcats loops` to list them, `orcats run <loop>` to run one firing, and `orcats serve <loop>` to host the trigger. `orcats run` and served children share one firing contract for event decoding, `defineLoop().run`, sink emission, diagnostics, and stop-reason exit codes.
172
+
173
+ Start with the full guide: [Loops](docs/loops.md). It covers the first-loop tutorial, presets, custom measures, state stores, fan-out/fan-in, loop modules, `orcats run/serve/loops`, recipes, troubleshooting, and migration from legacy workflow scripts.
174
+
175
+ ## CLI Reference
176
+
177
+ ```bash
178
+ orcats [--backend <name>] [--no-typecheck] <flow.ts> [-- <task args>]
179
+ orcats run <loop> # run a loop once; exit status reflects the stop reason
180
+ orcats serve <loop> # host a loop's trigger, spawning a child process per firing
181
+ orcats loops # list defined loops with their source and sink
182
+ orcats --version
183
+ ```
184
+
185
+ | Command | Meaning |
186
+ | --- | --- |
187
+ | `<flow.ts>` | Legacy script path: import and run a flow file (unchanged behavior) |
188
+ | `run <loop>` | Run a loop once. `<loop>` is a loop module path or a registered loop name; exit code reflects the stop reason |
189
+ | `serve <loop>` | Run a thin supervisor that owns the loop's trigger `Source` and spawns one isolated child process per firing through the shared firing contract |
190
+ | `loops` | Discover and list loops from `.orca/loops/` without firing any trigger, backend, or sink |
191
+
192
+ | Option | Meaning |
193
+ | --- | --- |
194
+ | `--backend <name>` | Validates the tag and sets `ORCA_BACKEND`, which `selectBackend()` reads |
195
+ | `--no-typecheck` | Skips the `tsc --noEmit` pre-flight and sets `ORCA_TYPECHECK_SKIPPED=1` |
196
+ | `--version`, `-v` | Prints `orcats <version>` |
197
+ | `--help`, `-h` | Prints usage |
198
+ | `-- <task args>` | Everything after `--` is the flow/loop task input, read via `flowArgs()` |
199
+
200
+ Loop verbs and the legacy script path share one preflight: the typecheck guard, `--backend`, and the `--` task-arg channel apply to all of them. By default, the CLI typechecks the current project before importing when it can find project typecheck setup: `typescript`, `tsconfig.json`, and a local `@twelvehart/orcats` package dependency. A standalone binary flow in a zero-project directory without `tsconfig.json` skips this guard. Use `--no-typecheck` only when you intentionally want to skip it.
201
+
202
+ During a run, Orcats writes synthesized progress diagnostics to stderr from structured run-output events. Stdout stays reserved for explicit flow output and loop sink payloads.
203
+
204
+ The default state adapter needs no service. Use the sqlite store when a loop needs local crash recovery or longer-lived checkpoint history.
205
+
206
+ ## Examples
207
+
208
+ The best way to learn the authoring model is to start with the examples.
209
+
210
+ | Example | What it shows |
211
+ | --- | --- |
212
+ | `examples/runnable/01-simple/index.ts` | Minimal autonomous flow that honors `--backend` through `selectBackend()` |
213
+ | `examples/implement.ts` | Plan, implement, review, and fix loop |
214
+ | `examples/implement-enhanced.ts` | Larger implementation loop shape |
215
+ | `examples/issue-pr.ts` | Issue-to-PR style workflow |
216
+ | `examples/issue-pr-bugfix.ts` | Bugfix-oriented issue workflow |
217
+ | `examples/linear-ticket-triage.ts` | Linear ticket triage loop with fake Linear and Slack IO |
218
+ | `examples/multi-backend-compare.ts` | Comparing backend behavior |
219
+ | `examples/epic.ts` | Structured output with a Zod schema and a directly pinned `codex()` backend |
220
+ | `examples/loop-single-cycle.ts` | A single-cycle preset loop (`loop()` + `untilManifestComplete()`), runnable with no real backend |
221
+ | `examples/loop-gated-task.ts` | A gate-converging loop using `untilGatesGreen()` |
222
+ | `examples/loop-fanout.ts` | A fan-out / fan-in loop: bounded-concurrency branches joined through a reducer |
223
+ | `examples/loop-persisted-state.ts` | Snapshot state store checkpoint, history, branch, and merge |
224
+ | `examples/loop-served-trigger.ts` | Import-safe `defineLoop()` module for `.orca/loops/` |
225
+ | `workflows/ai-slop-cleanup.ts` | Full dogfood workflow with monitoring support |
226
+
227
+ ## Agent Skills
228
+
229
+ Installable Agent Skills under `skills/` take a coding agent from "I have an
230
+ Orcats automation idea" to a saved, self-validating workflow or loop module — in
231
+ **any** git-backed repo, not just TypeScript projects. They compose as a
232
+ pipeline:
233
+
234
+ | Skill | Purpose |
235
+ | --- | --- |
236
+ | `skills/orcats-setup` | Install or verify the `orcats` CLI and verify at least one backend (claude/codex/opencode/pi) is authenticated; re-runnable as a doctor |
237
+ | `skills/orcats-author` | Detect the target repo's real test/lint commands, interview for the workflow or loop shape, generate an artifact that typechecks, and respect the loop execution/source/sink contracts |
238
+ | `skills/orcats-flow` | Run a saved workflow or loop with monitoring, detect stalls from progress/context-pressure evidence rather than slowness, and heal backend/auth/non-convergence failures within safety bounds |
239
+
240
+ ### Install The Skills
241
+
242
+ The skills install with the [`skills` CLI](https://github.com/vercel-labs/skills)
243
+ (`npx skills`), which reads the `skills/<name>/` directories in this repo and
244
+ copies each into your coding agent's skills directory:
245
+
246
+ ```bash
247
+ # See which skills the repo provides
248
+ npx skills add ASRagab/orca-ts --list
249
+
250
+ # Install all three, user-level (works for every detected agent)
251
+ npx skills add ASRagab/orca-ts --skill '*' --global
252
+
253
+ # Or install one skill to one agent (e.g. Claude Code)
254
+ npx skills add ASRagab/orca-ts --skill orcats-setup --agent claude-code
255
+ ```
256
+
257
+ Without `--global` the skills install into the current repo's agent directory
258
+ (project scope). Install order does not matter, but the intended flow is
259
+ `orcats-setup` → `orcats-author` → `orcats-flow`. Each skill is a
260
+ self-contained directory — its `SKILL.md` plus its own `scripts/`, `reference/`,
261
+ and flow templates — so there is no shared payload to install separately.
262
+
263
+ Before the repo is public, install from a local checkout instead:
264
+
265
+ ```bash
266
+ git clone https://github.com/ASRagab/orca-ts.git
267
+ npx skills add ./orca-ts --skill '*' --global
268
+ ```
269
+
270
+ ### Run A Saved Workflow
271
+
272
+ Saved one-shot workflows live at the target repo's `.orca/workflows/<name>.ts`
273
+ and are triggered through the Orcats CLI:
274
+
275
+ ```bash
276
+ orcats --backend <tag> .orca/workflows/<name>.ts [-- "<task args>"]
277
+ ```
278
+
279
+ Reusable loop modules live under `.orca/loops/<name>.ts` and use the loop CLI:
280
+
281
+ ```bash
282
+ orcats loops
283
+ orcats run <name-or-path>
284
+ orcats serve <name-or-path>
285
+ ```
286
+
287
+ Detailed guidance lives in each skill's `SKILL.md`.
288
+
289
+ ## Guides And Reference
290
+
291
+ | Document | Purpose |
292
+ | --- | --- |
293
+ | [Backend reference](docs/backends.md) | Backend adapter behavior and live smoke details |
294
+ | [Saved workflows](docs/workflows.md) | Generated workflow gates, baseline policy, and runbook behavior |
295
+ | [Loops](docs/loops.md) | Loop tutorial, recipes, API notes, state, distribution, and troubleshooting |
296
+ | [Plans](docs/plans.md) | Persistent plan helpers under `.orca/` |
297
+ | [Review automation](docs/review.md) | Reviewer prompts, review loops, and fix execution |
298
+ | [Parity harness](docs/parity.md) | Fixture tiers, schema exports, and backend parity checks |
299
+ | [Distribution](docs/distribution.md) | npm package, GitHub Release binaries, installer, and embedded import notes |
300
+ | [Release checks](docs/release.md) | Release runbook |
301
+ | [Project language](CONTEXT.md) | Terminology used in code, docs, and agent work |
302
+ | [Agent notes](AGENTS.md) | Contributor and agent-facing implementation context |
303
+
304
+ ## Public API Surface
305
+
306
+ The root export re-exports the main authoring modules:
307
+
308
+ ```ts
309
+ import {
310
+ captureDirtyBaselineSnapshot,
311
+ claude,
312
+ codex,
313
+ currentFlowContext,
314
+ flow,
315
+ llm,
316
+ loop,
317
+ opencode,
318
+ pi,
319
+ plan,
320
+ review,
321
+ resolveBaselinePolicy,
322
+ runBaselineGate,
323
+ selectBackend,
324
+ z
325
+ } from "@twelvehart/orcats";
326
+ ```
327
+
328
+ The package metadata exposes these entry points:
329
+
330
+ | Entry point | Purpose |
331
+ | --- | --- |
332
+ | `@twelvehart/orcats` | Root flow authoring API |
333
+ | `@twelvehart/orcats/model` | Shared model types and schemas |
334
+ | `@twelvehart/orcats/testing` | Test helpers |
335
+ | `bin.orcats` | Bun CLI shim installed by the npm package and source checkouts; release installs use the compiled standalone binary |
336
+
337
+ ## Development Commands
338
+
339
+ ```bash
340
+ bun run typecheck
341
+ bun test
342
+ bun run docs:check
343
+ bun run lint
344
+ bun run validate:fixtures
345
+ bun run validate:release
346
+ bun run validate:package
347
+ bun run build:types
348
+ bun run build:binary
349
+ bun run build:release
350
+ bun run smoke:package
351
+ bun run smoke:binary
352
+ ```
353
+
354
+ Run the full deterministic gate before opening a pull request:
355
+
356
+ ```bash
357
+ bun run verify
358
+ ```
359
+
360
+ Run a live backend smoke only in an environment configured for that backend:
361
+
362
+ ```bash
363
+ ORCA_REAL_BACKEND_SMOKE=1 ORCA_REAL_BACKEND=codex bun test tests/integration/real-backend-smoke.test.ts
364
+ ORCA_REAL_BACKEND_SMOKE=1 ORCA_REAL_BACKEND=claude bun test tests/integration/real-backend-smoke.test.ts
365
+ ORCA_REAL_BACKEND_SMOKE=1 ORCA_REAL_BACKEND=opencode bun test tests/integration/real-backend-smoke.test.ts
366
+ ORCA_REAL_BACKEND_SMOKE=1 ORCA_REAL_BACKEND=pi bun test tests/integration/real-backend-smoke.test.ts
367
+ ```
368
+
369
+ ## Troubleshooting
370
+
371
+ | Problem | What to check |
372
+ | --- | --- |
373
+ | `bun` is missing or too old | Install Bun `>=1.3.0` for source/project workflows; standalone binaries do not need Bun |
374
+ | CLI prints typecheck errors | Run `bun run typecheck`, fix the TypeScript errors, then rerun the flow |
375
+ | `orcats` is not found after npm install | Run it through the local package bin with `bunx -p @twelvehart/orcats orcats`, or add `node_modules/.bin` to your script path |
376
+ | `orcats: missing project typecheck setup` warning | Add `typescript`, `tsconfig.json`, and a local `@twelvehart/orcats` package dependency in the flow project to restore the typecheck guard |
377
+ | Live flow cannot start a backend | Confirm the backend CLI or adapter is on `PATH`, authenticated, and usable outside Orcats |
378
+ | `--backend` seems to do nothing | The flow must call `selectBackend()`; direct `claude()`/`codex()` calls pin the backend |
379
+ | Installer fails on checksum | Re-run; if persistent, download the tarball and `SHA256SUMS.txt` from the release page manually |
380
+ | Live backend smoke is skipped | Set `ORCA_REAL_BACKEND_SMOKE=1` and choose `ORCA_REAL_BACKEND` |
381
+ | OpenCode process keeps running | Own the backend instance and call `opencode().shutdown()` when your program is done |
382
+
383
+ ## Contributing
384
+
385
+ Keep README content focused on users first: what Orca is, how to install it, how to run it, how to write flows, and where to find reference material.
386
+
387
+ Implementation history, parity notes, and agent-specific guidance belong in `AGENTS.md`, `CONTEXT.md`, `docs/`, or archived OpenSpec changes rather than in the quickstart path.
388
+
389
+ Before submitting changes, run:
390
+
391
+ ```bash
392
+ bun run verify
393
+ ```
394
+
395
+ ## License And Attribution
396
+
397
+ Orcats is licensed under Apache-2.0. See [LICENSE](LICENSE) and [NOTICE](NOTICE).
398
+
399
+ Scala Orca by VirtusLab was the starting point and reference for this TypeScript-native reimagining. The original Orca project is Apache-2.0 licensed.
package/bin/orcats ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env bun
2
+ import { main } from "../src/cli/main.ts";
3
+
4
+ await main();
@@ -0,0 +1,74 @@
1
+ export type AcpId = number | string;
2
+ export interface AcpErrorPayload {
3
+ readonly code: number;
4
+ readonly message: string;
5
+ readonly data?: unknown;
6
+ }
7
+ export interface AcpRequestMessage {
8
+ readonly jsonrpc: "2.0";
9
+ readonly id: AcpId;
10
+ readonly method: string;
11
+ readonly params?: unknown;
12
+ }
13
+ export interface AcpNotificationMessage {
14
+ readonly jsonrpc: "2.0";
15
+ readonly method: string;
16
+ readonly params?: unknown;
17
+ }
18
+ export interface AcpResponseMessage {
19
+ readonly jsonrpc: "2.0";
20
+ readonly id: AcpId;
21
+ readonly result?: unknown;
22
+ readonly error?: AcpErrorPayload;
23
+ }
24
+ export type AcpIncomingMessage = AcpRequestMessage | AcpNotificationMessage;
25
+ export interface AcpProcess {
26
+ readonly stdout: AsyncIterable<string | Uint8Array>;
27
+ readonly stderr?: AsyncIterable<string | Uint8Array>;
28
+ readonly exit: Promise<number | null>;
29
+ write(data: string): void;
30
+ endStdin(): void;
31
+ kill(signal?: NodeJS.Signals): void;
32
+ }
33
+ export interface AcpSpawnOptions {
34
+ readonly cwd?: string;
35
+ readonly env?: NodeJS.ProcessEnv;
36
+ }
37
+ export type AcpProcessSpawner = (command: string, args: readonly string[], options: AcpSpawnOptions) => AcpProcess;
38
+ export type AcpRequestHandler = (message: AcpRequestMessage) => unknown;
39
+ export interface AcpClientOptions {
40
+ readonly command: string;
41
+ readonly args?: readonly string[];
42
+ readonly cwd?: string;
43
+ readonly env?: NodeJS.ProcessEnv;
44
+ readonly capacity?: number;
45
+ readonly requestTimeoutMs?: number;
46
+ readonly spawnProcess?: AcpProcessSpawner;
47
+ readonly handleRequest?: AcpRequestHandler;
48
+ readonly onIncomingMessage?: () => void;
49
+ }
50
+ export declare class AcpClient {
51
+ private readonly options;
52
+ readonly process: AcpProcess;
53
+ private readonly queue;
54
+ private readonly pending;
55
+ private readonly closedState;
56
+ private nextId;
57
+ private closed;
58
+ readonly stderr: Promise<string>;
59
+ readonly done: Promise<void>;
60
+ constructor(options: AcpClientOptions);
61
+ messages(): AsyncIterable<AcpIncomingMessage>;
62
+ request<T = unknown>(method: string, params?: unknown): Promise<T>;
63
+ notify(method: string, params?: unknown): void;
64
+ close(signal?: NodeJS.Signals, force?: boolean): void;
65
+ private readLoop;
66
+ private route;
67
+ private respondToRequest;
68
+ private finish;
69
+ private fail;
70
+ private write;
71
+ }
72
+ export declare function createAcpClient(options: AcpClientOptions): AcpClient;
73
+ export declare function spawnAcpProcess(command: string, args: readonly string[], options: AcpSpawnOptions): AcpProcess;
74
+ //# sourceMappingURL=acp-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"acp-client.d.ts","sourceRoot":"","sources":["../../src/backends/acp-client.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;AAEpC,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC;IACxB,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IACnB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,kBAAkB;IACj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E,gBAAgB,GAAG,SAAS,CAEpE;AAED,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,OAAO,EAAE,eAAe,GACvB,UAAU,CAyBZ"}
@@ -0,0 +1,31 @@
1
+ import { type AcpProcess, type AcpProcessSpawner } from "./acp-client.ts";
2
+ import { type SharedBackendConfig } from "./conversation-config.ts";
3
+ import type { AutonomousRequest } from "./types.ts";
4
+ import type { StreamConversation } from "../conversation/index.ts";
5
+ import { type BackendTag } from "../model/index.ts";
6
+ export interface AcpBackendRuntimeOptions<B extends BackendTag, Output = unknown> {
7
+ readonly backend: B;
8
+ readonly command: string;
9
+ readonly args?: readonly string[];
10
+ readonly config?: SharedBackendConfig<Output>;
11
+ readonly cwd?: string;
12
+ readonly env?: NodeJS.ProcessEnv;
13
+ readonly spawnProcess?: AcpProcessSpawner;
14
+ readonly setProcess: (process: AcpProcess) => void;
15
+ readonly setCancel: (cancel: () => Promise<void>) => void;
16
+ readonly cancelTimeoutMs?: number;
17
+ readonly shutdownTimeoutMs?: number;
18
+ readonly requestTimeoutMs?: number;
19
+ readonly inactivityTimeoutMs?: number;
20
+ }
21
+ export declare function experimentalAcpBackendEnabled(backend: "claude" | "codex"): boolean;
22
+ export declare function claudeAcpCommand(): {
23
+ readonly command: string;
24
+ readonly args: readonly string[];
25
+ };
26
+ export declare function codexAcpCommand(): {
27
+ readonly command: string;
28
+ readonly args: readonly string[];
29
+ };
30
+ export declare function runAcpConversation<Output, B extends "claude" | "codex">(request: AutonomousRequest<Output, B>, options: AcpBackendRuntimeOptions<B, Output>, conversation: StreamConversation<B>): Promise<void>;
31
+ //# sourceMappingURL=acp-run.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"acp-run.d.ts","sourceRoot":"","sources":["../../src/backends/acp-run.ts"],"names":[],"mappings":"AAIA,OAAO,EAGL,KAAK,UAAU,EACf,KAAK,iBAAiB,EAEvB,MAAM,iBAAiB,C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AC,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAEjG;AAED,wBAAgB,eAAe,IAAI;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAchG;AAaD,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,CAAC,SAAS,QAAQ,GAAG,OAAO,EAC3E,OAAO,EAAE,iBAAiB,CAAC,MAAM,EAAE,CAAC,CAAC,EACrC,OAAO,EAAE,wBAAwB,CAAC,CAAC,EAAE,MAAM,CAAC,EAC5C,YAAY,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAClC,OAAO,CAAC,IAAI,CAAC,CA6Hf"}
@@ -0,0 +1,35 @@
1
+ import type { z } from "zod";
2
+ import { type SubprocessProcess, type SubprocessSpawner } from "./subprocess-run.ts";
3
+ import type { AutonomousRequest, LlmBackend } from "./types.ts";
4
+ import { StreamConversation } from "../conversation/index.ts";
5
+ import { type BackendConfig } from "../model/index.ts";
6
+ export type ClaudeProcess = SubprocessProcess;
7
+ export type ClaudeProcessSpawner = SubprocessSpawner;
8
+ export type ClaudeTransport = "acp" | "stream-json";
9
+ export interface ClaudeBackendOptions {
10
+ readonly command?: string;
11
+ readonly cwd?: string;
12
+ readonly env?: NodeJS.ProcessEnv;
13
+ readonly capacity?: number;
14
+ readonly spawnProcess?: ClaudeProcessSpawner;
15
+ readonly spawnAcpProcess?: import("./acp-client.ts").AcpProcessSpawner;
16
+ readonly transport?: ClaudeTransport;
17
+ readonly acpCancelTimeoutMs?: number;
18
+ readonly config?: BackendConfig<"claude">;
19
+ readonly inactivityTimeoutMs?: number;
20
+ readonly wallClockTimeoutMs?: number;
21
+ }
22
+ interface ResolvedClaudeConfig<Output> {
23
+ model?: string;
24
+ systemPrompt?: string;
25
+ readOnly?: boolean;
26
+ selfManagedGit?: boolean;
27
+ retryAttempts?: number;
28
+ schema?: z.ZodType<Output>;
29
+ resumeSessionId?: string;
30
+ }
31
+ export declare function claudeStreamJsonArgs<Output>(config: ResolvedClaudeConfig<Output>): readonly string[];
32
+ export declare function runClaudeConversation<Output>(request: AutonomousRequest<Output, "claude">, options: ClaudeBackendOptions, conversation: StreamConversation<"claude">, setProcess: (process: ClaudeProcess) => void): Promise<void>;
33
+ export declare function claude(options?: ClaudeBackendOptions): LlmBackend<"claude">;
34
+ export {};
35
+ //# sourceMappingURL=claude-run.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claude-run.d.ts","sourceRoot":"","sources":["../../src/backends/claude-run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAU7B,OAAO,EAGL,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACvB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAoC,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEzF,MAAM,MAAM,aAAa,GAAG,iBAAiB,CAAC;AAC9C,MAAM,MAAM,oBAAoB,GAAG,iBAAiB,CAAC;AACrD,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,aAAa,CAAC;AAEpD,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACjC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,YAAY,CAAC,EAAE,oBAAoB,CAAC;IAC7C,QAAQ,CAAC,eAAe,CAAC,EAAE,OAAO,iBAAiB,EAAE,iBAAiB,CAAC;IACvE,QAAQ,CAAC,SAAS,CAAC,EAAE,eAAe,CAAC;IACrC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IACrC,QAAQ,CAAC,MAAM,CAAC,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IAC1C,QAAQ,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IACtC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;CACtC;AAED,UAAU,oBAAoB,CAAC,MAAM;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,oBAAoB,CAAC,MAAM,CAAC,GAAG,SAAS,MAAM,EAAE,CAepG;AASD,wBAAsB,qBAAqB,CAAC,MAAM,EAChD,OAAO,EAAE,iBAAiB,CAAC,MAAM,EAAE,QAAQ,CAAC,EAC5C,OAAO,EAAE,oBAAoB,EAC7B,YAAY,EAAE,kBAAkB,CAAC,QAAQ,CAAC,EAC1C,UAAU,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,IAAI,GAC3C,OAAO,CAAC,IAAI,CAAC,CAgCf;AA6BD,wBAAgB,MAAM,CAAC,OAAO,GAAE,oBAAyB,GAAG,UAAU,CAAC,QAAQ,CAAC,CAsE/E"}
@@ -0,0 +1,15 @@
1
+ import type { z } from "zod";
2
+ import { StreamConversation, type ConversationCapture } from "../conversation/index.ts";
3
+ export type ClaudeParseResult = ConversationCapture<"claude">;
4
+ export interface ClaudeStreamOptions<Output = unknown> {
5
+ readonly schema?: z.ZodType<Output>;
6
+ }
7
+ export declare function collectClaudeStreamJson(lines: readonly string[]): Promise<ClaudeParseResult>;
8
+ export declare function consumeClaudeStreamJson<Output = unknown>(lines: readonly string[], conversation: StreamConversation<"claude">, options?: ClaudeStreamOptions<Output>): Promise<void>;
9
+ export interface ClaudeStreamConsumer {
10
+ readonly signal: AbortSignal;
11
+ consume(raw: string): Promise<void>;
12
+ finish(): void;
13
+ }
14
+ export declare function createClaudeStreamConsumer<Output = unknown>(conversation: StreamConversation<"claude">, options?: ClaudeStreamOptions<Output>): ClaudeStreamConsumer;
15
+ //# sourceMappingURL=claude-stream-json.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claude-stream-json.d.ts","sourceRoot":"","sources":["../../src/backends/claude-stream-json.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQ7B,OAAO,EAEL,kBAAkB,EAClB,KAAK,mBAAmB,EACzB,MAAM,0BAA0B,CAAC;AAuClC,MAAM,MAAM,iBAAiB,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAAC;AAE9D,MAAM,WAAW,mBAAmB,CAAC,MAAM,GAAG,OAAO;IACnD,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;CACrC;AAED,wBAAsB,uBAAuB,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAOlG;AAED,wBAAsB,uBAAuB,CAAC,MAAM,GAAG,OAAO,EAC5D,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,YAAY,EAAE,kBAAkB,CAAC,QAAQ,CAAC,EAC1C,OAAO,GAAE,mBAAmB,CAAC,MAAM,CAAM,GACxC,OAAO,CAAC,IAAI,CAAC,CASf;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpC,MAAM,IAAI,IAAI,CAAC;CAChB;AAED,wBAAgB,0BAA0B,CAAC,MAAM,GAAG,OAAO,EACzD,YAAY,EAAE,kBAAkB,CAAC,QAAQ,CAAC,EAC1C,OAAO,GAAE,mBAAmB,CAAC,MAAM,CAAM,GACxC,oBAAoB,CAuCtB"}