@lizard-build/cli 4.0.104 → 4.0.107

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.
@@ -0,0 +1,112 @@
1
+ // Support tickets from the CLI: what `lizard support` attaches, and the support inbox.
2
+ //
3
+ // Two small pieces of local state in ~/.lizard/support.json:
4
+ // - the last failed platform calls (method, path, status, error), so a ticket carries the real
5
+ // error even when an agent describes it vaguely;
6
+ // - which support replies have been shown, so a reply is printed after the next commands (twice
7
+ // at most) and then stays in `lizard support show`.
8
+ // The inbox is checked after a command at most once a minute (GET /api/support/unread) and
9
+ // printed to stderr, so --json output on stdout never changes.
10
+ import fs from "node:fs";
11
+ import os from "node:os";
12
+ import path from "node:path";
13
+ import chalk from "chalk";
14
+ import { configDir } from "./config.js";
15
+ import { CURRENT_VERSION } from "./updater.js";
16
+ import { detectAgent } from "./agent.js";
17
+ const CHECK_EVERY_MS = 60_000;
18
+ const SHOW_TIMES = 2;
19
+ function stateFile() { return path.join(configDir(), "support.json"); }
20
+ function load() {
21
+ try {
22
+ return JSON.parse(fs.readFileSync(stateFile(), "utf8"));
23
+ }
24
+ catch {
25
+ return {};
26
+ }
27
+ }
28
+ function save(s) {
29
+ try {
30
+ fs.mkdirSync(configDir(), { recursive: true, mode: 0o700 });
31
+ fs.writeFileSync(stateFile(), JSON.stringify(s), { mode: 0o600 });
32
+ }
33
+ catch { /* best effort */ }
34
+ }
35
+ /** Called for every failed platform call. Never throws. */
36
+ export function recordFailedCall(method, urlPath, status, error, requestId) {
37
+ if (urlPath.startsWith("/api/support/"))
38
+ return;
39
+ const s = load();
40
+ const entry = {
41
+ method, path: urlPath.split("?")[0], status,
42
+ error: String(error).replace(/\bliz_[A-Za-z0-9_-]{8,}/g, "liz_[redacted]").slice(0, 400),
43
+ ...(requestId ? { requestId } : {}), at: new Date().toISOString(),
44
+ };
45
+ s.lastErrors = [...(s.lastErrors ?? []), entry].slice(-5);
46
+ save(s);
47
+ }
48
+ /** What a new ticket carries besides the message. Only the last hour's failures. */
49
+ export function ticketContext() {
50
+ const hourAgo = Date.now() - 3600_000;
51
+ const lastErrors = (load().lastErrors ?? []).filter((e) => Date.parse(e.at) > hourAgo);
52
+ return {
53
+ cliVersion: CURRENT_VERSION,
54
+ os: `${os.platform()} ${os.arch()} node ${process.versions.node}`,
55
+ ...(lastErrors.length ? { lastErrors } : {}),
56
+ };
57
+ }
58
+ export function agentName() {
59
+ return detectAgent() ?? undefined;
60
+ }
61
+ /** Server-side or network failures are worth a ticket; a 4xx about the request usually is not. */
62
+ export function isPlatformFailure(status, netCode) {
63
+ if (process.env.AGENT_SUPPORT === "0")
64
+ return false;
65
+ if (status === undefined)
66
+ return !!netCode;
67
+ return status >= 500 || status === 408;
68
+ }
69
+ export const SUPPORT_HINT = 'If this keeps failing, tell the Lizard team: lizard support open "<what you ran and what happened>" (the error above is attached automatically)';
70
+ /**
71
+ * Prints support replies the user has not seen yet, after a command. Throttled to one request
72
+ * a minute; each reply is printed at most twice. Never throws and never waits more than 2 s.
73
+ */
74
+ export async function printSupportInbox(fetchUnread, opts = {}) {
75
+ try {
76
+ const s = load();
77
+ if (!opts.force && s.checkedAt && Date.now() - s.checkedAt < CHECK_EVERY_MS)
78
+ return;
79
+ s.checkedAt = Date.now();
80
+ save(s);
81
+ const res = await Promise.race([
82
+ fetchUnread(),
83
+ new Promise((r) => setTimeout(() => r(null), 2000).unref()),
84
+ ]);
85
+ if (!res?.tickets?.length)
86
+ return;
87
+ const shown = { ...(load().shown ?? {}) };
88
+ const out = [];
89
+ for (const t of res.tickets) {
90
+ const fresh = t.messages.filter((m) => (shown[`${t.ticket}@${m.at}`] ?? 0) < SHOW_TIMES);
91
+ if (!fresh.length)
92
+ continue;
93
+ out.push(chalk.bold.green(`📬 Lizard support replied on ${t.ticket}`) + chalk.dim(` (${t.subject})`));
94
+ for (const m of fresh) {
95
+ shown[`${t.ticket}@${m.at}`] = (shown[`${t.ticket}@${m.at}`] ?? 0) + 1;
96
+ out.push(chalk.dim(` ${m.from}:`));
97
+ for (const line of m.body.split("\n"))
98
+ out.push(` ${line}`);
99
+ }
100
+ out.push(chalk.dim(` → answer: lizard support reply ${t.ticket} "<your answer>" · full thread: lizard support show ${t.ticket}`));
101
+ }
102
+ // Forget entries for replies that are no longer unread.
103
+ const live = new Set(res.tickets.flatMap((t) => t.messages.map((m) => `${t.ticket}@${m.at}`)));
104
+ const next = load();
105
+ next.shown = Object.fromEntries(Object.entries(shown).filter(([k]) => live.has(k)));
106
+ save(next);
107
+ if (out.length)
108
+ process.stderr.write("\n" + out.join("\n") + "\n");
109
+ }
110
+ catch { /* the inbox must never break a command */ }
111
+ }
112
+ //# sourceMappingURL=support.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"support.js","sourceRoot":"","sources":["../../src/lib/support.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,EAAE;AACF,6DAA6D;AAC7D,gGAAgG;AAChG,oDAAoD;AACpD,iGAAiG;AACjG,uDAAuD;AACvD,2FAA2F;AAC3F,+DAA+D;AAC/D,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAKzC,MAAM,cAAc,GAAG,MAAM,CAAC;AAC9B,MAAM,UAAU,GAAG,CAAC,CAAC;AAErB,SAAS,SAAS,KAAa,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;AAE/E,SAAS,IAAI;IACX,IAAI,CAAC;QAAC,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,SAAS,E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AI,CAAC,CAAC;IACrE,CAAC;IAAC,MAAM,CAAC,CAAC,0CAA0C,CAAC,CAAC;AACxD,CAAC"}
@@ -1,4 +1,4 @@
1
- export declare const CURRENT_VERSION = "4.0.104";
1
+ export declare const CURRENT_VERSION = "4.0.107";
2
2
  /**
3
3
  * True when selfUpdate() has a release asset to swap in for this platform.
4
4
  * False on Windows: a running .exe can't be replaced in place, so the
@@ -4,7 +4,7 @@ import { Readable } from "node:stream";
4
4
  import { join, dirname } from "node:path";
5
5
  import os from "node:os";
6
6
  import { spawn } from "node:child_process";
7
- export const CURRENT_VERSION = "4.0.104";
7
+ export const CURRENT_VERSION = "4.0.107";
8
8
  const RELEASES_API = "https://api.github.com/repos/lizard-build/lizard-cli/releases/latest";
9
9
  const RELEASE_BASE = "https://github.com/lizard-build/lizard-cli/releases/latest/download";
10
10
  /** Minimum gap between background update checks. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lizard-build/cli",
3
- "version": "4.0.104",
3
+ "version": "4.0.107",
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": {
@@ -26,6 +26,7 @@ If `$ARGUMENTS` is non-empty, treat it as the user's request and act on it. If e
26
26
  4. Resolve context before any change: `lizard status --json` shows whether this exact folder is linked. `linked: false` means commands go to the [default project](#default-project); pass `--project` when it matters. Confirm the project, service or sandbox you target.
27
27
  5. A network error (`fetch failed`, `UND_ERR_SOCKET`, `ECONNRESET`) is not an answer: run the command again. Before repeating a create, check with `list` / `ps` that the first attempt did not land.
28
28
  6. For destructive actions (delete a service, sandbox, volume or project, drop an addon, overwrite a project-wide secret, restart production), confirm with the user first. Without a terminal the CLI never asks: `sandbox rm`, `volume delete`, `keys delete` and `workspace rm` delete at once; `service`, `project`, `secrets` and `domain` deletes and billing changes refuse until you add `-y`. Add `-y` only after the user agrees.
29
+ 7. When Lizard itself is broken, or a plan or limit blocks the task, open a support ticket: see [Support](#support). After any command, read stderr for `📬 Lizard support replied`: answer support's questions there.
29
30
 
30
31
  ## Deploy command output
31
32
 
@@ -104,7 +105,7 @@ lizard sandbox exec <id> -- python3 /workspace/app.py
104
105
  lizard sandbox expose <id> 8000 --json # an HTTPS URL for a port in the sandbox
105
106
  lizard sandbox timeout <id> 3600000 # keep it for an hour from now
106
107
  lizard sandbox cpu <id> # the CPU model it runs on, e.g. AMD EPYC 7351P 16-Core Processor
107
- lizard sandbox pause <id> --fast # stop billing, keep files (~1 s); `resume <id>` brings it back
108
+ lizard sandbox pause <id> # stop billing, keep files (~1 s); `resume <id>` brings it back (--full: keep processes too)
108
109
  lizard sandbox rm <id> # delete it now (alias kill): no prompt without a terminal
109
110
  ```
110
111
 
@@ -117,7 +118,7 @@ lizard sandbox rm <id> # delete it now (alias
117
118
  - **Commands:** `exec <id> -- <cmd> [args…]` passes each argument as one word, so a whole shell line in one quoted string fails with `not found`: wrap it, `-- sh -c 'cd /workspace && npm test'`. Each call is a new process that starts in `/root`, gives up after 150 seconds (exit `4`, `EXEC_TIMEOUT`; the command may still be running) and keeps at most 512 KB of output. Run longer jobs in the background and poll a log: `-- sh -c 'cd /workspace && nohup npm run build > build.log 2>&1 &'`, then `-- tail -n 50 /workspace/build.log`. `ssh` needs a real terminal: from an agent, use `exec`.
118
119
  - **Ports:** `lizard sandbox expose <id> <port> --json` gives `url` with `?lizard_token=…`, which works in a browser: it swaps the token for a cookie and redirects. `curl -L` without a cookie jar gets `401`; from a script send the token as a header instead: `curl -H "X-Lizard-Access-Token: <accessToken>" https://<hostname>/`. The token opens every port of that sandbox: treat the URL like a password. Start the server in the background (as above) so `exec` returns.
119
120
  - **Keeping work:** files outlive a sandbox on a volume (`--volume <name>`) or in a snapshot.
120
- - **Pausing:** prefer `pause --fast`. It stops billing in about a second at any memory size and keeps every file; running processes end, and `resume` boots the sandbox fresh. Use plain `pause` (memory and processes kept, slower the more RAM is in use) only when something running must survive: a dev server you don't want to restart, a REPL or notebook with state, a local cluster, an agent mid-task. `resume <id>` is the same for both.
121
+ - **Pausing:** plain `pause` stops billing in about a second at any memory size and keeps every file; running processes end, and `resume` boots the sandbox fresh. Use `pause --full` (memory and processes kept, slower the more RAM is in use) only when something running must survive: a dev server you don't want to restart, a REPL or notebook with state, a local cluster, an agent mid-task. `resume <id>` is the same for both.
121
122
  - **Copies:** `lizard sandbox fork <id> -n 8 --json` starts live copies of a running sandbox (memory, processes, files) from one capture, e.g. a worker that has its tools installed and its app loaded. Each copy is a sandbox start: it counts toward the limits and bills at the source's size. The JSON has one entry per copy, `sandbox` or `error`; the command exits `1` if any copy failed, so delete the ones that started.
122
123
  - **Network:** outbound internet works (mail ports are blocked), but Lizard's own hosts answer only on ports 80 and 443, so a managed Postgres or Redis URL cannot be reached from a sandbox. Work with those databases from a deployed service, or from the user's machine with `lizard run --service postgres -- <cmd>`.
123
124
  - **Agents in a sandbox:** `lizard sandbox create -t codex --timeout 3600000`, then `lizard sandbox prompt <id> "task" --json`. Give it a real lifetime: at 5 minutes the sandbox and the agent are deleted mid-task.
@@ -296,6 +297,25 @@ Skip command-by-command transcripts unless they explain a failure.
296
297
  5. Don't generate Dockerfiles unsolicited — lizardpack auto-detects most stacks. Try a deploy first; write one only if it fails. Ask before either.
297
298
  6. Don't put runtime secrets (DB credentials, API keys, RPC creds, S3 keys) in `--global` "just in case another service needs it later". Scope to the services that consume them — see [Secrets and config](#secrets-and-config).
298
299
 
300
+ ## Support
301
+
302
+ `lizard support` sends a ticket to the Lizard team (a person reads it within minutes in working hours). When to open one:
303
+
304
+ - **Bug, open it yourself without asking** (it describes Lizard's failure, not the user's code) when Lizard fails: the same command fails twice with a 5xx, a timeout or `internal error`; a sandbox, app or database is stuck (`creating`, `pausing`, `deploying` for minutes) or crashed with no cause in its own logs; a documented command behaves differently from this guide. Failed commands print a hint on stderr (`support` in the JSON error) when this applies.
305
+ - **Limits or billing, ask the user first** (it asks the team for more on their behalf): a plan or limit blocks what the user is doing and they need more, such as vCPU or sandbox limits, a region or size their plan does not include, rate limits, a bigger plan. With their OK, use `--type limits` (or `billing`) and say what is needed and why (numbers, for how long).
306
+
307
+ ```sh
308
+ lizard support open "sandbox create in eu-west-lim-a returns 500" --expected "sandbox running" --actual "500 internal error, 3 tries since 17:40" --sandbox <id> --json
309
+ lizard support open "need 100 vCPU of sandboxes for a batch job next week; trial allows 8" --type limits --json
310
+ lizard support list --json # tickets, status, unread replies
311
+ lizard support show T-1043 --json # the whole thread; marks replies read
312
+ lizard support reply T-1043 "request id r_8f2…, still failing at 18:05" --json
313
+ ```
314
+
315
+ Write the ticket like a bug report: what you ran, what happened (the exact error), what you expected, since when. Your last failed Lizard calls, CLI version and OS are attached automatically; `--sandbox` / `--app` attach that resource's state. Never put secrets, keys or customer data in a ticket. Types: `bug` (default), `limits`, `billing`, `question`. Filing the same problem again does not open a new ticket: the answer has `similarId` (the open ticket) and `similarCount`; add details there with `lizard support reply`. At most 5 new tickets an hour. `AGENT_SUPPORT=0` in the environment means the user turned agent tickets off: don't open any.
316
+
317
+ After opening one, tell the user the ticket id and continue with whatever does not depend on the fix. Replies from the team are printed on stderr after your next `lizard` command (`📬 Lizard support replied on T-1043`) and emailed to the account owner. When support asks a question, answer with `lizard support reply` and tell the user what was asked. Don't open tickets for the user's own build errors, app bugs or wrong commands.
318
+
299
319
  ## Billing
300
320
 
301
321
  Billing belongs to the account owner. `lizard billing --workspace <id> --json` shows the plan of another workspace's owner.
@@ -354,7 +374,8 @@ and `body.status` with the links:
354
374
  vCPU of sandboxes at once, or too many starts per minute, hour or day, is HTTP 429,
355
375
  not a billing problem. `SANDBOX_LIMIT_REACHED` has `unit: "vcpu"`, `limit`, `running` (vCPU in use)
356
376
  and `needed` (vCPU the new sandbox needs): pause or delete idle sandboxes, pick a
357
- smaller size, or ask the user about a higher Pro tier. `SANDBOX_RATE_LIMITED` has
377
+ smaller size, or ask the user about a higher Pro tier; if the task needs more than any tier
378
+ gives, open a `lizard support open … --type limits` ticket. `SANDBOX_RATE_LIMITED` has
358
379
  `retryAfterS`: wait that long; on the trial, the first paid invoice lifts the start
359
380
  limits. A workspace can also have its own limits, set by its owner
360
381
  (`lizard workspace limits <ws>` shows them with current use): `WORKSPACE_SANDBOX_LIMIT`
@@ -167,10 +167,10 @@ A volume attaches to one sandbox at a time (409 `Volume is already attached to a
167
167
 
168
168
  ## Snapshots and pause/resume
169
169
 
170
- - `lizard sandbox snapshot <sandbox-id> --name my-app` saves files and running memory. You and the members of its project can list, restore and delete it; only you change its scope. By default it restores into any of your projects and workspaces; `--scope workspace` keeps it to the sandbox's workspace and `--scope project` to its project, and `sandbox snapshot-scope <id> <user|workspace|project>` changes that later. A Firecracker snapshot is ready as soon as the capture ends; the command waits until ready; `--no-wait` returns the queued capture.
170
+ - `lizard sandbox snapshot <sandbox-id> --name my-app` saves the sandbox's files (about a second whatever its RAM); sandboxes started from it boot fresh with them. `--full` (API `{"full": true}` / `{"memory": true}`) also saves memory and running processes, so new sandboxes continue where it was (a warmed-up REPL, a started server); it takes longer the more RAM is in use. The answer says what was kept (`withMemory`); where a files-only snapshot is not available yet it is taken with memory and says so in `fastSnapshotUnavailable`. You and the members of its project can list, restore and delete it; only you change its scope. By default it restores into any of your projects and workspaces; `--scope workspace` keeps it to the sandbox's workspace and `--scope project` to its project, and `sandbox snapshot-scope <id> <user|workspace|project>` changes that later. A Firecracker snapshot is ready as soon as the capture ends; the command waits until ready; `--no-wait` returns the queued capture.
171
171
  - `lizard sandbox restore <snapshot-id> [--project <project>] [--timeout <ms>]` starts a new sandbox from it (five-minute lifetime by default), in the snapshot's project unless `--project` names another. `--volume <volume>` mounts a volume at `/workspace` in the restored sandbox (Firecracker snapshots of a sandbox that had no volume attached; the volume must be in the snapshot's region). `sandbox create --snapshot <id> --project <project> [--volume <volume>]` also works. Restores stay in the snapshot's region. A snapshot restores at its source's size and bills flat at that size. `--size` with `--snapshot` is an error.
172
172
  - `lizard sandbox snapshots --project <project>` lists a project's snapshots; `--mine` lists every snapshot you took. `sandbox snapshot-rm <id>` deletes the snapshot; sandboxes already started from it keep running.
173
173
  - `lizard sandbox fork <sandbox-id> [-n <count>] [--timeout <ms>] --json` starts 1–100 live copies of a running sandbox: the platform pauses it for a moment, captures memory, processes and files once, and boots every copy from that capture; the source keeps its id and lifetime. Use it to fan out work from one prepared sandbox (tools installed, app loaded) without repeating the setup. Each copy is a sandbox start: it counts toward the running and start limits, runs at the source's size and bills like a new sandbox. The JSON is one entry per copy, `{ "sandbox": {…} }` or `{ "error": "…" }` (for example `Sandbox limit reached`); if any copy failed the command exits `1`, and the copies that did start keep running until you delete them. `--timeout` takes at least `1000`; leave it out to keep the source's lifetime. A sandbox with a volume attached can't be forked (409), and `fork` needs a running sandbox (409 for a paused one).
174
- - Prefer `lizard sandbox pause <id> --fast` (API `{"fast": true}`, SDK `pause({ fast: true })` / `pause(fast=True)`): it saves files only, stops billing in about a second whatever the sandbox's RAM, ends running processes, and `sandbox resume <id>` boots the sandbox fresh with its files (`memoryRestored: false` in the resume JSON). Use it whenever nothing running needs to survive (finished task, idle sandbox, files are what matter), and always for a `large` sandbox unless its processes must survive.
175
- - Plain `lizard sandbox pause <id>` also saves memory and processes, so it takes longer the more RAM is in use (minutes for a large sandbox that filled its memory). Use it only to come back to running processes: a dev server you don't want to restart, a REPL or notebook with state, an agent mid-task. Either pause stops billing and freezes the remaining lifetime; `sandbox resume <id>` restores the same sandbox ID, files, published ports and remaining lifetime (and, after a plain pause, processes and memory). Both support `--no-wait`. When the pause answer (and `--json` output) carries `tip`, a faster option fits: follow it next time.
174
+ - `lizard sandbox pause <id>` (API `POST /api/sandboxes/<id>/pause` with no body) saves files only: it stops billing in about a second whatever the sandbox's RAM, ends running processes, and `sandbox resume <id>` boots the sandbox fresh with its files (`memoryRestored: false` in the resume JSON). Use it whenever nothing running needs to survive (finished task, idle sandbox, files are what matter). `--fast` (API `{"fast": true}`, SDK `pause({ fast: true })` / `pause(fast=True)`) is the same pause. Where a fast pause isn't possible (an older sandbox, some regions) either one keeps memory instead and says so in `fastPauseUnavailable`.
175
+ - `lizard sandbox pause <id> --full` (API `{"full": true}` or `{"memory": true}`, SDK `pause({ full: true })` / `pause(full=True)`) also saves memory and processes, so it takes longer the more RAM is in use (minutes for a large sandbox that filled its memory). Use it only to come back to running processes: a dev server you don't want to restart, a REPL or notebook with state, an agent mid-task. Either pause stops billing and freezes the remaining lifetime; `sandbox resume <id>` restores the same sandbox ID, files, published ports and remaining lifetime (and, after `--full`, processes and memory). The pause JSON says what was kept (`pausedWithMemory`). Both support `--no-wait`. When the pause answer (and `--json` output) carries `tip`, a faster option fits: follow it next time.
176
176
  - Disconnect clients and terminals and stop workspace writes before capturing or pausing. To reuse one snapshot across sandboxes that each keep their own data, snapshot a sandbox with no volume attached and pass `--volume` on each restore; a snapshot taken with a volume attached cannot take a different one.
@@ -598,33 +598,55 @@ Examples:
598
598
  .addOption(new Option("--scope <scope>", "Where it may be restored: user = any of your projects and workspaces, workspace = only this workspace, project = only this project. Default: user, or with a workspace/project-scoped key only what the key covers")
599
599
  .choices(SNAPSHOT_SCOPES))
600
600
  .option("--no-wait", "Return once capture is queued")
601
- .description("Save a running sandbox, memory included")
601
+ // Files only by default (the platform's): about a second whatever the RAM, sandboxes started
602
+ // from it boot fresh. --full keeps memory and processes too. Sent as memory: true/false, which
603
+ // servers older than the "full" name accept; no flag = the platform's default.
604
+ .option("--full", "Also save memory and running processes: sandboxes started from it continue where this one was (slower to take)")
605
+ .option("--fast", "Files only (the default)")
606
+ .description("Save a running sandbox's files (--full: also its memory and running processes)")
602
607
  .action(async (id: string, opts) => {
608
+ if (opts.full && opts.fast) throw new Error("Use either --full or --fast, not both");
603
609
  // No pool size: Firecracker and gVisor snapshots keep no warm copies, and a runc pod
604
610
  // (the fallback when a Firecracker create fails) gets the server's default.
605
- let snapshot = await api.post<SnapshotRecord>(`/api/sandboxes/${id}/snapshot`, { name: opts.name, scope: opts.scope });
606
- if (opts.wait) snapshot = await waitForSnapshot(snapshot.id);
607
- if (isJSONMode()) printJSON(snapshot);
608
- else success(`Snapshot ${chalk.bold(snapshot.id)}: ${snapshot.status}`);
611
+ const choice = opts.full ? { memory: true } : opts.fast ? { memory: false } : {};
612
+ const taken = await api.post<SnapshotRecord & { withMemory?: boolean; fastSnapshotUnavailable?: string }>(`/api/sandboxes/${id}/snapshot`, { name: opts.name, scope: opts.scope, ...choice });
613
+ let snapshot: SnapshotRecord = taken;
614
+ if (opts.wait) snapshot = await waitForSnapshot(taken.id);
615
+ if (isJSONMode()) printJSON({ ...snapshot, ...(taken.withMemory !== undefined ? { withMemory: taken.withMemory } : {}), ...(taken.fastSnapshotUnavailable ? { fastSnapshotUnavailable: taken.fastSnapshotUnavailable } : {}) });
616
+ else {
617
+ success(`Snapshot ${chalk.bold(snapshot.id)}: ${snapshot.status}${taken.withMemory === true ? " (with memory)" : taken.withMemory === false ? " (files only)" : ""}`);
618
+ if (taken.withMemory === false) info(`Sandboxes started from it boot fresh with these files (use ${chalk.bold("--full")} to keep running processes).`);
619
+ if (taken.fastSnapshotUnavailable) info(taken.fastSnapshotUnavailable + ".");
620
+ }
609
621
  });
610
622
 
611
623
  for (const operation of ["pause", "resume"] as const) {
612
624
  const cmd = sb.command(operation)
613
625
  .argument("<id>", "Sandbox ID")
614
626
  .option("--no-wait", "Return once the operation is queued");
615
- // --fast: no memory saved, so the pause takes about a second whatever the RAM; the resume boots fresh.
616
- if (operation === "pause") cmd.option("--fast", "Pause instantly: keep files only, end processes (no memory saved)");
627
+ // Two kinds of pause. Fast (files only, about a second whatever the RAM; processes end and the
628
+ // resume boots fresh) is the platform's default. --full keeps memory and running processes.
629
+ // Neither flag sends no choice, so the platform's default applies. --full sends {"memory": true}
630
+ // (not "full") so it also works against servers older than the "full" name.
631
+ if (operation === "pause") {
632
+ cmd.option("--full", "Keep memory and running processes too (slower pause, resume picks up where it left off)");
633
+ cmd.option("--fast", "Same as a plain pause: keep files only and end processes");
634
+ }
617
635
  cmd
618
- .description(operation === "pause" ? "Save running state (memory and files) and stop the sandbox" : "Restore a paused sandbox with its saved memory and files")
636
+ .description(operation === "pause" ? "Pause the sandbox: keeps its files (--full: also its memory and running processes)" : "Restore a paused sandbox with its saved files (and memory, if paused with --full)")
619
637
  .action(async (id: string, opts) => {
620
- const fast = operation === "pause" && !!opts.fast;
621
- const queued = await api.post<{ id: string; status: string; snapshotId?: string; memoryRestored?: boolean; tip?: string }>(`/api/sandboxes/${id}/${operation}`, fast ? { memory: false } : {});
638
+ if (operation === "pause" && opts.full && opts.fast) throw new Error("Use either --full or --fast, not both");
639
+ const choice = operation !== "pause" ? {} : opts.full ? { memory: true } : opts.fast ? { memory: false } : {};
640
+ const queued = await api.post<{ id: string; status: string; snapshotId?: string; memoryRestored?: boolean; pausedWithMemory?: boolean; fastPauseUnavailable?: string; tip?: string }>(`/api/sandboxes/${id}/${operation}`, choice);
622
641
  if (opts.wait && operation === 'pause' && queued.snapshotId) await waitForSnapshot(queued.snapshotId);
623
642
  const result = opts.wait ? await waitForSandbox(id, operation === "pause" ? "paused" : "running") : queued;
624
- if (isJSONMode()) printJSON({ ...result, ...(operation === "resume" && queued.memoryRestored !== undefined ? { memoryRestored: queued.memoryRestored } : {}), ...(queued.tip ? { tip: queued.tip } : {}) });
643
+ // What the pause actually kept: the answer says (the default is the platform's to choose).
644
+ const filesOnly = operation === "pause" && (queued.pausedWithMemory === false || (queued.pausedWithMemory === undefined && !!opts.fast));
645
+ if (isJSONMode()) printJSON({ ...result, ...(operation === "resume" && queued.memoryRestored !== undefined ? { memoryRestored: queued.memoryRestored } : {}), ...(operation === "pause" && queued.pausedWithMemory !== undefined ? { pausedWithMemory: queued.pausedWithMemory } : {}), ...(queued.fastPauseUnavailable ? { fastPauseUnavailable: queued.fastPauseUnavailable } : {}), ...(queued.tip ? { tip: queued.tip } : {}) });
625
646
  else {
626
- success(`Sandbox ${chalk.bold(id)}: ${result.status}${fast ? " (files only)" : ""}`);
627
- if (fast) info("Processes ended. Resume boots it fresh with your files intact.");
647
+ success(`Sandbox ${chalk.bold(id)}: ${result.status}${filesOnly ? " (files only)" : operation === "pause" && queued.pausedWithMemory === true ? " (with memory)" : ""}`);
648
+ if (filesOnly) info(`Processes ended. Resume boots it fresh with your files intact (use ${chalk.bold("--full")} to keep running processes).`);
649
+ if (queued.fastPauseUnavailable) info(`Kept memory: ${queued.fastPauseUnavailable.replace(/; paused with memory instead$/, "")}.`);
628
650
  // The server says when a faster option fits (a large sandbox paused with its memory).
629
651
  if (queued.tip) info(`Tip: ${queued.tip.replace('{"fast": true} (CLI: pause --fast)', chalk.bold(`lizard sandbox pause ${id} --fast`))}`);
630
652
  if (operation === "resume" && queued.memoryRestored === false) info("It was paused without memory: booted fresh with its files; start your processes again.");
@@ -0,0 +1,103 @@
1
+ import chalk from "chalk";
2
+ import { Command, Option } from "commander";
3
+ import { api } from "../lib/api.js";
4
+ import { getProjectLink } from "../lib/config.js";
5
+ import { fail, isJSONMode, printJSON, table, timeAgo } from "../lib/format.js";
6
+ import { agentName, ticketContext } from "../lib/support.js";
7
+
8
+ /** AGENT_SUPPORT=0 turns off agent-opened tickets on this machine (support.md proposal 4.4). A person
9
+ * typing the command is not an agent, so it still works for them. */
10
+ function agentSupportOff(): boolean {
11
+ return process.env.AGENT_SUPPORT === "0" && !!agentName();
12
+ }
13
+
14
+ interface TicketView { id: string; type: string; subject: string; status: string; source: string; createdAt: string; updatedAt: string; unread: number }
15
+
16
+ const TYPES = ["bug", "limits", "billing", "question"];
17
+
18
+ function joinMessage(words: string[]): string {
19
+ const m = words.join(" ").trim();
20
+ if (!m) fail("Write what happened, e.g. lizard support open \"sandbox create in eu returns 500 since 10:00\"", 1, "MISSING_MESSAGE");
21
+ return m;
22
+ }
23
+
24
+ export function registerSupport(program: Command) {
25
+ const support = program
26
+ .command("support")
27
+ .description("Tickets to the Lizard team: something on Lizard is broken, or you need higher limits / a bigger plan. Replies appear after your next lizard command.");
28
+
29
+ support
30
+ .command("open")
31
+ .description("Open a ticket. Your last failed Lizard calls, CLI version and OS are attached automatically.")
32
+ .argument("<message...>", "What you did, what happened, what you expected")
33
+ .addOption(new Option("-t, --type <type>", "bug | limits | billing | question").choices(TYPES).default("bug"))
34
+ .option("--sandbox <id>", "The sandbox this is about (its state is attached)")
35
+ .option("--app <name-or-id>", "The app this is about (its state is attached)")
36
+ .option("--expected <text>", "What should have happened")
37
+ .option("--actual <text>", "What happened instead (the exact error)")
38
+ .option("--repro <text>", "Shortest steps or commands that show it")
39
+ .action(async (words: string[], opts: { type: string; sandbox?: string; app?: string; expected?: string; actual?: string; repro?: string }) => {
40
+ if (agentSupportOff()) fail("Agent support tickets are turned off on this machine (AGENT_SUPPORT=0). Tell the user what failed instead.", 1, "AGENT_SUPPORT_OFF");
41
+ const message = joinMessage(words);
42
+ const link = getProjectLink();
43
+ const res = await api.post<TicketView & { similarId?: string; similarCount?: number; note?: string }>("/api/support/tickets", {
44
+ message,
45
+ type: opts.type,
46
+ source: "cli",
47
+ agent: agentName(),
48
+ sandboxId: opts.sandbox,
49
+ appId: opts.app,
50
+ expected: opts.expected,
51
+ actual: opts.actual,
52
+ repro: opts.repro,
53
+ workspaceId: link?.workspaceId ?? undefined,
54
+ context: ticketContext(),
55
+ });
56
+ if (isJSONMode()) return printJSON(res);
57
+ console.log(chalk.green("✓") + ` ${res.similarId ? "Already open as" : "Opened"} ${chalk.bold(res.id)} — ${res.subject}`);
58
+ if (res.note) console.log(chalk.dim(res.note));
59
+ });
60
+
61
+ support
62
+ .command("list")
63
+ .alias("ls")
64
+ .description("Your tickets, newest activity first")
65
+ .action(async () => {
66
+ const { tickets } = await api.get<{ tickets: TicketView[] }>("/api/support/tickets");
67
+ if (isJSONMode()) return printJSON(tickets);
68
+ if (!tickets.length) return console.log("No tickets.");
69
+ table(["Ticket", "Type", "Status", "Updated", "Subject"], tickets.map((t) => [
70
+ t.unread ? chalk.green(`${t.id} •${t.unread} new`) : t.id, t.type, t.status, timeAgo(t.updatedAt), t.subject,
71
+ ]));
72
+ });
73
+
74
+ support
75
+ .command("show")
76
+ .description("A ticket with every message; marks support's replies as read")
77
+ .argument("<ticket>", "Ticket id, e.g. T-1043")
78
+ .action(async (ref: string) => {
79
+ const t = await api.get<TicketView & { messages: Array<{ from: string; body: string; at: string }> }>(
80
+ `/api/support/tickets/${encodeURIComponent(ref)}`);
81
+ if (isJSONMode()) return printJSON(t);
82
+ console.log(chalk.bold(`${t.id} · ${t.type} · ${t.status}`) + chalk.dim(` opened ${timeAgo(t.createdAt)}`));
83
+ for (const m of t.messages) {
84
+ console.log("");
85
+ console.log((m.from === "you" ? chalk.cyan(m.from) : chalk.green(m.from)) + chalk.dim(` ${timeAgo(m.at)}`));
86
+ console.log(m.body);
87
+ }
88
+ console.log("");
89
+ console.log(chalk.dim(`Answer: lizard support reply ${t.id} "…"`));
90
+ });
91
+
92
+ support
93
+ .command("reply")
94
+ .description("Add to a ticket: answer support's question, or add new details")
95
+ .argument("<ticket>", "Ticket id, e.g. T-1043")
96
+ .argument("<message...>", "Your answer")
97
+ .action(async (ref: string, words: string[]) => {
98
+ const res = await api.post<{ ok: boolean; ticket: string }>(
99
+ `/api/support/tickets/${encodeURIComponent(ref)}/messages`, { message: joinMessage(words) });
100
+ if (isJSONMode()) return printJSON(res);
101
+ console.log(chalk.green("✓") + ` Sent to the Lizard team on ${res.ticket}`);
102
+ });
103
+ }
package/src/index.ts CHANGED
@@ -4,7 +4,7 @@ import { Command } from "commander";
4
4
  import chalk from "chalk";
