@b3os/sdk 0.0.0-stage → 0.1.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/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 +97 -3
- 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,353 @@
|
|
|
1
|
+
// Generated by packages/sdk/scripts/generate.mjs from packages/spec/dist. Do not edit; run `pnpm generate`.
|
|
2
|
+
|
|
3
|
+
import type { BinaryInput, RequestOptions } from "../../core/client.ts";
|
|
4
|
+
import { Namespace } from "../../core/namespace.ts";
|
|
5
|
+
import type { Op } from "../../core/op.ts";
|
|
6
|
+
import type { APIPromise, ListPromise } from "../../core/promise.ts";
|
|
7
|
+
import type * as T from "../types.ts";
|
|
8
|
+
|
|
9
|
+
const callOp: Op = {
|
|
10
|
+
id: "actionsCall",
|
|
11
|
+
method: "POST",
|
|
12
|
+
path: "/v1/actions/call",
|
|
13
|
+
body: "json",
|
|
14
|
+
idem: true,
|
|
15
|
+
timeoutMs: 65000,
|
|
16
|
+
scope: "actions:run",
|
|
17
|
+
};
|
|
18
|
+
const describeOp: Op = {
|
|
19
|
+
id: "actionsDescribe",
|
|
20
|
+
method: "GET",
|
|
21
|
+
path: "/v1/actions/describe",
|
|
22
|
+
timeoutMs: 10000,
|
|
23
|
+
scope: "actions:read",
|
|
24
|
+
};
|
|
25
|
+
const listPacksOp: Op = {
|
|
26
|
+
id: "actionsListPacks",
|
|
27
|
+
method: "GET",
|
|
28
|
+
path: "/v1/actions/packs",
|
|
29
|
+
timeoutMs: 10000,
|
|
30
|
+
scope: "actions:read",
|
|
31
|
+
};
|
|
32
|
+
const getPackOp: Op = {
|
|
33
|
+
id: "actionsGetPack",
|
|
34
|
+
method: "GET",
|
|
35
|
+
path: "/v1/actions/packs/{namespace}/{name}",
|
|
36
|
+
params: ["namespace", "name"],
|
|
37
|
+
timeoutMs: 10000,
|
|
38
|
+
scope: "actions:read",
|
|
39
|
+
};
|
|
40
|
+
const getPackManifestOp: Op = {
|
|
41
|
+
id: "actionsGetPackManifest",
|
|
42
|
+
method: "GET",
|
|
43
|
+
path: "/v1/actions/packs/{namespace}/{name}/versions/{version}/manifest",
|
|
44
|
+
params: ["namespace", "name", "version"],
|
|
45
|
+
timeoutMs: 10000,
|
|
46
|
+
scope: "actions:read",
|
|
47
|
+
};
|
|
48
|
+
const listRegistryPacksOp: Op = {
|
|
49
|
+
id: "platformListRegistryPacks",
|
|
50
|
+
method: "GET",
|
|
51
|
+
path: "/v1/actions/registry/packs",
|
|
52
|
+
edge: true,
|
|
53
|
+
timeoutMs: 10000,
|
|
54
|
+
scope: "actions:read",
|
|
55
|
+
};
|
|
56
|
+
const publishPackOp: Op = {
|
|
57
|
+
id: "platformPublishPack",
|
|
58
|
+
method: "POST",
|
|
59
|
+
path: "/v1/actions/registry/packs",
|
|
60
|
+
body: "bytes",
|
|
61
|
+
contentType: "application/gzip",
|
|
62
|
+
edge: true,
|
|
63
|
+
timeoutMs: 30000,
|
|
64
|
+
scope: "actions:write",
|
|
65
|
+
};
|
|
66
|
+
const getRegistryPackOp: Op = {
|
|
67
|
+
id: "platformGetRegistryPack",
|
|
68
|
+
method: "GET",
|
|
69
|
+
path: "/v1/actions/registry/packs/{namespace}/{name}",
|
|
70
|
+
params: ["namespace", "name"],
|
|
71
|
+
edge: true,
|
|
72
|
+
timeoutMs: 10000,
|
|
73
|
+
scope: "actions:read",
|
|
74
|
+
};
|
|
75
|
+
const getRegistryPackVersionOp: Op = {
|
|
76
|
+
id: "platformGetRegistryPackVersion",
|
|
77
|
+
method: "GET",
|
|
78
|
+
path: "/v1/actions/registry/packs/{namespace}/{name}/versions/{version}",
|
|
79
|
+
params: ["namespace", "name", "version"],
|
|
80
|
+
edge: true,
|
|
81
|
+
timeoutMs: 10000,
|
|
82
|
+
scope: "actions:read",
|
|
83
|
+
};
|
|
84
|
+
const downloadPackOp: Op = {
|
|
85
|
+
id: "platformDownloadPack",
|
|
86
|
+
method: "GET",
|
|
87
|
+
path: "/v1/actions/registry/packs/{namespace}/{name}/versions/{version}/download",
|
|
88
|
+
params: ["namespace", "name", "version"],
|
|
89
|
+
edge: true,
|
|
90
|
+
timeoutMs: 10000,
|
|
91
|
+
scope: "actions:read",
|
|
92
|
+
};
|
|
93
|
+
const searchOp: Op = {
|
|
94
|
+
id: "actionsSearch",
|
|
95
|
+
method: "GET",
|
|
96
|
+
path: "/v1/actions/search",
|
|
97
|
+
timeoutMs: 10000,
|
|
98
|
+
scope: "actions:read",
|
|
99
|
+
};
|
|
100
|
+
const listSubscriptionsOp: Op = {
|
|
101
|
+
id: "actionsListSubscriptions",
|
|
102
|
+
method: "GET",
|
|
103
|
+
path: "/v1/actions/subscriptions",
|
|
104
|
+
timeoutMs: 10000,
|
|
105
|
+
scope: "actions:read",
|
|
106
|
+
};
|
|
107
|
+
const getSubscriptionOp: Op = {
|
|
108
|
+
id: "actionsGetSubscription",
|
|
109
|
+
method: "GET",
|
|
110
|
+
path: "/v1/actions/subscriptions/{subscription_id}",
|
|
111
|
+
params: ["subscription_id"],
|
|
112
|
+
timeoutMs: 10000,
|
|
113
|
+
scope: "actions:read",
|
|
114
|
+
};
|
|
115
|
+
const listTriggersOp: Op = {
|
|
116
|
+
id: "actionsListTriggers",
|
|
117
|
+
method: "GET",
|
|
118
|
+
path: "/v1/actions/triggers",
|
|
119
|
+
timeoutMs: 10000,
|
|
120
|
+
scope: "actions:read",
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
/** Descriptors of every actions operation, keyed by method name (for tooling and custom clients). */
|
|
124
|
+
export const actionsOps = {
|
|
125
|
+
call: callOp,
|
|
126
|
+
describe: describeOp,
|
|
127
|
+
listPacks: listPacksOp,
|
|
128
|
+
getPack: getPackOp,
|
|
129
|
+
getPackManifest: getPackManifestOp,
|
|
130
|
+
listRegistryPacks: listRegistryPacksOp,
|
|
131
|
+
publishPack: publishPackOp,
|
|
132
|
+
getRegistryPack: getRegistryPackOp,
|
|
133
|
+
getRegistryPackVersion: getRegistryPackVersionOp,
|
|
134
|
+
downloadPack: downloadPackOp,
|
|
135
|
+
search: searchOp,
|
|
136
|
+
listSubscriptions: listSubscriptionsOp,
|
|
137
|
+
getSubscription: getSubscriptionOp,
|
|
138
|
+
listTriggers: listTriggersOp,
|
|
139
|
+
} as const;
|
|
140
|
+
|
|
141
|
+
/** Marketplace actions and triggers: search, describe, call, packs and the registry (`/v1/actions`). */
|
|
142
|
+
export class ActionsAPI extends Namespace {
|
|
143
|
+
/**
|
|
144
|
+
* Call an action
|
|
145
|
+
*
|
|
146
|
+
* Validates `input` against the action's schema, runs it, validates the result against its output schema and
|
|
147
|
+
* returns it. Credentials come from `connections` (pack connection key to `conn_` ID), or else from your
|
|
148
|
+
* project's most recently created connection for that pack and key; when that connection belongs to an end
|
|
149
|
+
* user (it has a `subject`), the call is refused with `422 connection_required` instead, so an unnamed key
|
|
150
|
+
* never uses one end user's credential for another: name end-user connections explicitly. Using a stored
|
|
151
|
+
* connection, named or not, also needs `vault:run`. Only `pure` and `read` actions are retried automatically; send `Idempotency-Key`
|
|
152
|
+
* with `write` actions so a retry of your own does not repeat the effect (packs that declare an
|
|
153
|
+
* idempotency header pass it upstream). `timing` phases: `validate` (input schema), `inject` (connections),
|
|
154
|
+
* `render` (request templates), `upstream` (every HTTP exchange, retries and redirects included), `map`
|
|
155
|
+
* (response mapping and output schema) for declarative HTTP actions; `sidecar` for JavaScript actions.
|
|
156
|
+
* Bills one `actions.call` once the action ran.
|
|
157
|
+
*
|
|
158
|
+
* `POST /v1/actions/call` · scope `actions:run` · served by the node
|
|
159
|
+
*/
|
|
160
|
+
call(body: T.ActionCallRequest, options?: RequestOptions): APIPromise<T.ActionResult> {
|
|
161
|
+
return this._client._call<T.ActionResult>(callOp, { body }, options);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Describe an action
|
|
166
|
+
*
|
|
167
|
+
* Returns everything needed to call one action: input and output JSON Schemas, effect class, MCP annotations
|
|
168
|
+
* and tool definition, and the connections it needs. A reference with `@<major>` resolves to the newest
|
|
169
|
+
* matching release; the response shows the exact version.
|
|
170
|
+
*
|
|
171
|
+
* `GET /v1/actions/describe` · scope `actions:read` · served by the node
|
|
172
|
+
*/
|
|
173
|
+
describe(params: T.ActionsDescribeParams, options?: RequestOptions): APIPromise<T.ActionDescription> {
|
|
174
|
+
return this._client._call<T.ActionDescription>(describeOp, { query: params }, options);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* List packs
|
|
179
|
+
*
|
|
180
|
+
* Lists the packs available on the node, alphabetically by ID, optionally filtered by a search phrase.
|
|
181
|
+
*
|
|
182
|
+
* `GET /v1/actions/packs` · scope `actions:read` · served by the node
|
|
183
|
+
*/
|
|
184
|
+
listPacks(params?: T.ActionsListPacksParams, options?: RequestOptions): ListPromise<T.PackList, T.PackSummary> {
|
|
185
|
+
return this._client._list<T.PackList, T.PackSummary>(listPacksOp, { query: params }, options);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Get a pack
|
|
190
|
+
*
|
|
191
|
+
* Returns a pack version (the latest unless `version` is given) with its actions, triggers, connections and egress hosts.
|
|
192
|
+
*
|
|
193
|
+
* `GET /v1/actions/packs/{namespace}/{name}` · scope `actions:read` · served by the node
|
|
194
|
+
*/
|
|
195
|
+
getPack(
|
|
196
|
+
namespace: string,
|
|
197
|
+
name: string,
|
|
198
|
+
params?: T.ActionsGetPackParams,
|
|
199
|
+
options?: RequestOptions,
|
|
200
|
+
): APIPromise<T.Pack> {
|
|
201
|
+
return this._client._call<T.Pack>(getPackOp, { path: [namespace, name], query: params }, options);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Get a pack manifest
|
|
206
|
+
*
|
|
207
|
+
* Returns the exact `b3pack.json` of one pack version, as published and signed.
|
|
208
|
+
*
|
|
209
|
+
* `GET /v1/actions/packs/{namespace}/{name}/versions/{version}/manifest` · scope `actions:read` · served by the node
|
|
210
|
+
*/
|
|
211
|
+
getPackManifest(namespace: string, name: string, version: string, options?: RequestOptions): APIPromise<T.B3Pack> {
|
|
212
|
+
return this._client._call<T.B3Pack>(getPackManifestOp, { path: [namespace, name, version] }, options);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* List registry packs
|
|
217
|
+
*
|
|
218
|
+
* Lists packs in the registry with their latest version. Nodes use it to keep their local index current.
|
|
219
|
+
*
|
|
220
|
+
* `GET /v1/actions/registry/packs` · scope `actions:read` · served by beta-api.b3os.org
|
|
221
|
+
*/
|
|
222
|
+
listRegistryPacks(
|
|
223
|
+
params?: T.PlatformListRegistryPacksParams,
|
|
224
|
+
options?: RequestOptions,
|
|
225
|
+
): ListPromise<T.RegistryPackList, T.RegistryPack> {
|
|
226
|
+
return this._client._list<T.RegistryPackList, T.RegistryPack>(listRegistryPacksOp, { query: params }, options);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Publish a pack version
|
|
231
|
+
*
|
|
232
|
+
* Uploads a pack bundle: a gzip-compressed tar with `b3pack.json` at its root plus the files it references (at
|
|
233
|
+
* most 2,000 files and 16 MiB once decompressed; other organizations are refused before the upload is read). The
|
|
234
|
+
* manifest's `signature` must verify: `sig` is Ed25519 over `b3pack-sig-v1\n<pack>\n<version>\n<contentHash>`
|
|
235
|
+
* with the publisher key `kid`, and `contentHash` covers the bundle with the signature removed. Versions are
|
|
236
|
+
* immutable. In the beta only first-party publishers (`io.b3os`) may publish.
|
|
237
|
+
*
|
|
238
|
+
* `POST /v1/actions/registry/packs` · scope `actions:write` · served by beta-api.b3os.org
|
|
239
|
+
*/
|
|
240
|
+
publishPack(data: BinaryInput, options?: RequestOptions): APIPromise<T.RegistryPackVersion> {
|
|
241
|
+
return this._client._call<T.RegistryPackVersion>(publishPackOp, { body: data }, options);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Get a registry pack
|
|
246
|
+
*
|
|
247
|
+
* Returns one pack's registry record with every published version.
|
|
248
|
+
*
|
|
249
|
+
* `GET /v1/actions/registry/packs/{namespace}/{name}` · scope `actions:read` · served by beta-api.b3os.org
|
|
250
|
+
*/
|
|
251
|
+
getRegistryPack(namespace: string, name: string, options?: RequestOptions): APIPromise<T.RegistryPack> {
|
|
252
|
+
return this._client._call<T.RegistryPack>(getRegistryPackOp, { path: [namespace, name] }, options);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Get a registry pack version
|
|
257
|
+
*
|
|
258
|
+
* Returns the record nodes verify before loading a pack version (content hash, signature, publisher key) and its download URL.
|
|
259
|
+
*
|
|
260
|
+
* `GET /v1/actions/registry/packs/{namespace}/{name}/versions/{version}` · scope `actions:read` · served by beta-api.b3os.org
|
|
261
|
+
*/
|
|
262
|
+
getRegistryPackVersion(
|
|
263
|
+
namespace: string,
|
|
264
|
+
name: string,
|
|
265
|
+
version: string,
|
|
266
|
+
options?: RequestOptions,
|
|
267
|
+
): APIPromise<T.RegistryPackVersion> {
|
|
268
|
+
return this._client._call<T.RegistryPackVersion>(
|
|
269
|
+
getRegistryPackVersionOp,
|
|
270
|
+
{ path: [namespace, name, version] },
|
|
271
|
+
options,
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Download a pack version
|
|
277
|
+
*
|
|
278
|
+
* Redirects to a short-lived signed URL for the bundle. Verify `content_hash` and the signature before loading it.
|
|
279
|
+
*
|
|
280
|
+
* `GET /v1/actions/registry/packs/{namespace}/{name}/versions/{version}/download` · scope `actions:read` · served by beta-api.b3os.org
|
|
281
|
+
*/
|
|
282
|
+
downloadPack(namespace: string, name: string, version: string, options?: RequestOptions): APIPromise<Uint8Array> {
|
|
283
|
+
return this._client._call<Uint8Array>(
|
|
284
|
+
downloadPackOp,
|
|
285
|
+
{ path: [namespace, name, version] },
|
|
286
|
+
options,
|
|
287
|
+
"application/gzip, application/octet-stream",
|
|
288
|
+
"bytes",
|
|
289
|
+
);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Search actions
|
|
294
|
+
*
|
|
295
|
+
* Full-text search over action titles, descriptions and pack names, ranked for agents. Returns references you
|
|
296
|
+
* can pass to describe and call. The same results back the `actions_search` MCP tool.
|
|
297
|
+
*
|
|
298
|
+
* `GET /v1/actions/search` · scope `actions:read` · served by the node
|
|
299
|
+
*/
|
|
300
|
+
search(params: T.ActionsSearchParams, options?: RequestOptions): APIPromise<T.ActionSearchResult> {
|
|
301
|
+
return this._client._call<T.ActionSearchResult>(searchOp, { query: params }, options);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* List trigger subscriptions
|
|
306
|
+
*
|
|
307
|
+
* Lists the trigger subscriptions in your project, newest first. A subscription connects one `type: action`
|
|
308
|
+
* trigger of a published routine version to a pack trigger: publishing the version creates or updates it,
|
|
309
|
+
* and a rollback to a version without that trigger, a version that drops it, or deleting the routine removes
|
|
310
|
+
* it. Subscriptions are read-only here; change them by publishing the routine. Filter by routine or pack.
|
|
311
|
+
*
|
|
312
|
+
* `GET /v1/actions/subscriptions` · scope `actions:read` · served by the node
|
|
313
|
+
*/
|
|
314
|
+
listSubscriptions(
|
|
315
|
+
params?: T.ActionsListSubscriptionsParams,
|
|
316
|
+
options?: RequestOptions,
|
|
317
|
+
): ListPromise<T.TriggerSubscriptionList, T.TriggerSubscription> {
|
|
318
|
+
return this._client._list<T.TriggerSubscriptionList, T.TriggerSubscription>(
|
|
319
|
+
listSubscriptionsOp,
|
|
320
|
+
{ query: params },
|
|
321
|
+
options,
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Get a trigger subscription
|
|
327
|
+
*
|
|
328
|
+
* Returns one trigger subscription: the routine trigger it serves, the exact pack trigger version, the
|
|
329
|
+
* configuration and connections bound at publish, and its status (`failed` with `error` when subscribing at
|
|
330
|
+
* the provider failed; B3OS retries).
|
|
331
|
+
*
|
|
332
|
+
* `GET /v1/actions/subscriptions/{subscription_id}` · scope `actions:read` · served by the node
|
|
333
|
+
*/
|
|
334
|
+
getSubscription(subscriptionId: string, options?: RequestOptions): APIPromise<T.TriggerSubscription> {
|
|
335
|
+
return this._client._call<T.TriggerSubscription>(getSubscriptionOp, { path: [subscriptionId] }, options);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* List triggers
|
|
340
|
+
*
|
|
341
|
+
* Lists the triggers packs provide (webhook, poll and schedule), with their configuration and event schemas.
|
|
342
|
+
* Routines subscribe to them from their definition with a `type: action` trigger; each published one becomes a
|
|
343
|
+
* trigger subscription (`GET /v1/actions/subscriptions`).
|
|
344
|
+
*
|
|
345
|
+
* `GET /v1/actions/triggers` · scope `actions:read` · served by the node
|
|
346
|
+
*/
|
|
347
|
+
listTriggers(
|
|
348
|
+
params?: T.ActionsListTriggersParams,
|
|
349
|
+
options?: RequestOptions,
|
|
350
|
+
): ListPromise<T.TriggerList, T.TriggerSummary> {
|
|
351
|
+
return this._client._list<T.TriggerList, T.TriggerSummary>(listTriggersOp, { query: params }, options);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
// Generated by packages/sdk/scripts/generate.mjs from packages/spec/dist. Do not edit; run `pnpm generate`.
|
|
2
|
+
|
|
3
|
+
import type { RequestOptions, StreamOptions } from "../../core/client.ts";
|
|
4
|
+
import { Namespace } from "../../core/namespace.ts";
|
|
5
|
+
import type { Op } from "../../core/op.ts";
|
|
6
|
+
import type { APIPromise } from "../../core/promise.ts";
|
|
7
|
+
import type { EventStream } from "../../core/sse.ts";
|
|
8
|
+
import type * as T from "../types.ts";
|
|
9
|
+
|
|
10
|
+
const createSpeechOp: Op = {
|
|
11
|
+
id: "inferCreateSpeech",
|
|
12
|
+
method: "POST",
|
|
13
|
+
path: "/v1/infer/audio/speech",
|
|
14
|
+
body: "json",
|
|
15
|
+
timeoutMs: 65000,
|
|
16
|
+
errorFormat: "openai",
|
|
17
|
+
scope: "infer:run",
|
|
18
|
+
};
|
|
19
|
+
const listVoicesOp: Op = {
|
|
20
|
+
id: "inferListVoices",
|
|
21
|
+
method: "GET",
|
|
22
|
+
path: "/v1/infer/audio/voices",
|
|
23
|
+
timeoutMs: 10000,
|
|
24
|
+
scope: "infer:read",
|
|
25
|
+
};
|
|
26
|
+
const createChatCompletionOp: Op = {
|
|
27
|
+
id: "inferCreateChatCompletion",
|
|
28
|
+
method: "POST",
|
|
29
|
+
path: "/v1/infer/chat/completions",
|
|
30
|
+
body: "json",
|
|
31
|
+
stream: "sse",
|
|
32
|
+
timeoutMs: 600000,
|
|
33
|
+
errorFormat: "openai",
|
|
34
|
+
scope: "infer:run",
|
|
35
|
+
};
|
|
36
|
+
const createEmbeddingsOp: Op = {
|
|
37
|
+
id: "inferCreateEmbeddings",
|
|
38
|
+
method: "POST",
|
|
39
|
+
path: "/v1/infer/embeddings",
|
|
40
|
+
body: "json",
|
|
41
|
+
timeoutMs: 65000,
|
|
42
|
+
errorFormat: "openai",
|
|
43
|
+
stretch: true,
|
|
44
|
+
scope: "infer:run",
|
|
45
|
+
};
|
|
46
|
+
const listModelsOp: Op = {
|
|
47
|
+
id: "inferListModels",
|
|
48
|
+
method: "GET",
|
|
49
|
+
path: "/v1/infer/models",
|
|
50
|
+
timeoutMs: 10000,
|
|
51
|
+
errorFormat: "openai",
|
|
52
|
+
scope: "infer:read",
|
|
53
|
+
};
|
|
54
|
+
const getModelOp: Op = {
|
|
55
|
+
id: "inferGetModel",
|
|
56
|
+
method: "GET",
|
|
57
|
+
path: "/v1/infer/models/{model}",
|
|
58
|
+
params: ["model"],
|
|
59
|
+
wildcard: "model",
|
|
60
|
+
timeoutMs: 10000,
|
|
61
|
+
errorFormat: "openai",
|
|
62
|
+
scope: "infer:read",
|
|
63
|
+
};
|
|
64
|
+
const createResponseOp: Op = {
|
|
65
|
+
id: "inferCreateResponse",
|
|
66
|
+
method: "POST",
|
|
67
|
+
path: "/v1/infer/responses",
|
|
68
|
+
body: "json",
|
|
69
|
+
stream: "sse",
|
|
70
|
+
timeoutMs: 600000,
|
|
71
|
+
errorFormat: "openai",
|
|
72
|
+
stretch: true,
|
|
73
|
+
scope: "infer:run",
|
|
74
|
+
};
|
|
75
|
+
const createMessageOp: Op = {
|
|
76
|
+
id: "inferCreateMessage",
|
|
77
|
+
method: "POST",
|
|
78
|
+
path: "/v1/infer/v1/messages",
|
|
79
|
+
body: "json",
|
|
80
|
+
stream: "sse",
|
|
81
|
+
timeoutMs: 600000,
|
|
82
|
+
errorFormat: "openai",
|
|
83
|
+
stretch: true,
|
|
84
|
+
scope: "infer:run",
|
|
85
|
+
};
|
|
86
|
+
const countMessageTokensOp: Op = {
|
|
87
|
+
id: "inferCountMessageTokens",
|
|
88
|
+
method: "POST",
|
|
89
|
+
path: "/v1/infer/v1/messages/count_tokens",
|
|
90
|
+
body: "json",
|
|
91
|
+
timeoutMs: 30000,
|
|
92
|
+
errorFormat: "openai",
|
|
93
|
+
stretch: true,
|
|
94
|
+
scope: "infer:run",
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
/** Descriptors of every infer operation, keyed by method name (for tooling and custom clients). */
|
|
98
|
+
export const inferOps = {
|
|
99
|
+
createSpeech: createSpeechOp,
|
|
100
|
+
listVoices: listVoicesOp,
|
|
101
|
+
createChatCompletion: createChatCompletionOp,
|
|
102
|
+
createEmbeddings: createEmbeddingsOp,
|
|
103
|
+
listModels: listModelsOp,
|
|
104
|
+
getModel: getModelOp,
|
|
105
|
+
createResponse: createResponseOp,
|
|
106
|
+
createMessage: createMessageOp,
|
|
107
|
+
countMessageTokens: countMessageTokensOp,
|
|
108
|
+
} as const;
|
|
109
|
+
|
|
110
|
+
/** Models on the node: OpenAI-compatible chat, embeddings and speech (`/v1/infer`). */
|
|
111
|
+
export class InferAPI extends Namespace {
|
|
112
|
+
/**
|
|
113
|
+
* Create speech
|
|
114
|
+
*
|
|
115
|
+
* The OpenAI speech API: synthesizes `input` with a voice and returns the audio bytes. B3OS extension:
|
|
116
|
+
* `timestamps: "word"` returns JSON instead, with the audio base64-encoded and the start and end time of every
|
|
117
|
+
* word, which render uses to place clicks on words and cut captions. Every `response_format` is produced:
|
|
118
|
+
* `mp3`, `opus` (Ogg), `aac` (ADTS), `flac`, `wav` and `pcm` (16-bit mono at `sample_rate`, 24 kHz for
|
|
119
|
+
* `kokoro-82m`). `kokoro-82m` speaks at `speed` 0.5 to 2 and takes no `instructions`; other values return
|
|
120
|
+
* `400 unsupported_parameter`. While the node's voice service is down the answer is
|
|
121
|
+
* `503 infer_backend_unavailable` with `Retry-After`. `Server-Timing` carries the voice service's own
|
|
122
|
+
* `voice_queue` and `voice_run` beside b3osd's `synthesize` and `encode`. Bills `infer.audio_chars`
|
|
123
|
+
* (characters of `input`).
|
|
124
|
+
*
|
|
125
|
+
* `POST /v1/infer/audio/speech` · scope `infer:run` · served by the node
|
|
126
|
+
*/
|
|
127
|
+
createSpeech(
|
|
128
|
+
body: T.SpeechRequest & { timestamps: "word" },
|
|
129
|
+
options?: RequestOptions,
|
|
130
|
+
): APIPromise<T.SpeechWithTimestamps>;
|
|
131
|
+
createSpeech(body: T.SpeechRequest, options?: RequestOptions): APIPromise<Uint8Array>;
|
|
132
|
+
createSpeech(body: T.SpeechRequest, options: RequestOptions = {}): APIPromise<T.SpeechWithTimestamps | Uint8Array> {
|
|
133
|
+
if ((body as { timestamps?: string }).timestamps === "word") {
|
|
134
|
+
return this._client._call<T.SpeechWithTimestamps>(createSpeechOp, { body }, options);
|
|
135
|
+
}
|
|
136
|
+
return this._client._call<Uint8Array>(
|
|
137
|
+
createSpeechOp,
|
|
138
|
+
{ body },
|
|
139
|
+
options,
|
|
140
|
+
"audio/mpeg, audio/wav, audio/pcm, audio/ogg, audio/aac, audio/flac",
|
|
141
|
+
"bytes",
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* List voices
|
|
147
|
+
*
|
|
148
|
+
* Lists the voices each speech model offers, with language and an audio sample. A B3OS endpoint (not part of
|
|
149
|
+
* the OpenAI API), so it uses B3OS lists and errors: `503 infer_backend_unavailable` with `Retry-After` while
|
|
150
|
+
* the voice service is down. All voices arrive in one page (`next_cursor` is always `null`).
|
|
151
|
+
*
|
|
152
|
+
* `GET /v1/infer/audio/voices` · scope `infer:read` · served by the node
|
|
153
|
+
*/
|
|
154
|
+
listVoices(params?: T.InferListVoicesParams, options?: RequestOptions): APIPromise<T.VoiceList> {
|
|
155
|
+
return this._client._call<T.VoiceList>(listVoicesOp, { query: params }, options);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Create a chat completion
|
|
160
|
+
*
|
|
161
|
+
* The OpenAI Chat Completions API: messages (text and, on models with `image_input`, images), tools and
|
|
162
|
+
* tool choice, `response_format` with JSON Schema, sampling parameters and streaming. With `stream: true` the
|
|
163
|
+
* response is server-sent events of `chat.completion.chunk` objects ending with `data: [DONE]`, exactly as
|
|
164
|
+
* OpenAI sends them; `stream_options.include_usage` adds a final usage chunk (and `"usage": null` on the
|
|
165
|
+
* others). A stream that fails after it started ends with an OpenAI error event
|
|
166
|
+
* (`data: {"error": {...}}`); one that fails before the first token is a plain HTTP error. The response head
|
|
167
|
+
* of a stream waits for the first generated token, so `Server-Timing` can carry `ttft`.
|
|
168
|
+
*
|
|
169
|
+
* Parameters this node does not take return `400 unsupported_parameter` naming the parameter. Besides the
|
|
170
|
+
* OpenAI parameters below, it takes the sampling extensions `top_k`, `min_p`, `repetition_penalty` and
|
|
171
|
+
* `logit_bias`, and `chat_template_kwargs.enable_thinking` (the model answers without a reasoning phase
|
|
172
|
+
* unless it is `true`; the reasoning then arrives in `reasoning_content`). `metadata`, `store` and
|
|
173
|
+
* `service_tier` are accepted and ignored. `null` means unset for every optional parameter. Image URLs are
|
|
174
|
+
* `https://` (fetched by the node through its egress guard, which refuses private, loopback and metadata
|
|
175
|
+
* addresses with `403 egress_denied`) or `data:image/{png,jpeg,webp,gif};base64,`. JSON Schemas (tool
|
|
176
|
+
* `parameters`, `response_format.json_schema.schema`) larger than 64 KiB or nested deeper than 32 levels are
|
|
177
|
+
* `400 unsupported_parameter`.
|
|
178
|
+
*
|
|
179
|
+
* Bills input and output tokens. Requests are admitted against your organization's per-minute limits on the
|
|
180
|
+
* model: one request, and the estimated prompt plus `max_completion_tokens` (or `max_tokens`, else 512
|
|
181
|
+
* tokens), settled with the real counts when the request ends.
|
|
182
|
+
*
|
|
183
|
+
* `POST /v1/infer/chat/completions` · scope `infer:run` · served by the node
|
|
184
|
+
*/
|
|
185
|
+
createChatCompletion(
|
|
186
|
+
body: T.ChatCompletionRequest & { stream: true },
|
|
187
|
+
options?: StreamOptions,
|
|
188
|
+
): EventStream<T.ChatCompletionChunk>;
|
|
189
|
+
createChatCompletion(
|
|
190
|
+
body: T.ChatCompletionRequest & { stream?: false | null },
|
|
191
|
+
options?: RequestOptions,
|
|
192
|
+
): APIPromise<T.ChatCompletion>;
|
|
193
|
+
createChatCompletion(
|
|
194
|
+
body: T.ChatCompletionRequest,
|
|
195
|
+
options: StreamOptions = {},
|
|
196
|
+
): APIPromise<T.ChatCompletion> | EventStream<T.ChatCompletionChunk> {
|
|
197
|
+
if (body.stream) {
|
|
198
|
+
return this._client._postStream<T.ChatCompletionChunk>(createChatCompletionOp, { body }, options, {
|
|
199
|
+
doneSentinel: true,
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
return this._client._call<T.ChatCompletion>(createChatCompletionOp, { body }, options);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Create embeddings
|
|
207
|
+
*
|
|
208
|
+
* The OpenAI Embeddings API, for embedding models the node serves (`b3os.kind` is `embedding`). Other models
|
|
209
|
+
* return `404 model_not_available`; the beta node serves no embedding model yet. Bills input tokens.
|
|
210
|
+
*
|
|
211
|
+
* `POST /v1/infer/embeddings` · scope `infer:run` · served by the node
|
|
212
|
+
*
|
|
213
|
+
* Stretch: in the contract, but may answer `501 not_implemented` on this deployment.
|
|
214
|
+
*/
|
|
215
|
+
createEmbeddings(body: T.EmbeddingRequest, options?: RequestOptions): APIPromise<T.EmbeddingList> {
|
|
216
|
+
return this._client._call<T.EmbeddingList>(createEmbeddingsOp, { body }, options);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* List models
|
|
221
|
+
*
|
|
222
|
+
* The OpenAI model list for the models this node serves, each with a `b3os` object: context length,
|
|
223
|
+
* quantization, whether it supports tools, JSON Schema output and image input, the largest accepted request,
|
|
224
|
+
* and your per-model token and request limits. Chat models are listed while the node's model runtime is
|
|
225
|
+
* configured (one that is restarting is still listed; requests get `503` with `Retry-After`); speech models
|
|
226
|
+
* while the voice service answers.
|
|
227
|
+
*
|
|
228
|
+
* `GET /v1/infer/models` · scope `infer:read` · served by the node
|
|
229
|
+
*/
|
|
230
|
+
listModels(options?: RequestOptions): APIPromise<T.ModelList> {
|
|
231
|
+
return this._client._call<T.ModelList>(listModelsOp, {}, options);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Get a model
|
|
236
|
+
*
|
|
237
|
+
* One model from the list, by ID. IDs may contain a slash (`b3os/qwen3.5-9b`); send it unencoded.
|
|
238
|
+
*
|
|
239
|
+
* `GET /v1/infer/models/{model}` · scope `infer:read` · served by the node
|
|
240
|
+
*/
|
|
241
|
+
getModel(model: string, options?: RequestOptions): APIPromise<T.Model> {
|
|
242
|
+
return this._client._call<T.Model>(getModelOp, { path: [model] }, options);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Create a response (OpenAI Responses API)
|
|
247
|
+
*
|
|
248
|
+
* A stateless subset of the OpenAI Responses API on the node's own models, for SDKs and agent frameworks that
|
|
249
|
+
* speak Responses (the OpenAI Agents SDK among them) with only the base URL changed: `input` as a string or
|
|
250
|
+
* as items (`message` with `input_text` and `input_image` parts, or `output_text` for assistant turns;
|
|
251
|
+
* `function_call`, `function_call_output` and `reasoning` items), `instructions`, function tools with
|
|
252
|
+
* `tool_choice` and `parallel_tool_calls`, structured output through `text.format` (`json_schema`,
|
|
253
|
+
* `json_object`), `reasoning.effort` (`low` and above turn the model's reasoning phase on; its text arrives
|
|
254
|
+
* in `reasoning` items), `max_output_tokens`, `temperature`, `top_p`, and the Responses event stream
|
|
255
|
+
* (`response.created` ... `response.completed`, as OpenAI sends them).
|
|
256
|
+
*
|
|
257
|
+
* Nothing is stored: send the whole conversation as `input` items each turn. `previous_response_id`,
|
|
258
|
+
* `conversation`, `prompt`, `background: true` and `truncation: "auto"` are `400 unsupported_parameter`;
|
|
259
|
+
* `store`, `metadata` (echoed), `user`, `safety_identifier`, `prompt_cache_key`, `service_tier`,
|
|
260
|
+
* `text.verbosity`, `reasoning.summary` and `include: ["reasoning.encrypted_content"]` are accepted and
|
|
261
|
+
* ignored, and every response reports `store: false`. Tools other than `function` (web search, file
|
|
262
|
+
* search, computer use, code interpreter, MCP, image generation, shell) run on OpenAI's side and are
|
|
263
|
+
* `400 unsupported_parameter`. `null` means unset for every optional parameter. Images and JSON Schemas
|
|
264
|
+
* have the limits of chat completions. A stream that fails after it started ends with an `error` event; one
|
|
265
|
+
* that fails before the first token is a plain HTTP error. The response head of a stream waits for the
|
|
266
|
+
* first generated token, so `Server-Timing` can carry `ttft`.
|
|
267
|
+
*
|
|
268
|
+
* Bills input and output tokens, with the admission and limits of chat completions (the estimated prompt
|
|
269
|
+
* plus `max_output_tokens`, else 512 tokens, settled with the real counts; an abandoned stream is billed to
|
|
270
|
+
* its last token).
|
|
271
|
+
*
|
|
272
|
+
* `POST /v1/infer/responses` · scope `infer:run` · served by the node
|
|
273
|
+
*
|
|
274
|
+
* Stretch: in the contract, but may answer `501 not_implemented` on this deployment.
|
|
275
|
+
*/
|
|
276
|
+
createResponse(body: T.ResponsesRequest, options?: RequestOptions): APIPromise<T.ResponsesResponse> {
|
|
277
|
+
return this._client._call<T.ResponsesResponse>(createResponseOp, { body }, options);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Create a message (Anthropic Messages API)
|
|
282
|
+
*
|
|
283
|
+
* The Anthropic Messages API on the node's own model, so Anthropic SDKs and agents built on them run against
|
|
284
|
+
* it with only the base URL and the credential changed: set `ANTHROPIC_BASE_URL` (or `base_url`) to
|
|
285
|
+
* `https://beta-api.b3os.org/v1/infer`, the same base URL as the OpenAI SDKs (`http://127.0.0.1:7700/v1/infer`
|
|
286
|
+
* inside a sandbox; the SDKs add `/v1/messages`), and send the B3OS key as a bearer token
|
|
287
|
+
* (`ANTHROPIC_AUTH_TOKEN`, or `auth_token` in the SDKs). Text, images (`base64`, or `url` sources fetched by
|
|
288
|
+
* the node through its egress guard), custom tools with `tool_use` and `tool_result` blocks, `tool_choice`,
|
|
289
|
+
* `thinking` (the reasoning arrives in `thinking` blocks; `budget_tokens` caps it), JSON Schema output
|
|
290
|
+
* through `output_config.format`, stop sequences, a trailing assistant turn that the model continues, and
|
|
291
|
+
* streaming events (`message_start` ... `message_stop`, exactly as Anthropic sends them). Models are those
|
|
292
|
+
* of `GET /v1/infer/models`; there is no gateway route here.
|
|
293
|
+
*
|
|
294
|
+
* Parameters this node does not take return `400 unsupported_parameter` (tools Anthropic defines or runs,
|
|
295
|
+
* such as `web_search` or `bash`, `container`, `mcp_servers`, document and file sources).
|
|
296
|
+
* `cache_control`, `citations`, `metadata`, `service_tier`, `output_config.effort` and `thinking.display`
|
|
297
|
+
* are accepted and ignored (the runtime caches prompt prefixes on its own). Errors use the Anthropic shape
|
|
298
|
+
* (`{"type": "error", "error": {...}}`, with the B3OS code under `b3os`), except those raised before the
|
|
299
|
+
* request reaches the infer service (authentication, scopes, body size), which use the OpenAI shape of the
|
|
300
|
+
* rest of `/v1/infer`; Anthropic SDKs map both by HTTP status. A stream that fails after it started ends
|
|
301
|
+
* with an `error` event; one that fails before the first token is a plain HTTP error. The response head of
|
|
302
|
+
* a stream waits for the first generated token, so `Server-Timing` can carry `ttft`.
|
|
303
|
+
*
|
|
304
|
+
* Bills input and output tokens, with the admission and limits of chat completions (the estimated prompt
|
|
305
|
+
* plus `max_tokens`, settled with the real counts; an abandoned stream is billed to its last token).
|
|
306
|
+
*
|
|
307
|
+
* `POST /v1/infer/v1/messages` · scope `infer:run` · served by the node
|
|
308
|
+
*
|
|
309
|
+
* Stretch: in the contract, but may answer `501 not_implemented` on this deployment.
|
|
310
|
+
*/
|
|
311
|
+
createMessage(body: T.AnthropicMessagesRequest, options?: RequestOptions): APIPromise<T.AnthropicMessage> {
|
|
312
|
+
return this._client._call<T.AnthropicMessage>(createMessageOp, { body }, options);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Count the tokens of a message request
|
|
317
|
+
*
|
|
318
|
+
* The Anthropic token-counting API: the input tokens a Messages request with the same `messages`, `system`,
|
|
319
|
+
* `tools`, `tool_choice` and `thinking` would use, counted by the model runtime with the model's own chat
|
|
320
|
+
* template (images included). Free: it counts against your requests per minute, not your tokens.
|
|
321
|
+
*
|
|
322
|
+
* `POST /v1/infer/v1/messages/count_tokens` · scope `infer:run` · served by the node
|
|
323
|
+
*
|
|
324
|
+
* Stretch: in the contract, but may answer `501 not_implemented` on this deployment.
|
|
325
|
+
*/
|
|
326
|
+
countMessageTokens(
|
|
327
|
+
body: T.AnthropicCountTokensRequest,
|
|
328
|
+
options?: RequestOptions,
|
|
329
|
+
): APIPromise<T.AnthropicCountTokens> {
|
|
330
|
+
return this._client._call<T.AnthropicCountTokens>(countMessageTokensOp, { body }, options);
|
|
331
|
+
}
|
|
332
|
+
}
|