@intentic/sandbox-contract 1.167.0 → 1.169.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 (68) hide show
  1. package/dist/agent-catalog.d.ts +20 -2
  2. package/dist/agent-catalog.d.ts.map +1 -1
  3. package/dist/agent-catalog.js +80 -4
  4. package/dist/agent-catalog.js.map +1 -1
  5. package/dist/contracts/agent.contract.d.ts +36 -8
  6. package/dist/contracts/agent.contract.d.ts.map +1 -1
  7. package/dist/contracts/agent.contract.js +1 -2
  8. package/dist/contracts/agent.contract.js.map +1 -1
  9. package/dist/contracts/agents.contract.d.ts +37 -39
  10. package/dist/contracts/agents.contract.d.ts.map +1 -1
  11. package/dist/contracts/extensions.contract.d.ts +4 -0
  12. package/dist/contracts/extensions.contract.d.ts.map +1 -1
  13. package/dist/contracts/prepush.contract.d.ts +25 -0
  14. package/dist/contracts/prepush.contract.d.ts.map +1 -0
  15. package/dist/contracts/prepush.contract.js +8 -0
  16. package/dist/contracts/prepush.contract.js.map +1 -0
  17. package/dist/contracts/sessions.contract.d.ts +1 -39
  18. package/dist/contracts/sessions.contract.d.ts.map +1 -1
  19. package/dist/contracts/settings.contract.d.ts +8 -10
  20. package/dist/contracts/settings.contract.d.ts.map +1 -1
  21. package/dist/contracts/system.contract.d.ts +56 -0
  22. package/dist/contracts/system.contract.d.ts.map +1 -1
  23. package/dist/contracts/system.contract.js +7 -2
  24. package/dist/contracts/system.contract.js.map +1 -1
  25. package/dist/contracts/translator.contract.d.ts +36 -0
  26. package/dist/contracts/translator.contract.d.ts.map +1 -1
  27. package/dist/events.d.ts +88 -159
  28. package/dist/events.d.ts.map +1 -1
  29. package/dist/events.js +37 -4
  30. package/dist/events.js.map +1 -1
  31. package/dist/index.d.ts +218 -157
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +4 -3
  34. package/dist/index.js.map +1 -1
  35. package/dist/quick-model.d.ts +1 -0
  36. package/dist/quick-model.d.ts.map +1 -1
  37. package/dist/quick-model.js +1 -1
  38. package/dist/quick-model.js.map +1 -1
  39. package/dist/schemas.d.ts +176 -69
  40. package/dist/schemas.d.ts.map +1 -1
  41. package/dist/schemas.js +48 -40
  42. package/dist/schemas.js.map +1 -1
  43. package/dist/title.d.ts.map +1 -1
  44. package/dist/title.js.map +1 -1
  45. package/dist/workspace-state.d.ts +9 -0
  46. package/dist/workspace-state.d.ts.map +1 -0
  47. package/dist/workspace-state.js +61 -0
  48. package/dist/workspace-state.js.map +1 -0
  49. package/package.json +2 -2
  50. package/src/agent-catalog.test.ts +118 -0
  51. package/src/agent-catalog.ts +179 -15
  52. package/src/contracts/agent.contract.ts +1 -14
  53. package/src/contracts/prepush.contract.ts +16 -0
  54. package/src/contracts/system.contract.ts +15 -1
  55. package/src/events.test.ts +32 -0
  56. package/src/events.ts +105 -27
  57. package/src/index.ts +4 -3
  58. package/src/quick-model.ts +4 -2
  59. package/src/schemas.test.ts +13 -18
  60. package/src/schemas.ts +179 -152
  61. package/src/title.ts +6 -2
  62. package/src/workspace-state.test.ts +129 -0
  63. package/src/workspace-state.ts +150 -0
  64. package/dist/contracts/gate.contract.d.ts +0 -47
  65. package/dist/contracts/gate.contract.d.ts.map +0 -1
  66. package/dist/contracts/gate.contract.js +0 -9
  67. package/dist/contracts/gate.contract.js.map +0 -1
  68. package/src/contracts/gate.contract.ts +0 -19
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intentic/sandbox-contract",
3
- "version": "1.167.0",
3
+ "version": "1.169.0",
4
4
  "description": "oRPC wire contract for the intentic sandbox daemon — shared by the daemon and its browser client",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -56,7 +56,7 @@
