@intentic/sandbox-contract 1.421.0 → 1.422.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 (74) hide show
  1. package/dist/contracts/ci.contract.d.ts +30 -0
  2. package/dist/contracts/ci.contract.d.ts.map +1 -1
  3. package/dist/contracts/ci.contract.js +10 -1
  4. package/dist/contracts/ci.contract.js.map +1 -1
  5. package/dist/contracts/device.contract.d.ts +46 -0
  6. package/dist/contracts/device.contract.d.ts.map +1 -1
  7. package/dist/contracts/device.contract.js +2 -0
  8. package/dist/contracts/device.contract.js.map +1 -1
  9. package/dist/contracts/offload.contract.d.ts +51 -0
  10. package/dist/contracts/offload.contract.d.ts.map +1 -1
  11. package/dist/contracts/offload.contract.js +3 -3
  12. package/dist/contracts/offload.contract.js.map +1 -1
  13. package/dist/contracts/runner.contract.d.ts +294 -246
  14. package/dist/contracts/runner.contract.d.ts.map +1 -1
  15. package/dist/events/requests.js +1 -1
  16. package/dist/events/requests.js.map +1 -1
  17. package/dist/models/account-moves.js +4 -4
  18. package/dist/models/account-moves.js.map +1 -1
  19. package/dist/models/plan-pools.d.ts +3 -1
  20. package/dist/models/plan-pools.d.ts.map +1 -1
  21. package/dist/models/plan-pools.js +26 -3
  22. package/dist/models/plan-pools.js.map +1 -1
  23. package/dist/protocol/doors/runner-protocol.d.ts +42 -0
  24. package/dist/protocol/doors/runner-protocol.d.ts.map +1 -1
  25. package/dist/protocol/doors/runner-protocol.js +23 -0
  26. package/dist/protocol/doors/runner-protocol.js.map +1 -1
  27. package/dist/protocol/raw/raw-json-routes.d.ts +4 -0
  28. package/dist/protocol/raw/raw-json-routes.d.ts.map +1 -1
  29. package/dist/protocol/raw/raw-routes.d.ts +8 -0
  30. package/dist/protocol/raw/raw-routes.d.ts.map +1 -1
  31. package/dist/protocol/raw/raw-routes.js +2 -0
  32. package/dist/protocol/raw/raw-routes.js.map +1 -1
  33. package/dist/schemas/ci.d.ts +69 -0
  34. package/dist/schemas/ci.d.ts.map +1 -1
  35. package/dist/schemas/ci.js +30 -0
  36. package/dist/schemas/ci.js.map +1 -1
  37. package/dist/schemas/device-files.d.ts +71 -0
  38. package/dist/schemas/device-files.d.ts.map +1 -0
  39. package/dist/schemas/device-files.js +53 -0
  40. package/dist/schemas/device-files.js.map +1 -0
  41. package/dist/schemas/devices.d.ts.map +1 -1
  42. package/dist/schemas/devices.js.map +1 -1
  43. package/dist/schemas/hosts.d.ts +3 -0
  44. package/dist/schemas/hosts.d.ts.map +1 -1
  45. package/dist/schemas/hosts.js +3 -0
  46. package/dist/schemas/hosts.js.map +1 -1
  47. package/dist/schemas/offload.d.ts +40 -0
  48. package/dist/schemas/offload.d.ts.map +1 -1
  49. package/dist/schemas/offload.js +21 -0
  50. package/dist/schemas/offload.js.map +1 -1
  51. package/dist/schemas/providers/plan-limits.d.ts +1 -0
  52. package/dist/schemas/providers/plan-limits.d.ts.map +1 -1
  53. package/dist/schemas/providers/plan-limits.js +5 -1
  54. package/dist/schemas/providers/plan-limits.js.map +1 -1
  55. package/dist/schemas/settings.js +1 -1
  56. package/dist/schemas/settings.js.map +1 -1
  57. package/package.json +5 -5
  58. package/src/contracts/ci.contract.ts +13 -0
  59. package/src/contracts/device.contract.ts +5 -0
  60. package/src/contracts/offload.contract.ts +3 -2
  61. package/src/events/requests.ts +1 -1
  62. package/src/models/account-moves.ts +6 -6
  63. package/src/models/plan-pools.test.ts +57 -20
  64. package/src/models/plan-pools.ts +48 -8
  65. package/src/protocol/doors/runner-protocol.ts +42 -2
  66. package/src/protocol/raw/raw-routes.ts +5 -0
  67. package/src/schemas/automations.ts +3 -3
  68. package/src/schemas/ci.ts +42 -0
  69. package/src/schemas/device-files.ts +90 -0
  70. package/src/schemas/devices.ts +5 -4
  71. package/src/schemas/hosts.ts +15 -3
  72. package/src/schemas/offload.ts +39 -2
  73. package/src/schemas/providers/plan-limits.ts +7 -1
  74. package/src/schemas/settings.ts +1 -1
