@snappedly-tools/shipyard 0.8.0 → 0.9.1

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 (45) hide show
  1. package/README.md +24 -14
  2. package/dist/MountConfig-K5ILnfht.d.ts +26 -0
  3. package/dist/{MountConfig-BHnKnA4h.d.ts → SandboxProvider-oUAwYlWm.d.ts} +1 -26
  4. package/dist/{chunk-L6PX5QTU.js → chunk-57EEKW3R.js} +57 -55
  5. package/dist/chunk-57EEKW3R.js.map +1 -0
  6. package/dist/{chunk-JI3HDDMS.js → chunk-HXSZM52J.js} +3 -3
  7. package/dist/{chunk-JI3HDDMS.js.map → chunk-HXSZM52J.js.map} +1 -1
  8. package/dist/{chunk-44I2BL6E.js → chunk-JZUBT4WG.js} +20 -4
  9. package/dist/chunk-JZUBT4WG.js.map +1 -0
  10. package/dist/chunk-NQRFVKCU.js +1840 -0
  11. package/dist/chunk-NQRFVKCU.js.map +1 -0
  12. package/dist/chunk-Z5C4LHVP.js +137 -0
  13. package/dist/chunk-Z5C4LHVP.js.map +1 -0
  14. package/dist/createSandbox-DmbnWAZv.d.ts +739 -0
  15. package/dist/index.d.ts +7 -2534
  16. package/dist/index.js +216 -7269
  17. package/dist/index.js.map +1 -1
  18. package/dist/integrations/github.d.ts +52 -0
  19. package/dist/integrations/github.js +1049 -0
  20. package/dist/integrations/github.js.map +1 -0
  21. package/dist/integrations/releases.d.ts +136 -0
  22. package/dist/integrations/releases.js +500 -0
  23. package/dist/integrations/releases.js.map +1 -0
  24. package/dist/main.js +641 -383
  25. package/dist/main.js.map +1 -1
  26. package/dist/publication-BPoy_M9M.d.ts +1200 -0
  27. package/dist/sandboxes/docker.d.ts +2 -1
  28. package/dist/sandboxes/docker.js +2 -2
  29. package/dist/templates/parallel-planner/main.mts +11 -7
  30. package/dist/templates/parallel-planner/setup.sh +1 -0
  31. package/dist/templates/parallel-planner-with-review/main.mts +11 -7
  32. package/dist/templates/parallel-planner-with-review/setup.sh +1 -0
  33. package/dist/templates/sequential-reviewer/main.mts +7 -3
  34. package/dist/templates/sequential-reviewer/setup.sh +1 -0
  35. package/dist/templates/shared/setup.sh +1 -0
  36. package/dist/templates/simple-loop/main.mts +7 -3
  37. package/dist/templates/simple-loop/setup.sh +1 -0
  38. package/dist/workflow/coordinator/migrations/002_workflow_phase_records.sql +11 -0
  39. package/dist/workflow/coordinator/migrations/003_phase_record_schema_version.sql +6 -0
  40. package/dist/workflow.d.ts +472 -0
  41. package/dist/workflow.js +4345 -0
  42. package/dist/workflow.js.map +1 -0
  43. package/package.json +13 -1
  44. package/dist/chunk-44I2BL6E.js.map +0 -1
  45. package/dist/chunk-L6PX5QTU.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,559 +1,9 @@
