@intentic/sandbox-contract 1.390.0 → 1.392.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (192) hide show
  1. package/README.md +6 -1
  2. package/dist/contracts/agents.contract.d.ts +69 -0
  3. package/dist/contracts/agents.contract.d.ts.map +1 -1
  4. package/dist/contracts/agents.contract.js +10 -0
  5. package/dist/contracts/agents.contract.js.map +1 -1
  6. package/dist/contracts/ci.contract.d.ts +18 -0
  7. package/dist/contracts/ci.contract.d.ts.map +1 -1
  8. package/dist/contracts/ci.contract.js +19 -1
  9. package/dist/contracts/ci.contract.js.map +1 -1
  10. package/dist/contracts/device.contract.d.ts +10 -0
  11. package/dist/contracts/device.contract.d.ts.map +1 -1
  12. package/dist/contracts/ports.contract.d.ts +5 -0
  13. package/dist/contracts/ports.contract.d.ts.map +1 -1
  14. package/dist/contracts/ports.contract.js +1 -1
  15. package/dist/contracts/ports.contract.js.map +1 -1
  16. package/dist/contracts/runner.contract.d.ts +12 -4
  17. package/dist/contracts/runner.contract.d.ts.map +1 -1
  18. package/dist/contracts/runs.contract.d.ts +16 -0
  19. package/dist/contracts/runs.contract.d.ts.map +1 -1
  20. package/dist/contracts/settings.contract.d.ts +16 -0
  21. package/dist/contracts/settings.contract.d.ts.map +1 -1
  22. package/dist/contracts/system.contract.d.ts +66 -0
  23. package/dist/contracts/system.contract.d.ts.map +1 -1
  24. package/dist/contracts/system.contract.js +10 -1
  25. package/dist/contracts/system.contract.js.map +1 -1
  26. package/dist/events/agent-events.d.ts +4 -0
  27. package/dist/events/agent-events.d.ts.map +1 -1
  28. package/dist/events/agent-events.js +1 -0
  29. package/dist/events/agent-events.js.map +1 -1
  30. package/dist/events/agent-transcript.d.ts +1 -0
  31. package/dist/events/agent-transcript.d.ts.map +1 -1
  32. package/dist/events/failure-rows.js +1 -1
  33. package/dist/events/failure-rows.js.map +1 -1
  34. package/dist/events/land-conflict.d.ts +1 -0
  35. package/dist/events/land-conflict.d.ts.map +1 -1
  36. package/dist/events/land-conflict.js +4 -3
  37. package/dist/events/land-conflict.js.map +1 -1
  38. package/dist/events/requests.d.ts +1 -0
  39. package/dist/events/requests.d.ts.map +1 -1
  40. package/dist/events/requests.js +1 -1
  41. package/dist/events/requests.js.map +1 -1
  42. package/dist/events/resume.d.ts +2 -0
  43. package/dist/events/resume.d.ts.map +1 -1
  44. package/dist/events/resume.js +2 -0
  45. package/dist/events/resume.js.map +1 -1
  46. package/dist/events/sandbox-notice.d.ts +1 -0
  47. package/dist/events/sandbox-notice.d.ts.map +1 -1
  48. package/dist/events/sandbox-notice.js +1 -0
  49. package/dist/events/sandbox-notice.js.map +1 -1
  50. package/dist/events/system-events.d.ts +12 -0
  51. package/dist/events/system-events.d.ts.map +1 -1
  52. package/dist/events/transcript.d.ts +1 -0
  53. package/dist/events/transcript.d.ts.map +1 -1
  54. package/dist/events/transcript.js +4 -0
  55. package/dist/events/transcript.js.map +1 -1
  56. package/dist/index.d.ts +190 -0
  57. package/dist/index.d.ts.map +1 -1
  58. package/dist/models/agent-standing.d.ts +2 -0
  59. package/dist/models/agent-standing.d.ts.map +1 -1
  60. package/dist/models/agent-standing.js.map +1 -1
  61. package/dist/models/model-setups.d.ts.map +1 -1
  62. package/dist/models/model-setups.js +2 -1
  63. package/dist/models/model-setups.js.map +1 -1
  64. package/dist/policy/failure-codes.d.ts +158 -0
  65. package/dist/policy/failure-codes.d.ts.map +1 -0
  66. package/dist/policy/failure-codes.js +50 -0
  67. package/dist/policy/failure-codes.js.map +1 -0
  68. package/dist/protocol/raw/raw-routes.d.ts +12 -0
  69. package/dist/protocol/raw/raw-routes.d.ts.map +1 -1
  70. package/dist/protocol/raw/raw-routes.js +3 -0
  71. package/dist/protocol/raw/raw-routes.js.map +1 -1
  72. package/dist/schemas/agent-press.d.ts +13 -0
  73. package/dist/schemas/agent-press.d.ts.map +1 -0
  74. package/dist/schemas/agent-press.js +14 -0
  75. package/dist/schemas/agent-press.js.map +1 -0
  76. package/dist/schemas/agents-list.d.ts +6 -0
  77. package/dist/schemas/agents-list.d.ts.map +1 -1
  78. package/dist/schemas/agents.d.ts +11 -0
  79. package/dist/schemas/agents.d.ts.map +1 -1
  80. package/dist/schemas/agents.js +5 -6
  81. package/dist/schemas/agents.js.map +1 -1
  82. package/dist/schemas/ci.d.ts +21 -0
  83. package/dist/schemas/ci.d.ts.map +1 -1
  84. package/dist/schemas/ci.js +29 -0
  85. package/dist/schemas/ci.js.map +1 -1
  86. package/dist/schemas/device-resources.d.ts +54 -0
  87. package/dist/schemas/device-resources.d.ts.map +1 -0
  88. package/dist/schemas/device-resources.js +29 -0
  89. package/dist/schemas/device-resources.js.map +1 -0
  90. package/dist/schemas/devices.d.ts +2 -52
  91. package/dist/schemas/devices.d.ts.map +1 -1
  92. package/dist/schemas/devices.js +2 -27
  93. package/dist/schemas/devices.js.map +1 -1
  94. package/dist/schemas/git/clone.d.ts +12 -0
  95. package/dist/schemas/git/clone.d.ts.map +1 -0
  96. package/dist/schemas/git/clone.js +14 -0
  97. package/dist/schemas/git/clone.js.map +1 -0
  98. package/dist/schemas/hosts.d.ts +23 -0
  99. package/dist/schemas/hosts.d.ts.map +1 -1
  100. package/dist/schemas/hosts.js +14 -1
  101. package/dist/schemas/hosts.js.map +1 -1
  102. package/dist/schemas/metrics.d.ts +59 -0
  103. package/dist/schemas/metrics.d.ts.map +1 -1
  104. package/dist/schemas/metrics.js +19 -0
  105. package/dist/schemas/metrics.js.map +1 -1
  106. package/dist/schemas/ports.d.ts +10 -0
  107. package/dist/schemas/ports.d.ts.map +1 -1
  108. package/dist/schemas/ports.js +8 -0
  109. package/dist/schemas/ports.js.map +1 -1
  110. package/dist/schemas/providers/handoff.d.ts +1 -0
  111. package/dist/schemas/providers/handoff.d.ts.map +1 -1
  112. package/dist/schemas/providers/handoff.js +4 -1
  113. package/dist/schemas/providers/handoff.js.map +1 -1
  114. package/dist/schemas/providers/plan-limits.js +1 -1
  115. package/dist/schemas/providers/plan-limits.js.map +1 -1
  116. package/dist/schemas/run-targets.d.ts +31 -0
  117. package/dist/schemas/run-targets.d.ts.map +1 -1
  118. package/dist/schemas/run-targets.js +9 -0
  119. package/dist/schemas/run-targets.js.map +1 -1
  120. package/dist/schemas/settings.d.ts +29 -0
  121. package/dist/schemas/settings.d.ts.map +1 -1
  122. package/dist/schemas/settings.js +17 -0
  123. package/dist/schemas/settings.js.map +1 -1
  124. package/dist/schemas/stranded-clone.d.ts +9 -0
  125. package/dist/schemas/stranded-clone.d.ts.map +1 -0
  126. package/dist/schemas/stranded-clone.js +12 -0
  127. package/dist/schemas/stranded-clone.js.map +1 -0
  128. package/dist/state/definition.d.ts +20 -0
  129. package/dist/state/definition.d.ts.map +1 -1
  130. package/dist/state/fix-stance.js +1 -1
  131. package/dist/state/fix-stance.js.map +1 -1
  132. package/dist/state/runtime-state.d.ts +3 -0
  133. package/dist/state/runtime-state.d.ts.map +1 -1
  134. package/dist/state/runtime-state.js +1 -0
  135. package/dist/state/runtime-state.js.map +1 -1
  136. package/dist/state/workspace-state.d.ts.map +1 -1
  137. package/dist/state/workspace-state.js +1 -1
  138. package/dist/state/workspace-state.js.map +1 -1
  139. package/dist/text/transcript-fold.d.ts.map +1 -1
  140. package/dist/text/transcript-fold.js +6 -6
  141. package/dist/text/transcript-fold.js.map +1 -1
  142. package/dist/text/transcript-interruption.d.ts +4 -0
  143. package/dist/text/transcript-interruption.d.ts.map +1 -0
  144. package/dist/text/transcript-interruption.js +27 -0
  145. package/dist/text/transcript-interruption.js.map +1 -0
  146. package/package.json +5 -5
  147. package/src/contracts/agents.contract.ts +12 -0
  148. package/src/contracts/ci.contract.ts +21 -0
  149. package/src/contracts/ports.contract.ts +3 -2
  150. package/src/contracts/system.contract.ts +12 -1
  151. package/src/events/agent-events.ts +2 -0
  152. package/src/events/failure-rows.ts +1 -1
  153. package/src/events/land-conflict.test.ts +13 -1
  154. package/src/events/land-conflict.ts +8 -4
  155. package/src/events/requests.ts +1 -1
  156. package/src/events/resume.test.ts +7 -1
  157. package/src/events/resume.ts +3 -0
  158. package/src/events/sandbox-notice.ts +1 -0
  159. package/src/events/transcript.ts +6 -0
  160. package/src/models/agent-standing.ts +4 -0
  161. package/src/models/model-setups.test.ts +11 -0
  162. package/src/models/model-setups.ts +4 -1
  163. package/src/policy/failure-codes.ts +157 -0
  164. package/src/policy/tests/failure-codes.test.ts +141 -0
  165. package/src/protocol/raw/raw-routes.ts +5 -0
  166. package/src/schemas/agent-press.test.ts +46 -0
  167. package/src/schemas/agent-press.ts +34 -0
  168. package/src/schemas/agents.ts +8 -8
  169. package/src/schemas/ci.ts +45 -0
  170. package/src/schemas/device-resources.ts +58 -0
  171. package/src/schemas/devices.ts +20 -56
  172. package/src/schemas/git/clone.ts +22 -0
  173. package/src/schemas/hosts.ts +34 -3
  174. package/src/schemas/metrics.ts +28 -0
  175. package/src/schemas/ports.ts +12 -0
  176. package/src/schemas/providers/handoff.test.ts +7 -0
  177. package/src/schemas/providers/handoff.ts +4 -1
  178. package/src/schemas/providers/plan-limits.ts +1 -1
  179. package/src/schemas/run-targets.ts +23 -1
  180. package/src/schemas/settings.ts +32 -0
  181. package/src/schemas/stranded-clone.ts +15 -0
  182. package/src/state/fix-stance.ts +1 -1
  183. package/src/state/runtime-state.ts +4 -0
  184. package/src/state/workspace-state.ts +3 -2
  185. package/src/text/transcript-fold.test.ts +21 -7
  186. package/src/text/transcript-fold.ts +5 -6
  187. package/src/text/transcript-interruption.ts +30 -0
  188. package/dist/policy/turned-away.d.ts +0 -3
  189. package/dist/policy/turned-away.d.ts.map +0 -1
  190. package/dist/policy/turned-away.js +0 -33
  191. package/dist/policy/turned-away.js.map +0 -1
  192. package/src/policy/turned-away.ts +0 -52
