@sequenceholdings/studio-cli 0.9.15 → 0.9.17

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
@@ -70,6 +70,16 @@ pnpm add -D @sequenceholdings/studio-cli @sequenceholdings/lattice
70
70
  pnpm add -g @sequenceholdings/studio-cli
71
71
  ```
72
72
 
73
+ Global installations made with pnpm 10.28.2 through 10.x automatically follow the
74
+ `latest` npm tag on user machines. The CLI checks in the background at most
75
+ daily and upgrades only when the running package matches that pnpm global
76
+ installation. The command that triggered the check finishes before the upgrade;
77
+ the next eligible command reports a successful update on stderr. Run
78
+ `seq-studio updater track next` for previews, `seq-studio updater track latest`
79
+ to return, or `seq-studio updater status` to inspect the selected track.
80
+ Set `SEQ_STUDIO_NO_AUTO_UPDATE=1` to keep update notices without installing
81
+ updates. Project dependencies, CI, and pinned devboxes keep their own versions.
82
+
73
83
  ### Why pnpm and not npm
74
84
 
75
85
  Sequence uses pnpm's `minimumReleaseAge` setting (in `pnpm-workspace.yaml`)
@@ -917,11 +927,11 @@ compiled to canonical SQL before registration.
917
927
  | `seq-studio orm validate [dir]` | Parse and compile the namespace, then verify its committed migration chain is current. |
918
928
  | `seq-studio orm plan [dir] -e <env>` | Compare the compiled namespace with registry state without applying database changes; when available, print the live activation's source and provenance. |
919
929
  | `seq-studio orm diff [dir] [--check]` | Author the next committed migration, or verify the migration/snapshot chain offline for CI. |
920
- | `seq-studio orm apply [dir] -e <env> [--timeout <duration>] [--no-wait] [--unverified-source "<reason>"]` | Author a migration if needed, register/apply the namespace, activate its operation set, publish its declared capabilities, and refresh generated outputs. Waits until the new version is live (prints `live:`; default up to 20m); `--no-wait` returns once queued. |
930
+ | `seq-studio orm apply [dir] -e <env> [--timeout <duration>] [--no-wait] [--unverified-source "<reason>"] [--source-env <env>]` | Author a migration if needed, register/apply the namespace, activate its operation set, publish its declared capabilities, and refresh generated outputs. Waits until the new version is live (prints `live:`; default up to 20m); `--no-wait` returns once queued. `--source-env` verifies a checkout of another registered environment's Git Service; sign in there first. |
921
931
  | `seq-studio orm history <namespace> -e <env> [--limit N] [--json]` | List every change to the namespace's live schema and operations, newest first, with the actor and the Git Service source. `apply` from a clone of the target environment's Git Service (or `--repo`) sends its commit and package path; Atlas checks it and records `verified`, `ci`, `break_glass` or `reported`. Environments with `ORM_REQUIRE_VERIFIED_SOURCE=1`, and namespaces pinned with `--mode source`, refuse unverified applies; a namespace admin can override with `orm apply --unverified-source "<reason>"`. |
922
932
  | `seq-studio orm deployment-policy <namespace> -e <env> [--json]` | Inspect whether a namespace permits manual deployment, requires its enrolled repository's verified CI deployment, or is pinned to a verified source repository, branch and package path. |
923
933
  | `seq-studio orm deployment-policy <namespace> -e <env> --mode ci --repo <ns>/<name> --branch <branch> --target <target-key>` | Explicitly enroll an existing namespace. Requires namespace Admin, repository Admin, and an automatic branch policy already bound to this exact namespace. |
924
- | `seq-studio orm deployment-policy <namespace> -e <env> --mode source --repo <ns>/<name> --branch <branch> --path <dir>` | Keep direct applies but accept only ones Atlas verifies came from that repository, branch and package directory. Requires namespace Admin and repository Read. |
934
+ | `seq-studio orm deployment-policy <namespace> -e <env> --mode source --repo <ns>/<name> --branch <branch> --path <dir> [--source-env <env>]` | Keep direct applies but accept only ones Atlas verifies came from that repository, branch and package directory. Requires namespace Admin and repository Read; `--source-env` finds the repository in another registered environment and checks Read with your sign-in there. |
925
935
  | `seq-studio orm deployment-policy <namespace> -e <env> --mode manual` | Restore direct, permission-checked deployment; requires namespace Admin. |
926
936
  | `seq-studio orm execute <namespace> <operation> -e <env> [--variables-file <file>] [--var <name>=<value>]...` | Execute the deployed version's persisted operation by name, as the signed-in caller. Needs no checkout. |
927
937
  | `seq-studio orm execute <operation> [dir] --variables-file <file> -e <env>` | Execute an operation from the checkout's manifest through the installed ORM package, with variables from a JSON object file, as the signed-in caller. |
@@ -1146,7 +1156,8 @@ definition, and supply only parameter values at runtime. Bind values with
1146
1156
  shared manifest. `orm apply` and `orm execute` use the same lifecycle as GraphQL.
1147
1157
 
1148
1158
  SQL reads currently support inner/left/right/full joins with `ON`, cross joins,
1149
- `UNION`/`UNION ALL`, correlated EXISTS, non-recursive CTEs,
1159
+ `UNION`/`UNION ALL`, correlated EXISTS, non-recursive CTEs (including
1160
+ `MATERIALIZED` and `NOT MATERIALIZED` hints),
1150
1161
  grouping, supported aggregates, ordering, and limits. Unsupported SQL and
1151
1162
  unsupported policies fail compilation. Results use column metadata plus row
1152
1163
  arrays, with bigint and numeric values represented as strings. SQL writes,
@@ -1834,6 +1845,11 @@ successfully. Help does not initialize files, authenticate, or deploy.
1834
1845
  | `seq-studio artifact promote <deployment-id> -e <env>` | `promote <deployment-id> --env <env>` |
1835
1846
  | `seq-studio artifact rollback <deployment-id> -e <env>` | `rollback <deployment-id> --env <env>` |
1836
1847
 
1848
+ `artifact init` derives the initial bundle name, project ID, and title from the
1849
+ destination directory's final path component on both Windows and Unix. Review
1850
+ those fields in `artifact.bundle.yml` before the first deploy; the project ID
1851
+ becomes the deployed project's slug.
1852
+
1837
1853
  Artifact commands reject unknown options before authentication or network
1838
1854
  access, so a misspelled flag cannot be silently ignored. `seq-studio artifact
