@sequenceholdings/studio-cli 0.7.1 → 0.7.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.
package/README.md CHANGED
@@ -56,7 +56,7 @@ inspect `truncated` and pagination metadata where present.
56
56
  # In a process or artifact repo (devDependency, using pnpm — see below):
57
57
  pnpm add -D @sequenceholdings/studio-cli @sequenceholdings/lattice
58
58
 
59
- # Or globally (ORM commands need the in-repo install; see "ORM commands"):
59
+ # Or globally:
60
60
  pnpm add -g @sequenceholdings/studio-cli
61
61
  ```
62
62
 
@@ -248,8 +248,15 @@ locations, dependencies, and deployment selection.
248
248
  | `seq-studio init <dir> [--with <kinds>] [--skip-install]` | Scaffold a version 3 app, root pnpm workspace, shared package, README, and selected primitives; by default creates ORM, function, process, and artifact primitives, installs dependencies, and authors the first ORM migration |
249
249
  | `seq-studio add <kind> <name> [--depends-on <ids>] [--template <t>]` | Add any primitive, including additional ORM namespaces and UIs |
250
250
  | `seq-studio add package <name>` | Add a shared TypeScript package to the manifest and pnpm workspace |
251
+ | `seq-studio validate [--dir <path>] [--json]` | Offline check of the app manifest, dependency graph, contained primitive directories, and resolved member refs |
251
252
  | `seq-studio deploy -e <env> [--yes] [--only id1,id2] [--dry-run]` | Validate and deploy the selected app graph, including prerequisites |
252
253
 
254
+ `seq-studio validate` works before a legacy repository is adopted: it needs no
255
+ login or environment and lists existing members such as process refs. It does
256
+ not verify that remote members exist or that primitive-specific source can
257
+ deploy. `seq-studio deploy --dry-run` still requires the repository identity
258
+ receipt and performs its existing deployment preflight.
259
+
253
260
  `init` accepts `orm`, `workspace`, `function`, `agent`, `process`, `pipeline`, and `artifact` as
254
261
  a comma-separated `--with` list or boolean flags (`--agent --process`). With no
255
262
  kind flags it scaffolds `orm,function,process,artifact`. Repository CI/CD
@@ -851,6 +858,7 @@ compiled to canonical SQL before registration.
851
858
  | `seq-studio orm execute <operation> [dir] --variables-file <file> -e <env>` | Execute one named persisted operation as hashed in this checkout's `operations.manifest.json`, with variables from a JSON object file, as the signed-in caller. |
852
859
  | `seq-studio orm namespaces -e <env> [--limit N] [--offset N] [--json]` | List the namespaces you can read. |
853
860
  | `seq-studio orm describe <namespace> [<table> \| --operations] -e <env> [--json]` | Show a namespace's tables, views, and persisted operations (with their variables), only its operations, or one table's columns, actions, and the operations that write it. |
861
+ | `seq-studio orm operation show <namespace> <name> -e <env> [--json]` | Show the active persisted operation's registered GraphQL document; JSON also includes its hash and declared variables. Requires namespace read access. |
854
862
  | `seq-studio orm read <namespace> <table> -e <env> [--where …] [--select …] [--order …] [--limit N] [--offset N] [--json\|--jsonl]` | Read rows of a deployed v2 namespace's table as the caller. |
855
863
  | `seq-studio orm sql <namespace> --query <sql> \| --file <path> -e <env> [--param …] [--json\|--jsonl]` | Run read-only SQL against a deployed v2 namespace as the caller. |
856
864
  | `seq-studio orm migrate-from-yaml <dir>` | Convert a legacy YAML namespace to TypeScript authoring while preserving its committed migrations. |
@@ -874,8 +882,9 @@ pnpm exec seq-studio orm apply . -e local
874
882
  pnpm exec seq-studio orm validate .
875
883
  ```
876
884
 
877
- A globally installed CLI can't run ORM commands under pnpm 11: pnpm 11 isolates
878
- global packages, and `drizzle-kit` imports `drizzle-orm` without declaring it.
885
+ Global ORM commands require a CLI release that declares `drizzle-orm` directly.
886
+ Older releases can fail during module loading because `drizzle-kit` imports
887
+ `drizzle-orm` without declaring it. Update the global CLI if you see that error.
879
888
 
880
889
  `apply --dry-run` rehearses a migration against a disposable branch copy of
881
890
  the target environment's data. `apply --no-create` is the CI guard that refuses
@@ -902,6 +911,7 @@ seq-studio orm namespaces -e <env> --limit 20 --offset 20 --json
902
911
  seq-studio orm describe lending -e <env> # tables, views, persisted operations
903
912
  seq-studio orm describe lending --operations -e <env> # operations, requirements, variables
904
913
  seq-studio orm describe lending loans -e <env> # columns, enum values, links, actions
