@b3os/cli 0.2.1 → 0.2.2

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 (214) hide show
  1. package/README.md +87 -8
  2. package/assets/b3os-run.py +137 -0
  3. package/assets/skill/b3os/SKILL.md +111 -0
  4. package/dist/commands/_agents.d.ts +14 -0
  5. package/dist/commands/_agents.js +33 -0
  6. package/dist/commands/_agents.js.map +1 -0
  7. package/dist/commands/_common.js +6 -2
  8. package/dist/commands/_common.js.map +1 -1
  9. package/dist/commands/_context.d.ts +49 -0
  10. package/dist/commands/_context.js +260 -0
  11. package/dist/commands/_context.js.map +1 -0
  12. package/dist/commands/_next.d.ts +39 -0
  13. package/dist/commands/_next.js +77 -0
  14. package/dist/commands/_next.js.map +1 -0
  15. package/dist/commands/agent.d.ts +42 -0
  16. package/dist/commands/agent.js +218 -0
  17. package/dist/commands/agent.js.map +1 -0
  18. package/dist/commands/app.d.ts +2 -5
  19. package/dist/commands/app.js +229 -69
  20. package/dist/commands/app.js.map +1 -1
  21. package/dist/commands/auth.d.ts +70 -2
  22. package/dist/commands/auth.js +308 -33
  23. package/dist/commands/auth.js.map +1 -1
  24. package/dist/commands/docs.d.ts +54 -0
  25. package/dist/commands/docs.js +202 -0
  26. package/dist/commands/docs.js.map +1 -0
  27. package/dist/commands/doctor.d.ts +23 -0
  28. package/dist/commands/doctor.js +313 -0
  29. package/dist/commands/doctor.js.map +1 -0
  30. package/dist/commands/init.d.ts +38 -1
  31. package/dist/commands/init.js +259 -60
  32. package/dist/commands/init.js.map +1 -1
  33. package/dist/commands/listen.d.ts +30 -0
  34. package/dist/commands/listen.js +194 -0
  35. package/dist/commands/listen.js.map +1 -0
  36. package/dist/commands/manifest.d.ts +13 -1
  37. package/dist/commands/manifest.js +59 -7
  38. package/dist/commands/manifest.js.map +1 -1
  39. package/dist/commands/mcp.d.ts +25 -2
  40. package/dist/commands/mcp.js +120 -11
  41. package/dist/commands/mcp.js.map +1 -1
  42. package/dist/commands/sandbox.d.ts +35 -6
  43. package/dist/commands/sandbox.js +208 -9
  44. package/dist/commands/sandbox.js.map +1 -1
  45. package/dist/commands/setup.d.ts +39 -0
  46. package/dist/commands/setup.js +203 -0
  47. package/dist/commands/setup.js.map +1 -0
  48. package/dist/commands/tool.d.ts +109 -1
  49. package/dist/commands/tool.js +635 -47
  50. package/dist/commands/tool.js.map +1 -1
  51. package/dist/config.d.ts +30 -6
  52. package/dist/config.js +39 -8
  53. package/dist/config.js.map +1 -1
  54. package/dist/ctx.d.ts +5 -45
  55. package/dist/ctx.js +25 -160
  56. package/dist/ctx.js.map +1 -1
  57. package/dist/docs/index.json +1 -0
  58. package/dist/docs/pages/actions/call.md +300 -0
  59. package/dist/docs/pages/actions/catalog/airtable.md +737 -0
  60. package/dist/docs/pages/actions/catalog/arxiv.md +166 -0
  61. package/dist/docs/pages/actions/catalog/chainalysis-sanctions.md +125 -0
  62. package/dist/docs/pages/actions/catalog/coingecko.md +1558 -0
  63. package/dist/docs/pages/actions/catalog/deps-dev.md +465 -0
  64. package/dist/docs/pages/actions/catalog/dexscreener.md +568 -0
  65. package/dist/docs/pages/actions/catalog/discord.md +784 -0
  66. package/dist/docs/pages/actions/catalog/finnhub.md +776 -0
  67. package/dist/docs/pages/actions/catalog/frankfurter.md +438 -0
  68. package/dist/docs/pages/actions/catalog/github.md +1853 -0
  69. package/dist/docs/pages/actions/catalog/gmail.md +575 -0
  70. package/dist/docs/pages/actions/catalog/google-calendar.md +654 -0
  71. package/dist/docs/pages/actions/catalog/google-drive.md +502 -0
  72. package/dist/docs/pages/actions/catalog/google-sheets.md +700 -0
  73. package/dist/docs/pages/actions/catalog/hacker-news.md +542 -0
  74. package/dist/docs/pages/actions/catalog/http.md +824 -0
  75. package/dist/docs/pages/actions/catalog/hyperliquid.md +942 -0
  76. package/dist/docs/pages/actions/catalog/jira.md +920 -0
  77. package/dist/docs/pages/actions/catalog/kalshi.md +917 -0
  78. package/dist/docs/pages/actions/catalog/linear.md +1030 -0
  79. package/dist/docs/pages/actions/catalog/markets.md +21 -0
  80. package/dist/docs/pages/actions/catalog/morpho.md +247 -0
  81. package/dist/docs/pages/actions/catalog/notion.md +1077 -0
  82. package/dist/docs/pages/actions/catalog/nws.md +485 -0
  83. package/dist/docs/pages/actions/catalog/open-meteo.md +559 -0
  84. package/dist/docs/pages/actions/catalog/polymarket.md +1523 -0
  85. package/dist/docs/pages/actions/catalog/pushbullet.md +220 -0
  86. package/dist/docs/pages/actions/catalog/resend.md +307 -0
  87. package/dist/docs/pages/actions/catalog/s3.md +513 -0
  88. package/dist/docs/pages/actions/catalog/sec-edgar.md +487 -0
  89. package/dist/docs/pages/actions/catalog/slack.md +2629 -0
  90. package/dist/docs/pages/actions/catalog/stripe.md +1405 -0
  91. package/dist/docs/pages/actions/catalog/wikipedia.md +379 -0
  92. package/dist/docs/pages/actions/catalog.md +46 -0
  93. package/dist/docs/pages/actions/limits.md +50 -0
  94. package/dist/docs/pages/actions/model-tools.md +225 -0
  95. package/dist/docs/pages/actions/packs.md +148 -0
  96. package/dist/docs/pages/actions/settings.md +69 -0
  97. package/dist/docs/pages/actions/tools.md +244 -0
  98. package/dist/docs/pages/actions/triggers.md +149 -0
  99. package/dist/docs/pages/actions.md +88 -0
  100. package/dist/docs/pages/compat/anthropic.md +168 -0
  101. package/dist/docs/pages/compat/e2b.md +194 -0
  102. package/dist/docs/pages/compat/firecrawl.md +138 -0
  103. package/dist/docs/pages/compat/openai.md +168 -0
  104. package/dist/docs/pages/concepts/auth.md +151 -0
  105. package/dist/docs/pages/concepts/beta.md +55 -0
  106. package/dist/docs/pages/concepts/glossary.md +71 -0
  107. package/dist/docs/pages/concepts/ids.md +98 -0
  108. package/dist/docs/pages/concepts/jobs.md +229 -0
  109. package/dist/docs/pages/concepts/latency.md +138 -0
  110. package/dist/docs/pages/concepts/limits.md +191 -0
  111. package/dist/docs/pages/concepts/stack.md +59 -0
  112. package/dist/docs/pages/concepts/timing.md +86 -0
  113. package/dist/docs/pages/concepts/usage.md +110 -0
  114. package/dist/docs/pages/design/b3os-yaml.md +370 -0
  115. package/dist/docs/pages/design/deploy-from-github.md +122 -0
  116. package/dist/docs/pages/design/observability.md +134 -0
  117. package/dist/docs/pages/errors.md +1824 -0
  118. package/dist/docs/pages/infer/chat.md +570 -0
  119. package/dist/docs/pages/infer/limits.md +55 -0
  120. package/dist/docs/pages/infer/messages.md +185 -0
  121. package/dist/docs/pages/infer/responses.md +173 -0
  122. package/dist/docs/pages/infer/settings.md +154 -0
  123. package/dist/docs/pages/infer/speech.md +323 -0
  124. package/dist/docs/pages/infer.md +154 -0
  125. package/dist/docs/pages/introduction.md +162 -0
  126. package/dist/docs/pages/platform/addresses.md +174 -0
  127. package/dist/docs/pages/platform/call-log.md +99 -0
  128. package/dist/docs/pages/platform/custom-domains.md +104 -0
  129. package/dist/docs/pages/platform/keys.md +79 -0
  130. package/dist/docs/pages/platform/limits.md +57 -0
  131. package/dist/docs/pages/platform/members.md +101 -0
  132. package/dist/docs/pages/platform/requests.md +116 -0
  133. package/dist/docs/pages/platform/settings.md +129 -0
  134. package/dist/docs/pages/platform/webhooks.md +68 -0
  135. package/dist/docs/pages/platform.md +67 -0
  136. package/dist/docs/pages/quickstart/mcp.md +94 -0
  137. package/dist/docs/pages/quickstart/sandbox-agent.md +205 -0
  138. package/dist/docs/pages/quickstart/scrape.md +134 -0
  139. package/dist/docs/pages/quickstart.md +45 -0
  140. package/dist/docs/pages/render/inspections.md +162 -0
  141. package/dist/docs/pages/render/limits.md +72 -0
  142. package/dist/docs/pages/render/screenshots.md +179 -0
  143. package/dist/docs/pages/render/settings.md +431 -0
  144. package/dist/docs/pages/render/styles.md +342 -0
  145. package/dist/docs/pages/render/videos.md +272 -0
  146. package/dist/docs/pages/render.md +118 -0
  147. package/dist/docs/pages/routines/callables.md +174 -0
  148. package/dist/docs/pages/routines/definitions.md +361 -0
  149. package/dist/docs/pages/routines/limits.md +117 -0
  150. package/dist/docs/pages/routines/runs.md +328 -0
  151. package/dist/docs/pages/routines/settings.md +104 -0
  152. package/dist/docs/pages/routines/triggers.md +339 -0
  153. package/dist/docs/pages/routines.md +216 -0
  154. package/dist/docs/pages/sandboxes/agents.md +217 -0
  155. package/dist/docs/pages/sandboxes/commands.md +272 -0
  156. package/dist/docs/pages/sandboxes/images.md +166 -0
  157. package/dist/docs/pages/sandboxes/limits.md +143 -0
  158. package/dist/docs/pages/sandboxes/ports.md +260 -0
  159. package/dist/docs/pages/sandboxes/settings.md +358 -0
  160. package/dist/docs/pages/sandboxes/snapshots.md +423 -0
  161. package/dist/docs/pages/sandboxes/swarms.md +146 -0
  162. package/dist/docs/pages/sandboxes/volumes.md +131 -0
  163. package/dist/docs/pages/sandboxes.md +231 -0
  164. package/dist/docs/pages/sdks/cli.md +121 -0
  165. package/dist/docs/pages/sdks/mcp.md +169 -0
  166. package/dist/docs/pages/sdks/python.md +146 -0
  167. package/dist/docs/pages/sdks/typescript.md +202 -0
  168. package/dist/docs/pages/sdks.md +282 -0
  169. package/dist/docs/pages/settings.md +33 -0
  170. package/dist/docs/pages/vault/limits.md +46 -0
  171. package/dist/docs/pages/vault.md +133 -0
  172. package/dist/docs/pages/vision/agent-browser.md +115 -0
  173. package/dist/docs/pages/vision/crawl.md +333 -0
  174. package/dist/docs/pages/vision/extract.md +152 -0
  175. package/dist/docs/pages/vision/fetcher.md +15 -0
  176. package/dist/docs/pages/vision/limits.md +79 -0
  177. package/dist/docs/pages/vision/profiles.md +111 -0
  178. package/dist/docs/pages/vision/proxy.md +131 -0
  179. package/dist/docs/pages/vision/scrape.md +356 -0
  180. package/dist/docs/pages/vision/sessions.md +311 -0
  181. package/dist/docs/pages/vision/settings.md +656 -0
  182. package/dist/docs/pages/vision.md +175 -0
  183. package/dist/errors.d.ts +129 -0
  184. package/dist/errors.js +326 -0
  185. package/dist/errors.js.map +1 -0
  186. package/dist/main.d.ts +1 -1
  187. package/dist/main.js +26 -13
  188. package/dist/main.js.map +1 -1
  189. package/dist/manifest/domains.d.ts +50 -0
  190. package/dist/manifest/domains.js +159 -0
  191. package/dist/manifest/domains.js.map +1 -0
  192. package/dist/manifest/link.d.ts +20 -0
  193. package/dist/manifest/link.js +24 -0
  194. package/dist/manifest/link.js.map +1 -0
  195. package/dist/manifest/record.d.ts +1 -1
  196. package/dist/tool/archive.d.ts +33 -0
  197. package/dist/tool/archive.js +174 -0
  198. package/dist/tool/archive.js.map +1 -0
  199. package/dist/tool/calls.d.ts +46 -0
  200. package/dist/tool/calls.js +274 -0
  201. package/dist/tool/calls.js.map +1 -0
  202. package/dist/tool/checks.d.ts +21 -0
  203. package/dist/tool/checks.js +145 -0
  204. package/dist/tool/checks.js.map +1 -0
  205. package/dist/tool/elf.d.ts +19 -0
  206. package/dist/tool/elf.js +107 -0
  207. package/dist/tool/elf.js.map +1 -0
  208. package/dist/tool/predict.d.ts +8 -0
  209. package/dist/tool/predict.js +38 -0
  210. package/dist/tool/predict.js.map +1 -0
  211. package/dist/tool/ustar.d.ts +5 -0
  212. package/dist/tool/ustar.js +220 -0
  213. package/dist/tool/ustar.js.map +1 -0
  214. package/package.json +6 -5
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.js","sourceRoot":"","sources":["../../src/commands/agent.ts"],"names":[],"mappings":"AAAA,gHAAgH;AAChH,sHAAsH;AACtH,qEAAqE;AAErE,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AASvC,OAAO,EAAY,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAgB,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEzG,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAEhF,MAAM,WAAW,GAAG;;;;;;;;;;;;;;sBAcE,CAAC;AAEvB,kGAAkG;AAClG,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,EAAE,IAAI,EAAE,QAA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AAI,EAAE;KAC7C;CACF,CAAC"}
@@ -1,7 +1,4 @@
1
+ import { openable } from "../manifest/link.ts";
1
2
  import type { CliCommand } from "../registry.ts";
