@sequenceholdings/studio-cli 0.9.23 → 0.9.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/README.md +166 -146
  2. package/dist/access/commands.js +3 -5
  3. package/dist/access/principal.js +2 -2
  4. package/dist/access/tier-hosts.js +2 -2
  5. package/dist/agents/commands.d.ts +1 -1
  6. package/dist/agents/commands.js +9 -9
  7. package/dist/agents/scaffold.js +3 -3
  8. package/dist/agents/voice.d.ts +1 -1
  9. package/dist/agents/voice.js +1 -1
  10. package/dist/app/commands.d.ts +2 -2
  11. package/dist/app/commands.js +31 -21
  12. package/dist/app/deploy.d.ts +1 -1
  13. package/dist/app/deploy.js +1 -1
  14. package/dist/app/manifest.d.ts +9 -9
  15. package/dist/app/manifest.js +1 -1
  16. package/dist/app/prepare.js +1 -1
  17. package/dist/app/primitive-scaffold.js +1 -1
  18. package/dist/app/readme.js +6 -6
  19. package/dist/app/scaffold.js +1 -1
  20. package/dist/app/validate.d.ts +1 -1
  21. package/dist/app/workspace-scaffold.js +1 -1
  22. package/dist/app-preview/commands.d.ts +7 -0
  23. package/dist/app-preview/commands.js +264 -0
  24. package/dist/app-preview/fingerprint.d.ts +20 -0
  25. package/dist/app-preview/fingerprint.js +32 -0
  26. package/dist/app-preview/install.d.ts +31 -0
  27. package/dist/app-preview/install.js +53 -0
  28. package/dist/app-preview/namespace-probe.d.ts +13 -0
  29. package/dist/app-preview/namespace-probe.js +50 -0
  30. package/dist/app-preview/plan.d.ts +28 -0
  31. package/dist/app-preview/plan.js +41 -0
  32. package/dist/app-preview/run.d.ts +32 -0
  33. package/dist/app-preview/run.js +48 -0
  34. package/dist/app-preview/runners.d.ts +73 -0
  35. package/dist/app-preview/runners.js +226 -0
  36. package/dist/app-preview/secrets.d.ts +48 -0
  37. package/dist/app-preview/secrets.js +104 -0
  38. package/dist/app-preview/target.d.ts +28 -0
  39. package/dist/app-preview/target.js +62 -0
  40. package/dist/artifact/delegate.d.ts +1 -12
  41. package/dist/artifact/delegate.js +43 -124
  42. package/dist/artifact/sandbox.js +1 -1
  43. package/dist/auth-cmds/commands.js +1 -2
  44. package/dist/auth.js +1 -3
  45. package/dist/bin.js +12 -2
  46. package/dist/cli-attribution.d.ts +4 -0
  47. package/dist/cli-attribution.js +25 -3
  48. package/dist/cli-errors.d.ts +9 -1
  49. package/dist/cli-errors.js +20 -9
  50. package/dist/command-contract.d.ts +7 -182
  51. package/dist/command-contract.js +9 -33
  52. package/dist/command-help.d.ts +6 -6
  53. package/dist/command-help.js +31 -27
  54. package/dist/command-telemetry.js +2 -2
  55. package/dist/config-dir.d.ts +8 -0
  56. package/dist/config-dir.js +35 -0
  57. package/dist/config.d.ts +6 -7
  58. package/dist/config.js +15 -15
  59. package/dist/docs/commands.js +9 -4
  60. package/dist/edge-auth-headers.js +1 -18
  61. package/dist/env-registry.d.ts +4 -0
  62. package/dist/env-registry.js +15 -6
  63. package/dist/envs/commands.d.ts +3 -0
  64. package/dist/envs/commands.js +11 -0
  65. package/dist/exit-codes.d.ts +16 -0
  66. package/dist/exit-codes.js +27 -0
  67. package/dist/functions/bundle.d.ts +1 -1
  68. package/dist/functions/commands.d.ts +15 -0
  69. package/dist/functions/commands.js +86 -29
  70. package/dist/functions/manifest.js +1 -1
  71. package/dist/functions/service-account-guidance.d.ts +1 -1
  72. package/dist/functions/service-account-guidance.js +2 -2
  73. package/dist/lifecycle/check.d.ts +13 -0
  74. package/dist/lifecycle/check.js +116 -0
  75. package/dist/lifecycle/commands.d.ts +14 -0
  76. package/dist/lifecycle/commands.js +121 -0
  77. package/dist/lifecycle/plan.d.ts +28 -0
  78. package/dist/lifecycle/plan.js +113 -0
  79. package/dist/lifecycle/rollback.d.ts +7 -0
  80. package/dist/lifecycle/rollback.js +89 -0
  81. package/dist/lifecycle/seq-ci-tools.d.ts +107 -0
  82. package/dist/lifecycle/seq-ci-tools.js +177 -0
  83. package/dist/lifecycle/upgrade.d.ts +3 -0
  84. package/dist/lifecycle/upgrade.js +38 -0
  85. package/dist/machine-output.d.ts +11 -2
  86. package/dist/machine-output.js +32 -10
  87. package/dist/main.d.ts +16 -6
  88. package/dist/main.js +187 -361
  89. package/dist/orgs.d.ts +45 -0
  90. package/dist/orgs.js +106 -0
  91. package/dist/orm/delegate.d.ts +1 -1
  92. package/dist/orm/delegate.js +32 -18
  93. package/dist/orm/deployment-policy.js +1 -2
  94. package/dist/orm/discover.js +6 -8
  95. package/dist/orm/execute.d.ts +1 -1
  96. package/dist/orm/execute.js +5 -6
  97. package/dist/orm/failures.js +2 -2
  98. package/dist/orm/help.d.ts +1 -1
  99. package/dist/orm/help.js +5 -5
  100. package/dist/orm/history.js +1 -2
  101. package/dist/orm/operation-show.js +1 -2
  102. package/dist/orm/version-guard.d.ts +7 -2
  103. package/dist/orm/version-guard.js +12 -7
  104. package/dist/pipeline/codegen.js +2 -2
  105. package/dist/pipeline/commands.js +9 -7
  106. package/dist/pipeline/discovery.d.ts +1 -1
  107. package/dist/pipeline/discovery.js +2 -3
  108. package/dist/pipeline/help.d.ts +1 -1
  109. package/dist/pipeline/help.js +1 -1
  110. package/dist/pipeline/lifecycle.js +1 -1
  111. package/dist/pipeline/stage-secrets.js +4 -4
  112. package/dist/pipeline/templates.js +2 -2
  113. package/dist/pnpm-auto-update.js +3 -3
  114. package/dist/principals/commands.d.ts +1 -1
  115. package/dist/principals/commands.js +13 -14
  116. package/dist/process/commands.js +4 -1
  117. package/dist/process/run-steps.d.ts +2 -2
  118. package/dist/process/runs.js +1 -2
  119. package/dist/registry/commands.d.ts +4 -0
  120. package/dist/registry/commands.js +281 -0
  121. package/dist/registry/help.d.ts +8 -0
  122. package/dist/registry/help.js +64 -0
  123. package/dist/registry/lifecycle-commands.d.ts +3 -0
  124. package/dist/registry/lifecycle-commands.js +67 -0
  125. package/dist/registry/lookup.d.ts +6 -0
  126. package/dist/registry/lookup.js +18 -0
  127. package/dist/registry/runners.d.ts +14 -0
  128. package/dist/registry/runners.js +206 -0
  129. package/dist/registry/spec.d.ts +45 -0
  130. package/dist/registry/spec.js +8 -0
  131. package/dist/repos/commands.d.ts +1 -4
  132. package/dist/repos/commands.js +3 -21
  133. package/dist/repos/github-connect-command.d.ts +10 -1
  134. package/dist/repos/github-connect-command.js +52 -11
  135. package/dist/repos/github-init.d.ts +9 -2
  136. package/dist/repos/github-init.js +18 -2
  137. package/dist/repos/init-repo.js +1 -2
  138. package/dist/run-pinned.d.ts +48 -0
  139. package/dist/run-pinned.js +127 -0
  140. package/dist/sdk-source.d.ts +64 -0
  141. package/dist/sdk-source.js +199 -0
  142. package/dist/secrets/commands.d.ts +1 -1
  143. package/dist/secrets/commands.js +29 -24
  144. package/dist/service-accounts/commands.d.ts +1 -1
  145. package/dist/service-accounts/commands.js +4 -5
  146. package/dist/staged-env.d.ts +14 -0
  147. package/dist/staged-env.js +73 -0
  148. package/dist/storage/commands.js +21 -22
  149. package/dist/templates/catalog.d.ts +5 -5
  150. package/dist/templates/catalog.js +1 -1
  151. package/dist/update-check.js +3 -3
  152. package/dist/version-support.d.ts +39 -0
  153. package/dist/version-support.js +71 -0
  154. package/package.json +11 -10
  155. package/release-summary.json +4 -1
  156. package/dist/preview.d.ts +0 -90
  157. package/dist/preview.js +0 -292