5
5
  import { setJSONMode, isJSONMode, error } from "./lib/format.js";
6
6
  import { requireAuth, isLoggedIn } from "./lib/auth.js";
7
- import { setBaseURL, setAccessToken, APIError, isProjectDeletedError, isAccountScopeError } from "./lib/api.js";
7
+ import { api, getRequestToken, setBaseURL, setAccessToken, APIError, isProjectDeletedError, isAccountScopeError } from "./lib/api.js";
8
8
  import { checkForUpdateInBackground, runBackgroundUpdate, CURRENT_VERSION } from "./lib/updater.js";
9
9
 
10
10
  const BANNER = chalk.rgb(16, 185, 129)(
@@ -102,6 +102,8 @@ import { registerUp } from "./commands/up.js";
102
102
  import { registerUpgrade } from "./commands/upgrade.js";
103
103
  import { registerVolume } from "./commands/volume.js";
104
104
  import { registerWhoami } from "./commands/whoami.js";
105
+ import { registerSupport } from "./commands/support.js";
106
+ import { printSupportInbox, isPlatformFailure, SUPPORT_HINT } from "./lib/support.js";
105
107
  import { registerWorkspace } from "./commands/workspace.js";
106
108
 
107
109
  const program = new Command();
@@ -197,6 +199,7 @@ registerSleep(program);
197
199
  registerSecrets(program);
198
200
  registerService(program);
199
201
  registerSkill(program);
202
+ registerSupport(program);
200
203
  registerSSH(program);
201
204
  registerStatus(program);
202
205
  registerUnlink(program);
@@ -342,6 +345,16 @@ function writeAndExit(payload: string, code: number): void {
342
345
  process.stdout.write(payload, () => process.exit(code));
343
346
  }
344
347
 
348
+ /** Support replies not seen yet, on stderr after the command (lib/support.ts). Skipped when not
349
+ * signed in and for `lizard support show`, which prints the thread itself. */
350
+ async function supportInbox(): Promise<void> {
351
+ const args = process.argv.slice(2).filter((a) => !a.startsWith("-"));
352
+ if (args[0] === "support" && args[1] === "show") return;
353
+ if (["login", "logout", "upgrade", "help", "docs", "skills"].includes(args[0] ?? "")) return;
354
+ if (!getRequestToken()) return;
355
+ await printSupportInbox(() => api.get("/api/support/unread"));
356
+ }
357
+
345
358
  async function main() {
346
359
  // Hidden entry point: detached child spawned by checkForUpdateInBackground.
347
360
  // Handled before commander so it never shows up in help or telemetry.
@@ -414,6 +427,7 @@ async function main() {
414
427
 
415
428
  try {
416
429
  await program.parseAsync(process.argv);
430
+ await supportInbox();
417
431
  } catch (err: any) {
418
432
  // Commander throws for --help, --version, etc. — ignore those
419
433
  if (err.code === "commander.helpDisplayed" || err.code === "commander.version") {
@@ -494,6 +508,8 @@ async function main() {
494
508
  netCode === "UND_ERR_CONNECT_TIMEOUT";
495
509
 
496
510
  const exitCode = isAuth ? 2 : isNotFound ? 3 : isTimeout ? 4 : 1;
511
+ // Lizard itself failed (5xx, timeout, network): point the agent at a ticket.
512
+ const showSupportHint = isPlatformFailure(status, netCode) && !process.argv.slice(2).includes("support");
497
513
 
498
514
  if (isJSONMode()) {
499
515
  // Through writeAndExit, not console.log + exit: `body` carries the raw
@@ -506,6 +522,7 @@ async function main() {
506
522
  status: status ?? null,
507
523
  message: msg,
508
524
  body: apiErr?.body ?? null,
525
+ ...(showSupportHint ? { support: SUPPORT_HINT } : {}),
509
526
  },
510
527
  },
511
528
  null,
@@ -517,6 +534,8 @@ async function main() {
517
534
  }
518
535
 
519
536
  error(msg);
537
+ if (showSupportHint) process.stderr.write(chalk.dim(SUPPORT_HINT) + "\n");
538
+ await supportInbox();
520
539
  if (status === 401) {
521
540
  process.stderr.write("Run `lizard login` to re-authenticate.\n");
522
541
  }
package/src/lib/api.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { getToken } from "./auth.js";
2
2
  import { CURRENT_VERSION } from "./updater.js";
3
3
  import { detectAgent } from "./agent.js";
4
+ import { recordFailedCall } from "./support.js";
4
5
  import * as https from "node:https";
5
6
  import * as http from "node:http";
6
7
 
@@ -226,14 +227,23 @@ async function request<T = any>(
226
227
  }
227
228
 
228
229
  const init = { method, headers, body: body !== undefined ? JSON.stringify(body) : undefined };
229
- const res = method === "GET" ? await fetchWithRetry(url, init) : await fetch(url, init);
230
+ let res: Response;
231
+ try {
232
+ res = method === "GET" ? await fetchWithRetry(url, init) : await fetch(url, init);
233
+ } catch (e: any) {
234
+ // Kept for `lizard support open`, which attaches the last failures to a ticket.
235
+ recordFailedCall(method, path, e?.cause?.code ?? e?.code ?? "network", e?.cause?.message ?? e?.message ?? String(e));
236
+ throw e;
237
+ }
230
238
 
231
239
  if (!res.ok) {
232
240
  let body: unknown = null;
233
241
  try {
234
242
  body = await res.json();
235
243
  } catch {}
236
- throw apiErrorFrom(res.status, res.statusText, body);
244
+ const err = apiErrorFrom(res.status, res.statusText, body);
245
+ recordFailedCall(method, path, res.status, err.message, res.headers.get("x-request-id"));
246
+ throw err;
237
247
  }
238
248
 
239
249
  const text = await res.text();
package/src/lib/config.ts CHANGED
@@ -7,7 +7,7 @@ export const DEFAULT_REGION = "us-east-1";
7
7
  // Resolve at every call so tests (and exotic shells that mutate HOME) get a
8
8
  // fresh path. Cost is negligible — we hit disk anyway. LIZARD_HOME lets tests
9
9
  // (and power users) point the config dir somewhere other than ~/.lizard.
10
- function configDir(): string {
10
+ export function configDir(): string {
11
11
  return process.env.LIZARD_HOME
12
12
  ? path.join(process.env.LIZARD_HOME, ".lizard")
13
13
  : path.join(os.homedir(), ".lizard");