@mnaimfaizy/agent-kit 1.0.0-beta.13 → 1.0.0-beta.15

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 (79) hide show
  1. package/README.md +24 -5
  2. package/custom-harness.schema.json +243 -0
  3. package/harnesses.json +286 -0
  4. package/package.json +4 -2
  5. package/src/checks/ci-workflow.mjs +105 -0
  6. package/src/checks/claude-app.mjs +11 -2
  7. package/src/checks/custom-harness.mjs +157 -0
  8. package/src/checks/github-app.mjs +214 -0
  9. package/src/checks/review-response.mjs +54 -27
  10. package/src/checks/rulesets.mjs +9 -8
  11. package/src/checks/secrets-and-variables.mjs +220 -43
  12. package/src/checks/stages.mjs +705 -0
  13. package/src/cli.mjs +277 -31
  14. package/src/deep-scan/agent.mjs +145 -117
  15. package/src/deep-scan/credential.mjs +88 -42
  16. package/src/deep-scan/docker-driver.mjs +131 -49
  17. package/src/deep-scan/harness-text.mjs +99 -0
  18. package/src/deep-scan/lifecycle.mjs +92 -199
  19. package/src/deep-scan/limits.mjs +13 -7
  20. package/src/deep-scan/model-proxy.mjs +47 -602
  21. package/src/deep-scan/preflight.mjs +81 -1
  22. package/src/deep-scan/recipe.mjs +7 -7
  23. package/src/deep-scan/runtime.mjs +54 -6
  24. package/src/deep-scan/sandbox-run.mjs +232 -0
  25. package/src/deep-scan/sbx-driver.mjs +242 -50
  26. package/src/deep-scan/tar.mjs +69 -22
  27. package/src/deep-scan/verify.mjs +6 -1
  28. package/src/deep-scan.mjs +98 -14
  29. package/src/doctor.mjs +113 -4
  30. package/src/harness/adapters.mjs +30 -0
  31. package/src/harness/antigravity.mjs +187 -0
  32. package/src/harness/claude-code.mjs +236 -0
  33. package/src/harness/codex.mjs +219 -0
  34. package/src/harness/cursor.mjs +199 -0
  35. package/src/harness/custom/registry.mjs +21 -0
  36. package/src/harness/custom/schema.mjs +90 -0
  37. package/src/harness/custom.mjs +299 -0
  38. package/src/harness/facts.mjs +157 -0
  39. package/src/harness/gemini.mjs +164 -0
  40. package/src/harness/install-layer.mjs +141 -0
  41. package/src/harness/opencode.mjs +289 -0
  42. package/src/harness/resolve.mjs +156 -0
  43. package/src/harness/support-levels.mjs +197 -0
  44. package/src/harness-live/assess.mjs +291 -0
  45. package/src/harness-live/cursor-real.mjs +146 -0
  46. package/src/harness-live/cursor-version.mjs +70 -0
  47. package/src/harness-live/cursor.mjs +80 -0
  48. package/src/harness-live/custom.mjs +91 -0
  49. package/src/harness-live/fixture-harness.mjs +45 -0
  50. package/src/harness-live/harnesses.mjs +263 -0
  51. package/src/harness-live/host.mjs +414 -0
  52. package/src/harness-live/opencode.mjs +289 -0
  53. package/src/harness-live/probes.mjs +239 -0
  54. package/src/harness-live/run.mjs +214 -0
  55. package/src/harness-live/setup.mjs +126 -0
  56. package/src/harness-live/stage.mjs +161 -0
  57. package/src/harness-live/suite.mjs +481 -0
  58. package/src/harness-test.mjs +116 -0
  59. package/src/init.mjs +339 -23
  60. package/src/model-proxy/core.mjs +657 -0
  61. package/src/model-proxy/profiles/anthropic.mjs +241 -0
  62. package/src/model-proxy/profiles/gemini-api.mjs +311 -0
  63. package/src/model-proxy/profiles/openai.mjs +327 -0
  64. package/src/model-proxy/stub-dialects/anthropic.mjs +110 -0
  65. package/src/model-proxy/stub-dialects/gemini-api.mjs +178 -0
  66. package/src/model-proxy/stub-dialects/openai.mjs +173 -0
  67. package/src/model-proxy/stub.mjs +182 -0
  68. package/src/stage/audit.mjs +79 -0
  69. package/src/stage/egress-route.mjs +207 -0
  70. package/src/stage/implement/carry.mjs +308 -0
  71. package/src/stage/implement/sandbox.mjs +271 -0
  72. package/src/stage/implement/verify.mjs +70 -0
  73. package/src/stage/implement.mjs +218 -0
  74. package/src/stage/plan.mjs +115 -0
  75. package/src/stage/review-response.mjs +172 -0
  76. package/src/stage/review.mjs +185 -0
  77. package/src/stage/workspace.mjs +274 -0
  78. package/src/stage.mjs +1068 -0
  79. package/src/deep-scan/claude-code.mjs +0 -25
