@b3os/sdk 0.0.0-stage → 0.0.1
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/LICENSE +202 -0
- package/README.md +233 -2
- package/dist/cjs/core/client.d.ts +165 -0
- package/dist/cjs/core/client.js +825 -0
- package/dist/cjs/core/client.js.map +1 -0
- package/dist/cjs/core/errors.d.ts +101 -0
- package/dist/cjs/core/errors.js +249 -0
- package/dist/cjs/core/errors.js.map +1 -0
- package/dist/cjs/core/index.d.ts +12 -0
- package/dist/cjs/core/index.js +42 -0
- package/dist/cjs/core/index.js.map +1 -0
- package/dist/cjs/core/jobs.d.ts +31 -0
- package/dist/cjs/core/jobs.js +72 -0
- package/dist/cjs/core/jobs.js.map +1 -0
- package/dist/cjs/core/namespace.d.ts +7 -0
- package/dist/cjs/core/namespace.js +13 -0
- package/dist/cjs/core/namespace.js.map +1 -0
- package/dist/cjs/core/op.d.ts +47 -0
- package/dist/cjs/core/op.js +5 -0
- package/dist/cjs/core/op.js.map +1 -0
- package/dist/cjs/core/promise.d.ts +106 -0
- package/dist/cjs/core/promise.js +200 -0
- package/dist/cjs/core/promise.js.map +1 -0
- package/dist/cjs/core/response.d.ts +54 -0
- package/dist/cjs/core/response.js +92 -0
- package/dist/cjs/core/response.js.map +1 -0
- package/dist/cjs/core/sse.d.ts +79 -0
- package/dist/cjs/core/sse.js +291 -0
- package/dist/cjs/core/sse.js.map +1 -0
- package/dist/cjs/core/timing.d.ts +20 -0
- package/dist/cjs/core/timing.js +96 -0
- package/dist/cjs/core/timing.js.map +1 -0
- package/dist/cjs/core/transport.d.ts +80 -0
- package/dist/cjs/core/transport.js +472 -0
- package/dist/cjs/core/transport.js.map +1 -0
- package/dist/cjs/core/util.d.ts +25 -0
- package/dist/cjs/core/util.js +142 -0
- package/dist/cjs/core/util.js.map +1 -0
- package/dist/cjs/core/ws.d.ts +52 -0
- package/dist/cjs/core/ws.js +181 -0
- package/dist/cjs/core/ws.js.map +1 -0
- package/dist/cjs/generated/client.d.ts +62 -0
- package/dist/cjs/generated/client.js +130 -0
- package/dist/cjs/generated/client.js.map +1 -0
- package/dist/cjs/generated/errors.d.ts +4 -0
- package/dist/cjs/generated/errors.js +160 -0
- package/dist/cjs/generated/errors.js.map +1 -0
- package/dist/cjs/generated/ids.d.ts +114 -0
- package/dist/cjs/generated/ids.js +47 -0
- package/dist/cjs/generated/ids.js.map +1 -0
- package/dist/cjs/generated/jobs.d.ts +10 -0
- package/dist/cjs/generated/jobs.js +24 -0
- package/dist/cjs/generated/jobs.js.map +1 -0
- package/dist/cjs/generated/ns/actions.d.ts +161 -0
- package/dist/cjs/generated/ns/actions.js +304 -0
- package/dist/cjs/generated/ns/actions.js.map +1 -0
- package/dist/cjs/generated/ns/infer.d.ts +190 -0
- package/dist/cjs/generated/ns/infer.js +253 -0
- package/dist/cjs/generated/ns/infer.js.map +1 -0
- package/dist/cjs/generated/ns/keys.d.ts +76 -0
- package/dist/cjs/generated/ns/keys.js +144 -0
- package/dist/cjs/generated/ns/keys.js.map +1 -0
- package/dist/cjs/generated/ns/limits.d.ts +22 -0
- package/dist/cjs/generated/ns/limits.js +32 -0
- package/dist/cjs/generated/ns/limits.js.map +1 -0
- package/dist/cjs/generated/ns/orgs.d.ts +38 -0
- package/dist/cjs/generated/ns/orgs.js +68 -0
- package/dist/cjs/generated/ns/orgs.js.map +1 -0
- package/dist/cjs/generated/ns/projects.d.ts +57 -0
- package/dist/cjs/generated/ns/projects.js +115 -0
- package/dist/cjs/generated/ns/projects.js.map +1 -0
- package/dist/cjs/generated/ns/render.d.ts +159 -0
- package/dist/cjs/generated/ns/render.js +299 -0
- package/dist/cjs/generated/ns/render.js.map +1 -0
- package/dist/cjs/generated/ns/requests.d.ts +36 -0
- package/dist/cjs/generated/ns/requests.js +54 -0
- package/dist/cjs/generated/ns/requests.js.map +1 -0
- package/dist/cjs/generated/ns/routines.d.ts +212 -0
- package/dist/cjs/generated/ns/routines.js +419 -0
- package/dist/cjs/generated/ns/routines.js.map +1 -0
- package/dist/cjs/generated/ns/sandboxes.d.ts +318 -0
- package/dist/cjs/generated/ns/sandboxes.js +549 -0
- package/dist/cjs/generated/ns/sandboxes.js.map +1 -0
- package/dist/cjs/generated/ns/usage.d.ts +30 -0
- package/dist/cjs/generated/ns/usage.js +49 -0
- package/dist/cjs/generated/ns/usage.js.map +1 -0
- package/dist/cjs/generated/ns/vault.d.ts +69 -0
- package/dist/cjs/generated/ns/vault.js +122 -0
- package/dist/cjs/generated/ns/vault.js.map +1 -0
- package/dist/cjs/generated/ns/vision.d.ts +376 -0
- package/dist/cjs/generated/ns/vision.js +736 -0
- package/dist/cjs/generated/ns/vision.js.map +1 -0
- package/dist/cjs/generated/ns/webhooks.d.ts +50 -0
- package/dist/cjs/generated/ns/webhooks.js +91 -0
- package/dist/cjs/generated/ns/webhooks.js.map +1 -0
- package/dist/cjs/generated/types.d.ts +4613 -0
- package/dist/cjs/generated/types.js +4 -0
- package/dist/cjs/generated/types.js.map +1 -0
- package/dist/cjs/index.d.ts +22 -0
- package/dist/cjs/index.js +81 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/webhooks.d.ts +19 -0
- package/dist/cjs/webhooks.js +85 -0
- package/dist/cjs/webhooks.js.map +1 -0
- package/dist/esm/core/client.d.ts +165 -0
- package/dist/esm/core/client.js +821 -0
- package/dist/esm/core/client.js.map +1 -0
- package/dist/esm/core/errors.d.ts +101 -0
- package/dist/esm/core/errors.js +239 -0
- package/dist/esm/core/errors.js.map +1 -0
- package/dist/esm/core/index.d.ts +12 -0
- package/dist/esm/core/index.js +15 -0
- package/dist/esm/core/index.js.map +1 -0
- package/dist/esm/core/jobs.d.ts +31 -0
- package/dist/esm/core/jobs.js +66 -0
- package/dist/esm/core/jobs.js.map +1 -0
- package/dist/esm/core/namespace.d.ts +7 -0
- package/dist/esm/core/namespace.js +9 -0
- package/dist/esm/core/namespace.js.map +1 -0
- package/dist/esm/core/op.d.ts +47 -0
- package/dist/esm/core/op.js +4 -0
- package/dist/esm/core/op.js.map +1 -0
- package/dist/esm/core/promise.d.ts +106 -0
- package/dist/esm/core/promise.js +193 -0
- package/dist/esm/core/promise.js.map +1 -0
- package/dist/esm/core/response.d.ts +54 -0
- package/dist/esm/core/response.js +86 -0
- package/dist/esm/core/response.js.map +1 -0
- package/dist/esm/core/sse.d.ts +79 -0
- package/dist/esm/core/sse.js +286 -0
- package/dist/esm/core/sse.js.map +1 -0
- package/dist/esm/core/timing.d.ts +20 -0
- package/dist/esm/core/timing.js +92 -0
- package/dist/esm/core/timing.js.map +1 -0
- package/dist/esm/core/transport.d.ts +80 -0
- package/dist/esm/core/transport.js +465 -0
- package/dist/esm/core/transport.js.map +1 -0
- package/dist/esm/core/util.d.ts +25 -0
- package/dist/esm/core/util.js +128 -0
- package/dist/esm/core/util.js.map +1 -0
- package/dist/esm/core/ws.d.ts +52 -0
- package/dist/esm/core/ws.js +175 -0
- package/dist/esm/core/ws.js.map +1 -0
- package/dist/esm/generated/client.d.ts +62 -0
- package/dist/esm/generated/client.js +126 -0
- package/dist/esm/generated/client.js.map +1 -0
- package/dist/esm/generated/errors.d.ts +4 -0
- package/dist/esm/generated/errors.js +157 -0
- package/dist/esm/generated/errors.js.map +1 -0
- package/dist/esm/generated/ids.d.ts +114 -0
- package/dist/esm/generated/ids.js +42 -0
- package/dist/esm/generated/ids.js.map +1 -0
- package/dist/esm/generated/jobs.d.ts +10 -0
- package/dist/esm/generated/jobs.js +21 -0
- package/dist/esm/generated/jobs.js.map +1 -0
- package/dist/esm/generated/ns/actions.d.ts +161 -0
- package/dist/esm/generated/ns/actions.js +300 -0
- package/dist/esm/generated/ns/actions.js.map +1 -0
- package/dist/esm/generated/ns/infer.d.ts +190 -0
- package/dist/esm/generated/ns/infer.js +249 -0
- package/dist/esm/generated/ns/infer.js.map +1 -0
- package/dist/esm/generated/ns/keys.d.ts +76 -0
- package/dist/esm/generated/ns/keys.js +140 -0
- package/dist/esm/generated/ns/keys.js.map +1 -0
- package/dist/esm/generated/ns/limits.d.ts +22 -0
- package/dist/esm/generated/ns/limits.js +28 -0
- package/dist/esm/generated/ns/limits.js.map +1 -0
- package/dist/esm/generated/ns/orgs.d.ts +38 -0
- package/dist/esm/generated/ns/orgs.js +64 -0
- package/dist/esm/generated/ns/orgs.js.map +1 -0
- package/dist/esm/generated/ns/projects.d.ts +57 -0
- package/dist/esm/generated/ns/projects.js +111 -0
- package/dist/esm/generated/ns/projects.js.map +1 -0
- package/dist/esm/generated/ns/render.d.ts +159 -0
- package/dist/esm/generated/ns/render.js +295 -0
- package/dist/esm/generated/ns/render.js.map +1 -0
- package/dist/esm/generated/ns/requests.d.ts +36 -0
- package/dist/esm/generated/ns/requests.js +50 -0
- package/dist/esm/generated/ns/requests.js.map +1 -0
- package/dist/esm/generated/ns/routines.d.ts +212 -0
- package/dist/esm/generated/ns/routines.js +415 -0
- package/dist/esm/generated/ns/routines.js.map +1 -0
- package/dist/esm/generated/ns/sandboxes.d.ts +318 -0
- package/dist/esm/generated/ns/sandboxes.js +545 -0
- package/dist/esm/generated/ns/sandboxes.js.map +1 -0
- package/dist/esm/generated/ns/usage.d.ts +30 -0
- package/dist/esm/generated/ns/usage.js +45 -0
- package/dist/esm/generated/ns/usage.js.map +1 -0
- package/dist/esm/generated/ns/vault.d.ts +69 -0
- package/dist/esm/generated/ns/vault.js +118 -0
- package/dist/esm/generated/ns/vault.js.map +1 -0
- package/dist/esm/generated/ns/vision.d.ts +376 -0
- package/dist/esm/generated/ns/vision.js +732 -0
- package/dist/esm/generated/ns/vision.js.map +1 -0
- package/dist/esm/generated/ns/webhooks.d.ts +50 -0
- package/dist/esm/generated/ns/webhooks.js +87 -0
- package/dist/esm/generated/ns/webhooks.js.map +1 -0
- package/dist/esm/generated/types.d.ts +4613 -0
- package/dist/esm/generated/types.js +3 -0
- package/dist/esm/generated/types.js.map +1 -0
- package/dist/esm/index.d.ts +22 -0
- package/dist/esm/index.js +28 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/webhooks.d.ts +19 -0
- package/dist/esm/webhooks.js +79 -0
- package/dist/esm/webhooks.js.map +1 -0
- package/package.json +98 -4
- package/src/core/client.ts +1022 -0
- package/src/core/errors.ts +296 -0
- package/src/core/index.ts +45 -0
- package/src/core/jobs.ts +94 -0
- package/src/core/namespace.ts +10 -0
- package/src/core/op.ts +53 -0
- package/src/core/promise.ts +268 -0
- package/src/core/response.ts +115 -0
- package/src/core/sse.ts +305 -0
- package/src/core/timing.ts +106 -0
- package/src/core/transport.ts +489 -0
- package/src/core/util.ts +138 -0
- package/src/core/ws.ts +215 -0
- package/src/generated/client.ts +143 -0
- package/src/generated/errors.ts +313 -0
- package/src/generated/ids.ts +47 -0
- package/src/generated/jobs.ts +25 -0
- package/src/generated/ns/actions.ts +353 -0
- package/src/generated/ns/infer.ts +332 -0
- package/src/generated/ns/keys.ts +152 -0
- package/src/generated/ns/limits.ts +35 -0
- package/src/generated/ns/orgs.ts +77 -0
- package/src/generated/ns/projects.ts +122 -0
- package/src/generated/ns/render.ts +348 -0
- package/src/generated/ns/requests.ts +61 -0
- package/src/generated/ns/routines.ts +474 -0
- package/src/generated/ns/sandboxes.ts +671 -0
- package/src/generated/ns/usage.ts +56 -0
- package/src/generated/ns/vault.ts +136 -0
- package/src/generated/ns/vision.ts +836 -0
- package/src/generated/ns/webhooks.ts +100 -0
- package/src/generated/types.ts +5131 -0
- package/src/index.ts +30 -0
- package/src/webhooks.ts +100 -0
|
@@ -0,0 +1,4613 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Up to 16 string key-value pairs you attach to an object for your own use. Keys are 1 to 40 characters of
|
|
3
|
+
* `A-Z a-z 0-9 _ . : -`; values are at most 500 characters. B3OS never interprets them.
|
|
4
|
+
*/
|
|
5
|
+
export type Metadata = Record<string, string>;
|
|
6
|
+
/**
|
|
7
|
+
* A scope from the catalog (`vision:run`; `x-b3os-scopes`), `<product>:*` for every scope of one product, or `*`
|
|
8
|
+
* for every scope. The build generates `enum` from the catalog, the same list as `dist/scopes.json` plus
|
|
9
|
+
* `<product>:*` and `*`.
|
|
10
|
+
*/
|
|
11
|
+
export type Scope = "vision:read" | "vision:write" | "vision:run" | "render:read" | "render:write" | "render:run" | "sandboxes:read" | "sandboxes:write" | "sandboxes:run" | "routines:read" | "routines:write" | "routines:run" | "actions:read" | "actions:write" | "actions:run" | "infer:read" | "infer:write" | "infer:run" | "vault:read" | "vault:write" | "vault:run" | "platform:read" | "platform:write" | "vision:*" | "render:*" | "sandboxes:*" | "routines:*" | "actions:*" | "infer:*" | "vault:*" | "platform:*" | "*";
|
|
12
|
+
/**
|
|
13
|
+
* Server-side phase durations in milliseconds with microsecond resolution: the same phases as the
|
|
14
|
+
* `Server-Timing` header, keyed `<phase>_ms`. `total_ms` is always present. Phase names are product-specific
|
|
15
|
+
* and documented per operation. Example values in this reference are illustrative, not measurements.
|
|
16
|
+
*/
|
|
17
|
+
export interface Timing {
|
|
18
|
+
total_ms: number;
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
}
|
|
21
|
+
/** One validation problem. */
|
|
22
|
+
export interface ProblemItem {
|
|
23
|
+
/**
|
|
24
|
+
* Where the problem is: a JSON pointer into the request body (`/url`, `/steps/0/uses`), or `#query/<name>`,
|
|
25
|
+
* `#path/<name>` or `#header/<name>` for parameters.
|
|
26
|
+
*/
|
|
27
|
+
pointer: string;
|
|
28
|
+
/** What is wrong there. */
|
|
29
|
+
detail: string;
|
|
30
|
+
}
|
|
31
|
+
/** The limit an error refers to. IDs and current values are listed by `GET /v1/limits`. */
|
|
32
|
+
export interface LimitRef {
|
|
33
|
+
/** Limit ID, such as `vision.scrape.rpm` or `sandboxes.concurrent`. */
|
|
34
|
+
id: string;
|
|
35
|
+
/** The limit's value. */
|
|
36
|
+
limit: number;
|
|
37
|
+
/** What the limit counts, such as `requests`, `sandboxes`, `vcpu` or `MiB`. */
|
|
38
|
+
unit: string;
|
|
39
|
+
/** Window length in seconds for rate limits and quotas. */
|
|
40
|
+
window_s?: number;
|
|
41
|
+
/** Current usage against the limit, when known. */
|
|
42
|
+
current?: number;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* An RFC 9457 problem. `code` is stable and listed in the errors catalog; `type` links to its entry. `detail`
|
|
46
|
+
* is human-readable and may change. Extension members appear only for the codes that document them; ignore
|
|
47
|
+
* members you do not recognize.
|
|
48
|
+
*/
|
|
49
|
+
export interface Problem {
|
|
50
|
+
/** `https://docs.beta.b3os.org/errors#<code>`. */
|
|
51
|
+
type: string;
|
|
52
|
+
/** Short summary of the problem type. */
|
|
53
|
+
title: string;
|
|
54
|
+
/** The HTTP status code, repeated for convenience. */
|
|
55
|
+
status: number;
|
|
56
|
+
/** Stable machine-readable error code from the errors catalog. */
|
|
57
|
+
code: string;
|
|
58
|
+
/** Explanation of this occurrence. Never contains secrets. */
|
|
59
|
+
detail: string;
|
|
60
|
+
/** The request ID (`req_…`) of the request that failed. Include it when you contact support. */
|
|
61
|
+
instance?: string;
|
|
62
|
+
/** Validation problems, one per field (`invalid_request` and the other codes that list `errors`). */
|
|
63
|
+
errors?: ProblemItem[];
|
|
64
|
+
/**
|
|
65
|
+
* Finer-grained cause for codes that document one (`unauthorized`, `forbidden`, `egress_denied`, `upstream_unreachable`, …).
|
|
66
|
+
*/
|
|
67
|
+
reason?: string;
|
|
68
|
+
/** The scope that was missing (`forbidden` with `reason: scope`). */
|
|
69
|
+
required_scope?: string;
|
|
70
|
+
/** Same value as the `Retry-After` header, for clients that only read the body. */
|
|
71
|
+
retry_after_s?: number;
|
|
72
|
+
limit?: LimitRef;
|
|
73
|
+
/** The object's current status, for state conflicts such as `sandbox_not_running`. */
|
|
74
|
+
current_status?: string;
|
|
75
|
+
/** The HTTP status the upstream returned (`upstream_error`, `action_output_invalid`). */
|
|
76
|
+
upstream_status?: number;
|
|
77
|
+
/**
|
|
78
|
+
* The failed step, as a step ID (routines), an index (`act`) or a path such as `beats/2/do/0` (render).
|
|
79
|
+
*/
|
|
80
|
+
step?: string;
|
|
81
|
+
/** The error a pack's error mapping chose (`upstream_error` from pack actions). */
|
|
82
|
+
pack_error?: {
|
|
83
|
+
code: string;
|
|
84
|
+
message: string;
|
|
85
|
+
retryable: boolean;
|
|
86
|
+
};
|
|
87
|
+
[key: string]: unknown;
|
|
88
|
+
}
|
|
89
|
+
/** Returned by deletes. */
|
|
90
|
+
export interface Deleted {
|
|
91
|
+
id: string;
|
|
92
|
+
object: string;
|
|
93
|
+
deleted: true;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* A page of results. Pass `next_cursor` as `cursor` to get the next page; it is `null` on the last page.
|
|
97
|
+
* Pages are ordered newest first unless the operation says otherwise.
|
|
98
|
+
*/
|
|
99
|
+
export interface ListEnvelope {
|
|
100
|
+
object: "list";
|
|
101
|
+
data: unknown[];
|
|
102
|
+
next_cursor: string | null;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* `queued` → `running` → one of the terminal statuses `succeeded`, `failed` or `canceled`. A job never leaves
|
|
106
|
+
* a terminal status.
|
|
107
|
+
*/
|
|
108
|
+
export type JobStatus = "queued" | "running" | "succeeded" | "failed" | "canceled";
|
|
109
|
+
/** How far a job has got, in the job's own unit (pages, items, steps). */
|
|
110
|
+
export interface JobProgress {
|
|
111
|
+
/** Units finished, successfully or not. */
|
|
112
|
+
completed: number;
|
|
113
|
+
/** Units that failed (included in `completed`). */
|
|
114
|
+
failed?: number;
|
|
115
|
+
/** Units expected, when known. */
|
|
116
|
+
total?: number | null;
|
|
117
|
+
/** What is counted, such as `pages`, `items` or `steps`. */
|
|
118
|
+
unit: string;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* The shared shape of every long-running operation (crawls, batch scrapes, videos, routine runs, generic
|
|
122
|
+
* `job_` jobs). Each product's job type extends it and narrows `object` and `result`. `result` is present
|
|
123
|
+
* once the job succeeded; `error` once it failed or was canceled (`job_canceled`). `timing` is final once
|
|
124
|
+
* the job is terminal.
|
|
125
|
+
*/
|
|
126
|
+
export interface Job {
|
|
127
|
+
/** Prefixed ID of the job (`crawl_`, `batch_`, `vid_`, `run_`, `job_`). */
|
|
128
|
+
id: string;
|
|
129
|
+
/** The job type, such as `crawl`, `video`, `routine_run` or `job`. */
|
|
130
|
+
object: string;
|
|
131
|
+
status: JobStatus;
|
|
132
|
+
created_at: string;
|
|
133
|
+
updated_at: string;
|
|
134
|
+
started_at?: string | null;
|
|
135
|
+
finished_at?: string | null;
|
|
136
|
+
progress?: JobProgress;
|
|
137
|
+
/** The job's output. Present once `status` is `succeeded`; the product's job type defines its shape. */
|
|
138
|
+
result?: unknown;
|
|
139
|
+
error?: Problem;
|
|
140
|
+
timing?: Timing;
|
|
141
|
+
/** When the job's results are deleted (retention); `null` while the job is not terminal. */
|
|
142
|
+
expires_at?: string | null;
|
|
143
|
+
metadata?: Metadata;
|
|
144
|
+
webhook?: WebhookConfig;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* The `data` of one server-sent event. Every stream (job events, exec output, logs) uses this framing:
|
|
148
|
+
*
|
|
149
|
+
* ```
|
|
150
|
+
* id: <seq>
|
|
151
|
+
* event: <type>
|
|
152
|
+
* data: {"type": "<type>", "ts": "…", "job_id": "…", "seq": <seq>, …}
|
|
153
|
+
* ```
|
|
154
|
+
*
|
|
155
|
+
* `seq` increases by one per event; reconnect with `Last-Event-ID: <seq>` to resume. A `: ping` comment is
|
|
156
|
+
* sent every 15 seconds. Lifecycle events are `job.queued`, `job.running`, `job.progress` and the terminal
|
|
157
|
+
* `job.succeeded`, `job.failed` and `job.canceled`, which carry the final job (including its final `timing`)
|
|
158
|
+
* and end the stream. Products add their own event types (listed in each operation's `x-b3os-events`) with
|
|
159
|
+
* extra members at the top level.
|
|
160
|
+
*/
|
|
161
|
+
export interface JobEvent {
|
|
162
|
+
/** Event type, such as `job.running` or `crawl.page`. */
|
|
163
|
+
type: string;
|
|
164
|
+
/** When the event happened, with millisecond precision. */
|
|
165
|
+
ts: string;
|
|
166
|
+
/** ID of the job (or sandbox, for exec and log streams) the event belongs to. */
|
|
167
|
+
job_id: string;
|
|
168
|
+
/** Position in the stream; equals the SSE `id`. */
|
|
169
|
+
seq: number;
|
|
170
|
+
job?: Job;
|
|
171
|
+
progress?: JobProgress;
|
|
172
|
+
[key: string]: unknown;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Where to deliver this job's events. Deliveries are `POST`s of a `WebhookEvent` signed with
|
|
176
|
+
* `B3OS-Signature: t=<unix seconds>,v1=<hex HMAC-SHA256 of "<t>.<raw body>">` using the endpoint's secret
|
|
177
|
+
* (`POST /v1/webhooks/secret`). Failed deliveries are retried with backoff for 24 hours. Delivery goes
|
|
178
|
+
* through the egress guard, so private and loopback addresses are refused.
|
|
179
|
+
*/
|
|
180
|
+
export interface WebhookConfig {
|
|
181
|
+
/** An `https://` URL. */
|
|
182
|
+
url: string;
|
|
183
|
+
/**
|
|
184
|
+
* Event types to deliver. Defaults to the terminal events (`job.succeeded`, `job.failed`, `job.canceled`); `["*"]` delivers every event.
|
|
185
|
+
*/
|
|
186
|
+
events?: string[];
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* The body of a webhook delivery. `id` is stable across retries of the same delivery, so use it to deduplicate.
|
|
190
|
+
*/
|
|
191
|
+
export interface WebhookEvent {
|
|
192
|
+
id: string;
|
|
193
|
+
object: "event";
|
|
194
|
+
/** The event type, such as `job.succeeded`. */
|
|
195
|
+
type: string;
|
|
196
|
+
created_at: string;
|
|
197
|
+
/** The job the event belongs to. */
|
|
198
|
+
job_id?: string;
|
|
199
|
+
/** The event's members (as in the job's event stream); terminal events carry `job`. */
|
|
200
|
+
data: {
|
|
201
|
+
job?: Job;
|
|
202
|
+
[key: string]: unknown;
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* A JSON Schema (draft 2020-12) document, such as a routine's `inputs` or an action's `inputSchema`. B3OS checks
|
|
207
|
+
* it against the meta-schema when it is published. References to the meta-schema in `schemas/*.json` resolve
|
|
208
|
+
* here.
|
|
209
|
+
*/
|
|
210
|
+
export type JsonSchemaDocument = Record<string, unknown> | boolean;
|
|
211
|
+
/**
|
|
212
|
+
* How an action finds its element (the same rules as render timelines, `timeline.schema.json#/$defs/target`):
|
|
213
|
+
* candidates match `selector` (CSS), `text` (visible text, case-insensitive substring unless `exact`) or `role`
|
|
214
|
+
* plus accessible `name`, limited to `within`; the best-scored candidate wins, or the `nth` match when set. An
|
|
215
|
+
* element that stays outside the viewport after scrolling it into view fails with `target_not_found`.
|
|
216
|
+
*/
|
|
217
|
+
export type Target = {
|
|
218
|
+
selector?: string;
|
|
219
|
+
text?: string;
|
|
220
|
+
/** @default false */
|
|
221
|
+
exact?: boolean;
|
|
222
|
+
role?: string;
|
|
223
|
+
name?: string;
|
|
224
|
+
/** CSS selector of the scope. */
|
|
225
|
+
within?: string;
|
|
226
|
+
nth?: number;
|
|
227
|
+
};
|
|
228
|
+
/** Browser viewport in CSS pixels. */
|
|
229
|
+
export interface Viewport {
|
|
230
|
+
width: number;
|
|
231
|
+
height: number;
|
|
232
|
+
}
|
|
233
|
+
/** A position in CSS pixels. */
|
|
234
|
+
export interface Point {
|
|
235
|
+
x: number;
|
|
236
|
+
y: number;
|
|
237
|
+
}
|
|
238
|
+
/** Modifier keys held during the action. */
|
|
239
|
+
export type KeyModifiers = Array<"Alt" | "Control" | "Meta" | "Shift">;
|
|
240
|
+
/** Exactly one condition to wait for (the same as a timeline `wait` action's `for`). */
|
|
241
|
+
export interface WaitCondition {
|
|
242
|
+
/** An element matching this CSS selector is visible. */
|
|
243
|
+
selector?: string;
|
|
244
|
+
/** This text is visible. */
|
|
245
|
+
text?: string;
|
|
246
|
+
/** The page URL contains this substring. */
|
|
247
|
+
url?: string;
|
|
248
|
+
/** The network has been quiet. */
|
|
249
|
+
network_idle?: true;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* A single-use credential for opening one stream (WebSocket or SSE) at or below `resource` without a bearer
|
|
253
|
+
* header. Valid for `expires_in_s` seconds and consumed by the first connection attempt, successful or not.
|
|
254
|
+
* The stream runs as the principal that requested the ticket.
|
|
255
|
+
*/
|
|
256
|
+
export interface StreamTicket {
|
|
257
|
+
/** The ticket. Treat it like a password until it is used. */
|
|
258
|
+
ticket: string;
|
|
259
|
+
object: "stream_ticket";
|
|
260
|
+
/** Absolute API path the ticket opens streams under. */
|
|
261
|
+
resource: string;
|
|
262
|
+
/** Seconds until the ticket expires if unused. */
|
|
263
|
+
expires_in_s: number;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* `markdown` main content (or the whole page with `only_main_content: false`); `html` cleaned HTML;
|
|
267
|
+
* `raw_html` the HTML as received; `text` plain text; `links` absolute links; `metadata` title,
|
|
268
|
+
* description and Open Graph fields (always included, listed for compatibility); `screenshot` an image of the
|
|
269
|
+
* page (needs a browser); `json` structured data from `json.schema` (needs the node's model).
|
|
270
|
+
*/
|
|
271
|
+
export type ScrapeFormat = "markdown" | "html" | "raw_html" | "text" | "links" | "metadata" | "screenshot" | "json";
|
|
272
|
+
/**
|
|
273
|
+
* Which tier may serve the page. `auto` (default): cache, then HTTP fetch, then a browser when the page needs
|
|
274
|
+
* JavaScript. `fetch`: never start a browser. `browser`: always render in Chrome (needed for `actions`,
|
|
275
|
+
* `screenshot` and profiles; implied by them).
|
|
276
|
+
*/
|
|
277
|
+
export type ScrapeEngine = "auto" | "fetch" | "browser";
|
|
278
|
+
/** Options for the `screenshot` format. */
|
|
279
|
+
export interface ScreenshotOptions {
|
|
280
|
+
/** @default false */
|
|
281
|
+
full_page?: boolean;
|
|
282
|
+
/** @default "jpeg" */
|
|
283
|
+
format?: "jpeg" | "png" | "webp";
|
|
284
|
+
/**
|
|
285
|
+
* JPEG and WebP quality.
|
|
286
|
+
* @default 80
|
|
287
|
+
*/
|
|
288
|
+
quality?: number;
|
|
289
|
+
}
|
|
290
|
+
/** Options for the `json` format. The node's model fills `schema` from the page. */
|
|
291
|
+
export interface JsonExtractOptions {
|
|
292
|
+
/** A JSON Schema the result must match. */
|
|
293
|
+
schema?: Record<string, unknown>;
|
|
294
|
+
/** Guidance for the model. */
|
|
295
|
+
prompt?: string;
|
|
296
|
+
}
|
|
297
|
+
/** Options shared by scrape, batch scrape, crawl and extract. */
|
|
298
|
+
export interface ScrapeOptions {
|
|
299
|
+
/** @default ["markdown"] */
|
|
300
|
+
formats?: ScrapeFormat[];
|
|
301
|
+
/**
|
|
302
|
+
* Drop headers, navigation, footers and sidebars.
|
|
303
|
+
* @default true
|
|
304
|
+
*/
|
|
305
|
+
only_main_content?: boolean;
|
|
306
|
+
/** CSS selectors to keep; everything else is dropped. */
|
|
307
|
+
include_tags?: string[];
|
|
308
|
+
/** CSS selectors to drop. */
|
|
309
|
+
exclude_tags?: string[];
|
|
310
|
+
engine?: ScrapeEngine;
|
|
311
|
+
/**
|
|
312
|
+
* Extra wait after the page is ready, before capture.
|
|
313
|
+
* @default 0
|
|
314
|
+
*/
|
|
315
|
+
wait_for_ms?: number;
|
|
316
|
+
/** @default 30000 */
|
|
317
|
+
timeout_ms?: number;
|
|
318
|
+
/**
|
|
319
|
+
* Accept a cached copy up to this old (default 2 days). `0` always fetches.
|
|
320
|
+
* @default 172800000
|
|
321
|
+
*/
|
|
322
|
+
max_age_ms?: number;
|
|
323
|
+
/**
|
|
324
|
+
* Store the result in the cache. Requests with headers, a profile or actions are never shared across organizations.
|
|
325
|
+
* @default true
|
|
326
|
+
*/
|
|
327
|
+
store_in_cache?: boolean;
|
|
328
|
+
/**
|
|
329
|
+
* Extra request headers. A request with custom headers bypasses the shared cache. In a browser, a `Cookie` header becomes cookies for the page's host (path `/`), so it reaches the origin as on an HTTP fetch and is not sent to the other hosts the page loads from.
|
|
330
|
+
*/
|
|
331
|
+
headers?: Record<string, string>;
|
|
332
|
+
/**
|
|
333
|
+
* A profile ID or name to load cookies and storage from. Implies `engine: browser`. The page renders in a browser of its own (never one shared with other organizations), which counts toward `vision.sessions.concurrent` while it runs.
|
|
334
|
+
*/
|
|
335
|
+
profile?: string;
|
|
336
|
+
/** Browser actions to run before capture. Implies `engine: browser`. */
|
|
337
|
+
actions?: ActStep[];
|
|
338
|
+
/**
|
|
339
|
+
* BCP 47 locale for `Accept-Language` and the browser.
|
|
340
|
+
* @default "en-US"
|
|
341
|
+
*/
|
|
342
|
+
locale?: string;
|
|
343
|
+
/** IANA time zone for the browser, such as `America/Los_Angeles`. */
|
|
344
|
+
timezone?: string;
|
|
345
|
+
/**
|
|
346
|
+
* Emulate a phone (viewport, user agent, touch).
|
|
347
|
+
* @default false
|
|
348
|
+
*/
|
|
349
|
+
mobile?: boolean;
|
|
350
|
+
viewport?: Viewport;
|
|
351
|
+
/**
|
|
352
|
+
* Block ads, trackers and cookie banners.
|
|
353
|
+
* @default true
|
|
354
|
+
*/
|
|
355
|
+
block_ads?: boolean;
|
|
356
|
+
/**
|
|
357
|
+
* Resource types the browser does not download. Defaults to images, media and fonts unless a screenshot is requested.
|
|
358
|
+
*/
|
|
359
|
+
block_resources?: Array<"image" | "media" | "font" | "stylesheet">;
|
|
360
|
+
screenshot?: ScreenshotOptions;
|
|
361
|
+
json?: JsonExtractOptions;
|
|
362
|
+
}
|
|
363
|
+
/** A URL plus scrape options. */
|
|
364
|
+
export type ScrapeRequest = {
|
|
365
|
+
/** Absolute `http` or `https` URL. */
|
|
366
|
+
url: string;
|
|
367
|
+
} & ScrapeOptions;
|
|
368
|
+
/** Metadata read from the page. */
|
|
369
|
+
export interface PageMetadata {
|
|
370
|
+
title?: string;
|
|
371
|
+
description?: string;
|
|
372
|
+
language?: string;
|
|
373
|
+
canonical_url?: string;
|
|
374
|
+
favicon?: string;
|
|
375
|
+
/** Open Graph properties, keyed without the `og:` prefix. */
|
|
376
|
+
og?: Record<string, string>;
|
|
377
|
+
published_time?: string;
|
|
378
|
+
modified_time?: string;
|
|
379
|
+
/** The page's robots meta tag. */
|
|
380
|
+
robots?: string;
|
|
381
|
+
}
|
|
382
|
+
export interface CacheInfo {
|
|
383
|
+
/**
|
|
384
|
+
* `hit` served from cache; `miss` fetched and stored; `bypass` fetched and not shared (custom headers, profile, actions).
|
|
385
|
+
*/
|
|
386
|
+
state: "hit" | "miss" | "bypass";
|
|
387
|
+
/** Age of the served copy in seconds. */
|
|
388
|
+
age_s: number;
|
|
389
|
+
}
|
|
390
|
+
export interface ScreenshotData {
|
|
391
|
+
format: "jpeg" | "png" | "webp";
|
|
392
|
+
width: number;
|
|
393
|
+
height: number;
|
|
394
|
+
data_base64: string;
|
|
395
|
+
}
|
|
396
|
+
export interface ScrapeResult {
|
|
397
|
+
object: "scrape";
|
|
398
|
+
/** The requested URL. */
|
|
399
|
+
url: string;
|
|
400
|
+
/** The URL after redirects. */
|
|
401
|
+
final_url: string;
|
|
402
|
+
/** The HTTP status the site returned. A 404 page is still a successful scrape. */
|
|
403
|
+
status_code: number;
|
|
404
|
+
content_type?: string;
|
|
405
|
+
/** What served the page. */
|
|
406
|
+
tier: "cache" | "fetch" | "browser";
|
|
407
|
+
cache: CacheInfo;
|
|
408
|
+
markdown?: string;
|
|
409
|
+
html?: string;
|
|
410
|
+
raw_html?: string;
|
|
411
|
+
text?: string;
|
|
412
|
+
links?: string[];
|
|
413
|
+
screenshot?: ScreenshotData;
|
|
414
|
+
/** Data matching `json.schema`, when the `json` format was requested. */
|
|
415
|
+
json?: unknown;
|
|
416
|
+
metadata?: PageMetadata;
|
|
417
|
+
/** Results of `actions`, in order. */
|
|
418
|
+
actions?: ActStepResult[];
|
|
419
|
+
/** Non-fatal problems, such as a format that could not be produced. */
|
|
420
|
+
warnings: string[];
|
|
421
|
+
timing: Timing;
|
|
422
|
+
}
|
|
423
|
+
export interface MapRequest {
|
|
424
|
+
url: string;
|
|
425
|
+
/** Order results by relevance to this phrase. */
|
|
426
|
+
search?: string;
|
|
427
|
+
/**
|
|
428
|
+
* Use sitemaps alongside links (`include`), not at all (`skip`), or only sitemaps (`only`).
|
|
429
|
+
* @default "include"
|
|
430
|
+
*/
|
|
431
|
+
sitemap?: "include" | "skip" | "only";
|
|
432
|
+
/** @default true */
|
|
433
|
+
include_subdomains?: boolean;
|
|
434
|
+
/**
|
|
435
|
+
* Treat URLs that differ only in their query string as one.
|
|
436
|
+
* @default true
|
|
437
|
+
*/
|
|
438
|
+
ignore_query_parameters?: boolean;
|
|
439
|
+
/** @default 1000 */
|
|
440
|
+
limit?: number;
|
|
441
|
+
/** @default 30000 */
|
|
442
|
+
timeout_ms?: number;
|
|
443
|
+
}
|
|
444
|
+
export interface MapResult {
|
|
445
|
+
object: "map";
|
|
446
|
+
url: string;
|
|
447
|
+
links: {
|
|
448
|
+
url: string;
|
|
449
|
+
title?: string;
|
|
450
|
+
description?: string;
|
|
451
|
+
}[];
|
|
452
|
+
timing: Timing;
|
|
453
|
+
}
|
|
454
|
+
/** Scrape options applied to every page. */
|
|
455
|
+
export type NestedScrapeOptions = ScrapeOptions;
|
|
456
|
+
export interface BatchCreateRequest {
|
|
457
|
+
urls: string[];
|
|
458
|
+
scrape?: NestedScrapeOptions;
|
|
459
|
+
/**
|
|
460
|
+
* Skip URLs that do not parse (listed in `result.invalid_urls`) instead of rejecting the request.
|
|
461
|
+
* @default false
|
|
462
|
+
*/
|
|
463
|
+
ignore_invalid_urls?: boolean;
|
|
464
|
+
/** Pages scraped at once, capped by your concurrency limit. */
|
|
465
|
+
max_concurrency?: number;
|
|
466
|
+
webhook?: WebhookConfig;
|
|
467
|
+
metadata?: Metadata;
|
|
468
|
+
}
|
|
469
|
+
export interface CrawlCreateRequest {
|
|
470
|
+
/** Where to start. */
|
|
471
|
+
url: string;
|
|
472
|
+
/**
|
|
473
|
+
* Most pages to scrape.
|
|
474
|
+
* @default 100
|
|
475
|
+
*/
|
|
476
|
+
limit?: number;
|
|
477
|
+
/**
|
|
478
|
+
* Most link hops from `url` (sitemap URLs count as depth 0).
|
|
479
|
+
* @default 5
|
|
480
|
+
*/
|
|
481
|
+
max_depth?: number;
|
|
482
|
+
/** Regular expressions (RE2 syntax) a URL path must match to be crawled. */
|
|
483
|
+
include_paths?: string[];
|
|
484
|
+
/** Regular expressions (RE2 syntax); matching paths are skipped. */
|
|
485
|
+
exclude_paths?: string[];
|
|
486
|
+
/** @default "include" */
|
|
487
|
+
sitemap?: "include" | "skip" | "only";
|
|
488
|
+
/**
|
|
489
|
+
* Follow links to parent and sibling paths, not only below `url`.
|
|
490
|
+
* @default false
|
|
491
|
+
*/
|
|
492
|
+
crawl_entire_domain?: boolean;
|
|
493
|
+
/** @default false */
|
|
494
|
+
allow_subdomains?: boolean;
|
|
495
|
+
/**
|
|
496
|
+
* Scrape pages on other sites that the crawl links to (one hop; their links are not followed).
|
|
497
|
+
* @default false
|
|
498
|
+
*/
|
|
499
|
+
allow_external_links?: boolean;
|
|
500
|
+
/** @default false */
|
|
501
|
+
ignore_query_parameters?: boolean;
|
|
502
|
+
/** Minimum gap between requests to the same host. */
|
|
503
|
+
delay_ms?: number;
|
|
504
|
+
max_concurrency?: number;
|
|
505
|
+
scrape?: NestedScrapeOptions;
|
|
506
|
+
webhook?: WebhookConfig;
|
|
507
|
+
metadata?: Metadata;
|
|
508
|
+
}
|
|
509
|
+
/** One page of a crawl or batch scrape. */
|
|
510
|
+
export interface PageResult {
|
|
511
|
+
object: "page_result";
|
|
512
|
+
url: string;
|
|
513
|
+
status: "succeeded" | "failed";
|
|
514
|
+
/** Link hops from the crawl's start URL (crawls only). */
|
|
515
|
+
depth?: number;
|
|
516
|
+
scraped_at?: string;
|
|
517
|
+
scrape?: ScrapeResult;
|
|
518
|
+
error?: Problem;
|
|
519
|
+
}
|
|
520
|
+
export type PageResultList = Omit<ListEnvelope, "data"> & {
|
|
521
|
+
data: PageResult[];
|
|
522
|
+
};
|
|
523
|
+
/** A batch scrape job (`batch_…`). */
|
|
524
|
+
export type BatchScrape = Omit<Job, "id" | "object" | "result"> & {
|
|
525
|
+
id: string;
|
|
526
|
+
object: "batch_scrape";
|
|
527
|
+
result?: {
|
|
528
|
+
pages_succeeded: number;
|
|
529
|
+
pages_failed: number;
|
|
530
|
+
invalid_urls: string[];
|
|
531
|
+
};
|
|
532
|
+
};
|
|
533
|
+
export type BatchScrapeList = Omit<ListEnvelope, "data"> & {
|
|
534
|
+
data: BatchScrape[];
|
|
535
|
+
};
|
|
536
|
+
/** A crawl job (`crawl_…`). */
|
|
537
|
+
export type Crawl = Omit<Job, "id" | "object" | "result"> & {
|
|
538
|
+
id: string;
|
|
539
|
+
object: "crawl";
|
|
540
|
+
/** The start URL. */
|
|
541
|
+
url: string;
|
|
542
|
+
result?: {
|
|
543
|
+
pages_succeeded: number;
|
|
544
|
+
pages_failed: number;
|
|
545
|
+
/** URLs skipped because robots.txt disallows them. */
|
|
546
|
+
robots_blocked: string[];
|
|
547
|
+
};
|
|
548
|
+
};
|
|
549
|
+
export type CrawlList = Omit<ListEnvelope, "data"> & {
|
|
550
|
+
data: Crawl[];
|
|
551
|
+
};
|
|
552
|
+
/** A `page.succeeded` or `page.failed` event; `page` omits the page content (list pages to read it). */
|
|
553
|
+
export type PageEvent = JobEvent & {
|
|
554
|
+
page?: PageResult;
|
|
555
|
+
};
|
|
556
|
+
/** An event of a batch scrape's stream. */
|
|
557
|
+
export type BatchEvent = PageEvent;
|
|
558
|
+
/** An event of a crawl's stream. */
|
|
559
|
+
export type CrawlEvent = PageEvent;
|
|
560
|
+
export interface ExtractCreateRequest {
|
|
561
|
+
urls: string[];
|
|
562
|
+
prompt?: string;
|
|
563
|
+
/** JSON Schema of the result. */
|
|
564
|
+
schema?: Record<string, unknown>;
|
|
565
|
+
scrape?: NestedScrapeOptions;
|
|
566
|
+
/** Model ID from `GET /v1/infer/models`; defaults to the node's model. */
|
|
567
|
+
model?: string;
|
|
568
|
+
webhook?: WebhookConfig;
|
|
569
|
+
metadata?: Metadata;
|
|
570
|
+
}
|
|
571
|
+
/** An extraction job (`job_…`, `kind: vision.extract`). */
|
|
572
|
+
export type ExtractJob = Omit<Job, "id" | "object" | "result"> & {
|
|
573
|
+
id: string;
|
|
574
|
+
object: "job";
|
|
575
|
+
kind: "vision.extract";
|
|
576
|
+
result?: {
|
|
577
|
+
/** The extracted data, matching your schema. */
|
|
578
|
+
data: unknown;
|
|
579
|
+
/** Pages the data came from. */
|
|
580
|
+
sources: string[];
|
|
581
|
+
};
|
|
582
|
+
};
|
|
583
|
+
/** `active` until closed by `DELETE` (`closed`) or by its timeout (`expired`). */
|
|
584
|
+
export type SessionStatus = "active" | "closed" | "expired";
|
|
585
|
+
export interface SessionCreateRequest {
|
|
586
|
+
/** A profile ID or name to load. */
|
|
587
|
+
profile?: string;
|
|
588
|
+
/**
|
|
589
|
+
* Save cookies and storage back to `profile` when the session closes (the profile is `locked` meanwhile).
|
|
590
|
+
* @default false
|
|
591
|
+
*/
|
|
592
|
+
persist_profile?: boolean;
|
|
593
|
+
/**
|
|
594
|
+
* When saving back, replace the profile even if another session saved a newer revision since this one loaded it.
|
|
595
|
+
* @default false
|
|
596
|
+
*/
|
|
597
|
+
overwrite_profile?: boolean;
|
|
598
|
+
viewport?: Viewport;
|
|
599
|
+
/** @default "en-US" */
|
|
600
|
+
locale?: string;
|
|
601
|
+
timezone?: string;
|
|
602
|
+
user_agent?: string;
|
|
603
|
+
/**
|
|
604
|
+
* Close the session this many seconds after creation.
|
|
605
|
+
* @default 300
|
|
606
|
+
*/
|
|
607
|
+
timeout_s?: number;
|
|
608
|
+
/** @default false */
|
|
609
|
+
block_ads?: boolean;
|
|
610
|
+
block_resources?: Array<"image" | "media" | "font" | "stylesheet">;
|
|
611
|
+
metadata?: Metadata;
|
|
612
|
+
}
|
|
613
|
+
export interface SessionPage {
|
|
614
|
+
/** The CDP target ID. */
|
|
615
|
+
target_id: string;
|
|
616
|
+
url: string;
|
|
617
|
+
title?: string;
|
|
618
|
+
}
|
|
619
|
+
/** The profile a session loaded. */
|
|
620
|
+
export interface SessionProfileRef {
|
|
621
|
+
id: string;
|
|
622
|
+
name: string;
|
|
623
|
+
/** The revision the session loaded. */
|
|
624
|
+
revision: number;
|
|
625
|
+
/** Whether the session saves back on close. */
|
|
626
|
+
persist: boolean;
|
|
627
|
+
}
|
|
628
|
+
export interface BrowserSession {
|
|
629
|
+
id: string;
|
|
630
|
+
object: "browser_session";
|
|
631
|
+
status: SessionStatus;
|
|
632
|
+
created_at: string;
|
|
633
|
+
expires_at: string;
|
|
634
|
+
closed_at: string | null;
|
|
635
|
+
timeout_s: number;
|
|
636
|
+
viewport: Viewport;
|
|
637
|
+
/** The loaded profile, or `null`. */
|
|
638
|
+
profile: null | SessionProfileRef;
|
|
639
|
+
/** WebSocket URL of the session's CDP endpoint. */
|
|
640
|
+
cdp_url: string;
|
|
641
|
+
pages?: SessionPage[];
|
|
642
|
+
usage: {
|
|
643
|
+
/** Billed browser time so far. */
|
|
644
|
+
browser_ms: number;
|
|
645
|
+
};
|
|
646
|
+
timing?: Timing;
|
|
647
|
+
metadata: Metadata;
|
|
648
|
+
}
|
|
649
|
+
export type BrowserSessionList = Omit<ListEnvelope, "data"> & {
|
|
650
|
+
data: BrowserSession[];
|
|
651
|
+
};
|
|
652
|
+
/**
|
|
653
|
+
* One browser action; `kind` selects it. The kinds and their fields match render timeline actions
|
|
654
|
+
* (`navigate`, `click`, `hover`, `type`, `key`, `scroll`, `select`, `wait`) plus `evaluate`, `screenshot` and
|
|
655
|
+
* `markdown`, which only `act` and scrape `actions` offer.
|
|
656
|
+
*/
|
|
657
|
+
export type ActStep = ActNavigate | ActClick | ActHover | ActType | ActKey | ActScroll | ActSelect | ActWait | ActEvaluate | ActScreenshot | ActMarkdown;
|
|
658
|
+
export interface ActNavigate {
|
|
659
|
+
kind: "navigate";
|
|
660
|
+
url: string;
|
|
661
|
+
/** @default "load" */
|
|
662
|
+
wait_until?: "load" | "domcontentloaded" | "networkidle";
|
|
663
|
+
/** @default 10000 */
|
|
664
|
+
timeout_ms?: number;
|
|
665
|
+
}
|
|
666
|
+
export interface ActClick {
|
|
667
|
+
kind: "click";
|
|
668
|
+
target: Target;
|
|
669
|
+
/** @default "left" */
|
|
670
|
+
button?: "left" | "right" | "middle";
|
|
671
|
+
/** @default 1 */
|
|
672
|
+
count?: number;
|
|
673
|
+
modifiers?: KeyModifiers;
|
|
674
|
+
/**
|
|
675
|
+
* How long to wait for the target to appear.
|
|
676
|
+
* @default 10000
|
|
677
|
+
*/
|
|
678
|
+
timeout_ms?: number;
|
|
679
|
+
}
|
|
680
|
+
export interface ActHover {
|
|
681
|
+
kind: "hover";
|
|
682
|
+
target: Target;
|
|
683
|
+
/** @default 10000 */
|
|
684
|
+
timeout_ms?: number;
|
|
685
|
+
}
|
|
686
|
+
export interface ActType {
|
|
687
|
+
kind: "type";
|
|
688
|
+
target?: Target;
|
|
689
|
+
text: string;
|
|
690
|
+
/**
|
|
691
|
+
* Clear the field before typing.
|
|
692
|
+
* @default false
|
|
693
|
+
*/
|
|
694
|
+
clear?: boolean;
|
|
695
|
+
/**
|
|
696
|
+
* Delay between characters.
|
|
697
|
+
* @default 0
|
|
698
|
+
*/
|
|
699
|
+
interval_ms?: number;
|
|
700
|
+
/** @default 10000 */
|
|
701
|
+
timeout_ms?: number;
|
|
702
|
+
}
|
|
703
|
+
export interface ActKey {
|
|
704
|
+
kind: "key";
|
|
705
|
+
/** `KeyboardEvent.key`, such as `Enter`, `Tab` or `a`. */
|
|
706
|
+
key: string;
|
|
707
|
+
modifiers?: KeyModifiers;
|
|
708
|
+
}
|
|
709
|
+
/** Scroll to an offset (`to`), by a delta (`by`), or until `target` is in view. */
|
|
710
|
+
export interface ActScroll {
|
|
711
|
+
kind: "scroll";
|
|
712
|
+
target?: Target;
|
|
713
|
+
to?: Point;
|
|
714
|
+
by?: Point;
|
|
715
|
+
}
|
|
716
|
+
export interface ActSelect {
|
|
717
|
+
kind: "select";
|
|
718
|
+
target: Target;
|
|
719
|
+
/** The option value to select. */
|
|
720
|
+
value: string;
|
|
721
|
+
}
|
|
722
|
+
/** Wait a fixed time (`ms`) or until a condition holds (`for`). */
|
|
723
|
+
export interface ActWait {
|
|
724
|
+
kind: "wait";
|
|
725
|
+
ms?: number;
|
|
726
|
+
for?: WaitCondition;
|
|
727
|
+
/** @default 10000 */
|
|
728
|
+
timeout_ms?: number;
|
|
729
|
+
}
|
|
730
|
+
export interface ActEvaluate {
|
|
731
|
+
kind: "evaluate";
|
|
732
|
+
/**
|
|
733
|
+
* JavaScript evaluated in the page; a returned promise is awaited and the JSON-serializable result is returned.
|
|
734
|
+
*/
|
|
735
|
+
expression: string;
|
|
736
|
+
}
|
|
737
|
+
export interface ActScreenshot {
|
|
738
|
+
kind: "screenshot";
|
|
739
|
+
target?: Target;
|
|
740
|
+
/** @default false */
|
|
741
|
+
full_page?: boolean;
|
|
742
|
+
/** @default "jpeg" */
|
|
743
|
+
format?: "jpeg" | "png" | "webp";
|
|
744
|
+
/** @default 80 */
|
|
745
|
+
quality?: number;
|
|
746
|
+
}
|
|
747
|
+
export interface ActMarkdown {
|
|
748
|
+
kind: "markdown";
|
|
749
|
+
/** @default true */
|
|
750
|
+
only_main_content?: boolean;
|
|
751
|
+
}
|
|
752
|
+
export interface ActRequest {
|
|
753
|
+
actions: ActStep[];
|
|
754
|
+
/** The page to act on (from `pages`); defaults to the most recently active page. */
|
|
755
|
+
target_id?: string;
|
|
756
|
+
/** @default false */
|
|
757
|
+
continue_on_error?: boolean;
|
|
758
|
+
/** @default 30000 */
|
|
759
|
+
timeout_ms?: number;
|
|
760
|
+
}
|
|
761
|
+
export interface ActStepResult {
|
|
762
|
+
kind: "navigate" | "click" | "hover" | "type" | "key" | "scroll" | "select" | "wait" | "evaluate" | "screenshot" | "markdown";
|
|
763
|
+
status: "ok" | "failed" | "skipped";
|
|
764
|
+
duration_ms: number;
|
|
765
|
+
/** `navigate`: the URL after redirects. */
|
|
766
|
+
url?: string;
|
|
767
|
+
/** `navigate`: the HTTP status. */
|
|
768
|
+
status_code?: number;
|
|
769
|
+
/** `evaluate`: the JSON result. */
|
|
770
|
+
value?: unknown;
|
|
771
|
+
screenshot?: ScreenshotData;
|
|
772
|
+
/** `markdown`: the page as Markdown. */
|
|
773
|
+
markdown?: string;
|
|
774
|
+
error?: Problem;
|
|
775
|
+
}
|
|
776
|
+
export interface ActResult {
|
|
777
|
+
object: "act_result";
|
|
778
|
+
session_id: string;
|
|
779
|
+
/** `true` when every action succeeded. */
|
|
780
|
+
ok: boolean;
|
|
781
|
+
results: ActStepResult[];
|
|
782
|
+
timing: Timing;
|
|
783
|
+
}
|
|
784
|
+
/**
|
|
785
|
+
* A saved browser state (prof_) that vision sessions and render recordings can load. The root schema is the profile object the API returns (no secrets). $defs/storage_state is the sensitive payload, byte-compatible with Playwright's storageState (cookies, origins with localStorage, IndexedDB and OPFS), used for upload and export. $defs/sealed_profile is the at-rest record: the profile object plus the vault envelope around the encrypted storage state. Profiles are org-scoped and load only into sessions and jobs of their own org (ARCHITECTURE 5.1). Owner after freeze: vision.
|
|
786
|
+
*/
|
|
787
|
+
export interface Profile {
|
|
788
|
+
id: ProfileId;
|
|
789
|
+
object: "profile";
|
|
790
|
+
created_at: ProfileTimestamp;
|
|
791
|
+
/** Last time the storage state was replaced or saved back. */
|
|
792
|
+
updated_at: ProfileTimestamp;
|
|
793
|
+
/** Last time a session or render job loaded the profile; null if never. */
|
|
794
|
+
last_used_at: ProfileTimestamp | null;
|
|
795
|
+
/** When the profile is deleted automatically; null for no expiry. */
|
|
796
|
+
expires_at?: ProfileTimestamp | null;
|
|
797
|
+
metadata: ProfileMetadata;
|
|
798
|
+
name: string;
|
|
799
|
+
/** Owning org. Returned to the owner only; tenancy is checked on every access. */
|
|
800
|
+
org?: string;
|
|
801
|
+
project?: string;
|
|
802
|
+
/**
|
|
803
|
+
* Registrable domains the profile may hold state for. Every cookie domain and every origin host in the storage state must equal one of these or be a subdomain of one; an import that breaks this fails with profile_domain_mismatch. When omitted at creation, it is derived from the uploaded state.
|
|
804
|
+
*/
|
|
805
|
+
domains: ProfileRegistrableDomain[];
|
|
806
|
+
/**
|
|
807
|
+
* Increments on every save. A session that loaded revision n and saves back while the profile is at revision m > n fails with profile_conflict unless it asked to overwrite.
|
|
808
|
+
*/
|
|
809
|
+
revision: number;
|
|
810
|
+
/**
|
|
811
|
+
* active: loadable. locked: a session with persist is writing it back; loads still see the last revision. expired: past expires_at, about to be deleted.
|
|
812
|
+
*/
|
|
813
|
+
status: "active" | "locked" | "expired";
|
|
814
|
+
/**
|
|
815
|
+
* How the current revision was produced: uploaded storage state, saved back from a vision session, or imported from a render or CLI login.
|
|
816
|
+
*/
|
|
817
|
+
source?: "upload" | "session" | "login";
|
|
818
|
+
/** Counts over the current revision, so clients can show what a profile holds without decrypting it. */
|
|
819
|
+
stats: {
|
|
820
|
+
cookies: number;
|
|
821
|
+
origins: number;
|
|
822
|
+
indexeddb_databases?: number;
|
|
823
|
+
/** Size of the serialized storage state before encryption. */
|
|
824
|
+
bytes: number;
|
|
825
|
+
/**
|
|
826
|
+
* Earliest expires among persistent cookies; null when there are none. Lets clients warn before a login lapses.
|
|
827
|
+
*/
|
|
828
|
+
earliest_cookie_expiry?: ProfileTimestamp | null;
|
|
829
|
+
};
|
|
830
|
+
}
|
|
831
|
+
export type ProfileId = string;
|
|
832
|
+
/** RFC 3339, UTC, e.g. 2026-10-25T17:00:00Z. */
|
|
833
|
+
export type ProfileTimestamp = string;
|
|
834
|
+
/** Lowercase registrable domain (eTLD+1) such as example.com or example.co.uk, no leading dot. */
|
|
835
|
+
export type ProfileRegistrableDomain = string;
|
|
836
|
+
/** Customer string map, at most 16 keys (ARCHITECTURE 4.1). */
|
|
837
|
+
export type ProfileMetadata = Record<string, string>;
|
|
838
|
+
/**
|
|
839
|
+
* Playwright storageState cookie (also CDP Network.CookieParam). expires is Unix seconds as a float; -1 marks a session cookie.
|
|
840
|
+
*/
|
|
841
|
+
export interface ProfileCookie {
|
|
842
|
+
name: string;
|
|
843
|
+
value: string;
|
|
844
|
+
/** Host or .domain the cookie belongs to. */
|
|
845
|
+
domain: string;
|
|
846
|
+
path: string;
|
|
847
|
+
/** Unix time in seconds; -1 for a session cookie. */
|
|
848
|
+
expires: number;
|
|
849
|
+
httpOnly: boolean;
|
|
850
|
+
secure: boolean;
|
|
851
|
+
sameSite: "Strict" | "Lax" | "None";
|
|
852
|
+
/** CHIPS partition (top-level site, e.g. https://example.com) for partitioned cookies. */
|
|
853
|
+
partitionKey?: string;
|
|
854
|
+
/** Chromium partition detail Playwright emits for partitioned cookies; preserved as is. */
|
|
855
|
+
_crHasCrossSiteAncestor?: boolean;
|
|
856
|
+
}
|
|
857
|
+
export interface ProfileNameValue {
|
|
858
|
+
name: string;
|
|
859
|
+
value: string;
|
|
860
|
+
}
|
|
861
|
+
export type ProfileKeyPathArray = string[];
|
|
862
|
+
/**
|
|
863
|
+
* Playwright storageState IndexedDB snapshot (Playwright 1.51+). key and value carry plain JSON; keyEncoded and valueEncoded carry Playwright's serialized form for values JSON cannot represent (Date, binary, and so on). Treated as opaque by B3OS.
|
|
864
|
+
*/
|
|
865
|
+
export interface ProfileIndexedDBDatabase {
|
|
866
|
+
name: string;
|
|
867
|
+
version: number;
|
|
868
|
+
stores: {
|
|
869
|
+
name: string;
|
|
870
|
+
autoIncrement: boolean;
|
|
871
|
+
keyPath?: string;
|
|
872
|
+
keyPathArray?: ProfileKeyPathArray;
|
|
873
|
+
records: {
|
|
874
|
+
key?: unknown;
|
|
875
|
+
keyEncoded?: unknown;
|
|
876
|
+
value?: unknown;
|
|
877
|
+
valueEncoded?: unknown;
|
|
878
|
+
}[];
|
|
879
|
+
indexes: {
|
|
880
|
+
name: string;
|
|
881
|
+
keyPath?: string;
|
|
882
|
+
keyPathArray?: ProfileKeyPathArray;
|
|
883
|
+
multiEntry: boolean;
|
|
884
|
+
unique: boolean;
|
|
885
|
+
}[];
|
|
886
|
+
}[];
|
|
887
|
+
}
|
|
888
|
+
/**
|
|
889
|
+
* Playwright origin-private-file-system entry. Stored and exported unchanged; whether a session restores OPFS is reported by vision.
|
|
890
|
+
*/
|
|
891
|
+
export interface ProfileOpfsEntry {
|
|
892
|
+
path: string;
|
|
893
|
+
type: "file" | "directory";
|
|
894
|
+
base64?: string;
|
|
895
|
+
}
|
|
896
|
+
export interface ProfileOrigin {
|
|
897
|
+
/** Serialized origin: scheme://host[:port], no path. */
|
|
898
|
+
origin: string;
|
|
899
|
+
localStorage: ProfileNameValue[];
|
|
900
|
+
indexedDB?: ProfileIndexedDBDatabase[];
|
|
901
|
+
opfs?: ProfileOpfsEntry[];
|
|
902
|
+
}
|
|
903
|
+
/**
|
|
904
|
+
* Playwright storageState JSON (context.storageState({indexedDB: true})). Upload it as is; exports return the same shape. Sensitive: it is encrypted at rest, decrypted only inside the session or recorder that loads it, never logged and never sent to a model.
|
|
905
|
+
*/
|
|
906
|
+
export interface ProfileStorageState {
|
|
907
|
+
cookies: ProfileCookie[];
|
|
908
|
+
origins: ProfileOrigin[];
|
|
909
|
+
}
|
|
910
|
+
export interface ProfileCreateRequest {
|
|
911
|
+
/** Unique per project. */
|
|
912
|
+
name: string;
|
|
913
|
+
state: ProfileStorageState;
|
|
914
|
+
/** Registrable domains the profile may hold state for. Derived from `state` when omitted. */
|
|
915
|
+
domains?: string[];
|
|
916
|
+
/** Delete the profile automatically at this time. */
|
|
917
|
+
expires_at?: string;
|
|
918
|
+
metadata?: Metadata;
|
|
919
|
+
}
|
|
920
|
+
export interface ProfileUpdateRequest {
|
|
921
|
+
name?: string;
|
|
922
|
+
state?: ProfileStorageState;
|
|
923
|
+
domains?: string[];
|
|
924
|
+
expires_at?: string | null;
|
|
925
|
+
metadata?: Metadata;
|
|
926
|
+
}
|
|
927
|
+
export interface SessionProfileSaveRequest {
|
|
928
|
+
/** Profile to create or replace. */
|
|
929
|
+
name: string;
|
|
930
|
+
/**
|
|
931
|
+
* Replace the profile even if it changed since this session loaded it.
|
|
932
|
+
* @default false
|
|
933
|
+
*/
|
|
934
|
+
overwrite?: boolean;
|
|
935
|
+
}
|
|
936
|
+
export type ProfileList = Omit<ListEnvelope, "data"> & {
|
|
937
|
+
data: Profile[];
|
|
938
|
+
};
|
|
939
|
+
/** A preset ID from `GET /v1/render/presets`, such as `midnight`, `browser-dark` or `mac`. */
|
|
940
|
+
export type PresetRef = string;
|
|
941
|
+
export type PresetKind = "background" | "frame" | "cursor" | "captions" | "click_effect";
|
|
942
|
+
/**
|
|
943
|
+
* Style presets plus overrides, the same object as a timeline's `style` (restyle replaces exactly this). Field
|
|
944
|
+
* values inside `overrides` follow the compositor's style type (padding, corner radius, shadow, colors,
|
|
945
|
+
* gradients); strings are escaped before they reach any HTML or CSS.
|
|
946
|
+
*/
|
|
947
|
+
export interface RenderStyle {
|
|
948
|
+
background?: PresetRef;
|
|
949
|
+
frame?: PresetRef;
|
|
950
|
+
cursor?: PresetRef;
|
|
951
|
+
captions?: PresetRef;
|
|
952
|
+
click_effect?: PresetRef;
|
|
953
|
+
/** Style fields that override the presets. */
|
|
954
|
+
overrides?: Record<string, unknown>;
|
|
955
|
+
}
|
|
956
|
+
/** Give `url` or `html`. */
|
|
957
|
+
export type ScreenshotCreateRequest = {
|
|
958
|
+
/** Page to load (`http` or `https`). */
|
|
959
|
+
url?: string;
|
|
960
|
+
/** HTML to render instead of loading a URL. Rendered with no network access. */
|
|
961
|
+
html?: string;
|
|
962
|
+
/** A vision profile ID or name to load before navigating (with `url` only). */
|
|
963
|
+
profile?: string;
|
|
964
|
+
viewport?: Viewport;
|
|
965
|
+
/**
|
|
966
|
+
* Device pixel ratio of the capture.
|
|
967
|
+
* @default 1
|
|
968
|
+
*/
|
|
969
|
+
dpr?: 1 | 2 | 3;
|
|
970
|
+
/** @default false */
|
|
971
|
+
full_page?: boolean;
|
|
972
|
+
target?: Target;
|
|
973
|
+
/** @default "load" */
|
|
974
|
+
wait_until?: "load" | "domcontentloaded" | "networkidle";
|
|
975
|
+
/**
|
|
976
|
+
* Extra settle time after the page is ready.
|
|
977
|
+
* @default 0
|
|
978
|
+
*/
|
|
979
|
+
wait_for_ms?: number;
|
|
980
|
+
/** @default 30000 */
|
|
981
|
+
timeout_ms?: number;
|
|
982
|
+
/**
|
|
983
|
+
* Emulated `prefers-color-scheme`; `auto` leaves the page default.
|
|
984
|
+
* @default "auto"
|
|
985
|
+
*/
|
|
986
|
+
theme?: "light" | "dark" | "auto";
|
|
987
|
+
/** CSS selectors to hide before capture (cookie banners, chat widgets). */
|
|
988
|
+
hide?: string[];
|
|
989
|
+
/** @default true */
|
|
990
|
+
block_ads?: boolean;
|
|
991
|
+
style?: RenderStyle;
|
|
992
|
+
/** @default "webp" */
|
|
993
|
+
format?: "webp" | "png" | "jpeg";
|
|
994
|
+
/**
|
|
995
|
+
* WebP and JPEG quality.
|
|
996
|
+
* @default 90
|
|
997
|
+
*/
|
|
998
|
+
quality?: number;
|
|
999
|
+
/** Extra encodings of the same capture, each an artifact. */
|
|
1000
|
+
variants?: ScreenshotVariant[];
|
|
1001
|
+
metadata?: Metadata;
|
|
1002
|
+
};
|
|
1003
|
+
export interface ScreenshotVariant {
|
|
1004
|
+
format: "webp" | "png" | "jpeg";
|
|
1005
|
+
/** Scale to this width, keeping the aspect ratio. */
|
|
1006
|
+
width?: number;
|
|
1007
|
+
quality?: number;
|
|
1008
|
+
}
|
|
1009
|
+
export interface ScreenshotSource {
|
|
1010
|
+
url?: string;
|
|
1011
|
+
/** Present when the screenshot rendered inline HTML. */
|
|
1012
|
+
html?: true;
|
|
1013
|
+
profile?: string;
|
|
1014
|
+
}
|
|
1015
|
+
export interface Screenshot {
|
|
1016
|
+
id: string;
|
|
1017
|
+
object: "screenshot";
|
|
1018
|
+
/** Screenshots are synchronous, so a stored screenshot always succeeded. */
|
|
1019
|
+
status: "succeeded";
|
|
1020
|
+
source: ScreenshotSource;
|
|
1021
|
+
width: number;
|
|
1022
|
+
height: number;
|
|
1023
|
+
format: "webp" | "png" | "jpeg";
|
|
1024
|
+
/** The primary image first, then variants. */
|
|
1025
|
+
artifacts: Artifact[];
|
|
1026
|
+
created_at: string;
|
|
1027
|
+
expires_at: string;
|
|
1028
|
+
timing?: Timing;
|
|
1029
|
+
metadata: Metadata;
|
|
1030
|
+
}
|
|
1031
|
+
export type ScreenshotList = Omit<ListEnvelope, "data"> & {
|
|
1032
|
+
data: Screenshot[];
|
|
1033
|
+
};
|
|
1034
|
+
export interface Artifact {
|
|
1035
|
+
id: string;
|
|
1036
|
+
object: "artifact";
|
|
1037
|
+
kind: "image" | "mp4" | "gif" | "poster" | "vtt" | "srt";
|
|
1038
|
+
content_type: string;
|
|
1039
|
+
bytes?: number;
|
|
1040
|
+
width?: number;
|
|
1041
|
+
height?: number;
|
|
1042
|
+
duration_ms?: number;
|
|
1043
|
+
/**
|
|
1044
|
+
* Signed URL on `usercontent.b3os.org`, `https://usercontent.b3os.org/a/<id in host-safe form>/<name>?node=&exp=&sig=`:
|
|
1045
|
+
* an Ed25519 signature by the node's key over the method, path and expiry (`renderGetArtifactContent`), no
|
|
1046
|
+
* cookies. It works as soon as the artifact is reported, while the upload to storage is still finishing.
|
|
1047
|
+
*/
|
|
1048
|
+
url?: string;
|
|
1049
|
+
url_expires_at?: string;
|
|
1050
|
+
created_at?: string;
|
|
1051
|
+
/** When the artifact is deleted. */
|
|
1052
|
+
expires_at?: string;
|
|
1053
|
+
}
|
|
1054
|
+
/**
|
|
1055
|
+
* One browser step of a beat; `kind` selects it. These are the timeline action kinds
|
|
1056
|
+
* (`timeline.schema.json#/$defs/action`) without timing, which the director computes from the narration.
|
|
1057
|
+
*/
|
|
1058
|
+
export type ScriptStep = StepNavigate | StepClick | StepHover | StepType | StepKey | StepScroll | StepSelect | StepWait;
|
|
1059
|
+
export interface StepNavigate {
|
|
1060
|
+
kind: "navigate";
|
|
1061
|
+
url: string;
|
|
1062
|
+
/** @default "load" */
|
|
1063
|
+
wait_until?: "load" | "domcontentloaded" | "networkidle";
|
|
1064
|
+
/** @default 10000 */
|
|
1065
|
+
timeout_ms?: number;
|
|
1066
|
+
}
|
|
1067
|
+
export interface StepClick {
|
|
1068
|
+
kind: "click";
|
|
1069
|
+
target: Target;
|
|
1070
|
+
/** @default "left" */
|
|
1071
|
+
button?: "left" | "right" | "middle";
|
|
1072
|
+
/** @default 1 */
|
|
1073
|
+
count?: number;
|
|
1074
|
+
modifiers?: KeyModifiers;
|
|
1075
|
+
}
|
|
1076
|
+
export interface StepHover {
|
|
1077
|
+
kind: "hover";
|
|
1078
|
+
target: Target;
|
|
1079
|
+
}
|
|
1080
|
+
export interface StepType {
|
|
1081
|
+
kind: "type";
|
|
1082
|
+
target?: Target;
|
|
1083
|
+
text: string;
|
|
1084
|
+
/**
|
|
1085
|
+
* Delay between characters on the video's clock.
|
|
1086
|
+
* @default 80
|
|
1087
|
+
*/
|
|
1088
|
+
interval_ms?: number;
|
|
1089
|
+
}
|
|
1090
|
+
export interface StepKey {
|
|
1091
|
+
kind: "key";
|
|
1092
|
+
key: string;
|
|
1093
|
+
modifiers?: KeyModifiers;
|
|
1094
|
+
}
|
|
1095
|
+
/** Scroll to an offset (`to`), by a delta (`by`), or until `target` is in view. */
|
|
1096
|
+
export interface StepScroll {
|
|
1097
|
+
kind: "scroll";
|
|
1098
|
+
target?: Target;
|
|
1099
|
+
to?: Point;
|
|
1100
|
+
by?: Point;
|
|
1101
|
+
/** @default 600 */
|
|
1102
|
+
duration_ms?: number;
|
|
1103
|
+
}
|
|
1104
|
+
export interface StepSelect {
|
|
1105
|
+
kind: "select";
|
|
1106
|
+
target: Target;
|
|
1107
|
+
value: string;
|
|
1108
|
+
}
|
|
1109
|
+
/** Pause the story (`ms`) or hold the clock until a condition holds (`for`). */
|
|
1110
|
+
export interface StepWait {
|
|
1111
|
+
kind: "wait";
|
|
1112
|
+
ms?: number;
|
|
1113
|
+
for?: WaitCondition;
|
|
1114
|
+
/** @default 10000 */
|
|
1115
|
+
timeout_ms?: number;
|
|
1116
|
+
}
|
|
1117
|
+
/** One line of narration and the steps performed while it is said. */
|
|
1118
|
+
export interface Beat {
|
|
1119
|
+
/** Optional ID; generated as `b1`, `b2`, … when omitted. */
|
|
1120
|
+
id?: string;
|
|
1121
|
+
title?: string;
|
|
1122
|
+
/** Narration for this beat. Omit for a silent beat. */
|
|
1123
|
+
say?: string;
|
|
1124
|
+
do?: ScriptStep[];
|
|
1125
|
+
/** Extra time to stay on the beat after its narration and steps end. */
|
|
1126
|
+
hold_ms?: number;
|
|
1127
|
+
}
|
|
1128
|
+
export interface VideoSource {
|
|
1129
|
+
/** Where the recording starts. */
|
|
1130
|
+
url: string;
|
|
1131
|
+
/** A vision profile ID or name to start signed in. Responses show the resolved `prof_` ID. */
|
|
1132
|
+
profile?: string;
|
|
1133
|
+
}
|
|
1134
|
+
export interface VoiceSpec {
|
|
1135
|
+
/** A speech model from `GET /v1/infer/models`, such as `kokoro-82m`. */
|
|
1136
|
+
model: string;
|
|
1137
|
+
/** A voice from `GET /v1/infer/audio/voices`. */
|
|
1138
|
+
voice: string;
|
|
1139
|
+
/** @default 1 */
|
|
1140
|
+
speed?: number;
|
|
1141
|
+
}
|
|
1142
|
+
export interface CaptionOptions {
|
|
1143
|
+
/**
|
|
1144
|
+
* `none`: sidecar files only. `static`: draw each cue. `karaoke`: also highlight the spoken word.
|
|
1145
|
+
* @default "none"
|
|
1146
|
+
*/
|
|
1147
|
+
burn_in?: "none" | "static" | "karaoke";
|
|
1148
|
+
/** @default ["vtt"] */
|
|
1149
|
+
sidecars?: Array<"vtt" | "srt">;
|
|
1150
|
+
/** @default 42 */
|
|
1151
|
+
max_chars_per_line?: number;
|
|
1152
|
+
/** @default 2 */
|
|
1153
|
+
max_lines?: number;
|
|
1154
|
+
/** @default 20 */
|
|
1155
|
+
max_chars_per_second?: number;
|
|
1156
|
+
}
|
|
1157
|
+
export interface VideoOutput {
|
|
1158
|
+
width: number;
|
|
1159
|
+
height: number;
|
|
1160
|
+
fps: 24 | 25 | 30 | 50 | 60;
|
|
1161
|
+
}
|
|
1162
|
+
export type VideoFormat = "mp4" | "gif" | "poster";
|
|
1163
|
+
export interface VideoCreateRequest {
|
|
1164
|
+
source: VideoSource;
|
|
1165
|
+
beats: Beat[];
|
|
1166
|
+
voice?: VoiceSpec;
|
|
1167
|
+
captions?: CaptionOptions;
|
|
1168
|
+
style?: RenderStyle;
|
|
1169
|
+
camera?: {
|
|
1170
|
+
/**
|
|
1171
|
+
* Zoom toward the element each step acts on.
|
|
1172
|
+
* @default true
|
|
1173
|
+
*/
|
|
1174
|
+
auto_zoom?: boolean;
|
|
1175
|
+
/** @default 2 */
|
|
1176
|
+
max_zoom?: number;
|
|
1177
|
+
};
|
|
1178
|
+
viewport?: Viewport;
|
|
1179
|
+
output?: VideoOutput;
|
|
1180
|
+
/** @default ["mp4","poster"] */
|
|
1181
|
+
formats?: VideoFormat[];
|
|
1182
|
+
/** Seeds the page's randomness so a re-render is identical. */
|
|
1183
|
+
seed?: number;
|
|
1184
|
+
/** The page's `Date` at the start of the video; the clock then advances with the video. */
|
|
1185
|
+
start_time?: string;
|
|
1186
|
+
recording?: RecordingOptions;
|
|
1187
|
+
webhook?: WebhookConfig;
|
|
1188
|
+
metadata?: Metadata;
|
|
1189
|
+
}
|
|
1190
|
+
/**
|
|
1191
|
+
* Where the page's network traffic comes from. By default every video loads the site live and records that
|
|
1192
|
+
* load (its capture segments replay the recording, so they all see the same content). With `reuse: true` the
|
|
1193
|
+
* video replays the newest recording another video of this project made of the same source URL, steps,
|
|
1194
|
+
* viewport, seed and start time within `max_age_s`, instead of loading the site again: faster, and the
|
|
1195
|
+
* content is what the site served then. When no such recording exists the site is loaded and recorded as
|
|
1196
|
+
* usual. `result.recording` says which happened. Recordings hold the page's responses; they are deleted
|
|
1197
|
+
* 24 hours after they were made, or earlier with the last video that used them.
|
|
1198
|
+
*/
|
|
1199
|
+
export interface RecordingOptions {
|
|
1200
|
+
/** @default false */
|
|
1201
|
+
reuse?: boolean;
|
|
1202
|
+
/**
|
|
1203
|
+
* The oldest recording `reuse` accepts, in seconds.
|
|
1204
|
+
* @default 86400
|
|
1205
|
+
*/
|
|
1206
|
+
max_age_s?: number;
|
|
1207
|
+
}
|
|
1208
|
+
export interface RecordingInfo {
|
|
1209
|
+
/** True when the video replayed an earlier recording (`recording.reuse`) instead of loading the site. */
|
|
1210
|
+
reused: boolean;
|
|
1211
|
+
/** When the replayed or new recording was made. */
|
|
1212
|
+
recorded_at?: string;
|
|
1213
|
+
}
|
|
1214
|
+
export interface VideoRestyleRequest {
|
|
1215
|
+
style?: RenderStyle;
|
|
1216
|
+
captions?: CaptionOptions;
|
|
1217
|
+
output?: VideoOutput;
|
|
1218
|
+
formats?: VideoFormat[];
|
|
1219
|
+
webhook?: WebhookConfig;
|
|
1220
|
+
metadata?: Metadata;
|
|
1221
|
+
}
|
|
1222
|
+
export interface VideoResult {
|
|
1223
|
+
duration_ms: number;
|
|
1224
|
+
width: number;
|
|
1225
|
+
height: number;
|
|
1226
|
+
fps: number;
|
|
1227
|
+
artifacts: Artifact[];
|
|
1228
|
+
recording?: RecordingInfo;
|
|
1229
|
+
}
|
|
1230
|
+
/** A video job (`vid_…`). `progress` counts phases (voice, plan, capture, compose, encode, upload). */
|
|
1231
|
+
export type Video = Omit<Job, "id" | "object" | "result"> & {
|
|
1232
|
+
id: string;
|
|
1233
|
+
object: "video";
|
|
1234
|
+
source: VideoSource;
|
|
1235
|
+
/** The source video when this video is a restyle. */
|
|
1236
|
+
restyled_from: string | null;
|
|
1237
|
+
result?: VideoResult;
|
|
1238
|
+
};
|
|
1239
|
+
export type VideoList = Omit<ListEnvelope, "data"> & {
|
|
1240
|
+
data: Video[];
|
|
1241
|
+
};
|
|
1242
|
+
/**
|
|
1243
|
+
* An event of a video's stream. `video.phase` carries `phase`; `video.artifact` carries `artifact` (without a
|
|
1244
|
+
* signed URL; fetch the artifact or the video for one).
|
|
1245
|
+
*/
|
|
1246
|
+
export type VideoEvent = JobEvent & {
|
|
1247
|
+
phase?: "voice" | "plan" | "capture" | "compose" | "encode" | "upload";
|
|
1248
|
+
artifact?: Artifact;
|
|
1249
|
+
};
|
|
1250
|
+
/**
|
|
1251
|
+
* Everything a video job needs after planning: beats, narration with word timings, the timed action list the recorder replays, the cursor path, camera keyframes, captions and style references; plus the per-capture-frame plan sent to the recorder ($defs/capture_frame), the metadata the recorder returns per frame ($defs/captured_frame) and the per-output-frame FrameState the compositor consumes ($defs/frame_state). Times are integer microseconds from t = 0 on the virtual clock (_us); wall-clock budgets are _ms. Positions are CSS pixels in viewport space (origin at the viewport's top-left) unless a field says document space (viewport position plus scroll offset) or output space (pixels of the composed frame). Restyle keeps everything except style and re-composes from the archived capture. Owner after freeze: render-compose.
|
|
1252
|
+
*/
|
|
1253
|
+
export interface RenderTimeline {
|
|
1254
|
+
$schema?: string;
|
|
1255
|
+
version: 1;
|
|
1256
|
+
job?: string;
|
|
1257
|
+
/**
|
|
1258
|
+
* Length of the video. Output frame i exists for every i with round(i * 1e6 / output.fps) < duration_us.
|
|
1259
|
+
*/
|
|
1260
|
+
duration_us: number;
|
|
1261
|
+
/**
|
|
1262
|
+
* Browser viewport in CSS pixels. Capture runs at device pixel ratio 1; sharp zoom comes from clip.scale at capture time (ARCHITECTURE 5.2).
|
|
1263
|
+
*/
|
|
1264
|
+
viewport: {
|
|
1265
|
+
width: number;
|
|
1266
|
+
height: number;
|
|
1267
|
+
};
|
|
1268
|
+
capture: {
|
|
1269
|
+
/**
|
|
1270
|
+
* Page capture rate. Capture frame seq is taken at virtual time t(seq) = round(seq * 1e6 / fps) us.
|
|
1271
|
+
* @default 30
|
|
1272
|
+
*/
|
|
1273
|
+
fps: number;
|
|
1274
|
+
/** @default "jpeg" */
|
|
1275
|
+
format?: "jpeg" | "png";
|
|
1276
|
+
/**
|
|
1277
|
+
* JPEG quality passed to Chrome.
|
|
1278
|
+
* @default 90
|
|
1279
|
+
*/
|
|
1280
|
+
quality?: number;
|
|
1281
|
+
/**
|
|
1282
|
+
* screenshot: Page.captureScreenshot per virtual tick (any OS). beginframe: HeadlessExperimental.beginFrame with screenshot (Linux chrome-headless-shell; reports damage).
|
|
1283
|
+
* @default "screenshot"
|
|
1284
|
+
*/
|
|
1285
|
+
backend?: "screenshot" | "beginframe";
|
|
1286
|
+
/**
|
|
1287
|
+
* Number of segments captured in parallel; 1 means serial.
|
|
1288
|
+
* @default 1
|
|
1289
|
+
*/
|
|
1290
|
+
segments?: number;
|
|
1291
|
+
};
|
|
1292
|
+
/** Composed video. Output frame index i is presented at t = round(i * 1e6 / fps) us. */
|
|
1293
|
+
output: {
|
|
1294
|
+
width: number;
|
|
1295
|
+
height: number;
|
|
1296
|
+
fps: 24 | 25 | 30 | 50 | 60;
|
|
1297
|
+
};
|
|
1298
|
+
/**
|
|
1299
|
+
* Seeds Math.random and crypto.getRandomValues in the page and every PRNG in the director, so every segment worker sees the same sequence.
|
|
1300
|
+
*/
|
|
1301
|
+
seed?: number;
|
|
1302
|
+
/** Value of Date at t = 0; the page clock then advances with virtual time only. */
|
|
1303
|
+
start_time?: string;
|
|
1304
|
+
source?: {
|
|
1305
|
+
url: string;
|
|
1306
|
+
profile?: string;
|
|
1307
|
+
};
|
|
1308
|
+
/** References to style presets resolved by b3os-compose. Restyle replaces only this object. */
|
|
1309
|
+
style?: {
|
|
1310
|
+
background?: RenderTimelinePresetRef;
|
|
1311
|
+
frame?: RenderTimelinePresetRef;
|
|
1312
|
+
cursor?: RenderTimelinePresetRef;
|
|
1313
|
+
captions?: RenderTimelinePresetRef;
|
|
1314
|
+
click_effect?: RenderTimelinePresetRef;
|
|
1315
|
+
/**
|
|
1316
|
+
* Style fields that override the presets, validated by b3os-compose against its Style type (NOTES/render-compose.md 1.1): padding, corner_radius, shadow, border, background_color, background_gradient, aspect_ratio, canvas, fit, frame_title, frame_url, theme, cursor_size, cursor_zoom, click_color, click_duration_ms, caption_size, caption_color, caption_highlight, caption_background, caption_position, motion_blur, matte. Unknown keys and bad values are refused with 422 style_invalid.
|
|
1317
|
+
*/
|
|
1318
|
+
overrides?: Record<string, unknown>;
|
|
1319
|
+
};
|
|
1320
|
+
/**
|
|
1321
|
+
* Where the page layer lands in the output frame, computed by b3os-compose from style and output size and recorded for reproducibility.
|
|
1322
|
+
*/
|
|
1323
|
+
layout?: {
|
|
1324
|
+
/** Output space. */
|
|
1325
|
+
page: RenderTimelineRect;
|
|
1326
|
+
corner_radius?: number;
|
|
1327
|
+
};
|
|
1328
|
+
/** Narration-sized units of the story: what is said and what happens while it is said. */
|
|
1329
|
+
beats?: {
|
|
1330
|
+
id: RenderTimelineLocalId;
|
|
1331
|
+
title?: string;
|
|
1332
|
+
start_us: RenderTimelineUs;
|
|
1333
|
+
end_us: RenderTimelineUs;
|
|
1334
|
+
/** Narration segment spoken during this beat. */
|
|
1335
|
+
narration?: RenderTimelineLocalId;
|
|
1336
|
+
actions?: RenderTimelineLocalId[];
|
|
1337
|
+
}[];
|
|
1338
|
+
narration?: RenderTimelineNarration | null;
|
|
1339
|
+
/**
|
|
1340
|
+
* Timed browser actions in at_us order (ties keep array order). The recorder replays exactly this list in the probe pass and in every capture segment. The virtual clock is frozen while navigate and wait actions settle, so their wall time never shows in the video.
|
|
1341
|
+
*/
|
|
1342
|
+
actions: RenderTimelineAction[];
|
|
1343
|
+
/**
|
|
1344
|
+
* Composited cursor (not drawn in the page). Position is linear between consecutive points; pressed and visible keep their last value until a point changes them. Before the first point and after the last, the nearest point applies.
|
|
1345
|
+
*/
|
|
1346
|
+
cursor?: {
|
|
1347
|
+
points: {
|
|
1348
|
+
t_us: RenderTimelineUs;
|
|
1349
|
+
x: number;
|
|
1350
|
+
y: number;
|
|
1351
|
+
pressed?: boolean;
|
|
1352
|
+
visible?: boolean;
|
|
1353
|
+
}[];
|
|
1354
|
+
};
|
|
1355
|
+
/**
|
|
1356
|
+
* Camera keyframes. For t between keyframes k-1 and k: u = (t - t[k-1]) / (t[k] - t[k-1]), e = easing[k](u), zoom = zoom[k-1] * (zoom[k] / zoom[k-1])^e, center = center[k-1] + (center[k] - center[k-1]) * e. Before the first keyframe and after the last, the nearest keyframe holds. The camera rect is width = viewport.width / zoom, height = viewport.height / zoom, x = clamp(center.x - width / 2, 0, viewport.width - width), y likewise. Absent: zoom 1 centered.
|
|
1357
|
+
*/
|
|
1358
|
+
camera?: {
|
|
1359
|
+
keyframes: {
|
|
1360
|
+
t_us: RenderTimelineUs;
|
|
1361
|
+
center: RenderTimelinePoint;
|
|
1362
|
+
zoom: number;
|
|
1363
|
+
easing?: RenderTimelineEasing;
|
|
1364
|
+
}[];
|
|
1365
|
+
};
|
|
1366
|
+
captions?: {
|
|
1367
|
+
/**
|
|
1368
|
+
* none: sidecar files only. static: draw each cue. karaoke: draw each cue and highlight the word being spoken.
|
|
1369
|
+
*/
|
|
1370
|
+
burn_in: "none" | "static" | "karaoke";
|
|
1371
|
+
sidecars?: Array<"vtt" | "srt">;
|
|
1372
|
+
/** @default 42 */
|
|
1373
|
+
max_chars_per_line?: number;
|
|
1374
|
+
/** @default 2 */
|
|
1375
|
+
max_lines?: number;
|
|
1376
|
+
/** @default 20 */
|
|
1377
|
+
max_chars_per_second?: number;
|
|
1378
|
+
cues: RenderTimelineCue[];
|
|
1379
|
+
};
|
|
1380
|
+
/**
|
|
1381
|
+
* Per capture frame: the viewport region to capture. Sent to the recorder for each segment. Frames not listed are not captured.
|
|
1382
|
+
*/
|
|
1383
|
+
capture_plan?: RenderTimelineCaptureFrame[];
|
|
1384
|
+
/** Optional FrameState dump (debugging, tests, GET .../timeline?frames=1). */
|
|
1385
|
+
frames?: RenderTimelineFrameState[];
|
|
1386
|
+
}
|
|
1387
|
+
/** Microseconds on the virtual timeline. */
|
|
1388
|
+
export type RenderTimelineUs = number;
|
|
1389
|
+
export type RenderTimelineLocalId = string;
|
|
1390
|
+
/**
|
|
1391
|
+
* A preset id known to b3os-compose (GET /v1/render/presets), e.g. midnight, browser-dark, mac, arrow. Ids are unique across kinds; none (any kind) and auto and transparent (background) are values, not presets.
|
|
1392
|
+
*/
|
|
1393
|
+
export type RenderTimelinePresetRef = string;
|
|
1394
|
+
export interface RenderTimelinePoint {
|
|
1395
|
+
x: number;
|
|
1396
|
+
y: number;
|
|
1397
|
+
}
|
|
1398
|
+
export interface RenderTimelineRect {
|
|
1399
|
+
x: number;
|
|
1400
|
+
y: number;
|
|
1401
|
+
width: number;
|
|
1402
|
+
height: number;
|
|
1403
|
+
}
|
|
1404
|
+
/**
|
|
1405
|
+
* Easing for the segment that ends at this keyframe; u in [0, 1]. linear: u. ease_in_out_cubic: u < 0.5 ? 4u^3 : 1 - (2 - 2u)^3 / 2. ease_out_quart: 1 - (1 - u)^4. smootherstep: 6u^5 - 15u^4 + 10u^3. hold: 0 until u = 1, then 1. cubic_bezier: CSS cubic-bezier(x1, y1, x2, y2). critically_damped: s(u) / s(1) with s(u) = 1 - (1 + w u) e^(-w u). Default ease_in_out_cubic.
|
|
1406
|
+
*/
|
|
1407
|
+
export type RenderTimelineEasing = "linear" | "ease_in_out_cubic" | "ease_out_quart" | "smootherstep" | "hold" | {
|
|
1408
|
+
cubic_bezier: [number, number, number, number, ...unknown[]];
|
|
1409
|
+
} | {
|
|
1410
|
+
critically_damped: {
|
|
1411
|
+
omega: number;
|
|
1412
|
+
};
|
|
1413
|
+
};
|
|
1414
|
+
/**
|
|
1415
|
+
* What an action acts on. Resolution (littledemo targeting): candidates matching selector, text (visible text, case-insensitive substring unless exact), or role plus accessible name, limited to within; the best-scored candidate wins, or the nth match when nth is set. A target that is still outside the viewport after scrolling it into view fails the action with target_not_found.
|
|
1416
|
+
*/
|
|
1417
|
+
export type RenderTimelineTarget = {
|
|
1418
|
+
selector?: string;
|
|
1419
|
+
text?: string;
|
|
1420
|
+
/** @default false */
|
|
1421
|
+
exact?: boolean;
|
|
1422
|
+
role?: string;
|
|
1423
|
+
name?: string;
|
|
1424
|
+
/** CSS selector of the scope. */
|
|
1425
|
+
within?: string;
|
|
1426
|
+
nth?: number;
|
|
1427
|
+
};
|
|
1428
|
+
/**
|
|
1429
|
+
* What the probe pass observed when the action ran; filled by the recorder, read by the director to plan cursor and camera. rect and point are viewport space at at_us.
|
|
1430
|
+
*/
|
|
1431
|
+
export interface RenderTimelineObservation {
|
|
1432
|
+
ok: boolean;
|
|
1433
|
+
rect?: RenderTimelineRect;
|
|
1434
|
+
point?: RenderTimelinePoint;
|
|
1435
|
+
/** A unique selector for the resolved element. */
|
|
1436
|
+
selector?: string;
|
|
1437
|
+
/** Page URL after the action. */
|
|
1438
|
+
url?: string;
|
|
1439
|
+
/** Document scroll offset after the action. */
|
|
1440
|
+
scroll?: RenderTimelinePoint;
|
|
1441
|
+
/** Virtual time at which a navigate or wait finished. */
|
|
1442
|
+
settled_us?: RenderTimelineUs;
|
|
1443
|
+
error?: {
|
|
1444
|
+
code: string;
|
|
1445
|
+
detail?: string;
|
|
1446
|
+
};
|
|
1447
|
+
}
|
|
1448
|
+
export type RenderTimelineModifiers = Array<"Alt" | "Control" | "Meta" | "Shift">;
|
|
1449
|
+
export type RenderTimelineAction = {
|
|
1450
|
+
id: RenderTimelineLocalId;
|
|
1451
|
+
kind: "navigate" | "click" | "hover" | "type" | "key" | "scroll" | "select" | "wait";
|
|
1452
|
+
/** When the action starts. */
|
|
1453
|
+
at_us: RenderTimelineUs;
|
|
1454
|
+
beat?: RenderTimelineLocalId;
|
|
1455
|
+
target?: RenderTimelineTarget;
|
|
1456
|
+
url?: string;
|
|
1457
|
+
/** @default "load" */
|
|
1458
|
+
wait_until?: "load" | "domcontentloaded" | "networkidle";
|
|
1459
|
+
/** @default "left" */
|
|
1460
|
+
button?: "left" | "right" | "middle";
|
|
1461
|
+
/** @default 1 */
|
|
1462
|
+
count?: number;
|
|
1463
|
+
/**
|
|
1464
|
+
* click: time between mouse down and mouse up.
|
|
1465
|
+
* @default 60000
|
|
1466
|
+
*/
|
|
1467
|
+
press_us?: number;
|
|
1468
|
+
modifiers?: RenderTimelineModifiers;
|
|
1469
|
+
text?: string;
|
|
1470
|
+
/**
|
|
1471
|
+
* type: delay between characters; character i (a Unicode scalar value) is inserted at at_us + i * interval_us.
|
|
1472
|
+
* @default 80000
|
|
1473
|
+
*/
|
|
1474
|
+
interval_us?: number;
|
|
1475
|
+
/** KeyboardEvent.key, e.g. Enter, Tab, a. */
|
|
1476
|
+
key?: string;
|
|
1477
|
+
/** scroll: document scroll offset to reach. */
|
|
1478
|
+
to?: RenderTimelinePoint;
|
|
1479
|
+
/** scroll: delta from the current offset. */
|
|
1480
|
+
by?: RenderTimelinePoint;
|
|
1481
|
+
/**
|
|
1482
|
+
* scroll: animation length on the virtual clock.
|
|
1483
|
+
* @default 600000
|
|
1484
|
+
*/
|
|
1485
|
+
duration_us?: number;
|
|
1486
|
+
easing?: RenderTimelineEasing;
|
|
1487
|
+
/** select: option value. */
|
|
1488
|
+
value?: string;
|
|
1489
|
+
/** wait: the condition. The virtual clock is frozen until it holds. */
|
|
1490
|
+
for?: {
|
|
1491
|
+
selector?: string;
|
|
1492
|
+
text?: string;
|
|
1493
|
+
/** Substring the page URL must contain. */
|
|
1494
|
+
url?: string;
|
|
1495
|
+
network_idle?: true;
|
|
1496
|
+
};
|
|
1497
|
+
/**
|
|
1498
|
+
* navigate and wait: wall-clock budget for settling.
|
|
1499
|
+
* @default 10000
|
|
1500
|
+
*/
|
|
1501
|
+
timeout_ms?: number;
|
|
1502
|
+
observed?: RenderTimelineObservation;
|
|
1503
|
+
};
|
|
1504
|
+
export interface RenderTimelineWord {
|
|
1505
|
+
text: string;
|
|
1506
|
+
start_us: RenderTimelineUs;
|
|
1507
|
+
end_us: RenderTimelineUs;
|
|
1508
|
+
/** UTF-8 byte offset of the word in its segment text. */
|
|
1509
|
+
byte_start?: number;
|
|
1510
|
+
byte_end?: number;
|
|
1511
|
+
}
|
|
1512
|
+
/**
|
|
1513
|
+
* Voice-over. Audio is synthesized before capture so actions can be placed on words (ARCHITECTURE 5.2). Word times are absolute on the timeline: segment.start_us + the voice sidecar's start_ms * 1000.
|
|
1514
|
+
*/
|
|
1515
|
+
export interface RenderTimelineNarration {
|
|
1516
|
+
voice: {
|
|
1517
|
+
model: string;
|
|
1518
|
+
voice: string;
|
|
1519
|
+
/** @default 1 */
|
|
1520
|
+
speed?: number;
|
|
1521
|
+
};
|
|
1522
|
+
sample_rate: 16000 | 22050 | 24000 | 44100 | 48000;
|
|
1523
|
+
/** @default 0 */
|
|
1524
|
+
gain_db?: number;
|
|
1525
|
+
segments: {
|
|
1526
|
+
id: RenderTimelineLocalId;
|
|
1527
|
+
beat?: RenderTimelineLocalId;
|
|
1528
|
+
text: string;
|
|
1529
|
+
start_us: RenderTimelineUs;
|
|
1530
|
+
end_us: RenderTimelineUs;
|
|
1531
|
+
/** Mono PCM s16le at narration.sample_rate, stored by b3os-render (job-relative path or art_ id). */
|
|
1532
|
+
audio: {
|
|
1533
|
+
ref: string;
|
|
1534
|
+
samples: number;
|
|
1535
|
+
};
|
|
1536
|
+
words: RenderTimelineWord[];
|
|
1537
|
+
}[];
|
|
1538
|
+
}
|
|
1539
|
+
/**
|
|
1540
|
+
* One caption cue. words place each word on a line for karaoke highlighting; byte offsets index into that line's text.
|
|
1541
|
+
*/
|
|
1542
|
+
export interface RenderTimelineCue {
|
|
1543
|
+
id: RenderTimelineLocalId;
|
|
1544
|
+
start_us: RenderTimelineUs;
|
|
1545
|
+
end_us: RenderTimelineUs;
|
|
1546
|
+
lines: string[];
|
|
1547
|
+
words?: {
|
|
1548
|
+
text: string;
|
|
1549
|
+
start_us: RenderTimelineUs;
|
|
1550
|
+
end_us: RenderTimelineUs;
|
|
1551
|
+
line: number;
|
|
1552
|
+
byte_start: number;
|
|
1553
|
+
byte_end: number;
|
|
1554
|
+
}[];
|
|
1555
|
+
}
|
|
1556
|
+
/**
|
|
1557
|
+
* Capture plan entry: at t(seq) capture the viewport region camera (viewport space). The recorder adds the scroll offset to get the document-space clip and sets clip.scale = layout page width (output px) / camera.width so the image arrives at page-layer size.
|
|
1558
|
+
*/
|
|
1559
|
+
export interface RenderTimelineCaptureFrame {
|
|
1560
|
+
seq: number;
|
|
1561
|
+
camera: RenderTimelineRect;
|
|
1562
|
+
/** Explicit clip.scale; default derived as above. */
|
|
1563
|
+
scale?: number;
|
|
1564
|
+
}
|
|
1565
|
+
/**
|
|
1566
|
+
* Everything the compositor needs for output frame index, computed upfront from the timeline so frames compose in parallel. page says which captured image to draw and which viewport region it covers; camera is the region wanted at t_us; the compositor applies the residual transform from page.camera to camera (sub-pixel). Viewport-space positions map to output space through camera and layout.page.
|
|
1567
|
+
*/
|
|
1568
|
+
export interface RenderTimelineFrameState {
|
|
1569
|
+
index: number;
|
|
1570
|
+
t_us: RenderTimelineUs;
|
|
1571
|
+
page: {
|
|
1572
|
+
segment: number;
|
|
1573
|
+
/**
|
|
1574
|
+
* Latest capture frame with t(seq) <= t_us; when it had damage false, the image of the latest earlier frame with damage.
|
|
1575
|
+
*/
|
|
1576
|
+
seq: number;
|
|
1577
|
+
camera: RenderTimelineRect;
|
|
1578
|
+
};
|
|
1579
|
+
camera: RenderTimelineRect;
|
|
1580
|
+
cursor: {
|
|
1581
|
+
x: number;
|
|
1582
|
+
y: number;
|
|
1583
|
+
visible: boolean;
|
|
1584
|
+
pressed: boolean;
|
|
1585
|
+
};
|
|
1586
|
+
effects: {
|
|
1587
|
+
kind: "click";
|
|
1588
|
+
x: number;
|
|
1589
|
+
y: number;
|
|
1590
|
+
/** Time since the effect started; the style decides how long it lasts. */
|
|
1591
|
+
age_us: number;
|
|
1592
|
+
}[];
|
|
1593
|
+
caption: null | {
|
|
1594
|
+
cue: RenderTimelineLocalId;
|
|
1595
|
+
lines: string[];
|
|
1596
|
+
highlight?: {
|
|
1597
|
+
line: number;
|
|
1598
|
+
byte_start: number;
|
|
1599
|
+
byte_end: number;
|
|
1600
|
+
};
|
|
1601
|
+
};
|
|
1602
|
+
/**
|
|
1603
|
+
* Opacity of the window layer (page, frame chrome, shadow, border, cursor, click effects) over the background; the background and the caption stay opaque.
|
|
1604
|
+
*/
|
|
1605
|
+
opacity: number;
|
|
1606
|
+
/**
|
|
1607
|
+
* Change since the previous output frame, for motion blur: camera center delta and log-zoom delta of the keyframe path (before the viewport clamp, so a camera held at an edge still reports its path), cursor delta (viewport space).
|
|
1608
|
+
*/
|
|
1609
|
+
motion?: {
|
|
1610
|
+
camera_dx?: number;
|
|
1611
|
+
camera_dy?: number;
|
|
1612
|
+
camera_dlog_zoom?: number;
|
|
1613
|
+
cursor_dx?: number;
|
|
1614
|
+
cursor_dy?: number;
|
|
1615
|
+
};
|
|
1616
|
+
}
|
|
1617
|
+
export interface Preset {
|
|
1618
|
+
id: PresetRef;
|
|
1619
|
+
object: "preset";
|
|
1620
|
+
kind: PresetKind;
|
|
1621
|
+
name: string;
|
|
1622
|
+
/**
|
|
1623
|
+
* A preview image of the preset, a B3OS static asset: `https://beta.b3os.org/assets/presets/<preset>.<ext>`
|
|
1624
|
+
* (B3OS's own media are never served from `usercontent.b3os.org`, which holds customer bytes only).
|
|
1625
|
+
*/
|
|
1626
|
+
preview_url?: string;
|
|
1627
|
+
}
|
|
1628
|
+
export type PresetList = Omit<ListEnvelope, "data"> & {
|
|
1629
|
+
data: Preset[];
|
|
1630
|
+
};
|
|
1631
|
+
/**
|
|
1632
|
+
* `running` → `paused` ↔ `running` → `stopped`. `failed` means the microVM crashed; its usage is final.
|
|
1633
|
+
*/
|
|
1634
|
+
export type SandboxStatus = "running" | "paused" | "stopped" | "failed";
|
|
1635
|
+
/**
|
|
1636
|
+
* A value placed in the environment but never returned or logged; either the value itself or a field of a vault connection.
|
|
1637
|
+
*/
|
|
1638
|
+
export type SecretValue = string | {
|
|
1639
|
+
connection: string;
|
|
1640
|
+
/**
|
|
1641
|
+
* Which secret field of the connection (vault.yaml names). Defaults to the field the egress proxy would
|
|
1642
|
+
* inject for its type: `api_key` for api_key, `token` for bearer, `access_token` for oauth2; basic
|
|
1643
|
+
* connections need `field` (`username` or `password`).
|
|
1644
|
+
*/
|
|
1645
|
+
field?: string;
|
|
1646
|
+
};
|
|
1647
|
+
export interface SandboxPort {
|
|
1648
|
+
port: number;
|
|
1649
|
+
/**
|
|
1650
|
+
* Reachable by anyone with the sandbox's long-lived port URL (`ports[].url` in the sandbox; its token lasts 7
|
|
1651
|
+
* days). Private ports (the default) need a URL minted with `POST /v1/sandboxes/{sandbox_id}/ports/{port}/url`.
|
|
1652
|
+
* @default false
|
|
1653
|
+
*/
|
|
1654
|
+
public?: boolean;
|
|
1655
|
+
}
|
|
1656
|
+
/**
|
|
1657
|
+
* What code inside the sandbox may call at `http://127.0.0.1:7700`. Empty by default, revoked when the sandbox stops.
|
|
1658
|
+
*/
|
|
1659
|
+
export interface SandboxApiGrant {
|
|
1660
|
+
/**
|
|
1661
|
+
* A subset of your own scopes. `*` and `<product>:*` expand to the scopes you hold, except `sandboxes:write`,
|
|
1662
|
+
* `vault:*` and `platform:*`, which are granted only when named exactly.
|
|
1663
|
+
*/
|
|
1664
|
+
scopes?: Scope[];
|
|
1665
|
+
/**
|
|
1666
|
+
* Stop the sandbox's own API calls at this spend. `null` (the default) means the creating principal's cap:
|
|
1667
|
+
* a key's own spend cap, or, when code in a sandbox creates this one, that sandbox's grant cap. When the
|
|
1668
|
+
* creator has a cap, a higher one here is refused with `403 forbidden`, `reason: scope_escalation`.
|
|
1669
|
+
*/
|
|
1670
|
+
spend_cap_usd?: number | null;
|
|
1671
|
+
/** Vault connections the sandbox's action calls may use. */
|
|
1672
|
+
connections?: string[];
|
|
1673
|
+
}
|
|
1674
|
+
/**
|
|
1675
|
+
* Where sandbox traffic may go, enforced by the node's egress guard. `public` (default): any public internet
|
|
1676
|
+
* address. `allowlist`: only hosts matching `allow` (exact hosts or `*.` wildcards). `deny`: no outbound
|
|
1677
|
+
* network at all. Private, loopback, tailnet and metadata addresses are always refused. A sandbox has at most
|
|
1678
|
+
* 512 outbound connections open and 64 DNS queries in flight at once; past that, new connections are refused
|
|
1679
|
+
* (`egress_unavailable`) and queries answered `SERVFAIL`. When the sandbox stops, its outbound connections
|
|
1680
|
+
* and its connections to `http://127.0.0.1:7700` close at once.
|
|
1681
|
+
*/
|
|
1682
|
+
export interface EgressPolicy {
|
|
1683
|
+
/** @default "public" */
|
|
1684
|
+
mode?: "public" | "allowlist" | "deny";
|
|
1685
|
+
allow?: string[];
|
|
1686
|
+
}
|
|
1687
|
+
export interface SandboxCreateRequest {
|
|
1688
|
+
/**
|
|
1689
|
+
* Template name or `tpl_` ID. Ignored when `snapshot` is set.
|
|
1690
|
+
* @default "base"
|
|
1691
|
+
*/
|
|
1692
|
+
template?: string;
|
|
1693
|
+
/** Restore this snapshot instead of starting from a template. */
|
|
1694
|
+
snapshot?: string;
|
|
1695
|
+
/**
|
|
1696
|
+
* Virtual CPUs (plan maximum in `GET /v1/limits`).
|
|
1697
|
+
* @default 1
|
|
1698
|
+
*/
|
|
1699
|
+
vcpu?: number;
|
|
1700
|
+
/** @default 512 */
|
|
1701
|
+
memory_mib?: number;
|
|
1702
|
+
/** Disk size; defaults to the template's. */
|
|
1703
|
+
disk_gib?: number;
|
|
1704
|
+
/**
|
|
1705
|
+
* Lifetime in seconds from creation (or from the last `POST …/timeout`), capped by your plan.
|
|
1706
|
+
* @default 300
|
|
1707
|
+
*/
|
|
1708
|
+
timeout_s?: number;
|
|
1709
|
+
/**
|
|
1710
|
+
* What happens at `expires_at`. `stop` destroys the sandbox; `pause` pauses it so a later resume (after extending the timeout) continues it.
|
|
1711
|
+
* @default "stop"
|
|
1712
|
+
*/
|
|
1713
|
+
on_idle?: "stop" | "pause";
|
|
1714
|
+
/** Environment variables. Returned as given; put credentials in `secrets`. */
|
|
1715
|
+
env?: Record<string, string>;
|
|
1716
|
+
/** Environment variables whose values are never returned or logged. */
|
|
1717
|
+
secrets?: Record<string, SecretValue>;
|
|
1718
|
+
ports?: SandboxPort[];
|
|
1719
|
+
api?: SandboxApiGrant;
|
|
1720
|
+
egress?: EgressPolicy;
|
|
1721
|
+
/**
|
|
1722
|
+
* Track dirty memory pages so the sandbox can be forked (stretch).
|
|
1723
|
+
* @default false
|
|
1724
|
+
*/
|
|
1725
|
+
forkable?: boolean;
|
|
1726
|
+
metadata?: Metadata;
|
|
1727
|
+
}
|
|
1728
|
+
export interface TemplateRef {
|
|
1729
|
+
id: string;
|
|
1730
|
+
name: string;
|
|
1731
|
+
}
|
|
1732
|
+
export interface Sandbox {
|
|
1733
|
+
id: string;
|
|
1734
|
+
object: "sandbox";
|
|
1735
|
+
status: SandboxStatus;
|
|
1736
|
+
/** The ID in host-safe form, used in port URLs. */
|
|
1737
|
+
host_id: string;
|
|
1738
|
+
template: TemplateRef;
|
|
1739
|
+
/** The snapshot the sandbox was restored from. */
|
|
1740
|
+
snapshot: string | null;
|
|
1741
|
+
vcpu: number;
|
|
1742
|
+
memory_mib: number;
|
|
1743
|
+
disk_gib: number;
|
|
1744
|
+
timeout_s: number;
|
|
1745
|
+
on_idle: "stop" | "pause";
|
|
1746
|
+
expires_at: string;
|
|
1747
|
+
env: Record<string, string>;
|
|
1748
|
+
/** Names of the variables set from `secrets` (values are never returned). */
|
|
1749
|
+
secret_names: string[];
|
|
1750
|
+
ports: {
|
|
1751
|
+
port: number;
|
|
1752
|
+
public: boolean;
|
|
1753
|
+
/**
|
|
1754
|
+
* Public ports: the long-lived preview URL, token included. Private ports: `null`; mint a URL with
|
|
1755
|
+
* `POST /v1/sandboxes/{sandbox_id}/ports/{port}/url`.
|
|
1756
|
+
*/
|
|
1757
|
+
url: string | null;
|
|
1758
|
+
}[];
|
|
1759
|
+
api: {
|
|
1760
|
+
scopes: string[];
|
|
1761
|
+
/** The grant's own cap, or `null` when the creating principal's cap applies. */
|
|
1762
|
+
spend_cap_usd: number | null;
|
|
1763
|
+
connections: string[];
|
|
1764
|
+
};
|
|
1765
|
+
egress: {
|
|
1766
|
+
mode: "public" | "allowlist" | "deny";
|
|
1767
|
+
allow: string[];
|
|
1768
|
+
};
|
|
1769
|
+
forkable: boolean;
|
|
1770
|
+
created_at: string;
|
|
1771
|
+
started_at: string;
|
|
1772
|
+
paused_at: string | null;
|
|
1773
|
+
stopped_at: string | null;
|
|
1774
|
+
/** Why the sandbox stopped. */
|
|
1775
|
+
stop_reason: "deleted" | "timeout" | "failed" | null;
|
|
1776
|
+
usage: {
|
|
1777
|
+
vcpu_ms: number;
|
|
1778
|
+
gib_ms: number;
|
|
1779
|
+
};
|
|
1780
|
+
timing?: Timing;
|
|
1781
|
+
metadata: Metadata;
|
|
1782
|
+
}
|
|
1783
|
+
export type SandboxList = Omit<ListEnvelope, "data"> & {
|
|
1784
|
+
data: Sandbox[];
|
|
1785
|
+
};
|
|
1786
|
+
export interface TimeoutRequest {
|
|
1787
|
+
timeout_s: number;
|
|
1788
|
+
}
|
|
1789
|
+
export interface ForkRequest {
|
|
1790
|
+
/** @default 1 */
|
|
1791
|
+
count?: number;
|
|
1792
|
+
metadata?: Metadata;
|
|
1793
|
+
}
|
|
1794
|
+
export interface ExecRequest {
|
|
1795
|
+
/** A shell command line (run with `/bin/sh -c`) or an argv array. */
|
|
1796
|
+
cmd: string | string[];
|
|
1797
|
+
/** @default "/workspace" */
|
|
1798
|
+
cwd?: string;
|
|
1799
|
+
/** Extra environment variables for this command. */
|
|
1800
|
+
env?: Record<string, string>;
|
|
1801
|
+
/** Written to the command's standard input, which is then closed. */
|
|
1802
|
+
stdin?: string;
|
|
1803
|
+
/**
|
|
1804
|
+
* Kill the command after this long. At most 60000 unless the output is streamed or the command runs in the background.
|
|
1805
|
+
* @default 30000
|
|
1806
|
+
*/
|
|
1807
|
+
timeout_ms?: number;
|
|
1808
|
+
/**
|
|
1809
|
+
* Return at once; read output from the logs stream.
|
|
1810
|
+
* @default false
|
|
1811
|
+
*/
|
|
1812
|
+
background?: boolean;
|
|
1813
|
+
/** @default "user" */
|
|
1814
|
+
user?: "user" | "root";
|
|
1815
|
+
}
|
|
1816
|
+
export interface ExecResult {
|
|
1817
|
+
object: "exec_result";
|
|
1818
|
+
/** The exit status; `null` when the command was killed by a signal. */
|
|
1819
|
+
exit_code: number | null;
|
|
1820
|
+
/** The signal that ended the command, such as `KILL` after a timeout. */
|
|
1821
|
+
signal: string | null;
|
|
1822
|
+
timed_out: boolean;
|
|
1823
|
+
stdout: string;
|
|
1824
|
+
stderr: string;
|
|
1825
|
+
/** More than 1 MiB of stdout was produced; the rest was dropped. */
|
|
1826
|
+
stdout_truncated: boolean;
|
|
1827
|
+
stderr_truncated: boolean;
|
|
1828
|
+
duration_ms: number;
|
|
1829
|
+
timing?: Timing;
|
|
1830
|
+
}
|
|
1831
|
+
/**
|
|
1832
|
+
* `exec.stdout` and `exec.stderr` carry `data`; `exec.exit` carries `exit_code`, `signal`, `timed_out` and `duration_ms`.
|
|
1833
|
+
*/
|
|
1834
|
+
export type ExecEvent = JobEvent & {
|
|
1835
|
+
data?: string;
|
|
1836
|
+
exit_code?: number | null;
|
|
1837
|
+
signal?: string | null;
|
|
1838
|
+
timed_out?: boolean;
|
|
1839
|
+
duration_ms?: number;
|
|
1840
|
+
};
|
|
1841
|
+
export interface SandboxProcess {
|
|
1842
|
+
object: "process";
|
|
1843
|
+
pid: number;
|
|
1844
|
+
/** The command as started (argv arrays are joined with spaces). */
|
|
1845
|
+
cmd: string;
|
|
1846
|
+
cwd?: string;
|
|
1847
|
+
status: "running" | "exited";
|
|
1848
|
+
exit_code: number | null;
|
|
1849
|
+
signal?: string | null;
|
|
1850
|
+
started_at: string;
|
|
1851
|
+
exited_at: string | null;
|
|
1852
|
+
}
|
|
1853
|
+
export type SandboxProcessList = Omit<ListEnvelope, "data"> & {
|
|
1854
|
+
data: SandboxProcess[];
|
|
1855
|
+
};
|
|
1856
|
+
export interface KillRequest {
|
|
1857
|
+
/** @default "TERM" */
|
|
1858
|
+
signal?: "TERM" | "KILL" | "INT" | "HUP";
|
|
1859
|
+
}
|
|
1860
|
+
/**
|
|
1861
|
+
* `log.stdout` and `log.stderr` carry `pid` and `data`; `process.exited` carries `pid` and `exit_code`.
|
|
1862
|
+
*/
|
|
1863
|
+
export type LogEvent = JobEvent & {
|
|
1864
|
+
pid?: number;
|
|
1865
|
+
data?: string;
|
|
1866
|
+
exit_code?: number | null;
|
|
1867
|
+
};
|
|
1868
|
+
export interface RunCodeRequest {
|
|
1869
|
+
code: string;
|
|
1870
|
+
/** @default "python" */
|
|
1871
|
+
language?: "python" | "javascript";
|
|
1872
|
+
/** @default 30000 */
|
|
1873
|
+
timeout_ms?: number;
|
|
1874
|
+
env?: Record<string, string>;
|
|
1875
|
+
}
|
|
1876
|
+
export interface RunCodeOutput {
|
|
1877
|
+
/** `text/plain`, `text/html`, `text/markdown`, `application/json`, `image/png`, `image/svg+xml`, … */
|
|
1878
|
+
mime_type: string;
|
|
1879
|
+
/** The value; base64 for binary types such as `image/png`. */
|
|
1880
|
+
data: string;
|
|
1881
|
+
/** The value of the cell's last expression. */
|
|
1882
|
+
is_main_result?: boolean;
|
|
1883
|
+
}
|
|
1884
|
+
export interface RunCodeResult {
|
|
1885
|
+
object: "run_code_result";
|
|
1886
|
+
language: "python" | "javascript";
|
|
1887
|
+
execution_count: number;
|
|
1888
|
+
results: RunCodeOutput[];
|
|
1889
|
+
stdout: string;
|
|
1890
|
+
stderr: string;
|
|
1891
|
+
/** The exception the cell raised, or `null`. */
|
|
1892
|
+
error: null | {
|
|
1893
|
+
name: string;
|
|
1894
|
+
value: string;
|
|
1895
|
+
traceback: string;
|
|
1896
|
+
};
|
|
1897
|
+
duration_ms: number;
|
|
1898
|
+
timing?: Timing;
|
|
1899
|
+
}
|
|
1900
|
+
export interface FileEntry {
|
|
1901
|
+
name: string;
|
|
1902
|
+
path: string;
|
|
1903
|
+
type: "file" | "directory" | "symlink";
|
|
1904
|
+
size: number;
|
|
1905
|
+
/** Octal permission bits. */
|
|
1906
|
+
mode: string;
|
|
1907
|
+
modified_at: string;
|
|
1908
|
+
/** Symlink target. */
|
|
1909
|
+
target?: string;
|
|
1910
|
+
}
|
|
1911
|
+
export type FileEntryList = Omit<ListEnvelope, "data"> & {
|
|
1912
|
+
data: FileEntry[];
|
|
1913
|
+
};
|
|
1914
|
+
export interface PortUrlRequest {
|
|
1915
|
+
/**
|
|
1916
|
+
* How long the URL works, in seconds. Ignored for public ports.
|
|
1917
|
+
* @default 600
|
|
1918
|
+
*/
|
|
1919
|
+
ttl_s?: number;
|
|
1920
|
+
}
|
|
1921
|
+
export interface PortUrl {
|
|
1922
|
+
object: "port_url";
|
|
1923
|
+
port: number;
|
|
1924
|
+
public: boolean;
|
|
1925
|
+
/** `https://usercontent.b3os.org/sbx/<host_id>/<port>/<token>/`; the token is in the path. */
|
|
1926
|
+
url: string;
|
|
1927
|
+
/** When the token in `url` expires. */
|
|
1928
|
+
expires_at: string;
|
|
1929
|
+
}
|
|
1930
|
+
export interface SnapshotCreateRequest {
|
|
1931
|
+
name?: string;
|
|
1932
|
+
metadata?: Metadata;
|
|
1933
|
+
}
|
|
1934
|
+
export interface Snapshot {
|
|
1935
|
+
id: string;
|
|
1936
|
+
object: "snapshot";
|
|
1937
|
+
name?: string | null;
|
|
1938
|
+
status: "creating" | "ready" | "failed";
|
|
1939
|
+
sandbox_id: string;
|
|
1940
|
+
template: TemplateRef;
|
|
1941
|
+
vcpu: number;
|
|
1942
|
+
memory_mib: number;
|
|
1943
|
+
disk_gib: number;
|
|
1944
|
+
size_bytes: number;
|
|
1945
|
+
created_at: string;
|
|
1946
|
+
/** When the snapshot is deleted (7 days in the beta). */
|
|
1947
|
+
expires_at: string | null;
|
|
1948
|
+
timing?: Timing;
|
|
1949
|
+
metadata: Metadata;
|
|
1950
|
+
}
|
|
1951
|
+
export type SnapshotList = Omit<ListEnvelope, "data"> & {
|
|
1952
|
+
data: Snapshot[];
|
|
1953
|
+
};
|
|
1954
|
+
export interface Template {
|
|
1955
|
+
id: string;
|
|
1956
|
+
object: "template";
|
|
1957
|
+
name: string;
|
|
1958
|
+
description: string;
|
|
1959
|
+
os: string;
|
|
1960
|
+
runtimes: string[];
|
|
1961
|
+
/**
|
|
1962
|
+
* `cdp`: Chrome runs in the template's snapshot with DevTools on `127.0.0.1:9222` inside the sandbox; declare
|
|
1963
|
+
* port 9222 to reach it through a port preview.
|
|
1964
|
+
*/
|
|
1965
|
+
capabilities: Array<"exec" | "files" | "pty" | "run_code" | "cdp">;
|
|
1966
|
+
defaults: {
|
|
1967
|
+
vcpu: number;
|
|
1968
|
+
memory_mib: number;
|
|
1969
|
+
disk_gib: number;
|
|
1970
|
+
};
|
|
1971
|
+
created_at: string;
|
|
1972
|
+
}
|
|
1973
|
+
export type TemplateList = Omit<ListEnvelope, "data"> & {
|
|
1974
|
+
data: Template[];
|
|
1975
|
+
};
|
|
1976
|
+
/**
|
|
1977
|
+
* A routine as sent to PUT /v1/routines/{id} (ARCHITECTURE 5.4). GitHub-Actions-shaped: triggers, defaults and an ordered list of steps; expressions are CEL inside ${{ }}. Steps run in array order unless a step lists needs. Contexts, status functions, template rules and the divergences from GitHub Actions are in packages/spec/schemas/README.md. Compile-time rules JSON Schema cannot express (unique ids, needs pointing at earlier steps, references only to ancestors, retry forbidden on irreversible steps) are listed there under 'Routine publish checks'. Owner after freeze: routines.
|
|
1978
|
+
*/
|
|
1979
|
+
export interface RoutineDefinition {
|
|
1980
|
+
/** Optional pointer to this schema for editors. */
|
|
1981
|
+
$schema?: string;
|
|
1982
|
+
/**
|
|
1983
|
+
* Routine slug, unique within the project. Used by the CLI (b3os routine deploy); an MCP server that lists routines as tools names the tool routine_<name> with - mapped to _. runs, hooks, validate and import are reserved: they are API paths under /v1/routines.
|
|
1984
|
+
*/
|
|
1985
|
+
name: string;
|
|
1986
|
+
/** What the routine does; an MCP server that lists routines as tools uses it as the tool description. */
|
|
1987
|
+
description?: string;
|
|
1988
|
+
/**
|
|
1989
|
+
* JSON Schema 2020-12 for the run input, available as inputs. Defaults declared here are applied before the run starts. Absent: the run takes no input ({}).
|
|
1990
|
+
*/
|
|
1991
|
+
inputs?: RoutineDefinitionJsonSchemaObject;
|
|
1992
|
+
/**
|
|
1993
|
+
* The run's result, evaluated once after every step has finished and the run succeeded. Absent: the result is {}. Context: inputs, vars, env, trigger, run, steps (all).
|
|
1994
|
+
*/
|
|
1995
|
+
output?: RoutineDefinitionTemplateValue;
|
|
1996
|
+
/**
|
|
1997
|
+
* Non-secret strings evaluated once at run start (context: inputs, vars, trigger, run) and exposed as env.<NAME>. Not passed to sandboxes implicitly; put what a step needs in its with.
|
|
1998
|
+
*/
|
|
1999
|
+
env?: Record<string, RoutineDefinitionTemplateString>;
|
|
2000
|
+
/**
|
|
2001
|
+
* Read-only JSON constants exposed as vars.<name>. Values are literals; strings in them are not evaluated as templates.
|
|
2002
|
+
*/
|
|
2003
|
+
vars?: Record<string, unknown>;
|
|
2004
|
+
/**
|
|
2005
|
+
* How runs start besides POST /v1/routines/{id}/runs. Triggers switch atomically when a new version is published. Action triggers are trigger subscriptions (tsub_): publishing a version creates or updates them, and a rollback or delete removes them (README, 'Pack triggers').
|
|
2006
|
+
*/
|
|
2007
|
+
triggers?: RoutineDefinitionTrigger[];
|
|
2008
|
+
defaults?: {
|
|
2009
|
+
/**
|
|
2010
|
+
* ephemeral: memory only, nothing journaled (the agent tool-call fast path; a crash loses the run). standard: group-commit journal, effects durable before dependents run. strict: intent and result commits for every effect step (ARCHITECTURE 4.9, 5.4). A run may request a different tier at start.
|
|
2011
|
+
* @default "standard"
|
|
2012
|
+
*/
|
|
2013
|
+
durability?: "ephemeral" | "standard" | "strict";
|
|
2014
|
+
/**
|
|
2015
|
+
* Default timeout for uses and map steps that do not set timeout_ms. Wait and sleep steps are not affected.
|
|
2016
|
+
* @default 30000
|
|
2017
|
+
*/
|
|
2018
|
+
timeout_ms?: number;
|
|
2019
|
+
/**
|
|
2020
|
+
* Default retry policy, applied only to steps whose effect class is pure or read. A write step retries only when it sets retry itself; an irreversible step never retries.
|
|
2021
|
+
*/
|
|
2022
|
+
retry?: RoutineDefinitionRetry;
|
|
2023
|
+
/**
|
|
2024
|
+
* Admission for runs of this routine, shaped like GitHub's concurrency. At most limit runs are active per group; on_limit decides what a new run does when the group is full.
|
|
2025
|
+
*/
|
|
2026
|
+
concurrency?: {
|
|
2027
|
+
limit: number;
|
|
2028
|
+
/**
|
|
2029
|
+
* Group key evaluated at run start (context: inputs, vars, trigger). Default: one group for the routine.
|
|
2030
|
+
*/
|
|
2031
|
+
group?: RoutineDefinitionTemplateString;
|
|
2032
|
+
/**
|
|
2033
|
+
* queue: wait (FIFO) for a free slot. skip: the new run ends canceled with reason concurrency_skipped. cancel_running: cancel the oldest active run in the group, then start.
|
|
2034
|
+
* @default "queue"
|
|
2035
|
+
*/
|
|
2036
|
+
on_limit?: "queue" | "skip" | "cancel_running";
|
|
2037
|
+
};
|
|
2038
|
+
};
|
|
2039
|
+
steps: RoutineDefinitionStep[];
|
|
2040
|
+
}
|
|
2041
|
+
/**
|
|
2042
|
+
* A CEL identifier (so steps.<id>.outputs parses): lowercase letters, digits and _, not a CEL reserved word.
|
|
2043
|
+
*/
|
|
2044
|
+
export type RoutineDefinitionIdent = string;
|
|
2045
|
+
export type RoutineDefinitionJsonSchemaObject = JsonSchemaDocument & {
|
|
2046
|
+
type: "object";
|
|
2047
|
+
};
|
|
2048
|
+
/** Exactly one CEL expression wrapped as the whole string: ${{ <cel> }}. Keeps its CEL type. */
|
|
2049
|
+
export type RoutineDefinitionCelExpression = string;
|
|
2050
|
+
/**
|
|
2051
|
+
* A CEL bool expression, bare or wrapped in one ${{ }} (both forms are accepted, as in GitHub's if). Without a call to success(), failure() or always(), the condition is implicitly success() && (<expression>).
|
|
2052
|
+
*/
|
|
2053
|
+
export type RoutineDefinitionCondition = string;
|
|
2054
|
+
/** A string that may contain ${{ <cel> }} expressions (README, 'Templates'). */
|
|
2055
|
+
export type RoutineDefinitionTemplateString = string;
|
|
2056
|
+
/** Any JSON value; strings inside it at any depth are template strings, object keys are literal. */
|
|
2057
|
+
export type RoutineDefinitionTemplateValue = unknown;
|
|
2058
|
+
/** An object of template values. */
|
|
2059
|
+
export type RoutineDefinitionTemplateObject = Record<string, unknown>;
|
|
2060
|
+
/** Milliseconds: a literal integer or one CEL expression that evaluates to an int. */
|
|
2061
|
+
export type RoutineDefinitionDurationMs = number | RoutineDefinitionCelExpression;
|
|
2062
|
+
/**
|
|
2063
|
+
* <ref>@<ver>. First-party: vision/<name>@<major>, render/<name>@<major>, sandboxes/<name>@<major>, infer/<name>@<major>, core/http@1, core/transform@1, core/log@1 (core/map, core/wait and core/sleep are written as the map, wait and sleep_ms step fields). Sub-routine: routine/<rtn_id>@<ver_id>. Pack action: <namespace>/<pack>/<action>@<semver>, or @<major> which is resolved to the newest matching release when the version is published and pinned in it. The compiler checks that the callable exists and validates with against its input schema.
|
|
2064
|
+
*/
|
|
2065
|
+
export type RoutineDefinitionCallable = string;
|
|
2066
|
+
/**
|
|
2067
|
+
* A pack trigger: <namespace>/<pack>/<trigger>@<semver>, or @<major>, which is resolved to the newest matching release when the version is published and pinned in it (and in the trigger subscription).
|
|
2068
|
+
*/
|
|
2069
|
+
export type RoutineDefinitionTriggerRef = string;
|
|
2070
|
+
/**
|
|
2071
|
+
* Attempt n (n >= 2) starts after min(max_ms, initial_ms * factor^(n-2)) ms; with jitter the delay is drawn uniformly from [delay/2, delay] using a PRNG seeded by (run id, step id, item index, attempt), so replay is deterministic. Only failures the callee marks retryable (and timeouts of pure or read steps) are retried. Every attempt of a step carries the same idempotency key.
|
|
2072
|
+
*/
|
|
2073
|
+
export interface RoutineDefinitionRetry {
|
|
2074
|
+
/** Total attempts including the first. */
|
|
2075
|
+
max_attempts: number;
|
|
2076
|
+
/** @default 200 */
|
|
2077
|
+
initial_ms?: number;
|
|
2078
|
+
/** @default 2 */
|
|
2079
|
+
factor?: number;
|
|
2080
|
+
/** @default 30000 */
|
|
2081
|
+
max_ms?: number;
|
|
2082
|
+
/** @default true */
|
|
2083
|
+
jitter?: boolean;
|
|
2084
|
+
}
|
|
2085
|
+
/** A vault connection id, or one CEL expression that evaluates to one (for example from vars). */
|
|
2086
|
+
export type RoutineDefinitionConnectionRef = string;
|
|
2087
|
+
/**
|
|
2088
|
+
* Exactly one of uses (call), map (fan-out), wait (signal or time) or sleep_ms (delay). Without needs a step depends on the step before it in the same list (the first step has no dependency); needs: [] makes it a root that starts immediately. Ids are unique across the whole routine, including map bodies.
|
|
2089
|
+
*/
|
|
2090
|
+
export type RoutineDefinitionStep = {
|
|
2091
|
+
id: RoutineDefinitionIdent;
|
|
2092
|
+
/** Display label. */
|
|
2093
|
+
name?: string;
|
|
2094
|
+
uses?: RoutineDefinitionCallable;
|
|
2095
|
+
/**
|
|
2096
|
+
* Input for the callable. Context: inputs, vars, env, trigger, run, steps (ancestors only), item and index inside a map body.
|
|
2097
|
+
*/
|
|
2098
|
+
with?: RoutineDefinitionTemplateObject;
|
|
2099
|
+
/**
|
|
2100
|
+
* Pack action steps only: binds the pack's connection keys to vault connections. A key left out is resolved when the step runs with SecretStore::find_connection (the most recently created connection for that pack the run's principal may use); when there is none the step fails with connection_required. Bind explicitly when a project holds several.
|
|
2101
|
+
*/
|
|
2102
|
+
connections?: Record<string, RoutineDefinitionConnectionRef>;
|
|
2103
|
+
/**
|
|
2104
|
+
* Runs steps once per element of over. Inside the body, item is the element and index its position; steps.<id> of a body step refers to the current item. outputs of the map step: {items: [the last body step's outputs per element, null for failed or skipped items], outcomes: [outcome per element]}, both in input order. An item fails when a body step fails without continue_on_error; the first failed item cancels in-flight items and fails the map.
|
|
2105
|
+
*/
|
|
2106
|
+
map?: {
|
|
2107
|
+
/** Must evaluate to a list (at most 10,000 elements). */
|
|
2108
|
+
over: RoutineDefinitionCelExpression;
|
|
2109
|
+
/** @default 8 */
|
|
2110
|
+
concurrency?: number;
|
|
2111
|
+
steps: RoutineDefinitionStep[];
|
|
2112
|
+
};
|
|
2113
|
+
/**
|
|
2114
|
+
* Blocks the step without holding resources. {signal}: wait for POST /v1/routines/runs/{run_id}/signal with that name (signals sent before the step starts are buffered, at most 16 per signal name per run, and consumed in order). {signal, ms} or {signal, until}: give up at the deadline. {until}: wait for a time. outputs for signal waits: {signal, payload, received_at, timed_out}; a deadline is not a failure: timed_out is true and signal, payload and received_at are null. outputs for {until}: {fired_at}.
|
|
2115
|
+
*/
|
|
2116
|
+
wait?: {
|
|
2117
|
+
signal?: string;
|
|
2118
|
+
/** RFC 3339 timestamp, literal or produced by an expression. */
|
|
2119
|
+
until?: RoutineDefinitionTemplateString;
|
|
2120
|
+
/** Signal waits only: maximum wait. */
|
|
2121
|
+
ms?: RoutineDefinitionDurationMs;
|
|
2122
|
+
};
|
|
2123
|
+
/** Durable delay; outputs {}. */
|
|
2124
|
+
sleep_ms?: RoutineDefinitionDurationMs;
|
|
2125
|
+
/** Ids of earlier steps in the same list that must finish first. */
|
|
2126
|
+
needs?: RoutineDefinitionIdent[];
|
|
2127
|
+
if?: RoutineDefinitionCondition;
|
|
2128
|
+
retry?: RoutineDefinitionRetry;
|
|
2129
|
+
/** uses steps: per attempt. map steps: the whole map. */
|
|
2130
|
+
timeout_ms?: number;
|
|
2131
|
+
/**
|
|
2132
|
+
* When the step fails, its outcome is failure but its conclusion is success, so dependents run and the run can still succeed.
|
|
2133
|
+
* @default false
|
|
2134
|
+
*/
|
|
2135
|
+
continue_on_error?: boolean;
|
|
2136
|
+
};
|
|
2137
|
+
/**
|
|
2138
|
+
* core/http@1: one HTTP request through the egress guard, with no credentials (bind credentials through a pack action instead). Effect class read for GET and HEAD, write otherwise. outputs: {status: int, headers: map of lowercase name to string, body: parsed JSON when the response is JSON, else string}. A status >= 400 fails the step with upstream_error (retryable for 429 and 5xx) unless fail_on_error_status is false.
|
|
2139
|
+
*/
|
|
2140
|
+
export interface RoutineDefinitionCoreHttpWith {
|
|
2141
|
+
/** @default "GET" */
|
|
2142
|
+
method?: "GET" | "HEAD" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
2143
|
+
url: RoutineDefinitionTemplateString;
|
|
2144
|
+
headers?: Record<string, RoutineDefinitionTemplateString>;
|
|
2145
|
+
query?: Record<string, RoutineDefinitionTemplateValue>;
|
|
2146
|
+
body?: RoutineDefinitionTemplateValue;
|
|
2147
|
+
/** @default "json" */
|
|
2148
|
+
body_encoding?: "json" | "form" | "text";
|
|
2149
|
+
/** @default "auto" */
|
|
2150
|
+
response?: "auto" | "json" | "text";
|
|
2151
|
+
/** @default true */
|
|
2152
|
+
fail_on_error_status?: boolean;
|
|
2153
|
+
}
|
|
2154
|
+
/** core/transform@1: evaluates value; outputs {value}. Effect class pure. */
|
|
2155
|
+
export interface RoutineDefinitionCoreTransformWith {
|
|
2156
|
+
value: RoutineDefinitionTemplateValue;
|
|
2157
|
+
}
|
|
2158
|
+
/** core/log@1: writes a log event to the run's event stream; outputs {}. Effect class pure. */
|
|
2159
|
+
export interface RoutineDefinitionCoreLogWith {
|
|
2160
|
+
message: RoutineDefinitionTemplateString;
|
|
2161
|
+
/** @default "info" */
|
|
2162
|
+
level?: "debug" | "info" | "warn" | "error";
|
|
2163
|
+
data?: RoutineDefinitionTemplateValue;
|
|
2164
|
+
}
|
|
2165
|
+
/**
|
|
2166
|
+
* Occurrences missed while the node was down or the routine was paused: skip runs none, latest runs only the newest one, all runs each one in order. Only occurrences inside catch_up_window_s count. Required on every schedule (ARCHITECTURE 8).
|
|
2167
|
+
*/
|
|
2168
|
+
export type RoutineDefinitionCatchUp = "skip" | "latest" | "all";
|
|
2169
|
+
/**
|
|
2170
|
+
* When an occurrence fires while a run started by this trigger is still active: skip drops it, buffer_one keeps at most one pending occurrence (a newer one replaces it), allow starts it anyway, cancel_running cancels the active run first. defaults.concurrency still applies on top.
|
|
2171
|
+
*/
|
|
2172
|
+
export type RoutineDefinitionOverlap = "skip" | "buffer_one" | "allow" | "cancel_running";
|
|
2173
|
+
/**
|
|
2174
|
+
* trigger context by type. cron and interval: {type, id, occurrence_id, scheduled_at, fired_at}. webhook: {type, id, hook_id, delivery_id, received_at, method, headers (lowercase map), query (map), body (parsed JSON when the request is JSON, else string)}. action: {type, id, subscription_id, event_id, event_type, source, time, data (the pack trigger's event data, valid against its eventSchema)}. Runs started through the API: {type: api}; sub-routine runs: {type: routine, parent_run_id, parent_step_id}.
|
|
2175
|
+
*/
|
|
2176
|
+
export type RoutineDefinitionTrigger = {
|
|
2177
|
+
type: "cron" | "interval" | "webhook" | "action";
|
|
2178
|
+
id: RoutineDefinitionIdent;
|
|
2179
|
+
/** action only: the pack trigger to subscribe to. */
|
|
2180
|
+
uses?: RoutineDefinitionTriggerRef;
|
|
2181
|
+
/**
|
|
2182
|
+
* cron, interval, webhook: the run input built from the event (context: trigger, vars), validated against inputs; absent: {} plus input defaults. action: the pack trigger's configuration, validated against its configSchema and evaluated once when the version is published (context: vars only); action runs start with {} plus input defaults and read the event from trigger.data.
|
|
2183
|
+
*/
|
|
2184
|
+
with?: RoutineDefinitionTemplateObject;
|
|
2185
|
+
/**
|
|
2186
|
+
* action only: binds the pack trigger's connection keys (its requires.connections) to vault connections. A key left out is resolved when the version is published (the most recently created connection for that pack the publishing key may use) and pinned in the subscription; when there is none the publish fails with routine_invalid.
|
|
2187
|
+
*/
|
|
2188
|
+
connections?: Record<string, RoutineDefinitionConnectionRef>;
|
|
2189
|
+
/**
|
|
2190
|
+
* Start a run only when true (context: trigger, vars). A webhook delivery that does not match is acknowledged with 202 and starts nothing; an action event that does not match is dropped. Status functions are not available here.
|
|
2191
|
+
*/
|
|
2192
|
+
if?: RoutineDefinitionCondition;
|
|
2193
|
+
/**
|
|
2194
|
+
* Six fields with seconds: second minute hour day-of-month month day-of-week, single spaces. Numbers, names (JAN, MON), *, a-b, a,b, *\/n and ? are accepted; L, W and # in the day fields.
|
|
2195
|
+
*/
|
|
2196
|
+
cron?: string;
|
|
2197
|
+
/**
|
|
2198
|
+
* IANA zone for cron, default UTC. A local time skipped by a DST change fires at the first instant after the gap; a local time that occurs twice fires once, at its first occurrence.
|
|
2199
|
+
*/
|
|
2200
|
+
tz?: string;
|
|
2201
|
+
/** Interval period. Plans may raise the floor (GET /v1/limits). */
|
|
2202
|
+
every_ms?: number;
|
|
2203
|
+
/**
|
|
2204
|
+
* interval: epoch fires at Unix-epoch multiples of every_ms (clock aligned); publish fires every_ms after the version became active, then every every_ms.
|
|
2205
|
+
* @default "epoch"
|
|
2206
|
+
*/
|
|
2207
|
+
anchor?: "epoch" | "publish";
|
|
2208
|
+
catch_up?: RoutineDefinitionCatchUp;
|
|
2209
|
+
/** @default 86400 */
|
|
2210
|
+
catch_up_window_s?: number;
|
|
2211
|
+
overlap?: RoutineDefinitionOverlap;
|
|
2212
|
+
verify?: RoutineDefinitionWebhookVerify;
|
|
2213
|
+
/**
|
|
2214
|
+
* webhook: string key; a second delivery with the same key within 24 h returns the first delivery's response and starts nothing. Default per scheme: github X-GitHub-Delivery, stripe body.id, slack body.event_id, standard_webhooks webhook-id, b3os the Idempotency-Key header or else the v1 signature, hmac_sha256 none (then dedupe is required).
|
|
2215
|
+
*/
|
|
2216
|
+
dedupe?: RoutineDefinitionCelExpression;
|
|
2217
|
+
};
|
|
2218
|
+
/**
|
|
2219
|
+
* Mandatory verification for POST /v1/routines/hooks/{hk_id} (ARCHITECTURE 4.3); the hk_ id is created when the version is published. b3os: B3OS-Signature 't=<unix>,v1=<hex HMAC-SHA256(secret, "<t>.<body>")>' with a per-hook secret B3OS generates (shown once by the API). github, stripe, slack, standard_webhooks: the provider's scheme as in b3pack verify. hmac_sha256: generic, and always timestamped: the signature covers '<value of timestamp_header>.<body>', and a delivery whose timestamp header is missing or not a Unix time is refused. Timestamped schemes reject deliveries more than tolerance_s (at most 300 s) from the node clock. Secrets never appear in the URL.
|
|
2220
|
+
*/
|
|
2221
|
+
export type RoutineDefinitionWebhookVerify = {
|
|
2222
|
+
scheme: "b3os" | "github" | "stripe" | "slack" | "standard_webhooks" | "hmac_sha256";
|
|
2223
|
+
/**
|
|
2224
|
+
* An api_key vault connection whose api_key field holds the provider's signing secret (vault.yaml field names). Store it as a verification-only connection, without pack and without hosts: B3OS reads it to check signatures, and a connection with no hosts is never injected into any request. Not used with b3os.
|
|
2225
|
+
*/
|
|
2226
|
+
secret?: string;
|
|
2227
|
+
header?: string;
|
|
2228
|
+
encoding?: "hex" | "base64";
|
|
2229
|
+
prefix?: string;
|
|
2230
|
+
/** hmac_sha256 only, and required there: header carrying the delivery's Unix timestamp. */
|
|
2231
|
+
timestamp_header?: string;
|
|
2232
|
+
/** @default 300 */
|
|
2233
|
+
tolerance_s?: number;
|
|
2234
|
+
};
|
|
2235
|
+
export interface RoutineVersionRef {
|
|
2236
|
+
id: string;
|
|
2237
|
+
number: number;
|
|
2238
|
+
created_at: string;
|
|
2239
|
+
}
|
|
2240
|
+
export interface RoutineHook {
|
|
2241
|
+
id: string;
|
|
2242
|
+
/** Give this URL to the provider. */
|
|
2243
|
+
url: string;
|
|
2244
|
+
verify: "b3os" | "github" | "stripe" | "slack" | "standard_webhooks" | "hmac_sha256";
|
|
2245
|
+
/**
|
|
2246
|
+
* The `b3os` scheme's signing secret. Present only in the response of the publish that created the hook (and of a rotation).
|
|
2247
|
+
*/
|
|
2248
|
+
secret?: string;
|
|
2249
|
+
}
|
|
2250
|
+
export interface RoutineTrigger {
|
|
2251
|
+
/** The trigger's `id` in the definition. */
|
|
2252
|
+
id: string;
|
|
2253
|
+
type: "cron" | "interval" | "webhook" | "action";
|
|
2254
|
+
status: "active" | "paused";
|
|
2255
|
+
/** Next scheduled fire (cron and interval), or `null`. */
|
|
2256
|
+
next_fire_at: string | null;
|
|
2257
|
+
/** The inbound URL of a webhook trigger, or `null`. */
|
|
2258
|
+
hook: null | RoutineHook;
|
|
2259
|
+
/**
|
|
2260
|
+
* The trigger subscription of an action trigger (`GET /v1/actions/subscriptions/{subscription_id}`), or `null`.
|
|
2261
|
+
*/
|
|
2262
|
+
subscription_id: string | null;
|
|
2263
|
+
}
|
|
2264
|
+
export interface Routine {
|
|
2265
|
+
id: string;
|
|
2266
|
+
object: "routine";
|
|
2267
|
+
name: string;
|
|
2268
|
+
description: string | null;
|
|
2269
|
+
/** `paused` when triggers are stopped; API runs still work unless `paused_reason` is `run_as_revoked`. */
|
|
2270
|
+
status: "active" | "paused";
|
|
2271
|
+
paused_reason: "manual" | "run_as_revoked" | null;
|
|
2272
|
+
version: RoutineVersionRef;
|
|
2273
|
+
triggers: RoutineTrigger[];
|
|
2274
|
+
/**
|
|
2275
|
+
* The identity runs execute as (the key that published the active version, with its scopes at publish time).
|
|
2276
|
+
*/
|
|
2277
|
+
run_as: {
|
|
2278
|
+
/** The API key ID; `null` when a dashboard user published. */
|
|
2279
|
+
key: string | null;
|
|
2280
|
+
scopes: string[];
|
|
2281
|
+
};
|
|
2282
|
+
created_at: string;
|
|
2283
|
+
updated_at: string;
|
|
2284
|
+
metadata: Metadata;
|
|
2285
|
+
}
|
|
2286
|
+
export type RoutineList = Omit<ListEnvelope, "data"> & {
|
|
2287
|
+
data: Routine[];
|
|
2288
|
+
};
|
|
2289
|
+
export interface RoutineUpdateRequest {
|
|
2290
|
+
paused?: boolean;
|
|
2291
|
+
metadata?: Metadata;
|
|
2292
|
+
}
|
|
2293
|
+
export interface RollbackRequest {
|
|
2294
|
+
/** A `ver_` ID or a version number. */
|
|
2295
|
+
version: string | number;
|
|
2296
|
+
}
|
|
2297
|
+
export interface RoutineVersion {
|
|
2298
|
+
id: string;
|
|
2299
|
+
object: "routine_version";
|
|
2300
|
+
routine_id: string;
|
|
2301
|
+
number: number;
|
|
2302
|
+
active: boolean;
|
|
2303
|
+
/** The key ID that published this version. */
|
|
2304
|
+
published_by: string | null;
|
|
2305
|
+
/** The publisher's scopes, snapshotted; runs of this version get at most these. */
|
|
2306
|
+
scopes: string[];
|
|
2307
|
+
created_at: string;
|
|
2308
|
+
definition?: RoutineDefinition;
|
|
2309
|
+
}
|
|
2310
|
+
export type RoutineVersionList = Omit<ListEnvelope, "data"> & {
|
|
2311
|
+
data: RoutineVersion[];
|
|
2312
|
+
};
|
|
2313
|
+
export interface Diagnostic {
|
|
2314
|
+
severity: "error" | "warning";
|
|
2315
|
+
/** An error code from the catalog, such as `routine_invalid` or `connection_required`. */
|
|
2316
|
+
code: string;
|
|
2317
|
+
/** JSON pointer into the definition. */
|
|
2318
|
+
pointer: string;
|
|
2319
|
+
detail: string;
|
|
2320
|
+
}
|
|
2321
|
+
export interface RoutineValidation {
|
|
2322
|
+
object: "routine_validation";
|
|
2323
|
+
valid: boolean;
|
|
2324
|
+
diagnostics: Diagnostic[];
|
|
2325
|
+
/** Number of steps in the compiled plan, map bodies included. */
|
|
2326
|
+
steps?: number;
|
|
2327
|
+
}
|
|
2328
|
+
export interface RoutineImportRequest {
|
|
2329
|
+
format: "b3os-workflow-v1";
|
|
2330
|
+
/** The workflow JSON exported from the original B3OS app. */
|
|
2331
|
+
workflow: Record<string, unknown>;
|
|
2332
|
+
}
|
|
2333
|
+
export interface RoutineImport {
|
|
2334
|
+
object: "routine_import";
|
|
2335
|
+
definition: RoutineDefinition;
|
|
2336
|
+
diagnostics: Diagnostic[];
|
|
2337
|
+
}
|
|
2338
|
+
export interface HookRotateRequest {
|
|
2339
|
+
/** @default 86400 */
|
|
2340
|
+
grace_s?: number;
|
|
2341
|
+
}
|
|
2342
|
+
export interface HookSecret {
|
|
2343
|
+
object: "hook_secret";
|
|
2344
|
+
hook_id: string;
|
|
2345
|
+
secret: string;
|
|
2346
|
+
previous_valid_until: string | null;
|
|
2347
|
+
}
|
|
2348
|
+
/** How the run started (the `trigger` context of its expressions). */
|
|
2349
|
+
export interface RunTrigger {
|
|
2350
|
+
type: "api" | "cron" | "interval" | "webhook" | "action" | "routine";
|
|
2351
|
+
/** The trigger ID (cron, interval, webhook, action). */
|
|
2352
|
+
id?: string;
|
|
2353
|
+
/** Cron and interval occurrence, used to deduplicate fires. */
|
|
2354
|
+
occurrence_id?: string;
|
|
2355
|
+
scheduled_at?: string;
|
|
2356
|
+
hook_id?: string;
|
|
2357
|
+
delivery_id?: string;
|
|
2358
|
+
/** The trigger subscription that delivered the event (action triggers). */
|
|
2359
|
+
subscription_id?: string;
|
|
2360
|
+
/** The pack trigger event's ID (action triggers). */
|
|
2361
|
+
event_id?: string;
|
|
2362
|
+
/** For sub-routine runs. */
|
|
2363
|
+
parent_run_id?: string;
|
|
2364
|
+
parent_step_id?: string;
|
|
2365
|
+
}
|
|
2366
|
+
export interface StepRun {
|
|
2367
|
+
/** The step ID from the definition. */
|
|
2368
|
+
id: string;
|
|
2369
|
+
uses?: string;
|
|
2370
|
+
/** Position in the map's list, for steps inside a map body. */
|
|
2371
|
+
item_index?: number;
|
|
2372
|
+
status: "pending" | "running" | "waiting" | "retrying" | "succeeded" | "failed" | "skipped" | "canceled";
|
|
2373
|
+
attempt: number;
|
|
2374
|
+
started_at?: string;
|
|
2375
|
+
finished_at?: string;
|
|
2376
|
+
duration_ms?: number;
|
|
2377
|
+
/** The step's outputs, once it succeeded. */
|
|
2378
|
+
outputs?: unknown;
|
|
2379
|
+
error?: Problem;
|
|
2380
|
+
/** Item counts for a map step. */
|
|
2381
|
+
map?: {
|
|
2382
|
+
total?: number;
|
|
2383
|
+
succeeded?: number;
|
|
2384
|
+
failed?: number;
|
|
2385
|
+
running?: number;
|
|
2386
|
+
};
|
|
2387
|
+
/** What a waiting step waits for. */
|
|
2388
|
+
waiting_for?: {
|
|
2389
|
+
signal?: string;
|
|
2390
|
+
until?: string;
|
|
2391
|
+
};
|
|
2392
|
+
}
|
|
2393
|
+
export type StepRunList = Omit<ListEnvelope, "data"> & {
|
|
2394
|
+
data: StepRun[];
|
|
2395
|
+
};
|
|
2396
|
+
export interface RunCreateRequest {
|
|
2397
|
+
/** Validated against the routine's `inputs`; defaults from it are applied. */
|
|
2398
|
+
input?: Record<string, unknown>;
|
|
2399
|
+
/** Run this version instead of the active one (`ver_` ID or number). */
|
|
2400
|
+
version?: string | number;
|
|
2401
|
+
/** Override the routine's default durability for this run. */
|
|
2402
|
+
durability?: "ephemeral" | "standard" | "strict";
|
|
2403
|
+
webhook?: WebhookConfig;
|
|
2404
|
+
metadata?: Metadata;
|
|
2405
|
+
}
|
|
2406
|
+
/** A routine run (`run_…`); `result` is the routine's `output`. */
|
|
2407
|
+
export type RoutineRun = Omit<Job, "id" | "object"> & {
|
|
2408
|
+
id: string;
|
|
2409
|
+
object: "routine_run";
|
|
2410
|
+
routine_id: string;
|
|
2411
|
+
version_id: string;
|
|
2412
|
+
version_number: number;
|
|
2413
|
+
durability: "ephemeral" | "standard" | "strict";
|
|
2414
|
+
trigger: RunTrigger;
|
|
2415
|
+
input: Record<string, unknown>;
|
|
2416
|
+
/** Top-level steps in definition order. */
|
|
2417
|
+
steps: StepRun[];
|
|
2418
|
+
};
|
|
2419
|
+
export type RoutineRunList = Omit<ListEnvelope, "data"> & {
|
|
2420
|
+
data: RoutineRun[];
|
|
2421
|
+
};
|
|
2422
|
+
/** `step.*` events carry `step` (a `StepRun`); `run.log` carries `step_id`, `level` and `message`. */
|
|
2423
|
+
export type RunEvent = JobEvent & {
|
|
2424
|
+
step?: StepRun;
|
|
2425
|
+
step_id?: string;
|
|
2426
|
+
level?: "debug" | "info" | "warn" | "error";
|
|
2427
|
+
message?: string;
|
|
2428
|
+
};
|
|
2429
|
+
export interface SignalRequest {
|
|
2430
|
+
/** The `wait.signal` name the run waits for (routine.schema.json). */
|
|
2431
|
+
name: string;
|
|
2432
|
+
/** Becomes the waiting step's outputs. */
|
|
2433
|
+
payload?: unknown;
|
|
2434
|
+
}
|
|
2435
|
+
/**
|
|
2436
|
+
* One manifest per pack: connections, egress, actions (T0 declarative HTTP or T1 first-party JS), triggers (webhook, poll, schedule), fixtures, pricing and the publisher signature. Field names follow research/b3os-actions.md section 12.3 (camelCase, like MCP). Every string that contains ${{ }} is a CEL template; the template rules and CEL contexts are in packages/spec/schemas/README.md. Rules JSON Schema cannot express (unique action keys, egress subset, connection references, effect consistency) are listed in the README under 'b3pack publish checks' and are enforced by the actions registry and by examples/validate.mjs. Owner after freeze: actions.
|
|
2437
|
+
*/
|
|
2438
|
+
export interface B3Pack {
|
|
2439
|
+
/** Optional pointer to this schema for editors. Ignored by the runtime. */
|
|
2440
|
+
$schema?: string;
|
|
2441
|
+
pack: B3PackPackId;
|
|
2442
|
+
version: B3PackSemver;
|
|
2443
|
+
title: string;
|
|
2444
|
+
description: string;
|
|
2445
|
+
/**
|
|
2446
|
+
* Who publishes the pack. id must equal the namespace part of pack (registry check). Verification status lives in the registry record, never in the manifest, so a manifest cannot claim to be verified.
|
|
2447
|
+
*/
|
|
2448
|
+
publisher: {
|
|
2449
|
+
id: B3PackNamespace;
|
|
2450
|
+
name: string;
|
|
2451
|
+
url?: string;
|
|
2452
|
+
email?: string;
|
|
2453
|
+
};
|
|
2454
|
+
/** SPDX license expression, e.g. MIT, Apache-2.0, or LicenseRef-<name>. */
|
|
2455
|
+
license: string;
|
|
2456
|
+
/** Discovery facets (research 12.12). Free kebab-case values; the registry curates the displayed set. */
|
|
2457
|
+
facets?: {
|
|
2458
|
+
domain?: B3PackFacetList;
|
|
2459
|
+
assetClass?: B3PackFacetList;
|
|
2460
|
+
chains?: B3PackFacetList;
|
|
2461
|
+
};
|
|
2462
|
+
/** MCP-style icons. src is a bundle-relative path under assets/ or an https URL. */
|
|
2463
|
+
icons?: {
|
|
2464
|
+
src: string;
|
|
2465
|
+
mimeType?: "image/svg+xml" | "image/png" | "image/webp";
|
|
2466
|
+
sizes?: string[];
|
|
2467
|
+
}[];
|
|
2468
|
+
/**
|
|
2469
|
+
* Pack runtime API the pack needs, as a caret range (npm and Cargo read it the same way). The v1 runtime is 1.0.0, so packs declare ^1 or ^1.0.
|
|
2470
|
+
*/
|
|
2471
|
+
engine: string;
|
|
2472
|
+
/**
|
|
2473
|
+
* Credentials and configuration the pack's actions and triggers can use, keyed by a connection key that templates reference as connections.<key>. A customer binds each key to a vault connection (conn_). Secrets are injected at the egress layer and never reach templates, fixtures or T1 code.
|
|
2474
|
+
*/
|
|
2475
|
+
connections?: Record<string, B3PackConnection>;
|
|
2476
|
+
/**
|
|
2477
|
+
* Pack-wide egress ceiling: every outbound request from any action or trigger must match one entry. Actions may narrow it with their own egress list. Enforced by the b3os-core egress guard (ARCHITECTURE 4.4); a host diff between versions counts as a major change.
|
|
2478
|
+
*/
|
|
2479
|
+
egress?: B3PackEgressEntry[];
|
|
2480
|
+
actions: B3PackAction[];
|
|
2481
|
+
triggers?: B3PackTrigger[];
|
|
2482
|
+
/**
|
|
2483
|
+
* Default price for every action that does not set its own. v0.1 packs are free; the node still meters actions.call (ARCHITECTURE 4.5).
|
|
2484
|
+
*/
|
|
2485
|
+
pricing?: B3PackPricing;
|
|
2486
|
+
compat?: {
|
|
2487
|
+
/**
|
|
2488
|
+
* Maps an action key in this pack to the flat action id it replaces in the old B3OS catalog (research 12.3, 13). Used by the importer so old workflows resolve.
|
|
2489
|
+
*/
|
|
2490
|
+
legacyIds?: Record<string, string>;
|
|
2491
|
+
};
|
|
2492
|
+
signature?: B3PackSignature;
|
|
2493
|
+
}
|
|
2494
|
+
/**
|
|
2495
|
+
* Reverse-DNS publisher namespace with at least one dot, lowercase: io.b3os, com.example, io.github.acme.
|
|
2496
|
+
*/
|
|
2497
|
+
export type B3PackNamespace = string;
|
|
2498
|
+
/**
|
|
2499
|
+
* Pack id <namespace>/<name>, e.g. io.b3os/github. Action refs are <namespace>/<name>/<action>@<semver>.
|
|
2500
|
+
*/
|
|
2501
|
+
export type B3PackPackId = string;
|
|
2502
|
+
/**
|
|
2503
|
+
* Semantic version 2.0.0 without build metadata (two versions that differ only in build metadata would be the same release).
|
|
2504
|
+
*/
|
|
2505
|
+
export type B3PackSemver = string;
|
|
2506
|
+
/** Action or trigger key, kebab-case, unique within the pack. */
|
|
2507
|
+
export type B3PackKebabKey = string;
|
|
2508
|
+
/** Connection key, a CEL identifier so templates can write connections.<key>. */
|
|
2509
|
+
export type B3PackConnectionKey = string;
|
|
2510
|
+
export type B3PackFacetList = string[];
|
|
2511
|
+
/**
|
|
2512
|
+
* Lowercase host. Exact (api.github.com), wildcard (*.slack.com matches any name below slack.com but not slack.com itself), or * for any public host. * is first-party only and never receives injected credentials. IP literals are not allowed; the egress guard resolves names and denies private ranges either way.
|
|
2513
|
+
*/
|
|
2514
|
+
export type B3PackHostPattern = string;
|
|
2515
|
+
export interface B3PackEgressEntry {
|
|
2516
|
+
host: B3PackHostPattern;
|
|
2517
|
+
/**
|
|
2518
|
+
* Allowed destination ports. Default [443].
|
|
2519
|
+
* @default [443]
|
|
2520
|
+
*/
|
|
2521
|
+
ports?: number[];
|
|
2522
|
+
/**
|
|
2523
|
+
* Allowed URL schemes. Default ["https"]; plain http must be listed explicitly.
|
|
2524
|
+
* @default ["https"]
|
|
2525
|
+
*/
|
|
2526
|
+
schemes?: Array<"https" | "http">;
|
|
2527
|
+
}
|
|
2528
|
+
/**
|
|
2529
|
+
* A JSON Schema 2020-12 document whose top level describes an object (MCP requires object-typed inputSchema and outputSchema). Objects should be closed (additionalProperties false) unless declared open (research 12.4). x-b3-* keywords (x-b3-widget, x-b3-semantic, x-b3-options, ...) are allowed as annotations and ignored by validation.
|
|
2530
|
+
*/
|
|
2531
|
+
export type B3PackJsonSchemaObject = JsonSchemaDocument & {
|
|
2532
|
+
type: "object";
|
|
2533
|
+
};
|
|
2534
|
+
/**
|
|
2535
|
+
* Exactly one CEL expression wrapped as the whole string: ${{ <cel> }}. The result keeps its CEL type (bool, int, double, string, list, map, null).
|
|
2536
|
+
*/
|
|
2537
|
+
export type B3PackCelExpression = string;
|
|
2538
|
+
/**
|
|
2539
|
+
* A string that may contain ${{ <cel> }} expressions. A string that is exactly one expression keeps the expression's type; otherwise each expression is converted to text and spliced in (README, 'Templates').
|
|
2540
|
+
*/
|
|
2541
|
+
export type B3PackTemplateString = string;
|
|
2542
|
+
/** Any JSON value. Strings inside it (at any depth) are template strings; object keys are literal. */
|
|
2543
|
+
export type B3PackTemplateValue = unknown;
|
|
2544
|
+
/**
|
|
2545
|
+
* A connection definition. Secret fields the vault stores per type (the public names of vault.yaml ConnectionSecret), and how the egress proxy injects them (b3os-core egress::Injection): api_key {api_key}, injected as inject says (Header {name, prefix} or Query {name}); basic {username, password}, injected as Authorization: Basic base64(username:password); bearer {token}, injected as Authorization: Bearer <token>; oauth2 {access_token, refresh_token?, expires_at?, client_id?, client_secret?}, injected as Authorization: Bearer <access_token> (the refresh fields are never injected); none {} (configuration only). Each entry of hosts becomes one credential binding: credentials are injected only into requests to that host, after the egress guard validated and pinned the destination (ARCHITECTURE 4.4).
|
|
2546
|
+
*/
|
|
2547
|
+
export type B3PackConnection = {
|
|
2548
|
+
type: "api_key" | "basic" | "bearer" | "oauth2" | "none";
|
|
2549
|
+
label: string;
|
|
2550
|
+
description?: string;
|
|
2551
|
+
docsUrl?: string;
|
|
2552
|
+
/**
|
|
2553
|
+
* Hosts that receive the injected credential. Each entry must also be covered by the pack egress list. * is not allowed.
|
|
2554
|
+
*/
|
|
2555
|
+
hosts?: B3PackHostPattern[];
|
|
2556
|
+
/**
|
|
2557
|
+
* Non-secret configuration collected when the customer creates the connection (for example a Jira site name). Templates read it as connections.<key>.params.<field>.
|
|
2558
|
+
*/
|
|
2559
|
+
params?: B3PackJsonSchemaObject;
|
|
2560
|
+
inject?: B3PackInject;
|
|
2561
|
+
authorizationUrl?: string;
|
|
2562
|
+
tokenUrl?: string;
|
|
2563
|
+
scopes?: string[];
|
|
2564
|
+
pkce?: boolean;
|
|
2565
|
+
};
|
|
2566
|
+
/**
|
|
2567
|
+
* api_key only: where the connection's api_key field goes. in header: '<name>: <prefix><api_key>'; in query: '?<name>=<api_key>' (no prefix). bearer, oauth2 and basic always use the Authorization header and take no inject block. Request templates may not set the injected header or query parameter.
|
|
2568
|
+
*/
|
|
2569
|
+
export interface B3PackInject {
|
|
2570
|
+
/** @default "header" */
|
|
2571
|
+
in?: "header" | "query";
|
|
2572
|
+
/** Header name (case-insensitive) or query parameter name. */
|
|
2573
|
+
name?: string;
|
|
2574
|
+
/** Header injection only: literal text placed before the secret, e.g. 'Bearer ' or 'token '. */
|
|
2575
|
+
prefix?: string;
|
|
2576
|
+
}
|
|
2577
|
+
/**
|
|
2578
|
+
* The single source for MCP annotations, approval UI, retries and routine durability (research 12.3). readOnlyHint = class in {pure, read}; destructiveHint = class == irreversible; openWorldHint = effective egress is non-empty. The runtime retries only pure and read calls and never auto-retries irreversible ones.
|
|
2579
|
+
*/
|
|
2580
|
+
export interface B3PackEffects {
|
|
2581
|
+
class: "pure" | "read" | "write" | "irreversible";
|
|
2582
|
+
}
|
|
2583
|
+
/**
|
|
2584
|
+
* Publisher price on top of the platform's actions.call meter. v0.1 first-party packs are free. Amounts are decimal strings in USD to avoid float rounding.
|
|
2585
|
+
*/
|
|
2586
|
+
export interface B3PackPricing {
|
|
2587
|
+
model: "free" | "per_call";
|
|
2588
|
+
usd?: string;
|
|
2589
|
+
}
|
|
2590
|
+
export type B3PackHeaderName = string;
|
|
2591
|
+
/**
|
|
2592
|
+
* T0 request template. CEL context: input (validated input with schema defaults applied) and connections.<key>.params. In url, every expression that is not the whole string is percent-encoded with the RFC 3986 unreserved set (like encodeURIComponent); a whole-string url expression must yield an absolute URL and is used as is. The final URL must match the effective egress list; a templated host label may only produce [a-z0-9-] and must match a wildcard egress entry.
|
|
2593
|
+
*/
|
|
2594
|
+
export type B3PackHttpRequest = {
|
|
2595
|
+
method: "GET" | "HEAD" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
2596
|
+
url: B3PackTemplateString;
|
|
2597
|
+
/**
|
|
2598
|
+
* Query parameters appended to url, form-encoded. Value results: string, int, double and bool are stringified; null omits the parameter; a list repeats the parameter once per element; a map is an error.
|
|
2599
|
+
*/
|
|
2600
|
+
query?: Record<string, B3PackTemplateValue>;
|
|
2601
|
+
/**
|
|
2602
|
+
* Request headers. A null result omits the header; a value containing CR or LF fails the call. Not allowed: Host, Content-Length, Transfer-Encoding, Connection, Upgrade, TE, Trailer, Proxy-*, and any header a required connection injects.
|
|
2603
|
+
*/
|
|
2604
|
+
headers?: Record<string, B3PackTemplateString>;
|
|
2605
|
+
/** Request body template. Not allowed with GET or HEAD. */
|
|
2606
|
+
body?: B3PackTemplateValue;
|
|
2607
|
+
/**
|
|
2608
|
+
* json (default): the evaluated body is serialized as JSON with Content-Type application/json. form: the body must evaluate to a flat map; it is sent as application/x-www-form-urlencoded with the query rules above. text: the body must evaluate to a string; Content-Type defaults to text/plain;charset=utf-8.
|
|
2609
|
+
* @default "json"
|
|
2610
|
+
*/
|
|
2611
|
+
bodyEncoding?: "json" | "form" | "text";
|
|
2612
|
+
};
|
|
2613
|
+
/**
|
|
2614
|
+
* Response handling. CEL context: input, connections, response {status: int, headers: map of lowercase name to string (repeated headers joined with ', '), body: parsed JSON or string}.
|
|
2615
|
+
*/
|
|
2616
|
+
export interface B3PackHttpResponse {
|
|
2617
|
+
/**
|
|
2618
|
+
* How to read the body. auto (default): JSON when Content-Type is application/json or ends in +json, otherwise text. json fails the call if the body is not JSON. text keeps a string.
|
|
2619
|
+
* @default "auto"
|
|
2620
|
+
*/
|
|
2621
|
+
body?: "auto" | "json" | "text";
|
|
2622
|
+
/** Whether the call succeeded. Default ${{ response.status >= 200 && response.status < 300 }}. */
|
|
2623
|
+
success?: B3PackCelExpression;
|
|
2624
|
+
/**
|
|
2625
|
+
* Output template, evaluated on success. The result must validate against outputSchema. Default ${{ response.body }}.
|
|
2626
|
+
*/
|
|
2627
|
+
map?: B3PackTemplateValue;
|
|
2628
|
+
/**
|
|
2629
|
+
* Evaluated in order when success is false; the first match decides the error. No match: code upstream_error, retryable when status is 429 or 5xx.
|
|
2630
|
+
*/
|
|
2631
|
+
errors?: {
|
|
2632
|
+
if: B3PackCelExpression;
|
|
2633
|
+
code: string;
|
|
2634
|
+
message?: B3PackTemplateString;
|
|
2635
|
+
/** @default false */
|
|
2636
|
+
retryable?: boolean;
|
|
2637
|
+
}[];
|
|
2638
|
+
}
|
|
2639
|
+
/**
|
|
2640
|
+
* How the action runs. http = T0, declarative HTTP inside b3osd. js = T1, a first-party ES module run by the actions-js sidecar (packages/spec/sidecars/actions-js.md).
|
|
2641
|
+
*/
|
|
2642
|
+
export type B3PackImpl = {
|
|
2643
|
+
kind: "http";
|
|
2644
|
+
request: B3PackHttpRequest;
|
|
2645
|
+
response?: B3PackHttpResponse;
|
|
2646
|
+
} | {
|
|
2647
|
+
kind: "js";
|
|
2648
|
+
/**
|
|
2649
|
+
* Bundle-relative path of a self-contained ES module (bundled; no bare imports except node: built-ins the sidecar allows).
|
|
2650
|
+
*/
|
|
2651
|
+
entry: string;
|
|
2652
|
+
/**
|
|
2653
|
+
* Exported async function to call. Default run.
|
|
2654
|
+
* @default "run"
|
|
2655
|
+
*/
|
|
2656
|
+
export?: string;
|
|
2657
|
+
};
|
|
2658
|
+
export type B3PackExample = {
|
|
2659
|
+
fixture: B3PackFixturePath;
|
|
2660
|
+
} | {
|
|
2661
|
+
title?: string;
|
|
2662
|
+
input: Record<string, unknown>;
|
|
2663
|
+
output?: unknown;
|
|
2664
|
+
};
|
|
2665
|
+
/** Bundle-relative path of a fixture file (see $defs/fixture). */
|
|
2666
|
+
export type B3PackFixturePath = string;
|
|
2667
|
+
/**
|
|
2668
|
+
* One action; every action is an MCP tool. The MCP tool name defaults to <pack name>__<action key> (for example github__create-issue), mapped into [A-Za-z0-9_-]{1,64}; the registry adds a hash suffix on collision and stores the result in the index.
|
|
2669
|
+
*/
|
|
2670
|
+
export type B3PackAction = {
|
|
2671
|
+
key: B3PackKebabKey;
|
|
2672
|
+
title: string;
|
|
2673
|
+
description: string;
|
|
2674
|
+
inputSchema: B3PackJsonSchemaObject;
|
|
2675
|
+
outputSchema: B3PackJsonSchemaObject;
|
|
2676
|
+
effects: B3PackEffects;
|
|
2677
|
+
impl: B3PackImpl;
|
|
2678
|
+
requires?: {
|
|
2679
|
+
/**
|
|
2680
|
+
* Connection keys this action uses. Each must be declared in connections. For T0, every listed connection injects its credential into requests whose host matches its hosts.
|
|
2681
|
+
*/
|
|
2682
|
+
connections?: B3PackConnectionKey[];
|
|
2683
|
+
};
|
|
2684
|
+
/**
|
|
2685
|
+
* Narrows the pack egress list for this action; each entry must be covered by a pack entry. Default: the pack list. An action with an empty effective list may not make network calls (only pure T1 transforms).
|
|
2686
|
+
*/
|
|
2687
|
+
egress?: B3PackEgressEntry[];
|
|
2688
|
+
execution?: {
|
|
2689
|
+
/**
|
|
2690
|
+
* Wall-clock budget per call, including upstream time. Default 10000 for http, 30000 for js. A caller's shorter deadline wins.
|
|
2691
|
+
*/
|
|
2692
|
+
timeoutMs?: number;
|
|
2693
|
+
/** T1 only: V8 old-generation limit of the worker running the call. Default 128. */
|
|
2694
|
+
memoryMb?: number;
|
|
2695
|
+
/**
|
|
2696
|
+
* T0 write or irreversible only: header that carries the caller's idempotency key upstream (for example Idempotency-Key for Stripe). Absent means the upstream has no idempotency support.
|
|
2697
|
+
*/
|
|
2698
|
+
idempotencyHeader?: B3PackHeaderName;
|
|
2699
|
+
};
|
|
2700
|
+
/**
|
|
2701
|
+
* MCP hints that effects cannot derive. readOnlyHint, destructiveHint and openWorldHint are always derived and may not be set here.
|
|
2702
|
+
*/
|
|
2703
|
+
annotations?: {
|
|
2704
|
+
idempotentHint?: boolean;
|
|
2705
|
+
};
|
|
2706
|
+
examples?: B3PackExample[];
|
|
2707
|
+
pricing?: B3PackPricing;
|
|
2708
|
+
mcp?: {
|
|
2709
|
+
/** MCP tool name override; must be unique in the pack. */
|
|
2710
|
+
name?: string;
|
|
2711
|
+
/**
|
|
2712
|
+
* false keeps the action out of tools/list (still callable through actions_call). Default true.
|
|
2713
|
+
* @default true
|
|
2714
|
+
*/
|
|
2715
|
+
expose?: boolean;
|
|
2716
|
+
};
|
|
2717
|
+
};
|
|
2718
|
+
/**
|
|
2719
|
+
* Six-field cron with seconds: second minute hour day-of-month month day-of-week, single spaces. Fields accept numbers, names (JAN, MON), *, ranges a-b, lists a,b, steps *\/n and ?; L, W and # are accepted in the day fields.
|
|
2720
|
+
*/
|
|
2721
|
+
export type B3PackCron = string;
|
|
2722
|
+
/** IANA time zone name, e.g. America/Los_Angeles. Default UTC. */
|
|
2723
|
+
export type B3PackTimezone = string;
|
|
2724
|
+
/**
|
|
2725
|
+
* Mandatory delivery verification (ARCHITECTURE 4.3). Signatures are compared in constant time over the raw request body bytes. Schemes: github: X-Hub-Signature-256 'sha256=<hex HMAC-SHA256(secret, body)>'. stripe: Stripe-Signature 't=<unix>,v1=<hex>' over '<t>.<body>' (any v1 may match). slack: X-Slack-Signature 'v0=<hex>' over 'v0:<X-Slack-Request-Timestamp>:<body>'. standard_webhooks: webhook-signature 'v1,<base64>' entries over '<webhook-id>.<webhook-timestamp>.<body>', secret is base64 after the whsec_ prefix. hmac_sha256: generic, and always timestamped: the header value is prefix plus the HMAC-SHA256 (hex or base64, per encoding) of '<value of timestampHeader>.<body>', and a delivery whose timestamp header is missing or not a Unix time is refused. Timestamped schemes (stripe, slack, standard_webhooks, hmac_sha256) reject deliveries more than toleranceS (at most 300 s, the same rule as routine webhooks) from the node clock. The node also remembers the verified signature of each accepted delivery with its dedupe key (73 h, up to 10,000 per subscription), so a delivery replayed with a different unsigned header (for example X-GitHub-Delivery, which github's dedupe key reads) is still a duplicate; github signs no timestamp, so outside that window such a replay is not refused.
|
|
2726
|
+
*/
|
|
2727
|
+
export type B3PackVerify = {
|
|
2728
|
+
scheme: "github" | "stripe" | "slack" | "standard_webhooks" | "hmac_sha256";
|
|
2729
|
+
secret: {
|
|
2730
|
+
/**
|
|
2731
|
+
* generated: B3OS creates a random 32-byte secret per subscription and exposes it once to the subscribe call as subscription.secret. subscribe_result: the provider returns the secret; subscribe.secret extracts it. user: the customer supplies it when creating the subscription, as an api_key vault connection (verification-only: no pack, no hosts) bound under the routine trigger's connections.webhook_secret. The secret is stored in the vault, never in subscription state.
|
|
2732
|
+
*/
|
|
2733
|
+
from: "generated" | "subscribe_result" | "user";
|
|
2734
|
+
};
|
|
2735
|
+
/** hmac_sha256 only: signature header. */
|
|
2736
|
+
header?: B3PackHeaderName;
|
|
2737
|
+
/** hmac_sha256 only. Default hex. */
|
|
2738
|
+
encoding?: "hex" | "base64";
|
|
2739
|
+
/** hmac_sha256 only: literal prefix before the signature, e.g. sha256=. */
|
|
2740
|
+
prefix?: string;
|
|
2741
|
+
/**
|
|
2742
|
+
* hmac_sha256 only, and required there: header carrying the delivery's Unix timestamp; the signed payload is '<timestamp>.<body>'.
|
|
2743
|
+
*/
|
|
2744
|
+
timestampHeader?: B3PackHeaderName;
|
|
2745
|
+
/**
|
|
2746
|
+
* Timestamped schemes: the largest allowed distance in seconds between the delivery's timestamp and the node clock.
|
|
2747
|
+
* @default 300
|
|
2748
|
+
*/
|
|
2749
|
+
toleranceS?: number;
|
|
2750
|
+
};
|
|
2751
|
+
/**
|
|
2752
|
+
* Poll interval. default applies when the subscription does not choose; min is the floor a subscription may request. Plans may raise the floor (GET /v1/limits).
|
|
2753
|
+
*/
|
|
2754
|
+
export interface B3PackIntervalMs {
|
|
2755
|
+
default: number;
|
|
2756
|
+
min: number;
|
|
2757
|
+
}
|
|
2758
|
+
/**
|
|
2759
|
+
* A trigger turns provider events into B3OS events: CloudEvents-shaped {id, source, type, time, data, dedupeKey, subscription} with data validated against eventSchema. Delivery is at least once; consumers dedupe on (subscription, dedupeKey).
|
|
2760
|
+
*/
|
|
2761
|
+
export type B3PackTrigger = {
|
|
2762
|
+
key: B3PackKebabKey;
|
|
2763
|
+
title: string;
|
|
2764
|
+
description: string;
|
|
2765
|
+
kind: "webhook" | "poll" | "schedule";
|
|
2766
|
+
/** Per-subscription configuration, available to CEL as config. Default: an empty closed object. */
|
|
2767
|
+
configSchema?: B3PackJsonSchemaObject;
|
|
2768
|
+
eventSchema: B3PackJsonSchemaObject;
|
|
2769
|
+
requires?: {
|
|
2770
|
+
connections?: B3PackConnectionKey[];
|
|
2771
|
+
};
|
|
2772
|
+
examples?: {
|
|
2773
|
+
fixture: B3PackFixturePath;
|
|
2774
|
+
}[];
|
|
2775
|
+
verify?: B3PackVerify;
|
|
2776
|
+
/**
|
|
2777
|
+
* webhook: action called when a subscription is created (REST hooks). CEL context for with: config, subscription {id, url, secret (only when verify.secret.from is generated)}. state and secret are evaluated with result (the action output), config and subscription.
|
|
2778
|
+
*/
|
|
2779
|
+
subscribe?: {
|
|
2780
|
+
action: B3PackKebabKey;
|
|
2781
|
+
with: B3PackTemplateValue;
|
|
2782
|
+
/**
|
|
2783
|
+
* Non-secret state kept with the subscription (for example the provider's hook id), later available as subscription.state.
|
|
2784
|
+
*/
|
|
2785
|
+
state?: B3PackTemplateValue;
|
|
2786
|
+
/**
|
|
2787
|
+
* Required when verify.secret.from is subscribe_result: extracts the signing secret from result. Stored in the vault.
|
|
2788
|
+
*/
|
|
2789
|
+
secret?: B3PackCelExpression;
|
|
2790
|
+
};
|
|
2791
|
+
/**
|
|
2792
|
+
* webhook: action called when the subscription is deleted. CEL context for with: config, subscription {id, url, state}.
|
|
2793
|
+
*/
|
|
2794
|
+
unsubscribe?: {
|
|
2795
|
+
action: B3PackKebabKey;
|
|
2796
|
+
with: B3PackTemplateValue;
|
|
2797
|
+
};
|
|
2798
|
+
/**
|
|
2799
|
+
* webhook: answers a provider verification request (for example Slack url_verification) without emitting an event. Evaluated after signature verification. CEL context: request, config.
|
|
2800
|
+
*/
|
|
2801
|
+
handshake?: {
|
|
2802
|
+
if: B3PackCelExpression;
|
|
2803
|
+
response: {
|
|
2804
|
+
status: number;
|
|
2805
|
+
contentType?: "application/json" | "text/plain";
|
|
2806
|
+
body?: B3PackTemplateValue;
|
|
2807
|
+
};
|
|
2808
|
+
};
|
|
2809
|
+
/**
|
|
2810
|
+
* webhook: string that identifies the provider event (provider event id or delivery id). CEL context: request {method, headers (lowercase map), query, body (parsed JSON or string), received_at}, config, subscription.
|
|
2811
|
+
*/
|
|
2812
|
+
dedupeKey?: B3PackCelExpression;
|
|
2813
|
+
/**
|
|
2814
|
+
* webhook: bool; false acknowledges the delivery with 2xx and emits nothing. Same context as dedupeKey.
|
|
2815
|
+
*/
|
|
2816
|
+
filter?: B3PackCelExpression;
|
|
2817
|
+
/**
|
|
2818
|
+
* Event data template. webhook default ${{ request.body }} (context as dedupeKey); poll default ${{ item }} (context: item, config); schedule default ${{ result }} when action is set, else ${{ {'scheduled_at': scheduled_at} }} (context: result, config, scheduled_at).
|
|
2819
|
+
*/
|
|
2820
|
+
event?: B3PackTemplateValue;
|
|
2821
|
+
/**
|
|
2822
|
+
* poll: runs a read action of this pack on an interval and emits new items. CEL context for with: config, cursor (null on the first poll), subscription. items and cursor see result, cursor, config. The first poll records a baseline and emits nothing unless initial is emit.
|
|
2823
|
+
*/
|
|
2824
|
+
poll?: {
|
|
2825
|
+
action: B3PackKebabKey;
|
|
2826
|
+
with?: B3PackTemplateValue;
|
|
2827
|
+
/** List of raw items in result. */
|
|
2828
|
+
items: B3PackCelExpression;
|
|
2829
|
+
/** Next cursor; null keeps the previous one. */
|
|
2830
|
+
cursor?: B3PackCelExpression;
|
|
2831
|
+
intervalMs: B3PackIntervalMs;
|
|
2832
|
+
/** @default "baseline" */
|
|
2833
|
+
initial?: "baseline" | "emit";
|
|
2834
|
+
};
|
|
2835
|
+
/**
|
|
2836
|
+
* poll: which items are new. unique: emit items whose key was not among the last window keys seen. greatest: emit items whose key is greater than the largest key seen (keys are ints or RFC 3339 strings).
|
|
2837
|
+
*/
|
|
2838
|
+
dedupe?: {
|
|
2839
|
+
strategy: "unique" | "greatest";
|
|
2840
|
+
/** Per-item key. CEL context: item, config. */
|
|
2841
|
+
key: B3PackCelExpression;
|
|
2842
|
+
/** @default 1000 */
|
|
2843
|
+
window?: number;
|
|
2844
|
+
};
|
|
2845
|
+
/**
|
|
2846
|
+
* schedule: emits one event per occurrence, optionally carrying the result of a read action. Occurrences missed while the node was down follow catchUp (skip: none, latest: the newest one, all: every one within 24 h).
|
|
2847
|
+
*/
|
|
2848
|
+
schedule?: {
|
|
2849
|
+
cron?: B3PackCron;
|
|
2850
|
+
tz?: B3PackTimezone;
|
|
2851
|
+
everyMs?: number;
|
|
2852
|
+
catchUp: "skip" | "latest" | "all";
|
|
2853
|
+
action?: B3PackKebabKey;
|
|
2854
|
+
with?: B3PackTemplateValue;
|
|
2855
|
+
};
|
|
2856
|
+
};
|
|
2857
|
+
/**
|
|
2858
|
+
* Publisher signature written by the publish tool and repeated in the registry record. contentHash covers the whole bundle with this member removed (README, 'Pack content hash and signature'). sig is Ed25519 over the UTF-8 bytes of 'b3pack-sig-v1\n<pack>\n<version>\n<contentHash>'. Nodes verify contentHash and sig against the registry record and the publisher's registered key before loading (ARCHITECTURE 5.5).
|
|
2859
|
+
*/
|
|
2860
|
+
export interface B3PackSignature {
|
|
2861
|
+
alg: "ed25519";
|
|
2862
|
+
/** Publisher key id as registered: <namespace>#<label>. */
|
|
2863
|
+
kid: string;
|
|
2864
|
+
contentHash: string;
|
|
2865
|
+
/** base64url without padding of the 64-byte signature. */
|
|
2866
|
+
sig: string;
|
|
2867
|
+
}
|
|
2868
|
+
/**
|
|
2869
|
+
* `pure` computes from input only; `read` reads from the world; `write` changes it; `irreversible` changes it
|
|
2870
|
+
* and cannot be undone (never retried automatically). Drives MCP annotations and retries.
|
|
2871
|
+
*/
|
|
2872
|
+
export type EffectClass = "pure" | "read" | "write" | "irreversible";
|
|
2873
|
+
/**
|
|
2874
|
+
* `<namespace>/<name>/<action>@<version>`, the version exact (strict semver without build metadata, as in
|
|
2875
|
+
* b3pack's `semver` and the routine callable) or a major.
|
|
2876
|
+
*/
|
|
2877
|
+
export type ActionRef = string;
|
|
2878
|
+
/**
|
|
2879
|
+
* `<namespace>/<name>/<trigger>@<version>` with the exact version (a routine's `@<major>` is resolved and pinned at publish).
|
|
2880
|
+
*/
|
|
2881
|
+
export type TriggerRef = string;
|
|
2882
|
+
/**
|
|
2883
|
+
* One `type: action` trigger of a published routine, subscribed to a pack trigger. B3OS creates and updates it
|
|
2884
|
+
* when the routine version is published and removes it on rollback to a version without the trigger, on a
|
|
2885
|
+
* version that drops it, and on delete. Events it receives start runs of the routine with the event in the
|
|
2886
|
+
* run's `trigger` context.
|
|
2887
|
+
*/
|
|
2888
|
+
export interface TriggerSubscription {
|
|
2889
|
+
id: string;
|
|
2890
|
+
object: "trigger_subscription";
|
|
2891
|
+
/**
|
|
2892
|
+
* `active` receives events. `paused` while the routine's triggers are paused (its publishing key was revoked
|
|
2893
|
+
* or expired). `failed` when subscribing at the provider failed; `error` says why and B3OS retries.
|
|
2894
|
+
*/
|
|
2895
|
+
status: "active" | "paused" | "failed";
|
|
2896
|
+
routine_id: string;
|
|
2897
|
+
/** The routine version whose definition created or last updated the subscription. */
|
|
2898
|
+
version_id: string;
|
|
2899
|
+
/** The trigger's `id` in the routine definition. */
|
|
2900
|
+
trigger_id: string;
|
|
2901
|
+
trigger: TriggerRef;
|
|
2902
|
+
/** `<namespace>/<name>`. */
|
|
2903
|
+
pack: string;
|
|
2904
|
+
kind: "webhook" | "poll" | "schedule";
|
|
2905
|
+
/** The trigger's configuration (the routine trigger's `with`, evaluated at publish); never secret. */
|
|
2906
|
+
config: Record<string, unknown>;
|
|
2907
|
+
/** Pack connection key to the vault connection bound at publish. */
|
|
2908
|
+
connections: Record<string, string>;
|
|
2909
|
+
/**
|
|
2910
|
+
* Webhook triggers, the inbound hook registered with the provider (`POST /v1/actions/hooks/{hook_id}`); otherwise `null`.
|
|
2911
|
+
*/
|
|
2912
|
+
hook_id: string | null;
|
|
2913
|
+
last_event_at: string | null;
|
|
2914
|
+
/** Why subscribing failed (`status: failed`), or `null`. */
|
|
2915
|
+
error: null | Problem;
|
|
2916
|
+
created_at: string;
|
|
2917
|
+
updated_at: string;
|
|
2918
|
+
}
|
|
2919
|
+
export type TriggerSubscriptionList = Omit<ListEnvelope, "data"> & {
|
|
2920
|
+
data: TriggerSubscription[];
|
|
2921
|
+
};
|
|
2922
|
+
export interface ActionSummary {
|
|
2923
|
+
/** Exact reference with the resolved version. */
|
|
2924
|
+
ref: string;
|
|
2925
|
+
pack: string;
|
|
2926
|
+
key: string;
|
|
2927
|
+
title: string;
|
|
2928
|
+
description: string;
|
|
2929
|
+
effects: EffectClass;
|
|
2930
|
+
/** Connection keys the action needs. */
|
|
2931
|
+
connections: string[];
|
|
2932
|
+
/** The action's MCP tool name. */
|
|
2933
|
+
mcp_name: string;
|
|
2934
|
+
/** Search relevance from 0 to 1 (search results only). */
|
|
2935
|
+
score?: number;
|
|
2936
|
+
}
|
|
2937
|
+
export type ActionSearchResult = Omit<ListEnvelope, "data"> & {
|
|
2938
|
+
data: ActionSummary[];
|
|
2939
|
+
};
|
|
2940
|
+
export interface ConnectionRequirement {
|
|
2941
|
+
/** The connection key in the pack. */
|
|
2942
|
+
key: string;
|
|
2943
|
+
type: "api_key" | "basic" | "bearer" | "oauth2" | "none";
|
|
2944
|
+
label: string;
|
|
2945
|
+
/** Whether this action needs it. */
|
|
2946
|
+
required?: boolean;
|
|
2947
|
+
}
|
|
2948
|
+
export interface ActionDescription {
|
|
2949
|
+
object: "action";
|
|
2950
|
+
ref: string;
|
|
2951
|
+
pack: string;
|
|
2952
|
+
version: string;
|
|
2953
|
+
key: string;
|
|
2954
|
+
title: string;
|
|
2955
|
+
description: string;
|
|
2956
|
+
input_schema: JsonSchemaDocument;
|
|
2957
|
+
output_schema: JsonSchemaDocument;
|
|
2958
|
+
effects: EffectClass;
|
|
2959
|
+
/** MCP tool annotations derived from the effect class. */
|
|
2960
|
+
annotations: {
|
|
2961
|
+
readOnlyHint?: boolean;
|
|
2962
|
+
destructiveHint?: boolean;
|
|
2963
|
+
idempotentHint?: boolean;
|
|
2964
|
+
openWorldHint?: boolean;
|
|
2965
|
+
};
|
|
2966
|
+
connections: ConnectionRequirement[];
|
|
2967
|
+
/** The action as an MCP tool definition. */
|
|
2968
|
+
mcp: {
|
|
2969
|
+
name: string;
|
|
2970
|
+
title?: string;
|
|
2971
|
+
description: string;
|
|
2972
|
+
inputSchema: JsonSchemaDocument;
|
|
2973
|
+
outputSchema?: JsonSchemaDocument;
|
|
2974
|
+
};
|
|
2975
|
+
}
|
|
2976
|
+
export interface ActionCallRequest {
|
|
2977
|
+
ref: ActionRef;
|
|
2978
|
+
/** Validated against the action's input schema. */
|
|
2979
|
+
input?: Record<string, unknown>;
|
|
2980
|
+
/**
|
|
2981
|
+
* Pack connection key to vault connection ID. Omit a key to use your project's most recently created connection for it (refused with `422 connection_required` when that connection belongs to an end user).
|
|
2982
|
+
*/
|
|
2983
|
+
connections?: Record<string, string>;
|
|
2984
|
+
/** Overall time limit; defaults to the action's own. */
|
|
2985
|
+
timeout_ms?: number;
|
|
2986
|
+
}
|
|
2987
|
+
export interface ActionResult {
|
|
2988
|
+
object: "action_result";
|
|
2989
|
+
/** The exact version that ran. */
|
|
2990
|
+
ref: string;
|
|
2991
|
+
/** Matches the action's output schema. */
|
|
2992
|
+
output: unknown;
|
|
2993
|
+
/** HTTP status of the upstream call, for declarative HTTP actions. */
|
|
2994
|
+
upstream_status?: number;
|
|
2995
|
+
timing: Timing;
|
|
2996
|
+
}
|
|
2997
|
+
export interface TriggerSummary {
|
|
2998
|
+
ref: string;
|
|
2999
|
+
pack: string;
|
|
3000
|
+
key: string;
|
|
3001
|
+
title: string;
|
|
3002
|
+
description: string;
|
|
3003
|
+
kind: "webhook" | "poll" | "schedule";
|
|
3004
|
+
config_schema: JsonSchemaDocument;
|
|
3005
|
+
event_schema: JsonSchemaDocument;
|
|
3006
|
+
connections: string[];
|
|
3007
|
+
}
|
|
3008
|
+
export type TriggerList = Omit<ListEnvelope, "data"> & {
|
|
3009
|
+
data: TriggerSummary[];
|
|
3010
|
+
};
|
|
3011
|
+
export interface PackPublisher {
|
|
3012
|
+
id: string;
|
|
3013
|
+
name: string;
|
|
3014
|
+
/** Set by the registry, never by the manifest. */
|
|
3015
|
+
verified: boolean;
|
|
3016
|
+
}
|
|
3017
|
+
export interface PackSummaryFields {
|
|
3018
|
+
/** `<namespace>/<name>`. */
|
|
3019
|
+
id: string;
|
|
3020
|
+
object: "pack";
|
|
3021
|
+
title: string;
|
|
3022
|
+
description: string;
|
|
3023
|
+
publisher: PackPublisher;
|
|
3024
|
+
latest_version: string;
|
|
3025
|
+
action_count: number;
|
|
3026
|
+
trigger_count: number;
|
|
3027
|
+
}
|
|
3028
|
+
/** A pack in a list. */
|
|
3029
|
+
export type PackSummary = PackSummaryFields;
|
|
3030
|
+
export type PackList = Omit<ListEnvelope, "data"> & {
|
|
3031
|
+
data: PackSummary[];
|
|
3032
|
+
};
|
|
3033
|
+
/** One version of a pack. */
|
|
3034
|
+
export type Pack = PackSummaryFields & {
|
|
3035
|
+
version: string;
|
|
3036
|
+
/** Every published version, newest first. */
|
|
3037
|
+
versions: string[];
|
|
3038
|
+
connections: {
|
|
3039
|
+
key: string;
|
|
3040
|
+
type: "api_key" | "basic" | "bearer" | "oauth2" | "none";
|
|
3041
|
+
label: string;
|
|
3042
|
+
}[];
|
|
3043
|
+
/** Hosts the pack may reach. */
|
|
3044
|
+
egress: string[];
|
|
3045
|
+
actions: ActionSummary[];
|
|
3046
|
+
triggers: TriggerSummary[];
|
|
3047
|
+
content_hash: string;
|
|
3048
|
+
published_at: string;
|
|
3049
|
+
};
|
|
3050
|
+
/** The credential kind, as in pack manifests. */
|
|
3051
|
+
export type ConnectionType = "api_key" | "basic" | "bearer" | "oauth2" | "none";
|
|
3052
|
+
/**
|
|
3053
|
+
* Secret fields for the connection's type. Write-only: accepted on create and update, never returned or logged.
|
|
3054
|
+
*/
|
|
3055
|
+
export interface ConnectionSecret {
|
|
3056
|
+
api_key?: string;
|
|
3057
|
+
username?: string;
|
|
3058
|
+
password?: string;
|
|
3059
|
+
token?: string;
|
|
3060
|
+
access_token?: string;
|
|
3061
|
+
refresh_token?: string;
|
|
3062
|
+
/** When `access_token` expires (oauth2). */
|
|
3063
|
+
expires_at?: string;
|
|
3064
|
+
client_id?: string;
|
|
3065
|
+
client_secret?: string;
|
|
3066
|
+
}
|
|
3067
|
+
export interface ConnectionCreateRequest {
|
|
3068
|
+
/** The pack this credential is for (`io.b3os/github`). */
|
|
3069
|
+
pack?: string;
|
|
3070
|
+
/** The pack's connection key (`connections.<key>` in its manifest). Required with `pack`. */
|
|
3071
|
+
key?: string;
|
|
3072
|
+
type?: ConnectionType;
|
|
3073
|
+
label?: string;
|
|
3074
|
+
/** Your end user's ID, when you store one credential per user. */
|
|
3075
|
+
subject?: string;
|
|
3076
|
+
/**
|
|
3077
|
+
* Hosts that receive the credential (exact names or `*.` wildcards), taken from the pack for a pack
|
|
3078
|
+
* connection. Without `pack`, list the hosts your own HTTP steps call, or omit it (or give `[]`) for a
|
|
3079
|
+
* verification-only connection: a connection with no hosts is never injected anywhere, because egress
|
|
3080
|
+
* injection matches on hosts. It only holds a secret B3OS itself uses, such as a routine webhook's
|
|
3081
|
+
* `verify.secret`.
|
|
3082
|
+
*/
|
|
3083
|
+
hosts?: string[];
|
|
3084
|
+
/** Non-secret configuration the pack's connection declares (for example a Jira site name). */
|
|
3085
|
+
params?: Record<string, unknown>;
|
|
3086
|
+
secret: ConnectionSecret;
|
|
3087
|
+
metadata?: Metadata;
|
|
3088
|
+
}
|
|
3089
|
+
export interface ConnectionUpdateRequest {
|
|
3090
|
+
label?: string;
|
|
3091
|
+
subject?: string | null;
|
|
3092
|
+
/** Connections without a pack only. `[]` makes the connection verification-only (never injected). */
|
|
3093
|
+
hosts?: string[];
|
|
3094
|
+
params?: Record<string, unknown>;
|
|
3095
|
+
secret?: ConnectionSecret;
|
|
3096
|
+
metadata?: Metadata;
|
|
3097
|
+
}
|
|
3098
|
+
export interface Connection {
|
|
3099
|
+
id: string;
|
|
3100
|
+
object: "connection";
|
|
3101
|
+
pack: string | null;
|
|
3102
|
+
key: string | null;
|
|
3103
|
+
type: ConnectionType;
|
|
3104
|
+
label: string | null;
|
|
3105
|
+
subject: string | null;
|
|
3106
|
+
/** Hosts that receive the credential; `[]` for a verification-only connection (never injected). */
|
|
3107
|
+
hosts: string[];
|
|
3108
|
+
params: Record<string, unknown>;
|
|
3109
|
+
/** Names of the stored secret fields. */
|
|
3110
|
+
secret_fields: string[];
|
|
3111
|
+
/** `expired` when an OAuth access token passed `expires_at` and could not be refreshed. */
|
|
3112
|
+
status: "active" | "expired";
|
|
3113
|
+
expires_at: string | null;
|
|
3114
|
+
created_at: string;
|
|
3115
|
+
updated_at: string;
|
|
3116
|
+
last_used_at: string | null;
|
|
3117
|
+
metadata: Metadata;
|
|
3118
|
+
}
|
|
3119
|
+
export type ConnectionList = Omit<ListEnvelope, "data"> & {
|
|
3120
|
+
data: Connection[];
|
|
3121
|
+
};
|
|
3122
|
+
export interface TextPart {
|
|
3123
|
+
type: "text";
|
|
3124
|
+
text: string;
|
|
3125
|
+
}
|
|
3126
|
+
export interface ImagePart {
|
|
3127
|
+
type: "image_url";
|
|
3128
|
+
image_url: {
|
|
3129
|
+
/**
|
|
3130
|
+
* An `https://` URL (fetched by the node through its egress guard; PNG, JPEG, WebP or GIF, at most
|
|
3131
|
+
* 10 MiB) or a `data:image/{png,jpeg,webp,gif};base64,` URL. Images are scaled to at most about
|
|
3132
|
+
* one megapixel (about 1,024 prompt tokens each).
|
|
3133
|
+
*/
|
|
3134
|
+
url: string;
|
|
3135
|
+
detail?: "auto" | "low" | "high";
|
|
3136
|
+
};
|
|
3137
|
+
}
|
|
3138
|
+
export type ContentPart = TextPart | ImagePart;
|
|
3139
|
+
export interface ToolCall {
|
|
3140
|
+
id: string;
|
|
3141
|
+
type: "function";
|
|
3142
|
+
function: {
|
|
3143
|
+
name: string;
|
|
3144
|
+
/** JSON-encoded arguments. */
|
|
3145
|
+
arguments: string;
|
|
3146
|
+
};
|
|
3147
|
+
}
|
|
3148
|
+
/**
|
|
3149
|
+
* A message. `content` may be a string or a list of parts (images only in `user` messages); only `assistant`
|
|
3150
|
+
* messages may have `null` content (`400 invalid_request` with the pointer otherwise). Members not listed
|
|
3151
|
+
* here (such as `annotations` or `audio` echoed from an earlier response) are ignored.
|
|
3152
|
+
*/
|
|
3153
|
+
export interface ChatMessage {
|
|
3154
|
+
role: "system" | "developer" | "user" | "assistant" | "tool";
|
|
3155
|
+
content?: string | null | ContentPart[];
|
|
3156
|
+
name?: string | null;
|
|
3157
|
+
tool_calls?: ToolCall[] | null;
|
|
3158
|
+
/** For `tool` messages, the call this is the result of. */
|
|
3159
|
+
tool_call_id?: string | null;
|
|
3160
|
+
refusal?: string | null;
|
|
3161
|
+
/** B3OS extension. The reasoning of an earlier assistant turn, passed back to the model's template. */
|
|
3162
|
+
reasoning_content?: string | null;
|
|
3163
|
+
}
|
|
3164
|
+
export interface FunctionTool {
|
|
3165
|
+
type: "function";
|
|
3166
|
+
function: {
|
|
3167
|
+
name: string;
|
|
3168
|
+
description?: string;
|
|
3169
|
+
/** A JSON Schema object (at most 64 KiB serialized and 32 levels deep), as OpenAI requires. */
|
|
3170
|
+
parameters?: Record<string, unknown>;
|
|
3171
|
+
strict?: boolean;
|
|
3172
|
+
};
|
|
3173
|
+
}
|
|
3174
|
+
export interface ResponseFormatText {
|
|
3175
|
+
type: "text";
|
|
3176
|
+
}
|
|
3177
|
+
export interface ResponseFormatJsonObject {
|
|
3178
|
+
type: "json_object";
|
|
3179
|
+
}
|
|
3180
|
+
export interface ResponseFormatJsonSchema {
|
|
3181
|
+
type: "json_schema";
|
|
3182
|
+
json_schema: {
|
|
3183
|
+
name: string;
|
|
3184
|
+
description?: string;
|
|
3185
|
+
/** A JSON Schema object (at most 64 KiB serialized and 32 levels deep), as OpenAI requires. */
|
|
3186
|
+
schema?: Record<string, unknown>;
|
|
3187
|
+
strict?: boolean;
|
|
3188
|
+
};
|
|
3189
|
+
}
|
|
3190
|
+
/**
|
|
3191
|
+
* OpenAI Chat Completions parameters, the runtime extensions this node takes, and `route`. Any other parameter
|
|
3192
|
+
* is `400 unsupported_parameter`. `null` means unset for every optional parameter.
|
|
3193
|
+
*/
|
|
3194
|
+
export interface ChatCompletionRequest {
|
|
3195
|
+
/** A model ID from `GET /v1/infer/models`. */
|
|
3196
|
+
model: string;
|
|
3197
|
+
messages: ChatMessage[];
|
|
3198
|
+
tools?: FunctionTool[] | null;
|
|
3199
|
+
tool_choice?: null | "none" | "auto" | "required" | {
|
|
3200
|
+
type: "function";
|
|
3201
|
+
function: {
|
|
3202
|
+
name: string;
|
|
3203
|
+
};
|
|
3204
|
+
};
|
|
3205
|
+
parallel_tool_calls?: boolean | null;
|
|
3206
|
+
response_format?: null | ResponseFormatText | ResponseFormatJsonObject | ResponseFormatJsonSchema;
|
|
3207
|
+
temperature?: number | null;
|
|
3208
|
+
/**
|
|
3209
|
+
* Nucleus sampling. `0` keeps only the most probable token (passed to the runtime as 1e-9, the same thing, since vLLM takes values above 0 only).
|
|
3210
|
+
*/
|
|
3211
|
+
top_p?: number | null;
|
|
3212
|
+
max_tokens?: number | null;
|
|
3213
|
+
/** Wins over `max_tokens` when both are set. */
|
|
3214
|
+
max_completion_tokens?: number | null;
|
|
3215
|
+
stop?: null | string | string[];
|
|
3216
|
+
seed?: number | null;
|
|
3217
|
+
/** Only 1 is supported. */
|
|
3218
|
+
n?: number | null;
|
|
3219
|
+
presence_penalty?: number | null;
|
|
3220
|
+
frequency_penalty?: number | null;
|
|
3221
|
+
logprobs?: boolean | null;
|
|
3222
|
+
top_logprobs?: number | null;
|
|
3223
|
+
user?: string | null;
|
|
3224
|
+
/** @default false */
|
|
3225
|
+
stream?: boolean | null;
|
|
3226
|
+
stream_options?: {
|
|
3227
|
+
include_usage?: boolean | null;
|
|
3228
|
+
} | null;
|
|
3229
|
+
/**
|
|
3230
|
+
* B3OS extension. `gateway` sends the request to the B3IQ gateway when this node does not serve the model
|
|
3231
|
+
* (models it serves stay local); without it an unknown model is `404 model_not_available`.
|
|
3232
|
+
* @default "local"
|
|
3233
|
+
*/
|
|
3234
|
+
route?: "local" | "gateway" | null;
|
|
3235
|
+
/** Runtime extension. Sample from the `top_k` most likely tokens; `-1` turns it off. */
|
|
3236
|
+
top_k?: number | null;
|
|
3237
|
+
/** Runtime extension. Minimum probability relative to the most likely token. */
|
|
3238
|
+
min_p?: number | null;
|
|
3239
|
+
/** Runtime extension. Values above 1 discourage repeating tokens. */
|
|
3240
|
+
repetition_penalty?: number | null;
|
|
3241
|
+
/** Token ID to bias added to its logit. */
|
|
3242
|
+
logit_bias?: Record<string, number> | null;
|
|
3243
|
+
/** Runtime extension. Only `enable_thinking` is taken. */
|
|
3244
|
+
chat_template_kwargs?: {
|
|
3245
|
+
/** Let the model reason before answering; the reasoning arrives in `reasoning_content`. */
|
|
3246
|
+
enable_thinking?: boolean;
|
|
3247
|
+
} | null;
|
|
3248
|
+
/** Accepted and ignored. */
|
|
3249
|
+
metadata?: Record<string, string> | null;
|
|
3250
|
+
/** Accepted and ignored (nothing is stored). */
|
|
3251
|
+
store?: boolean | null;
|
|
3252
|
+
/** Accepted and ignored. */
|
|
3253
|
+
service_tier?: string | null;
|
|
3254
|
+
}
|
|
3255
|
+
export interface Usage {
|
|
3256
|
+
prompt_tokens: number;
|
|
3257
|
+
completion_tokens: number;
|
|
3258
|
+
total_tokens: number;
|
|
3259
|
+
[key: string]: unknown;
|
|
3260
|
+
}
|
|
3261
|
+
/**
|
|
3262
|
+
* B3OS extension; OpenAI SDKs ignore it. On a stream it rides on the last chunk: the usage chunk with
|
|
3263
|
+
* `stream_options.include_usage`, else the chunk with `finish_reason`.
|
|
3264
|
+
*/
|
|
3265
|
+
export interface InferMeta {
|
|
3266
|
+
route?: "local" | "gateway";
|
|
3267
|
+
node?: string;
|
|
3268
|
+
/** Server-side milliseconds from the request head (`ttft_ms` on streams, `model_ms` without). */
|
|
3269
|
+
timing?: {
|
|
3270
|
+
ttft_ms?: number;
|
|
3271
|
+
model_ms?: number;
|
|
3272
|
+
total_ms?: number;
|
|
3273
|
+
};
|
|
3274
|
+
}
|
|
3275
|
+
export interface ChatCompletion {
|
|
3276
|
+
id: string;
|
|
3277
|
+
object: "chat.completion";
|
|
3278
|
+
/** Unix seconds. */
|
|
3279
|
+
created: number;
|
|
3280
|
+
model: string;
|
|
3281
|
+
choices: {
|
|
3282
|
+
index: number;
|
|
3283
|
+
message: {
|
|
3284
|
+
role: "assistant";
|
|
3285
|
+
content: string | null;
|
|
3286
|
+
tool_calls?: ToolCall[];
|
|
3287
|
+
refusal?: string | null;
|
|
3288
|
+
/** B3OS extension. The model's reasoning, when `chat_template_kwargs.enable_thinking` is on. */
|
|
3289
|
+
reasoning_content?: string;
|
|
3290
|
+
};
|
|
3291
|
+
finish_reason: "stop" | "length" | "tool_calls" | "content_filter";
|
|
3292
|
+
logprobs?: Record<string, unknown> | null;
|
|
3293
|
+
}[];
|
|
3294
|
+
usage?: Usage;
|
|
3295
|
+
system_fingerprint?: string | null;
|
|
3296
|
+
b3os?: InferMeta;
|
|
3297
|
+
}
|
|
3298
|
+
export interface ChatCompletionChunk {
|
|
3299
|
+
id: string;
|
|
3300
|
+
object: "chat.completion.chunk";
|
|
3301
|
+
created: number;
|
|
3302
|
+
model: string;
|
|
3303
|
+
choices: {
|
|
3304
|
+
index: number;
|
|
3305
|
+
delta: {
|
|
3306
|
+
role?: "assistant";
|
|
3307
|
+
content?: string | null;
|
|
3308
|
+
tool_calls?: {
|
|
3309
|
+
index: number;
|
|
3310
|
+
id?: string;
|
|
3311
|
+
type?: "function";
|
|
3312
|
+
function?: {
|
|
3313
|
+
name?: string;
|
|
3314
|
+
arguments?: string;
|
|
3315
|
+
};
|
|
3316
|
+
}[];
|
|
3317
|
+
refusal?: string | null;
|
|
3318
|
+
/** B3OS extension. A piece of the model's reasoning (thinking on). */
|
|
3319
|
+
reasoning_content?: string;
|
|
3320
|
+
};
|
|
3321
|
+
finish_reason: "stop" | "length" | "tool_calls" | "content_filter" | null;
|
|
3322
|
+
logprobs?: Record<string, unknown> | null;
|
|
3323
|
+
}[];
|
|
3324
|
+
usage?: null | Usage;
|
|
3325
|
+
b3os?: InferMeta;
|
|
3326
|
+
}
|
|
3327
|
+
/** B3OS extension with what the model supports and your limits on it. */
|
|
3328
|
+
export interface ModelInfo {
|
|
3329
|
+
kind: "chat" | "embedding" | "speech";
|
|
3330
|
+
context_length: number | null;
|
|
3331
|
+
quantization: string | null;
|
|
3332
|
+
tools: boolean;
|
|
3333
|
+
json_schema: boolean;
|
|
3334
|
+
image_input: boolean;
|
|
3335
|
+
max_request_bytes: number;
|
|
3336
|
+
limits: {
|
|
3337
|
+
/** Tokens per minute for your organization. */
|
|
3338
|
+
tpm: number | null;
|
|
3339
|
+
rpm: number | null;
|
|
3340
|
+
};
|
|
3341
|
+
}
|
|
3342
|
+
export interface Model {
|
|
3343
|
+
id: string;
|
|
3344
|
+
object: "model";
|
|
3345
|
+
created: number;
|
|
3346
|
+
owned_by: string;
|
|
3347
|
+
b3os: ModelInfo;
|
|
3348
|
+
}
|
|
3349
|
+
/** The OpenAI list shape (no cursor). */
|
|
3350
|
+
export interface ModelList {
|
|
3351
|
+
object: "list";
|
|
3352
|
+
data: Model[];
|
|
3353
|
+
}
|
|
3354
|
+
export interface EmbeddingRequest {
|
|
3355
|
+
model: string;
|
|
3356
|
+
input: string | string[] | number[] | number[][];
|
|
3357
|
+
/** @default "float" */
|
|
3358
|
+
encoding_format?: "float" | "base64";
|
|
3359
|
+
dimensions?: number;
|
|
3360
|
+
user?: string;
|
|
3361
|
+
}
|
|
3362
|
+
export interface EmbeddingList {
|
|
3363
|
+
object: "list";
|
|
3364
|
+
data: {
|
|
3365
|
+
object: "embedding";
|
|
3366
|
+
index: number;
|
|
3367
|
+
embedding: number[] | string;
|
|
3368
|
+
}[];
|
|
3369
|
+
model: string;
|
|
3370
|
+
usage: {
|
|
3371
|
+
prompt_tokens: number;
|
|
3372
|
+
total_tokens: number;
|
|
3373
|
+
};
|
|
3374
|
+
}
|
|
3375
|
+
/** OpenAI speech parameters; `null` means unset on the optional ones. */
|
|
3376
|
+
export interface SpeechRequest {
|
|
3377
|
+
/** A speech model, such as `kokoro-82m`. */
|
|
3378
|
+
model: string;
|
|
3379
|
+
input: string;
|
|
3380
|
+
/** A voice ID from `GET /v1/infer/audio/voices`. */
|
|
3381
|
+
voice: string;
|
|
3382
|
+
/** @default "mp3" */
|
|
3383
|
+
response_format?: "mp3" | "opus" | "aac" | "flac" | "wav" | "pcm" | null;
|
|
3384
|
+
/**
|
|
3385
|
+
* OpenAI's range. `kokoro-82m` speaks at 0.5 to 2; a speed outside a model's range is `400 unsupported_parameter` (never clamped).
|
|
3386
|
+
* @default 1
|
|
3387
|
+
*/
|
|
3388
|
+
speed?: number | null;
|
|
3389
|
+
/**
|
|
3390
|
+
* Style guidance, for models that support it. `kokoro-82m` does not: non-blank instructions are `400 unsupported_parameter`.
|
|
3391
|
+
*/
|
|
3392
|
+
instructions?: string | null;
|
|
3393
|
+
/**
|
|
3394
|
+
* B3OS extension. `word` returns JSON with base64 audio and per-word start and end times.
|
|
3395
|
+
* @default "none"
|
|
3396
|
+
*/
|
|
3397
|
+
timestamps?: "none" | "word" | null;
|
|
3398
|
+
}
|
|
3399
|
+
export interface SpeechWithTimestamps {
|
|
3400
|
+
object: "speech";
|
|
3401
|
+
model: string;
|
|
3402
|
+
voice: string;
|
|
3403
|
+
format: "mp3" | "opus" | "aac" | "flac" | "wav" | "pcm";
|
|
3404
|
+
sample_rate: number;
|
|
3405
|
+
duration_ms: number;
|
|
3406
|
+
audio_base64: string;
|
|
3407
|
+
words: {
|
|
3408
|
+
text: string;
|
|
3409
|
+
start_ms: number;
|
|
3410
|
+
end_ms: number;
|
|
3411
|
+
}[];
|
|
3412
|
+
}
|
|
3413
|
+
export interface Voice {
|
|
3414
|
+
id: string;
|
|
3415
|
+
object: "voice";
|
|
3416
|
+
model: string;
|
|
3417
|
+
name: string;
|
|
3418
|
+
/** BCP 47 tag. */
|
|
3419
|
+
language: string;
|
|
3420
|
+
/**
|
|
3421
|
+
* A short audio sample of the voice, a B3OS static asset: `https://beta.b3os.org/assets/voices/<voice>.<ext>`
|
|
3422
|
+
* (B3OS's own media are never served from `usercontent.b3os.org`, which holds customer bytes only).
|
|
3423
|
+
*/
|
|
3424
|
+
sample_url?: string;
|
|
3425
|
+
}
|
|
3426
|
+
export type VoiceList = Omit<ListEnvelope, "data"> & {
|
|
3427
|
+
data: Voice[];
|
|
3428
|
+
};
|
|
3429
|
+
/** Accepted and ignored. */
|
|
3430
|
+
export type AnthropicCacheControl = {
|
|
3431
|
+
type?: string;
|
|
3432
|
+
ttl?: string;
|
|
3433
|
+
} | null;
|
|
3434
|
+
export interface AnthropicTextBlock {
|
|
3435
|
+
type: "text";
|
|
3436
|
+
text: string;
|
|
3437
|
+
cache_control?: AnthropicCacheControl;
|
|
3438
|
+
/** Accepted and ignored. */
|
|
3439
|
+
citations?: Record<string, unknown>[] | null;
|
|
3440
|
+
}
|
|
3441
|
+
export interface AnthropicImageBlock {
|
|
3442
|
+
type: "image";
|
|
3443
|
+
source: {
|
|
3444
|
+
type: "base64";
|
|
3445
|
+
media_type: "image/png" | "image/jpeg" | "image/webp" | "image/gif";
|
|
3446
|
+
/** The image file, which must be a PNG, JPEG, WebP or GIF. */
|
|
3447
|
+
data: string;
|
|
3448
|
+
} | {
|
|
3449
|
+
type: "url";
|
|
3450
|
+
/** Fetched by the node through its egress guard (PNG, JPEG, WebP or GIF, at most 10 MiB). */
|
|
3451
|
+
url: string;
|
|
3452
|
+
};
|
|
3453
|
+
cache_control?: AnthropicCacheControl;
|
|
3454
|
+
}
|
|
3455
|
+
export interface AnthropicToolUseBlock {
|
|
3456
|
+
type: "tool_use";
|
|
3457
|
+
id: string;
|
|
3458
|
+
name: string;
|
|
3459
|
+
input: Record<string, unknown>;
|
|
3460
|
+
cache_control?: AnthropicCacheControl;
|
|
3461
|
+
}
|
|
3462
|
+
export interface AnthropicToolResultBlock {
|
|
3463
|
+
type: "tool_result";
|
|
3464
|
+
tool_use_id: string;
|
|
3465
|
+
content?: null | string | Array<AnthropicTextBlock | AnthropicImageBlock>;
|
|
3466
|
+
/** The result is an error; the model sees it prefixed with `Error:`. */
|
|
3467
|
+
is_error?: boolean | null;
|
|
3468
|
+
cache_control?: AnthropicCacheControl;
|
|
3469
|
+
}
|
|
3470
|
+
export interface AnthropicThinkingBlock {
|
|
3471
|
+
type: "thinking";
|
|
3472
|
+
thinking: string;
|
|
3473
|
+
/** Opaque; this node does not check it. */
|
|
3474
|
+
signature?: string | null;
|
|
3475
|
+
}
|
|
3476
|
+
/** Accepted in assistant turns and left out of the prompt. */
|
|
3477
|
+
export interface AnthropicRedactedThinkingBlock {
|
|
3478
|
+
type: "redacted_thinking";
|
|
3479
|
+
data: string;
|
|
3480
|
+
}
|
|
3481
|
+
export interface AnthropicUserMessage {
|
|
3482
|
+
role: "user";
|
|
3483
|
+
content: string | Array<AnthropicTextBlock | AnthropicImageBlock | AnthropicToolResultBlock>;
|
|
3484
|
+
}
|
|
3485
|
+
/** An earlier answer; as the last message, the start of the answer, which the model continues. */
|
|
3486
|
+
export interface AnthropicAssistantMessage {
|
|
3487
|
+
role: "assistant";
|
|
3488
|
+
content: string | Array<AnthropicTextBlock | AnthropicToolUseBlock | AnthropicThinkingBlock | AnthropicRedactedThinkingBlock>;
|
|
3489
|
+
}
|
|
3490
|
+
export type AnthropicInputMessage = AnthropicUserMessage | AnthropicAssistantMessage;
|
|
3491
|
+
/**
|
|
3492
|
+
* A custom tool. Tools Anthropic defines or runs (a `type` other than `custom`) are `unsupported_parameter`.
|
|
3493
|
+
*/
|
|
3494
|
+
export interface AnthropicTool {
|
|
3495
|
+
type?: "custom" | null;
|
|
3496
|
+
/** Unique within `tools`. */
|
|
3497
|
+
name: string;
|
|
3498
|
+
description?: string | null;
|
|
3499
|
+
/** A JSON Schema object (at most 64 KiB serialized and 32 levels deep). */
|
|
3500
|
+
input_schema: Record<string, unknown>;
|
|
3501
|
+
strict?: boolean | null;
|
|
3502
|
+
cache_control?: AnthropicCacheControl;
|
|
3503
|
+
}
|
|
3504
|
+
export type AnthropicToolChoice = (Record<string, unknown> & {
|
|
3505
|
+
/** `any` makes the model call a tool (it needs `tools`). */
|
|
3506
|
+
type: "auto" | "any";
|
|
3507
|
+
disable_parallel_tool_use?: boolean | null;
|
|
3508
|
+
}) | {
|
|
3509
|
+
type: "tool";
|
|
3510
|
+
/** One of `tools`. */
|
|
3511
|
+
name: string;
|
|
3512
|
+
disable_parallel_tool_use?: boolean | null;
|
|
3513
|
+
} | {
|
|
3514
|
+
type: "none";
|
|
3515
|
+
};
|
|
3516
|
+
/**
|
|
3517
|
+
* `enabled` (with `budget_tokens`, at least 1024 and less than `max_tokens`) and `adaptive` let the model
|
|
3518
|
+
* reason first, in `thinking` blocks; `disabled`, the default, does not. `display` is accepted and ignored.
|
|
3519
|
+
*/
|
|
3520
|
+
export type AnthropicThinking = (Record<string, unknown> & {
|
|
3521
|
+
type: "enabled";
|
|
3522
|
+
budget_tokens: number;
|
|
3523
|
+
display?: "summarized" | "omitted" | "updates" | null;
|
|
3524
|
+
}) | {
|
|
3525
|
+
type: "adaptive";
|
|
3526
|
+
display?: "summarized" | "omitted" | "updates" | null;
|
|
3527
|
+
} | {
|
|
3528
|
+
type: "disabled";
|
|
3529
|
+
};
|
|
3530
|
+
/**
|
|
3531
|
+
* Anthropic Messages parameters. Any other parameter is `400 unsupported_parameter`; `null` means unset.
|
|
3532
|
+
*/
|
|
3533
|
+
export interface AnthropicMessagesRequest {
|
|
3534
|
+
model: string;
|
|
3535
|
+
messages: AnthropicInputMessage[];
|
|
3536
|
+
max_tokens: number;
|
|
3537
|
+
/** The system prompt; text blocks are joined with blank lines. */
|
|
3538
|
+
system?: null | string | AnthropicTextBlock[];
|
|
3539
|
+
tools?: AnthropicTool[] | null;
|
|
3540
|
+
tool_choice?: null | AnthropicToolChoice;
|
|
3541
|
+
thinking?: null | AnthropicThinking;
|
|
3542
|
+
output_config?: {
|
|
3543
|
+
/** The answer is JSON matching `schema` (at most 64 KiB serialized and 32 levels deep). */
|
|
3544
|
+
format?: {
|
|
3545
|
+
type: "json_schema";
|
|
3546
|
+
/** A JSON Schema object, as Anthropic requires. */
|
|
3547
|
+
schema: Record<string, unknown>;
|
|
3548
|
+
} | null;
|
|
3549
|
+
/** Accepted and ignored. */
|
|
3550
|
+
effort?: "low" | "medium" | "high" | "xhigh" | "max" | null;
|
|
3551
|
+
} | null;
|
|
3552
|
+
stop_sequences?: string[] | null;
|
|
3553
|
+
stream?: boolean | null;
|
|
3554
|
+
temperature?: number | null;
|
|
3555
|
+
/**
|
|
3556
|
+
* Nucleus sampling. `0` keeps only the most probable token (passed to the runtime as 1e-9, the same thing, since vLLM takes values above 0 only).
|
|
3557
|
+
*/
|
|
3558
|
+
top_p?: number | null;
|
|
3559
|
+
top_k?: number | null;
|
|
3560
|
+
/** Accepted and ignored. */
|
|
3561
|
+
metadata?: {
|
|
3562
|
+
user_id?: string | null;
|
|
3563
|
+
} | null;
|
|
3564
|
+
/** Accepted and ignored. */
|
|
3565
|
+
service_tier?: string | null;
|
|
3566
|
+
}
|
|
3567
|
+
/** The input of a Messages request. Any other parameter is `400 unsupported_parameter`. */
|
|
3568
|
+
export interface AnthropicCountTokensRequest {
|
|
3569
|
+
model: string;
|
|
3570
|
+
messages: AnthropicInputMessage[];
|
|
3571
|
+
/** The system prompt; text blocks are joined with blank lines. */
|
|
3572
|
+
system?: null | string | AnthropicTextBlock[];
|
|
3573
|
+
tools?: AnthropicTool[] | null;
|
|
3574
|
+
tool_choice?: null | AnthropicToolChoice;
|
|
3575
|
+
thinking?: null | AnthropicThinking;
|
|
3576
|
+
}
|
|
3577
|
+
export interface AnthropicCountTokens {
|
|
3578
|
+
input_tokens: number;
|
|
3579
|
+
}
|
|
3580
|
+
export interface AnthropicUsage {
|
|
3581
|
+
input_tokens: number;
|
|
3582
|
+
output_tokens: number;
|
|
3583
|
+
}
|
|
3584
|
+
/**
|
|
3585
|
+
* A block of the answer, `text`, `tool_use` (with `id`, `name`, `input`) or `thinking` (with `signature`).
|
|
3586
|
+
*/
|
|
3587
|
+
export interface AnthropicOutputBlock {
|
|
3588
|
+
type: "text" | "tool_use" | "thinking";
|
|
3589
|
+
text?: string;
|
|
3590
|
+
id?: string;
|
|
3591
|
+
name?: string;
|
|
3592
|
+
input?: Record<string, unknown>;
|
|
3593
|
+
thinking?: string;
|
|
3594
|
+
signature?: string;
|
|
3595
|
+
}
|
|
3596
|
+
export interface AnthropicMessage {
|
|
3597
|
+
id: string;
|
|
3598
|
+
type: "message";
|
|
3599
|
+
role: "assistant";
|
|
3600
|
+
content: AnthropicOutputBlock[];
|
|
3601
|
+
model: string;
|
|
3602
|
+
stop_reason: "end_turn" | "max_tokens" | "stop_sequence" | "tool_use" | "refusal";
|
|
3603
|
+
/** The stop sequence that ended the answer. */
|
|
3604
|
+
stop_sequence: string | null;
|
|
3605
|
+
usage: AnthropicUsage;
|
|
3606
|
+
b3os?: InferMeta;
|
|
3607
|
+
}
|
|
3608
|
+
/**
|
|
3609
|
+
* One event of a stream, named by its `type` (the SSE `event:` field carries the same name):
|
|
3610
|
+
* `message_start` (`message`, with empty `content` and the input tokens), `content_block_start` (`index`,
|
|
3611
|
+
* `content_block`), `content_block_delta` (`index`, and a `delta` of type `text_delta`, `input_json_delta`,
|
|
3612
|
+
* `thinking_delta` or `signature_delta`), `content_block_stop` (`index`), `message_delta` (`delta` with
|
|
3613
|
+
* `stop_reason` and `stop_sequence`, and `usage`), `message_stop` (with the `b3os` metadata), or `error`.
|
|
3614
|
+
*/
|
|
3615
|
+
export interface AnthropicStreamEvent {
|
|
3616
|
+
type: "message_start" | "content_block_start" | "content_block_delta" | "content_block_stop" | "message_delta" | "message_stop" | "error";
|
|
3617
|
+
message?: Record<string, unknown>;
|
|
3618
|
+
index?: number;
|
|
3619
|
+
content_block?: Record<string, unknown>;
|
|
3620
|
+
delta?: Record<string, unknown>;
|
|
3621
|
+
usage?: Record<string, unknown>;
|
|
3622
|
+
error?: {
|
|
3623
|
+
type?: string;
|
|
3624
|
+
message?: string;
|
|
3625
|
+
};
|
|
3626
|
+
b3os?: InferMeta;
|
|
3627
|
+
}
|
|
3628
|
+
export interface ResponsesInputText {
|
|
3629
|
+
type: "input_text";
|
|
3630
|
+
text: string;
|
|
3631
|
+
prompt_cache_breakpoint?: ResponsesCacheBreakpoint;
|
|
3632
|
+
}
|
|
3633
|
+
/** Accepted and ignored; the runtime caches prompt prefixes on its own. */
|
|
3634
|
+
export type ResponsesCacheBreakpoint = {
|
|
3635
|
+
mode?: "explicit" | null;
|
|
3636
|
+
} | null;
|
|
3637
|
+
export interface ResponsesInputImage {
|
|
3638
|
+
type: "input_image";
|
|
3639
|
+
/** `https://` (fetched by the node through its egress guard) or a base64 `data:` URL. */
|
|
3640
|
+
image_url: string;
|
|
3641
|
+
/** Accepted and ignored; images are resized to about 1 MP. */
|
|
3642
|
+
detail?: "auto" | "low" | "high" | "original" | null;
|
|
3643
|
+
/** The Files API is not available on this node (null only). */
|
|
3644
|
+
file_id?: null;
|
|
3645
|
+
prompt_cache_breakpoint?: ResponsesCacheBreakpoint;
|
|
3646
|
+
}
|
|
3647
|
+
export interface ResponsesOutputText {
|
|
3648
|
+
type: "output_text";
|
|
3649
|
+
text: string;
|
|
3650
|
+
annotations?: Record<string, unknown>[] | null;
|
|
3651
|
+
logprobs?: Record<string, unknown>[] | null;
|
|
3652
|
+
}
|
|
3653
|
+
export interface ResponsesRefusal {
|
|
3654
|
+
type: "refusal";
|
|
3655
|
+
refusal: string;
|
|
3656
|
+
}
|
|
3657
|
+
/**
|
|
3658
|
+
* A message. `user` messages take `input_text` and `input_image` parts, `system` and `developer` messages `input_text` parts (both become the system prompt, after `instructions`), `assistant` messages `output_text` and `refusal` parts. A string is one text part.
|
|
3659
|
+
*/
|
|
3660
|
+
export interface ResponsesInputMessage {
|
|
3661
|
+
type?: "message" | null;
|
|
3662
|
+
role: "user" | "assistant" | "system" | "developer";
|
|
3663
|
+
content: string | Array<ResponsesInputText | ResponsesInputImage | ResponsesOutputText | ResponsesRefusal>;
|
|
3664
|
+
id?: string | null;
|
|
3665
|
+
status?: string | null;
|
|
3666
|
+
phase?: string | null;
|
|
3667
|
+
}
|
|
3668
|
+
/** A function call the model made in an earlier turn. */
|
|
3669
|
+
export interface ResponsesFunctionCallItem {
|
|
3670
|
+
type: "function_call";
|
|
3671
|
+
call_id: string;
|
|
3672
|
+
name: string;
|
|
3673
|
+
arguments: string;
|
|
3674
|
+
id?: string | null;
|
|
3675
|
+
status?: string | null;
|
|
3676
|
+
caller?: Record<string, unknown> | null;
|
|
3677
|
+
namespace?: string | null;
|
|
3678
|
+
/** Accepted and ignored. */
|
|
3679
|
+
async?: boolean | null;
|
|
3680
|
+
}
|
|
3681
|
+
/**
|
|
3682
|
+
* A function's result for an earlier `function_call` with the same `call_id` in `input`. Images in `output` reach the model as a user message after the tool results.
|
|
3683
|
+
*/
|
|
3684
|
+
export interface ResponsesFunctionCallOutputItem {
|
|
3685
|
+
type: "function_call_output";
|
|
3686
|
+
call_id: string;
|
|
3687
|
+
output: string | Array<ResponsesInputText | ResponsesInputImage>;
|
|
3688
|
+
id?: string | null;
|
|
3689
|
+
status?: string | null;
|
|
3690
|
+
caller?: Record<string, unknown> | null;
|
|
3691
|
+
name?: string | null;
|
|
3692
|
+
namespace?: string | null;
|
|
3693
|
+
}
|
|
3694
|
+
export interface ResponsesReasoningText {
|
|
3695
|
+
type: "reasoning_text" | "summary_text";
|
|
3696
|
+
text: string;
|
|
3697
|
+
}
|
|
3698
|
+
/**
|
|
3699
|
+
* Reasoning from an earlier turn; its `content` (else its `summary`) goes back to the model with that turn. `encrypted_content` is accepted and ignored.
|
|
3700
|
+
*/
|
|
3701
|
+
export interface ResponsesReasoningInputItem {
|
|
3702
|
+
type: "reasoning";
|
|
3703
|
+
id?: string | null;
|
|
3704
|
+
summary?: ResponsesReasoningText[] | null;
|
|
3705
|
+
content?: ResponsesReasoningText[] | null;
|
|
3706
|
+
encrypted_content?: string | null;
|
|
3707
|
+
status?: string | null;
|
|
3708
|
+
}
|
|
3709
|
+
export type ResponsesInputItem = ResponsesInputMessage | ResponsesFunctionCallItem | ResponsesFunctionCallOutputItem | ResponsesReasoningInputItem;
|
|
3710
|
+
export interface ResponsesFunctionTool {
|
|
3711
|
+
type: "function";
|
|
3712
|
+
/** Unique within `tools`. */
|
|
3713
|
+
name: string;
|
|
3714
|
+
description?: string | null;
|
|
3715
|
+
/** A JSON Schema object (at most 64 KiB serialized and 32 levels deep); absent means no arguments. */
|
|
3716
|
+
parameters?: Record<string, unknown> | null;
|
|
3717
|
+
strict?: boolean | null;
|
|
3718
|
+
allowed_callers?: "direct"[] | null;
|
|
3719
|
+
defer_loading?: false | null;
|
|
3720
|
+
/** Accepted (a JSON Schema object) and ignored. */
|
|
3721
|
+
output_schema?: Record<string, unknown> | null;
|
|
3722
|
+
}
|
|
3723
|
+
export interface ResponsesTextFormat {
|
|
3724
|
+
type: "text" | "json_object" | "json_schema";
|
|
3725
|
+
/** Required with `json_schema`. */
|
|
3726
|
+
name?: string;
|
|
3727
|
+
/** `json_schema` only: the JSON Schema the answer matches (at most 64 KiB and 32 levels). */
|
|
3728
|
+
schema?: Record<string, unknown>;
|
|
3729
|
+
description?: string | null;
|
|
3730
|
+
strict?: boolean | null;
|
|
3731
|
+
}
|
|
3732
|
+
/**
|
|
3733
|
+
* OpenAI Responses parameters this node takes. Any other parameter is `400 unsupported_parameter` (`previous_response_id`, `conversation`, `prompt`, `top_logprobs` and `max_tool_calls` too, unless null); `null` means unset.
|
|
3734
|
+
*/
|
|
3735
|
+
export interface ResponsesRequest {
|
|
3736
|
+
model: string;
|
|
3737
|
+
input: string | ResponsesInputItem[];
|
|
3738
|
+
instructions?: string | null;
|
|
3739
|
+
max_output_tokens?: number | null;
|
|
3740
|
+
temperature?: number | null;
|
|
3741
|
+
/**
|
|
3742
|
+
* Nucleus sampling. `0` keeps only the most probable token (passed to the runtime as 1e-9, the same thing, since vLLM takes values above 0 only).
|
|
3743
|
+
*/
|
|
3744
|
+
top_p?: number | null;
|
|
3745
|
+
tools?: ResponsesFunctionTool[] | null;
|
|
3746
|
+
tool_choice?: null | "none" | "auto" | "required" | {
|
|
3747
|
+
type: "function";
|
|
3748
|
+
name: string;
|
|
3749
|
+
};
|
|
3750
|
+
parallel_tool_calls?: boolean | null;
|
|
3751
|
+
text?: {
|
|
3752
|
+
format?: null | ResponsesTextFormat;
|
|
3753
|
+
/** Accepted and ignored. */
|
|
3754
|
+
verbosity?: "low" | "medium" | "high" | null;
|
|
3755
|
+
} | null;
|
|
3756
|
+
reasoning?: {
|
|
3757
|
+
/** `low` and above turn the reasoning phase on; unset, `none` and `minimal` leave it off. */
|
|
3758
|
+
effort?: "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | null;
|
|
3759
|
+
/** Accepted and ignored. */
|
|
3760
|
+
summary?: "auto" | "concise" | "detailed" | null;
|
|
3761
|
+
/** Accepted and ignored. */
|
|
3762
|
+
generate_summary?: "auto" | "concise" | "detailed" | null;
|
|
3763
|
+
} | null;
|
|
3764
|
+
stream?: boolean | null;
|
|
3765
|
+
stream_options?: {
|
|
3766
|
+
/** Accepted and ignored. */
|
|
3767
|
+
include_obfuscation?: boolean | null;
|
|
3768
|
+
} | null;
|
|
3769
|
+
/** Accepted and ignored; nothing is stored. */
|
|
3770
|
+
store?: boolean | null;
|
|
3771
|
+
/** Echoed in the response. */
|
|
3772
|
+
metadata?: Record<string, string> | null;
|
|
3773
|
+
user?: string | null;
|
|
3774
|
+
safety_identifier?: string | null;
|
|
3775
|
+
prompt_cache_key?: string | null;
|
|
3776
|
+
service_tier?: string | null;
|
|
3777
|
+
/** `auto` is refused: the node never drops input items. */
|
|
3778
|
+
truncation?: "disabled" | null;
|
|
3779
|
+
background?: false | null;
|
|
3780
|
+
include?: "reasoning.encrypted_content"[] | null;
|
|
3781
|
+
/** Null only: responses are not stored; send the conversation as `input`. */
|
|
3782
|
+
previous_response_id?: null;
|
|
3783
|
+
/** Null only. */
|
|
3784
|
+
conversation?: null;
|
|
3785
|
+
/** Null only. */
|
|
3786
|
+
prompt?: null;
|
|
3787
|
+
/** Null only. */
|
|
3788
|
+
top_logprobs?: null;
|
|
3789
|
+
/** Null only. */
|
|
3790
|
+
max_tool_calls?: null;
|
|
3791
|
+
}
|
|
3792
|
+
export interface ResponsesOutputMessage {
|
|
3793
|
+
type: "message";
|
|
3794
|
+
id: string;
|
|
3795
|
+
status: "in_progress" | "completed" | "incomplete";
|
|
3796
|
+
role: "assistant";
|
|
3797
|
+
content: ResponsesOutputText[];
|
|
3798
|
+
}
|
|
3799
|
+
export interface ResponsesOutputReasoning {
|
|
3800
|
+
type: "reasoning";
|
|
3801
|
+
id: string;
|
|
3802
|
+
status?: "in_progress" | "completed" | "incomplete";
|
|
3803
|
+
summary: ResponsesReasoningText[];
|
|
3804
|
+
content?: ResponsesReasoningText[];
|
|
3805
|
+
}
|
|
3806
|
+
export interface ResponsesOutputFunctionCall {
|
|
3807
|
+
type: "function_call";
|
|
3808
|
+
id: string;
|
|
3809
|
+
status: "in_progress" | "completed" | "incomplete";
|
|
3810
|
+
call_id: string;
|
|
3811
|
+
name: string;
|
|
3812
|
+
arguments: string;
|
|
3813
|
+
}
|
|
3814
|
+
export type ResponsesOutputItem = ResponsesOutputMessage | ResponsesOutputReasoning | ResponsesOutputFunctionCall;
|
|
3815
|
+
export interface ResponsesUsage {
|
|
3816
|
+
input_tokens: number;
|
|
3817
|
+
input_tokens_details: {
|
|
3818
|
+
cached_tokens?: number;
|
|
3819
|
+
cache_write_tokens?: number;
|
|
3820
|
+
};
|
|
3821
|
+
output_tokens: number;
|
|
3822
|
+
output_tokens_details: {
|
|
3823
|
+
reasoning_tokens?: number;
|
|
3824
|
+
};
|
|
3825
|
+
total_tokens: number;
|
|
3826
|
+
}
|
|
3827
|
+
/**
|
|
3828
|
+
* A response. The request's parameters are echoed as OpenAI does (`instructions`, `tools`, `tool_choice`, `text`, `reasoning`, `metadata` and the sampling parameters); `store` is always false. `status` is `incomplete`, with `incomplete_details.reason` `max_output_tokens`, when the output hit that limit.
|
|
3829
|
+
*/
|
|
3830
|
+
export interface ResponsesResponse {
|
|
3831
|
+
id: string;
|
|
3832
|
+
object: "response";
|
|
3833
|
+
created_at: number;
|
|
3834
|
+
completed_at?: number;
|
|
3835
|
+
status: "in_progress" | "completed" | "incomplete" | "failed";
|
|
3836
|
+
background?: boolean;
|
|
3837
|
+
error?: Record<string, unknown> | null;
|
|
3838
|
+
incomplete_details?: {
|
|
3839
|
+
reason?: string;
|
|
3840
|
+
} | null;
|
|
3841
|
+
instructions?: string | null;
|
|
3842
|
+
max_output_tokens?: number | null;
|
|
3843
|
+
model: string;
|
|
3844
|
+
output: ResponsesOutputItem[];
|
|
3845
|
+
parallel_tool_calls?: boolean;
|
|
3846
|
+
previous_response_id?: null;
|
|
3847
|
+
reasoning?: Record<string, unknown>;
|
|
3848
|
+
store?: false;
|
|
3849
|
+
temperature?: number | null;
|
|
3850
|
+
text?: Record<string, unknown>;
|
|
3851
|
+
tool_choice?: unknown;
|
|
3852
|
+
tools?: Record<string, unknown>[];
|
|
3853
|
+
top_p?: number | null;
|
|
3854
|
+
truncation?: string;
|
|
3855
|
+
metadata?: Record<string, unknown>;
|
|
3856
|
+
usage?: null | ResponsesUsage;
|
|
3857
|
+
b3os?: InferMeta;
|
|
3858
|
+
}
|
|
3859
|
+
/**
|
|
3860
|
+
* One event of a stream, named by its `type` (the SSE `event:` field carries the same name) and numbered by
|
|
3861
|
+
* `sequence_number`: `response.created` and `response.in_progress` (`response`, without output), then per
|
|
3862
|
+
* output item `response.output_item.added`, its content (`response.content_part.added`,
|
|
3863
|
+
* `response.output_text.delta`/`done` or `response.reasoning_text.delta`/`done`,
|
|
3864
|
+
* `response.content_part.done`; or `response.function_call_arguments.delta`/`done`) and
|
|
3865
|
+
* `response.output_item.done`, and last `response.completed` or `response.incomplete` (the whole response,
|
|
3866
|
+
* with the `b3os` metadata), or `error` (`code`, `message`).
|
|
3867
|
+
*/
|
|
3868
|
+
export interface ResponsesStreamEvent {
|
|
3869
|
+
type: "response.created" | "response.in_progress" | "response.output_item.added" | "response.content_part.added" | "response.output_text.delta" | "response.output_text.done" | "response.reasoning_text.delta" | "response.reasoning_text.done" | "response.function_call_arguments.delta" | "response.function_call_arguments.done" | "response.content_part.done" | "response.output_item.done" | "response.completed" | "response.incomplete" | "error";
|
|
3870
|
+
sequence_number: number;
|
|
3871
|
+
response?: ResponsesResponse;
|
|
3872
|
+
output_index?: number;
|
|
3873
|
+
item?: ResponsesOutputItem;
|
|
3874
|
+
item_id?: string;
|
|
3875
|
+
content_index?: number;
|
|
3876
|
+
part?: Record<string, unknown>;
|
|
3877
|
+
delta?: string;
|
|
3878
|
+
text?: string;
|
|
3879
|
+
logprobs?: unknown[];
|
|
3880
|
+
arguments?: string;
|
|
3881
|
+
name?: string;
|
|
3882
|
+
code?: string | null;
|
|
3883
|
+
message?: string;
|
|
3884
|
+
param?: string | null;
|
|
3885
|
+
}
|
|
3886
|
+
export interface WebhookSecretRequest {
|
|
3887
|
+
url: string;
|
|
3888
|
+
}
|
|
3889
|
+
export interface WebhookRotateRequest {
|
|
3890
|
+
url: string;
|
|
3891
|
+
/** @default 86400 */
|
|
3892
|
+
grace_s?: number;
|
|
3893
|
+
}
|
|
3894
|
+
export interface WebhookSecret {
|
|
3895
|
+
object: "webhook_secret";
|
|
3896
|
+
/** The normalized endpoint URL. */
|
|
3897
|
+
url: string;
|
|
3898
|
+
secret: string;
|
|
3899
|
+
/** Until when the previous secret still signs deliveries, after a rotation. */
|
|
3900
|
+
previous_valid_until: string | null;
|
|
3901
|
+
created_at: string;
|
|
3902
|
+
}
|
|
3903
|
+
export type DeliveryStatus = "pending" | "retrying" | "succeeded" | "failed";
|
|
3904
|
+
export interface WebhookDelivery {
|
|
3905
|
+
/** The event ID, the same as in the delivered body. */
|
|
3906
|
+
id: string;
|
|
3907
|
+
object: "webhook_delivery";
|
|
3908
|
+
url: string;
|
|
3909
|
+
type: string;
|
|
3910
|
+
job_id: string | null;
|
|
3911
|
+
status: DeliveryStatus;
|
|
3912
|
+
attempts: number;
|
|
3913
|
+
last_status_code: number | null;
|
|
3914
|
+
last_error: string | null;
|
|
3915
|
+
next_attempt_at: string | null;
|
|
3916
|
+
created_at: string;
|
|
3917
|
+
updated_at: string;
|
|
3918
|
+
}
|
|
3919
|
+
export type WebhookDeliveryList = Omit<ListEnvelope, "data"> & {
|
|
3920
|
+
data: WebhookDelivery[];
|
|
3921
|
+
};
|
|
3922
|
+
export interface ApiKeyCreateRequest {
|
|
3923
|
+
name: string;
|
|
3924
|
+
scopes: Scope[];
|
|
3925
|
+
/** Defaults to the caller's project. */
|
|
3926
|
+
project_id?: string;
|
|
3927
|
+
spend_cap_usd?: number | null;
|
|
3928
|
+
expires_at?: string | null;
|
|
3929
|
+
metadata?: Metadata;
|
|
3930
|
+
}
|
|
3931
|
+
export interface ApiKeyUpdateRequest {
|
|
3932
|
+
name?: string;
|
|
3933
|
+
spend_cap_usd?: number | null;
|
|
3934
|
+
expires_at?: string | null;
|
|
3935
|
+
metadata?: Metadata;
|
|
3936
|
+
}
|
|
3937
|
+
export interface Actor {
|
|
3938
|
+
type: "user" | "api_key";
|
|
3939
|
+
id: string;
|
|
3940
|
+
}
|
|
3941
|
+
export interface ApiKeyFields {
|
|
3942
|
+
id: string;
|
|
3943
|
+
object: "api_key";
|
|
3944
|
+
/**
|
|
3945
|
+
* `api_key` (`b3os_sk_…`, made with `POST /v1/keys`) or `cli_token` (`b3os_pat_…`, from the device login; `created_by` is the user who approved it).
|
|
3946
|
+
*/
|
|
3947
|
+
kind: "api_key" | "cli_token";
|
|
3948
|
+
/** The device-login client a CLI token was issued to (`b3os-cli`); null for API keys. */
|
|
3949
|
+
client_id: string | null;
|
|
3950
|
+
name: string;
|
|
3951
|
+
/** The start and end of the secret, for recognizing it. */
|
|
3952
|
+
redacted: string;
|
|
3953
|
+
org_id: string;
|
|
3954
|
+
project_id: string;
|
|
3955
|
+
scopes: Scope[];
|
|
3956
|
+
spend_cap_usd: number | null;
|
|
3957
|
+
/** Spend in the current billing period. */
|
|
3958
|
+
spent_usd: number;
|
|
3959
|
+
status: "active" | "revoked" | "expired";
|
|
3960
|
+
expires_at: string | null;
|
|
3961
|
+
created_at: string;
|
|
3962
|
+
created_by: Actor;
|
|
3963
|
+
last_used_at: string | null;
|
|
3964
|
+
revoked_at: string | null;
|
|
3965
|
+
metadata: Metadata;
|
|
3966
|
+
}
|
|
3967
|
+
export type ApiKey = ApiKeyFields;
|
|
3968
|
+
/** A new key, with its secret (returned only once). */
|
|
3969
|
+
export type ApiKeyWithSecret = ApiKeyFields & {
|
|
3970
|
+
secret: string;
|
|
3971
|
+
};
|
|
3972
|
+
export type ApiKeyList = Omit<ListEnvelope, "data"> & {
|
|
3973
|
+
data: ApiKey[];
|
|
3974
|
+
};
|
|
3975
|
+
export interface UserSummary {
|
|
3976
|
+
id: string;
|
|
3977
|
+
email: string;
|
|
3978
|
+
name: string | null;
|
|
3979
|
+
image_url: string | null;
|
|
3980
|
+
}
|
|
3981
|
+
export interface CurrentPrincipal {
|
|
3982
|
+
object: "principal";
|
|
3983
|
+
kind: "api_key" | "cli_token" | "session" | "sandbox";
|
|
3984
|
+
key_id: string | null;
|
|
3985
|
+
user: null | UserSummary;
|
|
3986
|
+
/** For calls from inside a sandbox. */
|
|
3987
|
+
sandbox_id?: string | null;
|
|
3988
|
+
org_id: string;
|
|
3989
|
+
project_id: string;
|
|
3990
|
+
scopes: Scope[];
|
|
3991
|
+
spend_cap_usd: number | null;
|
|
3992
|
+
expires_at: string | null;
|
|
3993
|
+
}
|
|
3994
|
+
export interface UsageSummary {
|
|
3995
|
+
object: "usage_summary";
|
|
3996
|
+
start: string;
|
|
3997
|
+
end: string;
|
|
3998
|
+
group_by: Array<"product" | "unit" | "key" | "project" | "day">;
|
|
3999
|
+
rows: {
|
|
4000
|
+
product: string;
|
|
4001
|
+
unit: string;
|
|
4002
|
+
qty: number;
|
|
4003
|
+
key_id?: string;
|
|
4004
|
+
project_id?: string;
|
|
4005
|
+
day?: string;
|
|
4006
|
+
}[];
|
|
4007
|
+
}
|
|
4008
|
+
export interface UsageRecord {
|
|
4009
|
+
id: string;
|
|
4010
|
+
object: "usage_record";
|
|
4011
|
+
ts: string;
|
|
4012
|
+
org_id: string;
|
|
4013
|
+
project_id: string;
|
|
4014
|
+
key_id: string | null;
|
|
4015
|
+
/** Set when a sandbox's own API calls caused the usage. */
|
|
4016
|
+
sandbox_id: string | null;
|
|
4017
|
+
node: string;
|
|
4018
|
+
product: string;
|
|
4019
|
+
unit: string;
|
|
4020
|
+
qty: number;
|
|
4021
|
+
request_id: string | null;
|
|
4022
|
+
/** Unit-specific detail, such as the tier that served a page. */
|
|
4023
|
+
meta: Record<string, unknown>;
|
|
4024
|
+
}
|
|
4025
|
+
export type UsageRecordList = Omit<ListEnvelope, "data"> & {
|
|
4026
|
+
data: UsageRecord[];
|
|
4027
|
+
};
|
|
4028
|
+
export interface LimitItem {
|
|
4029
|
+
/** Limit ID, also used in the `limit` member of problems. */
|
|
4030
|
+
id: string;
|
|
4031
|
+
product: string;
|
|
4032
|
+
kind: "concurrency" | "rate" | "quota" | "size" | "duration";
|
|
4033
|
+
limit: number | null;
|
|
4034
|
+
unit: string;
|
|
4035
|
+
window_s?: number;
|
|
4036
|
+
current?: number;
|
|
4037
|
+
/** Seconds until the window or quota resets. */
|
|
4038
|
+
reset_s?: number;
|
|
4039
|
+
}
|
|
4040
|
+
export interface Limits {
|
|
4041
|
+
object: "limits";
|
|
4042
|
+
org_id: string;
|
|
4043
|
+
project_id: string;
|
|
4044
|
+
key_id: string | null;
|
|
4045
|
+
spend: {
|
|
4046
|
+
cap_usd: number | null;
|
|
4047
|
+
used_usd: number;
|
|
4048
|
+
period_start: string;
|
|
4049
|
+
period_end: string;
|
|
4050
|
+
};
|
|
4051
|
+
items: LimitItem[];
|
|
4052
|
+
}
|
|
4053
|
+
export interface Organization {
|
|
4054
|
+
id: string;
|
|
4055
|
+
object: "organization";
|
|
4056
|
+
name: string;
|
|
4057
|
+
slug: string;
|
|
4058
|
+
/** The caller's role; `null` for API keys. */
|
|
4059
|
+
role: "owner" | "admin" | "member" | null;
|
|
4060
|
+
plan: "beta";
|
|
4061
|
+
created_at: string;
|
|
4062
|
+
metadata: Metadata;
|
|
4063
|
+
}
|
|
4064
|
+
export type OrganizationList = Omit<ListEnvelope, "data"> & {
|
|
4065
|
+
data: Organization[];
|
|
4066
|
+
};
|
|
4067
|
+
export interface Member {
|
|
4068
|
+
object: "member";
|
|
4069
|
+
user: UserSummary;
|
|
4070
|
+
role: "owner" | "admin" | "member";
|
|
4071
|
+
joined_at: string;
|
|
4072
|
+
}
|
|
4073
|
+
export type MemberList = Omit<ListEnvelope, "data"> & {
|
|
4074
|
+
data: Member[];
|
|
4075
|
+
};
|
|
4076
|
+
export interface Project {
|
|
4077
|
+
id: string;
|
|
4078
|
+
object: "project";
|
|
4079
|
+
org_id: string;
|
|
4080
|
+
name: string;
|
|
4081
|
+
created_at: string;
|
|
4082
|
+
updated_at: string;
|
|
4083
|
+
metadata: Metadata;
|
|
4084
|
+
}
|
|
4085
|
+
export type ProjectList = Omit<ListEnvelope, "data"> & {
|
|
4086
|
+
data: Project[];
|
|
4087
|
+
};
|
|
4088
|
+
export interface ProjectCreateRequest {
|
|
4089
|
+
name: string;
|
|
4090
|
+
metadata?: Metadata;
|
|
4091
|
+
}
|
|
4092
|
+
export interface ProjectUpdateRequest {
|
|
4093
|
+
name?: string;
|
|
4094
|
+
metadata?: Metadata;
|
|
4095
|
+
}
|
|
4096
|
+
export interface RegistryPublisher {
|
|
4097
|
+
id: string;
|
|
4098
|
+
name: string;
|
|
4099
|
+
verified: boolean;
|
|
4100
|
+
}
|
|
4101
|
+
export interface RegistryPack {
|
|
4102
|
+
id: string;
|
|
4103
|
+
object: "registry_pack";
|
|
4104
|
+
publisher: RegistryPublisher;
|
|
4105
|
+
latest_version: string;
|
|
4106
|
+
versions: string[];
|
|
4107
|
+
created_at: string;
|
|
4108
|
+
updated_at: string;
|
|
4109
|
+
}
|
|
4110
|
+
export type RegistryPackList = Omit<ListEnvelope, "data"> & {
|
|
4111
|
+
data: RegistryPack[];
|
|
4112
|
+
};
|
|
4113
|
+
export interface RegistryPackVersion {
|
|
4114
|
+
object: "registry_pack_version";
|
|
4115
|
+
pack: string;
|
|
4116
|
+
version: string;
|
|
4117
|
+
content_hash: string;
|
|
4118
|
+
signature: {
|
|
4119
|
+
alg: "ed25519";
|
|
4120
|
+
kid: string;
|
|
4121
|
+
sig: string;
|
|
4122
|
+
};
|
|
4123
|
+
publisher: RegistryPublisher;
|
|
4124
|
+
size_bytes: number;
|
|
4125
|
+
published_at: string;
|
|
4126
|
+
yanked: boolean;
|
|
4127
|
+
download_url: string;
|
|
4128
|
+
}
|
|
4129
|
+
/**
|
|
4130
|
+
* How the request reached B3OS: `edge` (through beta-api.b3os.org or the dashboard; forwarded to the node, or
|
|
4131
|
+
* answered by the edge itself), `uds` (the node's Unix socket), `tcp` (the node's loopback TCP listener) or
|
|
4132
|
+
* `sandbox` (from inside a sandbox, over vsock).
|
|
4133
|
+
*/
|
|
4134
|
+
export type RequestConnection = "edge" | "uds" | "tcp" | "sandbox";
|
|
4135
|
+
export interface RequestPhase {
|
|
4136
|
+
name: string;
|
|
4137
|
+
source: "edge" | "node";
|
|
4138
|
+
duration_ms: number;
|
|
4139
|
+
}
|
|
4140
|
+
export interface RequestRecord {
|
|
4141
|
+
id: string;
|
|
4142
|
+
object: "request";
|
|
4143
|
+
method: string;
|
|
4144
|
+
/** The path without the query string. */
|
|
4145
|
+
path: string;
|
|
4146
|
+
operation_id: string | null;
|
|
4147
|
+
product: string | null;
|
|
4148
|
+
status_code: number;
|
|
4149
|
+
error_code: string | null;
|
|
4150
|
+
org_id: string;
|
|
4151
|
+
project_id: string;
|
|
4152
|
+
/** The API key behind the request (for sandbox calls, the key that created the sandbox). */
|
|
4153
|
+
key_id: string | null;
|
|
4154
|
+
/** The node that served it; `null` for a request the edge answered itself. */
|
|
4155
|
+
node: string | null;
|
|
4156
|
+
connection: RequestConnection;
|
|
4157
|
+
/** The calling sandbox, for `sandbox` connections; otherwise `null`. */
|
|
4158
|
+
sandbox_id: string | null;
|
|
4159
|
+
started_at: string;
|
|
4160
|
+
/**
|
|
4161
|
+
* From the first request byte read to the last response byte written, measured on the node (at the edge for
|
|
4162
|
+
* a request the edge answered itself); for streams, until the stream ended.
|
|
4163
|
+
*/
|
|
4164
|
+
duration_ms: number;
|
|
4165
|
+
request_bytes: number;
|
|
4166
|
+
response_bytes: number;
|
|
4167
|
+
/** The node's phases (`source: node`) and the edge's `edge_*` phases (`source: edge`), in order. */
|
|
4168
|
+
phases: RequestPhase[];
|
|
4169
|
+
/** The W3C trace ID from `traceparent`, when sent. */
|
|
4170
|
+
trace_id: string | null;
|
|
4171
|
+
user_agent: string | null;
|
|
4172
|
+
}
|
|
4173
|
+
export type RequestRecordList = Omit<ListEnvelope, "data"> & {
|
|
4174
|
+
data: RequestRecord[];
|
|
4175
|
+
};
|
|
4176
|
+
/** Parameters of `listBatches`. */
|
|
4177
|
+
export interface VisionListBatchesParams {
|
|
4178
|
+
/**
|
|
4179
|
+
* Page size, from 1 to 100.
|
|
4180
|
+
* @default 20
|
|
4181
|
+
*/
|
|
4182
|
+
limit?: number;
|
|
4183
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
4184
|
+
cursor?: string;
|
|
4185
|
+
/** Only jobs with this status. */
|
|
4186
|
+
status?: JobStatus;
|
|
4187
|
+
}
|
|
4188
|
+
/** Parameters of `listBatchPages`. */
|
|
4189
|
+
export interface VisionListBatchPagesParams {
|
|
4190
|
+
/**
|
|
4191
|
+
* Page size, from 1 to 100.
|
|
4192
|
+
* @default 20
|
|
4193
|
+
*/
|
|
4194
|
+
limit?: number;
|
|
4195
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
4196
|
+
cursor?: string;
|
|
4197
|
+
/** Only pages that succeeded, or only pages that failed. */
|
|
4198
|
+
status?: "succeeded" | "failed";
|
|
4199
|
+
}
|
|
4200
|
+
/** Parameters of `listCrawls`. */
|
|
4201
|
+
export interface VisionListCrawlsParams {
|
|
4202
|
+
/**
|
|
4203
|
+
* Page size, from 1 to 100.
|
|
4204
|
+
* @default 20
|
|
4205
|
+
*/
|
|
4206
|
+
limit?: number;
|
|
4207
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
4208
|
+
cursor?: string;
|
|
4209
|
+
/** Only jobs with this status. */
|
|
4210
|
+
status?: JobStatus;
|
|
4211
|
+
}
|
|
4212
|
+
/** Parameters of `listCrawlPages`. */
|
|
4213
|
+
export interface VisionListCrawlPagesParams {
|
|
4214
|
+
/**
|
|
4215
|
+
* Page size, from 1 to 100.
|
|
4216
|
+
* @default 20
|
|
4217
|
+
*/
|
|
4218
|
+
limit?: number;
|
|
4219
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
4220
|
+
cursor?: string;
|
|
4221
|
+
/** Only pages that succeeded, or only pages that failed. */
|
|
4222
|
+
status?: "succeeded" | "failed";
|
|
4223
|
+
}
|
|
4224
|
+
/** Parameters of `listProfiles`. */
|
|
4225
|
+
export interface VisionListProfilesParams {
|
|
4226
|
+
/**
|
|
4227
|
+
* Page size, from 1 to 100.
|
|
4228
|
+
* @default 20
|
|
4229
|
+
*/
|
|
4230
|
+
limit?: number;
|
|
4231
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
4232
|
+
cursor?: string;
|
|
4233
|
+
}
|
|
4234
|
+
/** Parameters of `readUrl` (header parameters are sent as their `X-B3OS-*` headers). */
|
|
4235
|
+
export interface VisionReadUrlParams {
|
|
4236
|
+
/**
|
|
4237
|
+
* Response format.
|
|
4238
|
+
* @default "markdown"
|
|
4239
|
+
*/
|
|
4240
|
+
format?: "markdown" | "html" | "text" | "json";
|
|
4241
|
+
/** Which tier may serve the page (see `engine` on scrape). */
|
|
4242
|
+
engine?: ScrapeEngine;
|
|
4243
|
+
/**
|
|
4244
|
+
* Timeout in milliseconds, 1000 to 60000.
|
|
4245
|
+
* @default 30000
|
|
4246
|
+
*/
|
|
4247
|
+
timeout_ms?: number;
|
|
4248
|
+
/**
|
|
4249
|
+
* Accept a cached copy up to this old; `0` bypasses the cache.
|
|
4250
|
+
* @default 172800000
|
|
4251
|
+
*/
|
|
4252
|
+
max_age_ms?: number;
|
|
4253
|
+
/**
|
|
4254
|
+
* `false` keeps headers, navigation and footers.
|
|
4255
|
+
* @default true
|
|
4256
|
+
*/
|
|
4257
|
+
only_main_content?: boolean;
|
|
4258
|
+
/**
|
|
4259
|
+
* Extra wait after the page is ready, in milliseconds.
|
|
4260
|
+
* @default 0
|
|
4261
|
+
*/
|
|
4262
|
+
wait_for_ms?: number;
|
|
4263
|
+
}
|
|
4264
|
+
/** Parameters of `listSessions`. */
|
|
4265
|
+
export interface VisionListSessionsParams {
|
|
4266
|
+
/**
|
|
4267
|
+
* Page size, from 1 to 100.
|
|
4268
|
+
* @default 20
|
|
4269
|
+
*/
|
|
4270
|
+
limit?: number;
|
|
4271
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
4272
|
+
cursor?: string;
|
|
4273
|
+
/** Only sessions with this status. */
|
|
4274
|
+
status?: SessionStatus;
|
|
4275
|
+
}
|
|
4276
|
+
/** Parameters of `listPresets`. */
|
|
4277
|
+
export interface RenderListPresetsParams {
|
|
4278
|
+
/** Only presets of this kind. */
|
|
4279
|
+
kind?: PresetKind;
|
|
4280
|
+
}
|
|
4281
|
+
/** Parameters of `listScreenshots`. */
|
|
4282
|
+
export interface RenderListScreenshotsParams {
|
|
4283
|
+
/**
|
|
4284
|
+
* Page size, from 1 to 100.
|
|
4285
|
+
* @default 20
|
|
4286
|
+
*/
|
|
4287
|
+
limit?: number;
|
|
4288
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
4289
|
+
cursor?: string;
|
|
4290
|
+
}
|
|
4291
|
+
/** Parameters of `listVideos`. */
|
|
4292
|
+
export interface RenderListVideosParams {
|
|
4293
|
+
/**
|
|
4294
|
+
* Page size, from 1 to 100.
|
|
4295
|
+
* @default 20
|
|
4296
|
+
*/
|
|
4297
|
+
limit?: number;
|
|
4298
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
4299
|
+
cursor?: string;
|
|
4300
|
+
/** Only videos with this status. */
|
|
4301
|
+
status?: JobStatus;
|
|
4302
|
+
}
|
|
4303
|
+
/** Parameters of `getVideoTimeline`. */
|
|
4304
|
+
export interface RenderGetVideoTimelineParams {
|
|
4305
|
+
/**
|
|
4306
|
+
* Include the per-output-frame state.
|
|
4307
|
+
* @default false
|
|
4308
|
+
*/
|
|
4309
|
+
frames?: boolean;
|
|
4310
|
+
}
|
|
4311
|
+
/** Parameters of `listSandboxes`. */
|
|
4312
|
+
export interface SandboxesListSandboxesParams {
|
|
4313
|
+
/**
|
|
4314
|
+
* Page size, from 1 to 100.
|
|
4315
|
+
* @default 20
|
|
4316
|
+
*/
|
|
4317
|
+
limit?: number;
|
|
4318
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
4319
|
+
cursor?: string;
|
|
4320
|
+
/** Only sandboxes with this status. */
|
|
4321
|
+
status?: SandboxStatus;
|
|
4322
|
+
}
|
|
4323
|
+
/** Parameters of `listSnapshots`. */
|
|
4324
|
+
export interface SandboxesListSnapshotsParams {
|
|
4325
|
+
/**
|
|
4326
|
+
* Page size, from 1 to 100.
|
|
4327
|
+
* @default 20
|
|
4328
|
+
*/
|
|
4329
|
+
limit?: number;
|
|
4330
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
4331
|
+
cursor?: string;
|
|
4332
|
+
}
|
|
4333
|
+
/** Parameters of `readFile`. */
|
|
4334
|
+
export interface SandboxesReadFileParams {
|
|
4335
|
+
/** Absolute path inside the sandbox. */
|
|
4336
|
+
path: string;
|
|
4337
|
+
/**
|
|
4338
|
+
* `1` lists the directory instead of reading a file.
|
|
4339
|
+
* @default 0
|
|
4340
|
+
*/
|
|
4341
|
+
list?: 0 | 1;
|
|
4342
|
+
}
|
|
4343
|
+
/** Parameters of `writeFile`. */
|
|
4344
|
+
export interface SandboxesWriteFileParams {
|
|
4345
|
+
/** Absolute path inside the sandbox. */
|
|
4346
|
+
path: string;
|
|
4347
|
+
/**
|
|
4348
|
+
* Octal file mode for a new file.
|
|
4349
|
+
* @default "0644"
|
|
4350
|
+
*/
|
|
4351
|
+
mode?: string;
|
|
4352
|
+
/**
|
|
4353
|
+
* `1` creates missing parent directories.
|
|
4354
|
+
* @default 0
|
|
4355
|
+
*/
|
|
4356
|
+
mkdir?: 0 | 1;
|
|
4357
|
+
}
|
|
4358
|
+
/** Parameters of `streamLogs`. */
|
|
4359
|
+
export interface SandboxesStreamLogsParams {
|
|
4360
|
+
/** Only this process. */
|
|
4361
|
+
pid?: number;
|
|
4362
|
+
/**
|
|
4363
|
+
* Keep the stream open for new output.
|
|
4364
|
+
* @default true
|
|
4365
|
+
*/
|
|
4366
|
+
follow?: boolean;
|
|
4367
|
+
}
|
|
4368
|
+
/** Parameters of `openPty`. */
|
|
4369
|
+
export interface SandboxesOpenPtyParams {
|
|
4370
|
+
/** @default 80 */
|
|
4371
|
+
cols?: number;
|
|
4372
|
+
/** @default 24 */
|
|
4373
|
+
rows?: number;
|
|
4374
|
+
/** Command to run instead of the login shell. */
|
|
4375
|
+
cmd?: string;
|
|
4376
|
+
cwd?: string;
|
|
4377
|
+
}
|
|
4378
|
+
/** Parameters of `listRoutines`. */
|
|
4379
|
+
export interface RoutinesListRoutinesParams {
|
|
4380
|
+
/**
|
|
4381
|
+
* Page size, from 1 to 100.
|
|
4382
|
+
* @default 20
|
|
4383
|
+
*/
|
|
4384
|
+
limit?: number;
|
|
4385
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
4386
|
+
cursor?: string;
|
|
4387
|
+
}
|
|
4388
|
+
/** Parameters of `listRunSteps`. */
|
|
4389
|
+
export interface RoutinesListRunStepsParams {
|
|
4390
|
+
/**
|
|
4391
|
+
* Page size, from 1 to 100.
|
|
4392
|
+
* @default 20
|
|
4393
|
+
*/
|
|
4394
|
+
limit?: number;
|
|
4395
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
4396
|
+
cursor?: string;
|
|
4397
|
+
}
|
|
4398
|
+
/** Parameters of `listRuns`. */
|
|
4399
|
+
export interface RoutinesListRunsParams {
|
|
4400
|
+
/**
|
|
4401
|
+
* Page size, from 1 to 100.
|
|
4402
|
+
* @default 20
|
|
4403
|
+
*/
|
|
4404
|
+
limit?: number;
|
|
4405
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
4406
|
+
cursor?: string;
|
|
4407
|
+
/** Only runs with this status. */
|
|
4408
|
+
status?: JobStatus;
|
|
4409
|
+
}
|
|
4410
|
+
/** Parameters of `listVersions`. */
|
|
4411
|
+
export interface RoutinesListVersionsParams {
|
|
4412
|
+
/**
|
|
4413
|
+
* Page size, from 1 to 100.
|
|
4414
|
+
* @default 20
|
|
4415
|
+
*/
|
|
4416
|
+
limit?: number;
|
|
4417
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
4418
|
+
cursor?: string;
|
|
4419
|
+
}
|
|
4420
|
+
/** Parameters of `describe`. */
|
|
4421
|
+
export interface ActionsDescribeParams {
|
|
4422
|
+
/** `<namespace>/<name>/<action>@<version>`; the version may be exact (`1.2.0`) or a major (`1`). */
|
|
4423
|
+
ref: ActionRef;
|
|
4424
|
+
}
|
|
4425
|
+
/** Parameters of `listPacks`. */
|
|
4426
|
+
export interface ActionsListPacksParams {
|
|
4427
|
+
/** Words to search for in pack titles and descriptions. */
|
|
4428
|
+
q?: string;
|
|
4429
|
+
/**
|
|
4430
|
+
* Page size, from 1 to 100.
|
|
4431
|
+
* @default 20
|
|
4432
|
+
*/
|
|
4433
|
+
limit?: number;
|
|
4434
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
4435
|
+
cursor?: string;
|
|
4436
|
+
}
|
|
4437
|
+
/** Parameters of `getPack`. */
|
|
4438
|
+
export interface ActionsGetPackParams {
|
|
4439
|
+
/** An exact version or a range such as `1` or `^1.2`. */
|
|
4440
|
+
version?: string;
|
|
4441
|
+
}
|
|
4442
|
+
/** Parameters of `listRegistryPacks`. */
|
|
4443
|
+
export interface PlatformListRegistryPacksParams {
|
|
4444
|
+
/**
|
|
4445
|
+
* Page size, from 1 to 100.
|
|
4446
|
+
* @default 20
|
|
4447
|
+
*/
|
|
4448
|
+
limit?: number;
|
|
4449
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
4450
|
+
cursor?: string;
|
|
4451
|
+
/** Only packs with a version published after this time. */
|
|
4452
|
+
updated_since?: string;
|
|
4453
|
+
}
|
|
4454
|
+
/** Parameters of `search`. */
|
|
4455
|
+
export interface ActionsSearchParams {
|
|
4456
|
+
/** What the action should do, in words. */
|
|
4457
|
+
q: string;
|
|
4458
|
+
/** Only actions of this pack (`io.b3os/github`). */
|
|
4459
|
+
pack?: string;
|
|
4460
|
+
/** Only actions with this effect class. */
|
|
4461
|
+
effects?: EffectClass;
|
|
4462
|
+
/**
|
|
4463
|
+
* Results to return, from 1 to 50.
|
|
4464
|
+
* @default 10
|
|
4465
|
+
*/
|
|
4466
|
+
limit?: number;
|
|
4467
|
+
}
|
|
4468
|
+
/** Parameters of `listSubscriptions`. */
|
|
4469
|
+
export interface ActionsListSubscriptionsParams {
|
|
4470
|
+
/** Only subscriptions of this routine (`rtn_…`). */
|
|
4471
|
+
routine_id?: string;
|
|
4472
|
+
/** Only subscriptions to triggers of this pack (`io.b3os/stripe`). */
|
|
4473
|
+
pack?: string;
|
|
4474
|
+
/**
|
|
4475
|
+
* Page size, from 1 to 100.
|
|
4476
|
+
* @default 20
|
|
4477
|
+
*/
|
|
4478
|
+
limit?: number;
|
|
4479
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
4480
|
+
cursor?: string;
|
|
4481
|
+
}
|
|
4482
|
+
/** Parameters of `listTriggers`. */
|
|
4483
|
+
export interface ActionsListTriggersParams {
|
|
4484
|
+
/** Words to search for. */
|
|
4485
|
+
q?: string;
|
|
4486
|
+
/** Only triggers of this pack. */
|
|
4487
|
+
pack?: string;
|
|
4488
|
+
kind?: "webhook" | "poll" | "schedule";
|
|
4489
|
+
/**
|
|
4490
|
+
* Page size, from 1 to 100.
|
|
4491
|
+
* @default 20
|
|
4492
|
+
*/
|
|
4493
|
+
limit?: number;
|
|
4494
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
4495
|
+
cursor?: string;
|
|
4496
|
+
}
|
|
4497
|
+
/** Parameters of `listConnections`. */
|
|
4498
|
+
export interface VaultListConnectionsParams {
|
|
4499
|
+
/**
|
|
4500
|
+
* Page size, from 1 to 100.
|
|
4501
|
+
* @default 20
|
|
4502
|
+
*/
|
|
4503
|
+
limit?: number;
|
|
4504
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
4505
|
+
cursor?: string;
|
|
4506
|
+
/** Only connections for this pack. */
|
|
4507
|
+
pack?: string;
|
|
4508
|
+
/** Only connections of this end user. */
|
|
4509
|
+
subject?: string;
|
|
4510
|
+
}
|
|
4511
|
+
/** Parameters of `listVoices`. */
|
|
4512
|
+
export interface InferListVoicesParams {
|
|
4513
|
+
/** Only voices of this model. */
|
|
4514
|
+
model?: string;
|
|
4515
|
+
}
|
|
4516
|
+
/** Parameters of `listKeys`. */
|
|
4517
|
+
export interface PlatformListKeysParams {
|
|
4518
|
+
/**
|
|
4519
|
+
* Page size, from 1 to 100.
|
|
4520
|
+
* @default 20
|
|
4521
|
+
*/
|
|
4522
|
+
limit?: number;
|
|
4523
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
4524
|
+
cursor?: string;
|
|
4525
|
+
/** Only keys of this project. */
|
|
4526
|
+
project_id?: string;
|
|
4527
|
+
status?: "active" | "revoked" | "expired";
|
|
4528
|
+
/** Only API keys or only CLI tokens. */
|
|
4529
|
+
kind?: "api_key" | "cli_token";
|
|
4530
|
+
}
|
|
4531
|
+
/** Parameters of `getUsage`. */
|
|
4532
|
+
export interface PlatformGetUsageParams {
|
|
4533
|
+
start?: string;
|
|
4534
|
+
end?: string;
|
|
4535
|
+
/**
|
|
4536
|
+
* Comma-separated dimensions.
|
|
4537
|
+
* @default "product,unit"
|
|
4538
|
+
*/
|
|
4539
|
+
group_by?: string;
|
|
4540
|
+
/** Only this project. */
|
|
4541
|
+
project_id?: string;
|
|
4542
|
+
}
|
|
4543
|
+
/** Parameters of `listUsageRecords`. */
|
|
4544
|
+
export interface PlatformListUsageRecordsParams {
|
|
4545
|
+
/**
|
|
4546
|
+
* Page size, from 1 to 100.
|
|
4547
|
+
* @default 20
|
|
4548
|
+
*/
|
|
4549
|
+
limit?: number;
|
|
4550
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
4551
|
+
cursor?: string;
|
|
4552
|
+
start?: string;
|
|
4553
|
+
end?: string;
|
|
4554
|
+
product?: string;
|
|
4555
|
+
unit?: string;
|
|
4556
|
+
key_id?: string;
|
|
4557
|
+
request_id?: string;
|
|
4558
|
+
}
|
|
4559
|
+
/** Parameters of `listRequests`. */
|
|
4560
|
+
export interface PlatformListRequestsParams {
|
|
4561
|
+
/**
|
|
4562
|
+
* Page size, from 1 to 100.
|
|
4563
|
+
* @default 20
|
|
4564
|
+
*/
|
|
4565
|
+
limit?: number;
|
|
4566
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
4567
|
+
cursor?: string;
|
|
4568
|
+
product?: string;
|
|
4569
|
+
operation_id?: string;
|
|
4570
|
+
/** Only requests that succeeded (`2xx`) or failed (`4xx`, `5xx`). */
|
|
4571
|
+
status?: "2xx" | "4xx" | "5xx";
|
|
4572
|
+
key_id?: string;
|
|
4573
|
+
/** Only requests that arrived this way. */
|
|
4574
|
+
connection?: RequestConnection;
|
|
4575
|
+
/** Only requests made from inside this sandbox. */
|
|
4576
|
+
sandbox_id?: string;
|
|
4577
|
+
since?: string;
|
|
4578
|
+
}
|
|
4579
|
+
/** Parameters of `listDeliveries`. */
|
|
4580
|
+
export interface WebhooksListDeliveriesParams {
|
|
4581
|
+
/**
|
|
4582
|
+
* Page size, from 1 to 100.
|
|
4583
|
+
* @default 20
|
|
4584
|
+
*/
|
|
4585
|
+
limit?: number;
|
|
4586
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
4587
|
+
cursor?: string;
|
|
4588
|
+
/** Only deliveries to this endpoint. */
|
|
4589
|
+
url?: string;
|
|
4590
|
+
/** Only deliveries for this job. */
|
|
4591
|
+
job_id?: string;
|
|
4592
|
+
status?: DeliveryStatus;
|
|
4593
|
+
}
|
|
4594
|
+
/** Parameters of `listMembers`. */
|
|
4595
|
+
export interface PlatformListMembersParams {
|
|
4596
|
+
/**
|
|
4597
|
+
* Page size, from 1 to 100.
|
|
4598
|
+
* @default 20
|
|
4599
|
+
*/
|
|
4600
|
+
limit?: number;
|
|
4601
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
4602
|
+
cursor?: string;
|
|
4603
|
+
}
|
|
4604
|
+
/** Parameters of `listProjects`. */
|
|
4605
|
+
export interface PlatformListProjectsParams {
|
|
4606
|
+
/**
|
|
4607
|
+
* Page size, from 1 to 100.
|
|
4608
|
+
* @default 20
|
|
4609
|
+
*/
|
|
4610
|
+
limit?: number;
|
|
4611
|
+
/** Opaque cursor from the previous page's `next_cursor`. Omit it for the first page. */
|
|
4612
|
+
cursor?: string;
|
|
4613
|
+
}
|