@intentic/sandbox-contract 1.412.1 → 1.414.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 (60) hide show
  1. package/dist/contracts/ci.contract.d.ts +5 -0
  2. package/dist/contracts/ci.contract.d.ts.map +1 -1
  3. package/dist/contracts/pages.contract.d.ts +13 -0
  4. package/dist/contracts/pages.contract.d.ts.map +1 -1
  5. package/dist/contracts/pages.contract.js +19 -0
  6. package/dist/contracts/pages.contract.js.map +1 -1
  7. package/dist/contracts/system.contract.d.ts +3 -0
  8. package/dist/contracts/system.contract.d.ts.map +1 -1
  9. package/dist/events/transcript.d.ts.map +1 -1
  10. package/dist/events/transcript.js.map +1 -1
  11. package/dist/ids/conversation-ids.d.ts +4 -1
  12. package/dist/ids/conversation-ids.d.ts.map +1 -1
  13. package/dist/ids/conversation-ids.js +24 -8
  14. package/dist/ids/conversation-ids.js.map +1 -1
  15. package/dist/protocol/doors/webext-links.d.ts +7 -0
  16. package/dist/protocol/doors/webext-links.d.ts.map +1 -1
  17. package/dist/protocol/doors/webext-links.js +7 -0
  18. package/dist/protocol/doors/webext-links.js.map +1 -1
  19. package/dist/protocol/raw/raw-routes.d.ts +15 -0
  20. package/dist/protocol/raw/raw-routes.d.ts.map +1 -1
  21. package/dist/protocol/raw/raw-routes.js +3 -0
  22. package/dist/protocol/raw/raw-routes.js.map +1 -1
  23. package/dist/schemas/ci.d.ts +12 -0
  24. package/dist/schemas/ci.d.ts.map +1 -1
  25. package/dist/schemas/ci.js +10 -0
  26. package/dist/schemas/ci.js.map +1 -1
  27. package/dist/schemas/metrics.d.ts +8 -0
  28. package/dist/schemas/metrics.d.ts.map +1 -1
  29. package/dist/schemas/metrics.js +1 -0
  30. package/dist/schemas/metrics.js.map +1 -1
  31. package/dist/schemas/webext.d.ts +19 -0
  32. package/dist/schemas/webext.d.ts.map +1 -1
  33. package/dist/schemas/webext.js +6 -0
  34. package/dist/schemas/webext.js.map +1 -1
  35. package/dist/state/fix-stance.d.ts.map +1 -1
  36. package/dist/state/fix-stance.js +1 -1
  37. package/dist/state/fix-stance.js.map +1 -1
  38. package/dist/text/land-rows.d.ts.map +1 -1
  39. package/dist/text/land-rows.js +5 -2
  40. package/dist/text/land-rows.js.map +1 -1
  41. package/dist/text/pages.d.ts +21 -0
  42. package/dist/text/pages.d.ts.map +1 -1
  43. package/dist/text/pages.js +34 -3
  44. package/dist/text/pages.js.map +1 -1
  45. package/package.json +5 -5
  46. package/src/contracts/pages.contract.ts +27 -2
  47. package/src/events/transcript.ts +2 -1
  48. package/src/ids/conversation-ids.test.ts +50 -17
  49. package/src/ids/conversation-ids.ts +42 -15
  50. package/src/protocol/doors/webext-links.ts +25 -0
  51. package/src/protocol/ingress-contract.fixture.json +3 -0
  52. package/src/protocol/raw/raw-routes.ts +7 -0
  53. package/src/schemas/ci.ts +16 -0
  54. package/src/schemas/metrics.ts +3 -0
  55. package/src/schemas/webext.ts +16 -0
  56. package/src/state/fix-stance.ts +3 -2
  57. package/src/text/land-rows.ts +6 -3
  58. package/src/text/pages.test.ts +58 -0
  59. package/src/text/pages.ts +96 -21
  60. package/src/text/transcript-fold.test.ts +0 -2
@@ -4,8 +4,8 @@ import { PAGE_ERROR_CHARS, PAGE_ERRORS_MAX } from "../text/pages.js";
4
4
 
5
5
  // Pages the agent showed in a chat. The pages themselves are files the workspace already serves; the routes here are
6
6
  // what an MCP server's app asks of its server while a reader uses it (`tools/call` over the bridge), carried by the
