@sixb/cli 0.1.20 → 0.1.22

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 (130) hide show
  1. package/README.md +21 -4
  2. package/dist/commands/api.d.ts.map +1 -1
  3. package/dist/commands/app.d.ts.map +1 -1
  4. package/dist/commands/build.d.ts.map +1 -1
  5. package/dist/commands/check.d.ts.map +1 -1
  6. package/dist/commands/db-migrate.d.ts.map +1 -1
  7. package/dist/commands/deploy.d.ts.map +1 -1
  8. package/dist/commands/desktop.d.ts +15 -0
  9. package/dist/commands/desktop.d.ts.map +1 -0
  10. package/dist/commands/dev-runner.d.ts +4 -0
  11. package/dist/commands/dev-runner.d.ts.map +1 -1
  12. package/dist/commands/dev.d.ts.map +1 -1
  13. package/dist/commands/init.d.ts.map +1 -1
  14. package/dist/commands/lake-check.d.ts.map +1 -1
  15. package/dist/commands/lake-cleanup.d.ts +2 -0
  16. package/dist/commands/lake-cleanup.d.ts.map +1 -1
  17. package/dist/commands/login.d.ts.map +1 -1
  18. package/dist/commands/logout.d.ts.map +1 -1
  19. package/dist/commands/orchestrator.d.ts.map +1 -1
  20. package/dist/commands/profile.d.ts.map +1 -1
  21. package/dist/commands/rules.d.ts.map +1 -1
  22. package/dist/commands/scheduler.d.ts.map +1 -1
  23. package/dist/commands/service-account.d.ts.map +1 -1
  24. package/dist/commands/status.d.ts.map +1 -1
  25. package/dist/commands/token.d.ts.map +1 -1
  26. package/dist/commands/typegen.d.ts.map +1 -1
  27. package/dist/commands/worker-group.d.ts +2 -0
  28. package/dist/commands/worker-group.d.ts.map +1 -1
  29. package/dist/commands/worker.d.ts +2 -0
  30. package/dist/commands/worker.d.ts.map +1 -1
  31. package/dist/lib/command-line.d.ts +22 -2
  32. package/dist/lib/command-line.d.ts.map +1 -1
  33. package/dist/lib/deploy-release.d.ts +3 -1
  34. package/dist/lib/deploy-release.d.ts.map +1 -1
  35. package/dist/lib/desktop.d.ts +26 -0
  36. package/dist/lib/desktop.d.ts.map +1 -0
  37. package/dist/lib/dev-messages.d.ts +43 -0
  38. package/dist/lib/dev-messages.d.ts.map +1 -0
  39. package/dist/lib/dev-supervisor.d.ts +27 -0
  40. package/dist/lib/dev-supervisor.d.ts.map +1 -1
  41. package/dist/lib/open-url.d.ts +3 -0
  42. package/dist/lib/open-url.d.ts.map +1 -0
  43. package/dist/lib/role-lifecycle.d.ts.map +1 -1
  44. package/dist/lib/runtime.d.ts +10 -0
  45. package/dist/lib/runtime.d.ts.map +1 -1
  46. package/dist/lib/worker-concurrency.d.ts +11 -0
  47. package/dist/lib/worker-concurrency.d.ts.map +1 -1
  48. package/dist/lib/worker-registry.d.ts +2 -0
  49. package/dist/lib/worker-registry.d.ts.map +1 -1
  50. package/dist/ui/deploy-screens.d.ts +48 -0
  51. package/dist/ui/deploy-screens.d.ts.map +1 -0
  52. package/dist/ui/index.d.ts +28 -233
  53. package/dist/ui/index.d.ts.map +1 -1
  54. package/dist/ui/layout.d.ts +65 -0
  55. package/dist/ui/layout.d.ts.map +1 -0
  56. package/dist/ui/live/ansi.d.ts +8 -0
  57. package/dist/ui/live/ansi.d.ts.map +1 -0
  58. package/dist/ui/live/can-run-live.d.ts +6 -0
  59. package/dist/ui/live/can-run-live.d.ts.map +1 -0
  60. package/dist/ui/live/components.d.ts +17 -0
  61. package/dist/ui/live/components.d.ts.map +1 -0
  62. package/dist/ui/live/deploy.d.ts +22 -0
  63. package/dist/ui/live/deploy.d.ts.map +1 -0
  64. package/dist/ui/live/dev.d.ts +47 -0
  65. package/dist/ui/live/dev.d.ts.map +1 -0
  66. package/dist/ui/live/prompt.d.ts +30 -0
  67. package/dist/ui/live/prompt.d.ts.map +1 -0
  68. package/dist/ui/live/session.d.ts +27 -0
  69. package/dist/ui/live/session.d.ts.map +1 -0
  70. package/dist/ui/screens.d.ts +136 -0
  71. package/dist/ui/screens.d.ts.map +1 -0
  72. package/dist/ui/theme.d.ts +58 -0
  73. package/dist/ui/theme.d.ts.map +1 -0
  74. package/package.json +21 -19
  75. package/src/commands/{api.tsx → api.ts} +18 -27
  76. package/src/commands/{app.tsx → app.ts} +14 -18
  77. package/src/commands/build.ts +70 -0
  78. package/src/commands/{check.tsx → check.ts} +74 -19
  79. package/src/commands/db-migrate.ts +32 -0
  80. package/src/commands/{deploy.tsx → deploy.ts} +109 -102
  81. package/src/commands/desktop.ts +71 -0
  82. package/src/commands/{dev-runner.tsx → dev-runner.ts} +67 -33
  83. package/src/commands/{init.tsx → init.ts} +19 -8
  84. package/src/commands/lake-check.ts +36 -0
  85. package/src/commands/{lake-cleanup.tsx → lake-cleanup.ts} +24 -8
  86. package/src/commands/{login.tsx → login.ts} +36 -30
  87. package/src/commands/{logout.tsx → logout.ts} +5 -5
  88. package/src/commands/{orchestrator.tsx → orchestrator.ts} +15 -28
  89. package/src/commands/{profile.tsx → profile.ts} +38 -19
  90. package/src/commands/{rules.tsx → rules.ts} +15 -24
  91. package/src/commands/{scheduler.tsx → scheduler.ts} +14 -27
  92. package/src/commands/{service-account.tsx → service-account.ts} +37 -39
  93. package/src/commands/{status.tsx → status.ts} +8 -8
  94. package/src/commands/{token.tsx → token.ts} +19 -20
  95. package/src/commands/typegen.ts +18 -0
  96. package/src/commands/{worker-group.tsx → worker-group.ts} +40 -29
  97. package/src/commands/{worker.tsx → worker.ts} +30 -22
  98. package/src/index.tsx +22 -1
  99. package/src/lib/command-line.ts +108 -57
  100. package/src/lib/deploy-release.ts +17 -1
  101. package/src/lib/desktop.ts +52 -0
  102. package/src/lib/dev-messages.ts +44 -0
  103. package/src/lib/dev-supervisor.ts +132 -12
  104. package/src/lib/open-url.ts +15 -0
  105. package/src/lib/role-lifecycle.ts +2 -3
  106. package/src/lib/runtime.ts +21 -0
  107. package/src/lib/worker-concurrency.ts +31 -0
  108. package/src/lib/worker-registry.ts +4 -0
  109. package/src/ui/README.md +54 -0
  110. package/src/ui/deploy-screens.ts +360 -0
  111. package/src/ui/index.ts +158 -0
  112. package/src/ui/layout.ts +245 -0
  113. package/src/ui/live/ansi.ts +103 -0
  114. package/src/ui/live/can-run-live.ts +9 -0
  115. package/src/ui/live/components.tsx +81 -0
  116. package/src/ui/live/deploy.tsx +170 -0
  117. package/src/ui/live/dev.tsx +522 -0
  118. package/src/ui/live/prompt.tsx +205 -0
  119. package/src/ui/live/session.ts +103 -0
  120. package/src/ui/screens.ts +490 -0
  121. package/src/ui/theme.ts +122 -0
  122. package/dist/lib/role-view.d.ts +0 -21
  123. package/dist/lib/role-view.d.ts.map +0 -1
  124. package/src/commands/build.tsx +0 -65
  125. package/src/commands/db-migrate.tsx +0 -30
  126. package/src/commands/lake-check.tsx +0 -20
  127. package/src/commands/typegen.tsx +0 -18
  128. package/src/lib/role-view.ts +0 -49
  129. package/src/ui/index.tsx +0 -1363
  130. /package/src/commands/{dev.tsx → dev.ts} +0 -0
