@b3os/sdk 0.0.0-stage → 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (242) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +233 -2
  3. package/dist/cjs/core/client.d.ts +165 -0
  4. package/dist/cjs/core/client.js +825 -0
  5. package/dist/cjs/core/client.js.map +1 -0
  6. package/dist/cjs/core/errors.d.ts +101 -0
  7. package/dist/cjs/core/errors.js +249 -0
  8. package/dist/cjs/core/errors.js.map +1 -0
  9. package/dist/cjs/core/index.d.ts +12 -0
  10. package/dist/cjs/core/index.js +42 -0
  11. package/dist/cjs/core/index.js.map +1 -0
  12. package/dist/cjs/core/jobs.d.ts +31 -0
  13. package/dist/cjs/core/jobs.js +72 -0
  14. package/dist/cjs/core/jobs.js.map +1 -0
  15. package/dist/cjs/core/namespace.d.ts +7 -0
  16. package/dist/cjs/core/namespace.js +13 -0
  17. package/dist/cjs/core/namespace.js.map +1 -0
  18. package/dist/cjs/core/op.d.ts +47 -0
  19. package/dist/cjs/core/op.js +5 -0
  20. package/dist/cjs/core/op.js.map +1 -0
  21. package/dist/cjs/core/promise.d.ts +106 -0
  22. package/dist/cjs/core/promise.js +200 -0
  23. package/dist/cjs/core/promise.js.map +1 -0
  24. package/dist/cjs/core/response.d.ts +54 -0
  25. package/dist/cjs/core/response.js +92 -0
  26. package/dist/cjs/core/response.js.map +1 -0
  27. package/dist/cjs/core/sse.d.ts +79 -0
  28. package/dist/cjs/core/sse.js +291 -0
  29. package/dist/cjs/core/sse.js.map +1 -0
  30. package/dist/cjs/core/timing.d.ts +20 -0
  31. package/dist/cjs/core/timing.js +96 -0
  32. package/dist/cjs/core/timing.js.map +1 -0
  33. package/dist/cjs/core/transport.d.ts +80 -0
  34. package/dist/cjs/core/transport.js +472 -0
  35. package/dist/cjs/core/transport.js.map +1 -0
  36. package/dist/cjs/core/util.d.ts +25 -0
  37. package/dist/cjs/core/util.js +142 -0
  38. package/dist/cjs/core/util.js.map +1 -0
  39. package/dist/cjs/core/ws.d.ts +52 -0
  40. package/dist/cjs/core/ws.js +181 -0
  41. package/dist/cjs/core/ws.js.map +1 -0
  42. package/dist/cjs/generated/client.d.ts +62 -0
  43. package/dist/cjs/generated/client.js +130 -0
  44. package/dist/cjs/generated/client.js.map +1 -0
  45. package/dist/cjs/generated/errors.d.ts +4 -0
  46. package/dist/cjs/generated/errors.js +160 -0
  47. package/dist/cjs/generated/errors.js.map +1 -0
  48. package/dist/cjs/generated/ids.d.ts +114 -0
  49. package/dist/cjs/generated/ids.js +47 -0
  50. package/dist/cjs/generated/ids.js.map +1 -0
  51. package/dist/cjs/generated/jobs.d.ts +10 -0
  52. package/dist/cjs/generated/jobs.js +24 -0
  53. package/dist/cjs/generated/jobs.js.map +1 -0
  54. package/dist/cjs/generated/ns/actions.d.ts +161 -0
  55. package/dist/cjs/generated/ns/actions.js +304 -0
  56. package/dist/cjs/generated/ns/actions.js.map +1 -0
  57. package/dist/cjs/generated/ns/infer.d.ts +190 -0
  58. package/dist/cjs/generated/ns/infer.js +253 -0
  59. package/dist/cjs/generated/ns/infer.js.map +1 -0
  60. package/dist/cjs/generated/ns/keys.d.ts +76 -0
  61. package/dist/cjs/generated/ns/keys.js +144 -0
  62. package/dist/cjs/generated/ns/keys.js.map +1 -0
  63. package/dist/cjs/generated/ns/limits.d.ts +22 -0
  64. package/dist/cjs/generated/ns/limits.js +32 -0
  65. package/dist/cjs/generated/ns/limits.js.map +1 -0
  66. package/dist/cjs/generated/ns/orgs.d.ts +38 -0
  67. package/dist/cjs/generated/ns/orgs.js +68 -0
  68. package/dist/cjs/generated/ns/orgs.js.map +1 -0
  69. package/dist/cjs/generated/ns/projects.d.ts +57 -0
  70. package/dist/cjs/generated/ns/projects.js +115 -0
  71. package/dist/cjs/generated/ns/projects.js.map +1 -0
  72. package/dist/cjs/generated/ns/render.d.ts +159 -0
  73. package/dist/cjs/generated/ns/render.js +299 -0
  74. package/dist/cjs/generated/ns/render.js.map +1 -0
  75. package/dist/cjs/generated/ns/requests.d.ts +36 -0
  76. package/dist/cjs/generated/ns/requests.js +54 -0
  77. package/dist/cjs/generated/ns/requests.js.map +1 -0
  78. package/dist/cjs/generated/ns/routines.d.ts +212 -0
  79. package/dist/cjs/generated/ns/routines.js +419 -0
  80. package/dist/cjs/generated/ns/routines.js.map +1 -0
  81. package/dist/cjs/generated/ns/sandboxes.d.ts +318 -0
  82. package/dist/cjs/generated/ns/sandboxes.js +549 -0
  83. package/dist/cjs/generated/ns/sandboxes.js.map +1 -0
  84. package/dist/cjs/generated/ns/usage.d.ts +30 -0
  85. package/dist/cjs/generated/ns/usage.js +49 -0
  86. package/dist/cjs/generated/ns/usage.js.map +1 -0
  87. package/dist/cjs/generated/ns/vault.d.ts +69 -0
  88. package/dist/cjs/generated/ns/vault.js +122 -0
  89. package/dist/cjs/generated/ns/vault.js.map +1 -0
  90. package/dist/cjs/generated/ns/vision.d.ts +376 -0
  91. package/dist/cjs/generated/ns/vision.js +736 -0
  92. package/dist/cjs/generated/ns/vision.js.map +1 -0
  93. package/dist/cjs/generated/ns/webhooks.d.ts +50 -0
  94. package/dist/cjs/generated/ns/webhooks.js +91 -0
  95. package/dist/cjs/generated/ns/webhooks.js.map +1 -0
  96. package/dist/cjs/generated/types.d.ts +4613 -0
  97. package/dist/cjs/generated/types.js +4 -0
  98. package/dist/cjs/generated/types.js.map +1 -0
  99. package/dist/cjs/index.d.ts +22 -0
  100. package/dist/cjs/index.js +81 -0
  101. package/dist/cjs/index.js.map +1 -0
  102. package/dist/cjs/package.json +3 -0
  103. package/dist/cjs/webhooks.d.ts +19 -0
  104. package/dist/cjs/webhooks.js +85 -0
  105. package/dist/cjs/webhooks.js.map +1 -0
  106. package/dist/esm/core/client.d.ts +165 -0
  107. package/dist/esm/core/client.js +821 -0
  108. package/dist/esm/core/client.js.map +1 -0
  109. package/dist/esm/core/errors.d.ts +101 -0
  110. package/dist/esm/core/errors.js +239 -0
  111. package/dist/esm/core/errors.js.map +1 -0
  112. package/dist/esm/core/index.d.ts +12 -0
  113. package/dist/esm/core/index.js +15 -0
  114. package/dist/esm/core/index.js.map +1 -0
  115. package/dist/esm/core/jobs.d.ts +31 -0
  116. package/dist/esm/core/jobs.js +66 -0
  117. package/dist/esm/core/jobs.js.map +1 -0
  118. package/dist/esm/core/namespace.d.ts +7 -0
  119. package/dist/esm/core/namespace.js +9 -0
  120. package/dist/esm/core/namespace.js.map +1 -0
  121. package/dist/esm/core/op.d.ts +47 -0
  122. package/dist/esm/core/op.js +4 -0
  123. package/dist/esm/core/op.js.map +1 -0
  124. package/dist/esm/core/promise.d.ts +106 -0
  125. package/dist/esm/core/promise.js +193 -0
  126. package/dist/esm/core/promise.js.map +1 -0
  127. package/dist/esm/core/response.d.ts +54 -0
  128. package/dist/esm/core/response.js +86 -0
  129. package/dist/esm/core/response.js.map +1 -0
  130. package/dist/esm/core/sse.d.ts +79 -0
  131. package/dist/esm/core/sse.js +286 -0
  132. package/dist/esm/core/sse.js.map +1 -0
  133. package/dist/esm/core/timing.d.ts +20 -0
  134. package/dist/esm/core/timing.js +92 -0
  135. package/dist/esm/core/timing.js.map +1 -0
  136. package/dist/esm/core/transport.d.ts +80 -0
  137. package/dist/esm/core/transport.js +465 -0
  138. package/dist/esm/core/transport.js.map +1 -0
  139. package/dist/esm/core/util.d.ts +25 -0
  140. package/dist/esm/core/util.js +128 -0
  141. package/dist/esm/core/util.js.map +1 -0
  142. package/dist/esm/core/ws.d.ts +52 -0
  143. package/dist/esm/core/ws.js +175 -0
  144. package/dist/esm/core/ws.js.map +1 -0
  145. package/dist/esm/generated/client.d.ts +62 -0
  146. package/dist/esm/generated/client.js +126 -0
  147. package/dist/esm/generated/client.js.map +1 -0
  148. package/dist/esm/generated/errors.d.ts +4 -0
  149. package/dist/esm/generated/errors.js +157 -0
  150. package/dist/esm/generated/errors.js.map +1 -0
  151. package/dist/esm/generated/ids.d.ts +114 -0
  152. package/dist/esm/generated/ids.js +42 -0
  153. package/dist/esm/generated/ids.js.map +1 -0
  154. package/dist/esm/generated/jobs.d.ts +10 -0
  155. package/dist/esm/generated/jobs.js +21 -0
  156. package/dist/esm/generated/jobs.js.map +1 -0
  157. package/dist/esm/generated/ns/actions.d.ts +161 -0
  158. package/dist/esm/generated/ns/actions.js +300 -0
  159. package/dist/esm/generated/ns/actions.js.map +1 -0
  160. package/dist/esm/generated/ns/infer.d.ts +190 -0
  161. package/dist/esm/generated/ns/infer.js +249 -0
  162. package/dist/esm/generated/ns/infer.js.map +1 -0
  163. package/dist/esm/generated/ns/keys.d.ts +76 -0
  164. package/dist/esm/generated/ns/keys.js +140 -0
  165. package/dist/esm/generated/ns/keys.js.map +1 -0
  166. package/dist/esm/generated/ns/limits.d.ts +22 -0
  167. package/dist/esm/generated/ns/limits.js +28 -0
  168. package/dist/esm/generated/ns/limits.js.map +1 -0
  169. package/dist/esm/generated/ns/orgs.d.ts +38 -0
  170. package/dist/esm/generated/ns/orgs.js +64 -0
  171. package/dist/esm/generated/ns/orgs.js.map +1 -0
  172. package/dist/esm/generated/ns/projects.d.ts +57 -0
  173. package/dist/esm/generated/ns/projects.js +111 -0
  174. package/dist/esm/generated/ns/projects.js.map +1 -0
  175. package/dist/esm/generated/ns/render.d.ts +159 -0
  176. package/dist/esm/generated/ns/render.js +295 -0
  177. package/dist/esm/generated/ns/render.js.map +1 -0
  178. package/dist/esm/generated/ns/requests.d.ts +36 -0
  179. package/dist/esm/generated/ns/requests.js +50 -0
  180. package/dist/esm/generated/ns/requests.js.map +1 -0
  181. package/dist/esm/generated/ns/routines.d.ts +212 -0
  182. package/dist/esm/generated/ns/routines.js +415 -0
  183. package/dist/esm/generated/ns/routines.js.map +1 -0
  184. package/dist/esm/generated/ns/sandboxes.d.ts +318 -0
  185. package/dist/esm/generated/ns/sandboxes.js +545 -0
  186. package/dist/esm/generated/ns/sandboxes.js.map +1 -0
  187. package/dist/esm/generated/ns/usage.d.ts +30 -0
  188. package/dist/esm/generated/ns/usage.js +45 -0
  189. package/dist/esm/generated/ns/usage.js.map +1 -0
  190. package/dist/esm/generated/ns/vault.d.ts +69 -0
  191. package/dist/esm/generated/ns/vault.js +118 -0
  192. package/dist/esm/generated/ns/vault.js.map +1 -0
  193. package/dist/esm/generated/ns/vision.d.ts +376 -0
  194. package/dist/esm/generated/ns/vision.js +732 -0
  195. package/dist/esm/generated/ns/vision.js.map +1 -0
  196. package/dist/esm/generated/ns/webhooks.d.ts +50 -0
  197. package/dist/esm/generated/ns/webhooks.js +87 -0
  198. package/dist/esm/generated/ns/webhooks.js.map +1 -0
  199. package/dist/esm/generated/types.d.ts +4613 -0
  200. package/dist/esm/generated/types.js +3 -0
  201. package/dist/esm/generated/types.js.map +1 -0
  202. package/dist/esm/index.d.ts +22 -0
  203. package/dist/esm/index.js +28 -0
  204. package/dist/esm/index.js.map +1 -0
  205. package/dist/esm/webhooks.d.ts +19 -0
  206. package/dist/esm/webhooks.js +79 -0
  207. package/dist/esm/webhooks.js.map +1 -0
  208. package/package.json +98 -4
  209. package/src/core/client.ts +1022 -0
  210. package/src/core/errors.ts +296 -0
  211. package/src/core/index.ts +45 -0
  212. package/src/core/jobs.ts +94 -0
  213. package/src/core/namespace.ts +10 -0
  214. package/src/core/op.ts +53 -0
  215. package/src/core/promise.ts +268 -0
  216. package/src/core/response.ts +115 -0
  217. package/src/core/sse.ts +305 -0
  218. package/src/core/timing.ts +106 -0
  219. package/src/core/transport.ts +489 -0
  220. package/src/core/util.ts +138 -0
  221. package/src/core/ws.ts +215 -0
  222. package/src/generated/client.ts +143 -0
  223. package/src/generated/errors.ts +313 -0
  224. package/src/generated/ids.ts +47 -0
  225. package/src/generated/jobs.ts +25 -0
  226. package/src/generated/ns/actions.ts +353 -0
  227. package/src/generated/ns/infer.ts +332 -0
  228. package/src/generated/ns/keys.ts +152 -0
  229. package/src/generated/ns/limits.ts +35 -0
  230. package/src/generated/ns/orgs.ts +77 -0
  231. package/src/generated/ns/projects.ts +122 -0
  232. package/src/generated/ns/render.ts +348 -0
  233. package/src/generated/ns/requests.ts +61 -0
  234. package/src/generated/ns/routines.ts +474 -0
  235. package/src/generated/ns/sandboxes.ts +671 -0
  236. package/src/generated/ns/usage.ts +56 -0
  237. package/src/generated/ns/vault.ts +136 -0
  238. package/src/generated/ns/vision.ts +836 -0
  239. package/src/generated/ns/webhooks.ts +100 -0
  240. package/src/generated/types.ts +5131 -0
  241. package/src/index.ts +30 -0
  242. package/src/webhooks.ts +100 -0
