@sequenceholdings/studio-cli 0.1.27 → 0.1.28

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 (61) hide show
  1. package/README.md +255 -72
  2. package/dist/app/adapters.d.ts +9 -0
  3. package/dist/app/adapters.js +176 -0
  4. package/dist/app/commands.d.ts +2 -2
  5. package/dist/app/commands.js +98 -22
  6. package/dist/app/deploy.d.ts +9 -10
  7. package/dist/app/deploy.js +83 -141
  8. package/dist/app/graph.d.ts +15 -0
  9. package/dist/app/graph.js +36 -0
  10. package/dist/app/manifest-validation.d.ts +16 -0
  11. package/dist/app/manifest-validation.js +99 -0
  12. package/dist/app/manifest.d.ts +27 -9
  13. package/dist/app/manifest.js +23 -107
  14. package/dist/app/paths.d.ts +14 -0
  15. package/dist/app/paths.js +77 -0
  16. package/dist/app/primitive-scaffold.d.ts +18 -0
  17. package/dist/app/primitive-scaffold.js +136 -0
  18. package/dist/app/readme.d.ts +4 -18
  19. package/dist/app/readme.js +105 -233
  20. package/dist/app/run-deployment.d.ts +8 -0
  21. package/dist/app/run-deployment.js +50 -0
  22. package/dist/app/scaffold-files.d.ts +13 -0
  23. package/dist/app/scaffold-files.js +68 -0
  24. package/dist/app/scaffold.d.ts +11 -3
  25. package/dist/app/scaffold.js +77 -245
  26. package/dist/app/workspace-compile.d.ts +18 -0
  27. package/dist/app/workspace-compile.js +143 -0
  28. package/dist/app/workspace-model.d.ts +70 -0
  29. package/dist/app/workspace-model.js +159 -0
  30. package/dist/app/workspace-scaffold.d.ts +27 -0
  31. package/dist/app/workspace-scaffold.js +126 -0
  32. package/dist/app/workspace.d.ts +14 -0
  33. package/dist/app/workspace.js +147 -0
  34. package/dist/atlas-client.js +28 -6
  35. package/dist/auth-cmds/commands.d.ts +1 -1
  36. package/dist/auth-cmds/commands.js +5 -2
  37. package/dist/functions/commands.js +7 -1
  38. package/dist/functions/manifest.d.ts +18 -0
  39. package/dist/functions/manifest.js +29 -4
  40. package/dist/main.js +8 -3
  41. package/dist/pat-hints.js +1 -0
  42. package/dist/pipeline/commands.js +27 -9
  43. package/dist/pipeline/lifecycle.d.ts +2 -0
  44. package/dist/pipeline/lifecycle.js +91 -11
  45. package/dist/process/build.js +59 -43
  46. package/dist/process/codegen.d.ts +3 -2
  47. package/dist/process/codegen.js +143 -27
  48. package/dist/process/commands.d.ts +2 -0
  49. package/dist/process/commands.js +63 -18
  50. package/dist/process/discover.d.ts +6 -3
  51. package/dist/process/discover.js +11 -3
  52. package/dist/process/lint.d.ts +14 -0
  53. package/dist/process/lint.js +143 -5
  54. package/dist/process/plan-diff.d.ts +8 -0
  55. package/dist/process/plan-diff.js +61 -4
  56. package/dist/process/safety-baseline.d.ts +154 -0
  57. package/dist/process/safety-baseline.js +387 -0
  58. package/dist/process/simulate.js +64 -22
  59. package/dist/repos/commands.d.ts +1 -1
  60. package/dist/repos/commands.js +29 -3
  61. package/package.json +6 -5
@@ -4,66 +4,22 @@
4
4
  * Child primitives keep their own deploy/apply verbs; this command only
5
5
  * orchestrates them. Injectable runners keep unit tests offline.
6
6
  */