@@ -1,20 +1,22 @@
1
1
  // The Deep scan sandbox lifecycle (#369), from image to teardown, on the
2
- // runtime `selectRuntime` chose. In order: prepare the image (with a pinned
3
- // Claude Code, its auto-updater off); start the sandbox with no mount; copy
2
+ // runtime `selectRuntime` chose. In order: prepare the image (the Harness
3
+ // image, or the recipe's with the harness copied from it, ADR 0029: the pinned
4
+ // harness, its updater off); start the sandbox with no mount; copy
4
5
  // in an export of the trusted ref (never the working tree) and the grounding
5
6
  // files, and nothing else; run the setup phase (`setup`, `start`, `ready`,
6
7
  // `seed`) with no agent and no model credential, its egress limited to the
7
8
  // recipe's `registries`; cut the network and check from the host that it is
8
9
  // cut; open the model route (the key-injecting model proxy on the host, the
9
10
  // scan's only way out) and check from the host that nothing else is open;
10
- // hand the agent its brief and run the real Claude Code (#370); copy out the
11
+ // hand the agent its brief and run the real harness (#370); copy out the
11
12
  // one report file; and destroy the sandbox on every exit path, an interrupt
12
13
  // included. The real model credential reaches only the model proxy, in this
13
14
  // process: the sandbox gets a placeholder.
14
15
  //
15
16
  // Every run is bounded from out here (#371): the setup wall clock runs from
16
17
  // the image step until the agent step starts, the scan wall clock over the
17
- // agent step, Claude Code runs with the launcher's `--max-turns`, and the
18
+ // agent step, the harness takes the launcher's `--max-turns` where it has a
19
+ // turn limit, and the
18
20
  // model proxy refuses requests past the token cap. A limit that fires stops
19
21
  // the running step through the same seam an interrupt does, then the report
20
22
  // it left is copied out with the launcher's `Stopped:` line, and the sandbox
@@ -24,32 +26,28 @@
24
26
  // Kata, Firecracker on Docker Engine) and sbx-driver.mjs (Docker
25
27
  // Sandboxes). This module owns the order, the output and every refusal.
26
28
 
27
- import { randomBytes } from "node:crypto";
28
29
  import { mkdtempSync, writeFileSync } from "node:fs";
29
30
  import { tmpdir } from "node:os";
30
31
  import { join } from "node:path";
31
32
  import { firstLine } from "../exec.mjs";
