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,273 @@
1
+ /**
2
+ * `orizu internal hosted-boot` — the in-sandbox BOOT ENTRYPOINT for the DO-path
3
+ * hosted agent (ALI-1057). The session coordinator's Durable Object launches
4
+ * this DETACHED (`ORIZU_SANDBOX_ENTRYPOINT`, via nohup) once it has verified the
5
+ * pre-baked runtime marker; from here the sandbox bootstraps itself under the
6
+ * PULL model (ALI-1055): no operator writes its credentials, and no bearer or
7
+ * connector secret ever rests in Cloudflare.
8
+ *
9
+ * WHAT DIFFERS FROM THE OPERATOR PATH (packages/cli/src/hosted-session-cli.ts +
10
+ * hosted-bootstrap.ts) — and ONLY this:
11
+ * (a) credentials are PULLED over HTTP at boot instead of the operator writing
12
+ * a 0600 bearer file: the boot secret is exchanged for a fresh Orizu agent
13
+ * bearer at ORIZU_AGENT_TOKEN_URL, and the connector env comes from
14
+ * ORIZU_ENV_BUNDLE_URL (the 5A contract — connectors only, NO model key);
15
+ * (b) the git credential helper runs in PULL MODE (hosted-runtime-assets.ts):
16
+ * it GETs a fresh bearer per git op from the agent-token URL (boot-secret
17
+ * auth) rather than reading a host-rotated 0600 file.
18
+ * Everything else — the clone via the credential helper, the loop, the event
19
+ * sink, redaction — is REUSED, not reimplemented.
20
+ *
21
+ * FROZEN ENV CONTRACT (workers/session-coordinator/src/bootstrap.ts
22
+ * `planSandboxEnv`). Required (fail-fast if any is missing):
23
+ * ORIZU_BOOT_SECRET the per-sandbox durable bootstrap secret;
24
+ * ORIZU_AGENT_TOKEN_URL {coordinator}/sessions/:id/agent-token (bearer pull);
25
+ * ORIZU_ENV_BUNDLE_URL {orizu}/api/coordinator/sessions/:id/env-bundle;
26
+ * ORIZU_BASE_URL the Orizu control-plane origin;
27
+ * ORIZU_SESSION_ID this session id.
28
+ * Present-but-optional in the contract, resolved from the control plane when
29
+ * absent: ORIZU_RUN_ID, ORIZU_WORKSPACE_ID (read back from the session), and the
30
+ * non-secret ANTHROPIC_API_KEY dummy placeholder (firewall brokers the real key).
31
+ */
32
+ import { type HostedLoopContext, type HostedLoopResult } from './hosted-loop.js';
33
+ export type BootFetch = (url: string, init?: RequestInit) => Promise<Response>;
34
+ export declare const REQUIRED_BOOT_ENV_VARS: readonly ["ORIZU_BOOT_SECRET", "ORIZU_AGENT_TOKEN_URL", "ORIZU_ENV_BUNDLE_URL", "ORIZU_BASE_URL", "ORIZU_SESSION_ID"];
35
+ export interface HostedBootEnv {
36
+ bootSecret: string;
37
+ agentTokenUrl: string;
38
+ /** {coordinator}/sessions/:id/boot-status — the ALI-1060 agent-liveness
39
+ * callback, derived from agentTokenUrl (same boot-secret auth). */
40
+ bootStatusUrl: string;
41
+ envBundleUrl: string;
42
+ baseUrl: string;
43
+ sessionId: string;
44
+ /** Present in the contract only for resume flows; else resolved server-side. */
45
+ runId: string | null;
46
+ /** Rarely set by the DO (the start body carries no workspace id); read back
47
+ * from the session when absent. */
48
+ workspaceId: string | null;
49
+ /** Non-secret dummy the firewall rewrites on egress — never a real key. */
50
+ anthropicDummyKey: string | null;
51
+ }
52
+ /** Validate the frozen env contract. A list of missing REQUIRED names means the
53
+ * boot must FAIL FAST with a clear error (the DO records the non-zero exit). */
54
+ export declare function resolveHostedBootEnv(env: Record<string, string | undefined>): {
55
+ ok: true;
56
+ value: HostedBootEnv;
57
+ } | {
58
+ ok: false;
59
+ missing: string[];
60
+ };
61
+ /** The boot-status route is the agent-token route's sibling; swap the trailing
62
+ * path segment. Falls back to appending when the shape is unexpected. */
63
+ export declare function deriveBootStatusUrl(agentTokenUrl: string): string;
64
+ /** Best-effort scrub + truncate for a reported failure reason: never leak the
65
+ * boot secret (the one credential the boot always holds), and keep it short. */
66
+ export declare function redactBootReason(reason: string, bootSecret: string): string;
67
+ /**
68
+ * Report the boot outcome to the coordinator's boot-status route (ALI-1060),
69
+ * authed with the boot secret (same as the agent-token pull). Best-effort: the
70
+ * DO's own readiness-timeout is the backstop if this never lands, so a failed
71
+ * report must never mask the boot result. NEVER logs the secret.
72
+ */
73
+ export declare function postBootStatus(opts: {
74
+ bootStatusUrl: string;
75
+ bootSecret: string;
76
+ /** 'ready' | 'failed' are the ALI-1060 liveness signals; 'complete' is the
77
+ * ALI-1064 terminal signal — the loop finished (after auto-harvest), so the
78
+ * DO ends the workspace session and stops instead of extending to 24h. */
79
+ status: 'ready' | 'failed' | 'complete';
80
+ runId: string | null;
81
+ reason?: string | null;
82
+ fetchImpl: BootFetch;
83
+ log?: (line: string) => void;
84
+ }): Promise<void>;
85
+ export interface PulledBearer {
86
+ token: string;
87
+ /** Epoch ms, or null when the response omitted a parseable expiry. */
88
+ expiresAtMs: number | null;
89
+ }
90
+ export interface PullAgentBearerOptions {
91
+ agentTokenUrl: string;
92
+ bootSecret: string;
93
+ fetchImpl: BootFetch;
94
+ /** Total attempts before giving up (the DO may still be arming). Default 5. */
95
+ attempts?: number;
96
+ /** Base backoff in ms (doubles each retry). Default 500. */
97
+ backoffMs?: number;
98
+ sleep?: (ms: number) => Promise<void>;
99
+ log?: (line: string) => void;
100
+ }
101
+ /**
102
+ * Exchange the boot secret for a fresh Orizu agent bearer at the coordinator's
103
+ * agent-token route (`GET`, `Authorization: Bearer <boot secret>` → 200
104
+ * `{token, tokenId, expiresAt}`). Retries with exponential backoff: the DO
105
+ * persists the boot-secret digest and serves this route DURING bootstrap, but a
106
+ * transient mint failure (control-plane blip) should not abort the whole boot.
107
+ * The secret is NEVER logged.
108
+ */
109
+ export declare function pullAgentBearer(opts: PullAgentBearerOptions): Promise<PulledBearer>;
110
+ export interface EnvBundleConnector {
111
+ ref: string;
112
+ envVar: string;
113
+ value: string;
114
+ }
115
+ export interface EnvBundle {
116
+ sessionId: string | null;
117
+ connectors: EnvBundleConnector[];
118
+ redactEnvVars: string[];
119
+ }
120
+ /**
121
+ * Pull the connector env bundle (5A contract): `GET` with the agent bearer → 200
122
+ * `{sessionId, connectors:[{ref,envVar,value}], redactEnvVars:[...]}`. The model
123
+ * key is DELIBERATELY absent (brokered at the firewall). Never logs a value.
124
+ */
125
+ export declare function fetchEnvBundle(opts: {
126
+ envBundleUrl: string;
127
+ bearer: string;
128
+ fetchImpl: BootFetch;
129
+ }): Promise<EnvBundle>;
130
+ /**
131
+ * Export each connector `{envVar: value}` into the environment the loop/agent
132
+ * inherits, and REGISTER every redacted var on `ORIZU_INJECTED_ENV_VARS` — the
133
+ * exact hook the in-sandbox loop reads (`redactionListFromEnv`) to scrub these
134
+ * values from run events. Returns the merged redaction-var list.
135
+ */
136
+ export declare function applyEnvBundle(bundle: EnvBundle, env: Record<string, string | undefined>): string[];
137
+ export interface ResolvedSession {
138
+ workspaceId: string;
139
+ repoBranch: string;
140
+ task: string;
141
+ model: string | null;
142
+ reasoningEffort: string | null;
143
+ /** Session lifetime in minutes (from client_info), if the coordinator recorded
144
+ * it — used to derive the per-prompt max-duration cap (ALI-1061). */
145
+ durationMinutes: number | null;
146
+ /** Most recent existing run id, if any (else the boot creates one). */
147
+ runId: string | null;
148
+ }
149
+ /** GET the session (agent-capable, RLS-scoped) to learn its workspace, branch,
150
+ * task, and any existing run — the DO start body carries none of these. */
151
+ export declare function resolveSession(opts: {
152
+ baseUrl: string;
153
+ sessionId: string;
154
+ bearer: string;
155
+ fetchImpl: BootFetch;
156
+ }): Promise<ResolvedSession>;
157
+ /** Reuse an existing run or start one with the AGENT bearer (actor_type='agent'),
158
+ * exactly like the operator path's run-start step. */
159
+ export declare function ensureRun(opts: {
160
+ baseUrl: string;
161
+ sessionId: string;
162
+ bearer: string;
163
+ fetchImpl: BootFetch;
164
+ existingRunId: string | null;
165
+ title?: string;
166
+ }): Promise<string>;
167
+ /** Mint a session_read repo token to learn the repo full name, then build the
168
+ * GitHub clone URL (mirrors the operator path's `defaultResolveRepo`). */
169
+ export declare function resolveRepo(opts: {
170
+ baseUrl: string;
171
+ workspaceId: string;
172
+ sessionId: string;
173
+ bearer: string;
174
+ fetchImpl: BootFetch;
175
+ }): Promise<{
176
+ repoFullName: string;
177
+ cloneUrl: string;
178
+ }>;
179
+ export interface BootExecResult {
180
+ status: number;
181
+ stdout: string;
182
+ stderr: string;
183
+ }
184
+ export type BootExec = (cmd: string, args: string[], opts?: {
185
+ cwd?: string;
186
+ }) => BootExecResult;
187
+ export declare function assertSafeRunId(runId: string): void;
188
+ export interface RunHostedBootOptions {
189
+ env: HostedBootEnv;
190
+ /** Mutable env map the loop/agent inherits (default: process.env). */
191
+ processEnv?: Record<string, string | undefined>;
192
+ /** Sandbox root the run dir + repo live under (default: process.cwd()). */
193
+ root?: string;
194
+ fetchImpl?: BootFetch;
195
+ exec?: BootExec;
196
+ /** File writer (default: atomic 0600 temp+rename). Injected in tests. */
197
+ writeFile?: (path: string, contents: string) => void;
198
+ /** File reader (default: readFileSync utf8). Injected in tests so the
199
+ * bearer-provider read is backed by the same store as writeFile. */
200
+ readFile?: (path: string) => string;
201
+ /** Dir maker (default: recursive mkdir). Injected in tests. */
202
+ mkdirp?: (path: string) => void;
203
+ /** Run the loop (default: `runHostedLoop`). Injected in tests. */
204
+ runLoop?: (input: {
205
+ context: HostedLoopContext;
206
+ taskPrompt: string;
207
+ bearerProvider: () => string;
208
+ /** Verbatim secrets the loop's event redaction must scrub (ALI-1062: the
209
+ * boot secret — bare hex, so no shape pattern would ever catch it). */
210
+ redactSecretsList: readonly string[];
211
+ }) => Promise<HostedLoopResult>;
212
+ now?: () => number;
213
+ log?: (line: string) => void;
214
+ /** Bearer-pull tuning (passed through to `pullAgentBearer`). */
215
+ bearerAttempts?: number;
216
+ bearerBackoffMs?: number;
217
+ sleep?: (ms: number) => Promise<void>;
218
+ /** ALI-1060: invoked once the run id + agent bearer are known (after
219
+ * ensureRun), so a caller can report/mark on a LATER throw. */
220
+ onBootContext?: (ctx: {
221
+ runId: string;
222
+ bearer: string;
223
+ }) => void;
224
+ }
225
+ export interface HostedBootResult {
226
+ ok: boolean;
227
+ runId: string | null;
228
+ loopStatus: string | null;
229
+ error: string | null;
230
+ }
231
+ /**
232
+ * The full in-sandbox boot: validate → pull bearer → pull+apply env bundle →
233
+ * resolve session/run/repo → write the pull-mode credential assets → clone the
234
+ * session branch → launch the hosted loop (reused, in-process) with a bearer
235
+ * provider fed by the same pull-mode source. Returns the loop's terminal status.
236
+ */
237
+ export declare function runHostedBoot(opts: RunHostedBootOptions): Promise<HostedBootResult>;
238
+ export interface HostedBootCommandIo {
239
+ print: (line: string) => void;
240
+ printErr?: (line: string) => void;
241
+ json?: boolean;
242
+ }
243
+ /**
244
+ * Read the frozen env contract from the process env and run the boot. Fails fast
245
+ * (exit 1) with a clear message naming every missing required var. The DO records
246
+ * the exit code; run failures beyond the boot itself are recorded server-side.
247
+ */
248
+ export declare function hostedBootCommand(io: HostedBootCommandIo): Promise<number>;
249
+ /**
250
+ * Failure fan-out on a boot throw (ALI-1060): mark the run terminally `failed`
251
+ * (the operator path's agent-bearer terminal PATCH) and always signal the
252
+ * coordinator's boot-status route so the DO tears the sandbox down promptly.
253
+ * Best-effort throughout — the boot secret is scrubbed from the reported reason.
254
+ *
255
+ * PRE-BEARER failures (a throw before `onBootContext` — `pullAgentBearer` /
256
+ * `fetchEnvBundle` blew up, so `ctx` is null) still have a run id: the server
257
+ * PRE-CREATES it and injects ORIZU_RUN_ID. We attempt a SHORT bearer pull here
258
+ * so we can self-mark that run failed rather than leaving it `running` until the
259
+ * DO's readiness timeout. If even that pull fails, the DO backstop (boot-status
260
+ * failure now, readiness timeout otherwise) is the last line.
261
+ */
262
+ export declare function reportBootFailure(opts: {
263
+ env: HostedBootEnv;
264
+ ctx: {
265
+ runId: string;
266
+ bearer: string;
267
+ } | null;
268
+ reason: string;
269
+ log: (line: string) => void;
270
+ /** Injectable transport (default: global fetch). Exposed for tests. */
271
+ fetchImpl?: BootFetch;
272
+ }): Promise<void>;
273
+ //# sourceMappingURL=hosted-boot.d.ts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AYG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE;IAC5C,GAAG,EAAE,aAAa,CAAA;IAClB,GAAG,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAA;IAC7C,MAAM,EAAE,MAAM,CAAA;IACd,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAC3B,uEAAuE;IACvE,SAAS,CAAC,EAAE,SAAS,CAAA;CACtB,GAAG,OAAO,CAAC,IAAI,CAAC,CA+ChB"}
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Self-contained rehearsal for the hosted bootstrap (ALI-925), extending the
3
+ * ALI-973 `daytona-slice-rehearsal` pattern.
4
+ *
5
+ * The whole `bootstrapHostedSandbox` flow runs against the local-sim provider
6
+ * with NO Daytona and NO GitHub: a REAL bare git repo backs the session branch,
7
+ * and a REAL HTTP broker (`hosted-broker-server.ts`) stands in for the Orizu
8
+ * control plane (per-repo token broker + RunAPI event ingest).
9
+ *
10
+ * The broker runs as a SEPARATE PROCESS on purpose: local-sim's `exec` blocks on
11
+ * `spawnSync`, and the in-sandbox credential helper it runs calls the broker over
12
+ * the network — an in-process server could not answer while the test thread is
13
+ * blocked. The broker journals events/tokens to files the rehearsal reads back.
14
+ */
15
+ import { type SandboxProvider } from './sandbox-provider.js';
16
+ import type { BrokerConfig } from './hosted-broker-server.js';
17
+ import { type GitHttpConfig } from './hosted-git-http-server.js';
18
+ export interface SpawnedBroker {
19
+ apiBaseUrl: string;
20
+ port: number;
21
+ stop: () => void;
22
+ }
23
+ /**
24
+ * Env keys the broker server reads (kept here so callers do not hand-roll them).
25
+ */
26
+ export declare function brokerEnv(config: BrokerConfig): Record<string, string>;
27
+ /**
28
+ * Spawn the broker server as its own process and resolve once it prints
29
+ * `LISTENING <port>` on stdout.
30
+ */
31
+ export declare function spawnBrokerProcess(config: BrokerConfig): Promise<SpawnedBroker>;
32
+ export interface SpawnedGitHttpServer {
33
+ baseUrl: string;
34
+ port: number;
35
+ stop: () => void;
36
+ }
37
+ /**
38
+ * Spawn the authenticated smart-HTTP git server as its own process (same
39
+ * separate-process rationale as the broker) and resolve once it prints
40
+ * `LISTENING <port>`. `baseUrl` is the clone URL root; append the repo segment.
41
+ */
42
+ export declare function spawnGitHttpProcess(config: GitHttpConfig): Promise<SpawnedGitHttpServer>;
43
+ export interface RecordedRehearsalEvent {
44
+ runId: string;
45
+ eventId: string;
46
+ sequence: number;
47
+ eventType: string;
48
+ payload: unknown;
49
+ }
50
+ export interface HostedBootstrapRehearsal {
51
+ apiBaseUrl: string;
52
+ bearer: string;
53
+ workspaceId: string;
54
+ sessionId: string;
55
+ runId: string;
56
+ sessionBranch: string;
57
+ repoFullName: string;
58
+ provider: SandboxProvider;
59
+ resolveCloneUrl: (repo: string) => string;
60
+ /** VCS host the helper is scoped to (the loopback git server). */
61
+ host: string;
62
+ /** Loopback hosts the helper may serve over plain HTTP (rehearsal only). */
63
+ insecureHttpHosts: readonly string[];
64
+ /** All run events the broker accepted, in arrival order. */
65
+ events: () => RecordedRehearsalEvent[];
66
+ /** Every token value the broker minted (for residue-sweep assertions). */
67
+ tokensIssued: () => string[];
68
+ /** Every Basic-auth password the git server received (proves password===token). */
69
+ basicAuthPasswords: () => string[];
70
+ cleanup: () => Promise<void>;
71
+ }
72
+ export interface RehearsalOptions {
73
+ bearer?: string;
74
+ keep?: boolean;
75
+ /** Seed `.orizu/setup.sh` onto the session branch (force-added past the
76
+ * workbench `.orizu/` gitignore) so the setup-hook step has a hook to run. */
77
+ setupHookBody?: string;
78
+ /** Force the repo-token broker to a status (tests the 4xx credential path). */
79
+ repoTokenStatus?: number;
80
+ /** Force the run-events ingest to a status (tests the failure path). */
81
+ eventsStatus?: number;
82
+ /** Serve the full RunAPI + session + agent-token surface (P3.5 e2e). */
83
+ fullRunApi?: boolean;
84
+ }
85
+ export declare function createHostedBootstrapRehearsal(options?: RehearsalOptions): Promise<HostedBootstrapRehearsal>;
86
+ //# sourceMappingURL=hosted-bootstrap-rehearsal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hosted-bootstrap-rehearsal.d.ts","sourceRoot":"","sources":["../src/hosted-bootstrap-rehearsal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AASH,OAAO,EAA0B,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACpF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EAAc,KAAK,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAuC5E,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,IAAI,CAAA;CACjB;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAkBtE;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC,CA0BrF;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,IAAI,CAAA;CACjB;AAED;;;;GAIG;AACH,wBAAsB,mBAAmB,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,oBAAoB,CAAC,CA0B9F;AAID,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,OAAO,CAAA;CACjB;AAED,MAAM,WAAW,wBAAwB;IACvC,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,aAAa,EAAE,MAAM,CAAA;IACrB,YAAY,EAAE,MAAM,CAAA;IACpB,QAAQ,EAAE,eAAe,CAAA;IACzB,eAAe,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAA;IACzC,kEAAkE;IAClE,IAAI,EAAE,MAAM,CAAA;IACZ,4EAA4E;IAC5E,iBAAiB,EAAE,SAAS,MAAM,EAAE,CAAA;IACpC,4DAA4D;IAC5D,MAAM,EAAE,MAAM,sBAAsB,EAAE,CAAA;IACtC,0EAA0E;IAC1E,YAAY,EAAE,MAAM,MAAM,EAAE,CAAA;IAC5B,mFAAmF;IACnF,kBAAkB,EAAE,MAAM,MAAM,EAAE,CAAA;IAClC,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAC7B;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,OAAO,CAAA;IACd;mFAC+E;IAC/E,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,+EAA+E;IAC/E,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,wEAAwE;IACxE,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,wEAAwE;IACxE,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB;AAuBD,wBAAsB,8BAA8B,CAClD,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,wBAAwB,CAAC,CAqFnC"}
@@ -0,0 +1,188 @@
1
+ /**
2
+ * Host-driven hosted-sandbox bootstrap (ALI-925 / P3.3, per ADR-005 §8).
3
+ *
4
+ * Given a live `SandboxSession` (from the Orizu `SandboxProvider` seam — works
5
+ * with BOTH the Daytona adapter and local-sim), an Orizu API base URL, a bearer,
6
+ * and the workspace/session/run ids + session branch, `bootstrapHostedSandbox`
7
+ * performs the in-sandbox boot flow forked in DESIGN from OpenInspect's
8
+ * `entrypoint.py` supervisor:
9
+ *
10
+ * 1. inject boot context (env/config) as run-scoped files — the bearer only in
11
+ * a 0600 file reaped at teardown, never in git config or the clone URL (G3);
12
+ * 2. install the git credential helper (self-contained script asset) and scope
13
+ * it to the repo dir ONLY (never --global);
14
+ * 3. clone the session branch via the helper (no token in URL / .git/config);
15
+ * 4. install the Orizu CLI (non-fatal, recorded);
16
+ * 5. run the customer `.orizu/setup.sh` hook if present (fresh-boot, non-fatal);
17
+ * 6. record lifecycle events to the RunAPI with client-assigned sequences
18
+ * (generic event types only — never the reserved run_* lifecycle types);
19
+ * 7. on failure, record `bootstrap_failed`, tear down, and sweep for residue.
20
+ *
21
+ * P3.4/P3.5 (OpenCode driver, event bridge, `orizu session start --hosted`)
22
+ * build ON TOP of this — `bootstrapHostedSandbox` is the single writer for the
23
+ * run at this stage and returns the run cursor so a follow-on can continue it.
24
+ */
25
+ import type { SandboxSession } from './sandbox-provider.js';
26
+ import { type HygieneFinding } from './sandbox-hygiene.js';
27
+ export type HostedFetch = (url: string, init?: RequestInit) => Promise<Response>;
28
+ export interface AppendedRunEvent {
29
+ eventId: string;
30
+ sequence: number;
31
+ eventType: string;
32
+ /** Already redacted — safe to inspect / serialize in tests. */
33
+ payload: Record<string, unknown>;
34
+ }
35
+ /**
36
+ * The bootstrap orchestrator is the single writer for the run at this stage, so
37
+ * it owns a local monotonic sequence (per §4b). Every payload is redacted with
38
+ * the bearer before it leaves the process — a run-event body must never carry
39
+ * the bearer or a minted token. Lifecycle run_* types are rejected server-side;
40
+ * the orchestrator only emits generic types.
41
+ */
42
+ export interface BootstrapRunEventSink {
43
+ append(eventType: string, payload?: Record<string, unknown>): Promise<AppendedRunEvent>;
44
+ readonly recorded: readonly AppendedRunEvent[];
45
+ }
46
+ export interface CreateRunEventSinkOptions {
47
+ apiBaseUrl: string;
48
+ runId: string;
49
+ bearer: string;
50
+ fetchImpl?: HostedFetch;
51
+ /** Extra verbatim secrets to redact from payloads (e.g. minted tokens). */
52
+ redactSecretsList?: readonly string[];
53
+ now?: () => number;
54
+ /** Sequence to start at (defaults to 1). */
55
+ startSequence?: number;
56
+ }
57
+ export declare function createBootstrapRunEventSink(options: CreateRunEventSinkOptions): BootstrapRunEventSink;
58
+ export interface HostedBootstrapOptions {
59
+ session: SandboxSession;
60
+ apiBaseUrl: string;
61
+ /** Opaque bearer — a PAT in rehearsal, a G2 session token in production. */
62
+ bearer: string;
63
+ workspaceId: string;
64
+ sessionId: string;
65
+ runId: string;
66
+ sessionBranch: string;
67
+ repoFullName: string;
68
+ /** Map the broker repo full-name → a clone URL the provider understands.
69
+ * Live: `https://github.com/<repo>.git`. Local-sim: the bare repo path. */
70
+ resolveCloneUrl: (repo: string) => string;
71
+ /** Directory (relative to the sandbox root) the session branch clones into. */
72
+ workspaceDir?: string;
73
+ /** VCS host the credential helper serves (default github.com). */
74
+ host?: string;
75
+ /**
76
+ * Broker purpose vocabulary the helper mints with. When omitted, the default
77
+ * is chosen from `bearerKind` (below): a human bearer mints `write`/`read`, an
78
+ * agent bearer mints `session_write`/`session_read`. Injectable so a caller can
79
+ * override without editing the credential-helper script.
80
+ */
81
+ tokenPurposes?: {
82
+ primary: string;
83
+ fallback: string;
84
+ };
85
+ /**
86
+ * Kind of bearer in the 0600 file — the orchestrator KNOWS what it minted, so
87
+ * the default broker purposes are chosen from this EXPLICIT signal, never by
88
+ * sniffing the token. 'agent' → session_write/session_read; 'human' (default)
89
+ * → write/read. Ignored when `tokenPurposes` is passed explicitly.
90
+ */
91
+ bearerKind?: 'agent' | 'human';
92
+ /**
93
+ * Hosts the credential helper may serve over plain HTTP (loopback rehearsal
94
+ * only). Production omits this → the helper stays https-only.
95
+ */
96
+ insecureHttpHosts?: readonly string[];
97
+ /** Helper cache refresh buffer (ms) — overridable so tests can force refresh. */
98
+ cacheBufferMs?: number;
99
+ /**
100
+ * Defer the customer `.orizu/setup.sh` hook to the in-sandbox loop (P3-a). When
101
+ * true, bootstrap does NOT run the hook; it records `setup_hook_deferred` and
102
+ * the loop runs it AFTER its egress canary passes. The host sets this for
103
+ * enforced-egress providers so the hook's network access cannot precede the
104
+ * canary's detection of a silent firewall failure. Default false (run inline).
105
+ */
106
+ deferSetupHook?: boolean;
107
+ /** Published CLI version to install in-sandbox (default 'latest'). */
108
+ cliVersion?: string;
109
+ /** Override the CLI-install shell command (tests inject a deterministic one). */
110
+ cliInstallCommand?: string;
111
+ /**
112
+ * Pre-baked runtime (ALI-1017): the image already ships the Orizu CLI on PATH,
113
+ * so the CLI-install step is SKIPPED (it would fail under G5 default-deny egress
114
+ * anyway) and a `cli_prebaked` event is recorded instead of `cli_installed`.
115
+ * The host sets this together with the sandbox `image` so the two never
116
+ * disagree. When unset, bootstrap ALSO belt-checks the `/opt/orizu/prebaked.json`
117
+ * marker on the sandbox filesystem; either signal skips the install.
118
+ */
119
+ prebaked?: boolean;
120
+ /** Inject a RunAPI sink (tests/production); default builds one over apiBaseUrl. */
121
+ sink?: BootstrapRunEventSink;
122
+ fetchImpl?: HostedFetch;
123
+ now?: () => number;
124
+ }
125
+ export interface HostedBootstrapStep {
126
+ key: string;
127
+ ok: boolean;
128
+ detail: string;
129
+ }
130
+ export interface HostedBootstrapResult {
131
+ ok: boolean;
132
+ steps: HostedBootstrapStep[];
133
+ events: readonly AppendedRunEvent[];
134
+ paths: HostedRuntimePaths;
135
+ /** Set on the failure path: the residue sweep result after teardown. */
136
+ sweep: {
137
+ clean: boolean;
138
+ findings: HygieneFinding[];
139
+ } | null;
140
+ failure: {
141
+ step: string;
142
+ error: string;
143
+ } | null;
144
+ }
145
+ export interface HostedRuntimePaths {
146
+ root: string;
147
+ runDirRel: string;
148
+ runDirAbs: string;
149
+ repoDirRel: string;
150
+ helperScriptAbs: string;
151
+ bootContextAbs: string;
152
+ bearerFileAbs: string;
153
+ cacheFileAbs: string;
154
+ }
155
+ export declare function computeRuntimePaths(root: string, runId: string, workspaceDir: string): HostedRuntimePaths;
156
+ export declare function bootstrapHostedSandbox(opts: HostedBootstrapOptions): Promise<HostedBootstrapResult>;
157
+ export interface TeardownOptions {
158
+ session: SandboxSession;
159
+ paths: HostedRuntimePaths;
160
+ bearer: string;
161
+ workspaceDir?: string;
162
+ /** Extra token values to sweep for (e.g. a minted repo token a test planted). */
163
+ extraTokens?: readonly string[];
164
+ }
165
+ /**
166
+ * Tear the run-scoped credential material down and PROVE no token residue
167
+ * remains (G3, extends ALI-973's `sweepForTokenResidue`). Removes the run dir
168
+ * (bearer + boot context + minted-token cache), unsets the repo-local credential
169
+ * helper, then sweeps .git/config, the git credential cache, env, argv, and
170
+ * ~/.git-credentials for the bearer, any extra tokens, and the token markers.
171
+ */
172
+ export declare function teardownHostedSandbox(opts: TeardownOptions): Promise<{
173
+ clean: boolean;
174
+ findings: HygieneFinding[];
175
+ }>;
176
+ export interface HostedSweepOptions {
177
+ bearer: string;
178
+ paths: HostedRuntimePaths;
179
+ workspaceDir: string;
180
+ extraTokens?: readonly string[];
181
+ }
182
+ /**
183
+ * Extend the ALI-973 sweep with hosted-specific probes: the run dir (bearer +
184
+ * cache) must be gone, and the standard leak surfaces (.git/config, ~/.git-
185
+ * credentials, credential cache, env, argv) must be free of the bearer.
186
+ */
187
+ export declare function sweepHostedResidue(session: SandboxSession, opts: HostedSweepOptions): Promise<HygieneFinding[]>;
188
+ //# sourceMappingURL=hosted-bootstrap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hosted-bootstrap.d.ts","sourceRoot":"","sources":["../src/hosted-bootstrap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAE3D,OAAO,EAAwB,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAiBhF,MAAM,MAAM,WAAW,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;AAIhF,MA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4
+ * This runs as its OWN process (spawned via `bun <this file>`), NOT in-process,
5
+ * for a specific reason: the local-sim `SandboxSession.exec` uses a blocking
6
+ * `spawnSync`, and the in-sandbox credential helper it runs makes a real HTTP
7
+ * call back to this broker. An in-process server can't answer that call while
8
+ * the test thread is blocked in `spawnSync` — so the broker must be a separate
9
+ * process with its own event loop.
10
+ *
11
+ * It implements exactly the two contracts the bootstrap depends on:
12
+ * - POST /api/cli/workspaces/:id/repo-token → {token, expiresAt, repo, mintId}
13
+ * - POST /api/cli/workbench-runs/:id/events → 201 (rejects reserved run_* 400)
14
+ * and it journals every accepted event / issued token to newline-delimited JSON
15
+ * files so the parent test can read them back. Config comes from env (below).
16
+ *
17
+ * Not shipped to end users — a test/rehearsal fixture only.
18
+ */
19
+ export interface BrokerConfig {
20
+ bearer: string;
21
+ repo: string;
22
+ /** Test-only exact Artifacts remote returned by the repo-token endpoint. */
23
+ artifactsRemote?: string;
24
+ /** Test-only expiry override for fail-closed helper rehearsals. */
25
+ artifactsExpiresAt?: string;
26
+ eventsFile?: string;
27
+ tokensFile?: string;
28
+ repoTokenStatus?: number;
29
+ eventsStatus?: number;
30
+ denyWrite?: boolean;
31
+ port?: number;
32
+ /**
33
+ * E2E mode: accept ANY non-empty Bearer (the full hosted flow uses a human
34
+ * bearer for session/agent-token mints and a DISTINCT agent bearer for
35
+ * run/events), and serve the full RunAPI + session + agent-token surface so
36
+ * `startHostedSession` can be driven end to end. Off by default so the
37
+ * bootstrap/credential-helper tests keep their strict single-bearer contract.
38
+ */
39
+ fullRunApi?: boolean;
40
+ /** E2E: the session id + branch the /sessions endpoint returns (so it matches
41
+ * a pre-seeded session branch on the local bare repo). */
42
+ sessionId?: string;
43
+ sessionBranch?: string;
44
+ }
45
+ export declare function readBrokerConfigFromEnv(env: NodeJS.ProcessEnv): BrokerConfig;
46
+ export declare function startBrokerServer(config: BrokerConfig): {
47
+ port: number;
48
+ stop: (force?: boolean) => void;
49
+ };
50
+ //# sourceMappingURL=hosted-broker-server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hosted-broker-server.d.ts","sourceRoot":"","sources":["../src/hosted-broker-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AA8BH,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,4EAA4E;IAC5E,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,mEAAmE;IACnE,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB;+DAC2D;IAC3D,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB;AAED,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,YAAY,CAgB5E;AASD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,YAAY,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,CAAC,KAAK,CAAC,EAAE,OAAO,KAAK,IAAI,CAAA;CAAE,CA6LzG"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Standalone authenticated smart-HTTP git server for the ALI-925 rehearsal.
3
+ *
4
+ * Runs as its OWN process (spawned via `bun <this file>`), for the same reason
5
+ * the fake broker does: the local-sim `SandboxSession.exec` blocks on a
6
+ * `spawnSync` git clone, and the in-sandbox credential helper that clone drives
7
+ * makes real HTTP calls out. A server sharing the test's event loop could not
8
+ * answer while that loop is blocked — so the git server must be its own process.
9
+ *
10
+ * It proves the integrated credential path end-to-end: it (a) requires HTTP Basic
11
+ * auth and rejects unauthenticated requests with 401 + `WWW-Authenticate`, forcing
12
+ * git to invoke the credential helper, and (b) on authenticated requests serves a
13
+ * real bare repo by shelling to `git http-backend` as CGI. Every Basic-auth
14
+ * password it receives is journaled to a file so the rehearsal can assert the
15
+ * password git presented equals the token the broker minted (git → helper →
16
+ * broker → token → authenticated clone).
17
+ *
18
+ * Not shipped to end users — a test/rehearsal fixture only.
19
+ */
20
+ export interface GitHttpConfig {
21
+ /** Absolute path to the bare repo (e.g. `<root>/workbench.git`). */
22
+ repoDir: string;
23
+ /** File the server appends every received `{ user, pass }` to (NDJSON). */
24
+ authLogFile?: string;
25
+ port?: number;
26
+ }
27
+ export declare function readGitHttpConfigFromEnv(env: NodeJS.ProcessEnv): GitHttpConfig;
28
+ /** The env keys the server reads (kept here so callers do not hand-roll them). */
29
+ export declare function gitHttpEnv(config: GitHttpConfig): Record<string, string>;
30
+ /** The clone path segment a client uses (the bare repo's basename). */
31
+ export declare function gitHttpRepoSegment(config: GitHttpConfig): string;
32
+ export declare function startGitHttpServer(config: GitHttpConfig): {
33
+ port: number;
34
+ stop: (force?: boolean) => void;
35
+ };
36
+ //# sourceMappingURL=hosted-git-http-server.d.ts.map