1
- import { S as SessionTransferHandle, a as SandboxProvider, B as BranchStrategy, E as ExecResult, b as MergeToHeadBranchStrategy, N as NamedBranchStrategy } from './MountConfig-BHnKnA4h.js';
2
- export { c as InteractiveExecOptions, d as IsolatedCreateOptions, e as IsolatedSandboxHandle, I as IsolatedSandboxProvider, f as IsolatedSandboxProviderConfig, M as MountConfig, g as createIsolatedSandboxProvider } from './MountConfig-BHnKnA4h.js';
3
- import { StandardSchemaV1 } from '@standard-schema/spec';
4
-
5
- /** Reasoning efforts accepted by the Codex CLI. */
6
- declare const CODEX_REASONING_EFFORTS: readonly ["low", "medium", "high", "xhigh", "max"];
7
- type CodexReasoningEffort = (typeof CODEX_REASONING_EFFORTS)[number];
8
- /** A model identifier plus the reasoning policy used for that model role. */
9
- interface CodexModelConfig {
10
- readonly model: string;
11
- readonly effort: CodexReasoningEffort;
12
- }
13
- declare const CODEX_MODELS: {
14
- readonly routine: {
15
- readonly model: string;
16
- readonly effort: "low" | "medium" | "high" | "xhigh" | "max";
17
- };
18
- readonly strong: {
19
- readonly model: string;
20
- readonly effort: "low" | "medium" | "high" | "xhigh" | "max";
21
- };
22
- };
23
-
24
- type ParsedStreamEvent = {
25
- type: "text";
26
- text: string;
27
- } | {
28
- type: "result";
29
- result: string;
30
- } | {
31
- type: "tool_call";
32
- name: string;
33
- args: string;
34
- } | {
35
- type: "session_id";
36
- sessionId: string;
37
- } | {
38
- type: "usage";
39
- usage: IterationUsage;
40
- };
41
- /** Options passed to buildPrintCommand and buildInteractiveArgs. */
42
- interface AgentCommandOptions {
43
- readonly prompt: string;
44
- readonly dangerouslySkipPermissions: boolean;
45
- /** Tools the controlled phase is permitted to invoke. */
46
- readonly toolAllowlist?: readonly string[];
47
- /** When set, the agent should resume the given session ID instead of starting fresh. */
48
- readonly resumeSession?: string;
49
- /**
50
- * When true alongside `resumeSession`, the agent should fork the session
51
- * instead of mutating it — Claude's `--fork-session`, Codex's
52
- * `codex exec fork`. The parent session JSONL is left intact and the agent
53
- * writes a new session under a fresh id.
54
- */
55
- readonly forkSession?: boolean;
56
- }
57
- /** Return type of buildPrintCommand — command string plus optional stdin content.
58
- * When `stdin` is set, the sandbox pipes it to the child process's stdin
59
- * instead of inlining the prompt in argv, avoiding the Linux 128 KB per-arg limit. */
60
- interface PrintCommand {
61
- readonly command: string;
62
- readonly stdin?: string;
63
- }
64
- /** Per-iteration token usage snapshot extracted from the agent session. */
65
- interface IterationUsage {
66
- readonly inputTokens: number;
67
- readonly cacheCreationInputTokens: number;
68
- readonly cacheReadInputTokens: number;
69
- readonly outputTokens: number;
70
- }
71
- interface AgentSessionStorage {
72
- /** Transfer a session JSONL from the sandbox into the host store. */
73
- captureToHost(args: {
74
- hostCwd: string;
75
- sandboxCwd: string;
76
- sessionId: string;
77
- handle: SessionTransferHandle;
78
- }): Promise<void>;
79
- /** Transfer a session JSONL from the host store into the sandbox. */
80
- resumeIntoSandbox(args: {
81
- hostCwd: string;
82
- sandboxCwd: string;
83
- sessionId: string;
84
- handle: SessionTransferHandle;
85
- }): Promise<void>;
86
- /** Read a captured session JSONL from the host store. Returns undefined when absent. */
87
- readHostSession(cwd: string, sessionId: string): Promise<string | undefined>;
88
- /** Whether a session with the given id exists in the host store keyed on cwd. */
89
- existsOnHost(cwd: string, sessionId: string): Promise<boolean>;
90
- /** Absolute host path where a session would be stored (for not-found error messages). */
91
- hostSessionFilePath(cwd: string, sessionId: string): string | undefined;
92
- }
93
- interface AgentProvider {
94
- readonly name: string;
95
- /** Environment variables injected by this agent provider. Merged at launch time with env resolver and sandbox provider env. */
96
- readonly env: Record<string, string>;
97
- /** Set only when this provider enforces `AgentCommandOptions.toolAllowlist`. */
98
- readonly supportsToolAllowlist?: boolean;
99
- /** When true, session capture is enabled for this provider. Default: true for file-backed providers. */
100
- readonly captureSessions: boolean;
101
- /** Provider-owned storage and transfer behavior for resumable agent sessions. */
102
- readonly sessionStorage?: AgentSessionStorage;
103
- buildPrintCommand(options: AgentCommandOptions): PrintCommand;
104
- buildInteractiveArgs?(options: AgentCommandOptions): string[];
105
- parseStreamLine(line: string): ParsedStreamEvent[];
106
- /** Parse token usage from the captured session JSONL content. Only implemented by Claude Code. */
107
- parseSessionUsage?(content: string): IterationUsage | undefined;
108
- }
109
- /** Options for the codex agent provider. */
110
- interface CodexOptions {
111
- /** Set to `null` to use the provider default instead of a configured role effort. */
112
- readonly effort?: CodexReasoningEffort | null;
113
- /** Environment variables injected by this agent provider. */
114
- readonly env?: Record<string, string>;
115
- /** When false, session capture is disabled. Default: true. */
116
- readonly captureSessions?: boolean;
117
- /** Override Codex session directories for tests or non-standard installs. */
118
- readonly sessionStorage?: {
119
- readonly hostSessionsDir?: string;
120
- readonly sandboxSessionsDir?: string;
121
- };
122
- /**
123
- * Maps to Codex's `approvals_reviewer` config key (set via
124
- * `-c approvals_reviewer="<value>"`). When set to `"auto_review"`, the
125
- * provider swaps the default `--dangerously-bypass-approvals-and-sandbox`
126
- * for an interactive approval policy (`-a on-request`) and Codex's most
127
- * permissive sandbox (`-s danger-full-access`) — auto-review needs
128
- * something to review, and the safety boundary is the reviewer agent
129
- * rather than the filesystem sandbox.
130
- */
131
- readonly approvalsReviewer?: "user" | "auto_review";
132
- }
133
- declare const codex: (model: string | CodexModelConfig, options?: CodexOptions) => AgentProvider & {
134
- readonly sessionStorage: AgentSessionStorage;
135
- };
136
- interface ClaudeCodeOptions {
137
- /** Set to `null` to leave effort selection to the provider. */
138
- readonly effort?: "low" | "medium" | "high" | "xhigh" | "max" | null;
139
- /** Environment variables injected by this agent provider. */
140
- readonly env?: Record<string, string>;
141
- /** When false, session capture is disabled. Default: true. */
142
- readonly captureSessions?: boolean;
143
- /** Override Claude session directories for tests or non-standard installs. */
144
- readonly sessionStorage?: {
145
- readonly hostProjectsDir?: string;
146
- readonly sandboxProjectsDir?: string;
147
- };
148
- /**
149
- * Maps directly to Claude's `--permission-mode` flag. When set, replaces the
150
- * default `--dangerously-skip-permissions` Shipyard passes on AFK runs —
151
- * the two flags are mutually exclusive on Claude's CLI. Use `"auto"` for
152
- * AI-mediated per-tool approve/deny on unsandboxed host runs.
153
- */
154
- readonly permissionMode?: "default" | "acceptEdits" | "plan" | "auto" | "dontAsk" | "bypassPermissions";
155
- }
156
- declare const claudeCode: (model: string, options?: ClaudeCodeOptions) => AgentProvider & {
157
- readonly sessionStorage: AgentSessionStorage;
158
- };
159
-
160
- /**
161
- * A single event in the agent's output stream, surfaced to callers of `run()`
162
- * so they can forward it to their own observability system.
163
- *
164
- * Emitted only in log-to-file mode when an `onAgentStreamEvent` callback is
165
- * provided via `logging`. See `run()`.
166
- *
167
- * The `"raw"` variant carries every stdout line the agent emits, verbatim and
168
- * before parsing — including lines that the provider's stream parser would
169
- * otherwise drop (e.g. tool-use blocks for unrecognised tools). Intended for
170
- * debugging when the typed `"text"` / `"toolCall"` events don't surface
171
- * enough detail.
172
- */
173
- type AgentStreamEvent = {
174
- readonly type: "text";
175
- readonly message: string;
176
- readonly iteration: number;
177
- readonly timestamp: Date;
178
- } | {
179
- readonly type: "toolCall";
180
- readonly name: string;
181
- readonly formattedArgs: string;
182
- readonly iteration: number;
183
- readonly timestamp: Date;
184
- } | {
185
- readonly type: "raw";
186
- readonly line: string;
187
- readonly iteration: number;
188
- readonly timestamp: Date;
189
- };
190
-
191
- type SandboxHooks = {
192
- readonly host?: {
193
- readonly onWorktreeReady?: ReadonlyArray<{
194
- readonly command: string;
195
- readonly timeoutMs?: number;
196
- }>;
197
- readonly onSandboxReady?: ReadonlyArray<{
198
- readonly command: string;
199
- readonly timeoutMs?: number;
200
- }>;
201
- };
202
- readonly sandbox?: {
203
- readonly onSandboxReady?: ReadonlyArray<{
204
- readonly command: string;
205
- readonly sudo?: boolean;
206
- readonly timeoutMs?: number;
207
- }>;
208
- };
209
- };
210
-
211
- /** Per-iteration result carrying an optional session ID. */
212
- interface IterationResult {
213
- /** Agent session ID extracted from the provider stream, when available. */
214
- readonly sessionId?: string;
215
- /** Absolute host path to the captured session record, when capture is enabled. */
216
- readonly sessionFilePath?: string;
217
- /** Token usage snapshot from the last assistant message in the session, or undefined when capture is disabled or provider does not support usage parsing. */
218
- readonly usage?: IterationUsage;
219
- }
220
-
221
- /**
222
- * A map of named values used for prompt argument substitution.
223
- * Each key corresponds to a `{{KEY}}` placeholder in the prompt; the value
224
- * replaces it before the prompt is passed to the agent.
225
- */
226
- type PromptArgs = Record<string, string | number | boolean>;
227
-
228
- /** Branded output definition for `Output.object({ tag, schema })`. */
229
- interface OutputObjectDefinition<T> {
230
- readonly _tag: "object";
231
- readonly tag: string;
232
- readonly schema: StandardSchemaV1<unknown, T>;
233
- /**
234
- * Maximum number of additional attempts after the first if structured output
235
- * extraction or validation fails. Each retry resumes the failed run's agent
236
- * session and feeds back a token-efficient description of the error so the
237
- * agent can re-emit a corrected tag. Default: `0` (no retries).
238
- *
239
- * Retries require the agent provider to support session resumption (i.e.
240
- * `provider.sessionStorage` is populated — Codex or Claude Code). `run()`
241
- * fails at entry with a clear error when retries are requested but the
242
- * provider cannot resume.
243
- */
244
- readonly maxRetries?: number;
245
- }
246
- /** Branded output definition for `Output.string({ tag })`. */
247
- interface OutputStringDefinition {
248
- readonly _tag: "string";
249
- readonly tag: string;
250
- /**
251
- * Maximum number of additional attempts after the first if structured output
252
- * extraction fails. Each retry resumes the failed run's agent session and
253
- * feeds back a token-efficient description of the error so the agent can
254
- * re-emit a corrected tag. Default: `0` (no retries).
255
- *
256
- * Retries require the agent provider to support session resumption (i.e.
257
- * `provider.sessionStorage` is populated — Codex or Claude Code). `run()`
258
- * fails at entry with a clear error when retries are requested but the
259
- * provider cannot resume.
260
- */
261
- readonly maxRetries?: number;
262
- }
263
- /** Union of all output definition shapes accepted by `run()`. */
264
- type OutputDefinition = OutputObjectDefinition<any> | OutputStringDefinition;
265
- /**
266
- * Helpers for declaring structured output on `run()`.
267
- *
268
- * ```ts
269
- * import { Output, run } from "@snappedly-tools/shipyard";
270
- * import { z } from "zod";
271
- *
272
- * const result = await run({
273
- * output: Output.object({ tag: "result", schema: z.object({ answer: z.number() }) }),
274
- * // ...
275
- * });
276
- * console.log(result.output.answer); // typed as number
277
- * ```
278
- */
279
- declare const Output: {
280
- /**
281
- * Declare an object-typed structured output extracted from an XML tag in
282
- * the agent's stdout. The tag contents are JSON-parsed (with fence-aware
283
- * unwrapping) and validated against the provided Standard Schema validator.
284
- *
285
- * Set `maxRetries` to have `run()` automatically resume the failed session
286
- * and ask the agent to re-emit corrected output when extraction or
287
- * validation fails. Default: `0` (no retries).
288
- */
289
- readonly object: <Schema extends StandardSchemaV1>(opts: {
290
- tag: string;
291
- schema: Schema;
292
- maxRetries?: number;
293
- }) => OutputObjectDefinition<StandardSchemaV1.InferOutput<Schema>>;
294
- /**
295
- * Declare a string-typed structured output extracted from an XML tag in
296
- * the agent's stdout. The tag contents are whitespace-trimmed and returned
297
- * as a plain string — no JSON parsing, no schema validation.
298
- *
299
- * Set `maxRetries` to have `run()` automatically resume the failed session
300
- * and ask the agent to re-emit corrected output when extraction fails.
301
- * Default: `0` (no retries).
302
- */
303
- readonly string: (opts: {
304
- tag: string;
305
- maxRetries?: number;
306
- }) => OutputStringDefinition;
307
- };
308
- interface StructuredOutputErrorOptions {
309
- readonly tag: string;
310
- readonly rawMatched: string | undefined;
311
- readonly cause?: unknown;
312
- readonly commits: {
313
- sha: string;
314
- }[];
315
- readonly branch: string;
316
- readonly preservedWorktreePath?: string;
317
- readonly sessionId?: string;
318
- readonly sessionFilePath?: string;
319
- }
320
- /**
321
- * Thrown by `run()` when structured output extraction or validation fails.
322
- *
323
- * Possible failure modes:
324
- * - The configured XML tag was not found in stdout (`rawMatched` is `undefined`).
325
- * - The tag contents failed `JSON.parse` (`cause` carries the parse error).
326
- * - The parsed JSON failed schema validation (`cause` carries the Standard Schema issues).
327
- *
328
- * The error carries `commits`, `branch`, and optionally `preservedWorktreePath`
329
- * so callers can decide recovery without losing the run's side effects.
330
- *
331
- * It also carries `sessionId` (and `sessionFilePath` when the session was
332
- * captured to the host) of the iteration that produced the bad output, so a
333
- * caller can resume that same session and ask the agent to re-emit corrected
334
- * output:
335
- *
336
- * ```ts
337
- * try {
338
- * return await run({ ...opts, output });
339
- * } catch (e) {
340
- * if (e instanceof StructuredOutputError && e.sessionId) {
341
- * return await run({
342
- * ...opts,
343
- * output,
344
- * resumeSession: e.sessionId,
345
- * prompt: feedback(e),
346
- * });
347
- * }
348
- * throw e;
349
- * }
350
- * ```
351
- */
352
- declare class StructuredOutputError extends Error {
353
- readonly tag: string;
354
- readonly rawMatched: string | undefined;
355
- readonly cause: unknown;
356
- readonly commits: {
357
- sha: string;
358
- }[];
359
- readonly branch: string;
360
- readonly preservedWorktreePath?: string;
361
- /** Session ID of the iteration that produced the bad output, when available. */
362
- readonly sessionId?: string;
363
- /** Host path to the captured session JSONL, when the session was captured. */
364
- readonly sessionFilePath?: string;
365
- constructor(message: string, options: StructuredOutputErrorOptions);
366
- }
367
-
368
- /**
369
- * Controls where Shipyard writes iteration progress and agent output.
370
- * Use `"file"` (log-to-file mode) to write to a log file on disk, or
371
- * `"stdout"` (terminal mode) to render an interactive UI in the terminal.
372
- */
373
- type LoggingOption =
374
- /** Write progress and agent output to a log file at the given path (log-to-file mode). */
375
- {
376
- readonly type: "file";
377
- readonly path: string;
378
- /**
379
- * Optional callback invoked for each agent stream event (text chunk,
380
- * tool call, or raw stdout line) in addition to being written to the
381
- * log file. Intended for forwarding the agent's output stream to
382
- * external observability systems. Errors thrown by the callback are
383
- * swallowed.
384
- */
385
- readonly onAgentStreamEvent?: (event: AgentStreamEvent) => void;
386
- /**
387
- * When `true`, every raw stdout line the agent emits is appended
388
- * verbatim to the same log file at `path`, in real time. Includes
389
- * lines the provider's stream parser would otherwise drop (e.g.
390
- * tool-use blocks for unrecognised tools). Intended for debugging
391
- * stuck or unexpected agent behavior — note that the raw JSON is
392
- * interleaved with the human-readable log output. Default: `false`.
393
- */
394
- readonly verbose?: boolean;
395
- }
396
- /** Render progress and agent output as an interactive UI in the terminal (terminal mode). */
397
- | {
398
- readonly type: "stdout";
399
- /**
400
- * When `true`, every raw stdout line the agent emits is written
401
- * verbatim to `process.stdout`, in real time. Includes lines the
402
- * provider's stream parser would otherwise drop. Intended for
403
- * debugging stuck or unexpected agent behavior. Note: the raw output
404
- * is interleaved with the interactive terminal UI. Default: `false`.
405
- */
406
- readonly verbose?: boolean;
407
- };
408
- /** Override default timeouts for built-in lifecycle steps. Unset keys keep their defaults. */
409
- interface Timeouts {
410
- /** Timeout (ms) for copying selected paths into a worktree or Docker sandbox. Default: 60_000. */
411
- readonly copyToWorktreeMs?: number;
412
- /** Timeout (ms) for each in-sandbox git setup command (safe.directory, user.name/email, branch discovery). Default: 10_000. */
413
- readonly gitSetupMs?: number;
414
- /** Timeout (ms) for collecting the commits produced during the run. Default: 30_000. */
415
- readonly commitCollectionMs?: number;
416
- /** Timeout (ms) for merging the temp branch back to the host branch (merge-to-head strategy). Default: 30_000. */
417
- readonly mergeToHostMs?: number;
418
- }
419
- interface RunOptions<A extends AgentProvider = AgentProvider> {
420
- /** Agent provider to use (e.g. codex(CODEX_MODELS.routine)) */
421
- readonly agent: A;
422
- /** Sandbox provider (e.g. docker({ imageName: "shipyard:myrepo" })). */
423
- readonly sandbox: SandboxProvider;
424
- /**
425
- * Host repo directory. Replaces `process.cwd()` as the anchor for
426
- * `.shipyard/worktrees/`, `.shipyard/.env`, `.shipyard/logs/YYYY-MM-DD/`,
427
- * `.shipyard/patches/`, and git operations.
428
- *
429
- * - Relative paths are resolved against `process.cwd()`.
430
- * - Absolute paths are used as-is.
431
- * - Defaults to `process.cwd()` when omitted.
432
- */
433
- readonly cwd?: string;
434
- /** Inline prompt string (mutually exclusive with promptFile) */
435
- readonly prompt?: string;
436
- /**
437
- * Path to a prompt file (mutually exclusive with prompt).
438
- *
439
- * **Note:** `promptFile` is always resolved against `process.cwd()`, not
440
- * against the `cwd` option. If you set a custom `cwd`, pass an absolute
441
- * `promptFile` to avoid ambiguity.
442
- */
443
- readonly promptFile?: string;
444
- /** Maximum iterations to run (default: 1) */
445
- readonly maxIterations?: number;
446
- /** Lifecycle hooks grouped by execution location (host or sandbox). */
447
- readonly hooks?: SandboxHooks;
448
- /** Key-value map for {{KEY}} placeholder substitution in prompts */
449
- readonly promptArgs?: PromptArgs;
450
- /** Logging mode (default: { type: 'file' } with auto-generated path under .shipyard/logs/YYYY-MM-DD/) */
451
- readonly logging?: LoggingOption;
452
- /** Substring(s) the agent emits to stop the iteration loop early. Matched via `includes` against agent output. (default: `"<promise>COMPLETE</promise>"`) */
453
- readonly completionSignal?: string | string[];
454
- /** Idle timeout in seconds. If the agent produces no output for this long, it fails. Default: 600 (10 minutes) */
455
- readonly idleTimeoutSeconds?: number;
456
- /**
457
- * Grace window in seconds after a completion signal is observed in the
458
- * agent's output. The agent process is expected to exit shortly after
459
- * emitting the signal; if it does not (typically because a spawned child —
460
- * a `gh`/git subprocess or long-lived MCP server — keeps stdout open),
461
- * Shipyard force-completes the iteration with a warning. Resets on every
462
- * subsequent output line so trailing data (token-usage events, terminal
463
- * `result` events, structured-output tags) is still captured. Independent
464
- * of `idleTimeoutSeconds`. Default: 60.
465
- */
466
- readonly completionTimeoutSeconds?: number;
467
- /** Optional name for the run, shown as a prefix in log output */
468
- readonly name?: string;
469
- /** Paths relative to the host repo root to copy into Docker after Git sync. */
470
- readonly copyToWorktree?: string[];
471
- /** Tools the provider must enforce for this controlled phase. */
472
- readonly toolAllowlist?: readonly string[];
473
- /** Branch strategy; defaults to merge-to-head. */
474
- readonly branchStrategy?: BranchStrategy;
475
- /** Resume a prior agent session by ID. The session record must exist on the host. Incompatible with maxIterations > 1. */
476
- readonly resumeSession?: string;
477
- /**
478
- * An `AbortSignal` that cancels the run when aborted.
479
- *
480
- * - If `signal.aborted` is already `true` at entry, `run()` rejects
481
- * immediately without doing any setup work.
482
- * - Aborting mid-iteration kills the in-flight agent subprocess.
483
- * - Phase boundaries (between iterations) also check the signal.
484
- * - The rejected promise surfaces `signal.reason` via
485
- * `signal.throwIfAborted()` — no Shipyard-specific wrapping.
486
- * - The worktree is preserved on disk after abort (error-path behavior).
487
- */
488
- readonly signal?: AbortSignal;
489
- /** Override default timeouts for built-in lifecycle steps. Unset keys keep their defaults. */
490
- readonly timeouts?: Timeouts;
491
- /**
492
- * Structured output definition. When provided, the agent's stdout is
493
- * scanned for the configured XML tag after the iteration completes, and the
494
- * result is parsed/validated and returned on `RunResult.output`.
495
- *
496
- * Use `Output.object({ tag, schema })` for JSON+schema or
497
- * `Output.string({ tag })` for raw string extraction.
498
- *
499
- * Constraints:
500
- * - `maxIterations` must be `1` (the default).
501
- * - The resolved prompt must contain the configured opening tag literal.
502
- *
503
- * See ADR 0010 for design rationale.
504
- */
505
- readonly output?: OutputDefinition;
506
- }
507
-
508
- type ResumeRunResultOptions = Omit<RunOptions, "agent" | "sandbox" | "prompt" | "promptFile" | "resumeSession" | "forkSession" | "maxIterations">;
509
- interface RunResult {
510
- /** Per-iteration results (use `iterations.length` for the count). */
511
- readonly iterations: IterationResult[];
512
- /** The matched completion signal string, or undefined if no signal fired before the iteration limit. */
513
- readonly completionSignal?: string;
514
- /** Combined stdout output from all agent iterations. */
515
- readonly stdout: string;
516
- /** List of commits made by the agent during the run, each identified by its SHA. */
517
- readonly commits: {
518
- sha: string;
519
- }[];
520
- /** The branch name the agent worked on inside the sandbox. */
521
- readonly branch: string;
522
- /** Path to the log file, if logging was drained to a file. */
523
- readonly logFilePath?: string;
524
- /** Host path to the preserved worktree, set when the run succeeded but the worktree had uncommitted changes. */
525
- readonly preservedWorktreePath?: string;
526
- /** Continue the last captured agent session for exactly one iteration.
527
- * Present only when the provider supports resume (`sessionStorage` populated). */
528
- readonly resume?: (prompt: string, options?: ResumeRunResultOptions) => Promise<RunResult>;
529
- /**
530
- * Fork the last captured agent session for exactly one iteration: the
531
- * parent session JSONL is left intact and the child run gets its own
532
- * session id, enabling fan-out patterns where multiple children diverge
533
- * from a single parent. Present only when the provider supports resume
534
- * (`sessionStorage` populated).
535
- *
536
- * Sessions only: fork isolates the agent session, not the branch or
537
- * sandbox. Safe concurrent fan-out (`Promise.all([r.fork(a), r.fork(b)])`)
538
- * requires the caller to give each fork a distinct `branch` — `head` and
539
- * `merge-to-head` are not safe for concurrent forks. See ADR 0018.
540
- */
541
- readonly fork?: (prompt: string, options?: ResumeRunResultOptions) => Promise<RunResult>;
542
- }
543
- /** Overload: with `Output.object`, returns `RunResult` with typed `output: T`. */
544
- declare function run<T, A extends AgentProvider>(options: RunOptions<A> & {
545
- output: OutputObjectDefinition<T>;
546
- }): Promise<RunResult & {
547
- output: T;
548
- }>;
549
- /** Overload: with `Output.string`, returns `RunResult` with `output: string`. */
550
- declare function run<A extends AgentProvider>(options: RunOptions<A> & {
551
- output: OutputStringDefinition;
552
- }): Promise<RunResult & {
553
- output: string;
554
- }>;
555
- /** Overload: without `output`, returns the standard `RunResult`. */
556
- declare function run<A extends AgentProvider>(options: RunOptions<A>): Promise<RunResult>;
1
+ import { A as AgentProvider, S as SandboxHooks, P as PromptArgs, T as Timeouts, L as LoggingOption, I as IterationResult, a as Sandbox, C as CloseResult } from './createSandbox-DmbnWAZv.js';
2
+ export { b as AgentCommandOptions, c as AgentStreamEvent, d as CODEX_MODELS, e as CODEX_REASONING_EFFORTS, f as ClaudeCodeOptions, g as CodexModelConfig, h as CodexOptions, i as CodexReasoningEffort, j as CreateSandboxOptions, k as IterationUsage, O as Output, l as OutputDefinition, m as OutputObjectDefinition, n as OutputStringDefinition, o as PrintCommand, R as ResumeSandboxRunResultOptions, p as RunOptions, q as RunResult, r as SandboxExecOptions, s as SandboxInteractiveOptions, t as SandboxInteractiveResult, u as SandboxRunOptions, v as SandboxRunResult, w as StructuredOutputError, x as claudeCode, y as codex, z as createSandbox, B as run } from './createSandbox-DmbnWAZv.js';
3
+ import { S as SandboxProvider, B as BranchStrategy, M as MergeToHeadBranchStrategy, N as NamedBranchStrategy } from './SandboxProvider-oUAwYlWm.js';
4
+ export { E as ExecResult, a as InteractiveExecOptions, b as IsolatedCreateOptions, c as IsolatedSandboxHandle, I as IsolatedSandboxProvider, d as IsolatedSandboxProviderConfig, e as createIsolatedSandboxProvider } from './SandboxProvider-oUAwYlWm.js';
5
+ export { M as MountConfig } from './MountConfig-K5ILnfht.js';
6
+ import '@standard-schema/spec';
557
7
 