32
- import { agentBrief, agentEnv, agentScript, BRIEF_PATH, TURNS_MARKER } from "./agent.mjs";
33
- import { CLAUDE_CODE_VERSION, layerDockerfile } from "./claude-code.mjs";
34
- import { callerKeyFor } from "./credential.mjs";
35
- import { dockerDriver, LABEL } from "./docker-driver.mjs";
36
- import { groundingUrlProblem, isGroundingUrl } from "./grounding-url.mjs";
37
33
  import {
38
- LimitReached,
39
- STOPPED_EXIT,
40
- stoppedStatus,
41
- TOKENS,
42
- TURNS,
43
- WALL_CLOCK,
44
- withStopped,
45
- } from "./limits.mjs";
46
- import { startModelProxy } from "./model-proxy.mjs";
47
- import { sbxDriver } from "./sbx-driver.mjs";
48
- import { ENDS_HERE, indent, Interrupted, outputLines, StepFailed } from "./steps.mjs";
34
+ agentBrief,
35
+ agentPlan,
36
+ agentScript,
37
+ BRIEF_PATH,
38
+ credentialMarker,
39
+ turnsMarker,
40
+ } from "./agent.mjs";
41
+ import { LABEL } from "./docker-driver.mjs";
42
+ import { textFor } from "./harness-text.mjs";
43
+ import { groundingUrlProblem, isGroundingUrl } from "./grounding-url.mjs";
44
+ import { LimitReached, STOPPED_EXIT, stoppedStatus, TURNS, withStopped } from "./limits.mjs";
45
+ import { cutNetwork, openModelRoute, runInSandbox } from "./sandbox-run.mjs";
46
+ import { ENDS_HERE, indent, outputLines, StepFailed } from "./steps.mjs";
49
47
  import { tarOf } from "./tar.mjs";
50
48
  import { checkVerificationReport, FINDINGS_PATH, verificationBrief } from "./verify.mjs";
51
49
 
52
- export { CLAUDE_CODE_VERSION, LABEL, layerDockerfile };
50
+ export { LABEL };
53
51
 
54
52
  /** Where the sandbox holds the repository, the grounding and the report. */
55
53
  export const WORKSPACE = "/workspace";
@@ -66,28 +64,29 @@ export const MAX_GROUNDING_BYTES = 10 * 1024 * 1024;
66
64
  export const MAX_EXPORT_BYTES = 1024 * 1024 * 1024;
67
65
  const GROUNDING_TIMEOUT_MS = 60_000;
68
66
 
69
- /** What the Agent step line says for a model or effort not asked for. */
70
- const CLAUDE_DEFAULT = "Claude Code's default";
71
-
72
67
  /** Why a line is withheld from a world-readable log. */
73
68
  const PUBLIC_LOG = "the Public-log rule: this log is world-readable in GitHub Actions";
74
69
 
75
70
  /**
76
- * The line a run prints when the model API answered every request with a
77
- * 401 or 403: the credential's kind and where it came from (a variable's
78
- * name, or 1Password), never its value.
71
+ * The line a run prints when the model API refused the credential in every
72
+ * answer (a 401 or 403, or what the harness's API answers beside them): the
73
+ * credential's kind and where it came from (a variable's name, or
74
+ * 1Password), never its value.
79
75
  * @param {"api-key" | "subscription"} kind
80
76
  * @param {string} from
77
+ * @param {string} harness
78
+ * @param {string} [model]
81
79
  */
