@sixb/cli 0.1.1 → 0.1.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.
- package/README.md +5 -2
- package/dist/commands/api.d.ts.map +1 -1
- package/dist/commands/dev.d.ts +2 -0
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/worker-group.d.ts +2 -0
- package/dist/commands/worker-group.d.ts.map +1 -1
- package/dist/commands/worker.d.ts +2 -0
- package/dist/commands/worker.d.ts.map +1 -1
- package/dist/lib/agent-turn-timeout.d.ts +6 -0
- package/dist/lib/agent-turn-timeout.d.ts.map +1 -0
- package/dist/lib/health.d.ts +3 -3
- package/dist/lib/health.d.ts.map +1 -1
- package/dist/lib/loadSixb.d.ts +3 -48
- package/dist/lib/loadSixb.d.ts.map +1 -1
- package/dist/lib/production.d.ts +2 -2
- package/dist/lib/production.d.ts.map +1 -1
- package/dist/lib/runtime.d.ts +11 -8
- package/dist/lib/runtime.d.ts.map +1 -1
- package/dist/lib/shareable-providers.d.ts +3 -3
- package/dist/lib/shareable-providers.d.ts.map +1 -1
- package/dist/lib/storage-migration.d.ts +2 -2
- package/dist/lib/storage-migration.d.ts.map +1 -1
- package/dist/lib/worker-concurrency.d.ts +9 -0
- package/dist/lib/worker-concurrency.d.ts.map +1 -0
- package/dist/lib/worker-registry.d.ts +41 -4
- package/dist/lib/worker-registry.d.ts.map +1 -1
- package/dist/ui/index.d.ts +12 -16
- package/dist/ui/index.d.ts.map +1 -1
- package/package.json +16 -16
- package/src/commands/api.tsx +9 -4
- package/src/commands/app.tsx +2 -2
- package/src/commands/atlas.tsx +2 -2
- package/src/commands/check.tsx +1 -1
- package/src/commands/dev.tsx +38 -16
- package/src/commands/orchestrator.tsx +2 -2
- package/src/commands/rules.tsx +2 -2
- package/src/commands/scheduler.tsx +2 -2
- package/src/commands/worker-group.tsx +18 -6
- package/src/commands/worker.tsx +20 -5
- package/src/index.tsx +19 -3
- package/src/lib/agent-turn-timeout.ts +40 -0
- package/src/lib/health.ts +8 -8
- package/src/lib/loadSixb.ts +70 -105
- package/src/lib/production.ts +2 -2
- package/src/lib/runtime.ts +59 -42
- package/src/lib/shareable-providers.ts +6 -6
- package/src/lib/storage-migration.ts +3 -3
- package/src/lib/worker-concurrency.ts +127 -0
- package/src/lib/worker-registry.ts +68 -27
- package/src/ui/index.tsx +35 -71
|
@@ -6,15 +6,49 @@ import { ProjectionWorker } from "@sixb/projection-worker"
|
|
|
6
6
|
import { SyncWorker } from "@sixb/sync-worker"
|
|
7
7
|
import { WorkflowWorker } from "@sixb/workflow-worker"
|
|
8
8
|
import { SixbCliError } from "./errors"
|
|
9
|
-
import type {
|
|
9
|
+
import type { LoadedSixbHost } from "./loadSixb"
|
|
10
10
|
import { configuredOrigin } from "./public-origin"
|
|
11
11
|
|
|
12
|
+
export const WORKER_TYPES = [
|
|
13
|
+
"sync",
|
|
14
|
+
"action",
|
|
15
|
+
"agent",
|
|
16
|
+
"pipeline",
|
|
17
|
+
"projection",
|
|
18
|
+
"workflow",
|
|
19
|
+
] as const
|
|
20
|
+
|
|
21
|
+
export type WorkerType = (typeof WORKER_TYPES)[number]
|
|
22
|
+
|
|
23
|
+
export const WORKER_CONCURRENCY_CONFIG = {
|
|
24
|
+
sync: { configurable: true, environmentVariable: "SIXB_SYNC_WORKER_CONCURRENCY" },
|
|
25
|
+
action: { configurable: false, environmentVariable: "SIXB_ACTION_WORKER_CONCURRENCY" },
|
|
26
|
+
agent: { configurable: true, environmentVariable: "SIXB_AGENT_WORKER_CONCURRENCY" },
|
|
27
|
+
pipeline: { configurable: true, environmentVariable: "SIXB_PIPELINE_WORKER_CONCURRENCY" },
|
|
28
|
+
projection: { configurable: true, environmentVariable: "SIXB_PROJECTION_WORKER_CONCURRENCY" },
|
|
29
|
+
workflow: { configurable: true, environmentVariable: "SIXB_WORKFLOW_WORKER_CONCURRENCY" },
|
|
30
|
+
} as const satisfies Record<
|
|
31
|
+
WorkerType,
|
|
32
|
+
{ readonly configurable: boolean; readonly environmentVariable: string }
|
|
33
|
+
>
|
|
34
|
+
|
|
35
|
+
export type ConfigurableWorkerType = {
|
|
36
|
+
[Type in WorkerType]: (typeof WORKER_CONCURRENCY_CONFIG)[Type]["configurable"] extends true
|
|
37
|
+
? Type
|
|
38
|
+
: never
|
|
39
|
+
}[WorkerType]
|
|
40
|
+
|
|
41
|
+
export type WorkerConcurrency = Readonly<Partial<Record<ConfigurableWorkerType, number>>>
|
|
42
|
+
export type QueueWorkerProcess = Worker & { readonly concurrency: number }
|
|
43
|
+
|
|
12
44
|
export interface WorkerCreationOptions {
|
|
13
45
|
readonly agentApiBaseUrl?: string
|
|
46
|
+
readonly agentTurnTimeoutMs?: number
|
|
47
|
+
readonly workerConcurrency?: WorkerConcurrency
|
|
14
48
|
}
|
|
15
49
|
|
|
16
50
|
interface WorkerFactory {
|
|
17
|
-
readonly create: (sixb:
|
|
51
|
+
readonly create: (sixb: LoadedSixbHost, options: WorkerCreationOptions) => QueueWorkerProcess
|
|
18
52
|
/**
|
|
19
53
|
* Why this worker cannot be constructed with the given options, or `null` when it can.
|
|
20
54
|
* Asked before anything is constructed, so a group names every reason at once.
|
|
@@ -28,9 +62,10 @@ interface WorkerFactory {
|
|
|
28
62
|
const AGENT_ORIGIN_REQUIRED =
|
|
29
63
|
"requires --api-public-origin or SIXB_API_PUBLIC_ORIGIN (agent workers call the API)"
|
|
30
64
|
|
|
31
|
-
const workerFactories: Record<
|
|
65
|
+
const workerFactories: Record<WorkerType, WorkerFactory> = {
|
|
32
66
|
sync: {
|
|
33
|
-
create: (sixb) =>
|
|
67
|
+
create: (sixb, options) =>
|
|
68
|
+
new SyncWorker(sixb, { concurrency: options.workerConcurrency?.sync }),
|
|
34
69
|
},
|
|
35
70
|
action: {
|
|
36
71
|
create: (sixb) => new ActionWorker(sixb),
|
|
@@ -39,27 +74,32 @@ const workerFactories: Record<string, WorkerFactory> = {
|
|
|
39
74
|
create: (sixb, options) =>
|
|
40
75
|
new AgentWorker(sixb, {
|
|
41
76
|
apiBaseUrl: resolveAgentApiBaseUrl(options.agentApiBaseUrl),
|
|
77
|
+
concurrency: options.workerConcurrency?.agent,
|
|
78
|
+
turnTimeoutMs: options.agentTurnTimeoutMs,
|
|
42
79
|
}),
|
|
43
80
|
unmetRequirement: (options) =>
|
|
44
81
|
agentApiBaseUrl(options.agentApiBaseUrl) ? null : AGENT_ORIGIN_REQUIRED,
|
|
45
82
|
},
|
|
46
83
|
pipeline: {
|
|
47
|
-
create: (sixb) =>
|
|
84
|
+
create: (sixb, options) =>
|
|
85
|
+
new PipelineWorker(sixb, { concurrency: options.workerConcurrency?.pipeline }),
|
|
48
86
|
},
|
|
49
87
|
projection: {
|
|
50
|
-
create: (sixb) =>
|
|
88
|
+
create: (sixb, options) =>
|
|
89
|
+
new ProjectionWorker(sixb, { concurrency: options.workerConcurrency?.projection }),
|
|
51
90
|
},
|
|
52
91
|
workflow: {
|
|
53
|
-
create: (sixb) =>
|
|
92
|
+
create: (sixb, options) =>
|
|
93
|
+
new WorkflowWorker(sixb, { concurrency: options.workerConcurrency?.workflow }),
|
|
54
94
|
},
|
|
55
95
|
}
|
|
56
96
|
|
|
57
97
|
export function createWorkerForType(
|
|
58
|
-
sixb:
|
|
98
|
+
sixb: LoadedSixbHost,
|
|
59
99
|
workerType: string,
|
|
60
100
|
options: WorkerCreationOptions = {}
|
|
61
|
-
):
|
|
62
|
-
const factory = workerFactories[workerType]
|
|
101
|
+
): QueueWorkerProcess {
|
|
102
|
+
const factory = isWorkerType(workerType) ? workerFactories[workerType] : undefined
|
|
63
103
|
if (!factory) {
|
|
64
104
|
throw new Error(`[SixbWorker] Unknown worker '${workerType}'. Available: ${knownWorkers()}`)
|
|
65
105
|
}
|
|
@@ -67,12 +107,12 @@ export function createWorkerForType(
|
|
|
67
107
|
return factory.create(sixb, options)
|
|
68
108
|
}
|
|
69
109
|
|
|
70
|
-
export function resolveWorkerTypeToStart(requestedWorker?: string):
|
|
110
|
+
export function resolveWorkerTypeToStart(requestedWorker?: string): WorkerType {
|
|
71
111
|
if (!requestedWorker) {
|
|
72
112
|
throw new Error(`[SixbWorker] Usage: sixb worker <${knownWorkers().replaceAll(", ", "|")}>`)
|
|
73
113
|
}
|
|
74
114
|
|
|
75
|
-
if (!
|
|
115
|
+
if (!isWorkerType(requestedWorker)) {
|
|
76
116
|
throw new Error(
|
|
77
117
|
`[SixbWorker] Unknown worker '${requestedWorker}'. Available: ${knownWorkers()}`
|
|
78
118
|
)
|
|
@@ -89,7 +129,9 @@ export function unmetWorkerRequirement(
|
|
|
89
129
|
workerType: string,
|
|
90
130
|
options: WorkerCreationOptions
|
|
91
131
|
): string | null {
|
|
92
|
-
return
|
|
132
|
+
return isWorkerType(workerType)
|
|
133
|
+
? (workerFactories[workerType].unmetRequirement?.(options) ?? null)
|
|
134
|
+
: null
|
|
93
135
|
}
|
|
94
136
|
|
|
95
137
|
export interface WorkerGroupInputs {
|
|
@@ -139,35 +181,30 @@ export function assertWorkerInputs(input: WorkerGroupInputs): void {
|
|
|
139
181
|
})
|
|
140
182
|
}
|
|
141
183
|
|
|
142
|
-
export function resolveRegisteredWorkerTypes(sixb:
|
|
143
|
-
const workerTypes:
|
|
184
|
+
export function resolveRegisteredWorkerTypes(sixb: LoadedSixbHost): readonly WorkerType[] {
|
|
185
|
+
const workerTypes: WorkerType[] = []
|
|
144
186
|
|
|
145
|
-
if (sixb.
|
|
187
|
+
if (sixb.definitions.syncs.list().length > 0) {
|
|
146
188
|
workerTypes.push("sync")
|
|
147
189
|
}
|
|
148
190
|
|
|
149
|
-
if (sixb.
|
|
191
|
+
if (sixb.definitions.pipelines.list().length > 0) {
|
|
150
192
|
workerTypes.push("pipeline")
|
|
151
193
|
}
|
|
152
194
|
|
|
153
|
-
if (
|
|
154
|
-
sixb.listObjectProjections().length +
|
|
155
|
-
sixb.listLinkProjections().length +
|
|
156
|
-
sixb.listTelemetryProjections().length >
|
|
157
|
-
0
|
|
158
|
-
) {
|
|
195
|
+
if (sixb.definitions.projections.list().length > 0) {
|
|
159
196
|
workerTypes.push("projection")
|
|
160
197
|
}
|
|
161
198
|
|
|
162
|
-
if (sixb.
|
|
199
|
+
if (sixb.definitions.actions.list().length > 0) {
|
|
163
200
|
workerTypes.push("action")
|
|
164
201
|
}
|
|
165
202
|
|
|
166
|
-
if (sixb.agents.list().length > 0 && sixb.storage.agents) {
|
|
203
|
+
if (sixb.definitions.agents.list().length > 0 && sixb.storage.agents) {
|
|
167
204
|
workerTypes.push("agent")
|
|
168
205
|
}
|
|
169
206
|
|
|
170
|
-
if (sixb.workflows.list().length > 0) {
|
|
207
|
+
if (sixb.definitions.workflows.list().length > 0) {
|
|
171
208
|
workerTypes.push("workflow")
|
|
172
209
|
}
|
|
173
210
|
|
|
@@ -175,7 +212,11 @@ export function resolveRegisteredWorkerTypes(sixb: LoadedSixb): readonly string[
|
|
|
175
212
|
}
|
|
176
213
|
|
|
177
214
|
function knownWorkers(): string {
|
|
178
|
-
return
|
|
215
|
+
return WORKER_TYPES.join(", ")
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function isWorkerType(value: string): value is WorkerType {
|
|
219
|
+
return WORKER_TYPES.some((workerType) => workerType === value)
|
|
179
220
|
}
|
|
180
221
|
|
|
181
222
|
function agentApiBaseUrl(value: string | undefined): string | null {
|
package/src/ui/index.tsx
CHANGED
|
@@ -392,6 +392,14 @@ export function HelpView({ errorMessage }: { errorMessage?: string }) {
|
|
|
392
392
|
{ label: "--api-port <port>", value: "API port (default: Atlas port + 2)" },
|
|
393
393
|
{ label: "--api-host <host>", value: "API bind host (default: --host)" },
|
|
394
394
|
{ label: "--api-public-origin <origin>", value: "Public API origin" },
|
|
395
|
+
{
|
|
396
|
+
label: "--agent-turn-timeout <duration>",
|
|
397
|
+
value: "Agent turn wall-clock budget (default: 10m)",
|
|
398
|
+
},
|
|
399
|
+
{
|
|
400
|
+
label: "--concurrency <value>",
|
|
401
|
+
value: "Concurrent jobs: count for worker; repeat type=count for dev/worker-group",
|
|
402
|
+
},
|
|
395
403
|
{ label: "--atlas-public-origin <origin>", value: "Public Atlas origin" },
|
|
396
404
|
{ label: "--app-public-origin <origin>", value: "Public custom app origin" },
|
|
397
405
|
{ label: "--api-url <url>", value: "API origin for auth/token commands" },
|
|
@@ -429,8 +437,8 @@ export function HelpView({ errorMessage }: { errorMessage?: string }) {
|
|
|
429
437
|
"sixb orchestrator",
|
|
430
438
|
"sixb rules",
|
|
431
439
|
"sixb worker pipeline",
|
|
432
|
-
"sixb worker
|
|
433
|
-
"sixb worker-group sync
|
|
440
|
+
"sixb worker agent --concurrency 8",
|
|
441
|
+
"sixb worker-group sync agent --concurrency sync=2 --concurrency agent=8",
|
|
434
442
|
"sixb dev --entry examples/mac-os/sixb.config.ts --port 8080",
|
|
435
443
|
"sixb check",
|
|
436
444
|
"sixb typegen",
|
|
@@ -493,9 +501,8 @@ export function DevView({
|
|
|
493
501
|
apiDocsUrl,
|
|
494
502
|
wsUrl,
|
|
495
503
|
uiUrl,
|
|
496
|
-
uiStatus,
|
|
497
504
|
appUrl,
|
|
498
|
-
|
|
505
|
+
workers = [],
|
|
499
506
|
warnings = [],
|
|
500
507
|
}: {
|
|
501
508
|
name: string
|
|
@@ -503,9 +510,8 @@ export function DevView({
|
|
|
503
510
|
apiDocsUrl: string
|
|
504
511
|
wsUrl: string
|
|
505
512
|
uiUrl: string | null
|
|
506
|
-
uiStatus: string | null
|
|
507
513
|
appUrl?: string | null
|
|
508
|
-
|
|
514
|
+
workers?: readonly { readonly type: string; readonly concurrency: number }[]
|
|
509
515
|
warnings?: readonly string[]
|
|
510
516
|
}) {
|
|
511
517
|
const serverItems: KeyValueItem[] = [
|
|
@@ -515,8 +521,6 @@ export function DevView({
|
|
|
515
521
|
]
|
|
516
522
|
if (uiUrl) {
|
|
517
523
|
serverItems.push({ label: "Atlas UI", value: uiUrl })
|
|
518
|
-
} else if (uiStatus) {
|
|
519
|
-
serverItems.push({ label: "Atlas UI", value: uiStatus })
|
|
520
524
|
}
|
|
521
525
|
|
|
522
526
|
return (
|
|
@@ -531,10 +535,16 @@ export function DevView({
|
|
|
531
535
|
<ServicePanel name="Custom app" items={[{ label: "URL", value: appUrl }]} />
|
|
532
536
|
</>
|
|
533
537
|
) : null}
|
|
534
|
-
{
|
|
538
|
+
{workers.length > 0 ? (
|
|
535
539
|
<>
|
|
536
540
|
<Spacer />
|
|
537
|
-
<ServicePanel
|
|
541
|
+
<ServicePanel
|
|
542
|
+
name="Workers"
|
|
543
|
+
items={workers.map((worker) => ({
|
|
544
|
+
label: worker.type,
|
|
545
|
+
value: `running · concurrency ${worker.concurrency}`,
|
|
546
|
+
}))}
|
|
547
|
+
/>
|
|
538
548
|
</>
|
|
539
549
|
) : null}
|
|
540
550
|
{warnings.length > 0 ? (
|
|
@@ -552,71 +562,16 @@ export function DevView({
|
|
|
552
562
|
)
|
|
553
563
|
}
|
|
554
564
|
|
|
555
|
-
export function StartView({
|
|
556
|
-
name,
|
|
557
|
-
apiUrl,
|
|
558
|
-
apiDocsUrl,
|
|
559
|
-
wsUrl,
|
|
560
|
-
uiUrl,
|
|
561
|
-
uiStatus,
|
|
562
|
-
appUrl,
|
|
563
|
-
warnings = [],
|
|
564
|
-
}: {
|
|
565
|
-
name: string
|
|
566
|
-
apiUrl: string
|
|
567
|
-
apiDocsUrl: string
|
|
568
|
-
wsUrl: string
|
|
569
|
-
uiUrl: string | null
|
|
570
|
-
uiStatus?: string | null
|
|
571
|
-
appUrl?: string | null
|
|
572
|
-
warnings?: readonly string[]
|
|
573
|
-
}) {
|
|
574
|
-
const serverItems: KeyValueItem[] = [
|
|
575
|
-
{ label: "API", value: apiUrl },
|
|
576
|
-
{ label: "API docs", value: apiDocsUrl },
|
|
577
|
-
{ label: "Events", value: wsUrl },
|
|
578
|
-
]
|
|
579
|
-
if (uiUrl) {
|
|
580
|
-
serverItems.push({ label: "Atlas UI", value: uiUrl })
|
|
581
|
-
} else if (uiStatus) {
|
|
582
|
-
serverItems.push({ label: "Atlas UI", value: uiStatus })
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
return (
|
|
586
|
-
<Box flexDirection="column">
|
|
587
|
-
<Text color="green" bold>
|
|
588
|
-
Sixb started
|
|
589
|
-
</Text>
|
|
590
|
-
<Text dimColor>{name}</Text>
|
|
591
|
-
<Spacer />
|
|
592
|
-
<ServicePanel name="Server" items={serverItems} />
|
|
593
|
-
{appUrl ? (
|
|
594
|
-
<>
|
|
595
|
-
<Spacer />
|
|
596
|
-
<ServicePanel name="Custom app" items={[{ label: "URL", value: appUrl }]} />
|
|
597
|
-
</>
|
|
598
|
-
) : null}
|
|
599
|
-
{warnings.length > 0 ? (
|
|
600
|
-
<>
|
|
601
|
-
<Spacer />
|
|
602
|
-
<SectionTitle>Warnings</SectionTitle>
|
|
603
|
-
<BulletList items={warnings} />
|
|
604
|
-
</>
|
|
605
|
-
) : null}
|
|
606
|
-
<Spacer />
|
|
607
|
-
<Text dimColor>Press Ctrl+C to stop</Text>
|
|
608
|
-
</Box>
|
|
609
|
-
)
|
|
610
|
-
}
|
|
611
|
-
|
|
612
565
|
export function WorkerView({
|
|
613
566
|
name,
|
|
614
567
|
workerId,
|
|
568
|
+
concurrency,
|
|
615
569
|
storage,
|
|
616
570
|
warnings = [],
|
|
617
571
|
}: {
|
|
618
572
|
name: string
|
|
619
573
|
workerId: string
|
|
574
|
+
concurrency: number
|
|
620
575
|
storage?: string | null
|
|
621
576
|
warnings?: readonly string[]
|
|
622
577
|
}) {
|
|
@@ -627,7 +582,13 @@ export function WorkerView({
|
|
|
627
582
|
</Text>
|
|
628
583
|
<Text dimColor>{name}</Text>
|
|
629
584
|
<Spacer />
|
|
630
|
-
<ServicePanel
|
|
585
|
+
<ServicePanel
|
|
586
|
+
name="Worker"
|
|
587
|
+
items={[
|
|
588
|
+
{ label: "ID", value: workerId },
|
|
589
|
+
{ label: "Concurrency", value: String(concurrency) },
|
|
590
|
+
]}
|
|
591
|
+
/>
|
|
631
592
|
<StoragePanel summary={storage} />
|
|
632
593
|
{warnings.length > 0 ? (
|
|
633
594
|
<>
|
|
@@ -644,12 +605,12 @@ export function WorkerView({
|
|
|
644
605
|
|
|
645
606
|
export function WorkerGroupView({
|
|
646
607
|
name,
|
|
647
|
-
|
|
608
|
+
workers,
|
|
648
609
|
storage,
|
|
649
610
|
warnings = [],
|
|
650
611
|
}: {
|
|
651
612
|
name: string
|
|
652
|
-
|
|
613
|
+
workers: readonly { readonly type: string; readonly concurrency: number }[]
|
|
653
614
|
storage?: string | null
|
|
654
615
|
warnings?: readonly string[]
|
|
655
616
|
}) {
|
|
@@ -662,7 +623,10 @@ export function WorkerGroupView({
|
|
|
662
623
|
<Spacer />
|
|
663
624
|
<ServicePanel
|
|
664
625
|
name="Workers"
|
|
665
|
-
items={
|
|
626
|
+
items={workers.map((worker) => ({
|
|
627
|
+
label: worker.type,
|
|
628
|
+
value: `running · concurrency ${worker.concurrency}`,
|
|
629
|
+
}))}
|
|
666
630
|
/>
|
|
667
631
|
<StoragePanel summary={storage} />
|
|
668
632
|
{warnings.length > 0 ? (
|