@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.
- package/README.md +1 -1
- package/dist/cjs/core/util.d.ts +1 -1
- package/dist/cjs/core/util.js +1 -1
- package/dist/cjs/generated/client.d.ts +5 -0
- package/dist/cjs/generated/client.js +9 -0
- package/dist/cjs/generated/client.js.map +1 -1
- package/dist/cjs/generated/errors.d.ts +1 -1
- package/dist/cjs/generated/errors.js +45 -0
- package/dist/cjs/generated/errors.js.map +1 -1
- package/dist/cjs/generated/ids.d.ts +28 -0
- package/dist/cjs/generated/ids.js +7 -0
- package/dist/cjs/generated/ids.js.map +1 -1
- package/dist/cjs/generated/ns/agents.d.ts +449 -11
- package/dist/cjs/generated/ns/agents.js +609 -11
- package/dist/cjs/generated/ns/agents.js.map +1 -1
- package/dist/cjs/generated/ns/images.d.ts +84 -3
- package/dist/cjs/generated/ns/images.js +126 -2
- package/dist/cjs/generated/ns/images.js.map +1 -1
- package/dist/cjs/generated/ns/keys.d.ts +12 -4
- package/dist/cjs/generated/ns/keys.js +12 -4
- package/dist/cjs/generated/ns/keys.js.map +1 -1
- package/dist/cjs/generated/ns/listeners.d.ts +6 -2
- package/dist/cjs/generated/ns/listeners.js +6 -2
- package/dist/cjs/generated/ns/listeners.js.map +1 -1
- package/dist/cjs/generated/ns/routines.d.ts +11 -0
- package/dist/cjs/generated/ns/routines.js +11 -0
- package/dist/cjs/generated/ns/routines.js.map +1 -1
- package/dist/cjs/generated/ns/sandboxes.d.ts +140 -1
- package/dist/cjs/generated/ns/sandboxes.js +190 -1
- package/dist/cjs/generated/ns/sandboxes.js.map +1 -1
- package/dist/cjs/generated/ns/vision.d.ts +55 -1
- package/dist/cjs/generated/ns/vision.js +94 -1
- package/dist/cjs/generated/ns/vision.js.map +1 -1
- package/dist/cjs/generated/ns/workspaces.d.ts +225 -0
- package/dist/cjs/generated/ns/workspaces.js +410 -0
- package/dist/cjs/generated/ns/workspaces.js.map +1 -0
- package/dist/cjs/generated/types.d.ts +2312 -90
- package/dist/esm/core/util.d.ts +1 -1
- package/dist/esm/core/util.js +1 -1
- package/dist/esm/generated/client.d.ts +5 -0
- package/dist/esm/generated/client.js +9 -0
- package/dist/esm/generated/client.js.map +1 -1
- package/dist/esm/generated/errors.d.ts +1 -1
- package/dist/esm/generated/errors.js +45 -0
- package/dist/esm/generated/errors.js.map +1 -1
- package/dist/esm/generated/ids.d.ts +28 -0
- package/dist/esm/generated/ids.js +7 -0
- package/dist/esm/generated/ids.js.map +1 -1
- package/dist/esm/generated/ns/agents.d.ts +449 -11
- package/dist/esm/generated/ns/agents.js +609 -11
- package/dist/esm/generated/ns/agents.js.map +1 -1
- package/dist/esm/generated/ns/images.d.ts +84 -3
- package/dist/esm/generated/ns/images.js +126 -2
- package/dist/esm/generated/ns/images.js.map +1 -1
- package/dist/esm/generated/ns/keys.d.ts +12 -4
- package/dist/esm/generated/ns/keys.js +12 -4
- package/dist/esm/generated/ns/keys.js.map +1 -1
- package/dist/esm/generated/ns/listeners.d.ts +6 -2
- package/dist/esm/generated/ns/listeners.js +6 -2
- package/dist/esm/generated/ns/listeners.js.map +1 -1
- package/dist/esm/generated/ns/routines.d.ts +11 -0
- package/dist/esm/generated/ns/routines.js +11 -0
- package/dist/esm/generated/ns/routines.js.map +1 -1
- package/dist/esm/generated/ns/sandboxes.d.ts +140 -1
- package/dist/esm/generated/ns/sandboxes.js +190 -1
- package/dist/esm/generated/ns/sandboxes.js.map +1 -1
- package/dist/esm/generated/ns/vision.d.ts +55 -1
- package/dist/esm/generated/ns/vision.js +94 -1
- package/dist/esm/generated/ns/vision.js.map +1 -1
- package/dist/esm/generated/ns/workspaces.d.ts +225 -0
- package/dist/esm/generated/ns/workspaces.js +406 -0
- package/dist/esm/generated/ns/workspaces.js.map +1 -0
- package/dist/esm/generated/types.d.ts +2312 -90
- package/package.json +1 -1
- package/src/core/util.ts +1 -1
- package/src/generated/client.ts +10 -0
- package/src/generated/errors.ts +90 -0
- package/src/generated/ids.ts +7 -0
- package/src/generated/ns/agents.ts +663 -11
- package/src/generated/ns/images.ts +131 -3
- package/src/generated/ns/keys.ts +12 -4
- package/src/generated/ns/listeners.ts +6 -2
- package/src/generated/ns/routines.ts +11 -0
- package/src/generated/ns/sandboxes.ts +203 -1
- package/src/generated/ns/vision.ts +101 -1
- package/src/generated/ns/workspaces.ts +448 -0
- package/src/generated/types.ts +2488 -55
|
@@ -8,7 +8,7 @@ export type Metadata = Record<string, string>;
|
|
|
8
8
|
* for every scope. The build generates `enum` from the catalog, the same list as `dist/scopes.json` plus
|
|
9
9
|
* `<product>:*` and `*`.
|
|
10
10
|
*/
|
|
11
|
-
export type Scope = "vision:read" | "vision:write" | "vision:run" | "vision:profiles:use" | "vision:profiles:export" | "render:read" | "render:write" | "render:run" | "sandboxes:read" | "sandboxes:write" | "sandboxes:run" | "agents:read" | "agents:write" | "agents:run" | "routines:read" | "routines:write" | "routines:run" | "listeners:read" | "listeners:write" | "actions:read" | "actions:write" | "actions:run" | "actions:tools:publish" | "infer:read" | "infer:write" | "infer:run" | "vault:read" | "vault:write" | "vault:run" | "vault:connections:reveal" | "platform:read" | "platform:write" | "platform:content:read" | "settings:write" | "vision:*" | "render:*" | "sandboxes:*" | "agents:*" | "routines:*" | "listeners:*" | "actions:*" | "infer:*" | "vault:*" | "platform:*" | "settings:*" | "*";
|
|
11
|
+
export type Scope = "vision:read" | "vision:write" | "vision:run" | "vision:profiles:use" | "vision:profiles:export" | "render:read" | "render:write" | "render:run" | "sandboxes:read" | "sandboxes:write" | "sandboxes:run" | "agents:read" | "agents:write" | "agents:run" | "routines:read" | "routines:write" | "routines:run" | "listeners:read" | "listeners:write" | "workspaces:read" | "workspaces:write" | "workspaces:run" | "workspaces:rules:write" | "workspaces:subjects:assert" | "actions:read" | "actions:write" | "actions:run" | "actions:tools:publish" | "infer:read" | "infer:write" | "infer:run" | "vault:read" | "vault:write" | "vault:run" | "vault:connections:reveal" | "platform:read" | "platform:write" | "platform:content:read" | "settings:write" | "vision:*" | "render:*" | "sandboxes:*" | "agents:*" | "routines:*" | "listeners:*" | "workspaces:*" | "actions:*" | "infer:*" | "vault:*" | "platform:*" | "settings:*" | "*";
|
|
12
12
|
/**
|
|
13
13
|
* Server-side phase durations in milliseconds with microsecond resolution: the same phases as the
|
|
14
14
|
* `Server-Timing` header, keyed `<phase>_ms`. `total_ms` is always present. Phase names are product-specific
|
|
@@ -82,6 +82,18 @@ export interface Problem {
|
|
|
82
82
|
limit?: LimitRef;
|
|
83
83
|
/** The object's current status, for state conflicts such as `sandbox_not_running`. */
|
|
84
84
|
current_status?: string;
|
|
85
|
+
/** The branch's head now (`head_moved`). */
|
|
86
|
+
current_head?: string;
|
|
87
|
+
/** The workspace paths the code is about (`path_not_writable`, `append_only_violation`), at most 100. */
|
|
88
|
+
paths?: string[];
|
|
89
|
+
/** Every path a merge could not combine (`merge_conflict`), with the blob IDs of the three sides. */
|
|
90
|
+
conflicts?: {
|
|
91
|
+
path: string;
|
|
92
|
+
kind: "content" | "binary" | "delete_modify" | "add_add" | "type";
|
|
93
|
+
base: string | null;
|
|
94
|
+
ours: string | null;
|
|
95
|
+
theirs: string | null;
|
|
96
|
+
}[];
|
|
85
97
|
/** The sandbox that holds a lease's key now, or null when none does (`lease_holder_changed`). */
|
|
86
98
|
holder?: string | null;
|
|
87
99
|
/** The head of the linked branch now (`manifest_changed`). */
|
|
@@ -148,6 +160,14 @@ export interface Problem {
|
|
|
148
160
|
* 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.
|
|
149
161
|
*/
|
|
150
162
|
egress_reason?: string;
|
|
163
|
+
/**
|
|
164
|
+
* 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`.
|
|
165
|
+
*/
|
|
166
|
+
image_status?: string;
|
|
167
|
+
/**
|
|
168
|
+
* Why a hosted tool's image did not import (`tool_failed` with `reason: image`): `stage` (where it stopped, an image error stage) and `detail`.
|
|
169
|
+
*/
|
|
170
|
+
image_error?: Record<string, unknown>;
|
|
151
171
|
/** The part of the answer that was filled (`extract_fields_missing`), without the missing fields. */
|
|
152
172
|
partial_data?: unknown;
|
|
153
173
|
/** The job's pages and how each was read (vision extract errors), as in the job's `result.pages`. */
|
|
@@ -548,7 +568,7 @@ export type ScrapeRequest = {
|
|
|
548
568
|
* `hosts` list the proxy's host (needs `vault:run`).
|
|
549
569
|
* A URL with a username or password is refused (`400 invalid_request`): put them in a connection. This node
|
|
550
570
|
* takes `http://` proxies only; plain HTTP means the username and password cross the network to your proxy
|
|
551
|
-
* unencrypted. Batches, crawls
|
|
571
|
+
* unencrypted. Batches, crawls and the Firecrawl surface do not take `proxy` yet; sessions take it with `stealth` only.
|
|
552
572
|
*/
|
|
553
573
|
export type ProxyOption = "none" | "auto" | "residential" | string | {
|
|
554
574
|
/** Your proxy's URL, `http://host:port`. */
|
|
@@ -1015,7 +1035,139 @@ export interface SessionCreateRequest {
|
|
|
1015
1035
|
* @default false
|
|
1016
1036
|
*/
|
|
1017
1037
|
thumbnails?: boolean;
|
|
1038
|
+
/**
|
|
1039
|
+
* `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).
|
|
1040
|
+
*/
|
|
1041
|
+
isolation?: SessionIsolation;
|
|
1042
|
+
stealth?: StealthOption;
|
|
1043
|
+
/**
|
|
1044
|
+
* Where a stealth session leaves from (`vision.proxy`); only with `stealth`, else `400 invalid_request`.
|
|
1045
|
+
* `none` (the default): the node's own address, and the session carries the `exit_direct` warning. A
|
|
1046
|
+
* proxy URL or `{url, connection}`: your own proxy, as on a scrape, kept for the whole session (one exit,
|
|
1047
|
+
* never rotated). `auto` and `residential` answer `422 option_not_allowed` with `bound_by: catalog`: stealth
|
|
1048
|
+
* sessions never use the residential network.
|
|
1049
|
+
*/
|
|
1050
|
+
proxy?: ProxyOption;
|
|
1051
|
+
}
|
|
1052
|
+
/**
|
|
1053
|
+
* A stealth session (`vision.stealth`, needs the flag for your organization and the stealth terms accepted by
|
|
1054
|
+
* an owner; else `422 option_not_allowed` with `bound_by: org`). The browser runs headful in a microVM of its
|
|
1055
|
+
* own, keeps one consistent identity (screen, window, fonts, input style), and takes its time zone and locale
|
|
1056
|
+
* from where its exit is. `true` is `{}`; `false` or no member is an ordinary session. It implies `isolation:
|
|
1057
|
+
* microvm` (`process` is `400`), runs engine `chrome` (`headless-shell` is `400`), and sets the window, locale
|
|
1058
|
+
* and time zone itself (`viewport`, `locale`, `timezone`, `user_agent` and `block_resources` are `400`).
|
|
1059
|
+
*/
|
|
1060
|
+
export type StealthOption = boolean | {
|
|
1061
|
+
/**
|
|
1062
|
+
* An identity to reuse. Omitted: the profile's identity when `profile` names one that has one, else a new identity.
|
|
1063
|
+
*/
|
|
1064
|
+
identity?: string;
|
|
1065
|
+
/**
|
|
1066
|
+
* 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.
|
|
1067
|
+
*/
|
|
1068
|
+
region?: string;
|
|
1069
|
+
/**
|
|
1070
|
+
* 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.
|
|
1071
|
+
* @default true
|
|
1072
|
+
*/
|
|
1073
|
+
humanize?: boolean;
|
|
1074
|
+
};
|
|
1075
|
+
/** What a stealth session's browser presents and where it leaves from. */
|
|
1076
|
+
export interface SessionStealth {
|
|
1077
|
+
identity: string;
|
|
1078
|
+
persona: {
|
|
1079
|
+
os: "linux";
|
|
1080
|
+
browser: "chrome";
|
|
1081
|
+
/** The running browser's major version. */
|
|
1082
|
+
major: number;
|
|
1083
|
+
screen: string;
|
|
1084
|
+
locale: string;
|
|
1085
|
+
timezone: string;
|
|
1086
|
+
/**
|
|
1087
|
+
* 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.
|
|
1088
|
+
*/
|
|
1089
|
+
gpu?: string;
|
|
1090
|
+
};
|
|
1091
|
+
exit: {
|
|
1092
|
+
/** `byo`: your proxy. `direct`: the node's address. */
|
|
1093
|
+
class: "byo" | "direct";
|
|
1094
|
+
/** Where the exit is (ISO 3166-1 alpha-2), as measured when the session started. */
|
|
1095
|
+
country?: string;
|
|
1096
|
+
region?: string;
|
|
1097
|
+
};
|
|
1098
|
+
/** The stealth engine's stage (1 today). */
|
|
1099
|
+
stage: number;
|
|
1100
|
+
/**
|
|
1101
|
+
* 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).
|
|
1102
|
+
*/
|
|
1103
|
+
warnings: string[];
|
|
1104
|
+
}
|
|
1105
|
+
export interface StealthAudit {
|
|
1106
|
+
object: "stealth_audit";
|
|
1107
|
+
session_id: string;
|
|
1108
|
+
/**
|
|
1109
|
+
* 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.
|
|
1110
|
+
*/
|
|
1111
|
+
lines: {
|
|
1112
|
+
t: string;
|
|
1113
|
+
kind: string;
|
|
1114
|
+
[key: string]: unknown;
|
|
1115
|
+
}[];
|
|
1116
|
+
}
|
|
1117
|
+
/**
|
|
1118
|
+
* 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.
|
|
1119
|
+
*/
|
|
1120
|
+
export interface StealthIdentity {
|
|
1121
|
+
id: string;
|
|
1122
|
+
object: "stealth_identity";
|
|
1123
|
+
state: "active" | "retired";
|
|
1124
|
+
persona: {
|
|
1125
|
+
/** The persona catalog's version it was drawn from. */
|
|
1126
|
+
catalog: number;
|
|
1127
|
+
os: "linux";
|
|
1128
|
+
browser: "chrome";
|
|
1129
|
+
/** The screen in CSS pixels. */
|
|
1130
|
+
screen: string;
|
|
1131
|
+
device_scale_factor: number;
|
|
1132
|
+
window: {
|
|
1133
|
+
x: number;
|
|
1134
|
+
y: number;
|
|
1135
|
+
width: number;
|
|
1136
|
+
height: number;
|
|
1137
|
+
maximized: boolean;
|
|
1138
|
+
};
|
|
1139
|
+
/** The font families its browser sees. */
|
|
1140
|
+
fonts: string[];
|
|
1141
|
+
/**
|
|
1142
|
+
* 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.
|
|
1143
|
+
*/
|
|
1144
|
+
gpu?: string;
|
|
1145
|
+
/**
|
|
1146
|
+
* 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.
|
|
1147
|
+
*/
|
|
1148
|
+
font_rendering?: {
|
|
1149
|
+
hinting: "hintslight" | "hintfull" | "hintnone";
|
|
1150
|
+
autohint: boolean;
|
|
1151
|
+
sans_serif: string;
|
|
1152
|
+
serif: string;
|
|
1153
|
+
monospace: string;
|
|
1154
|
+
};
|
|
1155
|
+
};
|
|
1156
|
+
/** `us` or `us-ny`; `null` until a session names one or its first exit sets it. */
|
|
1157
|
+
home_region: string | null;
|
|
1158
|
+
/** Stealth sessions that used it. */
|
|
1159
|
+
sessions: number;
|
|
1160
|
+
created_at: string;
|
|
1161
|
+
last_used_at: string | null;
|
|
1162
|
+
retired_at: string | null;
|
|
1018
1163
|
}
|
|
1164
|
+
export type StealthIdentityList = Omit<ListEnvelope, "data"> & {
|
|
1165
|
+
data: StealthIdentity[];
|
|
1166
|
+
};
|
|
1167
|
+
/**
|
|
1168
|
+
* 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.
|
|
1169
|
+
*/
|
|
1170
|
+
export type SessionIsolation = "process" | "microvm";
|
|
1019
1171
|
export interface SessionTimeline {
|
|
1020
1172
|
object: "session_timeline";
|
|
1021
1173
|
session_id: string;
|
|
@@ -1103,12 +1255,17 @@ export interface BrowserSession {
|
|
|
1103
1255
|
* Why the session closed; `null` while it is active. `deleted`: `DELETE`. `expired`: its timeout.
|
|
1104
1256
|
* `browser_exited`: its browser stopped under it. `node_restart`: the node stopped or restarted while the
|
|
1105
1257
|
* session was open; browser time is billed up to the stop and not after it (nothing when the node did not
|
|
1106
|
-
* stop cleanly, since it cannot tell when the browser stopped).
|
|
1258
|
+
* stop cleanly, since it cannot tell when the browser stopped). `stealth_revoked`: a stealth session whose
|
|
1259
|
+
* organization lost the `vision.stealth` flag or its acceptance of the stealth terms. Closed sessions stay
|
|
1260
|
+
* readable for 7 days.
|
|
1107
1261
|
*/
|
|
1108
|
-
closed_reason?: "deleted" | "expired" | "browser_exited" | "node_restart" | null;
|
|
1262
|
+
closed_reason?: "deleted" | "expired" | "browser_exited" | "node_restart" | "stealth_revoked" | null;
|
|
1109
1263
|
timeout_s: number;
|
|
1110
1264
|
viewport: Viewport;
|
|
1111
1265
|
browser: BrowserEngine;
|
|
1266
|
+
isolation: SessionIsolation;
|
|
1267
|
+
/** Present on stealth sessions only. */
|
|
1268
|
+
stealth?: SessionStealth;
|
|
1112
1269
|
/** The loaded profile, or `null`. */
|
|
1113
1270
|
profile: null | SessionProfileRef;
|
|
1114
1271
|
/** WebSocket URL of the session's CDP endpoint. */
|
|
@@ -1207,7 +1364,9 @@ export interface ActKey {
|
|
|
1207
1364
|
modifiers?: KeyModifiers;
|
|
1208
1365
|
settle?: ActSettle;
|
|
1209
1366
|
}
|
|
1210
|
-
/**
|
|
1367
|
+
/**
|
|
1368
|
+
* 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.
|
|
1369
|
+
*/
|
|
1211
1370
|
export interface ActScroll {
|
|
1212
1371
|
kind: "scroll";
|
|
1213
1372
|
target?: ActTarget;
|
|
@@ -1399,6 +1558,10 @@ export interface Profile {
|
|
|
1399
1558
|
* 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.
|
|
1400
1559
|
*/
|
|
1401
1560
|
exportable: boolean;
|
|
1561
|
+
/**
|
|
1562
|
+
* 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.
|
|
1563
|
+
*/
|
|
1564
|
+
identity?: string;
|
|
1402
1565
|
/** Owning org. Returned to the owner only; tenancy is checked on every access. */
|
|
1403
1566
|
org?: string;
|
|
1404
1567
|
project?: string;
|
|
@@ -3851,7 +4014,7 @@ export type RenderBackgroundPackList = Omit<ListEnvelope, "data"> & {
|
|
|
3851
4014
|
data: RenderBackgroundPack[];
|
|
3852
4015
|
};
|
|
3853
4016
|
/**
|
|
3854
|
-
* `running` → `paused` ↔ `running` → `stopped`. `failed` means the microVM crashed; its usage is final. `hibernated` is
|
|
4017
|
+
* `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.
|
|
3855
4018
|
*/
|
|
3856
4019
|
export type SandboxStatus = "running" | "paused" | "stopped" | "failed" | "hibernated";
|
|
3857
4020
|
/**
|
|
@@ -3954,7 +4117,8 @@ export interface EgressPolicy {
|
|
|
3954
4117
|
export interface SandboxCreateRequest {
|
|
3955
4118
|
/**
|
|
3956
4119
|
* Template name or `tpl_` ID: a node template (`GET /v1/sandboxes/templates`) or one of your project's
|
|
3957
|
-
* image templates (an image's `template`
|
|
4120
|
+
* image templates (an image's `template`, or its `name`; a name of an image that is not `ready` answers
|
|
4121
|
+
* `409 image_not_ready`). Node templates are looked up first. Ignored when `snapshot` is set.
|
|
3958
4122
|
* @default "base"
|
|
3959
4123
|
*/
|
|
3960
4124
|
template?: string;
|
|
@@ -4047,6 +4211,17 @@ export interface SandboxCreateRequest {
|
|
|
4047
4211
|
* volume is free for the next sandbox once the microVM has exited.
|
|
4048
4212
|
*/
|
|
4049
4213
|
volumes?: VolumeAttach[];
|
|
4214
|
+
/**
|
|
4215
|
+
* A workspace branch to mount (`POST /v1/workspaces`), at most one in this beta. Behind the `workspaces.api`
|
|
4216
|
+
* flag: `403 feature_not_enabled` while it is off for your organization. The branch's head is mounted at
|
|
4217
|
+
* `path` as a copy-on-write folder: the base files are shared and read-only underneath, and what the sandbox
|
|
4218
|
+
* writes there is the branch's change set, kept on the sandbox's disk until it is committed. Commands see
|
|
4219
|
+
* `B3OS_WORKSPACE_ID`, `B3OS_BRANCH_ID` and `B3OS_WORKSPACE_PATH`. Holding a protected branch (`main`) needs
|
|
4220
|
+
* `workspaces:write`, any other branch `workspaces:run`. A branch with no commit yet is `422
|
|
4221
|
+
* workspace_invalid` (reason `empty`). In this beta a sandbox with a workspace cannot be snapshotted (`409
|
|
4222
|
+
* conflict`), and `snapshot` and `forkable: true` are refused with it (`400 invalid_request`).
|
|
4223
|
+
*/
|
|
4224
|
+
workspaces?: SandboxWorkspaceAttach[];
|
|
4050
4225
|
owner?: SandboxOwner;
|
|
4051
4226
|
metadata?: Metadata;
|
|
4052
4227
|
}
|
|
@@ -4060,6 +4235,35 @@ export interface VolumeAttach {
|
|
|
4060
4235
|
*/
|
|
4061
4236
|
owner?: string;
|
|
4062
4237
|
}
|
|
4238
|
+
export interface SandboxWorkspaceAttach {
|
|
4239
|
+
/** The workspace's `ws_` ID. */
|
|
4240
|
+
workspace: string;
|
|
4241
|
+
/**
|
|
4242
|
+
* An open branch's `br_` ID or name, or `new` (a new ephemeral branch from `from`).
|
|
4243
|
+
* @default "new"
|
|
4244
|
+
*/
|
|
4245
|
+
branch?: string;
|
|
4246
|
+
/**
|
|
4247
|
+
* Where a new branch starts: a branch name or ID, or a `cmt_` commit ID; `main` when unset. Only with a new
|
|
4248
|
+
* branch (`400 invalid_request` otherwise).
|
|
4249
|
+
*/
|
|
4250
|
+
from?: string;
|
|
4251
|
+
/**
|
|
4252
|
+
* Where the branch appears in the sandbox: absolute, and not a system folder or under one (the rules of a
|
|
4253
|
+
* volume mount's `path`); never overlapping a volume mount.
|
|
4254
|
+
* @default "/workspace"
|
|
4255
|
+
*/
|
|
4256
|
+
path?: string;
|
|
4257
|
+
}
|
|
4258
|
+
export interface SandboxWorkspace {
|
|
4259
|
+
workspace_id: string;
|
|
4260
|
+
branch_id: string;
|
|
4261
|
+
/** `ephemeral/<branch_id>` for a branch the create made. */
|
|
4262
|
+
branch_name: string;
|
|
4263
|
+
/** The commit the sandbox's base files are (the branch's head when the sandbox was created). */
|
|
4264
|
+
commit_id: string;
|
|
4265
|
+
path: string;
|
|
4266
|
+
}
|
|
4063
4267
|
export interface VolumeMount {
|
|
4064
4268
|
/**
|
|
4065
4269
|
* Where the folder appears in the sandbox: absolute, not `/`, not a system folder or under one (`/proc`,
|
|
@@ -4279,6 +4483,7 @@ export interface Sandbox {
|
|
|
4279
4483
|
* running and renews its `expires_at` itself. `null` when it never held one. Always sent by this node.
|
|
4280
4484
|
*/
|
|
4281
4485
|
lease?: null | SandboxLease;
|
|
4486
|
+
restore?: SandboxRestore;
|
|
4282
4487
|
/**
|
|
4283
4488
|
* The processes the node supervises (an exec with `background: true` and `restart`), oldest first; empty
|
|
4284
4489
|
* when there are none. Always sent by this node.
|
|
@@ -4286,6 +4491,8 @@ export interface Sandbox {
|
|
|
4286
4491
|
supervised?: SupervisedProcess[];
|
|
4287
4492
|
/** The volume the sandbox holds and where it is mounted; empty when none. Always sent by this node. */
|
|
4288
4493
|
volumes?: SandboxVolume[];
|
|
4494
|
+
/** The workspace branch the sandbox holds and where it is mounted; present only when it holds one. */
|
|
4495
|
+
workspaces?: SandboxWorkspace[];
|
|
4289
4496
|
options: SandboxOptions;
|
|
4290
4497
|
owner?: SandboxOwner;
|
|
4291
4498
|
/**
|
|
@@ -4331,6 +4538,13 @@ export interface LeaseRequest {
|
|
|
4331
4538
|
* that already holds `key` answers 200 whatever this says.
|
|
4332
4539
|
*/
|
|
4333
4540
|
expect_holder?: string | null;
|
|
4541
|
+
/**
|
|
4542
|
+
* The order the node boots the project's services again in place after it loses their microVMs (a node
|
|
4543
|
+
* restart or release): higher first, and a service waits up to 2 minutes while one of its project with a
|
|
4544
|
+
* higher priority is not running and ready yet, so a database comes back before the app that uses it.
|
|
4545
|
+
* Default 0. Sent again with the same `key`, it changes only the priority.
|
|
4546
|
+
*/
|
|
4547
|
+
restore_priority?: number;
|
|
4334
4548
|
}
|
|
4335
4549
|
/** A sandbox's lease, held or ended. */
|
|
4336
4550
|
export interface SandboxLease {
|
|
@@ -4346,6 +4560,48 @@ export interface SandboxLease {
|
|
|
4346
4560
|
* one then stops within `sandboxes.lease_term`), or the sandbox's `stop_reason`.
|
|
4347
4561
|
*/
|
|
4348
4562
|
end_reason: "released" | "replaced" | "deleted" | "timeout" | "failed" | "budget" | "revoked" | null;
|
|
4563
|
+
/** The lease's restore priority (`PUT …/lease`); 0 by default. */
|
|
4564
|
+
restore_priority?: number;
|
|
4565
|
+
}
|
|
4566
|
+
/**
|
|
4567
|
+
* Present only for a project's service the node kept through the loss of its microVM: one that holds a lease
|
|
4568
|
+
* (`PUT …/lease`; not an agent instance, not started by another sandbox, no workspace, and `secrets` only as
|
|
4569
|
+
* connection references, which its boot reveals again while the edge says their creator still may). When its
|
|
4570
|
+
* microVM ends without anyone asking (a node restart or release, a VM lost while the node runs, a VM gone when
|
|
4571
|
+
* the node starts), the node keeps its disk and boots it again in place: the same ID (so its addresses need no
|
|
4572
|
+
* switch), its disk, its volume, its lease and its supervised processes, which start again. Boots back off 0,
|
|
4573
|
+
* 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
|
|
4574
|
+
* node gives up and the sandbox ends `failed`. While it has no VM it bills no compute.
|
|
4575
|
+
*/
|
|
4576
|
+
export interface SandboxRestore {
|
|
4577
|
+
/** Why its last microVM ended. */
|
|
4578
|
+
cause: "node_stop" | "vm_lost" | "vm_gone_at_start";
|
|
4579
|
+
/**
|
|
4580
|
+
* `clean`: the disk was copied after TERM to its supervised processes, its volume's release and a sync;
|
|
4581
|
+
* `crash`: copied while the guest ran or after its VM died, so writes the guest had not synced may be
|
|
4582
|
+
* missing (as after a power cut).
|
|
4583
|
+
*/
|
|
4584
|
+
consistency: "clean" | "crash";
|
|
4585
|
+
state: "waiting" | "booting" | "booted" | "gave_up";
|
|
4586
|
+
/** When its last microVM ended. */
|
|
4587
|
+
since: string;
|
|
4588
|
+
/** Boots begun since its last run of 10 minutes. */
|
|
4589
|
+
attempts: number;
|
|
4590
|
+
/** When the next boot may begin; `null` while it boots, once booted, and once given up. */
|
|
4591
|
+
next_at: string | null;
|
|
4592
|
+
booted_at: string | null;
|
|
4593
|
+
/** When the node gave up booting it (the sandbox ended `failed`). */
|
|
4594
|
+
gave_up_at: string | null;
|
|
4595
|
+
/** Why the last boot failed, or why the node gave up. */
|
|
4596
|
+
last_error: string | null;
|
|
4597
|
+
/**
|
|
4598
|
+
* For a service with `secrets` (connection references), why the node did not reveal them again:
|
|
4599
|
+
* `restore_grant_revoked`, the edge said the principal that revealed them at its create no longer may (its
|
|
4600
|
+
* key revoked or expired, its user removed, its scopes cut, its application unlinked; the sandbox ends
|
|
4601
|
+
* `stopped`, `revoked`); `restore_grant_unknown`, the edge could not say, through every boot of the backoff
|
|
4602
|
+
* (it ends `failed`). The node never keeps a secret's value, only its reference.
|
|
4603
|
+
*/
|
|
4604
|
+
reason?: "restore_grant_revoked" | "restore_grant_unknown" | null;
|
|
4349
4605
|
}
|
|
4350
4606
|
/** A background process the node starts again when it exits (an exec with `restart`). */
|
|
4351
4607
|
export interface SupervisedProcess {
|
|
@@ -4666,6 +4922,203 @@ export interface Snapshot {
|
|
|
4666
4922
|
export type SnapshotList = Omit<ListEnvelope, "data"> & {
|
|
4667
4923
|
data: Snapshot[];
|
|
4668
4924
|
};
|
|
4925
|
+
/** How many more sandboxes of one shape would be created now, and the limits behind the count. */
|
|
4926
|
+
export interface SandboxCapacity {
|
|
4927
|
+
object: "sandbox_capacity";
|
|
4928
|
+
/** The template's name. */
|
|
4929
|
+
template: string;
|
|
4930
|
+
vcpu: number;
|
|
4931
|
+
memory_mib: number;
|
|
4932
|
+
/**
|
|
4933
|
+
* Creates of this shape that would pass now; the least of `org`, `desktops` (desktop templates only) and `node.room`.
|
|
4934
|
+
*/
|
|
4935
|
+
room: number;
|
|
4936
|
+
/** The limit that refuses the next create when `room` is 0; `null` while a create would pass. */
|
|
4937
|
+
binding: "org_concurrency" | "desktops" | "node" | null;
|
|
4938
|
+
org: CapacityCount;
|
|
4939
|
+
desktops: CapacityCount;
|
|
4940
|
+
node: {
|
|
4941
|
+
/** Sandboxes of this shape waiting warm in the node's pool. */
|
|
4942
|
+
parked: number;
|
|
4943
|
+
/**
|
|
4944
|
+
* 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.
|
|
4945
|
+
*/
|
|
4946
|
+
room: number | null;
|
|
4947
|
+
};
|
|
4948
|
+
/** When `room` is 0, how long to wait before trying again. */
|
|
4949
|
+
retry_after_s?: number;
|
|
4950
|
+
}
|
|
4951
|
+
/**
|
|
4952
|
+
* Your organization's live sandboxes against one limit (`sandboxes.concurrent` or `sandboxes.desktops_concurrent`).
|
|
4953
|
+
*/
|
|
4954
|
+
export interface CapacityCount {
|
|
4955
|
+
/** Running and paused sandboxes, and creates in flight. */
|
|
4956
|
+
running: number;
|
|
4957
|
+
limit: number;
|
|
4958
|
+
}
|
|
4959
|
+
export interface Computer {
|
|
4960
|
+
object: "computer";
|
|
4961
|
+
display: {
|
|
4962
|
+
width: number;
|
|
4963
|
+
height: number;
|
|
4964
|
+
};
|
|
4965
|
+
cursor: ComputerPoint;
|
|
4966
|
+
/**
|
|
4967
|
+
* 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.
|
|
4968
|
+
*/
|
|
4969
|
+
controller: "agent" | "human";
|
|
4970
|
+
}
|
|
4971
|
+
/** A position on the screen, in pixels from the top left. */
|
|
4972
|
+
export interface ComputerPoint {
|
|
4973
|
+
x: number;
|
|
4974
|
+
y: number;
|
|
4975
|
+
}
|
|
4976
|
+
export interface ComputerScreenshotOptions {
|
|
4977
|
+
/** @default "jpeg" */
|
|
4978
|
+
format?: "png" | "jpeg";
|
|
4979
|
+
/**
|
|
4980
|
+
* JPEG quality.
|
|
4981
|
+
* @default 80
|
|
4982
|
+
*/
|
|
4983
|
+
quality?: number;
|
|
4984
|
+
}
|
|
4985
|
+
/** Before the screenshot, wait until the screen has not changed for `quiet_ms`, at most `max_ms`. */
|
|
4986
|
+
export interface ComputerSettle {
|
|
4987
|
+
/** @default 80 */
|
|
4988
|
+
quiet_ms?: number;
|
|
4989
|
+
/** @default 1000 */
|
|
4990
|
+
max_ms?: number;
|
|
4991
|
+
}
|
|
4992
|
+
export interface ComputerActRequest {
|
|
4993
|
+
/** Run in order. Their `wait` actions add up to at most 30,000 ms. */
|
|
4994
|
+
actions: ComputerAction[];
|
|
4995
|
+
/** A screenshot after the actions; `null` or left out for none. */
|
|
4996
|
+
screenshot?: ComputerScreenshotOptions | null;
|
|
4997
|
+
/** Wait for the screen to settle before the screenshot; `null` or left out for no wait. */
|
|
4998
|
+
settle?: ComputerSettle | null;
|
|
4999
|
+
}
|
|
5000
|
+
/** One mouse or keyboard action; `action` selects it. */
|
|
5001
|
+
export type ComputerAction = ComputerClick | ComputerMove | ComputerMouseDown | ComputerMouseUp | ComputerDrag | ComputerScroll | ComputerType | ComputerKey | ComputerKeyDown | ComputerKeyUp | ComputerWait | ComputerCursorPosition;
|
|
5002
|
+
/** Pixels from the left (`x`) or the top (`y`); within the screen. */
|
|
5003
|
+
export type ComputerCoordinate = number;
|
|
5004
|
+
export type ComputerButton = "left" | "right" | "middle";
|
|
5005
|
+
/**
|
|
5006
|
+
* Click at `x`, `y` (both or neither; neither clicks at the pointer). `count` 2 is a double click, 3 a triple click.
|
|
5007
|
+
*/
|
|
5008
|
+
export interface ComputerClick {
|
|
5009
|
+
action: "click";
|
|
5010
|
+
x?: ComputerCoordinate;
|
|
5011
|
+
y?: ComputerCoordinate;
|
|
5012
|
+
button?: ComputerButton;
|
|
5013
|
+
/** @default 1 */
|
|
5014
|
+
count?: number;
|
|
5015
|
+
}
|
|
5016
|
+
/** Move the pointer. */
|
|
5017
|
+
export interface ComputerMove {
|
|
5018
|
+
action: "move";
|
|
5019
|
+
x: ComputerCoordinate;
|
|
5020
|
+
y: ComputerCoordinate;
|
|
5021
|
+
}
|
|
5022
|
+
/** Press a button, at `x`, `y` or at the pointer, and hold it. */
|
|
5023
|
+
export interface ComputerMouseDown {
|
|
5024
|
+
action: "mouse_down";
|
|
5025
|
+
x?: ComputerCoordinate;
|
|
5026
|
+
y?: ComputerCoordinate;
|
|
5027
|
+
button?: ComputerButton;
|
|
5028
|
+
}
|
|
5029
|
+
/** Release a button, at `x`, `y` or at the pointer. */
|
|
5030
|
+
export interface ComputerMouseUp {
|
|
5031
|
+
action: "mouse_up";
|
|
5032
|
+
x?: ComputerCoordinate;
|
|
5033
|
+
y?: ComputerCoordinate;
|
|
5034
|
+
button?: ComputerButton;
|
|
5035
|
+
}
|
|
5036
|
+
/**
|
|
5037
|
+
* 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.
|
|
5038
|
+
*/
|
|
5039
|
+
export interface ComputerDrag {
|
|
5040
|
+
action: "drag";
|
|
5041
|
+
/** `[[x, y], ...]`, 2 to 64 points. */
|
|
5042
|
+
path: ComputerCoordinate[][];
|
|
5043
|
+
button?: ComputerButton;
|
|
5044
|
+
}
|
|
5045
|
+
/** Turn the wheel `amount` clicks, at `x`, `y` or at the pointer. */
|
|
5046
|
+
export interface ComputerScroll {
|
|
5047
|
+
action: "scroll";
|
|
5048
|
+
x?: ComputerCoordinate;
|
|
5049
|
+
y?: ComputerCoordinate;
|
|
5050
|
+
direction: "up" | "down" | "left" | "right";
|
|
5051
|
+
/** @default 1 */
|
|
5052
|
+
amount?: number;
|
|
5053
|
+
}
|
|
5054
|
+
/** Type the text, as a keyboard would (newline and tab included). The node logs its length only. */
|
|
5055
|
+
export interface ComputerType {
|
|
5056
|
+
action: "type";
|
|
5057
|
+
/** At most 8,192 bytes of UTF-8; no control characters other than newline, carriage return and tab. */
|
|
5058
|
+
text: string;
|
|
5059
|
+
}
|
|
5060
|
+
/** Press and release a key or a chord of xdotool key names joined by `+`. */
|
|
5061
|
+
export interface ComputerKey {
|
|
5062
|
+
action: "key";
|
|
5063
|
+
keys: string;
|
|
5064
|
+
}
|
|
5065
|
+
/** Press one key and hold it until `key_up` (or the end of a batch that fails). */
|
|
5066
|
+
export interface ComputerKeyDown {
|
|
5067
|
+
action: "key_down";
|
|
5068
|
+
key: string;
|
|
5069
|
+
}
|
|
5070
|
+
/** Release a held key. */
|
|
5071
|
+
export interface ComputerKeyUp {
|
|
5072
|
+
action: "key_up";
|
|
5073
|
+
key: string;
|
|
5074
|
+
}
|
|
5075
|
+
/** Wait */
|
|
5076
|
+
export interface ComputerWait {
|
|
5077
|
+
action: "wait";
|
|
5078
|
+
ms: number;
|
|
5079
|
+
}
|
|
5080
|
+
/** Sends no input; the answer's `cursor` is the pointer's position. */
|
|
5081
|
+
export interface ComputerCursorPosition {
|
|
5082
|
+
action: "cursor_position";
|
|
5083
|
+
}
|
|
5084
|
+
export interface ComputerActResult {
|
|
5085
|
+
object: "computer_actions";
|
|
5086
|
+
/** One per action, in order. */
|
|
5087
|
+
results: ComputerActionResult[];
|
|
5088
|
+
/** Where the pointer is after the actions; `null` when the X server went away during the batch. */
|
|
5089
|
+
cursor: ComputerPoint | null;
|
|
5090
|
+
/** The screenshot asked for; `null` when none was asked for or it could not be taken. */
|
|
5091
|
+
screenshot: ScreenshotData | null;
|
|
5092
|
+
/** How long the settle waited, ms; `null` without `settle`. */
|
|
5093
|
+
settled_ms: number | null;
|
|
5094
|
+
/** `quiet`: the screen stayed still for `quiet_ms`; `deadline`: `max_ms` passed first. */
|
|
5095
|
+
settled_by: "quiet" | "deadline" | null;
|
|
5096
|
+
/** Time inside the sandbox, ms. */
|
|
5097
|
+
timing: {
|
|
5098
|
+
act_ms: number;
|
|
5099
|
+
settle_ms: number;
|
|
5100
|
+
capture_ms: number;
|
|
5101
|
+
encode_ms: number;
|
|
5102
|
+
};
|
|
5103
|
+
}
|
|
5104
|
+
export interface ComputerActionResult {
|
|
5105
|
+
ok: boolean;
|
|
5106
|
+
/**
|
|
5107
|
+
* Whether the action's input reached the X server. `delivered_unverified`: sent and synced; what the
|
|
5108
|
+
* application did with it is not checked. `delivery_uncertain`: part of it may have been sent.
|
|
5109
|
+
* `not_delivered`: nothing was sent (the action failed before its input, was skipped, or sends no input:
|
|
5110
|
+
* `wait`, `cursor_position`). `unknown`: the X server went away after the input was sent.
|
|
5111
|
+
*/
|
|
5112
|
+
delivery: "delivered_verified" | "delivered_unverified" | "delivery_uncertain" | "not_delivered" | "unknown";
|
|
5113
|
+
/**
|
|
5114
|
+
* Whether sending the action again is safe. `safe`: nothing was sent, or the action does the same thing
|
|
5115
|
+
* twice (`move`, `wait`, `cursor_position`). `unsafe`: its input landed and a second send repeats it.
|
|
5116
|
+
* `unknown`: whether its input landed cannot be told.
|
|
5117
|
+
*/
|
|
5118
|
+
retry: "safe" | "unsafe" | "unknown";
|
|
5119
|
+
/** Why the action failed; `null` when it did not. */
|
|
5120
|
+
error: string | null;
|
|
5121
|
+
}
|
|
4669
5122
|
export interface Template {
|
|
4670
5123
|
id: string;
|
|
4671
5124
|
object: "template";
|
|
@@ -4675,9 +5128,10 @@ export interface Template {
|
|
|
4675
5128
|
runtimes: string[];
|
|
4676
5129
|
/**
|
|
4677
5130
|
* `cdp`: Chrome runs in the template's snapshot with DevTools on `127.0.0.1:9222` inside the sandbox; declare
|
|
4678
|
-
* port 9222 to reach it through a port preview.
|
|
5131
|
+
* port 9222 to reach it through a port preview. `computer`: the sandbox has a screen, a mouse and a keyboard
|
|
5132
|
+
* that `/v1/sandboxes/{sandbox_id}/computer` reads and drives (the `desktop` template).
|
|
4679
5133
|
*/
|
|
4680
|
-
capabilities: Array<"exec" | "files" | "pty" | "run_code" | "cdp">;
|
|
5134
|
+
capabilities: Array<"exec" | "files" | "pty" | "run_code" | "cdp" | "computer">;
|
|
4681
5135
|
defaults: {
|
|
4682
5136
|
vcpu: number;
|
|
4683
5137
|
memory_mib: number;
|
|
@@ -4694,8 +5148,8 @@ export interface Template {
|
|
|
4694
5148
|
}[];
|
|
4695
5149
|
/**
|
|
4696
5150
|
* `node`: one of the node's templates, the same for everyone. `project`: an imported image's template,
|
|
4697
|
-
* which only its project sees and can start sandboxes from. An image template's `name` is its
|
|
4698
|
-
* it has one size (`size_classes` holds only the image's).
|
|
5151
|
+
* which only its project sees and can start sandboxes from. An image template's `name` is its image's
|
|
5152
|
+
* `name` when it has one, else its `tpl_` ID, and it has one size (`size_classes` holds only the image's).
|
|
4699
5153
|
*/
|
|
4700
5154
|
owner: "node" | "project";
|
|
4701
5155
|
/** The image this template was imported from (`owner: project`); `null` for node templates. */
|
|
@@ -4708,6 +5162,39 @@ export interface Template {
|
|
|
4708
5162
|
*/
|
|
4709
5163
|
agent_sha256?: string;
|
|
4710
5164
|
}
|
|
5165
|
+
/**
|
|
5166
|
+
* Exactly one of `image` (an import) and `build` (a Dockerfile build); the rest as `POST /v1/images` takes it.
|
|
5167
|
+
*/
|
|
5168
|
+
export type TemplateCreateRequest = {
|
|
5169
|
+
name?: ImageName;
|
|
5170
|
+
/** An image reference, as `ref` of `POST /v1/images` (`python:3.11-slim`); a private one needs `auth`. */
|
|
5171
|
+
image?: string;
|
|
5172
|
+
build?: ImageBuild;
|
|
5173
|
+
auth?: ImageRegistryAuth;
|
|
5174
|
+
warmup?: ImageWarmup;
|
|
5175
|
+
/** The size every sandbox from the template has. Default 1, at most your plan's `sandboxes.vcpu_max`. */
|
|
5176
|
+
vcpu?: number;
|
|
5177
|
+
/**
|
|
5178
|
+
* The memory every sandbox from the template has. Default 1024, at most your plan's `sandboxes.memory_max`.
|
|
5179
|
+
*/
|
|
5180
|
+
memory_mib?: number;
|
|
5181
|
+
};
|
|
5182
|
+
/**
|
|
5183
|
+
* 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.
|
|
5184
|
+
*/
|
|
5185
|
+
export interface TemplateCreated {
|
|
5186
|
+
id: string;
|
|
5187
|
+
object: "template";
|
|
5188
|
+
/** The image's name, else `null` (then the template is started by its ID). */
|
|
5189
|
+
name: null | ImageName;
|
|
5190
|
+
status: ImageStatus;
|
|
5191
|
+
/** The image (`GET /v1/images/{image_id}?wait=30` until it is `ready`). */
|
|
5192
|
+
image: string;
|
|
5193
|
+
/** The image's flattened root file system, once stored. */
|
|
5194
|
+
rootfs_sha256: string | null;
|
|
5195
|
+
/** The image's key; the same request in this project answers this template. */
|
|
5196
|
+
key: string;
|
|
5197
|
+
}
|
|
4711
5198
|
export type TemplateList = Omit<ListEnvelope, "data"> & {
|
|
4712
5199
|
data: Template[];
|
|
4713
5200
|
};
|
|
@@ -4864,14 +5351,14 @@ export type SwarmEvent = JobEvent & {
|
|
|
4864
5351
|
}[];
|
|
4865
5352
|
};
|
|
4866
5353
|
/**
|
|
4867
|
-
* `queued` (accepted, waiting for the queue), `pulling` (layers streaming into the unpacking microVM),
|
|
5354
|
+
* `queued` (accepted, waiting for the queue), `building` (a Dockerfile build running in its microVM), `pulling` (layers streaming into the unpacking microVM),
|
|
4868
5355
|
* `flattening` (the last byte sent; waiting for the unpacker and the store), `warming` (the first boot, the
|
|
4869
5356
|
* warm-up and the warm snapshot), `ready`. `rebuilding`: a node release changed the guest agent, kernel or
|
|
4870
5357
|
* hypervisor, and the warm snapshot is being taken again (creates answer `409 image_not_ready` until it is
|
|
4871
5358
|
* `ready`). `failed`: see `error`. `evicted`: the node's image cache was full and this image, unused, was
|
|
4872
5359
|
* removed; import it again with the same request.
|
|
4873
5360
|
*/
|
|
4874
|
-
export type ImageStatus = "queued" | "pulling" | "flattening" | "warming" | "ready" | "rebuilding" | "failed" | "evicted";
|
|
5361
|
+
export type ImageStatus = "queued" | "building" | "pulling" | "flattening" | "warming" | "ready" | "rebuilding" | "failed" | "evicted";
|
|
4875
5362
|
export interface ImageWarmup {
|
|
4876
5363
|
/**
|
|
4877
5364
|
* Commands run once, in order, in the image's first boot before its warm snapshot is taken: each an
|
|
@@ -4880,14 +5367,33 @@ export interface ImageWarmup {
|
|
|
4880
5367
|
*/
|
|
4881
5368
|
commands: string[][];
|
|
4882
5369
|
}
|
|
4883
|
-
|
|
5370
|
+
/**
|
|
5371
|
+
* The project's name for the image (`images.build`): `name[:tag]`, at most 64 characters in all, each part of
|
|
5372
|
+
* lowercase letters, digits, `.`, `_` and `-` and starting with a letter or a digit, the name not starting
|
|
5373
|
+
* with `tpl_`. The whole string is the name (`app` and `app:latest` are two names). `POST /v1/sandboxes
|
|
5374
|
+
* {"template": "<name>"}` starts from it in this project only; another project's name answers `404
|
|
5375
|
+
* template_not_found`. Unique among the project's images, never a node template's name (`base` nor
|
|
5376
|
+
* `base:v1`), and part of the image's key.
|
|
5377
|
+
*/
|
|
5378
|
+
export type ImageName = string;
|
|
5379
|
+
/**
|
|
5380
|
+
* An application, as its b3os.yaml `name` (`images.build`): on a request, the application asking for the image,
|
|
5381
|
+
* which then holds it (`held_by`) instead of keeping it until it is deleted (`kept`).
|
|
5382
|
+
*/
|
|
5383
|
+
export type ImageAppName = string;
|
|
5384
|
+
/** Exactly one of `ref` (an import) and `build` (a Dockerfile build). */
|
|
5385
|
+
export type ImageImportRequest = {
|
|
4884
5386
|
/**
|
|
4885
5387
|
* An image reference: `[registry/]repository[:tag|@sha256:digest]`. Without a registry it is Docker Hub
|
|
4886
5388
|
* (`python:3.11-slim` is `registry-1.docker.io/library/python:3.11-slim`); without a tag or digest it is
|
|
4887
5389
|
* `latest`. A tag is resolved to its digest once, when the import is accepted; the image keeps that digest.
|
|
4888
|
-
*
|
|
5390
|
+
* A private image needs `auth`.
|
|
4889
5391
|
*/
|
|
4890
|
-
ref
|
|
5392
|
+
ref?: string;
|
|
5393
|
+
build?: ImageBuild;
|
|
5394
|
+
name?: ImageName;
|
|
5395
|
+
auth?: ImageRegistryAuth;
|
|
5396
|
+
app?: ImageAppName;
|
|
4891
5397
|
warmup?: ImageWarmup;
|
|
4892
5398
|
/** The size every sandbox from the image has. Default 1, at most your plan's `sandboxes.vcpu_max`. */
|
|
4893
5399
|
vcpu?: number;
|
|
@@ -4895,6 +5401,68 @@ export interface ImageImportRequest {
|
|
|
4895
5401
|
* The memory every sandbox from the image has. Default 1024, at most your plan's `sandboxes.memory_max`.
|
|
4896
5402
|
*/
|
|
4897
5403
|
memory_mib?: number;
|
|
5404
|
+
};
|
|
5405
|
+
/**
|
|
5406
|
+
* A private registry's credential, from the vault (with the `images.build` flag; an import only, not a build).
|
|
5407
|
+
* `connection` names a connection of this project of type `basic`: `username`, and the password or an access
|
|
5408
|
+
* token in `password` (a Docker Hub or GitHub personal access token with read access to the image). Its
|
|
5409
|
+
* `hosts` must list the registry and the registry's token service: `registry-1.docker.io` and `auth.docker.io`
|
|
5410
|
+
* (or `*.docker.io`) for Docker Hub, `ghcr.io` for GHCR.
|
|
5411
|
+
*
|
|
5412
|
+
* The node reads the connection when the import is accepted, as your credential (it needs `vault:run`), keeps
|
|
5413
|
+
* it in memory for that one import, and sends it only in the Basic `Authorization` header of the token request
|
|
5414
|
+
* the registry's `WWW-Authenticate: Bearer` challenge names, over https, to a host the connection lists. It is
|
|
5415
|
+
* never logged, never put into an error, the image or its key, and never reaches a microVM; the tokens it earns
|
|
5416
|
+
* are used by that import only. Registries that only take Basic credentials on every request (no token
|
|
5417
|
+
* service) are not supported yet.
|
|
5418
|
+
*
|
|
5419
|
+
* The key does not name the connection: the same image pulled with another of the project's connections is the
|
|
5420
|
+
* same image.
|
|
5421
|
+
*/
|
|
5422
|
+
export interface ImageRegistryAuth {
|
|
5423
|
+
/** A `basic` connection of this project, bound to the registry's hosts. */
|
|
5424
|
+
connection: string;
|
|
5425
|
+
}
|
|
5426
|
+
export interface ImageContext {
|
|
5427
|
+
object: "image_context";
|
|
5428
|
+
sha256: string;
|
|
5429
|
+
bytes: number;
|
|
5430
|
+
/** When the tar goes, unless it is uploaded again or a build names it first. */
|
|
5431
|
+
expires_at: string;
|
|
5432
|
+
}
|
|
5433
|
+
export interface ImageContextPart {
|
|
5434
|
+
/** A tar this project uploaded with `PUT /v1/images/contexts/{sha256}` (kept 24 hours). */
|
|
5435
|
+
sha256: string;
|
|
5436
|
+
/**
|
|
5437
|
+
* The folder of the build context the tar is unpacked into, relative (no `..`, no leading `/`); empty for the context's root.
|
|
5438
|
+
* @default ""
|
|
5439
|
+
*/
|
|
5440
|
+
at?: string;
|
|
5441
|
+
}
|
|
5442
|
+
/**
|
|
5443
|
+
* A Dockerfile build. The context is one or more uploaded tars, unpacked in order inside the build microVM
|
|
5444
|
+
* (never on the host); the Dockerfile is a file of the context. The build runs BuildKit's Dockerfile frontend
|
|
5445
|
+
* as root inside a microVM of its own, with the public internet through B3OS's egress guard and no secrets,
|
|
5446
|
+
* for `linux/amd64`, within 1,800 seconds; the result is flattened and becomes a template as an import does.
|
|
5447
|
+
* The same request in the same project (the same context bytes, Dockerfile path, arguments and target) answers
|
|
5448
|
+
* the image it already built; a base image tag that moved since is not pulled again unless `no_cache` is set.
|
|
5449
|
+
*/
|
|
5450
|
+
export interface ImageBuild {
|
|
5451
|
+
context: ImageContextPart[];
|
|
5452
|
+
/**
|
|
5453
|
+
* The Dockerfile's path in the context, relative.
|
|
5454
|
+
* @default "Dockerfile"
|
|
5455
|
+
*/
|
|
5456
|
+
dockerfile?: string;
|
|
5457
|
+
/** Build arguments (`ARG`). Part of the key; not secret (they are in the image's history). */
|
|
5458
|
+
args?: Record<string, string>;
|
|
5459
|
+
/** The stage to build (`--target`), else the last. */
|
|
5460
|
+
target?: string | null;
|
|
5461
|
+
/**
|
|
5462
|
+
* Build again even when this project already has the image of this request.
|
|
5463
|
+
* @default false
|
|
5464
|
+
*/
|
|
5465
|
+
no_cache?: boolean;
|
|
4898
5466
|
}
|
|
4899
5467
|
/**
|
|
4900
5468
|
* What the image's own configuration says, read when it was imported. `user`, `env` and `workdir` apply to every
|
|
@@ -4926,13 +5494,15 @@ export interface ImagePackage {
|
|
|
4926
5494
|
}
|
|
4927
5495
|
/**
|
|
4928
5496
|
* Milliseconds each finished stage took (`null` until it finishes): `resolve` (the reference to a digest,
|
|
4929
|
-
* before the answer), `queue` (waiting for a slot), `
|
|
5497
|
+
* before the answer; `null` for a build), `queue` (waiting for a slot), `build` (a Dockerfile build, `null` for an
|
|
5498
|
+
* import), `pull_flatten` (pulling and unpacking, which overlap; for a build, unpacking its result),
|
|
4930
5499
|
* `adopt` (checking and storing the file system), `golden` (the first boot, warm-up and warm snapshot), and
|
|
4931
5500
|
* `total`.
|
|
4932
5501
|
*/
|
|
4933
5502
|
export interface ImageStagesMs {
|
|
4934
5503
|
resolve: number | null;
|
|
4935
5504
|
queue: number | null;
|
|
5505
|
+
build: number | null;
|
|
4936
5506
|
pull_flatten: number | null;
|
|
4937
5507
|
adopt: number | null;
|
|
4938
5508
|
golden: number | null;
|
|
@@ -4941,18 +5511,39 @@ export interface ImageStagesMs {
|
|
|
4941
5511
|
export interface ImageError {
|
|
4942
5512
|
/** `import_failed`. */
|
|
4943
5513
|
code: string;
|
|
4944
|
-
stage: "resolve" | "pull" | "flatten" | "adopt" | "golden" | "rebuild" | "interrupted";
|
|
5514
|
+
stage: "resolve" | "build" | "pull" | "flatten" | "adopt" | "golden" | "rebuild" | "interrupted";
|
|
4945
5515
|
detail: string;
|
|
4946
5516
|
/** The last 4 KiB of the unpacker's or the warm-up's output, when there was any. */
|
|
4947
5517
|
output: string | null;
|
|
4948
5518
|
}
|
|
5519
|
+
export interface ImageBuildSource {
|
|
5520
|
+
context: {
|
|
5521
|
+
sha256: string;
|
|
5522
|
+
at: string;
|
|
5523
|
+
bytes: number;
|
|
5524
|
+
}[];
|
|
5525
|
+
dockerfile: string;
|
|
5526
|
+
args: Record<string, string>;
|
|
5527
|
+
target: string | null;
|
|
5528
|
+
/** The base images the build pulled, by reference and digest, once it ran. */
|
|
5529
|
+
base_images: {
|
|
5530
|
+
ref: string;
|
|
5531
|
+
digest: string;
|
|
5532
|
+
}[];
|
|
5533
|
+
}
|
|
4949
5534
|
export interface Image {
|
|
4950
5535
|
id: string;
|
|
4951
5536
|
object: "image";
|
|
4952
|
-
/** The reference as given. */
|
|
4953
|
-
ref: string;
|
|
4954
|
-
/** The `
|
|
4955
|
-
|
|
5537
|
+
/** The reference as given; `null` for a build. */
|
|
5538
|
+
ref: string | null;
|
|
5539
|
+
/** The build request, for an image built from a Dockerfile; `null` for an import. */
|
|
5540
|
+
build: null | ImageBuildSource;
|
|
5541
|
+
/** The project's name for the image (`images.build`), else `null`. */
|
|
5542
|
+
name: null | ImageName;
|
|
5543
|
+
/**
|
|
5544
|
+
* The `linux/amd64` image manifest's digest: the imported one, or for a build the one BuildKit produced (`null` until the build finishes).
|
|
5545
|
+
*/
|
|
5546
|
+
digest: string | null;
|
|
4956
5547
|
/** The index (multi-platform list) the manifest was picked from, when the reference named one. */
|
|
4957
5548
|
index_digest: string | null;
|
|
4958
5549
|
platform: "linux/amd64";
|
|
@@ -4972,7 +5563,9 @@ export interface Image {
|
|
|
4972
5563
|
vcpu: number;
|
|
4973
5564
|
memory_mib: number;
|
|
4974
5565
|
};
|
|
4975
|
-
/**
|
|
5566
|
+
/**
|
|
5567
|
+
* 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.
|
|
5568
|
+
*/
|
|
4976
5569
|
key: string;
|
|
4977
5570
|
stages_ms: ImageStagesMs;
|
|
4978
5571
|
/** Compressed layer bytes pulled from the registry. */
|
|
@@ -4990,13 +5583,55 @@ export interface Image {
|
|
|
4990
5583
|
error: null | ImageError;
|
|
4991
5584
|
created_at: string;
|
|
4992
5585
|
ready_at: string | null;
|
|
5586
|
+
/**
|
|
5587
|
+
* 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`.
|
|
5588
|
+
*/
|
|
5589
|
+
held_by: ImageAppName[];
|
|
5590
|
+
/**
|
|
5591
|
+
* 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.
|
|
5592
|
+
*/
|
|
5593
|
+
kept: boolean;
|
|
5594
|
+
}
|
|
5595
|
+
/** An application's hold on an image, released (`POST /v1/images/{image_id}/release`). */
|
|
5596
|
+
export interface ImageRelease {
|
|
5597
|
+
object: "image_release";
|
|
5598
|
+
image: string;
|
|
5599
|
+
app: ImageAppName;
|
|
5600
|
+
/** The image is gone (deleted as `DELETE /v1/images/{image_id}` deletes it). */
|
|
5601
|
+
removed: boolean;
|
|
5602
|
+
/** The applications that still hold it. */
|
|
5603
|
+
held_by: ImageAppName[];
|
|
5604
|
+
/** It is kept until deleted (asked for without `app` at least once), so it stays. */
|
|
5605
|
+
kept: boolean;
|
|
5606
|
+
/**
|
|
5607
|
+
* 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.
|
|
5608
|
+
*/
|
|
5609
|
+
in_use: boolean;
|
|
5610
|
+
}
|
|
5611
|
+
export interface ImageReleaseRequest {
|
|
5612
|
+
app: ImageAppName;
|
|
5613
|
+
}
|
|
5614
|
+
/** Lines of an image's build log. */
|
|
5615
|
+
export interface ImageLog {
|
|
5616
|
+
object: "image_log";
|
|
5617
|
+
/** The image ID (`img_…`). */
|
|
5618
|
+
image: string;
|
|
5619
|
+
status: ImageStatus;
|
|
5620
|
+
/** The log's lines from `offset`, without their line ends. */
|
|
5621
|
+
lines: string[];
|
|
5622
|
+
/** The `offset` of the next read. */
|
|
5623
|
+
next_offset: number;
|
|
4993
5624
|
}
|
|
4994
5625
|
export type ImageList = Omit<ListEnvelope, "data"> & {
|
|
4995
5626
|
data: Image[];
|
|
4996
5627
|
};
|
|
4997
5628
|
/** An instance's key, stored and shown as written, so never a credential or a personal detail. */
|
|
4998
5629
|
export type AgentInstanceKey = string;
|
|
4999
|
-
/**
|
|
5630
|
+
/**
|
|
5631
|
+
* Lowercase letters, digits and `-`, starting with a letter. `sessions`, `harnesses`, `grants`, `self` and
|
|
5632
|
+
* `recipes` are reserved: they are path segments under `/v1/agents`, or will be (`recipes`, for shared harness
|
|
5633
|
+
* definitions).
|
|
5634
|
+
*/
|
|
5000
5635
|
export type AgentName = string;
|
|
5001
5636
|
/**
|
|
5002
5637
|
* What each instance starts from: a template (node templates, or one of your project's image templates) at a
|
|
@@ -5070,55 +5705,1134 @@ export interface AgentTurns {
|
|
|
5070
5705
|
*/
|
|
5071
5706
|
redeliver?: boolean;
|
|
5072
5707
|
}
|
|
5073
|
-
|
|
5074
|
-
|
|
5075
|
-
|
|
5076
|
-
|
|
5077
|
-
|
|
5078
|
-
|
|
5708
|
+
/**
|
|
5709
|
+
* Which harness. The open-source ones come first: `opencode` (MIT; its server takes steers, queued prompts and
|
|
5710
|
+
* permission answers, with a TUI that attaches to the same server), `codex` (OpenAI's Codex CLI, Apache-2.0)
|
|
5711
|
+
* and `pi` (Earendil's pi coding agent, MIT); then `claude-code` (Anthropic's Claude Code). Each is driven by a
|
|
5712
|
+
* driver built into the shim, and what each takes (providers, sign-ins, a model the node serves, modes, lists)
|
|
5713
|
+
* is its entry in `GET /v1/agents/harnesses`, which lists the ones this node runs. Or `acp`, a harness your
|
|
5714
|
+
* organization brings that speaks the Agent Client Protocol over stdio, named in the block's `acp` (planned,
|
|
5715
|
+
* after prepared snapshots, for your organization's own use; refused with `422 harness_capability_unsupported`
|
|
5716
|
+
* until the shim serves it).
|
|
5717
|
+
*/
|
|
5718
|
+
export type AgentHarnessKindName = "opencode" | "codex" | "pi" | "claude-code" | "acp";
|
|
5719
|
+
/**
|
|
5720
|
+
* A coding agent people already use, run unmodified as the agent's harness (planned: not served on the beta
|
|
5721
|
+
* node yet; research/harnesses-design.md). The instance's entry is B3OS's shim, `b3os-harness serve`, which owns
|
|
5722
|
+
* the harness process, delivers turns into it, turns its hooks and stream into `harness.*` events, answers its
|
|
5723
|
+
* permission prompts and serves its terminal. What the node and the shim say to each other inside the instance
|
|
5724
|
+
* (the environment, `/run/b3os/harness.json`, the headers and the shim's routes) is
|
|
5725
|
+
* packages/spec/sidecars/harness.md.
|
|
5726
|
+
*
|
|
5727
|
+
* The block is a recipe: write it once, and deploy it as many agents and instances as you need. Its members are
|
|
5728
|
+
* settled at three times:
|
|
5729
|
+
*
|
|
5730
|
+
* - At prepare, what has to be fetched: `skills` and `plugins` from `git`, `npm` or `artifact`, and `mcp`
|
|
5731
|
+
* servers run from an npm package. The node installs them, with the harness at `version`, into a snapshot of
|
|
5732
|
+
* the `harness` template that it builds once per prepare key and shares across the project
|
|
5733
|
+
* (`Agent.harness_prepared`), so each instance starts with them in place. The key covers only that fetched
|
|
5734
|
+
* set, the kind, the version, the template and the shim, so editing any other member builds nothing again.
|
|
5735
|
+
* Until prepared snapshots ship, those sources answer `422 harness_setup_needs_prepare`.
|
|
5736
|
+
* - When an instance starts, what the shim writes and sets up: `instructions`, `settings`, `mcp` entries,
|
|
5737
|
+
* `skills` and `plugins` given as `text`, `files` or `builtin`, `files`, `mode`, `terminal`, and each
|
|
5738
|
+
* credential profile's directory.
|
|
5739
|
+
* - At each turn: `model`, `permissions`, `hooks` and the turn's credential profile.
|
|
5740
|
+
*
|
|
5741
|
+
* Until they are served on this node, three members are refused when the definition is written, even when
|
|
5742
|
+
* empty (`[]` or `{}`), with `422 harness_capability_unsupported`: `repo`, `context` and `acp` (`kind: acp`
|
|
5743
|
+
* with it). The node never stores them, so neither a stored block nor `/run/b3os/harness.json` carries them.
|
|
5744
|
+
* A vault connection outside a credential profile reaches the instance as a `B3OS_CONN_<N>` secret (below): a
|
|
5745
|
+
* remote `mcp` server's `connection` and a stdio server's `{connection}` `env` values. `repo.connection` waits
|
|
5746
|
+
* for `repo`. A `${...}` or `{env:...}` in a server's `url`, `command` or `env`, which Claude Code and opencode
|
|
5747
|
+
* would expand from the harness's environment, is `400 invalid_request`: name a connection instead.
|
|
5748
|
+
*
|
|
5749
|
+
* B3OS's own tools are default entries of the block's lists, not a switch. `mcp` starts with `b3os`, B3OS's MCP
|
|
5750
|
+
* server inside the instance (`{builtin: b3os, toolsets: [browser, vision, render, sandboxes, actions, infer]}`,
|
|
5751
|
+
* at `B3OS_MCP_URL`), and `skills` starts with `b3os`, the skill that says how to use them (`{builtin: b3os}`);
|
|
5752
|
+
* `GET /v1/agents/harnesses` lists both (`checks.defaults`). Your `mcp` and `skills` maps are a JSON merge patch
|
|
5753
|
+
* (RFC 7396) over those defaults, the rule the shim applies: an entry under a new name is added, an entry set
|
|
5754
|
+
* to `null` is removed, and an entry under a default's name is merged into the default member by member (a
|
|
5755
|
+
* member set to `null` is removed, an array replaces the default's whole). So `"mcp": {"b3os": {"toolsets":
|
|
5756
|
+
* ["vision"]}}` keeps only the page tools without restating `builtin`, and `"mcp": {"b3os": null}, "skills":
|
|
5757
|
+
* {"b3os": null}` leaves the harness its own tools only. `plugins` has no default. The grant the node fills in
|
|
5758
|
+
* comes with the merged `b3os` MCP entry: the scopes its toolsets need, scoped to the instance
|
|
5759
|
+
* (`AgentHarnessMcpBuiltin`); without that entry the filled `api` carries no B3OS MCP tool scopes (only
|
|
5760
|
+
* `infer:run` if a `node` profile is present, and nothing otherwise). A model the node serves is reached
|
|
5761
|
+
* through the `model` or a `node` profile you pick, not through these entries. Every node carries the
|
|
5762
|
+
* defaults; a toolset a node does not serve is left out of the server's tools. A default is added only where
|
|
5763
|
+
* the kind takes its list (the kind's `setup` in `GET /v1/agents/harnesses`), and both default entries are
|
|
5764
|
+
* builtins of the `harness` template, so they change no prepare key.
|
|
5765
|
+
*
|
|
5766
|
+
* The stored block keeps `mcp` and `skills` as you wrote them, never merged: your own entries and patches, a
|
|
5767
|
+
* removed default kept as `null`, `{}` when you gave none. So a block that is read and sent back changes
|
|
5768
|
+
* nothing, and the shim, which merges once at start, sees the same maps you wrote. The merged lists are those
|
|
5769
|
+
* maps merged over `checks.defaults`, and the filled `api` shows the grant they bring.
|
|
5770
|
+
*
|
|
5771
|
+
* The node fills the rest of the definition from this block: `source.template` (the `harness` template, which
|
|
5772
|
+
* pins each harness's versions) and `source.snapshot` (the revision's prepared snapshot, once prepared
|
|
5773
|
+
* snapshots ship and it is built), `entry` (`b3os-harness serve --config /run/b3os/harness.json` on port 7801,
|
|
5774
|
+
* ready when that port answers, `max_restarts` 5), `secrets` (beside your own: each `key` profile's
|
|
5775
|
+
* credentials, as `B3OS_PROFILE_<NAME>__<VAR>`, and the secret of every other connection the block names, as
|
|
5776
|
+
* `B3OS_CONN_<N>`, which the file maps to its member: `repo`, a remote `mcp` server's `connection`, a stdio
|
|
5777
|
+
* server's `{connection}` values), `api` (the scopes that come with the `b3os` MCP entry, plus `infer:run`
|
|
5778
|
+
* when a `node` profile is present, and nothing without either), `egress` and `turns.timeout_s` (3,600
|
|
5779
|
+
* seconds, the most a turn may take). The shim writes each connection's secret where its member says (the
|
|
5780
|
+
* instance's git credentials, the harness's MCP config, as a variable the config refers to) and keeps every
|
|
5781
|
+
* `B3OS_*` variable out of the harness's processes and its terminal except the ones B3OS gives every sandbox
|
|
5782
|
+
* (`B3OS_API_URL`, `B3OS_SANDBOX_ID`, `B3OS_PROJECT`, `B3OS_PORT_BASE_PATH`, `B3OS_MCP_URL`, `B3OS_MODEL`,
|
|
5783
|
+
* `B3OS_WORKSPACE_ID`, `B3OS_BRANCH_ID`, `B3OS_WORKSPACE_PATH`): the profiles' values, the connections' secrets,
|
|
5784
|
+
* the shim's token, the flags and the instance's id never reach it. Set `api`,
|
|
5785
|
+
* `egress` or `turns` yourself to use your own instead. `source.vcpu`, `memory_mib` and `disk_gib` apply as
|
|
5786
|
+
* for any agent. `source.template`, `source.snapshot` and `entry` cannot be set beside `harness`, and neither
|
|
5787
|
+
* can an `env` or `secrets` name that starts with `B3OS_` (the node's and the shim's own) or that the kind's
|
|
5788
|
+
* shim sets or removes (`checks.kinds.<kind>.env_owned`) (`400 invalid_request`).
|
|
5789
|
+
*
|
|
5790
|
+
* `/run/b3os/harness.json` is this block as the node stored it, with exactly these changes and nothing else: it
|
|
5791
|
+
* leaves out `hooks.webhook` and `hooks.decide.url` (both calls leave from the node, so neither URL nor a
|
|
5792
|
+
* secret enters the instance) and every vault `connection` (a profile's values arrive as
|
|
5793
|
+
* `B3OS_PROFILE_<NAME>__<VAR>`, any other connection's as `B3OS_CONN_<N>`); each `node` profile gains
|
|
5794
|
+
* `base_url`, the node's infer inside the instance (`http://127.0.0.1:7700/v1/infer`); and `connections` maps
|
|
5795
|
+
* each member a secret goes to (`mcp.<name>`, `mcp.<name>.env.<VAR>`, and `repo` once it is served) to its
|
|
5796
|
+
* variable. It never holds a credential. packages/spec/sidecars/harness.md
|
|
5797
|
+
* lists every member and which the shim reads.
|
|
5798
|
+
*
|
|
5799
|
+
* The filled `egress` is an allowlist of exactly the hosts the block reaches from the instance: each `key` and
|
|
5800
|
+
* `signin` profile's provider hosts, from the kind's `auth.hosts` in `GET /v1/agents/harnesses` (a `{region}`
|
|
5801
|
+
* in one filled from the profile's `region`); each profile's `base_url` host; the `repo` host; and each remote
|
|
5802
|
+
* `mcp` server's host. A profile whose provider has no hosts in the catalog is `422
|
|
5803
|
+
* harness_capability_unsupported`. Your own `egress` must let the same hosts through (`public`, or an
|
|
5804
|
+
* `allowlist` that matches each one); one it does not is `400 invalid_request`, naming the host. B3OS itself is
|
|
5805
|
+
* reached inside the instance at `http://127.0.0.1:7700`, outside `egress`, and the `hooks.webhook` and
|
|
5806
|
+
* `hooks.decide` calls leave from the node, so neither host goes in the list. The hosts a stdio `mcp` server
|
|
5807
|
+
* reaches are not known to the node: list them in your own `egress`.
|
|
5808
|
+
*
|
|
5809
|
+
* No harness agent takes a plan's token. A name in `AgentHarnessPlanEnv` in `env`, `secrets`, an `mcp` server's
|
|
5810
|
+
* `env` or a `settings` `env` entry is `400 invalid_request`. A value holding a plan's token (`sk-ant-oat` or
|
|
5811
|
+
* `sk-ant-ort`) is `400 harness_plan_credential` wherever it is: any string in the stored definition (`env`,
|
|
5812
|
+
* `secrets`, this block's members, argv such as an `mcp` server's or `acp`'s `command`, `settings`, and every
|
|
5813
|
+
* skill, plugin and file), and the resolved value of every connection the definition names (each profile's,
|
|
5814
|
+
* `repo`'s, a remote `mcp` server's and a stdio server's `{connection}` values). The node checks when the
|
|
5815
|
+
* definition is written and again each time it makes an instance, so a connection changed later is refused
|
|
5816
|
+
* then.
|
|
5817
|
+
*
|
|
5818
|
+
* The block is part of the revision, as the rest of the definition is: a `PATCH` makes a new revision, and
|
|
5819
|
+
* `upgrade: on_wake` moves sleeping instances to it. A harness cannot change its own definition (`agents:write`
|
|
5820
|
+
* is granted only when named exactly), and what the recipe installs is read-only to the harness.
|
|
5821
|
+
*/
|
|
5822
|
+
export interface AgentHarness {
|
|
5079
5823
|
/**
|
|
5080
|
-
*
|
|
5081
|
-
*
|
|
5082
|
-
*
|
|
5824
|
+
* Which harness. Default: `opencode`, which is open source and reaches the providers its catalog entry's
|
|
5825
|
+
* `auth.key` lists (Anthropic, OpenAI and OpenRouter, and through OpenRouter many others). Its driver was
|
|
5826
|
+
* checked live against opencode 2.4.2 and a real provider on 2026-11-28: `openai/gpt-4o-mini` through
|
|
5827
|
+
* OpenRouter, three turns, one of them running a shell tool, each reporting its usage and cost.
|
|
5083
5828
|
*/
|
|
5084
|
-
|
|
5085
|
-
api?: SandboxApiGrant;
|
|
5086
|
-
egress?: EgressPolicy;
|
|
5087
|
-
sleep?: AgentSleep;
|
|
5088
|
-
turns?: AgentTurns;
|
|
5089
|
-
metadata?: Metadata;
|
|
5090
|
-
}
|
|
5091
|
-
export interface AgentUpdateRequest {
|
|
5092
|
-
source?: AgentSource;
|
|
5093
|
-
entry?: AgentEntry;
|
|
5094
|
-
env?: Record<string, string>;
|
|
5095
|
-
secrets?: Record<string, SecretValue>;
|
|
5096
|
-
api?: SandboxApiGrant;
|
|
5097
|
-
egress?: EgressPolicy;
|
|
5098
|
-
sleep?: AgentSleep;
|
|
5099
|
-
turns?: AgentTurns;
|
|
5829
|
+
kind?: AgentHarnessKindName;
|
|
5100
5830
|
/**
|
|
5101
|
-
*
|
|
5102
|
-
*
|
|
5103
|
-
* @default "new_instances"
|
|
5831
|
+
* The harness's version, one of the kind's `versions` in `GET /v1/agents/harnesses`. Default: its
|
|
5832
|
+
* `default_version`. A version this node does not run is `422 harness_version_unavailable`.
|
|
5104
5833
|
*/
|
|
5105
|
-
|
|
5106
|
-
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
|
|
5114
|
-
|
|
5115
|
-
|
|
5116
|
-
|
|
5834
|
+
version?: string;
|
|
5835
|
+
acp?: AgentHarnessAcp;
|
|
5836
|
+
auth?: AgentHarnessAuth;
|
|
5837
|
+
/**
|
|
5838
|
+
* The model, as the harness names it (opencode's `openrouter/openai/gpt-4o-mini`, Claude Code's
|
|
5839
|
+
* `claude-opus-5-5`), or a model the node's infer serves (`GET /v1/infer/models`), which the harness then
|
|
5840
|
+
* reaches on the node with no key, for a kind whose catalog entry has `auth.node: true`. A profile's own
|
|
5841
|
+
* `model` wins for that profile's turns. Default: the harness's own default.
|
|
5842
|
+
*/
|
|
5843
|
+
model?: string;
|
|
5844
|
+
/**
|
|
5845
|
+
* What the harness may do without asking. `auto`: the microVM is the sandbox, so the harness runs in its
|
|
5846
|
+
* most autonomous mode (every tool allowed in opencode and pi, Codex's full access with approvals off,
|
|
5847
|
+
* Claude Code's `bypassPermissions`). `ask`: every permission prompt becomes `harness.permission.requested`
|
|
5848
|
+
* and the turn waits for `POST /v1/agents/{agent}/instances/{key}/decisions`; one nobody answers is denied
|
|
5849
|
+
* at the turn's timeout. `plan`: read-only tools only; every write is denied, and
|
|
5850
|
+
* `hooks.decide` is never called. In `auto` and `ask`, `hooks.decide` answers before a person.
|
|
5851
|
+
* @default "auto"
|
|
5852
|
+
*/
|
|
5853
|
+
permissions?: "auto" | "ask" | "plan";
|
|
5854
|
+
/**
|
|
5855
|
+
* How the shim drives the harness. `api`: headless and structured (opencode's server, Codex's app-server,
|
|
5856
|
+
* pi's RPC mode, Claude Code's stream-json); the terminal holds a shell in the workspace. `terminal`: the
|
|
5857
|
+
* harness's own TUI holds the terminal and turns are pasted into it, so a person can type turns of their
|
|
5858
|
+
* own there. In `terminal` mode the events come from the harness's hooks, so a kind may report less there
|
|
5859
|
+
* (Claude Code's TUI sends no `harness.message`). The kind's `modes` in `GET /v1/agents/harnesses` lists
|
|
5860
|
+
* what it takes (`422 harness_capability_unsupported` otherwise), with these limits:
|
|
5861
|
+
*
|
|
5862
|
+
* - Codex and pi run in `api` only. pi's RPC process and its TUI cannot share one session file yet.
|
|
5863
|
+
* - opencode in `terminal` takes no `hooks.decide` outside `permissions: plan`: its TUI answers permission
|
|
5864
|
+
* prompts itself, and an "always" answered there would keep the webhook from seeing that tool again. The
|
|
5865
|
+
* kind's `capabilities.decide_modes` lists the modes where `hooks.decide` answers.
|
|
5866
|
+
* @default "api"
|
|
5867
|
+
*/
|
|
5868
|
+
mode?: "api" | "terminal";
|
|
5869
|
+
/**
|
|
5870
|
+
* The repository cloned into the workspace. Not served yet: refused at write, even empty, with `422
|
|
5871
|
+
* harness_capability_unsupported` until the harness's shim clones it.
|
|
5872
|
+
*/
|
|
5873
|
+
repo?: AgentHarnessRepo;
|
|
5874
|
+
/**
|
|
5875
|
+
* Appended to the harness's own system prompt, as written, when a harness session starts. Yours, so never
|
|
5876
|
+
* quoted.
|
|
5877
|
+
*/
|
|
5878
|
+
instructions?: string;
|
|
5879
|
+
/**
|
|
5880
|
+
* Text added, as written, at each harness session's start (`session_start`) or before each turn
|
|
5881
|
+
* (`turn_start`); a resumed session does not get `session_start` again.
|
|
5882
|
+
* - `api` mode: it goes before the turn's own text in its prompt.
|
|
5883
|
+
* - `terminal` mode: it goes through the TUI's own hooks (Claude Code's SessionStart and UserPromptSubmit
|
|
5884
|
+
* `additionalContext`). A kind whose TUI the shim cannot reach is refused it there (`422
|
|
5885
|
+
* harness_capability_unsupported`); today that is opencode.
|
|
5886
|
+
*
|
|
5887
|
+
* Not served on the beta node yet: refused at write, even as `[]`, with `422 harness_capability_unsupported`.
|
|
5888
|
+
*/
|
|
5889
|
+
context?: AgentHarnessContext[];
|
|
5890
|
+
/**
|
|
5891
|
+
* Skills (folders with a `SKILL.md`), by name, put where the harness reads them: Claude Code's skills
|
|
5892
|
+
* directory of each profile, Codex's extra skill roots. It starts with `b3os`, the builtin skill for B3OS's
|
|
5893
|
+
* tools; this map is a JSON merge patch over that default (`AgentHarness`): a new name is added and `null`
|
|
5894
|
+
* removes an entry. `b3os` takes only `{builtin: b3os}` or `null`. Stored as written. A kind whose `setup`
|
|
5895
|
+
* in `GET /v1/agents/harnesses` does not list `skills` gets no default, and a skill of yours there answers
|
|
5896
|
+
* `422 harness_capability_unsupported`.
|
|
5897
|
+
*/
|
|
5898
|
+
skills?: Record<string, AgentHarnessSetupItem | null>;
|
|
5899
|
+
/**
|
|
5900
|
+
* Plugins, by name, in the kind's own plugin format: a Claude Code plugin directory (loaded with
|
|
5901
|
+
* `--plugin-dir`), a Codex plugin (installed from a local marketplace at prepare). There is no default
|
|
5902
|
+
* plugin. With `permissions: ask`, a
|
|
5903
|
+
* plugin whose hooks can answer a permission prompt (Claude Code's `PreToolUse` or `PermissionRequest`) is
|
|
5904
|
+
* `400 invalid_request`, since a person is the gate there; with `hooks.decide` it is allowed, because the
|
|
5905
|
+
* shim's own hook still runs on every tool and a deny wins. A kind whose `setup` does not list `plugins`
|
|
5906
|
+
* answers `422 harness_capability_unsupported`.
|
|
5907
|
+
*/
|
|
5908
|
+
plugins?: Record<string, AgentHarnessSetupItem>;
|
|
5909
|
+
/**
|
|
5910
|
+
* MCP servers for the harness, by name, written into its own MCP config when the instance starts:
|
|
5911
|
+
* opencode's `mcp`, each profile's Codex `config.toml`, Claude Code's `--mcp-config` file (with
|
|
5912
|
+
* `--strict-mcp-config`, so a repository's own `.mcp.json` is not read), or an ACP harness's session. Each
|
|
5913
|
+
* is remote (`url`) or run in the instance (`command`). It starts with `b3os`, B3OS's own server
|
|
5914
|
+
* (`AgentHarnessMcpBuiltin`), which brings the instance's grant; this map is a JSON merge patch over that
|
|
5915
|
+
* default (`AgentHarness`): a new name is added, `null` removes an entry, and `"b3os": {"toolsets": [...]}`
|
|
5916
|
+
* narrows the default's toolsets without restating `builtin`. Stored as written. A kind whose `setup` does
|
|
5917
|
+
* not list `mcp` gets no default, and a server of yours there answers `422 harness_capability_unsupported`.
|
|
5918
|
+
*/
|
|
5919
|
+
mcp?: {
|
|
5920
|
+
b3os?: AgentHarnessMcpBuiltin | null;
|
|
5921
|
+
[key: string]: unknown;
|
|
5922
|
+
};
|
|
5923
|
+
settings?: AgentHarnessSettings;
|
|
5924
|
+
/**
|
|
5925
|
+
* Files written into the workspace before the first harness session, after the repository is cloned
|
|
5926
|
+
* (`CLAUDE.md`, `AGENTS.md`). A file already at the path is replaced. Skills and plugins go in `skills` and
|
|
5927
|
+
* `plugins`.
|
|
5928
|
+
*/
|
|
5929
|
+
files?: AgentHarnessFile[];
|
|
5930
|
+
hooks?: AgentHarnessHooks;
|
|
5931
|
+
terminal?: AgentHarnessTerminal;
|
|
5932
|
+
}
|
|
5933
|
+
/**
|
|
5934
|
+
* A harness your organization brings, for `kind: acp` only (planned: it needs prepared snapshots, and it is for
|
|
5935
|
+
* your organization's own use). It speaks the Agent Client Protocol over stdio: the shim starts `command` as the
|
|
5936
|
+
* harness's user, opens a session with the block's `mcp` servers, sends each turn as a prompt and each cancel as
|
|
5937
|
+
* an interrupt, and answers the harness's permission requests through the same rules, `hooks.decide` and people
|
|
5938
|
+
* as any harness, allowing or rejecting each call once. The package is installed at prepare. An ACP harness
|
|
5939
|
+
* takes `key` and `node` profiles only, never `signin`; it is steered only when it implements B3OS's optional
|
|
5940
|
+
* `_b3os/steer` method (`422 harness_capability_unsupported` otherwise); and `hooks.decide` on
|
|
5941
|
+
* `harness.tool.requested` is refused, because the node cannot check that every tool call reaches a permission
|
|
5942
|
+
* request. With any other `kind` it is `400 invalid_request`.
|
|
5943
|
+
*/
|
|
5944
|
+
export interface AgentHarnessAcp {
|
|
5945
|
+
npm: AgentHarnessNpmSource;
|
|
5946
|
+
/** The command that starts the harness in ACP mode, from the installed package. */
|
|
5947
|
+
command: string[];
|
|
5948
|
+
/** The environment variables the harness reads a `key` profile's key from. */
|
|
5949
|
+
key_env?: string[];
|
|
5950
|
+
}
|
|
5951
|
+
/**
|
|
5952
|
+
* How the harness reaches its model: named credential profiles, so plans, subscriptions and API keys sit side by
|
|
5953
|
+
* side and each turn uses one of them. B3OS never collects, stores, reads or routes a plan's token: no member
|
|
5954
|
+
* takes one, a harness agent's `env`, `secrets`, `mcp` `env` and `settings` `env` refuse the variables a
|
|
5955
|
+
* harness reads one from (`AgentHarnessPlanEnv`), and a value holding one, in the definition or in a connection
|
|
5956
|
+
* it names, is `400 harness_plan_credential` (`AgentHarness`).
|
|
5957
|
+
*
|
|
5958
|
+
* - `{connection}` is shorthand for one `key` profile named `default`.
|
|
5959
|
+
* - Left out, with a `model` the node's infer serves, it is one `node` profile named `default`, for a kind
|
|
5960
|
+
* whose catalog entry has `auth.node: true` (`422 harness_capability_unsupported` for another); left out
|
|
5961
|
+
* with any other model, `400 invalid_request`.
|
|
5962
|
+
* - `{default, profiles}`: up to 8 named profiles (`AgentHarnessAuthProfile`). `default` is the profile a turn
|
|
5963
|
+
* uses when neither its message nor its conversation names one, and is required with more than one profile.
|
|
5964
|
+
*
|
|
5965
|
+
* The node stores the expanded form, so a read always shows `{default, profiles}`.
|
|
5966
|
+
*
|
|
5967
|
+
* A turn's profile is its message's `profile`, else the one its conversation used last, else `default`. A
|
|
5968
|
+
* caller only picks among the definition's profiles and never sends a credential with a turn. Profiles switch
|
|
5969
|
+
* between turns only, and a switch to another account starts without the provider's prompt cache. Each profile
|
|
5970
|
+
* has its own directory in the instance, so two sign-ins never share a file, and the harness's sessions are
|
|
5971
|
+
* shared across them, so a conversation goes on under another profile.
|
|
5972
|
+
*
|
|
5973
|
+
* A profile's `fallback` names the profile a conversation moves to when this one reaches a usage limit or is
|
|
5974
|
+
* refused. A fallback never moves into a `signin` profile, so a plan is only ever chosen by name, and it never
|
|
5975
|
+
* moves back by itself: `harness.auth.limited` carries `resets_at`, and you move back by naming the profile.
|
|
5976
|
+
* Errors the harness retries itself (a rate limit of the moment, a 5xx, an overload) never trigger one. Until a
|
|
5977
|
+
* kind's limit signal is checked against its pinned version, no fallback fires for it.
|
|
5978
|
+
*/
|
|
5979
|
+
export type AgentHarnessAuth = AgentHarnessAuthConnection | AgentHarnessAuthProfiles;
|
|
5980
|
+
/** Shorthand for `{default: default, profiles: {default: {type: key, connection}}}`. */
|
|
5981
|
+
export interface AgentHarnessAuthConnection {
|
|
5982
|
+
connection: string;
|
|
5983
|
+
}
|
|
5984
|
+
export interface AgentHarnessAuthProfiles {
|
|
5985
|
+
default?: AgentHarnessProfileName;
|
|
5986
|
+
/**
|
|
5987
|
+
* The profiles by name. A `default` that names none of them, a `fallback` whose `to` names none of them or
|
|
5988
|
+
* a `signin` profile, and a cycle of fallbacks are `400 invalid_request`.
|
|
5989
|
+
*/
|
|
5990
|
+
profiles: Record<string, AgentHarnessAuthProfile>;
|
|
5991
|
+
}
|
|
5992
|
+
/**
|
|
5993
|
+
* A credential profile's name: 1 to 32 lowercase letters, digits and single `_`s, starting with a letter and
|
|
5994
|
+
* not ending with `_`. It goes into an environment variable's name, `B3OS_PROFILE_<NAME>__<VAR>`, where the
|
|
5995
|
+
* first `__` ends the name, so no two profiles and variables share one.
|
|
5996
|
+
*/
|
|
5997
|
+
export type AgentHarnessProfileName = string;
|
|
5998
|
+
/**
|
|
5999
|
+
* One credential: `key` (an API key or a cloud provider's credentials from your vault), `signin` (a person's own
|
|
6000
|
+
* plan, signed in inside their own instance) or `node` (a model the node serves). The kind's `auth` in
|
|
6001
|
+
* `GET /v1/agents/harnesses` says which it takes.
|
|
6002
|
+
*/
|
|
6003
|
+
export type AgentHarnessAuthProfile = AgentHarnessAuthKey | AgentHarnessAuthSignin | AgentHarnessAuthNode;
|
|
6004
|
+
/**
|
|
6005
|
+
* An API key, or a cloud provider's credentials, from a vault connection. The node puts its values in the
|
|
6006
|
+
* shim's environment as `B3OS_PROFILE_<NAME>__<VAR>`, and the shim gives them, under the names the harness reads
|
|
6007
|
+
* (the kind's `auth.key`), to this profile's harness processes only; opencode's one server holds every `key`
|
|
6008
|
+
* profile's. Until egress credential injection ships, code in the instance can read the key, as with an agent's
|
|
6009
|
+
* `secrets`; it needs `vault:run` and `vault:connections:reveal`. The provider bills the key's owner.
|
|
6010
|
+
*/
|
|
6011
|
+
export interface AgentHarnessAuthKey {
|
|
6012
|
+
type: "key";
|
|
6013
|
+
connection: string;
|
|
6014
|
+
provider?: AgentHarnessKeyProvider;
|
|
6015
|
+
/**
|
|
6016
|
+
* For `anthropic_compatible` and `openai_compatible` only: the gateway the harness sends to. Its host
|
|
6017
|
+
* joins the filled `egress`.
|
|
6018
|
+
*/
|
|
6019
|
+
base_url?: string;
|
|
6020
|
+
/** The cloud region, for `bedrock` and `vertex`. */
|
|
6021
|
+
region?: string;
|
|
6022
|
+
/** The model for this profile's turns, when it is not the block's `model`. */
|
|
6023
|
+
model?: string;
|
|
6024
|
+
/** A name for people (the console, the CLI, events). */
|
|
6025
|
+
label?: string;
|
|
6026
|
+
fallback?: AgentHarnessAuthFallback;
|
|
6027
|
+
}
|
|
6028
|
+
/**
|
|
6029
|
+
* A person's own plan (a Claude or ChatGPT subscription), which that person signs in to inside their own
|
|
6030
|
+
* instance with the harness's own login, in the sign-in window (`GET …/terminal?window=signin:<profile>`). The
|
|
6031
|
+
* harness writes its credential file in this profile's directory, as it would on a laptop. B3OS never asks for
|
|
6032
|
+
* the token, never reads, stores or copies the file, and has no member to take one; the shim checks only that
|
|
6033
|
+
* the file exists, and asks the harness what it is signed in as (`harness.auth.ready`).
|
|
6034
|
+
*
|
|
6035
|
+
* A `signin` profile makes the agent personal (`Agent.owner`), whatever the provider: a person makes it, not a
|
|
6036
|
+
* key, and only its owner drives it, so one person uses each plan. Forks and children never carry a sign-in.
|
|
6037
|
+
* It needs a `provider` the kind's `auth.signin` lists (`422 harness_signin_unsupported`), and it is served
|
|
6038
|
+
* only on an instance made from the revision's prepared snapshot, which holds no other harness that could read
|
|
6039
|
+
* the file. A ChatGPT plan (`openai`) needs no flag. A Claude plan (`anthropic`) needs the
|
|
6040
|
+
* `agents.claude_plan_signin` flag, off by default and turned on per organization (`403
|
|
6041
|
+
* harness_claude_plan_signin_disabled` without it). The provider's terms for personal plans apply, and they
|
|
6042
|
+
* assume one person's ordinary use.
|
|
6043
|
+
*
|
|
6044
|
+
* Not served yet. Personal agents wait on two prerequisites, and until both land the node refuses every
|
|
6045
|
+
* `signin` profile with `403 harness_personal_agent`, whatever its provider and flag:
|
|
6046
|
+
*
|
|
6047
|
+
* - Harness agent VMs closed to the generic sandboxes API. Today any caller holding `sandboxes:run` in the
|
|
6048
|
+
* project can reach an agent's microVM by its `sandbox_id` (`GET /v1/sandboxes/{sandbox_id}`, exec, files,
|
|
6049
|
+
* logs and ports), and so read a sign-in's credential file and the shim's token. A personal agent's VMs (and,
|
|
6050
|
+
* once the node can, every harness agent's) answer those routes as a sandbox that does not exist, and
|
|
6051
|
+
* `AgentInstance.sandbox_id` is `null` for them.
|
|
6052
|
+
* - A person in the node's principal. A node token carries the organization, the project, the key, its scopes
|
|
6053
|
+
* and the request ID, and no person, so the node cannot tell an owner from anyone else in the project. The
|
|
6054
|
+
* edge's node tokens for dashboard sessions and CLI tokens gain the person (`usr`) and their organization
|
|
6055
|
+
* role, the claims workspaces asks for too.
|
|
6056
|
+
*
|
|
6057
|
+
* After both, a `signin` profile still waits for prepared snapshots (`422 harness_setup_needs_prepare` until
|
|
6058
|
+
* they ship).
|
|
6059
|
+
*/
|
|
6060
|
+
export interface AgentHarnessAuthSignin {
|
|
6061
|
+
type: "signin";
|
|
6062
|
+
/**
|
|
6063
|
+
* `openai` (a ChatGPT plan) or `anthropic` (a Claude plan, behind `agents.claude_plan_signin`). The kind's
|
|
6064
|
+
* `auth.signin` in `GET /v1/agents/harnesses` lists which it signs in to: today Codex `openai` and Claude
|
|
6065
|
+
* Code `anthropic`, and opencode and pi none until their logins are checked on their pinned versions.
|
|
6066
|
+
*/
|
|
6067
|
+
provider: "anthropic" | "openai";
|
|
6068
|
+
/** The model for this profile's turns, when it is not the block's `model`. */
|
|
6069
|
+
model?: string;
|
|
6070
|
+
/** A name for people (the console, the CLI, events). */
|
|
6071
|
+
label?: string;
|
|
6072
|
+
fallback?: AgentHarnessAuthFallback;
|
|
6073
|
+
}
|
|
6074
|
+
/**
|
|
6075
|
+
* A model the node's infer serves (`GET /v1/infer/models`), reached inside the instance with no key, at the
|
|
6076
|
+
* `base_url` the node gives the shim (`http://127.0.0.1:7700/v1/infer`). It adds `infer:run` to the instance's
|
|
6077
|
+
* grant, and infer bills its tokens to your organization. Only for a kind whose catalog entry has `auth.node:
|
|
6078
|
+
* true` (`422 harness_capability_unsupported` otherwise): today Codex and Claude Code.
|
|
6079
|
+
*/
|
|
6080
|
+
export interface AgentHarnessAuthNode {
|
|
6081
|
+
type: "node";
|
|
6082
|
+
model: string;
|
|
6083
|
+
/** A name for people (the console, the CLI, events). */
|
|
6084
|
+
label?: string;
|
|
6085
|
+
fallback?: AgentHarnessAuthFallback;
|
|
6086
|
+
}
|
|
6087
|
+
/**
|
|
6088
|
+
* Whose API a `key` profile's credentials are for. Default: the connection's provider; the stored profile always
|
|
6089
|
+
* names it. Only a provider the kind's `auth.key` lists, with its hosts in `auth.hosts` (`422
|
|
6090
|
+
* harness_capability_unsupported` otherwise).
|
|
6091
|
+
*/
|
|
6092
|
+
export type AgentHarnessKeyProvider = "anthropic" | "openai" | "bedrock" | "vertex" | "foundry" | "azure_openai" | "openrouter" | "openai_compatible" | "anthropic_compatible";
|
|
6093
|
+
/**
|
|
6094
|
+
* Where a conversation goes when this profile stops. The turn that stopped ends `harness.turn.failed`
|
|
6095
|
+
* (`error.code` `limit_reached` or `auth_required`), the shim marks the profile limited until its `resets_at`
|
|
6096
|
+
* (or until it checks again at the next turn) and sends `harness.auth.limited`, and the conversation moves to
|
|
6097
|
+
* `to` (`harness.auth.switched`). A chain follows each profile's own `fallback`. When every profile is limited,
|
|
6098
|
+
* the turn fails `no_profile_ready` with the earliest `resets_at`.
|
|
6099
|
+
*/
|
|
6100
|
+
export interface AgentHarnessAuthFallback {
|
|
6101
|
+
to: AgentHarnessProfileName;
|
|
6102
|
+
/**
|
|
6103
|
+
* `limit`: a usage limit was reached or the credits ran out. `auth`: the credential was refused or expired.
|
|
6104
|
+
*/
|
|
6105
|
+
on: Array<"limit" | "auth">;
|
|
6106
|
+
/**
|
|
6107
|
+
* `next_turn` (the default, chosen): the conversation's next turn runs on `to`. `continue`: the shim starts
|
|
6108
|
+
* one turn on `to` at once, with a fixed line ("Continue the task; the previous turn stopped at a usage
|
|
6109
|
+
* limit") and `source: fallback`. The prompt that stopped is never sent again, since its tools may have run.
|
|
6110
|
+
* @default "next_turn"
|
|
6111
|
+
*/
|
|
6112
|
+
resume?: "next_turn" | "continue";
|
|
6113
|
+
}
|
|
6114
|
+
/**
|
|
6115
|
+
* A skill or a plugin, under its name in `skills` or `plugins`: exactly one source. `text`, `files` and `builtin`
|
|
6116
|
+
* are written when the instance starts. `git`, `npm` and `artifact` are fetched once, at prepare, into the
|
|
6117
|
+
* revision's prepared snapshot, and are pinned so a revision never changes under you: a git `ref` is resolved to a
|
|
6118
|
+
* `commit` when the definition is written, an npm `version` is exact (`422 harness_setup_unpinned` otherwise) and
|
|
6119
|
+
* its integrity is recorded, and an artifact is checked by its `sha256`.
|
|
6120
|
+
*/
|
|
6121
|
+
export type AgentHarnessSetupItem = {
|
|
6122
|
+
/** A skill's one file, its `SKILL.md`. Not for a plugin. */
|
|
6123
|
+
text?: string;
|
|
6124
|
+
/** The item's files, each relative to the item's folder. */
|
|
6125
|
+
files?: AgentHarnessFile[];
|
|
6126
|
+
git?: AgentHarnessGitSource;
|
|
6127
|
+
npm?: AgentHarnessNpmSource;
|
|
6128
|
+
artifact?: AgentHarnessArtifactSource;
|
|
6129
|
+
/**
|
|
6130
|
+
* One of B3's own items, shipped in the `harness` template. `b3os` is the skill for B3OS's tools, and the
|
|
6131
|
+
* default entry of `skills`; only under the name `b3os`, and only in `skills`.
|
|
6132
|
+
*/
|
|
6133
|
+
builtin?: "b3os";
|
|
6134
|
+
};
|
|
6135
|
+
/**
|
|
6136
|
+
* A folder of a public Git repository, fetched at prepare (the build has no access to your vault). Give `ref` or
|
|
6137
|
+
* `commit`: the node resolves a `ref` once, when the definition is written, and stores the `commit` beside it.
|
|
6138
|
+
* That lookup leaves from the node through the egress guard, as a webhook delivery does (private and loopback
|
|
6139
|
+
* addresses refused), and counts as your egress; a `ref` it cannot resolve is `400 invalid_request`, naming
|
|
6140
|
+
* the member, never quoting what the server answered.
|
|
6141
|
+
*/
|
|
6142
|
+
export interface AgentHarnessGitSource {
|
|
6143
|
+
url: string;
|
|
6144
|
+
/** A branch or tag. */
|
|
6145
|
+
ref?: string;
|
|
6146
|
+
commit?: string;
|
|
6147
|
+
/** The item's folder in the repository. Default, its root. */
|
|
6148
|
+
path?: string;
|
|
6149
|
+
}
|
|
6150
|
+
/**
|
|
6151
|
+
* An npm package, installed at prepare with its install scripts off. `version` is an exact version; a range or
|
|
6152
|
+
* a tag is `422 harness_setup_unpinned`. The node records the package's `integrity` when the definition is
|
|
6153
|
+
* written, looking it up through the egress guard, and checks it at prepare.
|
|
6154
|
+
*/
|
|
6155
|
+
export interface AgentHarnessNpmSource {
|
|
6156
|
+
package: string;
|
|
6157
|
+
version: string;
|
|
6158
|
+
/** The package's `sha512-` integrity, set by the node. */
|
|
6159
|
+
integrity?: string;
|
|
6160
|
+
}
|
|
6161
|
+
/**
|
|
6162
|
+
* A bundle of the item's folder in your project's artifact store, checked by `sha256` at prepare. Uploading one
|
|
6163
|
+
* needs a public artifact upload route, which is planned.
|
|
6164
|
+
*/
|
|
6165
|
+
export interface AgentHarnessArtifactSource {
|
|
6166
|
+
id: string;
|
|
6167
|
+
sha256: string;
|
|
6168
|
+
}
|
|
6169
|
+
/**
|
|
6170
|
+
* The harness's own settings, under the block's own `kind` (another kind's key is `400 invalid_request`),
|
|
6171
|
+
* merged under the settings the shim writes when the instance starts: opencode's config, each profile's Codex
|
|
6172
|
+
* `config.toml`, pi's `settings.json`, Claude Code's `--settings` file. A key the shim owns (the kind's
|
|
6173
|
+
* `settings_refused`: its hooks, permissions, login method, providers, MCP servers, and the plugins and plugin
|
|
6174
|
+
* marketplaces it turns on) is `400 invalid_request`, naming the key, and so is an `env` entry (Claude Code's
|
|
6175
|
+
* `env`) named in `AgentHarnessPlanEnv`, like one of the kind's key variables or `B3OS_*`, and a plan's token in
|
|
6176
|
+
* any value. MCP servers go in `mcp` and plugins in `plugins`, where they are pinned and checked.
|
|
6177
|
+
*/
|
|
6178
|
+
export interface AgentHarnessSettings {
|
|
6179
|
+
opencode?: Record<string, unknown>;
|
|
6180
|
+
codex?: Record<string, unknown>;
|
|
6181
|
+
pi?: Record<string, unknown>;
|
|
6182
|
+
"claude-code"?: Record<string, unknown>;
|
|
6183
|
+
}
|
|
6184
|
+
/** The repository cloned into the workspace at the instance's first start, before its first turn. */
|
|
6185
|
+
export interface AgentHarnessRepo {
|
|
6186
|
+
/** An `https://` Git URL. */
|
|
6187
|
+
url: string;
|
|
6188
|
+
/** The branch, tag or commit to check out. Default, the repository's default branch. */
|
|
6189
|
+
ref?: string;
|
|
6190
|
+
/**
|
|
6191
|
+
* A vault connection with a token for a private repository. The node delivers its secret as a
|
|
6192
|
+
* `B3OS_CONN_<N>` variable, and the harness's shim clones inside the instance and writes the token into the
|
|
6193
|
+
* instance's git credentials, so the harness can fetch and push with it and code in the instance can read
|
|
6194
|
+
* it; it needs `vault:run` and `vault:connections:reveal`. Refused with the rest of `repo` (`422
|
|
6195
|
+
* harness_capability_unsupported`) until the shim clones it.
|
|
6196
|
+
*/
|
|
6197
|
+
connection?: string;
|
|
6198
|
+
}
|
|
6199
|
+
export interface AgentHarnessContext {
|
|
6200
|
+
at: "session_start" | "turn_start";
|
|
6201
|
+
text: string;
|
|
6202
|
+
}
|
|
6203
|
+
export interface AgentHarnessMcpRemote {
|
|
6204
|
+
/**
|
|
6205
|
+
* The server's `https://` URL (streamable HTTP or SSE). Reached through the instance's `egress`, which the
|
|
6206
|
+
* node fills with its host.
|
|
6207
|
+
*/
|
|
6208
|
+
url: string;
|
|
6209
|
+
/**
|
|
6210
|
+
* A vault connection whose token the harness sends to this server as `Authorization: Bearer <token>`. The
|
|
6211
|
+
* node delivers its secret as a `B3OS_CONN_<N>` variable, and the shim writes the harness's MCP config to
|
|
6212
|
+
* send it (as a variable the config refers to, never the value: opencode's `{env:...}`, Claude Code's
|
|
6213
|
+
* `${...}`, Codex's `bearer_token_env_var`), so code in the instance can read it. It needs `vault:run` and
|
|
6214
|
+
* `vault:connections:reveal`, and a connection whose type has a credential field (`api_key`, `bearer` or
|
|
6215
|
+
* `oauth2`; another is `400 invalid_request`). A connection bound to `hosts` is `422
|
|
6216
|
+
* connection_host_bound` (B3OS adds such a credential only at the egress proxy, never inside a VM), and one
|
|
6217
|
+
* holding a plan's token is `400 harness_plan_credential`.
|
|
6218
|
+
*/
|
|
6219
|
+
connection?: string;
|
|
6220
|
+
}
|
|
6221
|
+
/**
|
|
6222
|
+
* A server the harness starts in the instance, as the harness's user, over stdio. With `npm`, the package is
|
|
6223
|
+
* installed at prepare and its commands are on the server's `PATH`; until prepared snapshots ship that answers
|
|
6224
|
+
* `422 harness_setup_needs_prepare`.
|
|
6225
|
+
*/
|
|
6226
|
+
export interface AgentHarnessMcpStdio {
|
|
6227
|
+
command: string[];
|
|
6228
|
+
npm?: AgentHarnessNpmSource;
|
|
6229
|
+
/**
|
|
6230
|
+
* The server's environment. A `{connection}` value is a vault connection's secret, delivered as a
|
|
6231
|
+
* `B3OS_CONN_<N>` variable and set in the server's environment by the shim, so code in the instance can read
|
|
6232
|
+
* it; it needs `vault:run` and `vault:connections:reveal`. `field` names the secret field, and is required
|
|
6233
|
+
* for a connection type with no credential field of its own (`400 invalid_request`). A connection bound to
|
|
6234
|
+
* `hosts` is `422 connection_host_bound`.
|
|
6235
|
+
*/
|
|
6236
|
+
env?: Record<string, string | {
|
|
6237
|
+
connection: string;
|
|
6238
|
+
/** Which secret field of the connection, as a sandbox's `secrets` takes it. */
|
|
6239
|
+
field?: string;
|
|
6240
|
+
}>;
|
|
6241
|
+
}
|
|
6242
|
+
/**
|
|
6243
|
+
* B3OS's own MCP server inside the instance, at the instance's local address (`B3OS_MCP_URL`): the `mcp.b3os`
|
|
6244
|
+
* entry, and only that one. The default is `{builtin: b3os}` with all six toolsets; what you write under `b3os`
|
|
6245
|
+
* is merged into it as a JSON merge patch, so `{toolsets: [vision]}` narrows it and `builtin` need not be
|
|
6246
|
+
* restated. It brings the instance's B3OS MCP grant: the node fills `api` with the scopes the merged entry's
|
|
6247
|
+
* `toolsets` need, scoped to the instance, unless the definition sets `api` itself. A definition without this
|
|
6248
|
+
* entry gets no filled B3OS MCP scopes (only `infer:run` when it declares a `node` profile, and nothing
|
|
6249
|
+
* otherwise). The server lists the tools of each toolset this node serves, so a node without one lists fewer
|
|
6250
|
+
* tools.
|
|
6251
|
+
*/
|
|
6252
|
+
export interface AgentHarnessMcpBuiltin {
|
|
6253
|
+
/** `b3os`: B3OS's own server, the default's; may be left out. */
|
|
6254
|
+
builtin?: "b3os";
|
|
6255
|
+
/**
|
|
6256
|
+
* Which of B3OS's tools the server lists, and so which scopes the filled grant holds. Default: all six.
|
|
6257
|
+
* `browser` (the `browser_*` tools; `vision:run` and `vision:write`), `vision` (web pages: `vision_scrape`
|
|
6258
|
+
* and the like; `vision:run`), `render` (screenshots and videos; `render:run`), `sandboxes` (code in
|
|
6259
|
+
* other sandboxes; `sandboxes:run`), `actions` (the pack actions the grant's actions rule allows;
|
|
6260
|
+
* `actions:read` and `actions:run`) and `infer` (the node's models; `infer:run`).
|
|
6261
|
+
*/
|
|
6262
|
+
toolsets?: Array<"browser" | "vision" | "render" | "sandboxes" | "actions" | "infer">;
|
|
6263
|
+
}
|
|
6264
|
+
export interface AgentHarnessFile {
|
|
6265
|
+
/**
|
|
6266
|
+
* Relative to the workspace, or, in a skill's or plugin's `files`, to the item's folder. A path with a `..`
|
|
6267
|
+
* segment is `400 invalid_request`.
|
|
6268
|
+
*/
|
|
6269
|
+
path: string;
|
|
6270
|
+
text: string;
|
|
6271
|
+
}
|
|
6272
|
+
/** Where the harness's events go beyond its session's stream, and who answers its questions. */
|
|
6273
|
+
export interface AgentHarnessHooks {
|
|
6274
|
+
webhook?: AgentHarnessWebhook;
|
|
6275
|
+
decide?: AgentHarnessDecide;
|
|
6276
|
+
/**
|
|
6277
|
+
* Add each event's native payload (`native.payload`: the harness's own hook or stream record), after the
|
|
6278
|
+
* redaction listeners use. Off by default, because a native payload can hold a tool's whole input.
|
|
6279
|
+
* @default false
|
|
6280
|
+
*/
|
|
6281
|
+
include_native?: boolean;
|
|
6282
|
+
}
|
|
6283
|
+
/** An event type (`harness.turn.completed`), a family (`harness.turn.*`) or `*` for every type. */
|
|
6284
|
+
export type AgentHarnessEventPattern = string;
|
|
6285
|
+
/**
|
|
6286
|
+
* Where the agents product sends this agent's `harness.*` events, from every instance and every way a turn
|
|
6287
|
+
* came: each event `events` selects is a `POST` of a `WebhookEvent` (`agentsDeliverHarnessEvent`), signed with
|
|
6288
|
+
* `B3OS-Signature` and the URL's secret (`POST /v1/webhooks/secret`), retried with backoff for 24 hours, in
|
|
6289
|
+
* order per session. Delivery goes through the egress guard.
|
|
6290
|
+
*/
|
|
6291
|
+
export interface AgentHarnessWebhook {
|
|
6292
|
+
/** An `https://` URL. */
|
|
6293
|
+
url: string;
|
|
6294
|
+
/**
|
|
6295
|
+
* Default: every type but `harness.message`, which carries each piece of streamed text as its own event; name
|
|
6296
|
+
* it, or `*`, to get it too.
|
|
6297
|
+
*/
|
|
6298
|
+
events?: AgentHarnessEventPattern[];
|
|
6299
|
+
}
|
|
6300
|
+
/**
|
|
6301
|
+
* A webhook that answers the harness's questions while the turn waits (`agentsDecideHarnessEvent`): before a
|
|
6302
|
+
* tool runs (`harness.tool.requested`), when the harness asks for permission (`harness.permission.requested`),
|
|
6303
|
+
* or as a turn starts (`harness.turn.started`, to add context). The harness's shim hands each question to the
|
|
6304
|
+
* node (`POST /v1/agents/self/decide`), and the node makes the call: signed as a webhook delivery is, through
|
|
6305
|
+
* the egress guard (private and loopback addresses refused), so the URL's secret never enters the instance and
|
|
6306
|
+
* its host need not be in the instance's `egress`. The turn waits up to `timeout_ms` for `{decision: allow |
|
|
6307
|
+
* deny | ask, reason?, context?}`. It fails closed: no answer in time, a status other than 2xx, or a body
|
|
6308
|
+
* without a `decision` is `deny`, unless `on_timeout` is `allow`. `ask` hands the question to a person. The
|
|
6309
|
+
* definition's own rules come first, and in `permissions: plan` the webhook is never called: the harness's
|
|
6310
|
+
* read-only mode and the rules answer every question there.
|
|
6311
|
+
*/
|
|
6312
|
+
export interface AgentHarnessDecide {
|
|
6313
|
+
/** An `https://` URL. */
|
|
6314
|
+
url: string;
|
|
6315
|
+
/** @default ["harness.tool.requested"] */
|
|
6316
|
+
events?: Array<"harness.tool.requested" | "harness.permission.requested" | "harness.turn.started">;
|
|
6317
|
+
/**
|
|
6318
|
+
* How long the turn waits for the answer.
|
|
6319
|
+
* @default 3000
|
|
6320
|
+
*/
|
|
6321
|
+
timeout_ms?: number;
|
|
6322
|
+
/**
|
|
6323
|
+
* The decision when the webhook does not answer in time, fails, or answers without a decision.
|
|
6324
|
+
* @default "deny"
|
|
6325
|
+
*/
|
|
6326
|
+
on_timeout?: "deny" | "allow";
|
|
6327
|
+
}
|
|
6328
|
+
export interface AgentHarnessTerminal {
|
|
6329
|
+
/**
|
|
6330
|
+
* Record the terminal as asciicast v3 files on the instance's disk (`…/terminal/recordings`). Off by default:
|
|
6331
|
+
* a recording keeps whatever the terminal showed, codes and keys printed in it included.
|
|
6332
|
+
* @default false
|
|
6333
|
+
*/
|
|
6334
|
+
record?: boolean;
|
|
6335
|
+
}
|
|
6336
|
+
/**
|
|
6337
|
+
* The type of a harness event, the same for every harness. Each is what the instance reports about itself, not
|
|
6338
|
+
* something the node observed. What each carries in `data`:
|
|
6339
|
+
*
|
|
6340
|
+
* - `harness.session.started`: `native_session` (the harness's own session ID), `resumed`, `model`, `auth`
|
|
6341
|
+
* (`profile`, `type`, `provider`) and `withheld` (the names of the variables the shim kept from the harness,
|
|
6342
|
+
* never their values). `harness.session.ended`: `reason`.
|
|
6343
|
+
* - `harness.turn.started`: `source`, `profile`, `chars`, `prompt` (the first 4,000 characters). `source` is
|
|
6344
|
+
* where the turn came from, set from the message's `initiator` and never from its body: `api` (a key, a
|
|
6345
|
+
* person or a sandbox), `routine`, `listener`, `instance` (another agent instance), `terminal` (typed in the
|
|
6346
|
+
* terminal), `steer`, or `fallback` (the turn a profile's `fallback` with `resume: continue` starts).
|
|
6347
|
+
* - `harness.message`: `role`, `text`, `delta` (`true` while the text streams).
|
|
6348
|
+
* - `harness.tool.requested`: `tool`, `call_id`, `summary`, `parent` (the subagent's call, when one ran it).
|
|
6349
|
+
* `harness.tool.completed`: `tool`, `call_id`, `ok`, `duration_ms`.
|
|
6350
|
+
* - `harness.permission.requested`: `request` (the `dec_` ID `POST …/decisions` answers), `kind`, `tool`,
|
|
6351
|
+
* `summary`, `reason`. `harness.permission.resolved`: `request`, or `call_id` for a call the definition's
|
|
6352
|
+
* rules or `hooks.decide` answered without asking; `decision`, `by` (`rules`, `decide`, `person`, `timeout`
|
|
6353
|
+
* or `withdrawn`, when the turn ended first) and `reason`.
|
|
6354
|
+
* - `harness.subagent.started`: `agent_id`, `kind`, `model`. `harness.subagent.completed`: `agent_id`.
|
|
6355
|
+
* - `harness.compacted`: nothing.
|
|
6356
|
+
* - `harness.turn.completed`: `result`, `usage` (`AgentHarnessUsage`), `cost_usd` and `list_price_usd` (as on a
|
|
6357
|
+
* usage row), `timing` (`model_ms`, `tool_ms`, `wall_ms`), `steps` and `files` (the workspace paths the turn
|
|
6358
|
+
* changed, when the harness reports them). `harness.turn.failed`: `error` (`code`, `detail`; `limit_reached`,
|
|
6359
|
+
* `auth_required` and `no_profile_ready` carry `profile` and `resets_at` when known), `timing`, `usage`.
|
|
6360
|
+
* `harness.turn.interrupted`: `timing`, `usage`.
|
|
6361
|
+
* - `harness.terminal.attached` and `harness.terminal.detached`: `role`, `viewer`, `viewers` (how many remain).
|
|
6362
|
+
* - `harness.auth.required`: `profile`, `reason` (`signed_out`, `expired`, `refused` or `missing`), `detail`.
|
|
6363
|
+
* - `harness.auth.ready`: `profile`, `type`, `provider` and `plan` (what the harness says it is signed in as,
|
|
6364
|
+
* when it says).
|
|
6365
|
+
* - `harness.auth.limited`: `profile`, `limit` (`usage`, `credits` or `rate`), `resets_at` and `used_percent`
|
|
6366
|
+
* when the harness reports them, `detail`.
|
|
6367
|
+
* - `harness.auth.switched`: `from`, `to`, `why` (`requested` or `fallback`), `billed_to`.
|
|
6368
|
+
* - `harness.auth.removed`: `profile`, `cli`, `reason`: `signed_out` (the owner signed out), or
|
|
6369
|
+
* `signin_not_personal` (a harness's credential file where no sign-in belongs, removed without being read).
|
|
6370
|
+
*/
|
|
6371
|
+
export type AgentHarnessEventType = "harness.session.started" | "harness.session.ended" | "harness.turn.started" | "harness.message" | "harness.tool.requested" | "harness.tool.completed" | "harness.permission.requested" | "harness.permission.resolved" | "harness.subagent.started" | "harness.subagent.completed" | "harness.compacted" | "harness.turn.completed" | "harness.turn.failed" | "harness.turn.interrupted" | "harness.terminal.attached" | "harness.terminal.detached" | "harness.auth.required" | "harness.auth.ready" | "harness.auth.limited" | "harness.auth.switched" | "harness.auth.removed";
|
|
6372
|
+
/** A turn's token use, one row per model, as the harness reported it. */
|
|
6373
|
+
export interface AgentHarnessUsage {
|
|
6374
|
+
models: AgentHarnessUsageRow[];
|
|
6375
|
+
[key: string]: unknown;
|
|
6376
|
+
}
|
|
6377
|
+
/**
|
|
6378
|
+
* One model's tokens in a turn, and who pays for them. `cost_usd` is there only when `billed_to` is `key` or
|
|
6379
|
+
* `node`; for a plan's turn, the figure the harness reports goes in `list_price_usd`, so a sum of `cost_usd`
|
|
6380
|
+
* never counts a plan's turns as spend.
|
|
6381
|
+
*/
|
|
6382
|
+
export interface AgentHarnessUsageRow {
|
|
6383
|
+
model: string;
|
|
6384
|
+
input: number;
|
|
6385
|
+
cacheRead: number;
|
|
6386
|
+
cacheWrite: number;
|
|
6387
|
+
output: number;
|
|
6388
|
+
reasoning?: number;
|
|
6389
|
+
profile: AgentHarnessProfileName;
|
|
6390
|
+
/** `key`: the key's owner, through the provider. `plan`: a person's plan. `node`: infer on the node. */
|
|
6391
|
+
billed_to: "key" | "plan" | "node";
|
|
6392
|
+
/** What the harness or infer reports this row cost, for `key` and `node` only. */
|
|
6393
|
+
cost_usd?: number;
|
|
6394
|
+
/** For `plan` only, what the harness reports the tokens would cost at list price; not a charge. */
|
|
6395
|
+
list_price_usd?: number;
|
|
6396
|
+
}
|
|
6397
|
+
/**
|
|
6398
|
+
* One event of a harness, in the product-event envelope (ARCHITECTURE 4.12). The harness's shim writes `id`,
|
|
6399
|
+
* `type`, `time`, `harness`, `conversation`, `data` and `native`. The node sets `seq`, `org`, `project`,
|
|
6400
|
+
* `instance` and, for an event of a delivered turn, `session_id` and `subject` (from the session) as it writes
|
|
6401
|
+
* the event to the instance's log, replacing whatever the shim sent on a delivery's answer. The shim numbers
|
|
6402
|
+
* the events of its own streams too, but that number orders them only within one run of the shim and starts
|
|
6403
|
+
* again when the shim restarts; a self event carries none (`AgentSelfEvent`).
|
|
6404
|
+
*/
|
|
6405
|
+
export interface AgentHarnessEvent {
|
|
6406
|
+
/** Unique per event; deduplicate on it. */
|
|
6407
|
+
id: string;
|
|
6408
|
+
/**
|
|
6409
|
+
* The event's place in its instance's event log, set by the node and growing across restarts of the
|
|
6410
|
+
* harness's shim. The SSE `id` of `GET …/stream`.
|
|
6411
|
+
*/
|
|
6412
|
+
seq: number;
|
|
6413
|
+
type: AgentHarnessEventType;
|
|
6414
|
+
time: string;
|
|
6415
|
+
harness: AgentHarnessKindName;
|
|
6416
|
+
org?: string;
|
|
6417
|
+
project?: string;
|
|
6418
|
+
instance?: string;
|
|
6419
|
+
/** The agent session, for an event of a turn sent as a message. */
|
|
6420
|
+
session_id?: string;
|
|
6421
|
+
/** The harness session the event belongs to (the message's `conversation`). */
|
|
6422
|
+
conversation?: string;
|
|
6423
|
+
/** The end user the turn is for, for an event of a delivered turn (the session's `subject`). */
|
|
6424
|
+
subject?: string;
|
|
6425
|
+
/** What happened; `AgentHarnessEventType` lists the members of each type. */
|
|
6426
|
+
data: {
|
|
6427
|
+
usage?: AgentHarnessUsage;
|
|
6428
|
+
[key: string]: unknown;
|
|
6429
|
+
};
|
|
6430
|
+
/** The harness event this one came from. `payload` only with `hooks.include_native`. */
|
|
6431
|
+
native?: {
|
|
6432
|
+
harness: AgentHarnessKindName;
|
|
6433
|
+
event: string;
|
|
6434
|
+
payload?: unknown;
|
|
6435
|
+
};
|
|
6436
|
+
}
|
|
6437
|
+
/**
|
|
6438
|
+
* One harness this node runs, as its driver declares it (`b3os-harness catalog --json`, printed by the shim
|
|
6439
|
+
* and served as printed). A feature not yet checked against the kind's pinned version is left out, and a
|
|
6440
|
+
* definition that uses it is refused.
|
|
6441
|
+
*/
|
|
6442
|
+
export interface AgentHarnessKind {
|
|
6443
|
+
object: "harness_kind";
|
|
6444
|
+
kind: AgentHarnessKindName;
|
|
6445
|
+
/** The harness's own name. */
|
|
6446
|
+
name: string;
|
|
6447
|
+
/**
|
|
6448
|
+
* `native`: a driver built into the shim and reviewed by B3. `acp`: the generic Agent Client Protocol
|
|
6449
|
+
* adapter, which runs the harness as its own process over stdio.
|
|
6450
|
+
*/
|
|
6451
|
+
driver: "native" | "acp";
|
|
6452
|
+
/** The versions this node runs, newest first. */
|
|
6453
|
+
versions: string[];
|
|
6454
|
+
/** What a definition without `version` gets. */
|
|
6455
|
+
default_version: string;
|
|
6456
|
+
modes: Array<"api" | "terminal">;
|
|
6457
|
+
capabilities: AgentHarnessCapabilities;
|
|
6458
|
+
auth: AgentHarnessKindAuth;
|
|
6459
|
+
/** The lists of the `harness` block this kind takes; another is `422 harness_capability_unsupported`. */
|
|
6460
|
+
setup: Array<"skills" | "plugins" | "mcp" | "instructions" | "settings">;
|
|
6461
|
+
/**
|
|
6462
|
+
* The kind's own settings keys the shim owns (its hooks, permissions, login method, providers, MCP servers,
|
|
6463
|
+
* and the plugins and marketplaces it turns on), which a definition's `settings` may not set (`400
|
|
6464
|
+
* invalid_request`).
|
|
6465
|
+
*/
|
|
6466
|
+
settings_refused: string[];
|
|
6467
|
+
/**
|
|
6468
|
+
* The environment variables this kind reads a plan's token from. No harness agent's `env` or `secrets` sets
|
|
6469
|
+
* these, or any other kind's (`400 invalid_request`).
|
|
6470
|
+
*/
|
|
6471
|
+
plan_env: AgentHarnessPlanEnv[];
|
|
6472
|
+
}
|
|
6473
|
+
/** What the kind's driver delivers; the shim's conformance test checks each one it declares. */
|
|
6474
|
+
export interface AgentHarnessCapabilities {
|
|
6475
|
+
/** A running turn takes more text (`POST …/steer`). */
|
|
6476
|
+
steer: boolean;
|
|
6477
|
+
/** A running turn stops with its usage so far, and the harness session stays open. */
|
|
6478
|
+
interrupt: boolean;
|
|
6479
|
+
/** A conversation continues its harness session after the shim or the instance restarts. */
|
|
6480
|
+
resume: boolean;
|
|
6481
|
+
/**
|
|
6482
|
+
* Which tool calls the shim sees before they run, and so which `hooks.decide` on `harness.tool.requested`
|
|
6483
|
+
* answers: `every_tool`, `asked` (only the calls the harness asks permission for), or `partial` (some calls
|
|
6484
|
+
* run without asking, such as Codex's read-only commands).
|
|
6485
|
+
*/
|
|
6486
|
+
tool_gate: "every_tool" | "asked" | "partial";
|
|
6487
|
+
/**
|
|
6488
|
+
* The `mode`s in which `hooks.decide` answers. A definition with `hooks.decide` in another mode is `422
|
|
6489
|
+
* harness_capability_unsupported`, but in `permissions: plan`, where the webhook is never called. opencode
|
|
6490
|
+
* lists `api` only: in `terminal` its TUI answers permission prompts itself.
|
|
6491
|
+
*/
|
|
6492
|
+
decide_modes: Array<"api" | "terminal">;
|
|
6493
|
+
/** Turns report their tokens per model. */
|
|
6494
|
+
usage: boolean;
|
|
6495
|
+
/** The harness's subagents show as `harness.subagent.*` events. */
|
|
6496
|
+
subagent_events: boolean;
|
|
6497
|
+
}
|
|
6498
|
+
/** The credential profiles the kind takes (`AgentHarnessAuthProfile`). */
|
|
6499
|
+
export interface AgentHarnessKindAuth {
|
|
6500
|
+
/** Each `key` provider the kind takes, with the environment variables a profile of it sets. */
|
|
6501
|
+
key: Record<string, string[]>;
|
|
6502
|
+
/**
|
|
6503
|
+
* The plans a person may sign in to in a `signin` profile; empty when the kind takes none. `anthropic`
|
|
6504
|
+
* also needs `agents.claude_plan_signin`.
|
|
6505
|
+
*/
|
|
6506
|
+
signin: Array<"anthropic" | "openai">;
|
|
6507
|
+
/** A `node` profile (a model the node's infer serves) works with this kind. */
|
|
6508
|
+
node: boolean;
|
|
6509
|
+
/**
|
|
6510
|
+
* The hosts a profile of each provider reaches from the instance at the kind's pinned version, measured on
|
|
6511
|
+
* the pin with the kind's own switches for the CLI's other traffic set (telemetry, update checks, a plugin
|
|
6512
|
+
* sync). The node puts them in the filled `egress` and checks your own `egress` against them
|
|
6513
|
+
* (`AgentHarness`).
|
|
6514
|
+
* - `key`: what a turn on each `auth.key` provider reaches: its model API, and a model catalog the kind
|
|
6515
|
+
* fetches for it. A `*_compatible` provider lists none; its `base_url` host stands for them.
|
|
6516
|
+
* - `signin`: each `auth.signin` provider's login, token and model API hosts.
|
|
6517
|
+
*
|
|
6518
|
+
* Exact hosts or `*.` wildcards. A `{region}` label is filled from the profile's `region`, which a profile
|
|
6519
|
+
* of that provider then needs (`400 invalid_request` without one). A profile whose provider is not listed
|
|
6520
|
+
* here is refused (`422 harness_capability_unsupported`).
|
|
6521
|
+
*/
|
|
6522
|
+
hosts: {
|
|
6523
|
+
key: Record<string, string[]>;
|
|
6524
|
+
signin: Record<string, string[]>;
|
|
6525
|
+
};
|
|
6526
|
+
}
|
|
6527
|
+
/**
|
|
6528
|
+
* An environment variable a harness reads a plan's token from, or that changes where it signs in:
|
|
6529
|
+
* `CLAUDE_CODE_OAUTH_TOKEN` and `CLAUDE_CODE_OAUTH_REFRESH_TOKEN` (Claude Code 2.1.332; `claude auth login`
|
|
6530
|
+
* signs in from the refresh token);
|
|
6531
|
+
* Claude Code 2.1.332's session and bridge tokens (`CLAUDE_CODE_SESSIONS_OAUTH_TOKEN`, `CLAUDE_BRIDGE_OAUTH_TOKEN`,
|
|
6532
|
+
* `CLAUDE_CODE_SESSION_ACCESS_TOKEN`), the forms that read a token from a descriptor or a file, which a value
|
|
6533
|
+
* check cannot see (`CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR`, `CLAUDE_CODE_WEBSOCKET_AUTH_FILE_DESCRIPTOR`,
|
|
6534
|
+
* `CLAUDE_SESSION_INGRESS_TOKEN_FILE`, `CLAUDE_CODE_HOST_CREDS_FILE`), an account credential
|
|
6535
|
+
* (`CLAUDE_TRUSTED_DEVICE_TOKEN`) and the OAuth endpoint overrides (`CLAUDE_CODE_CUSTOM_OAUTH_URL`,
|
|
6536
|
+
* `CLAUDE_LOCAL_OAUTH_API_BASE`, `USE_LOCAL_OAUTH`, `USE_STAGING_OAUTH`), all read from the binary's strings;
|
|
6537
|
+
* `ANTHROPIC_OAUTH_TOKEN` (pi), and `CODEX_ACCESS_TOKEN` (Codex 0.164.0: `codex login --with-access-token`
|
|
6538
|
+
* reads an access token from it; refused until it is checked whether that token is a ChatGPT plan's). An agent
|
|
6539
|
+
* with a `harness` block never takes one of these names in `env` or `secrets`, in an `mcp` server's `env`, or
|
|
6540
|
+
* in a `settings` `env` entry, whatever its `kind`, since the `harness` template holds every harness: `400
|
|
6541
|
+
* invalid_request`. Names alone do not hold the line, because pi sends any Anthropic key whose value holds
|
|
6542
|
+
* `sk-ant-oat` as a plan login: a value holding `sk-ant-oat` or `sk-ant-ort` is `400 harness_plan_credential`
|
|
6543
|
+
* anywhere in the definition and in the resolved value of every connection it names (`AgentHarness`), and the
|
|
6544
|
+
* shim drops every variable whose value holds one from the harness's environment and the terminal's. B3OS
|
|
6545
|
+
* never stores a plan's token.
|
|
6546
|
+
*/
|
|
6547
|
+
export type AgentHarnessPlanEnv = "CLAUDE_CODE_OAUTH_TOKEN" | "CLAUDE_CODE_OAUTH_REFRESH_TOKEN" | "ANTHROPIC_OAUTH_TOKEN" | "CODEX_ACCESS_TOKEN" | "CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR" | "CLAUDE_CODE_SESSIONS_OAUTH_TOKEN" | "CLAUDE_BRIDGE_OAUTH_TOKEN" | "CLAUDE_CODE_SESSION_ACCESS_TOKEN" | "CLAUDE_CODE_WEBSOCKET_AUTH_FILE_DESCRIPTOR" | "CLAUDE_SESSION_INGRESS_TOKEN_FILE" | "CLAUDE_CODE_HOST_CREDS_FILE" | "CLAUDE_TRUSTED_DEVICE_TOKEN" | "CLAUDE_CODE_CUSTOM_OAUTH_URL" | "CLAUDE_LOCAL_OAUTH_API_BASE" | "USE_LOCAL_OAUTH" | "USE_STAGING_OAUTH";
|
|
6548
|
+
/**
|
|
6549
|
+
* The catalog as the shim prints it (`b3os-harness catalog --json`): the kinds in `data`, open-source first,
|
|
6550
|
+
* and `checks`. The node stores it with the `harness` template's build and serves it unchanged.
|
|
6551
|
+
*/
|
|
6552
|
+
export type AgentHarnessKindList = Omit<ListEnvelope, "data"> & {
|
|
6553
|
+
data: AgentHarnessKind[];
|
|
6554
|
+
checks: AgentHarnessCatalogChecks;
|
|
6555
|
+
};
|
|
6556
|
+
/**
|
|
6557
|
+
* What the shim refuses or removes at start beyond each kind's entry, so the node refuses the same at write:
|
|
6558
|
+
* per kind (`kinds`), the rules for profile names, the plan-token names and value, the workspace paths `files`
|
|
6559
|
+
* may not write, the default `mcp` and `skills` entries, each B3OS toolset's scopes and the flag each gated
|
|
6560
|
+
* sign-in needs.
|
|
6561
|
+
*/
|
|
6562
|
+
export interface AgentHarnessCatalogChecks {
|
|
6563
|
+
kinds: Record<string, AgentHarnessKindChecks>;
|
|
6564
|
+
profiles: {
|
|
6565
|
+
/** The most profiles a definition holds. */
|
|
6566
|
+
max: number;
|
|
6567
|
+
/** The pattern a profile's name matches (an ECMAScript regular expression). */
|
|
6568
|
+
name: string;
|
|
6569
|
+
};
|
|
6570
|
+
/** Every kind's plan variables, refused as names on every harness agent. */
|
|
6571
|
+
plan_env: AgentHarnessPlanEnv[];
|
|
6572
|
+
/** The pattern of a plan's token, refused as a value anywhere (an ECMAScript regular expression). */
|
|
6573
|
+
plan_value: string;
|
|
6574
|
+
/** Workspace paths (a file, or a directory ending in `/`) no definition's `files` writes. */
|
|
6575
|
+
files_refused: string[];
|
|
6576
|
+
/**
|
|
6577
|
+
* The entries every definition's `mcp` and `skills` start with. A definition's maps are a JSON merge patch
|
|
6578
|
+
* (RFC 7396) over them (`AgentHarness`); a kind whose `setup` does not list a list gets none.
|
|
6579
|
+
*/
|
|
6580
|
+
defaults: {
|
|
6581
|
+
mcp: Record<string, AgentHarnessMcpBuiltin>;
|
|
6582
|
+
skills: Record<string, AgentHarnessSetupItem>;
|
|
6583
|
+
};
|
|
6584
|
+
/** Each B3OS toolset's scopes; the filled grant is the merged `mcp.b3os` entry's toolsets' scopes. */
|
|
6585
|
+
b3os_toolsets: Record<string, string[]>;
|
|
6586
|
+
/** The flag a sign-in to each listed provider needs; a provider not listed, and every key, needs none. */
|
|
6587
|
+
signin_flags: Record<string, string>;
|
|
6588
|
+
}
|
|
6589
|
+
/** What the shim enforces for one kind beyond its catalog entry. */
|
|
6590
|
+
export interface AgentHarnessKindChecks {
|
|
6591
|
+
/**
|
|
6592
|
+
* Per `key` provider, the variables the node delivers as `B3OS_PROFILE_<NAME>__<VAR>`; the `optional` ones
|
|
6593
|
+
* may be left out (`AWS_SESSION_TOKEN`).
|
|
6594
|
+
*/
|
|
6595
|
+
deliver: Record<string, {
|
|
6596
|
+
env: string[];
|
|
6597
|
+
optional: string[];
|
|
6598
|
+
}>;
|
|
6599
|
+
/** The providers whose profile needs an `https://` `base_url`; any other provider's refuses one. */
|
|
6600
|
+
base_url: AgentHarnessKeyProvider[];
|
|
6601
|
+
/** The providers whose profile takes a `region`. */
|
|
6602
|
+
region: AgentHarnessKeyProvider[];
|
|
6603
|
+
/**
|
|
6604
|
+
* Every variable the shim sets or removes in the kind's processes; a definition's `env` or `secrets` naming one is refused.
|
|
6605
|
+
*/
|
|
6606
|
+
env_owned: string[];
|
|
6607
|
+
/** The CLI's config-directory variable, which the shim sets to each profile's directory. */
|
|
6608
|
+
dir_env: string;
|
|
6609
|
+
/** Lists the kind takes only from a prepared snapshot; refused until prepared snapshots ship. */
|
|
6610
|
+
prepare_only: Array<"skills" | "plugins" | "mcp" | "instructions" | "settings">;
|
|
6611
|
+
/**
|
|
6612
|
+
* For a kind that has one, the only keys its `settings.<kind>` takes, checked on its pinned version; any other
|
|
6613
|
+
* key is refused, as is any in its `settings_refused`. Absent: every key not refused is taken.
|
|
6614
|
+
*/
|
|
6615
|
+
settings_allowed?: string[];
|
|
6616
|
+
/**
|
|
6617
|
+
* When true, a definition with more than one `key` profile gives each one a model on the profile's own
|
|
6618
|
+
* provider (the profile's `model`, else the block's); one that has none is refused at write. The kind runs
|
|
6619
|
+
* every key profile in one process, each on its own model (opencode), so such a profile would run nothing.
|
|
6620
|
+
*/
|
|
6621
|
+
key_profiles_need_model?: boolean;
|
|
6622
|
+
/** The limit and auth signals the driver reads from the CLI. */
|
|
6623
|
+
signals: Record<string, "limit" | "auth">;
|
|
6624
|
+
/** The signals seen live on the kind's pinned version; only these move a profile's `fallback`. */
|
|
6625
|
+
checked: string[];
|
|
6626
|
+
}
|
|
6627
|
+
export interface AgentSteerRequest {
|
|
6628
|
+
/** What the harness reads at its next step. Yours, so never quoted. */
|
|
6629
|
+
text: string;
|
|
6630
|
+
}
|
|
6631
|
+
export interface AgentDecisionRequest {
|
|
6632
|
+
/** The `request` of the `harness.permission.requested` event, unique per instance. */
|
|
6633
|
+
request: string;
|
|
6634
|
+
decision: "allow" | "deny";
|
|
6635
|
+
/** Shown to the harness with the decision. */
|
|
6636
|
+
reason?: string;
|
|
6637
|
+
}
|
|
6638
|
+
export interface AgentDecision {
|
|
6639
|
+
object: "agent_decision";
|
|
6640
|
+
instance_id: string;
|
|
6641
|
+
/**
|
|
6642
|
+
* The session whose turn asked, or `null` for a turn that is not a session (typed in the terminal or
|
|
6643
|
+
* started inside the instance).
|
|
6644
|
+
*/
|
|
6645
|
+
session_id: string | null;
|
|
6646
|
+
request: string;
|
|
6647
|
+
decision: "allow" | "deny";
|
|
6648
|
+
reason: string | null;
|
|
6649
|
+
by: AgentSessionInitiator;
|
|
6650
|
+
decided_at: string;
|
|
6651
|
+
}
|
|
6652
|
+
/**
|
|
6653
|
+
* `watch`: the live view and the terminal, view-only. `control`: also input, when nobody else holds it.
|
|
6654
|
+
*/
|
|
6655
|
+
export type AgentGrantRole = "watch" | "control";
|
|
6656
|
+
export interface AgentGrantCreateRequest {
|
|
6657
|
+
/** @default "watch" */
|
|
6658
|
+
role?: AgentGrantRole;
|
|
6659
|
+
/**
|
|
6660
|
+
* How long the link works. Chosen for the beta.
|
|
6661
|
+
* @default 900
|
|
6662
|
+
*/
|
|
6663
|
+
ttl_s?: number;
|
|
6664
|
+
/**
|
|
6665
|
+
* How many times the link may be redeemed: each page load is one, and so is each reconnect of its terminal
|
|
6666
|
+
* or event stream. Default, any number until it expires.
|
|
6667
|
+
*/
|
|
6668
|
+
uses?: number;
|
|
6669
|
+
}
|
|
6670
|
+
export interface AgentGrant {
|
|
6671
|
+
id: string;
|
|
6672
|
+
object: "agent_grant";
|
|
6673
|
+
agent_id: string;
|
|
6674
|
+
key: AgentInstanceKey;
|
|
6675
|
+
role: AgentGrantRole;
|
|
6676
|
+
/** The grant's secret, in the create answer only (`null` everywhere else). Treat it as a password. */
|
|
6677
|
+
token: string | null;
|
|
6678
|
+
/** The share page with the token in its fragment, in the create answer only. */
|
|
6679
|
+
url: string | null;
|
|
6680
|
+
expires_at: string;
|
|
6681
|
+
uses: number | null;
|
|
6682
|
+
uses_left: number | null;
|
|
6683
|
+
created_by: AgentSessionInitiator;
|
|
6684
|
+
created_at: string;
|
|
6685
|
+
}
|
|
6686
|
+
export type AgentGrantList = Omit<ListEnvelope, "data"> & {
|
|
6687
|
+
data: AgentGrant[];
|
|
6688
|
+
};
|
|
6689
|
+
export interface AgentTerminalRecording {
|
|
6690
|
+
id: string;
|
|
6691
|
+
object: "terminal_recording";
|
|
6692
|
+
/** The harness session whose terminal it recorded. */
|
|
6693
|
+
conversation: string;
|
|
6694
|
+
format: "asciicast-v3";
|
|
6695
|
+
bytes: number;
|
|
6696
|
+
started_at: string;
|
|
6697
|
+
/** The last write; a recording still being written keeps growing. */
|
|
6698
|
+
updated_at: string;
|
|
6699
|
+
}
|
|
6700
|
+
export type AgentTerminalRecordingList = Omit<ListEnvelope, "data"> & {
|
|
6701
|
+
data: AgentTerminalRecording[];
|
|
6702
|
+
};
|
|
6703
|
+
export interface AgentSelfEventsRequest {
|
|
6704
|
+
events: AgentSelfEvent[];
|
|
6705
|
+
}
|
|
6706
|
+
/**
|
|
6707
|
+
* A harness event as the shim records it from inside the instance: an `AgentHarnessEvent` without the members
|
|
6708
|
+
* the node sets (`seq`, `org`, `project`, `instance`, `session_id`, `subject`), which a self event never
|
|
6709
|
+
* carries (`400 invalid_request`): the node assigns the log's `seq` as it writes the event.
|
|
6710
|
+
*/
|
|
6711
|
+
export interface AgentSelfEvent {
|
|
6712
|
+
id: string;
|
|
6713
|
+
type: AgentHarnessEventType;
|
|
6714
|
+
time: string;
|
|
6715
|
+
harness: AgentHarnessKindName;
|
|
6716
|
+
conversation?: string;
|
|
6717
|
+
data: {
|
|
6718
|
+
usage?: AgentHarnessUsage;
|
|
6719
|
+
[key: string]: unknown;
|
|
6720
|
+
};
|
|
6721
|
+
native?: {
|
|
6722
|
+
harness: AgentHarnessKindName;
|
|
6723
|
+
event: string;
|
|
6724
|
+
payload?: unknown;
|
|
6725
|
+
};
|
|
6726
|
+
}
|
|
6727
|
+
/** A question for the definition's `hooks.decide` webhook, from the harness's shim. */
|
|
6728
|
+
export interface AgentSelfDecideRequest {
|
|
6729
|
+
type: "harness.tool.requested" | "harness.permission.requested" | "harness.turn.started";
|
|
6730
|
+
/**
|
|
6731
|
+
* The session the turn was delivered as (the delivery's `session`), when the question belongs to one. The
|
|
6732
|
+
* node keeps it only when it is the session the instance runs now.
|
|
6733
|
+
*/
|
|
6734
|
+
session?: string;
|
|
6735
|
+
conversation?: string;
|
|
6736
|
+
/** `tool`, `input` (the tool's arguments), `summary` and `call_id`; a turn's `prompt`. */
|
|
6737
|
+
data: Record<string, unknown>;
|
|
6738
|
+
}
|
|
6739
|
+
export interface AgentSelfDecision {
|
|
6740
|
+
object: "agent_self_decision";
|
|
6741
|
+
/** `ask` hands the question to a person (`harness.permission.requested`). */
|
|
6742
|
+
decision: "allow" | "deny" | "ask";
|
|
6743
|
+
reason?: string;
|
|
6744
|
+
/** Added to what the model sees next, quoted as information. */
|
|
6745
|
+
context?: string;
|
|
6746
|
+
/**
|
|
6747
|
+
* `true` when the webhook did not answer in time, failed or answered without a `decision`, and `decision` is
|
|
6748
|
+
* the definition's `on_timeout`.
|
|
6749
|
+
*/
|
|
6750
|
+
fallback: boolean;
|
|
6751
|
+
}
|
|
6752
|
+
export interface AgentSelfEventsResult {
|
|
6753
|
+
object: "agent_self_events";
|
|
6754
|
+
accepted: number;
|
|
6755
|
+
/** Events whose `id` the instance had already recorded; not written again. */
|
|
6756
|
+
duplicates: number;
|
|
6757
|
+
}
|
|
6758
|
+
/** Set exactly one of `entry` (your own harness) and `harness` (a coding agent B3OS runs for you). */
|
|
6759
|
+
export type AgentCreateRequest = {
|
|
6760
|
+
name: AgentName;
|
|
6761
|
+
source?: AgentSource;
|
|
6762
|
+
entry?: AgentEntry;
|
|
6763
|
+
harness?: AgentHarness;
|
|
6764
|
+
/** Environment variables of the harness. Returned as given; put credentials in `secrets`. */
|
|
6765
|
+
env?: Record<string, string>;
|
|
6766
|
+
/**
|
|
6767
|
+
* Environment variables never returned or logged, as a sandbox's `secrets`: code in the instance can read
|
|
6768
|
+
* them. A memory snapshot holds them, so the node keeps an instance's snapshots to itself: they are never
|
|
6769
|
+
* listed or restorable through the API.
|
|
6770
|
+
*/
|
|
6771
|
+
secrets?: Record<string, SecretValue>;
|
|
6772
|
+
api?: SandboxApiGrant;
|
|
6773
|
+
egress?: EgressPolicy;
|
|
6774
|
+
sleep?: AgentSleep;
|
|
6775
|
+
turns?: AgentTurns;
|
|
6776
|
+
metadata?: Metadata;
|
|
6777
|
+
};
|
|
6778
|
+
/** `entry` and `harness` never come together, and an agent keeps the one it was made with. */
|
|
6779
|
+
export interface AgentUpdateRequest {
|
|
6780
|
+
source?: AgentSource;
|
|
6781
|
+
entry?: AgentEntry;
|
|
6782
|
+
harness?: AgentHarness;
|
|
6783
|
+
env?: Record<string, string>;
|
|
6784
|
+
secrets?: Record<string, SecretValue>;
|
|
6785
|
+
api?: SandboxApiGrant;
|
|
6786
|
+
egress?: EgressPolicy;
|
|
6787
|
+
sleep?: AgentSleep;
|
|
6788
|
+
turns?: AgentTurns;
|
|
6789
|
+
/**
|
|
6790
|
+
* What happens to instances of earlier revisions: `new_instances` leaves them as they are; `on_wake` makes a
|
|
6791
|
+
* sleeping one again from this revision at its next wake, which ends its memory and disk.
|
|
6792
|
+
* @default "new_instances"
|
|
6793
|
+
*/
|
|
6794
|
+
upgrade?: "new_instances" | "on_wake";
|
|
6795
|
+
metadata?: Metadata;
|
|
6796
|
+
}
|
|
6797
|
+
export interface Agent {
|
|
6798
|
+
id: string;
|
|
6799
|
+
object: "agent";
|
|
6800
|
+
name: AgentName;
|
|
6801
|
+
/** Grows by one with each update. Each instance keeps the revision it was made from. */
|
|
6802
|
+
revision: number;
|
|
6803
|
+
source: AgentSource;
|
|
6804
|
+
entry: AgentEntry;
|
|
6805
|
+
env: Record<string, string>;
|
|
5117
6806
|
secret_names: string[];
|
|
5118
6807
|
api: SandboxApiGrant;
|
|
5119
6808
|
egress: EgressPolicy;
|
|
5120
6809
|
sleep: AgentSleep;
|
|
5121
6810
|
turns: AgentTurns;
|
|
6811
|
+
/**
|
|
6812
|
+
* Only on an agent made with a `harness` block (planned), as the node stored it: defaults filled in,
|
|
6813
|
+
* shorthands expanded, git refs resolved to commits, and `mcp` and `skills` as you wrote them, nulls
|
|
6814
|
+
* included, never merged with their default `b3os` entries (`AgentHarness`), so the block can be sent back
|
|
6815
|
+
* as it is.
|
|
6816
|
+
*/
|
|
6817
|
+
harness?: AgentHarness;
|
|
6818
|
+
/**
|
|
6819
|
+
* The person a personal agent belongs to, or `null`. An agent with a `signin` profile is personal (planned):
|
|
6820
|
+
* its owner is the person who made it, and it never changes. Everything that drives it or reads what its
|
|
6821
|
+
* instances hold is the owner's alone, and so is changing it: messages, steer, cancel, decisions, making,
|
|
6822
|
+
* waking and putting to sleep its instances (an instance may also put itself to sleep from inside), its
|
|
6823
|
+
* sessions (read, listed or streamed: their results and `session.output` carry the turns), and its
|
|
6824
|
+
* instances' stream, terminal, tickets, grants and recordings. Anyone else, an organization admin included,
|
|
6825
|
+
* gets `403 harness_personal_agent`. The owner or an organization admin may delete it or one of its
|
|
6826
|
+
* instances, and list or revoke its grants. Every `agents:read` caller still sees the definition and each
|
|
6827
|
+
* instance's status and lifecycle events (`GET …/instances`, `GET …/instances/{key}/events`), which hold no
|
|
6828
|
+
* turn. Listeners never send it turns, and routines only when the owner made them. The owner shares a view with a `watch` grant;
|
|
6829
|
+
* `control` grants are refused. Forks and children of it run only on `key` and `node` profiles (`409
|
|
6830
|
+
* harness_profile_unavailable`), and nothing it signed in to is carried to another instance. Not served
|
|
6831
|
+
* yet: until the prerequisites `AgentHarnessAuthSignin` names land, the node makes no personal agent, so
|
|
6832
|
+
* `owner` is `null` on every agent.
|
|
6833
|
+
*/
|
|
6834
|
+
owner?: null | AgentOwner;
|
|
6835
|
+
harness_prepared?: AgentHarnessPrepared;
|
|
5122
6836
|
upgrade: "new_instances" | "on_wake";
|
|
5123
6837
|
/** How many instances the agent has, in any state. */
|
|
5124
6838
|
instances: number;
|
|
@@ -5126,6 +6840,33 @@ export interface Agent {
|
|
|
5126
6840
|
updated_at: string;
|
|
5127
6841
|
metadata: Metadata;
|
|
5128
6842
|
}
|
|
6843
|
+
export interface AgentOwner {
|
|
6844
|
+
kind: "user";
|
|
6845
|
+
id: string;
|
|
6846
|
+
}
|
|
6847
|
+
/**
|
|
6848
|
+
* The revision's prepared snapshot (planned): the `harness` template with only this kind's harness at its
|
|
6849
|
+
* `version` and the recipe's fetched items installed, built once per `key` and shared by the project's agents
|
|
6850
|
+
* with the same key. The build runs in a `builder` sandbox with no secrets and no vault access, reaching only
|
|
6851
|
+
* the recipe's source hosts, and fails if any harness credential file exists in it. Messages wait while it
|
|
6852
|
+
* builds, and that time counts toward `turns.timeout_s`; a failed build fails them with
|
|
6853
|
+
* `harness_prepare_failed`. `upgrade: on_wake` moves instances only to a revision whose snapshot is `ready`.
|
|
6854
|
+
* It counts against your snapshot quota.
|
|
6855
|
+
*/
|
|
6856
|
+
export interface AgentHarnessPrepared {
|
|
6857
|
+
/**
|
|
6858
|
+
* The prepare key: the SHA-256 of the template's ID and revision, the shim's version, the `kind`, the
|
|
6859
|
+
* `version` and the resolved sources of the fetched items. A change elsewhere in the block keeps it.
|
|
6860
|
+
*/
|
|
6861
|
+
key: string;
|
|
6862
|
+
/** `none`: nothing is built for this revision yet. */
|
|
6863
|
+
status: "none" | "queued" | "building" | "ready" | "failed";
|
|
6864
|
+
/** The snapshot instances start from, once `ready`; also the filled `source.snapshot`. */
|
|
6865
|
+
snapshot: string | null;
|
|
6866
|
+
built_at: string | null;
|
|
6867
|
+
/** Why the last build failed, naming the step and the item. */
|
|
6868
|
+
error: null | Problem;
|
|
6869
|
+
}
|
|
5129
6870
|
export type AgentList = Omit<ListEnvelope, "data"> & {
|
|
5130
6871
|
data: Agent[];
|
|
5131
6872
|
};
|
|
@@ -5159,7 +6900,10 @@ export interface AgentInstance {
|
|
|
5159
6900
|
key: AgentInstanceKey;
|
|
5160
6901
|
revision: number;
|
|
5161
6902
|
status: AgentInstanceStatus;
|
|
5162
|
-
/**
|
|
6903
|
+
/**
|
|
6904
|
+
* The instance's microVM, the same through every sleep tier; `null` before it was first made. `null` too for
|
|
6905
|
+
* an instance of a personal agent (planned), whose microVM the generic sandboxes API does not reach.
|
|
6906
|
+
*/
|
|
5163
6907
|
sandbox_id: string | null;
|
|
5164
6908
|
/** Host memory the instance holds now (0 when hibernated or dormant). */
|
|
5165
6909
|
resident_mib: number;
|
|
@@ -5200,6 +6944,16 @@ export type AgentInstanceEventList = Omit<ListEnvelope, "data"> & {
|
|
|
5200
6944
|
/**
|
|
5201
6945
|
* Your message. Every member but the reserved ones (`type`, `conversation`, `subject`, `metadata`, `create`,
|
|
5202
6946
|
* `webhook`) is yours, and reaches the harness as `message`, with `type`.
|
|
6947
|
+
*
|
|
6948
|
+
* A message to an agent with a `harness` block (planned) is closed instead. Besides the reserved members it takes
|
|
6949
|
+
* `text` (the prompt, a string of 1 to 262,144 characters, required), `context` (at most 16 `{text, source?}`
|
|
6950
|
+
* objects, each quoted as information), `profile` (one of the definition's credential profiles) and, from a
|
|
6951
|
+
* listener's actor sink (`type: listener.event`), `event`, quoted whole, in place of `text`. Any other member is
|
|
6952
|
+
* `400 invalid_request`, so a field the harness would not read is refused, not dropped. A listener's message
|
|
6953
|
+
* is `422 harness_capability_unsupported` until the harness's shim quotes its `event`.
|
|
6954
|
+
* `source`, `limits` and `parent` are reserved there for the run contract.
|
|
6955
|
+
* These members bind harness agents only: an agent with an `entry` keeps every member but the reserved ones as
|
|
6956
|
+
* its own.
|
|
5203
6957
|
*/
|
|
5204
6958
|
export interface AgentMessageRequest {
|
|
5205
6959
|
/**
|
|
@@ -5249,6 +7003,8 @@ export type AgentSessionList = Omit<ListEnvelope, "data"> & {
|
|
|
5249
7003
|
};
|
|
5250
7004
|
/**
|
|
5251
7005
|
* `session.waking` carries `woke_from`; `session.output` carries `data`, one event the harness streamed, as text.
|
|
7006
|
+
* For an agent with a `harness` block (planned), each `session.output`'s `data` is one `AgentHarnessEvent` as
|
|
7007
|
+
* JSON, as the node wrote it to the instance's event log (its `seq` is the log's, not this stream's).
|
|
5252
7008
|
*/
|
|
5253
7009
|
export type AgentSessionEvent = JobEvent & {
|
|
5254
7010
|
woke_from?: AgentWokeFrom;
|
|
@@ -5283,7 +7039,7 @@ export interface RoutineDefinition {
|
|
|
5283
7039
|
*/
|
|
5284
7040
|
vars?: Record<string, unknown>;
|
|
5285
7041
|
/**
|
|
5286
|
-
* 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').
|
|
7042
|
+
* 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').
|
|
5287
7043
|
*/
|
|
5288
7044
|
triggers?: RoutineDefinitionTrigger[];
|
|
5289
7045
|
defaults?: {
|
|
@@ -5484,15 +7240,19 @@ export type RoutineDefinitionCatchUp = "skip" | "latest" | "all";
|
|
|
5484
7240
|
*/
|
|
5485
7241
|
export type RoutineDefinitionOverlap = "skip" | "buffer_one" | "allow" | "cancel_running";
|
|
5486
7242
|
/**
|
|
5487
|
-
* 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}.
|
|
7243
|
+
* 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}.
|
|
5488
7244
|
*/
|
|
5489
7245
|
export type RoutineDefinitionTrigger = {
|
|
5490
|
-
type: "cron" | "interval" | "webhook" | "action";
|
|
7246
|
+
type: "cron" | "interval" | "webhook" | "action" | "listener";
|
|
5491
7247
|
id: RoutineDefinitionIdent;
|
|
5492
7248
|
/** action only: the pack trigger to subscribe to. */
|
|
5493
7249
|
uses?: RoutineDefinitionTriggerRef;
|
|
5494
7250
|
/**
|
|
5495
|
-
*
|
|
7251
|
+
* listener only: an object declares the routine's own listener (listenerTrigger); a string names a listener that already exists in the project (listenerRef).
|
|
7252
|
+
*/
|
|
7253
|
+
listener?: RoutineDefinitionListenerTrigger | RoutineDefinitionListenerRef;
|
|
7254
|
+
/**
|
|
7255
|
+
* 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.
|
|
5496
7256
|
*/
|
|
5497
7257
|
with?: RoutineDefinitionTemplateObject;
|
|
5498
7258
|
/**
|
|
@@ -5500,7 +7260,7 @@ export type RoutineDefinitionTrigger = {
|
|
|
5500
7260
|
*/
|
|
5501
7261
|
connections?: Record<string, RoutineDefinitionConnectionRef>;
|
|
5502
7262
|
/**
|
|
5503
|
-
* 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.
|
|
7263
|
+
* 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.
|
|
5504
7264
|
*/
|
|
5505
7265
|
if?: RoutineDefinitionCondition;
|
|
5506
7266
|
/**
|
|
@@ -5529,6 +7289,29 @@ export type RoutineDefinitionTrigger = {
|
|
|
5529
7289
|
*/
|
|
5530
7290
|
dedupe?: RoutineDefinitionCelExpression;
|
|
5531
7291
|
};
|
|
7292
|
+
/**
|
|
7293
|
+
* 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).
|
|
7294
|
+
*/
|
|
7295
|
+
export interface RoutineDefinitionListenerTrigger {
|
|
7296
|
+
/** listeners.yaml ListenerSource: push, http_poll, sse, websocket, webhook or pack. */
|
|
7297
|
+
source: {
|
|
7298
|
+
type: "push" | "http_poll" | "sse" | "websocket" | "webhook" | "pack";
|
|
7299
|
+
};
|
|
7300
|
+
/** listeners.yaml ListenerDedupe. */
|
|
7301
|
+
dedupe?: Record<string, unknown>;
|
|
7302
|
+
/**
|
|
7303
|
+
* listeners.yaml ListenerFilter: a CEL filter over the event, or a model filter, applied before the event is kept.
|
|
7304
|
+
*/
|
|
7305
|
+
filter?: Record<string, unknown>;
|
|
7306
|
+
/** listeners.yaml ListenerRedact: JSON pointers removed from each payload before it is kept. */
|
|
7307
|
+
redact?: string[];
|
|
7308
|
+
/** listeners.yaml ListenerBudgetRequest. */
|
|
7309
|
+
budget?: Record<string, unknown>;
|
|
7310
|
+
}
|
|
7311
|
+
/**
|
|
7312
|
+
* 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.
|
|
7313
|
+
*/
|
|
7314
|
+
export type RoutineDefinitionListenerRef = string;
|
|
5532
7315
|
/**
|
|
5533
7316
|
* 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.
|
|
5534
7317
|
*/
|
|
@@ -5577,7 +7360,7 @@ export interface RoutineHook {
|
|
|
5577
7360
|
export interface RoutineTrigger {
|
|
5578
7361
|
/** The trigger's `id` in the definition. */
|
|
5579
7362
|
id: string;
|
|
5580
|
-
type: "cron" | "interval" | "webhook" | "action";
|
|
7363
|
+
type: "cron" | "interval" | "webhook" | "action" | "listener";
|
|
5581
7364
|
status: "active" | "paused";
|
|
5582
7365
|
/** Next scheduled fire (cron and interval), or `null`. */
|
|
5583
7366
|
next_fire_at: string | null;
|
|
@@ -5587,6 +7370,10 @@ export interface RoutineTrigger {
|
|
|
5587
7370
|
* The trigger subscription of an action trigger (`GET /v1/actions/subscriptions/{subscription_id}`), or `null`.
|
|
5588
7371
|
*/
|
|
5589
7372
|
subscription_id: string | null;
|
|
7373
|
+
/**
|
|
7374
|
+
* 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`).
|
|
7375
|
+
*/
|
|
7376
|
+
listener_id: string | null;
|
|
5590
7377
|
}
|
|
5591
7378
|
export interface Routine {
|
|
5592
7379
|
id: string;
|
|
@@ -5610,7 +7397,7 @@ export interface Routine {
|
|
|
5610
7397
|
updated_at: string;
|
|
5611
7398
|
metadata: Metadata;
|
|
5612
7399
|
/**
|
|
5613
|
-
* 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.
|
|
7400
|
+
* 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.
|
|
5614
7401
|
*/
|
|
5615
7402
|
warnings?: Diagnostic[];
|
|
5616
7403
|
}
|
|
@@ -5714,9 +7501,13 @@ export interface HookSecret {
|
|
|
5714
7501
|
}
|
|
5715
7502
|
/** How the run started (the `trigger` context of its expressions). */
|
|
5716
7503
|
export interface RunTrigger {
|
|
5717
|
-
type: "api" | "cron" | "interval" | "webhook" | "action" | "routine" | "replay";
|
|
5718
|
-
/**
|
|
7504
|
+
type: "api" | "cron" | "interval" | "webhook" | "action" | "listener" | "routine" | "replay";
|
|
7505
|
+
/**
|
|
7506
|
+
* The trigger ID (cron, interval, webhook, action, and listener triggers), or the listener (`lsn_`) of a listener whose sink names the routine.
|
|
7507
|
+
*/
|
|
5719
7508
|
id?: string;
|
|
7509
|
+
/** The listener that delivered the event (listener triggers). */
|
|
7510
|
+
listener_id?: string;
|
|
5720
7511
|
/** Cron and interval occurrence, used to deduplicate fires. */
|
|
5721
7512
|
occurrence_id?: string;
|
|
5722
7513
|
scheduled_at?: string;
|
|
@@ -5724,8 +7515,12 @@ export interface RunTrigger {
|
|
|
5724
7515
|
delivery_id?: string;
|
|
5725
7516
|
/** The trigger subscription that delivered the event (action triggers). */
|
|
5726
7517
|
subscription_id?: string;
|
|
5727
|
-
/** The pack trigger event's ID (action triggers). */
|
|
7518
|
+
/** The pack trigger event's ID (action triggers), or the listener event's (`evt_`, listeners). */
|
|
5728
7519
|
event_id?: string;
|
|
7520
|
+
/**
|
|
7521
|
+
* 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.
|
|
7522
|
+
*/
|
|
7523
|
+
trace_id?: string;
|
|
5729
7524
|
/** For sub-routine runs, the calling run; for replays, the source run. */
|
|
5730
7525
|
parent_run_id?: string;
|
|
5731
7526
|
parent_step_id?: string;
|
|
@@ -6136,8 +7931,8 @@ export interface RoutineSink {
|
|
|
6136
7931
|
routine: string;
|
|
6137
7932
|
/**
|
|
6138
7933
|
* `run` starts a run of the routine's active version per event, with `trigger = {type: listener, id,
|
|
6139
|
-
* event_id, seq, dedupe_key, received_at, payload}`; a redelivery of the same `dedupe_key`
|
|
6140
|
-
* second run. `event` sends the event to the routine's runs waiting with `wait: {event: <event>}`
|
|
7934
|
+
* event_id, seq, dedupe_key, received_at, payload, trace_id}`; a redelivery of the same `dedupe_key`
|
|
7935
|
+
* starts no second run. `event` sends the event to the routine's runs waiting with `wait: {event: <event>}`
|
|
6141
7936
|
* (`routinesSendEvent`), with `data` = the payload.
|
|
6142
7937
|
* @default "run"
|
|
6143
7938
|
*/
|
|
@@ -6155,6 +7950,25 @@ export interface RoutineSink {
|
|
|
6155
7950
|
*/
|
|
6156
7951
|
retry_for_s?: number;
|
|
6157
7952
|
batch?: ListenerBatch;
|
|
7953
|
+
/**
|
|
7954
|
+
* Set by routines on the listener of a routine's `type: listener` trigger: that trigger's ID. Routines
|
|
7955
|
+
* creates the listener when it publishes the version, as the publishing key, and removes it when a version
|
|
7956
|
+
* without the trigger is published or the routine is deleted. Each event starts a run with the trigger's
|
|
7957
|
+
* `if` and `with`, and `trigger = {type: listener, id: <trigger id>, listener_id, ...}`. Such a listener is
|
|
7958
|
+
* read-only here: PATCH and DELETE answer `409 listener_managed`. A request cannot set it. With `bound`,
|
|
7959
|
+
* the trigger names this listener instead (preview, `routines.named_listeners`): the listener is yours, and
|
|
7960
|
+
* only its sink is held.
|
|
7961
|
+
*/
|
|
7962
|
+
trigger?: string;
|
|
7963
|
+
/**
|
|
7964
|
+
* True while a routine's `type: listener` trigger names this listener (by id or name) and its active
|
|
7965
|
+
* version is published: routines set `routine` and `trigger` when it bound the listener, keeping
|
|
7966
|
+
* `concurrency`, `retry_for_s` and `batch`. Every field but `sink` can still change; a PATCH of `sink`
|
|
7967
|
+
* answers `409 listener_bound`. A version without the trigger, or deleting the routine, clears it and
|
|
7968
|
+
* pauses the listener (`status_reason: routine_unbound`). While the routine is paused, deliveries are
|
|
7969
|
+
* retried until `retry_for_s`, then fail `routine_paused`. A request cannot set it.
|
|
7970
|
+
*/
|
|
7971
|
+
bound?: boolean;
|
|
6158
7972
|
}
|
|
6159
7973
|
export interface WebhookSink {
|
|
6160
7974
|
type: "webhook";
|
|
@@ -6228,7 +8042,7 @@ export interface Listener {
|
|
|
6228
8042
|
object: "listener";
|
|
6229
8043
|
name: string | null;
|
|
6230
8044
|
status: ListenerStatus;
|
|
6231
|
-
status_reason: "user" | "budget" | "auth" | "egress_denied" | "source_errors" | "owner_revoked" | "sandbox_ended" | null;
|
|
8045
|
+
status_reason: "user" | "budget" | "auth" | "egress_denied" | "source_errors" | "owner_revoked" | "sandbox_ended" | "routine_unbound" | null;
|
|
6232
8046
|
/** Why the source last failed, or why the listener ended `failed`. */
|
|
6233
8047
|
error: {
|
|
6234
8048
|
code: string;
|
|
@@ -6272,6 +8086,10 @@ export interface Listener {
|
|
|
6272
8086
|
failed: number;
|
|
6273
8087
|
skipped: number;
|
|
6274
8088
|
reconnects: number;
|
|
8089
|
+
/**
|
|
8090
|
+
* 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`.
|
|
8091
|
+
*/
|
|
8092
|
+
retries?: number;
|
|
6275
8093
|
last_event_at: string | null;
|
|
6276
8094
|
};
|
|
6277
8095
|
created_at: string;
|
|
@@ -6396,6 +8214,198 @@ export interface ListenerTestResult {
|
|
|
6396
8214
|
/** With `deliver: true` and a kept event, the event as written to the log. */
|
|
6397
8215
|
event: ListenerEvent | null;
|
|
6398
8216
|
}
|
|
8217
|
+
/**
|
|
8218
|
+
* One path rule. `path` is gitignore-style (`*` within a name, `**` across directories) and may use `{human}`,
|
|
8219
|
+
* `{initiator}` and `{agent}`, which bind to that principal's ID. `read` and `write` list selectors:
|
|
8220
|
+
* `agent:<id or name>`, `user:usr_…`, `role:owner|admin|member`, `subject:<id>`, `key:key_…`, `routine:rtn_…`,
|
|
8221
|
+
* `listener:lsn_…`, the bare roles `agent`, `human` and `initiator`, and `project`. A null list leaves that side
|
|
8222
|
+
* to the rules before it.
|
|
8223
|
+
*/
|
|
8224
|
+
export interface WorkspaceRule {
|
|
8225
|
+
path: string;
|
|
8226
|
+
read?: string[] | null;
|
|
8227
|
+
write?: string[] | null;
|
|
8228
|
+
/**
|
|
8229
|
+
* A commit may only add bytes at the end of a matching file.
|
|
8230
|
+
* @default false
|
|
8231
|
+
*/
|
|
8232
|
+
append_only?: boolean;
|
|
8233
|
+
}
|
|
8234
|
+
export interface WorkspaceCreateRequest {
|
|
8235
|
+
/** Unique in the project. */
|
|
8236
|
+
name: string;
|
|
8237
|
+
rules?: WorkspaceRule[];
|
|
8238
|
+
metadata?: Metadata;
|
|
8239
|
+
}
|
|
8240
|
+
export interface WorkspaceRulesRequest {
|
|
8241
|
+
rules: WorkspaceRule[];
|
|
8242
|
+
}
|
|
8243
|
+
export interface Workspace {
|
|
8244
|
+
id: string;
|
|
8245
|
+
object: "workspace";
|
|
8246
|
+
name: string;
|
|
8247
|
+
status: "active" | "deleted";
|
|
8248
|
+
default_branch: string;
|
|
8249
|
+
/** The head commit of the default branch; null before the first commit. */
|
|
8250
|
+
head: string | null;
|
|
8251
|
+
rules: WorkspaceRule[];
|
|
8252
|
+
usage: {
|
|
8253
|
+
/** Unique content bytes stored, the unit of `workspaces.storage_gib_h`. */
|
|
8254
|
+
bytes: number;
|
|
8255
|
+
/** Files at the head of the default branch. */
|
|
8256
|
+
files: number;
|
|
8257
|
+
commits: number;
|
|
8258
|
+
open_branches: number;
|
|
8259
|
+
};
|
|
8260
|
+
created_at: string;
|
|
8261
|
+
updated_at: string;
|
|
8262
|
+
metadata: Metadata;
|
|
8263
|
+
}
|
|
8264
|
+
export type WorkspaceList = Omit<ListEnvelope, "data"> & {
|
|
8265
|
+
data: Workspace[];
|
|
8266
|
+
};
|
|
8267
|
+
export type BranchStatus = "open" | "merged" | "closed" | "expired";
|
|
8268
|
+
export interface BranchCreateRequest {
|
|
8269
|
+
/**
|
|
8270
|
+
* A branch name or ID, or a commit ID, to start from.
|
|
8271
|
+
* @default "main"
|
|
8272
|
+
*/
|
|
8273
|
+
from?: string;
|
|
8274
|
+
/** Unique among the workspace's open branches. Without one the branch is ephemeral. */
|
|
8275
|
+
name?: string;
|
|
8276
|
+
/** An ephemeral branch's lifetime; 604,800 (7 days) by default. */
|
|
8277
|
+
ttl_s?: number;
|
|
8278
|
+
metadata?: Metadata;
|
|
8279
|
+
}
|
|
8280
|
+
export type PrincipalRef = {
|
|
8281
|
+
kind: "agent" | "routine" | "key" | "user" | "subject" | "sandbox" | "instance" | "routine_run" | "listener";
|
|
8282
|
+
id: string;
|
|
8283
|
+
} | null;
|
|
8284
|
+
export interface Branch {
|
|
8285
|
+
id: string;
|
|
8286
|
+
object: "branch";
|
|
8287
|
+
workspace: string;
|
|
8288
|
+
name: string;
|
|
8289
|
+
kind: "named" | "ephemeral";
|
|
8290
|
+
/** Merging into it needs `workspaces:write` (`main` is protected). */
|
|
8291
|
+
protected: boolean;
|
|
8292
|
+
status: BranchStatus;
|
|
8293
|
+
/** The commit the branch started from; null for a branch of an empty workspace. */
|
|
8294
|
+
base: string | null;
|
|
8295
|
+
head: string | null;
|
|
8296
|
+
holder: PrincipalRef;
|
|
8297
|
+
expires_at: string | null;
|
|
8298
|
+
created_at: string;
|
|
8299
|
+
metadata: Metadata;
|
|
8300
|
+
}
|
|
8301
|
+
export type BranchList = Omit<ListEnvelope, "data"> & {
|
|
8302
|
+
data: Branch[];
|
|
8303
|
+
};
|
|
8304
|
+
/** One file to write (`content` as UTF-8 text or `content_base64` as bytes) or to delete. */
|
|
8305
|
+
export interface CommitFile {
|
|
8306
|
+
/** Absolute in the workspace (`/notes/today.md`); no `..`, no empty segment. */
|
|
8307
|
+
path: string;
|
|
8308
|
+
content?: string;
|
|
8309
|
+
content_base64?: string;
|
|
8310
|
+
/**
|
|
8311
|
+
* A regular file, an executable, or a symlink whose content is its target.
|
|
8312
|
+
* @default "100644"
|
|
8313
|
+
*/
|
|
8314
|
+
mode?: "100644" | "100755" | "120000";
|
|
8315
|
+
delete?: boolean;
|
|
8316
|
+
}
|
|
8317
|
+
export interface CommitRequest {
|
|
8318
|
+
message: string;
|
|
8319
|
+
/**
|
|
8320
|
+
* The files to write or delete. Required, except from inside the sandbox that holds the branch (its
|
|
8321
|
+
* `workspaces` member on create): there, without `files`, the commit is what the sandbox changed under the
|
|
8322
|
+
* branch's path.
|
|
8323
|
+
*/
|
|
8324
|
+
files?: CommitFile[];
|
|
8325
|
+
/**
|
|
8326
|
+
* The end user this call works for: the `human` principal the workspace's rules check. Only a credential holding
|
|
8327
|
+
* `workspaces:subjects:assert` may name one (`403 forbidden`, reason `scope`), never a sandbox's own credential
|
|
8328
|
+
* (reason `sandbox`). 1 to 200 letters, digits or `._:@-`.
|
|
8329
|
+
*/
|
|
8330
|
+
subject?: string;
|
|
8331
|
+
if_head?: string;
|
|
8332
|
+
}
|
|
8333
|
+
export interface Commit {
|
|
8334
|
+
id: string;
|
|
8335
|
+
object: "commit";
|
|
8336
|
+
workspace: string;
|
|
8337
|
+
/** The branch it was made on. */
|
|
8338
|
+
branch: string;
|
|
8339
|
+
parents: string[];
|
|
8340
|
+
/** The git tree ID of its content. */
|
|
8341
|
+
tree: string;
|
|
8342
|
+
/** Its git commit ID, the same after a push to a git remote. */
|
|
8343
|
+
git_sha: string;
|
|
8344
|
+
message: string;
|
|
8345
|
+
principals: {
|
|
8346
|
+
agent: PrincipalRef;
|
|
8347
|
+
human: PrincipalRef;
|
|
8348
|
+
initiator: PrincipalRef;
|
|
8349
|
+
};
|
|
8350
|
+
stats: {
|
|
8351
|
+
files_changed: number;
|
|
8352
|
+
/** New content bytes the commit stored. */
|
|
8353
|
+
bytes: number;
|
|
8354
|
+
};
|
|
8355
|
+
created_at: string;
|
|
8356
|
+
}
|
|
8357
|
+
export type CommitList = Omit<ListEnvelope, "data"> & {
|
|
8358
|
+
data: Commit[];
|
|
8359
|
+
};
|
|
8360
|
+
export interface MergeRequest {
|
|
8361
|
+
/**
|
|
8362
|
+
* The end user this call works for: the `human` principal the workspace's rules check. Only a credential holding
|
|
8363
|
+
* `workspaces:subjects:assert` may name one (`403 forbidden`, reason `scope`), never a sandbox's own credential
|
|
8364
|
+
* (reason `sandbox`). 1 to 200 letters, digits or `._:@-`.
|
|
8365
|
+
*/
|
|
8366
|
+
subject?: string;
|
|
8367
|
+
/**
|
|
8368
|
+
* The target branch, by name or ID.
|
|
8369
|
+
* @default "main"
|
|
8370
|
+
*/
|
|
8371
|
+
into?: string;
|
|
8372
|
+
/** @default "three_way" */
|
|
8373
|
+
mode?: "three_way" | "paths";
|
|
8374
|
+
/** Merge only while the target's head is this commit. */
|
|
8375
|
+
if_head?: string;
|
|
8376
|
+
message?: string;
|
|
8377
|
+
}
|
|
8378
|
+
export interface MergeResult {
|
|
8379
|
+
object: "workspace_merge";
|
|
8380
|
+
into: string;
|
|
8381
|
+
/** The target had not moved since the branch's base, so its head became the branch's head. */
|
|
8382
|
+
fast_forward: boolean;
|
|
8383
|
+
commit: Commit;
|
|
8384
|
+
}
|
|
8385
|
+
export interface WorkspaceDiff {
|
|
8386
|
+
object: "workspace_diff";
|
|
8387
|
+
base: string;
|
|
8388
|
+
head: string;
|
|
8389
|
+
changes: {
|
|
8390
|
+
path: string;
|
|
8391
|
+
kind: "added" | "modified" | "deleted" | "type_changed";
|
|
8392
|
+
old_size: number | null;
|
|
8393
|
+
new_size: number | null;
|
|
8394
|
+
}[];
|
|
8395
|
+
/** More than 10,000 changes; narrow it with `path`. */
|
|
8396
|
+
truncated: boolean;
|
|
8397
|
+
}
|
|
8398
|
+
export interface WorkspaceEntry {
|
|
8399
|
+
path: string;
|
|
8400
|
+
type: "file" | "dir" | "symlink";
|
|
8401
|
+
size: number | null;
|
|
8402
|
+
mode: string;
|
|
8403
|
+
/** The git blob ID; null for a directory. */
|
|
8404
|
+
blob: string | null;
|
|
8405
|
+
}
|
|
8406
|
+
export type WorkspaceEntryList = Omit<ListEnvelope, "data"> & {
|
|
8407
|
+
data: WorkspaceEntry[];
|
|
8408
|
+
};
|
|
6399
8409
|
/**
|
|
6400
8410
|
* One JSON-RPC 2.0 message of the Model Context Protocol (https://modelcontextprotocol.io): a request
|
|
6401
8411
|
* (`method` and `id`), a notification (`method`, no `id`) or a response (`result` or `error`). Methods served:
|
|
@@ -6633,7 +8643,7 @@ export interface B3PackHttpResponse {
|
|
|
6633
8643
|
}[];
|
|
6634
8644
|
}
|
|
6635
8645
|
/**
|
|
6636
|
-
* 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').
|
|
8646
|
+
* 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).
|
|
6637
8647
|
*/
|
|
6638
8648
|
export type B3PackImpl = {
|
|
6639
8649
|
kind: "http";
|
|
@@ -6657,9 +8667,19 @@ export type B3PackImpl = {
|
|
|
6657
8667
|
*/
|
|
6658
8668
|
protocol: "json-stdio";
|
|
6659
8669
|
/**
|
|
6660
|
-
* 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
|
|
8670
|
+
* 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).
|
|
6661
8671
|
*/
|
|
6662
8672
|
cmd: string[];
|
|
8673
|
+
} | {
|
|
8674
|
+
kind: "vm";
|
|
8675
|
+
/**
|
|
8676
|
+
* 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').
|
|
8677
|
+
*/
|
|
8678
|
+
protocol: "argv";
|
|
8679
|
+
/**
|
|
8680
|
+
* 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).
|
|
8681
|
+
*/
|
|
8682
|
+
argv: string[];
|
|
6663
8683
|
};
|
|
6664
8684
|
export type B3PackExample = {
|
|
6665
8685
|
fixture: B3PackFixturePath;
|
|
@@ -6882,21 +8902,23 @@ export type B3PackTrigger = {
|
|
|
6882
8902
|
aliases?: B3PackSearchPhrases;
|
|
6883
8903
|
};
|
|
6884
8904
|
/**
|
|
6885
|
-
* 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,
|
|
8905
|
+
* 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).
|
|
6886
8906
|
*/
|
|
6887
8907
|
export interface B3PackTool {
|
|
6888
8908
|
/**
|
|
6889
8909
|
* 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.
|
|
6890
8910
|
*/
|
|
6891
8911
|
kind: "cli" | "mcp";
|
|
6892
|
-
/**
|
|
6893
|
-
|
|
8912
|
+
/**
|
|
8913
|
+
* The shared template the tool runs on, with its archive (tool.bundle). Bases have no versions yet. Absent when tool.image names an image.
|
|
8914
|
+
*/
|
|
8915
|
+
base?: {
|
|
6894
8916
|
name: "base" | "files" | "browser" | "code-interpreter";
|
|
6895
8917
|
/** Reserved: not read, because bases have no versions yet. Refused in this version. */
|
|
6896
8918
|
range?: string;
|
|
6897
8919
|
};
|
|
6898
8920
|
/**
|
|
6899
|
-
* The tool VM's size, one of the base's size classes. Absent: 1 vCPU and 512 MiB, the only size of this version.
|
|
8921
|
+
* 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).
|
|
6900
8922
|
*/
|
|
6901
8923
|
size?: {
|
|
6902
8924
|
vcpu: number;
|
|
@@ -6955,8 +8977,21 @@ export interface B3PackTool {
|
|
|
6955
8977
|
* Reserved: a command run once when the node prepares the tool's snapshot (later). Refused in this version.
|
|
6956
8978
|
*/
|
|
6957
8979
|
setup?: unknown;
|
|
6958
|
-
/**
|
|
6959
|
-
|
|
8980
|
+
/**
|
|
8981
|
+
* 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).
|
|
8982
|
+
*/
|
|
8983
|
+
image?: {
|
|
8984
|
+
/**
|
|
8985
|
+
* 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.
|
|
8986
|
+
*/
|
|
8987
|
+
ref?: string;
|
|
8988
|
+
/**
|
|
8989
|
+
* Reserved: an image built from a Dockerfile and a context the registry stores (later). Refused in this version.
|
|
8990
|
+
*/
|
|
8991
|
+
build?: unknown;
|
|
8992
|
+
/** Reserved: a vault connection for a private registry (later). Refused in this version. */
|
|
8993
|
+
auth?: unknown;
|
|
8994
|
+
};
|
|
6960
8995
|
/** Reserved: output formats a takedown can turn off by name (later). Refused in this version. */
|
|
6961
8996
|
formats?: unknown;
|
|
6962
8997
|
/**
|
|
@@ -7250,8 +9285,14 @@ export interface ToolAllIn {
|
|
|
7250
9285
|
*/
|
|
7251
9286
|
export interface ActionTool {
|
|
7252
9287
|
kind: "cli";
|
|
7253
|
-
/** The template its VM is made from. */
|
|
9288
|
+
/** The template its VM is made from; empty for a tool built from an image (`image`). */
|
|
7254
9289
|
base: string;
|
|
9290
|
+
/**
|
|
9291
|
+
* A tool built from an image (slice C, behind the preview flag `actions.tools_image`): the image, pinned by
|
|
9292
|
+
* digest (`tool.image.ref`). Each node imports it at the version's first call, and each call restores a fresh
|
|
9293
|
+
* VM from its template with no network. Absent for a tool on a base.
|
|
9294
|
+
*/
|
|
9295
|
+
image?: string;
|
|
7255
9296
|
network: "none";
|
|
7256
9297
|
price: ToolPrice;
|
|
7257
9298
|
/** `execution.maxInputMb`: the most input file data one call may carry, in MiB. */
|
|
@@ -7269,7 +9310,8 @@ export interface ActionTool {
|
|
|
7269
9310
|
/**
|
|
7270
9311
|
* The node's estimate of the time from claim to the tool's command starting, in milliseconds, for this
|
|
7271
9312
|
* version's archive: a warm-pool claim plus the copy and the unpack for its size and format, from the
|
|
7272
|
-
* table measured on 2026-11-13 (warm pool, 1 vCPU and 512 MiB).
|
|
9313
|
+
* table measured on 2026-11-13 (warm pool, 1 vCPU and 512 MiB). For a tool built from an image, the
|
|
9314
|
+
* warm-pool claim alone: nothing is copied or unpacked.
|
|
7273
9315
|
*/
|
|
7274
9316
|
start_estimate_ms: number;
|
|
7275
9317
|
/** What one call costs all in, or `null` before this version's first call on this node. */
|
|
@@ -8319,6 +10361,10 @@ export interface ApiKeyCreateRequest {
|
|
|
8319
10361
|
/** Defaults to the caller's project. */
|
|
8320
10362
|
project_id?: string;
|
|
8321
10363
|
spend_cap_usd?: number | null;
|
|
10364
|
+
/**
|
|
10365
|
+
* When the key stops working. Left out: 90 days from now for a key made with a CLI token, never for one made
|
|
10366
|
+
* with a dashboard session or an API key that does not expire; an API key that expires must set it.
|
|
10367
|
+
*/
|
|
8322
10368
|
expires_at?: string | null;
|
|
8323
10369
|
metadata?: Metadata;
|
|
8324
10370
|
}
|
|
@@ -8600,8 +10646,10 @@ export interface ToolBlock {
|
|
|
8600
10646
|
export type ToolBlockList = Omit<ListEnvelope, "data"> & {
|
|
8601
10647
|
data: ToolBlock[];
|
|
8602
10648
|
};
|
|
8603
|
-
/**
|
|
8604
|
-
|
|
10649
|
+
/**
|
|
10650
|
+
* 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.
|
|
10651
|
+
*/
|
|
10652
|
+
export type SettingValue = string | number | boolean | Record<string, unknown> | null;
|
|
8605
10653
|
export interface SettingRequest {
|
|
8606
10654
|
value: SettingValue;
|
|
8607
10655
|
}
|
|
@@ -8716,6 +10764,14 @@ export interface RequestRecord {
|
|
|
8716
10764
|
phases: RequestPhase[];
|
|
8717
10765
|
/** The W3C trace ID from `traceparent`, when sent. */
|
|
8718
10766
|
trace_id: string | null;
|
|
10767
|
+
/**
|
|
10768
|
+
* The span id the node gave this request (with `traceparent` sent): the parent id in the `traceparent` its
|
|
10769
|
+
* handler passes on, so a request it made (an MCP product tool's) names it in `parent_span_id`. Absent from
|
|
10770
|
+
* records written before node release 1127 and from requests the edge answered itself.
|
|
10771
|
+
*/
|
|
10772
|
+
span_id?: string | null;
|
|
10773
|
+
/** The span id in the `traceparent` the request arrived with (its caller's span), when sent. */
|
|
10774
|
+
parent_span_id?: string | null;
|
|
8719
10775
|
user_agent: string | null;
|
|
8720
10776
|
source: RequestSource;
|
|
8721
10777
|
action?: RequestAction;
|
|
@@ -9019,6 +11075,16 @@ export interface VisionListCrawlPagesParams {
|
|
|
9019
11075
|
/** Only pages that succeeded, or only pages that failed. */
|
|
9020
11076
|
status?: "succeeded" | "failed";
|
|
9021
11077
|
}
|
|
11078
|
+
/** Parameters of `listIdentities`. */
|
|
11079
|
+
export interface VisionListIdentitiesParams {
|
|
11080
|
+
/**
|
|
11081
|
+
* Page size, from 1 to 100.
|
|
11082
|
+
* @default 20
|
|
11083
|
+
*/
|
|
11084
|
+
limit?: number;
|
|
11085
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
11086
|
+
cursor?: string;
|
|
11087
|
+
}
|
|
9022
11088
|
/** Parameters of `listProfiles`. */
|
|
9023
11089
|
export interface VisionListProfilesParams {
|
|
9024
11090
|
/**
|
|
@@ -9180,6 +11246,18 @@ export interface SandboxesListSandboxesParams {
|
|
|
9180
11246
|
*/
|
|
9181
11247
|
metadata?: Record<string, string>;
|
|
9182
11248
|
}
|
|
11249
|
+
/** Parameters of `getCapacity`. */
|
|
11250
|
+
export interface SandboxesGetCapacityParams {
|
|
11251
|
+
/**
|
|
11252
|
+
* Template name or `tpl_` ID.
|
|
11253
|
+
* @default "desktop"
|
|
11254
|
+
*/
|
|
11255
|
+
template?: string;
|
|
11256
|
+
/** vCPUs of each sandbox; the template's default when left out. */
|
|
11257
|
+
vcpu?: number;
|
|
11258
|
+
/** Memory of each sandbox, MiB; the template's default when left out. */
|
|
11259
|
+
memory_mib?: number;
|
|
11260
|
+
}
|
|
9183
11261
|
/** Parameters of `listSnapshots`. */
|
|
9184
11262
|
export interface SandboxesListSnapshotsParams {
|
|
9185
11263
|
/**
|
|
@@ -9238,6 +11316,16 @@ export interface SandboxesListVolumesParams {
|
|
|
9238
11316
|
/** Only volumes in this status. */
|
|
9239
11317
|
status?: "available" | "attached" | "deleted";
|
|
9240
11318
|
}
|
|
11319
|
+
/** Parameters of `computerScreenshot`. */
|
|
11320
|
+
export interface SandboxesComputerScreenshotParams {
|
|
11321
|
+
/** `png` or `jpeg`. Without it: the image type `Accept` names, else `jpeg`. */
|
|
11322
|
+
format?: "png" | "jpeg";
|
|
11323
|
+
/**
|
|
11324
|
+
* JPEG quality, 1 to 100.
|
|
11325
|
+
* @default 80
|
|
11326
|
+
*/
|
|
11327
|
+
quality?: number;
|
|
11328
|
+
}
|
|
9241
11329
|
/** Parameters of `deleteFile`. */
|
|
9242
11330
|
export interface SandboxesDeleteFileParams {
|
|
9243
11331
|
/** Absolute path inside the sandbox. */
|
|
@@ -9332,6 +11420,19 @@ export interface ImagesGetImageParams {
|
|
|
9332
11420
|
*/
|
|
9333
11421
|
wait?: number;
|
|
9334
11422
|
}
|
|
11423
|
+
/** Parameters of `getImageLogs`. */
|
|
11424
|
+
export interface ImagesGetImageLogsParams {
|
|
11425
|
+
/**
|
|
11426
|
+
* The first line to answer (0 is the first).
|
|
11427
|
+
* @default 0
|
|
11428
|
+
*/
|
|
11429
|
+
offset?: number;
|
|
11430
|
+
/**
|
|
11431
|
+
* Hold the answer up to this many seconds until there are lines past `offset` or the image settles.
|
|
11432
|
+
* @default 0
|
|
11433
|
+
*/
|
|
11434
|
+
wait?: number;
|
|
11435
|
+
}
|
|
9335
11436
|
/** Parameters of `listAgents`. */
|
|
9336
11437
|
export interface AgentsListAgentsParams {
|
|
9337
11438
|
/**
|
|
@@ -9364,6 +11465,50 @@ export interface AgentsListInstanceEventsParams {
|
|
|
9364
11465
|
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
9365
11466
|
cursor?: string;
|
|
9366
11467
|
}
|
|
11468
|
+
/** Parameters of `listGrants`. */
|
|
11469
|
+
export interface AgentsListGrantsParams {
|
|
11470
|
+
/**
|
|
11471
|
+
* Page size, from 1 to 100.
|
|
11472
|
+
* @default 20
|
|
11473
|
+
*/
|
|
11474
|
+
limit?: number;
|
|
11475
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
11476
|
+
cursor?: string;
|
|
11477
|
+
}
|
|
11478
|
+
/** Parameters of `openTerminal`. */
|
|
11479
|
+
export interface AgentsOpenTerminalParams {
|
|
11480
|
+
/**
|
|
11481
|
+
* `view` (the default) or `control`, which also needs `agents:run`.
|
|
11482
|
+
* @default "view"
|
|
11483
|
+
*/
|
|
11484
|
+
role?: "view" | "control";
|
|
11485
|
+
/** The byte offset to resume from, with `session`. Without it the socket starts at the current screen. */
|
|
11486
|
+
cursor?: number;
|
|
11487
|
+
/** The terminal (`pts_…`) the `cursor` belongs to, from the session frame of the socket you resume. */
|
|
11488
|
+
session?: string;
|
|
11489
|
+
/** Which harness session's terminal, when the instance has more than one. Default `default`. */
|
|
11490
|
+
conversation?: string;
|
|
11491
|
+
/**
|
|
11492
|
+
* `main` (the default): the harness's terminal. `signin:<profile>` and `signout:<profile>`: the sign-in
|
|
11493
|
+
* and sign-out windows for one of the definition's `signin` profiles, for a personal agent's owner only.
|
|
11494
|
+
* @default "main"
|
|
11495
|
+
*/
|
|
11496
|
+
window?: string;
|
|
11497
|
+
/** The controller's width; ignored for a viewer. */
|
|
11498
|
+
cols?: number;
|
|
11499
|
+
/** The controller's height; ignored for a viewer. */
|
|
11500
|
+
rows?: number;
|
|
11501
|
+
}
|
|
11502
|
+
/** Parameters of `listRecordings`. */
|
|
11503
|
+
export interface AgentsListRecordingsParams {
|
|
11504
|
+
/**
|
|
11505
|
+
* Page size, from 1 to 100.
|
|
11506
|
+
* @default 20
|
|
11507
|
+
*/
|
|
11508
|
+
limit?: number;
|
|
11509
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
11510
|
+
cursor?: string;
|
|
11511
|
+
}
|
|
9367
11512
|
/** Parameters of `listSessions`. */
|
|
9368
11513
|
export interface AgentsListSessionsParams {
|
|
9369
11514
|
/**
|
|
@@ -9461,6 +11606,83 @@ export interface ListenersListEventsParams {
|
|
|
9461
11606
|
/** Only events in this status. */
|
|
9462
11607
|
status?: ListenerEventStatus;
|
|
9463
11608
|
}
|
|
11609
|
+
/** Parameters of `listWorkspaces`. */
|
|
11610
|
+
export interface WorkspacesListWorkspacesParams {
|
|
11611
|
+
/**
|
|
11612
|
+
* Page size, from 1 to 100.
|
|
11613
|
+
* @default 20
|
|
11614
|
+
*/
|
|
11615
|
+
limit?: number;
|
|
11616
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
11617
|
+
cursor?: string;
|
|
11618
|
+
}
|
|
11619
|
+
/** Parameters of `listBranches`. */
|
|
11620
|
+
export interface WorkspacesListBranchesParams {
|
|
11621
|
+
/**
|
|
11622
|
+
* Page size, from 1 to 100.
|
|
11623
|
+
* @default 20
|
|
11624
|
+
*/
|
|
11625
|
+
limit?: number;
|
|
11626
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
11627
|
+
cursor?: string;
|
|
11628
|
+
/** Only the branch with this name. */
|
|
11629
|
+
name?: string;
|
|
11630
|
+
/** Only branches in this status. */
|
|
11631
|
+
status?: BranchStatus;
|
|
11632
|
+
}
|
|
11633
|
+
/** Parameters of `listCommits`. */
|
|
11634
|
+
export interface WorkspacesListCommitsParams {
|
|
11635
|
+
/**
|
|
11636
|
+
* Page size, from 1 to 100.
|
|
11637
|
+
* @default 20
|
|
11638
|
+
*/
|
|
11639
|
+
limit?: number;
|
|
11640
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
11641
|
+
cursor?: string;
|
|
11642
|
+
/** The branch whose history to list (`br_…`); `main` when absent. */
|
|
11643
|
+
branch_id?: string;
|
|
11644
|
+
}
|
|
11645
|
+
/** Parameters of `diff`. */
|
|
11646
|
+
export interface WorkspacesDiffParams {
|
|
11647
|
+
/**
|
|
11648
|
+
* The end user this call works for: the `human` principal the workspace's rules check. Only a credential holding
|
|
11649
|
+
* `workspaces:subjects:assert` may name one (`403 forbidden`, reason `scope`), never a sandbox's own credential
|
|
11650
|
+
* (reason `sandbox`). 1 to 200 letters, digits or `._:@-`.
|
|
11651
|
+
*/
|
|
11652
|
+
subject?: string;
|
|
11653
|
+
/** A commit ID (`cmt_…`) or a branch name. */
|
|
11654
|
+
base: string;
|
|
11655
|
+
/** A commit ID (`cmt_…`) or a branch name. */
|
|
11656
|
+
head: string;
|
|
11657
|
+
/** Only paths under this directory. */
|
|
11658
|
+
path?: string;
|
|
11659
|
+
}
|
|
11660
|
+
/** Parameters of `listFiles`. */
|
|
11661
|
+
export interface WorkspacesListFilesParams {
|
|
11662
|
+
/**
|
|
11663
|
+
* The end user this call works for: the `human` principal the workspace's rules check. Only a credential holding
|
|
11664
|
+
* `workspaces:subjects:assert` may name one (`403 forbidden`, reason `scope`), never a sandbox's own credential
|
|
11665
|
+
* (reason `sandbox`). 1 to 200 letters, digits or `._:@-`.
|
|
11666
|
+
*/
|
|
11667
|
+
subject?: string;
|
|
11668
|
+
/** A commit ID (`cmt_…`) or a branch name; `main` when absent. */
|
|
11669
|
+
ref?: string;
|
|
11670
|
+
/** The directory or file, absolute in the workspace; `/` when absent. */
|
|
11671
|
+
path?: string;
|
|
11672
|
+
}
|
|
11673
|
+
/** Parameters of `readFile`. */
|
|
11674
|
+
export interface WorkspacesReadFileParams {
|
|
11675
|
+
/**
|
|
11676
|
+
* The end user this call works for: the `human` principal the workspace's rules check. Only a credential holding
|
|
11677
|
+
* `workspaces:subjects:assert` may name one (`403 forbidden`, reason `scope`), never a sandbox's own credential
|
|
11678
|
+
* (reason `sandbox`). 1 to 200 letters, digits or `._:@-`.
|
|
11679
|
+
*/
|
|
11680
|
+
subject?: string;
|
|
11681
|
+
/** A commit ID (`cmt_…`) or a branch name; `main` when absent. */
|
|
11682
|
+
ref?: string;
|
|
11683
|
+
/** The file, absolute in the workspace. */
|
|
11684
|
+
path: string;
|
|
11685
|
+
}
|
|
9464
11686
|
/** Parameters of `describe`. */
|
|
9465
11687
|
export interface ActionsDescribeParams {
|
|
9466
11688
|
/** `<namespace>/<name>/<action>@<version>`; the version may be exact (`1.0.0`) or a major (`1`). */
|