withruntime 0.50.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (491) hide show
  1. package/dist/generated/apps.d.ts +309 -0
  2. package/dist/generated/apps.js +333 -0
  3. package/dist/generated/audit.d.ts +47 -0
  4. package/dist/generated/audit.js +14 -0
  5. package/dist/generated/browsers.d.ts +309 -0
  6. package/dist/generated/browsers.js +333 -0
  7. package/dist/generated/builds.d.ts +309 -0
  8. package/dist/generated/builds.js +333 -0
  9. package/dist/generated/ci.d.ts +309 -0
  10. package/dist/generated/ci.js +333 -0
  11. package/dist/generated/containers.d.ts +309 -0
  12. package/dist/generated/containers.js +333 -0
  13. package/dist/generated/desktops.d.ts +309 -0
  14. package/dist/generated/desktops.js +333 -0
  15. package/dist/generated/domains.d.ts +80 -0
  16. package/dist/generated/domains.js +58 -0
  17. package/dist/generated/egressIps.d.ts +36 -0
  18. package/dist/generated/egressIps.js +14 -0
  19. package/dist/generated/events.d.ts +37 -0
  20. package/dist/generated/events.js +14 -0
  21. package/dist/generated/feedback.d.ts +44 -0
  22. package/dist/generated/feedback.js +13 -0
  23. package/dist/generated/functions.d.ts +309 -0
  24. package/dist/generated/functions.js +333 -0
  25. package/dist/generated/identities.d.ts +36 -0
  26. package/dist/generated/identities.js +22 -0
  27. package/dist/generated/images.d.ts +200 -0
  28. package/dist/generated/images.js +65 -0
  29. package/dist/generated/index.d.ts +143 -0
  30. package/dist/generated/index.js +184 -0
  31. package/dist/generated/jobRuns.d.ts +68 -0
  32. package/dist/generated/jobRuns.js +22 -0
  33. package/dist/generated/jobs.d.ts +144 -0
  34. package/dist/generated/jobs.js +85 -0
  35. package/dist/generated/keys.d.ts +105 -0
  36. package/dist/generated/keys.js +26 -0
  37. package/dist/generated/me.d.ts +33 -0
  38. package/dist/generated/me.js +13 -0
  39. package/dist/generated/networks.d.ts +32 -0
  40. package/dist/generated/networks.js +14 -0
  41. package/dist/generated/notebooks.d.ts +309 -0
  42. package/dist/generated/notebooks.js +333 -0
  43. package/dist/generated/otel.d.ts +46 -0
  44. package/dist/generated/otel.js +22 -0
  45. package/dist/generated/ports.d.ts +55 -0
  46. package/dist/generated/ports.js +22 -0
  47. package/dist/generated/previews.d.ts +86 -0
  48. package/dist/generated/previews.js +67 -0
  49. package/dist/generated/projects.d.ts +47 -0
  50. package/dist/generated/projects.js +26 -0
  51. package/dist/generated/roles.d.ts +36 -0
  52. package/dist/generated/roles.js +22 -0
  53. package/dist/generated/routes.d.ts +3 -0
  54. package/dist/generated/routes.js +4 -0
  55. package/dist/generated/runtime.d.ts +176 -0
  56. package/dist/generated/runtime.js +416 -0
  57. package/dist/generated/sandboxes.d.ts +952 -0
  58. package/dist/generated/sandboxes.js +342 -0
  59. package/dist/generated/secrets.d.ts +116 -0
  60. package/dist/generated/secrets.js +54 -0
  61. package/dist/generated/sessions.d.ts +47 -0
  62. package/dist/generated/sessions.js +17 -0
  63. package/dist/generated/signing.d.ts +68 -0
  64. package/dist/generated/signing.js +187 -0
  65. package/dist/generated/sites.d.ts +309 -0
  66. package/dist/generated/sites.js +333 -0
  67. package/dist/generated/snapshots.d.ts +27 -0
  68. package/dist/generated/snapshots.js +22 -0
  69. package/dist/generated/tunnels.d.ts +68 -0
  70. package/dist/generated/tunnels.js +14 -0
  71. package/dist/generated/usage.d.ts +155 -0
  72. package/dist/generated/usage.js +17 -0
  73. package/dist/generated/volumes.d.ts +36 -0
  74. package/dist/generated/volumes.js +26 -0
  75. package/dist/generated/webhooks.d.ts +44 -0
  76. package/dist/generated/webhooks.js +22 -0
  77. package/dist/generated/workspaces.d.ts +309 -0
  78. package/dist/generated/workspaces.js +333 -0
  79. package/dist/v2/cli.d.ts +7 -0
  80. package/dist/v2/cli.js +283 -0
  81. package/dist/v2/index.d.ts +1 -0
  82. package/dist/v2/index.js +4 -0
  83. package/dist/v2/login.d.ts +35 -0
  84. package/dist/v2/login.js +225 -0
  85. package/dist/v2/mcp.d.ts +1 -0
  86. package/dist/v2/mcp.js +49 -0
  87. package/dist/v2/openapi.json +75750 -0
  88. package/dist/v2/shims/base.d.ts +33 -0
  89. package/dist/v2/shims/base.js +54 -0
  90. package/dist/v2/shims/blaxel.d.ts +60 -0
  91. package/dist/v2/shims/blaxel.js +71 -0
  92. package/dist/v2/shims/cloudflare.d.ts +52 -0
  93. package/dist/v2/shims/cloudflare.js +55 -0
  94. package/dist/v2/shims/daytona.d.ts +58 -0
  95. package/dist/v2/shims/daytona.js +74 -0
  96. package/dist/v2/shims/e2b.d.ts +142 -0
  97. package/dist/v2/shims/e2b.js +238 -0
  98. package/dist/v2/shims/fly.d.ts +6 -0
  99. package/dist/v2/shims/fly.js +91 -0
  100. package/dist/v2/shims/modal.d.ts +54 -0
  101. package/dist/v2/shims/modal.js +79 -0
  102. package/dist/v2/shims/morph.d.ts +60 -0
  103. package/dist/v2/shims/morph.js +87 -0
  104. package/dist/v2/shims/vercel.d.ts +53 -0
  105. package/dist/v2/shims/vercel.js +90 -0
  106. package/dist/v2/table.d.ts +53 -0
  107. package/dist/v2/table.js +122 -0
  108. package/package.json +20 -310
  109. package/BLAXEL.md +0 -290
  110. package/COMPATIBILITY.md +0 -447
  111. package/DAYTONA.md +0 -237
  112. package/E2B.md +0 -314
  113. package/README.md +0 -331
  114. package/README.src.md +0 -333
  115. package/VERCEL.md +0 -230
  116. package/agent-platforms-inventory.json +0 -387
  117. package/compatibility-lock.json +0 -305
  118. package/dist/agents/browser.d.ts +0 -12
  119. package/dist/agents/browser.js +0 -12
  120. package/dist/agents/index.d.ts +0 -11
  121. package/dist/agents/index.js +0 -11
  122. package/dist/agents-cli.d.ts +0 -16
  123. package/dist/agents-cli.js +0 -1237
  124. package/dist/agents-deploy.d.ts +0 -196
  125. package/dist/agents-deploy.js +0 -872
  126. package/dist/agents-file.d.ts +0 -19
  127. package/dist/agents-file.js +0 -135
  128. package/dist/ai/index.d.ts +0 -49
  129. package/dist/ai/index.js +0 -31
  130. package/dist/ai-harness/index.d.ts +0 -194
  131. package/dist/ai-harness/index.js +0 -522
  132. package/dist/api-defaults.d.ts +0 -17
  133. package/dist/api-defaults.js +0 -22
  134. package/dist/apps/index.d.ts +0 -10
  135. package/dist/apps/index.js +0 -11
  136. package/dist/apps-cli.d.ts +0 -16
  137. package/dist/apps-cli.js +0 -1021
  138. package/dist/billing-cli.d.ts +0 -23
  139. package/dist/billing-cli.js +0 -264
  140. package/dist/blaxel/client.d.ts +0 -59
  141. package/dist/blaxel/client.js +0 -86
  142. package/dist/blaxel/context.d.ts +0 -59
  143. package/dist/blaxel/context.js +0 -162
  144. package/dist/blaxel/errors.d.ts +0 -130
  145. package/dist/blaxel/errors.js +0 -315
  146. package/dist/blaxel/filesystem.d.ts +0 -147
  147. package/dist/blaxel/filesystem.js +0 -585
  148. package/dist/blaxel/index.d.ts +0 -287
  149. package/dist/blaxel/index.js +0 -351
  150. package/dist/blaxel/interpreter.d.ts +0 -71
  151. package/dist/blaxel/interpreter.js +0 -256
  152. package/dist/blaxel/lookup.d.ts +0 -39
  153. package/dist/blaxel/lookup.js +0 -84
  154. package/dist/blaxel/pagination.d.ts +0 -39
  155. package/dist/blaxel/pagination.js +0 -88
  156. package/dist/blaxel/preview.d.ts +0 -136
  157. package/dist/blaxel/preview.js +0 -304
  158. package/dist/blaxel/process.d.ts +0 -126
  159. package/dist/blaxel/process.js +0 -581
  160. package/dist/blaxel/sandbox.d.ts +0 -198
  161. package/dist/blaxel/sandbox.js +0 -856
  162. package/dist/blaxel/session.d.ts +0 -31
  163. package/dist/blaxel/session.js +0 -136
  164. package/dist/blaxel/snapshot.d.ts +0 -123
  165. package/dist/blaxel/snapshot.js +0 -199
  166. package/dist/blaxel/types.d.ts +0 -145
  167. package/dist/blaxel/types.js +0 -60
  168. package/dist/blaxel/unsupported.d.ts +0 -20
  169. package/dist/blaxel/unsupported.js +0 -32
  170. package/dist/browser-stub.d.ts +0 -1
  171. package/dist/browser-stub.js +0 -1
  172. package/dist/browsers/index.d.ts +0 -9
  173. package/dist/browsers/index.js +0 -10
  174. package/dist/browsers-cli.d.ts +0 -13
  175. package/dist/browsers-cli.js +0 -279
  176. package/dist/builds/index.d.ts +0 -10
  177. package/dist/builds/index.js +0 -11
  178. package/dist/ci/index.d.ts +0 -13
  179. package/dist/ci/index.js +0 -14
  180. package/dist/ci-cli.d.ts +0 -20
  181. package/dist/ci-cli.js +0 -537
  182. package/dist/ci-import.d.ts +0 -23
  183. package/dist/ci-import.js +0 -565
  184. package/dist/claude-agent-sdk/index.d.ts +0 -7
  185. package/dist/claude-agent-sdk/index.js +0 -65
  186. package/dist/cli/logs.d.ts +0 -21
  187. package/dist/cli/logs.js +0 -188
  188. package/dist/cli-extras.d.ts +0 -39
  189. package/dist/cli-extras.js +0 -267
  190. package/dist/cli-name.d.ts +0 -6
  191. package/dist/cli-name.js +0 -8
  192. package/dist/cli-update.d.ts +0 -11
  193. package/dist/cli-update.js +0 -46
  194. package/dist/cli-words.d.ts +0 -36
  195. package/dist/cli-words.js +0 -167
  196. package/dist/cli.d.ts +0 -92
  197. package/dist/cli.js +0 -5463
  198. package/dist/client.d.ts +0 -189
  199. package/dist/client.js +0 -205
  200. package/dist/cloudflare/errors.d.ts +0 -166
  201. package/dist/cloudflare/errors.js +0 -183
  202. package/dist/cloudflare/identity.d.ts +0 -7
  203. package/dist/cloudflare/identity.js +0 -13
  204. package/dist/cloudflare/index.d.ts +0 -545
  205. package/dist/cloudflare/index.js +0 -1106
  206. package/dist/cloudflare/interpreter.d.ts +0 -119
  207. package/dist/cloudflare/interpreter.js +0 -232
  208. package/dist/cloudflare/mime.d.ts +0 -1
  209. package/dist/cloudflare/mime.js +0 -66
  210. package/dist/cloudflare/streams.d.ts +0 -46
  211. package/dist/cloudflare/streams.js +0 -175
  212. package/dist/cloudflare/types.d.ts +0 -338
  213. package/dist/cloudflare/types.js +0 -80
  214. package/dist/cloudflare/watch.d.ts +0 -9
  215. package/dist/cloudflare/watch.js +0 -24
  216. package/dist/cloudflare/worker.d.ts +0 -706
  217. package/dist/cloudflare/worker.js +0 -633
  218. package/dist/codesandbox/guest-service.d.ts +0 -31
  219. package/dist/codesandbox/guest-service.js +0 -490
  220. package/dist/codesandbox/index.d.ts +0 -574
  221. package/dist/codesandbox/index.js +0 -1747
  222. package/dist/compat/core.d.ts +0 -58
  223. package/dist/compat/core.js +0 -267
  224. package/dist/compat/files.d.ts +0 -27
  225. package/dist/compat/files.js +0 -157
  226. package/dist/compat/lease.d.ts +0 -37
  227. package/dist/compat/lease.js +0 -93
  228. package/dist/compat/shell.d.ts +0 -4
  229. package/dist/compat/shell.js +0 -165
  230. package/dist/containers/index.d.ts +0 -10
  231. package/dist/containers/index.js +0 -11
  232. package/dist/credentials.d.ts +0 -71
  233. package/dist/credentials.js +0 -340
  234. package/dist/daytona/client.d.ts +0 -48
  235. package/dist/daytona/client.js +0 -45
  236. package/dist/daytona/computer-use.d.ts +0 -171
  237. package/dist/daytona/computer-use.js +0 -382
  238. package/dist/daytona/context.d.ts +0 -41
  239. package/dist/daytona/context.js +0 -50
  240. package/dist/daytona/daytona.d.ts +0 -213
  241. package/dist/daytona/daytona.js +0 -578
  242. package/dist/daytona/errors.d.ts +0 -117
  243. package/dist/daytona/errors.js +0 -201
  244. package/dist/daytona/filesystem.d.ts +0 -99
  245. package/dist/daytona/filesystem.js +0 -300
  246. package/dist/daytona/git.d.ts +0 -33
  247. package/dist/daytona/git.js +0 -128
  248. package/dist/daytona/image.d.ts +0 -49
  249. package/dist/daytona/image.js +0 -146
  250. package/dist/daytona/index.d.ts +0 -87
  251. package/dist/daytona/index.js +0 -102
  252. package/dist/daytona/process.d.ts +0 -143
  253. package/dist/daytona/process.js +0 -565
  254. package/dist/daytona/sandbox.d.ts +0 -222
  255. package/dist/daytona/sandbox.js +0 -505
  256. package/dist/desktops/index.d.ts +0 -9
  257. package/dist/desktops/index.js +0 -10
  258. package/dist/domains/index.d.ts +0 -9
  259. package/dist/domains/index.js +0 -10
  260. package/dist/e2b/client.d.ts +0 -76
  261. package/dist/e2b/client.js +0 -124
  262. package/dist/e2b/code-interpreter.d.ts +0 -134
  263. package/dist/e2b/code-interpreter.js +0 -239
  264. package/dist/e2b/commands.d.ts +0 -135
  265. package/dist/e2b/commands.js +0 -452
  266. package/dist/e2b/errors.d.ts +0 -125
  267. package/dist/e2b/errors.js +0 -247
  268. package/dist/e2b/filesystem.d.ts +0 -111
  269. package/dist/e2b/filesystem.js +0 -374
  270. package/dist/e2b/index.d.ts +0 -35
  271. package/dist/e2b/index.js +0 -69
  272. package/dist/e2b/pty.d.ts +0 -24
  273. package/dist/e2b/pty.js +0 -83
  274. package/dist/e2b/sandbox.d.ts +0 -248
  275. package/dist/e2b/sandbox.js +0 -781
  276. package/dist/e2b/unsupported.d.ts +0 -38
  277. package/dist/e2b/unsupported.js +0 -48
  278. package/dist/e2b/users.d.ts +0 -39
  279. package/dist/e2b/users.js +0 -207
  280. package/dist/errors.d.ts +0 -100
  281. package/dist/errors.js +0 -198
  282. package/dist/file-source.d.ts +0 -16
  283. package/dist/file-source.js +0 -162
  284. package/dist/fly/index.d.ts +0 -102
  285. package/dist/fly/index.js +0 -930
  286. package/dist/freestyle/index.d.ts +0 -629
  287. package/dist/freestyle/index.js +0 -1187
  288. package/dist/functions/index.d.ts +0 -10
  289. package/dist/functions/index.js +0 -11
  290. package/dist/identity.d.ts +0 -30
  291. package/dist/identity.js +0 -141
  292. package/dist/image-context.d.ts +0 -39
  293. package/dist/image-context.js +0 -176
  294. package/dist/images/index.d.ts +0 -9
  295. package/dist/images/index.js +0 -10
  296. package/dist/index.d.ts +0 -87
  297. package/dist/index.js +0 -51
  298. package/dist/inngest/index.d.ts +0 -96
  299. package/dist/inngest/index.js +0 -183
  300. package/dist/ips/index.d.ts +0 -9
  301. package/dist/ips/index.js +0 -10
  302. package/dist/jobs/index.d.ts +0 -9
  303. package/dist/jobs/index.js +0 -10
  304. package/dist/jobs-code/cron.d.ts +0 -12
  305. package/dist/jobs-code/cron.js +0 -93
  306. package/dist/jobs-code/registry.d.ts +0 -31
  307. package/dist/jobs-code/registry.js +0 -30
  308. package/dist/jobs-code/runner.d.ts +0 -1
  309. package/dist/jobs-code/runner.js +0 -74
  310. package/dist/jobs-deploy.d.ts +0 -22
  311. package/dist/jobs-deploy.js +0 -247
  312. package/dist/jobs-import.d.ts +0 -15
  313. package/dist/jobs-import.js +0 -231
  314. package/dist/keys.d.ts +0 -55
  315. package/dist/keys.js +0 -211
  316. package/dist/login.d.ts +0 -88
  317. package/dist/login.js +0 -369
  318. package/dist/machine.d.ts +0 -222
  319. package/dist/machine.js +0 -578
  320. package/dist/mcp.d.ts +0 -16
  321. package/dist/mcp.js +0 -377
  322. package/dist/modal/index.d.ts +0 -532
  323. package/dist/modal/index.js +0 -1284
  324. package/dist/morph/index.d.ts +0 -255
  325. package/dist/morph/index.js +0 -641
  326. package/dist/network-cli.d.ts +0 -17
  327. package/dist/network-cli.js +0 -523
  328. package/dist/networks/index.d.ts +0 -11
  329. package/dist/networks/index.js +0 -10
  330. package/dist/openai-agents/index.d.ts +0 -132
  331. package/dist/openai-agents/index.js +0 -738
  332. package/dist/page.d.ts +0 -13
  333. package/dist/page.js +0 -39
  334. package/dist/ports/index.d.ts +0 -9
  335. package/dist/ports/index.js +0 -10
  336. package/dist/product-names.d.ts +0 -52
  337. package/dist/product-names.js +0 -174
  338. package/dist/product-renames.d.ts +0 -103
  339. package/dist/product-renames.js +0 -189
  340. package/dist/products/agents.d.ts +0 -935
  341. package/dist/products/agents.js +0 -581
  342. package/dist/products/api-keys.d.ts +0 -113
  343. package/dist/products/api-keys.js +0 -32
  344. package/dist/products/apps.d.ts +0 -409
  345. package/dist/products/apps.js +0 -231
  346. package/dist/products/audit.d.ts +0 -51
  347. package/dist/products/audit.js +0 -10
  348. package/dist/products/balancers.d.ts +0 -87
  349. package/dist/products/balancers.js +0 -8
  350. package/dist/products/billing.d.ts +0 -76
  351. package/dist/products/billing.js +0 -26
  352. package/dist/products/browser.d.ts +0 -73
  353. package/dist/products/browser.js +0 -29
  354. package/dist/products/browsers.d.ts +0 -184
  355. package/dist/products/browsers.js +0 -180
  356. package/dist/products/builds.d.ts +0 -175
  357. package/dist/products/builds.js +0 -234
  358. package/dist/products/ci.d.ts +0 -406
  359. package/dist/products/ci.js +0 -133
  360. package/dist/products/containers.d.ts +0 -71
  361. package/dist/products/containers.js +0 -6
  362. package/dist/products/desktop.d.ts +0 -141
  363. package/dist/products/desktop.js +0 -83
  364. package/dist/products/desktops.d.ts +0 -71
  365. package/dist/products/desktops.js +0 -27
  366. package/dist/products/functions.d.ts +0 -2
  367. package/dist/products/functions.js +0 -5
  368. package/dist/products/images.d.ts +0 -229
  369. package/dist/products/images.js +0 -235
  370. package/dist/products/index.d.ts +0 -84
  371. package/dist/products/index.js +0 -105
  372. package/dist/products/interpreter.d.ts +0 -97
  373. package/dist/products/interpreter.js +0 -106
  374. package/dist/products/jobs.d.ts +0 -408
  375. package/dist/products/jobs.js +0 -256
  376. package/dist/products/limits.d.ts +0 -61
  377. package/dist/products/limits.js +0 -10
  378. package/dist/products/logs.d.ts +0 -245
  379. package/dist/products/logs.js +0 -274
  380. package/dist/products/mcp.d.ts +0 -88
  381. package/dist/products/mcp.js +0 -58
  382. package/dist/products/mounts.d.ts +0 -49
  383. package/dist/products/mounts.js +0 -21
  384. package/dist/products/network-products.d.ts +0 -268
  385. package/dist/products/network-products.js +0 -127
  386. package/dist/products/network.d.ts +0 -62
  387. package/dist/products/network.js +0 -19
  388. package/dist/products/observability.d.ts +0 -264
  389. package/dist/products/observability.js +0 -123
  390. package/dist/products/plans.d.ts +0 -133
  391. package/dist/products/plans.js +0 -24
  392. package/dist/products/previews.d.ts +0 -70
  393. package/dist/products/previews.js +0 -39
  394. package/dist/products/private-network.d.ts +0 -22
  395. package/dist/products/private-network.js +0 -10
  396. package/dist/products/queues.d.ts +0 -149
  397. package/dist/products/queues.js +0 -213
  398. package/dist/products/referrals.d.ts +0 -50
  399. package/dist/products/referrals.js +0 -8
  400. package/dist/products/reservations.d.ts +0 -108
  401. package/dist/products/reservations.js +0 -41
  402. package/dist/products/resources.d.ts +0 -55
  403. package/dist/products/resources.js +0 -122
  404. package/dist/products/secrets.d.ts +0 -316
  405. package/dist/products/secrets.js +0 -333
  406. package/dist/products/signed-requests.d.ts +0 -21
  407. package/dist/products/signed-requests.js +0 -11
  408. package/dist/products/sso.d.ts +0 -44
  409. package/dist/products/sso.js +0 -8
  410. package/dist/products/streams.d.ts +0 -73
  411. package/dist/products/streams.js +0 -17
  412. package/dist/products/switching.d.ts +0 -123
  413. package/dist/products/switching.js +0 -26
  414. package/dist/products/tailscale.d.ts +0 -57
  415. package/dist/products/tailscale.js +0 -17
  416. package/dist/products/uptime.d.ts +0 -97
  417. package/dist/products/uptime.js +0 -42
  418. package/dist/products/volumes.d.ts +0 -190
  419. package/dist/products/volumes.js +0 -114
  420. package/dist/products/watch.d.ts +0 -112
  421. package/dist/products/watch.js +0 -249
  422. package/dist/proxy.d.ts +0 -30
  423. package/dist/proxy.js +0 -200
  424. package/dist/record-cli.d.ts +0 -23
  425. package/dist/record-cli.js +0 -308
  426. package/dist/renamed-products.d.ts +0 -38
  427. package/dist/renamed-products.js +0 -34
  428. package/dist/resumable.d.ts +0 -32
  429. package/dist/resumable.js +0 -201
  430. package/dist/runloop/index.d.ts +0 -333
  431. package/dist/runloop/index.js +0 -560
  432. package/dist/runloop/pagination.d.ts +0 -46
  433. package/dist/runloop/pagination.js +0 -82
  434. package/dist/runloop/sdk.d.ts +0 -131
  435. package/dist/runloop/sdk.js +0 -167
  436. package/dist/runloop/snapshots.d.ts +0 -52
  437. package/dist/runloop/snapshots.js +0 -244
  438. package/dist/sandbox.d.ts +0 -371
  439. package/dist/sandbox.js +0 -1500
  440. package/dist/sandboxes/index.d.ts +0 -11
  441. package/dist/sandboxes/index.js +0 -12
  442. package/dist/sealing.d.ts +0 -6
  443. package/dist/sealing.js +0 -14
  444. package/dist/snapshots/index.d.ts +0 -9
  445. package/dist/snapshots/index.js +0 -11
  446. package/dist/snapshots.d.ts +0 -82
  447. package/dist/snapshots.js +0 -65
  448. package/dist/sprites/index.d.ts +0 -563
  449. package/dist/sprites/index.js +0 -1370
  450. package/dist/ssh.d.ts +0 -56
  451. package/dist/ssh.js +0 -416
  452. package/dist/switched-off.d.ts +0 -5
  453. package/dist/switched-off.js +0 -8
  454. package/dist/tar.d.ts +0 -15
  455. package/dist/tar.js +0 -526
  456. package/dist/terminal.d.ts +0 -24
  457. package/dist/terminal.js +0 -32
  458. package/dist/tools/index.d.ts +0 -62
  459. package/dist/tools/index.js +0 -181
  460. package/dist/transport.d.ts +0 -165
  461. package/dist/transport.js +0 -883
  462. package/dist/trigger/index.d.ts +0 -202
  463. package/dist/trigger/index.js +0 -244
  464. package/dist/tunnel.d.ts +0 -70
  465. package/dist/tunnel.js +0 -316
  466. package/dist/types.d.ts +0 -585
  467. package/dist/types.js +0 -1
  468. package/dist/vercel/client.d.ts +0 -40
  469. package/dist/vercel/client.js +0 -39
  470. package/dist/vercel/command.d.ts +0 -117
  471. package/dist/vercel/command.js +0 -391
  472. package/dist/vercel/errors.d.ts +0 -53
  473. package/dist/vercel/errors.js +0 -131
  474. package/dist/vercel/filesystem.d.ts +0 -153
  475. package/dist/vercel/filesystem.js +0 -297
  476. package/dist/vercel/index.d.ts +0 -24
  477. package/dist/vercel/index.js +0 -36
  478. package/dist/vercel/sandbox-user.d.ts +0 -70
  479. package/dist/vercel/sandbox-user.js +0 -207
  480. package/dist/vercel/sandbox.d.ts +0 -372
  481. package/dist/vercel/sandbox.js +0 -1037
  482. package/dist/vercel/snapshot.d.ts +0 -94
  483. package/dist/vercel/snapshot.js +0 -137
  484. package/dist/volumes/index.d.ts +0 -9
  485. package/dist/volumes/index.js +0 -10
  486. package/dist/wait.d.ts +0 -12
  487. package/dist/wait.js +0 -47
  488. package/dist/wallet.d.ts +0 -45
  489. package/dist/wallet.js +0 -56
  490. package/dist/wireguard.d.ts +0 -7
  491. package/dist/wireguard.js +0 -13
