@inquir/compute-cli 0.4.0 → 0.4.2

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.
Files changed (61) hide show
  1. package/README.md +667 -619
  2. package/dist/commands/admin.d.ts.map +1 -1
  3. package/dist/commands/admin.js +7 -5
  4. package/dist/commands/admin.js.map +1 -1
  5. package/dist/commands/apps-describe.d.ts.map +1 -1
  6. package/dist/commands/apps-describe.js +8 -1
  7. package/dist/commands/apps-describe.js.map +1 -1
  8. package/dist/commands/apps-instances.d.ts +18 -0
  9. package/dist/commands/apps-instances.d.ts.map +1 -0
  10. package/dist/commands/apps-instances.js +87 -0
  11. package/dist/commands/apps-instances.js.map +1 -0
  12. package/dist/commands/apps-observability.d.ts +6 -0
  13. package/dist/commands/apps-observability.d.ts.map +1 -1
  14. package/dist/commands/apps-observability.js +38 -9
  15. package/dist/commands/apps-observability.js.map +1 -1
  16. package/dist/commands/apps.d.ts +108 -5
  17. package/dist/commands/apps.d.ts.map +1 -1
  18. package/dist/commands/apps.js +681 -67
  19. package/dist/commands/apps.js.map +1 -1
  20. package/dist/commands/deploy.d.ts +13 -0
  21. package/dist/commands/deploy.d.ts.map +1 -1
  22. package/dist/commands/deploy.js +80 -8
  23. package/dist/commands/deploy.js.map +1 -1
  24. package/dist/commands/functions.d.ts +7 -0
  25. package/dist/commands/functions.d.ts.map +1 -0
  26. package/dist/commands/functions.js +80 -0
  27. package/dist/commands/functions.js.map +1 -0
  28. package/dist/commands/init.d.ts.map +1 -1
  29. package/dist/commands/init.js +21 -16
  30. package/dist/commands/init.js.map +1 -1
  31. package/dist/index.js +3 -0
  32. package/dist/index.js.map +1 -1
  33. package/dist/utils/api.d.ts +34 -12
  34. package/dist/utils/api.d.ts.map +1 -1
  35. package/dist/utils/api.js +41 -5
  36. package/dist/utils/api.js.map +1 -1
  37. package/dist/utils/apps-presentation.d.ts +7 -0
  38. package/dist/utils/apps-presentation.d.ts.map +1 -1
  39. package/dist/utils/apps-presentation.js +25 -1
  40. package/dist/utils/apps-presentation.js.map +1 -1
  41. package/dist/utils/errors.d.ts.map +1 -1
  42. package/dist/utils/errors.js +41 -0
  43. package/dist/utils/errors.js.map +1 -1
  44. package/dist/utils/msys-path.d.ts +14 -0
  45. package/dist/utils/msys-path.d.ts.map +1 -0
  46. package/dist/utils/msys-path.js +55 -0
  47. package/dist/utils/msys-path.js.map +1 -0
  48. package/dist/utils/package-metadata.d.ts +6 -0
  49. package/dist/utils/package-metadata.d.ts.map +1 -1
  50. package/dist/utils/package-metadata.js +9 -1
  51. package/dist/utils/package-metadata.js.map +1 -1
  52. package/dist/utils/source-pack.d.ts +24 -0
  53. package/dist/utils/source-pack.d.ts.map +1 -0
  54. package/dist/utils/source-pack.js +63 -0
  55. package/dist/utils/source-pack.js.map +1 -0
  56. package/dist/utils/system-config.d.ts +9 -0
  57. package/dist/utils/system-config.d.ts.map +1 -0
  58. package/dist/utils/system-config.js +48 -0
  59. package/dist/utils/system-config.js.map +1 -0
  60. package/package.json +34 -34
  61. package/skill/SKILL.md +73 -73
