@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
@@ -0,0 +1,89 @@
1
+ /**
2
+ * `seq-studio access roles` — create and edit a resource's roles in Atlas.
3
+ *
4
+ * Capabilities are code (declared in the resource's source and published by
5
+ * its deploy); roles are data: they bundle capabilities, live in the Atlas
6
+ * role registry, and are edited here or on the Permissions page. This wraps
7
+ * the registry routes the Permissions page uses, so registry write authority
8
+ * (the resource's capability admins) and DAG validation stay server-side.
9
+ */
10
+ import { deleteJson, getJson, patchJson, postJson } from '../atlas-client.js';
11
+ import { validateCommandInput } from '../command-input.js';
12
+ import { buildContext, clientOptions } from '../functions/commands.js';
13
+ export const ACCESS_ROLES_USAGE = `usage:
14
+ seq-studio access roles list <artifact|function|orm> <resource-id> -e <env>
15
+ seq-studio access roles create <artifact|function|orm> <resource-id> <role-key> -e <env>
16
+ [--grants <capability,...>] [--inherits <role,...>] [--description <text>] [--default]
17
+ seq-studio access roles update <artifact|function|orm> <resource-id> <role-key> -e <env>
18
+ [--grants <capability,...>] [--inherits <role,...>] [--description <text>] [--default | --no-default]
19
+ seq-studio access roles delete <artifact|function|orm> <resource-id> <role-key> -e <env>
20
+
21
+ Roles bundle the capabilities a resource declares in its source; create and edit
22
+ them here, then assign them with seq-studio access grant ... --key <role-key>.
23
+ --grants and --inherits replace the role's whole list on update.
24
+ Editing roles requires capability-admin authority on the resource.
25
+ `;
26
+ const VERBS = new Set(['list', 'create', 'update', 'delete']);
27
+ const HOST_TYPES = new Set(['artifact', 'function', 'orm']);
28
+ function keyList(value) {
29
+ if (typeof value !== 'string')
30
+ return undefined;
31
+ return value.split(',').map((key) => key.trim()).filter(Boolean);
32
+ }
33
+ /** The role fields passed as flags; omitted flags leave the field unchanged on update. */
34
+ function roleFields(args) {
35
+ if (args.flags.default === true && args.flags['no-default'] === true)
36
+ throw new Error('Choose one of --default or --no-default.');
37
+ const grants = keyList(args.flags.grants);
38
+ const inherits = keyList(args.flags.inherits);
39
+ const description = typeof args.flags.description === 'string' ? args.flags.description : undefined;
40
+ const isDefault = args.flags.default === true ? true : args.flags['no-default'] === true ? false : undefined;
41
+ return {
42
+ ...(grants ? { grants } : {}),
43
+ ...(inherits ? { inherits } : {}),
44
+ ...(description !== undefined ? { description } : {}),
45
+ ...(isDefault !== undefined ? { isDefault } : {}),
46
+ };
47
+ }
48
+ /** The request one `access roles` invocation makes. */
49
+ export function rolesRequest(args) {
50
+ const [verb, hostType, hostId, key] = args.positional;
51
+ if (!verb || !VERBS.has(verb))
52
+ throw new Error('Usage: seq-studio access roles <list|create|update|delete> ... See: seq-studio access roles --help');
53
+ const editing = verb === 'create' || verb === 'update';
54
+ validateCommandInput({
55
+ args,
56
+ flags: editing
57
+ ? { grants: 'string', inherits: 'string', description: 'string', default: 'boolean', ...(verb === 'update' ? { 'no-default': 'boolean' } : {}) }
58
+ : {},
59
+ positional: verb === 'list' ? 3 : 4,
60
+ });
61
+ if (!hostType || !HOST_TYPES.has(hostType))
62
+ throw new Error('Resource type must be artifact, function, or orm.');
63
+ if (!hostId?.trim())
64
+ throw new Error('A resource ID is required.');
65
+ const roles = `/api/custom-roles/registry/${encodeURIComponent(`${hostType}_${hostId}`)}/roles`;
66
+ if (verb === 'list')
67
+ return { method: 'GET', path: roles };
68
+ if (!key || !/^[a-z0-9-]{1,64}$/.test(key))
69
+ throw new Error('A role key is 1–64 lowercase letters, digits, and hyphens.');
70
+ const path = `${roles}/${encodeURIComponent(key)}`;
71
+ if (verb === 'delete')
72
+ return { method: 'DELETE', path };
73
+ const body = roleFields(args);
74
+ if (verb === 'create')
75
+ return { method: 'POST', path: roles, body: { key, ...body } };
76
+ if (Object.keys(body).length === 0)
77
+ throw new Error('Pass at least one of --grants, --inherits, --description, --default, or --no-default.');
78
+ return { method: 'PATCH', path, body };
79
+ }
80
+ export async function runAccessRolesCommand(args) {
81
+ const { method, path, body } = rolesRequest(args);
82
+ const request = { ...clientOptions(await buildContext(args)), path };
83
+ const result = method === 'GET' ? await getJson(request)
84
+ : method === 'POST' ? await postJson({ ...request, body })
85
+ : method === 'PATCH' ? await patchJson({ ...request, body })
86
+ : await deleteJson(request);
87
+ console.log(JSON.stringify(result, null, 2));
88
+ return 0;
89
+ }
@@ -0,0 +1,12 @@
1
+ import { type AccessHost } from './host-contract.js';
2
+ export declare function permissionsHost({ name, resourceType, summary, keys, floor, routeId }: {
3
+ name: string;
4
+ resourceType: string;
5
+ summary: string;
6
+ keys: readonly string[];
7
+ floor?: string;
8
+ routeId?: (id: string) => string;
9
+ }): AccessHost;
10
+ export declare const secretHost: AccessHost;
11
+ export declare function gitHost(kind: 'repo' | 'namespace'): AccessHost;
12
+ export declare const workspaceHost: AccessHost;
@@ -0,0 +1,206 @@
1
+ /** Hosts with fixed tiers, where a principal holds one tier per resource. */
2
+ import { resolveRepo } from '@sequenceholdings/artifact-studio/git-service-client';
3
+ import { getJson, putJson, sendJsonOrNoContent } from '../atlas-client.js';
4
+ import { heldTierConflict, requireTier, selectedTier, staticDefinitions, unsupportedPrincipal, } from './host-contract.js';
5
+ import { serviceAccountSubject } from './principal.js';
6
+ function permissionsSubject(principal) {
7
+ if (principal.kind === 'group')
8
+ return { type: 'group', id: principal.id, fga: `group:${principal.id}#member` };
9
+ const id = principal.kind === 'service-account' ? serviceAccountSubject(principal.id) : principal.id;
10
+ return { type: principal.kind === 'service-account' ? 'service_account' : 'user', id, fga: `user:${id}` };
11
+ }
12
+ export function permissionsHost({ name, resourceType, summary, keys, floor, routeId }) {
13
+ const path = (id) => `/api/authz/permissions/${resourceType}/${encodeURIComponent(routeId ? routeId(id) : id)}`;
14
+ const read = (call) => getJson({ ...call.request, path: path(call.id) });
15
+ const host = {
16
+ name,
17
+ summary,
18
+ floor,
19
+ keys,
20
+ singleTier: true,
21
+ principals: ['user', 'group', 'service-account'],
22
+ definitions: async () => staticDefinitions(host),
23
+ list: async (call) => {
24
+ const tier = selectedTier(host, call.selection);
25
+ const current = await read(call);
26
+ if (!tier)
27
+ return current;
28
+ const holders = new Set((current.directGrants?.tuples ?? []).filter((tuple) => tuple.relation === tier).map((tuple) => tuple.subject));
29
+ return {
30
+ ...current,
31
+ principals: (current.principals ?? []).filter((principal) => holders.has(principal.type === 'group' ? `group:${principal.id}#member` : `user:${principal.id}`)),
32
+ };
33
+ },
34
+ grant: async (call) => {
35
+ const tier = requireTier(host, call.change);
36
+ if (!host.principals.includes(call.change.principal.kind))
37
+ throw unsupportedPrincipal(host, call.change.principal.kind);
38
+ const subject = permissionsSubject(call.change.principal);
39
+ const current = await read(call);
40
+ const held = heldTiers({ current, subject: subject.fga, keys });
41
+ if (held.includes(tier) && held.length === 1)
42
+ return { ok: true, unchanged: true };
43
+ const others = held.filter((role) => role !== tier);
44
+ if (others.length > 0 && !call.change.replace)
45
+ throw heldTierConflict({ host, current: others.join(', '), tier });
46
+ const principal = { type: subject.type, id: subject.id, role: tier };
47
+ return putJson({
48
+ ...call.request,
49
+ path: path(call.id),
50
+ // Echo the public set so older servers (which default it to []) never
51
+ // unpublish the resource as a side effect of a named grant.
52
+ body: { ...(held.length > 0 ? { updated: [principal] } : { added: [principal] }), publicRelations: current.publicRelations ?? [] },
53
+ });
54
+ },
55
+ revoke: async (call) => {
56
+ const tier = requireTier(host, call.change);
57
+ const subject = permissionsSubject(call.change.principal);
58
+ const current = await read(call);
59
+ const held = heldTiers({ current, subject: subject.fga, keys });
60
+ if (!held.includes(tier))
61
+ throw new Error(`This principal holds no direct ${tier} grant on this ${name}${held.length ? ` (it holds ${held.join(', ')})` : ''}.`);
62
+ const remaining = held.filter((role) => role !== tier);
63
+ if (remaining.length > 1) {
64
+ throw new Error(`This principal holds ${held.join(', ')}; revoke would need to keep several tiers. Change it in the Permissions page.`);
65
+ }
66
+ const body = remaining.length === 1
67
+ ? { updated: [{ type: subject.type, id: subject.id, role: remaining[0] }] }
68
+ : { removed: [{ type: subject.type, id: subject.id }] };
69
+ return putJson({ ...call.request, path: path(call.id), body: { ...body, publicRelations: current.publicRelations ?? [] } });
70
+ },
71
+ };
72
+ return host;
73
+ }
74
+ function heldTiers({ current, subject, keys }) {
75
+ return [...new Set((current.directGrants?.tuples ?? [])
76
+ .filter((tuple) => tuple.subject === subject && keys.includes(tuple.relation))
77
+ .map((tuple) => tuple.relation))];
78
+ }
79
+ function principalRowsHost({ name, summary, keys, floor, basePath, toAccess, fromAccess, rowsKey }) {
80
+ const readRows = (body) => (body[rowsKey] ?? []);
81
+ const target = (principal) => {
82
+ if (principal.kind === 'organization')
83
+ throw unsupportedPrincipal(host, principal.kind);
84
+ return principal.kind === 'group'
85
+ ? { principalType: 'role', principalId: principal.id }
86
+ : { principalType: 'user', principalId: principal.kind === 'service-account' ? serviceAccountSubject(principal.id) : principal.id };
87
+ };
88
+ const currentTier = async (call, principal) => {
89
+ const rows = readRows(await getJson({ ...call.request, path: await basePath(call) }));
90
+ const row = rows.find((entry) => entry.principalType === principal.principalType && entry.principalId === principal.principalId);
91
+ return row ? fromAccess(row.access) : undefined;
92
+ };
93
+ const host = {
94
+ name,
95
+ summary,
96
+ floor,
97
+ keys,
98
+ singleTier: true,
99
+ principals: ['user', 'group', 'service-account'],
100
+ definitions: async () => staticDefinitions(host),
101
+ list: async (call) => {
102
+ const tier = selectedTier(host, call.selection);
103
+ const body = await getJson({ ...call.request, path: await basePath(call) });
104
+ if (!tier)
105
+ return body;
106
+ return { ...body, [rowsKey]: readRows(body).filter((row) => fromAccess(row.access) === tier) };
107
+ },
108
+ grant: async (call) => {
109
+ const tier = requireTier(host, call.change);
110
+ const principal = target(call.change.principal);
111
+ const current = await currentTier(call, principal);
112
+ if (current === tier)
113
+ return { ok: true, unchanged: true };
114
+ if (current && !call.change.replace)
115
+ throw heldTierConflict({ host, current, tier });
116
+ const result = await sendJsonOrNoContent({ ...call.request, method: 'POST', path: await basePath(call), body: { ...principal, access: toAccess(tier) } });
117
+ return result ?? { ok: true };
118
+ },
119
+ revoke: async (call) => {
120
+ const tier = requireTier(host, call.change);
121
+ const principal = target(call.change.principal);
122
+ const current = await currentTier(call, principal);
123
+ if (current !== tier)
124
+ throw new Error(`This principal holds no direct ${tier} grant on this ${name}${current ? ` (it holds ${current})` : ''}.`);
125
+ const result = await sendJsonOrNoContent({ ...call.request, method: 'DELETE', path: await basePath(call), body: principal });
126
+ return result ?? { ok: true };
127
+ },
128
+ };
129
+ return host;
130
+ }
131
+ const identity = (value) => value;
132
+ export const secretHost = principalRowsHost({
133
+ name: 'secret',
134
+ summary: 'Managed secret (id from seq-studio secrets list); user = runtime read via attachment',
135
+ keys: ['user', 'editor', 'admin'],
136
+ floor: 'user',
137
+ basePath: async ({ id }) => `/api/managed-secrets/${encodeURIComponent(id)}/principals`,
138
+ toAccess: identity,
139
+ fromAccess: identity,
140
+ rowsKey: 'principals',
141
+ });
142
+ const GIT_TIER_TO_ACCESS = { reader: 'read', writer: 'write', merger: 'merge', admin: 'admin' };
143
+ const GIT_ACCESS_TO_TIER = Object.fromEntries(Object.entries(GIT_TIER_TO_ACCESS).map(([tier, access]) => [access, tier]));
144
+ async function repoId(call) {
145
+ const parts = call.id.split('/');
146
+ if (parts.length === 1)
147
+ return call.id;
148
+ if (parts.length !== 2 || !parts[0] || !parts[1])
149
+ throw new Error('Repos are <namespace>/<name> or a repo id.');
150
+ const resolved = await resolveRepo({ ...call.request, namespace: parts[0], name: parts[1] });
151
+ return resolved.id;
152
+ }
153
+ export function gitHost(kind) {
154
+ return principalRowsHost({
155
+ name: kind,
156
+ summary: kind === 'repo' ? 'Git-service repository (<namespace>/<name> or id)' : 'Git-service namespace (slug); tiers cascade to its repos',
157
+ keys: ['reader', 'writer', 'merger', 'admin'],
158
+ basePath: async (call) => kind === 'repo'
159
+ ? `/api/git-service/repos/${encodeURIComponent(await repoId(call))}/principals`
160
+ : `/api/git-service/namespaces/${encodeURIComponent(call.id)}/principals`,
161
+ toAccess: (tier) => GIT_TIER_TO_ACCESS[tier] ?? tier,
162
+ fromAccess: (access) => GIT_ACCESS_TO_TIER[access] ?? access,
163
+ rowsKey: 'items',
164
+ });
165
+ }
166
+ function storagePrincipal(principal) {
167
+ return { type: principal.kind === 'service-account' ? 'service_account' : principal.kind, id: principal.id };
168
+ }
169
+ export const workspaceHost = {
170
+ name: 'workspace',
171
+ summary: 'Workspaces V2 storage workspace (use seq-studio storage access for folders/files)',
172
+ keys: ['viewer', 'editor', 'admin'],
173
+ singleTier: true,
174
+ principals: ['user', 'group', 'organization', 'service-account'],
175
+ definitions: async () => staticDefinitions(workspaceHost),
176
+ list: async (call) => {
177
+ const tier = selectedTier(workspaceHost, call.selection);
178
+ const access = await getJson({ ...call.request, path: storagePath(call) });
179
+ return tier ? { ...access, grants: access.grants.filter((grant) => grant.role === tier) } : access;
180
+ },
181
+ grant: async (call) => {
182
+ const tier = requireTier(workspaceHost, call.change);
183
+ const principal = storagePrincipal(call.change.principal);
184
+ const access = await getJson({ ...call.request, path: storagePath(call) });
185
+ const existing = access.grants.find((grant) => grant.type === principal.type && grant.id === principal.id);
186
+ if (existing?.role === tier)
187
+ return { ok: true, unchanged: true };
188
+ if (existing && !call.change.replace)
189
+ throw heldTierConflict({ host: workspaceHost, current: existing.role, tier });
190
+ const grants = [...access.grants.filter((grant) => grant !== existing), { ...principal, role: tier }];
191
+ return putJson({ ...call.request, path: storagePath(call), body: { expectedRevision: access.revision, restricted: access.restricted, grants } });
192
+ },
193
+ revoke: async (call) => {
194
+ const tier = requireTier(workspaceHost, call.change);
195
+ const principal = storagePrincipal(call.change.principal);
196
+ const access = await getJson({ ...call.request, path: storagePath(call) });
197
+ const existing = access.grants.find((grant) => grant.type === principal.type && grant.id === principal.id);
198
+ if (existing?.role !== tier)
199
+ throw new Error(`This principal holds no direct ${tier} grant on this workspace${existing ? ` (it holds ${existing.role})` : ''}.`);
200
+ const grants = access.grants.filter((grant) => grant !== existing);
201
+ return putJson({ ...call.request, path: storagePath(call), body: { expectedRevision: access.revision, restricted: access.restricted, grants } });
202
+ },
203
+ };
204
+ function storagePath({ id }) {
205
+ return `/api/storage/workspaces/${encodeURIComponent(id)}/access`;
206
+ }
@@ -20,5 +20,5 @@ export declare function agentsApplyCommand(args: ParsedArgs, { mode }?: {
20
20
  }): Promise<number>;