7
- // daemon since the app's frame reaches no network of its own, and what a page's own scripts threw as it drew, carried
8
- // back to the agent that showed it.
7
+ // daemon since the app's frame reaches no network of its own, what a page's own scripts threw as it drew, carried
8
+ // back to the agent that showed it, and the ticket a page's video and audio stream with.
9
9
  export const PageAppCallSchema = z.object({
10
10
  page: z.string().min(1).describe("The stored page the app is drawn from, as a workspace path; it names the server and the tool the app belongs to."),
11
11
  name: z.string().min(1).describe("The tool the app asks to call, on its own server."),
@@ -37,6 +37,18 @@ export const PageErrorsResultSchema = z.object({
37
37
  ),
38
38
  });
39
39
 
40
+ export const PageMediaTicketQuerySchema = z.object({
41
+ page: z.string().min(1).describe("The stored page whose video and audio the ticket covers, as a workspace path."),
42
+ });
43
+ export const PageMediaTicketSchema = z.object({
44
+ ticket: z
45
+ .string()
46
+ .describe(
47
+ "Put it in the page's media addresses, GET /pages/media/{ticket}/{index}. It buys exactly the files the page named when it was shown, each only while it is unchanged.",
48
+ ),
49
+ expiresAt: z.number().describe("When it stops working, in milliseconds, so a player can tell a dead ticket from a dead file."),
50
+ });
51
+
40
52
  export const pagesContract = {
41
53
  appCall: procedure
42
54
  .route({
@@ -58,4 +70,17 @@ export const pagesContract = {
58
70
  })
59
71
  .input(PageErrorsSchema)
60
72
  .output(PageErrorsResultSchema),
73
+ // Mints the ticket GET /pages/media/{ticket}/{index} (a plain byte-range route a <video> talks to) requires.
74
+ mediaTicket: procedure
75
+ .route({
76
+ method: "POST",
77
+ path: "/pages/media-ticket",
78
+ summary: "Get a pass for playing a shown page's video and audio",
79
+ description:
80
+ "Mints the short-lived ticket a shown page's video and audio elements stream with, since a player cannot carry an ordinary header. It covers only the files that page named when the agent showed it, and each only while it is still the file that was shown: one overwritten or removed since is refused rather than played in its place.",
81
+ })
82
+ // Playing a page's media is reading the page, and the ticket is narrower than the bearer.
83
+ .meta({ floor: "viewer", guest: true })
84
+ .input(PageMediaTicketQuerySchema)
85
+ .output(PageMediaTicketSchema),
61
86
  };
@@ -338,7 +338,8 @@ export const TranscriptRowSchema = z.object({
338
338
  // The follow-up this notice offers, by name; the chat decides what it does, and whether it stands. `sendAnyway` sends
339
339
  // the held message; `sandboxMemory` offers that and a raise of the sandbox's memory; `sendAgain` sends a turn the
340
340
  // sandbox kept after a refusal no raise would clear; `switchModel` opens the model list for a turn a model's refusal
341
- // stopped partway, so the same conversation carries on with another.
341
+ // stopped partway, so the same conversation carries on with another. `landHold` is no longer written; stored rows that
342
+ // carry it must still parse.
342
343
  noticeAction: z
343
344
  .enum(["landHold", "depsInstall", "watchStop", "sandboxMemory", "sendAnyway", "sendAgain", "switchModel"])
344
345
  .optional()
@@ -10,9 +10,12 @@ import {
10
10
  TAIL_ALPHABET,
11
11
  homeConversationId,
12
12
  isHomeConversationId,
13
+ legacyCiFixConversationId,
14
+ ciFixBase,
13
15
  ciFixConversationId,
14
16
  fixAttemptId,
15
17
  fixAttemptOf,
18
+ isCiFixConversationId,
16
19
  fixAttemptsOf,
17
20
  latestFixAttempt,
18
21
  newConversationId,
@@ -64,10 +67,10 @@ test("every word is a short lowercase word, listed once", () => {
64
67
  }
65
68
  });
66
69
 
67
- // A drawn id must never read as a derived one (`home-…`, `ci-fix-…`, `sub-…`) or as a git ref. Every prefix a
70
+ // A drawn id must never read as a derived one (`home-…`, `fix-…`, `sub-…`) or as a git ref. Every prefix a
68
71
  // conversation id is minted under is listed, wherever it is minted: fix agents, home, subagents and links (this file's
69
72
  // module), automation fires (`a-`), workflow steps (`wf-`), the public doors (`wc-` Visitor chat, `bug-` issue
70
- // intake), extension update reviews (`ext-update-`) and the batch packs (`xt-`, `dg-`, `mt-`). Then the neighbours a
73
+ // intake), extension update reviews (`upd-`) and the batch packs (`xt-`, `dg-`, `mt-`). Then the neighbours a
71
74
  // drawn id would be mistaken for: a borrowed account (`lent-`) and a watch (`watch-k7mq` is its exact shape).
72
75
  test("no word collides with a derived id's prefix or a git name", () => {
73
76
  const prefixes = [
@@ -81,7 +84,7 @@ test("no word collides with a derived id's prefix or a git name", () => {
81
84
  "wf-",
82
85
  "wc-",
83
86
  "bug-",
84
- "ext-update-",
87
+ "upd-",
85
88
  "xt-",
86
89
  "dg-",
87
90
  "mt-",
@@ -138,7 +141,9 @@ test("ids are unique across a burst", () => {
138
141
  });
139
142
 
140
143
  test("a CI fix id is the same string every time it is derived", () => {
141
- expect(ciFixConversationId(`web`, 4213)).toBe(`ci-fix-web-4213`);
144
+ expect(ciFixConversationId(`web`, 4213)).toBe(`fix-web-391`);
145
+ // The id the screenshot that asked for this carried, `ci-fix-intentic-42991360694-attempt5`, now reads:
146
+ expect(fixAttemptId(ciFixConversationId(`intentic`, 42_991_360_694), 5)).toBe(`fix-intentic-jqzy27q_5`);
142
147
  expect(ciFixConversationId(`web`, 4213)).toBe(ciFixConversationId(`web`, 4213));
143
148
  });
144
149
 
@@ -158,31 +163,39 @@ test("every derived id passes the conversation-id guard", () => {
158
163
  }
159
164
  });
160
165
 
166
+ test("a fix agent is told apart by its id, whichever shape it was minted in", () => {
167
+ expect(isCiFixConversationId(ciFixConversationId(`web`, 41))).toBe(true);
168
+ expect(isCiFixConversationId(`ci-fix-intentic-42991360694-attempt5`)).toBe(true);
169
+ // The gate CLI's own conversations, and a drawn id.
170
+ expect(isCiFixConversationId(`ci-42991360694-1`)).toBe(false);
171
+ expect(isCiFixConversationId(`otter-k7mq`)).toBe(false);
172
+ });
173
+
161
174
  test("the prefix is carried by every fix id", () => {
162
- expect(ciFixConversationId(`ci-fix`, 7)).toBe(`ci-fix-ci-fix-7`);
175
+ expect(ciFixConversationId(`ci-fix`, 7)).toBe(`fix-ci-fix-7`);
163
176
  });
164
177
 
165
178
  // Attempt 1 is the bare derived id, so every fix conversation minted before attempts existed reads as attempt 1.
166
179
  test("the first attempt wears the failure's own id, later ones carry their number", () => {
167
180
  const base = ciFixConversationId(`web`, 41);
168
181
  expect(fixAttemptId(base, 1)).toBe(base);
169
- expect(fixAttemptId(base, 2)).toBe(`ci-fix-web-41-attempt2`);
182
+ expect(fixAttemptId(base, 2)).toBe(`fix-web-15_2`);
170
183
  expect(fixAttemptOf(base, base)).toBe(1);
171
- expect(fixAttemptOf(base, `ci-fix-web-41-attempt2`)).toBe(2);
172
- expect(fixAttemptOf(base, `ci-fix-web-41-attempt12`)).toBe(12);
184
+ expect(fixAttemptOf(base, `fix-web-15_2`)).toBe(2);
185
+ expect(fixAttemptOf(base, `fix-web-15_12`)).toBe(12);
173
186
  });
174
187
 
175
188
  // Read base-relative on purpose: a base ends in a run id, so a neighbouring failure's id can start with this one.
176
189
  test("another failure's id is not an attempt at this one", () => {
177
190
  const base = ciFixConversationId(`web`, 41);
178
- // Repo `web-41`, run 2: starts with the base and a dash, and is nobody's attempt.
179
- expect(fixAttemptOf(base, ciFixConversationId(`web-41`, 2))).toBeUndefined();
180
- expect(fixAttemptOf(base, ciFixConversationId(`web`, 412))).toBeUndefined();
191
+ // Repo `web-15`, run 2: starts with the base and a dash, and is nobody's attempt.
192
+ expect(fixAttemptOf(base, ciFixConversationId(`web-15`, 2))).toBeUndefined();
193
+ expect(fixAttemptOf(base, ciFixConversationId(`web`, 41 * 36))).toBeUndefined();
181
194
  expect(fixAttemptOf(base, `swift-otter-k9m2`)).toBeUndefined();
182
195
  // One spelling per attempt.
183
- expect(fixAttemptOf(base, `ci-fix-web-41-attempt1`)).toBeUndefined();
184
- expect(fixAttemptOf(base, `ci-fix-web-41-attempt02`)).toBeUndefined();
185
- expect(fixAttemptOf(base, `ci-fix-web-41-attempt`)).toBeUndefined();
196
+ expect(fixAttemptOf(base, `fix-web-15_1`)).toBeUndefined();
197
+ expect(fixAttemptOf(base, `fix-web-15_02`)).toBeUndefined();
198
+ expect(fixAttemptOf(base, `fix-web-15_`)).toBeUndefined();
186
199
  });
187
200
 
188
201
  test("attempts are read off the roster, earliest first, and the newest is the live answer", () => {
@@ -197,9 +210,9 @@ test("attempts are read off the roster, earliest first, and the newest is the li
197
210
  test("the next attempt is numbered past every known one, archived included", () => {
198
211
  const base = ciFixConversationId(`web`, 41);
199
212
  expect(nextFixAttemptId(base, [])).toBe(base);
200
- expect(nextFixAttemptId(base, [base])).toBe(`ci-fix-web-41-attempt2`);
201
- expect(nextFixAttemptId(base, [`ci-fix-web-41-attempt3`, `swift-otter-k9m2`])).toBe(`ci-fix-web-41-attempt4`);
202
- expect(nextFixAttemptId(base, [ciFixConversationId(`web-41`, 2)])).toBe(base);
213
+ expect(nextFixAttemptId(base, [base])).toBe(`fix-web-15_2`);
214
+ expect(nextFixAttemptId(base, [`fix-web-15_3`, `swift-otter-k9m2`])).toBe(`fix-web-15_4`);
215
+ expect(nextFixAttemptId(base, [ciFixConversationId(`web-15`, 2)])).toBe(base);
203
216
  });
204
217
 
205
218
  test("an attempt id passes the guard and fits, even for the widest run id a forge mints", () => {
@@ -211,6 +224,26 @@ test("an attempt id passes the guard and fits, even for the widest run id a forg
211
224
  }
212
225
  });
213
226
 
227
+ // Fix agents minted before the ids were shortened (2026-11-12) still answer their failures: the board found none of them
228
+ // after the change, and offered Fix with agent beside a failure two agents had already worked.
229
+ test("a run fixed before the ids were shortened keeps its own family", () => {
230
+ const legacy = legacyCiFixConversationId(`intentic`, 43_301_660_752);
231
+ expect(legacy).toBe(`ci-fix-intentic-43301660752`);
232
+ expect(fixAttemptOf(legacy, `ci-fix-intentic-43301660752-attempt2`)).toBe(2);
233
+ // An attempt minted after the change, on the family the legacy base began.
234
+ expect(fixAttemptOf(legacy, fixAttemptId(legacy, 3))).toBe(3);
235
+ expect(latestFixAttempt(legacy, [{ id: legacy }, { id: `ci-fix-intentic-43301660752-attempt2` }])?.attempt).toBe(2);
236
+ expect(ciFixBase(`intentic`, 43_301_660_752, [`ci-fix-intentic-43301660752-attempt2`])).toBe(legacy);
237
+ expect(ciFixBase(`intentic`, 43_301_660_752, [`swift-otter-k9m2`])).toBe(ciFixConversationId(`intentic`, 43_301_660_752));
238
+ });
239
+
240
+ test("the legacy attempt mark is read only on the bases that once carried it", () => {
241
+ const base = ciFixConversationId(`web`, 41);
242
+ expect(fixAttemptOf(base, `${base}-attempt2`)).toBeUndefined();
243
+ // Another legacy run's id is no attempt: `-attempt` never follows a decimal run id inside a base.
244
+ expect(fixAttemptOf(legacyCiFixConversationId(`web`, 41), legacyCiFixConversationId(`web-41`, 2))).toBeUndefined();
245
+ });
246
+
214
247
  // One home conversation per member, derived from who they are: the same in every browser and in the daemon, whatever the
215
248
  // email's case, a valid conversation id, and never the email itself.
216
249
  test("a home conversation id is its member's alone, stable and folded, and says nothing of the address", () => {
@@ -76,18 +76,39 @@ export const looksDrawn = (id: string): boolean => {
76
76
  };
77
77
 
78
78
  // Derived, not drawn, so a re-computed id says whether an agent is already on this failure and a second press continues
79
- // it. The repo is included (one run id per project) and slugified, not hashed, since people read it.
80
- export const CI_FIX_PREFIX = "ci-fix-";
81
- // Leaves ~24 characters for the run id and an attempt suffix within the 64-char id limit; the widest run id either
82
- // forge mints is eleven digits.
83
- const REPO_SLUG_MAX = 32;
84
- const repoSlug = (repo: string): string =>
79
+ // it. The repo is included (one run id per project) and slugified, not hashed, since people read it. Kept short, since it
80
+ // is also the branch and the worktree folder every board row prints: `fix-intentic-jqzy27q`, not
81
+ // `ci-fix-intentic-42991360694`. Not `ci-`: the gate CLI names its own conversations `ci-<run>-<attempt>`. The run id is base36 (the widest either forge mints, eleven digits, is eight
82
+ // characters), and the repo is cut at sixteen, which still names it: the run id is what keeps two repos apart.
83
+ export const CI_FIX_PREFIX = "fix-";
84
+ // What fix agents minted before the ids were shortened carry; still a fix agent's, so still read as one.
85
+ const LEGACY_CI_FIX_PREFIX = "ci-fix-";
86
+ export const isCiFixConversationId = (id: string): boolean => id.startsWith(CI_FIX_PREFIX) || id.startsWith(LEGACY_CI_FIX_PREFIX);
87
+ const REPO_SLUG_MAX = 16;
88
+ const repoSlug = (repo: string, max = REPO_SLUG_MAX): string =>
85
89
  repo
86
90
  .toLowerCase()
87
91
  .replace(/[^a-z0-9]+/g, "-")
88
- .slice(0, REPO_SLUG_MAX)
92
+ .slice(0, max)
89
93
  .replace(/^-+|-+$/g, "") || "repo";
90
- export const ciFixConversationId = (repo: string, runId: number): string => `${CI_FIX_PREFIX}${repoSlug(repo)}-${runId}`;
94
+ export const ciFixConversationId = (repo: string, runId: number): string => `${CI_FIX_PREFIX}${repoSlug(repo)}-${runId.toString(36)}`;
95
+ // The same failure's id as it was minted before 2026-11-12: the repo cut at thirty-two, the run id in decimal. Fix agents
96
+ // started then still answer their failures, so every reader that pairs a run with its agent asks under both (ciFixBase).
97
+ const LEGACY_REPO_SLUG_MAX = 32;
98
+ export const legacyCiFixConversationId = (repo: string, runId: number): string =>
99
+ `${LEGACY_CI_FIX_PREFIX}${repoSlug(repo, LEGACY_REPO_SLUG_MAX)}-${runId}`;
100
+ // The base a run's fix attempts share: the legacy spelling while an attempt under it is known (live or archived), so a
101
+ // press on a failure fixed before the ids were shortened continues that family (attempt 3, not a second attempt 1 that
102
+ // knows nothing of the first two); the current spelling otherwise.
103
+ export const ciFixBase = (repo: string, runId: number, knownIds: Iterable<string>): string => {
104
+ const legacy = legacyCiFixConversationId(repo, runId);
105
+ for (const id of knownIds) {
106
+ if (fixAttemptOf(legacy, id) !== undefined) {
107
+ return legacy;
108
+ }
109
+ }
110
+ return ciFixConversationId(repo, runId);
111
+ };
91
112
  // The title a CI fix conversation opens with: the daemon names it so (ci-fix.ts), and the board's card standing in for it
92
113
  // while the press is out (Pipelines, `chat.launchAgent`) wears the same words, so the one hands over to the other unchanged.
93
114
  export const ciFixTitle = (run: { readonly title?: string | undefined; readonly repo: string }): string =>
@@ -127,23 +148,29 @@ export const landFixConversationId = (project: string, failingSince: number): st
127
148
  // ONE FAILURE, MANY ATTEMPTS, ONE LIVE ANSWER. The derived id above names the FAILURE; an attempt at it is a
128
149
  // conversation of its own, so starting over (another model, a clean worktree) never rewrites a record some other window
129
150
  // is showing, and every attempt keeps its own transcript, cost and URL. Attempt 1 wears the bare id, so every id minted
130
- // before attempts existed is attempt 1 of its failure.
131
- const ATTEMPT_MARK = "-attempt";
151
+ // before attempts existed is attempt 1 of its failure. Later ones add `_<n>`: an underscore, since no base holds one (a
152
+ // slug turns every other character into `-`), so `fix-web-15_2` can only be run 15's second attempt, never a base.
153
+ const ATTEMPT_MARK = "_";
154
+ // What later attempts carried before 2026-11-12, still read on the bases minted then (a legacy CI fix's, which ends in a
155
+ // decimal run id, and a land fix's, which ends in six base36 characters), where `-attempt` cannot be part of a base.
156
+ // Never on a current `fix-` base: its base36 run id could one day spell it.
157
+ const LEGACY_ATTEMPT_MARK = "-attempt";
158
+ const legacyAttempts = (base: string): boolean => base.startsWith(LEGACY_CI_FIX_PREFIX) || base.startsWith(LAND_FIX_PREFIX);
132
159
 
133
160
  export const fixAttemptId = (base: string, attempt: number): string => (attempt <= 1 ? base : `${base}${ATTEMPT_MARK}${attempt}`);
134
161
 
135
162
  // Which attempt at `base` this id is, or undefined for an id that is none of them. Read base-relative, never the other
136
- // way round: a base ends in a run id or a digest, so nothing about an id on its own says where an attempt marker would
137
- // begin, and `ci-fix-web-41-2` is repo `web-41`'s run 2, not a second go at run 41.
163
+ // way round: the marker is unambiguous, but only the base says which failure an attempt answers.
138
164
  export const fixAttemptOf = (base: string, id: string): number | undefined => {
139
165
  if (id === base) {
140
166
  return 1;
141
167
  }
142
- if (!id.startsWith(`${base}${ATTEMPT_MARK}`)) {
168
+ const mark = [ATTEMPT_MARK, ...(legacyAttempts(base) ? [LEGACY_ATTEMPT_MARK] : [])].find((each) => id.startsWith(`${base}${each}`));
169
+ if (mark === undefined) {
143
170
  return undefined;
144
171
  }
145
- const rest = id.slice(base.length + ATTEMPT_MARK.length);
146
- // One spelling per attempt: the first is the bare id, so `-attempt1` and a zero-padded number are nobody's.
172
+ const rest = id.slice(base.length + mark.length);
173
+ // One spelling per attempt: the first is the bare id, so `_1` and a zero-padded number are nobody's.
147
174
  return /^[2-9]\d*$|^[1-9]\d+$/.test(rest) ? Number(rest) : undefined;
148
175
  };
149
176
 
@@ -22,6 +22,31 @@ export const webextLendUrl = (sandboxUrl: string): string => `${sandboxUrl.repla
22
22
  // are: a tool answer over the socket lands in the model's context, and this value must never reach one.
23
23
  export const webextSecretUrl = (sandboxUrl: string): string => `${sandboxUrl.replace(/\/$/, "")}/system/webext/secret`;
24
24
 
25
+ // Where the extension stores a picture, video or file it fetched from a page (`save_media`, a download the agent's click
26
+ // started), bearer-authenticated. The bytes are the raw body, never MCP JSON: a tool answer lands in a model's context,
27
+ // and base64 inside JSON costs a third more besides. The answer names where the file now is in the sandbox.
28
+ export const webextMediaUrl = (sandboxUrl: string): string => `${sandboxUrl.replace(/\/$/, "")}/system/webext/media`;
29
+
30
+ // The other direction (`upload_file`): the extension collects one sandbox file for a ticket the daemon added to the call
31
+ // on its way through, so a browser can never ask for a file on its own say-so.
32
+ export const webextFileUrl = (sandboxUrl: string): string => `${sandboxUrl.replace(/\/$/, "")}/system/webext/file`;
33
+
34
+ // The most either door carries in one file. A generated picture is a few MB and a short clip tens; past this an agent
35
+ // is moving something no page tool should carry, and both sides hold the whole file in memory while it crosses.
36
+ export const WEBEXT_MEDIA_MAX_BYTES = 50 * 1024 * 1024;
37
+
38
+ // Headers beside the media body: the file-name stem the page suggested (URI-encoded, the sandbox sanitizes it) and the
39
+ // page's host, which the sandbox's log line names.
40
+ export const WEBEXT_MEDIA_NAME_HEADER = "x-intentic-name";
41
+ export const WEBEXT_MEDIA_SOURCE_HEADER = "x-intentic-source";
42
+
43
+ // The tool that puts a sandbox file into a page's file input. The daemon recognises calls to it on their way to the
44
+ // browser and adds the ticket the file is collected with (the sandbox's webext/file-tickets.ts).
45
+ export const WEBEXT_UPLOAD_TOOL = "upload_file";
46
+
47
+ // How long a file ticket waits to be collected; the extension collects it before it asks the person anything.
48
+ export const WEBEXT_FILE_TICKET_TTL_MS = 60_000;
49
+
25
50
  // Where the extension tells its sandbox that site access changed outside the popup (2026-10-20), bearer-authenticated.
26
51
  export const webextGrantsChangedUrl = (sandboxUrl: string): string => `${sandboxUrl.replace(/\/$/, "")}/system/webext/grants-changed`;
27
52
 
@@ -50,11 +50,14 @@
50
50
  "GET /workspace/raw",
51
51
  "GET /workspace/media",
52
52
  "GET /workspace/download",
53
+ "GET /pages/media/{ticket}/{index}",
53
54
  "POST /workspace/upload",
54
55
  "POST /workspace/upload-archive",
55
56
  "GET /system/sync/ssh",
56
57
  "GET /bundles/download",
57
58
  "GET /extensions/{id}/bundle",
59
+ "POST /system/webext/media",
60
+ "POST /system/webext/file",
58
61
  "GET /system/runners/git/{repo}/info/refs",
59
62
  "POST /system/runners/git/{repo}/git-upload-pack",
60
63
  "POST /system/runners/git/{repo}/git-receive-pack"
@@ -45,6 +45,9 @@ export const RAW_ROUTES = {
45
45
  // A previewed web page and the files it names, loaded by a frame, which sends no header: the ticket is the path's
46
46
  // first segment, so the page's relative addresses carry it, and it is checked in the handler.
47
47
  "GET /workspace/preview/{ticket}/*": { auth: "door", guest: true },
48
+ // A shown page's video or audio, streamed in ranges to a player inside the page's sealed frame, which sends no header:
49
+ // the ticket (pages.mediaTicket) is checked in the handler, against the files the page named when it was shown.
50
+ "GET /pages/media/{ticket}/{index}": { auth: "door", guest: true, lane: "bulk" },
48
51
  // An attachment is part of the message it rides with; any other target edits the shared tree.
49
52
  "POST /workspace/upload": { floor: "writer", attachmentFloor: "collaborator", lane: "bulk" },
50
53
  "POST /workspace/upload-diff": {},
@@ -260,6 +263,10 @@ export const RAW_ROUTES = {
260
263
  // for this browser and one host, handed back on the browser's own request rather than over the tool socket.
261
264
  "POST /system/webext/secret": { auth: "door", control: "never" },
262
265
  "POST /system/webext/grants-changed": { auth: "door", control: "never" },
266
+ // A picture, video or file the agent saved from a page in that browser, as the raw body, onto the artifacts shelf;
267
+ // and one shelf file going the other way, for a ticket the daemon added to the agent's `upload_file` call.
268
+ "POST /system/webext/media": { auth: "door", control: "never", lane: "bulk" },
269
+ "POST /system/webext/file": { auth: "door", control: "never", lane: "bulk" },
263
270
  // This sandbox's keyring keys (schemas/keyring.ts), public halves only: a keyring fetches them here over TLS, from the
264
271
  // sandbox's own address, before it shares anything with it, rather than take them from whoever relays the share.
265
272
  "GET /keyring/keys": { auth: "door", control: "never" },
package/src/schemas/ci.ts CHANGED
@@ -239,6 +239,16 @@ export const CiForgetParamSchema = z.object({
239
239
  .describe("The workflow to stop tracking, by the name the failure lists it under. Leave it out to end the whole failure, every workflow on it."),
240
240
  });
241
241
  export type CiForgetParam = z.infer<typeof CiForgetParamSchema>;
242
+ // A step only a person can take, outside the repository, that a CI fix agent ended its turn on: a field in a store's
243
+ // dashboard, a secret's value, an account setting. No commit fixes such a failure, so the board shows the step on the
244
+ // failed run instead of reading the agent's turn as a fix (ci/owner-steps.ts).
245
+ export const CI_OWNER_STEP_MARK = "Owner step:";
246
+ export const CiOwnerStepSchema = z.object({
247
+ conversationId: z.string().describe("The fix agent that said it: which run's failure it answers is in its id."),
248
+ step: z.string().describe("What the owner has to do, and where, in the agent's own words."),
249
+ at: z.number().describe("When the turn that said it ended, in milliseconds."),
250
+ });
251
+ export type CiOwnerStep = z.infer<typeof CiOwnerStepSchema>;
242
252
  export const CiRunsResponseSchema = z.object({
243
253
  repos: z.array(CiRepoSchema).describe("Which workspace repositories are wired to a forge, and how each one's notifications are set up."),
244
254
  // Newest first, across all mapped repos.
@@ -247,6 +257,12 @@ export const CiRunsResponseSchema = z.object({
247
257
  .array(CiMainFailureSchema)
248
258
  .optional()
249
259
  .describe("Every main-line branch failing right now, with the fix agent on it. Absent from a daemon that keeps none."),
260
+ ownerSteps: z
261
+ .array(CiOwnerStepSchema)
262
+ .optional()
263
+ .describe(
264
+ "Steps outside the repository that CI fix agents ended their latest turn on, one per agent. Absent from a daemon that keeps none.",
265
+ ),
250
266
  });
251
267
  export type CiRunsResponse = z.infer<typeof CiRunsResponseSchema>;
252
268
  // Re-resolves repo → project + token on every call, so a stale card can't act on a mapping the workspace no longer has.
@@ -225,6 +225,9 @@ export const STORAGE_CLEANABILITY = {
225
225
  browserProfiles: "confirm",
226
226
  // Weights downloaded for local models.
227
227
  modelWeights: "confirm",
228
+ // What agents' tools downloaded and built in the workspace's cache folder, one folder per tool: Python environments,
229
+ // model weights, package downloads. Comes back only by downloading or building it again.
230
+ toolCaches: "confirm",
228
231
  // The sandbox's own logs and terminal captures.
229
232
  logs: "safe",
230
233
  // Scratch space agents and checks leave behind.
@@ -128,3 +128,19 @@ export type WebExtSecretRequest = z.infer<typeof WebExtSecretRequestSchema>;
128
128
  // not, which reaches the agent as the tool's refusal.
129
129
  export const WebExtSecretAnswerSchema = union([object({ ok: literal(true), value: string() }), object({ ok: literal(false), message: string() })]);
130
130
  export type WebExtSecretAnswer = z.infer<typeof WebExtSecretAnswerSchema>;
131
+
132
+ // What the sandbox answers a stored picture, video or file (webextMediaUrl): where it now is, as the agent reads it,
133
+ // with its size and type; or the sentence why it was not stored, which reaches the agent as the tool's refusal.
134
+ export const WebExtMediaAnswerSchema = union([
135
+ object({ ok: literal(true), path: string(), bytes: number(), mimeType: string() }),
136
+ object({ ok: literal(false), message: string() }),
137
+ ]);
138
+ export type WebExtMediaAnswer = z.infer<typeof WebExtMediaAnswerSchema>;
139
+
140
+ // The extension collecting a sandbox file for a page's file input (webextFileUrl): the ticket the daemon added to the
141
+ // `upload_file` call, and nothing else. The bytes come back as the answer's body, the file's name in its
142
+ // `x-intentic-name` header; a refusal comes back as `{ ok: false, message }`.
143
+ export const WebExtFileRequestSchema = object({ ticket: string().min(1) });
144
+ export type WebExtFileRequest = z.infer<typeof WebExtFileRequestSchema>;
145
+ export const WebExtFileRefusalSchema = object({ ok: literal(false), message: string() });
146
+ export type WebExtFileRefusal = z.infer<typeof WebExtFileRefusalSchema>;
@@ -10,7 +10,7 @@ export type FixStanceKind =
10
10
  | "needs-you"
11
11
  // The fix is written and held on the agent's branch, waiting to be reviewed and landed.
12
12
  | "ready"
13
- // It is in the workspace. What is left is proving it: re-run the check.
13
+ // It is in the workspace, not yet in a commit any check has run. What is left is proving it: commit and push.
14
14
  | "landed"
15
15
  // Stopped on a spent allowance, which is a wait rather than a failure and must not be drawn as one.
16
16
  | "waiting"
@@ -63,7 +63,8 @@ const LANDED: FixStance = {
63
63
  ongoing: false,
64
64
  retry: false,
65
65
  label: "Fix landed",
66
- hint: "The fix is in your workspace. Running the check again is what proves it.",
66
+ // Not "run the check again": a re-run repeats the commit that failed, which the fix is not in (2026-11-12).
67
+ hint: "The fix is in your workspace. Commit and push it: the next run of the check shows whether it worked.",
67
68
  };
68
69
 
69
70
  const WAITING: FixStance = {
@@ -100,16 +100,19 @@ export const landedRow = (event: Extract<AgentEvent, { kind: "landed" }>): Trans
100
100
  noticeCode: noticeCode({ code: "landConflict", params: { files, repos } }),
101
101
  };
102
102
  }
103
- // noticeAction fires only here, right as the auto-behavior ran; an active install takes the slot instead.
103
+ // An install the land started is the one follow-up offered; a landed row never asks the user to change how this agent lands.
104
104
  const deps = event.deps === undefined || event.deps.missing === 0 ? undefined : event.deps;
105
- return {
105
+ const row: TranscriptRow = {
106
106
  role: "notice",
107
107
  // A home's land (the only one named) is committed too, by nobody pressing anything: said, not left to the Changes panel.
108
108
  text: `${event.land === undefined ? "Changes landed in your workspace: review them in the Changes panel." : "Landed in your workspace and committed."}${dependencyLine(event.deps)}`,
109
- noticeAction: (event.deps?.started.length ?? 0) > 0 ? "depsInstall" : "landHold",
110
109
  noticeCode: noticeCode({
111
110
  code: "landed",
112
111
  params: deps === undefined && event.land === undefined ? undefined : { deps: deps?.missing, queued: deps?.deferred || undefined, land: event.land },
113
112
  }),
114
113
  };
114
+ if ((event.deps?.started.length ?? 0) > 0) {
115
+ row.noticeAction = "depsInstall";
116
+ }
117
+ return row;
115
118
  };
@@ -6,7 +6,13 @@ import {
6
6
  mcpAppDataScript,
7
7
  PAGE_FALLBACK_THEMES,
8
8
  PAGE_THEME_VARIABLES,
9
+ pageMediaScript,
10
+ pageMediaSigned,
9
11
  pageThemeCss,
12
+ placePageMedia,
13
+ readPageMedia,
14
+ sealedPagePolicy,
15
+ withoutPageMedia,
10
16
  publishedPage,
11
17
  readMcpAppData,
12
18
  sealedPage,
@@ -160,3 +166,55 @@ describe("sizedFirst", () => {
160
166
  expect(JSON.parse(literal!)).toBe(page);
161
167
  });
162
168
  });
169
+
170
+ describe("a page's streamed media", () => {
171
+ const TAKE = { path: "/work/shots/take1.mp4", type: "video/mp4", size: 12_000_000, mtimeMs: 1_731_400_000_000.25 };
172
+ const ADDRESS = "https://sandbox.example/pages/media/T0k3n_-x/0";
173
+
174
+ it("opens media-src to exactly the addresses named, and nothing else to anything", () => {
175
+ const policy = sealedPagePolicy([ADDRESS]);
176
+ const directives = Object.fromEntries(policy.split("; ").map((directive) => [directive.split(" ")[0], directive]));
177
+ expect(directives["media-src"]).toBe(`media-src data: blob: ${ADDRESS}`);
178
+ expect(directives["default-src"]).toBe(`default-src 'none'`);
179
+ expect(directives["connect-src"]).toBe(`connect-src data: blob:`);
180
+ expect(directives["img-src"]).toBe(`img-src data: blob:`);
181
+ expect(policy.split(ADDRESS).length).toBe(2);
182
+ expect(sealedPagePolicy()).toBe(SEALED_PAGE_POLICY);
183
+ expect(SEALED_PAGE_POLICY).toContain(`media-src data: blob:;`);
184
+ });
185
+
186
+ it("leaves out an address that could break out of its source expression", () => {
187
+ const policy = sealedPagePolicy([`https://bad.example/a; script-src *`, `https://bad.example/b c`, `javascript:alert(1)`, ADDRESS]);
188
+ expect(policy).not.toContain(`script-src *`);
189
+ expect(policy).not.toContain(`bad.example`);
190
+ expect(policy).toContain(ADDRESS);
191
+ });
192
+
193
+ it("reads back the manifest the daemon wrote, and none the page wrote itself once it is dropped", () => {
194
+ const stored = standalonePage(intoHead(`<video src="intentic-media:0"></video>`, pageMediaScript({ files: [TAKE], signature: `sig` })));
195
+ expect(readPageMedia(stored)).toEqual({ files: [TAKE], signature: `sig` });
196
+ expect(readPageMedia(`<p>no media</p>`)).toBeUndefined();
197
+ const written = `<script type="application/json" id="intentic-page-media"><script type="application/json" id="intentic-page-media">[]</script>`;
198
+ expect(withoutPageMedia(written)).not.toContain(`id="intentic-page-media"`);
199
+ });
200
+
201
+ it("publishes a page without its manifest, so a share never carries the sandbox's paths", () => {
202
+ const stored = standalonePage(intoHead(`<video src="intentic-media:0"></video>`, pageMediaScript({ files: [TAKE], signature: `sig` })));
203
+ const published = publishedPage(stored);
204
+ expect(published).not.toContain(TAKE.path);
205
+ expect(readPageMedia(published)).toBeUndefined();
206
+ expect(published).toContain(`<video src="intentic-media:0"></video>`);
207
+ });
208
+
209
+ it("signs over the page and every field of every file, so neither can move without the signature failing", () => {
210
+ const signed = pageMediaSigned(`pages/c1/a.r0.html`, [TAKE]);
211
+ expect(pageMediaSigned(`pages/c2/a.r0.html`, [TAKE])).not.toBe(signed);
212
+ expect(pageMediaSigned(`pages/c1/a.r0.html`, [{ ...TAKE, mtimeMs: TAKE.mtimeMs + 1 }])).not.toBe(signed);
213
+ expect(pageMediaSigned(`pages/c1/a.r0.html`, [{ mtimeMs: TAKE.mtimeMs, size: TAKE.size, type: TAKE.type, path: TAKE.path }])).toBe(signed);
214
+ });
215
+
216
+ it("swaps each reference the manifest numbers for its address, leaving one past it alone", () => {
217
+ const html = `<video src="intentic-media:0"></video><script>const t=["intentic-media:0","intentic-media:1"]</script>`;
218
+ expect(placePageMedia(html, 1, (index) => `https://s/${index}`)).toBe(`<video src="https://s/0"></video><script>const t=["https://s/0","intentic-media:1"]</script>`);
219
+ });
220
+ });