@@ -10,7 +10,7 @@ import {
10
10
  } from "@sixb/client"
11
11
  import { createCliSixbClient, unwrapSixbApiResult } from "../lib/api-client"
12
12
  import { resolveProfileApiClientConfig } from "../lib/profile-api-client"
13
- import { KeyValueResultView, renderStatic, SecretResultView, TableResultView } from "../ui"
13
+ import { keyValueResultView, renderStatic, secretResultView, tableResultView } from "../ui"
14
14
  import {
15
15
  assertSignedIn,
16
16
  formatDate,
@@ -70,13 +70,12 @@ async function listServiceAccounts(options: ServiceAccountCommandOptions) {
70
70
  }
71
71
 
72
72
  await renderStatic(
73
- <TableResultView
74
- title="Service accounts"
75
- subtitle={`${result.serviceAccounts.length} visible`}
76
- headers={["Name", "ID", "Status", "Groups", "Updated"]}
77
- rows={result.serviceAccounts.map(serviceAccountRow)}
78
- emptyMessage="No service accounts."
79
- />
73
+ tableResultView({
74
+ subtitle: `${result.serviceAccounts.length} visible`,
75
+ headers: ["Name", "ID", "Status", "Groups", "Updated"],
76
+ rows: result.serviceAccounts.map(serviceAccountRow),
77
+ emptyMessage: "No service accounts.",
78
+ })
80
79
  )
81
80
  }