2
- /**
3
- * Whether `url` is what `b3os app open` may hand a browser: exactly `https://<label>.<app domain>/`, with at most a
4
- * `?b3os_link=` of a link token's shape (apps/edge/src/apphosts/link.ts LINK_TOKEN).
5
- */
6
- export declare function openable(url: string, label: string): boolean;
3
+ export { openable };
7
4
  export declare const commands: CliCommand[];
@@ -4,22 +4,26 @@
4
4
  // open and link use them, and down stops them before it retires anything.
5
5
  import { existsSync } from "node:fs";
6
6
  import { dirname, resolve } from "node:path";
7
- import { BLOCKED_WORDS, clockOf, deployAfter, listHosts, noHostsRoutes, ownAddress, parseRecreated, revCommit, routeHosts, StepError, serviceHealth, serviceProcess, sleep, validDepId, validDeployId, } from "@b3os/deploy";
8
- import { APP_DOMAIN, LABEL, ROUTE_SETTLE_MS, ROUTE_STALE_MAX_MS } from "@b3os/deploy/hosts";
7
+ import { appVolumes, BLOCKED_WORDS, clockOf, crashLoopWords, deployAfter, downWords, lastExitWords, listHosts, noHostsRoutes, ownAddress, parseRecreated, restartWords, revCommit, routeHosts, StepError, serviceHealth, serviceProcess, sleep, supervisedEntry, VOLUME_FREE_MS, validDepId, validDeployId, volumeFree, } from "@b3os/deploy";
8
+ import { APP_DOMAIN, ROUTE_SETTLE_MS, ROUTE_STALE_MAX_MS } from "@b3os/deploy/hosts";
9
9
  import { CliError, EXIT, intFlag, parse, splitSub, UsageError } from "../ctx.js";
