orizu 0.5.20 → 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 (260) hide show
  1. package/dist/archive-artifacts-cli.d.ts +50 -0
  2. package/dist/archive-artifacts-cli.d.ts.map +1 -0
  3. package/dist/artifact-archive.d.ts +48 -0
  4. package/dist/artifact-archive.d.ts.map +1 -0
  5. package/dist/artifact-pull.d.ts +22 -0
  6. package/dist/artifact-pull.d.ts.map +1 -0
  7. package/dist/banner.d.ts +3 -0
  8. package/dist/banner.d.ts.map +1 -0
  9. package/dist/connectors-cli.d.ts +31 -0
  10. package/dist/connectors-cli.d.ts.map +1 -0
  11. package/dist/credentials.d.ts +46 -0
  12. package/dist/credentials.d.ts.map +1 -0
  13. package/dist/csv.d.ts +49 -0
  14. package/dist/csv.d.ts.map +1 -0
  15. package/dist/dataset-download.d.ts +6 -0
  16. package/dist/dataset-download.d.ts.map +1 -0
  17. package/dist/dataset-edit-rows.d.ts +10 -0
  18. package/dist/dataset-edit-rows.d.ts.map +1 -0
  19. package/dist/dataset-upload-snapshot.d.ts +13 -0
  20. package/dist/dataset-upload-snapshot.d.ts.map +1 -0
  21. package/dist/daytona-slice-rehearsal.d.ts +89 -0
  22. package/dist/daytona-slice-rehearsal.d.ts.map +1 -0
  23. package/dist/daytona-slice.d.ts +106 -0
  24. package/dist/daytona-slice.d.ts.map +1 -0
  25. package/dist/deploy-key-merge-core.d.ts +121 -0
  26. package/dist/deploy-key-merge-core.d.ts.map +1 -0
  27. package/dist/diff-comments-cli.d.ts +12 -0
  28. package/dist/diff-comments-cli.d.ts.map +1 -0
  29. package/dist/diff-comments-cli.js +3 -0
  30. package/dist/egress-allowlist-cli.d.ts +23 -0
  31. package/dist/egress-allowlist-cli.d.ts.map +1 -0
  32. package/dist/egress-policy.d.ts +108 -0
  33. package/dist/egress-policy.d.ts.map +1 -0
  34. package/dist/error-response.d.ts +9 -0
  35. package/dist/error-response.d.ts.map +1 -0
  36. package/dist/file-parser.d.ts +5 -0
  37. package/dist/file-parser.d.ts.map +1 -0
  38. package/dist/gepa-engine-dispatch.d.ts +9 -0
  39. package/dist/gepa-engine-dispatch.d.ts.map +1 -0
  40. package/dist/gepa-engine-dispatch.js +48 -2
  41. package/dist/gepa-python-command.d.ts +6 -0
  42. package/dist/gepa-python-command.d.ts.map +1 -0
  43. package/dist/gepa-python-paths.d.ts +6 -0
  44. package/dist/gepa-python-paths.d.ts.map +1 -0
  45. package/dist/gepa-python-paths.js +6 -3
  46. package/dist/git-credential.d.ts +69 -0
  47. package/dist/git-credential.d.ts.map +1 -0
  48. package/dist/git-recovery-environment.d.ts +31 -0
  49. package/dist/git-recovery-environment.d.ts.map +1 -0
  50. package/dist/github-setup.d.ts +122 -0
  51. package/dist/github-setup.d.ts.map +1 -0
  52. package/dist/global-flags.d.ts +12 -0
  53. package/dist/global-flags.d.ts.map +1 -0
  54. package/dist/help.d.ts +46 -0
  55. package/dist/help.d.ts.map +1 -0
  56. package/dist/help.js +91 -23
  57. package/dist/hosted-boot.d.ts +273 -0
  58. package/dist/hosted-boot.d.ts.map +1 -0
  59. package/dist/hosted-bootstrap-rehearsal.d.ts +86 -0
  60. package/dist/hosted-bootstrap-rehearsal.d.ts.map +1 -0
  61. package/dist/hosted-bootstrap.d.ts +188 -0
  62. package/dist/hosted-bootstrap.d.ts.map +1 -0
  63. package/dist/hosted-broker-server.d.ts +50 -0
  64. package/dist/hosted-broker-server.d.ts.map +1 -0
  65. package/dist/hosted-git-http-server.d.ts +36 -0
  66. package/dist/hosted-git-http-server.d.ts.map +1 -0
  67. package/dist/hosted-harness-claude.d.ts +195 -0
  68. package/dist/hosted-harness-claude.d.ts.map +1 -0
  69. package/dist/hosted-harness-opencode.d.ts +227 -0
  70. package/dist/hosted-harness-opencode.d.ts.map +1 -0
  71. package/dist/hosted-harness.d.ts +118 -0
  72. package/dist/hosted-harness.d.ts.map +1 -0
  73. package/dist/hosted-harvest.d.ts +68 -0
  74. package/dist/hosted-harvest.d.ts.map +1 -0
  75. package/dist/hosted-headless.d.ts +72 -0
  76. package/dist/hosted-headless.d.ts.map +1 -0
  77. package/dist/hosted-loop-lifecycle.d.ts +206 -0
  78. package/dist/hosted-loop-lifecycle.d.ts.map +1 -0
  79. package/dist/hosted-loop.d.ts +170 -0
  80. package/dist/hosted-loop.d.ts.map +1 -0
  81. package/dist/hosted-run-event-sink.d.ts +222 -0
  82. package/dist/hosted-run-event-sink.d.ts.map +1 -0
  83. package/dist/hosted-runtime-assets.d.ts +186 -0
  84. package/dist/hosted-runtime-assets.d.ts.map +1 -0
  85. package/dist/hosted-session-cli.d.ts +258 -0
  86. package/dist/hosted-session-cli.d.ts.map +1 -0
  87. package/dist/hosted-skill-staging.d.ts +73 -0
  88. package/dist/hosted-skill-staging.d.ts.map +1 -0
  89. package/dist/http.d.ts +8 -0
  90. package/dist/http.d.ts.map +1 -0
  91. package/dist/index.d.ts +22 -0
  92. package/dist/index.d.ts.map +1 -0
  93. package/dist/index.js +88 -92
  94. package/dist/instruction-set-gepa-launch.d.ts +3 -0
  95. package/dist/instruction-set-gepa-launch.d.ts.map +1 -0
  96. package/dist/instruction-set-gepa-launch.js +15 -0
  97. package/dist/instruction-set-loader.d.ts +6 -0
  98. package/dist/instruction-set-loader.d.ts.map +1 -0
  99. package/dist/instruction-set-loader.js +59 -0
  100. package/dist/instruction-set-manifest.d.ts +14 -0
  101. package/dist/instruction-set-manifest.d.ts.map +1 -0
  102. package/dist/instruction-set-manifest.js +162 -0
  103. package/dist/instruction-sets-cli.d.ts +40 -0
  104. package/dist/instruction-sets-cli.d.ts.map +1 -0
  105. package/dist/instruction-sets-cli.js +361 -0
  106. package/dist/json-response.d.ts +4 -0
  107. package/dist/json-response.d.ts.map +1 -0
  108. package/dist/jsonl-stream.d.ts +8 -0
  109. package/dist/jsonl-stream.d.ts.map +1 -0
  110. package/dist/kill-switch-cli.d.ts +30 -0
  111. package/dist/kill-switch-cli.d.ts.map +1 -0
  112. package/dist/loopback-serve.d.ts +25 -0
  113. package/dist/loopback-serve.d.ts.map +1 -0
  114. package/dist/manifests-cli.d.ts +22 -0
  115. package/dist/manifests-cli.d.ts.map +1 -0
  116. package/dist/markdown-report-input.d.ts +7 -0
  117. package/dist/markdown-report-input.d.ts.map +1 -0
  118. package/dist/merge-job.d.ts +155 -0
  119. package/dist/merge-job.d.ts.map +1 -0
  120. package/dist/model-configs-cli.d.ts +19 -0
  121. package/dist/model-configs-cli.d.ts.map +1 -0
  122. package/dist/model-configs-cli.js +104 -0
  123. package/dist/optimization-export-cli.d.ts +19 -0
  124. package/dist/optimization-export-cli.d.ts.map +1 -0
  125. package/dist/optimizations-list-cli.d.ts +20 -0
  126. package/dist/optimizations-list-cli.d.ts.map +1 -0
  127. package/dist/optimizations-promote-cli.d.ts +8 -0
  128. package/dist/optimizations-promote-cli.d.ts.map +1 -0
  129. package/dist/optimizations-promote-cli.js +34 -0
  130. package/dist/option-validation.d.ts +15 -0
  131. package/dist/option-validation.d.ts.map +1 -0
  132. package/dist/preview-runtime.d.ts +63 -0
  133. package/dist/preview-runtime.d.ts.map +1 -0
  134. package/dist/prompt-draft-push.d.ts +60 -0
  135. package/dist/prompt-draft-push.d.ts.map +1 -0
  136. package/dist/prompt-label-cli.d.ts +11 -0
  137. package/dist/prompt-label-cli.d.ts.map +1 -0
  138. package/dist/prompt-label-cli.js +29 -0
  139. package/dist/prompt-length-wire.d.ts +28 -0
  140. package/dist/prompt-length-wire.d.ts.map +1 -0
  141. package/dist/prompt-report-cli.d.ts +10 -0
  142. package/dist/prompt-report-cli.d.ts.map +1 -0
  143. package/dist/prompt-summary-table.d.ts +15 -0
  144. package/dist/prompt-summary-table.d.ts.map +1 -0
  145. package/dist/prompt-summary-table.js +6 -0
  146. package/dist/registration-tag-warning.d.ts +32 -0
  147. package/dist/registration-tag-warning.d.ts.map +1 -0
  148. package/dist/report-comments-cli.d.ts +16 -0
  149. package/dist/report-comments-cli.d.ts.map +1 -0
  150. package/dist/report-markdown-blankness.d.ts +2 -0
  151. package/dist/report-markdown-blankness.d.ts.map +1 -0
  152. package/dist/report-replacement-warning.d.ts +17 -0
  153. package/dist/report-replacement-warning.d.ts.map +1 -0
  154. package/dist/repository-backup-core.d.ts +225 -0
  155. package/dist/repository-backup-core.d.ts.map +1 -0
  156. package/dist/repository-recovery-manifest.d.ts +83 -0
  157. package/dist/repository-recovery-manifest.d.ts.map +1 -0
  158. package/dist/run-event-digest.d.ts +74 -0
  159. package/dist/run-event-digest.d.ts.map +1 -0
  160. package/dist/runner-dir-verify.d.ts +66 -0
  161. package/dist/runner-dir-verify.d.ts.map +1 -0
  162. package/dist/runner-instruction-set-contract.d.ts +24 -0
  163. package/dist/runner-instruction-set-contract.d.ts.map +1 -0
  164. package/dist/runner-instruction-set-contract.js +50 -0
  165. package/dist/sandbox-hygiene.d.ts +45 -0
  166. package/dist/sandbox-hygiene.d.ts.map +1 -0
  167. package/dist/sandbox-provider.d.ts +193 -0
  168. package/dist/sandbox-provider.d.ts.map +1 -0
  169. package/dist/scorer-draft-push.d.ts +50 -0
  170. package/dist/scorer-draft-push.d.ts.map +1 -0
  171. package/dist/scorers-cli.d.ts +20 -0
  172. package/dist/scorers-cli.d.ts.map +1 -0
  173. package/dist/scorers-cli.js +22 -0
  174. package/dist/scorers-verify-parity-bridge.d.ts +16 -0
  175. package/dist/scorers-verify-parity-bridge.d.ts.map +1 -0
  176. package/dist/scorers-verify-parity-bridge.js +90 -0
  177. package/dist/scorers-verify-parity.d.ts +81 -0
  178. package/dist/scorers-verify-parity.d.ts.map +1 -0
  179. package/dist/scorers-verify-parity.js +502 -0
  180. package/dist/scores-accept-cli.d.ts +21 -0
  181. package/dist/scores-accept-cli.d.ts.map +1 -0
  182. package/dist/secret-redaction.d.ts +47 -0
  183. package/dist/secret-redaction.d.ts.map +1 -0
  184. package/dist/session-timeline.d.ts +54 -0
  185. package/dist/session-timeline.d.ts.map +1 -0
  186. package/dist/setup-prompt.d.ts +5 -0
  187. package/dist/setup-prompt.d.ts.map +1 -0
  188. package/dist/skill-installer.d.ts +68 -0
  189. package/dist/skill-installer.d.ts.map +1 -0
  190. package/dist/skilled-proposer-launch.d.ts +7 -0
  191. package/dist/skilled-proposer-launch.d.ts.map +1 -0
  192. package/dist/skilled-proposer-launch.js +60 -0
  193. package/dist/smoke.d.ts +102 -0
  194. package/dist/smoke.d.ts.map +1 -0
  195. package/dist/start-intent.d.ts +12 -0
  196. package/dist/start-intent.d.ts.map +1 -0
  197. package/dist/task-assignment-manifest.d.ts +15 -0
  198. package/dist/task-assignment-manifest.d.ts.map +1 -0
  199. package/dist/task-create-error.d.ts +18 -0
  200. package/dist/task-create-error.d.ts.map +1 -0
  201. package/dist/team-connectors-cli.d.ts +29 -0
  202. package/dist/team-connectors-cli.d.ts.map +1 -0
  203. package/dist/types.d.ts +39 -0
  204. package/dist/types.d.ts.map +1 -0
  205. package/dist/vercel-sandbox-provider.d.ts +156 -0
  206. package/dist/vercel-sandbox-provider.d.ts.map +1 -0
  207. package/dist/workbench-cli.d.ts +233 -0
  208. package/dist/workbench-cli.d.ts.map +1 -0
  209. package/dist/workspace-sync.d.ts +207 -0
  210. package/dist/workspace-sync.d.ts.map +1 -0
  211. package/dist/workspace.d.ts +92 -0
  212. package/dist/workspace.d.ts.map +1 -0
  213. package/dist/zip-draft-push.d.ts +55 -0
  214. package/dist/zip-draft-push.d.ts.map +1 -0
  215. package/package.json +14 -1
  216. package/requirements/README.md +138 -0
  217. package/requirements/skilled-proposer.in +66 -0
  218. package/requirements/skilled-proposer.lock +265 -0
  219. package/scripts/ensure-skilled-proposer-venv.mjs +5 -0
  220. package/scripts/refresh-skilled-proposer-lock.mjs +256 -0
  221. package/src/diff-comments-cli.ts +4 -0
  222. package/src/gepa-engine-dispatch.ts +42 -2
  223. package/src/gepa-python-paths.ts +6 -3
  224. package/src/help.ts +93 -23
  225. package/src/index.ts +99 -126
  226. package/src/instruction-set-gepa-launch.ts +28 -0
  227. package/src/instruction-set-loader.ts +37 -0
  228. package/src/instruction-set-manifest.ts +120 -0
  229. package/src/instruction-sets-cli.ts +306 -0
  230. package/src/model-configs-cli.ts +119 -0
  231. package/src/optimizations-promote-cli.ts +41 -0
  232. package/src/prompt-label-cli.ts +55 -0
  233. package/src/prompt-summary-table.ts +12 -0
  234. package/src/runner-instruction-set-contract.ts +64 -0
  235. package/src/scorers-cli.ts +40 -0
  236. package/src/scorers-verify-parity-bridge.ts +90 -0
  237. package/src/scorers-verify-parity.ts +564 -0
  238. package/src/skilled-proposer-launch.ts +89 -0
  239. package/src/skilled-proposer-venv-manager.mjs +757 -0
  240. package/tsconfig.json +2 -0
  241. package/vendor/orizu-gepa/src/orizu_gepa_connector/__init__.py +2 -1
  242. package/vendor/orizu-gepa/src/orizu_gepa_connector/adapter.py +8 -2
  243. package/vendor/orizu-gepa/src/orizu_gepa_connector/callbacks.py +17 -3
  244. package/vendor/orizu-gepa/src/orizu_gepa_connector/engine.py +100 -8
  245. package/vendor/orizu-gepa/src/orizu_gepa_connector/instruction_set_loader.py +52 -0
  246. package/vendor/orizu-gepa/src/orizu_gepa_connector/reflection.py +92 -12
  247. package/vendor/orizu-gepa/src/orizu_gepa_connector/runtime.py +100 -22
  248. package/vendor/orizu-gepa/src/orizu_gepa_connector/skilled_proposer_bridge.py +381 -0
  249. package/vendor/orizu-gepa/src/orizu_gepa_connector/stop_conditions.py +17 -0
  250. package/vendor/orizu-gepa/src/orizu_gepa_connector/translator.py +2 -1
  251. package/vendor/orizu-gepa-python/src/orizu_gepa/client.py +52 -7
  252. package/vendor/orizu-gepa-python/src/orizu_gepa/local_log.py +4 -1
  253. package/vendor/orizu-gepa-python/src/orizu_gepa/optimizer.py +10 -5
  254. package/vendor/orizu-gepa-python/src/orizu_gepa/reflection.py +323 -68
  255. package/vendor/orizu-gepa-python/src/orizu_gepa/runner.py +207 -13
  256. package/vendor/skills/orizu-cli/SKILL.md +2 -0
  257. package/vendor/skills/orizu-cli/references/cli-reference.md +85 -1
  258. package/vendor/skills/orizu-cli/references/migrate-existing-gepa-setup.md +303 -0
  259. package/vendor/skills/orizu-cli/references/optimization-with-gepa.md +25 -0
  260. package/vendor/skills/orizu-cli/references/prompt-control-plane.md +108 -8
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Headless-run helpers (ALI-1037) for the in-sandbox loop.
3
+ *
4
+ * - `withIdleWatchdog`: wraps a harness event stream and aborts a prompt that
5
+ * makes NO progress (no harness event) for a bounded window, so a stalled
6
+ * agent can never hang a hosted run forever. On idle it invokes `onTimeout`
7
+ * (the loop aborts the harness) then throws `AgentStalledError`, which the
8
+ * loop turns into a `failed` terminal — AFTER running the end-of-run harvest.
9
+ *
10
+ * - `annotateHeadlessQuestions`: observability for the question-tool deny path.
11
+ * The interactive `question` tool is DENIED via OpenCode's permission map
12
+ * (see HEADLESS_DENIED_TOOLS in hosted-harness-opencode.ts), so a headless
13
+ * run never blocks on it. When the agent nonetheless attempts a `question`
14
+ * tool call, this wrapper emits a `question_auto_answered` event recording the
15
+ * question and the option that WOULD be recommended, so the run timeline shows
16
+ * the auto-handling. It touches only the normalized event stream — never the
17
+ * fragile OpenCode SSE transform.
18
+ */
19
+ import type { HarnessEvent } from './hosted-harness.js';
20
+ /** Thrown by `withIdleWatchdog` when the stream is idle past its timeout. */
21
+ export declare class AgentStalledError extends Error {
22
+ readonly idleMs: number;
23
+ constructor(idleMs: number);
24
+ }
25
+ /** Render the idle window for the error message. Minutes (the operator-facing
26
+ * unit; default window is 25m), rounded to one decimal so sub-minute test
27
+ * windows still read sensibly. */
28
+ export declare function formatIdleWindow(ms: number): string;
29
+ export interface IdleWatchdogOptions<T> {
30
+ /** No harness event within this many ms aborts the prompt. <= 0 disables. */
31
+ timeoutMs: number;
32
+ /** Invoked once on idle (the loop aborts the harness) before the throw. */
33
+ onTimeout: () => Promise<void> | void;
34
+ /**
35
+ * Whether a value counts as PROGRESS (resets the idle timer). Values passed
36
+ * through as non-progress are still yielded downstream but do NOT extend the
37
+ * idle deadline. Defaults to treating every value as progress. Used to exclude
38
+ * synthetic deny-path events (e.g. `question_auto_answered`) so a model stuck
39
+ * in a denied-question retry loop still trips `agent_stalled` (ALI-1069).
40
+ */
41
+ isProgress?: (value: T) => boolean;
42
+ }
43
+ /**
44
+ * Wrap `source` so that if no PROGRESS arrives within `timeoutMs`, `onTimeout`
45
+ * runs and `AgentStalledError` is thrown. The idle deadline advances only on
46
+ * values `opts.isProgress` accepts (default: all), so it measures gaps between
47
+ * real progress events, not total duration — a stream of non-progress values
48
+ * (e.g. `question_auto_answered` deny-path events) passes through WITHOUT
49
+ * resetting the timer, so a stuck loop still stalls. The still-pending `next()`
50
+ * is not left as an unhandled rejection, and the underlying iterator is
51
+ * returned/closed on any early exit.
52
+ */
53
+ export declare function withIdleWatchdog<T>(source: AsyncIterable<T>, opts: IdleWatchdogOptions<T>): AsyncGenerator<T>;
54
+ export interface ParsedHeadlessQuestion {
55
+ question: string;
56
+ chosenOption: string;
57
+ }
58
+ /**
59
+ * Parse the OpenCode `question` tool args into the question text and the option
60
+ * we would pick headless: the one labeled "(Recommended)" if present, else the
61
+ * first. Defensive against the tool's shape drifting (options as strings or
62
+ * objects; the question under any of several keys).
63
+ */
64
+ export declare function parseHeadlessQuestion(args: unknown): ParsedHeadlessQuestion;
65
+ /**
66
+ * Pass every harness event through unchanged; when a `question` tool call/result
67
+ * is seen, additionally emit a `question_auto_answered` event (deduped per
68
+ * callId+message) recording the auto-handling. The tool is denied at the
69
+ * permission layer, so this is a record — not an interactive reply.
70
+ */
71
+ export declare function annotateHeadlessQuestions(source: AsyncIterable<HarnessEvent>): AsyncGenerator<HarnessEvent>;
72
+ //# sourceMappingURL=hosted-headless.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hosted-headless.d.ts","sourceRoot":"","sources":["../src/hosted-headless.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAEvD,6EAA6E;AAC7E,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;gBACX,MAAM,EAAE,MAAM;CAK3B;AAED;;mCAEmC;AACnC,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAGnD;AAED,MAAM,WAAW,mBAAmB,CAAC,CAAC;IACpC,6EAA6E;IAC7E,SAAS,EAAE,MAAM,CAAA;IACjB,2EAA2E;IAC3E,SAAS,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;IACrC;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAA;CACnC;AAID;;;;;;;;;GASG;AACH,wBAAuB,gBAAgB,CAAC,CAAC,EACvC,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,EACxB,IAAI,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAC3B,cAAc,CAAC,CAAC,CAAC,CAyCnB;AAeD,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,MAAM,CAAA;IAChB,YAAY,EAAE,MAAM,CAAA;CACrB;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,OAAO,GAAG,sBAAsB,CA0B3E;AAED;;;;;GAKG;AACH,wBAAuB,yBAAyB,CAC9C,MAAM,EAAE,aAAa,CAAC,YAAY,CAAC,GAClC,cAAc,CAAC,YAAY,CAAC,CAuB9B"}
@@ -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,8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;IAC7E,MAAM,EAAE,MAAM,CAAA;CACf;AAED;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAejF;AAED,wDAAwD;AACxD,MAAM,WAAW,mBAAmB;IAClC;qFACiF;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,MAA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