21
21
  export declare function agentsListCommand(args: ParsedArgs): Promise<number>;
22
22
  export declare function agentsShowCommand(args: ParsedArgs): Promise<number>;
23
- export declare const AGENTS_USAGE = "usage:\n seq-studio agents init <dir> scaffold a typed agent\n seq-studio agents validate [--dir d] [--target app] [--only ids] offline compile + validation\n seq-studio agents bundle --out <file> [--dir d] [--target app] [--only ids] offline deploy body { definitions, bundleHash }\n seq-studio agents plan [--dir d] [-e <env>] [--only ids] [--managed] offline bundle plan or live diff\n seq-studio agents apply [--dir d] -e <env> [--only ids] [--yes] [--managed] apply creates/updates; never deletes\n seq-studio agents list -e <env> list visible agents\n seq-studio agents show <id> -e <env> show one agent\n seq-studio agents voice help internal Voice authoring/publication\n\n plan and apply deploy configuration only, as you: a new agent needs Can\n create on Agent Builder, an existing one needs editor, and access stays\n whatever Agent Builder or the API set. --managed is Sequence's code-managed\n path, where the definition also owns access; it is limited to Sequence staff.\n\n Source: local --dir (default .), --repo agents/<name>, or --git-url <url>.\n Use --ref for remote sources. --target selects the deployment APP_ENV when it\n differs from the CLI environment alias (notably OpCo registrations). --only\n accepts a comma-separated list of agent IDs after environment selection.\n";
23
+ export declare const AGENTS_USAGE = "usage:\n seq-studio agents init <dir> [--repo <ns>/<name>] scaffold a typed agent (--repo: into a git-service repo)\n seq-studio agents validate [--dir d] [--target app] [--only ids] offline compile + validation\n seq-studio agents bundle --out <file> [--dir d] [--target app] [--only ids] offline deploy body { definitions, bundleHash }\n seq-studio agents plan [--dir d] [-e <env>] [--only ids] [--managed] [--check-execution] offline bundle plan or live diff\n seq-studio agents apply [--dir d] -e <env> [--only ids] [--yes] [--managed] [--check-execution] apply creates/updates; never deletes\n seq-studio agents list -e <env> list visible agents\n seq-studio agents show <id> -e <env> show one agent\n seq-studio agents voice help internal Voice authoring/publication\n\n plan and apply deploy configuration only, as you: a new agent needs Can\n create on Agent Builder, an existing one needs editor, and access stays\n whatever Agent Builder or the API set. --managed is Sequence's code-managed\n path, where the definition also owns access; it is limited to Sequence staff.\n\n --check-execution requires -e, CONFIG mode and at most 20 existing agents in\n one whole bundle. It checks proposed pinned-execution eligibility before\n apply writes; it is point-in-time and grants no access or future identity.\n Unknown checked routes or missing acknowledgement fail without fallback.\n\n Source: local --dir (default .), --repo agents/<name>, or --git-url <url>.\n Use --ref for remote sources. --target selects the deployment APP_ENV when it\n differs from the CLI environment alias (notably OpCo registrations). --only\n accepts a comma-separated list of agent IDs after environment selection.\n\n Init into a repo: --repo <ns>/<name> on an init command creates that platform\n git-service repo if missing (same name rules as repos create), then clones it\n into <dir> and scaffolds there, or, when <dir> is inside a Git checkout, sets\n it as that checkout's origin (a different existing origin is refused). It\n needs -e <env>, or an agent sandbox. Nothing is committed or pushed; the\n command prints the git add, commit, and push to run.\n";
24
24
  export declare function runAgentsCommand(sub: string | undefined, args: ParsedArgs): Promise<number>;