@@ -13,7 +13,9 @@ import {
13
13
  refusalVerdict,
14
14
  refusedInstant,
15
15
  refusedPoolReset,
16
- roomiestAccount,
16
+ bestWithRoom,
17
+ NEARLY_OUT_ROOM,
18
+ renewalOf,
17
19
  scopedWindow,
18
20
  uncoveredModels,
19
21
  serviceState,
@@ -179,8 +181,8 @@ test("spent is the contract's one line: 99.5% still has room, 100% is spent unti
179
181
  test("a pool read at 100 in whole percents is at the line with no room, until a refusal proves it empty", () => {
180
182
  const week = window({ kind: "seven_day", utilization: 100, resetsAt: 900, rounded: true });
181
183
  const atLine = usage(window({ kind: "five_hour", utilization: 75, rounded: true }), week);
182
- expect(readingHeadroom(atLine)).toEqual({ kind: "ready", room: 0 });
183
- expect(readingHeadroom(atLine, { id: "claude-opus-5-5" })).toEqual({ kind: "ready", room: 0 });
184
+ expect(readingHeadroom(atLine)).toEqual({ kind: "ready", room: 0, renewsAt: 900 });
185
+ expect(readingHeadroom(atLine, { id: "claude-opus-5-5" })).toEqual({ kind: "ready", room: 0, renewsAt: 900 });
184
186
  // A precise 100 is still spent.
185
187
  expect(readingHeadroom(usage(window({ kind: "seven_day", utilization: 100, resetsAt: 900 })))).toEqual({ kind: "spent", reopensAt: 900 });
186
188
  // The provider refused it: spent until the pool reopens, and a reading still at the line does not answer that.
@@ -349,7 +351,7 @@ test("a spent allowance with no instant named is stamped with its pool's reset,
349
351
  const lapsed = at(500, window({ kind: "five_hour", utilization: 0, lapsedAt: reset }), window({ kind: "seven_day", utilization: 40, resetsAt: 900 }));
350
352
  expect(refusedPoolReset(spent, [{ account: "a", usage: lapsed }])).toBe(900);
351
353
  expect(refusalVerdict(filed, [{ account: "a", usage: lapsed }], reset * 1000)).toBe("answered");
352
- expect(serviceStates([{ account: "a", usage: lapsed }], [filed], undefined, reset * 1000).get("a")).toEqual({ kind: "ready", room: 60 });
354
+ expect(serviceStates([{ account: "a", usage: lapsed }], [filed], undefined, reset * 1000).get("a")).toEqual({ kind: "ready", room: 60, renewsAt: 900 });
353
355
  });
354
356
 
355
357
  // 2026-10-21: Claude refused at 5h 98% and weekly 97% (rounded) with no time named, so the refusal was stamped with the
@@ -378,7 +380,7 @@ test("a stamped reset ends a refusal only where no reading since it says the poo
378
380
  expect(serviceStates([{ account: "a", usage: weeklyFull }], [stamped], undefined, now).get("a")).toEqual(unstampedVerdict);
379
381
  expect(fleetCapacity([{ account: "a", usage: weeklyFull }], [stamped], undefined, now)).toMatchObject({ kind: "spent", reopensAt: weeklyReset });
380
382
  // Nothing read since the stamp: it ends there. Read with room since: over.
381
- expect(serviceStates([{ account: "a", usage: refusedIn }], [stamped], undefined, now).get("a")).toEqual({ kind: "ready", room: 2 });
383
+ expect(serviceStates([{ account: "a", usage: refusedIn }], [stamped], undefined, now).get("a")).toEqual({ kind: "ready", room: 2, renewsAt: weeklyReset });
382
384
  const roomSince = at((fiveHourReset + 600) * 1000, window({ kind: "five_hour", utilization: 4, resetsAt: fiveHourReset + 18_000 }), window({ kind: "seven_day", utilization: 60, resetsAt: weeklyReset }));
383
385
  expect(refusalVerdict(stamped, [{ account: "a", usage: roomSince }], now)).toBe("answered");
384
386
  });
@@ -436,9 +438,9 @@ test("each account answers to the newest refusal on file that still stands over
436
438
  b: { kind: "blocked", fix: "reconnect", reason: "no." },
437
439
  });
438
440
  // Only the provider's last one: the first account is back at the line, no room but not proven spent.
439
- expect(serviceStates(accounts, [elsewhere], undefined, 9_999).get("a")).toEqual({ kind: "ready", room: 0 });
441
+ expect(serviceStates(accounts, [elsewhere], undefined, 9_999).get("a")).toEqual({ kind: "ready", room: 0, renewsAt: 20 });
440
442
  // Past the instant the provider named, its refusal is over and the reading speaks alone.
441
- expect(serviceStates(accounts, [elsewhere, own], undefined, 20_000).get("a")).toEqual({ kind: "ready", room: 0 });
443
+ expect(serviceStates(accounts, [elsewhere, own], undefined, 20_000).get("a")).toEqual({ kind: "ready", room: 0, renewsAt: 20 });
442
444
  // A newer refusal on the same account outranks the older one.
443
445
  const revoked = refusal({ kind: "auth", account: "a", at: 6_000 });
444
446
  expect(serviceStates(accounts, [own, revoked], undefined, 9_999).get("a")).toEqual({ kind: "blocked", fix: "reconnect", reason: "no." });
@@ -491,14 +493,14 @@ test("refusals naming their accounts hold a 31-account Google fleet steady acros
491
493
  expect(fleetCapacity(accounts, refused, flash, reread)).toMatchObject({ kind: "serving", serving: 2, accounts: 31 });
492
494
  const states = serviceStates(accounts, refused, opus, reread);
493
495
  expect(states.get("tried-0")).toEqual({ kind: "spent", reopensAt: opusBack, pool: "Claude and GPT models" });
494
- expect(states.get("svichita09")).toEqual({ kind: "ready", room: 100 });
496
+ expect(states.get("svichita09")).toEqual({ kind: "ready", room: 100, renewsAt: opusBack });
495
497
  }
496
498
  // The same refusal filed under no account is answered on each account by its own reading alone: the account with
497
499
  // room frees itself, never one whose reading since says nothing.
498
500
  const nameless = refusal({ kind: "limit", at: refusedAt, model: "claude-opus-4-6-thinking", resetsAt: opusBack });
499
501
  const onlyOneRead = fleet(refusedAt - 30_000).map((facts) => (facts.account === "svichita09" ? { ...facts, usage: pools(reread, 0, 19.42) } : facts));
500
502
  const states = serviceStates([...onlyOneRead, { account: "unread" }], [nameless], opus, reread);
501
- expect(states.get("svichita09")).toEqual({ kind: "ready", room: 100 });
503
+ expect(states.get("svichita09")).toEqual({ kind: "ready", room: 100, renewsAt: opusBack });
502
504
  expect(states.get("unread")).toMatchObject({ kind: "spent", reopensAt: opusBack });
503
505
  });
504
506
 
