@sequenceholdings/studio-cli 0.4.3 → 0.4.6

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 (45) hide show
  1. package/README.md +92 -19
  2. package/dist/app/agent-refs.d.ts +16 -0
  3. package/dist/app/agent-refs.js +18 -6
  4. package/dist/app/application-registration.d.ts +11 -3
  5. package/dist/app/application-registration.js +20 -6
  6. package/dist/app/application-suggestions.d.ts +58 -0
  7. package/dist/app/application-suggestions.js +164 -0
  8. package/dist/app/deploy.js +7 -4
  9. package/dist/app/env-bindings.js +2 -2
  10. package/dist/app/manifest-validation.d.ts +5 -0
  11. package/dist/app/manifest-validation.js +60 -22
  12. package/dist/app/manifest.d.ts +33 -0
  13. package/dist/app/manifest.js +16 -0
  14. package/dist/app/readme.d.ts +6 -3
  15. package/dist/app/readme.js +36 -6
  16. package/dist/app/scaffold.js +2 -1
  17. package/dist/artifact/delegate.js +6 -34
  18. package/dist/auth-cmds/commands.js +2 -2
  19. package/dist/auth.d.ts +0 -9
  20. package/dist/auth.js +2 -29
  21. package/dist/command-help.d.ts +2 -0
  22. package/dist/command-help.js +89 -0
  23. package/dist/config.d.ts +7 -20
  24. package/dist/config.js +22 -64
  25. package/dist/envs/commands.js +17 -67
  26. package/dist/functions/commands.d.ts +0 -1
  27. package/dist/functions/commands.js +3 -49
  28. package/dist/functions/deploy-preflight.d.ts +1 -1
  29. package/dist/functions/deploy-preflight.js +2 -1
  30. package/dist/functions/manifest.d.ts +3 -0
  31. package/dist/functions/manifest.js +27 -17
  32. package/dist/login.d.ts +0 -6
  33. package/dist/login.js +3 -34
  34. package/dist/main.js +2 -2
  35. package/dist/orm/delegate.js +2 -2
  36. package/dist/pipeline/discovery.js +2 -2
  37. package/dist/pipeline/lifecycle.js +2 -2
  38. package/dist/pipeline/repin-orm.js +3 -3
  39. package/dist/process/commands.js +4 -8
  40. package/dist/repos/commands.d.ts +0 -1
  41. package/dist/repos/commands.js +3 -40
  42. package/dist/storage/commands.js +2 -2
  43. package/package.json +9 -9
  44. package/dist/env-catalog.d.ts +0 -63
  45. package/dist/env-catalog.js +0 -121
@@ -29,10 +29,11 @@ function validateRoles({ manifest, ctx }) {
29
29
  }
30
30
  const kindById = new Map([
31
31
  ...manifest.primitives.map((entry) => [entry.id, entry.kind]),
32
- ...(manifest.secrets ?? []).map((secret) => [secret.id, 'secret']),
33
- ...(manifest.service_accounts ?? []).map((account) => [account.id, 'service_account']),
32
+ ...referenceKinds(manifest),
34
33
  ]);
35
34
  const entryById = new Map(manifest.primitives.map((entry) => [entry.id, entry]));
35
+ // An existing member's ref names exactly one host: the deploy-only checks don't apply.
36
+ const existingIds = new Set((manifest.existing ?? []).map((entry) => entry.id));
36
37
  const definitions = manifest.roles.definitions;