1839
1855
  deploy` validates explicit manifest bindings: the selected
@@ -48,9 +48,10 @@ export declare function postJsonResponse({ baseUrl, token, path, body, headers,
48
48
  headers?: Record<string, string>;
49
49
  timeoutMs?: number;
50
50
  }): Promise<AtlasResponse>;
51
- export declare function putJson<T>({ baseUrl, token, path, body, }: ClientOptions & {
51
+ export declare function putJson<T>({ baseUrl, token, path, body, headers, }: ClientOptions & {
52
52
  path: string;
53
53
  body?: unknown;
54
+ headers?: Record<string, string>;
54
55
  }): Promise<T>;
55
56
  export declare function patchJson<T>({ baseUrl, token, path, body, }: ClientOptions & {
56
57
  path: string;
@@ -9,6 +9,7 @@ import { createPlatformTransport, createOperatorPlatformClient, } from "@sequenc
9
9
  import { validationDetail } from "./validation-detail.js";
10
10
  import { edgeAuthHeaders } from "./edge-auth-headers.js";
11
11
  import { sandboxBearerFor } from "./sandbox-auth.js";
12
+ import { devboxAwareBearer } from "./host-token.js";
12
13
  import { errorCode, isTransient503 } from "./transient-503.js";
13
14
  import { fetchWithCliAttribution } from "./cli-attribution.js";
14
15
  const MAX_503_RETRIES = 5;
@@ -57,7 +58,7 @@ async function authenticatedFetch({ baseUrl, init = {}, path, token, retry503 =
57
58
  timeoutMs,
58
59
  auth: {
59
60
  kind: "operator",
60
- bearer: async () => (await sandboxBearerFor(baseUrl)) ?? token,
61
+ bearer: async () => (await sandboxBearerFor(baseUrl)) ?? (await devboxAwareBearer(baseUrl, token)),
61
62
  },
62
63
  edgeHeaders: () => edgeAuthHeaders(baseUrl),
63
64
  });
@@ -261,14 +262,14 @@ export async function postJsonResponse({ baseUrl, token, path, body, headers = {
261
262
  body: await response.text(),
262
263
  };
263
264
  }
264
- export async function putJson({ baseUrl, token, path, body, }) {
265
+ export async function putJson({ baseUrl, token, path, body, headers, }) {
265
266
  const response = await authenticatedFetch({
266
267
  baseUrl,
267
268
  token,
268
269
  path,
269
270
  init: {
270
271
  method: "PUT",
271
- headers: { "Content-Type": "application/json" },
272
+ headers: { ...headers, "Content-Type": "application/json" },
272
273
  body: body === undefined ? undefined : JSON.stringify(body),
273
274
  },
274
275
  });
@@ -342,7 +343,7 @@ export function operatorPlatformClient({ baseUrl, token, }) {
342
343
  return createOperatorPlatformClient({
343
344
  fetchImpl: fetchWithCliAttribution,
344
345
  baseUrl,
345
- bearer: async () => (await sandboxBearerFor(baseUrl)) ?? token,
346
+ bearer: async () => (await sandboxBearerFor(baseUrl)) ?? (await devboxAwareBearer(baseUrl, token)),
346
347
  edgeHeaders: () => edgeAuthHeaders(baseUrl),
347
348
  });
348
349
  }
package/dist/auth.js CHANGED
@@ -6,6 +6,7 @@ import { join } from 'node:path';
6
6
  import { validateDeploymentAudience, validateDeploymentBaseUrl, } from '@sequenceholdings/artifact-studio/deployment-validation';
7
7
  import { withCrossProcessFileLock } from './file-lock.js';
8
8
  import { isSandboxOrigin, readSandboxToken, SandboxAuthError, sandboxTarget } from './sandbox-auth.js';
9
+ import { devboxHostToken } from './host-token.js';
9
10
  function hasErrorCode(error, code) {
10
11
  return error instanceof Error && Reflect.get(error, 'code') === code;
11
12
  }
@@ -485,11 +486,59 @@ async function sandboxAccessToken(targetUrl) {
485
486
  }
486
487
  return { authMode: 'sandbox', token: await readSandboxToken(sandbox) };
487
488
  }
488
- async function resolveAccessTokenWithMode(options) {
489
- // Sandbox token mode replaces every other source, before any realm lookup.
490
- const sandbox = await sandboxAccessToken(options?.targetUrl);
489
+ /**
490
+ * A devbox owner's login, written per host by the control plane (host-token.ts).
491
+ * It is that person's identity, so it resolves as `user`; keyed by the request's
492
+ * own host, it can only ever go where it was minted.
493
+ */
494
+ async function devboxAccessToken(targetUrl) {
495
+ const token = targetUrl ? await devboxHostToken(targetUrl) : null;
496
+ return token ? { authMode: 'user', token } : null;
497
+ }
498
+ /**
499
+ * The user's own unexpired cached login for this environment, or null. Never
500
+ * refreshes, logs in, or throws: it only decides whether a login the user
501
+ * chose to make should win over the devbox owner token.
502
+ */
503
+ async function liveCachedUserLogin(options) {
504
+ if (authModePrefersM2m())
505
+ return null;
506
+ try {
507
+ const realm = await realmForEnv(options.env, { targetUrl: options.targetUrl });
508
+ if (options.targetUrl)
509
+ validateRealmTarget({ realm, targetUrl: options.targetUrl });
510
+ const tokens = await loadCachedUserTokens(realm.name);
511
+ if (!tokens?.access_token || (tokens.expires_at ?? 0) <= Date.now() / 1000 + 60)
512
+ return null;
513
+ verifyTokenMatchesRealm({ accessToken: tokens.access_token, realm });
514
+ return { authMode: 'user', token: tokens.access_token };
515
+ }
516
+ catch {
517
+ return null;
518
+ }
519
+ }
520
+ /**
521
+ * A token the environment supplies rather than a login: the sandbox bearer,
522
+ * else a devbox owner token. A live login of the user's own for the same
523
+ * deployment beats the devbox token: the user made it deliberately (the
524
+ * box's sign-in page), and it keeps working on a deployment that does not
525
+ * accept the box's token yet. Without one, the devbox token is used as before.
526
+ */
527
+ async function ambientAccessToken(options) {
528
+ const sandbox = await sandboxAccessToken(options.targetUrl);
491
529
  if (sandbox)
492
530
  return sandbox;
531
+ const devbox = await devboxAccessToken(options.targetUrl);
532
+ if (!devbox)
533
+ return null;
534
+ return (await liveCachedUserLogin(options)) ?? devbox;
535
+ }
536
+ async function resolveAccessTokenWithMode(options) {
537
+ // Sandbox token mode replaces every other source, before any realm lookup;
538
+ // then a devbox owner's login for the target host.
539
+ const ambient = await ambientAccessToken({ env: options?.env, targetUrl: options?.targetUrl });
540
+ if (ambient)
541
+ return ambient;
493
542
  const realm = await realmForEnv(options?.env, { targetUrl: options?.targetUrl });
494
543
  if (options?.targetUrl)
495
544
  validateRealmTarget({ realm, targetUrl: options.targetUrl });
@@ -119,6 +119,12 @@ export declare const COMMAND_CONTRACT: readonly [{
119
119
  readonly lifecycle: "preview";
120
120
  readonly access: "offline";
121
121
  readonly subcommands: readonly ["enable", "disable", "status"];
122
+ }, {
123
+ readonly name: "updater";
124
+ readonly description: "Control global pnpm CLI updates";
125
+ readonly lifecycle: "preview";
126
+ readonly access: "offline";
127
+ readonly subcommands: readonly ["status", "track"];
122
128
  }, {
123
129
  readonly name: "version";
124
130
  readonly description: "Print the installed CLI version";
@@ -20,6 +20,7 @@ export const COMMAND_CONTRACT = [
20
20
  { name: 'logout', description: 'Remove cached user tokens', lifecycle: 'stable', access: 'public', subcommands: [] },
21
21
  { name: 'doctor', description: 'Diagnose CLI configuration and access', lifecycle: 'stable', access: 'mixed', subcommands: [] },
22
22
  { name: 'telemetry', description: 'Control authenticated command telemetry', lifecycle: 'preview', access: 'offline', subcommands: ['enable', 'disable', 'status'] },
23
+ { name: 'updater', description: 'Control global pnpm CLI updates', lifecycle: 'preview', access: 'offline', subcommands: ['status', 'track'] },
23
24
  { name: 'version', description: 'Print the installed CLI version', lifecycle: 'stable', access: 'offline', subcommands: [] },
24
25
  { name: 'help', description: 'Show command help', lifecycle: 'stable', access: 'offline', subcommands: [] },
25
26
  { name: 'storage', description: 'Manage Workspaces V2 file storage', lifecycle: 'preview', access: 'authenticated', subcommands: ['init', 'validate', 'apply', 'list', 'show', 'mkdir', 'upload', 'import', 'uploads', 'reconcile', 'download', 'access', 'trash', 'restore', 'purge', 'operations', 'abort', 'delete'] },
@@ -2,8 +2,8 @@ export { PIPELINE_HELP } from './pipeline/help.js';
2
2
  /** `--repo` on every init command; shared so the commands describe it identically. */
3
3
  export declare const INIT_INTO_REPO_HELP = " Init into a repo: --repo <ns>/<name> on an init command creates that platform\n git-service repo if missing (same name rules as repos create), then clones it\n into <dir> and scaffolds there, or, when <dir> is inside a Git checkout, sets\n it as that checkout's origin (a different existing origin is refused). It\n needs -e <env>, or an agent sandbox. Nothing is committed or pushed; the\n command prints the git add, commit, and push to run.\n In a git-service checkout (with or without --repo), orm init, functions init\n and artifact init also declare the scaffold under resources in\n .seq/repository.yml, so repository CI checks and deploys it. A scaffold inside\n a declared application is not declared; add it to that app with seq-studio add.\n";
4
4
  export declare const ORM_HISTORY_HELP = "usage:\n seq-studio orm history <namespace> -e <env> [--limit N] [--json]\n\n Lists every change to the namespace's live schema and operations, newest\n first: when, who, what moved, and the Git Service source. \"verified\" and \"ci\"\n sources were checked by Atlas against the repository; \"reported\" means Atlas\n could not tie the change to a pushed commit on a release branch, with the\n reason when one was claimed. \"break_glass\" is an admin override made with\n orm apply --unverified-source \"<reason>\". * marks the live activation.\n History starts with the first apply after the environment recorded it.\n";
5
- export declare const ORM_DEPLOYMENT_POLICY_HELP = "usage:\n seq-studio orm deployment-policy <namespace> -e <env> [--json]\n seq-studio orm deployment-policy <namespace> -e <env> --mode ci --repo <ns>/<name> --branch <branch> --target <target-key>\n seq-studio orm deployment-policy <namespace> -e <env> --mode manual\n seq-studio orm deployment-policy <namespace> -e <env> --mode source --repo <ns>/<name> --branch <branch> --path <dir>\n\n Existing namespaces default to manual deployment. CI mode rejects direct ORM\n registration, schema apply, and operations-only activation on the server;\n only the enrolled repository's verified merge deployment may activate changes.\n Enabling CI mode requires namespace Admin, repository Admin, and an existing\n automatic branch binding to this namespace. Restoring manual mode requires\n namespace Admin. This changes deployment policy; it does not deploy source.\n\n Source mode keeps direct applies but accepts only ones Atlas verifies came\n from that repository, branch and package directory (pass --path . for the\n repository root). It requires namespace Admin and repository Read. Namespace\n admins can still apply with --unverified-source \"<reason>\", which is recorded.\n";
6
- export declare const ORM_HELP = "usage:\n seq-studio orm init <dir> [--repo <ns>/<name>]\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> [--timeout <duration>] [--no-wait] [--unverified-source \"<reason>\"]\n seq-studio orm history <namespace> -e <env> [--limit N] [--json]\n seq-studio orm deployment-policy <namespace> -e <env> [--mode manual|ci|source] [--repo <ns>/<name> --branch <branch> (--target <target-key> | --path <dir>)] [--json]\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 Schema commands require the ORM loaded by seq-studio to satisfy the v2\n namespace's package.json @sequenceholdings/orm range before compiling.\n apply waits until the new version is live and serving (default up to 20m), then\n prints \"live:\"; --no-wait returns once the apply is queued.\n CI-managed namespaces reject direct apply; use the enrolled repository's merge\n workflow. Source-pinned namespaces accept only applies Atlas verifies against\n their repository, branch and package path, and an environment can require a\n verified source for every apply. A namespace admin may record an audited\n exception with --unverified-source \"<reason>\". deployment-policy reads or\n explicitly changes this namespace setting.\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\n Init into a repo: --repo <ns>/<name> on an init command creates that platform\n git-service repo if missing (same name rules as repos create), then clones it\n into <dir> and scaffolds there, or, when <dir> is inside a Git checkout, sets\n it as that checkout's origin (a different existing origin is refused). It\n needs -e <env>, or an agent sandbox. Nothing is committed or pushed; the\n command prints the git add, commit, and push to run.\n In a git-service checkout (with or without --repo), orm init, functions init\n and artifact init also declare the scaffold under resources in\n .seq/repository.yml, so repository CI checks and deploys it. A scaffold inside\n a declared application is not declared; add it to that app with seq-studio add.\n";
5
+ export declare const ORM_DEPLOYMENT_POLICY_HELP = "usage:\n seq-studio orm deployment-policy <namespace> -e <env> [--json]\n seq-studio orm deployment-policy <namespace> -e <env> --mode ci --repo <ns>/<name> --branch <branch> --target <target-key>\n seq-studio orm deployment-policy <namespace> -e <env> --mode manual\n seq-studio orm deployment-policy <namespace> -e <env> --mode source --repo <ns>/<name> --branch <branch> --path <dir> [--source-env <env>]\n\n Existing namespaces default to manual deployment. CI mode rejects direct ORM\n registration, schema apply, and operations-only activation on the server;\n only the enrolled repository's verified merge deployment may activate changes.\n Enabling CI mode requires namespace Admin, repository Admin, and an existing\n automatic branch binding to this namespace. Restoring manual mode requires\n namespace Admin. This changes deployment policy; it does not deploy source.\n\n Source mode keeps direct applies but accepts only ones Atlas verifies came\n from that repository, branch and package directory (pass --path . for the\n repository root). It requires namespace Admin and repository Read. Namespace\n admins can still apply with --unverified-source \"<reason>\", which is recorded.\n --source-env names the environment whose Git Service holds the repository when\n it is not this one's (sign in there too); applies must then pass the same\n --source-env from a clean clone of that repository.\n";
6
+ export declare const ORM_HELP = "usage:\n seq-studio orm init <dir> [--repo <ns>/<name>]\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> [--timeout <duration>] [--no-wait] [--unverified-source \"<reason>\"] [--source-env <env>]\n seq-studio orm history <namespace> -e <env> [--limit N] [--json]\n seq-studio orm deployment-policy <namespace> -e <env> [--mode manual|ci|source] [--repo <ns>/<name> --branch <branch> (--target <target-key> | --path <dir> [--source-env <env>])] [--json]\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 Schema commands require the ORM loaded by seq-studio to satisfy the v2\n namespace's package.json @sequenceholdings/orm range before compiling.\n apply waits until the new version is live and serving (default up to 20m), then\n prints \"live:\"; --no-wait returns once the apply is queued.\n CI-managed namespaces reject direct apply; use the enrolled repository's merge\n workflow. Source-pinned namespaces accept only applies Atlas verifies against\n their repository, branch and package path, and an environment can require a\n verified source for every apply. A namespace admin may record an audited\n exception with --unverified-source \"<reason>\". --source-env <env> applies from a\n clone of another environment's Git Service, which Atlas verifies there with your\n sign-in for it. deployment-policy reads or explicitly changes this namespace setting.\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\n Init into a repo: --repo <ns>/<name> on an init command creates that platform\n git-service repo if missing (same name rules as repos create), then clones it\n into <dir> and scaffolds there, or, when <dir> is inside a Git checkout, sets\n it as that checkout's origin (a different existing origin is refused). It\n needs -e <env>, or an agent sandbox. Nothing is committed or pushed; the\n command prints the git add, commit, and push to run.\n In a git-service checkout (with or without --repo), orm init, functions init\n and artifact init also declare the scaffold under resources in\n .seq/repository.yml, so repository CI checks and deploys it. A scaffold inside\n a declared application is not declared; add it to that app with seq-studio add.\n";
7
7
  /** Artifact commands in sandbox token mode; shared by the offline and delegate usage. */
8
8
  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";
9
9
  export declare const ARTIFACT_HELP = "usage:\n seq-studio artifact init <dir> [--template react-vite|nextjs] [--repo <namespace>/<name>]\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>] [--secret-source local|hosted|none] [--local-secrets <bindings.json>] [--bundler turbopack|webpack]\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 Init into a repo: --repo <ns>/<name> on an init command creates that platform\n git-service repo if missing (same name rules as repos create), then clones it\n into <dir> and scaffolds there, or, when <dir> is inside a Git checkout, sets\n it as that checkout's origin (a different existing origin is refused). It\n needs -e <env>, or an agent sandbox. Nothing is committed or pushed; the\n command prints the git add, commit, and push to run.\n In a git-service checkout (with or without --repo), orm init, functions init\n and artifact init also declare the scaffold under resources in\n .seq/repository.yml, so repository CI checks and deploys it. A scaffold inside\n a declared application is not declared; add it to that app with seq-studio add.\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";
@@ -28,7 +28,7 @@ export const ORM_DEPLOYMENT_POLICY_HELP = `usage:
28
28
  seq-studio orm deployment-policy <namespace> -e <env> [--json]