82
- function credentialRefusedLine(kind, from) {
80
+ function credentialRefusedLine(kind, from, harness, model) {
81
+ const text = textFor(harness, model);
83
82
  const what =
84
83
  kind === "subscription"
85
84
  ? `the Claude subscription token from ${from} was not accepted (its value is not shown). Make a fresh one with claude setup-token, then run deep-scan again.`
86
- : `the API key from ${from} was not accepted (its value is not shown). Check that the key is current and its Anthropic Console workspace is active, then run deep-scan again.`;
87
- return `The model API refused the credential: every answer was 401 or 403, so ${what}`;
85
+ : `the API key from ${from} was not accepted (its value is not shown). ${text.keyRefused}, then run deep-scan again.`;
86
+ return `The model API refused the credential: every answer was ${text.refusedAs ?? "401 or 403"}, so ${what}`;
88
87
  }
89
88
 
90
- /** How many lines of Claude Code's error output a failed agent step shows. */
89
+ /** How many lines of the harness's error output a failed agent step shows. */
91
90
  const AGENT_ERROR_LINES = 20;
92
91
 
93
92
  /** The setup phase's fields, in the order they run: services before seeding. */
@@ -102,6 +101,8 @@ const SETUP_ORDER = ["setup", "start", "ready", "seed"];
102
101
  * start: (steps: object) => Promise<{ isolation?: string } | void>,
103
102
  * copyIn: (tar: Buffer, what: string) => Promise<void>,
104
103
  * installAgent: (out: Function) => Promise<void>,
104
+ * carryOut: (script: string, opts: { maxBytes: number }) => Promise<{ data: Buffer } | { error: string }>,
105
+ * renew: () => Promise<void>,
105
106
  * openSetupEgress: (registries: string[]) => Promise<{ env: string[], note: string }>,
106
107
  * refused: () => string[],
107
108
  * exec: (script: string, opts?: { env?: string[], workdir?: string | null }) => Promise<import("../exec.mjs").StartResult>,
@@ -133,6 +134,7 @@ const SETUP_ORDER = ["setup", "start", "ready", "seed"];
133
134
  * credential: string,
134
135
  * credentialKind?: "api-key" | "subscription",
135
136
  * credentialFrom?: string,
137
+ * harness?: string,
136
138
  * limits: import("./limits.mjs").Limits,
137
139
  * model?: string,
138
140
  * effort?: string,
@@ -160,99 +162,15 @@ const SETUP_ORDER = ["setup", "start", "ready", "seed"];
160
162
  * }} Verification
161
163
  */