914
+ seq-studio orm operation show lending ListLoans -e <env> --json # active document and hash
905
915
  ```
906
916
 
907
917
  - `namespaces` lists only namespaces you can read, ordered by name, with their
@@ -918,6 +928,11 @@ seq-studio orm describe lending loans -e <env> # columns, enum values, links
918
928
  - Each persisted operation lists the variables it declares as `name: type`, with
919
929
  `!` when required and `= value` for a default. `--operations` prints only the
920
930
  operations.
931
+ - `operation show` reads one active operation through the namespace reader gate.
932
+ Without `--json` it prints the registered GraphQL document. `--json` includes
933
+ the document, hash, variables, and requirements for contract review. Missing
934
+ and unreadable operations return the same not-found result. It does not run
935
+ the operation or read rows.
921
936
 
922
937
  ### Running a deployed operation (`orm execute <namespace> <operation>`)
923
938
 
@@ -1168,6 +1183,7 @@ functions cannot opt in retroactively. The default remains mutable. See the
1168
1183
  | `seq-studio functions deploy --dir <dir> -e <env>` | Preview secrets and deploy a local function |
1169
1184
  | `seq-studio functions build --repo managed-functions/<name> [--path <dir>] -e <env>` | Materialize and validate a function from the platform Git Service |
1170
1185
  | `seq-studio functions deploy --repo managed-functions/<name> [--path <dir>] -e <env>` | Materialize and deploy a function from the platform Git Service |
1186
+ | `seq-studio functions show --fn <slug> -e <env> --json [--version <id-or-name>]` | Inspect reader-gated active release provenance and optionally select an exact submitted version |
1171
1187
  | `seq-studio functions limits [-e <env>] [--json] [--fn <slug>]` | Inspect fleet, runtime, cache, and bundle defaults/caps; optionally inspect one function's effective runtime limits |
1172
1188
  | `seq-studio functions invoke --fn <slug> -e <env> [--data <json> \| --data @<file> \| --stdin]` | Invoke a deployed function and print its response body |
1173
1189
 
@@ -1175,6 +1191,17 @@ functions cannot opt in retroactively. The default remains mutable. See the
1175
1191
  that function. Versions named by repository CI, such as `ci-abc`, do not reset
1176
1192
  the sequence. A function with no numbered versions starts at `v1`.
1177
1193
 
1194
+ After an upload is accepted, `functions show --fn <slug> -e <env> --json` returns
1195
+ the server's `activeVersionId`, `immutableRelease`, exact active version, and
1196
+ version history with status, Git revision and dirty bit, and source digest.
1197
+ Use `--version <id-or-name>` to include `selectedVersion` for a submitted
1198
+ release, even while another version is active. Missing provenance on older
1199
+ version records appears as `null`; an environment that does not expose release
1200
+ identity fails the inspection. Reader access is required. If a deploy poll
1201
+ loses transport after upload acceptance, inspect the accepted version's status
1202
+ and compare its ID with `activeVersionId` before deciding what to do next.
1203
+ Do not resubmit the deployment solely because its poll disconnected.
1204
+
1178
1205
  To select an existing secret version before the first deployment, declare its
1179
1206
  name in `managed-function.yml`, then register and pin before uploading code:
1180
1207
 
@@ -1924,11 +1951,18 @@ New repositories created on identity-capable Atlas releases contain a committed
1924
1951
 
1925
1952
  The platform owns `identity`. Tenant ownership comes from the hosting
1926
1953
  deployment, not the creator's organization, repository name, remote URL, or
1927
- editable file. Renaming a repository does not change its ID. Staging and
1928
- production share a tenant; this file intentionally does not select an environment.
1954
+ editable file. Renaming a repository does not change its ID. A tenant's staging
1955
+ and production deployments share a tenant; this file intentionally does not
1956
+ select an environment.
1929
1957
  Separate hosted repositories still have distinct IDs: copying this file does
1930
1958
  not register a mirror or authorize promotion.
1931
1959
 
1960
+ Environment names alone are not tenant identities; the platform resolves the
1961
+ owner from the hosting deployment configuration. Correcting a deployment's
1962
+ owner mapping does not rewrite identities already issued to repositories; an
1963
+ old mismatched receipt still fails deployment admission and needs explicit
1964
+ platform reconciliation, not a hand-edited receipt or a cross-tenant exception.
1965
+
1932
1966
  `metadata` is an extensible JSON object for non-secret annotations (for example,
1933
1967
  `{"example.com": {"team": "engineering"}}`). Prefer namespaced keys for tools.
1934
1968
  It is never an authorization or deployment-routing input. The whole file is
@@ -2834,4 +2868,4 @@ load the page or the installed feedback skill.
2834
2868
 
2835
2869
  ### Planned verified service policy support
2836
2870
 
2837
- The unpublished Studio CLI 0.7.0 release chain carries ORM 2.7.0. Namespace policies using `servicePrincipal()` require the matching deployed IR v6 runtime. Before registration, `orm apply` checks authenticated target protocol support and refuses an unavailable or older runtime. The chain uses Artifact Studio 0.10.0, Managed Functions 0.4.4 and Pipeline Spec 0.3.0. Pipeline Spec 0.3.0 and Studio CLI 0.7.0 remain awaiting publication; package versions alone do not prove rollout. The existing `workspace:*` consumer dependencies resolve to ORM 2.7.0 when the reviewed chain is packed.
2871
+ The unpublished Studio CLI 0.7.0 release chain carries ORM 2.7.1. Namespace policies using `servicePrincipal()` require the matching deployed IR v6 runtime. Before registration, `orm apply` checks authenticated target protocol support and refuses an unavailable or older runtime. Artifact Studio 0.10.1, Managed Functions 0.4.5 and Pipeline Spec 0.3.0 remain awaiting publication in this same chain; package versions alone do not prove rollout. The existing `workspace:*` consumer dependencies resolve to ORM 2.7.1 when the reviewed chain is packed.
@@ -7,7 +7,9 @@
7
7
  import type { ParsedArgs } from '../process/commands.js';
8
8
  export declare const APP_INIT_USAGE: string;
9
9
  export declare const APP_ADD_USAGE: string;
10
- export declare const APP_DEPLOY_USAGE = "usage:\n seq-studio deploy -e <env> [options]\n\n Requires a platform repository clone with an adopted identity and a matching\n .seq/identity.json committed on the selected server. Checked before any\n primitive runs, including --dry-run; there is no legacy bypass.\n\n Deploy the app declared in sequence.app.yml. Versions 2 and 3 use\n depends_on prerequisites; deploy.order optionally orders ready primitives.\n Runs each kind's existing command:\n orm \u2192 seq-studio orm apply <path> -e <env>\n function \u2192 seq-studio functions deploy --dir <path> -e <env> [--yes]\n agent \u2192 seq-studio agents apply --dir <path> -e <env> [--yes], config-only (access stays in Atlas)\n process \u2192 seq-studio process apply --dir <path> -e <env>\n pipeline \u2192 seq-studio pipeline deploy --repo <repo> --ref <ref> -e <env>\n artifact \u2192 seq-studio artifact deploy <path> -e <env>\n\n Options:\n -e, --env <name> target environment (required)\n --dir <path> app root (default: cwd; must contain sequence.app.yml)\n --only <id1,id2> deploy these ids and their prerequisites (v2)\n --yes non-interactive (forwarded to primitive commands)\n --dry-run validate/compile selected sources without deploying (v2)\n --approved-by <sub> recorded caller approval for protected pipeline targets\n --wait-timeout <d> pipeline polling timeout, e.g. 10m or 2h\n\n Examples:\n seq-studio deploy -e staging --yes\n seq-studio deploy -e local --only get-pokemon --yes\n seq-studio deploy --dir ./pokedex -e staging --dry-run\n\n Run from the app root (directory with sequence.app.yml), or pass --dir.\n Version 1 manifests keep their existing ordering and exact --only behavior.\n Pipelines require repo and ref in their manifest entry.\n ORM namespaces require generated code and a reviewed migration ledger:\n seq-studio orm generate <path> && seq-studio orm diff <path>\n Commit generated migrations before the first deployment and schema changes.\n Repository admission reads the remote receipt at HEAD; all dry-runs need\n network/auth. Version 1 dry-run only lists after that check.\n A dry-run never opens a browser login: sign in beforehand. It warns,\n rather than fails, when the\n artifact source is not committed and clean on main.\n Version 2 writes the result to .sequence/deployments/<environment>.json.\n";
10
+ export declare const APP_DEPLOY_USAGE = "usage:\n seq-studio deploy -e <env> [options]\n\n Requires a platform repository clone with an adopted identity and a matching\n .seq/identity.json committed on the selected server. Checked before any\n primitive runs, including --dry-run; there is no legacy bypass.\n\n Deploy the app declared in sequence.app.yml. Versions 2 and 3 use\n depends_on prerequisites; deploy.order optionally orders ready primitives.\n Runs each kind's existing command:\n orm \u2192 seq-studio orm apply <path> -e <env>\n function \u2192 seq-studio functions deploy --dir <path> -e <env> [--yes]\n agent \u2192 seq-studio agents apply --dir <path> -e <env> [--yes], config-only (access stays in Atlas)\n process \u2192 seq-studio process apply --dir <path> -e <env>\n pipeline \u2192 seq-studio pipeline deploy --repo <repo> --ref <ref> -e <env>\n artifact \u2192 seq-studio artifact deploy <path> -e <env>\n\n Options:\n -e, --env <name> target environment (required)\n --dir <path> app root (default: cwd; must contain sequence.app.yml)\n --only <id1,id2> deploy these ids and their prerequisites (v2)\n --yes non-interactive (forwarded to primitive commands)\n --dry-run validate/compile selected sources without deploying (v2)\n --approved-by <sub> recorded caller approval for protected pipeline targets\n --wait-timeout <d> pipeline polling timeout, e.g. 10m or 2h\n\n Examples:\n seq-studio deploy -e staging --yes\n seq-studio deploy -e local --only get-pokemon --yes\n seq-studio deploy --dir ./pokedex -e staging --dry-run\n\n Run from the app root (directory with sequence.app.yml), or pass --dir.\n Version 1 manifests keep their existing ordering and exact --only behavior.\n Pipelines require repo and ref in their manifest entry.\n ORM namespaces require generated code and a reviewed migration ledger:\n seq-studio orm generate <path> && seq-studio orm diff <path>\n Commit generated migrations before the first deployment and schema changes.\n Repository admission reads the remote receipt at HEAD; all dry-runs need\n network/auth. Version 1 dry-run only lists after that check.\n For offline manifest, graph, path, and member checks before adoption, use\n `seq-studio validate`.\n A dry-run never opens a browser login: sign in beforehand. It warns,\n rather than fails, when the\n artifact source is not committed and clean on main.\n Version 2 writes the result to .sequence/deployments/<environment>.json.\n";
11
+ export declare const APP_VALIDATE_USAGE = "usage:\n seq-studio validate [--dir <path>] [--json]\n\n Validate sequence.app.yml, its dependency graph, and primitive directories\n locally. List resolved Application members, including existing process refs.\n No environment, login, repository adoption, or network access is required.\n This checks local structure only; it does not validate remote member existence,\n primitive-specific source, or authorize deployment. Deploy still requires a\n matching repository identity receipt.\n\n Options:\n --dir <path> app root (default: cwd)\n --json print structured validation result\n";
12
+ export declare function runAppValidateCommand(args: ParsedArgs): Promise<number>;
11
13
  /**
12
14
  * Hosted Next.js apps deploy only where the deployment runs the Next.js
13
15
  * runtime, which not every deployment does yet; the server then refuses with
@@ -8,6 +8,7 @@ import { basename, resolve } from 'node:path';
8
8
  import { parseDurationMs } from '@sequenceholdings/lattice';
9
9
  import { REQUIRE_EXPLICIT_ENV_MESSAGE, explicitOrSandboxEnv } from '../env-flags.js';
10
10
  import { deployApp } from './deploy.js';
11
+ import { validateAppLocal } from './validate.js';
11
12
  import { DEFAULT_APP_KINDS, resolveRequestedKinds } from './kinds.js';
12
13
  import { AppPreparationError, prepareScaffoldedApp } from './prepare.js';
13
14
  import { planRepositoryDeclaration, REPOSITORY_INDEX_PATH, writeRepositoryDeclaration } from './repository-index.js';
@@ -121,11 +122,61 @@ export const APP_DEPLOY_USAGE = `usage:
121
122
  Commit generated migrations before the first deployment and schema changes.
122
123
  Repository admission reads the remote receipt at HEAD; all dry-runs need
123
124
  network/auth. Version 1 dry-run only lists after that check.