@@ -1,5 +1,6 @@
1
1
  import { getJson, postJson } from '../atlas-client.js';
2
2
  import { readConfig } from '../config.js';
3
+ import { INIT_INTO_REPO_HELP } from '../command-help.js';
3
4
  import { wantsHelp } from '../command-input.js';
4
5
  import { applyInChunks } from './apply-chunks.js';
5
6
  import { confirmYes } from '../prompt.js';
@@ -13,6 +14,36 @@ const DEPLOY_ROUTES = {
13
14
  managed: { plan: '/api/agents/deploy/plan', apply: '/api/agents/deploy/apply' },
14
15
  config: { plan: '/api/agents/deploy/config/plan', apply: '/api/agents/deploy/config/apply' },
15
16
  };
17
+ const CHECKED_CONFIG_ROUTES = {
18
+ plan: '/api/agents/deploy/config/execution/plan', apply: '/api/agents/deploy/config/execution/apply',
19
+ };
20
+ function executionCheckRequested({ args, mode }) {
21
+ if (!Object.prototype.hasOwnProperty.call(args.flags, 'check-execution'))
22
+ return false;
23
+ const values = [...(args.repeatedFlags?.['check-execution'] ?? []), args.flags['check-execution']];
24
+ if (values.some(value => value !== true && value !== 'true')) {
25
+ throw new Error('Use the bare --check-execution flag (or --check-execution=true); other values cannot select unchecked deployment');
26
+ }
27
+ if (mode !== 'config' || requestedDeployMode(args) !== 'config')
28
+ throw new Error('--check-execution supports CONFIG deployment only; remove --managed');
29
+ if (!requestedEnvironment(args))
30
+ throw new Error('--check-execution requires an explicit environment (-e <env>)');
31
+ return true;
32
+ }
33
+ function requireCheckedBundleBudget({ count }) {
34
+ if (count > 20)
35
+ throw new Error('--check-execution accepts at most 20 agents in one whole bundle; select a smaller bundle');
36
+ }
37
+ /** A response cannot silently downgrade a checked operation on an older/mixed backend. */
38
+ function requireExecutionReadiness({ response, ids }) {
39
+ const ack = response && typeof response === 'object' ? Reflect.get(response, 'executionReadiness') : undefined;
40
+ const checked = ack && typeof ack === 'object' ? Reflect.get(ack, 'checked') : undefined;
41
+ const returnedIds = ack && typeof ack === 'object' ? Reflect.get(ack, 'agentIds') : undefined;
42
+ if (checked !== true || !Array.isArray(returnedIds) || returnedIds.some(id => typeof id !== 'string')
43
+ || JSON.stringify([...returnedIds].sort()) !== JSON.stringify([...ids].sort())) {
44
+ throw new Error('Backend did not acknowledge execution readiness for the complete selected bundle; no unchecked fallback is allowed');
45
+ }
46
+ }
16
47
  /** Config deploys by default; `--managed` selects Sequence's code-managed path. */
