@testsprite/testsprite-cli 0.16.0 → 0.18.0

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 (206) hide show
  1. package/README.md +52 -147
  2. package/dist/commands/agent.d.ts +12 -4
  3. package/dist/commands/agent.js +48 -63
  4. package/dist/commands/auth.d.ts +6 -10
  5. package/dist/commands/auth.js +40 -56
  6. package/dist/commands/ci.d.ts +23 -100
  7. package/dist/commands/ci.js +293 -487
  8. package/dist/commands/conversation.d.ts +27 -0
  9. package/dist/commands/conversation.js +741 -0
  10. package/dist/commands/doctor.d.ts +5 -1
  11. package/dist/commands/doctor.js +129 -34
  12. package/dist/commands/init.d.ts +4 -45
  13. package/dist/commands/init.js +108 -66
  14. package/dist/commands/project-env.d.ts +62 -2
  15. package/dist/commands/project-env.js +434 -43
  16. package/dist/commands/project-sign-in.d.ts +0 -48
  17. package/dist/commands/project-sign-in.js +1 -229
  18. package/dist/commands/project.d.ts +19 -186
  19. package/dist/commands/project.js +108 -926
  20. package/dist/commands/result.d.ts +10 -0
  21. package/dist/commands/result.js +216 -0
  22. package/dist/commands/schedule.d.ts +0 -29
  23. package/dist/commands/schedule.js +28 -87
  24. package/dist/commands/test.d.ts +301 -1838
  25. package/dist/commands/test.js +1880 -13917
  26. package/dist/commands/testlist.d.ts +130 -5
  27. package/dist/commands/testlist.js +300 -342
  28. package/dist/commands/tunnel.d.ts +3 -3
  29. package/dist/commands/tunnel.js +23 -20
  30. package/dist/commands/usage.d.ts +12 -45
  31. package/dist/commands/usage.js +50 -131
  32. package/dist/index.js +191 -110
  33. package/dist/lib/agent-detect.js +9 -5
  34. package/dist/lib/agent-targets.d.ts +21 -2
  35. package/dist/lib/agent-targets.js +88 -11
  36. package/dist/lib/args.d.ts +13 -0
  37. package/dist/lib/args.js +49 -0
  38. package/dist/lib/basic-auth.d.ts +3 -0
  39. package/dist/lib/basic-auth.js +15 -0
  40. package/dist/lib/billing-refusal.js +4 -3
  41. package/dist/lib/ci-linkage.d.ts +4 -82
  42. package/dist/lib/ci-linkage.js +4 -157
  43. package/dist/lib/ci-run.js +1 -1
  44. package/dist/lib/client-factory.d.ts +12 -4
  45. package/dist/lib/client-factory.js +41 -30
  46. package/dist/lib/commit-signal.d.ts +65 -0
  47. package/dist/lib/commit-signal.js +305 -0
  48. package/dist/lib/concurrency-limiter.d.ts +6 -0
  49. package/dist/lib/concurrency-limiter.js +29 -0
  50. package/dist/lib/config.js +10 -5
  51. package/dist/lib/conflict-reason.d.ts +9 -3
  52. package/dist/lib/conflict-reason.js +6 -3
  53. package/dist/lib/conversation/answers.d.ts +9 -0
  54. package/dist/lib/conversation/answers.js +49 -0
  55. package/dist/lib/conversation/api.d.ts +75 -0
  56. package/dist/lib/conversation/api.js +151 -0
  57. package/dist/lib/conversation/change.d.ts +31 -0
  58. package/dist/lib/conversation/change.js +124 -0
  59. package/dist/lib/conversation/context.d.ts +29 -0
  60. package/dist/lib/conversation/context.js +82 -0
  61. package/dist/lib/conversation/environment.d.ts +16 -0
  62. package/dist/lib/conversation/environment.js +21 -0
  63. package/dist/lib/conversation/follow.d.ts +24 -0
  64. package/dist/lib/conversation/follow.js +42 -0
  65. package/dist/lib/conversation/render.d.ts +33 -0
  66. package/dist/lib/conversation/render.js +318 -0
  67. package/dist/lib/conversation/title.d.ts +2 -0
  68. package/dist/lib/conversation/title.js +18 -0
  69. package/dist/lib/conversation/types.d.ts +158 -0
  70. package/dist/lib/conversation/types.js +6 -0
  71. package/dist/lib/credentials.js +67 -11
  72. package/dist/lib/cron.d.ts +1 -1
  73. package/dist/lib/cron.js +2 -2
  74. package/dist/lib/dispatch-stop.d.ts +20 -0
  75. package/dist/lib/dispatch-stop.js +30 -0
  76. package/dist/lib/download.d.ts +100 -0
  77. package/dist/lib/download.js +408 -0
  78. package/dist/lib/dry-run/fetch.d.ts +10 -0
  79. package/dist/lib/dry-run/fetch.js +20 -0
  80. package/dist/lib/dry-run/samples.d.ts +6 -34
  81. package/dist/lib/dry-run/samples.js +375 -747
  82. package/dist/lib/environment-tunnel.d.ts +19 -30
  83. package/dist/lib/environment-tunnel.js +168 -202
  84. package/dist/lib/errors.d.ts +20 -4
  85. package/dist/lib/errors.js +36 -16
  86. package/dist/lib/facade.d.ts +7 -29
  87. package/dist/lib/facade.js +7 -36
  88. package/dist/lib/failing-fe-resolver.d.ts +13 -58
  89. package/dist/lib/failing-fe-resolver.js +47 -132
  90. package/dist/lib/first-suite-hint.d.ts +20 -30
  91. package/dist/lib/first-suite-hint.js +57 -72
  92. package/dist/lib/gh-output.d.ts +76 -21
  93. package/dist/lib/gh-output.js +171 -90
  94. package/dist/lib/git-utils.d.ts +56 -0
  95. package/dist/lib/git-utils.js +212 -0
  96. package/dist/lib/github-context.d.ts +2 -0
  97. package/dist/lib/github-context.js +40 -8
  98. package/dist/lib/history-retention.d.ts +6 -2
  99. package/dist/lib/history-retention.js +10 -7
  100. package/dist/lib/http.d.ts +58 -134
  101. package/dist/lib/http.js +354 -291
  102. package/dist/lib/interrupt.d.ts +14 -8
  103. package/dist/lib/interrupt.js +28 -10
  104. package/dist/lib/junit-report.d.ts +57 -4
  105. package/dist/lib/junit-report.js +202 -32
  106. package/dist/lib/local-target.d.ts +8 -7
  107. package/dist/lib/local-target.js +14 -13
  108. package/dist/lib/output.d.ts +2 -41
  109. package/dist/lib/output.js +13 -51
  110. package/dist/lib/pagination.d.ts +2 -5
  111. package/dist/lib/pagination.js +2 -5
  112. package/dist/lib/presigned-url.d.ts +22 -0
  113. package/dist/lib/presigned-url.js +90 -0
  114. package/dist/lib/prompt.js +36 -2
  115. package/dist/lib/proxy.js +2 -1
  116. package/dist/lib/redact.d.ts +2 -2
  117. package/dist/lib/redact.js +3 -4
  118. package/dist/lib/removed-commands.d.ts +18 -0
  119. package/dist/lib/removed-commands.js +170 -0
  120. package/dist/lib/render-error.d.ts +31 -6
  121. package/dist/lib/render-error.js +88 -25
  122. package/dist/lib/response-schemas.d.ts +38 -30
  123. package/dist/lib/response-schemas.js +207 -207
  124. package/dist/lib/result/api.d.ts +24 -0
  125. package/dist/lib/result/api.js +28 -0
  126. package/dist/lib/result/evidence.d.ts +73 -0
  127. package/dist/lib/result/evidence.js +422 -0
  128. package/dist/lib/result/render.d.ts +20 -0
  129. package/dist/lib/result/render.js +194 -0
  130. package/dist/lib/result/types.d.ts +122 -0
  131. package/dist/lib/result/types.js +19 -0
  132. package/dist/lib/run-output.d.ts +275 -0
  133. package/dist/lib/run-output.js +227 -0
  134. package/dist/lib/run-render.d.ts +101 -0
  135. package/dist/lib/run-render.js +183 -0
  136. package/dist/lib/run-wait.d.ts +192 -0
  137. package/dist/lib/run-wait.js +452 -0
  138. package/dist/lib/runs.types.d.ts +118 -367
  139. package/dist/lib/runs.types.js +0 -14
  140. package/dist/lib/secret-file.d.ts +1 -1
  141. package/dist/lib/secret-file.js +11 -2
  142. package/dist/lib/skill-nudge.d.ts +7 -27
  143. package/dist/lib/skill-nudge.js +9 -37
  144. package/dist/lib/target-path.d.ts +15 -0
  145. package/dist/lib/target-path.js +35 -0
  146. package/dist/lib/target-url-advisory.d.ts +19 -0
  147. package/dist/lib/target-url-advisory.js +31 -0
  148. package/dist/lib/target-url-preflight.d.ts +9 -0
  149. package/dist/lib/target-url-preflight.js +214 -106
  150. package/dist/lib/target-url.d.ts +8 -8
  151. package/dist/lib/target-url.js +14 -24
  152. package/dist/lib/telemetry.d.ts +35 -15
  153. package/dist/lib/telemetry.js +38 -9
  154. package/dist/lib/terminal-text.d.ts +41 -0
  155. package/dist/lib/terminal-text.js +127 -0
  156. package/dist/lib/testlist.types.d.ts +16 -8
  157. package/dist/lib/testlist.types.js +1 -1
  158. package/dist/lib/text-equality.d.ts +2 -0
  159. package/dist/lib/text-equality.js +5 -0
  160. package/dist/lib/text-file.d.ts +16 -0
  161. package/dist/lib/text-file.js +41 -0
  162. package/dist/lib/text-table.d.ts +46 -0
  163. package/dist/lib/text-table.js +72 -4
  164. package/dist/lib/ticker.d.ts +9 -2
  165. package/dist/lib/ticker.js +16 -3
  166. package/dist/lib/transport-failure.d.ts +22 -0
  167. package/dist/lib/transport-failure.js +126 -0
  168. package/dist/lib/tunnel-session.d.ts +8 -2
  169. package/dist/lib/tunnel-session.js +24 -11
  170. package/dist/lib/update-check.js +3 -2
  171. package/dist/lib/url-template.d.ts +43 -0
  172. package/dist/lib/url-template.js +151 -0
  173. package/dist/lib/validate.d.ts +0 -64
  174. package/dist/lib/validate.js +2 -131
  175. package/dist/lib/version-notice.js +4 -3
  176. package/dist/lib/wait-exit.d.ts +37 -2
  177. package/dist/lib/wait-exit.js +88 -30
  178. package/dist/lib/workspace-status.js +10 -2
  179. package/dist/version.d.ts +1 -1
  180. package/dist/version.js +1 -1
  181. package/package.json +2 -3
  182. package/skills/testsprite-ci.skill.md +52 -23
  183. package/skills/testsprite-onboard.skill.md +70 -153
  184. package/skills/testsprite-verify.codex.md +54 -58
  185. package/skills/testsprite-verify.skill.md +189 -358
  186. package/dist/lib/browser.d.ts +0 -6
  187. package/dist/lib/browser.js +0 -54
  188. package/dist/lib/bundle.d.ts +0 -234
  189. package/dist/lib/bundle.js +0 -781
  190. package/dist/lib/deprecate.d.ts +0 -32
  191. package/dist/lib/deprecate.js +0 -39
  192. package/dist/lib/flaky.d.ts +0 -91
  193. package/dist/lib/flaky.js +0 -71
  194. package/dist/lib/plan-poll.d.ts +0 -171
  195. package/dist/lib/plan-poll.js +0 -441
  196. package/dist/lib/plans.types.d.ts +0 -130
  197. package/dist/lib/plans.types.js +0 -31
  198. package/dist/lib/poll.d.ts +0 -100
  199. package/dist/lib/poll.js +0 -290
  200. package/dist/lib/rate-throttle.d.ts +0 -49
  201. package/dist/lib/rate-throttle.js +0 -75
  202. package/dist/lib/run-progress.d.ts +0 -41
  203. package/dist/lib/run-progress.js +0 -56
  204. package/dist/lib/v3-advisory.d.ts +0 -55
  205. package/dist/lib/v3-advisory.js +0 -74
  206. package/schemas/plan.schema.json +0 -61