package/README.md CHANGED
@@ -1,619 +1,667 @@
1
- # @inquir/compute-cli
2
-
3
- CLI for workspace-first Inquir Compute development.
4
-
5
- ## Install
6
-
7
- Global (recommended). `@latest` also upgrades an existing install to the newest
8
- published version:
9
-
10
- ```bash
11
- npm install -g @inquir/compute-cli@latest
12
- ```
13
-
14
- Verify it's on your `PATH`:
15
-
16
- ```bash
17
- inquir --version
18
- inquir --help
19
- ```
20
-
21
- Or run without installing:
22
-
23
- ```bash
24
- npx @inquir/compute-cli@latest --help
25
- ```
26
-
27
- > Requires **Node.js 22+**. To upgrade later, re-run the install command above. On
28
- > macOS/Linux you may need `sudo` for a global install, or use a Node version
29
- > manager (nvm/fnm) to avoid it. To remove: `npm uninstall -g @inquir/compute-cli`.
30
-
31
- ## Concepts
32
-
33
- - **Function**: a single compute unit with typed input/output (Zod schemas). Defined with `defineFunction()`. Run locally with `inquir run`, deployed and invoked remotely with `inquir deploy` / `inquir invoke`.
34
- - **Pipeline**: a declarative DAG of functions defined with `definePipeline()`. Registered in the codegen registry for client use; remote run/deploy for pipelines is handled by the backend.
35
- - **Client**: the generated TypeScript module at `.inquir/generated/client.ts`. Wraps remote invocation with schemas inferred from your source. Import it in your application code.
36
- - **Source of truth**: your local files under `functionsDir` and `pipelinesDir`. `registry.json` is a derived artifact rebuilt by `inquir codegen` — never hand-edit it.
37
- - **Local ↔ remote link**: each deployed remote function stores a `linkedLocalName` (your local asset name) and a `sourceHash`. `inquir sync status` compares hashes to detect drift.
38
-
39
- ## Quick Start
40
-
41
- ```bash
42
- inquir init
43
- inquir codegen
44
- inquir list
45
- inquir run hello --payload '{"name":"World"}'
46
- ```
47
-
48
- ## Authentication
49
-
50
- The recommended way to authenticate on your own machine is a browser login,
51
- which mints a user-scoped **Personal Access Token** (PAT) bound to your account
52
- and stores it in `~/.inquir/config.json`:
53
-
54
- ```bash
55
- inquir login # opens your browser to approve this device
56
- inquir whoami # show the signed-in user + active workspace
57
- ```
58
-
59
- `inquir login` prints a short code and opens a dashboard page; confirm the code
60
- matches and click **Authorize**. The CLI then receives its token automatically.
61
- Browser-issued CLI sessions expire (90 days by default; the server can configure
62
- a shorter lifetime). The CLI records the issuing API and expiry with the token.
63
- Logging in again saves the new session before revoking the previous session owned
64
- by that profile, unless another stored profile or environment variable still uses it.
65
-
66
- Other login modes:
67
-
68
- ```bash
69
- inquir login --browserless # print the URL + code instead of opening a browser
70
- inquir login --token <pat> # non-interactive (CI): use a PAT created in the dashboard
71
- inquir login --name "my CI" # label the device/token shown in the dashboard
72
- ```
73
-
74
- Login stores the API URL together with the token. To keep credentials for another
75
- API separately, use a named environment:
76
-
77
- ```bash
78
- inquir login --env staging --api-url https://staging.example.com --token <pat>
79
- inquir whoami --env staging
80
- ```
81
-
82
- Changing a login's API or token clears its cached identity and workspace until
83
- membership discovery succeeds. A previous workspace on the same API is restored
84
- only if the new token can still access it. If discovery is temporarily unavailable,
85
- the token remains saved and subsequent commands do not reuse the previous
86
- account's stored workspace.
87
-
88
- Create and revoke PATs from the dashboard under **API Keys → Personal Access
89
- Tokens**. `inquir logout` revokes its browser-issued CLI session at the API that
90
- issued it, then clears the local credentials and workspace. If the API is offline,
91
- the local logout still completes and warns that server revocation was not confirmed.
92
- Imported PATs (`--token`), tokens saved by older CLI versions, and credentials shared
93
- with another profile are only cleared locally; revoke them in the dashboard when
94
- they are no longer needed. Shell environment variables are never removed by logout.
95
- `inquir logout --env staging` leaves the default profile intact and prevents the
96
- logged-out profile from inheriting its credentials again.
97
-
98
- > A PAT can deploy to **any workspace you belong to**. A workspace-scoped **API
99
- > key** is pinned to a single workspace and ignores workspace switching.
100
-
101
- ## Workspaces
102
-
103
- A single login works across every workspace you're a member of. List them and
104
- choose a default:
105
-
106
- ```bash
107
- inquir workspaces # list workspaces (active one marked with *)
108
- inquir use <slug|id> # set the active workspace for subsequent commands
109
- ```
110
-
111
- Target a different workspace for a single command with `--workspace`:
112
-
113
- ```bash
114
- inquir deploy hello --workspace acme-prod
115
- inquir deploys hello --workspace acme-prod
116
- inquir whoami --workspace acme-prod
117
- ```
118
-
119
- Under the hood, user-scoped credentials send an `X-Inquir-Workspace` header; the
120
- server verifies your membership before honoring it.
121
-
122
- ## Application projects
123
-
124
- Projects group long-lived container applications inside a workspace: web services,
125
- APIs, databases, and workers. Serverless functions are managed separately and cannot
126
- be added to these projects. A new application creates a project named after itself
127
- unless you select an existing project:
128
-
129
- ```bash
130
- inquir projects list
131
- inquir projects create shop
132
- inquir projects use shop
133
- inquir apps create api --port 3000
134
- inquir apps create db --template postgres --project shop
135
- inquir projects add shop existing-app
136
- inquir projects move shop db # file it in shop, take it out of its other projects
137
- inquir projects remove shop old-api # unfile it; it keeps running
138
- inquir projects current
139
- inquir projects use --clear
140
- ```
141
-
142
- `projects use` saves the selection for the current directory, or the nearest
143
- `inquir.config.json` root. Use `--cwd <path>` to select another directory. The
144
- selection is kept locally under `~/.inquir/project-contexts` and isolated by API,
145
- the actual workspace, and signed-in user (or API key). Switching workspace or
146
- account therefore cannot silently reuse another context's project.
147
-
148
- `apps create --project <project>` overrides the selection for one command.
149
- `projects use --clear` returns to automatic project creation. Every project command
150
- accepts a project's ID, slug, or unique display name, and an application's ID or
151
- name. `apps create` prints the project an application landed in. All project
152
- commands support `--json`. Deploying an existing container application with
153
- `apps deploy` keeps its project membership. `projects add` files an application in
154
- one more project; `projects move` files it and takes it out of every other one.
155
- No project command archives a project: the API does not record which were created
156
- automatically, so an emptied one is reported and left for you to archive in the
157
- dashboard. This selection does not change the serverless `inquir deploy`
158
- workflow or local source/configuration project discovery.
159
-
160
- ## Deploy a function (remote)
161
-
162
- Once installed globally, deploying takes three steps:
163
-
164
- ```bash
165
- # 1. Authenticate. Easiest on a workstation:
166
- inquir login
167
- # For CI / scripts, export env vars for a one-off instead:
168
- # export INQUIR_API_URL="https://api.inquir.org"
169
- # export INQUIR_API_KEY="<api-key>" # workspace-scoped key, or
170
- # export INQUIR_TOKEN="<personal-access-token>"
171
-
172
- # 2. From your workspace (created by `inquir init`), deploy an asset by name.
173
- inquir deploy hello # streams build/deploy logs, exits non-zero on failure
174
-
175
- # 3. Invoke it remotely.
176
- inquir invoke hello --payload '{"name":"World"}'
177
- ```
178
-
179
- Get an API key from your Inquir Compute workspace settings. For CI, prefer the
180
- [`inquir-compute/deploy-action`](../deploy-action) GitHub Action (supports keyless
181
- OIDC auth), or run `inquir deploy --ci`.
182
-
183
- ## Commands
184
-
185
- **Project & local dev**
186
-
187
- - `inquir init [--name <name>] [--skip-install]` - scaffold `inquir.config.json`, folders, and a sample function. Interactive on a TTY (prompts for the project name); guides you to `login`/`run`/`deploy` afterward.
188
- - `inquir codegen` - discover assets and generate `.inquir/generated/client.ts` + `registry.json`.
189
- - `inquir list [--remote]` - list local assets, or deployed remote functions with `--remote`.
190
- - `inquir run <asset>` - run a local asset.
191
- - `inquir debug <asset>` - run locally with inspector enabled.
192
- - `inquir sync status` - compare local hashes with remote hashes (`in-sync`, `drift`, `missing`).
193
-
194
- **Auth & workspaces**
195
-
196
- - `inquir login` - authenticate the CLI (browser pairing, `--browserless`, or `--token`).
197
- - `inquir logout` - revoke the current browser-issued CLI session and clear its local credentials and workspace.
198
- - `inquir whoami` - show the signed-in user, active workspace, and role.
199
- - `inquir workspaces` - list the workspaces you belong to.
200
- - `inquir use <slug|id> [--local]` - set the active workspace; `--local` links *this project* by writing `workspace` into `inquir.config.json`.
201
-
202
- **Deploy & run remotely**
203
-
204
- - `inquir deploy <asset>` - package, upload, and deploy a function (async; streams build logs).
205
- - `inquir invoke <asset>` - invoke remote function by name / linked local name.
206
- - `inquir logs <asset>` - show recent remote invocation history.
207
- - `inquir deploys <function>` - list deploy history for a remote function.
208
- - `inquir status <deployId>` - show a deploy's status (`--follow` to stream logs).
209
- - `inquir rollback <function> [deployId]` - roll back to a previous successful deploy.
210
- - `inquir delete <function>` - delete a remote function (asks for confirmation; `--yes` to skip).
211
-
212
- **Container services (apps)**
213
-
214
- Long-lived containers from any OCI image — the counterpart to functions. HTTP
215
- ports are served over a hostname; TCP ports are published and dialled directly,
216
- so a database, SMTP relay or SSH endpoint is a first-class service with no
217
- runtime adapter involved.
218
-
219
- - `inquir apps list` - list applications.
220
- - `inquir apps create <name> [--port <n>] [--tcp …] [--set K=V]` - create an application.
221
- - `inquir apps deploy <app> [--image <ref>]` - start a release and wait until it is healthy. Without `--image` the current directory (or `--dir`) is built from its Dockerfile first; `--build <id>` releases an existing build.
222
- - `inquir apps build <app> [--dir <path>] [--dockerfile <f>] [--context <dir>] [--build-arg K=V]` - build an image from source without releasing it.
223
- - `inquir apps builds <app>` - build history (`--cancel <buildId>` drops a queued build).
224
- - `inquir apps status <app>` - endpoints (public and private), hostnames and recent releases. The `private:` lines are what another app in the workspace dials (`{slug}.apps.internal`, port per TCP service); they appear once the platform has verified the route.
225
- - `inquir apps logs <app|release|build> [--tail <n>]` - stream container (or build) logs.
226
- - `inquir apps promote <release>` - send production traffic to a release (needs a login, not an API key).
227
- - `inquir apps rollback <app>` - return production to the previous release.
228
- - `inquir apps stop <release>` - stop any release that is not serving production.
229
- - `inquir apps exec <app> -- <command>` - run a command inside the container (owner/admin login only — it can read every secret).
230
- - `inquir apps update <app> [--set K=V] [--port …] [--egress none|full] [--ingress private|public] …` - change settings; applies to the next release. `--ingress public` creates the generated public domain, `--ingress private` removes it (the private address is unaffected). New apps are private unless created with `--ingress public`.
231
- - `inquir apps domain <app> [hostname] [--verify|--remove]` - bind a custom hostname; publish the printed TXT record and point DNS at the platform, then `--verify`.
232
- - `inquir apps delete <app> --yes` - archive an application (stops every release, unbinds every hostname).
233
-
234
- Project archive in the dashboard also archives every application in the project, including applications shared with another project. It requires production permissions (`projects:write` and `apps:promote`). Clearing the local project selection with `inquir projects use --clear` only changes where future applications are created; it does not archive applications.
235
-
236
-
237
- ```bash
238
- # an HTTP service built from the Dockerfile in the current directory
239
- inquir apps create web --port 3000
240
- inquir apps deploy web
241
- inquir apps promote <releaseId>
242
-
243
- # ...or from a prebuilt image
244
- inquir apps deploy web --image nginx:alpine
245
-
246
- # a database: no HTTP port at all, published on a pinned port,
247
- # health-checked by asking the service itself
248
- inquir apps create db \
249
- --tcp postgres:5432:public:25432 \
250
- --health-command "pg_isready -h 127.0.0.1" \
251
- --set POSTGRES_PASSWORD=secret
252
- inquir apps deploy db --image postgres:16-alpine
253
- ```
254
-
255
- `--tcp name:port[:public][:hostPort]` — `public` publishes beyond loopback,
256
- and a pinned `hostPort` keeps a connection string valid across restarts (an
257
- unpinned port is reassigned every time the container is recreated). A public
258
- TCP port is reachable by anyone who can reach the host: the platform
259
- terminates no TLS and checks no credentials on raw TCP, so the service must
260
- authenticate its own clients.
261
-
262
- `--drain-grace <seconds>` (`create`, `deploy`, `update`; 0–3600) — the time the
263
- old container gets after SIGTERM before it is killed (`runtimeSpec.drainGraceSeconds`).
264
- Like `--memory` or `--cpu` it is saved on the application by `create`/`update`
265
- and carried into every release built from the saved runtime.
266
-
267
- **Databases**
268
-
269
- - `inquir apps create <name> --template postgres|redis` - create a database: image, persistent volume, private TCP port, generated password and its first release, in one command. Add `--volume-runner <runner>` to keep its data and container on a worker; the worker runs the operator's digest-pinned mirror of the template image, and without one the create is refused (`APP_TEMPLATE_IMAGE_NOT_MIRRORED`).
270
- - `inquir apps connection-url <db>` - print the live connection URL, credentials included (it lands in your shell history).
271
- - `inquir apps connect <db> <app>` - write that URL into another application's env as `DATABASE_URL` / `REDIS_URL` without it passing through your terminal; it applies on that application's next release.
272
- - `inquir apps backups <app> [list|create|restore <id>|delete <id>]` - volume snapshots. `restore` **overwrites the volume** with the snapshot and stops the application while it runs, so it asks for confirmation — pass `--yes` in a script.
273
-
274
- ```bash
275
- inquir apps create mydb --template postgres
276
- inquir apps connect mydb web # web gets DATABASE_URL on its next release
277
- inquir apps backups mydb create # snapshot every volume, wait for it to settle
278
- inquir apps backups mydb restore 3f9c1a2b --yes
279
- ```
280
-
281
- An application that declares a volume deploys by stopping its container before
282
- starting the new one, so two containers never write the same data — expect a
283
- short outage on every deploy. Backups are crash-consistent (the container is
284
- paused while it is copied) and need an artifact store configured on the
285
- deployment; without one the backup commands report that they are unavailable.
286
-
287
- **Staying up to date**
288
-
289
- The CLI keeps itself in step with the platform. On start it checks — at most
290
- every 12 hours, with a 2.5 s network timeout, never failing your command — the
291
- npm registry for the latest `@inquir/compute-cli` and the API for the minimum
292
- version it still supports (`GET /v1/cli/version`). When a newer version exists
293
- and the CLI is a global npm install running in an interactive terminal, it
294
- updates itself and re-runs your command; in CI, under `--json`, without a TTY,
295
- via `npx` or from a source checkout it only prints a one-line notice. If the
296
- API's *minimum* is not met, the command stops with the exact fix instead of
297
- failing later on a changed wire contract.
298
-
299
- - `inquir upgrade` - update now (`--check` only reports).
300
- - Opt out: `inquir config set autoUpdate false`, `INQUIR_NO_AUTO_UPDATE=1`, or `--no-update` on one command.
301
-
302
- **Diagnostics & config**
303
-
304
- - `inquir doctor` - diagnose environment, credentials, and API connectivity (`--json` for a report).
305
- - `inquir config [show|get <key>|set <key> <value>|path]` - view/edit CLI configuration.
306
- - `inquir help [command]` - show grouped help, or help for one command.
307
-
308
- **Platform operators**
309
-
310
- - `inquir admin cluster [status|hold|release|move <memberId>|host register|grant <host> <capability>|revoke <host> <capability>]` -
311
- the multi-master control plane (docs/roadmap/R4_MULTI_MASTER.md §6.2). It authenticates with the platform admin token in
312
- `INQUIR_ADMIN_TOKEN`, never with your login; changes need the full token and land in the admin audit log.
313
- - `inquir admin allocations relocate <allocationId> --reason <text> [--target <runnerId>]` - move one serving replica
314
- make-before-break: its replacement starts (on the target, which must pass every placement filter and have room), takes
315
- the traffic, and only then is the replica stopped. Pinned, volume, preview and TCP-pinned replicas are refused, as is an
316
- application in a deployment handoff. `inquir admin allocations relocation <operationId>` shows where it is. Same token.
317
-
318
- ### `deploy` flags
319
-
320
- ```bash
321
- inquir deploy hello # package + async deploy, stream build logs
322
- inquir deploy hello --stage staging # target a deploy stage (alias: --environment)
323
- inquir deploy hello --set KEY=val --set OTHER=val # set environment variables (repeatable)
324
- inquir deploy hello --env-file .env.production # load env vars from a dotenv file
325
- inquir deploy hello --memory 512 --timeout 60000 # memory (MB) / timeout (ms)
326
- inquir deploy hello --layer <layerId> --layer <id2> # attach layers (repeatable)
327
- inquir deploy hello --no-logs # queue and wait for completion without streaming
328
- inquir deploy hello --ci # plain output, non-zero exit on failure (for CI)
329
- inquir deploy hello --dry-run # validate + package only; no create/deploy
330
- inquir deploy hello --json # machine-readable result
331
- ```
332
-
333
- > Note: `--env` selects a named **credential environment** from your config; `--stage`
334
- > (alias `--environment`) selects the **deploy stage** (production/staging/preview). They
335
- > are different — don't confuse them.
336
-
337
- ## Global Flags
338
-
339
- Global flags work in **any position** (before or after the command) and accept both
340
- `--flag value` and `--flag=value`:
341
-
342
- - `--json` - machine-readable output (implies no color).
343
- - `--debug` - verbose diagnostics + stack traces (also `INQUIR_DEBUG=1`).
344
- - `--quiet` - suppress status chatter (errors + requested results only).
345
- - `--no-color` - disable ANSI color (also honoured: `NO_COLOR`, `FORCE_COLOR`).
346
- - `--yes`, `-y` - assume "yes" for confirmations (required for destructive ops in CI).
347
- - `--cwd <path>` - run as if from this directory (alias: `--config`, which also accepts a config file path).
348
- - `--env <name>` - select a named credential environment from the config.
349
- - `--workspace <slug|id>` - target a specific workspace for this command (user-scoped login).
350
- - `--api-url <url>` - override the API base URL.
351
- - `--token <pat>` - use a Personal Access Token (non-interactive / CI).
352
-
353
- ```bash
354
- inquir run hello --cwd ./services/api
355
- inquir --workspace acme-prod deploy hello
356
- ```
357
-
358
- ## Exit codes
359
-
360
- | Code | Meaning |
361
- |------|---------|
362
- | `0` | success |
363
- | `1` | runtime error (build failed, not found, server error) |
364
- | `2` | usage / validation error (bad flags, missing args) |
365
- | `3` | network / timeout |
366
- | `4` | authentication required / forbidden |
367
- | `130` | interrupted (Ctrl+C / SIGINT) |
368
-
369
- A bare `Ctrl+C` aborts cleanly — the CLI prints `Aborted (SIGINT).` to stderr and
370
- exits `130`, leaving stdout untouched (safe for piping) and no stack trace.
371
-
372
- With `--json`, errors are emitted as a structured envelope on stdout:
373
-
374
- ```json
375
- { "ok": false, "error": { "code": "AUTH_REQUIRED", "title": "You are not logged in", "message": "…", "requestId": "…" } }
376
- ```
377
-
378
- ## CI usage
379
-
380
- In CI / non-TTY, the CLI never prompts; supply credentials via env and use `--ci`/`--yes`:
381
-
382
- ```bash
383
- export INQUIR_TOKEN="$INQUIR_PAT" # or INQUIR_API_KEY for a workspace key
384
- export INQUIR_WORKSPACE="acme-prod" # optional: target workspace
385
- inquir deploy hello --ci --json
386
- ```
387
-
388
- For GitHub Actions, prefer the [`@inquir/deploy-action`](../deploy-action) GitHub Action
389
- (supports keyless OIDC auth).
390
-
391
- ## Payload Input
392
-
393
- `run` and `invoke` support:
394
-
395
- - `--payload '{"k":"v"}'`
396
- - `--payload-file ./payload.json`
397
- - stdin piping
398
-
399
- Shell quoting differs by platform. To pass inline JSON:
400
-
401
- ```bash
402
- # macOS / Linux (bash, zsh) — single-quote the JSON:
403
- inquir invoke hello --payload '{"name":"World"}'
404
- ```
405
-
406
- ```powershell
407
- # Windows PowerShell — single-quote the JSON:
408
- inquir invoke hello --payload '{"name":"World"}'
409
- ```
410
-
411
- ```bat
412
- :: Windows cmd.exe — escape the inner double quotes:
413
- inquir invoke hello --payload "{\"name\":\"World\"}"
414
- ```
415
-
416
- When quoting gets awkward (especially on Windows), prefer `--payload-file ./payload.json`
417
- or pipe via stdin: `type payload.json | inquir invoke hello`.
418
-
419
- ## Remote Auth / Environment
420
-
421
- The CLI resolves each credential field independently, in this order (first match
422
- wins):
423
-
424
- 1. CLI flags (`--api-url`, `--token`, `--workspace`) / `--env <name>` selection
425
- 2. Environment variables (`LAMBDA_*` are legacy fallbacks):
426
- - `INQUIR_API_URL`, `INQUIR_API_KEY`
427
- - `INQUIR_TOKEN` — a Personal Access Token (takes precedence over `apiKey`)
428
- - `INQUIR_WORKSPACE` — active workspace (slug or id)
429
- - `INQUIR_ENV` — pick a named environment
430
- 3. Selected environment in the config file
431
- 4. Project link — `workspace` in the local `inquir.config.json` (set by `inquir use --local`); applies to the workspace only, below flags/env
432
- 5. Top-level config file values (credentials and workspace only when the named environment uses the same API)
433
- 6. Default `apiUrl` of `https://api.inquir.org` (override with env/config for local dev)
434
-
435
- A named environment with its own different API does not inherit the default
436
- token, API key, cached identity, or workspace. Partial profiles using the same API
437
- can still inherit defaults. Explicit flags and environment variables keep the
438
- precedence above. An unknown environment name fails before a remote command;
439
- `inquir login --env <name>` can create it.
440
-
441
- When login changes the default API, existing named profiles that inherited that
442
- API and contain credentials, a workspace, or cached identity retain their previous
443
- API binding. Their stored credentials are preserved. A profile that previously
444
- inherited its credentials may need its own login after this change. Empty profiles
445
- continue to inherit defaults. Changing a profile's API also removes its stored API
446
- key, so logging out of the new PAT cannot reactivate a key from the previous API.
447
-
448
- When both a `token` (PAT) and an `apiKey` are present, the PAT wins. The active
449
- `workspaceId` is only applied to user-scoped credentials (PAT/session); for a
450
- workspace-scoped API key it is ignored unless you pass `--workspace` explicitly.
451
-
452
- Config file locations:
453
-
454
- - `~/.inquir/config.json` (preferred, written by `inquir login` / `use`; saved with `0600` permissions)
455
- - `~/.lambda-cli/config.json` (legacy fallback — **credentials only**; the legacy `apiUrl` is intentionally ignored so you aren't silently pinned to `localhost`)
456
-
457
- Credential updates use an atomic file replacement and an exclusive
458
- `~/.inquir/config.json.lock` while updating or revoking a session. A timed-out lock
459
- is never stolen from a running command. If a command crashed and subsequent commands
460
- report `AUTH_CONFIG_LOCKED`, stop all CLI commands before removing that lock file.
461
- Older CLI versions do not participate in this locking protocol; avoid running old
462
- and new versions concurrently against the same configuration.
463
-
464
- Example (written/managed by `inquir login`, `inquir use`, `inquir logout`):
465
-
466
- ```json
467
- {
468
- "apiUrl": "https://api.inquir.org",
469
- "token": "inq_pat_…",
470
- "workspaceId": "acme-prod",
471
- "user": { "id": "…", "email": "you@example.com", "name": "You" },
472
- "environments": {
473
- "staging": {
474
- "apiUrl": "https://staging.example.com",
475
- "apiKey": "staging-key"
476
- }
477
- }
478
- }
479
- ```
480
-
481
- ## Troubleshooting
482
-
483
- Start with `inquir doctor` — it checks the CLI/Node version, config file, credential,
484
- API connectivity + latency, active workspace, and local project, and prints a fix for any
485
- failing check.
486
-
487
- | Symptom | Likely cause / fix |
488
- |---------|--------------------|
489
- | `You are not logged in` (exit 4) | No credential resolved. Run `inquir login`, or set `INQUIR_TOKEN`/`INQUIR_API_KEY` in CI. |
490
- | `Permission denied` (exit 4) | Wrong workspace or insufficient role. Check `inquir whoami`; switch with `inquir use`. |
491
- | `Not found` for a function | Wrong name or workspace. `inquir list --remote` to see what exists in the active workspace. |
492
- | Commands hit `localhost` unexpectedly | A stale `apiUrl` in config/env. Check `inquir config show`; override with `--api-url` or `INQUIR_API_URL`. |
493
- | Network error (exit 3) | Can't reach the API. Verify connectivity and `--api-url`; re-run `inquir doctor`. |
494
- | Garbled output in logs/CI | Disable color with `--no-color` or `NO_COLOR=1` (color auto-disables when not a TTY and in `--json`). |
495
- | Need raw detail for a failure | Re-run with `--debug` for stack traces and the response body (secrets are redacted). |
496
-
497
- ## Publishing to npm (maintainers)
498
-
499
- The CLI (`@inquir/compute-cli`) depends on the SDK (`@inquir/compute`), so the
500
- SDK must be published **first** at a version satisfying the CLI's dependency
501
- range (`dependencies["@inquir/compute"]`, `^0.4.0` for CLI 0.4.0). Set the lower
502
- bound to the first SDK release containing every API the CLI imports. A workspace
503
- build uses the local SDK and cannot prove that an older published SDK works.
504
-
505
- Release order for 0.4.0: CLI 0.4.0 imports `isPromoteAccepted` and
506
- `getApplicationRollout` (the background promote, `inquir apps promote`), which
507
- SDK 0.3.0 does not export. Publish SDK 0.4.0 first and confirm it on the
508
- registry; a CLI published against SDK 0.3.0 would fail at startup.
509
-
510
- New `inquir init` scaffolds inherit this SDK range and require Node.js 22+.
511
- Existing `package.json` files are preserved; update their dependencies explicitly
512
- when adopting a newer SDK.
513
-
514
- Prerequisites:
515
-
516
- - An npm account with publish access to the `@inquir` scope (create the org/scope on npmjs.com), then `npm login`.
517
- - Both packages declare `"publishConfig": { "access": "public" }`, so scoped packages publish publicly.
518
- - Both packages build before packing or publishing from source. The SDK includes
519
- `dist/`; the CLI includes `dist/` and its bundled `skill/`. npm also includes
520
- package metadata and README files.
521
- - Choose unused release versions, update the CLI's SDK dependency and the lockfile,
522
- then run the SDK and CLI tests before preparing the release candidate.
523
-
524
- Prepare the exact tarballs from the repo root:
525
-
526
- ```bash
527
- # Cleans and builds the SDK first, then the CLI.
528
- npm run build --workspace @inquir/compute-cli
529
- # Reuse the verified build instead of rebuilding during packing.
530
- npm pack --workspace @inquir/compute --ignore-scripts
531
- npm pack --workspace @inquir/compute-cli --ignore-scripts
532
- ```
533
-
534
- Install both tarballs into a temporary directory outside this repository. Check
535
- `npm ls @inquir/compute`, `inquir --version`, `inquir --help`, project commands,
536
- and a local TypeScript function run. Resolve packages from that installation,
537
- without workspace links, so the smoke test exercises the files users receive.
538
-
539
- Publish those tested tarballs in order (0.3.0 shown; use the chosen versions):
540
-
541
- ```bash
542
- npm publish ./inquir-compute-0.3.0.tgz --access public
543
- # Confirm this SDK version is available from the registry before publishing CLI.
544
- npm view @inquir/compute@0.3.0 version
545
- npm publish ./inquir-compute-cli-0.3.0.tgz --access public
546
- ```
547
-
548
- After building, preview package contents without publishing with
549
- `npm pack --dry-run --json --ignore-scripts --workspace @inquir/compute-cli`.
550
- `--ignore-scripts` skips build hooks, so only use it after the explicit build.
551
- The installed command is `inquir`, from `dist/index.js` with its Node shebang.
552
- After publishing, users can install it with:
553
-
554
- ```bash
555
- npm install -g @inquir/compute-cli@latest
556
- inquir --help
557
- ```
558
- ## Application observability
559
-
560
- Read actual resource history for every release and replica, or HTTP gateway measurements:
561
-
562
- ```sh
563
- inquir apps metrics api --since 6h
564
- inquir apps metrics api --since 30d --json
565
- inquir apps metrics api --http --since 1d --json
566
- ```
567
-
568
- The resource table shows the latest point per replica in the selected window. JSON contains all returned points, their enforced CPU/RAM limits, network transfer rates, disk I/O rates and deployment markers. `null` means the measurement is unavailable; it is not zero. Disk I/O measures reads/writes, not occupied volume space. HTTP measurements cover gateway requests, including request counts, 5xx errors, response bytes and latency percentiles. Resource and HTTP history is retained for 30 days; resource points older than a day are rolled up to one per five minutes, and older than a week to one per hour, each keeping the bucket's last point plus its CPU and memory peak and mean. Inspect `status`, `latestSampleAt` and `truncated` in resource JSON before interpreting a range as current or complete.
569
-
570
- Ask what the CPU and memory figures could be, from what the production replicas actually used:
571
-
572
- ```sh
573
- inquir apps resources recommend api
574
- inquir apps resources recommend api --days 3 --json
575
- ```
576
-
577
- The recommendation is read-only. Memory is 1.2 × the peak working set in the window (default 7 days), at least 64 MB, at least 256 MB for a database, and never below the peak of the whole 30-day history plus 10%. The CPU limit follows the peak (1.5 ×, at least 0.1 vCPU); the reserved request shown is what the platform would reserve for that limit, next to the request the 95th percentile of five-minute averages alone would justify. A recommendation needs 24 hours of observed usage; `confidence` reports the days observed and the samples behind it, and `--json` adds each release (replica set) seen in the window. Apply one yourself with `inquir apps update api --memory <mb> --cpu <vcpus>` and `inquir apps redeploy api`.
578
-
579
- Persisted container logs remain readable after the container is replaced. Select an app and optionally an exact release or runtime identity:
580
-
581
- ```sh
582
- inquir apps log-history api --since 1h --level error --json
583
- inquir apps logs api --history --release <release-id> --replica <allocation-id> --allocation-fence 4
584
- inquir apps log-history api --runner <runner-id> --runner-epoch 0 --container <full-container-id>
585
- inquir apps log-history api --http --since 7d --status 503 --search /api --json
586
- ```
587
-
588
- History returns one page, newest first. Runtime retention is 7 days; HTTP retention is 30 days. Use `--limit` (up to 200 runtime rows or 500 HTTP rows) and `--cursor` for older pages. Always reuse the response's `from` and `to` as `--from`/`--to`, plus the same filters, when using a cursor. `apps logs api` without `--history` still follows the current release; `apps logs <build-id>` still reads build output.
589
-
590
- Configure alert rules using JSON files or stdin. Destinations are write-only and are omitted from command output:
591
-
592
- ```sh
593
- inquir apps alerts api list --json
594
- inquir apps alerts api create --file cpu-alert.json
595
- inquir apps alerts api update <rule-id> --file patch.json
596
- inquir apps alerts api incidents --limit 25 --json
597
- inquir apps alerts api delete <rule-id>
598
- ```
599
-
600
- Example `cpu-alert.json` (incident-only until a notification destination is configured):
601
-
602
- ```json
603
- {
604
- "name": "High CPU",
605
- "enabled": true,
606
- "metric": "cpu_percent",
607
- "threshold": 85,
608
- "forSeconds": 120,
609
- "recoveryThreshold": 65,
610
- "recoveryForSeconds": 60,
611
- "noDataSeconds": 180,
612
- "noData": "alert",
613
- "channels": []
614
- }
615
- ```
616
-
617
- Use `memory_percent` for RAM or `deployment_failed` for failed production deployments. CPU/RAM rules evaluate the continuous maximum across current production replicas; the hot replica can change during the hold period. Percentage thresholds refer to each container's enforced limit. For deployment events, timing and threshold fields do not control the failure trigger. Notification channels have the shape `{"type":"webhook","url":"https://your-endpoint.example/alerts"}` or `{"type":"slack","url":"https://hooks.slack.com/..."}`. Keep secret URLs in a file outside version control, or pipe JSON to `--file -`. The server must have secret encryption configured to accept notification channels.
618
-
619
- A patch such as `{"threshold":90}` keeps existing destinations. `{"channels":[]}` removes them. Deleting a rule disables it and resolves active incidents while preserving retained history. Incident results include notification delivery state and retry counts. All commands honor the existing `--workspace`, `--env`, `--api-url` and credential selection rules.
1
+ # @inquir/compute-cli
2
+
3
+ CLI for workspace-first Inquir Compute development.
4
+
5
+ ## Install
6
+
7
+ Global (recommended). `@latest` also upgrades an existing install to the newest
8
+ published version:
9
+
10
+ ```bash
11
+ npm install -g @inquir/compute-cli@latest
12
+ ```
13
+
14
+ Verify it's on your `PATH`:
15
+
16
+ ```bash
17
+ inquir --version
18
+ inquir --help
19
+ ```
20
+
21
+ Or run without installing:
22
+
23
+ ```bash
24
+ npx @inquir/compute-cli@latest --help
25
+ ```
26
+
27
+ > Requires **Node.js 22+**. To upgrade later, re-run the install command above. On
28
+ > macOS/Linux you may need `sudo` for a global install, or use a Node version
29
+ > manager (nvm/fnm) to avoid it. To remove: `npm uninstall -g @inquir/compute-cli`.
30
+
31
+ ## Concepts
32
+
33
+ - **Function**: a single compute unit with typed input/output (Zod schemas). Defined with `defineFunction()`. Run locally with `inquir run`, deployed and invoked remotely with `inquir deploy` / `inquir invoke`.
34
+ - **Pipeline**: a declarative DAG of functions defined with `definePipeline()`. Registered in the codegen registry for client use; remote run/deploy for pipelines is handled by the backend.
35
+ - **Client**: the generated TypeScript module at `.inquir/generated/client.ts`. Wraps remote invocation with schemas inferred from your source. Import it in your application code.
36
+ - **Source of truth**: your local files under `functionsDir` and `pipelinesDir`. `registry.json` is a derived artifact rebuilt by `inquir codegen` — never hand-edit it.
37
+ - **Local ↔ remote link**: each deployed remote function stores a `linkedLocalName` (your local asset name) and a `sourceHash`. `inquir sync status` compares hashes to detect drift.
38
+
39
+ ## Quick Start
40
+
41
+ ```bash
42
+ inquir init
43
+ inquir codegen
44
+ inquir list
45
+ inquir run hello --payload '{"name":"World"}'
46
+ ```
47
+
48
+ ## Authentication
49
+
50
+ The recommended way to authenticate on your own machine is a browser login,
51
+ which mints a user-scoped **Personal Access Token** (PAT) bound to your account
52
+ and stores it in `~/.inquir/config.json`:
53
+
54
+ ```bash
55
+ inquir login # opens your browser to approve this device
56
+ inquir whoami # show the signed-in user + active workspace
57
+ ```
58
+
59
+ `inquir login` prints a short code and opens a dashboard page; confirm the code
60
+ matches and click **Authorize**. The CLI then receives its token automatically.
61
+ Browser-issued CLI sessions expire (90 days by default; the server can configure
62
+ a shorter lifetime). The CLI records the issuing API and expiry with the token.
63
+ Logging in again saves the new session before revoking the previous session owned
64
+ by that profile, unless another stored profile or environment variable still uses it.
65
+
66
+ Other login modes:
67
+
68
+ ```bash
69
+ inquir login --browserless # print the URL + code instead of opening a browser
70
+ inquir login --token <pat> # non-interactive (CI): use a PAT created in the dashboard
71
+ inquir login --name "my CI" # label the device/token shown in the dashboard
72
+ ```
73
+
74
+ Login stores the API URL together with the token. To keep credentials for another
75
+ API separately, use a named environment:
76
+
77
+ ```bash
78
+ inquir login --env staging --api-url https://staging.example.com --token <pat>
79
+ inquir whoami --env staging
80
+ ```
81
+
82
+ Changing a login's API or token clears its cached identity and workspace until
83
+ membership discovery succeeds. A previous workspace on the same API is restored
84
+ only if the new token can still access it. If discovery is temporarily unavailable,
85
+ the token remains saved and subsequent commands do not reuse the previous
86
+ account's stored workspace.
87
+
88
+ Create and revoke PATs from the dashboard under **API Keys → Personal Access
89
+ Tokens**. `inquir logout` revokes its browser-issued CLI session at the API that
90
+ issued it, then clears the local credentials and workspace. If the API is offline,
91
+ the local logout still completes and warns that server revocation was not confirmed.
92
+ Imported PATs (`--token`), tokens saved by older CLI versions, and credentials shared
93
+ with another profile are only cleared locally; revoke them in the dashboard when
94
+ they are no longer needed. Shell environment variables are never removed by logout.
95
+ `inquir logout --env staging` leaves the default profile intact and prevents the
96
+ logged-out profile from inheriting its credentials again.
97
+
98
+ > A PAT can deploy to **any workspace you belong to**. A workspace-scoped **API
99
+ > key** is pinned to a single workspace and ignores workspace switching.
100
+
101
+ ## Workspaces
102
+
103
+ A single login works across every workspace you're a member of. List them and
104
+ choose a default:
105
+
106
+ ```bash
107
+ inquir workspaces # list workspaces (active one marked with *)
108
+ inquir use <slug|id> # set the active workspace for subsequent commands
109
+ ```
110
+
111
+ Target a different workspace for a single command with `--workspace`:
112
+
113
+ ```bash
114
+ inquir deploy hello --workspace acme-prod
115
+ inquir deploys hello --workspace acme-prod
116
+ inquir whoami --workspace acme-prod
117
+ ```
118
+
119
+ Under the hood, user-scoped credentials send an `X-Inquir-Workspace` header; the
120
+ server verifies your membership before honoring it.
121
+
122
+ ## Application projects
123
+
124
+ Projects group long-lived container applications inside a workspace: web services,
125
+ APIs, databases, and workers. Serverless functions are managed separately and cannot
126
+ be added to these projects. A new application creates a project named after itself
127
+ unless you select an existing project:
128
+
129
+ ```bash
130
+ inquir projects list
131
+ inquir projects create shop
132
+ inquir projects use shop
133
+ inquir apps create api --port 3000
134
+ inquir apps create db --template postgres --project shop
135
+ inquir projects add shop existing-app
136
+ inquir projects move shop db # file it in shop, take it out of its other projects
137
+ inquir projects remove shop old-api # unfile it; it keeps running
138
+ inquir projects current
139
+ inquir projects use --clear
140
+ ```
141
+
142
+ `projects use` saves the selection for the current directory, or the nearest
143
+ `inquir.config.json` root. Use `--cwd <path>` to select another directory. The
144
+ selection is kept locally under `~/.inquir/project-contexts` and isolated by API,
145
+ the actual workspace, and signed-in user (or API key). Switching workspace or
146
+ account therefore cannot silently reuse another context's project.
147
+
148
+ `apps create --project <project>` overrides the selection for one command.
149
+ `projects use --clear` returns to automatic project creation. Every project command
150
+ accepts a project's ID, slug, or unique display name, and an application's ID or
151
+ name. `apps create` prints the project an application landed in. All project
152
+ commands support `--json`. Deploying an existing container application with
153
+ `apps deploy` keeps its project membership. `projects add` files an application in
154
+ one more project; `projects move` files it and takes it out of every other one.
155
+ No project command archives a project: the API does not record which were created
156
+ automatically, so an emptied one is reported and left for you to archive in the
157
+ dashboard. This selection does not change the serverless `inquir deploy`
158
+ workflow or local source/configuration project discovery.
159
+
160
+ ## Deploy a function (remote)
161
+
162
+ Once installed globally, deploying takes three steps:
163
+
164
+ ```bash
165
+ # 1. Authenticate. Easiest on a workstation:
166
+ inquir login
167
+ # For CI / scripts, export env vars for a one-off instead:
168
+ # export INQUIR_API_URL="https://api.inquir.org"
169
+ # export INQUIR_API_KEY="<api-key>" # workspace-scoped key, or
170
+ # export INQUIR_TOKEN="<personal-access-token>"
171
+
172
+ # 2. From your workspace (created by `inquir init`), deploy an asset by name.
173
+ inquir deploy hello # streams build/deploy logs, exits non-zero on failure
174
+
175
+ # 3. Invoke it remotely.
176
+ inquir invoke hello --payload '{"name":"World"}'
177
+ ```
178
+
179
+ Create a Personal Access Token under Settings → API Keys in the console. For CI,
180
+ store it as a secret, export it as `INQUIR_TOKEN` and run `inquir deploy --ci`
181
+ (see [CI usage](#ci-usage)).
182
+
183
+ ## Commands
184
+
185
+ **Project & local dev**
186
+
187
+ - `inquir init [--name <name>] [--skip-install]` - scaffold `inquir.config.json`, folders, and a sample function. Interactive on a TTY (prompts for the project name); guides you to `login`/`run`/`deploy` afterward.
188
+ - `inquir codegen` - discover assets and generate `.inquir/generated/client.ts` + `registry.json`.
189
+ - `inquir list [--remote]` - list local assets, or deployed remote functions with `--remote`.
190
+ - `inquir run <asset>` - run a local asset.
191
+ - `inquir debug <asset>` - run locally with inspector enabled.
192
+ - `inquir sync status` - compare local hashes with remote hashes (`in-sync`, `drift`, `missing`).
193
+
194
+ **Auth & workspaces**
195
+
196
+ - `inquir login` - authenticate the CLI (browser pairing, `--browserless`, or `--token`).
197
+ - `inquir logout` - revoke the current browser-issued CLI session and clear its local credentials and workspace.
198
+ - `inquir whoami` - show the signed-in user, active workspace, and role.
199
+ - `inquir workspaces` - list the workspaces you belong to.
200
+ - `inquir use <slug|id> [--local]` - set the active workspace; `--local` links *this project* by writing `workspace` into `inquir.config.json`.
201
+
202
+ **Deploy & run remotely**
203
+
204
+ - `inquir deploy <asset>` - package, upload, and deploy a function (async; streams build logs).
205
+ - `inquir invoke <asset>` - invoke remote function by name / linked local name.
206
+ - `inquir logs <asset>` - show recent remote invocation history.
207
+ - `inquir deploys <function>` - list deploy history for a remote function.
208
+ - `inquir status <deployId>` - show a deploy's status (`--follow` to stream logs).
209
+ - `inquir rollback <function> [deployId]` - roll back to a previous successful deploy.
210
+ - `inquir delete <function>` - delete a remote function (asks for confirmation; `--yes` to skip).
211
+
212
+ **Container services (apps)**
213
+
214
+ Long-lived containers from any OCI image — the counterpart to functions. HTTP
215
+ ports are served over a hostname; TCP ports are published and dialled directly,
216
+ so a database, SMTP relay or SSH endpoint is a first-class service with no
217
+ runtime adapter involved.
218
+
219
+ - `inquir apps list` - list applications.
220
+ - `inquir apps create <name> [--port <n>] [--tcp …] [--set K=V]` - create an application.
221
+ - `inquir apps deploy <app> [--image <ref>]` - start a release and wait until it is healthy. Without `--image` the current directory (or `--dir`) is built from its Dockerfile first; `--build <id>` releases an existing build. `services.web.env` in `inquir.yaml` holds non-secret defaults: applied where the platform enables it (`APPS_MANIFEST_ENV=on`), with an application variable of the same name winning; the deploy prints what it applied and warns about anything it ignored or overrode. Never put secrets in `inquir.yaml`.
222
+ - `inquir apps build <app> [--dir <path>] [--dockerfile <f>] [--context <dir>] [--build-arg K=V]` - build an image from source without releasing it.
223
+ - `inquir apps builds <app>` - build history (`--cancel <buildId>` drops a queued build).
224
+ - `inquir apps status <app>` - endpoints (public and private), hostnames and recent releases. The `private:` lines are what another app in the workspace dials (`{slug}.apps.internal`, port per TCP service); they appear once the platform has verified the route.
225
+ - `inquir apps instances <app> [--json]` - the application's replicas, like pods: name (`<app>-<index>-<id8>`), state, ready, restarts, runner, region, CPU/RAM now.
226
+ - `inquir apps logs <app|release|build> [--tail <n>] [--replica <name|index>]` - stream container (or build) logs; `--replica` follows one replica.
227
+ - `inquir apps promote <release>` - send production traffic to a release (needs a login, not an API key).
228
+ - `inquir apps rollback <app>` - return production to the previous release.
229
+ - `inquir apps stop <release>` - stop any release that is not serving production.
230
+ - `inquir apps exec <app> [--replica <name|index>] -- <command>` - run a command inside the container (owner/admin login only — it can read every secret). `--replica` picks one serving replica; without it the server picks the production container.
231
+ - `inquir apps update <app> [--set K=V] [--unset K] [--port …] [--egress none|full] [--ingress private|public] …` - change settings; applies to the next release. `--unset` removes a variable and its production-only marker (e.g. so the `inquir.yaml` value applies). `--ingress public` creates the generated public domain, `--ingress private` removes it (the private address is unaffected). New apps are private unless created with `--ingress public`.
232
+ - `inquir apps update <app> --node-selector inquir.io/region=eu [--node-selector tier=fast]` - run the next releases only on servers carrying every one of these node labels (`--clear-node-selector` removes it). Well-known labels: `inquir.io/region`, `inquir.io/zone`, `inquir.io/runtime`, `inquir.io/arch`, `inquir.io/gpu`, `inquir.io/gpu-count`; operator labels the platform publishes work too. Needs node placement enabled on the platform (`COMPUTE_NODE_AFFINITY=enforce`); a selector no server matches yet is accepted with a warning, and `inquir apps describe` says why a replica waits. Full Kubernetes-style `runtime.nodeAffinity` goes through the API or `inquir.yaml`.
233
+ - `inquir apps update <app> --location <id|auto>` (experimental) - run the next releases in one of the platform's locations (`nl`, `ru`, ...); `auto` runs wherever there is capacity. Shown by `inquir apps status` and `inquir apps describe`; offered only where the platform enables it (`COMPUTE_SERVICE_LOCATIONS=on`). A service whose volume data lives in another location is refused: the data does not move.
234
+ - `inquir apps domain <app> [hostname] [--verify|--remove]` - bind a custom hostname; publish the printed TXT record and point DNS at the platform, then `--verify`.
235
+ Advanced, not recommended: a quoted mask `inquir apps domain <app> '*.example.com' --yes` binds every first-level subdomain when the server enables it (`APPS_WILDCARD_DOMAINS=on`). It takes traffic from every such name, including services you may not know about, and each subdomain gets its own certificate within a weekly budget; prefer binding hostnames one by one. Proof: a wildcard CNAME `*.example.com` and TXT `_inquir-verify.example.com`.
236
+ - `inquir apps delete <app> --yes` - archive an application (stops every release, unbinds every hostname).
237
+
238
+ Project archive in the dashboard also archives every application in the project, including applications shared with another project. It requires production permissions (`projects:write` and `apps:promote`). Clearing the local project selection with `inquir projects use --clear` only changes where future applications are created; it does not archive applications.
239
+
240
+
241
+ ```bash
242
+ # an HTTP service built from the Dockerfile in the current directory
243
+ inquir apps create web --port 3000
244
+ inquir apps deploy web
245
+ inquir apps promote <releaseId>
246
+
247
+ # ...or from a prebuilt image
248
+ inquir apps deploy web --image nginx:alpine
249
+
250
+ # a database: no HTTP port at all, a persistent volume and a TCP port
251
+ # on the private network (other applications of the workspace connect to it)
252
+ inquir apps create db --template postgres
253
+ ```
254
+
255
+ `--tcp name:port` declares a TCP port on the private network. The optional
256
+ modifiers `:public` and a numeric `:hostPort` pin (`name:port[:public][:hostPort]`;
257
+ a pin implies `public`) ask for a public TCP port. Public TCP ports are not
258
+ available on inquir.org at the moment: such a port is refused with
259
+ `PUBLIC_TCP_UNAVAILABLE`. Where a server
260
+ does offer them, a public TCP port is reachable by anyone who can reach the
261
+ host: the platform terminates no TLS and checks no credentials on raw TCP, so
262
+ the service must authenticate its own clients.
263
+
264
+ `--drain-grace <seconds>` (`create`, `deploy`, `update`; 0–3600) — the time the
265
+ old container gets after SIGTERM before it is killed (`runtimeSpec.drainGraceSeconds`).
266
+ Like `--memory` or `--cpu` it is saved on the application by `create`/`update`
267
+ and carried into every release built from the saved runtime.
268
+
269
+ **Databases**
270
+
271
+ - `inquir apps create <name> --template postgres|redis` - create a database: image, persistent volume, private TCP port, generated password and its first release, in one command. Add `--volume-runner <runner>` to keep its data and container on a worker; the worker runs the operator's digest-pinned mirror of the template image, and without one the create is refused (`APP_TEMPLATE_IMAGE_NOT_MIRRORED`).
272
+ - `inquir apps connection-url <db>` - print the live connection URL, credentials included (it lands in your shell history).
273
+ - `inquir apps connect <db> <app>` - write that URL into another application's env as `DATABASE_URL` / `REDIS_URL` without it passing through your terminal; it applies on that application's next release.
274
+ - `inquir apps backups <app> [list|create|restore <id>|delete <id>]` - volume snapshots. `restore` **overwrites the volume** with the snapshot and stops the application while it runs, so it asks for confirmation — pass `--yes` in a script.
275
+
276
+ ```bash
277
+ inquir apps create mydb --template postgres
278
+ inquir apps connect mydb web # web gets DATABASE_URL on its next release
279
+ inquir apps backups mydb create # snapshot every volume, wait for it to settle
280
+ inquir apps backups mydb restore 3f9c1a2b --yes
281
+ ```
282
+
283
+ An application that declares a volume deploys by stopping its container before
284
+ starting the new one, so two containers never write the same data — expect a
285
+ short outage on every deploy. Backups are crash-consistent (the container is
286
+ paused while it is copied) and need an artifact store configured on the
287
+ deployment; without one the backup commands report that they are unavailable.
288
+
289
+ **Staying up to date**
290
+
291
+ The CLI keeps itself in step with the platform. On start it checks — at most
292
+ every 12 hours, with a 2.5 s network timeout, never failing your command — the
293
+ npm registry for the latest `@inquir/compute-cli` and the API for the minimum
294
+ version it still supports (`GET /v1/cli/version`). When a newer version exists
295
+ and the CLI is a global npm install running in an interactive terminal, it
296
+ updates itself and re-runs your command; in CI, under `--json`, without a TTY,
297
+ via `npx` or from a source checkout it only prints a one-line notice. If the
298
+ API's *minimum* is not met, the command stops with the exact fix instead of
299
+ failing later on a changed wire contract.
300
+
301
+ - `inquir upgrade` - update now (`--check` only reports).
302
+ - Opt out: `inquir config set autoUpdate false`, `INQUIR_NO_AUTO_UPDATE=1`, or `--no-update` on one command.
303
+
304
+ **Diagnostics & config**
305
+
306
+ - `inquir doctor` - diagnose environment, credentials, and API connectivity (`--json` for a report).
307
+ - `inquir config [show|get <key>|set <key> <value>|path]` - view/edit CLI configuration.
308
+ - `inquir help [command]` - show grouped help, or help for one command.
309
+
310
+ **Platform operators**
311
+
312
+ - `inquir admin cluster [status|hold|release|move <memberId>|host register|grant <host> <capability>|revoke <host> <capability>]` -
313
+ the multi-master control plane (docs/roadmap/R4_MULTI_MASTER.md §6.2). It authenticates with the platform admin token in
314
+ `INQUIR_ADMIN_TOKEN`, never with your login; changes need the full token and land in the admin audit log.
315
+ - `inquir admin allocations relocate <allocationId> --reason <text> [--target <runnerId>]` - move one serving replica
316
+ make-before-break: its replacement starts (on the target, which must pass every placement filter and have room), takes
317
+ the traffic, and only then is the replica stopped. Pinned, volume, preview and TCP-pinned replicas are refused, as is an
318
+ application in a deployment handoff. `inquir admin allocations relocation <operationId>` shows where it is. Same token.
319
+
320
+ ### `deploy` flags
321
+
322
+ ```bash
323
+ inquir deploy hello # package + async deploy, stream build logs
324
+ inquir deploy hello --stage staging # target a deploy stage (alias: --environment)
325
+ inquir deploy hello --set KEY=val --set OTHER=val # set environment variables (repeatable)
326
+ inquir deploy hello --env-file .env.production # load env vars from a dotenv file
327
+ inquir deploy hello --memory 512 --timeout 60000 # memory (MB) / timeout (ms)
328
+ inquir deploy hello --layer <layerId> --layer <id2> # deprecated: attach layers (repeatable)
329
+ inquir deploy hello --no-logs # queue and wait for completion without streaming
330
+ inquir deploy hello --ci # plain output, non-zero exit on failure (for CI)
331
+ inquir deploy hello --dry-run # validate + package only; no create/deploy
332
+ inquir deploy hello --json # machine-readable result
333
+ ```
334
+
335
+ > Deprecated: `--layer`. Layers are being replaced by `build.dependencies` in
336
+ > `inquir.yaml`, the same key and shape for every runtime; a function has one
337
+ > runtime, so its list holds entries of that runtime only
338
+ > (see https://inquir.org/docs/inquir-yaml):
339
+ >
340
+ > ```yaml
341
+ > # inquir.yaml of a Node.js function: name@version
342
+ > build:
343
+ > dependencies:
344
+ > - "zod@3.23.8"
345
+ > ```
346
+ >
347
+ > ```yaml
348
+ > # inquir.yaml of a Python function: a pip requirement
349
+ > build:
350
+ > dependencies:
351
+ > - "requests==2.32.3"
352
+ > ```
353
+ >
354
+ > Layers already attached keep working. While the platform reports the deprecation, a
355
+ > new `--layer` attachment works and the CLI prints a warning; once it enforces it, the
356
+ > deploy is refused with `LAYERS_DEPRECATED`.
357
+
358
+ > Note: `--env` selects a named **credential environment** from your config; `--stage`
359
+ > (alias `--environment`) selects the **deploy stage** (production/staging/preview). They
360
+ > are different — don't confuse them.
361
+
362
+ ## Global Flags
363
+
364
+ Global flags work in **any position** (before or after the command) and accept both
365
+ `--flag value` and `--flag=value`:
366
+
367
+ - `--json` - machine-readable output (implies no color).
368
+ - `--debug` - verbose diagnostics + stack traces (also `INQUIR_DEBUG=1`).
369
+ - `--quiet` - suppress status chatter (errors + requested results only).
370
+ - `--no-color` - disable ANSI color (also honoured: `NO_COLOR`, `FORCE_COLOR`).
371
+ - `--yes`, `-y` - assume "yes" for confirmations (required for destructive ops in CI).
372
+ - `--cwd <path>` - run as if from this directory (alias: `--config`, which also accepts a config file path).
373
+ - `--env <name>` - select a named credential environment from the config.
374
+ - `--workspace <slug|id>` - target a specific workspace for this command (user-scoped login).
375
+ - `--api-url <url>` - override the API base URL.
376
+ - `--token <pat>` - use a Personal Access Token (non-interactive / CI).
377
+
378
+ ```bash
379
+ inquir run hello --cwd ./services/api
380
+ inquir --workspace acme-prod deploy hello
381
+ ```
382
+
383
+ ## Exit codes
384
+
385
+ | Code | Meaning |
386
+ |------|---------|
387
+ | `0` | success |
388
+ | `1` | runtime error (build failed, not found, server error) |
389
+ | `2` | usage / validation error (bad flags, missing args) |
390
+ | `3` | network / timeout |
391
+ | `4` | authentication required / forbidden |
392
+ | `130` | interrupted (Ctrl+C / SIGINT) |
393
+
394
+ A bare `Ctrl+C` aborts cleanly — the CLI prints `Aborted (SIGINT).` to stderr and
395
+ exits `130`, leaving stdout untouched (safe for piping) and no stack trace.
396
+
397
+ With `--json`, errors are emitted as a structured envelope on stdout:
398
+
399
+ ```json
400
+ { "ok": false, "error": { "code": "AUTH_REQUIRED", "title": "You are not logged in", "message": "…", "requestId": "…" } }
401
+ ```
402
+
403
+ ## CI usage
404
+
405
+ In CI / non-TTY, the CLI never prompts; supply credentials via env and use `--ci`/`--yes`:
406
+
407
+ ```bash
408
+ export INQUIR_TOKEN="$INQUIR_PAT" # or INQUIR_API_KEY for a workspace key
409
+ export INQUIR_WORKSPACE="acme-prod" # optional: target workspace
410
+ inquir deploy hello --ci --json
411
+ ```
412
+
413
+ In GitHub Actions, run the CLI with `npx --yes @inquir/compute-cli@<version>` after
414
+ `actions/setup-node` (Node.js 22) and pass the token from the repository secrets:
415
+ `inquir deploy ./functions/hello --ci` for a function, or
416
+ `inquir apps deploy web --dir . --promote` for a container application (promotion
417
+ needs the token of a workspace owner or admin). The docs page
418
+ https://inquir.org/docs/ci-cd has complete workflows.
419
+
420
+ ## Payload Input
421
+
422
+ `run` and `invoke` support:
423
+
424
+ - `--payload '{"k":"v"}'`
425
+ - `--payload-file ./payload.json`
426
+ - stdin piping
427
+
428
+ Shell quoting differs by platform. To pass inline JSON:
429
+
430
+ ```bash
431
+ # macOS / Linux (bash, zsh) — single-quote the JSON:
432
+ inquir invoke hello --payload '{"name":"World"}'
433
+ ```
434
+
435
+ ```powershell
436
+ # Windows PowerShell — single-quote the JSON:
437
+ inquir invoke hello --payload '{"name":"World"}'
438
+ ```
439
+
440
+ ```bat
441
+ :: Windows cmd.exe — escape the inner double quotes:
442
+ inquir invoke hello --payload "{\"name\":\"World\"}"
443
+ ```
444
+
445
+ When quoting gets awkward (especially on Windows), prefer `--payload-file ./payload.json`
446
+ or pipe via stdin: `type payload.json | inquir invoke hello`.
447
+
448
+ ## Remote Auth / Environment
449
+
450
+ The CLI resolves each credential field independently, in this order (first match
451
+ wins):
452
+
453
+ 1. CLI flags (`--api-url`, `--token`, `--workspace`) / `--env <name>` selection
454
+ 2. Environment variables (`LAMBDA_*` are legacy fallbacks):
455
+ - `INQUIR_API_URL`, `INQUIR_API_KEY`
456
+ - `INQUIR_TOKEN` — a Personal Access Token (takes precedence over `apiKey`)
457
+ - `INQUIR_WORKSPACE` — active workspace (slug or id)
458
+ - `INQUIR_ENV` — pick a named environment
459
+ 3. Selected environment in the config file
460
+ 4. Project link — `workspace` in the local `inquir.config.json` (set by `inquir use --local`); applies to the workspace only, below flags/env
461
+ 5. Top-level config file values (credentials and workspace only when the named environment uses the same API)
462
+ 6. Default `apiUrl` of `https://api.inquir.org` (override with env/config for local dev)
463
+
464
+ A named environment with its own different API does not inherit the default
465
+ token, API key, cached identity, or workspace. Partial profiles using the same API
466
+ can still inherit defaults. Explicit flags and environment variables keep the
467
+ precedence above. An unknown environment name fails before a remote command;
468
+ `inquir login --env <name>` can create it.
469
+
470
+ When login changes the default API, existing named profiles that inherited that
471
+ API and contain credentials, a workspace, or cached identity retain their previous
472
+ API binding. Their stored credentials are preserved. A profile that previously
473
+ inherited its credentials may need its own login after this change. Empty profiles
474
+ continue to inherit defaults. Changing a profile's API also removes its stored API
475
+ key, so logging out of the new PAT cannot reactivate a key from the previous API.
476
+
477
+ When both a `token` (PAT) and an `apiKey` are present, the PAT wins. The active
478
+ `workspaceId` is only applied to user-scoped credentials (PAT/session); for a
479
+ workspace-scoped API key it is ignored unless you pass `--workspace` explicitly.
480
+
481
+ Config file locations:
482
+
483
+ - `~/.inquir/config.json` (preferred, written by `inquir login` / `use`; saved with `0600` permissions)
484
+ - `~/.lambda-cli/config.json` (legacy fallback — **credentials only**; the legacy `apiUrl` is intentionally ignored so you aren't silently pinned to `localhost`)
485
+
486
+ Credential updates use an atomic file replacement and an exclusive
487
+ `~/.inquir/config.json.lock` while updating or revoking a session. A timed-out lock
488
+ is never stolen from a running command. If a command crashed and subsequent commands
489
+ report `AUTH_CONFIG_LOCKED`, stop all CLI commands before removing that lock file.
490
+ Older CLI versions do not participate in this locking protocol; avoid running old
491
+ and new versions concurrently against the same configuration.
492
+
493
+ Example (written/managed by `inquir login`, `inquir use`, `inquir logout`):
494
+
495
+ ```json
496
+ {
497
+ "apiUrl": "https://api.inquir.org",
498
+ "token": "inq_pat_…",
499
+ "workspaceId": "acme-prod",
500
+ "user": { "id": "…", "email": "you@example.com", "name": "You" },
501
+ "environments": {
502
+ "staging": {
503
+ "apiUrl": "https://staging.example.com",
504
+ "apiKey": "staging-key"
505
+ }
506
+ }
507
+ }
508
+ ```
509
+
510
+ ## Troubleshooting
511
+
512
+ Start with `inquir doctor` — it checks the CLI/Node version, config file, credential,
513
+ API connectivity + latency, active workspace, and local project, and prints a fix for any
514
+ failing check.
515
+
516
+ | Symptom | Likely cause / fix |
517
+ |---------|--------------------|
518
+ | `You are not logged in` (exit 4) | No credential resolved. Run `inquir login`, or set `INQUIR_TOKEN`/`INQUIR_API_KEY` in CI. |
519
+ | `Permission denied` (exit 4) | Wrong workspace or insufficient role. Check `inquir whoami`; switch with `inquir use`. |
520
+ | `Not found` for a function | Wrong name or workspace. `inquir list --remote` to see what exists in the active workspace. |
521
+ | Commands hit `localhost` unexpectedly | A stale `apiUrl` in config/env. Check `inquir config show`; override with `--api-url` or `INQUIR_API_URL`. |
522
+ | Network error (exit 3) | Can't reach the API. Verify connectivity and `--api-url`; re-run `inquir doctor`. |
523
+ | Garbled output in logs/CI | Disable color with `--no-color` or `NO_COLOR=1` (color auto-disables when not a TTY and in `--json`). |
524
+ | Need raw detail for a failure | Re-run with `--debug` for stack traces and the response body (secrets are redacted). |
525
+
526
+ ## Publishing to npm (maintainers)
527
+
528
+ The CLI (`@inquir/compute-cli`) depends on the SDK (`@inquir/compute`), so the
529
+ SDK must be published **first** at a version satisfying the CLI's dependency
530
+ range (`dependencies["@inquir/compute"]`, `^0.4.0` for CLI 0.4.0). Set the lower
531
+ bound to the first SDK release containing every API the CLI imports. A workspace
532
+ build uses the local SDK and cannot prove that an older published SDK works.
533
+
534
+ Release order for 0.4.0: CLI 0.4.0 imports `isPromoteAccepted` and
535
+ `getApplicationRollout` (the background promote, `inquir apps promote`), which
536
+ SDK 0.3.0 does not export. Publish SDK 0.4.0 first and confirm it on the
537
+ registry; a CLI published against SDK 0.3.0 would fail at startup.
538
+
539
+ Next release (CLI 0.4.1): the CLI imports `listAppInstances` and
540
+ `matchAppInstance` (`inquir apps instances`, `--replica`), which SDK 0.4.0 does
541
+ not export, and `createSourceArchive`, `manifestBuildContext` (source
542
+ uploads that honour the build context's .dockerignore/.inquirignore and keep
543
+ secret-like files out) and `getProductionReplacement` (the replacement phase
544
+ while a redeploy waits), which SDK 0.4.1 does not export; its dependency
545
+ floor is `^0.4.2`. Publish SDK 0.4.2 first and
546
+ confirm it on the registry, then the CLI.
547
+
548
+ Release after that (the CLI after 0.4.1; its version is bumped together with
549
+ the published command snapshot, `frontend/src/pages/Docs/cliCommandHelp.json`):
550
+ `inquir apps domain <app> '*.example.com' --yes`
551
+ passes `acknowledgeWildcardRisks` as the new fourth argument of
552
+ `addApplicationDomain`. SDK 0.4.2 accepts the call but silently drops the
553
+ argument, so the server answers 400 `DOMAIN_WILDCARD_NOT_ACKNOWLEDGED`; the
554
+ dependency floor is `^0.4.3`. Publish SDK 0.4.3 first and confirm it on the
555
+ registry, then the CLI.
556
+
557
+ New `inquir init` scaffolds inherit this SDK range and require Node.js 22+.
558
+ Existing `package.json` files are preserved; update their dependencies explicitly
559
+ when adopting a newer SDK.
560
+
561
+ Prerequisites:
562
+
563
+ - An npm account with publish access to the `@inquir` scope (create the org/scope on npmjs.com), then `npm login`.
564
+ - Both packages declare `"publishConfig": { "access": "public" }`, so scoped packages publish publicly.
565
+ - Both packages build before packing or publishing from source. The SDK includes
566
+ `dist/`; the CLI includes `dist/` and its bundled `skill/`. npm also includes
567
+ package metadata and README files.
568
+ - Choose unused release versions, update the CLI's SDK dependency and the lockfile,
569
+ then run the SDK and CLI tests before preparing the release candidate.
570
+
571
+ Prepare the exact tarballs from the repo root:
572
+
573
+ ```bash
574
+ # Cleans and builds the SDK first, then the CLI.
575
+ npm run build --workspace @inquir/compute-cli
576
+ # Reuse the verified build instead of rebuilding during packing.
577
+ npm pack --workspace @inquir/compute --ignore-scripts
578
+ npm pack --workspace @inquir/compute-cli --ignore-scripts
579
+ ```
580
+
581
+ Install both tarballs into a temporary directory outside this repository. Check
582
+ `npm ls @inquir/compute`, `inquir --version`, `inquir --help`, project commands,
583
+ and a local TypeScript function run. Resolve packages from that installation,
584
+ without workspace links, so the smoke test exercises the files users receive.
585
+
586
+ Publish those tested tarballs in order (0.3.0 shown; use the chosen versions):
587
+
588
+ ```bash
589
+ npm publish ./inquir-compute-0.3.0.tgz --access public
590
+ # Confirm this SDK version is available from the registry before publishing CLI.
591
+ npm view @inquir/compute@0.3.0 version
592
+ npm publish ./inquir-compute-cli-0.3.0.tgz --access public
593
+ ```
594
+
595
+ After building, preview package contents without publishing with
596
+ `npm pack --dry-run --json --ignore-scripts --workspace @inquir/compute-cli`.
597
+ `--ignore-scripts` skips build hooks, so only use it after the explicit build.
598
+ The installed command is `inquir`, from `dist/index.js` with its Node shebang.
599
+ After publishing, users can install it with:
600
+
601
+ ```bash
602
+ npm install -g @inquir/compute-cli@latest
603
+ inquir --help
604
+ ```
605
+ ## Application observability
606
+
607
+ Read actual resource history for every release and replica, or HTTP gateway measurements:
608
+
609
+ ```sh
610
+ inquir apps metrics api --since 6h
611
+ inquir apps metrics api --since 30d --json
612
+ inquir apps metrics api --http --since 1d --json
613
+ ```
614
+
615
+ The resource table shows the latest point per replica in the selected window. JSON contains all returned points, their enforced CPU/RAM limits, network transfer rates, disk I/O rates and deployment markers. `null` means the measurement is unavailable; it is not zero. Disk I/O measures reads/writes, not occupied volume space. HTTP measurements cover gateway requests, including request counts, 5xx errors, response bytes and latency percentiles. Resource and HTTP history is retained for 30 days; resource points older than a day are rolled up to one per five minutes, and older than a week to one per hour, each keeping the bucket's last point plus its CPU and memory peak and mean. Inspect `status`, `latestSampleAt` and `truncated` in resource JSON before interpreting a range as current or complete.
616
+
617
+ Ask what the CPU and memory figures could be, from what the production replicas actually used:
618
+
619
+ ```sh
620
+ inquir apps resources recommend api
621
+ inquir apps resources recommend api --days 3 --json
622
+ ```
623
+
624
+ The recommendation is read-only. Memory is 1.2 × the peak working set in the window (default 7 days), at least 64 MB, at least 256 MB for a database, and never below the peak of the whole 30-day history plus 10%. The CPU limit follows the peak (1.5 ×, at least 0.1 vCPU); the reserved request shown is what the platform would reserve for that limit, next to the request the 95th percentile of five-minute averages alone would justify. A recommendation needs 24 hours of observed usage; `confidence` reports the days observed and the samples behind it, and `--json` adds each release (replica set) seen in the window. Apply one yourself with `inquir apps update api --memory <mb> --cpu <vcpus>` and `inquir apps redeploy api`.
625
+
626
+ Persisted container logs remain readable after the container is replaced. Select an app and optionally an exact release or runtime identity:
627
+
628
+ ```sh
629
+ inquir apps log-history api --since 1h --level error --json
630
+ inquir apps logs api --history --release <release-id> --replica <allocation-id> --allocation-fence 4
631
+ inquir apps log-history api --since 1h --replica api-1-b1b1b1b1 # a name or index from apps instances
632
+ inquir apps log-history api --runner <runner-id> --runner-epoch 0 --container <full-container-id>
633
+ inquir apps log-history api --http --since 7d --status 503 --search /api --json
634
+ ```
635
+
636
+ History returns one page, newest first. Runtime retention is 7 days; HTTP retention is 30 days. Use `--limit` (up to 200 runtime rows or 500 HTTP rows) and `--cursor` for older pages. Always reuse the response's `from` and `to` as `--from`/`--to`, plus the same filters, when using a cursor. `apps logs api` without `--history` still follows the current release; `apps logs <build-id>` still reads build output.
637
+
638
+ Configure alert rules using JSON files or stdin. Destinations are write-only and are omitted from command output:
639
+
640
+ ```sh
641
+ inquir apps alerts api list --json
642
+ inquir apps alerts api create --file cpu-alert.json
643
+ inquir apps alerts api update <rule-id> --file patch.json
644
+ inquir apps alerts api incidents --limit 25 --json
645
+ inquir apps alerts api delete <rule-id>
646
+ ```
647
+
648
+ Example `cpu-alert.json` (incident-only until a notification destination is configured):
649
+
650
+ ```json
651
+ {
652
+ "name": "High CPU",
653
+ "enabled": true,
654
+ "metric": "cpu_percent",
655
+ "threshold": 85,
656
+ "forSeconds": 120,
657
+ "recoveryThreshold": 65,
658
+ "recoveryForSeconds": 60,
659
+ "noDataSeconds": 180,
660
+ "noData": "alert",
661
+ "channels": []
662
+ }
663
+ ```
664
+
665
+ Use `memory_percent` for RAM or `deployment_failed` for failed production deployments. CPU/RAM rules evaluate the continuous maximum across current production replicas; the hot replica can change during the hold period. Percentage thresholds refer to each container's enforced limit. For deployment events, timing and threshold fields do not control the failure trigger. Notification channels have the shape `{"type":"webhook","url":"https://your-endpoint.example/alerts"}` or `{"type":"slack","url":"https://hooks.slack.com/..."}`. Keep secret URLs in a file outside version control, or pipe JSON to `--file -`. The server must have secret encryption configured to accept notification channels.
666
+
667
+ A patch such as `{"threshold":90}` keeps existing destinations. `{"channels":[]}` removes them. Deleting a rule disables it and resolves active incidents while preserving retained history. Incident results include notification delivery state and retry counts. All commands honor the existing `--workspace`, `--env`, `--api-url` and credential selection rules.