@sixb/cli 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +275 -0
  3. package/dist/commands/access-token-utils.d.ts +9 -0
  4. package/dist/commands/access-token-utils.d.ts.map +1 -0
  5. package/dist/commands/api.d.ts +13 -0
  6. package/dist/commands/api.d.ts.map +1 -0
  7. package/dist/commands/app.d.ts +9 -0
  8. package/dist/commands/app.d.ts.map +1 -0
  9. package/dist/commands/atlas.d.ts +9 -0
  10. package/dist/commands/atlas.d.ts.map +1 -0
  11. package/dist/commands/auth.d.ts +8 -0
  12. package/dist/commands/auth.d.ts.map +1 -0
  13. package/dist/commands/build.d.ts +6 -0
  14. package/dist/commands/build.d.ts.map +1 -0
  15. package/dist/commands/check.d.ts +5 -0
  16. package/dist/commands/check.d.ts.map +1 -0
  17. package/dist/commands/db-migrate.d.ts +5 -0
  18. package/dist/commands/db-migrate.d.ts.map +1 -0
  19. package/dist/commands/dev.d.ts +12 -0
  20. package/dist/commands/dev.d.ts.map +1 -0
  21. package/dist/commands/init.d.ts +3 -0
  22. package/dist/commands/init.d.ts.map +1 -0
  23. package/dist/commands/lake-check.d.ts +5 -0
  24. package/dist/commands/lake-check.d.ts.map +1 -0
  25. package/dist/commands/lake-cleanup.d.ts +16 -0
  26. package/dist/commands/lake-cleanup.d.ts.map +1 -0
  27. package/dist/commands/orchestrator.d.ts +6 -0
  28. package/dist/commands/orchestrator.d.ts.map +1 -0
  29. package/dist/commands/rules.d.ts +6 -0
  30. package/dist/commands/rules.d.ts.map +1 -0
  31. package/dist/commands/scheduler.d.ts +6 -0
  32. package/dist/commands/scheduler.d.ts.map +1 -0
  33. package/dist/commands/service-account.d.ts +14 -0
  34. package/dist/commands/service-account.d.ts.map +1 -0
  35. package/dist/commands/token.d.ts +14 -0
  36. package/dist/commands/token.d.ts.map +1 -0
  37. package/dist/commands/typegen.d.ts +5 -0
  38. package/dist/commands/typegen.d.ts.map +1 -0
  39. package/dist/commands/worker-group.d.ts +8 -0
  40. package/dist/commands/worker-group.d.ts.map +1 -0
  41. package/dist/commands/worker.d.ts +8 -0
  42. package/dist/commands/worker.d.ts.map +1 -0
  43. package/dist/index.d.ts +3 -0
  44. package/dist/index.d.ts.map +1 -0
  45. package/dist/lib/api-client.d.ts +26 -0
  46. package/dist/lib/api-client.d.ts.map +1 -0
  47. package/dist/lib/browser-topology.d.ts +62 -0
  48. package/dist/lib/browser-topology.d.ts.map +1 -0
  49. package/dist/lib/errors.d.ts +19 -0
  50. package/dist/lib/errors.d.ts.map +1 -0
  51. package/dist/lib/health.d.ts +25 -0
  52. package/dist/lib/health.d.ts.map +1 -0
  53. package/dist/lib/loadSixb.d.ts +49 -0
  54. package/dist/lib/loadSixb.d.ts.map +1 -0
  55. package/dist/lib/production-roles.d.ts +65 -0
  56. package/dist/lib/production-roles.d.ts.map +1 -0
  57. package/dist/lib/production.d.ts +29 -0
  58. package/dist/lib/production.d.ts.map +1 -0
  59. package/dist/lib/public-origin.d.ts +17 -0
  60. package/dist/lib/public-origin.d.ts.map +1 -0
  61. package/dist/lib/runtime.d.ts +76 -0
  62. package/dist/lib/runtime.d.ts.map +1 -0
  63. package/dist/lib/shareable-providers.d.ts +20 -0
  64. package/dist/lib/shareable-providers.d.ts.map +1 -0
  65. package/dist/lib/storage-migration.d.ts +40 -0
  66. package/dist/lib/storage-migration.d.ts.map +1 -0
  67. package/dist/lib/typegen.d.ts +5 -0
  68. package/dist/lib/typegen.d.ts.map +1 -0
  69. package/dist/lib/worker-registry.d.ts +30 -0
  70. package/dist/lib/worker-registry.d.ts.map +1 -0
  71. package/dist/tsconfig.json +5 -0
  72. package/dist/ui/index.d.ts +164 -0
  73. package/dist/ui/index.d.ts.map +1 -0
  74. package/package.json +68 -0
  75. package/src/commands/access-token-utils.ts +63 -0
  76. package/src/commands/api.tsx +111 -0
  77. package/src/commands/app.tsx +91 -0
  78. package/src/commands/atlas.tsx +75 -0
  79. package/src/commands/auth.tsx +96 -0
  80. package/src/commands/build.tsx +90 -0
  81. package/src/commands/check.tsx +58 -0
  82. package/src/commands/db-migrate.tsx +27 -0
  83. package/src/commands/dev.tsx +141 -0
  84. package/src/commands/init.tsx +18 -0
  85. package/src/commands/lake-check.tsx +20 -0
  86. package/src/commands/lake-cleanup.tsx +63 -0
  87. package/src/commands/orchestrator.tsx +87 -0
  88. package/src/commands/rules.tsx +81 -0
  89. package/src/commands/scheduler.tsx +77 -0
  90. package/src/commands/service-account.tsx +304 -0
  91. package/src/commands/token.tsx +143 -0
  92. package/src/commands/typegen.tsx +18 -0
  93. package/src/commands/worker-group.tsx +120 -0
  94. package/src/commands/worker.tsx +96 -0
  95. package/src/index.tsx +390 -0
  96. package/src/lib/api-client.ts +132 -0
  97. package/src/lib/browser-topology.ts +292 -0
  98. package/src/lib/errors.ts +40 -0
  99. package/src/lib/health.ts +138 -0
  100. package/src/lib/loadSixb.ts +175 -0
  101. package/src/lib/production-roles.ts +48 -0
  102. package/src/lib/production.ts +104 -0
  103. package/src/lib/public-origin.ts +46 -0
  104. package/src/lib/runtime.ts +346 -0
  105. package/src/lib/shareable-providers.ts +67 -0
  106. package/src/lib/storage-migration.ts +120 -0
  107. package/src/lib/typegen.ts +12 -0
  108. package/src/lib/worker-registry.ts +191 -0
  109. package/src/ui/index.tsx +953 -0
