@runloop/rl-cli 1.2.0 → 1.4.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/README.md +29 -8
- package/dist/commands/blueprint/from-dockerfile.js +182 -0
- package/dist/commands/blueprint/list.js +97 -28
- package/dist/commands/blueprint/prune.js +7 -19
- package/dist/commands/devbox/create.js +3 -0
- package/dist/commands/devbox/list.js +44 -65
- package/dist/commands/menu.js +2 -1
- package/dist/commands/network-policy/create.js +27 -0
- package/dist/commands/network-policy/delete.js +21 -0
- package/dist/commands/network-policy/get.js +15 -0
- package/dist/commands/network-policy/list.js +494 -0
- package/dist/commands/object/list.js +516 -24
- package/dist/commands/snapshot/list.js +90 -29
- package/dist/components/Banner.js +109 -8
- package/dist/components/ConfirmationPrompt.js +45 -0
- package/dist/components/DevboxActionsMenu.js +42 -6
- package/dist/components/DevboxCard.js +1 -1
- package/dist/components/DevboxCreatePage.js +174 -168
- package/dist/components/DevboxDetailPage.js +218 -272
- package/dist/components/LogsViewer.js +8 -1
- package/dist/components/MainMenu.js +35 -4
- package/dist/components/NavigationTips.js +24 -0
- package/dist/components/NetworkPolicyCreatePage.js +263 -0
- package/dist/components/OperationsMenu.js +9 -1
- package/dist/components/ResourceActionsMenu.js +5 -1
- package/dist/components/ResourceDetailPage.js +204 -0
- package/dist/components/ResourceListView.js +19 -2
- package/dist/components/StatusBadge.js +2 -2
- package/dist/components/Table.js +6 -8
- package/dist/components/form/FormActionButton.js +7 -0
- package/dist/components/form/FormField.js +7 -0
- package/dist/components/form/FormListManager.js +112 -0
- package/dist/components/form/FormSelect.js +34 -0
- package/dist/components/form/FormTextInput.js +8 -0
- package/dist/components/form/index.js +8 -0
- package/dist/hooks/useViewportHeight.js +38 -20
- package/dist/router/Router.js +23 -1
- package/dist/screens/BlueprintDetailScreen.js +355 -0
- package/dist/screens/DevboxDetailScreen.js +4 -4
- package/dist/screens/MenuScreen.js +6 -0
- package/dist/screens/NetworkPolicyCreateScreen.js +7 -0
- package/dist/screens/NetworkPolicyDetailScreen.js +247 -0
- package/dist/screens/NetworkPolicyListScreen.js +7 -0
- package/dist/screens/ObjectDetailScreen.js +377 -0
- package/dist/screens/ObjectListScreen.js +7 -0
- package/dist/screens/SnapshotDetailScreen.js +208 -0
- package/dist/services/blueprintService.js +30 -11
- package/dist/services/networkPolicyService.js +108 -0
- package/dist/services/objectService.js +101 -0
- package/dist/services/snapshotService.js +39 -3
- package/dist/store/blueprintStore.js +4 -10
- package/dist/store/index.js +1 -0
- package/dist/store/networkPolicyStore.js +83 -0
- package/dist/store/objectStore.js +92 -0
- package/dist/store/snapshotStore.js +4 -8
- package/dist/utils/commands.js +65 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](https://github.com/runloopai/rl-cli/actions/workflows/ci.yml)
|
|
5
5
|
[](LICENSE)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
A **TUI + CLI** for the [Runloop.ai](https://runloop.ai) platform. Use it as an **interactive TUI** (Terminal User Interface) with rich UI components, or as a **traditional CLI** for scripting and automation.
|
|
8
8
|
|
|
9
9
|
📖 **[Full Documentation](https://docs.runloop.ai/docs/tools/cli)**
|
|
10
10
|
|
|
@@ -15,10 +15,10 @@ An interactive CLI for interacting with the [Runloop.ai](https://runloop.ai) pla
|
|
|
15
15
|
## Quick Example
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
|
-
#
|
|
18
|
+
# TUI mode - launches an interactive terminal UI
|
|
19
19
|
rli
|
|
20
20
|
|
|
21
|
-
#
|
|
21
|
+
# CLI mode - perfect for scripts and automation
|
|
22
22
|
rli devbox list # Outputs JSON/text
|
|
23
23
|
rli devbox create --name my-devbox
|
|
24
24
|
rli devbox exec <devbox-id> echo "Hello World"
|
|
@@ -27,10 +27,11 @@ rli devbox delete <devbox-id>
|
|
|
27
27
|
|
|
28
28
|
## Features
|
|
29
29
|
|
|
30
|
+
- 🖥️ **TUI mode** — Interactive terminal UI with menus, tables, and real-time updates
|
|
31
|
+
- 🎯 **CLI mode** — Traditional commands with text, JSON, and YAML output for scripting
|
|
30
32
|
- ⚡ Fast and responsive with pagination
|
|
31
33
|
- 📦 Manage devboxes, snapshots, and blueprints
|
|
32
|
-
- 🚀 Execute commands,
|
|
33
|
-
- 🎯 Traditional CLI with text, json, and yaml output modes.
|
|
34
|
+
- 🚀 Execute commands, SSH, view logs in devboxes
|
|
34
35
|
- 🤖 **Model Context Protocol (MCP) server for AI integration**
|
|
35
36
|
|
|
36
37
|
## Installation
|
|
@@ -53,13 +54,23 @@ Get your API key from [https://runloop.ai/settings](https://runloop.ai/settings)
|
|
|
53
54
|
|
|
54
55
|
## Usage
|
|
55
56
|
|
|
56
|
-
### Interactive
|
|
57
|
+
### TUI (Interactive Mode)
|
|
57
58
|
|
|
58
59
|
```bash
|
|
59
|
-
rli #
|
|
60
|
+
rli # Launch the interactive TUI
|
|
60
61
|
rli --help # See help information
|
|
61
62
|
```
|
|
62
63
|
|
|
64
|
+
### CLI (Scripting Mode)
|
|
65
|
+
|
|
66
|
+
All commands support `--output` (`-o`) for format control:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
rli devbox list # Default text output
|
|
70
|
+
rli devbox list -o json # JSON output
|
|
71
|
+
rli devbox list -o yaml # YAML output
|
|
72
|
+
```
|
|
73
|
+
|
|
63
74
|
## Command Structure
|
|
64
75
|
|
|
65
76
|
The CLI is organized into command buckets:
|
|
@@ -107,6 +118,7 @@ rli blueprint create # Create a new blueprint
|
|
|
107
118
|
rli blueprint get <name-or-id> # Get blueprint details by name or ID (...
|
|
108
119
|
rli blueprint logs <name-or-id> # Get blueprint build logs by name or I...
|
|
109
120
|
rli blueprint prune <name> # Delete old blueprint builds, keeping ...
|
|
121
|
+
rli blueprint from-dockerfile # Create a blueprint from a Dockerfile ...
|
|
110
122
|
```
|
|
111
123
|
|
|
112
124
|
### Object Commands (alias: `obj`)
|
|
@@ -119,6 +131,15 @@ rli object upload <path> # Upload a file as an object
|
|
|
119
131
|
rli object delete <id> # Delete an object (irreversible)
|
|
120
132
|
```
|
|
121
133
|
|
|
134
|
+
### Network-policy Commands (alias: `np`)
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
rli network-policy list # List network policies
|
|
138
|
+
rli network-policy get <id> # Get network policy details
|
|
139
|
+
rli network-policy create # Create a new network policy
|
|
140
|
+
rli network-policy delete <id> # Delete a network policy
|
|
141
|
+
```
|
|
142
|
+
|
|
122
143
|
### Mcp Commands
|
|
123
144
|
|
|
124
145
|
```bash
|
|
@@ -160,7 +181,7 @@ rli mcp start --http --port 8080
|
|
|
160
181
|
|
|
161
182
|
## Theme Configuration
|
|
162
183
|
|
|
163
|
-
The
|
|
184
|
+
The TUI supports both light and dark terminal themes and will automatically select the appropriate theme.
|
|
164
185
|
|
|
165
186
|
## Development
|
|
166
187
|
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create blueprint from Dockerfile command
|
|
3
|
+
*
|
|
4
|
+
* Manually handles each step with progress feedback:
|
|
5
|
+
* 1. Upload build context as tarball
|
|
6
|
+
* 2. Create blueprint
|
|
7
|
+
* 3. Poll for build completion
|
|
8
|
+
*/
|
|
9
|
+
import { readFile, stat } from "fs/promises";
|
|
10
|
+
import { resolve, join } from "path";
|
|
11
|
+
import { getClient } from "../../utils/client.js";
|
|
12
|
+
import { output, outputError } from "../../utils/output.js";
|
|
13
|
+
import { StorageObject } from "@runloop/api-client/sdk";
|
|
14
|
+
// Helper to check if we should show progress
|
|
15
|
+
function shouldShowProgress(options) {
|
|
16
|
+
return !options.output || options.output === "text";
|
|
17
|
+
}
|
|
18
|
+
// Helper to log progress (to stderr so it doesn't interfere with JSON output)
|
|
19
|
+
function logProgress(message, options) {
|
|
20
|
+
if (shouldShowProgress(options)) {
|
|
21
|
+
console.error(message);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
// Helper to format elapsed time
|
|
25
|
+
function formatElapsed(startTime) {
|
|
26
|
+
const elapsed = Math.round((Date.now() - startTime) / 1000);
|
|
27
|
+
if (elapsed < 60) {
|
|
28
|
+
return `${elapsed}s`;
|
|
29
|
+
}
|
|
30
|
+
const minutes = Math.floor(elapsed / 60);
|
|
31
|
+
const seconds = elapsed % 60;
|
|
32
|
+
return `${minutes}m ${seconds}s`;
|
|
33
|
+
}
|
|
34
|
+
export async function createBlueprintFromDockerfile(options) {
|
|
35
|
+
const startTime = Date.now();
|
|
36
|
+
try {
|
|
37
|
+
const client = getClient();
|
|
38
|
+
// Resolve build context path (defaults to current directory)
|
|
39
|
+
const buildContextPath = resolve(options.buildContext || ".");
|
|
40
|
+
// Verify build context exists and is a directory
|
|
41
|
+
try {
|
|
42
|
+
const stats = await stat(buildContextPath);
|
|
43
|
+
if (!stats.isDirectory()) {
|
|
44
|
+
outputError(`Build context path is not a directory: ${buildContextPath}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
outputError(`Build context path does not exist: ${buildContextPath}`);
|
|
49
|
+
}
|
|
50
|
+
// Resolve Dockerfile path
|
|
51
|
+
const dockerfilePath = options.dockerfile
|
|
52
|
+
? resolve(options.dockerfile)
|
|
53
|
+
: join(buildContextPath, "Dockerfile");
|
|
54
|
+
// Verify Dockerfile exists
|
|
55
|
+
try {
|
|
56
|
+
const stats = await stat(dockerfilePath);
|
|
57
|
+
if (!stats.isFile()) {
|
|
58
|
+
outputError(`Dockerfile path is not a file: ${dockerfilePath}`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
outputError(`Dockerfile not found: ${dockerfilePath}`);
|
|
63
|
+
}
|
|
64
|
+
// Log initial info
|
|
65
|
+
logProgress(`\n📦 Creating blueprint "${options.name}" from Dockerfile`, options);
|
|
66
|
+
logProgress(` Build context: ${buildContextPath}`, options);
|
|
67
|
+
logProgress(` Dockerfile: ${dockerfilePath}\n`, options);
|
|
68
|
+
// Read the Dockerfile contents
|
|
69
|
+
const dockerfileContents = await readFile(dockerfilePath, "utf-8");
|
|
70
|
+
// Parse user parameters
|
|
71
|
+
let userParameters = undefined;
|
|
72
|
+
if (options.user && options.root) {
|
|
73
|
+
outputError("Only one of --user or --root can be specified");
|
|
74
|
+
}
|
|
75
|
+
else if (options.user) {
|
|
76
|
+
const [username, uid] = options.user.split(":");
|
|
77
|
+
if (!username || !uid) {
|
|
78
|
+
outputError("User must be in format 'username:uid'");
|
|
79
|
+
}
|
|
80
|
+
userParameters = { username, uid: parseInt(uid) };
|
|
81
|
+
}
|
|
82
|
+
else if (options.root) {
|
|
83
|
+
userParameters = { username: "root", uid: 0 };
|
|
84
|
+
}
|
|
85
|
+
// Build launch parameters
|
|
86
|
+
const launchParameters = {};
|
|
87
|
+
if (options.resources) {
|
|
88
|
+
launchParameters.resource_size_request = options.resources;
|
|
89
|
+
}
|
|
90
|
+
if (options.architecture) {
|
|
91
|
+
launchParameters.architecture = options.architecture;
|
|
92
|
+
}
|
|
93
|
+
if (options.availablePorts) {
|
|
94
|
+
launchParameters.available_ports = options.availablePorts.map((port) => parseInt(port, 10));
|
|
95
|
+
}
|
|
96
|
+
if (userParameters) {
|
|
97
|
+
launchParameters.user_parameters = userParameters;
|
|
98
|
+
}
|
|
99
|
+
// Parse TTL (default: 1 hour = 3600000ms)
|
|
100
|
+
const ttlMs = options.ttl ? parseInt(options.ttl) * 1000 : 3600000;
|
|
101
|
+
// Step 1: Upload build context
|
|
102
|
+
logProgress(`⏳ [1/3] Creating and uploading build context tarball...`, options);
|
|
103
|
+
const uploadStart = Date.now();
|
|
104
|
+
const storageObject = await StorageObject.uploadFromDir(client, buildContextPath, {
|
|
105
|
+
name: `build-context-${options.name}`,
|
|
106
|
+
ttl_ms: ttlMs,
|
|
107
|
+
});
|
|
108
|
+
logProgress(`✅ [1/3] Build context uploaded (${formatElapsed(uploadStart)})`, options);
|
|
109
|
+
logProgress(` Object ID: ${storageObject.id}`, options);
|
|
110
|
+
// Step 2: Create the blueprint
|
|
111
|
+
logProgress(`\n⏳ [2/3] Creating blueprint...`, options);
|
|
112
|
+
const createStart = Date.now();
|
|
113
|
+
const createParams = {
|
|
114
|
+
name: options.name,
|
|
115
|
+
dockerfile: dockerfileContents,
|
|
116
|
+
system_setup_commands: options.systemSetupCommands,
|
|
117
|
+
launch_parameters: launchParameters,
|
|
118
|
+
build_context: {
|
|
119
|
+
type: "object",
|
|
120
|
+
object_id: storageObject.id,
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
const blueprintResponse = await client.blueprints.create(createParams);
|
|
124
|
+
logProgress(`✅ [2/3] Blueprint created (${formatElapsed(createStart)})`, options);
|
|
125
|
+
logProgress(` Blueprint ID: ${blueprintResponse.id}`, options);
|
|
126
|
+
// Step 3: Wait for build to complete (unless --no-wait)
|
|
127
|
+
if (options.noWait) {
|
|
128
|
+
logProgress(`\n⏩ Skipping build wait (--no-wait specified)`, options);
|
|
129
|
+
logProgress(` Check status with: rli blueprint get ${blueprintResponse.id}`, options);
|
|
130
|
+
logProgress(` View logs with: rli blueprint logs ${blueprintResponse.id}\n`, options);
|
|
131
|
+
output(blueprintResponse, {
|
|
132
|
+
format: options.output,
|
|
133
|
+
defaultFormat: "json",
|
|
134
|
+
});
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
logProgress(`\n⏳ [3/3] Waiting for build to complete...`, options);
|
|
138
|
+
const buildStart = Date.now();
|
|
139
|
+
let lastStatus = "";
|
|
140
|
+
let pollCount = 0;
|
|
141
|
+
// Poll for completion
|
|
142
|
+
while (true) {
|
|
143
|
+
const blueprint = await client.blueprints.retrieve(blueprintResponse.id);
|
|
144
|
+
const currentStatus = blueprint.status || "unknown";
|
|
145
|
+
// Log status changes
|
|
146
|
+
if (currentStatus !== lastStatus) {
|
|
147
|
+
const elapsed = formatElapsed(buildStart);
|
|
148
|
+
logProgress(` Status: ${currentStatus} (${elapsed})`, options);
|
|
149
|
+
lastStatus = currentStatus;
|
|
150
|
+
}
|
|
151
|
+
else if (pollCount % 10 === 0 && pollCount > 0) {
|
|
152
|
+
// Log periodic updates even without status change (every ~30s)
|
|
153
|
+
const elapsed = formatElapsed(buildStart);
|
|
154
|
+
logProgress(` Still ${currentStatus}... (${elapsed})`, options);
|
|
155
|
+
}
|
|
156
|
+
// Check for terminal states
|
|
157
|
+
if (blueprint.status === "build_complete") {
|
|
158
|
+
logProgress(`\n✅ [3/3] Build completed successfully! (${formatElapsed(buildStart)})`, options);
|
|
159
|
+
logProgress(`\n🎉 Blueprint "${options.name}" is ready!`, options);
|
|
160
|
+
logProgress(` Total time: ${formatElapsed(startTime)}`, options);
|
|
161
|
+
logProgress(` Blueprint ID: ${blueprint.id}\n`, options);
|
|
162
|
+
output(blueprint, { format: options.output, defaultFormat: "json" });
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
if (blueprint.status === "failed") {
|
|
166
|
+
logProgress(`\n❌ [3/3] Build failed (${formatElapsed(buildStart)})`, options);
|
|
167
|
+
if (blueprint.failure_reason) {
|
|
168
|
+
logProgress(` Reason: ${blueprint.failure_reason}`, options);
|
|
169
|
+
}
|
|
170
|
+
logProgress(` View logs with: rli blueprint logs ${blueprint.id}\n`, options);
|
|
171
|
+
outputError(`Blueprint build failed. Status: ${blueprint.status}`);
|
|
172
|
+
}
|
|
173
|
+
// Wait before next poll (3 seconds)
|
|
174
|
+
await new Promise((resolve) => setTimeout(resolve, 3000));
|
|
175
|
+
pollCount++;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
catch (error) {
|
|
179
|
+
logProgress(`\n❌ Failed after ${formatElapsed(startTime)}`, options);
|
|
180
|
+
outputError("Failed to create blueprint from Dockerfile", error);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
@@ -9,6 +9,7 @@ import { SpinnerComponent } from "../../components/Spinner.js";
|
|
|
9
9
|
import { ErrorMessage } from "../../components/ErrorMessage.js";
|
|
10
10
|
import { SuccessMessage } from "../../components/SuccessMessage.js";
|
|
11
11
|
import { Breadcrumb } from "../../components/Breadcrumb.js";
|
|
12
|
+
import { NavigationTips } from "../../components/NavigationTips.js";
|
|
12
13
|
import { createTextColumn, Table } from "../../components/Table.js";
|
|
13
14
|
import { ActionsPopup } from "../../components/ActionsPopup.js";
|
|
14
15
|
import { formatTimeAgo } from "../../components/ResourceListView.js";
|
|
@@ -21,6 +22,7 @@ import { useExitOnCtrlC } from "../../hooks/useExitOnCtrlC.js";
|
|
|
21
22
|
import { useViewportHeight } from "../../hooks/useViewportHeight.js";
|
|
22
23
|
import { useCursorPagination } from "../../hooks/useCursorPagination.js";
|
|
23
24
|
import { useNavigation } from "../../store/navigationStore.js";
|
|
25
|
+
import { ConfirmationPrompt } from "../../components/ConfirmationPrompt.js";
|
|
24
26
|
const DEFAULT_PAGE_SIZE = 10;
|
|
25
27
|
const ListBlueprintsUI = ({ onBack, onExit, }) => {
|
|
26
28
|
const { exit: inkExit } = useApp();
|
|
@@ -33,6 +35,7 @@ const ListBlueprintsUI = ({ onBack, onExit, }) => {
|
|
|
33
35
|
const [operationError, setOperationError] = React.useState(null);
|
|
34
36
|
const [operationLoading, setOperationLoading] = React.useState(false);
|
|
35
37
|
const [showCreateDevbox, setShowCreateDevbox] = React.useState(false);
|
|
38
|
+
const [showDeleteConfirm, setShowDeleteConfirm] = React.useState(false);
|
|
36
39
|
const [selectedIndex, setSelectedIndex] = React.useState(0);
|
|
37
40
|
const [showPopup, setShowPopup] = React.useState(false);
|
|
38
41
|
const { navigate } = useNavigation();
|
|
@@ -44,13 +47,18 @@ const ListBlueprintsUI = ({ onBack, onExit, }) => {
|
|
|
44
47
|
});
|
|
45
48
|
const PAGE_SIZE = viewportHeight;
|
|
46
49
|
// All width constants
|
|
50
|
+
const fixedWidth = 6; // border + padding
|
|
47
51
|
const statusIconWidth = 2;
|
|
48
52
|
const statusTextWidth = 10;
|
|
49
53
|
const idWidth = 25;
|
|
50
|
-
const nameWidth = Math.max(15, terminalWidth >= 120 ? 30 : 25);
|
|
51
54
|
const descriptionWidth = 40;
|
|
52
55
|
const timeWidth = 20;
|
|
53
56
|
const showDescription = terminalWidth >= 120;
|
|
57
|
+
// Name width uses remaining space after fixed columns
|
|
58
|
+
const baseWidth = fixedWidth + statusIconWidth + statusTextWidth + idWidth + timeWidth;
|
|
59
|
+
const optionalWidth = showDescription ? descriptionWidth : 0;
|
|
60
|
+
const remainingWidth = terminalWidth - baseWidth - optionalWidth;
|
|
61
|
+
const nameWidth = Math.min(80, Math.max(15, remainingWidth));
|
|
54
62
|
// Fetch function for pagination hook
|
|
55
63
|
const fetchPage = React.useCallback(async (params) => {
|
|
56
64
|
const client = getClient();
|
|
@@ -88,7 +96,10 @@ const ListBlueprintsUI = ({ onBack, onExit, }) => {
|
|
|
88
96
|
pageSize: PAGE_SIZE,
|
|
89
97
|
getItemId: (blueprint) => blueprint.id,
|
|
90
98
|
pollInterval: 2000,
|
|
91
|
-
pollingEnabled: !showPopup &&
|
|
99
|
+
pollingEnabled: !showPopup &&
|
|
100
|
+
!showCreateDevbox &&
|
|
101
|
+
!executingOperation &&
|
|
102
|
+
!showDeleteConfirm,
|
|
92
103
|
deps: [PAGE_SIZE],
|
|
93
104
|
});
|
|
94
105
|
// Memoize columns array
|
|
@@ -99,10 +110,7 @@ const ListBlueprintsUI = ({ onBack, onExit, }) => {
|
|
|
99
110
|
width: statusIconWidth,
|
|
100
111
|
render: (blueprint, _index, isSelected) => {
|
|
101
112
|
const statusDisplay = getStatusDisplay(blueprint.status || "");
|
|
102
|
-
|
|
103
|
-
? colors.info
|
|
104
|
-
: statusDisplay.color;
|
|
105
|
-
return (_jsxs(Text, { color: isSelected ? "white" : statusColor, bold: true, dimColor: false, inverse: isSelected, wrap: "truncate", children: [statusDisplay.icon, " "] }));
|
|
113
|
+
return (_jsxs(Text, { color: isSelected ? "white" : statusDisplay.color, bold: true, dimColor: false, inverse: isSelected, wrap: "truncate", children: [statusDisplay.icon, " "] }));
|
|
106
114
|
},
|
|
107
115
|
},
|
|
108
116
|
{
|
|
@@ -123,13 +131,10 @@ const ListBlueprintsUI = ({ onBack, onExit, }) => {
|
|
|
123
131
|
width: statusTextWidth,
|
|
124
132
|
render: (blueprint, _index, isSelected) => {
|
|
125
133
|
const statusDisplay = getStatusDisplay(blueprint.status || "");
|
|
126
|
-
const statusColor = statusDisplay.color === colors.textDim
|
|
127
|
-
? colors.info
|
|
128
|
-
: statusDisplay.color;
|
|
129
134
|
const safeWidth = Math.max(1, statusTextWidth);
|
|
130
135
|
const truncated = statusDisplay.text.slice(0, safeWidth);
|
|
131
136
|
const padded = truncated.padEnd(safeWidth, " ");
|
|
132
|
-
return (_jsx(Text, { color: isSelected ? "white" :
|
|
137
|
+
return (_jsx(Text, { color: isSelected ? "white" : statusDisplay.color, bold: true, dimColor: false, inverse: isSelected, wrap: "truncate", children: padded }));
|
|
133
138
|
},
|
|
134
139
|
},
|
|
135
140
|
createTextColumn("name", "Name", (blueprint) => blueprint.name || "", {
|
|
@@ -156,6 +161,13 @@ const ListBlueprintsUI = ({ onBack, onExit, }) => {
|
|
|
156
161
|
// Helper function to generate operations based on selected blueprint
|
|
157
162
|
const getOperationsForBlueprint = (blueprint) => {
|
|
158
163
|
const operations = [];
|
|
164
|
+
// View Details is always first
|
|
165
|
+
operations.push({
|
|
166
|
+
key: "view_details",
|
|
167
|
+
label: "View Details",
|
|
168
|
+
color: colors.primary,
|
|
169
|
+
icon: figures.pointer,
|
|
170
|
+
});
|
|
159
171
|
// View Logs is always available
|
|
160
172
|
operations.push({
|
|
161
173
|
key: "view_logs",
|
|
@@ -213,6 +225,14 @@ const ListBlueprintsUI = ({ onBack, onExit, }) => {
|
|
|
213
225
|
try {
|
|
214
226
|
setOperationLoading(true);
|
|
215
227
|
switch (operation) {
|
|
228
|
+
case "view_details":
|
|
229
|
+
// Navigate to the detail screen
|
|
230
|
+
setOperationLoading(false);
|
|
231
|
+
setExecutingOperation(null);
|
|
232
|
+
navigate("blueprint-detail", {
|
|
233
|
+
blueprintId: blueprint.id,
|
|
234
|
+
});
|
|
235
|
+
return;
|
|
216
236
|
case "view_logs":
|
|
217
237
|
// Navigate to the logs screen
|
|
218
238
|
setOperationLoading(false);
|
|
@@ -295,16 +315,33 @@ const ListBlueprintsUI = ({ onBack, onExit, }) => {
|
|
|
295
315
|
else if (key.return) {
|
|
296
316
|
setShowPopup(false);
|
|
297
317
|
const operationKey = allOperations[selectedOperation].key;
|
|
298
|
-
if (operationKey === "
|
|
318
|
+
if (operationKey === "view_details") {
|
|
319
|
+
navigate("blueprint-detail", {
|
|
320
|
+
blueprintId: selectedBlueprintItem.id,
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
else if (operationKey === "create_devbox") {
|
|
299
324
|
setSelectedBlueprint(selectedBlueprintItem);
|
|
300
325
|
setShowCreateDevbox(true);
|
|
301
326
|
}
|
|
327
|
+
else if (operationKey === "delete") {
|
|
328
|
+
// Show delete confirmation
|
|
329
|
+
setSelectedBlueprint(selectedBlueprintItem);
|
|
330
|
+
setShowDeleteConfirm(true);
|
|
331
|
+
}
|
|
302
332
|
else {
|
|
303
333
|
setSelectedBlueprint(selectedBlueprintItem);
|
|
304
334
|
setExecutingOperation(operationKey);
|
|
305
335
|
executeOperation(selectedBlueprintItem, operationKey);
|
|
306
336
|
}
|
|
307
337
|
}
|
|
338
|
+
else if (input === "v" && selectedBlueprintItem) {
|
|
339
|
+
// View details hotkey
|
|
340
|
+
setShowPopup(false);
|
|
341
|
+
navigate("blueprint-detail", {
|
|
342
|
+
blueprintId: selectedBlueprintItem.id,
|
|
343
|
+
});
|
|
344
|
+
}
|
|
308
345
|
else if (key.escape || input === "q") {
|
|
309
346
|
setShowPopup(false);
|
|
310
347
|
setSelectedOperation(0);
|
|
@@ -321,10 +358,10 @@ const ListBlueprintsUI = ({ onBack, onExit, }) => {
|
|
|
321
358
|
else if (input === "d") {
|
|
322
359
|
const deleteIndex = allOperations.findIndex((op) => op.key === "delete");
|
|
323
360
|
if (deleteIndex >= 0) {
|
|
361
|
+
// Show delete confirmation
|
|
324
362
|
setShowPopup(false);
|
|
325
363
|
setSelectedBlueprint(selectedBlueprintItem);
|
|
326
|
-
|
|
327
|
-
executeOperation(selectedBlueprintItem, "delete");
|
|
364
|
+
setShowDeleteConfirm(true);
|
|
328
365
|
}
|
|
329
366
|
}
|
|
330
367
|
else if (input === "l") {
|
|
@@ -360,6 +397,12 @@ const ListBlueprintsUI = ({ onBack, onExit, }) => {
|
|
|
360
397
|
prevPage();
|
|
361
398
|
setSelectedIndex(0);
|
|
362
399
|
}
|
|
400
|
+
else if (key.return && selectedBlueprintItem) {
|
|
401
|
+
// Enter key navigates to detail view
|
|
402
|
+
navigate("blueprint-detail", {
|
|
403
|
+
blueprintId: selectedBlueprintItem.id,
|
|
404
|
+
});
|
|
405
|
+
}
|
|
363
406
|
else if (input === "a") {
|
|
364
407
|
setShowPopup(true);
|
|
365
408
|
setSelectedOperation(0);
|
|
@@ -400,6 +443,21 @@ const ListBlueprintsUI = ({ onBack, onExit, }) => {
|
|
|
400
443
|
}
|
|
401
444
|
}
|
|
402
445
|
});
|
|
446
|
+
// Delete confirmation
|
|
447
|
+
if (showDeleteConfirm && selectedBlueprint) {
|
|
448
|
+
return (_jsx(ConfirmationPrompt, { title: "Delete Blueprint", message: `Are you sure you want to delete "${selectedBlueprint.name || selectedBlueprint.id}"?`, details: "This action cannot be undone.", breadcrumbItems: [
|
|
449
|
+
{ label: "Blueprints" },
|
|
450
|
+
{ label: selectedBlueprint.name || selectedBlueprint.id },
|
|
451
|
+
{ label: "Delete", active: true },
|
|
452
|
+
], onConfirm: () => {
|
|
453
|
+
setShowDeleteConfirm(false);
|
|
454
|
+
setExecutingOperation("delete");
|
|
455
|
+
executeOperation(selectedBlueprint, "delete");
|
|
456
|
+
}, onCancel: () => {
|
|
457
|
+
setShowDeleteConfirm(false);
|
|
458
|
+
setSelectedBlueprint(null);
|
|
459
|
+
} }));
|
|
460
|
+
}
|
|
403
461
|
// Operation result display
|
|
404
462
|
if (operationResult || operationError) {
|
|
405
463
|
const operationLabel = operations.find((o) => o.key === executingOperation)?.label ||
|
|
@@ -410,7 +468,7 @@ const ListBlueprintsUI = ({ onBack, onExit, }) => {
|
|
|
410
468
|
label: selectedBlueprint?.name || selectedBlueprint?.id || "Blueprint",
|
|
411
469
|
},
|
|
412
470
|
{ label: operationLabel, active: true },
|
|
413
|
-
] }), _jsx(Header, { title: "Operation Result" }), operationResult && _jsx(SuccessMessage, { message: operationResult }), operationError && (_jsx(ErrorMessage, { message: "Operation failed", error: operationError })), _jsx(
|
|
471
|
+
] }), _jsx(Header, { title: "Operation Result" }), operationResult && _jsx(SuccessMessage, { message: operationResult }), operationError && (_jsx(ErrorMessage, { message: "Operation failed", error: operationError })), _jsx(NavigationTips, { tips: [{ key: "Enter/q/esc", label: "Continue" }] })] }));
|
|
414
472
|
}
|
|
415
473
|
// Operation input mode
|
|
416
474
|
if (executingOperation && selectedBlueprint) {
|
|
@@ -435,7 +493,10 @@ const ListBlueprintsUI = ({ onBack, onExit, }) => {
|
|
|
435
493
|
{ label: "Blueprints" },
|
|
436
494
|
{ label: selectedBlueprint.name || selectedBlueprint.id },
|
|
437
495
|
{ label: operationLabel, active: true },
|
|
438
|
-
] }), _jsx(Header, { title: operationLabel }), _jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsx(Box, { marginBottom: 1, children: _jsx(Text, { color: colors.primary, bold: true, children: selectedBlueprint.name || selectedBlueprint.id }) }), _jsx(Box, { children: _jsxs(Text, { color: colors.textDim, children: [currentOp?.inputPrompt || "", " "] }) }), _jsx(Box, { marginTop: 1, children: _jsx(TextInput, { value: operationInput, onChange: setOperationInput, placeholder: currentOp?.inputPlaceholder || "" }) }), _jsx(
|
|
496
|
+
] }), _jsx(Header, { title: operationLabel }), _jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsx(Box, { marginBottom: 1, children: _jsx(Text, { color: colors.primary, bold: true, children: selectedBlueprint.name || selectedBlueprint.id }) }), _jsx(Box, { children: _jsxs(Text, { color: colors.textDim, children: [currentOp?.inputPrompt || "", " "] }) }), _jsx(Box, { marginTop: 1, children: _jsx(TextInput, { value: operationInput, onChange: setOperationInput, placeholder: currentOp?.inputPlaceholder || "" }) }), _jsx(NavigationTips, { marginTop: 1, paddingX: 0, tips: [
|
|
497
|
+
{ key: "Enter", label: "Execute" },
|
|
498
|
+
{ key: "q/esc", label: "Cancel" },
|
|
499
|
+
] })] })] }));
|
|
439
500
|
}
|
|
440
501
|
// For operations that don't need input (like view_logs), fall through to list view
|
|
441
502
|
}
|
|
@@ -458,24 +519,32 @@ const ListBlueprintsUI = ({ onBack, onExit, }) => {
|
|
|
458
519
|
if (listError) {
|
|
459
520
|
return (_jsxs(_Fragment, { children: [_jsx(Breadcrumb, { items: [{ label: "Blueprints", active: true }] }), _jsx(ErrorMessage, { message: "Failed to load blueprints", error: listError })] }));
|
|
460
521
|
}
|
|
461
|
-
// Empty state
|
|
462
|
-
if (blueprints.length === 0) {
|
|
463
|
-
return (_jsxs(_Fragment, { children: [_jsx(Breadcrumb, { items: [{ label: "Blueprints", active: true }] }), _jsxs(Box, { children: [_jsx(Text, { color: colors.warning, children: figures.info }), _jsx(Text, { children: " No blueprints found. Try: " }), _jsx(Text, { color: colors.primary, bold: true, children: "rli blueprint create" })] })] }));
|
|
464
|
-
}
|
|
465
522
|
// List view
|
|
466
|
-
return (_jsxs(_Fragment, { children: [_jsx(Breadcrumb, { items: [{ label: "Blueprints", active: true }] }), !showPopup && (_jsx(Table, { data: blueprints, keyExtractor: (blueprint) => blueprint.id, selectedIndex: selectedIndex, title: `blueprints[${totalCount}]`, columns: blueprintColumns })), !showPopup && (_jsxs(Box, { marginTop: 1, paddingX: 1, children: [_jsxs(Text, { color: colors.primary, bold: true, children: [figures.hamburger, " ", totalCount] }), _jsxs(Text, { color: colors.textDim, dimColor: true, children: [" ", "total"] }), totalPages > 1 && (_jsxs(_Fragment, { children: [_jsxs(Text, { color: colors.textDim, dimColor: true, children: [" ", "\u2022", " "] }), navigating ? (_jsxs(Text, { color: colors.warning, children: [figures.pointer, " Loading page ", currentPage + 1, "..."] })) : (_jsxs(Text, { color: colors.textDim, dimColor: true, children: ["Page ", currentPage + 1, " of ", totalPages] }))] })), _jsxs(Text, { color: colors.textDim, dimColor: true, children: [" ", "\u2022", " "] }), _jsxs(Text, { color: colors.textDim, dimColor: true, children: ["Showing ", startIndex + 1, "-", endIndex, " of ", totalCount] })] })), showPopup && selectedBlueprintItem && (_jsx(Box, { marginTop: 2, justifyContent: "center", children: _jsx(ActionsPopup, { devbox: selectedBlueprintItem, operations: allOperations.map((op) => ({
|
|
523
|
+
return (_jsxs(_Fragment, { children: [_jsx(Breadcrumb, { items: [{ label: "Blueprints", active: true }] }), !showPopup && (_jsx(Table, { data: blueprints, keyExtractor: (blueprint) => blueprint.id, selectedIndex: selectedIndex, title: `blueprints[${totalCount}]`, columns: blueprintColumns, emptyState: _jsxs(Text, { color: colors.textDim, children: [figures.info, " No blueprints found. Try: rli blueprint create"] }) })), !showPopup && (_jsxs(Box, { marginTop: 1, paddingX: 1, children: [_jsxs(Text, { color: colors.primary, bold: true, children: [figures.hamburger, " ", totalCount] }), _jsxs(Text, { color: colors.textDim, dimColor: true, children: [" ", "total"] }), totalPages > 1 && (_jsxs(_Fragment, { children: [_jsxs(Text, { color: colors.textDim, dimColor: true, children: [" ", "\u2022", " "] }), navigating ? (_jsxs(Text, { color: colors.warning, children: [figures.pointer, " Loading page ", currentPage + 1, "..."] })) : (_jsxs(Text, { color: colors.textDim, dimColor: true, children: ["Page ", currentPage + 1, " of ", totalPages] }))] })), _jsxs(Text, { color: colors.textDim, dimColor: true, children: [" ", "\u2022", " "] }), _jsxs(Text, { color: colors.textDim, dimColor: true, children: ["Showing ", startIndex + 1, "-", endIndex, " of ", totalCount] })] })), showPopup && selectedBlueprintItem && (_jsx(Box, { marginTop: 2, justifyContent: "center", children: _jsx(ActionsPopup, { devbox: selectedBlueprintItem, operations: allOperations.map((op) => ({
|
|
467
524
|
key: op.key,
|
|
468
525
|
label: op.label,
|
|
469
526
|
color: op.color,
|
|
470
527
|
icon: op.icon,
|
|
471
|
-
shortcut: op.key === "
|
|
472
|
-
? "
|
|
473
|
-
: op.key === "
|
|
474
|
-
? "
|
|
475
|
-
: op.key === "
|
|
476
|
-
? "
|
|
477
|
-
: ""
|
|
478
|
-
|
|
528
|
+
shortcut: op.key === "view_details"
|
|
529
|
+
? "v"
|
|
530
|
+
: op.key === "create_devbox"
|
|
531
|
+
? "c"
|
|
532
|
+
: op.key === "delete"
|
|
533
|
+
? "d"
|
|
534
|
+
: op.key === "view_logs"
|
|
535
|
+
? "l"
|
|
536
|
+
: "",
|
|
537
|
+
})), selectedOperation: selectedOperation, onClose: () => setShowPopup(false) }) })), _jsx(NavigationTips, { showArrows: true, tips: [
|
|
538
|
+
{
|
|
539
|
+
icon: `${figures.arrowLeft}${figures.arrowRight}`,
|
|
540
|
+
label: "Page",
|
|
541
|
+
condition: hasMore || hasPrev,
|
|
542
|
+
},
|
|
543
|
+
{ key: "Enter", label: "Details" },
|
|
544
|
+
{ key: "a", label: "Actions" },
|
|
545
|
+
{ key: "o", label: "Browser" },
|
|
546
|
+
{ key: "Esc", label: "Back" },
|
|
547
|
+
] })] }));
|
|
479
548
|
};
|
|
480
549
|
// Export the UI component for use in the main menu
|
|
481
550
|
export { ListBlueprintsUI };
|
|
@@ -42,9 +42,9 @@ async function fetchAllBlueprintsWithName(name) {
|
|
|
42
42
|
*/
|
|
43
43
|
function categorizeBlueprints(blueprints, keepCount) {
|
|
44
44
|
// Filter successful builds
|
|
45
|
-
const successful = blueprints.filter((b) => b.status === "build_complete"
|
|
46
|
-
// Filter failed builds
|
|
47
|
-
const failed = blueprints.filter((b) => b.status !== "build_complete"
|
|
45
|
+
const successful = blueprints.filter((b) => b.status === "build_complete");
|
|
46
|
+
// Filter failed/incomplete builds
|
|
47
|
+
const failed = blueprints.filter((b) => b.status !== "build_complete");
|
|
48
48
|
// Sort successful by create_time_ms descending (newest first)
|
|
49
49
|
successful.sort((a, b) => (b.create_time_ms || 0) - (a.create_time_ms || 0));
|
|
50
50
|
// Determine what to keep and delete
|
|
@@ -106,14 +106,8 @@ function displaySummary(name, result, isDryRun) {
|
|
|
106
106
|
else {
|
|
107
107
|
// Show all blueprints without summarizing
|
|
108
108
|
for (const blueprint of result.toDelete) {
|
|
109
|
-
const icon = blueprint.status === "build_complete"
|
|
110
|
-
|
|
111
|
-
? "✓"
|
|
112
|
-
: "✗";
|
|
113
|
-
const statusLabel = blueprint.status === "build_complete" ||
|
|
114
|
-
blueprint.status === "building_complete"
|
|
115
|
-
? "successful"
|
|
116
|
-
: "failed";
|
|
109
|
+
const icon = blueprint.status === "build_complete" ? "✓" : "⚠";
|
|
110
|
+
const statusLabel = blueprint.status === "build_complete" ? "successful" : "failed";
|
|
117
111
|
console.log(` ${icon} ${blueprint.id} - Created ${formatTimestamp(blueprint.create_time_ms)} (${statusLabel})`);
|
|
118
112
|
}
|
|
119
113
|
}
|
|
@@ -127,14 +121,8 @@ function displayDeletedBlueprints(deleted) {
|
|
|
127
121
|
}
|
|
128
122
|
console.log("\nDeleted blueprints:");
|
|
129
123
|
for (const blueprint of deleted) {
|
|
130
|
-
const icon = blueprint.status === "build_complete"
|
|
131
|
-
|
|
132
|
-
? "✓"
|
|
133
|
-
: "✗";
|
|
134
|
-
const statusLabel = blueprint.status === "build_complete" ||
|
|
135
|
-
blueprint.status === "building_complete"
|
|
136
|
-
? "successful"
|
|
137
|
-
: "failed";
|
|
124
|
+
const icon = blueprint.status === "build_complete" ? "✓" : "⚠";
|
|
125
|
+
const statusLabel = blueprint.status === "build_complete" ? "successful" : "failed";
|
|
138
126
|
console.log(` ${icon} ${blueprint.id} - Created ${formatTimestamp(blueprint.create_time_ms)} (${statusLabel})`);
|
|
139
127
|
}
|
|
140
128
|
}
|
|
@@ -74,6 +74,9 @@ export async function createDevbox(options = {}) {
|
|
|
74
74
|
on_idle: options.idleAction,
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
|
+
if (options.networkPolicy) {
|
|
78
|
+
launchParameters.network_policy_id = options.networkPolicy;
|
|
79
|
+
}
|
|
77
80
|
// Build create request
|
|
78
81
|
const createRequest = {
|
|
79
82
|
name: options.name || `devbox-${Date.now()}`,
|