@inquir/compute-cli 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/README.md +223 -114
  2. package/dist/commands/admin-tenants.d.ts +11 -0
  3. package/dist/commands/admin-tenants.d.ts.map +1 -0
  4. package/dist/commands/admin-tenants.js +318 -0
  5. package/dist/commands/admin-tenants.js.map +1 -0
  6. package/dist/commands/admin.d.ts +2 -0
  7. package/dist/commands/admin.d.ts.map +1 -0
  8. package/dist/commands/admin.js +445 -0
  9. package/dist/commands/admin.js.map +1 -0
  10. package/dist/commands/apps-describe.d.ts +9 -0
  11. package/dist/commands/apps-describe.d.ts.map +1 -0
  12. package/dist/commands/apps-describe.js +118 -0
  13. package/dist/commands/apps-describe.js.map +1 -0
  14. package/dist/commands/apps-observability.d.ts +9 -0
  15. package/dist/commands/apps-observability.d.ts.map +1 -0
  16. package/dist/commands/apps-observability.js +281 -0
  17. package/dist/commands/apps-observability.js.map +1 -0
  18. package/dist/commands/apps-promote.d.ts +31 -0
  19. package/dist/commands/apps-promote.d.ts.map +1 -0
  20. package/dist/commands/apps-promote.js +115 -0
  21. package/dist/commands/apps-promote.js.map +1 -0
  22. package/dist/commands/apps-resources.d.ts +6 -0
  23. package/dist/commands/apps-resources.d.ts.map +1 -0
  24. package/dist/commands/apps-resources.js +107 -0
  25. package/dist/commands/apps-resources.js.map +1 -0
  26. package/dist/commands/apps.d.ts +25 -2
  27. package/dist/commands/apps.d.ts.map +1 -1
  28. package/dist/commands/apps.js +434 -66
  29. package/dist/commands/apps.js.map +1 -1
  30. package/dist/commands/config.d.ts.map +1 -1
  31. package/dist/commands/config.js +7 -3
  32. package/dist/commands/config.js.map +1 -1
  33. package/dist/commands/delete.d.ts.map +1 -1
  34. package/dist/commands/delete.js +10 -2
  35. package/dist/commands/delete.js.map +1 -1
  36. package/dist/commands/login.d.ts.map +1 -1
  37. package/dist/commands/login.js +78 -33
  38. package/dist/commands/login.js.map +1 -1
  39. package/dist/commands/logout.d.ts.map +1 -1
  40. package/dist/commands/logout.js +37 -5
  41. package/dist/commands/logout.js.map +1 -1
  42. package/dist/commands/mcp.d.ts +13 -0
  43. package/dist/commands/mcp.d.ts.map +1 -1
  44. package/dist/commands/mcp.js +184 -77
  45. package/dist/commands/mcp.js.map +1 -1
  46. package/dist/commands/projects.d.ts.map +1 -1
  47. package/dist/commands/projects.js +107 -11
  48. package/dist/commands/projects.js.map +1 -1
  49. package/dist/index.js +9 -1
  50. package/dist/index.js.map +1 -1
  51. package/dist/lib/finite-source-command-client.d.ts +3 -0
  52. package/dist/lib/finite-source-command-client.d.ts.map +1 -0
  53. package/dist/lib/finite-source-command-client.js +3 -0
  54. package/dist/lib/finite-source-command-client.js.map +1 -0
  55. package/dist/lib/mcp-io.d.ts +23 -0
  56. package/dist/lib/mcp-io.d.ts.map +1 -0
  57. package/dist/lib/mcp-io.js +185 -0
  58. package/dist/lib/mcp-io.js.map +1 -0
  59. package/dist/lib/mcp-source-commands.d.ts +17 -0
  60. package/dist/lib/mcp-source-commands.d.ts.map +1 -0
  61. package/dist/lib/mcp-source-commands.js +345 -0
  62. package/dist/lib/mcp-source-commands.js.map +1 -0
  63. package/dist/utils/api.d.ts +19 -10
  64. package/dist/utils/api.d.ts.map +1 -1
  65. package/dist/utils/api.js +22 -4
  66. package/dist/utils/api.js.map +1 -1
  67. package/dist/utils/apps-presentation.d.ts +1 -1
  68. package/dist/utils/apps-presentation.d.ts.map +1 -1
  69. package/dist/utils/apps-presentation.js +10 -0
  70. package/dist/utils/apps-presentation.js.map +1 -1
  71. package/dist/utils/auth.d.ts +21 -1
  72. package/dist/utils/auth.d.ts.map +1 -1
  73. package/dist/utils/auth.js +119 -22
  74. package/dist/utils/auth.js.map +1 -1
  75. package/dist/utils/browser.d.ts +12 -0
  76. package/dist/utils/browser.d.ts.map +1 -1
  77. package/dist/utils/browser.js +37 -16
  78. package/dist/utils/browser.js.map +1 -1
  79. package/dist/utils/package-metadata.js +1 -1
  80. package/dist/utils/project-context.d.ts.map +1 -1
  81. package/dist/utils/project-context.js +7 -5
  82. package/dist/utils/project-context.js.map +1 -1
  83. package/dist/utils/project-lookup.d.ts +10 -0
  84. package/dist/utils/project-lookup.d.ts.map +1 -0
  85. package/dist/utils/project-lookup.js +52 -0
  86. package/dist/utils/project-lookup.js.map +1 -0
  87. package/package.json +10 -10
  88. package/skill/SKILL.md +9 -3
