@sequenceholdings/studio-cli 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -386,9 +386,9 @@ Application role gives them everything the app needs: each member's end-user
386
386
  access plus the member roles and capabilities the role bundles. Grants are made
387
387
  in Atlas too, never in the manifest.
388
388
 
389
- - A role's includes can reach `artifact`, `function`, `orm`, and `process`
390
- primitives: a member's end-user access (`invoker` on functions and
391
- processes), one of its registered roles, or one of its capabilities.
389
+ - A role's includes can reach `artifact`, `function`, `orm`, `process`, and
390
+ `agent` primitives: a member's end-user access (`invoker` on functions,
391
+ processes and agents), one of its registered roles, or one of its capabilities.
392
392
  A member role or capability doesn't grant end-user access by itself — as on
393
393
  the primitive, a role needs an explicit end-user include on each member its
394
394
  holders should be able to open.
@@ -398,9 +398,15 @@ in Atlas too, never in the manifest.
398
398
  ```yaml
399
399
  - { id: approval-flow, kind: process, path: processes/approval, only: [loan-approval] }
400
400
  ```
401
+ - An `agent` primitive likewise offers only end-user access (chatting with it
402
+ and starting jobs), and a role can include it only when the entry deploys
403
+ exactly one agent — a directory with one agent, or `only: [<agent-id>]`. Its
404
+ member ref is the agent id that entry deploys to the target environment, so
405
+ the deploy refuses a role that reaches an entry deploying several agents.
406
+ Seeing other people's conversations with the agent is never bundled.
401
407
  - The Application registers after every primitive deploys; if one fails, it
402
408
  is skipped. Registering requires capability admin on every member (owner,
403
- for a process), checked on every deploy.
409
+ for a process or an agent), checked on every deploy.
404
410
  - Members are synced every deploy. Removing one removes every role's access
405
411
  into it.
406
412
  - A Next.js artifact is an ordinary `artifact` member. Its server calls ORM and
@@ -409,8 +415,12 @@ in Atlas too, never in the manifest.
409
415
  on every namespace and `invoker` on every function and process its
410
416
  `server.capabilities` reach (the same holds for any artifact's browser
411
417
  `capabilities`). The deploy prints an `access_gap` warning for each missing
412
- namespace or function grant; process starts aren't checked yet, so grant the
413
- process `invoker` explicitly. It never adds grants for you.
418
+ namespace, function or process grant. It never adds grants for you.
419
+ - An agent runs as whoever uses it, so a role giving "Can use" on an agent
420
+ should also include its subagents and managed functions. The deploy prints
421
+ an `access_gap` warning for each one missing, saying whether the agent
422
+ requires it (runs are refused) or not (runs go ahead without it), then a
423
+ link to the Application's Runtime access, where each gap is one click to fix.
414
424
 
415
425
  #### Deprecated: role definitions in YAML
416
426
 
@@ -459,6 +469,9 @@ and inherits only other collaborator roles.
459
469
  | `orm` | `reader`, `writer` |
460
470
  | `process` (exactly one, `only: [<process-id>]`) | `editor` |
461
471
  | `pipeline` (needs `repo`) | `viewer`, `operator`, `editor` |
472
+ | `agent` (exactly one agent) | `editor` |
473
+ | secret (listed under `secrets:`) | `editor` |
474
+ | service account (listed under `service_accounts:`) | `actor` |
462
475
 
463
476
  - Never `admin` or `owner`: admin can share a member and bundle it into other
464
477
  Applications, so it stays a direct grant. Workspaces are never bundled.
@@ -468,6 +481,30 @@ and inherits only other collaborator roles.
468
481
  `viewer` sees its runs, `operator` runs its stages, `editor` deploys it.
469
482
  - A pipeline member is its release unit, the same id deploy registers:
470
483
  `pipelines/<name>`, or `apps/<name>@<path>` for one of an app's pipelines.
484
+ - Secrets the app's functions and pipelines read are listed under a top-level
485
+ `secrets:` block by their name in each environment. Deploy doesn't create or
486
+ set them — use `seq-studio secrets` — it bundles them so a collaborator role
487
+ can give `editor` (set the value, roll back, attach and pin it; values stay
488
+ write-only). Like a pipeline, a secret has nothing to use: functions and
489
+ stages read it through their own attachments whether or not it's listed,
490
+ so it appears only in collaborator roles. A `uses` edge may point at one.
491
+ - Service accounts the app's members run as are listed under a top-level
492
+ `service_accounts:` block by slug (`- { id: runtime, slug: loan-desk-runtime }`).
493
+ A collaborator role may give `actor`, which every deploy that runs code as
494
+ the account requires. Actor is close to the account's own access, so its
495
+ admins see what the account holds before they allow it. Members run as the
496
+ account whether or not it's listed.
497
+
498
+ ```yaml
499
+ secrets:
500
+ - { id: candescent-oauth, name: CANDESCENT_OAUTH }
501
+ collaborators:
502
+ definitions:
503
+ maintainer:
504
+ includes:
505
+ - { primitive: desk-api, tier: editor }
506
+ - { primitive: candescent-oauth, tier: editor }
507
+ ```
471
508
  - Consent is stricter than for runtime roles: bundling a member's tiers needs