10
10
  import { all, listTagged, planRollback, retire, TAG } from "../manifest/apply.js";
11
+ import { domains } from "../manifest/domains.js";
12
+ import { createLink, openable } from "../manifest/link.js";
11
13
  import { loadManifest, MANIFEST_FILE } from "../manifest/load.js";
12
14
  import * as git from "../manifest/source.js";
13
15
  import { openBrowser, WINDOWS_OPENER_NOTE } from "./auth.js";
14
16
  import { runPlanned } from "./manifest.js";
15
17
  import { sandboxRequests } from "./requests.js";
18
+ export { openable };
16
19
  const USAGE = `usage: b3os app <command>
17
20
  status [--file FILE | --app NAME] the application's addresses (https://<label>.b3os.io: state, the generation
18
21
  each serves, cookies this address did not set that were dropped), its service
19
22
  generations (last 7 days), build snapshots and routines with their last runs,
20
23
  found by their b3os.app tag; for each running generation its URL, its process,
21
24
  its last call to B3OS, when its lease ends, its logs command, and why a
22
- keepalive recreated it; for a service with none running, what starts it again
25
+ keepalive recreated it; for a service with none running, what starts it again;
26
+ its volumes (size, used, which generation holds each)
23
27
  logs [APP] [--service NAME] [--follow]
24
28
  a running service's output, each line with its time (UTC); --follow keeps
25
29
  reading until the process exits
@@ -36,10 +40,23 @@ const USAGE = `usage: b3os app <command>
36
40
  604800, 7 days; 60 to 7776000): anyone who has it gets in. --rotate first makes
37
41
  every link stop working within 6 s (streams and WebSockets already open can run
38
42
  up to an hour more), then makes the new link
39
- down --app NAME [--yes] stop its addresses (each label stays the application's), wait 7 s, then
43
+ domains [ls] | add HOSTNAME [--service NAME [--port N]] | verify HOSTNAME | rm HOSTNAME [--yes]
44
+ the application's custom domains (shop.example.com): add prints the DNS record
45
+ to add at your DNS host (a CNAME to the address, or at the root of a zone an
46
+ ALIAS and a TXT record); verify looks for it now (B3OS also looks every 5
47
+ minutes; a domain whose record is not seen within 72 hours is dropped); ls
48
+ prints each one's state; rm stops it serving at once. A domain whose record
49
+ stops naming the address stops serving too
50
+ A domain serves the application's own address, or that of service NAME (--port
51
+ N when it has more than one); the address keeps serving too. Not turned on
52
+ for customers yet: B3 runs custom domains on its own organization first
53
+ down --app NAME [--yes] [--delete-volumes NAME]
54
+ stop its addresses (each label stays the application's), wait 7 s, then
40
55
  delete: each running generation (TERM, up to 30 s to exit, then delete; one
41
56
  an address serves again by then is kept), then the routines, then the build
42
- snapshots
57
+ snapshots. Its volumes are kept, with their data, and listed; --delete-volumes
58
+ with the application's name typed again deletes them too (each is restorable
59
+ for 7 days: b3os sandbox volumes restore NAME)
43
60
  rollback [APP] [--to DEPLOY] [--yes] [--dry-run]