7
- import { realpath } from 'node:fs/promises';
8
- import { isAbsolute, relative, resolve, sep } from 'node:path';
7
+ import { rename, rm, writeFile } from 'node:fs/promises';
8
+ import { randomUUID } from 'node:crypto';
9
+ import { existsSync } from 'node:fs';
10
+ import { join, resolve } from 'node:path';
11
+ import { ensureAppOutputDirectory, resolveContainedPrimitivePath } from './paths.js';
12
+ export { resolveContainedPrimitivePath } from './paths.js';
13
+ import { executeDeployment } from './run-deployment.js';
14
+ import { dependencyClosure, dependencyOrder } from './graph.js';
15
+ import { createDefaultDeployers, validateAppPrimitive } from './adapters.js';
16
+ import { prepareAppWorkspace } from './workspace.js';
17
+ import { localGitMetadata } from '@sequenceholdings/artifact-studio/source-resolver';
18
+ import { assertActiveDeployProvenance } from '@sequenceholdings/artifact-studio/active-deploy-policy';
19
+ export { createDefaultDeployers } from './adapters.js';
9
20
  import { defaultDeployOrder, loadAppManifest, } from './manifest.js';
10
21
  const LOG = '[seq-studio]';
11
22
  const APP_MANIFEST_HINT = 'sequence.app.yml';
12
- function assertRelativePrimitivePath(entryPath) {
13
- const segments = entryPath.split('/');
14
- if (entryPath.length === 0 ||
15
- entryPath.trim() !== entryPath ||
16
- isAbsolute(entryPath) ||
17
- entryPath.includes('\\') ||
18
- [...entryPath].some((character) => character.charCodeAt(0) < 0x20) ||
19
- segments.some((segment) => segment.length === 0 || segment === '.' || segment === '..')) {
20
- throw new Error(`${APP_MANIFEST_HINT}: primitive path must be a relative directory within the app root (got ${JSON.stringify(entryPath)})`);
21
- }
22
- }
23
- function assertPathInsideRoot({ rootDir, candidate, entryPath, }) {
24
- const relativePath = relative(rootDir, candidate);
25
- if (relativePath === '..' ||
26
- relativePath.startsWith(`..${sep}`) ||
27
- isAbsolute(relativePath)) {
28
- throw new Error(`${APP_MANIFEST_HINT}: primitive path escapes the app root (got ${JSON.stringify(entryPath)})`);
29
- }
30
- }
31
- /**
32
- * Resolve a manifest primitive path under the app root. Rejects absolute paths,
33
- * lexical traversal, and symlink escapes (via realpath) before a deployer runs.
34
- * Missing targets keep the lexical candidate after a lexical containment check.
35
- */
36
- export async function resolveContainedPrimitivePath({ rootDir, entryPath, }) {
37
- assertRelativePrimitivePath(entryPath);
38
- const root = resolve(rootDir);
39
- let canonicalRoot = root;
40
- try {
41
- canonicalRoot = await realpath(root);
42
- }
43
- catch (error) {
44
- if (error.code !== 'ENOENT')
45
- throw error;
46
- }
47
- // Resolve against the canonical root so macOS /var → /private/var does not
48
- // look like an escape when comparing realpath(root) to a lexical candidate.
49
- const candidate = resolve(canonicalRoot, entryPath);
50
- assertPathInsideRoot({ rootDir: canonicalRoot, candidate, entryPath });
51
- try {
52
- const canonicalCandidate = await realpath(candidate);
53
- assertPathInsideRoot({
54
- rootDir: canonicalRoot,
55
- candidate: canonicalCandidate,
56
- entryPath,
57
- });
58
- return canonicalCandidate;
59
- }
60
- catch (error) {
61
- if (error.code !== 'ENOENT')
62
- throw error;
63
- // Target does not exist yet (dry-run / pre-scaffold) — lexical check stands.
64
- return candidate;
65
- }
66
- }
67
23
  /** Resolve ordered primitive entries for deploy, validating order / --only ids. */
68
24
  export function resolveDeployEntries({ manifest, only, }) {
69
25
  const byId = new Map(manifest.primitives.map((entry) => [entry.id, entry]));
@@ -81,40 +37,32 @@ export function resolveDeployEntries({ manifest, only, }) {
81
37
  if (!orderedIds.includes(entry.id))
82
38
  orderedIds.push(entry.id);
83
39
  }
40
+ const effectiveIds = manifest.schema_version === 2
41
+ ? dependencyOrder({ entries: manifest.primitives, priority: orderedIds })
42
+ : orderedIds;
84
43
  if (only && only.length > 0) {
85
44
  const unknown = only.filter((id) => !byId.has(id));
86
45
  if (unknown.length > 0) {
87
46
  throw new Error(`Unknown primitive id(s) in --only: ${unknown.join(', ')}. Known: ${[...byId.keys()].join(', ')}`);
88
47
  }
89
- const onlySet = new Set(only);
90
- return orderedIds
48
+ const onlySet = manifest.schema_version === 2
49
+ ? dependencyClosure({ entries: manifest.primitives, selected: only })
50
+ : new Set(only);
51
+ return effectiveIds
91
52
  .filter((id) => onlySet.has(id))
92
53
  .map((id) => byId.get(id));
93
54
  }
94
- return orderedIds.map((id) => byId.get(id));
55
+ return effectiveIds.map((id) => byId.get(id));
95
56
  }
