@sixb/cli 0.2.1 → 0.2.3

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 (121) hide show
  1. package/README.md +25 -22
  2. package/dist/commands/access-token-utils.d.ts.map +1 -1
  3. package/dist/commands/agent.d.ts +4 -1
  4. package/dist/commands/agent.d.ts.map +1 -1
  5. package/dist/commands/api.d.ts.map +1 -1
  6. package/dist/commands/check.d.ts.map +1 -1
  7. package/dist/commands/connect.d.ts +13 -0
  8. package/dist/commands/connect.d.ts.map +1 -0
  9. package/dist/commands/db-migrate.d.ts.map +1 -1
  10. package/dist/commands/db-prepare.d.ts.map +1 -1
  11. package/dist/commands/deploy.d.ts.map +1 -1
  12. package/dist/commands/desktop.d.ts.map +1 -1
  13. package/dist/commands/dev-runner.d.ts.map +1 -1
  14. package/dist/commands/env.d.ts +6 -1
  15. package/dist/commands/env.d.ts.map +1 -1
  16. package/dist/commands/lake-cleanup.d.ts +2 -12
  17. package/dist/commands/lake-cleanup.d.ts.map +1 -1
  18. package/dist/commands/lake-rejected.d.ts +10 -0
  19. package/dist/commands/lake-rejected.d.ts.map +1 -0
  20. package/dist/commands/orchestrator.d.ts.map +1 -1
  21. package/dist/commands/scheduler.d.ts +2 -5
  22. package/dist/commands/scheduler.d.ts.map +1 -1
  23. package/dist/commands/worker-group.d.ts.map +1 -1
  24. package/dist/lib/command-line.d.ts +22 -7
  25. package/dist/lib/command-line.d.ts.map +1 -1
  26. package/dist/{tui → lib}/connection.d.ts +11 -1
  27. package/dist/{tui → lib}/connection.d.ts.map +1 -1
  28. package/dist/lib/deploy-release.d.ts +7 -1
  29. package/dist/lib/deploy-release.d.ts.map +1 -1
  30. package/dist/lib/desktop.d.ts +4 -0
  31. package/dist/lib/desktop.d.ts.map +1 -1
  32. package/dist/lib/dev-supervisor.d.ts.map +1 -1
  33. package/dist/lib/duration.d.ts +3 -0
  34. package/dist/lib/duration.d.ts.map +1 -0
  35. package/dist/lib/loadSixb.d.ts.map +1 -1
  36. package/dist/lib/production-roles.d.ts +0 -4
  37. package/dist/lib/production-roles.d.ts.map +1 -1
  38. package/dist/lib/profiles.d.ts +5 -0
  39. package/dist/lib/profiles.d.ts.map +1 -1
  40. package/dist/lib/runtime.d.ts +7 -9
  41. package/dist/lib/runtime.d.ts.map +1 -1
  42. package/dist/lib/worker-concurrency.d.ts.map +1 -1
  43. package/dist/lib/worker-registry.d.ts +4 -1
  44. package/dist/lib/worker-registry.d.ts.map +1 -1
  45. package/dist/runner/allowed-folders.d.ts +17 -0
  46. package/dist/runner/allowed-folders.d.ts.map +1 -0
  47. package/dist/runner/computer-connection.d.ts +70 -0
  48. package/dist/runner/computer-connection.d.ts.map +1 -0
  49. package/dist/runner/computer.d.ts.map +1 -0
  50. package/dist/runner/desktop-runner-main.d.ts +2 -0
  51. package/dist/runner/desktop-runner-main.d.ts.map +1 -0
  52. package/dist/runner/desktop-runner.d.ts +43 -0
  53. package/dist/runner/desktop-runner.d.ts.map +1 -0
  54. package/dist/runner/keep-awake.d.ts +11 -0
  55. package/dist/runner/keep-awake.d.ts.map +1 -0
  56. package/dist/runner/local-runner.d.ts +131 -0
  57. package/dist/runner/local-runner.d.ts.map +1 -0
  58. package/dist/tui/app.d.ts +2 -2
  59. package/dist/tui/app.d.ts.map +1 -1
  60. package/dist/tui/format.d.ts +29 -0
  61. package/dist/tui/format.d.ts.map +1 -1
  62. package/dist/tui/index.d.ts.map +1 -1
  63. package/dist/tui/settings.d.ts +5 -8
  64. package/dist/tui/settings.d.ts.map +1 -1
  65. package/dist/ui/deploy-screens.d.ts +4 -2
  66. package/dist/ui/deploy-screens.d.ts.map +1 -1
  67. package/dist/ui/env-screens.d.ts +14 -1
  68. package/dist/ui/env-screens.d.ts.map +1 -1
  69. package/dist/ui/screens.d.ts +5 -11
  70. package/dist/ui/screens.d.ts.map +1 -1
  71. package/package.json +21 -17
  72. package/src/commands/access-token-utils.ts +2 -20
  73. package/src/commands/agent.ts +122 -39
  74. package/src/commands/api.ts +7 -0
  75. package/src/commands/check.ts +75 -1
  76. package/src/commands/connect.ts +197 -0
  77. package/src/commands/db-migrate.ts +1 -0
  78. package/src/commands/db-prepare.ts +1 -0
  79. package/src/commands/deploy.ts +15 -3
  80. package/src/commands/desktop.ts +2 -1
  81. package/src/commands/dev-runner.ts +5 -0
  82. package/src/commands/env.ts +99 -20
  83. package/src/commands/lake-cleanup.ts +25 -48
  84. package/src/commands/lake-rejected.ts +36 -0
  85. package/src/commands/orchestrator.ts +2 -7
  86. package/src/commands/scheduler.ts +11 -61
  87. package/src/commands/worker-group.ts +6 -3
  88. package/src/index.tsx +23 -4
  89. package/src/lib/command-line.ts +47 -15
  90. package/src/{tui → lib}/connection.ts +64 -17
  91. package/src/lib/deploy-release.ts +42 -2
  92. package/src/lib/desktop.ts +8 -1
  93. package/src/lib/dev-supervisor.ts +7 -2
  94. package/src/lib/duration.ts +11 -0
  95. package/src/lib/loadSixb.ts +3 -4
  96. package/src/lib/production-roles.ts +0 -1
  97. package/src/lib/profiles.ts +15 -1
  98. package/src/lib/runtime.ts +63 -43
  99. package/src/lib/shareable-providers.ts +2 -2
  100. package/src/lib/storage-migration.ts +1 -0
  101. package/src/lib/worker-concurrency.ts +1 -0
  102. package/src/lib/worker-registry.ts +36 -1
  103. package/src/runner/allowed-folders.ts +126 -0
  104. package/src/runner/computer-connection.ts +184 -0
  105. package/src/runner/desktop-runner-main.ts +9 -0
  106. package/src/runner/desktop-runner.ts +217 -0
  107. package/src/runner/keep-awake.ts +50 -0
  108. package/src/runner/local-runner.ts +427 -0
  109. package/src/tui/app.tsx +168 -12
  110. package/src/tui/format.ts +213 -7
  111. package/src/tui/index.tsx +14 -13
  112. package/src/tui/settings.ts +12 -44
  113. package/src/ui/deploy-screens.ts +8 -1
  114. package/src/ui/env-screens.ts +39 -5
  115. package/src/ui/screens.ts +21 -20
  116. package/dist/tui/computer.d.ts.map +0 -1
  117. package/dist/tui/runner.d.ts +0 -75
  118. package/dist/tui/runner.d.ts.map +0 -1
  119. package/src/tui/runner.ts +0 -256
  120. /package/dist/{tui → runner}/computer.d.ts +0 -0
  121. /package/src/{tui → runner}/computer.ts +0 -0
