@lizard-build/cli 4.0.134 → 4.0.136
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/commands/git-hosting.js +35 -33
- package/dist/commands/git-hosting.js.map +1 -1
- package/dist/commands/logs.js +15 -12
- package/dist/commands/logs.js.map +1 -1
- package/dist/commands/sandbox.js +24 -13
- package/dist/commands/sandbox.js.map +1 -1
- package/dist/commands/up.d.ts +9 -0
- package/dist/commands/up.js +43 -13
- package/dist/commands/up.js.map +1 -1
- package/dist/lib/checkout.d.ts +7 -0
- package/dist/lib/checkout.js +20 -1
- package/dist/lib/checkout.js.map +1 -1
- package/dist/lib/config.d.ts +6 -1
- package/dist/lib/config.js +16 -4
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/env-guard.js +38 -2
- package/dist/lib/env-guard.js.map +1 -1
- package/dist/lib/signin.d.ts +9 -0
- package/dist/lib/signin.js +19 -2
- package/dist/lib/signin.js.map +1 -1
- package/dist/lib/skills-data.generated.js +2 -2
- package/dist/lib/skills-data.generated.js.map +1 -1
- package/dist/lib/terminal.d.ts +20 -0
- package/dist/lib/terminal.js +32 -0
- package/dist/lib/terminal.js.map +1 -0
- package/dist/lib/updater.d.ts +1 -1
- package/dist/lib/updater.js +1 -1
- package/dist/lib/upload-filter.d.ts +14 -0
- package/dist/lib/upload-filter.js +146 -0
- package/dist/lib/upload-filter.js.map +1 -0
- package/package.json +1 -1
- package/skill-data/core/references/deploys.md +1 -1
- package/skill-data/core/references/sandboxes.md +1 -1
- package/src/commands/git-hosting.ts +35 -33
- package/src/commands/logs.ts +16 -12
- package/src/commands/sandbox.ts +27 -12
- package/src/commands/up.ts +59 -9
- package/src/lib/checkout.ts +22 -1
- package/src/lib/config.ts +12 -5
- package/src/lib/env-guard.ts +37 -2
- package/src/lib/signin.ts +24 -2
- package/src/lib/terminal.ts +36 -0
- package/src/lib/updater.ts +1 -1
- package/src/lib/upload-filter.ts +141 -0
- package/test/unit/checkout-symlink.test.ts +19 -1
- package/test/unit/config.test.ts +21 -0
- package/test/unit/env-guard.test.ts +6 -2
- package/test/unit/login.test.ts +26 -1
- package/test/unit/terminal.test.ts +25 -0
- package/test/unit/upload-filter.test.ts +62 -0
- package/lizard-wrapper.sh +0 -2
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import * as os from "node:os";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
// ── what `lizard up` must not upload by accident ────────────────────────────
|
|
5
|
+
const SECRET_DIRS = new Set([".ssh", ".aws", ".gnupg"]);
|
|
6
|
+
const SECRET_FILES = new Set([".npmrc", ".pypirc", ".netrc"]);
|
|
7
|
+
const ENV_TEMPLATES = new Set([".env.example", ".env.sample"]);
|
|
8
|
+
/** A `.env` or `.env.*` file that holds values (not `.env.example` / `.env.sample`). */
|
|
9
|
+
export function isEnvFile(name) {
|
|
10
|
+
return (name === ".env" || name.startsWith(".env.")) && !ENV_TEMPLATES.has(name);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Credentials and keys that a folder walk would otherwise upload: env files, SSH/AWS/GnuPG
|
|
14
|
+
* folders, package-manager and netrc credentials, Docker's login file, private keys.
|
|
15
|
+
* `rel` is a /-separated path relative to the upload root.
|
|
16
|
+
*/
|
|
17
|
+
export function isSensitivePath(rel) {
|
|
18
|
+
const parts = rel.split("/");
|
|
19
|
+
const name = parts[parts.length - 1];
|
|
20
|
+
if (parts.slice(0, -1).some((d) => SECRET_DIRS.has(d)))
|
|
21
|
+
return true;
|
|
22
|
+
if (SECRET_DIRS.has(name))
|
|
23
|
+
return true;
|
|
24
|
+
if (SECRET_FILES.has(name) || isEnvFile(name))
|
|
25
|
+
return true;
|
|
26
|
+
if (name === "config.json" && parts[parts.length - 2] === ".docker")
|
|
27
|
+
return true;
|
|
28
|
+
if (/^id_(rsa|ed25519|ecdsa)/.test(name))
|
|
29
|
+
return true;
|
|
30
|
+
const ext = path.extname(name).toLowerCase();
|
|
31
|
+
return ext === ".pem" || ext === ".key";
|
|
32
|
+
}
|
|
33
|
+
/** The home folder or a file system root: a walk from there would upload a whole machine. */
|
|
34
|
+
export function isTooBroadToUpload(dir) {
|
|
35
|
+
const real = (p) => {
|
|
36
|
+
try {
|
|
37
|
+
return fs.realpathSync(p);
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return path.resolve(p);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const d = real(dir);
|
|
44
|
+
return d === real(os.homedir()) || d === path.parse(d).root;
|
|
45
|
+
}
|
|
46
|
+
function globToRegex(glob) {
|
|
47
|
+
let out = "";
|
|
48
|
+
for (let i = 0; i < glob.length; i++) {
|
|
49
|
+
const c = glob[i];
|
|
50
|
+
if (c === "*") {
|
|
51
|
+
if (glob[i + 1] === "*") {
|
|
52
|
+
const atStart = i === 0 || glob[i - 1] === "/";
|
|
53
|
+
const atEnd = i + 2 === glob.length || glob[i + 2] === "/";
|
|
54
|
+
if (atStart && atEnd) {
|
|
55
|
+
if (glob[i + 2] === "/") {
|
|
56
|
+
out += "(?:.*/)?"; // `**/`: any number of folders, including none
|
|
57
|
+
i += 2;
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
out += ".*"; // trailing `**`: everything inside
|
|
61
|
+
i += 1;
|
|
62
|
+
}
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
out += "[^/]*";
|
|
67
|
+
}
|
|
68
|
+
else if (c === "?") {
|
|
69
|
+
out += "[^/]";
|
|
70
|
+
}
|
|
71
|
+
else if (c === "[") {
|
|
72
|
+
const close = glob.indexOf("]", i + 2);
|
|
73
|
+
if (close === -1) {
|
|
74
|
+
out += "\\[";
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
let body = glob.slice(i + 1, close).replace(/\\/g, "\\\\");
|
|
78
|
+
if (body.startsWith("!"))
|
|
79
|
+
body = "^" + body.slice(1);
|
|
80
|
+
out += `[${body}]`;
|
|
81
|
+
i = close;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
else if (c === "\\" && i + 1 < glob.length) {
|
|
85
|
+
out += glob[++i].replace(/[.*+?^${}()|[\]\\/]/g, "\\$&");
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
out += c.replace(/[.*+?^${}()|[\]\\/]/g, "\\$&");
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return out;
|
|
92
|
+
}
|
|
93
|
+
/** Parse gitignore-syntax text into a matcher for /-separated paths relative to its folder. */
|
|
94
|
+
export function parseIgnore(text) {
|
|
95
|
+
const rules = [];
|
|
96
|
+
for (const raw of text.split(/\r?\n/)) {
|
|
97
|
+
let line = raw.replace(/(?<!\\)\s+$/, "");
|
|
98
|
+
if (!line || line.startsWith("#"))
|
|
99
|
+
continue;
|
|
100
|
+
let negate = false;
|
|
101
|
+
if (line.startsWith("!")) {
|
|
102
|
+
negate = true;
|
|
103
|
+
line = line.slice(1);
|
|
104
|
+
}
|
|
105
|
+
else if (line.startsWith("\\!") || line.startsWith("\\#")) {
|
|
106
|
+
line = line.slice(1);
|
|
107
|
+
}
|
|
108
|
+
let dirOnly = false;
|
|
109
|
+
if (line.endsWith("/")) {
|
|
110
|
+
dirOnly = true;
|
|
111
|
+
line = line.replace(/\/+$/, "");
|
|
112
|
+
}
|
|
113
|
+
if (!line)
|
|
114
|
+
continue;
|
|
115
|
+
const anchored = line.includes("/");
|
|
116
|
+
line = line.replace(/^\//, "");
|
|
117
|
+
const body = globToRegex(line);
|
|
118
|
+
rules.push({ re: new RegExp(`^${anchored ? "" : "(?:.*/)?"}${body}$`), negate, dirOnly });
|
|
119
|
+
}
|
|
120
|
+
const verdict = (p, isDir) => {
|
|
121
|
+
let v;
|
|
122
|
+
for (const r of rules)
|
|
123
|
+
if ((!r.dirOnly || isDir) && r.re.test(p))
|
|
124
|
+
v = !r.negate;
|
|
125
|
+
return v;
|
|
126
|
+
};
|
|
127
|
+
// As in git: a file inside an ignored folder stays ignored.
|
|
128
|
+
return (rel, isDir = false) => {
|
|
129
|
+
const parts = rel.split("/");
|
|
130
|
+
for (let i = 1; i <= parts.length; i++) {
|
|
131
|
+
if (verdict(parts.slice(0, i).join("/"), i < parts.length || isDir))
|
|
132
|
+
return true;
|
|
133
|
+
}
|
|
134
|
+
return false;
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
/** The matcher for `<root>/.lizardignore`, or null when there is none. */
|
|
138
|
+
export function loadLizardIgnore(root) {
|
|
139
|
+
try {
|
|
140
|
+
return parseIgnore(fs.readFileSync(path.join(root, ".lizardignore"), "utf8"));
|
|
141
|
+
}
|
|
142
|
+
catch {
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=upload-filter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload-filter.js","sourceRoot":"","sources":["../../src/lib/upload-filter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,+EAA+E;AAE/E,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;AACxD,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC;AAC9D,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,cAAc,EAAE,aAAa,CAAC,CAAC,CAAC;AAE/D,wFAAwF;AACxF,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,OAAO,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,CAA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AAI,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;gBAAE,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC;QAChF,OAAO,CAAC,CAAC;IACX,CAAC,CAAC;IACF,4DAA4D;IAC5D,OAAO,CAAC,GAAW,EAAE,KAAK,GAAG,KAAK,EAAE,EAAE;QACpC,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACvC,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC;gBAAE,OAAO,IAAI,CAAC;QACnF,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;AACJ,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,IAAI,CAAC;QACH,OAAO,WAAW,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,eAAe,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IAChF,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lizard-build/cli",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.136",
|
|
4
4
|
"description": "Lizard CLI — deploy apps, databases and sandboxes to Lizard (lizard.build) from your terminal or your coding agent. Detects Go, Node, Python, Rust, Ruby, PHP, Java and static sites; adds Managed Postgres, Managed Redis and Managed Object Storage in one command.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -100,7 +100,7 @@ Field names are flat and match the wire schema 1:1 (and `service show` output).
|
|
|
100
100
|
lizard up --json
|
|
101
101
|
```
|
|
102
102
|
|
|
103
|
-
- Uploads cwd as a tarball (at most 150 MB compressed) and forces `sourceType=upload`. In a git repo it sends tracked files plus untracked files that `.gitignore` doesn't exclude; outside git it skips `node_modules`, `.git`, `dist`, `build`, `.next`, virtualenvs and caches, so a prebuilt `dist/` is not sent.
|
|
103
|
+
- Uploads cwd as a tarball (at most 150 MB compressed) and forces `sourceType=upload`. In a git repo it sends tracked files plus untracked files that `.gitignore` doesn't exclude; outside git it skips `node_modules`, `.git`, `dist`, `build`, `.next`, virtualenvs and caches, so a prebuilt `dist/` is not sent. Outside git it also skips files that look like secrets (`.env`/`.env.*` except `.env.example`/`.env.sample`, `.ssh/`, `.aws/`, `.gnupg/`, `.npmrc`, `.pypirc`, `.netrc`, `.docker/config.json`, `id_rsa*`/`id_ed25519*`/`id_ecdsa*`, `*.pem`, `*.key`), prints which, and refuses to run from the home folder or `/`; in git it warns about an untracked, non-ignored `.env*`. A `.lizardignore` (gitignore syntax) in the uploaded folder excludes more paths in both cases. `.dockerignore` is not read.
|
|
104
104
|
- Streams build logs; ends with `{ event: "deployed", status: "running", url }`. A failed build ends with `{ event: "error", message }` and exit 1; no `deployed` event means the service isn't running yet (see the core guide).
|
|
105
105
|
- With no linked service, `up` deploys into the service named like `package.json` `name` (else the folder), and switches it to an upload even if it was git-backed. `--service <name>` deploys to that service, creating it when none has the name; a folder linked to an addon (after `lizard add postgres`) is treated as unlinked.
|
|
106
106
|
- Flags: `--project`, `--service`, `--region`, `--build-command`, `--start-command`, `--pre-deploy-command`, `--port`, `--detach`, `--ci`.
|
|
@@ -28,7 +28,7 @@ The details behind the Sandboxes section of the core guide. Read the part the ta
|
|
|
28
28
|
| `codex`, `claude`, `opencode`, `pi`, `prime` | One coding agent each (Codex, Claude Code, OpenCode, pi, Prime Agent) on Node 22, with git, python3, ripgrep, curl, jq and `lizard`: see [Coding agents](#coding-agents) |
|
|
29
29
|
| `desktop` | A graphical desktop with Chromium, plus Codex and `lizard`: see [Desktop](#desktop-computer-use) |
|
|
30
30
|
|
|
31
|
-
Every template in `us-east-1` also has `gh` (GitHub CLI) and Docker: see [Docker](#docker). A sandbox starts in `us-east-1` unless `--region` names another; with `--volume` or `--snapshot` it starts in their region. An unknown name fails and lists the region's `availableTemplates`. `--with-token` on `sandbox create` signs in the sandbox's own `lizard` with a new key limited to the sandbox's project, deleted with the sandbox (only useful on templates that ship `lizard`).
|
|
31
|
+
Every template in `us-east-1` also has `gh` (GitHub CLI) and Docker: see [Docker](#docker). A sandbox starts in `us-east-1` unless `--region` names another; with `--volume` or `--snapshot` it starts in their region. An unknown name fails and lists the region's `availableTemplates`. `--with-token` on `sandbox create` signs in the sandbox's own `lizard` with a new key limited to the sandbox's project, deleted with the sandbox (only useful on templates that ship `lizard`; works with any sign-in, a browser `lizard login` included).
|
|
32
32
|
|
|
33
33
|
`--no-internet` on `sandbox create` starts a sandbox with no internet at all (no outbound TCP, UDP, DNS or ping) for its whole life, its resumes and forks included, and none of its ports can be made public (`sandbox expose` and the desktop are refused); commands and files still work. It is set at create only and cannot be changed later. Not available with a container volume or snapshot. Use it to run untrusted code that must not reach the network.
|
|
34
34
|
|
|
@@ -5,6 +5,7 @@ import { readFileSync, writeFileSync, existsSync, statSync } from "node:fs";
|
|
|
5
5
|
import { basename } from "node:path";
|
|
6
6
|
import { APIError } from "../lib/api.js";
|
|
7
7
|
import { isJSONMode, printJSON, table, success, info, warn, link } from "../lib/format.js";
|
|
8
|
+
import { termSafe as safeOut, termSafeErr as safeErr } from "../lib/terminal.js";
|
|
8
9
|
import {
|
|
9
10
|
lg, qs, seg, segs, resolveRepo, repoPath, myLogin, gitURL, ago, ACTIVE_RUN, checksState,
|
|
10
11
|
} from "../lib/lizard-git.js";
|
|
@@ -155,7 +156,8 @@ export function registerLizardGit(git: Command) {
|
|
|
155
156
|
continue;
|
|
156
157
|
}
|
|
157
158
|
for (const line of wc.unifiedDiff(old, cur, p).split("\n")) {
|
|
158
|
-
|
|
159
|
+
const l = safeOut(line);
|
|
160
|
+
console.log(l.startsWith("+") && !l.startsWith("+++") ? chalk.green(l) : l.startsWith("-") && !l.startsWith("---") ? chalk.red(l) : l.startsWith("@@") ? chalk.cyan(l) : l);
|
|
159
161
|
}
|
|
160
162
|
}
|
|
161
163
|
});
|
|
@@ -292,7 +294,7 @@ export function registerLizardGit(git: Command) {
|
|
|
292
294
|
out(repos, () => {
|
|
293
295
|
if (!repos.length) return info("No repositories. Create one: lizard git repo create <name>");
|
|
294
296
|
table(["REPO", "VISIBILITY", "UPDATED", "DESCRIPTION"], repos.map((r) => [
|
|
295
|
-
`${r.owner}/${r.name}`, r.private ? "private" : "public", ago(r.pushedAt ?? r.updatedAt), (r.description ?? "").slice(0, 60),
|
|
297
|
+
`${r.owner}/${r.name}`, r.private ? "private" : "public", ago(r.pushedAt ?? r.updatedAt), safeOut(r.description ?? "").slice(0, 60),
|
|
296
298
|
]));
|
|
297
299
|
});
|
|
298
300
|
});
|
|
@@ -321,8 +323,8 @@ export function registerLizardGit(git: Command) {
|
|
|
321
323
|
const m = await lg.get<any>(repoPath(r));
|
|
322
324
|
out(m, () => {
|
|
323
325
|
info(`${chalk.bold(r)} ${m.repo.private ? "private" : "public"} ${chalk.dim(`you: ${m.role || "reader"}`)}`);
|
|
324
|
-
if (m.workspace) info(chalk.dim(`workspace: ${m.workspace.name} (${m.workspace.slug}): its members are collaborators`));
|
|
325
|
-
if (m.repo.description) info(m.repo.description);
|
|
326
|
+
if (m.workspace) info(chalk.dim(`workspace: ${safeErr(m.workspace.name)} (${safeErr(m.workspace.slug)}): its members are collaborators`));
|
|
327
|
+
if (m.repo.description) info(safeErr(m.repo.description));
|
|
326
328
|
if (m.forkOf) info(chalk.dim(`forked from ${m.forkOf}`));
|
|
327
329
|
info(`default branch ${m.repo.defaultBranch} · ${m.branches} branches · ${m.tags} tags · ${m.openIssues} open issues · ${m.openPulls} open pull requests · ${m.repo.stars} stars`);
|
|
328
330
|
info(`${link(`${gitURL()}/${r}`)}\ncheck out: lizard git clone ${r}`);
|
|
@@ -407,11 +409,11 @@ export function registerLizardGit(git: Command) {
|
|
|
407
409
|
if (opts.recursive) {
|
|
408
410
|
const files = await lg.get<string[]>(qs(`${repoPath(r)}/files`, { ref: opts.ref }));
|
|
409
411
|
const f = path ? files.filter((p) => p.startsWith(path.replace(/\/?$/, "/"))) : files;
|
|
410
|
-
return out(f, () => process.stdout.write(f.join("\n") + (f.length ? "\n" : "")));
|
|
412
|
+
return out(f, () => process.stdout.write(safeOut(f.join("\n")) + (f.length ? "\n" : "")));
|
|
411
413
|
}
|
|
412
414
|
const t = await lg.get<any>(qs(`${repoPath(r)}/tree`, { ref: opts.ref, path }));
|
|
413
415
|
const entries: any[] = t.entries ?? t;
|
|
414
|
-
out(t, () => table(["TYPE", "NAME", "SIZE"], entries.map((
|
|
416
|
+
out(t, () => table(["TYPE", "NAME", "SIZE"], entries.map((x) => [x.type, x.type === "tree" ? chalk.bold(safeOut(x.name) + "/") : safeOut(x.name), x.size != null ? String(x.size) : ""])));
|
|
415
417
|
});
|
|
416
418
|
repoOpt(git.command("cat").description("Print a file from a Lizard Git repository").argument("<path>"))
|
|
417
419
|
.option("--ref <ref>", "Branch, tag or commit (default branch)")
|
|
@@ -426,7 +428,7 @@ export function registerLizardGit(git: Command) {
|
|
|
426
428
|
return done({ path, ref, bytes: data.length, output: opts.output }, `Wrote ${data.length} bytes to ${opts.output}`);
|
|
427
429
|
}
|
|
428
430
|
if (isJSONMode()) return printJSON({ path, ref, content: data.toString("utf8") });
|
|
429
|
-
process.stdout.write(data);
|
|
431
|
+
process.stdout.write(process.stdout.isTTY ? safeOut(data.toString("utf8")) : data);
|
|
430
432
|
});
|
|
431
433
|
repoOpt(git.command("log").description("Commits of a Lizard Git repository"))
|
|
432
434
|
.option("--ref <ref>", "Branch, tag or commit")
|
|
@@ -435,15 +437,15 @@ export function registerLizardGit(git: Command) {
|
|
|
435
437
|
.action(async (opts) => {
|
|
436
438
|
const r = await resolveRepo(opts.repo);
|
|
437
439
|
const c = await lg.get<any>(qs(`${repoPath(r)}/commits`, { ref: opts.ref, path: opts.path, page: opts.page }));
|
|
438
|
-
out(c, () => table(["COMMIT", "AUTHOR", "WHEN", "SUBJECT"], c.commits.map((x: any) => [chalk.yellow(x.sha.slice(0, 7)), x.authorName, ago(x.date), x.subject.slice(0, 70)])));
|
|
440
|
+
out(c, () => table(["COMMIT", "AUTHOR", "WHEN", "SUBJECT"], c.commits.map((x: any) => [chalk.yellow(x.sha.slice(0, 7)), x.authorName, ago(x.date), safeOut(x.subject).slice(0, 70)])));
|
|
439
441
|
});
|
|
440
442
|
repoOpt(git.command("show").description("One commit: message and changed files").argument("<sha>"))
|
|
441
443
|
.action(async (sha: string, opts) => {
|
|
442
444
|
const r = await resolveRepo(opts.repo);
|
|
443
445
|
const c = await lg.get<any>(`${repoPath(r)}/commits/${seg(sha)}`);
|
|
444
446
|
out(c, () => {
|
|
445
|
-
info(`${chalk.yellow(c.commit.sha)}\n${c.commit.authorName} <${c.commit.authorEmail}> ${ago(c.commit.date)}\n\n ${c.commit.subject}\n`);
|
|
446
|
-
for (const f of c.diff?.files ?? []) info(` ${f.status} ${f.newPath || f.oldPath} ${chalk.green(`+${f.additions}`)} ${chalk.red(`-${f.deletions}`)}`);
|
|
447
|
+
info(`${chalk.yellow(c.commit.sha)}\n${safeErr(c.commit.authorName)} <${safeErr(c.commit.authorEmail)}> ${ago(c.commit.date)}\n\n ${safeErr(c.commit.subject)}\n`);
|
|
448
|
+
for (const f of c.diff?.files ?? []) info(` ${f.status} ${safeErr(f.newPath || f.oldPath)} ${chalk.green(`+${f.additions}`)} ${chalk.red(`-${f.deletions}`)}`);
|
|
447
449
|
});
|
|
448
450
|
});
|
|
449
451
|
repoOpt(git.command("search").description("Search the code of a Lizard Git repository").argument("<text>"))
|
|
@@ -451,7 +453,7 @@ export function registerLizardGit(git: Command) {
|
|
|
451
453
|
.action(async (text: string, opts) => {
|
|
452
454
|
const r = await resolveRepo(opts.repo);
|
|
453
455
|
const hits = await lg.get<any[]>(qs(`${repoPath(r)}/search`, { q: text, ref: opts.ref }));
|
|
454
|
-
out(hits, () => hits.length ? hits.forEach((h) => info(`${chalk.cyan(h.path)}:${h.line}: ${(h.text ?? "").trim()}`)) : info("No matches."));
|
|
456
|
+
out(hits, () => hits.length ? hits.forEach((h) => info(`${chalk.cyan(safeErr(h.path))}:${h.line}: ${safeErr(h.text ?? "").trim()}`)) : info("No matches."));
|
|
455
457
|
});
|
|
456
458
|
// ── Issues and pull requests ─────────────────────────────────────────
|
|
457
459
|
for (const kind of ["issue", "pr"] as const) {
|
|
@@ -470,9 +472,9 @@ export function registerLizardGit(git: Command) {
|
|
|
470
472
|
out(l, () => {
|
|
471
473
|
if (!l.items.length) return info(`No ${opts.state === "all" ? "" : opts.state + " "}${noun}s. (${l.open} open, ${l.closed} closed)`);
|
|
472
474
|
table(["#", "STATE", "TITLE", pulls ? "BRANCH" : "LABELS", "AUTHOR", "UPDATED"], l.items.map((i: any) => [
|
|
473
|
-
String(i.number), state(i.draft ? "draft" : i.state), i.title.slice(0, 60),
|
|
474
|
-
pulls ? `${i.headRepo ? i.headRepo.split("/")[0] + ":" : ""}${i.headRef} → ${i.baseRef}` : (i.labels ?? []).map((x: any) => x.name).join(","),
|
|
475
|
-
i.author, ago(i.updatedAt),
|
|
475
|
+
String(i.number), state(i.draft ? "draft" : i.state), safeOut(i.title).slice(0, 60),
|
|
476
|
+
safeOut(pulls ? `${i.headRepo ? i.headRepo.split("/")[0] + ":" : ""}${i.headRef} → ${i.baseRef}` : (i.labels ?? []).map((x: any) => x.name).join(",")),
|
|
477
|
+
safeOut(i.author), ago(i.updatedAt),
|
|
476
478
|
]));
|
|
477
479
|
});
|
|
478
480
|
});
|
|
@@ -519,19 +521,19 @@ export function registerLizardGit(git: Command) {
|
|
|
519
521
|
if (d.issue.isPull) reviews = await lg.get<any>(`${repoPath(r)}/pulls/${n}/reviews`).catch(() => null);
|
|
520
522
|
out(reviews ? { ...d, reviews } : d, () => {
|
|
521
523
|
const i = d.issue;
|
|
522
|
-
info(`${chalk.bold(i.title)} ${chalk.dim(`#${i.number}`)} ${state(i.draft ? "draft" : i.state)}`);
|
|
523
|
-
info(chalk.dim(`${i.author} opened ${ago(i.createdAt)}${i.isPull ? ` · ${i.headRepo ? i.headRepo + ":" : ""}${i.headRef} → ${i.baseRef}` : ""}`));
|
|
524
|
-
if (i.labels?.length) info(`labels: ${i.labels.map((l: any) => l.name).join(", ")}`);
|
|
525
|
-
if (i.assignees?.length) info(`assignees: ${i.assignees.map((a: any) => a.login).join(", ")}`);
|
|
524
|
+
info(`${chalk.bold(safeErr(i.title))} ${chalk.dim(`#${i.number}`)} ${state(i.draft ? "draft" : i.state)}`);
|
|
525
|
+
info(chalk.dim(`${safeErr(i.author)} opened ${ago(i.createdAt)}${i.isPull ? safeErr(` · ${i.headRepo ? i.headRepo + ":" : ""}${i.headRef} → ${i.baseRef}`) : ""}`));
|
|
526
|
+
if (i.labels?.length) info(`labels: ${safeErr(i.labels.map((l: any) => l.name).join(", "))}`);
|
|
527
|
+
if (i.assignees?.length) info(`assignees: ${safeErr(i.assignees.map((a: any) => a.login).join(", "))}`);
|
|
526
528
|
if (d.pull) {
|
|
527
529
|
const p = d.pull;
|
|
528
|
-
if (p.merge) info(`merge: ${p.merge.conflicts?.length ? chalk.red("conflicts in " + p.merge.conflicts.join(", ")) : chalk.green("no conflicts")}`);
|
|
529
|
-
if (p.gate?.blockers?.length) info(`${chalk.yellow("blocked:")} ${p.gate.blockers.join("; ")}`);
|
|
530
|
-
if (reviews?.decision) info(`reviews: ${reviews.decision.approvals.length} approved${reviews.decision.changesRequested.length ? `, changes requested by ${reviews.decision.changesRequested.join(", ")}` : ""}`);
|
|
530
|
+
if (p.merge) info(`merge: ${p.merge.conflicts?.length ? chalk.red("conflicts in " + safeErr(p.merge.conflicts.join(", "))) : chalk.green("no conflicts")}`);
|
|
531
|
+
if (p.gate?.blockers?.length) info(`${chalk.yellow("blocked:")} ${safeErr(p.gate.blockers.join("; "))}`);
|
|
532
|
+
if (reviews?.decision) info(`reviews: ${reviews.decision.approvals.length} approved${reviews.decision.changesRequested.length ? `, changes requested by ${safeErr(reviews.decision.changesRequested.join(", "))}` : ""}`);
|
|
531
533
|
}
|
|
532
|
-
if (i.body?.trim()) info(`\n${i.body.trim()}\n`);
|
|
534
|
+
if (i.body?.trim()) info(`\n${safeErr(i.body.trim())}\n`);
|
|
533
535
|
const cs: any[] = (d.comments ?? []).filter((c: any) => c.kind === "comment" || !c.kind);
|
|
534
|
-
for (const c of opts.comments ? cs : cs.slice(-10)) info(`${chalk.bold(c.author)} ${chalk.dim(ago(c.createdAt))}\n ${
|
|
536
|
+
for (const c of opts.comments ? cs : cs.slice(-10)) info(`${chalk.bold(safeErr(c.author))} ${chalk.dim(ago(c.createdAt))}\n ${safeErr(c.body).trim().replace(/\n/g, "\n ")}\n`);
|
|
535
537
|
info(link(`${gitURL()}/${r}/${i.isPull ? "pull" : "issues"}/${i.number}`));
|
|
536
538
|
});
|
|
537
539
|
});
|
|
@@ -600,12 +602,12 @@ export function registerLizardGit(git: Command) {
|
|
|
600
602
|
out(d, () => {
|
|
601
603
|
for (const f of d.diff?.files ?? []) {
|
|
602
604
|
const name = f.oldPath && f.newPath && f.oldPath !== f.newPath ? `${f.oldPath} → ${f.newPath}` : f.newPath || f.oldPath;
|
|
603
|
-
process.stdout.write(`${chalk.bold(name)} ${chalk.green(`+${f.additions}`)} ${chalk.red(`-${f.deletions}`)}${f.binary ? " (binary)" : ""}\n`);
|
|
605
|
+
process.stdout.write(`${chalk.bold(safeOut(name))} ${chalk.green(`+${f.additions}`)} ${chalk.red(`-${f.deletions}`)}${f.binary ? " (binary)" : ""}\n`);
|
|
604
606
|
if (opts.stat) continue;
|
|
605
607
|
for (const h of f.hunks ?? []) {
|
|
606
|
-
process.stdout.write(chalk.cyan(h.header) + "\n");
|
|
608
|
+
process.stdout.write(chalk.cyan(safeOut(h.header)) + "\n");
|
|
607
609
|
for (const l of h.lines ?? []) {
|
|
608
|
-
const t = `${l.k}${l.t}
|
|
610
|
+
const t = safeOut(`${l.k}${l.t}`);
|
|
609
611
|
process.stdout.write((l.k === "+" ? chalk.green(t) : l.k === "-" ? chalk.red(t) : t) + "\n");
|
|
610
612
|
}
|
|
611
613
|
}
|
|
@@ -616,7 +618,7 @@ export function registerLizardGit(git: Command) {
|
|
|
616
618
|
.action(async (n: number, opts) => {
|
|
617
619
|
const r = await resolveRepo(opts.repo);
|
|
618
620
|
const cs = await lg.get<any[]>(`${repoPath(r)}/pulls/${n}/commits`);
|
|
619
|
-
out(cs, () => table(["COMMIT", "AUTHOR", "SUBJECT"], cs.map((c) => [chalk.yellow(c.sha.slice(0, 7)), c.authorName, c.subject.slice(0, 70)])));
|
|
621
|
+
out(cs, () => table(["COMMIT", "AUTHOR", "SUBJECT"], cs.map((c) => [chalk.yellow(c.sha.slice(0, 7)), safeOut(c.authorName), safeOut(c.subject).slice(0, 70)])));
|
|
620
622
|
});
|
|
621
623
|
repoOpt(grp.command("review").description("Approve, request changes, or comment on a pull request").argument("<number>", "", int))
|
|
622
624
|
.option("--approve").option("--request-changes").option("--comment", "A review that only comments (default)")
|
|
@@ -639,9 +641,9 @@ export function registerLizardGit(git: Command) {
|
|
|
639
641
|
const r = await resolveRepo(opts.repo);
|
|
640
642
|
const rv = await lg.get<any>(`${repoPath(r)}/pulls/${n}/reviews`);
|
|
641
643
|
out(rv, () => {
|
|
642
|
-
for (const x of rv.reviews) info(`${chalk.bold(x.author)} ${state(x.state)} ${chalk.dim(ago(x.createdAt))}${x.body ? `\n ${x.body}` : ""}`);
|
|
643
|
-
for (const c of rv.comments) info(`${chalk.cyan(`${c.path}:${c.line}`)} ${chalk.bold(c.author)}: ${c.body}`);
|
|
644
|
-
info(`approvals: ${rv.decision.approvals.join(", ") || "none"}${rv.decision.changesRequested.length ? ` · changes requested: ${rv.decision.changesRequested.join(", ")}` : ""}`);
|
|
644
|
+
for (const x of rv.reviews) info(`${chalk.bold(safeErr(x.author))} ${state(x.state)} ${chalk.dim(ago(x.createdAt))}${x.body ? `\n ${safeErr(x.body)}` : ""}`);
|
|
645
|
+
for (const c of rv.comments) info(`${chalk.cyan(safeErr(`${c.path}:${c.line}`))} ${chalk.bold(safeErr(c.author))}: ${safeErr(c.body)}`);
|
|
646
|
+
info(`approvals: ${safeErr(rv.decision.approvals.join(", ")) || "none"}${rv.decision.changesRequested.length ? ` · changes requested: ${safeErr(rv.decision.changesRequested.join(", "))}` : ""}`);
|
|
645
647
|
});
|
|
646
648
|
});
|
|
647
649
|
repoOpt(grp.command("checks").description("CI runs and commit statuses of a pull request's head").argument("<number>", "", int))
|
|
@@ -1202,9 +1204,9 @@ export function registerLizardGit(git: Command) {
|
|
|
1202
1204
|
const r = await resolveRepo(opts.repo);
|
|
1203
1205
|
const x = await findRelease(r, tag);
|
|
1204
1206
|
out(x, () => {
|
|
1205
|
-
info(`${chalk.bold(x.name || x.tag)} ${chalk.dim(x.tag)}${x.draft ? " draft" : ""}${x.prerelease ? " pre-release" : ""} ${x.sha?.slice(0, 7) ?? ""}`);
|
|
1206
|
-
if (x.body) info(`\n${x.body}\n`);
|
|
1207
|
-
for (const a of x.assets ?? []) info(` ${a.name} ${a.size} B`);
|
|
1207
|
+
info(`${chalk.bold(safeErr(x.name || x.tag))} ${chalk.dim(safeErr(x.tag))}${x.draft ? " draft" : ""}${x.prerelease ? " pre-release" : ""} ${x.sha?.slice(0, 7) ?? ""}`);
|
|
1208
|
+
if (x.body) info(`\n${safeErr(x.body)}\n`);
|
|
1209
|
+
for (const a of x.assets ?? []) info(` ${safeErr(a.name)} ${a.size} B`);
|
|
1208
1210
|
});
|
|
1209
1211
|
});
|
|
1210
1212
|
repoOpt(release.command("edit").description("Change a release").argument("<tag>"))
|
package/src/commands/logs.ts
CHANGED
|
@@ -5,6 +5,10 @@ import { streamSSE, api, withScope, withQuery, type ResourceScope } from "../lib
|
|
|
5
5
|
import { resolveProjectScope, resolveService, getActiveServiceWithKind } from "../lib/resolve.js";
|
|
6
6
|
import { getProjectLink } from "../lib/config.js";
|
|
7
7
|
import { info, error, warn, fail, isTTY, isJSONMode, printJSON, table, statusColor, timeAgo } from "../lib/format.js";
|
|
8
|
+
import { termSafe } from "../lib/terminal.js";
|
|
9
|
+
|
|
10
|
+
/** A service's log text for the terminal: its colors stay, nothing else that steers the terminal. */
|
|
11
|
+
const logText = (s: unknown) => termSafe(s, { keepColors: true });
|
|
8
12
|
|
|
9
13
|
// Levels assigned by the platform's log collector (regex over the message
|
|
10
14
|
// text — apps that log errors without an "error"-like keyword come as info).
|
|
@@ -247,7 +251,7 @@ async function fetchFlatRestarts(appId: string): Promise<FlatEvent[]> {
|
|
|
247
251
|
|
|
248
252
|
function replicaPrefix(e: any): string {
|
|
249
253
|
if (!e.replica) return "";
|
|
250
|
-
return chalk.magenta(`[${e.replica}]`) + " ";
|
|
254
|
+
return chalk.magenta(`[${logText(e.replica)}]`) + " ";
|
|
251
255
|
}
|
|
252
256
|
|
|
253
257
|
function printLogEntry(e: any) {
|
|
@@ -257,10 +261,10 @@ function printLogEntry(e: any) {
|
|
|
257
261
|
}
|
|
258
262
|
const rep = replicaPrefix(e);
|
|
259
263
|
if (e.service && e.message) {
|
|
260
|
-
const prefix = chalk.cyan(`[${e.service}]`);
|
|
261
|
-
process.stdout.write(`${prefix} ${rep}${e.message}\n`);
|
|
264
|
+
const prefix = chalk.cyan(`[${logText(e.service)}]`);
|
|
265
|
+
process.stdout.write(`${prefix} ${rep}${logText(e.message)}\n`);
|
|
262
266
|
} else if (e.message) {
|
|
263
|
-
process.stdout.write(`${rep}${e.message}\n`);
|
|
267
|
+
process.stdout.write(`${rep}${logText(e.message)}\n`);
|
|
264
268
|
}
|
|
265
269
|
}
|
|
266
270
|
|
|
@@ -280,12 +284,12 @@ function printLogLine(data: string) {
|
|
|
280
284
|
|
|
281
285
|
const rep = replicaPrefix(parsed);
|
|
282
286
|
if (parsed.service && parsed.message) {
|
|
283
|
-
const prefix = chalk.cyan(`[${parsed.service}]`);
|
|
284
|
-
process.stdout.write(`${prefix} ${rep}${parsed.message}\n`);
|
|
287
|
+
const prefix = chalk.cyan(`[${logText(parsed.service)}]`);
|
|
288
|
+
process.stdout.write(`${prefix} ${rep}${logText(parsed.message)}\n`);
|
|
285
289
|
} else if (parsed.message) {
|
|
286
|
-
process.stdout.write(`${rep}${parsed.message}\n`);
|
|
290
|
+
process.stdout.write(`${rep}${logText(parsed.message)}\n`);
|
|
287
291
|
} else {
|
|
288
|
-
process.stdout.write(data + "\n");
|
|
292
|
+
process.stdout.write(logText(data) + "\n");
|
|
289
293
|
}
|
|
290
294
|
}
|
|
291
295
|
|
|
@@ -372,13 +376,13 @@ async function showRestartLogTail(
|
|
|
372
376
|
console.log(chalk.dim("When: ") + timeAgo(evt.crashedAt));
|
|
373
377
|
console.log(chalk.dim("Source: ") + evt.source);
|
|
374
378
|
console.log(chalk.dim("Status: ") + statusColor(evt.status));
|
|
375
|
-
if (evt.exitInfo) console.log(chalk.dim("Exit: ") + evt.exitInfo);
|
|
376
|
-
if (evt.triggeredBy) console.log(chalk.dim("By: ") + evt.triggeredBy);
|
|
379
|
+
if (evt.exitInfo) console.log(chalk.dim("Exit: ") + logText(evt.exitInfo));
|
|
380
|
+
if (evt.triggeredBy) console.log(chalk.dim("By: ") + logText(evt.triggeredBy));
|
|
377
381
|
if (evt.buildId) console.log(chalk.dim("Build: ") + evt.buildId);
|
|
378
382
|
console.log();
|
|
379
383
|
|
|
380
384
|
if (evt.logsTail) {
|
|
381
|
-
process.stdout.write(evt.logsTail);
|
|
385
|
+
process.stdout.write(logText(evt.logsTail));
|
|
382
386
|
if (!evt.logsTail.endsWith("\n")) process.stdout.write("\n");
|
|
383
387
|
} else {
|
|
384
388
|
info(chalk.dim(`<no log tail captured — source=${evt.source} (manual restarts don't capture logs)>`));
|
|
@@ -453,7 +457,7 @@ async function showBuildLogs(
|
|
|
453
457
|
if (isJSONMode()) {
|
|
454
458
|
process.stdout.write(JSON.stringify({ message: line }) + "\n");
|
|
455
459
|
} else {
|
|
456
|
-
process.stdout.write(line + "\n");
|
|
460
|
+
process.stdout.write(logText(line) + "\n");
|
|
457
461
|
}
|
|
458
462
|
}
|
|
459
463
|
return;
|
package/src/commands/sandbox.ts
CHANGED
|
@@ -62,6 +62,8 @@ interface SandboxRecord {
|
|
|
62
62
|
/** Set by the platform when nothing named a project and it used the account's default. */
|
|
63
63
|
projectName?: string;
|
|
64
64
|
projectDefaulted?: boolean;
|
|
65
|
+
/** Only when created with --with-token: whether the sandbox's own key is in its ~/.lizard/config.json. Absent from older platforms. */
|
|
66
|
+
sessionKey?: boolean;
|
|
65
67
|
/** Only when created with --repo. */
|
|
66
68
|
repo?: { fullName: string; path: string | null; status: "cloned" | "cloning" | "failed"; error?: string; readOnly?: boolean; manageUrl?: string };
|
|
67
69
|
}
|
|
@@ -189,7 +191,7 @@ export function registerSandbox(program: Command) {
|
|
|
189
191
|
.option("--region <code>", `Region to create the sandbox in (default ${DEFAULT_REGION}; with --volume or --snapshot, theirs)`)
|
|
190
192
|
.option("--snapshot <id>", "Create from a private saved snapshot, at the size it was taken at")
|
|
191
193
|
.option("--volume <name-or-id>", "Attach a persistent volume")
|
|
192
|
-
.option("--with-token [key]", "Sign in `lizard` inside the sandbox with a new key limited to the sandbox's project and deleted with it (
|
|
194
|
+
.option("--with-token [key]", "Sign in `lizard` inside the sandbox with a new key limited to the sandbox's project and deleted with it (works with any sign-in; a liz_ key given here is only needed by older platforms)")
|
|
193
195
|
.option("-p, --project <id>", "Project to create the sandbox in (name, slug, or ID). Defaults to the linked project.")
|
|
194
196
|
.option("--allow-host <host>", "With no internet, still allow this host name (pypi.org, *.pythonhosted.org: ports 80/443) or IPv4 address/range (every port); repeat for more. Implies --no-internet", (v: string, all: string[] = []) => [...all, v])
|
|
195
197
|
.option("--no-internet", "Fully closed sandbox, for its whole life (its resumes and forks too): no internet and no public ports; commands and files still work")
|
|
@@ -258,21 +260,23 @@ A prompt needs a sandbox from an agent template (claude, codex, opencode, pi, pr
|
|
|
258
260
|
|
|
259
261
|
const spinner = isJSONMode() ? null : ora("Creating sandbox...").start();
|
|
260
262
|
let sandbox: SandboxRecord;
|
|
263
|
+
let lizardTokenSent = false;
|
|
261
264
|
try {
|
|
262
|
-
// --with-token
|
|
263
|
-
//
|
|
264
|
-
//
|
|
265
|
-
//
|
|
266
|
-
//
|
|
267
|
-
//
|
|
268
|
-
// workspace if it escapes — warn rather than silently do the dangerous thing.
|
|
265
|
+
// --with-token: the platform writes a NEW key of the sandbox's own (scoped to its
|
|
266
|
+
// project, deleted with it) to ~/.lizard/config.json inside the sandbox, so `lizard`
|
|
267
|
+
// works there. Your own credential is never written. `withSessionKey` asks for it with
|
|
268
|
+
// whatever sign-in this command uses, a browser `lizard login` included. `lizardToken`
|
|
269
|
+
// is how older platforms are asked: they need one of your liz_ keys as proof, so it is
|
|
270
|
+
// sent only when there is one (given here, or the key you are signed in with).
|
|
269
271
|
let lizardToken: string | undefined;
|
|
270
272
|
if (opts.withToken) {
|
|
271
|
-
|
|
272
|
-
if (
|
|
273
|
-
|
|
274
|
-
throw new Error("--with-token expects a liz_ API key. Create a workspace-scoped one with `lizard keys create`.");
|
|
273
|
+
const given = typeof opts.withToken === "string" ? opts.withToken : undefined;
|
|
274
|
+
if (given && !given.startsWith("liz_")) {
|
|
275
|
+
throw new Error("--with-token takes no value, or a liz_ API key. Use bare --with-token to sign the sandbox in with your current login.");
|
|
275
276
|
}
|
|
277
|
+
const own = getToken() ?? undefined;
|
|
278
|
+
lizardToken = given ?? (own?.startsWith("liz_") ? own : undefined);
|
|
279
|
+
lizardTokenSent = !!lizardToken;
|
|
276
280
|
}
|
|
277
281
|
|
|
278
282
|
// No --region: us-east-1. A volume or a snapshot exists in one region only, so with
|
|
@@ -286,6 +290,7 @@ A prompt needs a sandbox from an agent template (claude, codex, opencode, pi, pr
|
|
|
286
290
|
region: opts.region || (defaultRegion ? DEFAULT_REGION : undefined),
|
|
287
291
|
volumeId,
|
|
288
292
|
volumeName,
|
|
293
|
+
...(opts.withToken ? { withSessionKey: true } : {}),
|
|
289
294
|
lizardToken,
|
|
290
295
|
projectId,
|
|
291
296
|
// Sent only when asked: every other create stays byte-for-byte what it was.
|
|
@@ -343,6 +348,16 @@ A prompt needs a sandbox from an agent template (claude, codex, opencode, pi, pr
|
|
|
343
348
|
throw new Error("This region's platform does not support --environment yet; the sandbox it started had the project's default variables and was deleted.");
|
|
344
349
|
}
|
|
345
350
|
|
|
351
|
+
// --with-token: a sandbox that was asked to sign itself in but could not (lzs pauses its
|
|
352
|
+
// sandbox from inside; without the key it would run, and bill, until deleted) is deleted.
|
|
353
|
+
// An older platform says nothing: it signed the sandbox in only if it was handed a liz_ key.
|
|
354
|
+
if (opts.withToken && (sandbox.sessionKey === false || (sandbox.sessionKey === undefined && !lizardTokenSent))) {
|
|
355
|
+
await api.delete(`/api/sandboxes/${sandbox.id}`).catch(() => {});
|
|
356
|
+
throw new Error(sandbox.sessionKey === false
|
|
357
|
+
? "The sandbox could not be signed in to `lizard` (--with-token), so it was deleted. Try again; if it keeps failing, report it with `lizard support open`."
|
|
358
|
+
: "This region's platform needs a liz_ API key for --with-token: pass one (`--with-token liz_...`, from `lizard keys create`). The sandbox it started was not signed in and was deleted.");
|
|
359
|
+
}
|
|
360
|
+
|
|
346
361
|
// The schedule, right after the create. If it is refused the sandbox stays: it works, and
|
|
347
362
|
// the schedule can be set again in its first 15 minutes.
|
|
348
363
|
const scheduled = scheduleBody ? await scheduleNewSandbox(sandbox.id, scheduleBody) : null;
|