125
+ For offline manifest, graph, path, and member checks before adoption, use
126
+ \`seq-studio validate\`.
124
127
  A dry-run never opens a browser login: sign in beforehand. It warns,
125
128
  rather than fails, when the
126
129
  artifact source is not committed and clean on main.
127
130
  Version 2 writes the result to .sequence/deployments/<environment>.json.
128
131
  `;
132
+ export const APP_VALIDATE_USAGE = `usage:
133
+ seq-studio validate [--dir <path>] [--json]
134
+
135
+ Validate sequence.app.yml, its dependency graph, and primitive directories
136
+ locally. List resolved Application members, including existing process refs.
137
+ No environment, login, repository adoption, or network access is required.
138
+ This checks local structure only; it does not validate remote member existence,
139
+ primitive-specific source, or authorize deployment. Deploy still requires a
140
+ matching repository identity receipt.
141
+
142
+ Options:
143
+ --dir <path> app root (default: cwd)
144
+ --json print structured validation result
145
+ `;
146
+ export async function runAppValidateCommand(args) {
147
+ if (args.flags.help === true || args.flags.h === true) {
148
+ console.log(APP_VALIDATE_USAGE);
149
+ return 0;
150
+ }
151
+ try {
152
+ if (args.positional.length > 0)
153
+ throw new Error('unexpected arguments; use --dir for the app root');
154
+ for (const [flag, value] of Object.entries(args.flags)) {
155
+ if (flag === 'dir' && typeof value === 'string' && value.trim())
156
+ continue;
157
+ if (flag === 'json' && value === true)
158
+ continue;
159
+ throw new Error(flag === 'dir' ? '--dir requires a value' : `unknown option --${flag}`);
160
+ }
161
+ const result = await validateAppLocal({ rootDir: resolve(flagString(args.flags, 'dir') ?? process.cwd()) });
162
+ if (args.flags.json === true) {
163
+ console.log(JSON.stringify(result, null, 2));
164
+ }
165
+ else {
166
+ console.log(`${LOG} app "${result.app}" manifest valid (${result.primitives.length} primitive(s), ${result.members.length} member(s))`);
167
+ for (const entry of result.primitives)
168
+ console.log(`${LOG} - ${entry.kind} ${entry.id} (${entry.path})`);
169
+ for (const member of result.members)
170
+ console.log(`${LOG} - member ${member.kind} ${member.id} -> ${member.ref}`);
171
+ console.log(`${LOG} local validation only; deployment still requires repository admission`);
172
+ }
173
+ return 0;
174
+ }
175
+ catch (error) {
176
+ printError(error);
177
+ return 1;
178
+ }
179
+ }
129
180
  function pipelineTypeFlag(flags) {
130
181
  const value = flags['pipeline-type'];
131
182
  if (value === undefined)
@@ -0,0 +1,16 @@
1
+ export declare function validateAppLocal({ rootDir }: {
2
+ rootDir: string;
3
+ }): Promise<{
4
+ app: string;
5
+ schemaVersion: 1 | 2 | 3;
6
+ primitives: {
7
+ id: string;
8
+ kind: "function" | "process" | "artifact" | "pipeline" | "orm" | "agent" | "workspace";
9
+ path: string;
10
+ }[];
11
+ members: {
12
+ id: string;
13
+ kind: string;
14
+ ref: string;
15
+ }[];
16
+ }>;
@@ -0,0 +1,40 @@
1
+ /** Local app manifest, graph, path, and member checks without deployment admission. */
2
+ import { stat } from 'node:fs/promises';
3
+ import { resolve } from 'node:path';
4
+ import { buildApplicationDeployBody } from './application-registration.js';
5
+ import { resolveDeployEntries } from './deploy.js';
6
+ import { loadAppManifest } from './manifest.js';
7
+ import { resolveContainedPrimitivePath } from './paths.js';
8
+ export async function validateAppLocal({ rootDir }) {
9
+ const root = resolve(rootDir);
10
+ const manifest = await loadAppManifest(root);
11
+ const entries = resolveDeployEntries({ manifest });
12
+ for (const entry of entries) {
13
+ const path = await resolveContainedPrimitivePath({ rootDir: root, entryPath: entry.path });
14
+ let info;
15
+ try {
16
+ info = await stat(path);
17
+ }
18
+ catch (error) {
19
+ if (error.code === 'ENOENT') {
20
+ throw new Error(`sequence.app.yml: primitive "${entry.id}" directory does not exist: ${entry.path}`);
21
+ }
22
+ throw error;
23
+ }
24
+ if (!info.isDirectory()) {
25
+ throw new Error(`sequence.app.yml: primitive "${entry.id}" path is not a directory: ${entry.path}`);
26
+ }
27
+ }
28
+ return {
29
+ app: manifest.app.id,
30
+ schemaVersion: manifest.schema_version,
31
+ primitives: entries.map(({ id, kind, path }) => ({ id, kind, path })),
32
+ // Use the same local member projection as Application registration. The
33
+ // server's "lattice" member kind is called "process" in the CLI.
34
+ members: buildApplicationDeployBody(manifest).members.map(({ key, kind, ref }) => ({
35
+ id: key,
36
+ kind: kind === 'lattice' ? 'process' : kind,
37
+ ref,
38
+ })),
39
+ };
40
+ }
@@ -22,6 +22,8 @@ export declare class AtlasApiError extends Error {
22
22
  readonly name = "AtlasApiError";
23
23
  retryAfterSeconds: number | null;
24
24
  constructor(status: number, message: string, path: string, statusText?: string, body?: unknown);
25
+ /** The structured `error.code` (or top-level `code`) Atlas sent, if any. */
26
+ get code(): string | null;
25
27
  }
26
28
  /** Bounded single attempt for commands whose uncertain result must be reconciled by the caller. */
27
29
  export declare function requestJsonOnce({ baseUrl, token, path, method, body, }: ClientOptions & {
@@ -8,6 +8,7 @@ import { authenticatedRequestUrl } from '@sequenceholdings/artifact-studio/deplo
8
8
  import { validationDetail } from './validation-detail.js';
9
9
  import { PREVIEW_DOMAIN } from './preview.js';
10
10
  import { sandboxBearerFor } from './sandbox-auth.js';
11
+ import { errorCode, isTransient503 } from './transient-503.js';
11
12
  const MAX_503_RETRIES = 5;
12
13
  const DEFAULT_RETRY_AFTER_SECONDS = 2;
13
14
  const LOG_PREFIX = '[seq-studio]';
@@ -26,6 +27,10 @@ export class AtlasApiError extends Error {
26
27
  this.statusText = statusText;
27
28
  this.body = body;
28
29
  }
30
+ /** The structured `error.code` (or top-level `code`) Atlas sent, if any. */
31
+ get code() {
32
+ return errorCode(this.body);
33
+ }
29
34
  }
30
35
  async function fetchWith503Retry(input, init) {
31
36
  let attempt = 0;
@@ -33,6 +38,9 @@ async function fetchWith503Retry(input, init) {
33
38
  const response = await fetch(input, init);
34
39
  if (response.status !== 503 || attempt >= MAX_503_RETRIES)
35
40
  return response;
41
+ const body = parseErrorBody(await response.clone().text(), response.headers.get('content-type') ?? '');
42
+ if (!isTransient503(body))
43
+ return response;
36
44
  const retryAfter = Number(response.headers.get('Retry-After')) || DEFAULT_RETRY_AFTER_SECONDS;
37
45
  attempt += 1;
38
46
  console.warn(`${LOG_PREFIX} backend warming up (503); retrying in ${retryAfter}s (attempt ${attempt}/${MAX_503_RETRIES})`);
package/dist/bin.js CHANGED
@@ -15,6 +15,7 @@ const doctorOffline = argv[0] === 'doctor' && (() => {
15
15
  const value = parseArgs(argv.slice(1)).flags.offline;
16
16
  return value === true || value === 'true';
17
17
  })();
18
+ const isOfflineCommand = argv[0] === 'validate' || doctorOffline;
18
19
  run(argv)
19
20
  .catch((error) => {
20
21
  console.error(error instanceof Error ? error.message : error);
@@ -23,7 +24,7 @@ run(argv)
23
24
  // The update notice runs after the command so it never delays real output,
24
25
  // and it is best-effort (never throws, never changes the exit code).
25
26
  .then(async (code) => {
26
- if (!isHelpOrDiscovery && !doctorOffline && !(argv[0] === 'auth' && argv[1] === 'git-credential')) {
27
+ if (!isHelpOrDiscovery && !isOfflineCommand && !(argv[0] === 'auth' && argv[1] === 'git-credential')) {
27
28
  const { maybeNotifyUpdate } = await import('./update-check.js');
28
29
  await maybeNotifyUpdate();
29
30
  }
@@ -34,6 +34,12 @@ export function clarifyApplyFailureReason(reason) {
34
34
  }
35
35
  return reason;
36
36
  }
37
+ function nextStepFor503(error) {
38
+ if (error.code === 'storage_configuration') {
39
+ return 'Next step: this Atlas has no storage bucket configured. For a local Atlas, restart it with `make dev-all` from `atlas/` (it provisions dev storage); for a deployed environment, ask its operator to configure storage.';
40
+ }
41
+ return 'Next step: wait a few seconds and retry (backend may still be warming up).';
42
+ }
37
43
  function nextStepForAtlasError(error) {
38
44
  const msg = error.message.toLowerCase();
39
45
  if (error.status === 401) {
@@ -53,9 +59,8 @@ function nextStepForAtlasError(error) {
53
59
  return 'Next step: reduce the request size and retry; pipeline query accepts up to 10,000 SQL characters.';
54
60
  return 'Next step: run `seq-studio functions build` and reduce bundle size or dependencies.';
55
61
  }
56
- if (error.status === 503) {
57
- return 'Next step: wait a few seconds and retry (backend may still be warming up).';
58
- }
62
+ if (error.status === 503)
63
+ return nextStepFor503(error);
59
64
  if (error.status === 524 || msg.includes('timeout') || msg.includes('timed out')) {
60
65
  if (error.path.startsWith('/api/data-pipelines/'))
61
66
  return 'Next step: retry the read; if it persists, confirm the environment and backend availability.';
@@ -11,6 +11,12 @@ export declare const COMMAND_CONTRACT: readonly [{
11
11
  readonly lifecycle: "preview";
12
12
  readonly access: "offline";
13
13
  readonly subcommands: readonly [];
14
+ }, {
15
+ readonly name: "validate";
16
+ readonly description: "Validate an app manifest, graph, paths, and members offline";
17
+ readonly lifecycle: "preview";
18
+ readonly access: "offline";
19
+ readonly subcommands: readonly [];
14
20
  }, {
15
21
  readonly name: "deploy";
16
22
  readonly description: "Deploy an app workspace";
@@ -2,6 +2,7 @@
2
2
  export const COMMAND_CONTRACT = [
3
3
  { name: 'init', description: 'Scaffold an app workspace or use a published template', lifecycle: 'preview', access: 'mixed', subcommands: [] },
4
4
  { name: 'add', description: 'Add a primitive to an app workspace', lifecycle: 'preview', access: 'offline', subcommands: [] },
5
+ { name: 'validate', description: 'Validate an app manifest, graph, paths, and members offline', lifecycle: 'preview', access: 'offline', subcommands: [] },
5
6
  { name: 'deploy', description: 'Deploy an app workspace', lifecycle: 'preview', access: 'authenticated', subcommands: [] },
6
7
  { name: 'process', description: 'Build and operate Lattice processes', lifecycle: 'preview', access: 'mixed', subcommands: ['init', 'lint', 'plan', 'apply', 'test', 'simulate', 'bundle', 'promote', 'pull', 'runs', 'safety-baseline'] },
7
8
  { name: 'artifact', description: 'Build and operate Artifact Studio apps', lifecycle: 'stable', access: 'mixed', subcommands: ['init', 'whoami', 'link', 'env', 'status', 'list', 'show', 'validate', 'build', 'plan', 'deploy', 'dev', 'promote', 'pull', 'rollback'] },
@@ -1,13 +1,13 @@
1
1
  /** Help text reachable before command implementations, auth, optional SDKs, or Atlas clients load. */
2
- export declare const ORM_HELP = "usage:\n seq-studio orm init <dir>\n seq-studio orm generate [dir] [--migration-export] [--check]\n seq-studio orm validate [dir]\n seq-studio orm plan [dir] -e <env>\n seq-studio orm apply [dir] -e <env>\n seq-studio orm execute <namespace> <operation> -e <env> [--variables-file <file>] [--var <name>=<value>]...\n seq-studio orm execute <operation> [dir] --variables-file <file> -e <env>\n seq-studio orm namespaces -e <env> [--limit N] [--offset N] [--json]\n seq-studio orm describe <namespace> [<table> | --operations] -e <env> [--json]\n seq-studio orm read <namespace> <table> -e <env> [--where <column>=<op>.<value>]... [--select <cols>] [--order <col>[.desc]] [--limit N] [--offset N] [--json|--jsonl]\n seq-studio orm sql <namespace> --query <sql> | --file <path> -e <env> [--param <name>[:<type>]=<value>]... | [--params <json-object>] [--json|--jsonl]\n seq-studio orm diff [dir] [--check] [--allow-destructive] [--rebase]\n seq-studio orm migrate-from-yaml <dir>\n seq-studio orm import [dir] --spec <file> | --table <table> --from <schema.table> --map <target=source,...>\n\n -e/--env is required for commands that contact Atlas. Use seq-studio envs list\n to discover environments and seq-studio login to authenticate.\n namespaces lists what you can read; describe shows its tables and operations.\n Run seq-studio orm describe --help for the output.\n execute <namespace> <operation> runs the deployed version's persisted operation by\n name, with no checkout. Run seq-studio orm execute --help for both forms.\n read and sql query a v2 namespace as you through its built-in read-only SQL.\n sql must name tables as <namespace>.<table> (FROM lending.loans, not FROM loans).\n Run seq-studio orm read --help for the filter grammar, parameters, and output formats.\n";
2
+ export declare const ORM_HELP = "usage:\n seq-studio orm init <dir>\n seq-studio orm generate [dir] [--migration-export] [--check]\n seq-studio orm validate [dir]\n seq-studio orm plan [dir] -e <env>\n seq-studio orm apply [dir] -e <env>\n seq-studio orm execute <namespace> <operation> -e <env> [--variables-file <file>] [--var <name>=<value>]...\n seq-studio orm execute <operation> [dir] --variables-file <file> -e <env>\n seq-studio orm namespaces -e <env> [--limit N] [--offset N] [--json]\n seq-studio orm describe <namespace> [<table> | --operations] -e <env> [--json]\n seq-studio orm operation show <namespace> <name> -e <env> [--json]\n seq-studio orm read <namespace> <table> -e <env> [--where <column>=<op>.<value>]... [--select <cols>] [--order <col>[.desc]] [--limit N] [--offset N] [--json|--jsonl]\n seq-studio orm sql <namespace> --query <sql> | --file <path> -e <env> [--param <name>[:<type>]=<value>]... | [--params <json-object>] [--json|--jsonl]\n seq-studio orm diff [dir] [--check] [--allow-destructive] [--rebase]\n seq-studio orm migrate-from-yaml <dir>\n seq-studio orm import [dir] --spec <file> | --table <table> --from <schema.table> --map <target=source,...>\n\n -e/--env is required for commands that contact Atlas. Use seq-studio envs list\n to discover environments and seq-studio login to authenticate.\n namespaces lists what you can read; describe shows its tables and operations.\n Run seq-studio orm describe --help for the output.\n execute <namespace> <operation> runs the deployed version's persisted operation by\n name, with no checkout. Run seq-studio orm execute --help for both forms.\n read and sql query a v2 namespace as you through its built-in read-only SQL.\n sql must name tables as <namespace>.<table> (FROM lending.loans, not FROM loans).\n Run seq-studio orm read --help for the filter grammar, parameters, and output formats.\n";
3
3
  /** Artifact commands in sandbox token mode; shared by the offline and delegate usage. */
4
4
  export declare const ARTIFACT_SANDBOX_HELP = " In an agent sandbox (SEQ_STUDIO_BASE_URL + SEQ_STUDIO_TOKEN_FILE), build, plan\n and deploy take --repo: push the app to a Git Service repository and deploy\n from it. Atlas builds Next.js applications; static applications are bundled\n from the repository and must declare no package.json dependencies or\n optionalDependencies, because the sandbox cannot reach a package registry.\n dev, login, logout, --git-url, --source-env, --pr and --env-url are\n unavailable there, and -e is ignored.\n";
5
5
  export declare const ARTIFACT_HELP = "usage:\n seq-studio artifact init <dir> [--template react-vite|nextjs]\n seq-studio artifact whoami -e <env>\n seq-studio artifact link [dir] -e <env> [--project <id>]\n seq-studio artifact env list|use <env>\n seq-studio artifact status [-e <env>]\n seq-studio artifact list -e <env> [--json]\n seq-studio artifact show <slug-or-id> -e <env> [--json]\n seq-studio artifact validate [dir]\n seq-studio artifact build|plan|deploy [dir | --repo <namespace>/<name> | --git-url <url>] [--ref <ref>] -e <env>\n seq-studio artifact dev [dir] -e <env> [--once] [--key <name>] [--link <package-dir>] [--port <port>]\n seq-studio artifact pull <project-id> -e <env> --out <dir>\n seq-studio artifact promote|rollback <deployment-id> -e <env>\n\n Help is available offline. Authenticate with seq-studio login. Build and deploy\n sources may be local, a platform git-service repo, or a public HTTPS Git URL;\n deployments target a named environment with -e. Local, preview, and official\n deployment workflows have different source and approval rules; see the public\n CLI README.\n\n In an agent sandbox (SEQ_STUDIO_BASE_URL + SEQ_STUDIO_TOKEN_FILE), build, plan\n and deploy take --repo: push the app to a Git Service repository and deploy\n from it. Atlas builds Next.js applications; static applications are bundled\n from the repository and must declare no package.json dependencies or\n optionalDependencies, because the sandbox cannot reach a package registry.\n dev, login, logout, --git-url, --source-env, --pr and --env-url are\n unavailable there, and -e is ignored.\n";
6
6
  export declare const PIPELINE_HELP = "usage:\n seq-studio pipeline list -e <env> [--limit 1..200] [--offset N] [--json]\n list pipeline repository rollups (not assets)\n seq-studio pipeline assets -e <env> [--repo <namespace>/<slug>] [--json]\n list asset declarations, including assets that may not be deployed\n seq-studio pipeline search <query> -e <env> [--target <id>] [--repo <namespace>/<slug>] [--limit N] [--offset N] [--json]\n seq-studio pipeline describe <asset-id> -e <env> [--target <id>] [--repo <namespace>/<slug>] [--json]\n seq-studio pipeline schema|sample <asset-id> -e <env> [--target <id>] [--limit N] [--json]\n seq-studio pipeline query <asset-id> --sql <read-only-sql> -e <env> [--target <id>] [--limit N] [--json]\n seq-studio pipeline init|validate|plan|deploy|status|migrate|adopt|unbind|run-now|promote|rollback ...\n seq-studio pipeline plan|deploy --repo <namespace>/<slug> --ref <sha|branch>\n [--root <directory>] [--source-env <first-party-env>] -e <env> [--target <id>]\n For an existing target release unit, source-env selects a separately\n authenticated canonical repository from banksouth, staging, or production.\n Source identity must be adopted and belong to the destination tenant.\n Registered OpCo source origins are not supported yet. The target verifies\n and snapshots source before planning; no target repository is created.\n Not compatible with --dir, existing IDs, or coordinated migrations.\n Rollback uses retained snapshots; historical source commits can be re-planned\n explicitly with deploy --ref <sha> --source-env <env>.\n seq-studio pipeline plan --plan-request-id <id> -e <env> [--json]\n poll an existing durable plan without enqueueing or attaching credentials\n Lifecycle --json results use stdout; progress uses stderr. Deploy --run-now\n executes producers in the managed worker; local polling may disconnect.\n\n Discovery requires staff access. Use list for pipeline repositories, assets\n for declared assets, and search/describe for active deployment metadata;\n use schema to verify physical columns. -e chooses the environment and\n --target chooses a logical target when the environment has more than one.\n Help is available offline.\n";
7
- export declare const FUNCTIONS_USAGE = "usage:\n seq-studio functions init <dir> scaffold manifest, TypeScript handler, and docs pointers\n seq-studio functions build [--dir d] local pre-flight (manifest, lockfile, SDK timeout cap)\n seq-studio functions register -e <env> [--dir d] register a shell + initial secret declarations; no deploy\n seq-studio functions deploy -e <env> [-m msg] preflight, upload, then show version and lifecycle progress\n seq-studio functions list -e <env> [--match-local] functions visible on the environment\n seq-studio functions show -e <env> [--fn slug] detail for one function (versions, secrets)\n seq-studio functions limits [-e <env>] [--json] bundled defaults/caps, or deployed policy\n [--fn slug] also show effective runtime limits (requires -e)\n seq-studio functions dev [--dir path] [--port 8080] local HTTP server with cache context\n seq-studio functions invoke -e <env> [--data JSON | --data @file | --stdin]\n invoke a function and print its response\n seq-studio functions logs -e <env> [--limit N] [--since t] function logs (reader-gated)\n seq-studio functions promote <version> -e <env> make a version live\n seq-studio functions rollback [<version>] -e <env> redeploy a prior version\n seq-studio functions delete -e <env> [--yes] archive function + tear down its runtime\n (version history is retained)\n\n Flags: -e/--env <env|preview:<slug>> (required for network commands; see: seq-studio envs list) \u00B7 --fn <slug> \u00B7 --dir <path>\n --path <repo-subdirectory> (remote build/deploy only) select one function in a multi-function repo\n --from-env-file <path> (default: .env) source file for secret values\n --no-wait \u00B7 --yes\n --no-provision (deploy) update-only: error instead of registering a new\n shell, writing secret values, or attaching secrets (CI sweep)\n\n Local Atlas builds and runs deployed functions on this computer, including teardown.\n \"functions dev\" runs a standalone handler without Atlas registration.\n\n Configure per-function CPU and concurrency in managed-function.yml under limits.\n Run \"functions limits\" for valid settings; redeploy to apply manifest changes.\n Invocation rates are shared across Atlas replicas; 429 includes Retry-After.\n If the shared rate limiter is unavailable, invocation fails closed with 503.\n\n Source for build/deploy: a local --dir (default .), a platform git-service\n repo (--repo <ns>/<name>), or a public HTTPS git URL (--git-url <url>). --path selects\n a function directory within a remote repo; omit it for the existing root-manifest\n layout. --ref selects a branch/tag/commit (default: the repo's default branch).\n Remote sources record the pinned commit as provenance (never dirty) and NEVER\n read a repo-committed .env for secret values \u2014 provision secrets server-side\n or pass a local --from-env-file (resolved against your cwd).\n\n Interactive --repo builds clone over smart-HTTP using your seq-studio login\n and repository read access. No PAT is needed. Headless M2M builds use JSON\n materialize and accept only platform-managed --repo sources. Use --env to\n select the same environment for source and deployment.\n";
7
+ export declare const FUNCTIONS_USAGE = "usage:\n seq-studio functions init <dir> scaffold manifest, TypeScript handler, and docs pointers\n seq-studio functions build [--dir d] local pre-flight (manifest, lockfile, SDK timeout cap)\n seq-studio functions register -e <env> [--dir d] register a shell + initial secret declarations; no deploy\n seq-studio functions deploy -e <env> [-m msg] preflight, upload, then show version and lifecycle progress\n seq-studio functions list -e <env> [--match-local] functions visible on the environment\n seq-studio functions show -e <env> [--fn slug] detail for one function (versions, secrets)\n [--json] [--version id|name] reader-gated release provenance\n seq-studio functions limits [-e <env>] [--json] bundled defaults/caps, or deployed policy\n [--fn slug] also show effective runtime limits (requires -e)\n seq-studio functions dev [--dir path] [--port 8080] local HTTP server with cache context\n seq-studio functions invoke -e <env> [--data JSON | --data @file | --stdin]\n invoke a function and print its response\n seq-studio functions logs -e <env> [--limit N] [--since t] function logs (reader-gated)\n seq-studio functions promote <version> -e <env> make a version live\n seq-studio functions rollback [<version>] -e <env> redeploy a prior version\n seq-studio functions delete -e <env> [--yes] archive function + tear down its runtime\n (version history is retained)\n\n Flags: -e/--env <env|preview:<slug>> (required for network commands; see: seq-studio envs list) \u00B7 --fn <slug> \u00B7 --dir <path>\n --path <repo-subdirectory> (remote build/deploy only) select one function in a multi-function repo\n --from-env-file <path> (default: .env) source file for secret values\n --no-wait \u00B7 --yes\n --no-provision (deploy) update-only: error instead of registering a new\n shell, writing secret values, or attaching secrets (CI sweep)\n\n Local Atlas builds and runs deployed functions on this computer, including teardown.\n \"functions dev\" runs a standalone handler without Atlas registration.\n\n Configure per-function CPU and concurrency in managed-function.yml under limits.\n Run \"functions limits\" for valid settings; redeploy to apply manifest changes.\n Invocation rates are shared across Atlas replicas; 429 includes Retry-After.\n If the shared rate limiter is unavailable, invocation fails closed with 503.\n\n Source for build/deploy: a local --dir (default .), a platform git-service\n repo (--repo <ns>/<name>), or a public HTTPS git URL (--git-url <url>). --path selects\n a function directory within a remote repo; omit it for the existing root-manifest\n layout. --ref selects a branch/tag/commit (default: the repo's default branch).\n Remote sources record the pinned commit as provenance (never dirty) and NEVER\n read a repo-committed .env for secret values \u2014 provision secrets server-side\n or pass a local --from-env-file (resolved against your cwd).\n\n Interactive --repo builds clone over smart-HTTP using your seq-studio login\n and repository read access. No PAT is needed. Headless M2M builds use JSON\n materialize and accept only platform-managed --repo sources. Use --env to\n select the same environment for source and deployment.\n";
8
8
  export declare const REPOS_USAGE = "usage:\n seq-studio repos list -e <env> [--namespace <slug>] [--mine] repos visible on the environment\n seq-studio repos namespaces [create <slug>] -e <env> list or create namespaces\n seq-studio repos show <ns>/<name> -e <env> repo detail (branches, clone URL)\n seq-studio repos identity <ns>/<name> -e <env> [--write --dir .] show/install the server-issued identity receipt\n --adopt --write --yes admin-only legacy binding; commit the receipt via PR\n seq-studio repos create <ns>/<name> -e <env> [--default-branch b] [--git-backend walgit]\n create a repo seeded with a README; --git-backend\n walgit creates it empty (for pushing existing\n history); needs namespace write\n seq-studio repos clone <ns>/<name> -e <env> [--ref r] [--output dir] [--force] [--full] [--transport auto|git|json]\n seq-studio repos clone --url <https://\u2026/repos/<id>/git> -e <env> [--ref r] [--output dir] [--full]\n seq-studio repos clone --id <uuid> -e <env> [--ref r] [--output dir] [--full]\n real Git clone using seq-studio login;\n configures login for subsequent git pull/push\n seq-studio repos pull <ns>/<name> -e <env> [--ref r] [--out dir] [--force]\n materialize the tree at a ref (JSON API)\n seq-studio repos pulls <list|show|create|diff|merge|close|comment|comments|review|reviews|checks> [args]\n review requests (see pulls --help)\n seq-studio repos delete <ns>/<name> -e <env> [--yes] delete a repo (confirm prompt)\n seq-studio repos ci init [--dir <repository>] create a native pipeline using platform defaults\n seq-studio repos ci show <ns>/<name> -e <env> --pr <number> [--json] inspect the server CI plan and runs\n seq-studio repos ci show <ns>/<name> -e <env> [--ref r] preview pipeline discovery or legacy checks\n seq-studio repos ci require <ns>/<name> --check <name> -e <env> disabled legacy control\n seq-studio repos ci import <ns>/<name> -e <env> [--ref r] disabled legacy control\n\n Flags: -e/--env <env> (required; see: seq-studio envs list)\n\n clone uses your login token (never written into the remote URL or Git config).\n A repository-local credential helper reads your current login for git pull/push.\n After expiry, run seq-studio login --env <env> again.\n --transport auto (default) and git both create a real Git checkout.\n Personal access tokens are retired; ATLAS_GIT_PAT is ignored.\n --transport json downloads files without .git; requires\n <ns>/<name>. repos pull also provides this files-only workflow.\n --ref accepts a branch, tag, or commit SHA (SHA \u2192 full clone, then checkout).\n Branch and tag clones are shallow (--depth 1). Pass --full for history.\n --output selects the clone directory (--out remains an alias).\n\n Authenticate JSON API calls with: seq-studio login\n Authenticate git clone/push with: seq-studio login --env <env>\n";
9
9
  export declare const PROCESS_RUNS_USAGE = "usage:\n seq-studio process runs start <process-id> -e <env> [--version <v>] [--run-id <id>]\n [--metadata-file <file.json>] [--title <text>] [--entity <type>:<id>] [--json]\n seq-studio process runs list -e <env> [--process <id>] [--status <status>]\n [--entity-type <type>] [--entity-id <id>] [--archived] [--limit 1..500] [--json]\n seq-studio process runs show <run-id> -e <env> [--wait [--timeout <seconds>]] [--json]\n seq-studio process runs cancel <run-id> -e <env> [--json]\n\n Runs start and are read as you: start needs invoker on the process, show and\n list return only runs you can view, and cancel needs invoker on the process.\n --version pins a published process version; omitted, the active version runs.\n --run-id makes start idempotent: repeating it for the same process returns the\n existing run instead of starting another. --metadata-file is a JSON object\n stored on the run.\n list returns the newest runs first, up to --limit (default 50, max 500); the run\n API has no cursor, so narrow with filters to reach older runs.\n --status: pending, running, completed, failed, cancelled, timed_out.\n show --wait polls until the run finishes (default timeout 600s); the run keeps\n going if the wait times out.\n";
10
- export declare const ORM_DISCOVER_HELP = "usage:\n seq-studio orm namespaces -e <env> [--limit N] [--offset N] [--json]\n seq-studio orm describe <namespace> [<table> | --operations] -e <env> [--json]\n\n Find the ORM data you can read, then query it with orm read or orm sql.\n namespaces lists only namespaces you can read, ordered by name: format (v2 or\n v1), table and persisted-operation counts. It pages with --limit (default 50)\n and --offset; the total and the next page go to stderr.\n describe <namespace> lists its tables and views and the persisted operations\n it serves, with what each requires and the variables it declares (name: type,\n ! when required). --operations prints only the operations, ready for\n orm execute <namespace> <operation>. describe <namespace> <table> lists the\n table's columns (types, nullability, keys), enum values, links, actions, and\n the persisted operations that write it. Column names are the ones orm read and\n orm sql accept.\n A namespace you cannot read reports not found, the same as a missing one.\n --json prints the full description (describe omits the generated GraphQL SDL).\n In an agent sandbox (SEQ_STUDIO_BASE_URL + SEQ_STUDIO_TOKEN_FILE), -e is not needed.\n";
10
+ export declare const ORM_DISCOVER_HELP = "usage:\n seq-studio orm namespaces -e <env> [--limit N] [--offset N] [--json]\n seq-studio orm describe <namespace> [<table> | --operations] -e <env> [--json]\n seq-studio orm operation show <namespace> <name> -e <env> [--json]\n\n Find the ORM data you can read, then query it with orm read or orm sql.\n namespaces lists only namespaces you can read, ordered by name: format (v2 or\n v1), table and persisted-operation counts. It pages with --limit (default 50)\n and --offset; the total and the next page go to stderr.\n describe <namespace> lists its tables and views and the persisted operations\n it serves, with what each requires and the variables it declares (name: type,\n ! when required). --operations prints only the operations, ready for\n orm execute <namespace> <operation>. describe <namespace> <table> lists the\n table's columns (types, nullability, keys), enum values, links, actions, and\n the persisted operations that write it. Column names are the ones orm read and\n orm sql accept.\n A namespace you cannot read reports not found, the same as a missing one.\n --json prints the full description (describe omits the generated GraphQL SDL).\n operation show prints one active persisted operation's registered GraphQL\n document; --json includes its hash, declared variables, and requirements.\n Missing and unreadable operations both report not found.\n In an agent sandbox (SEQ_STUDIO_BASE_URL + SEQ_STUDIO_TOKEN_FILE), -e is not needed.\n";
11
11
  export declare const ORM_EXECUTE_HELP = "usage:\n seq-studio orm execute <namespace> <operation> -e <env> [--variables-file <file>] [--var <name>=<value>]...\n seq-studio orm execute <operation> [dir] --variables-file <file> -e <env>\n\n Run one persisted operation as you. The server applies the operation's\n required capability or role and the namespace's row policies.\n By name: execute <namespace> <operation> looks the operation up in the\n namespace's deployed version and runs it. No checkout is needed, so it runs\n what is deployed even when a local clone is behind. List what you can run:\n seq-studio orm describe <namespace> --operations\n From a checkout: execute <operation> [dir] runs the operation as hashed in the\n namespace directory's operations.manifest.json (default dir: .). If the\n deployed version hashes it differently, execute prints both hashes and the\n by-name command instead of a bare 404.\n The form is chosen by the second argument: an existing directory means a\n checkout; otherwise it is <namespace> <operation>.\n --variables-file takes a JSON object. --var <name>=<value> (repeatable, by\n name only) sets one variable and wins over the file: numbers and booleans\n parse by the declared type, lists, filter inputs and jsonb take JSON, and other\n types take the text as is. Use the file for null.\n Output is the JSON response: {\"data\": ...}.\n In an agent sandbox (SEQ_STUDIO_BASE_URL + SEQ_STUDIO_TOKEN_FILE), -e is not needed.\n";
12
12
  export declare function staticHelp({ namespace, sub }: {
13
13
  namespace: string;
@@ -9,6 +9,7 @@ export const ORM_HELP = `usage:
9
9
  seq-studio orm execute <operation> [dir] --variables-file <file> -e <env>
10
10
  seq-studio orm namespaces -e <env> [--limit N] [--offset N] [--json]
11
11
  seq-studio orm describe <namespace> [<table> | --operations] -e <env> [--json]
12
+ seq-studio orm operation show <namespace> <name> -e <env> [--json]
12
13
  seq-studio orm read <namespace> <table> -e <env> [--where <column>=<op>.<value>]... [--select <cols>] [--order <col>[.desc]] [--limit N] [--offset N] [--json|--jsonl]
13
14
  seq-studio orm sql <namespace> --query <sql> | --file <path> -e <env> [--param <name>[:<type>]=<value>]... | [--params <json-object>] [--json|--jsonl]
14
15
  seq-studio orm diff [dir] [--check] [--allow-destructive] [--rebase]
@@ -93,6 +94,7 @@ export const FUNCTIONS_USAGE = `usage:
93
94
  seq-studio functions deploy -e <env> [-m msg] preflight, upload, then show version and lifecycle progress
94
95
  seq-studio functions list -e <env> [--match-local] functions visible on the environment
95
96
  seq-studio functions show -e <env> [--fn slug] detail for one function (versions, secrets)
97
+ [--json] [--version id|name] reader-gated release provenance
96
98
  seq-studio functions limits [-e <env>] [--json] bundled defaults/caps, or deployed policy
97
99
  [--fn slug] also show effective runtime limits (requires -e)
98
100
  seq-studio functions dev [--dir path] [--port 8080] local HTTP server with cache context
@@ -197,6 +199,7 @@ export const PROCESS_RUNS_USAGE = `usage:
197
199
  export const ORM_DISCOVER_HELP = `usage:
198
200
  seq-studio orm namespaces -e <env> [--limit N] [--offset N] [--json]
199
201
  seq-studio orm describe <namespace> [<table> | --operations] -e <env> [--json]
202
+ seq-studio orm operation show <namespace> <name> -e <env> [--json]
200
203
 
201
204
  Find the ORM data you can read, then query it with orm read or orm sql.
202
205
  namespaces lists only namespaces you can read, ordered by name: format (v2 or
@@ -211,6 +214,9 @@ export const ORM_DISCOVER_HELP = `usage:
211
214
  orm sql accept.
212
215
  A namespace you cannot read reports not found, the same as a missing one.
213
216
  --json prints the full description (describe omits the generated GraphQL SDL).
217
+ operation show prints one active persisted operation's registered GraphQL
218
+ document; --json includes its hash, declared variables, and requirements.
219
+ Missing and unreadable operations both report not found.
214
220
  In an agent sandbox (SEQ_STUDIO_BASE_URL + SEQ_STUDIO_TOKEN_FILE), -e is not needed.
215
221
  `;
216
222
  export const ORM_EXECUTE_HELP = `usage:
@@ -27,9 +27,13 @@ export interface VersionSummary {
27
27
  id: string;
28
28
  functionId: string;
29
29
  version: string;
30
+ sourceHash?: string | null;
30
31
  status: string;
31
32
  statusDetail: string | null;
32
33
  deployMessage: string | null;
34
+ gitCommit?: string | null;
35
+ gitBranch?: string | null;
36
+ gitDirty?: boolean | null;
33
37
  createdAt: string;
34
38
  deployedAt: string | null;
35
39
  isActive: boolean;
@@ -955,11 +955,72 @@ async function printFunctionShowDetails({ ctx, fn, }) {
955
955
  egressEnforced: detail?.function.egressEnforced ?? fn.egressEnforced ?? false,
956
956
  });
957
957
  }
958
+ async function printFunctionReleaseJson(ctx, fn, selected) {
959
+ if (!fn.currentUserAccess) {
960
+ throw new Error('Release provenance requires read access to this function');
961
+ }
962
+ const detail = await getFunctionDetail(ctx, fn.id);
963
+ if (!detail)
964
+ throw new Error(`Function ${fn.slug} is no longer available on ${ctx.env.name}`);
965
+ const release = detail.function;
966
+ if (release.activeVersionId === undefined || typeof release.immutableRelease !== 'boolean') {
967
+ throw new Error('This environment does not expose activeVersionId and immutableRelease for release inspection');
968
+ }
969
+ const versions = await listVersions(ctx, fn.id);
970
+ const active = release.activeVersionId
971
+ ? versions.find((version) => version.id === release.activeVersionId)
972
+ : undefined;
973
+ if (release.activeVersionId && !active) {
974
+ throw new Error(`Active version ${release.activeVersionId} is missing from the version list; retry inspection`);
975
+ }
976
+ const selectedVersion = selected === undefined
977
+ ? undefined
978
+ : versions.find((version) => version.id === selected || version.version === selected);
979
+ if (selected !== undefined && !selectedVersion) {
980
+ throw new Error(`Version ${selected} was not found for ${fn.slug} on ${ctx.env.name}`);
981
+ }
982
+ const projectVersion = (version) => ({
983
+ id: version.id,
984
+ version: version.version,
985
+ status: version.status ?? null,
986
+ isActive: version.id === release.activeVersionId,
987
+ sourceHash: version.sourceHash ?? null,
988
+ gitCommit: version.gitCommit ?? null,
989
+ gitBranch: version.gitBranch ?? null,
990
+ gitDirty: version.gitDirty ?? null,
991
+ createdAt: version.createdAt ?? null,
992
+ deployedAt: version.deployedAt ?? null,
993
+ });
994
+ console.log(JSON.stringify({
995
+ environment: ctx.env.name,
996
+ function: {
997
+ id: release.id,
998
+ slug: release.slug,
999
+ title: release.title,
1000
+ deployed: release.deployed,
1001
+ activeVersionId: release.activeVersionId,
1002
+ immutableRelease: release.immutableRelease,
1003
+ },
1004
+ activeVersion: active ? projectVersion(active) : null,
1005
+ versions: versions.map(projectVersion),
1006
+ ...(selectedVersion ? { selectedVersion: projectVersion(selectedVersion) } : {}),
1007
+ }, null, 2));
1008
+ return 0;
1009
+ }
958
1010
  export async function functionsShowCommand(args) {
1011
+ const selected = args.flags.version;
1012
+ if (selected !== undefined && (typeof selected !== 'string' || !selected.trim())) {
1013
+ throw new Error('--version requires a version ID or name');
1014
+ }
1015
+ if (selected !== undefined && !flagBool(args.flags, 'json')) {
1016
+ throw new Error('--version requires --json');
1017
+ }
959
1018
  const ctx = await buildContext(args);
960
1019
  const fn = await resolveFunction({ ctx, args, required: true });
961
1020
  if (!fn)
962
1021
  return 1;
1022
+ if (flagBool(args.flags, 'json'))
1023
+ return printFunctionReleaseJson(ctx, fn, selected);
963
1024
  console.log(`${LOG} function on ${ctx.env.name}:`);
964
1025
  console.log(` id: ${fn.id}`);
965
1026
  console.log(` slug: ${fn.slug}`);
package/dist/main.js CHANGED
@@ -33,6 +33,7 @@ import { sandboxUsageFooter } from './sandbox-auth.js';
33
33
  const TOP_LEVEL_USAGE = `usage:
34
34
  seq-studio init <dir> [options] scaffold an app or use a published template
35
35
  seq-studio add <kind> <name> [internal] add a primitive to the current app monorepo
36
+ seq-studio validate [--dir <path>] validate an app manifest offline
36
37
  seq-studio deploy -e <env> [internal] deploy primitives from sequence.app.yml
37
38
  seq-studio process <sub> [args] lint | plan | apply | runs | test | simulate | bundle | init
38
39
  seq-studio artifact <sub> [args] init | whoami | link | env | status | list | show | validate | build | plan | deploy | dev | promote | pull | rollback
@@ -149,6 +150,10 @@ export async function run(argv = process.argv.slice(2)) {
149
150
  const { runAppDeployCommand } = await import('./app/commands.js');
150
151
  return runAppDeployCommand(parseArgs([sub, ...rest].filter((a) => Boolean(a))));
151
152
  }
153
+ case 'validate': {
154
+ const { runAppValidateCommand } = await import('./app/commands.js');
155
+ return runAppValidateCommand(parseArgs([sub, ...rest].filter((a) => Boolean(a))));
156
+ }
152
157
  case 'process':
153
158
  return runProcessNamespace(sub, rest);
154
159
  case 'artifact': {
@@ -30,4 +30,5 @@ export interface OrmRepoSelection {
30
30
  * so these values must never be forwarded to it.
31
31
  */
32
32
  export declare function extractOrmRepoSelection(argv: readonly string[]): OrmRepoSelection | null;
33
+ export declare function formatOrmDependencyFailure(message: string): string;
33
34
  export declare function runOrmCommand(sub: string | undefined, rest: string[]): Promise<number>;
@@ -189,27 +189,37 @@ async function loadOrmCli() {
189
189
  ' pnpm exec seq-studio orm …');
190
190
  }
191
191
  else {
192
- console.error('@sequenceholdings/orm is installed but a dependency failed to load. Reinstall dependencies, then retry.\n' +
193
- 'A CLI installed globally with pnpm 11 cannot load drizzle-kit, which imports drizzle-orm without declaring it; ' +
194
- 'run the app\'s own CLI instead (`pnpm exec seq-studio orm …`).\n' +
195
- ` ${message}`);
192
+ console.error(formatOrmDependencyFailure(message));
196
193
  }
197
194
  return null;
198
195
  }
199
196
  }
197
+ export function formatOrmDependencyFailure(message) {
198
+ if (/Cannot find package 'drizzle-orm' imported from .*[/\\]drizzle-kit[/\\]api\.mjs/.test(message)) {
199
+ return 'drizzle-kit cannot resolve drizzle-orm from this CLI installation. Update or reinstall ' +
200
+ '@sequenceholdings/studio-cli so drizzle-orm is installed beside drizzle-kit, then retry.\n' +
201
+ ` ${message}`;
202
+ }
203
+ return '@sequenceholdings/orm is installed but a dependency failed to load. Reinstall dependencies, then retry.\n' +
204
+ ` ${message}`;
205
+ }
200
206
  /**
201
207
  * Subcommands seq-studio implements itself rather than forwarding to the ORM
202
208
  * CLI: discovery reads Atlas's registry, and ad-hoc reads go through the ORM
203
209
  * client. None of them needs a namespace directory.
204
210
  */
205
- const NATIVE_ORM_SUBS = new Set(['namespaces', 'describe', 'read', 'sql']);
211
+ const NATIVE_ORM_SUBS = new Set(['namespaces', 'describe', 'operation', 'read', 'sql']);
206
212
  async function runNativeOrmCommand(sub, rest) {
207
213
  const help = rest.includes('--help') || rest.includes('-h');
208
- if (sub === 'namespaces' || sub === 'describe') {
214
+ if (sub === 'namespaces' || sub === 'describe' || sub === 'operation') {
209
215
  if (help) {
210
216
  console.log(ORM_DISCOVER_HELP);
211
217
  return 0;
212
218
  }
219
+ if (sub === 'operation') {
220
+ const { ormOperationShowCommand } = await import('./operation-show.js');
221
+ return ormOperationShowCommand(parseArgs(rest));
222
+ }
213
223
  const { ormDescribeCommand, ormNamespacesCommand } = await import('./discover.js');
214
224
  return sub === 'namespaces' ? ormNamespacesCommand(parseArgs(rest)) : ormDescribeCommand(parseArgs(rest));
215
225
  }
@@ -246,6 +246,32 @@ export declare const operationDetailSchema: z.ZodObject<{
246
246
  default: z.ZodOptional<z.ZodUnknown>;
247
247
  }, z.core.$loose>>;
248
248
  }, z.core.$loose>;
249
+ /** The reader-gated active operation detail also includes its registered document. */
250
+ export declare const operationInspectionSchema: z.ZodObject<{
251
+ name: z.ZodString;
252
+ op_hash: z.ZodString;
253
+ kind: z.ZodString;
254
+ requires: z.ZodNullable<z.ZodObject<{
255
+ capability: z.ZodOptional<z.ZodString>;
256
+ role: z.ZodOptional<z.ZodString>;
257
+ }, z.core.$loose>>;
258
+ variables: z.ZodArray<z.ZodObject<{
259
+ name: z.ZodString;
260
+ type: z.ZodObject<{
261
+ kind: z.ZodString;
262
+ scalar: z.ZodOptional<z.ZodString>;
263
+ name: z.ZodOptional<z.ZodString>;
264
+ values: z.ZodOptional<z.ZodArray<z.ZodString>>;
265
+ input: z.ZodOptional<z.ZodString>;
266
+ table: z.ZodOptional<z.ZodString>;
267
+ }, z.core.$loose>;
268
+ nullable: z.ZodBoolean;
269
+ list: z.ZodBoolean;
270
+ default: z.ZodOptional<z.ZodUnknown>;
271
+ }, z.core.$loose>>;
272
+ namespace: z.ZodString;
273
+ document: z.ZodString;
274
+ }, z.core.$loose>;
249
275
  export type SchemaView = z.infer<typeof schemaViewSchema>;
250
276
  export type Operation = z.infer<typeof operationSchema>;
251
277
  export type OperationDetail = z.infer<typeof operationDetailSchema>;
@@ -102,6 +102,11 @@ export const operationDetailSchema = z.looseObject({
102
102
  requires: requiresSchema,
103
103
  variables: z.array(variableSchema),
104
104
  });
105
+ /** The reader-gated active operation detail also includes its registered document. */
106
+ export const operationInspectionSchema = operationDetailSchema.safeExtend({
107
+ namespace: z.string(),
108
+ document: z.string(),
109
+ });
105
110
  export function parseResponse({ schema, body, what }) {
106
111
  const parsed = schema.safeParse(body);
107
112
  if (!parsed.success) {
@@ -0,0 +1,2 @@
1
+ import type { ParsedArgs } from '../process/commands.js';
2
+ export declare function ormOperationShowCommand(args: ParsedArgs): Promise<number>;
@@ -0,0 +1,35 @@
1
+ /** Inspect the active persisted operation without executing it. */
2
+ import { AtlasApiError, getJson } from '../atlas-client.js';
3
+ import { printCliError } from '../cli-errors.js';
4
+ import { validateCommandInput } from '../command-input.js';
5
+ import { buildContext, clientOptions } from '../functions/commands.js';
6
+ import { operationInspectionSchema, parseResponse } from './discover-schema.js';
7
+ export async function ormOperationShowCommand(args) {
8
+ try {
9
+ validateCommandInput({ args, flags: {}, positional: 3 });
10
+ const [action, namespace, name] = args.positional;
11
+ if (action !== 'show')
12
+ throw new Error('Expected orm operation show <namespace> <name>. See --help.');
13
+ if (!namespace || !name)
14
+ throw new Error('Namespace and operation name are required.');
15
+ const options = clientOptions(await buildContext(args));
16
+ const path = `/api/orm/namespaces/${encodeURIComponent(namespace)}/operations/${encodeURIComponent(name)}`;
17
+ let body;
18
+ try {
19
+ body = await getJson({ ...options, path });
20
+ }
21
+ catch (error) {
22
+ if (error instanceof AtlasApiError && error.status === 404) {
23
+ throw new Error(`Operation '${namespace}/${name}' was not found or you cannot read it.`);
24
+ }
25
+ throw error;
26
+ }
27
+ const operation = parseResponse({ schema: operationInspectionSchema, body, what: 'operation detail' });
28
+ console.log(args.flags.json === true ? JSON.stringify(operation, null, 2) : operation.document);
29
+ return 0;
30
+ }
31
+ catch (error) {
32
+ printCliError(error);
33
+ return 1;
34
+ }
35
+ }
@@ -0,0 +1,4 @@
1
+ /** The structured `error.code` (or top-level `code`) of an Atlas error body, if any. */
2
+ export declare function errorCode(body: unknown): string | null;
3
+ /** Whether a 503 may clear if retried: anything but a known configuration error. */
4
+ export declare function isTransient503(body: unknown): boolean;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Structured 503 codes that are a standing answer, not a warm-up: the feature
3
+ * is not configured for this environment, so retrying only delays the error.
4
+ * Atlas also sends plain `{ detail }` 503s for transient states without a
5
+ * Retry-After (for example a deploy-permission check that is briefly
6
+ * unavailable), so only a code listed here opts a 503 out of retrying.
7
+ */
8
+ const PERMANENT_503_CODES = new Set(['storage_configuration']);
9
+ /** The structured `error.code` (or top-level `code`) of an Atlas error body, if any. */
10
+ export function errorCode(body) {
11
+ if (!body || typeof body !== 'object')
12
+ return null;
13
+ const { code, error } = body;
14
+ if (error && typeof error === 'object') {
15
+ const nested = error.code;
16
+ if (typeof nested === 'string')
17
+ return nested;
18
+ }
19
+ return typeof code === 'string' ? code : null;
20
+ }
21
+ /** Whether a 503 may clear if retried: anything but a known configuration error. */
22
+ export function isTransient503(body) {
23
+ const code = errorCode(body);
24
+ return code === null || !PERMANENT_503_CODES.has(code);
25
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sequenceholdings/studio-cli",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "description": "Unified Sequence Studio CLI — `seq-studio init` / `add` / `deploy` (app monorepos), `seq-studio agents`, `seq-studio process` (Lattice), `seq-studio artifact`, `seq-studio functions` / `secrets`, `seq-studio repos`, and `seq-studio auth whoami`. Includes Auth0 browser login shared with seqapi.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -41,10 +41,11 @@
41
41
  "smol-toml": "^1.9.0",
42
42
  "tsx": "^4.20.3",
43
43
  "zod": "^4.1.13",
44
+ "drizzle-orm": "^0.45.2",
44
45
  "yaml": "^2.8.4",
46
+ "@sequenceholdings/agent-spec": "0.1.4",
45
47
  "@sequenceholdings/artifact-studio": "0.10.1",
46
48
  "@sequenceholdings/lattice": "0.1.7",
47
- "@sequenceholdings/agent-spec": "0.1.4",
48
49
  "@sequenceholdings/managed-functions": "0.4.5",
49
50
  "@sequenceholdings/storage": "0.1.2"
50
51
  },