@b3os/sdk 0.2.2 → 0.2.4

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 (87) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/core/util.d.ts +1 -1
  3. package/dist/cjs/core/util.js +1 -1
  4. package/dist/cjs/generated/client.d.ts +5 -0
  5. package/dist/cjs/generated/client.js +9 -0
  6. package/dist/cjs/generated/client.js.map +1 -1
  7. package/dist/cjs/generated/errors.d.ts +1 -1
  8. package/dist/cjs/generated/errors.js +45 -0
  9. package/dist/cjs/generated/errors.js.map +1 -1
  10. package/dist/cjs/generated/ids.d.ts +28 -0
  11. package/dist/cjs/generated/ids.js +7 -0
  12. package/dist/cjs/generated/ids.js.map +1 -1
  13. package/dist/cjs/generated/ns/agents.d.ts +449 -11
  14. package/dist/cjs/generated/ns/agents.js +609 -11
  15. package/dist/cjs/generated/ns/agents.js.map +1 -1
  16. package/dist/cjs/generated/ns/images.d.ts +84 -3
  17. package/dist/cjs/generated/ns/images.js +126 -2
  18. package/dist/cjs/generated/ns/images.js.map +1 -1
  19. package/dist/cjs/generated/ns/keys.d.ts +12 -4
  20. package/dist/cjs/generated/ns/keys.js +12 -4
  21. package/dist/cjs/generated/ns/keys.js.map +1 -1
  22. package/dist/cjs/generated/ns/listeners.d.ts +6 -2
  23. package/dist/cjs/generated/ns/listeners.js +6 -2
  24. package/dist/cjs/generated/ns/listeners.js.map +1 -1
  25. package/dist/cjs/generated/ns/routines.d.ts +11 -0
  26. package/dist/cjs/generated/ns/routines.js +11 -0
  27. package/dist/cjs/generated/ns/routines.js.map +1 -1
  28. package/dist/cjs/generated/ns/sandboxes.d.ts +140 -1
  29. package/dist/cjs/generated/ns/sandboxes.js +190 -1
  30. package/dist/cjs/generated/ns/sandboxes.js.map +1 -1
  31. package/dist/cjs/generated/ns/vision.d.ts +55 -1
  32. package/dist/cjs/generated/ns/vision.js +94 -1
  33. package/dist/cjs/generated/ns/vision.js.map +1 -1
  34. package/dist/cjs/generated/ns/workspaces.d.ts +225 -0
  35. package/dist/cjs/generated/ns/workspaces.js +410 -0
  36. package/dist/cjs/generated/ns/workspaces.js.map +1 -0
  37. package/dist/cjs/generated/types.d.ts +2312 -90
  38. package/dist/esm/core/util.d.ts +1 -1
  39. package/dist/esm/core/util.js +1 -1
  40. package/dist/esm/generated/client.d.ts +5 -0
  41. package/dist/esm/generated/client.js +9 -0
  42. package/dist/esm/generated/client.js.map +1 -1
  43. package/dist/esm/generated/errors.d.ts +1 -1
  44. package/dist/esm/generated/errors.js +45 -0
  45. package/dist/esm/generated/errors.js.map +1 -1
  46. package/dist/esm/generated/ids.d.ts +28 -0
  47. package/dist/esm/generated/ids.js +7 -0
  48. package/dist/esm/generated/ids.js.map +1 -1
  49. package/dist/esm/generated/ns/agents.d.ts +449 -11
  50. package/dist/esm/generated/ns/agents.js +609 -11
  51. package/dist/esm/generated/ns/agents.js.map +1 -1
  52. package/dist/esm/generated/ns/images.d.ts +84 -3
  53. package/dist/esm/generated/ns/images.js +126 -2
  54. package/dist/esm/generated/ns/images.js.map +1 -1
  55. package/dist/esm/generated/ns/keys.d.ts +12 -4
  56. package/dist/esm/generated/ns/keys.js +12 -4
  57. package/dist/esm/generated/ns/keys.js.map +1 -1
  58. package/dist/esm/generated/ns/listeners.d.ts +6 -2
  59. package/dist/esm/generated/ns/listeners.js +6 -2
  60. package/dist/esm/generated/ns/listeners.js.map +1 -1
  61. package/dist/esm/generated/ns/routines.d.ts +11 -0
  62. package/dist/esm/generated/ns/routines.js +11 -0
  63. package/dist/esm/generated/ns/routines.js.map +1 -1
  64. package/dist/esm/generated/ns/sandboxes.d.ts +140 -1
  65. package/dist/esm/generated/ns/sandboxes.js +190 -1
  66. package/dist/esm/generated/ns/sandboxes.js.map +1 -1
  67. package/dist/esm/generated/ns/vision.d.ts +55 -1
  68. package/dist/esm/generated/ns/vision.js +94 -1
  69. package/dist/esm/generated/ns/vision.js.map +1 -1
  70. package/dist/esm/generated/ns/workspaces.d.ts +225 -0
  71. package/dist/esm/generated/ns/workspaces.js +406 -0
  72. package/dist/esm/generated/ns/workspaces.js.map +1 -0
  73. package/dist/esm/generated/types.d.ts +2312 -90
  74. package/package.json +1 -1
  75. package/src/core/util.ts +1 -1
  76. package/src/generated/client.ts +10 -0
  77. package/src/generated/errors.ts +90 -0
  78. package/src/generated/ids.ts +7 -0
  79. package/src/generated/ns/agents.ts +663 -11
  80. package/src/generated/ns/images.ts +131 -3
  81. package/src/generated/ns/keys.ts +12 -4
  82. package/src/generated/ns/listeners.ts +6 -2
  83. package/src/generated/ns/routines.ts +11 -0
  84. package/src/generated/ns/sandboxes.ts +203 -1
  85. package/src/generated/ns/vision.ts +101 -1
  86. package/src/generated/ns/workspaces.ts +448 -0
  87. package/src/generated/types.ts +2488 -55
@@ -34,6 +34,11 @@ export type Scope =
34
34
  | "routines:run"
35
35
  | "listeners:read"
36
36
  | "listeners:write"
37
+ | "workspaces:read"
38
+ | "workspaces:write"
39
+ | "workspaces:run"
40
+ | "workspaces:rules:write"
41
+ | "workspaces:subjects:assert"
37
42
  | "actions:read"
38
43
  | "actions:write"
39
44
  | "actions:run"
@@ -55,6 +60,7 @@ export type Scope =
55
60
  | "agents:*"
56
61
  | "routines:*"
57
62
  | "listeners:*"
63
+ | "workspaces:*"
58
64
  | "actions:*"
59
65
  | "infer:*"
60
66
  | "vault:*"