82
81
 
@@ -108,15 +107,15 @@ async function createServiceAccount(options: ServiceAccountCommandOptions) {
108
107
  }
109
108
 
110
109
  await renderStatic(
111
- <KeyValueResultView
112
- title="Created service account"
113
- items={[
110
+ keyValueResultView({
111
+ title: "Created service account",
112
+ items: [
114
113
  { label: "Name", value: result.serviceAccount.name },
115
114
  { label: "ID", value: result.serviceAccount.id },
116
115
  { label: "Status", value: result.serviceAccount.status },
117
116
  { label: "Groups", value: formatGroups(result.serviceAccount.groupIds) },
118
- ]}
119
- />
117
+ ],
118
+ })
120
119
  )
121
120
  }
122
121
 
@@ -140,14 +139,14 @@ async function disableServiceAccount(options: ServiceAccountCommandOptions) {
140
139
  }
141
140
 
142
141
  await renderStatic(
143
- <KeyValueResultView
144
- title="Disabled service account"
145
- items={[
142
+ keyValueResultView({
143
+ title: "Disabled service account",
144
+ items: [
146
145
  { label: "Name", value: result.serviceAccount.name },
147
146
  { label: "ID", value: result.serviceAccount.id },
148
147
  { label: "Status", value: result.serviceAccount.status },
149
- ]}
150
- />
148
+ ],
149
+ })
151
150
  )
152
151
  }
153
152
 
@@ -190,20 +189,19 @@ async function listServiceAccountTokens(options: ServiceAccountCommandOptions) {
190
189
  }
191
190
 
192
191
  await renderStatic(
193
- <TableResultView
194
- title="Service-account tokens"
195
- subtitle={serviceAccountId}
196
- headers={["Name", "ID", "Status", "Groups", "Last used", "Expires"]}
197
- rows={result.accessTokens.map((token) => [
192
+ tableResultView({
193
+ subtitle: serviceAccountId,
194
+ headers: ["Name", "ID", "Status", "Groups", "Last used", "Expires"],
195
+ rows: result.accessTokens.map((token) => [
198
196
  token.name,
199
197
  token.id,
200
198
  token.status,
201
199
  formatGroups(token.groupIds),
202
200
  formatDate(token.lastUsedAt),
203
201
  formatDate(token.expiresAt),
204
- ])}
205
- emptyMessage="No service-account tokens."
206
- />
202
+ ]),
203
+ emptyMessage: "No service-account tokens.",
204
+ })
207
205
  )
208
206
  }
209
207
 
@@ -240,17 +238,17 @@ async function createServiceAccountToken(options: ServiceAccountCommandOptions)
240
238
  }
241
239
 
