@tokenfactory/acc-runner 0.27.0 → 0.27.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 (161) hide show
  1. package/dist/anthropic-auth.d.ts +53 -0
  2. package/dist/anthropic-auth.d.ts.map +1 -0
  3. package/dist/anthropic-auth.js +89 -0
  4. package/dist/anthropic-auth.js.map +1 -0
  5. package/dist/bin-resolve.d.ts +16 -0
  6. package/dist/bin-resolve.d.ts.map +1 -0
  7. package/dist/bin-resolve.js +35 -0
  8. package/dist/bin-resolve.js.map +1 -0
  9. package/dist/cli.d.ts +3 -0
  10. package/dist/cli.d.ts.map +1 -0
  11. package/dist/cli.js +128 -0
  12. package/dist/cli.js.map +1 -0
  13. package/dist/config.d.ts +121 -0
  14. package/dist/config.d.ts.map +1 -0
  15. package/dist/config.js +396 -0
  16. package/dist/config.js.map +1 -0
  17. package/dist/cost-pricing.d.ts +130 -0
  18. package/dist/cost-pricing.d.ts.map +1 -0
  19. package/dist/cost-pricing.js +191 -0
  20. package/dist/cost-pricing.js.map +1 -0
  21. package/dist/doctor.d.ts +49 -0
  22. package/dist/doctor.d.ts.map +1 -0
  23. package/dist/doctor.js +776 -0
  24. package/dist/doctor.js.map +1 -0
  25. package/dist/failure-classifier.d.ts +112 -0
  26. package/dist/failure-classifier.d.ts.map +1 -0
  27. package/dist/failure-classifier.js +353 -0
  28. package/dist/failure-classifier.js.map +1 -0
  29. package/dist/gh.d.ts +22 -0
  30. package/dist/gh.d.ts.map +1 -0
  31. package/dist/gh.js +48 -0
  32. package/dist/gh.js.map +1 -0
  33. package/dist/git.d.ts +50 -0
  34. package/dist/git.d.ts.map +1 -0
  35. package/dist/git.js +127 -0
  36. package/dist/git.js.map +1 -0
  37. package/dist/github-client.d.ts +133 -0
  38. package/dist/github-client.d.ts.map +1 -0
  39. package/dist/github-client.js +234 -0
  40. package/dist/github-client.js.map +1 -0
  41. package/dist/keychain.d.ts +21 -0
  42. package/dist/keychain.d.ts.map +1 -0
  43. package/dist/keychain.js +45 -0
  44. package/dist/keychain.js.map +1 -0
  45. package/dist/login.d.ts +12 -0
  46. package/dist/login.d.ts.map +1 -0
  47. package/dist/login.js +133 -0
  48. package/dist/login.js.map +1 -0
  49. package/dist/logout.d.ts +2 -0
  50. package/dist/logout.d.ts.map +1 -0
  51. package/dist/logout.js +31 -0
  52. package/dist/logout.js.map +1 -0
  53. package/dist/mcp-spawn.d.ts +30 -0
  54. package/dist/mcp-spawn.d.ts.map +1 -0
  55. package/dist/mcp-spawn.js +145 -0
  56. package/dist/mcp-spawn.js.map +1 -0
  57. package/dist/messaging.d.ts +49 -0
  58. package/dist/messaging.d.ts.map +1 -0
  59. package/dist/messaging.js +36 -0
  60. package/dist/messaging.js.map +1 -0
  61. package/dist/pkg-version.d.ts +3 -0
  62. package/dist/pkg-version.d.ts.map +1 -0
  63. package/dist/pkg-version.js +20 -0
  64. package/dist/pkg-version.js.map +1 -0
  65. package/dist/profiles/designer-prompt.d.ts +18 -0
  66. package/dist/profiles/designer-prompt.d.ts.map +1 -0
  67. package/dist/profiles/designer-prompt.js +172 -0
  68. package/dist/profiles/designer-prompt.js.map +1 -0
  69. package/dist/profiles/developer-prompt.d.ts +24 -0
  70. package/dist/profiles/developer-prompt.d.ts.map +1 -0
  71. package/dist/profiles/developer-prompt.js +24 -0
  72. package/dist/profiles/developer-prompt.js.map +1 -0
  73. package/dist/profiles/manager-prompt.d.ts +34 -0
  74. package/dist/profiles/manager-prompt.d.ts.map +1 -0
  75. package/dist/profiles/manager-prompt.js +93 -0
  76. package/dist/profiles/manager-prompt.js.map +1 -0
  77. package/dist/profiles/tester-prompt.d.ts +28 -0
  78. package/dist/profiles/tester-prompt.d.ts.map +1 -0
  79. package/dist/profiles/tester-prompt.js +165 -0
  80. package/dist/profiles/tester-prompt.js.map +1 -0
  81. package/dist/prompt.d.ts +38 -0
  82. package/dist/prompt.d.ts.map +1 -0
  83. package/dist/prompt.js +78 -0
  84. package/dist/prompt.js.map +1 -0
  85. package/dist/runtime/cache-dir.d.ts +10 -0
  86. package/dist/runtime/cache-dir.d.ts.map +1 -0
  87. package/dist/runtime/cache-dir.js +42 -0
  88. package/dist/runtime/cache-dir.js.map +1 -0
  89. package/dist/runtime/conflict-resolver.d.ts +65 -0
  90. package/dist/runtime/conflict-resolver.d.ts.map +1 -0
  91. package/dist/runtime/conflict-resolver.js +477 -0
  92. package/dist/runtime/conflict-resolver.js.map +1 -0
  93. package/dist/runtime/expand-args.d.ts +28 -0
  94. package/dist/runtime/expand-args.d.ts.map +1 -0
  95. package/dist/runtime/expand-args.js +50 -0
  96. package/dist/runtime/expand-args.js.map +1 -0
  97. package/dist/runtime/locks.d.ts +21 -0
  98. package/dist/runtime/locks.d.ts.map +1 -0
  99. package/dist/runtime/locks.js +103 -0
  100. package/dist/runtime/locks.js.map +1 -0
  101. package/dist/runtime/provision-mutex.d.ts +37 -0
  102. package/dist/runtime/provision-mutex.d.ts.map +1 -0
  103. package/dist/runtime/provision-mutex.js +67 -0
  104. package/dist/runtime/provision-mutex.js.map +1 -0
  105. package/dist/runtime/quarantine.d.ts +30 -0
  106. package/dist/runtime/quarantine.d.ts.map +1 -0
  107. package/dist/runtime/quarantine.js +53 -0
  108. package/dist/runtime/quarantine.js.map +1 -0
  109. package/dist/runtime/resolution-integrity.d.ts +86 -0
  110. package/dist/runtime/resolution-integrity.d.ts.map +1 -0
  111. package/dist/runtime/resolution-integrity.js +248 -0
  112. package/dist/runtime/resolution-integrity.js.map +1 -0
  113. package/dist/runtime/reviewer.d.ts +81 -0
  114. package/dist/runtime/reviewer.d.ts.map +1 -0
  115. package/dist/runtime/reviewer.js +374 -0
  116. package/dist/runtime/reviewer.js.map +1 -0
  117. package/dist/runtime/rework.d.ts +48 -0
  118. package/dist/runtime/rework.d.ts.map +1 -0
  119. package/dist/runtime/rework.js +136 -0
  120. package/dist/runtime/rework.js.map +1 -0
  121. package/dist/runtime/singleton.d.ts +66 -0
  122. package/dist/runtime/singleton.d.ts.map +1 -0
  123. package/dist/runtime/singleton.js +227 -0
  124. package/dist/runtime/singleton.js.map +1 -0
  125. package/dist/runtime/version-drift.d.ts +31 -0
  126. package/dist/runtime/version-drift.d.ts.map +1 -0
  127. package/dist/runtime/version-drift.js +114 -0
  128. package/dist/runtime/version-drift.js.map +1 -0
  129. package/dist/runtime/worktree.d.ts +74 -0
  130. package/dist/runtime/worktree.d.ts.map +1 -0
  131. package/dist/runtime/worktree.js +211 -0
  132. package/dist/runtime/worktree.js.map +1 -0
  133. package/dist/secrets/inject.d.ts +70 -0
  134. package/dist/secrets/inject.d.ts.map +1 -0
  135. package/dist/secrets/inject.js +102 -0
  136. package/dist/secrets/inject.js.map +1 -0
  137. package/dist/supabase.d.ts +4 -0
  138. package/dist/supabase.d.ts.map +1 -0
  139. package/dist/supabase.js +36 -0
  140. package/dist/supabase.js.map +1 -0
  141. package/dist/task-runner.d.ts +313 -0
  142. package/dist/task-runner.d.ts.map +1 -0
  143. package/dist/task-runner.js +1766 -0
  144. package/dist/task-runner.js.map +1 -0
  145. package/dist/token-provider.d.ts +50 -0
  146. package/dist/token-provider.d.ts.map +1 -0
  147. package/dist/token-provider.js +177 -0
  148. package/dist/token-provider.js.map +1 -0
  149. package/dist/types.d.ts +120 -0
  150. package/dist/types.d.ts.map +1 -0
  151. package/dist/types.js +16 -0
  152. package/dist/types.js.map +1 -0
  153. package/dist/version-check.d.ts +17 -0
  154. package/dist/version-check.d.ts.map +1 -0
  155. package/dist/version-check.js +56 -0
  156. package/dist/version-check.js.map +1 -0
  157. package/dist/watch.d.ts +296 -0
  158. package/dist/watch.d.ts.map +1 -0
  159. package/dist/watch.js +1570 -0
  160. package/dist/watch.js.map +1 -0
  161. package/package.json +1 -1