@@ -1,1237 +0,0 @@
1
- import { existsSync, readFileSync, writeFileSync } from "node:fs";
2
- import { dirname, join, resolve } from "node:path";
3
- import { me, named } from "./cli-name.js";
4
- import { AGENT_TEMPLATES, agentTemplate, AGENT_USES, agents, } from "./products/agents.js";
5
- import { secrets } from "./products/secrets.js";
6
- export const AGENT_HELP = `runtime agents <command>
7
-
8
- An agent runs a harness (Claude Code, Codex, Gemini CLI, or your own code on
9
- an agents SDK) in a sandbox of its own for each session, on your model key.
10
- In a private beta: outside it, each command says how to ask to join.
11
-
12
- templates The harnesses and uses to start from
13
- init [name] [--template <harness>] [--use support|team] [--file runtime.yml]
14
- Write a starter agents: section into runtime.yml
15
- deploy [--file runtime.yml] [--dry-run] [--prune [--prune-memory]]
16
- Make your agents match runtime.yml: create, update
17
- (a new version only when it changed) and set
18
- triggers; one line per change. --prune deletes the
19
- agents a deploy made that the file no longer names,
20
- with their triggers; one holding memory files only
21
- with --prune-memory too, which deletes them for good
22
- create <name> (--template <harness> | --command "<cmd>") [--use support|team]
23
- [--instructions <text> | --instructions-file <path>] [--secret NAME]... [--pool NAME]...
24
- [--env KEY=VALUE]... [--image <image> | --snapshot <id>] [--vcpu n] [--memory n]
25
- [--max-concurrent n] [--idle-pause n] [--max-children n] [--advisor <model>]
26
- [--advisor-secret NAME] [--model <model>] [--session-overrides '<json>']
27
- [--permissions '<json>'] [--label key=value]...
28
- Make an agent; prints its id. --secret names an egress
29
- secret it may use: its model key, of any provider.
30
- --pool names a Claude account's secret (each one
31
- given replaces the template's): each session takes
32
- the one with the most usage left. --advisor names a
33
- model its sessions may ask for advice (advise), its
34
- key the egress secret --advisor-secret names (that
35
- provider's usual one by default, among --secret).
36
- --session-overrides sets what a session's start may
37
- override:
38
- '{"models":["claude-opus-5-5"],"instructions":"replace",
39
- "maxVcpu":8,"maxMemoryMiB":16384,"maxSessionDollars":20}'
40
- ls Your agents
41
- get <agent> One agent, in full (an id or its name)
42
- update <agent> [the options of create] A new version: what you give changes, the rest stays
43
- rm <agent> Delete it, its triggers, and stop its sessions
44
- start <agent> <words...> [--key <key>] [--follow] [--model <model>]
45
- [--instructions <text> | --instructions-file <path>] [--replace-instructions]
46
- [--mcp <server>]... [--no-mcp] [--disallow <tool>]... [--vcpu n] [--memory n]
47
- [--max-dollars n]
48
- A session with these words, or the open one with the
49
- key (such as customer:42); --follow prints its log
50
- until it ends. The other options override the
51
- agent's definition for this session alone, within
52
- its session overrides: its model, instructions added
53
- (or in place of the agent's), the MCP servers it
54
- keeps, tools it may not use, its size and budget
55
- send <session> <words...> Words into a session
56
- events <session> [--after <seq>] [--follow] A session's log; --follow until it ends
57
- trace <session> [--otlp] [--export [--endpoint <url>] [--header key=value]...]
58
- Every model turn and tool call: timing, tokens and
59
- cost, totals by model and tool. --otlp prints
60
- OpenTelemetry traces (OTLP/JSON); --export sends them
61
- to a collector (--endpoint, or
62
- OTEL_EXPORTER_OTLP_TRACES_ENDPOINT /
63
- OTEL_EXPORTER_OTLP_ENDPOINT and _HEADERS)
64
- sessions [--agent <agent>] [--state <state>]...
65
- Sessions, newest first
66
- sessions delete <session> Delete an ended session and its log; its history is
67
- storage, kept until you delete it
68
- stop <session> Stop a session
69
- switch anthropic Run Claude Managed Agents code on Runtime: the
70
- base URL to give Anthropic's SDK, and whether
71
- the model key (ANTHROPIC_API_KEY) is set
72
- asks [--state <state>]... [--agent <agent>] [--label key=value]...
73
- The inbox: what your agents' sessions need answered,
74
- one row per step however many sessions ask it
75
- asks get <ask> One ask: its options, pick and the sessions asking
76
- answer <ask> [<option>] [--text <words>] Answer it with an option's label, words, or both:
77
- every session asking reads it next and wakes
78
- workflow run <file.json | -> [--follow] Run a workflow: many sessions in phases, fanned out
79
- and pipelined, with maxSessions, maxConcurrent and
80
- maxDollars; prints its id, or --follow prints each
81
- phase's progress until it ends, then its result
82
- workflow get <workflow> Its state, each phase's progress, cost and result
83
- workflow watch <workflow> Its progress as it changes, until it ends
84
- workflow steps <workflow> [--state <state>]...
85
- Each step: its phase, item, session and state
86
- workflow stop <workflow> Nothing more starts; its open sessions stop
87
- workflows [--state running|done|failed|stopped]...
88
- Workflows, newest first
89
- approve <ask> Let a tool call the agent's permissions held run
90
- deny <ask> [--message <words>] Keep a held tool call from running; the message is
91
- told to the agent
92
- slack install A link that adds Runtime's Slack app to a workspace
93
- slack ls | rm <team> The workspaces added; remove one
94
- triggers <agent> Its triggers
95
- triggers add <agent> --kind <slack|github|schedule|webhook> --config '<json>' [--rules '<json>']
96
- triggers rules <triggerId> '<json>' Set its rules in place: priority, maxStartsPerHour,
97
- onEnded (start|note|ask), notify (email|webhook)
98
- and a webhook's key ("{cause}"); its secret stays
99
- triggers call <triggerId> <words...> [--key <key>] [--label key=value]... [--secret <secret>]
100
- Call a webhook as its sender would, by its secret
101
- (or RUNTIME_TRIGGER_SECRET): starts, joins, notes or
102
- holds
103
- triggers held <triggerId> [--state held|started|dismissed]...
104
- Calls it held for you; none is dropped
105
- triggers held start <triggerId> <callId> Start one, with every call held for its key since
106
- triggers held dismiss <triggerId> <callId> Dismiss one; nothing runs
107
- triggers pause <triggerId> --why <words> Hold it: a webhook's calls are kept for you, saying why
108
- triggers resume <triggerId>
109
- triggers rm <triggerId>
110
- memory ls <agent> [--scope <key>] [--prefix <path>]
111
- Its memory files, with their scope (shared or a key)
112
- memory search <agent> <words...> [--scope <key>] [--limit n]
113
- Files whose words match, best first
114
- memory cat <agent> <path> [--scope <key>] A file's text
115
- memory put <agent> <path> [<file> | - | --content <text>] [--scope <key>]
116
- Seed or replace a file (from a file, or - for stdin)
117
- memory rm <agent> <path> [--scope <key>] Delete a file
118
- Without --scope: the shared memory, which every
119
- session reads and only a shared agent's write
120
-
121
- A subscription is for your own team's agents; an agent that serves your
122
- customers uses an API key.
123
-
124
- Examples
125
- printf %s "$ANTHROPIC_API_KEY" | runtime secrets set ANTHROPIC_API_KEY --host api.anthropic.com
126
- runtime agents create helper --template claude-code --use support --instructions "Answer briefly."
127
- runtime agents start helper "How do I reset my password?" --key customer:42 --follow
128
- runtime agents start helper "Summarize this ticket" --model claude-haiku-5-5 --disallow Bash
129
- runtime agents memory put helper faq/refunds.md refunds.md
130
- runtime agents asks && runtime agents answer <ask> "Raise to 20 TB"
131
- runtime agents workflow run review.json --follow
132
- runtime agents update helper --permissions '{"default":"auto","tools":{"shell":"always_ask"}}'
133
- runtime agents approve <ask>
134
- runtime agents trace <session> --export --endpoint https://otel.example.com
135
- runtime agents init --template claude-code && runtime agents deploy --dry-run
136
- runtime agents create ci-review --template review --pool CLAUDE_1 --pool CLAUDE_2
137
- runtime agents switch anthropic
138
- `;
139
- const when = (iso) => iso ?? "-";
140
- /** The guide to running Claude Managed Agents code on Runtime. */
141
- const SWITCH_DOCS = "https://withruntime.com/docs/switch-from-claude-managed-agents";
142
- /** A trigger's rules as the CLI takes them: one JSON object. */
143
- function rulesOf(text, kit) {
144
- let rules;
145
- try {
146
- rules = JSON.parse(text);
147
- }
148
- catch {
149
- rules = undefined;
150
- }
151
- if (!rules || typeof rules !== "object" || Array.isArray(rules))
152
- throw kit.usage(`Rules are a JSON object, such as '{"key":"{cause}","maxStartsPerHour":60,"onEnded":"ask"}'.`);
153
- return rules;
154
- }
155
- const OPTIONS = [
156
- "template",
157
- "use",
158
- "command",
159
- "instructions",
160
- "instructions-file",
161
- "secret",
162
- "pool",
163
- "env",
164
- "image",
165
- "snapshot",
166
- "vcpu",
167
- "memory",
168
- "max-concurrent",
169
- "idle-pause",
170
- "model",
171
- "session-overrides",
172
- "max-children",
173
- "advisor",
174
- "advisor-secret",
175
- "permissions",
176
- "label",
177
- ];
178
- const ASK_STATES = ["open", "answered", "expired", "withdrawn", "closed"];
179
- const askLine = (a) => {
180
- const options = a.options.map((o) => (o.label === a.pick ? `${o.label} (pick)` : o.label));
181
- return [
182
- `${a.id} ${a.state}${a.step ? ` step ${a.step}` : ""}, ${a.sessions.length} session${a.sessions.length === 1 ? "" : "s"} asking`,
183
- ` ${a.question}`,
184
- ...(a.why ? [` why: ${a.why}`] : []),
185
- ...(a.toolCall ? [` tool call: ${a.toolCall.tool} ${JSON.stringify(a.toolCall.input)}`] : []),
186
- ...(options.length ? [` options: ${options.join(" | ")}`] : []),
187
- ...(a.expiresAt ? [` expires ${a.expiresAt}`] : []),
188
- ...(a.answer
189
- ? [` answered: ${[a.answer.option, a.answer.text].filter(Boolean).join(": ")}`]
190
- : []),
191
- ].join("\n");
192
- };
193
- const STATES = [
194
- "queued",
195
- "running",
196
- "waiting",
197
- "done",
198
- "failed",
199
- "stopped",
200
- ];
201
- /** The definition the options give, on top of `base` (an agent's own, for
202
- * an update): a template's command and key, a use's sizes, then each option. */
203
- function definitionOf(args, kit, env, base) {
204
- const { flag, integer, usage } = kit;
205
- const template = flag(args, "template");
206
- const use = flag(args, "use");
207
- if (template !== undefined && !(template in AGENT_TEMPLATES))
208
- throw usage(`--template takes ${Object.keys(AGENT_TEMPLATES).join(", ")}.`);
209
- if (use !== undefined && use !== "support" && use !== "team")
210
- throw usage("--use takes support or team.");
211
- const instructionsFile = flag(args, "instructions-file");
212
- const instructions = instructionsFile !== undefined
213
- ? readFileSync(instructionsFile, "utf8")
214
- : flag(args, "instructions");
215
- const image = flag(args, "image");
216
- const snapshot = flag(args, "snapshot");
217
- if (image !== undefined && snapshot !== undefined)
218
- throw usage("Give --image or --snapshot, not both.");
219
- const secrets = args.flags.get("secret");
220
- const definition = {
221
- ...(base ?? {}),
222
- ...(template ? agentTemplate(template).definition : {}),
223
- ...(use ? AGENT_USES[use].definition : {}),
224
- };
225
- const set = (field, value) => {
226
- if (value !== undefined)
227
- definition[field] = value;
228
- };
229
- set("command", flag(args, "command"));
230
- set("instructions", instructions);
231
- if (secrets)
232
- set("secrets", [...new Set([...(definition.secrets ?? []), ...secrets])]);
233
- const pool = args.flags.get("pool");
234
- if (pool)
235
- set("pool", [...new Set(pool)]);
236
- if (args.flags.has("env"))
237
- set("env", {
238
- ...(definition.env ?? {}),
239
- ...kit.envPairs(args, env),
240
- });
241
- if (image !== undefined)
242
- set("from", { image });
243
- if (snapshot !== undefined)
244
- set("from", { snapshot });
245
- set("vcpu", integer(args, "vcpu"));
246
- set("memoryMiB", integer(args, "memory"));
247
- set("maxConcurrent", integer(args, "max-concurrent"));
248
- set("idlePauseSeconds", integer(args, "idle-pause"));
249
- set("model", flag(args, "model"));
250
- const limits = flag(args, "session-overrides");
251
- if (limits !== undefined)
252
- set("sessionOverrides", jsonObject(limits, "--session-overrides", kit));
253
- set("maxChildren", integer(args, "max-children"));
254
- const advisor = flag(args, "advisor");
255
- const advisorSecret = flag(args, "advisor-secret");
256
- if (advisorSecret !== undefined && advisor === undefined && !definition.advisor)
257
- throw usage("Give --advisor <model> with --advisor-secret.");
258
- if (advisor !== undefined || advisorSecret !== undefined)
259
- set("advisor", {
260
- ...(definition.advisor ?? {}),
261
- ...(advisor === undefined ? {} : { model: advisor }),
262
- ...(advisorSecret === undefined ? {} : { secret: advisorSecret }),
263
- });
264
- const permissions = flag(args, "permissions");
265
- if (permissions !== undefined) {
266
- try {
267
- set("permissions", JSON.parse(permissions));
268
- }
269
- catch {
270
- throw usage(`--permissions takes JSON: '{"default":"auto","tools":{"shell":"always_ask"}}'.`);
271
- }
272
- }
273
- return definition;
274
- }
275
- /** A flag's JSON object, or a usage error that says so. */
276
- function jsonObject(text, name, kit) {
277
- let value;
278
- try {
279
- value = JSON.parse(text);
280
- }
281
- catch {
282
- value = undefined;
283
- }
284
- if (!value || typeof value !== "object" || Array.isArray(value))
285
- throw kit.usage(`${name} takes a JSON object, such as '{"models":["claude-opus-5-5"]}'.`);
286
- return value;
287
- }
288
- /** A session's overrides, from start's options; none given, none. */
289
- function overridesOf(args, kit) {
290
- const { flag, has, integer, usage } = kit;
291
- const file = flag(args, "instructions-file");
292
- const instructions = file !== undefined ? readFileSync(file, "utf8") : flag(args, "instructions");
293
- if (has(args, "replace-instructions") && instructions === undefined)
294
- throw usage("--replace-instructions needs --instructions or --instructions-file.");
295
- if (has(args, "no-mcp") && args.flags.has("mcp"))
296
- throw usage("Give --mcp or --no-mcp, not both.");
297
- const dollars = flag(args, "max-dollars");
298
- if (dollars !== undefined && !(Number(dollars) > 0))
299
- throw usage("--max-dollars takes a number of dollars, such as 2.5.");
300
- const o = {};
301
- const model = flag(args, "model");
302
- if (model !== undefined)
303
- o.model = model;
304
- if (instructions !== undefined)
305
- o.instructions = instructions;
306
- if (has(args, "replace-instructions"))
307
- o.instructionsMode = "replace";
308
- if (has(args, "no-mcp"))
309
- o.mcp = [];
310
- else if (args.flags.has("mcp"))
311
- o.mcp = [...new Set(args.flags.get("mcp"))];
312
- if (args.flags.has("disallow"))
313
- o.disallowedTools = [...new Set(args.flags.get("disallow"))];
314
- const vcpu = integer(args, "vcpu");
315
- if (vcpu !== undefined)
316
- o.vcpu = vcpu;
317
- const memory = integer(args, "memory");
318
- if (memory !== undefined)
319
- o.memoryMiB = memory;
320
- if (dollars !== undefined)
321
- o.maxSessionDollars = Number(dollars);
322
- return Object.keys(o).length ? o : undefined;
323
- }
324
- const WORKFLOW_STATES = ["running", "done", "failed", "stopped"];
325
- /** A workflow in a few lines: its state, cost, each phase's progress and,
326
- * once ended, its result. */
327
- const workflowLines = (w) => [
328
- `${w.id}${w.name ? ` ${w.name}` : ""} ${w.state}${w.reason && w.reason !== "done" ? ` (${w.reason})` : ""}, ${w.started} session${w.started === 1 ? "" : "s"}, $${w.cost.dollars.toFixed(2)} of $${w.maxDollars}`,
329
- ...w.phases.map((p) => ` ${p.name.padEnd(16)} ${p.done}/${p.total}${p.ready ? "" : "+"} done, ${p.running} running, ${p.pending} waiting${p.failed ? `, ${p.failed} failed` : ""}`),
330
- ...(w.result !== null ? ["", w.result] : []),
331
- ].join("\n");
332
- const line = (e) => `${String(e.seq).padStart(4)} ${e.kind.padEnd(6)} ${e.actor}: ${e.kind === "turn"
333
- ? turnLine(e.body)
334
- : e.kind === "tool"
335
- ? toolLine(e.body)
336
- : typeof e.body.text === "string"
337
- ? e.body.text
338
- : JSON.stringify(e.body)}`;
339
- const count = (n) => n.toLocaleString("en-US");
340
- const seconds = (ms) => `${(ms / 1000).toFixed(1)} s`;
341
- const dollars = (usd) => usd === null ? "unpriced" : `$${usd < 1 ? usd.toFixed(4) : usd.toFixed(2)}`;
342
- function turnLine(t) {
343
- const calls = t.toolCalls.length ? ` -> ${t.toolCalls.map((c) => c.name).join(", ")}` : "";
344
- const failed = t.error ? ` FAILED ${t.error}` : "";
345
- return `${t.model} ${seconds(t.durationMs)}, ${count(t.inputTokens)} in, ${count(t.outputTokens)} out, ${count(t.cacheReadTokens)} cached, ${dollars(t.costUsd)}${calls}${failed}`;
346
- }
347
- function toolLine(t) {
348
- return `${t.name} ${seconds(t.durationMs)}${t.error ? " FAILED" : ""}${t.input ? ` ${t.input.slice(0, 100)}` : ""}`;
349
- }
350
- /** Spans a trace command reads a request: the API's most. */
351
- const TRACE_PAGE = 500;
352
- /** The span list of an OTLP page, as the API writes it: one resource, one scope. */
353
- function otlpSpans(otlp) {
354
- const scope = otlp.resourceSpans[0]
355
- ?.scopeSpans?.[0];
356
- if (!scope)
357
- return [];
358
- scope.spans ??= [];
359
- return scope.spans;
360
- }
361
- /** Where --export sends OTLP: --endpoint, else the OpenTelemetry SDK's own
362
- * variables; a base URL gets /v1/traces, as an OTLP/HTTP exporter adds it. */
363
- export function otlpTarget(endpoint, env, headers) {
364
- const full = endpoint ?? env.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT;
365
- const base = endpoint ? undefined : env.OTEL_EXPORTER_OTLP_ENDPOINT;
366
- const url = full
367
- ? endpoint && !/\/v1\/traces\/?$/.test(endpoint)
368
- ? `${endpoint.replace(/\/+$/, "")}/v1/traces`
369
- : full
370
- : base
371
- ? `${base.replace(/\/+$/, "")}/v1/traces`
372
- : null;
373
- if (!url)
374
- return null;
375
- const fromEnv = {};
376
- for (const pair of (env.OTEL_EXPORTER_OTLP_TRACES_HEADERS ??
377
- env.OTEL_EXPORTER_OTLP_HEADERS ??
378
- "").split(",")) {
379
- const at = pair.indexOf("=");
380
- if (at > 0)
381
- fromEnv[decodeURIComponent(pair.slice(0, at).trim())] = decodeURIComponent(pair.slice(at + 1).trim());
382
- }
383
- return { url, headers: { ...fromEnv, ...headers } };
384
- }
385
- export async function agentsCommand(argv, env, out, client, kit) {
386
- const { parse, flag, has, need, pairs, table, usage, unknown } = kit;
387
- const [verb, ...rest] = argv;
388
- const print = (human, value) => out.write(out.json ? JSON.stringify(value) : human);
389
- if (!verb || verb === "help" || verb === "--help") {
390
- print(named(AGENT_HELP), { usage: named(AGENT_HELP) });
391
- return 0;
392
- }
393
- if (verb === "templates") {
394
- const value = { templates: AGENT_TEMPLATES, uses: AGENT_USES };
395
- print([
396
- table([
397
- ["TEMPLATE", "HARNESS", "MODEL KEY", "SUBSCRIPTION"],
398
- ...Object.values(AGENT_TEMPLATES).map((t) => [
399
- t.key,
400
- t.title,
401
- `${t.apiKeySecret} (${t.apiKeyHost})`,
402
- t.subscription ? "yes, for your own team" : "no",
403
- ]),
404
- ]),
405
- "",
406
- table([
407
- ["USE", "FOR", "SIZE", "TRIGGERS"],
408
- ...Object.values(AGENT_USES).map((u) => [
409
- u.key,
410
- u.title,
411
- `${u.definition.vcpu} vCPU, ${u.definition.memoryMiB} MiB`,
412
- u.triggers.join(", "),
413
- ]),
414
- ]),
415
- ].join("\n"), value);
416
- return 0;
417
- }
418
- if (verb === "init")
419
- return initFile(rest, out, kit);
420
- if (verb === "deploy")
421
- return deploy(rest, out, client, kit);
422
- const transport = (await client()).transport;
423
- const api = agents(transport);
424
- const follow = async (sessionId, after) => {
425
- for await (const e of (await api.session(sessionId)).events({ after }))
426
- out.write(out.json ? JSON.stringify(e) : line(e));
427
- };
428
- switch (verb) {
429
- case "create": {
430
- const args = parse(rest, [], OPTIONS);
431
- const name = need(args.positional[0], "the agent's name");
432
- const definition = definitionOf(args, kit, env);
433
- if (!definition.command)
434
- throw usage(`Give --template (${Object.keys(AGENT_TEMPLATES).join(", ")}) or --command.`);
435
- const agent = await api.create({
436
- name,
437
- definition,
438
- ...(args.flags.has("label") ? { labels: pairs(args, "label") } : {}),
439
- });
440
- if (!out.json && agent.warnings.includes("subscription_for_customers"))
441
- out.error("Warning: this agent answers your customers with a subscription's token. A subscription is for your own team's agents; an agent that serves your customers uses an API key.");
442
- print(agent.id, agent);
443
- return 0;
444
- }
445
- case "ls":
446
- case "list": {
447
- parse(rest, [], []);
448
- const all = await (await api.list({ limit: 100 })).toArray(Infinity);
449
- print(all.length
450
- ? table([
451
- ["ID", "NAME", "VERSION", "SIZE", "COMMAND", "CREATED"],
452
- ...all.map((a) => [
453
- a.id,
454
- a.name,
455
- `v${a.version}`,
456
- `${a.definition.vcpu} vCPU, ${a.definition.memoryMiB} MiB`,
457
- a.definition.command.length > 40
458
- ? `${a.definition.command.slice(0, 39)}…`
459
- : a.definition.command,
460
- when(a.createdAt),
461
- ]),
462
- ])
463
- : `No agents. Make one: ${me} agents create helper --template claude-code --use support`, all);
464
- return 0;
465
- }
466
- case "get": {
467
- const agent = await api.get(need(rest[0], "an agent's id or name"));
468
- print(JSON.stringify(agent, null, 2), agent);
469
- return 0;
470
- }
471
- case "update": {
472
- const args = parse(rest, [], OPTIONS.filter((o) => o !== "label"));
473
- const current = await api.get(need(args.positional[0], "an agent's id or name"));
474
- const agent = await api.update(current.id, definitionOf(args, kit, env, current.definition));
475
- print(`${agent.name} is now version ${agent.version}.`, agent);
476
- return 0;
477
- }
478
- case "rm":
479
- case "delete": {
480
- const target = need(rest[0], "an agent's id or name");
481
- await api.delete(target);
482
- print(`${target} deleted; its open sessions are stopping.`, { deleted: true });
483
- return 0;
484
- }
485
- case "start": {
486
- const args = parse(rest, ["follow", "replace-instructions", "no-mcp"], [
487
- "key",
488
- "model",
489
- "instructions",
490
- "instructions-file",
491
- "mcp",
492
- "disallow",
493
- "vcpu",
494
- "memory",
495
- "max-dollars",
496
- ]);
497
- const target = need(args.positional[0], "an agent's id or name");
498
- const input = args.positional.slice(1).join(" ");
499
- if (!input)
500
- throw usage(`Give the words: ${me} agents start ${target} "Fix the failing test"`);
501
- const key = flag(args, "key");
502
- const overrides = overridesOf(args, kit);
503
- const session = await api.start(target, {
504
- input,
505
- ...(key === undefined ? {} : { key }),
506
- ...(overrides ? { overrides } : {}),
507
- });
508
- if (!has(args, "follow")) {
509
- print(session.id, { session: session.session, joined: session.joined, seq: session.seq });
510
- return 0;
511
- }
512
- if (!out.json)
513
- out.error(`Session ${session.id}${session.joined ? " (joined)" : ""}`);
514
- await follow(session.id, 0);
515
- return 0;
516
- }
517
- case "send": {
518
- const id = need(rest[0], "a session's id");
519
- const text = rest.slice(1).join(" ");
520
- if (!text)
521
- throw usage(`Give the words: ${me} agents send ${id} "And the docs too"`);
522
- const sent = await (await api.session(id)).send(text);
523
- print(`seq ${sent.seq}`, sent);
524
- return 0;
525
- }
526
- case "events": {
527
- const args = parse(rest, ["follow"], ["after"]);
528
- const id = need(args.positional[0], "a session's id");
529
- const after = kit.integer(args, "after") ?? 0;
530
- if (has(args, "follow")) {
531
- await follow(id, after);
532
- return 0;
533
- }
534
- // One read without waiting: what is there now.
535
- const read = await transport.json({
536
- method: "GET",
537
- path: `/v1/agents/sessions/${encodeURIComponent(id)}/events`,
538
- query: { after },
539
- });
540
- print(read.data.map(line).join("\n") || "No events yet.", read);
541
- return 0;
542
- }
543
- case "trace": {
544
- const args = parse(rest, ["otlp", "export"], ["endpoint", "header"]);
545
- const id = need(args.positional[0], "a session's id");
546
- if (has(args, "export")) {
547
- const target = otlpTarget(flag(args, "endpoint"), env, args.flags.has("header") ? pairs(args, "header") : {});
548
- if (!target)
549
- throw usage("Give --endpoint, or set OTEL_EXPORTER_OTLP_ENDPOINT: where your collector takes OTLP/HTTP.");
550
- // One export request a page: the collector joins them by trace id.
551
- let spans = 0;
552
- for (let after = 0; after !== null;) {
553
- const { nextAfter, ...otlp } = await api.sessions.trace(id, {
554
- format: "otlp",
555
- after,
556
- limit: TRACE_PAGE,
557
- });
558
- const sent = await fetch(target.url, {
559
- method: "POST",
560
- headers: { "content-type": "application/json", ...target.headers },
561
- body: JSON.stringify(otlp),
562
- });
563
- if (!sent.ok) {
564
- out.error(`${target.url} returned ${sent.status}: ${(await sent.text()).slice(0, 500)}`);
565
- return 1;
566
- }
567
- spans += otlpSpans(otlp).length;
568
- after = nextAfter;
569
- }
570
- print(`Sent ${spans} spans to ${target.url}.`, { sent: spans, url: target.url });
571
- return 0;
572
- }
573
- if (has(args, "otlp")) {
574
- // Every page's spans in one ExportTraceServiceRequest.
575
- let whole;
576
- for (let after = 0; after !== null;) {
577
- const page = await api.sessions.trace(id, {
578
- format: "otlp",
579
- after,
580
- limit: TRACE_PAGE,
581
- });
582
- if (whole)
583
- otlpSpans(whole).push(...otlpSpans(page));
584
- else
585
- whole = page;
586
- after = page.nextAfter;
587
- }
588
- const { nextAfter: _, ...otlp } = whole;
589
- out.write(JSON.stringify(otlp));
590
- return 0;
591
- }
592
- const trace = await api.sessions.trace(id, { limit: TRACE_PAGE });
593
- for (let after = trace.nextAfter; after !== null;) {
594
- const page = await api.sessions.trace(id, { after, limit: TRACE_PAGE });
595
- trace.spans.push(...page.spans);
596
- after = trace.nextAfter = page.nextAfter;
597
- }
598
- const t = trace.totals;
599
- print([
600
- `${count(t.turns)} turns, ${count(t.toolCalls)} tool calls, ${dollars(t.costUsd)}${t.unpricedTurns ? ` (${t.unpricedTurns} turns unpriced)` : ""}`,
601
- `${count(t.inputTokens)} in, ${count(t.outputTokens)} out, ${count(t.cacheReadTokens)} cache read, ${count(t.cacheWriteTokens)} cache write; ${seconds(t.modelMs)} in the model, ${seconds(t.toolMs)} in tools`,
602
- "",
603
- trace.models.length
604
- ? table([
605
- ["MODEL", "TURNS", "IN", "OUT", "CACHE READ", "COST"],
606
- ...trace.models.map((m) => [
607
- m.model,
608
- count(m.turns),
609
- count(m.inputTokens),
610
- count(m.outputTokens),
611
- count(m.cacheReadTokens),
612
- m.unpricedTurns === m.turns ? "unpriced" : dollars(m.costUsd),
613
- ]),
614
- ])
615
- : "No turns yet.",
616
- ...(trace.tools.length
617
- ? [
618
- "",
619
- table([
620
- ["TOOL", "CALLS", "FAILED", "TIME"],
621
- ...trace.tools.map((k) => [
622
- k.name,
623
- count(k.calls),
624
- count(k.failed),
625
- seconds(k.durationMs),
626
- ]),
627
- ]),
628
- ]
629
- : []),
630
- "",
631
- ...trace.spans.map((x) => `${String(x.seq).padStart(4)} ${x.startedAt} ${x.kind.padEnd(4)} ${x.kind === "turn" ? turnLine(x) : toolLine(x)}`),
632
- ].join("\n"), trace);
633
- return 0;
634
- }
635
- case "sessions": {
636
- if (rest[0] === "delete" || rest[0] === "rm") {
637
- const target = need(rest[1], "a session's id");
638
- await api.sessions.delete(target);
639
- print(`${target} deleted.`, { deleted: true });
640
- return 0;
641
- }
642
- const args = parse(rest, [], ["agent", "state"]);
643
- const states = args.flags.get("state");
644
- for (const state of states ?? [])
645
- if (!STATES.includes(state))
646
- throw usage(`--state takes ${STATES.join(", ")}.`);
647
- const agent = flag(args, "agent");
648
- const page = await api.sessions.list({
649
- limit: 100,
650
- ...(agent === undefined ? {} : { agent }),
651
- ...(states ? { state: states } : {}),
652
- });
653
- print(page.data.length
654
- ? table([
655
- ["ID", "AGENT", "STATE", "KEY", "TRIGGER", "CREATED"],
656
- ...page.data.map((s) => [
657
- s.id,
658
- s.agentId,
659
- s.state,
660
- s.key ?? "-",
661
- s.trigger,
662
- when(s.createdAt),
663
- ]),
664
- ])
665
- : "No sessions.", page.data);
666
- return 0;
667
- }
668
- case "asks": {
669
- if (rest[0] === "get") {
670
- const one = await api.asks.get(need(rest[1], "an ask's id"));
671
- print(askLine(one), one);
672
- return 0;
673
- }
674
- const args = parse(rest, [], ["state", "agent", "label"]);
675
- const states = args.flags.get("state");
676
- for (const state of states ?? [])
677
- if (!ASK_STATES.includes(state))
678
- throw usage(`--state takes ${ASK_STATES.join(", ")}.`);
679
- const agent = flag(args, "agent");
680
- const labels = args.flags.has("label") ? pairs(args, "label") : undefined;
681
- const page = await api.asks.list({
682
- limit: 100,
683
- ...(agent === undefined ? {} : { agent }),
684
- ...(states ? { state: states } : {}),
685
- ...(labels ? { labels } : {}),
686
- });
687
- print(page.data.map(askLine).join("\n\n") || "Nothing to answer.", page.data);
688
- return 0;
689
- }
690
- case "answer": {
691
- const args = parse(rest, [], ["text"]);
692
- const id = need(args.positional[0], "an ask's id");
693
- const option = args.positional.slice(1).join(" ") || undefined;
694
- const text = flag(args, "text");
695
- if (option === undefined && text === undefined)
696
- throw usage(`Give an option's label, --text, or both: ${me} agents answer ${id} "Keep it"`);
697
- const answered = await api.asks.answer(id, {
698
- ...(option === undefined ? {} : { option }),
699
- ...(text === undefined ? {} : { text }),
700
- });
701
- print(`${answered.id} answered; ${answered.sessions.filter((x) => x.state === "answered").length} session(s) woken.`, answered);
702
- return 0;
703
- }
704
- case "workflows": {
705
- const args = parse(rest, [], ["state"]);
706
- const states = args.flags.get("state");
707
- for (const state of states ?? [])
708
- if (!WORKFLOW_STATES.includes(state))
709
- throw usage(`--state takes ${WORKFLOW_STATES.join(", ")}.`);
710
- const page = await api.workflows.list({
711
- limit: 100,
712
- ...(states ? { state: states } : {}),
713
- });
714
- print(page.data.length
715
- ? table([
716
- ["ID", "NAME", "STATE", "SESSIONS", "COST", "CREATED"],
717
- ...page.data.map((w) => [
718
- w.id,
719
- w.name ?? "-",
720
- w.reason && w.reason !== "done" ? `${w.state} (${w.reason})` : w.state,
721
- String(w.started),
722
- `$${w.cost.dollars.toFixed(2)}`,
723
- when(w.createdAt),
724
- ]),
725
- ])
726
- : `No workflows. Run one: ${me} agents workflow run workflow.json`, page.data);
727
- return 0;
728
- }
729
- case "workflow": {
730
- const [sub, ...more] = rest;
731
- const watch = async (id, after) => {
732
- let last;
733
- for await (const now of api.workflows.follow(id, { after })) {
734
- last = now;
735
- out.write(out.json ? JSON.stringify(now) : `${workflowLines({ ...now, result: null })}\n`);
736
- }
737
- last ??= await api.workflows.get(id);
738
- if (!out.json && last.result !== null)
739
- out.write(last.result);
740
- return last.state === "done" ? 0 : 1;
741
- };
742
- if (sub === "run") {
743
- const args = parse(more, ["follow"], []);
744
- const file = need(args.positional[0], "a workflow's JSON file, or - for stdin");
745
- let text;
746
- if (file === "-") {
747
- const chunks = [];
748
- for await (const chunk of process.stdin)
749
- chunks.push(chunk);
750
- text = Buffer.concat(chunks).toString("utf8");
751
- }
752
- else
753
- text = readFileSync(file, "utf8");
754
- let spec;
755
- try {
756
- spec = JSON.parse(text);
757
- }
758
- catch (error) {
759
- throw usage(`${file} is not JSON: ${error.message}`);
760
- }
761
- const made = await api.workflows.run(spec);
762
- if (!has(args, "follow")) {
763
- print(made.id, made.workflow);
764
- return 0;
765
- }
766
- if (!out.json)
767
- out.error(`Workflow ${made.id}`);
768
- out.write(out.json ? JSON.stringify(made.workflow) : `${workflowLines(made.workflow)}\n`);
769
- return watch(made.id, made.workflow.version);
770
- }
771
- if (sub === "get") {
772
- const w = await api.workflows.get(need(more[0], "a workflow's id"));
773
- print(workflowLines(w), w);
774
- return 0;
775
- }
776
- if (sub === "watch")
777
- return watch(need(more[0], "a workflow's id"), 0);
778
- if (sub === "steps") {
779
- const args = parse(more, [], ["state"]);
780
- const id = need(args.positional[0], "a workflow's id");
781
- const states = args.flags.get("state");
782
- const all = await (await api.workflows.steps(id, {
783
- limit: 100,
784
- ...(states ? { state: states } : {}),
785
- })).toArray(Infinity);
786
- print(all.length
787
- ? table([
788
- ["PHASE", "ITEM", "STATE", "SESSION", "ITEM TEXT"],
789
- ...all.map((x) => [
790
- x.phase,
791
- String(x.item + 1),
792
- x.state,
793
- x.sessionId ?? "-",
794
- (x.itemText ?? "-").replace(/\s+/g, " ").slice(0, 60),
795
- ]),
796
- ])
797
- : "No steps yet.", all);
798
- return 0;
799
- }
800
- if (sub === "stop") {
801
- const w = await api.workflows.stop(need(more[0], "a workflow's id"));
802
- print(`${w.id} ${w.state}.`, w);
803
- return 0;
804
- }
805
- throw unknown("agents workflow command", sub ?? "", ["run", "get", "watch", "steps", "stop"]);
806
- }
807
- case "approve":
808
- case "deny": {
809
- const args = parse(rest, [], verb === "deny" ? ["message"] : []);
810
- const id = need(args.positional[0], "an ask's id");
811
- const message = verb === "deny" ? flag(args, "message") : undefined;
812
- const answered = verb === "approve" ? await api.asks.approve(id) : await api.asks.deny(id, message);
813
- print(`${answered.id}: ${answered.toolCall?.tool ?? "the call"} ${verb === "approve" ? "allowed" : "denied"}.`, answered);
814
- return 0;
815
- }
816
- case "stop": {
817
- const session = await (await api.session(need(rest[0], "a session's id"))).stop();
818
- print(`${session.id} ${session.state}.`, session);
819
- return 0;
820
- }
821
- case "switch": {
822
- const platform = need(rest[0], "the platform to switch from: anthropic");
823
- if (platform !== "anthropic")
824
- throw usage(`runtime agents switch takes anthropic (Claude Managed Agents); ${platform} is not available yet.`);
825
- const { baseURL } = await api.anthropic();
826
- const modelKey = (await secrets(transport).list()).find((s) => s.name === "ANTHROPIC_API_KEY");
827
- const value = {
828
- platform,
829
- baseURL,
830
- modelKey: modelKey ? { name: modelKey.name, hosts: modelKey.hosts } : null,
831
- docs: SWITCH_DOCS,
832
- };
833
- print([
834
- "Claude Managed Agents code runs on Runtime with its client's base URL and key changed:",
835
- "",
836
- ` new Anthropic({ baseURL: "${baseURL}", apiKey: process.env.RUNTIME_API_KEY })`,
837
- ` anthropic.Anthropic(base_url="${baseURL}", api_key=os.environ["RUNTIME_API_KEY"])`,
838
- "",
839
- modelKey
840
- ? `Model key: ANTHROPIC_API_KEY is set (${modelKey.hosts.join(", ")}); sessions use it.`
841
- : [
842
- "Model key: ANTHROPIC_API_KEY is not set. Agents run on your own Anthropic key;",
843
- "store it once, and the sandbox never sees it:",
844
- ' printf %s "$ANTHROPIC_API_KEY" | runtime secrets set ANTHROPIC_API_KEY --host api.anthropic.com',
845
- ].join("\n"),
846
- `What maps and what does not: ${SWITCH_DOCS}`,
847
- "",
848
- ].join("\n"), value);
849
- return 0;
850
- }
851
- case "slack": {
852
- const [sub, ...more] = rest;
853
- if (sub === "install") {
854
- const link = await api.slack.install();
855
- print(`Open this link to add Runtime's Slack app to a workspace (good until ${link.expiresAt}):\n${link.url}`, link);
856
- return 0;
857
- }
858
- if (sub === "rm") {
859
- const team = need(more[0], "a workspace's id (T…), from `agents slack ls`");
860
- await api.slack.remove(team);
861
- print(`${team} removed.`, { team, removed: true });
862
- return 0;
863
- }
864
- if (sub === undefined || sub === "ls") {
865
- const teams = await api.slack.teams();
866
- print(teams.length
867
- ? teams.map((w) => `${w.team} ${w.name ?? ""} added ${w.installedAt}`).join("\n")
868
- : `No Slack workspace is added. Add one: ${me} agents slack install`, teams);
869
- return 0;
870
- }
871
- throw usage(`Use ${me} agents slack install, ls or rm <team>.`);
872
- }
873
- case "triggers": {
874
- const [sub, ...more] = rest;
875
- if (sub === "add") {
876
- const args = parse(more, [], ["kind", "config", "rules"]);
877
- const target = need(args.positional[0], "an agent's id or name");
878
- let config;
879
- try {
880
- config = JSON.parse(flag(args, "config") ?? "{}");
881
- }
882
- catch {
883
- throw usage(`--config takes JSON, such as --config '{"cron":"0 9 * * 1-5","input":"Triage new issues"}'.`);
884
- }
885
- const rules = flag(args, "rules");
886
- const trigger = await api.triggers.create(target, {
887
- kind: need(flag(args, "kind"), "--kind"),
888
- config,
889
- ...(rules === undefined ? {} : { rules: rulesOf(rules, kit) }),
890
- });
891
- // A webhook's secret is answered this once.
892
- print(trigger.secret
893
- ? `${trigger.id}\nsecret ${trigger.secret} (shown once; each call carries it)`
894
- : trigger.id, trigger);
895
- return 0;
896
- }
897
- if (sub === "rules") {
898
- const id = need(more[0], "a trigger's id");
899
- const trigger = await api.triggers.setRules(id, rulesOf(need(more[1], `the rules as JSON: ${me} agents triggers rules ${id} '{"priority":10}'`), kit));
900
- print(`${trigger.id} rules ${JSON.stringify(trigger.rules)}`, trigger);
901
- return 0;
902
- }
903
- if (sub === "call") {
904
- const args = parse(more, [], ["key", "label", "secret"]);
905
- const id = need(args.positional[0], "a trigger's id");
906
- const text = args.positional.slice(1).join(" ");
907
- if (!text)
908
- throw usage(`Give the words: ${me} agents triggers call ${id} "disk full on db-1"`);
909
- const secret = flag(args, "secret") ?? env.RUNTIME_TRIGGER_SECRET;
910
- if (!secret)
911
- throw usage("Give the trigger's secret: --secret rtat_… or RUNTIME_TRIGGER_SECRET, as answered when the webhook was added.");
912
- const key = flag(args, "key");
913
- const done = await api.triggers.call(id, secret, {
914
- text,
915
- ...(key === undefined ? {} : { key }),
916
- ...(args.flags.has("label") ? { labels: pairs(args, "label") } : {}),
917
- });
918
- print(done.outcome === "held"
919
- ? `held ${done.callId}: ${done.why}`
920
- : `${done.outcome} ${done.sessionId} seq ${done.seq}`, done);
921
- return 0;
922
- }
923
- if (sub === "held") {
924
- const [action, ...after] = more;
925
- if (action === "start" || action === "dismiss") {
926
- const id = need(after[0], "a trigger's id");
927
- const call = need(after[1], "a held call's id");
928
- if (action === "start") {
929
- const started = await api.triggers.startHeld(id, call);
930
- print(`${started.joined ? "joined" : "started"} ${started.session.id} with ${started.calls} held call${started.calls === 1 ? "" : "s"}`, started);
931
- }
932
- else {
933
- const dismissed = await api.triggers.dismissHeld(id, call);
934
- print(`${dismissed.id} dismissed.`, dismissed);
935
- }
936
- return 0;
937
- }
938
- const args = parse(more, [], ["state"]);
939
- const states = args.flags.get("state");
940
- for (const state of states ?? [])
941
- if (!["held", "started", "dismissed"].includes(state))
942
- throw usage("--state takes held, started, dismissed.");
943
- const page = await api.triggers.held(need(args.positional[0], "a trigger's id"), {
944
- limit: 100,
945
- ...(states ? { state: states } : {}),
946
- });
947
- print(page.data.length
948
- ? table([
949
- ["ID", "STATE", "WHY", "KEY", "CREATED", "WORDS"],
950
- ...page.data.map((c) => [
951
- c.id,
952
- c.state,
953
- c.why,
954
- c.key ?? "-",
955
- when(c.createdAt),
956
- c.text.replace(/\s+/g, " ").slice(0, 60),
957
- ]),
958
- ])
959
- : "No held calls.", page.data);
960
- return 0;
961
- }
962
- if (sub === "pause") {
963
- const args = parse(more, [], ["why"]);
964
- const trigger = await api.triggers.pause(need(args.positional[0], "a trigger's id"), need(flag(args, "why"), "--why"));
965
- print(`${trigger.id} paused: ${trigger.pausedWhy}`, trigger);
966
- return 0;
967
- }
968
- if (sub === "resume") {
969
- const trigger = await api.triggers.resume(need(more[0], "a trigger's id"));
970
- print(`${trigger.id} resumed.`, trigger);
971
- return 0;
972
- }
973
- if (sub === "rm" || sub === "delete") {
974
- await api.triggers.delete(need(more[0], "a trigger's id"));
975
- print(`${more[0]} deleted.`, { deleted: true });
976
- return 0;
977
- }
978
- const all = await api.triggers.list(need(sub, "an agent's id or name"));
979
- print(all.length
980
- ? table([
981
- ["ID", "KIND", "CONFIG", "RULES", "PAUSED"],
982
- ...all.map((t) => [
983
- t.id,
984
- t.kind,
985
- JSON.stringify(t.config),
986
- Object.keys(t.rules ?? {}).length ? JSON.stringify(t.rules) : "-",
987
- t.pausedWhy ?? "-",
988
- ]),
989
- ])
990
- : "No triggers.", all);
991
- return 0;
992
- }
993
- case "memory":
994
- return memoryCommand(rest, api, out, kit, print);
995
- default:
996
- throw unknown("agents command", verb, [
997
- "templates",
998
- "init",
999
- "deploy",
1000
- "create",
1001
- "ls",
1002
- "get",
1003
- "update",
1004
- "rm",
1005
- "start",
1006
- "send",
1007
- "events",
1008
- "trace",
1009
- "sessions",
1010
- "stop",
1011
- "asks",
1012
- "answer",
1013
- "workflow",
1014
- "workflows",
1015
- "approve",
1016
- "deny",
1017
- "triggers",
1018
- "memory",
1019
- ]);
1020
- }
1021
- }
1022
- const scopeName = (scope) => scope || "(shared)";
1023
- /** `runtime agents memory`: an agent's built-in memory, by scope and path.
1024
- * Without --scope, cat, put and rm mean the shared memory, which every
1025
- * session reads (a per-key session read-only, what you put there alone);
1026
- * ls and search mean every scope. */
1027
- async function memoryCommand(argv, api, out, kit, print) {
1028
- const { parse, flag, need, table, usage, unknown } = kit;
1029
- const [sub, ...rest] = argv;
1030
- switch (sub) {
1031
- case "ls":
1032
- case "list": {
1033
- const args = parse(rest, [], ["scope", "prefix"]);
1034
- const agent = need(args.positional[0], "an agent's id or name");
1035
- const scope = flag(args, "scope");
1036
- const prefix = flag(args, "prefix");
1037
- const first = await api.memory.list(agent, {
1038
- limit: 1000,
1039
- ...(scope === undefined ? {} : { scope }),
1040
- ...(prefix === undefined ? {} : { prefix }),
1041
- });
1042
- const all = await first.toArray(Infinity);
1043
- const { usage: used } = first;
1044
- print([
1045
- all.length
1046
- ? table([
1047
- ["SCOPE", "PATH", "BYTES", "UPDATED"],
1048
- ...all.map((f) => [scopeName(f.scope), f.path, String(f.bytes), f.updatedAt]),
1049
- ])
1050
- : "No memory files.",
1051
- `${used.files} files, ${used.bytes} bytes in all (at most ${used.limitFiles} files, ${used.limitBytes} bytes).`,
1052
- ].join("\n"), { data: all, usage: used });
1053
- return 0;
1054
- }
1055
- case "search": {
1056
- const args = parse(rest, [], ["scope", "limit"]);
1057
- const agent = need(args.positional[0], "an agent's id or name");
1058
- const words = args.positional.slice(1).join(" ");
1059
- if (!words)
1060
- throw usage(`Give the words: ${me} agents memory search ${agent} "refund policy"`);
1061
- const scope = flag(args, "scope");
1062
- const limit = kit.integer(args, "limit");
1063
- const hits = await api.memory.search(agent, words, {
1064
- ...(scope === undefined ? {} : { scope }),
1065
- ...(limit === undefined ? {} : { limit }),
1066
- });
1067
- print(hits.length
1068
- ? table([
1069
- ["SCOPE", "PATH", "SNIPPET"],
1070
- ...hits.map((h) => [scopeName(h.scope), h.path, h.snippet.replace(/\s+/g, " ")]),
1071
- ])
1072
- : "Nothing matches.", hits);
1073
- return 0;
1074
- }
1075
- case "cat":
1076
- case "read": {
1077
- const args = parse(rest, [], ["scope"]);
1078
- const agent = need(args.positional[0], "an agent's id or name");
1079
- const file = await api.memory.read(agent, need(args.positional[1], "a file's path"), {
1080
- scope: flag(args, "scope") ?? "",
1081
- });
1082
- print(file.content, file);
1083
- return 0;
1084
- }
1085
- case "put":
1086
- case "write": {
1087
- const args = parse(rest, [], ["scope", "content"]);
1088
- const agent = need(args.positional[0], "an agent's id or name");
1089
- const path = need(args.positional[1], "a file's path");
1090
- const source = args.positional[2];
1091
- const given = flag(args, "content");
1092
- if (given !== undefined && source !== undefined)
1093
- throw usage("Give a file or --content, not both.");
1094
- let content = given;
1095
- if (content === undefined) {
1096
- if (source !== undefined && source !== "-")
1097
- content = readFileSync(source, "utf8");
1098
- // stdin only when named: a CI step with nothing piped in would
1099
- // otherwise replace the file with nothing.
1100
- else if (source === "-") {
1101
- const chunks = [];
1102
- for await (const chunk of process.stdin)
1103
- chunks.push(chunk);
1104
- content = Buffer.concat(chunks).toString("utf8");
1105
- }
1106
- else
1107
- throw usage(`Give the text: a file (${me} agents memory put ${agent} ${path} notes.md), - for stdin, or --content.`);
1108
- }
1109
- const written = await api.memory.write(agent, path, content, {
1110
- scope: flag(args, "scope") ?? "",
1111
- });
1112
- print(`${written.created ? "Wrote" : "Replaced"} ${path} in ${scopeName(written.scope)}: ${written.bytes} bytes.`, written);
1113
- return 0;
1114
- }
1115
- case "rm":
1116
- case "delete": {
1117
- const args = parse(rest, [], ["scope"]);
1118
- const agent = need(args.positional[0], "an agent's id or name");
1119
- const path = need(args.positional[1], "a file's path");
1120
- const scope = flag(args, "scope") ?? "";
1121
- const deleted = await api.memory.delete(agent, path, { scope });
1122
- print(deleted
1123
- ? `${path} deleted from ${scopeName(scope)}.`
1124
- : `No ${path} in ${scopeName(scope)}.`, { deleted });
1125
- return 0;
1126
- }
1127
- default:
1128
- if (!sub)
1129
- throw usage("agents memory takes ls, search, cat, put or rm.");
1130
- throw unknown("agents memory command", sub, ["ls", "search", "cat", "put", "rm"]);
1131
- }
1132
- }
1133
- /** `runtime agents init`: a starter agents: section, into a new runtime.yml
1134
- * or added to one that has none yet. The YAML parser loads only here and in
1135
- * deploy. */
1136
- async function initFile(argv, out, kit) {
1137
- const { parse, flag, usage } = kit;
1138
- const { AGENTS_FILE, parseAgentsFile, starterAgents } = await import("./agents-file.js");
1139
- const args = parse(argv, [], ["template", "use", "file"]);
1140
- const template = flag(args, "template") ?? "claude-code";
1141
- if (!(template in AGENT_TEMPLATES))
1142
- throw usage(`--template takes ${Object.keys(AGENT_TEMPLATES).join(", ")}.`);
1143
- const use = flag(args, "use");
1144
- if (use !== undefined && use !== "support" && use !== "team")
1145
- throw usage("--use takes support or team.");
1146
- const name = args.positional[0] ?? template;
1147
- if (!/^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$/.test(name))
1148
- throw usage("An agent's name is letters, digits, '.', '_' and '-', starting with a letter or digit.");
1149
- const file = flag(args, "file") ?? AGENTS_FILE;
1150
- const folder = dirname(resolve(file));
1151
- const instructionsFile = ["AGENTS.md", "CLAUDE.md"].find((f) => existsSync(join(folder, f)));
1152
- const text = starterAgents({
1153
- name,
1154
- template,
1155
- ...(use ? { use } : {}),
1156
- ...(instructionsFile ? { instructionsFile } : {}),
1157
- });
1158
- if (existsSync(file)) {
1159
- const existing = readFileSync(file, "utf8");
1160
- const config = parseAgentsFile(existing, file).config;
1161
- if (typeof config === "object" && config !== null && "agents" in config)
1162
- throw usage(`${file} already has an agents: section. Add ${name} under it by hand, or run \`${me} agents deploy\`.`);
1163
- writeFileSync(file, `${existing}${existing.endsWith("\n") || !existing ? "" : "\n"}\n${text}`);
1164
- }
1165
- else
1166
- writeFileSync(file, text);
1167
- const t = agentTemplate(template);
1168
- say(out, [
1169
- `Wrote agent ${name} (${t.title}) to ${file}${instructionsFile ? `, with ${instructionsFile} as its instructions` : ""}.`,
1170
- "Next:",
1171
- ` printf %s "$${t.apiKeySecret}" | ${me} secrets set ${t.apiKeySecret} --host ${t.apiKeyHost}`,
1172
- ` ${me} agents deploy --dry-run`,
1173
- ` ${me} agents deploy`,
1174
- ].join("\n"), { file, name, template, text });
1175
- return 0;
1176
- }
1177
- /** `runtime agents deploy`: the file is read and checked before any key is
1178
- * needed, then the plan is made against the account and each change made in
1179
- * turn, printed as it is made with its idempotency key. */
1180
- async function deploy(argv, out, client, kit) {
1181
- const { parse, flag, has } = kit;
1182
- const { AGENTS_FILE, loadAgentsFile } = await import("./agents-file.js");
1183
- const { checkAgentsFile, withDeploy } = await import("./agents-deploy.js");
1184
- const args = parse(argv, ["dry-run", "prune", "prune-memory"], ["file"]);
1185
- if (has(args, "prune-memory") && !has(args, "prune"))
1186
- throw kit.usage("--prune-memory goes with --prune.");
1187
- const dryRun = has(args, "dry-run");
1188
- const source = loadAgentsFile(flag(args, "file") ?? AGENTS_FILE);
1189
- const count = checkAgentsFile(source).length;
1190
- const api = withDeploy(agents((await client()).transport));
1191
- const shown = (c) => `${dryRun ? "would " : ""}${c.text} (key ${c.key})`;
1192
- if (!out.json)
1193
- out.write(`${source.file}: ${count} agent${count === 1 ? "" : "s"}${dryRun ? ". Dry run: nothing is changed." : "."}`);
1194
- let made = 0;
1195
- let result;
1196
- try {
1197
- result = await api.deploy(source, {
1198
- dryRun,
1199
- prune: has(args, "prune"),
1200
- pruneMemory: has(args, "prune-memory"),
1201
- onChange: (change) => {
1202
- made++;
1203
- if (out.json)
1204
- return;
1205
- out.write(shown(change));
1206
- if (change.action === "add-trigger" && change.secret)
1207
- out.write(` secret ${change.secret} (shown this once: each of its calls carries it; keep it now)`);
1208
- },
1209
- });
1210
- }
1211
- catch (error) {
1212
- if (made && !out.json)
1213
- out.error(`Stopped after ${made} change${made === 1 ? "" : "s"}. Run \`${me} agents deploy\` again to make the rest: each change's key makes a rerun safe.`);
1214
- throw error;
1215
- }
1216
- if (out.json) {
1217
- out.write(JSON.stringify(result));
1218
- return 0;
1219
- }
1220
- if (dryRun)
1221
- for (const change of result.changes)
1222
- out.write(shown(change));
1223
- if (result.unchanged.length)
1224
- out.write(`unchanged: ${result.unchanged.join(", ")}`);
1225
- for (const kept of result.leftAlone)
1226
- out.write(`left alone: ${kept.agent} (${kept.why})`);
1227
- const n = result.changes.length;
1228
- out.write(n === 0
1229
- ? `Nothing to change: your agents match ${source.file}.`
1230
- : dryRun
1231
- ? `${n} change${n === 1 ? "" : "s"} planned. Run \`${me} agents deploy\` to make ${n === 1 ? "it" : "them"}.`
1232
- : `Done: ${n} change${n === 1 ? "" : "s"}.`);
1233
- return 0;
1234
- }
1235
- function say(out, human, value) {
1236
- out.write(out.json ? JSON.stringify(value) : human);
1237
- }