@sequenceholdings/studio-cli 0.7.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/README.md +390 -54
  2. package/dist/access/commands.d.ts +1 -1
  3. package/dist/access/commands.js +102 -55
  4. package/dist/access/custom-role-hosts.d.ts +3 -0
  5. package/dist/access/custom-role-hosts.js +88 -0
  6. package/dist/access/group-rosters.d.ts +6 -0
  7. package/dist/access/group-rosters.js +33 -0
  8. package/dist/access/host-contract.d.ts +55 -0
  9. package/dist/access/host-contract.js +33 -0
  10. package/dist/access/hosts.d.ts +4 -0
  11. package/dist/access/hosts.js +60 -0
  12. package/dist/access/principal.d.ts +16 -0
  13. package/dist/access/principal.js +36 -0
  14. package/dist/access/roles.d.ts +18 -0
  15. package/dist/access/roles.js +89 -0
  16. package/dist/access/tier-hosts.d.ts +12 -0
  17. package/dist/access/tier-hosts.js +206 -0
  18. package/dist/agents/commands.d.ts +1 -1
  19. package/dist/agents/commands.js +76 -16
  20. package/dist/agents/scaffold.js +8 -3
  21. package/dist/app/commands.d.ts +3 -1
  22. package/dist/app/commands.js +88 -12
  23. package/dist/app/manifest.d.ts +2 -2
  24. package/dist/app/official-source.d.ts +4 -2
  25. package/dist/app/official-source.js +6 -4
  26. package/dist/app/readme.js +2 -2
  27. package/dist/app/validate.d.ts +16 -0
  28. package/dist/app/validate.js +40 -0
  29. package/dist/app/workspace-model.js +4 -0
  30. package/dist/app/workspace-scaffold.js +5 -3
  31. package/dist/app/workspace.d.ts +2 -0
  32. package/dist/app/workspace.js +1 -1
  33. package/dist/artifact/delegate.js +26 -3
  34. package/dist/artifact/sandbox.js +2 -1
  35. package/dist/atlas-client.d.ts +17 -8
  36. package/dist/atlas-client.js +146 -62
  37. package/dist/bin.js +10 -1
  38. package/dist/cli-errors.js +12 -3
  39. package/dist/command-contract.d.ts +14 -2
  40. package/dist/command-contract.js +4 -2
  41. package/dist/command-help.d.ts +9 -7
  42. package/dist/command-help.js +56 -12
  43. package/dist/env-flags.d.ts +7 -0
  44. package/dist/env-flags.js +23 -0
  45. package/dist/functions/commands.d.ts +4 -0
  46. package/dist/functions/commands.js +127 -11
  47. package/dist/functions/manifest.d.ts +5 -0
  48. package/dist/functions/manifest.js +44 -23
  49. package/dist/functions/service-account-guidance.d.ts +21 -0
  50. package/dist/functions/service-account-guidance.js +62 -0
  51. package/dist/functions/workspace.d.ts +11 -0
  52. package/dist/functions/workspace.js +52 -0
  53. package/dist/main.d.ts +2 -1
  54. package/dist/main.js +17 -3
  55. package/dist/orm/delegate.d.ts +1 -0
  56. package/dist/orm/delegate.js +65 -12
  57. package/dist/orm/discover-schema.d.ts +26 -0
  58. package/dist/orm/discover-schema.js +5 -0
  59. package/dist/orm/execute.js +11 -5
  60. package/dist/orm/failures.d.ts +32 -0
  61. package/dist/orm/failures.js +75 -0
  62. package/dist/orm/operation-show.d.ts +2 -0
  63. package/dist/orm/operation-show.js +35 -0
  64. package/dist/orm/read.js +3 -3
  65. package/dist/orm/version-guard.d.ts +3 -0
  66. package/dist/orm/version-guard.js +63 -0
  67. package/dist/pipeline/commands.js +4 -1
  68. package/dist/principals/commands.d.ts +3 -0
  69. package/dist/principals/commands.js +124 -0
  70. package/dist/process/runs.d.ts +4 -3
  71. package/dist/process/runs.js +52 -10
  72. package/dist/release-age.d.ts +1 -1
  73. package/dist/release-age.js +1 -0
  74. package/dist/repos/commands.d.ts +44 -0
  75. package/dist/repos/commands.js +55 -15
  76. package/dist/repos/init-repo.d.ts +45 -0
  77. package/dist/repos/init-repo.js +257 -0
  78. package/dist/sandbox-unpushed-warning.d.ts +23 -0
  79. package/dist/sandbox-unpushed-warning.js +86 -0
  80. package/dist/service-accounts/commands.js +15 -3
  81. package/dist/templates/commands.d.ts +14 -2
  82. package/dist/templates/commands.js +70 -16
  83. package/dist/templates/process/pnpm-workspace.yaml +1 -0
  84. package/dist/transient-503.d.ts +4 -0
  85. package/dist/transient-503.js +25 -0
  86. package/package.json +14 -10
  87. package/templates/process/pnpm-workspace.yaml +1 -0
