@b3os/sdk 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +172 -42
- package/dist/cjs/core/bytes.d.ts +30 -0
- package/dist/cjs/core/bytes.js +115 -0
- package/dist/cjs/core/bytes.js.map +1 -0
- package/dist/cjs/core/client.d.ts +80 -3
- package/dist/cjs/core/client.js +236 -33
- package/dist/cjs/core/client.js.map +1 -1
- package/dist/cjs/core/errors.d.ts +16 -4
- package/dist/cjs/core/errors.js +9 -6
- package/dist/cjs/core/errors.js.map +1 -1
- package/dist/cjs/core/handle.d.ts +36 -0
- package/dist/cjs/core/handle.js +97 -0
- package/dist/cjs/core/handle.js.map +1 -0
- package/dist/cjs/core/index.d.ts +8 -4
- package/dist/cjs/core/index.js +14 -1
- package/dist/cjs/core/index.js.map +1 -1
- package/dist/cjs/core/login.d.ts +24 -0
- package/dist/cjs/core/login.js +93 -0
- package/dist/cjs/core/login.js.map +1 -0
- package/dist/cjs/core/namespace.d.ts +1 -1
- package/dist/cjs/core/namespace.js +1 -1
- package/dist/cjs/core/op.d.ts +11 -1
- package/dist/cjs/core/timing.d.ts +1 -1
- package/dist/cjs/core/timing.js +8 -1
- package/dist/cjs/core/timing.js.map +1 -1
- package/dist/cjs/core/traces-api.d.ts +42 -0
- package/dist/cjs/core/traces-api.js +54 -0
- package/dist/cjs/core/traces-api.js.map +1 -0
- package/dist/cjs/core/traces.d.ts +120 -0
- package/dist/cjs/core/traces.js +306 -0
- package/dist/cjs/core/traces.js.map +1 -0
- package/dist/cjs/core/transport.js +1 -1
- package/dist/cjs/core/transport.js.map +1 -1
- package/dist/cjs/core/util.d.ts +15 -3
- package/dist/cjs/core/util.js +54 -2
- package/dist/cjs/core/util.js.map +1 -1
- package/dist/cjs/core/ws.d.ts +4 -0
- package/dist/cjs/core/ws.js +7 -4
- package/dist/cjs/core/ws.js.map +1 -1
- package/dist/cjs/generated/client.d.ts +2 -2
- package/dist/cjs/generated/client.js +2 -2
- package/dist/cjs/generated/errors.d.ts +1 -1
- package/dist/cjs/generated/errors.js +42 -0
- package/dist/cjs/generated/errors.js.map +1 -1
- package/dist/cjs/generated/ids.d.ts +12 -0
- package/dist/cjs/generated/ids.js +3 -0
- package/dist/cjs/generated/ids.js.map +1 -1
- package/dist/cjs/generated/jobs.js +1 -1
- package/dist/cjs/generated/ns/actions.d.ts +48 -6
- package/dist/cjs/generated/ns/actions.js +59 -6
- package/dist/cjs/generated/ns/actions.js.map +1 -1
- package/dist/cjs/generated/ns/infer.d.ts +185 -54
- package/dist/cjs/generated/ns/infer.js +28 -74
- package/dist/cjs/generated/ns/infer.js.map +1 -1
- package/dist/cjs/generated/ns/keys.d.ts +14 -1
- package/dist/cjs/generated/ns/keys.js +24 -1
- package/dist/cjs/generated/ns/keys.js.map +1 -1
- package/dist/cjs/generated/ns/render.d.ts +115 -6
- package/dist/cjs/generated/ns/render.js +135 -7
- package/dist/cjs/generated/ns/render.js.map +1 -1
- package/dist/cjs/generated/ns/requests.d.ts +3 -1
- package/dist/cjs/generated/ns/requests.js +3 -1
- package/dist/cjs/generated/ns/requests.js.map +1 -1
- package/dist/cjs/generated/ns/routines.d.ts +131 -9
- package/dist/cjs/generated/ns/routines.js +186 -9
- package/dist/cjs/generated/ns/routines.js.map +1 -1
- package/dist/cjs/generated/ns/sandboxes.d.ts +327 -31
- package/dist/cjs/generated/ns/sandboxes.js +417 -29
- package/dist/cjs/generated/ns/sandboxes.js.map +1 -1
- package/dist/cjs/generated/ns/vision.d.ts +133 -14
- package/dist/cjs/generated/ns/vision.js +158 -12
- package/dist/cjs/generated/ns/vision.js.map +1 -1
- package/dist/cjs/generated/ns/webhooks.d.ts +8 -5
- package/dist/cjs/generated/ns/webhooks.js +8 -5
- package/dist/cjs/generated/ns/webhooks.js.map +1 -1
- package/dist/cjs/generated/types.d.ts +2750 -328
- package/dist/cjs/helpers/agents.d.ts +95 -0
- package/dist/cjs/helpers/agents.js +205 -0
- package/dist/cjs/helpers/agents.js.map +1 -0
- package/dist/cjs/helpers/render.d.ts +15 -0
- package/dist/cjs/helpers/render.js +74 -0
- package/dist/cjs/helpers/render.js.map +1 -0
- package/dist/cjs/helpers/routines.d.ts +61 -0
- package/dist/cjs/helpers/routines.js +234 -0
- package/dist/cjs/helpers/routines.js.map +1 -0
- package/dist/cjs/helpers/sandboxes.d.ts +237 -0
- package/dist/cjs/helpers/sandboxes.js +608 -0
- package/dist/cjs/helpers/sandboxes.js.map +1 -0
- package/dist/cjs/index.d.ts +4 -1
- package/dist/cjs/index.js +8 -5
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/routines.d.ts +1 -0
- package/dist/cjs/routines.js +21 -0
- package/dist/cjs/routines.js.map +1 -0
- package/dist/cjs/webhooks.js.map +1 -1
- package/dist/esm/core/bytes.d.ts +30 -0
- package/dist/esm/core/bytes.js +111 -0
- package/dist/esm/core/bytes.js.map +1 -0
- package/dist/esm/core/client.d.ts +80 -3
- package/dist/esm/core/client.js +233 -31
- package/dist/esm/core/client.js.map +1 -1
- package/dist/esm/core/errors.d.ts +16 -4
- package/dist/esm/core/errors.js +9 -6
- package/dist/esm/core/errors.js.map +1 -1
- package/dist/esm/core/handle.d.ts +36 -0
- package/dist/esm/core/handle.js +93 -0
- package/dist/esm/core/handle.js.map +1 -0
- package/dist/esm/core/index.d.ts +8 -4
- package/dist/esm/core/index.js +6 -2
- package/dist/esm/core/index.js.map +1 -1
- package/dist/esm/core/login.d.ts +24 -0
- package/dist/esm/core/login.js +85 -0
- package/dist/esm/core/login.js.map +1 -0
- package/dist/esm/core/namespace.d.ts +1 -1
- package/dist/esm/core/namespace.js +1 -1
- package/dist/esm/core/op.d.ts +11 -1
- package/dist/esm/core/timing.d.ts +1 -1
- package/dist/esm/core/timing.js +8 -1
- package/dist/esm/core/timing.js.map +1 -1
- package/dist/esm/core/traces-api.d.ts +42 -0
- package/dist/esm/core/traces-api.js +50 -0
- package/dist/esm/core/traces-api.js.map +1 -0
- package/dist/esm/core/traces.d.ts +120 -0
- package/dist/esm/core/traces.js +295 -0
- package/dist/esm/core/traces.js.map +1 -0
- package/dist/esm/core/transport.js +1 -1
- package/dist/esm/core/transport.js.map +1 -1
- package/dist/esm/core/util.d.ts +15 -3
- package/dist/esm/core/util.js +48 -1
- package/dist/esm/core/util.js.map +1 -1
- package/dist/esm/core/ws.d.ts +4 -0
- package/dist/esm/core/ws.js +7 -4
- package/dist/esm/core/ws.js.map +1 -1
- package/dist/esm/generated/client.d.ts +2 -2
- package/dist/esm/generated/client.js +2 -2
- package/dist/esm/generated/errors.d.ts +1 -1
- package/dist/esm/generated/errors.js +42 -0
- package/dist/esm/generated/errors.js.map +1 -1
- package/dist/esm/generated/ids.d.ts +12 -0
- package/dist/esm/generated/ids.js +3 -0
- package/dist/esm/generated/ids.js.map +1 -1
- package/dist/esm/generated/jobs.js +1 -1
- package/dist/esm/generated/ns/actions.d.ts +48 -6
- package/dist/esm/generated/ns/actions.js +59 -6
- package/dist/esm/generated/ns/actions.js.map +1 -1
- package/dist/esm/generated/ns/infer.d.ts +185 -54
- package/dist/esm/generated/ns/infer.js +28 -74
- package/dist/esm/generated/ns/infer.js.map +1 -1
- package/dist/esm/generated/ns/keys.d.ts +14 -1
- package/dist/esm/generated/ns/keys.js +24 -1
- package/dist/esm/generated/ns/keys.js.map +1 -1
- package/dist/esm/generated/ns/render.d.ts +115 -6
- package/dist/esm/generated/ns/render.js +135 -7
- package/dist/esm/generated/ns/render.js.map +1 -1
- package/dist/esm/generated/ns/requests.d.ts +3 -1
- package/dist/esm/generated/ns/requests.js +3 -1
- package/dist/esm/generated/ns/requests.js.map +1 -1
- package/dist/esm/generated/ns/routines.d.ts +131 -9
- package/dist/esm/generated/ns/routines.js +186 -9
- package/dist/esm/generated/ns/routines.js.map +1 -1
- package/dist/esm/generated/ns/sandboxes.d.ts +327 -31
- package/dist/esm/generated/ns/sandboxes.js +417 -29
- package/dist/esm/generated/ns/sandboxes.js.map +1 -1
- package/dist/esm/generated/ns/vision.d.ts +133 -14
- package/dist/esm/generated/ns/vision.js +158 -12
- package/dist/esm/generated/ns/vision.js.map +1 -1
- package/dist/esm/generated/ns/webhooks.d.ts +8 -5
- package/dist/esm/generated/ns/webhooks.js +8 -5
- package/dist/esm/generated/ns/webhooks.js.map +1 -1
- package/dist/esm/generated/types.d.ts +2750 -328
- package/dist/esm/helpers/agents.d.ts +95 -0
- package/dist/esm/helpers/agents.js +199 -0
- package/dist/esm/helpers/agents.js.map +1 -0
- package/dist/esm/helpers/render.d.ts +15 -0
- package/dist/esm/helpers/render.js +70 -0
- package/dist/esm/helpers/render.js.map +1 -0
- package/dist/esm/helpers/routines.d.ts +61 -0
- package/dist/esm/helpers/routines.js +226 -0
- package/dist/esm/helpers/routines.js.map +1 -0
- package/dist/esm/helpers/sandboxes.d.ts +237 -0
- package/dist/esm/helpers/sandboxes.js +600 -0
- package/dist/esm/helpers/sandboxes.js.map +1 -0
- package/dist/esm/index.d.ts +4 -1
- package/dist/esm/index.js +6 -5
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/routines.d.ts +1 -0
- package/dist/esm/routines.js +5 -0
- package/dist/esm/routines.js.map +1 -0
- package/dist/esm/webhooks.js.map +1 -1
- package/package.json +14 -3
- package/src/core/bytes.ts +112 -0
- package/src/core/client.ts +285 -33
- package/src/core/errors.ts +27 -10
- package/src/core/handle.ts +107 -0
- package/src/core/index.ts +17 -2
- package/src/core/login.ts +98 -0
- package/src/core/namespace.ts +1 -1
- package/src/core/op.ts +11 -1
- package/src/core/timing.ts +7 -2
- package/src/core/traces-api.ts +80 -0
- package/src/core/traces.ts +375 -0
- package/src/core/transport.ts +1 -1
- package/src/core/util.ts +53 -3
- package/src/core/ws.ts +11 -4
- package/src/generated/client.ts +2 -2
- package/src/generated/errors.ts +84 -0
- package/src/generated/ids.ts +3 -0
- package/src/generated/jobs.ts +1 -1
- package/src/generated/ns/actions.ts +69 -6
- package/src/generated/ns/infer.ts +229 -61
- package/src/generated/ns/keys.ts +25 -1
- package/src/generated/ns/render.ts +172 -7
- package/src/generated/ns/requests.ts +3 -1
- package/src/generated/ns/routines.ts +205 -9
- package/src/generated/ns/sandboxes.ts +493 -34
- package/src/generated/ns/vision.ts +168 -14
- package/src/generated/ns/webhooks.ts +8 -5
- package/src/generated/types.ts +3034 -472
- package/src/helpers/agents.ts +300 -0
- package/src/helpers/render.ts +91 -0
- package/src/helpers/routines.ts +278 -0
- package/src/helpers/sandboxes.ts +788 -0
- package/src/index.ts +29 -5
- package/src/routines.ts +5 -0
- package/src/webhooks.ts +5 -1
|
@@ -34,6 +34,15 @@ const getPackOp = {
|
|
|
34
34
|
timeoutMs: 10000,
|
|
35
35
|
scope: "actions:read",
|
|
36
36
|
};
|
|
37
|
+
const getPackToolsOp = {
|
|
38
|
+
id: "actionsGetPackTools",
|
|
39
|
+
method: "GET",
|
|
40
|
+
path: "/v1/actions/packs/{namespace}/{name}/tools",
|
|
41
|
+
params: ["namespace", "name"],
|
|
42
|
+
headerParams: { if_none_match: "If-None-Match" },
|
|
43
|
+
timeoutMs: 10000,
|
|
44
|
+
scope: "actions:read",
|
|
45
|
+
};
|
|
37
46
|
const getPackManifestOp = {
|
|
38
47
|
id: "actionsGetPackManifest",
|
|
39
48
|
method: "GET",
|
|
@@ -122,6 +131,7 @@ exports.actionsOps = {
|
|
|
122
131
|
describe: describeOp,
|
|
123
132
|
listPacks: listPacksOp,
|
|
124
133
|
getPack: getPackOp,
|
|
134
|
+
getPackTools: getPackToolsOp,
|
|
125
135
|
getPackManifest: getPackManifestOp,
|
|
126
136
|
listRegistryPacks: listRegistryPacksOp,
|
|
127
137
|
publishPack: publishPackOp,
|
|
@@ -140,10 +150,27 @@ class ActionsAPI extends namespace_ts_1.Namespace {
|
|
|
140
150
|
*
|
|
141
151
|
* Validates `input` against the action's schema, runs it, validates the result against its output schema and
|
|
142
152
|
* returns it. Credentials come from `connections` (pack connection key to `conn_` ID), or else from your
|
|
143
|
-
* project's most recently created connection for that pack and key
|
|
144
|
-
* user (
|
|
145
|
-
*
|
|
146
|
-
* connection
|
|
153
|
+
* project's most recently created connection for that pack and key that has no `subject`: an unnamed key never
|
|
154
|
+
* uses an end user's connection (one with a `subject`), even when it is newer; name end-user connections
|
|
155
|
+
* explicitly. A call with `subject` (your end user's ID) resolves each unnamed key to that subject's most
|
|
156
|
+
* recently created connection for the pack and key instead, never to another subject's or to one without a
|
|
157
|
+
* `subject`. With no such connection the call is refused with `422 connection_required`. Using a stored
|
|
158
|
+
* connection, named or not, also needs `vault:run`. A credential is sent only over `https`, and only to a host
|
|
159
|
+
* that both the called pack version declares for the connection and the connection is bound to (its `hosts`;
|
|
160
|
+
* a host a later pack version adds needs a new connection). A request to a plain `http` URL whose host would
|
|
161
|
+
* get a credential is refused with `403 egress_denied` (`reason: scheme`) and nothing is sent; after a
|
|
162
|
+
* redirect, a credential bound through a wildcard host (`*.atlassian.net`) goes only back to the host the
|
|
163
|
+
* request started at. A JavaScript action whose credential would be bound only through a wildcard host is
|
|
164
|
+
* refused with `501 not_implemented` on a node whose egress proxy for JavaScript actions cannot yet keep it
|
|
165
|
+
* on one host; nothing runs and nothing is billed. Credential values an upstream echoes are replaced by `*`
|
|
166
|
+
* characters before the response mapping reads the answer, and what a mapping computes, every error text
|
|
167
|
+
* and the output of a JavaScript action are searched again. Found are values as written, with JSON string
|
|
168
|
+
* escapes (`\/`, `\u0073`) or percent escapes in either hex case, also nested (a JSON text in a string, a URL
|
|
169
|
+
* in another URL's query), and for `basic` the `Authorization` value (values of at least 8 characters; error
|
|
170
|
+
* texts also drop shorter ones of at least 4). JavaScript code reads answers through the node's egress proxy:
|
|
171
|
+
* the built-in one replaces all of these spellings, the platform proxy only values written as is. Other
|
|
172
|
+
* encodings, such as base64 of an API key, are not recognized.
|
|
173
|
+
* Only `pure` and `read` actions are retried automatically; send `Idempotency-Key`
|
|
147
174
|
* with `write` actions so a retry of your own does not repeat the effect (packs that declare an
|
|
148
175
|
* idempotency header pass it upstream). `timing` phases: `validate` (input schema), `inject` (connections),
|
|
149
176
|
* `render` (request templates), `upstream` (every HTTP exchange, retries and redirects included), `map`
|
|
@@ -187,6 +214,20 @@ class ActionsAPI extends namespace_ts_1.Namespace {
|
|
|
187
214
|
getPack(namespace, name, params, options) {
|
|
188
215
|
return this._client._call(getPackOp, { path: [namespace, name], query: params }, options);
|
|
189
216
|
}
|
|
217
|
+
/**
|
|
218
|
+
* List a pack's MCP tools
|
|
219
|
+
*
|
|
220
|
+
* Every action of a pack version that is exposed to MCP, as MCP tool definitions in one response, so an MCP
|
|
221
|
+
* server lists a pack's tools with one request instead of one describe per action. The node builds the list
|
|
222
|
+
* when it loads the pack. Tool names are the registry's (`mcp_name`); each tool also carries the action's `ref`
|
|
223
|
+
* and `effects`, which a server drops from `tools/list`. Cache the response for `ttlMs`; the `ETag` is the
|
|
224
|
+
* version's content hash plus the filters, and `If-None-Match` with it answers `304`.
|
|
225
|
+
*
|
|
226
|
+
* `GET /v1/actions/packs/{namespace}/{name}/tools` · scope `actions:read` · served by the node
|
|
227
|
+
*/
|
|
228
|
+
getPackTools(namespace, name, params, options) {
|
|
229
|
+
return this._client._call(getPackToolsOp, { path: [namespace, name], query: params, headerParams: params }, options);
|
|
230
|
+
}
|
|
190
231
|
/**
|
|
191
232
|
* Get a pack manifest
|
|
192
233
|
*
|
|
@@ -254,8 +295,20 @@ class ActionsAPI extends namespace_ts_1.Namespace {
|
|
|
254
295
|
/**
|
|
255
296
|
* Search actions
|
|
256
297
|
*
|
|
257
|
-
* Full-text search over action titles, descriptions and
|
|
258
|
-
* can pass to describe and call. The same results back the `actions_search` MCP tool.
|
|
298
|
+
* Full-text search over action titles, descriptions, pack names and task phrases, ranked for agents. Returns
|
|
299
|
+
* references you can pass to describe and call. The same results back the `actions_search` MCP tool. With
|
|
300
|
+
* `kind=trigger` it searches triggers instead (results have `kind: trigger`, and their refs go in a routine's
|
|
301
|
+
* action trigger), and with `kind=any` both, ranked together, each result with its `kind`.
|
|
302
|
+
*
|
|
303
|
+
* Every answer says whether anything matched: `match` is `found` or `none`. A query that names a pack (`slack`,
|
|
304
|
+
* `google sheets`, or a pack's term such as `email` or `weather`) searches only the packs it names, and its
|
|
305
|
+
* other words are values (`weather in Tokyo`). A query that names no pack matches only an action that carries
|
|
306
|
+
* all of its words. A service the catalog does not have (`telegram message`) matches nothing, and verbs keep
|
|
307
|
+
* the effect class they ask for: `delete` or `send` only actions that write, `read` or `list` only actions
|
|
308
|
+
* that read. A removal, or an action that cannot be undone, must also be about what the query names
|
|
309
|
+
* (`delete the repo` matches nothing, since no GitHub action deletes a repository). With `match: none`,
|
|
310
|
+
* `data` is empty, `unmatched` lists the words the catalog does not know, and `fallback` names the generic
|
|
311
|
+
* HTTP actions to use instead. Never substitute an unrelated action.
|
|
259
312
|
*
|
|
260
313
|
* `GET /v1/actions/search` · scope `actions:read` · served by the node
|
|
261
314
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../../../../src/generated/ns/actions.ts"],"names":[],"mappings":";AAAA,4GAA4G;;;AAG5G,0DAAoD;AAKpD,MAAM,MAAM,GAAO;IACjB,EAAE,EAAE,aAAa;IACjB,MAAM,EAAE,MAAM;IACd,IAAI,EAAE,kBAAkB;IACxB,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,IAAI;IACV,SAAS,EAAE,KAAK;IAChB,KAAK,EAAE,aAAa;CACrB,CAAC;AACF,MAAM,UAAU,GAAO;IACrB,EAAE,EAAE,iBAAiB;IACrB,MAAM,EAAE,KAAK;IACb,IAAI,EAAE,sBAAsB;IAC5B,SAAS,EAAE,KAAK;IAChB,KAAK,EAAE,cAAc;CACtB,CAAC;AACF,MAAM,WAAW,GAAO;IACtB,EAAE,EAAE,kBAAkB;IACtB,MAAM,EAAE,KAAK;IACb,IAAI,EAAE,mBAAmB;IACzB,SAAS,EAAE,KAAK;IAChB,KAAK,EAAE,cAAc;CACtB,C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AAW,EAAE,aAAa;IAC1B,eAAe,EAAE,iBAAiB;IAClC,sBAAsB,EAAE,wBAAwB;IAChD,YAAY,EAAE,cAAc;IAC5B,MAAM,EAAE,QAAQ;IAChB,iBAAiB,EAAE,mBAAmB;IACtC,eAAe,EAAE,iBAAiB;IAClC,YAAY,EAAE,cAAc;CACpB,CAAC;AAEX,wGAAwG;AACxG,MAAa,UAAW,SAAQ,wBAAS;IACvC
|
|
1
|
+
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../../../../src/generated/ns/actions.ts"],"names":[],"mappings":";AAAA,4GAA4G;;;AAG5G,0DAAoD;AAKpD,MAAM,MAAM,GAAO;IACjB,EAAE,EAAE,aAAa;IACjB,MAAM,EAAE,MAAM;IACd,IAAI,EAAE,kBAAkB;IACxB,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,IAAI;IACV,SAAS,EAAE,KAAK;IAChB,KAAK,EAAE,aAAa;CACrB,CAAC;AACF,MAAM,UAAU,GAAO;IACrB,EAAE,EAAE,iBAAiB;IACrB,MAAM,EAAE,KAAK;IACb,IAAI,EAAE,sBAAsB;IAC5B,SAAS,EAAE,KAAK;IAChB,KAAK,EAAE,cAAc;CACtB,CAAC;AACF,MAAM,WAAW,GAAO;IACtB,EAAE,EAAE,kBAAkB;IACtB,MAAM,EAAE,KAAK;IACb,IAAI,EAAE,mBAAmB;IACzB,SAAS,EAAE,KAAK;IAChB,KAAK,EAAE,cAAc;CACtB,CAAC;AACF,MAAM,SAAS,GAAO;IACpB,EAAE,EAAE,gBAAgB;IACpB,MAAM,EAAE,KAAK;IACb,IAAI,EAAE,sCAAsC;IAC5C,MAAM,EAAE,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,SAAS,EAAE,KAAK;IAChB,KAAK,EAAE,cAAc;CACtB,CAAC;AACF,MAAM,cAAc,GAAO;IACzB,EAAE,EAAE,qBAAqB;IACzB,MAAM,EAAE,KAAK;IACb,IAAI,EAAE,4CAA4C;IAClD,MAAM,EAAE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EAAE,OAAwB;QACrF,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CACvB,cAAc,EACd,EAAE,IAAI,EAAE,CAAC,SAAS,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,EACpC,OAAO,EACP,4CAA4C,EAC5C,OAAO,CACR,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,MAAM,CAAC,MAA6B,EAAE,OAAwB;QAC5D,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAuB,QAAQ,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,CAAC;IACxF,CAAC;IAED;;;;;;;;;OASG;IACH,iBAAiB,CACf,MAAyC,EACzC,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CACvB,mBAAmB,EACnB,EAAE,KAAK,EAAE,MAAM,EAAE,EACjB,OAAO,CACR,CAAC;IACJ,CAAC;IAED;;;;;;;;OAQG;IACH,eAAe,CAAC,cAAsB,EAAE,OAAwB;QAC9D,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAwB,iBAAiB,EAAE,EAAE,IAAI,EAAE,CAAC,cAAc,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IAC3G,CAAC;IAED;;;;;;;;OAQG;IACH,YAAY,CACV,MAAoC,EACpC,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAkC,cAAc,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,CAAC;IACzG,CAAC;CACF;AAxQD,gCAwQC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ByteStream } from "../../core/bytes.ts";
|
|
1
2
|
import type { RequestOptions, StreamOptions } from "../../core/client.ts";
|
|
2
3
|
import { Namespace } from "../../core/namespace.ts";
|
|
3
4
|
import type { Op } from "../../core/op.ts";
|
|
@@ -26,13 +27,40 @@ export declare class InferAPI extends Namespace {
|
|
|
26
27
|
* word, which render uses to place clicks on words and cut captions. Every `response_format` is produced:
|
|
27
28
|
* `mp3`, `opus` (Ogg), `aac` (ADTS), `flac`, `wav` and `pcm` (16-bit mono at `sample_rate`, 24 kHz for
|
|
28
29
|
* `kokoro-82m`). `kokoro-82m` speaks at `speed` 0.5 to 2 and takes no `instructions`; other values return
|
|
29
|
-
* `400 unsupported_parameter`.
|
|
30
|
-
* `
|
|
30
|
+
* `400 unsupported_parameter`. OpenAI's voice names work: `alloy`, `echo`, `fable`, `nova` and `onyx` are
|
|
31
|
+
* Kokoro's `af_alloy`, `am_echo`, `bm_fable`, `af_nova` and `am_onyx`, and `ash`, `ballad`, `cedar`, `coral`,
|
|
32
|
+
* `marin`, `sage`, `shimmer` and `verse` are a fixed pick of other Kokoro voices (`am_michael`, `bm_george`,
|
|
33
|
+
* `am_fenrir`, `af_heart`, `af_kore`, `af_sarah`, `af_bella` and `am_puck`), not a claim that they sound alike.
|
|
34
|
+
* The `x-b3os-voice` header names the voice that spoke. Any other name is `404 voice_not_found`. B3OS
|
|
35
|
+
* extension: `language` reads `input` in another language than the voice's own (one of the `language` values
|
|
36
|
+
* `GET /v1/infer/audio/voices` lists; others are `400 unsupported_parameter`). While the
|
|
37
|
+
* node's voice service is down the answer is `503 infer_backend_unavailable` with `Retry-After`.
|
|
38
|
+
* `Server-Timing` carries the voice service's own
|
|
31
39
|
* `voice_queue` and `voice_run` beside b3osd's `synthesize` and `encode`. Bills `infer.audio_chars`
|
|
32
40
|
* (characters of `input`).
|
|
33
41
|
*
|
|
42
|
+
* Streaming: without `stream_format` the clip comes in one piece. With OpenAI's `stream_format` the audio
|
|
43
|
+
* is sent as it is made, sentence by sentence: `audio` sends the bytes of `response_format` as they come (a
|
|
44
|
+
* `wav` stream's header has open sizes, `0xFFFFFFFF`), and `sse` sends `speech.audio.delta` events with
|
|
45
|
+
* base64 audio, then one `speech.audio.done` with the format, duration, `words` when `timestamps` is `word`,
|
|
46
|
+
* and `b3os` timing. The response head waits for the first audio, so `Server-Timing` carries `ttfa`, the time
|
|
47
|
+
* from the request to the first audio bytes, and an error before any audio is a plain HTTP error. A failure
|
|
48
|
+
* after audio ends an `sse` stream with an `error` event and cuts an `audio` stream short; the characters of
|
|
49
|
+
* each part of the input that produced audio are billed. `timestamps: "word"` with `stream_format: "audio"`
|
|
50
|
+
* is `400 unsupported_parameter` (an audio stream carries only audio).
|
|
51
|
+
*
|
|
52
|
+
* In flight: each organization may have 32 speech answers on a node at once, streamed or not, each counted
|
|
53
|
+
* until its last byte is read; the next is `429 concurrency_limited` with `Retry-After: 1`. An answer whose
|
|
54
|
+
* caller reads nothing of it for 2 minutes ends, and its body is cut short.
|
|
55
|
+
*
|
|
34
56
|
* `POST /v1/infer/audio/speech` · scope `infer:run` · served by the node
|
|
35
57
|
*/
|
|
58
|
+
createSpeech(body: T.SpeechRequest & {
|
|
59
|
+
stream_format: "sse";
|
|
60
|
+
}, options?: StreamOptions): EventStream<T.SpeechStreamEvent>;
|
|
61
|
+
createSpeech(body: T.SpeechRequest & {
|
|
62
|
+
stream_format: "audio";
|
|
63
|
+
}, options?: RequestOptions): ByteStream;
|
|
36
64
|
createSpeech(body: T.SpeechRequest & {
|
|
37
65
|
timestamps: "word";
|
|
38
66
|
}, options?: RequestOptions): APIPromise<T.SpeechWithTimestamps>;
|
|
@@ -40,8 +68,9 @@ export declare class InferAPI extends Namespace {
|
|
|
40
68
|
/**
|
|
41
69
|
* List voices
|
|
42
70
|
*
|
|
43
|
-
* Lists the voices each speech model offers,
|
|
44
|
-
*
|
|
71
|
+
* Lists the voices each speech model offers, featured voices first, with language, gender, where the word
|
|
72
|
+
* timings come from, the voice's tier and use case, whether it is its language's default, and an audio
|
|
73
|
+
* sample. A B3OS endpoint (not part of the OpenAI API), so it uses B3OS lists and errors: `503 infer_backend_unavailable` with `Retry-After` while
|
|
45
74
|
* the voice service is down. All voices arrive in one page (`next_cursor` is always `null`).
|
|
46
75
|
*
|
|
47
76
|
* `GET /v1/infer/audio/voices` · scope `infer:read` · served by the node
|
|
@@ -61,16 +90,41 @@ export declare class InferAPI extends Namespace {
|
|
|
61
90
|
* Parameters this node does not take return `400 unsupported_parameter` naming the parameter. Besides the
|
|
62
91
|
* OpenAI parameters below, it takes the sampling extensions `top_k`, `min_p`, `repetition_penalty` and
|
|
63
92
|
* `logit_bias`, and `chat_template_kwargs.enable_thinking` (the model answers without a reasoning phase
|
|
64
|
-
* unless it is `true`; the reasoning then arrives in `reasoning_content`). `
|
|
65
|
-
*
|
|
93
|
+
* unless it is `true`; the reasoning then arrives in `reasoning_content`). `reasoning_effort` turns the
|
|
94
|
+
* reasoning phase on with a ceiling the node enforces: `low` 256, `medium` 1,024, `high` 4,096 and `xhigh`
|
|
95
|
+
* 8,192 reasoning tokens, after which the reasoning closes and the answer starts in the same request; `none`
|
|
96
|
+
* and `minimal` turn it off. `metadata`, `store`,
|
|
97
|
+
* `service_tier`, `prompt_cache_key`, `prompt_cache_retention`, `safety_identifier` and `verbosity` are
|
|
98
|
+
* accepted and ignored. `null` means unset for every optional parameter. Image URLs are
|
|
66
99
|
* `https://` (fetched by the node through its egress guard, which refuses private, loopback and metadata
|
|
67
100
|
* addresses with `403 egress_denied`) or `data:image/{png,jpeg,webp,gif};base64,`. JSON Schemas (tool
|
|
68
101
|
* `parameters`, `response_format.json_schema.schema`) larger than 64 KiB or nested deeper than 32 levels are
|
|
69
102
|
* `400 unsupported_parameter`.
|
|
70
103
|
*
|
|
104
|
+
* The runtime caches prompt prefixes per organization: the node salts the cache with your organization on
|
|
105
|
+
* every chat completion, Messages and Responses request, so a request reuses cached prefixes only from your
|
|
106
|
+
* own organization's requests, and another organization's request never hits yours. The salt is the node's,
|
|
107
|
+
* not a parameter: `cache_salt` is `400 unsupported_parameter`. The runtime's image caches (processed and
|
|
108
|
+
* encoded images) are split the same way: the node gives every image an identity derived from your
|
|
109
|
+
* organization and the image's bytes, so a cached image serves only your own organization's requests. A
|
|
110
|
+
* content part's `uuid` is `400 invalid_request`.
|
|
111
|
+
*
|
|
112
|
+
* Conversations are checked against what the model's chat template takes (`400 invalid_request` with the
|
|
113
|
+
* pointer): every message but an assistant one needs `content`, and on `b3os/qwen3.5-9b` the conversation
|
|
114
|
+
* needs a user message that is more than tool results. Developer messages are system messages on this node's
|
|
115
|
+
* models (OpenAI's meaning of the role); on `b3os/qwen3.5-9b` the system and developer messages a
|
|
116
|
+
* conversation starts with are joined into one, separated by a blank line (its chat template takes one), and
|
|
117
|
+
* a system or developer message after another turn is `400 invalid_request` pointing at it.
|
|
118
|
+
*
|
|
71
119
|
* Bills input and output tokens. Requests are admitted against your organization's per-minute limits on the
|
|
72
|
-
* model: one request, and the estimated prompt plus `max_completion_tokens` (or `max_tokens`, else
|
|
73
|
-
* tokens), settled with the real counts when the request ends.
|
|
120
|
+
* model: one request, and the estimated prompt plus `max_completion_tokens` (or `max_tokens`, else the
|
|
121
|
+
* default output cap, else 512 tokens), settled with the real counts when the request ends. The default
|
|
122
|
+
* output cap is a node setting, shown per model as `b3os.default_max_tokens` in `GET /v1/infer/models`: where
|
|
123
|
+
* it is set, a request that sets neither stops there with `finish_reason: "length"` (set `max_tokens` to go
|
|
124
|
+
* higher); where it is `null`, there is no cap and such a request can run to the end of the context. Each
|
|
125
|
+
* `https://` image reserves the node's image size limit (10 MiB) from your organization's per-minute image
|
|
126
|
+
* bytes before it is fetched, and gives back what it did not use; the bytes fetched count against the
|
|
127
|
+
* organization's daily egress quota.
|
|
74
128
|
*
|
|
75
129
|
* `POST /v1/infer/chat/completions` · scope `infer:run` · served by the node
|
|
76
130
|
*/
|
|
@@ -115,34 +169,76 @@ export declare class InferAPI extends Namespace {
|
|
|
115
169
|
* Create a response (OpenAI Responses API)
|
|
116
170
|
*
|
|
117
171
|
* A stateless subset of the OpenAI Responses API on the node's own models, for SDKs and agent frameworks that
|
|
118
|
-
* speak Responses (the OpenAI Agents SDK among them) with only the base URL changed
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
* `
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
* `
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
172
|
+
* speak Responses (the OpenAI Agents SDK among them) with only the base URL changed. Nothing is stored: send
|
|
173
|
+
* the whole conversation as `input` items each turn, and every response reports `store: false`. Models are
|
|
174
|
+
* those of `GET /v1/infer/models`; there is no gateway route on Responses. `null` means unset for every
|
|
175
|
+
* optional parameter.
|
|
176
|
+
*
|
|
177
|
+
* **Supported**
|
|
178
|
+
*
|
|
179
|
+
* | Parameter | On this node |
|
|
180
|
+
* |---|---|
|
|
181
|
+
* | `model` | A chat model from `GET /v1/infer/models` |
|
|
182
|
+
* | `input` | A string, or items: `message` (`input_text` and `input_image` parts; `output_text` for assistant turns), `function_call`, `function_call_output` and `reasoning` |
|
|
183
|
+
* | `instructions` | Joined with the system and developer items `input` starts with into one system message |
|
|
184
|
+
* | `tools`, `tool_choice`, `parallel_tool_calls` | `function` tools (at most 128); `tool_choice` `none`, `auto`, `required` or a named function. A tool's `strict` is passed to the runtime when set, and the response echoes what was applied: the value sent, or `null` when unset (OpenAI's default is `true`; unset here, `auto` tool calls are not held to the schema) |
|
|
185
|
+
* | `text.format` | `text`, `json_schema` (at most 64 KiB serialized and 32 levels deep) and `json_object` |
|
|
186
|
+
* | `reasoning.effort` | `low` and above turn the model's reasoning phase on, at most 256, 1,024, 4,096 or 8,192 reasoning tokens (`low` to `xhigh`, as chat's `reasoning_effort`); its text arrives in `reasoning` items. `none` and `minimal` leave it off |
|
|
187
|
+
* | `max_output_tokens` | Caps the answer; admission reserves it. Unset, the answer stops at the model's default output cap where the node sets one (`b3os.default_max_tokens`), with `status: "incomplete"`; where that is `null`, it can run to the end of the context |
|
|
188
|
+
* | `temperature`, `top_p` | Passed to the runtime |
|
|
189
|
+
* | `stream` | The Responses event stream (`response.created` ... `response.completed`), as OpenAI sends it |
|
|
190
|
+
* | `input_image` | `https://` URLs (fetched by the node through its egress guard) or `data:image/{png,jpeg,webp,gif};base64,` URLs, with the image limits of chat completions |
|
|
191
|
+
*
|
|
192
|
+
* **Accepted and ignored**
|
|
136
193
|
*
|
|
194
|
+
* | Parameter | Why |
|
|
195
|
+
* |---|---|
|
|
196
|
+
* | `store` | Nothing is stored; the response says `store: false` |
|
|
197
|
+
* | `metadata` | Echoed in the response (at most 16 keys) |
|
|
198
|
+
* | `user`, `safety_identifier`, `prompt_cache_key`, `prompt_cache_retention`, `service_tier` | No effect on this node; the runtime caches prompt prefixes on its own, per organization |
|
|
199
|
+
* | `text.verbosity`, `reasoning.summary`, `reasoning.generate_summary` | Echoed; the reasoning text is returned whole |
|
|
200
|
+
* | `include: ["reasoning.encrypted_content"]` | Reasoning items carry their text in `content` |
|
|
201
|
+
* | `stream_options.include_obfuscation` | No obfuscation padding is sent |
|
|
202
|
+
* | `truncation: "disabled"` | The default; the node never drops input items |
|
|
203
|
+
*
|
|
204
|
+
* **Refused** (`400 unsupported_parameter`, pointing at the parameter)
|
|
205
|
+
*
|
|
206
|
+
* | Parameter | Why |
|
|
207
|
+
* |---|---|
|
|
208
|
+
* | `previous_response_id`, `conversation`, `background: true`, `item_reference` items | They need stored responses |
|
|
209
|
+
* | `prompt` | Stored prompts are not available |
|
|
210
|
+
* | `truncation: "auto"` | The node never drops input items; keep the input within the model's context |
|
|
211
|
+
* | Tools other than `function` (web search, file search, computer use, code interpreter, MCP, image generation, shell), `defer_loading: true`, `allowed_callers` other than `direct` | They run on OpenAI's side |
|
|
212
|
+
* | `input_file` parts, `file_id` images | The Files API is not available |
|
|
213
|
+
* | `top_logprobs`, `max_tool_calls`, other `include` values | Not available on this node |
|
|
214
|
+
* | Any other parameter | The request is closed |
|
|
215
|
+
*
|
|
216
|
+
* **Errors** (OpenAI shape, the B3OS code in `error.code`)
|
|
217
|
+
*
|
|
218
|
+
* | Status | When |
|
|
219
|
+
* |---|---|
|
|
220
|
+
* | `400 invalid_request` | A malformed value, or a conversation the chat template refuses: on `b3os/qwen3.5-9b` it needs a user message that is more than function call outputs, and a system or developer item after another turn is refused (pointing at `input`) |
|
|
221
|
+
* | `400 unsupported_parameter` | The Refused rows above |
|
|
222
|
+
* | `400 context_length_exceeded` | The prompt plus `max_output_tokens` does not fit the model's context |
|
|
223
|
+
* | `403 egress_denied` | An image URL on a private, loopback or metadata address |
|
|
224
|
+
* | `404 model_not_available` | The model is not served on this node |
|
|
225
|
+
* | `429` | Over your organization's requests or tokens per minute, image bytes per minute or requests in flight (`Retry-After` says when) |
|
|
226
|
+
* | `503 infer_backend_unavailable` | The runtime is restarting or its slots are taken (`Retry-After`) |
|
|
227
|
+
* | stream `error` event | A stream that fails after it started ends with an `error` event; one that fails before the first token is a plain HTTP error |
|
|
228
|
+
*
|
|
229
|
+
* The response head of a stream waits for the first generated token, so `Server-Timing` can carry `ttft`.
|
|
137
230
|
* Bills input and output tokens, with the admission and limits of chat completions (the estimated prompt
|
|
138
|
-
* plus `max_output_tokens`, else 512 tokens, settled with the real counts; an
|
|
139
|
-
* its last token).
|
|
231
|
+
* plus `max_output_tokens`, else the default output cap, else 512 tokens, settled with the real counts; an
|
|
232
|
+
* abandoned stream is billed to its last token).
|
|
140
233
|
*
|
|
141
234
|
* `POST /v1/infer/responses` · scope `infer:run` · served by the node
|
|
142
|
-
*
|
|
143
|
-
* Stretch: in the contract, but may answer `501 not_implemented` on this deployment.
|
|
144
235
|
*/
|
|
145
|
-
createResponse(body: T.ResponsesRequest
|
|
236
|
+
createResponse(body: T.ResponsesRequest & {
|
|
237
|
+
stream: true;
|
|
238
|
+
}, options?: StreamOptions): EventStream<T.ResponsesStreamEvent>;
|
|
239
|
+
createResponse(body: T.ResponsesRequest & {
|
|
240
|
+
stream?: false | null;
|
|
241
|
+
}, options?: RequestOptions): APIPromise<T.ResponsesResponse>;
|
|
146
242
|
/**
|
|
147
243
|
* Create a message (Anthropic Messages API)
|
|
148
244
|
*
|
|
@@ -150,31 +246,68 @@ export declare class InferAPI extends Namespace {
|
|
|
150
246
|
* it with only the base URL and the credential changed: set `ANTHROPIC_BASE_URL` (or `base_url`) to
|
|
151
247
|
* `https://beta-api.b3os.org/v1/infer`, the same base URL as the OpenAI SDKs (`http://127.0.0.1:7700/v1/infer`
|
|
152
248
|
* inside a sandbox; the SDKs add `/v1/messages`), and send the B3OS key as a bearer token
|
|
153
|
-
* (`ANTHROPIC_AUTH_TOKEN`, or `auth_token` in the SDKs).
|
|
154
|
-
*
|
|
155
|
-
* `thinking` (the reasoning arrives in `thinking` blocks; `budget_tokens` caps it), JSON Schema output
|
|
156
|
-
* through `output_config.format`, stop sequences, a trailing assistant turn that the model continues, and
|
|
157
|
-
* streaming events (`message_start` ... `message_stop`, exactly as Anthropic sends them). Models are those
|
|
158
|
-
* of `GET /v1/infer/models`; there is no gateway route here.
|
|
159
|
-
*
|
|
160
|
-
* Parameters this node does not take return `400 unsupported_parameter` (tools Anthropic defines or runs,
|
|
161
|
-
* such as `web_search` or `bash`, `container`, `mcp_servers`, document and file sources).
|
|
162
|
-
* `cache_control`, `citations`, `metadata`, `service_tier`, `output_config.effort` and `thinking.display`
|
|
163
|
-
* are accepted and ignored (the runtime caches prompt prefixes on its own). Errors use the Anthropic shape
|
|
164
|
-
* (`{"type": "error", "error": {...}}`, with the B3OS code under `b3os`), except those raised before the
|
|
165
|
-
* request reaches the infer service (authentication, scopes, body size), which use the OpenAI shape of the
|
|
166
|
-
* rest of `/v1/infer`; Anthropic SDKs map both by HTTP status. A stream that fails after it started ends
|
|
167
|
-
* with an `error` event; one that fails before the first token is a plain HTTP error. The response head of
|
|
168
|
-
* a stream waits for the first generated token, so `Server-Timing` can carry `ttft`.
|
|
249
|
+
* (`ANTHROPIC_AUTH_TOKEN`, or `auth_token` in the SDKs). Models are those of `GET /v1/infer/models`; there is
|
|
250
|
+
* no gateway route here. `null` means unset for every optional parameter.
|
|
169
251
|
*
|
|
170
|
-
*
|
|
171
|
-
* plus `max_tokens`, settled with the real counts; an abandoned stream is billed to its last token).
|
|
252
|
+
* **Supported**
|
|
172
253
|
*
|
|
173
|
-
*
|
|
254
|
+
* | Parameter | On this node |
|
|
255
|
+
* |---|---|
|
|
256
|
+
* | `model`, `max_tokens` | Both required; `max_tokens` caps the answer and admission reserves it |
|
|
257
|
+
* | `messages` | `text`, `image` (`base64`, or `url` sources fetched by the node through its egress guard), `tool_use`, `tool_result` and `thinking` blocks. A trailing assistant turn ending in text is continued (prefill) |
|
|
258
|
+
* | `system` | A string or text blocks, joined with blank lines |
|
|
259
|
+
* | `tools`, `tool_choice` | Custom tools (`name`, `description`, `input_schema`, `strict`; at most 128); `tool_choice` `auto`, `any`, `tool` or `none`, with `disable_parallel_tool_use` |
|
|
260
|
+
* | `thinking` | `enabled` (`budget_tokens` from 1,024 and below `max_tokens` caps the reasoning), `adaptive` (capped at `output_config.effort`'s budget, `high` by default) or `disabled`; the reasoning arrives in `thinking` blocks |
|
|
261
|
+
* | `output_config.format` | JSON Schema output (`json_schema`, at most 64 KiB serialized and 32 levels deep) |
|
|
262
|
+
* | `stop_sequences` | At most 4 |
|
|
263
|
+
* | `temperature`, `top_p`, `top_k` | Passed to the runtime (`temperature` and `top_p` from 0 to 1) |
|
|
264
|
+
* | `stream` | Streaming events (`message_start` ... `message_stop`), exactly as Anthropic sends them |
|
|
174
265
|
*
|
|
175
|
-
*
|
|
266
|
+
* **Accepted and ignored**
|
|
267
|
+
*
|
|
268
|
+
* | Parameter | Why |
|
|
269
|
+
* |---|---|
|
|
270
|
+
* | `cache_control` (on any block or tool) | The runtime caches prompt prefixes on its own, per organization |
|
|
271
|
+
* | `context_management` | The node clears nothing from the conversation; the model sees every turn you send |
|
|
272
|
+
* | `citations` (on text blocks), `metadata.user_id`, `service_tier` | No effect on this node |
|
|
273
|
+
* | `output_config.effort` | With adaptive `thinking`, the reasoning budget: `low` 256, `medium` 1,024, `high` 4,096, `xhigh` and `max` 8,192 tokens (chat's `reasoning_effort` table). No effect otherwise |
|
|
274
|
+
* | `thinking.display` | The reasoning is always returned |
|
|
275
|
+
*
|
|
276
|
+
* **Refused** (`400 unsupported_parameter`, pointing at the parameter)
|
|
277
|
+
*
|
|
278
|
+
* | Parameter | Why |
|
|
279
|
+
* |---|---|
|
|
280
|
+
* | Tools Anthropic defines or runs (`web_search`, `bash`, `code_execution`, `computer`, `text_editor` and the like) | This node runs custom tools only |
|
|
281
|
+
* | `mcp_servers`, `container` | Not available on this node |
|
|
282
|
+
* | `document` blocks and `file` sources (the Files API) | Send text, or the image as base64 or a URL |
|
|
283
|
+
* | Any other parameter | The request is closed, as Anthropic refuses extra inputs |
|
|
284
|
+
*
|
|
285
|
+
* **Errors** (Anthropic shape, `{"type": "error", "error": {"type", "message"}}`, with the B3OS code under `b3os`)
|
|
286
|
+
*
|
|
287
|
+
* | Status (`error.type`) | When |
|
|
288
|
+
* |---|---|
|
|
289
|
+
* | `400 invalid_request_error` | A malformed value (`invalid_request`), a Refused row (`unsupported_parameter`), a prompt that does not fit the context (`context_length_exceeded`), or a conversation the chat template refuses: on `b3os/qwen3.5-9b` it needs a user turn with more than `tool_result` blocks, and is not empty once empty text blocks are dropped (pointing at `messages`) |
|
|
290
|
+
* | `403 permission_error` | An image URL on a private, loopback or metadata address (`egress_denied`) |
|
|
291
|
+
* | `404 not_found_error` | The model is not served on this node (`model_not_available`) |
|
|
292
|
+
* | `429 rate_limit_error` | Over your organization's requests or tokens per minute, image bytes per minute or requests in flight (`Retry-After` says when) |
|
|
293
|
+
* | `503 overloaded_error` | The runtime is restarting or its slots are taken (`infer_backend_unavailable`, `Retry-After`) |
|
|
294
|
+
* | stream `error` event | A stream that fails after it started ends with an `error` event; one that fails before the first token is a plain HTTP error |
|
|
295
|
+
*
|
|
296
|
+
* Errors raised before the request reaches the infer service (authentication, scopes, body size, an
|
|
297
|
+
* unavailable node), on the node and at the edge, use the same Anthropic shape, so Anthropic SDKs raise the
|
|
298
|
+
* exception they would for Anthropic's own API. The response head of a stream waits for the first generated
|
|
299
|
+
* token, so `Server-Timing` can carry `ttft`. Bills input and output
|
|
300
|
+
* tokens, with the admission and limits of chat completions (the estimated prompt plus `max_tokens`, settled
|
|
301
|
+
* with the real counts; an abandoned stream is billed to its last token).
|
|
302
|
+
*
|
|
303
|
+
* `POST /v1/infer/v1/messages` · scope `infer:run` · served by the node
|
|
176
304
|
*/
|
|
177
|
-
createMessage(body: T.AnthropicMessagesRequest
|
|
305
|
+
createMessage(body: T.AnthropicMessagesRequest & {
|
|
306
|
+
stream: true;
|
|
307
|
+
}, options?: StreamOptions): EventStream<T.AnthropicStreamEvent>;
|
|
308
|
+
createMessage(body: T.AnthropicMessagesRequest & {
|
|
309
|
+
stream?: false | null;
|
|
310
|
+
}, options?: RequestOptions): APIPromise<T.AnthropicMessage>;
|
|
178
311
|
/**
|
|
179
312
|
* Count the tokens of a message request
|
|
180
313
|
*
|
|
@@ -183,8 +316,6 @@ export declare class InferAPI extends Namespace {
|
|
|
183
316
|
* template (images included). Free: it counts against your requests per minute, not your tokens.
|
|
184
317
|
*
|
|
185
318
|
* `POST /v1/infer/v1/messages/count_tokens` · scope `infer:run` · served by the node
|
|
186
|
-
*
|
|
187
|
-
* Stretch: in the contract, but may answer `501 not_implemented` on this deployment.
|
|
188
319
|
*/
|
|
189
320
|
countMessageTokens(body: T.AnthropicCountTokensRequest, options?: RequestOptions): APIPromise<T.AnthropicCountTokens>;
|
|
190
321
|
}
|
|
@@ -8,6 +8,7 @@ const createSpeechOp = {
|
|
|
8
8
|
method: "POST",
|
|
9
9
|
path: "/v1/infer/audio/speech",
|
|
10
10
|
body: "json",
|
|
11
|
+
stream: "sse",
|
|
11
12
|
timeoutMs: 65000,
|
|
12
13
|
errorFormat: "openai",
|
|
13
14
|
scope: "infer:run",
|
|
@@ -65,7 +66,6 @@ const createResponseOp = {
|
|
|
65
66
|
stream: "sse",
|
|
66
67
|
timeoutMs: 600000,
|
|
67
68
|
errorFormat: "openai",
|
|
68
|
-
stretch: true,
|
|
69
69
|
scope: "infer:run",
|
|
70
70
|
};
|
|
71
71
|
const createMessageOp = {
|
|
@@ -75,8 +75,7 @@ const createMessageOp = {
|
|
|
75
75
|
body: "json",
|
|
76
76
|
stream: "sse",
|
|
77
77
|
timeoutMs: 600000,
|
|
78
|
-
errorFormat: "
|
|
79
|
-
stretch: true,
|
|
78
|
+
errorFormat: "anthropic",
|
|
80
79
|
scope: "infer:run",
|
|
81
80
|
};
|
|
82
81
|
const countMessageTokensOp = {
|
|
@@ -85,8 +84,7 @@ const countMessageTokensOp = {
|
|
|
85
84
|
path: "/v1/infer/v1/messages/count_tokens",
|
|
86
85
|
body: "json",
|
|
87
86
|
timeoutMs: 30000,
|
|
88
|
-
errorFormat: "
|
|
89
|
-
stretch: true,
|
|
87
|
+
errorFormat: "anthropic",
|
|
90
88
|
scope: "infer:run",
|
|
91
89
|
};
|
|
92
90
|
/** Descriptors of every infer operation, keyed by method name (for tooling and custom clients). */
|
|
@@ -104,7 +102,16 @@ exports.inferOps = {
|
|
|
104
102
|
/** Models on the node: OpenAI-compatible chat, embeddings and speech (`/v1/infer`). */
|
|
105
103
|
class InferAPI extends namespace_ts_1.Namespace {
|
|
106
104
|
createSpeech(body, options = {}) {
|
|
107
|
-
|
|
105
|
+
const b = body;
|
|
106
|
+
if (b.stream_format === "sse") {
|
|
107
|
+
return this._client._postStream(createSpeechOp, { body }, options, {
|
|
108
|
+
terminal: (e) => ["speech.audio.done", "error"].includes(e.type ?? ""),
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
if (b.stream_format === "audio") {
|
|
112
|
+
return this._client._postBytes(createSpeechOp, { body }, options, "audio/mpeg, audio/wav, audio/pcm, audio/ogg, audio/aac, audio/flac");
|
|
113
|
+
}
|
|
114
|
+
if (b.timestamps === "word") {
|
|
108
115
|
return this._client._call(createSpeechOp, { body }, options);
|
|
109
116
|
}
|
|
110
117
|
return this._client._call(createSpeechOp, { body }, options, "audio/mpeg, audio/wav, audio/pcm, audio/ogg, audio/aac, audio/flac", "bytes");
|
|
@@ -112,8 +119,9 @@ class InferAPI extends namespace_ts_1.Namespace {
|
|
|
112
119
|
/**
|
|
113
120
|
* List voices
|
|
114
121
|
*
|
|
115
|
-
* Lists the voices each speech model offers,
|
|
116
|
-
*
|
|
122
|
+
* Lists the voices each speech model offers, featured voices first, with language, gender, where the word
|
|
123
|
+
* timings come from, the voice's tier and use case, whether it is its language's default, and an audio
|
|
124
|
+
* sample. A B3OS endpoint (not part of the OpenAI API), so it uses B3OS lists and errors: `503 infer_backend_unavailable` with `Retry-After` while
|
|
117
125
|
* the voice service is down. All voices arrive in one page (`next_cursor` is always `null`).
|
|
118
126
|
*
|
|
119
127
|
* `GET /v1/infer/audio/voices` · scope `infer:read` · served by the node
|
|
@@ -166,72 +174,20 @@ class InferAPI extends namespace_ts_1.Namespace {
|
|
|
166
174
|
getModel(model, options) {
|
|
167
175
|
return this._client._call(getModelOp, { path: [model] }, options);
|
|
168
176
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
* `function_call`, `function_call_output` and `reasoning` items), `instructions`, function tools with
|
|
176
|
-
* `tool_choice` and `parallel_tool_calls`, structured output through `text.format` (`json_schema`,
|
|
177
|
-
* `json_object`), `reasoning.effort` (`low` and above turn the model's reasoning phase on; its text arrives
|
|
178
|
-
* in `reasoning` items), `max_output_tokens`, `temperature`, `top_p`, and the Responses event stream
|
|
179
|
-
* (`response.created` ... `response.completed`, as OpenAI sends them).
|
|
180
|
-
*
|
|
181
|
-
* Nothing is stored: send the whole conversation as `input` items each turn. `previous_response_id`,
|
|
182
|
-
* `conversation`, `prompt`, `background: true` and `truncation: "auto"` are `400 unsupported_parameter`;
|
|
183
|
-
* `store`, `metadata` (echoed), `user`, `safety_identifier`, `prompt_cache_key`, `service_tier`,
|
|
184
|
-
* `text.verbosity`, `reasoning.summary` and `include: ["reasoning.encrypted_content"]` are accepted and
|
|
185
|
-
* ignored, and every response reports `store: false`. Tools other than `function` (web search, file
|
|
186
|
-
* search, computer use, code interpreter, MCP, image generation, shell) run on OpenAI's side and are
|
|
187
|
-
* `400 unsupported_parameter`. `null` means unset for every optional parameter. Images and JSON Schemas
|
|
188
|
-
* have the limits of chat completions. A stream that fails after it started ends with an `error` event; one
|
|
189
|
-
* that fails before the first token is a plain HTTP error. The response head of a stream waits for the
|
|
190
|
-
* first generated token, so `Server-Timing` can carry `ttft`.
|
|
191
|
-
*
|
|
192
|
-
* Bills input and output tokens, with the admission and limits of chat completions (the estimated prompt
|
|
193
|
-
* plus `max_output_tokens`, else 512 tokens, settled with the real counts; an abandoned stream is billed to
|
|
194
|
-
* its last token).
|
|
195
|
-
*
|
|
196
|
-
* `POST /v1/infer/responses` · scope `infer:run` · served by the node
|
|
197
|
-
*
|
|
198
|
-
* Stretch: in the contract, but may answer `501 not_implemented` on this deployment.
|
|
199
|
-
*/
|
|
200
|
-
createResponse(body, options) {
|
|
177
|
+
createResponse(body, options = {}) {
|
|
178
|
+
if (body.stream) {
|
|
179
|
+
return this._client._postStream(createResponseOp, { body }, options, {
|
|
180
|
+
terminal: (e) => ["response.completed", "response.incomplete", "error"].includes(e.type ?? ""),
|
|
181
|
+
});
|
|
182
|
+
}
|
|
201
183
|
return this._client._call(createResponseOp, { body }, options);
|
|
202
184
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
* inside a sandbox; the SDKs add `/v1/messages`), and send the B3OS key as a bearer token
|
|
210
|
-
* (`ANTHROPIC_AUTH_TOKEN`, or `auth_token` in the SDKs). Text, images (`base64`, or `url` sources fetched by
|
|
211
|
-
* the node through its egress guard), custom tools with `tool_use` and `tool_result` blocks, `tool_choice`,
|
|
212
|
-
* `thinking` (the reasoning arrives in `thinking` blocks; `budget_tokens` caps it), JSON Schema output
|
|
213
|
-
* through `output_config.format`, stop sequences, a trailing assistant turn that the model continues, and
|
|
214
|
-
* streaming events (`message_start` ... `message_stop`, exactly as Anthropic sends them). Models are those
|
|
215
|
-
* of `GET /v1/infer/models`; there is no gateway route here.
|
|
216
|
-
*
|
|
217
|
-
* Parameters this node does not take return `400 unsupported_parameter` (tools Anthropic defines or runs,
|
|
218
|
-
* such as `web_search` or `bash`, `container`, `mcp_servers`, document and file sources).
|
|
219
|
-
* `cache_control`, `citations`, `metadata`, `service_tier`, `output_config.effort` and `thinking.display`
|
|
220
|
-
* are accepted and ignored (the runtime caches prompt prefixes on its own). Errors use the Anthropic shape
|
|
221
|
-
* (`{"type": "error", "error": {...}}`, with the B3OS code under `b3os`), except those raised before the
|
|
222
|
-
* request reaches the infer service (authentication, scopes, body size), which use the OpenAI shape of the
|
|
223
|
-
* rest of `/v1/infer`; Anthropic SDKs map both by HTTP status. A stream that fails after it started ends
|
|
224
|
-
* with an `error` event; one that fails before the first token is a plain HTTP error. The response head of
|
|
225
|
-
* a stream waits for the first generated token, so `Server-Timing` can carry `ttft`.
|
|
226
|
-
*
|
|
227
|
-
* Bills input and output tokens, with the admission and limits of chat completions (the estimated prompt
|
|
228
|
-
* plus `max_tokens`, settled with the real counts; an abandoned stream is billed to its last token).
|
|
229
|
-
*
|
|
230
|
-
* `POST /v1/infer/v1/messages` · scope `infer:run` · served by the node
|
|
231
|
-
*
|
|
232
|
-
* Stretch: in the contract, but may answer `501 not_implemented` on this deployment.
|
|
233
|
-
*/
|
|
234
|
-
createMessage(body, options) {
|
|
185
|
+
createMessage(body, options = {}) {
|
|
186
|
+
if (body.stream) {
|
|
187
|
+
return this._client._postStream(createMessageOp, { body }, options, {
|
|
188
|
+
terminal: (e) => ["message_stop", "error"].includes(e.type ?? ""),
|
|
189
|
+
});
|
|
190
|
+
}
|
|
235
191
|
return this._client._call(createMessageOp, { body }, options);
|
|
236
192
|
}
|
|
237
193
|
/**
|
|
@@ -242,8 +198,6 @@ class InferAPI extends namespace_ts_1.Namespace {
|
|
|
242
198
|
* template (images included). Free: it counts against your requests per minute, not your tokens.
|
|
243
199
|
*
|
|
244
200
|
* `POST /v1/infer/v1/messages/count_tokens` · scope `infer:run` · served by the node
|
|
245
|
-
*
|
|
246
|
-
* Stretch: in the contract, but may answer `501 not_implemented` on this deployment.
|
|
247
201
|
*/
|
|
248
202
|
countMessageTokens(body, options) {
|
|
249
203
|
return this._client._call(countMessageTokensOp, { body }, options);
|