@upstash/box-cli 0.1.8 → 0.1.10
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.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +73 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/connect.d.ts.map +1 -1
- package/dist/commands/connect.js +6 -1
- package/dist/commands/connect.js.map +1 -1
- package/dist/commands/snapshot.d.ts +7 -0
- package/dist/commands/snapshot.d.ts.map +1 -0
- package/dist/commands/snapshot.js +45 -0
- package/dist/commands/snapshot.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -65
- package/dist/index.js.map +1 -1
- package/dist/repl/client.d.ts +10 -23
- package/dist/repl/client.d.ts.map +1 -1
- package/dist/repl/client.js +76 -86
- package/dist/repl/client.js.map +1 -1
- package/dist/repl/commands/console.d.ts +3 -2
- package/dist/repl/commands/console.d.ts.map +1 -1
- package/dist/repl/commands/console.js +5 -11
- package/dist/repl/commands/console.js.map +1 -1
- package/dist/repl/commands/delete.d.ts +3 -3
- package/dist/repl/commands/delete.d.ts.map +1 -1
- package/dist/repl/commands/delete.js +4 -4
- package/dist/repl/commands/delete.js.map +1 -1
- package/dist/repl/commands/exec.d.ts +2 -2
- package/dist/repl/commands/exec.d.ts.map +1 -1
- package/dist/repl/commands/exec.js +3 -3
- package/dist/repl/commands/exec.js.map +1 -1
- package/dist/repl/commands/files.d.ts +2 -2
- package/dist/repl/commands/files.d.ts.map +1 -1
- package/dist/repl/commands/files.js +10 -10
- package/dist/repl/commands/files.js.map +1 -1
- package/dist/repl/commands/git.d.ts +2 -2
- package/dist/repl/commands/git.d.ts.map +1 -1
- package/dist/repl/commands/git.js +7 -7
- package/dist/repl/commands/git.js.map +1 -1
- package/dist/repl/commands/pause.d.ts +3 -3
- package/dist/repl/commands/pause.d.ts.map +1 -1
- package/dist/repl/commands/pause.js +4 -4
- package/dist/repl/commands/pause.js.map +1 -1
- package/dist/repl/commands/run.d.ts +3 -3
- package/dist/repl/commands/run.d.ts.map +1 -1
- package/dist/repl/commands/run.js +5 -5
- package/dist/repl/commands/run.js.map +1 -1
- package/dist/repl/commands/snapshot.d.ts +2 -2
- package/dist/repl/commands/snapshot.d.ts.map +1 -1
- package/dist/repl/commands/snapshot.js +2 -2
- package/dist/repl/commands/snapshot.js.map +1 -1
- package/dist/repl/terminal.d.ts.map +1 -1
- package/dist/repl/terminal.js +77 -46
- package/dist/repl/terminal.js.map +1 -1
- package/dist/repl/types.d.ts +40 -0
- package/dist/repl/types.d.ts.map +1 -0
- package/dist/repl/types.js +2 -0
- package/dist/repl/types.js.map +1 -0
- package/package.json +7 -7
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,eAAe,CAAC"}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import "dotenv/config";
|
|
3
|
+
import { Command } from "commander";
|
|
4
|
+
import { createCommand } from "./commands/create.js";
|
|
5
|
+
import { connectCommand } from "./commands/connect.js";
|
|
6
|
+
import { fromSnapshotCommand } from "./commands/from-snapshot.js";
|
|
7
|
+
import { listCommand } from "./commands/list.js";
|
|
8
|
+
import { getCommand } from "./commands/get.js";
|
|
9
|
+
import { initDemoCommand } from "./commands/init-demo.js";
|
|
10
|
+
import { snapshotCommand } from "./commands/snapshot.js";
|
|
11
|
+
import { completionCommand } from "./commands/completion.js";
|
|
12
|
+
const program = new Command();
|
|
13
|
+
program
|
|
14
|
+
.name("box")
|
|
15
|
+
.description("CLI for Upstash Box — REPL-first interface for AI coding agents")
|
|
16
|
+
.version("0.1.0");
|
|
17
|
+
program
|
|
18
|
+
.command("create")
|
|
19
|
+
.description("Create a new box and enter the REPL")
|
|
20
|
+
.option("--token <token>", "Upstash Box API token")
|
|
21
|
+
.option("--runtime <runtime>", "Runtime environment (node, python, golang, ruby, rust)")
|
|
22
|
+
.option("--agent-model <model>", "Agent model identifier")
|
|
23
|
+
.option("--agent-api-key <key>", "Agent API key (Anthropic or OpenAI)")
|
|
24
|
+
.option("--git-token <token>", "GitHub personal access token")
|
|
25
|
+
.option("--env <KEY=VAL>", "Environment variable (repeatable)", (val, prev) => [...prev, val], [])
|
|
26
|
+
.action((opts) => createCommand(opts));
|
|
27
|
+
program
|
|
28
|
+
.command("connect [box-id]")
|
|
29
|
+
.description("Connect to an existing box (or most recent) and enter the REPL")
|
|
30
|
+
.option("--token <token>", "Upstash Box API token")
|
|
31
|
+
.action((boxId, opts) => connectCommand(boxId, opts));
|
|
32
|
+
program
|
|
33
|
+
.command("from-snapshot <snapshot-id>")
|
|
34
|
+
.description("Create a new box from a snapshot and enter the REPL")
|
|
35
|
+
.option("--token <token>", "Upstash Box API token")
|
|
36
|
+
.option("--runtime <runtime>", "Runtime environment")
|
|
37
|
+
.option("--agent-model <model>", "Agent model identifier")
|
|
38
|
+
.option("--agent-api-key <key>", "Agent API key")
|
|
39
|
+
.option("--git-token <token>", "GitHub personal access token")
|
|
40
|
+
.option("--env <KEY=VAL>", "Environment variable (repeatable)", (val, prev) => [...prev, val], [])
|
|
41
|
+
.action((snapshotId, opts) => fromSnapshotCommand(snapshotId, opts));
|
|
42
|
+
program
|
|
43
|
+
.command("list")
|
|
44
|
+
.description("List all boxes")
|
|
45
|
+
.option("--token <token>", "Upstash Box API token")
|
|
46
|
+
.action((opts) => listCommand(opts));
|
|
47
|
+
program
|
|
48
|
+
.command("get <box-id>")
|
|
49
|
+
.description("Get details about a box")
|
|
50
|
+
.option("--token <token>", "Upstash Box API token")
|
|
51
|
+
.action((boxId, opts) => getCommand(boxId, opts));
|
|
52
|
+
program
|
|
53
|
+
.command("snapshot [box-id]")
|
|
54
|
+
.description("Create a snapshot of a box")
|
|
55
|
+
.option("--token <token>", "Upstash Box API token")
|
|
56
|
+
.option("--name <name>", "Snapshot name")
|
|
57
|
+
.action((boxId, opts) => snapshotCommand(boxId, opts));
|
|
58
|
+
program
|
|
59
|
+
.command("init-demo")
|
|
60
|
+
.description("Scaffold a standalone demo project for @upstash/box")
|
|
61
|
+
.option("--token <token>", "Upstash Box API token")
|
|
62
|
+
.option("--agent-model <model>", "Agent model identifier")
|
|
63
|
+
.option("--agent-api-key <key>", "Agent API key (required if --agent-model is set)")
|
|
64
|
+
.option("--runtime <runtime>", "Runtime environment", "node")
|
|
65
|
+
.option("--git-token <token>", "GitHub personal access token")
|
|
66
|
+
.option("--directory <dir>", "Output directory", "box-demo")
|
|
67
|
+
.action((opts) => initDemoCommand(opts));
|
|
68
|
+
program
|
|
69
|
+
.command("completion")
|
|
70
|
+
.description('Output shell completion script (eval "$(box completion)")')
|
|
71
|
+
.action(() => completionCommand());
|
|
72
|
+
program.parse();
|
|
73
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,eAAe,CAAC;AACvB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,MAAM,OAAO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AAC;KAC5D,MAAM,CAAC,qBAAqB,EAAE,8BAA8B,CAAC;KAC7D,MAAM,CAAC,mBAAmB,EAAE,kBAAkB,EAAE,UAAU,CAAC;KAC3D,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC;AAE3C,OAAO;KACJ,OAAO,CAAC,YAAY,CAAC;KACrB,WAAW,CAAC,2DAA2D,CAAC;KACxE,MAAM,CAAC,GAAG,EAAE,CAAC,iBAAiB,EAAE,CAAC,CAAC;AAErC,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../../src/commands/connect.ts"],"names":[],"mappings":"AAMA,UAAU,YAAY;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAsB,cAAc,CAClC,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,KAAK,EAAE,YAAY,GAClB,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../../src/commands/connect.ts"],"names":[],"mappings":"AAMA,UAAU,YAAY;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAsB,cAAc,CAClC,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,KAAK,EAAE,YAAY,GAClB,OAAO,CAAC,IAAI,CAAC,CA8Cf"}
|
package/dist/commands/connect.js
CHANGED
|
@@ -33,7 +33,12 @@ export async function connectCommand(boxId, flags) {
|
|
|
33
33
|
targetId = selected;
|
|
34
34
|
}
|
|
35
35
|
else {
|
|
36
|
-
|
|
36
|
+
if (active.length === 1) {
|
|
37
|
+
console.log("Only one box found, using it...");
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
console.log("No box ID specified, connecting to most recent...");
|
|
41
|
+
}
|
|
37
42
|
targetId = active[0].id;
|
|
38
43
|
}
|
|
39
44
|
}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@upstash/box";
|
|
2
|
+
import { resolveToken } from "../auth.js";
|
|
3
|
+
import { interactiveSelect } from "../utils/interactive-select.js";
|
|
4
|
+
import { dim } from "../utils/ansi.js";
|
|
5
|
+
export async function snapshotCommand(boxId, flags) {
|
|
6
|
+
const apiKey = resolveToken(flags.token);
|
|
7
|
+
let targetId = boxId;
|
|
8
|
+
// If no box ID provided, pick interactively or fall back to most recent
|
|
9
|
+
if (!targetId) {
|
|
10
|
+
const boxes = await Box.list({ apiKey });
|
|
11
|
+
const active = boxes.filter((b) => b.status !== "deleted");
|
|
12
|
+
if (active.length === 0) {
|
|
13
|
+
console.error("No boxes found.");
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
16
|
+
if (process.stdin.isTTY && active.length > 1) {
|
|
17
|
+
const items = active.slice(0, 10);
|
|
18
|
+
const idWidth = Math.max(...items.map((b) => b.id.length));
|
|
19
|
+
const statusWidth = Math.max(...items.map((b) => b.status.length));
|
|
20
|
+
const selected = await interactiveSelect({
|
|
21
|
+
prompt: "Select a box to snapshot:",
|
|
22
|
+
items: items.map((b) => ({
|
|
23
|
+
label: b.id.padEnd(idWidth),
|
|
24
|
+
value: b.id,
|
|
25
|
+
description: `${b.status.padEnd(statusWidth)} ${b.model ?? ""}`,
|
|
26
|
+
})),
|
|
27
|
+
});
|
|
28
|
+
if (!selected) {
|
|
29
|
+
console.log(dim("Aborted."));
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
targetId = selected;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
console.log("Only one box found, using it...");
|
|
36
|
+
targetId = active[0].id;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const snapshotName = flags.name ?? `snapshot-${Date.now()}`;
|
|
40
|
+
console.log(`\nCreating snapshot of box ${targetId}...`);
|
|
41
|
+
const box = await Box.get(targetId, { apiKey });
|
|
42
|
+
const snapshot = await box.snapshot({ name: snapshotName });
|
|
43
|
+
console.log(`Snapshot created: ${snapshot.id} (${snapshot.name})`);
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=snapshot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot.js","sourceRoot":"","sources":["../../src/commands/snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAOvC,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,KAAyB,EACzB,KAAoB;IAEpB,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAEzC,IAAI,QAAQ,GAAG,KAAK,CAAC;IAErB,wEAAwE;IACxE,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,KAAK,GAAG,MAAM,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;QACzC,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC;QAC3D,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,OAAO,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;YACjC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC7C,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAClC,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,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GAAG,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC;IAC5D,OAAO,CAAC,GAAG,CAAC,qBAAqB,QAAQ,CAAC,EAAE,KAAK,QAAQ,CAAC,IAAI,GAAG,CAAC,CAAC;AACrE,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export { BoxREPLClient, COMMAND_NAMES, COMMAND_DESCRIPTIONS } from "./repl/client.js";
|
|
2
|
+
export type { BoxREPLEvent, BoxREPLCommand, BoxREPLCommandHandler, BoxREPLCommandName, } from "./repl/types.js";
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACtF,YAAY,EACV,YAAY,EACZ,cAAc,EACd,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,66 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import "dotenv/config";
|
|
3
|
-
import { Command } from "commander";
|
|
4
|
-
import { createCommand } from "./commands/create.js";
|
|
5
|
-
import { connectCommand } from "./commands/connect.js";
|
|
6
|
-
import { fromSnapshotCommand } from "./commands/from-snapshot.js";
|
|
7
|
-
import { listCommand } from "./commands/list.js";
|
|
8
|
-
import { getCommand } from "./commands/get.js";
|
|
9
|
-
import { initDemoCommand } from "./commands/init-demo.js";
|
|
10
|
-
import { completionCommand } from "./commands/completion.js";
|
|
11
|
-
const program = new Command();
|
|
12
|
-
program
|
|
13
|
-
.name("box")
|
|
14
|
-
.description("CLI for Upstash Box — REPL-first interface for AI coding agents")
|
|
15
|
-
.version("0.1.0");
|
|
16
|
-
program
|
|
17
|
-
.command("create")
|
|
18
|
-
.description("Create a new box and enter the REPL")
|
|
19
|
-
.option("--token <token>", "Upstash Box API token")
|
|
20
|
-
.option("--runtime <runtime>", "Runtime environment (node, python, golang, ruby, rust)")
|
|
21
|
-
.option("--agent-model <model>", "Agent model identifier")
|
|
22
|
-
.option("--agent-api-key <key>", "Agent API key (Anthropic or OpenAI)")
|
|
23
|
-
.option("--git-token <token>", "GitHub personal access token")
|
|
24
|
-
.option("--env <KEY=VAL>", "Environment variable (repeatable)", (val, prev) => [...prev, val], [])
|
|
25
|
-
.action((opts) => createCommand(opts));
|
|
26
|
-
program
|
|
27
|
-
.command("connect [box-id]")
|
|
28
|
-
.description("Connect to an existing box (or most recent) and enter the REPL")
|
|
29
|
-
.option("--token <token>", "Upstash Box API token")
|
|
30
|
-
.action((boxId, opts) => connectCommand(boxId, opts));
|
|
31
|
-
program
|
|
32
|
-
.command("from-snapshot <snapshot-id>")
|
|
33
|
-
.description("Create a new box from a snapshot and enter the REPL")
|
|
34
|
-
.option("--token <token>", "Upstash Box API token")
|
|
35
|
-
.option("--runtime <runtime>", "Runtime environment")
|
|
36
|
-
.option("--agent-model <model>", "Agent model identifier")
|
|
37
|
-
.option("--agent-api-key <key>", "Agent API key")
|
|
38
|
-
.option("--git-token <token>", "GitHub personal access token")
|
|
39
|
-
.option("--env <KEY=VAL>", "Environment variable (repeatable)", (val, prev) => [...prev, val], [])
|
|
40
|
-
.action((snapshotId, opts) => fromSnapshotCommand(snapshotId, opts));
|
|
41
|
-
program
|
|
42
|
-
.command("list")
|
|
43
|
-
.description("List all boxes")
|
|
44
|
-
.option("--token <token>", "Upstash Box API token")
|
|
45
|
-
.action((opts) => listCommand(opts));
|
|
46
|
-
program
|
|
47
|
-
.command("get <box-id>")
|
|
48
|
-
.description("Get details about a box")
|
|
49
|
-
.option("--token <token>", "Upstash Box API token")
|
|
50
|
-
.action((boxId, opts) => getCommand(boxId, opts));
|
|
51
|
-
program
|
|
52
|
-
.command("init-demo")
|
|
53
|
-
.description("Scaffold a standalone demo project for @upstash/box")
|
|
54
|
-
.option("--token <token>", "Upstash Box API token")
|
|
55
|
-
.option("--agent-model <model>", "Agent model identifier")
|
|
56
|
-
.option("--agent-api-key <key>", "Agent API key (required if --agent-model is set)")
|
|
57
|
-
.option("--runtime <runtime>", "Runtime environment", "node")
|
|
58
|
-
.option("--git-token <token>", "GitHub personal access token")
|
|
59
|
-
.option("--directory <dir>", "Output directory", "box-demo")
|
|
60
|
-
.action((opts) => initDemoCommand(opts));
|
|
61
|
-
program
|
|
62
|
-
.command("completion")
|
|
63
|
-
.description('Output shell completion script (eval "$(box completion)")')
|
|
64
|
-
.action(() => completionCommand());
|
|
65
|
-
program.parse();
|
|
1
|
+
export { BoxREPLClient, COMMAND_NAMES, COMMAND_DESCRIPTIONS } from "./repl/client.js";
|
|
66
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/repl/client.d.ts
CHANGED
|
@@ -1,30 +1,17 @@
|
|
|
1
1
|
import type { Box } from "@upstash/box";
|
|
2
|
-
|
|
3
|
-
onLog: (message: string) => void;
|
|
4
|
-
onError: (message: string) => void;
|
|
5
|
-
onStream: (message: string) => void;
|
|
6
|
-
/** Loading indicator. Return a stop() function. */
|
|
7
|
-
onLoadingStart?: () => () => void;
|
|
8
|
-
/** Post-command suggestion (e.g. "try: /snapshot"). */
|
|
9
|
-
onSuggestion?: (text: string) => void;
|
|
10
|
-
/** Timing info after each command. */
|
|
11
|
-
onCommandComplete?: (command: string, durationMs: number) => void;
|
|
12
|
-
/** Unknown /command with fuzzy suggestions. Falls back to onError if absent. */
|
|
13
|
-
onCommandNotFound?: (typed: string, suggestions: string[]) => void;
|
|
14
|
-
};
|
|
2
|
+
import type { BoxREPLEvent, BoxREPLCommand, BoxREPLCommandName } from "./types.js";
|
|
15
3
|
/** All available command names (without / prefix). */
|
|
16
|
-
export declare const COMMAND_NAMES:
|
|
4
|
+
export declare const COMMAND_NAMES: BoxREPLCommandName[];
|
|
17
5
|
/** Command descriptions for completer/preview. */
|
|
18
|
-
export declare const COMMAND_DESCRIPTIONS: Record<
|
|
6
|
+
export declare const COMMAND_DESCRIPTIONS: Record<BoxREPLCommandName, string>;
|
|
19
7
|
export declare class BoxREPLClient {
|
|
20
8
|
readonly box: Box;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
startLoop(): Promise<void>;
|
|
9
|
+
constructor(box: Box);
|
|
10
|
+
/** Parse input and return the matching command + args, or null. */
|
|
11
|
+
private getCommand;
|
|
12
|
+
/** Return commands whose name starts with the given prefix. */
|
|
13
|
+
static suggestCommands(prefix: string): BoxREPLCommand[];
|
|
14
|
+
/** Process a single line of input and yield events. */
|
|
15
|
+
handleInput(input: string): AsyncGenerator<BoxREPLEvent>;
|
|
29
16
|
}
|
|
30
17
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/repl/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/repl/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAyBnF,sDAAsD;AACtD,eAAO,MAAM,aAAa,EAA4B,kBAAkB,EAAE,CAAC;AAE3E,kDAAkD;AAClD,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,kBAAkB,EAAE,MAAM,CAE7B,CAAC;AAoBxC,qBAAa,aAAa;IACxB,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC;gBAEN,GAAG,EAAE,GAAG;IAIpB,mEAAmE;IACnE,OAAO,CAAC,UAAU;IAelB,+DAA+D;IAC/D,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,EAAE;IAOxD,uDAAuD;IAChD,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,CAAC,YAAY,CAAC;CA8ChE"}
|
package/dist/repl/client.js
CHANGED
|
@@ -8,30 +8,24 @@ import { handleDelete } from "./commands/delete.js";
|
|
|
8
8
|
import { handleConsole } from "./commands/console.js";
|
|
9
9
|
import { fuzzyMatch } from "../utils/fuzzy.js";
|
|
10
10
|
const COMMANDS = {
|
|
11
|
-
run: handleRun,
|
|
12
|
-
exec: handleExec,
|
|
13
|
-
files:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
run: { description: "Run the agent with a prompt", handler: handleRun },
|
|
12
|
+
exec: { description: "Execute a shell command", handler: handleExec },
|
|
13
|
+
files: {
|
|
14
|
+
description: "File operations (read, write, list, upload, download)",
|
|
15
|
+
handler: handleFiles,
|
|
16
|
+
},
|
|
17
|
+
git: { description: "Git operations (clone, diff, create-pr)", handler: handleGit },
|
|
18
|
+
snapshot: { description: "Create a snapshot of the current box", handler: handleSnapshot },
|
|
19
|
+
pause: { description: "Pause the box and exit", handler: handlePause },
|
|
20
|
+
delete: { description: "Delete the box and exit", handler: handleDelete },
|
|
21
|
+
console: { description: "Open the box in Upstash console", handler: handleConsole },
|
|
19
22
|
};
|
|
20
23
|
/** All available command names (without / prefix). */
|
|
21
24
|
export const COMMAND_NAMES = Object.keys(COMMANDS);
|
|
22
25
|
/** Command descriptions for completer/preview. */
|
|
23
|
-
export const COMMAND_DESCRIPTIONS =
|
|
24
|
-
run: "Run the agent with a prompt",
|
|
25
|
-
exec: "Execute a shell command",
|
|
26
|
-
files: "File operations (read, write, list, upload, download)",
|
|
27
|
-
git: "Git operations (clone, diff, create-pr)",
|
|
28
|
-
snapshot: "Create a snapshot of the current box",
|
|
29
|
-
pause: "Pause the box and exit",
|
|
30
|
-
delete: "Delete the box and exit",
|
|
31
|
-
console: "Open the box in Upstash console",
|
|
32
|
-
};
|
|
26
|
+
export const COMMAND_DESCRIPTIONS = Object.fromEntries(COMMAND_NAMES.map((name) => [name, COMMANDS[name].description]));
|
|
33
27
|
/** Context-aware suggestion after a command completes. */
|
|
34
|
-
function
|
|
28
|
+
function getNextCommandSuggestion(cmdName) {
|
|
35
29
|
switch (cmdName) {
|
|
36
30
|
case "exec":
|
|
37
31
|
return "/files list .";
|
|
@@ -49,82 +43,78 @@ function getSuggestion(cmdName) {
|
|
|
49
43
|
}
|
|
50
44
|
export class BoxREPLClient {
|
|
51
45
|
box;
|
|
52
|
-
|
|
53
|
-
hooks;
|
|
54
|
-
constructor({ box, promptUser, hooks, }) {
|
|
46
|
+
constructor(box) {
|
|
55
47
|
this.box = box;
|
|
56
|
-
this.promptUser = promptUser;
|
|
57
|
-
this.hooks = hooks;
|
|
58
48
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
stopLoading?.();
|
|
95
|
-
hooks.onError(`Error: ${err instanceof Error ? err.message : err}`);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
// Unknown command — fuzzy match
|
|
100
|
-
const suggestions = fuzzyMatch(cmdName, COMMAND_NAMES);
|
|
101
|
-
if (hooks.onCommandNotFound) {
|
|
102
|
-
hooks.onCommandNotFound(cmdName, suggestions);
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
const msg = suggestions.length > 0
|
|
106
|
-
? `Unknown command: /${cmdName}. Did you mean: ${suggestions.map((s) => `/${s}`).join(", ")}?`
|
|
107
|
-
: `Unknown command: /${cmdName}. Available: ${COMMAND_NAMES.map((c) => `/${c}`).join(", ")}`;
|
|
108
|
-
hooks.onError(msg);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
// No / prefix — treat as agent prompt
|
|
49
|
+
/** Parse input and return the matching command + args, or null. */
|
|
50
|
+
getCommand(input) {
|
|
51
|
+
const trimmed = input.trim();
|
|
52
|
+
if (!trimmed.startsWith("/"))
|
|
53
|
+
return null;
|
|
54
|
+
const withoutSlash = trimmed.slice(1);
|
|
55
|
+
const spaceIdx = withoutSlash.indexOf(" ");
|
|
56
|
+
const cmdName = spaceIdx === -1 ? withoutSlash : withoutSlash.slice(0, spaceIdx);
|
|
57
|
+
const args = spaceIdx === -1 ? "" : withoutSlash.slice(spaceIdx + 1).trim();
|
|
58
|
+
const entry = COMMANDS[cmdName];
|
|
59
|
+
if (!entry)
|
|
60
|
+
return null;
|
|
61
|
+
return { command: { name: cmdName, ...entry }, args };
|
|
62
|
+
}
|
|
63
|
+
/** Return commands whose name starts with the given prefix. */
|
|
64
|
+
static suggestCommands(prefix) {
|
|
65
|
+
return COMMAND_NAMES.filter((name) => name.startsWith(prefix)).map((name) => ({
|
|
66
|
+
name,
|
|
67
|
+
...COMMANDS[name],
|
|
68
|
+
}));
|
|
69
|
+
}
|
|
70
|
+
/** Process a single line of input and yield events. */
|
|
71
|
+
async *handleInput(input) {
|
|
72
|
+
const trimmed = input.trim();
|
|
73
|
+
if (!trimmed)
|
|
74
|
+
return;
|
|
75
|
+
if (trimmed === "exit" || trimmed === "/exit") {
|
|
76
|
+
yield { type: "exit", message: "Goodbye." };
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (trimmed.startsWith("/")) {
|
|
80
|
+
const parsed = this.getCommand(trimmed);
|
|
81
|
+
if (parsed) {
|
|
82
|
+
const { command, args } = parsed;
|
|
83
|
+
yield { type: "command:start", command: command.name, args };
|
|
114
84
|
const start = Date.now();
|
|
115
|
-
const stopLoading = hooks.onLoadingStart?.();
|
|
116
85
|
try {
|
|
117
|
-
|
|
118
|
-
stopLoading?.();
|
|
86
|
+
yield* command.handler(this.box, args);
|
|
119
87
|
const durationMs = Date.now() - start;
|
|
120
|
-
|
|
121
|
-
|
|
88
|
+
yield { type: "command:complete", command: command.name, durationMs };
|
|
89
|
+
const suggestion = getNextCommandSuggestion(command.name);
|
|
90
|
+
if (suggestion)
|
|
91
|
+
yield { type: "suggestion", text: suggestion };
|
|
122
92
|
}
|
|
123
93
|
catch (err) {
|
|
124
|
-
|
|
125
|
-
hooks.onError(`Error: ${err instanceof Error ? err.message : err}`);
|
|
94
|
+
yield { type: "error", message: `Error: ${err instanceof Error ? err.message : err}` };
|
|
126
95
|
}
|
|
127
96
|
}
|
|
97
|
+
else {
|
|
98
|
+
const withoutSlash = trimmed.slice(1);
|
|
99
|
+
const spaceIdx = withoutSlash.indexOf(" ");
|
|
100
|
+
const cmdName = spaceIdx === -1 ? withoutSlash : withoutSlash.slice(0, spaceIdx);
|
|
101
|
+
const suggestions = fuzzyMatch(cmdName, COMMAND_NAMES);
|
|
102
|
+
yield { type: "command:not-found", typed: cmdName, suggestions };
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
// No / prefix — treat as agent prompt
|
|
107
|
+
yield { type: "command:start", command: "run", args: trimmed };
|
|
108
|
+
const start = Date.now();
|
|
109
|
+
try {
|
|
110
|
+
yield* handleRun(this.box, trimmed);
|
|
111
|
+
const durationMs = Date.now() - start;
|
|
112
|
+
yield { type: "command:complete", command: "run", durationMs };
|
|
113
|
+
yield { type: "suggestion", text: "/snapshot" };
|
|
114
|
+
}
|
|
115
|
+
catch (err) {
|
|
116
|
+
yield { type: "error", message: `Error: ${err instanceof Error ? err.message : err}` };
|
|
117
|
+
}
|
|
128
118
|
}
|
|
129
119
|
}
|
|
130
120
|
}
|
package/dist/repl/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/repl/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/repl/client.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,MAAM,QAAQ,GAA6D;IACzE,GAAG,EAAE,EAAE,WAAW,EAAE,6BAA6B,EAAE,OAAO,EAAE,SAAS,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CAAC,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC;YACzF,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { Box } from "@upstash/box";
|
|
2
|
-
import type {
|
|
2
|
+
import type { BoxREPLEvent } from "../types.js";
|
|
3
3
|
/**
|
|
4
4
|
* Open the Upstash console for the current box in the default browser.
|
|
5
|
+
* Yields an open-url event; the consumer handles actually opening the browser.
|
|
5
6
|
*/
|
|
6
|
-
export declare function handleConsole(box: Box, _args: string
|
|
7
|
+
export declare function handleConsole(box: Box, _args: string): AsyncGenerator<BoxREPLEvent>;
|
|
7
8
|
//# sourceMappingURL=console.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"console.d.ts","sourceRoot":"","sources":["../../../src/repl/commands/console.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"console.d.ts","sourceRoot":"","sources":["../../../src/repl/commands/console.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAIhD;;;GAGG;AACH,wBAAuB,aAAa,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,GAAG,cAAc,CAAC,YAAY,CAAC,CAI1F"}
|
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
const UPSTASH_CONSOLE_URL = "http://localhost:3000/box/resolve";
|
|
1
|
+
const UPSTASH_CONSOLE_URL = "https://console.upstash.com/box/resolve";
|
|
3
2
|
/**
|
|
4
3
|
* Open the Upstash console for the current box in the default browser.
|
|
4
|
+
* Yields an open-url event; the consumer handles actually opening the browser.
|
|
5
5
|
*/
|
|
6
|
-
export async function handleConsole(box, _args
|
|
6
|
+
export async function* handleConsole(box, _args) {
|
|
7
7
|
const url = `${UPSTASH_CONSOLE_URL}/${box.id}`;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (err) {
|
|
11
|
-
hooks.onError(`Failed to open browser: ${err.message}`);
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
hooks.onLog(`Opening ${url}`);
|
|
8
|
+
yield { type: "open-url", url };
|
|
9
|
+
yield { type: "log", message: `Opening ${url}` };
|
|
16
10
|
}
|
|
17
11
|
//# sourceMappingURL=console.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"console.js","sourceRoot":"","sources":["../../../src/repl/commands/console.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"console.js","sourceRoot":"","sources":["../../../src/repl/commands/console.ts"],"names":[],"mappings":"AAGA,MAAM,mBAAmB,GAAG,yCAAyC,CAAC;AAEtE;;;GAGG;AACH,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,aAAa,CAAC,GAAQ,EAAE,KAAa;IAC1D,MAAM,GAAG,GAAG,GAAG,mBAAmB,IAAI,GAAG,CAAC,EAAE,EAAE,CAAC;IAC/C,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC;IAChC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,GAAG,EAAE,EAAE,CAAC;AACnD,CAAC"}
|