@@ -0,0 +1,313 @@
1
+ import { type ExecaChildProcess } from "execa";
2
+ import { type RunnerConfig, type RunnerProfile } from "./config.js";
3
+ import { type NormalizedUsage } from "./cost-pricing.js";
4
+ import { type ClaudeExitClass } from "./failure-classifier.js";
5
+ import { type GitRunner } from "./git.js";
6
+ import { type GhRunner } from "./gh.js";
7
+ import { type McpConfigCleanup, type McpSpawnOptions } from "./mcp-spawn.js";
8
+ import { type PostRunnerStateArgs } from "./messaging.js";
9
+ import { type TaskLock } from "./runtime/locks.js";
10
+ import { type PreparedWorktree, type PrepareWorktreeOptions } from "./runtime/worktree.js";
11
+ import { type ConflictResolutionDeps } from "./runtime/conflict-resolver.js";
12
+ import { type AssertResolutionOptions, type ResolutionIntegrityDeps, type ResolutionIntegrityResult } from "./runtime/resolution-integrity.js";
13
+ import type { RunnerSupabaseClient } from "./supabase.js";
14
+ export interface CostEventPayload extends NormalizedUsage {
15
+ task_id: string;
16
+ model: string;
17
+ usd_cents: number;
18
+ runner_id?: string | null;
19
+ }
20
+ export interface RunTaskDeps {
21
+ supabase: RunnerSupabaseClient;
22
+ cfg: RunnerConfig;
23
+ git?: GitRunner;
24
+ gh?: GhRunner;
25
+ /** Override for tests — defaults to
26
+ * execa('claude', ['--print', '--dangerously-skip-permissions',
27
+ * '--output-format=json', '--model', modelId?]).
28
+ *
29
+ * v0.6.0 REG-296: modelId is forwarded as `--model <modelId>` when
30
+ * the task carries one, so cost tracking matches the actual model
31
+ * claude spawned with (previously the operator's default Opus was
32
+ * always used regardless of task.model_id). */
33
+ spawnClaude?: (cwd: string, modelId?: string) => ExecaChildProcess;
34
+ /** v0.6.0 REG-301: plain `git checkout <baseBranch>` so the task
35
+ * branch forks from the integration base, not whatever was checked
36
+ * out in cwd. Defaults to `execa('git', ['checkout', baseBranch])`.
37
+ * Tests inject a mock to assert the call ordering against the
38
+ * task-runner pre-spawn sequence. */
39
+ checkoutBase?: (repoPath: string, baseBranch: string) => Promise<void>;
40
+ /**
41
+ * Cost-event sink. Defaults to a direct `acc.record_cost_event` RPC
42
+ * on the runner's already-authenticated supabase client. Tests
43
+ * override; production callers (watch.ts) can override too if they
44
+ * prefer to route through /api/runner/cost-event.
45
+ */
46
+ postCostEvent?: (event: CostEventPayload) => Promise<void>;
47
+ /**
48
+ * Runner session coordinates threaded down so the per-task
49
+ * .mcp.json can be authored before Claude Code spawns AND so the
50
+ * v0.6.1 claim_task_with_locks RPC can attribute the lock to the
51
+ * caller's runner row. v0.6.1 (REG-309 sibling): required now —
52
+ * watch.ts has always passed it; tests must stub it.
53
+ */
54
+ session: {
55
+ accessToken: string;
56
+ runnerId: string;
57
+ };
58
+ /** Public URL forwarded to acc-mcp-server for telemetry POSTs. */
59
+ publicUrl?: string;
60
+ /** Override for tests; defaults to writing a real .mcp.json. */
61
+ writeMcpConfig?: (opts: McpSpawnOptions) => Promise<McpConfigCleanup>;
62
+ /**
63
+ * v0.11-F: per-task PID lock at `~/.cache/acc-runner/locks/<task_id>.pid`.
64
+ * Throws `TaskLockHeldError` when another live runner holds the lock;
65
+ * the caller surfaces `phase: "worktree_lock"` and bails before any
66
+ * worktree side-effect lands.
67
+ */
68
+ acquireLock?: (taskId: string) => Promise<TaskLock>;
69
+ /**
70
+ * v0.11-F: provision an isolated git worktree at
71
+ * `~/.cache/acc-runner/work/<task_id>/`. All subsequent git ops +
72
+ * spawnClaude run with the worktree's path as cwd, never the
73
+ * operator's shared clone.
74
+ */
75
+ prepareWorktree?: (opts: PrepareWorktreeOptions) => Promise<PreparedWorktree>;
76
+ /**
77
+ * v0.12-RESUME: cadence (ms) for the periodic
78
+ * `acc.update_task_signal` RPC that refreshes
79
+ * `acc.tasks.last_runner_signal_at` while the task is in flight.
80
+ * The 5-minute cron sweep uses a 5-minute cutoff, so 30s gives
81
+ * ~10 missed signals of margin before a still-alive runner gets
82
+ * its task pulled back to queued. Tests override to a sub-second
83
+ * cadence so the loop is observable without real-time waits.
84
+ */
85
+ signalIntervalMs?: number;
86
+ /**
87
+ * v0.14-MESSAGING-RUNTIME-WIRE: bus sink for state transitions.
88
+ * Defaults to `acc.post_agent_message` on the same supabase client.
89
+ * Tests override to capture the call sequence. Best-effort — a
90
+ * failed post is logged but never bubbles past the task run.
91
+ */
92
+ postRunnerStateMessage?: (args: PostRunnerStateArgs) => Promise<void>;
93
+ /**
94
+ * v0.14-MESSAGING-RUNTIME-WIRE: runner-profile loader. Defaults to
95
+ * `loadProfile()` from config.js. Returns null when no profile is
96
+ * selected (the v0.13 byte-identical path). Tests inject a stub so
97
+ * the prelude consumer can be exercised without writing a real JSON
98
+ * + module pair to disk.
99
+ */
100
+ loadProfile?: () => RunnerProfile | null;
101
+ /**
102
+ * v0.14-MESSAGING-RUNTIME-WIRE: prelude-module loader. Defaults to
103
+ * the production dynamic-import path; tests inject a stub so the
104
+ * vitest/jsdom-backed environment doesn't try to route the
105
+ * file-URL through Vite's resolver. Returns the prelude string —
106
+ * empty string when the profile has no prelude or the module's
107
+ * default export is not a string.
108
+ */
109
+ loadPromptPrelude?: (profile: RunnerProfile) => Promise<string>;
110
+ /**
111
+ * v0.48 T-48-5: optional dep overrides for the conflict-resolution path.
112
+ * Tests inject stubs to avoid real GitHub API calls. Production callers
113
+ * (watch.ts) leave this undefined — the defaults apply.
114
+ */
115
+ conflictResolutionDeps?: Partial<ConflictResolutionDeps>;
116
+ /**
117
+ * v0.51 T-51-1: resolve a PR's head branch via gh when a rework task's
118
+ * sentinel carries an empty branch. Tests inject a stub; production
119
+ * defaults to `gh pr view <n> -R <repo> --json headRefName`.
120
+ */
121
+ fetchPrHeadRef?: (repo: string, prNumber: number) => Promise<string>;
122
+ /**
123
+ * v0.63 T-63-1: authoritative env tiebreaker for a silent instant-empty
124
+ * claude exit. Defaults to spawning `claude --version` with a short
125
+ * timeout. Returns `ok: true` when the binary answers (the host is fine,
126
+ * so the exit was a transient `claude_unavailable` → pause + retry, NEVER
127
+ * quarantine) and `ok: false` when the probe itself errors / times out /
128
+ * exits non-zero (the binary or host is genuinely broken → upgrade to
129
+ * env_broken → quarantine). Tests inject a stub so they don't shell out to
130
+ * a real claude.
131
+ */
132
+ healthProbe?: () => Promise<{
133
+ ok: boolean;
134
+ detail: string;
135
+ }>;
136
+ /**
137
+ * v0.57 T-57-2: conflict-resolution integrity guardrail. Runs before the
138
+ * push of a conflict-resolution task and rejects merges that left conflict
139
+ * markers, fail typecheck, or regressed a package version without a
140
+ * matching CHANGELOG entry. Defaults to `assertResolutionIntegrity` against
141
+ * the worktree; tests inject a stub to drive the three incident replays
142
+ * without a real worktree.
143
+ */
144
+ assertResolutionIntegrity?: (workdir: string, opts: AssertResolutionOptions, deps?: ResolutionIntegrityDeps) => Promise<ResolutionIntegrityResult>;
145
+ }
146
+ export interface RunTaskController {
147
+ taskId: string;
148
+ promise: Promise<RunTaskOutcome>;
149
+ cancel(): void;
150
+ }
151
+ /**
152
+ * Failure phase tag. watch.ts pump() prints this on the stderr summary
153
+ * line (REG-294) so an operator can tell whether a multi-minute task
154
+ * died at fetch, git, claude, or push.
155
+ */
156
+ export type RunTaskPhase = "claim_locks" | "transition_to_running" | "fetch" | "worktree_lock" | "git" | "claude_exit" | "push" | "github";
157
+ export interface RunTaskOutcome {
158
+ taskId: string;
159
+ status: "ok" | "failed" | "cancelled" | "capacity_paused" | "requeued";
160
+ prUrl?: string;
161
+ exitCode?: number | null;
162
+ error?: string;
163
+ /** v0.6.0 REG-294: which phase of runTask produced the failure. Set
164
+ * on every non-ok return so watch.ts pump() can surface a clear
165
+ * one-liner to the operator. */
166
+ phase?: RunTaskPhase;
167
+ /**
168
+ * v0.48: set when the failure classifier identifies a machine-level
169
+ * failure (usage_limit | auth_expired | env_broken). watch.ts uses
170
+ * this to quarantine the runner and NOT count the failure toward
171
+ * the task's retry budget.
172
+ *
173
+ * v0.56 (T-56-1): NEVER set for capacity_exhausted — capacity is a
174
+ * pause, not a quarantine. The capacity case sets the two fields below
175
+ * and status='capacity_paused' instead.
176
+ */
177
+ quarantine_cause?: ClaudeExitClass;
178
+ /**
179
+ * v0.56 (T-56-1): true when claude exited because the Claude account hit
180
+ * its session/usage limit (api_error_status 429). The task is NOT
181
+ * transitioned to 'failed' — it is left for the stale-running sweep to
182
+ * return to 'queued' (runner_id cleared) losslessly — and watch.ts pauses
183
+ * the whole runner (tasks AND reviews) until `resume_at`. No
184
+ * dead-letter, no quarantine, no retry-budget burn.
185
+ */
186
+ capacity_exhausted?: boolean;
187
+ /**
188
+ * v0.63 (T-63-1): true when claude exited with the silent instant-empty
189
+ * fingerprint (fast + empty, no 127, no env/auth/usage pattern) AND a
190
+ * `claude --version` health probe confirmed the binary still works — i.e.
191
+ * claude was momentarily unavailable, not the host broken. Routed exactly
192
+ * like capacity_exhausted: the task is left 'running' for the stale-running
193
+ * sweep to requeue losslessly (no dead-letter, no quarantine, no
194
+ * retry-budget burn) and `status` is 'capacity_paused' so watch.ts pauses
195
+ * the runner via the existing capacity lane. `resume_at` carries an
196
+ * EXPONENTIAL backoff instant (longer each consecutive silent exit). A
197
+ * sustained streak inside a rolling window escalates to a human INFRA alert
198
+ * — but NEVER quarantines.
199
+ */
200
+ claude_unavailable?: boolean;
201
+ /**
202
+ * v0.56 (T-56-1): the stated reset instant (ISO-8601) parsed from
203
+ * claude's "...resets <time>" message, or null when no time was present
204
+ * (watch.ts then applies its default capacity backoff).
205
+ *
206
+ * v0.63 (T-63-1): also carries the exponential-backoff resume instant for a
207
+ * claude_unavailable pause (always non-null in that case).
208
+ */
209
+ resume_at?: string | null;
210
+ /**
211
+ * v0.53 T-53-4: number of consecutive instant-empty claude exits that
212
+ * produced the quarantine_cause (only set alongside an env_broken
213
+ * cause). watch.ts persists it into quarantine.json's `consecutive`
214
+ * field. A definitive env_broken records 1; a heuristic env_broken
215
+ * records 2 (the runner retried the spawn and it exited instantly
216
+ * again). Undefined for non-env_broken causes.
217
+ */
218
+ quarantine_consecutive?: number;
219
+ }
220
+ /**
221
+ * v0.6.0 REG-296: build the argv for `claude --print`. Splitting this
222
+ * out keeps the model-passthrough logic unit-testable without spawning
223
+ * a real subprocess. modelId is forwarded as `--model <id>` when
224
+ * non-empty (whitespace counts as empty); otherwise omitted so claude
225
+ * uses the operator's default model.
226
+ */
227
+ export declare function buildClaudeArgs(modelId?: string | null): string[];
228
+ /**
229
+ * v0.6.0 REG-295: expand `~/...` paths against $HOME so a task can
230
+ * carry `repo_path_hint = "~/work/foo"` from a row populated on a
231
+ * different machine. Absolute and relative paths pass through.
232
+ */
233
+ export declare function expandHomePath(p: string): string;
234
+ /**
235
+ * v0.63 T-63-1: knobs for the silent-claude-unavailability response. Defaults
236
+ * pause + back off + retry on each silent instant-empty exit, growing the
237
+ * backoff exponentially, and raise a human INFRA alert only after a SUSTAINED
238
+ * streak inside a rolling window — never on 2, and never a quarantine.
239
+ */
240
+ export interface ClaudeUnavailableKnobs {
241
+ /** Rolling window for the sustained-streak INFRA alert. */
242
+ windowMs: number;
243
+ /** Silent exits within `windowMs` that trip the INFRA alert (default ~5). */
244
+ alertThreshold: number;
245
+ /** First pause backoff; doubles each consecutive silent exit. */
246
+ backoffBaseMs: number;
247
+ /** Backoff ceiling so the ladder can't run away. */
248
+ backoffMaxMs: number;
249
+ }
250
+ /** v0.63 T-63-1: override the silent-unavailability knobs (used by tests). */
251
+ export declare function configureClaudeUnavailable(partial: Partial<ClaudeUnavailableKnobs>): void;
252
+ /** v0.63 T-63-1: reset both the streak and the knobs (used by tests). */
253
+ export declare function resetClaudeUnavailableState(): void;
254
+ export interface ClaudeUnavailableDecision {
255
+ /** Consecutive silent exits (drives the exponential backoff). */
256
+ streak: number;
257
+ /** Silent exits inside the rolling window (drives the INFRA alert). */
258
+ windowCount: number;
259
+ /** True once windowCount reaches the alert threshold — escalate to a human. */
260
+ alert: boolean;
261
+ /** Pause backoff (ms) for this exit. */
262
+ backoffMs: number;
263
+ /** Absolute resume instant (ISO-8601) = now + backoffMs. */
264
+ resumeAt: string;
265
+ }
266
+ /**
267
+ * v0.63 T-63-1: record one silent instant-empty exit and compute the response
268
+ * (exponential backoff + whether the sustained-streak INFRA alert trips).
269
+ * Exported so the watch process and the unit suite share one definition.
270
+ */
271
+ export declare function recordClaudeUnavailable(now: number): ClaudeUnavailableDecision;
272
+ /**
273
+ * Pull the structured report block from claude's stdout. Recognises
274
+ * both `--output-format=json` (extracts .result) and plain text. Falls
275
+ * back to the entire stdout (capped) if no `## Summary` heading is
276
+ * present — that way the PR body still tells the reviewer what happened.
277
+ */
278
+ export declare function extractReportFromOutput(stdout: string): string;
279
+ /**
280
+ * v0.35-B: extract the PR number from a `gh pr create` URL. Returns null
281
+ * when the URL doesn't carry a `/pull/<int>` segment so the caller can
282
+ * fall back to the webhook-driven path. GitHub URLs encode PR ids as the
283
+ * last path segment; anchors and query strings are tolerated.
284
+ */
285
+ export declare function parsePrNumber(url: string | null | undefined): number | null;
286
+ /**
287
+ * Build a cost event from claude's stdout. Always returns a payload
288
+ * (zero-cost when usage isn't parseable) so the cap-tracking surface
289
+ * stays consistent: one cost_events row per attempt.
290
+ */
291
+ export declare function buildCostEvent(taskId: string, stdout: string, fallbackModel: string | null | undefined, runnerId: string | null | undefined): CostEventPayload;
292
+ /**
293
+ * v0.14-MESSAGING-RUNTIME-WIRE — dynamic-import the prelude module
294
+ * referenced by a runner profile and return its default-exported string.
295
+ *
296
+ * The prelude path in the profile JSON (e.g. `./src/profiles/developer-
297
+ * prompt.ts`) is interpreted from the runner package root — the parent
298
+ * of the runner-profiles dir where the JSON lives. In source/dev the
299
+ * .ts file is importable via tsx; in the npm-published artifact only
300
+ * `dist/` ships, so we map `src/*.ts` → `dist/*.js` when the .ts target
301
+ * doesn't exist. Returns empty string when no prelude is configured or
302
+ * the import resolves to a non-string default (v0.13 byte-identical).
303
+ *
304
+ * Exported so tests can stub the resolution + import seam via the
305
+ * `loadPromptPrelude` dep on RunTaskDeps — vitest's Vite-backed
306
+ * transform pipeline does not handle dynamic imports of arbitrary file
307
+ * URLs in the jsdom environment, so the production path is exercised
308
+ * by the runner's own unit suite (node env) rather than by the
309
+ * top-level integration test.
310
+ */
311
+ export declare function loadPromptPrelude(profile: RunnerProfile): Promise<string>;
312
+ export declare function runTask(taskId: string, deps: RunTaskDeps): RunTaskController;
313
+ //# sourceMappingURL=task-runner.d.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