@sixb/cli 0.2.2 → 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.
- package/README.md +25 -22
- package/dist/commands/access-token-utils.d.ts.map +1 -1
- package/dist/commands/api.d.ts.map +1 -1
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/dev-runner.d.ts.map +1 -1
- package/dist/commands/env.d.ts +6 -1
- package/dist/commands/env.d.ts.map +1 -1
- package/dist/commands/lake-cleanup.d.ts +2 -12
- package/dist/commands/lake-cleanup.d.ts.map +1 -1
- package/dist/commands/lake-rejected.d.ts +10 -0
- package/dist/commands/lake-rejected.d.ts.map +1 -0
- package/dist/commands/orchestrator.d.ts.map +1 -1
- package/dist/commands/scheduler.d.ts +2 -5
- package/dist/commands/scheduler.d.ts.map +1 -1
- package/dist/commands/worker-group.d.ts.map +1 -1
- package/dist/lib/command-line.d.ts +12 -7
- package/dist/lib/command-line.d.ts.map +1 -1
- package/dist/lib/deploy-release.d.ts +7 -1
- package/dist/lib/deploy-release.d.ts.map +1 -1
- package/dist/lib/duration.d.ts +3 -0
- package/dist/lib/duration.d.ts.map +1 -0
- package/dist/lib/loadSixb.d.ts.map +1 -1
- package/dist/lib/production-roles.d.ts +0 -4
- package/dist/lib/production-roles.d.ts.map +1 -1
- package/dist/lib/runtime.d.ts +7 -9
- package/dist/lib/runtime.d.ts.map +1 -1
- package/dist/lib/worker-concurrency.d.ts.map +1 -1
- package/dist/lib/worker-registry.d.ts +4 -1
- package/dist/lib/worker-registry.d.ts.map +1 -1
- package/dist/tui/format.d.ts.map +1 -1
- package/dist/ui/deploy-screens.d.ts +4 -2
- package/dist/ui/deploy-screens.d.ts.map +1 -1
- package/dist/ui/env-screens.d.ts +14 -1
- package/dist/ui/env-screens.d.ts.map +1 -1
- package/dist/ui/screens.d.ts +5 -11
- package/dist/ui/screens.d.ts.map +1 -1
- package/package.json +20 -16
- package/src/commands/access-token-utils.ts +2 -20
- package/src/commands/api.ts +7 -0
- package/src/commands/check.ts +75 -1
- package/src/commands/deploy.ts +15 -3
- package/src/commands/dev-runner.ts +5 -0
- package/src/commands/env.ts +99 -20
- package/src/commands/lake-cleanup.ts +25 -48
- package/src/commands/lake-rejected.ts +36 -0
- package/src/commands/orchestrator.ts +2 -7
- package/src/commands/scheduler.ts +11 -61
- package/src/commands/worker-group.ts +6 -3
- package/src/index.tsx +10 -4
- package/src/lib/command-line.ts +25 -12
- package/src/lib/deploy-release.ts +42 -2
- package/src/lib/duration.ts +11 -0
- package/src/lib/loadSixb.ts +3 -4
- package/src/lib/production-roles.ts +0 -1
- package/src/lib/runtime.ts +62 -43
- package/src/lib/shareable-providers.ts +2 -2
- package/src/lib/worker-concurrency.ts +1 -0
- package/src/lib/worker-registry.ts +36 -1
- package/src/tui/format.ts +10 -1
- package/src/ui/deploy-screens.ts +8 -1
- package/src/ui/env-screens.ts +39 -5
- package/src/ui/screens.ts +21 -20
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { AgentWorker } from "@sixb/agent-worker"
|
|
2
|
+
import { getDatasetIngestRuntime, getLakeRetentionRuntime } from "@sixb/core/internal/runtime"
|
|
2
3
|
import type { Worker } from "@sixb/core/internal/workers"
|
|
4
|
+
import { LakeWorker } from "@sixb/lake-worker"
|
|
3
5
|
import { PipelineWorker } from "@sixb/pipeline-worker"
|
|
4
6
|
import { ProjectionWorker } from "@sixb/projection-worker"
|
|
5
7
|
import { SyncWorker } from "@sixb/sync-worker"
|
|
@@ -8,7 +10,7 @@ import { SixbCliError } from "./errors"
|
|
|
8
10
|
import type { LoadedSixbHost } from "./loadSixb"
|
|
9
11
|
import { configuredOrigin } from "./public-origin"
|
|
10
12
|
|
|
11
|
-
export const WORKER_TYPES = ["sync", "agent", "pipeline", "projection", "workflow"] as const
|
|
13
|
+
export const WORKER_TYPES = ["sync", "agent", "pipeline", "projection", "workflow", "lake"] as const
|
|
12
14
|
|
|
13
15
|
export type WorkerType = (typeof WORKER_TYPES)[number]
|
|
14
16
|
|
|
@@ -74,6 +76,10 @@ const workerFactories: Record<WorkerType, WorkerFactory> = {
|
|
|
74
76
|
create: (sixb, options) =>
|
|
75
77
|
new WorkflowWorker(sixb, { concurrency: options.workerConcurrency?.workflow }),
|
|
76
78
|
},
|
|
79
|
+
lake: {
|
|
80
|
+
create: (sixb, options) =>
|
|
81
|
+
new LakeWorker(sixb, { concurrency: options.workerConcurrency?.lake }),
|
|
82
|
+
},
|
|
77
83
|
}
|
|
78
84
|
|
|
79
85
|
export function createWorkerForType(
|
|
@@ -197,6 +203,10 @@ export function resolveRegisteredWorkerTypes(sixb: LoadedSixbHost): readonly Wor
|
|
|
197
203
|
workerTypes.push("workflow")
|
|
198
204
|
}
|
|
199
205
|
|
|
206
|
+
if (lakeWorkerRequired(sixb)) {
|
|
207
|
+
workerTypes.push("lake")
|
|
208
|
+
}
|
|
209
|
+
|
|
200
210
|
return workerTypes
|
|
201
211
|
}
|
|
202
212
|
|
|
@@ -220,6 +230,31 @@ function resolveAgentApiBaseUrl(value: string | undefined): string {
|
|
|
220
230
|
return apiBaseUrl
|
|
221
231
|
}
|
|
222
232
|
|
|
233
|
+
export function lakeWorkerRequired(sixb: LoadedSixbHost): boolean {
|
|
234
|
+
return getLakeRetentionRuntime(sixb).automatic || getDatasetIngestRuntime(sixb).enabled
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/** Requests stay queued while no worker claims them, which looks like an idle system. */
|
|
238
|
+
export function omittedWorkerWarnings(
|
|
239
|
+
sixb: LoadedSixbHost,
|
|
240
|
+
workerTypes: readonly string[]
|
|
241
|
+
): readonly string[] {
|
|
242
|
+
if (workerTypes.includes("lake")) return []
|
|
243
|
+
|
|
244
|
+
return [
|
|
245
|
+
...(getLakeRetentionRuntime(sixb).automatic
|
|
246
|
+
? [
|
|
247
|
+
"Lake cleanup needs a lake worker and this group has none: run `sixb worker lake`, or the lake keeps growing.",
|
|
248
|
+
]
|
|
249
|
+
: []),
|
|
250
|
+
...(getDatasetIngestRuntime(sixb).enabled
|
|
251
|
+
? [
|
|
252
|
+
"Ingested changes need a lake worker and this group has none: run `sixb worker lake`, or they wait and never reach their dataset.",
|
|
253
|
+
]
|
|
254
|
+
: []),
|
|
255
|
+
]
|
|
256
|
+
}
|
|
257
|
+
|
|
223
258
|
/** Explicit model calls can enqueue accounting recovery without a model catalog. */
|
|
224
259
|
export function agentWorkerRequired(sixb: LoadedSixbHost): boolean {
|
|
225
260
|
const { storage } = sixb
|
package/src/tui/format.ts
CHANGED
|
@@ -112,13 +112,22 @@ export function toolLine(
|
|
|
112
112
|
...(failed ? fetchFailure(part.error) : {}),
|
|
113
113
|
}
|
|
114
114
|
case "publish_artifact":
|
|
115
|
+
case "update_artifact":
|
|
116
|
+
// What `update_artifact` was called: earlier threads hold calls to it.
|
|
115
117
|
case "publish_artifact_version":
|
|
116
118
|
return {
|
|
117
|
-
verb: "publish",
|
|
119
|
+
verb: part.name === "publish_artifact" ? "publish" : "update",
|
|
118
120
|
detail: text(input?.title) || text(input?.path) || text(input?.artifactId),
|
|
119
121
|
...(output?.artifactId ? { note: `artifact:${text(output.artifactId)}` } : {}),
|
|
120
122
|
...error,
|
|
121
123
|
}
|
|
124
|
+
case "open_artifact":
|
|
125
|
+
return {
|
|
126
|
+
verb: "open",
|
|
127
|
+
detail: text(output?.title) || text(input?.id),
|
|
128
|
+
...(output?.artifactId ? { note: `artifact:${text(output.artifactId)}` } : {}),
|
|
129
|
+
...error,
|
|
130
|
+
}
|
|
122
131
|
case "spawn_agent":
|
|
123
132
|
return {
|
|
124
133
|
verb: "agent",
|
package/src/ui/deploy-screens.ts
CHANGED
|
@@ -20,15 +20,18 @@ import {
|
|
|
20
20
|
section,
|
|
21
21
|
stack,
|
|
22
22
|
table,
|
|
23
|
+
warnings as warningLines,
|
|
23
24
|
} from "./layout"
|
|
24
25
|
import { glyph, tone } from "./theme"
|
|
25
26
|
|
|
26
27
|
export function deployReleaseView({
|
|
27
28
|
release,
|
|
28
29
|
configPath,
|
|
30
|
+
warnings = [],
|
|
29
31
|
}: {
|
|
30
32
|
release: DeployRelease
|
|
31
33
|
configPath: string
|
|
34
|
+
warnings?: readonly string[]
|
|
32
35
|
}): string {
|
|
33
36
|
const steps = [
|
|
34
37
|
...(release.steps.env ? [{ label: "env", commands: [release.steps.env] }] : []),
|
|
@@ -93,6 +96,7 @@ export function deployReleaseView({
|
|
|
93
96
|
origins.size > 0 ? tone.muted("plus the public origins above") : null
|
|
94
97
|
)
|
|
95
98
|
),
|
|
99
|
+
warningLines(warnings),
|
|
96
100
|
headline("idle", "Nothing was deployed", "--json prints the full release")
|
|
97
101
|
)
|
|
98
102
|
}
|
|
@@ -107,11 +111,13 @@ export function deployCompleteView({
|
|
|
107
111
|
release,
|
|
108
112
|
seconds,
|
|
109
113
|
keptEnv = false,
|
|
114
|
+
warnings = [],
|
|
110
115
|
}: {
|
|
111
116
|
release: DeployRelease
|
|
112
117
|
seconds?: number
|
|
113
118
|
/** The deploy couldn't update the server's `.env`, so this release runs on its current values. */
|
|
114
119
|
keptEnv?: boolean
|
|
120
|
+
warnings?: readonly string[]
|
|
115
121
|
}): string {
|
|
116
122
|
const urls = release.services.flatMap((service) =>
|
|
117
123
|
service.http ? [{ label: service.name, value: service.http.publicOrigin }] : []
|
|
@@ -129,7 +135,8 @@ export function deployCompleteView({
|
|
|
129
135
|
"This release runs on the server's current .env, not on the latest values. Deploy again to update them.",
|
|
130
136
|
tone.muted
|
|
131
137
|
)
|
|
132
|
-
: null
|
|
138
|
+
: null,
|
|
139
|
+
warningLines(warnings)
|
|
133
140
|
)
|
|
134
141
|
}
|
|
135
142
|
|
package/src/ui/env-screens.ts
CHANGED
|
@@ -27,15 +27,49 @@ export function envSetView(input: {
|
|
|
27
27
|
)
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
/** What `init` did with `sixb.env.ts`: wrote names into it, left it to the author, or had none to add. */
|
|
31
|
+
export type EnvInitConfig =
|
|
32
|
+
| { readonly kind: "written"; readonly names: number }
|
|
33
|
+
| { readonly kind: "paste"; readonly names: number; readonly lines: readonly string[] }
|
|
34
|
+
| { readonly kind: "unchanged" }
|
|
35
|
+
|
|
30
36
|
export function envInitView(input: {
|
|
31
|
-
|
|
32
|
-
readonly
|
|
37
|
+
/** Per environment: how many values were sent, and how many it had already. */
|
|
38
|
+
readonly uploaded: readonly {
|
|
39
|
+
readonly env: EnvName
|
|
40
|
+
readonly count: number
|
|
41
|
+
readonly already: number
|
|
42
|
+
}[]
|
|
43
|
+
readonly config: EnvInitConfig
|
|
33
44
|
}): string {
|
|
34
|
-
const
|
|
45
|
+
const sent = input.uploaded.filter(({ count }) => count > 0)
|
|
46
|
+
const had = input.uploaded.filter(({ already }) => already > 0)
|
|
47
|
+
const { config } = input
|
|
35
48
|
return screen(
|
|
36
49
|
stack(
|
|
37
|
-
|
|
38
|
-
|
|
50
|
+
sent.length > 0
|
|
51
|
+
? headline(
|
|
52
|
+
"ok",
|
|
53
|
+
`Uploaded ${sent.map(({ env, count }) => `${plural(count, "variable")} to ${env}`).join(" and ")}`
|
|
54
|
+
)
|
|
55
|
+
: headline("ok", "Nothing to upload"),
|
|
56
|
+
had.length > 0
|
|
57
|
+
? tone.muted(
|
|
58
|
+
`Already there: ${had.map(({ env, already }) => `${already} in ${env}`).join(", ")}`
|
|
59
|
+
)
|
|
60
|
+
: null,
|
|
61
|
+
config.kind === "written"
|
|
62
|
+
? headline("ok", `Wrote sixb.env.ts with ${plural(config.names, "name")}`)
|
|
63
|
+
: null,
|
|
64
|
+
config.kind === "paste"
|
|
65
|
+
? stack(
|
|
66
|
+
headline("warn", `Add ${plural(config.names, "name")} to \`vars\` in sixb.env.ts`),
|
|
67
|
+
tone.muted(
|
|
68
|
+
"It isn't an empty `vars: {}`, so it was left alone. A first guess at each:"
|
|
69
|
+
),
|
|
70
|
+
config.lines.join("\n")
|
|
71
|
+
)
|
|
72
|
+
: null
|
|
39
73
|
)
|
|
40
74
|
)
|
|
41
75
|
}
|
package/src/ui/screens.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { LakeRetentionReport } from "@sixb/core/lake-storage"
|
|
1
2
|
import {
|
|
2
3
|
CLI_EXAMPLES,
|
|
3
4
|
type CliHelp,
|
|
@@ -430,39 +431,39 @@ export function lakeCheckView({
|
|
|
430
431
|
return screen(headline("ok", "Lake definitions compatible", projectId), warningLines(warnings))
|
|
431
432
|
}
|
|
432
433
|
|
|
433
|
-
export interface LakeCleanupReport {
|
|
434
|
-
readonly dryRun: boolean
|
|
435
|
-
readonly expireOlderThan: string
|
|
436
|
-
readonly deleteOlderThan: string
|
|
437
|
-
readonly snapshots: number
|
|
438
|
-
readonly keptSnapshots?: number
|
|
439
|
-
readonly oldFiles: number
|
|
440
|
-
readonly orphanedFiles: number
|
|
441
|
-
}
|
|
442
|
-
|
|
443
434
|
export function lakeCleanupView({
|
|
444
435
|
projectId,
|
|
436
|
+
keepVersionsFor,
|
|
437
|
+
deleteFilesAfter,
|
|
445
438
|
report,
|
|
446
439
|
}: {
|
|
447
440
|
projectId: string
|
|
448
|
-
|
|
441
|
+
keepVersionsFor: string
|
|
442
|
+
deleteFilesAfter: string
|
|
443
|
+
report: LakeRetentionReport
|
|
449
444
|
}): string {
|
|
445
|
+
// A dry run measures one pass: when more remain, what the run would clean is more than it counts.
|
|
446
|
+
const measuredOnePass = report.dryRun && report.hasMore
|
|
447
|
+
const atLeast = (count: number) => (measuredOnePass ? `${count}+` : String(count))
|
|
448
|
+
|
|
450
449
|
return screen(
|
|
451
450
|
header(report.dryRun ? "lake cleanup --dry-run" : "lake cleanup", projectId),
|
|
452
451
|
rows([
|
|
453
|
-
{ label: "
|
|
454
|
-
{ label: "Delete
|
|
455
|
-
{ label: "
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
{ label: "Old files", value: String(report.oldFiles) },
|
|
460
|
-
{ label: "Orphaned files", value: String(report.orphanedFiles) },
|
|
452
|
+
{ label: "Keep versions for", value: keepVersionsFor },
|
|
453
|
+
{ label: "Delete files after", value: deleteFilesAfter },
|
|
454
|
+
{ label: "Expired versions", value: atLeast(report.expiredVersions) },
|
|
455
|
+
{ label: "Kept versions", value: String(report.keptVersions) },
|
|
456
|
+
{ label: "Deleted files", value: atLeast(report.deletedFiles) },
|
|
457
|
+
{ label: "Orphaned files", value: atLeast(report.orphanedFiles) },
|
|
461
458
|
]),
|
|
462
459
|
headline(
|
|
463
460
|
"ok",
|
|
464
461
|
report.dryRun ? "Lake cleanup dry run complete" : "Lake cleanup complete",
|
|
465
|
-
report.dryRun
|
|
462
|
+
report.dryRun
|
|
463
|
+
? measuredOnePass
|
|
464
|
+
? "nothing was deleted; one pass measured, more remain"
|
|
465
|
+
: "nothing was deleted"
|
|
466
|
+
: undefined
|
|
466
467
|
)
|
|
467
468
|
)
|
|
468
469
|
}
|