@boxrouter/sdk 0.0.1-alpha.0 → 0.12.190

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 (338) hide show
  1. package/NOTICE +29 -5
  2. package/README.md +497 -24
  3. package/dist/addresses.d.ts +5 -0
  4. package/dist/addresses.js +10 -0
  5. package/dist/api-error.d.ts +62 -0
  6. package/dist/api-error.js +264 -0
  7. package/dist/boxrouter.d.ts +68 -0
  8. package/dist/boxrouter.js +291 -0
  9. package/dist/browser-session/index.d.ts +17 -0
  10. package/dist/browser-session/index.js +48 -0
  11. package/dist/browser-session/operations.gen.d.ts +272 -0
  12. package/dist/browser-session/operations.gen.js +58 -0
  13. package/dist/browser-session/responseContracts/api_keys.d.ts +2 -0
  14. package/dist/browser-session/responseContracts/api_keys.js +10 -0
  15. package/dist/browser-session/responseContracts/credits.d.ts +2 -0
  16. package/dist/browser-session/responseContracts/credits.js +8 -0
  17. package/dist/browser-session/responseContracts/github.d.ts +2 -0
  18. package/dist/browser-session/responseContracts/github.js +11 -0
  19. package/dist/browser-session/responseContracts/identity.d.ts +2 -0
  20. package/dist/browser-session/responseContracts/identity.js +30 -0
  21. package/dist/browser-session/responseContracts/organizations.d.ts +2 -0
  22. package/dist/browser-session/responseContracts/organizations.js +17 -0
  23. package/dist/browser-session/responseContracts/privacy.d.ts +2 -0
  24. package/dist/browser-session/responseContracts/privacy.js +7 -0
  25. package/dist/browser-session/responseContracts.gen.d.ts +3 -0
  26. package/dist/browser-session/responseContracts.gen.js +10 -0
  27. package/dist/browser-session/responseValidators/api_keys-diagnostics.cjs +1 -0
  28. package/dist/browser-session/responseValidators/api_keys-diagnostics.d.cts +4 -0
  29. package/dist/browser-session/responseValidators/api_keys.cjs +2 -0
  30. package/dist/browser-session/responseValidators/api_keys.d.cts +4 -0
  31. package/dist/browser-session/responseValidators/credits-diagnostics.cjs +1 -0
  32. package/dist/browser-session/responseValidators/credits-diagnostics.d.cts +3 -0
  33. package/dist/browser-session/responseValidators/credits.cjs +2 -0
  34. package/dist/browser-session/responseValidators/credits.d.cts +3 -0
  35. package/dist/browser-session/responseValidators/github-diagnostics.cjs +1 -0
  36. package/dist/browser-session/responseValidators/github-diagnostics.d.cts +3 -0
  37. package/dist/browser-session/responseValidators/github.cjs +2 -0
  38. package/dist/browser-session/responseValidators/github.d.cts +3 -0
  39. package/dist/browser-session/responseValidators/identity-diagnostics.cjs +1 -0
  40. package/dist/browser-session/responseValidators/identity-diagnostics.d.cts +23 -0
  41. package/dist/browser-session/responseValidators/identity.cjs +2 -0
  42. package/dist/browser-session/responseValidators/identity.d.cts +23 -0
  43. package/dist/browser-session/responseValidators/organizations-diagnostics.cjs +1 -0
  44. package/dist/browser-session/responseValidators/organizations-diagnostics.d.cts +15 -0
  45. package/dist/browser-session/responseValidators/organizations.cjs +2 -0
  46. package/dist/browser-session/responseValidators/organizations.d.cts +15 -0
  47. package/dist/browser-session/responseValidators/privacy-diagnostics.cjs +1 -0
  48. package/dist/browser-session/responseValidators/privacy-diagnostics.d.cts +2 -0
  49. package/dist/browser-session/responseValidators/privacy.cjs +2 -0
  50. package/dist/browser-session/responseValidators/privacy.d.cts +2 -0
  51. package/dist/client/client.gen.d.ts +1 -1
  52. package/dist/client/client.gen.js +46 -94
  53. package/dist/client/index.d.ts +10 -10
  54. package/dist/client/index.js +16 -5
  55. package/dist/client/types.gen.d.ts +6 -6
  56. package/dist/client/types.gen.js +2 -1
  57. package/dist/client/utils.gen.d.ts +2 -2
  58. package/dist/client/utils.gen.js +31 -20
  59. package/dist/client.gen.d.ts +2 -2
  60. package/dist/client.gen.js +5 -2
  61. package/dist/command-check.gen.d.ts +14 -0
  62. package/dist/command-check.gen.js +23 -0
  63. package/dist/command-input.gen.d.ts +6 -0
  64. package/dist/command-input.gen.js +45 -0
  65. package/dist/core/auth.gen.js +5 -1
  66. package/dist/core/binaryStream.d.ts +8 -0
  67. package/dist/core/binaryStream.js +76 -0
  68. package/dist/core/bodySerializer.gen.d.ts +1 -1
  69. package/dist/core/bodySerializer.gen.js +8 -5
  70. package/dist/core/commandValidators.cjs +1 -0
  71. package/dist/core/commandValidators.d.cts +14 -0
  72. package/dist/core/eventValidation.d.ts +17 -0
  73. package/dist/core/eventValidation.js +56 -0
  74. package/dist/core/eventValidators.cjs +1 -0
  75. package/dist/core/eventValidators.d.cts +2 -0
  76. package/dist/core/json.d.ts +3 -0
  77. package/dist/core/json.js +33 -0
  78. package/dist/core/params.gen.js +4 -1
  79. package/dist/core/pathSerializer.gen.js +20 -11
  80. package/dist/core/queryKeySerializer.gen.js +12 -6
  81. package/dist/core/responseContracts/actions.d.ts +2 -0
  82. package/dist/core/responseContracts/actions.js +30 -0
  83. package/dist/core/responseContracts/agents.d.ts +2 -0
  84. package/dist/core/responseContracts/agents.js +7 -0
  85. package/dist/core/responseContracts/artifacts.d.ts +2 -0
  86. package/dist/core/responseContracts/artifacts.js +8 -0
  87. package/dist/core/responseContracts/commands.d.ts +2 -0
  88. package/dist/core/responseContracts/commands.js +6 -0
  89. package/dist/core/responseContracts/credits.d.ts +2 -0
  90. package/dist/core/responseContracts/credits.js +27 -0
  91. package/dist/core/responseContracts/files.d.ts +2 -0
  92. package/dist/core/responseContracts/files.js +15 -0
  93. package/dist/core/responseContracts/github.d.ts +2 -0
  94. package/dist/core/responseContracts/github.js +8 -0
  95. package/dist/core/responseContracts/images.d.ts +2 -0
  96. package/dist/core/responseContracts/images.js +8 -0
  97. package/dist/core/responseContracts/launchRuns.d.ts +2 -0
  98. package/dist/core/responseContracts/launchRuns.js +10 -0
  99. package/dist/core/responseContracts/launches.d.ts +2 -0
  100. package/dist/core/responseContracts/launches.js +10 -0
  101. package/dist/core/responseContracts/operations.d.ts +2 -0
  102. package/dist/core/responseContracts/operations.js +7 -0
  103. package/dist/core/responseContracts/previews.d.ts +2 -0
  104. package/dist/core/responseContracts/previews.js +8 -0
  105. package/dist/core/responseContracts/pricing.d.ts +2 -0
  106. package/dist/core/responseContracts/pricing.js +6 -0
  107. package/dist/core/responseContracts/processes.d.ts +2 -0
  108. package/dist/core/responseContracts/processes.js +11 -0
  109. package/dist/core/responseContracts/provider_accounts.d.ts +2 -0
  110. package/dist/core/responseContracts/provider_accounts.js +13 -0
  111. package/dist/core/responseContracts/providers.d.ts +2 -0
  112. package/dist/core/responseContracts/providers.js +6 -0
  113. package/dist/core/responseContracts/routing.d.ts +2 -0
  114. package/dist/core/responseContracts/routing.js +8 -0
  115. package/dist/core/responseContracts/sandboxes.d.ts +2 -0
  116. package/dist/core/responseContracts/sandboxes.js +15 -0
  117. package/dist/core/responseContracts/secrets.d.ts +2 -0
  118. package/dist/core/responseContracts/secrets.js +8 -0
  119. package/dist/core/responseContracts/spend_limits.d.ts +2 -0
  120. package/dist/core/responseContracts/spend_limits.js +8 -0
  121. package/dist/core/responseContracts/terminals.d.ts +2 -0
  122. package/dist/core/responseContracts/terminals.js +11 -0
  123. package/dist/core/responseContracts/usage.d.ts +2 -0
  124. package/dist/core/responseContracts/usage.js +7 -0
  125. package/dist/core/responseContracts/volumes.d.ts +2 -0
  126. package/dist/core/responseContracts/volumes.js +19 -0
  127. package/dist/core/responseContracts.gen.d.ts +3 -0
  128. package/dist/core/responseContracts.gen.js +27 -0
  129. package/dist/core/responseModes.d.ts +19 -0
  130. package/dist/core/responseModes.js +13 -0
  131. package/dist/core/responseValidation.d.ts +44 -0
  132. package/dist/core/responseValidation.js +174 -0
  133. package/dist/core/responseValidators/actions-diagnostics.cjs +4 -0
  134. package/dist/core/responseValidators/actions-diagnostics.d.cts +24 -0
  135. package/dist/core/responseValidators/actions.cjs +2 -0
  136. package/dist/core/responseValidators/actions.d.cts +24 -0
  137. package/dist/core/responseValidators/agents-diagnostics.cjs +1 -0
  138. package/dist/core/responseValidators/agents-diagnostics.d.cts +2 -0
  139. package/dist/core/responseValidators/agents.cjs +2 -0
  140. package/dist/core/responseValidators/agents.d.cts +2 -0
  141. package/dist/core/responseValidators/artifacts-diagnostics.cjs +1 -0
  142. package/dist/core/responseValidators/artifacts-diagnostics.d.cts +2 -0
  143. package/dist/core/responseValidators/artifacts.cjs +2 -0
  144. package/dist/core/responseValidators/artifacts.d.cts +2 -0
  145. package/dist/core/responseValidators/commands-diagnostics.cjs +1 -0
  146. package/dist/core/responseValidators/commands-diagnostics.d.cts +1 -0
  147. package/dist/core/responseValidators/commands.cjs +2 -0
  148. package/dist/core/responseValidators/commands.d.cts +1 -0
  149. package/dist/core/responseValidators/compact.cjs +122 -0
  150. package/dist/core/responseValidators/credits-diagnostics.cjs +1 -0
  151. package/dist/core/responseValidators/credits-diagnostics.d.cts +21 -0
  152. package/dist/core/responseValidators/credits.cjs +2 -0
  153. package/dist/core/responseValidators/credits.d.cts +21 -0
  154. package/dist/core/responseValidators/files-diagnostics.cjs +1 -0
  155. package/dist/core/responseValidators/files-diagnostics.d.cts +5 -0
  156. package/dist/core/responseValidators/files.cjs +2 -0
  157. package/dist/core/responseValidators/files.d.cts +5 -0
  158. package/dist/core/responseValidators/github-diagnostics.cjs +1 -0
  159. package/dist/core/responseValidators/github-diagnostics.d.cts +2 -0
  160. package/dist/core/responseValidators/github.cjs +2 -0
  161. package/dist/core/responseValidators/github.d.cts +2 -0
  162. package/dist/core/responseValidators/images-diagnostics.cjs +1 -0
  163. package/dist/core/responseValidators/images-diagnostics.d.cts +3 -0
  164. package/dist/core/responseValidators/images.cjs +2 -0
  165. package/dist/core/responseValidators/images.d.cts +3 -0
  166. package/dist/core/responseValidators/launchRuns-diagnostics.cjs +1 -0
  167. package/dist/core/responseValidators/launchRuns-diagnostics.d.cts +5 -0
  168. package/dist/core/responseValidators/launchRuns.cjs +2 -0
  169. package/dist/core/responseValidators/launchRuns.d.cts +5 -0
  170. package/dist/core/responseValidators/launches-diagnostics.cjs +10 -0
  171. package/dist/core/responseValidators/launches-diagnostics.d.cts +5 -0
  172. package/dist/core/responseValidators/launches.cjs +2 -0
  173. package/dist/core/responseValidators/launches.d.cts +5 -0
  174. package/dist/core/responseValidators/operations-diagnostics.cjs +1 -0
  175. package/dist/core/responseValidators/operations-diagnostics.d.cts +2 -0
  176. package/dist/core/responseValidators/operations.cjs +2 -0
  177. package/dist/core/responseValidators/operations.d.cts +2 -0
  178. package/dist/core/responseValidators/previews-diagnostics.cjs +1 -0
  179. package/dist/core/responseValidators/previews-diagnostics.d.cts +3 -0
  180. package/dist/core/responseValidators/previews.cjs +2 -0
  181. package/dist/core/responseValidators/previews.d.cts +3 -0
  182. package/dist/core/responseValidators/pricing-diagnostics.cjs +7 -0
  183. package/dist/core/responseValidators/pricing-diagnostics.d.cts +1 -0
  184. package/dist/core/responseValidators/pricing.cjs +2 -0
  185. package/dist/core/responseValidators/pricing.d.cts +1 -0
  186. package/dist/core/responseValidators/processes-diagnostics.cjs +1 -0
  187. package/dist/core/responseValidators/processes-diagnostics.d.cts +2 -0
  188. package/dist/core/responseValidators/processes.cjs +2 -0
  189. package/dist/core/responseValidators/processes.d.cts +2 -0
  190. package/dist/core/responseValidators/provider_accounts-diagnostics.cjs +1 -0
  191. package/dist/core/responseValidators/provider_accounts-diagnostics.d.cts +8 -0
  192. package/dist/core/responseValidators/provider_accounts.cjs +2 -0
  193. package/dist/core/responseValidators/provider_accounts.d.cts +8 -0
  194. package/dist/core/responseValidators/providers-diagnostics.cjs +1 -0
  195. package/dist/core/responseValidators/providers-diagnostics.d.cts +1 -0
  196. package/dist/core/responseValidators/providers.cjs +2 -0
  197. package/dist/core/responseValidators/providers.d.cts +1 -0
  198. package/dist/core/responseValidators/routing-diagnostics.cjs +1 -0
  199. package/dist/core/responseValidators/routing-diagnostics.d.cts +3 -0
  200. package/dist/core/responseValidators/routing.cjs +2 -0
  201. package/dist/core/responseValidators/routing.d.cts +3 -0
  202. package/dist/core/responseValidators/sandboxes-diagnostics.cjs +1 -0
  203. package/dist/core/responseValidators/sandboxes-diagnostics.d.cts +10 -0
  204. package/dist/core/responseValidators/sandboxes.cjs +2 -0
  205. package/dist/core/responseValidators/sandboxes.d.cts +10 -0
  206. package/dist/core/responseValidators/secrets-diagnostics.cjs +1 -0
  207. package/dist/core/responseValidators/secrets-diagnostics.d.cts +1 -0
  208. package/dist/core/responseValidators/secrets.cjs +2 -0
  209. package/dist/core/responseValidators/secrets.d.cts +1 -0
  210. package/dist/core/responseValidators/spend_limits-diagnostics.cjs +1 -0
  211. package/dist/core/responseValidators/spend_limits-diagnostics.d.cts +3 -0
  212. package/dist/core/responseValidators/spend_limits.cjs +2 -0
  213. package/dist/core/responseValidators/spend_limits.d.cts +3 -0
  214. package/dist/core/responseValidators/terminals-diagnostics.cjs +1 -0
  215. package/dist/core/responseValidators/terminals-diagnostics.d.cts +2 -0
  216. package/dist/core/responseValidators/terminals.cjs +2 -0
  217. package/dist/core/responseValidators/terminals.d.cts +2 -0
  218. package/dist/core/responseValidators/usage-diagnostics.cjs +1 -0
  219. package/dist/core/responseValidators/usage-diagnostics.d.cts +1 -0
  220. package/dist/core/responseValidators/usage.cjs +2 -0
  221. package/dist/core/responseValidators/usage.d.cts +1 -0
  222. package/dist/core/responseValidators/volumes-diagnostics.cjs +1 -0
  223. package/dist/core/responseValidators/volumes-diagnostics.d.cts +10 -0
  224. package/dist/core/responseValidators/volumes.cjs +2 -0
  225. package/dist/core/responseValidators/volumes.d.cts +10 -0
  226. package/dist/core/serverSentEvents.gen.d.ts +21 -62
  227. package/dist/core/serverSentEvents.gen.js +297 -116
  228. package/dist/core/streamErrors.d.ts +32 -0
  229. package/dist/core/streamErrors.js +51 -0
  230. package/dist/core/types.gen.d.ts +2 -2
  231. package/dist/core/types.gen.js +2 -1
  232. package/dist/core/utils.gen.d.ts +1 -1
  233. package/dist/core/utils.gen.js +16 -10
  234. package/dist/creation.gen.d.ts +21 -0
  235. package/dist/creation.gen.js +35 -0
  236. package/dist/data-origin.d.ts +25 -0
  237. package/dist/data-origin.js +57 -0
  238. package/dist/error-codes.gen.d.ts +2 -0
  239. package/dist/error-codes.gen.js +2 -0
  240. package/dist/idempotency.gen.d.ts +1 -0
  241. package/dist/idempotency.gen.js +60 -0
  242. package/dist/images.d.ts +74 -0
  243. package/dist/images.js +88 -0
  244. package/dist/index.d.ts +22 -2
  245. package/dist/index.js +79 -1
  246. package/dist/launch-input.gen.d.ts +9 -0
  247. package/dist/launch-input.gen.js +83 -0
  248. package/dist/launch.d.ts +28 -0
  249. package/dist/launch.js +222 -0
  250. package/dist/namespace-actions.d.mts +307 -0
  251. package/dist/namespace-actions.mjs +595 -0
  252. package/dist/namespace-agents.d.mts +33 -0
  253. package/dist/namespace-agents.mjs +40 -0
  254. package/dist/namespace-artifacts.d.mts +46 -0
  255. package/dist/namespace-artifacts.mjs +69 -0
  256. package/dist/namespace-base.d.mts +7 -0
  257. package/dist/namespace-base.mjs +7 -0
  258. package/dist/namespace-commands.d.mts +57 -0
  259. package/dist/namespace-commands.mjs +57 -0
  260. package/dist/namespace-credits.d.mts +213 -0
  261. package/dist/namespace-credits.mjs +476 -0
  262. package/dist/namespace-files.d.mts +203 -0
  263. package/dist/namespace-files.mjs +334 -0
  264. package/dist/namespace-github.d.mts +50 -0
  265. package/dist/namespace-github.mjs +68 -0
  266. package/dist/namespace-images.d.mts +52 -0
  267. package/dist/namespace-images.mjs +78 -0
  268. package/dist/namespace-launch_runs.d.mts +89 -0
  269. package/dist/namespace-launch_runs.mjs +133 -0
  270. package/dist/namespace-launches.d.mts +89 -0
  271. package/dist/namespace-launches.mjs +133 -0
  272. package/dist/namespace-operations.d.mts +45 -0
  273. package/dist/namespace-operations.mjs +52 -0
  274. package/dist/namespace-previews.d.mts +79 -0
  275. package/dist/namespace-previews.mjs +101 -0
  276. package/dist/namespace-pricing.d.mts +31 -0
  277. package/dist/namespace-pricing.mjs +22 -0
  278. package/dist/namespace-processes.d.mts +125 -0
  279. package/dist/namespace-processes.mjs +184 -0
  280. package/dist/namespace-provider_accounts.d.mts +156 -0
  281. package/dist/namespace-provider_accounts.mjs +241 -0
  282. package/dist/namespace-providers.d.mts +28 -0
  283. package/dist/namespace-providers.mjs +24 -0
  284. package/dist/namespace-routing.d.mts +64 -0
  285. package/dist/namespace-routing.mjs +86 -0
  286. package/dist/namespace-sandboxes.d.mts +287 -0
  287. package/dist/namespace-sandboxes.mjs +402 -0
  288. package/dist/namespace-secrets.d.mts +46 -0
  289. package/dist/namespace-secrets.mjs +68 -0
  290. package/dist/namespace-spend_limits.d.mts +48 -0
  291. package/dist/namespace-spend_limits.mjs +70 -0
  292. package/dist/namespace-terminals.d.mts +112 -0
  293. package/dist/namespace-terminals.mjs +177 -0
  294. package/dist/namespace-usage.d.mts +46 -0
  295. package/dist/namespace-usage.mjs +53 -0
  296. package/dist/namespace-volumes.d.mts +110 -0
  297. package/dist/namespace-volumes.mjs +269 -0
  298. package/dist/operations.d.ts +14 -0
  299. package/dist/operations.js +31 -0
  300. package/dist/retry.d.ts +8 -0
  301. package/dist/retry.js +63 -0
  302. package/dist/routing-choices.gen.d.ts +132 -0
  303. package/dist/routing-choices.gen.js +136 -0
  304. package/dist/routing.d.ts +23 -0
  305. package/dist/routing.js +38 -0
  306. package/dist/sandbox-handle.gen.d.ts +8 -0
  307. package/dist/sandbox-handle.gen.js +14 -0
  308. package/dist/sandboxes.d.ts +213 -0
  309. package/dist/sandboxes.js +507 -0
  310. package/dist/sdk.gen.d.ts +2016 -12
  311. package/dist/sdk.gen.js +3862 -16
  312. package/dist/server-timing.d.ts +19 -0
  313. package/dist/server-timing.gen.d.ts +265 -0
  314. package/dist/server-timing.gen.js +254 -0
  315. package/dist/server-timing.js +421 -0
  316. package/dist/spend-limits.d.ts +17 -0
  317. package/dist/spend-limits.js +26 -0
  318. package/dist/telemetry.d.ts +51 -0
  319. package/dist/telemetry.gen.d.ts +1 -0
  320. package/dist/telemetry.gen.js +5 -0
  321. package/dist/telemetry.js +438 -0
  322. package/dist/terminal.d.ts +61 -0
  323. package/dist/terminal.js +266 -0
  324. package/dist/transfer.d.ts +75 -0
  325. package/dist/transfer.js +389 -0
  326. package/dist/types.gen.d.ts +14936 -110
  327. package/dist/types.gen.js +2 -1
  328. package/dist/user-agent.d.ts +2 -0
  329. package/dist/user-agent.js +18 -0
  330. package/dist/version.gen.d.ts +1 -0
  331. package/dist/version.gen.js +5 -0
  332. package/dist/volumes.d.ts +33 -0
  333. package/dist/volumes.js +221 -0
  334. package/dist/waits.d.ts +31 -0
  335. package/dist/waits.js +42 -0
  336. package/dist/workflow-policy.gen.d.ts +41 -0
  337. package/dist/workflow-policy.gen.js +45 -0
  338. package/package.json +124 -14
