@anchrd/colab-sdk 0.1.36 → 0.1.37

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 (48) hide show
  1. package/dist/actions/actions.d.ts +30 -23
  2. package/dist/actions/actions.js +2 -2
  3. package/dist/archive/archive.d.ts +1 -0
  4. package/dist/archive/archive.js +3 -0
  5. package/dist/boards/boards.d.ts +21 -21
  6. package/dist/columns/columns.d.ts +2 -2
  7. package/dist/connectors/connectors.d.ts +6 -6
  8. package/dist/crawls/crawls.d.ts +3 -3
  9. package/dist/error/error.d.ts +9 -3
  10. package/dist/error/error.js +12 -3
  11. package/dist/gadgets/gadgets.d.ts +125 -9
  12. package/dist/gadgets/gadgets.js +123 -0
  13. package/dist/goals/goals.d.ts +54 -10
  14. package/dist/goals/goals.js +36 -7
  15. package/dist/grammar/grammar.d.ts +2 -0
  16. package/dist/grammar/grammar.js +10 -0
  17. package/dist/home/home.d.ts +300 -0
  18. package/dist/home/home.js +53 -0
  19. package/dist/links/links.d.ts +166 -0
  20. package/dist/links/links.js +149 -0
  21. package/dist/mcps/mcps.d.ts +3 -3
  22. package/dist/messages/messages.d.ts +3 -0
  23. package/dist/nodes/nodes.d.ts +46 -20
  24. package/dist/nodes/nodes.js +11 -3
  25. package/dist/operators/operators.d.ts +389 -47
  26. package/dist/operators/operators.js +268 -70
  27. package/dist/organisation/organisation.d.ts +2 -0
  28. package/dist/organisation/organisation.js +9 -0
  29. package/dist/primitives/primitives.d.ts +9 -0
  30. package/dist/primitives/primitives.js +16 -0
  31. package/dist/roles/roles.d.ts +1 -0
  32. package/dist/roles/roles.js +3 -0
  33. package/dist/runs/runs.d.ts +2 -2
  34. package/dist/sdk.d.ts +10 -9
  35. package/dist/sdk.js +10 -9
  36. package/dist/skills/skills.d.ts +37 -7
  37. package/dist/skills/skills.js +50 -0
  38. package/dist/sources/sources.d.ts +54 -14
  39. package/dist/sources/sources.js +50 -5
  40. package/dist/tables/tables.d.ts +42 -0
  41. package/dist/tables/tables.js +55 -2
  42. package/dist/tool.d.ts +1 -0
  43. package/dist/tree-order/tree-order.d.ts +2 -2
  44. package/dist/tree-order/tree-order.js +1 -1
  45. package/dist/users/users.d.ts +2 -0
  46. package/dist/users/users.js +3 -2
  47. package/dist/versions/versions.d.ts +13 -13
  48. package/package.json +1 -1
@@ -4,7 +4,7 @@ import { Flag, Limit } from "../list-input.js";
4
4
  import { MachineId } from "../machines/machines.js";
5
5
  import { McpId } from "../mcps/mcps.js";
6
6
  import { NodeId } from "../nodes/nodes.js";
7
- import { Rev } from "../primitives/primitives.js";
7
+ import { AgentName, PlanSubstep, planEvidenceMax, Rev } from "../primitives/primitives.js";
8
8
  import { RoleId } from "../roles/roles.js";
9
9
  import { Schedule } from "../schedule/schedule.js";
10
10
  import { OperatorProvider, UserId } from "../users/users.js";
@@ -16,85 +16,159 @@ import { OperatorProvider, UserId } from "../users/users.js";
16
16
  // ⚠️ A credential's value goes in and never comes out: no answer carries it, and no field of an answer
17
17
  // is called `key`, `secret`, `token` or `password` (`/mcp` would strike it, `redactSecrets`). The
18
18
  // value's field in the inputs is `value`, the kinds are `subscription` and `apikey`.