@@ -0,0 +1,52 @@
1
+ import { ApiError } from '../sdk.js';
2
+ import { getProject, listProjects } from './api.js';
3
+ import { CliError, ExitCode } from './errors.js';
4
+ /** A lookup by name reads the project list; bounded like the other list scans. */
5
+ const MAX_PROJECT_LIST_PAGES = 20;
6
+ export function isNotFound(error) {
7
+ return error instanceof ApiError && error.status === 404;
8
+ }
9
+ async function projectsNamed(name, apiOptions) {
10
+ const byId = new Map();
11
+ let cursor;
12
+ for (let page = 0; page < MAX_PROJECT_LIST_PAGES; page++) {
13
+ const result = await listProjects({ limit: 100, cursor }, apiOptions);
14
+ for (const project of result.items)
15
+ byId.set(project.id, project);
16
+ if (!result.nextCursor || result.nextCursor === cursor)
17
+ break;
18
+ cursor = result.nextCursor;
19
+ }
20
+ const projects = [...byId.values()];
21
+ const exact = projects.filter((project) => project.name === name);
22
+ if (exact.length > 0)
23
+ return exact;
24
+ const folded = name.toLocaleLowerCase();
25
+ return projects.filter((project) => project.name.toLocaleLowerCase() === folded);
26
+ }
27
+ /**
28
+ * A project by the id or slug the API takes, or by its display name — the
29
+ * only thing the dashboard shows. A name is tried only after the API answered
30
+ * 404, so an id or slug always wins, and only a unique one is accepted.
31
+ */
32
+ export async function resolveProject(selector, apiOptions) {
33
+ try {
34
+ return await getProject(selector, apiOptions);
35
+ }
36
+ catch (error) {
37
+ if (!isNotFound(error))
38
+ throw error;
39
+ const named = await projectsNamed(selector, apiOptions);
40
+ if (named.length === 1)
41
+ return getProject(named[0].id, apiOptions);
42
+ if (named.length > 1) {
43
+ throw new CliError(`Several projects are named '${selector}'`, {
44
+ code: 'AMBIGUOUS_PROJECT',
45
+ exitCode: ExitCode.USAGE,
46
+ fix: `Use the slug of the one you mean: ${named.map((project) => project.slug).join(', ')}`,
47
+ });
48
+ }
49
+ throw error;
50
+ }
51
+ }
52
+ //# sourceMappingURL=project-lookup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-lookup.js","sourceRoot":"","sources":["../../src/utils/project-lookup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAoC,MAAM,WAAW,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,YAAY,EAA0B,MAAM,UAAU,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEjD,kFAAkF;AAClF,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAElC,MAAM,UAAU,UAAU,CAAC,KAAc;IACvC,OAAO,KAAK,YAAY,QAAQ,IAAI,KAAK,CAAC,MAAM,KAAK,GAAG,CAAC;AAC3D,CAAC;AAED,KAAK,UAAU,aAAa,CAAC,IAAY,EAAE,UAA6B;IACtE,MAAM,IAAI,GAAG,IAAI,GAAG,EAAmB,CAAC;IACxC,IAAI,MAA0B,CAAC;IAC/B,KAAK,IAAI,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,sBAAsB,EAAE,IAAI,EAAE,EAAE,CAAC;QACzD,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,UAAU,CAAC,CAAC;QACtE,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,KAAK;YAAE,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QAClE,IAAI,CAAC,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC,UAAU,KAAK,MAAM;YAAE,MAAM;QAC9D,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC;IAC7B,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AAI,CAAC,EAAE;aAC5F,CAAC,CAAC;QACL,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inquir/compute-cli",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "description": "Workspace-first CLI for Inquir Compute.",
6
6
  "bin": {
@@ -12,19 +12,19 @@
12
12
  ],
13
13
  "scripts": {
14
14
  "clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\"",
15
- "build": "npm run clean && npm --prefix ../.. run build --workspace @inquir/compute && tsc -p tsconfig.json",
15
+ "build": "npm run clean && npm --prefix ../.. run build --workspace @inquir/compute && tsc -p tsconfig.json",
16
16
  "build:self": "tsc -p tsconfig.json",
17
- "prepack": "npm run build",
17
+ "prepack": "npm run build",
18
18
  "test": "npx vitest run -c vitest.config.ts"
19
19
  },
