@b3os/sdk 0.2.0 → 0.2.2
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/dist/cjs/core/sse.d.ts +2 -0
- package/dist/cjs/core/sse.js +17 -5
- package/dist/cjs/core/sse.js.map +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 +13 -0
- package/dist/cjs/generated/client.js +25 -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 +95 -0
- package/dist/cjs/generated/errors.js.map +1 -1
- package/dist/cjs/generated/ids.d.ts +61 -0
- package/dist/cjs/generated/ids.js +15 -0
- package/dist/cjs/generated/ids.js.map +1 -1
- package/dist/cjs/generated/jobs.js +4 -0
- package/dist/cjs/generated/jobs.js.map +1 -1
- package/dist/cjs/generated/ns/actions.d.ts +303 -4
- package/dist/cjs/generated/ns/actions.js +446 -4
- package/dist/cjs/generated/ns/actions.js.map +1 -1
- package/dist/cjs/generated/ns/agents.d.ts +229 -0
- package/dist/cjs/generated/ns/agents.js +402 -0
- package/dist/cjs/generated/ns/agents.js.map +1 -0
- package/dist/cjs/generated/ns/images.d.ts +81 -0
- package/dist/cjs/generated/ns/images.js +122 -0
- package/dist/cjs/generated/ns/images.js.map +1 -0
- package/dist/cjs/generated/ns/infer.d.ts +71 -3
- package/dist/cjs/generated/ns/infer.js +98 -3
- package/dist/cjs/generated/ns/infer.js.map +1 -1
- package/dist/cjs/generated/ns/keys.d.ts +3 -1
- package/dist/cjs/generated/ns/keys.js +3 -1
- package/dist/cjs/generated/ns/keys.js.map +1 -1
- package/dist/cjs/generated/ns/listeners.d.ts +159 -0
- package/dist/cjs/generated/ns/listeners.js +264 -0
- package/dist/cjs/generated/ns/listeners.js.map +1 -0
- package/dist/cjs/generated/ns/orgs.d.ts +10 -0
- package/dist/cjs/generated/ns/orgs.js +26 -1
- package/dist/cjs/generated/ns/orgs.js.map +1 -1
- package/dist/cjs/generated/ns/projects.d.ts +32 -0
- package/dist/cjs/generated/ns/projects.js +66 -0
- package/dist/cjs/generated/ns/projects.js.map +1 -1
- package/dist/cjs/generated/ns/render.d.ts +192 -21
- package/dist/cjs/generated/ns/render.js +267 -24
- package/dist/cjs/generated/ns/render.js.map +1 -1
- package/dist/cjs/generated/ns/requests.d.ts +3 -1
- package/dist/cjs/generated/ns/requests.js +3 -1
- package/dist/cjs/generated/ns/requests.js.map +1 -1
- package/dist/cjs/generated/ns/routines.d.ts +11 -4
- package/dist/cjs/generated/ns/routines.js +11 -4
- package/dist/cjs/generated/ns/routines.js.map +1 -1
- package/dist/cjs/generated/ns/sandboxes.d.ts +292 -7
- package/dist/cjs/generated/ns/sandboxes.js +444 -6
- package/dist/cjs/generated/ns/sandboxes.js.map +1 -1
- package/dist/cjs/generated/ns/usage.d.ts +1 -1
- package/dist/cjs/generated/ns/usage.js +1 -1
- package/dist/cjs/generated/ns/vision.d.ts +59 -17
- package/dist/cjs/generated/ns/vision.js +59 -21
- package/dist/cjs/generated/ns/vision.js.map +1 -1
- package/dist/cjs/generated/types.d.ts +2787 -85
- package/dist/cjs/helpers/sandboxes.d.ts +46 -3
- package/dist/cjs/helpers/sandboxes.js +127 -14
- package/dist/cjs/helpers/sandboxes.js.map +1 -1
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +2 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/core/sse.d.ts +2 -0
- package/dist/esm/core/sse.js +17 -5
- package/dist/esm/core/sse.js.map +1 -1
- package/dist/esm/core/util.d.ts +1 -1
- package/dist/esm/core/util.js +1 -1
- package/dist/esm/generated/client.d.ts +13 -0
- package/dist/esm/generated/client.js +25 -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 +95 -0
- package/dist/esm/generated/errors.js.map +1 -1
- package/dist/esm/generated/ids.d.ts +61 -0
- package/dist/esm/generated/ids.js +15 -0
- package/dist/esm/generated/ids.js.map +1 -1
- package/dist/esm/generated/jobs.js +4 -0
- package/dist/esm/generated/jobs.js.map +1 -1
- package/dist/esm/generated/ns/actions.d.ts +303 -4
- package/dist/esm/generated/ns/actions.js +446 -4
- package/dist/esm/generated/ns/actions.js.map +1 -1
- package/dist/esm/generated/ns/agents.d.ts +229 -0
- package/dist/esm/generated/ns/agents.js +398 -0
- package/dist/esm/generated/ns/agents.js.map +1 -0
- package/dist/esm/generated/ns/images.d.ts +81 -0
- package/dist/esm/generated/ns/images.js +118 -0
- package/dist/esm/generated/ns/images.js.map +1 -0
- package/dist/esm/generated/ns/infer.d.ts +71 -3
- package/dist/esm/generated/ns/infer.js +98 -3
- package/dist/esm/generated/ns/infer.js.map +1 -1
- package/dist/esm/generated/ns/keys.d.ts +3 -1
- package/dist/esm/generated/ns/keys.js +3 -1
- package/dist/esm/generated/ns/keys.js.map +1 -1
- package/dist/esm/generated/ns/listeners.d.ts +159 -0
- package/dist/esm/generated/ns/listeners.js +260 -0
- package/dist/esm/generated/ns/listeners.js.map +1 -0
- package/dist/esm/generated/ns/orgs.d.ts +10 -0
- package/dist/esm/generated/ns/orgs.js +26 -1
- package/dist/esm/generated/ns/orgs.js.map +1 -1
- package/dist/esm/generated/ns/projects.d.ts +32 -0
- package/dist/esm/generated/ns/projects.js +66 -0
- package/dist/esm/generated/ns/projects.js.map +1 -1
- package/dist/esm/generated/ns/render.d.ts +192 -21
- package/dist/esm/generated/ns/render.js +267 -24
- package/dist/esm/generated/ns/render.js.map +1 -1
- package/dist/esm/generated/ns/requests.d.ts +3 -1
- package/dist/esm/generated/ns/requests.js +3 -1
- package/dist/esm/generated/ns/requests.js.map +1 -1
- package/dist/esm/generated/ns/routines.d.ts +11 -4
- package/dist/esm/generated/ns/routines.js +11 -4
- package/dist/esm/generated/ns/routines.js.map +1 -1
- package/dist/esm/generated/ns/sandboxes.d.ts +292 -7
- package/dist/esm/generated/ns/sandboxes.js +444 -6
- package/dist/esm/generated/ns/sandboxes.js.map +1 -1
- package/dist/esm/generated/ns/usage.d.ts +1 -1
- package/dist/esm/generated/ns/usage.js +1 -1
- package/dist/esm/generated/ns/vision.d.ts +59 -17
- package/dist/esm/generated/ns/vision.js +59 -21
- package/dist/esm/generated/ns/vision.js.map +1 -1
- package/dist/esm/generated/types.d.ts +2787 -85
- package/dist/esm/helpers/sandboxes.d.ts +46 -3
- package/dist/esm/helpers/sandboxes.js +126 -13
- package/dist/esm/helpers/sandboxes.js.map +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
- package/src/core/sse.ts +17 -5
- package/src/core/util.ts +1 -1
- package/src/generated/client.ts +28 -0
- package/src/generated/errors.ts +190 -0
- package/src/generated/ids.ts +15 -0
- package/src/generated/jobs.ts +4 -0
- package/src/generated/ns/actions.ts +483 -4
- package/src/generated/ns/agents.ts +461 -0
- package/src/generated/ns/images.ts +128 -0
- package/src/generated/ns/infer.ts +100 -3
- package/src/generated/ns/keys.ts +3 -1
- package/src/generated/ns/listeners.ts +296 -0
- package/src/generated/ns/orgs.ts +27 -1
- package/src/generated/ns/projects.ts +74 -0
- package/src/generated/ns/render.ts +277 -24
- package/src/generated/ns/requests.ts +3 -1
- package/src/generated/ns/routines.ts +11 -4
- package/src/generated/ns/sandboxes.ts +492 -7
- package/src/generated/ns/usage.ts +1 -1
- package/src/generated/ns/vision.ts +59 -21
- package/src/generated/types.ts +3511 -575
- package/src/helpers/sandboxes.ts +167 -14
- package/src/index.ts +1 -0
|
@@ -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" | "routines:read" | "routines:write" | "routines:run" | "actions:read" | "actions:write" | "actions:run" | "infer:read" | "infer:write" | "infer:run" | "vault:read" | "vault:write" | "vault:run" | "platform:read" | "platform:write" | "vision:*" | "render:*" | "sandboxes:*" | "routines:*" | "actions:*" | "infer:*" | "vault:*" | "platform:*" | "*";
|
|
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:*" | "*";
|
|
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,12 @@ 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 sandbox that holds a lease's key now, or null when none does (`lease_holder_changed`). */
|
|
86
|
+
holder?: string | null;
|
|
87
|
+
/** The head of the linked branch now (`manifest_changed`). */
|
|
88
|
+
head_commit?: string;
|
|
89
|
+
/** The digest of b3os.yaml at `head_commit` (`manifest_changed`); null when the file is not there. */
|
|
90
|
+
head_digest?: string | null;
|
|
85
91
|
/** The HTTP status the upstream returned (`upstream_error`, `action_output_invalid`). */
|
|
86
92
|
upstream_status?: number;
|
|
87
93
|
/**
|
|
@@ -95,15 +101,57 @@ export interface Problem {
|
|
|
95
101
|
retryable: boolean;
|
|
96
102
|
};
|
|
97
103
|
/**
|
|
98
|
-
* The option a request value was refused for, by its id (`option_not_allowed`), e.g. `sandboxes.clone_reset`.
|
|
104
|
+
* The option a request or setting value was refused for, by its id (`option_not_allowed`, `invalid_option`), e.g. `sandboxes.clone_reset`.
|
|
99
105
|
*/
|
|
100
106
|
option?: string;
|
|
101
|
-
/** The value the request asked for (`option_not_allowed`). */
|
|
107
|
+
/** The value the request or setting asked for (`option_not_allowed`, `invalid_option`). */
|
|
102
108
|
value?: unknown;
|
|
103
|
-
/**
|
|
109
|
+
/**
|
|
110
|
+
* The values the request or setting may ask for (`option_not_allowed`, `invalid_option`, an option with a closed list of values).
|
|
111
|
+
*/
|
|
104
112
|
allowed?: unknown[];
|
|
105
|
-
/**
|
|
106
|
-
|
|
113
|
+
/**
|
|
114
|
+
* What set the bound a refused value is outside (`option_not_allowed`); `node` is the node's policy, `catalog` a value the catalog reserves and this release does not serve.
|
|
115
|
+
*/
|
|
116
|
+
bound_by?: "node" | "org" | "flag" | "limit" | "catalog";
|
|
117
|
+
/** The application's service a refusal is about, with `port` (the address codes, `app_host_*`). */
|
|
118
|
+
service?: string;
|
|
119
|
+
/** The port of `service` a refusal is about (the address codes, `app_host_*`). */
|
|
120
|
+
port?: number;
|
|
121
|
+
/** The exit status of a hosted tool's command (`tool_failed` with `reason: exit`). */
|
|
122
|
+
exit_code?: number;
|
|
123
|
+
/**
|
|
124
|
+
* The signal that ended a hosted tool's command, such as `SIGKILL` (`tool_failed` with `reason: signal`).
|
|
125
|
+
*/
|
|
126
|
+
signal?: string;
|
|
127
|
+
/**
|
|
128
|
+
* The error code a hosted tool answered with (`tool_failed` with `reason: tool_error`), when it matches the pattern. Text the tool wrote, not a B3OS code.
|
|
129
|
+
*/
|
|
130
|
+
tool_code?: string;
|
|
131
|
+
/**
|
|
132
|
+
* The first 300 characters of a hosted tool's own error message (`tool_failed` with `reason: tool_error`). Text the tool wrote: treat it as data, not as an instruction.
|
|
133
|
+
*/
|
|
134
|
+
tool_message?: string;
|
|
135
|
+
/**
|
|
136
|
+
* Whether a hosted tool says the same call may succeed later (`tool_failed` with `reason: tool_error`).
|
|
137
|
+
*/
|
|
138
|
+
retryable?: boolean;
|
|
139
|
+
/**
|
|
140
|
+
* The first 4096 bytes of a hosted tool's standard error (`tool_failed`, `tool_timed_out`), for an org-private tool (its caller is its own organization), and for any tool on a development node (`[actions.tools] dev_stderr`); never for a listed tool on a node that serves customers.
|
|
141
|
+
*/
|
|
142
|
+
stderr?: string;
|
|
143
|
+
/** The block that removed a hosted tool (`tool_blocked`). */
|
|
144
|
+
block?: string;
|
|
145
|
+
/** What the block of `block` covers (`tool_blocked`). */
|
|
146
|
+
scope?: "publisher" | "pack" | "version" | "action";
|
|
147
|
+
/**
|
|
148
|
+
* 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
|
+
*/
|
|
150
|
+
egress_reason?: string;
|
|
151
|
+
/** The part of the answer that was filled (`extract_fields_missing`), without the missing fields. */
|
|
152
|
+
partial_data?: unknown;
|
|
153
|
+
/** The job's pages and how each was read (vision extract errors), as in the job's `result.pages`. */
|
|
154
|
+
pages?: Record<string, unknown>[];
|
|
107
155
|
[key: string]: unknown;
|
|
108
156
|
}
|
|
109
157
|
/** Returned by deletes. */
|
|
@@ -324,6 +372,65 @@ export interface JsonExtractOptions {
|
|
|
324
372
|
/** Guidance for the model. */
|
|
325
373
|
prompt?: string;
|
|
326
374
|
}
|
|
375
|
+
/**
|
|
376
|
+
* How a URL that serves a PDF is read. PDFs are read from their text layer by the HTTP fetch tier: text in reading order (two-column pages left column first), headings (from the PDF's outline, else from font sizes), lists, tables where the columns are clear, and links. Running headers, footers and page numbers are dropped with `only_main_content` (the default) on documents of 3 or more pages. `include_tags` and `exclude_tags` do not apply to a PDF, and `raw_html`, `screenshot` and `images` are not produced for one (each adds a warning).
|
|
377
|
+
*/
|
|
378
|
+
export interface PdfOptions {
|
|
379
|
+
/**
|
|
380
|
+
* `text` reads the text layer. `off` does not read PDFs: a PDF answers `422 content_type_unsupported`, and a crawl does not follow links that end in `.pdf`.
|
|
381
|
+
* @default "text"
|
|
382
|
+
*/
|
|
383
|
+
mode?: "text" | "off";
|
|
384
|
+
/**
|
|
385
|
+
* Read at most this many pages, from the first. The default and the ceiling are the node's `vision.pdf.pages_max` (500); a value above it answers `422 limit_exceeded`, and a batch, crawl, extract or search that carries one is refused before it starts. A longer file returns its first pages with `pdf.truncated: max_pages` and bills only the pages read.
|
|
386
|
+
*/
|
|
387
|
+
max_pages?: number;
|
|
388
|
+
/**
|
|
389
|
+
* Put `\n\n---\n\n<!-- page N -->\n\n` between pages in `markdown` (between pages only: no marker before page 1), the marker Firecrawl uses. `text` and `html` keep a plain break.
|
|
390
|
+
* @default true
|
|
391
|
+
*/
|
|
392
|
+
page_markers?: boolean;
|
|
393
|
+
/**
|
|
394
|
+
* Also return each page's Markdown on its own, in `pdf.page_markdown`.
|
|
395
|
+
* @default false
|
|
396
|
+
*/
|
|
397
|
+
pages?: boolean;
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* What a PDF scrape read. Present only when the URL served a PDF. The document's own metadata (`title`, `author`, ...) is present when the PDF states it.
|
|
401
|
+
*/
|
|
402
|
+
export interface PdfInfo {
|
|
403
|
+
/** Pages in the file. */
|
|
404
|
+
pages: number;
|
|
405
|
+
/** Pages converted, from the first. */
|
|
406
|
+
pages_read: number;
|
|
407
|
+
/** `vision.page` units this scrape billed: the pages read. */
|
|
408
|
+
pages_billed: number;
|
|
409
|
+
/**
|
|
410
|
+
* Why fewer pages than the file holds were read: `max_pages` (the request's or the node's page cap), `max_chars` (about 2 million characters of text, or a page too dense to pass on whole, cut there), `deadline` (the scrape's time ran out; the pages read by then are returned), `allowance` (the organization's monthly page allowance ran out). `null` when the whole file was read.
|
|
411
|
+
*/
|
|
412
|
+
truncated: "max_pages" | "max_chars" | "deadline" | "allowance" | null;
|
|
413
|
+
title?: string;
|
|
414
|
+
author?: string;
|
|
415
|
+
subject?: string;
|
|
416
|
+
keywords?: string;
|
|
417
|
+
/** The program that made the original document. */
|
|
418
|
+
creator?: string;
|
|
419
|
+
/** The program that wrote the PDF. */
|
|
420
|
+
producer?: string;
|
|
421
|
+
/** The PDF's creation date (RFC 3339, converted from the PDF date). */
|
|
422
|
+
created_at?: string;
|
|
423
|
+
modified_at?: string;
|
|
424
|
+
/** The PDF carries a structure tree (tagged PDF). The tree is not used yet. */
|
|
425
|
+
tagged?: boolean;
|
|
426
|
+
/** Pages with images and no text layer (scanned); OCR is not available yet, so they add no text. */
|
|
427
|
+
no_text_pages?: number[];
|
|
428
|
+
/** Each page's Markdown, with `pdf.pages`. */
|
|
429
|
+
page_markdown?: {
|
|
430
|
+
page: number;
|
|
431
|
+
markdown: string;
|
|
432
|
+
}[];
|
|
433
|
+
}
|
|
327
434
|
/** Options shared by scrape, batch scrape, crawl and extract. */
|
|
328
435
|
export interface ScrapeOptions {
|
|
329
436
|
/** @default ["markdown"] */
|
|
@@ -409,6 +516,7 @@ export interface ScrapeOptions {
|
|
|
409
516
|
block_resources?: Array<"image" | "media" | "font" | "stylesheet">;
|
|
410
517
|
screenshot?: ScreenshotOptions;
|
|
411
518
|
json?: JsonExtractOptions;
|
|
519
|
+
pdf?: PdfOptions;
|
|
412
520
|
/**
|
|
413
521
|
* What a wall (`page_state` `blocked` or `captcha`) costs. `free`: no `vision.page`, and the result carries no page content, only `page_state`, `status_code`, `final_url` and `content_withheld: true`. `bill`: the wall bills like any page and its content is returned. A scrape with `actions` bills either way.
|
|
414
522
|
* @default "free"
|
|
@@ -419,7 +527,81 @@ export interface ScrapeOptions {
|
|
|
419
527
|
export type ScrapeRequest = {
|
|
420
528
|
/** Absolute `http` or `https` URL. */
|
|
421
529
|
url: string;
|
|
530
|
+
proxy?: ProxyOption;
|
|
531
|
+
/**
|
|
532
|
+
* The country of the residential address (ISO 3166-1 alpha-2, any case; default `US`), for `proxy` `auto` and `residential` only. The node lists the countries it offers; another answers `422 option_not_allowed`. Locale and time zone do not follow it: set `locale` and `timezone` yourself.
|
|
533
|
+
*/
|
|
534
|
+
proxy_country?: string;
|
|
422
535
|
} & ScrapeOptions;
|
|
536
|
+
/**
|
|
537
|
+
* Where the scrape leaves from (`vision.proxy`). Absent: the node's default, `none` unless its operator set
|
|
538
|
+
* `auto`.
|
|
539
|
+
* - `none`: the node's own address, always.
|
|
540
|
+
* - `auto`: the node's address; when the page comes back a wall (`page_state` `blocked` or `captcha`), vision
|
|
541
|
+
* asks once more from a residential address, unless the request or the site rules that out
|
|
542
|
+
* (`egress.retry.skipped` says why no retry ran). Where residential reads are off it is exactly `none`,
|
|
543
|
+
* never an error.
|
|
544
|
+
* - `residential`: read the page from a residential address, every request of the scrape (`422
|
|
545
|
+
* option_not_allowed` where that is off: `bound_by: node` or `org`).
|
|
546
|
+
* - `http://host:port`: your own proxy, without credentials.
|
|
547
|
+
* - `{url, connection}`: your own proxy with the username and password of a `basic` vault connection whose
|
|
548
|
+
* `hosts` list the proxy's host (needs `vault:run`).
|
|
549
|
+
* A URL with a username or password is refused (`400 invalid_request`): put them in a connection. This node
|
|
550
|
+
* takes `http://` proxies only; plain HTTP means the username and password cross the network to your proxy
|
|
551
|
+
* unencrypted. Batches, crawls, sessions and the Firecrawl surface do not take `proxy` yet.
|
|
552
|
+
*/
|
|
553
|
+
export type ProxyOption = "none" | "auto" | "residential" | string | {
|
|
554
|
+
/** Your proxy's URL, `http://host:port`. */
|
|
555
|
+
url: string;
|
|
556
|
+
/** A `basic` vault connection with the proxy's username and password. */
|
|
557
|
+
connection?: string;
|
|
558
|
+
};
|
|
559
|
+
/**
|
|
560
|
+
* Which exit served the page returned. `node`: the node's own address. `byo`: your proxy (`host`, never its
|
|
561
|
+
* credentials). `residential`: read from a residential address (`country`, `exit_session`). `bytes` counts
|
|
562
|
+
* both directions through the exit for this scrape. With `proxy: "auto"`, after a wall from the node's address:
|
|
563
|
+
* `retried_from`, `first` (the node's wall) when the residential read's page is the one returned, or `retry`
|
|
564
|
+
* when no retry ran (`skipped`) or it did not help (`outcome`).
|
|
565
|
+
*/
|
|
566
|
+
export interface Egress {
|
|
567
|
+
exit: "node" | "byo" | "residential";
|
|
568
|
+
/** Your proxy's host (`byo`). */
|
|
569
|
+
host?: string;
|
|
570
|
+
/** The residential address's country (`residential`). */
|
|
571
|
+
country?: string;
|
|
572
|
+
/**
|
|
573
|
+
* B3OS's id of the residential exit session (one address), the same for every page of one host and organization while it lasts.
|
|
574
|
+
*/
|
|
575
|
+
exit_session?: string;
|
|
576
|
+
/** Bytes through the exit for this scrape, both directions. */
|
|
577
|
+
bytes?: number;
|
|
578
|
+
/** The page was read from a residential address after a wall from the node's address. */
|
|
579
|
+
retried_from?: "node";
|
|
580
|
+
/** The node's wall, when the residential read's page is the one returned. */
|
|
581
|
+
first?: {
|
|
582
|
+
page_state?: string;
|
|
583
|
+
signal?: string;
|
|
584
|
+
status_code?: number;
|
|
585
|
+
};
|
|
586
|
+
/**
|
|
587
|
+
* `auto` after a wall from the node's address: why no retry ran (`skipped`), or how the retry from a residential address ended when the node's wall is the page returned (`outcome` `wall` or `failed`).
|
|
588
|
+
*/
|
|
589
|
+
retry?: {
|
|
590
|
+
skipped?: "org" | "node" | "credentials" | "opt_out" | "category" | "memory" | "rate_limited" | "time" | "quota" | "robots" | "capacity";
|
|
591
|
+
exit?: "residential";
|
|
592
|
+
outcome?: "wall" | "failed";
|
|
593
|
+
page_state?: string;
|
|
594
|
+
error?: string;
|
|
595
|
+
bytes?: number;
|
|
596
|
+
};
|
|
597
|
+
}
|
|
598
|
+
/**
|
|
599
|
+
* The options the scrape read, each with its `value` and the level it came from (`request` or `node`): `vision.proxy` always, `vision.proxy_country` for `auto` and `residential`. Your own proxy's value is `{"url": "http://host:port"}`, with `connection` when one was named.
|
|
600
|
+
*/
|
|
601
|
+
export type ScrapeOptionsApplied = Record<string, {
|
|
602
|
+
value: unknown;
|
|
603
|
+
from: "request" | "node";
|
|
604
|
+
}>;
|
|
423
605
|
/** Metadata read from the page. */
|
|
424
606
|
export interface PageMetadata {
|
|
425
607
|
title?: string;
|
|
@@ -436,7 +618,7 @@ export interface PageMetadata {
|
|
|
436
618
|
}
|
|
437
619
|
export interface CacheInfo {
|
|
438
620
|
/**
|
|
439
|
-
* `hit` served from cache; `miss` fetched and stored; `bypass` fetched and not shared (custom headers, profile, actions).
|
|
621
|
+
* `hit` served from cache; `miss` fetched and stored; `bypass` fetched and not shared (custom headers, profile, actions, and every PDF).
|
|
440
622
|
*/
|
|
441
623
|
state: "hit" | "miss" | "bypass";
|
|
442
624
|
/** Age of the served copy in seconds. */
|
|
@@ -463,6 +645,14 @@ export interface ScrapeResult {
|
|
|
463
645
|
content_type?: string;
|
|
464
646
|
/** What served the page. */
|
|
465
647
|
tier: "cache" | "fetch" | "browser";
|
|
648
|
+
/**
|
|
649
|
+
* Present when the browser served an `engine: "auto"` scrape: why the fetch tier did not. `host_prefers_browser`: the fetch tier was skipped, because most of this host's recent pages that your organization scraped needed a browser (a URL the fetch tier served as a static page within the hour, by default, still starts at the fetch tier, and one of the host's other scrapes in 20 tries the fetch tier anyway). `needs_js`: the fetch tier's page needed JavaScript. `empty_page`: the fetch tier's page came out empty. `thin_page`: the fetch tier's page was thin or mostly script, and the browser's had more text. `fetch_failed`: the fetch failed in a way a browser may not (TLS, a connection, a redirect loop, a timeout). `challenged`: the site answered the fetch tier with a bot challenge or block page, with Chrome's headers and, after a 403, with the [B3OS fetcher](https://docs.beta.b3os.org/vision/fetcher)'s (see `fetch_identity`); or it refused both for this URL, or for two URLs of the host, within the hour by default, so the fetch tier was skipped for your organization's scrape.
|
|
650
|
+
*/
|
|
651
|
+
tier_reason?: "host_prefers_browser" | "needs_js" | "empty_page" | "thin_page" | "fetch_failed" | "challenged";
|
|
652
|
+
/**
|
|
653
|
+
* Who the fetch tier's last request of this scrape said it was, when the fetch tier sent one from the node's address. `chrome`: the headers Chrome sends for a page (the default). `honest`: the [B3OS fetcher](https://docs.beta.b3os.org/vision/fetcher), with the user agent `Mozilla/5.0 (compatible; B3OS-Vision/<version>; +https://docs.beta.b3os.org/vision/fetcher)` and no client hints. The fetch tier asks once more as the B3OS fetcher when Chrome's headers get a 403 bot challenge, and a page it gets that way carries a warning; your organization's scrapes of that host start with it for up to an hour, by default, then with Chrome's headers again. Never when your request sets `User-Agent`, `Sec-CH-*`, `Sec-Fetch-*` or `Upgrade-Insecure-Requests` in `headers`, and never through an exit. Absent for a cache hit, a scrape the browser served without a fetch, and a page that went through an exit.
|
|
654
|
+
*/
|
|
655
|
+
fetch_identity?: "chrome" | "honest";
|
|
466
656
|
cache: CacheInfo;
|
|
467
657
|
markdown?: string;
|
|
468
658
|
html?: string;
|
|
@@ -476,6 +666,7 @@ export interface ScrapeResult {
|
|
|
476
666
|
/** Results of `actions`, in order. */
|
|
477
667
|
actions?: ActStepResult[];
|
|
478
668
|
page_state?: PageState;
|
|
669
|
+
pdf?: PdfInfo;
|
|
479
670
|
/**
|
|
480
671
|
* Present (`true`) when the page is a wall and the scrape was free (`walls: free`): the result then has no `markdown`, `html`, `raw_html`, `text`, `links`, `metadata`, `screenshot`, `json`, `actions` or `content_type`, only the state, `status_code` and `final_url`.
|
|
481
672
|
*/
|
|
@@ -483,6 +674,8 @@ export interface ScrapeResult {
|
|
|
483
674
|
/** Non-fatal problems, such as a format that could not be produced. */
|
|
484
675
|
warnings: string[];
|
|
485
676
|
timing: Timing;
|
|
677
|
+
egress?: Egress;
|
|
678
|
+
options?: ScrapeOptionsApplied;
|
|
486
679
|
}
|
|
487
680
|
export interface PrepareRequest {
|
|
488
681
|
/** The page a coming scrape will fetch. */
|
|
@@ -667,6 +860,9 @@ export interface PageResult {
|
|
|
667
860
|
depth?: number;
|
|
668
861
|
scraped_at?: string;
|
|
669
862
|
scrape?: ScrapeResult;
|
|
863
|
+
/**
|
|
864
|
+
* Why the page failed, with the codes a scrape answers with: for example `navigation_failed`, `scrape_timeout`, `content_type_unsupported`, and for a PDF `pdf_unreadable` or `pdf_encrypted`. A failed page bills nothing.
|
|
865
|
+
*/
|
|
670
866
|
error?: Problem;
|
|
671
867
|
}
|
|
672
868
|
export type PageResultList = Omit<ListEnvelope, "data"> & {
|
|
@@ -709,10 +905,15 @@ export type PageEvent = JobEvent & {
|
|
|
709
905
|
export type BatchEvent = PageEvent;
|
|
710
906
|
/** An event of a crawl's stream. */
|
|
711
907
|
export type CrawlEvent = PageEvent;
|
|
908
|
+
/** At least one of `schema` and `prompt` is required. */
|
|
712
909
|
export interface ExtractCreateRequest {
|
|
910
|
+
/** The pages to read (`vision.extract.urls_max`); duplicates are read once. */
|
|
713
911
|
urls: string[];
|
|
912
|
+
/** What to extract, in words. With `schema`, guidance for filling it. */
|
|
714
913
|
prompt?: string;
|
|
715
|
-
/**
|
|
914
|
+
/**
|
|
915
|
+
* JSON Schema of the result (draft 2020-12, or the draft its `$schema` names, such as draft-07 from zod). At most 64 KiB and 32 levels deep; `$ref` may only point inside the schema.
|
|
916
|
+
*/
|
|
716
917
|
schema?: Record<string, unknown>;
|
|
717
918
|
scrape?: NestedScrapeOptions;
|
|
718
919
|
/** Model ID from `GET /v1/infer/models`; defaults to the node's model. */
|
|
@@ -726,12 +927,46 @@ export type ExtractJob = Omit<Job, "id" | "object" | "result"> & {
|
|
|
726
927
|
object: "job";
|
|
727
928
|
kind: "vision.extract";
|
|
728
929
|
result?: {
|
|
729
|
-
/** The extracted data,
|
|
930
|
+
/** The extracted data, validated against your schema (any JSON object without one). */
|
|
730
931
|
data: unknown;
|
|
731
|
-
/** Pages the data came from
|
|
932
|
+
/** Pages the data came from, as given in `urls`. */
|
|
732
933
|
sources: string[];
|
|
934
|
+
/** For each top-level field of `data`, the pages it came from. */
|
|
935
|
+
field_sources?: Record<string, string[]>;
|
|
936
|
+
/** Every URL of the job, in the order given, and how it was read. */
|
|
937
|
+
pages?: ExtractPage[];
|
|
938
|
+
usage?: ExtractUsage;
|
|
939
|
+
/**
|
|
940
|
+
* Pages or pieces left out (too many model calls), conflicting values the merge resolved (`/plans/0/usd_per_month: https://a says 49, https://b says 59; kept the first`), and the pages' own warnings.
|
|
941
|
+
*/
|
|
942
|
+
warnings?: string[];
|
|
733
943
|
};
|
|
734
944
|
};
|
|
945
|
+
/** One URL of an extract job. */
|
|
946
|
+
export interface ExtractPage {
|
|
947
|
+
url: string;
|
|
948
|
+
status: "succeeded" | "failed";
|
|
949
|
+
final_url?: string;
|
|
950
|
+
content_type?: string | null;
|
|
951
|
+
/** Characters of the page's Markdown the model read. */
|
|
952
|
+
chars?: number;
|
|
953
|
+
/** The page's Markdown was cut (pieces past `extract.max_model_calls`, or a PDF's own caps). */
|
|
954
|
+
truncated?: boolean;
|
|
955
|
+
/** Pages read when the URL served a PDF. */
|
|
956
|
+
pdf_pages?: number | null;
|
|
957
|
+
/** Why the page failed (the codes a scrape answers with). A failed page bills nothing. */
|
|
958
|
+
error?: Problem;
|
|
959
|
+
}
|
|
960
|
+
/** What the job used. */
|
|
961
|
+
export interface ExtractUsage {
|
|
962
|
+
/** `vision.page` units billed for the pages read. */
|
|
963
|
+
pages_billed: number;
|
|
964
|
+
/** Prompt tokens of the model calls (billed by infer as `infer.input_tokens`). */
|
|
965
|
+
input_tokens: number;
|
|
966
|
+
/** Answer tokens of the model calls (`infer.output_tokens`). */
|
|
967
|
+
output_tokens: number;
|
|
968
|
+
model_calls: number;
|
|
969
|
+
}
|
|
735
970
|
/**
|
|
736
971
|
* `active` until closed by its timeout (`expired`) or otherwise (`closed`: `DELETE`, its browser stopped, or the node restarted; `closed_reason` says which).
|
|
737
972
|
*/
|
|
@@ -1060,6 +1295,12 @@ export interface SnapshotData {
|
|
|
1060
1295
|
complete: boolean;
|
|
1061
1296
|
/** The budget (`max_tokens`) cut the outline. */
|
|
1062
1297
|
truncated: boolean;
|
|
1298
|
+
/**
|
|
1299
|
+
* The page's `document.title` when the outline was taken, read in act's isolated world (never the page's own world); empty when it could not be read. Node release 1119.
|
|
1300
|
+
*/
|
|
1301
|
+
title?: string;
|
|
1302
|
+
/** The page's URL when the outline was taken, read the same way. Node release 1119. */
|
|
1303
|
+
url?: string;
|
|
1063
1304
|
}
|
|
1064
1305
|
export interface ActRequest {
|
|
1065
1306
|
actions: ActStep[];
|
|
@@ -1865,6 +2106,298 @@ export interface OverlayRemoved {
|
|
|
1865
2106
|
export type ScreenshotList = Omit<ListEnvelope, "data"> & {
|
|
1866
2107
|
data: Screenshot[];
|
|
1867
2108
|
};
|
|
2109
|
+
/**
|
|
2110
|
+
* Give exactly one of `url` or `video_id`. `steps`, `watch`, `viewport` and `theme` are for `url` only.
|
|
2111
|
+
*/
|
|
2112
|
+
export type InspectionCreateRequest = {
|
|
2113
|
+
/** Page to load (`http` or `https`), checked by the egress guard. */
|
|
2114
|
+
url?: string;
|
|
2115
|
+
/** A succeeded video of this project to read the window from. */
|
|
2116
|
+
video_id?: string;
|
|
2117
|
+
/**
|
|
2118
|
+
* Browser steps to run during the window. Step 0 starts at 300 ms; each next step starts when the one before it ends. `navigate` and `wait` with `for` hold the clock until they are done. The window must end at least 200 ms after the last step ends.
|
|
2119
|
+
*/
|
|
2120
|
+
steps?: ScriptStep[];
|
|
2121
|
+
/** Elements whose box is read on every frame (`trace`). */
|
|
2122
|
+
watch?: InspectionWatchTarget[];
|
|
2123
|
+
/**
|
|
2124
|
+
* Length of the window. Default 3000; with `video_id`, the rest of the video from `from_ms`, at most 10000 ms and 300 frames (a default cut to 300 frames carries a `window_cut` warning).
|
|
2125
|
+
*/
|
|
2126
|
+
duration_ms?: number;
|
|
2127
|
+
/**
|
|
2128
|
+
* With `video_id` only (refused with `url`): where the window starts in the video, 0 when left out. A window that runs past the end of the video is cut to it (`window_cut` warning).
|
|
2129
|
+
*/
|
|
2130
|
+
from_ms?: number;
|
|
2131
|
+
/**
|
|
2132
|
+
* Frames a second. Default 30; with `video_id`, the video's own rate. `duration_ms` times `fps` is at most 300 frames.
|
|
2133
|
+
*/
|
|
2134
|
+
fps?: 10 | 15 | 30 | 60;
|
|
2135
|
+
viewport?: InspectionViewport;
|
|
2136
|
+
/**
|
|
2137
|
+
* Emulated `prefers-color-scheme`; `auto` leaves the page default.
|
|
2138
|
+
* @default "auto"
|
|
2139
|
+
*/
|
|
2140
|
+
theme?: "light" | "dark" | "auto";
|
|
2141
|
+
/**
|
|
2142
|
+
* Put the sheet's tiles at a fixed interval from the window's start instead of where pixels change. The window may hold at most 12 tiles at this interval.
|
|
2143
|
+
*/
|
|
2144
|
+
interval_ms?: number;
|
|
2145
|
+
};
|
|
2146
|
+
/** Browser viewport in CSS pixels. Default 1280x800. */
|
|
2147
|
+
export interface InspectionViewport {
|
|
2148
|
+
width: number;
|
|
2149
|
+
height: number;
|
|
2150
|
+
}
|
|
2151
|
+
/**
|
|
2152
|
+
* An element to follow frame by frame: `selector` (CSS), or visible `text` (case-insensitive substring unless `exact`; the `nth` match when set). `role` and `name` are not accepted here: they cost too much to resolve on every frame.
|
|
2153
|
+
*/
|
|
2154
|
+
export type InspectionWatchTarget = {
|
|
2155
|
+
selector?: string;
|
|
2156
|
+
text?: string;
|
|
2157
|
+
/** @default false */
|
|
2158
|
+
exact?: boolean;
|
|
2159
|
+
nth?: number;
|
|
2160
|
+
};
|
|
2161
|
+
export interface Inspection {
|
|
2162
|
+
id: string;
|
|
2163
|
+
object: "inspection";
|
|
2164
|
+
/** An inspection answers once it has finished; a failure is an error response. */
|
|
2165
|
+
status: "succeeded";
|
|
2166
|
+
source: InspectionSource;
|
|
2167
|
+
window: InspectionWindow;
|
|
2168
|
+
/** When each step ran, in the window's clock. */
|
|
2169
|
+
steps: InspectionStep[];
|
|
2170
|
+
/**
|
|
2171
|
+
* Up to 8 plain lines in time order, the same events as `report` and `trace`, such as `0.333 s content below y 318 moved up 29 px (layout)`. When `layout_shifts` has a source on a shift's frame, that shift's line ends with the source's `label` in quotes (the largest labelled source when there are several): `0.333 s content below y 318 moved up 29 px (layout) "Step a1"`. A window where nothing changed has one line, `no change`.
|
|
2172
|
+
*/
|
|
2173
|
+
summary: string[];
|
|
2174
|
+
report: InspectionReport;
|
|
2175
|
+
/** One entry per `watch` target, in request order; empty without `watch`. */
|
|
2176
|
+
trace: InspectionTrace[];
|
|
2177
|
+
/**
|
|
2178
|
+
* The browser's own layout-shift entries (the Layout Instability API), each naming the elements that moved. Left out when the browser reported none.
|
|
2179
|
+
*/
|
|
2180
|
+
layout_shifts?: InspectionLayoutShift[];
|
|
2181
|
+
sheet: InspectionSheet;
|
|
2182
|
+
/**
|
|
2183
|
+
* Non-fatal problems, each starting with a code and a colon: `http_status` (the site answered an error status), `watch_not_found` (a `watch` target matched nothing on the first frame), `window_cut` (the window ran past the end of the video and was cut to it, or the default window of a video was more than 300 frames and was cut to 300).
|
|
2184
|
+
*/
|
|
2185
|
+
warnings: string[];
|
|
2186
|
+
/**
|
|
2187
|
+
* Phases `queue` (waiting for a free inspection slot), `claim`, `navigate`, `settle`, `capture`, `analyze`, `sheet`, `persist` and `total`, also sent as `Server-Timing`. A video source has no `claim`, `navigate` or `settle`; its `capture` is reading the video.
|
|
2188
|
+
*/
|
|
2189
|
+
timing: Timing;
|
|
2190
|
+
created_at: string;
|
|
2191
|
+
/** When the sheet is deleted, 24 hours after it was made. */
|
|
2192
|
+
expires_at: string;
|
|
2193
|
+
}
|
|
2194
|
+
/** The page (`url`, `final_url`, `status_code`) or the video (`video_id`). */
|
|
2195
|
+
export interface InspectionSource {
|
|
2196
|
+
url?: string;
|
|
2197
|
+
/** The URL after redirects. */
|
|
2198
|
+
final_url?: string;
|
|
2199
|
+
/** The HTTP status the site answered for the page. */
|
|
2200
|
+
status_code?: number;
|
|
2201
|
+
video_id?: string;
|
|
2202
|
+
}
|
|
2203
|
+
export interface InspectionSize {
|
|
2204
|
+
width: number;
|
|
2205
|
+
height: number;
|
|
2206
|
+
}
|
|
2207
|
+
export interface InspectionWindow {
|
|
2208
|
+
/** The time of frame 0. Frame i is at `from_ms + round(i * 1000 / fps)`. */
|
|
2209
|
+
from_ms: number;
|
|
2210
|
+
duration_ms: number;
|
|
2211
|
+
fps: number;
|
|
2212
|
+
frames: number;
|
|
2213
|
+
/** The frame size in `units`, the viewport for a page and the video's size for a video. */
|
|
2214
|
+
viewport: InspectionSize;
|
|
2215
|
+
/** What every position and size in the answer is measured in. */
|
|
2216
|
+
units: "css_px" | "video_px";
|
|
2217
|
+
}
|
|
2218
|
+
export interface InspectionStep {
|
|
2219
|
+
/** The step's path in the request, such as `steps/0`. */
|
|
2220
|
+
path: string;
|
|
2221
|
+
kind: string;
|
|
2222
|
+
/** When it started (a click's press). */
|
|
2223
|
+
t_ms: number;
|
|
2224
|
+
/** When it ended. */
|
|
2225
|
+
end_ms: number;
|
|
2226
|
+
}
|
|
2227
|
+
/** A box in `window.units`. `name` is set on the two regions the sheet crops, `R1` and `R2`. */
|
|
2228
|
+
export interface InspectionRegion {
|
|
2229
|
+
x: number;
|
|
2230
|
+
y: number;
|
|
2231
|
+
w: number;
|
|
2232
|
+
h: number;
|
|
2233
|
+
name?: "R1" | "R2";
|
|
2234
|
+
}
|
|
2235
|
+
export interface InspectionRect {
|
|
2236
|
+
x: number;
|
|
2237
|
+
y: number;
|
|
2238
|
+
w: number;
|
|
2239
|
+
h: number;
|
|
2240
|
+
}
|
|
2241
|
+
/**
|
|
2242
|
+
* What changed from each frame to the next. A pixel changed when its luma moved by more than 24 levels; frames are read on a 2 px grid. Times are `t_ms` in the window's clock and frames are indexes from 0.
|
|
2243
|
+
*/
|
|
2244
|
+
export interface InspectionReport {
|
|
2245
|
+
/**
|
|
2246
|
+
* `[frame, share]` for every frame where at least 0.1% of the picture changed against the frame before.
|
|
2247
|
+
*/
|
|
2248
|
+
changed: [number, number, ...unknown[]][];
|
|
2249
|
+
/**
|
|
2250
|
+
* Runs of changed frames, joined across quiet gaps of up to 2 frames at 30 fps (about 67 ms), with their changed regions (16 px cells, at most 4 per event, largest first).
|
|
2251
|
+
*/
|
|
2252
|
+
events: InspectionEvent[];
|
|
2253
|
+
/** Content that moved vertically by more than 2 px from one frame to the next. */
|
|
2254
|
+
shifts: InspectionShift[];
|
|
2255
|
+
/**
|
|
2256
|
+
* A region of at least 0.5% of the picture that changed and came back within 100 ms (A, then B, then A).
|
|
2257
|
+
*/
|
|
2258
|
+
flashes: InspectionFlash[];
|
|
2259
|
+
/**
|
|
2260
|
+
* Frames where at least 40% of the picture was replaced while the frames either side changed by at most 5%.
|
|
2261
|
+
*/
|
|
2262
|
+
cuts: InspectionCut[];
|
|
2263
|
+
/** Three or more frames without a move between two scroll shifts the same way. */
|
|
2264
|
+
stalls: InspectionStall[];
|
|
2265
|
+
/** `[y0, y1)` rows left out of the analysis: a video's caption rows. Left out when none. */
|
|
2266
|
+
masked?: number[][];
|
|
2267
|
+
network?: InspectionNetwork;
|
|
2268
|
+
}
|
|
2269
|
+
export interface InspectionEvent {
|
|
2270
|
+
/** The first changed frame. */
|
|
2271
|
+
t0_ms: number;
|
|
2272
|
+
/** The settled frame, the first one after the last change (the last frame when it never settled). */
|
|
2273
|
+
t1_ms: number;
|
|
2274
|
+
/** The largest changed share in the run. */
|
|
2275
|
+
peak: number;
|
|
2276
|
+
peak_ms: number;
|
|
2277
|
+
/** Changed frames in the run. */
|
|
2278
|
+
frames: number;
|
|
2279
|
+
/** False when the window ended while it was still changing. */
|
|
2280
|
+
settled: boolean;
|
|
2281
|
+
/** The step that started at most 100 ms before the run, such as `steps/0`. */
|
|
2282
|
+
after_step?: string;
|
|
2283
|
+
regions: InspectionRegion[];
|
|
2284
|
+
}
|
|
2285
|
+
export interface InspectionShift {
|
|
2286
|
+
t_ms: number;
|
|
2287
|
+
frame: number;
|
|
2288
|
+
/** How far it moved; positive is down. */
|
|
2289
|
+
dy: number;
|
|
2290
|
+
/** The row, in the frame before, where the moved content starts (0 when `whole`). */
|
|
2291
|
+
from_y: number;
|
|
2292
|
+
/** `scroll` when the page's scroll offset moved by the same amount, else `layout`. */
|
|
2293
|
+
kind: "scroll" | "layout";
|
|
2294
|
+
/** It moved 8 px or more. */
|
|
2295
|
+
large: boolean;
|
|
2296
|
+
/** Everything moved, the top of the picture included. */
|
|
2297
|
+
whole: boolean;
|
|
2298
|
+
}
|
|
2299
|
+
export interface InspectionFlash {
|
|
2300
|
+
t_ms: number;
|
|
2301
|
+
frame: number;
|
|
2302
|
+
/** How long it showed. */
|
|
2303
|
+
ms: number;
|
|
2304
|
+
region: InspectionRegion;
|
|
2305
|
+
/** `lighter` or `darker` when the region's mean luma moved by 16 levels or more. */
|
|
2306
|
+
kind: "lighter" | "darker" | "other";
|
|
2307
|
+
}
|
|
2308
|
+
export interface InspectionCut {
|
|
2309
|
+
t_ms: number;
|
|
2310
|
+
frame: number;
|
|
2311
|
+
/** The share of the picture that changed. */
|
|
2312
|
+
share: number;
|
|
2313
|
+
/** `camera_cut` is a cut the video's camera planned (video source only). */
|
|
2314
|
+
kind: "cut" | "camera_cut";
|
|
2315
|
+
}
|
|
2316
|
+
export interface InspectionStall {
|
|
2317
|
+
/** The first frame without a move. */
|
|
2318
|
+
t0_ms: number;
|
|
2319
|
+
/** The frame where the scroll moved again. */
|
|
2320
|
+
t1_ms: number;
|
|
2321
|
+
frames: number;
|
|
2322
|
+
}
|
|
2323
|
+
/**
|
|
2324
|
+
* How long the page's clock waited on the network (page source only). Network waits are not page time, so they never show in `t_ms`.
|
|
2325
|
+
*/
|
|
2326
|
+
export interface InspectionNetwork {
|
|
2327
|
+
/** Wall-clock ms the page's clock was held while requests were in flight. */
|
|
2328
|
+
held_ms: number;
|
|
2329
|
+
/** How many times it was held. */
|
|
2330
|
+
waits: number;
|
|
2331
|
+
/** Page time run ahead of the window off camera (0 for an inspection, which never runs ahead). */
|
|
2332
|
+
ahead_ms: number;
|
|
2333
|
+
}
|
|
2334
|
+
export interface InspectionTrace {
|
|
2335
|
+
target: InspectionWatchTarget;
|
|
2336
|
+
/** Whether the target matched an element on any frame. */
|
|
2337
|
+
found: boolean;
|
|
2338
|
+
/** The first 40 characters of the element's text or `aria-label`. */
|
|
2339
|
+
label?: string;
|
|
2340
|
+
/**
|
|
2341
|
+
* `[t_ms, x, y, w, h, visible]` in viewport CSS px (to 0.5 px), on the first frame and on every frame where a value changed by 1 px or more or visibility changed. `visible` is false when the element is hidden, has an empty box or lies outside the viewport.
|
|
2342
|
+
*/
|
|
2343
|
+
boxes: [number, number, number, number, number, boolean, ...unknown[]][];
|
|
2344
|
+
/** Each change of the box against the entry before it. */
|
|
2345
|
+
moves: {
|
|
2346
|
+
t_ms: number;
|
|
2347
|
+
dx: number;
|
|
2348
|
+
dy: number;
|
|
2349
|
+
dw: number;
|
|
2350
|
+
dh: number;
|
|
2351
|
+
}[];
|
|
2352
|
+
}
|
|
2353
|
+
export interface InspectionLayoutShift {
|
|
2354
|
+
/** The frame the shift showed on. */
|
|
2355
|
+
t_ms: number;
|
|
2356
|
+
sources: {
|
|
2357
|
+
/** A unique CSS selector for the element that moved. */
|
|
2358
|
+
selector: string;
|
|
2359
|
+
/** The first 40 characters of its text or `aria-label`. */
|
|
2360
|
+
label?: string;
|
|
2361
|
+
from: InspectionRect;
|
|
2362
|
+
to: InspectionRect;
|
|
2363
|
+
}[];
|
|
2364
|
+
}
|
|
2365
|
+
/**
|
|
2366
|
+
* The contact sheet: up to 12 tiles in reading order, each under a black strip with its time, frame, changed share and word tags (`CLICK steps/0`, `SHIFT -29`, `FLASH 67 ms`, `CUT`), changed regions outlined in magenta, then before/after crops of `R1` and `R2`. Tiles go to the first and last frames, flashes, cuts, shifts, the start and end of each event and each step, then where most pixels changed. Positions here are sheet px.
|
|
2367
|
+
*/
|
|
2368
|
+
export interface InspectionSheet {
|
|
2369
|
+
artifact: Artifact;
|
|
2370
|
+
width: number;
|
|
2371
|
+
height: number;
|
|
2372
|
+
/** ceil(width / 28) x ceil(height / 28), the image's cost for a model that reads 28 px patches. */
|
|
2373
|
+
tokens: number;
|
|
2374
|
+
tiles: InspectionTile[];
|
|
2375
|
+
crops: InspectionCrop[];
|
|
2376
|
+
}
|
|
2377
|
+
export interface InspectionTile {
|
|
2378
|
+
frame: number;
|
|
2379
|
+
t_ms: number;
|
|
2380
|
+
x: number;
|
|
2381
|
+
y: number;
|
|
2382
|
+
w: number;
|
|
2383
|
+
h: number;
|
|
2384
|
+
tags: string[];
|
|
2385
|
+
}
|
|
2386
|
+
/**
|
|
2387
|
+
* One region before and after its change, the region plus 16 px around it, scaled by `scale` (at most 2). Before is the frame just before the change; after is its settled frame (for a flash, the flash frame).
|
|
2388
|
+
*/
|
|
2389
|
+
export interface InspectionCrop {
|
|
2390
|
+
region: "R1" | "R2";
|
|
2391
|
+
before_ms: number;
|
|
2392
|
+
after_ms: number;
|
|
2393
|
+
scale: number;
|
|
2394
|
+
/** The part of the frame shown, in `window.units`. */
|
|
2395
|
+
area: InspectionRegion;
|
|
2396
|
+
/** Where the before panel is on the sheet. */
|
|
2397
|
+
before: InspectionRect;
|
|
2398
|
+
/** Where the after panel is on the sheet. */
|
|
2399
|
+
after: InspectionRect;
|
|
2400
|
+
}
|
|
1868
2401
|
export interface Artifact {
|
|
1869
2402
|
id: string;
|
|
1870
2403
|
object: "artifact";
|
|
@@ -2004,9 +2537,21 @@ export interface VideoOutput {
|
|
|
2004
2537
|
fps: 24 | 25 | 30 | 50 | 60;
|
|
2005
2538
|
}
|
|
2006
2539
|
export type VideoFormat = "mp4" | "gif" | "poster";
|
|
2540
|
+
/**
|
|
2541
|
+
* Give exactly one of `beats` and `goal` (422 `script_invalid` at `/goal` otherwise). `goal` takes no `source.profile` (422 `script_invalid` at `/source/profile`): a goal is planned on public pages only.
|
|
2542
|
+
*/
|
|
2007
2543
|
export interface VideoCreateRequest {
|
|
2008
2544
|
source: VideoSource;
|
|
2009
|
-
|
|
2545
|
+
/** The script, one beat per line of narration. Leave it out and give `goal` to have the node plan it. */
|
|
2546
|
+
beats?: Beat[];
|
|
2547
|
+
/**
|
|
2548
|
+
* What the video should show, in a sentence ("Show how to open billing and switch the plan to annual").
|
|
2549
|
+
* The node plans the beats from the start page (the operation's description says how) and the video
|
|
2550
|
+
* shows them in `goal`. Needs `vision:run` and `infer:run` besides `render:run`. Not with
|
|
2551
|
+
* `source.profile`: a goal is planned on public pages only.
|
|
2552
|
+
*/
|
|
2553
|
+
goal?: string;
|
|
2554
|
+
alias?: VideoAliasName;
|
|
2010
2555
|
/**
|
|
2011
2556
|
* The narration voice. Leave it out and every beat with `say` is narrated in the node's default voice,
|
|
2012
2557
|
* `kokoro-82m` `af_heart`, normalized to -16 LUFS. Narration is speech made as the caller, so it needs
|
|
@@ -2338,6 +2883,7 @@ export interface RecordingInfo {
|
|
|
2338
2883
|
recorded_at?: string;
|
|
2339
2884
|
}
|
|
2340
2885
|
export interface VideoRestyleRequest {
|
|
2886
|
+
alias?: VideoAliasName;
|
|
2341
2887
|
style?: RenderStyle;
|
|
2342
2888
|
captions?: CaptionOptions;
|
|
2343
2889
|
output?: VideoOutput;
|
|
@@ -2349,23 +2895,137 @@ export interface VideoShareRequest {
|
|
|
2349
2895
|
/** The page title and preview title. Default the first beat's `title`, else "Video". */
|
|
2350
2896
|
title?: string;
|
|
2351
2897
|
}
|
|
2898
|
+
/**
|
|
2899
|
+
* A public share of a video or an alias. Its URLs are on `usercontent.b3os.org` and need no key:
|
|
2900
|
+
*
|
|
2901
|
+
* - `/s/<share id>`: the player page (HTML, Open Graph and JSON-LD for link previews, its own iframe embed).
|
|
2902
|
+
* Query parameters shape the player: `autoplay=1` (starts muted, as browsers require), `muted=1`, `loop=1`,
|
|
2903
|
+
* `controls=0` and `t=<seconds>` (0 to 86400, where it starts); others are ignored.
|
|
2904
|
+
* - `/s/<share id>/<file>`: the share's current file (`video.mp4`, `poster.jpg`, `video.gif`,
|
|
2905
|
+
* `captions.vtt`, `chapters.vtt`), the URLs in `media`. For an alias share they change bytes when the alias
|
|
2906
|
+
* moves (the `ETag` changes with them).
|
|
2907
|
+
* - `/s/<share id>/v/<video host id>/<file>`: a file of one video, which the page itself plays, so a player
|
|
2908
|
+
* keeps one video's bytes. For an alias, the video it left stays served for an hour after it moves.
|
|
2909
|
+
* - `/oembed?url=<share URL>` (`oembed_url`): the oEmbed answer (JSON, type `video`), an iframe of the page at
|
|
2910
|
+
* most 960 wide (`maxwidth` and `maxheight` make it smaller) plus a 32-pixel footer.
|
|
2911
|
+
*
|
|
2912
|
+
* A stopped, expired or taken-down share answers 404 on its files and oEmbed, and a short page on its own URL
|
|
2913
|
+
* (404, 410 for a video that expired, 451 when B3 took it down). Every answer may be cached for 60 seconds at
|
|
2914
|
+
* most, and each address may make 600 requests a minute (`render.share.address.rpm`).
|
|
2915
|
+
*/
|
|
2352
2916
|
export interface VideoShare {
|
|
2353
2917
|
object: "video_share";
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2918
|
+
/** The share ID. Unguessable (128 random bits); its host-safe form (`shr-…`) is in `url`. */
|
|
2919
|
+
id: string;
|
|
2920
|
+
/** The video it plays now (for an alias share, the one the alias points at; `null` when none). */
|
|
2921
|
+
video_id: string | null;
|
|
2922
|
+
/** The alias for an alias share, else `null`. */
|
|
2923
|
+
alias: string | null;
|
|
2357
2924
|
title: string;
|
|
2358
|
-
/** The share page,
|
|
2925
|
+
/** The share page, `https://usercontent.b3os.org/s/shr-…`. */
|
|
2359
2926
|
url: string;
|
|
2360
|
-
/**
|
|
2927
|
+
/**
|
|
2928
|
+
* An `<iframe>` of the page, ready to paste: 960 pixels wide (less for a narrower video) at the video's aspect ratio plus the page's 32-pixel footer.
|
|
2929
|
+
*/
|
|
2361
2930
|
embed_html: string;
|
|
2931
|
+
/** The oEmbed answer for `url`. */
|
|
2932
|
+
oembed_url: string;
|
|
2933
|
+
media: VideoShareMedia;
|
|
2362
2934
|
/** The video's width in pixels. */
|
|
2363
2935
|
width: number;
|
|
2364
2936
|
/** The video's height in pixels. */
|
|
2365
2937
|
height: number;
|
|
2366
2938
|
created_at: string;
|
|
2367
|
-
/**
|
|
2368
|
-
|
|
2939
|
+
/**
|
|
2940
|
+
* When the share ends: the video's own expiry for a video share (`null` while an alias keeps the video, as the video's own `expires_at` is then); `null` for an alias share, which lasts as long as the alias.
|
|
2941
|
+
*/
|
|
2942
|
+
expires_at: string | null;
|
|
2943
|
+
/**
|
|
2944
|
+
* `true` when B3 took the share down: its page answers 451 and its files and oEmbed 404, and sharing it again answers 403 `share_blocked` until B3 lifts the takedown. The reason is not shown; write to abuse@b3os.org to ask about it. The node learns of a takedown within about 10 minutes.
|
|
2945
|
+
*/
|
|
2946
|
+
blocked: boolean;
|
|
2947
|
+
}
|
|
2948
|
+
/** Stable URLs of the share's files, for a README image or a `<video>` written by hand. */
|
|
2949
|
+
export interface VideoShareMedia {
|
|
2950
|
+
mp4: string;
|
|
2951
|
+
poster?: string;
|
|
2952
|
+
gif?: string;
|
|
2953
|
+
/** WebVTT captions. */
|
|
2954
|
+
captions?: string;
|
|
2955
|
+
/** WebVTT chapters (beat titles). */
|
|
2956
|
+
chapters?: string;
|
|
2957
|
+
}
|
|
2958
|
+
export interface VideoShareRef {
|
|
2959
|
+
id: string;
|
|
2960
|
+
url: string;
|
|
2961
|
+
/**
|
|
2962
|
+
* `true` when B3 took the share down (its page answers 451); the reason is not shown. See `VideoShare.blocked`.
|
|
2963
|
+
*/
|
|
2964
|
+
blocked: boolean;
|
|
2965
|
+
}
|
|
2966
|
+
/**
|
|
2967
|
+
* Tags the video with this alias of the project and makes the alias if it does not exist. When the video
|
|
2968
|
+
* succeeds, the alias points at it (unless it is pinned, or a newer tagged video already succeeded), and the
|
|
2969
|
+
* video is kept past the 7-day retention while it does. Its files count toward `render.kept.bytes`; a video
|
|
2970
|
+
* that would pass that limit still succeeds but is kept 7 days, leaves the alias where it was and warns
|
|
2971
|
+
* `alias_storage`. A new alias past `render.aliases.max` answers 422 `limit_exceeded`. Needs `render:write`
|
|
2972
|
+
* (a tag can change what a live share plays). A video recorded with `source.profile` never moves an alias that
|
|
2973
|
+
* has a share: it warns `alias_signed_in`, and `PUT` with `video_id` moves the alias to it.
|
|
2974
|
+
*/
|
|
2975
|
+
export type VideoAliasName = string;
|
|
2976
|
+
export interface VideoAliasPutRequest {
|
|
2977
|
+
/** Point the alias at this tagged, succeeded video and pin it there (`follow` becomes `false`). */
|
|
2978
|
+
video_id?: string;
|
|
2979
|
+
/**
|
|
2980
|
+
* `true`: move to the newest succeeded tagged video now and with every later one. `false`: stay where it is. With `video_id`, only `false` may be given.
|
|
2981
|
+
*/
|
|
2982
|
+
follow?: boolean;
|
|
2983
|
+
}
|
|
2984
|
+
export interface VideoAlias {
|
|
2985
|
+
object: "video_alias";
|
|
2986
|
+
id: string;
|
|
2987
|
+
name: VideoAliasName;
|
|
2988
|
+
/** The video the alias points at, kept while it does; `null` before one succeeded. */
|
|
2989
|
+
video_id: string | null;
|
|
2990
|
+
/** Whether a newly succeeded tagged video moves the alias (`false` after `PUT` with `video_id`). */
|
|
2991
|
+
follow: boolean;
|
|
2992
|
+
/** The newest 20 videos tagged with the alias, newest first, expired ones left out. */
|
|
2993
|
+
videos: {
|
|
2994
|
+
video_id: string;
|
|
2995
|
+
status: JobStatus;
|
|
2996
|
+
created_at: string;
|
|
2997
|
+
}[];
|
|
2998
|
+
/** The alias's share, if any; `blocked` says when B3 took it down. */
|
|
2999
|
+
share: VideoShare | null;
|
|
3000
|
+
created_at: string;
|
|
3001
|
+
updated_at: string;
|
|
3002
|
+
}
|
|
3003
|
+
export type VideoAliasList = Omit<ListEnvelope, "data"> & {
|
|
3004
|
+
data: VideoAlias[];
|
|
3005
|
+
};
|
|
3006
|
+
/**
|
|
3007
|
+
* A video made from a `goal`: what was asked and the beats the node planned. `state` is `drafting` while the
|
|
3008
|
+
* job's draft phase runs, `drafted` once the beats are planned (they are then the video's script), `failed`
|
|
3009
|
+
* when planning failed (the job's `error` is `goal_unplanned`).
|
|
3010
|
+
*/
|
|
3011
|
+
export interface VideoGoal {
|
|
3012
|
+
/** The goal as given. */
|
|
3013
|
+
text: string;
|
|
3014
|
+
state: "drafting" | "drafted" | "failed";
|
|
3015
|
+
/** The planned beats; send them as `beats` to record the same steps again. */
|
|
3016
|
+
beats?: Beat[];
|
|
3017
|
+
/** Whether the planned steps ran once in a browser before recording. */
|
|
3018
|
+
checked?: boolean;
|
|
3019
|
+
/** Steps the model wrote that the page could not run, left out of `beats`. */
|
|
3020
|
+
dropped?: number;
|
|
3021
|
+
/** Buttons, links and fields the start page listed. */
|
|
3022
|
+
controls?: number;
|
|
3023
|
+
/** Controls the planned steps revealed that the start page did not show (a form, the next page). */
|
|
3024
|
+
more?: number;
|
|
3025
|
+
/** The chat model that planned the beats. */
|
|
3026
|
+
model?: string;
|
|
3027
|
+
/** How long planning took. */
|
|
3028
|
+
plan_ms?: number;
|
|
2369
3029
|
}
|
|
2370
3030
|
export interface VideoResult {
|
|
2371
3031
|
duration_ms: number;
|
|
@@ -2383,7 +3043,7 @@ export interface VideoResult {
|
|
|
2383
3043
|
recording?: RecordingInfo;
|
|
2384
3044
|
narration?: NarrationInfo;
|
|
2385
3045
|
/**
|
|
2386
|
-
* Non-fatal problems, each starting with a code and a colon: `narration_scope` (the beats' `say` lines were not spoken because the key lacks `infer:run`, which narration needs; the video has no narration track); `page_requests` (requests for the page's code, styles or fonts, or for its own site's data, made while the video was captured, were not in the network recording made when it loaded, so they failed and the video can show a page that did not finish loading; up to three are named, without their query; trackers, beacons and prefetches that fail the same way are not counted); `zoom_soft` (the page drew differently between two parts of the capture and the video could not be captured again whole, so from the time it names on the video comes from a lower device scale and its zooms are softer than the page); `background_fallback` (the library image the `auto` background or `background_ref: "auto"` chose could not be loaded in time; the video was drawn on the studio pick, or the style's own background, and a restyle tries again); `scroll_round_trip` (the steps make the page scroll down and back up, or up and back down, within 4 s and no one scroll position shows every element they act on, so the video runs both scrolls; the timeline's `warnings` has the code too); `auto_background_pin` (the project's, organization's or node's `auto_background` pin does not clear the first frame's edges, so `auto` picked another image; it names both). A restyle repeats its source's, except `background_fallback`, which it decides again, and `auto_background_pin`, which it repeats only when it draws the source's image again (a restyle that picks the background again says its own, and one that draws another background says none). Absent when there is nothing to say.
|
|
3046
|
+
* Non-fatal problems, each starting with a code and a colon: `narration_scope` (the beats' `say` lines were not spoken because the key lacks `infer:run`, which narration needs; the video has no narration track); `page_requests` (requests for the page's code, styles or fonts, or for its own site's data, made while the video was captured, were not in the network recording made when it loaded, so they failed and the video can show a page that did not finish loading; up to three are named, without their query; trackers, beacons and prefetches that fail the same way are not counted); `zoom_soft` (the page drew differently between two parts of the capture and the video could not be captured again whole, so from the time it names on the video comes from a lower device scale and its zooms are softer than the page); `background_fallback` (the library image the `auto` background or `background_ref: "auto"` chose could not be loaded in time; the video was drawn on the studio pick, or the style's own background, and a restyle tries again); `scroll_round_trip` (the steps make the page scroll down and back up, or up and back down, within 4 s and no one scroll position shows every element they act on, so the video runs both scrolls; the timeline's `warnings` has the code too); `auto_background_pin` (the project's, organization's or node's `auto_background` pin does not clear the first frame's edges, so `auto` picked another image; it names both); `alias_storage` (the video is tagged with an alias but its files would pass the organization's `render.kept.bytes`, so it is kept 7 days like any video and the alias did not move to it); `alias_signed_in` (the video was recorded with `source.profile` and its alias has a share, so the alias did not move to it; `PUT /v1/render/aliases/{alias}` with `video_id` moves it); `alias_unshareable` (the video's MP4 is larger than the node uploads to storage, from which shares serve files, so the alias did not move to it); `goal_steps_dropped` (the goal's planned steps that the page could not run were left out; it says how many). A restyle repeats its source's, except `background_fallback`, which it decides again, and `auto_background_pin`, which it repeats only when it draws the source's image again (a restyle that picks the background again says its own, and one that draws another background says none). Absent when there is nothing to say.
|
|
2387
3047
|
*/
|
|
2388
3048
|
warnings?: string[];
|
|
2389
3049
|
auto_background?: AutoBackgroundChoice;
|
|
@@ -2400,7 +3060,11 @@ export interface NarrationInfo {
|
|
|
2400
3060
|
/** Why the narration was not spoken (only when `spoken` is false). */
|
|
2401
3061
|
reason?: string;
|
|
2402
3062
|
}
|
|
2403
|
-
/**
|
|
3063
|
+
/**
|
|
3064
|
+
* A video job (`vid_…`). `progress` counts phases (voice, plan, capture, compose, encode, upload; a video made
|
|
3065
|
+
* from a `goal` starts with draft). While an alias points at the video (`kept_by_alias`), `expires_at` is
|
|
3066
|
+
* `null`: the video is kept until the alias moves on, then for 24 hours more.
|
|
3067
|
+
*/
|
|
2404
3068
|
export type Video = Omit<Job, "id" | "object" | "result"> & {
|
|
2405
3069
|
id: string;
|
|
2406
3070
|
object: "video";
|
|
@@ -2414,6 +3078,15 @@ export type Video = Omit<Job, "id" | "object" | "result"> & {
|
|
|
2414
3078
|
*/
|
|
2415
3079
|
queue_position?: number;
|
|
2416
3080
|
result?: VideoResult;
|
|
3081
|
+
/** The alias the video was created or restyled with, if any. */
|
|
3082
|
+
alias?: string | null;
|
|
3083
|
+
/** The alias that points at the video and keeps it past the retention, if any. */
|
|
3084
|
+
kept_by_alias?: string | null;
|
|
3085
|
+
/**
|
|
3086
|
+
* The video's own share, if any (`POST /v1/render/videos/{video_id}/share`); `blocked: true` when B3 took it down.
|
|
3087
|
+
*/
|
|
3088
|
+
share?: VideoShareRef | null;
|
|
3089
|
+
goal?: VideoGoal;
|
|
2417
3090
|
};
|
|
2418
3091
|
export type VideoList = Omit<ListEnvelope, "data"> & {
|
|
2419
3092
|
data: Video[];
|
|
@@ -2421,11 +3094,16 @@ export type VideoList = Omit<ListEnvelope, "data"> & {
|
|
|
2421
3094
|
/**
|
|
2422
3095
|
* An event of a video's stream. `job.queued` carries `queue_position` when the video waits for a slot (its
|
|
2423
3096
|
* place when it was created; the video itself has the current one); `video.phase` carries `phase`;
|
|
3097
|
+
* `video.drafted` (a video made from a `goal`) carries the planned `beats`, `checked`, `dropped` and `model`;
|
|
2424
3098
|
* `video.artifact` carries `artifact` (without a signed URL; fetch the artifact or the video for one).
|
|
2425
3099
|
*/
|
|
2426
3100
|
export type VideoEvent = JobEvent & {
|
|
2427
3101
|
queue_position?: number;
|
|
2428
|
-
phase?: "voice" | "plan" | "capture" | "compose" | "encode" | "upload";
|
|
3102
|
+
phase?: "draft" | "voice" | "plan" | "capture" | "compose" | "encode" | "upload";
|
|
3103
|
+
beats?: Beat[];
|
|
3104
|
+
checked?: boolean;
|
|
3105
|
+
dropped?: number;
|
|
3106
|
+
model?: string;
|
|
2429
3107
|
artifact?: Artifact;
|
|
2430
3108
|
};
|
|
2431
3109
|
/**
|
|
@@ -3173,9 +3851,9 @@ export type RenderBackgroundPackList = Omit<ListEnvelope, "data"> & {
|
|
|
3173
3851
|
data: RenderBackgroundPack[];
|
|
3174
3852
|
};
|
|
3175
3853
|
/**
|
|
3176
|
-
* `running` → `paused` ↔ `running` → `stopped`. `failed` means the microVM crashed; its usage is final.
|
|
3854
|
+
* `running` → `paused` ↔ `running` → `stopped`. `failed` means the microVM crashed; its usage is final. `hibernated` is an agent instance's microVM written to the node's disk with no process left (only agent instances, `/v1/agents`): its memory snapshot, which a message to its instance or a request to its port restores in place, or its disk alone (dormant), which a message to its instance boots. It is never listed.
|
|
3177
3855
|
*/
|
|
3178
|
-
export type SandboxStatus = "running" | "paused" | "stopped" | "failed";
|
|
3856
|
+
export type SandboxStatus = "running" | "paused" | "stopped" | "failed" | "hibernated";
|
|
3179
3857
|
/**
|
|
3180
3858
|
* A value placed in the environment but never returned or logged; either the value itself or a field of a vault connection.
|
|
3181
3859
|
*/
|
|
@@ -3189,6 +3867,11 @@ export type SecretValue = string | {
|
|
|
3189
3867
|
field?: string;
|
|
3190
3868
|
};
|
|
3191
3869
|
export interface SandboxPort {
|
|
3870
|
+
/**
|
|
3871
|
+
* The port the app listens on inside the sandbox. Not 53, 1080, 3128, 7700 or 15001: the B3OS guest agent
|
|
3872
|
+
* listens on those in every sandbox (its API proxy, egress proxies and DNS), so they are never proxied and
|
|
3873
|
+
* a create that declares one is `400 invalid_request`.
|
|
3874
|
+
*/
|
|
3192
3875
|
port: number;
|
|
3193
3876
|
/**
|
|
3194
3877
|
* Reachable by anyone with the sandbox's long-lived port URL (`ports[].url` in the sandbox; its token lasts 7
|
|
@@ -3204,6 +3887,14 @@ export interface SandboxPort {
|
|
|
3204
3887
|
* @default 65
|
|
3205
3888
|
*/
|
|
3206
3889
|
first_byte_s?: number;
|
|
3890
|
+
/**
|
|
3891
|
+
* The port has an app address (`<label>.b3os.io`); `b3os apply` sets it on such a port and keeps the port
|
|
3892
|
+
* private (no long-lived URL). The sandbox then counts as reachable from the internet for as long as it
|
|
3893
|
+
* lives, as with a public port: code in another sandbox whose egress is not `public` cannot reach into it,
|
|
3894
|
+
* and code in such a sandbox cannot start one with an addressed port (`403 egress_escalation`).
|
|
3895
|
+
* @default false
|
|
3896
|
+
*/
|
|
3897
|
+
addressed?: boolean;
|
|
3207
3898
|
}
|
|
3208
3899
|
/**
|
|
3209
3900
|
* What code inside the sandbox may call at `http://127.0.0.1:7700`. Empty by default, revoked when the sandbox stops.
|
|
@@ -3222,7 +3913,28 @@ export interface SandboxApiGrant {
|
|
|
3222
3913
|
spend_cap_usd?: number | null;
|
|
3223
3914
|
/** Vault connections the sandbox's action calls may use. */
|
|
3224
3915
|
connections?: string[];
|
|
3916
|
+
actions?: SandboxActionsRule;
|
|
3225
3917
|
}
|
|
3918
|
+
/**
|
|
3919
|
+
* Which pack actions code in the sandbox may call (`POST /v1/actions/call`) and which it gets as tools over MCP
|
|
3920
|
+
* (`POST /v1/actions/mcp`, at `B3OS_MCP_URL`, which the node sets when `allow` names an entry and the grant
|
|
3921
|
+
* holds `actions:read`). Without it (the default, or `null`), the creating principal's rule: none for an API
|
|
3922
|
+
* key, so any action your scopes allow; a sandbox's own rule for the sandboxes it creates, which may only
|
|
3923
|
+
* narrow it (`403 forbidden`, `reason: scope_escalation`). A call outside the rule is refused with
|
|
3924
|
+
* `403 action_not_allowed` before anything is read, bound or billed. `b3os apply` and the GitHub App write one
|
|
3925
|
+
* entry per pack a service declares in `uses`, at the version `actions.packs` gives, so a service calls the
|
|
3926
|
+
* tools it declared and no other pack. A routine run the sandbox starts runs as its publisher within the rule
|
|
3927
|
+
* (a step outside it fails with `action_not_allowed`), and the sandbox signals or sends events only to runs
|
|
3928
|
+
* within its rule. Read routes (describe, the pack and tools routes) are not bounded.
|
|
3929
|
+
*/
|
|
3930
|
+
export type SandboxActionsRule = {
|
|
3931
|
+
/**
|
|
3932
|
+
* `<namespace>/<name>/<action>[@<version>]`: `<action>` an action key or `*` (every action of the pack),
|
|
3933
|
+
* `<version>` an exact version or a range (`1.0.1`, `1`, `1.2`, `^1.2`); without one, any version. A call
|
|
3934
|
+
* that names a range runs the newest allowed version it admits. Empty: no pack action at all.
|
|
3935
|
+
*/
|
|
3936
|
+
allow: string[];
|
|
3937
|
+
} | null;
|
|
3226
3938
|
/**
|
|
3227
3939
|
* Where sandbox traffic may go, enforced by the node's egress guard. `public` (default): any public internet
|
|
3228
3940
|
* address. `allowlist`: only hosts matching `allow` (exact hosts or `*.` wildcards). `deny`: no outbound
|
|
@@ -3241,14 +3953,21 @@ export interface EgressPolicy {
|
|
|
3241
3953
|
}
|
|
3242
3954
|
export interface SandboxCreateRequest {
|
|
3243
3955
|
/**
|
|
3244
|
-
* Template name or `tpl_` ID
|
|
3956
|
+
* 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`). Ignored when `snapshot` is set.
|
|
3245
3958
|
* @default "base"
|
|
3246
3959
|
*/
|
|
3247
3960
|
template?: string;
|
|
3248
3961
|
/** Restore this snapshot instead of starting from a template. */
|
|
3249
3962
|
snapshot?: string;
|
|
3963
|
+
/**
|
|
3964
|
+
* Start from one of your project's imported images (`POST /v1/images`), once it is `ready`. Needs the
|
|
3965
|
+
* `images.import` flag on for your organization. Not with `template` or `snapshot` (`400 invalid_request`).
|
|
3966
|
+
*/
|
|
3967
|
+
image?: string;
|
|
3250
3968
|
/**
|
|
3251
3969
|
* Virtual CPUs; defaults to the template's (`defaults.vcpu`), at most your plan's `sandboxes.vcpu_max`.
|
|
3970
|
+
* A sandbox from an image has the image's size: any other value answers `400 invalid_request`.
|
|
3252
3971
|
* A microVM cannot change its vCPU count, so sandboxes come from pools per size: a create at one of the
|
|
3253
3972
|
* template's `size_classes` claims a pre-warmed microVM, any other size is restored on demand (a pool
|
|
3254
3973
|
* miss: tens of milliseconds, plus about two seconds the first time a node sees that size). A node
|
|
@@ -3320,33 +4039,134 @@ export interface SandboxCreateRequest {
|
|
|
3320
4039
|
* `X-B3OS-Options` header.
|
|
3321
4040
|
*/
|
|
3322
4041
|
clone_reset?: "full" | "none";
|
|
4042
|
+
/**
|
|
4043
|
+
* A volume to mount (`POST /v1/sandboxes/volumes`), held by this sandbox alone until it ends: at most one in
|
|
4044
|
+
* this beta (mount several of its folders with `subpath`). A volume another running or paused sandbox
|
|
4045
|
+
* holds is `409 volume_in_use`. The sandbox cannot be snapshotted or forked (`409 volume_attached`), and
|
|
4046
|
+
* `forkable: true` is refused. When the sandbox ends, its guest syncs and unmounts the volume first; the
|
|
4047
|
+
* volume is free for the next sandbox once the microVM has exited.
|
|
4048
|
+
*/
|
|
4049
|
+
volumes?: VolumeAttach[];
|
|
4050
|
+
owner?: SandboxOwner;
|
|
3323
4051
|
metadata?: Metadata;
|
|
3324
4052
|
}
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
port?: number;
|
|
3335
|
-
/** A shell command line (run with `/bin/sh -c`) or an argv array. */
|
|
3336
|
-
cmd?: string | string[];
|
|
3337
|
-
/** @default 10 */
|
|
3338
|
-
interval_ms?: number;
|
|
3339
|
-
/** @default 60 */
|
|
3340
|
-
timeout_s?: number;
|
|
4053
|
+
export interface VolumeAttach {
|
|
4054
|
+
/** The volume's `vol_` ID or name. */
|
|
4055
|
+
volume: string;
|
|
4056
|
+
mounts: VolumeMount[];
|
|
4057
|
+
/**
|
|
4058
|
+
* `uid` or `uid:gid` that owns the volume's root and each subpath folder when they are first made; default,
|
|
4059
|
+
* the account commands run as (`user`, uid 1000, or an image's `USER`). Later mounts change no owner.
|
|
4060
|
+
*/
|
|
4061
|
+
owner?: string;
|
|
3341
4062
|
}
|
|
3342
|
-
export interface
|
|
3343
|
-
/**
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
4063
|
+
export interface VolumeMount {
|
|
4064
|
+
/**
|
|
4065
|
+
* Where the folder appears in the sandbox: absolute, not `/`, not a system folder or under one (`/proc`,
|
|
4066
|
+
* `/sys`, `/dev`, `/run`, `/etc`, `/usr`, `/boot`, `/bin`, `/sbin`, `/lib*`, `/mnt`, `/var/run`); mount under
|
|
4067
|
+
* `/workspace`, `/data`, `/home`, `/srv`, `/opt` or `/var/lib`. Two mounts of a sandbox never overlap.
|
|
4068
|
+
*/
|
|
4069
|
+
path: string;
|
|
4070
|
+
/** A folder of the volume (made on first use); empty or absent for the volume's root. */
|
|
4071
|
+
subpath?: string;
|
|
4072
|
+
/** @default false */
|
|
4073
|
+
read_only?: boolean;
|
|
4074
|
+
}
|
|
4075
|
+
export interface SandboxVolume {
|
|
4076
|
+
volume_id: string;
|
|
4077
|
+
name: string;
|
|
4078
|
+
mounts: VolumeMount[];
|
|
4079
|
+
owner?: string | null;
|
|
4080
|
+
}
|
|
4081
|
+
export interface Volume {
|
|
4082
|
+
id: string;
|
|
4083
|
+
object: "volume";
|
|
4084
|
+
name: string;
|
|
4085
|
+
size_gib: number;
|
|
4086
|
+
/**
|
|
4087
|
+
* `attached` from the create of the sandbox that holds it until that sandbox's microVM has exited; `deleted` until `purge_at`.
|
|
4088
|
+
*/
|
|
4089
|
+
status: "available" | "attached" | "deleted";
|
|
4090
|
+
attached_to: null | {
|
|
4091
|
+
sandbox_id: string;
|
|
4092
|
+
since: string;
|
|
4093
|
+
};
|
|
4094
|
+
/** What the volume's file system held at its last mount or stats read; null before its first mount. */
|
|
4095
|
+
used_bytes: number | null;
|
|
4096
|
+
metadata: Metadata;
|
|
4097
|
+
created_at: string;
|
|
4098
|
+
deleted_at: string | null;
|
|
4099
|
+
/** When a deleted volume and its data are removed for good. */
|
|
4100
|
+
purge_at: string | null;
|
|
4101
|
+
}
|
|
4102
|
+
export type VolumeList = Omit<ListEnvelope, "data"> & {
|
|
4103
|
+
data: Volume[];
|
|
4104
|
+
};
|
|
4105
|
+
export interface VolumeCreateRequest {
|
|
4106
|
+
/** Unique among the project's volumes, deleted ones included until they are purged. */
|
|
4107
|
+
name: string;
|
|
4108
|
+
/** At most your plan's `sandboxes.volume_max`. */
|
|
4109
|
+
size_gib: number;
|
|
4110
|
+
metadata?: Metadata;
|
|
4111
|
+
}
|
|
4112
|
+
export interface VolumeUpdateRequest {
|
|
4113
|
+
/** A larger size; a volume never shrinks. */
|
|
4114
|
+
size_gib?: number;
|
|
4115
|
+
metadata?: Metadata;
|
|
4116
|
+
}
|
|
4117
|
+
export interface VolumePurgeRequest {
|
|
4118
|
+
/** The volume's name. */
|
|
4119
|
+
confirm: string;
|
|
4120
|
+
}
|
|
4121
|
+
/**
|
|
4122
|
+
* Who the sandbox belongs to, which decides what its key can do to it.
|
|
4123
|
+
*
|
|
4124
|
+
* - `key` (the default): the sandbox acts as the key that created it. It stops when that key is revoked or
|
|
4125
|
+
* expires (`stop_reason: revoked`), and its B3OS calls count toward the key's spend cap: an agent's sandbox
|
|
4126
|
+
* lives no longer than the credential that made it.
|
|
4127
|
+
* - `project`: a service of an application. It acts as its project, within its `api` grant (scopes and
|
|
4128
|
+
* connections), and holds no key: a key's expiry or revoke never stops it. The key that created it is kept as
|
|
4129
|
+
* `created_by_key`. Its spend cap: with `api.spend_cap_usd`, that cap, its own; without one, the creating
|
|
4130
|
+
* key's cap, shared with everything else that key runs: its usage counts toward that key's `spent_usd`, and
|
|
4131
|
+
* the key's cap stops it (`stop_reason: budget`), also after the key is revoked or expires. Both caps count
|
|
4132
|
+
* the whole billing period and survive restarts of the node. What else stops it: its organization suspended or
|
|
4133
|
+
* out of credits (`budget`), a delete or a take down (`deleted`), and B3. Needs `metadata."b3os.app"` (`400
|
|
4134
|
+
* invalid_request` otherwise), so it is listed under its application with a Take down, and an outside caller
|
|
4135
|
+
* (an API key, a CLI token, the console): a sandbox's own credential gets `403 forbidden` with `reason:
|
|
4136
|
+
* sandbox`, a routine run `reason: routine`. `b3os apply` (CLI 0.2.2) and the GitHub App create services this
|
|
4137
|
+
* way. A fork of it belongs to the key that forks it.
|
|
4138
|
+
*
|
|
4139
|
+
* What a service's own code starts (a create or a fork with the service's credential) is the service's:
|
|
4140
|
+
* `owner: project`, `parent` its creator and `root` the service. It holds no key either, and it ends when
|
|
4141
|
+
* the service ends (`stop_reason: revoked`), however long its own timeout or lease, so a take down reaches
|
|
4142
|
+
* everything a service started.
|
|
4143
|
+
*/
|
|
4144
|
+
export type SandboxOwner = "key" | "project";
|
|
4145
|
+
/**
|
|
4146
|
+
* When the sandbox counts as ready: a TCP port inside it accepting connections (`port`), or a command that
|
|
4147
|
+
* exits 0 (`cmd`, run as `user` with a 5 s limit per try). Set exactly one. The node tries it every
|
|
4148
|
+
* `interval_ms` from the moment it is set until it passes or `timeout_s` runs out; the sandbox's `readiness`
|
|
4149
|
+
* reports the result and `POST /v1/sandboxes/{sandbox_id}/ready` waits for it. Probing goes on across a
|
|
4150
|
+
* restart of the node's daemon, within the same `timeout_s`; `attempts` counts the tries since the daemon
|
|
4151
|
+
* last recorded a change of `status`, so it can start again from a lower number after such a restart.
|
|
4152
|
+
*/
|
|
4153
|
+
export interface ReadinessProbe {
|
|
4154
|
+
port?: number;
|
|
4155
|
+
/** A shell command line (run with `/bin/sh -c`) or an argv array. */
|
|
4156
|
+
cmd?: string | string[];
|
|
4157
|
+
/** @default 10 */
|
|
4158
|
+
interval_ms?: number;
|
|
4159
|
+
/** @default 60 */
|
|
4160
|
+
timeout_s?: number;
|
|
4161
|
+
}
|
|
4162
|
+
export interface Readiness {
|
|
4163
|
+
/** `failed`: the probe did not pass within its `timeout_s`, or the sandbox stopped first. */
|
|
4164
|
+
status: "pending" | "ready" | "failed";
|
|
4165
|
+
probe: ReadinessProbe;
|
|
4166
|
+
attempts: number;
|
|
4167
|
+
ready_at: string | null;
|
|
4168
|
+
/** From the create's start (or from when the probe was set) to the first passing try. */
|
|
4169
|
+
time_to_ready_ms: number | null;
|
|
3350
4170
|
/** Why the last failing try failed. */
|
|
3351
4171
|
last_error: string | null;
|
|
3352
4172
|
}
|
|
@@ -3397,6 +4217,8 @@ export interface Sandbox {
|
|
|
3397
4217
|
ports: {
|
|
3398
4218
|
port: number;
|
|
3399
4219
|
public: boolean;
|
|
4220
|
+
/** The port has an app address (the create set `addressed`); always sent by this node. */
|
|
4221
|
+
addressed?: boolean;
|
|
3400
4222
|
/**
|
|
3401
4223
|
* Public ports: the long-lived preview URL, token included. Private ports: `null`; mint a URL with
|
|
3402
4224
|
* `POST /v1/sandboxes/{sandbox_id}/ports/{port}/url`. Also `null` when code in another sandbox reads
|
|
@@ -3413,6 +4235,14 @@ export interface Sandbox {
|
|
|
3413
4235
|
/** The grant's own cap, or `null` when the creating principal's cap applies. */
|
|
3414
4236
|
spend_cap_usd: number | null;
|
|
3415
4237
|
connections: string[];
|
|
4238
|
+
/**
|
|
4239
|
+
* The actions rule the sandbox holds (the grant's, or the one it inherited from the sandbox that created
|
|
4240
|
+
* it), or `null` when it holds none; a node before release 1118 leaves the member out. Its packs are the
|
|
4241
|
+
* sandbox's tools at `B3OS_MCP_URL`.
|
|
4242
|
+
*/
|
|
4243
|
+
actions?: {
|
|
4244
|
+
allow: string[];
|
|
4245
|
+
} | null;
|
|
3416
4246
|
};
|
|
3417
4247
|
egress: {
|
|
3418
4248
|
mode: "public" | "allowlist" | "deny";
|
|
@@ -3427,7 +4257,9 @@ export interface Sandbox {
|
|
|
3427
4257
|
* Why the sandbox stopped: `deleted`, `timeout` (it reached `expires_at`), `failed` (the microVM crashed),
|
|
3428
4258
|
* `budget` (while it ran, its organization was suspended or ran out of credits, or the creating key or
|
|
3429
4259
|
* the sandbox's own `api.spend_cap_usd` reached its cap; the node checks every 10 s) or `revoked` (the key
|
|
3430
|
-
* that created it was revoked
|
|
4260
|
+
* that created it was revoked or expired, or, for a sandbox a service started, the service at its `root`
|
|
4261
|
+
* ended). A project's service never stops for its key's revoke or expiry; for the key's spend cap only when
|
|
4262
|
+
* its grant sets no cap of its own.
|
|
3431
4263
|
*/
|
|
3432
4264
|
stop_reason: "deleted" | "timeout" | "failed" | "budget" | "revoked" | null;
|
|
3433
4265
|
usage: {
|
|
@@ -3442,7 +4274,33 @@ export interface Sandbox {
|
|
|
3442
4274
|
};
|
|
3443
4275
|
/** The readiness probe and what it found; `null` when the sandbox has none. */
|
|
3444
4276
|
readiness?: null | Readiness;
|
|
4277
|
+
/**
|
|
4278
|
+
* The sandbox's lease (`PUT /v1/sandboxes/{sandbox_id}/lease`): while `held`, the node keeps the sandbox
|
|
4279
|
+
* running and renews its `expires_at` itself. `null` when it never held one. Always sent by this node.
|
|
4280
|
+
*/
|
|
4281
|
+
lease?: null | SandboxLease;
|
|
4282
|
+
/**
|
|
4283
|
+
* The processes the node supervises (an exec with `background: true` and `restart`), oldest first; empty
|
|
4284
|
+
* when there are none. Always sent by this node.
|
|
4285
|
+
*/
|
|
4286
|
+
supervised?: SupervisedProcess[];
|
|
4287
|
+
/** The volume the sandbox holds and where it is mounted; empty when none. Always sent by this node. */
|
|
4288
|
+
volumes?: SandboxVolume[];
|
|
3445
4289
|
options: SandboxOptions;
|
|
4290
|
+
owner?: SandboxOwner;
|
|
4291
|
+
/**
|
|
4292
|
+
* The key that created the sandbox, whoever owns it; `null` when the creator held none: the GitHub App, or
|
|
4293
|
+
* a service's own credential (then `root` names the service).
|
|
4294
|
+
*/
|
|
4295
|
+
created_by_key?: string | null;
|
|
4296
|
+
/** The sandbox whose own credential created this one; `null` when an outside caller did. */
|
|
4297
|
+
parent?: string | null;
|
|
4298
|
+
/**
|
|
4299
|
+
* The project's service this sandbox was started from, directly or through other sandboxes it started
|
|
4300
|
+
* (`owner: project`). This sandbox ends when that service ends. `null` for a service and for a sandbox no
|
|
4301
|
+
* service started.
|
|
4302
|
+
*/
|
|
4303
|
+
root?: string | null;
|
|
3446
4304
|
timing?: Timing;
|
|
3447
4305
|
metadata: Metadata;
|
|
3448
4306
|
}
|
|
@@ -3460,6 +4318,65 @@ export interface SandboxOptions {
|
|
|
3460
4318
|
export type SandboxList = Omit<ListEnvelope, "data"> & {
|
|
3461
4319
|
data: Sandbox[];
|
|
3462
4320
|
};
|
|
4321
|
+
export interface LeaseRequest {
|
|
4322
|
+
/**
|
|
4323
|
+
* The lease's name, 1 to 128 of `A-Z a-z 0-9 . _ : / -`. One live sandbox of the project holds it at a time:
|
|
4324
|
+
* holding it here takes it from the sandbox that held it.
|
|
4325
|
+
*/
|
|
4326
|
+
key: string;
|
|
4327
|
+
/**
|
|
4328
|
+
* A precondition: the sandbox you read holding `key` (its ID), or `null` when you read none holding it. The
|
|
4329
|
+
* key is taken only while that is still so; otherwise `409 lease_holder_changed` names the sandbox that holds
|
|
4330
|
+
* it now (`holder`) and nothing changes. Left out, the key is taken from whichever sandbox holds it. A sandbox
|
|
4331
|
+
* that already holds `key` answers 200 whatever this says.
|
|
4332
|
+
*/
|
|
4333
|
+
expect_holder?: string | null;
|
|
4334
|
+
}
|
|
4335
|
+
/** A sandbox's lease, held or ended. */
|
|
4336
|
+
export interface SandboxLease {
|
|
4337
|
+
key: string;
|
|
4338
|
+
state: "held" | "ended";
|
|
4339
|
+
/** When the sandbox took the lease. */
|
|
4340
|
+
since: string;
|
|
4341
|
+
/** When the node last moved `expires_at` for it; `null` before the first renewal. */
|
|
4342
|
+
renewed_at: string | null;
|
|
4343
|
+
ended_at: string | null;
|
|
4344
|
+
/**
|
|
4345
|
+
* Why it ended: `released` (`DELETE …/lease`), `replaced` (another sandbox of the project took its key; this
|
|
4346
|
+
* one then stops within `sandboxes.lease_term`), or the sandbox's `stop_reason`.
|
|
4347
|
+
*/
|
|
4348
|
+
end_reason: "released" | "replaced" | "deleted" | "timeout" | "failed" | "budget" | "revoked" | null;
|
|
4349
|
+
}
|
|
4350
|
+
/** A background process the node starts again when it exits (an exec with `restart`). */
|
|
4351
|
+
export interface SupervisedProcess {
|
|
4352
|
+
/** The process running now, or the last one while it waits to start again; `null` if none started. */
|
|
4353
|
+
pid: number | null;
|
|
4354
|
+
/** The command as started (argv arrays are joined with spaces). */
|
|
4355
|
+
cmd: string;
|
|
4356
|
+
restart: "on-failure" | "always";
|
|
4357
|
+
/**
|
|
4358
|
+
* `starting`: started again, and the sandbox's readiness probe has not passed since. `running`: it runs
|
|
4359
|
+
* (and is ready, when the sandbox has a probe). `backoff`: it exited and starts again at `next_start_at`.
|
|
4360
|
+
* `crash_loop`: 5 exits within 300 s; restarts go on, at most 60 s apart, and it reads `crash_loop`, running
|
|
4361
|
+
* or waiting, until one run lasts 60 s. `exited`: it exited and
|
|
4362
|
+
* its policy keeps it down (`on-failure` after exit code 0). `stopped`: stopped through
|
|
4363
|
+
* `POST …/processes/{pid}/kill`, or the sandbox stopped.
|
|
4364
|
+
*/
|
|
4365
|
+
state: "starting" | "running" | "backoff" | "crash_loop" | "exited" | "stopped";
|
|
4366
|
+
/** How many times the node started it again. */
|
|
4367
|
+
restarts: number;
|
|
4368
|
+
/** When the current process started. */
|
|
4369
|
+
started_at: string | null;
|
|
4370
|
+
/** How the last process ended; `null` before any exit. */
|
|
4371
|
+
last_exit: null | {
|
|
4372
|
+
pid: number | null;
|
|
4373
|
+
exit_code: number | null;
|
|
4374
|
+
signal: string | null;
|
|
4375
|
+
at: string;
|
|
4376
|
+
};
|
|
4377
|
+
/** When it starts again, in `backoff` and `crash_loop`; `null` otherwise. */
|
|
4378
|
+
next_start_at: string | null;
|
|
4379
|
+
}
|
|
3463
4380
|
export interface TimeoutRequest {
|
|
3464
4381
|
timeout_s: number;
|
|
3465
4382
|
}
|
|
@@ -3511,6 +4428,13 @@ export interface ExecRequest {
|
|
|
3511
4428
|
background?: boolean;
|
|
3512
4429
|
/** @default "user" */
|
|
3513
4430
|
user?: "user" | "root";
|
|
4431
|
+
/**
|
|
4432
|
+
* With `background: true` only: the node starts the command again in this sandbox when it exits.
|
|
4433
|
+
* `on-failure` after a non-zero exit code or a signal, `always` after any exit. Waits between restarts in
|
|
4434
|
+
* a row: 0, 1, 2, 4, 8, 16, 32, then 60 s; a run of 60 s resets them. 5 exits within 300 s report
|
|
4435
|
+
* `crash_loop`. At most 8 per sandbox. Left out, the process is not supervised.
|
|
4436
|
+
*/
|
|
4437
|
+
restart?: "on-failure" | "always";
|
|
3514
4438
|
}
|
|
3515
4439
|
export interface ExecResult {
|
|
3516
4440
|
object: "exec_result";
|
|
@@ -3548,6 +4472,13 @@ export interface SandboxProcess {
|
|
|
3548
4472
|
signal?: string | null;
|
|
3549
4473
|
started_at: string;
|
|
3550
4474
|
exited_at: string | null;
|
|
4475
|
+
/**
|
|
4476
|
+
* The node supervises this process now (it is the current process of an entry in the sandbox's
|
|
4477
|
+
* `supervised`). Always sent by this node.
|
|
4478
|
+
*/
|
|
4479
|
+
supervised?: boolean;
|
|
4480
|
+
/** The process this one replaced when the node started the command again; `null` otherwise. */
|
|
4481
|
+
restart_of?: number | null;
|
|
3551
4482
|
}
|
|
3552
4483
|
/** What a running sandbox uses now (`GET /v1/sandboxes/{sandbox_id}/stats`). */
|
|
3553
4484
|
export interface SandboxStats {
|
|
@@ -3586,6 +4517,14 @@ export interface SandboxStats {
|
|
|
3586
4517
|
*/
|
|
3587
4518
|
total: number | null;
|
|
3588
4519
|
};
|
|
4520
|
+
/**
|
|
4521
|
+
* The mounted volume's size and use (its guest name is its host ID); present only when the sandbox holds one.
|
|
4522
|
+
*/
|
|
4523
|
+
volumes?: {
|
|
4524
|
+
name: string;
|
|
4525
|
+
used_bytes: number;
|
|
4526
|
+
total_bytes: number;
|
|
4527
|
+
}[];
|
|
3589
4528
|
}
|
|
3590
4529
|
export type SandboxProcessList = Omit<ListEnvelope, "data"> & {
|
|
3591
4530
|
data: SandboxProcess[];
|
|
@@ -3593,6 +4532,15 @@ export type SandboxProcessList = Omit<ListEnvelope, "data"> & {
|
|
|
3593
4532
|
export interface KillRequest {
|
|
3594
4533
|
/** @default "TERM" */
|
|
3595
4534
|
signal?: "TERM" | "KILL" | "INT" | "HUP";
|
|
4535
|
+
/**
|
|
4536
|
+
* On a supervised process: keep the supervision, so the node starts the command again once the signal
|
|
4537
|
+
* ends it (counted as a restart). Without it the supervision ends first and the process stays down.
|
|
4538
|
+
* Ignored on a process the node does not supervise. A process still running 10 s after the signal ignored
|
|
4539
|
+
* it: the request lapses (the node logs it), and the process's next exit counts as a crash. Send `KILL` to
|
|
4540
|
+
* restart one that ignores `TERM`.
|
|
4541
|
+
* @default false
|
|
4542
|
+
*/
|
|
4543
|
+
restart?: boolean;
|
|
3596
4544
|
}
|
|
3597
4545
|
/**
|
|
3598
4546
|
* `log.stdout` and `log.stderr` carry `pid` and `data`; `process.exited` carries `pid` and `exit_code`.
|
|
@@ -3726,28 +4674,585 @@ export interface Template {
|
|
|
3726
4674
|
os: string;
|
|
3727
4675
|
runtimes: string[];
|
|
3728
4676
|
/**
|
|
3729
|
-
* `cdp`: Chrome runs in the template's snapshot with DevTools on `127.0.0.1:9222` inside the sandbox; declare
|
|
3730
|
-
* port 9222 to reach it through a port preview.
|
|
4677
|
+
* `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.
|
|
4679
|
+
*/
|
|
4680
|
+
capabilities: Array<"exec" | "files" | "pty" | "run_code" | "cdp">;
|
|
4681
|
+
defaults: {
|
|
4682
|
+
vcpu: number;
|
|
4683
|
+
memory_mib: number;
|
|
4684
|
+
disk_gib: number;
|
|
4685
|
+
};
|
|
4686
|
+
/**
|
|
4687
|
+
* The sizes this node keeps pre-warmed microVMs of: the template's default size first, then at most one
|
|
4688
|
+
* larger class. A create at one of them claims a parked microVM; any other size (within your plan) is
|
|
4689
|
+
* restored on demand, a pool miss.
|
|
4690
|
+
*/
|
|
4691
|
+
size_classes: {
|
|
4692
|
+
vcpu: number;
|
|
4693
|
+
memory_mib: number;
|
|
4694
|
+
}[];
|
|
4695
|
+
/**
|
|
4696
|
+
* `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 `tpl_` ID and
|
|
4698
|
+
* it has one size (`size_classes` holds only the image's).
|
|
4699
|
+
*/
|
|
4700
|
+
owner: "node" | "project";
|
|
4701
|
+
/** The image this template was imported from (`owner: project`); `null` for node templates. */
|
|
4702
|
+
image: string | null;
|
|
4703
|
+
created_at: string;
|
|
4704
|
+
/**
|
|
4705
|
+
* The sha256 of the guest agent in the template's image. A node's agent update changes it while
|
|
4706
|
+
* `created_at` stays, so a deployment's build key takes it: each application builds again once at its first
|
|
4707
|
+
* deploy after an agent update. Absent from a template whose image records no agent.
|
|
4708
|
+
*/
|
|
4709
|
+
agent_sha256?: string;
|
|
4710
|
+
}
|
|
4711
|
+
export type TemplateList = Omit<ListEnvelope, "data"> & {
|
|
4712
|
+
data: Template[];
|
|
4713
|
+
};
|
|
4714
|
+
/**
|
|
4715
|
+
* One child's command. In `defaults`, every field is optional; a child's own fields replace the defaults' (`env` is merged, the child's keys winning).
|
|
4716
|
+
*/
|
|
4717
|
+
export interface SwarmChildSpec {
|
|
4718
|
+
/** A shell command line (run with `/bin/sh -c`) or an argv array, as for exec. */
|
|
4719
|
+
cmd?: string | string[];
|
|
4720
|
+
/**
|
|
4721
|
+
* Extra environment variables for this child's command, on top of the checkpoint's. Kept with the swarm's record; never put secrets here.
|
|
4722
|
+
*/
|
|
4723
|
+
env?: Record<string, string>;
|
|
4724
|
+
/** @default "/workspace" */
|
|
4725
|
+
cwd?: string;
|
|
4726
|
+
/** Written to the command's standard input, which is then closed. */
|
|
4727
|
+
stdin?: string;
|
|
4728
|
+
/** @default "user" */
|
|
4729
|
+
user?: "user" | "root";
|
|
4730
|
+
/**
|
|
4731
|
+
* Kill the command after this long; the child then ends `timed_out`.
|
|
4732
|
+
* @default 300000
|
|
4733
|
+
*/
|
|
4734
|
+
timeout_ms?: number;
|
|
4735
|
+
metadata?: Metadata;
|
|
4736
|
+
}
|
|
4737
|
+
/** The checkpoint every child starts from. Exactly one of `sandbox` and `snapshot`. */
|
|
4738
|
+
export interface SwarmSource {
|
|
4739
|
+
/** A forkable sandbox, running or paused. A paused one is resumed for the fork and paused again. */
|
|
4740
|
+
sandbox?: string;
|
|
4741
|
+
/** A snapshot of this project; every child is restored from it. */
|
|
4742
|
+
snapshot?: string;
|
|
4743
|
+
}
|
|
4744
|
+
/**
|
|
4745
|
+
* Give either `children` or `count` (with `defaults`), not both. Every child needs a `cmd`, its own or the defaults'.
|
|
4746
|
+
*/
|
|
4747
|
+
export interface SwarmCreateRequest {
|
|
4748
|
+
from: SwarmSource;
|
|
4749
|
+
/** The children, in index order (`sandboxes.swarm_children_max`). */
|
|
4750
|
+
children?: SwarmChildSpec[];
|
|
4751
|
+
/** This many children, each running `defaults`. */
|
|
4752
|
+
count?: number;
|
|
4753
|
+
defaults?: SwarmChildSpec;
|
|
4754
|
+
/**
|
|
4755
|
+
* `first_success`: once a child exits 0, kill the other children's commands and end the swarm.
|
|
4756
|
+
* @default "all"
|
|
4757
|
+
*/
|
|
4758
|
+
stop_when?: "all" | "first_success";
|
|
4759
|
+
/**
|
|
4760
|
+
* Which children stay running after their command ends; the rest are deleted.
|
|
4761
|
+
* @default "none"
|
|
4762
|
+
*/
|
|
4763
|
+
keep?: "none" | "succeeded" | "all";
|
|
4764
|
+
/**
|
|
4765
|
+
* Add `child.stdout` and `child.stderr` events to the swarm's stream (each stream up to `output_max_bytes`).
|
|
4766
|
+
* @default false
|
|
4767
|
+
*/
|
|
4768
|
+
stream_output?: boolean;
|
|
4769
|
+
/**
|
|
4770
|
+
* How many bytes of each child's stdout and of its stderr are kept; the rest is dropped and `stdout_truncated` or `stderr_truncated` is set.
|
|
4771
|
+
* @default 65536
|
|
4772
|
+
*/
|
|
4773
|
+
output_max_bytes?: number;
|
|
4774
|
+
/** As for a fork (`ForkRequest.clone_reset`), for every child. */
|
|
4775
|
+
clone_reset?: "full" | "none";
|
|
4776
|
+
webhook?: WebhookConfig;
|
|
4777
|
+
metadata?: Metadata;
|
|
4778
|
+
}
|
|
4779
|
+
/** One child of a swarm and what its command did. */
|
|
4780
|
+
export interface SwarmChild {
|
|
4781
|
+
/** The child's position in `children` (or 0 to `count` - 1); also its `B3OS_SWARM_INDEX`. */
|
|
4782
|
+
index: number;
|
|
4783
|
+
/** The child's sandbox; `null` until the fork made it. */
|
|
4784
|
+
sandbox_id: string | null;
|
|
4785
|
+
/**
|
|
4786
|
+
* `queued` until its sandbox exists, `running` while its command runs, then `exited` (any exit code),
|
|
4787
|
+
* `timed_out` (killed at `timeout_ms`), `failed` (the command could not start or the sandbox was lost;
|
|
4788
|
+
* see `error`) or `canceled` (the swarm stopped it).
|
|
4789
|
+
*/
|
|
4790
|
+
status: "queued" | "running" | "exited" | "timed_out" | "failed" | "canceled";
|
|
4791
|
+
/** The command's exit status; `null` until it exits, or when a signal ended it. */
|
|
4792
|
+
exit_code: number | null;
|
|
4793
|
+
/** The signal that ended the command, such as `KILL` after a timeout or a cancel. */
|
|
4794
|
+
signal: string | null;
|
|
4795
|
+
stdout: string;
|
|
4796
|
+
stderr: string;
|
|
4797
|
+
stdout_truncated: boolean;
|
|
4798
|
+
stderr_truncated: boolean;
|
|
4799
|
+
/** The child's sandbox was left running (`keep`); delete it when you are done with it. */
|
|
4800
|
+
kept: boolean;
|
|
4801
|
+
error?: Problem;
|
|
4802
|
+
metadata?: Metadata;
|
|
4803
|
+
/**
|
|
4804
|
+
* `start_ms`: from the swarm's start to the command's start. `run_ms`: the command's own run. `total_ms`: from the swarm's start to the command's end (or to now while it runs).
|
|
4805
|
+
*/
|
|
4806
|
+
timing: {
|
|
4807
|
+
start_ms?: number;
|
|
4808
|
+
run_ms?: number;
|
|
4809
|
+
total_ms: number;
|
|
4810
|
+
};
|
|
4811
|
+
}
|
|
4812
|
+
/** A swarm (`swm_…`), one checkpoint forked into children that each ran a command. */
|
|
4813
|
+
export type Swarm = Omit<Job, "id" | "object" | "result" | "timing"> & {
|
|
4814
|
+
id: string;
|
|
4815
|
+
object: "swarm";
|
|
4816
|
+
from: SwarmSource;
|
|
4817
|
+
stop_when: "all" | "first_success";
|
|
4818
|
+
keep: "none" | "succeeded" | "all";
|
|
4819
|
+
/** Every child, by index. Left out of lists. */
|
|
4820
|
+
children?: SwarmChild[];
|
|
4821
|
+
/** How the children ended. Present once the swarm ended, and on a canceled swarm. */
|
|
4822
|
+
result?: {
|
|
4823
|
+
exit_zero: number;
|
|
4824
|
+
exit_nonzero: number;
|
|
4825
|
+
timed_out: number;
|
|
4826
|
+
failed: number;
|
|
4827
|
+
canceled: number;
|
|
4828
|
+
/** With `stop_when: first_success`, the index of the child that exited 0 first; else `null`. */
|
|
4829
|
+
winner: number | null;
|
|
4830
|
+
};
|
|
4831
|
+
/**
|
|
4832
|
+
* `fork_ms`: the fork or the restores that made the children. `first_exit_ms` and `last_exit_ms`: from the swarm's start to the first and the last command's end. `total_ms`: the whole swarm.
|
|
4833
|
+
*/
|
|
4834
|
+
timing?: {
|
|
4835
|
+
fork_ms?: number;
|
|
4836
|
+
first_exit_ms?: number;
|
|
4837
|
+
last_exit_ms?: number;
|
|
4838
|
+
total_ms: number;
|
|
4839
|
+
};
|
|
4840
|
+
};
|
|
4841
|
+
export type SwarmList = Omit<ListEnvelope, "data"> & {
|
|
4842
|
+
data: Swarm[];
|
|
4843
|
+
};
|
|
4844
|
+
export type SwarmChildList = Omit<ListEnvelope, "data"> & {
|
|
4845
|
+
data: SwarmChild[];
|
|
4846
|
+
};
|
|
4847
|
+
/**
|
|
4848
|
+
* An event of a swarm's stream. `swarm.forked` carries `children` (each `index` and `sandbox_id`) and the
|
|
4849
|
+
* fork's `timing`; `child.started`, `child.exited` and `child.failed` carry `index` and `sandbox_id`, and
|
|
4850
|
+
* `child.exited` also `exit_code`, `signal` and `timed_out`, `child.failed` an `error`; `child.stdout` and
|
|
4851
|
+
* `child.stderr` carry `index` and `data`.
|
|
4852
|
+
*/
|
|
4853
|
+
export type SwarmEvent = JobEvent & {
|
|
4854
|
+
index?: number;
|
|
4855
|
+
sandbox_id?: string;
|
|
4856
|
+
data?: string;
|
|
4857
|
+
exit_code?: number | null;
|
|
4858
|
+
signal?: string | null;
|
|
4859
|
+
timed_out?: boolean;
|
|
4860
|
+
error?: Problem;
|
|
4861
|
+
children?: {
|
|
4862
|
+
index: number;
|
|
4863
|
+
sandbox_id: string;
|
|
4864
|
+
}[];
|
|
4865
|
+
};
|
|
4866
|
+
/**
|
|
4867
|
+
* `queued` (accepted, waiting for the queue), `pulling` (layers streaming into the unpacking microVM),
|
|
4868
|
+
* `flattening` (the last byte sent; waiting for the unpacker and the store), `warming` (the first boot, the
|
|
4869
|
+
* warm-up and the warm snapshot), `ready`. `rebuilding`: a node release changed the guest agent, kernel or
|
|
4870
|
+
* hypervisor, and the warm snapshot is being taken again (creates answer `409 image_not_ready` until it is
|
|
4871
|
+
* `ready`). `failed`: see `error`. `evicted`: the node's image cache was full and this image, unused, was
|
|
4872
|
+
* removed; import it again with the same request.
|
|
4873
|
+
*/
|
|
4874
|
+
export type ImageStatus = "queued" | "pulling" | "flattening" | "warming" | "ready" | "rebuilding" | "failed" | "evicted";
|
|
4875
|
+
export interface ImageWarmup {
|
|
4876
|
+
/**
|
|
4877
|
+
* Commands run once, in order, in the image's first boot before its warm snapshot is taken: each an
|
|
4878
|
+
* argument list, as root, in `WORKDIR` (else `/`), with the image's `ENV`, with no network, all of them
|
|
4879
|
+
* within 300 seconds. A command that exits non-zero fails the import (stage `golden`).
|
|
4880
|
+
*/
|
|
4881
|
+
commands: string[][];
|
|
4882
|
+
}
|
|
4883
|
+
export interface ImageImportRequest {
|
|
4884
|
+
/**
|
|
4885
|
+
* An image reference: `[registry/]repository[:tag|@sha256:digest]`. Without a registry it is Docker Hub
|
|
4886
|
+
* (`python:3.11-slim` is `registry-1.docker.io/library/python:3.11-slim`); without a tag or digest it is
|
|
4887
|
+
* `latest`. A tag is resolved to its digest once, when the import is accepted; the image keeps that digest.
|
|
4888
|
+
* Public images only (no credentials).
|
|
4889
|
+
*/
|
|
4890
|
+
ref: string;
|
|
4891
|
+
warmup?: ImageWarmup;
|
|
4892
|
+
/** The size every sandbox from the image has. Default 1, at most your plan's `sandboxes.vcpu_max`. */
|
|
4893
|
+
vcpu?: number;
|
|
4894
|
+
/**
|
|
4895
|
+
* The memory every sandbox from the image has. Default 1024, at most your plan's `sandboxes.memory_max`.
|
|
4896
|
+
*/
|
|
4897
|
+
memory_mib?: number;
|
|
4898
|
+
}
|
|
4899
|
+
/**
|
|
4900
|
+
* What the image's own configuration says, read when it was imported. `user`, `env` and `workdir` apply to every
|
|
4901
|
+
* command a sandbox from the image runs (`user` as in Docker: a name from the image's `/etc/passwd`, or
|
|
4902
|
+
* `uid[:gid]`; root when unset). `entrypoint`, `cmd`, `exposed_ports`, `volumes` and `healthcheck` are reported,
|
|
4903
|
+
* not run: a sandbox starts with no process of the image's own. Labels are shown, never acted on.
|
|
4904
|
+
*/
|
|
4905
|
+
export interface ImageConfig {
|
|
4906
|
+
entrypoint: string[] | null;
|
|
4907
|
+
cmd: string[] | null;
|
|
4908
|
+
env: Record<string, string>;
|
|
4909
|
+
workdir: string | null;
|
|
4910
|
+
user: string | null;
|
|
4911
|
+
exposed_ports: string[];
|
|
4912
|
+
volumes: string[];
|
|
4913
|
+
labels: Record<string, string>;
|
|
4914
|
+
/** Docker's `HEALTHCHECK`, when the image has one (a Docker extension, not part of OCI). */
|
|
4915
|
+
healthcheck: {
|
|
4916
|
+
test: string[];
|
|
4917
|
+
interval_ms: number | null;
|
|
4918
|
+
timeout_ms: number | null;
|
|
4919
|
+
start_period_ms: number | null;
|
|
4920
|
+
retries: number | null;
|
|
4921
|
+
} | null;
|
|
4922
|
+
}
|
|
4923
|
+
export interface ImagePackage {
|
|
4924
|
+
name: string;
|
|
4925
|
+
version: string;
|
|
4926
|
+
}
|
|
4927
|
+
/**
|
|
4928
|
+
* Milliseconds each finished stage took (`null` until it finishes): `resolve` (the reference to a digest,
|
|
4929
|
+
* before the answer), `queue` (waiting for a slot), `pull_flatten` (pulling and unpacking, which overlap),
|
|
4930
|
+
* `adopt` (checking and storing the file system), `golden` (the first boot, warm-up and warm snapshot), and
|
|
4931
|
+
* `total`.
|
|
4932
|
+
*/
|
|
4933
|
+
export interface ImageStagesMs {
|
|
4934
|
+
resolve: number | null;
|
|
4935
|
+
queue: number | null;
|
|
4936
|
+
pull_flatten: number | null;
|
|
4937
|
+
adopt: number | null;
|
|
4938
|
+
golden: number | null;
|
|
4939
|
+
total: number | null;
|
|
4940
|
+
}
|
|
4941
|
+
export interface ImageError {
|
|
4942
|
+
/** `import_failed`. */
|
|
4943
|
+
code: string;
|
|
4944
|
+
stage: "resolve" | "pull" | "flatten" | "adopt" | "golden" | "rebuild" | "interrupted";
|
|
4945
|
+
detail: string;
|
|
4946
|
+
/** The last 4 KiB of the unpacker's or the warm-up's output, when there was any. */
|
|
4947
|
+
output: string | null;
|
|
4948
|
+
}
|
|
4949
|
+
export interface Image {
|
|
4950
|
+
id: string;
|
|
4951
|
+
object: "image";
|
|
4952
|
+
/** The reference as given. */
|
|
4953
|
+
ref: string;
|
|
4954
|
+
/** The `linux/amd64` image manifest's digest. */
|
|
4955
|
+
digest: string;
|
|
4956
|
+
/** The index (multi-platform list) the manifest was picked from, when the reference named one. */
|
|
4957
|
+
index_digest: string | null;
|
|
4958
|
+
platform: "linux/amd64";
|
|
4959
|
+
status: ImageStatus;
|
|
4960
|
+
/**
|
|
4961
|
+
* The template sandboxes start from (`POST /v1/sandboxes {"template": "tpl_…"}`), set once the image has been ready.
|
|
4962
|
+
*/
|
|
4963
|
+
template: string | null;
|
|
4964
|
+
config: ImageConfig;
|
|
4965
|
+
/** The flattened read-only root file system, once stored. */
|
|
4966
|
+
rootfs: {
|
|
4967
|
+
sha256: string;
|
|
4968
|
+
bytes: number;
|
|
4969
|
+
} | null;
|
|
4970
|
+
warmup: ImageWarmup;
|
|
4971
|
+
size: {
|
|
4972
|
+
vcpu: number;
|
|
4973
|
+
memory_mib: number;
|
|
4974
|
+
};
|
|
4975
|
+
/** The import key (sha256); an import with the same key in this project returns this image. */
|
|
4976
|
+
key: string;
|
|
4977
|
+
stages_ms: ImageStagesMs;
|
|
4978
|
+
/** Compressed layer bytes pulled from the registry. */
|
|
4979
|
+
bytes_pulled: number;
|
|
4980
|
+
/**
|
|
4981
|
+
* Packages the unpacker found, best effort, at most 2,000 of each kind: Debian packages (`dpkg`), Python
|
|
4982
|
+
* distributions under `site-packages` (`pip`) and global `node_modules` (`npm`). `null` until the image is
|
|
4983
|
+
* flattened.
|
|
4984
|
+
*/
|
|
4985
|
+
packages: {
|
|
4986
|
+
dpkg: ImagePackage[];
|
|
4987
|
+
pip: ImagePackage[];
|
|
4988
|
+
npm: ImagePackage[];
|
|
4989
|
+
} | null;
|
|
4990
|
+
error: null | ImageError;
|
|
4991
|
+
created_at: string;
|
|
4992
|
+
ready_at: string | null;
|
|
4993
|
+
}
|
|
4994
|
+
export type ImageList = Omit<ListEnvelope, "data"> & {
|
|
4995
|
+
data: Image[];
|
|
4996
|
+
};
|
|
4997
|
+
/** An instance's key, stored and shown as written, so never a credential or a personal detail. */
|
|
4998
|
+
export type AgentInstanceKey = string;
|
|
4999
|
+
/** Lowercase letters, digits and `-`, starting with a letter. `sessions` is reserved. */
|
|
5000
|
+
export type AgentName = string;
|
|
5001
|
+
/**
|
|
5002
|
+
* What each instance starts from: a template (node templates, or one of your project's image templates) at a
|
|
5003
|
+
* size, or one of your project's snapshots. The size is fixed per agent, within `sandboxes.vcpu_max` and
|
|
5004
|
+
* `sandboxes.memory_max`.
|
|
5005
|
+
*/
|
|
5006
|
+
export interface AgentSource {
|
|
5007
|
+
/** @default "agent" */
|
|
5008
|
+
template?: string;
|
|
5009
|
+
/** Restore this snapshot instead of starting from a template. */
|
|
5010
|
+
snapshot?: string;
|
|
5011
|
+
vcpu?: number;
|
|
5012
|
+
memory_mib?: number;
|
|
5013
|
+
disk_gib?: number;
|
|
5014
|
+
}
|
|
5015
|
+
/**
|
|
5016
|
+
* The harness. `command` runs in each instance when it is made, and again after a cold boot from its disk. The
|
|
5017
|
+
* node delivers each message as a `POST` to `port` and `path`. The instance counts as made once `readiness`
|
|
5018
|
+
* passes (by default, once `port` accepts connections). A harness that exits is started again in place, at most
|
|
5019
|
+
* `max_restarts` times in a row; past that the instance is `failed`.
|
|
5020
|
+
*/
|
|
5021
|
+
export interface AgentEntry {
|
|
5022
|
+
command: string[];
|
|
5023
|
+
/** Not 53, 1080, 3128, 7700 or 15001, which the guest agent listens on. */
|
|
5024
|
+
port: number;
|
|
5025
|
+
/** @default "/" */
|
|
5026
|
+
path?: string;
|
|
5027
|
+
readiness?: ReadinessProbe;
|
|
5028
|
+
/** @default 5 */
|
|
5029
|
+
max_restarts?: number;
|
|
5030
|
+
}
|
|
5031
|
+
/**
|
|
5032
|
+
* When an idle instance moves to each sleep tier. Quiet means no turn, no queued message, no open connection
|
|
5033
|
+
* through its ports, no exec, file or terminal call and no sandbox it started still running; its own outbound
|
|
5034
|
+
* traffic does not count. Every default was chosen for the beta, not measured.
|
|
5035
|
+
*/
|
|
5036
|
+
export interface AgentSleep {
|
|
5037
|
+
/**
|
|
5038
|
+
* Quiet this long, it pauses in memory.
|
|
5039
|
+
* @default 30
|
|
5040
|
+
*/
|
|
5041
|
+
ram_after_s?: number;
|
|
5042
|
+
/**
|
|
5043
|
+
* Paused this long, its memory goes to a snapshot on the node's disk and its memory is freed.
|
|
5044
|
+
* @default 600
|
|
5045
|
+
*/
|
|
5046
|
+
snapshot_after_s?: number;
|
|
5047
|
+
/**
|
|
5048
|
+
* How long a memory snapshot is kept. After it, the instance is `dormant`: only its disk is kept, and the
|
|
5049
|
+
* next message cold boots it from that disk and runs `entry.command` again.
|
|
5050
|
+
* @default 604800
|
|
5051
|
+
*/
|
|
5052
|
+
snapshot_keep_s?: number;
|
|
5053
|
+
}
|
|
5054
|
+
/** How messages become turns. One turn runs at a time per instance. */
|
|
5055
|
+
export interface AgentTurns {
|
|
5056
|
+
/**
|
|
5057
|
+
* Messages that may wait for the current turn, at most `agents.queue_max`.
|
|
5058
|
+
* @default 16
|
|
5059
|
+
*/
|
|
5060
|
+
queue_max?: number;
|
|
5061
|
+
/**
|
|
5062
|
+
* How long a turn may take from its message's acceptance, queue time included.
|
|
5063
|
+
* @default 300
|
|
5064
|
+
*/
|
|
5065
|
+
timeout_s?: number;
|
|
5066
|
+
/**
|
|
5067
|
+
* Deliver a message again after the node restarted while the harness had it. Only for a harness that
|
|
5068
|
+
* ignores a session ID it has seen (`x-b3os-session`).
|
|
5069
|
+
* @default false
|
|
5070
|
+
*/
|
|
5071
|
+
redeliver?: boolean;
|
|
5072
|
+
}
|
|
5073
|
+
export interface AgentCreateRequest {
|
|
5074
|
+
name: AgentName;
|
|
5075
|
+
source?: AgentSource;
|
|
5076
|
+
entry: AgentEntry;
|
|
5077
|
+
/** Environment variables of the harness. Returned as given; put credentials in `secrets`. */
|
|
5078
|
+
env?: Record<string, string>;
|
|
5079
|
+
/**
|
|
5080
|
+
* Environment variables never returned or logged, as a sandbox's `secrets`: code in the instance can read
|
|
5081
|
+
* them. A memory snapshot holds them, so the node keeps an instance's snapshots to itself: they are never
|
|
5082
|
+
* listed or restorable through the API.
|
|
5083
|
+
*/
|
|
5084
|
+
secrets?: Record<string, SecretValue>;
|
|
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;
|
|
5100
|
+
/**
|
|
5101
|
+
* What happens to instances of earlier revisions: `new_instances` leaves them as they are; `on_wake` makes a
|
|
5102
|
+
* sleeping one again from this revision at its next wake, which ends its memory and disk.
|
|
5103
|
+
* @default "new_instances"
|
|
5104
|
+
*/
|
|
5105
|
+
upgrade?: "new_instances" | "on_wake";
|
|
5106
|
+
metadata?: Metadata;
|
|
5107
|
+
}
|
|
5108
|
+
export interface Agent {
|
|
5109
|
+
id: string;
|
|
5110
|
+
object: "agent";
|
|
5111
|
+
name: AgentName;
|
|
5112
|
+
/** Grows by one with each update. Each instance keeps the revision it was made from. */
|
|
5113
|
+
revision: number;
|
|
5114
|
+
source: AgentSource;
|
|
5115
|
+
entry: AgentEntry;
|
|
5116
|
+
env: Record<string, string>;
|
|
5117
|
+
secret_names: string[];
|
|
5118
|
+
api: SandboxApiGrant;
|
|
5119
|
+
egress: EgressPolicy;
|
|
5120
|
+
sleep: AgentSleep;
|
|
5121
|
+
turns: AgentTurns;
|
|
5122
|
+
upgrade: "new_instances" | "on_wake";
|
|
5123
|
+
/** How many instances the agent has, in any state. */
|
|
5124
|
+
instances: number;
|
|
5125
|
+
created_at: string;
|
|
5126
|
+
updated_at: string;
|
|
5127
|
+
metadata: Metadata;
|
|
5128
|
+
}
|
|
5129
|
+
export type AgentList = Omit<ListEnvelope, "data"> & {
|
|
5130
|
+
data: Agent[];
|
|
5131
|
+
};
|
|
5132
|
+
/**
|
|
5133
|
+
* `creating` (its microVM starting and its harness passing readiness), `running`, `paused` (asleep in memory),
|
|
5134
|
+
* `hibernated` (asleep as a memory snapshot on disk), `dormant` (only its disk kept), `waking` (on its way back
|
|
5135
|
+
* to `running`) or `failed` (it recovers at its next message).
|
|
5136
|
+
*/
|
|
5137
|
+
export type AgentInstanceStatus = "creating" | "running" | "paused" | "hibernated" | "dormant" | "waking" | "failed";
|
|
5138
|
+
export interface AgentInstancePutRequest {
|
|
5139
|
+
/**
|
|
5140
|
+
* Wake an existing sleeping instance too.
|
|
5141
|
+
* @default false
|
|
5142
|
+
*/
|
|
5143
|
+
wake?: boolean;
|
|
5144
|
+
/**
|
|
5145
|
+
* Delete an existing instance (memory, snapshot and disk) and make it again from the current revision.
|
|
5146
|
+
* @default false
|
|
5147
|
+
*/
|
|
5148
|
+
replace?: boolean;
|
|
5149
|
+
metadata?: Metadata;
|
|
5150
|
+
}
|
|
5151
|
+
export interface AgentInstanceSleepRequest {
|
|
5152
|
+
/** @default "ram" */
|
|
5153
|
+
tier?: "ram" | "snapshot";
|
|
5154
|
+
}
|
|
5155
|
+
export interface AgentInstance {
|
|
5156
|
+
id: string;
|
|
5157
|
+
object: "agent_instance";
|
|
5158
|
+
agent_id: string;
|
|
5159
|
+
key: AgentInstanceKey;
|
|
5160
|
+
revision: number;
|
|
5161
|
+
status: AgentInstanceStatus;
|
|
5162
|
+
/** The instance's microVM, the same through every sleep tier; `null` before it was first made. */
|
|
5163
|
+
sandbox_id: string | null;
|
|
5164
|
+
/** Host memory the instance holds now (0 when hibernated or dormant). */
|
|
5165
|
+
resident_mib: number;
|
|
5166
|
+
/**
|
|
5167
|
+
* Bytes its checkpoint holds on the node beside its running microVM, which is its memory snapshot (memory, device state and a copy of its disk) or, when dormant, its disk alone. Kept while it sleeps and after it wakes, until the next one replaces it. 0 before its first.
|
|
5168
|
+
*/
|
|
5169
|
+
storage_bytes: number;
|
|
5170
|
+
/** Messages waiting for the current turn. */
|
|
5171
|
+
queued: number;
|
|
5172
|
+
last_message_at: string | null;
|
|
5173
|
+
/** When it last went to sleep; `null` while it runs. */
|
|
5174
|
+
slept_at: string | null;
|
|
5175
|
+
/** When its kept memory snapshot was written, if it has one. */
|
|
5176
|
+
snapshot_at: string | null;
|
|
5177
|
+
created_at: string;
|
|
5178
|
+
metadata: Metadata;
|
|
5179
|
+
}
|
|
5180
|
+
export type AgentInstanceList = Omit<ListEnvelope, "data"> & {
|
|
5181
|
+
data: AgentInstance[];
|
|
5182
|
+
};
|
|
5183
|
+
/**
|
|
5184
|
+
* How the instance was brought to the turn: `none` (it was running), `ram` (resumed from memory), `snapshot`
|
|
5185
|
+
* (restored from its memory snapshot), `disk` (cold booted from its disk, memory lost), `new` (made from the
|
|
5186
|
+
* agent). `null` until the session is delivered.
|
|
5187
|
+
*/
|
|
5188
|
+
export type AgentWokeFrom = "none" | "ram" | "snapshot" | "disk" | "new" | null;
|
|
5189
|
+
export interface AgentInstanceEvent {
|
|
5190
|
+
object: "agent_instance_event";
|
|
5191
|
+
type: "instance.created" | "instance.paused" | "instance.hibernated" | "instance.dormant" | "instance.woke" | "instance.failed" | "instance.recovered" | "instance.upgraded";
|
|
5192
|
+
ts: string;
|
|
5193
|
+
woke_from?: AgentWokeFrom;
|
|
5194
|
+
session_id?: string;
|
|
5195
|
+
detail?: string;
|
|
5196
|
+
}
|
|
5197
|
+
export type AgentInstanceEventList = Omit<ListEnvelope, "data"> & {
|
|
5198
|
+
data: AgentInstanceEvent[];
|
|
5199
|
+
};
|
|
5200
|
+
/**
|
|
5201
|
+
* Your message. Every member but the reserved ones (`type`, `conversation`, `subject`, `metadata`, `create`,
|
|
5202
|
+
* `webhook`) is yours, and reaches the harness as `message`, with `type`.
|
|
5203
|
+
*/
|
|
5204
|
+
export interface AgentMessageRequest {
|
|
5205
|
+
/**
|
|
5206
|
+
* What kind of message this is (a listener's actor sink sends `listener.event`).
|
|
5207
|
+
* @default "message"
|
|
3731
5208
|
*/
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
5209
|
+
type?: string;
|
|
5210
|
+
/** Your conversation or thread ID. Default, the `b3os.conversation` baggage. */
|
|
5211
|
+
conversation?: string;
|
|
5212
|
+
/** The end user the turn is for, an opaque ID, never an email. Default, the `b3os.subject` baggage. */
|
|
5213
|
+
subject?: string;
|
|
5214
|
+
metadata?: Metadata;
|
|
3738
5215
|
/**
|
|
3739
|
-
*
|
|
3740
|
-
*
|
|
3741
|
-
* restored on demand, a pool miss.
|
|
5216
|
+
* Make the instance if it does not exist. `false` answers `404 instance_not_found` instead.
|
|
5217
|
+
* @default true
|
|
3742
5218
|
*/
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
}[];
|
|
3747
|
-
created_at: string;
|
|
5219
|
+
create?: boolean;
|
|
5220
|
+
webhook?: WebhookConfig;
|
|
5221
|
+
[key: string]: unknown;
|
|
3748
5222
|
}
|
|
3749
|
-
|
|
3750
|
-
|
|
5223
|
+
/** Who sent the message, from its credential. */
|
|
5224
|
+
export interface AgentSessionInitiator {
|
|
5225
|
+
kind: "key" | "user" | "sandbox" | "instance" | "routine_run" | "listener";
|
|
5226
|
+
id: string;
|
|
5227
|
+
}
|
|
5228
|
+
/** One turn (`ses_…`); `result` is the harness's answer. */
|
|
5229
|
+
export type AgentSession = Omit<Job, "id" | "object"> & {
|
|
5230
|
+
id: string;
|
|
5231
|
+
object: "agent_session";
|
|
5232
|
+
/** Where the turn is; `status` says how it ended. */
|
|
5233
|
+
phase: "queued" | "waking" | "delivered" | "ended";
|
|
5234
|
+
agent_id: string;
|
|
5235
|
+
instance_id: string;
|
|
5236
|
+
key: AgentInstanceKey;
|
|
5237
|
+
revision: number;
|
|
5238
|
+
type: string;
|
|
5239
|
+
conversation: string | null;
|
|
5240
|
+
subject: string | null;
|
|
5241
|
+
initiator: AgentSessionInitiator;
|
|
5242
|
+
woke_from: AgentWokeFrom;
|
|
5243
|
+
/** The instance had failed and recovered for this turn; `woke_from` says how. */
|
|
5244
|
+
recovered: boolean;
|
|
5245
|
+
trace_id: string;
|
|
5246
|
+
};
|
|
5247
|
+
export type AgentSessionList = Omit<ListEnvelope, "data"> & {
|
|
5248
|
+
data: AgentSession[];
|
|
5249
|
+
};
|
|
5250
|
+
/**
|
|
5251
|
+
* `session.waking` carries `woke_from`; `session.output` carries `data`, one event the harness streamed, as text.
|
|
5252
|
+
*/
|
|
5253
|
+
export type AgentSessionEvent = JobEvent & {
|
|
5254
|
+
woke_from?: AgentWokeFrom;
|
|
5255
|
+
data?: string;
|
|
3751
5256
|
};
|
|
3752
5257
|
/**
|
|
3753
5258
|
* A routine as sent to PUT /v1/routines/{id} (ARCHITECTURE 5.4). GitHub-Actions-shaped: triggers, defaults and an ordered list of steps; expressions are CEL inside ${{ }}. Steps run in array order unless a step lists needs. Contexts, status functions, template rules and the divergences from GitHub Actions are in packages/spec/schemas/README.md. Compile-time rules JSON Schema cannot express (unique ids, needs pointing at earlier steps, references only to ancestors, retry forbidden on irreversible steps) are listed there under 'Routine publish checks'. Owner after freeze: routines.
|
|
@@ -3788,7 +5293,7 @@ export interface RoutineDefinition {
|
|
|
3788
5293
|
*/
|
|
3789
5294
|
durability?: "ephemeral" | "standard" | "strict";
|
|
3790
5295
|
/**
|
|
3791
|
-
* Default timeout for uses and map steps that do not set timeout_ms. Wait and sleep steps are not affected. A
|
|
5296
|
+
* Default timeout for uses and map steps that do not set timeout_ms. Wait and sleep steps are not affected. A product step (vision/*, render/*, sandboxes/*, infer/*) that sets neither waits as long as its operation allows instead: its operation's timeout (65 seconds for vision/search@1 and vision/scrape@1, 600 seconds for infer/chat@1, one hour for every job callable today), and 65 seconds for sandboxes/exec@1, whose one hour is a streamed exec's. A map step that sets neither waits what one item's steps may take in a row (each step's own timeout, added along the steps it needs) once per round of concurrency items, and at least 30 seconds.
|
|
3792
5297
|
* @default 30000
|
|
3793
5298
|
*/
|
|
3794
5299
|
timeout_ms?: number;
|
|
@@ -4407,12 +5912,519 @@ export interface SignalRequest {
|
|
|
4407
5912
|
payload?: unknown;
|
|
4408
5913
|
}
|
|
4409
5914
|
/**
|
|
4410
|
-
*
|
|
5915
|
+
* A CEL expression (the routines dialect, without `${{ }}`), compiled at create and run under a cost meter.
|
|
5916
|
+
* It sees `event` (`payload`, `headers`, `source`, `received_at`), `listener` (`id`, `name`, `metadata`) and
|
|
5917
|
+
* `now`; a source's `items` and `cursor` expressions see `response` (`status`, `headers`, `body`) and
|
|
5918
|
+
* `cursor` instead.
|
|
5919
|
+
*/
|
|
5920
|
+
export type CelExpression = string;
|
|
5921
|
+
/**
|
|
5922
|
+
* A vault connection in this project, injected by its type (`bearer`, `api_key`, `basic`, `oauth2`) into each
|
|
5923
|
+
* https request to the source when the URL's host is one of the connection's `hosts`. Resolved again at each
|
|
5924
|
+
* connect, so a rotated secret or a refreshed OAuth token applies from the next one. Needs `vault:run`.
|
|
5925
|
+
*/
|
|
5926
|
+
export type ConnectionId = string;
|
|
5927
|
+
/** Extra request headers. `Authorization`, `Cookie` and `Host` are refused here; use `connection`. */
|
|
5928
|
+
export type SourceHeaders = Record<string, string>;
|
|
5929
|
+
export interface HttpPollSource {
|
|
5930
|
+
type: "http_poll";
|
|
5931
|
+
/**
|
|
5932
|
+
* http or https. May hold `${{ cursor }}`, replaced (URL-encoded) by the current cursor, or by an empty string before the first one.
|
|
5933
|
+
*/
|
|
5934
|
+
url: string;
|
|
5935
|
+
/** @default "GET" */
|
|
5936
|
+
method?: "GET" | "POST";
|
|
5937
|
+
headers?: SourceHeaders;
|
|
5938
|
+
/** A JSON body for `POST`; string values may hold `${{ cursor }}`. */
|
|
5939
|
+
body?: unknown;
|
|
5940
|
+
connection?: ConnectionId;
|
|
5941
|
+
/**
|
|
5942
|
+
* Time between polls, from the end of one to the start of the next. 429 and 5xx answers back off up to 10 times this.
|
|
5943
|
+
* @default 60000
|
|
5944
|
+
*/
|
|
5945
|
+
interval_ms?: number;
|
|
5946
|
+
/**
|
|
5947
|
+
* The list of events in a response. Default `response.body` when it is a list, else `[response.body]`.
|
|
5948
|
+
*/
|
|
5949
|
+
items?: CelExpression;
|
|
5950
|
+
/**
|
|
5951
|
+
* The next cursor, from the response. It is stored only after every event of the response is in the log. `null` keeps the current one.
|
|
5952
|
+
*/
|
|
5953
|
+
cursor?: CelExpression;
|
|
5954
|
+
/**
|
|
5955
|
+
* `skip`: the first poll records what is there and emits nothing; `emit`: it emits every item.
|
|
5956
|
+
* @default "skip"
|
|
5957
|
+
*/
|
|
5958
|
+
initial?: "skip" | "emit";
|
|
5959
|
+
}
|
|
5960
|
+
export interface SseSource {
|
|
5961
|
+
type: "sse";
|
|
5962
|
+
/** http or https. */
|
|
5963
|
+
url: string;
|
|
5964
|
+
headers?: SourceHeaders;
|
|
5965
|
+
connection?: ConnectionId;
|
|
5966
|
+
/**
|
|
5967
|
+
* Keep only frames whose `event:` is one of these (`message` for frames without one). `null` keeps every frame.
|
|
5968
|
+
*/
|
|
5969
|
+
event_types?: string[] | null;
|
|
5970
|
+
/**
|
|
5971
|
+
* Reconnect when nothing (frames or comments) arrives for this long.
|
|
5972
|
+
* @default 90000
|
|
5973
|
+
*/
|
|
5974
|
+
idle_timeout_ms?: number;
|
|
5975
|
+
}
|
|
5976
|
+
/**
|
|
5977
|
+
* A WebSocket held by the node's socket holder (`b3os-listend`), a unit of its own, so a node release that
|
|
5978
|
+
* restarts the API server keeps the socket open: each frame is written to disk before anything reads it, and
|
|
5979
|
+
* the server reads what arrived while it was down. After a network drop or a restart of the holder itself the
|
|
5980
|
+
* source reconnects on HookBuffer's ladder (1, 2, 5, 10, 30, 60 s). The reconnect resumes when a cursor is
|
|
5981
|
+
* stored and the frames it sends (`resume`, else `subscribe`) hold `${{ cursor }}`; otherwise the time the
|
|
5982
|
+
* socket was down is a `gap` record in the history.
|
|
5983
|
+
*
|
|
5984
|
+
* A text frame that is JSON becomes the event's `payload` as JSON, any other text frame as a string, and a
|
|
5985
|
+
* binary frame as its base64 text with `headers.binary` true. A frame over `listeners.event_bytes_max` is
|
|
5986
|
+
* counted as failed and not kept.
|
|
5987
|
+
*/
|
|
5988
|
+
export interface WebsocketSource {
|
|
5989
|
+
type: "websocket";
|
|
5990
|
+
/** ws or wss. A `connection` is sent only in a wss handshake. */
|
|
5991
|
+
url: string;
|
|
5992
|
+
headers?: SourceHeaders;
|
|
5993
|
+
connection?: ConnectionId;
|
|
5994
|
+
/**
|
|
5995
|
+
* Frames sent after each connect, in order. An object or array is sent as its JSON text, a string as it is; string values may hold `${{ cursor }}`, replaced by the stored cursor (an empty string before the first).
|
|
5996
|
+
*/
|
|
5997
|
+
subscribe?: unknown[];
|
|
5998
|
+
/**
|
|
5999
|
+
* Frames sent instead of `subscribe` after a reconnect when a cursor is stored; string values may hold `${{ cursor }}`.
|
|
6000
|
+
*/
|
|
6001
|
+
resume?: unknown[];
|
|
6002
|
+
/**
|
|
6003
|
+
* The cursor after an event, from `event` (`payload`, `headers`). It is stored once the event is in the log; `null` keeps the current one.
|
|
6004
|
+
*/
|
|
6005
|
+
cursor?: CelExpression;
|
|
6006
|
+
/**
|
|
6007
|
+
* The events in one frame, from `frame` (its parsed JSON, or its text). By default a frame is one event. A frame whose `split` is not a list is counted as failed.
|
|
6008
|
+
*/
|
|
6009
|
+
split?: CelExpression;
|
|
6010
|
+
/**
|
|
6011
|
+
* A ping is sent this often; a socket that sends nothing (no pong, no frame) for twice this long is reconnected.
|
|
6012
|
+
* @default 30000
|
|
6013
|
+
*/
|
|
6014
|
+
ping_ms?: number;
|
|
6015
|
+
}
|
|
6016
|
+
/**
|
|
6017
|
+
* How a `webhook` source checks each delivery, as a routine's webhook trigger does. `b3os`: `B3OS-Signature:
|
|
6018
|
+
* t=<unix>,v1=<hex HMAC-SHA256(secret, "<t>.<body>")>` with a per-hook secret B3OS makes, shown once in the
|
|
6019
|
+
* create answer (`source.secret`). `github`, `stripe`, `slack`, `standard_webhooks`: the provider's own
|
|
6020
|
+
* scheme, with its signing secret in `secret`. `hmac_sha256`: a generic HMAC over `<value of
|
|
6021
|
+
* timestamp_header>.<body>` in `header` (`header` and `timestamp_header` are required, and `dedupe.key` must
|
|
6022
|
+
* be set). Timestamped schemes refuse a delivery more than `tolerance_s` from the node clock. Secrets never
|
|
6023
|
+
* appear in the URL.
|
|
6024
|
+
*/
|
|
6025
|
+
export interface ListenerWebhookVerify {
|
|
6026
|
+
scheme: "b3os" | "github" | "stripe" | "slack" | "standard_webhooks" | "hmac_sha256";
|
|
6027
|
+
/**
|
|
6028
|
+
* An `api_key` vault connection whose `api_key` holds the provider's signing secret. Keep it verification-only, with no pack and no hosts, so it is never injected into a request. Needs `vault:run`. Required for every scheme but `b3os`, and refused with it.
|
|
6029
|
+
*/
|
|
6030
|
+
secret?: string;
|
|
6031
|
+
/** `hmac_sha256` only: the header holding the signature. */
|
|
6032
|
+
header?: string;
|
|
6033
|
+
/** `hmac_sha256` only: how the signature is written. Default `hex`. */
|
|
6034
|
+
encoding?: "hex" | "base64";
|
|
6035
|
+
/** `hmac_sha256` only: text before the signature in `header`, such as `sha256=`. */
|
|
6036
|
+
prefix?: string;
|
|
6037
|
+
/** `hmac_sha256` only: the header holding the delivery's Unix timestamp. */
|
|
6038
|
+
timestamp_header?: string;
|
|
6039
|
+
/** @default 300 */
|
|
6040
|
+
tolerance_s?: number;
|
|
6041
|
+
}
|
|
6042
|
+
/**
|
|
6043
|
+
* Deliveries a provider sends to `hook_url` (`POST /v1/listeners/hooks/{hook_id}`), through the edge, which
|
|
6044
|
+
* queues them for 72 hours while the node is down. `hook_id`, `hook_url` and `secret` are set by B3OS and
|
|
6045
|
+
* refused in a request.
|
|
6046
|
+
*/
|
|
6047
|
+
export interface WebhookSource {
|
|
6048
|
+
type: "webhook";
|
|
6049
|
+
verify: ListenerWebhookVerify;
|
|
6050
|
+
hook_id?: string;
|
|
6051
|
+
/** Give this URL to the provider. */
|
|
6052
|
+
hook_url?: string;
|
|
6053
|
+
/** The `b3os` scheme's signing secret, in the create answer only. */
|
|
6054
|
+
secret?: string;
|
|
6055
|
+
}
|
|
6056
|
+
/**
|
|
6057
|
+
* A pack's trigger, as a routine's `type: action` trigger takes it: the actions trigger manager subscribes
|
|
6058
|
+
* (registering a provider webhook, or polling, or a schedule) and hands each event to the listener, keyed by
|
|
6059
|
+
* the trigger's own event ID. The event's `payload` is the trigger's `data`; its `headers` carry
|
|
6060
|
+
* `event_type`, `source`, `time` and `subscription_id`.
|
|
6061
|
+
*/
|
|
6062
|
+
export interface PackSource {
|
|
6063
|
+
type: "pack";
|
|
6064
|
+
/** `<namespace>/<pack>/<trigger>@<version or major>`, such as `io.b3os/github/push@1`. */
|
|
6065
|
+
uses: string;
|
|
6066
|
+
/** The trigger's configuration, valid against its `configSchema`. */
|
|
6067
|
+
with?: unknown;
|
|
6068
|
+
/**
|
|
6069
|
+
* Connection key to `conn_` ID; an unbound required key takes the project's most recent connection for it.
|
|
6070
|
+
*/
|
|
6071
|
+
connections?: Record<string, ConnectionId>;
|
|
6072
|
+
}
|
|
6073
|
+
/** Events arrive through `POST /v1/listeners/{listener_id}/events`. */
|
|
6074
|
+
export interface PushSource {
|
|
6075
|
+
type: "push";
|
|
6076
|
+
}
|
|
6077
|
+
export type ListenerSource = HttpPollSource | SseSource | WebsocketSource | WebhookSource | PackSource | PushSource;
|
|
6078
|
+
export interface ListenerDedupe {
|
|
6079
|
+
/**
|
|
6080
|
+
* The event's identity, turned into text. Defaults: the SSE frame's `id` when it has one, a push event's
|
|
6081
|
+
* `dedupe_key`, otherwise the SHA-256 of the payload's canonical JSON.
|
|
6082
|
+
*/
|
|
6083
|
+
key?: CelExpression;
|
|
6084
|
+
/**
|
|
6085
|
+
* How long a key is remembered; a repeat within it is dropped before the filter.
|
|
6086
|
+
* @default 86400
|
|
6087
|
+
*/
|
|
6088
|
+
window_s?: number;
|
|
6089
|
+
}
|
|
6090
|
+
export interface ListenerFilter {
|
|
6091
|
+
/**
|
|
6092
|
+
* Keep the event when this is `true`. An evaluation error drops the event as `filtered`, with the error in its record.
|
|
6093
|
+
*/
|
|
6094
|
+
cel?: CelExpression;
|
|
6095
|
+
model?: ListenerModelFilter;
|
|
6096
|
+
}
|
|
6097
|
+
/**
|
|
6098
|
+
* One question to the small model (`b3os/qwen3.5-9b`) about each event CEL kept, asked after the event is in the
|
|
6099
|
+
* log and before the sink. The answer is `{match, reason}` plus `fields`; `match: false` ends the event
|
|
6100
|
+
* `filtered`. Calls run as the listener's owner (`infer:run`) and bill infer tokens, at most
|
|
6101
|
+
* `listeners.model_filter.rpm` a minute per listener, in order.
|
|
6102
|
+
*/
|
|
6103
|
+
export interface ListenerModelFilter {
|
|
6104
|
+
/** The question, such as "Does this mail ask for something that must happen today?". */
|
|
6105
|
+
prompt: string;
|
|
6106
|
+
/**
|
|
6107
|
+
* The event's payload is cut to about this many tokens (four bytes of JSON each).
|
|
6108
|
+
* @default 2048
|
|
6109
|
+
*/
|
|
6110
|
+
max_input_tokens?: number;
|
|
6111
|
+
/**
|
|
6112
|
+
* A JSON-schema object (`type: object`, at most 16 `properties`, none named `match` or `reason`) of extra values the model returns beside them; they are recorded in the event's `filter.model.fields`.
|
|
6113
|
+
*/
|
|
6114
|
+
fields?: Record<string, unknown>;
|
|
6115
|
+
/**
|
|
6116
|
+
* What happens to an event the model could not judge (an error, a timeout, output that does not parse, the token budget spent).
|
|
6117
|
+
* @default "drop"
|
|
6118
|
+
*/
|
|
6119
|
+
on_error?: "drop" | "pass";
|
|
6120
|
+
}
|
|
6121
|
+
/**
|
|
6122
|
+
* Hand kept events to the sink together: once `max_events` are waiting, or once the oldest has waited
|
|
6123
|
+
* `max_wait_ms`. One delivery is `{type: listener.batch, id, dedupe_key, count, first_seq, last_seq, events}`:
|
|
6124
|
+
* `events` in the order the listener kept them, each with its own `dedupe_key`, and the batch's `dedupe_key`
|
|
6125
|
+
* a digest of theirs, so a receiver that sees the same batch twice can drop it. A routine sink starts one run
|
|
6126
|
+
* per batch with the batch as its `trigger`. Needs `concurrency: 1`, and for a routine sink `mode: run`.
|
|
6127
|
+
*/
|
|
6128
|
+
export interface ListenerBatch {
|
|
6129
|
+
max_events: number;
|
|
6130
|
+
/** @default 1000 */
|
|
6131
|
+
max_wait_ms?: number;
|
|
6132
|
+
}
|
|
6133
|
+
export interface RoutineSink {
|
|
6134
|
+
type: "routine";
|
|
6135
|
+
/** The routine's ID (`rtn_…`) or name in this project. Needs `routines:run`. */
|
|
6136
|
+
routine: string;
|
|
6137
|
+
/**
|
|
6138
|
+
* `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` starts no
|
|
6140
|
+
* second run. `event` sends the event to the routine's runs waiting with `wait: {event: <event>}`
|
|
6141
|
+
* (`routinesSendEvent`), with `data` = the payload.
|
|
6142
|
+
* @default "run"
|
|
6143
|
+
*/
|
|
6144
|
+
mode?: "run" | "event";
|
|
6145
|
+
/** The event name, for `mode: event` (required there). */
|
|
6146
|
+
event?: string | null;
|
|
6147
|
+
/**
|
|
6148
|
+
* Deliveries in flight at once. With 1, events arrive in the order the listener kept them.
|
|
6149
|
+
* @default 1
|
|
6150
|
+
*/
|
|
6151
|
+
concurrency?: number;
|
|
6152
|
+
/**
|
|
6153
|
+
* How long a retryable failure (5xx, 429, 503) is retried, with backoff, before the event is `failed`.
|
|
6154
|
+
* @default 86400
|
|
6155
|
+
*/
|
|
6156
|
+
retry_for_s?: number;
|
|
6157
|
+
batch?: ListenerBatch;
|
|
6158
|
+
}
|
|
6159
|
+
export interface WebhookSink {
|
|
6160
|
+
type: "webhook";
|
|
6161
|
+
/**
|
|
6162
|
+
* https. Each kept event is POSTed as a `WebhookEvent` (`type: listener.event`, `job_id` = the listener)
|
|
6163
|
+
* signed with `B3OS-Signature` under the endpoint's secret (`POST /v1/webhooks/secret`), through the
|
|
6164
|
+
* egress guard and retried for 24 hours. Its `data` is `{type: listener, id, event_id, seq, dedupe_key,
|
|
6165
|
+
* received_at, payload}`; `data.dedupe_key` (32 hex characters, a digest of the listener and the event's
|
|
6166
|
+
* key) is the same on every delivery of one event, so a receiver can drop a repeat. With `batch`, the
|
|
6167
|
+
* event type is `listener.batch` and `data` is the batch (`ListenerBatch`).
|
|
6168
|
+
*/
|
|
6169
|
+
url: string;
|
|
6170
|
+
/** @default 1 */
|
|
6171
|
+
concurrency?: number;
|
|
6172
|
+
/** @default 86400 */
|
|
6173
|
+
retry_for_s?: number;
|
|
6174
|
+
batch?: ListenerBatch;
|
|
6175
|
+
}
|
|
6176
|
+
export type ListenerSink = RoutineSink | WebhookSink;
|
|
6177
|
+
/**
|
|
6178
|
+
* JSON pointers into the payload (`/customer/email`). Their values are replaced by `"[redacted]"` before the
|
|
6179
|
+
* event is written anywhere: the log, the history and the sink's copy. A pointer that does not exist in an
|
|
6180
|
+
* event changes nothing. The filter sees the redacted event too.
|
|
6181
|
+
*/
|
|
6182
|
+
export type ListenerRedact = string[];
|
|
6183
|
+
export interface ListenerBudgetRequest {
|
|
6184
|
+
/**
|
|
6185
|
+
* Events the filter may keep per UTC day. At the limit, delivery pauses (`status_reason: budget`) and further events are kept as `skipped` until the day ends. At most the organization's `listeners.events.daily`.
|
|
6186
|
+
*/
|
|
6187
|
+
events_per_day?: number;
|
|
6188
|
+
/**
|
|
6189
|
+
* Infer tokens the model filter may spend per UTC day; past it, events go by `filter.model.on_error`. Default and at most ten times the organization's `listeners.model_tokens.default`.
|
|
6190
|
+
*/
|
|
6191
|
+
model_tokens_per_day?: number;
|
|
6192
|
+
}
|
|
6193
|
+
export interface ListenerCreateRequest {
|
|
6194
|
+
/** A label; not unique. */
|
|
6195
|
+
name?: string | null;
|
|
6196
|
+
source: ListenerSource;
|
|
6197
|
+
dedupe?: ListenerDedupe;
|
|
6198
|
+
filter?: ListenerFilter;
|
|
6199
|
+
sink: ListenerSink;
|
|
6200
|
+
redact?: ListenerRedact;
|
|
6201
|
+
/** Seconds from now until the listener ends `expired`. Not with `expires_at`. */
|
|
6202
|
+
ttl_s?: number;
|
|
6203
|
+
/** When the listener ends `expired`. Not with `ttl_s`. */
|
|
6204
|
+
expires_at?: string;
|
|
6205
|
+
budget?: ListenerBudgetRequest;
|
|
6206
|
+
metadata?: Metadata;
|
|
6207
|
+
}
|
|
6208
|
+
export interface ListenerUpdateRequest {
|
|
6209
|
+
paused?: boolean;
|
|
6210
|
+
/** Seconds from now until the listener ends `expired`. Not with `expires_at`. */
|
|
6211
|
+
ttl_s?: number;
|
|
6212
|
+
/** When the listener ends `expired`; `null` lets it live until deleted. */
|
|
6213
|
+
expires_at?: string | null;
|
|
6214
|
+
filter?: ListenerFilter;
|
|
6215
|
+
sink?: ListenerSink;
|
|
6216
|
+
redact?: ListenerRedact;
|
|
6217
|
+
budget?: ListenerBudgetRequest;
|
|
6218
|
+
metadata?: Metadata;
|
|
6219
|
+
}
|
|
6220
|
+
/**
|
|
6221
|
+
* `starting` until the first connect or poll succeeds; `active`; `reconnecting` while the source is down and
|
|
6222
|
+
* being retried; `paused` (`status_reason` `user` or `budget`); then the ends: `failed` (`error` says why),
|
|
6223
|
+
* `expired` (its lifetime passed) and `revoked` (its owner key was revoked or expired, or its sandbox ended).
|
|
6224
|
+
*/
|
|
6225
|
+
export type ListenerStatus = "starting" | "active" | "reconnecting" | "paused" | "failed" | "expired" | "revoked";
|
|
6226
|
+
export interface Listener {
|
|
6227
|
+
id: string;
|
|
6228
|
+
object: "listener";
|
|
6229
|
+
name: string | null;
|
|
6230
|
+
status: ListenerStatus;
|
|
6231
|
+
status_reason: "user" | "budget" | "auth" | "egress_denied" | "source_errors" | "owner_revoked" | "sandbox_ended" | null;
|
|
6232
|
+
/** Why the source last failed, or why the listener ended `failed`. */
|
|
6233
|
+
error: {
|
|
6234
|
+
code: string;
|
|
6235
|
+
detail: string;
|
|
6236
|
+
at: string;
|
|
6237
|
+
} | null;
|
|
6238
|
+
source: ListenerSource;
|
|
6239
|
+
source_state: {
|
|
6240
|
+
/** The stored cursor (`http_poll`, `websocket`) or last event ID (`sse`); `null` before the first. */
|
|
6241
|
+
cursor: unknown;
|
|
6242
|
+
connected_since: string | null;
|
|
6243
|
+
/** The next poll, or the next reconnect attempt while `reconnecting`. */
|
|
6244
|
+
next_attempt_at: string | null;
|
|
6245
|
+
};
|
|
6246
|
+
dedupe: ListenerDedupe;
|
|
6247
|
+
filter: ListenerFilter;
|
|
6248
|
+
sink: ListenerSink;
|
|
6249
|
+
redact: ListenerRedact;
|
|
6250
|
+
expires_at: string | null;
|
|
6251
|
+
budget: {
|
|
6252
|
+
events_per_day: number;
|
|
6253
|
+
model_tokens_per_day: number;
|
|
6254
|
+
used: {
|
|
6255
|
+
events: number;
|
|
6256
|
+
model_tokens: number;
|
|
6257
|
+
window_start: string;
|
|
6258
|
+
};
|
|
6259
|
+
};
|
|
6260
|
+
owner: {
|
|
6261
|
+
kind: "key" | "project";
|
|
6262
|
+
/** The owning key (`key_…`) or project (`prj_…`). */
|
|
6263
|
+
id: string;
|
|
6264
|
+
/** The sandbox that created it, when one did; the listener ends with that sandbox's root. */
|
|
6265
|
+
sandbox: string | null;
|
|
6266
|
+
};
|
|
6267
|
+
stats: {
|
|
6268
|
+
received: number;
|
|
6269
|
+
delivered: number;
|
|
6270
|
+
filtered: number;
|
|
6271
|
+
duplicates: number;
|
|
6272
|
+
failed: number;
|
|
6273
|
+
skipped: number;
|
|
6274
|
+
reconnects: number;
|
|
6275
|
+
last_event_at: string | null;
|
|
6276
|
+
};
|
|
6277
|
+
created_at: string;
|
|
6278
|
+
updated_at: string;
|
|
6279
|
+
metadata: Metadata;
|
|
6280
|
+
}
|
|
6281
|
+
export type ListenerList = Omit<ListEnvelope, "data"> & {
|
|
6282
|
+
data: Listener[];
|
|
6283
|
+
};
|
|
6284
|
+
/**
|
|
6285
|
+
* `pending` (in the log, being delivered or retried), `delivered`, `filtered` (the filter dropped it or could
|
|
6286
|
+
* not evaluate), `failed` (the sink refused it, or kept failing for `retry_for_s`), `skipped` (the budget was
|
|
6287
|
+
* spent).
|
|
6288
|
+
*/
|
|
6289
|
+
export type ListenerEventStatus = "pending" | "delivered" | "filtered" | "failed" | "skipped";
|
|
6290
|
+
export interface ListenerEvent {
|
|
6291
|
+
id: string;
|
|
6292
|
+
object: "listener_event";
|
|
6293
|
+
listener: string;
|
|
6294
|
+
/** The listener's own sequence number, from 1, gap records included. */
|
|
6295
|
+
seq: number;
|
|
6296
|
+
kind: "event" | "gap";
|
|
6297
|
+
received_at: string;
|
|
6298
|
+
dedupe_key: string | null;
|
|
6299
|
+
/** The event as the source sent it (JSON, or a string for text), after `redact`. `null` for a gap. */
|
|
6300
|
+
payload: unknown;
|
|
6301
|
+
payload_truncated: boolean;
|
|
6302
|
+
filter: {
|
|
6303
|
+
cel?: boolean | null;
|
|
6304
|
+
error?: string | null;
|
|
6305
|
+
/**
|
|
6306
|
+
* The model filter's verdict, `{match, reason, fields, tokens}`, or when it could not judge `{match: null, error: {code, detail}, on_error, tokens}`.
|
|
6307
|
+
*/
|
|
6308
|
+
model?: {
|
|
6309
|
+
match?: boolean | null;
|
|
6310
|
+
reason?: string;
|
|
6311
|
+
fields?: Record<string, unknown>;
|
|
6312
|
+
tokens?: number;
|
|
6313
|
+
error?: {
|
|
6314
|
+
code?: string;
|
|
6315
|
+
detail?: string;
|
|
6316
|
+
};
|
|
6317
|
+
on_error?: "drop" | "pass";
|
|
6318
|
+
} | null;
|
|
6319
|
+
} | null;
|
|
6320
|
+
status: ListenerEventStatus | null;
|
|
6321
|
+
delivery: {
|
|
6322
|
+
attempts: number;
|
|
6323
|
+
/** The run (`run_…`) or webhook delivery the sink made. */
|
|
6324
|
+
sink_ref: string | null;
|
|
6325
|
+
delivered_at: string | null;
|
|
6326
|
+
last_error: {
|
|
6327
|
+
code?: string;
|
|
6328
|
+
detail?: string;
|
|
6329
|
+
} | null;
|
|
6330
|
+
} | null;
|
|
6331
|
+
/** For `kind: gap`, the time the source was down. */
|
|
6332
|
+
gap: {
|
|
6333
|
+
from: string;
|
|
6334
|
+
to: string;
|
|
6335
|
+
reason: "disconnected" | "node_restart" | "backlog_full";
|
|
6336
|
+
} | null;
|
|
6337
|
+
/**
|
|
6338
|
+
* Where the node spent the time between receiving the event and its sink accepting it, measured on the node
|
|
6339
|
+
* in milliseconds with microsecond resolution (the platform's `Timing`). `append_ms`: from receipt (the frame
|
|
6340
|
+
* read, the poll's response or the request in hand) to the event durable in the listener's log; dedupe and
|
|
6341
|
+
* the CEL filter run inside it. `filter_ms`: the model filter's question, only when it was asked.
|
|
6342
|
+
* `sink_ms`: from the log, or the model filter's verdict, to the sink accepting the event (a run created, a
|
|
6343
|
+
* webhook delivery queued, a batch handed over), the wait for the delivery task, every retry and a batch's
|
|
6344
|
+
* wait included. `total_ms`: from receipt to the last phase the event reached. A phase the event did not
|
|
6345
|
+
* go through is left out: an event the filter dropped has no `sink_ms`. Absent on a gap record, on an
|
|
6346
|
+
* event still on its way to the sink, and on events whose receipt the node did not see (kept before a
|
|
6347
|
+
* restart of b3osd, or before the node recorded timing).
|
|
6348
|
+
*/
|
|
6349
|
+
timing?: Timing | null;
|
|
6350
|
+
}
|
|
6351
|
+
export type ListenerEventList = Omit<ListEnvelope, "data"> & {
|
|
6352
|
+
data: ListenerEvent[];
|
|
6353
|
+
};
|
|
6354
|
+
export interface ListenerStreamFrame {
|
|
6355
|
+
type: "listener.event" | "listener.gap" | "listener.status";
|
|
6356
|
+
ts: string;
|
|
6357
|
+
seq: number;
|
|
6358
|
+
event?: ListenerEvent | null;
|
|
6359
|
+
status?: ListenerStatus | null;
|
|
6360
|
+
}
|
|
6361
|
+
export interface ListenerIngestRequest {
|
|
6362
|
+
events: {
|
|
6363
|
+
/** Any JSON value, at most `listeners.event_bytes_max` when serialized. */
|
|
6364
|
+
payload: unknown;
|
|
6365
|
+
dedupe_key?: string;
|
|
6366
|
+
}[];
|
|
6367
|
+
}
|
|
6368
|
+
export interface ListenerIngestResult {
|
|
6369
|
+
object: "listener_ingest";
|
|
6370
|
+
accepted: number;
|
|
6371
|
+
duplicates: number;
|
|
6372
|
+
events: {
|
|
6373
|
+
/** The event's ID; `null` for a duplicate. */
|
|
6374
|
+
id: string | null;
|
|
6375
|
+
seq: number | null;
|
|
6376
|
+
status: "pending" | "duplicate";
|
|
6377
|
+
}[];
|
|
6378
|
+
}
|
|
6379
|
+
export interface ListenerTestRequest {
|
|
6380
|
+
/** A sample event payload. */
|
|
6381
|
+
payload: unknown;
|
|
6382
|
+
/** @default false */
|
|
6383
|
+
deliver?: boolean;
|
|
6384
|
+
}
|
|
6385
|
+
export interface ListenerTestResult {
|
|
6386
|
+
object: "listener_test";
|
|
6387
|
+
dedupe_key: string | null;
|
|
6388
|
+
/** Whether the key is in the dedupe window now. */
|
|
6389
|
+
duplicate: boolean;
|
|
6390
|
+
filter: {
|
|
6391
|
+
cel?: boolean | null;
|
|
6392
|
+
error?: string | null;
|
|
6393
|
+
};
|
|
6394
|
+
/** Whether the listener would keep the event (not a duplicate, and the filter passed). */
|
|
6395
|
+
kept: boolean;
|
|
6396
|
+
/** With `deliver: true` and a kept event, the event as written to the log. */
|
|
6397
|
+
event: ListenerEvent | null;
|
|
6398
|
+
}
|
|
6399
|
+
/**
|
|
6400
|
+
* One JSON-RPC 2.0 message of the Model Context Protocol (https://modelcontextprotocol.io): a request
|
|
6401
|
+
* (`method` and `id`), a notification (`method`, no `id`) or a response (`result` or `error`). Methods served:
|
|
6402
|
+
* `initialize`, `server/discover`, `ping`, `tools/list`, `tools/call`, the empty `resources/list`,
|
|
6403
|
+
* `resources/templates/list` and `prompts/list`, and every `notifications/*`.
|
|
6404
|
+
*/
|
|
6405
|
+
export interface McpMessage {
|
|
6406
|
+
jsonrpc: "2.0";
|
|
6407
|
+
/** A string, an integer or `null` (a response to a message whose id could not be read). */
|
|
6408
|
+
id?: unknown;
|
|
6409
|
+
method?: string;
|
|
6410
|
+
params?: Record<string, unknown>;
|
|
6411
|
+
result?: Record<string, unknown>;
|
|
6412
|
+
error?: {
|
|
6413
|
+
code: number;
|
|
6414
|
+
message: string;
|
|
6415
|
+
data?: unknown;
|
|
6416
|
+
};
|
|
6417
|
+
}
|
|
6418
|
+
/**
|
|
6419
|
+
* One manifest per pack: connections, egress, actions (T0 declarative HTTP, T1 first-party JS, or vm: a hosted tool's command run in a fresh microVM), triggers (webhook, poll, schedule), fixtures, pricing and the publisher signature. A pack whose actions are vm is a hosted tool and has a tool block. Field names follow research/b3os-actions.md section 12.3 (camelCase, like MCP). Every string that contains ${{ }} is a CEL template; the template rules and CEL contexts are in packages/spec/schemas/README.md. Rules JSON Schema cannot express (unique action keys, egress subset, connection references, effect consistency, what a hosted tool may declare in this version) are listed in the README under 'b3pack publish checks' and are enforced by the actions registry and by examples/validate.mjs. Owner after freeze: actions.
|
|
4411
6420
|
*/
|
|
4412
6421
|
export interface B3Pack {
|
|
4413
6422
|
/** Optional pointer to this schema for editors. Ignored by the runtime. */
|
|
4414
6423
|
$schema?: string;
|
|
4415
6424
|
pack: B3PackPackId;
|
|
6425
|
+
/**
|
|
6426
|
+
* The version. <x.y.z>-dev.<unix seconds> is a dev version (README, publish check 23): org-private tools only, outside the version limit, and replaced by the next dev version of the pack.
|
|
6427
|
+
*/
|
|
4416
6428
|
version: B3PackSemver;
|
|
4417
6429
|
title: string;
|
|
4418
6430
|
description: string;
|
|
@@ -4440,7 +6452,7 @@ export interface B3Pack {
|
|
|
4440
6452
|
sizes?: string[];
|
|
4441
6453
|
}[];
|
|
4442
6454
|
/**
|
|
4443
|
-
* Pack runtime API the pack needs, as a caret range (npm and Cargo read it the same way). The
|
|
6455
|
+
* Pack runtime API the pack needs, as a caret range (npm and Cargo read it the same way). The runtime is 1.1.0: packs without a tool block declare ^1, ^1.0 or ^1.1; a pack with a tool block declares ^1.1 or later (the vm kind is runtime API 1.1), so a node from before hosted tools refuses it instead of loading half of it.
|
|
4444
6456
|
*/
|
|
4445
6457
|
engine: string;
|
|
4446
6458
|
/**
|
|
@@ -4454,9 +6466,10 @@ export interface B3Pack {
|
|
|
4454
6466
|
actions: B3PackAction[];
|
|
4455
6467
|
triggers?: B3PackTrigger[];
|
|
4456
6468
|
/**
|
|
4457
|
-
* Default price for every action that does not set its own.
|
|
6469
|
+
* Default price for every action that does not set its own. A price is charged on vm actions only (a hosted tool's publisher price, usage unit actions.publisher_microusd); packs without vm actions are free and the node still meters actions.call (ARCHITECTURE 4.5).
|
|
4458
6470
|
*/
|
|
4459
6471
|
pricing?: B3PackPricing;
|
|
6472
|
+
tool?: B3PackTool;
|
|
4460
6473
|
compat?: {
|
|
4461
6474
|
/**
|
|
4462
6475
|
* Maps an action key in this pack to the flat action id it replaces in the old B3OS catalog (research 12.3, 13). Used by the importer so old workflows resolve.
|
|
@@ -4508,7 +6521,7 @@ export interface B3PackEgressEntry {
|
|
|
4508
6521
|
schemes?: Array<"https" | "http">;
|
|
4509
6522
|
}
|
|
4510
6523
|
/**
|
|
4511
|
-
* A JSON Schema 2020-12 document whose top level describes an object (MCP requires object-typed inputSchema and outputSchema). Objects should be closed (additionalProperties false) unless declared open (research 12.4). x-b3-* keywords (x-b3-widget, x-b3-semantic, x-b3-options, ...) are allowed as annotations and ignored by validation.
|
|
6524
|
+
* A JSON Schema 2020-12 document whose top level describes an object (MCP requires object-typed inputSchema and outputSchema). Objects should be closed (additionalProperties false) unless declared open (research 12.4). x-b3-* keywords (x-b3-widget, x-b3-semantic, x-b3-options, ...) are allowed as annotations and ignored by validation. x-b3os-file marks a file field of a vm action: on a top-level property of inputSchema it is {"accept": [media types]} and the property's value is a file value; on a top-level property of outputSchema it is {"produces": [media types]} and the tool answers {"path": "/out/<name>"} there (README, 'b3pack publish checks' 19).
|
|
4512
6525
|
*/
|
|
4513
6526
|
export type B3PackJsonSchemaObject = JsonSchemaDocument & {
|
|
4514
6527
|
type: "object";
|
|
@@ -4563,11 +6576,12 @@ export interface B3PackEffects {
|
|
|
4563
6576
|
class: "pure" | "read" | "write" | "irreversible";
|
|
4564
6577
|
}
|
|
4565
6578
|
/**
|
|
4566
|
-
* Publisher price on top of the platform's actions.
|
|
6579
|
+
* Publisher price, charged on vm actions only, on top of the platform's own meters (a hosted tool's call bills actions.tool_call, actions.vcpu_ms and actions.gib_ms; the price is actions.publisher_microusd). First-party packs and org-private tools are free. Amounts are decimal strings in USD to avoid float rounding; the publish checks hold usd to at most 6 decimal places, so it is a whole number of micro-USD, and to at most 1 USD a call (per_call), 0.01 USD a second (per_second) or 0.01 USD a MiB (per_input_mb). per_call charges usd once per call; per_second charges ceil(usd in micro-USD x run_ms / 1000), run_ms being the node's clock around the tool's own command only (copy and unpack never count); per_input_mb charges ceil(usd in micro-USD x in_bytes / 1048576), in_bytes being the call's input file bytes plus its stdin JSON. A price is charged only on a call that answered validly. freeCalls (priced models only): the calls each calling organization makes free of the price each UTC month, per pack, counted on the node.
|
|
4567
6580
|
*/
|
|
4568
6581
|
export interface B3PackPricing {
|
|
4569
|
-
model: "free" | "per_call";
|
|
6582
|
+
model: "free" | "per_call" | "per_second" | "per_input_mb";
|
|
4570
6583
|
usd?: string;
|
|
6584
|
+
freeCalls?: number;
|
|
4571
6585
|
}
|
|
4572
6586
|
export type B3PackHeaderName = string;
|
|
4573
6587
|
/**
|
|
@@ -4619,7 +6633,7 @@ export interface B3PackHttpResponse {
|
|
|
4619
6633
|
}[];
|
|
4620
6634
|
}
|
|
4621
6635
|
/**
|
|
4622
|
-
* 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).
|
|
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').
|
|
4623
6637
|
*/
|
|
4624
6638
|
export type B3PackImpl = {
|
|
4625
6639
|
kind: "http";
|
|
@@ -4636,6 +6650,16 @@ export type B3PackImpl = {
|
|
|
4636
6650
|
* @default "run"
|
|
4637
6651
|
*/
|
|
4638
6652
|
export?: string;
|
|
6653
|
+
} | {
|
|
6654
|
+
kind: "vm";
|
|
6655
|
+
/**
|
|
6656
|
+
* The request is one JSON object on stdin; the answer is the last line of stdout, {"output": ...} or {"error": {code, message, retryable}}, with exit status 0 either way.
|
|
6657
|
+
*/
|
|
6658
|
+
protocol: "json-stdio";
|
|
6659
|
+
/**
|
|
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/ (publish check 18).
|
|
6661
|
+
*/
|
|
6662
|
+
cmd: string[];
|
|
4639
6663
|
};
|
|
4640
6664
|
export type B3PackExample = {
|
|
4641
6665
|
fixture: B3PackFixturePath;
|
|
@@ -4669,9 +6693,24 @@ export type B3PackAction = {
|
|
|
4669
6693
|
egress?: B3PackEgressEntry[];
|
|
4670
6694
|
execution?: {
|
|
4671
6695
|
/**
|
|
4672
|
-
* Wall-clock budget per call, including upstream time. Default 10000 for http, 30000 for js. A caller's shorter deadline wins.
|
|
6696
|
+
* Wall-clock budget per call, including upstream time. Default 10000 for http, 30000 for js and vm; at most 60000 for vm. A caller's shorter deadline wins, except on a priced vm action, where a shorter timeout_ms is refused.
|
|
4673
6697
|
*/
|
|
4674
6698
|
timeoutMs?: number;
|
|
6699
|
+
/**
|
|
6700
|
+
* vm only: the most input file data one call may carry, in MiB, summed over its file values ($bytes, $url and $file alike). Default 16, at most 64.
|
|
6701
|
+
* @default 16
|
|
6702
|
+
*/
|
|
6703
|
+
maxInputMb?: number;
|
|
6704
|
+
/**
|
|
6705
|
+
* vm only: the most output file data one call may return, in MiB, summed over its output files. Default 16, at most 64.
|
|
6706
|
+
* @default 16
|
|
6707
|
+
*/
|
|
6708
|
+
maxOutputMb?: number;
|
|
6709
|
+
/**
|
|
6710
|
+
* vm only: the most output files one call may return. Default 4, at most 16.
|
|
6711
|
+
* @default 4
|
|
6712
|
+
*/
|
|
6713
|
+
maxOutputFiles?: number;
|
|
4675
6714
|
/** T1 only: V8 old-generation limit of the worker running the call. Default 128. */
|
|
4676
6715
|
memoryMb?: number;
|
|
4677
6716
|
/**
|
|
@@ -4688,7 +6727,9 @@ export type B3PackAction = {
|
|
|
4688
6727
|
examples?: B3PackExample[];
|
|
4689
6728
|
pricing?: B3PackPricing;
|
|
4690
6729
|
mcp?: {
|
|
4691
|
-
/**
|
|
6730
|
+
/**
|
|
6731
|
+
* MCP tool name override; must be unique in the pack. A name that starts with browser_, vision_ or render_ (and not another _ after it) is reserved for B3OS's product tools (node release 1119).
|
|
6732
|
+
*/
|
|
4692
6733
|
name?: string;
|
|
4693
6734
|
/**
|
|
4694
6735
|
* false keeps the action out of tools/list (still callable through actions_call). Default true.
|
|
@@ -4840,6 +6881,103 @@ export type B3PackTrigger = {
|
|
|
4840
6881
|
/** Task phrases for this trigger (when an issue is opened). */
|
|
4841
6882
|
aliases?: B3PackSearchPhrases;
|
|
4842
6883
|
};
|
|
6884
|
+
/**
|
|
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, image, formats, bundle.files, base.range), so that what this version refuses is refused with a plain sentence of the publish checks rather than a schema error.
|
|
6886
|
+
*/
|
|
6887
|
+
export interface B3PackTool {
|
|
6888
|
+
/**
|
|
6889
|
+
* 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
|
+
*/
|
|
6891
|
+
kind: "cli" | "mcp";
|
|
6892
|
+
/** The shared template the tool runs on. Bases have no versions yet. */
|
|
6893
|
+
base: {
|
|
6894
|
+
name: "base" | "files" | "browser" | "code-interpreter";
|
|
6895
|
+
/** Reserved: not read, because bases have no versions yet. Refused in this version. */
|
|
6896
|
+
range?: string;
|
|
6897
|
+
};
|
|
6898
|
+
/**
|
|
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.
|
|
6900
|
+
*/
|
|
6901
|
+
size?: {
|
|
6902
|
+
vcpu: number;
|
|
6903
|
+
memoryMb: number;
|
|
6904
|
+
};
|
|
6905
|
+
/**
|
|
6906
|
+
* Where the tool's files come from. This version reads one archive, unpacked at /tool before each call.
|
|
6907
|
+
*/
|
|
6908
|
+
bundle?: {
|
|
6909
|
+
archive?: B3PackToolArchive;
|
|
6910
|
+
/**
|
|
6911
|
+
* Reserved: files carried inside the pack bundle under tool/, with their sources (later versions). Refused in this version.
|
|
6912
|
+
*/
|
|
6913
|
+
files?: unknown[];
|
|
6914
|
+
};
|
|
6915
|
+
/**
|
|
6916
|
+
* call: one fresh VM per call, deleted before the call answers. session (later): a keyed instance kept between calls.
|
|
6917
|
+
*/
|
|
6918
|
+
runtime?: {
|
|
6919
|
+
mode: "call" | "session";
|
|
6920
|
+
/** Reserved for session tools. */
|
|
6921
|
+
start?: unknown;
|
|
6922
|
+
/** Reserved for session tools. */
|
|
6923
|
+
ready?: unknown;
|
|
6924
|
+
/** Reserved for session tools. */
|
|
6925
|
+
idleS?: number;
|
|
6926
|
+
/** Reserved for session tools. */
|
|
6927
|
+
maxS?: number;
|
|
6928
|
+
};
|
|
6929
|
+
/**
|
|
6930
|
+
* What the tool's VM may reach. none: nothing (egress deny); the pack's egress list is empty. hosts (later): the pack's egress list, port 443 only. caller (later, first-party only): hosts the caller names.
|
|
6931
|
+
*/
|
|
6932
|
+
network?: {
|
|
6933
|
+
mode: "none" | "hosts" | "caller";
|
|
6934
|
+
};
|
|
6935
|
+
/** The software the tool runs and did not write. Stored and returned by describe. */
|
|
6936
|
+
upstream?: {
|
|
6937
|
+
name: string;
|
|
6938
|
+
url: string;
|
|
6939
|
+
version: string;
|
|
6940
|
+
/** SPDX license expression. */
|
|
6941
|
+
license: string;
|
|
6942
|
+
/** Where the publisher got the upstream's files, and their digest. */
|
|
6943
|
+
obtained?: {
|
|
6944
|
+
url: string;
|
|
6945
|
+
sha256?: string;
|
|
6946
|
+
};
|
|
6947
|
+
patchedBy?: string;
|
|
6948
|
+
trademarkPolicy?: string;
|
|
6949
|
+
}[];
|
|
6950
|
+
/**
|
|
6951
|
+
* Bundle-relative path of the notices file (licences, attributions, 'Not affiliated with ...'). It must be a file of the pack bundle.
|
|
6952
|
+
*/
|
|
6953
|
+
notices?: string;
|
|
6954
|
+
/**
|
|
6955
|
+
* Reserved: a command run once when the node prepares the tool's snapshot (later). Refused in this version.
|
|
6956
|
+
*/
|
|
6957
|
+
setup?: unknown;
|
|
6958
|
+
/** Reserved: an imported image's artifact (later). Refused in this version. */
|
|
6959
|
+
image?: unknown;
|
|
6960
|
+
/** Reserved: output formats a takedown can turn off by name (later). Refused in this version. */
|
|
6961
|
+
formats?: unknown;
|
|
6962
|
+
/**
|
|
6963
|
+
* The error codes the tool answers with ({"error": {"code": ...}}), so the publisher's health view counts each one. A code the list does not name still reaches the caller as tool_code, and the health view counts it as undeclared.
|
|
6964
|
+
*/
|
|
6965
|
+
errors?: string[];
|
|
6966
|
+
}
|
|
6967
|
+
/**
|
|
6968
|
+
* One archive of the tool's files, named by its sha256, uploaded to the registry's blob store before the pack is published, and unpacked at /tool before each call. The publish checks cap it at 64 MiB packed (bytes 67108864), 512 MiB unpacked (unpackedBytes 536870912) and 20,000 entries.
|
|
6969
|
+
*/
|
|
6970
|
+
export interface B3PackToolArchive {
|
|
6971
|
+
/** Lowercase hex sha256 of the archive's bytes. */
|
|
6972
|
+
sha256: string;
|
|
6973
|
+
/** The archive's size in bytes. */
|
|
6974
|
+
bytes: number;
|
|
6975
|
+
format: "tar.gz" | "tar";
|
|
6976
|
+
/** The sum of the sizes of the archive's regular files. */
|
|
6977
|
+
unpackedBytes: number;
|
|
6978
|
+
/** Files, directories and links in the archive. */
|
|
6979
|
+
entries: number;
|
|
6980
|
+
}
|
|
4843
6981
|
/**
|
|
4844
6982
|
* Publisher signature written by the publish tool and repeated in the registry record. contentHash covers the whole bundle with this member removed (README, 'Pack content hash and signature'). sig is Ed25519 over the UTF-8 bytes of 'b3pack-sig-v1\n<pack>\n<version>\n<contentHash>'. Nodes verify contentHash and sig against the registry record and the publisher's registered key before loading (ARCHITECTURE 5.5).
|
|
4845
6983
|
*/
|
|
@@ -4921,6 +7059,10 @@ export interface ActionSummary {
|
|
|
4921
7059
|
score?: number;
|
|
4922
7060
|
/** Set in search results when the search asked for `kind=any`. */
|
|
4923
7061
|
kind?: "action";
|
|
7062
|
+
/**
|
|
7063
|
+
* In a pack (`GET /v1/actions/packs/{namespace}/{name}`), for a hosted tool's action; absent in search results and for other actions.
|
|
7064
|
+
*/
|
|
7065
|
+
tool?: ActionTool;
|
|
4924
7066
|
}
|
|
4925
7067
|
/** A trigger in search results (`kind=trigger` or `kind=any`). */
|
|
4926
7068
|
export interface TriggerSearchHit {
|
|
@@ -5014,6 +7156,7 @@ export interface ActionDescription {
|
|
|
5014
7156
|
* when the node loads the pack. Their inputs also appear as `examples` in `mcp.inputSchema`.
|
|
5015
7157
|
*/
|
|
5016
7158
|
examples: ActionExample[];
|
|
7159
|
+
tool?: ActionTool;
|
|
5017
7160
|
}
|
|
5018
7161
|
export interface ActionCallRequest {
|
|
5019
7162
|
ref: ActionRef;
|
|
@@ -5034,12 +7177,104 @@ export interface ActionResult {
|
|
|
5034
7177
|
object: "action_result";
|
|
5035
7178
|
/** The exact version that ran. */
|
|
5036
7179
|
ref: string;
|
|
5037
|
-
/** Matches the action's output schema. */
|
|
7180
|
+
/** Matches the action's output schema. A hosted tool's output file is a `ToolFileOutput`, a link. */
|
|
5038
7181
|
output: unknown;
|
|
5039
7182
|
/** HTTP status of the upstream call, for declarative HTTP actions. */
|
|
5040
7183
|
upstream_status?: number;
|
|
7184
|
+
/**
|
|
7185
|
+
* `vm` for a hosted tool's call (its command ran in a microVM made for the call). Absent for other actions.
|
|
7186
|
+
*/
|
|
7187
|
+
tier?: "vm";
|
|
7188
|
+
cost?: ToolCallCost;
|
|
5041
7189
|
timing: Timing;
|
|
5042
7190
|
}
|
|
7191
|
+
/**
|
|
7192
|
+
* What a hosted tool's call costs, in micro-USD (millionths of a US dollar), from the node's unit prices when
|
|
7193
|
+
* the call ran: `compute` (`actions.vcpu_ms` and `actions.gib_ms`), `floor` (`actions.tool_call`), `price` (the
|
|
7194
|
+
* publisher's, `actions.publisher_microusd`; 0 when the tool failed or is free) and their sum, `total`. The
|
|
7195
|
+
* same numbers are in the `actions.tool_call` usage record's `meta.cost_micro_usd`.
|
|
7196
|
+
*/
|
|
7197
|
+
export interface ToolCallCost {
|
|
7198
|
+
compute: number;
|
|
7199
|
+
floor: number;
|
|
7200
|
+
price: number;
|
|
7201
|
+
total: number;
|
|
7202
|
+
}
|
|
7203
|
+
/** A file name, without directories. */
|
|
7204
|
+
export type ToolFileName = string;
|
|
7205
|
+
/**
|
|
7206
|
+
* A hosted tool's file in the node's file store: an upload, a fetched `$url` or an output file. It is kept
|
|
7207
|
+
* 1 hour from when it was written (`expires_at`), counts toward `actions.files_bytes` until then, and is
|
|
7208
|
+
* readable only from its project. `link` is a fresh signed download link that expires at the earlier of
|
|
7209
|
+
* `expires_at` and 1 hour from now.
|
|
7210
|
+
*/
|
|
7211
|
+
export interface ToolFile {
|
|
7212
|
+
object: "tool_file";
|
|
7213
|
+
id: string;
|
|
7214
|
+
name: ToolFileName;
|
|
7215
|
+
bytes: number;
|
|
7216
|
+
sha256: string;
|
|
7217
|
+
/** From the name's extension (`.pdf` is `application/pdf`), else `application/octet-stream`. */
|
|
7218
|
+
content_type: string;
|
|
7219
|
+
created_at: string;
|
|
7220
|
+
expires_at: string;
|
|
7221
|
+
/** The signed download link, as `ToolFileOutput.$link`. */
|
|
7222
|
+
link: string;
|
|
7223
|
+
}
|
|
7224
|
+
/**
|
|
7225
|
+
* A hosted tool action's publisher price, from its manifest (`pricing`, b3pack publish check 20). `micro_usd`
|
|
7226
|
+
* is the rate in micro-USD (millionths of a US dollar): per call, per second of the tool's own run, or per MiB
|
|
7227
|
+
* of input; 0 when free. `free_calls` is the calls each calling organization makes free of the price per UTC
|
|
7228
|
+
* month, for the pack.
|
|
7229
|
+
*/
|
|
7230
|
+
export interface ToolPrice {
|
|
7231
|
+
model: "free" | "per_call" | "per_second" | "per_input_mb";
|
|
7232
|
+
micro_usd: number;
|
|
7233
|
+
free_calls: number;
|
|
7234
|
+
}
|
|
7235
|
+
/**
|
|
7236
|
+
* What one call of this action costs all in, in micro-USD, from this version's own last calls on this node
|
|
7237
|
+
* (at most the last 100): the price at the median call (the median `run_ms` or input size for a rate), the
|
|
7238
|
+
* median compute, and the floor, at the node's unit prices now. `basis` says what it was taken from.
|
|
7239
|
+
*/
|
|
7240
|
+
export interface ToolAllIn {
|
|
7241
|
+
/** `compute` + `floor` + `price`. */
|
|
7242
|
+
micro_usd: number;
|
|
7243
|
+
compute: number;
|
|
7244
|
+
floor: number;
|
|
7245
|
+
price: number;
|
|
7246
|
+
basis: string;
|
|
7247
|
+
}
|
|
7248
|
+
/**
|
|
7249
|
+
* For a hosted tool's action (`impl.kind` `vm`), what it runs on, what it may take and return, and what it costs; absent for other actions.
|
|
7250
|
+
*/
|
|
7251
|
+
export interface ActionTool {
|
|
7252
|
+
kind: "cli";
|
|
7253
|
+
/** The template its VM is made from. */
|
|
7254
|
+
base: string;
|
|
7255
|
+
network: "none";
|
|
7256
|
+
price: ToolPrice;
|
|
7257
|
+
/** `execution.maxInputMb`: the most input file data one call may carry, in MiB. */
|
|
7258
|
+
max_input_mb: number;
|
|
7259
|
+
/** `execution.maxOutputMb`: the most output file data one call may return, in MiB. */
|
|
7260
|
+
max_output_mb: number;
|
|
7261
|
+
/** `execution.maxOutputFiles`: the most output files one call may return. */
|
|
7262
|
+
max_output_files: number;
|
|
7263
|
+
/** The tool's declared error codes (`tool.errors`); empty when it declares none. */
|
|
7264
|
+
errors: string[];
|
|
7265
|
+
/** The software the tool runs and did not write (the manifest's `tool.upstream`). */
|
|
7266
|
+
upstream: Record<string, unknown>[];
|
|
7267
|
+
/** The bundle path of the tool's notices file. */
|
|
7268
|
+
notices?: string;
|
|
7269
|
+
/**
|
|
7270
|
+
* The node's estimate of the time from claim to the tool's command starting, in milliseconds, for this
|
|
7271
|
+
* 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).
|
|
7273
|
+
*/
|
|
7274
|
+
start_estimate_ms: number;
|
|
7275
|
+
/** What one call costs all in, or `null` before this version's first call on this node. */
|
|
7276
|
+
all_in: ToolAllIn | null;
|
|
7277
|
+
}
|
|
5043
7278
|
export interface TriggerSummary {
|
|
5044
7279
|
ref: string;
|
|
5045
7280
|
pack: string;
|
|
@@ -5201,7 +7436,10 @@ export interface ConnectionCreateRequest {
|
|
|
5201
7436
|
* connection. Without `pack`, list the hosts your own HTTP steps call, or omit it (or give `[]`) for a
|
|
5202
7437
|
* verification-only connection: a connection with no hosts is never injected anywhere, because egress
|
|
5203
7438
|
* injection matches on hosts. It only holds a secret B3OS itself uses, such as a routine webhook's
|
|
5204
|
-
* `verify.secret`.
|
|
7439
|
+
* `verify.secret`. A `basic` connection may also list public IP addresses (IPv4, or IPv6 with or without
|
|
7440
|
+
* brackets, kept in canonical form), such as a proxy given by its address; a private, loopback,
|
|
7441
|
+
* link-local, CGNAT, multicast or metadata address is refused with `422 connection_invalid`, and no other
|
|
7442
|
+
* type lists an IP address.
|
|
5205
7443
|
*/
|
|
5206
7444
|
hosts?: string[];
|
|
5207
7445
|
/** Non-secret configuration the pack's connection declares (for example a Jira site name). */
|
|
@@ -5212,7 +7450,10 @@ export interface ConnectionCreateRequest {
|
|
|
5212
7450
|
export interface ConnectionUpdateRequest {
|
|
5213
7451
|
label?: string;
|
|
5214
7452
|
subject?: string | null;
|
|
5215
|
-
/**
|
|
7453
|
+
/**
|
|
7454
|
+
* Connections without a pack only. `[]` makes the connection verification-only (never injected). The same
|
|
7455
|
+
* rules as on create: a `basic` connection may list public IP addresses, no other type any.
|
|
7456
|
+
*/
|
|
5216
7457
|
hosts?: string[];
|
|
5217
7458
|
params?: Record<string, unknown>;
|
|
5218
7459
|
secret?: ConnectionSecret;
|
|
@@ -5446,6 +7687,14 @@ export interface InferMeta {
|
|
|
5446
7687
|
model_ms?: number;
|
|
5447
7688
|
total_ms?: number;
|
|
5448
7689
|
};
|
|
7690
|
+
/**
|
|
7691
|
+
* What `platform.capture_content` (prompt logging) applied to this call and where it came from (`request`, `project`, `org`, `node`); `clamped` when a stored value could not apply and `off` did instead. `model`: the call's prompt and answer are kept for 7 days (`GET /v1/llm-calls/{request_id}/content`). Also in the `X-B3OS-Options` response header.
|
|
7692
|
+
*/
|
|
7693
|
+
capture?: {
|
|
7694
|
+
value: "off" | "model";
|
|
7695
|
+
from: "request" | "project" | "org" | "node";
|
|
7696
|
+
clamped: boolean;
|
|
7697
|
+
};
|
|
5449
7698
|
}
|
|
5450
7699
|
export interface ChatCompletion {
|
|
5451
7700
|
id: string;
|
|
@@ -5505,7 +7754,10 @@ export interface ModelInfo {
|
|
|
5505
7754
|
* On `b3os/default` only: the chat model it names, whose limits apply. A request for the alias is served, limited and metered as that model, and its response names that model.
|
|
5506
7755
|
*/
|
|
5507
7756
|
alias_of?: string;
|
|
5508
|
-
kind: "chat" | "embedding" | "speech";
|
|
7757
|
+
kind: "chat" | "embedding" | "rerank" | "speech";
|
|
7758
|
+
/**
|
|
7759
|
+
* Tokens per request on chat models; on embedding models, tokens per input; on rerank models, tokens per query and document pair.
|
|
7760
|
+
*/
|
|
5509
7761
|
context_length: number | null;
|
|
5510
7762
|
/**
|
|
5511
7763
|
* The output cap of a chat request that sets no `max_tokens` (or `max_completion_tokens`, or Responses'
|
|
@@ -5519,6 +7771,12 @@ export interface ModelInfo {
|
|
|
5519
7771
|
json_schema: boolean;
|
|
5520
7772
|
image_input: boolean;
|
|
5521
7773
|
max_request_bytes: number;
|
|
7774
|
+
/** Embedding models only. Values per vector, and the most `dimensions` takes. */
|
|
7775
|
+
dimensions?: number;
|
|
7776
|
+
/**
|
|
7777
|
+
* Embedding models only. The fewest values `dimensions` takes; the same as `dimensions` when the model offers no shorter vectors.
|
|
7778
|
+
*/
|
|
7779
|
+
min_dimensions?: number;
|
|
5522
7780
|
limits: {
|
|
5523
7781
|
/**
|
|
5524
7782
|
* Tokens per minute for your organization (its own value from the node's budget snapshot, else the node's default).
|
|
@@ -5540,12 +7798,28 @@ export interface ModelList {
|
|
|
5540
7798
|
data: Model[];
|
|
5541
7799
|
}
|
|
5542
7800
|
export interface EmbeddingRequest {
|
|
7801
|
+
/** An embedding model's ID from `GET /v1/infer/models`. */
|
|
5543
7802
|
model: string;
|
|
5544
|
-
|
|
7803
|
+
/** The text to embed. Arrays of token IDs are `400 unsupported_parameter`. */
|
|
7804
|
+
input: string | string[];
|
|
5545
7805
|
/** @default "float" */
|
|
5546
7806
|
encoding_format?: "float" | "base64";
|
|
7807
|
+
/** Values per vector, from the model's `b3os.min_dimensions` to its `b3os.dimensions`. */
|
|
5547
7808
|
dimensions?: number;
|
|
7809
|
+
/** Accepted and ignored. */
|
|
5548
7810
|
user?: string;
|
|
7811
|
+
/**
|
|
7812
|
+
* B3OS extension. `query` puts the model's query prompt before each input.
|
|
7813
|
+
* @default "document"
|
|
7814
|
+
*/
|
|
7815
|
+
input_type?: "document" | "query";
|
|
7816
|
+
/** B3OS extension. The task the query prompt describes; only with `input_type` `query`. */
|
|
7817
|
+
instruction?: string;
|
|
7818
|
+
/**
|
|
7819
|
+
* B3OS extension. `end` cuts an input longer than the model's `context_length` at the end; `none` refuses it.
|
|
7820
|
+
* @default "none"
|
|
7821
|
+
*/
|
|
7822
|
+
truncate?: "none" | "end";
|
|
5549
7823
|
}
|
|
5550
7824
|
export interface EmbeddingList {
|
|
5551
7825
|
object: "list";
|
|
@@ -5559,6 +7833,72 @@ export interface EmbeddingList {
|
|
|
5559
7833
|
prompt_tokens: number;
|
|
5560
7834
|
total_tokens: number;
|
|
5561
7835
|
};
|
|
7836
|
+
b3os?: EmbeddingMeta;
|
|
7837
|
+
}
|
|
7838
|
+
/** B3OS extension; OpenAI SDKs ignore it. */
|
|
7839
|
+
export interface EmbeddingMeta {
|
|
7840
|
+
route: "local";
|
|
7841
|
+
node: string;
|
|
7842
|
+
/** Values per vector. */
|
|
7843
|
+
dimensions: number;
|
|
7844
|
+
/** Every vector has length 1. */
|
|
7845
|
+
normalized: true;
|
|
7846
|
+
/** Server-side milliseconds from the request head. */
|
|
7847
|
+
timing: {
|
|
7848
|
+
model_ms?: number;
|
|
7849
|
+
total_ms?: number;
|
|
7850
|
+
};
|
|
7851
|
+
}
|
|
7852
|
+
export interface RerankRequest {
|
|
7853
|
+
/** A rerank model's ID from `GET /v1/infer/models`. */
|
|
7854
|
+
model: string;
|
|
7855
|
+
/** At most 2,048 tokens. */
|
|
7856
|
+
query: string;
|
|
7857
|
+
documents: Array<string | {
|
|
7858
|
+
text: string;
|
|
7859
|
+
}>;
|
|
7860
|
+
/** How many results to return; default every document. */
|
|
7861
|
+
top_n?: number;
|
|
7862
|
+
/**
|
|
7863
|
+
* Each document is cut at the end to this many tokens.
|
|
7864
|
+
* @default 4096
|
|
7865
|
+
*/
|
|
7866
|
+
max_tokens_per_doc?: number;
|
|
7867
|
+
/**
|
|
7868
|
+
* B3OS extension. Each result also carries its document.
|
|
7869
|
+
* @default false
|
|
7870
|
+
*/
|
|
7871
|
+
return_documents?: boolean;
|
|
7872
|
+
/** B3OS extension. The task the model's query prompt describes. */
|
|
7873
|
+
instruction?: string;
|
|
7874
|
+
}
|
|
7875
|
+
export interface RerankList {
|
|
7876
|
+
/** The request ID. */
|
|
7877
|
+
id: string;
|
|
7878
|
+
model: string;
|
|
7879
|
+
/** Highest `relevance_score` first. */
|
|
7880
|
+
results: {
|
|
7881
|
+
/** The document's position in `documents`. */
|
|
7882
|
+
index: number;
|
|
7883
|
+
relevance_score: number;
|
|
7884
|
+
/** With `return_documents: true`: the document as sent. */
|
|
7885
|
+
document?: {
|
|
7886
|
+
text: string;
|
|
7887
|
+
};
|
|
7888
|
+
}[];
|
|
7889
|
+
usage: {
|
|
7890
|
+
total_tokens: number;
|
|
7891
|
+
};
|
|
7892
|
+
/** Cohere's metadata. */
|
|
7893
|
+
meta: {
|
|
7894
|
+
api_version: {
|
|
7895
|
+
version: "2";
|
|
7896
|
+
};
|
|
7897
|
+
billed_units: {
|
|
7898
|
+
input_tokens: number;
|
|
7899
|
+
};
|
|
7900
|
+
};
|
|
7901
|
+
b3os?: InferMeta;
|
|
5562
7902
|
}
|
|
5563
7903
|
/** OpenAI speech parameters; `null` means unset on the optional ones. */
|
|
5564
7904
|
export interface SpeechRequest {
|
|
@@ -6179,12 +8519,144 @@ export interface RegistryPackVersion {
|
|
|
6179
8519
|
alg: "ed25519";
|
|
6180
8520
|
kid: string;
|
|
6181
8521
|
sig: string;
|
|
8522
|
+
/**
|
|
8523
|
+
* An org-private version only: the organization's public key for `kid` (`org.<org>#g<generation>`),
|
|
8524
|
+
* base64url without padding of its 32 bytes. A node verifies `sig` with it only for a pack in that same
|
|
8525
|
+
* `org.` namespace, for that organization; a listed pack never verifies with a record's key.
|
|
8526
|
+
*/
|
|
8527
|
+
public_key?: string;
|
|
6182
8528
|
};
|
|
6183
8529
|
publisher: RegistryPublisher;
|
|
6184
8530
|
size_bytes: number;
|
|
6185
8531
|
published_at: string;
|
|
8532
|
+
/** A yanked version resolves only when pinned exactly (`@1.2.0`); a range or major (`@1`) skips it. */
|
|
6186
8533
|
yanked: boolean;
|
|
8534
|
+
/**
|
|
8535
|
+
* A dev version (`<x.y.z>-dev.<unix seconds>`, org-private tools only), replaced by the pack's next dev version and outside the version limits. Nodes deployed before slice B do not send it.
|
|
8536
|
+
*/
|
|
8537
|
+
dev?: boolean;
|
|
6187
8538
|
download_url: string;
|
|
8539
|
+
/**
|
|
8540
|
+
* The API key (`key_...`) or dashboard user (`usr_...`) that published the version, shown to the namespace's owner and to B3's organizations; `null` for any other reader, a node, and versions published before it was recorded.
|
|
8541
|
+
*/
|
|
8542
|
+
published_by?: string | null;
|
|
8543
|
+
}
|
|
8544
|
+
/** A hosted tool's archive in the registry's blob store, named by its sha256. */
|
|
8545
|
+
export interface RegistryBlob {
|
|
8546
|
+
object: "registry_blob";
|
|
8547
|
+
digest: string;
|
|
8548
|
+
bytes: number;
|
|
8549
|
+
created_at: string;
|
|
8550
|
+
}
|
|
8551
|
+
export interface RegistryYankRequest {
|
|
8552
|
+
/** `true` yanks the version, `false` restores it. */
|
|
8553
|
+
yanked: boolean;
|
|
8554
|
+
}
|
|
8555
|
+
/**
|
|
8556
|
+
* What to block. `publisher` is a namespace; `pack` (`<namespace>/<name>`, in `publisher`) is required for the
|
|
8557
|
+
* scopes `pack`, `version` and `action`; `version` (exact) for `version`, and optionally for `action` (absent:
|
|
8558
|
+
* the action in every version); `action` (an action key) for `action`.
|
|
8559
|
+
*/
|
|
8560
|
+
export interface ToolBlockCreateRequest {
|
|
8561
|
+
scope: "publisher" | "pack" | "version" | "action";
|
|
8562
|
+
publisher: string;
|
|
8563
|
+
pack?: string;
|
|
8564
|
+
version?: string;
|
|
8565
|
+
action?: string;
|
|
8566
|
+
/** Why, for B3's own records. Never sent to nodes or shown to the publisher. */
|
|
8567
|
+
reason: string;
|
|
8568
|
+
/**
|
|
8569
|
+
* Who asked, for B3's own records (a ticket, a notice). Never sent to nodes or shown to the publisher.
|
|
8570
|
+
*/
|
|
8571
|
+
requested_by: string;
|
|
8572
|
+
/** The sha256 of the evidence B3 keeps elsewhere. */
|
|
8573
|
+
evidence_sha256?: string;
|
|
8574
|
+
}
|
|
8575
|
+
export interface ToolBlockLift {
|
|
8576
|
+
lifted_at: string;
|
|
8577
|
+
/** An `io.b3os` key id (`io.b3os#<label>`). */
|
|
8578
|
+
kid: string;
|
|
8579
|
+
sig: string;
|
|
8580
|
+
}
|
|
8581
|
+
/**
|
|
8582
|
+
* A block that removes a hosted tool, its version, one action, or every tool of a publisher. `lift` is `null` while it is in force.
|
|
8583
|
+
*/
|
|
8584
|
+
export interface ToolBlock {
|
|
8585
|
+
object: "tool_block";
|
|
8586
|
+
id: string;
|
|
8587
|
+
scope: "publisher" | "pack" | "version" | "action";
|
|
8588
|
+
publisher: string;
|
|
8589
|
+
pack: string | null;
|
|
8590
|
+
version: string | null;
|
|
8591
|
+
action: string | null;
|
|
8592
|
+
reason: string;
|
|
8593
|
+
requested_by: string;
|
|
8594
|
+
evidence_sha256: string | null;
|
|
8595
|
+
created_at: string;
|
|
8596
|
+
/** The API key (`key_...`) or dashboard user (`usr_...`) that placed the block. */
|
|
8597
|
+
created_by: string;
|
|
8598
|
+
lift: ToolBlockLift | null;
|
|
8599
|
+
}
|
|
8600
|
+
export type ToolBlockList = Omit<ListEnvelope, "data"> & {
|
|
8601
|
+
data: ToolBlock[];
|
|
8602
|
+
};
|
|
8603
|
+
/** An option's value; for an enum option, one of its values (`x-b3os-options`). */
|
|
8604
|
+
export type SettingValue = string | number | boolean;
|
|
8605
|
+
export interface SettingRequest {
|
|
8606
|
+
value: SettingValue;
|
|
8607
|
+
}
|
|
8608
|
+
/** One option set for one project or organization. */
|
|
8609
|
+
export interface StoredSetting {
|
|
8610
|
+
/** The option id. */
|
|
8611
|
+
id: string;
|
|
8612
|
+
object: "setting";
|
|
8613
|
+
value: SettingValue;
|
|
8614
|
+
scope: "project" | "org";
|
|
8615
|
+
/** The project (`prj_`) or organization (`org_`) it is set for. */
|
|
8616
|
+
scope_id: string;
|
|
8617
|
+
updated_at: string;
|
|
8618
|
+
/** The user (`usr_`) or key (`key_`) that last set it. */
|
|
8619
|
+
updated_by: string;
|
|
8620
|
+
}
|
|
8621
|
+
export type StoredSettingList = Omit<ListEnvelope, "data"> & {
|
|
8622
|
+
data: StoredSetting[];
|
|
8623
|
+
};
|
|
8624
|
+
/**
|
|
8625
|
+
* `isolated`: the app's server gets only the cookies its own address set, plus the names in `script`.
|
|
8626
|
+
* `shared`: the browser's cookies pass, except Cloudflare's and B3OS's own names and values that are not plain
|
|
8627
|
+
* (a space, comma, quote or backslash).
|
|
8628
|
+
*/
|
|
8629
|
+
export type AppHostCookieMode = "isolated" | "shared";
|
|
8630
|
+
export interface AppHostCookies {
|
|
8631
|
+
mode: AppHostCookieMode;
|
|
8632
|
+
/** Cookies a page script writes and the app's server reads, by name. */
|
|
8633
|
+
script: string[];
|
|
8634
|
+
}
|
|
8635
|
+
export interface PortHostRequest {
|
|
8636
|
+
/**
|
|
8637
|
+
* How long the link works, in seconds.
|
|
8638
|
+
* @default 600
|
|
8639
|
+
*/
|
|
8640
|
+
ttl_s?: number;
|
|
8641
|
+
/**
|
|
8642
|
+
* Replace the host's secret first: every earlier link and cookie of this host stops working within 6 seconds (streams already open can run up to an hour).
|
|
8643
|
+
* @default false
|
|
8644
|
+
*/
|
|
8645
|
+
rotate?: boolean;
|
|
8646
|
+
cookies?: AppHostCookies;
|
|
8647
|
+
}
|
|
8648
|
+
export interface PortHost {
|
|
8649
|
+
object: "port_host";
|
|
8650
|
+
sandbox_id: string;
|
|
8651
|
+
port: number;
|
|
8652
|
+
/** `<port>-sbx-<id>.b3os.io`: the host, safe to show. */
|
|
8653
|
+
host: string;
|
|
8654
|
+
/** `https://<host>/?b3os_link=<token>`. Share it as a secret. */
|
|
8655
|
+
url: string;
|
|
8656
|
+
/** When the link stops working (a browser that opened it stays in for 24 hours from its visit). */
|
|
8657
|
+
expires_at: string;
|
|
8658
|
+
rotated: boolean;
|
|
8659
|
+
cookies: AppHostCookies;
|
|
6188
8660
|
}
|
|
6189
8661
|
/**
|
|
6190
8662
|
* How the request reached B3OS: `edge` (through beta-api.b3os.org or the dashboard; forwarded to the node, or
|
|
@@ -6196,10 +8668,12 @@ export type RequestConnection = "edge" | "uds" | "tcp" | "sandbox";
|
|
|
6196
8668
|
* Who made the request: `api_key` (an API key), `cli_token` (the CLI's device-login token), `dashboard` (a
|
|
6197
8669
|
* signed-in dashboard session; its successful reads are not logged, its changes and errors are), `sandbox` (code
|
|
6198
8670
|
* inside a sandbox, as its creating key), `routine` (a routine run, as the key that published its version),
|
|
6199
|
-
* `local` (a host-local caller on the node's Unix socket)
|
|
6200
|
-
* callback to a public route, or a request refused before authentication)
|
|
8671
|
+
* `local` (a host-local caller on the node's Unix socket), `public` (no credential: a webhook or signed
|
|
8672
|
+
* callback to a public route, or a request refused before authentication), `address` (a visitor of an app
|
|
8673
|
+
* address, `<label>.b3os.io`) or `preview` (a visitor of a sandbox port preview). `address` and `preview`
|
|
8674
|
+
* records belong to the sandbox's project; their `path` is the app's path, without the query, cut at 1,024 bytes.
|
|
6201
8675
|
*/
|
|
6202
|
-
export type RequestSource = "api_key" | "cli_token" | "dashboard" | "sandbox" | "routine" | "local" | "public";
|
|
8676
|
+
export type RequestSource = "api_key" | "cli_token" | "dashboard" | "sandbox" | "routine" | "local" | "public" | "address" | "preview";
|
|
6203
8677
|
export interface RequestPhase {
|
|
6204
8678
|
name: string;
|
|
6205
8679
|
source: "edge" | "node";
|
|
@@ -6244,7 +8718,28 @@ export interface RequestRecord {
|
|
|
6244
8718
|
trace_id: string | null;
|
|
6245
8719
|
user_agent: string | null;
|
|
6246
8720
|
source: RequestSource;
|
|
8721
|
+
action?: RequestAction;
|
|
6247
8722
|
}
|
|
8723
|
+
/**
|
|
8724
|
+
* The pack action the request ran: a `POST /v1/actions/call`, or one `tools/call` of a sandbox's MCP server
|
|
8725
|
+
* (`POST /v1/actions/mcp`, with `tool` set). `null` for any other request, and absent from records written
|
|
8726
|
+
* before node release 1118. A tool call answers HTTP 200 whether or not the action succeeded, so its own outcome
|
|
8727
|
+
* is here: `status_code` 200, or the status of the problem that refused or failed it. For a product tool (node
|
|
8728
|
+
* release 1119: `browser_*`, `vision_*`, `render_*`), `pack` is the toolset (`browser`, `vision` or `render`)
|
|
8729
|
+
* and `ref` is `<product>/<operationId>` of the product request the tool made (`vision/visionAct`), which has a
|
|
8730
|
+
* record of its own on the sandbox's connection, with the same `trace_id` when the call sent a `traceparent`.
|
|
8731
|
+
*/
|
|
8732
|
+
export type RequestAction = {
|
|
8733
|
+
/**
|
|
8734
|
+
* `<namespace>/<name>/<action>@<version>`: the exact version that ran, or the ref as asked when the call was refused before it resolved one; `<product>/<operationId>` for a product tool.
|
|
8735
|
+
*/
|
|
8736
|
+
ref: string;
|
|
8737
|
+
pack: string;
|
|
8738
|
+
/** The MCP tool name, for a `tools/call`; `null` for `POST /v1/actions/call`. */
|
|
8739
|
+
tool: string | null;
|
|
8740
|
+
status_code: number;
|
|
8741
|
+
error_code: string | null;
|
|
8742
|
+
} | null;
|
|
6248
8743
|
export type RequestRecordList = Omit<ListEnvelope, "data"> & {
|
|
6249
8744
|
data: RequestRecord[];
|
|
6250
8745
|
};
|
|
@@ -6586,6 +9081,16 @@ export interface VisionListSessionsParams {
|
|
|
6586
9081
|
/** Only sessions with this status. */
|
|
6587
9082
|
status?: SessionStatus;
|
|
6588
9083
|
}
|
|
9084
|
+
/** Parameters of `listAliases`. */
|
|
9085
|
+
export interface RenderListAliasesParams {
|
|
9086
|
+
/**
|
|
9087
|
+
* Page size, from 1 to 100.
|
|
9088
|
+
* @default 20
|
|
9089
|
+
*/
|
|
9090
|
+
limit?: number;
|
|
9091
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
9092
|
+
cursor?: string;
|
|
9093
|
+
}
|
|
6589
9094
|
/** Parameters of `listBackgrounds`. */
|
|
6590
9095
|
export interface RenderListBackgroundsParams {
|
|
6591
9096
|
/** Only this pack's backgrounds (`GET /v1/render/backgrounds/packs` lists the packs). */
|
|
@@ -6660,6 +9165,15 @@ export interface SandboxesListSandboxesParams {
|
|
|
6660
9165
|
cursor?: string;
|
|
6661
9166
|
/** Only sandboxes with this status. */
|
|
6662
9167
|
status?: SandboxStatus;
|
|
9168
|
+
/** Only sandboxes with this `owner` (`project`, the services of applications, or `key`). */
|
|
9169
|
+
owner?: SandboxOwner;
|
|
9170
|
+
/** Only the sandboxes this project's service started, directly or not (`root`). */
|
|
9171
|
+
root?: string;
|
|
9172
|
+
/**
|
|
9173
|
+
* Only sandboxes this key created (`created_by_key`). With `owner=project`: the services a key deployed,
|
|
9174
|
+
* which keep running after it is revoked.
|
|
9175
|
+
*/
|
|
9176
|
+
created_by_key?: string;
|
|
6663
9177
|
/**
|
|
6664
9178
|
* Only sandboxes whose `metadata` holds each of these pairs, as `metadata[<key>]=<value>`: up to 4, all of
|
|
6665
9179
|
* which must match exactly. Keys follow the `metadata` key rule (1 to 40 of `A-Z a-z 0-9 _ . : -`).
|
|
@@ -6676,6 +9190,54 @@ export interface SandboxesListSnapshotsParams {
|
|
|
6676
9190
|
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
6677
9191
|
cursor?: string;
|
|
6678
9192
|
}
|
|
9193
|
+
/** Parameters of `listSwarms`. */
|
|
9194
|
+
export interface SandboxesListSwarmsParams {
|
|
9195
|
+
/**
|
|
9196
|
+
* Page size, from 1 to 100.
|
|
9197
|
+
* @default 20
|
|
9198
|
+
*/
|
|
9199
|
+
limit?: number;
|
|
9200
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
9201
|
+
cursor?: string;
|
|
9202
|
+
/** Only swarms with this status. */
|
|
9203
|
+
status?: JobStatus;
|
|
9204
|
+
}
|
|
9205
|
+
/** Parameters of `getSwarm`. */
|
|
9206
|
+
export interface SandboxesGetSwarmParams {
|
|
9207
|
+
/**
|
|
9208
|
+
* Seconds to wait for the job to finish before responding, from 0 to 60. If it finishes in time the response
|
|
9209
|
+
* is `200` with the finished job; otherwise `202` with the job as it is, a `Location` to poll and
|
|
9210
|
+
* `Retry-After`. `0` (the default) returns immediately.
|
|
9211
|
+
* @default 0
|
|
9212
|
+
*/
|
|
9213
|
+
wait?: number;
|
|
9214
|
+
}
|
|
9215
|
+
/** Parameters of `listSwarmChildren`. */
|
|
9216
|
+
export interface SandboxesListSwarmChildrenParams {
|
|
9217
|
+
/**
|
|
9218
|
+
* Page size, from 1 to 100.
|
|
9219
|
+
* @default 20
|
|
9220
|
+
*/
|
|
9221
|
+
limit?: number;
|
|
9222
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
9223
|
+
cursor?: string;
|
|
9224
|
+
/** Only children with this status. */
|
|
9225
|
+
status?: "queued" | "running" | "exited" | "timed_out" | "failed" | "canceled";
|
|
9226
|
+
}
|
|
9227
|
+
/** Parameters of `listVolumes`. */
|
|
9228
|
+
export interface SandboxesListVolumesParams {
|
|
9229
|
+
/**
|
|
9230
|
+
* Page size, from 1 to 100.
|
|
9231
|
+
* @default 20
|
|
9232
|
+
*/
|
|
9233
|
+
limit?: number;
|
|
9234
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
9235
|
+
cursor?: string;
|
|
9236
|
+
/** Only the volume with this name. */
|
|
9237
|
+
name?: string;
|
|
9238
|
+
/** Only volumes in this status. */
|
|
9239
|
+
status?: "available" | "attached" | "deleted";
|
|
9240
|
+
}
|
|
6679
9241
|
/** Parameters of `deleteFile`. */
|
|
6680
9242
|
export interface SandboxesDeleteFileParams {
|
|
6681
9243
|
/** Absolute path inside the sandbox. */
|
|
@@ -6757,6 +9319,66 @@ export interface SandboxesListRequestsParams {
|
|
|
6757
9319
|
/** Only requests of this W3C trace (the trace id of their `traceparent`). */
|
|
6758
9320
|
trace_id?: string;
|
|
6759
9321
|
since?: string;
|
|
9322
|
+
/**
|
|
9323
|
+
* Only requests that ran an action of this pack (their `action.pack`), or a tool of this product toolset of a sandbox's MCP server (`browser`, `vision` or `render`, node release 1119).
|
|
9324
|
+
*/
|
|
9325
|
+
pack?: string;
|
|
9326
|
+
}
|
|
9327
|
+
/** Parameters of `getImage`. */
|
|
9328
|
+
export interface ImagesGetImageParams {
|
|
9329
|
+
/**
|
|
9330
|
+
* Hold the answer up to this many seconds until the image is `ready`, `failed` or `evicted`.
|
|
9331
|
+
* @default 0
|
|
9332
|
+
*/
|
|
9333
|
+
wait?: number;
|
|
9334
|
+
}
|
|
9335
|
+
/** Parameters of `listAgents`. */
|
|
9336
|
+
export interface AgentsListAgentsParams {
|
|
9337
|
+
/**
|
|
9338
|
+
* Page size, from 1 to 100.
|
|
9339
|
+
* @default 20
|
|
9340
|
+
*/
|
|
9341
|
+
limit?: number;
|
|
9342
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
9343
|
+
cursor?: string;
|
|
9344
|
+
}
|
|
9345
|
+
/** Parameters of `listInstances`. */
|
|
9346
|
+
export interface AgentsListInstancesParams {
|
|
9347
|
+
/**
|
|
9348
|
+
* Page size, from 1 to 100.
|
|
9349
|
+
* @default 20
|
|
9350
|
+
*/
|
|
9351
|
+
limit?: number;
|
|
9352
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
9353
|
+
cursor?: string;
|
|
9354
|
+
/** Only instances with this status. */
|
|
9355
|
+
status?: AgentInstanceStatus;
|
|
9356
|
+
}
|
|
9357
|
+
/** Parameters of `listInstanceEvents`. */
|
|
9358
|
+
export interface AgentsListInstanceEventsParams {
|
|
9359
|
+
/**
|
|
9360
|
+
* Page size, from 1 to 100.
|
|
9361
|
+
* @default 20
|
|
9362
|
+
*/
|
|
9363
|
+
limit?: number;
|
|
9364
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
9365
|
+
cursor?: string;
|
|
9366
|
+
}
|
|
9367
|
+
/** Parameters of `listSessions`. */
|
|
9368
|
+
export interface AgentsListSessionsParams {
|
|
9369
|
+
/**
|
|
9370
|
+
* Page size, from 1 to 100.
|
|
9371
|
+
* @default 20
|
|
9372
|
+
*/
|
|
9373
|
+
limit?: number;
|
|
9374
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
9375
|
+
cursor?: string;
|
|
9376
|
+
/** Only sessions of this instance. */
|
|
9377
|
+
key?: AgentInstanceKey;
|
|
9378
|
+
/** Only sessions of this conversation. */
|
|
9379
|
+
conversation?: string;
|
|
9380
|
+
/** Only sessions with this status. */
|
|
9381
|
+
status?: JobStatus;
|
|
6760
9382
|
}
|
|
6761
9383
|
/** Parameters of `listRoutines`. */
|
|
6762
9384
|
export interface RoutinesListRoutinesParams {
|
|
@@ -6815,11 +9437,40 @@ export interface RoutinesListVersionsParams {
|
|
|
6815
9437
|
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
6816
9438
|
cursor?: string;
|
|
6817
9439
|
}
|
|
9440
|
+
/** Parameters of `listListeners`. */
|
|
9441
|
+
export interface ListenersListListenersParams {
|
|
9442
|
+
/**
|
|
9443
|
+
* Page size, from 1 to 100.
|
|
9444
|
+
* @default 20
|
|
9445
|
+
*/
|
|
9446
|
+
limit?: number;
|
|
9447
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
9448
|
+
cursor?: string;
|
|
9449
|
+
/** Only listeners in this status. */
|
|
9450
|
+
status?: ListenerStatus;
|
|
9451
|
+
}
|
|
9452
|
+
/** Parameters of `listEvents`. */
|
|
9453
|
+
export interface ListenersListEventsParams {
|
|
9454
|
+
/**
|
|
9455
|
+
* Page size, from 1 to 100.
|
|
9456
|
+
* @default 20
|
|
9457
|
+
*/
|
|
9458
|
+
limit?: number;
|
|
9459
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
9460
|
+
cursor?: string;
|
|
9461
|
+
/** Only events in this status. */
|
|
9462
|
+
status?: ListenerEventStatus;
|
|
9463
|
+
}
|
|
6818
9464
|
/** Parameters of `describe`. */
|
|
6819
9465
|
export interface ActionsDescribeParams {
|
|
6820
9466
|
/** `<namespace>/<name>/<action>@<version>`; the version may be exact (`1.0.0`) or a major (`1`). */
|
|
6821
9467
|
ref: ActionRef;
|
|
6822
9468
|
}
|
|
9469
|
+
/** Parameters of `uploadFile`. */
|
|
9470
|
+
export interface ActionsUploadFileParams {
|
|
9471
|
+
/** The file's name, which the tool sees at `/in/<field>/<name>`. */
|
|
9472
|
+
name: ToolFileName;
|
|
9473
|
+
}
|
|
6823
9474
|
/** Parameters of `listPacks`. */
|
|
6824
9475
|
export interface ActionsListPacksParams {
|
|
6825
9476
|
/** Words to search for in pack titles and descriptions. */
|
|
@@ -6848,6 +9499,16 @@ export interface ActionsGetPackToolsParams {
|
|
|
6848
9499
|
/** The `ETag` of a response you hold. */
|
|
6849
9500
|
if_none_match?: string;
|
|
6850
9501
|
}
|
|
9502
|
+
/** Parameters of `listToolBlocks`. */
|
|
9503
|
+
export interface PlatformListToolBlocksParams {
|
|
9504
|
+
/**
|
|
9505
|
+
* Page size, from 1 to 100.
|
|
9506
|
+
* @default 20
|
|
9507
|
+
*/
|
|
9508
|
+
limit?: number;
|
|
9509
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
9510
|
+
cursor?: string;
|
|
9511
|
+
}
|
|
6851
9512
|
/** Parameters of `listRegistryPacks`. */
|
|
6852
9513
|
export interface PlatformListRegistryPacksParams {
|
|
6853
9514
|
/**
|
|
@@ -6927,6 +9588,39 @@ export interface InferListVoicesParams {
|
|
|
6927
9588
|
/** Only voices of this model. */
|
|
6928
9589
|
model?: string;
|
|
6929
9590
|
}
|
|
9591
|
+
/** Parameters of `createChatCompletion` (header parameters are sent as their `X-B3OS-*` headers). */
|
|
9592
|
+
export interface InferCreateChatCompletionParams {
|
|
9593
|
+
/**
|
|
9594
|
+
* `off` keeps nothing of this call in the model call log, whatever the project's `platform.capture_content` setting. The only value: a request can turn prompt logging off, never on. Any other value is `400 invalid_request`.
|
|
9595
|
+
*/
|
|
9596
|
+
capture_content?: "off";
|
|
9597
|
+
/**
|
|
9598
|
+
* The request id of a kept model call this call replays (the console's Replay). When this call is kept, its record names that call in `replay_of` if it is in the same project. Not capture mode's `x-b3os-replay`.
|
|
9599
|
+
*/
|
|
9600
|
+
replay_of?: string;
|
|
9601
|
+
}
|
|
9602
|
+
/** Parameters of `createResponse` (header parameters are sent as their `X-B3OS-*` headers). */
|
|
9603
|
+
export interface InferCreateResponseParams {
|
|
9604
|
+
/**
|
|
9605
|
+
* `off` keeps nothing of this call in the model call log, whatever the project's `platform.capture_content` setting. The only value: a request can turn prompt logging off, never on. Any other value is `400 invalid_request`.
|
|
9606
|
+
*/
|
|
9607
|
+
capture_content?: "off";
|
|
9608
|
+
/**
|
|
9609
|
+
* The request id of a kept model call this call replays (the console's Replay). When this call is kept, its record names that call in `replay_of` if it is in the same project. Not capture mode's `x-b3os-replay`.
|
|
9610
|
+
*/
|
|
9611
|
+
replay_of?: string;
|
|
9612
|
+
}
|
|
9613
|
+
/** Parameters of `createMessage` (header parameters are sent as their `X-B3OS-*` headers). */
|
|
9614
|
+
export interface InferCreateMessageParams {
|
|
9615
|
+
/**
|
|
9616
|
+
* `off` keeps nothing of this call in the model call log, whatever the project's `platform.capture_content` setting. The only value: a request can turn prompt logging off, never on. Any other value is `400 invalid_request`.
|
|
9617
|
+
*/
|
|
9618
|
+
capture_content?: "off";
|
|
9619
|
+
/**
|
|
9620
|
+
* The request id of a kept model call this call replays (the console's Replay). When this call is kept, its record names that call in `replay_of` if it is in the same project. Not capture mode's `x-b3os-replay`.
|
|
9621
|
+
*/
|
|
9622
|
+
replay_of?: string;
|
|
9623
|
+
}
|
|
6930
9624
|
/** Parameters of `listKeys`. */
|
|
6931
9625
|
export interface PlatformListKeysParams {
|
|
6932
9626
|
/**
|
|
@@ -6968,6 +9662,10 @@ export interface PlatformListUsageRecordsParams {
|
|
|
6968
9662
|
product?: string;
|
|
6969
9663
|
unit?: string;
|
|
6970
9664
|
key_id?: string;
|
|
9665
|
+
/**
|
|
9666
|
+
* The usage a sandbox's own API calls caused (an application's pack calls, say). Only the calling project's sandboxes; another project's sandbox lists no records.
|
|
9667
|
+
*/
|
|
9668
|
+
sandbox_id?: string;
|
|
6971
9669
|
request_id?: string;
|
|
6972
9670
|
}
|
|
6973
9671
|
/** Parameters of `listRequests`. */
|
|
@@ -6997,6 +9695,10 @@ export interface PlatformListRequestsParams {
|
|
|
6997
9695
|
*/
|
|
6998
9696
|
trace_id?: string;
|
|
6999
9697
|
since?: string;
|
|
9698
|
+
/**
|
|
9699
|
+
* Only requests that ran an action of this pack (their `action.pack`), or a tool of this product toolset of a sandbox's MCP server (`browser`, `vision` or `render`, node release 1119).
|
|
9700
|
+
*/
|
|
9701
|
+
pack?: string;
|
|
7000
9702
|
}
|
|
7001
9703
|
/** Parameters of `listDeliveries`. */
|
|
7002
9704
|
export interface WebhooksListDeliveriesParams {
|