@@ -4,7 +4,7 @@
4
4
  * Delegates to `runCli` from the `@sequenceholdings/artifact-studio/cli`
5
5
  * library export, so the command implementations live in one place. We:
6
6
  *
7
- * 1. Resolve `--env` from `~/.config/lattice/config.toml`.
7
+ * 1. Resolve `--env` from `~/.config/seq-studio/config.toml`.
8
8
  * 2. Set `ARTIFACT_STUDIO_BASE_URL` so artifact-studio's API client
9
9
  * uses the resolved URL (instead of its own built-in env map).
10
10
  * 3. Install an internal token provider so auth is shared with the rest of
@@ -15,11 +15,13 @@
15
15
  * from Atlas instead, and only commands that need neither a local login nor a
16
16
  * package registry run: an agent sandbox reaches its Atlas origin and nothing else.
17
17
  */
18
+ import { resolve as resolvePath } from 'node:path';
19
+ import { BREAK_GLASS_HEADER, cliAttributionHeaders } from '../cli-attribution.js';
20
+ import { ExitCode } from '../exit-codes.js';
18
21
  import { getAccessTokenWithMode, tryGetAccessTokenWithMode } from '../auth.js';
19
22
  import { ARTIFACT_SANDBOX_HELP, INIT_INTO_REPO_HELP } from '../command-help.js';
20
23
  import { readConfig, resolveConfiguredEnv } from '../config.js';
21
24
  import { normalizeShortEnvFlag, readEnvFromArgv, withoutEnvFlag } from '../env-flags.js';
22
- import { PREVIEW_DOMAIN, PREVIEW_PROJECT, resolvePreviewByPr } from '../preview.js';
23
25
  import { sandboxTarget } from '../sandbox-auth.js';
24
26
  import { runSandboxArtifactCommand } from './sandbox.js';
25
27
  const ARTIFACT_USAGE = `usage:
@@ -79,14 +81,6 @@ const ARTIFACT_USAGE = `usage:
79
81
  capability workspace IDs against -e. It does not scan source text or arbitrary
