@b3os/sdk 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/cjs/core/sse.d.ts +2 -0
  2. package/dist/cjs/core/sse.js +17 -5
  3. package/dist/cjs/core/sse.js.map +1 -1
  4. package/dist/cjs/core/util.d.ts +1 -1
  5. package/dist/cjs/core/util.js +1 -1
  6. package/dist/cjs/generated/errors.d.ts +1 -1
  7. package/dist/cjs/generated/errors.js +20 -0
  8. package/dist/cjs/generated/errors.js.map +1 -1
  9. package/dist/cjs/generated/ns/actions.d.ts +66 -1
  10. package/dist/cjs/generated/ns/actions.js +101 -1
  11. package/dist/cjs/generated/ns/actions.js.map +1 -1
  12. package/dist/cjs/generated/types.d.ts +218 -12
  13. package/dist/cjs/helpers/sandboxes.d.ts +26 -2
  14. package/dist/cjs/helpers/sandboxes.js +114 -13
  15. package/dist/cjs/helpers/sandboxes.js.map +1 -1
  16. package/dist/cjs/index.d.ts +1 -1
  17. package/dist/cjs/index.js +2 -1
  18. package/dist/cjs/index.js.map +1 -1
  19. package/dist/esm/core/sse.d.ts +2 -0
  20. package/dist/esm/core/sse.js +17 -5
  21. package/dist/esm/core/sse.js.map +1 -1
  22. package/dist/esm/core/util.d.ts +1 -1
  23. package/dist/esm/core/util.js +1 -1
  24. package/dist/esm/generated/errors.d.ts +1 -1
  25. package/dist/esm/generated/errors.js +20 -0
  26. package/dist/esm/generated/errors.js.map +1 -1
  27. package/dist/esm/generated/ns/actions.d.ts +66 -1
  28. package/dist/esm/generated/ns/actions.js +101 -1
  29. package/dist/esm/generated/ns/actions.js.map +1 -1
  30. package/dist/esm/generated/types.d.ts +218 -12
  31. package/dist/esm/helpers/sandboxes.d.ts +26 -2
  32. package/dist/esm/helpers/sandboxes.js +113 -12
  33. package/dist/esm/helpers/sandboxes.js.map +1 -1
  34. package/dist/esm/index.d.ts +1 -1
  35. package/dist/esm/index.js +1 -1
  36. package/dist/esm/index.js.map +1 -1
  37. package/package.json +1 -1
  38. package/src/core/sse.ts +17 -5
  39. package/src/core/util.ts +1 -1
  40. package/src/generated/errors.ts +40 -0
  41. package/src/generated/ns/actions.ts +110 -1
  42. package/src/generated/types.ts +232 -11
  43. package/src/helpers/sandboxes.ts +136 -12
  44. package/src/index.ts +1 -0
@@ -54,6 +54,35 @@ const getPackManifestOp: Op = {
54
54
  timeoutMs: 10000,
55
55
  scope: "actions:read",
56
56
  };
