@sixb/cli 0.1.25 → 0.1.26

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 (76) hide show
  1. package/README.md +5 -5
  2. package/dist/commands/agent.d.ts +16 -0
  3. package/dist/commands/agent.d.ts.map +1 -0
  4. package/dist/commands/dev-runner.d.ts +0 -1
  5. package/dist/commands/dev-runner.d.ts.map +1 -1
  6. package/dist/commands/worker-group.d.ts +0 -1
  7. package/dist/commands/worker-group.d.ts.map +1 -1
  8. package/dist/commands/worker.d.ts +0 -1
  9. package/dist/commands/worker.d.ts.map +1 -1
  10. package/dist/lib/command-line.d.ts +16 -6
  11. package/dist/lib/command-line.d.ts.map +1 -1
  12. package/dist/lib/deploy-release.d.ts.map +1 -1
  13. package/dist/lib/github-ci.d.ts.map +1 -1
  14. package/dist/lib/runtime.d.ts +0 -1
  15. package/dist/lib/runtime.d.ts.map +1 -1
  16. package/dist/lib/worker-registry.d.ts +0 -1
  17. package/dist/lib/worker-registry.d.ts.map +1 -1
  18. package/dist/tui/app.d.ts +19 -0
  19. package/dist/tui/app.d.ts.map +1 -0
  20. package/dist/tui/brand.d.ts +7 -0
  21. package/dist/tui/brand.d.ts.map +1 -0
  22. package/dist/tui/computer.d.ts +3 -0
  23. package/dist/tui/computer.d.ts.map +1 -0
  24. package/dist/tui/connection.d.ts +45 -0
  25. package/dist/tui/connection.d.ts.map +1 -0
  26. package/dist/tui/folders.d.ts +7 -0
  27. package/dist/tui/folders.d.ts.map +1 -0
  28. package/dist/tui/format.d.ts +33 -0
  29. package/dist/tui/format.d.ts.map +1 -0
  30. package/dist/tui/index.d.ts +12 -0
  31. package/dist/tui/index.d.ts.map +1 -0
  32. package/dist/tui/palette.d.ts +25 -0
  33. package/dist/tui/palette.d.ts.map +1 -0
  34. package/dist/tui/parts.d.ts +66 -0
  35. package/dist/tui/parts.d.ts.map +1 -0
  36. package/dist/tui/runner.d.ts +52 -0
  37. package/dist/tui/runner.d.ts.map +1 -0
  38. package/dist/tui/settings.d.ts +44 -0
  39. package/dist/tui/settings.d.ts.map +1 -0
  40. package/dist/tui/slash.d.ts +14 -0
  41. package/dist/tui/slash.d.ts.map +1 -0
  42. package/dist/tui/theme.d.ts +39 -0
  43. package/dist/tui/theme.d.ts.map +1 -0
  44. package/dist/tui/transcript.d.ts +52 -0
  45. package/dist/tui/transcript.d.ts.map +1 -0
  46. package/dist/tui/ui.d.ts +35 -0
  47. package/dist/tui/ui.d.ts.map +1 -0
  48. package/package.json +17 -15
  49. package/src/commands/agent.ts +337 -0
  50. package/src/commands/dev-runner.ts +0 -4
  51. package/src/commands/worker-group.ts +0 -4
  52. package/src/commands/worker.ts +0 -4
  53. package/src/index.tsx +57 -5
  54. package/src/lib/command-line.ts +52 -15
  55. package/src/lib/deploy-release.ts +0 -11
  56. package/src/lib/github-ci.ts +3 -1
  57. package/src/lib/runtime.ts +0 -2
  58. package/src/lib/worker-registry.ts +0 -2
  59. package/src/tui/app.tsx +1198 -0
  60. package/src/tui/brand.tsx +51 -0
  61. package/src/tui/computer.ts +54 -0
  62. package/src/tui/connection.ts +149 -0
  63. package/src/tui/folders.ts +41 -0
  64. package/src/tui/format.ts +260 -0
  65. package/src/tui/index.tsx +353 -0
  66. package/src/tui/palette.tsx +183 -0
  67. package/src/tui/parts.ts +254 -0
  68. package/src/tui/runner.ts +173 -0
  69. package/src/tui/settings.ts +127 -0
  70. package/src/tui/slash.ts +32 -0
  71. package/src/tui/theme.ts +111 -0
  72. package/src/tui/transcript.tsx +555 -0
  73. package/src/tui/ui.tsx +148 -0
  74. package/dist/lib/agent-turn-timeout.d.ts +0 -8
  75. package/dist/lib/agent-turn-timeout.d.ts.map +0 -1
  76. package/src/lib/agent-turn-timeout.ts +0 -46
