orizu 0.5.19 → 0.5.21

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 (378) hide show
  1. package/README.md +23 -0
  2. package/dist/archive-artifacts-cli.d.ts +50 -0
  3. package/dist/archive-artifacts-cli.d.ts.map +1 -0
  4. package/dist/artifact-archive.d.ts +48 -0
  5. package/dist/artifact-archive.d.ts.map +1 -0
  6. package/dist/artifact-pull.d.ts +22 -0
  7. package/dist/artifact-pull.d.ts.map +1 -0
  8. package/dist/banner.d.ts +3 -0
  9. package/dist/banner.d.ts.map +1 -0
  10. package/dist/connectors-cli.d.ts +31 -0
  11. package/dist/connectors-cli.d.ts.map +1 -0
  12. package/dist/credentials.d.ts +46 -0
  13. package/dist/credentials.d.ts.map +1 -0
  14. package/dist/csv.d.ts +49 -0
  15. package/dist/csv.d.ts.map +1 -0
  16. package/dist/dataset-download.d.ts +6 -0
  17. package/dist/dataset-download.d.ts.map +1 -0
  18. package/dist/dataset-edit-rows.d.ts +10 -0
  19. package/dist/dataset-edit-rows.d.ts.map +1 -0
  20. package/dist/dataset-upload-snapshot.d.ts +13 -0
  21. package/dist/dataset-upload-snapshot.d.ts.map +1 -0
  22. package/dist/daytona-slice-rehearsal.d.ts +89 -0
  23. package/dist/daytona-slice-rehearsal.d.ts.map +1 -0
  24. package/dist/daytona-slice.d.ts +106 -0
  25. package/dist/daytona-slice.d.ts.map +1 -0
  26. package/dist/deploy-key-merge-core.d.ts +121 -0
  27. package/dist/deploy-key-merge-core.d.ts.map +1 -0
  28. package/dist/diff-comments-cli.d.ts +12 -0
  29. package/dist/diff-comments-cli.d.ts.map +1 -0
  30. package/dist/diff-comments-cli.js +21 -2
  31. package/dist/egress-allowlist-cli.d.ts +23 -0
  32. package/dist/egress-allowlist-cli.d.ts.map +1 -0
  33. package/dist/egress-policy.d.ts +108 -0
  34. package/dist/egress-policy.d.ts.map +1 -0
  35. package/dist/error-response.d.ts +9 -0
  36. package/dist/error-response.d.ts.map +1 -0
  37. package/dist/file-parser.d.ts +5 -0
  38. package/dist/file-parser.d.ts.map +1 -0
  39. package/dist/gepa-engine-dispatch.d.ts +9 -0
  40. package/dist/gepa-engine-dispatch.d.ts.map +1 -0
  41. package/dist/gepa-engine-dispatch.js +307 -0
  42. package/dist/gepa-python-command.d.ts +6 -0
  43. package/dist/gepa-python-command.d.ts.map +1 -0
  44. package/dist/gepa-python-command.js +26 -0
  45. package/dist/gepa-python-paths.d.ts +6 -0
  46. package/dist/gepa-python-paths.d.ts.map +1 -0
  47. package/dist/gepa-python-paths.js +42 -0
  48. package/dist/git-credential.d.ts +69 -0
  49. package/dist/git-credential.d.ts.map +1 -0
  50. package/dist/git-recovery-environment.d.ts +31 -0
  51. package/dist/git-recovery-environment.d.ts.map +1 -0
  52. package/dist/github-setup.d.ts +122 -0
  53. package/dist/github-setup.d.ts.map +1 -0
  54. package/dist/global-flags.d.ts +12 -0
  55. package/dist/global-flags.d.ts.map +1 -0
  56. package/dist/help.d.ts +46 -0
  57. package/dist/help.d.ts.map +1 -0
  58. package/dist/help.js +93 -25
  59. package/dist/hosted-boot.d.ts +273 -0
  60. package/dist/hosted-boot.d.ts.map +1 -0
  61. package/dist/hosted-bootstrap-rehearsal.d.ts +86 -0
  62. package/dist/hosted-bootstrap-rehearsal.d.ts.map +1 -0
  63. package/dist/hosted-bootstrap.d.ts +188 -0
  64. package/dist/hosted-bootstrap.d.ts.map +1 -0
  65. package/dist/hosted-broker-server.d.ts +50 -0
  66. package/dist/hosted-broker-server.d.ts.map +1 -0
  67. package/dist/hosted-git-http-server.d.ts +36 -0
  68. package/dist/hosted-git-http-server.d.ts.map +1 -0
  69. package/dist/hosted-harness-claude.d.ts +195 -0
  70. package/dist/hosted-harness-claude.d.ts.map +1 -0
  71. package/dist/hosted-harness-opencode.d.ts +227 -0
  72. package/dist/hosted-harness-opencode.d.ts.map +1 -0
  73. package/dist/hosted-harness.d.ts +118 -0
  74. package/dist/hosted-harness.d.ts.map +1 -0
  75. package/dist/hosted-harvest.d.ts +68 -0
  76. package/dist/hosted-harvest.d.ts.map +1 -0
  77. package/dist/hosted-headless.d.ts +72 -0
  78. package/dist/hosted-headless.d.ts.map +1 -0
  79. package/dist/hosted-loop-lifecycle.d.ts +206 -0
  80. package/dist/hosted-loop-lifecycle.d.ts.map +1 -0
  81. package/dist/hosted-loop.d.ts +170 -0
  82. package/dist/hosted-loop.d.ts.map +1 -0
  83. package/dist/hosted-run-event-sink.d.ts +222 -0
  84. package/dist/hosted-run-event-sink.d.ts.map +1 -0
  85. package/dist/hosted-runtime-assets.d.ts +186 -0
  86. package/dist/hosted-runtime-assets.d.ts.map +1 -0
  87. package/dist/hosted-session-cli.d.ts +258 -0
  88. package/dist/hosted-session-cli.d.ts.map +1 -0
  89. package/dist/hosted-skill-staging.d.ts +73 -0
  90. package/dist/hosted-skill-staging.d.ts.map +1 -0
  91. package/dist/http.d.ts +8 -0
  92. package/dist/http.d.ts.map +1 -0
  93. package/dist/index.d.ts +22 -0
  94. package/dist/index.d.ts.map +1 -0
  95. package/dist/index.js +119 -129
  96. package/dist/instruction-set-gepa-launch.d.ts +3 -0
  97. package/dist/instruction-set-gepa-launch.d.ts.map +1 -0
  98. package/dist/instruction-set-gepa-launch.js +15 -0
  99. package/dist/instruction-set-loader.d.ts +6 -0
  100. package/dist/instruction-set-loader.d.ts.map +1 -0
  101. package/dist/instruction-set-loader.js +59 -0
  102. package/dist/instruction-set-manifest.d.ts +14 -0
  103. package/dist/instruction-set-manifest.d.ts.map +1 -0
  104. package/dist/instruction-set-manifest.js +162 -0
  105. package/dist/instruction-sets-cli.d.ts +40 -0
  106. package/dist/instruction-sets-cli.d.ts.map +1 -0
  107. package/dist/instruction-sets-cli.js +361 -0
  108. package/dist/json-response.d.ts +4 -0
  109. package/dist/json-response.d.ts.map +1 -0
  110. package/dist/jsonl-stream.d.ts +8 -0
  111. package/dist/jsonl-stream.d.ts.map +1 -0
  112. package/dist/kill-switch-cli.d.ts +30 -0
  113. package/dist/kill-switch-cli.d.ts.map +1 -0
  114. package/dist/loopback-serve.d.ts +25 -0
  115. package/dist/loopback-serve.d.ts.map +1 -0
  116. package/dist/manifests-cli.d.ts +22 -0
  117. package/dist/manifests-cli.d.ts.map +1 -0
  118. package/dist/markdown-report-input.d.ts +7 -0
  119. package/dist/markdown-report-input.d.ts.map +1 -0
  120. package/dist/markdown-report-input.js +15 -1
  121. package/dist/merge-job.d.ts +155 -0
  122. package/dist/merge-job.d.ts.map +1 -0
  123. package/dist/model-configs-cli.d.ts +19 -0
  124. package/dist/model-configs-cli.d.ts.map +1 -0
  125. package/dist/model-configs-cli.js +104 -0
  126. package/dist/optimization-export-cli.d.ts +19 -0
  127. package/dist/optimization-export-cli.d.ts.map +1 -0
  128. package/dist/optimizations-list-cli.d.ts +20 -0
  129. package/dist/optimizations-list-cli.d.ts.map +1 -0
  130. package/dist/optimizations-promote-cli.d.ts +8 -0
  131. package/dist/optimizations-promote-cli.d.ts.map +1 -0
  132. package/dist/optimizations-promote-cli.js +34 -0
  133. package/dist/option-validation.d.ts +15 -0
  134. package/dist/option-validation.d.ts.map +1 -0
  135. package/dist/preview-runtime.d.ts +63 -0
  136. package/dist/preview-runtime.d.ts.map +1 -0
  137. package/dist/prompt-draft-push.d.ts +60 -0
  138. package/dist/prompt-draft-push.d.ts.map +1 -0
  139. package/dist/prompt-label-cli.d.ts +11 -0
  140. package/dist/prompt-label-cli.d.ts.map +1 -0
  141. package/dist/prompt-label-cli.js +29 -0
  142. package/dist/prompt-length-wire.d.ts +28 -0
  143. package/dist/prompt-length-wire.d.ts.map +1 -0
  144. package/dist/prompt-length-wire.js +2 -2
  145. package/dist/prompt-report-cli.d.ts +10 -0
  146. package/dist/prompt-report-cli.d.ts.map +1 -0
  147. package/dist/prompt-report-cli.js +2 -2
  148. package/dist/prompt-summary-table.d.ts +15 -0
  149. package/dist/prompt-summary-table.d.ts.map +1 -0
  150. package/dist/prompt-summary-table.js +6 -0
  151. package/dist/registration-tag-warning.d.ts +32 -0
  152. package/dist/registration-tag-warning.d.ts.map +1 -0
  153. package/dist/report-comments-cli.d.ts +16 -0
  154. package/dist/report-comments-cli.d.ts.map +1 -0
  155. package/dist/report-markdown-blankness.d.ts +2 -0
  156. package/dist/report-markdown-blankness.d.ts.map +1 -0
  157. package/dist/report-markdown-blankness.js +6 -0
  158. package/dist/report-replacement-warning.d.ts +17 -0
  159. package/dist/report-replacement-warning.d.ts.map +1 -0
  160. package/dist/report-replacement-warning.js +31 -0
  161. package/dist/repository-backup-core.d.ts +225 -0
  162. package/dist/repository-backup-core.d.ts.map +1 -0
  163. package/dist/repository-recovery-manifest.d.ts +83 -0
  164. package/dist/repository-recovery-manifest.d.ts.map +1 -0
  165. package/dist/run-event-digest.d.ts +74 -0
  166. package/dist/run-event-digest.d.ts.map +1 -0
  167. package/dist/runner-dir-verify.d.ts +66 -0
  168. package/dist/runner-dir-verify.d.ts.map +1 -0
  169. package/dist/runner-instruction-set-contract.d.ts +24 -0
  170. package/dist/runner-instruction-set-contract.d.ts.map +1 -0
  171. package/dist/runner-instruction-set-contract.js +50 -0
  172. package/dist/sandbox-hygiene.d.ts +45 -0
  173. package/dist/sandbox-hygiene.d.ts.map +1 -0
  174. package/dist/sandbox-provider.d.ts +193 -0
  175. package/dist/sandbox-provider.d.ts.map +1 -0
  176. package/dist/scorer-draft-push.d.ts +50 -0
  177. package/dist/scorer-draft-push.d.ts.map +1 -0
  178. package/dist/scorers-cli.d.ts +20 -0
  179. package/dist/scorers-cli.d.ts.map +1 -0
  180. package/dist/scorers-cli.js +22 -0
  181. package/dist/scorers-verify-parity-bridge.d.ts +16 -0
  182. package/dist/scorers-verify-parity-bridge.d.ts.map +1 -0
  183. package/dist/scorers-verify-parity-bridge.js +90 -0
  184. package/dist/scorers-verify-parity.d.ts +81 -0
  185. package/dist/scorers-verify-parity.d.ts.map +1 -0
  186. package/dist/scorers-verify-parity.js +502 -0
  187. package/dist/scores-accept-cli.d.ts +21 -0
  188. package/dist/scores-accept-cli.d.ts.map +1 -0
  189. package/dist/secret-redaction.d.ts +47 -0
  190. package/dist/secret-redaction.d.ts.map +1 -0
  191. package/dist/session-timeline.d.ts +54 -0
  192. package/dist/session-timeline.d.ts.map +1 -0
  193. package/dist/setup-prompt.d.ts +5 -0
  194. package/dist/setup-prompt.d.ts.map +1 -0
  195. package/dist/skill-installer.d.ts +68 -0
  196. package/dist/skill-installer.d.ts.map +1 -0
  197. package/dist/skilled-proposer-launch.d.ts +7 -0
  198. package/dist/skilled-proposer-launch.d.ts.map +1 -0
  199. package/dist/skilled-proposer-launch.js +60 -0
  200. package/dist/smoke.d.ts +102 -0
  201. package/dist/smoke.d.ts.map +1 -0
  202. package/dist/start-intent.d.ts +12 -0
  203. package/dist/start-intent.d.ts.map +1 -0
  204. package/dist/task-assignment-manifest.d.ts +15 -0
  205. package/dist/task-assignment-manifest.d.ts.map +1 -0
  206. package/dist/task-create-error.d.ts +18 -0
  207. package/dist/task-create-error.d.ts.map +1 -0
  208. package/dist/team-connectors-cli.d.ts +29 -0
  209. package/dist/team-connectors-cli.d.ts.map +1 -0
  210. package/dist/types.d.ts +39 -0
  211. package/dist/types.d.ts.map +1 -0
  212. package/dist/vercel-sandbox-provider.d.ts +156 -0
  213. package/dist/vercel-sandbox-provider.d.ts.map +1 -0
  214. package/dist/workbench-cli.d.ts +233 -0
  215. package/dist/workbench-cli.d.ts.map +1 -0
  216. package/dist/workspace-sync.d.ts +207 -0
  217. package/dist/workspace-sync.d.ts.map +1 -0
  218. package/dist/workspace.d.ts +92 -0
  219. package/dist/workspace.d.ts.map +1 -0
  220. package/dist/zip-draft-push.d.ts +55 -0
  221. package/dist/zip-draft-push.d.ts.map +1 -0
  222. package/package.json +15 -2
  223. package/requirements/README.md +138 -0
  224. package/requirements/skilled-proposer.in +66 -0
  225. package/requirements/skilled-proposer.lock +265 -0
  226. package/scripts/build-cli-dist.mjs +30 -0
  227. package/scripts/ensure-skilled-proposer-venv.mjs +5 -0
  228. package/scripts/orizu-source-checkout.d.mts +1 -0
  229. package/scripts/orizu-source-checkout.mjs +10 -0
  230. package/scripts/refresh-skilled-proposer-lock.mjs +256 -0
  231. package/scripts/vendor-gepa-python.mjs +187 -4
  232. package/src/diff-comments-cli.ts +41 -3
  233. package/src/gepa-engine-dispatch.ts +340 -0
  234. package/src/gepa-python-command.ts +31 -0
  235. package/src/gepa-python-paths.ts +56 -0
  236. package/src/help.ts +95 -25
  237. package/src/index.ts +131 -166
  238. package/src/instruction-set-gepa-launch.ts +28 -0
  239. package/src/instruction-set-loader.ts +37 -0
  240. package/src/instruction-set-manifest.ts +120 -0
  241. package/src/instruction-sets-cli.ts +306 -0
  242. package/src/markdown-report-input.ts +19 -1
  243. package/src/model-configs-cli.ts +119 -0
  244. package/src/optimizations-promote-cli.ts +41 -0
  245. package/src/prompt-label-cli.ts +55 -0
  246. package/src/prompt-length-wire.ts +1 -1
  247. package/src/prompt-report-cli.ts +2 -2
  248. package/src/prompt-summary-table.ts +12 -0
  249. package/src/report-markdown-blankness.ts +6 -0
  250. package/src/report-replacement-warning.ts +35 -0
  251. package/src/runner-instruction-set-contract.ts +64 -0
  252. package/src/scorers-cli.ts +40 -0
  253. package/src/scorers-verify-parity-bridge.ts +90 -0
  254. package/src/scorers-verify-parity.ts +564 -0
  255. package/src/skilled-proposer-launch.ts +89 -0
  256. package/src/skilled-proposer-venv-manager.mjs +757 -0
  257. package/tsconfig.json +2 -0
  258. package/vendor/gepa-python/LICENSE +7 -0
  259. package/vendor/gepa-python/manifest.json +107 -0
  260. package/vendor/gepa-python/src/gepa/__init__.py +22 -0
  261. package/vendor/gepa-python/src/gepa/adapters/__init__.py +0 -0
  262. package/vendor/gepa-python/src/gepa/adapters/anymaths_adapter/__init__.py +1 -0
  263. package/vendor/gepa-python/src/gepa/adapters/anymaths_adapter/anymaths_adapter.py +174 -0
  264. package/vendor/gepa-python/src/gepa/adapters/confidence_adapter/__init__.py +26 -0
  265. package/vendor/gepa-python/src/gepa/adapters/confidence_adapter/confidence_adapter.py +618 -0
  266. package/vendor/gepa-python/src/gepa/adapters/confidence_adapter/scoring.py +206 -0
  267. package/vendor/gepa-python/src/gepa/adapters/default_adapter/__init__.py +0 -0
  268. package/vendor/gepa-python/src/gepa/adapters/default_adapter/default_adapter.py +206 -0
  269. package/vendor/gepa-python/src/gepa/adapters/dspy_adapter/__init__.py +0 -0
  270. package/vendor/gepa-python/src/gepa/adapters/dspy_adapter/dspy_adapter.py +525 -0
  271. package/vendor/gepa-python/src/gepa/adapters/dspy_adapter/instruction_proposal.py +500 -0
  272. package/vendor/gepa-python/src/gepa/adapters/dspy_full_program_adapter/__init__.py +6 -0
  273. package/vendor/gepa-python/src/gepa/adapters/dspy_full_program_adapter/dspy_program_proposal_signature.py +137 -0
  274. package/vendor/gepa-python/src/gepa/adapters/dspy_full_program_adapter/full_program_adapter.py +269 -0
  275. package/vendor/gepa-python/src/gepa/adapters/generic_rag_adapter/__init__.py +56 -0
  276. package/vendor/gepa-python/src/gepa/adapters/generic_rag_adapter/evaluation_metrics.py +226 -0
  277. package/vendor/gepa-python/src/gepa/adapters/generic_rag_adapter/generic_rag_adapter.py +496 -0
  278. package/vendor/gepa-python/src/gepa/adapters/generic_rag_adapter/rag_pipeline.py +238 -0
  279. package/vendor/gepa-python/src/gepa/adapters/generic_rag_adapter/vector_store_interface.py +212 -0
  280. package/vendor/gepa-python/src/gepa/adapters/generic_rag_adapter/vector_stores/__init__.py +2 -0
  281. package/vendor/gepa-python/src/gepa/adapters/generic_rag_adapter/vector_stores/chroma_store.py +196 -0
  282. package/vendor/gepa-python/src/gepa/adapters/generic_rag_adapter/vector_stores/lancedb_store.py +422 -0
  283. package/vendor/gepa-python/src/gepa/adapters/generic_rag_adapter/vector_stores/milvus_store.py +409 -0
  284. package/vendor/gepa-python/src/gepa/adapters/generic_rag_adapter/vector_stores/qdrant_store.py +368 -0
  285. package/vendor/gepa-python/src/gepa/adapters/generic_rag_adapter/vector_stores/weaviate_store.py +418 -0
  286. package/vendor/gepa-python/src/gepa/adapters/langchain_adapter/__init__.py +11 -0
  287. package/vendor/gepa-python/src/gepa/adapters/langchain_adapter/langchain_adapter.py +261 -0
  288. package/vendor/gepa-python/src/gepa/adapters/mcp_adapter/__init__.py +37 -0
  289. package/vendor/gepa-python/src/gepa/adapters/mcp_adapter/mcp_adapter.py +693 -0
  290. package/vendor/gepa-python/src/gepa/adapters/mcp_adapter/mcp_client.py +364 -0
  291. package/vendor/gepa-python/src/gepa/adapters/optimize_anything_adapter/optimize_anything_adapter.py +879 -0
  292. package/vendor/gepa-python/src/gepa/adapters/terminal_bench_adapter/__init__.py +0 -0
  293. package/vendor/gepa-python/src/gepa/adapters/terminal_bench_adapter/terminal_bench_adapter.py +217 -0
  294. package/vendor/gepa-python/src/gepa/api.py +468 -0
  295. package/vendor/gepa-python/src/gepa/core/__init__.py +0 -0
  296. package/vendor/gepa-python/src/gepa/core/adapter.py +227 -0
  297. package/vendor/gepa-python/src/gepa/core/callbacks.py +551 -0
  298. package/vendor/gepa-python/src/gepa/core/data_loader.py +74 -0
  299. package/vendor/gepa-python/src/gepa/core/engine.py +1025 -0
  300. package/vendor/gepa-python/src/gepa/core/result.py +271 -0
  301. package/vendor/gepa-python/src/gepa/core/state.py +706 -0
  302. package/vendor/gepa-python/src/gepa/examples/__init__.py +0 -0
  303. package/vendor/gepa-python/src/gepa/examples/aime.py +24 -0
  304. package/vendor/gepa-python/src/gepa/examples/anymaths-bench/eval_default.py +111 -0
  305. package/vendor/gepa-python/src/gepa/examples/anymaths-bench/train_anymaths.py +177 -0
  306. package/vendor/gepa-python/src/gepa/examples/mcp_adapter/__init__.py +4 -0
  307. package/vendor/gepa-python/src/gepa/examples/mcp_adapter/mcp_optimization_example.py +456 -0
  308. package/vendor/gepa-python/src/gepa/examples/rag_adapter/__init__.py +9 -0
  309. package/vendor/gepa-python/src/gepa/examples/rag_adapter/rag_optimization.py +824 -0
  310. package/vendor/gepa-python/src/gepa/examples/terminal-bench/train_terminus.py +161 -0
  311. package/vendor/gepa-python/src/gepa/gepa_utils.py +117 -0
  312. package/vendor/gepa-python/src/gepa/gskill/__init__.py +1 -0
  313. package/vendor/gepa-python/src/gepa/gskill/gskill/__init__.py +0 -0
  314. package/vendor/gepa-python/src/gepa/gskill/gskill/cost_tracker.py +194 -0
  315. package/vendor/gepa-python/src/gepa/gskill/gskill/evaluate/__init__.py +0 -0
  316. package/vendor/gepa-python/src/gepa/gskill/gskill/evaluate/claude_code.py +1117 -0
  317. package/vendor/gepa-python/src/gepa/gskill/gskill/evaluate/claude_code_skills.py +613 -0
  318. package/vendor/gepa-python/src/gepa/gskill/gskill/evaluate/mini_swe_agent.py +440 -0
  319. package/vendor/gepa-python/src/gepa/gskill/gskill/experiment_logger.py +367 -0
  320. package/vendor/gepa-python/src/gepa/gskill/gskill/swe_fitness_fn.py +209 -0
  321. package/vendor/gepa-python/src/gepa/gskill/gskill/swe_harness.py +352 -0
  322. package/vendor/gepa-python/src/gepa/gskill/gskill/train_optimize_anything.py +830 -0
  323. package/vendor/gepa-python/src/gepa/image.py +104 -0
  324. package/vendor/gepa-python/src/gepa/lm.py +261 -0
  325. package/vendor/gepa-python/src/gepa/logging/__init__.py +0 -0
  326. package/vendor/gepa-python/src/gepa/logging/experiment_tracker.py +457 -0
  327. package/vendor/gepa-python/src/gepa/logging/logger.py +75 -0
  328. package/vendor/gepa-python/src/gepa/logging/utils.py +130 -0
  329. package/vendor/gepa-python/src/gepa/optimize_anything.py +1701 -0
  330. package/vendor/gepa-python/src/gepa/proposer/__init__.py +0 -0
  331. package/vendor/gepa-python/src/gepa/proposer/base.py +53 -0
  332. package/vendor/gepa-python/src/gepa/proposer/merge.py +403 -0
  333. package/vendor/gepa-python/src/gepa/proposer/reflective_mutation/__init__.py +0 -0
  334. package/vendor/gepa-python/src/gepa/proposer/reflective_mutation/base.py +64 -0
  335. package/vendor/gepa-python/src/gepa/proposer/reflective_mutation/reflection_lm.py +178 -0
  336. package/vendor/gepa-python/src/gepa/proposer/reflective_mutation/reflective_mutation.py +641 -0
  337. package/vendor/gepa-python/src/gepa/py.typed +0 -0
  338. package/vendor/gepa-python/src/gepa/strategies/__init__.py +0 -0
  339. package/vendor/gepa-python/src/gepa/strategies/acceptance.py +66 -0
  340. package/vendor/gepa-python/src/gepa/strategies/batch_sampler.py +103 -0
  341. package/vendor/gepa-python/src/gepa/strategies/candidate_selector.py +82 -0
  342. package/vendor/gepa-python/src/gepa/strategies/component_selector.py +36 -0
  343. package/vendor/gepa-python/src/gepa/strategies/eval_policy.py +64 -0
  344. package/vendor/gepa-python/src/gepa/strategies/instruction_proposal.py +153 -0
  345. package/vendor/gepa-python/src/gepa/strategies/proposal_sampling.py +128 -0
  346. package/vendor/gepa-python/src/gepa/strategies/proposal_selection.py +84 -0
  347. package/vendor/gepa-python/src/gepa/utils/__init__.py +63 -0
  348. package/vendor/gepa-python/src/gepa/utils/code_execution.py +626 -0
  349. package/vendor/gepa-python/src/gepa/utils/stdio_capture.py +145 -0
  350. package/vendor/gepa-python/src/gepa/utils/stop_condition.py +230 -0
  351. package/vendor/gepa-python/src/gepa/visualization.py +359 -0
  352. package/vendor/orizu-gepa/pyproject.toml +18 -0
  353. package/vendor/orizu-gepa/src/orizu_gepa_connector/__init__.py +9 -0
  354. package/vendor/orizu-gepa/src/orizu_gepa_connector/__main__.py +5 -0
  355. package/vendor/orizu-gepa/src/orizu_gepa_connector/adapter.py +138 -0
  356. package/vendor/orizu-gepa/src/orizu_gepa_connector/callbacks.py +666 -0
  357. package/vendor/orizu-gepa/src/orizu_gepa_connector/cli.py +7 -0
  358. package/vendor/orizu-gepa/src/orizu_gepa_connector/engine.py +269 -0
  359. package/vendor/orizu-gepa/src/orizu_gepa_connector/instruction_set_loader.py +52 -0
  360. package/vendor/orizu-gepa/src/orizu_gepa_connector/preflight.py +64 -0
  361. package/vendor/orizu-gepa/src/orizu_gepa_connector/reflection.py +186 -0
  362. package/vendor/orizu-gepa/src/orizu_gepa_connector/runtime.py +721 -0
  363. package/vendor/orizu-gepa/src/orizu_gepa_connector/skilled_proposer_bridge.py +381 -0
  364. package/vendor/orizu-gepa/src/orizu_gepa_connector/stop_conditions.py +55 -0
  365. package/vendor/orizu-gepa/src/orizu_gepa_connector/translator.py +203 -0
  366. package/vendor/orizu-gepa-python/pyproject.toml +1 -1
  367. package/vendor/orizu-gepa-python/src/orizu_gepa/cli.py +1 -0
  368. package/vendor/orizu-gepa-python/src/orizu_gepa/client.py +52 -7
  369. package/vendor/orizu-gepa-python/src/orizu_gepa/local_log.py +52 -0
  370. package/vendor/orizu-gepa-python/src/orizu_gepa/optimizer.py +10 -5
  371. package/vendor/orizu-gepa-python/src/orizu_gepa/reflection.py +323 -68
  372. package/vendor/orizu-gepa-python/src/orizu_gepa/runner.py +207 -13
  373. package/vendor/skills/orizu-cli/SKILL.md +3 -1
  374. package/vendor/skills/orizu-cli/references/cli-reference.md +85 -1
  375. package/vendor/skills/orizu-cli/references/migrate-existing-gepa-setup.md +303 -0
  376. package/vendor/skills/orizu-cli/references/optimization-reports.md +1 -1
  377. package/vendor/skills/orizu-cli/references/optimization-with-gepa.md +26 -1
  378. package/vendor/skills/orizu-cli/references/prompt-control-plane.md +113 -10
