@intentic/sandbox-contract 1.389.0 → 1.391.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 (185) 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/device.contract.d.ts +14 -0
  7. package/dist/contracts/device.contract.d.ts.map +1 -1
  8. package/dist/contracts/device.contract.js +2 -2
  9. package/dist/contracts/device.contract.js.map +1 -1
  10. package/dist/contracts/ports.contract.d.ts +5 -0
  11. package/dist/contracts/ports.contract.d.ts.map +1 -1
  12. package/dist/contracts/ports.contract.js +1 -1
  13. package/dist/contracts/ports.contract.js.map +1 -1
  14. package/dist/contracts/runner.contract.d.ts +12 -4
  15. package/dist/contracts/runner.contract.d.ts.map +1 -1
  16. package/dist/contracts/runs.contract.d.ts +17 -0
  17. package/dist/contracts/runs.contract.d.ts.map +1 -1
  18. package/dist/contracts/settings.contract.d.ts +16 -0
  19. package/dist/contracts/settings.contract.d.ts.map +1 -1
  20. package/dist/contracts/system.contract.d.ts +66 -0
  21. package/dist/contracts/system.contract.d.ts.map +1 -1
  22. package/dist/contracts/system.contract.js +10 -1
  23. package/dist/contracts/system.contract.js.map +1 -1
  24. package/dist/events/agent-events.d.ts +4 -0
  25. package/dist/events/agent-events.d.ts.map +1 -1
  26. package/dist/events/agent-events.js +1 -0
  27. package/dist/events/agent-events.js.map +1 -1
  28. package/dist/events/agent-transcript.d.ts +1 -0
  29. package/dist/events/agent-transcript.d.ts.map +1 -1
  30. package/dist/events/failure-rows.js +1 -1
  31. package/dist/events/failure-rows.js.map +1 -1
  32. package/dist/events/land-conflict.d.ts +1 -0
  33. package/dist/events/land-conflict.d.ts.map +1 -1
  34. package/dist/events/land-conflict.js +4 -3
  35. package/dist/events/land-conflict.js.map +1 -1
  36. package/dist/events/requests.d.ts +1 -0
  37. package/dist/events/requests.d.ts.map +1 -1
  38. package/dist/events/requests.js +1 -1
  39. package/dist/events/requests.js.map +1 -1
  40. package/dist/events/resume.d.ts +2 -0
  41. package/dist/events/resume.d.ts.map +1 -1
  42. package/dist/events/resume.js +2 -0
  43. package/dist/events/resume.js.map +1 -1
  44. package/dist/events/sandbox-notice.d.ts +1 -0
  45. package/dist/events/sandbox-notice.d.ts.map +1 -1
  46. package/dist/events/sandbox-notice.js +1 -0
  47. package/dist/events/sandbox-notice.js.map +1 -1
  48. package/dist/events/system-events.d.ts +12 -0
  49. package/dist/events/system-events.d.ts.map +1 -1
  50. package/dist/events/transcript.d.ts +1 -0
  51. package/dist/events/transcript.d.ts.map +1 -1
  52. package/dist/events/transcript.js +4 -0
  53. package/dist/events/transcript.js.map +1 -1
  54. package/dist/index.d.ts +173 -0
  55. package/dist/index.d.ts.map +1 -1
  56. package/dist/models/agent-standing.d.ts +2 -0
  57. package/dist/models/agent-standing.d.ts.map +1 -1
  58. package/dist/models/agent-standing.js.map +1 -1
  59. package/dist/models/model-setups.d.ts.map +1 -1
  60. package/dist/models/model-setups.js +2 -1
  61. package/dist/models/model-setups.js.map +1 -1
  62. package/dist/policy/failure-codes.d.ts +158 -0
  63. package/dist/policy/failure-codes.d.ts.map +1 -0
  64. package/dist/policy/failure-codes.js +50 -0
  65. package/dist/policy/failure-codes.js.map +1 -0
  66. package/dist/protocol/raw/raw-routes.d.ts +12 -0
  67. package/dist/protocol/raw/raw-routes.d.ts.map +1 -1
  68. package/dist/protocol/raw/raw-routes.js +3 -0
  69. package/dist/protocol/raw/raw-routes.js.map +1 -1
  70. package/dist/schemas/agent-press.d.ts +13 -0
  71. package/dist/schemas/agent-press.d.ts.map +1 -0
  72. package/dist/schemas/agent-press.js +14 -0
  73. package/dist/schemas/agent-press.js.map +1 -0
  74. package/dist/schemas/agents-list.d.ts +6 -0
  75. package/dist/schemas/agents-list.d.ts.map +1 -1
  76. package/dist/schemas/agents.d.ts +11 -0
  77. package/dist/schemas/agents.d.ts.map +1 -1
  78. package/dist/schemas/agents.js +5 -6
  79. package/dist/schemas/agents.js.map +1 -1
  80. package/dist/schemas/device-resources.d.ts +54 -0
  81. package/dist/schemas/device-resources.d.ts.map +1 -0
  82. package/dist/schemas/device-resources.js +29 -0
  83. package/dist/schemas/device-resources.js.map +1 -0
  84. package/dist/schemas/devices.d.ts +2 -52
  85. package/dist/schemas/devices.d.ts.map +1 -1
  86. package/dist/schemas/devices.js +2 -27
  87. package/dist/schemas/devices.js.map +1 -1
  88. package/dist/schemas/git/clone.d.ts +12 -0
  89. package/dist/schemas/git/clone.d.ts.map +1 -0
  90. package/dist/schemas/git/clone.js +14 -0
  91. package/dist/schemas/git/clone.js.map +1 -0
  92. package/dist/schemas/hosts.d.ts +37 -0
  93. package/dist/schemas/hosts.d.ts.map +1 -1
  94. package/dist/schemas/hosts.js +22 -0
  95. package/dist/schemas/hosts.js.map +1 -1
  96. package/dist/schemas/metrics.d.ts +59 -0
  97. package/dist/schemas/metrics.d.ts.map +1 -1
  98. package/dist/schemas/metrics.js +19 -0
  99. package/dist/schemas/metrics.js.map +1 -1
  100. package/dist/schemas/ports.d.ts +10 -0
  101. package/dist/schemas/ports.d.ts.map +1 -1
  102. package/dist/schemas/ports.js +8 -0
  103. package/dist/schemas/ports.js.map +1 -1
  104. package/dist/schemas/providers/handoff.d.ts +1 -0
  105. package/dist/schemas/providers/handoff.d.ts.map +1 -1
  106. package/dist/schemas/providers/handoff.js +4 -1
  107. package/dist/schemas/providers/handoff.js.map +1 -1
  108. package/dist/schemas/providers/plan-limits.js +1 -1
  109. package/dist/schemas/providers/plan-limits.js.map +1 -1
  110. package/dist/schemas/run-targets.d.ts +36 -0
  111. package/dist/schemas/run-targets.d.ts.map +1 -1
  112. package/dist/schemas/run-targets.js +11 -0
  113. package/dist/schemas/run-targets.js.map +1 -1
  114. package/dist/schemas/settings.d.ts +29 -0
  115. package/dist/schemas/settings.d.ts.map +1 -1
  116. package/dist/schemas/settings.js +17 -0
  117. package/dist/schemas/settings.js.map +1 -1
  118. package/dist/schemas/stranded-clone.d.ts +9 -0
  119. package/dist/schemas/stranded-clone.d.ts.map +1 -0
  120. package/dist/schemas/stranded-clone.js +12 -0
  121. package/dist/schemas/stranded-clone.js.map +1 -0
  122. package/dist/state/definition.d.ts +20 -0
  123. package/dist/state/definition.d.ts.map +1 -1
  124. package/dist/state/fix-stance.js +1 -1
  125. package/dist/state/fix-stance.js.map +1 -1
  126. package/dist/state/runtime-state.d.ts +3 -0
  127. package/dist/state/runtime-state.d.ts.map +1 -1
  128. package/dist/state/runtime-state.js +1 -0
  129. package/dist/state/runtime-state.js.map +1 -1
  130. package/dist/state/workspace-state.d.ts.map +1 -1
  131. package/dist/state/workspace-state.js +1 -1
  132. package/dist/state/workspace-state.js.map +1 -1
  133. package/dist/text/transcript-fold.d.ts.map +1 -1
  134. package/dist/text/transcript-fold.js +6 -6
  135. package/dist/text/transcript-fold.js.map +1 -1
  136. package/dist/text/transcript-interruption.d.ts +4 -0
  137. package/dist/text/transcript-interruption.d.ts.map +1 -0
  138. package/dist/text/transcript-interruption.js +27 -0
  139. package/dist/text/transcript-interruption.js.map +1 -0
  140. package/package.json +5 -5
  141. package/src/contracts/agents.contract.ts +12 -0
  142. package/src/contracts/device.contract.ts +4 -3
  143. package/src/contracts/ports.contract.ts +3 -2
  144. package/src/contracts/system.contract.ts +12 -1
  145. package/src/events/agent-events.ts +2 -0
  146. package/src/events/failure-rows.ts +1 -1
  147. package/src/events/land-conflict.test.ts +13 -1
  148. package/src/events/land-conflict.ts +8 -4
  149. package/src/events/requests.ts +1 -1
  150. package/src/events/resume.test.ts +7 -1
  151. package/src/events/resume.ts +3 -0
  152. package/src/events/sandbox-notice.ts +1 -0
  153. package/src/events/transcript.ts +6 -0
  154. package/src/models/agent-standing.ts +4 -0
  155. package/src/models/model-setups.test.ts +11 -0
  156. package/src/models/model-setups.ts +4 -1
  157. package/src/policy/failure-codes.ts +157 -0
  158. package/src/policy/tests/failure-codes.test.ts +141 -0
  159. package/src/protocol/raw/raw-routes.ts +5 -0
  160. package/src/schemas/agent-press.test.ts +46 -0
  161. package/src/schemas/agent-press.ts +34 -0
  162. package/src/schemas/agents.ts +8 -8
  163. package/src/schemas/device-resources.ts +58 -0
  164. package/src/schemas/devices.ts +20 -56
  165. package/src/schemas/git/clone.ts +22 -0
  166. package/src/schemas/hosts.ts +62 -0
  167. package/src/schemas/metrics.ts +28 -0
  168. package/src/schemas/ports.ts +12 -0
  169. package/src/schemas/providers/handoff.test.ts +7 -0
  170. package/src/schemas/providers/handoff.ts +4 -1
  171. package/src/schemas/providers/plan-limits.ts +1 -1
  172. package/src/schemas/run-targets.ts +31 -1
  173. package/src/schemas/settings.ts +32 -0
  174. package/src/schemas/stranded-clone.ts +15 -0
  175. package/src/state/fix-stance.ts +1 -1
  176. package/src/state/runtime-state.ts +4 -0
  177. package/src/state/workspace-state.ts +3 -2
  178. package/src/text/transcript-fold.test.ts +21 -7
  179. package/src/text/transcript-fold.ts +5 -6
  180. package/src/text/transcript-interruption.ts +30 -0
  181. package/dist/policy/turned-away.d.ts +0 -3
  182. package/dist/policy/turned-away.d.ts.map +0 -1
  183. package/dist/policy/turned-away.js +0 -33
  184. package/dist/policy/turned-away.js.map +0 -1
  185. package/src/policy/turned-away.ts +0 -52