package/src/index.tsx CHANGED
@@ -23,6 +23,7 @@ const args = process.argv.slice(2)
23
23
  const MINIMUM_BUN_VERSION = "1.4.2"
24
24
 
25
25
  assertSupportedBunVersion()
26
+ assertBunCheckRanTheChecker()
26
27
 
27
28
  const VERSION = `sixb v${await readPackageVersion()}`
28
29
 
@@ -42,6 +43,22 @@ function assertSupportedBunVersion(): void {
42
43
  process.exit(1)
43
44
  }
44
45
 
46
+ /**
47
+ * A project's `typecheck` script runs `bun check --no-script`. Bun before 1.4.3 has no type
48
+ * checker, so it runs the project's `check` script — this command — with the flag instead, and an
49
+ * unknown-option error would not say why.
50
+ */
51
+ function assertBunCheckRanTheChecker(): void {
52
+ if (args[0] !== "check" || !args.includes("--no-script")) return
53
+ if (compareVersions(Bun.version, "1.4.3") >= 0) return
54
+
55
+ console.error(
56
+ `[Sixb] Bun ${Bun.version} has no type checker, so \`bun check\` ran the project's \`check\` ` +
57
+ "script instead. Run `bun upgrade` and try again."
58
+ )
59
+ process.exit(1)
60
+ }
61
+
45
62
  /** Numeric compare of the leading `major.minor.patch`, ignoring any prerelease suffix. */