@@ -139,6 +145,18 @@ export interface Problem {
139
145
  limit?: LimitRef;
140
146
  /** The object's current status, for state conflicts such as `sandbox_not_running`. */
141
147
  current_status?: string;
148
+ /** The branch's head now (`head_moved`). */
149
+ current_head?: string;
150
+ /** The workspace paths the code is about (`path_not_writable`, `append_only_violation`), at most 100. */
151
+ paths?: string[];
152
+ /** Every path a merge could not combine (`merge_conflict`), with the blob IDs of the three sides. */
153
+ conflicts?: {
154
+ path: string;
155
+ kind: "content" | "binary" | "delete_modify" | "add_add" | "type";
156
+ base: string | null;
157
+ ours: string | null;
158
+ theirs: string | null;
159
+ }[];
142
160
  /** The sandbox that holds a lease's key now, or null when none does (`lease_holder_changed`). */
143
161
  holder?: string | null;
144
162
  /** The head of the linked branch now (`manifest_changed`). */
@@ -205,6 +223,14 @@ export interface Problem {
205
223
  * Why the egress guard refused the address of a hosted tool's `$url` file value (`action_input_invalid` with `reason: url_denied`): one of `egress_denied`'s reasons.
206
224
  */
207
225
  egress_reason?: string;
226
+ /**
227
+ * How far the node is with importing a hosted tool's image (`tool_unavailable` with `reason: image`): an image status, such as `pulling` or `warming`.
228
+ */
229
+ image_status?: string;
230
+ /**
231
+ * Why a hosted tool's image did not import (`tool_failed` with `reason: image`): `stage` (where it stopped, an image error stage) and `detail`.
232
+ */
233
+ image_error?: Record<string, unknown>;
208
234
  /** The part of the answer that was filled (`extract_fields_missing`), without the missing fields. */
209
235
  partial_data?: unknown;
210
236
  /** The job's pages and how each was read (vision extract errors), as in the job's `result.pages`. */
@@ -630,7 +656,7 @@ export type ScrapeRequest = {
630
656
  * `hosts` list the proxy's host (needs `vault:run`).
631
657
  * A URL with a username or password is refused (`400 invalid_request`): put them in a connection. This node
632
658
  * takes `http://` proxies only; plain HTTP means the username and password cross the network to your proxy
633
- * unencrypted. Batches, crawls, sessions and the Firecrawl surface do not take `proxy` yet.
659
+ * unencrypted. Batches, crawls and the Firecrawl surface do not take `proxy` yet; sessions take it with `stealth` only.
634
660
  */
635
661
  export type ProxyOption =
636
662
  | "none"
@@ -1146,8 +1172,148 @@ export interface SessionCreateRequest {
1146
1172
  * @default false
1147
1173
  */
1148
1174
  thumbnails?: boolean;
1175
+ /**
1176
+ * `microvm`: the session's browser runs in a microVM of its own (2 vCPU, 2 GiB, full Chrome with its own sandbox, a fresh random seed, machine ID and clock), or the create is refused with `503 capacity_unavailable` and `Retry-After: 1` when the node has none ready. `process`: the node's browser pool. Without it, the node decides (`process` on every node today).
1177
+ */
1178
+ isolation?: SessionIsolation;
1179
+ stealth?: StealthOption;
1180
+ /**
1181
+ * Where a stealth session leaves from (`vision.proxy`); only with `stealth`, else `400 invalid_request`.
1182
+ * `none` (the default): the node's own address, and the session carries the `exit_direct` warning. A
1183
+ * proxy URL or `{url, connection}`: your own proxy, as on a scrape, kept for the whole session (one exit,
1184
+ * never rotated). `auto` and `residential` answer `422 option_not_allowed` with `bound_by: catalog`: stealth
1185
+ * sessions never use the residential network.
1186
+ */
1187
+ proxy?: ProxyOption;
1188
+ }
1189
+
1190
+ /**
1191
+ * A stealth session (`vision.stealth`, needs the flag for your organization and the stealth terms accepted by
1192
+ * an owner; else `422 option_not_allowed` with `bound_by: org`). The browser runs headful in a microVM of its
1193
+ * own, keeps one consistent identity (screen, window, fonts, input style), and takes its time zone and locale
1194
+ * from where its exit is. `true` is `{}`; `false` or no member is an ordinary session. It implies `isolation:
1195
+ * microvm` (`process` is `400`), runs engine `chrome` (`headless-shell` is `400`), and sets the window, locale
1196
+ * and time zone itself (`viewport`, `locale`, `timezone`, `user_agent` and `block_resources` are `400`).
1197
+ */
1198
+ export type StealthOption =
1199
+ | boolean
1200
+ | {
1201
+ /**
1202
+ * An identity to reuse. Omitted: the profile's identity when `profile` names one that has one, else a new identity.
1203
+ */
1204
+ identity?: string;
1205
+ /**
1206
+ * The identity's home region, a country (`US`) or a country and a subdivision (`us-ny`). Omitted: the identity's, else where the exit is. The time zone and locale always follow where the exit actually is; a session whose exit is elsewhere carries the `exit_region_changed` warning.
1207
+ */
1208
+ region?: string;
1209
+ /**
1210
+ * Act steps (click, hover, type, key and scroll) send their input through the browser's own screen, shaped like a person's: pointer paths, key presses with their timing, wheel scrolling. A target out of view is reached with the wheel, never scrolled to by script while the wheel can reach it. Slower: a click takes hundreds of milliseconds. `false`: the default session's input.
1211
+ * @default true
1212
+ */
1213
+ humanize?: boolean;
1214
+ };
1215
+
1216
+ /** What a stealth session's browser presents and where it leaves from. */
1217
+ export interface SessionStealth {
1218
+ identity: string;
1219
+ persona: {
1220
+ os: "linux";
1221
+ browser: "chrome";
1222
+ /** The running browser's major version. */
1223
+ major: number;
1224
+ screen: string;
1225
+ locale: string;
1226
+ timezone: string;
1227
+ /**
1228
+ * The GPU its browser reports (WebGL's unmasked renderer names it), for an identity of persona catalog 2 or later. Absent: an earlier identity, whose browser keeps a software renderer.
1229
+ */
1230
+ gpu?: string;
1231
+ };
1232
+ exit: {
1233
+ /** `byo`: your proxy. `direct`: the node's address. */
1234
+ class: "byo" | "direct";
1235
+ /** Where the exit is (ISO 3166-1 alpha-2), as measured when the session started. */
1236
+ country?: string;
1237
+ region?: string;
1238
+ };
1239
+ /** The stealth engine's stage (1 today). */
1240
+ stage: number;
1241
+ /**
1242
+ * What undoes part of stealth and B3OS cannot fix on its side: `exit_direct` (the node's address, a datacenter range), `exit_region_changed` (the exit is outside the identity's home region), `client_runtime_enable` (a CDP client enabled the `Runtime` domain on a page, which pages can observe).
1243
+ */
1244
+ warnings: string[];
1245
+ }
1246
+
1247
+ export interface StealthAudit {
1248
+ object: "stealth_audit";
1249
+ session_id: string;
1250
+ /**
1251
+ * In order. Every line has `t` (RFC 3339) and `kind`: `open`, `connection`, `navigation`, `challenge`, `refused`, `warning`, `act` or `close`, and the members of its kind.
1252
+ */
1253
+ lines: {
1254
+ t: string;
1255
+ kind: string;
1256
+ [key: string]: unknown;
1257
+ }[];
1258
+ }
1259
+
1260
+ /**
1261
+ * A stealth identity: what a stealth session's browser presents (drawn once and kept, so every session that uses it presents the same), its home region, and how it was used. It holds no cookies and no secret.
1262
+ */
1263
+ export interface StealthIdentity {
1264
+ id: string;
1265
+ object: "stealth_identity";
1266
+ state: "active" | "retired";
1267
+ persona: {
1268
+ /** The persona catalog's version it was drawn from. */
1269
+ catalog: number;
1270
+ os: "linux";
1271
+ browser: "chrome";
1272
+ /** The screen in CSS pixels. */
1273
+ screen: string;
1274
+ device_scale_factor: number;
1275
+ window: {
1276
+ x: number;
1277
+ y: number;
1278
+ width: number;
1279
+ height: number;
1280
+ maximized: boolean;
1281
+ };
1282
+ /** The font families its browser sees. */
1283
+ fonts: string[];
1284
+ /**
1285
+ * The GPU its browser reports (WebGL's unmasked renderer names it), from persona catalog 2 on: an Intel integrated GPU named as Linux's Mesa driver names it. Absent for a catalog 1 identity, whose browser keeps a software renderer.
1286
+ */
1287
+ gpu?: string;
1288
+ /**
1289
+ * How its desktop renders text, from persona catalog 3 on: fontconfig's hinting style, whether the autohinter is on, and the families the CSS generic families resolve to. Canvas text follows them. Absent for an earlier identity, whose desktop keeps the image's defaults.
1290
+ */
1291
+ font_rendering?: {
1292
+ hinting: "hintslight" | "hintfull" | "hintnone";
1293
+ autohint: boolean;
1294
+ sans_serif: string;
1295
+ serif: string;
1296
+ monospace: string;
1297
+ };
1298
+ };
1299
+ /** `us` or `us-ny`; `null` until a session names one or its first exit sets it. */
1300
+ home_region: string | null;
1301
+ /** Stealth sessions that used it. */
1302
+ sessions: number;
1303
+ created_at: string;
1304
+ last_used_at: string | null;
1305
+ retired_at: string | null;
1149
1306
  }
1150
1307
 
1308
+ export type StealthIdentityList = Omit<ListEnvelope, "data"> & {
1309
+ data: StealthIdentity[];
1310
+ };
1311
+
1312
+ /**
1313
+ * Where a session's browser runs: `process`, a browser of the node's pool (one browser per session, never shared); `microvm`, a microVM of its own.
1314
+ */
1315
+ export type SessionIsolation = "process" | "microvm";
1316
+
1151
1317
  export interface SessionTimeline {
1152
1318
  object: "session_timeline";
1153
1319
  session_id: string;
@@ -1253,12 +1419,17 @@ export interface BrowserSession {
1253
1419
  * Why the session closed; `null` while it is active. `deleted`: `DELETE`. `expired`: its timeout.
1254
1420
  * `browser_exited`: its browser stopped under it. `node_restart`: the node stopped or restarted while the
1255
1421
  * session was open; browser time is billed up to the stop and not after it (nothing when the node did not
1256
- * stop cleanly, since it cannot tell when the browser stopped). Closed sessions stay readable for 7 days.
1422
+ * stop cleanly, since it cannot tell when the browser stopped). `stealth_revoked`: a stealth session whose
1423
+ * organization lost the `vision.stealth` flag or its acceptance of the stealth terms. Closed sessions stay
1424
+ * readable for 7 days.
1257
1425
  */
1258
- closed_reason?: "deleted" | "expired" | "browser_exited" | "node_restart" | null;
1426
+ closed_reason?: "deleted" | "expired" | "browser_exited" | "node_restart" | "stealth_revoked" | null;
1259
1427
  timeout_s: number;
1260
1428
  viewport: Viewport;
1261
1429
  browser: BrowserEngine;
1430
+ isolation: SessionIsolation;
1431
+ /** Present on stealth sessions only. */
1432
+ stealth?: SessionStealth;
1262
1433
  /** The loaded profile, or `null`. */
1263
1434
  profile: null | SessionProfileRef;
1264
1435
  /** WebSocket URL of the session's CDP endpoint. */
@@ -1380,7 +1551,9 @@ export interface ActKey {
1380
1551
  settle?: ActSettle;
1381
1552
  }
1382
1553
 
1383
- /** Scroll to an offset (`to`), by a delta (`by`), or until `target` is in view. */
1554
+ /**
1555
+ * Scroll to an offset (`to`), by a delta (`by`), or until `target` is in view. In a stealth session with `humanize`, the wheel turns until `target` is in view, and `by` or `to` with a target then turn the wheel at it: what a wheel there scrolls (the target when it scrolls, else its nearest scroll container, else the page) moves by `by`, or to `to` in its own offsets.
1556
+ */
1384
1557
  export interface ActScroll {
1385
1558
  kind: "scroll";
1386
1559
  target?: ActTarget;
@@ -1605,6 +1778,10 @@ export interface Profile {
1605
1778
  * Whether GET /v1/vision/profiles/{id}/state exports the state. True when the current state was uploaded; false when a B3OS browser session saved it: such state still loads into the organization's sessions, scrapes and render jobs, but the state route answers 403 profile_not_exportable. The flag governs that route only: a session's CDP client with vision:profiles:export reads the cookies of a profile the session loaded, and scripts in its pages read what the page's own scripts can. An upload makes a profile exportable again.
1606
1779
  */
1607
1780
  exportable: boolean;
1781
+ /**
1782
+ * The stealth identity bound to this profile: a stealth session that loaded the profile with persist_profile saved it here, and later stealth sessions that load the profile use it unless they name another. Absent on a profile no stealth session saved.
1783
+ */
1784
+ identity?: string;
1608
1785
  /** Owning org. Returned to the owner only; tenancy is checked on every access. */
1609
1786
  org?: string;
1610
1787
  project?: string;
@@ -4221,7 +4398,7 @@ export type RenderBackgroundPackList = Omit<ListEnvelope, "data"> & {
4221
4398
  };
4222
4399
 
4223
4400
  /**
4224
- * `running` → `paused` ↔ `running` → `stopped`. `failed` means the microVM crashed; its usage is final. `hibernated` is an agent instance's microVM written to the node's disk with no process left (only agent instances, `/v1/agents`): its memory snapshot, which a message to its instance or a request to its port restores in place, or its disk alone (dormant), which a message to its instance boots. It is never listed.
4401
+ * `running` → `paused` ↔ `running` → `stopped`. `failed` means the microVM crashed; its usage is final. `hibernated` is a microVM written to the node's disk with no process left. For an agent instance (`/v1/agents`), never listed: its memory snapshot, which a message to its instance or a request to its port restores in place, or its disk alone (dormant), which a message to its instance boots. For a project's service that holds a lease, listed, with `restore`: its microVM ended without anyone asking (a node restart or release, a lost VM), and the node boots it again in place from its kept disk, with the same ID, volume and lease; a request to its port answers 503 `sandbox_restoring` meanwhile.
4225
4402
  */
4226
4403
  export type SandboxStatus = "running" | "paused" | "stopped" | "failed" | "hibernated";
4227
4404
 
@@ -4332,7 +4509,8 @@ export interface EgressPolicy {
4332
4509
  export interface SandboxCreateRequest {
4333
4510
  /**
4334
4511
  * Template name or `tpl_` ID: a node template (`GET /v1/sandboxes/templates`) or one of your project's
4335
- * image templates (an image's `template`). Ignored when `snapshot` is set.
4512
+ * image templates (an image's `template`, or its `name`; a name of an image that is not `ready` answers
4513
+ * `409 image_not_ready`). Node templates are looked up first. Ignored when `snapshot` is set.
4336
4514
  * @default "base"
4337
4515
  */
4338
4516
  template?: string;
@@ -4425,6 +4603,17 @@ export interface SandboxCreateRequest {
4425
4603
  * volume is free for the next sandbox once the microVM has exited.
4426
4604
  */
4427
4605
  volumes?: VolumeAttach[];
4606
+ /**
4607
+ * A workspace branch to mount (`POST /v1/workspaces`), at most one in this beta. Behind the `workspaces.api`
4608
+ * flag: `403 feature_not_enabled` while it is off for your organization. The branch's head is mounted at
4609
+ * `path` as a copy-on-write folder: the base files are shared and read-only underneath, and what the sandbox
4610
+ * writes there is the branch's change set, kept on the sandbox's disk until it is committed. Commands see
4611
+ * `B3OS_WORKSPACE_ID`, `B3OS_BRANCH_ID` and `B3OS_WORKSPACE_PATH`. Holding a protected branch (`main`) needs
4612
+ * `workspaces:write`, any other branch `workspaces:run`. A branch with no commit yet is `422
4613
+ * workspace_invalid` (reason `empty`). In this beta a sandbox with a workspace cannot be snapshotted (`409
4614
+ * conflict`), and `snapshot` and `forkable: true` are refused with it (`400 invalid_request`).
4615
+ */
4616
+ workspaces?: SandboxWorkspaceAttach[];
4428
4617
  owner?: SandboxOwner;
4429
4618
  metadata?: Metadata;
4430
4619
  }
@@ -4440,6 +4629,37 @@ export interface VolumeAttach {
4440
4629
  owner?: string;
4441
4630
  }
4442
4631
 
4632
+ export interface SandboxWorkspaceAttach {
4633
+ /** The workspace's `ws_` ID. */
4634
+ workspace: string;
4635
+ /**
4636
+ * An open branch's `br_` ID or name, or `new` (a new ephemeral branch from `from`).
4637
+ * @default "new"
4638
+ */
4639
+ branch?: string;
4640
+ /**
4641
+ * Where a new branch starts: a branch name or ID, or a `cmt_` commit ID; `main` when unset. Only with a new
4642
+ * branch (`400 invalid_request` otherwise).
4643
+ */
4644
+ from?: string;
4645
+ /**
4646
+ * Where the branch appears in the sandbox: absolute, and not a system folder or under one (the rules of a
4647
+ * volume mount's `path`); never overlapping a volume mount.
4648
+ * @default "/workspace"
4649
+ */
4650
+ path?: string;
4651
+ }
4652
+
4653
+ export interface SandboxWorkspace {
4654
+ workspace_id: string;
4655
+ branch_id: string;
4656
+ /** `ephemeral/<branch_id>` for a branch the create made. */
4657
+ branch_name: string;
4658
+ /** The commit the sandbox's base files are (the branch's head when the sandbox was created). */
4659
+ commit_id: string;
4660
+ path: string;
4661
+ }
4662
+
4443
4663
  export interface VolumeMount {
4444
4664
  /**
4445
4665
  * Where the folder appears in the sandbox: absolute, not `/`, not a system folder or under one (`/proc`,
@@ -4672,6 +4892,7 @@ export interface Sandbox {
4672
4892
  * running and renews its `expires_at` itself. `null` when it never held one. Always sent by this node.
4673
4893
  */
4674
4894
  lease?: null | SandboxLease;
4895
+ restore?: SandboxRestore;
4675
4896
  /**
4676
4897
  * The processes the node supervises (an exec with `background: true` and `restart`), oldest first; empty
4677
4898
  * when there are none. Always sent by this node.
@@ -4679,6 +4900,8 @@ export interface Sandbox {
4679
4900
  supervised?: SupervisedProcess[];
4680
4901
  /** The volume the sandbox holds and where it is mounted; empty when none. Always sent by this node. */
4681
4902
  volumes?: SandboxVolume[];
4903
+ /** The workspace branch the sandbox holds and where it is mounted; present only when it holds one. */
4904
+ workspaces?: SandboxWorkspace[];
4682
4905
  options: SandboxOptions;
4683
4906
  owner?: SandboxOwner;
4684
4907
  /**
@@ -4727,6 +4950,13 @@ export interface LeaseRequest {
4727
4950
  * that already holds `key` answers 200 whatever this says.
4728
4951
  */
4729
4952
  expect_holder?: string | null;
4953
+ /**
4954
+ * The order the node boots the project's services again in place after it loses their microVMs (a node
4955
+ * restart or release): higher first, and a service waits up to 2 minutes while one of its project with a
4956
+ * higher priority is not running and ready yet, so a database comes back before the app that uses it.
4957
+ * Default 0. Sent again with the same `key`, it changes only the priority.
4958
+ */
4959
+ restore_priority?: number;
4730
4960
  }
4731
4961
 
4732
4962
  /** A sandbox's lease, held or ended. */
@@ -4743,6 +4973,49 @@ export interface SandboxLease {
4743
4973
  * one then stops within `sandboxes.lease_term`), or the sandbox's `stop_reason`.
4744
4974
  */
4745
4975
  end_reason: "released" | "replaced" | "deleted" | "timeout" | "failed" | "budget" | "revoked" | null;
4976
+ /** The lease's restore priority (`PUT …/lease`); 0 by default. */
4977
+ restore_priority?: number;
4978
+ }
4979
+
4980
+ /**
4981
+ * Present only for a project's service the node kept through the loss of its microVM: one that holds a lease
4982
+ * (`PUT …/lease`; not an agent instance, not started by another sandbox, no workspace, and `secrets` only as
4983
+ * connection references, which its boot reveals again while the edge says their creator still may). When its
4984
+ * microVM ends without anyone asking (a node restart or release, a VM lost while the node runs, a VM gone when
4985
+ * the node starts), the node keeps its disk and boots it again in place: the same ID (so its addresses need no
4986
+ * switch), its disk, its volume, its lease and its supervised processes, which start again. Boots back off 0,
4987
+ * 10, 60, 300 and 900 s; a boot whose VM is lost again within 10 minutes counts as failed; after 5 in a row the
4988
+ * node gives up and the sandbox ends `failed`. While it has no VM it bills no compute.
4989
+ */
4990
+ export interface SandboxRestore {
4991
+ /** Why its last microVM ended. */
4992
+ cause: "node_stop" | "vm_lost" | "vm_gone_at_start";
4993
+ /**
4994
+ * `clean`: the disk was copied after TERM to its supervised processes, its volume's release and a sync;
4995
+ * `crash`: copied while the guest ran or after its VM died, so writes the guest had not synced may be
4996
+ * missing (as after a power cut).
4997
+ */
4998
+ consistency: "clean" | "crash";
4999
+ state: "waiting" | "booting" | "booted" | "gave_up";
5000
+ /** When its last microVM ended. */
5001
+ since: string;
5002
+ /** Boots begun since its last run of 10 minutes. */
5003
+ attempts: number;
5004
+ /** When the next boot may begin; `null` while it boots, once booted, and once given up. */
5005
+ next_at: string | null;
5006
+ booted_at: string | null;
5007
+ /** When the node gave up booting it (the sandbox ended `failed`). */
5008
+ gave_up_at: string | null;
5009
+ /** Why the last boot failed, or why the node gave up. */
5010
+ last_error: string | null;
5011
+ /**
5012
+ * For a service with `secrets` (connection references), why the node did not reveal them again:
5013
+ * `restore_grant_revoked`, the edge said the principal that revealed them at its create no longer may (its
5014
+ * key revoked or expired, its user removed, its scopes cut, its application unlinked; the sandbox ends
5015
+ * `stopped`, `revoked`); `restore_grant_unknown`, the edge could not say, through every boot of the backoff
5016
+ * (it ends `failed`). The node never keeps a secret's value, only its reference.
5017
+ */
5018
+ reason?: "restore_grant_revoked" | "restore_grant_unknown" | null;
4746
5019
  }
4747
5020
 
4748
5021
  /** A background process the node starts again when it exits (an exec with `restart`). */
@@ -5088,6 +5361,239 @@ export type SnapshotList = Omit<ListEnvelope, "data"> & {
5088
5361
  data: Snapshot[];
5089
5362
  };
5090
5363
 
5364
+ /** How many more sandboxes of one shape would be created now, and the limits behind the count. */
5365
+ export interface SandboxCapacity {
5366
+ object: "sandbox_capacity";
5367
+ /** The template's name. */
5368
+ template: string;
5369
+ vcpu: number;
5370
+ memory_mib: number;
5371
+ /**
5372
+ * Creates of this shape that would pass now; the least of `org`, `desktops` (desktop templates only) and `node.room`.
5373
+ */
5374
+ room: number;
5375
+ /** The limit that refuses the next create when `room` is 0; `null` while a create would pass. */
5376
+ binding: "org_concurrency" | "desktops" | "node" | null;
5377
+ org: CapacityCount;
5378
+ desktops: CapacityCount;
5379
+ node: {
5380
+ /** Sandboxes of this shape waiting warm in the node's pool. */
5381
+ parked: number;
5382
+ /**
5383
+ * Sandboxes of this shape the memory left under the node's microVM memory limit holds, or 0 while the node's disk store is too full; `null` when the node cannot read the limit.
5384
+ */
5385
+ room: number | null;
5386
+ };
5387
+ /** When `room` is 0, how long to wait before trying again. */
5388
+ retry_after_s?: number;
5389
+ }
5390
+
5391
+ /**
5392
+ * Your organization's live sandboxes against one limit (`sandboxes.concurrent` or `sandboxes.desktops_concurrent`).
5393
+ */
5394
+ export interface CapacityCount {
5395
+ /** Running and paused sandboxes, and creates in flight. */
5396
+ running: number;
5397
+ limit: number;
5398
+ }
5399
+
5400
+ export interface Computer {
5401
+ object: "computer";
5402
+ display: {
5403
+ width: number;
5404
+ height: number;
5405
+ };
5406
+ cursor: ComputerPoint;
5407
+ /**
5408
+ * Who controls the desktop's input: `agent` (the computer-use operations) or `human` (a person who took over, which is not built yet). Always `agent` for now.
5409
+ */
5410
+ controller: "agent" | "human";
5411
+ }
5412
+
5413
+ /** A position on the screen, in pixels from the top left. */
5414
+ export interface ComputerPoint {
5415
+ x: number;
5416
+ y: number;
5417
+ }
5418
+
5419
+ export interface ComputerScreenshotOptions {
5420
+ /** @default "jpeg" */
5421
+ format?: "png" | "jpeg";
5422
+ /**
5423
+ * JPEG quality.
5424
+ * @default 80
5425
+ */
5426
+ quality?: number;
5427
+ }
5428
+
5429
+ /** Before the screenshot, wait until the screen has not changed for `quiet_ms`, at most `max_ms`. */
5430
+ export interface ComputerSettle {
5431
+ /** @default 80 */
5432
+ quiet_ms?: number;
5433
+ /** @default 1000 */
5434
+ max_ms?: number;
5435
+ }
5436
+
5437
+ export interface ComputerActRequest {
5438
+ /** Run in order. Their `wait` actions add up to at most 30,000 ms. */
5439
+ actions: ComputerAction[];
5440
+ /** A screenshot after the actions; `null` or left out for none. */
5441
+ screenshot?: ComputerScreenshotOptions | null;
5442
+ /** Wait for the screen to settle before the screenshot; `null` or left out for no wait. */
5443
+ settle?: ComputerSettle | null;
5444
+ }
5445
+
5446
+ /** One mouse or keyboard action; `action` selects it. */
5447
+ export type ComputerAction =
5448
+ | ComputerClick
5449
+ | ComputerMove
5450
+ | ComputerMouseDown
5451
+ | ComputerMouseUp
5452
+ | ComputerDrag
5453
+ | ComputerScroll
5454
+ | ComputerType
5455
+ | ComputerKey
5456
+ | ComputerKeyDown
5457
+ | ComputerKeyUp
5458
+ | ComputerWait
5459
+ | ComputerCursorPosition;
5460
+
5461
+ /** Pixels from the left (`x`) or the top (`y`); within the screen. */
5462
+ export type ComputerCoordinate = number;
5463
+
5464
+ export type ComputerButton = "left" | "right" | "middle";
5465
+
5466
+ /**
5467
+ * Click at `x`, `y` (both or neither; neither clicks at the pointer). `count` 2 is a double click, 3 a triple click.
5468
+ */
5469
+ export interface ComputerClick {
5470
+ action: "click";
5471
+ x?: ComputerCoordinate;
5472
+ y?: ComputerCoordinate;
5473
+ button?: ComputerButton;
5474
+ /** @default 1 */
5475
+ count?: number;
5476
+ }
5477
+
5478
+ /** Move the pointer. */
5479
+ export interface ComputerMove {
5480
+ action: "move";
5481
+ x: ComputerCoordinate;
5482
+ y: ComputerCoordinate;
5483
+ }
5484
+
5485
+ /** Press a button, at `x`, `y` or at the pointer, and hold it. */
5486
+ export interface ComputerMouseDown {
5487
+ action: "mouse_down";
5488
+ x?: ComputerCoordinate;
5489
+ y?: ComputerCoordinate;
5490
+ button?: ComputerButton;
5491
+ }
5492
+
5493
+ /** Release a button, at `x`, `y` or at the pointer. */
5494
+ export interface ComputerMouseUp {
5495
+ action: "mouse_up";
5496
+ x?: ComputerCoordinate;
5497
+ y?: ComputerCoordinate;
5498
+ button?: ComputerButton;
5499
+ }
5500
+
5501
+ /**
5502
+ * Press the button at the first point, move through the others and release at the last. The button is released if the drag fails part way.
5503
+ */
5504
+ export interface ComputerDrag {
5505
+ action: "drag";
5506
+ /** `[[x, y], ...]`, 2 to 64 points. */
5507
+ path: ComputerCoordinate[][];
5508
+ button?: ComputerButton;
5509
+ }
5510
+
5511
+ /** Turn the wheel `amount` clicks, at `x`, `y` or at the pointer. */
5512
+ export interface ComputerScroll {
5513
+ action: "scroll";
5514
+ x?: ComputerCoordinate;
5515
+ y?: ComputerCoordinate;
5516
+ direction: "up" | "down" | "left" | "right";
5517
+ /** @default 1 */
5518
+ amount?: number;
5519
+ }
5520
+
5521
+ /** Type the text, as a keyboard would (newline and tab included). The node logs its length only. */
5522
+ export interface ComputerType {
5523
+ action: "type";
5524
+ /** At most 8,192 bytes of UTF-8; no control characters other than newline, carriage return and tab. */
5525
+ text: string;
5526
+ }
5527
+
5528
+ /** Press and release a key or a chord of xdotool key names joined by `+`. */
5529
+ export interface ComputerKey {
5530
+ action: "key";
5531
+ keys: string;
5532
+ }
5533
+
5534
+ /** Press one key and hold it until `key_up` (or the end of a batch that fails). */
5535
+ export interface ComputerKeyDown {
5536
+ action: "key_down";
5537
+ key: string;
5538
+ }
5539
+
5540
+ /** Release a held key. */
5541
+ export interface ComputerKeyUp {
5542
+ action: "key_up";
5543
+ key: string;
5544
+ }
5545
+
5546
+ /** Wait */
5547
+ export interface ComputerWait {
5548
+ action: "wait";
5549
+ ms: number;
5550
+ }
5551
+
5552
+ /** Sends no input; the answer's `cursor` is the pointer's position. */
5553
+ export interface ComputerCursorPosition {
5554
+ action: "cursor_position";
5555
+ }
5556
+
5557
+ export interface ComputerActResult {
5558
+ object: "computer_actions";
5559
+ /** One per action, in order. */
5560
+ results: ComputerActionResult[];
5561
+ /** Where the pointer is after the actions; `null` when the X server went away during the batch. */
5562
+ cursor: ComputerPoint | null;
5563
+ /** The screenshot asked for; `null` when none was asked for or it could not be taken. */
5564
+ screenshot: ScreenshotData | null;
5565
+ /** How long the settle waited, ms; `null` without `settle`. */
5566
+ settled_ms: number | null;
5567
+ /** `quiet`: the screen stayed still for `quiet_ms`; `deadline`: `max_ms` passed first. */
5568
+ settled_by: "quiet" | "deadline" | null;
5569
+ /** Time inside the sandbox, ms. */
5570
+ timing: {
5571
+ act_ms: number;
5572
+ settle_ms: number;
5573
+ capture_ms: number;
5574
+ encode_ms: number;
5575
+ };
5576
+ }
5577
+
5578
+ export interface ComputerActionResult {
5579
+ ok: boolean;
5580
+ /**
5581
+ * Whether the action's input reached the X server. `delivered_unverified`: sent and synced; what the
5582
+ * application did with it is not checked. `delivery_uncertain`: part of it may have been sent.
5583
+ * `not_delivered`: nothing was sent (the action failed before its input, was skipped, or sends no input:
5584
+ * `wait`, `cursor_position`). `unknown`: the X server went away after the input was sent.
5585
+ */
5586
+ delivery: "delivered_verified" | "delivered_unverified" | "delivery_uncertain" | "not_delivered" | "unknown";
5587
+ /**
5588
+ * Whether sending the action again is safe. `safe`: nothing was sent, or the action does the same thing
5589
+ * twice (`move`, `wait`, `cursor_position`). `unsafe`: its input landed and a second send repeats it.
5590
+ * `unknown`: whether its input landed cannot be told.
5591
+ */
5592
+ retry: "safe" | "unsafe" | "unknown";
5593
+ /** Why the action failed; `null` when it did not. */
5594
+ error: string | null;
5595
+ }
5596
+
5091
5597
  export interface Template {
5092
5598
  id: string;
5093
5599
  object: "template";
@@ -5097,9 +5603,10 @@ export interface Template {
5097
5603
  runtimes: string[];
5098
5604
  /**
5099
5605
  * `cdp`: Chrome runs in the template's snapshot with DevTools on `127.0.0.1:9222` inside the sandbox; declare
5100
- * port 9222 to reach it through a port preview.
5606
+ * port 9222 to reach it through a port preview. `computer`: the sandbox has a screen, a mouse and a keyboard
5607
+ * that `/v1/sandboxes/{sandbox_id}/computer` reads and drives (the `desktop` template).
5101
5608
  */
5102
- capabilities: Array<"exec" | "files" | "pty" | "run_code" | "cdp">;
5609
+ capabilities: Array<"exec" | "files" | "pty" | "run_code" | "cdp" | "computer">;
5103
5610
  defaults: {
5104
5611
  vcpu: number;
5105
5612
  memory_mib: number;
@@ -5116,8 +5623,8 @@ export interface Template {
5116
5623
  }[];
5117
5624
  /**
5118
5625
  * `node`: one of the node's templates, the same for everyone. `project`: an imported image's template,
5119
- * which only its project sees and can start sandboxes from. An image template's `name` is its `tpl_` ID and
5120
- * it has one size (`size_classes` holds only the image's).
5626
+ * which only its project sees and can start sandboxes from. An image template's `name` is its image's
5627
+ * `name` when it has one, else its `tpl_` ID, and it has one size (`size_classes` holds only the image's).
5121
5628
  */
5122
5629
  owner: "node" | "project";
5123
5630
  /** The image this template was imported from (`owner: project`); `null` for node templates. */
@@ -5131,6 +5638,41 @@ export interface Template {
5131
5638
  agent_sha256?: string;
5132
5639
  }
5133
5640
 
5641
+ /**
5642
+ * Exactly one of `image` (an import) and `build` (a Dockerfile build); the rest as `POST /v1/images` takes it.
5643
+ */
5644
+ export type TemplateCreateRequest = {
5645
+ name?: ImageName;
5646
+ /** An image reference, as `ref` of `POST /v1/images` (`python:3.11-slim`); a private one needs `auth`. */
5647
+ image?: string;
5648
+ build?: ImageBuild;
5649
+ auth?: ImageRegistryAuth;
5650
+ warmup?: ImageWarmup;
5651
+ /** The size every sandbox from the template has. Default 1, at most your plan's `sandboxes.vcpu_max`. */
5652
+ vcpu?: number;
5653
+ /**
5654
+ * The memory every sandbox from the template has. Default 1024, at most your plan's `sandboxes.memory_max`.
5655
+ */
5656
+ memory_mib?: number;
5657
+ };
5658
+
5659
+ /**
5660
+ * A template made by `POST /v1/sandboxes/templates`: its image's template, from the image's start. Once the image is `ready`, `GET /v1/sandboxes/templates/{template}` returns the whole template.
5661
+ */
5662
+ export interface TemplateCreated {
5663
+ id: string;
5664
+ object: "template";
5665
+ /** The image's name, else `null` (then the template is started by its ID). */
5666
+ name: null | ImageName;
5667
+ status: ImageStatus;
5668
+ /** The image (`GET /v1/images/{image_id}?wait=30` until it is `ready`). */
5669
+ image: string;
5670
+ /** The image's flattened root file system, once stored. */
5671
+ rootfs_sha256: string | null;
5672
+ /** The image's key; the same request in this project answers this template. */
5673
+ key: string;
5674
+ }
5675
+
5134
5676
  export type TemplateList = Omit<ListEnvelope, "data"> & {
5135
5677
  data: Template[];
5136
5678
  };
@@ -5296,7 +5838,7 @@ export type SwarmEvent = JobEvent & {
5296
5838
  };
5297
5839
 
5298
5840
  /**
5299
- * `queued` (accepted, waiting for the queue), `pulling` (layers streaming into the unpacking microVM),
5841
+ * `queued` (accepted, waiting for the queue), `building` (a Dockerfile build running in its microVM), `pulling` (layers streaming into the unpacking microVM),
5300
5842
  * `flattening` (the last byte sent; waiting for the unpacker and the store), `warming` (the first boot, the
5301
5843
  * warm-up and the warm snapshot), `ready`. `rebuilding`: a node release changed the guest agent, kernel or
5302
5844
  * hypervisor, and the warm snapshot is being taken again (creates answer `409 image_not_ready` until it is
@@ -5305,6 +5847,7 @@ export type SwarmEvent = JobEvent & {
5305
5847
  */
5306
5848
  export type ImageStatus =
5307
5849
  | "queued"
5850
+ | "building"
5308
5851
  | "pulling"
5309
5852
  | "flattening"
5310
5853
  | "warming"
@@ -5322,14 +5865,35 @@ export interface ImageWarmup {
5322
5865
  commands: string[][];
5323
5866
  }
5324
5867
 
5325
- export interface ImageImportRequest {
5868
+ /**
5869
+ * The project's name for the image (`images.build`): `name[:tag]`, at most 64 characters in all, each part of
5870
+ * lowercase letters, digits, `.`, `_` and `-` and starting with a letter or a digit, the name not starting
5871
+ * with `tpl_`. The whole string is the name (`app` and `app:latest` are two names). `POST /v1/sandboxes
5872
+ * {"template": "<name>"}` starts from it in this project only; another project's name answers `404
5873
+ * template_not_found`. Unique among the project's images, never a node template's name (`base` nor
5874
+ * `base:v1`), and part of the image's key.
5875
+ */
5876
+ export type ImageName = string;
5877
+
5878
+ /**
5879
+ * An application, as its b3os.yaml `name` (`images.build`): on a request, the application asking for the image,
5880
+ * which then holds it (`held_by`) instead of keeping it until it is deleted (`kept`).
5881
+ */
5882
+ export type ImageAppName = string;
5883
+
5884
+ /** Exactly one of `ref` (an import) and `build` (a Dockerfile build). */
5885
+ export type ImageImportRequest = {
5326
5886
  /**
5327
5887
  * An image reference: `[registry/]repository[:tag|@sha256:digest]`. Without a registry it is Docker Hub
5328
5888
  * (`python:3.11-slim` is `registry-1.docker.io/library/python:3.11-slim`); without a tag or digest it is
5329
5889
  * `latest`. A tag is resolved to its digest once, when the import is accepted; the image keeps that digest.
5330
- * Public images only (no credentials).
5890
+ * A private image needs `auth`.
5331
5891
  */
5332
- ref: string;
5892
+ ref?: string;
5893
+ build?: ImageBuild;
5894
+ name?: ImageName;
5895
+ auth?: ImageRegistryAuth;
5896
+ app?: ImageAppName;
5333
5897
  warmup?: ImageWarmup;
5334
5898
  /** The size every sandbox from the image has. Default 1, at most your plan's `sandboxes.vcpu_max`. */
5335
5899
  vcpu?: number;
@@ -5337,6 +5901,72 @@ export interface ImageImportRequest {
5337
5901
  * The memory every sandbox from the image has. Default 1024, at most your plan's `sandboxes.memory_max`.
5338
5902
  */
5339
5903
  memory_mib?: number;
5904
+ };
5905
+
5906
+ /**
5907
+ * A private registry's credential, from the vault (with the `images.build` flag; an import only, not a build).
5908
+ * `connection` names a connection of this project of type `basic`: `username`, and the password or an access
5909
+ * token in `password` (a Docker Hub or GitHub personal access token with read access to the image). Its
5910
+ * `hosts` must list the registry and the registry's token service: `registry-1.docker.io` and `auth.docker.io`
5911
+ * (or `*.docker.io`) for Docker Hub, `ghcr.io` for GHCR.
5912
+ *
5913
+ * The node reads the connection when the import is accepted, as your credential (it needs `vault:run`), keeps
5914
+ * it in memory for that one import, and sends it only in the Basic `Authorization` header of the token request
5915
+ * the registry's `WWW-Authenticate: Bearer` challenge names, over https, to a host the connection lists. It is
5916
+ * never logged, never put into an error, the image or its key, and never reaches a microVM; the tokens it earns
5917
+ * are used by that import only. Registries that only take Basic credentials on every request (no token
5918
+ * service) are not supported yet.
5919
+ *
5920
+ * The key does not name the connection: the same image pulled with another of the project's connections is the
5921
+ * same image.
5922
+ */
5923
+ export interface ImageRegistryAuth {
5924
+ /** A `basic` connection of this project, bound to the registry's hosts. */
5925
+ connection: string;
5926
+ }
5927
+
5928
+ export interface ImageContext {
5929
+ object: "image_context";
5930
+ sha256: string;
5931
+ bytes: number;
5932
+ /** When the tar goes, unless it is uploaded again or a build names it first. */
5933
+ expires_at: string;
5934
+ }
5935
+
5936
+ export interface ImageContextPart {
5937
+ /** A tar this project uploaded with `PUT /v1/images/contexts/{sha256}` (kept 24 hours). */
5938
+ sha256: string;
5939
+ /**
5940
+ * The folder of the build context the tar is unpacked into, relative (no `..`, no leading `/`); empty for the context's root.
5941
+ * @default ""
5942
+ */
5943
+ at?: string;
5944
+ }
5945
+
5946
+ /**
5947
+ * A Dockerfile build. The context is one or more uploaded tars, unpacked in order inside the build microVM
5948
+ * (never on the host); the Dockerfile is a file of the context. The build runs BuildKit's Dockerfile frontend
5949
+ * as root inside a microVM of its own, with the public internet through B3OS's egress guard and no secrets,
5950
+ * for `linux/amd64`, within 1,800 seconds; the result is flattened and becomes a template as an import does.
5951
+ * The same request in the same project (the same context bytes, Dockerfile path, arguments and target) answers
5952
+ * the image it already built; a base image tag that moved since is not pulled again unless `no_cache` is set.
5953
+ */
5954
+ export interface ImageBuild {
5955
+ context: ImageContextPart[];
5956
+ /**
5957
+ * The Dockerfile's path in the context, relative.
5958
+ * @default "Dockerfile"
5959
+ */
5960
+ dockerfile?: string;
5961
+ /** Build arguments (`ARG`). Part of the key; not secret (they are in the image's history). */
5962
+ args?: Record<string, string>;
5963
+ /** The stage to build (`--target`), else the last. */
5964
+ target?: string | null;
5965
+ /**
5966
+ * Build again even when this project already has the image of this request.
5967
+ * @default false
5968
+ */
5969
+ no_cache?: boolean;
5340
5970
  }
5341
5971
 
5342
5972
  /**
@@ -5371,13 +6001,15 @@ export interface ImagePackage {
5371
6001
 
5372
6002
  /**
5373
6003
  * Milliseconds each finished stage took (`null` until it finishes): `resolve` (the reference to a digest,
5374
- * before the answer), `queue` (waiting for a slot), `pull_flatten` (pulling and unpacking, which overlap),
6004
+ * before the answer; `null` for a build), `queue` (waiting for a slot), `build` (a Dockerfile build, `null` for an
6005
+ * import), `pull_flatten` (pulling and unpacking, which overlap; for a build, unpacking its result),
5375
6006
  * `adopt` (checking and storing the file system), `golden` (the first boot, warm-up and warm snapshot), and
5376
6007
  * `total`.
5377
6008
  */
5378
6009
  export interface ImageStagesMs {
5379
6010
  resolve: number | null;
5380
6011
  queue: number | null;
6012
+ build: number | null;
5381
6013
  pull_flatten: number | null;
5382
6014
  adopt: number | null;
5383
6015
  golden: number | null;
@@ -5387,19 +6019,41 @@ export interface ImageStagesMs {
5387
6019
  export interface ImageError {
5388
6020
  /** `import_failed`. */
5389
6021
  code: string;
5390
- stage: "resolve" | "pull" | "flatten" | "adopt" | "golden" | "rebuild" | "interrupted";
6022
+ stage: "resolve" | "build" | "pull" | "flatten" | "adopt" | "golden" | "rebuild" | "interrupted";
5391
6023
  detail: string;
5392
6024
  /** The last 4 KiB of the unpacker's or the warm-up's output, when there was any. */
5393
6025
  output: string | null;
5394
6026
  }
5395
6027
 
6028
+ export interface ImageBuildSource {
6029
+ context: {
6030
+ sha256: string;
6031
+ at: string;
6032
+ bytes: number;
6033
+ }[];
6034
+ dockerfile: string;
6035
+ args: Record<string, string>;
6036
+ target: string | null;
6037
+ /** The base images the build pulled, by reference and digest, once it ran. */
6038
+ base_images: {
6039
+ ref: string;
6040
+ digest: string;
6041
+ }[];
6042
+ }
6043
+
5396
6044
  export interface Image {
5397
6045
  id: string;
5398
6046
  object: "image";
5399
- /** The reference as given. */
5400
- ref: string;
5401
- /** The `linux/amd64` image manifest's digest. */
5402
- digest: string;
6047
+ /** The reference as given; `null` for a build. */
6048
+ ref: string | null;
6049
+ /** The build request, for an image built from a Dockerfile; `null` for an import. */
6050
+ build: null | ImageBuildSource;
6051
+ /** The project's name for the image (`images.build`), else `null`. */
6052
+ name: null | ImageName;
6053
+ /**
6054
+ * The `linux/amd64` image manifest's digest: the imported one, or for a build the one BuildKit produced (`null` until the build finishes).
6055
+ */
6056
+ digest: string | null;
5403
6057
  /** The index (multi-platform list) the manifest was picked from, when the reference named one. */
5404
6058
  index_digest: string | null;
5405
6059
  platform: "linux/amd64";
@@ -5419,7 +6073,9 @@ export interface Image {
5419
6073
  vcpu: number;
5420
6074
  memory_mib: number;
5421
6075
  };
5422
- /** The import key (sha256); an import with the same key in this project returns this image. */
6076
+ /**
6077
+ * The import key (sha256), over the image's source, warm-up, size, name and the node's build inputs; an import with the same key in this project returns this image.
6078
+ */
5423
6079
  key: string;
5424
6080
  stages_ms: ImageStagesMs;
5425
6081
  /** Compressed layer bytes pulled from the registry. */
@@ -5437,16 +6093,61 @@ export interface Image {
5437
6093
  error: null | ImageError;
5438
6094
  created_at: string;
5439
6095
  ready_at: string | null;
6096
+ /**
6097
+ * The applications (b3os.yaml `name`) that hold the image: each asked for it with `app`, or runs a sandbox from it. Empty for an image only ever asked for without `app`.
6098
+ */
6099
+ held_by: ImageAppName[];
6100
+ /**
6101
+ * Asked for without `app` at least once (an import, a template, an E2B build, or any image from before holds): kept until you delete it. An image that is not kept goes once no application holds it and nothing uses it.
6102
+ */
6103
+ kept: boolean;
5440
6104
  }
5441
6105
 
5442
- export type ImageList = Omit<ListEnvelope, "data"> & {
5443
- data: Image[];
5444
- };
6106
+ /** An application's hold on an image, released (`POST /v1/images/{image_id}/release`). */
6107
+ export interface ImageRelease {
6108
+ object: "image_release";
6109
+ image: string;
6110
+ app: ImageAppName;
6111
+ /** The image is gone (deleted as `DELETE /v1/images/{image_id}` deletes it). */
6112
+ removed: boolean;
6113
+ /** The applications that still hold it. */
6114
+ held_by: ImageAppName[];
6115
+ /** It is kept until deleted (asked for without `app` at least once), so it stays. */
6116
+ kept: boolean;
6117
+ /**
6118
+ * A running, paused or hibernated sandbox, or a snapshot, uses its template, so it stays; once nothing does and nothing holds or keeps it, the node removes it.
6119
+ */
6120
+ in_use: boolean;
6121
+ }
5445
6122
 
5446
- /** An instance's key, stored and shown as written, so never a credential or a personal detail. */
5447
- export type AgentInstanceKey = string;
6123
+ export interface ImageReleaseRequest {
6124
+ app: ImageAppName;
6125
+ }
6126
+
6127
+ /** Lines of an image's build log. */
6128
+ export interface ImageLog {
6129
+ object: "image_log";
6130
+ /** The image ID (`img_…`). */
6131
+ image: string;
6132
+ status: ImageStatus;
6133
+ /** The log's lines from `offset`, without their line ends. */
6134
+ lines: string[];
6135
+ /** The `offset` of the next read. */
6136
+ next_offset: number;
6137
+ }
6138
+
6139
+ export type ImageList = Omit<ListEnvelope, "data"> & {
6140
+ data: Image[];
6141
+ };
6142
+
6143
+ /** An instance's key, stored and shown as written, so never a credential or a personal detail. */
6144
+ export type AgentInstanceKey = string;
5448
6145
 
5449
- /** Lowercase letters, digits and `-`, starting with a letter. `sessions` is reserved. */
6146
+ /**
6147
+ * Lowercase letters, digits and `-`, starting with a letter. `sessions`, `harnesses`, `grants`, `self` and
6148
+ * `recipes` are reserved: they are path segments under `/v1/agents`, or will be (`recipes`, for shared harness
6149
+ * definitions).
6150
+ */
5450
6151
  export type AgentName = string;
5451
6152
 
5452
6153
  /**
@@ -5525,10 +6226,1169 @@ export interface AgentTurns {
5525
6226
  redeliver?: boolean;
5526
6227
  }
5527
6228
 
5528
- export interface AgentCreateRequest {
6229
+ /**
6230
+ * Which harness. The open-source ones come first: `opencode` (MIT; its server takes steers, queued prompts and
6231
+ * permission answers, with a TUI that attaches to the same server), `codex` (OpenAI's Codex CLI, Apache-2.0)
6232
+ * and `pi` (Earendil's pi coding agent, MIT); then `claude-code` (Anthropic's Claude Code). Each is driven by a
6233
+ * driver built into the shim, and what each takes (providers, sign-ins, a model the node serves, modes, lists)
6234
+ * is its entry in `GET /v1/agents/harnesses`, which lists the ones this node runs. Or `acp`, a harness your
6235
+ * organization brings that speaks the Agent Client Protocol over stdio, named in the block's `acp` (planned,
6236
+ * after prepared snapshots, for your organization's own use; refused with `422 harness_capability_unsupported`
6237
+ * until the shim serves it).
6238
+ */
6239
+ export type AgentHarnessKindName = "opencode" | "codex" | "pi" | "claude-code" | "acp";
6240
+
6241
+ /**
6242
+ * A coding agent people already use, run unmodified as the agent's harness (planned: not served on the beta
6243
+ * node yet; research/harnesses-design.md). The instance's entry is B3OS's shim, `b3os-harness serve`, which owns
6244
+ * the harness process, delivers turns into it, turns its hooks and stream into `harness.*` events, answers its
6245
+ * permission prompts and serves its terminal. What the node and the shim say to each other inside the instance
6246
+ * (the environment, `/run/b3os/harness.json`, the headers and the shim's routes) is
6247
+ * packages/spec/sidecars/harness.md.
6248
+ *
6249
+ * The block is a recipe: write it once, and deploy it as many agents and instances as you need. Its members are
6250
+ * settled at three times:
6251
+ *
6252
+ * - At prepare, what has to be fetched: `skills` and `plugins` from `git`, `npm` or `artifact`, and `mcp`
6253
+ * servers run from an npm package. The node installs them, with the harness at `version`, into a snapshot of
6254
+ * the `harness` template that it builds once per prepare key and shares across the project
6255
+ * (`Agent.harness_prepared`), so each instance starts with them in place. The key covers only that fetched
6256
+ * set, the kind, the version, the template and the shim, so editing any other member builds nothing again.
6257
+ * Until prepared snapshots ship, those sources answer `422 harness_setup_needs_prepare`.
6258
+ * - When an instance starts, what the shim writes and sets up: `instructions`, `settings`, `mcp` entries,
6259
+ * `skills` and `plugins` given as `text`, `files` or `builtin`, `files`, `mode`, `terminal`, and each
6260
+ * credential profile's directory.
6261
+ * - At each turn: `model`, `permissions`, `hooks` and the turn's credential profile.
6262
+ *
6263
+ * Until they are served on this node, three members are refused when the definition is written, even when
6264
+ * empty (`[]` or `{}`), with `422 harness_capability_unsupported`: `repo`, `context` and `acp` (`kind: acp`
6265
+ * with it). The node never stores them, so neither a stored block nor `/run/b3os/harness.json` carries them.
6266
+ * A vault connection outside a credential profile reaches the instance as a `B3OS_CONN_<N>` secret (below): a
6267
+ * remote `mcp` server's `connection` and a stdio server's `{connection}` `env` values. `repo.connection` waits
6268
+ * for `repo`. A `${...}` or `{env:...}` in a server's `url`, `command` or `env`, which Claude Code and opencode
6269
+ * would expand from the harness's environment, is `400 invalid_request`: name a connection instead.
6270
+ *
6271
+ * B3OS's own tools are default entries of the block's lists, not a switch. `mcp` starts with `b3os`, B3OS's MCP
6272
+ * server inside the instance (`{builtin: b3os, toolsets: [browser, vision, render, sandboxes, actions, infer]}`,
6273
+ * at `B3OS_MCP_URL`), and `skills` starts with `b3os`, the skill that says how to use them (`{builtin: b3os}`);
6274
+ * `GET /v1/agents/harnesses` lists both (`checks.defaults`). Your `mcp` and `skills` maps are a JSON merge patch
6275
+ * (RFC 7396) over those defaults, the rule the shim applies: an entry under a new name is added, an entry set
6276
+ * to `null` is removed, and an entry under a default's name is merged into the default member by member (a
6277
+ * member set to `null` is removed, an array replaces the default's whole). So `"mcp": {"b3os": {"toolsets":
6278
+ * ["vision"]}}` keeps only the page tools without restating `builtin`, and `"mcp": {"b3os": null}, "skills":
6279
+ * {"b3os": null}` leaves the harness its own tools only. `plugins` has no default. The grant the node fills in
6280
+ * comes with the merged `b3os` MCP entry: the scopes its toolsets need, scoped to the instance
6281
+ * (`AgentHarnessMcpBuiltin`); without that entry the filled `api` carries no B3OS MCP tool scopes (only
6282
+ * `infer:run` if a `node` profile is present, and nothing otherwise). A model the node serves is reached
6283
+ * through the `model` or a `node` profile you pick, not through these entries. Every node carries the
6284
+ * defaults; a toolset a node does not serve is left out of the server's tools. A default is added only where
6285
+ * the kind takes its list (the kind's `setup` in `GET /v1/agents/harnesses`), and both default entries are
6286
+ * builtins of the `harness` template, so they change no prepare key.
6287
+ *
6288
+ * The stored block keeps `mcp` and `skills` as you wrote them, never merged: your own entries and patches, a
6289
+ * removed default kept as `null`, `{}` when you gave none. So a block that is read and sent back changes
6290
+ * nothing, and the shim, which merges once at start, sees the same maps you wrote. The merged lists are those
6291
+ * maps merged over `checks.defaults`, and the filled `api` shows the grant they bring.
6292
+ *
6293
+ * The node fills the rest of the definition from this block: `source.template` (the `harness` template, which
6294
+ * pins each harness's versions) and `source.snapshot` (the revision's prepared snapshot, once prepared
6295
+ * snapshots ship and it is built), `entry` (`b3os-harness serve --config /run/b3os/harness.json` on port 7801,
6296
+ * ready when that port answers, `max_restarts` 5), `secrets` (beside your own: each `key` profile's
6297
+ * credentials, as `B3OS_PROFILE_<NAME>__<VAR>`, and the secret of every other connection the block names, as
6298
+ * `B3OS_CONN_<N>`, which the file maps to its member: `repo`, a remote `mcp` server's `connection`, a stdio
6299
+ * server's `{connection}` values), `api` (the scopes that come with the `b3os` MCP entry, plus `infer:run`
6300
+ * when a `node` profile is present, and nothing without either), `egress` and `turns.timeout_s` (3,600
6301
+ * seconds, the most a turn may take). The shim writes each connection's secret where its member says (the
6302
+ * instance's git credentials, the harness's MCP config, as a variable the config refers to) and keeps every
6303
+ * `B3OS_*` variable out of the harness's processes and its terminal except the ones B3OS gives every sandbox
6304
+ * (`B3OS_API_URL`, `B3OS_SANDBOX_ID`, `B3OS_PROJECT`, `B3OS_PORT_BASE_PATH`, `B3OS_MCP_URL`, `B3OS_MODEL`,
6305
+ * `B3OS_WORKSPACE_ID`, `B3OS_BRANCH_ID`, `B3OS_WORKSPACE_PATH`): the profiles' values, the connections' secrets,
6306
+ * the shim's token, the flags and the instance's id never reach it. Set `api`,
6307
+ * `egress` or `turns` yourself to use your own instead. `source.vcpu`, `memory_mib` and `disk_gib` apply as
6308
+ * for any agent. `source.template`, `source.snapshot` and `entry` cannot be set beside `harness`, and neither
6309
+ * can an `env` or `secrets` name that starts with `B3OS_` (the node's and the shim's own) or that the kind's
6310
+ * shim sets or removes (`checks.kinds.<kind>.env_owned`) (`400 invalid_request`).
6311
+ *
6312
+ * `/run/b3os/harness.json` is this block as the node stored it, with exactly these changes and nothing else: it
6313
+ * leaves out `hooks.webhook` and `hooks.decide.url` (both calls leave from the node, so neither URL nor a
6314
+ * secret enters the instance) and every vault `connection` (a profile's values arrive as
6315
+ * `B3OS_PROFILE_<NAME>__<VAR>`, any other connection's as `B3OS_CONN_<N>`); each `node` profile gains
6316
+ * `base_url`, the node's infer inside the instance (`http://127.0.0.1:7700/v1/infer`); and `connections` maps
6317
+ * each member a secret goes to (`mcp.<name>`, `mcp.<name>.env.<VAR>`, and `repo` once it is served) to its
6318
+ * variable. It never holds a credential. packages/spec/sidecars/harness.md
6319
+ * lists every member and which the shim reads.
6320
+ *
6321
+ * The filled `egress` is an allowlist of exactly the hosts the block reaches from the instance: each `key` and
6322
+ * `signin` profile's provider hosts, from the kind's `auth.hosts` in `GET /v1/agents/harnesses` (a `{region}`
6323
+ * in one filled from the profile's `region`); each profile's `base_url` host; the `repo` host; and each remote
6324
+ * `mcp` server's host. A profile whose provider has no hosts in the catalog is `422
6325
+ * harness_capability_unsupported`. Your own `egress` must let the same hosts through (`public`, or an
6326
+ * `allowlist` that matches each one); one it does not is `400 invalid_request`, naming the host. B3OS itself is
6327
+ * reached inside the instance at `http://127.0.0.1:7700`, outside `egress`, and the `hooks.webhook` and
6328
+ * `hooks.decide` calls leave from the node, so neither host goes in the list. The hosts a stdio `mcp` server
6329
+ * reaches are not known to the node: list them in your own `egress`.
6330
+ *
6331
+ * No harness agent takes a plan's token. A name in `AgentHarnessPlanEnv` in `env`, `secrets`, an `mcp` server's
6332
+ * `env` or a `settings` `env` entry is `400 invalid_request`. A value holding a plan's token (`sk-ant-oat` or
6333
+ * `sk-ant-ort`) is `400 harness_plan_credential` wherever it is: any string in the stored definition (`env`,
6334
+ * `secrets`, this block's members, argv such as an `mcp` server's or `acp`'s `command`, `settings`, and every
6335
+ * skill, plugin and file), and the resolved value of every connection the definition names (each profile's,
6336
+ * `repo`'s, a remote `mcp` server's and a stdio server's `{connection}` values). The node checks when the
6337
+ * definition is written and again each time it makes an instance, so a connection changed later is refused
6338
+ * then.
6339
+ *
6340
+ * The block is part of the revision, as the rest of the definition is: a `PATCH` makes a new revision, and
6341
+ * `upgrade: on_wake` moves sleeping instances to it. A harness cannot change its own definition (`agents:write`
6342
+ * is granted only when named exactly), and what the recipe installs is read-only to the harness.
6343
+ */
6344
+ export interface AgentHarness {
6345
+ /**
6346
+ * Which harness. Default: `opencode`, which is open source and reaches the providers its catalog entry's
6347
+ * `auth.key` lists (Anthropic, OpenAI and OpenRouter, and through OpenRouter many others). Its driver was
6348
+ * checked live against opencode 2.4.2 and a real provider on 2026-11-28: `openai/gpt-4o-mini` through
6349
+ * OpenRouter, three turns, one of them running a shell tool, each reporting its usage and cost.
6350
+ */
6351
+ kind?: AgentHarnessKindName;
6352
+ /**
6353
+ * The harness's version, one of the kind's `versions` in `GET /v1/agents/harnesses`. Default: its
6354
+ * `default_version`. A version this node does not run is `422 harness_version_unavailable`.
6355
+ */
6356
+ version?: string;
6357
+ acp?: AgentHarnessAcp;
6358
+ auth?: AgentHarnessAuth;
6359
+ /**
6360
+ * The model, as the harness names it (opencode's `openrouter/openai/gpt-4o-mini`, Claude Code's
6361
+ * `claude-opus-5-5`), or a model the node's infer serves (`GET /v1/infer/models`), which the harness then
6362
+ * reaches on the node with no key, for a kind whose catalog entry has `auth.node: true`. A profile's own
6363
+ * `model` wins for that profile's turns. Default: the harness's own default.
6364
+ */
6365
+ model?: string;
6366
+ /**
6367
+ * What the harness may do without asking. `auto`: the microVM is the sandbox, so the harness runs in its
6368
+ * most autonomous mode (every tool allowed in opencode and pi, Codex's full access with approvals off,
6369
+ * Claude Code's `bypassPermissions`). `ask`: every permission prompt becomes `harness.permission.requested`
6370
+ * and the turn waits for `POST /v1/agents/{agent}/instances/{key}/decisions`; one nobody answers is denied
6371
+ * at the turn's timeout. `plan`: read-only tools only; every write is denied, and
6372
+ * `hooks.decide` is never called. In `auto` and `ask`, `hooks.decide` answers before a person.
6373
+ * @default "auto"
6374
+ */
6375
+ permissions?: "auto" | "ask" | "plan";
6376
+ /**
6377
+ * How the shim drives the harness. `api`: headless and structured (opencode's server, Codex's app-server,
6378
+ * pi's RPC mode, Claude Code's stream-json); the terminal holds a shell in the workspace. `terminal`: the
6379
+ * harness's own TUI holds the terminal and turns are pasted into it, so a person can type turns of their
6380
+ * own there. In `terminal` mode the events come from the harness's hooks, so a kind may report less there
6381
+ * (Claude Code's TUI sends no `harness.message`). The kind's `modes` in `GET /v1/agents/harnesses` lists
6382
+ * what it takes (`422 harness_capability_unsupported` otherwise), with these limits:
6383
+ *
6384
+ * - Codex and pi run in `api` only. pi's RPC process and its TUI cannot share one session file yet.
6385
+ * - opencode in `terminal` takes no `hooks.decide` outside `permissions: plan`: its TUI answers permission
6386
+ * prompts itself, and an "always" answered there would keep the webhook from seeing that tool again. The
6387
+ * kind's `capabilities.decide_modes` lists the modes where `hooks.decide` answers.
6388
+ * @default "api"
6389
+ */
6390
+ mode?: "api" | "terminal";
6391
+ /**
6392
+ * The repository cloned into the workspace. Not served yet: refused at write, even empty, with `422
6393
+ * harness_capability_unsupported` until the harness's shim clones it.
6394
+ */
6395
+ repo?: AgentHarnessRepo;
6396
+ /**
6397
+ * Appended to the harness's own system prompt, as written, when a harness session starts. Yours, so never
6398
+ * quoted.
6399
+ */
6400
+ instructions?: string;
6401
+ /**
6402
+ * Text added, as written, at each harness session's start (`session_start`) or before each turn
6403
+ * (`turn_start`); a resumed session does not get `session_start` again.
6404
+ * - `api` mode: it goes before the turn's own text in its prompt.
6405
+ * - `terminal` mode: it goes through the TUI's own hooks (Claude Code's SessionStart and UserPromptSubmit
6406
+ * `additionalContext`). A kind whose TUI the shim cannot reach is refused it there (`422
6407
+ * harness_capability_unsupported`); today that is opencode.
6408
+ *
6409
+ * Not served on the beta node yet: refused at write, even as `[]`, with `422 harness_capability_unsupported`.
6410
+ */
6411
+ context?: AgentHarnessContext[];
6412
+ /**
6413
+ * Skills (folders with a `SKILL.md`), by name, put where the harness reads them: Claude Code's skills
6414
+ * directory of each profile, Codex's extra skill roots. It starts with `b3os`, the builtin skill for B3OS's
6415
+ * tools; this map is a JSON merge patch over that default (`AgentHarness`): a new name is added and `null`
6416
+ * removes an entry. `b3os` takes only `{builtin: b3os}` or `null`. Stored as written. A kind whose `setup`
6417
+ * in `GET /v1/agents/harnesses` does not list `skills` gets no default, and a skill of yours there answers
6418
+ * `422 harness_capability_unsupported`.
6419
+ */
6420
+ skills?: Record<string, AgentHarnessSetupItem | null>;
6421
+ /**
6422
+ * Plugins, by name, in the kind's own plugin format: a Claude Code plugin directory (loaded with
6423
+ * `--plugin-dir`), a Codex plugin (installed from a local marketplace at prepare). There is no default
6424
+ * plugin. With `permissions: ask`, a
6425
+ * plugin whose hooks can answer a permission prompt (Claude Code's `PreToolUse` or `PermissionRequest`) is
6426
+ * `400 invalid_request`, since a person is the gate there; with `hooks.decide` it is allowed, because the
6427
+ * shim's own hook still runs on every tool and a deny wins. A kind whose `setup` does not list `plugins`
6428
+ * answers `422 harness_capability_unsupported`.
6429
+ */
6430
+ plugins?: Record<string, AgentHarnessSetupItem>;
6431
+ /**
6432
+ * MCP servers for the harness, by name, written into its own MCP config when the instance starts:
6433
+ * opencode's `mcp`, each profile's Codex `config.toml`, Claude Code's `--mcp-config` file (with
6434
+ * `--strict-mcp-config`, so a repository's own `.mcp.json` is not read), or an ACP harness's session. Each
6435
+ * is remote (`url`) or run in the instance (`command`). It starts with `b3os`, B3OS's own server
6436
+ * (`AgentHarnessMcpBuiltin`), which brings the instance's grant; this map is a JSON merge patch over that
6437
+ * default (`AgentHarness`): a new name is added, `null` removes an entry, and `"b3os": {"toolsets": [...]}`
6438
+ * narrows the default's toolsets without restating `builtin`. Stored as written. A kind whose `setup` does
6439
+ * not list `mcp` gets no default, and a server of yours there answers `422 harness_capability_unsupported`.
6440
+ */
6441
+ mcp?: {
6442
+ b3os?: AgentHarnessMcpBuiltin | null;
6443
+ [key: string]: unknown;
6444
+ };
6445
+ settings?: AgentHarnessSettings;
6446
+ /**
6447
+ * Files written into the workspace before the first harness session, after the repository is cloned
6448
+ * (`CLAUDE.md`, `AGENTS.md`). A file already at the path is replaced. Skills and plugins go in `skills` and
6449
+ * `plugins`.
6450
+ */
6451
+ files?: AgentHarnessFile[];
6452
+ hooks?: AgentHarnessHooks;
6453
+ terminal?: AgentHarnessTerminal;
6454
+ }
6455
+
6456
+ /**
6457
+ * A harness your organization brings, for `kind: acp` only (planned: it needs prepared snapshots, and it is for
6458
+ * your organization's own use). It speaks the Agent Client Protocol over stdio: the shim starts `command` as the
6459
+ * harness's user, opens a session with the block's `mcp` servers, sends each turn as a prompt and each cancel as
6460
+ * an interrupt, and answers the harness's permission requests through the same rules, `hooks.decide` and people
6461
+ * as any harness, allowing or rejecting each call once. The package is installed at prepare. An ACP harness
6462
+ * takes `key` and `node` profiles only, never `signin`; it is steered only when it implements B3OS's optional
6463
+ * `_b3os/steer` method (`422 harness_capability_unsupported` otherwise); and `hooks.decide` on
6464
+ * `harness.tool.requested` is refused, because the node cannot check that every tool call reaches a permission
6465
+ * request. With any other `kind` it is `400 invalid_request`.
6466
+ */
6467
+ export interface AgentHarnessAcp {
6468
+ npm: AgentHarnessNpmSource;
6469
+ /** The command that starts the harness in ACP mode, from the installed package. */
6470
+ command: string[];
6471
+ /** The environment variables the harness reads a `key` profile's key from. */
6472
+ key_env?: string[];
6473
+ }
6474
+
6475
+ /**
6476
+ * How the harness reaches its model: named credential profiles, so plans, subscriptions and API keys sit side by
6477
+ * side and each turn uses one of them. B3OS never collects, stores, reads or routes a plan's token: no member
6478
+ * takes one, a harness agent's `env`, `secrets`, `mcp` `env` and `settings` `env` refuse the variables a
6479
+ * harness reads one from (`AgentHarnessPlanEnv`), and a value holding one, in the definition or in a connection
6480
+ * it names, is `400 harness_plan_credential` (`AgentHarness`).
6481
+ *
6482
+ * - `{connection}` is shorthand for one `key` profile named `default`.
6483
+ * - Left out, with a `model` the node's infer serves, it is one `node` profile named `default`, for a kind
6484
+ * whose catalog entry has `auth.node: true` (`422 harness_capability_unsupported` for another); left out
6485
+ * with any other model, `400 invalid_request`.
6486
+ * - `{default, profiles}`: up to 8 named profiles (`AgentHarnessAuthProfile`). `default` is the profile a turn
6487
+ * uses when neither its message nor its conversation names one, and is required with more than one profile.
6488
+ *
6489
+ * The node stores the expanded form, so a read always shows `{default, profiles}`.
6490
+ *
6491
+ * A turn's profile is its message's `profile`, else the one its conversation used last, else `default`. A
6492
+ * caller only picks among the definition's profiles and never sends a credential with a turn. Profiles switch
6493
+ * between turns only, and a switch to another account starts without the provider's prompt cache. Each profile
6494
+ * has its own directory in the instance, so two sign-ins never share a file, and the harness's sessions are
6495
+ * shared across them, so a conversation goes on under another profile.
6496
+ *
6497
+ * A profile's `fallback` names the profile a conversation moves to when this one reaches a usage limit or is
6498
+ * refused. A fallback never moves into a `signin` profile, so a plan is only ever chosen by name, and it never
6499
+ * moves back by itself: `harness.auth.limited` carries `resets_at`, and you move back by naming the profile.
6500
+ * Errors the harness retries itself (a rate limit of the moment, a 5xx, an overload) never trigger one. Until a
6501
+ * kind's limit signal is checked against its pinned version, no fallback fires for it.
6502
+ */
6503
+ export type AgentHarnessAuth = AgentHarnessAuthConnection | AgentHarnessAuthProfiles;
6504
+
6505
+ /** Shorthand for `{default: default, profiles: {default: {type: key, connection}}}`. */
6506
+ export interface AgentHarnessAuthConnection {
6507
+ connection: string;
6508
+ }
6509
+
6510
+ export interface AgentHarnessAuthProfiles {
6511
+ default?: AgentHarnessProfileName;
6512
+ /**
6513
+ * The profiles by name. A `default` that names none of them, a `fallback` whose `to` names none of them or
6514
+ * a `signin` profile, and a cycle of fallbacks are `400 invalid_request`.
6515
+ */
6516
+ profiles: Record<string, AgentHarnessAuthProfile>;
6517
+ }
6518
+
6519
+ /**
6520
+ * A credential profile's name: 1 to 32 lowercase letters, digits and single `_`s, starting with a letter and
6521
+ * not ending with `_`. It goes into an environment variable's name, `B3OS_PROFILE_<NAME>__<VAR>`, where the
6522
+ * first `__` ends the name, so no two profiles and variables share one.
6523
+ */
6524
+ export type AgentHarnessProfileName = string;
6525
+
6526
+ /**
6527
+ * One credential: `key` (an API key or a cloud provider's credentials from your vault), `signin` (a person's own
6528
+ * plan, signed in inside their own instance) or `node` (a model the node serves). The kind's `auth` in
6529
+ * `GET /v1/agents/harnesses` says which it takes.
6530
+ */
6531
+ export type AgentHarnessAuthProfile = AgentHarnessAuthKey | AgentHarnessAuthSignin | AgentHarnessAuthNode;
6532
+
6533
+ /**
6534
+ * An API key, or a cloud provider's credentials, from a vault connection. The node puts its values in the
6535
+ * shim's environment as `B3OS_PROFILE_<NAME>__<VAR>`, and the shim gives them, under the names the harness reads
6536
+ * (the kind's `auth.key`), to this profile's harness processes only; opencode's one server holds every `key`
6537
+ * profile's. Until egress credential injection ships, code in the instance can read the key, as with an agent's
6538
+ * `secrets`; it needs `vault:run` and `vault:connections:reveal`. The provider bills the key's owner.
6539
+ */
6540
+ export interface AgentHarnessAuthKey {
6541
+ type: "key";
6542
+ connection: string;
6543
+ provider?: AgentHarnessKeyProvider;
6544
+ /**
6545
+ * For `anthropic_compatible` and `openai_compatible` only: the gateway the harness sends to. Its host
6546
+ * joins the filled `egress`.
6547
+ */
6548
+ base_url?: string;
6549
+ /** The cloud region, for `bedrock` and `vertex`. */
6550
+ region?: string;
6551
+ /** The model for this profile's turns, when it is not the block's `model`. */
6552
+ model?: string;
6553
+ /** A name for people (the console, the CLI, events). */
6554
+ label?: string;
6555
+ fallback?: AgentHarnessAuthFallback;
6556
+ }
6557
+
6558
+ /**
6559
+ * A person's own plan (a Claude or ChatGPT subscription), which that person signs in to inside their own
6560
+ * instance with the harness's own login, in the sign-in window (`GET …/terminal?window=signin:<profile>`). The
6561
+ * harness writes its credential file in this profile's directory, as it would on a laptop. B3OS never asks for
6562
+ * the token, never reads, stores or copies the file, and has no member to take one; the shim checks only that
6563
+ * the file exists, and asks the harness what it is signed in as (`harness.auth.ready`).
6564
+ *
6565
+ * A `signin` profile makes the agent personal (`Agent.owner`), whatever the provider: a person makes it, not a
6566
+ * key, and only its owner drives it, so one person uses each plan. Forks and children never carry a sign-in.
6567
+ * It needs a `provider` the kind's `auth.signin` lists (`422 harness_signin_unsupported`), and it is served
6568
+ * only on an instance made from the revision's prepared snapshot, which holds no other harness that could read
6569
+ * the file. A ChatGPT plan (`openai`) needs no flag. A Claude plan (`anthropic`) needs the
6570
+ * `agents.claude_plan_signin` flag, off by default and turned on per organization (`403
6571
+ * harness_claude_plan_signin_disabled` without it). The provider's terms for personal plans apply, and they
6572
+ * assume one person's ordinary use.
6573
+ *
6574
+ * Not served yet. Personal agents wait on two prerequisites, and until both land the node refuses every
6575
+ * `signin` profile with `403 harness_personal_agent`, whatever its provider and flag:
6576
+ *
6577
+ * - Harness agent VMs closed to the generic sandboxes API. Today any caller holding `sandboxes:run` in the
6578
+ * project can reach an agent's microVM by its `sandbox_id` (`GET /v1/sandboxes/{sandbox_id}`, exec, files,
6579
+ * logs and ports), and so read a sign-in's credential file and the shim's token. A personal agent's VMs (and,
6580
+ * once the node can, every harness agent's) answer those routes as a sandbox that does not exist, and
6581
+ * `AgentInstance.sandbox_id` is `null` for them.
6582
+ * - A person in the node's principal. A node token carries the organization, the project, the key, its scopes
6583
+ * and the request ID, and no person, so the node cannot tell an owner from anyone else in the project. The
6584
+ * edge's node tokens for dashboard sessions and CLI tokens gain the person (`usr`) and their organization
6585
+ * role, the claims workspaces asks for too.
6586
+ *
6587
+ * After both, a `signin` profile still waits for prepared snapshots (`422 harness_setup_needs_prepare` until
6588
+ * they ship).
6589
+ */
6590
+ export interface AgentHarnessAuthSignin {
6591
+ type: "signin";
6592
+ /**
6593
+ * `openai` (a ChatGPT plan) or `anthropic` (a Claude plan, behind `agents.claude_plan_signin`). The kind's
6594
+ * `auth.signin` in `GET /v1/agents/harnesses` lists which it signs in to: today Codex `openai` and Claude
6595
+ * Code `anthropic`, and opencode and pi none until their logins are checked on their pinned versions.
6596
+ */
6597
+ provider: "anthropic" | "openai";
6598
+ /** The model for this profile's turns, when it is not the block's `model`. */
6599
+ model?: string;
6600
+ /** A name for people (the console, the CLI, events). */
6601
+ label?: string;
6602
+ fallback?: AgentHarnessAuthFallback;
6603
+ }
6604
+
6605
+ /**
6606
+ * A model the node's infer serves (`GET /v1/infer/models`), reached inside the instance with no key, at the
6607
+ * `base_url` the node gives the shim (`http://127.0.0.1:7700/v1/infer`). It adds `infer:run` to the instance's
6608
+ * grant, and infer bills its tokens to your organization. Only for a kind whose catalog entry has `auth.node:
6609
+ * true` (`422 harness_capability_unsupported` otherwise): today Codex and Claude Code.
6610
+ */
6611
+ export interface AgentHarnessAuthNode {
6612
+ type: "node";
6613
+ model: string;
6614
+ /** A name for people (the console, the CLI, events). */
6615
+ label?: string;
6616
+ fallback?: AgentHarnessAuthFallback;
6617
+ }
6618
+
6619
+ /**
6620
+ * Whose API a `key` profile's credentials are for. Default: the connection's provider; the stored profile always
6621
+ * names it. Only a provider the kind's `auth.key` lists, with its hosts in `auth.hosts` (`422
6622
+ * harness_capability_unsupported` otherwise).
6623
+ */
6624
+ export type AgentHarnessKeyProvider =
6625
+ | "anthropic"
6626
+ | "openai"
6627
+ | "bedrock"
6628
+ | "vertex"
6629
+ | "foundry"
6630
+ | "azure_openai"
6631
+ | "openrouter"
6632
+ | "openai_compatible"
6633
+ | "anthropic_compatible";
6634
+
6635
+ /**
6636
+ * Where a conversation goes when this profile stops. The turn that stopped ends `harness.turn.failed`
6637
+ * (`error.code` `limit_reached` or `auth_required`), the shim marks the profile limited until its `resets_at`
6638
+ * (or until it checks again at the next turn) and sends `harness.auth.limited`, and the conversation moves to
6639
+ * `to` (`harness.auth.switched`). A chain follows each profile's own `fallback`. When every profile is limited,
6640
+ * the turn fails `no_profile_ready` with the earliest `resets_at`.
6641
+ */
6642
+ export interface AgentHarnessAuthFallback {
6643
+ to: AgentHarnessProfileName;
6644
+ /**
6645
+ * `limit`: a usage limit was reached or the credits ran out. `auth`: the credential was refused or expired.
6646
+ */
6647
+ on: Array<"limit" | "auth">;
6648
+ /**
6649
+ * `next_turn` (the default, chosen): the conversation's next turn runs on `to`. `continue`: the shim starts
6650
+ * one turn on `to` at once, with a fixed line ("Continue the task; the previous turn stopped at a usage
6651
+ * limit") and `source: fallback`. The prompt that stopped is never sent again, since its tools may have run.
6652
+ * @default "next_turn"
6653
+ */
6654
+ resume?: "next_turn" | "continue";
6655
+ }
6656
+
6657
+ /**
6658
+ * A skill or a plugin, under its name in `skills` or `plugins`: exactly one source. `text`, `files` and `builtin`
6659
+ * are written when the instance starts. `git`, `npm` and `artifact` are fetched once, at prepare, into the
6660
+ * revision's prepared snapshot, and are pinned so a revision never changes under you: a git `ref` is resolved to a
6661
+ * `commit` when the definition is written, an npm `version` is exact (`422 harness_setup_unpinned` otherwise) and
6662
+ * its integrity is recorded, and an artifact is checked by its `sha256`.
6663
+ */
6664
+ export type AgentHarnessSetupItem = {
6665
+ /** A skill's one file, its `SKILL.md`. Not for a plugin. */
6666
+ text?: string;
6667
+ /** The item's files, each relative to the item's folder. */
6668
+ files?: AgentHarnessFile[];
6669
+ git?: AgentHarnessGitSource;
6670
+ npm?: AgentHarnessNpmSource;
6671
+ artifact?: AgentHarnessArtifactSource;
6672
+ /**
6673
+ * One of B3's own items, shipped in the `harness` template. `b3os` is the skill for B3OS's tools, and the
6674
+ * default entry of `skills`; only under the name `b3os`, and only in `skills`.
6675
+ */
6676
+ builtin?: "b3os";
6677
+ };
6678
+
6679
+ /**
6680
+ * A folder of a public Git repository, fetched at prepare (the build has no access to your vault). Give `ref` or
6681
+ * `commit`: the node resolves a `ref` once, when the definition is written, and stores the `commit` beside it.
6682
+ * That lookup leaves from the node through the egress guard, as a webhook delivery does (private and loopback
6683
+ * addresses refused), and counts as your egress; a `ref` it cannot resolve is `400 invalid_request`, naming
6684
+ * the member, never quoting what the server answered.
6685
+ */
6686
+ export interface AgentHarnessGitSource {
6687
+ url: string;
6688
+ /** A branch or tag. */
6689
+ ref?: string;
6690
+ commit?: string;
6691
+ /** The item's folder in the repository. Default, its root. */
6692
+ path?: string;
6693
+ }
6694
+
6695
+ /**
6696
+ * An npm package, installed at prepare with its install scripts off. `version` is an exact version; a range or
6697
+ * a tag is `422 harness_setup_unpinned`. The node records the package's `integrity` when the definition is
6698
+ * written, looking it up through the egress guard, and checks it at prepare.
6699
+ */
6700
+ export interface AgentHarnessNpmSource {
6701
+ package: string;
6702
+ version: string;
6703
+ /** The package's `sha512-` integrity, set by the node. */
6704
+ integrity?: string;
6705
+ }
6706
+
6707
+ /**
6708
+ * A bundle of the item's folder in your project's artifact store, checked by `sha256` at prepare. Uploading one
6709
+ * needs a public artifact upload route, which is planned.
6710
+ */
6711
+ export interface AgentHarnessArtifactSource {
6712
+ id: string;
6713
+ sha256: string;
6714
+ }
6715
+
6716
+ /**
6717
+ * The harness's own settings, under the block's own `kind` (another kind's key is `400 invalid_request`),
6718
+ * merged under the settings the shim writes when the instance starts: opencode's config, each profile's Codex
6719
+ * `config.toml`, pi's `settings.json`, Claude Code's `--settings` file. A key the shim owns (the kind's
6720
+ * `settings_refused`: its hooks, permissions, login method, providers, MCP servers, and the plugins and plugin
6721
+ * marketplaces it turns on) is `400 invalid_request`, naming the key, and so is an `env` entry (Claude Code's
6722
+ * `env`) named in `AgentHarnessPlanEnv`, like one of the kind's key variables or `B3OS_*`, and a plan's token in
6723
+ * any value. MCP servers go in `mcp` and plugins in `plugins`, where they are pinned and checked.
6724
+ */
6725
+ export interface AgentHarnessSettings {
6726
+ opencode?: Record<string, unknown>;
6727
+ codex?: Record<string, unknown>;
6728
+ pi?: Record<string, unknown>;
6729
+ "claude-code"?: Record<string, unknown>;
6730
+ }
6731
+
6732
+ /** The repository cloned into the workspace at the instance's first start, before its first turn. */
6733
+ export interface AgentHarnessRepo {
6734
+ /** An `https://` Git URL. */
6735
+ url: string;
6736
+ /** The branch, tag or commit to check out. Default, the repository's default branch. */
6737
+ ref?: string;
6738
+ /**
6739
+ * A vault connection with a token for a private repository. The node delivers its secret as a
6740
+ * `B3OS_CONN_<N>` variable, and the harness's shim clones inside the instance and writes the token into the
6741
+ * instance's git credentials, so the harness can fetch and push with it and code in the instance can read
6742
+ * it; it needs `vault:run` and `vault:connections:reveal`. Refused with the rest of `repo` (`422
6743
+ * harness_capability_unsupported`) until the shim clones it.
6744
+ */
6745
+ connection?: string;
6746
+ }
6747
+
6748
+ export interface AgentHarnessContext {
6749
+ at: "session_start" | "turn_start";
6750
+ text: string;
6751
+ }
6752
+
6753
+ export interface AgentHarnessMcpRemote {
6754
+ /**
6755
+ * The server's `https://` URL (streamable HTTP or SSE). Reached through the instance's `egress`, which the
6756
+ * node fills with its host.
6757
+ */
6758
+ url: string;
6759
+ /**
6760
+ * A vault connection whose token the harness sends to this server as `Authorization: Bearer <token>`. The
6761
+ * node delivers its secret as a `B3OS_CONN_<N>` variable, and the shim writes the harness's MCP config to
6762
+ * send it (as a variable the config refers to, never the value: opencode's `{env:...}`, Claude Code's
6763
+ * `${...}`, Codex's `bearer_token_env_var`), so code in the instance can read it. It needs `vault:run` and
6764
+ * `vault:connections:reveal`, and a connection whose type has a credential field (`api_key`, `bearer` or
6765
+ * `oauth2`; another is `400 invalid_request`). A connection bound to `hosts` is `422
6766
+ * connection_host_bound` (B3OS adds such a credential only at the egress proxy, never inside a VM), and one
6767
+ * holding a plan's token is `400 harness_plan_credential`.
6768
+ */
6769
+ connection?: string;
6770
+ }
6771
+
6772
+ /**
6773
+ * A server the harness starts in the instance, as the harness's user, over stdio. With `npm`, the package is
6774
+ * installed at prepare and its commands are on the server's `PATH`; until prepared snapshots ship that answers
6775
+ * `422 harness_setup_needs_prepare`.
6776
+ */
6777
+ export interface AgentHarnessMcpStdio {
6778
+ command: string[];
6779
+ npm?: AgentHarnessNpmSource;
6780
+ /**
6781
+ * The server's environment. A `{connection}` value is a vault connection's secret, delivered as a
6782
+ * `B3OS_CONN_<N>` variable and set in the server's environment by the shim, so code in the instance can read
6783
+ * it; it needs `vault:run` and `vault:connections:reveal`. `field` names the secret field, and is required
6784
+ * for a connection type with no credential field of its own (`400 invalid_request`). A connection bound to
6785
+ * `hosts` is `422 connection_host_bound`.
6786
+ */
6787
+ env?: Record<
6788
+ string,
6789
+ | string
6790
+ | {
6791
+ connection: string;
6792
+ /** Which secret field of the connection, as a sandbox's `secrets` takes it. */
6793
+ field?: string;
6794
+ }
6795
+ >;
6796
+ }
6797
+
6798
+ /**
6799
+ * B3OS's own MCP server inside the instance, at the instance's local address (`B3OS_MCP_URL`): the `mcp.b3os`
6800
+ * entry, and only that one. The default is `{builtin: b3os}` with all six toolsets; what you write under `b3os`
6801
+ * is merged into it as a JSON merge patch, so `{toolsets: [vision]}` narrows it and `builtin` need not be
6802
+ * restated. It brings the instance's B3OS MCP grant: the node fills `api` with the scopes the merged entry's
6803
+ * `toolsets` need, scoped to the instance, unless the definition sets `api` itself. A definition without this
6804
+ * entry gets no filled B3OS MCP scopes (only `infer:run` when it declares a `node` profile, and nothing
6805
+ * otherwise). The server lists the tools of each toolset this node serves, so a node without one lists fewer
6806
+ * tools.
6807
+ */
6808
+ export interface AgentHarnessMcpBuiltin {
6809
+ /** `b3os`: B3OS's own server, the default's; may be left out. */
6810
+ builtin?: "b3os";
6811
+ /**
6812
+ * Which of B3OS's tools the server lists, and so which scopes the filled grant holds. Default: all six.
6813
+ * `browser` (the `browser_*` tools; `vision:run` and `vision:write`), `vision` (web pages: `vision_scrape`
6814
+ * and the like; `vision:run`), `render` (screenshots and videos; `render:run`), `sandboxes` (code in
6815
+ * other sandboxes; `sandboxes:run`), `actions` (the pack actions the grant's actions rule allows;
6816
+ * `actions:read` and `actions:run`) and `infer` (the node's models; `infer:run`).
6817
+ */
6818
+ toolsets?: Array<"browser" | "vision" | "render" | "sandboxes" | "actions" | "infer">;
6819
+ }
6820
+
6821
+ export interface AgentHarnessFile {
6822
+ /**
6823
+ * Relative to the workspace, or, in a skill's or plugin's `files`, to the item's folder. A path with a `..`
6824
+ * segment is `400 invalid_request`.
6825
+ */
6826
+ path: string;
6827
+ text: string;
6828
+ }
6829
+
6830
+ /** Where the harness's events go beyond its session's stream, and who answers its questions. */
6831
+ export interface AgentHarnessHooks {
6832
+ webhook?: AgentHarnessWebhook;
6833
+ decide?: AgentHarnessDecide;
6834
+ /**
6835
+ * Add each event's native payload (`native.payload`: the harness's own hook or stream record), after the
6836
+ * redaction listeners use. Off by default, because a native payload can hold a tool's whole input.
6837
+ * @default false
6838
+ */
6839
+ include_native?: boolean;
6840
+ }
6841
+
6842
+ /** An event type (`harness.turn.completed`), a family (`harness.turn.*`) or `*` for every type. */
6843
+ export type AgentHarnessEventPattern = string;
6844
+
6845
+ /**
6846
+ * Where the agents product sends this agent's `harness.*` events, from every instance and every way a turn
6847
+ * came: each event `events` selects is a `POST` of a `WebhookEvent` (`agentsDeliverHarnessEvent`), signed with
6848
+ * `B3OS-Signature` and the URL's secret (`POST /v1/webhooks/secret`), retried with backoff for 24 hours, in
6849
+ * order per session. Delivery goes through the egress guard.
6850
+ */
6851
+ export interface AgentHarnessWebhook {
6852
+ /** An `https://` URL. */
6853
+ url: string;
6854
+ /**
6855
+ * Default: every type but `harness.message`, which carries each piece of streamed text as its own event; name
6856
+ * it, or `*`, to get it too.
6857
+ */
6858
+ events?: AgentHarnessEventPattern[];
6859
+ }
6860
+
6861
+ /**
6862
+ * A webhook that answers the harness's questions while the turn waits (`agentsDecideHarnessEvent`): before a
6863
+ * tool runs (`harness.tool.requested`), when the harness asks for permission (`harness.permission.requested`),
6864
+ * or as a turn starts (`harness.turn.started`, to add context). The harness's shim hands each question to the
6865
+ * node (`POST /v1/agents/self/decide`), and the node makes the call: signed as a webhook delivery is, through
6866
+ * the egress guard (private and loopback addresses refused), so the URL's secret never enters the instance and
6867
+ * its host need not be in the instance's `egress`. The turn waits up to `timeout_ms` for `{decision: allow |
6868
+ * deny | ask, reason?, context?}`. It fails closed: no answer in time, a status other than 2xx, or a body
6869
+ * without a `decision` is `deny`, unless `on_timeout` is `allow`. `ask` hands the question to a person. The
6870
+ * definition's own rules come first, and in `permissions: plan` the webhook is never called: the harness's
6871
+ * read-only mode and the rules answer every question there.
6872
+ */
6873
+ export interface AgentHarnessDecide {
6874
+ /** An `https://` URL. */
6875
+ url: string;
6876
+ /** @default ["harness.tool.requested"] */
6877
+ events?: Array<"harness.tool.requested" | "harness.permission.requested" | "harness.turn.started">;
6878
+ /**
6879
+ * How long the turn waits for the answer.
6880
+ * @default 3000
6881
+ */
6882
+ timeout_ms?: number;
6883
+ /**
6884
+ * The decision when the webhook does not answer in time, fails, or answers without a decision.
6885
+ * @default "deny"
6886
+ */
6887
+ on_timeout?: "deny" | "allow";
6888
+ }
6889
+
6890
+ export interface AgentHarnessTerminal {
6891
+ /**
6892
+ * Record the terminal as asciicast v3 files on the instance's disk (`…/terminal/recordings`). Off by default:
6893
+ * a recording keeps whatever the terminal showed, codes and keys printed in it included.
6894
+ * @default false
6895
+ */
6896
+ record?: boolean;
6897
+ }
6898
+
6899
+ /**
6900
+ * The type of a harness event, the same for every harness. Each is what the instance reports about itself, not
6901
+ * something the node observed. What each carries in `data`:
6902
+ *
6903
+ * - `harness.session.started`: `native_session` (the harness's own session ID), `resumed`, `model`, `auth`
6904
+ * (`profile`, `type`, `provider`) and `withheld` (the names of the variables the shim kept from the harness,
6905
+ * never their values). `harness.session.ended`: `reason`.
6906
+ * - `harness.turn.started`: `source`, `profile`, `chars`, `prompt` (the first 4,000 characters). `source` is
6907
+ * where the turn came from, set from the message's `initiator` and never from its body: `api` (a key, a
6908
+ * person or a sandbox), `routine`, `listener`, `instance` (another agent instance), `terminal` (typed in the
6909
+ * terminal), `steer`, or `fallback` (the turn a profile's `fallback` with `resume: continue` starts).
6910
+ * - `harness.message`: `role`, `text`, `delta` (`true` while the text streams).
6911
+ * - `harness.tool.requested`: `tool`, `call_id`, `summary`, `parent` (the subagent's call, when one ran it).
6912
+ * `harness.tool.completed`: `tool`, `call_id`, `ok`, `duration_ms`.
6913
+ * - `harness.permission.requested`: `request` (the `dec_` ID `POST …/decisions` answers), `kind`, `tool`,
6914
+ * `summary`, `reason`. `harness.permission.resolved`: `request`, or `call_id` for a call the definition's
6915
+ * rules or `hooks.decide` answered without asking; `decision`, `by` (`rules`, `decide`, `person`, `timeout`
6916
+ * or `withdrawn`, when the turn ended first) and `reason`.
6917
+ * - `harness.subagent.started`: `agent_id`, `kind`, `model`. `harness.subagent.completed`: `agent_id`.
6918
+ * - `harness.compacted`: nothing.
6919
+ * - `harness.turn.completed`: `result`, `usage` (`AgentHarnessUsage`), `cost_usd` and `list_price_usd` (as on a
6920
+ * usage row), `timing` (`model_ms`, `tool_ms`, `wall_ms`), `steps` and `files` (the workspace paths the turn
6921
+ * changed, when the harness reports them). `harness.turn.failed`: `error` (`code`, `detail`; `limit_reached`,
6922
+ * `auth_required` and `no_profile_ready` carry `profile` and `resets_at` when known), `timing`, `usage`.
6923
+ * `harness.turn.interrupted`: `timing`, `usage`.
6924
+ * - `harness.terminal.attached` and `harness.terminal.detached`: `role`, `viewer`, `viewers` (how many remain).
6925
+ * - `harness.auth.required`: `profile`, `reason` (`signed_out`, `expired`, `refused` or `missing`), `detail`.
6926
+ * - `harness.auth.ready`: `profile`, `type`, `provider` and `plan` (what the harness says it is signed in as,
6927
+ * when it says).
6928
+ * - `harness.auth.limited`: `profile`, `limit` (`usage`, `credits` or `rate`), `resets_at` and `used_percent`
6929
+ * when the harness reports them, `detail`.
6930
+ * - `harness.auth.switched`: `from`, `to`, `why` (`requested` or `fallback`), `billed_to`.
6931
+ * - `harness.auth.removed`: `profile`, `cli`, `reason`: `signed_out` (the owner signed out), or
6932
+ * `signin_not_personal` (a harness's credential file where no sign-in belongs, removed without being read).
6933
+ */
6934
+ export type AgentHarnessEventType =
6935
+ | "harness.session.started"
6936
+ | "harness.session.ended"
6937
+ | "harness.turn.started"
6938
+ | "harness.message"
6939
+ | "harness.tool.requested"
6940
+ | "harness.tool.completed"
6941
+ | "harness.permission.requested"
6942
+ | "harness.permission.resolved"
6943
+ | "harness.subagent.started"
6944
+ | "harness.subagent.completed"
6945
+ | "harness.compacted"
6946
+ | "harness.turn.completed"
6947
+ | "harness.turn.failed"
6948
+ | "harness.turn.interrupted"
6949
+ | "harness.terminal.attached"
6950
+ | "harness.terminal.detached"
6951
+ | "harness.auth.required"
6952
+ | "harness.auth.ready"
6953
+ | "harness.auth.limited"
6954
+ | "harness.auth.switched"
6955
+ | "harness.auth.removed";
6956
+
6957
+ /** A turn's token use, one row per model, as the harness reported it. */
6958
+ export interface AgentHarnessUsage {
6959
+ models: AgentHarnessUsageRow[];
6960
+ [key: string]: unknown;
6961
+ }
6962
+
6963
+ /**
6964
+ * One model's tokens in a turn, and who pays for them. `cost_usd` is there only when `billed_to` is `key` or
6965
+ * `node`; for a plan's turn, the figure the harness reports goes in `list_price_usd`, so a sum of `cost_usd`
6966
+ * never counts a plan's turns as spend.
6967
+ */
6968
+ export interface AgentHarnessUsageRow {
6969
+ model: string;
6970
+ input: number;
6971
+ cacheRead: number;
6972
+ cacheWrite: number;
6973
+ output: number;
6974
+ reasoning?: number;
6975
+ profile: AgentHarnessProfileName;
6976
+ /** `key`: the key's owner, through the provider. `plan`: a person's plan. `node`: infer on the node. */
6977
+ billed_to: "key" | "plan" | "node";
6978
+ /** What the harness or infer reports this row cost, for `key` and `node` only. */
6979
+ cost_usd?: number;
6980
+ /** For `plan` only, what the harness reports the tokens would cost at list price; not a charge. */
6981
+ list_price_usd?: number;
6982
+ }
6983
+
6984
+ /**
6985
+ * One event of a harness, in the product-event envelope (ARCHITECTURE 4.12). The harness's shim writes `id`,
6986
+ * `type`, `time`, `harness`, `conversation`, `data` and `native`. The node sets `seq`, `org`, `project`,
6987
+ * `instance` and, for an event of a delivered turn, `session_id` and `subject` (from the session) as it writes
6988
+ * the event to the instance's log, replacing whatever the shim sent on a delivery's answer. The shim numbers
6989
+ * the events of its own streams too, but that number orders them only within one run of the shim and starts
6990
+ * again when the shim restarts; a self event carries none (`AgentSelfEvent`).
6991
+ */
6992
+ export interface AgentHarnessEvent {
6993
+ /** Unique per event; deduplicate on it. */
6994
+ id: string;
6995
+ /**
6996
+ * The event's place in its instance's event log, set by the node and growing across restarts of the
6997
+ * harness's shim. The SSE `id` of `GET …/stream`.
6998
+ */
6999
+ seq: number;
7000
+ type: AgentHarnessEventType;
7001
+ time: string;
7002
+ harness: AgentHarnessKindName;
7003
+ org?: string;
7004
+ project?: string;
7005
+ instance?: string;
7006
+ /** The agent session, for an event of a turn sent as a message. */
7007
+ session_id?: string;
7008
+ /** The harness session the event belongs to (the message's `conversation`). */
7009
+ conversation?: string;
7010
+ /** The end user the turn is for, for an event of a delivered turn (the session's `subject`). */
7011
+ subject?: string;
7012
+ /** What happened; `AgentHarnessEventType` lists the members of each type. */
7013
+ data: {
7014
+ usage?: AgentHarnessUsage;
7015
+ [key: string]: unknown;
7016
+ };
7017
+ /** The harness event this one came from. `payload` only with `hooks.include_native`. */
7018
+ native?: {
7019
+ harness: AgentHarnessKindName;
7020
+ event: string;
7021
+ payload?: unknown;
7022
+ };
7023
+ }
7024
+
7025
+ /**
7026
+ * One harness this node runs, as its driver declares it (`b3os-harness catalog --json`, printed by the shim
7027
+ * and served as printed). A feature not yet checked against the kind's pinned version is left out, and a
7028
+ * definition that uses it is refused.
7029
+ */
7030
+ export interface AgentHarnessKind {
7031
+ object: "harness_kind";
7032
+ kind: AgentHarnessKindName;
7033
+ /** The harness's own name. */
7034
+ name: string;
7035
+ /**
7036
+ * `native`: a driver built into the shim and reviewed by B3. `acp`: the generic Agent Client Protocol
7037
+ * adapter, which runs the harness as its own process over stdio.
7038
+ */
7039
+ driver: "native" | "acp";
7040
+ /** The versions this node runs, newest first. */
7041
+ versions: string[];
7042
+ /** What a definition without `version` gets. */
7043
+ default_version: string;
7044
+ modes: Array<"api" | "terminal">;
7045
+ capabilities: AgentHarnessCapabilities;
7046
+ auth: AgentHarnessKindAuth;
7047
+ /** The lists of the `harness` block this kind takes; another is `422 harness_capability_unsupported`. */
7048
+ setup: Array<"skills" | "plugins" | "mcp" | "instructions" | "settings">;
7049
+ /**
7050
+ * The kind's own settings keys the shim owns (its hooks, permissions, login method, providers, MCP servers,
7051
+ * and the plugins and marketplaces it turns on), which a definition's `settings` may not set (`400
7052
+ * invalid_request`).
7053
+ */
7054
+ settings_refused: string[];
7055
+ /**
7056
+ * The environment variables this kind reads a plan's token from. No harness agent's `env` or `secrets` sets
7057
+ * these, or any other kind's (`400 invalid_request`).
7058
+ */
7059
+ plan_env: AgentHarnessPlanEnv[];
7060
+ }
7061
+
7062
+ /** What the kind's driver delivers; the shim's conformance test checks each one it declares. */
7063
+ export interface AgentHarnessCapabilities {
7064
+ /** A running turn takes more text (`POST …/steer`). */
7065
+ steer: boolean;
7066
+ /** A running turn stops with its usage so far, and the harness session stays open. */
7067
+ interrupt: boolean;
7068
+ /** A conversation continues its harness session after the shim or the instance restarts. */
7069
+ resume: boolean;
7070
+ /**
7071
+ * Which tool calls the shim sees before they run, and so which `hooks.decide` on `harness.tool.requested`
7072
+ * answers: `every_tool`, `asked` (only the calls the harness asks permission for), or `partial` (some calls
7073
+ * run without asking, such as Codex's read-only commands).
7074
+ */
7075
+ tool_gate: "every_tool" | "asked" | "partial";
7076
+ /**
7077
+ * The `mode`s in which `hooks.decide` answers. A definition with `hooks.decide` in another mode is `422
7078
+ * harness_capability_unsupported`, but in `permissions: plan`, where the webhook is never called. opencode
7079
+ * lists `api` only: in `terminal` its TUI answers permission prompts itself.
7080
+ */
7081
+ decide_modes: Array<"api" | "terminal">;
7082
+ /** Turns report their tokens per model. */
7083
+ usage: boolean;
7084
+ /** The harness's subagents show as `harness.subagent.*` events. */
7085
+ subagent_events: boolean;
7086
+ }
7087
+
7088
+ /** The credential profiles the kind takes (`AgentHarnessAuthProfile`). */
7089
+ export interface AgentHarnessKindAuth {
7090
+ /** Each `key` provider the kind takes, with the environment variables a profile of it sets. */
7091
+ key: Record<string, string[]>;
7092
+ /**
7093
+ * The plans a person may sign in to in a `signin` profile; empty when the kind takes none. `anthropic`
7094
+ * also needs `agents.claude_plan_signin`.
7095
+ */
7096
+ signin: Array<"anthropic" | "openai">;
7097
+ /** A `node` profile (a model the node's infer serves) works with this kind. */
7098
+ node: boolean;
7099
+ /**
7100
+ * The hosts a profile of each provider reaches from the instance at the kind's pinned version, measured on
7101
+ * the pin with the kind's own switches for the CLI's other traffic set (telemetry, update checks, a plugin
7102
+ * sync). The node puts them in the filled `egress` and checks your own `egress` against them
7103
+ * (`AgentHarness`).
7104
+ * - `key`: what a turn on each `auth.key` provider reaches: its model API, and a model catalog the kind
7105
+ * fetches for it. A `*_compatible` provider lists none; its `base_url` host stands for them.
7106
+ * - `signin`: each `auth.signin` provider's login, token and model API hosts.
7107
+ *
7108
+ * Exact hosts or `*.` wildcards. A `{region}` label is filled from the profile's `region`, which a profile
7109
+ * of that provider then needs (`400 invalid_request` without one). A profile whose provider is not listed
7110
+ * here is refused (`422 harness_capability_unsupported`).
7111
+ */
7112
+ hosts: {
7113
+ key: Record<string, string[]>;
7114
+ signin: Record<string, string[]>;
7115
+ };
7116
+ }
7117
+
7118
+ /**
7119
+ * An environment variable a harness reads a plan's token from, or that changes where it signs in:
7120
+ * `CLAUDE_CODE_OAUTH_TOKEN` and `CLAUDE_CODE_OAUTH_REFRESH_TOKEN` (Claude Code 2.1.332; `claude auth login`
7121
+ * signs in from the refresh token);
7122
+ * Claude Code 2.1.332's session and bridge tokens (`CLAUDE_CODE_SESSIONS_OAUTH_TOKEN`, `CLAUDE_BRIDGE_OAUTH_TOKEN`,
7123
+ * `CLAUDE_CODE_SESSION_ACCESS_TOKEN`), the forms that read a token from a descriptor or a file, which a value
7124
+ * check cannot see (`CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR`, `CLAUDE_CODE_WEBSOCKET_AUTH_FILE_DESCRIPTOR`,
7125
+ * `CLAUDE_SESSION_INGRESS_TOKEN_FILE`, `CLAUDE_CODE_HOST_CREDS_FILE`), an account credential
7126
+ * (`CLAUDE_TRUSTED_DEVICE_TOKEN`) and the OAuth endpoint overrides (`CLAUDE_CODE_CUSTOM_OAUTH_URL`,
7127
+ * `CLAUDE_LOCAL_OAUTH_API_BASE`, `USE_LOCAL_OAUTH`, `USE_STAGING_OAUTH`), all read from the binary's strings;
7128
+ * `ANTHROPIC_OAUTH_TOKEN` (pi), and `CODEX_ACCESS_TOKEN` (Codex 0.164.0: `codex login --with-access-token`
7129
+ * reads an access token from it; refused until it is checked whether that token is a ChatGPT plan's). An agent
7130
+ * with a `harness` block never takes one of these names in `env` or `secrets`, in an `mcp` server's `env`, or
7131
+ * in a `settings` `env` entry, whatever its `kind`, since the `harness` template holds every harness: `400
7132
+ * invalid_request`. Names alone do not hold the line, because pi sends any Anthropic key whose value holds
7133
+ * `sk-ant-oat` as a plan login: a value holding `sk-ant-oat` or `sk-ant-ort` is `400 harness_plan_credential`
7134
+ * anywhere in the definition and in the resolved value of every connection it names (`AgentHarness`), and the
7135
+ * shim drops every variable whose value holds one from the harness's environment and the terminal's. B3OS
7136
+ * never stores a plan's token.
7137
+ */
7138
+ export type AgentHarnessPlanEnv =
7139
+ | "CLAUDE_CODE_OAUTH_TOKEN"
7140
+ | "CLAUDE_CODE_OAUTH_REFRESH_TOKEN"
7141
+ | "ANTHROPIC_OAUTH_TOKEN"
7142
+ | "CODEX_ACCESS_TOKEN"
7143
+ | "CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR"
7144
+ | "CLAUDE_CODE_SESSIONS_OAUTH_TOKEN"
7145
+ | "CLAUDE_BRIDGE_OAUTH_TOKEN"
7146
+ | "CLAUDE_CODE_SESSION_ACCESS_TOKEN"
7147
+ | "CLAUDE_CODE_WEBSOCKET_AUTH_FILE_DESCRIPTOR"
7148
+ | "CLAUDE_SESSION_INGRESS_TOKEN_FILE"
7149
+ | "CLAUDE_CODE_HOST_CREDS_FILE"
7150
+ | "CLAUDE_TRUSTED_DEVICE_TOKEN"
7151
+ | "CLAUDE_CODE_CUSTOM_OAUTH_URL"
7152
+ | "CLAUDE_LOCAL_OAUTH_API_BASE"
7153
+ | "USE_LOCAL_OAUTH"
7154
+ | "USE_STAGING_OAUTH";
7155
+
7156
+ /**
7157
+ * The catalog as the shim prints it (`b3os-harness catalog --json`): the kinds in `data`, open-source first,
7158
+ * and `checks`. The node stores it with the `harness` template's build and serves it unchanged.
7159
+ */
7160
+ export type AgentHarnessKindList = Omit<ListEnvelope, "data"> & {
7161
+ data: AgentHarnessKind[];
7162
+ checks: AgentHarnessCatalogChecks;
7163
+ };
7164
+
7165
+ /**
7166
+ * What the shim refuses or removes at start beyond each kind's entry, so the node refuses the same at write:
7167
+ * per kind (`kinds`), the rules for profile names, the plan-token names and value, the workspace paths `files`
7168
+ * may not write, the default `mcp` and `skills` entries, each B3OS toolset's scopes and the flag each gated
7169
+ * sign-in needs.
7170
+ */
7171
+ export interface AgentHarnessCatalogChecks {
7172
+ kinds: Record<string, AgentHarnessKindChecks>;
7173
+ profiles: {
7174
+ /** The most profiles a definition holds. */
7175
+ max: number;
7176
+ /** The pattern a profile's name matches (an ECMAScript regular expression). */
7177
+ name: string;
7178
+ };
7179
+ /** Every kind's plan variables, refused as names on every harness agent. */
7180
+ plan_env: AgentHarnessPlanEnv[];
7181
+ /** The pattern of a plan's token, refused as a value anywhere (an ECMAScript regular expression). */
7182
+ plan_value: string;
7183
+ /** Workspace paths (a file, or a directory ending in `/`) no definition's `files` writes. */
7184
+ files_refused: string[];
7185
+ /**
7186
+ * The entries every definition's `mcp` and `skills` start with. A definition's maps are a JSON merge patch
7187
+ * (RFC 7396) over them (`AgentHarness`); a kind whose `setup` does not list a list gets none.
7188
+ */
7189
+ defaults: {
7190
+ mcp: Record<string, AgentHarnessMcpBuiltin>;
7191
+ skills: Record<string, AgentHarnessSetupItem>;
7192
+ };
7193
+ /** Each B3OS toolset's scopes; the filled grant is the merged `mcp.b3os` entry's toolsets' scopes. */
7194
+ b3os_toolsets: Record<string, string[]>;
7195
+ /** The flag a sign-in to each listed provider needs; a provider not listed, and every key, needs none. */
7196
+ signin_flags: Record<string, string>;
7197
+ }
7198
+
7199
+ /** What the shim enforces for one kind beyond its catalog entry. */
7200
+ export interface AgentHarnessKindChecks {
7201
+ /**
7202
+ * Per `key` provider, the variables the node delivers as `B3OS_PROFILE_<NAME>__<VAR>`; the `optional` ones
7203
+ * may be left out (`AWS_SESSION_TOKEN`).
7204
+ */
7205
+ deliver: Record<
7206
+ string,
7207
+ {
7208
+ env: string[];
7209
+ optional: string[];
7210
+ }
7211
+ >;
7212
+ /** The providers whose profile needs an `https://` `base_url`; any other provider's refuses one. */
7213
+ base_url: AgentHarnessKeyProvider[];
7214
+ /** The providers whose profile takes a `region`. */
7215
+ region: AgentHarnessKeyProvider[];
7216
+ /**
7217
+ * Every variable the shim sets or removes in the kind's processes; a definition's `env` or `secrets` naming one is refused.
7218
+ */
7219
+ env_owned: string[];
7220
+ /** The CLI's config-directory variable, which the shim sets to each profile's directory. */
7221
+ dir_env: string;
7222
+ /** Lists the kind takes only from a prepared snapshot; refused until prepared snapshots ship. */
7223
+ prepare_only: Array<"skills" | "plugins" | "mcp" | "instructions" | "settings">;
7224
+ /**
7225
+ * For a kind that has one, the only keys its `settings.<kind>` takes, checked on its pinned version; any other
7226
+ * key is refused, as is any in its `settings_refused`. Absent: every key not refused is taken.
7227
+ */
7228
+ settings_allowed?: string[];
7229
+ /**
7230
+ * When true, a definition with more than one `key` profile gives each one a model on the profile's own
7231
+ * provider (the profile's `model`, else the block's); one that has none is refused at write. The kind runs
7232
+ * every key profile in one process, each on its own model (opencode), so such a profile would run nothing.
7233
+ */
7234
+ key_profiles_need_model?: boolean;
7235
+ /** The limit and auth signals the driver reads from the CLI. */
7236
+ signals: Record<string, "limit" | "auth">;
7237
+ /** The signals seen live on the kind's pinned version; only these move a profile's `fallback`. */
7238
+ checked: string[];
7239
+ }
7240
+
7241
+ export interface AgentSteerRequest {
7242
+ /** What the harness reads at its next step. Yours, so never quoted. */
7243
+ text: string;
7244
+ }
7245
+
7246
+ export interface AgentDecisionRequest {
7247
+ /** The `request` of the `harness.permission.requested` event, unique per instance. */
7248
+ request: string;
7249
+ decision: "allow" | "deny";
7250
+ /** Shown to the harness with the decision. */
7251
+ reason?: string;
7252
+ }
7253
+
7254
+ export interface AgentDecision {
7255
+ object: "agent_decision";
7256
+ instance_id: string;
7257
+ /**
7258
+ * The session whose turn asked, or `null` for a turn that is not a session (typed in the terminal or
7259
+ * started inside the instance).
7260
+ */
7261
+ session_id: string | null;
7262
+ request: string;
7263
+ decision: "allow" | "deny";
7264
+ reason: string | null;
7265
+ by: AgentSessionInitiator;
7266
+ decided_at: string;
7267
+ }
7268
+
7269
+ /**
7270
+ * `watch`: the live view and the terminal, view-only. `control`: also input, when nobody else holds it.
7271
+ */
7272
+ export type AgentGrantRole = "watch" | "control";
7273
+
7274
+ export interface AgentGrantCreateRequest {
7275
+ /** @default "watch" */
7276
+ role?: AgentGrantRole;
7277
+ /**
7278
+ * How long the link works. Chosen for the beta.
7279
+ * @default 900
7280
+ */
7281
+ ttl_s?: number;
7282
+ /**
7283
+ * How many times the link may be redeemed: each page load is one, and so is each reconnect of its terminal
7284
+ * or event stream. Default, any number until it expires.
7285
+ */
7286
+ uses?: number;
7287
+ }
7288
+
7289
+ export interface AgentGrant {
7290
+ id: string;
7291
+ object: "agent_grant";
7292
+ agent_id: string;
7293
+ key: AgentInstanceKey;
7294
+ role: AgentGrantRole;
7295
+ /** The grant's secret, in the create answer only (`null` everywhere else). Treat it as a password. */
7296
+ token: string | null;
7297
+ /** The share page with the token in its fragment, in the create answer only. */
7298
+ url: string | null;
7299
+ expires_at: string;
7300
+ uses: number | null;
7301
+ uses_left: number | null;
7302
+ created_by: AgentSessionInitiator;
7303
+ created_at: string;
7304
+ }
7305
+
7306
+ export type AgentGrantList = Omit<ListEnvelope, "data"> & {
7307
+ data: AgentGrant[];
7308
+ };
7309
+
7310
+ export interface AgentTerminalRecording {
7311
+ id: string;
7312
+ object: "terminal_recording";
7313
+ /** The harness session whose terminal it recorded. */
7314
+ conversation: string;
7315
+ format: "asciicast-v3";
7316
+ bytes: number;
7317
+ started_at: string;
7318
+ /** The last write; a recording still being written keeps growing. */
7319
+ updated_at: string;
7320
+ }
7321
+
7322
+ export type AgentTerminalRecordingList = Omit<ListEnvelope, "data"> & {
7323
+ data: AgentTerminalRecording[];
7324
+ };
7325
+
7326
+ export interface AgentSelfEventsRequest {
7327
+ events: AgentSelfEvent[];
7328
+ }
7329
+
7330
+ /**
7331
+ * A harness event as the shim records it from inside the instance: an `AgentHarnessEvent` without the members
7332
+ * the node sets (`seq`, `org`, `project`, `instance`, `session_id`, `subject`), which a self event never
7333
+ * carries (`400 invalid_request`): the node assigns the log's `seq` as it writes the event.
7334
+ */
7335
+ export interface AgentSelfEvent {
7336
+ id: string;
7337
+ type: AgentHarnessEventType;
7338
+ time: string;
7339
+ harness: AgentHarnessKindName;
7340
+ conversation?: string;
7341
+ data: {
7342
+ usage?: AgentHarnessUsage;
7343
+ [key: string]: unknown;
7344
+ };
7345
+ native?: {
7346
+ harness: AgentHarnessKindName;
7347
+ event: string;
7348
+ payload?: unknown;
7349
+ };
7350
+ }
7351
+
7352
+ /** A question for the definition's `hooks.decide` webhook, from the harness's shim. */
7353
+ export interface AgentSelfDecideRequest {
7354
+ type: "harness.tool.requested" | "harness.permission.requested" | "harness.turn.started";
7355
+ /**
7356
+ * The session the turn was delivered as (the delivery's `session`), when the question belongs to one. The
7357
+ * node keeps it only when it is the session the instance runs now.
7358
+ */
7359
+ session?: string;
7360
+ conversation?: string;
7361
+ /** `tool`, `input` (the tool's arguments), `summary` and `call_id`; a turn's `prompt`. */
7362
+ data: Record<string, unknown>;
7363
+ }
7364
+
7365
+ export interface AgentSelfDecision {
7366
+ object: "agent_self_decision";
7367
+ /** `ask` hands the question to a person (`harness.permission.requested`). */
7368
+ decision: "allow" | "deny" | "ask";
7369
+ reason?: string;
7370
+ /** Added to what the model sees next, quoted as information. */
7371
+ context?: string;
7372
+ /**
7373
+ * `true` when the webhook did not answer in time, failed or answered without a `decision`, and `decision` is
7374
+ * the definition's `on_timeout`.
7375
+ */
7376
+ fallback: boolean;
7377
+ }
7378
+
7379
+ export interface AgentSelfEventsResult {
7380
+ object: "agent_self_events";
7381
+ accepted: number;
7382
+ /** Events whose `id` the instance had already recorded; not written again. */
7383
+ duplicates: number;
7384
+ }
7385
+
7386
+ /** Set exactly one of `entry` (your own harness) and `harness` (a coding agent B3OS runs for you). */
7387
+ export type AgentCreateRequest = {
5529
7388
  name: AgentName;
5530
7389
  source?: AgentSource;
5531
- entry: AgentEntry;
7390
+ entry?: AgentEntry;
7391
+ harness?: AgentHarness;
5532
7392
  /** Environment variables of the harness. Returned as given; put credentials in `secrets`. */
5533
7393
  env?: Record<string, string>;
5534
7394
  /**
@@ -5542,11 +7402,13 @@ export interface AgentCreateRequest {
5542
7402
  sleep?: AgentSleep;
5543
7403
  turns?: AgentTurns;
5544
7404
  metadata?: Metadata;
5545
- }
7405
+ };
5546
7406
 
7407
+ /** `entry` and `harness` never come together, and an agent keeps the one it was made with. */
5547
7408
  export interface AgentUpdateRequest {
5548
7409
  source?: AgentSource;
5549
7410
  entry?: AgentEntry;
7411
+ harness?: AgentHarness;
5550
7412
  env?: Record<string, string>;
5551
7413
  secrets?: Record<string, SecretValue>;
5552
7414
  api?: SandboxApiGrant;
@@ -5576,6 +7438,31 @@ export interface Agent {
5576
7438
  egress: EgressPolicy;
5577
7439
  sleep: AgentSleep;
5578
7440
  turns: AgentTurns;
7441
+ /**
7442
+ * Only on an agent made with a `harness` block (planned), as the node stored it: defaults filled in,
7443
+ * shorthands expanded, git refs resolved to commits, and `mcp` and `skills` as you wrote them, nulls
7444
+ * included, never merged with their default `b3os` entries (`AgentHarness`), so the block can be sent back
7445
+ * as it is.
7446
+ */
7447
+ harness?: AgentHarness;
7448
+ /**
7449
+ * The person a personal agent belongs to, or `null`. An agent with a `signin` profile is personal (planned):
7450
+ * its owner is the person who made it, and it never changes. Everything that drives it or reads what its
7451
+ * instances hold is the owner's alone, and so is changing it: messages, steer, cancel, decisions, making,
7452
+ * waking and putting to sleep its instances (an instance may also put itself to sleep from inside), its
7453
+ * sessions (read, listed or streamed: their results and `session.output` carry the turns), and its
7454
+ * instances' stream, terminal, tickets, grants and recordings. Anyone else, an organization admin included,
7455
+ * gets `403 harness_personal_agent`. The owner or an organization admin may delete it or one of its
7456
+ * instances, and list or revoke its grants. Every `agents:read` caller still sees the definition and each
7457
+ * instance's status and lifecycle events (`GET …/instances`, `GET …/instances/{key}/events`), which hold no
7458
+ * turn. Listeners never send it turns, and routines only when the owner made them. The owner shares a view with a `watch` grant;
7459
+ * `control` grants are refused. Forks and children of it run only on `key` and `node` profiles (`409
7460
+ * harness_profile_unavailable`), and nothing it signed in to is carried to another instance. Not served
7461
+ * yet: until the prerequisites `AgentHarnessAuthSignin` names land, the node makes no personal agent, so
7462
+ * `owner` is `null` on every agent.
7463
+ */
7464
+ owner?: null | AgentOwner;
7465
+ harness_prepared?: AgentHarnessPrepared;
5579
7466
  upgrade: "new_instances" | "on_wake";
5580
7467
  /** How many instances the agent has, in any state. */
5581
7468
  instances: number;
@@ -5584,6 +7471,35 @@ export interface Agent {
5584
7471
  metadata: Metadata;
5585
7472
  }
5586
7473
 
7474
+ export interface AgentOwner {
7475
+ kind: "user";
7476
+ id: string;
7477
+ }
7478
+
7479
+ /**
7480
+ * The revision's prepared snapshot (planned): the `harness` template with only this kind's harness at its
7481
+ * `version` and the recipe's fetched items installed, built once per `key` and shared by the project's agents
7482
+ * with the same key. The build runs in a `builder` sandbox with no secrets and no vault access, reaching only
7483
+ * the recipe's source hosts, and fails if any harness credential file exists in it. Messages wait while it
7484
+ * builds, and that time counts toward `turns.timeout_s`; a failed build fails them with
7485
+ * `harness_prepare_failed`. `upgrade: on_wake` moves instances only to a revision whose snapshot is `ready`.
7486
+ * It counts against your snapshot quota.
7487
+ */
7488
+ export interface AgentHarnessPrepared {
7489
+ /**
7490
+ * The prepare key: the SHA-256 of the template's ID and revision, the shim's version, the `kind`, the
7491
+ * `version` and the resolved sources of the fetched items. A change elsewhere in the block keeps it.
7492
+ */
7493
+ key: string;
7494
+ /** `none`: nothing is built for this revision yet. */
7495
+ status: "none" | "queued" | "building" | "ready" | "failed";
7496
+ /** The snapshot instances start from, once `ready`; also the filled `source.snapshot`. */
7497
+ snapshot: string | null;
7498
+ built_at: string | null;
7499
+ /** Why the last build failed, naming the step and the item. */
7500
+ error: null | Problem;
7501
+ }
7502
+
5587
7503
  export type AgentList = Omit<ListEnvelope, "data"> & {
5588
7504
  data: Agent[];
5589
7505
  };
@@ -5621,7 +7537,10 @@ export interface AgentInstance {
5621
7537
  key: AgentInstanceKey;
5622
7538
  revision: number;
5623
7539
  status: AgentInstanceStatus;
5624
- /** The instance's microVM, the same through every sleep tier; `null` before it was first made. */
7540
+ /**
7541
+ * The instance's microVM, the same through every sleep tier; `null` before it was first made. `null` too for
7542
+ * an instance of a personal agent (planned), whose microVM the generic sandboxes API does not reach.
7543
+ */
5625
7544
  sandbox_id: string | null;
5626
7545
  /** Host memory the instance holds now (0 when hibernated or dormant). */
5627
7546
  resident_mib: number;
@@ -5675,6 +7594,16 @@ export type AgentInstanceEventList = Omit<ListEnvelope, "data"> & {
5675
7594
  /**
5676
7595
  * Your message. Every member but the reserved ones (`type`, `conversation`, `subject`, `metadata`, `create`,
5677
7596
  * `webhook`) is yours, and reaches the harness as `message`, with `type`.
7597
+ *
7598
+ * A message to an agent with a `harness` block (planned) is closed instead. Besides the reserved members it takes
7599
+ * `text` (the prompt, a string of 1 to 262,144 characters, required), `context` (at most 16 `{text, source?}`
7600
+ * objects, each quoted as information), `profile` (one of the definition's credential profiles) and, from a
7601
+ * listener's actor sink (`type: listener.event`), `event`, quoted whole, in place of `text`. Any other member is
7602
+ * `400 invalid_request`, so a field the harness would not read is refused, not dropped. A listener's message
7603
+ * is `422 harness_capability_unsupported` until the harness's shim quotes its `event`.
7604
+ * `source`, `limits` and `parent` are reserved there for the run contract.
7605
+ * These members bind harness agents only: an agent with an `entry` keeps every member but the reserved ones as
7606
+ * its own.
5678
7607
  */
5679
7608
  export interface AgentMessageRequest {
5680
7609
  /**
@@ -5728,6 +7657,8 @@ export type AgentSessionList = Omit<ListEnvelope, "data"> & {
5728
7657
 
5729
7658
  /**
5730
7659
  * `session.waking` carries `woke_from`; `session.output` carries `data`, one event the harness streamed, as text.
7660
+ * For an agent with a `harness` block (planned), each `session.output`'s `data` is one `AgentHarnessEvent` as
7661
+ * JSON, as the node wrote it to the instance's event log (its `seq` is the log's, not this stream's).
5731
7662
  */
5732
7663
  export type AgentSessionEvent = JobEvent & {
5733
7664
  woke_from?: AgentWokeFrom;
@@ -5763,7 +7694,7 @@ export interface RoutineDefinition {
5763
7694
  */
5764
7695
  vars?: Record<string, unknown>;
5765
7696
  /**
5766
- * How runs start besides POST /v1/routines/{id}/runs. Triggers switch atomically when a new version is published. Action triggers are trigger subscriptions (tsub_): publishing a version creates or updates them, and a rollback or delete removes them (README, 'Pack triggers').
7697
+ * How runs start besides POST /v1/routines/{id}/runs. Triggers switch atomically when a new version is published. Action triggers are trigger subscriptions (tsub_): publishing a version creates or updates them, and a rollback or delete removes them (README, 'Pack triggers'). Listener triggers are listeners (lsn_): one the trigger declares is the routine's own (publishing creates it, and a version without the trigger or a delete removes it); one the trigger names by id or name is bound for as long as a version names it (README, 'Listener triggers').
5767
7698
  */
5768
7699
  triggers?: RoutineDefinitionTrigger[];
5769
7700
  defaults?: {
@@ -5983,15 +7914,19 @@ export type RoutineDefinitionCatchUp = "skip" | "latest" | "all";
5983
7914
  export type RoutineDefinitionOverlap = "skip" | "buffer_one" | "allow" | "cancel_running";
5984
7915
 
5985
7916
  /**
5986
- * trigger context by type. cron and interval: {type, id, occurrence_id, scheduled_at, fired_at}. webhook: {type, id, hook_id, delivery_id, received_at, method, headers (lowercase map), query (map), body (parsed JSON when the request is JSON, else string)}. action: {type, id, subscription_id, event_id, event_type, source, time, data (the pack trigger's event data, valid against its eventSchema)}. Runs started through the API: {type: api}; sub-routine runs: {type: routine, parent_run_id, parent_step_id}.
7917
+ * trigger context by type. cron and interval: {type, id, occurrence_id, scheduled_at, fired_at}. webhook: {type, id, hook_id, delivery_id, received_at, method, headers (lowercase map), query (map), body (parsed JSON when the request is JSON, else string)}. action: {type, id, subscription_id, event_id, event_type, source, time, data (the pack trigger's event data, valid against its eventSchema)}. listener: {type, id, listener_id, event_id, seq, dedupe_key, received_at, payload (the event as the listener kept it, after redact), trace_id (the run's trace, derived from the listener and the event)}. Runs started through the API: {type: api}; sub-routine runs: {type: routine, parent_run_id, parent_step_id}.
5987
7918
  */
5988
7919
  export type RoutineDefinitionTrigger = {
5989
- type: "cron" | "interval" | "webhook" | "action";
7920
+ type: "cron" | "interval" | "webhook" | "action" | "listener";
5990
7921
  id: RoutineDefinitionIdent;
5991
7922
  /** action only: the pack trigger to subscribe to. */
5992
7923
  uses?: RoutineDefinitionTriggerRef;
5993
7924
  /**
5994
- * cron, interval, webhook: the run input built from the event (context: trigger, vars), validated against inputs; absent: {} plus input defaults. action: the pack trigger's configuration, validated against its configSchema and evaluated once when the version is published (context: vars only); action runs start with {} plus input defaults and read the event from trigger.data.
7925
+ * listener only: an object declares the routine's own listener (listenerTrigger); a string names a listener that already exists in the project (listenerRef).
7926
+ */
7927
+ listener?: RoutineDefinitionListenerTrigger | RoutineDefinitionListenerRef;
7928
+ /**
7929
+ * cron, interval, webhook, listener: the run input built from the event (context: trigger, vars), validated against inputs; absent: {} plus input defaults. action: the pack trigger's configuration, validated against its configSchema and evaluated once when the version is published (context: vars only); action runs start with {} plus input defaults and read the event from trigger.data.
5995
7930
  */
5996
7931
  with?: RoutineDefinitionTemplateObject;
5997
7932
  /**
@@ -5999,7 +7934,7 @@ export type RoutineDefinitionTrigger = {
5999
7934
  */
6000
7935
  connections?: Record<string, RoutineDefinitionConnectionRef>;
6001
7936
  /**
6002
- * Start a run only when true (context: trigger, vars). A webhook delivery that does not match is acknowledged with 202 and starts nothing; an action event that does not match is dropped. Status functions are not available here.
7937
+ * Start a run only when true (context: trigger, vars). A webhook delivery that does not match is acknowledged with 202 and starts nothing; an action or listener event that does not match is dropped. Status functions are not available here.
6003
7938
  */
6004
7939
  if?: RoutineDefinitionCondition;
6005
7940
  /**
@@ -6029,6 +7964,31 @@ export type RoutineDefinitionTrigger = {
6029
7964
  dedupe?: RoutineDefinitionCelExpression;
6030
7965
  };
6031
7966
 
7967
+ /**
7968
+ * listener only: the listener the trigger holds, in the shape of POST /v1/listeners (listeners.yaml ListenerCreateRequest) without sink, name, ttl_s, expires_at and metadata: its sink is this routine and it lives as long as a version with this trigger is active. Publishing creates it (lsn_, owned by the routine, read-only in /v1/listeners) as the publishing key, which needs routines:run; the listeners product validates it, and a refusal fails the publish with routine_invalid pointing into this object. Taken as written: nothing in it is evaluated as a routine expression (an http_poll URL's ${{ cursor }} is the listener's own).
7969
+ */
7970
+ export interface RoutineDefinitionListenerTrigger {
7971
+ /** listeners.yaml ListenerSource: push, http_poll, sse, websocket, webhook or pack. */
7972
+ source: {
7973
+ type: "push" | "http_poll" | "sse" | "websocket" | "webhook" | "pack";
7974
+ };
7975
+ /** listeners.yaml ListenerDedupe. */
7976
+ dedupe?: Record<string, unknown>;
7977
+ /**
7978
+ * listeners.yaml ListenerFilter: a CEL filter over the event, or a model filter, applied before the event is kept.
7979
+ */
7980
+ filter?: Record<string, unknown>;
7981
+ /** listeners.yaml ListenerRedact: JSON pointers removed from each payload before it is kept. */
7982
+ redact?: string[];
7983
+ /** listeners.yaml ListenerBudgetRequest. */
7984
+ budget?: Record<string, unknown>;
7985
+ }
7986
+
7987
+ /**
7988
+ * listener only, behind the preview flag routines.named_listeners (with listeners.api): a listener that already exists in this project, by its id (lsn_...) or its name (among the listeners that have not ended; a name two of them share is refused). Publishing binds it: its sink becomes this routine and trigger (sink.bound in /v1/listeners), so its delivery, order and retries stay the listener's own. The publishing key needs listeners:read, and listeners:write when the listener's sink points anywhere else. A listener another trigger holds, one a routine made, or one that has ended is refused. A version without the trigger, a rollback to one, or deleting the routine unbinds it and pauses it (status_reason routine_unbound). Pausing the routine holds its deliveries until the sink's retry_for_s.
7989
+ */
7990
+ export type RoutineDefinitionListenerRef = string;
7991
+
6032
7992
  /**
6033
7993
  * webhook only: answer a provider's GET verification request, such as Meta's hub.challenge with hub.verify_token or Dropbox's challenge. GET /v1/routines/hooks/{hk_id}?<param>=<value>&<token_param>=<verify token> answers 200 text/plain with <value> and starts no run; a missing or wrong token answers 401 webhook_signature_invalid. <value> must be 1-1024 characters of A-Z a-z 0-9 and . _ ~ : + / = -. Without token_param and token_connection any caller gets the echo; the POST deliveries are verified by verify either way.
6034
7994
  */
@@ -6081,7 +8041,7 @@ export interface RoutineHook {
6081
8041
  export interface RoutineTrigger {
6082
8042
  /** The trigger's `id` in the definition. */
6083
8043
  id: string;
6084
- type: "cron" | "interval" | "webhook" | "action";
8044
+ type: "cron" | "interval" | "webhook" | "action" | "listener";
6085
8045
  status: "active" | "paused";
6086
8046
  /** Next scheduled fire (cron and interval), or `null`. */
6087
8047
  next_fire_at: string | null;
@@ -6091,6 +8051,10 @@ export interface RoutineTrigger {
6091
8051
  * The trigger subscription of an action trigger (`GET /v1/actions/subscriptions/{subscription_id}`), or `null`.
6092
8052
  */
6093
8053
  subscription_id: string | null;
8054
+ /**
8055
+ * The listener of a listener trigger (`GET /v1/listeners/{listener_id}`), or `null`. A listener the trigger declares is the routine's and read-only there; one it names stays its owner's, bound to this trigger (`sink.bound`).
8056
+ */
8057
+ listener_id: string | null;
6094
8058
  }
6095
8059
 
6096
8060
  export interface Routine {
@@ -6115,7 +8079,7 @@ export interface Routine {
6115
8079
  updated_at: string;
6116
8080
  metadata: Metadata;
6117
8081
  /**
6118
- * Present only when something about the active version needs attention. Today: a `product_unavailable` warning at `/triggers/<i>` for each action trigger whose subscription the actions product does not hold yet (it was not running, or answered 5xx or 429, when the version was published). The publish stands, the trigger starts no runs until it is subscribed, and routines retries the subscription every 10 seconds until the actions product takes it; the warning then goes away. A 4xx from the actions product fails the publish with `routine_invalid` instead.
8082
+ * Present only when something about the active version needs attention. Today: a `product_unavailable` warning at `/triggers/<i>` for each action trigger whose subscription the actions product does not hold yet (it was not running, or answered 5xx or 429, when the version was published). The publish stands, the trigger starts no runs until it is subscribed, and routines retries the subscription every 10 seconds until the actions product takes it; the warning then goes away. A 4xx from the actions product fails the publish with `routine_invalid` instead. For a listener trigger that names a listener, at `/triggers/<i>/listener`: `listener_not_found` when the listener was deleted or no longer feeds the trigger, and `listener_not_active` when it has ended or its owner paused it. The trigger starts no runs meanwhile; publish a version that names another listener, or resume it.
6119
8083
  */
6120
8084
  warnings?: Diagnostic[];
6121
8085
  }
@@ -6234,9 +8198,13 @@ export interface HookSecret {
6234
8198
 
6235
8199
  /** How the run started (the `trigger` context of its expressions). */
6236
8200
  export interface RunTrigger {
6237
- type: "api" | "cron" | "interval" | "webhook" | "action" | "routine" | "replay";
6238
- /** The trigger ID (cron, interval, webhook, action). */
8201
+ type: "api" | "cron" | "interval" | "webhook" | "action" | "listener" | "routine" | "replay";
8202
+ /**
8203
+ * The trigger ID (cron, interval, webhook, action, and listener triggers), or the listener (`lsn_`) of a listener whose sink names the routine.
8204
+ */
6239
8205
  id?: string;
8206
+ /** The listener that delivered the event (listener triggers). */
8207
+ listener_id?: string;
6240
8208
  /** Cron and interval occurrence, used to deduplicate fires. */
6241
8209
  occurrence_id?: string;
6242
8210
  scheduled_at?: string;
@@ -6244,8 +8212,12 @@ export interface RunTrigger {
6244
8212
  delivery_id?: string;
6245
8213
  /** The trigger subscription that delivered the event (action triggers). */
6246
8214
  subscription_id?: string;
6247
- /** The pack trigger event's ID (action triggers). */
8215
+ /** The pack trigger event's ID (action triggers), or the listener event's (`evt_`, listeners). */
6248
8216
  event_id?: string;
8217
+ /**
8218
+ * Listener runs. The run's trace (`GET /v1/traces/{trace_id}`), derived from the listener and the event, so a redelivery of the event lands in the same trace.
8219
+ */
8220
+ trace_id?: string;
6249
8221
  /** For sub-routine runs, the calling run; for replays, the source run. */
6250
8222
  parent_run_id?: string;
6251
8223
  parent_step_id?: string;
@@ -6684,8 +8656,8 @@ export interface RoutineSink {
6684
8656
  routine: string;
6685
8657
  /**
6686
8658
  * `run` starts a run of the routine's active version per event, with `trigger = {type: listener, id,
6687
- * event_id, seq, dedupe_key, received_at, payload}`; a redelivery of the same `dedupe_key` starts no
6688
- * second run. `event` sends the event to the routine's runs waiting with `wait: {event: <event>}`
8659
+ * event_id, seq, dedupe_key, received_at, payload, trace_id}`; a redelivery of the same `dedupe_key`
8660
+ * starts no second run. `event` sends the event to the routine's runs waiting with `wait: {event: <event>}`
6689
8661
  * (`routinesSendEvent`), with `data` = the payload.
6690
8662
  * @default "run"
6691
8663
  */
@@ -6703,6 +8675,25 @@ export interface RoutineSink {
6703
8675
  */
6704
8676
  retry_for_s?: number;
6705
8677
  batch?: ListenerBatch;
8678
+ /**
8679
+ * Set by routines on the listener of a routine's `type: listener` trigger: that trigger's ID. Routines
8680
+ * creates the listener when it publishes the version, as the publishing key, and removes it when a version
8681
+ * without the trigger is published or the routine is deleted. Each event starts a run with the trigger's
8682
+ * `if` and `with`, and `trigger = {type: listener, id: <trigger id>, listener_id, ...}`. Such a listener is
8683
+ * read-only here: PATCH and DELETE answer `409 listener_managed`. A request cannot set it. With `bound`,
8684
+ * the trigger names this listener instead (preview, `routines.named_listeners`): the listener is yours, and
8685
+ * only its sink is held.
8686
+ */
8687
+ trigger?: string;
8688
+ /**
8689
+ * True while a routine's `type: listener` trigger names this listener (by id or name) and its active
8690
+ * version is published: routines set `routine` and `trigger` when it bound the listener, keeping
8691
+ * `concurrency`, `retry_for_s` and `batch`. Every field but `sink` can still change; a PATCH of `sink`
8692
+ * answers `409 listener_bound`. A version without the trigger, or deleting the routine, clears it and
8693
+ * pauses the listener (`status_reason: routine_unbound`). While the routine is paused, deliveries are
8694
+ * retried until `retry_for_s`, then fail `routine_paused`. A request cannot set it.
8695
+ */
8696
+ bound?: boolean;
6706
8697
  }
6707
8698
 
6708
8699
  export interface WebhookSink {
@@ -6792,6 +8783,7 @@ export interface Listener {
6792
8783
  | "source_errors"
6793
8784
  | "owner_revoked"
6794
8785
  | "sandbox_ended"
8786
+ | "routine_unbound"
6795
8787
  | null;
6796
8788
  /** Why the source last failed, or why the listener ended `failed`. */
6797
8789
  error: {
@@ -6836,6 +8828,10 @@ export interface Listener {
6836
8828
  failed: number;
6837
8829
  skipped: number;
6838
8830
  reconnects: number;
8831
+ /**
8832
+ * Delivery attempts the sink answered with a retryable refusal (5xx, 429, a paused routine) and that were tried again. An event still refused at `retry_for_s` is counted in `failed`, with the refusal's code in its `delivery.last_error`.
8833
+ */
8834
+ retries?: number;
6839
8835
  last_event_at: string | null;
6840
8836
  };
6841
8837
  created_at: string;
@@ -6970,6 +8966,217 @@ export interface ListenerTestResult {
6970
8966
  event: ListenerEvent | null;
6971
8967
  }
6972
8968
 
8969
+ /**
8970
+ * One path rule. `path` is gitignore-style (`*` within a name, `**` across directories) and may use `{human}`,
8971
+ * `{initiator}` and `{agent}`, which bind to that principal's ID. `read` and `write` list selectors:
8972
+ * `agent:<id or name>`, `user:usr_…`, `role:owner|admin|member`, `subject:<id>`, `key:key_…`, `routine:rtn_…`,
8973
+ * `listener:lsn_…`, the bare roles `agent`, `human` and `initiator`, and `project`. A null list leaves that side
8974
+ * to the rules before it.
8975
+ */
8976
+ export interface WorkspaceRule {
8977
+ path: string;
8978
+ read?: string[] | null;
8979
+ write?: string[] | null;
8980
+ /**
8981
+ * A commit may only add bytes at the end of a matching file.
8982
+ * @default false
8983
+ */
8984
+ append_only?: boolean;
8985
+ }
8986
+
8987
+ export interface WorkspaceCreateRequest {
8988
+ /** Unique in the project. */
8989
+ name: string;
8990
+ rules?: WorkspaceRule[];
8991
+ metadata?: Metadata;
8992
+ }
8993
+
8994
+ export interface WorkspaceRulesRequest {
8995
+ rules: WorkspaceRule[];
8996
+ }
8997
+
8998
+ export interface Workspace {
8999
+ id: string;
9000
+ object: "workspace";
9001
+ name: string;
9002
+ status: "active" | "deleted";
9003
+ default_branch: string;
9004
+ /** The head commit of the default branch; null before the first commit. */
9005
+ head: string | null;
9006
+ rules: WorkspaceRule[];
9007
+ usage: {
9008
+ /** Unique content bytes stored, the unit of `workspaces.storage_gib_h`. */
9009
+ bytes: number;
9010
+ /** Files at the head of the default branch. */
9011
+ files: number;
9012
+ commits: number;
9013
+ open_branches: number;
9014
+ };
9015
+ created_at: string;
9016
+ updated_at: string;
9017
+ metadata: Metadata;
9018
+ }
9019
+
9020
+ export type WorkspaceList = Omit<ListEnvelope, "data"> & {
9021
+ data: Workspace[];
9022
+ };
9023
+
9024
+ export type BranchStatus = "open" | "merged" | "closed" | "expired";
9025
+
9026
+ export interface BranchCreateRequest {
9027
+ /**
9028
+ * A branch name or ID, or a commit ID, to start from.
9029
+ * @default "main"
9030
+ */
9031
+ from?: string;
9032
+ /** Unique among the workspace's open branches. Without one the branch is ephemeral. */
9033
+ name?: string;
9034
+ /** An ephemeral branch's lifetime; 604,800 (7 days) by default. */
9035
+ ttl_s?: number;
9036
+ metadata?: Metadata;
9037
+ }
9038
+
9039
+ export type PrincipalRef = {
9040
+ kind: "agent" | "routine" | "key" | "user" | "subject" | "sandbox" | "instance" | "routine_run" | "listener";
9041
+ id: string;
9042
+ } | null;
9043
+
9044
+ export interface Branch {
9045
+ id: string;
9046
+ object: "branch";
9047
+ workspace: string;
9048
+ name: string;
9049
+ kind: "named" | "ephemeral";
9050
+ /** Merging into it needs `workspaces:write` (`main` is protected). */
9051
+ protected: boolean;
9052
+ status: BranchStatus;
9053
+ /** The commit the branch started from; null for a branch of an empty workspace. */
9054
+ base: string | null;
9055
+ head: string | null;
9056
+ holder: PrincipalRef;
9057
+ expires_at: string | null;
9058
+ created_at: string;
9059
+ metadata: Metadata;
9060
+ }
9061
+
9062
+ export type BranchList = Omit<ListEnvelope, "data"> & {
9063
+ data: Branch[];
9064
+ };
9065
+
9066
+ /** One file to write (`content` as UTF-8 text or `content_base64` as bytes) or to delete. */
9067
+ export interface CommitFile {
9068
+ /** Absolute in the workspace (`/notes/today.md`); no `..`, no empty segment. */
9069
+ path: string;
9070
+ content?: string;
9071
+ content_base64?: string;
9072
+ /**
9073
+ * A regular file, an executable, or a symlink whose content is its target.
9074
+ * @default "100644"
9075
+ */
9076
+ mode?: "100644" | "100755" | "120000";
9077
+ delete?: boolean;
9078
+ }
9079
+
9080
+ export interface CommitRequest {
9081
+ message: string;
9082
+ /**
9083
+ * The files to write or delete. Required, except from inside the sandbox that holds the branch (its
9084
+ * `workspaces` member on create): there, without `files`, the commit is what the sandbox changed under the
9085
+ * branch's path.
9086
+ */
9087
+ files?: CommitFile[];
9088
+ /**
9089
+ * The end user this call works for: the `human` principal the workspace's rules check. Only a credential holding
9090
+ * `workspaces:subjects:assert` may name one (`403 forbidden`, reason `scope`), never a sandbox's own credential
9091
+ * (reason `sandbox`). 1 to 200 letters, digits or `._:@-`.
9092
+ */
9093
+ subject?: string;
9094
+ if_head?: string;
9095
+ }
9096
+
9097
+ export interface Commit {
9098
+ id: string;
9099
+ object: "commit";
9100
+ workspace: string;
9101
+ /** The branch it was made on. */
9102
+ branch: string;
9103
+ parents: string[];
9104
+ /** The git tree ID of its content. */
9105
+ tree: string;
9106
+ /** Its git commit ID, the same after a push to a git remote. */
9107
+ git_sha: string;
9108
+ message: string;
9109
+ principals: {
9110
+ agent: PrincipalRef;
9111
+ human: PrincipalRef;
9112
+ initiator: PrincipalRef;
9113
+ };
9114
+ stats: {
9115
+ files_changed: number;
9116
+ /** New content bytes the commit stored. */
9117
+ bytes: number;
9118
+ };
9119
+ created_at: string;
9120
+ }
9121
+
9122
+ export type CommitList = Omit<ListEnvelope, "data"> & {
9123
+ data: Commit[];
9124
+ };
9125
+
9126
+ export interface MergeRequest {
9127
+ /**
9128
+ * The end user this call works for: the `human` principal the workspace's rules check. Only a credential holding
9129
+ * `workspaces:subjects:assert` may name one (`403 forbidden`, reason `scope`), never a sandbox's own credential
9130
+ * (reason `sandbox`). 1 to 200 letters, digits or `._:@-`.
9131
+ */
9132
+ subject?: string;
9133
+ /**
9134
+ * The target branch, by name or ID.
9135
+ * @default "main"
9136
+ */
9137
+ into?: string;
9138
+ /** @default "three_way" */
9139
+ mode?: "three_way" | "paths";
9140
+ /** Merge only while the target's head is this commit. */
9141
+ if_head?: string;
9142
+ message?: string;
9143
+ }
9144
+
9145
+ export interface MergeResult {
9146
+ object: "workspace_merge";
9147
+ into: string;
9148
+ /** The target had not moved since the branch's base, so its head became the branch's head. */
9149
+ fast_forward: boolean;
9150
+ commit: Commit;
9151
+ }
9152
+
9153
+ export interface WorkspaceDiff {
9154
+ object: "workspace_diff";
9155
+ base: string;
9156
+ head: string;
9157
+ changes: {
9158
+ path: string;
9159
+ kind: "added" | "modified" | "deleted" | "type_changed";
9160
+ old_size: number | null;
9161
+ new_size: number | null;
9162
+ }[];
9163
+ /** More than 10,000 changes; narrow it with `path`. */
9164
+ truncated: boolean;
9165
+ }
9166
+
9167
+ export interface WorkspaceEntry {
9168
+ path: string;
9169
+ type: "file" | "dir" | "symlink";
9170
+ size: number | null;
9171
+ mode: string;
9172
+ /** The git blob ID; null for a directory. */
9173
+ blob: string | null;
9174
+ }
9175
+
9176
+ export type WorkspaceEntryList = Omit<ListEnvelope, "data"> & {
9177
+ data: WorkspaceEntry[];
9178
+ };
9179
+
6973
9180
  /**
6974
9181
  * One JSON-RPC 2.0 message of the Model Context Protocol (https://modelcontextprotocol.io): a request
6975
9182
  * (`method` and `id`), a notification (`method`, no `id`) or a response (`result` or `error`). Methods served:
@@ -7229,7 +9436,7 @@ export interface B3PackHttpResponse {
7229
9436
  }
7230
9437
 
7231
9438
  /**
7232
- * How the action runs. http = T0, declarative HTTP inside b3osd. js = T1, a first-party ES module run by the actions-js sidecar (packages/spec/sidecars/actions-js.md). vm = a hosted tool: each call runs cmd in a fresh microVM of tool.base with the tool's archive unpacked at /tool, the request as one JSON object on stdin and one JSON object as the last line of stdout (protocol json-stdio, README 'Hosted tools').
9439
+ * How the action runs. http = T0, declarative HTTP inside b3osd. js = T1, a first-party ES module run by the actions-js sidecar (packages/spec/sidecars/actions-js.md). vm = a hosted tool: each call runs cmd in a fresh microVM of tool.base with the tool's archive unpacked at /tool (or of the tool's image, tool.image), the request as one JSON object on stdin and one JSON object as the last line of stdout (protocol json-stdio, README 'Hosted tools'); or, for an image tool, the argv template filled from the call's input (protocol argv).
7233
9440
  */
7234
9441
  export type B3PackImpl =
7235
9442
  | {
@@ -7256,9 +9463,20 @@ export type B3PackImpl =
7256
9463
  */
7257
9464
  protocol: "json-stdio";
7258
9465
  /**
7259
- * The command and its arguments, run with no shell, working directory /work, as the guest's user. Fixed text: no caller value ever enters it. cmd[0] is a path under /tool/ (publish check 18).
9466
+ * The command and its arguments, run with no shell, working directory /work, as the guest's user (an image tool: the image's USER). Fixed text: no caller value ever enters it. cmd[0] is a path under /tool/, or for an image tool an absolute path in the image (publish check 18).
7260
9467
  */
7261
9468
  cmd: string[];
9469
+ }
9470
+ | {
9471
+ kind: "vm";
9472
+ /**
9473
+ * Image tools only (publish check 18). The node fills argv from the call's input and runs it with no shell, stdin empty, in /work, as the image's USER; the output is the files the {out:<file>} tokens name, or stdout as the output stdout (README 'Hosted tools: the argv call').
9474
+ */
9475
+ protocol: "argv";
9476
+ /**
9477
+ * The command line as words. argv[0] names the program (a name the image's PATH finds, or an absolute path) and holds no token. In the other words: {x} the string input x, {x:int} the integer input x, {x:file} and {x:file=<media type>} the path of the input file x, {out:<file>} the path /out/<file> of an output file the program writes (the output field is the file name before its first dot), {{ and }} a literal brace. A value is always one argument, never split or expanded (publish check 18).
9478
+ */
9479
+ argv: string[];
7262
9480
  };
7263
9481
 
7264
9482
  export type B3PackExample =
@@ -7492,21 +9710,23 @@ export type B3PackTrigger = {
7492
9710
  };
7493
9711
 
7494
9712
  /**
7495
- * A hosted tool: the software a pack's vm actions run, and what it needs to run. Required when any action is vm and refused otherwise (publish checks 13 to 23). The schema admits the values of later versions (mcp, the other bases, session, hosts, caller, any size) and the reserved keys (setup, image, formats, bundle.files, base.range), so that what this version refuses is refused with a plain sentence of the publish checks rather than a schema error.
9713
+ * A hosted tool: the software a pack's vm actions run, and what it needs to run. Required when any action is vm and refused otherwise (publish checks 13 to 23). The schema admits the values of later versions (mcp, the other bases, session, hosts, caller, any size) and the reserved keys (setup, formats, bundle.files, base.range, image.build, image.auth), so that what this version refuses is refused with a plain sentence of the publish checks rather than a schema error. A tool names tool.base (with tool.bundle) or tool.image, never both (publish check 14).
7496
9714
  */
7497
9715
  export interface B3PackTool {
7498
9716
  /**
7499
9717
  * cli: a command that reads a request on stdin and writes an answer on stdout. mcp (later, not in this version): an MCP server. Shown on the listing.
7500
9718
  */
7501
9719
  kind: "cli" | "mcp";
7502
- /** The shared template the tool runs on. Bases have no versions yet. */
7503
- base: {
9720
+ /**
9721
+ * The shared template the tool runs on, with its archive (tool.bundle). Bases have no versions yet. Absent when tool.image names an image.
9722
+ */
9723
+ base?: {
7504
9724
  name: "base" | "files" | "browser" | "code-interpreter";
7505
9725
  /** Reserved: not read, because bases have no versions yet. Refused in this version. */
7506
9726
  range?: string;
7507
9727
  };
7508
9728
  /**
7509
- * The tool VM's size, one of the base's size classes. Absent: 1 vCPU and 512 MiB, the only size of this version.
9729
+ * The tool VM's size, one of the base's size classes. Absent: 1 vCPU and 512 MiB, the only size of a tool on base in this version; an image tool takes 1x512, 1x1024 or 2x2048 (publish check 14).
7510
9730
  */
7511
9731
  size?: {
7512
9732
  vcpu: number;
@@ -7565,8 +9785,21 @@ export interface B3PackTool {
7565
9785
  * Reserved: a command run once when the node prepares the tool's snapshot (later). Refused in this version.
7566
9786
  */
7567
9787
  setup?: unknown;
7568
- /** Reserved: an imported image's artifact (later). Refused in this version. */
7569
- image?: unknown;
9788
+ /**
9789
+ * The OCI image the tool runs (slice C), in place of tool.base and tool.bundle: each call restores a fresh microVM from the image's template on the node, with no network. Org-private tools only in this version (publish check 14).
9790
+ */
9791
+ image?: {
9792
+ /**
9793
+ * The image, pinned by digest: [<registry>/]<name>[:<tag>]@sha256:<64 hex>, from a public registry, for linux/amd64. b3os tool init --from-image resolves a tag to its digest.
9794
+ */
9795
+ ref?: string;
9796
+ /**
9797
+ * Reserved: an image built from a Dockerfile and a context the registry stores (later). Refused in this version.
9798
+ */
9799
+ build?: unknown;
9800
+ /** Reserved: a vault connection for a private registry (later). Refused in this version. */
9801
+ auth?: unknown;
9802
+ };
7570
9803
  /** Reserved: output formats a takedown can turn off by name (later). Refused in this version. */
7571
9804
  formats?: unknown;
7572
9805
  /**
@@ -7882,8 +10115,14 @@ export interface ToolAllIn {
7882
10115
  */
7883
10116
  export interface ActionTool {
7884
10117
  kind: "cli";
7885
- /** The template its VM is made from. */
10118
+ /** The template its VM is made from; empty for a tool built from an image (`image`). */
7886
10119
  base: string;
10120
+ /**
10121
+ * A tool built from an image (slice C, behind the preview flag `actions.tools_image`): the image, pinned by
10122
+ * digest (`tool.image.ref`). Each node imports it at the version's first call, and each call restores a fresh
10123
+ * VM from its template with no network. Absent for a tool on a base.
10124
+ */
10125
+ image?: string;
7887
10126
  network: "none";
7888
10127
  price: ToolPrice;
7889
10128
  /** `execution.maxInputMb`: the most input file data one call may carry, in MiB. */
@@ -7901,7 +10140,8 @@ export interface ActionTool {
7901
10140
  /**
7902
10141
  * The node's estimate of the time from claim to the tool's command starting, in milliseconds, for this
7903
10142
  * version's archive: a warm-pool claim plus the copy and the unpack for its size and format, from the
7904
- * table measured on 2026-11-13 (warm pool, 1 vCPU and 512 MiB).
10143
+ * table measured on 2026-11-13 (warm pool, 1 vCPU and 512 MiB). For a tool built from an image, the
10144
+ * warm-pool claim alone: nothing is copied or unpacked.
7905
10145
  */
7906
10146
  start_estimate_ms: number;
7907
10147
  /** What one call costs all in, or `null` before this version's first call on this node. */
@@ -9054,6 +11294,10 @@ export interface ApiKeyCreateRequest {
9054
11294
  /** Defaults to the caller's project. */
9055
11295
  project_id?: string;
9056
11296
  spend_cap_usd?: number | null;
11297
+ /**
11298
+ * When the key stops working. Left out: 90 days from now for a key made with a CLI token, never for one made
11299
+ * with a dashboard session or an API key that does not expire; an API key that expires must set it.
11300
+ */
9057
11301
  expires_at?: string | null;
9058
11302
  metadata?: Metadata;
9059
11303
  }
@@ -9367,8 +11611,10 @@ export type ToolBlockList = Omit<ListEnvelope, "data"> & {
9367
11611
  data: ToolBlock[];
9368
11612
  };
9369
11613
 
9370
- /** An option's value; for an enum option, one of its values (`x-b3os-options`). */
9371
- export type SettingValue = string | number | boolean;
11614
+ /**
11615
+ * An option's value: for an enum option, one of its values; for an object option, an object of the members its catalog row names in `fields` (`x-b3os-options`), such as `platform.export_otlp`'s `{url, connection, header, content}`. An unset object option resolves to null.
11616
+ */
11617
+ export type SettingValue = string | number | boolean | Record<string, unknown> | null;
9372
11618
 
9373
11619
  export interface SettingRequest {
9374
11620
  value: SettingValue;
@@ -9503,6 +11749,14 @@ export interface RequestRecord {
9503
11749
  phases: RequestPhase[];
9504
11750
  /** The W3C trace ID from `traceparent`, when sent. */
9505
11751
  trace_id: string | null;
11752
+ /**
11753
+ * The span id the node gave this request (with `traceparent` sent): the parent id in the `traceparent` its
11754
+ * handler passes on, so a request it made (an MCP product tool's) names it in `parent_span_id`. Absent from
11755
+ * records written before node release 1127 and from requests the edge answered itself.
11756
+ */
11757
+ span_id?: string | null;
11758
+ /** The span id in the `traceparent` the request arrived with (its caller's span), when sent. */
11759
+ parent_span_id?: string | null;
9506
11760
  user_agent: string | null;
9507
11761
  source: RequestSource;
9508
11762
  action?: RequestAction;
@@ -9855,6 +12109,17 @@ export interface VisionListCrawlPagesParams {
9855
12109
  status?: "succeeded" | "failed";
9856
12110
  }
9857
12111
 
12112
+ /** Parameters of `listIdentities`. */
12113
+ export interface VisionListIdentitiesParams {
12114
+ /**
12115
+ * Page size, from 1 to 100.
12116
+ * @default 20
12117
+ */
12118
+ limit?: number;
12119
+ /** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
12120
+ cursor?: string;
12121
+ }
12122
+
9858
12123
  /** Parameters of `listProfiles`. */
9859
12124
  export interface VisionListProfilesParams {
9860
12125
  /**
@@ -10026,6 +12291,19 @@ export interface SandboxesListSandboxesParams {
10026
12291
  metadata?: Record<string, string>;
10027
12292
  }
10028
12293
 
12294
+ /** Parameters of `getCapacity`. */
12295
+ export interface SandboxesGetCapacityParams {
12296
+ /**
12297
+ * Template name or `tpl_` ID.
12298
+ * @default "desktop"
12299
+ */
12300
+ template?: string;
12301
+ /** vCPUs of each sandbox; the template's default when left out. */
12302
+ vcpu?: number;
12303
+ /** Memory of each sandbox, MiB; the template's default when left out. */
12304
+ memory_mib?: number;
12305
+ }
12306
+
10029
12307
  /** Parameters of `listSnapshots`. */
10030
12308
  export interface SandboxesListSnapshotsParams {
10031
12309
  /**
@@ -10089,6 +12367,17 @@ export interface SandboxesListVolumesParams {
10089
12367
  status?: "available" | "attached" | "deleted";
10090
12368
  }
10091
12369
 
12370
+ /** Parameters of `computerScreenshot`. */
12371
+ export interface SandboxesComputerScreenshotParams {
12372
+ /** `png` or `jpeg`. Without it: the image type `Accept` names, else `jpeg`. */
12373
+ format?: "png" | "jpeg";
12374
+ /**
12375
+ * JPEG quality, 1 to 100.
12376
+ * @default 80
12377
+ */
12378
+ quality?: number;
12379
+ }
12380
+
10092
12381
  /** Parameters of `deleteFile`. */
10093
12382
  export interface SandboxesDeleteFileParams {
10094
12383
  /** Absolute path inside the sandbox. */
@@ -10191,6 +12480,20 @@ export interface ImagesGetImageParams {
10191
12480
  wait?: number;
10192
12481
  }
10193
12482
 
12483
+ /** Parameters of `getImageLogs`. */
12484
+ export interface ImagesGetImageLogsParams {
12485
+ /**
12486
+ * The first line to answer (0 is the first).
12487
+ * @default 0
12488
+ */
12489
+ offset?: number;
12490
+ /**
12491
+ * Hold the answer up to this many seconds until there are lines past `offset` or the image settles.
12492
+ * @default 0
12493
+ */
12494
+ wait?: number;
12495
+ }
12496
+
10194
12497
  /** Parameters of `listAgents`. */
10195
12498
  export interface AgentsListAgentsParams {
10196
12499
  /**
@@ -10226,6 +12529,53 @@ export interface AgentsListInstanceEventsParams {
10226
12529
  cursor?: string;
10227
12530
  }
10228
12531
 
12532
+ /** Parameters of `listGrants`. */
12533
+ export interface AgentsListGrantsParams {
12534
+ /**
12535
+ * Page size, from 1 to 100.
12536
+ * @default 20
12537
+ */
12538
+ limit?: number;
12539
+ /** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
12540
+ cursor?: string;
12541
+ }
12542
+
12543
+ /** Parameters of `openTerminal`. */
12544
+ export interface AgentsOpenTerminalParams {
12545
+ /**
12546
+ * `view` (the default) or `control`, which also needs `agents:run`.
12547
+ * @default "view"
12548
+ */
12549
+ role?: "view" | "control";
12550
+ /** The byte offset to resume from, with `session`. Without it the socket starts at the current screen. */
12551
+ cursor?: number;
12552
+ /** The terminal (`pts_…`) the `cursor` belongs to, from the session frame of the socket you resume. */
12553
+ session?: string;
12554
+ /** Which harness session's terminal, when the instance has more than one. Default `default`. */
12555
+ conversation?: string;
12556
+ /**
12557
+ * `main` (the default): the harness's terminal. `signin:<profile>` and `signout:<profile>`: the sign-in
12558
+ * and sign-out windows for one of the definition's `signin` profiles, for a personal agent's owner only.
12559
+ * @default "main"
12560
+ */
12561
+ window?: string;
12562
+ /** The controller's width; ignored for a viewer. */
12563
+ cols?: number;
12564
+ /** The controller's height; ignored for a viewer. */
12565
+ rows?: number;
12566
+ }
12567
+
12568
+ /** Parameters of `listRecordings`. */
12569
+ export interface AgentsListRecordingsParams {
12570
+ /**
12571
+ * Page size, from 1 to 100.
12572
+ * @default 20
12573
+ */
12574
+ limit?: number;
12575
+ /** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
12576
+ cursor?: string;
12577
+ }
12578
+
10229
12579
  /** Parameters of `listSessions`. */
10230
12580
  export interface AgentsListSessionsParams {
10231
12581
  /**
@@ -10332,6 +12682,89 @@ export interface ListenersListEventsParams {
10332
12682
  status?: ListenerEventStatus;
10333
12683
  }
10334
12684
 
12685
+ /** Parameters of `listWorkspaces`. */
12686
+ export interface WorkspacesListWorkspacesParams {
12687
+ /**
12688
+ * Page size, from 1 to 100.
12689
+ * @default 20
12690
+ */
12691
+ limit?: number;
12692
+ /** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
12693
+ cursor?: string;
12694
+ }
12695
+
12696
+ /** Parameters of `listBranches`. */
12697
+ export interface WorkspacesListBranchesParams {
12698
+ /**
12699
+ * Page size, from 1 to 100.
12700
+ * @default 20
12701
+ */
12702
+ limit?: number;
12703
+ /** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
12704
+ cursor?: string;
12705
+ /** Only the branch with this name. */
12706
+ name?: string;
12707
+ /** Only branches in this status. */
12708
+ status?: BranchStatus;
12709
+ }
12710
+
12711
+ /** Parameters of `listCommits`. */
12712
+ export interface WorkspacesListCommitsParams {
12713
+ /**
12714
+ * Page size, from 1 to 100.
12715
+ * @default 20
12716
+ */
12717
+ limit?: number;
12718
+ /** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
12719
+ cursor?: string;
12720
+ /** The branch whose history to list (`br_…`); `main` when absent. */
12721
+ branch_id?: string;
12722
+ }
12723
+
12724
+ /** Parameters of `diff`. */
12725
+ export interface WorkspacesDiffParams {
12726
+ /**
12727
+ * The end user this call works for: the `human` principal the workspace's rules check. Only a credential holding
12728
+ * `workspaces:subjects:assert` may name one (`403 forbidden`, reason `scope`), never a sandbox's own credential
12729
+ * (reason `sandbox`). 1 to 200 letters, digits or `._:@-`.
12730
+ */
12731
+ subject?: string;
12732
+ /** A commit ID (`cmt_…`) or a branch name. */
12733
+ base: string;
12734
+ /** A commit ID (`cmt_…`) or a branch name. */
12735
+ head: string;
12736
+ /** Only paths under this directory. */
12737
+ path?: string;
12738
+ }
12739
+
12740
+ /** Parameters of `listFiles`. */
12741
+ export interface WorkspacesListFilesParams {
12742
+ /**
12743
+ * The end user this call works for: the `human` principal the workspace's rules check. Only a credential holding
12744
+ * `workspaces:subjects:assert` may name one (`403 forbidden`, reason `scope`), never a sandbox's own credential
12745
+ * (reason `sandbox`). 1 to 200 letters, digits or `._:@-`.
12746
+ */
12747
+ subject?: string;
12748
+ /** A commit ID (`cmt_…`) or a branch name; `main` when absent. */
12749
+ ref?: string;
12750
+ /** The directory or file, absolute in the workspace; `/` when absent. */
12751
+ path?: string;
12752
+ }
12753
+
12754
+ /** Parameters of `readFile`. */
12755
+ export interface WorkspacesReadFileParams {
12756
+ /**
12757
+ * The end user this call works for: the `human` principal the workspace's rules check. Only a credential holding
12758
+ * `workspaces:subjects:assert` may name one (`403 forbidden`, reason `scope`), never a sandbox's own credential
12759
+ * (reason `sandbox`). 1 to 200 letters, digits or `._:@-`.
12760
+ */
12761
+ subject?: string;
12762
+ /** A commit ID (`cmt_…`) or a branch name; `main` when absent. */
12763
+ ref?: string;
12764
+ /** The file, absolute in the workspace. */
12765
+ path: string;
12766
+ }
12767
+
10335
12768
  /** Parameters of `describe`. */
10336
12769
  export interface ActionsDescribeParams {
10337
12770
  /** `<namespace>/<name>/<action>@<version>`; the version may be exact (`1.0.0`) or a major (`1`). */