19
- // The catalog (Einstellungen › Operator › Katalog). `models` are the names the provider's CLI takes
20
- // without a UI: Claude Code's aliases for "the newest of this line", Gemini CLI's aliases `pro`,
21
- // `flash` and `flash-lite` the same; Codex has no aliases, so its names are the models
22
- // `codex debug models` of Codex 0.162.1 lists as current (#455). `subagents`: only Claude Code has
23
- // them (#455); the UI hides the setting for the others. `costs`: only Claude Code reports a dollar
24
- // amount; Codex and Gemini report tokens, and their runs carry no `costUsd` (Jack, #455), unless
25
- // they run through the Cloudflare AI Gateway, whose logs carry the amount (#470). `gateway` is in
26
- // every provider's kinds: one gateway credential serves the Operators of all three (#470). Only Claude
27
- // keeps the sign-in of a subscription (#459). `beta`: Codex and Gemini carry the mark wherever the UI
28
- // names them, with the note that Claude is the tried way (#459).
29
- //
30
- // `gateway`: the models an Operator on a gateway credential may take, and its default there (#483).
31
- // ⚠️ The gateway pays only for the models it knows; any other request goes on to the provider without
32
- // a key and is refused. Nothing is replaced on the way: a model not in this list cannot be chosen
33
- // with a gateway credential, and with the customer's own key or subscription the full `models` stay.
34
- // Measured 2026-10-15 with one smallest request per model through a gateway with Unified Billing
35
- // (paths and header as in developers.cloudflare.com/ai-gateway/usage/providers/{anthropic,openai,
36
- // google-ai-studio}/; the gateway's docs name no list of models, /features/unified-billing/):
37
- // - Claude Code 2.1.299: `opus` (`claude-opus-5-5`) and `sonnet` (`claude-sonnet-5-5`) answer 200;
38
- // `haiku` (`claude-haiku-5-5`) 401 from Anthropic. `claude-haiku-4-5` answers, but Claude Code then
39
- // finds none of its MCP tools (run `…ZX0N8A` of #470), so it is no choice.
40
- // - Codex: `gpt-6.1-sol` and `gpt-6-luna` 200, `gpt-6-astra` 401 from OpenAI.
41
- // - Gemini CLI 0.63.0: its aliases are the 3.5 line, 403 from Google; `gemini-2.5-pro`, `-flash`
42
- // and `-flash-lite` 200 and ran as Operators (#470), so the gateway offers those by name. Also 200
43
- // that day, not offered without a run: `gemini-3.8-flash`, `gemini-3.1-flash-lite`,
44
- // `gemini-3.1-pro-preview`.
45
- // Add a model here once the gateway pays for it, after one smallest request and one run.
19
+ // The models of the kind Gateway (E210, #1011), by the gateway's own name `provider/model` as its
20
+ // Unified API (`/compat`) takes it. `context` in tokens; `price` in US dollars per million tokens
21
+ // (input, input read from the cache, output, and a cache write where the catalog names its own), the providers' list prices of 2026-11-04 and, for
22
+ // Workers AI, its catalog: the amount of a run where the token cannot read the gateway's logs.
23
+ // Each answered one smallest request through `/compat` on 2026-11-04 (#1011, #1018). OpenAI's GPT
24
+ // models (#1018) are priced from Cloudflare's catalog (developers.cloudflare.com/ai/models/openai/,
25
+ // the short-context price; they also name a cache write). Through `/compat` they refuse
26
+ // `max_tokens` (`outputLimit` names the field that caps a step's output) and call tools only with
27
+ // `reasoning_effort: "none"` (`reasoningEffort`). Left out: `openai/gpt-6.1-sol`, which refuses
28
+ // both tools with reasoning and "none" on Chat Completions and calls tools only through
29
+ // `/responses`, and `deepseek/deepseek-v4-pro`, which Fireworks serves only through the REST API
30
+ // with "Workers AI Read" (Spike #979).
31
+ export const gatewayCatalog = [
32
+ {
33
+ gateway: "cloudflare",
34
+ name: "Cloudflare",
35
+ models: [
36
+ {
37
+ model: "workers-ai/@cf/deepseek-ai/deepseek-v4-pro-0813",
38
+ name: "DeepSeek V4 Pro",
39
+ context: 1_000_000,
40
+ price: { input: 1.32, cacheRead: 0.044, output: 3.96 },
41
+ },
42
+ {
43
+ model: "anthropic/claude-sonnet-4-6",
44
+ name: "Claude Sonnet 4.6",
45
+ context: 200_000,
46
+ price: { input: 3, cacheRead: 0.3, output: 15 },
47
+ },
48
+ {
49
+ model: "anthropic/claude-opus-4-6",
50
+ name: "Claude Opus 4.6",
51
+ context: 200_000,
52
+ price: { input: 5, cacheRead: 0.5, output: 25 },
53
+ },
54
+ {
55
+ model: "anthropic/claude-haiku-4-5",
56
+ name: "Claude Haiku 4.5",
57
+ context: 200_000,
58
+ price: { input: 1, cacheRead: 0.1, output: 5 },
59
+ },
60
+ {
61
+ model: "google-ai-studio/gemini-2.5-pro",
62
+ name: "Gemini 2.5 Pro",
63
+ context: 1_000_000,
64
+ price: { input: 1.25, cacheRead: 0.125, output: 10 },
65
+ },
66
+ {
67
+ model: "google-ai-studio/gemini-2.5-flash",
68
+ name: "Gemini 2.5 Flash",
69
+ context: 1_000_000,
70
+ price: { input: 0.3, cacheRead: 0.03, output: 2.5 },
71
+ },
72
+ {
73
+ model: "openai/gpt-6.1-terra",
74
+ name: "GPT-6.1 Terra",
75
+ context: 1_050_000,
76
+ price: { input: 1, cacheRead: 0.05, cacheWrite: 1.25, output: 5 },
77
+ outputLimit: "max_completion_tokens",
78
+ reasoningEffort: "none",
79
+ },
80
+ {
81
+ model: "openai/gpt-6-luna",
82
+ name: "GPT-6 Luna",
83
+ context: 1_050_000,
84
+ price: { input: 0.1, cacheRead: 0.01, cacheWrite: 0.125, output: 0.5 },
85
+ outputLimit: "max_completion_tokens",
86
+ reasoningEffort: "none",
87
+ },
88
+ ],
89
+ },
90
+ ];
91
+ function gatewayModelIds() {
92
+ return gatewayCatalog.flatMap((entry) => entry.models.map((model) => model.model));
93
+ }
94
+ // The entry of a model of the kind Gateway, or null for every other model.
95
+ export function gatewayModelOf(model) {
96
+ for (const entry of gatewayCatalog) {
97
+ for (const found of entry.models)
98
+ if (found.model === model)
99
+ return found;
100
+ }
101
+ return null;
102
+ }
103
+ export function outputLimitOf(model) {
104
+ const entry = gatewayModelOf(model);
105
+ return entry && "outputLimit" in entry ? entry.outputLimit : "max_tokens";
106
+ }
107
+ // The reasoning effort a model must be sent to call tools on Chat Completions, or null (#1018).
108
+ export function reasoningEffortOf(model) {
109
+ const entry = gatewayModelOf(model);
110
+ return entry && "reasoningEffort" in entry ? entry.reasoningEffort : null;
111
+ }
112
+ // A cache write at its own price where the catalog names one, else at the input's.
113
+ export function cacheWritePriceOf(entry) {
114
+ return "cacheWrite" in entry.price ? entry.price.cacheWrite : entry.price.input;
115
+ }
116
+ // The table of a gateway model, checked: every price and context a positive number, every name a
117
+ // `provider/model` the gateway's Unified API takes.
118
+ export const GatewayModelEntrySchema = z.object({
119
+ model: z.string().regex(/^[a-z-]+\/[^\s]+$/),
120
+ name: z.string().min(1),
121
+ context: z.int().positive(),
122
+ price: z.object({
123
+ input: z.number().nonnegative(),
124
+ cacheRead: z.number().nonnegative(),
125
+ cacheWrite: z.number().nonnegative().optional(),
126
+ output: z.number().nonnegative(),
127
+ }),
128
+ outputLimit: z.enum(["max_tokens", "max_completion_tokens"]).optional(),
129
+ reasoningEffort: z.literal("none").optional(),
130
+ });
131
+ // The catalog (Einstellungen › Operator › Katalog), two kinds (E210):
132
+ // - `claude`: Claude Code in a container, with the sign-in of a subscription or an API key. Its
133
+ // `models` are Claude Code's aliases for "the newest of this line". Through the gateway it runs no
134
+ // more since #978: that is the kind Gateway's.
135
+ // - `gateway` (#1011): an Operator on Project Think without a CLI, whose model is any of
136
+ // `gatewayCatalog` through the customer's AI Gateway; its credential is the gateway credential.
137
+ // Codex and Gemini are gone since #978 (Jack, 2026-11-04, after the Spike #979): GPT and Gemini come
138
+ // as models of the gateway. `OperatorProvider` keeps their names, so a row stored before still reads;
139
+ // a credential of theirs reads invalid with the reason (`withdrawnOf`), and no run of theirs starts.
140
+ // `subagents`: only Claude Code has them. `costs`: both report an amount, the gateway's from its logs
141
+ // or the catalog's price.
46
142
  export const operatorProviders = [
47
143
  {
48
144
  provider: "claude",
49
145
  name: "Claude",
50
146
  vendor: "Anthropic",
51
147
  selectable: true,
52
- kinds: ["subscription", "apikey", "gateway"],
148
+ kinds: ["subscription", "apikey"],
53
149
  beta: false,
54
150
  models: ["opus", "sonnet", "haiku"],
55
151
  defaultModel: "sonnet",
56
- gateway: { models: ["opus", "sonnet"], defaultModel: "sonnet" },
57
152
  subagents: true,
58
153
  costs: true,
59
154
  },
60
155
  {
61
- provider: "codex",
62
- name: "Codex",
63
- vendor: "OpenAI",
156
+ provider: "gateway",
157
+ name: "Gateway",
158
+ vendor: "Cloudflare AI Gateway",
64
159
  selectable: true,
65
- // No ChatGPT sign-in (#459): chatgpt.com refuses every request that carries `CF-Worker`,
66
- // which Cloudflare sets on each request of a Worker; GPT runs with an API key or the gateway.
67
- kinds: ["apikey", "gateway"],
68
- beta: true,
69
- models: ["gpt-6-astra", "gpt-6.1-sol", "gpt-6-luna"],
70
- defaultModel: "gpt-6.1-sol",
71
- gateway: { models: ["gpt-6.1-sol", "gpt-6-luna"], defaultModel: "gpt-6.1-sol" },
72
- subagents: false,
73
- costs: false,
74
- },
75
- {
76
- provider: "gemini",
77
- name: "Gemini",
78
- vendor: "Google",
79
- selectable: true,
80
- // No Google sign-in (#459): Code Assist then asks for a Google Cloud project of the account,
81
- // and for free accounts the Gemini CLI gave way to Antigravity (#507, from #502).
82
- kinds: ["apikey", "gateway"],
83
- beta: true,
84
- models: ["pro", "flash", "flash-lite"],
85
- defaultModel: "flash",
86
- gateway: {
87
- models: ["gemini-2.5-pro", "gemini-2.5-flash", "gemini-2.5-flash-lite"],
88
- defaultModel: "gemini-2.5-flash",
89
- },
160
+ kinds: ["gateway"],
161
+ beta: false,
162
+ models: gatewayModelIds(),
163
+ defaultModel: "workers-ai/@cf/deepseek-ai/deepseek-v4-pro-0813",
90
164
  subagents: false,
91
- costs: false,
165
+ costs: true,
92
166
  },
93
167
  ];