37
38
  for (const [key, definition] of Object.entries(definitions)) {
38
39
  const at = (...path) => ['roles', 'definitions', key, ...path];
@@ -70,7 +71,7 @@ function validateRoles({ manifest, ctx }) {
70
71
  ctx.addIssue({ code: 'custom', message: `invoker is the function and process floor; use end_user for ${kind} primitives`, path: at('includes', index, 'role') });
71
72
  }
72
73
  else if (kind === 'process') {
73
- processIncludeIssue({ entry: entryById.get(include.primitive), include, path: at('includes', index), ctx });
74
+ processIncludeIssue({ entry: entryById.get(include.primitive), existing: existingIds.has(include.primitive), include, path: at('includes', index), ctx });
74
75
  }
75
76
  else if (kind === 'agent') {
76
77
  agentIncludeIssue({ entry: entryById.get(include.primitive), include, path: at('includes', index), ctx });
@@ -87,8 +88,7 @@ function validateCollaborators({ manifest, ctx }) {
87
88
  return;
88
89
  }
89
90
  const entryById = new Map(manifest.primitives.map((entry) => [entry.id, entry]));
90
- const secretIds = new Set((manifest.secrets ?? []).map((secret) => secret.id));
91
- const accountIds = new Set((manifest.service_accounts ?? []).map((account) => account.id));
91
+ const referenced = new Map(referenceKinds(manifest));
92
92
  const definitions = manifest.collaborators.definitions;
93
93
  for (const [key, definition] of Object.entries(definitions)) {
94
94
  const at = (...path) => ['collaborators', 'definitions', key, ...path];
@@ -98,16 +98,11 @@ function validateCollaborators({ manifest, ctx }) {
98
98
  }
99
99
  }
100
100
  for (const [index, include] of definition.includes.entries()) {
101
- if (accountIds.has(include.primitive)) {
102
- if (include.tier !== 'actor') {
103
- ctx.addIssue({ code: 'custom', message: 'service accounts offer actor — admin stays a direct grant', path: at('includes', index, 'tier') });
104
- }
105
- continue;
106
- }
107
- if (secretIds.has(include.primitive)) {
108
- if (include.tier !== 'editor') {
109
- ctx.addIssue({ code: 'custom', message: 'secrets offer editor — admin and owner stay direct grants', path: at('includes', index, 'tier') });
110
- }
101
+ const referencedKind = referenced.get(include.primitive);
102
+ if (referencedKind) {
103
+ const issue = referencedTierIssue(referencedKind, include.tier);
104
+ if (issue)
105
+ ctx.addIssue({ code: 'custom', message: issue, path: at('includes', index, 'tier') });
111
106
  continue;
112
107
  }
113
108
  const entry = entryById.get(include.primitive);
@@ -133,16 +128,35 @@ function validateCollaborators({ manifest, ctx }) {
133
128
  }
134
129
  }
135
130
  }
131
+ /** Members the manifest names without deploying — secrets, service accounts, existing members — by id. */
132
+ function referenceKinds(manifest) {
133
+ return [
134
+ ...(manifest.secrets ?? []).map((secret) => [secret.id, 'secret']),
135
+ ...(manifest.service_accounts ?? []).map((account) => [account.id, 'service_account']),
136
+ ...(manifest.existing ?? []).map((entry) => [entry.id, entry.kind]),
137
+ ];
138
+ }
139
+ /** Why a collaborator role can't give `tier` on a referenced member, or null when it can. */
140
+ function referencedTierIssue(kind, tier) {
141
+ const tiers = COLLABORATOR_TIERS_BY_KIND[kind] ?? [];
142
+ if (tiers.includes(tier))
143
+ return null;
144
+ if (kind === 'service_account')
145
+ return 'service accounts offer actor — admin stays a direct grant';
146
+ if (kind === 'secret')
147
+ return 'secrets offer editor — admin and owner stay direct grants';
148
+ return `${kind} members offer ${tiers.join(', ')} — admin and owner stay direct grants`;
149
+ }
136
150
  /**
137
151
  * A process member is floor-only (a Lattice process has no roles or
138
152
  * capabilities), and the entry must deploy exactly one process so Atlas
139
153
  * knows which one the role reaches.
140
154
  */
141
- function processIncludeIssue({ entry, include, path, ctx, }) {
155
+ function processIncludeIssue({ entry, existing = false, include, path, ctx, }) {
142
156
  if (include.capability !== undefined || (include.role !== 'end_user' && include.role !== 'invoker')) {
143
157
  ctx.addIssue({ code: 'custom', message: 'process primitives offer only end_user (or invoker) — not roles or capabilities', path });
144
158
  }
145
- else if (entry?.only?.length !== 1) {
159
+ else if (!existing && entry?.only?.length !== 1) {
146
160
  ctx.addIssue({ code: 'custom', message: `set only: [<process-id>] on "${entry?.id ?? ''}" so the role reaches exactly one process`, path });
147
161
  }
148
162
  }
@@ -166,16 +180,34 @@ function validateV2Entry({ entry, index, ctx }) {
166
180
  issue('target is supported for agent/pipeline deployments', 'target');
167
181
  }
168
182
  }
183
+ /**
184
+ * Why `entry` can't share its path with the entries already on it, or null.
185
+ * Agent and process entries may, when each selects its own definitions with
186
+ * `only` — so one directory of several agents can be several members.
187
+ */
188
+ function sharedPathIssue(sharing, entry) {
189
+ if (sharing.length === 0)
190
+ return null;
191
+ const selective = (candidate) => (candidate.kind === 'agent' || candidate.kind === 'process') && candidate.kind === entry.kind && (candidate.only?.length ?? 0) > 0;
192
+ if (!selective(entry) || !sharing.every(selective)) {
193
+ return `duplicate primitive path "${entry.path}" — agent and process entries can share one when each selects different definitions with only`;
194
+ }
195
+ const taken = sharing.flatMap((other) => (other.only ?? []).map((id) => [id, other.id]));
196
+ const clash = taken.find(([id]) => entry.only?.includes(id));
197
+ return clash ? `"${clash[1]}" and "${entry.id}" both select "${clash[0]}" from "${entry.path}"` : null;
198
+ }
169
199
  function validateInventory({ manifest, ctx }) {
170
200
  const ids = new Set();
171
- const paths = new Set();
201
+ const byPath = new Map();
172
202
  for (const [index, entry] of manifest.primitives.entries()) {
173
203
  if (ids.has(entry.id))
174
204
  ctx.addIssue({ code: 'custom', message: `duplicate primitive id "${entry.id}"`, path: ['primitives', index, 'id'] });
175
- if (paths.has(entry.path))
176
- ctx.addIssue({ code: 'custom', message: `duplicate primitive path "${entry.path}"`, path: ['primitives', index, 'path'] });
205
+ const sharing = byPath.get(entry.path) ?? [];
206
+ const issue = sharedPathIssue(sharing, entry);
207
+ if (issue)
208
+ ctx.addIssue({ code: 'custom', message: issue, path: ['primitives', index, 'path'] });
177
209
  ids.add(entry.id);
178
- paths.add(entry.path);
210
+ byPath.set(entry.path, [...sharing, entry]);
179
211
  if (usesGraph(manifest))
180
212
  validateV2Entry({ entry, index, ctx });
181
213
  }
@@ -188,6 +220,7 @@ function validateInventory({ manifest, ctx }) {
188
220
  validateUses({ entry, index, ids: useTargets, ctx });
189
221
  }
190
222
  const names = new Set();
223
+ const paths = new Set(byPath.keys());
191
224
  for (const [index, pkg] of (manifest.packages ?? []).entries()) {
192
225
  if (names.has(pkg.name) || paths.has(pkg.path))
193
226
  ctx.addIssue({ code: 'custom', message: 'duplicate shared package name or path', path: ['packages', index] });
@@ -216,6 +249,11 @@ function validateSecrets({ manifest, ids, ctx, }) {
216
249
  what: 'service account',
217
250
  entries: (manifest.service_accounts ?? []).map((account) => ({ id: account.id, name: account.slug })),
218
251
  },
252
+ {
253
+ field: 'existing',
254
+ what: 'existing member',
255
+ entries: (manifest.existing ?? []).map((entry) => ({ id: entry.id, name: `${entry.kind} ${entry.ref}` })),
256
+ },
219
257
  ];
220
258
  for (const { field, what, entries } of lists) {
221
259
  if (!manifest[field])
@@ -298,7 +336,7 @@ export function validateManifestGraph(manifest, ctx) {
298
336
  }
299
337
  }
300
338
  }
301
- const severalAgentsMessage = (id) => `"${id}" deploys several agents; set only: [<agent-id>] so the role reaches exactly one agent`;
339
+ const severalAgentsMessage = (id) => `"${id}" deploys several agents; give each its own entry with only: [<agent-id>] (entries may share the path) so the role reaches exactly one agent`;
302
340
  /**
303
341
  * An agent member is floor-only for runtime roles (an agent has no roles or
304
342
  * capabilities), and the entry must deploy exactly one agent. `only` with
@@ -127,6 +127,27 @@ declare const appServiceAccountSchema: z.ZodObject<{
127
127
  slug: z.ZodString;
128
128
  }, z.core.$strict>;
129
129
  export type AppServiceAccountEntry = z.infer<typeof appServiceAccountSchema>;
130
+ /** Kinds an Application can include without deploying them. */
131
+ export declare const EXISTING_MEMBER_KINDS: readonly ["artifact", "function", "orm", "process", "agent", "pipeline"];
132
+ /**
133
+ * Something already deployed elsewhere that the Application includes without
134
+ * deploying it, by the stable name Atlas knows it by: a function's slug, a
135
+ * namespace, a process id, an agent id, an artifact's slug, or a
136
+ * pipeline's release unit (`pipelines/<name>`).
137
+ */
138
+ declare const appExistingSchema: z.ZodObject<{
139
+ id: z.ZodString;
140
+ kind: z.ZodEnum<{
141
+ function: "function";
142
+ process: "process";
143
+ artifact: "artifact";
144
+ pipeline: "pipeline";
145
+ orm: "orm";
146
+ agent: "agent";
147
+ }>;
148
+ ref: z.ZodString;
149
+ }, z.core.$strict>;
150
+ export type AppExistingEntry = z.infer<typeof appExistingSchema>;
130
151
  export declare const appManifestSchema: z.ZodObject<{
131
152
  schema_version: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>]>;
132
153
  app: z.ZodObject<{
@@ -183,6 +204,18 @@ export declare const appManifestSchema: z.ZodObject<{
183
204
  id: z.ZodString;
184
205
  slug: z.ZodString;
185
206
  }, z.core.$strict>>>;
207
+ existing: z.ZodOptional<z.ZodArray<z.ZodObject<{
208
+ id: z.ZodString;
209
+ kind: z.ZodEnum<{
210
+ function: "function";
211
+ process: "process";
212
+ artifact: "artifact";
213
+ pipeline: "pipeline";
214
+ orm: "orm";
215
+ agent: "agent";
216
+ }>;
217
+ ref: z.ZodString;
218
+ }, z.core.$strict>>>;
186
219
  roles: z.ZodOptional<z.ZodObject<{
187
220
  definitions: z.ZodRecord<z.ZodString, z.ZodObject<{
188
221
  description: z.ZodOptional<z.ZodString>;
@@ -176,6 +176,21 @@ const appServiceAccountSchema = z
176
176
  slug: z.string().min(1).max(100).regex(/^[a-z0-9][a-z0-9-]*$/, 'service account slugs are lowercase kebab-case'),
177
177
  })
178
178
  .strict();
179
+ /** Kinds an Application can include without deploying them. */
180
+ export const EXISTING_MEMBER_KINDS = ['artifact', 'function', 'orm', 'process', 'agent', 'pipeline'];
181
+ /**
182
+ * Something already deployed elsewhere that the Application includes without
183
+ * deploying it, by the stable name Atlas knows it by: a function's slug, a
184
+ * namespace, a process id, an agent id, an artifact's slug, or a
185
+ * pipeline's release unit (`pipelines/<name>`).
186
+ */
187
+ const appExistingSchema = z
188
+ .object({
189
+ id: z.string().min(1).max(128),
190
+ kind: z.enum(EXISTING_MEMBER_KINDS),
191
+ ref: z.string().min(1).max(255),
192
+ })
193
+ .strict();
179
194
  const relativeDirectorySchema = z.string().min(1).refine((path) => path.trim() === path && !path.includes('\\') && !/^[A-Za-z]:/.test(path) &&
180
195
  !/[\x00-\x1f]/.test(path) && path.split('/').every((part) => part !== '' && part !== '.' && part !== '..'), 'path must be a relative directory within the app root');
181
196
  export const appManifestSchema = z
@@ -203,6 +218,7 @@ export const appManifestSchema = z
203
218
  .default({ on_error: 'stop' }),
204
219
  secrets: z.array(appSecretSchema).optional(),
205
220
  service_accounts: z.array(appServiceAccountSchema).optional(),
221
+ existing: z.array(appExistingSchema).optional(),
206
222
  roles: applicationRolesSchema.optional(),
207
223
  collaborators: applicationCollaboratorsSchema.optional(),
208
224
  capabilities: applicationCapabilitiesSchema.optional(),
@@ -1,19 +1,22 @@
1
1
  /** App README generated by init; git-service seed detection stays stable. */
2
2
  import { type PrimitiveKind } from './manifest.js';
3
- export declare const SEQUENCE_DOCS_URL = "https://docs.seqholdings.com/";
4
3
  /** Keep identical to atlas/src/server/services/git-service/initial-readme.ts. */
5
4
  export declare const GIT_SERVICE_SEED_MARKER = "<!-- seq-studio:git-service-seed -->";
6
5
  export declare function isGitServiceSeedReadme(body: string): boolean;
7
- export declare const README_REQUIRED_SECTIONS: readonly ["https://docs.seqholdings.com/", "Artifact Studio", "ORM", "Managed Function", "seq-studio init", "seq.functions.invoke"];
6
+ /** Keep the marker format identical to the git-service initial README renderer. */
7
+ export declare function readGitServiceSeedAtlasOrigin(body: string | null): string | undefined;
8
+ export declare const README_REQUIRED_SECTIONS: readonly ["/docs", "Artifact Studio", "ORM", "Managed Function", "seq-studio init", "seq.functions.invoke"];
8
9
  export interface AppReadmeInput {
9
10
  appId: string;
10
11
  title?: string;
11
12
  description?: string;
12
13
  primitives: readonly PrimitiveKind[];
13
14
  functionName?: string;
15
+ atlasOrigin?: string;
14
16
  }
15
17
  export declare function renderAppReadme(input: AppReadmeInput): string;
16
- export declare function renderEmptyRepoReadme({ repoName, namespaceSlug }: {
18
+ export declare function renderEmptyRepoReadme({ repoName, namespaceSlug, atlasOrigin }: {
17
19
  repoName: string;
18
20
  namespaceSlug?: string;
21
+ atlasOrigin?: string;
19
22
  }): string;
@@ -1,13 +1,37 @@
1
1
  /** App README generated by init; git-service seed detection stays stable. */
2
2
  import { titleizeSlug } from './manifest.js';
3
- export const SEQUENCE_DOCS_URL = 'https://docs.seqholdings.com/';
4
3
  /** Keep identical to atlas/src/server/services/git-service/initial-readme.ts. */
5
4
  export const GIT_SERVICE_SEED_MARKER = '<!-- seq-studio:git-service-seed -->';
6
5
  export function isGitServiceSeedReadme(body) {
7
6
  return body.includes(GIT_SERVICE_SEED_MARKER);
8
7
  }
8
+ function normalizeAtlasOrigin(value) {
9
+ if (!value)
10
+ return undefined;
11
+ try {
12
+ const url = new URL(value);
13
+ if (!['https:', 'http:'].includes(url.protocol) || url.username || url.password
14
+ || url.pathname !== '/' || url.search || url.hash)
15
+ return undefined;
16
+ return url.origin;
17
+ }
18
+ catch {
19
+ return undefined;
20
+ }
21
+ }
22
+ /** Keep the marker format identical to the git-service initial README renderer. */
23
+ export function readGitServiceSeedAtlasOrigin(body) {
24
+ if (!body || !isGitServiceSeedReadme(body))
25
+ return undefined;
26
+ return normalizeAtlasOrigin(body.match(/^<!-- seq-studio:atlas-origin=([^\r\n]+) -->\r?$/m)?.[1]);
27
+ }
28
+ function docsLink({ atlasOrigin, label, slug = '' }) {
29
+ return atlasOrigin
30
+ ? `[${label}](${atlasOrigin}/docs/${slug})`
31
+ : `\`<atlas-url>/docs${slug ? `/${slug}` : ''}\``;
32
+ }
9
33
  export const README_REQUIRED_SECTIONS = [
10
- 'https://docs.seqholdings.com/', 'Artifact Studio', 'ORM', 'Managed Function',
34
+ '/docs', 'Artifact Studio', 'ORM', 'Managed Function',
11
35
  'seq-studio init', 'seq.functions.invoke',
12
36
  ];
13
37
  function primitivePath({ kind, appId, functionName }) {
@@ -27,6 +51,7 @@ const PRIMITIVE_LABELS = {
27
51
  workspace: 'Workspaces V2 workspace',
28
52
  };
29
53
  export function renderAppReadme(input) {
54
+ const atlasOrigin = normalizeAtlasOrigin(input.atlasOrigin);
30
55
  const title = input.title?.trim() || titleizeSlug(input.appId);
31
56
  const description = input.description?.trim() || 'A Sequence Platform app. Keep source in Git and deploy with seq-studio.';
32
57
  const kinds = new Set(input.primitives);
@@ -40,7 +65,9 @@ ${description}
40
65
 
41
66
  This repository is a **seq-studio app bundle**. Its root \`sequence.app.yml\` defines the app's deployable primitives, source locations, and deployment prerequisites. Keep this file, shared packages, primitive manifests, and the root lockfile together in Git.
42
67
 
43
- **Platform documentation:** [Sequence Platform](${SEQUENCE_DOCS_URL})
68
+ **Platform documentation:** ${docsLink({ atlasOrigin, label: 'Sequence Platform' })}
69
+
70
+ Documentation lives at \`/docs\` on the Atlas URL for your target environment. Find that URL with \`seq-studio envs list\` or ask your platform administrator; use it wherever \`<atlas-url>\` appears. The environment name is a CLI label, not a hostname. Keep the \`/docs/…\` path when switching environments.
44
71
 
45
72
  ## What this repository contains
46
73
 
@@ -144,15 +171,18 @@ seq-studio deploy -e <environment-name> --yes
144
171
  - **Official artifact deployments** require the full app checkout to be clean on \`main\`, including shared packages and the root manifest. Use \`seq-studio artifact dev artifact -e <environment-name>\` to preview uncommitted UI.
145
172
  - **Environment bindings** are resolved at deploy time. \`-e\` selects the environment. Source may not hardcode another environment's API origin or workspace UUID. Declare API origins in \`artifact.bundle.yml\` \`targets\`, and workspace use with \`uses\` on the workspace primitive.
146
173
 
147
- The per-primitive commands remain available for validation and operation; \`seq-studio deploy\` is the app-level deployment entry point. See \`seq-studio deploy --help\` and the [CLI command reference](${SEQUENCE_DOCS_URL}seq-studio/commands).
174
+ The per-primitive commands remain available for validation and operation; \`seq-studio deploy\` is the app-level deployment entry point. See \`seq-studio deploy --help\` and the CLI command reference at ${docsLink({ atlasOrigin, label: 'CLI command reference', slug: 'seq-studio/commands' })}.
148
175
  `;
149
176
  }
150
- export function renderEmptyRepoReadme({ repoName, namespaceSlug }) {
177
+ export function renderEmptyRepoReadme({ repoName, namespaceSlug, atlasOrigin }) {
151
178
  const qualified = namespaceSlug ? `${namespaceSlug}/${repoName}` : repoName;
152
- return `${GIT_SERVICE_SEED_MARKER}\n${renderAppReadme({
179
+ const origin = normalizeAtlasOrigin(atlasOrigin);
180
+ const originMarker = origin ? `<!-- seq-studio:atlas-origin=${origin} -->\n` : '';
181
+ return `${GIT_SERVICE_SEED_MARKER}\n${originMarker}${renderAppReadme({
153
182
  appId: repoName,
154
183
  description: `Sequence Platform git-service repository \`${qualified}\`. Scaffold an app in this clone, then validate and deploy with seq-studio.`,
155
184
  primitives: ['orm', 'function', 'artifact'],
185
+ atlasOrigin: origin,
156
186
  }).replace('## Implement this app', `## Scaffold the app
157
187
 
158
188
  From this clone's root:
@@ -8,7 +8,7 @@ import { join, relative, resolve } from 'node:path';
8
8
  import { currentVersion, isNewerVersion } from '../update-check.js';
9
9
  import { extendDeployOrder, loadAppManifest, titleizeSlug, writeAppManifest, } from './manifest.js';
10
10
  import { inspectScaffoldTarget, mergeGitignore, rollbackAppScaffold } from './scaffold-files.js';
11
- import { renderAppReadme } from './readme.js';
11
+ import { readGitServiceSeedAtlasOrigin, renderAppReadme } from './readme.js';
12
12
  import { writeScaffoldGuidance } from '../scaffold-guidance.js';
13
13
  import { primitiveIdFor, relativePathFor, scaffoldKind } from './primitive-scaffold.js';
14
14
  import { joinAppWorkspace, scaffoldAppWorkspace, scaffoldSharedPackage } from './workspace-scaffold.js';
@@ -77,6 +77,7 @@ export async function initAppMonorepo({ rootDir, appId, kinds, names = defaultSc
77
77
  description: manifest.app.description,
78
78
  primitives: kinds,
79
79
  functionName: names.functionName,
80
+ atlasOrigin: readGitServiceSeedAtlasOrigin(snapshot.previousReadme),
80
81
  }), 'utf8');
81
82
  return manifest;
82
83
  }
@@ -11,9 +11,8 @@
11
11
  * `seq-studio` without exposing the bearer in argv or environment.
12
12
  * 4. Forward all remaining argv to `runCli`.
13
13
  */
14
- import { getAccessTokenWithMode, M2mTokenError, tryGetAccessTokenWithMode, } from '../auth.js';
15
- import { readConfig, resolveEnvWithDiscovery } from '../config.js';
16
- import { fetchCatalog, readCachedCatalog } from '../env-catalog.js';
14
+ import { getAccessTokenWithMode, tryGetAccessTokenWithMode } from '../auth.js';
15
+ import { readConfig, resolveConfiguredEnv } from '../config.js';
17
16
  import { normalizeShortEnvFlag, readEnvFromArgv } from '../env-flags.js';
18
17
  import { PREVIEW_DOMAIN, PREVIEW_PROJECT, resolvePreviewByPr } from '../preview.js';
19
18
  const ARTIFACT_USAGE = `usage:
@@ -96,7 +95,7 @@ export async function runArtifactCommand(sub, rest) {
96
95
  await auth[sub]();
97
96
  return 0;
98
97
  }
99
- // `artifact env list` renders the tier-aware discovered catalog instead of
98
+ // `artifact env list` renders the configured environments instead of
100
99
  // artifact-studio's built-in (local-only) list.
101
100
  if (sub === 'env' && rest[0] === 'list') {
102
101
  const { runEnvsCommand } = await import('../envs/commands.js');
@@ -117,7 +116,6 @@ export async function runArtifactCommand(sub, rest) {
117
116
  let resolved;
118
117
  let argvForCli = forwardRest;
119
118
  if (envUrl !== undefined) {
120
- await requireSequenceTier('--env-url');
121
119
  const validated = validatePreviewEnvUrl(envUrl);
122
120
  // Explicit override wins over everything. Keep the user's --env name if
123
121
  // they gave one, else label it `preview`.
@@ -125,13 +123,12 @@ export async function runArtifactCommand(sub, rest) {
125
123
  argvForCli = ensureEnvFlag(forwardRest, resolved.name);
126
124
  }
127
125
  else if (prNumber !== undefined) {
128
- await requireSequenceTier('--pr');
129
126
  const preview = await resolvePreviewByPr({ pr: prNumber });
130
127
  resolved = { name: `preview:${preview.slug}`, url: preview.url };
131
128
  argvForCli = ensureEnvFlag(forwardRest, resolved.name);
132
129
  }
133
130
  else if (requested) {
134
- resolved = await resolveEnvWithDiscovery({ requested });
131
+ resolved = await resolveConfiguredEnv({ requested });
135
132
  // For `preview:<slug>` normalize the forwarded --env to the canonical name.
136
133
  if (resolved.name !== requested)
137
134
  argvForCli = ensureEnvFlag(forwardRest, resolved.name);
@@ -144,8 +141,8 @@ export async function runArtifactCommand(sub, rest) {
144
141
  if (isPreviewUrl(resolved.url))
145
142
  applyPreviewAccessHeader();
146
143
  }
147
- // Always hand artifact-studio the env map visible to this identity
148
- // (discovered catalog + config.toml). Commands that resolve an env *name*
144
+ // Always hand artifact-studio the configured env map (config.toml +
145
+ // registered deployments). Commands that resolve an env *name*
149
146
  // without an explicit --env flag — the stored `.artifact-studio/config.json`
150
147
  // defaultEnv, `artifact env set <name>` — would otherwise fall back to
151
148
  // artifact-studio's built-in local-only map and fail on deployed envs.
@@ -167,31 +164,6 @@ export async function runArtifactCommand(sub, rest) {
167
164
  }));
168
165
  return runArtifactStudio([sub, ...argvForCli]);
169
166
  }
170
- /**
171
- * Preview targeting (`preview:<slug>`, `--pr`, `--env-url`) is a
172
- * Sequence-staff surface. The tier comes from the cached discovery catalog;
173
- * refresh it lazily so a just-logged-in engineer isn't blocked on a stale
174
- * anonymous cache.
175
- */
176
- async function requireSequenceTier(flag) {
177
- let { tier } = await readConfig();
178
- if (tier !== 'sequence') {
179
- try {
180
- tier = (await fetchCatalog())?.tier ?? 'anonymous';
181
- }
182
- catch (err) {
183
- // Broken CI credentials must surface as the Auth0 error, not as a
184
- // misleading "Sequence-staff surface" rejection.
185
- if (err instanceof M2mTokenError)
186
- throw err;
187
- tier = (await readCachedCatalog())?.tier ?? 'anonymous';
188
- }
189
- }
190
- if (tier !== 'sequence') {
191
- throw new Error(`${flag} targets per-PR preview environments, a Sequence-staff surface. ` +
192
- 'Authenticate with `seq-studio login` and run `seq-studio envs refresh`.');
193
- }
194
- }
195
167
  /**
196
168
  * Strip the seq-studio-only `--pr <number>` and `--env-url <url>` flags from
197
169
  * argv and return the rest (forwarded to artifact-studio) plus the parsed
@@ -18,8 +18,8 @@ import { confirmYes } from '../prompt.js';
18
18
  import { storeGitCredentials } from '../repos/git-clone.js';
19
19
  import { formatPatSetupHint, settingsTokensUrl } from '../pat-hints.js';
20
20
  /**
21
- * Tokens-page URLs rendered from the environments visible to this identity
22
- * (discovered catalog + config.toml). Anonymous users get a generic pointer
21
+ * Tokens-page URLs rendered from the configured environments (config.toml +
22
+ * registered deployments). With none configured, print a generic pointer
23
23
  * instead of a hardcoded list of internal hosts.
24
24
  */
25
25
  async function settingsTokensLines() {
package/dist/auth.d.ts CHANGED
@@ -176,15 +176,6 @@ export declare function verifyTokenMatchesRealm({ accessToken, realm, requireOrg
176
176
  realm: AuthRealm;
177
177
  requireOrganization?: boolean;
178
178
  }): void;
179
- export declare function decodeJwtSub(token: string): string | null;
180
- /**
181
- * The Auth0 subject the CLI would authenticate as right now, without any
182
- * network call. Matches token resolution precedence: a valid user session
183
- * wins over an ambient M2M secret unless `SEQAPI_AUTH_MODE=m2m`.
184
- */
185
- export declare function currentIdentitySubject(options?: {
186
- env?: string;
187
- }): Promise<string | null>;
188
179
  export declare function loadCachedUserTokens(realmName?: string): Promise<SeqapiTokens | null>;
189
180
  export declare function saveTokens(tokens: SeqapiTokens, realmName?: string): Promise<void>;
190
181
  export declare function deleteRealmTokens(realmName: string): Promise<void>;
package/dist/auth.js CHANGED
@@ -613,9 +613,8 @@ export async function inspectAuthPreflight(options) {
613
613
  };
614
614
  }
615
615
  /**
616
- * Decode the `sub` claim from a JWT without verification. Verification is the
617
- * server's job — this is only used to compare identities locally (e.g. to
618
- * bind the cached environment catalog to the identity that fetched it).
616
+ * Decode a JWT's claims without verification. Verification is the server's
617
+ * job — this is only used to inspect a token locally.
619
618
  */
620
619
  function decodeJwtClaims(token) {
621
620
  const payload = token.split('.')[1];
@@ -656,32 +655,6 @@ export function verifyTokenMatchesRealm({ accessToken, realm, requireOrganizatio
656
655
  `expected '${realm.organization}' — refusing to store it.`);
657
656
  }
658
657
  }
659
- export function decodeJwtSub(token) {
660
- const claims = decodeJwtClaims(token);
661
- const sub = claims ? Reflect.get(claims, 'sub') : null;
662
- return typeof sub === 'string' && sub ? sub : null;
663
- }
664
- /**
665
- * The Auth0 subject the CLI would authenticate as right now, without any
666
- * network call. Matches token resolution precedence: a valid user session
667
- * wins over an ambient M2M secret unless `SEQAPI_AUTH_MODE=m2m`.
668
- */
669
- export async function currentIdentitySubject(options = {}) {
670
- const realm = await realmForEnv(options.env);
671
- const forceM2m = authModePrefersM2m();
672
- if (!forceM2m) {
673
- const tokens = await loadCachedUserTokens(realm.name);
674
- const now = Date.now() / 1000;
675
- if (tokens?.access_token && (tokens.expires_at ?? 0) > now + 60) {
676
- verifyTokenMatchesRealm({ accessToken: tokens.access_token, realm });
677
- return decodeJwtSub(tokens.access_token);
678
- }
679
- }
680
- if (realm.m2mClientId && process.env[m2mSecretEnvName(realm)]?.trim()) {
681
- return `${realm.m2mClientId}@clients`;
682
- }
683
- return null;
684
- }
685
658
  async function readTokenFile() {
686
659
  const path = seqapiTokenPath();
687
660
  let text;
@@ -2,6 +2,8 @@
2
2
  export declare const ORM_HELP = "usage:\n seq-studio orm init <dir>\n seq-studio orm generate [dir] [--migration-export] [--check]\n seq-studio orm validate [dir]\n seq-studio orm plan [dir] -e <env>\n seq-studio orm apply [dir] -e <env>\n seq-studio orm execute <operation> [dir] --variables-file <file> -e <env>\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";
3
3
  export declare const ARTIFACT_HELP = "usage:\n seq-studio artifact init <dir> [--template react-vite|nextjs]\n seq-studio artifact whoami -e <env>\n seq-studio artifact link [dir] -e <env> [--project <id>]\n seq-studio artifact env list|use <env>\n seq-studio artifact status [-e <env>]\n seq-studio artifact list -e <env> [--json]\n seq-studio artifact show <slug-or-id> -e <env> [--json]\n seq-studio artifact validate [dir]\n seq-studio artifact build|plan|deploy [dir | --repo <namespace>/<name> | --git-url <url>] [--ref <ref>] -e <env>\n seq-studio artifact dev [dir] -e <env> [--once] [--key <name>] [--link <package-dir>] [--port <port>]\n seq-studio artifact pull <project-id> -e <env> --out <dir>\n seq-studio artifact promote|rollback <deployment-id> -e <env>\n\n Help is available offline. Authenticate with seq-studio login. Build and deploy\n sources may be local, a platform git-service repo, or a public HTTPS Git URL;\n deployments target a named environment with -e. Local, preview, and official\n deployment workflows have different source and approval rules; see the public\n CLI README.\n";
4
4
  export declare const PIPELINE_HELP = "usage:\n seq-studio pipeline list -e <env> [--limit 1..200] [--offset N] [--json]\n list pipeline repository rollups (not assets)\n seq-studio pipeline assets -e <env> [--repo <namespace>/<slug>] [--json]\n list asset declarations, including assets that may not be deployed\n seq-studio pipeline search <query> -e <env> [--target <id>] [--repo <namespace>/<slug>] [--limit N] [--offset N] [--json]\n seq-studio pipeline describe <asset-id> -e <env> [--target <id>] [--repo <namespace>/<slug>] [--json]\n seq-studio pipeline schema|sample <asset-id> -e <env> [--target <id>] [--limit N] [--json]\n seq-studio pipeline query <asset-id> --sql <read-only-sql> -e <env> [--target <id>] [--limit N] [--json]\n seq-studio pipeline init|validate|plan|deploy|status|migrate|adopt|unbind|run-now|promote|rollback ...\n seq-studio pipeline plan --plan-request-id <id> -e <env> [--json]\n poll an existing durable plan without enqueueing or attaching credentials\n Lifecycle --json results use stdout; progress uses stderr. Deploy --run-now\n executes producers in the managed worker; local polling may disconnect.\n\n Discovery requires staff access. Use list for pipeline repositories, assets\n for declared assets, and search/describe for active deployment metadata;\n use schema to verify physical columns. -e chooses the environment and\n --target chooses a logical target when the environment has more than one.\n Help is available offline.\n";
5
+ export declare const FUNCTIONS_USAGE = "usage:\n seq-studio functions init <dir> scaffold manifest, TypeScript handler, and docs pointers\n seq-studio functions build [--dir d] local pre-flight (manifest, lockfile, SDK timeout cap)\n seq-studio functions register -e <env> [--dir d] register a function shell without deploying\n seq-studio functions deploy -e <env> [-m msg] preflight deployed capabilities, then upload and deploy\n seq-studio functions list -e <env> [--match-local] functions visible on the environment\n seq-studio functions show -e <env> [--fn slug] detail for one function (versions, secrets)\n seq-studio functions limits [-e <env>] [--json] bundled defaults/caps, or deployed policy\n [--fn slug] also show effective runtime limits (requires -e)\n seq-studio functions dev [--dir path] [--port 8080] local HTTP server with cache context\n seq-studio functions invoke -e <env> [--data JSON | --data @file | --stdin]\n invoke a function and print its response\n seq-studio functions logs -e <env> [--limit N] [--since t] function logs (reader-gated)\n seq-studio functions promote <version> -e <env> make a version live\n seq-studio functions rollback [<version>] -e <env> redeploy a prior version\n seq-studio functions delete -e <env> [--yes] archive function + tear down its runtime\n (version history is retained)\n\n Flags: -e/--env <env|preview:<slug>> (required for network commands; see: seq-studio envs list) \u00B7 --fn <slug> \u00B7 --dir <path>\n --path <repo-subdirectory> (remote build/deploy only) select one function in a multi-function repo\n --from-env-file <path> (default: .env) source file for secret values\n --no-wait \u00B7 --yes\n --no-provision (deploy) update-only: error instead of registering a new\n shell, writing secret values, or attaching secrets (CI sweep)\n\n Local Atlas builds and runs deployed functions on this computer, including teardown.\n \"functions dev\" runs a standalone handler without Atlas registration.\n\n Configure per-function CPU and concurrency in managed-function.yml under limits.\n Run \"functions limits\" for valid settings; redeploy to apply manifest changes.\n Invocation rates are shared across Atlas replicas; 429 includes Retry-After.\n If the shared rate limiter is unavailable, invocation fails closed with 503.\n\n Source for build/deploy: a local --dir (default .), a platform git-service\n repo (--repo <ns>/<name>), or a public HTTPS git URL (--git-url <url>). --path selects\n a function directory within a remote repo; omit it for the existing root-manifest\n layout. --ref selects a branch/tag/commit (default: the repo's default branch).\n Remote sources record the pinned commit as provenance (never dirty) and NEVER\n read a repo-committed .env for secret values \u2014 provision secrets server-side\n or pass a local --from-env-file (resolved against your cwd).\n\n Interactive --repo builds clone over smart-HTTP and require a repo:read git\n PAT in ATLAS_GIT_PAT (`seq-studio auth pat create --scopes repo:read`, or\n Atlas \u2192 Settings \u2192 Tokens). Headless M2M builds use JSON materialize and\n accept only platform-managed --repo sources. Interactive builds also need\n --env + seq-studio login to resolve the repo and deploy.\n";
6
+ export declare const REPOS_USAGE = "usage:\n seq-studio repos list -e <env> [--namespace <slug>] [--mine] repos visible on the environment\n seq-studio repos namespaces [create <slug>] -e <env> list or create namespaces\n seq-studio repos show <ns>/<name> -e <env> repo detail (branches, clone URL)\n seq-studio repos create <ns>/<name> -e <env> [--default-branch b] [--git-backend walgit]\n create a repo seeded with a README; --git-backend\n walgit creates it empty (for pushing existing\n history); needs namespace write\n seq-studio repos clone <ns>/<name> -e <env> [--ref r] [--output dir] [--force] [--full] [--transport auto|git|json]\n seq-studio repos clone --url <https://\u2026/repos/<id>/git> -e <env> [--ref r] [--output dir] [--full]\n seq-studio repos clone --id <uuid> -e <env> [--ref r] [--output dir] [--full]\n smart-HTTP when ATLAS_GIT_PAT is set;\n otherwise JSON materialize (<ns>/<name>)\n seq-studio repos pull <ns>/<name> -e <env> [--ref r] [--out dir] [--force]\n materialize the tree at a ref (JSON API)\n seq-studio repos pulls <list|show|create|diff|merge> [args] review requests (see pulls --help)\n seq-studio repos delete <ns>/<name> -e <env> [--yes] delete a repo (confirm prompt)\n seq-studio repos ci show <ns>/<name> -e <env> [--ref r] preview discovered CI checks\n seq-studio repos ci require <ns>/<name> --check <name> -e <env> reserved (refuses write until sandboxed runner)\n seq-studio repos ci import <ns>/<name> -e <env> [--ref r] reserved (refuses write until sandboxed runner)\n\n Flags: -e/--env <env> (required; see: seq-studio envs list)\n\n clone prefers real git clone (PAT via askpass \u2014 never written into the remote\n URL). --transport auto (default) uses Git when ATLAS_GIT_PAT is set and JSON\n materialization otherwise; --transport git requires a repo:read PAT; --transport\n json ignores ATLAS_GIT_PAT and uses the signed-in Atlas identity (<ns>/<name>\n only; no .git directory). Authentication failures explain this retry path.\n JSON materialization requires repo read access and prints how to create a PAT.\n PAT without Auth0 login: use --id from Repositories \u2192 Clone\n (or --url with the environment's canonical HTTPS origin).\n --ref accepts a branch, tag, or commit SHA (SHA \u2192 full clone, then checkout).\n Branch and tag clones are shallow (--depth 1). Pass --full for history.\n --output selects the clone directory (--out remains an alias).\n\n Authenticate JSON API calls with: seq-studio login\n Authenticate git clone/push with: ATLAS_GIT_PAT (from Atlas Settings \u2192 Tokens)\n";
5
7
  export declare function staticHelp({ namespace, sub }: {
6
8
  namespace: string;
7
9
  sub?: string;