56
56
  "@orpc/contract": "1.14.13",
57
57
  "tslib": "2.8.1",
58
58
  "zod": "4.4.3",
59
- "@intentic/extension-api": "1.167.0"
59
+ "@intentic/extension-api": "1.169.0"
60
60
  },
61
61
  "devDependencies": {
62
62
  "@types/node": "24.13.2",
@@ -0,0 +1,118 @@
1
+ import { describe, expect, it, test } from "vitest";
2
+ import { type AgentCapabilities, capabilitiesOf, clampMode, HARNESSES, limitationsOf, modesFor, PROVIDERS } from "./agent-catalog.js";
3
+ import type { AgentHarness, AgentProvider, PermissionMode } from "./schemas.js";
4
+
5
+ /* THE MATRIX GUARD.
6
+ *
7
+ * Four runtimes serve turns behind one seam, and for a long time the only record of what each could do was a
8
+ * comment inside its own adapter. The surfaces above them could not read those, so they offered the same
9
+ * controls to all four: a permission mode to a runtime with no approval channel, an effort scale to one that
10
+ * drops the field. The record is what fixed that, and this is what keeps it honest.
11
+ *
12
+ * By SHAPE, not by a list: PROVIDERS × HARNESSES comes from the catalog itself, so a provider added tomorrow is
13
+ * covered the day it is added. If a pair fails here, the answer is a row in capabilitiesOf — never a special
14
+ * case in the surface that asked. */
15
+
16
+ const pairs: { provider: AgentProvider; harness: AgentHarness }[] = PROVIDERS.flatMap((provider) =>
17
+ HARNESSES.map((harness) => ({ provider: provider.value as AgentProvider, harness: harness.value })),
18
+ );
19
+
20
+ describe("every provider/harness pair declares what it can do", () => {
21
+ it.each(pairs)("$provider on the $harness harness", ({ provider, harness }) => {
22
+ const capabilities = capabilitiesOf(provider, harness);
23
+
24
+ // Nothing may be left to inference: a `permissions` a surface can't read, or a runtime nobody serves,
25
+ // is the drift this record exists to end.
26
+ expect(["claude-code", "codex", "opencode", "acp"]).toContain(capabilities.runtime);
27
+ expect(["modes", "plan"]).toContain(capabilities.permissions);
28
+ expect(["full", "http", "none"]).toContain(capabilities.mcp);
29
+ expect(["namespace", "cwd"]).toContain(capabilities.isolation);
30
+ // The permission modes offered must include the mode a clamp falls back to — a floor that isn't in the
31
+ // list would leave the composer showing a posture the runtime can't hold.
32
+ expect(modesFor(capabilities)).toContain(clampMode("default", capabilities));
33
+ });
34
+ });
35
+
36
+ // An ACP provider is an installed capability's id — any string that isn't a native provider. It gets the ACP
37
+ // floor whatever harness the client happened to send, because the agent IS its own loop.
38
+ test("an unknown provider id is an ACP agent, on either harness", () => {
39
+ for (const harness of HARNESSES) {
40
+ expect(capabilitiesOf("some-installed-agent", harness.value).runtime).toBe("acp");
41
+ }
42
+ });
43
+
44
+ /* The harness axis is real for exactly two providers. Claude is always its own Claude Code loop, and kimi/gemini
45
+ * have no native runtime at all (Moonshot speaks the Anthropic protocol directly; Google is re-served through
46
+ * the translator), so all three run it whatever the client sent — which is why "is the harness claude-code" was
47
+ * never the question worth asking. */
48
+ test("only codex and grok change runtime with the harness", () => {
49
+ const switched = PROVIDERS.filter((provider) => capabilitiesOf(provider.value, "native") !== capabilitiesOf(provider.value, "claude-code"));
50
+
51
+ expect(switched.map((provider) => provider.value)).toEqual(["codex", "grok"]);
52
+ });
53
+
54
+ test("codex and grok under the Claude Code harness get the full ceiling — it is the same loop", () => {
55
+ for (const provider of ["codex", "grok"] as const) {
56
+ expect(capabilitiesOf(provider, "claude-code")).toEqual(capabilitiesOf("claude", "native"));
57
+ }
58
+ });
59
+
60
+ // The composer's four modes describe behaviours the Claude Code loop actually has. A runtime whose every tool
61
+ // call is pre-approved has two postures, so it is offered two names — not four names for two behaviours.
62
+ test("a plan-only runtime offers the two postures it has", () => {
63
+ expect(modesFor(capabilitiesOf("codex", "native"))).toEqual(["plan", "bypassPermissions"]);
64
+ expect(modesFor(capabilitiesOf("claude", "native"))).toEqual(["default", "acceptEdits", "plan", "bypassPermissions"]);
65
+ });
66
+
67
+ test("a mode the runtime can't hold falls back to the one it runs; one it can holds", () => {
68
+ const codex = capabilitiesOf("codex", "native");
69
+
70
+ expect(clampMode("acceptEdits", codex)).toBe("bypassPermissions");
71
+ expect(clampMode("plan", codex)).toBe("plan");
72
+ expect(clampMode("acceptEdits", capabilitiesOf("claude", "native"))).toBe("acceptEdits");
73
+ });
74
+
75
+ /* The user-facing half. The full ceiling says nothing — an empty list is what hides the picker's block — and
76
+ * every axis the record carries has a sentence here, because a capability nobody can read is how this started. */
77
+ test("the ceiling has nothing to disclose; a floor names what it lacks", () => {
78
+ expect(limitationsOf(capabilitiesOf("claude", "native"))).toEqual([]);
79
+
80
+ const grok = limitationsOf(capabilitiesOf("grok", "native"));
81
+ expect(grok).toContain("no per-tool approvals");
82
+ expect(grok).toContain("no mid-turn steering");
83
+ expect(grok).toContain("no effort control");
84
+ expect(grok).toContain("worktree by working directory only");
85
+
86
+ // ACP takes our http MCP tools when it advertises them, so its line is a narrowing rather than an absence —
87
+ // and it publishes commands and terminals, which must NOT be listed as missing.
88
+ const acp = limitationsOf(capabilitiesOf("some-installed-agent", "native"));
89
+ expect(acp).toContain("MCP tools only — no plugins or browser");
90
+ expect(acp).not.toContain("no slash commands");
91
+ expect(acp).not.toContain("no terminal panel");
92
+ });
93
+
94
+ test("every axis a record can lack has words for it", () => {
95
+ const nothing: AgentCapabilities = {
96
+ runtime: "acp",
97
+ steering: false,
98
+ permissions: "plan",
99
+ questions: false,
100
+ mcp: "none",
101
+ effort: false,
102
+ isolation: "cwd",
103
+ commands: false,
104
+ terminals: false,
105
+ recovery: false,
106
+ };
107
+
108
+ // Nine axes, nine sentences: an axis added to the interface without one would silently never be disclosed.
109
+ expect(limitationsOf(nothing)).toHaveLength(9);
110
+ });
111
+
112
+ // The mode vocabulary is the contract's own PermissionMode, so a mode added to the wire can't be quietly absent
113
+ // from the runtime that owns them all.
114
+ test("the Claude Code loop offers every PermissionMode the wire has", () => {
115
+ const wire: PermissionMode[] = ["default", "acceptEdits", "plan", "bypassPermissions"];
116
+
117
+ expect([...modesFor(capabilitiesOf("claude", "native"))].toSorted()).toEqual(wire.toSorted());
118
+ });
@@ -1,4 +1,4 @@
1
- import type { AgentHarness, AgentProvider, Model, NativeProvider } from "./schemas.js";
1
+ import { type AgentHarness, type AgentProvider, type Model, NATIVE_PROVIDERS, type NativeProvider, type PermissionMode } from "./schemas.js";
2
2
 
3
3
  /* The provider / harness / model catalog every picker shares (the chat menu, the automations dialog) — pure
4
4
  * data keyed by the wire vocabulary in schemas.ts, so the surfaces can't drift. Live state stays with the
@@ -46,6 +46,23 @@ export const PROVIDER_ACCESS: Record<NativeProvider, ProviderAccess> = {
46
46
  gemini: { kind: "free", requirement: "Google sign-in", runs: "Gemini, Claude and GPT-OSS under Claude Code" },
47
47
  };
48
48
 
49
+ /* WHOSE ALLOWANCE A TURN ON THIS PROVIDER SPENDS, as the subject of a sentence — a third naming of the same
50
+ * five ids, and the third is not redundancy. PROVIDERS names the RUNTIME the user picks ("Claude Code", "Kimi
51
+ * Code") and PROVIDER_ACCESS.requirement names the thing they CONNECT ("Claude subscription", "Google sign-in");
52
+ * neither reads as English in "… usage limit reached", and neither is what a spent quota belongs to.
53
+ *
54
+ * The routed providers are why this can't be inferred from the harness: a `gemini` turn drives Claude Opus 4.6
55
+ * through Google's Antigravity channel on a plain Google sign-in, so the quota that refuses it is Google's and
56
+ * Anthropic has no part in it. Saying "Claude usage limit reached" there sends the user to check the wrong
57
+ * account — and to a reset that is days out on a pool they never touched. */
58
+ export const PROVIDER_VENDOR: Record<NativeProvider, string> = {
59
+ claude: "Claude",
60
+ codex: "ChatGPT",
61
+ grok: "xAI",
62
+ kimi: "Kimi Code",
63
+ gemini: "Google",
64
+ };
65
+
49
66
  // What a turn on this provider costs at the MARGIN, ordering the same three kinds by the only question a
50
67
  // helper spending the user's money on their behalf has to answer: free is free; a subscription is already paid
51
68
  // but has a quota the user watches; a key is metered, so every call is real money. Deliberately not folded into
@@ -60,6 +77,21 @@ export const accessFor = (provider: AgentProvider): ProviderAccess | undefined =
60
77
  // static fallback.
61
78
  export const providerLabel = (provider: AgentProvider): string => PROVIDERS.find((p) => p.value === provider)?.label ?? provider;
62
79
 
80
+ /* Whether a plan-limit reading for this provider is OBTAINABLE at all — one fact, on the wire, because both
81
+ * halves need it and they need the same answer. The daemon reads it to decide what to even ask upstream for
82
+ * (usage/translator-usage.ts); the browser reads it to say WHY an account shows no meter, which is the
83
+ * difference between "this plan publishes nothing" and "we haven't measured yet" — two states that look
84
+ * identical as a blank row and mean opposite things.
85
+ *
86
+ * Three can be read, by two mechanisms that stop at the daemon's readers: Claude's rides its own turn (the
87
+ * OAuth usage endpoint, agent.ts), ChatGPT's and Google's are pulled through the translator's
88
+ * credential-scoped api-call. Grok is absent because xAI's usable billing data needs a subject id CLIProxyAPI
89
+ * keeps out of its auth-file listing, and the fallback probe spends a token to answer. Kimi is absent because
90
+ * it publishes no quota endpoint — the bundled translator knows only its chat and OAuth routes. Adding either
91
+ * is adding a reader and its name here, and nothing else. */
92
+ export const PLAN_LIMIT_PROVIDERS: readonly NativeProvider[] = ["claude", "codex", "gemini"];
93
+ export const reportsPlanLimits = (provider: AgentProvider): boolean => PLAN_LIMIT_PROVIDERS.includes(provider as NativeProvider);
94
+
63
95
  // The harness (agentic loop) a turn runs on, orthogonal to the provider. `native` = the provider's own runtime;
64
96
  // `claude-code` = the Claude Code loop for any provider (codex/grok then route through the translator). Only
65
97
  // surfaced for codex/grok — claude is always its own Claude Code loop, and kimi/gemini have no native runtime
@@ -69,20 +101,152 @@ export const HARNESSES: readonly { label: string; value: AgentHarness }[] = [
69
101
  { label: "Claude Code", value: "claude-code" },
70
102
  ];
71
103
 
72
- // Whether a turn on this provider/harness pair ACTUALLY runs the Claude Code Agent SDK loop which is not the
73
- // same question as `harness === "claude-code"`. Claude is always its own Claude Code loop, and kimi/gemini have
74
- // no native runtime at all (both are re-served through the translator), so all three run it whatever harness the
75
- // client happened to send; only codex/grok have a native
76
- // runtime to switch away from. An ACP agent runs its own loop and is never one of these.
77
- //
78
- // Everything the SDK loop owns keys off this: the SteeringQueue that makes mid-turn injection possible, and the
79
- // session store `/sessions/:id` reads a finished conversation's transcript back out of. Both sides of the wire
80
- // answer it here so a provider that gains (or loses) a native runtime is one edit, not a hunt for the literals.
81
- export const runsClaudeCode = (provider: AgentProvider, harness: AgentHarness): boolean =>
82
- provider === "claude" ||
83
- provider === "kimi" ||
84
- provider === "gemini" ||
85
- ((provider === "codex" || provider === "grok") && harness === "claude-code");
104
+ /* WHAT A PROVIDER/HARNESS PAIR CAN ACTUALLY DO one declaration, read by both sides of the wire.
105
+ *
106
+ * Four runtimes serve turns behind one seam (AgentRequest in, AgentEvent frames out): the Claude Code Agent SDK
107
+ * loop, Codex's exec surface, OpenCode, and any ACP agent. They do NOT do the same things, and for a long time
108
+ * the only thing that said so was a comment inside each adapter "Ignores the Claude-only request fields" —
109
+ * which no surface above it could read. So the composer offered "Ask before each file edit" on a runtime whose
110
+ * every tool call is pre-approved, and offered a reasoning-effort scale to a runtime that drops the field.
111
+ *
112
+ * A capability is listed here only if something READS it: the daemon gates a seam on it, the composer hides or
113
+ * clamps a control by it, or `limitationsOf` tells the user about it. That is the whole point — an ability the
114
+ * matrix claims and nothing consults is how the drift started.
115
+ *
116
+ * Adding a provider is a row here, not a hunt for literals; agent-catalog.test.ts walks PROVIDERS × HARNESSES
117
+ * and demands one, so a pair can never be silently absent. */
118
+ export interface AgentCapabilities {
119
+ // Which agentic loop actually serves the turn — the question "is the harness `claude-code`" only looks like.
120
+ // Claude is always its own Claude Code loop, and kimi/gemini have no native runtime at all (both are
121
+ // re-served through the translator), so all three run it whatever harness the client sent; only codex/grok
122
+ // have a native runtime to switch away from. Names the session store a finished conversation's transcript is
123
+ // backfilled from, too.
124
+ readonly runtime: "claude-code" | "codex" | "opencode" | "acp";
125
+ // Mid-turn injection (the SteeringQueue behind /agent/steer). Needs the SDK's streaming-input mode.
126
+ readonly steering: boolean;
127
+ // How much of the permission-mode axis the runtime honours. "modes" = every PermissionMode, with per-tool
128
+ // permission cards and `mode` frames when the agent moves itself; "plan" = propose-then-approve or run, and
129
+ // nothing in between — the container is the isolation boundary and every tool call is pre-approved.
130
+ readonly permissions: "modes" | "plan";
131
+ // Can stop mid-turn and ask the user a multiple-choice question (`question` frames).
132
+ readonly questions: boolean;
133
+ // Which of the turn's tools reach the agent. "full" = http MCP tools + in-process SDK servers + plugin
134
+ // checkouts + the browser servers; "http" = the http MCP tools alone, and only if the agent advertises http
135
+ // MCP support; "none" = the runtime has no seam for them at all.
136
+ readonly mcp: "full" | "http" | "none";
137
+ // Reasoning-effort selection is forwarded to the model.
138
+ readonly effort: boolean;
139
+ // How an isolated conversation's worktree is enforced. "namespace" = the worktree IS /work inside the turn's
140
+ // mount namespace (with the tool-input rewrite as the fallback when the container can't build one); "cwd" =
141
+ // the turn is merely cwd'd into the worktree, so an absolute /work path still reaches the shared checkout —
142
+ // which is why those turns are told where their tree is (turn-preamble.ts).
143
+ readonly isolation: "namespace" | "cwd";
144
+ // Publishes its slash commands (`commands` frames) for the composer's `/` popover.
145
+ readonly commands: boolean;
146
+ // Runs its shell in a tmux session the terminal panel can attach to (`terminal` frames).
147
+ readonly terminals: boolean;
148
+ // Fails with the coded frames the daemon's auto-resume keys off (rate_limit, provider-outage), so a turn the
149
+ // provider killed is re-run once the breaker says the provider is back (turn-resume.ts).
150
+ readonly recovery: boolean;
151
+ }
152
+
153
+ // The Claude Code Agent SDK loop — the ceiling every other runtime is measured against, and the only one that
154
+ // owns the whole request: permission callbacks, the ask tool, plugins, hooks, and the spawn seam a mount
155
+ // namespace needs.
156
+ const CLAUDE_CODE: AgentCapabilities = {
157
+ runtime: "claude-code",
158
+ steering: true,
159
+ permissions: "modes",
160
+ questions: true,
161
+ mcp: "full",
162
+ effort: true,
163
+ isolation: "namespace",
164
+ commands: true,
165
+ terminals: true,
166
+ recovery: true,
167
+ };
168
+
169
+ // Codex's exec surface: item-level events, no approval channel, no MCP seam through the SDK constructor we use.
170
+ // Reasoning effort IS forwarded (modelReasoningEffort). `codex app-server` is the upgrade path for the first two.
171
+ const CODEX: AgentCapabilities = {
172
+ runtime: "codex",
173
+ steering: false,
174
+ permissions: "plan",
175
+ questions: false,
176
+ mcp: "none",
177
+ effort: true,
178
+ isolation: "cwd",
179
+ commands: false,
180
+ terminals: false,
181
+ recovery: false,
182
+ };
183
+
184
+ // OpenCode (the Grok runtime): its own agentic loop, its own tools, allow-all permissions. It takes a model id
185
+ // and a prompt — no effort scale, no tools of ours, no command list.
186
+ const OPENCODE: AgentCapabilities = {
187
+ runtime: "opencode",
188
+ steering: false,
189
+ permissions: "plan",
190
+ questions: false,
191
+ mcp: "none",
192
+ effort: false,
193
+ isolation: "cwd",
194
+ commands: false,
195
+ terminals: false,
196
+ recovery: false,
197
+ };
198
+
199
+ // Any agent speaking the Agent Client Protocol: a documented floor rather than the native ceiling. It publishes
200
+ // commands, runs its terminals in the conversation's tmux session, and takes our http MCP tools when it says it
201
+ // can — but it owns its own model, effort and permission posture.
202
+ const ACP: AgentCapabilities = {
203
+ runtime: "acp",
204
+ steering: false,
205
+ permissions: "plan",
206
+ questions: false,
207
+ mcp: "http",
208
+ effort: false,
209
+ isolation: "cwd",
210
+ commands: true,
211
+ terminals: true,
212
+ recovery: false,
213
+ };
214
+
215
+ // The pair → its record. An id that names no native provider is an installed `agent`-kind capability, served
216
+ // over ACP.
217
+ export const capabilitiesOf = (provider: AgentProvider, harness: AgentHarness): AgentCapabilities => {
218
+ if (provider === "codex") {
219
+ return harness === "claude-code" ? CLAUDE_CODE : CODEX;
220
+ }
221
+ if (provider === "grok") {
222
+ return harness === "claude-code" ? CLAUDE_CODE : OPENCODE;
223
+ }
224
+ return (NATIVE_PROVIDERS as readonly string[]).includes(provider) ? CLAUDE_CODE : ACP;
225
+ };
226
+
227
+ // Which permission modes a runtime can actually be put in. Under "plan" every other mode collapses onto the
228
+ // autonomous posture the runtime already runs, so offering them would be offering four names for two behaviours.
229
+ export const modesFor = (capabilities: AgentCapabilities): readonly PermissionMode[] =>
230
+ capabilities.permissions === "modes" ? ["default", "acceptEdits", "plan", "bypassPermissions"] : ["plan", "bypassPermissions"];
231
+
232
+ // The mode a selection falls back to when the runtime can't hold it — the same shape as clampEffort, and for the
233
+ // same reason: a provider switch must not leave the composer showing a posture nothing applies.
234
+ export const clampMode = (mode: PermissionMode, capabilities: AgentCapabilities): PermissionMode =>
235
+ modesFor(capabilities).includes(mode) ? mode : "bypassPermissions";
236
+
237
+ // What this pair does NOT do, phrased for the person about to send a message to it — the honest half of the
238
+ // picker, and the reason the record carries axes the daemon itself never branches on. Empty ⇒ the full ceiling.
239
+ export const limitationsOf = (capabilities: AgentCapabilities): string[] => [
240
+ ...(capabilities.permissions === "plan" ? ["no per-tool approvals"] : []),
241
+ ...(capabilities.questions ? [] : ["no clarifying questions"]),
242
+ ...(capabilities.steering ? [] : ["no mid-turn steering"]),
243
+ ...(capabilities.mcp === "none" ? ["no MCP tools or plugins"] : capabilities.mcp === "http" ? ["MCP tools only — no plugins or browser"] : []),
244
+ ...(capabilities.effort ? [] : ["no effort control"]),
245
+ ...(capabilities.commands ? [] : ["no slash commands"]),
246
+ ...(capabilities.terminals ? [] : ["no terminal panel"]),
247
+ ...(capabilities.isolation === "namespace" ? [] : ["worktree by working directory only"]),
248
+ ...(capabilities.recovery ? [] : ["no auto-resume after an outage"]),
249
+ ];
86
250
 
87
251
  // Claude's compile-time model floor, shared by the daemon's catalog (claude-models.ts — its last rung, reached
88
252
  // only before either live source has ever answered) and by the web's pre-load list, so the two can't name
@@ -1,15 +1,6 @@
1
1
  import { eventIterator, oc } from "@orpc/contract";
2
2
  import { AgentCommandsQuerySchema, AgentCommandsSchema, AttachFrameSchema } from "../events.js";
3
- import {
4
- AgentReplySchema,
5
- AgentTurnSchema,
6
- AttachTurnSchema,
7
- OkSchema,
8
- ResumeLimitSchema,
9
- StartedTurnSchema,
10
- SteerSchema,
11
- StopTurnSchema,
12
- } from "../schemas.js";
3
+ import { AgentReplySchema, AgentTurnSchema, AttachTurnSchema, OkSchema, StartedTurnSchema, SteerSchema, StopTurnSchema } from "../schemas.js";
13
4
 
14
5
  // A turn EXECUTES as a detached daemon-side run: `run` starts it and acks with the run id; any number of
15
6
  // clients render it via `attach` (replay from a seq cursor, then live) — the initiating window holds no
@@ -22,10 +13,6 @@ export const agentContract = {
22
13
  reply: oc.route({ method: "POST", path: "/agent/reply" }).input(AgentReplySchema).output(OkSchema),
23
14
  steer: oc.route({ method: "POST", path: "/agent/steer" }).input(SteerSchema).output(OkSchema),
24
15
  stop: oc.route({ method: "POST", path: "/agent/stop" }).input(StopTurnSchema).output(OkSchema),
25
- // Fire the conversation's pending usage-limit resume immediately, optionally on another account — the
26
- // chat's "resume on another account" action. Acks with the run id, exactly like `run`; the resumed turn
27
- // is an ordinary detached run any window attaches to.
28
- resumeLimit: oc.route({ method: "POST", path: "/agent/resume-limit" }).input(ResumeLimitSchema).output(StartedTurnSchema),
29
16
  // The provider's slash commands as last published by one of its turns, so a conversation's `/` popover is
30
17
  // populated before it has run one. The live `commands` frame stays authoritative for a running turn.
31
18
  commands: oc.route({ method: "GET", path: "/agent/commands" }).input(AgentCommandsQuerySchema).output(AgentCommandsSchema),
@@ -0,0 +1,16 @@
1
+ import { oc } from "@orpc/contract";
2
+ import { OkSchema, PrepushRunSchema } from "../schemas.js";
3
+
4
+ // The pre-push check — the command the workspace runs when the user pushes, before anything leaves the machine
5
+ // (see PrepushRunSchema for where this sits and why). Three verbs about ONE run: the check answers about the
6
+ // main working tree, of which there is exactly one, so nothing here is addressed by id.
7
+ //
8
+ // `run` starts the check and returns immediately — a suite takes minutes, and an oRPC call held open for one
9
+ // would die on the first proxy timeout with the work still going. The dialog that started it polls `state`,
10
+ // which carries the live output tail while `status` is `running`. `cancel` kills the child's whole process
11
+ // group; the run settles as `cancelled` and the push it was gating does not go.
12
+ export const prepushContract = {
13
+ state: oc.route({ method: "GET", path: "/prepush/state" }).output(PrepushRunSchema),
14
+ run: oc.route({ method: "POST", path: "/prepush/run" }).output(OkSchema),
15
+ cancel: oc.route({ method: "POST", path: "/prepush/cancel" }).output(OkSchema),
16
+ };
@@ -1,6 +1,6 @@
1
1
  import { eventIterator, oc } from "@orpc/contract";
2
2
  import { z } from "zod";
3
- import { SystemEventSchema } from "../events.js";
3
+ import { SessionTranscriptSchema, SystemEventSchema } from "../events.js";
4
4
  import {
5
5
  BrowserNameParamSchema,
6
6
  BrowsersListSchema,
@@ -10,6 +10,8 @@ import {
10
10
  InfoSchema,
11
11
  OkSchema,
12
12
  PresenceReportSchema,
13
+ SubagentIdParamSchema,
14
+ SubagentsListSchema,
13
15
  TerminalNameParamSchema,
14
16
  TerminalsListSchema,
15
17
  UsageSummarySchema,
@@ -47,4 +49,16 @@ export const systemContract = {
47
49
  // which is the honest account of the owner pulling the plug.
48
50
  browsers: oc.route({ method: "GET", path: "/system/browsers" }).output(BrowsersListSchema),
49
51
  closeBrowser: oc.route({ method: "DELETE", path: "/system/browsers/{name}" }).input(BrowserNameParamSchema).output(OkSchema),
52
+ // The agents this sandbox's agents started — SDK subagents and delegated Codex/Grok runs alike (see
53
+ // SubagentSessionSchema). Same two-route shape as the browsers above, and same division of labour: the list
54
+ // is polled by the Subagents area while it is on screen and loosely by the rail, so its tile can appear the
55
+ // moment a turn delegates. There is no third WebSocket here, because a subagent has no byte stream to watch —
56
+ // what you watch it through is its TRANSCRIPT, which `subagentTranscript` serves in the one shape every
57
+ // other transcript route already answers in: live from the parent turn's frame log while it runs, off the
58
+ // provider's own store once it has finished.
59
+ subagents: oc.route({ method: "GET", path: "/system/subagents" }).output(SubagentsListSchema),
60
+ subagentTranscript: oc
61
+ .route({ method: "GET", path: "/system/subagents/{id}/transcript" })
62
+ .input(SubagentIdParamSchema)
63
+ .output(SessionTranscriptSchema),
50
64
  };
@@ -0,0 +1,32 @@
1
+ import { expect, test } from "vitest";
2
+ import { RESUME_NOTES, withResumeNote, withoutResumeNote } from "./events.js";
3
+
4
+ /* The resume note is a round trip across the wire: the daemon wraps a prompt to tell the model what interrupted
5
+ * it, and the client unwraps the SAME prompt off an attach head to tell whether it already has that bubble. A
6
+ * mismatch between the two halves fails silently and cosmetically — a paragraph of machine prose rendered as
7
+ * something the user typed — which is exactly the kind of drift that stays broken. */
8
+ test("a resume note round-trips back to the user's own words", () => {
9
+ for (const note of Object.values(RESUME_NOTES)) {
10
+ expect(withoutResumeNote(withResumeNote("ship the parser", note))).toBe("ship the parser");
11
+ }
12
+ });
13
+
14
+ // A prompt with blank lines of its own: only the note's own separator comes off, never the user's paragraphs.
15
+ test("stripping takes the note and nothing of the prompt", () => {
16
+ const prompt = "step one\n\nstep two\n\nstep three";
17
+ expect(withoutResumeNote(withResumeNote(prompt, RESUME_NOTES.outage))).toBe(prompt);
18
+ });
19
+
20
+ // An ordinary prompt passes through untouched, so every attach head can be handed through it.
21
+ test("a prompt that is not a resume is left alone", () => {
22
+ expect(withoutResumeNote("just a question")).toBe("just a question");
23
+ expect(withoutResumeNote("")).toBe("");
24
+ });
25
+
26
+ // Wrapping is idempotent: a resume that dies the same way again is re-recorded from its own input, and a second
27
+ // note stacked on the first would grow the prompt on every attempt.
28
+ test("wrapping an already-wrapped prompt adds nothing", () => {
29
+ const once = withResumeNote("retry me", RESUME_NOTES.restart);
30
+ expect(withResumeNote(once, RESUME_NOTES.restart)).toBe(once);
31
+ expect(withResumeNote(once, RESUME_NOTES.auth)).toBe(once);
32
+ });