@@ -0,0 +1,206 @@
1
+ /**
2
+ * Hosted-loop LIFECYCLE seam (ALI-1015 Phase 1, per ADR-005 Resolution).
3
+ *
4
+ * The orchestration-facing parts of the hosted loop, extracted VERBATIM from
5
+ * `hosted-loop.ts` so they can be re-exported through the shared
6
+ * `lib/hosted-runtime/` surface and driven by a server-side coordinator (the
7
+ * per-session Durable Object) as well as the CLI. This module deliberately
8
+ * carries NO harness/runtime machinery: its only import is the TYPE-ONLY
9
+ * `HarnessEvent` (erased at compile time), so a Worker bundle that pulls the
10
+ * lifecycle seam never drags in the OpenCode/Claude-SDK drivers or any Node
11
+ * child-process code.
12
+ *
13
+ * Contents (moved, not rewritten — behavior identical):
14
+ * - `HostedLoopContext` — the run-scoped boot context the host orchestrator
15
+ * writes for the in-sandbox loop;
16
+ * - `buildOpenCodeSpawnEnv` — the pre-authenticated agent env (ALI-1044);
17
+ * - the G5 egress canary: `runEgressCanary`, `egressCanaryAllowedHost`,
18
+ * `defaultProbeEgress`, and their types/constants;
19
+ * - `SetupHookOutcome` — the deferred customer-setup-hook contract.
20
+ *
21
+ * `hosted-loop.ts` re-exports everything here, so the CLI's import surface
22
+ * (`@/packages/cli/src/hosted-loop`) is unchanged.
23
+ */
24
+ import type { HarnessEvent } from './hosted-harness.js';
25
+ /**
26
+ * Default provider-qualified hosted model — the SINGLE source of truth
27
+ * (ALI-1086). Imported by both the operator-path session CLI
28
+ * (`hosted-session-cli.ts`) and the DO-path boot (`hosted-boot.ts`); never
29
+ * re-inline it.
30
+ *
31
+ * PIN CONSTRAINT: the hosted OpenCode runtime is HARD-PINNED to
32
+ * `opencode-ai@1.14.41` (`OPENCODE_PINNED_VERSION`, SSE-fragile — do not bump)
33
+ * whose BUNDLED model catalog predates this model (newest bundled anthropic
34
+ * opus: claude-opus-4-7). Verified empirically on ALI-1086: 1.14.41 DOES fetch
35
+ * `https://models.dev/api.json` at boot when reachable (cached to
36
+ * `~/.cache/opencode/models.json`, refreshed when stale, disabled only by
37
+ * `OPENCODE_DISABLE_MODELS_FETCH`), so with models.dev on the sandbox egress
38
+ * allowlist (#1392, `ORIZU_HOSTED_EGRESS_ALLOWLIST`) this id resolves in new
39
+ * sandboxes. If the catalog fetch is blocked/stale anyway, the loop's
40
+ * pre-prompt validation (`awaitOpenCodeModelResolvable`) fails the run fast,
41
+ * naming the resolvable alternatives. The durable fix for the stale bundled
42
+ * catalog is the ALI-929 harness swap.
43
+ */
44
+ export declare const DEFAULT_HOSTED_MODEL = "anthropic/claude-opus-4-8";
45
+ /**
46
+ * The run-scoped context the host orchestrator writes for the loop. Paths are
47
+ * ABSOLUTE (or sandbox-root-relative) so the loop resolves them regardless of
48
+ * cwd. NO secret lives here — the bearer is read from `bearerFile` (0600).
49
+ */
50
+ export interface HostedLoopContext {
51
+ apiBaseUrl: string;
52
+ runId: string;
53
+ /** 0600 file holding the agent bearer (never inlined into this context). */
54
+ bearerFile: string;
55
+ /** File holding the single task prompt (v0: one prompt, no queue). */
56
+ taskFile: string;
57
+ /** Directory the agent operates in (the cloned session-branch workspace). */
58
+ workspaceDir: string;
59
+ /** Provider-qualified model, e.g. "anthropic/claude-opus-4-8". */
60
+ model: string;
61
+ reasoningEffort?: string;
62
+ /** Idempotency / correlation key for the prompt. */
63
+ messageId: string;
64
+ /** Git identity for commit attribution during the prompt. */
65
+ author: {
66
+ name: string;
67
+ email: string;
68
+ };
69
+ /**
70
+ * Which `AgentHarness` drives the loop (ALI-929 swappability seam). Default
71
+ * 'opencode'. 'claude-agent-sdk' selects the in-process Claude-Agent-SDK driver
72
+ * — no `opencode` install/spawn happens on that path.
73
+ */
74
+ harness?: 'opencode' | 'claude-agent-sdk';
75
+ /**
76
+ * Total sandbox lifetime budget in ms (derived from the session `--duration`).
77
+ * The loop derives the per-prompt max-duration cap from this (budget minus a
78
+ * harvest margin, floored at the harness default) so a long `--duration` run is
79
+ * NOT killed at the hard-coded 90-min prompt cap while its sandbox still lives
80
+ * (ALI-1061). Unset for undated runs → the harness default (5400s) floor holds.
81
+ */
82
+ sandboxBudgetMs?: number;
83
+ opencodePort?: number;
84
+ opencodePinnedVersion?: string;
85
+ /**
86
+ * Pre-baked runtime (ALI-1017): the image already ships the pinned `opencode`
87
+ * on PATH, so the loop SKIPS the `opencode-ai` install (npm is blocked under G5
88
+ * default-deny egress) and spawns `opencode` directly, recording an
89
+ * `opencode_prebaked` artifact instead of `opencode_install`. The host sets this
90
+ * together with the sandbox `image` so the two never disagree. When unset, the
91
+ * loop ALSO belt-checks the `/opt/orizu/prebaked.json` marker; either signal
92
+ * skips the install. Ignored on the claude-agent-sdk path (no server to install).
93
+ */
94
+ prebaked?: boolean;
95
+ /**
96
+ * Non-secret placeholder key OpenCode is given so it FORMS model requests; the
97
+ * sandbox firewall's request transform overrides the real auth header at the
98
+ * proxy (model-key brokering, G3). Never a real key.
99
+ */
100
+ anthropicDummyKey?: string;
101
+ /** OpenCode session id to resume on reconnect. */
102
+ resumeAgentSessionId?: string;
103
+ /**
104
+ * Startup egress-canary probe host (G5 / ALI-1006). When SET, the loop runs a
105
+ * POSITIVE-CONTROL canary before any agent work, probing BOTH this known
106
+ * NON-allowlisted (denied) host AND a known-allowed host (the Orizu API base,
107
+ * derived from `apiBaseUrl`). The run proceeds ONLY IF the allowed host is
108
+ * reachable AND the denied host is blocked (`egress_blocked` proof). Any other
109
+ * outcome FAILS the run closed (`egress_allowed`): the denied host reachable
110
+ * means the firewall did not take; the allowed host ALSO unreachable means the
111
+ * network is broken and we cannot distinguish policy-enforcement from a total
112
+ * outage — either way we must not proceed to real customer data. The host sets
113
+ * this only for providers that actually enforce egress (Vercel); it is UNSET
114
+ * for local-sim / no-policy runs, so the canary is skipped there. Default
115
+ * denied probe target: `example.com`.
116
+ */
117
+ egressCanaryHost?: string;
118
+ /**
119
+ * When true, run the customer `.orizu/setup.sh` hook HERE (in the loop), AFTER
120
+ * the egress canary has proven the firewall is live and BEFORE harness work.
121
+ * The host sets this for enforced-egress providers so bootstrap DEFERS the hook
122
+ * (which would otherwise get network access before the canary could detect a
123
+ * silent firewall failure). UNSET for local-sim / no-policy runs, where
124
+ * bootstrap runs the hook inline as before. See docs sandbox-egress-policy §4.
125
+ */
126
+ runSetupHook?: boolean;
127
+ }
128
+ /**
129
+ * Environment injected into the spawned OpenCode server so the AGENT's bash sees a
130
+ * PRE-AUTHENTICATED `orizu` CLI (ALI-1044). ORIZU_TOKEN_FILE points at the 0600
131
+ * rotated bearer file and ORIZU_BASE_URL at the Orizu API — the exact vars the
132
+ * CLI's auth resolution reads (resolveEnvBearerToken + resolveBaseUrl). The dummy
133
+ * ANTHROPIC key (model-key brokering, G3) is preserved. No real secret is carried
134
+ * here: the bearer stays on disk and is read fresh per request from the file.
135
+ */
136
+ export declare function buildOpenCodeSpawnEnv(context: HostedLoopContext): Record<string, string> | undefined;
137
+ /** Default egress-canary probe host (a known non-allowlisted destination). */
138
+ export declare const DEFAULT_EGRESS_CANARY_HOST = "example.com";
139
+ export interface EgressProbeResult {
140
+ /** True when the denied host was reachable (policy did NOT take → fail closed). */
141
+ reachable: boolean;
142
+ /** Short human/audit detail (HTTP status on reach, error class on block). */
143
+ detail: string;
144
+ }
145
+ /**
146
+ * Default probe: attempt a bounded HTTPS GET to `host`. A live default-deny
147
+ * firewall makes this THROW for a DENIED host (connection reset / timeout / DNS
148
+ * failure) → `reachable: false`. Any response at all — even an error status —
149
+ * proves the host was reachable → `reachable: true`. Used for BOTH the allowed
150
+ * (positive-control) and denied probes.
151
+ */
152
+ export declare function defaultProbeEgress(host: string): Promise<EgressProbeResult>;
153
+ /** The two hosts the positive-control canary probes. */
154
+ export interface EgressCanaryTargets {
155
+ /** A known-ALLOWED host (the Orizu API base) that MUST be reachable — the
156
+ * positive control that distinguishes "policy blocking" from "network dead". */
157
+ allowedHost: string;
158
+ /** A known-DENIED, non-allowlisted host that MUST be blocked (`example.com`). */
159
+ deniedHost: string;
160
+ }
161
+ export interface EgressCanaryDecision {
162
+ proceed: boolean;
163
+ /** Null on proceed; a human/audit reason for the fail-closed decision. */
164
+ reason: string | null;
165
+ allowed: EgressProbeResult;
166
+ denied: EgressProbeResult;
167
+ }
168
+ /**
169
+ * Run the startup egress canary as a POSITIVE CONTROL and emit the proof event
170
+ * through the (single-writer) sink. Probes BOTH a known-allowed host and the
171
+ * known-denied host, then decides:
172
+ *
173
+ * - allowed REACHABLE and denied BLOCKED → the firewall is live AND the network
174
+ * works → emit `egress_blocked` and PROCEED (the ONLY healthy outcome);
175
+ * - denied REACHABLE → egress is NOT enforced → emit `egress_allowed`, FAIL
176
+ * CLOSED;
177
+ * - allowed ALSO UNREACHABLE (denied blocked but the positive control failed) →
178
+ * we cannot tell policy-blocking from a total network outage → emit
179
+ * `egress_allowed`, FAIL CLOSED.
180
+ *
181
+ * The `egress_blocked` kind therefore means EXACTLY "proceeded, positive control
182
+ * passed"; `egress_allowed` means "failed closed" (the payload `result` field
183
+ * distinguishes an unexpectedly-reachable denied host from an unreachable
184
+ * positive control). Old behavior — treating ANY denied-host throw (incl. a
185
+ * timeout under a total outage) as "blocked → proceed" — failed OPEN; this now
186
+ * fails closed on that ambiguity.
187
+ */
188
+ export declare function runEgressCanary(targets: EgressCanaryTargets, sink: {
189
+ append: (event: HarnessEvent) => Promise<void>;
190
+ }, probe: (host: string) => Promise<EgressProbeResult>, now?: () => number): Promise<EgressCanaryDecision>;
191
+ /**
192
+ * Derive the known-ALLOWED positive-control host from the run's Orizu API base —
193
+ * always allowlisted (it is the agent's control-plane path) and ours, so it is
194
+ * the safest "must be reachable" signal. Falls back to a lenient host parse if
195
+ * the base is not a well-formed URL.
196
+ */
197
+ export declare function egressCanaryAllowedHost(apiBaseUrl: string): string;
198
+ /** Outcome of the deferred customer setup hook run inside the loop. */
199
+ export interface SetupHookOutcome {
200
+ /** True when a `.orizu/setup.sh` existed and was executed. */
201
+ ran: boolean;
202
+ /** True when the hook was absent OR exited 0 (non-fatal either way). */
203
+ ok: boolean;
204
+ detail: string;
205
+ }
206
+ //# sourceMappingURL=hosted-loop-lifecycle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hosted-loop-lifecycle.d.ts","sourceRoot":"","sources":["../src/hosted-loop-lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAEvD;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,oBAAoB,8BAA8B,CAAA;AAE/D;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE,MAAM,CAAA;IACb,4EAA4E;IAC5E,UAAU,EAAE,MAAM,CAAA;IAClB,sEAAsE;IACtE,QAAQ,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iF;IACjF,WAAW,EAAE,MAAM,CAAA;IACnB,iFAAiF;IACjF,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,OAAO,CAAA;IAChB,0EAA0E;IAC1E,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,OAAO,EAAE,iBAAiB,CAAA;IAC1B,MAAM,EAAE,iBAAiB,CAAA;CAC1B;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,mBAAmB,EAC5B,IAAI,EAAE;IAAE,MAAM,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,EACxD,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,iBAAiB,CAAC,EACnD,GAAG,GAAE,MAAM,MAAyB,GACnC,OAAO,CAAC,oBAAoB,CAAC,CAkE/B;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAMlE;AAED,uEAAuE;AACvE,MAAM,WAAW,gBAAgB;IAC/B,8DAA8D;IAC9D,GAAG,EAAE,OAAO,CAAA;IACZ,wEAAwE;IACxE,EAAE,EAAE,OAAO,CAAA;IACX,MAAM,EAAE,MAAM,CAAA;CACf"}
@@ -0,0 +1,170 @@
1
+ /**
2
+ * In-sandbox hosted agent loop (ALI-928 / P3.5, per ADR-005).
3
+ *
4
+ * Runs INSIDE the sandbox (installed by the bootstrap CLI step, launched
5
+ * DETACHED by `orizu session start --hosted`). It composes the ALI-926 pieces:
6
+ *
7
+ * 1. resolve the loop boot context (a run-scoped JSON file written by the host
8
+ * orchestrator) + read the agent bearer from its 0600 file (G3);
9
+ * 2. install `opencode` pinned to OPENCODE_PINNED_VERSION (non-fatal-RECORDED;
10
+ * if it is unavailable the spawn/connect below fails and the run finishes
11
+ * 'failed' cleanly — the run never dangles);
12
+ * 3. build a RESUME-AWARE RunEventSink (continues the server's sequence after
13
+ * the run-start + bootstrap events — so a reconnect loses nothing);
14
+ * 4. provision the `AgentHarness` SELECTED by `context.harness` (default
15
+ * 'opencode': install+spawn `opencode serve` then connect the OpenCode
16
+ * driver; 'claude-agent-sdk': construct the in-process Claude-Agent-SDK
17
+ * driver — no server to install or spawn), then drive the SINGLE task prompt
18
+ * (v0: no queue) through `drainHarnessToSink`;
19
+ * 5. the terminal event decides the run's final status via the sink's PATCH.
20
+ *
21
+ * SWAPPABILITY (ALI-929 / P3.6): harness SELECTION is the ONLY thing that differs
22
+ * between the two drivers — `start()` → `runPrompt()` → `drainHarnessToSink()` →
23
+ * `shutdown()` is byte-identical for both, and the sink, event vocabulary, and
24
+ * terminal-PATCH flow are unchanged. That is the proof: a second harness drops in
25
+ * behind the seam with no change to any consumer beyond the selector.
26
+ *
27
+ * The redaction list carries the agent bearer (added automatically by the sink)
28
+ * plus any model key present in the process env (defense in depth for the G3
29
+ * per-exec fallback — with firewall brokering the real key never reaches here).
30
+ *
31
+ * TESTABILITY: `runHostedLoop` takes injected `fetchImpl`, `spawnOpenCode`,
32
+ * `installOpenCode`, and `createHarness`, so the whole loop runs in-process
33
+ * against a fake broker + fake OpenCode server with no real binary.
34
+ */
35
+ import type { AgentHarness } from './hosted-harness.js';
36
+ import { type HarvestExec } from './hosted-harvest.js';
37
+ import { type ModelValidationOutcome, type SpawnOpenCodeOptions, type SpawnedOpenCode } from './hosted-harness-opencode.js';
38
+ import { type HostedFetch, type TerminalStatus } from './hosted-run-event-sink.js';
39
+ import { type EgressProbeResult, type HostedLoopContext, type SetupHookOutcome } from './hosted-loop-lifecycle.js';
40
+ export { DEFAULT_EGRESS_CANARY_HOST, DEFAULT_HOSTED_MODEL, buildOpenCodeSpawnEnv, egressCanaryAllowedHost, runEgressCanary, } from './hosted-loop-lifecycle.js';
41
+ export type { EgressCanaryDecision, EgressCanaryTargets, EgressProbeResult, HostedLoopContext, SetupHookOutcome, } from './hosted-loop-lifecycle.js';
42
+ export declare const PROMPT_HARVEST_MARGIN_MS: number;
43
+ /**
44
+ * Derive the per-prompt max-duration cap from the sandbox lifetime budget: the
45
+ * budget minus a harvest margin, FLOORED at the harness default so a short or
46
+ * undated run is never shortened below the historical 5400s cap (ALI-1061).
47
+ * Undated runs (`sandboxBudgetMs` unset / non-positive) get exactly the default.
48
+ */
49
+ export declare function derivePromptMaxDurationMs(sandboxBudgetMs: number | undefined): number;
50
+ export interface InstallResult {
51
+ ok: boolean;
52
+ detail: string;
53
+ }
54
+ export interface RunHostedLoopOptions {
55
+ context: HostedLoopContext;
56
+ /**
57
+ * Agent bearer, as a FIXED string (tests / in-process launcher) OR omitted in
58
+ * favor of `bearerProvider`. In production the loop reads the rotated 0600
59
+ * bearer file per request via a provider (see `bearerProvider`), so a
60
+ * host-side rotation is picked up without restarting the loop.
61
+ */
62
+ bearer?: string;
63
+ /** Per-request bearer resolver (default: read `context.bearerFile`, trimmed).
64
+ * Passing a provider is what lets rotation reach the event sink. */
65
+ bearerProvider?: () => string;
66
+ /** The single task prompt (already read from the task file by the caller). */
67
+ taskPrompt: string;
68
+ fetchImpl?: HostedFetch;
69
+ /** Build the harness for a spawned OpenCode base URL (default: OpenCode driver).
70
+ * `options.promptMaxDurationMs` is the duration-derived per-prompt cap (ALI-1061). */
71
+ createHarness?: (baseUrl: string, options?: {
72
+ promptMaxDurationMs?: number;
73
+ }) => AgentHarness;
74
+ /** Build the in-process Claude-Agent-SDK harness (default: real SDK loader).
75
+ * Injectable so the swap test drives a fake `query()` with no real SDK. */
76
+ createClaudeHarness?: () => AgentHarness;
77
+ spawnOpenCode?: (opts: SpawnOpenCodeOptions) => SpawnedOpenCode | Promise<SpawnedOpenCode>;
78
+ installOpenCode?: () => Promise<InstallResult>;
79
+ /**
80
+ * Pre-prompt model validation against the RUNNING opencode's resolvable
81
+ * catalog (ALI-1086). Default: `awaitOpenCodeModelResolvable`, which polls
82
+ * `GET /config/providers` briefly so the boot-time models.dev refresh can
83
+ * land. An `unresolvable` outcome fails the run BEFORE the first prompt with
84
+ * an error naming the requested id and the resolvable alternatives; a
85
+ * `skipped` outcome (catalog endpoint unreachable) proceeds — opencode's own
86
+ * `session.error` remains the backstop. Injectable for tests.
87
+ */
88
+ validateModel?: (input: {
89
+ baseUrl: string;
90
+ model: string;
91
+ }) => Promise<ModelValidationOutcome>;
92
+ now?: () => number;
93
+ signal?: AbortSignal;
94
+ /** Extra verbatim secrets to redact (the bearer is added by the sink itself). */
95
+ redactSecretsList?: readonly string[];
96
+ /** Egress-canary probe (default: a bounded `fetch` to https://<host>/).
97
+ * Injectable so tests exercise both the blocked and reachable branches with
98
+ * no real network. Called once per host (allowed + denied) by the canary. */
99
+ probeEgress?: (host: string) => Promise<EgressProbeResult>;
100
+ /** Run the deferred customer setup hook (default: `bash .orizu/setup.sh` in the
101
+ * workspace, non-fatal). Injectable so tests exercise the deferred-hook path
102
+ * with no real filesystem or child process. */
103
+ runSetupHook?: (input: {
104
+ workspaceDir: string;
105
+ }) => Promise<SetupHookOutcome> | SetupHookOutcome;
106
+ /**
107
+ * Standing preamble wrapped around the user task (ALI-1036). Defaults to
108
+ * `HOSTED_TASK_PREAMBLE`; pass an override to customize it, or an empty string
109
+ * to send the task verbatim (tests). The user task is always kept verbatim
110
+ * beneath a delimiter (see `composeHostedTaskPrompt`).
111
+ */
112
+ taskPreamble?: string;
113
+ /**
114
+ * Injectable git runner for the end-of-run auto-harvest (ALI-1036). Default:
115
+ * real `git` via child_process in `context.workspaceDir`.
116
+ */
117
+ harvestExec?: HarvestExec;
118
+ /**
119
+ * Idle watchdog window (ALI-1037): abort the prompt + fail the run
120
+ * `agent_stalled` if NO progress event arrives for this many ms. Default: env
121
+ * `ORIZU_AGENT_IDLE_TIMEOUT_MS` or 25 minutes. <= 0 disables the watchdog.
122
+ */
123
+ idleTimeoutMs?: number;
124
+ /** Injectable sleep for the terminal-delivery retry backoff (ALI-1065
125
+ * finding 2). Tests pass a no-op to avoid real delays. */
126
+ sleepImpl?: (ms: number) => Promise<void>;
127
+ }
128
+ export interface HostedLoopResult {
129
+ status: TerminalStatus;
130
+ agentSessionId: string | null;
131
+ installOk: boolean;
132
+ error: string | null;
133
+ }
134
+ /** Default idle-watchdog window (ALI-1037): abort a prompt that makes no progress
135
+ * for this long. The timer resets on every harness EVENT, and a legitimate long
136
+ * single tool call (a big `npm install`, a build, an optimization step) emits no
137
+ * intermediate events — so this must comfortably exceed the longest expected
138
+ * quiet tool call (review finding #2). Overridable per-run via `idleTimeoutMs` or
139
+ * the `ORIZU_AGENT_IDLE_TIMEOUT_MS` env var. */
140
+ export declare const DEFAULT_AGENT_IDLE_TIMEOUT_MS: number;
141
+ /**
142
+ * Loop-level retry schedule for an undeliverable TERMINAL transition (ALI-1065
143
+ * finding 2). Each entry is a pause before one more full sink delivery cycle
144
+ * (which itself retries ~4 times over ~350ms), so a transport blip of a few
145
+ * seconds recovers with the ORIGINAL status instead of being re-recorded as
146
+ * 'failed'. Bounded: a persistently unreachable control plane fails the
147
+ * DELIVERY visibly (result.error) without recording a wrong outcome.
148
+ */
149
+ export declare const TERMINAL_DELIVERY_RETRY_DELAYS_MS: readonly number[];
150
+ /**
151
+ * Env var naming OTHER env vars whose values were injected as secrets — the
152
+ * server env-bundle pull (ALI-1055: `GET /api/coordinator/sessions/:id/
153
+ * env-bundle` returns `redactEnvVars`) writes it as a comma-separated list of
154
+ * names (e.g. `ANTHROPIC_API_KEY,BRAINTRUST_API_KEY`) so every pulled secret
155
+ * (model key + connector credentials) lands on the run-event redaction list.
156
+ */
157
+ export declare const INJECTED_ENV_VARS_ENV = "ORIZU_INJECTED_ENV_VARS";
158
+ export declare function runHostedLoop(opts: RunHostedLoopOptions): Promise<HostedLoopResult>;
159
+ export interface HostedLoopCommandIo {
160
+ print: (line: string) => void;
161
+ printErr?: (line: string) => void;
162
+ json?: boolean;
163
+ }
164
+ /**
165
+ * Read the loop context + bearer + task from disk and run the loop. Invoked
166
+ * in-sandbox as a hidden command; the run's terminal status is recorded
167
+ * server-side regardless of this process's exit code.
168
+ */
169
+ export declare function hostedLoopCommand(args: readonly string[], io: HostedLoopCommandIo): Promise<number>;
170
+ //# sourceMappingURL=hosted-loop.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hosted-loop.d.ts","sourceRoot":"","sources":["../src/hosted-loop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAOH,OAAO,KAAK,EAAE,YAAY,EAAiB,MAAM,qBAAqB,CAAA;AAQtE,OAAO,EAAoB,KAAK,WAAW,EAAuB,MAAM,qBAAqB,CAAA;AAE7F,OAAO,EAML,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACrB,MAAM,8BAA8B,CAAA;AAErC,OAAO,EAKL,KAAK,WAAW,EAChB,KAAK,cAAc,EACpB,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAOL,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACtB,MAAM,4BAA4B,CAAA;AAKnC,OAAO,EACL,0BAA0B,EAC1B,oBAAoB,EACpB,qBAAqB,EACrB,uBAAuB,EACvB,eAAe,GAChB,MAAM,4BAA4B,CAAA;AACnC,YAAY,EACV,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,4BAA4B,CAAA;AAOnC,eAAO,MAAM,wBAAwB,QAAgB,CAAA;AAErD;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,eAAe,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAKrF;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,OAAO,CAAA;IACX,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,iBAAiB,CAAA;IAC1B;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAA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AC2D;IAC3D,SAAS,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CAC1C;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,cAAc,CAAA;IACtB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,SAAS,EAAE,OAAO,CAAA;IAClB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CACrB;AAeD;;;;;iDAKiD;AACjD,eAAO,MAAM,6BAA6B,QAAiB,CAAA;AAa3D;;;;;;;GAOG;AACH,eAAO,MAAM,iCAAiC,EAAE,SAAS,MAAM,EAAmB,CAAA;AAKlF;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,4BAA4B,CAAA;AA4E9D,wBAAsB,aAAa,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAgZzF;AAID,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAC7B,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IACjC,IAAI,CAAC,EAAE,OAAO,CAAA;CACf;AASD;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,EAAE,EAAE,mBAAmB,GACtB,OAAO,CAAC,MAAM,CAAC,CAwBjB"}
@@ -0,0 +1,222 @@
1
+ /**
2
+ * RunEventSink — the RunAPI event bridge (ALI-926 / P3.4, interface 2 of
3
+ * ADR-005's swappability contract; the full realization of audit §4b).
4
+ *
5
+ * This is the transport half that `bridge.py`'s WebSocket client is NOT: it maps
6
+ * normalized `HarnessEvent`s onto Orizu's append-only, client-sequenced
7
+ * `workbench_run_events` and terminal PATCH. It extends the seed
8
+ * `createBootstrapRunEventSink` (`hosted-bootstrap.ts`) into the complete bridge:
9
+ * kind-to-event-type mapping, token coalescing, monotonic client-sequenced
10
+ * allocation (gaps tolerated on an ambiguous append failure, but NEVER a content
11
+ * swap at a committed sequence — see the P2-4 burn rule in `postEvent`),
12
+ * critical-event delivery guarantees, terminal-via-PATCH, reconnect/resume, and
13
+ * the "Orizu records win" disagreement rule. A retried POST is an idempotent 200
14
+ * ONLY for a content-identical replay (same eventId, same sequence, same
15
+ * payload); a burned sequence after an ambiguous error leaves a server-visible
16
+ * gap, which is acceptable.
17
+ *
18
+ * ── Disagreement rule (Orizu records win) ────────────────────────────────────
19
+ * Orizu's RunAPI is the source of truth; the OpenCode-side session state is a
20
+ * cache/UX layer. If the harness reports state that CONTRADICTS a terminal Orizu
21
+ * run status — e.g. it keeps streaming parts after the run was finished — the
22
+ * sink REFUSES to append: once `finish()` succeeds the sink is SEALED, and any
23
+ * later `append()` throws `RunTerminalError` locally rather than POSTing. The
24
+ * sink never un-terminates a run and never invents a new one. A run-gone/terminal
25
+ * signal from the server (append 404/410, or a persistent terminal-status 409 on
26
+ * the finish PATCH) is likewise accepted as truth, sealing the sink. Note the
27
+ * narrow classifications: a 403 is NOT "terminal" — it is a `RunAuthError`
28
+ * (revoked bearer or lost access) that does not seal, and a 409 whose run is
29
+ * still running does NOT report success. The harness is a subordinate producer;
30
+ * the server record wins every disagreement.
31
+ *
32
+ * ── Artifact-ref decision (transcript/summary) ───────────────────────────────
33
+ * The audit points at `lib/primitive-artifact-writer.server.ts`, but that is
34
+ * server-only Supabase/object-store code the sandbox cannot import, and the
35
+ * CLI's existing artifact write paths (`orizu runners/prompts/... push`) are all
36
+ * PROJECT-scoped versioned-primitive uploads — there is NO run-scoped artifact
37
+ * write path today. Per ADR-003 (do not invent a new storage convention), a
38
+ * transcript is recorded as a BOUNDED-TAIL run event (`agent_transcript`,
39
+ * `TRANSCRIPT_TAIL_MAX_CHARS`) appended BEFORE the terminal PATCH (a post-terminal
40
+ * append would be refused by the seal). TODO(P3.6/ALI-928): when a run-scoped
41
+ * artifact-ref CLI path lands, swap the tail event for a real object ref.
42
+ */
43
+ import type { HarnessEvent, HarnessEventKind } from './hosted-harness.js';
44
+ export type HostedFetch = (url: string, init?: RequestInit) => Promise<Response>;
45
+ export declare const EGRESS_ALLOWED_EVENT_TYPE = "egress_allowed";
46
+ export declare const EGRESS_BLOCKED_EVENT_TYPE = "egress_blocked";
47
+ /** The RunAPI event type a harness kind maps to, or null if it is not appendable
48
+ * (terminal kinds route through the PATCH; deferred kinds have no mapping yet). */
49
+ export declare function eventTypeForKind(kind: HarnessEventKind): string | null;
50
+ export declare const AGENT_TOKEN_EVENT_TYPE = "agent_token";
51
+ export declare const AGENT_TRANSCRIPT_EVENT_TYPE = "agent_transcript";
52
+ /** Bounded tail size for the transcript stopgap (see artifact-ref decision). */
53
+ export declare const TRANSCRIPT_TAIL_MAX_CHARS = 16384;
54
+ export declare const CREDENTIAL_ROTATED_EVENT_TYPE = "credential_rotated";
55
+ export declare const CREDENTIAL_MINT_FAILED_EVENT_TYPE = "credential_mint_failed";
56
+ export type TerminalStatus = 'succeeded' | 'failed' | 'cancelled';
57
+ export interface FinishOptions {
58
+ summary?: Record<string, unknown>;
59
+ evidence?: Record<string, unknown>;
60
+ /** Full agent transcript; stored as a bounded-tail `agent_transcript` event
61
+ * BEFORE the terminal PATCH (see the artifact-ref decision docblock). */
62
+ transcript?: string;
63
+ }
64
+ export interface RunEventSink {
65
+ /** Map + coalesce + POST a harness event. Owns per-run monotonic sequence.
66
+ * Terminal kinds are rejected (they must go through `finish`). */
67
+ append(event: HarnessEvent): Promise<void>;
68
+ /** Force-flush any coalesced token snapshots (also runs on every structural
69
+ * event and on `finish`). Exposed so callers can flush on a timer if desired. */
70
+ flushTokens(): Promise<void>;
71
+ /** Terminal transition via PATCH; records the transcript tail first, then CAS. */
72
+ finish(status: TerminalStatus, opts?: FinishOptions): Promise<void>;
73
+ /** True once a terminal transition has landed and the sink is sealed. */
74
+ readonly sealed: boolean;
75
+ /** The next sequence the sink will attempt to allocate (test/resume aid). */
76
+ readonly nextSequence: number;
77
+ /** Events the sink has confirmed appended, in order (redacted payloads). */
78
+ readonly recorded: readonly AppendedRunEvent[];
79
+ }
80
+ export interface AppendedRunEvent {
81
+ eventId: string;
82
+ sequence: number;
83
+ eventType: string;
84
+ payload: Record<string, unknown>;
85
+ }
86
+ /** Raised when an append is attempted against a run the sink knows is terminal. */
87
+ export declare class RunTerminalError extends Error {
88
+ constructor(message: string);
89
+ }
90
+ /** Raised when a critical event (or the terminal PATCH) is undeliverable after
91
+ * the bounded retry budget — the caller MUST treat the run as compromised. */
92
+ export declare class CriticalDeliveryError extends Error {
93
+ constructor(message: string);
94
+ }
95
+ /**
96
+ * Raised when `finish()` itself is undeliverable (ALI-1065 finding 2): a
97
+ * CriticalDeliveryError thrown WHILE DELIVERING A TERMINAL TRANSITION, carrying
98
+ * the intended status + finish options so the caller can retry the delivery
99
+ * with the ORIGINAL outcome. Before this, the error surfaced as a bare
100
+ * CriticalDeliveryError and the loop's generic catch re-finished the run
101
+ * 'failed' — a ~1s transport blip on the SUCCESS terminal recorded a succeeded
102
+ * run as failed. Subclasses CriticalDeliveryError so existing classification
103
+ * (drop-vs-surface) is unchanged.
104
+ */
105
+ export declare class TerminalDeliveryError extends CriticalDeliveryError {
106
+ readonly intendedStatus: TerminalStatus;
107
+ readonly finishOptions: FinishOptions | undefined;
108
+ constructor(message: string, intendedStatus: TerminalStatus, finishOptions?: FinishOptions);
109
+ }
110
+ /**
111
+ * Raised on a 403 from the RunAPI. Named for what a 403 actually is — NOT "the
112
+ * run is terminal" (that is 404/410). A 403 means the caller may no longer write
113
+ * this run: the session bearer was revoked, OR the agent lost access to the run
114
+ * (e.g. its session was reassigned). The write definitely did not land, so the
115
+ * sink does NOT seal and does NOT burn the sequence; the caller decides whether
116
+ * to re-authenticate or abandon the run.
117
+ */
118
+ export declare class RunAuthError extends Error {
119
+ constructor(message: string);
120
+ }
121
+ export interface CreateRunEventSinkOptions {
122
+ apiBaseUrl: string;
123
+ runId: string;
124
+ /**
125
+ * The Orizu bearer, EITHER a fixed string OR a provider resolved per request.
126
+ * A provider (e.g. one that reads the rotated 0600 bearer file) lets the sink
127
+ * pick up a host-side token rotation without being rebuilt: every request
128
+ * resolves the current value, and on a 401/403 the sink re-resolves ONCE and
129
+ * retries before classifying the failure (fresh token after rotation).
130
+ */
131
+ bearer: string | (() => string);
132
+ fetchImpl?: HostedFetch;
133
+ /**
134
+ * Verbatim secrets to strip from every payload before it leaves the sandbox.
135
+ *
136
+ * THIS IS THE REDACTION GUARANTEE. Exact-match on these values is the control
137
+ * we rely on — ANY secret that is present in the sandbox (the run bearer is
138
+ * added automatically; also pass every minted repo token, model-provider API
139
+ * key, and any credential a customer setup step injects) MUST appear in this
140
+ * list. Whatever is here is scrubbed wherever it appears, even mid-string and
141
+ * regardless of its shape. The token-shape patterns in `secret-redaction.ts`
142
+ * are only defense-in-depth for credentials no one declared; never treat a
143
+ * shape match as the primary safeguard.
144
+ */
145
+ redactSecretsList?: readonly string[];
146
+ now?: () => number;
147
+ /** First sequence to allocate (resume sets this to server cursor + 1). */
148
+ startSequence?: number;
149
+ /** eventId namespace; deterministic ids `<prefix>:<sequence>` make a replayed
150
+ * event an idempotent 200 (never a 409 same-sequence-different-eventId). */
151
+ eventIdPrefix?: string;
152
+ /** Bounded retry budget for critical deliveries (append critical + finish). */
153
+ maxCriticalAttempts?: number;
154
+ /**
155
+ * Bounded retry budget for NON-critical appends (agent_tool_call, agent_step_*,
156
+ * token snapshots) before the event is DROPPED. Retries only on transient
157
+ * network/5xx failures; on exhaustion the event is dropped (never thrown), so a
158
+ * single bad POST in a multi-hour run never fails the whole run (ALI-1061).
159
+ * Default 3.
160
+ */
161
+ maxNonCriticalAttempts?: number;
162
+ /** Injectable backoff sleep (tests pass a no-op to avoid real delays). */
163
+ sleepImpl?: (ms: number) => Promise<void>;
164
+ /** Local diagnostic sink for disagreement-rule logs (never throws). */
165
+ onDiagnostic?: (message: string) => void;
166
+ }
167
+ export declare function createRunEventSink(options: CreateRunEventSinkOptions): RunEventSink;
168
+ export interface ResumeRunEventSinkOptions extends Omit<CreateRunEventSinkOptions, 'startSequence'> {
169
+ /** Page size for the cursor tail while discovering the latest sequence. */
170
+ pageSize?: number;
171
+ }
172
+ /**
173
+ * Rebuild a sink after a restart WITHOUT losing run continuity (acceptance:
174
+ * "reconnect/resume without losing run continuity"). Walks the events GET
175
+ * cursor tail to the end to learn the server's latest sequence, then returns a
176
+ * fresh sink whose first allocation is `latest + 1`.
177
+ *
178
+ * ── QUIESCE PRECONDITION (single-writer handoff) ─────────────────────────────
179
+ * This is safe ONLY when the predecessor sink has FULLY STOPPED before resume
180
+ * runs — the RunAPI is single-writer-per-run (see the events route), and resume
181
+ * assumes it is the sole writer while it reads the tail and picks the next
182
+ * sequence. It does NOT coordinate with a live predecessor. If a still-in-flight
183
+ * commit from a not-yet-dead sink lands AFTER we read the cursor, that sink and
184
+ * this one can both target the same next sequence. We do not claim "no
185
+ * collision": deterministic eventIds (`<runId>:<sequence>`) make an identical
186
+ * replay an idempotent 200, but two DIFFERENT payloads racing one sequence is a
187
+ * real conflict — bounded, not eliminated, by the P2-4 burn rule (the loser
188
+ * burns its candidate and advances rather than swapping committed content).
189
+ * Callers MUST ensure the predecessor is quiesced; treat overlap as a bug.
190
+ *
191
+ * ── STUCK-RUNNING RECOVERY (out of scope here) ───────────────────────────────
192
+ * If a sink crashes BETWEEN its last append and finish(), the run is left with
193
+ * status='running' server-side and no terminal event — resume can continue
194
+ * appending, but nothing in THIS module will time out and finalize an abandoned
195
+ * run whose writer never came back. A server-side watchdog owns that recovery
196
+ * (G6 / ALI-1007); it is deliberately not implemented in the sandbox client.
197
+ */
198
+ export declare function resumeRunEventSink(options: ResumeRunEventSinkOptions): Promise<RunEventSink>;
199
+ export interface DrainOptions {
200
+ /** Transcript captured by the caller, stored on the terminal transition. */
201
+ transcript?: string;
202
+ summary?: Record<string, unknown>;
203
+ evidence?: Record<string, unknown>;
204
+ /**
205
+ * Hook invoked AFTER the stream yields its terminal event but BEFORE `finish()`
206
+ * seals the sink, on EVERY terminal path (success, failure, abnormal end). Used
207
+ * by the loop's end-of-run auto-harvest (ALI-1036) so `work_persisted` /
208
+ * `work_none` / `work_persist_failed` can still be appended while the sink is
209
+ * writable. Its own failure must never change the run's terminal status — the
210
+ * hook itself is responsible for swallowing errors.
211
+ */
212
+ beforeFinish?: () => Promise<void>;
213
+ }
214
+ /**
215
+ * Consume a harness `runPrompt` stream into a sink: structural events are
216
+ * appended (with token coalescing), and the single terminal event
217
+ * (`execution_complete` / `error`) is routed to `finish()` — NEVER appended.
218
+ * This is the event bridge's happy-path driver; the terminal event decides the
219
+ * run's final status.
220
+ */
221
+ export declare function drainHarnessToSink(events: AsyncIterable<HarnessEvent>, sink: RunEventSink, opts?: DrainOptions): Promise<TerminalStatus>;
222
+ //# sourceMappingURL=hosted-run-event-sink.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hosted-run-event-sink.d.ts","sourceRoot":"","sources":["../src/hosted-run-event-sink.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAIzE,MAAM,MAAM,WAAW,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;AAUhF,eAAO,MAAM,yBAAyB,mBAAmB,CAAA;AACzD,eAAO,MAAM,yBAAyB,mBAAmB,CAAA;AA8BzD;oFACoF;AACpF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,gBAAgB,GAAG,MAAM,GAAG,IAAI,CAEtE;AAED,eAAO,MAAM,sBAAsB,gBAAgB,CAAA;AACnD,eAAO,MAAM,2BAA2B,qBAAqB,CAAA;AAC7D,gFAAgF;AAChF,eAAO,MAAM,yBAAyB,QAAS,CAAA;AAY/C,eAAO,MAAM,6BAA6B,uB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