@runloop/rl-cli 0.5.0 → 0.9.0

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/dist/cli.js CHANGED
@@ -1,13 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import { Command } from "commander";
3
- import { createDevbox } from "./commands/devbox/create.js";
4
- import { listDevboxes } from "./commands/devbox/list.js";
5
- import { deleteDevbox } from "./commands/devbox/delete.js";
6
- import { execCommand } from "./commands/devbox/exec.js";
7
- import { uploadFile } from "./commands/devbox/upload.js";
8
- import { VERSION } from "./version.js";
9
2
  import { exitAlternateScreenBuffer } from "./utils/screen.js";
10
3
  import { processUtils } from "./utils/processUtils.js";
4
+ import { createProgram } from "./utils/commands.js";
5
+ import { getApiKeyErrorMessage } from "./utils/config.js";
11
6
  // Global Ctrl+C handler to ensure it always exits
12
7
  processUtils.on("SIGINT", () => {
13
8
  // Force exit immediately, clearing alternate screen buffer
@@ -15,400 +10,7 @@ processUtils.on("SIGINT", () => {
15
10
  processUtils.stdout.write("\n");
16
11
  processUtils.exit(130); // Standard exit code for SIGINT
17
12
  });
18
- const program = new Command();
19
- program
20
- .name("rli")
21
- .description("Beautiful CLI for Runloop devbox management")
22
- .version(VERSION);
23
- // Devbox commands
24
- const devbox = program
25
- .command("devbox")
26
- .description("Manage devboxes")
27
- .alias("d");
28
- devbox
29
- .command("create")
30
- .description("Create a new devbox")
31
- .option("-n, --name <name>", "Devbox name")
32
- .option("-t, --template <template>", "Snapshot ID to use (alias: --snapshot)")
33
- .option("-s, --snapshot <snapshot>", "Snapshot ID to use")
34
- .option("--blueprint <blueprint>", "Blueprint name or ID to use")
35
- .option("--resources <size>", "Resource size (X_SMALL, SMALL, MEDIUM, LARGE, X_LARGE, XX_LARGE)")
36
- .option("--architecture <arch>", "Architecture (arm64, x86_64)")
37
- .option("--entrypoint <command>", "Entrypoint command to run")
38
- .option("--launch-commands <commands...>", "Initialization commands to run on startup")
39
- .option("--env-vars <vars...>", "Environment variables (format: KEY=value)")
40
- .option("--code-mounts <mounts...>", "Code mount configurations (JSON format)")
41
- .option("--idle-time <seconds>", "Idle time in seconds before idle action")
42
- .option("--idle-action <action>", "Action on idle (shutdown, suspend)")
43
- .option("--available-ports <ports...>", "Available ports")
44
- .option("--root", "Run as root")
45
- .option("--user <user:uid>", "Run as this user (format: username:uid)")
46
- .option("-o, --output [format]", "Output format: text|json|yaml (default: text)")
47
- .action(createDevbox);
48
- devbox
49
- .command("list")
50
- .description("List all devboxes")
51
- .option("-s, --status <status>", "Filter by status (initializing, running, suspending, suspended, resuming, failure, shutdown)")
52
- .option("-l, --limit <n>", "Max results", "20")
53
- .option("-o, --output [format]", "Output format: text|json|yaml (default: json)")
54
- .action(async (options) => {
55
- await listDevboxes(options);
56
- });
57
- devbox
58
- .command("delete <id>")
59
- .description("Shutdown a devbox")
60
- .alias("rm")
61
- .option("-o, --output [format]", "Output format: text|json|yaml (default: text)")
62
- .action(deleteDevbox);
63
- devbox
64
- .command("exec <id> <command...>")
65
- .description("Execute a command in a devbox")
66
- .option("--shell-name <name>", "Shell name to use (optional)")
67
- .option("-o, --output [format]", "Output format: text|json|yaml (default: text)")
68
- .action(async (id, command, options) => {
69
- await execCommand(id, command, options);
70
- });
71
- devbox
72
- .command("upload <id> <file>")
73
- .description("Upload a file to a devbox")
74
- .option("-p, --path <path>", "Target path in devbox")
75
- .option("-o, --output [format]", "Output format: text|json|yaml (default: text)")
76
- .action(uploadFile);
77
- // Additional devbox commands
78
- devbox
79
- .command("get <id>")
80
- .description("Get devbox details")
81
- .option("-o, --output [format]", "Output format: text|json|yaml (default: json)")
82
- .action(async (id, options) => {
83
- const { getDevbox } = await import("./commands/devbox/get.js");
84
- await getDevbox(id, options);
85
- });
86
- devbox
87
- .command("suspend <id>")
88
- .description("Suspend a devbox")
89
- .option("-o, --output [format]", "Output format: text|json|yaml (default: text)")
90
- .action(async (id, options) => {
91
- const { suspendDevbox } = await import("./commands/devbox/suspend.js");
92
- await suspendDevbox(id, options);
93
- });
94
- devbox
95
- .command("resume <id>")
96
- .description("Resume a suspended devbox")
97
- .option("-o, --output [format]", "Output format: text|json|yaml (default: text)")
98
- .action(async (id, options) => {
99
- const { resumeDevbox } = await import("./commands/devbox/resume.js");
100
- await resumeDevbox(id, options);
101
- });
102
- devbox
103
- .command("shutdown <id>")
104
- .description("Shutdown a devbox")
105
- .option("-o, --output [format]", "Output format: text|json|yaml (default: text)")
106
- .action(async (id, options) => {
107
- const { shutdownDevbox } = await import("./commands/devbox/shutdown.js");
108
- await shutdownDevbox(id, options);
109
- });
110
- devbox
111
- .command("ssh <id>")
112
- .description("SSH into a devbox")
113
- .option("--config-only", "Print SSH config only")
114
- .option("--no-wait", "Do not wait for devbox to be ready")
115
- .option("--timeout <seconds>", "Timeout in seconds to wait for readiness", "180")
116
- .option("--poll-interval <seconds>", "Polling interval in seconds while waiting", "3")
117
- .option("-o, --output [format]", "Output format: text|json|yaml (default: text)")
118
- .action(async (id, options) => {
119
- const { sshDevbox } = await import("./commands/devbox/ssh.js");
120
- await sshDevbox(id, options);
121
- });
122
- devbox
123
- .command("scp <id> <src> <dst>")
124
- .description("Copy files to/from a devbox using scp")
125
- .option("--scp-options <options>", "Additional scp options (quoted)")
126
- .option("-o, --output [format]", "Output format: text|json|yaml (default: text)")
127
- .action(async (id, src, dst, options) => {
128
- const { scpFiles } = await import("./commands/devbox/scp.js");
129
- await scpFiles(id, { src, dst, ...options });
130
- });
131
- devbox
132
- .command("rsync <id> <src> <dst>")
133
- .description("Sync files to/from a devbox using rsync")
134
- .option("--rsync-options <options>", "Additional rsync options (quoted)")
135
- .option("-o, --output [format]", "Output format: text|json|yaml (default: text)")
136
- .action(async (id, src, dst, options) => {
137
- const { rsyncFiles } = await import("./commands/devbox/rsync.js");
138
- await rsyncFiles(id, { src, dst, ...options });
139
- });
140
- devbox
141
- .command("tunnel <id> <ports>")
142
- .description("Create a port-forwarding tunnel to a devbox")
143
- .option("-o, --output [format]", "Output format: text|json|yaml (default: text)")
144
- .action(async (id, ports, options) => {
145
- const { createTunnel } = await import("./commands/devbox/tunnel.js");
146
- await createTunnel(id, { ports, ...options });
147
- });
148
- devbox
149
- .command("read <id>")
150
- .description("Read a file from a devbox using the API")
151
- .option("--remote <path>", "Remote file path to read from the devbox")
152
- .option("--output-path <path>", "Local file path to write the contents to")
153
- .option("-o, --output [format]", "Output format: text|json|yaml (default: text)")
154
- .action(async (id, options) => {
155
- const { readFile } = await import("./commands/devbox/read.js");
156
- await readFile(id, options);
157
- });
158
- devbox
159
- .command("write <id>")
160
- .description("Write a file to a devbox using the API")
161
- .option("--input <path>", "Local file path to read contents from")
162
- .option("--remote <path>", "Remote file path to write to on the devbox")
163
- .option("-o, --output [format]", "Output format: text|json|yaml (default: text)")
164
- .action(async (id, options) => {
165
- const { writeFile } = await import("./commands/devbox/write.js");
166
- await writeFile(id, options);
167
- });
168
- devbox
169
- .command("download <id>")
170
- .description("Download a file from a devbox")
171
- .option("--file-path <path>", "Path to the file in the devbox")
172
- .option("--output-path <path>", "Local path where to save the downloaded file")
173
- .option("-o, --output-format [format]", "Output format: text|json|yaml (default: interactive)")
174
- .action(async (id, options) => {
175
- const { downloadFile } = await import("./commands/devbox/download.js");
176
- await downloadFile(id, options);
177
- });
178
- devbox
179
- .command("exec-async <id> <command...>")
180
- .description("Execute a command asynchronously on a devbox")
181
- .option("--shell-name <name>", "Shell name to use (optional)")
182
- .option("-o, --output [format]", "Output format: text|json|yaml (default: text)")
183
- .action(async (id, command, options) => {
184
- const { execAsync } = await import("./commands/devbox/execAsync.js");
185
- await execAsync(id, { command: command.join(" "), ...options });
186
- });
187
- devbox
188
- .command("get-async <id> <execution-id>")
189
- .description("Get status of an async execution")
190
- .option("-o, --output [format]", "Output format: text|json|yaml (default: text)")
191
- .action(async (id, executionId, options) => {
192
- const { getAsync } = await import("./commands/devbox/getAsync.js");
193
- await getAsync(id, { executionId, ...options });
194
- });
195
- devbox
196
- .command("send-stdin <id> <execution-id>")
197
- .description("Send stdin to a running async execution")
198
- .option("--text <text>", "Text content to send to stdin")
199
- .option("--signal <signal>", "Signal to send (EOF, INTERRUPT)")
200
- .option("-o, --output [format]", "Output format: text|json|yaml (default: text)")
201
- .action(async (id, executionId, options) => {
202
- const { sendStdin } = await import("./commands/devbox/sendStdin.js");
203
- await sendStdin(id, executionId, options);
204
- });
205
- devbox
206
- .command("logs <id>")
207
- .description("View devbox logs")
208
- .option("-o, --output [format]", "Output format: text|json|yaml (default: text)")
209
- .action(async (id, options) => {
210
- const { getLogs } = await import("./commands/devbox/logs.js");
211
- await getLogs(id, options);
212
- });
213
- // Snapshot commands
214
- const snapshot = program
215
- .command("snapshot")
216
- .description("Manage devbox snapshots")
217
- .alias("snap");
218
- snapshot
219
- .command("list")
220
- .description("List all snapshots")
221
- .option("-d, --devbox <id>", "Filter by devbox ID")
222
- .option("-o, --output [format]", "Output format: text|json|yaml (default: json)")
223
- .action(async (options) => {
224
- const { listSnapshots } = await import("./commands/snapshot/list.js");
225
- await listSnapshots(options);
226
- });
227
- snapshot
228
- .command("create <devbox-id>")
229
- .description("Create a snapshot of a devbox")
230
- .option("-n, --name <name>", "Snapshot name")
231
- .option("-o, --output [format]", "Output format: text|json|yaml (default: text)")
232
- .action(async (devboxId, options) => {
233
- const { createSnapshot } = await import("./commands/snapshot/create.js");
234
- createSnapshot(devboxId, options);
235
- });
236
- snapshot
237
- .command("delete <id>")
238
- .description("Delete a snapshot")
239
- .alias("rm")
240
- .option("-o, --output [format]", "Output format: text|json|yaml (default: text)")
241
- .action(async (id, options) => {
242
- const { deleteSnapshot } = await import("./commands/snapshot/delete.js");
243
- deleteSnapshot(id, options);
244
- });
245
- snapshot
246
- .command("get <id>")
247
- .description("Get snapshot details")
248
- .option("-o, --output [format]", "Output format: text|json|yaml (default: json)")
249
- .action(async (id, options) => {
250
- const { getSnapshot } = await import("./commands/snapshot/get.js");
251
- await getSnapshot({ id, ...options });
252
- });
253
- snapshot
254
- .command("status <snapshot-id>")
255
- .description("Get snapshot operation status")
256
- .option("-o, --output [format]", "Output format: text|json|yaml (default: text)")
257
- .action(async (snapshotId, options) => {
258
- const { getSnapshotStatus } = await import("./commands/snapshot/status.js");
259
- await getSnapshotStatus({ snapshotId, ...options });
260
- });
261
- // Blueprint commands
262
- const blueprint = program
263
- .command("blueprint")
264
- .description("Manage blueprints")
265
- .alias("bp");
266
- blueprint
267
- .command("list")
268
- .description("List all blueprints")
269
- .option("-n, --name <name>", "Filter by blueprint name")
270
- .option("-o, --output [format]", "Output format: text|json|yaml (default: json)")
271
- .action(async (options) => {
272
- const { listBlueprints } = await import("./commands/blueprint/list.js");
273
- await listBlueprints(options);
274
- });
275
- blueprint
276
- .command("create")
277
- .description("Create a new blueprint")
278
- .requiredOption("--name <name>", "Blueprint name (required)")
279
- .option("--dockerfile <content>", "Dockerfile contents")
280
- .option("--dockerfile-path <path>", "Dockerfile path")
281
- .option("--system-setup-commands <commands...>", "System setup commands")
282
- .option("--resources <size>", "Resource size (X_SMALL, SMALL, MEDIUM, LARGE, X_LARGE, XX_LARGE)")
283
- .option("--architecture <arch>", "Architecture (arm64, x86_64)")
284
- .option("--available-ports <ports...>", "Available ports")
285
- .option("--root", "Run as root")
286
- .option("--user <user:uid>", "Run as this user (format: username:uid)")
287
- .option("-o, --output [format]", "Output format: text|json|yaml (default: json)")
288
- .action(async (options) => {
289
- const { createBlueprint } = await import("./commands/blueprint/create.js");
290
- await createBlueprint(options);
291
- });
292
- blueprint
293
- .command("get <name-or-id>")
294
- .description("Get blueprint details by name or ID (IDs start with bpt_)")
295
- .option("-o, --output [format]", "Output format: text|json|yaml (default: json)")
296
- .action(async (id, options) => {
297
- const { getBlueprint } = await import("./commands/blueprint/get.js");
298
- await getBlueprint({ id, ...options });
299
- });
300
- blueprint
301
- .command("logs <name-or-id>")
302
- .description("Get blueprint build logs by name or ID (IDs start with bpt_)")
303
- .option("-o, --output [format]", "Output format: text|json|yaml (default: text)")
304
- .action(async (id, options) => {
305
- const { getBlueprintLogs } = await import("./commands/blueprint/logs.js");
306
- await getBlueprintLogs({ id, ...options });
307
- });
308
- // Object storage commands
309
- const object = program
310
- .command("object")
311
- .description("Manage object storage")
312
- .alias("obj");
313
- object
314
- .command("list")
315
- .description("List objects")
316
- .option("--limit <n>", "Max results", "20")
317
- .option("--starting-after <id>", "Starting point for pagination")
318
- .option("--name <name>", "Filter by name (partial match supported)")
319
- .option("--content-type <type>", "Filter by content type")
320
- .option("--state <state>", "Filter by state (UPLOADING, READ_ONLY, DELETED)")
321
- .option("--search <query>", "Search by object ID or name")
322
- .option("--public", "List public objects only")
323
- .option("-o, --output [format]", "Output format: text|json|yaml (default: json)")
324
- .action(async (options) => {
325
- const { listObjects } = await import("./commands/object/list.js");
326
- await listObjects(options);
327
- });
328
- object
329
- .command("get <id>")
330
- .description("Get object details")
331
- .option("-o, --output [format]", "Output format: text|json|yaml (default: text)")
332
- .action(async (id, options) => {
333
- const { getObject } = await import("./commands/object/get.js");
334
- await getObject({ id, ...options });
335
- });
336
- object
337
- .command("download <id> <path>")
338
- .description("Download object to local file")
339
- .option("--extract", "Extract downloaded archive after download")
340
- .option("--duration-seconds <seconds>", "Duration in seconds for the presigned URL validity", "3600")
341
- .option("-o, --output [format]", "Output format: text|json|yaml (default: text)")
342
- .action(async (id, path, options) => {
343
- const { downloadObject } = await import("./commands/object/download.js");
344
- await downloadObject({ id, path, ...options });
345
- });
346
- object
347
- .command("upload <path>")
348
- .description("Upload a file as an object")
349
- .option("--name <name>", "Object name (required)")
350
- .option("--content-type <type>", "Content type: unspecified|text|binary|gzip|tar|tgz")
351
- .option("--public", "Make object publicly accessible")
352
- .option("-o, --output [format]", "Output format: text|json|yaml (default: text)")
353
- .action(async (path, options) => {
354
- const { uploadObject } = await import("./commands/object/upload.js");
355
- if (!options.output) {
356
- const { runInteractiveCommand } = await import("./utils/interactiveCommand.js");
357
- await runInteractiveCommand(() => uploadObject({ path, ...options }));
358
- }
359
- else {
360
- await uploadObject({ path, ...options });
361
- }
362
- });
363
- object
364
- .command("delete <id>")
365
- .description("Delete an object (irreversible)")
366
- .option("-o, --output [format]", "Output format: text|json|yaml (default: text)")
367
- .action(async (id, options) => {
368
- const { deleteObject } = await import("./commands/object/delete.js");
369
- await deleteObject({ id, ...options });
370
- });
371
- // MCP server commands
372
- const mcp = program
373
- .command("mcp")
374
- .description("Model Context Protocol (MCP) server commands");
375
- mcp
376
- .command("start")
377
- .description("Start the MCP server")
378
- .option("--http", "Use HTTP/SSE transport instead of stdio")
379
- .option("-p, --port <port>", "Port to listen on for HTTP mode (default: 3000)", parseInt)
380
- .action(async (options) => {
381
- if (options.http) {
382
- const { startMcpHttpServer } = await import("./commands/mcp-http.js");
383
- await startMcpHttpServer(options.port);
384
- }
385
- else {
386
- const { startMcpServer } = await import("./commands/mcp.js");
387
- await startMcpServer();
388
- }
389
- });
390
- mcp
391
- .command("install")
392
- .description("Install Runloop MCP server configuration in Claude Desktop")
393
- .action(async () => {
394
- const { installMcpConfig } = await import("./commands/mcp-install.js");
395
- await installMcpConfig();
396
- });
397
- // Hidden command: 'rli mcp' without subcommand starts the server (for Claude Desktop config compatibility)
398
- program
399
- .command("mcp-server", { hidden: true })
400
- .option("--http", "Use HTTP/SSE transport instead of stdio")
401
- .option("-p, --port <port>", "Port to listen on for HTTP mode (default: 3000)", parseInt)
402
- .action(async (options) => {
403
- if (options.http) {
404
- const { startMcpHttpServer } = await import("./commands/mcp-http.js");
405
- await startMcpHttpServer(options.port);
406
- }
407
- else {
408
- const { startMcpServer } = await import("./commands/mcp.js");
409
- await startMcpServer();
410
- }
411
- });
13
+ const program = createProgram();
412
14
  // Main CLI entry point
413
15
  (async () => {
414
16
  // Initialize theme system early (before any UI rendering)
@@ -417,21 +19,7 @@ program
417
19
  // Check if API key is configured (except for mcp commands)
418
20
  const args = process.argv.slice(2);
419
21
  if (!process.env.RUNLOOP_API_KEY) {
420
- console.error(`
421
- ❌ API key not configured.
422
-
423
- To get started:
424
- 1. Go to https://platform.runloop.ai/settings and create an API key
425
- 2. Set the environment variable:
426
-
427
- export RUNLOOP_API_KEY=your_api_key_here
428
-
429
- To make it permanent, add this line to your shell config:
430
- • For zsh: echo 'export RUNLOOP_API_KEY=your_api_key_here' >> ~/.zshrc
431
- • For bash: echo 'export RUNLOOP_API_KEY=your_api_key_here' >> ~/.bashrc
432
-
433
- Then restart your terminal or run: source ~/.zshrc (or ~/.bashrc)
434
- `);
22
+ console.error(getApiKeyErrorMessage());
435
23
  processUtils.exit(1);
436
24
  return; // Ensure execution stops
437
25
  }
@@ -452,8 +452,12 @@ const ListDevboxesUI = ({ status, onBack, onExit, onNavigateToDetail, }) => {
452
452
  if (showCreate) {
453
453
  return (_jsx(DevboxCreatePage, { onBack: () => {
454
454
  setShowCreate(false);
455
- }, onCreate: () => {
455
+ }, onCreate: (devbox) => {
456
456
  setShowCreate(false);
457
+ // Navigate to the newly created devbox's detail page
458
+ if (onNavigateToDetail) {
459
+ onNavigateToDetail(devbox.id);
460
+ }
457
461
  } }));
458
462
  }
459
463
  // Actions view
@@ -7,6 +7,7 @@ import { StatusBadge } from "./StatusBadge.js";
7
7
  import { MetadataDisplay } from "./MetadataDisplay.js";
8
8
  import { Breadcrumb } from "./Breadcrumb.js";
9
9
  import { DevboxActionsMenu } from "./DevboxActionsMenu.js";
10
+ import { StateHistory } from "./StateHistory.js";
10
11
  import { getDevboxUrl } from "../utils/url.js";
11
12
  import { colors } from "../utils/theme.js";
12
13
  import { useViewportHeight } from "../hooks/useViewportHeight.js";
@@ -433,7 +434,7 @@ export const DevboxDetailPage = ({ devbox: initialDevbox, onBack, }) => {
433
434
  lp?.architecture) && (_jsxs(Box, { flexDirection: "column", paddingX: 1, flexGrow: 1, children: [_jsxs(Text, { color: colors.warning, bold: true, children: [figures.squareSmallFilled, " Resources"] }), _jsxs(Text, { dimColor: true, children: [lp?.resource_size_request && `${lp.resource_size_request}`, lp?.architecture && ` • ${lp.architecture}`, lp?.custom_cpu_cores && ` • ${lp.custom_cpu_cores}VCPU`, lp?.custom_gb_memory && ` • ${lp.custom_gb_memory}GB RAM`, lp?.custom_disk_size && ` • ${lp.custom_disk_size}GB DISC`] })] })), hasCapabilities && (_jsxs(Box, { flexDirection: "column", paddingX: 1, flexGrow: 1, children: [_jsxs(Text, { color: colors.info, bold: true, children: [figures.tick, " Capabilities"] }), _jsx(Text, { dimColor: true, children: selectedDevbox.capabilities
434
435
  .filter((c) => c !== "unknown")
435
436
  .join(", ") })] })), (selectedDevbox.blueprint_id || selectedDevbox.snapshot_id) && (_jsxs(Box, { flexDirection: "column", paddingX: 1, flexGrow: 1, children: [_jsxs(Text, { color: colors.secondary, bold: true, children: [figures.circleFilled, " Source"] }), selectedDevbox.blueprint_id && (_jsxs(_Fragment, { children: [_jsx(Text, { dimColor: true, children: "BP: " }), _jsx(Text, { color: colors.idColor, children: selectedDevbox.blueprint_id })] })), selectedDevbox.snapshot_id && (_jsxs(_Fragment, { children: [_jsx(Text, { dimColor: true, children: "Snap: " }), _jsx(Text, { color: colors.idColor, children: selectedDevbox.snapshot_id })] }))] }))] }), selectedDevbox.metadata &&
436
- Object.keys(selectedDevbox.metadata).length > 0 && (_jsx(Box, { marginBottom: 1, paddingX: 1, children: _jsx(MetadataDisplay, { metadata: selectedDevbox.metadata, showBorder: false }) })), selectedDevbox.failure_reason && (_jsxs(Box, { marginBottom: 1, paddingX: 1, children: [_jsxs(Text, { color: colors.error, bold: true, children: [figures.cross, " "] }), _jsx(Text, { color: colors.error, dimColor: true, children: selectedDevbox.failure_reason })] })), _jsxs(Box, { flexDirection: "column", marginTop: 1, children: [_jsxs(Text, { color: colors.primary, bold: true, children: [figures.play, " Actions"] }), _jsx(Box, { flexDirection: "column", children: operations.map((op, index) => {
437
+ Object.keys(selectedDevbox.metadata).length > 0 && (_jsx(Box, { marginBottom: 1, paddingX: 1, children: _jsx(MetadataDisplay, { metadata: selectedDevbox.metadata, showBorder: false }) })), selectedDevbox.failure_reason && (_jsxs(Box, { marginBottom: 1, paddingX: 1, children: [_jsxs(Text, { color: colors.error, bold: true, children: [figures.cross, " "] }), _jsx(Text, { color: colors.error, dimColor: true, children: selectedDevbox.failure_reason })] })), _jsx(StateHistory, { stateTransitions: selectedDevbox.state_transitions }), _jsxs(Box, { flexDirection: "column", marginTop: 1, children: [_jsxs(Text, { color: colors.primary, bold: true, children: [figures.play, " Actions"] }), _jsx(Box, { flexDirection: "column", children: operations.map((op, index) => {
437
438
  const isSelected = index === selectedOperation;
438
439
  return (_jsxs(Box, { children: [_jsxs(Text, { color: isSelected ? colors.primary : colors.textDim, children: [isSelected ? figures.pointer : " ", " "] }), _jsxs(Text, { color: isSelected ? op.color : colors.textDim, bold: isSelected, children: [op.icon, " ", op.label] }), _jsxs(Text, { color: colors.textDim, dimColor: true, children: [" ", "[", op.shortcut, "]"] })] }, op.key));
439
440
  }) })] }), _jsx(Box, { marginTop: 1, children: _jsxs(Text, { color: colors.textDim, dimColor: true, children: [figures.arrowUp, figures.arrowDown, " Navigate \u2022 [Enter] Execute \u2022 [i] Full Details \u2022 [o] Browser \u2022 [q] Back"] }) })] }));
@@ -0,0 +1,80 @@
1
+ import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { Box, Text } from "ink";
3
+ import figures from "figures";
4
+ import { colors } from "../utils/theme.js";
5
+ // Format time ago in a succinct way
6
+ const formatTimeAgo = (timestamp) => {
7
+ const seconds = Math.floor((Date.now() - timestamp) / 1000);
8
+ if (seconds < 60)
9
+ return `${seconds}s ago`;
10
+ const minutes = Math.floor(seconds / 60);
11
+ if (minutes < 60)
12
+ return `${minutes}m ago`;
13
+ const hours = Math.floor(minutes / 60);
14
+ if (hours < 24)
15
+ return `${hours}h ago`;
16
+ const days = Math.floor(hours / 24);
17
+ if (days < 30)
18
+ return `${days}d ago`;
19
+ const months = Math.floor(days / 30);
20
+ if (months < 12)
21
+ return `${months}mo ago`;
22
+ const years = Math.floor(months / 12);
23
+ return `${years}y ago`;
24
+ };
25
+ // Format duration in a succinct way
26
+ const formatDuration = (milliseconds) => {
27
+ const seconds = Math.floor(milliseconds / 1000);
28
+ if (seconds < 60)
29
+ return `${seconds}s`;
30
+ const minutes = Math.floor(seconds / 60);
31
+ if (minutes < 60)
32
+ return `${minutes}m`;
33
+ const hours = Math.floor(minutes / 60);
34
+ if (hours < 24)
35
+ return `${hours}h ${minutes % 60}m`;
36
+ const days = Math.floor(hours / 24);
37
+ return `${days}d ${hours % 24}h`;
38
+ };
39
+ // Capitalize first letter of a string
40
+ const capitalize = (str) => str.charAt(0).toUpperCase() + str.slice(1);
41
+ export const StateHistory = ({ stateTransitions }) => {
42
+ if (!stateTransitions ||
43
+ !Array.isArray(stateTransitions) ||
44
+ stateTransitions.length === 0) {
45
+ return null;
46
+ }
47
+ // Get last 3 transitions (most recent first)
48
+ const lastThree = stateTransitions
49
+ .slice(-3)
50
+ .reverse()
51
+ .map((transition, idx, arr) => {
52
+ const transitionTime = transition.transition_time_ms;
53
+ // Calculate duration: time until next transition, or until now if it's the current state
54
+ let duration = 0;
55
+ if (transitionTime) {
56
+ if (idx === 0) {
57
+ // Most recent state - duration is from transition time to now
58
+ duration = Date.now() - transitionTime;
59
+ }
60
+ else {
61
+ // Previous state - duration is from this transition to the next one
62
+ const nextTransition = arr[idx - 1];
63
+ const nextTransitionTime = nextTransition.transition_time_ms;
64
+ if (nextTransitionTime) {
65
+ duration = nextTransitionTime - transitionTime;
66
+ }
67
+ }
68
+ }
69
+ return {
70
+ status: transition.status,
71
+ transitionTime,
72
+ duration,
73
+ };
74
+ })
75
+ .filter((state) => state.transitionTime); // Only show states with valid timestamps
76
+ if (lastThree.length === 0) {
77
+ return null;
78
+ }
79
+ return (_jsxs(Box, { flexDirection: "column", marginBottom: 1, paddingX: 1, children: [_jsxs(Text, { color: colors.info, bold: true, children: [figures.circleFilled, " State History"] }), _jsx(Box, { flexDirection: "column", children: lastThree.map((state, idx) => (_jsx(Box, { flexDirection: "column", children: _jsxs(Text, { dimColor: true, children: [capitalize(state.status), state.transitionTime && (_jsxs(_Fragment, { children: [" ", "at ", new Date(state.transitionTime).toLocaleString(), " ", _jsxs(Text, { color: colors.textDim, dimColor: true, children: ["(", formatTimeAgo(state.transitionTime), ")"] }), state.duration > 0 && (_jsxs(_Fragment, { children: [" ", "\u2022 Duration:", " ", _jsx(Text, { color: colors.info, children: formatDuration(state.duration) })] }))] }))] }) }, idx))) })] }));
80
+ };
@@ -2,10 +2,10 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useNavigation } from "../store/navigationStore.js";
3
3
  import { DevboxCreatePage } from "../components/DevboxCreatePage.js";
4
4
  export function DevboxCreateScreen() {
5
- const { goBack } = useNavigation();
6
- const handleCreate = () => {
7
- // After creation, go back to list (which will refresh)
8
- goBack();
5
+ const { goBack, navigate } = useNavigation();
6
+ const handleCreate = (devbox) => {
7
+ // After creation, navigate to the devbox detail page
8
+ navigate("devbox-detail", { devboxId: devbox.id });
9
9
  };
10
10
  return _jsx(DevboxCreatePage, { onBack: goBack, onCreate: handleCreate });
11
11
  }