@b3os/sdk 0.2.1 → 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/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 +75 -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 +267 -33
- package/dist/cjs/generated/ns/actions.js +375 -33
- 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 +2564 -68
- package/dist/cjs/helpers/sandboxes.d.ts +20 -1
- package/dist/cjs/helpers/sandboxes.js +13 -1
- package/dist/cjs/helpers/sandboxes.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 +75 -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 +267 -33
- package/dist/esm/generated/ns/actions.js +375 -33
- 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 +2564 -68
- package/dist/esm/helpers/sandboxes.d.ts +20 -1
- package/dist/esm/helpers/sandboxes.js +13 -1
- package/dist/esm/helpers/sandboxes.js.map +1 -1
- package/package.json +1 -1
- package/src/core/util.ts +1 -1
- package/src/generated/client.ts +28 -0
- package/src/generated/errors.ts +150 -0
- package/src/generated/ids.ts +15 -0
- package/src/generated/jobs.ts +4 -0
- package/src/generated/ns/actions.ts +403 -33
- 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 +2907 -192
- package/src/helpers/sandboxes.ts +31 -2
package/src/generated/types.ts
CHANGED
|
@@ -26,9 +26,14 @@ export type Scope =
|
|
|
26
26
|
| "sandboxes:read"
|
|
27
27
|
| "sandboxes:write"
|
|
28
28
|
| "sandboxes:run"
|
|
29
|
+
| "agents:read"
|
|
30
|
+
| "agents:write"
|
|
31
|
+
| "agents:run"
|
|
29
32
|
| "routines:read"
|
|
30
33
|
| "routines:write"
|
|
31
34
|
| "routines:run"
|
|
35
|
+
| "listeners:read"
|
|
36
|
+
| "listeners:write"
|
|
32
37
|
| "actions:read"
|
|
33
38
|
| "actions:write"
|
|
34
39
|
| "actions:run"
|
|
@@ -39,16 +44,22 @@ export type Scope =
|
|
|
39
44
|
| "vault:read"
|
|
40
45
|
| "vault:write"
|
|
41
46
|
| "vault:run"
|
|
47
|
+
| "vault:connections:reveal"
|
|
42
48
|
| "platform:read"
|
|
43
49
|
| "platform:write"
|
|
50
|
+
| "platform:content:read"
|
|
51
|
+
| "settings:write"
|
|
44
52
|
| "vision:*"
|
|
45
53
|
| "render:*"
|
|
46
54
|
| "sandboxes:*"
|
|
55
|
+
| "agents:*"
|
|
47
56
|
| "routines:*"
|
|
57
|
+
| "listeners:*"
|
|
48
58
|
| "actions:*"
|
|
49
59
|
| "infer:*"
|
|
50
60
|
| "vault:*"
|
|
51
61
|
| "platform:*"
|
|
62
|
+
| "settings:*"
|
|
52
63
|
| "*";
|
|
53
64
|
|
|
54
65
|
/**
|
|
@@ -128,6 +139,12 @@ export interface Problem {
|
|
|
128
139
|
limit?: LimitRef;
|
|
129
140
|
/** The object's current status, for state conflicts such as `sandbox_not_running`. */
|
|
130
141
|
current_status?: string;
|
|
142
|
+
/** The sandbox that holds a lease's key now, or null when none does (`lease_holder_changed`). */
|
|
143
|
+
holder?: string | null;
|
|
144
|
+
/** The head of the linked branch now (`manifest_changed`). */
|
|
145
|
+
head_commit?: string;
|
|
146
|
+
/** The digest of b3os.yaml at `head_commit` (`manifest_changed`); null when the file is not there. */
|
|
147
|
+
head_digest?: string | null;
|
|
131
148
|
/** The HTTP status the upstream returned (`upstream_error`, `action_output_invalid`). */
|
|
132
149
|
upstream_status?: number;
|
|
133
150
|
/**
|
|
@@ -141,15 +158,19 @@ export interface Problem {
|
|
|
141
158
|
retryable: boolean;
|
|
142
159
|
};
|
|
143
160
|
/**
|
|
144
|
-
* The option a request value was refused for, by its id (`option_not_allowed`), e.g. `sandboxes.clone_reset`.
|
|
161
|
+
* The option a request or setting value was refused for, by its id (`option_not_allowed`, `invalid_option`), e.g. `sandboxes.clone_reset`.
|
|
145
162
|
*/
|
|
146
163
|
option?: string;
|
|
147
|
-
/** The value the request asked for (`option_not_allowed`). */
|
|
164
|
+
/** The value the request or setting asked for (`option_not_allowed`, `invalid_option`). */
|
|
148
165
|
value?: unknown;
|
|
149
|
-
/**
|
|
166
|
+
/**
|
|
167
|
+
* The values the request or setting may ask for (`option_not_allowed`, `invalid_option`, an option with a closed list of values).
|
|
168
|
+
*/
|
|
150
169
|
allowed?: unknown[];
|
|
151
|
-
/**
|
|
152
|
-
|
|
170
|
+
/**
|
|
171
|
+
* 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.
|
|
172
|
+
*/
|
|
173
|
+
bound_by?: "node" | "org" | "flag" | "limit" | "catalog";
|
|
153
174
|
/** The application's service a refusal is about, with `port` (the address codes, `app_host_*`). */
|
|
154
175
|
service?: string;
|
|
155
176
|
/** The port of `service` a refusal is about (the address codes, `app_host_*`). */
|
|
@@ -173,9 +194,21 @@ export interface Problem {
|
|
|
173
194
|
*/
|
|
174
195
|
retryable?: boolean;
|
|
175
196
|
/**
|
|
176
|
-
* The first 4096 bytes of a hosted tool's standard error, on a development node
|
|
197
|
+
* 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.
|
|
177
198
|
*/
|
|
178
199
|
stderr?: string;
|
|
200
|
+
/** The block that removed a hosted tool (`tool_blocked`). */
|
|
201
|
+
block?: string;
|
|
202
|
+
/** What the block of `block` covers (`tool_blocked`). */
|
|
203
|
+
scope?: "publisher" | "pack" | "version" | "action";
|
|
204
|
+
/**
|
|
205
|
+
* Why the egress guard refused the address of a hosted tool's `$url` file value (`action_input_invalid` with `reason: url_denied`): one of `egress_denied`'s reasons.
|
|
206
|
+
*/
|
|
207
|
+
egress_reason?: string;
|
|
208
|
+
/** The part of the answer that was filled (`extract_fields_missing`), without the missing fields. */
|
|
209
|
+
partial_data?: unknown;
|
|
210
|
+
/** The job's pages and how each was read (vision extract errors), as in the job's `result.pages`. */
|
|
211
|
+
pages?: Record<string, unknown>[];
|
|
179
212
|
[key: string]: unknown;
|
|
180
213
|
}
|
|
181
214
|
|
|
@@ -417,6 +450,67 @@ export interface JsonExtractOptions {
|
|
|
417
450
|
prompt?: string;
|
|
418
451
|
}
|
|
419
452
|
|
|
453
|
+
/**
|
|
454
|
+
* 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).
|
|
455
|
+
*/
|
|
456
|
+
export interface PdfOptions {
|
|
457
|
+
/**
|
|
458
|
+
* `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`.
|
|
459
|
+
* @default "text"
|
|
460
|
+
*/
|
|
461
|
+
mode?: "text" | "off";
|
|
462
|
+
/**
|
|
463
|
+
* 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.
|
|
464
|
+
*/
|
|
465
|
+
max_pages?: number;
|
|
466
|
+
/**
|
|
467
|
+
* 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.
|
|
468
|
+
* @default true
|
|
469
|
+
*/
|
|
470
|
+
page_markers?: boolean;
|
|
471
|
+
/**
|
|
472
|
+
* Also return each page's Markdown on its own, in `pdf.page_markdown`.
|
|
473
|
+
* @default false
|
|
474
|
+
*/
|
|
475
|
+
pages?: boolean;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* 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.
|
|
480
|
+
*/
|
|
481
|
+
export interface PdfInfo {
|
|
482
|
+
/** Pages in the file. */
|
|
483
|
+
pages: number;
|
|
484
|
+
/** Pages converted, from the first. */
|
|
485
|
+
pages_read: number;
|
|
486
|
+
/** `vision.page` units this scrape billed: the pages read. */
|
|
487
|
+
pages_billed: number;
|
|
488
|
+
/**
|
|
489
|
+
* 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.
|
|
490
|
+
*/
|
|
491
|
+
truncated: "max_pages" | "max_chars" | "deadline" | "allowance" | null;
|
|
492
|
+
title?: string;
|
|
493
|
+
author?: string;
|
|
494
|
+
subject?: string;
|
|
495
|
+
keywords?: string;
|
|
496
|
+
/** The program that made the original document. */
|
|
497
|
+
creator?: string;
|
|
498
|
+
/** The program that wrote the PDF. */
|
|
499
|
+
producer?: string;
|
|
500
|
+
/** The PDF's creation date (RFC 3339, converted from the PDF date). */
|
|
501
|
+
created_at?: string;
|
|
502
|
+
modified_at?: string;
|
|
503
|
+
/** The PDF carries a structure tree (tagged PDF). The tree is not used yet. */
|
|
504
|
+
tagged?: boolean;
|
|
505
|
+
/** Pages with images and no text layer (scanned); OCR is not available yet, so they add no text. */
|
|
506
|
+
no_text_pages?: number[];
|
|
507
|
+
/** Each page's Markdown, with `pdf.pages`. */
|
|
508
|
+
page_markdown?: {
|
|
509
|
+
page: number;
|
|
510
|
+
markdown: string;
|
|
511
|
+
}[];
|
|
512
|
+
}
|
|
513
|
+
|
|
420
514
|
/** Options shared by scrape, batch scrape, crawl and extract. */
|
|
421
515
|
export interface ScrapeOptions {
|
|
422
516
|
/** @default ["markdown"] */
|
|
@@ -502,6 +596,7 @@ export interface ScrapeOptions {
|
|
|
502
596
|
block_resources?: Array<"image" | "media" | "font" | "stylesheet">;
|
|
503
597
|
screenshot?: ScreenshotOptions;
|
|
504
598
|
json?: JsonExtractOptions;
|
|
599
|
+
pdf?: PdfOptions;
|
|
505
600
|
/**
|
|
506
601
|
* 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.
|
|
507
602
|
* @default "free"
|
|
@@ -513,8 +608,104 @@ export interface ScrapeOptions {
|
|
|
513
608
|
export type ScrapeRequest = {
|
|
514
609
|
/** Absolute `http` or `https` URL. */
|
|
515
610
|
url: string;
|
|
611
|
+
proxy?: ProxyOption;
|
|
612
|
+
/**
|
|
613
|
+
* 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.
|
|
614
|
+
*/
|
|
615
|
+
proxy_country?: string;
|
|
516
616
|
} & ScrapeOptions;
|
|
517
617
|
|
|
618
|
+
/**
|
|
619
|
+
* Where the scrape leaves from (`vision.proxy`). Absent: the node's default, `none` unless its operator set
|
|
620
|
+
* `auto`.
|
|
621
|
+
* - `none`: the node's own address, always.
|
|
622
|
+
* - `auto`: the node's address; when the page comes back a wall (`page_state` `blocked` or `captcha`), vision
|
|
623
|
+
* asks once more from a residential address, unless the request or the site rules that out
|
|
624
|
+
* (`egress.retry.skipped` says why no retry ran). Where residential reads are off it is exactly `none`,
|
|
625
|
+
* never an error.
|
|
626
|
+
* - `residential`: read the page from a residential address, every request of the scrape (`422
|
|
627
|
+
* option_not_allowed` where that is off: `bound_by: node` or `org`).
|
|
628
|
+
* - `http://host:port`: your own proxy, without credentials.
|
|
629
|
+
* - `{url, connection}`: your own proxy with the username and password of a `basic` vault connection whose
|
|
630
|
+
* `hosts` list the proxy's host (needs `vault:run`).
|
|
631
|
+
* A URL with a username or password is refused (`400 invalid_request`): put them in a connection. This node
|
|
632
|
+
* takes `http://` proxies only; plain HTTP means the username and password cross the network to your proxy
|
|
633
|
+
* unencrypted. Batches, crawls, sessions and the Firecrawl surface do not take `proxy` yet.
|
|
634
|
+
*/
|
|
635
|
+
export type ProxyOption =
|
|
636
|
+
| "none"
|
|
637
|
+
| "auto"
|
|
638
|
+
| "residential"
|
|
639
|
+
| string
|
|
640
|
+
| {
|
|
641
|
+
/** Your proxy's URL, `http://host:port`. */
|
|
642
|
+
url: string;
|
|
643
|
+
/** A `basic` vault connection with the proxy's username and password. */
|
|
644
|
+
connection?: string;
|
|
645
|
+
};
|
|
646
|
+
|
|
647
|
+
/**
|
|
648
|
+
* Which exit served the page returned. `node`: the node's own address. `byo`: your proxy (`host`, never its
|
|
649
|
+
* credentials). `residential`: read from a residential address (`country`, `exit_session`). `bytes` counts
|
|
650
|
+
* both directions through the exit for this scrape. With `proxy: "auto"`, after a wall from the node's address:
|
|
651
|
+
* `retried_from`, `first` (the node's wall) when the residential read's page is the one returned, or `retry`
|
|
652
|
+
* when no retry ran (`skipped`) or it did not help (`outcome`).
|
|
653
|
+
*/
|
|
654
|
+
export interface Egress {
|
|
655
|
+
exit: "node" | "byo" | "residential";
|
|
656
|
+
/** Your proxy's host (`byo`). */
|
|
657
|
+
host?: string;
|
|
658
|
+
/** The residential address's country (`residential`). */
|
|
659
|
+
country?: string;
|
|
660
|
+
/**
|
|
661
|
+
* B3OS's id of the residential exit session (one address), the same for every page of one host and organization while it lasts.
|
|
662
|
+
*/
|
|
663
|
+
exit_session?: string;
|
|
664
|
+
/** Bytes through the exit for this scrape, both directions. */
|
|
665
|
+
bytes?: number;
|
|
666
|
+
/** The page was read from a residential address after a wall from the node's address. */
|
|
667
|
+
retried_from?: "node";
|
|
668
|
+
/** The node's wall, when the residential read's page is the one returned. */
|
|
669
|
+
first?: {
|
|
670
|
+
page_state?: string;
|
|
671
|
+
signal?: string;
|
|
672
|
+
status_code?: number;
|
|
673
|
+
};
|
|
674
|
+
/**
|
|
675
|
+
* `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`).
|
|
676
|
+
*/
|
|
677
|
+
retry?: {
|
|
678
|
+
skipped?:
|
|
679
|
+
| "org"
|
|
680
|
+
| "node"
|
|
681
|
+
| "credentials"
|
|
682
|
+
| "opt_out"
|
|
683
|
+
| "category"
|
|
684
|
+
| "memory"
|
|
685
|
+
| "rate_limited"
|
|
686
|
+
| "time"
|
|
687
|
+
| "quota"
|
|
688
|
+
| "robots"
|
|
689
|
+
| "capacity";
|
|
690
|
+
exit?: "residential";
|
|
691
|
+
outcome?: "wall" | "failed";
|
|
692
|
+
page_state?: string;
|
|
693
|
+
error?: string;
|
|
694
|
+
bytes?: number;
|
|
695
|
+
};
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
/**
|
|
699
|
+
* 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.
|
|
700
|
+
*/
|
|
701
|
+
export type ScrapeOptionsApplied = Record<
|
|
702
|
+
string,
|
|
703
|
+
{
|
|
704
|
+
value: unknown;
|
|
705
|
+
from: "request" | "node";
|
|
706
|
+
}
|
|
707
|
+
>;
|
|
708
|
+
|
|
518
709
|
/** Metadata read from the page. */
|
|
519
710
|
export interface PageMetadata {
|
|
520
711
|
title?: string;
|
|
@@ -532,7 +723,7 @@ export interface PageMetadata {
|
|
|
532
723
|
|
|
533
724
|
export interface CacheInfo {
|
|
534
725
|
/**
|
|
535
|
-
* `hit` served from cache; `miss` fetched and stored; `bypass` fetched and not shared (custom headers, profile, actions).
|
|
726
|
+
* `hit` served from cache; `miss` fetched and stored; `bypass` fetched and not shared (custom headers, profile, actions, and every PDF).
|
|
536
727
|
*/
|
|
537
728
|
state: "hit" | "miss" | "bypass";
|
|
538
729
|
/** Age of the served copy in seconds. */
|
|
@@ -562,9 +753,13 @@ export interface ScrapeResult {
|
|
|
562
753
|
/** What served the page. */
|
|
563
754
|
tier: "cache" | "fetch" | "browser";
|
|
564
755
|
/**
|
|
565
|
-
* 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).
|
|
756
|
+
* 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.
|
|
757
|
+
*/
|
|
758
|
+
tier_reason?: "host_prefers_browser" | "needs_js" | "empty_page" | "thin_page" | "fetch_failed" | "challenged";
|
|
759
|
+
/**
|
|
760
|
+
* 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.
|
|
566
761
|
*/
|
|
567
|
-
|
|
762
|
+
fetch_identity?: "chrome" | "honest";
|
|
568
763
|
cache: CacheInfo;
|
|
569
764
|
markdown?: string;
|
|
570
765
|
html?: string;
|
|
@@ -578,6 +773,7 @@ export interface ScrapeResult {
|
|
|
578
773
|
/** Results of `actions`, in order. */
|
|
579
774
|
actions?: ActStepResult[];
|
|
580
775
|
page_state?: PageState;
|
|
776
|
+
pdf?: PdfInfo;
|
|
581
777
|
/**
|
|
582
778
|
* 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`.
|
|
583
779
|
*/
|
|
@@ -585,6 +781,8 @@ export interface ScrapeResult {
|
|
|
585
781
|
/** Non-fatal problems, such as a format that could not be produced. */
|
|
586
782
|
warnings: string[];
|
|
587
783
|
timing: Timing;
|
|
784
|
+
egress?: Egress;
|
|
785
|
+
options?: ScrapeOptionsApplied;
|
|
588
786
|
}
|
|
589
787
|
|
|
590
788
|
export interface PrepareRequest {
|
|
@@ -779,6 +977,9 @@ export interface PageResult {
|
|
|
779
977
|
depth?: number;
|
|
780
978
|
scraped_at?: string;
|
|
781
979
|
scrape?: ScrapeResult;
|
|
980
|
+
/**
|
|
981
|
+
* 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.
|
|
982
|
+
*/
|
|
782
983
|
error?: Problem;
|
|
783
984
|
}
|
|
784
985
|
|
|
@@ -830,10 +1031,15 @@ export type BatchEvent = PageEvent;
|
|
|
830
1031
|
/** An event of a crawl's stream. */
|
|
831
1032
|
export type CrawlEvent = PageEvent;
|
|
832
1033
|
|
|
1034
|
+
/** At least one of `schema` and `prompt` is required. */
|
|
833
1035
|
export interface ExtractCreateRequest {
|
|
1036
|
+
/** The pages to read (`vision.extract.urls_max`); duplicates are read once. */
|
|
834
1037
|
urls: string[];
|
|
1038
|
+
/** What to extract, in words. With `schema`, guidance for filling it. */
|
|
835
1039
|
prompt?: string;
|
|
836
|
-
/**
|
|
1040
|
+
/**
|
|
1041
|
+
* 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.
|
|
1042
|
+
*/
|
|
837
1043
|
schema?: Record<string, unknown>;
|
|
838
1044
|
scrape?: NestedScrapeOptions;
|
|
839
1045
|
/** Model ID from `GET /v1/infer/models`; defaults to the node's model. */
|
|
@@ -848,13 +1054,49 @@ export type ExtractJob = Omit<Job, "id" | "object" | "result"> & {
|
|
|
848
1054
|
object: "job";
|
|
849
1055
|
kind: "vision.extract";
|
|
850
1056
|
result?: {
|
|
851
|
-
/** The extracted data,
|
|
1057
|
+
/** The extracted data, validated against your schema (any JSON object without one). */
|
|
852
1058
|
data: unknown;
|
|
853
|
-
/** Pages the data came from
|
|
1059
|
+
/** Pages the data came from, as given in `urls`. */
|
|
854
1060
|
sources: string[];
|
|
1061
|
+
/** For each top-level field of `data`, the pages it came from. */
|
|
1062
|
+
field_sources?: Record<string, string[]>;
|
|
1063
|
+
/** Every URL of the job, in the order given, and how it was read. */
|
|
1064
|
+
pages?: ExtractPage[];
|
|
1065
|
+
usage?: ExtractUsage;
|
|
1066
|
+
/**
|
|
1067
|
+
* 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.
|
|
1068
|
+
*/
|
|
1069
|
+
warnings?: string[];
|
|
855
1070
|
};
|
|
856
1071
|
};
|
|
857
1072
|
|
|
1073
|
+
/** One URL of an extract job. */
|
|
1074
|
+
export interface ExtractPage {
|
|
1075
|
+
url: string;
|
|
1076
|
+
status: "succeeded" | "failed";
|
|
1077
|
+
final_url?: string;
|
|
1078
|
+
content_type?: string | null;
|
|
1079
|
+
/** Characters of the page's Markdown the model read. */
|
|
1080
|
+
chars?: number;
|
|
1081
|
+
/** The page's Markdown was cut (pieces past `extract.max_model_calls`, or a PDF's own caps). */
|
|
1082
|
+
truncated?: boolean;
|
|
1083
|
+
/** Pages read when the URL served a PDF. */
|
|
1084
|
+
pdf_pages?: number | null;
|
|
1085
|
+
/** Why the page failed (the codes a scrape answers with). A failed page bills nothing. */
|
|
1086
|
+
error?: Problem;
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
/** What the job used. */
|
|
1090
|
+
export interface ExtractUsage {
|
|
1091
|
+
/** `vision.page` units billed for the pages read. */
|
|
1092
|
+
pages_billed: number;
|
|
1093
|
+
/** Prompt tokens of the model calls (billed by infer as `infer.input_tokens`). */
|
|
1094
|
+
input_tokens: number;
|
|
1095
|
+
/** Answer tokens of the model calls (`infer.output_tokens`). */
|
|
1096
|
+
output_tokens: number;
|
|
1097
|
+
model_calls: number;
|
|
1098
|
+
}
|
|
1099
|
+
|
|
858
1100
|
/**
|
|
859
1101
|
* `active` until closed by its timeout (`expired`) or otherwise (`closed`: `DELETE`, its browser stopped, or the node restarted; `closed_reason` says which).
|
|
860
1102
|
*/
|
|
@@ -1235,6 +1477,12 @@ export interface SnapshotData {
|
|
|
1235
1477
|
complete: boolean;
|
|
1236
1478
|
/** The budget (`max_tokens`) cut the outline. */
|
|
1237
1479
|
truncated: boolean;
|
|
1480
|
+
/**
|
|
1481
|
+
* 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.
|
|
1482
|
+
*/
|
|
1483
|
+
title?: string;
|
|
1484
|
+
/** The page's URL when the outline was taken, read the same way. Node release 1119. */
|
|
1485
|
+
url?: string;
|
|
1238
1486
|
}
|
|
1239
1487
|
|
|
1240
1488
|
export interface ActRequest {
|
|
@@ -2140,6 +2388,320 @@ export type ScreenshotList = Omit<ListEnvelope, "data"> & {
|
|
|
2140
2388
|
data: Screenshot[];
|
|
2141
2389
|
};
|
|
2142
2390
|
|
|
2391
|
+
/**
|
|
2392
|
+
* Give exactly one of `url` or `video_id`. `steps`, `watch`, `viewport` and `theme` are for `url` only.
|
|
2393
|
+
*/
|
|
2394
|
+
export type InspectionCreateRequest = {
|
|
2395
|
+
/** Page to load (`http` or `https`), checked by the egress guard. */
|
|
2396
|
+
url?: string;
|
|
2397
|
+
/** A succeeded video of this project to read the window from. */
|
|
2398
|
+
video_id?: string;
|
|
2399
|
+
/**
|
|
2400
|
+
* 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.
|
|
2401
|
+
*/
|
|
2402
|
+
steps?: ScriptStep[];
|
|
2403
|
+
/** Elements whose box is read on every frame (`trace`). */
|
|
2404
|
+
watch?: InspectionWatchTarget[];
|
|
2405
|
+
/**
|
|
2406
|
+
* 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).
|
|
2407
|
+
*/
|
|
2408
|
+
duration_ms?: number;
|
|
2409
|
+
/**
|
|
2410
|
+
* 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).
|
|
2411
|
+
*/
|
|
2412
|
+
from_ms?: number;
|
|
2413
|
+
/**
|
|
2414
|
+
* Frames a second. Default 30; with `video_id`, the video's own rate. `duration_ms` times `fps` is at most 300 frames.
|
|
2415
|
+
*/
|
|
2416
|
+
fps?: 10 | 15 | 30 | 60;
|
|
2417
|
+
viewport?: InspectionViewport;
|
|
2418
|
+
/**
|
|
2419
|
+
* Emulated `prefers-color-scheme`; `auto` leaves the page default.
|
|
2420
|
+
* @default "auto"
|
|
2421
|
+
*/
|
|
2422
|
+
theme?: "light" | "dark" | "auto";
|
|
2423
|
+
/**
|
|
2424
|
+
* 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.
|
|
2425
|
+
*/
|
|
2426
|
+
interval_ms?: number;
|
|
2427
|
+
};
|
|
2428
|
+
|
|
2429
|
+
/** Browser viewport in CSS pixels. Default 1280x800. */
|
|
2430
|
+
export interface InspectionViewport {
|
|
2431
|
+
width: number;
|
|
2432
|
+
height: number;
|
|
2433
|
+
}
|
|
2434
|
+
|
|
2435
|
+
/**
|
|
2436
|
+
* 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.
|
|
2437
|
+
*/
|
|
2438
|
+
export type InspectionWatchTarget = {
|
|
2439
|
+
selector?: string;
|
|
2440
|
+
text?: string;
|
|
2441
|
+
/** @default false */
|
|
2442
|
+
exact?: boolean;
|
|
2443
|
+
nth?: number;
|
|
2444
|
+
};
|
|
2445
|
+
|
|
2446
|
+
export interface Inspection {
|
|
2447
|
+
id: string;
|
|
2448
|
+
object: "inspection";
|
|
2449
|
+
/** An inspection answers once it has finished; a failure is an error response. */
|
|
2450
|
+
status: "succeeded";
|
|
2451
|
+
source: InspectionSource;
|
|
2452
|
+
window: InspectionWindow;
|
|
2453
|
+
/** When each step ran, in the window's clock. */
|
|
2454
|
+
steps: InspectionStep[];
|
|
2455
|
+
/**
|
|
2456
|
+
* 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`.
|
|
2457
|
+
*/
|
|
2458
|
+
summary: string[];
|
|
2459
|
+
report: InspectionReport;
|
|
2460
|
+
/** One entry per `watch` target, in request order; empty without `watch`. */
|
|
2461
|
+
trace: InspectionTrace[];
|
|
2462
|
+
/**
|
|
2463
|
+
* The browser's own layout-shift entries (the Layout Instability API), each naming the elements that moved. Left out when the browser reported none.
|
|
2464
|
+
*/
|
|
2465
|
+
layout_shifts?: InspectionLayoutShift[];
|
|
2466
|
+
sheet: InspectionSheet;
|
|
2467
|
+
/**
|
|
2468
|
+
* 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).
|
|
2469
|
+
*/
|
|
2470
|
+
warnings: string[];
|
|
2471
|
+
/**
|
|
2472
|
+
* 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.
|
|
2473
|
+
*/
|
|
2474
|
+
timing: Timing;
|
|
2475
|
+
created_at: string;
|
|
2476
|
+
/** When the sheet is deleted, 24 hours after it was made. */
|
|
2477
|
+
expires_at: string;
|
|
2478
|
+
}
|
|
2479
|
+
|
|
2480
|
+
/** The page (`url`, `final_url`, `status_code`) or the video (`video_id`). */
|
|
2481
|
+
export interface InspectionSource {
|
|
2482
|
+
url?: string;
|
|
2483
|
+
/** The URL after redirects. */
|
|
2484
|
+
final_url?: string;
|
|
2485
|
+
/** The HTTP status the site answered for the page. */
|
|
2486
|
+
status_code?: number;
|
|
2487
|
+
video_id?: string;
|
|
2488
|
+
}
|
|
2489
|
+
|
|
2490
|
+
export interface InspectionSize {
|
|
2491
|
+
width: number;
|
|
2492
|
+
height: number;
|
|
2493
|
+
}
|
|
2494
|
+
|
|
2495
|
+
export interface InspectionWindow {
|
|
2496
|
+
/** The time of frame 0. Frame i is at `from_ms + round(i * 1000 / fps)`. */
|
|
2497
|
+
from_ms: number;
|
|
2498
|
+
duration_ms: number;
|
|
2499
|
+
fps: number;
|
|
2500
|
+
frames: number;
|
|
2501
|
+
/** The frame size in `units`, the viewport for a page and the video's size for a video. */
|
|
2502
|
+
viewport: InspectionSize;
|
|
2503
|
+
/** What every position and size in the answer is measured in. */
|
|
2504
|
+
units: "css_px" | "video_px";
|
|
2505
|
+
}
|
|
2506
|
+
|
|
2507
|
+
export interface InspectionStep {
|
|
2508
|
+
/** The step's path in the request, such as `steps/0`. */
|
|
2509
|
+
path: string;
|
|
2510
|
+
kind: string;
|
|
2511
|
+
/** When it started (a click's press). */
|
|
2512
|
+
t_ms: number;
|
|
2513
|
+
/** When it ended. */
|
|
2514
|
+
end_ms: number;
|
|
2515
|
+
}
|
|
2516
|
+
|
|
2517
|
+
/** A box in `window.units`. `name` is set on the two regions the sheet crops, `R1` and `R2`. */
|
|
2518
|
+
export interface InspectionRegion {
|
|
2519
|
+
x: number;
|
|
2520
|
+
y: number;
|
|
2521
|
+
w: number;
|
|
2522
|
+
h: number;
|
|
2523
|
+
name?: "R1" | "R2";
|
|
2524
|
+
}
|
|
2525
|
+
|
|
2526
|
+
export interface InspectionRect {
|
|
2527
|
+
x: number;
|
|
2528
|
+
y: number;
|
|
2529
|
+
w: number;
|
|
2530
|
+
h: number;
|
|
2531
|
+
}
|
|
2532
|
+
|
|
2533
|
+
/**
|
|
2534
|
+
* 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.
|
|
2535
|
+
*/
|
|
2536
|
+
export interface InspectionReport {
|
|
2537
|
+
/**
|
|
2538
|
+
* `[frame, share]` for every frame where at least 0.1% of the picture changed against the frame before.
|
|
2539
|
+
*/
|
|
2540
|
+
changed: [number, number, ...unknown[]][];
|
|
2541
|
+
/**
|
|
2542
|
+
* 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).
|
|
2543
|
+
*/
|
|
2544
|
+
events: InspectionEvent[];
|
|
2545
|
+
/** Content that moved vertically by more than 2 px from one frame to the next. */
|
|
2546
|
+
shifts: InspectionShift[];
|
|
2547
|
+
/**
|
|
2548
|
+
* A region of at least 0.5% of the picture that changed and came back within 100 ms (A, then B, then A).
|
|
2549
|
+
*/
|
|
2550
|
+
flashes: InspectionFlash[];
|
|
2551
|
+
/**
|
|
2552
|
+
* Frames where at least 40% of the picture was replaced while the frames either side changed by at most 5%.
|
|
2553
|
+
*/
|
|
2554
|
+
cuts: InspectionCut[];
|
|
2555
|
+
/** Three or more frames without a move between two scroll shifts the same way. */
|
|
2556
|
+
stalls: InspectionStall[];
|
|
2557
|
+
/** `[y0, y1)` rows left out of the analysis: a video's caption rows. Left out when none. */
|
|
2558
|
+
masked?: number[][];
|
|
2559
|
+
network?: InspectionNetwork;
|
|
2560
|
+
}
|
|
2561
|
+
|
|
2562
|
+
export interface InspectionEvent {
|
|
2563
|
+
/** The first changed frame. */
|
|
2564
|
+
t0_ms: number;
|
|
2565
|
+
/** The settled frame, the first one after the last change (the last frame when it never settled). */
|
|
2566
|
+
t1_ms: number;
|
|
2567
|
+
/** The largest changed share in the run. */
|
|
2568
|
+
peak: number;
|
|
2569
|
+
peak_ms: number;
|
|
2570
|
+
/** Changed frames in the run. */
|
|
2571
|
+
frames: number;
|
|
2572
|
+
/** False when the window ended while it was still changing. */
|
|
2573
|
+
settled: boolean;
|
|
2574
|
+
/** The step that started at most 100 ms before the run, such as `steps/0`. */
|
|
2575
|
+
after_step?: string;
|
|
2576
|
+
regions: InspectionRegion[];
|
|
2577
|
+
}
|
|
2578
|
+
|
|
2579
|
+
export interface InspectionShift {
|
|
2580
|
+
t_ms: number;
|
|
2581
|
+
frame: number;
|
|
2582
|
+
/** How far it moved; positive is down. */
|
|
2583
|
+
dy: number;
|
|
2584
|
+
/** The row, in the frame before, where the moved content starts (0 when `whole`). */
|
|
2585
|
+
from_y: number;
|
|
2586
|
+
/** `scroll` when the page's scroll offset moved by the same amount, else `layout`. */
|
|
2587
|
+
kind: "scroll" | "layout";
|
|
2588
|
+
/** It moved 8 px or more. */
|
|
2589
|
+
large: boolean;
|
|
2590
|
+
/** Everything moved, the top of the picture included. */
|
|
2591
|
+
whole: boolean;
|
|
2592
|
+
}
|
|
2593
|
+
|
|
2594
|
+
export interface InspectionFlash {
|
|
2595
|
+
t_ms: number;
|
|
2596
|
+
frame: number;
|
|
2597
|
+
/** How long it showed. */
|
|
2598
|
+
ms: number;
|
|
2599
|
+
region: InspectionRegion;
|
|
2600
|
+
/** `lighter` or `darker` when the region's mean luma moved by 16 levels or more. */
|
|
2601
|
+
kind: "lighter" | "darker" | "other";
|
|
2602
|
+
}
|
|
2603
|
+
|
|
2604
|
+
export interface InspectionCut {
|
|
2605
|
+
t_ms: number;
|
|
2606
|
+
frame: number;
|
|
2607
|
+
/** The share of the picture that changed. */
|
|
2608
|
+
share: number;
|
|
2609
|
+
/** `camera_cut` is a cut the video's camera planned (video source only). */
|
|
2610
|
+
kind: "cut" | "camera_cut";
|
|
2611
|
+
}
|
|
2612
|
+
|
|
2613
|
+
export interface InspectionStall {
|
|
2614
|
+
/** The first frame without a move. */
|
|
2615
|
+
t0_ms: number;
|
|
2616
|
+
/** The frame where the scroll moved again. */
|
|
2617
|
+
t1_ms: number;
|
|
2618
|
+
frames: number;
|
|
2619
|
+
}
|
|
2620
|
+
|
|
2621
|
+
/**
|
|
2622
|
+
* 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`.
|
|
2623
|
+
*/
|
|
2624
|
+
export interface InspectionNetwork {
|
|
2625
|
+
/** Wall-clock ms the page's clock was held while requests were in flight. */
|
|
2626
|
+
held_ms: number;
|
|
2627
|
+
/** How many times it was held. */
|
|
2628
|
+
waits: number;
|
|
2629
|
+
/** Page time run ahead of the window off camera (0 for an inspection, which never runs ahead). */
|
|
2630
|
+
ahead_ms: number;
|
|
2631
|
+
}
|
|
2632
|
+
|
|
2633
|
+
export interface InspectionTrace {
|
|
2634
|
+
target: InspectionWatchTarget;
|
|
2635
|
+
/** Whether the target matched an element on any frame. */
|
|
2636
|
+
found: boolean;
|
|
2637
|
+
/** The first 40 characters of the element's text or `aria-label`. */
|
|
2638
|
+
label?: string;
|
|
2639
|
+
/**
|
|
2640
|
+
* `[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.
|
|
2641
|
+
*/
|
|
2642
|
+
boxes: [number, number, number, number, number, boolean, ...unknown[]][];
|
|
2643
|
+
/** Each change of the box against the entry before it. */
|
|
2644
|
+
moves: {
|
|
2645
|
+
t_ms: number;
|
|
2646
|
+
dx: number;
|
|
2647
|
+
dy: number;
|
|
2648
|
+
dw: number;
|
|
2649
|
+
dh: number;
|
|
2650
|
+
}[];
|
|
2651
|
+
}
|
|
2652
|
+
|
|
2653
|
+
export interface InspectionLayoutShift {
|
|
2654
|
+
/** The frame the shift showed on. */
|
|
2655
|
+
t_ms: number;
|
|
2656
|
+
sources: {
|
|
2657
|
+
/** A unique CSS selector for the element that moved. */
|
|
2658
|
+
selector: string;
|
|
2659
|
+
/** The first 40 characters of its text or `aria-label`. */
|
|
2660
|
+
label?: string;
|
|
2661
|
+
from: InspectionRect;
|
|
2662
|
+
to: InspectionRect;
|
|
2663
|
+
}[];
|
|
2664
|
+
}
|
|
2665
|
+
|
|
2666
|
+
/**
|
|
2667
|
+
* 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.
|
|
2668
|
+
*/
|
|
2669
|
+
export interface InspectionSheet {
|
|
2670
|
+
artifact: Artifact;
|
|
2671
|
+
width: number;
|
|
2672
|
+
height: number;
|
|
2673
|
+
/** ceil(width / 28) x ceil(height / 28), the image's cost for a model that reads 28 px patches. */
|
|
2674
|
+
tokens: number;
|
|
2675
|
+
tiles: InspectionTile[];
|
|
2676
|
+
crops: InspectionCrop[];
|
|
2677
|
+
}
|
|
2678
|
+
|
|
2679
|
+
export interface InspectionTile {
|
|
2680
|
+
frame: number;
|
|
2681
|
+
t_ms: number;
|
|
2682
|
+
x: number;
|
|
2683
|
+
y: number;
|
|
2684
|
+
w: number;
|
|
2685
|
+
h: number;
|
|
2686
|
+
tags: string[];
|
|
2687
|
+
}
|
|
2688
|
+
|
|
2689
|
+
/**
|
|
2690
|
+
* 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).
|
|
2691
|
+
*/
|
|
2692
|
+
export interface InspectionCrop {
|
|
2693
|
+
region: "R1" | "R2";
|
|
2694
|
+
before_ms: number;
|
|
2695
|
+
after_ms: number;
|
|
2696
|
+
scale: number;
|
|
2697
|
+
/** The part of the frame shown, in `window.units`. */
|
|
2698
|
+
area: InspectionRegion;
|
|
2699
|
+
/** Where the before panel is on the sheet. */
|
|
2700
|
+
before: InspectionRect;
|
|
2701
|
+
/** Where the after panel is on the sheet. */
|
|
2702
|
+
after: InspectionRect;
|
|
2703
|
+
}
|
|
2704
|
+
|
|
2143
2705
|
export interface Artifact {
|
|
2144
2706
|
id: string;
|
|
2145
2707
|
object: "artifact";
|
|
@@ -2295,9 +2857,21 @@ export interface VideoOutput {
|
|
|
2295
2857
|
|
|
2296
2858
|
export type VideoFormat = "mp4" | "gif" | "poster";
|
|
2297
2859
|
|
|
2860
|
+
/**
|
|
2861
|
+
* 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.
|
|
2862
|
+
*/
|
|
2298
2863
|
export interface VideoCreateRequest {
|
|
2299
2864
|
source: VideoSource;
|
|
2300
|
-
|
|
2865
|
+
/** The script, one beat per line of narration. Leave it out and give `goal` to have the node plan it. */
|
|
2866
|
+
beats?: Beat[];
|
|
2867
|
+
/**
|
|
2868
|
+
* What the video should show, in a sentence ("Show how to open billing and switch the plan to annual").
|
|
2869
|
+
* The node plans the beats from the start page (the operation's description says how) and the video
|
|
2870
|
+
* shows them in `goal`. Needs `vision:run` and `infer:run` besides `render:run`. Not with
|
|
2871
|
+
* `source.profile`: a goal is planned on public pages only.
|
|
2872
|
+
*/
|
|
2873
|
+
goal?: string;
|
|
2874
|
+
alias?: VideoAliasName;
|
|
2301
2875
|
/**
|
|
2302
2876
|
* The narration voice. Leave it out and every beat with `say` is narrated in the node's default voice,
|
|
2303
2877
|
* `kokoro-82m` `af_heart`, normalized to -16 LUFS. Narration is speech made as the caller, so it needs
|
|
@@ -2634,6 +3208,7 @@ export interface RecordingInfo {
|
|
|
2634
3208
|
}
|
|
2635
3209
|
|
|
2636
3210
|
export interface VideoRestyleRequest {
|
|
3211
|
+
alias?: VideoAliasName;
|
|
2637
3212
|
style?: RenderStyle;
|
|
2638
3213
|
captions?: CaptionOptions;
|
|
2639
3214
|
output?: VideoOutput;
|
|
@@ -2647,23 +3222,144 @@ export interface VideoShareRequest {
|
|
|
2647
3222
|
title?: string;
|
|
2648
3223
|
}
|
|
2649
3224
|
|
|
3225
|
+
/**
|
|
3226
|
+
* A public share of a video or an alias. Its URLs are on `usercontent.b3os.org` and need no key:
|
|
3227
|
+
*
|
|
3228
|
+
* - `/s/<share id>`: the player page (HTML, Open Graph and JSON-LD for link previews, its own iframe embed).
|
|
3229
|
+
* Query parameters shape the player: `autoplay=1` (starts muted, as browsers require), `muted=1`, `loop=1`,
|
|
3230
|
+
* `controls=0` and `t=<seconds>` (0 to 86400, where it starts); others are ignored.
|
|
3231
|
+
* - `/s/<share id>/<file>`: the share's current file (`video.mp4`, `poster.jpg`, `video.gif`,
|
|
3232
|
+
* `captions.vtt`, `chapters.vtt`), the URLs in `media`. For an alias share they change bytes when the alias
|
|
3233
|
+
* moves (the `ETag` changes with them).
|
|
3234
|
+
* - `/s/<share id>/v/<video host id>/<file>`: a file of one video, which the page itself plays, so a player
|
|
3235
|
+
* keeps one video's bytes. For an alias, the video it left stays served for an hour after it moves.
|
|
3236
|
+
* - `/oembed?url=<share URL>` (`oembed_url`): the oEmbed answer (JSON, type `video`), an iframe of the page at
|
|
3237
|
+
* most 960 wide (`maxwidth` and `maxheight` make it smaller) plus a 32-pixel footer.
|
|
3238
|
+
*
|
|
3239
|
+
* A stopped, expired or taken-down share answers 404 on its files and oEmbed, and a short page on its own URL
|
|
3240
|
+
* (404, 410 for a video that expired, 451 when B3 took it down). Every answer may be cached for 60 seconds at
|
|
3241
|
+
* most, and each address may make 600 requests a minute (`render.share.address.rpm`).
|
|
3242
|
+
*/
|
|
2650
3243
|
export interface VideoShare {
|
|
2651
3244
|
object: "video_share";
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
3245
|
+
/** The share ID. Unguessable (128 random bits); its host-safe form (`shr-…`) is in `url`. */
|
|
3246
|
+
id: string;
|
|
3247
|
+
/** The video it plays now (for an alias share, the one the alias points at; `null` when none). */
|
|
3248
|
+
video_id: string | null;
|
|
3249
|
+
/** The alias for an alias share, else `null`. */
|
|
3250
|
+
alias: string | null;
|
|
2655
3251
|
title: string;
|
|
2656
|
-
/** The share page,
|
|
3252
|
+
/** The share page, `https://usercontent.b3os.org/s/shr-…`. */
|
|
2657
3253
|
url: string;
|
|
2658
|
-
/**
|
|
3254
|
+
/**
|
|
3255
|
+
* 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.
|
|
3256
|
+
*/
|
|
2659
3257
|
embed_html: string;
|
|
3258
|
+
/** The oEmbed answer for `url`. */
|
|
3259
|
+
oembed_url: string;
|
|
3260
|
+
media: VideoShareMedia;
|
|
2660
3261
|
/** The video's width in pixels. */
|
|
2661
3262
|
width: number;
|
|
2662
3263
|
/** The video's height in pixels. */
|
|
2663
3264
|
height: number;
|
|
2664
3265
|
created_at: string;
|
|
2665
|
-
/**
|
|
2666
|
-
|
|
3266
|
+
/**
|
|
3267
|
+
* 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.
|
|
3268
|
+
*/
|
|
3269
|
+
expires_at: string | null;
|
|
3270
|
+
/**
|
|
3271
|
+
* `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.
|
|
3272
|
+
*/
|
|
3273
|
+
blocked: boolean;
|
|
3274
|
+
}
|
|
3275
|
+
|
|
3276
|
+
/** Stable URLs of the share's files, for a README image or a `<video>` written by hand. */
|
|
3277
|
+
export interface VideoShareMedia {
|
|
3278
|
+
mp4: string;
|
|
3279
|
+
poster?: string;
|
|
3280
|
+
gif?: string;
|
|
3281
|
+
/** WebVTT captions. */
|
|
3282
|
+
captions?: string;
|
|
3283
|
+
/** WebVTT chapters (beat titles). */
|
|
3284
|
+
chapters?: string;
|
|
3285
|
+
}
|
|
3286
|
+
|
|
3287
|
+
export interface VideoShareRef {
|
|
3288
|
+
id: string;
|
|
3289
|
+
url: string;
|
|
3290
|
+
/**
|
|
3291
|
+
* `true` when B3 took the share down (its page answers 451); the reason is not shown. See `VideoShare.blocked`.
|
|
3292
|
+
*/
|
|
3293
|
+
blocked: boolean;
|
|
3294
|
+
}
|
|
3295
|
+
|
|
3296
|
+
/**
|
|
3297
|
+
* Tags the video with this alias of the project and makes the alias if it does not exist. When the video
|
|
3298
|
+
* succeeds, the alias points at it (unless it is pinned, or a newer tagged video already succeeded), and the
|
|
3299
|
+
* video is kept past the 7-day retention while it does. Its files count toward `render.kept.bytes`; a video
|
|
3300
|
+
* that would pass that limit still succeeds but is kept 7 days, leaves the alias where it was and warns
|
|
3301
|
+
* `alias_storage`. A new alias past `render.aliases.max` answers 422 `limit_exceeded`. Needs `render:write`
|
|
3302
|
+
* (a tag can change what a live share plays). A video recorded with `source.profile` never moves an alias that
|
|
3303
|
+
* has a share: it warns `alias_signed_in`, and `PUT` with `video_id` moves the alias to it.
|
|
3304
|
+
*/
|
|
3305
|
+
export type VideoAliasName = string;
|
|
3306
|
+
|
|
3307
|
+
export interface VideoAliasPutRequest {
|
|
3308
|
+
/** Point the alias at this tagged, succeeded video and pin it there (`follow` becomes `false`). */
|
|
3309
|
+
video_id?: string;
|
|
3310
|
+
/**
|
|
3311
|
+
* `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.
|
|
3312
|
+
*/
|
|
3313
|
+
follow?: boolean;
|
|
3314
|
+
}
|
|
3315
|
+
|
|
3316
|
+
export interface VideoAlias {
|
|
3317
|
+
object: "video_alias";
|
|
3318
|
+
id: string;
|
|
3319
|
+
name: VideoAliasName;
|
|
3320
|
+
/** The video the alias points at, kept while it does; `null` before one succeeded. */
|
|
3321
|
+
video_id: string | null;
|
|
3322
|
+
/** Whether a newly succeeded tagged video moves the alias (`false` after `PUT` with `video_id`). */
|
|
3323
|
+
follow: boolean;
|
|
3324
|
+
/** The newest 20 videos tagged with the alias, newest first, expired ones left out. */
|
|
3325
|
+
videos: {
|
|
3326
|
+
video_id: string;
|
|
3327
|
+
status: JobStatus;
|
|
3328
|
+
created_at: string;
|
|
3329
|
+
}[];
|
|
3330
|
+
/** The alias's share, if any; `blocked` says when B3 took it down. */
|
|
3331
|
+
share: VideoShare | null;
|
|
3332
|
+
created_at: string;
|
|
3333
|
+
updated_at: string;
|
|
3334
|
+
}
|
|
3335
|
+
|
|
3336
|
+
export type VideoAliasList = Omit<ListEnvelope, "data"> & {
|
|
3337
|
+
data: VideoAlias[];
|
|
3338
|
+
};
|
|
3339
|
+
|
|
3340
|
+
/**
|
|
3341
|
+
* A video made from a `goal`: what was asked and the beats the node planned. `state` is `drafting` while the
|
|
3342
|
+
* job's draft phase runs, `drafted` once the beats are planned (they are then the video's script), `failed`
|
|
3343
|
+
* when planning failed (the job's `error` is `goal_unplanned`).
|
|
3344
|
+
*/
|
|
3345
|
+
export interface VideoGoal {
|
|
3346
|
+
/** The goal as given. */
|
|
3347
|
+
text: string;
|
|
3348
|
+
state: "drafting" | "drafted" | "failed";
|
|
3349
|
+
/** The planned beats; send them as `beats` to record the same steps again. */
|
|
3350
|
+
beats?: Beat[];
|
|
3351
|
+
/** Whether the planned steps ran once in a browser before recording. */
|
|
3352
|
+
checked?: boolean;
|
|
3353
|
+
/** Steps the model wrote that the page could not run, left out of `beats`. */
|
|
3354
|
+
dropped?: number;
|
|
3355
|
+
/** Buttons, links and fields the start page listed. */
|
|
3356
|
+
controls?: number;
|
|
3357
|
+
/** Controls the planned steps revealed that the start page did not show (a form, the next page). */
|
|
3358
|
+
more?: number;
|
|
3359
|
+
/** The chat model that planned the beats. */
|
|
3360
|
+
model?: string;
|
|
3361
|
+
/** How long planning took. */
|
|
3362
|
+
plan_ms?: number;
|
|
2667
3363
|
}
|
|
2668
3364
|
|
|
2669
3365
|
export interface VideoResult {
|
|
@@ -2682,7 +3378,7 @@ export interface VideoResult {
|
|
|
2682
3378
|
recording?: RecordingInfo;
|
|
2683
3379
|
narration?: NarrationInfo;
|
|
2684
3380
|
/**
|
|
2685
|
-
* 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.
|
|
3381
|
+
* 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.
|
|
2686
3382
|
*/
|
|
2687
3383
|
warnings?: string[];
|
|
2688
3384
|
auto_background?: AutoBackgroundChoice;
|
|
@@ -2701,7 +3397,11 @@ export interface NarrationInfo {
|
|
|
2701
3397
|
reason?: string;
|
|
2702
3398
|
}
|
|
2703
3399
|
|
|
2704
|
-
/**
|
|
3400
|
+
/**
|
|
3401
|
+
* A video job (`vid_…`). `progress` counts phases (voice, plan, capture, compose, encode, upload; a video made
|
|
3402
|
+
* from a `goal` starts with draft). While an alias points at the video (`kept_by_alias`), `expires_at` is
|
|
3403
|
+
* `null`: the video is kept until the alias moves on, then for 24 hours more.
|
|
3404
|
+
*/
|
|
2705
3405
|
export type Video = Omit<Job, "id" | "object" | "result"> & {
|
|
2706
3406
|
id: string;
|
|
2707
3407
|
object: "video";
|
|
@@ -2715,6 +3415,15 @@ export type Video = Omit<Job, "id" | "object" | "result"> & {
|
|
|
2715
3415
|
*/
|
|
2716
3416
|
queue_position?: number;
|
|
2717
3417
|
result?: VideoResult;
|
|
3418
|
+
/** The alias the video was created or restyled with, if any. */
|
|
3419
|
+
alias?: string | null;
|
|
3420
|
+
/** The alias that points at the video and keeps it past the retention, if any. */
|
|
3421
|
+
kept_by_alias?: string | null;
|
|
3422
|
+
/**
|
|
3423
|
+
* The video's own share, if any (`POST /v1/render/videos/{video_id}/share`); `blocked: true` when B3 took it down.
|
|
3424
|
+
*/
|
|
3425
|
+
share?: VideoShareRef | null;
|
|
3426
|
+
goal?: VideoGoal;
|
|
2718
3427
|
};
|
|
2719
3428
|
|
|
2720
3429
|
export type VideoList = Omit<ListEnvelope, "data"> & {
|
|
@@ -2724,11 +3433,16 @@ export type VideoList = Omit<ListEnvelope, "data"> & {
|
|
|
2724
3433
|
/**
|
|
2725
3434
|
* An event of a video's stream. `job.queued` carries `queue_position` when the video waits for a slot (its
|
|
2726
3435
|
* place when it was created; the video itself has the current one); `video.phase` carries `phase`;
|
|
3436
|
+
* `video.drafted` (a video made from a `goal`) carries the planned `beats`, `checked`, `dropped` and `model`;
|
|
2727
3437
|
* `video.artifact` carries `artifact` (without a signed URL; fetch the artifact or the video for one).
|
|
2728
3438
|
*/
|
|
2729
3439
|
export type VideoEvent = JobEvent & {
|
|
2730
3440
|
queue_position?: number;
|
|
2731
|
-
phase?: "voice" | "plan" | "capture" | "compose" | "encode" | "upload";
|
|
3441
|
+
phase?: "draft" | "voice" | "plan" | "capture" | "compose" | "encode" | "upload";
|
|
3442
|
+
beats?: Beat[];
|
|
3443
|
+
checked?: boolean;
|
|
3444
|
+
dropped?: number;
|
|
3445
|
+
model?: string;
|
|
2732
3446
|
artifact?: Artifact;
|
|
2733
3447
|
};
|
|
2734
3448
|
|
|
@@ -3507,9 +4221,9 @@ export type RenderBackgroundPackList = Omit<ListEnvelope, "data"> & {
|
|
|
3507
4221
|
};
|
|
3508
4222
|
|
|
3509
4223
|
/**
|
|
3510
|
-
* `running` → `paused` ↔ `running` → `stopped`. `failed` means the microVM crashed; its usage is final.
|
|
4224
|
+
* `running` → `paused` ↔ `running` → `stopped`. `failed` means the microVM crashed; its usage is final. `hibernated` is an agent instance's microVM written to the node's disk with no process left (only agent instances, `/v1/agents`): its memory snapshot, which a message to its instance or a request to its port restores in place, or its disk alone (dormant), which a message to its instance boots. It is never listed.
|
|
3511
4225
|
*/
|
|
3512
|
-
export type SandboxStatus = "running" | "paused" | "stopped" | "failed";
|
|
4226
|
+
export type SandboxStatus = "running" | "paused" | "stopped" | "failed" | "hibernated";
|
|
3513
4227
|
|
|
3514
4228
|
/**
|
|
3515
4229
|
* A value placed in the environment but never returned or logged; either the value itself or a field of a vault connection.
|
|
@@ -3574,8 +4288,30 @@ export interface SandboxApiGrant {
|
|
|
3574
4288
|
spend_cap_usd?: number | null;
|
|
3575
4289
|
/** Vault connections the sandbox's action calls may use. */
|
|
3576
4290
|
connections?: string[];
|
|
4291
|
+
actions?: SandboxActionsRule;
|
|
3577
4292
|
}
|
|
3578
4293
|
|
|
4294
|
+
/**
|
|
4295
|
+
* Which pack actions code in the sandbox may call (`POST /v1/actions/call`) and which it gets as tools over MCP
|
|
4296
|
+
* (`POST /v1/actions/mcp`, at `B3OS_MCP_URL`, which the node sets when `allow` names an entry and the grant
|
|
4297
|
+
* holds `actions:read`). Without it (the default, or `null`), the creating principal's rule: none for an API
|
|
4298
|
+
* key, so any action your scopes allow; a sandbox's own rule for the sandboxes it creates, which may only
|
|
4299
|
+
* narrow it (`403 forbidden`, `reason: scope_escalation`). A call outside the rule is refused with
|
|
4300
|
+
* `403 action_not_allowed` before anything is read, bound or billed. `b3os apply` and the GitHub App write one
|
|
4301
|
+
* entry per pack a service declares in `uses`, at the version `actions.packs` gives, so a service calls the
|
|
4302
|
+
* tools it declared and no other pack. A routine run the sandbox starts runs as its publisher within the rule
|
|
4303
|
+
* (a step outside it fails with `action_not_allowed`), and the sandbox signals or sends events only to runs
|
|
4304
|
+
* within its rule. Read routes (describe, the pack and tools routes) are not bounded.
|
|
4305
|
+
*/
|
|
4306
|
+
export type SandboxActionsRule = {
|
|
4307
|
+
/**
|
|
4308
|
+
* `<namespace>/<name>/<action>[@<version>]`: `<action>` an action key or `*` (every action of the pack),
|
|
4309
|
+
* `<version>` an exact version or a range (`1.0.1`, `1`, `1.2`, `^1.2`); without one, any version. A call
|
|
4310
|
+
* that names a range runs the newest allowed version it admits. Empty: no pack action at all.
|
|
4311
|
+
*/
|
|
4312
|
+
allow: string[];
|
|
4313
|
+
} | null;
|
|
4314
|
+
|
|
3579
4315
|
/**
|
|
3580
4316
|
* Where sandbox traffic may go, enforced by the node's egress guard. `public` (default): any public internet
|
|
3581
4317
|
* address. `allowlist`: only hosts matching `allow` (exact hosts or `*.` wildcards). `deny`: no outbound
|
|
@@ -3595,14 +4331,21 @@ export interface EgressPolicy {
|
|
|
3595
4331
|
|
|
3596
4332
|
export interface SandboxCreateRequest {
|
|
3597
4333
|
/**
|
|
3598
|
-
* Template name or `tpl_` ID
|
|
4334
|
+
* Template name or `tpl_` ID: a node template (`GET /v1/sandboxes/templates`) or one of your project's
|
|
4335
|
+
* image templates (an image's `template`). Ignored when `snapshot` is set.
|
|
3599
4336
|
* @default "base"
|
|
3600
4337
|
*/
|
|
3601
4338
|
template?: string;
|
|
3602
4339
|
/** Restore this snapshot instead of starting from a template. */
|
|
3603
4340
|
snapshot?: string;
|
|
4341
|
+
/**
|
|
4342
|
+
* Start from one of your project's imported images (`POST /v1/images`), once it is `ready`. Needs the
|
|
4343
|
+
* `images.import` flag on for your organization. Not with `template` or `snapshot` (`400 invalid_request`).
|
|
4344
|
+
*/
|
|
4345
|
+
image?: string;
|
|
3604
4346
|
/**
|
|
3605
4347
|
* Virtual CPUs; defaults to the template's (`defaults.vcpu`), at most your plan's `sandboxes.vcpu_max`.
|
|
4348
|
+
* A sandbox from an image has the image's size: any other value answers `400 invalid_request`.
|
|
3606
4349
|
* A microVM cannot change its vCPU count, so sandboxes come from pools per size: a create at one of the
|
|
3607
4350
|
* template's `size_classes` claims a pre-warmed microVM, any other size is restored on demand (a pool
|
|
3608
4351
|
* miss: tens of milliseconds, plus about two seconds the first time a node sees that size). A node
|
|
@@ -3674,21 +4417,131 @@ export interface SandboxCreateRequest {
|
|
|
3674
4417
|
* `X-B3OS-Options` header.
|
|
3675
4418
|
*/
|
|
3676
4419
|
clone_reset?: "full" | "none";
|
|
4420
|
+
/**
|
|
4421
|
+
* A volume to mount (`POST /v1/sandboxes/volumes`), held by this sandbox alone until it ends: at most one in
|
|
4422
|
+
* this beta (mount several of its folders with `subpath`). A volume another running or paused sandbox
|
|
4423
|
+
* holds is `409 volume_in_use`. The sandbox cannot be snapshotted or forked (`409 volume_attached`), and
|
|
4424
|
+
* `forkable: true` is refused. When the sandbox ends, its guest syncs and unmounts the volume first; the
|
|
4425
|
+
* volume is free for the next sandbox once the microVM has exited.
|
|
4426
|
+
*/
|
|
4427
|
+
volumes?: VolumeAttach[];
|
|
4428
|
+
owner?: SandboxOwner;
|
|
3677
4429
|
metadata?: Metadata;
|
|
3678
4430
|
}
|
|
3679
4431
|
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
4432
|
+
export interface VolumeAttach {
|
|
4433
|
+
/** The volume's `vol_` ID or name. */
|
|
4434
|
+
volume: string;
|
|
4435
|
+
mounts: VolumeMount[];
|
|
4436
|
+
/**
|
|
4437
|
+
* `uid` or `uid:gid` that owns the volume's root and each subpath folder when they are first made; default,
|
|
4438
|
+
* the account commands run as (`user`, uid 1000, or an image's `USER`). Later mounts change no owner.
|
|
4439
|
+
*/
|
|
4440
|
+
owner?: string;
|
|
4441
|
+
}
|
|
4442
|
+
|
|
4443
|
+
export interface VolumeMount {
|
|
4444
|
+
/**
|
|
4445
|
+
* Where the folder appears in the sandbox: absolute, not `/`, not a system folder or under one (`/proc`,
|
|
4446
|
+
* `/sys`, `/dev`, `/run`, `/etc`, `/usr`, `/boot`, `/bin`, `/sbin`, `/lib*`, `/mnt`, `/var/run`); mount under
|
|
4447
|
+
* `/workspace`, `/data`, `/home`, `/srv`, `/opt` or `/var/lib`. Two mounts of a sandbox never overlap.
|
|
4448
|
+
*/
|
|
4449
|
+
path: string;
|
|
4450
|
+
/** A folder of the volume (made on first use); empty or absent for the volume's root. */
|
|
4451
|
+
subpath?: string;
|
|
4452
|
+
/** @default false */
|
|
4453
|
+
read_only?: boolean;
|
|
4454
|
+
}
|
|
4455
|
+
|
|
4456
|
+
export interface SandboxVolume {
|
|
4457
|
+
volume_id: string;
|
|
4458
|
+
name: string;
|
|
4459
|
+
mounts: VolumeMount[];
|
|
4460
|
+
owner?: string | null;
|
|
4461
|
+
}
|
|
4462
|
+
|
|
4463
|
+
export interface Volume {
|
|
4464
|
+
id: string;
|
|
4465
|
+
object: "volume";
|
|
4466
|
+
name: string;
|
|
4467
|
+
size_gib: number;
|
|
4468
|
+
/**
|
|
4469
|
+
* `attached` from the create of the sandbox that holds it until that sandbox's microVM has exited; `deleted` until `purge_at`.
|
|
4470
|
+
*/
|
|
4471
|
+
status: "available" | "attached" | "deleted";
|
|
4472
|
+
attached_to: null | {
|
|
4473
|
+
sandbox_id: string;
|
|
4474
|
+
since: string;
|
|
4475
|
+
};
|
|
4476
|
+
/** What the volume's file system held at its last mount or stats read; null before its first mount. */
|
|
4477
|
+
used_bytes: number | null;
|
|
4478
|
+
metadata: Metadata;
|
|
4479
|
+
created_at: string;
|
|
4480
|
+
deleted_at: string | null;
|
|
4481
|
+
/** When a deleted volume and its data are removed for good. */
|
|
4482
|
+
purge_at: string | null;
|
|
4483
|
+
}
|
|
4484
|
+
|
|
4485
|
+
export type VolumeList = Omit<ListEnvelope, "data"> & {
|
|
4486
|
+
data: Volume[];
|
|
4487
|
+
};
|
|
4488
|
+
|
|
4489
|
+
export interface VolumeCreateRequest {
|
|
4490
|
+
/** Unique among the project's volumes, deleted ones included until they are purged. */
|
|
4491
|
+
name: string;
|
|
4492
|
+
/** At most your plan's `sandboxes.volume_max`. */
|
|
4493
|
+
size_gib: number;
|
|
4494
|
+
metadata?: Metadata;
|
|
4495
|
+
}
|
|
4496
|
+
|
|
4497
|
+
export interface VolumeUpdateRequest {
|
|
4498
|
+
/** A larger size; a volume never shrinks. */
|
|
4499
|
+
size_gib?: number;
|
|
4500
|
+
metadata?: Metadata;
|
|
4501
|
+
}
|
|
4502
|
+
|
|
4503
|
+
export interface VolumePurgeRequest {
|
|
4504
|
+
/** The volume's name. */
|
|
4505
|
+
confirm: string;
|
|
4506
|
+
}
|
|
4507
|
+
|
|
4508
|
+
/**
|
|
4509
|
+
* Who the sandbox belongs to, which decides what its key can do to it.
|
|
4510
|
+
*
|
|
4511
|
+
* - `key` (the default): the sandbox acts as the key that created it. It stops when that key is revoked or
|
|
4512
|
+
* expires (`stop_reason: revoked`), and its B3OS calls count toward the key's spend cap: an agent's sandbox
|
|
4513
|
+
* lives no longer than the credential that made it.
|
|
4514
|
+
* - `project`: a service of an application. It acts as its project, within its `api` grant (scopes and
|
|
4515
|
+
* connections), and holds no key: a key's expiry or revoke never stops it. The key that created it is kept as
|
|
4516
|
+
* `created_by_key`. Its spend cap: with `api.spend_cap_usd`, that cap, its own; without one, the creating
|
|
4517
|
+
* key's cap, shared with everything else that key runs: its usage counts toward that key's `spent_usd`, and
|
|
4518
|
+
* the key's cap stops it (`stop_reason: budget`), also after the key is revoked or expires. Both caps count
|
|
4519
|
+
* the whole billing period and survive restarts of the node. What else stops it: its organization suspended or
|
|
4520
|
+
* out of credits (`budget`), a delete or a take down (`deleted`), and B3. Needs `metadata."b3os.app"` (`400
|
|
4521
|
+
* invalid_request` otherwise), so it is listed under its application with a Take down, and an outside caller
|
|
4522
|
+
* (an API key, a CLI token, the console): a sandbox's own credential gets `403 forbidden` with `reason:
|
|
4523
|
+
* sandbox`, a routine run `reason: routine`. `b3os apply` (CLI 0.2.2) and the GitHub App create services this
|
|
4524
|
+
* way. A fork of it belongs to the key that forks it.
|
|
4525
|
+
*
|
|
4526
|
+
* What a service's own code starts (a create or a fork with the service's credential) is the service's:
|
|
4527
|
+
* `owner: project`, `parent` its creator and `root` the service. It holds no key either, and it ends when
|
|
4528
|
+
* the service ends (`stop_reason: revoked`), however long its own timeout or lease, so a take down reaches
|
|
4529
|
+
* everything a service started.
|
|
4530
|
+
*/
|
|
4531
|
+
export type SandboxOwner = "key" | "project";
|
|
4532
|
+
|
|
4533
|
+
/**
|
|
4534
|
+
* When the sandbox counts as ready: a TCP port inside it accepting connections (`port`), or a command that
|
|
4535
|
+
* exits 0 (`cmd`, run as `user` with a 5 s limit per try). Set exactly one. The node tries it every
|
|
4536
|
+
* `interval_ms` from the moment it is set until it passes or `timeout_s` runs out; the sandbox's `readiness`
|
|
4537
|
+
* reports the result and `POST /v1/sandboxes/{sandbox_id}/ready` waits for it. Probing goes on across a
|
|
4538
|
+
* restart of the node's daemon, within the same `timeout_s`; `attempts` counts the tries since the daemon
|
|
4539
|
+
* last recorded a change of `status`, so it can start again from a lower number after such a restart.
|
|
4540
|
+
*/
|
|
4541
|
+
export interface ReadinessProbe {
|
|
4542
|
+
port?: number;
|
|
4543
|
+
/** A shell command line (run with `/bin/sh -c`) or an argv array. */
|
|
4544
|
+
cmd?: string | string[];
|
|
3692
4545
|
/** @default 10 */
|
|
3693
4546
|
interval_ms?: number;
|
|
3694
4547
|
/** @default 60 */
|
|
@@ -3775,6 +4628,14 @@ export interface Sandbox {
|
|
|
3775
4628
|
/** The grant's own cap, or `null` when the creating principal's cap applies. */
|
|
3776
4629
|
spend_cap_usd: number | null;
|
|
3777
4630
|
connections: string[];
|
|
4631
|
+
/**
|
|
4632
|
+
* The actions rule the sandbox holds (the grant's, or the one it inherited from the sandbox that created
|
|
4633
|
+
* it), or `null` when it holds none; a node before release 1118 leaves the member out. Its packs are the
|
|
4634
|
+
* sandbox's tools at `B3OS_MCP_URL`.
|
|
4635
|
+
*/
|
|
4636
|
+
actions?: {
|
|
4637
|
+
allow: string[];
|
|
4638
|
+
} | null;
|
|
3778
4639
|
};
|
|
3779
4640
|
egress: {
|
|
3780
4641
|
mode: "public" | "allowlist" | "deny";
|
|
@@ -3789,7 +4650,9 @@ export interface Sandbox {
|
|
|
3789
4650
|
* Why the sandbox stopped: `deleted`, `timeout` (it reached `expires_at`), `failed` (the microVM crashed),
|
|
3790
4651
|
* `budget` (while it ran, its organization was suspended or ran out of credits, or the creating key or
|
|
3791
4652
|
* the sandbox's own `api.spend_cap_usd` reached its cap; the node checks every 10 s) or `revoked` (the key
|
|
3792
|
-
* that created it was revoked
|
|
4653
|
+
* that created it was revoked or expired, or, for a sandbox a service started, the service at its `root`
|
|
4654
|
+
* ended). A project's service never stops for its key's revoke or expiry; for the key's spend cap only when
|
|
4655
|
+
* its grant sets no cap of its own.
|
|
3793
4656
|
*/
|
|
3794
4657
|
stop_reason: "deleted" | "timeout" | "failed" | "budget" | "revoked" | null;
|
|
3795
4658
|
usage: {
|
|
@@ -3804,7 +4667,33 @@ export interface Sandbox {
|
|
|
3804
4667
|
};
|
|
3805
4668
|
/** The readiness probe and what it found; `null` when the sandbox has none. */
|
|
3806
4669
|
readiness?: null | Readiness;
|
|
4670
|
+
/**
|
|
4671
|
+
* The sandbox's lease (`PUT /v1/sandboxes/{sandbox_id}/lease`): while `held`, the node keeps the sandbox
|
|
4672
|
+
* running and renews its `expires_at` itself. `null` when it never held one. Always sent by this node.
|
|
4673
|
+
*/
|
|
4674
|
+
lease?: null | SandboxLease;
|
|
4675
|
+
/**
|
|
4676
|
+
* The processes the node supervises (an exec with `background: true` and `restart`), oldest first; empty
|
|
4677
|
+
* when there are none. Always sent by this node.
|
|
4678
|
+
*/
|
|
4679
|
+
supervised?: SupervisedProcess[];
|
|
4680
|
+
/** The volume the sandbox holds and where it is mounted; empty when none. Always sent by this node. */
|
|
4681
|
+
volumes?: SandboxVolume[];
|
|
3807
4682
|
options: SandboxOptions;
|
|
4683
|
+
owner?: SandboxOwner;
|
|
4684
|
+
/**
|
|
4685
|
+
* The key that created the sandbox, whoever owns it; `null` when the creator held none: the GitHub App, or
|
|
4686
|
+
* a service's own credential (then `root` names the service).
|
|
4687
|
+
*/
|
|
4688
|
+
created_by_key?: string | null;
|
|
4689
|
+
/** The sandbox whose own credential created this one; `null` when an outside caller did. */
|
|
4690
|
+
parent?: string | null;
|
|
4691
|
+
/**
|
|
4692
|
+
* The project's service this sandbox was started from, directly or through other sandboxes it started
|
|
4693
|
+
* (`owner: project`). This sandbox ends when that service ends. `null` for a service and for a sandbox no
|
|
4694
|
+
* service started.
|
|
4695
|
+
*/
|
|
4696
|
+
root?: string | null;
|
|
3808
4697
|
timing?: Timing;
|
|
3809
4698
|
metadata: Metadata;
|
|
3810
4699
|
}
|
|
@@ -3825,6 +4714,68 @@ export type SandboxList = Omit<ListEnvelope, "data"> & {
|
|
|
3825
4714
|
data: Sandbox[];
|
|
3826
4715
|
};
|
|
3827
4716
|
|
|
4717
|
+
export interface LeaseRequest {
|
|
4718
|
+
/**
|
|
4719
|
+
* 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:
|
|
4720
|
+
* holding it here takes it from the sandbox that held it.
|
|
4721
|
+
*/
|
|
4722
|
+
key: string;
|
|
4723
|
+
/**
|
|
4724
|
+
* A precondition: the sandbox you read holding `key` (its ID), or `null` when you read none holding it. The
|
|
4725
|
+
* key is taken only while that is still so; otherwise `409 lease_holder_changed` names the sandbox that holds
|
|
4726
|
+
* it now (`holder`) and nothing changes. Left out, the key is taken from whichever sandbox holds it. A sandbox
|
|
4727
|
+
* that already holds `key` answers 200 whatever this says.
|
|
4728
|
+
*/
|
|
4729
|
+
expect_holder?: string | null;
|
|
4730
|
+
}
|
|
4731
|
+
|
|
4732
|
+
/** A sandbox's lease, held or ended. */
|
|
4733
|
+
export interface SandboxLease {
|
|
4734
|
+
key: string;
|
|
4735
|
+
state: "held" | "ended";
|
|
4736
|
+
/** When the sandbox took the lease. */
|
|
4737
|
+
since: string;
|
|
4738
|
+
/** When the node last moved `expires_at` for it; `null` before the first renewal. */
|
|
4739
|
+
renewed_at: string | null;
|
|
4740
|
+
ended_at: string | null;
|
|
4741
|
+
/**
|
|
4742
|
+
* Why it ended: `released` (`DELETE …/lease`), `replaced` (another sandbox of the project took its key; this
|
|
4743
|
+
* one then stops within `sandboxes.lease_term`), or the sandbox's `stop_reason`.
|
|
4744
|
+
*/
|
|
4745
|
+
end_reason: "released" | "replaced" | "deleted" | "timeout" | "failed" | "budget" | "revoked" | null;
|
|
4746
|
+
}
|
|
4747
|
+
|
|
4748
|
+
/** A background process the node starts again when it exits (an exec with `restart`). */
|
|
4749
|
+
export interface SupervisedProcess {
|
|
4750
|
+
/** The process running now, or the last one while it waits to start again; `null` if none started. */
|
|
4751
|
+
pid: number | null;
|
|
4752
|
+
/** The command as started (argv arrays are joined with spaces). */
|
|
4753
|
+
cmd: string;
|
|
4754
|
+
restart: "on-failure" | "always";
|
|
4755
|
+
/**
|
|
4756
|
+
* `starting`: started again, and the sandbox's readiness probe has not passed since. `running`: it runs
|
|
4757
|
+
* (and is ready, when the sandbox has a probe). `backoff`: it exited and starts again at `next_start_at`.
|
|
4758
|
+
* `crash_loop`: 5 exits within 300 s; restarts go on, at most 60 s apart, and it reads `crash_loop`, running
|
|
4759
|
+
* or waiting, until one run lasts 60 s. `exited`: it exited and
|
|
4760
|
+
* its policy keeps it down (`on-failure` after exit code 0). `stopped`: stopped through
|
|
4761
|
+
* `POST …/processes/{pid}/kill`, or the sandbox stopped.
|
|
4762
|
+
*/
|
|
4763
|
+
state: "starting" | "running" | "backoff" | "crash_loop" | "exited" | "stopped";
|
|
4764
|
+
/** How many times the node started it again. */
|
|
4765
|
+
restarts: number;
|
|
4766
|
+
/** When the current process started. */
|
|
4767
|
+
started_at: string | null;
|
|
4768
|
+
/** How the last process ended; `null` before any exit. */
|
|
4769
|
+
last_exit: null | {
|
|
4770
|
+
pid: number | null;
|
|
4771
|
+
exit_code: number | null;
|
|
4772
|
+
signal: string | null;
|
|
4773
|
+
at: string;
|
|
4774
|
+
};
|
|
4775
|
+
/** When it starts again, in `backoff` and `crash_loop`; `null` otherwise. */
|
|
4776
|
+
next_start_at: string | null;
|
|
4777
|
+
}
|
|
4778
|
+
|
|
3828
4779
|
export interface TimeoutRequest {
|
|
3829
4780
|
timeout_s: number;
|
|
3830
4781
|
}
|
|
@@ -3878,6 +4829,13 @@ export interface ExecRequest {
|
|
|
3878
4829
|
background?: boolean;
|
|
3879
4830
|
/** @default "user" */
|
|
3880
4831
|
user?: "user" | "root";
|
|
4832
|
+
/**
|
|
4833
|
+
* With `background: true` only: the node starts the command again in this sandbox when it exits.
|
|
4834
|
+
* `on-failure` after a non-zero exit code or a signal, `always` after any exit. Waits between restarts in
|
|
4835
|
+
* 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
|
|
4836
|
+
* `crash_loop`. At most 8 per sandbox. Left out, the process is not supervised.
|
|
4837
|
+
*/
|
|
4838
|
+
restart?: "on-failure" | "always";
|
|
3881
4839
|
}
|
|
3882
4840
|
|
|
3883
4841
|
export interface ExecResult {
|
|
@@ -3918,6 +4876,13 @@ export interface SandboxProcess {
|
|
|
3918
4876
|
signal?: string | null;
|
|
3919
4877
|
started_at: string;
|
|
3920
4878
|
exited_at: string | null;
|
|
4879
|
+
/**
|
|
4880
|
+
* The node supervises this process now (it is the current process of an entry in the sandbox's
|
|
4881
|
+
* `supervised`). Always sent by this node.
|
|
4882
|
+
*/
|
|
4883
|
+
supervised?: boolean;
|
|
4884
|
+
/** The process this one replaced when the node started the command again; `null` otherwise. */
|
|
4885
|
+
restart_of?: number | null;
|
|
3921
4886
|
}
|
|
3922
4887
|
|
|
3923
4888
|
/** What a running sandbox uses now (`GET /v1/sandboxes/{sandbox_id}/stats`). */
|
|
@@ -3957,6 +4922,14 @@ export interface SandboxStats {
|
|
|
3957
4922
|
*/
|
|
3958
4923
|
total: number | null;
|
|
3959
4924
|
};
|
|
4925
|
+
/**
|
|
4926
|
+
* The mounted volume's size and use (its guest name is its host ID); present only when the sandbox holds one.
|
|
4927
|
+
*/
|
|
4928
|
+
volumes?: {
|
|
4929
|
+
name: string;
|
|
4930
|
+
used_bytes: number;
|
|
4931
|
+
total_bytes: number;
|
|
4932
|
+
}[];
|
|
3960
4933
|
}
|
|
3961
4934
|
|
|
3962
4935
|
export type SandboxProcessList = Omit<ListEnvelope, "data"> & {
|
|
@@ -3966,6 +4939,15 @@ export type SandboxProcessList = Omit<ListEnvelope, "data"> & {
|
|
|
3966
4939
|
export interface KillRequest {
|
|
3967
4940
|
/** @default "TERM" */
|
|
3968
4941
|
signal?: "TERM" | "KILL" | "INT" | "HUP";
|
|
4942
|
+
/**
|
|
4943
|
+
* On a supervised process: keep the supervision, so the node starts the command again once the signal
|
|
4944
|
+
* ends it (counted as a restart). Without it the supervision ends first and the process stays down.
|
|
4945
|
+
* Ignored on a process the node does not supervise. A process still running 10 s after the signal ignored
|
|
4946
|
+
* it: the request lapses (the node logs it), and the process's next exit counts as a crash. Send `KILL` to
|
|
4947
|
+
* restart one that ignores `TERM`.
|
|
4948
|
+
* @default false
|
|
4949
|
+
*/
|
|
4950
|
+
restart?: boolean;
|
|
3969
4951
|
}
|
|
3970
4952
|
|
|
3971
4953
|
/**
|
|
@@ -4114,29 +5096,642 @@ export interface Template {
|
|
|
4114
5096
|
os: string;
|
|
4115
5097
|
runtimes: string[];
|
|
4116
5098
|
/**
|
|
4117
|
-
* `cdp`: Chrome runs in the template's snapshot with DevTools on `127.0.0.1:9222` inside the sandbox; declare
|
|
4118
|
-
* port 9222 to reach it through a port preview.
|
|
5099
|
+
* `cdp`: Chrome runs in the template's snapshot with DevTools on `127.0.0.1:9222` inside the sandbox; declare
|
|
5100
|
+
* port 9222 to reach it through a port preview.
|
|
5101
|
+
*/
|
|
5102
|
+
capabilities: Array<"exec" | "files" | "pty" | "run_code" | "cdp">;
|
|
5103
|
+
defaults: {
|
|
5104
|
+
vcpu: number;
|
|
5105
|
+
memory_mib: number;
|
|
5106
|
+
disk_gib: number;
|
|
5107
|
+
};
|
|
5108
|
+
/**
|
|
5109
|
+
* The sizes this node keeps pre-warmed microVMs of: the template's default size first, then at most one
|
|
5110
|
+
* larger class. A create at one of them claims a parked microVM; any other size (within your plan) is
|
|
5111
|
+
* restored on demand, a pool miss.
|
|
5112
|
+
*/
|
|
5113
|
+
size_classes: {
|
|
5114
|
+
vcpu: number;
|
|
5115
|
+
memory_mib: number;
|
|
5116
|
+
}[];
|
|
5117
|
+
/**
|
|
5118
|
+
* `node`: one of the node's templates, the same for everyone. `project`: an imported image's template,
|
|
5119
|
+
* which only its project sees and can start sandboxes from. An image template's `name` is its `tpl_` ID and
|
|
5120
|
+
* it has one size (`size_classes` holds only the image's).
|
|
5121
|
+
*/
|
|
5122
|
+
owner: "node" | "project";
|
|
5123
|
+
/** The image this template was imported from (`owner: project`); `null` for node templates. */
|
|
5124
|
+
image: string | null;
|
|
5125
|
+
created_at: string;
|
|
5126
|
+
/**
|
|
5127
|
+
* The sha256 of the guest agent in the template's image. A node's agent update changes it while
|
|
5128
|
+
* `created_at` stays, so a deployment's build key takes it: each application builds again once at its first
|
|
5129
|
+
* deploy after an agent update. Absent from a template whose image records no agent.
|
|
5130
|
+
*/
|
|
5131
|
+
agent_sha256?: string;
|
|
5132
|
+
}
|
|
5133
|
+
|
|
5134
|
+
export type TemplateList = Omit<ListEnvelope, "data"> & {
|
|
5135
|
+
data: Template[];
|
|
5136
|
+
};
|
|
5137
|
+
|
|
5138
|
+
/**
|
|
5139
|
+
* 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).
|
|
5140
|
+
*/
|
|
5141
|
+
export interface SwarmChildSpec {
|
|
5142
|
+
/** A shell command line (run with `/bin/sh -c`) or an argv array, as for exec. */
|
|
5143
|
+
cmd?: string | string[];
|
|
5144
|
+
/**
|
|
5145
|
+
* Extra environment variables for this child's command, on top of the checkpoint's. Kept with the swarm's record; never put secrets here.
|
|
5146
|
+
*/
|
|
5147
|
+
env?: Record<string, string>;
|
|
5148
|
+
/** @default "/workspace" */
|
|
5149
|
+
cwd?: string;
|
|
5150
|
+
/** Written to the command's standard input, which is then closed. */
|
|
5151
|
+
stdin?: string;
|
|
5152
|
+
/** @default "user" */
|
|
5153
|
+
user?: "user" | "root";
|
|
5154
|
+
/**
|
|
5155
|
+
* Kill the command after this long; the child then ends `timed_out`.
|
|
5156
|
+
* @default 300000
|
|
5157
|
+
*/
|
|
5158
|
+
timeout_ms?: number;
|
|
5159
|
+
metadata?: Metadata;
|
|
5160
|
+
}
|
|
5161
|
+
|
|
5162
|
+
/** The checkpoint every child starts from. Exactly one of `sandbox` and `snapshot`. */
|
|
5163
|
+
export interface SwarmSource {
|
|
5164
|
+
/** A forkable sandbox, running or paused. A paused one is resumed for the fork and paused again. */
|
|
5165
|
+
sandbox?: string;
|
|
5166
|
+
/** A snapshot of this project; every child is restored from it. */
|
|
5167
|
+
snapshot?: string;
|
|
5168
|
+
}
|
|
5169
|
+
|
|
5170
|
+
/**
|
|
5171
|
+
* Give either `children` or `count` (with `defaults`), not both. Every child needs a `cmd`, its own or the defaults'.
|
|
5172
|
+
*/
|
|
5173
|
+
export interface SwarmCreateRequest {
|
|
5174
|
+
from: SwarmSource;
|
|
5175
|
+
/** The children, in index order (`sandboxes.swarm_children_max`). */
|
|
5176
|
+
children?: SwarmChildSpec[];
|
|
5177
|
+
/** This many children, each running `defaults`. */
|
|
5178
|
+
count?: number;
|
|
5179
|
+
defaults?: SwarmChildSpec;
|
|
5180
|
+
/**
|
|
5181
|
+
* `first_success`: once a child exits 0, kill the other children's commands and end the swarm.
|
|
5182
|
+
* @default "all"
|
|
5183
|
+
*/
|
|
5184
|
+
stop_when?: "all" | "first_success";
|
|
5185
|
+
/**
|
|
5186
|
+
* Which children stay running after their command ends; the rest are deleted.
|
|
5187
|
+
* @default "none"
|
|
5188
|
+
*/
|
|
5189
|
+
keep?: "none" | "succeeded" | "all";
|
|
5190
|
+
/**
|
|
5191
|
+
* Add `child.stdout` and `child.stderr` events to the swarm's stream (each stream up to `output_max_bytes`).
|
|
5192
|
+
* @default false
|
|
5193
|
+
*/
|
|
5194
|
+
stream_output?: boolean;
|
|
5195
|
+
/**
|
|
5196
|
+
* 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.
|
|
5197
|
+
* @default 65536
|
|
5198
|
+
*/
|
|
5199
|
+
output_max_bytes?: number;
|
|
5200
|
+
/** As for a fork (`ForkRequest.clone_reset`), for every child. */
|
|
5201
|
+
clone_reset?: "full" | "none";
|
|
5202
|
+
webhook?: WebhookConfig;
|
|
5203
|
+
metadata?: Metadata;
|
|
5204
|
+
}
|
|
5205
|
+
|
|
5206
|
+
/** One child of a swarm and what its command did. */
|
|
5207
|
+
export interface SwarmChild {
|
|
5208
|
+
/** The child's position in `children` (or 0 to `count` - 1); also its `B3OS_SWARM_INDEX`. */
|
|
5209
|
+
index: number;
|
|
5210
|
+
/** The child's sandbox; `null` until the fork made it. */
|
|
5211
|
+
sandbox_id: string | null;
|
|
5212
|
+
/**
|
|
5213
|
+
* `queued` until its sandbox exists, `running` while its command runs, then `exited` (any exit code),
|
|
5214
|
+
* `timed_out` (killed at `timeout_ms`), `failed` (the command could not start or the sandbox was lost;
|
|
5215
|
+
* see `error`) or `canceled` (the swarm stopped it).
|
|
5216
|
+
*/
|
|
5217
|
+
status: "queued" | "running" | "exited" | "timed_out" | "failed" | "canceled";
|
|
5218
|
+
/** The command's exit status; `null` until it exits, or when a signal ended it. */
|
|
5219
|
+
exit_code: number | null;
|
|
5220
|
+
/** The signal that ended the command, such as `KILL` after a timeout or a cancel. */
|
|
5221
|
+
signal: string | null;
|
|
5222
|
+
stdout: string;
|
|
5223
|
+
stderr: string;
|
|
5224
|
+
stdout_truncated: boolean;
|
|
5225
|
+
stderr_truncated: boolean;
|
|
5226
|
+
/** The child's sandbox was left running (`keep`); delete it when you are done with it. */
|
|
5227
|
+
kept: boolean;
|
|
5228
|
+
error?: Problem;
|
|
5229
|
+
metadata?: Metadata;
|
|
5230
|
+
/**
|
|
5231
|
+
* `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).
|
|
5232
|
+
*/
|
|
5233
|
+
timing: {
|
|
5234
|
+
start_ms?: number;
|
|
5235
|
+
run_ms?: number;
|
|
5236
|
+
total_ms: number;
|
|
5237
|
+
};
|
|
5238
|
+
}
|
|
5239
|
+
|
|
5240
|
+
/** A swarm (`swm_…`), one checkpoint forked into children that each ran a command. */
|
|
5241
|
+
export type Swarm = Omit<Job, "id" | "object" | "result" | "timing"> & {
|
|
5242
|
+
id: string;
|
|
5243
|
+
object: "swarm";
|
|
5244
|
+
from: SwarmSource;
|
|
5245
|
+
stop_when: "all" | "first_success";
|
|
5246
|
+
keep: "none" | "succeeded" | "all";
|
|
5247
|
+
/** Every child, by index. Left out of lists. */
|
|
5248
|
+
children?: SwarmChild[];
|
|
5249
|
+
/** How the children ended. Present once the swarm ended, and on a canceled swarm. */
|
|
5250
|
+
result?: {
|
|
5251
|
+
exit_zero: number;
|
|
5252
|
+
exit_nonzero: number;
|
|
5253
|
+
timed_out: number;
|
|
5254
|
+
failed: number;
|
|
5255
|
+
canceled: number;
|
|
5256
|
+
/** With `stop_when: first_success`, the index of the child that exited 0 first; else `null`. */
|
|
5257
|
+
winner: number | null;
|
|
5258
|
+
};
|
|
5259
|
+
/**
|
|
5260
|
+
* `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.
|
|
5261
|
+
*/
|
|
5262
|
+
timing?: {
|
|
5263
|
+
fork_ms?: number;
|
|
5264
|
+
first_exit_ms?: number;
|
|
5265
|
+
last_exit_ms?: number;
|
|
5266
|
+
total_ms: number;
|
|
5267
|
+
};
|
|
5268
|
+
};
|
|
5269
|
+
|
|
5270
|
+
export type SwarmList = Omit<ListEnvelope, "data"> & {
|
|
5271
|
+
data: Swarm[];
|
|
5272
|
+
};
|
|
5273
|
+
|
|
5274
|
+
export type SwarmChildList = Omit<ListEnvelope, "data"> & {
|
|
5275
|
+
data: SwarmChild[];
|
|
5276
|
+
};
|
|
5277
|
+
|
|
5278
|
+
/**
|
|
5279
|
+
* An event of a swarm's stream. `swarm.forked` carries `children` (each `index` and `sandbox_id`) and the
|
|
5280
|
+
* fork's `timing`; `child.started`, `child.exited` and `child.failed` carry `index` and `sandbox_id`, and
|
|
5281
|
+
* `child.exited` also `exit_code`, `signal` and `timed_out`, `child.failed` an `error`; `child.stdout` and
|
|
5282
|
+
* `child.stderr` carry `index` and `data`.
|
|
5283
|
+
*/
|
|
5284
|
+
export type SwarmEvent = JobEvent & {
|
|
5285
|
+
index?: number;
|
|
5286
|
+
sandbox_id?: string;
|
|
5287
|
+
data?: string;
|
|
5288
|
+
exit_code?: number | null;
|
|
5289
|
+
signal?: string | null;
|
|
5290
|
+
timed_out?: boolean;
|
|
5291
|
+
error?: Problem;
|
|
5292
|
+
children?: {
|
|
5293
|
+
index: number;
|
|
5294
|
+
sandbox_id: string;
|
|
5295
|
+
}[];
|
|
5296
|
+
};
|
|
5297
|
+
|
|
5298
|
+
/**
|
|
5299
|
+
* `queued` (accepted, waiting for the queue), `pulling` (layers streaming into the unpacking microVM),
|
|
5300
|
+
* `flattening` (the last byte sent; waiting for the unpacker and the store), `warming` (the first boot, the
|
|
5301
|
+
* warm-up and the warm snapshot), `ready`. `rebuilding`: a node release changed the guest agent, kernel or
|
|
5302
|
+
* hypervisor, and the warm snapshot is being taken again (creates answer `409 image_not_ready` until it is
|
|
5303
|
+
* `ready`). `failed`: see `error`. `evicted`: the node's image cache was full and this image, unused, was
|
|
5304
|
+
* removed; import it again with the same request.
|
|
5305
|
+
*/
|
|
5306
|
+
export type ImageStatus =
|
|
5307
|
+
| "queued"
|
|
5308
|
+
| "pulling"
|
|
5309
|
+
| "flattening"
|
|
5310
|
+
| "warming"
|
|
5311
|
+
| "ready"
|
|
5312
|
+
| "rebuilding"
|
|
5313
|
+
| "failed"
|
|
5314
|
+
| "evicted";
|
|
5315
|
+
|
|
5316
|
+
export interface ImageWarmup {
|
|
5317
|
+
/**
|
|
5318
|
+
* Commands run once, in order, in the image's first boot before its warm snapshot is taken: each an
|
|
5319
|
+
* argument list, as root, in `WORKDIR` (else `/`), with the image's `ENV`, with no network, all of them
|
|
5320
|
+
* within 300 seconds. A command that exits non-zero fails the import (stage `golden`).
|
|
5321
|
+
*/
|
|
5322
|
+
commands: string[][];
|
|
5323
|
+
}
|
|
5324
|
+
|
|
5325
|
+
export interface ImageImportRequest {
|
|
5326
|
+
/**
|
|
5327
|
+
* An image reference: `[registry/]repository[:tag|@sha256:digest]`. Without a registry it is Docker Hub
|
|
5328
|
+
* (`python:3.11-slim` is `registry-1.docker.io/library/python:3.11-slim`); without a tag or digest it is
|
|
5329
|
+
* `latest`. A tag is resolved to its digest once, when the import is accepted; the image keeps that digest.
|
|
5330
|
+
* Public images only (no credentials).
|
|
5331
|
+
*/
|
|
5332
|
+
ref: string;
|
|
5333
|
+
warmup?: ImageWarmup;
|
|
5334
|
+
/** The size every sandbox from the image has. Default 1, at most your plan's `sandboxes.vcpu_max`. */
|
|
5335
|
+
vcpu?: number;
|
|
5336
|
+
/**
|
|
5337
|
+
* The memory every sandbox from the image has. Default 1024, at most your plan's `sandboxes.memory_max`.
|
|
5338
|
+
*/
|
|
5339
|
+
memory_mib?: number;
|
|
5340
|
+
}
|
|
5341
|
+
|
|
5342
|
+
/**
|
|
5343
|
+
* What the image's own configuration says, read when it was imported. `user`, `env` and `workdir` apply to every
|
|
5344
|
+
* command a sandbox from the image runs (`user` as in Docker: a name from the image's `/etc/passwd`, or
|
|
5345
|
+
* `uid[:gid]`; root when unset). `entrypoint`, `cmd`, `exposed_ports`, `volumes` and `healthcheck` are reported,
|
|
5346
|
+
* not run: a sandbox starts with no process of the image's own. Labels are shown, never acted on.
|
|
5347
|
+
*/
|
|
5348
|
+
export interface ImageConfig {
|
|
5349
|
+
entrypoint: string[] | null;
|
|
5350
|
+
cmd: string[] | null;
|
|
5351
|
+
env: Record<string, string>;
|
|
5352
|
+
workdir: string | null;
|
|
5353
|
+
user: string | null;
|
|
5354
|
+
exposed_ports: string[];
|
|
5355
|
+
volumes: string[];
|
|
5356
|
+
labels: Record<string, string>;
|
|
5357
|
+
/** Docker's `HEALTHCHECK`, when the image has one (a Docker extension, not part of OCI). */
|
|
5358
|
+
healthcheck: {
|
|
5359
|
+
test: string[];
|
|
5360
|
+
interval_ms: number | null;
|
|
5361
|
+
timeout_ms: number | null;
|
|
5362
|
+
start_period_ms: number | null;
|
|
5363
|
+
retries: number | null;
|
|
5364
|
+
} | null;
|
|
5365
|
+
}
|
|
5366
|
+
|
|
5367
|
+
export interface ImagePackage {
|
|
5368
|
+
name: string;
|
|
5369
|
+
version: string;
|
|
5370
|
+
}
|
|
5371
|
+
|
|
5372
|
+
/**
|
|
5373
|
+
* Milliseconds each finished stage took (`null` until it finishes): `resolve` (the reference to a digest,
|
|
5374
|
+
* before the answer), `queue` (waiting for a slot), `pull_flatten` (pulling and unpacking, which overlap),
|
|
5375
|
+
* `adopt` (checking and storing the file system), `golden` (the first boot, warm-up and warm snapshot), and
|
|
5376
|
+
* `total`.
|
|
5377
|
+
*/
|
|
5378
|
+
export interface ImageStagesMs {
|
|
5379
|
+
resolve: number | null;
|
|
5380
|
+
queue: number | null;
|
|
5381
|
+
pull_flatten: number | null;
|
|
5382
|
+
adopt: number | null;
|
|
5383
|
+
golden: number | null;
|
|
5384
|
+
total: number | null;
|
|
5385
|
+
}
|
|
5386
|
+
|
|
5387
|
+
export interface ImageError {
|
|
5388
|
+
/** `import_failed`. */
|
|
5389
|
+
code: string;
|
|
5390
|
+
stage: "resolve" | "pull" | "flatten" | "adopt" | "golden" | "rebuild" | "interrupted";
|
|
5391
|
+
detail: string;
|
|
5392
|
+
/** The last 4 KiB of the unpacker's or the warm-up's output, when there was any. */
|
|
5393
|
+
output: string | null;
|
|
5394
|
+
}
|
|
5395
|
+
|
|
5396
|
+
export interface Image {
|
|
5397
|
+
id: string;
|
|
5398
|
+
object: "image";
|
|
5399
|
+
/** The reference as given. */
|
|
5400
|
+
ref: string;
|
|
5401
|
+
/** The `linux/amd64` image manifest's digest. */
|
|
5402
|
+
digest: string;
|
|
5403
|
+
/** The index (multi-platform list) the manifest was picked from, when the reference named one. */
|
|
5404
|
+
index_digest: string | null;
|
|
5405
|
+
platform: "linux/amd64";
|
|
5406
|
+
status: ImageStatus;
|
|
5407
|
+
/**
|
|
5408
|
+
* The template sandboxes start from (`POST /v1/sandboxes {"template": "tpl_…"}`), set once the image has been ready.
|
|
5409
|
+
*/
|
|
5410
|
+
template: string | null;
|
|
5411
|
+
config: ImageConfig;
|
|
5412
|
+
/** The flattened read-only root file system, once stored. */
|
|
5413
|
+
rootfs: {
|
|
5414
|
+
sha256: string;
|
|
5415
|
+
bytes: number;
|
|
5416
|
+
} | null;
|
|
5417
|
+
warmup: ImageWarmup;
|
|
5418
|
+
size: {
|
|
5419
|
+
vcpu: number;
|
|
5420
|
+
memory_mib: number;
|
|
5421
|
+
};
|
|
5422
|
+
/** The import key (sha256); an import with the same key in this project returns this image. */
|
|
5423
|
+
key: string;
|
|
5424
|
+
stages_ms: ImageStagesMs;
|
|
5425
|
+
/** Compressed layer bytes pulled from the registry. */
|
|
5426
|
+
bytes_pulled: number;
|
|
5427
|
+
/**
|
|
5428
|
+
* Packages the unpacker found, best effort, at most 2,000 of each kind: Debian packages (`dpkg`), Python
|
|
5429
|
+
* distributions under `site-packages` (`pip`) and global `node_modules` (`npm`). `null` until the image is
|
|
5430
|
+
* flattened.
|
|
5431
|
+
*/
|
|
5432
|
+
packages: {
|
|
5433
|
+
dpkg: ImagePackage[];
|
|
5434
|
+
pip: ImagePackage[];
|
|
5435
|
+
npm: ImagePackage[];
|
|
5436
|
+
} | null;
|
|
5437
|
+
error: null | ImageError;
|
|
5438
|
+
created_at: string;
|
|
5439
|
+
ready_at: string | null;
|
|
5440
|
+
}
|
|
5441
|
+
|
|
5442
|
+
export type ImageList = Omit<ListEnvelope, "data"> & {
|
|
5443
|
+
data: Image[];
|
|
5444
|
+
};
|
|
5445
|
+
|
|
5446
|
+
/** An instance's key, stored and shown as written, so never a credential or a personal detail. */
|
|
5447
|
+
export type AgentInstanceKey = string;
|
|
5448
|
+
|
|
5449
|
+
/** Lowercase letters, digits and `-`, starting with a letter. `sessions` is reserved. */
|
|
5450
|
+
export type AgentName = string;
|
|
5451
|
+
|
|
5452
|
+
/**
|
|
5453
|
+
* What each instance starts from: a template (node templates, or one of your project's image templates) at a
|
|
5454
|
+
* size, or one of your project's snapshots. The size is fixed per agent, within `sandboxes.vcpu_max` and
|
|
5455
|
+
* `sandboxes.memory_max`.
|
|
5456
|
+
*/
|
|
5457
|
+
export interface AgentSource {
|
|
5458
|
+
/** @default "agent" */
|
|
5459
|
+
template?: string;
|
|
5460
|
+
/** Restore this snapshot instead of starting from a template. */
|
|
5461
|
+
snapshot?: string;
|
|
5462
|
+
vcpu?: number;
|
|
5463
|
+
memory_mib?: number;
|
|
5464
|
+
disk_gib?: number;
|
|
5465
|
+
}
|
|
5466
|
+
|
|
5467
|
+
/**
|
|
5468
|
+
* The harness. `command` runs in each instance when it is made, and again after a cold boot from its disk. The
|
|
5469
|
+
* node delivers each message as a `POST` to `port` and `path`. The instance counts as made once `readiness`
|
|
5470
|
+
* passes (by default, once `port` accepts connections). A harness that exits is started again in place, at most
|
|
5471
|
+
* `max_restarts` times in a row; past that the instance is `failed`.
|
|
5472
|
+
*/
|
|
5473
|
+
export interface AgentEntry {
|
|
5474
|
+
command: string[];
|
|
5475
|
+
/** Not 53, 1080, 3128, 7700 or 15001, which the guest agent listens on. */
|
|
5476
|
+
port: number;
|
|
5477
|
+
/** @default "/" */
|
|
5478
|
+
path?: string;
|
|
5479
|
+
readiness?: ReadinessProbe;
|
|
5480
|
+
/** @default 5 */
|
|
5481
|
+
max_restarts?: number;
|
|
5482
|
+
}
|
|
5483
|
+
|
|
5484
|
+
/**
|
|
5485
|
+
* When an idle instance moves to each sleep tier. Quiet means no turn, no queued message, no open connection
|
|
5486
|
+
* through its ports, no exec, file or terminal call and no sandbox it started still running; its own outbound
|
|
5487
|
+
* traffic does not count. Every default was chosen for the beta, not measured.
|
|
5488
|
+
*/
|
|
5489
|
+
export interface AgentSleep {
|
|
5490
|
+
/**
|
|
5491
|
+
* Quiet this long, it pauses in memory.
|
|
5492
|
+
* @default 30
|
|
5493
|
+
*/
|
|
5494
|
+
ram_after_s?: number;
|
|
5495
|
+
/**
|
|
5496
|
+
* Paused this long, its memory goes to a snapshot on the node's disk and its memory is freed.
|
|
5497
|
+
* @default 600
|
|
5498
|
+
*/
|
|
5499
|
+
snapshot_after_s?: number;
|
|
5500
|
+
/**
|
|
5501
|
+
* How long a memory snapshot is kept. After it, the instance is `dormant`: only its disk is kept, and the
|
|
5502
|
+
* next message cold boots it from that disk and runs `entry.command` again.
|
|
5503
|
+
* @default 604800
|
|
5504
|
+
*/
|
|
5505
|
+
snapshot_keep_s?: number;
|
|
5506
|
+
}
|
|
5507
|
+
|
|
5508
|
+
/** How messages become turns. One turn runs at a time per instance. */
|
|
5509
|
+
export interface AgentTurns {
|
|
5510
|
+
/**
|
|
5511
|
+
* Messages that may wait for the current turn, at most `agents.queue_max`.
|
|
5512
|
+
* @default 16
|
|
5513
|
+
*/
|
|
5514
|
+
queue_max?: number;
|
|
5515
|
+
/**
|
|
5516
|
+
* How long a turn may take from its message's acceptance, queue time included.
|
|
5517
|
+
* @default 300
|
|
5518
|
+
*/
|
|
5519
|
+
timeout_s?: number;
|
|
5520
|
+
/**
|
|
5521
|
+
* Deliver a message again after the node restarted while the harness had it. Only for a harness that
|
|
5522
|
+
* ignores a session ID it has seen (`x-b3os-session`).
|
|
5523
|
+
* @default false
|
|
5524
|
+
*/
|
|
5525
|
+
redeliver?: boolean;
|
|
5526
|
+
}
|
|
5527
|
+
|
|
5528
|
+
export interface AgentCreateRequest {
|
|
5529
|
+
name: AgentName;
|
|
5530
|
+
source?: AgentSource;
|
|
5531
|
+
entry: AgentEntry;
|
|
5532
|
+
/** Environment variables of the harness. Returned as given; put credentials in `secrets`. */
|
|
5533
|
+
env?: Record<string, string>;
|
|
5534
|
+
/**
|
|
5535
|
+
* Environment variables never returned or logged, as a sandbox's `secrets`: code in the instance can read
|
|
5536
|
+
* them. A memory snapshot holds them, so the node keeps an instance's snapshots to itself: they are never
|
|
5537
|
+
* listed or restorable through the API.
|
|
5538
|
+
*/
|
|
5539
|
+
secrets?: Record<string, SecretValue>;
|
|
5540
|
+
api?: SandboxApiGrant;
|
|
5541
|
+
egress?: EgressPolicy;
|
|
5542
|
+
sleep?: AgentSleep;
|
|
5543
|
+
turns?: AgentTurns;
|
|
5544
|
+
metadata?: Metadata;
|
|
5545
|
+
}
|
|
5546
|
+
|
|
5547
|
+
export interface AgentUpdateRequest {
|
|
5548
|
+
source?: AgentSource;
|
|
5549
|
+
entry?: AgentEntry;
|
|
5550
|
+
env?: Record<string, string>;
|
|
5551
|
+
secrets?: Record<string, SecretValue>;
|
|
5552
|
+
api?: SandboxApiGrant;
|
|
5553
|
+
egress?: EgressPolicy;
|
|
5554
|
+
sleep?: AgentSleep;
|
|
5555
|
+
turns?: AgentTurns;
|
|
5556
|
+
/**
|
|
5557
|
+
* What happens to instances of earlier revisions: `new_instances` leaves them as they are; `on_wake` makes a
|
|
5558
|
+
* sleeping one again from this revision at its next wake, which ends its memory and disk.
|
|
5559
|
+
* @default "new_instances"
|
|
5560
|
+
*/
|
|
5561
|
+
upgrade?: "new_instances" | "on_wake";
|
|
5562
|
+
metadata?: Metadata;
|
|
5563
|
+
}
|
|
5564
|
+
|
|
5565
|
+
export interface Agent {
|
|
5566
|
+
id: string;
|
|
5567
|
+
object: "agent";
|
|
5568
|
+
name: AgentName;
|
|
5569
|
+
/** Grows by one with each update. Each instance keeps the revision it was made from. */
|
|
5570
|
+
revision: number;
|
|
5571
|
+
source: AgentSource;
|
|
5572
|
+
entry: AgentEntry;
|
|
5573
|
+
env: Record<string, string>;
|
|
5574
|
+
secret_names: string[];
|
|
5575
|
+
api: SandboxApiGrant;
|
|
5576
|
+
egress: EgressPolicy;
|
|
5577
|
+
sleep: AgentSleep;
|
|
5578
|
+
turns: AgentTurns;
|
|
5579
|
+
upgrade: "new_instances" | "on_wake";
|
|
5580
|
+
/** How many instances the agent has, in any state. */
|
|
5581
|
+
instances: number;
|
|
5582
|
+
created_at: string;
|
|
5583
|
+
updated_at: string;
|
|
5584
|
+
metadata: Metadata;
|
|
5585
|
+
}
|
|
5586
|
+
|
|
5587
|
+
export type AgentList = Omit<ListEnvelope, "data"> & {
|
|
5588
|
+
data: Agent[];
|
|
5589
|
+
};
|
|
5590
|
+
|
|
5591
|
+
/**
|
|
5592
|
+
* `creating` (its microVM starting and its harness passing readiness), `running`, `paused` (asleep in memory),
|
|
5593
|
+
* `hibernated` (asleep as a memory snapshot on disk), `dormant` (only its disk kept), `waking` (on its way back
|
|
5594
|
+
* to `running`) or `failed` (it recovers at its next message).
|
|
5595
|
+
*/
|
|
5596
|
+
export type AgentInstanceStatus = "creating" | "running" | "paused" | "hibernated" | "dormant" | "waking" | "failed";
|
|
5597
|
+
|
|
5598
|
+
export interface AgentInstancePutRequest {
|
|
5599
|
+
/**
|
|
5600
|
+
* Wake an existing sleeping instance too.
|
|
5601
|
+
* @default false
|
|
5602
|
+
*/
|
|
5603
|
+
wake?: boolean;
|
|
5604
|
+
/**
|
|
5605
|
+
* Delete an existing instance (memory, snapshot and disk) and make it again from the current revision.
|
|
5606
|
+
* @default false
|
|
5607
|
+
*/
|
|
5608
|
+
replace?: boolean;
|
|
5609
|
+
metadata?: Metadata;
|
|
5610
|
+
}
|
|
5611
|
+
|
|
5612
|
+
export interface AgentInstanceSleepRequest {
|
|
5613
|
+
/** @default "ram" */
|
|
5614
|
+
tier?: "ram" | "snapshot";
|
|
5615
|
+
}
|
|
5616
|
+
|
|
5617
|
+
export interface AgentInstance {
|
|
5618
|
+
id: string;
|
|
5619
|
+
object: "agent_instance";
|
|
5620
|
+
agent_id: string;
|
|
5621
|
+
key: AgentInstanceKey;
|
|
5622
|
+
revision: number;
|
|
5623
|
+
status: AgentInstanceStatus;
|
|
5624
|
+
/** The instance's microVM, the same through every sleep tier; `null` before it was first made. */
|
|
5625
|
+
sandbox_id: string | null;
|
|
5626
|
+
/** Host memory the instance holds now (0 when hibernated or dormant). */
|
|
5627
|
+
resident_mib: number;
|
|
5628
|
+
/**
|
|
5629
|
+
* 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.
|
|
5630
|
+
*/
|
|
5631
|
+
storage_bytes: number;
|
|
5632
|
+
/** Messages waiting for the current turn. */
|
|
5633
|
+
queued: number;
|
|
5634
|
+
last_message_at: string | null;
|
|
5635
|
+
/** When it last went to sleep; `null` while it runs. */
|
|
5636
|
+
slept_at: string | null;
|
|
5637
|
+
/** When its kept memory snapshot was written, if it has one. */
|
|
5638
|
+
snapshot_at: string | null;
|
|
5639
|
+
created_at: string;
|
|
5640
|
+
metadata: Metadata;
|
|
5641
|
+
}
|
|
5642
|
+
|
|
5643
|
+
export type AgentInstanceList = Omit<ListEnvelope, "data"> & {
|
|
5644
|
+
data: AgentInstance[];
|
|
5645
|
+
};
|
|
5646
|
+
|
|
5647
|
+
/**
|
|
5648
|
+
* How the instance was brought to the turn: `none` (it was running), `ram` (resumed from memory), `snapshot`
|
|
5649
|
+
* (restored from its memory snapshot), `disk` (cold booted from its disk, memory lost), `new` (made from the
|
|
5650
|
+
* agent). `null` until the session is delivered.
|
|
5651
|
+
*/
|
|
5652
|
+
export type AgentWokeFrom = "none" | "ram" | "snapshot" | "disk" | "new" | null;
|
|
5653
|
+
|
|
5654
|
+
export interface AgentInstanceEvent {
|
|
5655
|
+
object: "agent_instance_event";
|
|
5656
|
+
type:
|
|
5657
|
+
| "instance.created"
|
|
5658
|
+
| "instance.paused"
|
|
5659
|
+
| "instance.hibernated"
|
|
5660
|
+
| "instance.dormant"
|
|
5661
|
+
| "instance.woke"
|
|
5662
|
+
| "instance.failed"
|
|
5663
|
+
| "instance.recovered"
|
|
5664
|
+
| "instance.upgraded";
|
|
5665
|
+
ts: string;
|
|
5666
|
+
woke_from?: AgentWokeFrom;
|
|
5667
|
+
session_id?: string;
|
|
5668
|
+
detail?: string;
|
|
5669
|
+
}
|
|
5670
|
+
|
|
5671
|
+
export type AgentInstanceEventList = Omit<ListEnvelope, "data"> & {
|
|
5672
|
+
data: AgentInstanceEvent[];
|
|
5673
|
+
};
|
|
5674
|
+
|
|
5675
|
+
/**
|
|
5676
|
+
* Your message. Every member but the reserved ones (`type`, `conversation`, `subject`, `metadata`, `create`,
|
|
5677
|
+
* `webhook`) is yours, and reaches the harness as `message`, with `type`.
|
|
5678
|
+
*/
|
|
5679
|
+
export interface AgentMessageRequest {
|
|
5680
|
+
/**
|
|
5681
|
+
* What kind of message this is (a listener's actor sink sends `listener.event`).
|
|
5682
|
+
* @default "message"
|
|
4119
5683
|
*/
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
5684
|
+
type?: string;
|
|
5685
|
+
/** Your conversation or thread ID. Default, the `b3os.conversation` baggage. */
|
|
5686
|
+
conversation?: string;
|
|
5687
|
+
/** The end user the turn is for, an opaque ID, never an email. Default, the `b3os.subject` baggage. */
|
|
5688
|
+
subject?: string;
|
|
5689
|
+
metadata?: Metadata;
|
|
4126
5690
|
/**
|
|
4127
|
-
*
|
|
4128
|
-
*
|
|
4129
|
-
* restored on demand, a pool miss.
|
|
5691
|
+
* Make the instance if it does not exist. `false` answers `404 instance_not_found` instead.
|
|
5692
|
+
* @default true
|
|
4130
5693
|
*/
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
}[];
|
|
4135
|
-
created_at: string;
|
|
5694
|
+
create?: boolean;
|
|
5695
|
+
webhook?: WebhookConfig;
|
|
5696
|
+
[key: string]: unknown;
|
|
4136
5697
|
}
|
|
4137
5698
|
|
|
4138
|
-
|
|
4139
|
-
|
|
5699
|
+
/** Who sent the message, from its credential. */
|
|
5700
|
+
export interface AgentSessionInitiator {
|
|
5701
|
+
kind: "key" | "user" | "sandbox" | "instance" | "routine_run" | "listener";
|
|
5702
|
+
id: string;
|
|
5703
|
+
}
|
|
5704
|
+
|
|
5705
|
+
/** One turn (`ses_…`); `result` is the harness's answer. */
|
|
5706
|
+
export type AgentSession = Omit<Job, "id" | "object"> & {
|
|
5707
|
+
id: string;
|
|
5708
|
+
object: "agent_session";
|
|
5709
|
+
/** Where the turn is; `status` says how it ended. */
|
|
5710
|
+
phase: "queued" | "waking" | "delivered" | "ended";
|
|
5711
|
+
agent_id: string;
|
|
5712
|
+
instance_id: string;
|
|
5713
|
+
key: AgentInstanceKey;
|
|
5714
|
+
revision: number;
|
|
5715
|
+
type: string;
|
|
5716
|
+
conversation: string | null;
|
|
5717
|
+
subject: string | null;
|
|
5718
|
+
initiator: AgentSessionInitiator;
|
|
5719
|
+
woke_from: AgentWokeFrom;
|
|
5720
|
+
/** The instance had failed and recovered for this turn; `woke_from` says how. */
|
|
5721
|
+
recovered: boolean;
|
|
5722
|
+
trace_id: string;
|
|
5723
|
+
};
|
|
5724
|
+
|
|
5725
|
+
export type AgentSessionList = Omit<ListEnvelope, "data"> & {
|
|
5726
|
+
data: AgentSession[];
|
|
5727
|
+
};
|
|
5728
|
+
|
|
5729
|
+
/**
|
|
5730
|
+
* `session.waking` carries `woke_from`; `session.output` carries `data`, one event the harness streamed, as text.
|
|
5731
|
+
*/
|
|
5732
|
+
export type AgentSessionEvent = JobEvent & {
|
|
5733
|
+
woke_from?: AgentWokeFrom;
|
|
5734
|
+
data?: string;
|
|
4140
5735
|
};
|
|
4141
5736
|
|
|
4142
5737
|
/**
|
|
@@ -4178,7 +5773,7 @@ export interface RoutineDefinition {
|
|
|
4178
5773
|
*/
|
|
4179
5774
|
durability?: "ephemeral" | "standard" | "strict";
|
|
4180
5775
|
/**
|
|
4181
|
-
* Default timeout for uses and map steps that do not set timeout_ms. Wait and sleep steps are not affected. A
|
|
5776
|
+
* 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.
|
|
4182
5777
|
* @default 30000
|
|
4183
5778
|
*/
|
|
4184
5779
|
timeout_ms?: number;
|
|
@@ -4717,136 +6312,682 @@ export interface RunCreateRequest {
|
|
|
4717
6312
|
|
|
4718
6313
|
export interface RunReplayRequest {
|
|
4719
6314
|
/**
|
|
4720
|
-
* Run this top-level step and every step downstream of it again. Absent: only the steps that did not succeed, and those downstream of them, run again.
|
|
6315
|
+
* Run this top-level step and every step downstream of it again. Absent: only the steps that did not succeed, and those downstream of them, run again.
|
|
6316
|
+
*/
|
|
6317
|
+
from_step?: string;
|
|
6318
|
+
/**
|
|
6319
|
+
* The new run's input instead of the source run's; validated against the version's `inputs`. When it differs from the source's, the steps that read it (directly or through `env`) and the steps that wait for a signal run again, with every step downstream of them.
|
|
6320
|
+
*/
|
|
6321
|
+
input?: Record<string, unknown>;
|
|
6322
|
+
/**
|
|
6323
|
+
* Replay with this version instead of the source run's (`ver_` ID or number). The steps it adds or changes and the steps that wait for a signal run again, with every step downstream of them.
|
|
6324
|
+
*/
|
|
6325
|
+
version?: string | number;
|
|
6326
|
+
/** Override the version's default durability for the new run. */
|
|
6327
|
+
durability?: "ephemeral" | "standard" | "strict";
|
|
6328
|
+
webhook?: WebhookConfig;
|
|
6329
|
+
metadata?: Metadata;
|
|
6330
|
+
}
|
|
6331
|
+
|
|
6332
|
+
/** A routine run (`run_…`); `result` is the routine's `output`. */
|
|
6333
|
+
export type RoutineRun = Omit<Job, "id" | "object"> & {
|
|
6334
|
+
id: string;
|
|
6335
|
+
object: "routine_run";
|
|
6336
|
+
routine_id: string;
|
|
6337
|
+
version_id: string;
|
|
6338
|
+
version_number: number;
|
|
6339
|
+
durability: "ephemeral" | "standard" | "strict";
|
|
6340
|
+
trigger: RunTrigger;
|
|
6341
|
+
input: Record<string, unknown>;
|
|
6342
|
+
/**
|
|
6343
|
+
* The run's outcome line: when the routine's `output` is an object with a non-empty `summary` string,
|
|
6344
|
+
* that string on one line, cut to 140 characters (an ellipsis marks the cut). Absent otherwise. Run
|
|
6345
|
+
* lists, the run's terminal event and its webhook carry it, so a list of runs says what each one did.
|
|
6346
|
+
*/
|
|
6347
|
+
summary?: string;
|
|
6348
|
+
/** Top-level steps in definition order (empty when `steps_kept` is `false`). */
|
|
6349
|
+
steps: StepRun[];
|
|
6350
|
+
/**
|
|
6351
|
+
* `false` on an `ephemeral` run read after it ended: only its summary was kept (status, timing,
|
|
6352
|
+
* `input`, `result`, `error` and its IDs), so `steps` is empty, `…/steps` and a replay answer 410
|
|
6353
|
+
* `run_steps_not_kept`, and `…/events` sends its terminal event alone. The `?wait=` answer, the event
|
|
6354
|
+
* stream and the webhook carried its steps as it ended. Absent on every other run.
|
|
6355
|
+
*/
|
|
6356
|
+
steps_kept?: false;
|
|
6357
|
+
};
|
|
6358
|
+
|
|
6359
|
+
export type RoutineRunList = Omit<ListEnvelope, "data"> & {
|
|
6360
|
+
data: RoutineRun[];
|
|
6361
|
+
};
|
|
6362
|
+
|
|
6363
|
+
/** `step.*` events carry `step` (a `StepRun`); `run.log` carries `step_id`, `level` and `message`. */
|
|
6364
|
+
export type RunEvent = JobEvent & {
|
|
6365
|
+
step?: StepRun;
|
|
6366
|
+
step_id?: string;
|
|
6367
|
+
level?: "debug" | "info" | "warn" | "error";
|
|
6368
|
+
message?: string;
|
|
6369
|
+
};
|
|
6370
|
+
|
|
6371
|
+
export interface RoutineEventRequest {
|
|
6372
|
+
/** The event name `wait.event` names. */
|
|
6373
|
+
name: string;
|
|
6374
|
+
/** What `wait.match` is checked against, and the step's `data` output. */
|
|
6375
|
+
data?: unknown;
|
|
6376
|
+
/** Your ID for the event, passed to the step's `id` output. */
|
|
6377
|
+
id?: string;
|
|
6378
|
+
}
|
|
6379
|
+
|
|
6380
|
+
export interface RoutineEvent {
|
|
6381
|
+
object: "routine_event";
|
|
6382
|
+
name: string;
|
|
6383
|
+
id?: string | null;
|
|
6384
|
+
/** How many waiting steps the event resumed. */
|
|
6385
|
+
delivered: number;
|
|
6386
|
+
/** The runs and steps it resumed (the first 100). */
|
|
6387
|
+
runs: {
|
|
6388
|
+
run_id: string;
|
|
6389
|
+
step_id: string;
|
|
6390
|
+
}[];
|
|
6391
|
+
}
|
|
6392
|
+
|
|
6393
|
+
/**
|
|
6394
|
+
* A wait's `prompt` as evaluated when the step started waiting. `dropped` names fields left out because they were not https URLs.
|
|
6395
|
+
*/
|
|
6396
|
+
export interface WaitPrompt {
|
|
6397
|
+
title?: string;
|
|
6398
|
+
body?: string;
|
|
6399
|
+
image?: string;
|
|
6400
|
+
/**
|
|
6401
|
+
* The render artifact the image came from, when `image` was one (`steps.shot.outputs.artifacts[0]`). Its URL is signed for a day; the link's page signs a fresh one, as the run's principal, each time it is served.
|
|
6402
|
+
*/
|
|
6403
|
+
image_artifact?: string;
|
|
6404
|
+
link?: string;
|
|
6405
|
+
dropped?: Array<"image" | "link">;
|
|
6406
|
+
}
|
|
6407
|
+
|
|
6408
|
+
/** A wait link's step. */
|
|
6409
|
+
export interface RoutineWait {
|
|
6410
|
+
object: "routine_wait";
|
|
6411
|
+
/**
|
|
6412
|
+
* waiting: it takes an answer. pending: the step has not started waiting. answered: through a link or a signal. timed_out: its deadline passed. expired: 7 days after it started waiting. ended: the run ended, or the step was skipped or canceled, before an answer.
|
|
6413
|
+
*/
|
|
6414
|
+
status: "waiting" | "pending" | "answered" | "timed_out" | "expired" | "ended";
|
|
6415
|
+
run_id: string;
|
|
6416
|
+
run_status: "queued" | "running" | "succeeded" | "failed" | "canceled";
|
|
6417
|
+
routine_id: string;
|
|
6418
|
+
routine_name?: string | null;
|
|
6419
|
+
step_id: string;
|
|
6420
|
+
step_name?: string | null;
|
|
6421
|
+
/**
|
|
6422
|
+
* The step's evaluated prompt while it waits, and after an answer while the node still holds the run (null once the run is only in the run store).
|
|
6423
|
+
*/
|
|
6424
|
+
prompt: WaitPrompt | null;
|
|
6425
|
+
waiting_since?: string | null;
|
|
6426
|
+
/**
|
|
6427
|
+
* While the step waits, when the link stops taking an answer: 7 days after the step started waiting, or the step's own deadline (`wait.ms`, `wait.until`) when that is sooner.
|
|
6428
|
+
*/
|
|
6429
|
+
expires_at?: string | null;
|
|
6430
|
+
/** Once answered. `decision` is null for a signal sent through the API without one. */
|
|
6431
|
+
answer: {
|
|
6432
|
+
decision?: "approve" | "reject" | null;
|
|
6433
|
+
approved?: boolean | null;
|
|
6434
|
+
comment?: string | null;
|
|
6435
|
+
via?: "link" | "signal";
|
|
6436
|
+
answered_at?: string | null;
|
|
6437
|
+
} | null;
|
|
6438
|
+
}
|
|
6439
|
+
|
|
6440
|
+
export interface SignalRequest {
|
|
6441
|
+
/** The `wait.signal` name the run waits for (routine.schema.json). */
|
|
6442
|
+
name: string;
|
|
6443
|
+
/** Becomes the waiting step's outputs. */
|
|
6444
|
+
payload?: unknown;
|
|
6445
|
+
}
|
|
6446
|
+
|
|
6447
|
+
/**
|
|
6448
|
+
* A CEL expression (the routines dialect, without `${{ }}`), compiled at create and run under a cost meter.
|
|
6449
|
+
* It sees `event` (`payload`, `headers`, `source`, `received_at`), `listener` (`id`, `name`, `metadata`) and
|
|
6450
|
+
* `now`; a source's `items` and `cursor` expressions see `response` (`status`, `headers`, `body`) and
|
|
6451
|
+
* `cursor` instead.
|
|
6452
|
+
*/
|
|
6453
|
+
export type CelExpression = string;
|
|
6454
|
+
|
|
6455
|
+
/**
|
|
6456
|
+
* A vault connection in this project, injected by its type (`bearer`, `api_key`, `basic`, `oauth2`) into each
|
|
6457
|
+
* https request to the source when the URL's host is one of the connection's `hosts`. Resolved again at each
|
|
6458
|
+
* connect, so a rotated secret or a refreshed OAuth token applies from the next one. Needs `vault:run`.
|
|
6459
|
+
*/
|
|
6460
|
+
export type ConnectionId = string;
|
|
6461
|
+
|
|
6462
|
+
/** Extra request headers. `Authorization`, `Cookie` and `Host` are refused here; use `connection`. */
|
|
6463
|
+
export type SourceHeaders = Record<string, string>;
|
|
6464
|
+
|
|
6465
|
+
export interface HttpPollSource {
|
|
6466
|
+
type: "http_poll";
|
|
6467
|
+
/**
|
|
6468
|
+
* http or https. May hold `${{ cursor }}`, replaced (URL-encoded) by the current cursor, or by an empty string before the first one.
|
|
6469
|
+
*/
|
|
6470
|
+
url: string;
|
|
6471
|
+
/** @default "GET" */
|
|
6472
|
+
method?: "GET" | "POST";
|
|
6473
|
+
headers?: SourceHeaders;
|
|
6474
|
+
/** A JSON body for `POST`; string values may hold `${{ cursor }}`. */
|
|
6475
|
+
body?: unknown;
|
|
6476
|
+
connection?: ConnectionId;
|
|
6477
|
+
/**
|
|
6478
|
+
* 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.
|
|
6479
|
+
* @default 60000
|
|
6480
|
+
*/
|
|
6481
|
+
interval_ms?: number;
|
|
6482
|
+
/**
|
|
6483
|
+
* The list of events in a response. Default `response.body` when it is a list, else `[response.body]`.
|
|
6484
|
+
*/
|
|
6485
|
+
items?: CelExpression;
|
|
6486
|
+
/**
|
|
6487
|
+
* 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.
|
|
6488
|
+
*/
|
|
6489
|
+
cursor?: CelExpression;
|
|
6490
|
+
/**
|
|
6491
|
+
* `skip`: the first poll records what is there and emits nothing; `emit`: it emits every item.
|
|
6492
|
+
* @default "skip"
|
|
6493
|
+
*/
|
|
6494
|
+
initial?: "skip" | "emit";
|
|
6495
|
+
}
|
|
6496
|
+
|
|
6497
|
+
export interface SseSource {
|
|
6498
|
+
type: "sse";
|
|
6499
|
+
/** http or https. */
|
|
6500
|
+
url: string;
|
|
6501
|
+
headers?: SourceHeaders;
|
|
6502
|
+
connection?: ConnectionId;
|
|
6503
|
+
/**
|
|
6504
|
+
* Keep only frames whose `event:` is one of these (`message` for frames without one). `null` keeps every frame.
|
|
6505
|
+
*/
|
|
6506
|
+
event_types?: string[] | null;
|
|
6507
|
+
/**
|
|
6508
|
+
* Reconnect when nothing (frames or comments) arrives for this long.
|
|
6509
|
+
* @default 90000
|
|
6510
|
+
*/
|
|
6511
|
+
idle_timeout_ms?: number;
|
|
6512
|
+
}
|
|
6513
|
+
|
|
6514
|
+
/**
|
|
6515
|
+
* A WebSocket held by the node's socket holder (`b3os-listend`), a unit of its own, so a node release that
|
|
6516
|
+
* restarts the API server keeps the socket open: each frame is written to disk before anything reads it, and
|
|
6517
|
+
* the server reads what arrived while it was down. After a network drop or a restart of the holder itself the
|
|
6518
|
+
* source reconnects on HookBuffer's ladder (1, 2, 5, 10, 30, 60 s). The reconnect resumes when a cursor is
|
|
6519
|
+
* stored and the frames it sends (`resume`, else `subscribe`) hold `${{ cursor }}`; otherwise the time the
|
|
6520
|
+
* socket was down is a `gap` record in the history.
|
|
6521
|
+
*
|
|
6522
|
+
* A text frame that is JSON becomes the event's `payload` as JSON, any other text frame as a string, and a
|
|
6523
|
+
* binary frame as its base64 text with `headers.binary` true. A frame over `listeners.event_bytes_max` is
|
|
6524
|
+
* counted as failed and not kept.
|
|
6525
|
+
*/
|
|
6526
|
+
export interface WebsocketSource {
|
|
6527
|
+
type: "websocket";
|
|
6528
|
+
/** ws or wss. A `connection` is sent only in a wss handshake. */
|
|
6529
|
+
url: string;
|
|
6530
|
+
headers?: SourceHeaders;
|
|
6531
|
+
connection?: ConnectionId;
|
|
6532
|
+
/**
|
|
6533
|
+
* 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).
|
|
6534
|
+
*/
|
|
6535
|
+
subscribe?: unknown[];
|
|
6536
|
+
/**
|
|
6537
|
+
* Frames sent instead of `subscribe` after a reconnect when a cursor is stored; string values may hold `${{ cursor }}`.
|
|
6538
|
+
*/
|
|
6539
|
+
resume?: unknown[];
|
|
6540
|
+
/**
|
|
6541
|
+
* The cursor after an event, from `event` (`payload`, `headers`). It is stored once the event is in the log; `null` keeps the current one.
|
|
6542
|
+
*/
|
|
6543
|
+
cursor?: CelExpression;
|
|
6544
|
+
/**
|
|
6545
|
+
* 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.
|
|
6546
|
+
*/
|
|
6547
|
+
split?: CelExpression;
|
|
6548
|
+
/**
|
|
6549
|
+
* A ping is sent this often; a socket that sends nothing (no pong, no frame) for twice this long is reconnected.
|
|
6550
|
+
* @default 30000
|
|
6551
|
+
*/
|
|
6552
|
+
ping_ms?: number;
|
|
6553
|
+
}
|
|
6554
|
+
|
|
6555
|
+
/**
|
|
6556
|
+
* How a `webhook` source checks each delivery, as a routine's webhook trigger does. `b3os`: `B3OS-Signature:
|
|
6557
|
+
* t=<unix>,v1=<hex HMAC-SHA256(secret, "<t>.<body>")>` with a per-hook secret B3OS makes, shown once in the
|
|
6558
|
+
* create answer (`source.secret`). `github`, `stripe`, `slack`, `standard_webhooks`: the provider's own
|
|
6559
|
+
* scheme, with its signing secret in `secret`. `hmac_sha256`: a generic HMAC over `<value of
|
|
6560
|
+
* timestamp_header>.<body>` in `header` (`header` and `timestamp_header` are required, and `dedupe.key` must
|
|
6561
|
+
* be set). Timestamped schemes refuse a delivery more than `tolerance_s` from the node clock. Secrets never
|
|
6562
|
+
* appear in the URL.
|
|
6563
|
+
*/
|
|
6564
|
+
export interface ListenerWebhookVerify {
|
|
6565
|
+
scheme: "b3os" | "github" | "stripe" | "slack" | "standard_webhooks" | "hmac_sha256";
|
|
6566
|
+
/**
|
|
6567
|
+
* 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.
|
|
6568
|
+
*/
|
|
6569
|
+
secret?: string;
|
|
6570
|
+
/** `hmac_sha256` only: the header holding the signature. */
|
|
6571
|
+
header?: string;
|
|
6572
|
+
/** `hmac_sha256` only: how the signature is written. Default `hex`. */
|
|
6573
|
+
encoding?: "hex" | "base64";
|
|
6574
|
+
/** `hmac_sha256` only: text before the signature in `header`, such as `sha256=`. */
|
|
6575
|
+
prefix?: string;
|
|
6576
|
+
/** `hmac_sha256` only: the header holding the delivery's Unix timestamp. */
|
|
6577
|
+
timestamp_header?: string;
|
|
6578
|
+
/** @default 300 */
|
|
6579
|
+
tolerance_s?: number;
|
|
6580
|
+
}
|
|
6581
|
+
|
|
6582
|
+
/**
|
|
6583
|
+
* Deliveries a provider sends to `hook_url` (`POST /v1/listeners/hooks/{hook_id}`), through the edge, which
|
|
6584
|
+
* queues them for 72 hours while the node is down. `hook_id`, `hook_url` and `secret` are set by B3OS and
|
|
6585
|
+
* refused in a request.
|
|
6586
|
+
*/
|
|
6587
|
+
export interface WebhookSource {
|
|
6588
|
+
type: "webhook";
|
|
6589
|
+
verify: ListenerWebhookVerify;
|
|
6590
|
+
hook_id?: string;
|
|
6591
|
+
/** Give this URL to the provider. */
|
|
6592
|
+
hook_url?: string;
|
|
6593
|
+
/** The `b3os` scheme's signing secret, in the create answer only. */
|
|
6594
|
+
secret?: string;
|
|
6595
|
+
}
|
|
6596
|
+
|
|
6597
|
+
/**
|
|
6598
|
+
* A pack's trigger, as a routine's `type: action` trigger takes it: the actions trigger manager subscribes
|
|
6599
|
+
* (registering a provider webhook, or polling, or a schedule) and hands each event to the listener, keyed by
|
|
6600
|
+
* the trigger's own event ID. The event's `payload` is the trigger's `data`; its `headers` carry
|
|
6601
|
+
* `event_type`, `source`, `time` and `subscription_id`.
|
|
6602
|
+
*/
|
|
6603
|
+
export interface PackSource {
|
|
6604
|
+
type: "pack";
|
|
6605
|
+
/** `<namespace>/<pack>/<trigger>@<version or major>`, such as `io.b3os/github/push@1`. */
|
|
6606
|
+
uses: string;
|
|
6607
|
+
/** The trigger's configuration, valid against its `configSchema`. */
|
|
6608
|
+
with?: unknown;
|
|
6609
|
+
/**
|
|
6610
|
+
* Connection key to `conn_` ID; an unbound required key takes the project's most recent connection for it.
|
|
6611
|
+
*/
|
|
6612
|
+
connections?: Record<string, ConnectionId>;
|
|
6613
|
+
}
|
|
6614
|
+
|
|
6615
|
+
/** Events arrive through `POST /v1/listeners/{listener_id}/events`. */
|
|
6616
|
+
export interface PushSource {
|
|
6617
|
+
type: "push";
|
|
6618
|
+
}
|
|
6619
|
+
|
|
6620
|
+
export type ListenerSource = HttpPollSource | SseSource | WebsocketSource | WebhookSource | PackSource | PushSource;
|
|
6621
|
+
|
|
6622
|
+
export interface ListenerDedupe {
|
|
6623
|
+
/**
|
|
6624
|
+
* The event's identity, turned into text. Defaults: the SSE frame's `id` when it has one, a push event's
|
|
6625
|
+
* `dedupe_key`, otherwise the SHA-256 of the payload's canonical JSON.
|
|
4721
6626
|
*/
|
|
4722
|
-
|
|
6627
|
+
key?: CelExpression;
|
|
4723
6628
|
/**
|
|
4724
|
-
*
|
|
6629
|
+
* How long a key is remembered; a repeat within it is dropped before the filter.
|
|
6630
|
+
* @default 86400
|
|
4725
6631
|
*/
|
|
4726
|
-
|
|
6632
|
+
window_s?: number;
|
|
6633
|
+
}
|
|
6634
|
+
|
|
6635
|
+
export interface ListenerFilter {
|
|
4727
6636
|
/**
|
|
4728
|
-
*
|
|
6637
|
+
* Keep the event when this is `true`. An evaluation error drops the event as `filtered`, with the error in its record.
|
|
4729
6638
|
*/
|
|
4730
|
-
|
|
4731
|
-
|
|
4732
|
-
durability?: "ephemeral" | "standard" | "strict";
|
|
4733
|
-
webhook?: WebhookConfig;
|
|
4734
|
-
metadata?: Metadata;
|
|
6639
|
+
cel?: CelExpression;
|
|
6640
|
+
model?: ListenerModelFilter;
|
|
4735
6641
|
}
|
|
4736
6642
|
|
|
4737
|
-
/**
|
|
4738
|
-
|
|
4739
|
-
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
input: Record<string, unknown>;
|
|
6643
|
+
/**
|
|
6644
|
+
* One question to the small model (`b3os/qwen3.5-9b`) about each event CEL kept, asked after the event is in the
|
|
6645
|
+
* log and before the sink. The answer is `{match, reason}` plus `fields`; `match: false` ends the event
|
|
6646
|
+
* `filtered`. Calls run as the listener's owner (`infer:run`) and bill infer tokens, at most
|
|
6647
|
+
* `listeners.model_filter.rpm` a minute per listener, in order.
|
|
6648
|
+
*/
|
|
6649
|
+
export interface ListenerModelFilter {
|
|
6650
|
+
/** The question, such as "Does this mail ask for something that must happen today?". */
|
|
6651
|
+
prompt: string;
|
|
4747
6652
|
/**
|
|
4748
|
-
* The
|
|
4749
|
-
*
|
|
4750
|
-
* lists, the run's terminal event and its webhook carry it, so a list of runs says what each one did.
|
|
6653
|
+
* The event's payload is cut to about this many tokens (four bytes of JSON each).
|
|
6654
|
+
* @default 2048
|
|
4751
6655
|
*/
|
|
4752
|
-
|
|
4753
|
-
/** Top-level steps in definition order (empty when `steps_kept` is `false`). */
|
|
4754
|
-
steps: StepRun[];
|
|
6656
|
+
max_input_tokens?: number;
|
|
4755
6657
|
/**
|
|
4756
|
-
* `
|
|
4757
|
-
* `input`, `result`, `error` and its IDs), so `steps` is empty, `…/steps` and a replay answer 410
|
|
4758
|
-
* `run_steps_not_kept`, and `…/events` sends its terminal event alone. The `?wait=` answer, the event
|
|
4759
|
-
* stream and the webhook carried its steps as it ended. Absent on every other run.
|
|
6658
|
+
* 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`.
|
|
4760
6659
|
*/
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
/** `step.*` events carry `step` (a `StepRun`); `run.log` carries `step_id`, `level` and `message`. */
|
|
4769
|
-
export type RunEvent = JobEvent & {
|
|
4770
|
-
step?: StepRun;
|
|
4771
|
-
step_id?: string;
|
|
4772
|
-
level?: "debug" | "info" | "warn" | "error";
|
|
4773
|
-
message?: string;
|
|
4774
|
-
};
|
|
4775
|
-
|
|
4776
|
-
export interface RoutineEventRequest {
|
|
4777
|
-
/** The event name `wait.event` names. */
|
|
4778
|
-
name: string;
|
|
4779
|
-
/** What `wait.match` is checked against, and the step's `data` output. */
|
|
4780
|
-
data?: unknown;
|
|
4781
|
-
/** Your ID for the event, passed to the step's `id` output. */
|
|
4782
|
-
id?: string;
|
|
4783
|
-
}
|
|
4784
|
-
|
|
4785
|
-
export interface RoutineEvent {
|
|
4786
|
-
object: "routine_event";
|
|
4787
|
-
name: string;
|
|
4788
|
-
id?: string | null;
|
|
4789
|
-
/** How many waiting steps the event resumed. */
|
|
4790
|
-
delivered: number;
|
|
4791
|
-
/** The runs and steps it resumed (the first 100). */
|
|
4792
|
-
runs: {
|
|
4793
|
-
run_id: string;
|
|
4794
|
-
step_id: string;
|
|
4795
|
-
}[];
|
|
6660
|
+
fields?: Record<string, unknown>;
|
|
6661
|
+
/**
|
|
6662
|
+
* What happens to an event the model could not judge (an error, a timeout, output that does not parse, the token budget spent).
|
|
6663
|
+
* @default "drop"
|
|
6664
|
+
*/
|
|
6665
|
+
on_error?: "drop" | "pass";
|
|
4796
6666
|
}
|
|
4797
6667
|
|
|
4798
6668
|
/**
|
|
4799
|
-
*
|
|
6669
|
+
* Hand kept events to the sink together: once `max_events` are waiting, or once the oldest has waited
|
|
6670
|
+
* `max_wait_ms`. One delivery is `{type: listener.batch, id, dedupe_key, count, first_seq, last_seq, events}`:
|
|
6671
|
+
* `events` in the order the listener kept them, each with its own `dedupe_key`, and the batch's `dedupe_key`
|
|
6672
|
+
* a digest of theirs, so a receiver that sees the same batch twice can drop it. A routine sink starts one run
|
|
6673
|
+
* per batch with the batch as its `trigger`. Needs `concurrency: 1`, and for a routine sink `mode: run`.
|
|
4800
6674
|
*/
|
|
4801
|
-
export interface
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
|
|
6675
|
+
export interface ListenerBatch {
|
|
6676
|
+
max_events: number;
|
|
6677
|
+
/** @default 1000 */
|
|
6678
|
+
max_wait_ms?: number;
|
|
6679
|
+
}
|
|
6680
|
+
|
|
6681
|
+
export interface RoutineSink {
|
|
6682
|
+
type: "routine";
|
|
6683
|
+
/** The routine's ID (`rtn_…`) or name in this project. Needs `routines:run`. */
|
|
6684
|
+
routine: string;
|
|
4805
6685
|
/**
|
|
4806
|
-
*
|
|
6686
|
+
* `run` starts a run of the routine's active version per event, with `trigger = {type: listener, id,
|
|
6687
|
+
* event_id, seq, dedupe_key, received_at, payload}`; a redelivery of the same `dedupe_key` starts no
|
|
6688
|
+
* second run. `event` sends the event to the routine's runs waiting with `wait: {event: <event>}`
|
|
6689
|
+
* (`routinesSendEvent`), with `data` = the payload.
|
|
6690
|
+
* @default "run"
|
|
4807
6691
|
*/
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
6692
|
+
mode?: "run" | "event";
|
|
6693
|
+
/** The event name, for `mode: event` (required there). */
|
|
6694
|
+
event?: string | null;
|
|
6695
|
+
/**
|
|
6696
|
+
* Deliveries in flight at once. With 1, events arrive in the order the listener kept them.
|
|
6697
|
+
* @default 1
|
|
6698
|
+
*/
|
|
6699
|
+
concurrency?: number;
|
|
6700
|
+
/**
|
|
6701
|
+
* How long a retryable failure (5xx, 429, 503) is retried, with backoff, before the event is `failed`.
|
|
6702
|
+
* @default 86400
|
|
6703
|
+
*/
|
|
6704
|
+
retry_for_s?: number;
|
|
6705
|
+
batch?: ListenerBatch;
|
|
4811
6706
|
}
|
|
4812
6707
|
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
object: "routine_wait";
|
|
6708
|
+
export interface WebhookSink {
|
|
6709
|
+
type: "webhook";
|
|
4816
6710
|
/**
|
|
4817
|
-
*
|
|
6711
|
+
* https. Each kept event is POSTed as a `WebhookEvent` (`type: listener.event`, `job_id` = the listener)
|
|
6712
|
+
* signed with `B3OS-Signature` under the endpoint's secret (`POST /v1/webhooks/secret`), through the
|
|
6713
|
+
* egress guard and retried for 24 hours. Its `data` is `{type: listener, id, event_id, seq, dedupe_key,
|
|
6714
|
+
* received_at, payload}`; `data.dedupe_key` (32 hex characters, a digest of the listener and the event's
|
|
6715
|
+
* key) is the same on every delivery of one event, so a receiver can drop a repeat. With `batch`, the
|
|
6716
|
+
* event type is `listener.batch` and `data` is the batch (`ListenerBatch`).
|
|
4818
6717
|
*/
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
|
|
6718
|
+
url: string;
|
|
6719
|
+
/** @default 1 */
|
|
6720
|
+
concurrency?: number;
|
|
6721
|
+
/** @default 86400 */
|
|
6722
|
+
retry_for_s?: number;
|
|
6723
|
+
batch?: ListenerBatch;
|
|
6724
|
+
}
|
|
6725
|
+
|
|
6726
|
+
export type ListenerSink = RoutineSink | WebhookSink;
|
|
6727
|
+
|
|
6728
|
+
/**
|
|
6729
|
+
* JSON pointers into the payload (`/customer/email`). Their values are replaced by `"[redacted]"` before the
|
|
6730
|
+
* event is written anywhere: the log, the history and the sink's copy. A pointer that does not exist in an
|
|
6731
|
+
* event changes nothing. The filter sees the redacted event too.
|
|
6732
|
+
*/
|
|
6733
|
+
export type ListenerRedact = string[];
|
|
6734
|
+
|
|
6735
|
+
export interface ListenerBudgetRequest {
|
|
4826
6736
|
/**
|
|
4827
|
-
*
|
|
6737
|
+
* 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`.
|
|
4828
6738
|
*/
|
|
4829
|
-
|
|
4830
|
-
waiting_since?: string | null;
|
|
6739
|
+
events_per_day?: number;
|
|
4831
6740
|
/**
|
|
4832
|
-
*
|
|
6741
|
+
* 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`.
|
|
4833
6742
|
*/
|
|
6743
|
+
model_tokens_per_day?: number;
|
|
6744
|
+
}
|
|
6745
|
+
|
|
6746
|
+
export interface ListenerCreateRequest {
|
|
6747
|
+
/** A label; not unique. */
|
|
6748
|
+
name?: string | null;
|
|
6749
|
+
source: ListenerSource;
|
|
6750
|
+
dedupe?: ListenerDedupe;
|
|
6751
|
+
filter?: ListenerFilter;
|
|
6752
|
+
sink: ListenerSink;
|
|
6753
|
+
redact?: ListenerRedact;
|
|
6754
|
+
/** Seconds from now until the listener ends `expired`. Not with `expires_at`. */
|
|
6755
|
+
ttl_s?: number;
|
|
6756
|
+
/** When the listener ends `expired`. Not with `ttl_s`. */
|
|
6757
|
+
expires_at?: string;
|
|
6758
|
+
budget?: ListenerBudgetRequest;
|
|
6759
|
+
metadata?: Metadata;
|
|
6760
|
+
}
|
|
6761
|
+
|
|
6762
|
+
export interface ListenerUpdateRequest {
|
|
6763
|
+
paused?: boolean;
|
|
6764
|
+
/** Seconds from now until the listener ends `expired`. Not with `expires_at`. */
|
|
6765
|
+
ttl_s?: number;
|
|
6766
|
+
/** When the listener ends `expired`; `null` lets it live until deleted. */
|
|
4834
6767
|
expires_at?: string | null;
|
|
4835
|
-
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
6768
|
+
filter?: ListenerFilter;
|
|
6769
|
+
sink?: ListenerSink;
|
|
6770
|
+
redact?: ListenerRedact;
|
|
6771
|
+
budget?: ListenerBudgetRequest;
|
|
6772
|
+
metadata?: Metadata;
|
|
6773
|
+
}
|
|
6774
|
+
|
|
6775
|
+
/**
|
|
6776
|
+
* `starting` until the first connect or poll succeeds; `active`; `reconnecting` while the source is down and
|
|
6777
|
+
* being retried; `paused` (`status_reason` `user` or `budget`); then the ends: `failed` (`error` says why),
|
|
6778
|
+
* `expired` (its lifetime passed) and `revoked` (its owner key was revoked or expired, or its sandbox ended).
|
|
6779
|
+
*/
|
|
6780
|
+
export type ListenerStatus = "starting" | "active" | "reconnecting" | "paused" | "failed" | "expired" | "revoked";
|
|
6781
|
+
|
|
6782
|
+
export interface Listener {
|
|
6783
|
+
id: string;
|
|
6784
|
+
object: "listener";
|
|
6785
|
+
name: string | null;
|
|
6786
|
+
status: ListenerStatus;
|
|
6787
|
+
status_reason:
|
|
6788
|
+
| "user"
|
|
6789
|
+
| "budget"
|
|
6790
|
+
| "auth"
|
|
6791
|
+
| "egress_denied"
|
|
6792
|
+
| "source_errors"
|
|
6793
|
+
| "owner_revoked"
|
|
6794
|
+
| "sandbox_ended"
|
|
6795
|
+
| null;
|
|
6796
|
+
/** Why the source last failed, or why the listener ended `failed`. */
|
|
6797
|
+
error: {
|
|
6798
|
+
code: string;
|
|
6799
|
+
detail: string;
|
|
6800
|
+
at: string;
|
|
4842
6801
|
} | null;
|
|
6802
|
+
source: ListenerSource;
|
|
6803
|
+
source_state: {
|
|
6804
|
+
/** The stored cursor (`http_poll`, `websocket`) or last event ID (`sse`); `null` before the first. */
|
|
6805
|
+
cursor: unknown;
|
|
6806
|
+
connected_since: string | null;
|
|
6807
|
+
/** The next poll, or the next reconnect attempt while `reconnecting`. */
|
|
6808
|
+
next_attempt_at: string | null;
|
|
6809
|
+
};
|
|
6810
|
+
dedupe: ListenerDedupe;
|
|
6811
|
+
filter: ListenerFilter;
|
|
6812
|
+
sink: ListenerSink;
|
|
6813
|
+
redact: ListenerRedact;
|
|
6814
|
+
expires_at: string | null;
|
|
6815
|
+
budget: {
|
|
6816
|
+
events_per_day: number;
|
|
6817
|
+
model_tokens_per_day: number;
|
|
6818
|
+
used: {
|
|
6819
|
+
events: number;
|
|
6820
|
+
model_tokens: number;
|
|
6821
|
+
window_start: string;
|
|
6822
|
+
};
|
|
6823
|
+
};
|
|
6824
|
+
owner: {
|
|
6825
|
+
kind: "key" | "project";
|
|
6826
|
+
/** The owning key (`key_…`) or project (`prj_…`). */
|
|
6827
|
+
id: string;
|
|
6828
|
+
/** The sandbox that created it, when one did; the listener ends with that sandbox's root. */
|
|
6829
|
+
sandbox: string | null;
|
|
6830
|
+
};
|
|
6831
|
+
stats: {
|
|
6832
|
+
received: number;
|
|
6833
|
+
delivered: number;
|
|
6834
|
+
filtered: number;
|
|
6835
|
+
duplicates: number;
|
|
6836
|
+
failed: number;
|
|
6837
|
+
skipped: number;
|
|
6838
|
+
reconnects: number;
|
|
6839
|
+
last_event_at: string | null;
|
|
6840
|
+
};
|
|
6841
|
+
created_at: string;
|
|
6842
|
+
updated_at: string;
|
|
6843
|
+
metadata: Metadata;
|
|
4843
6844
|
}
|
|
4844
6845
|
|
|
4845
|
-
export
|
|
4846
|
-
|
|
4847
|
-
|
|
4848
|
-
|
|
4849
|
-
|
|
6846
|
+
export type ListenerList = Omit<ListEnvelope, "data"> & {
|
|
6847
|
+
data: Listener[];
|
|
6848
|
+
};
|
|
6849
|
+
|
|
6850
|
+
/**
|
|
6851
|
+
* `pending` (in the log, being delivered or retried), `delivered`, `filtered` (the filter dropped it or could
|
|
6852
|
+
* not evaluate), `failed` (the sink refused it, or kept failing for `retry_for_s`), `skipped` (the budget was
|
|
6853
|
+
* spent).
|
|
6854
|
+
*/
|
|
6855
|
+
export type ListenerEventStatus = "pending" | "delivered" | "filtered" | "failed" | "skipped";
|
|
6856
|
+
|
|
6857
|
+
export interface ListenerEvent {
|
|
6858
|
+
id: string;
|
|
6859
|
+
object: "listener_event";
|
|
6860
|
+
listener: string;
|
|
6861
|
+
/** The listener's own sequence number, from 1, gap records included. */
|
|
6862
|
+
seq: number;
|
|
6863
|
+
kind: "event" | "gap";
|
|
6864
|
+
received_at: string;
|
|
6865
|
+
dedupe_key: string | null;
|
|
6866
|
+
/** The event as the source sent it (JSON, or a string for text), after `redact`. `null` for a gap. */
|
|
6867
|
+
payload: unknown;
|
|
6868
|
+
payload_truncated: boolean;
|
|
6869
|
+
filter: {
|
|
6870
|
+
cel?: boolean | null;
|
|
6871
|
+
error?: string | null;
|
|
6872
|
+
/**
|
|
6873
|
+
* The model filter's verdict, `{match, reason, fields, tokens}`, or when it could not judge `{match: null, error: {code, detail}, on_error, tokens}`.
|
|
6874
|
+
*/
|
|
6875
|
+
model?: {
|
|
6876
|
+
match?: boolean | null;
|
|
6877
|
+
reason?: string;
|
|
6878
|
+
fields?: Record<string, unknown>;
|
|
6879
|
+
tokens?: number;
|
|
6880
|
+
error?: {
|
|
6881
|
+
code?: string;
|
|
6882
|
+
detail?: string;
|
|
6883
|
+
};
|
|
6884
|
+
on_error?: "drop" | "pass";
|
|
6885
|
+
} | null;
|
|
6886
|
+
} | null;
|
|
6887
|
+
status: ListenerEventStatus | null;
|
|
6888
|
+
delivery: {
|
|
6889
|
+
attempts: number;
|
|
6890
|
+
/** The run (`run_…`) or webhook delivery the sink made. */
|
|
6891
|
+
sink_ref: string | null;
|
|
6892
|
+
delivered_at: string | null;
|
|
6893
|
+
last_error: {
|
|
6894
|
+
code?: string;
|
|
6895
|
+
detail?: string;
|
|
6896
|
+
} | null;
|
|
6897
|
+
} | null;
|
|
6898
|
+
/** For `kind: gap`, the time the source was down. */
|
|
6899
|
+
gap: {
|
|
6900
|
+
from: string;
|
|
6901
|
+
to: string;
|
|
6902
|
+
reason: "disconnected" | "node_restart" | "backlog_full";
|
|
6903
|
+
} | null;
|
|
6904
|
+
/**
|
|
6905
|
+
* Where the node spent the time between receiving the event and its sink accepting it, measured on the node
|
|
6906
|
+
* in milliseconds with microsecond resolution (the platform's `Timing`). `append_ms`: from receipt (the frame
|
|
6907
|
+
* read, the poll's response or the request in hand) to the event durable in the listener's log; dedupe and
|
|
6908
|
+
* the CEL filter run inside it. `filter_ms`: the model filter's question, only when it was asked.
|
|
6909
|
+
* `sink_ms`: from the log, or the model filter's verdict, to the sink accepting the event (a run created, a
|
|
6910
|
+
* webhook delivery queued, a batch handed over), the wait for the delivery task, every retry and a batch's
|
|
6911
|
+
* wait included. `total_ms`: from receipt to the last phase the event reached. A phase the event did not
|
|
6912
|
+
* go through is left out: an event the filter dropped has no `sink_ms`. Absent on a gap record, on an
|
|
6913
|
+
* event still on its way to the sink, and on events whose receipt the node did not see (kept before a
|
|
6914
|
+
* restart of b3osd, or before the node recorded timing).
|
|
6915
|
+
*/
|
|
6916
|
+
timing?: Timing | null;
|
|
6917
|
+
}
|
|
6918
|
+
|
|
6919
|
+
export type ListenerEventList = Omit<ListEnvelope, "data"> & {
|
|
6920
|
+
data: ListenerEvent[];
|
|
6921
|
+
};
|
|
6922
|
+
|
|
6923
|
+
export interface ListenerStreamFrame {
|
|
6924
|
+
type: "listener.event" | "listener.gap" | "listener.status";
|
|
6925
|
+
ts: string;
|
|
6926
|
+
seq: number;
|
|
6927
|
+
event?: ListenerEvent | null;
|
|
6928
|
+
status?: ListenerStatus | null;
|
|
6929
|
+
}
|
|
6930
|
+
|
|
6931
|
+
export interface ListenerIngestRequest {
|
|
6932
|
+
events: {
|
|
6933
|
+
/** Any JSON value, at most `listeners.event_bytes_max` when serialized. */
|
|
6934
|
+
payload: unknown;
|
|
6935
|
+
dedupe_key?: string;
|
|
6936
|
+
}[];
|
|
6937
|
+
}
|
|
6938
|
+
|
|
6939
|
+
export interface ListenerIngestResult {
|
|
6940
|
+
object: "listener_ingest";
|
|
6941
|
+
accepted: number;
|
|
6942
|
+
duplicates: number;
|
|
6943
|
+
events: {
|
|
6944
|
+
/** The event's ID; `null` for a duplicate. */
|
|
6945
|
+
id: string | null;
|
|
6946
|
+
seq: number | null;
|
|
6947
|
+
status: "pending" | "duplicate";
|
|
6948
|
+
}[];
|
|
6949
|
+
}
|
|
6950
|
+
|
|
6951
|
+
export interface ListenerTestRequest {
|
|
6952
|
+
/** A sample event payload. */
|
|
6953
|
+
payload: unknown;
|
|
6954
|
+
/** @default false */
|
|
6955
|
+
deliver?: boolean;
|
|
6956
|
+
}
|
|
6957
|
+
|
|
6958
|
+
export interface ListenerTestResult {
|
|
6959
|
+
object: "listener_test";
|
|
6960
|
+
dedupe_key: string | null;
|
|
6961
|
+
/** Whether the key is in the dedupe window now. */
|
|
6962
|
+
duplicate: boolean;
|
|
6963
|
+
filter: {
|
|
6964
|
+
cel?: boolean | null;
|
|
6965
|
+
error?: string | null;
|
|
6966
|
+
};
|
|
6967
|
+
/** Whether the listener would keep the event (not a duplicate, and the filter passed). */
|
|
6968
|
+
kept: boolean;
|
|
6969
|
+
/** With `deliver: true` and a kept event, the event as written to the log. */
|
|
6970
|
+
event: ListenerEvent | null;
|
|
6971
|
+
}
|
|
6972
|
+
|
|
6973
|
+
/**
|
|
6974
|
+
* One JSON-RPC 2.0 message of the Model Context Protocol (https://modelcontextprotocol.io): a request
|
|
6975
|
+
* (`method` and `id`), a notification (`method`, no `id`) or a response (`result` or `error`). Methods served:
|
|
6976
|
+
* `initialize`, `server/discover`, `ping`, `tools/list`, `tools/call`, the empty `resources/list`,
|
|
6977
|
+
* `resources/templates/list` and `prompts/list`, and every `notifications/*`.
|
|
6978
|
+
*/
|
|
6979
|
+
export interface McpMessage {
|
|
6980
|
+
jsonrpc: "2.0";
|
|
6981
|
+
/** A string, an integer or `null` (a response to a message whose id could not be read). */
|
|
6982
|
+
id?: unknown;
|
|
6983
|
+
method?: string;
|
|
6984
|
+
params?: Record<string, unknown>;
|
|
6985
|
+
result?: Record<string, unknown>;
|
|
6986
|
+
error?: {
|
|
6987
|
+
code: number;
|
|
6988
|
+
message: string;
|
|
6989
|
+
data?: unknown;
|
|
6990
|
+
};
|
|
4850
6991
|
}
|
|
4851
6992
|
|
|
4852
6993
|
/**
|
|
@@ -4856,6 +6997,9 @@ export interface B3Pack {
|
|
|
4856
6997
|
/** Optional pointer to this schema for editors. Ignored by the runtime. */
|
|
4857
6998
|
$schema?: string;
|
|
4858
6999
|
pack: B3PackPackId;
|
|
7000
|
+
/**
|
|
7001
|
+
* 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.
|
|
7002
|
+
*/
|
|
4859
7003
|
version: B3PackSemver;
|
|
4860
7004
|
title: string;
|
|
4861
7005
|
description: string;
|
|
@@ -5024,11 +7168,12 @@ export interface B3PackEffects {
|
|
|
5024
7168
|
}
|
|
5025
7169
|
|
|
5026
7170
|
/**
|
|
5027
|
-
* 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 are free. Amounts are decimal strings in USD to avoid float rounding; the publish checks hold
|
|
7171
|
+
* 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.
|
|
5028
7172
|
*/
|
|
5029
7173
|
export interface B3PackPricing {
|
|
5030
|
-
model: "free" | "per_call";
|
|
7174
|
+
model: "free" | "per_call" | "per_second" | "per_input_mb";
|
|
5031
7175
|
usd?: string;
|
|
7176
|
+
freeCalls?: number;
|
|
5032
7177
|
}
|
|
5033
7178
|
|
|
5034
7179
|
export type B3PackHeaderName = string;
|
|
@@ -5156,12 +7301,19 @@ export type B3PackAction = {
|
|
|
5156
7301
|
*/
|
|
5157
7302
|
timeoutMs?: number;
|
|
5158
7303
|
/**
|
|
5159
|
-
* vm only
|
|
7304
|
+
* 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.
|
|
7305
|
+
* @default 16
|
|
5160
7306
|
*/
|
|
5161
7307
|
maxInputMb?: number;
|
|
5162
|
-
/**
|
|
7308
|
+
/**
|
|
7309
|
+
* vm only: the most output file data one call may return, in MiB, summed over its output files. Default 16, at most 64.
|
|
7310
|
+
* @default 16
|
|
7311
|
+
*/
|
|
5163
7312
|
maxOutputMb?: number;
|
|
5164
|
-
/**
|
|
7313
|
+
/**
|
|
7314
|
+
* vm only: the most output files one call may return. Default 4, at most 16.
|
|
7315
|
+
* @default 4
|
|
7316
|
+
*/
|
|
5165
7317
|
maxOutputFiles?: number;
|
|
5166
7318
|
/** T1 only: V8 old-generation limit of the worker running the call. Default 128. */
|
|
5167
7319
|
memoryMb?: number;
|
|
@@ -5179,7 +7331,9 @@ export type B3PackAction = {
|
|
|
5179
7331
|
examples?: B3PackExample[];
|
|
5180
7332
|
pricing?: B3PackPricing;
|
|
5181
7333
|
mcp?: {
|
|
5182
|
-
/**
|
|
7334
|
+
/**
|
|
7335
|
+
* 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).
|
|
7336
|
+
*/
|
|
5183
7337
|
name?: string;
|
|
5184
7338
|
/**
|
|
5185
7339
|
* false keeps the action out of tools/list (still callable through actions_call). Default true.
|
|
@@ -5338,11 +7492,11 @@ export type B3PackTrigger = {
|
|
|
5338
7492
|
};
|
|
5339
7493
|
|
|
5340
7494
|
/**
|
|
5341
|
-
* 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
|
|
7495
|
+
* A hosted tool: the software a pack's vm actions run, and what it needs to run. Required when any action is vm and refused otherwise (publish checks 13 to 23). The schema admits the values of later versions (mcp, the other bases, session, hosts, caller, any size) and the reserved keys (setup, image, formats, bundle.files, base.range), so that what this version refuses is refused with a plain sentence of the publish checks rather than a schema error.
|
|
5342
7496
|
*/
|
|
5343
7497
|
export interface B3PackTool {
|
|
5344
7498
|
/**
|
|
5345
|
-
* cli: a command that reads a request on stdin and writes an answer on stdout. mcp (later): an MCP server. Shown on the listing.
|
|
7499
|
+
* 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.
|
|
5346
7500
|
*/
|
|
5347
7501
|
kind: "cli" | "mcp";
|
|
5348
7502
|
/** The shared template the tool runs on. Bases have no versions yet. */
|
|
@@ -5415,8 +7569,10 @@ export interface B3PackTool {
|
|
|
5415
7569
|
image?: unknown;
|
|
5416
7570
|
/** Reserved: output formats a takedown can turn off by name (later). Refused in this version. */
|
|
5417
7571
|
formats?: unknown;
|
|
5418
|
-
/**
|
|
5419
|
-
|
|
7572
|
+
/**
|
|
7573
|
+
* 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.
|
|
7574
|
+
*/
|
|
7575
|
+
errors?: string[];
|
|
5420
7576
|
}
|
|
5421
7577
|
|
|
5422
7578
|
/**
|
|
@@ -5521,6 +7677,10 @@ export interface ActionSummary {
|
|
|
5521
7677
|
score?: number;
|
|
5522
7678
|
/** Set in search results when the search asked for `kind=any`. */
|
|
5523
7679
|
kind?: "action";
|
|
7680
|
+
/**
|
|
7681
|
+
* In a pack (`GET /v1/actions/packs/{namespace}/{name}`), for a hosted tool's action; absent in search results and for other actions.
|
|
7682
|
+
*/
|
|
7683
|
+
tool?: ActionTool;
|
|
5524
7684
|
}
|
|
5525
7685
|
|
|
5526
7686
|
/** A trigger in search results (`kind=trigger` or `kind=any`). */
|
|
@@ -5620,23 +7780,7 @@ export interface ActionDescription {
|
|
|
5620
7780
|
* when the node loads the pack. Their inputs also appear as `examples` in `mcp.inputSchema`.
|
|
5621
7781
|
*/
|
|
5622
7782
|
examples: ActionExample[];
|
|
5623
|
-
|
|
5624
|
-
* For a hosted tool's action (`impl.kind` `vm`), what it runs on and what it costs; absent for other actions.
|
|
5625
|
-
*/
|
|
5626
|
-
tool?: {
|
|
5627
|
-
kind: "cli";
|
|
5628
|
-
/** The template its VM is made from. */
|
|
5629
|
-
base: string;
|
|
5630
|
-
network: "none";
|
|
5631
|
-
/**
|
|
5632
|
-
* The publisher's price per call that answered validly, in micro-USD (millionths of a US dollar); 0 when free.
|
|
5633
|
-
*/
|
|
5634
|
-
price_micro_usd: number;
|
|
5635
|
-
/** The software the tool runs and did not write (the manifest's `tool.upstream`). */
|
|
5636
|
-
upstream: Record<string, unknown>[];
|
|
5637
|
-
/** The bundle path of the tool's notices file. */
|
|
5638
|
-
notices?: string;
|
|
5639
|
-
};
|
|
7783
|
+
tool?: ActionTool;
|
|
5640
7784
|
}
|
|
5641
7785
|
|
|
5642
7786
|
export interface ActionCallRequest {
|
|
@@ -5659,7 +7803,7 @@ export interface ActionResult {
|
|
|
5659
7803
|
object: "action_result";
|
|
5660
7804
|
/** The exact version that ran. */
|
|
5661
7805
|
ref: string;
|
|
5662
|
-
/** Matches the action's output schema. A hosted tool's output file is a `ToolFileOutput
|
|
7806
|
+
/** Matches the action's output schema. A hosted tool's output file is a `ToolFileOutput`, a link. */
|
|
5663
7807
|
output: unknown;
|
|
5664
7808
|
/** HTTP status of the upstream call, for declarative HTTP actions. */
|
|
5665
7809
|
upstream_status?: number;
|
|
@@ -5684,6 +7828,86 @@ export interface ToolCallCost {
|
|
|
5684
7828
|
total: number;
|
|
5685
7829
|
}
|
|
5686
7830
|
|
|
7831
|
+
/** A file name, without directories. */
|
|
7832
|
+
export type ToolFileName = string;
|
|
7833
|
+
|
|
7834
|
+
/**
|
|
7835
|
+
* A hosted tool's file in the node's file store: an upload, a fetched `$url` or an output file. It is kept
|
|
7836
|
+
* 1 hour from when it was written (`expires_at`), counts toward `actions.files_bytes` until then, and is
|
|
7837
|
+
* readable only from its project. `link` is a fresh signed download link that expires at the earlier of
|
|
7838
|
+
* `expires_at` and 1 hour from now.
|
|
7839
|
+
*/
|
|
7840
|
+
export interface ToolFile {
|
|
7841
|
+
object: "tool_file";
|
|
7842
|
+
id: string;
|
|
7843
|
+
name: ToolFileName;
|
|
7844
|
+
bytes: number;
|
|
7845
|
+
sha256: string;
|
|
7846
|
+
/** From the name's extension (`.pdf` is `application/pdf`), else `application/octet-stream`. */
|
|
7847
|
+
content_type: string;
|
|
7848
|
+
created_at: string;
|
|
7849
|
+
expires_at: string;
|
|
7850
|
+
/** The signed download link, as `ToolFileOutput.$link`. */
|
|
7851
|
+
link: string;
|
|
7852
|
+
}
|
|
7853
|
+
|
|
7854
|
+
/**
|
|
7855
|
+
* A hosted tool action's publisher price, from its manifest (`pricing`, b3pack publish check 20). `micro_usd`
|
|
7856
|
+
* is the rate in micro-USD (millionths of a US dollar): per call, per second of the tool's own run, or per MiB
|
|
7857
|
+
* of input; 0 when free. `free_calls` is the calls each calling organization makes free of the price per UTC
|
|
7858
|
+
* month, for the pack.
|
|
7859
|
+
*/
|
|
7860
|
+
export interface ToolPrice {
|
|
7861
|
+
model: "free" | "per_call" | "per_second" | "per_input_mb";
|
|
7862
|
+
micro_usd: number;
|
|
7863
|
+
free_calls: number;
|
|
7864
|
+
}
|
|
7865
|
+
|
|
7866
|
+
/**
|
|
7867
|
+
* What one call of this action costs all in, in micro-USD, from this version's own last calls on this node
|
|
7868
|
+
* (at most the last 100): the price at the median call (the median `run_ms` or input size for a rate), the
|
|
7869
|
+
* median compute, and the floor, at the node's unit prices now. `basis` says what it was taken from.
|
|
7870
|
+
*/
|
|
7871
|
+
export interface ToolAllIn {
|
|
7872
|
+
/** `compute` + `floor` + `price`. */
|
|
7873
|
+
micro_usd: number;
|
|
7874
|
+
compute: number;
|
|
7875
|
+
floor: number;
|
|
7876
|
+
price: number;
|
|
7877
|
+
basis: string;
|
|
7878
|
+
}
|
|
7879
|
+
|
|
7880
|
+
/**
|
|
7881
|
+
* 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.
|
|
7882
|
+
*/
|
|
7883
|
+
export interface ActionTool {
|
|
7884
|
+
kind: "cli";
|
|
7885
|
+
/** The template its VM is made from. */
|
|
7886
|
+
base: string;
|
|
7887
|
+
network: "none";
|
|
7888
|
+
price: ToolPrice;
|
|
7889
|
+
/** `execution.maxInputMb`: the most input file data one call may carry, in MiB. */
|
|
7890
|
+
max_input_mb: number;
|
|
7891
|
+
/** `execution.maxOutputMb`: the most output file data one call may return, in MiB. */
|
|
7892
|
+
max_output_mb: number;
|
|
7893
|
+
/** `execution.maxOutputFiles`: the most output files one call may return. */
|
|
7894
|
+
max_output_files: number;
|
|
7895
|
+
/** The tool's declared error codes (`tool.errors`); empty when it declares none. */
|
|
7896
|
+
errors: string[];
|
|
7897
|
+
/** The software the tool runs and did not write (the manifest's `tool.upstream`). */
|
|
7898
|
+
upstream: Record<string, unknown>[];
|
|
7899
|
+
/** The bundle path of the tool's notices file. */
|
|
7900
|
+
notices?: string;
|
|
7901
|
+
/**
|
|
7902
|
+
* The node's estimate of the time from claim to the tool's command starting, in milliseconds, for this
|
|
7903
|
+
* version's archive: a warm-pool claim plus the copy and the unpack for its size and format, from the
|
|
7904
|
+
* table measured on 2026-11-13 (warm pool, 1 vCPU and 512 MiB).
|
|
7905
|
+
*/
|
|
7906
|
+
start_estimate_ms: number;
|
|
7907
|
+
/** What one call costs all in, or `null` before this version's first call on this node. */
|
|
7908
|
+
all_in: ToolAllIn | null;
|
|
7909
|
+
}
|
|
7910
|
+
|
|
5687
7911
|
export interface TriggerSummary {
|
|
5688
7912
|
ref: string;
|
|
5689
7913
|
pack: string;
|
|
@@ -5855,7 +8079,10 @@ export interface ConnectionCreateRequest {
|
|
|
5855
8079
|
* connection. Without `pack`, list the hosts your own HTTP steps call, or omit it (or give `[]`) for a
|
|
5856
8080
|
* verification-only connection: a connection with no hosts is never injected anywhere, because egress
|
|
5857
8081
|
* injection matches on hosts. It only holds a secret B3OS itself uses, such as a routine webhook's
|
|
5858
|
-
* `verify.secret`.
|
|
8082
|
+
* `verify.secret`. A `basic` connection may also list public IP addresses (IPv4, or IPv6 with or without
|
|
8083
|
+
* brackets, kept in canonical form), such as a proxy given by its address; a private, loopback,
|
|
8084
|
+
* link-local, CGNAT, multicast or metadata address is refused with `422 connection_invalid`, and no other
|
|
8085
|
+
* type lists an IP address.
|
|
5859
8086
|
*/
|
|
5860
8087
|
hosts?: string[];
|
|
5861
8088
|
/** Non-secret configuration the pack's connection declares (for example a Jira site name). */
|
|
@@ -5867,7 +8094,10 @@ export interface ConnectionCreateRequest {
|
|
|
5867
8094
|
export interface ConnectionUpdateRequest {
|
|
5868
8095
|
label?: string;
|
|
5869
8096
|
subject?: string | null;
|
|
5870
|
-
/**
|
|
8097
|
+
/**
|
|
8098
|
+
* Connections without a pack only. `[]` makes the connection verification-only (never injected). The same
|
|
8099
|
+
* rules as on create: a `basic` connection may list public IP addresses, no other type any.
|
|
8100
|
+
*/
|
|
5871
8101
|
hosts?: string[];
|
|
5872
8102
|
params?: Record<string, unknown>;
|
|
5873
8103
|
secret?: ConnectionSecret;
|
|
@@ -6122,6 +8352,14 @@ export interface InferMeta {
|
|
|
6122
8352
|
model_ms?: number;
|
|
6123
8353
|
total_ms?: number;
|
|
6124
8354
|
};
|
|
8355
|
+
/**
|
|
8356
|
+
* 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.
|
|
8357
|
+
*/
|
|
8358
|
+
capture?: {
|
|
8359
|
+
value: "off" | "model";
|
|
8360
|
+
from: "request" | "project" | "org" | "node";
|
|
8361
|
+
clamped: boolean;
|
|
8362
|
+
};
|
|
6125
8363
|
}
|
|
6126
8364
|
|
|
6127
8365
|
export interface ChatCompletion {
|
|
@@ -6183,8 +8421,11 @@ export interface ModelInfo {
|
|
|
6183
8421
|
/**
|
|
6184
8422
|
* 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.
|
|
6185
8423
|
*/
|
|
6186
|
-
alias_of?: string;
|
|
6187
|
-
kind: "chat" | "embedding" | "speech";
|
|
8424
|
+
alias_of?: string;
|
|
8425
|
+
kind: "chat" | "embedding" | "rerank" | "speech";
|
|
8426
|
+
/**
|
|
8427
|
+
* Tokens per request on chat models; on embedding models, tokens per input; on rerank models, tokens per query and document pair.
|
|
8428
|
+
*/
|
|
6188
8429
|
context_length: number | null;
|
|
6189
8430
|
/**
|
|
6190
8431
|
* The output cap of a chat request that sets no `max_tokens` (or `max_completion_tokens`, or Responses'
|
|
@@ -6198,6 +8439,12 @@ export interface ModelInfo {
|
|
|
6198
8439
|
json_schema: boolean;
|
|
6199
8440
|
image_input: boolean;
|
|
6200
8441
|
max_request_bytes: number;
|
|
8442
|
+
/** Embedding models only. Values per vector, and the most `dimensions` takes. */
|
|
8443
|
+
dimensions?: number;
|
|
8444
|
+
/**
|
|
8445
|
+
* Embedding models only. The fewest values `dimensions` takes; the same as `dimensions` when the model offers no shorter vectors.
|
|
8446
|
+
*/
|
|
8447
|
+
min_dimensions?: number;
|
|
6201
8448
|
limits: {
|
|
6202
8449
|
/**
|
|
6203
8450
|
* Tokens per minute for your organization (its own value from the node's budget snapshot, else the node's default).
|
|
@@ -6222,12 +8469,28 @@ export interface ModelList {
|
|
|
6222
8469
|
}
|
|
6223
8470
|
|
|
6224
8471
|
export interface EmbeddingRequest {
|
|
8472
|
+
/** An embedding model's ID from `GET /v1/infer/models`. */
|
|
6225
8473
|
model: string;
|
|
6226
|
-
|
|
8474
|
+
/** The text to embed. Arrays of token IDs are `400 unsupported_parameter`. */
|
|
8475
|
+
input: string | string[];
|
|
6227
8476
|
/** @default "float" */
|
|
6228
8477
|
encoding_format?: "float" | "base64";
|
|
8478
|
+
/** Values per vector, from the model's `b3os.min_dimensions` to its `b3os.dimensions`. */
|
|
6229
8479
|
dimensions?: number;
|
|
8480
|
+
/** Accepted and ignored. */
|
|
6230
8481
|
user?: string;
|
|
8482
|
+
/**
|
|
8483
|
+
* B3OS extension. `query` puts the model's query prompt before each input.
|
|
8484
|
+
* @default "document"
|
|
8485
|
+
*/
|
|
8486
|
+
input_type?: "document" | "query";
|
|
8487
|
+
/** B3OS extension. The task the query prompt describes; only with `input_type` `query`. */
|
|
8488
|
+
instruction?: string;
|
|
8489
|
+
/**
|
|
8490
|
+
* B3OS extension. `end` cuts an input longer than the model's `context_length` at the end; `none` refuses it.
|
|
8491
|
+
* @default "none"
|
|
8492
|
+
*/
|
|
8493
|
+
truncate?: "none" | "end";
|
|
6231
8494
|
}
|
|
6232
8495
|
|
|
6233
8496
|
export interface EmbeddingList {
|
|
@@ -6242,6 +8505,78 @@ export interface EmbeddingList {
|
|
|
6242
8505
|
prompt_tokens: number;
|
|
6243
8506
|
total_tokens: number;
|
|
6244
8507
|
};
|
|
8508
|
+
b3os?: EmbeddingMeta;
|
|
8509
|
+
}
|
|
8510
|
+
|
|
8511
|
+
/** B3OS extension; OpenAI SDKs ignore it. */
|
|
8512
|
+
export interface EmbeddingMeta {
|
|
8513
|
+
route: "local";
|
|
8514
|
+
node: string;
|
|
8515
|
+
/** Values per vector. */
|
|
8516
|
+
dimensions: number;
|
|
8517
|
+
/** Every vector has length 1. */
|
|
8518
|
+
normalized: true;
|
|
8519
|
+
/** Server-side milliseconds from the request head. */
|
|
8520
|
+
timing: {
|
|
8521
|
+
model_ms?: number;
|
|
8522
|
+
total_ms?: number;
|
|
8523
|
+
};
|
|
8524
|
+
}
|
|
8525
|
+
|
|
8526
|
+
export interface RerankRequest {
|
|
8527
|
+
/** A rerank model's ID from `GET /v1/infer/models`. */
|
|
8528
|
+
model: string;
|
|
8529
|
+
/** At most 2,048 tokens. */
|
|
8530
|
+
query: string;
|
|
8531
|
+
documents: Array<
|
|
8532
|
+
| string
|
|
8533
|
+
| {
|
|
8534
|
+
text: string;
|
|
8535
|
+
}
|
|
8536
|
+
>;
|
|
8537
|
+
/** How many results to return; default every document. */
|
|
8538
|
+
top_n?: number;
|
|
8539
|
+
/**
|
|
8540
|
+
* Each document is cut at the end to this many tokens.
|
|
8541
|
+
* @default 4096
|
|
8542
|
+
*/
|
|
8543
|
+
max_tokens_per_doc?: number;
|
|
8544
|
+
/**
|
|
8545
|
+
* B3OS extension. Each result also carries its document.
|
|
8546
|
+
* @default false
|
|
8547
|
+
*/
|
|
8548
|
+
return_documents?: boolean;
|
|
8549
|
+
/** B3OS extension. The task the model's query prompt describes. */
|
|
8550
|
+
instruction?: string;
|
|
8551
|
+
}
|
|
8552
|
+
|
|
8553
|
+
export interface RerankList {
|
|
8554
|
+
/** The request ID. */
|
|
8555
|
+
id: string;
|
|
8556
|
+
model: string;
|
|
8557
|
+
/** Highest `relevance_score` first. */
|
|
8558
|
+
results: {
|
|
8559
|
+
/** The document's position in `documents`. */
|
|
8560
|
+
index: number;
|
|
8561
|
+
relevance_score: number;
|
|
8562
|
+
/** With `return_documents: true`: the document as sent. */
|
|
8563
|
+
document?: {
|
|
8564
|
+
text: string;
|
|
8565
|
+
};
|
|
8566
|
+
}[];
|
|
8567
|
+
usage: {
|
|
8568
|
+
total_tokens: number;
|
|
8569
|
+
};
|
|
8570
|
+
/** Cohere's metadata. */
|
|
8571
|
+
meta: {
|
|
8572
|
+
api_version: {
|
|
8573
|
+
version: "2";
|
|
8574
|
+
};
|
|
8575
|
+
billed_units: {
|
|
8576
|
+
input_tokens: number;
|
|
8577
|
+
};
|
|
8578
|
+
};
|
|
8579
|
+
b3os?: InferMeta;
|
|
6245
8580
|
}
|
|
6246
8581
|
|
|
6247
8582
|
/** OpenAI speech parameters; `null` means unset on the optional ones. */
|
|
@@ -6944,11 +9279,22 @@ export interface RegistryPackVersion {
|
|
|
6944
9279
|
alg: "ed25519";
|
|
6945
9280
|
kid: string;
|
|
6946
9281
|
sig: string;
|
|
9282
|
+
/**
|
|
9283
|
+
* An org-private version only: the organization's public key for `kid` (`org.<org>#g<generation>`),
|
|
9284
|
+
* base64url without padding of its 32 bytes. A node verifies `sig` with it only for a pack in that same
|
|
9285
|
+
* `org.` namespace, for that organization; a listed pack never verifies with a record's key.
|
|
9286
|
+
*/
|
|
9287
|
+
public_key?: string;
|
|
6947
9288
|
};
|
|
6948
9289
|
publisher: RegistryPublisher;
|
|
6949
9290
|
size_bytes: number;
|
|
6950
9291
|
published_at: string;
|
|
9292
|
+
/** A yanked version resolves only when pinned exactly (`@1.2.0`); a range or major (`@1`) skips it. */
|
|
6951
9293
|
yanked: boolean;
|
|
9294
|
+
/**
|
|
9295
|
+
* 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.
|
|
9296
|
+
*/
|
|
9297
|
+
dev?: boolean;
|
|
6952
9298
|
download_url: string;
|
|
6953
9299
|
/**
|
|
6954
9300
|
* 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.
|
|
@@ -6964,6 +9310,129 @@ export interface RegistryBlob {
|
|
|
6964
9310
|
created_at: string;
|
|
6965
9311
|
}
|
|
6966
9312
|
|
|
9313
|
+
export interface RegistryYankRequest {
|
|
9314
|
+
/** `true` yanks the version, `false` restores it. */
|
|
9315
|
+
yanked: boolean;
|
|
9316
|
+
}
|
|
9317
|
+
|
|
9318
|
+
/**
|
|
9319
|
+
* What to block. `publisher` is a namespace; `pack` (`<namespace>/<name>`, in `publisher`) is required for the
|
|
9320
|
+
* scopes `pack`, `version` and `action`; `version` (exact) for `version`, and optionally for `action` (absent:
|
|
9321
|
+
* the action in every version); `action` (an action key) for `action`.
|
|
9322
|
+
*/
|
|
9323
|
+
export interface ToolBlockCreateRequest {
|
|
9324
|
+
scope: "publisher" | "pack" | "version" | "action";
|
|
9325
|
+
publisher: string;
|
|
9326
|
+
pack?: string;
|
|
9327
|
+
version?: string;
|
|
9328
|
+
action?: string;
|
|
9329
|
+
/** Why, for B3's own records. Never sent to nodes or shown to the publisher. */
|
|
9330
|
+
reason: string;
|
|
9331
|
+
/**
|
|
9332
|
+
* Who asked, for B3's own records (a ticket, a notice). Never sent to nodes or shown to the publisher.
|
|
9333
|
+
*/
|
|
9334
|
+
requested_by: string;
|
|
9335
|
+
/** The sha256 of the evidence B3 keeps elsewhere. */
|
|
9336
|
+
evidence_sha256?: string;
|
|
9337
|
+
}
|
|
9338
|
+
|
|
9339
|
+
export interface ToolBlockLift {
|
|
9340
|
+
lifted_at: string;
|
|
9341
|
+
/** An `io.b3os` key id (`io.b3os#<label>`). */
|
|
9342
|
+
kid: string;
|
|
9343
|
+
sig: string;
|
|
9344
|
+
}
|
|
9345
|
+
|
|
9346
|
+
/**
|
|
9347
|
+
* 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.
|
|
9348
|
+
*/
|
|
9349
|
+
export interface ToolBlock {
|
|
9350
|
+
object: "tool_block";
|
|
9351
|
+
id: string;
|
|
9352
|
+
scope: "publisher" | "pack" | "version" | "action";
|
|
9353
|
+
publisher: string;
|
|
9354
|
+
pack: string | null;
|
|
9355
|
+
version: string | null;
|
|
9356
|
+
action: string | null;
|
|
9357
|
+
reason: string;
|
|
9358
|
+
requested_by: string;
|
|
9359
|
+
evidence_sha256: string | null;
|
|
9360
|
+
created_at: string;
|
|
9361
|
+
/** The API key (`key_...`) or dashboard user (`usr_...`) that placed the block. */
|
|
9362
|
+
created_by: string;
|
|
9363
|
+
lift: ToolBlockLift | null;
|
|
9364
|
+
}
|
|
9365
|
+
|
|
9366
|
+
export type ToolBlockList = Omit<ListEnvelope, "data"> & {
|
|
9367
|
+
data: ToolBlock[];
|
|
9368
|
+
};
|
|
9369
|
+
|
|
9370
|
+
/** An option's value; for an enum option, one of its values (`x-b3os-options`). */
|
|
9371
|
+
export type SettingValue = string | number | boolean;
|
|
9372
|
+
|
|
9373
|
+
export interface SettingRequest {
|
|
9374
|
+
value: SettingValue;
|
|
9375
|
+
}
|
|
9376
|
+
|
|
9377
|
+
/** One option set for one project or organization. */
|
|
9378
|
+
export interface StoredSetting {
|
|
9379
|
+
/** The option id. */
|
|
9380
|
+
id: string;
|
|
9381
|
+
object: "setting";
|
|
9382
|
+
value: SettingValue;
|
|
9383
|
+
scope: "project" | "org";
|
|
9384
|
+
/** The project (`prj_`) or organization (`org_`) it is set for. */
|
|
9385
|
+
scope_id: string;
|
|
9386
|
+
updated_at: string;
|
|
9387
|
+
/** The user (`usr_`) or key (`key_`) that last set it. */
|
|
9388
|
+
updated_by: string;
|
|
9389
|
+
}
|
|
9390
|
+
|
|
9391
|
+
export type StoredSettingList = Omit<ListEnvelope, "data"> & {
|
|
9392
|
+
data: StoredSetting[];
|
|
9393
|
+
};
|
|
9394
|
+
|
|
9395
|
+
/**
|
|
9396
|
+
* `isolated`: the app's server gets only the cookies its own address set, plus the names in `script`.
|
|
9397
|
+
* `shared`: the browser's cookies pass, except Cloudflare's and B3OS's own names and values that are not plain
|
|
9398
|
+
* (a space, comma, quote or backslash).
|
|
9399
|
+
*/
|
|
9400
|
+
export type AppHostCookieMode = "isolated" | "shared";
|
|
9401
|
+
|
|
9402
|
+
export interface AppHostCookies {
|
|
9403
|
+
mode: AppHostCookieMode;
|
|
9404
|
+
/** Cookies a page script writes and the app's server reads, by name. */
|
|
9405
|
+
script: string[];
|
|
9406
|
+
}
|
|
9407
|
+
|
|
9408
|
+
export interface PortHostRequest {
|
|
9409
|
+
/**
|
|
9410
|
+
* How long the link works, in seconds.
|
|
9411
|
+
* @default 600
|
|
9412
|
+
*/
|
|
9413
|
+
ttl_s?: number;
|
|
9414
|
+
/**
|
|
9415
|
+
* 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).
|
|
9416
|
+
* @default false
|
|
9417
|
+
*/
|
|
9418
|
+
rotate?: boolean;
|
|
9419
|
+
cookies?: AppHostCookies;
|
|
9420
|
+
}
|
|
9421
|
+
|
|
9422
|
+
export interface PortHost {
|
|
9423
|
+
object: "port_host";
|
|
9424
|
+
sandbox_id: string;
|
|
9425
|
+
port: number;
|
|
9426
|
+
/** `<port>-sbx-<id>.b3os.io`: the host, safe to show. */
|
|
9427
|
+
host: string;
|
|
9428
|
+
/** `https://<host>/?b3os_link=<token>`. Share it as a secret. */
|
|
9429
|
+
url: string;
|
|
9430
|
+
/** When the link stops working (a browser that opened it stays in for 24 hours from its visit). */
|
|
9431
|
+
expires_at: string;
|
|
9432
|
+
rotated: boolean;
|
|
9433
|
+
cookies: AppHostCookies;
|
|
9434
|
+
}
|
|
9435
|
+
|
|
6967
9436
|
/**
|
|
6968
9437
|
* How the request reached B3OS: `edge` (through beta-api.b3os.org or the dashboard; forwarded to the node, or
|
|
6969
9438
|
* answered by the edge itself), `uds` (the node's Unix socket), `tcp` (the node's loopback TCP listener) or
|
|
@@ -7036,8 +9505,30 @@ export interface RequestRecord {
|
|
|
7036
9505
|
trace_id: string | null;
|
|
7037
9506
|
user_agent: string | null;
|
|
7038
9507
|
source: RequestSource;
|
|
9508
|
+
action?: RequestAction;
|
|
7039
9509
|
}
|
|
7040
9510
|
|
|
9511
|
+
/**
|
|
9512
|
+
* The pack action the request ran: a `POST /v1/actions/call`, or one `tools/call` of a sandbox's MCP server
|
|
9513
|
+
* (`POST /v1/actions/mcp`, with `tool` set). `null` for any other request, and absent from records written
|
|
9514
|
+
* before node release 1118. A tool call answers HTTP 200 whether or not the action succeeded, so its own outcome
|
|
9515
|
+
* is here: `status_code` 200, or the status of the problem that refused or failed it. For a product tool (node
|
|
9516
|
+
* release 1119: `browser_*`, `vision_*`, `render_*`), `pack` is the toolset (`browser`, `vision` or `render`)
|
|
9517
|
+
* and `ref` is `<product>/<operationId>` of the product request the tool made (`vision/visionAct`), which has a
|
|
9518
|
+
* record of its own on the sandbox's connection, with the same `trace_id` when the call sent a `traceparent`.
|
|
9519
|
+
*/
|
|
9520
|
+
export type RequestAction = {
|
|
9521
|
+
/**
|
|
9522
|
+
* `<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.
|
|
9523
|
+
*/
|
|
9524
|
+
ref: string;
|
|
9525
|
+
pack: string;
|
|
9526
|
+
/** The MCP tool name, for a `tools/call`; `null` for `POST /v1/actions/call`. */
|
|
9527
|
+
tool: string | null;
|
|
9528
|
+
status_code: number;
|
|
9529
|
+
error_code: string | null;
|
|
9530
|
+
} | null;
|
|
9531
|
+
|
|
7041
9532
|
export type RequestRecordList = Omit<ListEnvelope, "data"> & {
|
|
7042
9533
|
data: RequestRecord[];
|
|
7043
9534
|
};
|
|
@@ -7429,6 +9920,17 @@ export interface VisionListSessionsParams {
|
|
|
7429
9920
|
status?: SessionStatus;
|
|
7430
9921
|
}
|
|
7431
9922
|
|
|
9923
|
+
/** Parameters of `listAliases`. */
|
|
9924
|
+
export interface RenderListAliasesParams {
|
|
9925
|
+
/**
|
|
9926
|
+
* Page size, from 1 to 100.
|
|
9927
|
+
* @default 20
|
|
9928
|
+
*/
|
|
9929
|
+
limit?: number;
|
|
9930
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
9931
|
+
cursor?: string;
|
|
9932
|
+
}
|
|
9933
|
+
|
|
7432
9934
|
/** Parameters of `listBackgrounds`. */
|
|
7433
9935
|
export interface RenderListBackgroundsParams {
|
|
7434
9936
|
/** Only this pack's backgrounds (`GET /v1/render/backgrounds/packs` lists the packs). */
|
|
@@ -7508,6 +10010,15 @@ export interface SandboxesListSandboxesParams {
|
|
|
7508
10010
|
cursor?: string;
|
|
7509
10011
|
/** Only sandboxes with this status. */
|
|
7510
10012
|
status?: SandboxStatus;
|
|
10013
|
+
/** Only sandboxes with this `owner` (`project`, the services of applications, or `key`). */
|
|
10014
|
+
owner?: SandboxOwner;
|
|
10015
|
+
/** Only the sandboxes this project's service started, directly or not (`root`). */
|
|
10016
|
+
root?: string;
|
|
10017
|
+
/**
|
|
10018
|
+
* Only sandboxes this key created (`created_by_key`). With `owner=project`: the services a key deployed,
|
|
10019
|
+
* which keep running after it is revoked.
|
|
10020
|
+
*/
|
|
10021
|
+
created_by_key?: string;
|
|
7511
10022
|
/**
|
|
7512
10023
|
* Only sandboxes whose `metadata` holds each of these pairs, as `metadata[<key>]=<value>`: up to 4, all of
|
|
7513
10024
|
* which must match exactly. Keys follow the `metadata` key rule (1 to 40 of `A-Z a-z 0-9 _ . : -`).
|
|
@@ -7526,6 +10037,58 @@ export interface SandboxesListSnapshotsParams {
|
|
|
7526
10037
|
cursor?: string;
|
|
7527
10038
|
}
|
|
7528
10039
|
|
|
10040
|
+
/** Parameters of `listSwarms`. */
|
|
10041
|
+
export interface SandboxesListSwarmsParams {
|
|
10042
|
+
/**
|
|
10043
|
+
* Page size, from 1 to 100.
|
|
10044
|
+
* @default 20
|
|
10045
|
+
*/
|
|
10046
|
+
limit?: number;
|
|
10047
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
10048
|
+
cursor?: string;
|
|
10049
|
+
/** Only swarms with this status. */
|
|
10050
|
+
status?: JobStatus;
|
|
10051
|
+
}
|
|
10052
|
+
|
|
10053
|
+
/** Parameters of `getSwarm`. */
|
|
10054
|
+
export interface SandboxesGetSwarmParams {
|
|
10055
|
+
/**
|
|
10056
|
+
* Seconds to wait for the job to finish before responding, from 0 to 60. If it finishes in time the response
|
|
10057
|
+
* is `200` with the finished job; otherwise `202` with the job as it is, a `Location` to poll and
|
|
10058
|
+
* `Retry-After`. `0` (the default) returns immediately.
|
|
10059
|
+
* @default 0
|
|
10060
|
+
*/
|
|
10061
|
+
wait?: number;
|
|
10062
|
+
}
|
|
10063
|
+
|
|
10064
|
+
/** Parameters of `listSwarmChildren`. */
|
|
10065
|
+
export interface SandboxesListSwarmChildrenParams {
|
|
10066
|
+
/**
|
|
10067
|
+
* Page size, from 1 to 100.
|
|
10068
|
+
* @default 20
|
|
10069
|
+
*/
|
|
10070
|
+
limit?: number;
|
|
10071
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
10072
|
+
cursor?: string;
|
|
10073
|
+
/** Only children with this status. */
|
|
10074
|
+
status?: "queued" | "running" | "exited" | "timed_out" | "failed" | "canceled";
|
|
10075
|
+
}
|
|
10076
|
+
|
|
10077
|
+
/** Parameters of `listVolumes`. */
|
|
10078
|
+
export interface SandboxesListVolumesParams {
|
|
10079
|
+
/**
|
|
10080
|
+
* Page size, from 1 to 100.
|
|
10081
|
+
* @default 20
|
|
10082
|
+
*/
|
|
10083
|
+
limit?: number;
|
|
10084
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
10085
|
+
cursor?: string;
|
|
10086
|
+
/** Only the volume with this name. */
|
|
10087
|
+
name?: string;
|
|
10088
|
+
/** Only volumes in this status. */
|
|
10089
|
+
status?: "available" | "attached" | "deleted";
|
|
10090
|
+
}
|
|
10091
|
+
|
|
7529
10092
|
/** Parameters of `deleteFile`. */
|
|
7530
10093
|
export interface SandboxesDeleteFileParams {
|
|
7531
10094
|
/** Absolute path inside the sandbox. */
|
|
@@ -7613,6 +10176,71 @@ export interface SandboxesListRequestsParams {
|
|
|
7613
10176
|
/** Only requests of this W3C trace (the trace id of their `traceparent`). */
|
|
7614
10177
|
trace_id?: string;
|
|
7615
10178
|
since?: string;
|
|
10179
|
+
/**
|
|
10180
|
+
* 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).
|
|
10181
|
+
*/
|
|
10182
|
+
pack?: string;
|
|
10183
|
+
}
|
|
10184
|
+
|
|
10185
|
+
/** Parameters of `getImage`. */
|
|
10186
|
+
export interface ImagesGetImageParams {
|
|
10187
|
+
/**
|
|
10188
|
+
* Hold the answer up to this many seconds until the image is `ready`, `failed` or `evicted`.
|
|
10189
|
+
* @default 0
|
|
10190
|
+
*/
|
|
10191
|
+
wait?: number;
|
|
10192
|
+
}
|
|
10193
|
+
|
|
10194
|
+
/** Parameters of `listAgents`. */
|
|
10195
|
+
export interface AgentsListAgentsParams {
|
|
10196
|
+
/**
|
|
10197
|
+
* Page size, from 1 to 100.
|
|
10198
|
+
* @default 20
|
|
10199
|
+
*/
|
|
10200
|
+
limit?: number;
|
|
10201
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
10202
|
+
cursor?: string;
|
|
10203
|
+
}
|
|
10204
|
+
|
|
10205
|
+
/** Parameters of `listInstances`. */
|
|
10206
|
+
export interface AgentsListInstancesParams {
|
|
10207
|
+
/**
|
|
10208
|
+
* Page size, from 1 to 100.
|
|
10209
|
+
* @default 20
|
|
10210
|
+
*/
|
|
10211
|
+
limit?: number;
|
|
10212
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
10213
|
+
cursor?: string;
|
|
10214
|
+
/** Only instances with this status. */
|
|
10215
|
+
status?: AgentInstanceStatus;
|
|
10216
|
+
}
|
|
10217
|
+
|
|
10218
|
+
/** Parameters of `listInstanceEvents`. */
|
|
10219
|
+
export interface AgentsListInstanceEventsParams {
|
|
10220
|
+
/**
|
|
10221
|
+
* Page size, from 1 to 100.
|
|
10222
|
+
* @default 20
|
|
10223
|
+
*/
|
|
10224
|
+
limit?: number;
|
|
10225
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
10226
|
+
cursor?: string;
|
|
10227
|
+
}
|
|
10228
|
+
|
|
10229
|
+
/** Parameters of `listSessions`. */
|
|
10230
|
+
export interface AgentsListSessionsParams {
|
|
10231
|
+
/**
|
|
10232
|
+
* Page size, from 1 to 100.
|
|
10233
|
+
* @default 20
|
|
10234
|
+
*/
|
|
10235
|
+
limit?: number;
|
|
10236
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
10237
|
+
cursor?: string;
|
|
10238
|
+
/** Only sessions of this instance. */
|
|
10239
|
+
key?: AgentInstanceKey;
|
|
10240
|
+
/** Only sessions of this conversation. */
|
|
10241
|
+
conversation?: string;
|
|
10242
|
+
/** Only sessions with this status. */
|
|
10243
|
+
status?: JobStatus;
|
|
7616
10244
|
}
|
|
7617
10245
|
|
|
7618
10246
|
/** Parameters of `listRoutines`. */
|
|
@@ -7678,12 +10306,44 @@ export interface RoutinesListVersionsParams {
|
|
|
7678
10306
|
cursor?: string;
|
|
7679
10307
|
}
|
|
7680
10308
|
|
|
10309
|
+
/** Parameters of `listListeners`. */
|
|
10310
|
+
export interface ListenersListListenersParams {
|
|
10311
|
+
/**
|
|
10312
|
+
* Page size, from 1 to 100.
|
|
10313
|
+
* @default 20
|
|
10314
|
+
*/
|
|
10315
|
+
limit?: number;
|
|
10316
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
10317
|
+
cursor?: string;
|
|
10318
|
+
/** Only listeners in this status. */
|
|
10319
|
+
status?: ListenerStatus;
|
|
10320
|
+
}
|
|
10321
|
+
|
|
10322
|
+
/** Parameters of `listEvents`. */
|
|
10323
|
+
export interface ListenersListEventsParams {
|
|
10324
|
+
/**
|
|
10325
|
+
* Page size, from 1 to 100.
|
|
10326
|
+
* @default 20
|
|
10327
|
+
*/
|
|
10328
|
+
limit?: number;
|
|
10329
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
10330
|
+
cursor?: string;
|
|
10331
|
+
/** Only events in this status. */
|
|
10332
|
+
status?: ListenerEventStatus;
|
|
10333
|
+
}
|
|
10334
|
+
|
|
7681
10335
|
/** Parameters of `describe`. */
|
|
7682
10336
|
export interface ActionsDescribeParams {
|
|
7683
10337
|
/** `<namespace>/<name>/<action>@<version>`; the version may be exact (`1.0.0`) or a major (`1`). */
|
|
7684
10338
|
ref: ActionRef;
|
|
7685
10339
|
}
|
|
7686
10340
|
|
|
10341
|
+
/** Parameters of `uploadFile`. */
|
|
10342
|
+
export interface ActionsUploadFileParams {
|
|
10343
|
+
/** The file's name, which the tool sees at `/in/<field>/<name>`. */
|
|
10344
|
+
name: ToolFileName;
|
|
10345
|
+
}
|
|
10346
|
+
|
|
7687
10347
|
/** Parameters of `listPacks`. */
|
|
7688
10348
|
export interface ActionsListPacksParams {
|
|
7689
10349
|
/** Words to search for in pack titles and descriptions. */
|
|
@@ -7715,6 +10375,17 @@ export interface ActionsGetPackToolsParams {
|
|
|
7715
10375
|
if_none_match?: string;
|
|
7716
10376
|
}
|
|
7717
10377
|
|
|
10378
|
+
/** Parameters of `listToolBlocks`. */
|
|
10379
|
+
export interface PlatformListToolBlocksParams {
|
|
10380
|
+
/**
|
|
10381
|
+
* Page size, from 1 to 100.
|
|
10382
|
+
* @default 20
|
|
10383
|
+
*/
|
|
10384
|
+
limit?: number;
|
|
10385
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
10386
|
+
cursor?: string;
|
|
10387
|
+
}
|
|
10388
|
+
|
|
7718
10389
|
/** Parameters of `listRegistryPacks`. */
|
|
7719
10390
|
export interface PlatformListRegistryPacksParams {
|
|
7720
10391
|
/**
|
|
@@ -7800,6 +10471,42 @@ export interface InferListVoicesParams {
|
|
|
7800
10471
|
model?: string;
|
|
7801
10472
|
}
|
|
7802
10473
|
|
|
10474
|
+
/** Parameters of `createChatCompletion` (header parameters are sent as their `X-B3OS-*` headers). */
|
|
10475
|
+
export interface InferCreateChatCompletionParams {
|
|
10476
|
+
/**
|
|
10477
|
+
* `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`.
|
|
10478
|
+
*/
|
|
10479
|
+
capture_content?: "off";
|
|
10480
|
+
/**
|
|
10481
|
+
* 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`.
|
|
10482
|
+
*/
|
|
10483
|
+
replay_of?: string;
|
|
10484
|
+
}
|
|
10485
|
+
|
|
10486
|
+
/** Parameters of `createResponse` (header parameters are sent as their `X-B3OS-*` headers). */
|
|
10487
|
+
export interface InferCreateResponseParams {
|
|
10488
|
+
/**
|
|
10489
|
+
* `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`.
|
|
10490
|
+
*/
|
|
10491
|
+
capture_content?: "off";
|
|
10492
|
+
/**
|
|
10493
|
+
* 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`.
|
|
10494
|
+
*/
|
|
10495
|
+
replay_of?: string;
|
|
10496
|
+
}
|
|
10497
|
+
|
|
10498
|
+
/** Parameters of `createMessage` (header parameters are sent as their `X-B3OS-*` headers). */
|
|
10499
|
+
export interface InferCreateMessageParams {
|
|
10500
|
+
/**
|
|
10501
|
+
* `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`.
|
|
10502
|
+
*/
|
|
10503
|
+
capture_content?: "off";
|
|
10504
|
+
/**
|
|
10505
|
+
* 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`.
|
|
10506
|
+
*/
|
|
10507
|
+
replay_of?: string;
|
|
10508
|
+
}
|
|
10509
|
+
|
|
7803
10510
|
/** Parameters of `listKeys`. */
|
|
7804
10511
|
export interface PlatformListKeysParams {
|
|
7805
10512
|
/**
|
|
@@ -7843,6 +10550,10 @@ export interface PlatformListUsageRecordsParams {
|
|
|
7843
10550
|
product?: string;
|
|
7844
10551
|
unit?: string;
|
|
7845
10552
|
key_id?: string;
|
|
10553
|
+
/**
|
|
10554
|
+
* 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.
|
|
10555
|
+
*/
|
|
10556
|
+
sandbox_id?: string;
|
|
7846
10557
|
request_id?: string;
|
|
7847
10558
|
}
|
|
7848
10559
|
|
|
@@ -7873,6 +10584,10 @@ export interface PlatformListRequestsParams {
|
|
|
7873
10584
|
*/
|
|
7874
10585
|
trace_id?: string;
|
|
7875
10586
|
since?: string;
|
|
10587
|
+
/**
|
|
10588
|
+
* 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).
|
|
10589
|
+
*/
|
|
10590
|
+
pack?: string;
|
|
7876
10591
|
}
|
|
7877
10592
|
|
|
7878
10593
|
/** Parameters of `listDeliveries`. */
|