57
+ const getRegistryBlobOp: Op = {
58
+ id: "platformGetRegistryBlob",
59
+ method: "GET",
60
+ path: "/v1/actions/registry/blobs/{digest}",
61
+ params: ["digest"],
62
+ edge: true,
63
+ timeoutMs: 10000,
64
+ scope: "actions:read",
65
+ };
66
+ const headRegistryBlobOp: Op = {
67
+ id: "platformHeadRegistryBlob",
68
+ method: "HEAD",
69
+ path: "/v1/actions/registry/blobs/{digest}",
70
+ params: ["digest"],
71
+ edge: true,
72
+ timeoutMs: 10000,
73
+ scope: "actions:tools:publish",
74
+ };
75
+ const putRegistryBlobOp: Op = {
76
+ id: "platformPutRegistryBlob",
77
+ method: "PUT",
78
+ path: "/v1/actions/registry/blobs/{digest}",
79
+ params: ["digest"],
80
+ body: "bytes",
81
+ contentType: "application/octet-stream",
82
+ edge: true,
83
+ timeoutMs: 60000,
84
+ scope: "actions:tools:publish",
85
+ };
57
86
  const listRegistryPacksOp: Op = {
58
87
  id: "platformListRegistryPacks",
59
88
  method: "GET",
@@ -137,6 +166,9 @@ export const actionsOps = {
137
166
  getPack: getPackOp,
138
167
  getPackTools: getPackToolsOp,
139
168
  getPackManifest: getPackManifestOp,
169
+ getRegistryBlob: getRegistryBlobOp,
170
+ headRegistryBlob: headRegistryBlobOp,
171
+ putRegistryBlob: putRegistryBlobOp,
140
172
  listRegistryPacks: listRegistryPacksOp,
141
173
  publishPack: publishPackOp,
142
174
  getRegistryPack: getRegistryPackOp,
@@ -182,6 +214,25 @@ export class ActionsAPI extends Namespace {
182
214
  * (response mapping and output schema) for declarative HTTP actions; `sidecar` for JavaScript actions.
183
215
  * Bills one `actions.call` once the action ran.
184
216
  *
217
+ * **Hosted tools** (a preview, on for every organization in the beta; without `actions.tools` a `vm` call is
218
+ * `404 feature_not_enabled` and nothing runs). A `vm` action runs its publisher's command in a fresh microVM
219
+ * with no network, made for this call only and deleted before the call answers. A file field of the input
220
+ * schema (`x-b3os-file`) takes a file value inline, `{"$bytes": "<base64>", "name": "<name>"}` with `name`
221
+ * matching `^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$` (`ToolFileInput`); an output file comes back as
222
+ * `{"$bytes", "name", "bytes", "contentType"}` (`ToolFileOutput`), 262144 bytes of files in all. The budget is
223
+ * the least of `timeout_ms`, the action's own timeout and 60 seconds; a priced action refuses a `timeout_ms`
224
+ * below its own (`400 invalid_request`) here, and runs to its own timeout when a routine step calls it. Every
225
+ * call is a fresh VM, and a call that finished is charged even if the client had stopped waiting: send
226
+ * `Idempotency-Key` with a priced call, so a retry with the same key gets the stored answer and is not charged
227
+ * again (a routine step's retry with its key gets the answer of the call it started). Per organization: 120 tool calls started a minute, 4 at once, and
228
+ * 20 USD of publisher prices a month, counted on each node (`429`); per node, a limit of tool VMs at once (`503 tool_unavailable`,
229
+ * `reason: node_busy`). The answer has `tier: vm`, `cost` in micro-USD, and the `timing` phases `validate`,
230
+ * `start`, `copy`, `unpack`, `run`, `collect`, `delete` and `cost`. A tool call bills `actions.tool_call` (the
231
+ * floor, once the command ran) instead of `actions.call`, the VM's `actions.vcpu_ms` and `actions.gib_ms`,
232
+ * and, once the tool answered, its output matched its schema and its output files were read, the publisher's
233
+ * price as `actions.publisher_microusd`. A failure
234
+ * before the command ran bills nothing; a failure of the tool bills compute and the floor and no price.
235
+ *
185
236
  * `POST /v1/actions/call` · scope `actions:run` · served by the node
186
237
  */
187
238
  call(body: T.ActionCallRequest, options?: RequestOptions): APIPromise<T.ActionResult> {
@@ -263,6 +314,56 @@ export class ActionsAPI extends Namespace {
263
314
  return this._client._call<T.B3Pack>(getPackManifestOp, { path: [namespace, name, version] }, options);
264
315
  }
265
316
 
317
+ /**
318
+ * Download a hosted tool's archive
319
+ *
320
+ * Redirects to a short-lived signed URL for the archive (`application/octet-stream`). Served to a node's
321
+ * registry sync (a node-signed read), to the organization the publisher list names for a namespace that
322
+ * published a pack naming this archive, and to B3's organizations; to anyone else it is `404`, as if it did
323
+ * not exist. Verify the sha256 before use.
324
+ *
325
+ * `GET /v1/actions/registry/blobs/{digest}` · scope `actions:read` · served by beta-api.b3os.org
326
+ */
327
+ getRegistryBlob(digest: string, options?: RequestOptions): APIPromise<Uint8Array> {
328
+ return this._client._call<Uint8Array>(
329
+ getRegistryBlobOp,
330
+ { path: [digest] },
331
+ options,
332
+ "application/gzip, application/octet-stream",
333
+ "bytes",
334
+ );
335
+ }
336
+
337
+ /**
338
+ * Check for a hosted tool's archive
339
+ *
340
+ * Answers `200` with the archive's `Content-Length` when the blob store holds `digest`, else `404` (a HEAD
341
+ * answer carries no body). `b3os tool
342
+ * publish` asks before it uploads. Needs the `actions.tools` flag and the scope `actions:tools:publish`.
343
+ *
344
+ * `HEAD /v1/actions/registry/blobs/{digest}` · scope `actions:tools:publish` · served by beta-api.b3os.org
345
+ */
346
+ headRegistryBlob(digest: string, options?: RequestOptions): APIPromise<void> {
347
+ return this._client._call<void>(headRegistryBlobOp, { path: [digest] }, options);
348
+ }
349
+
350
+ /**
351
+ * Upload a hosted tool's archive
352
+ *
353
+ * Stores a hosted tool's archive under its sha256, before the pack that names it is published
354
+ * (`platformPublishPack`). The body is the archive's bytes; `Content-Length` is required and at most
355
+ * 67108864 (64 MiB), and is checked before the body is read. The edge hashes the body as it streams it to
356
+ * storage: a body whose sha256 is not `digest`, or whose length is not `Content-Length`, is deleted and
357
+ * refused with `422 pack_invalid`. No `Content-Length` is `400 invalid_request`. A digest already stored answers `200` and stores nothing, so a retry is
358
+ * safe. Needs the `actions.tools` flag and the scope `actions:tools:publish`, which `*` and `actions:*` never
359
+ * grant; in the beta only B3's organizations may upload.
360
+ *
361
+ * `PUT /v1/actions/registry/blobs/{digest}` · scope `actions:tools:publish` · served by beta-api.b3os.org
362
+ */
363
+ putRegistryBlob(digest: string, data: BinaryInput, options?: RequestOptions): APIPromise<T.RegistryBlob> {
364
+ return this._client._call<T.RegistryBlob>(putRegistryBlobOp, { path: [digest], body: data }, options);
365
+ }
366
+
266
367
  /**
267
368
  * List registry packs
268
369
  *
@@ -284,7 +385,15 @@ export class ActionsAPI extends Namespace {
284
385
  * most 2,000 files and 16 MiB once decompressed; other organizations are refused before the upload is read). The
285
386
  * manifest's `signature` must verify: `sig` is Ed25519 over `b3pack-sig-v1\n<pack>\n<version>\n<contentHash>`
286
387
  * with the publisher key `kid`, and `contentHash` covers the bundle with the signature removed. Versions are
287
- * immutable. In the beta only first-party publishers (`io.b3os`) may publish.
388
+ * immutable. In the beta only B3's organizations may publish, into `io.b3os` or a namespace the registry's
389
+ * publisher list names for the caller's organization.
390
+ *
391
+ * A pack with a `tool` block (a hosted tool) also needs: the `actions.tools` flag for the caller's
392
+ * organization (`404 feature_not_enabled`), the scope `actions:tools:publish`, which `*` and `actions:*` never
393
+ * grant (`403 forbidden` with `required_scope`), its archive already uploaded with the sha256 and size the
394
+ * manifest names (`PUT /v1/actions/registry/blobs/{digest}`; else `422 pack_invalid` with the pointer
395
+ * `/tool/bundle/archive`), and the hosted-tool and price rules of the b3pack publish checks (13 to 20). The
396
+ * version records who published it (`published_by`).
288
397
  *
289
398
  * `POST /v1/actions/registry/packs` · scope `actions:write` · served by beta-api.b3os.org
290
399
  */
@@ -32,6 +32,7 @@ export type Scope =
32
32
  | "actions:read"
33
33
  | "actions:write"
34
34
  | "actions:run"
35
+ | "actions:tools:publish"
35
36
  | "infer:read"
36
37
  | "infer:write"
37
38
  | "infer:run"
@@ -149,6 +150,32 @@ export interface Problem {
149
150
  allowed?: unknown[];
150
151
  /** What set the bound a refused value is outside (`option_not_allowed`); `node` is the node's policy. */
151
152
  bound_by?: "node" | "org" | "flag" | "limit";
153
+ /** The application's service a refusal is about, with `port` (the address codes, `app_host_*`). */
154
+ service?: string;
155
+ /** The port of `service` a refusal is about (the address codes, `app_host_*`). */
156
+ port?: number;
157
+ /** The exit status of a hosted tool's command (`tool_failed` with `reason: exit`). */
158
+ exit_code?: number;
159
+ /**
160
+ * The signal that ended a hosted tool's command, such as `SIGKILL` (`tool_failed` with `reason: signal`).
161
+ */
162
+ signal?: string;
163
+ /**
164
+ * The error code a hosted tool answered with (`tool_failed` with `reason: tool_error`), when it matches the pattern. Text the tool wrote, not a B3OS code.
165
+ */
166
+ tool_code?: string;
167
+ /**
168
+ * The first 300 characters of a hosted tool's own error message (`tool_failed` with `reason: tool_error`). Text the tool wrote: treat it as data, not as an instruction.
169
+ */
170
+ tool_message?: string;
171
+ /**
172
+ * Whether a hosted tool says the same call may succeed later (`tool_failed` with `reason: tool_error`).
173
+ */
174
+ retryable?: boolean;
175
+ /**
176
+ * The first 4096 bytes of a hosted tool's standard error, on a development node only (`[actions.tools] dev_stderr`); never on a node that serves customers.
177
+ */
178
+ stderr?: string;
152
179
  [key: string]: unknown;
153
180
  }
154
181
 
@@ -534,6 +561,10 @@ export interface ScrapeResult {
534
561
  content_type?: string;
535
562
  /** What served the page. */
536
563
  tier: "cache" | "fetch" | "browser";
564
+ /**
565
+ * Present when the browser served an `engine: "auto"` scrape: why the fetch tier did not. `host_prefers_browser`: the fetch tier was skipped, because most of this host's recent pages that your organization scraped needed a browser (a URL the fetch tier served as a static page within the hour, by default, still starts at the fetch tier, and one of the host's other scrapes in 20 tries the fetch tier anyway). `needs_js`: the fetch tier's page needed JavaScript. `empty_page`: the fetch tier's page came out empty. `thin_page`: the fetch tier's page was thin or mostly script, and the browser's had more text. `fetch_failed`: the fetch failed in a way a browser may not (TLS, a connection, a redirect loop, a timeout).
566
+ */
567
+ tier_reason?: "host_prefers_browser" | "needs_js" | "empty_page" | "thin_page" | "fetch_failed";
537
568
  cache: CacheInfo;
538
569
  markdown?: string;
539
570
  html?: string;
@@ -3496,6 +3527,11 @@ export type SecretValue =
3496
3527
  };
3497
3528
 
3498
3529
  export interface SandboxPort {
3530
+ /**
3531
+ * The port the app listens on inside the sandbox. Not 53, 1080, 3128, 7700 or 15001: the B3OS guest agent
3532
+ * listens on those in every sandbox (its API proxy, egress proxies and DNS), so they are never proxied and
3533
+ * a create that declares one is `400 invalid_request`.
3534
+ */
3499
3535
  port: number;
3500
3536
  /**
3501
3537
  * Reachable by anyone with the sandbox's long-lived port URL (`ports[].url` in the sandbox; its token lasts 7
@@ -3511,6 +3547,14 @@ export interface SandboxPort {
3511
3547
  * @default 65
3512
3548
  */
3513
3549
  first_byte_s?: number;
3550
+ /**
3551
+ * The port has an app address (`<label>.b3os.io`); `b3os apply` sets it on such a port and keeps the port
3552
+ * private (no long-lived URL). The sandbox then counts as reachable from the internet for as long as it
3553
+ * lives, as with a public port: code in another sandbox whose egress is not `public` cannot reach into it,
3554
+ * and code in such a sandbox cannot start one with an addressed port (`403 egress_escalation`).
3555
+ * @default false
3556
+ */
3557
+ addressed?: boolean;
3514
3558
  }
3515
3559
 
3516
3560
  /**
@@ -3713,6 +3757,8 @@ export interface Sandbox {
3713
3757
  ports: {
3714
3758
  port: number;
3715
3759
  public: boolean;
3760
+ /** The port has an app address (the create set `addressed`); always sent by this node. */
3761
+ addressed?: boolean;
3716
3762
  /**
3717
3763
  * Public ports: the long-lived preview URL, token included. Private ports: `null`; mint a URL with
3718
3764
  * `POST /v1/sandboxes/{sandbox_id}/ports/{port}/url`. Also `null` when code in another sandbox reads
@@ -4804,7 +4850,7 @@ export interface SignalRequest {
4804
4850
  }
4805
4851
 
4806
4852
  /**
4807
- * One manifest per pack: connections, egress, actions (T0 declarative HTTP or T1 first-party JS), triggers (webhook, poll, schedule), fixtures, pricing and the publisher signature. Field names follow research/b3os-actions.md section 12.3 (camelCase, like MCP). Every string that contains ${{ }} is a CEL template; the template rules and CEL contexts are in packages/spec/schemas/README.md. Rules JSON Schema cannot express (unique action keys, egress subset, connection references, effect consistency) are listed in the README under 'b3pack publish checks' and are enforced by the actions registry and by examples/validate.mjs. Owner after freeze: actions.
4853
+ * One manifest per pack: connections, egress, actions (T0 declarative HTTP, T1 first-party JS, or vm: a hosted tool's command run in a fresh microVM), triggers (webhook, poll, schedule), fixtures, pricing and the publisher signature. A pack whose actions are vm is a hosted tool and has a tool block. Field names follow research/b3os-actions.md section 12.3 (camelCase, like MCP). Every string that contains ${{ }} is a CEL template; the template rules and CEL contexts are in packages/spec/schemas/README.md. Rules JSON Schema cannot express (unique action keys, egress subset, connection references, effect consistency, what a hosted tool may declare in this version) are listed in the README under 'b3pack publish checks' and are enforced by the actions registry and by examples/validate.mjs. Owner after freeze: actions.
4808
4854
  */
4809
4855
  export interface B3Pack {
4810
4856
  /** Optional pointer to this schema for editors. Ignored by the runtime. */
@@ -4837,7 +4883,7 @@ export interface B3Pack {
4837
4883
  sizes?: string[];
4838
4884
  }[];
4839
4885
  /**
4840
- * Pack runtime API the pack needs, as a caret range (npm and Cargo read it the same way). The v1 runtime is 1.0.0, so packs declare ^1 or ^1.0.
4886
+ * Pack runtime API the pack needs, as a caret range (npm and Cargo read it the same way). The runtime is 1.1.0: packs without a tool block declare ^1, ^1.0 or ^1.1; a pack with a tool block declares ^1.1 or later (the vm kind is runtime API 1.1), so a node from before hosted tools refuses it instead of loading half of it.
4841
4887
  */
4842
4888
  engine: string;
4843
4889
  /**
@@ -4851,9 +4897,10 @@ export interface B3Pack {
4851
4897
  actions: B3PackAction[];
4852
4898
  triggers?: B3PackTrigger[];
4853
4899
  /**
4854
- * Default price for every action that does not set its own. v0.1 packs are free; the node still meters actions.call (ARCHITECTURE 4.5).
4900
+ * Default price for every action that does not set its own. A price is charged on vm actions only (a hosted tool's publisher price, usage unit actions.publisher_microusd); packs without vm actions are free and the node still meters actions.call (ARCHITECTURE 4.5).
4855
4901
  */
4856
4902
  pricing?: B3PackPricing;
4903
+ tool?: B3PackTool;
4857
4904
  compat?: {
4858
4905
  /**
4859
4906
  * Maps an action key in this pack to the flat action id it replaces in the old B3OS catalog (research 12.3, 13). Used by the importer so old workflows resolve.
@@ -4915,7 +4962,7 @@ export interface B3PackEgressEntry {
4915
4962
  }
4916
4963
 
4917
4964
  /**
4918
- * A JSON Schema 2020-12 document whose top level describes an object (MCP requires object-typed inputSchema and outputSchema). Objects should be closed (additionalProperties false) unless declared open (research 12.4). x-b3-* keywords (x-b3-widget, x-b3-semantic, x-b3-options, ...) are allowed as annotations and ignored by validation.
4965
+ * A JSON Schema 2020-12 document whose top level describes an object (MCP requires object-typed inputSchema and outputSchema). Objects should be closed (additionalProperties false) unless declared open (research 12.4). x-b3-* keywords (x-b3-widget, x-b3-semantic, x-b3-options, ...) are allowed as annotations and ignored by validation. x-b3os-file marks a file field of a vm action: on a top-level property of inputSchema it is {"accept": [media types]} and the property's value is a file value; on a top-level property of outputSchema it is {"produces": [media types]} and the tool answers {"path": "/out/<name>"} there (README, 'b3pack publish checks' 19).
4919
4966
  */
4920
4967
  export type B3PackJsonSchemaObject = JsonSchemaDocument & {
4921
4968
  type: "object";
@@ -4977,7 +5024,7 @@ export interface B3PackEffects {
4977
5024
  }
4978
5025
 
4979
5026
  /**
4980
- * Publisher price on top of the platform's actions.call meter. v0.1 first-party packs are free. Amounts are decimal strings in USD to avoid float rounding.
5027
+ * Publisher price, charged on vm actions only, on top of the platform's own meters (a hosted tool's call bills actions.tool_call, actions.vcpu_ms and actions.gib_ms; the price is actions.publisher_microusd). First-party packs are free. Amounts are decimal strings in USD to avoid float rounding; the publish checks hold a per_call price to at most 1 USD and 6 decimal places, so it is a whole number of micro-USD.
4981
5028
  */
4982
5029
  export interface B3PackPricing {
4983
5030
  model: "free" | "per_call";
@@ -5037,7 +5084,7 @@ export interface B3PackHttpResponse {
5037
5084
  }
5038
5085
 
5039
5086
  /**
5040
- * How the action runs. http = T0, declarative HTTP inside b3osd. js = T1, a first-party ES module run by the actions-js sidecar (packages/spec/sidecars/actions-js.md).
5087
+ * How the action runs. http = T0, declarative HTTP inside b3osd. js = T1, a first-party ES module run by the actions-js sidecar (packages/spec/sidecars/actions-js.md). vm = a hosted tool: each call runs cmd in a fresh microVM of tool.base with the tool's archive unpacked at /tool, the request as one JSON object on stdin and one JSON object as the last line of stdout (protocol json-stdio, README 'Hosted tools').
5041
5088
  */
5042
5089
  export type B3PackImpl =
5043
5090
  | {
@@ -5056,6 +5103,17 @@ export type B3PackImpl =
5056
5103
  * @default "run"
5057
5104
  */
5058
5105
  export?: string;
5106
+ }
5107
+ | {
5108
+ kind: "vm";
5109
+ /**
5110
+ * The request is one JSON object on stdin; the answer is the last line of stdout, {"output": ...} or {"error": {code, message, retryable}}, with exit status 0 either way.
5111
+ */
5112
+ protocol: "json-stdio";
5113
+ /**
5114
+ * The command and its arguments, run with no shell, working directory /work, as the guest's user. Fixed text: no caller value ever enters it. cmd[0] is a path under /tool/ (publish check 18).
5115
+ */
5116
+ cmd: string[];
5059
5117
  };
5060
5118
 
5061
5119
  export type B3PackExample =
@@ -5094,9 +5152,17 @@ export type B3PackAction = {
5094
5152
  egress?: B3PackEgressEntry[];
5095
5153
  execution?: {
5096
5154
  /**
5097
- * Wall-clock budget per call, including upstream time. Default 10000 for http, 30000 for js. A caller's shorter deadline wins.
5155
+ * Wall-clock budget per call, including upstream time. Default 10000 for http, 30000 for js and vm; at most 60000 for vm. A caller's shorter deadline wins, except on a priced vm action, where a shorter timeout_ms is refused.
5098
5156
  */
5099
5157
  timeoutMs?: number;
5158
+ /**
5159
+ * vm only, reserved for files that are not inline (slice B): the most input file data a call may carry. Refused in this version.
5160
+ */
5161
+ maxInputMb?: number;
5162
+ /** vm only, reserved (slice B): the most output file data a call may return. Refused in this version. */
5163
+ maxOutputMb?: number;
5164
+ /** vm only, reserved (slice B): the most output files a call may return. Refused in this version. */
5165
+ maxOutputFiles?: number;
5100
5166
  /** T1 only: V8 old-generation limit of the worker running the call. Default 128. */
5101
5167
  memoryMb?: number;
5102
5168
  /**
@@ -5271,6 +5337,103 @@ export type B3PackTrigger = {
5271
5337
  aliases?: B3PackSearchPhrases;
5272
5338
  };
5273
5339
 
5340
+ /**
5341
+ * A hosted tool: the software a pack's vm actions run, and what it needs to run. Required when any action is vm and refused otherwise (publish checks 13 to 20). The schema admits the values of later versions (mcp, the other bases, session, hosts, caller, any size) and the reserved keys (setup, image, formats, errors, bundle.files, base.range), so that what this version refuses is refused with a plain sentence of the publish checks rather than a schema error.
5342
+ */
5343
+ export interface B3PackTool {
5344
+ /**
5345
+ * cli: a command that reads a request on stdin and writes an answer on stdout. mcp (later): an MCP server. Shown on the listing.
5346
+ */
5347
+ kind: "cli" | "mcp";
5348
+ /** The shared template the tool runs on. Bases have no versions yet. */
5349
+ base: {
5350
+ name: "base" | "files" | "browser" | "code-interpreter";
5351
+ /** Reserved: not read, because bases have no versions yet. Refused in this version. */
5352
+ range?: string;
5353
+ };
5354
+ /**
5355
+ * The tool VM's size, one of the base's size classes. Absent: 1 vCPU and 512 MiB, the only size of this version.
5356
+ */
5357
+ size?: {
5358
+ vcpu: number;
5359
+ memoryMb: number;
5360
+ };
5361
+ /**
5362
+ * Where the tool's files come from. This version reads one archive, unpacked at /tool before each call.
5363
+ */
5364
+ bundle?: {
5365
+ archive?: B3PackToolArchive;
5366
+ /**
5367
+ * Reserved: files carried inside the pack bundle under tool/, with their sources (later versions). Refused in this version.
5368
+ */
5369
+ files?: unknown[];
5370
+ };
5371
+ /**
5372
+ * call: one fresh VM per call, deleted before the call answers. session (later): a keyed instance kept between calls.
5373
+ */
5374
+ runtime?: {
5375
+ mode: "call" | "session";
5376
+ /** Reserved for session tools. */
5377
+ start?: unknown;
5378
+ /** Reserved for session tools. */
5379
+ ready?: unknown;
5380
+ /** Reserved for session tools. */
5381
+ idleS?: number;
5382
+ /** Reserved for session tools. */
5383
+ maxS?: number;
5384
+ };
5385
+ /**
5386
+ * What the tool's VM may reach. none: nothing (egress deny); the pack's egress list is empty. hosts (later): the pack's egress list, port 443 only. caller (later, first-party only): hosts the caller names.
5387
+ */
5388
+ network?: {
5389
+ mode: "none" | "hosts" | "caller";
5390
+ };
5391
+ /** The software the tool runs and did not write. Stored and returned by describe. */
5392
+ upstream?: {
5393
+ name: string;
5394
+ url: string;
5395
+ version: string;
5396
+ /** SPDX license expression. */
5397
+ license: string;
5398
+ /** Where the publisher got the upstream's files, and their digest. */
5399
+ obtained?: {
5400
+ url: string;
5401
+ sha256?: string;
5402
+ };
5403
+ patchedBy?: string;
5404
+ trademarkPolicy?: string;
5405
+ }[];
5406
+ /**
5407
+ * Bundle-relative path of the notices file (licences, attributions, 'Not affiliated with ...'). It must be a file of the pack bundle.
5408
+ */
5409
+ notices?: string;
5410
+ /**
5411
+ * Reserved: a command run once when the node prepares the tool's snapshot (later). Refused in this version.
5412
+ */
5413
+ setup?: unknown;
5414
+ /** Reserved: an imported image's artifact (later). Refused in this version. */
5415
+ image?: unknown;
5416
+ /** Reserved: output formats a takedown can turn off by name (later). Refused in this version. */
5417
+ formats?: unknown;
5418
+ /** Reserved: the tool's own error codes, as an enum (later). Refused in this version. */
5419
+ errors?: unknown;
5420
+ }
5421
+
5422
+ /**
5423
+ * One archive of the tool's files, named by its sha256, uploaded to the registry's blob store before the pack is published, and unpacked at /tool before each call. The publish checks cap it at 64 MiB packed (bytes 67108864), 512 MiB unpacked (unpackedBytes 536870912) and 20,000 entries.
5424
+ */
5425
+ export interface B3PackToolArchive {
5426
+ /** Lowercase hex sha256 of the archive's bytes. */
5427
+ sha256: string;
5428
+ /** The archive's size in bytes. */
5429
+ bytes: number;
5430
+ format: "tar.gz" | "tar";
5431
+ /** The sum of the sizes of the archive's regular files. */
5432
+ unpackedBytes: number;
5433
+ /** Files, directories and links in the archive. */
5434
+ entries: number;
5435
+ }
5436
+
5274
5437
  /**
5275
5438
  * Publisher signature written by the publish tool and repeated in the registry record. contentHash covers the whole bundle with this member removed (README, 'Pack content hash and signature'). sig is Ed25519 over the UTF-8 bytes of 'b3pack-sig-v1\n<pack>\n<version>\n<contentHash>'. Nodes verify contentHash and sig against the registry record and the publisher's registered key before loading (ARCHITECTURE 5.5).
5276
5439
  */
@@ -5457,6 +5620,23 @@ export interface ActionDescription {
5457
5620
  * when the node loads the pack. Their inputs also appear as `examples` in `mcp.inputSchema`.
5458
5621
  */
5459
5622
  examples: ActionExample[];
5623
+ /**
5624
+ * For a hosted tool's action (`impl.kind` `vm`), what it runs on and what it costs; absent for other actions.
5625
+ */
5626
+ tool?: {
5627
+ kind: "cli";
5628
+ /** The template its VM is made from. */
5629
+ base: string;
5630
+ network: "none";
5631
+ /**
5632
+ * The publisher's price per call that answered validly, in micro-USD (millionths of a US dollar); 0 when free.
5633
+ */
5634
+ price_micro_usd: number;
5635
+ /** The software the tool runs and did not write (the manifest's `tool.upstream`). */
5636
+ upstream: Record<string, unknown>[];
5637
+ /** The bundle path of the tool's notices file. */
5638
+ notices?: string;
5639
+ };
5460
5640
  }
5461
5641
 
5462
5642
  export interface ActionCallRequest {
@@ -5479,13 +5659,31 @@ export interface ActionResult {
5479
5659
  object: "action_result";
5480
5660
  /** The exact version that ran. */
5481
5661
  ref: string;
5482
- /** Matches the action's output schema. */
5662
+ /** Matches the action's output schema. A hosted tool's output file is a `ToolFileOutput`. */
5483
5663
  output: unknown;
5484
5664
  /** HTTP status of the upstream call, for declarative HTTP actions. */
5485
5665
  upstream_status?: number;
5666
+ /**
5667
+ * `vm` for a hosted tool's call (its command ran in a microVM made for the call). Absent for other actions.
5668
+ */
5669
+ tier?: "vm";
5670
+ cost?: ToolCallCost;
5486
5671
  timing: Timing;
5487
5672
  }
5488
5673
 
5674
+ /**
5675
+ * What a hosted tool's call costs, in micro-USD (millionths of a US dollar), from the node's unit prices when
5676
+ * the call ran: `compute` (`actions.vcpu_ms` and `actions.gib_ms`), `floor` (`actions.tool_call`), `price` (the
5677
+ * publisher's, `actions.publisher_microusd`; 0 when the tool failed or is free) and their sum, `total`. The
5678
+ * same numbers are in the `actions.tool_call` usage record's `meta.cost_micro_usd`.
5679
+ */
5680
+ export interface ToolCallCost {
5681
+ compute: number;
5682
+ floor: number;
5683
+ price: number;
5684
+ total: number;
5685
+ }
5686
+
5489
5687
  export interface TriggerSummary {
5490
5688
  ref: string;
5491
5689
  pack: string;
@@ -6752,6 +6950,18 @@ export interface RegistryPackVersion {
6752
6950
  published_at: string;
6753
6951
  yanked: boolean;
6754
6952
  download_url: string;
6953
+ /**
6954
+ * The API key (`key_...`) or dashboard user (`usr_...`) that published the version, shown to the namespace's owner and to B3's organizations; `null` for any other reader, a node, and versions published before it was recorded.
6955
+ */
6956
+ published_by?: string | null;
6957
+ }
6958
+
6959
+ /** A hosted tool's archive in the registry's blob store, named by its sha256. */
6960
+ export interface RegistryBlob {
6961
+ object: "registry_blob";
6962
+ digest: string;
6963
+ bytes: number;
6964
+ created_at: string;
6755
6965
  }
6756
6966
 
6757
6967
  /**
@@ -6765,10 +6975,21 @@ export type RequestConnection = "edge" | "uds" | "tcp" | "sandbox";
6765
6975
  * Who made the request: `api_key` (an API key), `cli_token` (the CLI's device-login token), `dashboard` (a
6766
6976
  * signed-in dashboard session; its successful reads are not logged, its changes and errors are), `sandbox` (code
6767
6977
  * inside a sandbox, as its creating key), `routine` (a routine run, as the key that published its version),
6768
- * `local` (a host-local caller on the node's Unix socket) or `public` (no credential: a webhook or signed
6769
- * callback to a public route, or a request refused before authentication).
6978
+ * `local` (a host-local caller on the node's Unix socket), `public` (no credential: a webhook or signed
6979
+ * callback to a public route, or a request refused before authentication), `address` (a visitor of an app
6980
+ * address, `<label>.b3os.io`) or `preview` (a visitor of a sandbox port preview). `address` and `preview`
6981
+ * records belong to the sandbox's project; their `path` is the app's path, without the query, cut at 1,024 bytes.
6770
6982
  */
6771
- export type RequestSource = "api_key" | "cli_token" | "dashboard" | "sandbox" | "routine" | "local" | "public";
6983
+ export type RequestSource =
6984
+ | "api_key"
6985
+ | "cli_token"
6986
+ | "dashboard"
6987
+ | "sandbox"
6988
+ | "routine"
6989
+ | "local"
6990
+ | "public"
6991
+ | "address"
6992
+ | "preview";
6772
6993
 
6773
6994
  export interface RequestPhase {
6774
6995
  name: string;