558
8
  interface InteractiveOptions {
559
9
  /** Agent provider to use (e.g. codex(CODEX_MODELS.routine)) */
@@ -623,188 +73,6 @@ interface InteractiveResult {
623
73
  */
624
74
  declare const interactive: (options: InteractiveOptions) => Promise<InteractiveResult>;
625
75
 
626
- interface CreateSandboxOptions {
627
- /** Explicit branch for the worktree (required). */
628
- readonly branch: string;
629
- /**
630
- * Ref to fork from when `branch` does not yet exist. Ignored when the branch
631
- * already exists. Defaults to `HEAD`.
632
- */
633
- readonly baseBranch?: string;
634
- /** Sandbox provider (e.g. docker({ imageName: "shipyard:myrepo" })). */
635
- readonly sandbox: SandboxProvider;
636
- /**
637
- * Host repo directory. Replaces `process.cwd()` as the anchor for
638
- * `.shipyard/worktrees/`, `.shipyard/.env`, and git operations.
639
- *
640
- * - Relative paths are resolved against `process.cwd()`.
641
- * - Absolute paths are used as-is.
642
- * - Defaults to `process.cwd()` when omitted.
643
- */
644
- readonly cwd?: string;
645
- /** Lifecycle hooks grouped by execution location (host or sandbox). */
646
- readonly hooks?: SandboxHooks;
647
- /** Paths relative to the host repo root to copy into Docker after Git sync. */
648
- readonly copyToWorktree?: string[];
649
- /** Override default timeouts for built-in lifecycle steps. Unset keys keep their defaults. */
650
- readonly timeouts?: Timeouts;
651
- }
652
- /**
653
- * Options accepted by `SandboxRunResult.resume()` / `.fork()`. Mirrors
654
- * `ResumeRunResultOptions` in `run.ts` — drops the fields owned by the
655
- * captured run (prompt, iteration count, resumeSession/forkSession bookkeeping).
656
- *
657
- * Defined as the base interface that `SandboxRunOptions` extends — the
658
- * interface-extends shape is cheaper for the TS checker than
659
- * `Omit<SandboxRunOptions, ...>` (which forces a mapped-type computation
660
- * on every reference).
661
- */
662
- interface ResumeSandboxRunResultOptions {
663
- /** Key-value map for {{KEY}} placeholder substitution in prompts. */
664
- readonly promptArgs?: PromptArgs;
665
- /** Substring(s) the agent emits to stop the iteration loop early. */
666
- readonly completionSignal?: string | string[];
667
- /** Idle timeout in seconds. Default: 600. */
668
- readonly idleTimeoutSeconds?: number;
669
- /** Grace window in seconds after a completion signal is observed but the agent process has not exited. See ADR 0019. Default: 60. */
670
- readonly completionTimeoutSeconds?: number;
671
- /** Display name for this run. */
672
- readonly name?: string;
673
- /** Tools the provider must enforce for this controlled phase. */
674
- readonly toolAllowlist?: readonly string[];
675
- /** Logging mode. */
676
- readonly logging?: LoggingOption;
677
- /**
678
- * An `AbortSignal` that cancels the run when aborted.
679
- *
680
- * - Pre-aborted signal rejects immediately without setup.
681
- * - Mid-iteration abort kills the in-flight agent subprocess.
682
- * - The rejected promise surfaces `signal.reason` verbatim.
683
- * - The `Sandbox` handle remains usable after abort — call `.run()` again
684
- * with a fresh signal, or `.close()` to tear down.
685
- */
686
- readonly signal?: AbortSignal;
687
- }
688
- interface SandboxRunOptions extends ResumeSandboxRunResultOptions {
689
- /** Agent provider to use (e.g. codex(CODEX_MODELS.routine)). */
690
- readonly agent: AgentProvider;
691
- /** Inline prompt string (mutually exclusive with promptFile). */
692
- readonly prompt?: string;
693
- /** Path to a prompt file (mutually exclusive with prompt). */
694
- readonly promptFile?: string;
695
- /** Maximum iterations to run (default: 1). */
696
- readonly maxIterations?: number;
697
- /** Resume a prior agent session by id. The session JSONL must exist on the host (captured by a prior `sandbox.run()`). Incompatible with `maxIterations > 1`. */
698
- readonly resumeSession?: string;
699
- }
700
- interface SandboxRunResult {
701
- /** Per-iteration results (use `iterations.length` for the count). */
702
- readonly iterations: IterationResult[];
703
- /** The matched completion signal string, or undefined if none fired. */
704
- readonly completionSignal?: string;
705
- /** Combined stdout output from all agent iterations. */
706
- readonly stdout: string;
707
- /** List of commits made by the agent during the run. */
708
- readonly commits: {
709
- sha: string;
710
- }[];
711
- /** Path to the log file, if logging was drained to a file. */
712
- readonly logFilePath?: string;
713
- /**
714
- * Continue the last captured agent session for exactly one iteration inside
715
- * the same long-lived sandbox. Present only when the provider supports
716
- * resume (`sessionStorage` populated) and a session id was captured.
717
- */
718
- readonly resume?: (prompt: string, options?: ResumeSandboxRunResultOptions) => Promise<SandboxRunResult>;
719
- /**
720
- * Fork the last captured agent session for exactly one iteration inside the
721
- * same long-lived sandbox: the parent session JSONL is left intact and the
722
- * child run gets its own session id. Present only when the provider
723
- * supports resume (`sessionStorage` populated) and a session id was
724
- * captured. See ADR 0018 for fork semantics.
725
- */
726
- readonly fork?: (prompt: string, options?: ResumeSandboxRunResultOptions) => Promise<SandboxRunResult>;
727
- }
728
- interface SandboxInteractiveOptions {
729
- /** Agent provider to use (e.g. codex(CODEX_MODELS.routine)). */
730
- readonly agent: AgentProvider;
731
- /** Inline prompt string (mutually exclusive with promptFile). */
732
- readonly prompt?: string;
733
- /** Path to a prompt file (mutually exclusive with prompt). */
734
- readonly promptFile?: string;
735
- /** Key-value map for {{KEY}} placeholder substitution in prompts. */
736
- readonly promptArgs?: PromptArgs;
737
- /** Display name for this interactive session. */
738
- readonly name?: string;
739
- /**
740
- * An `AbortSignal` that cancels the interactive session when aborted.
741
- *
742
- * - Pre-aborted signal rejects immediately without setup.
743
- * - The rejected promise surfaces `signal.reason` verbatim.
744
- * - The `Sandbox` handle remains usable after abort.
745
- */
746
- readonly signal?: AbortSignal;
747
- }
748
- interface SandboxInteractiveResult {
749
- /** List of commits made during the interactive session. */
750
- readonly commits: {
751
- sha: string;
752
- }[];
753
- /** Exit code of the interactive process. */
754
- readonly exitCode: number;
755
- }
756
- interface CloseResult {
757
- /** Host path to the preserved worktree, set when the worktree had uncommitted changes. */
758
- readonly preservedWorktreePath?: string;
759
- }
760
- interface Sandbox {
761
- /** The branch the worktree is on. */
762
- readonly branch: string;
763
- /** Host path to the worktree. */
764
- readonly worktreePath: string;
765
- /** Invoke an agent inside the existing sandbox. */
766
- run(options: SandboxRunOptions): Promise<SandboxRunResult>;
767
- /** Launch an interactive agent session inside the existing sandbox. */
768
- interactive(options: SandboxInteractiveOptions): Promise<SandboxInteractiveResult>;
769
- /**
770
- * Execute a command inside the existing sandbox.
771
- *
772
- * `cwd` defaults to the sandbox repo path (same default `interactive()`
773
- * uses), so callers get the same working directory across providers. Pass
774
- * `cwd` to override.
775
- *
776
- * Returns the full `ExecResult` — non-zero `exitCode` is surfaced, not
777
- * thrown. Callers that want strict semantics should check `result.exitCode`
778
- * themselves (matching the contract of `SessionTransferHandle.exec`).
779
- */
780
- exec(command: string, options?: SandboxExecOptions): Promise<ExecResult>;
781
- /** Tear down the sandbox and worktree. */
782
- close(): Promise<CloseResult>;
783
- /** Auto teardown via `await using`. */
784
- [Symbol.asyncDispose](): Promise<void>;
785
- }
786
- /** Options accepted by `Sandbox.exec()`. Mirrors the provider handle's `exec` options. */
787
- interface SandboxExecOptions {
788
- /** Per-line stdout callback for streaming output. */
789
- readonly onLine?: (line: string) => void;
790
- /** Working directory for the command. Defaults to the sandbox repo path. */
791
- readonly cwd?: string;
792
- /** Run the command with sudo, when the provider supports it. */
793
- readonly sudo?: boolean;
794
- /** Stdin payload — piped to the child process and then closed. Avoids the Linux 128 KB per-arg limit. */
795
- readonly stdin?: string;
796
- /** Abort the command when the surrounding operation is cancelled. */
797
- readonly signal?: AbortSignal;
798
- /** Reject/terminate the command after this many combined output bytes. */
799
- readonly maxOutputBytes?: number;
800
- }
801
- /**
802
- * Eagerly creates a git worktree on the provided explicit branch and starts
803
- * a Docker sandbox with a synced Git workspace. Returns a Sandbox handle that
804
- * can be reused across multiple `run()` calls.
805
- */
806
- declare const createSandbox: (options: CreateSandboxOptions) => Promise<Sandbox>;
807
-
808
76
  /** Branch strategies valid for createWorktree — head is excluded. */
809
77
  type WorktreeBranchStrategy = MergeToHeadBranchStrategy | NamedBranchStrategy;
810
78
  interface CreateWorktreeOptions {
@@ -1025,1799 +293,4 @@ interface CwdError extends Error {
1025
293
  /** The provided `cwd` path does not exist or is not a directory. */
1026
294
  declare const CwdError: CwdErrorConstructor;
1027
295
 
1028
- declare const WORKFLOW_CONTRACT_VERSION: 1;
1029
- type WorkItemKind = "planning-spec" | "executable-issue" | "pr-repair";
1030
- type RiskLevel = "low" | "medium" | "high" | "critical";
1031
- type WorkRisk = RiskLevel | "unknown";
1032
- type WorkScope = "small" | "substantial" | "unknown";
1033
- type WorkflowPhase = "triage" | "implementation" | "checking" | "review" | "repair" | "handoff" | "merge" | "release-verification";
1034
- type LifecycleState = "queued" | "waiting-info" | "authorized" | "implementing" | "checking" | "reviewing" | "repairing" | "human-review" | "merged" | "release-verifying" | "completed" | "failed" | "blocked" | "cancelled";
1035
- type PhaseOutcome = "completed" | "needs-info" | "blocked" | "failed" | "cancelled";
1036
- type CheckStatus = "passed" | "failed" | "incomplete" | "blocked" | "unknown";
1037
- type FindingSeverity = "info" | "low" | "medium" | "high" | "critical";
1038
- type ReviewAxis = "standards" | "spec" | "interface";
1039
- type FindingDisposition = "open" | "fixed" | "rejected" | "accepted" | "deferred";
1040
- interface WorkIdentity {
1041
- readonly repository: string;
1042
- readonly itemId: string;
1043
- readonly kind: WorkItemKind;
1044
- }
1045
- interface SourceReference {
1046
- readonly provider: "github" | "slack" | "manual";
1047
- readonly repository: string;
1048
- readonly itemId: string;
1049
- readonly url?: string;
1050
- /** Original content is retained durably but must not be echoed to an unauthorized destination. */
1051
- readonly originalBody: string;
1052
- readonly author?: string;
1053
- }
1054
- interface RevisionReference {
1055
- readonly branch: string;
1056
- readonly sha: string;
1057
- }
1058
- interface Authorization {
1059
- readonly status: "pending" | "approved" | "withdrawn";
1060
- readonly actor?: string;
1061
- readonly actorRole?: "maintainer" | "owner" | "policy";
1062
- readonly approvedAt?: string;
1063
- }
1064
- interface VerificationPlan {
1065
- readonly checks: readonly string[];
1066
- readonly artifacts: readonly string[];
1067
- }
1068
- interface WorkBrief {
1069
- readonly contractVersion: typeof WORKFLOW_CONTRACT_VERSION;
1070
- readonly id: string;
1071
- readonly revision: number;
1072
- readonly hash: string;
1073
- readonly identity: WorkIdentity;
1074
- readonly source: SourceReference;
1075
- readonly problem: string;
1076
- readonly evidence: readonly string[];
1077
- readonly acceptanceCriteria: readonly string[];
1078
- readonly exclusions: readonly string[];
1079
- readonly risk: WorkRisk;
1080
- readonly scope?: WorkScope;
1081
- readonly verification: VerificationPlan;
1082
- readonly unresolvedQuestions: readonly string[];
1083
- readonly authorization: Authorization;
1084
- readonly base: RevisionReference;
1085
- readonly policyRevision: string;
1086
- readonly skillRevision: string;
1087
- readonly createdAt: string;
1088
- }
1089
- interface CheckCommand {
1090
- readonly name: string;
1091
- readonly command: string;
1092
- readonly required: boolean;
1093
- }
1094
- interface PhaseBudget {
1095
- readonly maxAttempts: number;
1096
- readonly timeoutSeconds: number;
1097
- }
1098
- type AgentRole = "routine" | "strong";
1099
- interface AgentModelRoles {
1100
- readonly routine: string;
1101
- readonly strong: string;
1102
- }
1103
- type WorkerPolicy = {
1104
- readonly provider: string;
1105
- readonly sandbox: string;
1106
- readonly skillRevision: string;
1107
- } & ({
1108
- readonly model: string;
1109
- readonly models?: never;
1110
- } | {
1111
- readonly model?: never;
1112
- readonly models: AgentModelRoles;
1113
- });
1114
- interface AgentSelection {
1115
- readonly provider: string;
1116
- readonly model: string;
1117
- readonly role: AgentRole;
1118
- }
1119
- interface RepositoryPolicy {
1120
- readonly contractVersion: typeof WORKFLOW_CONTRACT_VERSION;
1121
- readonly repository: string;
1122
- readonly revision: string;
1123
- readonly baseBranch: string;
1124
- readonly issueClosure: "merge-and-ci" | "staging-verification" | "production-verification";
1125
- readonly authorization: {
1126
- readonly required: boolean;
1127
- readonly allowedActors: readonly ("maintainer" | "owner" | "policy")[];
1128
- readonly autoStartRisk: readonly RiskLevel[];
1129
- };
1130
- readonly worker: WorkerPolicy;
1131
- readonly checks: readonly CheckCommand[];
1132
- readonly phaseBudgets: Readonly<Record<WorkflowPhase, PhaseBudget>>;
1133
- readonly repairBudget: {
1134
- readonly maxBatches: number;
1135
- readonly maxFollowUps: number;
1136
- };
1137
- }
1138
- /** Whether a brief carries an authorization accepted by this repository policy. */
1139
- declare const isAuthorizationAllowed: (brief: Pick<WorkBrief, "authorization">, policy: Pick<RepositoryPolicy, "authorization">) => boolean;
1140
- interface CheckEvidence {
1141
- readonly name: string;
1142
- readonly command: string;
1143
- readonly status: CheckStatus;
1144
- readonly summary: string;
1145
- /** Candidate identity for checks that are used as a lifecycle gate. */
1146
- readonly baseSha?: string;
1147
- readonly headSha?: string;
1148
- readonly briefHash?: string;
1149
- readonly startedAt?: string;
1150
- readonly completedAt?: string;
1151
- readonly exitCode?: number;
1152
- readonly artifactRefs?: readonly string[];
1153
- }
1154
- interface Finding {
1155
- readonly id: string;
1156
- readonly severity: FindingSeverity;
1157
- readonly axis: ReviewAxis;
1158
- readonly disposition: FindingDisposition;
1159
- readonly title: string;
1160
- readonly evidence: string;
1161
- readonly location?: string;
1162
- readonly requirement?: string;
1163
- readonly verification?: string;
1164
- }
1165
- interface ReviewEvidence {
1166
- readonly outcome: "passed" | "actionable-findings" | "incomplete" | "blocked" | "failed";
1167
- readonly axes: readonly ReviewAxis[];
1168
- readonly findings: readonly Finding[];
1169
- readonly headSha: string;
1170
- readonly baseSha?: string;
1171
- readonly briefHash: string;
1172
- }
1173
- interface PhaseResult {
1174
- readonly contractVersion: typeof WORKFLOW_CONTRACT_VERSION;
1175
- readonly assignmentId: string;
1176
- readonly phase: WorkflowPhase;
1177
- readonly outcome: PhaseOutcome;
1178
- readonly identity: WorkIdentity;
1179
- /** Brief revision executed by this phase. */
1180
- readonly briefHash: string;
1181
- readonly base?: RevisionReference;
1182
- readonly head?: RevisionReference;
1183
- readonly summary: string;
1184
- readonly evidence: readonly string[];
1185
- readonly checks: readonly CheckEvidence[];
1186
- readonly commits: readonly string[];
1187
- readonly artifacts: readonly string[];
1188
- readonly questions: readonly string[];
1189
- readonly findings: readonly Finding[];
1190
- /** Review axes explicitly completed, including axes with no findings. */
1191
- readonly reviewAxes?: readonly ReviewAxis[];
1192
- readonly completedAt: string;
1193
- }
1194
- interface Assignment {
1195
- readonly contractVersion: typeof WORKFLOW_CONTRACT_VERSION;
1196
- readonly id: string;
1197
- readonly phase: WorkflowPhase;
1198
- readonly attempt: number;
1199
- readonly identity: WorkIdentity;
1200
- readonly briefId: string;
1201
- readonly briefRevision: number;
1202
- readonly briefHash: string;
1203
- readonly policyRevision: string;
1204
- readonly skillRevision: string;
1205
- /** Missing only on assignments persisted before role model selection shipped. */
1206
- readonly agentSelection?: AgentSelection;
1207
- readonly base: RevisionReference;
1208
- readonly head?: RevisionReference;
1209
- readonly createdAt: string;
1210
- }
1211
- interface TransitionContext {
1212
- readonly kind: WorkItemKind;
1213
- readonly authorization: Authorization["status"];
1214
- readonly checks?: readonly CheckEvidence[];
1215
- /** Required check names from the repository policy. */
1216
- readonly requiredCheckNames?: readonly string[];
1217
- /** Exact candidate identity required for lifecycle-gating check evidence. */
1218
- readonly checkCandidate?: {
1219
- readonly baseSha: string;
1220
- readonly headSha: string;
1221
- readonly briefHash: string;
1222
- };
1223
- readonly review?: ReviewEvidence;
1224
- readonly currentHeadSha?: string;
1225
- readonly assignedHeadSha?: string;
1226
- }
1227
- declare class ContractValidationError extends Error {
1228
- readonly issues: readonly string[];
1229
- constructor(message: string, issues?: readonly string[]);
1230
- }
1231
- type CreateWorkBriefInput = Omit<WorkBrief, "contractVersion" | "id" | "revision" | "hash"> & {
1232
- readonly id?: string;
1233
- readonly revision?: number;
1234
- /** Accepted for callers carrying a previously materialized brief; always recomputed. */
1235
- readonly hash?: string;
1236
- readonly contractVersion?: typeof WORKFLOW_CONTRACT_VERSION;
1237
- };
1238
- declare const createWorkBrief: (input: CreateWorkBriefInput) => WorkBrief;
1239
- declare const parseWorkBrief: (value: unknown) => WorkBrief;
1240
- type CreateRepositoryPolicyInput = Omit<RepositoryPolicy, "contractVersion">;
1241
- declare const parseRepositoryPolicy: (value: unknown) => RepositoryPolicy;
1242
- declare const createRepositoryPolicy: (input: CreateRepositoryPolicyInput) => RepositoryPolicy;
1243
- declare const resolveAgentSelection: (policy: Pick<RepositoryPolicy, "worker">, phase: WorkflowPhase, risk?: WorkRisk, scope?: WorkScope) => AgentSelection;
1244
- declare const parseCheckEvidence: (value: unknown) => CheckEvidence;
1245
- declare const requireTransition: (from: LifecycleState, to: LifecycleState, context: TransitionContext) => void;
1246
- interface CreateAssignmentInput {
1247
- readonly id: string;
1248
- readonly phase: WorkflowPhase;
1249
- readonly brief: WorkBrief;
1250
- readonly policy: RepositoryPolicy;
1251
- readonly attempt: number;
1252
- readonly head?: RevisionReference;
1253
- readonly createdAt: string;
1254
- }
1255
- declare const createAssignment: (input: CreateAssignmentInput) => Assignment;
1256
- declare const parsePhaseResult: (value: unknown) => PhaseResult;
1257
-
1258
- type JobControl = "active" | "paused" | "cancelled" | "superseded";
1259
- type EventStatus = "received" | "accepted" | "ignored";
1260
- type EventIgnoreReason = "out-of-order" | "closed-item" | "withdrawn-authorization" | "repository-stopped" | "invalid-policy";
1261
- type DispatchStatus = "pending" | "claimed" | "started" | "completed" | "failed" | "cancelled";
1262
- type EffectStatus = "pending" | "claimed" | "succeeded" | "uncertain" | "failed" | "cancelled";
1263
- interface WorkKey {
1264
- readonly repository: string;
1265
- readonly itemId: string;
1266
- readonly briefRevision: number;
1267
- readonly phase: WorkflowPhase;
1268
- readonly relevantRevision: string;
1269
- }
1270
- interface WorkflowEventInput {
1271
- readonly deliveryId: string;
1272
- readonly brief: WorkBrief;
1273
- readonly policy: RepositoryPolicy;
1274
- readonly phase: WorkflowPhase;
1275
- readonly relevantRevision: string;
1276
- readonly observedAt: string;
1277
- /** A closed source item invalidates queued and active work. */
1278
- readonly sourceState?: "open" | "closed";
1279
- readonly payload?: unknown;
1280
- }
1281
- interface StoredEvent extends WorkflowEventInput {
1282
- readonly id: string;
1283
- readonly key: WorkKey;
1284
- readonly status: EventStatus;
1285
- readonly ignoreReason?: EventIgnoreReason;
1286
- readonly jobId?: string;
1287
- readonly receivedAt: string;
1288
- }
1289
- interface RepairBudgetUsage {
1290
- readonly repairBatches: number;
1291
- readonly followUps: number;
1292
- }
1293
- interface WorkflowJob {
1294
- readonly id: string;
1295
- readonly key: WorkKey;
1296
- readonly brief: WorkBrief;
1297
- readonly policy: RepositoryPolicy;
1298
- readonly state: LifecycleState;
1299
- readonly control: JobControl;
1300
- readonly phaseAttempts: Readonly<Record<WorkflowPhase, number>>;
1301
- readonly repairBatches: number;
1302
- readonly followUps: number;
1303
- readonly infrastructureRetries: number;
1304
- readonly infrastructureRetryLimit: number;
1305
- readonly assignments: readonly Assignment[];
1306
- readonly phaseResults: readonly PhaseResult[];
1307
- readonly activeAssignmentId?: string;
1308
- readonly latestObservedAt: string;
1309
- readonly createdAt: string;
1310
- readonly updatedAt: string;
1311
- readonly version: number;
1312
- }
1313
- interface DispatchIntent {
1314
- readonly id: string;
1315
- readonly dedupeKey: string;
1316
- readonly key: WorkKey;
1317
- readonly jobId: string;
1318
- readonly status: DispatchStatus;
1319
- readonly assignment?: Assignment;
1320
- readonly workerId?: string;
1321
- readonly claimedAt?: number;
1322
- readonly claimExpiresAt?: number;
1323
- readonly error?: string;
1324
- readonly createdAt: string;
1325
- readonly updatedAt: string;
1326
- }
1327
- interface EffectIntent {
1328
- readonly id: string;
1329
- readonly jobId: string;
1330
- readonly kind: string;
1331
- readonly marker: string;
1332
- readonly payload?: unknown;
1333
- readonly status: EffectStatus;
1334
- readonly externalRef?: unknown;
1335
- readonly workerId?: string;
1336
- readonly fencingToken?: number;
1337
- readonly claimedAt?: number;
1338
- readonly claimExpiresAt?: number;
1339
- readonly error?: string;
1340
- readonly createdAt: string;
1341
- readonly updatedAt: string;
1342
- }
1343
- interface BranchLease {
1344
- readonly leaseId: string;
1345
- readonly resourceKey: string;
1346
- readonly repository: string;
1347
- readonly branch: string;
1348
- readonly jobId: string;
1349
- readonly workerId: string;
1350
- readonly fencingToken: number;
1351
- readonly acquiredAt: number;
1352
- readonly heartbeatAt: number;
1353
- readonly expiresAt: number;
1354
- }
1355
- interface RepositoryControl {
1356
- readonly repository: string;
1357
- readonly stopped: boolean;
1358
- readonly reason?: string;
1359
- readonly updatedAt: string;
1360
- }
1361
- interface CoordinatorStorageTransaction {
1362
- insertEventIfAbsent(event: StoredEvent): Promise<{
1363
- readonly event: StoredEvent;
1364
- readonly inserted: boolean;
1365
- }>;
1366
- saveEvent(event: StoredEvent): Promise<void>;
1367
- /** Serialize intake for an identity even before its first job row exists. */
1368
- lockWorkIdentity(identity: WorkIdentity): Promise<void>;
1369
- getJob(jobId: string): Promise<WorkflowJob | undefined>;
1370
- findJobByKey(key: WorkKey, briefHash: string): Promise<WorkflowJob | undefined>;
1371
- findCurrentJob(identity: WorkIdentity): Promise<WorkflowJob | undefined>;
1372
- insertJob(job: WorkflowJob): Promise<void>;
1373
- saveJob(job: WorkflowJob): Promise<void>;
1374
- findDispatchByDedupeKey(dedupeKey: string): Promise<DispatchIntent | undefined>;
1375
- findDispatchByAssignmentId(assignmentId: string): Promise<DispatchIntent | undefined>;
1376
- findPendingDispatch(repository: string, nowMilliseconds: number, selector?: {
1377
- readonly jobId?: string;
1378
- readonly dispatchId?: string;
1379
- }): Promise<DispatchIntent | undefined>;
1380
- insertDispatchIfAbsent(dispatch: DispatchIntent): Promise<{
1381
- readonly dispatch: DispatchIntent;
1382
- readonly inserted: boolean;
1383
- }>;
1384
- saveDispatch(dispatch: DispatchIntent): Promise<void>;
1385
- findEffect(jobId: string, kind: string, marker: string): Promise<EffectIntent | undefined>;
1386
- insertEffectIfAbsent(effect: EffectIntent): Promise<{
1387
- readonly effect: EffectIntent;
1388
- readonly inserted: boolean;
1389
- }>;
1390
- saveEffect(effect: EffectIntent): Promise<void>;
1391
- getLease(repository: string, branch: string): Promise<BranchLease | undefined>;
1392
- /** Serialize lease acquisition even when no lease row exists yet. */
1393
- lockLeaseResource(repository: string, branch: string): Promise<void>;
1394
- saveLease(lease: BranchLease): Promise<void>;
1395
- findLeasesForJob(jobId: string): Promise<readonly BranchLease[]>;
1396
- findLeasesForRepository(repository: string): Promise<readonly BranchLease[]>;
1397
- getRepositoryControl(repository: string): Promise<RepositoryControl | undefined>;
1398
- saveRepositoryControl(control: RepositoryControl): Promise<void>;
1399
- }
1400
- interface CoordinatorStorage {
1401
- transaction<T>(operation: (transaction: CoordinatorStorageTransaction) => Promise<T>): Promise<T>;
1402
- }
1403
- interface CoordinatorClock {
1404
- now(): string;
1405
- nowMilliseconds(): number;
1406
- }
1407
- interface WorkflowCoordinatorOptions {
1408
- readonly storage: CoordinatorStorage;
1409
- readonly clock?: CoordinatorClock;
1410
- readonly idFactory?: (prefix: string) => string;
1411
- readonly infrastructureRetryLimit?: number;
1412
- readonly dispatchClaimTtlMs?: number;
1413
- readonly effectClaimTtlMs?: number;
1414
- }
1415
- interface DispatchRequest {
1416
- readonly repository: string;
1417
- readonly workerId: string;
1418
- /** Restrict dispatch to a known job/intent when a workflow runner is resuming. */
1419
- readonly jobId?: string;
1420
- readonly dispatchId?: string;
1421
- }
1422
- type DispatchBlockReason = "repository-stopped" | "job-paused" | "job-cancelled" | "job-superseded" | "authorization-withdrawn" | "authorization-pending" | "invalid-policy" | "semantic-budget-exhausted" | "infrastructure-retries-exhausted" | "invalid-transition";
1423
- interface IngestResult {
1424
- readonly disposition: "accepted" | "duplicate" | "out-of-order" | "ignored";
1425
- readonly event: StoredEvent;
1426
- readonly job?: WorkflowJob;
1427
- readonly dispatch?: DispatchIntent;
1428
- readonly reason?: EventIgnoreReason;
1429
- }
1430
- interface DispatchResult {
1431
- readonly status: "dispatched" | "none" | "blocked";
1432
- readonly dispatch?: DispatchIntent;
1433
- readonly assignment?: Assignment;
1434
- readonly job?: WorkflowJob;
1435
- readonly reason?: DispatchBlockReason;
1436
- }
1437
- interface AcquireBranchLeaseInput {
1438
- readonly repository: string;
1439
- readonly branch: string;
1440
- readonly jobId: string;
1441
- readonly workerId: string;
1442
- readonly ttlMs: number;
1443
- }
1444
- interface SubmitPhaseResultInput {
1445
- readonly jobId: string;
1446
- readonly result: PhaseResult;
1447
- /** Every non-duplicate result must be fenced by the worker's active lease. */
1448
- readonly lease: BranchLease;
1449
- }
1450
- interface SchedulePhaseInput {
1451
- readonly jobId: string;
1452
- readonly phase: WorkflowPhase;
1453
- readonly relevantRevision: string;
1454
- readonly head?: {
1455
- readonly branch: string;
1456
- readonly sha: string;
1457
- };
1458
- }
1459
- interface SchedulePhaseResult {
1460
- readonly status: "scheduled" | "duplicate" | "blocked";
1461
- readonly job: WorkflowJob;
1462
- readonly dispatch?: DispatchIntent;
1463
- readonly reason?: string;
1464
- }
1465
- interface PhaseResultSubmission {
1466
- readonly job: WorkflowJob;
1467
- readonly duplicate: boolean;
1468
- readonly transitioned: boolean;
1469
- }
1470
- interface InfrastructureFailureInput {
1471
- readonly jobId: string;
1472
- readonly assignmentId: string;
1473
- readonly error: string;
1474
- }
1475
- interface InfrastructureRetryResult {
1476
- readonly status: "retry-scheduled" | "exhausted" | "not-retryable";
1477
- readonly job: WorkflowJob;
1478
- readonly dispatch?: DispatchIntent;
1479
- }
1480
- interface RepairRequestResult {
1481
- readonly status: "scheduled" | "blocked" | "not-allowed";
1482
- readonly job: WorkflowJob;
1483
- readonly dispatch?: DispatchIntent;
1484
- readonly reason?: string;
1485
- }
1486
- interface EffectOperationContext {
1487
- readonly effect: EffectIntent;
1488
- readonly fencingToken: number;
1489
- }
1490
- interface PublishEffectInput<T> {
1491
- readonly jobId: string;
1492
- readonly lease: BranchLease;
1493
- /** Optional resource binding for effects that operate on a branch. */
1494
- readonly branch?: string;
1495
- /** Optional resource binding for effects that target the workflow item. */
1496
- readonly itemId?: string;
1497
- /** Optional candidate binding for effects that publish a commit head. */
1498
- readonly headSha?: string;
1499
- readonly kind: string;
1500
- readonly marker: string;
1501
- readonly payload?: unknown;
1502
- readonly reconcile?: (context: EffectOperationContext) => Promise<T | undefined>;
1503
- readonly publish: (context: EffectOperationContext) => Promise<T>;
1504
- }
1505
- interface EffectExecution<T> {
1506
- readonly disposition: "published" | "reconciled" | "already-succeeded" | "in-flight";
1507
- readonly effect: EffectIntent;
1508
- readonly externalRef?: T;
1509
- }
1510
-
1511
- /**
1512
- * Deterministic storage for coordinator tests. Each transaction runs against
1513
- * an isolated draft and commits atomically when the callback succeeds.
1514
- */
1515
- declare class InMemoryCoordinatorStorage implements CoordinatorStorage {
1516
- private state;
1517
- private transactionTail;
1518
- transaction<T>(operation: (transaction: CoordinatorStorageTransaction) => Promise<T>): Promise<T>;
1519
- }
1520
-
1521
- /** Minimal query surface implemented by `pg`, Neon, and compatible clients. */
1522
- interface PostgresQueryResult<Row extends Record<string, unknown> = Record<string, unknown>> {
1523
- readonly rows: readonly Row[];
1524
- readonly rowCount?: number | null;
1525
- }
1526
- interface PostgresQueryClient {
1527
- query<Row extends Record<string, unknown> = Record<string, unknown>>(text: string, values?: readonly unknown[]): Promise<PostgresQueryResult<Row>>;
1528
- }
1529
- interface PostgresConnection extends PostgresQueryClient {
1530
- release?: () => void;
1531
- }
1532
- interface PostgresCoordinatorStorageOptions {
1533
- /** A connected client or a pool with a transaction-scoped `connect()` method. */
1534
- readonly client: PostgresQueryClient & {
1535
- readonly connect?: () => Promise<PostgresConnection>;
1536
- };
1537
- }
1538
- /** PostgreSQL-backed implementation; schema installation remains an operator concern. */
1539
- declare class PostgresCoordinatorStorage implements CoordinatorStorage {
1540
- private readonly client;
1541
- constructor(options: PostgresCoordinatorStorageOptions);
1542
- transaction<T>(operation: (transaction: CoordinatorStorageTransaction) => Promise<T>): Promise<T>;
1543
- }
1544
-
1545
- declare class LeaseLostError extends Error {
1546
- constructor(message?: string);
1547
- }
1548
- declare class LeaseBusyError extends Error {
1549
- constructor(message: string);
1550
- }
1551
- declare class WorkflowCoordinator {
1552
- private readonly storage;
1553
- private readonly clock;
1554
- private readonly idFactory;
1555
- private readonly infrastructureRetryLimit;
1556
- private readonly dispatchClaimTtlMs;
1557
- private readonly effectClaimTtlMs;
1558
- constructor(options: WorkflowCoordinatorOptions);
1559
- getJob(jobId: string): Promise<WorkflowJob | undefined>;
1560
- getCurrentJob(identity: WorkIdentity): Promise<WorkflowJob | undefined>;
1561
- getRepositoryControl(repository: string): Promise<RepositoryControl | undefined>;
1562
- ingest(input: WorkflowEventInput): Promise<IngestResult>;
1563
- dispatchNext(request: DispatchRequest): Promise<DispatchResult>;
1564
- private latestHeadForRevision;
1565
- private dispatchBlockReason;
1566
- acquireBranchLease(input: AcquireBranchLeaseInput): Promise<BranchLease>;
1567
- heartbeatBranchLease(lease: BranchLease): Promise<BranchLease>;
1568
- private assertLease;
1569
- publishEffect<T>(input: PublishEffectInput<T>): Promise<EffectExecution<T>>;
1570
- private assertPublicationAllowed;
1571
- private finishEffect;
1572
- recordPhaseResult(input: SubmitPhaseResultInput): Promise<{
1573
- job: WorkflowJob;
1574
- duplicate: boolean;
1575
- transitioned: boolean;
1576
- }>;
1577
- recordInfrastructureFailure(input: InfrastructureFailureInput): Promise<InfrastructureRetryResult>;
1578
- setRepositoryStop(input: {
1579
- readonly repository: string;
1580
- readonly stopped: boolean;
1581
- readonly reason?: string;
1582
- }): Promise<RepositoryControl>;
1583
- pauseJob(jobId: string, reason?: string): Promise<WorkflowJob>;
1584
- cancelJob(jobId: string, reason?: string): Promise<WorkflowJob>;
1585
- supersedeJob(jobId: string, reason?: string): Promise<WorkflowJob>;
1586
- resumeJob(jobId: string): Promise<WorkflowJob>;
1587
- private updateJobControl;
1588
- schedulePhase(input: SchedulePhaseInput): Promise<SchedulePhaseResult>;
1589
- scheduleRepair(input: {
1590
- readonly jobId: string;
1591
- readonly brief: WorkBrief;
1592
- readonly policy: RepositoryPolicy;
1593
- readonly followUp?: boolean;
1594
- readonly relevantRevision?: string;
1595
- }): Promise<RepairRequestResult>;
1596
- private cancelStoredJob;
1597
- }
1598
-
1599
- interface TrustedPhaseInputs {
1600
- readonly brief: WorkBrief;
1601
- readonly policy: RepositoryPolicy;
1602
- readonly skill: {
1603
- readonly revision: string;
1604
- readonly content: string;
1605
- };
1606
- }
1607
- interface UntrustedPhaseInputs {
1608
- readonly sourceText: string;
1609
- readonly repositoryContent: readonly string[];
1610
- }
1611
- interface PhaseControls {
1612
- readonly toolAllowlist: readonly string[];
1613
- readonly credentialAllowlist: readonly string[];
1614
- readonly timeoutSeconds: number;
1615
- readonly maxIterations: number;
1616
- }
1617
- interface CredentialResolver {
1618
- resolve(name: string): Promise<string | undefined>;
1619
- }
1620
- declare class CredentialNotAllowedError extends Error {
1621
- constructor(name: string);
1622
- }
1623
- declare class CredentialUnavailableError extends Error {
1624
- constructor(name: string);
1625
- }
1626
- interface PhaseCredentials {
1627
- get(name: string): Promise<string>;
1628
- }
1629
- interface PhaseCheckout {
1630
- readonly branch: string;
1631
- readonly candidate?: RevisionReference;
1632
- readonly immutable: boolean;
1633
- }
1634
- interface PhaseEngineRequest {
1635
- readonly assignment: Assignment;
1636
- readonly agentSelection: AgentSelection;
1637
- readonly trusted: TrustedPhaseInputs;
1638
- readonly untrusted: UntrustedPhaseInputs;
1639
- readonly controls: PhaseControls;
1640
- readonly credentials: PhaseCredentials;
1641
- readonly signal: AbortSignal;
1642
- readonly checkout: PhaseCheckout;
1643
- readonly output?: OutputDefinition;
1644
- }
1645
- interface PhaseArtifact {
1646
- readonly name: string;
1647
- readonly kind: "stdout" | "stderr" | "patch" | "log" | "worktree" | "other";
1648
- readonly content: string;
1649
- }
1650
- interface ArtifactStore {
1651
- save(artifact: PhaseArtifact): Promise<void>;
1652
- }
1653
- interface InMemoryArtifactStore extends ArtifactStore {
1654
- readonly artifacts: PhaseArtifact[];
1655
- }
1656
- declare const createInMemoryArtifactStore: () => InMemoryArtifactStore;
1657
- interface PhaseReport {
1658
- readonly summary: string;
1659
- readonly evidence: readonly string[];
1660
- readonly checks: readonly CheckEvidence[];
1661
- readonly commits: readonly string[];
1662
- readonly artifacts: readonly string[];
1663
- readonly questions: readonly string[];
1664
- readonly findings: readonly Finding[];
1665
- readonly reviewAxes?: readonly ReviewAxis[];
1666
- }
1667
- interface PhaseEngineResponse {
1668
- readonly stdout: string;
1669
- readonly stderr?: string;
1670
- readonly completionSignal?: string;
1671
- /** Kept for adapters that already validate output; executePhase revalidates stdout. */
1672
- readonly structuredOutput?: unknown;
1673
- readonly commits: readonly (string | {
1674
- readonly sha: string;
1675
- })[];
1676
- readonly branch: string;
1677
- readonly headSha: string;
1678
- readonly report: PhaseReport;
1679
- readonly artifacts?: readonly PhaseArtifact[];
1680
- readonly preservedWorktreePath?: string;
1681
- readonly outcome?: "completed" | "needs-info";
1682
- }
1683
- interface PhaseEngineAdapter {
1684
- /**
1685
- * Execute one phase. After `request.signal` aborts, this promise MUST settle
1686
- * only after the provider has stopped all work that can mutate the candidate.
1687
- */
1688
- execute(request: PhaseEngineRequest): Promise<PhaseEngineResponse>;
1689
- }
1690
- interface FakePhaseEngineAdapterOptions {
1691
- readonly response?: PhaseEngineResponse;
1692
- readonly respond?: (request: PhaseEngineRequest) => Promise<PhaseEngineResponse>;
1693
- }
1694
- declare const createFakePhaseEngineAdapter: (options: FakePhaseEngineAdapterOptions) => PhaseEngineAdapter;
1695
- type PhaseExecutionStatus = "completed" | "needs-info" | "provider-failure" | "cancelled" | "timed-out" | "failed-verification";
1696
- interface PhaseFailure {
1697
- readonly kind: "provider" | "timeout" | "cancellation" | "validation";
1698
- readonly message: string;
1699
- }
1700
- interface PhaseExecutionResult {
1701
- readonly status: PhaseExecutionStatus;
1702
- readonly phaseResult: PhaseResult;
1703
- readonly output?: unknown;
1704
- readonly failure?: PhaseFailure;
1705
- }
1706
- interface ExecutePhaseOptions {
1707
- readonly assignment: Assignment;
1708
- /** Dedicated mutation branch for implementation and repair phases. */
1709
- readonly branch?: string;
1710
- readonly trusted: TrustedPhaseInputs;
1711
- readonly untrusted: UntrustedPhaseInputs;
1712
- readonly controls: PhaseControls;
1713
- readonly adapter: PhaseEngineAdapter;
1714
- readonly artifactStore: ArtifactStore;
1715
- readonly credentialResolver: CredentialResolver;
1716
- readonly output?: OutputDefinition;
1717
- readonly signal?: AbortSignal;
1718
- }
1719
- declare const executePhase: (options: ExecutePhaseOptions) => Promise<PhaseExecutionResult>;
1720
- type PhaseAgentResolver = {
1721
- /** Pre-resolved provider for legacy single-model policies. */
1722
- readonly agent: AgentProvider;
1723
- readonly resolveAgent?: never;
1724
- } | {
1725
- readonly agent?: never;
1726
- /** Creates the provider selected by the assignment's trusted policy. */
1727
- readonly resolveAgent: (selection: AgentSelection) => AgentProvider;
1728
- };
1729
- type RunPhaseEngineAdapterOptions = PhaseAgentResolver & {
1730
- readonly sandbox: SandboxProvider;
1731
- readonly cwd?: string;
1732
- readonly run: (options: RunOptions) => Promise<RunResult & {
1733
- output?: unknown;
1734
- }>;
1735
- };
1736
- declare const createRunPhaseEngineAdapter: (options: RunPhaseEngineAdapterOptions) => PhaseEngineAdapter;
1737
- type CreateSandboxPhaseEngineAdapterOptions = PhaseAgentResolver & {
1738
- readonly sandbox: SandboxProvider;
1739
- readonly cwd?: string;
1740
- readonly createSandbox: (options: CreateSandboxOptions) => Promise<Sandbox>;
1741
- };
1742
- declare const createCreateSandboxPhaseEngineAdapter: (options: CreateSandboxPhaseEngineAdapterOptions) => PhaseEngineAdapter;
1743
-
1744
- interface HandoffCandidate {
1745
- readonly base: RevisionReference;
1746
- readonly head: RevisionReference;
1747
- readonly briefHash: string;
1748
- }
1749
- interface BranchProtectionState {
1750
- readonly enforced: boolean;
1751
- readonly humanApprovalRequired: boolean;
1752
- /** Fresh provider evidence; caller-supplied booleans alone are not a merge gate. */
1753
- readonly provider: "github";
1754
- readonly verifiedAt: string;
1755
- }
1756
- interface HumanApproval {
1757
- readonly actor: string;
1758
- readonly actorRole: "owner" | "maintainer";
1759
- readonly approvedAt: string;
1760
- readonly baseSha: string;
1761
- readonly headSha: string;
1762
- readonly briefHash: string;
1763
- }
1764
- interface HandoffReadinessInput {
1765
- readonly job: WorkflowJob;
1766
- readonly candidate: HandoffCandidate;
1767
- readonly checks: readonly CheckEvidence[];
1768
- readonly review: ReviewEvidence;
1769
- readonly requiredAxes?: readonly ReviewAxis[];
1770
- readonly branchProtection?: BranchProtectionState;
1771
- readonly humanApproval?: HumanApproval;
1772
- readonly now?: () => string;
1773
- readonly freshnessWindowSeconds?: number;
1774
- }
1775
- interface HandoffPacket {
1776
- readonly sourceIssue: string;
1777
- readonly pullRequest?: string;
1778
- readonly candidate: HandoffCandidate;
1779
- readonly briefRevision: number;
1780
- readonly briefHash: string;
1781
- readonly change: string;
1782
- readonly risk: WorkBrief["risk"];
1783
- readonly acceptanceCriteria: readonly string[];
1784
- readonly acceptanceEvidence: readonly string[];
1785
- readonly checks: readonly CheckEvidence[];
1786
- readonly reviewAxes: readonly ReviewAxis[];
1787
- readonly findings: readonly Finding[];
1788
- readonly limitations: readonly string[];
1789
- }
1790
- type HandoffOutcome = "blocked" | "ready-for-review" | "review-requested"
1791
- /** Retained for source-item triage; PR handoff uses ready-for-review. */
1792
- | "ready-for-human" | "repair-needed" | "rejected" | "abandoned" | "merge-ready" | "merged" | "open";
1793
- interface HandoffReadinessResult {
1794
- readonly outcome: "blocked" | "ready-for-review" | "review-requested" | "merge-ready";
1795
- readonly readyForReview: boolean;
1796
- readonly reviewRequested: boolean;
1797
- readonly readyForHuman: boolean;
1798
- readonly mergeReady: boolean;
1799
- readonly reasons: readonly string[];
1800
- readonly packet: HandoffPacket;
1801
- }
1802
- interface HumanHandoffPublisher {
1803
- requestReview(input: {
1804
- readonly packet: HandoffPacket;
1805
- readonly pullRequestNumber: number;
1806
- }): Promise<void>;
1807
- }
1808
- interface PrepareHandoffOptions extends HandoffReadinessInput {
1809
- readonly sourceIssueNumber: number;
1810
- readonly pullRequestNumber: number;
1811
- readonly publisher?: HumanHandoffPublisher;
1812
- readonly readCurrent?: () => Promise<HandoffCandidate>;
1813
- }
1814
- interface HumanReviewDecisionInput {
1815
- readonly decision: "approved" | "changes-requested" | "rejected" | "abandoned";
1816
- readonly reason?: string;
1817
- }
1818
- interface HumanReviewDecision {
1819
- readonly outcome: Extract<HandoffOutcome, "merge-ready" | "repair-needed" | "rejected" | "abandoned">;
1820
- readonly reason?: string;
1821
- }
1822
- interface HumanReviewRoundTripOptions {
1823
- readonly candidate: HandoffCandidate;
1824
- readonly pullRequestNumber: number;
1825
- readonly decision: HumanReviewDecisionInput;
1826
- /** Re-reads the PR head and brief before applying the human decision. */
1827
- readonly readCurrent: () => Promise<HandoffCandidate>;
1828
- /** Keeps a requested-changes repair on the existing PR branch. */
1829
- readonly requestRepair: (input: {
1830
- readonly candidate: HandoffCandidate;
1831
- readonly pullRequestNumber: number;
1832
- readonly reason: string;
1833
- }) => Promise<void>;
1834
- }
1835
- interface HumanReviewRoundTripResult {
1836
- readonly outcome: "blocked" | Extract<HandoffOutcome, "merge-ready" | "repair-needed" | "rejected" | "abandoned">;
1837
- readonly reason?: string;
1838
- readonly candidate: HandoffCandidate;
1839
- readonly pullRequestNumber: number;
1840
- }
1841
- interface MergeTransport {
1842
- mergeProtected(input: {
1843
- readonly pullRequestNumber: number;
1844
- readonly headSha: string;
1845
- readonly baseBranch: string;
1846
- }): Promise<{
1847
- readonly mergedSha: string;
1848
- }>;
1849
- }
1850
- interface MergeCandidateOptions extends Omit<HandoffReadinessInput, "branchProtection"> {
1851
- readonly pullRequestNumber: number;
1852
- readonly humanApproval: HumanApproval;
1853
- /** Re-reads the PR, branch and brief identity immediately before merging. */
1854
- readonly readCurrent: () => Promise<HandoffCandidate>;
1855
- /** Fetches fresh provider evidence immediately before a protected merge. */
1856
- readonly readBranchProtection: () => Promise<BranchProtectionState>;
1857
- readonly transport: MergeTransport;
1858
- }
1859
- interface MergeResult {
1860
- readonly outcome: "blocked" | "merged";
1861
- readonly reason?: string;
1862
- readonly mergedSha?: string;
1863
- }
1864
- interface CompletionInput {
1865
- readonly policy: RepositoryPolicy;
1866
- readonly mergedSha: string;
1867
- readonly candidate: HandoffCandidate;
1868
- readonly checks: readonly CheckEvidence[];
1869
- }
1870
- interface CompletionResult {
1871
- readonly outcome: "completed" | "open";
1872
- readonly reason?: string;
1873
- readonly mergedSha: string;
1874
- readonly checks: readonly CheckEvidence[];
1875
- }
1876
- interface SourceIssueCloser {
1877
- closeIssue(input: {
1878
- readonly issueNumber: number;
1879
- readonly mergedSha: string;
1880
- readonly checks: readonly CheckEvidence[];
1881
- }): Promise<void>;
1882
- }
1883
- interface CloseSourceIssueOptions extends CompletionInput {
1884
- readonly sourceIssueNumber: number;
1885
- readonly closer: SourceIssueCloser;
1886
- }
1887
- interface SourceIssueClosureResult extends CompletionResult {
1888
- readonly closed: boolean;
1889
- }
1890
- declare const evaluateHandoffReadiness: (input: HandoffReadinessInput) => HandoffReadinessResult;
1891
- declare const prepareHumanHandoff: (input: PrepareHandoffOptions) => Promise<HandoffReadinessResult>;
1892
- declare const resolveHumanReviewDecision: (input: HumanReviewDecisionInput) => HumanReviewDecision;
1893
- declare const processHumanReviewDecision: (input: HumanReviewRoundTripOptions) => Promise<HumanReviewRoundTripResult>;
1894
- declare const mergeProtectedCandidate: (input: MergeCandidateOptions) => Promise<MergeResult>;
1895
- declare const completeSourceIssue: (input: CompletionInput) => CompletionResult;
1896
- declare const closeSourceIssue: (input: CloseSourceIssueOptions) => Promise<SourceIssueClosureResult>;
1897
-
1898
- interface GitHubWebhookSignatureInput {
1899
- readonly body: string | Uint8Array;
1900
- readonly signature?: string;
1901
- readonly secret: string | Uint8Array;
1902
- }
1903
- /**
1904
- * Verifies GitHub's `X-Hub-Signature-256` value without exposing the secret.
1905
- * Malformed values are compared against a same-sized zero buffer so the final
1906
- * digest comparison always uses the constant-time primitive.
1907
- */
1908
- declare const verifyGitHubWebhookSignature: (input: GitHubWebhookSignatureInput) => boolean;
1909
-
1910
- type TriageCategory = "bug" | "enhancement" | "support" | "duplicate" | "sensitive" | "non-actionable";
1911
- type TriageOutcome = "completed" | "needs-info" | "duplicate" | "sensitive" | "non-actionable" | "blocked" | "failed";
1912
- interface TriageSource {
1913
- readonly provider: "github" | "slack" | "manual";
1914
- readonly repository: string;
1915
- readonly itemId: string;
1916
- readonly title: string;
1917
- readonly body: string;
1918
- readonly author?: string;
1919
- readonly url?: string;
1920
- readonly updatedAt: string;
1921
- readonly kind?: WorkItemKind;
1922
- readonly labels?: readonly string[];
1923
- }
1924
- interface ClarificationReply {
1925
- readonly id: string;
1926
- readonly body: string;
1927
- readonly author?: string;
1928
- readonly updatedAt: string;
1929
- }
1930
- interface TriageAssessment {
1931
- readonly category: TriageCategory;
1932
- readonly evidence: readonly string[];
1933
- readonly relevantFiles: readonly string[];
1934
- readonly acceptanceCriteria: readonly string[];
1935
- readonly exclusions: readonly string[];
1936
- readonly risk: RiskLevel;
1937
- readonly verification: readonly string[];
1938
- readonly unresolvedQuestions: readonly string[];
1939
- readonly requirementsConfirmed: boolean;
1940
- readonly duplicateOf?: string;
1941
- readonly sensitiveReason?: string;
1942
- }
1943
- interface TriageInvestigationRequest {
1944
- readonly source: TriageSource;
1945
- readonly policy: RepositoryPolicy;
1946
- readonly base: RevisionReference;
1947
- readonly previous?: TriageRecord;
1948
- readonly clarificationReply?: ClarificationReply;
1949
- }
1950
- type TriageInvestigator = ((request: TriageInvestigationRequest) => Promise<TriageAssessment>) | {
1951
- investigate(request: TriageInvestigationRequest): Promise<TriageAssessment>;
1952
- };
1953
- interface TriageRecord {
1954
- readonly id: string;
1955
- readonly sourceKey: string;
1956
- /** Retained for durable investigation and resumption; never used as public output. */
1957
- readonly source: TriageSource;
1958
- readonly sourceUpdatedAt: string;
1959
- readonly sourceFingerprint: string;
1960
- readonly revision: number;
1961
- readonly category: TriageCategory;
1962
- readonly outcome: TriageOutcome;
1963
- readonly assessment: TriageAssessment;
1964
- readonly brief?: WorkBrief;
1965
- readonly questions: readonly string[];
1966
- readonly clarificationIds: readonly string[];
1967
- readonly duplicateOf?: string;
1968
- readonly publicMessage: string;
1969
- readonly createdAt: string;
1970
- readonly updatedAt: string;
1971
- }
1972
- interface TriageStore {
1973
- get(sourceKey: string): TriageRecord | undefined;
1974
- save(record: TriageRecord): void;
1975
- }
1976
- declare class InMemoryTriageStore implements TriageStore {
1977
- private readonly records;
1978
- get(sourceKey: string): TriageRecord | undefined;
1979
- save(record: TriageRecord): void;
1980
- }
1981
- interface RunTriageOptions {
1982
- readonly source: TriageSource;
1983
- readonly policy: RepositoryPolicy;
1984
- readonly base: RevisionReference;
1985
- readonly store: TriageStore;
1986
- readonly investigator?: TriageInvestigator;
1987
- readonly clarificationReply?: ClarificationReply;
1988
- readonly now?: () => string;
1989
- }
1990
- interface TriageResult {
1991
- readonly outcome: TriageOutcome;
1992
- readonly category: TriageCategory;
1993
- readonly brief?: WorkBrief;
1994
- readonly questions: readonly string[];
1995
- readonly publicMessage: string;
1996
- readonly record: TriageRecord;
1997
- readonly implementationEligible: boolean;
1998
- }
1999
- declare const defaultInvestigator: TriageInvestigator;
2000
- declare const runTriage: ({ source: rawSource, policy, base, store, investigator, clarificationReply, now, }: RunTriageOptions) => Promise<TriageResult>;
2001
-
2002
- type GitHubEventName = "issues" | "issue_comment" | "pull_request" | "pull_request_review" | "pull_request_review_comment" | "check_run" | "check_suite";
2003
- type GitHubActorType = "User" | "Bot" | "Organization" | string;
2004
- interface GitHubActor {
2005
- readonly login: string;
2006
- readonly type?: GitHubActorType;
2007
- }
2008
- interface GitHubIssueSnapshot {
2009
- readonly number: number;
2010
- readonly title: string;
2011
- readonly body: string;
2012
- readonly state: "open" | "closed";
2013
- readonly updatedAt: string;
2014
- readonly htmlUrl?: string;
2015
- readonly authorLogin?: string;
2016
- readonly labels: readonly string[];
2017
- readonly pullRequestNumber?: number;
2018
- }
2019
- interface GitHubCommentSnapshot {
2020
- readonly id: string;
2021
- readonly body: string;
2022
- readonly updatedAt: string;
2023
- readonly htmlUrl?: string;
2024
- readonly authorLogin?: string;
2025
- }
2026
- interface GitHubPullRequestSnapshot {
2027
- readonly number: number;
2028
- readonly title: string;
2029
- readonly body: string;
2030
- readonly state: "open" | "closed";
2031
- readonly draft: boolean;
2032
- readonly branch: string;
2033
- readonly baseBranch: string;
2034
- readonly headSha: string;
2035
- readonly updatedAt: string;
2036
- readonly htmlUrl?: string;
2037
- readonly authorLogin?: string;
2038
- }
2039
- type GitHubPullRequestReviewState = "approved" | "changes-requested" | "commented" | "dismissed" | "pending";
2040
- interface GitHubPullRequestReviewSnapshot {
2041
- readonly id: string;
2042
- readonly state: GitHubPullRequestReviewState;
2043
- readonly headSha: string;
2044
- readonly submittedAt: string;
2045
- readonly authorLogin?: string;
2046
- }
2047
- interface GitHubBranchSnapshot {
2048
- readonly name: string;
2049
- readonly headSha: string;
2050
- readonly htmlUrl?: string;
2051
- }
2052
- interface GitHubCheckSnapshot {
2053
- readonly id: string;
2054
- readonly name: string;
2055
- readonly headSha: string;
2056
- readonly status: "queued" | "in_progress" | "completed";
2057
- readonly conclusion?: "success" | "failure" | "neutral" | "cancelled" | "timed_out" | "action_required" | "stale" | "skipped";
2058
- readonly htmlUrl?: string;
2059
- }
2060
- interface GitHubWebhookRequest {
2061
- readonly body: string | Uint8Array;
2062
- readonly headers: Readonly<Record<string, string | undefined>>;
2063
- }
2064
- interface GitHubWebhookEnvelope {
2065
- readonly eventName: string;
2066
- readonly deliveryId: string;
2067
- readonly payload: unknown;
2068
- readonly receivedAt: string;
2069
- }
2070
- interface GitHubAuthorizationPolicy {
2071
- /** Exact repository names allowed to produce workflow input. */
2072
- readonly allowedRepositories: readonly string[];
2073
- /** Exact GitHub logins allowed to submit workflow input. */
2074
- readonly allowedSenders: readonly string[];
2075
- /** Exact GitHub logins allowed to approve or request changes on tracked pull requests. */
2076
- readonly allowedReviewers: readonly string[];
2077
- /** Additional service logins treated as bot-originated. */
2078
- readonly botLogins?: readonly string[];
2079
- }
2080
- interface GitHubBriefDefaults {
2081
- readonly risk?: RiskLevel;
2082
- readonly acceptanceCriteria?: readonly string[];
2083
- readonly exclusions?: readonly string[];
2084
- readonly unresolvedQuestions?: readonly string[];
2085
- readonly verificationArtifacts?: readonly string[];
2086
- }
2087
- type GitHubIssueEventKind = "issue-created" | "issue-edited" | "issue-replied";
2088
- type GitHubTrackedPullRequestEventKind = "tracked-pr-updated";
2089
- type GitHubNormalizedEventKind = GitHubIssueEventKind | GitHubTrackedPullRequestEventKind;
2090
- type GitHubEventIgnoreReason = "unsupported-event" | "unsupported-action" | "bot-originated" | "unrelated-pull-request";
2091
- interface GitHubNormalizedEvent {
2092
- readonly kind: GitHubNormalizedEventKind;
2093
- readonly eventName: GitHubEventName;
2094
- readonly action: string;
2095
- readonly deliveryId: string;
2096
- readonly repository: string;
2097
- readonly sender: GitHubActor;
2098
- readonly issueNumber: number;
2099
- readonly pullRequestNumber?: number;
2100
- readonly title: string;
2101
- readonly body: string;
2102
- readonly labels: readonly string[];
2103
- readonly relevantRevision: string;
2104
- readonly observedAt: string;
2105
- readonly sourceState: "open" | "closed";
2106
- readonly reply?: GitHubCommentSnapshot;
2107
- readonly review?: GitHubPullRequestReviewSnapshot;
2108
- readonly trackedPullRequest?: GitHubTrackedPullRequest;
2109
- readonly workflowEvent: WorkflowEventInput;
2110
- }
2111
- interface GitHubIgnoredEvent {
2112
- readonly disposition: "ignored";
2113
- readonly reason: GitHubEventIgnoreReason;
2114
- readonly eventName: string;
2115
- readonly action?: string;
2116
- readonly deliveryId: string;
2117
- readonly repository: string;
2118
- readonly sender: GitHubActor;
2119
- }
2120
- type GitHubNormalizationResult = {
2121
- readonly disposition: "accepted";
2122
- readonly event: GitHubNormalizedEvent;
2123
- } | GitHubIgnoredEvent;
2124
- type GitHubDeliveryStatus = "received" | "accepted" | "ignored" | "rejected";
2125
- interface GitHubDeliveryRecord {
2126
- readonly deliveryId: string;
2127
- readonly eventName: string;
2128
- readonly repository: string;
2129
- readonly senderLogin: string;
2130
- readonly receivedAt: string;
2131
- readonly payloadHash: string;
2132
- readonly payload: unknown;
2133
- readonly status: GitHubDeliveryStatus;
2134
- readonly eventKind?: GitHubNormalizedEventKind;
2135
- readonly reason?: string;
2136
- readonly jobId?: string;
2137
- }
2138
- interface GitHubDeliveryStore {
2139
- recordDeliveryIfAbsent(delivery: GitHubDeliveryRecord): Promise<{
2140
- readonly delivery: GitHubDeliveryRecord;
2141
- readonly inserted: boolean;
2142
- }>;
2143
- getDelivery(deliveryId: string): Promise<GitHubDeliveryRecord | undefined>;
2144
- updateDelivery(delivery: GitHubDeliveryRecord): Promise<void>;
2145
- }
2146
- interface GitHubTrackedPullRequest {
2147
- readonly repository: string;
2148
- readonly pullRequestNumber: number;
2149
- readonly jobId: string;
2150
- readonly itemId: string;
2151
- readonly branch: string;
2152
- readonly headSha: string;
2153
- readonly marker: string;
2154
- readonly brief: WorkBrief;
2155
- readonly policy: RepositoryPolicy;
2156
- readonly createdAt: string;
2157
- }
2158
- interface GitHubPullRequestReviewHandler {
2159
- readCurrent(input: {
2160
- readonly candidate: HandoffCandidate;
2161
- readonly trackedPullRequest: GitHubTrackedPullRequest;
2162
- }): Promise<HandoffCandidate>;
2163
- requestRepair(input: {
2164
- readonly candidate: HandoffCandidate;
2165
- readonly pullRequestNumber: number;
2166
- readonly reason: string;
2167
- }): Promise<void>;
2168
- }
2169
- interface GitHubTrackingStore {
2170
- findTrackedPullRequest(repository: string, pullRequestNumber: number): Promise<GitHubTrackedPullRequest | undefined>;
2171
- saveTrackedPullRequest(pullRequest: GitHubTrackedPullRequest): Promise<void>;
2172
- }
2173
- interface GitHubBriefFactoryInput {
2174
- readonly event: Omit<GitHubNormalizedEvent, "workflowEvent">;
2175
- readonly itemKind: "planning-spec" | "executable-issue" | "pr-repair";
2176
- readonly policy: RepositoryPolicy;
2177
- readonly base: RevisionReference;
2178
- readonly authorization: Authorization;
2179
- readonly revision: number;
2180
- readonly defaults?: GitHubBriefDefaults;
2181
- }
2182
- type GitHubBriefFactory = (input: GitHubBriefFactoryInput) => WorkBrief;
2183
- interface GitHubIntegrationOptions {
2184
- readonly coordinator: WorkflowCoordinator;
2185
- readonly policy: RepositoryPolicy;
2186
- readonly base: RevisionReference;
2187
- readonly authorization: GitHubAuthorizationPolicy;
2188
- readonly deliveryStore: GitHubDeliveryStore;
2189
- readonly webhookSecret: string | Uint8Array;
2190
- readonly trackingStore?: GitHubTrackingStore;
2191
- /** Review events fail closed unless the caller wires candidate-bound handoff handling. */
2192
- readonly reviewHandler?: GitHubPullRequestReviewHandler;
2193
- readonly briefDefaults?: GitHubBriefDefaults;
2194
- readonly briefFactory?: GitHubBriefFactory;
2195
- /** Optional automatic investigation adapter; absent means intake remains raw triage. */
2196
- readonly triage?: {
2197
- readonly store: TriageStore;
2198
- readonly investigator?: TriageInvestigator;
2199
- };
2200
- readonly now?: () => string;
2201
- }
2202
- interface GitHubWebhookReceipt {
2203
- readonly status: "accepted" | "duplicate" | "ignored" | "rejected";
2204
- readonly deliveryId: string;
2205
- readonly reason?: string;
2206
- readonly event?: GitHubNormalizedEvent;
2207
- readonly ingest?: IngestResult;
2208
- readonly review?: HumanReviewRoundTripResult;
2209
- }
2210
- interface GitHubReconciliationInput {
2211
- readonly repository: string;
2212
- readonly issueNumber?: number;
2213
- readonly pullRequestNumber?: number;
2214
- readonly transport: GitHubReadTransport;
2215
- }
2216
- interface GitHubReconciliationResult {
2217
- readonly status: "accepted" | "duplicate" | "ignored" | "not-found";
2218
- readonly deliveryId: string;
2219
- readonly reason?: string;
2220
- readonly event?: GitHubNormalizedEvent;
2221
- readonly ingest?: IngestResult;
2222
- }
2223
- interface GitHubReadTransport {
2224
- fetchIssue(input: {
2225
- readonly repository: string;
2226
- readonly issueNumber: number;
2227
- }): Promise<GitHubIssueSnapshot | undefined>;
2228
- fetchPullRequest(input: {
2229
- readonly repository: string;
2230
- readonly pullRequestNumber: number;
2231
- }): Promise<GitHubPullRequestSnapshot | undefined>;
2232
- findCommentByMarker(input: {
2233
- readonly repository: string;
2234
- readonly issueNumber: number;
2235
- readonly marker: string;
2236
- }): Promise<GitHubCommentSnapshot | undefined>;
2237
- findBranchByName(input: {
2238
- readonly repository: string;
2239
- readonly branch: string;
2240
- }): Promise<GitHubBranchSnapshot | undefined>;
2241
- findPullRequestByMarker(input: {
2242
- readonly repository: string;
2243
- readonly marker: string;
2244
- }): Promise<GitHubPullRequestSnapshot | undefined>;
2245
- findCheckByMarker(input: {
2246
- readonly repository: string;
2247
- readonly marker: string;
2248
- readonly headSha: string;
2249
- }): Promise<GitHubCheckSnapshot | undefined>;
2250
- findIssueByMarker(input: {
2251
- readonly repository: string;
2252
- readonly marker: string;
2253
- }): Promise<GitHubIssueSnapshot | undefined>;
2254
- }
2255
- interface GitHubWriteTransport {
2256
- createComment(input: {
2257
- readonly repository: string;
2258
- readonly issueNumber: number;
2259
- readonly body: string;
2260
- }): Promise<GitHubCommentSnapshot>;
2261
- createBranch(input: {
2262
- readonly repository: string;
2263
- readonly branch: string;
2264
- readonly headSha: string;
2265
- readonly marker: string;
2266
- }): Promise<GitHubBranchSnapshot>;
2267
- createPullRequest(input: {
2268
- readonly repository: string;
2269
- readonly title: string;
2270
- readonly body: string;
2271
- readonly branch: string;
2272
- readonly baseBranch: string;
2273
- readonly draft: boolean;
2274
- readonly marker: string;
2275
- }): Promise<GitHubPullRequestSnapshot>;
2276
- createCheck(input: {
2277
- readonly repository: string;
2278
- readonly name: string;
2279
- readonly headSha: string;
2280
- readonly marker: string;
2281
- readonly status: GitHubCheckSnapshot["status"];
2282
- readonly conclusion?: GitHubCheckSnapshot["conclusion"];
2283
- readonly summary: string;
2284
- }): Promise<GitHubCheckSnapshot>;
2285
- createRepairIssue(input: {
2286
- readonly repository: string;
2287
- readonly title: string;
2288
- readonly body: string;
2289
- readonly marker: string;
2290
- readonly labels: readonly string[];
2291
- }): Promise<GitHubIssueSnapshot>;
2292
- }
2293
- interface GitHubPublicationOptions {
2294
- readonly coordinator: WorkflowCoordinator;
2295
- readonly transport: GitHubReadTransport & GitHubWriteTransport;
2296
- readonly trackingStore: GitHubTrackingStore;
2297
- readonly now?: () => string;
2298
- }
2299
- interface GitHubPublicationResult<T> {
2300
- readonly marker: string;
2301
- readonly remote: T | undefined;
2302
- readonly disposition: EffectExecution<T>["disposition"];
2303
- readonly effect: EffectIntent;
2304
- }
2305
- interface GitHubCommentPublicationInput {
2306
- readonly jobId: string;
2307
- readonly lease: BranchLease;
2308
- readonly issueNumber: number;
2309
- readonly body: string;
2310
- readonly key?: string;
2311
- }
2312
- interface GitHubBriefPublicationInput {
2313
- readonly jobId: string;
2314
- readonly lease: BranchLease;
2315
- readonly issueNumber: number;
2316
- readonly brief: WorkBrief;
2317
- }
2318
- interface GitHubBranchPublicationInput {
2319
- readonly jobId: string;
2320
- readonly lease: BranchLease;
2321
- readonly branch: string;
2322
- readonly headSha: string;
2323
- }
2324
- interface GitHubPullRequestPublicationInput {
2325
- readonly jobId: string;
2326
- readonly lease: BranchLease;
2327
- readonly title: string;
2328
- readonly body: string;
2329
- readonly branch: string;
2330
- readonly baseBranch: string;
2331
- readonly headSha: string;
2332
- readonly draft?: boolean;
2333
- }
2334
- interface GitHubCheckPublicationInput {
2335
- readonly jobId: string;
2336
- readonly lease: BranchLease;
2337
- /** Candidate branch used to bind the check to the active lease. */
2338
- readonly branch?: string;
2339
- readonly name: string;
2340
- readonly headSha: string;
2341
- readonly status: GitHubCheckSnapshot["status"];
2342
- readonly conclusion?: GitHubCheckSnapshot["conclusion"];
2343
- readonly summary: string;
2344
- readonly key?: string;
2345
- }
2346
- interface GitHubRepairIssuePublicationInput {
2347
- readonly jobId: string;
2348
- readonly lease: BranchLease;
2349
- readonly title: string;
2350
- readonly body: string;
2351
- readonly labels?: readonly string[];
2352
- }
2353
- interface GitHubRepairLinkPublicationInput {
2354
- readonly jobId: string;
2355
- readonly lease: BranchLease;
2356
- readonly issueNumber: number;
2357
- readonly repairIssueUrl: string;
2358
- }
2359
-
2360
- /**
2361
- * Small in-memory adapter for tests and local development. Production callers
2362
- * should provide a durable adapter with the same atomic insert semantics.
2363
- */
2364
- declare class InMemoryGitHubStore implements GitHubDeliveryStore, GitHubTrackingStore {
2365
- private readonly deliveries;
2366
- private readonly trackedPullRequests;
2367
- recordDeliveryIfAbsent(delivery: GitHubDeliveryRecord): Promise<{
2368
- readonly delivery: GitHubDeliveryRecord;
2369
- readonly inserted: boolean;
2370
- }>;
2371
- getDelivery(deliveryId: string): Promise<GitHubDeliveryRecord | undefined>;
2372
- updateDelivery(delivery: GitHubDeliveryRecord): Promise<void>;
2373
- findTrackedPullRequest(repository: string, pullRequestNumber: number): Promise<GitHubTrackedPullRequest | undefined>;
2374
- saveTrackedPullRequest(pullRequest: GitHubTrackedPullRequest): Promise<void>;
2375
- }
2376
-
2377
- declare const reviewDecisionFor: (review: GitHubPullRequestReviewSnapshot) => HumanReviewDecisionInput | undefined;
2378
- declare const createGitHubIssueBrief: (input: GitHubBriefFactoryInput) => WorkBrief;
2379
- declare class GitHubIntegration {
2380
- private readonly options;
2381
- private readonly now;
2382
- constructor(options: GitHubIntegrationOptions);
2383
- receiveWebhook(request: GitHubWebhookRequest): Promise<GitHubWebhookReceipt>;
2384
- normalize(envelope: GitHubWebhookEnvelope): Promise<GitHubNormalizationResult>;
2385
- reconcile(input: GitHubReconciliationInput): Promise<GitHubReconciliationResult>;
2386
- private processEnvelope;
2387
- private rejectStored;
2388
- private ignoreStored;
2389
- private briefForIssue;
2390
- private normalizeTrackedPullRequest;
2391
- private issuePayload;
2392
- private pullRequestPayload;
2393
- private toReconciliationResult;
2394
- }
2395
-
2396
- /** Coordinator-owned GitHub effects with stable markers and remote reconciliation. */
2397
- declare class GitHubPublication {
2398
- private readonly options;
2399
- constructor(options: GitHubPublicationOptions);
2400
- publishComment(input: GitHubCommentPublicationInput): Promise<GitHubPublicationResult<GitHubCommentSnapshot>>;
2401
- publishBrief(input: GitHubBriefPublicationInput): Promise<GitHubPublicationResult<GitHubCommentSnapshot>>;
2402
- publishBranch(input: GitHubBranchPublicationInput): Promise<GitHubPublicationResult<GitHubBranchSnapshot>>;
2403
- publishPullRequest(input: GitHubPullRequestPublicationInput): Promise<GitHubPublicationResult<GitHubPullRequestSnapshot>>;
2404
- publishCheck(input: GitHubCheckPublicationInput): Promise<GitHubPublicationResult<GitHubCheckSnapshot>>;
2405
- publishRepairIssue(input: GitHubRepairIssuePublicationInput): Promise<GitHubPublicationResult<GitHubIssueSnapshot>>;
2406
- publishRepairLink(input: GitHubRepairLinkPublicationInput): Promise<GitHubPublicationResult<GitHubCommentSnapshot>>;
2407
- }
2408
-
2409
- type ReviewRunOutcome = "passed" | "actionable-findings" | "incomplete" | "blocked" | "failed";
2410
- interface ReviewCandidate {
2411
- readonly base: RevisionReference;
2412
- readonly head: RevisionReference;
2413
- readonly brief: WorkBrief;
2414
- readonly policy: RepositoryPolicy;
2415
- readonly requiredAxes?: readonly ReviewAxis[];
2416
- }
2417
- interface ReviewCheckout {
2418
- readonly base: RevisionReference;
2419
- readonly candidate: RevisionReference;
2420
- readonly immutable: true;
2421
- }
2422
- interface ReviewRequest {
2423
- readonly candidate: ReviewCandidate;
2424
- readonly checkout: ReviewCheckout;
2425
- readonly signal: AbortSignal;
2426
- }
2427
- interface ReviewFindingInput {
2428
- readonly id: string;
2429
- readonly severity: FindingSeverity;
2430
- readonly axis: ReviewAxis;
2431
- readonly title: string;
2432
- readonly evidence: string;
2433
- readonly location?: string;
2434
- readonly requirement?: string;
2435
- readonly verification?: string;
2436
- }
2437
- interface ReviewResponse {
2438
- readonly outcome?: ReviewRunOutcome;
2439
- readonly axes: readonly ReviewAxis[];
2440
- readonly findings: readonly ReviewFindingInput[];
2441
- readonly evidence: readonly string[];
2442
- readonly headSha: string;
2443
- readonly baseSha?: string;
2444
- readonly briefHash: string;
2445
- /** Any returned commit or changed file means the reviewer violated read-only review. */
2446
- readonly commits?: readonly string[];
2447
- readonly changedFiles?: readonly string[];
2448
- }
2449
- interface ReviewProvider {
2450
- review(request: ReviewRequest): Promise<ReviewResponse>;
2451
- }
2452
- interface CurrentCandidate {
2453
- readonly base: RevisionReference;
2454
- readonly head: RevisionReference;
2455
- readonly briefHash: string;
2456
- }
2457
- interface IndependentReviewOptions {
2458
- readonly candidate: ReviewCandidate;
2459
- readonly provider: ReviewProvider;
2460
- readonly readCurrent?: () => Promise<CurrentCandidate>;
2461
- readonly signal?: AbortSignal;
2462
- }
2463
- interface ReviewFailure {
2464
- readonly kind: "provider" | "malformed" | "stale-candidate" | "mutation";
2465
- readonly message: string;
2466
- }
2467
- interface IndependentReviewResult {
2468
- readonly outcome: ReviewRunOutcome;
2469
- readonly candidate: ReviewCandidate;
2470
- readonly reviewAxes: readonly ReviewAxis[];
2471
- readonly findings: readonly Finding[];
2472
- readonly evidence: readonly string[];
2473
- readonly reviewEvidence: ReviewEvidence;
2474
- readonly failure?: ReviewFailure;
2475
- }
2476
- /** Run a read-only, candidate-bound review and normalize its evidence. */
2477
- declare const runIndependentReview: (options: IndependentReviewOptions) => Promise<IndependentReviewResult>;
2478
-
2479
- interface CurrentImplementationCandidate {
2480
- readonly base: RevisionReference;
2481
- readonly briefHash: string;
2482
- }
2483
- interface ImplementationExecutionTemplate extends Omit<ExecutePhaseOptions, "assignment" | "branch"> {
2484
- readonly branch?: string;
2485
- }
2486
- interface AuthorizedImplementationOptions {
2487
- readonly coordinator: WorkflowCoordinator;
2488
- readonly publication: GitHubPublication;
2489
- readonly brief: WorkBrief;
2490
- readonly policy: RepositoryPolicy;
2491
- readonly workerId: string;
2492
- readonly issueNumber?: number;
2493
- readonly branch?: string;
2494
- readonly execution?: ImplementationExecutionTemplate;
2495
- readonly readCurrent?: () => Promise<CurrentImplementationCandidate>;
2496
- readonly now?: () => string;
2497
- readonly leaseTtlMs?: number;
2498
- }
2499
- type ImplementationOutcome = "dispatched" | "completed" | "needs-info" | "blocked" | "failed";
2500
- interface ImplementationPublication {
2501
- readonly brief?: GitHubPublicationResult<unknown>;
2502
- readonly checks: readonly GitHubPublicationResult<unknown>[];
2503
- readonly branch?: GitHubPublicationResult<unknown>;
2504
- readonly pullRequest?: GitHubPublicationResult<GitHubPullRequestSnapshot>;
2505
- }
2506
- interface AuthorizedImplementationResult {
2507
- readonly outcome: ImplementationOutcome;
2508
- readonly reason?: string;
2509
- readonly job?: WorkflowJob;
2510
- readonly dispatch?: DispatchResult;
2511
- readonly assignment?: Assignment;
2512
- readonly lease?: BranchLease;
2513
- readonly phaseResult?: PhaseResult;
2514
- readonly execution?: PhaseExecutionResult;
2515
- readonly publication?: ImplementationPublication;
2516
- readonly pullRequest?: GitHubPullRequestSnapshot;
2517
- readonly nextPhase?: "review";
2518
- readonly nextDispatch?: DispatchIntent;
2519
- readonly readyForReview: boolean;
2520
- }
2521
- interface ReviewSchedulingInput {
2522
- readonly brief: WorkBrief;
2523
- readonly policy: RepositoryPolicy;
2524
- readonly base: RevisionReference;
2525
- readonly head: RevisionReference;
2526
- readonly checks: readonly CheckEvidence[];
2527
- readonly requiredAxes?: ReviewCandidate["requiredAxes"];
2528
- }
2529
- interface ReviewSchedulingResult {
2530
- readonly status: "ready" | "blocked";
2531
- readonly reasons: readonly string[];
2532
- readonly candidate?: ReviewCandidate;
2533
- }
2534
- /** Build a review candidate only after the current implementation checks pass. */
2535
- declare const prepareIndependentReview: (input: ReviewSchedulingInput) => ReviewSchedulingResult;
2536
- declare const runAuthorizedImplementation: (options: AuthorizedImplementationOptions) => Promise<AuthorizedImplementationResult>;
2537
-
2538
- interface CostMeasurement {
2539
- readonly currency?: string;
2540
- readonly amount?: number;
2541
- readonly inputTokens?: number;
2542
- readonly outputTokens?: number;
2543
- readonly provider?: string;
2544
- readonly model?: string;
2545
- }
2546
- interface OperatorStatusOptions {
2547
- readonly cost?: CostMeasurement;
2548
- readonly now?: string;
2549
- }
2550
- interface OperatorCheckStatus {
2551
- readonly name: string;
2552
- readonly command: string;
2553
- readonly status: CheckEvidence["status"];
2554
- readonly summary: string;
2555
- readonly artifactRefs?: readonly string[];
2556
- }
2557
- interface OperatorStatus {
2558
- readonly jobId: string;
2559
- readonly repository: string;
2560
- readonly itemId: string;
2561
- readonly kind: string;
2562
- readonly state: WorkflowJob["state"];
2563
- readonly control: WorkflowJob["control"];
2564
- readonly phase: WorkflowPhase;
2565
- readonly waitingReason?: string;
2566
- readonly queueAgeSeconds: number;
2567
- readonly attempts: Readonly<Record<WorkflowPhase, number>>;
2568
- readonly activeAssignmentId?: string;
2569
- readonly latestObservedAt: string;
2570
- readonly checks: readonly OperatorCheckStatus[];
2571
- readonly artifacts: readonly string[];
2572
- readonly cost: {
2573
- readonly status: "unknown";
2574
- } | ({
2575
- readonly status: "measured";
2576
- } & CostMeasurement);
2577
- readonly interventions: readonly OperatorIntervention[];
2578
- readonly repositoryControl?: RepositoryControl;
2579
- }
2580
- interface OperatorIntervention {
2581
- readonly action: "pause" | "cancel" | "resume" | "stop-repository" | "resume-repository";
2582
- readonly reason?: string;
2583
- readonly at: string;
2584
- }
2585
- interface WorkflowOperatorOptions {
2586
- readonly coordinator: WorkflowCoordinator;
2587
- readonly now?: () => string;
2588
- }
2589
- declare const redact: (value: string) => string;
2590
- declare class WorkflowOperator {
2591
- private readonly coordinator;
2592
- private readonly now;
2593
- private readonly interventions;
2594
- constructor(options: WorkflowOperatorOptions);
2595
- status(jobId: string, options?: OperatorStatusOptions): Promise<OperatorStatus>;
2596
- pause(jobId: string, reason?: string): Promise<WorkflowJob>;
2597
- cancel(jobId: string, reason?: string): Promise<WorkflowJob>;
2598
- resume(jobId: string): Promise<WorkflowJob>;
2599
- stopRepository(repository: string, reason?: string): Promise<RepositoryControl>;
2600
- resumeRepository(repository: string): Promise<RepositoryControl>;
2601
- private record;
2602
- }
2603
-
2604
- interface RepairCandidate {
2605
- readonly base: RevisionReference;
2606
- readonly head: RevisionReference;
2607
- readonly briefHash: string;
2608
- }
2609
- interface RepairBatch {
2610
- readonly id: string;
2611
- readonly jobId: string;
2612
- readonly sourceIssueNumber?: number;
2613
- readonly pullRequestNumber?: number;
2614
- readonly candidate: RepairCandidate;
2615
- readonly brief: WorkBrief;
2616
- readonly findings: readonly Finding[];
2617
- readonly followUp: boolean;
2618
- readonly createdAt: string;
2619
- }
2620
- interface RepairBatchStore {
2621
- get(key: string): RepairBatchResult | undefined;
2622
- save(key: string, result: RepairBatchResult): void;
2623
- }
2624
- declare class InMemoryRepairBatchStore implements RepairBatchStore {
2625
- private readonly results;
2626
- get(key: string): RepairBatchResult | undefined;
2627
- save(key: string, result: RepairBatchResult): void;
2628
- }
2629
- interface CurrentRepairCandidate {
2630
- readonly base: RevisionReference;
2631
- readonly head: RevisionReference;
2632
- readonly briefHash: string;
2633
- readonly pullRequest?: GitHubPullRequestSnapshot;
2634
- }
2635
- interface ScheduleRepairOptions {
2636
- readonly coordinator: WorkflowCoordinator;
2637
- readonly publication: GitHubPublication;
2638
- readonly store: RepairBatchStore;
2639
- readonly jobId: string;
2640
- readonly brief: WorkBrief;
2641
- readonly policy: RepositoryPolicy;
2642
- readonly candidate: RepairCandidate;
2643
- readonly workerId: string;
2644
- readonly sourceIssueNumber?: number;
2645
- readonly pullRequestNumber?: number;
2646
- readonly followUp?: boolean;
2647
- readonly pullRequestState?: "open" | "closed";
2648
- readonly readCurrent?: () => Promise<CurrentRepairCandidate>;
2649
- readonly now?: () => string;
2650
- readonly leaseTtlMs?: number;
2651
- }
2652
- type RepairScheduleOutcome = "scheduled" | "duplicate" | "blocked";
2653
- interface RepairBatchResult {
2654
- readonly outcome: RepairScheduleOutcome;
2655
- readonly reason?: string;
2656
- readonly batch: RepairBatch;
2657
- readonly job?: WorkflowJob;
2658
- readonly dispatch?: DispatchIntent;
2659
- readonly lease?: BranchLease;
2660
- readonly repairIssue?: GitHubIssueSnapshot;
2661
- readonly issuePublication?: GitHubPublicationResult<GitHubIssueSnapshot>;
2662
- readonly linkPublication?: GitHubPublicationResult<unknown>;
2663
- }
2664
- interface ScheduleRepairInput extends ScheduleRepairOptions {
2665
- readonly findings: readonly Finding[];
2666
- }
2667
- interface RepairExecutionTemplate extends Omit<ExecutePhaseOptions, "assignment" | "branch"> {
2668
- readonly branch?: string;
2669
- }
2670
- interface RunBoundedRepairOptions extends ScheduleRepairInput {
2671
- readonly execution: RepairExecutionTemplate;
2672
- }
2673
- interface BoundedRepairExecutionResult {
2674
- readonly outcome: "completed" | "needs-info" | "failed" | "blocked";
2675
- readonly reason?: string;
2676
- readonly repair: RepairBatchResult;
2677
- readonly assignment?: Assignment;
2678
- readonly dispatch?: DispatchResult;
2679
- readonly execution?: PhaseExecutionResult;
2680
- readonly phaseResult?: PhaseResult;
2681
- readonly nextPhase?: "checking" | "review";
2682
- readonly nextDispatch?: DispatchIntent;
2683
- }
2684
- declare const scheduleBoundedRepair: (input: ScheduleRepairInput) => Promise<RepairBatchResult>;
2685
- /** Execute a scheduled repair on the existing leased branch; review remains a separate phase. */
2686
- declare const runBoundedRepair: (input: RunBoundedRepairOptions) => Promise<BoundedRepairExecutionResult>;
2687
-
2688
- type ReleaseEnvironment = "staging" | "production";
2689
- type ReleaseCheckStatus = "passed" | "failed" | "missing" | "unknown";
2690
- interface ReleaseCandidate {
2691
- readonly sourceSha: string;
2692
- readonly reviewedHeadSha: string;
2693
- readonly briefHash: string;
2694
- readonly artifactDigest: string;
2695
- /** Provider-specific immutable locator; integrity is bound separately by artifactDigest. */
2696
- readonly artifactRef: string;
2697
- readonly version?: string;
2698
- }
2699
- interface ReleasePolicy {
2700
- readonly repository: string;
2701
- readonly stagingName: string;
2702
- readonly productionName: string;
2703
- readonly requiredStagingChecks: readonly string[];
2704
- readonly requireHumanApproval: boolean;
2705
- /** Maximum age for a production approval before it must be renewed. */
2706
- readonly approvalFreshnessSeconds?: number;
2707
- /** Roles allowed to approve production; release coordinators may request but not approve. */
2708
- readonly approvalRoles?: readonly ("owner" | "maintainer")[];
2709
- /** Recovery is recorded as a requested action; it is never inferred or executed by default. */
2710
- readonly recoveryMode: "roll-forward" | "rollback" | "owner-decision";
2711
- }
2712
- interface ReleaseActor {
2713
- readonly id: string;
2714
- readonly role: "release-coordinator" | "owner" | "maintainer";
2715
- }
2716
- interface ReleaseCheck {
2717
- readonly name: string;
2718
- readonly status: ReleaseCheckStatus;
2719
- readonly summary: string;
2720
- }
2721
- interface ReleaseVerification {
2722
- readonly environment: ReleaseEnvironment;
2723
- readonly candidate: ReleaseCandidate;
2724
- readonly deploymentId: string;
2725
- readonly checks: readonly ReleaseCheck[];
2726
- readonly smoke: "passed" | "failed" | "missing" | "unknown";
2727
- readonly health: "passed" | "failed" | "missing" | "unknown";
2728
- readonly recordedAt: string;
2729
- readonly failureReason?: string;
2730
- }
2731
- interface ProductionApproval {
2732
- readonly actor: ReleaseActor;
2733
- readonly approvedAt: string;
2734
- readonly candidate: ReleaseCandidate;
2735
- }
2736
- type ReleaseStateStatus = "staging-requested" | "staging-failed" | "staging-verified" | "production-approved" | "production-requested" | "production-failed" | "production-verified";
2737
- interface ReleaseState {
2738
- readonly key: string;
2739
- readonly candidate: ReleaseCandidate;
2740
- readonly status: ReleaseStateStatus;
2741
- readonly staging?: ReleaseVerification;
2742
- readonly approval?: ProductionApproval;
2743
- readonly recovery?: RecoveryRecord;
2744
- readonly production?: ReleaseVerification;
2745
- readonly updatedAt: string;
2746
- }
2747
- interface ReleaseStore {
2748
- get(key: string): ReleaseState | undefined;
2749
- save(state: ReleaseState): void;
2750
- }
2751
- declare class InMemoryReleaseStore implements ReleaseStore {
2752
- private readonly states;
2753
- get(key: string): ReleaseState | undefined;
2754
- save(state: ReleaseState): void;
2755
- }
2756
- interface ReleaseTransport {
2757
- requestDeployment(input: {
2758
- readonly environment: ReleaseEnvironment;
2759
- readonly environmentName: string;
2760
- readonly candidate: ReleaseCandidate;
2761
- readonly actor: ReleaseActor;
2762
- readonly idempotencyKey: string;
2763
- }): Promise<{
2764
- readonly deploymentId: string;
2765
- }>;
2766
- reconcileDeployment?(input: {
2767
- readonly environment: ReleaseEnvironment;
2768
- readonly environmentName: string;
2769
- readonly candidate: ReleaseCandidate;
2770
- readonly idempotencyKey: string;
2771
- }): Promise<{
2772
- readonly deploymentId: string;
2773
- } | undefined>;
2774
- }
2775
- interface ReleaseIntegrationOptions {
2776
- readonly policy: ReleasePolicy;
2777
- readonly store: ReleaseStore;
2778
- readonly transport: ReleaseTransport;
2779
- readonly actor: ReleaseActor;
2780
- /** Validate a provider-specific immutable locator not covered by built-in formats. */
2781
- readonly validateArtifactRef?: (candidate: ReleaseCandidate) => string | undefined;
2782
- readonly now?: () => string;
2783
- }
2784
- interface ReleaseOperationResult {
2785
- readonly outcome: "requested" | "duplicate" | "verified" | "approved" | "blocked" | "failed";
2786
- readonly reason?: string;
2787
- readonly state?: ReleaseState;
2788
- }
2789
- interface RecoveryRecord {
2790
- readonly candidate: ReleaseCandidate;
2791
- readonly action: ReleasePolicy["recoveryMode"];
2792
- readonly reason: string;
2793
- readonly authorizedBy: ReleaseActor;
2794
- readonly recordedAt: string;
2795
- }
2796
- declare const releaseCandidateKey: (candidate: ReleaseCandidate) => string;
2797
- declare class ReleaseIntegration {
2798
- private readonly policy;
2799
- private readonly store;
2800
- private readonly transport;
2801
- private readonly actor;
2802
- private readonly validateArtifactRef?;
2803
- private readonly now;
2804
- constructor(options: ReleaseIntegrationOptions);
2805
- private stateKey;
2806
- requestStaging(candidate: ReleaseCandidate): Promise<ReleaseOperationResult>;
2807
- recordStagingVerification(verification: ReleaseVerification): ReleaseOperationResult;
2808
- approveProduction(input: {
2809
- readonly candidate: ReleaseCandidate;
2810
- readonly approval: ProductionApproval;
2811
- }): ReleaseOperationResult;
2812
- promoteProduction(candidate: ReleaseCandidate): Promise<ReleaseOperationResult>;
2813
- private requestDeployment;
2814
- recordProductionVerification(verification: ReleaseVerification): ReleaseOperationResult;
2815
- recordRecovery(input: {
2816
- readonly candidate: ReleaseCandidate;
2817
- readonly reason: string;
2818
- readonly authorizedBy: ReleaseActor;
2819
- }): RecoveryRecord;
2820
- }
2821
- declare const candidateMatchesApproval: (candidate: ReleaseCandidate, approval: ProductionApproval) => boolean;
2822
-
2823
- export { type AcquireBranchLeaseInput, type AgentCommandOptions, type AgentModelRoles, type AgentProvider, type AgentRole, type AgentSelection, type AgentStreamEvent, type ArtifactStore, type Assignment, type Authorization, type AuthorizedImplementationOptions, type AuthorizedImplementationResult, type BoundedRepairExecutionResult, type BranchLease, type BranchProtectionState, BranchStrategy, CODEX_MODELS, CODEX_REASONING_EFFORTS, type CheckCommand, type CheckEvidence, type CheckStatus, type ClarificationReply, type ClaudeCodeOptions, type CloseResult, type CloseSourceIssueOptions, type CodexModelConfig, type CodexOptions, type CodexReasoningEffort, type CompletionInput, type CompletionResult, ContractValidationError, type CoordinatorClock, type CoordinatorStorage, type CoordinatorStorageTransaction, type CostMeasurement, type CreateAssignmentInput, type CreateRepositoryPolicyInput, type CreateSandboxOptions, type CreateSandboxPhaseEngineAdapterOptions, type CreateWorkBriefInput, type CreateWorktreeOptions, CredentialNotAllowedError, type CredentialResolver, CredentialUnavailableError, type CurrentCandidate, type CurrentImplementationCandidate, type CurrentRepairCandidate, CwdError, type DispatchBlockReason, type DispatchIntent, type DispatchRequest, type DispatchResult, type DispatchStatus, type EffectExecution, type EffectIntent, type EffectOperationContext, type EffectStatus, type EventIgnoreReason, type EventStatus, ExecResult, type ExecutePhaseOptions, type FakePhaseEngineAdapterOptions, type Finding, type FindingDisposition, type FindingSeverity, type GitHubActor, type GitHubActorType, type GitHubAuthorizationPolicy, type GitHubBranchPublicationInput, type GitHubBranchSnapshot, type GitHubBriefDefaults, type GitHubBriefFactory, type GitHubBriefFactoryInput, type GitHubBriefPublicationInput, type GitHubCheckPublicationInput, type GitHubCheckSnapshot, type GitHubCommentPublicationInput, type GitHubCommentSnapshot, type GitHubDeliveryRecord, type GitHubDeliveryStatus, type GitHubDeliveryStore, type GitHubEventIgnoreReason, type GitHubEventName, type GitHubIgnoredEvent, GitHubIntegration, type GitHubIntegrationOptions, type GitHubIssueEventKind, type GitHubIssueSnapshot, type GitHubNormalizationResult, type GitHubNormalizedEvent, type GitHubNormalizedEventKind, GitHubPublication, type GitHubPublicationOptions, type GitHubPublicationResult, type GitHubPullRequestPublicationInput, type GitHubPullRequestReviewHandler, type GitHubPullRequestReviewSnapshot, type GitHubPullRequestReviewState, type GitHubPullRequestSnapshot, type GitHubReadTransport, type GitHubReconciliationInput, type GitHubReconciliationResult, type GitHubRepairIssuePublicationInput, type GitHubRepairLinkPublicationInput, type GitHubTrackedPullRequest, type GitHubTrackedPullRequestEventKind, type GitHubTrackingStore, type GitHubWebhookEnvelope, type GitHubWebhookReceipt, type GitHubWebhookRequest, type GitHubWebhookSignatureInput, type GitHubWriteTransport, type HandoffCandidate, type HandoffOutcome, type HandoffPacket, type HandoffReadinessInput, type HandoffReadinessResult, type HostSessionLookup, type HumanApproval, type HumanHandoffPublisher, type HumanReviewDecision, type HumanReviewDecisionInput, type HumanReviewRoundTripOptions, type HumanReviewRoundTripResult, type ImplementationExecutionTemplate, type ImplementationOutcome, type ImplementationPublication, type InMemoryArtifactStore, InMemoryCoordinatorStorage, InMemoryGitHubStore, InMemoryReleaseStore, InMemoryRepairBatchStore, InMemoryTriageStore, type IndependentReviewOptions, type IndependentReviewResult, type InfrastructureFailureInput, type InfrastructureRetryResult, type IngestResult, type InteractiveOptions, type InteractiveResult, type IterationResult, type IterationUsage, type JobControl, LeaseBusyError, LeaseLostError, type LifecycleState, type LoggingOption, type MergeCandidateOptions, type MergeResult, MergeToHeadBranchStrategy, type MergeTransport, NamedBranchStrategy, type OperatorCheckStatus, type OperatorIntervention, type OperatorStatus, type OperatorStatusOptions, Output, type OutputDefinition, type OutputObjectDefinition, type OutputStringDefinition, type PhaseAgentResolver, type PhaseArtifact, type PhaseBudget, type PhaseCheckout, type PhaseControls, type PhaseCredentials, type PhaseEngineAdapter, type PhaseEngineRequest, type PhaseEngineResponse, type PhaseExecutionResult, type PhaseExecutionStatus, type PhaseFailure, type PhaseOutcome, type PhaseReport, type PhaseResult, type PhaseResultSubmission, type PostgresConnection, PostgresCoordinatorStorage, type PostgresCoordinatorStorageOptions, type PostgresQueryClient, type PostgresQueryResult, type PrepareHandoffOptions, type PrintCommand, type ProductionApproval, type PromptArgs, type PublishEffectInput, type RecoveryRecord, type ReleaseActor, type ReleaseCandidate, type ReleaseCheck, type ReleaseCheckStatus, type ReleaseEnvironment, ReleaseIntegration, type ReleaseIntegrationOptions, type ReleaseOperationResult, type ReleasePolicy, type ReleaseState, type ReleaseStateStatus, type ReleaseStore, type ReleaseTransport, type ReleaseVerification, type RepairBatch, type RepairBatchResult, type RepairBatchStore, type RepairBudgetUsage, type RepairCandidate, type RepairExecutionTemplate, type RepairRequestResult, type RepairScheduleOutcome, type RepositoryControl, type RepositoryPolicy, type ResumeSandboxRunResultOptions, type ReviewAxis, type ReviewCandidate, type ReviewCheckout, type ReviewEvidence, type ReviewFailure, type ReviewFindingInput, type ReviewProvider, type ReviewRequest, type ReviewResponse, type ReviewRunOutcome, type ReviewSchedulingInput, type ReviewSchedulingResult, type RevisionReference, type RiskLevel, type RunBoundedRepairOptions, type RunOptions, type RunPhaseEngineAdapterOptions, type RunResult, type RunTriageOptions, type Sandbox, type SandboxExecOptions, type SandboxHooks, type SandboxInteractiveOptions, type SandboxInteractiveResult, SandboxProvider, type SandboxRunOptions, type SandboxRunResult, type SchedulePhaseInput, type SchedulePhaseResult, type ScheduleRepairInput, type ScheduleRepairOptions, type SourceIssueCloser, type SourceIssueClosureResult, type SourceReference, type StoredEvent, StructuredOutputError, type SubmitPhaseResultInput, type Timeouts, type TransitionContext, type TriageAssessment, type TriageCategory, type TriageInvestigationRequest, type TriageInvestigator, type TriageOutcome, type TriageRecord, type TriageResult, type TriageSource, type TriageStore, type TrustedPhaseInputs, type UntrustedPhaseInputs, type VerificationPlan, WORKFLOW_CONTRACT_VERSION, type WorkBrief, type WorkIdentity, type WorkItemKind, type WorkKey, type WorkRisk, type WorkScope, type WorkerPolicy, WorkflowCoordinator, type WorkflowCoordinatorOptions, type WorkflowEventInput, type WorkflowJob, WorkflowOperator, type WorkflowOperatorOptions, type WorkflowPhase, type Worktree, type WorktreeBranchStrategy, type WorktreeCreateSandboxOptions, type WorktreeInteractiveOptions, type WorktreeRunOptions, type WorktreeRunResult, candidateMatchesApproval, claudeCode, claudeHostSessionPath, claudeSandboxSessionPath, closeSourceIssue, codex, completeSourceIssue, createAssignment, createCreateSandboxPhaseEngineAdapter, createFakePhaseEngineAdapter, createGitHubIssueBrief, createInMemoryArtifactStore, createRepositoryPolicy, createRunPhaseEngineAdapter, createSandbox, createWorkBrief, createWorktree, defaultInvestigator as defaultTriageInvestigator, encodeProjectPath, evaluateHandoffReadiness, executePhase, findClaudeSessionOnHost, findCodexSessionOnHost, interactive, isAuthorizationAllowed, mergeProtectedCandidate, parseCheckEvidence, parsePhaseResult, parseRepositoryPolicy, parseWorkBrief, prepareHumanHandoff, prepareIndependentReview, processHumanReviewDecision, redact as redactOperatorText, releaseCandidateKey, requireTransition, resolveAgentSelection, resolveHumanReviewDecision, reviewDecisionFor, run, runAuthorizedImplementation, runBoundedRepair, runIndependentReview, runTriage, scheduleBoundedRepair, transferClaudeSession, transferCodexSession, verifyGitHubWebhookSignature };
296
+ export { AgentProvider, BranchStrategy, CloseResult, type CreateWorktreeOptions, CwdError, type HostSessionLookup, type InteractiveOptions, type InteractiveResult, IterationResult, LoggingOption, MergeToHeadBranchStrategy, NamedBranchStrategy, PromptArgs, Sandbox, SandboxHooks, SandboxProvider, Timeouts, type Worktree, type WorktreeBranchStrategy, type WorktreeCreateSandboxOptions, type WorktreeInteractiveOptions, type WorktreeRunOptions, type WorktreeRunResult, claudeHostSessionPath, claudeSandboxSessionPath, createWorktree, encodeProjectPath, findClaudeSessionOnHost, findCodexSessionOnHost, interactive, transferClaudeSession, transferCodexSession };