44
61
  deploy again the commit of the last deploy before the current one (the newest
45
62
  a running service generation or a routine names) that went live with another
@@ -59,6 +76,10 @@ const USAGE = `usage: b3os app <command>
59
76
  The application is the b3os.yaml \`name\` (default: read from ./${MANIFEST_FILE}). b3os apply --keepalive does not
60
77
  recreate a generation that was deleted (b3os app down), unless an address still serves it; b3os apply deploys it
61
78
  again.`;
79
+ /** A volume's used bytes: MiB, or GiB from 1 GiB. */
80
+ function mibOrGib(n) {
81
+ return n >= 1024 ** 3 ? `${(n / 1024 ** 3).toFixed(1)} GiB` : `${Math.round(n / 1024 ** 2)} MiB`;
82
+ }
62
83
  function appName(v, required) {
63
84
  if (typeof v.app === "string")
64
85
  return v.app;
@@ -85,6 +106,33 @@ function commandsOf(v, name) {
85
106
  }
86
107
  return out;
87
108
  }
109
+ /** How long `app logs --follow` waits for the node to start a supervised command again (the backoff's cap and more). */
110
+ const RESTART_WAIT_MS = 90_000;
111
+ /**
112
+ * The process the node started in place of `pid` (stay-up C1), waiting through its backoff: null when the sandbox
113
+ * ended, nothing supervises the command, or the supervision stopped, exited or is in a crash loop.
114
+ */
115
+ async function restartedFrom(b3, sandbox, cmd, pid, poll = 500) {
116
+ const until = Date.now() + RESTART_WAIT_MS;
117
+ for (;;) {
118
+ const s = await b3.sandboxes.getSandbox(sandbox).catch(() => null);
119
+ const sup = s?.status === "running" ? supervisedEntry(s.supervised, cmd) : null;
120
+ if (!sup || !["starting", "running", "backoff"].includes(sup.state))
121
+ return null;
122
+ if (sup.pid !== null && sup.pid !== pid && sup.state !== "backoff") {
123
+ const e = sup.last_exit;
124
+ const how = e?.signal
125
+ ? e.signal.replace(/^SIG/, "")
126
+ : e?.exit_code != null
127
+ ? `code ${e.exit_code}`
128
+ : "with no code";
129
+ return { pid: sup.pid, how };
130
+ }
131
+ if (Date.now() >= until)
132
+ return null;
133
+ await sleep(poll);
134
+ }
135
+ }
88
136
  /** A generation's processes (the service's is picked by @b3os/deploy serviceProcess: its command, else the oldest). */