472
509
  **admin** on it (owner, for a process), checked on every deploy.
473
510
  - Only the Application's admins create, edit and grant collaborator roles in
@@ -9,11 +9,14 @@
9
9
  * The YAML's `role: end_user | invoker` alias becomes the server's single
10
10
  * `{ type: 'end_user' }` spelling here, so the API has one contract. Members
11
11
  * are the artifact/function/ORM primitives, single-process entries and
12
- * pipelines, referenced by the stable names that resolve in every environment.
12
+ * pipelines, referenced by the stable names that resolve in every environment,
13
+ * single-agent entries, referenced by the agent id they deploy to the target
14
+ * environment (agent-refs.ts), the app's `secrets`, by name, and its
15
+ * `service_accounts`, by slug.
13
16
  */
14
17
  import { type ClientOptions } from '../atlas-client.js';
15
18
  import { type AppManifest, type PrimitiveEntry } from './manifest.js';
16
- type MemberKind = 'artifact' | 'function' | 'orm' | 'lattice' | 'pipeline';
19
+ type MemberKind = 'artifact' | 'function' | 'orm' | 'lattice' | 'pipeline' | 'agent' | 'secret' | 'service_account';
17
20
  export interface ApplicationDeployMember {
18
21
  key: string;
19
22
  kind: MemberKind;
@@ -40,11 +43,11 @@ type ApplicationDeployRole = {
40
43
  inherits: string[];
41
44
  includes: ApplicationDeployInclude[];
42
45
  };
43
- /** Every primitive, members or not — the nodes of the Dependencies graph. */
46
+ /** Every primitive and secret, members or not — the nodes of the Dependencies graph. */
44
47
  export interface ApplicationDeployComponent {
45
48
  key: string;
46
- kind: PrimitiveEntry['kind'];
47
- /** The stable name Atlas can resolve: slug, project id, namespace, workspace name, or process id. */
49
+ kind: PrimitiveEntry['kind'] | 'secret' | 'service_account';
50
+ /** The stable name Atlas can resolve: slug, project id, namespace, workspace name, process id, or secret name. */
48
51
  ref?: string;
49
52
  }
50
53
  /** A runtime dependency (`uses`): `from` uses `to` while it runs. */
@@ -98,6 +101,8 @@ export type ApplicationRegistration = {
98
101
  warnings: ApplicationDeployWarning[];
99
102
  /** Members whose admins must allow this Application before roles reach them. Older servers send none. */
100
103
  requested?: ApplicationConsentRequest[];
104
+ /** The Application's Runtime access page, where access gaps are fixed. */
105
+ accessUrl?: string;
101
106
  } | {
102
107
  status: 'failed';
103
108
  message: string;
@@ -108,6 +113,12 @@ export type RegisterApplication = (args: {
108
113
  /** Primitive id -> the agent an agent entry deploys. */
109
114
  agentRefs?: ReadonlyMap<string, string>;
110
115
  }) => Promise<ApplicationRegistration>;
116
+ /**
117
+ * Agent entries a role or collaborator role includes that didn't resolve to
118
+ * exactly one agent (a directory of several, or one the deploy couldn't read):
119
+ * such a role would reach no agent, so registering it is refused up front.
120
+ */
121
+ export declare function unresolvedAgentIncludes(manifest: AppManifest, agentRefs: ReadonlyMap<string, string>): string[];
111
122
  export declare function putApplication({ client, manifest, agentRefs, }: {
112
123
  client: ClientOptions;
113
124
  manifest: AppManifest;
@@ -9,7 +9,10 @@
9
9
  * The YAML's `role: end_user | invoker` alias becomes the server's single
10
10
  * `{ type: 'end_user' }` spelling here, so the API has one contract. Members
11
11
  * are the artifact/function/ORM primitives, single-process entries and
12
- * pipelines, referenced by the stable names that resolve in every environment.
12
+ * pipelines, referenced by the stable names that resolve in every environment,
13
+ * single-agent entries, referenced by the agent id they deploy to the target
14
+ * environment (agent-refs.ts), the app's `secrets`, by name, and its
15
+ * `service_accounts`, by slug.
13
16
  */
14
17
  import { AtlasApiError, putJson } from '../atlas-client.js';
15
18
  import { buildContext, clientOptions } from '../functions/commands.js';
@@ -19,9 +22,13 @@ const LOG = '[seq-studio]';
19
22
  /**
20
23
  * The member ref Atlas resolves: project slug, function slug, namespace, a
21
24
  * pipeline's release unit, or — for a process entry that deploys exactly one
22
- * process — its process id.
25
+ * process — its process id, or — for an agent entry that deploys exactly one
26
+ * agent — that agent's id here.
23
27
  */
24
- function memberOf(entry) {
28
+ function memberOf(entry, agentRefs) {
29
+ const agentId = entry.kind === 'agent' ? agentRefs.get(entry.id) : undefined;
30
+ if (agentId)
31
+ return { key: entry.id, kind: 'agent', ref: agentId };
25
32
  if (entry.kind === 'artifact' && entry.project_id)
26
33
  return { key: entry.id, kind: 'artifact', ref: entry.project_id };
27
34
  if (entry.kind === 'function' && entry.slug)
@@ -82,14 +89,22 @@ export function buildApplicationDeployBody(manifest, { agentRefs = new Map() } =
82
89
  return {
83
90
  title: manifest.app.title,
84
91
  ...(manifest.app.description !== undefined ? { description: manifest.app.description } : {}),
85
- members: manifest.primitives.flatMap((entry) => {
86
- const member = memberOf(entry);
87
- return member ? [member] : [];
88
- }),
89
- components: manifest.primitives.map((entry) => {
90
- const ref = componentRef(entry, agentRefs);
91
- return { key: entry.id, kind: entry.kind, ...(ref !== undefined ? { ref } : {}) };
92
- }),
92
+ members: [
93
+ ...manifest.primitives.flatMap((entry) => {
94
+ const member = memberOf(entry, agentRefs);
95
+ return member ? [member] : [];
96
+ }),
97
+ ...(manifest.secrets ?? []).map((secret) => ({ key: secret.id, kind: 'secret', ref: secret.name })),
98
+ ...(manifest.service_accounts ?? []).map((account) => ({ key: account.id, kind: 'service_account', ref: account.slug })),
99
+ ],
100
+ components: [
101
+ ...manifest.primitives.map((entry) => {
102
+ const ref = componentRef(entry, agentRefs);
103
+ return { key: entry.id, kind: entry.kind, ...(ref !== undefined ? { ref } : {}) };
104
+ }),
105
+ ...(manifest.secrets ?? []).map((secret) => ({ key: secret.id, kind: 'secret', ref: secret.name })),
106
+ ...(manifest.service_accounts ?? []).map((account) => ({ key: account.id, kind: 'service_account', ref: account.slug })),
107
+ ],
93
108
  edges: manifest.primitives.flatMap((entry) => entry.uses.map((use) => ({ from: entry.id, to: use.primitive, ...(use.as !== undefined ? { label: use.as } : {}) }))),
94
109
  roles,
95
110
  collaborators: collaboratorRolesOf(manifest),
@@ -100,7 +115,7 @@ function asRecord(value) {
100
115
  return value && typeof value === 'object' ? Object.fromEntries(Object.entries(value)) : {};
101
116
  }
102
117
  const isString = (value) => typeof value === 'string';
103
- const MEMBER_KINDS = ['artifact', 'function', 'orm', 'lattice', 'pipeline'];
118
+ const MEMBER_KINDS = ['artifact', 'function', 'orm', 'lattice', 'pipeline', 'agent', 'secret', 'service_account'];
104
119
  const isMemberKind = (value) => MEMBER_KINDS.some((kind) => kind === value);
105
120
  const MEMBER_KIND_LABEL = {
106
121
  artifact: 'artifact',
@@ -108,6 +123,9 @@ const MEMBER_KIND_LABEL = {
108
123
  orm: 'ORM namespace',
109
124
  lattice: 'Lattice process',
110
125
  pipeline: 'pipeline',
126
+ agent: 'agent',
127
+ secret: 'secret',
128
+ service_account: 'service account',
111
129
  };
112
130
  /** Server-side detail worth printing beyond the error message. */
113
131
  function errorDetailLines(error) {
@@ -124,7 +142,28 @@ function errorDetailLines(error) {
124
142
  }
125
143
  return lines;
126
144
  }
127
- export async function putApplication({ client, manifest, agentRefs, }) {
145
+ /**
146
+ * Agent entries a role or collaborator role includes that didn't resolve to
147
+ * exactly one agent (a directory of several, or one the deploy couldn't read):
148
+ * such a role would reach no agent, so registering it is refused up front.
149
+ */
150
+ export function unresolvedAgentIncludes(manifest, agentRefs) {
151
+ const agentEntries = new Set(manifest.primitives.filter((entry) => entry.kind === 'agent').map((entry) => entry.id));
152
+ const included = [
153
+ ...Object.values(manifest.roles?.definitions ?? {}).flatMap((definition) => definition.includes),
154
+ ...Object.values(manifest.collaborators?.definitions ?? {}).flatMap((definition) => definition.includes),
155
+ ].map((include) => include.primitive);
156
+ return [...new Set(included.filter((id) => agentEntries.has(id) && !agentRefs.has(id)))];
157
+ }
158
+ export async function putApplication({ client, manifest, agentRefs = new Map(), }) {
159
+ const unresolved = unresolvedAgentIncludes(manifest, agentRefs);
160
+ if (unresolved.length > 0) {
161
+ return {
162
+ status: 'failed',
163
+ message: `roles include agent entries that don't deploy exactly one agent here: ${unresolved.join(', ')}. ` +
164
+ 'Set only: [<agent-id>] on each so its roles reach one agent.',
165
+ };
166
+ }
128
167
  const path = `/api/custom-roles/applications/${encodeURIComponent(manifest.app.id)}`;
129
168
  try {
130
169
  const response = await putJson({
@@ -151,7 +190,8 @@ export async function putApplication({ client, manifest, agentRefs, }) {
151
190
  }]
152
191
  : [];
153
192
  });
154
- return { status: 'registered', created: response.created === true, warnings, requested };
193
+ const accessUrl = new URL(`/permissions/applications/application/${encodeURIComponent(manifest.app.id)}?tab=roles`, client.baseUrl).toString();
194
+ return { status: 'registered', created: response.created === true, warnings, requested, accessUrl };
155
195
  }
156
196
  catch (error) {
157
197
  if (!(error instanceof AtlasApiError))
@@ -172,11 +212,17 @@ export function logApplicationRegistration({ appId, registration, }) {
172
212
  const section = warning.kind === 'collaborator' ? 'collaborators' : warning.kind === 'capability' ? 'capabilities' : 'roles';
173
213
  console.warn(`${LOG} ! ${section}.${warning.role}: ${warning.detail}`);
174
214
  }
215
+ // Roles live in Atlas, so that's where a gap is closed: each offers adding the missing "Can use".
216
+ if (registration.accessUrl && registration.warnings.some((warning) => warning.type === 'access_gap')) {
217
+ console.warn(`${LOG} Fix access gaps from Runtime access, one click each: ${registration.accessUrl}`);
218
+ }
175
219
  const requested = registration.requested ?? [];
176
220
  if (requested.length > 0) {
177
221
  console.warn(`${LOG} Waiting for consent — roles that include these members take effect once their admins allow "${appId}":`);
178
222
  for (const request of requested) {
179
- const what = request.level === 'collaborator' ? 'to bundle its edit tiers' : 'to give people access';
223
+ const what = request.kind === 'service_account'
224
+ ? 'to let collaborator roles give Actor'
225
+ : request.level === 'collaborator' ? 'to bundle its edit tiers' : 'to give people access';
180
226
  const before = request.previously ? ` (previously ${request.previously})` : '';
181
227
  console.warn(`${LOG} ${request.member}: ${MEMBER_KIND_LABEL[request.kind]} "${request.ref}" — ask its admins ${what}${before}`);
182
228
  }
@@ -11,6 +11,14 @@ type ManifestGraph = {
11
11
  order?: string[];
12
12
  on_error: 'stop' | 'continue';
13
13
  };
14
+ secrets?: {
15
+ id: string;
16
+ name: string;
17
+ }[];
18
+ service_accounts?: {
19
+ id: string;
20
+ slug: string;
21
+ }[];
14
22
  roles?: {
15
23
  definitions: Record<string, {
16
24
  inherits: string[];
@@ -1,8 +1,8 @@
1
1
  import { dependencyOrder } from './graph.js';
2
2
  /** Primitive kinds an Application role can reach into. */
3
- const ROLE_MEMBER_KINDS = new Set(['artifact', 'function', 'orm', 'process']);
3
+ const ROLE_MEMBER_KINDS = new Set(['artifact', 'function', 'orm', 'process', 'agent']);
4
4
  /** Kinds whose floor YAML may also spell `invoker` (their native term). */
5
- const INVOKER_FLOOR_KINDS = new Set(['function', 'process']);
5
+ const INVOKER_FLOOR_KINDS = new Set(['function', 'process', 'agent']);
6
6
  /** The member tiers each kind lets a collaborator role bundle (mirrors Atlas). */
7
7
  const COLLABORATOR_TIERS_BY_KIND = {
8
8
  artifact: ['reader', 'writer'],
@@ -10,6 +10,9 @@ const COLLABORATOR_TIERS_BY_KIND = {
10
10
  orm: ['reader', 'writer'],
11
11
  process: ['editor'],
12
12
  pipeline: ['viewer', 'operator', 'editor'],
13
+ agent: ['editor'],
14
+ secret: ['editor'],
15
+ service_account: ['actor'],
13
16
  };
14
17
  /** v2 and v3 share the deployment graph (manifest.ts `usesAppGraph`; inlined to avoid an import cycle). */
15
18
  const usesGraph = (manifest) => manifest.schema_version >= 2;
@@ -24,7 +27,11 @@ function validateRoles({ manifest, ctx }) {
24
27
  ctx.addIssue({ code: 'custom', message: 'roles require schema_version: 3', path: ['roles'] });
25
28
  return;
26
29
  }
27
- const kindById = new Map(manifest.primitives.map((entry) => [entry.id, entry.kind]));
30
+ const kindById = new Map([
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']),
34
+ ]);
28
35
  const entryById = new Map(manifest.primitives.map((entry) => [entry.id, entry]));
29
36
  const definitions = manifest.roles.definitions;
30
37
  for (const [key, definition] of Object.entries(definitions)) {
@@ -48,6 +55,14 @@ function validateRoles({ manifest, ctx }) {
48
55
  // A pipeline runs as a service principal: nothing about it is "used" at runtime.
49
56
  ctx.addIssue({ code: 'custom', message: "pipelines have no runtime access to bundle — give their viewer, operator or editor tier under collaborators", path: at('includes', index, 'primitive') });
50
57
  }
58
+ else if (kind === 'secret') {
59
+ // Functions and stages read a secret through their attachments; people never open one.
60
+ ctx.addIssue({ code: 'custom', message: "secrets have no runtime access to bundle — give their editor tier under collaborators", path: at('includes', index, 'primitive') });
61
+ }
62
+ else if (kind === 'service_account') {
63
+ // Members run as an account whoever uses them; people never act as it at runtime.
64
+ ctx.addIssue({ code: 'custom', message: "service accounts have no runtime access to bundle — give their actor tier under collaborators", path: at('includes', index, 'primitive') });
65
+ }
51
66
  else if (!ROLE_MEMBER_KINDS.has(kind)) {
52
67
  ctx.addIssue({ code: 'custom', message: `Application roles can't include ${kind} primitives yet`, path: at('includes', index, 'primitive') });
53
68
  }
@@ -57,6 +72,9 @@ function validateRoles({ manifest, ctx }) {
57
72
  else if (kind === 'process') {
58
73
  processIncludeIssue({ entry: entryById.get(include.primitive), include, path: at('includes', index), ctx });
59
74
  }
75
+ else if (kind === 'agent') {
76
+ agentIncludeIssue({ entry: entryById.get(include.primitive), include, path: at('includes', index), ctx });
77
+ }
60
78
  }
61
79
  }
62
80
  }
@@ -69,6 +87,8 @@ function validateCollaborators({ manifest, ctx }) {
69
87
  return;
70
88
  }
71
89
  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));
72
92
  const definitions = manifest.collaborators.definitions;
73
93
  for (const [key, definition] of Object.entries(definitions)) {
74
94
  const at = (...path) => ['collaborators', 'definitions', key, ...path];
@@ -78,6 +98,18 @@ function validateCollaborators({ manifest, ctx }) {
78
98
  }
79
99
  }
80
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
+ }
111
+ continue;
112
+ }
81
113
  const entry = entryById.get(include.primitive);
82
114
  const allowed = entry ? COLLABORATOR_TIERS_BY_KIND[entry.kind] : undefined;
83
115
  if (!entry) {
@@ -95,6 +127,9 @@ function validateCollaborators({ manifest, ctx }) {
95
127
  else if (entry.kind === 'process' && entry.only?.length !== 1) {
96
128
  ctx.addIssue({ code: 'custom', message: `set only: [<process-id>] on "${entry.id}" so the role reaches exactly one process`, path: at('includes', index) });
97
129
  }
130
+ else if (entry.kind === 'agent' && (entry.only?.length ?? 1) !== 1) {
131
+ ctx.addIssue({ code: 'custom', message: severalAgentsMessage(entry.id), path: at('includes', index) });
132
+ }
98
133
  }
99
134
  }
100
135
  }
@@ -144,12 +179,13 @@ function validateInventory({ manifest, ctx }) {
144
179
  if (usesGraph(manifest))
145
180
  validateV2Entry({ entry, index, ctx });
146
181
  }
182
+ const useTargets = validateSecrets({ manifest, ids, ctx });
147
183
  for (const [index, entry] of manifest.primitives.entries()) {
148
184
  for (const [depIndex, dep] of entry.depends_on.entries()) {
149
185
  if (!ids.has(dep))
150
186
  ctx.addIssue({ code: 'custom', message: `depends_on references unknown primitive id "${dep}"`, path: ['primitives', index, 'depends_on', depIndex] });
151
187
  }
152
- validateUses({ entry, index, ids, ctx });
188
+ validateUses({ entry, index, ids: useTargets, ctx });
153
189
  }
154
190
  const names = new Set();
155
191
  for (const [index, pkg] of (manifest.packages ?? []).entries()) {
@@ -167,7 +203,40 @@ function validateInventory({ manifest, ctx }) {
167
203
  }
168
204
  }
169
205
  }
170
- /** `uses` edges (runtime dependencies) must point at other primitives in this app, once each. */
206
+ /**
207
+ * `secrets` (schema_version 3): ids unique across primitives and secrets, one
208
+ * entry per secret name. Returns every id a `uses` edge may point at.
209
+ */
210
+ function validateSecrets({ manifest, ids, ctx, }) {
211
+ const targets = new Set(ids);
212
+ const lists = [
213
+ { field: 'secrets', what: 'secret', entries: (manifest.secrets ?? []).map((secret) => ({ id: secret.id, name: secret.name })) },
214
+ {
215
+ field: 'service_accounts',
216
+ what: 'service account',
217
+ entries: (manifest.service_accounts ?? []).map((account) => ({ id: account.id, name: account.slug })),
218
+ },
219
+ ];
220
+ for (const { field, what, entries } of lists) {
221
+ if (!manifest[field])
222
+ continue;
223
+ if (manifest.schema_version !== 3) {
224
+ ctx.addIssue({ code: 'custom', message: `${field} require schema_version: 3`, path: [field] });
225
+ continue;
226
+ }
227
+ const names = new Set();
228
+ for (const [index, entry] of entries.entries()) {
229
+ if (targets.has(entry.id))
230
+ ctx.addIssue({ code: 'custom', message: `duplicate primitive or ${what} id "${entry.id}"`, path: [field, index, 'id'] });
231
+ if (names.has(entry.name))
232
+ ctx.addIssue({ code: 'custom', message: `${what} "${entry.name}" is listed twice`, path: [field, index] });
233
+ targets.add(entry.id);
234
+ names.add(entry.name);
235
+ }
236
+ }
237
+ return targets;
238
+ }
239
+ /** `uses` edges (runtime dependencies) must point at other primitives or secrets in this app, once each. */
171
240
  function validateUses({ entry, index, ids, ctx, }) {
172
241
  const seen = new Set();
173
242
  for (const [useIndex, use] of entry.uses.entries()) {
@@ -229,3 +298,18 @@ export function validateManifestGraph(manifest, ctx) {
229
298
  }
230
299
  }
231
300
  }
301
+ const severalAgentsMessage = (id) => `"${id}" deploys several agents; set only: [<agent-id>] so the role reaches exactly one agent`;
302
+ /**
303
+ * An agent member is floor-only for runtime roles (an agent has no roles or
304
+ * capabilities), and the entry must deploy exactly one agent. `only` with
305
+ * several ids is caught here; a directory of several agents without `only`
306
+ * is caught when the deploy resolves which agent the entry deploys.
307
+ */
308
+ function agentIncludeIssue({ entry, include, path, ctx, }) {
309
+ if (include.capability !== undefined || (include.role !== 'end_user' && include.role !== 'invoker')) {
310
+ ctx.addIssue({ code: 'custom', message: 'agent primitives offer only end_user (or invoker) — not roles or capabilities', path });
311
+ }
312
+ else if ((entry?.only?.length ?? 1) !== 1) {
313
+ ctx.addIssue({ code: 'custom', message: severalAgentsMessage(entry?.id ?? ''), path });
314
+ }
315
+ }
@@ -81,7 +81,7 @@ export declare const applicationCapabilitiesSchema: z.ZodRecord<z.ZodString, z.Z
81
81
  * kind offers is checked in manifest-validation.ts; admin and owner never
82
82
  * are — they stay direct grants.
83
83
  */
84
- export declare const COLLABORATOR_TIERS: readonly ["viewer", "reader", "operator", "writer", "editor"];
84
+ export declare const COLLABORATOR_TIERS: readonly ["viewer", "reader", "operator", "writer", "editor", "actor"];
85
85
  export type CollaboratorTier = (typeof COLLABORATOR_TIERS)[number];
86
86
  /**
87
87
  * Application collaborator roles (schema_version 3): bundle the tiers that
@@ -100,10 +100,33 @@ export declare const applicationCollaboratorsSchema: z.ZodObject<{
100
100
  reader: "reader";
101
101
  writer: "writer";
102
102
  operator: "operator";
103
+ actor: "actor";
103
104
  }>;
104
105
  }, z.core.$strict>>>;
105
106
  }, z.core.$strict>>;
106
107
  }, z.core.$strict>;
108
+ /**
109
+ * Managed secrets the app's functions and pipelines read (schema_version 3).
110
+ * Not deployed from here — create and set them with `seq-studio secrets` —
111
+ * but named so collaborator roles can bundle their editor tier and `uses`
112
+ * can point at them. `name` is the secret's name in each environment.
113
+ */
114
+ declare const appSecretSchema: z.ZodObject<{
115
+ id: z.ZodString;
116
+ name: z.ZodString;
117
+ }, z.core.$strict>;
118
+ export type AppSecretEntry = z.infer<typeof appSecretSchema>;
119
+ /**
120
+ * Service accounts the app's members run as (schema_version 3). Not created
121
+ * from here — the account's admins create it in Atlas — but named so
122
+ * collaborator roles can bundle its actor tier (deploy members that run as
123
+ * it) and `uses` can point at it. `slug` is the account's slug here.
124
+ */
125
+ declare const appServiceAccountSchema: z.ZodObject<{
126
+ id: z.ZodString;
127
+ slug: z.ZodString;
128
+ }, z.core.$strict>;
129
+ export type AppServiceAccountEntry = z.infer<typeof appServiceAccountSchema>;
107
130
  export declare const appManifestSchema: z.ZodObject<{
108
131
  schema_version: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>]>;
109
132
  app: z.ZodObject<{
@@ -152,6 +175,14 @@ export declare const appManifestSchema: z.ZodObject<{
152
175
  stop: "stop";
153
176
  }>>;
154
177
  }, z.core.$strict>>;
178
+ secrets: z.ZodOptional<z.ZodArray<z.ZodObject<{
179
+ id: z.ZodString;
180
+ name: z.ZodString;
181
+ }, z.core.$strict>>>;
182
+ service_accounts: z.ZodOptional<z.ZodArray<z.ZodObject<{
183
+ id: z.ZodString;
184
+ slug: z.ZodString;
185
+ }, z.core.$strict>>>;
155
186
  roles: z.ZodOptional<z.ZodObject<{
156
187
  definitions: z.ZodRecord<z.ZodString, z.ZodObject<{
157
188
  description: z.ZodOptional<z.ZodString>;
@@ -175,6 +206,7 @@ export declare const appManifestSchema: z.ZodObject<{
175
206
  reader: "reader";
176
207
  writer: "writer";
177
208
  operator: "operator";
209
+ actor: "actor";
178
210
  }>;
179
211
  }, z.core.$strict>>>;
180
212
  }, z.core.$strict>>;
@@ -134,7 +134,7 @@ export const applicationCapabilitiesSchema = z.record(roleKeySchema, z.object({
134
134
  * kind offers is checked in manifest-validation.ts; admin and owner never
135
135
  * are — they stay direct grants.
136
136
  */
137
- export const COLLABORATOR_TIERS = ['viewer', 'reader', 'operator', 'writer', 'editor'];
137
+ export const COLLABORATOR_TIERS = ['viewer', 'reader', 'operator', 'writer', 'editor', 'actor'];
138
138
  const applicationCollaboratorDefinitionSchema = z
139
139
  .object({
140
140
  description: z.string().max(1024).optional(),
@@ -152,6 +152,30 @@ const applicationCollaboratorDefinitionSchema = z
152
152
  export const applicationCollaboratorsSchema = z
153
153
  .object({ definitions: z.record(roleKeySchema, applicationCollaboratorDefinitionSchema) })
154
154
  .strict();
155
+ /**
156
+ * Managed secrets the app's functions and pipelines read (schema_version 3).
157
+ * Not deployed from here — create and set them with `seq-studio secrets` —
158
+ * but named so collaborator roles can bundle their editor tier and `uses`
159
+ * can point at them. `name` is the secret's name in each environment.
160
+ */
161
+ const appSecretSchema = z
162
+ .object({
163
+ id: z.string().min(1).max(128),
164
+ name: z.string().max(255).regex(/^[A-Z][A-Z0-9_]*$/, 'secret names are UPPER_SNAKE_CASE'),
165
+ })
166
+ .strict();
167
+ /**
168
+ * Service accounts the app's members run as (schema_version 3). Not created
169
+ * from here — the account's admins create it in Atlas — but named so
170
+ * collaborator roles can bundle its actor tier (deploy members that run as
171
+ * it) and `uses` can point at it. `slug` is the account's slug here.
172
+ */
173
+ const appServiceAccountSchema = z
174
+ .object({
175
+ id: z.string().min(1).max(128),
176
+ slug: z.string().min(1).max(100).regex(/^[a-z0-9][a-z0-9-]*$/, 'service account slugs are lowercase kebab-case'),
177
+ })
178
+ .strict();
155
179
  const relativeDirectorySchema = z.string().min(1).refine((path) => path.trim() === path && !path.includes('\\') && !/^[A-Za-z]:/.test(path) &&
156
180
  !/[\x00-\x1f]/.test(path) && path.split('/').every((part) => part !== '' && part !== '.' && part !== '..'), 'path must be a relative directory within the app root');
157
181
  export const appManifestSchema = z
@@ -177,6 +201,8 @@ export const appManifestSchema = z
177
201
  on_error: z.enum(['stop', 'continue']).default('stop'),
178
202
  }).strict()
179
203
  .default({ on_error: 'stop' }),
204
+ secrets: z.array(appSecretSchema).optional(),
205
+ service_accounts: z.array(appServiceAccountSchema).optional(),
180
206
  roles: applicationRolesSchema.optional(),
181
207
  collaborators: applicationCollaboratorsSchema.optional(),
182
208
  capabilities: applicationCapabilitiesSchema.optional(),
@@ -83,6 +83,16 @@ seq-studio doctor -e <environment-name>
83
83
 
84
84
  Run \`pnpm install\` **once from the app root**. Commit the generated root \`pnpm-lock.yaml\`; CI uses \`pnpm install --frozen-lockfile\`. App scaffolding consolidates the standalone templates' install configuration at the root. The root workspace retains the seven-day dependency age gate and explicit build-script allowlist.
85
85
 
86
+ For a fullstack app, scaffold with \`seq-studio init <app> --with artifact --template nextjs\`.
87
+ Its Next.js artifact uses Node.js 24 and a separate install root: run \`pnpm install\`
88
+ inside \`artifact/\` and commit \`artifact/pnpm-lock.yaml\` as well. Keep its generated
89
+ \`lint\`, \`type-check\`, \`test\` and \`build\` scripts. Repository CI runs these checks
90
+ and an SSR/API smoke test on Buildkite before packaging the validated standalone
91
+ output for the managed runtime. Configure registered resource bindings and automatic
92
+ CI in Atlas; \`sequence.app.yml\` supplies the inventory, so \`.seq/ci.json\` is optional.
93
+ Build-time values belong in \`build.public_env\` and must use \`NEXT_PUBLIC_*\` names.
94
+ Server secrets and resource credentials are attached only at runtime.
95
+
86
96
  Use the environment name your administrator supplies. \`local\` means a real Atlas server at \`http://localhost:5001\`, not a standalone Vite server. Login proves identity; resource permissions are still required. ORM and pipeline commands require the matching \`@sequenceholdings/orm\` / \`@sequenceholdings/pipeline-spec\` SDK installed alongside the CLI.
87
97
 
88
98
  ## Shared packages
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sequenceholdings/studio-cli",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "Unified Sequence Studio CLI — `seq-studio init` / `add` / `deploy` (app monorepos), `seq-studio agents`, `seq-studio process` (Lattice), `seq-studio artifact`, `seq-studio functions` / `secrets`, `seq-studio repos`, and `seq-studio auth pat`. Includes Auth0 browser login shared with seqapi.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -38,18 +38,18 @@
38
38
  "dependencies": {
39
39
  "esbuild": "^0.25.0",
40
40
  "js-yaml": "^4.3.2",
41
- "smol-toml": "^1.7.1",
41
+ "smol-toml": "^1.9.0",
42
42
  "tsx": "^4.20.3",
43
43
  "zod": "^4.1.13",
44
- "@sequenceholdings/lattice": "0.1.5",
45
- "@sequenceholdings/artifact-studio": "0.5.0",
46
44
  "@sequenceholdings/agent-spec": "0.1.3",
47
- "@sequenceholdings/managed-functions": "0.3.0",
45
+ "@sequenceholdings/artifact-studio": "0.6.3",
46
+ "@sequenceholdings/lattice": "0.1.5",
47
+ "@sequenceholdings/managed-functions": "0.3.1",
48
48
  "@sequenceholdings/storage": "0.1.0"
49
49
  },
50
50
  "peerDependencies": {
51
- "@sequenceholdings/orm": "2.2.0",
52
- "@sequenceholdings/pipeline-spec": "0.2.0"
51
+ "@sequenceholdings/orm": "2.3.0",
52
+ "@sequenceholdings/pipeline-spec": "0.2.1"
53
53
  },
54
54
  "peerDependenciesMeta": {
55
55
  "@sequenceholdings/orm": {
@@ -64,8 +64,8 @@
64
64
  "@types/node": "^22.0.0",
65
65
  "typescript": "^5.6.0",
66
66
  "vitest": "^4.1.11",
67
- "@sequenceholdings/orm": "2.2.0",
68
- "@sequenceholdings/pipeline-spec": "0.2.0"
67
+ "@sequenceholdings/orm": "2.3.0",
68
+ "@sequenceholdings/pipeline-spec": "0.2.1"
69
69
  },
70
70
  "engines": {
71
71
  "node": ">=20"