@@ -0,0 +1,318 @@
1
+ import type { BinaryInput, RequestOptions, StreamOptions } from "../../core/client.ts";
2
+ import { Namespace } from "../../core/namespace.ts";
3
+ import type { Op } from "../../core/op.ts";
4
+ import type { APIPromise, ListPromise } from "../../core/promise.ts";
5
+ import type { EventStream } from "../../core/sse.ts";
6
+ import { PtySession } from "../../core/ws.ts";
7
+ import type * as T from "../types.ts";
8
+ /** Descriptors of every sandboxes operation, keyed by method name (for tooling and custom clients). */
9
+ export declare const sandboxesOps: {
10
+ readonly listSandboxes: Op;
11
+ readonly createSandbox: Op;
12
+ readonly listSnapshots: Op;
13
+ readonly deleteSnapshot: Op;
14
+ readonly getSnapshot: Op;
15
+ readonly listTemplates: Op;
16
+ readonly getTemplate: Op;
17
+ readonly deleteSandbox: Op;
18
+ readonly getSandbox: Op;
19
+ readonly exec: Op;
20
+ readonly readFile: Op;
21
+ readonly writeFile: Op;
22
+ readonly forkSandbox: Op;
23
+ readonly streamLogs: Op;
24
+ readonly pauseSandbox: Op;
25
+ readonly createPortUrl: Op;
26
+ readonly listProcesses: Op;
27
+ readonly killProcess: Op;
28
+ readonly openPty: Op;
29
+ readonly resumeSandbox: Op;
30
+ readonly runCode: Op;
31
+ readonly createSnapshot: Op;
32
+ readonly createTicket: Op;
33
+ readonly setTimeout: Op;
34
+ };
35
+ /** Firecracker microVM sandboxes: exec, files, terminals, ports, snapshots (`/v1/sandboxes`). */
36
+ export declare class SandboxesAPI extends Namespace {
37
+ /**
38
+ * List sandboxes
39
+ *
40
+ * Lists sandboxes in this project, newest first, including stopped ones from the last 7 days.
41
+ *
42
+ * `GET /v1/sandboxes` · scope `sandboxes:read` · served by the node
43
+ */
44
+ listSandboxes(params?: T.SandboxesListSandboxesParams, options?: RequestOptions): ListPromise<T.SandboxList, T.Sandbox>;
45
+ /**
46
+ * Create a sandbox
47
+ *
48
+ * Claims a pre-warmed microVM from the template's pool (or restores a snapshot), binds a fresh identity to it
49
+ * (new entropy, machine ID and clock) and returns it running. The sandbox stops when `timeout_s` passes unless
50
+ * you extend it, and `on_idle: pause` pauses it instead. It bills `sandboxes.vcpu_ms` (CPU used) and
51
+ * `sandboxes.gib_ms` (memory allocated) while running.
52
+ *
53
+ * `api` grants code inside the sandbox access to B3OS (`http://127.0.0.1:7700`) with scopes that must be a
54
+ * subset of yours; `sandboxes:write`, every `vault:*` and every `platform:*` scope are never granted unless named
55
+ * explicitly. `api.spend_cap_usd` may not exceed your own spend cap, and `null` means your cap applies; scopes
56
+ * or a cap beyond yours are refused with `403 forbidden`, `reason: scope_escalation`.
57
+ *
58
+ * Inside the sandbox the environment also has `B3OS_API_URL=http://127.0.0.1:7700`, `B3OS_SANDBOX_ID`,
59
+ * `B3OS_PROJECT` and `B3OS_PORT_BASE_PATH=/sbx/<host_id>`. `B3OS_PORT_BASE_PATH` is only the fixed start of
60
+ * every port preview path on `usercontent.b3os.org`, not a full base path: the full prefix of a request,
61
+ * `/sbx/<host_id>/<port>/<token>`, arrives with it in `X-Forwarded-Prefix` (`sandboxesProxyPortGet`).
62
+ *
63
+ * `timing` phases: `validate_ms`, then `claim_ms` and `resume_ms` for a pre-warmed microVM from the pool, or
64
+ * `restore_ms` when none was parked (a restore on demand, or from a snapshot), then `bind_ms` (the identity
65
+ * and environment reach the guest agent), and `total_ms`.
66
+ *
67
+ * A create that has started finishes even if the client disconnects before the response: the sandbox then
68
+ * runs (and is billed) until its timeout or a delete, and `GET /v1/sandboxes` lists it with the `metadata`
69
+ * it was created with. After a disconnect, look for it there before you retry: a retry is a new create, also
70
+ * with the same `Idempotency-Key`, because the key is released when the client goes away before the
71
+ * response. Fork, snapshot, pause and resume also finish after a disconnect.
72
+ *
73
+ * `POST /v1/sandboxes` · scope `sandboxes:write` · served by the node
74
+ */
75
+ createSandbox(body?: T.SandboxCreateRequest, options?: RequestOptions): APIPromise<T.Sandbox>;
76
+ /**
77
+ * List snapshots
78
+ *
79
+ * Lists snapshots in this project, newest first.
80
+ *
81
+ * `GET /v1/sandboxes/snapshots` · scope `sandboxes:read` · served by the node
82
+ */
83
+ listSnapshots(params?: T.SandboxesListSnapshotsParams, options?: RequestOptions): ListPromise<T.SnapshotList, T.Snapshot>;
84
+ /**
85
+ * Delete a snapshot
86
+ *
87
+ * Deletes the snapshot. Sandboxes already restored from it keep running.
88
+ *
89
+ * `DELETE /v1/sandboxes/snapshots/{snapshot_id}` · scope `sandboxes:write` · served by the node
90
+ */
91
+ deleteSnapshot(snapshotId: string, options?: RequestOptions): APIPromise<T.Deleted>;
92
+ /**
93
+ * Get a snapshot
94
+ *
95
+ * Returns a snapshot's metadata and status.
96
+ *
97
+ * `GET /v1/sandboxes/snapshots/{snapshot_id}` · scope `sandboxes:read` · served by the node
98
+ */
99
+ getSnapshot(snapshotId: string, options?: RequestOptions): APIPromise<T.Snapshot>;
100
+ /**
101
+ * List templates
102
+ *
103
+ * Lists the templates sandboxes can start from (`base`, `code-interpreter`, `agent`, and on nodes that build it
104
+ * `browser`: Chrome already running in the snapshot, a VM-isolated browser with DevTools on port 9222) with their
105
+ * contents and defaults.
106
+ *
107
+ * `GET /v1/sandboxes/templates` · scope `sandboxes:read` · served by the node
108
+ */
109
+ listTemplates(options?: RequestOptions): APIPromise<T.TemplateList>;
110
+ /**
111
+ * Get a template
112
+ *
113
+ * Returns one template by name (`base`) or ID (`tpl_…`).
114
+ *
115
+ * `GET /v1/sandboxes/templates/{template}` · scope `sandboxes:read` · served by the node
116
+ */
117
+ getTemplate(template: string, options?: RequestOptions): APIPromise<T.Template>;
118
+ /**
119
+ * Delete a sandbox
120
+ *
121
+ * Stops the sandbox and destroys its memory and disk. Snapshots taken from it are kept. Returns the stopped sandbox with its final usage.
122
+ *
123
+ * `DELETE /v1/sandboxes/{sandbox_id}` · scope `sandboxes:write` · served by the node
124
+ */
125
+ deleteSandbox(sandboxId: string, options?: RequestOptions): APIPromise<T.Sandbox>;
126
+ /**
127
+ * Get a sandbox
128
+ *
129
+ * Returns the sandbox with its status, expiry, ports and usage so far.
130
+ *
131
+ * `GET /v1/sandboxes/{sandbox_id}` · scope `sandboxes:read` · served by the node
132
+ */
133
+ getSandbox(sandboxId: string, options?: RequestOptions): APIPromise<T.Sandbox>;
134
+ /**
135
+ * Run a command
136
+ *
137
+ * Runs a command in the sandbox. By default the response waits for it to exit (at most `timeout_ms`, up to 60
138
+ * seconds) and returns its exit code and output. With `?stream=true` (or `Accept: text/event-stream`) output
139
+ * arrives as `exec.stdout` and `exec.stderr` events while it runs, ending with `exec.exit`; streamed commands
140
+ * may run up to an hour. With `background: true` the response returns at once with the process, whose output
141
+ * you read from `GET /v1/sandboxes/{sandbox_id}/logs`.
142
+ *
143
+ * `cmd` as a string runs through `/bin/sh -c`; as an array it is executed directly. Output is UTF-8 (invalid
144
+ * bytes become U+FFFD) and each stream is capped at 1 MiB in a buffered response.
145
+ *
146
+ * `POST /v1/sandboxes/{sandbox_id}/exec` · scope `sandboxes:run` · served by the node
147
+ */
148
+ exec(sandboxId: string, body: T.ExecRequest & {
149
+ background: true;
150
+ }, options?: RequestOptions): APIPromise<T.SandboxProcess>;
151
+ exec(sandboxId: string, body: T.ExecRequest, options: StreamOptions & {
152
+ stream: true;
153
+ }): EventStream<T.ExecEvent>;
154
+ exec(sandboxId: string, body: T.ExecRequest, options?: RequestOptions & {
155
+ stream?: false;
156
+ }): APIPromise<T.ExecResult>;
157
+ /**
158
+ * Read a file or list a directory
159
+ *
160
+ * Returns the file at `path` as bytes. With `list=1` returns the directory's entries (or the single entry
161
+ * when `path` is a file) as JSON instead. Transfers are capped at 64 MiB.
162
+ *
163
+ * `GET /v1/sandboxes/{sandbox_id}/files` · scope `sandboxes:run` · served by the node
164
+ */
165
+ readFile(sandboxId: string, params: T.SandboxesReadFileParams & {
166
+ list: 1;
167
+ }, options?: RequestOptions): APIPromise<T.FileEntryList>;
168
+ readFile(sandboxId: string, params: T.SandboxesReadFileParams & {
169
+ list?: 0;
170
+ }, options?: RequestOptions): APIPromise<Uint8Array>;
171
+ /**
172
+ * Write a file
173
+ *
174
+ * Writes the request body to `path`, replacing any existing file, creating parent directories with `mkdir=1`.
175
+ * Returns the file's entry. Up to 64 MiB per request.
176
+ *
177
+ * `PUT /v1/sandboxes/{sandbox_id}/files` · scope `sandboxes:run` · served by the node
178
+ */
179
+ writeFile(sandboxId: string, params: T.SandboxesWriteFileParams, data: BinaryInput, options?: RequestOptions): APIPromise<T.FileEntry>;
180
+ /**
181
+ * Fork a sandbox
182
+ *
183
+ * Creates `count` new running sandboxes that share the source's memory and disk copy-on-write, each with a fresh
184
+ * identity (its own id, entropy, machine ID and clock; the source's environment, secrets, files and running
185
+ * processes carry over). The source must have been created with `forkable: true` (forkable sandboxes are
186
+ * restored for themselves rather than claimed from a pool, and track the pages they change); forks are
187
+ * forkable too. The source pauses while its changed memory is written (`pause`, `base`, `snapshot`, `export`
188
+ * phases in `Server-Timing`), then runs on; like a snapshot this resets its open connections to the outside.
189
+ * Each fork counts against your sandbox concurrency.
190
+ *
191
+ * `POST /v1/sandboxes/{sandbox_id}/fork` · scope `sandboxes:write` · served by the node
192
+ *
193
+ * Stretch: in the contract, but may answer `501 not_implemented` on this deployment.
194
+ */
195
+ forkSandbox(sandboxId: string, body?: T.ForkRequest, options?: RequestOptions): APIPromise<T.SandboxList>;
196
+ /**
197
+ * Stream process logs
198
+ *
199
+ * Server-sent events with the output of background processes: `log.stdout` and `log.stderr` per chunk and
200
+ * `process.exited` when one ends. Starts with up to 1 MiB of buffered output per process, then follows new
201
+ * output until the sandbox stops (or immediately ends with `follow=false`). Filter to one process with `pid`.
202
+ * Authenticate with the `Authorization` header or a ticket from `POST /v1/sandboxes/{sandbox_id}/ticket`
203
+ * (`?ticket=`, for `EventSource`).
204
+ *
205
+ * `GET /v1/sandboxes/{sandbox_id}/logs` · scope `sandboxes:run` · served by the node
206
+ */
207
+ streamLogs(sandboxId: string, params?: T.SandboxesStreamLogsParams, options?: StreamOptions): EventStream<T.LogEvent>;
208
+ /**
209
+ * Pause a sandbox
210
+ *
211
+ * Freezes the sandbox's vCPUs and keeps its memory and disk on the node. A paused sandbox bills no CPU time
212
+ * and still counts allocated memory; it still expires at `expires_at`. Resume continues exactly where it
213
+ * stopped. Pausing a paused sandbox returns it unchanged.
214
+ *
215
+ * `POST /v1/sandboxes/{sandbox_id}/pause` · scope `sandboxes:write` · served by the node
216
+ */
217
+ pauseSandbox(sandboxId: string, options?: RequestOptions): APIPromise<T.Sandbox>;
218
+ /**
219
+ * Get a URL for a port
220
+ *
221
+ * Returns a URL that reaches `port` inside the sandbox:
222
+ * `https://usercontent.b3os.org/sbx/<host_id>/<port>/<token>/`. The token in the path is signed by the node and
223
+ * expires after `ttl_s` (10 minutes by default, at most 24 hours); anyone with the URL reaches the port until
224
+ * then, with no cookie or other credential. For a public port the response is the sandbox's long-lived URL
225
+ * (`ports[].url`) and `ttl_s` is ignored. The port must be declared in `ports` when the sandbox is created. The
226
+ * app sees the URL's base path in `X-Forwarded-Prefix` on every request (token format and forwarding:
227
+ * `sandboxesProxyPortGet`).
228
+ *
229
+ * `POST /v1/sandboxes/{sandbox_id}/ports/{port}/url` · scope `sandboxes:run` · served by the node
230
+ */
231
+ createPortUrl(sandboxId: string, port: number, body?: T.PortUrlRequest, options?: RequestOptions): APIPromise<T.PortUrl>;
232
+ /**
233
+ * List background processes
234
+ *
235
+ * Lists processes started with `background: true`, running or exited, newest first.
236
+ *
237
+ * `GET /v1/sandboxes/{sandbox_id}/processes` · scope `sandboxes:run` · served by the node
238
+ */
239
+ listProcesses(sandboxId: string, options?: RequestOptions): APIPromise<T.SandboxProcessList>;
240
+ /**
241
+ * Signal a background process
242
+ *
243
+ * Sends a signal (default `TERM`) to a background process and its process group, and returns the process.
244
+ *
245
+ * `POST /v1/sandboxes/{sandbox_id}/processes/{pid}/kill` · scope `sandboxes:run` · served by the node
246
+ */
247
+ killProcess(sandboxId: string, pid: number, body?: T.KillRequest, options?: RequestOptions): APIPromise<T.SandboxProcess>;
248
+ /**
249
+ * Open a terminal
250
+ *
251
+ * Opens a WebSocket attached to a new pseudo-terminal running the user's login shell (or `cmd`). Binary frames
252
+ * carry terminal bytes in both directions. Text frames carry JSON control messages: send
253
+ * `{"type": "resize", "cols": 120, "rows": 40}`; the server sends `{"type": "exit", "code": 0}` before it closes.
254
+ * Authenticate with the `Authorization` header or a ticket from `POST /v1/sandboxes/{sandbox_id}/ticket`.
255
+ *
256
+ * `GET /v1/sandboxes/{sandbox_id}/pty` · scope `sandboxes:run` · served by the node
257
+ */
258
+ openPty(sandboxId: string, params?: T.SandboxesOpenPtyParams, options?: RequestOptions): Promise<PtySession>;
259
+ /**
260
+ * Resume a sandbox
261
+ *
262
+ * Resumes a paused sandbox. Processes continue where they were, and the guest clock is corrected. Resuming a
263
+ * running sandbox returns it unchanged. A resumed sandbox is billed again (`sandboxes.gib_ms`), so a resume is
264
+ * admitted like a create (credits, spend cap).
265
+ *
266
+ * `POST /v1/sandboxes/{sandbox_id}/resume` · scope `sandboxes:write` · served by the node
267
+ */
268
+ resumeSandbox(sandboxId: string, options?: RequestOptions): APIPromise<T.Sandbox>;
269
+ /**
270
+ * Run code in a kernel
271
+ *
272
+ * Runs code in the sandbox's Jupyter kernel and returns its rich results (text, images, HTML, JSON), output
273
+ * and any error. State persists between calls, like cells in a notebook. Needs a sandbox created from the
274
+ * `code-interpreter` template.
275
+ *
276
+ * `POST /v1/sandboxes/{sandbox_id}/run_code` · scope `sandboxes:run` · served by the node
277
+ */
278
+ runCode(sandboxId: string, body: T.RunCodeRequest, options?: RequestOptions): APIPromise<T.RunCodeResult>;
279
+ /**
280
+ * Snapshot a sandbox
281
+ *
282
+ * Saves the sandbox's memory and disk as a snapshot you can create new sandboxes from. The sandbox keeps
283
+ * running (it pauses for the copy). New sandboxes restored from a snapshot get a fresh identity, so two of them
284
+ * never share random state. Writing the snapshot resets the sandbox's open connections to the outside (open
285
+ * PTY sessions, streaming execs and log streams, port preview connections, outbound TCP connections); new
286
+ * ones work as soon as the call returns.
287
+ *
288
+ * Snapshots are kept 7 days. An organization keeps at most `sandboxes.snapshots_max` snapshots (beta: 20)
289
+ * per node, counting at most `sandboxes.snapshot_storage_max` (beta: 40 GiB). Each snapshot counts its
290
+ * sandbox's memory plus its disk size: the memory is stored whole, and the disk copy comes to hold every
291
+ * block the sandbox rewrites after the snapshot. Past either limit the snapshot is refused with
292
+ * `422 limit_exceeded` until you delete some. While the node's snapshot store is nearly full, snapshots and
293
+ * forks are refused with `503 capacity_unavailable`.
294
+ *
295
+ * `POST /v1/sandboxes/{sandbox_id}/snapshot` · scope `sandboxes:write` · served by the node
296
+ */
297
+ createSnapshot(sandboxId: string, body?: T.SnapshotCreateRequest, options?: RequestOptions): APIPromise<T.Snapshot>;
298
+ /**
299
+ * Create a stream ticket
300
+ *
301
+ * Returns a single-use ticket, valid for 30 seconds, that opens one stream under this sandbox (the terminal
302
+ * WebSocket or the logs event stream) without a bearer header. Pass it as `?ticket=` or in
303
+ * `Sec-WebSocket-Protocol: b3os.v1, b3os.ticket.<ticket>`. The stream runs with this caller's scopes.
304
+ *
305
+ * `POST /v1/sandboxes/{sandbox_id}/ticket` · scope `sandboxes:read` · served by the node
306
+ */
307
+ createTicket(sandboxId: string, options?: RequestOptions): APIPromise<T.StreamTicket>;
308
+ /**
309
+ * Extend a sandbox's timeout
310
+ *
311
+ * Sets the sandbox to expire `timeout_s` seconds from now (up to your plan's maximum lifetime). Works on running
312
+ * and paused sandboxes. A longer life is billed (`sandboxes.vcpu_ms`, `sandboxes.gib_ms`), so the call is
313
+ * admitted like a create (credits, spend cap).
314
+ *
315
+ * `POST /v1/sandboxes/{sandbox_id}/timeout` · scope `sandboxes:write` · served by the node
316
+ */
317
+ setTimeout(sandboxId: string, body: T.TimeoutRequest, options?: RequestOptions): APIPromise<T.Sandbox>;
318
+ }