@@ -1,63 +1,13 @@
1
- import type { LoadedSixbHost } from "../lib/loadSixb"
2
- import { loadProductionSixb } from "../lib/production"
3
- import { runUntilSignal, stopQuietly } from "../lib/role-lifecycle"
4
- import {
5
- type RunningSchedulerRuntime,
6
- startSchedulerRuntime,
7
- stopSixbProviders,
8
- } from "../lib/runtime"
9
- import { migrateStorageForRole } from "../lib/storage-migration"
10
- import { printStopping, renderCliError, renderStatic, roleView, startTask } from "../ui"
11
-
12
- export interface SchedulerOptions {
13
- entry?: string
14
- noMigrate?: boolean
15
- }
16
-
17
- export async function runScheduler(options: SchedulerOptions = {}) {
18
- process.env.NODE_ENV = "production"
19
-
20
- const loaded = await loadProductionSixb({ entry: options.entry, role: "scheduler" })
21
- const app = startTask("scheduler", "Starting scheduler")
22
-
23
- let sixb: LoadedSixbHost | null = loaded.sixb
24
- let runtime: RunningSchedulerRuntime | null = null
25
-
26
- try {
27
- const migration = await migrateStorageForRole(sixb, {
28
- role: "scheduler",
29
- noMigrate: options.noMigrate,
30
- onStart: () => app.step("Migrating storage"),
31
- })
32
-
33
- runtime = await startSchedulerRuntime(sixb)
34
-
35
- app.stop()
36
- await renderStatic(
37
- roleView({
38
- command: "scheduler",
39
- name: sixb.id,
40
- items: [{ label: "role", value: "schedule event producer" }],
41
- storage: migration.summary,
42
- })
43
- )
44
-
45
- await runUntilSignal(async () => {
46
- app.stop()
47
- printStopping("scheduler")
48
- await stopQuietly(() => runtime?.stop() ?? Promise.resolve())
49
- if (sixb) {
50
- await stopSixbProviders(sixb)
51
- }
52
- sixb = null
1
+ import { SixbCliError } from "../lib/errors"
2
+ import { renderCliError } from "../ui"
3
+
4
+ /** The command stays only to say where cron went: a process manager left on it must see a failure. */
5
+ export async function runScheduler(): Promise<void> {
6
+ await renderCliError(
7
+ new SixbCliError("[SixbCLI] `sixb scheduler` no longer runs: `sixb orchestrator` runs cron.", {
8
+ remediation:
9
+ "Remove this process from your deployment and keep one `sixb orchestrator` running.",
53
10
  })
54
- } catch (error) {
55
- app.stop()
56
- await stopQuietly(() => runtime?.stop() ?? Promise.resolve())
57
- if (sixb) {
58
- await stopSixbProviders(sixb)
59
- }
60
- await renderCliError(error)
61
- process.exit(1)
62
- }
11
+ )
12
+ process.exit(1)
63
13
  }
@@ -13,6 +13,7 @@ import {
13
13
  agentRuntimeRequired,
14
14
  assertWorkerInputs,
15
15
  createWorkerForType,
16
+ omittedWorkerWarnings,
16
17
  type QueueWorkerProcess,
17
18
  resolveRegisteredWorkerTypes,
18
19
  resolveWorkerTypeToStart,
@@ -102,10 +103,12 @@ export async function runWorkerGroup(options: WorkerGroupOptions = {}) {
102
103
  )
103
104
  await Promise.all(workers.map((worker) => worker.start()))
104
105
 
105
- const warnings =
106
- workerTypes.length === 0
106
+ const warnings = [
107
+ ...(workerTypes.length === 0
107
108
  ? ["No queue worker types are registered; the worker group process is idle."]
108
- : []
109
+ : []),
110
+ ...omittedWorkerWarnings(host, workerTypes),
111
+ ]
109
112
 
110
113
  app.stop()
111
114
  await renderStatic(
package/src/index.tsx CHANGED
@@ -226,6 +226,19 @@ async function main(): Promise<void> {
226
226
  cloud: hasFlag("cloud"),
227
227
  approvalMode: getFlag("approval-mode"),
228
228
  json: hasFlag("json"),
229
+ detach: hasFlag("detach"),
230
+ apiUrl: getFlag("api-url"),
231
+ profile: getFlag("profile"),
232
+ })
233
+ break
234
+ }
235
+
236
+ case "connect": {
237
+ const { runConnect } = await import("./commands/connect")
238
+ await runConnect({
239
+ folders: positionals,
240
+ yes: hasFlag("yes"),
241
+ json: hasFlag("json"),
229
242
  apiUrl: getFlag("api-url"),
230
243
  profile: getFlag("profile"),
231
244
  })
@@ -302,7 +315,7 @@ async function main(): Promise<void> {
302
315
 
303
316
  case "scheduler": {
304
317
  const { runScheduler } = await import("./commands/scheduler")
305
- await runScheduler({ entry: getFlag("entry"), noMigrate: hasFlag("no-migrate") })
318
+ await runScheduler()
306
319
  break
307
320
  }
308
321
 
@@ -363,13 +376,19 @@ async function main(): Promise<void> {
363
376
  break
364
377
  }
365
378
 
379
+ case "lake:rejected": {
380
+ const { runLakeRejected } = await import("./commands/lake-rejected")
381
+ await runLakeRejected({ entry: getFlag("entry"), dataset: getFlag("dataset") })
382
+ break
383
+ }
384
+
366
385
  case "lake:cleanup": {
367
386
  const { runLakeCleanup } = await import("./commands/lake-cleanup")
368
387
  await runLakeCleanup({
369
388
  entry: getFlag("entry"),
370
389
  dryRun: hasFlag("dry-run"),
371
- expireOlderThan: getFlag("expire-older-than"),
372
- deleteOlderThan: getFlag("delete-older-than"),
390
+ keepVersionsFor: getFlag("keep-versions-for"),
391
+ deleteFilesAfter: getFlag("delete-files-after"),
373
392
  })
374
393
  break
375
394
  }
@@ -379,7 +398,7 @@ async function main(): Promise<void> {
379
398
  const dev = getFlag("dev")
380
399
  const prod = getFlag("prod")
381
400
  await runEnvInit({
382
- project: positionals[0] ?? "",
401
+ ...(positionals[0] === undefined ? {} : { project: positionals[0] }),
383
402
  ...(dev === undefined ? {} : { dev }),
384
403
  ...(prod === undefined ? {} : { prod }),
385
404
  })
@@ -119,6 +119,16 @@ export const CLI_OPTION_DEFINITIONS = {
119
119
  summary: "What this turn may do without asking (default: your mode in the conversation)",
120
120
  kind: "string",
121
121
  },
122
+ detach: {
123
+ syntax: "--detach",
124
+ summary: "Send the message and exit, without following the turn",
125
+ kind: "boolean",
126
+ },
127
+ yes: {
128
+ syntax: "--yes",
129
+ summary: "Allow the folders named without asking",
130
+ kind: "boolean",
131
+ },
122
132
  outdir: { syntax: "--outdir <path>", summary: "Build output directory", kind: "string" },
123
133
  ref: {
124
134
  syntax: "--ref <ref>",
@@ -176,14 +186,20 @@ export const CLI_OPTION_DEFINITIONS = {
176
186
  summary: "Show what would change without changing it",
177
187
  kind: "boolean",
178
188
  },
179
- "expire-older-than": {
180
- syntax: "--expire-older-than <interval>",
181
- summary: "Lake snapshot expiration window",
189
+ dataset: {
190
+ syntax: "--dataset <id>",
191
+ summary: "Show one dataset's rejected deliveries (default: every dataset)",
192
+ kind: "string",
193
+ },
194
+ "keep-versions-for": {
195
+ syntax: "--keep-versions-for <duration>",
196
+ summary:
197
+ "How long a replaced lake version stays readable (default: `lakeMaintenance`, at least 1h)",
182
198
  kind: "string",
183
199
  },
184
- "delete-older-than": {
185
- syntax: "--delete-older-than <interval>",
186
- summary: "Lake file deletion window",
200
+ "delete-files-after": {
201
+ syntax: "--delete-files-after <duration>",
202
+ summary: "How long unread lake files wait before deletion (default: `lakeMaintenance`)",
187
203
  kind: "string",
188
204
  },
189
205
  } as const satisfies Record<string, { syntax: string; summary: string; kind: OptionKind }>
@@ -191,6 +207,7 @@ export const CLI_OPTION_DEFINITIONS = {
191
207
  export type CliOptionName = keyof typeof CLI_OPTION_DEFINITIONS
192
208
  export type LocalCommandId =
193
209
  | "agent"
210
+ | "connect"
194
211
  | "dev"
195
212
  | "api"
196
213
  | "app"
@@ -222,6 +239,7 @@ export type LocalCommandId =
222
239
  | "db:prepare"
223
240
  | "lake:check"
224
241
  | "lake:cleanup"
242
+ | "lake:rejected"
225
243
  | "deploy"
226
244
  | "deploy:status"
227
245
  | "deploy:logs"
@@ -289,6 +307,7 @@ const INSTANCE_SUMMARIES = {
289
307
  workflows: "Discover and start workflows",
290
308
  "workflow-runs": "Inspect workflow execution history",
291
309
  users: "List and search project members",
310
+ artifacts: "Read, resolve and reply to an artifact's comments",
292
311
  models: "List the project's models and their prices",
293
312
  datasets: "Read datasets, their versions and rows",
294
313
  syncs: "List the syncs you may run",
@@ -352,14 +371,21 @@ const commandTree: readonly CommandNode[] = [
352
371
  options: [...CONNECTION_OPTIONS, "json"],
353
372
  }),
354
373
  command("agent", "Ask the agent; it works in this folder", {
355
- usage: 'sixb agent "<message>" [--thread <id>] [--cloud] [--approval-mode <mode>] [--json]',
374
+ usage:
375
+ 'sixb agent "<message>" [--thread <id>] [--cloud] [--approval-mode <mode>] [--detach] [--json]',
356
376
  // No --token: a command the agent runs could read it from this one's arguments. A token comes
357
377
  // from a profile or SIXB_API_TOKEN.
358
- options: ["api-url", "profile", "thread", "cloud", "approval-mode", "json"],
378
+ options: ["api-url", "profile", "thread", "cloud", "approval-mode", "detach", "json"],
359
379
  // The message, quoted or not; standard input when there is none.
360
380
  maximumPositionals: Number.POSITIVE_INFINITY,
361
381
  rootHelpLabel: 'agent "<message>"',
362
382
  }),
383
+ command("connect", "Run messages from the web in folders on this computer", {
384
+ usage: "sixb connect [folder...] [--yes] [--json]",
385
+ options: ["api-url", "profile", "yes", "json"],
386
+ maximumPositionals: Number.POSITIVE_INFINITY,
387
+ rootHelpLabel: "connect [folder...]",
388
+ }),
363
389
  {
364
390
  name: "profile",
365
391
  summary: "List, show, or switch saved profiles",
@@ -471,10 +497,10 @@ const commandTree: readonly CommandNode[] = [
471
497
  },
472
498
  ],
473
499
  },
474
- command("scheduler", "Start the production scheduler", {
500
+ command("scheduler", "Removed: the orchestrator runs cron schedules", {
475
501
  options: ["entry", "no-migrate"],
476
502
  }),
477
- command("orchestrator", "Start the production orchestrator, which queues work for events", {
503
+ command("orchestrator", "Start the production orchestrator: cron, event dispatch and upkeep", {
478
504
  options: ["entry", "no-migrate"],
479
505
  }),
480
506
  command("rules", "Start the production rules runtime", { options: ["entry", "no-migrate"] }),
@@ -558,9 +584,14 @@ const commandTree: readonly CommandNode[] = [
558
584
  }),
559
585
  command("lake:cleanup", "Clean up old lake snapshots and files", {
560
586
  path: ["lake", "cleanup"],
561
- options: ["entry", "dry-run", "expire-older-than", "delete-older-than"],
587
+ options: ["entry", "dry-run", "keep-versions-for", "delete-files-after"],
562
588
  rootHelpLabel: "lake cleanup",
563
589
  }),
590
+ command("lake:rejected", "Show ingested deliveries refused after they were accepted", {
591
+ path: ["lake", "rejected"],
592
+ options: ["entry", "dataset"],
593
+ rootHelpLabel: "lake rejected",
594
+ }),
564
595
  ],
565
596
  },
566
597
  {
@@ -632,9 +663,8 @@ const commandTree: readonly CommandNode[] = [
632
663
  children: [
633
664
  command("env:init", "Move a project's values to its source and write sixb.env.ts", {
634
665
  path: ["env", "init"],
635
- usage: "sixb env init <project> [--dev <file>] [--prod <file>]",
666
+ usage: "sixb env init [doppler-project] [--dev <file>] [--prod <file>]",
636
667
  options: ["dev", "prod"],
637
- minimumPositionals: 1,
638
668
  maximumPositionals: 1,
639
669
  }),
640
670
  command("env:pull", "Write .env from the project's source", {
@@ -720,13 +750,14 @@ const ROOT_HELP_GROUP_COMMANDS: readonly {
720
750
  /** Listed by name only: each has its own help. */
721
751
  readonly compact?: boolean
722
752
  }[] = [
723
- { title: "Agent", names: ["agent"] },
753
+ { title: "Agent", names: ["agent", "connect"] },
724
754
  { title: "Develop", names: ["init", "dev", "env", "check", "typegen", "build"] },
725
755
  { title: "Deploy", names: ["deploy", "desktop"] },
726
756
  {
727
757
  title: "Run in production",
728
- names: ["api", "app", "scheduler", "orchestrator", "rules", "worker", "worker-group"],
758
+ names: ["api", "app", "orchestrator", "rules", "worker", "worker-group"],
729
759
  },
760
+ { title: "Removed", names: ["scheduler"] },
730
761
  { title: "Storage", names: ["db", "lake"] },
731
762
  {
732
763
  title: "Connect to an instance",
@@ -813,6 +844,7 @@ export function wantsManagementJson(args: readonly string[]): boolean {
813
844
  "service-account",
814
845
  "deploy",
815
846
  "agent",
847
+ "connect",
816
848
  ].includes(args[0] ?? "") &&
817
849
  args.some((argument) => argument === "--json" || argument.startsWith("--json="))
818
850
  )
@@ -8,13 +8,17 @@ import {
8
8
  type SixbSessionTokens,
9
9
  startSixbDeviceLogin,
10
10
  } from "@sixb/client"
11
- import { normalizeApiUrl } from "../lib/api-client"
11
+ import { normalizeApiUrl } from "./api-client"
12
+ import { errorMessage } from "./errors"
12
13
  import {
14
+ ProfileUnansweredError,
13
15
  profileSessionStore,
14
16
  type ResolvedProfile,
17
+ readConfig,
15
18
  resolveProfile,
19
+ type SixbConfigFile,
16
20
  updateConfig,
17
- } from "../lib/profiles"
21
+ } from "./profiles"
18
22
 
19
23
  /** A project the app talks to, as the person signed in to it. */
20
24
  export interface Connection {
@@ -45,7 +49,10 @@ export async function connect(input: {
45
49
  try {
46
50
  resolved = await resolveProfile(input)
47
51
  } catch (error) {
48
- return { apiUrl: input.apiUrl ?? "", reason: "session-ended", message: errorText(error) }
52
+ if (error instanceof ProfileUnansweredError) {
53
+ return { apiUrl: error.apiUrl, reason: "unreachable", message: error.message }
54
+ }
55
+ return { apiUrl: input.apiUrl ?? "", reason: "session-ended", message: errorMessage(error) }
49
56
  }
50
57
  const profile = resolved.profile
51
58
  const viaSession = resolved.tokenSource === "session" && profile !== undefined
@@ -101,11 +108,24 @@ export async function connect(input: {
101
108
  apiUrl: resolved.apiUrl,
102
109
  ...(profile === undefined ? {} : { profile }),
103
110
  reason: status === 401 || status === 403 ? "signed-out" : "unreachable",
104
- message: errorText(error),
111
+ message: errorMessage(error),
105
112
  }
106
113
  }
107
114
  }
108
115
 
116
+ /**
117
+ * The profiles signed in to `apiUrl`: the CLI's own sign-in there serves a program beside it. The one
118
+ * `sixb` is using comes first.
119
+ */
120
+ export async function profilesSignedInTo(apiUrl: string): Promise<readonly string[]> {
121
+ const baseUrl = normalizeApiUrl(apiUrl)
122
+ const { profiles, currentProfile } = await readConfig()
123
+ return Object.entries(profiles)
124
+ .filter(([, profile]) => profile.apiUrl === baseUrl && (profile.session || profile.token))
125
+ .map(([name]) => name)
126
+ .sort((a, b) => Number(b === currentProfile) - Number(a === currentProfile))
127
+ }
128
+
109
129
  /** A sign-in in progress: show the code, open the page, then wait for the person to approve it. */
110
130
  export interface PendingSignIn {
111
131
  readonly apiUrl: string
@@ -116,11 +136,49 @@ export interface PendingSignIn {
116
136
 
117
137
  /**
118
138
  * Sign this computer in to `apiUrl` with the device flow, as `sixb login` does, and keep the
119
- * session on a profile named after the project.
139
+ * session on a profile named after the project, which `sixb` then uses.
120
140
  */
121
141
  export async function startSignIn(apiUrl: string): Promise<PendingSignIn> {
122
142
  const baseUrl = normalizeApiUrl(apiUrl)
123
143
  const login = await startSixbDeviceLogin({ baseUrl, clientName: `sixb on ${hostname()}` })
144
+ return pendingSignIn(baseUrl, login, (config, project, session) => ({
145
+ version: 1,
146
+ currentProfile: project,
147
+ profiles: {
148
+ ...config.profiles,
149
+ [project]: { apiUrl: baseUrl, projectId: project, session },
150
+ },
151
+ }))
152
+ }
153
+
154
+ /**
155
+ * As `startSignIn`, for a program beside `sixb` rather than `sixb` itself: what `sixb` is using stays
156
+ * as it was, and so does a profile of the same name for another address.
157
+ */
158
+ export async function startSignInBeside(
159
+ apiUrl: string,
160
+ clientName: string
161
+ ): Promise<PendingSignIn> {
162
+ const baseUrl = normalizeApiUrl(apiUrl)
163
+ const login = await startSixbDeviceLogin({ baseUrl, clientName })
164
+ return pendingSignIn(baseUrl, login, (config, project, session) => {
165
+ const taken = config.profiles[project]
166
+ const name =
167
+ taken && taken.apiUrl !== baseUrl
168
+ ? `${project}-${new URL(baseUrl).host.replace(":", "-")}`
169
+ : project
170
+ return {
171
+ ...config,
172
+ profiles: { ...config.profiles, [name]: { apiUrl: baseUrl, projectId: project, session } },
173
+ }
174
+ })
175
+ }
176
+
177
+ function pendingSignIn(
178
+ baseUrl: string,
179
+ login: Awaited<ReturnType<typeof startSixbDeviceLogin>>,
180
+ keep: (config: SixbConfigFile, project: string, session: SixbSessionTokens) => SixbConfigFile
181
+ ): PendingSignIn {
124
182
  return {
125
183
  apiUrl: baseUrl,
126
184
  userCode: login.userCode,
@@ -132,18 +190,7 @@ export async function startSignIn(apiUrl: string): Promise<PendingSignIn> {
132
190
  auth: { kind: "bearer", token: session.accessToken },
133
191
  })
134
192
  const { data: project } = await getProjectInfo({ client, throwOnError: true })
135
- await updateConfig((config) => ({
136
- version: 1,
137
- currentProfile: project.id,
138
- profiles: {
139
- ...config.profiles,
140
- [project.id]: { apiUrl: baseUrl, projectId: project.id, session },
141
- },
142
- }))
193
+ await updateConfig((config) => keep(config, project.id, session))
143
194
  },
144
195
  }
145
196
  }
146
-
147
- function errorText(error: unknown): string {
148
- return error instanceof Error ? error.message : String(error)
149
- }
@@ -1,4 +1,5 @@
1
1
  import type {
2
+ DeployCheck,
2
3
  DeployCommand,
3
4
  DeployConfig,
4
5
  DeployEnv,
@@ -28,7 +29,6 @@ const ROLE_SERVICES = {
28
29
  api: "api",
29
30
  app: "app",
30
31
  orchestrator: "orchestrator",
31
- scheduler: "scheduler",
32
32
  rules: "rules",
33
33
  "worker-group": "workers",
34
34
  // A deployment co-hosts its workers in one `worker-group`; `workers.process.instances` scales it.
@@ -44,7 +44,6 @@ const SERVICE_ROLES: { readonly [Service in DeployServiceName]: RoleOf<Service>
44
44
  api: "api",
45
45
  app: "app",
46
46
  orchestrator: "orchestrator",
47
- scheduler: "scheduler",
48
47
  rules: "rules",
49
48
  workers: "worker-group",
50
49
  }
@@ -168,6 +167,47 @@ function sixbService(
168
167
  }
169
168
  }
170
169
 
170
+ /**
171
+ * What this config leaves the lake's background work without: its retention, and the changes
172
+ * `ingest` stores. Only the project knows whether it has datasets, and this reads the config alone,
173
+ * so it warns and never stops a deploy.
174
+ */
175
+ export function lakeWorkChecks(config: DeployConfig): readonly DeployCheck[] {
176
+ const { orchestrator, workers } = config.services ?? {}
177
+ const types = typeof workers === "object" ? workers.types : undefined
178
+ const lakeWorkerOmitted = workers === false || (Array.isArray(types) && !types.includes("lake"))
179
+
180
+ const missing = [
181
+ ...(orchestrator === false ? ["the orchestrator requests it"] : []),
182
+ ...(lakeWorkerOmitted ? ["a `lake` worker runs it"] : []),
183
+ ]
184
+
185
+ return [
186
+ ...(missing.length > 0
187
+ ? [
188
+ {
189
+ id: "lake-retention",
190
+ label: "Lake retention",
191
+ status: "warning" as const,
192
+ detail: `Not deployed: ${missing.join(", and ")}.`,
193
+ remedy: "Deploy them, or a project with datasets keeps every replaced version.",
194
+ },
195
+ ]
196
+ : []),
197
+ ...(lakeWorkerOmitted
198
+ ? [
199
+ {
200
+ id: "dataset-ingestion",
201
+ label: "Dataset ingestion",
202
+ status: "warning" as const,
203
+ detail: "Not deployed: a `lake` worker writes what `ingest` stores.",
204
+ remedy: "Deploy one, or ingested changes wait and never reach their dataset.",
205
+ },
206
+ ]
207
+ : []),
208
+ ]
209
+ }
210
+
171
211
  function workerGroupArgs(options: DeployWorkersConfig): string[] {
172
212
  const types = options.types === undefined || options.types === "all" ? [] : options.types
173
213
  const args = ["worker-group", ...types]
@@ -1,4 +1,4 @@
1
- import { pathToFileURL } from "node:url"
1
+ import { fileURLToPath, pathToFileURL } from "node:url"
2
2
  import { SixbCliError } from "./errors"
3
3
 
4
4
  export interface DesktopAppOptions {
@@ -6,8 +6,15 @@ export interface DesktopAppOptions {
6
6
  /** Where the app is served. The desktop app opens it and takes its name and icon from it. */
7
7
  readonly appUrl: string
8
8
  readonly apiOrigin: string
9
+ /** What the app compiles to run the agent on this computer. */
10
+ readonly runnerEntry: string
9
11
  }
10
12
 
13
+ /** From the CLI's `src`, which ships: `@sixb/desktop` compiles it into the app. */
14
+ export const DESKTOP_RUNNER_ENTRY = fileURLToPath(
15
+ new URL("../runner/desktop-runner-main.ts", import.meta.url)
16
+ )
17
+
11
18
  /**
12
19
  * What the CLI calls on `@sixb/desktop`. Declared here, not imported: the CLI does not depend on
13
20
  * the package, and `desktop.test.ts` holds the two together.
@@ -2,7 +2,7 @@ import { spawn } from "node:child_process"
2
2
  import { dirname, resolve } from "node:path"
3
3
  import type { DevOptions } from "../commands/dev-runner"
4
4
  import { canRunLive } from "../ui/live/can-run-live"
5
- import { loadDesktop } from "./desktop"
5
+ import { DESKTOP_RUNNER_ENTRY, loadDesktop } from "./desktop"
6
6
  import { DEV_UI_ENV, type DevChildMessage } from "./dev-messages"
7
7
  import { watchDevSource } from "./dev-watch"
8
8
  import { errorMessage } from "./errors"
@@ -175,7 +175,12 @@ export async function runDevSupervisor(options: DevOptions): Promise<void> {
175
175
  const app = servedApp(message)
176
176
  if (desktop && app && !desktopWindow) {
177
177
  desktopWindow = desktop
178
- .openDesktopApp({ projectRoot: root, appUrl: app.url, apiOrigin: app.apiOrigin })
178
+ .openDesktopApp({
179
+ projectRoot: root,
180
+ runnerEntry: DESKTOP_RUNNER_ENTRY,
181
+ appUrl: app.url,
182
+ apiOrigin: app.apiOrigin,
183
+ })
179
184
  .catch((error: unknown) => {
180
185
  reporter.error(`Could not open the desktop window: ${errorMessage(error)}`)
181
186
  // The next generation to come up tries again.
@@ -0,0 +1,11 @@
1
+ import { parseDuration } from "@sixb/core/internal/runtime"
2
+
3
+ /** A duration flag such as 30m, 12h, 7d, 4w or 1y, in milliseconds. */
4
+ export function parseDurationMs(value: string, flag: string): number {
5
+ const durationMs = parseDuration(value)
6
+ if (durationMs === null) {
7
+ throw new Error(`[SixbCLI] Use ${flag} like 30d, 12h, 4w, or 1y.`)
8
+ }
9
+
10
+ return durationMs
11
+ }
@@ -17,13 +17,14 @@ const REQUIRED_HOST_PROPERTIES = [
17
17
  "blobStorage",
18
18
  "queues",
19
19
  "auth",
20
- "scheduler",
21
20
  ] as const
22
21
 
23
22
  const REQUIRED_LIFECYCLE_METHODS = [
24
23
  "withScope",
24
+ "startMaintenance",
25
25
  "startOntologyMaintenance",
26
26
  "getOntologyOperationalStatus",
27
+ "prepareReadiness",
27
28
  "checkReadiness",
28
29
  "closeLogger",
29
30
  "closeConnectors",
@@ -103,9 +104,7 @@ function isSixbHost(value: unknown): value is LoadedSixbHost {
103
104
  isRecord(value.logging) &&
104
105
  hasMethods(value.logging, ["startExecution", "read", "tail"]) &&
105
106
  isRecord(value.blobStorage) &&
106
- hasMethods(value.blobStorage, ["put", "open", "stat"]) &&
107
- isRecord(value.scheduler) &&
108
- hasMethods(value.scheduler, ["start", "stop"])
107
+ hasMethods(value.blobStorage, ["put", "open", "stat"])
109
108
  )
110
109
  }
111
110
 
@@ -7,7 +7,6 @@
7
7
  const PRODUCTION_ROLES = {
8
8
  api: { onEventPlane: true, usesStorageSchema: true },
9
9
  rules: { onEventPlane: true, usesStorageSchema: true },
10
- scheduler: { onEventPlane: true, usesStorageSchema: true },
11
10
  orchestrator: { onEventPlane: true, usesStorageSchema: true },
12
11
  worker: { onEventPlane: true, usesStorageSchema: true },
13
12
  "worker-group": { onEventPlane: true, usesStorageSchema: true },
@@ -9,6 +9,7 @@ import {
9
9
  type SixbSessionTokens,
10
10
  } from "@sixb/client"
11
11
  import { normalizeApiUrl } from "./api-client"
12
+ import { errorMessage } from "./errors"
12
13
 
13
14
  const CONFIG_DIRECTORY_MODE = 0o700
14
15
  const CONFIG_FILE_MODE = 0o600
@@ -188,6 +189,17 @@ export function assertProfileName(name: string): void {
188
189
  }
189
190
  }
190
191
 
192
+ /** Its sign-in couldn't be refreshed for want of an answer, which says nothing about the sign-in. */
193
+ export class ProfileUnansweredError extends Error {
194
+ constructor(
195
+ readonly apiUrl: string,
196
+ cause: unknown
197
+ ) {
198
+ super(errorMessage(cause), { cause })
199
+ this.name = "ProfileUnansweredError"
200
+ }
201
+ }
202
+
191
203
  async function resolvedStoredProfile(
192
204
  stored: SixbProfile,
193
205
  profile: string,
@@ -203,7 +215,9 @@ async function resolvedStoredProfile(
203
215
  baseUrl: stored.apiUrl,
204
216
  store: profileSessionStore(profile, options),
205
217
  }).catch((error: unknown) => {
206
- if (!(error instanceof SixbSessionEndedError)) throw error
218
+ if (!(error instanceof SixbSessionEndedError)) {
219
+ throw new ProfileUnansweredError(stored.apiUrl, error)
220
+ }
207
221
  return null
208
222
  })
209
223
  if (!token) {