@@ -1,4 +1,4 @@
1
- import { isLandConflict, keepDeletedPrompt } from "./land-conflict.js";
1
+ import { isLandConflict, keepDeletedPrompt, landConflictPrompt } from "./land-conflict.js";
2
2
 
3
3
  // The turn a "Keep deleted" press sends: the same errand as a Resolve (the chat folds it as one), but with the answer
4
4
  // to the modify/delete conflict already decided, since "keep both sides" would bring the owner's deleted file back.
@@ -12,6 +12,9 @@ it(`asks for the deleted files to stay gone, named per repo, on the named main l
12
12
  );
13
13
  expect(isLandConflict(prompt)).toBe(true);
14
14
  expect(prompt).toContain("`git rebase main`");
15
+ // Commits only what is left: the land usually committed the worktree, and `git commit` with nothing staged exits 1.
16
+ expect(prompt).toContain("1. `git add -A; git diff --cached --quiet || git commit -qm wip`");
17
+ expect(prompt).not.toContain("&& git commit");
15
18
  expect(prompt).toContain("`git rm` it");
16
19
  expect(prompt).toContain(`Keep them deleted: do not re-create them`);
17
20
  expect(prompt).toContain(`root\n - docs/reports/a.md`);
@@ -21,3 +24,12 @@ it(`asks for the deleted files to stay gone, named per repo, on the named main l
21
24
  it(`falls back to the worktree list when no main line was named`, () => {
22
25
  expect(keepDeletedPrompt([{ repo: `root`, path: `a.md`, reason: `workspace` }], undefined)).toContain("FIRST line of `git worktree list`");
23
26
  });
27
+
28
+ // The prompt said "The app re-lands automatically" while 83 of 90 resolve turns on one sandbox ended held on their
29
+ // branch again: it lands by itself only where the conversation's work does, and it says so.
30
+ it(`tells the resolve turn what becomes of its work, held or landed, and to commit only what is left`, () => {
31
+ const prompt = landConflictPrompt([{ repo: `root`, clean: 0, mainBranch: `main`, paths: [{ path: `a.ts`, reason: `diverged` }] }]);
32
+ expect(prompt).toContain("1. `git add -A; git diff --cached --quiet || git commit -qm wip`");
33
+ expect(prompt).not.toContain(`re-lands automatically`);
34
+ expect(prompt).toContain(`lands it where this conversation's work lands by itself, or keeps it on its branch, ready for the user to land from its review`);
35
+ });
@@ -2,7 +2,7 @@ import type { LandConflict, LandConflictReason } from "../schemas/agents.js";
2
2
  import { withoutResumeNote } from "./resume.js";
3
3
 
4
4
  // The turn sent to a conversation whose land refused, asking it to rebase and resolve, recognised by its opening. The
5
- // app sends it on a Resolve press and the daemon to a home conversation (home/home-conflict.ts), so it is composed here,
5
+ // app sends it on a Resolve press and the daemon at once where nobody would press it (land/settle/resolve-conflict.ts), so it is composed here,
6
6
  // where the fold must recognise it as well: that turn's own rebase notice would otherwise tell the reader the thing the
7
7
  // turn was sent to fix.
8
8
 
@@ -59,6 +59,10 @@ const sharedMainBranch = (conflicts: readonly LandConflict[] | undefined): strin
59
59
  return only === undefined || only === "" ? undefined : only;
60
60
  };