@@ -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';
@@ -42,12 +43,17 @@ export const APP_INIT_USAGE = `usage:
42
43
  --template <t> react-vite (default) or nextjs for the artifact, or
43
44
  <name>@<version> to start from a published app
44
45
  template in the -e deployment
45
- -e, --env <name> registered deployment whose template catalog to read
46
+ -e, --env <name> registered deployment whose template catalog (or --repo) to use
46
47
  --description <text> optional app.description in the manifest
47
48
  --skip-install skip pnpm install and ORM migration authoring (offline)
49
+ --repo <ns>/<name> scaffold into a platform git-service repo, created if
50
+ missing: clone it into <dir>, or set it as origin when
51
+ <dir> is inside a Git checkout. Needs -e (or an agent
52
+ sandbox). Prints the commit and push commands.
48
53
 
49
54
  Examples:
50
55
  seq-studio init pokedex
56
+ seq-studio init pokedex --repo apps/pokedex -e staging
51
57
  seq-studio init . --template nextjs
52
58
  seq-studio init reports # a new app inside an existing repository
53
59
  seq-studio init pokedex --with orm,function,artifact
@@ -121,11 +127,61 @@ export const APP_DEPLOY_USAGE = `usage:
121
127
  Commit generated migrations before the first deployment and schema changes.
122
128
  Repository admission reads the remote receipt at HEAD; all dry-runs need
123
129
  network/auth. Version 1 dry-run only lists after that check.
130
+ For offline manifest, graph, path, and member checks before adoption, use
131
+ \`seq-studio validate\`.
124
132
  A dry-run never opens a browser login: sign in beforehand. It warns,
125
133
  rather than fails, when the
126
134
  artifact source is not committed and clean on main.
127
135
  Version 2 writes the result to .sequence/deployments/<environment>.json.
128
136
  `;