46
63
  function compareVersions(left: string, right: string): number {
47
64
  const parse = (value: string) =>
@@ -70,6 +87,15 @@ async function readPackageVersion(): Promise<string> {
70
87
  }
71
88
 
72
89
  async function main(): Promise<void> {
90
+ // `sixb` alone, in a terminal: the full-screen app. Anywhere else it prints its help.
91
+ if (args.length === 0) {
92
+ const { canRunLive } = await import("./ui/live/can-run-live")
93
+ if (canRunLive()) {
94
+ const { runTui } = await import("./tui")
95
+ await runTui({ version: VERSION })
96
+ return
97
+ }
98
+ }
73
99
  const parsed = parseCliArgs(args)
74
100
  if (parsed.kind === "version") {
75
101
  const { renderVersion } = await import("./ui")
@@ -106,7 +132,6 @@ async function main(): Promise<void> {
106
132
  apiHost: getFlag("api-host"),
107
133
  apiPublicOrigin: getFlag("api-public-origin"),
108
134
  appPublicOrigin: getFlag("app-public-origin"),
109
- agentTurnTimeout: getFlag("agent-turn-timeout"),
110
135
  concurrency: getFlags("concurrency"),
111
136
  vectorConcurrency: getFlag("vector-concurrency"),
112
137
  subagentConcurrency: getFlag("subagent-concurrency"),
@@ -123,7 +148,6 @@ async function main(): Promise<void> {
123
148
  noMigrate: hasFlag("no-migrate"),
124
149
  workerType: positionals[0],
125
150
  apiPublicOrigin: getFlag("api-public-origin"),
126
- agentTurnTimeout: getFlag("agent-turn-timeout"),
127
151
  concurrency: getFlag("concurrency"),
128
152
  vectorConcurrency: getFlag("vector-concurrency"),
129
153
  subagentConcurrency: getFlag("subagent-concurrency"),
@@ -139,7 +163,6 @@ async function main(): Promise<void> {
139
163
  noMigrate: hasFlag("no-migrate"),
140
164
  workerTypes: positionals,
141
165
  apiPublicOrigin: getFlag("api-public-origin"),
142
- agentTurnTimeout: getFlag("agent-turn-timeout"),
143
166
  concurrency: getFlags("concurrency"),
144
167
  vectorConcurrency: getFlag("vector-concurrency"),
145
168
  subagentConcurrency: getFlag("subagent-concurrency"),
@@ -193,6 +216,20 @@ async function main(): Promise<void> {
193
216
  break
194
217
  }
195
218
 
219
+ case "agent": {
220
+ const { runAgent } = await import("./commands/agent")
221
+ await runAgent({
222
+ text: positionals,
223
+ thread: getFlag("thread"),
224
+ cloud: hasFlag("cloud"),
225
+ approvalMode: getFlag("approval-mode"),
226
+ json: hasFlag("json"),
227
+ apiUrl: getFlag("api-url"),
228
+ profile: getFlag("profile"),
229
+ })
230
+ break
231
+ }
232
+
196
233
  case "status": {
197
234
  const { runStatus } = await import("./commands/status")
198
235
  await runStatus({
@@ -427,7 +464,7 @@ main().catch(async (error) => {
427
464
  function cliExitCode(error: unknown): number {
428
465
  if (error instanceof CliUsageError) return error.exitCode
429
466
  if (error instanceof CliError) return error.exitCode
430
- if (error instanceof SixbApiError) return 3
467
+ if (isApiError(error)) return 3
431
468
  if (errorMessage(error).startsWith("Usage:")) return 2
432
469
  return 1
433
470
  }
@@ -443,7 +480,7 @@ function cliErrorBody(error: unknown): {
443
480
  if (error instanceof CliUsageError) {
444
481
  return { code: "invalid_arguments", message: error.message, hint: error.help.usage }
445
482
  }
446
- if (error instanceof SixbApiError) {
483
+ if (isApiError(error)) {
447
484
  return {
448
485
  code: "api_error",
449
486
  ...(error.status === undefined ? {} : { status: error.status }),
@@ -456,6 +493,21 @@ function cliErrorBody(error: unknown): {
456
493
  }
457
494
  }
458
495
 
496
+ /**
497
+ * The CLI's own API error, or the one `@sixb/client` throws on `throwOnError`: another class, known
498
+ * by its shape. The client is not imported here, so a command that never calls the API never loads it.
499
+ */
500
+ function isApiError(
501
+ error: unknown
502
+ ): error is { readonly status?: number; readonly message: string } {
503
+ if (error instanceof SixbApiError) return true
504
+ return (
505
+ error instanceof Error &&
506
+ error.name === "SixbApiError" &&
507
+ typeof (error as { status?: unknown }).status === "number"
508
+ )
509
+ }
510
+
459
511
  function assertNever(value: never): never {
460
512
  throw new Error(`[SixbCLI] Command '${String(value)}' has no handler.`)
461
513
  }
@@ -34,11 +34,6 @@ export const CLI_OPTION_DEFINITIONS = {
34
34
  summary: "Public API origin",
35
35
  kind: "string",
36
36
  },
37
- "agent-turn-timeout": {
38
- syntax: "--agent-turn-timeout <duration>",
39
- summary: "Agent turn wall-clock budget (default: 10m)",
40
- kind: "string",
41
- },
42
37
  concurrency: {
43
38
  syntax: "--concurrency <value>",
44
39
  summary: "Concurrent jobs: count for worker; repeat type=count for dev/worker-group",
@@ -109,6 +104,21 @@ export const CLI_OPTION_DEFINITIONS = {
109
104
  },
110
105
  group: { syntax: "--group <id>", summary: "Assignable token group; may repeat", kind: "string" },
111
106
  json: { syntax: "--json", summary: "Print JSON instead of formatted output", kind: "boolean" },
107
+ thread: {
108
+ syntax: "--thread <id>",
109
+ summary: "Continue this conversation instead of starting one",
110
+ kind: "string",
111
+ },
112
+ cloud: {
113
+ syntax: "--cloud",
114
+ summary: "Run a new conversation in the cloud, not on this computer",
115
+ kind: "boolean",
116
+ },
117
+ "approval-mode": {
118
+ syntax: "--approval-mode <manual|accept-edits|auto>",
119
+ summary: "What this turn may do without asking (default: your mode in the conversation)",
120
+ kind: "string",
121
+ },
112
122
  outdir: { syntax: "--outdir <path>", summary: "Build output directory", kind: "string" },
113
123
  ref: {
114
124
  syntax: "--ref <ref>",
@@ -155,6 +165,7 @@ export const CLI_OPTION_DEFINITIONS = {
155
165
 
156
166
  export type CliOptionName = keyof typeof CLI_OPTION_DEFINITIONS
157
167
  export type LocalCommandId =
168
+ | "agent"
158
169
  | "dev"
159
170
  | "api"
160
171
  | "app"
@@ -250,6 +261,11 @@ const INSTANCE_SUMMARIES = {
250
261
  "workflow-runs": "Inspect workflow execution history",
251
262
  users: "List and search project members",
252
263
  models: "List the project's models and their prices",
264
+ datasets: "Read datasets, their versions and rows",
265
+ syncs: "List the syncs you may run",
266
+ "sync-runs": "Inspect sync run history",
267
+ pipelines: "List the pipelines you may run",
268
+ "pipeline-runs": "Inspect pipeline runs and their steps",
253
269
  } as const satisfies Record<InstanceCommand, string>
254
270
 
255
271
  const instanceNodes: readonly CommandNode[] = INSTANCE_COMMANDS.map((name) => ({
@@ -270,7 +286,6 @@ const commandTree: readonly CommandNode[] = [
270
286
  "api-port",
271
287
  "api-host",
272
288
  "api-public-origin",
273
- "agent-turn-timeout",
274
289
  "concurrency",
275
290
  "vector-concurrency",
276
291
  "subagent-concurrency",
@@ -307,6 +322,15 @@ const commandTree: readonly CommandNode[] = [
307
322
  command("status", "Check the current profile's connection", {
308
323
  options: [...CONNECTION_OPTIONS, "json"],
309
324
  }),
325
+ command("agent", "Ask the agent; it works in this folder", {
326
+ usage: 'sixb agent "<message>" [--thread <id>] [--cloud] [--approval-mode <mode>] [--json]',
327
+ // No --token: a command the agent runs could read it from this one's arguments. A token comes
328
+ // from a profile or SIXB_API_TOKEN.
329
+ options: ["api-url", "profile", "thread", "cloud", "approval-mode", "json"],
330
+ // The message, quoted or not; standard input when there is none.
331
+ maximumPositionals: Number.POSITIVE_INFINITY,
332
+ rootHelpLabel: 'agent "<message>"',
333
+ }),
310
334
  {
311
335
  name: "profile",
312
336
  summary: "List, show, or switch saved profiles",
@@ -431,7 +455,6 @@ const commandTree: readonly CommandNode[] = [
431
455
  "entry",
432
456
  "no-migrate",
433
457
  "api-public-origin",
434
- "agent-turn-timeout",
435
458
  "concurrency",
436
459
  "vector-concurrency",
437
460
  "subagent-concurrency",
@@ -447,7 +470,6 @@ const commandTree: readonly CommandNode[] = [
447
470
  "entry",
448
471
  "no-migrate",
449
472
  "api-public-origin",
450
- "agent-turn-timeout",
451
473
  "concurrency",
452
474
  "vector-concurrency",
453
475
  "subagent-concurrency",
@@ -622,7 +644,7 @@ export class CliUsageError extends Error {
622
644
 
623
645
  export const ROOT_HELP: CliHelp = {
624
646
  path: [],
625
- usage: "sixb <command> [options]",
647
+ usage: "sixb [command] [options]",
626
648
  summary: "Real-time digital twin framework",
627
649
  commands: rootHelpItems(commandTree),
628
650
  // Each command lists its own options; the root names the ones most commands share. Its last
@@ -640,6 +662,7 @@ const ROOT_HELP_GROUP_COMMANDS: readonly {
640
662
  /** Listed by name only: each has its own help. */
641
663
  readonly compact?: boolean
642
664
  }[] = [
665
+ { title: "Agent", names: ["agent"] },
643
666
  { title: "Develop", names: ["init", "dev", "check", "typegen", "build"] },
644
667
  { title: "Deploy", names: ["deploy", "desktop"] },
645
668
  {
@@ -664,9 +687,15 @@ export const ROOT_HELP_GROUPS: readonly {
664
687
  const groups = ROOT_HELP_GROUP_COMMANDS.map((group) => ({
665
688
  title: group.title,
666
689
  ...(group.compact ? { compact: true } : {}),
667
- items: rootHelpItems(
668
- group.names.flatMap((name) => commandTree.filter((node) => node.name === name))
669
- ),
690
+ items: [
691
+ // `sixb` alone is no command, but it is how most people meet the agent.
692
+ ...(group.title === "Agent"
693
+ ? [{ label: "(no command)", value: "Open Sixb here: talk to the agent in this folder" }]
694
+ : []),
695
+ ...rootHelpItems(
696
+ group.names.flatMap((name) => commandTree.filter((node) => node.name === name))
697
+ ),
698
+ ],
670
699
  }))
671
700
  // A command added without a group still shows up.
672
701
  return ungrouped.length > 0
@@ -717,9 +746,17 @@ export function repeatedOption(options: ParsedCliOptions, name: CliOptionName):
717
746
 
718
747
  export function wantsManagementJson(args: readonly string[]): boolean {
719
748
  return (
720
- ["login", "logout", "status", "profile", "token", "service-account", "deploy"].includes(
721
- args[0] ?? ""
722
- ) && args.some((argument) => argument === "--json" || argument.startsWith("--json="))
749
+ [
750
+ "login",
751
+ "logout",
752
+ "status",
753
+ "profile",
754
+ "token",
755
+ "service-account",
756
+ "deploy",
757
+ "agent",
758
+ ].includes(args[0] ?? "") &&
759
+ args.some((argument) => argument === "--json" || argument.startsWith("--json="))
723
760
  )
724
761
  }
725
762
 
@@ -17,7 +17,6 @@ import {
17
17
  isDeployHttpService,
18
18
  isDeploySingletonService,
19
19
  } from "@sixb/core/internal/deploy"
20
- import { parseAgentTurnTimeoutMs } from "./agent-turn-timeout"
21
20
  import { SixbCliError } from "./errors"
22
21
  import { type ProductionRole, productionRoleFacts } from "./production-roles"
23
22
 
@@ -170,16 +169,6 @@ function workerGroupArgs(options: DeployWorkersConfig): string[] {
170
169
  const types = options.types === undefined || options.types === "all" ? [] : options.types
171
170
  const args = ["worker-group", ...types]
172
171
 
173
- if (options.agentTurnTimeout !== undefined) {
174
- if (parseAgentTurnTimeoutMs(options.agentTurnTimeout) === null) {
175
- throw new SixbCliError(
176
- `[SixbDeploy] services.workers.agentTurnTimeout '${options.agentTurnTimeout}' is not a ` +
177
- "duration.",
178
- { remediation: 'Use a positive duration such as "30s", "10m", or "1h".' }
179
- )
180
- }
181
- args.push("--agent-turn-timeout", options.agentTurnTimeout)
182
- }
183
172
  for (const [workerType, concurrency] of Object.entries(options.concurrency ?? {})) {
184
173
  args.push("--concurrency", `${workerType}=${concurrency}`)
185
174
  }
@@ -95,7 +95,9 @@ export function renderWorkflow(input: WorkflowInput): string {
95
95
  ? [" with:", ` bun-version-file: ${input.bunVersionFile}`]
96
96
  : []),
97
97
  " - name: Install dependencies",
98
- " run: bun install --frozen-lockfile",
98
+ // `sixb deploy` only loads `sixb.deploy.ts` and uploads the source; the server installs again
99
+ // with lifecycle scripts. Skipping them here skips downloads such as a Playwright browser.
100
+ " run: bun install --frozen-lockfile --ignore-scripts",
99
101
  ...workingDirectory,
100
102
  " - name: Install the deploy key",
101
103
  " env:",
@@ -60,7 +60,6 @@ export interface StartSixbRuntimeOptions {
60
60
  */
61
61
  readonly api?: RuntimeApiServer
62
62
  readonly agentApiBaseUrl?: string
63
- readonly agentTurnTimeoutMs?: number
64
63
  readonly workerConcurrency?: WorkerConcurrency
65
64
  readonly vectorConcurrency?: number
66
65
  readonly subagentConcurrency?: number
@@ -292,7 +291,6 @@ export async function startSixbRuntime(
292
291
  ? requireAgentApiBaseUrl(options.agentApiBaseUrl)
293
292
  : undefined,
294
293
  concurrency: options.workerConcurrency?.agent,
295
- turnTimeoutMs: options.agentTurnTimeoutMs,
296
294
  subagentConcurrency: options.subagentConcurrency,
297
295
  subagentConcurrencyPerRun: options.subagentConcurrencyPerRun,
298
296
  })
@@ -17,7 +17,6 @@ export type QueueWorkerProcess = Worker & { readonly concurrency: number }
17
17
 
18
18
  export interface WorkerCreationOptions {
19
19
  readonly agentApiBaseUrl?: string
20
- readonly agentTurnTimeoutMs?: number
21
20
  readonly workerConcurrency?: WorkerConcurrency
22
21
  readonly vectorConcurrency?: number
23
22
  readonly subagentConcurrency?: number
@@ -54,7 +53,6 @@ const workerFactories: Record<WorkerType, WorkerFactory> = {
54
53
  ? resolveAgentApiBaseUrl(options.agentApiBaseUrl)
55
54
  : undefined,
56
55
  concurrency: options.workerConcurrency?.agent,
57
- turnTimeoutMs: options.agentTurnTimeoutMs,
58
56
  subagentConcurrency: options.subagentConcurrency,
59
57
  subagentConcurrencyPerRun: options.subagentConcurrencyPerRun,
60
58
  }),