package/NOTICE CHANGED
@@ -1,15 +1,39 @@
1
1
  BoxRouter TypeScript SDK
2
- Copyright 2026 BoxRouter
2
+ Copyright 2026 BoxRouter, Inc.
3
3
 
4
4
  This distribution contains API client code generated from BoxRouter's OpenAPI
5
5
  contract and runtime support authored by BoxRouter. Third-party packages are
6
6
  installed separately and remain under their respective licenses.
7
7
 
8
8
  The OpenAPI contract includes schema material from the separately licensed
9
- Sandbox Provider Specification and provider-pricing projects. Both projects are
10
- licensed under Apache License 2.0; see their authoritative license files:
11
- https://github.com/boxrouter/sandbox-provider-spec/blob/main/LICENSE
12
- https://github.com/boxrouter/sandbox-provider-pricing/blob/main/LICENSE
9
+ Sandbox Provider Specification and sandbox-provider-pricing projects. Both projects are
10
+ licensed under Apache License 2.0; the Apache License text is included in LICENSE
11
+
12
+ The files under dist/client and dist/core are runtime code emitted by
13
+ @hey-api/openapi-ts (https://github.com/hey-api/openapi-ts), which is licensed
14
+ under the MIT License:
15
+
16
+ MIT License
17
+
18
+ Copyright (c) Hey API
19
+
20
+ Permission is hereby granted, free of charge, to any person obtaining a copy
21
+ of this software and associated documentation files (the "Software"), to deal
22
+ in the Software without restriction, including without limitation the rights
23
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
24
+ copies of the Software, and to permit persons to whom the Software is
25
+ furnished to do so, subject to the following conditions:
26
+
27
+ The above copyright notice and this permission notice shall be included in all
28
+ copies or substantial portions of the Software.
29
+
30
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
31
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
32
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
33
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
34
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
35
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
36
+ SOFTWARE.
13
37
 
14
38
  Provider names, provider API descriptions, and linked provider documentation
15
39
  remain the property of their respective owners. References do not imply
package/README.md CHANGED
@@ -1,36 +1,509 @@
1
- # BoxRouter JavaScript SDK — discovery preview
1
+ # BoxRouter TypeScript SDK
2
2
 
3
- An early, read-only client for discovering the provider routes available to your
4
- BoxRouter workspace. Requires Node.js 22.18 or later and access to a BoxRouter
5
- deployment. Sandbox creation and other SDK operations are not included.
6
- The API may change before the full SDK release.
3
+ > **Alpha.** The API can change in any release, and a release can be withdrawn.
4
+ > Pin an exact version.
7
5
 
8
- This release uses the `alpha` tag; no `latest` release is published.
6
+ Requires the Node.js version declared in the package manifest's `engines.node` field. Install the SDK from npm:
9
7
 
10
8
  ```sh
11
- npm install @boxrouter/sdk@alpha
9
+ npm install @boxrouter/sdk
12
10
  ```
13
11
 
14
- ```js
15
- import { listProviders } from '@boxrouter/sdk';
12
+ The package contains CommonJS JavaScript and TypeScript declarations. Use the
13
+ named ESM import from an `.mjs` file or a project with `"type": "module"`;
14
+ CommonJS applications can use `require('@boxrouter/sdk')` from `.cjs` files.
16
15
 
17
- const result = await listProviders({
18
- baseUrl: process.env.BOXROUTER_BASE_URL,
19
- auth: process.env.BOXROUTER_API_KEY,
20
- throwOnError: true,
16
+ Create an execution API key in BoxRouter, configure a provider account such as
17
+ E2B or Modal. Provider credentials stay in BoxRouter. Sandbox creation may
18
+ incur charges from the selected provider:
19
+
20
+ ```sh
21
+ export BOXROUTER_API_KEY='your-execution-key'
22
+ ```
23
+
24
+ The client defaults to the hosted API. Set `BOXROUTER_BASE_URL` (or pass `baseUrl`)
25
+ for another deployment.
26
+
27
+ <!-- quickstart:start -->
28
+ ```typescript
29
+ import { BoxRouter } from '@boxrouter/sdk';
30
+
31
+ const client = new BoxRouter({
32
+ apiKey: process.env.BOXROUTER_API_KEY,
33
+ });
34
+ let box;
35
+ try {
36
+ box = await client.sandboxes.create({});
37
+ await box.files.write('/tmp/hello.txt', 'hello');
38
+ const result = await box.exec('cat /tmp/hello.txt');
39
+ process.stdout.write(result.stdout);
40
+ } finally {
41
+ try {
42
+ if (box) await box.destroy();
43
+ } finally {
44
+ await client.close();
45
+ }
46
+ }
47
+ ```
48
+ <!-- quickstart:end -->
49
+
50
+ The example prints `hello`.
51
+
52
+ `box.destroy()` asks BoxRouter to destroy the remote sandbox and returns the `Sandbox` Cloud
53
+ answers with (see "The sandbox object" below). `client.close()`
54
+ closes only the local Node connection pool; it does not affect the sandbox. If
55
+ destroying the sandbox fails or its response is lost, the remote outcome is
56
+ unknown and should be checked before you try again. Closing still releases the
57
+ local connection pool. A client created with a caller-supplied `fetch` does not
58
+ close that fetch implementation; a `withUserAgentSuffix()` view does not own
59
+ the parent client's pool. Closing either one therefore does not close the
60
+ custom transport or the parent's pool; close the owning client instead. Before
61
+ awaiting `client.close()`, consume or cancel any active response streams. The
62
+ pool closes gracefully after in-flight requests finish, so an unread stream can
63
+ keep `close()` pending.
64
+
65
+ The following blocks are fragments. Create a fresh client as above and close it when you finish.
66
+ Destroy any sandbox you create; the examples below show cleanup for their own sandboxes.
67
+
68
+ To receive Cloud's bounded Server-Timing measurements, opt in with a fetch wrapper.
69
+ The callback runs after the response body is consumed or canceled; `clientMs` includes
70
+ fetch and body transfer, while `cloudMs`, `databaseMs`, `codeMs`, `providerConnectMs`
71
+ and `providerWaitMs` are `null` when the server does not provide them. The wrapper keeps
72
+ native `Response.clone()` behavior and pulls stream data only when the caller reads it.
73
+ The callback receives only these durations and never request or credential data.
74
+
75
+ ```typescript
76
+ import { BoxRouter, createServerTimingFetch } from '@boxrouter/sdk';
77
+
78
+ const client = new BoxRouter({
79
+ apiKey: process.env.BOXROUTER_API_KEY!,
80
+ fetch: createServerTimingFetch(timing => console.log(timing)),
81
+ });
82
+ ```
83
+
84
+ State what the sandbox needs instead of naming a provider: gates by name in
85
+ `requirements`, `resources`, a lifetime and ranking preferences. Routes that cannot
86
+ satisfy them are excluded before routing, and the sandbox records its contract and why
87
+ its route was chosen. `match` returns the same evaluation without creating anything:
88
+
89
+ ```typescript
90
+ const needs = {
91
+ lifetime_seconds: 1800,
92
+ at_end: 'pause' as const,
93
+ requirements: { pause_resume: {} },
94
+ resources: { cpu_min: 2, memory_min_mib: 4096 },
95
+ preferences: { sort: 'price' as const },
96
+ };
97
+ console.log((await client.sandboxes.match(needs)).eligible.map(route => route.provider));
98
+ const routed = await client.sandboxes.create(needs);
99
+ try {
100
+ console.log(routed.route?.provider, routed.contract?.spec_version);
101
+ } finally {
102
+ await routed.destroy();
103
+ }
104
+ ```
105
+
106
+ An image in a registry that needs a login: `privateImage()` returns the `image` and the
107
+ request-only `registry_credentials` (Cloud never stores, logs or returns them). Spread it
108
+ into a create, match or prepare body. Private images run on your own provider keys, so
109
+ connect that provider account first:
110
+
111
+ ```typescript
112
+ import { privateImage } from '@boxrouter/sdk';
113
+
114
+ const login = { username: 'reader', password: process.env.REGISTRY_TOKEN! };
115
+ const box = await client.sandboxes.create({
116
+ ...privateImage('ghcr.io/acme/app:1', login),
117
+ preferences: { only: ['e2b'] },
118
+ });
119
+ try {
120
+ console.log(box.id);
121
+ } finally {
122
+ await box.destroy();
123
+ }
124
+ ```
125
+
126
+ `launch` takes it too, spread into its options. The manifest's `image` is `{ private_oci }` and
127
+ the login goes only in the launch request's `registry_credentials`:
128
+
129
+ ```typescript
130
+ const box = await client.sandboxes.launch(
131
+ { ...privateImage('ghcr.io/acme/app:1', login), provider: 'e2b' });
132
+ ```
133
+
134
+ Prepare an image ahead of its first sandbox so no create pays for the setup. `prepare`
135
+ waits: it resolves once no selected provider is `queued` or `preparing`, so read each
136
+ provider's `state` in the result. Pass `{ wait: false }` as the second argument to get the
137
+ started status at once; if preparation is still pending after the wait's bound, `prepare`
138
+ rejects with a `WaitTimeoutError` (name `TimeoutError`), setup continues, and
139
+ `preparations` reads it. Name the
140
+ providers, or pass the body you would send to `create` as `match` and BoxRouter prepares
141
+ the first `top` providers that create would rank best. `prepare` takes exactly one of the
142
+ two forms and rejects otherwise. `privateImage()` works in both, on providers you
143
+ connected with your own key; its login is used once for the setup and never stored:
144
+
145
+ ```typescript
146
+ await client.images.prepare({ image: 'app:v12', providers: ['e2b'], sizes: [4] });
147
+ await client.images.prepare({
148
+ match: { image: 'app:v12', resources: { cpu_min: 2 } },
149
+ top: 2,
150
+ });
151
+ await client.images.prepare({
152
+ match: { ...privateImage('ghcr.io/acme/app:1', login), resources: { cpu_min: 2 } },
153
+ top: 2,
154
+ });
155
+ const started = await client.images.prepare({ image: 'app:v12', providers: ['e2b'] }, { wait: false });
156
+ console.log(await client.images.preparations('app:v12', ['e2b']));
157
+ await client.images.unprepare('app:v12', ['e2b']);
158
+ ```
159
+
160
+ Status and unprepare name a private tag that this workspace prepared or created with its
161
+ login before; for any other private tag, name its digest (`repo@sha256:...`).
162
+
163
+ Every handle has `pause()`, `resume()`, `extend()` and `previews.open()`. Name the
164
+ requirement a method needs when you create the sandbox: `requirements` takes a list of
165
+ requirement names or the object form, and the list `['pause_resume']` sends
166
+ `{ "pause_resume": {} }`. A sandbox created without the requirement answers a gated
167
+ call with an `APIError` whose `code` is `'not_named'` (status 409). An unknown name in
168
+ the list throws a `TypeError` that lists the accepted names. The preview example opens a
169
+ public link and destroys its sandbox immediately. To use the link, start a service on
170
+ port 3000 and keep the sandbox running:
171
+
172
+ ```typescript
173
+ const paused = await client.sandboxes.create({ requirements: ['pause_resume'] });
174
+ try {
175
+ await paused.pause(); // Paused; paused.state is now 'paused'
176
+ await paused.resume(); // Resumed, or undefined when it was already running
177
+ await paused.extend({ lifetime_seconds: 1800 }); // Lifetime; 1800 is the new total, not an increment
178
+ } finally {
179
+ await paused.destroy();
180
+ }
181
+
182
+ const previewable = await client.sandboxes.create({
183
+ requirements: { previews: { access: 'public', ports: [3000] } },
184
+ });
185
+ try {
186
+ console.log((await previewable.previews.open(3000)).url);
187
+ } finally {
188
+ await previewable.destroy();
189
+ }
190
+ ```
191
+
192
+ `pause()`, `resume()` and `extend()` update the handle's `state` and `lifetime`.
193
+ `client.sandboxes.list(query?)` returns one `SandboxPage` of your sandboxes.
194
+
195
+ Editors use the declarations automatically. For a standalone type check or a CI
196
+ type-check step, run:
197
+
198
+ ```sh
199
+ npx tsc --noEmit --strict --target ES2022 --module NodeNext \
200
+ --moduleResolution NodeNext --lib ES2022,DOM,DOM.Iterable,ESNext.Disposable src/index.ts
201
+ ```
202
+
203
+ ## The sandbox object
204
+
205
+ There is one sandbox shape. A handle from `create()` or `get(id)` exposes every field of the
206
+ `Sandbox` as a read-only property, using the wire names: `box.id`, `box.state`,
207
+ `box.lifetime`, `box.cost`, `box.route`, `box.contract`, `box.volume` and the rest. `route`
208
+ and `contract` are `null` for a sandbox recorded without them. Properties show the last
209
+ response, so they change only when you call `refresh()`, `destroy()`, `pause()`, `resume()` or `extend()`:
210
+
211
+ ```typescript
212
+ const box = await client.sandboxes.get('SANDBOX_ID');
213
+ console.log(box.state, box.lifetime.remaining_seconds, box.cost?.label);
214
+ await box.refresh();
215
+ console.log(box.state);
216
+ ```
217
+
218
+ `refresh()` reads the sandbox again and updates the handle. A handle for an ended
219
+ sandbox answers the first operation with the usual `sandbox_ended` API error.
220
+
221
+ `destroy()` always answers with the `Sandbox`, and the handle takes its fields. While the
222
+ destroy is pending, `state` is `destroying` and `operation_id` names the operation Cloud
223
+ finishes without you; once confirmed, `state` is `destroyed` and `operation_id` is `null`.
224
+ Destroying again returns the confirmed sandbox:
225
+
226
+ ```typescript
227
+ const box = await client.sandboxes.create({});
228
+ try {
229
+ await box.exec('true');
230
+ } finally {
231
+ const ended = await box.destroy();
232
+ console.log(ended.state, box.state, ended.operation_id);
233
+ }
234
+ ```
235
+
236
+ Create, inspect, checkpoint and remove persistent volumes with `client.volumes`: use
237
+ `create`, `list`, `get`, `listCheckpoints`, `getCheckpoint`, `save`, `deleteCheckpoint`,
238
+ `release` and `delete`. A sandbox attached to a volume can call
239
+ `box.saveVolume({ message })`; `box.destroy({ discardUnsaved: true })` explicitly
240
+ allows destruction to discard changes if saving fails.
241
+
242
+ When no route qualifies, creation throws `APIError` with code `no_eligible_route`;
243
+ `error.error.details` lists every excluded route with the checks it failed and the
244
+ nearest changes. A body written in the retired 0.2.0 words (`timeout_seconds`, `egress`,
245
+ `provider`, a dotted `requirements` key) is refused by the type checker and, if sent
246
+ anyway, by the server with `invalid_request`.
247
+
248
+ For output while a command runs, start a background process (E2B, Modal, Blaxel):
249
+
250
+ ```typescript
251
+ const running = await box.processes.start('make test');
252
+ let output = await running.read(); // stdout_base64, stderr_base64, next_stdout, next_stderr, exit_code
253
+ output = await running.read({ stdout: output.next_stdout, stderr: output.next_stderr });
254
+ const done = await running.wait({ timeoutSeconds: 600 });
255
+ console.log(done.exit_code);
256
+ await running.remove();
257
+ ```
258
+
259
+ `read()` returns up to 256 KiB per stream from the byte offsets you pass and never blocks;
260
+ `exit_code` is set once the process ended and both streams were read to their ends.
261
+ `wait()` polls `read()` and returns all output from its offsets, rejecting with a
262
+ `TimeoutError` when `timeoutSeconds` passes; the command keeps running. Use
263
+ `running.cancel()` to stop it and `running.remove()` to delete its retained output. With
264
+ `stdin: true`, `writeStdin()` and `closeStdin()` feed it.
265
+
266
+ Files read as `Uint8Array`. Commands return `stdout`, `stderr` and `exit_code`;
267
+ nonzero exit status is a workload result. `native_error` keeps the provider's error for
268
+ the command when it reports one. HTTP failures raise the exported
269
+ `APIError`: retain `requestId`, `operationId`, `outcome` and `idempotencyKey`; its
270
+ `error` object keeps the complete envelope, including `provider`, `native_status` and
271
+ `native_code`.
272
+ This applies to `BoxRouter`, direct `BoxRouterApi` calls, and transport result
273
+ errors. Error diagnostics read at most 64 KiB; non-JSON error bodies are omitted
274
+ and header request IDs remain available. Successful responses must match the
275
+ operation's declared status and media type, and every property the client knows must
276
+ match its JSON schema, including when selecting another parsing format. A property a
277
+ newer API adds is accepted and left on the returned value; the types do not declare it.
278
+ Invalid responses raise `APIError`, preserving status, request ID and mutation key
279
+ without copying decoder text or payloads. For a read (GET) the message says the read
280
+ failed, nothing was changed and it can be retried; for any other method it says the
281
+ result is unconfirmed and to inspect the operation before retrying. When no kind of record
282
+ matched, it adds that a newer SDK is needed if it keeps failing. A stream skips an event of
283
+ a kind this client does not know and still ends at its terminal event. A response enum the
284
+ API grows (a sandbox's `state` and `state_reason`, an API key's `permissions`) is typed as its
285
+ known values plus any string, so a value added later reaches your code.
286
+ Failures before HTTP headers remain fetch exceptions and are not resent. Every API error carries
287
+ `retry` (`safe`, `after_fix`, `check_outcome` or `never`) and `retry_after_seconds`; `APIError` exposes them as
288
+ `status`, `retry`, `retryAfterSeconds` and `details`, and `docUrl` is the page that explains the code. The client resends only `retry: "safe"` (nothing ran
289
+ and waiting helps), with the same idempotency key, up to `maxRetries` times (`new BoxRouter({ maxRetries: 2 })`
290
+ is the default; 0 turns it off), waiting `retry_after_seconds` or a doubling backoff; a wait longer than the
291
+ client sleeps is raised instead. A call with a request body is resent only when it carries an idempotency key.
292
+ HTTP redirects are rejected by default, including for buffered requests, so a
293
+ redirect cannot automatically forward credentials or replay a mutation. Use the
294
+ API's final URL as `baseUrl`. Low-level request options retain explicit Fetch
295
+ redirect controls; choosing `redirect: 'follow'` permits request forwarding.
296
+ A timeout or lost response can leave work running; inspect operation history
297
+ before submitting new work. Failed cleanup does not establish destruction.
298
+
299
+ Every method of this entry point is provider-neutral. Generated methods are broader
300
+ than implemented hosted support: a sandbox may use only the gates its creation named, so
301
+ read `box.contract?.gates` for what each was granted and the API repository's
302
+ `docs/coverage.md` before relying on one. A call outside them is refused with `not_named`.
303
+ A sandbox recorded without a contract has `box.contract === null`.
304
+
305
+ `exec` returns text (`stdout`, `stderr`) unless the config says `output: 'bytes'`, which
306
+ returns exact `Uint8Array` streams in `stdout` and `stderr`. The result keeps `exit_code`
307
+ and both truncation flags in either mode; the types follow the config, so a literal
308
+ `output` needs no check on the result.
309
+ `box.files.list(path)` returns immediate entries with `name` and `type`.
310
+
311
+ `client.sandboxes.openTerminal(sandboxId, options)` opens a PTY shell on any
312
+ provider, or attaches with `terminalId`. `rows` and `cols` set the size of a new
313
+ terminal. On attach, use `terminal.resize(rows, cols)` to request an explicit
314
+ resize. It returns a `Terminal` handle:
315
+ `output()` yields exact byte chunks and stops at exit; `events()` retains raw typed
316
+ events. `lastEventId` tracks consumed SSE events, and omitted cursors resume from
317
+ that point. A terminal error raises `TerminalError` with its `event`, `code`,
318
+ `message`, `outcome` and `retry`. `close()` detaches local observers only; it does
319
+ not stop the remote shell. The sandbox image must provide `python3`.
320
+
321
+ ```typescript
322
+ const terminal = await client.sandboxes.openTerminal(sandboxId, { rows: 40, cols: 120 });
323
+ try {
324
+ for await (const chunk of terminal.output()) process.stdout.write(chunk);
325
+ console.log(terminal.exitCode);
326
+ } finally {
327
+ terminal.close();
328
+ }
329
+ ```
330
+
331
+ ## Downloads
332
+
333
+ Generated binary operations also provide `…Stream()` methods. They return
334
+ `{ data, request, response }`, retaining the original Fetch request and response.
335
+ Binary `data` is a `ReadableStream<Uint8Array>`; a declared JSON alternative is
336
+ buffered and validated before returning its JSON value.
337
+
338
+ ```typescript
339
+ import { createWriteStream } from 'node:fs';
340
+ import { Writable } from 'node:stream';
341
+
342
+ const download = await client.api.files.readStream({
343
+ path: { sandbox_id: box.id }, query: { path: '/tmp/hello.txt' },
21
344
  });
22
- console.log(result.data);
345
+ await download.data.pipeTo(Writable.toWeb(createWriteStream('hello.txt')));
346
+ ```
347
+
348
+ Consume or cancel the stream to close the transfer. `pipeTo` also cancels the
349
+ source when its destination fails. A disconnected body raises `APIError` with the
350
+ original response and mutation key; it does not restart the operation. Downloads
351
+ can leave partial local files. Client streaming does not remove Cloud's provider
352
+ buffering or transfer limits.
353
+
354
+ Move files of any practical size with `box.files.upload` and `box.files.download`:
355
+
356
+ ```typescript
357
+ await box.files.upload('./dataset.parquet', '/home/user/data/dataset.parquet');
358
+ await box.files.download('/home/user/out/results.tar.gz', './results.tar.gz');
359
+ const stream = await box.files.download('/home/user/out/results.tar.gz'); // ReadableStream<Uint8Array>
23
360
  ```
24
361
 
25
- Set `BOXROUTER_BASE_URL` to your deployment's API base URL and
26
- `BOXROUTER_API_KEY` to a BoxRouter API key. Discovery reports current visibility
27
- and eligibility; it does not reserve capacity. With `throwOnError: true`, HTTP
28
- failures reject the promise. This preview does not include the full SDK's typed
29
- error models.
362
+ `upload` takes a local path, `Blob`, `Uint8Array` or `ReadableStream` (a stream needs `size`) and
363
+ accepts `concurrency`, `progress(done, total)`, `signal` and `idempotencyKey`. A download to a path
364
+ is written to `<path>.part-<random>` and renamed once the full length arrived; the stream form
365
+ errors if the body ends short. An upload is never sent again once any byte may have gone: the
366
+ upload is aborted and the error raised, and bytes already written may remain. `files.write` and
367
+ `files.read` switch to the same flow above 1 MiB, so they need no change. Volumes use the same
368
+ transfer engine.
30
369
 
31
- To rebuild this preview, sync its own `release-pins.txt` with `gh pins sync` from
32
- this directory, unpack `.artifacts/sdk-codegen.tgz` into `.artifacts`, then run
33
- `node src/build-preview.mjs` from the repository root. Run its installed-package
34
- checks with `node --test src/preview/tests/client.test.mjs`.
370
+ ## Tracing
35
371
 
36
- Licensed under Apache-2.0. Contact: maintainer@boxrouter.ai.
372
+ The SDK uses the OpenTelemetry API; your application configures the tracer provider,
373
+ context manager, W3C trace-context propagator, sampling and export. With no provider,
374
+ instrumentation is inactive. The SDK installs no exporters or background workers.
375
+
376
+ Buffered requests and SSE iteration emit `boxrouter.client` spans named for canonical
377
+ operations. Spans include HTTP status and validated `boxrouter.request.id`; streams
378
+ also record delivered event counts and `boxrouter.stream.end` (`completed`, `error`
379
+ or `cancelled`). SSE spans start on first iteration and end on EOF, failure or close.
380
+ Uncertain remote execution and local stream cancellation remain distinct. Binary
381
+ stream spans remain open until EOF, failure or cancellation and record delivered,
382
+ decoded bytes in `boxrouter.stream.bytes`. Raw `parseAs: 'stream'` reads use the
383
+ same lifecycle instrumentation.
384
+ Standard `TimeoutError` abort reasons record an error outcome, including in SSE
385
+ iteration. Intentional stream closure remains `cancelled`. Buffered requests
386
+ distinguish standard `TimeoutError` and `AbortError` without capturing their messages.
387
+
388
+ Recording buffered request spans may also include three client timing attributes,
389
+ all measured in milliseconds with a monotonic clock: `boxrouter.client.request_preparation.duration_ms`
390
+ covers request construction and setup before the fetch callback starts;
391
+ `boxrouter.client.response_headers.duration_ms` covers the fetch callback from
392
+ dispatch until it returns a `Response` or rejects; and
393
+ `boxrouter.client.response_processing.duration_ms` covers buffered body handling
394
+ after the response is returned until the SDK finishes the operation. Request
395
+ preparation is omitted when its clock readings are unavailable; when a request
396
+ fails before fetch starts, it covers setup until the operation finishes. Response
397
+ headers is omitted if its timing cannot
398
+ be measured; it can be present even when fetch rejects, because it measures the
399
+ time until that rejection. Response processing is omitted when fetch does not
400
+ return a response or its timing cannot be measured. All three are omitted when
401
+ the span is not recording.
402
+
403
+ Applications that need these phases even when a span is not recording can opt in
404
+ to the request phase observer exported by the generated client:
405
+
406
+ ```ts
407
+ import { setRequestPhaseObserver } from '@boxrouter/sdk';
408
+
409
+ setRequestPhaseObserver(({ phase, outcome, durationMs }) => {
410
+ // Record only the bounded phase and outcome dimensions.
411
+ // requestPhaseHistogram comes from the application's metrics setup.
412
+ requestPhaseHistogram.record(durationMs, { phase, outcome });
413
+ });
414
+
415
+ // Disable observations when they are no longer needed.
416
+ setRequestPhaseObserver(undefined);
417
+ ```
418
+
419
+ The observer reports `request_preparation`, `response_headers`, and
420
+ `response_processing` for requests, plus `stream_lifetime` for SSE and binary
421
+ streams. For streams, response processing covers setup before the stream body;
422
+ the stream lifetime is reported separately through completion, failure, or
423
+ cancellation. Every `durationMs` uses the monotonic clock and describes only
424
+ its named phase; a phase is omitted when its interval cannot be measured.
425
+ Outcomes come from a fixed, bounded set: `success`,
426
+ `http_error`, `network_error`, `cancelled`, `parse_error`, `stream_error`,
427
+ `stream_cancelled`, and `unknown`.
428
+ Each observation contains only `phase`, `outcome`, and `durationMs`; it carries
429
+ no request IDs, URLs, bodies, credentials, or exception details. The callback
430
+ runs synchronously on the request path, so keep it lightweight and use only
431
+ bounded metric labels. Callback errors are ignored so they cannot replace the
432
+ request result. The observer is module-wide and applies to requests created
433
+ after it is installed; disable it with `setRequestPhaseObserver(undefined)`.
434
+ The SDK does not export these observations as metrics itself.
435
+
436
+ Only W3C `traceparent` is injected from the configured propagator. Automatic baggage,
437
+ URLs, resource IDs, request/response bodies, credentials, exception messages and stacks
438
+ are excluded. Application-installed automatic instrumentation has its own capture
439
+ policy; review it separately. Follow the
440
+ [OpenTelemetry library guidance](https://opentelemetry.io/docs/concepts/instrumentation/libraries/)
441
+ when configuring your application.
442
+
443
+ JSON integers outside JavaScript's safe range are returned as `bigint`; generated
444
+ numeric fields have type `number | bigint`. Use `.toString()` for display and
445
+ `BigInt(value)` for exact integer arithmetic. Supply large request values as bigint
446
+ (for example `9007199254740993n`); SDK serialization keeps them as JSON integers.
447
+ Already-unsafe integer numbers fail before dispatch. Decimal-text timestamps remain
448
+ strings. Native `JSON.stringify` cannot serialize bigint values.
449
+
450
+ After a request is constructed, transport and stream failures raise `RequestError`.
451
+ It retains `request`, any received `response`, `idempotencyKey`, `requestId` and the
452
+ original error as `cause`. HTTP failures use `APIError`; streaming HTTP failures
453
+ use its `StreamHTTPError` subclass with the same recovery fields. Streaming error
454
+ bodies retain at most 64 KiB, with `bodyTruncated` indicating overflow; incomplete
455
+ diagnostics may not contain recovery fields. Retain
456
+ these identifiers for reconciliation; transport cancellation does not cancel remote
457
+ work, and the SDK never resends a call whose `retry` is `check_outcome`, `after_fix` or `never`.
458
+ For a persistent transport failure against `boxrouter.ai`, `RequestError.reportUrl`
459
+ and its message point to Support, prefilled with a request ID when one was received;
460
+ the message also offers `support@boxrouter.ai` if the page cannot be opened. Explicit
461
+ cancellation and custom API hosts do not get BoxRouter reporting details.
462
+
463
+ ## Client identification
464
+
465
+ Generated HTTP operations send `boxrouter-typescript/<SDK version>` in Node,
466
+ including JSON, file streams and events. Pass
467
+ `userAgentSuffix: 'my-app/1.0'` to append a product token (1–256 printable ASCII
468
+ characters, including one non-space; complete header at most 512).
469
+ `client.withUserAgentSuffix('integration/1.0')` returns an independent view of the
470
+ current transport configuration and interceptors, without changing the owner.
471
+ Browsers control their own User-Agent; BoxRouter's website Worker identifies its
472
+ upstream API calls as `boxrouter-web`. Cloud stores only an allowlisted product
473
+ name and major.minor version, never the raw header or arbitrary suffix.
474
+
475
+ ## Launch agents
476
+
477
+ `client.sandboxes.launch(options)` and `launch(agent, options)` wait until the launch is
478
+ ready and resolve to the sandbox: the same `SandboxHandle` that `create` returns. `destroy()`
479
+ ends it. The handle's `launch` property is the `Launch` result (`undefined` for handles from
480
+ `create` and `get`) with `interactive` resolved from the launch, then the manifest, then
481
+ `true`, so `box.launch.interactive === false` tells an unattended launch. A launch that is
482
+ still pending after its bound rejects with a `WaitTimeoutError` naming the operation id;
483
+ read the operation before launching again. If the launch succeeded but reading the sandbox
484
+ failed, the error message ends with `Sandbox ID: <id>`.
485
+
486
+ ```typescript
487
+ await using box = await client.sandboxes.launch('codex', { repo: 'acme/agent@main' });
488
+ const terminal = await box.openTerminal({ rows: 40, cols: 120 });
489
+ for await (const chunk of terminal.output()) process.stdout.write(chunk);
490
+ ```
491
+
492
+ After a launch, `box.openTerminal` opens a shell that first writes the launch's command
493
+ (an interactive launch only) and defaults the terminal timeout to 3600 s; pass `terminalId`
494
+ to attach to an existing shell instead. For `interactive: false`, Cloud starts the command
495
+ during preparation and `openTerminal` opens a plain shell. `await using` closes remaining
496
+ observers and destroys the sandbox when its scope ends. `manifest` takes a plain object;
497
+ a `source` key marks a source manifest.
498
+
499
+ ## Wait for an operation
500
+
501
+ `client.operations.wait(id)` reads an operation until its outcome is no longer `unknown`
502
+ and returns it (`completed`, `partial` and `not_started` end the wait). It never repeats the
503
+ mutation; after its bound it rejects with a `WaitTimeoutError`. `client.api.operations.get(id)`
504
+ reads once.
505
+
506
+ ```typescript
507
+ const operation = await client.operations.wait(operationId);
508
+ console.log(operation.outcome);
509
+ ```
@@ -0,0 +1,5 @@
1
+ export declare const SUPPORT = "support@boxrouter.ai";
2
+ export declare const PRIVACY = "privacy@boxrouter.ai";
3
+ export declare const SECURITY = "security@boxrouter.ai";
4
+ export declare const ABUSE = "abuse@boxrouter.ai";
5
+ export declare const CONDUCT = "conduct@boxrouter.ai";
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ // Generated from the BoxRouter email registry. Do not edit.
3
+ // Public email addresses: the ones that may appear in published packages.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.CONDUCT = exports.ABUSE = exports.SECURITY = exports.PRIVACY = exports.SUPPORT = void 0;
6
+ exports.SUPPORT = "support@boxrouter.ai";
7
+ exports.PRIVACY = "privacy@boxrouter.ai";
8
+ exports.SECURITY = "security@boxrouter.ai";
9
+ exports.ABUSE = "abuse@boxrouter.ai";
10
+ exports.CONDUCT = "conduct@boxrouter.ai";
@@ -0,0 +1,62 @@
1
+ import type { ErrorCode } from './error-codes.gen';
2
+ /** Where to report an unexpected failure, with the request ID prefilled when there is one. */
3
+ export declare function reportUrl(requestId?: string): string;
4
+ /** A bounded, payload-free description of a response schema mismatch. */
5
+ export type ResponseSchemaDiagnostic = Readonly<{
6
+ keyword: string;
7
+ instancePath: string;
8
+ schemaPath: string;
9
+ }>;
10
+ /**
11
+ * An API failure with an explanation and identifiers for reconciliation. An unexpected failure (a 5xx, an
12
+ * uncertain outcome or a reply this SDK cannot read) says where to report it; a failure the caller can fix, such
13
+ * as a bad key, does not. `unexpected` overrides that rule for a reply that is not BoxRouter's at all.
14
+ */
15
+ export declare class APIError extends Error {
16
+ readonly response: Response;
17
+ readonly request: Request | undefined;
18
+ readonly status: number;
19
+ readonly error: Readonly<Record<string, unknown>>;
20
+ /** The documented codes complete in an editor; a code newer than this SDK is still a string. */
21
+ readonly code?: ErrorCode;
22
+ readonly requestId?: string;
23
+ readonly operationId?: string;
24
+ readonly sandboxId?: string;
25
+ readonly outcome?: string;
26
+ /** What to do next, when the API names a fix. */
27
+ readonly fix?: string;
28
+ /** What to do about sending the call again: `safe`, `after_fix`, `check_outcome` or `never` (a newer API may add values). */
29
+ readonly retry?: string;
30
+ /** How long to wait before a `retry: "safe"` resend; undefined when the API names no wait. */
31
+ readonly retryAfterSeconds?: number;
32
+ /** The documentation page for this code (`.../docs/error-codes#<code>`); undefined when the API names none. */
33
+ readonly docUrl?: string;
34
+ /** Code-specific context for programs; fields this SDK does not know are kept. */
35
+ readonly details: Readonly<Record<string, unknown>>;
36
+ /** Safe schema paths only; never includes response values or validator params. */
37
+ readonly schemaDiagnostics?: readonly ResponseSchemaDiagnostic[];
38
+ readonly idempotencyKey?: string;
39
+ /** Where to report this failure; undefined for a failure the caller can fix. */
40
+ readonly reportUrl?: string;
41
+ constructor(payload: unknown, response: Response, request: Request | undefined, message?: string, idempotencyKey?: string, unexpected?: boolean, schemaDiagnostics?: readonly ResponseSchemaDiagnostic[]);
42
+ }
43
+ /** Say what a failed call means: a read changed nothing, a mutation may have happened. */
44
+ export declare function unconfirmed(request: Request, failure: string): string;
45
+ /** Mark a failure that followed a send, so its message does not claim the request was never sent. */
46
+ export declare function markAfterSend(error: unknown): unknown;
47
+ /** A request failed locally; a mutation's remote outcome may still be unknown. */
48
+ export declare class RequestError extends Error {
49
+ readonly request: Request;
50
+ readonly response?: Response | undefined;
51
+ readonly idempotencyKey?: string;
52
+ readonly requestId?: string;
53
+ /** Where to report a persistent transport failure against BoxRouter. */
54
+ readonly reportUrl?: string;
55
+ constructor(cause: unknown, request: Request, response?: Response | undefined);
56
+ }
57
+ export declare function requestFailure(error: unknown, request?: Request, response?: Response): unknown;
58
+ /** Where no kind of record matched, a newer API may be the cause; say what then fixes it. */
59
+ export declare const UNKNOWN_KIND = "It may hold a kind of record this SDK does not know; if it keeps failing, a newer SDK is needed.";
60
+ /** A response BoxRouter did not send: every BoxRouter response carries a request ID. */
61
+ export declare function foreign(response: Response, request: Request): string | undefined;
62
+ export declare function invalidResponse(response: Response, request: Request, payload?: unknown, kind?: boolean, schemaDiagnostics?: readonly ResponseSchemaDiagnostic[]): APIError;