17
48
  function requestedDeployMode(args) {
18
49
  return flagBool(args.flags, 'managed') ? 'managed' : 'config';
@@ -70,11 +101,12 @@ function printPlan(plan) {
70
101
  const fields = entry.changedFields?.length
71
102
  ? `: ${entry.changedFields.join(', ')}`
72
103
  : '';
73
- console.log(` ${marker} ${entry.name} (${entry.id}) ${entry.action}${fields}`);
104
+ console.log(` ${marker} ${entry.name ?? entry.id} (${entry.id}) ${entry.action}${fields}`);
74
105
  }
75
106
  console.log(`${LOG} plan: ${plan.summary.creates} create, ${plan.summary.updates} update, ${plan.summary.unchanged} unchanged`);
76
107
  }
77
108
  export async function agentsPlanCommand(args) {
109
+ const checkExecution = executionCheckRequested({ args, mode: requestedDeployMode(args) });
78
110
  const environment = requestedEnvironment(args);
79
111
  if (!environment) {
80
112
  const { source } = await materialize({ args, requireEnvironment: false });
@@ -105,16 +137,22 @@ export async function agentsPlanCommand(args) {
105
137
  throw new Error('Missing deployment context');
106
138
  try {
107
139
  const bundle = await deploymentBundle({ args, source, context });
140
+ if (checkExecution)
141
+ requireCheckedBundleBudget({ count: bundle.definitions.length });
108
142
  const plan = await postJson({
109
143
  ...clientOptions(context),
110
- path: DEPLOY_ROUTES[requestedDeployMode(args)].plan,
144
+ path: (checkExecution ? CHECKED_CONFIG_ROUTES : DEPLOY_ROUTES[requestedDeployMode(args)]).plan,
111
145
  body: {
112
146
  definitions: bundle.definitions,
113
147
  bundleHash: bundle.hash,
114
148
  source: source.provenance.gitCommit ?? 'local',
115
149
  },
116
150
  });
151
+ if (checkExecution)
152
+ requireExecutionReadiness({ response: plan, ids: bundle.definitions.map(({ id }) => id) });
117
153
  printPlan(plan);
154
+ if (checkExecution)
155
+ console.log(`${LOG} execution readiness checked for this proposed configuration at this time; admission still rechecks source and access`);
118
156
  return 0;
119
157
  }
120
158
  finally {
@@ -122,7 +160,8 @@ export async function agentsPlanCommand(args) {
122
160
  }
123
161
  }
124
162
  export async function agentsApplyCommand(args, { mode = requestedDeployMode(args) } = {}) {
125
- const routes = DEPLOY_ROUTES[mode];
163
+ const checkExecution = executionCheckRequested({ args, mode });
164
+ const routes = checkExecution ? CHECKED_CONFIG_ROUTES : DEPLOY_ROUTES[mode];
126
165
  const { source, context } = await materialize({
127
166
  args,
128
167
  requireEnvironment: true,
@@ -131,6 +170,8 @@ export async function agentsApplyCommand(args, { mode = requestedDeployMode(args
131
170
  throw new Error('Missing deployment context');
132
171
  try {
133
172
  const bundle = await deploymentBundle({ args, source, context });
173
+ if (checkExecution)
174
+ requireCheckedBundleBudget({ count: bundle.definitions.length });
134
175
  const plan = await postJson({
135
176
  ...clientOptions(context),
136
177
  path: routes.plan,
@@ -140,6 +181,8 @@ export async function agentsApplyCommand(args, { mode = requestedDeployMode(args
140
181
  source: source.provenance.gitCommit ?? 'local',
141
182
  },
142
183
  });
184
+ if (checkExecution)
185
+ requireExecutionReadiness({ response: plan, ids: bundle.definitions.map(({ id }) => id) });
143
186
  printPlan(plan);
144
187
  const preview = [
145
188
  `${LOG} apply ${bundle.definitions.length} agent definitions to ${context.env.name}`,
@@ -150,15 +193,26 @@ export async function agentsApplyCommand(args, { mode = requestedDeployMode(args
150
193
  if (!(await confirmYes({ preview, confirmed: flagBool(args.flags, 'yes') }))) {
151
194
  return 1;
152
195
  }
153
- const summary = await applyInChunks({
154
- context,
155
- definitions: bundle.definitions,
156
- source: source.provenance.gitCommit ?? 'local',
157
- path: routes.apply,
158
- // The server checks a config deploy as one bundle (agents it creates may
159
- // name each other), so it must arrive whole, as plan saw it.
160
- ...(mode === 'config' ? { chunkSize: Math.max(bundle.definitions.length, 1) } : {}),
161
- });
196
+ let summary;
197
+ if (checkExecution) {
198
+ // Dedicated checked apply repeats readiness before writes; never split or use the ordinary endpoint.
199
+ const result = await postJson({
200
+ ...clientOptions(context), path: routes.apply,
201
+ body: { definitions: bundle.definitions, bundleHash: bundle.hash, source: source.provenance.gitCommit ?? 'local' },
202
+ });
203
+ requireExecutionReadiness({ response: result, ids: bundle.definitions.map(({ id }) => id) });
204
+ summary = result.summary;
205
+ }
206
+ else {
207
+ summary = await applyInChunks({
208
+ context,
209
+ definitions: bundle.definitions,
210
+ source: source.provenance.gitCommit ?? 'local',
211
+ path: routes.apply,
212
+ // A normal CONFIG deploy retains its existing whole-bundle behavior.
213
+ ...(mode === 'config' ? { chunkSize: Math.max(bundle.definitions.length, 1) } : {}),
214
+ });
215
+ }
162
216
  console.log(`${LOG} applied: ${summary.created} created, ${summary.updated} updated, ${summary.unchanged} unchanged`);
163
217
  return 0;
164
218
  }
@@ -192,11 +246,11 @@ export async function agentsShowCommand(args) {
192
246
  return 0;
193
247
  }
194
248
  export const AGENTS_USAGE = `usage:
195
- seq-studio agents init <dir> scaffold a typed agent
249
+ seq-studio agents init <dir> [--repo <ns>/<name>] scaffold a typed agent (--repo: into a git-service repo)
196
250
  seq-studio agents validate [--dir d] [--target app] [--only ids] offline compile + validation
197
251
  seq-studio agents bundle --out <file> [--dir d] [--target app] [--only ids] offline deploy body { definitions, bundleHash }
198
- seq-studio agents plan [--dir d] [-e <env>] [--only ids] [--managed] offline bundle plan or live diff
199
- seq-studio agents apply [--dir d] -e <env> [--only ids] [--yes] [--managed] apply creates/updates; never deletes
252
+ seq-studio agents plan [--dir d] [-e <env>] [--only ids] [--managed] [--check-execution] offline bundle plan or live diff
253
+ seq-studio agents apply [--dir d] -e <env> [--only ids] [--yes] [--managed] [--check-execution] apply creates/updates; never deletes
200
254
  seq-studio agents list -e <env> list visible agents
201
255
  seq-studio agents show <id> -e <env> show one agent
202
256
  seq-studio agents voice help internal Voice authoring/publication
@@ -206,11 +260,17 @@ export const AGENTS_USAGE = `usage:
206
260
  whatever Agent Builder or the API set. --managed is Sequence's code-managed
207
261
  path, where the definition also owns access; it is limited to Sequence staff.
208
262
 
263
+ --check-execution requires -e, CONFIG mode and at most 20 existing agents in
264
+ one whole bundle. It checks proposed pinned-execution eligibility before
265
+ apply writes; it is point-in-time and grants no access or future identity.
266
+ Unknown checked routes or missing acknowledgement fail without fallback.
267
+
209
268
  Source: local --dir (default .), --repo agents/<name>, or --git-url <url>.
210
269
  Use --ref for remote sources. --target selects the deployment APP_ENV when it
211
270
  differs from the CLI environment alias (notably OpCo registrations). --only
212
271
  accepts a comma-separated list of agent IDs after environment selection.
213
- `;
272
+
273
+ ${INIT_INTO_REPO_HELP}`;
214
274
  export async function runAgentsCommand(sub, args) {
215
275
  try {
216
276
  // `agents <sub> --help` prints help instead of running the subcommand.
@@ -2,6 +2,7 @@ import { randomBytes } from 'node:crypto';
2
2
  import { existsSync } from 'node:fs';
3
3
  import { mkdir, writeFile } from 'node:fs/promises';
4
4
  import { basename, join, resolve } from 'node:path';
5
+ import { RECOMMENDED_AGENT_MODEL } from '@sequenceholdings/agent-spec';
5
6
  import { currentVersion } from '../update-check.js';
6
7
  import { FIRST_PARTY_RELEASE_AGE_EXCLUDE } from '../release-age.js';
7
8
  import { writeScaffoldGuidance } from '../scaffold-guidance.js';
@@ -12,8 +13,8 @@ export const agent = defineAgent({
12
13
  id: '${id}',
13
14
  name: '${name}',
14
15
  model: {
15
- provider: 'anthropic',
16
- name: 'claude-sonnet-4-6',
16
+ provider: '${RECOMMENDED_AGENT_MODEL.provider}',
17
+ name: '${RECOMMENDED_AGENT_MODEL.name}',
17
18
  },
18
19
  systemPrompt: 'Describe the agent role and operating instructions.',
19
20
  })
@@ -21,9 +22,13 @@ export const agent = defineAgent({
21
22
  export async function agentsInitCommand(args) {
22
23
  const target = args.positional[0];
23
24
  if (!target) {
24
- console.error('usage: seq-studio agents init <dir>');
25
+ console.error('usage: seq-studio agents init <dir> [--repo <ns>/<name> -e <env>]');
25
26
  return 1;
26
27
  }
28
+ if (args.flags.repo !== undefined) {
29
+ const { runInitWithRepo, withoutRepoFlag } = await import('../repos/init-repo.js');
30
+ return runInitWithRepo({ args, target, scaffold: () => agentsInitCommand(withoutRepoFlag(args)) });
31
+ }
27
32
  const directory = resolve(target);
28
33
  const file = join(directory, 'agent.ts');
29
34
  if (existsSync(file)) {
@@ -7,7 +7,9 @@
7
7
  import type { ParsedArgs } from '../process/commands.js';
8
8
  export declare const APP_INIT_USAGE: string;
9
9
  export declare const APP_ADD_USAGE: string;
10
- export declare const APP_DEPLOY_USAGE = "usage:\n seq-studio deploy -e <env> [options]\n\n Requires a platform repository clone with an adopted identity and a matching\n .seq/identity.json committed on the selected server. Checked before any\n primitive runs, including --dry-run; there is no legacy bypass.\n\n Deploy the app declared in sequence.app.yml. Versions 2 and 3 use\n depends_on prerequisites; deploy.order optionally orders ready primitives.\n Runs each kind's existing command:\n orm \u2192 seq-studio orm apply <path> -e <env>\n function \u2192 seq-studio functions deploy --dir <path> -e <env> [--yes]\n agent \u2192 seq-studio agents apply --dir <path> -e <env> [--yes], config-only (access stays in Atlas)\n process \u2192 seq-studio process apply --dir <path> -e <env>\n pipeline \u2192 seq-studio pipeline deploy --repo <repo> --ref <ref> -e <env>\n artifact \u2192 seq-studio artifact deploy <path> -e <env>\n\n Options:\n -e, --env <name> target environment (required)\n --dir <path> app root (default: cwd; must contain sequence.app.yml)\n --only <id1,id2> deploy these ids and their prerequisites (v2)\n --yes non-interactive (forwarded to primitive commands)\n --dry-run validate/compile selected sources without deploying (v2)\n --approved-by <sub> recorded caller approval for protected pipeline targets\n --wait-timeout <d> pipeline polling timeout, e.g. 10m or 2h\n\n Examples:\n seq-studio deploy -e staging --yes\n seq-studio deploy -e local --only get-pokemon --yes\n seq-studio deploy --dir ./pokedex -e staging --dry-run\n\n Run from the app root (directory with sequence.app.yml), or pass --dir.\n Version 1 manifests keep their existing ordering and exact --only behavior.\n Pipelines require repo and ref in their manifest entry.\n ORM namespaces require generated code and a reviewed migration ledger:\n seq-studio orm generate <path> && seq-studio orm diff <path>\n Commit generated migrations before the first deployment and schema changes.\n Repository admission reads the remote receipt at HEAD; all dry-runs need\n network/auth. Version 1 dry-run only lists after that check.\n A dry-run never opens a browser login: sign in beforehand. It warns,\n rather than fails, when the\n artifact source is not committed and clean on main.\n Version 2 writes the result to .sequence/deployments/<environment>.json.\n";
10
+ export declare const APP_DEPLOY_USAGE = "usage:\n seq-studio deploy -e <env> [options]\n\n Requires a platform repository clone with an adopted identity and a matching\n .seq/identity.json committed on the selected server. Checked before any\n primitive runs, including --dry-run; there is no legacy bypass.\n\n Deploy the app declared in sequence.app.yml. Versions 2 and 3 use\n depends_on prerequisites; deploy.order optionally orders ready primitives.\n Runs each kind's existing command:\n orm \u2192 seq-studio orm apply <path> -e <env>\n function \u2192 seq-studio functions deploy --dir <path> -e <env> [--yes]\n agent \u2192 seq-studio agents apply --dir <path> -e <env> [--yes], config-only (access stays in Atlas)\n process \u2192 seq-studio process apply --dir <path> -e <env>\n pipeline \u2192 seq-studio pipeline deploy --repo <repo> --ref <ref> -e <env>\n artifact \u2192 seq-studio artifact deploy <path> -e <env>\n\n Options:\n -e, --env <name> target environment (required)\n --dir <path> app root (default: cwd; must contain sequence.app.yml)\n --only <id1,id2> deploy these ids and their prerequisites (v2)\n --yes non-interactive (forwarded to primitive commands)\n --dry-run validate/compile selected sources without deploying (v2)\n --approved-by <sub> recorded caller approval for protected pipeline targets\n --wait-timeout <d> pipeline polling timeout, e.g. 10m or 2h\n\n Examples:\n seq-studio deploy -e staging --yes\n seq-studio deploy -e local --only get-pokemon --yes\n seq-studio deploy --dir ./pokedex -e staging --dry-run\n\n Run from the app root (directory with sequence.app.yml), or pass --dir.\n Version 1 manifests keep their existing ordering and exact --only behavior.\n Pipelines require repo and ref in their manifest entry.\n ORM namespaces require generated code and a reviewed migration ledger:\n seq-studio orm generate <path> && seq-studio orm diff <path>\n Commit generated migrations before the first deployment and schema changes.\n Repository admission reads the remote receipt at HEAD; all dry-runs need\n network/auth. Version 1 dry-run only lists after that check.\n For offline manifest, graph, path, and member checks before adoption, use\n `seq-studio validate`.\n A dry-run never opens a browser login: sign in beforehand. It warns,\n rather than fails, when the\n artifact source is not committed and clean on main.\n Version 2 writes the result to .sequence/deployments/<environment>.json.\n";
11
+ export declare const APP_VALIDATE_USAGE = "usage:\n seq-studio validate [--dir <path>] [--json]\n\n Validate sequence.app.yml, its dependency graph, and primitive directories\n locally. List resolved Application members, including existing process refs.\n No environment, login, repository adoption, or network access is required.\n This checks local structure only; it does not validate remote member existence,\n primitive-specific source, or authorize deployment. Deploy still requires a\n matching repository identity receipt.\n\n Options:\n --dir <path> app root (default: cwd)\n --json print structured validation result\n";
12
+ export declare function runAppValidateCommand(args: ParsedArgs): Promise<number>;
11
13
  /**
12
14
  * Hosted Next.js apps deploy only where the deployment runs the Next.js
13
15
  * runtime, which not every deployment does yet; the server then refuses with