242
240
  await renderStatic(
243
- <SecretResultView
244
- title="Created service-account token"
245
- subtitle={serviceAccountId}
246
- items={[
241
+ secretResultView({
242
+ title: "Created service-account token",
243
+ subtitle: serviceAccountId,
244
+ items: [
247
245
  { label: "Name", value: result.accessToken.name },
248
246
  { label: "ID", value: result.accessToken.id },
249
247
  { label: "Expires", value: formatDate(result.accessToken.expiresAt) },
250
248
  { label: "Groups", value: formatGroups(result.accessToken.groupIds) },
251
- ]}
252
- secret={result.tokenValue}
253
- />
249
+ ],
250
+ secret: result.tokenValue,
251
+ })
254
252
  )
255
253
  }
256
254
 
@@ -278,15 +276,15 @@ async function revokeServiceAccountToken(options: ServiceAccountCommandOptions)
278
276
  }
279
277
 
280
278
  await renderStatic(
281
- <KeyValueResultView
282
- title="Revoked service-account token"
283
- subtitle={serviceAccountId}
284
- items={[
279
+ keyValueResultView({
280
+ title: "Revoked service-account token",
281
+ subtitle: serviceAccountId,
282
+ items: [
285
283
  { label: "Name", value: result.accessToken.name },
286
284
  { label: "ID", value: result.accessToken.id },
287
285
  { label: "Status", value: result.accessToken.status },
288
- ]}
289
- />
286
+ ],
287
+ })
290
288
  )
291
289
  }
292
290
 
@@ -1,6 +1,6 @@
1
1
  import { CliError, createInstanceApiClient, writeJson } from "@sixb/cli-core"
2
2
  import { resolveProfile } from "../lib/profiles"
3
- import { KeyValueResultView, renderStatic } from "../ui"
3
+ import { keyValueResultView, renderStatic } from "../ui"
4
4
 
5
5
  export interface StatusCommandOptions {
6
6
  readonly apiUrl?: string
@@ -62,10 +62,10 @@ async function renderStatus(input: {
62
62
  }
63
63
 
64
64
  await renderStatic(
65
- <KeyValueResultView
66
- title={input.message ? "Authentication failed" : "Connected"}
67
- titleColor={input.message ? "red" : "green"}
68
- items={[
65
+ keyValueResultView({
66
+ title: input.message ? "Authentication failed" : "Connected",
67
+ titleColor: input.message ? "red" : "green",
68
+ items: [
69
69
  ...(input.profile ? [{ label: "Profile", value: input.profile }] : []),
70
70
  ...(input.projectId ? [{ label: "Project", value: input.projectId }] : []),
71
71
  { label: "API", value: input.apiUrl },
@@ -73,9 +73,9 @@ async function renderStatus(input: {
73
73
  label: "Authentication",
74
74
  value: input.authenticated ? "token" : input.message ? "failed" : "not required",
75
75
  },
76
- ]}
77
- message={input.message}
78
- />
76
+ ],
77
+ message: input.message,
78
+ })
79
79
  )
80
80
  }
81
81
 
@@ -6,7 +6,7 @@ import {
6
6
  } from "@sixb/client"
7
7
  import { createCliSixbClient, unwrapSixbApiResult } from "../lib/api-client"
8
8
  import { resolveProfileApiClientConfig } from "../lib/profile-api-client"
9
- import { KeyValueResultView, renderStatic, SecretResultView, TableResultView } from "../ui"
9
+ import { keyValueResultView, renderStatic, secretResultView, tableResultView } from "../ui"
10
10
  import {
11
11
  assertSignedIn,
12
12
  formatDate,
@@ -59,20 +59,19 @@ async function listTokens(options: TokenCommandOptions) {
59
59
  }
60
60
 
61
61
  await renderStatic(
62
- <TableResultView
63
- title="Personal access tokens"
64
- subtitle={`${result.accessTokens.length} visible`}
65
- headers={["Name", "ID", "Status", "Groups", "Last used", "Expires"]}
66
- rows={result.accessTokens.map((token) => [
62
+ tableResultView({
63
+ subtitle: `${result.accessTokens.length} visible`,
64
+ headers: ["Name", "ID", "Status", "Groups", "Last used", "Expires"],
65
+ rows: result.accessTokens.map((token) => [
67
66
  token.name,
68
67
  token.id,
69
68
  token.status,
70
69
  formatGroups(token.groupIds),
71
70
  formatDate(token.lastUsedAt),
72
71
  formatDate(token.expiresAt),
73
- ])}
74
- emptyMessage="No personal access tokens."
75
- />
72
+ ]),
73
+ emptyMessage: "No personal access tokens.",
74
+ })
76
75
  )
77
76
  }
78
77
 
@@ -104,16 +103,16 @@ async function createToken(options: TokenCommandOptions) {
104
103
  }
105
104
 
106
105
  await renderStatic(
107
- <SecretResultView
108
- title="Created personal access token"
109
- items={[
106
+ secretResultView({
107
+ title: "Created personal access token",
108
+ items: [
110
109
  { label: "Name", value: result.accessToken.name },
111
110
  { label: "ID", value: result.accessToken.id },
112
111
  { label: "Expires", value: formatDate(result.accessToken.expiresAt) },
113
112
  { label: "Groups", value: formatGroups(result.accessToken.groupIds) },
114
- ]}
115
- secret={result.tokenValue}
116
- />
113
+ ],
114
+ secret: result.tokenValue,
115
+ })
117
116
  )
118
117
  }
119
118
 
@@ -137,13 +136,13 @@ async function revokeToken(options: TokenCommandOptions) {
137
136
  }
138
137
 
139
138
  await renderStatic(
140
- <KeyValueResultView
141
- title="Revoked personal access token"
142
- items={[
139
+ keyValueResultView({
140
+ title: "Revoked personal access token",
141
+ items: [
143
142
  { label: "Name", value: result.accessToken.name },
144
143
  { label: "ID", value: result.accessToken.id },
145
144
  { label: "Status", value: result.accessToken.status },
146
- ]}
147
- />
145
+ ],
146
+ })
148
147
  )
149
148
  }