@@ -528,8 +530,43 @@ test("an unnamed turn takes the most room, then an unmeasured account, then a sp
528
530
  expect(preferredAccount([entry("seatless", blocked), entry("spent", { kind: "spent" })])?.id).toBe("spent");
529
531
  expect(preferredAccount([entry("seatless", blocked), entry("other", blocked)])?.id).toBe("seatless");
530
532
  expect(preferredAccount([entry("first", { kind: "ready", room: 60 }), entry("second", { kind: "ready", room: 60 })])?.id).toBe("first");
531
- expect(roomiestAccount([entry("seatless", blocked), entry("unread", { kind: "unknown" })])).toBeUndefined();
532
- expect(roomiestAccount([entry("low", { kind: "ready", room: 5 }), entry("high", { kind: "ready", room: 60 })])?.id).toBe("high");
533
+ expect(bestWithRoom([entry("seatless", blocked), entry("unread", { kind: "unknown" })])).toBeUndefined();
534
+ expect(bestWithRoom([entry("low", { kind: "ready", room: 5 }), entry("high", { kind: "ready", room: 60 })])?.id).toBe("high");
535
+ });
536
+
537
+ /* 2026-11-17: Claude's Ultra plan meters no five-hour window. One account had 70 weekly points left renewing in six days,
538
+ the other 40 renewing in ten hours, and the most-room pick spent the first while the second's reset unspent. */
539
+ test("between accounts with room, the one whose allowance renews first wins, unless it is nearly out", () => {
540
+ const entry = (id: string, state: AccountState) => ({ id, state });
541
+ const now = 1_800_000_000;
542
+ const later = entry("later", { kind: "ready", room: 70, renewsAt: now + 144 * 3_600 });
543
+ const sooner = entry("sooner", { kind: "ready", room: 40, renewsAt: now + 10 * 3_600 });
544
+ expect(preferredAccount([later, sooner])?.id).toBe("sooner");
545
+ expect(bestWithRoom([later, sooner])?.id).toBe("sooner");
546
+ // Nearly out, it ranks after every account with more, however soon it renews; among those, room decides.
547
+ const nearlyOut = entry("nearly-out", { kind: "ready", room: NEARLY_OUT_ROOM, renewsAt: now + 3_600 });
548
+ expect(preferredAccount([nearlyOut, later])?.id).toBe("later");
549
+ expect(preferredAccount([nearlyOut, entry("lower", { kind: "ready", room: 4, renewsAt: now })])?.id).toBe("nearly-out");
550
+ // A reset nobody published never outranks a known one; between two unknown, room decides as before.
551
+ expect(preferredAccount([entry("unknown", { kind: "ready", room: 90 }), sooner])?.id).toBe("sooner");
552
+ expect(preferredAccount([entry("a", { kind: "ready", room: 50 }), entry("b", { kind: "ready", room: 60 })])?.id).toBe("b");
553
+ // The same moment: room decides.
554
+ expect(preferredAccount([sooner, entry("roomier", { kind: "ready", room: 80, renewsAt: now + 10 * 3_600 })])?.id).toBe("roomier");
555
+ });
556
+
557
+ test("an allowance renews when the longest pool the turn spends resets, never when a five-hour one does", () => {
558
+ const now = 1_800_000_000;
559
+ const weekly = (utilization: number, resetsAt: number): UsageWindow => ({ kind: "seven_day", utilization, resetsAt, gates: "all" });
560
+ const fiveHour: UsageWindow = { kind: "five_hour", utilization: 90, resetsAt: now + 3_600, gates: "all" };
561
+ expect(renewalOf([fiveHour, weekly(40, now + 20 * 3_600)])).toBe(now + 20 * 3_600);
562
+ // Two weekly pools (the whole plan's and Opus's slice): the first of them to reset.
563
+ expect(renewalOf([weekly(40, now + 50 * 3_600), { ...weekly(10, now + 30 * 3_600), kind: "seven_day_opus", gates: { models: ["opus"] } }])).toBe(now + 30 * 3_600);
564
+ // The weekly pool has lapsed (its reset passed, nothing re-read it): what renews is unknown, not the five-hour reset.
565
+ expect(renewalOf([fiveHour, { kind: "seven_day", utilization: 0, gates: "all", lapsedAt: now }])).toBeUndefined();
566
+ // No pool names its length: the first to reset decides.
567
+ expect(renewalOf([{ kind: "pool:a", utilization: 10, resetsAt: now + 7_200, gates: "all" }, { kind: "pool:b", utilization: 10, resetsAt: now + 3_600, gates: "all" }])).toBe(now + 3_600);
568
+ // The verdict carries it, read off the pools still open.
569
+ expect(readingHeadroom({ windows: [fiveHour, weekly(40, now + 20 * 3_600)], measuredAt: now * 1000 })).toEqual({ kind: "ready", room: 10, renewsAt: now + 20 * 3_600 });
533
570
  });
534
571
 