20
- "publishConfig": {
21
- "access": "public"
22
- },
23
- "engines": {
24
- "node": ">=22"
25
- },
20
+ "publishConfig": {
21
+ "access": "public"
22
+ },
23
+ "engines": {
24
+ "node": ">=22"
25
+ },
26
26
  "dependencies": {
27
- "@inquir/compute": "^0.3.0",
27
+ "@inquir/compute": "^0.4.0",
28
28
  "tsx": "^4.19.2"
29
29
  },
30
30
  "devDependencies": {
package/skill/SKILL.md CHANGED
@@ -37,7 +37,7 @@ Overrides when detection guesses wrong: `--runtime`, `--handler <module.export>`
37
37
 
38
38
  ## Databases (Postgres / Redis)
39
39
 
40
- - `inquir apps create mydb --template postgres|redis` — one command from nothing to a running database: image, persistent volume, pinned public TCP port, generated password, first release.
40
+ - `inquir apps create mydb --template postgres|redis` — one command from nothing to a running database: image, persistent volume, private TCP port, generated password, first release. `--volume-runner <runner>` puts it on a worker; that needs the operator's mirror of the template image, and the refusal (`APP_TEMPLATE_IMAGE_NOT_MIRRORED`) says so.
41
41
  - `inquir apps connect mydb web` — writes the connection URL into another app's env as `DATABASE_URL` / `REDIS_URL`; applies on that app's next release. Prefer this: the password never passes through you.
42
42
  - `inquir apps connection-url mydb` — prints the live URL with credentials in it (and into shell history); use only when the consumer is not an app on the platform.
43
43
  - `inquir apps backups mydb [list|create|restore <id>|delete <id>]` — volume snapshots. `restore` **overwrites the volume** and stops the app while it runs; it asks for confirmation, so non-interactively it needs `--yes`.
@@ -48,15 +48,21 @@ Register once: `claude mcp add inquir -- inquir mcp`
48
48
 
49
49
  - `deploy {path, name?, start?, env?}` — detect + deploy a directory; returns detection reasons, deploy status, and error logs on failure.
50
50
  - `invoke {function, payload}` — run a function and get result + logs.
51
- - `exec {function, command, target?}` — run a shell command inside the function's container (its runtime image + code). `target: "source"` (default) is read-write: use it for installing deps, running tests, debugging.
51
+ - `exec {function, command, requestId, target?}` — submit an asynchronous command against a private source snapshot. Before calling, generate and retain one lowercase UUID v4 `requestId` per intent. A repeated UUID only observes; it never creates another execution. Finite execution must be enabled on the server; an unavailable response never falls back to writable published source. `target: "release"` uses the existing read-only release execution and needs no UUID.
52
+ - `source_command_status {requestId, waitMs?}` — read execution state/output; optional bounded GET polling. An interrupted wait does not cancel execution or release capacity.
53
+ - `source_command_reconcile {requestId}` — explicitly apply retained output if the original source is still current. Inspect `APPLIED`, `CONFLICT`, or `workspaceFailure`; never automatically rerun a command after conflict.
54
+ - `source_command_cancel {requestId}` — request durable cancellation. `CANCEL_REQUESTED` is intent, not a stopped-container receipt; `PUBLICATION_COMMITTED` means cancellation is too late.
55
+ - `source_command_resume {requestId, action: "status" | "submit"}` — reload the privately retained operation after restart. Use `status` first; `submit` explicitly retries the same saved bytes and UUID after an uncertain submission. Resume requires the same API, credential and workspace. Records contain command/env secrets and no credentials; preserve the CLI user profile's private filesystem permissions. Optional `inquir mcp --source-session <stable-conversation-id>` also binds JSON-RPC request IDs across reconnects; do not reuse that namespace for unrelated conversations.
52
56
  - `list_invocations {function}` — recent runs with errors and logs: the debugging entry point.
53
57
  - `deploy_status {deployId}`, `rollback {function, deployId}`, `list_functions`.
54
58
 
59
+ The stdio server admits four working calls, including at most one deploy/rollback, plus two source-control or deploy-status calls. A busy response starts no work; retain the source UUID when retrying. Ping and cancellation notifications remain available while work waits. Each input frame is limited to 64 KiB. HTTP responses are limited to 2 MiB for source commands and 4 MiB otherwise, with a 60-second timeout per request including body reads. Output waits for the reader, retaining at most sixteen replies or 8 MiB; a broken or stalled pipe closes observation. Disconnecting never sends a job cancellation.
60
+
55
61
  ## Debug loop that works
56
62
 
57
63
  1. `deploy` → read `deploy.error` and status.
58
64
  2. If failing at runtime: `list_invocations` → read logs.
59
- 3. Reproduce inside the container: `exec {command: "npm test"}` or `exec {command: "python -c '...'"}`.
65
+ 3. Submit a source command with a retained UUID, then read `source_command_status`. Review output before explicitly reconciling source changes. For a read-only release check use `exec {function: "my-function", command: "npm test", target: "release"}`.
60
66
  4. Fix code locally, `deploy` again. Deploys are versioned; `rollback` restores any previous success.
61
67
 
62
68
  ## Contracts that matter