89
137
  async function processesOf(b3, sandbox) {
90
138
  return (await b3.sandboxes.listProcesses(sandbox)).data;
@@ -304,6 +352,7 @@ const APP_OPTIONS = {
304
352
  ttl: { type: "string" },
305
353
  rotate: { type: "boolean" },
306
354
  port: { type: "string" },
355
+ "delete-volumes": { type: "string" },
307
356
  };
308
357
  async function app(ctx, argv) {
309
358
  const [sub, rest] = splitSub(argv);
@@ -342,6 +391,8 @@ async function app(ctx, argv) {
342
391
  }
343
392
  // The addresses (null: this API has none yet; a string: why they could not be read).
344
393
  const hosts = await listHosts(b3, name).catch(why);
394
+ // Its volumes (null: this node has none; a string: why they could not be read).
395
+ const vols = await appVolumes(b3, name).catch(why);
345
396
  // The application's own address first (the edge's `primary` when it sends it), then the rest as listed.
346
397
  const listed = Array.isArray(hosts) ? hosts : [];
347
398
  const own = ownAddress(listed);
@@ -358,7 +409,9 @@ async function app(ctx, argv) {
358
409
  port: h.port,
359
410
  access: h.access,
360
411
  cookies: h.cookies,
361
- state: h.state,
412
+ // `down` (B3-7023): routed to a sandbox the node said ended; since when and why beside it.
413
+ state: h.down ? "down" : h.state,
414
+ ...(h.down ? { down_since: h.down.since, down_reason: h.down.reason } : {}),
362
415
  /** The application's own address (the edge's `primary`; from an edge before it, `base_label` null). */
363
416
  primary: h === own,
364
417
  sandbox: h.sandbox_id,
@@ -372,7 +425,8 @@ async function app(ctx, argv) {
372
425
  .map((x) => {
373
426
  const service = (x.metadata?.[TAG.item] ?? "").slice(8);
374
427
  const list = procs.get(x.id);
375
- const health = serviceHealth(x.status, Array.isArray(list) ? list : null, commands.get(service));
428
+ // The node's supervisor, when it restarts the command in place (stay-up D7): restarting, crash loop.
429
+ const health = serviceHealth(x.status, Array.isArray(list) ? list : null, commands.get(service), x.supervised);
376
430
  const p = list === undefined ? undefined : typeof list === "string" ? list : health.process;
377
431
  const call = calls.get(x.id);
378
432
  return {
@@ -380,9 +434,16 @@ async function app(ctx, argv) {
380
434
  sandbox: x.id,
381
435
  /** The sandbox's status. */
382
436
  status: x.status,
383
- /** The service's: the sandbox's, or `down` when it runs and the service's process exited. */
437
+ /**
438
+ * The service's: the sandbox's; `down` when it runs and the service's process exited with nothing
439
+ * restarting it; `restarting` or `crash loop` while the node restarts it in place.
440
+ */
384
441
  state: health.state,
385
442
  ...(health.exit ? { exit: health.exit } : {}),
443
+ /** The node's supervision of the service's command (null: none, or a node from before). */
444
+ supervisor: health.supervisor ?? null,
445
+ /** The sandbox's node lease (null: none, or a node from before leases). */
446
+ lease: x.lease ?? null,
386
447
  stop_reason: x.stop_reason,
387
448
  rev: x.metadata?.[TAG.rev] ?? null,
388
449
  deploy: x.metadata?.[TAG.deploy] ?? null,
@@ -435,6 +496,24 @@ async function app(ctx, argv) {
435
496
  })),
436
497
  /** Each service with no running generation, and what starts it again (DEFECTS 41). */
437
498
  not_running: notRunning(sandboxes, listed),
499
+ /** Its volumes: kept across deploys, rollbacks and b3os app down (null: this node has none). */
500
+ volumes: Array.isArray(vols)
501
+ ? vols.map((v) => {
502
+ const holder = v.attached_to ? sandboxes.find((x) => x.id === v.attached_to?.sandbox_id) : undefined;
503
+ return {
504
+ volume: v.name,
505
+ id: v.id,
506
+ size_gib: v.size_gib,
507
+ used_bytes: v.used_bytes,
508
+ status: v.status,
509
+ sandbox: v.attached_to?.sandbox_id ?? null,
510
+ service: holder ? (holder.metadata?.[TAG.item] ?? "").replace(/^service\//, "") || null : null,
511
+ /** The last stop-first deploy's gap, from the release of the old generation to the switch. */
512
+ gap_ms: Number(v.metadata?.["b3os.gap_ms"]) || null,
513
+ };
514
+ })
515
+ : null,
516
+ ...(typeof vols === "string" ? { volumes_error: vols } : {}),
438
517
  routines: routines.map((r) => ({
439
518
  routine: r.name,
440
519
  id: r.id,
@@ -453,12 +532,15 @@ async function app(ctx, argv) {
453
532
  ctx.out(` not read: ${hosts}`);
454
533
  for (const h of doc.addresses) {
455
534
  ctx.out(` ${h.url} ${h.state}${h.sandbox ? ` ${h.sandbox}` : ""} (${h.service} port ${h.port}, access ${h.access}, cookies ${h.cookies.mode})`);
456
- if (h.state === "serving" && h.sandbox && h.sandbox_status !== "running")
535
+ const down = rows.find((r) => r.label === h.label)?.down;
536
+ if (down)
537
+ ctx.out(` ${downWords(down)}`);
538
+ else if (h.state === "serving" && h.sandbox && h.sandbox_status !== "running")
457
539
  ctx.out(` serving ${h.sandbox}, which is ${h.sandbox_status}: the address answers 503; b3os apply or b3os apply --keepalive recreates it`);
458
540
  if (h.state === "claimed")
459
541
  ctx.out(" claimed: the next b3os apply switches it to the service's generation");
460
542
  if (h.state === "stopped")
461
- ctx.out(` stopped: the address answers 503; the next b3os apply switches it to the service's generation if b3os.yaml still gives port ${h.port} an address (access, or public: true)`);
543
+ ctx.out(` stopped: the address answers 503; the next b3os apply switches it to the service's generation if b3os.yaml still gives port ${h.port} an address (access, public: true, or the default one)`);
462
544
  if (h.state === "blocked")
463
545
  ctx.out(` ${BLOCKED_WORDS}`);
464
546
  // Cookies the app's server never got (cookies: isolated), by name, never a value: the edge counts every
@@ -468,8 +550,16 @@ async function app(ctx, argv) {
468
550
  }
469
551
  }
470
552
  ctx.out("services (newest generation first, last 7 days)");
471
- // STATUS is the service's: `down (exited TERM)` when the sandbox runs and its process does not.
472
- ctx.table(doc.services.map((x) => ({ ...x, status: x.exit ? `down (exited ${x.exit.how})` : x.status })), ["service", "sandbox", "status", "stop_reason", "rev", "deploy", "expires_at"]);
553
+ // STATUS is the service's: `down (exited TERM)` when the sandbox runs and its process does not, `restarting` or
554
+ // `crash loop` while the node restarts it in place.
555
+ ctx.table(doc.services.map((x) => ({
556
+ ...x,
557
+ status: x.state === "down" && x.exit
558
+ ? `down (exited ${x.exit.how})`
559
+ : x.state === "restarting" || x.state === "crash loop"
560
+ ? x.state
561
+ : x.status,
562
+ })), ["service", "sandbox", "status", "stop_reason", "rev", "deploy", "expires_at"]);
473
563
  for (const n of doc.not_running)
474
564
  ctx.out(`${n.service}: ${n.line}`);
475
565
  for (const x of doc.services) {
@@ -479,11 +569,18 @@ async function app(ctx, argv) {
479
569
  if (x.recreated)
480
570
  ctx.out(` recreated ${RECREATED_WHY[x.recreated.cause]} ${ago(x.created_at)}: ${x.recreated.reason}${x.recreated.by ? ` (keepalive ${x.recreated.by})` : ""}`);
481
571
  for (const h of doc.addresses)
482
- if (h.state === "serving" && h.sandbox === x.sandbox)
572
+ if ((h.state === "serving" || h.state === "down") && h.sandbox === x.sandbox)
483
573
  ctx.out(` address ${h.url}`);
484
574
  for (const u of x.urls)
485
575
  ctx.out(` public URL ${u}`);
486
- if ("process" in x)
576
+ const sup = x.supervisor;
577
+ if (sup && x.state === "crash loop")
578
+ ctx.out(` process ${crashLoopWords(sup)}; see b3os app logs ${name} --service ${x.service}`);
579
+ else if (sup && x.state === "restarting")
580
+ ctx.out(` process restarting in place (restart ${sup.state === "backoff" ? sup.restarts + 1 : sup.restarts})${sup.last_exit ? `; last: ${lastExitWords(sup.last_exit)}` : ""}${sup.next_start_at ? `; next start ${clockOf(sup.next_start_at)}` : ""}`);
581
+ else if (sup && x.state === "running" && sup.pid !== null)
582
+ ctx.out(` process ${sup.pid} running${sup.started_at ? ` since ${clockOf(sup.started_at)}` : ""}${restartWords(sup) ? `; ${restartWords(sup)}` : ""}`);
583
+ else if ("process" in x)
487
584
  ctx.out(` process ${x.exit && x.process
488
585
  ? `${x.exit.pid} exited (${x.exit.how})${x.exit.at ? ` at ${x.exit.at} (${ago(x.exit.at)})` : ""}: ${x.process.cmd}`
489
586
  : x.process
@@ -491,7 +588,7 @@ async function app(ctx, argv) {
491
588
  : x.process_error
492
589
  ? `not read: ${x.process_error}`
493
590
  : "none started"}`);
494
- if (x.exit)
591
+ if (x.state === "down")
495
592
  ctx.out(` down nothing serves${x.urls.length ? " (its URL answers 502)" : ""}; the next b3os apply or b3os apply --keepalive recreates it`);
496
593
  if ("last_call" in x)
497
594
  ctx.out(` last call ${x.last_call
@@ -499,13 +596,27 @@ async function app(ctx, argv) {
499
596
  : x.last_call_error
500
597
  ? `not read: ${x.last_call_error}`
501
598
  : "none in the last 7 days"}`);
502
- if (x.expires_at)
599
+ if (x.lease?.state === "held")
600
+ ctx.out(` lease kept up by B3OS since ${clockOf(x.lease.since)}${x.lease.renewed_at ? ` (renewed ${clockOf(x.lease.renewed_at)})` : ""}; ends on b3os app down, a newer deploy, or the organization's limits`);
601
+ else if (x.expires_at)
503
602
  ctx.out(` lease ends ${x.expires_at} (${fromNow(x.expires_at)}); b3os apply --keepalive renews it, and so does each deploy`);
504
603
  if ("logs_command" in x)
505
604
  ctx.out(` logs ${x.logs_command}`);
506
605
  if ("requests_command" in x)
507
606
  ctx.out(` requests ${x.requests_command}`);
508
607
  }
608
+ if (doc.volumes?.length || typeof vols === "string") {
609
+ ctx.out("volumes (kept across deploys, rollbacks and b3os app down)");
610
+ if (typeof vols === "string")
611
+ ctx.out(` not read: ${vols}`);
612
+ ctx.table((doc.volumes ?? []).map((v) => ({
613
+ ...v,
614
+ size: `${v.size_gib} GiB`,
615
+ used: v.used_bytes === null ? "-" : mibOrGib(v.used_bytes),
616
+ holder: v.sandbox ? `${v.sandbox}${v.service ? ` (${v.service})` : ""}` : "-",
617
+ last_gap: v.gap_ms === null ? "-" : `${(v.gap_ms / 1000).toFixed(1)} s`,
618
+ })), ["volume", "id", "size", "used", "status", "holder", "last_gap"]);
619
+ }
509
620
  ctx.out("builds");
510
621
  ctx.table(doc.builds, ["service", "snapshot", "key", "status", "created_at"]);
511
622
  ctx.out("routines");
@@ -522,8 +633,7 @@ async function app(ctx, argv) {
522
633
  const rows = await listHosts(b3, name).catch(() => null);
523
634
  const wanted = typeof a.values.service === "string" ? a.values.service : undefined;
524
635
  const lines = notRunning(all, rows ?? []).filter((n) => !wanted || n.service === wanted);
525
- ctx.warn(`${name} has no running generation${lines.length ? `: ${lines.map((n) => (lines.length > 1 ? `${n.service}: ${n.line}` : n.line)).join("; ")}` : ": b3os app status lists its generations"}`);
526
- return EXIT.NOT_FOUND;
636
+ throw new CliError(`${name} has no running generation${lines.length ? `: ${lines.map((n) => (lines.length > 1 ? `${n.service}: ${n.line}` : n.line)).join("; ")}` : ": b3os app status lists its generations"}`, { code: "no_running_generation", exit: EXIT.NOT_FOUND });
527
637
  }
528
638
  const names = [...running.keys()];
529
639
  const svc = typeof a.values.service === "string" ? a.values.service : names.length === 1 ? names[0] : undefined;
@@ -532,23 +642,45 @@ async function app(ctx, argv) {
532
642
  const gen = running.get(svc);
533
643
  if (!gen)
534
644
  throw new UsageError(`${name} has no running generation of ${svc} (running: ${names.join(", ")})`);
535
- const p = serviceProcess(await processesOf(b3, gen.id), commandsOf(a.values, name).get(svc));
645
+ const cmd = commandsOf(a.values, name).get(svc);
646
+ const p = serviceProcess(await processesOf(b3, gen.id), cmd, supervisedEntry(gen.supervised, cmd));
536
647
  if (!p) {
537
- ctx.warn(`${svc} (${gen.id}) has no process: apply starts the service's command as a background process`);
538
- return EXIT.NOT_FOUND;
648
+ throw new CliError(`${svc} (${gen.id}) has no process: apply starts the service's command as a background process`, { code: "service_process_not_found", exit: EXIT.NOT_FOUND });
539
649
  }
540
650
  ctx.info(`${svc}: ${gen.id}, process ${p.pid} (${p.status}): ${p.cmd}`);
541
651
  const out = stamped((t) => ctx.io.stdout.write(t));
542
652
  const err = stamped((t) => ctx.io.stderr.write(t));
543
- for await (const ev of b3.sandboxes.streamLogs(gen.id, { pid: p.pid, follow: a.values.follow === true })) {
544
- if (ctx.json)
545
- ctx.printJsonLine(ev);
546
- else if (ev.type === "log.stdout")
547
- out(ev);
548
- else if (ev.type === "log.stderr")
549
- err(ev);
550
- else if (ev.type === "process.exited")
551
- ctx.info(`[process ${ev.pid} exited ${ev.exit_code ?? "by a signal"}]`);
653
+ const follow = a.values.follow === true;
654
+ let pid = p.pid;
655
+ for (;;) {
656
+ let exited = null;
657
+ for await (const ev of b3.sandboxes.streamLogs(gen.id, { pid, follow })) {
658
+ if (ctx.json)
659
+ ctx.printJsonLine(ev);
660
+ else if (ev.type === "log.stdout")
661
+ out(ev);
662
+ else if (ev.type === "log.stderr")
663
+ err(ev);
664
+ if (ev.type === "process.exited") {
665
+ exited = { pid: ev.pid ?? pid, exit_code: ev.exit_code ?? null };
666
+ // Followed: the stream is left for the next process the node starts (stay-up C1).
667
+ if (follow)
668
+ break;
669
+ if (!ctx.json)
670
+ ctx.info(`[process ${ev.pid} exited ${ev.exit_code ?? "by a signal"}]`);
671
+ }
672
+ }
673
+ if (!follow || !exited)
674
+ break;
675
+ const next = await restartedFrom(b3, gen.id, cmd, exited.pid);
676
+ if (!next) {
677
+ if (!ctx.json)
678
+ ctx.info(`[process ${exited.pid} exited ${exited.exit_code ?? "by a signal"}]`);
679
+ break;
680
+ }
681
+ if (!ctx.json)
682
+ ctx.info(`[process ${exited.pid} exited (${next.how}); B3OS started ${next.pid}]`);
683
+ pid = next.pid;
552
684
  }
553
685
  return EXIT.OK;
554
686
  }
@@ -559,8 +691,10 @@ async function app(ctx, argv) {
559
691
  throw new UsageError("--limit is 1 to 100");
560
692
  const gens = generationByService(await listTagged(b3, { [TAG.app]: name }));
561
693
  if (!gens.size) {
562
- ctx.warn(`${name} has no service generation in the last 7 days: b3os app status lists what it has`);
563
- return EXIT.NOT_FOUND;
694
+ throw new CliError(`${name} has no service generation in the last 7 days: b3os app status lists what it has`, {
695
+ code: "app_not_found",
696
+ exit: EXIT.NOT_FOUND,
697
+ });
564
698
  }
565
699
  const wanted = typeof a.values.service === "string" ? a.values.service : undefined;
566
700
  if (wanted && !gens.has(wanted))
@@ -584,6 +718,14 @@ async function app(ctx, argv) {
584
718
  }
585
719
  case "down": {
586
720
  const name = appName(a.values, true);
721
+ // Volumes outlive a take down (rulings 4); deleting them asks for the application's name a second time.
722
+ const delVols = a.values["delete-volumes"];
723
+ if (delVols !== undefined && delVols !== name)
724
+ throw new UsageError(`--delete-volumes takes the application's name typed again (${name}), so a volume is never deleted by a slip; got "${String(delVols)}"`);
725
+ const listed = await appVolumes(b3, name);
726
+ if (delVols !== undefined && !listed)
727
+ throw new UsageError("--delete-volumes: this node has no volumes (a node before release 1118)");
728
+ const vols = listed ?? [];
587
729
  const live = (await listTagged(b3, { [TAG.app]: name })).filter((x) => x.status === "running" || x.status === "paused");
588
730
  const routines = (await all(b3.routines.listRoutines({ limit: 100 }))).filter((r) => r.metadata?.[TAG.app] === name);
589
731
  const snapshots = (await all(b3.sandboxes.listSnapshots({ limit: 100 }), 200)).filter((x) => x.metadata?.[TAG.app] === name);
@@ -591,8 +733,10 @@ async function app(ctx, argv) {
591
733
  const hosts = await listHosts(b3, name);
592
734
  const serving = (hosts ?? []).filter((h) => h.state === "serving" && h.sandbox_id);
593
735
  const n = live.length + routines.length + snapshots.length;
594
- if (!n && !serving.length) {
736
+ if (!n && !serving.length && !(delVols !== undefined && vols.length)) {
595
737
  ctx.info(`nothing tagged b3os.app ${name} in this project`);
738
+ for (const v of vols)
739
+ ctx.info(`volume ${v.id} ${v.name}: kept, with its data`);
596
740
  return EXIT.OK;
597
741
  }
598
742
  for (const h of serving)
@@ -603,9 +747,16 @@ async function app(ctx, argv) {
603
747
  ctx.info(`routine ${r.id} ${r.name}`);
604
748
  for (const x of snapshots)
605
749
  ctx.info(`snapshot ${x.id} ${x.metadata?.[TAG.item] ?? ""}`);
750
+ for (const v of vols)
751
+ ctx.info(delVols !== undefined
752
+ ? `volume ${v.id} ${v.name}: deleted too (--delete-volumes), restorable for 7 days`
753
+ : `volume ${v.id} ${v.name}: kept, with its data (--delete-volumes ${name} deletes it)`);
754
+ const also = delVols !== undefined && vols.length
755
+ ? ` and ${vols.length === 1 ? "its volume" : `its ${vols.length} volumes`}`
756
+ : "";
606
757
  const what = serving.length
607
- ? `Stop ${serving.length === 1 ? "this address" : `these ${serving.length} addresses`} and delete these ${n} objects of ${name}?`
608
- : `Delete these ${n} objects of ${name}?`;
758
+ ? `Stop ${serving.length === 1 ? "this address" : `these ${serving.length} addresses`} and delete these ${n} objects of ${name}${also}?`
759
+ : `Delete these ${n} objects of ${name}${also}?`;
609
760
  if (!(await ctx.confirm(what))) {
610
761
  ctx.warn("Nothing was deleted.");
611
762
  return EXIT.OK;
@@ -670,6 +821,24 @@ async function app(ctx, argv) {
670
821
  done.push({ kind: "snapshot", id: x.id, how: "deleted" });
671
822
  ctx.info(`deleted snapshot ${x.id}`);
672
823
  }
824
+ // Volumes: kept, unless --delete-volumes named the application again; then each is deleted (restorable for 7
825
+ // days) once no sandbox holds it, which is a moment after its generation was deleted (its microVM exits first).
826
+ const keptVolumes = [];
827
+ for (const v of vols) {
828
+ if (delVols === undefined) {
829
+ keptVolumes.push({ id: v.id, name: v.name, size_gib: v.size_gib });
830
+ continue;
831
+ }
832
+ if (!(await volumeFree(b3, v.id, VOLUME_FREE_MS))) {
833
+ const why = `kept volume ${v.id} (${v.name}): a sandbox still holds it ${VOLUME_FREE_MS / 1000} s on`;
834
+ keptVolumes.push({ id: v.id, name: v.name, size_gib: v.size_gib, why });
835
+ ctx.warn(why);
836
+ continue;
837
+ }
838
+ const d = await b3.sandboxes.deleteVolume(v.id);
839
+ done.push({ kind: "volume", id: v.id, how: `deleted, restorable until ${d.purge_at ?? "its purge"}` });
840
+ ctx.info(`deleted volume ${v.id} (${v.name}): restorable until ${d.purge_at ?? "its purge"} with b3os sandbox volumes restore ${v.name}`);
841
+ }
673
842
  const stopped = done.filter((d) => d.kind === "address").length;
674
843
  ctx.result({
675
844
  object: "app_down",
@@ -677,22 +846,24 @@ async function app(ctx, argv) {
677
846
  deleted: done.filter((d) => d.kind !== "address"),
678
847
  stopped: done.filter((d) => d.kind === "address"),
679
848
  kept,
680
- }, () => ctx.out(`${name}: ${stopped ? `stopped ${stopped} ${stopped === 1 ? "address" : "addresses"}, ` : ""}deleted ${done.length - stopped} objects${kept.length ? `; ${kept.map((k) => k.why).join("; ")}` : ""}`));
849
+ volumes_kept: keptVolumes,
850
+ }, () => ctx.out(`${name}: ${stopped ? `stopped ${stopped} ${stopped === 1 ? "address" : "addresses"}, ` : ""}deleted ${done.length - stopped} objects${kept.length ? `; ${kept.map((k) => k.why).join("; ")}` : ""}${keptVolumes.length ? `; kept ${keptVolumes.length === 1 ? "volume" : "volumes"} ${keptVolumes.map((v) => v.name).join(", ")} with ${keptVolumes.length === 1 ? "its" : "their"} data` : ""}`));
681
851
  return EXIT.OK;
682
852
  }
683
853
  case "open": {
684
854
  const name = a.positionals[0] ?? appName(a.values, false);
685
855
  const hosts = await listHosts(b3, name);
686
856
  if (hosts === null) {
687
- ctx.warn(`this API has no app addresses yet: b3os app status prints each running generation's URL`);
688
- return EXIT.NOT_FOUND;
857
+ throw new CliError(`this API has no app addresses yet: b3os app status prints each running generation's URL`, {
858
+ code: "app_addresses_unavailable",
859
+ exit: EXIT.NOT_FOUND,
860
+ });
689
861
  }
690
862
  const svc = typeof a.values.service === "string" ? a.values.service : undefined;
691
863
  const mine = hosts.filter((h) => !svc || h.service === svc);
692
864
  const row = ownAddress(mine) ?? mine[0];
693
865
  if (!row) {
694
- ctx.warn(`${name} has no address${svc ? ` for service ${svc}` : ""}: b3os apply claims one for a port with access (or public: true)`);
695
- return EXIT.NOT_FOUND;
866
+ throw new CliError(`${name} has no address${svc ? ` for service ${svc}` : ""}: b3os apply claims one for a port with access (or public: true)`, { code: "app_host_not_found", exit: EXIT.NOT_FOUND });
696
867
  }
697
868
  // What a visitor gets there now, by the state's own page (review 3, tm17; decision 9).
698
869
  if (row.state !== "serving")
@@ -741,8 +912,10 @@ async function app(ctx, argv) {
741
912
  }
742
913
  const label = await linkLabel(b3, name, a.values);
743
914
  if (label === null) {
744
- ctx.warn("this API has no app addresses yet, so there is no link to make");
745
- return EXIT.NOT_FOUND;
915
+ throw new CliError("this API has no app addresses yet, so there is no link to make", {
916
+ code: "app_addresses_unavailable",
917
+ exit: EXIT.NOT_FOUND,
918
+ });
746
919
  }
747
920
  let link;
748
921
  try {
@@ -755,8 +928,10 @@ async function app(ctx, argv) {
755
928
  catch (e) {
756
929
  if (!noHostsRoutes(e))
757
930
  throw e;
758
- ctx.warn("this API has no app addresses yet, so there is no link to make");
759
- return EXIT.NOT_FOUND;
931
+ throw new CliError("this API has no app addresses yet, so there is no link to make", {
932
+ code: "app_addresses_unavailable",
933
+ exit: EXIT.NOT_FOUND,
934
+ });
760
935
  }
761
936
  ctx.result(rotate ? { ...link, warning: rotation } : link, () => {
762
937
  ctx.out(link.url);
@@ -764,6 +939,10 @@ async function app(ctx, argv) {
764
939
  });
765
940
  return EXIT.OK;
766
941
  }
942
+ case "domains": {
943
+ const name = appName(a.values, false);
944
+ return domains(ctx, b3, name, a.positionals, () => linkLabel(b3, name, a.values));
945
+ }
767
946
  case "rollback": {
768
947
  const name = a.positionals[0] ?? appName(a.values, false);
769
948
  const to = typeof a.values.to === "string" ? a.values.to : undefined;
@@ -777,8 +956,10 @@ async function app(ctx, argv) {
777
956
  const manifestInRepo = git.inRepo(root, file);
778
957
  const history = pastDeploys(await listTagged(b3, { [TAG.app]: name }));
779
958
  if (!history.length) {
780
- ctx.warn(`${name} has no service generation in the last 7 days: nothing to roll back to`);
781
- return EXIT.NOT_FOUND;
959
+ throw new CliError(`${name} has no service generation in the last 7 days: nothing to roll back to`, {
960
+ code: "nothing_to_roll_back",
961
+ exit: EXIT.NOT_FOUND,
962
+ });
782
963
  }
783
964
  const routines = (await all(b3.routines.listRoutines({ limit: 100 }))).filter((r) => r.metadata?.[TAG.app] === name);
784
965
  const current = currentDeploy(history, routines);
@@ -809,8 +990,7 @@ async function app(ctx, argv) {
809
990
  if (!target) {
810
991
  if (to)
811
992
  throw new UsageError(`${to} is not a deploy of ${name} that went live in the last 7 days: ${listed}`);
812
- ctx.warn(`nothing to roll back to: no deploy of ${name} before ${current?.deploy} in the last 7 days went live with another commit${listed ? ` (${listed})` : ""}`);
813
- return EXIT.NOT_FOUND;
993
+ throw new CliError(`nothing to roll back to: no deploy of ${name} before ${current?.deploy} in the last 7 days went live with another commit${listed ? ` (${listed})` : ""}`, { code: "nothing_to_roll_back", exit: EXIT.NOT_FOUND });
814
994
  }
815
995
  const commit = git.resolveCommit(root, target.commit);
816
996
  if (!commit)
@@ -865,16 +1045,6 @@ async function app(ctx, argv) {
865
1045
  throw new UsageError(`unknown app command "${sub}"\n${USAGE}`);
866
1046
  }
867
1047
  }
868
- /**
869
- * Whether `url` is what `b3os app open` may hand a browser: exactly `https://<label>.<app domain>/`, with at most a
870
- * `?b3os_link=` of a link token's shape (apps/edge/src/apphosts/link.ts LINK_TOKEN).
871
- */
872
- export function openable(url, label) {
873
- if (!LABEL.test(label))
874
- return false;
875
- const host = `${label}.${APP_DOMAIN}`.replace(/[.]/g, "\\.");
876
- return new RegExp(`^https://${host}/(\\?b3os_link=(0|[1-9][0-9]{0,11})\\.[A-Za-z0-9_-]{43})?$`).test(url);
877
- }
878
1048
  /**
879
1049
  * The label `b3os app link` asks for: undefined for the application's own (the edge picks it), the address of
880
1050
  * `--service` (and `--port`), or null when the API has no addresses.
@@ -900,20 +1070,10 @@ async function linkLabel(b3, app, v) {
900
1070
  return own.label;
901
1071
  throw new UsageError(`${what} has ${mine.length} addresses (ports ${mine.map((h) => h.port).join(", ")}): pass --port`);
902
1072
  }
903
- /** `POST /v1/apps/{app}/hosts/link`: a link to one of the application's link addresses (its own by default). */
904
- function createLink(b3, app, body) {
905
- return b3.request({
906
- method: "POST",
907
- path: `/v1/apps/${encodeURIComponent(app)}/hosts/link`,
908
- body,
909
- edge: true,
910
- timeoutMs: 15_000,
911
- });
912
- }
913
1073
  export const commands = [
914
1074
  {
915
1075
  name: "app",
916
- summary: "Status, address, logs and rollback of an app (status, open, link, logs, requests, rollback, down)",
1076
+ summary: "An app's status, address and rollback (status, open, link, domains, logs, requests, rollback, down)",
917
1077
  order: 245,
918
1078
  run: app,
919
1079
  options: APP_OPTIONS,