29
29
  seq-studio orm deployment-policy <namespace> -e <env> --mode ci --repo <ns>/<name> --branch <branch> --target <target-key>
30
30
  seq-studio orm deployment-policy <namespace> -e <env> --mode manual
31
- seq-studio orm deployment-policy <namespace> -e <env> --mode source --repo <ns>/<name> --branch <branch> --path <dir>
31
+ seq-studio orm deployment-policy <namespace> -e <env> --mode source --repo <ns>/<name> --branch <branch> --path <dir> [--source-env <env>]
32
32
 
33
33
  Existing namespaces default to manual deployment. CI mode rejects direct ORM
34
34
  registration, schema apply, and operations-only activation on the server;
@@ -41,15 +41,18 @@ export const ORM_DEPLOYMENT_POLICY_HELP = `usage:
41
41
  from that repository, branch and package directory (pass --path . for the
42
42
  repository root). It requires namespace Admin and repository Read. Namespace
43
43
  admins can still apply with --unverified-source "<reason>", which is recorded.
44
+ --source-env names the environment whose Git Service holds the repository when
45
+ it is not this one's (sign in there too); applies must then pass the same
46
+ --source-env from a clean clone of that repository.
44
47
  `;
45
48
  export const ORM_HELP = `usage:
46
49
  seq-studio orm init <dir> [--repo <ns>/<name>]
47
50
  seq-studio orm generate [dir] [--migration-export] [--check]
48
51
  seq-studio orm validate [dir]
49
52
  seq-studio orm plan [dir] -e <env>
50
- seq-studio orm apply [dir] -e <env> [--timeout <duration>] [--no-wait] [--unverified-source "<reason>"]
53
+ seq-studio orm apply [dir] -e <env> [--timeout <duration>] [--no-wait] [--unverified-source "<reason>"] [--source-env <env>]
51
54
  seq-studio orm history <namespace> -e <env> [--limit N] [--json]
52
- seq-studio orm deployment-policy <namespace> -e <env> [--mode manual|ci|source] [--repo <ns>/<name> --branch <branch> (--target <target-key> | --path <dir>)] [--json]
55
+ seq-studio orm deployment-policy <namespace> -e <env> [--mode manual|ci|source] [--repo <ns>/<name> --branch <branch> (--target <target-key> | --path <dir> [--source-env <env>])] [--json]
53
56
  seq-studio orm execute <namespace> <operation> -e <env> [--variables-file <file>] [--var <name>=<value>]...
54
57
  seq-studio orm execute <operation> [dir] --variables-file <file> -e <env>
55
58
  seq-studio orm namespaces -e <env> [--limit N] [--offset N] [--json]
@@ -71,8 +74,9 @@ export const ORM_HELP = `usage:
71
74
  workflow. Source-pinned namespaces accept only applies Atlas verifies against