@@ -0,0 +1,18 @@
1
+ import { generateProjectTypes } from "../lib/typegen"
2
+ import { renderStatic, typegenView, withTask } from "../ui"
3
+
4
+ export interface TypegenOptions {
5
+ entry?: string
6
+ }
7
+
8
+ export async function runTypegen(options: TypegenOptions = {}) {
9
+ const result = await withTask("typegen", "Generating types", () => generateProjectTypes(options))
10
+ await renderStatic(
11
+ typegenView({
12
+ path: result.path,
13
+ objectTypes: result.entries.length,
14
+ skipped: result.skipped,
15
+ written: result.written,
16
+ })
17
+ )
18
+ }
@@ -5,7 +5,11 @@ import { runUntilSignal, stopQuietly } from "../lib/role-lifecycle"
5
5
  import { recordApiPublicOrigin, stopSixbProviders, waitForWorkerFailure } from "../lib/runtime"
6
6
  import { assertShareableProviders } from "../lib/shareable-providers"
7
7
  import { migrateStorageForRole } from "../lib/storage-migration"
8
- import { resolveVectorConcurrency, resolveWorkerConcurrency } from "../lib/worker-concurrency"
8
+ import {
9
+ resolveSubagentConcurrency,
10
+ resolveVectorConcurrency,
11
+ resolveWorkerConcurrency,
12
+ } from "../lib/worker-concurrency"
9
13
  import {
10
14
  agentRuntimeRequired,
11
15
  assertWorkerInputs,
@@ -14,7 +18,14 @@ import {
14
18
  resolveRegisteredWorkerTypes,
15
19
  resolveWorkerTypeToStart,
16
20
  } from "../lib/worker-registry"
17
- import { LoadingView, renderCliError, renderPersistent, WorkerGroupView } from "../ui"
21
+ import {
22
+ printStopping,
23
+ renderCliError,
24
+ renderStatic,
25
+ roleView,
26
+ startTask,
27
+ workerItems,
28
+ } from "../ui"
18
29
 
19
30
  export interface WorkerGroupOptions {
20
31
  entry?: string
@@ -24,6 +35,8 @@ export interface WorkerGroupOptions {
24
35
  agentTurnTimeout?: string
25
36
  concurrency?: readonly string[]
26
37
  vectorConcurrency?: string
38
+ subagentConcurrency?: string
39
+ subagentConcurrencyPerRun?: string
27
40
  }
28
41
 
29
42
  export async function runWorkerGroup(options: WorkerGroupOptions = {}) {
@@ -35,11 +48,13 @@ export async function runWorkerGroup(options: WorkerGroupOptions = {}) {
35
48
  const agentTurnTimeoutMs = resolveAgentTurnTimeoutMs(options.agentTurnTimeout)
36
49
  const workerConcurrency = resolveWorkerConcurrency(options.concurrency)
37
50
  const vectorConcurrency = resolveVectorConcurrency(options.vectorConcurrency)
51
+ const subagents = resolveSubagentConcurrency({
52
+ perWorker: options.subagentConcurrency,
53
+ perRun: options.subagentConcurrencyPerRun,
54
+ })
38
55
  const entry = await resolveRuntimeEntry({ entry: options.entry })
39
56
 
40
- const app = renderPersistent(
41
- <LoadingView title="Starting sixb worker group" subtitle={entry} status="Loading runtime" />
42
- )
57
+ const app = startTask("worker-group", "Loading runtime")
43
58
 
44
59
  let sixb: LoadedSixbHost | null = null
45
60
  let workers: QueueWorkerProcess[] = []
@@ -74,19 +89,10 @@ export async function runWorkerGroup(options: WorkerGroupOptions = {}) {
74
89
  const migration = await migrateStorageForRole(sixb, {
75
90
  role: "worker-group",
76
91
  noMigrate: options.noMigrate,
77
- onStart: () =>
78
- app.rerender(
79
- <LoadingView
80
- title="Starting sixb worker group"
81
- subtitle={entry}
82
- status="Migrating storage"
83
- />
84
- ),
92
+ onStart: () => app.step("Migrating storage"),
85
93
  })
86
94
 
87
- app.rerender(
88
- <LoadingView title="Starting sixb worker group" subtitle={entry} status="Starting workers" />
89
- )
95
+ app.step("Starting workers")
90
96
 
91
97
  const host = sixb
92
98
  workers = workerTypes.map((workerType) =>
@@ -95,6 +101,7 @@ export async function runWorkerGroup(options: WorkerGroupOptions = {}) {
95
101
  agentTurnTimeoutMs,
96
102
  workerConcurrency,
97
103
  vectorConcurrency,
104
+ ...subagents,
98
105
  })
99
106
  )
100
107
  await Promise.all(workers.map((worker) => worker.start()))
@@ -104,29 +111,33 @@ export async function runWorkerGroup(options: WorkerGroupOptions = {}) {
104
111
  ? ["No queue worker types are registered; the worker group process is idle."]
105
112
  : []
106
113
 
107
- app.rerender(
108
- <WorkerGroupView
109
- name={sixb.id}
110
- workers={workerTypes.map((workerType, index) => ({
111
- type: workerType,
112
- concurrency: workers[index]?.concurrency ?? 1,
113
- }))}
114
- storage={migration.summary}
115
- warnings={warnings}
116
- />
114
+ app.stop()
115
+ await renderStatic(
116
+ roleView({
117
+ command: "worker-group",
118
+ name: sixb.id,
119
+ items: workerItems(
120
+ workerTypes.map((workerType, index) => ({
121
+ type: workerType,
122
+ concurrency: workers[index]?.concurrency ?? 1,
123
+ }))
124
+ ),
125
+ storage: migration.summary,
126
+ warnings,
127
+ })
117
128
  )
118
129
 
119
130
  await Promise.race([
120
131
  runUntilSignal(async () => {
121
- app.unmount()
122
- console.log("\nShutting down worker group...")
132
+ app.stop()
133
+ printStopping("worker-group")
123
134
  await stopWorkersAndProviders()
124
135
  sixb = null
125
136
  }),
126
137
  ...workers.map(waitForWorkerFailure),
127
138
  ])
128
139
  } catch (error) {
129
- app.unmount()
140
+ app.stop()
130
141
  await stopWorkersAndProviders()
131
142
  await renderCliError(error)
132
143
  process.exit(1)
@@ -6,7 +6,11 @@ import { runUntilSignal, stopQuietly } from "../lib/role-lifecycle"
6
6
  import { recordApiPublicOrigin, stopSixbProviders, waitForWorkerFailure } from "../lib/runtime"
7
7
  import { assertShareableProviders } from "../lib/shareable-providers"
8
8
  import { migrateStorageForRole } from "../lib/storage-migration"
9
- import { resolveSingleWorkerConcurrency, resolveVectorConcurrency } from "../lib/worker-concurrency"
9
+ import {
10
+ resolveSingleWorkerConcurrency,
11
+ resolveSubagentConcurrency,
12
+ resolveVectorConcurrency,
13
+ } from "../lib/worker-concurrency"
10
14
  import {
11
15
  agentRuntimeRequired,
12
16
  createWorkerForType,
@@ -14,7 +18,7 @@ import {
14
18
  resolveWorkerTypeToStart,
15
19
  unmetWorkerRequirement,
16
20
  } from "../lib/worker-registry"
17
- import { LoadingView, renderCliError, renderPersistent, WorkerView } from "../ui"
21
+ import { printStopping, renderCliError, renderStatic, roleView, startTask } from "../ui"
18
22
 
19
23
  export interface WorkerOptions {
20
24
  entry?: string
@@ -24,6 +28,8 @@ export interface WorkerOptions {
24
28
  agentTurnTimeout?: string
25
29
  concurrency?: string
26
30
  vectorConcurrency?: string
31
+ subagentConcurrency?: string
32
+ subagentConcurrencyPerRun?: string
27
33
  }
28
34
 
29
35
  export async function runWorker(options: WorkerOptions = {}) {
@@ -33,11 +39,13 @@ export async function runWorker(options: WorkerOptions = {}) {
33
39
  const agentTurnTimeoutMs = resolveAgentTurnTimeoutMs(options.agentTurnTimeout)
34
40
  const workerConcurrency = resolveSingleWorkerConcurrency(workerType, options.concurrency)
35
41
  const vectorConcurrency = resolveVectorConcurrency(options.vectorConcurrency)
42
+ const subagents = resolveSubagentConcurrency({
43
+ perWorker: options.subagentConcurrency,
44
+ perRun: options.subagentConcurrencyPerRun,
45
+ })
36
46
  const entry = await resolveRuntimeEntry({ entry: options.entry })
37
47
 
38
- const app = renderPersistent(
39
- <LoadingView title="Starting sixb worker" subtitle={entry} status="Loading runtime" />
40
- )
48
+ const app = startTask("worker", "Loading runtime")
41
49
 
42
50
  let sixb: LoadedSixbHost | null = null
43
51
  let worker: QueueWorkerProcess | null = null
@@ -64,38 +72,38 @@ export async function runWorker(options: WorkerOptions = {}) {
64
72
  const migration = await migrateStorageForRole(sixb, {
65
73
  role: "worker",
66
74
  noMigrate: options.noMigrate,
67
- onStart: () =>
68
- app.rerender(
69
- <LoadingView title="Starting sixb worker" subtitle={entry} status="Migrating storage" />
70
- ),
75
+ onStart: () => app.step("Migrating storage"),
71
76
  })
72
77
 
73
- app.rerender(
74
- <LoadingView title="Starting sixb worker" subtitle={entry} status="Starting worker" />
75
- )
78
+ app.step("Starting worker")
76
79
 
77
80
  worker = createWorkerForType(sixb, workerType, {
78
81
  agentApiBaseUrl: options.apiPublicOrigin,
79
82
  agentTurnTimeoutMs,
80
83
  workerConcurrency,
81
84
  vectorConcurrency,
85
+ ...subagents,
82
86
  })
83
87
  await worker.start()
84
88
 
85
89
  const workerId = `${workerType}-worker-${sixb.id}`
86
- app.rerender(
87
- <WorkerView
88
- name={sixb.id}
89
- workerId={workerId}
90
- concurrency={worker.concurrency}
91
- storage={migration.summary}
92
- />
90
+ app.stop()
91
+ await renderStatic(
92
+ roleView({
93
+ command: `worker ${workerType}`,
94
+ name: sixb.id,
95
+ items: [
96
+ { label: "worker", value: workerId },
97
+ { label: "concurrency", value: String(worker.concurrency) },
98
+ ],
99
+ storage: migration.summary,
100
+ })
93
101
  )
94
102
 
95
103
  await Promise.race([
96
104
  runUntilSignal(async () => {
97
- app.unmount()
98
- console.log("\nShutting down worker...")
105
+ app.stop()
106
+ printStopping("worker")
99
107
  await stopQuietly(() => worker?.stop() ?? Promise.resolve())
100
108
  if (sixb) {
101
109
  await stopSixbProviders(sixb)
@@ -105,7 +113,7 @@ export async function runWorker(options: WorkerOptions = {}) {
105
113
  waitForWorkerFailure(worker),
106
114
  ])
107
115
  } catch (error) {
108
- app.unmount()
116
+ app.stop()
109
117
  await stopQuietly(() => worker?.stop() ?? Promise.resolve())
110
118
  if (sixb) {
111
119
  await stopSixbProviders(sixb)
package/src/index.tsx CHANGED
@@ -87,6 +87,9 @@ async function main(): Promise<void> {
87
87
  return
88
88
  }
89
89
 
90
+ // Plain strings, no renderer: cheap enough to load for every command.
91
+ const { setCommandPath } = await import("./ui/layout")
92
+ setCommandPath(parsed.path)
90
93
  const { options, positionals } = parsed
91
94
  const getFlag = (name: CliOptionName) => stringOption(options, name)
92
95
  const getFlags = (name: CliOptionName) => repeatedOption(options, name)
@@ -106,6 +109,9 @@ async function main(): Promise<void> {
106
109
  agentTurnTimeout: getFlag("agent-turn-timeout"),
107
110
  concurrency: getFlags("concurrency"),
108
111
  vectorConcurrency: getFlag("vector-concurrency"),
112
+ subagentConcurrency: getFlag("subagent-concurrency"),
113
+ subagentConcurrencyPerRun: getFlag("subagent-concurrency-per-run"),
114
+ desktop: hasFlag("desktop"),
109
115
  })
110
116
  break
111
117
  }
@@ -120,6 +126,8 @@ async function main(): Promise<void> {
120
126
  agentTurnTimeout: getFlag("agent-turn-timeout"),
121
127
  concurrency: getFlag("concurrency"),
122
128
  vectorConcurrency: getFlag("vector-concurrency"),
129
+ subagentConcurrency: getFlag("subagent-concurrency"),
130
+ subagentConcurrencyPerRun: getFlag("subagent-concurrency-per-run"),
123
131
  })
124
132
  break
125
133
  }
@@ -134,6 +142,8 @@ async function main(): Promise<void> {
134
142
  agentTurnTimeout: getFlag("agent-turn-timeout"),
135
143
  concurrency: getFlags("concurrency"),
136
144
  vectorConcurrency: getFlag("vector-concurrency"),
145
+ subagentConcurrency: getFlag("subagent-concurrency"),
146
+ subagentConcurrencyPerRun: getFlag("subagent-concurrency-per-run"),
137
147
  })
138
148
  break
139
149
  }
@@ -287,6 +297,15 @@ async function main(): Promise<void> {
287
297
  break
288
298
  }
289
299
 
300
+ case "desktop:build": {
301
+ const { runDesktopBuild } = await import("./commands/desktop")
302
+ await runDesktopBuild({
303
+ apiPublicOrigin: getFlag("api-public-origin"),
304
+ appPublicOrigin: getFlag("app-public-origin"),
305
+ })
306
+ break
307
+ }
308
+
290
309
  case "db:prepare": {
291
310
  const { runDbPrepare } = await import("./commands/db-prepare")
292
311
  await runDbPrepare({ entry: getFlag("entry") })
@@ -395,9 +414,11 @@ main().catch(async (error) => {
395
414
  if (wantsManagementJson(args)) {
396
415
  process.stderr.write(`${JSON.stringify({ error: cliErrorBody(error) })}\n`)
397
416
  } else {
398
- // Loaded on demand, and never through JSX here: see `renderHelp` in `./ui`.
417
+ // Loaded on demand: a command that succeeds never needs it.
399
418
  const { renderCliError, renderHelp } = await import("./ui")
400
419
  if (error instanceof CliUsageError) await renderHelp(error.help, error.message)
420
+ // Backing out of a prompt is an answer, not a failure to explain.
421
+ else if (error instanceof Error && error.name === "PromptCancelledError") process.exit(130)
401
422
  else await renderCliError(error)
402
423
  }
403
424
  process.exit(exitCode)