@@ -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" };
@@ -1,6 +1,7 @@
1
1
  // agents: the conversation fleet
2
2
  import { LandingDeliverySchema } from "./project-delivery.js";
3
3
  import { AgentNextSchema } from "./agent-next.js";
4
+ import { AgentPressSchema } from "./agent-press.js";
4
5
  import { z } from "zod";
5
6
  import { AgentHarnessSchema, AgentOriginSchema, AgentProviderSchema, ConversationQueueSchema, ForkedFromSchema, FreshSessionSchema } from "./agent.js";
6
7
  import { FROM_BRANCHES_DESCRIPTION } from "./conversation-links.js";
@@ -9,6 +10,7 @@ import { LoopStateSchema } from "./loops.js";
9
10
  import { LimitPolicySchema, RetryPolicySchema, RoomPolicySchema, TurnBreakPolicySchema, TurnBreakSchema } from "./turn-break.js";
10
11
  import { KeepWarmSchema } from "./keep-warm.js";
11
12
  import { AgentNeedSchema } from "./needs.js";
13
+ import { StrandedCloneSchema } from "./stranded-clone.js";
12
14
  import { EMOJI_MAX_LENGTH, isSingleEmoji } from "../text/emoji.js";
13
15
  import { ProgramAskSchema } from "../events/requests.js";