94
- // The models an Operator of this provider may take with a credential of this kind, and the default
95
- // among them (#483): the gateway's own list, else the provider's.
96
- export function modelsOf(entry, kind) {
97
- return kind === "gateway" ? entry.gateway : entry;
168
+ // The models an Operator of this provider may take, and the default among them (#483). Since #978
169
+ // the kind decides nothing more: a gateway credential serves the kind Gateway only.
170
+ export function modelsOf(entry, _kind) {
171
+ return entry;
98
172
  }
99
173
  // `subscription`: the sign-in of a subscription, the token of `claude setup-token`; none for Codex
100
174
  // and Gemini since #459, a stored one reads as invalid. `apikey`: an API key (Claude Console,
@@ -122,6 +196,16 @@ export const OperatorModel = z.enum([
122
196
  "gemini-2.5-pro",
123
197
  "gemini-2.5-flash",
124
198
  "gemini-2.5-flash-lite",
199
+ // The kind Gateway (#1011), `gatewayCatalog`.
200
+ "workers-ai/@cf/deepseek-ai/deepseek-v4-pro-0813",
201
+ "anthropic/claude-sonnet-4-6",
202
+ "anthropic/claude-opus-4-6",
203
+ "anthropic/claude-haiku-4-5",
204
+ "google-ai-studio/gemini-2.5-pro",
205
+ "google-ai-studio/gemini-2.5-flash",
206
+ // OpenAI through the gateway (#1018).
207
+ "openai/gpt-6.1-terra",
208
+ "openai/gpt-6-luna",
125
209
  ]);
126
210
  export const CredentialId = idSchema("credential");
127
211
  const CredentialName = z.string().trim().min(1).max(64);
@@ -140,6 +224,17 @@ export const GatewayTarget = z.strictObject({
140
224
  .trim()
141
225
  .regex(/^[A-Za-z0-9_-]{1,64}$/, "A gateway id holds letters, digits, - and _ only."),
142
226
  });
227
+ // What a gateway credential's token may do (#1012), each tested with one smallest call: `run` the
228
+ // models through the gateway (needed, without it no Operator runs), `read` the gateway's logs (the
229
+ // amount of a run; without it the amount is tokens times the catalog's price) and `workersai` the
230
+ // REST API of Workers AI (`/ai/v1/…`, the models served only there). `granted` is null where the
231
+ // call could not tell; `without` says what is missing without the right.
232
+ export const GatewayRight = z.enum(["run", "read", "workersai"]);
233
+ export const GatewayRightCheck = z.object({
234
+ right: GatewayRight,
235
+ granted: z.boolean().nullable(),
236
+ without: z.string().nullable(),
237
+ });
143
238
  export const CredentialListInput = z.strictObject({
144
239
  cursor: CredentialId.optional(),
145
240
  limit: Limit.optional(),
@@ -156,9 +251,12 @@ export const CredentialCreateInput = z
156
251
  gateway: GatewayTarget.optional(),
157
252
  })
158
253
  .refine((input) => input.kind === "gateway"
159
- ? input.provider === undefined && input.gateway !== undefined
160
- : input.provider !== undefined && input.gateway === undefined, {
161
- message: "A gateway credential takes gateway and no provider; every other kind takes provider and no gateway.",
254
+ ? (input.provider === undefined || input.provider === "gateway") &&
255
+ input.gateway !== undefined
256
+ : input.provider !== undefined &&
257
+ input.provider !== "gateway" &&
258
+ input.gateway === undefined, {
259
+ message: "A gateway credential takes gateway and no provider but gateway (the kind Gateway, #1012); every other kind takes its provider and no gateway.",
162
260
  });
163
261
  // "Token ersetzen": a new value, a new name, or both. A new value is tested at once. A gateway
164
262
  // credential takes a new value only together with its `gateway` (#470).
@@ -206,6 +304,9 @@ export const Credential = z.object({
206
304
  personal: z.boolean(),
207
305
  // Ausweichen: a run that fails on it moves on to the next fitting credential in the order.
208
306
  fallback: z.boolean(),
307
+ // A gateway credential's rights as its last test found them (#1012); null for every other kind
308
+ // and before the first test since #1012.
309
+ rights: z.array(GatewayRightCheck).nullable(),
209
310
  // When a run last met the provider's usage limit on it, and until when the order skips it: the
210
311
  // time the provider named for its reset, else an hour (#890). Null where no limit was met.
211
312
  limitedAt: z.iso.datetime().nullable(),
@@ -249,17 +350,29 @@ export const Trigger = z.discriminatedUnion("on", [
249
350
  z.object({ on: z.literal("change"), quietMinutes: z.int().min(0).max(1440) }),
250
351
  z.object({ on: z.literal("schedule"), schedule: Schedule }),
251
352
  ]);
252
- // The limits of E81: the longest run in minutes and the most runs a day.
353
+ // How long the steps of a run stay (E211, #1028): 7, 30 or 90 days, or null for as long as the run.
354
+ export const KeepStepsDays = z.union([z.literal(7), z.literal(30), z.literal(90), z.null()]);
355
+ // The limits of E81: the longest run in minutes and the most runs a day; and how long the steps of
356
+ // its runs stay (E211).
253
357
  export const OperatorLimits = z.strictObject({
254
358
  maxRunMinutes: z.int().min(1).max(240),
255
359
  maxRunsPerDay: z.int().min(1).max(1000),
360
+ keepStepsDays: KeepStepsDays,
256
361
  });
257
362
  export const operatorDefaults = {
258
363
  model: "sonnet",
259
364
  subagents: { allowed: false, max: 3 },
260
- trigger: { on: "change", quietMinutes: 5 },
261
- limits: { maxRunMinutes: 30, maxRunsPerDay: 50 },
365
+ // No quiet time (E185, #966): woken by a mention or a goal's rhythm, a wait is only a delay.
366
+ trigger: { on: "change", quietMinutes: 0 },
367
+ limits: { maxRunMinutes: 30, maxRunsPerDay: 50, keepStepsDays: 30 },
262
368
  };
369
+ // The validation's Operator keeps 5 minutes, as a fixed value when it is created with the role
370
+ // `validator` and no trigger (E185): it sees many small saves in a row and takes them in one run.
371
+ // ⚠️ Not a standard of its own: an Operator handed the role later keeps what it stored.
372
+ export const validatorTrigger = { on: "change", quietMinutes: 5 };
373
+ // A schedule stored before #824 carries no quiet time and was read with the standard of then; it
374
+ // keeps those 5 minutes, so E185 changes no stored Operator silently.
375
+ export const scheduleQuietMinutes = 5;
263
376
  // `no_role`: it has no role and starts no run (E84). `paused`: see `pausedReason`. `ready`: it may run.
264
377
  // "läuft" is `running` beside the state (#337).
265
378
  export const OperatorState = z.enum(["no_role", "ready", "paused"]);
@@ -469,6 +582,9 @@ export const OperatorRunReason = z.enum([
469
582
  ]);
470
583
  // What woke it: a change after the quiet minutes, a fixed time, or the retry after a failure.
471
584
  export const OperatorRunTrigger = z.enum(["change", "schedule", "retry"]);
585
+ // Where a run's amount comes from (#1013): the AI Gateway's logs, the catalog's price times the
586
+ // tokens (the kind Gateway without "AI Gateway Read"), or the CLI's own figure.
587
+ export const OperatorRunCostSource = z.enum(["logs", "catalog", "provider"]);
472
588
  export const OperatorRunTokens = z.object({
473
589
  input: z.int().min(0),
474
590
  output: z.int().min(0),
@@ -509,6 +625,19 @@ const RunMachine = {
509
625
  // a page without `limit` this many runs. The protocol page reads every summary whole, 50 a page.
510
626
  export const runSummaryChars = 300;
511
627
  export const compactRunLimit = 20;
628
+ // One step of a run's plan (E218, #1036): what it is, how it is done, what it left, and whether it
629
+ // is done. Not a `step` of the protocol (`operator_run_step_list`): those are what the run did.
630
+ export const RunPlanStep = z.object({
631
+ title: z.string(),
632
+ how: z.string().nullable(),
633
+ result: z.string().nullable(),
634
+ done: z.boolean(),
635
+ // What the step left (E219, #1037): nodes as proof; empty for a step without any.
636
+ evidence: z.array(z.string()),
637
+ // The subagent the step went to and its plan beneath it (E220, #1038); absent on the main agent's.
638
+ agent: z.string().nullable().optional(),
639
+ steps: z.array(PlanSubstep).optional(),
640
+ });
512
641
  export const OperatorRun = z.object({
513
642
  runId: OperatorRunId,
514
643
  ...RunMachine,
@@ -531,6 +660,8 @@ export const OperatorRun = z.object({
531
660
  // Claude's own amount; Codex and Gemini report tokens and no amount, so their runs carry null
532
661
  // (#455). Through the Cloudflare AI Gateway the amount of its logs, for every provider (#470).
533
662
  costUsd: z.number().nullable(),
663
+ // Where the amount comes from (#1013); null without one and for a run before #1013.
664
+ costSource: OperatorRunCostSource.nullable(),
534
665
  tokens: OperatorRunTokens.nullable(),
535
666
  // The subagents the run started, and how many of them run now (E112); null for a run before
536
667
  // they were counted. Only Claude Code has subagents (E99).
@@ -547,6 +678,10 @@ export const OperatorRun = z.object({
547
678
  startedAt: z.iso.datetime(),
548
679
  endedAt: z.iso.datetime().nullable(),
549
680
  durationMs: z.int().nullable(),
681
+ // After how many days the daily job removed its steps (E211, #1028); null while they stand.
682
+ stepsRemovedDays: z.int().nullable(),
683
+ // Its plan (E218, #1036); null for a run that wrote none.
684
+ plan: z.array(RunPlanStep).nullable(),
550
685
  });
551
686
  const RunMoment = z.iso.datetime({ offset: true });
552
687
  export const OperatorRunListInput = z.strictObject({
@@ -571,12 +706,75 @@ export const OperatorRunGetInput = z.strictObject({ runId: OperatorRunId });
571
706
  // Stopping a run by hand (E112): its container ends, the run ends `stopped`.
572
707
  export const RunCancelInput = z.strictObject({ runId: OperatorRunId });
573
708
  // Marks the technical abort of a run read (E141, #825), like a chat: its row leaves the Actions.
574
- export const RunUpdateInput = z.strictObject({
709
+ export const runPlanMax = 30;
710
+ const RunPlanStepInput = z.strictObject({
711
+ title: z.string().trim().min(1).max(200).describe("The step in a few words."),
712
+ how: z
713
+ .string()
714
+ .trim()
715
+ .max(2000)
716
+ .nullable()
717
+ .optional()
718
+ .describe("How it is done: the tools, the nodes, what to check. Shown when it is next."),
719
+ result: z
720
+ .string()
721
+ .trim()
722
+ .max(2000)
723
+ .nullable()
724
+ .optional()
725
+ .describe("What the step left, in a sentence: the node made, the value found, what was checked. Needed to mark it done."),
726
+ done: z
727
+ .boolean()
728
+ .optional()
729
+ .describe("Whether the step is done; only with a result. Leaving it out means not yet."),
730
+ evidence: z
731
+ .array(idSchema("node"))
732
+ .max(planEvidenceMax)
733
+ .optional()
734
+ .describe("What the step left: the nodes it made or used as proof (a document, a table, a card handed over, a file)."),
735
+ agent: AgentName.nullable()
736
+ .optional()
737
+ .describe("The subagent you hand this step to with agent_run, by the name you give it; its own plan then stands beneath the step."),
738
+ });
739
+ export const RunUpdateInput = z
740
+ .strictObject({
575
741
  runId: OperatorRunId,
576
742
  read: z
577
743
  .literal(true)
744
+ .optional()
578
745
  .describe("true: you have seen that this run broke off. Its row leaves your Actions; a later run that completes takes it away by itself."),
746
+ plan: z
747
+ .array(RunPlanStepInput)
748
+ .min(1)
749
+ .max(runPlanMax)
750
+ .optional()
751
+ .describe("The plan of your own running run, in order; it replaces the one before. Mark a step done only with its result."),
752
+ agent: AgentName.optional().describe("Set by the run for a subagent: its plan goes beneath the step of the main agent's plan it took."),
753
+ })
754
+ .refine((input) => (input.read === undefined) !== (input.plan === undefined), {
755
+ message: "Give either read or plan.",
579
756
  });
757
+ // What `operator_run_update` answers to a plan (E218): the next open step with how it is done, of
758
+ // the rest only the titles, so the run works one step at a time.
759
+ export const RunPlanAnswer = z.object({
760
+ runId: OperatorRunId,
761
+ done: z.int(),
762
+ total: z.int(),
763
+ next: z.object({ title: z.string(), how: z.string().nullable() }).nullable(),
764
+ remaining: z.array(z.string()),
765
+ });
766
+ // The answer of a plan as it is stored: a step is next while it is not done, the first such first.
767
+ export function planAnswerOf(runId, plan) {
768
+ const open = plan.filter((step) => !step.done);
769
+ const [next, ...rest] = open;
770
+ return {
771
+ runId,
772
+ done: plan.length - open.length,
773
+ total: plan.length,
774
+ next: next ? { title: next.title, how: next.how } : null,
775
+ remaining: rest.map((step) => step.title),
776
+ };
777
+ }
580
778
  // One step of a run as its CLI's output showed it (E112): what the model wrote, a tool it called
581
779
  // with a short form of the input, the shortened result, a subagent's start and end. `agentId` is
582
780
  // the id of the call that started the subagent the step belongs to (`parent_tool_use_id` of Claude
@@ -23,6 +23,7 @@ export declare const OrganisationUpdateInput: z.ZodObject<{
23
23
  GBP: "GBP";
24
24
  }>>>;
25
25
  currencyRate: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
26
+ homeGadgetId: z.ZodOptional<z.ZodNullable<z.ZodTemplateLiteral<`node_${string}`>>>;
26
27
  }, z.core.$strict>;
27
28
  export type OrganisationUpdateInput = z.infer<typeof OrganisationUpdateInput>;
28
29
  export declare const Organisation: z.ZodObject<{
@@ -39,6 +40,7 @@ export declare const Organisation: z.ZodObject<{
39
40
  GBP: "GBP";
40
41
  }>>;
41
42
  currencyRate: z.ZodNullable<z.ZodNumber>;
43
+ homeGadgetId: z.ZodNullable<z.ZodString>;
42
44
  setAt: z.ZodNullable<z.ZodISODateTime>;
43
45
  setBy: z.ZodNullable<z.ZodTemplateLiteral<`user_${string}`>>;
44
46
  }, z.core.$strip>;
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod";
2
+ import { NodeId } from "../nodes/nodes.js";
2
3
  import { Locale, TimeZone } from "../profile/profile.js";
3
4
  import { UserId } from "../users/users.js";
4
5
  // Organisation › System (#930): what holds for the whole company. The name is the installation's
@@ -12,6 +13,9 @@ import { UserId } from "../users/users.js";
12
13
  // US dollars. With a currency other than USD and a fixed rate the admin enters (1 USD = `currencyRate`
13
14
  // of the currency), the UI shows and takes amounts in that currency, converted with the rate. The
14
15
  // MCP tools stay in US dollars. Null or USD: dollars everywhere, as before.
16
+ //
17
+ // The start (#1020, E208): the gadget whose live version stands under `/` for everybody who may read
18
+ // it. Null: none, and `/` shows Colab's fallback.
15
19
  export const currencies = ["EUR", "USD", "CHF", "GBP"];
16
20
  export const Currency = z.enum(currencies);
17
21
  // How many units of the currency one US dollar buys; fixed until an admin changes it.
@@ -30,6 +34,9 @@ export const OrganisationUpdateInput = z.strictObject({
30
34
  currencyRate: CurrencyRate.nullable()
31
35
  .optional()
32
36
  .describe("The fixed rate: how many units of the currency one US dollar is (1 USD = currencyRate), greater than 0, such as 0.92 for EUR. null takes it out. Left out: unchanged."),
37
+ homeGadgetId: NodeId.nullable()
38
+ .optional()
39
+ .describe("The gadget everybody sees under / (the start, E208): its live version, for whoever may read it. A gadget that is not archived. null takes it out, and / shows Colab's own fallback. Left out: unchanged."),
33
40
  });
34
41
  export const Organisation = z.object({
35
42
  // The installation's name for people; empty when the installation sets none.
@@ -39,6 +46,8 @@ export const Organisation = z.object({
39
46
  currency: Currency.nullable(),
40
47
  // 1 USD = currencyRate of the currency; null while unset.
41
48
  currencyRate: z.number().nullable(),
49
+ // The gadget under `/` (#1020, E208); null while none is set.
50
+ homeGadgetId: z.string().nullable(),
42
51
  // When and by whom the defaults were last changed; null while nobody has.
43
52
  setAt: z.iso.datetime().nullable(),
44
53
  setBy: UserId.nullable(),
@@ -3,3 +3,12 @@ export declare const IdempotencyKey: z.ZodString;
3
3
  export type IdempotencyKey = z.infer<typeof IdempotencyKey>;
4
4
  export declare const Rev: z.ZodNumber;
5
5
  export type Rev = z.infer<typeof Rev>;
6
+ export declare const planEvidenceMax = 20;
7
+ export declare const gatewayAgentsMax = 3;
8
+ export declare const AgentName: z.ZodString;
9
+ export declare const PlanSubstep: z.ZodObject<{
10
+ title: z.ZodString;
11
+ result: z.ZodNullable<z.ZodString>;
12
+ done: z.ZodBoolean;
13
+ }, z.core.$strip>;
14
+ export type PlanSubstep = z.infer<typeof PlanSubstep>;
@@ -17,3 +17,19 @@ export const Rev = z
17
17
  .int()
18
18
  .min(1)
19
19
  .describe("The revision of the node this change is based on, as the last read returned it. If someone saved in between, the call answers conflict, changes nothing and names under current what stands now: decide, and send it again with that rev.");
20
+ // The nodes one step of a plan may name as its evidence (E219, #1037), for goals and Operator runs.
21
+ export const planEvidenceMax = 20;
22
+ // A subagent of a Gateway Operator's run (E220, #1038): the name its main agent gave it, and its own
23
+ // plan under the step it took, one level, for goals and Operator runs alike.
24
+ export const gatewayAgentsMax = 3;
25
+ export const AgentName = z
26
+ .string()
27
+ .trim()
28
+ .min(1)
29
+ .max(60)
30
+ .describe("The subagent's name, as its main agent gave it.");
31
+ export const PlanSubstep = z.object({
32
+ title: z.string(),
33
+ result: z.string().nullable(),
34
+ done: z.boolean(),
35
+ });
@@ -1,5 +1,6 @@
1
1
  import { z } from "zod";
2
2
  export declare const RoleId: z.ZodTemplateLiteral<`role_${string}`>;
3
+ export declare const validatorRoleId = "role_01K0000000000000000000VDR1";
3
4
  export declare const RightPath: z.ZodString;
4
5
  export declare const RoleListInput: z.ZodObject<{
5
6
  archived: z.ZodOptional<z.ZodPreprocess<z.ZodBoolean, unknown>>;
@@ -5,6 +5,9 @@ import { Flag, Limit } from "../list-input.js";
5
5
  // their routes, and the answers the UI reads. A right is `package / resource / action`, every word one
6
6
  // word (E64).
7
7
  export const RoleId = idSchema("role");
8
+ // The fixed role `validator` (E79, E80): its id is fixed, so `operator` knows the validation's
9
+ // Operator at its creation (E185) without asking `access`.
10
+ export const validatorRoleId = "role_01K0000000000000000000VDR1";
8
11
  // A right (`access / role / list`) or the prefix of a level (`intelligence / document`, `connectors`).
9
12
  // The spaces around `/` are optional; `access` stores the form with them. The last word may be a
10
13
  // connector's function, `connectors / shopify / order-list` (#5): resource and action joined by a
@@ -102,25 +102,25 @@ export declare const RunList: z.ZodObject<{
102
102
  export type RunList = z.infer<typeof RunList>;
103
103
  export declare const RunDetail: z.ZodObject<{
104
104
  counts: z.ZodNullable<z.ZodRecord<z.ZodEnum<{
105
- archive: "archive";
106
105
  backlog: "backlog";
107
106
  open: "open";
108
107
  progress: "progress";
109
108
  done: "done";
110
109
  discarded: "discarded";
111
110
  blocked: "blocked";
111
+ archive: "archive";
112
112
  }> & z.core.$partial, z.ZodNumber>>;
113
113
  columns: z.ZodNullable<z.ZodArray<z.ZodObject<{
114
114
  columnId: z.ZodTemplateLiteral<`column_${string}`>;
115
115
  name: z.ZodString;
116
116
  type: z.ZodEnum<{
117
- archive: "archive";
118
117
  backlog: "backlog";
119
118
  open: "open";
120
119
  progress: "progress";
121
120
  done: "done";
122
121
  discarded: "discarded";
123
122
  blocked: "blocked";
123
+ archive: "archive";
124
124
  }>;
125
125
  tasks: z.ZodNumber;
126
126
  }, z.core.$strip>>>;