535
572
  test("an account at the line is tried after an unmeasured one and before a spent one, and never a move's destination", () => {
@@ -539,8 +576,8 @@ test("an account at the line is tried after an unmeasured one and before a spent
539
576
  expect(preferredAccount([entry("line", atLine), entry("unread", { kind: "unknown" })])?.id).toBe("unread");
540
577
  expect(preferredAccount([entry("spent", { kind: "spent" }), entry("line", atLine)])?.id).toBe("line");
541
578
  // A move lands only on proven room: two accounts at the line would otherwise hand a refused turn back and forth.
542
- expect(roomiestAccount([entry("line", atLine), entry("spent", { kind: "spent" })])).toBeUndefined();
543
- expect(roomiestAccount([entry("line", atLine), entry("low", { kind: "ready", room: 2 })])?.id).toBe("low");
579
+ expect(bestWithRoom([entry("line", atLine), entry("spent", { kind: "spent" })])).toBeUndefined();
580
+ expect(bestWithRoom([entry("line", atLine), entry("low", { kind: "ready", room: 2 })])?.id).toBe("low");
544
581
  });
545
582
 
546
583
  // The 2026-10-27/28 account: switched off, served for an evening (most room on its reading), switched off again.
@@ -548,9 +585,9 @@ test("an account its organisation keeps switching off goes behind every steady o
548
585
  const entry = (id: string, state: AccountState, flapping?: boolean) => ({ id, state, flapping });
549
586
  const flapping = entry("flapping", { kind: "ready", room: 90 }, true);
550
587
  expect(preferredAccount([flapping, entry("steady", { kind: "ready", room: 5 })])?.id).toBe("steady");
551
- expect(roomiestAccount([flapping, entry("steady", { kind: "ready", room: 5 }, false)])?.id).toBe("steady");
588
+ expect(bestWithRoom([flapping, entry("steady", { kind: "ready", room: 5 }, false)])?.id).toBe("steady");
552
589
  expect(preferredAccount([flapping, entry("unread", { kind: "unknown" }), entry("line", { kind: "ready", room: 0 })])?.id).toBe("flapping");
553
- expect(roomiestAccount([flapping, entry("line", { kind: "ready", room: 0 })])?.id).toBe("flapping");
590
+ expect(bestWithRoom([flapping, entry("line", { kind: "ready", room: 0 })])?.id).toBe("flapping");
554
591
  // Among flapping accounts, room decides again.
555
592
  expect(preferredAccount([flapping, entry("roomier", { kind: "ready", room: 95 }, true)])?.id).toBe("roomier");
556
593
  expect(preferredAccount([entry("off", { kind: "unknown" }, true), entry("on", { kind: "unknown" })])?.id).toBe("on");
@@ -588,8 +625,8 @@ test("an account whose only named pools are full, with models no pool covers, is
588
625
  test("a reading contradicted by an answered turn holds that model's full pools at the line, not spent", () => {
589
626
  const full = usage(window({ kind: "google:gemini-weekly", utilization: 100, resetsAt: 9_000, gates: { models: ["gemini"] } }));
590
627
  const contradicted: AccountUsage = { ...full, contradicted: { at: 1, model: "gemini-3.8-flash-high" } };
591
- expect(readingHeadroom(contradicted, { id: "gemini-3.8-flash-high" })).toEqual({ kind: "ready", room: 0 });
592
- expect(readingHeadroom(contradicted)).toEqual({ kind: "ready", room: 0 });
628
+ expect(readingHeadroom(contradicted, { id: "gemini-3.8-flash-high" })).toEqual({ kind: "ready", room: 0, renewsAt: 9_000 });
629
+ expect(readingHeadroom(contradicted)).toEqual({ kind: "ready", room: 0, renewsAt: 9_000 });
593
630
  // Another family's pool is not what the turn proved anything about.
594
631
  const other: AccountUsage = { ...full, contradicted: { at: 1, model: "claude-opus-4-6-thinking" } };
595
632
  expect(readingHeadroom(other, { id: "gemini-3.8-flash-high" })).toEqual({ kind: "spent", reopensAt: 9_000 });
@@ -645,7 +682,7 @@ test("a refusal's instant is judged against the pools a reading since publishes:
645
682
  const renewed = codex(Math.floor(now / 1000) + 6 * DAY);
646
683
  expect(refusedInstant(sol, renewed)).toBe("renewed");
647
684
  expect(refusalVerdict(sol, [{ account: "a", usage: renewed }], now)).toBe("answered");
648
- expect(serviceStates([{ account: "a", usage: renewed }], [sol], { id: "gpt-6.1-sol" }, now).get("a")).toEqual({ kind: "ready", room: 64 });
685
+ expect(serviceStates([{ account: "a", usage: renewed }], [sol], { id: "gpt-6.1-sol" }, now).get("a")).toEqual({ kind: "ready", room: 64, renewsAt: Math.floor(now / 1000) + 6 * DAY });
649
686
  // Renewed but already spent again: still held, by the window itself.
650
687
  expect(refusedInstant(sol, codex(Math.floor(now / 1000) + 6 * DAY, 100))).toBe("unpublished");
651
688
 
@@ -655,8 +692,8 @@ test("a refusal's instant is judged against the pools a reading since publishes:
655
692
  expect(refusedInstant(sol, unnamed)).toBe("unpublished");
656
693
  expect(refusalVerdict(sol, [{ account: "a", usage: unnamed }], now)).toBe("standing");
657
694
  expect(serviceState({ account: "a", usage: unnamed }, [sol], { id: "gpt-6.1-sol" }, now)).toEqual({ kind: "spent", reopensAt: instant, pool: "GPT 6.1 Sol" });
658
- expect(serviceState({ account: "a", usage: unnamed }, [sol], { id: "gpt-6-luna" }, now)).toEqual({ kind: "ready", room: 64 });
659
- expect(serviceState({ account: "a", usage: unnamed }, [sol], undefined, now)).toEqual({ kind: "ready", room: 64 });
695
+ expect(serviceState({ account: "a", usage: unnamed }, [sol], { id: "gpt-6-luna" }, now)).toEqual({ kind: "ready", room: 64, renewsAt: Math.floor(filed / 1000) + 5 * DAY });
696
+ expect(serviceState({ account: "a", usage: unnamed }, [sol], undefined, now)).toEqual({ kind: "ready", room: 64, renewsAt: Math.floor(filed / 1000) + 5 * DAY });
660
697
 
661
698
  // Nothing read since the refusal, or a pool with no reset to judge by: the instant outranks, on the pool the model spends.
662
699
  expect(refusedInstant(sol, { ...unnamed, measuredAt: filed - 1 })).toBe("unjudged");
@@ -109,6 +109,21 @@ const holdingPools = (full: readonly UsageWindow[], open: readonly UsageWindow[]
109
109
  return open.length === 0 ? full : [];
110
110
  };
111
111
 
112
+ /* WHEN AN ACCOUNT'S ALLOWANCE RENEWS, which is what a pick between accounts with room weighs first (preferredAccount).
113
+ What is left of a pool when it resets is gone: on 2026-11-17, with Claude's Ultra plan metering no five-hour window,
114
+ the pick kept every turn on the account with the most weekly room, resetting six days out, while another account's
115
+ 40% reset unspent ten hours later. The pool that decides is the longest the turn spends, since a shorter one refills
116
+ within the day whichever account is picked; among several of that length (Claude's weekly pool beside its weekly Opus
117
+ slice), the first to reset. Undefined where those publish no reset, or no pool names its length and none resets. */
118
+ export const renewalOf = (windows: readonly UsageWindow[]): number | undefined => {
119
+ const periods = windows.map((window) => windowPeriod(window)?.seconds);
120
+ const known = periods.filter((seconds) => seconds !== undefined);
121
+ const longest = known.length === 0 ? undefined : Math.max(...known);
122
+ const deciding = longest === undefined ? windows : windows.filter((_, index) => periods[index] === longest);
123
+ const resets = deciding.flatMap((window) => (window.resetsAt === undefined ? [] : [window.resetsAt]));
124
+ return resets.length === 0 ? undefined : Math.min(...resets);
125
+ };
126
+
112
127
  /**
113
128
  * What a reading says, at the contract's one spent line, never whether the account can serve: that is `serviceStates`,
114
129
  * which first lays every standing refusal on the reading (judgedReading). A provider that rounds its percentages (Claude
@@ -129,7 +144,9 @@ export const readingHeadroom = (usage: AccountUsage | undefined, model?: ModelRe
129
144
  const open = windows.filter((window) => !provenFull(window));
130
145
  const holding = holdingPools(full, open, model);
131
146
  if (holding.length === 0) {
132
- return { kind: "ready", room: Math.max(0, SPENT_UTILIZATION - Math.max(...open.map((window) => window.utilization))) };
147
+ const room = Math.max(0, SPENT_UTILIZATION - Math.max(...open.map((window) => window.utilization)));
148
+ const renewsAt = renewalOf(open);
149
+ return renewsAt === undefined ? { kind: "ready", room } : { kind: "ready", room, renewsAt };
133
150
  }
134
151
  const sliced = model === undefined && !holding.some((window) => window.gates === "all");
135
152
  // Every per-model slice this reading names is full, but it names none for some models the account serves: whether
@@ -361,20 +378,43 @@ const ranksAbove = (next: RankedAccount, best: RankedAccount): boolean => {
361
378
  if ((next.flapping === true) !== (best.flapping === true)) {
362
379
  return best.flapping === true;
363
380
  }
364
- return next.state.kind === "ready" && best.state.kind === "ready" && next.state.room > best.state.room;
381
+ return next.state.kind === "ready" && best.state.kind === "ready" && readyAbove(next.state, best.state);
382
+ };
383
+
384
+ /** Room at or below this, in points of the fullest pool, is an account nearly out: it ranks after every one with more. */
385
+ export const NEARLY_OUT_ROOM = 10;
386
+
387
+ /* BETWEEN TWO ACCOUNTS WITH ROOM, THE ONE WHOSE ALLOWANCE RENEWS FIRST (renewalOf), unless it is nearly out. Points left
388
+ in a pool at its reset are lost, so spending the pool that resets first wastes the least of what the plans pay for,
389
+ and the later one is still there when the first has renewed. Most room decides only between accounts renewing at the
390
+ same moment, between accounts no reset is known for, and among accounts nearly out, where room is what keeps the next
391
+ turn from being refused. This reads no load: the daemon's own Claude pick (budget-planner.ts pickAccount) orders the
392
+ same way among the accounts its projection says carry the turn with what already runs on them. */
393
+ const readyAbove = (next: AccountState & { kind: "ready" }, best: AccountState & { kind: "ready" }): boolean => {
394
+ const nextOpen = next.room > NEARLY_OUT_ROOM;
395
+ if (nextOpen !== best.room > NEARLY_OUT_ROOM) {
396
+ return nextOpen;
397
+ }
398
+ const nextRenews = next.renewsAt ?? Number.POSITIVE_INFINITY;
399
+ const bestRenews = best.renewsAt ?? Number.POSITIVE_INFINITY;
400
+ if (nextOpen && nextRenews !== bestRenews) {
401
+ return nextRenews < bestRenews;
402
+ }
403
+ return next.room > best.room;
365
404
  };
366
405
 
367
406
  /**
368
- * The account an unnamed turn runs on: ready by most room, then unmeasured, then at the line, then spent, blocked only
369
- * when that is all there is; within each, a flapping account after the steady ones. Ties keep the caller's order.
407
+ * The account an unnamed turn runs on: ready, then unmeasured, then at the line, then spent, blocked only when that is
408
+ * all there is; within each, a flapping account after the steady ones; among ready ones, the first to renew of those not
409
+ * nearly out, then the most room (readyAbove). Ties keep the caller's order.
370
410
  */
371
411
  export const preferredAccount = <T extends RankedAccount>(entries: readonly T[]): T | undefined =>
372
412
  entries.reduce<T | undefined>((best, next) => (best === undefined || ranksAbove(next, best) ? next : best), undefined);
373
413
 
374
414
  /**
375
- * The roomiest account with proven room, or none: what a move off a refused account may land on. Ties keep the caller's
376
- * order. An account at the line is left out: a move there could be refused in turn, and two such accounts would hand the
377
- * turn back and forth.
415
+ * The best account with proven room, by the same order, or none: what a move off a refused account may land on. Ties keep
416
+ * the caller's order. An account at the line is left out: a move there could be refused in turn, and two such accounts
417
+ * would hand the turn back and forth.
378
418
  */
379
- export const roomiestAccount = <T extends RankedAccount>(entries: readonly T[]): T | undefined =>
419
+ export const bestWithRoom = <T extends RankedAccount>(entries: readonly T[]): T | undefined =>
380
420
  preferredAccount(entries.filter((entry) => entry.state.kind === "ready" && entry.state.room > 0));
@@ -173,6 +173,9 @@ export const RunnerFactsSchema = z.object({
173
173
  // Absent where the kernel does not report it.
174
174
  cpuPressure: z.number().nonnegative().optional(),
175
175
  memoryStall: z.number().nonnegative().optional(),
176
+ // The GPUs a program there can use (passed through to the container), by name and memory; empty where there is none,
177
+ // absent from a runner that predates the question. What a heavy command that needs one is placed by.
178
+ gpus: z.array(z.object({ name: z.string(), memoryMb: z.number().int().nonnegative() })).optional(),
176
179
  });
177
180
  export type RunnerFacts = z.infer<typeof RunnerFactsSchema>;
178
181
 
@@ -291,6 +294,18 @@ export const OFFLOAD_REF_PREFIX = "refs/intentic-offload/";
291
294
  export const offloadRef = (runId: string): string => `${OFFLOAD_REF_PREFIX}${runId}`;
292
295
  const OffloadRunIdSchema = z.string().regex(/^[a-z0-9][a-z0-9-]{7,63}$/u);
293
296
  const EnvNameSchema = z.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u);
297
+ const Sha256Schema = z.string().regex(/^[0-9a-f]{64}$/u);
298
+
299
+ // A path an offloaded line makes that its caller needs back besides edits: a binary it built, a picture it rendered.
300
+ // Repo-relative, ignored paths included (`target/debug/integra`), or absolute under /tmp; a directory brings back every
301
+ // file under it. Never anywhere else on the runner, and never out of the repo by `..`.
302
+ export const OffloadOutputPathSchema = z
303
+ .string()
304
+ .min(1)
305
+ .max(1024)
306
+ .refine((path) => !path.split("/").includes(".."), "must not climb out by ..")
307
+ .refine((path) => !path.startsWith("/") || path.startsWith("/tmp/"), "an absolute output must be under /tmp/");
308
+ export const isTmpOutput = (path: string): boolean => path.startsWith("/tmp/");
294
309
 
295
310
  export const RunnerCommandSchema = z.object({
296
311
  runId: OffloadRunIdSchema,
@@ -306,6 +321,11 @@ export const RunnerCommandSchema = z.object({
306
321
  // Variables the line writes a file to (a report path): the runner points each at a scratch file and hands the file
307
322
  // back with the exit.
308
323
  exports: z.array(EnvNameSchema).max(8).default([]),
324
+ // Paths the line makes that come back whole, as `file` frames before the exit (OffloadOutputPathSchema).
325
+ outputs: z.array(OffloadOutputPathSchema).max(16).default([]),
326
+ // What the caller already holds at an output path (a directory's files by their own paths), by sha256: a file the
327
+ // same byte for byte is said, not sent.
328
+ have: z.record(z.string(), Sha256Schema).default({}),
309
329
  // The heavy-command rule it matched here, named in the runner's own output and queue.
310
330
  label: z.string().min(1).max(80),
311
331
  timeoutMs: z
@@ -317,12 +337,25 @@ export const RunnerCommandSchema = z.object({
317
337
  });
318
338
  export type RunnerCommand = z.infer<typeof RunnerCommandSchema>;
319
339
 
340
+ // One output file coming back, in pieces sent in order: each `data` is one gzip member of the next bytes, base64, and
341
+ // the last piece carries `end` with the whole file's size, mode and sha256, which the caller checks before it puts the
342
+ // file in place. `same` instead of data says the caller already holds it byte for byte.
343
+ export const RunnerFileFrameSchema = z.object({
344
+ kind: z.literal("file"),
345
+ path: z.string().min(1),
346
+ data: z.string().optional(),
347
+ end: z.object({ size: z.number().int().nonnegative(), mode: z.number().int().nonnegative(), sha256: Sha256Schema }).optional(),
348
+ same: z.boolean().optional(),
349
+ });
350
+ export type RunnerFileFrame = z.infer<typeof RunnerFileFrameSchema>;
351
+
320
352
  // What a running command streams back: narration of the runner's own steps (fetch, install, queue), the line's output
321
- // as it comes, and last its end: the exit, every file it changed as a binary git patch against the snapshot, and the
322
- // exported files, base64.
353
+ // as it comes, the output files asked for, and last its end: the exit, every file it changed as a binary git patch
354
+ // against the snapshot, and the exported files, base64.
323
355
  export const RunnerCommandFrameSchema = z.union([
324
356
  z.object({ kind: z.literal("status"), text: z.string() }),
325
357
  z.object({ kind: z.literal("output"), stream: z.enum(["stdout", "stderr"]), text: z.string() }),
358
+ RunnerFileFrameSchema,
326
359
  z.object({
327
360
  kind: z.literal("exit"),
328
361
  code: z.number().int(),
@@ -333,6 +366,13 @@ export const RunnerCommandFrameSchema = z.union([
333
366
  ran: z.boolean().default(true),
334
367
  patchBase64: z.string().optional(),
335
368
  files: z.record(EnvNameSchema, z.string()).default({}),
369
+ // How heavy the line was there, for the parent's command profiles (offload/command-profiles.ts): the most
370
+ // memory everything it started held at once, and how long it ran. Absent where the runner could not measure.
371
+ peakMemoryMb: z.number().int().nonnegative().optional(),
372
+ durationMs: z.number().int().nonnegative().optional(),
373
+ // Outputs asked for that the line never made, and ones too big to bring back.
374
+ missing: z.array(z.string()).optional(),
375
+ tooBig: z.array(z.string()).optional(),
336
376
  }),
337
377
  ]);
338
378
  export type RunnerCommandFrame = z.infer<typeof RunnerCommandFrameSchema>;
@@ -180,6 +180,11 @@ export const RAW_ROUTES = {
180
180
  // The `devices push` CLI: a program the agent built, carried to one of the owner's computers in chunks; held to the
181
181
  // devices the calling conversation's turn mounts, and refused by the machine itself unless "Run programs" is on.
182
182
  "POST /devices/{name}/artifacts": { agent: true, control: "never" },
183
+ // The `devices copy` CLI: a file or a folder carried to a path on one of the owner's computers, or back off it, in
184
+ // chunks (hosts/device-files.routes.ts); held to the same rule, and the machine holds each chunk to its folders and,
185
+ // onto it, its "Create and change files" switch.
186
+ "POST /devices/{name}/files": { agent: true, control: "never" },
187
+ "GET /devices/{name}/files": { agent: true, control: "never" },
183
188
  // The rest of the `devices` command, held to the same rule (hosts/device-door.routes.ts): the device's app_start for a
184
189
  // shell, and its loopback ports reached from the sandbox (hosts/device-tunnels.ts).
185
190
  "POST /devices/{name}/apps": { agent: true, control: "never" },
@@ -397,9 +397,9 @@ export const AutomationSchema = z.object({
397
397
  "Which models this automation may run on, best first. Required when it starts a new agent, and nothing is chosen for you: work that fires while nobody is watching spends a real allowance, so it names the models it spends rather than inheriting one. Tried in order, so a spent account does not silently stop the job. Not needed to continue a conversation, which runs on its own model, or to only notify.",
398
398
  ),
399
399
  // Absent means the daemon's pick: the account its conversation runs on for a continuing thread (moved off one that
400
- // can no longer serve), else the one that can serve with the most room. Named, it is a pin, run whatever its state,
401
- // so a refused account says so rather than being swapped; pinning matters more here than for a chat, since nobody
402
- // is watching to notice a stuck one.
400
+ // can no longer serve), else the sandbox's pick among those that can serve (the first to renew unless nearly out).
401
+ // Named, it is a pin, run whatever its state, so a refused account says so rather than being swapped; pinning
402
+ // matters more here than for a chat, since nobody is watching to notice a stuck one.
403
403
  account: z.string().optional().describe("Which account pays for it."),
404
404
  // Absent means the wake reaches no logged-in account at all, the strictest default here, since nobody is at the
405
405
  // composer when it fires. Posture only: what the wake may reach is `runAs`'s (docs/architecture/access.md).
package/src/schemas/ci.ts CHANGED
@@ -265,6 +265,48 @@ export const CiRunsResponseSchema = z.object({
265
265
  ),
266
266
  });
267
267
  export type CiRunsResponse = z.infer<typeof CiRunsResponseSchema>;
268
+ // 2026-11-17, the shinobi-society audit: conversation after conversation spent calls finding out whether a test that
269
+ // failed for it was its own or already failing on main (stashing its work, re-running main, comparing), while the daemon
270
+ // had already read every failed main-line job's log. `GET /ci/main` (`agents ci`) answers from what it heard, asking no
271
+ // forge: each job failing on a main line, the run and commit it last failed in, when that was read, and what its log
272
+ // named. A main line nothing is known of says so, so silence never reads as a passing main.
273
+ export const CiMainJobSchema = z.object({
274
+ workflow: z.string().describe("The workflow it is a job of, by the forge's name. `ci` on a forge that runs one pipeline per commit."),
275
+ job: z.string().describe("The job, by name."),
276
+ runId: z.number().optional().describe("The run it last failed in. Absent for a failure heard before the daemon kept it."),
277
+ sha: z.string().optional().describe("That run's commit, where the forge said."),
278
+ readAt: z.number().optional().describe("When the daemon read that failure, in milliseconds."),
279
+ errors: z
280
+ .array(z.string())
281
+ .optional()
282
+ .describe(
283
+ "What its failed steps printed, one line each and bounded: failing tests by name (`(fail) …`, `test … FAILED`), type and lint errors, failed checks, and how a task ended (a signal's exit code, a heap run out). Empty when its log named nothing of the kind; absent when the log was not read.",
284
+ ),
285
+ timedOut: z.boolean().optional().describe("Whether it failed by running out of time. Absent when it did not."),
286
+ });
287
+ export type CiMainJob = z.infer<typeof CiMainJobSchema>;
288
+ export const CiMainBranchSchema = z.object({
289
+ repo: z.string().describe("Which workspace repository."),
290
+ branch: z.string().optional().describe("Its main line. Absent when neither the forge nor the clone named a default branch and no run of one was heard."),
291
+ state: z
292
+ .enum(["failing", "clear", "unread"])
293
+ .describe(
294
+ "`failing`: the jobs below fail on it now. `clear`: a finished run of it was heard and no job of main's own code is known to fail. `unread`: no finished run of it has been heard, so nothing is known.",
295
+ ),
296
+ since: z.number().optional().describe("When its first job failed, on a failing one, in milliseconds."),
297
+ jobs: z.array(CiMainJobSchema).describe("The jobs failing on it now, in the order they began failing. Empty unless it is failing."),
298
+ lastRun: z
299
+ .object({ status: z.enum(["success", "failed"]), at: z.number() })
300
+ .optional()
301
+ .describe("The newest finished run of it the daemon heard, any workflow: how it ended and when it was heard. Absent when none was."),
302
+ fixer: z.string().optional().describe("The fix agent on its failure, when one is."),
303
+ });
304
+ export type CiMainBranch = z.infer<typeof CiMainBranchSchema>;
305
+ export const CiMainResponseSchema = z.object({
306
+ text: z.string().describe("The whole answer in words, as `agents ci` prints it."),
307
+ branches: z.array(CiMainBranchSchema).describe("Each repository wired to CI, and any main line still failing in one no longer wired."),
308
+ });
309
+ export type CiMainResponse = z.infer<typeof CiMainResponseSchema>;
268
310
  // Re-resolves repo → project + token on every call, so a stale card can't act on a mapping the workspace no longer has.
269
311
  export const CiRunParamSchema = z.object({
270
312
  repo: z
@@ -0,0 +1,90 @@
1
+ import { z } from "zod";
2
+ import { ARTIFACT_CHUNK_BYTES } from "./device-artifacts.js";
3
+
4
+ // A FILE OR A FOLDER COPIED BETWEEN THIS SANDBOX AND A CONNECTED COMPUTER (`devices copy`), either way, to a path the
5
+ // agent names. 2026-11-17, the shinobi-society audit: to move a 12 MB tarball or a built binary, agents ran `docker exec …
6
+ // && docker cp …` on rog through run_command, which works only where the sandbox's own container is on that very machine,
7
+ // needs its container name, and passes every guard by. read_file and write_file carry text alone, through the model.
8
+ // The CLI reads and writes the bytes in the agent's own shell (its view of /work), the daemon relays them over the device
9
+ // link in chunks through `copyFile`, and the machine checks every chunk against the same rules as its file tools: the
10
+ // folders it may touch for both ways, and "Create and change files" (`write`) for a copy onto it.
11
+
12
+ // One chunk's decoded size: the artifact push's, which a tunnel already carries.
13
+ export const FILE_COPY_CHUNK_BYTES = ARTIFACT_CHUNK_BYTES;
14
+ // The most one copy carries, decoded: a thousand chunks, minutes on a good link. Anything bigger is a disk image or a
15
+ // backup, which a command on the computer moves better than a relay through the sandbox.
16
+ export const FILE_COPY_MAX_BYTES = 2 * 1024 * 1024 * 1024;
17
+ // How long packing or unpacking a folder may take on the computer; the daemon waits that plus the device's answer.
18
+ export const FILE_COPY_TAR_TIMEOUT_MS = 10 * 60_000;
19
+
20
+ const Sha256Schema = z.string().regex(/^[0-9a-f]{64}$/, "a lowercase hex sha256");
21
+ const CopyIdSchema = z.string().regex(/^[0-9a-f]{32}$/);
22
+ // A path on the computer as the agent wrote it; the machine resolves it, links and all, against its folders.
23
+ const DevicePathSchema = z.string().min(1).max(4096);
24
+ // The source's own name, which a copy into a folder that exists lands under: one path segment, never `.` or `..`.
25
+ export const CopyNameSchema = z
26
+ .string()
27
+ .min(1)
28
+ .max(255)
29
+ .refine((name) => !/[/\\\0]/.test(name) && name !== "." && name !== "..", "a plain file or folder name");
30
+ // `file` is one file; `tar` a folder, packed by whichever side holds it and unpacked by the other.
31
+ export const CopyKindSchema = z.enum(["file", "tar"]);
32
+ export type CopyKind = z.infer<typeof CopyKindSchema>;
33
+ const ChunkDataSchema = z.string().max(Math.ceil(FILE_COPY_CHUNK_BYTES / 3) * 4);
34
+
35
+ export const CopyFileSchema = z.discriminatedUnion("op", [
36
+ // Onto the computer: where it will land (`path`, or `path/name` when `path` is a folder that exists), refused when
37
+ // that is taken unless `overwrite`. `executable` carries the sandbox file's x bit to a POSIX computer. `probe` asks
38
+ // every question and opens nothing, so a refusal is read before the first byte is sent.
39
+ z
40
+ .object({
41
+ op: z.literal("put-open"),
42
+ copy: CopyIdSchema,
43
+ path: DevicePathSchema,
44
+ name: CopyNameSchema,
45
+ kind: CopyKindSchema,
46
+ size: z.int().nonnegative().max(FILE_COPY_MAX_BYTES),
47
+ overwrite: z.boolean(),
48
+ executable: z.boolean(),
49
+ probe: z.boolean().optional(),
50
+ })
51
+ .strict(),
52
+ // One piece, at its offset; pieces arrive in order and a gap is refused.
53
+ z.object({ op: z.literal("put-chunk"), copy: CopyIdSchema, offset: z.int().nonnegative(), data: ChunkDataSchema }).strict(),
54
+ // The last word: the machine checks size and hash, then puts it in place. A mismatch throws the copy away.
55
+ z.object({ op: z.literal("put-commit"), copy: CopyIdSchema, sha256: Sha256Schema }).strict(),
56
+ // Off the computer: a file as it is, a folder packed as one tar first.
57
+ z.object({ op: z.literal("get-open"), copy: CopyIdSchema, path: DevicePathSchema }).strict(),
58
+ // The piece at `offset`, in order.
59
+ z.object({ op: z.literal("get-chunk"), copy: CopyIdSchema, offset: z.int().nonnegative() }).strict(),
60
+ // A copy finished or given up on: a put's part file is deleted, a get's handle and packed tar let go.
61
+ z.object({ op: z.literal("close"), copy: CopyIdSchema }).strict(),
62
+ ]);
63
+ export type CopyFile = z.infer<typeof CopyFileSchema>;
64
+
65
+ export const CopyFileResultSchema = z.object({
66
+ // Where it is on the computer: where a put lands or landed, what a get reads.
67
+ path: z.string().optional(),
68
+ // A get-open's: what is coming, how big, under what name, and whether a POSIX computer has it executable.
69
+ kind: CopyKindSchema.optional(),
70
+ size: z.int().nonnegative().optional(),
71
+ name: z.string().optional(),
72
+ executable: z.boolean().optional(),
73
+ // How many bytes of a put the machine holds, answered to every put-chunk.
74
+ received: z.int().nonnegative().optional(),
75
+ // A get-chunk's bytes, base64.
76
+ data: ChunkDataSchema.optional(),
77
+ // On a get's last chunk: the hash of everything it served, which the daemon checks what it relayed against.
78
+ sha256: Sha256Schema.optional(),
79
+ });
80
+ export type CopyFileResult = z.infer<typeof CopyFileResultSchema>;
81
+
82
+ // What `POST /devices/{name}/files` answers the CLI; a GET answers the bytes, with these in `x-intentic-copy-*` headers.
83
+ export const CopiedFileSchema = z.object({
84
+ device: z.string(),
85
+ path: z.string(),
86
+ kind: CopyKindSchema,
87
+ size: z.int().nonnegative(),
88
+ sha256: Sha256Schema,
89
+ });
90
+ export type CopiedFile = z.infer<typeof CopiedFileSchema>;
@@ -209,10 +209,11 @@ export const DeviceFlowLineSchema = z.discriminatedUnion("kind", [
209
209
  export type DeviceFlowLine = z.infer<typeof DeviceFlowLineSchema>;
210
210
  // Every op stops the resident process mid-command; a stream ending with no terminal frame is normal, not a failure, and
211
211
  // confirmation is the version moving on the next poll. `restart` is just a bare `intentic-machine run`.
212
- // `forget-unreachable` drops the machine's links to sandboxes that have answered nothing for long enough to be gone
213
- // (peer-dial's LONG_OUTAGE_ATTEMPTS) — never the link carrying the request, which is by definition answering. Never
214
- // automatic either: a laptop closed for a fortnight must find its sandboxes again, so nothing expires on its own and
215
- // dropping one is always somebody's decision.
212
+ // `forget-unreachable` drops the machine's links to sandboxes the platform has said no longer exist (the edge's final
213
+ // `unknown-sandbox`, which the machine's link marks as `goneSince`) — never one that is merely down, since it is offered
214
+ // on every sandbox's page and a sibling restarting or asleep must keep this machine, and never the link carrying the
215
+ // request, which is by definition answering. Before 2026-11-17 it took any link that had failed twenty dials (about
216
+ // eight minutes), and one sandbox's button disconnected the machine from another.
216
217
  export const DeviceAgentOpSchema = z.enum(["upgrade", "restart", "forget-unreachable"]);
217
218
  export type DeviceAgentOp = z.infer<typeof DeviceAgentOpSchema>;
218
219
  export const DeviceAgentFlowSchema = z.strictObject({ op: DeviceAgentOpSchema });
@@ -76,9 +76,11 @@ export const DeviceFactsSchema = z.object({
76
76
  wsl: WslEnvironmentSchema.optional(),
77
77
  // Windows only: the distros `wsl -l -q` lists, the names `run_command`'s `in: "wsl:<name>"` accepts.
78
78
  wslDistros: z.array(z.string()).optional(),
79
- // What this machine's agent is holding links to, and how much of it is answering nothing. COUNTS AND AN AGE ONLY:
80
- // the rest are other sandboxes' addresses, and a sandbox has no business learning its siblings'. Absent from an
81
- // agent older than this field, which is why "none unreachable" is not the same value as "did not say".
79
+ // What this machine's agent is holding links to, and how many of them are to sandboxes the platform has said no
80
+ // longer exist (since 2026-11-17; before, any link that had failed twenty dials, a sandbox merely down included).
81
+ // COUNTS AND AN AGE ONLY: the rest are other sandboxes' addresses, and a sandbox has no business learning its
82
+ // siblings'. Absent from an agent older than this field, which is why "none unreachable" is not the same value as
83
+ // "did not say".
82
84
  links: z.object({ total: z.number(), unreachable: z.number(), unreachableSince: z.number().optional() }).optional(),
83
85
  // Which of the optional ops this agent AND the `ic` it drives implement (DeviceFeatureSchema), for a page to offer
84
86
  // only what works and for the daemon to refuse an op before sending it. Strings on the wire, so a newer agent's
@@ -192,6 +194,9 @@ export const DeviceFeatureSchema = z.enum([
192
194
  // (2026-11-11) The `move-prepare`, `move-out` and `move-in` ops: an agent that has them driving an ic that says
193
195
  // `sandbox-move` (`ic sandbox move-out` / `move-in`), so a sandbox can be carried to another of the owner's computers.
194
196
  "sandbox-move",
197
+ // (2026-11-17) `copyFile`: a file or a folder copied to or from a path the agent names (`devices copy`), held to the
198
+ // folders and the write switch the file tools are.
199
+ "file-copy",
195
200
  ]);
196
201
  export type DeviceFeature = z.infer<typeof DeviceFeatureSchema>;
197
202
  export const DEVICE_FEATURE_RESHAPE_LATER: DeviceFeature = "reshape-later";
@@ -207,6 +212,7 @@ export const DEVICE_FEATURE_EGRESS: DeviceFeature = "egress";
207
212
  export const DEVICE_FEATURE_REACHABLE_WAYS_BACK: DeviceFeature = "reachable-ways-back";
208
213
  export const DEVICE_FEATURE_REACH_NETWORK: DeviceFeature = "reach-network";
209
214
  export const DEVICE_FEATURE_SANDBOX_MOVE: DeviceFeature = "sandbox-move";
215
+ export const DEVICE_FEATURE_FILE_COPY: DeviceFeature = "file-copy";
210
216
  // What `ic features --json` answers (_sandbox/ic/src/features.rs, golden/ic-features.json): the optional ops that ic
211
217
  // implements, as strings, since a newer ic's word means nothing to an older agent.
212
218
  export const IcFeaturesAnswerSchema = z.object({ features: z.array(z.string()) });
@@ -245,6 +251,12 @@ export const windowsPathOf = (distro: string, linuxPath: string): string => `\\\
245
251
  // own — but the owner connected a computer, not a shell, so the grant, the row and the tools are the machine's.
246
252
  export const HOST_NATIVE_ENVIRONMENT = "native";
247
253
 
254
+ // What a device card's status says of a machine that is paired and holds no socket right now (the device handler's
255
+ // `awayHint`, beside a `pending` state). Shared so the editor can read it as offline, which waits on the machine, rather
256
+ // than as a setup to finish, which a fresh pairing would: a machine whose sandbox had restarted read "needs setup" with a
257
+ // Connect button beside it (2026-11-17).
258
+ export const DEVICE_AWAY_DETAIL = "the device is offline";
259
+
248
260
  // Which environment a machine is describing when it connects: the distro by the name WSL registered (what `wsl -l -q`
249
261
  // prints and `in: "wsl:<name>"` takes), or the metal. Facts arrive at connect and no scope withholds them, so this is
250
262
  // always answerable — unlike `environmentOf` (devices.ts), which weighs a report too and may hold no evidence at all.