61
61
 
62
+ // Step 1 of both prompts. Never `&&`: the land usually committed the worktree already, and a `git commit` with nothing
63
+ // staged exits 1, which killed the rebase chained after it in 20 of 90 resolve turns on one sandbox (2026-11).
64
+ export const COMMIT_FIRST = "1. `git add -A; git diff --cached --quiet || git commit -qm wip`: a rebase refuses to start on a dirty tree, and this commits only when something is left to commit.";
65
+
62
66
  /**
63
67
  * The turn that asks a conversation to rebase and resolve a land that refused: sent by the app's Resolve press, and by
64
68
  * the daemon to a home conversation, whose person is never asked to. Required for the turn to succeed: commit first
@@ -71,7 +75,7 @@ export const landConflictPrompt = (conflicts: readonly LandConflict[] | undefine
71
75
  return [
72
76
  LAND_CONFLICT_OPENING,
73
77
  [
74
- "1. `git add -A && git commit`: a rebase refuses to start on a dirty tree.",
78
+ COMMIT_FIRST,
75
79
  main === undefined
76
80
  ? "2. `git rebase <branch>`, where `<branch>` is the one in brackets on the FIRST line of `git worktree list`, the user's main line. If the rebase gets away from you: `git rebase --abort`, then `git merge <branch>` instead."
77
81
  : `2. \`git rebase ${main}\`, that is the user's main line. If the rebase gets away from you: \`git rebase --abort\`, then \`git merge ${main}\` instead.`,
@@ -87,7 +91,7 @@ export const landConflictPrompt = (conflicts: readonly LandConflict[] | undefine
87
91
  };
88
92
 
89
93
  const STAY_INSIDE =
90
- "Stay inside your own worktree: never edit, stage or commit in the user's checkout. The app re-lands automatically when your turn ends, stop once the rebase is clean.";
94
+ "Stay inside your own worktree: never edit, stage or commit in the user's checkout. Stop once the rebase is clean: when your turn ends the app checks your branch against the main line again, and lands it where this conversation's work lands by itself, or keeps it on its branch, ready for the user to land from its review.";
91
95
 
92
96
  /**
93
97
  * The same turn for a land the user's own deletion held: they deleted files this conversation changed, chose to keep
@@ -100,7 +104,7 @@ export const keepDeletedPrompt = (deleted: readonly Blocker[], mainBranch: strin
100
104
  return [
101
105
  LAND_CONFLICT_OPENING,
102
106
  [
103
- "1. `git add -A && git commit`: a rebase refuses to start on a dirty tree.",
107
+ COMMIT_FIRST,
104
108
  mainBranch === undefined || mainBranch === ""
105
109
  ? "2. `git rebase <branch>`, where `<branch>` is the one in brackets on the FIRST line of `git worktree list`, the user's main line."
106
110
  : `2. \`git rebase ${main}\`, that is the user's main line.`,
@@ -221,7 +221,7 @@ export type ContextUsage = z.infer<typeof ContextUsageSchema>;
221
221
  export const ToolKindSchema = z.enum(["read", "edit", "delete", "move", "search", "execute", "think", "fetch", "other"]);
222
222
  export type ToolKind = z.infer<typeof ToolKindSchema>;
223
223
 
224
- export const ToolCallStatusSchema = z.enum(["pending", "in_progress", "completed", "failed"]);
224
+ export const ToolCallStatusSchema = z.enum(["pending", "in_progress", "completed", "failed", "interrupted"]);
225
225
  export type ToolCallStatus = z.infer<typeof ToolCallStatusSchema>;
226
226
 
227
227
  // A file a tool call touches. Workspace-root-relative, forward-slash; adapters normalize from the turn's cwd. `line` is
@@ -1,4 +1,4 @@
1
- import { RESUME_NOTES, resumeDisclosure, resumeNoteWith, resumeNoticeRow, withResumeNote, withoutResumeNote } from "./resume.js";
1
+ import { CONTINUATION_NOTE, RESTART_LOSSES, RESUME_NOTES, resumeDisclosure, resumeNoteWith, resumeNoticeRow, withResumeNote, withoutResumeNote } from "./resume.js";
2
2
 
3
3
  // Wrapping then unwrapping a resume note must return the exact original prompt; a mismatch leaks machine narration into
4
4
  // the user's own words on screen.
@@ -98,3 +98,9 @@ test("a carried-on turn's note stands alone, leaves no words, and records as a n
98
98
  noticeCode: { code: "resumed", params: { reason: "continued" } },
99
99
  });
100
100
  });
101
+
102
+
103
+ test("a manual continuation explains what a sandbox restart can have lost", () => {
104
+ expect(CONTINUATION_NOTE).toContain(`If the sandbox restarted: ${RESTART_LOSSES}`);
105
+ expect(withoutResumeNote(CONTINUATION_NOTE)).toBe("");
106
+ });
@@ -2,6 +2,7 @@ import { noticeCode, type ResumeNoticeReason } from "./sandbox-notice.js";
2
2
  import type { TranscriptRow, TurnNote } from "./transcript.js";
3
3
 
4
4
  // What a resumed turn's prompt says happened; lives on the wire since the client must recognise it too.
5
+ export const RESTART_LOSSES = "The sandbox ended the turn's in-process helpers. Background jobs and dev servers ended on a container restart; a daemon-only restart may preserve kept jobs and terminal sessions. A container recreation clears /tmp, including scripts and screenshots; check before relying on any file there. Retained helper edits stay in .claude/worktrees/agent-*. Keep evidence that must survive in /work/.intentic/records/artifacts/.";
5
6
 
6
7
  // The shared prefix lets a joining window reuse the existing bubble, not render the note as a new message.
7
8
  // What follows the note is the original request repeated; `answered` carries the user's actual answer instead.
@@ -59,6 +60,8 @@ export const resumeNoteWith = (note: string, tail: string | undefined): string =
59
60
  return said === undefined || said === "" ? note : `${note} ${said}`;
60
61
  };
61
62
 
63
+ export const CONTINUATION_NOTE = resumeNoteWith(RESUME_NOTES.continued, `If the sandbox restarted: ${RESTART_LOSSES}`);
64
+
62
65
  // The user's own words inside a resumed prompt, note and explanation stripped. Returns the prompt unchanged when it
63
66
  // isn't a resume, so any attach head can pass through it. A note standing alone (`continued`) leaves no words, and a
64
67
  // note's tail (resumeNoteWith) goes with it, up to the blank line that ends it.
@@ -110,6 +110,7 @@ export const SandboxNoticeSchema = z.discriminatedUnion("code", [
110
110
  cleared: count.optional(),
111
111
  model: z.string().optional(),
112
112
  fellBack: z.boolean().optional(),
113
+ reason: z.string().optional(),
113
114
  }),
114
115
  }),
115
116
  // A home conversation going on in a fresh session (schemas/providers/handoff.ts FreshStartSchema): `why` it did,
@@ -544,6 +544,12 @@ export const TurnEndingSchema = z.object({
544
544
  handoff: HandoffOfferSchema.optional().describe(
545
545
  "How the held turn can continue once its cache is cold: carry the session, trim it, or summarise it, which one the sandbox suggests, and which one a person picked. Absent where there is nothing to carry.",
546
546
  ),
547
+ pressOnly: z
548
+ .boolean()
549
+ .optional()
550
+ .describe(
551
+ "Only a press sends it again: no standing answer re-runs it, whatever the conversation's answer to its wall says, since it reached its own ceiling or ended incomplete. Absent for every other hold.",
552
+ ),
547
553
  })
548
554
  .optional()
549
555
  .describe("Present when the daemon still holds the refused turn whole, so a press re-runs it rather than appending a message after it."),
@@ -8,6 +8,7 @@ import {
8
8
  type LandFailure,
9
9
  } from "../schemas/agents.js";
10
10
  import { type AgentNext, goesBySelf } from "../schemas/agent-next.js";
11
+ import type { AgentPress } from "../schemas/agent-press.js";
11
12
 
12
13
  // (2026-10-16) Moved here from the editor (_editor/web/src/models/agent-status/agentStatus-standing.ts, which re-exports
13
14
  // it), so the daemon counts what needs the person by the very rules the board draws with (models/agent-lanes.ts): the
@@ -56,6 +57,9 @@ export interface AgentStanding {
56
57
  // What carries it on with nobody pressing anything, and when (AgentSummary.next): the daemon's one reading, which
57
58
  // every lane, chip and corner below asks, never the hold, the queue or an answer it was derived from.
58
59
  readonly next?: AgentNext | undefined;
60
+ // What a person's Continue does now (AgentSummary.press): the daemon's one reading, which the chat's strip follows over
61
+ // its own. Absent from a sandbox older than it, and from a standing carried where a card can't go.
62
+ readonly press?: AgentPress | undefined;
59
63
  // A land that broke (AgentSummary.landFailure), standing until one goes through whatever turns run after it. Absent
60
64
  // from a sandbox older than it, where only a turn's own `failure` can say so.
61
65
  readonly landFailure?: LandFailure | undefined;
@@ -98,3 +98,14 @@ test(`per-job lists become setups every job runs exactly as before on`, () => {
98
98
  // A job that never had a list, or had an empty one, ran on nothing and is on none.
99
99
  expect([settings.roleSetups[`loop-iteration`], settings.roleSetups[`safety-judge`]]).toEqual([undefined, undefined]);
100
100
  });
101
+
102
+
103
+ test("Low skips explicitly slow models and keeps the fast capable alternatives", () => {
104
+ expect(presetPins("low", [
105
+ { provider: "devin", ready: true, models: ["swe-1-6-slow", "swe-1-6-fast-slow", "swe-1-6-fast"] },
106
+ CLAUDE,
107
+ ])).toEqual([
108
+ { provider: "devin", model: "swe-1-6-fast" },
109
+ { provider: "claude", model: "claude-haiku-4-5-20251001" },
110
+ ]);
111
+ });
@@ -104,7 +104,10 @@ export const presetPins = (preset: PresetSetup, sources: readonly ModelSource[])
104
104
  sources
105
105
  .filter((source) => source.ready && !isEndpointProvider(source.provider))
106
106
  .flatMap((source) => {
107
- const newest = newestOnRung(source.models, PRESET_RUNG[preset]);
107
+ // Cheap jobs are on the interaction path (titles, commits, summaries); an explicitly slow model is
108
+ // unsuitable for the automatic Low preset. An owner's written pins remain authoritative.
109
+ const models = preset === "low" ? source.models.filter((model) => !/(?:^|[-_])slow(?:$|[-_])/i.test(model)) : source.models;
110
+ const newest = newestOnRung(models, PRESET_RUNG[preset]);
108
111
  return newest === undefined ? [] : [{ provider: source.provider, model: newest }];
109
112
  })
110
113
  .slice(0, PRESET_LENGTH);
@@ -0,0 +1,157 @@
1
+ import type { AgentErrorCode } from "../events/agent-events.js";
2
+
3
+ /* WHAT EACH FAILURE CODE IS, ONCE: the kind a reader names it by and what becomes of the turn it ended. Five places used
4
+ to classify the codes by hand (the door set here, the board's kinds, the chat's switch, the daemon's hold, the record's
5
+ ending) and they disagreed: the board called a refusal "Held" that the chat drew as a crash, and a turn that hit its
6
+ own ceiling was held by nobody, so no window offered to carry it on and people typed "Continue" by hand (2026-11).
7
+ Every one of them now reads this table, and a code added to the wire fails the build here until it has a row. */
8
+
9
+ // What kind of failure ended a turn, as the reader acts on it: the board's corner names the kind, and the chat's notice
10
+ // leads a provider's words with the kind's own line. Grouped by what the reader does next, not by provider; a failure
11
+ // nothing coded has no kind, and each surface says so in its own words.
12
+ export type FailureKind =
13
+ // The account signs in but is refused service: an organization or plan that switched it off.
14
+ | "access"
15
+ // The account's credential is dead or missing; a reconnect fixes it.
16
+ | "signedOut"
17
+ // The provider failed and kept failing past the retries.
18
+ | "outage"
19
+ // The model the turn named is not served to this account, or cannot run this kind of turn.
20
+ | "model"
21
+ // The turn is bigger than the model's window.
22
+ | "contextFull"
23
+ // The installed engine is older than the model requires.
24
+ | "update"
25
+ // The provider's safety classifier stopped the turn.
26
+ | "flagged"
27
+ // A spent allowance the `rate_limit` code does not cover (the free trial's day).
28
+ | "limit"
29
+ // The privacy shield held the words back before anything was read.
30
+ | "privacy"
31
+ // Held at the door for want of room, as a memory hold is.
32
+ | "held"
33
+ // The runtime stopped partway without failing outright; the work may be half done.
34
+ | "cutShort"
35
+ // The harness read the message as a slash command it does not have; the model never saw it.
36
+ | "command"
37
+ // The runtime warned about a turn it went on with: a note, not an ending.
38
+ | "advisory";
39
+
40
+ // What becomes of the turn a failure ended, which the daemon's hold and every window's offer both read.
41
+ export type FailureCourse =
42
+ // Refused before the model saw a word: nothing ran, and the words wait in the conversation's queue (or with the
43
+ // sandbox that started the turn) for whatever lets them through.
44
+ | "door"
45
+ // A spent allowance: held for its reopen, or for another account.
46
+ | "limit"
47
+ // The provider failing transiently: held for the breaker's next retry.
48
+ | "outage"
49
+ // A Claude token refused mid-turn: held while the daemon re-mints it, then re-run.
50
+ | "remint"
51
+ // The session outgrew the model's window: re-run once in a fresh session.
52
+ | "overflow"
53
+ // The provider's safety classifier stopped it: held for a person to choose the way on each time.
54
+ | "flagged"
55
+ // Stopped partway with nothing to repair: held whole for a person's press (Continue), since the next move is theirs.
56
+ | "carry"
57
+ // Nothing is held: what is left is the person's next message, or a fix outside the conversation.
58
+ | "bare"
59
+ // A warning about a turn that went on, not an ending.
60
+ | "note";
61
+
62
+ export interface FailureTraits {
63
+ readonly kind: FailureKind;
64
+ readonly course: FailureCourse;
65
+ // A refusal about the model itself (its allowance, its account, its catalogue, its window), which another model gets
66
+ // past: a turn one of these stops partway offers to carry on elsewhere rather than to wait.
67
+ readonly anotherModelClears?: true;
68
+ }
69
+
70
+ // Every code the wire names, with its kind and its course. The privacy shield's own refusals (privacy-egress.ts
71
+ // isPrivacyRefusal) are all the privacy kind and all turned away at the door.
72
+ export const FAILURE_CODES = {
73
+ // The session vanished mid-turn: the next send starts fresh.
74
+ "session-not-found": { kind: "cutShort", course: "bare" },
75
+ rate_limit: { kind: "limit", course: "limit" },
76
+ "codex-advisory": { kind: "advisory", course: "note" },
77
+ "codex-reauth": { kind: "signedOut", course: "bare" },
78
+ // Only the agent's own login command signs it in: nothing a press could re-run would get past it.
79
+ "acp-auth-required": { kind: "signedOut", course: "bare" },
80
+ "claude-reauth": { kind: "signedOut", course: "door" },
81
+ "claude-token-refused": { kind: "signedOut", course: "remint" },
82
+ // An organisation turned the account's Claude Code access off, or no account of the provider can serve: the next
83
+ // turn is routed off it (the daemon's blocked-account route), so the words wait for it rather than being spent.
84
+ "claude-not-entitled": { kind: "access", course: "door", anotherModelClears: true },
85
+ "account-not-entitled": { kind: "access", course: "bare" },
86
+ // The people this conversation works for may not spend the account the turn would run on.
87
+ "account-not-allowed": { kind: "access", course: "door", anotherModelClears: true },
88
+ "provider-outage": { kind: "outage", course: "outage" },
89
+ "trial-unavailable": { kind: "outage", course: "door", anotherModelClears: true },
90
+ "trial-model-unavailable": { kind: "model", course: "door", anotherModelClears: true },
91
+ "trial-exhausted": { kind: "limit", course: "door", anotherModelClears: true },
92
+ "unknown-command": { kind: "command", course: "door" },
93
+ "grok-model-invalid": { kind: "model", course: "bare" },
94
+ "codex-model-invalid": { kind: "model", course: "bare" },
95
+ "model-unavailable": { kind: "model", course: "door", anotherModelClears: true },
96
+ "context-window-too-small": { kind: "contextFull", course: "door", anotherModelClears: true },
97
+ "model-helper-only": { kind: "model", course: "door", anotherModelClears: true },
98
+ // The privacy shield refused an untrusted provider on a runtime it cannot read by content at all.
99
+ "privacy-unshielded": { kind: "privacy", course: "door" },
100
+ // The turn carries a tool list its runtime cannot keep.
101
+ "tools-unenforced": { kind: "held", course: "door" },
102
+ // The protected execution boundary refused admission, not an executed provider/runtime failure.
103
+ "agent-domain-refused": { kind: "held", course: "door" },
104
+ // The privacy shield found personal data in instructions a runtime loads itself, where it could not mask them.
105
+ "privacy-instructions": { kind: "privacy", course: "door" },
106
+ "context-overflow": { kind: "contextFull", course: "overflow" },
107
+ "subscription-required": { kind: "access", course: "bare" },
108
+ "agent-busy": { kind: "held", course: "bare" },
109
+ "sandbox-memory-low": { kind: "held", course: "door" },
110
+ // The conversation's own view of the workspace could not be set up in time: nothing was started in it.
111
+ "workspace-setup": { kind: "held", course: "door" },
112
+ "sandbox-disk-low": { kind: "held", course: "door" },
113
+ // The turn reached its own iteration or time ceiling, its work perhaps half done: carried on by a press, never by a
114
+ // clock, since a re-run on a timer is the runaway the ceiling exists to stop.
115
+ "turn-cap": { kind: "cutShort", course: "carry" },
116
+ "harness-incomplete": { kind: "cutShort", course: "carry" },
117
+ "engine-version-floor": { kind: "update", course: "door" },
118
+ "safeguard-flagged": { kind: "flagged", course: "flagged" },
119
+ } as const satisfies Record<AgentErrorCode, FailureTraits>;
120
+
121
+ // Looked up by a bare string, since a roster row and a stored ending carry the code as one: a newer sandbox's code this
122
+ // build has no row for reads as unknown, never as a wrong one, and never as an object prototype's own member.
123
+ const TRAITS_OF_CODE: ReadonlyMap<string, FailureTraits> = new Map(Object.entries(FAILURE_CODES));
124
+
125
+ /** What a failure code is; undefined for no code, and for a code this build does not know. */
126
+ export const failureTraitsOf = (code: string | undefined): FailureTraits | undefined => (code === undefined ? undefined : TRAITS_OF_CODE.get(code));
127
+
128
+ /**
129
+ * What becomes of the turn a failure ended. A failure nothing coded is a turn that stopped short with nothing named to
130
+ * repair, so it is carried on; a code this build does not know holds nothing, since nothing here knows what it would take.
131
+ */
132
+ export const failureCourseOf = (code: string | undefined): FailureCourse => {
133
+ if (code === undefined) {
134
+ return "carry";
135
+ }
136
+ return failureTraitsOf(code)?.course ?? "bare";
137
+ };
138
+
139
+ /* THE REFUSALS THAT TURN A WHOLE TURN AWAY AT THE DOOR: refused before the model saw a word, so nothing ran and the
140
+ message is still owed to somebody — the conversation's queue, held, for words a person sent, or the sandbox that
141
+ started the turn itself. Which codes those are is the failure table's to say (failure-codes.ts, the `door` course). */
142
+
143
+ // The codes whose traits say `test`, as a set: what they share is a fact about the turn, not a shape.
144
+ const codesWhere = (test: (traits: FailureTraits) => boolean): ReadonlySet<string> =>
145
+ new Set(Object.entries(FAILURE_CODES).flatMap(([code, traits]: [string, FailureTraits]) => (test(traits) ? [code] : [])));
146
+
147
+ const TURNED_AWAY = codesWhere((traits) => traits.course === "door");
148
+
149
+ // The refusals about the model itself (its allowance, its account, its catalogue, its window), which another model
150
+ // gets past: a turn one of these stops partway offers to carry on elsewhere rather than to wait.
151
+ const ANOTHER_MODEL_CLEARS = codesWhere((traits) => traits.anotherModelClears === true);
152
+
153
+ /** Whether another model would get past a refusal: the trial's, the model's, or the account's on it. */
154
+ export const anotherModelClears = (code: string | undefined): boolean => code !== undefined && ANOTHER_MODEL_CLEARS.has(code);
155
+
156
+ /** Whether a failure code refuses a turn before the model sees any of it. */
157
+ export const turnedAwayCode = (code: string | undefined): boolean => code !== undefined && TURNED_AWAY.has(code);
@@ -0,0 +1,141 @@
1
+ import { AgentErrorCodeSchema } from "../../events/agent-events.js";
2
+ import { isPrivacyRefusal } from "../../schemas/privacy-egress.js";
3
+ import { FAILURE_CODES, failureCourseOf, failureTraitsOf,anotherModelClears,turnedAwayCode } from "../failure-codes.js";
4
+
5
+ // The codes whose row says `test`, sorted, so a pin reads as a list.
6
+ const codesWhere = (test: (code: string) => boolean): string[] => AgentErrorCodeSchema.options.filter(test).toSorted();
7
+
8
+ test("every code the wire names has a row, and the table names no code the wire does not", () => {
9
+ expect(Object.keys(FAILURE_CODES).toSorted()).toEqual(AgentErrorCodeSchema.options.toSorted());
10
+ for (const code of AgentErrorCodeSchema.options) {
11
+ expect([code, failureTraitsOf(code)]).toEqual([code, FAILURE_CODES[code]]);
12
+ }
13
+ });
14
+
15
+ // The door course names the codes refused before the model saw a word.
16
+ test("the codes turned away at the door are exactly the eighteen refused before the model saw a word", () => {
17
+ const door = codesWhere((code) => failureCourseOf(code) === "door");
18
+ expect(door).toEqual(
19
+ [
20
+ "claude-reauth",
21
+ "claude-not-entitled",
22
+ "account-not-allowed",
23
+ "unknown-command",
24
+ "context-window-too-small",
25
+ "model-helper-only",
26
+ "privacy-unshielded",
27
+ "tools-unenforced",
28
+ "agent-domain-refused",
29
+ "privacy-instructions",
30
+ "sandbox-memory-low",
31
+ "workspace-setup",
32
+ "sandbox-disk-low",
33
+ "trial-unavailable",
34
+ "trial-model-unavailable",
35
+ "trial-exhausted",
36
+ "model-unavailable",
37
+ "engine-version-floor",
38
+ ].toSorted(),
39
+ );
40
+ expect(codesWhere(turnedAwayCode)).toEqual(door);
41
+ expect(turnedAwayCode(undefined)).toBe(false);
42
+ });
43
+
44
+ test("another model clears exactly the refusals about the model, its trial or its account", () => {
45
+ const cleared = [
46
+ "claude-not-entitled",
47
+ "account-not-allowed",
48
+ "context-window-too-small",
49
+ "model-helper-only",
50
+ "trial-unavailable",
51
+ "trial-model-unavailable",
52
+ "trial-exhausted",
53
+ "model-unavailable",
54
+ ].toSorted();
55
+ expect(codesWhere((code) => failureTraitsOf(code)?.anotherModelClears === true)).toEqual(cleared);
56
+ expect(codesWhere(anotherModelClears)).toEqual(cleared);
57
+ expect(anotherModelClears(undefined)).toBe(false);
58
+ });
59
+
60
+ test("every refusal the privacy shield names is the privacy kind, turned away at the door", () => {
61
+ const privacy = codesWhere(isPrivacyRefusal);
62
+ expect(privacy.length).toBeGreaterThan(0);
63
+ for (const code of privacy) {
64
+ expect([code, failureTraitsOf(code)?.kind, failureCourseOf(code)]).toEqual([code, "privacy", "door"]);
65
+ }
66
+ expect(codesWhere((code) => failureTraitsOf(code)?.kind === "privacy")).toEqual(privacy);
67
+ });
68
+
69
+ // The board's kinds as agentStatus-failure.ts kept them by hand until the table (KINDS_BY_CODE), the privacy shield's
70
+ // refusals added as it added them: pinned, so moving them here changed no word on a card.
71
+ test("every code keeps the kind the board named it by", () => {
72
+ const pinned = {
73
+ rate_limit: "limit",
74
+ "session-not-found": "cutShort",
75
+ "codex-advisory": "advisory",
76
+ "unknown-command": "command",
77
+ "agent-busy": "held",
78
+ "sandbox-memory-low": "held",
79
+ "sandbox-disk-low": "held",
80
+ "tools-unenforced": "held",
81
+ "agent-domain-refused": "held",
82
+ "claude-not-entitled": "access",
83
+ "account-not-entitled": "access",
84
+ "account-not-allowed": "access",
85
+ "subscription-required": "access",
86
+ "claude-reauth": "signedOut",
87
+ "codex-reauth": "signedOut",
88
+ "claude-token-refused": "signedOut",
89
+ "acp-auth-required": "signedOut",
90
+ "provider-outage": "outage",
91
+ "trial-unavailable": "outage",
92
+ "grok-model-invalid": "model",
93
+ "codex-model-invalid": "model",
94
+ "model-unavailable": "model",
95
+ "trial-model-unavailable": "model",
96
+ "model-helper-only": "model",
97
+ "context-window-too-small": "contextFull",
98
+ "context-overflow": "contextFull",
99
+ "engine-version-floor": "update",
100
+ "safeguard-flagged": "flagged",
101
+ "trial-exhausted": "limit",
102
+ "workspace-setup": "held",
103
+ "turn-cap": "cutShort",
104
+ "harness-incomplete": "cutShort",
105
+ "privacy-unshielded": "privacy",
106
+ "privacy-instructions": "privacy",
107
+ } as const;
108
+ expect(Object.fromEntries(Object.entries(FAILURE_CODES).map(([code, traits]) => [code, traits.kind]))).toEqual(pinned);
109
+ });
110
+
111
+ test("each wall's own code takes its course, and a turn that stopped at its own ceiling is carried on by a press", () => {
112
+ expect(failureCourseOf("rate_limit")).toBe("limit");
113
+ expect(failureCourseOf("provider-outage")).toBe("outage");
114
+ expect(failureCourseOf("claude-token-refused")).toBe("remint");
115
+ expect(failureCourseOf("context-overflow")).toBe("overflow");
116
+ expect(failureCourseOf("safeguard-flagged")).toBe("flagged");
117
+ expect(failureCourseOf("codex-advisory")).toBe("note");
118
+ expect(codesWhere((code) => failureCourseOf(code) === "carry")).toEqual(["harness-incomplete", "turn-cap"]);
119
+ expect(codesWhere((code) => failureCourseOf(code) === "bare")).toEqual(
120
+ [
121
+ "session-not-found",
122
+ "codex-reauth",
123
+ "acp-auth-required",
124
+ "account-not-entitled",
125
+ "subscription-required",
126
+ "grok-model-invalid",
127
+ "codex-model-invalid",
128
+ "agent-busy",
129
+ ].toSorted(),
130
+ );
131
+ });
132
+
133
+ test("a failure nothing coded is carried on, and a code this build does not know holds nothing", () => {
134
+ expect(failureCourseOf(undefined)).toBe("carry");
135
+ expect(failureTraitsOf(undefined)).toBeUndefined();
136
+ expect(failureTraitsOf("a-newer-sandbox-code")).toBeUndefined();
137
+ expect(failureCourseOf("a-newer-sandbox-code")).toBe("bare");
138
+ // A plain record lookup would answer these with Object.prototype's own members.
139
+ expect(failureTraitsOf("constructor")).toBeUndefined();
140
+ expect(failureTraitsOf("toString")).toBeUndefined();
141
+ });
@@ -179,6 +179,11 @@ export const RAW_ROUTES = {
179
179
  "POST /devices/{name}/apps/stop": { agent: true, control: "never" },
180
180
  "GET /devices/{name}/apps/{id}/output": { agent: true, control: "never" },
181
181
  "GET /devices/runs": { agent: true },
182
+ // A `devices run` building in the owner's tree holds lands into that repository until its build ends
183
+ // (hosts/runs/run-builds.ts): any shell's, since the run grant and the conversation each say whose build it is.
184
+ "POST /devices/builds": { agent: true, control: "never" },
185
+ "POST /devices/builds/{id}/renew": { agent: true, control: "never" },
186
+ "DELETE /devices/builds/{id}": { agent: true, control: "never" },
182
187
  "POST /devices/{name}/tunnels": { agent: true, control: "never" },
183
188
  "DELETE /devices/{name}/tunnels/{port}": { agent: true, control: "never" },
184
189
  "GET /devices/tunnels": { agent: true },
@@ -0,0 +1,46 @@
1
+ import { AgentEventSchema } from "../events/agent-events.js";
2
+ import { TurnEndingSchema } from "../events/transcript.js";
3
+ import { AgentPressSchema, NO_PRESS } from "./agent-press.js";
4
+ import { AgentSummarySchema } from "./agents.js";
5
+
6
+ // The card's press (AgentSummary.press) is what every chat window's strip follows over its own reading, so both of its
7
+ // kinds, and a hold only a press sends again (`pressOnly`), must survive the wire whole: a key the schema strips is a
8
+ // press the window never offers.
9
+
10
+ describe("AgentPress", () => {
11
+ test("carries nothing to press as itself, not as an absent field", () => {
12
+ expect(AgentPressSchema.parse(NO_PRESS)).toEqual({ kind: "none" });
13
+ const card = AgentSummarySchema.pick({ press: true });
14
+ expect(card.parse({ press: NO_PRESS })).toEqual({ press: { kind: "none" } });
15
+ // An older sandbox says nothing, which is not `none`.
16
+ expect(card.parse({})).toEqual({});
17
+ });
18
+
19
+ test.each([
20
+ { reason: "stopped" },
21
+ { reason: "stopped", held: { ran: true, contextTokens: 9_000, pressOnly: true } },
22
+ { reason: "limit", resetsAt: 2_000_000_000, held: { ran: false, handoffTokens: 1_200, moving: "acct-2" }, scheduled: true, nextAt: 2_000_000_100 },
23
+ { reason: "outage" },
24
+ { reason: "flagged", held: { ran: true } },
25
+ { reason: "stopped", held: { ran: true }, retries: { made: 1, max: 3 } },
26
+ ] as const)("round-trips a continue on %o", (ending) => {
27
+ const press = { kind: "continue", ending } as const;
28
+ expect(AgentPressSchema.parse(JSON.parse(JSON.stringify(press)))).toEqual(press);
29
+ });
30
+
31
+ test("refuses a kind it does not know, and a continue with no ending", () => {
32
+ expect(AgentPressSchema.safeParse({ kind: "later" }).success).toBe(false);
33
+ expect(AgentPressSchema.safeParse({ kind: "continue" }).success).toBe(false);
34
+ });
35
+ });
36
+
37
+ describe("a hold only a press sends again", () => {
38
+ test("is stated on the record's ending", () => {
39
+ expect(TurnEndingSchema.parse({ reason: "stopped", held: { ran: true, pressOnly: true } }).held).toEqual({ ran: true, pressOnly: true });
40
+ });
41
+
42
+ test("is stated on the error frame's held turn", () => {
43
+ const frame = { kind: "error", code: "turn-cap", message: "Reached the maximum number of turns.", autoResume: "available", held: { ran: true, pressOnly: true } };
44
+ expect(AgentEventSchema.parse(frame)).toMatchObject({ kind: "error", held: { ran: true, pressOnly: true } });
45
+ });
46
+ });
@@ -0,0 +1,34 @@
1
+ import { z } from "zod";
2
+ import { type TurnEnding, TurnEndingSchema } from "../events/transcript.js";
3
+
4
+ // WHAT A PERSON'S CONTINUE DOES NOW: the daemon's one reading of it (AgentSummary.press), derived every time the card is
5
+ // read from what the conversation holds (turn-ending.ts turnEndingOf), the very value its record states as the transcript's
6
+ // `ending`. Every chat window used to build its own from the live error frame it happened to watch, patched from the
7
+ // record and the card, and they disagreed: a card in Finished beside a composer still saying "Limit reached, work kept"
8
+ // (2026-11-01), a composer counting down to a reopen while the daemon re-ran the turn at once (2026-10-19), a reloaded
9
+ // window with no strip at all, or one that never went away.
10
+ const AgentPressMembers = z
11
+ .discriminatedUnion("kind", [
12
+ z.object({ kind: z.literal("none") }).describe("Nothing to continue: the last turn finished, runs now, or ended on something to repair first."),
13
+ z.object({
14
+ kind: z.literal("continue"),
15
+ ending: TurnEndingSchema.describe(
16
+ "How the last turn ended, which says what the press does: re-run the turn the daemon holds, or carry the session on.",
17
+ ),
18
+ }),
19
+ ])
20
+ .describe("What a person's Continue does for this conversation now, as the daemon reads it.");
21
+ // Named, never inferred: the card's schema then names this type instead of spelling the whole ending out inside every route
22
+ // that carries a card, which took the aggregated contract's type past what the declaration emitter will write (TS7056).
23
+ export interface NoPress {
24
+ readonly kind: "none";
25
+ }
26
+ export interface ContinuePress {
27
+ readonly kind: "continue";
28
+ readonly ending: TurnEnding;
29
+ }
30
+ export type AgentPress = NoPress | ContinuePress;
31
+ export const AgentPressSchema: z.ZodType<AgentPress> = AgentPressMembers;
32
+
33
+ /** The one `none`, shared by every writer that has nothing to offer. */
34
+ export const NO_PRESS: AgentPress = { kind: "none" };