80
82
  config values for URLs or UUIDs. Repository identity checks still apply.
81
83
 
82
- Per-PR preview environments (https://studio-atlas-git-<slug>.preview.seqholdings.com):
83
- -e preview:<branch-or-slug> compute the preview host from a branch name
84
- --pr <number> resolve the preview host from a PR (handles long slugs)
85
- --env-url <url> target an explicit preview URL (escape hatch)
86
-
87
- Preview deploys sit behind a Cloudflare WAF gate. Off the company network/VPN,
88
- set PREVIEW_ACCESS_HEADER=<secret> and the CLI sends it as x-preview-access.
89
-
90
84
  Authenticate with: seq-studio login
91
85
 
92
86
  ${INIT_INTO_REPO_HELP}
@@ -155,40 +149,19 @@ export async function runArtifactCommand(sub, rest) {
155
149
  // artifact plan -e staging` would land `-e` as positional and
156
150
  // `staging` as the next positional, with `flags.env` undefined.
157
151
  const normalizedRest = normalizeShortEnvFlag(rest);
158
- // Pull off seq-studio-only preview flags (`--pr`, `--env-url`) so they're not
159
- // forwarded to artifact-studio (its parser would store them as stray flags).
160
- const { rest: forwardRest, prNumber, envUrl } = extractPreviewFlags(normalizedRest);
161
152
  // Resolve --env if present so we can map to lattice config URLs. We
162
153
  // pull from the cleaned argv so both `-e` and `--env` paths work.
163
- const requested = readEnvFromArgv(forwardRest);
154
+ const requested = readEnvFromArgv(normalizedRest);
164
155
  let resolved;
165
- let argvForCli = forwardRest;
166
- if (envUrl !== undefined) {
167
- const validated = validatePreviewEnvUrl(envUrl);
168
- // Explicit override wins over everything. Keep the user's --env name if
169
- // they gave one, else label it `preview`.
170
- resolved = { name: requested ?? 'preview', url: validated };
171
- argvForCli = ensureEnvFlag(forwardRest, resolved.name);
172
- }
173
- else if (prNumber !== undefined) {
174
- const preview = await resolvePreviewByPr({ pr: prNumber });
175
- resolved = { name: `preview:${preview.slug}`, url: preview.url };
176
- argvForCli = ensureEnvFlag(forwardRest, resolved.name);
177
- }
178
- else if (requested) {
156
+ let argvForCli = normalizedRest;
157
+ if (requested) {
179
158
  resolved = await resolveConfiguredEnv({ requested });
180
- // For `preview:<slug>` normalize the forwarded --env to the canonical name.
159
+ // Forward the canonical name when resolution normalized the requested one.
181
160
  if (resolved.name !== requested)
182
- argvForCli = ensureEnvFlag(forwardRest, resolved.name);
161
+ argvForCli = ensureEnvFlag(normalizedRest, resolved.name);
183
162
  }
184
- if (resolved) {
163
+ if (resolved)
185
164
  process.env['ARTIFACT_STUDIO_BASE_URL'] = resolved.url;
186
- // When targeting a preview host, thread the Cloudflare WAF bypass header so
187
- // deploys work off the company network/VPN (mirrors atlas-ui-shot). Harmless
188
- // on built-in envs, so we only gate it on the host actually being a preview.
189
- if (isPreviewUrl(resolved.url))
190
- applyPreviewAccessHeader();
191
- }
192
165
  // Always hand artifact-studio the configured env map (config.toml +
193
166
  // registered deployments). Commands that resolve an env *name*
194
167
  // without an explicit --env flag — the stored `.artifact-studio/config.json`
@@ -198,13 +171,15 @@ export async function runArtifactCommand(sub, rest) {
198
171
  process.env['ARTIFACT_STUDIO_ENV_URLS'] = JSON.stringify(Object.fromEntries(Object.entries(routingConfig.envs).map(([name, { url }]) => [name, url])));
199
172
  // Lazy import so `process` / `doctor` commands don't pull in
200
173
  // artifact-studio's vite/react/tailwind dependency graph.
201
- const { getConfiguredDefaultEnv, runCli: runArtifactStudio, setTokenProvider } = await import('@sequenceholdings/artifact-studio/cli');
174
+ const { getConfiguredDefaultEnv, runCli: runArtifactStudio, setTokenProvider } = await (await import('../sdk-source.js')).importSdk({ name: '@sequenceholdings/artifact-studio', subpath: './cli',
175
+ bundled: () => import('@sequenceholdings/artifact-studio/cli'), cwd: await localAppDirectory({ sub, argv: argvForCli }) });
202
176
  const authEnvName = resolved?.name ?? (await getConfiguredDefaultEnv());
203
177
  const targetUrl = resolved?.url ??
204
178
  process.env['ARTIFACT_STUDIO_BASE_URL']?.trim() ??
205
179
  (authEnvName ? routingConfig.envs[authEnvName]?.url : undefined);
206
180
  if (targetUrl)
207
181
  process.env['ARTIFACT_STUDIO_BASE_URL'] = targetUrl;
182
+ applyBreakGlassHeader();
208
183
  setTokenProvider(async ({ allowInteractiveLogin, sourceEnvironment }) => {
209
184
  const source = sourceEnvironment
210
185
  ? await resolveConfiguredEnv({ requested: sourceEnvironment })
@@ -214,7 +189,7 @@ export async function runArtifactCommand(sub, rest) {
214
189
  ? await getAccessTokenWithMode(selected)
215
190
  : await tryGetAccessTokenWithMode({ failClosedForM2m: true, ...selected }));
216
191
  });
217
- return runArtifactStudio([sub, ...argvForCli]);
192
+ return runArtifactStudio([sub, ...argvForCli], { usageExitCode: ExitCode.Usage });
218
193
  }
219
194
  /**
220
195
  * Artifact Studio uses only credentials the CLI obtained itself, never a bearer
@@ -227,41 +202,6 @@ function artifactCredential(auth) {
227
202
  throw new Error('Sandbox tokens reach Artifact Studio only in sandbox token mode.');
228
203
  return { authMode: auth.authMode, token: auth.token };
229
204
  }
230
- /**
231
- * Strip the seq-studio-only `--pr <number>` and `--env-url <url>` flags from
232
- * argv and return the rest (forwarded to artifact-studio) plus the parsed
233
- * values. These never reach artifact-studio — they're consumed here to resolve
234
- * the preview base URL.
235
- */
236
- export function extractPreviewFlags(argv) {
237
- const rest = [];
238
- let prNumber;
239
- let envUrl;
240
- for (let i = 0; i < argv.length; i++) {
241
- const arg = argv[i];
242
- if (arg === undefined)
243
- continue;
244
- const [flag, inlineValue] = splitInlineValue(arg);
245
- if (flag === '--pr') {
246
- const value = inlineValue ?? takeValue(argv, i, () => (i += 1));
247
- const parsed = Number(value);
248
- if (!Number.isInteger(parsed) || parsed <= 0) {
249
- throw new Error(`--pr requires a positive integer (got "${value ?? ''}").`);
250
- }
251
- prNumber = parsed;
252
- }
253
- else if (flag === '--env-url') {
254
- const value = inlineValue ?? takeValue(argv, i, () => (i += 1));
255
- if (!value)
256
- throw new Error('--env-url requires a URL value.');
257
- envUrl = value;
258
- }
259
- else {
260
- rest.push(arg);
261
- }
262
- }
263
- return { rest, prNumber, envUrl };
264
- }
265
205
  function splitInlineValue(arg) {
266
206
  const eq = arg.indexOf('=');
267
207
  if (arg.startsWith('--') && eq !== -1)
@@ -300,59 +240,38 @@ function ensureEnvFlag(argv, name) {
300
240
  out.push('--env', name);
301
241
  return out;
302
242
  }
303
- function stripTrailingSlash(url) {
304
- return url.replace(/\/+$/, '');
305
- }
306
- function validatePreviewEnvUrl(value) {
307
- const trimmed = stripTrailingSlash(value.trim());
308
- let parsed;
309
- try {
310
- parsed = new URL(trimmed);
311
- }
312
- catch {
313
- throw new Error(`--env-url must be a valid URL (got "${value}").`);
314
- }
315
- if (parsed.username || parsed.password) {
316
- throw new Error('--env-url must not include a username/password component.');
317
- }
318
- if (parsed.protocol !== 'https:') {
319
- throw new Error(`--env-url must be an https preview URL on *.${PREVIEW_DOMAIN} (got "${parsed.protocol}//").`);
320
- }
321
- if (parsed.pathname !== '' && parsed.pathname !== '/') {
322
- throw new Error('--env-url must be an origin URL without a path component.');
323
- }
324
- if (parsed.search || parsed.hash) {
325
- throw new Error('--env-url must not include querystring or hash components.');
326
- }
327
- const host = parsed.hostname.toLowerCase();
328
- if (!host.endsWith(`.${PREVIEW_DOMAIN}`)) {
329
- throw new Error(`--env-url must be an https preview URL on *.${PREVIEW_DOMAIN} (got "${parsed.hostname}").`);
330
- }
331
- const expectedPrefix = `${PREVIEW_PROJECT}-git-`;
332
- if (!host.startsWith(expectedPrefix)) {
333
- throw new Error(`--env-url must target a ${PREVIEW_PROJECT} preview alias (expected host starting with "${expectedPrefix}", got "${parsed.hostname}").`);
334
- }
335
- return parsed.origin;
243
+ /** Subcommands whose first positional is the local application directory (artifact-studio's `[dir]`). */
244
+ const DIRECTORY_SUBCOMMANDS = new Set(['validate', 'build', 'plan', 'deploy', 'dev']);
245
+ /**
246
+ * The local application a directory-based command names, so its SDK and .seq/github.yml select the SDK copy.
247
+ * Undefined (the current directory) for other commands and for remote sources (--repo, --git-url).
248
+ */
249
+ async function localAppDirectory({ sub, argv }) {
250
+ if (!DIRECTORY_SUBCOMMANDS.has(sub))
251
+ return undefined;
252
+ const { parseArgs } = await import('../argv.js');
253
+ const args = parseArgs(argv);
254
+ if (args.flags.repo !== undefined || args.flags['git-url'] !== undefined)
255
+ return undefined;
256
+ return resolvePath(args.positional[0] ?? '.');
336
257
  }
337
- function isPreviewUrl(url) {
258
+ /**
259
+ * Carry `--break-glass` through artifact-studio's own transport, which does not
260
+ * use the CLI's (cli-attribution.ts). Added to ARTIFACT_STUDIO_EXTRA_HEADERS,
261
+ * which artifact-studio sends only to ARTIFACT_STUDIO_BASE_URL's origin.
262
+ */
263
+ function applyBreakGlassHeader() {
264
+ const reason = cliAttributionHeaders()[BREAK_GLASS_HEADER];
265
+ if (!reason)
266
+ return;
267
+ let existing = {};
338
268
  try {
339
- return new URL(url).hostname.endsWith(`.${PREVIEW_DOMAIN}`);
269
+ const parsed = JSON.parse(process.env['ARTIFACT_STUDIO_EXTRA_HEADERS'] ?? '{}');
270
+ if (parsed && typeof parsed === 'object' && !Array.isArray(parsed))
271
+ existing = parsed;
340
272
  }
341
273
  catch {
342
- return false;
274
+ // artifact-studio ignores malformed extra headers; replace them with ours.
343
275
  }
344
- }
345
- /**
346
- * Thread the Cloudflare WAF bypass header through artifact-studio's HTTP client
347
- * via ARTIFACT_STUDIO_EXTRA_HEADERS (read in artifact-studio/src/api.ts). Reads
348
- * the secret from PREVIEW_ACCESS_HEADER — the same env var atlas-ui-shot uses.
349
- * No-op when the secret isn't set (engineer is expected to be on the VPN).
350
- */
351
- function applyPreviewAccessHeader() {
352
- const secret = process.env['PREVIEW_ACCESS_HEADER']?.trim();
353
- if (!secret)
354
- return;
355
- process.env['ARTIFACT_STUDIO_EXTRA_HEADERS'] = JSON.stringify({
356
- 'x-preview-access': secret,
357
- });
276
+ process.env['ARTIFACT_STUDIO_EXTRA_HEADERS'] = JSON.stringify({ ...existing, [BREAK_GLASS_HEADER]: reason });
358
277
  }
@@ -26,7 +26,7 @@ const SANDBOX_REFUSED_COMMANDS = {
26
26
  logout: 'Atlas supplies the sandbox token, so there is no login.',
27
27
  };
28
28
  /** Flags that reach a source or deployment other than the sandbox's one Atlas origin. */
29
- const SANDBOX_REFUSED_FLAGS = ['--git-url', '--source-env', '--pr', '--env-url'];
29
+ const SANDBOX_REFUSED_FLAGS = ['--git-url', '--source-env'];
30
30
  /** Commands whose source is a build; in a sandbox it must come from a Git Service repository. */
31
31
  const SANDBOX_REPOSITORY_COMMANDS = new Set(['build', 'plan', 'deploy']);
32
32
  /** Commands that take no --env, so the sandbox environment is not added to their argv. */
@@ -49,7 +49,6 @@ export async function runAuthCommand(sub, args) {
49
49
  }
50
50
  }
51
51
  catch (error) {
52
- printCliError(error);
53
- return 1;
52
+ return printCliError(error);
54
53
  }
55
54
  }
package/dist/auth.js CHANGED
@@ -88,9 +88,7 @@ export function isSequenceAuthEnvName(envName) {
88
88
  return (envName === SEQUENCE_REALM ||
89
89
  SEQUENCE_BUILTIN_ENVS.has(envName) ||
90
90
  envName === 'worktree' ||
91
- envName.startsWith('local:') ||
92
- envName === 'preview' ||
93
- envName.startsWith('preview:'));
91
+ envName.startsWith('local:'));
94
92
  }
95
93
  // Both hostnames terminate at Sequence's one Auth0 tenant. Keep this explicit:
96
94
  // discovery must never be able to select an arbitrary credential recipient.
package/dist/bin.js CHANGED
@@ -2,6 +2,16 @@
2
2
  import { commandTelemetryName, run } from './main.js';
3
3
  import { parseArgs } from './argv.js';
4
4
  import { beginCommandTelemetry, finishCommandTelemetry } from './command-telemetry.js';
5
+ import { migrateLegacyConfigDir } from './config-dir.js';
6
+ import { exitCodeFor } from './exit-codes.js';
7
+ import { setDefaultAutoSelectFamilyAttemptTimeout } from 'node:net';
8
+ // Node's 250ms default gives up on IPv6/IPv4 happy-eyeballs too early on slow
9
+ // networks and fails with `fetch failed`; set it here so nobody needs NODE_OPTIONS.
10
+ setDefaultAutoSelectFamilyAttemptTimeout(2500);
11
+ // Once per machine: ~/.config/lattice becomes ~/.config/seq-studio (old path symlinked).
12
+ const migrationError = migrateLegacyConfigDir();
13
+ if (migrationError)
14
+ console.error(`note: could not move ~/.config/lattice to ~/.config/seq-studio: ${migrationError.message}`);
5
15
  // A consumer may close stdout while a remote operation continues. Stop local
6
16
  // output quietly; never cancel or retry the remote operation.
7
17
  process.stdout.on('error', (error) => {
@@ -22,8 +32,8 @@ let commandError;
22
32
  run(argv)
23
33
  .catch((error) => {
24
34
  commandError = error;
25
- console.error(error instanceof Error ? error.message : error);
26
- return 1;
35
+ console.error(`error ${error instanceof Error ? error.message : String(error)}`);
36
+ return exitCodeFor(error);
27
37
  })
28
38
  // The update notice runs after the command so it never delays real output,
29
39
  // and it is best-effort (never throws, never changes the exit code).
@@ -1,3 +1,7 @@
1
+ /** The reason `--break-glass` gave, which every request of this command carries (set by the router). */
2
+ export declare const BREAK_GLASS_ENV = "SEQ_STUDIO_BREAK_GLASS";
3
+ export declare const BREAK_GLASS_HEADER = "x-seq-break-glass";
4
+ export declare const DEPLOY_NOTICE_HEADER = "x-seq-deploy-notice";
1
5
  export declare function cliAttributionHeaders(): Record<string, string>;
2
6
  /** Inject only at the CLI-owned transport, after its origin/auth/redirect checks. */
3
7
  export declare const fetchWithCliAttribution: typeof fetch;
@@ -1,8 +1,16 @@
1
1
  import { currentVersion } from './update-check.js';
2
+ import { enforceSupportedVersion } from './version-support.js';
2
3
  // Read this installed package, never the delegated Artifact Studio SDK version.
3
4
  const version = currentVersion();
5
+ /** The reason `--break-glass` gave, which every request of this command carries (set by the router). */
6
+ export const BREAK_GLASS_ENV = 'SEQ_STUDIO_BREAK_GLASS';
7
+ export const BREAK_GLASS_HEADER = 'x-seq-break-glass';
8
+ export const DEPLOY_NOTICE_HEADER = 'x-seq-deploy-notice';
4
9
  export function cliAttributionHeaders() {
5
- return { 'x-sequence-client': 'seq-studio', 'x-sequence-client-version': version };
10
+ const reason = process.env[BREAK_GLASS_ENV]?.trim();
11
+ return { 'x-sequence-client': 'seq-studio', 'x-sequence-client-version': version,
12
+ // Header values must be ByteString: a reason in another script is sent percent-encoded.
13
+ ...(reason ? { [BREAK_GLASS_HEADER]: encodeURIComponent(reason).slice(0, 1000) } : {}) };
6
14
  }
7
15
  /** Inject only at the CLI-owned transport, after its origin/auth/redirect checks. */
8
16
  export const fetchWithCliAttribution = (input, init) => {
@@ -15,10 +23,24 @@ export const fetchWithCliAttribution = (input, init) => {
15
23
  if (name.toLowerCase() in identity)
16
24
  delete headers[name];
17
25
  }
18
- return globalThis.fetch(input, { ...init, headers: { ...headers, ...identity } });
26
+ return globalThis.fetch(input, { ...init, headers: { ...headers, ...identity } }).then(checked);
19
27
  }
20
28
  const headers = new Headers(source);
21
29
  for (const [name, value] of Object.entries(identity))
22
30
  headers.set(name, value);
23
- return globalThis.fetch(input, { ...init, headers });
31
+ return globalThis.fetch(input, { ...init, headers }).then(checked);
24
32
  };
33
+ const shownNotices = new Set();
34
+ /**
35
+ * Every Atlas response names the CLI versions it supports; refuse below its minimum. A deploy of a resource a
36
+ * GitHub repository controls carries a notice saying so, shown once per command.
37
+ */
38
+ function checked(response) {
39
+ enforceSupportedVersion(response, version);
40
+ const notice = response.headers.get(DEPLOY_NOTICE_HEADER)?.trim();
41
+ if (notice && !shownNotices.has(notice)) {
42
+ shownNotices.add(notice);
43
+ console.error(`note: ${notice}`);
44
+ }
45
+ return response;
46
+ }
@@ -1,5 +1,13 @@
1
1
  export declare const LOG = "[seq-studio]";
2
2
  /** Map common apply failure reasons to clearer copy (original reason is preserved). */
3
3
  export declare function clarifyApplyFailureReason(reason: string): string;
4
+ /**
5
+ * The 1.0 error shape: `error <what>`, then indented detail lines, ending with
6
+ * the next step when one is known.
7
+ */
4
8
  export declare function formatCliError(error: unknown): string[];
5
- export declare function printCliError(error: unknown): void;
9
+ /**
10
+ * Terminal command catches print through this and return its exit code
11
+ * (`return printCliError(error)`). Formatting alone remains side-effect free.
12
+ */
13
+ export declare function printCliError(error: unknown): number;
@@ -1,6 +1,7 @@
1
1
  import { PlatformError } from '@sequenceholdings/platform';
2
2
  import { recordTerminalCommandError } from './command-telemetry.js';
3
3
  import { AtlasApiError } from './atlas-client.js';
4
+ import { exitCodeFor } from './exit-codes.js';
4
5
  import { DEVBOX_TOKEN_DIR_ENV, devboxUnauthorizedHint } from './host-token.js';
5
6
  export const LOG = '[seq-studio]';
6
7
  /** Map common apply failure reasons to clearer copy (original reason is preserved). */
@@ -52,11 +53,14 @@ function nextStepForAtlasError(error) {
52
53
  const devbox = devboxUnauthorizedHint();
53
54
  return devbox ? `Next step: ${devbox}` : 'Next step: run `seq-studio login` and retry.';
54
55
  }
56
+ if (error.status === 403 && error.code === 'deploys_from_github') {
57
+ return 'Next step: merge the change in GitHub (or Promote) and let CI deploy it; in an emergency, retry with --break-glass "<reason>".';
58
+ }
55
59
  if (error.status === 403) {
56
60
  return 'Next step: confirm `-e` targets the right environment and you have the required access grant.';
57
61
  }
58
62
  if (error.status === 404 && msg.includes('function')) {
59
- return 'Next step: run `seq-studio functions list -e <env>` and confirm `managed-function.yml` `function.id` matches a remote slug.';
63
+ return 'Next step: run `seq-studio function list -e <env>` and confirm `managed-function.yml` `function.id` matches a remote slug.';
60
64
  }
61
65
  if (error.status === 409 && msg.includes('version')) {
62
66
  return 'Next step: rerun deploy — another upload may have taken the version slot.';
@@ -64,37 +68,44 @@ function nextStepForAtlasError(error) {
64
68
  if (error.status === 413 || msg.includes('too large')) {
65
69
  if (error.path.startsWith('/api/data-pipelines/'))
66
70
  return 'Next step: reduce the request size and retry; pipeline query accepts up to 10,000 SQL characters.';
67
- return 'Next step: run `seq-studio functions build` and reduce bundle size or dependencies.';
71
+ return 'Next step: run `seq-studio function build` and reduce bundle size or dependencies.';
68
72
  }
69
73
  if (error.status === 503)
70
74
  return nextStepFor503(error);
71
75
  if (error.status === 524 || msg.includes('timeout') || msg.includes('timed out')) {
72
76
  if (error.path.startsWith('/api/data-pipelines/'))
73
77
  return 'Next step: retry the read; if it persists, confirm the environment and backend availability.';
74
- return 'Next step: retry; if it persists check VPN/network, then `seq-studio functions list` or logs to see whether the operation completed.';
78
+ return 'Next step: retry; if it persists check VPN/network, then `seq-studio function list` or logs to see whether the operation completed.';
75
79
  }
76
80
  return null;
77
81
  }
82
+ /**
83
+ * The 1.0 error shape: `error <what>`, then indented detail lines, ending with
84
+ * the next step when one is known.
85
+ */
78
86
  export function formatCliError(error) {
79
87
  // Shared domain clients retain the CLI's existing status/path guidance.
80
88
  if (error instanceof PlatformError)
81
89
  return formatCliError(new AtlasApiError(error.status, error.message, error.path ?? '', '', { code: error.code }));
82
90
  if (error instanceof AtlasApiError) {
83
- const lines = [`${LOG} ${error.status}${error.statusText ? ` ${error.statusText}` : ''}: ${error.message}`];
91
+ const lines = [`error ${error.status}${error.statusText ? ` ${error.statusText}` : ''}: ${error.message}`];
84
92
  if (error.path)
85
- lines.push(`${LOG} request: ${error.path}`);
93
+ lines.push(` request: ${error.path}`);
86
94
  const next = nextStepForAtlasError(error);
87
95
  if (next)
88
- lines.push(`${LOG} ${next}`);
96
+ lines.push(` next: ${next.replace(/^Next step: /, '')}`);
89
97
  return lines;
90
98
  }
91
- return [`${LOG} ${error instanceof Error ? error.message : String(error)}`];
99
+ return [`error ${error instanceof Error ? error.message : String(error)}`];
92
100
  }
93
- // Terminal command catches use this before returning a failure exit code.
94
- // Formatting alone remains side-effect free.
101
+ /**
102
+ * Terminal command catches print through this and return its exit code
103
+ * (`return printCliError(error)`). Formatting alone remains side-effect free.
104
+ */
95
105
  export function printCliError(error) {
96
106
  recordTerminalCommandError(error);
97
107
  for (const line of formatCliError(error)) {
98
108
  console.error(line);
99
109
  }
110
+ return exitCodeFor(error);
100
111
  }
@@ -1,185 +1,10 @@
1
- /** Machine-readable summary of the CLI surface, kept independent of command implementations. */
2
- export declare const COMMAND_CONTRACT: readonly [{
3
- readonly name: "init";
4
- readonly description: "Scaffold an app workspace or use a published template; --repo scaffolds into a git-service repo";
5
- readonly lifecycle: "preview";
6
- readonly access: "mixed";
7
- readonly subcommands: readonly [];
8
- }, {
9
- readonly name: "add";
10
- readonly description: "Add a primitive to an app workspace";
11
- readonly lifecycle: "preview";
12
- readonly access: "offline";
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 [];
20
- }, {
21
- readonly name: "deploy";
22
- readonly description: "Deploy an app workspace";
23
- readonly lifecycle: "preview";
24
- readonly access: "authenticated";
25
- readonly subcommands: readonly [];
26
- }, {
27
- readonly name: "process";
28
- readonly description: "Build and operate Lattice processes";
29
- readonly lifecycle: "preview";
30
- readonly access: "mixed";
31
- readonly subcommands: readonly ["init", "lint", "plan", "apply", "test", "simulate", "bundle", "promote", "pull", "runs", "safety-baseline"];
32
- }, {
33
- readonly name: "artifact";
34
- readonly description: "Build and operate Artifact Studio apps";
35
- readonly lifecycle: "stable";
36
- readonly access: "mixed";
37
- readonly subcommands: readonly ["init", "whoami", "link", "env", "status", "list", "show", "validate", "build", "plan", "deploy", "dev", "promote", "pull", "rollback"];
38
- }, {
39
- readonly name: "functions";
40
- readonly description: "Build and operate Managed Functions";
41
- readonly lifecycle: "stable";
42
- readonly access: "authenticated";
43
- readonly subcommands: readonly ["init", "build", "deploy", "list", "show", "limits", "invoke", "logs", "promote", "rollback", "delete"];
44
- }, {
45
- readonly name: "agents";
46
- readonly description: "Validate and deploy typed agent definitions";
47
- readonly lifecycle: "preview";
48
- readonly access: "mixed";
49
- readonly subcommands: readonly ["init", "validate", "bundle", "plan", "apply", "list", "show"];
50
- }, {
51
- readonly name: "secrets";
52
- readonly description: "Manage organization-owned secrets";
53
- readonly lifecycle: "stable";
54
- readonly access: "authenticated";
55
- readonly subcommands: readonly ["create", "set", "list", "attach", "detach", "apply"];
56
- }, {
57
- readonly name: "repos";
58
- readonly description: "Manage repositories and native CI; ci init is offline";
59
- readonly lifecycle: "stable";
60
- readonly access: "mixed";
61
- readonly subcommands: readonly ["list", "namespaces", "show", "identity", "create", "clone", "attach-login", "pull", "pulls", "delete", "ci"];
62
- }, {
63
- readonly name: "repo";
64
- readonly description: "Set up a GitHub repository and connect it to Atlas deploys";
65
- readonly lifecycle: "preview";
66
- readonly access: "mixed";
67
- readonly subcommands: readonly ["init", "connect", "bind", "disconnect", "status"];
68
- }, {
69
- readonly name: "templates";
70
- readonly description: "Publish, synchronize, and list repository templates";
71
- readonly lifecycle: "internal";
72
- readonly access: "mixed";
73
- readonly subcommands: readonly ["publish", "sync", "list"];
74
- }, {
75
- readonly name: "pipeline";
76
- readonly description: "Discover and operate Data Pipelines";
77
- readonly lifecycle: "preview";
78
- readonly access: "staff";
79
- readonly subcommands: readonly ["list", "assets", "search", "describe", "schema", "sample", "query", "init", "validate", "plan", "deploy", "status", "migrate", "adopt", "unbind", "retire", "run-now", "promote", "rollback"];
80
- }, {
81
- readonly name: "docs";
82
- readonly description: "Search and read the environment's developer documentation";
83
- readonly lifecycle: "preview";
84
- readonly access: "public";
85
- readonly subcommands: readonly ["search", "read", "list"];
86
- }, {
87
- readonly name: "feedback";
88
- readonly description: "Submit agent feedback";
89
- readonly lifecycle: "preview";
90
- readonly access: "authenticated";
91
- readonly subcommands: readonly ["submit"];
92
- }, {
93
- readonly name: "auth";
94
- readonly description: "Manage Git authentication";
95
- readonly lifecycle: "stable";
96
- readonly access: "authenticated";
97
- readonly subcommands: readonly ["whoami", "git-credential", "pat"];
98
- }, {
99
- readonly name: "orm";
100
- readonly description: "Author and operate ORM namespaces";
101
- readonly lifecycle: "preview";
102
- readonly access: "mixed";
103
- readonly subcommands: readonly ["init", "generate", "validate", "plan", "apply", "history", "deployment-policy", "execute", "namespaces", "describe", "read", "sql", "diff", "migrate-from-yaml", "import"];
104
- }, {
105
- readonly name: "envs";
106
- readonly description: "Manage CLI environments";
107
- readonly lifecycle: "stable";
108
- readonly access: "mixed";
109
- readonly subcommands: readonly ["add", "list"];
110
- }, {
111
- readonly name: "login";
112
- readonly description: "Authenticate with Sequence";
113
- readonly lifecycle: "stable";
114
- readonly access: "public";
115
- readonly subcommands: readonly [];
116
- }, {
117
- readonly name: "logout";
118
- readonly description: "Remove cached user tokens";
119
- readonly lifecycle: "stable";
120
- readonly access: "public";
121
- readonly subcommands: readonly [];
122
- }, {
123
- readonly name: "doctor";
124
- readonly description: "Diagnose CLI configuration and access";
125
- readonly lifecycle: "stable";
126
- readonly access: "mixed";
127
- readonly subcommands: readonly [];
128
- }, {
129
- readonly name: "telemetry";
130
- readonly description: "Control authenticated command telemetry";
131
- readonly lifecycle: "preview";
132
- readonly access: "offline";
133
- readonly subcommands: readonly ["enable", "disable", "status"];
134
- }, {
135
- readonly name: "updater";
136
- readonly description: "Control global pnpm CLI updates";
137
- readonly lifecycle: "preview";
138
- readonly access: "offline";
139
- readonly subcommands: readonly ["status", "track"];
140
- }, {
141
- readonly name: "version";
142
- readonly description: "Print the installed CLI version";
143
- readonly lifecycle: "stable";
144
- readonly access: "offline";
145
- readonly subcommands: readonly [];
146
- }, {
147
- readonly name: "help";
148
- readonly description: "Show command help";
149
- readonly lifecycle: "stable";
150
- readonly access: "offline";
151
- readonly subcommands: readonly [];
152
- }, {
153
- readonly name: "storage";
154
- readonly description: "Manage Workspaces V2 file storage";
155
- readonly lifecycle: "preview";
156
- readonly access: "authenticated";
157
- readonly subcommands: readonly ["init", "validate", "apply", "list", "show", "mkdir", "upload", "import", "uploads", "reconcile", "download", "access", "trash", "restore", "purge", "operations", "abort", "delete"];
158
- }, {
159
- readonly name: "access";
160
- readonly description: "Manage resource access on every primitive";
161
- readonly lifecycle: "preview";
162
- readonly access: "authenticated";
163
- readonly subcommands: readonly ["definitions", "list", "grant", "revoke", "resolve"];
164
- }, {
165
- readonly name: "principals";
166
- readonly description: "Find principals and manage local groups";
167
- readonly lifecycle: "preview";
168
- readonly access: "authenticated";
169
- readonly subcommands: readonly ["search", "users", "groups"];
170
- }, {
171
- readonly name: "service-accounts";
172
- readonly description: "Manage runtime service accounts";
173
- readonly lifecycle: "preview";
174
- readonly access: "authenticated";
175
- readonly subcommands: readonly ["list", "show", "create"];
176
- }, {
177
- readonly name: "capabilities";
178
- readonly description: "Print the supported CLI command surface";
179
- readonly lifecycle: "blocked";
180
- readonly access: "offline";
181
- readonly subcommands: readonly [];
182
- }];
1
+ export declare const COMMAND_CONTRACT: {
2
+ name: string;
3
+ description: string;
4
+ lifecycle: import("./registry/spec.js").Lifecycle;
5
+ access: import("./registry/spec.js").Access;
6
+ subcommands: string[];
7
+ }[];
183
8
  export declare function renderCapabilities({ json }?: {
184
9
  json?: boolean;
185
10
  }): string;