137
+ export const APP_VALIDATE_USAGE = `usage:
138
+ seq-studio validate [--dir <path>] [--json]
139
+
140
+ Validate sequence.app.yml, its dependency graph, and primitive directories
141
+ locally. List resolved Application members, including existing process refs.
142
+ No environment, login, repository adoption, or network access is required.
143
+ This checks local structure only; it does not validate remote member existence,
144
+ primitive-specific source, or authorize deployment. Deploy still requires a
145
+ matching repository identity receipt.
146
+
147
+ Options:
148
+ --dir <path> app root (default: cwd)
149
+ --json print structured validation result
150
+ `;
151
+ export async function runAppValidateCommand(args) {
152
+ if (args.flags.help === true || args.flags.h === true) {
153
+ console.log(APP_VALIDATE_USAGE);
154
+ return 0;
155
+ }
156
+ try {
157
+ if (args.positional.length > 0)
158
+ throw new Error('unexpected arguments; use --dir for the app root');
159
+ for (const [flag, value] of Object.entries(args.flags)) {
160
+ if (flag === 'dir' && typeof value === 'string' && value.trim())
161
+ continue;
162
+ if (flag === 'json' && value === true)
163
+ continue;
164
+ throw new Error(flag === 'dir' ? '--dir requires a value' : `unknown option --${flag}`);
165
+ }
166
+ const result = await validateAppLocal({ rootDir: resolve(flagString(args.flags, 'dir') ?? process.cwd()) });
167
+ if (args.flags.json === true) {
168
+ console.log(JSON.stringify(result, null, 2));
169
+ }
170
+ else {
171
+ console.log(`${LOG} app "${result.app}" manifest valid (${result.primitives.length} primitive(s), ${result.members.length} member(s))`);
172
+ for (const entry of result.primitives)
173
+ console.log(`${LOG} - ${entry.kind} ${entry.id} (${entry.path})`);
174
+ for (const member of result.members)
175
+ console.log(`${LOG} - member ${member.kind} ${member.id} -> ${member.ref}`);
176
+ console.log(`${LOG} local validation only; deployment still requires repository admission`);
177
+ }
178
+ return 0;
179
+ }
180
+ catch (error) {
181
+ printError(error);
182
+ return 1;
183
+ }
184
+ }
129
185
  function pipelineTypeFlag(flags) {
130
186
  const value = flags['pipeline-type'];
131
187
  if (value === undefined)
@@ -157,7 +213,30 @@ function printError(error) {
157
213
  const message = error instanceof Error ? error.message : String(error);
158
214
  console.error(`${LOG} ${message}`);
159
215
  }
216
+ /**
217
+ * A published-template request (`--template <name>@<version>`), validated so
218
+ * a bad combination fails before `--repo` creates anything; null for the
219
+ * artifact templates (react-vite, nextjs) and the plain scaffold.
220
+ */
221
+ function publishedTemplateRequest({ flags, kinds }) {
222
+ const { template } = flags;
223
+ if (template === undefined || template === 'react-vite' || template === 'nextjs')
224
+ return null;
225
+ if (template === true)
226
+ throw new Error('--template requires <name>@<version>.');
227
+ const requested = flags.env ?? flags.e;
228
+ const environment = explicitOrSandboxEnv(typeof requested === 'string' ? requested : undefined);
229
+ if (!environment)
230
+ throw new Error('--template requires -e <deployment>.');
231
+ if (kinds.length > 0)
232
+ throw new Error('Use either --template or --with/primitive flags.');
233
+ return { selection: template, environment };
234
+ }
160
235
  export async function runAppInitCommand(args) {
236
+ return initApp({ args, intoCheckout: false });
237
+ }
238
+ /** `intoCheckout`: the target is the git-service checkout `--repo` just prepared. */
239
+ async function initApp({ args, intoCheckout }) {
161
240
  if (args.flags.help === true || args.flags.h === true) {
162
241
  console.log(APP_INIT_USAGE);
163
242
  return 0;
@@ -168,27 +247,24 @@ export async function runAppInitCommand(args) {
168
247
  return 1;
169
248
  }
170
249
  let kinds;
250
+ let published;
171
251
  try {
172
252
  kinds = resolveRequestedKinds(args.flags);
253
+ published = publishedTemplateRequest({ flags: args.flags, kinds });
173
254
  }
174
255
  catch (error) {
175
256
  printError(error);
176
257
  console.error(APP_INIT_USAGE);
177
258
  return 1;
178
259
  }
179
- const artifactTemplate = args.flags.template === 'react-vite' || args.flags.template === 'nextjs';
180
- if (args.flags.template !== undefined && !artifactTemplate) {
260
+ if (args.flags.repo !== undefined) {
261
+ const { runInitWithRepo, withoutRepoFlag } = await import('../repos/init-repo.js');
262
+ return runInitWithRepo({ args, target, scaffold: () => initApp({ args: withoutRepoFlag(args), intoCheckout: true }) });
263
+ }
264
+ if (published) {
181
265
  try {
182
- if (args.flags.template === true)
183
- throw new Error('--template requires <name>@<version>.');
184
- const requested = args.flags.env ?? args.flags.e;
185
- const env = explicitOrSandboxEnv(typeof requested === 'string' ? requested : undefined);
186
- if (!env)
187
- throw new Error('--template requires -e <deployment>.');
188
- if (kinds.length > 0)
189
- throw new Error('Use either --template or --with/primitive flags.');
190
266
  const { initFromTemplate } = await import('../templates/commands.js');
191
- await initFromTemplate({ selection: args.flags.template, target, environment: env });
267
+ await initFromTemplate({ ...published, target, intoCheckout });
192
268
  return 0;
193
269
  }
194
270
  catch (error) {
@@ -95,11 +95,11 @@ export declare const applicationCollaboratorsSchema: z.ZodObject<{
95
95
  includes: z.ZodDefault<z.ZodArray<z.ZodObject<{
96
96
  primitive: z.ZodString;
97
97
  tier: z.ZodEnum<{
98
+ operator: "operator";
98
99
  viewer: "viewer";
99
100
  editor: "editor";
100
101
  reader: "reader";
101
102
  writer: "writer";
102
- operator: "operator";
103
103
  actor: "actor";
104
104
  }>;
105
105
  }, z.core.$strict>>>;
@@ -234,11 +234,11 @@ export declare const appManifestSchema: z.ZodObject<{
234
234
  includes: z.ZodDefault<z.ZodArray<z.ZodObject<{
235
235
  primitive: z.ZodString;
236
236
  tier: z.ZodEnum<{
237
+ operator: "operator";
237
238
  viewer: "viewer";
238
239
  editor: "editor";
239
240
  reader: "reader";
240
241
  writer: "writer";
241
- operator: "operator";
242
242
  actor: "actor";
243
243
  }>;
244
244
  }, z.core.$strict>>>;
@@ -1,7 +1,9 @@
1
1
  /**
2
2
  * Official artifact deploys need committed, clean source on `main` (or
3
- * `staging` for a staging target). A dry-run deploys nothing, so there it
4
- * reports what a real deploy would refuse instead of failing.
3
+ * `staging` for a staging target). `env` is the CLI's name for the target,
4
+ * not the deployment's own environment, so Atlas decides whether `staging`
5
+ * is official there. A dry-run deploys nothing, so there it reports what a
6
+ * real deploy would refuse instead of failing.
5
7
  */
6
8
  export declare function checkOfficialArtifactSource({ dir, env, dryRun, }: {
7
9
  dir: string;
@@ -1,10 +1,12 @@
1
- import { ActiveDeployPolicyError, assertActiveDeployProvenance, } from '@sequenceholdings/artifact-studio/active-deploy-policy';
1
+ import { ActiveDeployPolicyError, assertActiveDeploySourceBeforeUpload, } from '@sequenceholdings/artifact-studio/active-deploy-policy';
2
2
  import { localGitMetadata } from '@sequenceholdings/artifact-studio/source-resolver';
3
3
  const LOG = '[seq-studio]';
4
4
  /**
5
5
  * Official artifact deploys need committed, clean source on `main` (or
6
- * `staging` for a staging target). A dry-run deploys nothing, so there it
7
- * reports what a real deploy would refuse instead of failing.
6
+ * `staging` for a staging target). `env` is the CLI's name for the target,
7
+ * not the deployment's own environment, so Atlas decides whether `staging`
8
+ * is official there. A dry-run deploys nothing, so there it reports what a
9
+ * real deploy would refuse instead of failing.
8
10
  */
9
11
  export function checkOfficialArtifactSource({ dir, env, dryRun = false, }) {
10
12
  const provenance = localGitMetadata(dir);
@@ -13,7 +15,7 @@ export function checkOfficialArtifactSource({ dir, env, dryRun = false, }) {
13
15
  throw new ActiveDeployPolicyError(`${dir} is not in a git repository with a commit. Official artifact deploys need committed ` +
14
16
  'source on `main`: run `git init`, commit, then deploy, or use a preview deploy.');
15
17
  }
16
- assertActiveDeployProvenance({ ...provenance, environment: env });
18
+ assertActiveDeploySourceBeforeUpload(provenance);
17
19
  }
18
20
  catch (error) {
19
21
  if (!dryRun || !(error instanceof ActiveDeployPolicyError))
@@ -135,13 +135,13 @@ Use the environment name your administrator supplies. \`local\` means a real Atl
135
135
 
136
136
  ## Shared packages
137
137
 
138
- Export common types, validation, and helpers from \`packages/shared/src/index.ts\`. Artifacts and processes depend on \`@${input.appId}/shared\` through \`workspace:*\`; ordinary imports work across the app. A function's dependencies ship as-is and a deployed bundle cannot follow a \`workspace:*\` link, so functions don't get one by default:
138
+ Export common types, validation, and helpers from \`packages/shared/src/index.ts\`. Processes depend on \`@${input.appId}/shared\` through \`workspace:*\`; ordinary imports work across the app. Functions and artifacts don't get the link by default: a function's dependencies ship as-is and a deployed bundle cannot follow a \`workspace:*\` link, and an artifact deployed on its own with \`seq-studio artifact deploy --repo\` builds from its directory alone. Import the package wherever it is linked:
139
139
 
140
140
  \`\`\`ts
141
141
  import { /* your exports */ } from '@${input.appId}/shared'
142
142
  \`\`\`
143
143
 
144
- Create another shared package with \`seq-studio add package contracts\`, then add it to a consumer using pnpm:
144
+ Create another shared package with \`seq-studio add package contracts\`, then add it (or \`shared\`) to a consumer using pnpm:
145
145
 
146
146
  \`\`\`bash
147
147
  pnpm --filter @${input.appId}/primitive-<primitive-id> add '@${input.appId}/contracts@workspace:*'
@@ -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
+ }
@@ -135,6 +135,10 @@ function subpathExport({ exports, key, browser, requireImport }) {
135
135
  return undefined;
136
136
  }
137
137
  function workspaceExport({ pkg, subpath, browser, requireImport }) {
138
+ // Explicit source entry avoids missing/stale dist output in clean repository
139
+ // function builds. Browser conditions and package subpath exports stay intact.
140
+ if (!browser && !subpath && pkg.json.seqStudio?.source)
141
+ return pkg.json.seqStudio.source;
138
142
  const exports = pkg.json.exports;
139
143
  if (exports && typeof exports === 'object' && !Array.isArray(exports) && Object.keys(exports).some((key) => key.startsWith('.'))) {
140
144
  return subpathExport({ exports, key: subpath ? `.${subpath}` : '.', browser, requireImport });
@@ -67,9 +67,11 @@ export async function joinAppWorkspace({ rootDir, manifest, entries, }) {
67
67
  const { pnpm, ...packageFields } = pkg;
68
68
  mergeOverrides({ existing: overrides, incoming: pnpm?.overrides ?? {} });
69
69
  // A function's packaged dependencies ship as-is and a deployed bundle cannot
70
- // resolve a workspace: link, so functions opt in to shared packages explicitly.
71
- // Artifacts and processes are bundled at build time, so the link is safe there.
72
- const shared = entry.kind === 'function' ? [] : manifest.packages ?? [];
70
+ // resolve a workspace: link. An artifact deployed on its own
71
+ // (`artifact deploy --repo`) builds from its directory alone, where the link
72
+ // is an unresolvable production dependency, and the scaffold never imports
73
+ // it. Both opt in to shared packages explicitly; processes get the link.
74
+ const shared = entry.kind === 'function' || entry.kind === 'artifact' ? [] : manifest.packages ?? [];
73
75
  await writeFile(packagePath, `${JSON.stringify({
74
76
  ...packageFields,
75
77
  name: `@${manifest.app.id}/primitive-${entry.id}`,
@@ -5,6 +5,8 @@ export interface AppWorkspaceOptions {
5
5
  manifest: WorkspaceManifest;
6
6
  entries: readonly PrimitiveEntry[];
7
7
  paths: ReadonlyMap<string, string>;
8
+ /** Standalone function commands read secrets from the original local dir. */
9
+ preserveFunctionEnv?: boolean;
8
10
  }
9
11
  /** Read-only dependency/path validation, suitable for deploy --dry-run. */
10
12
  export declare function validateAppWorkspace(options: AppWorkspaceOptions): Promise<void>;
@@ -126,7 +126,7 @@ export async function prepareAppWorkspace(options) {
126
126
  for (const [index, consumer] of staged.entries()) {
127
127
  const stageDir = join(temporary, String(index));
128
128
  await mkdir(stageDir, { recursive: true });
129
- const sourceFiles = await copyPrimitiveSources({ sourceDir: consumer.dir, stageDir, preserveEnv: consumer.entry.kind === 'function' });
129
+ const sourceFiles = await copyPrimitiveSources({ sourceDir: consumer.dir, stageDir, preserveEnv: consumer.entry.kind === 'function' && options.preserveFunctionEnv !== false });
130
130
  const compilerOptions = { sourceDir: consumer.dir, stageDir, json: consumer.json, packages, closure: consumer.closure };
131
131
  if (consumer.entry.kind === 'function')
132
132
  await compileWorkspaceFunction(compilerOptions);
@@ -16,14 +16,14 @@
16
16
  * package registry run: an agent sandbox reaches its Atlas origin and nothing else.
17
17
  */
18
18
  import { getAccessTokenWithMode, tryGetAccessTokenWithMode } from '../auth.js';
19
- import { ARTIFACT_SANDBOX_HELP } from '../command-help.js';
19
+ import { ARTIFACT_SANDBOX_HELP, INIT_INTO_REPO_HELP } from '../command-help.js';
20
20
  import { readConfig, resolveConfiguredEnv } from '../config.js';
21
- import { normalizeShortEnvFlag, readEnvFromArgv } from '../env-flags.js';
21
+ import { normalizeShortEnvFlag, readEnvFromArgv, withoutEnvFlag } from '../env-flags.js';
22
22
  import { PREVIEW_DOMAIN, PREVIEW_PROJECT, resolvePreviewByPr } from '../preview.js';
23
23
  import { sandboxTarget } from '../sandbox-auth.js';
24
24
  import { runSandboxArtifactCommand } from './sandbox.js';
25
25
  const ARTIFACT_USAGE = `usage:
26
- seq-studio artifact init <dir> [--template react-vite|nextjs]
26
+ seq-studio artifact init <dir> [--template react-vite|nextjs] [--repo <ns>/<name>]
27
27
  seq-studio artifact validate [dir]
28
28
  seq-studio artifact build [dir | --repo <ns>/<name> | --git-url <url>] [--ref <ref>] [--path <dir>] [--source-env <env>] [--out file.json]
29
29
  seq-studio artifact plan [dir | --repo <ns>/<name> | --git-url <url>] [--ref <ref>] [--path <dir>] [--source-env <env>] -e <env>
@@ -80,7 +80,27 @@ const ARTIFACT_USAGE = `usage:
80
80
 
81
81
  Authenticate with: seq-studio login
82
82
 
83
+ ${INIT_INTO_REPO_HELP}
83
84
  ${ARTIFACT_SANDBOX_HELP}`;
85
+ /**
86
+ * `init --repo` prepares the git-service checkout, then scaffolds into it
87
+ * through the ordinary init (sandbox or not). Null when `--repo` is absent.
88
+ * The environment is for the repository setup only: artifact-studio's init
89
+ * accepts no --env, so the delegated scaffold never sees one.
90
+ */
91
+ async function runArtifactInitWithRepo(rest) {
92
+ const { extractRepoFlag, runInitWithRepo } = await import('../repos/init-repo.js');
93
+ const { repo, rest: initArgv } = extractRepoFlag(rest);
94
+ if (repo === undefined)
95
+ return null;
96
+ const { parseArgs } = await import('../argv.js');
97
+ const args = parseArgs(normalizeShortEnvFlag(rest));
98
+ return runInitWithRepo({
99
+ args,
100
+ target: args.positional[0] ?? '.',
101
+ scaffold: () => runArtifactCommand('init', withoutEnvFlag(initArgv)),
102
+ });
103
+ }
84
104
  export async function runArtifactCommand(sub, rest) {
85
105
  if (rest.some((arg) => arg === '--token' || arg.startsWith('--token='))) {
86
106
  console.error('seq-studio artifact does not accept bearer tokens via --token. ' +
@@ -96,6 +116,9 @@ export async function runArtifactCommand(sub, rest) {
96
116
  }
97
117
  // Never pass a legacy bearer environment variable into the embedded package.
98
118
  delete process.env['ARTIFACT_STUDIO_TOKEN'];
119
+ const repoInit = sub === 'init' ? await runArtifactInitWithRepo(rest) : null;
120
+ if (repoInit !== null)
121
+ return repoInit;
99
122
  const sandbox = sandboxTarget();
100
123
  if (sandbox)
101
124
  return runSandboxArtifactCommand({ sandbox, sub, rest });
@@ -13,7 +13,8 @@ import { SANDBOX_ENV_NAME, sourceAuthMode } from '../sandbox-auth.js';
13
13
  /** How an agent gets an app deployed when a sandbox refuses the local path. */
14
14
  const SANDBOX_DEPLOY_GUIDANCE = 'Push the app to a Git Service repository and deploy from it: `seq-studio repos create <ns>/<name>`, ' +
15
15
  '`seq-studio repos clone <ns>/<name>`, commit and `git push` the app on main, then ' +
16
- '`seq-studio artifact deploy --repo <ns>/<name>`.';
16
+ '`seq-studio artifact deploy --repo <ns>/<name>`. To try a branch first, add `--ref <branch> --preview` ' +
17
+ 'for a private preview link that leaves the live app unchanged.';
17
18
  /** Shown when a static build would need `pnpm install`, which a sandbox cannot run. */
18
19
  const SANDBOX_INSTALL_GUIDANCE = 'An agent sandbox cannot reach a package registry. Remove the package.json dependencies and optionalDependencies ' +
19
20
  '(scaffold imports such as React, atlas-ui and the Artifact Studio SDK need none), ' +
@@ -1,9 +1,4 @@
1
- /**
2
- * Minimal authenticated HTTP client for Atlas. Same retry-on-503 contract
3
- * as `shared/services/artifact-studio/src/api.ts` so behavior is
4
- * consistent across both Sequence CLIs. Token + baseUrl are passed in by
5
- * the caller — this file knows nothing about token files or config TOMLs.
6
- */
1
+ import { createOperatorPlatformClient } from "@sequenceholdings/platform/server";
7
2
  export interface ClientOptions {
8
3
  baseUrl: string;
9
4
  token: string;
@@ -22,11 +17,13 @@ export declare class AtlasApiError extends Error {
22
17
  readonly name = "AtlasApiError";
23
18
  retryAfterSeconds: number | null;
24
19
  constructor(status: number, message: string, path: string, statusText?: string, body?: unknown);
20
+ /** The structured `error.code` (or top-level `code`) Atlas sent, if any. */
21
+ get code(): string | null;
25
22
  }
26
23
  /** Bounded single attempt for commands whose uncertain result must be reconciled by the caller. */
27
24
  export declare function requestJsonOnce({ baseUrl, token, path, method, body, }: ClientOptions & {
28
25
  path: string;
29
- method: 'GET' | 'POST' | 'PUT';
26
+ method: "GET" | "POST" | "PUT" | "DELETE";
30
27
  body?: unknown;
31
28
  }): Promise<unknown>;
32
29
  export declare function getJson<T>({ baseUrl, token, path, }: ClientOptions & {
@@ -45,10 +42,11 @@ export declare function postJson<T>({ baseUrl, token, path, body, sourceAuthoriz
45
42
  * necessarily JSON and whose non-2xx status may belong to the downstream
46
43
  * application. The caller decides how to render and interpret the status.
47
44
  */
48
- export declare function postJsonResponse({ baseUrl, token, path, body, headers, }: ClientOptions & {
45
+ export declare function postJsonResponse({ baseUrl, token, path, body, headers, timeoutMs, }: ClientOptions & {
49
46
  path: string;
50
47
  body?: unknown;
51
48
  headers?: Record<string, string>;
49
+ timeoutMs?: number;
52
50
  }): Promise<AtlasResponse>;
53
51
  export declare function putJson<T>({ baseUrl, token, path, body, }: ClientOptions & {
54
52
  path: string;
@@ -62,7 +60,18 @@ export declare function deleteJson<T>({ baseUrl, token, path, body, }: ClientOpt
62
60
  path: string;
63
61
  body?: unknown;
64
62
  }): Promise<T>;
63
+ /**
64
+ * JSON POST/DELETE for mutations that answer either a JSON body or 204 No
65
+ * Content (git-service principals, for example). Resolves `undefined` for 204.
66
+ */
67
+ export declare function sendJsonOrNoContent({ baseUrl, token, path, method, body, }: ClientOptions & {
68
+ path: string;
69
+ method: 'POST' | 'DELETE';
70
+ body?: unknown;
71
+ }): Promise<unknown>;
65
72
  /** DELETE for endpoints that return 204 with an empty body (deleteJson would choke on it). */
66
73
  export declare function deleteNoContent({ baseUrl, token, path, }: ClientOptions & {
67
74
  path: string;
68
75
  }): Promise<void>;
76
+ /** Shared platform transport owns origin, redirect, deadline and response bounds. CLI supplies only its current session and trusted edge credentials. */
77
+ export declare function operatorPlatformClient({ baseUrl, token, }: ClientOptions): ReturnType<typeof createOperatorPlatformClient>;