@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
@@ -18,9 +18,30 @@ export const OffloadTargetSchema = z.object({
18
18
  });
19
19
  export type OffloadTarget = z.infer<typeof OffloadTargetSchema>;
20
20
 
21
+ // What a line needs of the machine it runs on, said by whoever starts it (`remote-run --needs mem=12G,gpu`); the
22
+ // daemon adds what the line's own profile measured (offload/command-profiles.ts). A machine short of it is never picked.
23
+ export const OffloadNeedsSchema = z.object({
24
+ memoryMb: z.number().int().positive().optional(),
25
+ gpu: z.boolean().optional(),
26
+ });
27
+ export type OffloadNeeds = z.infer<typeof OffloadNeedsSchema>;
28
+
29
+ // The question `offload-run` asks before it snapshots anything. `eager` (remote-run's) picks the machine with the most
30
+ // room that fits even while this sandbox is calm; without it a line leaves only a busy sandbox, or one it does not fit.
31
+ // `label` and `command` name the line, so what it measured on earlier runs counts.
32
+ export const OffloadTargetInputSchema = z.object({
33
+ runner: z.string().min(1),
34
+ memoryMb: z.coerce.number().int().positive().optional(),
35
+ gpu: z.stringbool().optional(),
36
+ eager: z.stringbool().optional(),
37
+ label: z.string().min(1).max(80).optional(),
38
+ command: z.string().max(4000).optional(),
39
+ });
40
+ export type OffloadTargetInput = z.infer<typeof OffloadTargetInputSchema>;
41
+
21
42
  // What settings `offload.commands` names instead of one runner: whichever has the most room at the moment the command
22
- // starts, and only while this sandbox is busy (runners/fleet-advice.ts `roomierRunner`). While this sandbox is calm the
23
- // command runs here without a word. Reserved: no runner is ever enrolled under it.
43
+ // starts, and only while this sandbox is busy or cannot fit the line (runners/fleet-advice.ts `placeCommand`). While
44
+ // this sandbox is calm the command runs here without a word. Reserved: no runner is ever enrolled under it.
24
45
  export const OFFLOAD_ANY_RUNNER = "auto";
25
46
 
26
47
  export const OffloadRunSchema = RunnerCommandSchema.extend({ runner: z.string().min(1) });
@@ -43,9 +64,25 @@ export const OffloadRecordSchema = z.object({
43
64
  endedAt: z.number().optional(),
44
65
  code: z.number().int().optional(),
45
66
  failure: z.string().optional(),
67
+ // What the runner measured: the most memory the line held at once, and how long it ran there.
68
+ peakMemoryMb: z.number().int().nonnegative().optional(),
69
+ durationMs: z.number().int().nonnegative().optional(),
46
70
  });
47
71
  export type OffloadRecord = z.infer<typeof OffloadRecordSchema>;
48
72
 
73
+ // What earlier runs of one kind of line measured (offload/command-profiles.ts), keyed by its rule and the parts of the
74
+ // line that decide its size (`cargo test -p shinobi-society`, not the test filter after it).
75
+ export const CommandProfileSchema = z.object({
76
+ key: z.string().min(1),
77
+ runs: z.number().int().positive(),
78
+ // The most any of the last few runs held: memory is planned for the worst recent run, not the average.
79
+ peakMemoryMb: z.number().int().nonnegative().optional(),
80
+ // A moving average of how long it ran, on whichever machine.
81
+ durationMs: z.number().int().nonnegative().optional(),
82
+ lastAt: z.number(),
83
+ });
84
+ export type CommandProfile = z.infer<typeof CommandProfileSchema>;
85
+
49
86
  // One kind of heavy work the owner can send elsewhere: a heavy-command rule this sandbox queues (its id, as settings
50
87
  // `offload.commands` keys it) and the pattern that sorts a line into it.
51
88
  export const OffloadKindSchema = z.object({ id: z.string().min(1), pattern: z.string() });
@@ -97,7 +97,13 @@ export const AccountStateSchema = z.discriminatedUnion("kind", [
97
97
  room: z
98
98
  .number()
99
99
  .describe(
100
- "How much of the fullest pool that gates the turn is left, in percent (0 up to 100). Pickers take the most room. 0 is a rounded pool read at 100: at the line, tried after an unmeasured account, never a limit move's destination.",
100
+ "How much of the fullest pool that gates the turn is left, in percent (0 up to 100). 0 is a rounded pool read at 100: at the line, tried after an unmeasured account, never a limit move's destination. An account nearly out (plan-pools.ts NEARLY_OUT_ROOM) ranks after every one with more.",
101
+ ),
102
+ renewsAt: z
103
+ .number()
104
+ .optional()
105
+ .describe(
106
+ "When the longest pool that gates the turn resets, in epoch seconds: the moment what is left of it goes unspent for good. Pickers take the account that renews soonest among those not nearly out, then the most room. Absent where no such pool publishes a reset.",
101
107
  ),
102
108
  }),
103
109
  z.object({
@@ -683,7 +683,7 @@ export const SandboxSettingsSchema = z.object({
683
683
  childRerunHorizonHours: z.number().int().min(0).max(24).default(6).describe(
684
684
  "How long a subagent refused for a spent allowance waits for the provider's reset before it goes again by itself. Past it, or at 0, it stops and its parent hears where else the work can go. One spawned with fallbacks waits at most 90 minutes and then moves to them.",
685
685
  ),
686
- subagentBudget: z.boolean().default(true).describe("Start a subagent only where an account's allowance can carry it through its windows, on the account left with the most room after it. The rest wait as pending and start by themselves as running ones end or a window reopens. Off, every subagent starts at once, wherever the most room reads now."),
686
+ subagentBudget: z.boolean().default(true).describe("Start a subagent only where an account's allowance can carry it through its windows, on the account whose allowance renews first among those that can carry it, since what is left of an allowance at its reset is lost. The rest wait as pending and start by themselves as running ones end or a window reopens. Off, every subagent starts at once, on the account that renews first or, where none carries it, the one that holds out longest."),
687
687
  subagentReservePercent: z.number().int().min(0).max(50).default(10).describe("How much of each allowance window, in points of 100, subagents leave for your own conversations: a fan-out is planned against what is left past it."),
688
688
  // Width again, for a team-chat automation rather than a turn: each thread a message lands in is a conversation of
689
689
  // its own, and threads of one automation are worked on side by side up to this many (automations/scheduler.ts in