package/src/index.tsx ADDED
@@ -0,0 +1,390 @@
1
+ #!/usr/bin/env bun
2
+
3
+ import { join } from "node:path"
4
+ import { HelpView, renderCliError, renderStatic, VersionView } from "./ui"
5
+
6
+ const args = process.argv.slice(2)
7
+
8
+ /**
9
+ * Lowest Bun we test against, kept in step with `engines.bun` in every published manifest.
10
+ * `bun install` only warns about `engines`, so without this check an older Bun fails later on
11
+ * whichever API it happens to be missing, far from the cause.
12
+ */
13
+ const MINIMUM_BUN_VERSION = "1.3.0"
14
+
15
+ assertSupportedBunVersion()
16
+
17
+ const VERSION = `sixb v${await readPackageVersion()}`
18
+
19
+ function assertSupportedBunVersion(): void {
20
+ const current = typeof Bun === "undefined" ? undefined : Bun.version
21
+ if (!current) {
22
+ console.error("[Sixb] The sixb CLI requires Bun. See https://bun.sh to install it.")
23
+ process.exit(1)
24
+ }
25
+
26
+ if (compareVersions(current, MINIMUM_BUN_VERSION) >= 0) return
27
+
28
+ console.error(
29
+ `[Sixb] Bun ${MINIMUM_BUN_VERSION} or newer is required; this is Bun ${current}. ` +
30
+ "Run `bun upgrade` and try again."
31
+ )
32
+ process.exit(1)
33
+ }
34
+
35
+ /** Numeric compare of the leading `major.minor.patch`, ignoring any prerelease suffix. */
36
+ function compareVersions(left: string, right: string): number {
37
+ const parse = (value: string) =>
38
+ (value.split("-")[0] ?? "").split(".").map((part) => Number.parseInt(part, 10) || 0)
39
+ const a = parse(left)
40
+ const b = parse(right)
41
+
42
+ for (let index = 0; index < 3; index++) {
43
+ const difference = (a[index] ?? 0) - (b[index] ?? 0)
44
+ if (difference !== 0) return difference
45
+ }
46
+ return 0
47
+ }
48
+
49
+ async function readPackageVersion(): Promise<string> {
50
+ const fallbackVersion = "0.0.1"
51
+
52
+ try {
53
+ const packageJson = (await Bun.file(join(import.meta.dir, "..", "package.json")).json()) as {
54
+ version?: unknown
55
+ }
56
+ return typeof packageJson.version === "string" ? packageJson.version : fallbackVersion
57
+ } catch {
58
+ return fallbackVersion
59
+ }
60
+ }
61
+
62
+ function getFlag(name: string): string | undefined {
63
+ const direct = args.find((arg) => arg.startsWith(`--${name}=`))
64
+ if (direct) return direct.split("=")[1]
65
+
66
+ const idx = args.indexOf(`--${name}`)
67
+ if (idx >= 0) return args[idx + 1]
68
+
69
+ return undefined
70
+ }
71
+
72
+ function getFlags(name: string): string[] {
73
+ const values: string[] = []
74
+
75
+ for (let index = 0; index < args.length; index++) {
76
+ const arg = args[index]
77
+ if (arg === `--${name}`) {
78
+ const value = args[index + 1]
79
+ if (value && !value.startsWith("--")) {
80
+ values.push(value)
81
+ index++
82
+ }
83
+ } else if (arg?.startsWith(`--${name}=`)) {
84
+ values.push(arg.slice(name.length + 3))
85
+ }
86
+ }
87
+
88
+ return values
89
+ }
90
+
91
+ function hasFlag(name: string): boolean {
92
+ return args.includes(`--${name}`)
93
+ }
94
+
95
+ function hasFlagValue(name: string): boolean {
96
+ return hasFlag(name) || args.some((arg) => arg.startsWith(`--${name}=`))
97
+ }
98
+
99
+ const flagsWithValues = new Set([
100
+ "entry",
101
+ "port",
102
+ "host",
103
+ "api-port",
104
+ "api-host",
105
+ "api-public-origin",
106
+ "atlas-public-origin",
107
+ "app-public-origin",
108
+ "outdir",
109
+ "dir",
110
+ "expire-older-than",
111
+ "delete-older-than",
112
+ "api-url",
113
+ "token",
114
+ "id",
115
+ "name",
116
+ "description",
117
+ "expires-at",
118
+ "expires-in",
119
+ "group",
120
+ ])
121
+
122
+ function getCommandPositionals(): string[] {
123
+ const values: string[] = []
124
+
125
+ for (let index = 1; index < args.length; index++) {
126
+ const arg = args[index]
127
+ if (!arg) continue
128
+
129
+ if (arg.startsWith("--")) {
130
+ const flagName = arg.slice(2).split("=")[0] ?? ""
131
+ if (!arg.includes("=") && flagsWithValues.has(flagName)) {
132
+ index++
133
+ }
134
+ continue
135
+ }
136
+
137
+ values.push(arg)
138
+ }
139
+
140
+ return values
141
+ }
142
+
143
+ function getCommand(): string {
144
+ if (args[0] === "db") {
145
+ return args[1] ? `db:${args[1]}` : "db"
146
+ }
147
+ if (args[0] === "lake") {
148
+ return args[1] ? `lake:${args[1]}` : "lake"
149
+ }
150
+ return args[0] ?? "help"
151
+ }
152
+
153
+ async function main(): Promise<void> {
154
+ const command = getCommand()
155
+
156
+ if (hasFlag("help") || command === "help") {
157
+ await renderStatic(<HelpView />)
158
+ return
159
+ }
160
+
161
+ if (hasFlag("version") || command === "--version" || command === "-v") {
162
+ await renderStatic(<VersionView version={VERSION} />)
163
+ return
164
+ }
165
+
166
+ switch (command) {
167
+ case "dev": {
168
+ const { runDev } = await import("./commands/dev")
169
+ await runDev({
170
+ entry: getFlag("entry"),
171
+ port: getFlag("port"),
172
+ host: getFlag("host"),
173
+ apiPort: getFlag("api-port"),
174
+ apiHost: getFlag("api-host"),
175
+ apiPublicOrigin: getFlag("api-public-origin"),
176
+ atlasPublicOrigin: getFlag("atlas-public-origin"),
177
+ appPublicOrigin: getFlag("app-public-origin"),
178
+ })
179
+ break
180
+ }
181
+
182
+ case "worker": {
183
+ if (hasFlagValue("type") || hasFlagValue("worker")) {
184
+ throw new Error("[SixbWorker] Use `sixb worker <type>`.")
185
+ }
186
+
187
+ const { runWorker } = await import("./commands/worker")
188
+ await runWorker({
189
+ entry: getFlag("entry"),
190
+ noMigrate: hasFlag("no-migrate"),
191
+ workerType: getCommandPositionals()[0],
192
+ apiPublicOrigin: getFlag("api-public-origin"),
193
+ })
194
+ break
195
+ }
196
+
197
+ case "worker-group": {
198
+ const { runWorkerGroup } = await import("./commands/worker-group")
199
+ await runWorkerGroup({
200
+ entry: getFlag("entry"),
201
+ noMigrate: hasFlag("no-migrate"),
202
+ workerTypes: getCommandPositionals(),
203
+ apiPublicOrigin: getFlag("api-public-origin"),
204
+ })
205
+ break
206
+ }
207
+
208
+ case "api": {
209
+ const { runApi } = await import("./commands/api")
210
+ await runApi({
211
+ entry: getFlag("entry"),
212
+ noMigrate: hasFlag("no-migrate"),
213
+ port: getFlag("port"),
214
+ host: getFlag("host"),
215
+ apiPort: getFlag("api-port"),
216
+ apiHost: getFlag("api-host"),
217
+ apiPublicOrigin: getFlag("api-public-origin"),
218
+ atlasPublicOrigin: getFlag("atlas-public-origin"),
219
+ appPublicOrigin: getFlag("app-public-origin"),
220
+ })
221
+ break
222
+ }
223
+
224
+ case "atlas": {
225
+ const { runAtlas } = await import("./commands/atlas")
226
+ await runAtlas({
227
+ entry: getFlag("entry"),
228
+ port: getFlag("port"),
229
+ host: getFlag("host"),
230
+ apiPublicOrigin: getFlag("api-public-origin"),
231
+ atlasPublicOrigin: getFlag("atlas-public-origin"),
232
+ })
233
+ break
234
+ }
235
+
236
+ case "app": {
237
+ const { runApp } = await import("./commands/app")
238
+ await runApp({
239
+ entry: getFlag("entry"),
240
+ port: getFlag("port"),
241
+ host: getFlag("host"),
242
+ apiPublicOrigin: getFlag("api-public-origin"),
243
+ appPublicOrigin: getFlag("app-public-origin"),
244
+ })
245
+ break
246
+ }
247
+
248
+ case "auth": {
249
+ const { runAuth } = await import("./commands/auth")
250
+ const positionals = getCommandPositionals()
251
+ await runAuth({
252
+ action: positionals[0],
253
+ apiUrl: getFlag("api-url"),
254
+ token: getFlag("token"),
255
+ json: hasFlag("json"),
256
+ })
257
+ break
258
+ }
259
+
260
+ case "token": {
261
+ const { runToken } = await import("./commands/token")
262
+ const positionals = getCommandPositionals()
263
+ await runToken({
264
+ action: positionals[0],
265
+ positionals,
266
+ apiUrl: getFlag("api-url"),
267
+ token: getFlag("token"),
268
+ id: getFlag("id"),
269
+ name: getFlag("name"),
270
+ expiresAt: getFlag("expires-at"),
271
+ expiresIn: getFlag("expires-in"),
272
+ groupIds: getFlags("group"),
273
+ json: hasFlag("json"),
274
+ })
275
+ break
276
+ }
277
+
278
+ case "service-account": {
279
+ const { runServiceAccount } = await import("./commands/service-account")
280
+ await runServiceAccount({
281
+ positionals: getCommandPositionals(),
282
+ apiUrl: getFlag("api-url"),
283
+ token: getFlag("token"),
284
+ id: getFlag("id"),
285
+ name: getFlag("name"),
286
+ description: getFlag("description"),
287
+ expiresAt: getFlag("expires-at"),
288
+ expiresIn: getFlag("expires-in"),
289
+ groupIds: getFlags("group"),
290
+ json: hasFlag("json"),
291
+ })
292
+ break
293
+ }
294
+
295
+ case "scheduler": {
296
+ const { runScheduler } = await import("./commands/scheduler")
297
+ await runScheduler({ entry: getFlag("entry"), noMigrate: hasFlag("no-migrate") })
298
+ break
299
+ }
300
+
301
+ case "orchestrator": {
302
+ const { runOrchestrator } = await import("./commands/orchestrator")
303
+ await runOrchestrator({ entry: getFlag("entry"), noMigrate: hasFlag("no-migrate") })
304
+ break
305
+ }
306
+
307
+ case "rules": {
308
+ const { runRules } = await import("./commands/rules")
309
+ await runRules({ entry: getFlag("entry"), noMigrate: hasFlag("no-migrate") })
310
+ break
311
+ }
312
+
313
+ case "check": {
314
+ const { runCheck } = await import("./commands/check")
315
+ await runCheck({ entry: getFlag("entry") })
316
+ break
317
+ }
318
+
319
+ case "typegen": {
320
+ const { runTypegen } = await import("./commands/typegen")
321
+ await runTypegen({ entry: getFlag("entry") })
322
+ break
323
+ }
324
+
325
+ case "build": {
326
+ const { runBuild } = await import("./commands/build")
327
+ await runBuild({ entry: getFlag("entry"), outdir: getFlag("outdir") })
328
+ break
329
+ }
330
+
331
+ case "db:migrate": {
332
+ const { runDbMigrate } = await import("./commands/db-migrate")
333
+ await runDbMigrate({ entry: getFlag("entry") })
334
+ break
335
+ }
336
+
337
+ case "lake:check": {
338
+ const { runLakeCheck } = await import("./commands/lake-check")
339
+ await runLakeCheck({ entry: getFlag("entry") })
340
+ break
341
+ }
342
+
343
+ case "lake:cleanup": {
344
+ const { runLakeCleanup } = await import("./commands/lake-cleanup")
345
+ await runLakeCleanup({
346
+ entry: getFlag("entry"),
347
+ dryRun: hasFlag("dry-run"),
348
+ expireOlderThan: getFlag("expire-older-than"),
349
+ deleteOlderThan: getFlag("delete-older-than"),
350
+ })
351
+ break
352
+ }
353
+
354
+ case "init": {
355
+ const dir = args[1] && !args[1].startsWith("-") ? args[1] : undefined
356
+ const { runInit } = await import("./commands/init")
357
+ await runInit(dir)
358
+ break
359
+ }
360
+
361
+ case "create": {
362
+ const name = args[1]
363
+ if (!name) {
364
+ throw new Error("create requires a project name")
365
+ }
366
+ const { runCreate } = await import("./commands/init")
367
+ await runCreate(name)
368
+ break
369
+ }
370
+
371
+ case "db":
372
+ await renderStatic(<HelpView errorMessage="Usage: sixb db <migrate>" />)
373
+ process.exit(1)
374
+ break
375
+
376
+ case "lake":
377
+ await renderStatic(<HelpView errorMessage="Usage: sixb lake <check|cleanup>" />)
378
+ process.exit(1)
379
+ break
380
+
381
+ default:
382
+ await renderStatic(<HelpView errorMessage={`Unknown command: ${command}`} />)
383
+ process.exit(1)
384
+ }
385
+ }
386
+
387
+ main().catch(async (error) => {
388
+ await renderCliError(error)
389
+ process.exit(1)
390
+ })
@@ -0,0 +1,132 @@
1
+ import { createSixbClient, normalizeSixbApiBaseUrl, type SixbClient } from "@sixb/client"
2
+
3
+ export interface SixbApiClientConfig {
4
+ readonly apiUrl: string
5
+ readonly apiUrlSource: string
6
+ readonly token?: string
7
+ readonly tokenSource?: string
8
+ }
9
+
10
+ export interface ResolveApiClientConfigOptions {
11
+ readonly apiUrl?: string
12
+ readonly token?: string
13
+ readonly env?: Record<string, string | undefined>
14
+ }
15
+
16
+ export class SixbApiError extends Error {
17
+ readonly status: number | undefined
18
+ readonly responseBody: unknown
19
+
20
+ constructor(message: string, status: number | undefined, responseBody: unknown) {
21
+ super(message)
22
+ this.name = "SixbApiError"
23
+ this.status = status
24
+ this.responseBody = responseBody
25
+ }
26
+ }
27
+
28
+ export function resolveApiClientConfig(
29
+ options: ResolveApiClientConfigOptions = {}
30
+ ): SixbApiClientConfig {
31
+ const env = options.env ?? process.env
32
+ const apiUrlCandidate = firstConfigValue([
33
+ ["--api-url", options.apiUrl],
34
+ ["SIXB_API_URL", env.SIXB_API_URL],
35
+ ["SIXB_API_PUBLIC_ORIGIN", env.SIXB_API_PUBLIC_ORIGIN],
36
+ ]) ?? { source: "default", value: "http://localhost:3002" }
37
+ const tokenCandidate = firstConfigValue([
38
+ ["--token", options.token],
39
+ ["SIXB_API_TOKEN", env.SIXB_API_TOKEN],
40
+ ["SIXB_TOKEN", env.SIXB_TOKEN],
41
+ ])
42
+ const apiUrl = normalizeApiUrl(apiUrlCandidate.value)
43
+
44
+ return {
45
+ apiUrl,
46
+ apiUrlSource: apiUrlCandidate.source,
47
+ ...(tokenCandidate
48
+ ? {
49
+ token: tokenCandidate.value,
50
+ tokenSource: tokenCandidate.source,
51
+ }
52
+ : {}),
53
+ }
54
+ }
55
+
56
+ export function createCliSixbClient(config: SixbApiClientConfig): SixbClient {
57
+ if (!config.token) {
58
+ throw new Error("[SixbCLI] Missing API token. Set SIXB_API_TOKEN or pass --token.")
59
+ }
60
+
61
+ return createSixbClient({
62
+ baseUrl: config.apiUrl,
63
+ auth: { kind: "bearer", token: config.token },
64
+ })
65
+ }
66
+
67
+ export function unwrapSixbApiResult<T>(result: {
68
+ readonly data?: T
69
+ readonly error?: unknown
70
+ readonly response?: Response
71
+ }): T {
72
+ if (result.error !== undefined) {
73
+ throw new SixbApiError(
74
+ formatApiError(result.response?.status, result.error),
75
+ result.response?.status,
76
+ result.error
77
+ )
78
+ }
79
+
80
+ if (result.data === undefined) {
81
+ throw new SixbApiError("[SixbCLI] API request returned no data.", result.response?.status, null)
82
+ }
83
+
84
+ return result.data
85
+ }
86
+
87
+ export function normalizeApiUrl(value: string): string {
88
+ if (!/^https?:\/\//i.test(value)) {
89
+ throw new Error(`[SixbCLI] Invalid API URL '${value}'. Use a full http(s) URL.`)
90
+ }
91
+
92
+ try {
93
+ return normalizeSixbApiBaseUrl(value)
94
+ } catch {
95
+ throw new Error(`[SixbCLI] Invalid API URL '${value}'. Use a full http(s) URL.`)
96
+ }
97
+ }
98
+
99
+ function firstConfigValue(
100
+ entries: readonly (readonly [source: string, value: string | undefined])[]
101
+ ): { readonly source: string; readonly value: string } | undefined {
102
+ for (const [source, raw] of entries) {
103
+ const value = nonEmpty(raw)
104
+ if (value !== undefined) {
105
+ return { source, value }
106
+ }
107
+ }
108
+
109
+ return undefined
110
+ }
111
+
112
+ function nonEmpty(value: string | undefined): string | undefined {
113
+ const trimmed = value?.trim()
114
+ return trimmed ? trimmed : undefined
115
+ }
116
+
117
+ function formatApiError(status: number | undefined, body: unknown): string {
118
+ const statusLabel = status === undefined ? "network" : String(status)
119
+ if (typeof body === "object" && body && "error" in body && typeof body.error === "string") {
120
+ return `[SixbCLI] API request failed (${statusLabel}): ${body.error}`
121
+ }
122
+
123
+ if (typeof body === "string" && body.trim()) {
124
+ return `[SixbCLI] API request failed (${statusLabel}): ${body}`
125
+ }
126
+
127
+ if (body instanceof Error) {
128
+ return `[SixbCLI] API request failed (${statusLabel}): ${body.message}`
129
+ }
130
+
131
+ return `[SixbCLI] API request failed (${statusLabel}).`
132
+ }