72
75
  their repository, branch and package path, and an environment can require a
73
76
  verified source for every apply. A namespace admin may record an audited
74
- exception with --unverified-source "<reason>". deployment-policy reads or
75
- explicitly changes this namespace setting.
77
+ exception with --unverified-source "<reason>". --source-env <env> applies from a
78
+ clone of another environment's Git Service, which Atlas verifies there with your
79
+ sign-in for it. deployment-policy reads or explicitly changes this namespace setting.
76
80
  namespaces lists what you can read; describe shows its tables and operations.
77
81
  Run seq-studio orm describe --help for the output.
78
82
  execute <namespace> <operation> runs the deployed version's persisted operation by
@@ -5,6 +5,10 @@ interface DiscoveredRealm {
5
5
  organization?: string;
6
6
  m2mClientId?: string;
7
7
  }
8
+ /** A deployment's public CLI login, and the CLI environment name it advertises for itself. */
9
+ interface DeploymentLogin extends DiscoveredRealm {
10
+ cliEnvironment?: string;
11
+ }
8
12
  interface RegistrationResult {
9
13
  name: string;
10
14
  baseUrl: string;
@@ -19,7 +23,7 @@ export declare function seqapiConfigPath(): string;
19
23
  export declare function fetchDeploymentLogin({ baseUrl, fetchImpl, }: {
20
24
  baseUrl: string;
21
25
  fetchImpl?: typeof fetch;
22
- }): Promise<DiscoveredRealm>;
26
+ }): Promise<DeploymentLogin>;
23
27
  export declare function readRegisteredEnvironmentUrls({ configFile, }?: {
24
28
  configFile?: string;
25
29
  }): Promise<Record<string, {
@@ -3,7 +3,7 @@ import { mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises';
3
3
  import { homedir } from 'node:os';
4
4
  import { dirname, join } from 'node:path';
5
5
  import { validateDeploymentAudience, validateDeploymentBaseUrl, } from '@sequenceholdings/artifact-studio/deployment-validation';
6
- import { deleteRealmTokens, isSequenceAuthEnvName, validateAuth0Domain, } from './auth.js';
6
+ import { deleteRealmTokens, isSequenceAuthEnvName, isSharedLoginDeploymentName, usesSharedSequenceLogin, validateAuth0Domain, } from './auth.js';
7
7
  import { withCrossProcessFileLock } from './file-lock.js';
8
8
  const DISCOVERY_PATH = '/api/auth/cli-config';
9
9
  const ENV_NAME_PATTERN = /^[a-z0-9][a-z0-9-]*$/;
@@ -30,7 +30,14 @@ function validateEnvironmentName(input) {
30
30
  return name;
31
31
  }
32
32
  async function discoverRealm({ baseUrl, fetchImpl, }) {
33
- const login = await fetchDeploymentLogin({ baseUrl, fetchImpl });
33
+ const { cliEnvironment, ...login } = await fetchDeploymentLogin({ baseUrl, fetchImpl });
34
+ // A tenant registration never trusts the shared Sequence login, so a first-party deployment
35
+ // is saved under its reserved name instead: say which, rather than refuse its audience.
36
+ if (usesSharedSequenceLogin(login)) {
37
+ const reserved = cliEnvironment && isSharedLoginDeploymentName(cliEnvironment) ? cliEnvironment : '<staging|production|banksouth>';
38
+ throw new Error(`${baseUrl} signs in with the shared Sequence login, so it is a first-party deployment. ` +
39
+ `Save it under its first-party name instead: seq-studio envs add ${reserved} ${baseUrl}`);
40
+ }
34
41
  return { ...login, audience: validateDeploymentAudience({ audience: login.audience, baseUrl }) };
35
42
  }
36
43
  /**
@@ -83,12 +90,14 @@ export async function fetchDeploymentLogin({ baseUrl, fetchImpl = fetch, }) {
83
90
  if (missing.length > 0 || !domain || !clientId || !audience) {
84
91
  throw new Error(`${url} response is missing auth0.{${missing.join(', ')}}.`);
85
92
  }
93
+ const cliEnvironment = isRecord(data) ? optionalString(Reflect.get(data, 'cliEnvironment')) : undefined;
86
94
  return {
87
95
  domain: validateAuth0Domain(domain),
88
96
  clientId,
89
97
  audience,
90
98
  organization: optionalString(Reflect.get(auth0, 'organization')),
91
99
  m2mClientId: optionalString(Reflect.get(auth0, 'm2mClientId')),
100
+ ...(cliEnvironment ? { cliEnvironment } : {}),
92
101
  };
93
102
  }
94
103
  async function loadConfig(configFile) {
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Devbox host tokens.
3
+ *
4
+ * On a seq-code devbox that serves a Claude cloud session, the control plane
5
+ * writes the box owner's own short-lived Sequence login for each Atlas
6
+ * deployment it can vouch for into a directory, one file per host, and
7
+ * replaces them before they expire:
8
+ *
9
+ * SEQ_DEVBOX_TOKEN_DIR/<host> e.g. staging.example.seqholdings.com
10
+ *
11
+ * A request to an origin whose host has a live file uses it, unless the user
12
+ * has a live login of their own for that deployment, which wins (auth.ts);
13
+ * every other origin resolves exactly as before. Unlike sandbox token
14
+ * mode this pins nothing: `-e` still picks the deployment, and a deployment
15
+ * with no file (or `-e local`) falls through to the usual login.
16
+ *
17
+ * The file is read again for each request, so a rotation mid-command is picked
18
+ * up. A token whose `exp` is past (or within a minute of it) is ignored rather
19
+ * than sent: the login cache, if any, is the better answer then.
20
+ */
21
+ export declare const DEVBOX_TOKEN_DIR_ENV = "SEQ_DEVBOX_TOKEN_DIR";
22
+ /** The file name a token for `url` lives under, or null for an origin that never has one. */
23
+ export declare function devboxTokenHost(url: string): string | null;
24
+ /** The JWT's `exp`, read without verifying it: the server verifies, this only avoids sending a dead token. */
25
+ export declare function jwtExpiry(token: string): number | null;
26
+ /**
27
+ * The live devbox token for a request to `url`, or null outside a devbox, for
28
+ * a host with no file, or for an expired, unreadable or malformed one. Never
29
+ * throws: a broken file must not stop the ordinary login path.
30
+ *
31
+ * Also null under `SEQAPI_AUTH_MODE=m2m`, matching seqapi: an explicitly
32
+ * requested machine identity must not be swapped for the box owner's login.
33
+ */
34
+ export declare function devboxHostToken(url: string, { env, now }?: {
35
+ env?: NodeJS.ProcessEnv;
36
+ now?: number;
37
+ }): Promise<string | null>;
38
+ /**
39
+ * Whether `token` is one the control plane writes into the devbox token
40
+ * directory (a devbox owner token, or the control plane's own agent sandbox
41
+ * token) rather than a person's login. Read without verifying, only to decide
42
+ * whether re-reading the file mid-command may replace it.
43
+ */
44
+ export declare function isDevboxFileToken(token: string): boolean;
45
+ /**
46
+ * The bearer for one request on a command whose token was resolved up front.
47
+ * A command that started on the devbox file re-reads it, so a rotation
48
+ * mid-command is picked up. One that resolved to the user's own login keeps
49
+ * it while it has more than a minute left, then moves to the box's live
50
+ * token, so a long command does not die when that login expires.
51
+ */
52
+ export declare function devboxAwareBearer(url: string, token: string, { env, now }?: {
53
+ env?: NodeJS.ProcessEnv;
54
+ now?: number;
55
+ }): Promise<string>;
@@ -0,0 +1,117 @@
1
+ /**
2
+ * Devbox host tokens.
3
+ *
4
+ * On a seq-code devbox that serves a Claude cloud session, the control plane
5
+ * writes the box owner's own short-lived Sequence login for each Atlas
6
+ * deployment it can vouch for into a directory, one file per host, and
7
+ * replaces them before they expire:
8
+ *
9
+ * SEQ_DEVBOX_TOKEN_DIR/<host> e.g. staging.example.seqholdings.com
10
+ *
11
+ * A request to an origin whose host has a live file uses it, unless the user
12
+ * has a live login of their own for that deployment, which wins (auth.ts);
13
+ * every other origin resolves exactly as before. Unlike sandbox token
14
+ * mode this pins nothing: `-e` still picks the deployment, and a deployment
15
+ * with no file (or `-e local`) falls through to the usual login.
16
+ *
17
+ * The file is read again for each request, so a rotation mid-command is picked
18
+ * up. A token whose `exp` is past (or within a minute of it) is ignored rather
19
+ * than sent: the login cache, if any, is the better answer then.
20
+ */
21
+ import { readFile } from 'node:fs/promises';
22
+ import { join } from 'node:path';
23
+ export const DEVBOX_TOKEN_DIR_ENV = 'SEQ_DEVBOX_TOKEN_DIR';
24
+ const HOST = /^[a-z0-9.-]+(?::\d{1,5})?$/;
25
+ const EXPIRY_MARGIN_SECONDS = 60;
26
+ /** The file name a token for `url` lives under, or null for an origin that never has one. */
27
+ export function devboxTokenHost(url) {
28
+ let parsed;
29
+ try {
30
+ parsed = new URL(url);
31
+ }
32
+ catch {
33
+ return null;
34
+ }
35
+ // Loopback Atlas (the box's own) signs its own tokens; the control plane never writes one for it.
36
+ if (parsed.protocol !== 'https:')
37
+ return null;
38
+ const host = parsed.host.toLowerCase();
39
+ return HOST.test(host) ? host : null;
40
+ }
41
+ /** The JWT's `exp`, read without verifying it: the server verifies, this only avoids sending a dead token. */
42
+ export function jwtExpiry(token) {
43
+ const payload = token.split('.')[1];
44
+ if (!payload)
45
+ return null;
46
+ try {
47
+ const exp = JSON.parse(Buffer.from(payload, 'base64url').toString('utf8')).exp;
48
+ return typeof exp === 'number' && Number.isFinite(exp) ? exp : null;
49
+ }
50
+ catch {
51
+ return null;
52
+ }
53
+ }
54
+ /**
55
+ * The live devbox token for a request to `url`, or null outside a devbox, for
56
+ * a host with no file, or for an expired, unreadable or malformed one. Never
57
+ * throws: a broken file must not stop the ordinary login path.
58
+ *
59
+ * Also null under `SEQAPI_AUTH_MODE=m2m`, matching seqapi: an explicitly
60
+ * requested machine identity must not be swapped for the box owner's login.
61
+ */
62
+ export async function devboxHostToken(url, { env = process.env, now = Date.now() } = {}) {
63
+ if (env.SEQAPI_AUTH_MODE?.trim().toLowerCase() === 'm2m')
64
+ return null;
65
+ const dir = env[DEVBOX_TOKEN_DIR_ENV]?.trim();
66
+ if (!dir)
67
+ return null;
68
+ const host = devboxTokenHost(url);
69
+ if (!host)
70
+ return null;
71
+ let token;
72
+ try {
73
+ token = (await readFile(join(dir, host), 'utf8')).trim();
74
+ }
75
+ catch {
76
+ return null;
77
+ }
78
+ if (!token || /[\s\0]/.test(token))
79
+ return null;
80
+ const exp = jwtExpiry(token);
81
+ if (exp === null || exp * 1000 <= now + EXPIRY_MARGIN_SECONDS * 1000)
82
+ return null;
83
+ return token;
84
+ }
85
+ /**
86
+ * Whether `token` is one the control plane writes into the devbox token
87
+ * directory (a devbox owner token, or the control plane's own agent sandbox
88
+ * token) rather than a person's login. Read without verifying, only to decide
89
+ * whether re-reading the file mid-command may replace it.
90
+ */
91
+ export function isDevboxFileToken(token) {
92
+ const payload = token.split('.')[1];
93
+ if (!payload)
94
+ return false;
95
+ try {
96
+ const source = JSON.parse(Buffer.from(payload, 'base64url').toString('utf8')).source;
97
+ return source === 'devbox-owner' || source === 'agent-sandbox';
98
+ }
99
+ catch {
100
+ return false;
101
+ }
102
+ }
103
+ /**
104
+ * The bearer for one request on a command whose token was resolved up front.
105
+ * A command that started on the devbox file re-reads it, so a rotation
106
+ * mid-command is picked up. One that resolved to the user's own login keeps
107
+ * it while it has more than a minute left, then moves to the box's live
108
+ * token, so a long command does not die when that login expires.
109
+ */
110
+ export async function devboxAwareBearer(url, token, { env = process.env, now = Date.now() } = {}) {
111
+ if (token && !isDevboxFileToken(token)) {
112
+ const exp = jwtExpiry(token);
113
+ if (exp === null || exp * 1000 > now + EXPIRY_MARGIN_SECONDS * 1000)
114
+ return token;
115
+ }
116
+ return (await devboxHostToken(url, { env, now })) ?? token;
117
+ }
package/dist/main.js CHANGED
@@ -57,6 +57,7 @@ const TOP_LEVEL_USAGE = `usage:
57
57
  seq-studio logout [--env <name>] remove one realm's cached user tokens
58
58
  seq-studio doctor [-e <env>] [--json] [--offline] diagnose config, auth, toolchain, and writer gate
59
59
  seq-studio telemetry enable|disable|status control authenticated command metrics
60
+ seq-studio updater status | track latest|next control global pnpm auto-updates
60
61
  seq-studio version print the installed version
61
62
  seq-studio capabilities [--json] describe command availability and access
62
63
  seq-studio help show this message
@@ -112,8 +113,9 @@ const SUBCOMMANDS = {
112
113
  orm: new Set(['init', 'generate', 'validate', 'plan', 'apply', 'history', 'deployment-policy', 'execute', 'namespaces', 'describe', 'read', 'sql', 'diff', 'migrate-from-yaml', 'import']),
113
114
  pipeline: new Set(['list', 'assets', 'search', 'describe', 'schema', 'sample', 'query', 'init', 'validate', 'repin-orm', 'codegen', 'adopt', 'unbind', 'retire', 'plan', 'deploy', 'status', 'migrate', 'promote', 'rollback', 'run-now']),
114
115
  envs: new Set(['add', 'list']),
116
+ updater: new Set(['status', 'track']),
115
117
  };
116
- const TELEMETRY_EXCLUDED = new Set(['validate', 'telemetry', 'version', 'capabilities', 'help', 'login', 'logout', 'envs']);
118
+ const TELEMETRY_EXCLUDED = new Set(['validate', 'telemetry', 'updater', 'version', 'capabilities', 'help', 'login', 'logout', 'envs']);
117
119
  const TELEMETRY_TOP_LEVEL = new Set(['init', 'add', 'deploy', 'doctor']);
118
120
  const TELEMETRY_NESTED = {
119
121
  'repos pulls': new Set(['list', 'show', 'create', 'diff', 'merge', 'edit', 'close', 'comment', 'comments', 'resolve', 'unresolve', 'review', 'reviews', 'checks']),
@@ -279,6 +281,8 @@ async function dispatch(argv) {
279
281
  console.log(currentVersion());
280
282
  return 0;
281
283
  }
284
+ case 'updater':
285
+ return (await import('./pnpm-auto-update.js')).updaterCommand([sub, ...rest].filter((arg) => Boolean(arg)));
282
286
  case 'capabilities':
283
287
  return runCapabilities([sub, ...rest].filter((value) => Boolean(value)));
284
288
  case 'doctor':