96
- export async function createDefaultDeployers() {
97
- const { runOrmCommand } = await import('../orm/delegate.js');
98
- const { functionsDeployCommand } = await import('../functions/commands.js');
99
- const { runArtifactCommand } = await import('../artifact/delegate.js');
100
- return {
101
- async orm({ path, env }) {
102
- return runOrmCommand('apply', [path, '--env', env]);
103
- },
104
- async function({ path, env, yes }) {
105
- return functionsDeployCommand({
106
- positional: [],
107
- flags: {
108
- dir: path,
109
- env,
110
- ...(yes ? { yes: true } : {}),
111
- },
112
- });
113
- },
114
- async artifact({ path, env }) {
115
- return runArtifactCommand('deploy', [path, '--env', env]);
116
- },
117
- };
57
+ function assertAppDeploymentSource({ manifest, options, rootDir, entries }) {
58
+ // Shared sources live outside the UI directory. Check the entire original
59
+ // app before packaging so ignored staging cannot conceal a dirty package.
60
+ if (manifest.schema_version === 2 && options.env !== 'local' && entries.some((entry) => entry.kind === 'artifact')) {
61
+ assertActiveDeployProvenance(localGitMetadata(rootDir));
62
+ }
63
+ if (manifest.schema_version === 2 && manifest.packages?.length && options.env !== 'local' && !options.dryRun && !existsSync(join(rootDir, 'pnpm-lock.yaml'))) {
64
+ throw new Error('App workspace deployment requires a root pnpm-lock.yaml. Run pnpm install at the app root and commit the lockfile before deploying.');
65
+ }
118
66
  }
119
67
  export async function deployApp(options) {
120
68
  const rootDir = resolve(options.rootDir);
@@ -122,6 +70,10 @@ export async function deployApp(options) {
122
70
  const entries = resolveDeployEntries({ manifest, only: options.only });
123
71
  const onError = manifest.deploy.on_error;
124
72
  const deployers = options.deployers ?? (await createDefaultDeployers());
73
+ for (const entry of entries) {
74
+ if (!deployers[entry.kind])
75
+ throw new Error(`No deployer registered for ${entry.kind}`);
76
+ }
125
77
  // Validate every selected path before any deployer runs (including dry-run).
126
78
  const resolvedPaths = new Map();
127
79
  for (const entry of entries) {
@@ -131,67 +83,57 @@ export async function deployApp(options) {
131
83
  for (const entry of entries) {
132
84
  console.log(`${LOG} - ${entry.kind.padEnd(9)} ${entry.id} (${entry.path})`);
133
85
  }
134
- if (options.dryRun) {
135
- console.log(`${LOG} dry-run: no primitives deployed`);
136
- return {
137
- attempted: [],
138
- succeeded: [],
139
- failed: [],
140
- skipped: entries.map((entry) => entry.id),
141
- exitCode: 0,
142
- };
143
- }
144
- const attempted = [];
145
- const succeeded = [];
146
- const failed = [];
147
- const skipped = [];
148
- /** Failed or dependency-skipped ids — blocks transitive `depends_on` edges. */
149
- const unavailable = new Set();
150
- let stop = false;
151
- for (const entry of entries) {
152
- if (stop) {
153
- skipped.push(entry.id);
154
- unavailable.add(entry.id);
155
- console.log(`${LOG} skip ${entry.id} (stopped after earlier failure)`);
156
- continue;
157
- }
158
- const blockedBy = entry.depends_on.filter((id) => unavailable.has(id));
159
- if (blockedBy.length > 0) {
160
- skipped.push(entry.id);
161
- unavailable.add(entry.id);
162
- console.log(`${LOG} skip ${entry.id} (depends on failed/skipped: ${blockedBy.join(', ')})`);
163
- continue;
164
- }
165
- const path = resolvedPaths.get(entry.id);
166
- attempted.push(entry.id);
167
- console.log(`${LOG} → ${entry.kind} ${entry.id}`);
168
- let code;
169
- try {
170
- code = await deployers[entry.kind]({
171
- entry,
172
- path,
173
- env: options.env,
174
- yes: options.yes === true,
175
- });
176
- }
177
- catch (error) {
178
- const message = error instanceof Error ? error.message : String(error);
179
- console.error(`${LOG} ${entry.id} threw: ${message}`);
180
- code = 1;
86
+ assertAppDeploymentSource({ manifest, options, rootDir, entries });
87
+ const provenance = localGitMetadata(rootDir);
88
+ const prepared = manifest.schema_version === 2
89
+ ? await prepareAppWorkspace({ rootDir, manifest, entries, paths: resolvedPaths })
90
+ : { paths: resolvedPaths, cleanup: async () => { } };
91
+ try {
92
+ const pinnedEntries = new Map(entries.map((entry) => [entry.id, entry]));
93
+ const argsFor = (entry) => ({
94
+ entry: pinnedEntries.get(entry.id), path: prepared.paths.get(entry.id), rootDir, env: options.env,
95
+ yes: options.yes === true, approvedBy: options.approvedBy, waitTimeout: options.waitTimeout,
96
+ });
97
+ if (manifest.schema_version === 2) {
98
+ const validate = options.validatePrimitive ?? validateAppPrimitive;
99
+ for (const entry of entries) {
100
+ const pinned = await validate(argsFor(entry));
101
+ if (pinned)
102
+ pinnedEntries.set(entry.id, pinned);
103
+ }
181
104
  }
182
- if (code === 0) {
183
- succeeded.push(entry.id);
184
- console.log(`${LOG} ✓ ${entry.id}`);
105
+ if (options.dryRun) {
106
+ console.log(`${LOG} dry-run: no primitives deployed`);
107
+ return {
108
+ attempted: [],
109
+ succeeded: [],
110
+ failed: [],
111
+ skipped: entries.map((entry) => entry.id),
112
+ exitCode: 0,
113
+ };
185
114
  }
186
- else {
187
- failed.push(entry.id);
188
- unavailable.add(entry.id);
189
- console.error(`${LOG} ✗ ${entry.id} exited ${code}`);
190
- if (onError === 'stop')
191
- stop = true;
115
+ const reportDir = manifest.schema_version === 2
116
+ ? await ensureAppOutputDirectory({ rootDir, entryPath: '.sequence/deployments' }) : undefined;
117
+ const result = await executeDeployment({ entries, onError, deployers, argsFor });
118
+ if (reportDir) {
119
+ result.reportPath = join(reportDir, `${encodeURIComponent(options.env)}.json`);
120
+ const temporaryReport = join(reportDir, `${randomUUID()}.tmp`);
121
+ try {
122
+ await writeFile(temporaryReport, `${JSON.stringify({
123
+ schema_version: 1, app: manifest.app.id, environment: options.env,
124
+ completed_at: new Date().toISOString(), source: provenance,
125
+ packages: manifest.packages ?? [], primitives: [...pinnedEntries.values()], ...result,
126
+ }, null, 2)}\n`, { encoding: 'utf8', flag: 'wx', mode: 0o600 });
127
+ await rename(temporaryReport, result.reportPath);
128
+ }
129
+ finally {
130
+ await rm(temporaryReport, { force: true });
131
+ }
132
+ console.log(`${LOG} deployment report: ${result.reportPath}`);
192
133
  }
134
+ return result;
135
+ }
136
+ finally {
137
+ await prepared.cleanup();
193
138
  }
194
- const exitCode = failed.length > 0 ? 1 : 0;
195
- console.log(`${LOG} deploy finished: ${succeeded.length} ok, ${failed.length} failed, ${skipped.length} skipped`);
196
- return { attempted, succeeded, failed, skipped, exitCode };
197
139
  }
@@ -0,0 +1,15 @@
1
+ /** Stable topological planning. Kind/order priorities never override dependencies. */
2
+ export declare function dependencyOrder({ entries, priority, }: {
3
+ entries: readonly {
4
+ id: string;
5
+ depends_on: readonly string[];
6
+ }[];
7
+ priority: readonly string[];
8
+ }): string[];
9
+ export declare function dependencyClosure({ entries, selected, }: {
10
+ entries: readonly {
11
+ id: string;
12
+ depends_on: readonly string[];
13
+ }[];
14
+ selected: readonly string[];
15
+ }): Set<string>;
@@ -0,0 +1,36 @@
1
+ /** Stable topological planning. Kind/order priorities never override dependencies. */
2
+ export function dependencyOrder({ entries, priority, }) {
3
+ const pending = new Map(entries.map((entry) => [entry.id, entry]));
4
+ const completed = new Set();
5
+ const rank = new Map(priority.map((id, index) => [id, index]));
6
+ const result = [];
7
+ while (pending.size > 0) {
8
+ const ready = [...pending.values()]
9
+ .filter((entry) => entry.depends_on.every((id) => completed.has(id)))
10
+ .sort((a, b) => (rank.get(a.id) ?? Infinity) - (rank.get(b.id) ?? Infinity) || a.id.localeCompare(b.id));
11
+ const next = ready[0];
12
+ if (!next) {
13
+ throw new Error(`Dependency cycle or missing prerequisite involving: ${[...pending.keys()].join(', ')}`);
14
+ }
15
+ pending.delete(next.id);
16
+ completed.add(next.id);
17
+ result.push(next.id);
18
+ }
19
+ return result;
20
+ }
21
+ export function dependencyClosure({ entries, selected, }) {
22
+ const byId = new Map(entries.map((entry) => [entry.id, entry]));
23
+ const result = new Set();
24
+ const pending = [...selected];
25
+ while (pending.length > 0) {
26
+ const id = pending.pop();
27
+ if (result.has(id))
28
+ continue;
29
+ const entry = byId.get(id);
30
+ if (!entry)
31
+ throw new Error(`Unknown primitive id "${id}"`);
32
+ result.add(id);
33
+ pending.push(...entry.depends_on);
34
+ }
35
+ return result;
36
+ }
@@ -0,0 +1,16 @@
1
+ import type { z } from 'zod';
2
+ import type { PrimitiveEntry } from './manifest.js';
3
+ type ManifestGraph = {
4
+ schema_version: 1 | 2;
5
+ primitives: PrimitiveEntry[];
6
+ packages?: {
7
+ name: string;
8
+ path: string;
9
+ }[];
10
+ deploy: {
11
+ order?: string[];
12
+ on_error: 'stop' | 'continue';
13
+ };
14
+ };
15
+ export declare function validateManifestGraph(manifest: ManifestGraph, ctx: z.RefinementCtx): void;
16
+ export {};
@@ -0,0 +1,99 @@
1
+ import { dependencyOrder } from './graph.js';
2
+ function validateV2Entry({ entry, index, ctx }) {
3
+ const issue = (message, field) => ctx.addIssue({
4
+ code: 'custom', message, path: ['primitives', index, ...(field ? [field] : [])],
5
+ });
6
+ if (entry.path.trim() !== entry.path || entry.path.includes('\\') || /^[A-Za-z]:/.test(entry.path) ||
7
+ /[\x00-\x1f]/.test(entry.path) || entry.path.split('/').some((part) => ['', '.', '..'].includes(part))) {
8
+ issue('path must be a relative directory within the app root', 'path');
9
+ }
10
+ if (new Set(entry.depends_on).size !== entry.depends_on.length)
11
+ issue('duplicate depends_on entry', 'depends_on');
12
+ if ((entry.repo !== undefined || entry.ref !== undefined) && entry.kind !== 'pipeline') {
13
+ issue('repo/ref are pipeline release sources; other primitives deploy from their app path');
14
+ }
15
+ if (entry.only && entry.kind !== 'agent' && entry.kind !== 'process') {
16
+ issue('only is supported for agent/process definitions', 'only');
17
+ }
18
+ if (entry.target && entry.kind !== 'agent' && entry.kind !== 'pipeline') {
19
+ issue('target is supported for agent/pipeline deployments', 'target');
20
+ }
21
+ }
22
+ function validateInventory({ manifest, ctx }) {
23
+ const ids = new Set();
24
+ const paths = new Set();
25
+ for (const [index, entry] of manifest.primitives.entries()) {
26
+ if (ids.has(entry.id))
27
+ ctx.addIssue({ code: 'custom', message: `duplicate primitive id "${entry.id}"`, path: ['primitives', index, 'id'] });
28
+ if (paths.has(entry.path))
29
+ ctx.addIssue({ code: 'custom', message: `duplicate primitive path "${entry.path}"`, path: ['primitives', index, 'path'] });
30
+ ids.add(entry.id);
31
+ paths.add(entry.path);
32
+ if (manifest.schema_version === 2)
33
+ validateV2Entry({ entry, index, ctx });
34
+ }
35
+ for (const [index, entry] of manifest.primitives.entries()) {
36
+ for (const [depIndex, dep] of entry.depends_on.entries()) {
37
+ if (!ids.has(dep))
38
+ ctx.addIssue({ code: 'custom', message: `depends_on references unknown primitive id "${dep}"`, path: ['primitives', index, 'depends_on', depIndex] });
39
+ }
40
+ }
41
+ const names = new Set();
42
+ for (const [index, pkg] of (manifest.packages ?? []).entries()) {
43
+ if (names.has(pkg.name) || paths.has(pkg.path))
44
+ ctx.addIssue({ code: 'custom', message: 'duplicate shared package name or path', path: ['packages', index] });
45
+ names.add(pkg.name);
46
+ paths.add(pkg.path);
47
+ }
48
+ if (manifest.schema_version !== 2)
49
+ return;
50
+ const sortedPaths = [...paths].sort();
51
+ for (const [index, path] of sortedPaths.entries()) {
52
+ if (sortedPaths.slice(index + 1).some((other) => other.startsWith(`${path}/`))) {
53
+ ctx.addIssue({ code: 'custom', message: `primitive/package path "${path}" contains another bundle member; use separate source directories`, path: ['primitives'] });
54
+ }
55
+ }
56
+ }
57
+ function orderPriority({ manifest, ctx }) {
58
+ const known = new Set(manifest.primitives.map((entry) => entry.id));
59
+ const order = manifest.deploy.order ?? [];
60
+ const seen = new Set();
61
+ for (const [index, id] of order.entries()) {
62
+ if (seen.has(id))
63
+ ctx.addIssue({ code: 'custom', message: `duplicate deploy.order entry "${id}"`, path: ['deploy', 'order', index] });
64
+ if (!known.has(id))
65
+ ctx.addIssue({ code: 'custom', message: `deploy.order references unknown primitive id "${id}"`, path: ['deploy', 'order', index] });
66
+ seen.add(id);
67
+ }
68
+ if (order.length > 0)
69
+ return [...order, ...manifest.primitives.map((entry) => entry.id).filter((id) => !seen.has(id))];
70
+ // V1's kind ordering is contractual; V2 treats declaration order as a tie breaker here.
71
+ if (manifest.schema_version === 2)
72
+ return manifest.primitives.map((entry) => entry.id);
73
+ const ranks = ['orm', 'function', 'artifact'];
74
+ return [...manifest.primitives].sort((a, b) => ranks.indexOf(a.kind) - ranks.indexOf(b.kind) || a.id.localeCompare(b.id)).map((entry) => entry.id);
75
+ }
76
+ export function validateManifestGraph(manifest, ctx) {
77
+ if (manifest.schema_version === 1 && (manifest.packages !== undefined || manifest.primitives.some((entry) => !['orm', 'function', 'artifact'].includes(entry.kind)))) {
78
+ ctx.addIssue({ code: 'custom', message: 'Agents, processes, pipelines and shared packages require schema_version: 2', path: ['schema_version'] });
79
+ }
80
+ validateInventory({ manifest, ctx });
81
+ const priority = orderPriority({ manifest, ctx });
82
+ if (manifest.schema_version === 2) {
83
+ try {
84
+ dependencyOrder({ entries: manifest.primitives, priority });
85
+ }
86
+ catch (error) {
87
+ ctx.addIssue({ code: 'custom', message: error instanceof Error ? error.message : String(error), path: ['primitives'] });
88
+ }
89
+ return;
90
+ }
91
+ const position = new Map(priority.map((id, index) => [id, index]));
92
+ for (const entry of manifest.primitives) {
93
+ for (const dep of entry.depends_on) {
94
+ if ((position.get(dep) ?? -1) >= (position.get(entry.id) ?? Infinity)) {
95
+ ctx.addIssue({ code: 'custom', message: `deploy order places "${entry.id}" before its dependency "${dep}"`, path: ['deploy', 'order'] });
96
+ }
97
+ }
98
+ }
99
+ }
@@ -5,18 +5,21 @@
5
5
  * scaffolding and for the eventual Applications UI. Crawl-only discovery is
6
6
  * intentionally not supported — `seq-studio init` / `add` own this file.
7
7
  *
8
- * v0 kinds: orm | function | artifact. Process/agent can return later.
8
+ * Version 2 is the app deployment graph; version 1 keeps its legacy ordering.
9
9
  */
10
10
  import { z } from 'zod';
11
11
  export declare const APP_MANIFEST_FILENAME = "sequence.app.yml";
12
- export declare const PRIMITIVE_KINDS: readonly ["orm", "function", "artifact"];
12
+ export declare const PRIMITIVE_KINDS: readonly ["orm", "function", "agent", "process", "pipeline", "artifact"];
13
13
  export type PrimitiveKind = (typeof PRIMITIVE_KINDS)[number];
14
14
  export declare function isPrimitiveKind(value: string): value is PrimitiveKind;
15
15
  declare const primitiveEntrySchema: z.ZodObject<{
16
16
  id: z.ZodString;
17
17
  kind: z.ZodEnum<{
18
18
  function: "function";
19
+ agent: "agent";
20
+ process: "process";
19
21
  orm: "orm";
22
+ pipeline: "pipeline";
20
23
  artifact: "artifact";
21
24
  }>;
22
25
  path: z.ZodString;
@@ -24,23 +27,30 @@ declare const primitiveEntrySchema: z.ZodObject<{
24
27
  namespace: z.ZodOptional<z.ZodString>;
25
28
  slug: z.ZodOptional<z.ZodString>;
26
29
  project_id: z.ZodOptional<z.ZodString>;
27
- }, z.core.$strip>;
30
+ target: z.ZodOptional<z.ZodString>;
31
+ only: z.ZodOptional<z.ZodArray<z.ZodString>>;
32
+ repo: z.ZodOptional<z.ZodString>;
33
+ ref: z.ZodOptional<z.ZodString>;
34
+ }, z.core.$strict>;
28
35
  export declare const appManifestSchema: z.ZodObject<{
29
- schema_version: z.ZodLiteral<1>;
36
+ schema_version: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>]>;
30
37
  app: z.ZodObject<{
31
38
  id: z.ZodString;
32
39
  title: z.ZodString;
33
40
  description: z.ZodOptional<z.ZodString>;
34
- }, z.core.$strip>;
41
+ }, z.core.$strict>;
35
42
  studio: z.ZodObject<{
36
43
  created_with: z.ZodString;
37
44
  min_cli: z.ZodString;
38
- }, z.core.$strip>;
45
+ }, z.core.$strict>;
39
46
  primitives: z.ZodArray<z.ZodObject<{
40
47
  id: z.ZodString;
41
48
  kind: z.ZodEnum<{
42
49
  function: "function";
50
+ agent: "agent";
51
+ process: "process";
43
52
  orm: "orm";
53
+ pipeline: "pipeline";
44
54
  artifact: "artifact";
45
55
  }>;
46
56
  path: z.ZodString;
@@ -48,15 +58,23 @@ export declare const appManifestSchema: z.ZodObject<{
48
58
  namespace: z.ZodOptional<z.ZodString>;
49
59
  slug: z.ZodOptional<z.ZodString>;
50
60
  project_id: z.ZodOptional<z.ZodString>;
51
- }, z.core.$strip>>;
61
+ target: z.ZodOptional<z.ZodString>;
62
+ only: z.ZodOptional<z.ZodArray<z.ZodString>>;
63
+ repo: z.ZodOptional<z.ZodString>;
64
+ ref: z.ZodOptional<z.ZodString>;
65
+ }, z.core.$strict>>;
66
+ packages: z.ZodOptional<z.ZodArray<z.ZodObject<{
67
+ name: z.ZodString;
68
+ path: z.ZodString;
69
+ }, z.core.$strict>>>;
52
70
  deploy: z.ZodDefault<z.ZodObject<{
53
71
  order: z.ZodOptional<z.ZodArray<z.ZodString>>;
54
72
  on_error: z.ZodDefault<z.ZodEnum<{
55
73
  continue: "continue";
56
74
  stop: "stop";
57
75
  }>>;
58
- }, z.core.$strip>>;
59
- }, z.core.$strip>;
76
+ }, z.core.$strict>>;
77
+ }, z.core.$strict>;
60
78
  export type AppManifest = z.infer<typeof appManifestSchema>;
61
79
  export type PrimitiveEntry = z.infer<typeof primitiveEntrySchema>;
62
80
  /**