162
164
  export async function runLifecycle(opts) {
163
- const { runner, runtime, out, err, signals } = opts;
164
- const controller = new AbortController();
165
- const { signal } = controller;
166
- const handlers = Object.fromEntries(
167
- ["SIGINT", "SIGTERM"].map((sig) => [
168
- sig,
169
- () => {
170
- if (signal.aborted) return;
171
- err(`Interrupted (${sig}): stopping the current step and destroying the sandbox.`);
172
- controller.abort(sig);
173
- },
174
- ]),
165
+ // The harness's launch plan: the drivers put its install layer on the image.
166
+ const plan = agentPlan({
167
+ harness: opts.harness,
168
+ kind: opts.credentialKind,
169
+ model: opts.model,
170
+ });
171
+ return runInSandbox({ ...opts, plan }, ({ driver, clocks }) =>
172
+ lifecycle({ ...opts, driver, clocks }),
175
173
  );
176
- for (const [sig, handler] of Object.entries(handlers)) signals.on(sig, handler);
177
-
178
- const interrupted = () => new Interrupted(String(signal.reason ?? "SIGINT"));
179
-
180
- // The phase clocks. A limit aborts only the phase's own controller, so the
181
- // steps after it (the copy-out, the teardown) still run.
182
- const { timers, limits } = opts;
183
- /** @type {{ controller: AbortController, timer: unknown } | null} */
184
- let phase = null;
185
- /** @type {{ limit: string, detail: string } | null} */
186
- let stopped = null;
187
- const stop = (limit, detail) => {
188
- if (stopped || signal.aborted) return;
189
- stopped = { limit, detail };
190
- err(`${stoppedStatus(stopped)} Stopping the current step.`);
191
- phase?.controller.abort(stopped);
192
- };
193
- const clocks = {
194
- begin(name, minutes) {
195
- const controller = new AbortController();
196
- const timer = timers.setTimeout(
197
- () => stop(WALL_CLOCK, `the ${name} phase's ${minutes}-minute limit`),
198
- minutes * 60_000,
199
- );
200
- phase = { controller, timer };
201
- if (stopped) controller.abort(stopped);
202
- },
203
- end() {
204
- if (phase) timers.clearTimeout(phase.timer);
205
- phase = null;
206
- },
207
- stop,
208
- stopped: () => stopped,
209
- /** The signal a step stops on: an interrupt, or its phase's limit. */
210
- signal: () => (phase ? AbortSignal.any([signal, phase.controller.signal]) : signal),
211
- /** What a step stopped by `clocks.signal()` throws. */
212
- reason: () => (signal.aborted ? interrupted() : new LimitReached(stopped)),
213
- };
214
-
215
- /** @type {import("./docker-driver.mjs").Call} */
216
- const call = async (cmd, args, { stdin, cwd, maxOutput } = {}) => {
217
- const stepSignal = clocks.signal();
218
- if (stepSignal.aborted) throw clocks.reason();
219
- const r = await runner.start(cmd, args, { stdin, cwd, maxOutput, signal: stepSignal });
220
- if (r.aborted || stepSignal.aborted) throw clocks.reason();
221
- if (r.truncated) return r;
222
- // Ctrl+C in a terminal reaches the runtime's child too, and can end it
223
- // before the handler above runs: that is an interrupt, not a failure.
224
- if (r.signal === "SIGINT" || r.signal === "SIGTERM") throw new Interrupted(r.signal);
225
- return r;
226
- };
227
- const id = randomBytes(6).toString("hex");
228
- const driver =
229
- runtime.id === "sbx" ? sbxDriver({ id, call }) : dockerDriver({ runtime, id, call });
230
-
231
- let code;
232
- let thrown = null;
233
- try {
234
- code = await lifecycle({ ...opts, driver, clocks });
235
- } catch (e) {
236
- if (e instanceof LimitReached) {
237
- // A limit before the agent step: there is no report to deliver.
238
- out(`${stoppedStatus(e.stop)} No report came out: nothing was written, filed or posted.`);
239
- code = STOPPED_EXIT;
240
- } else if (e instanceof Interrupted) {
241
- code = e.signal === "SIGTERM" ? 143 : 130;
242
- } else if (e instanceof StepFailed) {
243
- err(e.lines.join("\n"));
244
- code = 1;
245
- } else {
246
- thrown = e;
247
- }
248
- }
249
- clocks.end();
250
- await driver.close();
251
- const tornDown = teardown(runner, driver.teardown(), out, err);
252
- driver.cleanup?.();
253
- for (const [sig, handler] of Object.entries(handlers)) signals.off(sig, handler);
254
- if (thrown) throw thrown;
255
- return (code === 0 || code === STOPPED_EXIT) && !tornDown ? 1 : code;
256
174
  }
257
175
 
258
176
  async function lifecycle({
@@ -268,6 +186,7 @@ async function lifecycle({
268
186
  credential,
269
187
  credentialKind = "api-key",
270
188
  credentialFrom = "its source",
189
+ harness = "claude-code",
271
190
  limits,
272
191
  model,
273
192
  effort,
@@ -318,7 +237,7 @@ async function lifecycle({
318
237
  return r.stdout;
319
238
  };
320
239
 
321
- // 1. Image, and its pinned Claude Code (or the runtime's refusal).
240
+ // 1. Image, and its pinned harness (or the runtime's refusal).
322
241
  await driver.prepare(steps, { archive, out, branch, short });
323
242
 
324
243
  // 2. The sandbox: no mount, no host environment, no Docker socket.
@@ -413,41 +332,26 @@ async function lifecycle({
413
332
  }
414
333
 
415
334
  // 5. Cut the network, and check from the host that it is cut.
416
- await driver.cutEgress();
417
- const left = await driver.egressLeft();
418
- if (left !== null) {
419
- throw new StepFailed([`FAILED the network is not cut: ${left}.`, ENDS_HERE]);
420
- }
421
- out("Network: cut (checked from the host); the agent step has no network.");
335
+ await cutNetwork(driver, out);
422
336
 
423
337
  // 6. The model route: the key-injecting model proxy on this machine, the
424
338
  // scan's only way out, and the check from the host that nothing else is.
425
- // The run's caller key: the sandboxed Claude Code holds it, and the proxy
426
- // forwards only a request that carries it.
427
- const callerKey = callerKeyFor(credentialKind);
428
- let proxy = null;
429
- const route = await driver.openModelRoute(async (bind) => {
430
- proxy = await startModelProxy({
431
- credential,
432
- kind: credentialKind,
433
- bind,
434
- callerKey,
435
- maxTokens: limits.tokens,
436
- onCap: () => clocks.stop(TOKENS, `the run's ${limits.tokens}-token cap`),
437
- ...(modelApi !== undefined ? { upstream: modelApi } : {}),
438
- });
439
- return proxy;
339
+ const { callerKey, route, proxy } = await openModelRoute({
340
+ driver,
341
+ clocks,
342
+ harness,
343
+ model,
344
+ credential,
345
+ credentialKind,
346
+ maxTokens: limits.tokens,
347
+ modelApi,
440
348
  });
441
- const extra = await driver.egressLeft();
442
- if (extra !== null) {
443
- throw new StepFailed([`FAILED more than the model route is open: ${extra}.`, ENDS_HERE]);
444
- }
445
349
  if (route.isolation) out(route.isolation);
446
350
  out(
447
351
  `Model route: only the model proxy on your machine (${route.note}), which forwards to the model API alone, with your ${credentialKind === "subscription" ? "token as its bearer value" : "key"}; checked from the host.`,
448
352
  );
449
353
 
450
- // 7. The agent step: Claude Code with a placeholder key, handed its brief.
354
+ // 7. The agent step: the harness with a placeholder key, handed its brief.
451
355
  // A Verification run's finding file goes in with it, after the setup phase
452
356
  // and the cut, so no setup step, which has registry egress, can read it.
453
357
  const paths = { workspace: WORKSPACE, grounding: GROUNDING_DIR, report: REPORT_PATH };
@@ -465,8 +369,10 @@ async function lifecycle({
465
369
  grounding,
466
370
  paths,
467
371
  discovers: subscription,
372
+ harness,
468
373
  })
469
374
  : agentBrief({
375
+ harness,
470
376
  branch,
471
377
  short,
472
378
  recipePath,
@@ -487,8 +393,22 @@ async function lifecycle({
487
393
  ? "copying the launcher's brief and the finding file in"
488
394
  : "copying the launcher's brief in",
489
395
  );
396
+ const plan = agentPlan({
397
+ harness,
398
+ baseUrl: route.url,
399
+ maxTurns: limits.turns,
400
+ model,
401
+ effort,
402
+ kind: credentialKind,
403
+ callerKey,
404
+ });
405
+ const { displayName, version } = plan.identity;
406
+ /** What the line says for a model or effort not asked for. */
407
+ const unasked = `${displayName}'s default`;
408
+ const text = textFor(harness, model);
409
+ const turnCap = text.turnLimit ? `at most ${limits.turns} turns` : "no turn limit";
490
410
  out(
491
- `Agent step: Claude Code ${CLAUDE_CODE_VERSION} (${subscription ? "no --bare: the subscription path, with a placeholder token; project settings and MCP servers not loaded" : "--bare, a placeholder key"}, web tools off, at most ${limits.turns} turns; requested model: ${model ?? CLAUDE_DEFAULT}, effort: ${effort ?? CLAUDE_DEFAULT}), handed ${verification ? "the Verification-run procedure, the finding file" : "the deep procedure"}, the Threat pack and the Scan recipe.`,
411
+ `Agent step: ${displayName} ${version} (${text.agentStep(credentialKind)}, ${turnCap}; requested model: ${model ?? unasked}, effort: ${effort ?? unasked}), handed ${verification ? "the Verification-run procedure, the finding file" : "the deep procedure"}, the Threat pack and the Scan recipe.`,
492
412
  );
493
413
  clocks.end();
494
414
  // The scan wall clock: the agent step alone.
@@ -496,25 +416,16 @@ async function lifecycle({
496
416
  /** @type {import("../exec.mjs").StartResult | null} null when a limit stopped it */
497
417
  let agent = null;
498
418
  try {
499
- agent = await driver.exec(
500
- agentScript({
501
- baseUrl: route.url,
502
- report: REPORT_PATH,
503
- workspace: WORKSPACE,
504
- maxTurns: limits.turns,
505
- ...(model !== undefined ? { model } : {}),
506
- ...(effort !== undefined ? { effort } : {}),
507
- kind: credentialKind,
508
- }),
509
- { env: agentEnv(credentialKind, callerKey) },
510
- );
419
+ agent = await driver.exec(agentScript({ plan, report: REPORT_PATH, workspace: WORKSPACE }), {
420
+ env: plan.launch.env,
421
+ });
511
422
  } catch (e) {
512
423
  if (!(e instanceof LimitReached)) throw e;
513
424
  }
514
425
  clocks.end();
515
- // Claude Code's own turn limit ended it: the script's fixed marker says so.
516
- if (agent && agent.stdout.toString("utf8").split(/\r?\n/).includes(TURNS_MARKER)) {
517
- clocks.stop(TURNS, `Claude Code's ${limits.turns}-turn limit`);
426
+ // The harness's own turn limit ended it: the script's fixed marker says so.
427
+ if (agent && agent.stdout.toString("utf8").split(/\r?\n/).includes(turnsMarker(plan))) {
428
+ clocks.stop(TURNS, `${displayName}'s ${limits.turns}-turn limit`);
518
429
  }
519
430
  // The scan is over: no route out is left open while the report comes out.
520
431
  await driver.close();
@@ -525,17 +436,27 @@ async function lifecycle({
525
436
  ? `Model proxy: ${proxy ? "closed" : "not started"} (${PUBLIC_LOG}).`
526
437
  : `Model proxy: ${proxy?.summary() ?? "not started"}.`,
527
438
  );
528
- // Every answer a 401 or 403: say plainly that the credential was refused,
439
+ // The harness said it has no credential it reads: the script's fixed line.
440
+ if (
441
+ agent &&
442
+ agent.status !== 0 &&
443
+ agent.stdout.toString("utf8").split(/\r?\n/).includes(credentialMarker(plan))
444
+ ) {
445
+ err(
446
+ `No model credential: ${displayName} said authentication is required, so it read no API key in the sandbox and asked for a sign-in, which deep-scan never gives it. This is a fault of the harness's launch, not of your key: report it with this line.`,
447
+ );
448
+ }
449
+ // Every answer a refusal: say plainly that the credential was refused,
529
450
  // its kind and where it came from, never its value. Locally only: a public
530
451
  // log gets none of the model API's answers.
531
452
  if (!publicLog && proxy?.credentialRefused())
532
- err(credentialRefusedLine(credentialKind, credentialFrom));
453
+ err(credentialRefusedLine(credentialKind, credentialFrom, harness, model));
533
454
  const stopped = clocks.stopped();
534
455
  if (stopped) {
535
456
  out(`${stoppedStatus(stopped)} Copying out what report the agent left.`);
536
457
  } else if (agent && agent.status !== 0 && publicLog) {
537
458
  err(
538
- `The agent step exited ${agent.status ?? "abnormally"}; copying out what report it left. Claude Code's error output stays in the sandbox (${PUBLIC_LOG}); run deep-scan locally to see it.`,
459
+ `The agent step exited ${agent.status ?? "abnormally"}; copying out what report it left. ${displayName}'s error output stays in the sandbox (${PUBLIC_LOG}); run deep-scan locally to see it.`,
539
460
  );
540
461
  } else if (agent && agent.status !== 0) {
541
462
  const lines = agent.stderr
@@ -547,7 +468,7 @@ async function lifecycle({
547
468
  `The agent step exited ${agent.status ?? "abnormally"}; copying out what report it left.`,
548
469
  ...(lines.length
549
470
  ? [
550
- `Claude Code's error output (its last ${AGENT_ERROR_LINES} lines at most; the rest of its output stays in the sandbox):`,
471
+ `${displayName}'s error output (its last ${AGENT_ERROR_LINES} lines at most; the rest of its output stays in the sandbox):`,
551
472
  ...indent(lines.slice(-AGENT_ERROR_LINES).join("\n")),
552
473
  ]
553
474
  : []),
@@ -625,34 +546,6 @@ async function lifecycle({
625
546
  return agent?.status === 0 ? 0 : 1;
626
547
  }
627
548
 
628
- /**
629
- * Run each teardown command, whatever happened before. Synchronous, so it
630
- * finishes even while an interrupt is pending.
631
- * @returns {boolean} whether nothing was left behind
632
- */
633
- function teardown(runner, commands, out, err) {
634
- if (!commands.length) return true;
635
- const left = [];
636
- for (const { what, cmd, args } of commands) {
637
- const r = runner(cmd, args);
638
- if (r.status !== 0 && !/no such|not found/i.test(r.stderr)) {
639
- left.push(`${what}: ${firstLine(r.stderr) || `exit ${r.status}`}`);
640
- }
641
- }
642
- if (left.length) {
643
- err(
644
- [
645
- "TEARDOWN could not remove:",
646
- ...left.map((l) => ` - ${l}`),
647
- `Remove them by hand; every Docker resource carries the label ${LABEL}, and every sandbox's name starts with agent-kit-deep-.`,
648
- ].join("\n"),
649
- );
650
- return false;
651
- }
652
- out(`Teardown: removed ${commands.map((c) => c.what).join(", ")}.`);
653
- return true;
654
- }
655
-
656
549
  async function fetchGrounding(fetch, url, where, clocks) {
657
550
  const fail = (why) =>
658
551
  new StepFailed([`FAILED ${where}: could not fetch ${url}: ${why}`, ENDS_HERE]);
@@ -1,7 +1,8 @@
1
1
  // The limits that bound every Deep scan (#371), all enforced from outside
2
2
  // the sandbox: the setup and scan wall clocks by the launcher, the turns by
3
- // the launcher's own `--max-turns` on the claude command line, and the token
4
- // cap by the model proxy, which counts the model API's returned `usage`.
3
+ // the launcher's own `--max-turns` on the claude command line (a harness with
4
+ // no turn limit, such as Codex CLI, has none), and the token cap by the model
5
+ // proxy, which counts the model API's returned `usage`.
5
6
  // Limits come from launcher flags only (and, in CI, workflow inputs): the
6
7
  // Scan recipe never sets them (recipe.mjs refuses a limit field), so a
7
8
  // merged recipe change cannot raise a run's spend.
@@ -73,12 +74,17 @@ export function parseLimits(values, defaults = DEFAULT_LIMITS) {
73
74
  return { limits };
74
75
  }
75
76
 
76
- /** The limits as one line of the launcher's output. */
77
- export function describeLimits(limits) {
78
- const flags = Object.values(LIMIT_FLAGS)
79
- .map((f) => `--${f.flag}`)
77
+ /**
78
+ * The limits as one line of the launcher's output. A harness with no turn
79
+ * limit (`turnLimit: false`) names none.
80
+ */
81
+ export function describeLimits(limits, { turnLimit = true } = {}) {
82
+ const flags = Object.entries(LIMIT_FLAGS)
83
+ .filter(([key]) => turnLimit || key !== "turns")
84
+ .map(([, f]) => `--${f.flag}`)
80
85
  .join(", ");
81
- return `Limits: setup ${limits.setupMinutes} min, scan ${limits.scanMinutes} min, ${limits.turns} turns, ${limits.tokens} tokens (raise them with ${flags}).`;
86
+ const turns = turnLimit ? `${limits.turns} turns, ` : "";
87
+ return `Limits: setup ${limits.setupMinutes} min, scan ${limits.scanMinutes} min, ${turns}${limits.tokens} tokens (raise them with ${flags}).`;
82
88
  }
83
89
 
84
90
  /** A run stopped by a limit: what fired, said for a person. */