14
16
  import { ReviewTallySchema, TurnProofSchema } from "./work-assurance.js";
@@ -137,13 +139,7 @@ export const TurnReachSchema = z.object({
137
139
  ),
138
140
  liveMore: z.number().optional().describe("How many more such files there were beyond the ones listed. Absent when all are listed."),
139
141
  stranded: z
140
- .array(
141
- z.object({
142
- dir: z.string().describe("The clone, as a folder relative to its own copy of the workspace."),
143
- uncommitted: z.number().describe("Files changed in it and never committed."),
144
- unpushed: z.number().describe("Commits in it its upstream does not have, or that no remote has when it follows none."),
145
- }),
146
- )
142
+ .array(StrandedCloneSchema)
147
143
  .max(TURN_REACH_LIST_MAX)
148
144
  .optional()
149
145
  .describe(
@@ -304,6 +300,10 @@ export const AgentSummarySchema = z.object({
304
300
  next: AgentNextSchema.optional().describe(
305
301
  "What carries it on next with nobody pressing anything, and when: a held turn re-run, a message held for memory, or messages booked for later. Absent when only a press moves it.",
306
302
  ),
303
+ // And what a press does instead (agent-press.ts): the daemon's one reading, which every chat window's strip follows.
304
+ press: AgentPressSchema.optional().describe(
305
+ "The daemon's one reading of what a person's Continue does now: carry on from how the last turn ended, or nothing. Every summary a sandbox that knows it writes carries it, `none` included, so its absence means a sandbox older than it.",
306
+ ),
307
307
  provider: AgentProviderSchema.describe("Which model provider it runs on."),
308
308
  harness: AgentHarnessSchema.describe("Which agentic loop it runs on."),
309
309
  // Latched with the conversation, so the card can say where work runs without asking anything else.
@@ -537,7 +537,7 @@ export const AgentSummarySchema = z.object({
537
537
  .string()
538
538
  .optional()
539
539
  .describe(
540
- "Which kind of failure it was, when the sandbox could tell: unlinked when its copy lost its link to the workspace, off_main_line when the shared workspace was moved off its main line and the work waits until it is back. Absent otherwise.",
540
+ "Which kind of failure it was, when the sandbox could tell: unlinked when its copy lost its link to the workspace, off_main_line when the shared workspace was moved off its main line and the work waits until it is back, repo_corrupt when the repository's own git storage is damaged (the sandbox checks and repairs it by itself). Absent otherwise.",
541
541
  ),
542
542
  at: z.number().describe("When it failed, in milliseconds."),
543
543
  })
@@ -0,0 +1,58 @@
1
+ import { z } from "zod";
2
+
3
+ // One sandbox's resource share as docker currently enforces it, read off the container by the machine agent.
4
+ // `overlayRuntime` is the environment's locked demand; `hostRuntime` is the owner's addition; `privileged`/`gpu` are
5
+ // docker's enforced truth.
6
+ // A delta against what runs: absent means leave it, `null` on the two caps means back to the default; at least one key
7
+ // must be set. What the old `reshape` op carries, which the machine agent carries out as `ic sandbox shape --set` (its
8
+ // `olderResizePlan`); `set-shape` carries a whole shape instead.
9
+ export const SandboxResourcesAskFieldsSchema = z.object({
10
+ memoryGib: z.int().positive().nullable().optional(),
11
+ cpus: z.int().positive().nullable().optional(),
12
+ privileged: z.boolean().optional(),
13
+ gpu: z.boolean().optional(),
14
+ });
15
+ // A sandbox's shape, WHOLE: the owner's own ask for its share of the machine, every field a value. `null` on a cap is
16
+ // the contract's default (the share derived from the engine, or every core). The switches are the owner's ask, not
17
+ // docker's answer: a directive the approved environment demands rides beside it (`overlayRuntime`), and a host
18
+ // without the NVIDIA runtime drops the GPU. `ic` stores it, validates it against the image's run contract when it is
19
+ // saved, and prints it in `ic sandbox list --json`; nobody else merges anything into it.
20
+ export const SandboxShapeSchema = z.object({
21
+ memoryGib: z.int().positive().nullable(),
22
+ cpus: z.int().positive().nullable(),
23
+ privileged: z.boolean(),
24
+ gpu: z.boolean(),
25
+ });
26
+ export type SandboxShape = z.infer<typeof SandboxShapeSchema>;
27
+ // When a `set-shape` takes effect: `now` restarts the sandbox onto it; `nextRestart` saves it in ic's record and
28
+ // restarts nothing, and the next restart through ic applies it — Restart or Start from any door, an update, a rollback
29
+ // or a rebuild. Docker restarting the container by itself (after a crash or a reboot) does not: only ic recreates one.
30
+ export const SandboxShapeWhenSchema = z.enum(["now", "nextRestart"]);
31
+ export type SandboxShapeWhen = z.infer<typeof SandboxShapeWhenSchema>;
32
+
33
+ export const SandboxResourcesSchema = z.object({
34
+ // The cgroup memory ceiling in bytes; absent when docker imposes none (the hosted shape).
35
+ memoryBytes: z.number().optional(),
36
+ // The CFS quota as whole cores; absent when the container may use every core (the default).
37
+ cpus: z.number().optional(),
38
+ privileged: z.boolean(),
39
+ gpu: z.boolean(),
40
+ hostRuntime: z.array(z.string()),
41
+ overlayRuntime: z.array(z.string()),
42
+ // The shape the container runs with (the owner's ask it carries). Absent from an agent older than `set-shape`.
43
+ shape: SandboxShapeSchema.optional(),
44
+ // The shape saved for the sandbox's next restart through ic, and not yet in force. Absent when nothing is saved.
45
+ desired: SandboxShapeSchema.optional(),
46
+ // READ-ONLY, from agents older than `set-shape`: their saved share, a delta against what runs. Nothing new writes
47
+ // it; kept one release so a newer page can still show what an older agent saved. Remove with `later`.
48
+ saved: SandboxResourcesAskFieldsSchema.optional(),
49
+ });
50
+ export type SandboxResources = z.infer<typeof SandboxResourcesSchema>;
51
+
52
+ // Fields also exported separately for callers that compose them and enforce the at-least-one rule themselves.
53
+ // Strict like every device input (DeviceSandboxFlowSchema says why): it is only ever sent to a device.
54
+ export const SandboxResourcesAskSchema = SandboxResourcesAskFieldsSchema.strict().refine((ask) => Object.values(ask).some((value) => value !== undefined), {
55
+ message: "a reshape must change at least one thing",
56
+ });
57
+ export type SandboxResourcesAsk = z.infer<typeof SandboxResourcesAskSchema>;
58
+