@@ -1,6 +0,0 @@
1
- export interface OpenInBrowserDeps {
2
- platform?: NodeJS.Platform;
3
- /** Process spawner taking an argv array. Defaults to a detached spawn. */
4
- exec?: (command: string, args: readonly string[]) => void;
5
- }
6
- export declare function openInBrowser(url: string, deps?: OpenInBrowserDeps): void;
@@ -1,54 +0,0 @@
1
- /**
2
- * Cross-platform "open this URL in the default browser" helper for
3
- * `test open` (issue #121). Spawns the platform opener with an argv array
4
- * (never a shell string) so a URL can never be shell-injected, and refuses
5
- * anything that is not http(s) before any process is spawned.
6
- *
7
- * Platform openers:
8
- * darwin open <url>
9
- * win32 rundll32 url.dll,FileProtocolHandler <url> (avoids `cmd /c start`,
10
- * whose re-parsing would mangle `&` and other metachars in the URL)
11
- * other xdg-open <url>
12
- *
13
- * The child is detached and unref'd so the CLI exits immediately; failures
14
- * are the caller's to surface (it already printed the URL as the fallback).
15
- */
16
- import { spawn } from 'node:child_process';
17
- import { localValidationError } from './errors.js';
18
- export function openInBrowser(url, deps = {}) {
19
- let parsed;
20
- try {
21
- parsed = new URL(url);
22
- }
23
- catch {
24
- throw localValidationError('url', 'must be a valid http(s) URL', undefined, 'field');
25
- }
26
- if (parsed.protocol !== 'https:' && parsed.protocol !== 'http:') {
27
- // User-input error, not an internal failure: classify as VALIDATION_ERROR
28
- // so it maps to exit 5 (like every other bad-argument path), not exit 1.
29
- throw localValidationError('url', `must be an http(s) URL (got ${parsed.protocol})`, undefined, 'field');
30
- }
31
- const platform = deps.platform ?? process.platform;
32
- const exec = deps.exec ??
33
- ((command, args) => {
34
- const child = spawn(command, [...args], { detached: true, stdio: 'ignore' });
35
- // spawn() reports a missing binary (ENOENT) ASYNCHRONOUSLY on the child,
36
- // so the caller's try/catch cannot see it — and an unhandled 'error'
37
- // event would crash the whole CLI. The URL is already on stdout, so
38
- // degrade to the same manual-open hint the sync failure path prints.
39
- child.on('error', () => {
40
- process.stderr.write('could not launch a browser; open the URL above manually (or use --no-browser)\n');
41
- });
42
- child.unref();
43
- });
44
- if (platform === 'darwin') {
45
- exec('open', [url]);
46
- return;
47
- }
48
- if (platform === 'win32') {
49
- exec('rundll32', ['url.dll,FileProtocolHandler', url]);
50
- return;
51
- }
52
- exec('xdg-open', [url]);
53
- }
54
- //# sourceMappingURL=browser.js.map
@@ -1,234 +0,0 @@
1
- /**
2
- * §6.7 FailureContext bundle writer.
3
- *
4
- * Given a `FailureContext` JSON envelope (returned by
5
- * `GET /api/cli/v1/tests/{id}/failure`), `writeBundle` dereferences
6
- * every presigned URL into local bytes and writes the §7 disk layout
7
- * under `<dir>`. The contract is "agent-safe" — every guarantee in
8
- * the FailureContext spec §3 + §7 is enforced here:
9
- *
10
- * 1. **Atomic** — every artifact in the bundle came from one
11
- * `snapshotId`. We refuse a forged response where
12
- * `bundle.snapshotId !== result.snapshotId` or steps disagree on
13
- * `runIdIfAvailable` (`assertContextIntegrity`).
14
- * 2. **Atomic on disk** — we write to `<dir>/.tmp/...` first and
15
- * `rename()` each file into place. `meta.json` is renamed last so
16
- * the presence of `<dir>/meta.json` ⇔ "bundle is complete and
17
- * self-consistent".
18
- * 3. **`.partial` on failure** — any download or fs failure leaves
19
- * a `<dir>/.partial` marker (with `requestId`, error summary,
20
- * snapshotId) and exits non-zero. Agents check `.partial` before
21
- * consuming.
22
- * 4. **Bounded budget** — the writer streams URL → file (no full-
23
- * buffer), so a 200MB video doesn't sit in V8's heap.
24
- *
25
- * What this module deliberately does NOT do:
26
- *
27
- * - Re-derive `snapshotId`. The CLI trusts whatever the facade
28
- * returned. A snapshotId mismatch is a backend bug and we surface
29
- * it as a typed validation error rather than try to "heal" it.
30
- * - Generate `summary` strings. Those are server-side per §6.1 of
31
- * the spec; the CLI emits whatever the facade produced.
32
- * - Resume after a partial bundle. M2 always re-fetches from scratch
33
- * when the agent re-runs. M3 may add resume.
34
- */
35
- import type { CliFailureContext } from '../commands/test.js';
36
- import { type ShutdownHandle } from './interrupt.js';
37
- import type { FetchImpl } from './http.js';
38
- /** Schema version stamped into `meta.json`. Bumps with the contract. */
39
- export declare const BUNDLE_SCHEMA_VERSION: "cli-v1";
40
- /** Max fetch attempts for each presigned URL (initial + retries). */
41
- export declare const STREAM_URL_MAX_RETRIES = 3;
42
- /** Delay between retries for transient transport failures (ms). */
43
- export declare const STREAM_URL_RETRY_DELAY_MS = 1000;
44
- /** Default radius around the failed step when `--failed-only` is set. */
45
- export declare const FAILED_ONLY_RADIUS = 1;
46
- /**
47
- * Sentinel reasons emitted on the `details.reason` field when the
48
- * integrity check throws. Exported so callers can branch on a typed
49
- * literal rather than parsing the message text.
50
- */
51
- export type BundleIntegrityReason = 'snapshot_id_mismatch' | 'run_id_mismatch' | 'code_version_mismatch' | 'evidence_missing_failed_step' | 'run_id_missing' | 'test_id_mismatch';
52
- /**
53
- * Options for {@link assertContextIntegrity}.
54
- */
55
- export interface AssertContextIntegrityOptions {
56
- /**
57
- * When `true`, the run-scoped path requires `ctx.meta.runId` (i.e.,
58
- * `ctx.result.runIdIfAvailable`) to be present. M2 callers pass
59
- * `{}` (or omit entirely) to preserve the opt-in behavior.
60
- */
61
- requireRunId?: boolean;
62
- }
63
- /**
64
- * Identity card written as `<dir>/meta.json`. Agents read this first —
65
- * if any other file's `snapshotId` disagrees, the bundle is corrupt
66
- * and they must refuse to act.
67
- *
68
- * `runIdIfAvailable` and `codeVersion` are surfaced from `result`
69
- * (already shared across every step in a valid bundle, so the meta
70
- * carries the bundle-wide value rather than the per-step one).
71
- */
72
- export interface BundleMeta {
73
- schemaVersion: typeof BUNDLE_SCHEMA_VERSION;
74
- snapshotId: string;
75
- testId: string;
76
- projectId: string;
77
- codeVersion: string | null;
78
- runIdIfAvailable: string | null;
79
- targetUrl: string | null;
80
- failedStepIndex: number | null;
81
- failureKind: string | null;
82
- /** When the backend captured the snapshot. Mirrors `result.finishedAt`. */
83
- capturedAt: string | null;
84
- /** When the CLI fetched the bundle (this run's clock). */
85
- fetchedAt: string;
86
- }
87
- export interface WriteBundleOptions {
88
- /** Absolute or relative target directory. */
89
- dir: string;
90
- /** Apply the §7.4 `--failed-only` filter (failed step ± 1) before downloading. */
91
- failedOnly: boolean;
92
- /** Custom fetch impl for tests. Defaults to global `fetch`. */
93
- fetchImpl?: FetchImpl;
94
- shutdownSignal?: AbortSignal;
95
- shutdown?: Pick<ShutdownHandle, 'runCriticalOperation'>;
96
- /** Server requestId to embed in `.partial` on failure. */
97
- requestId?: string;
98
- }
99
- export interface WriteBundleResult {
100
- meta: BundleMeta;
101
- /** Absolute path of the bundle directory. */
102
- dir: string;
103
- /** Files actually written, relative to `dir`. */
104
- files: string[];
105
- }
106
- /**
107
- * Compose the FailureContext spec §3 invariants into a single
108
- * trip wire. Throwing here is the agent-safety gate — we trust the
109
- * facade for the data, not for self-consistency.
110
- *
111
- * - Bundle-level `snapshotId` MUST equal `result.snapshotId`.
112
- * - All steps in the bundle MUST share `runIdIfAvailable` (or all
113
- * be `null`). Mixed values means a stitched read leaked through.
114
- *
115
- * The error envelope is `VALIDATION_ERROR` rather than `INTERNAL`
116
- * because the operator-facing remediation is "retry once" (the
117
- * snapshot may genuinely have been mid-mutation; a fresh fetch will
118
- * succeed). `requestId` is the original request id so support can
119
- * trace the bad envelope back.
120
- */
121
- export declare function assertContextIntegrity(ctx: CliFailureContext, requestId: string, opts?: AssertContextIntegrityOptions): void;
122
- /**
123
- * Apply the `--failed-only` filter — drop neighbor steps and their
124
- * evidence, keep the failed step. Idempotent: returns `ctx` unchanged
125
- * when `failedStepIndex` is null (no step-level diagnosis to filter)
126
- * or when the existing window already matches.
127
- */
128
- export declare function applyFailedOnly(ctx: CliFailureContext): CliFailureContext;
129
- /**
130
- * Resolve the user-supplied `--out` path into an absolute directory.
131
- * Empty strings are rejected with `VALIDATION_ERROR` for consistency
132
- * with `test code get --out`. We do NOT pre-create the directory or
133
- * its `.tmp` child — `writeBundle` mkdir's after the integrity check
134
- * passes so a forged response never modifies the operator's filesystem.
135
- */
136
- export declare function resolveBundleDir(rawPath: string): string;
137
- /**
138
- * Pick a code-file extension for `<dir>/code.<ext>` based on the §6.3
139
- * `language` + `framework`. The extension matches the test code's
140
- * language, not the user-app code under test.
141
- */
142
- export declare function pickCodeExtension(language: string, framework: string): string;
143
- /**
144
- * Pick the on-disk extension for `<dir>/video.<ext>` from the actual
145
- * `result.videoUrl`, instead of hardcoding `mp4` (the
146
- * recording is sometimes a `.webm` container; saving it under a `video.mp4`
147
- * name misleads strict-extension consumers). Falls back to `mp4` when the
148
- * URL is malformed or its extension isn't a recognized container, so a
149
- * response-controlled field can never smuggle an arbitrary suffix onto disk.
150
- */
151
- export declare function pickVideoExtension(url: string): string;
152
- /**
153
- * Step filename per §7.2 — 1-based index, zero-padded to two digits
154
- * for indices ≤ 99, three digits for ≥ 100. `${stepIndex}-snapshot.html`
155
- * etc. Never truncates: an agent constructing the path with
156
- * `padStart(2, '0')` works for the common case, and step ≥ 100 widens
157
- * naturally without breaking existing fixtures.
158
- */
159
- export declare function stepFilenamePrefix(stepIndex: number): string;
160
- /**
161
- * Refuse a composed artifact path that escapes `baseDir`. Step filenames are
162
- * built from response-controlled fields, so this is the final containment
163
- * check before any write. Returns the validated absolute path.
164
- */
165
- export declare function assertNoEscape(baseDir: string, segment: string): string;
166
- /**
167
- * Build the §7.1 meta.json given a context. Pure function, no I/O —
168
- * lets specs assert the meta shape without touching disk.
169
- */
170
- export declare function buildMeta(ctx: CliFailureContext, fetchedAt?: Date): BundleMeta;
171
- /**
172
- * Top-level bundle writer. The order matters:
173
- *
174
- * 1. `assertContextIntegrity` — fail closed on a forged envelope.
175
- * 2. `applyFailedOnly` — narrow before download (saves bytes).
176
- * 3. `mkdir <dir>/.tmp/` — fresh; clean any stale temp.
177
- * 4. `writeFile result.json / failure.json / code.<ext>` — local data.
178
- * 5. `fetch + stream` for `video.<ext>` (when set; extension matches the
179
- * actual recording container) and per-step snapshot/screenshot/
180
- * evidence-json files.
181
- * 6. `writeFile meta.json` LAST — its presence means "bundle complete".
182
- * 7. `rename .tmp/<file> -> <file>` for every file. Last rename
183
- * makes meta.json visible.
184
- *
185
- * On any failure between (3) and (6), write a `<dir>/.partial` marker
186
- * and re-throw so `index.ts` produces a typed exit code (UNAVAILABLE
187
- * → 10 by default; the original ApiError is preserved when applicable).
188
- */
189
- export declare function writeBundle(ctx: CliFailureContext, options: WriteBundleOptions): Promise<WriteBundleResult>;
190
- /**
191
- * Whether a top-level directory entry belongs to the bundle format —
192
- * i.e. something a prior `writeBundle` could have produced and this
193
- * commit is therefore allowed to clean up. `code.<ext>` and `video.<ext>`
194
- * are matched by pattern (not the current run's extension) so a stale
195
- * `code.py` or `video.webm` is still swept when the new bundle writes
196
- * `code.ts` / `video.mp4` (or no video at all). Everything else in the
197
- * directory is the user's and must never be deleted (`--out` can point at
198
- * a pre-existing, populated directory).
199
- */
200
- export declare function isBundleOwnedEntry(entry: string): boolean;
201
- /**
202
- * Atomically install the complete bundle staged in `tmpDir` into `dir`.
203
- *
204
- * Compatible with the #162 data-loss guard: only `isBundleOwnedEntry`
205
- * names are moved aside or replaced — foreign files in `--out` survive.
206
- *
207
- * Re-commit safety: bundle-owned entries are renamed to a sibling
208
- * aside directory before the new artifacts land. The prior `meta.json`
209
- * is moved aside first (§3/§7.3 — no meta ⇒ refuse to consume) so a
210
- * concurrent reader never sees meta pointing at steps already gone.
211
- * The new `meta.json` is installed last. On failure, aside entries are
212
- * restored so a failed re-commit never leaves the directory unusable.
213
- */
214
- export declare function commitBundle(tmpDir: string, dir: string, files: ReadonlyArray<string>): Promise<void>;
215
- /**
216
- * Stream a presigned URL into a file with bounded retry on transport
217
- * failures. 4xx (presigned URL expired or unauthorized) is NOT
218
- * retried — the URL won't recover on its own; an upstream re-fetch
219
- * is the only fix. Maps to `UNAVAILABLE` so `index.ts` exits 10.
220
- *
221
- * Streaming uses `pipeline` to honor backpressure: a slow disk pauses
222
- * the upstream reader rather than buffering chunks in V8 heap. This
223
- * matters for video files (multi-MB) and for very large HTML
224
- * snapshots.
225
- *
226
- * Transport failures (network reset, DNS blip, mid-stream EOF) are
227
- * retried up to STREAM_URL_MAX_RETRIES times with a fixed delay.
228
- * Presigned URLs are valid for 15 minutes, so retries are safe.
229
- */
230
- export declare function streamUrlToFile(url: string, filePath: string, fetchImpl: FetchImpl, deps?: {
231
- sleep?: (ms: number) => Promise<void>;
232
- shutdownSignal?: AbortSignal;
233
- shutdown?: Pick<ShutdownHandle, 'runCriticalOperation'>;
234
- }): Promise<void>;