@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.
- package/README.md +255 -72
- package/dist/app/adapters.d.ts +9 -0
- package/dist/app/adapters.js +176 -0
- package/dist/app/commands.d.ts +2 -2
- package/dist/app/commands.js +98 -22
- package/dist/app/deploy.d.ts +9 -10
- package/dist/app/deploy.js +83 -141
- package/dist/app/graph.d.ts +15 -0
- package/dist/app/graph.js +36 -0
- package/dist/app/manifest-validation.d.ts +16 -0
- package/dist/app/manifest-validation.js +99 -0
- package/dist/app/manifest.d.ts +27 -9
- package/dist/app/manifest.js +23 -107
- package/dist/app/paths.d.ts +14 -0
- package/dist/app/paths.js +77 -0
- package/dist/app/primitive-scaffold.d.ts +18 -0
- package/dist/app/primitive-scaffold.js +136 -0
- package/dist/app/readme.d.ts +4 -18
- package/dist/app/readme.js +105 -233
- package/dist/app/run-deployment.d.ts +8 -0
- package/dist/app/run-deployment.js +50 -0
- package/dist/app/scaffold-files.d.ts +13 -0
- package/dist/app/scaffold-files.js +68 -0
- package/dist/app/scaffold.d.ts +11 -3
- package/dist/app/scaffold.js +77 -245
- package/dist/app/workspace-compile.d.ts +18 -0
- package/dist/app/workspace-compile.js +143 -0
- package/dist/app/workspace-model.d.ts +70 -0
- package/dist/app/workspace-model.js +159 -0
- package/dist/app/workspace-scaffold.d.ts +27 -0
- package/dist/app/workspace-scaffold.js +126 -0
- package/dist/app/workspace.d.ts +14 -0
- package/dist/app/workspace.js +147 -0
- package/dist/atlas-client.js +28 -6
- package/dist/auth-cmds/commands.d.ts +1 -1
- package/dist/auth-cmds/commands.js +5 -2
- package/dist/functions/commands.js +7 -1
- package/dist/functions/manifest.d.ts +18 -0
- package/dist/functions/manifest.js +29 -4
- package/dist/main.js +8 -3
- package/dist/pat-hints.js +1 -0
- package/dist/pipeline/commands.js +27 -9
- package/dist/pipeline/lifecycle.d.ts +2 -0
- package/dist/pipeline/lifecycle.js +91 -11
- package/dist/process/build.js +59 -43
- package/dist/process/codegen.d.ts +3 -2
- package/dist/process/codegen.js +143 -27
- package/dist/process/commands.d.ts +2 -0
- package/dist/process/commands.js +63 -18
- package/dist/process/discover.d.ts +6 -3
- package/dist/process/discover.js +11 -3
- package/dist/process/lint.d.ts +14 -0
- package/dist/process/lint.js +143 -5
- package/dist/process/plan-diff.d.ts +8 -0
- package/dist/process/plan-diff.js +61 -4
- package/dist/process/safety-baseline.d.ts +154 -0
- package/dist/process/safety-baseline.js +387 -0
- package/dist/process/simulate.js +64 -22
- package/dist/repos/commands.d.ts +1 -1
- package/dist/repos/commands.js +29 -3
- package/package.json +6 -5
package/dist/process/codegen.js
CHANGED
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
* published from the UI can be pulled back into a local tree.
|
|
5
5
|
*
|
|
6
6
|
* Fidelity notes (the bundle is a compiled artifact, not the original source):
|
|
7
|
-
* -
|
|
8
|
-
*
|
|
7
|
+
* - JS mapper bodies are the build-time `Function.toString()` strings; JSONata
|
|
8
|
+
* mapper expressions are reconstructed as `jsonata('…')`. Both rebuild to
|
|
9
|
+
* the same content-addressed bundle fields.
|
|
9
10
|
* - Automation bodies live in the Atlas image; only the registry id is
|
|
10
11
|
* emitted (`function: '<id>'`).
|
|
11
12
|
* - Co-located subprocess pins (version / bundle_hash) are dropped — they are
|
|
@@ -49,7 +50,9 @@ export function generateProcessFiles(process, bundle) {
|
|
|
49
50
|
process.max_concurrent_runs !== undefined
|
|
50
51
|
? ` max_concurrent_runs: ${process.max_concurrent_runs},`
|
|
51
52
|
: null,
|
|
52
|
-
process.supervisor_retry !== undefined
|
|
53
|
+
process.supervisor_retry !== undefined
|
|
54
|
+
? ` supervisor_retry: ${retryConfig(process.supervisor_retry, ctx)},`
|
|
55
|
+
: null,
|
|
53
56
|
process.run_as !== undefined
|
|
54
57
|
? ` run_as: { ${[
|
|
55
58
|
process.run_as.email !== undefined ? `email: ${lit(process.run_as.email)}` : null,
|
|
@@ -60,6 +63,9 @@ export function generateProcessFiles(process, bundle) {
|
|
|
60
63
|
.filter((f) => f !== null)
|
|
61
64
|
.join(', ')} },`
|
|
62
65
|
: null,
|
|
66
|
+
process.input_schema !== undefined
|
|
67
|
+
? ` input_schema: ${pretty(process.input_schema, 1)},`
|
|
68
|
+
: null,
|
|
63
69
|
Array.isArray(process.tags) && process.tags.length > 0
|
|
64
70
|
? ` tags: ${pretty(process.tags, 1)},`
|
|
65
71
|
: null,
|
|
@@ -93,13 +99,15 @@ function emitNode(node, ctx) {
|
|
|
93
99
|
ctx.used.add('defineAgentNode');
|
|
94
100
|
return call('defineAgentNode', [
|
|
95
101
|
...head,
|
|
96
|
-
` agent: { id: ${lit(String(m.agent_id))}
|
|
102
|
+
` agent: { id: ${lit(String(m.agent_id))}${m.agent_version !== undefined
|
|
103
|
+
? `, version: ${value(m.agent_version)}`
|
|
104
|
+
: ''} },`,
|
|
97
105
|
m.workflow_id != null ? ` workflowId: ${lit(String(m.workflow_id))},` : null,
|
|
98
106
|
m.on_reset_edge_id != null ? ` on_reset_edge_id: ${lit(String(m.on_reset_edge_id))},` : null,
|
|
99
107
|
m.timeout !== undefined ? ` timeout: ${value(m.timeout)},` : null,
|
|
100
108
|
bindings(m.bindings),
|
|
101
|
-
middleware(m.middleware),
|
|
102
|
-
mapper('input', m.input_mapper_source),
|
|
109
|
+
middleware(m.middleware, ctx),
|
|
110
|
+
mapper('input', m.input_mapper_source, m.input_mapper_expr, ctx),
|
|
103
111
|
tail,
|
|
104
112
|
]);
|
|
105
113
|
}
|
|
@@ -113,13 +121,18 @@ function emitNode(node, ctx) {
|
|
|
113
121
|
m.timeout !== undefined ? ` timeout: ${value(m.timeout)},` : null,
|
|
114
122
|
m.on_timeout_edge_id != null ? ` on_timeout_edge_id: ${lit(String(m.on_timeout_edge_id))},` : null,
|
|
115
123
|
m.hide_timeout_edge_from_advance === true ? ` hideTimeoutEdgeFromAdvance: true,` : null,
|
|
116
|
-
m.
|
|
124
|
+
mapper('advance_allowed', m.advance_allowed_mapper_source, m.advance_allowed_mapper_expr, ctx),
|
|
125
|
+
m.advance_allowed !== undefined
|
|
126
|
+
? ` advance_allowed: ${pretty(m.advance_allowed, 1)},`
|
|
127
|
+
: null,
|
|
117
128
|
m.assignable_to !== undefined ? ` assignable_to: ${pretty(m.assignable_to, 1)},` : null,
|
|
118
129
|
bindings(m.bindings),
|
|
119
130
|
Array.isArray(m.artifact_refs) ? ` artifact_refs: ${pretty(m.artifact_refs, 1)},` : null,
|
|
120
|
-
mapper('artifact_refs', m.artifact_refs_mapper_source),
|
|
131
|
+
mapper('artifact_refs', m.artifact_refs_mapper_source, m.artifact_refs_mapper_expr, ctx),
|
|
121
132
|
m.comments !== undefined ? ` comments: ${pretty(m.comments, 1)},` : null,
|
|
122
|
-
mapper('
|
|
133
|
+
mapper('dueDate', m.due_date_source, m.due_date_expr, ctx),
|
|
134
|
+
emailNotification(m, ctx),
|
|
135
|
+
mapper('input', m.input_mapper_source, m.input_mapper_expr, ctx),
|
|
123
136
|
tail,
|
|
124
137
|
]);
|
|
125
138
|
}
|
|
@@ -136,8 +149,8 @@ function emitNode(node, ctx) {
|
|
|
136
149
|
m.limits !== undefined ? ` limits: ${pretty(m.limits, 1)},` : null,
|
|
137
150
|
runAsField(m.run_as),
|
|
138
151
|
bindings(m.bindings),
|
|
139
|
-
middleware(m.middleware),
|
|
140
|
-
mapper('input', m.input_mapper_source),
|
|
152
|
+
middleware(m.middleware, ctx),
|
|
153
|
+
mapper('input', m.input_mapper_source, m.input_mapper_expr, ctx),
|
|
141
154
|
tail,
|
|
142
155
|
]);
|
|
143
156
|
}
|
|
@@ -150,10 +163,12 @@ function emitNode(node, ctx) {
|
|
|
150
163
|
// Colocated pins re-resolve on rebuild; keep an external target's pin.
|
|
151
164
|
ctx.colocated.has(sub.process_id) ? null : ` version: ${lit(sub.version)},`,
|
|
152
165
|
` on_child_error: ${lit(sub.on_child_error)},`,
|
|
153
|
-
sub.supervisor_retry !== undefined
|
|
166
|
+
sub.supervisor_retry !== undefined
|
|
167
|
+
? ` supervisor_retry: ${retryConfig(sub.supervisor_retry, ctx)},`
|
|
168
|
+
: null,
|
|
154
169
|
bindings(m.bindings),
|
|
155
|
-
mapper('input', m.input_mapper_source),
|
|
156
|
-
|
|
170
|
+
mapper('input', m.input_mapper_source, m.input_mapper_expr, ctx),
|
|
171
|
+
requiredMapper('output', sub.output_mapper_source, sub.output_mapper_expr, ctx, `subprocess node "${node.id}"`),
|
|
157
172
|
tail,
|
|
158
173
|
]);
|
|
159
174
|
}
|
|
@@ -167,8 +182,7 @@ function emitNode(node, ctx) {
|
|
|
167
182
|
.join('\n')}\n ],`);
|
|
168
183
|
}
|
|
169
184
|
else {
|
|
170
|
-
|
|
171
|
-
branchFields.push(` fan_out: ${par.fan_out_source},`);
|
|
185
|
+
branchFields.push(requiredMapper('fan_out', par.fan_out_source, par.fan_out_expr, ctx, `parallel node "${node.id}"`));
|
|
172
186
|
if (par.max_fanout !== undefined)
|
|
173
187
|
branchFields.push(` max_fanout: ${par.max_fanout},`);
|
|
174
188
|
if (par.branch)
|
|
@@ -178,13 +192,15 @@ function emitNode(node, ctx) {
|
|
|
178
192
|
...head,
|
|
179
193
|
...branchFields,
|
|
180
194
|
par.max_concurrency !== undefined ? ` max_concurrency: ${par.max_concurrency},` : null,
|
|
181
|
-
par.supervisor_retry !== undefined
|
|
195
|
+
par.supervisor_retry !== undefined
|
|
196
|
+
? ` supervisor_retry: ${retryConfig(par.supervisor_retry, ctx)},`
|
|
197
|
+
: null,
|
|
182
198
|
bindings(m.bindings),
|
|
183
199
|
` on_branch_error: ${lit(par.on_branch_error)},`,
|
|
184
200
|
// Only 'eager' is ever serialized (barrier is the omitted default).
|
|
185
201
|
par.join_mode === 'eager' ? ` join_mode: ${lit('eager')},` : null,
|
|
186
|
-
|
|
187
|
-
mapper('input', m.input_mapper_source),
|
|
202
|
+
requiredMapper('join', par.join_source, par.join_expr, ctx, `parallel node "${node.id}"`),
|
|
203
|
+
mapper('input', m.input_mapper_source, m.input_mapper_expr, ctx),
|
|
188
204
|
tail,
|
|
189
205
|
]);
|
|
190
206
|
}
|
|
@@ -201,8 +217,8 @@ function emitNode(node, ctx) {
|
|
|
201
217
|
m.limits !== undefined ? ` limits: ${pretty(m.limits, 1)},` : null,
|
|
202
218
|
runAsField(m.run_as),
|
|
203
219
|
bindings(m.bindings),
|
|
204
|
-
middleware(m.middleware),
|
|
205
|
-
mapper('input', m.input_mapper_source),
|
|
220
|
+
middleware(m.middleware, ctx),
|
|
221
|
+
mapper('input', m.input_mapper_source, m.input_mapper_expr, ctx),
|
|
206
222
|
tail,
|
|
207
223
|
];
|
|
208
224
|
return call('defineManagedFunctionNode', fields);
|
|
@@ -227,11 +243,104 @@ function runAsField(runAs) {
|
|
|
227
243
|
return null;
|
|
228
244
|
return ` run_as: { service_account: ${lit(sa)} },`;
|
|
229
245
|
}
|
|
230
|
-
/**
|
|
231
|
-
function mapper(field, source) {
|
|
232
|
-
|
|
246
|
+
/** Inverse of build.ts's serializeMapperSlot for pulled source generation. */
|
|
247
|
+
function mapper(field, source, expr, ctx) {
|
|
248
|
+
const rendered = mapperValue(source, expr, ctx);
|
|
249
|
+
return rendered === null ? null : ` ${field}: ${rendered},`;
|
|
250
|
+
}
|
|
251
|
+
function requiredMapper(field, source, expr, ctx, owner) {
|
|
252
|
+
const rendered = mapperValue(source, expr, ctx);
|
|
253
|
+
if (rendered === null) {
|
|
254
|
+
throw new Error(`codegen: ${owner} has no ${field} mapper`);
|
|
255
|
+
}
|
|
256
|
+
return ` ${field}: ${rendered},`;
|
|
257
|
+
}
|
|
258
|
+
function mapperValue(source, expr, ctx) {
|
|
259
|
+
if (typeof source === 'string' && source.length > 0)
|
|
260
|
+
return source;
|
|
261
|
+
if (typeof expr === 'string' && expr.length > 0) {
|
|
262
|
+
ctx.used.add('jsonata');
|
|
263
|
+
return `jsonata(${lit(expr)})`;
|
|
264
|
+
}
|
|
265
|
+
return null;
|
|
266
|
+
}
|
|
267
|
+
function retryConfig(value, ctx, depth = 1) {
|
|
268
|
+
if (!isRecord(value)) {
|
|
269
|
+
throw new Error('codegen: retry config is not an object');
|
|
270
|
+
}
|
|
271
|
+
const fieldIndent = ' '.repeat(depth + 1);
|
|
272
|
+
const closingIndent = ' '.repeat(depth);
|
|
273
|
+
const fields = [
|
|
274
|
+
'maxAttempts',
|
|
275
|
+
'factor',
|
|
276
|
+
'minTimeoutInMs',
|
|
277
|
+
'maxTimeoutInMs',
|
|
278
|
+
'randomize',
|
|
279
|
+
].flatMap((key) => value[key] === undefined
|
|
280
|
+
? []
|
|
281
|
+
: [`${fieldIndent}${lit(key)}: ${pretty(value[key], depth + 1)},`]);
|
|
282
|
+
const retryIf = mapperValue(value.retryIf, value.retryIfExpr, ctx);
|
|
283
|
+
if (retryIf !== null)
|
|
284
|
+
fields.push(`${fieldIndent}retryIf: ${retryIf},`);
|
|
285
|
+
return fields.length === 0
|
|
286
|
+
? '{}'
|
|
287
|
+
: `{\n${fields.join('\n')}\n${closingIndent}}`;
|
|
288
|
+
}
|
|
289
|
+
function emailNotification(metadata, ctx) {
|
|
290
|
+
if (metadata.email_notification !== true)
|
|
233
291
|
return null;
|
|
234
|
-
|
|
292
|
+
const template = mapperValue(metadata.email_notification_template_source, metadata.email_notification_template_expr, ctx);
|
|
293
|
+
const reminders = emailReminders(metadata.email_notification_reminders, ctx);
|
|
294
|
+
const timezone = typeof metadata.email_notification_timezone === 'string'
|
|
295
|
+
? metadata.email_notification_timezone
|
|
296
|
+
: undefined;
|
|
297
|
+
const enabledEnvironments = Array.isArray(metadata.email_notification_enabled_environments)
|
|
298
|
+
? metadata.email_notification_enabled_environments
|
|
299
|
+
: undefined;
|
|
300
|
+
if (timezone === undefined &&
|
|
301
|
+
reminders === null &&
|
|
302
|
+
enabledEnvironments === undefined) {
|
|
303
|
+
return template === null
|
|
304
|
+
? ' emailNotification: true,'
|
|
305
|
+
: ` emailNotification: ${template},`;
|
|
306
|
+
}
|
|
307
|
+
const fields = [
|
|
308
|
+
template === null ? null : ` template: ${template},`,
|
|
309
|
+
timezone === undefined ? null : ` timezone: ${lit(timezone)},`,
|
|
310
|
+
reminders === null ? null : ` reminders: ${reminders},`,
|
|
311
|
+
enabledEnvironments === undefined
|
|
312
|
+
? null
|
|
313
|
+
: ` enabledEnvironments: ${pretty(enabledEnvironments, 2)},`,
|
|
314
|
+
]
|
|
315
|
+
.filter((field) => field !== null)
|
|
316
|
+
.join('\n');
|
|
317
|
+
return ` emailNotification: {\n${fields}\n },`;
|
|
318
|
+
}
|
|
319
|
+
function emailReminders(value, ctx) {
|
|
320
|
+
if (!Array.isArray(value) || value.length === 0)
|
|
321
|
+
return null;
|
|
322
|
+
const reminders = value.map((raw, index) => {
|
|
323
|
+
if (!isRecord(raw)) {
|
|
324
|
+
throw new Error(`codegen: email notification reminder ${index} is not an object`);
|
|
325
|
+
}
|
|
326
|
+
const template = mapperValue(raw.template_source, raw.template_expr, ctx);
|
|
327
|
+
const fields = [
|
|
328
|
+
typeof raw.before === 'string'
|
|
329
|
+
? ` before: ${lit(raw.before)},`
|
|
330
|
+
: null,
|
|
331
|
+
typeof raw.after === 'string'
|
|
332
|
+
? ` after: ${lit(raw.after)},`
|
|
333
|
+
: null,
|
|
334
|
+
template === null ? null : ` template: ${template},`,
|
|
335
|
+
]
|
|
336
|
+
.filter((field) => field !== null)
|
|
337
|
+
.join('\n');
|
|
338
|
+
return ` {\n${fields}\n }`;
|
|
339
|
+
});
|
|
340
|
+
return `[\n${reminders.join(',\n')}\n ]`;
|
|
341
|
+
}
|
|
342
|
+
function isRecord(value) {
|
|
343
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
235
344
|
}
|
|
236
345
|
/** A safely-escaped TS string literal. */
|
|
237
346
|
function lit(value) {
|
|
@@ -260,10 +369,17 @@ function bindings(v) {
|
|
|
260
369
|
return ` bindings: ${pretty(v, 1)},`;
|
|
261
370
|
}
|
|
262
371
|
/** An optional `middleware: [...]` field (node-execution middleware refs). */
|
|
263
|
-
function middleware(v) {
|
|
372
|
+
function middleware(v, ctx) {
|
|
264
373
|
if (!Array.isArray(v) || v.length === 0)
|
|
265
374
|
return null;
|
|
266
|
-
|
|
375
|
+
const refs = v.map((rawRef) => {
|
|
376
|
+
if (!isRecord(rawRef) || rawRef.id !== 'retry' || !isRecord(rawRef.config)) {
|
|
377
|
+
return ` ${pretty(rawRef, 2)}`;
|
|
378
|
+
}
|
|
379
|
+
ctx.used.add('withRetry');
|
|
380
|
+
return ` withRetry(${retryConfig(rawRef.config, ctx, 2)})`;
|
|
381
|
+
});
|
|
382
|
+
return ` middleware: [\n${refs.join(',\n')}\n ],`;
|
|
267
383
|
}
|
|
268
384
|
/** A node id → a valid, readable JS const identifier (camelCase, never a
|
|
269
385
|
* reserved word, always starting with a letter/underscore). */
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
export interface ParsedArgs {
|
|
8
8
|
positional: string[];
|
|
9
9
|
flags: Record<string, string | true>;
|
|
10
|
+
/** All string values for flags supplied more than once; `flags` keeps the last value. */
|
|
11
|
+
repeatedFlags?: Record<string, string[]>;
|
|
10
12
|
}
|
|
11
13
|
export declare function parseArgs(rest: string[]): ParsedArgs;
|
|
12
14
|
export type ProcessSourceSpec = {
|
package/dist/process/commands.js
CHANGED
|
@@ -17,7 +17,7 @@ import { finalizeCompiledBundle, summarizeBundle } from './build.js';
|
|
|
17
17
|
import { buildResolveProcessPinFromEnv } from './resolve-process-pin.js';
|
|
18
18
|
import { loadBundleForPublish } from './local-bundle.js';
|
|
19
19
|
import { findProcessRoot } from './discover.js';
|
|
20
|
-
import { formatLintResult, lintSerializedAgentContracts, } from './lint.js';
|
|
20
|
+
import { formatLintResult, lintBundleStaticGraphLimits, lintSerializedAgentContracts, } from './lint.js';
|
|
21
21
|
import { diffBundleAgainstActive, formatPlanDiff, } from './plan-diff.js';
|
|
22
22
|
import { formatSimulateResult } from './simulate.js';
|
|
23
23
|
import { buildAgentSchemaLoader } from './agent-loader.js';
|
|
@@ -27,6 +27,15 @@ import { compileProcessSourceIsolated, simulateProcessIsolated, } from './compil
|
|
|
27
27
|
export function parseArgs(rest) {
|
|
28
28
|
const positional = [];
|
|
29
29
|
const flags = {};
|
|
30
|
+
const repeatedFlags = {};
|
|
31
|
+
const setFlag = (key, value) => {
|
|
32
|
+
flags[key] = value;
|
|
33
|
+
if (typeof value === 'string') {
|
|
34
|
+
const values = repeatedFlags[key] ?? [];
|
|
35
|
+
values.push(value);
|
|
36
|
+
repeatedFlags[key] = values;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
30
39
|
for (let i = 0; i < rest.length; i++) {
|
|
31
40
|
const arg = rest[i];
|
|
32
41
|
if (arg === '--') {
|
|
@@ -41,7 +50,7 @@ export function parseArgs(rest) {
|
|
|
41
50
|
// wrong target.
|
|
42
51
|
const eqIdx = body.indexOf('=');
|
|
43
52
|
if (eqIdx >= 0) {
|
|
44
|
-
|
|
53
|
+
setFlag(body.slice(0, eqIdx), body.slice(eqIdx + 1));
|
|
45
54
|
continue;
|
|
46
55
|
}
|
|
47
56
|
const key = body;
|
|
@@ -51,11 +60,11 @@ export function parseArgs(rest) {
|
|
|
51
60
|
// would consume `-e` as the value of `--out` and silently swallow
|
|
52
61
|
// the `-e` flag.
|
|
53
62
|
if (next && !next.startsWith('-')) {
|
|
54
|
-
|
|
63
|
+
setFlag(key, next);
|
|
55
64
|
i += 1;
|
|
56
65
|
}
|
|
57
66
|
else {
|
|
58
|
-
|
|
67
|
+
setFlag(key, true);
|
|
59
68
|
}
|
|
60
69
|
}
|
|
61
70
|
else if (arg.startsWith('-') && arg.length >= 2 && !arg.startsWith('--')) {
|
|
@@ -71,23 +80,27 @@ export function parseArgs(rest) {
|
|
|
71
80
|
continue;
|
|
72
81
|
}
|
|
73
82
|
if (eqIdx >= 0) {
|
|
74
|
-
|
|
83
|
+
setFlag(longName, arg.slice(eqIdx + 1));
|
|
75
84
|
continue;
|
|
76
85
|
}
|
|
77
86
|
const next = rest[i + 1];
|
|
78
87
|
if (next && !next.startsWith('-')) {
|
|
79
|
-
|
|
88
|
+
setFlag(longName, next);
|
|
80
89
|
i += 1;
|
|
81
90
|
}
|
|
82
91
|
else {
|
|
83
|
-
|
|
92
|
+
setFlag(longName, true);
|
|
84
93
|
}
|
|
85
94
|
}
|
|
86
95
|
else {
|
|
87
96
|
positional.push(arg);
|
|
88
97
|
}
|
|
89
98
|
}
|
|
90
|
-
return {
|
|
99
|
+
return {
|
|
100
|
+
positional,
|
|
101
|
+
flags,
|
|
102
|
+
...(Object.keys(repeatedFlags).length > 0 ? { repeatedFlags } : {}),
|
|
103
|
+
};
|
|
91
104
|
}
|
|
92
105
|
const SHORT_FLAG_ALIASES = {
|
|
93
106
|
'-e': 'env',
|
|
@@ -132,6 +145,10 @@ export function parseProcessSourceSpec(flags) {
|
|
|
132
145
|
throw new Error('--repo requires a value: --repo processes/<name>');
|
|
133
146
|
if (flags.ref === true)
|
|
134
147
|
throw new Error('--ref requires a value.');
|
|
148
|
+
if (flags.dir === true)
|
|
149
|
+
throw new Error('--dir requires a directory.');
|
|
150
|
+
if (repo && flags.dir !== undefined)
|
|
151
|
+
throw new Error('--dir cannot be combined with --repo.');
|
|
135
152
|
if (ref && !repo)
|
|
136
153
|
throw new Error('--ref only applies together with --repo.');
|
|
137
154
|
if (ref && ref.startsWith('-'))
|
|
@@ -213,7 +230,15 @@ function slugify(value) {
|
|
|
213
230
|
// lint
|
|
214
231
|
// ---------------------------------------------------------------------------
|
|
215
232
|
export async function lintCommand(args) {
|
|
216
|
-
const compiled = await compileLocalProcessSource();
|
|
233
|
+
const compiled = await compileLocalProcessSource(args);
|
|
234
|
+
const selection = resolveOnlyIds({
|
|
235
|
+
only: args.flags.only,
|
|
236
|
+
knownIds: new Set(compiled.bundle.processes.map((definition) => definition.id)),
|
|
237
|
+
});
|
|
238
|
+
if (selection.error) {
|
|
239
|
+
console.error(selection.error);
|
|
240
|
+
return 1;
|
|
241
|
+
}
|
|
217
242
|
const result = await lintCompiledProcessSource({
|
|
218
243
|
compiled,
|
|
219
244
|
loadAgentSchemaEdgeIdEnum: await tryBuildAgentLoader(args),
|
|
@@ -228,8 +253,13 @@ export async function lintCommand(args) {
|
|
|
228
253
|
console.log(`\nlint ok — ${compiled.bundle.processes.length} process(es) checked, ${result.warnings.length} warning(s)`);
|
|
229
254
|
return 0;
|
|
230
255
|
}
|
|
231
|
-
|
|
232
|
-
|
|
256
|
+
function localProcessDirectory(args) {
|
|
257
|
+
if (args.flags.dir === true)
|
|
258
|
+
throw new Error('--dir requires a directory.');
|
|
259
|
+
return args.flags.dir;
|
|
260
|
+
}
|
|
261
|
+
async function compileLocalProcessSource(args) {
|
|
262
|
+
const rootDir = await findProcessRoot({ directory: localProcessDirectory(args) });
|
|
233
263
|
return compileProcessSourceIsolated({
|
|
234
264
|
rootDir,
|
|
235
265
|
provenance: localGitMetadata(rootDir),
|
|
@@ -243,12 +273,18 @@ async function lintCompiledProcessSource({ compiled, loadAgentSchemaEdgeIdEnum,
|
|
|
243
273
|
// parent only adds registry-dependent validation (or the offline warning).
|
|
244
274
|
includeStaticValidation: false,
|
|
245
275
|
});
|
|
276
|
+
// Static graph limits (LAT-148): ceilings are errors, published defaults
|
|
277
|
+
// are warnings — the target deployment's profile is what registration
|
|
278
|
+
// actually enforces.
|
|
279
|
+
const limitLint = lintBundleStaticGraphLimits({ bundle: compiled.bundle });
|
|
246
280
|
return {
|
|
247
|
-
errors: [...compiled.lint.errors, ...agentLint.errors],
|
|
248
|
-
warnings: [...compiled.lint.warnings, ...agentLint.warnings],
|
|
281
|
+
errors: [...compiled.lint.errors, ...agentLint.errors, ...limitLint.errors],
|
|
282
|
+
warnings: [...compiled.lint.warnings, ...agentLint.warnings, ...limitLint.warnings],
|
|
249
283
|
};
|
|
250
284
|
}
|
|
251
285
|
async function tryBuildAgentLoader(args) {
|
|
286
|
+
if (args.flags.offline === true || args.flags.offline === 'true')
|
|
287
|
+
return undefined;
|
|
252
288
|
// Agent loader is only meaningful when we have a target env + token.
|
|
253
289
|
// If either fails to resolve, skip the check; lint will emit a warning
|
|
254
290
|
// for multi-edge agent nodes instead of failing.
|
|
@@ -286,8 +322,17 @@ async function buildBundleForPublish(args, compiled) {
|
|
|
286
322
|
}
|
|
287
323
|
}
|
|
288
324
|
export async function planCommand(args) {
|
|
289
|
-
const compiled = await compileLocalProcessSource();
|
|
325
|
+
const compiled = await compileLocalProcessSource(args);
|
|
290
326
|
const bundle = await buildBundleForPublish(args, compiled);
|
|
327
|
+
// Static graph limits (LAT-148): run limits lint so `process plan` matches registration.
|
|
328
|
+
const limitLint = lintBundleStaticGraphLimits({ bundle });
|
|
329
|
+
const formattedLint = formatLintResult(limitLint);
|
|
330
|
+
if (formattedLint.text)
|
|
331
|
+
console.log(formattedLint.text);
|
|
332
|
+
if (formattedLint.hasErrors) {
|
|
333
|
+
console.error(`\nplan FAILED — ${limitLint.errors.length} static graph limit error(s), ${limitLint.warnings.length} warning(s)`);
|
|
334
|
+
return 1;
|
|
335
|
+
}
|
|
291
336
|
const summary = summarizeBundle(bundle);
|
|
292
337
|
console.log(JSON.stringify(summary, null, 2));
|
|
293
338
|
const loadActiveProcess = await tryBuildActiveProcessLoader(args);
|
|
@@ -339,7 +384,7 @@ async function tryBuildActiveProcessLoader(args) {
|
|
|
339
384
|
// test (CI wrapper)
|
|
340
385
|
// ---------------------------------------------------------------------------
|
|
341
386
|
export async function testCommand(args) {
|
|
342
|
-
const compiled = await compileLocalProcessSource();
|
|
387
|
+
const compiled = await compileLocalProcessSource(args);
|
|
343
388
|
const lintResult = await lintCompiledProcessSource({
|
|
344
389
|
compiled,
|
|
345
390
|
loadAgentSchemaEdgeIdEnum: await tryBuildAgentLoader(args),
|
|
@@ -415,7 +460,7 @@ export async function applyCommand(args) {
|
|
|
415
460
|
return applyLocal(args);
|
|
416
461
|
}
|
|
417
462
|
async function applyLocal(args) {
|
|
418
|
-
const compiled = await compileLocalProcessSource();
|
|
463
|
+
const compiled = await compileLocalProcessSource(args);
|
|
419
464
|
const { env, token } = await getEnvAndToken(args);
|
|
420
465
|
return registerAndPromote({ args, env, token, compiled });
|
|
421
466
|
}
|
|
@@ -613,7 +658,7 @@ export async function bundleCommand(args) {
|
|
|
613
658
|
const sub = args.positional[0];
|
|
614
659
|
switch (sub) {
|
|
615
660
|
case 'build': {
|
|
616
|
-
const compiled = await compileLocalProcessSource();
|
|
661
|
+
const compiled = await compileLocalProcessSource(args);
|
|
617
662
|
const bundle = await buildBundleForPublish(args, compiled);
|
|
618
663
|
const out = typeof args.flags.out === 'string' ? resolve(args.flags.out) : null;
|
|
619
664
|
if (out) {
|
|
@@ -750,7 +795,7 @@ export async function simulateCommand(args) {
|
|
|
750
795
|
return 1;
|
|
751
796
|
}
|
|
752
797
|
const simulation = await simulateProcessIsolated({
|
|
753
|
-
rootDir: await findProcessRoot(),
|
|
798
|
+
rootDir: await findProcessRoot({ directory: localProcessDirectory(args) }),
|
|
754
799
|
processId,
|
|
755
800
|
});
|
|
756
801
|
if (simulation.kind === 'not-found') {
|
|
@@ -20,10 +20,13 @@ export interface LoadedProcess {
|
|
|
20
20
|
* Resolve the root directory to scan for `<id>/process.ts` folders.
|
|
21
21
|
*
|
|
22
22
|
* Precedence:
|
|
23
|
-
* 1. `
|
|
24
|
-
* 2.
|
|
23
|
+
* 1. Explicit `--dir` (absolute or relative to cwd)
|
|
24
|
+
* 2. `LATTICE_PROCESSES_ROOT` env var (absolute or relative to cwd)
|
|
25
|
+
* 3. The current working directory (the typical case in an external repo)
|
|
25
26
|
*/
|
|
26
|
-
export declare function findProcessRoot(
|
|
27
|
+
export declare function findProcessRoot({ directory }?: {
|
|
28
|
+
directory?: string;
|
|
29
|
+
}): Promise<string>;
|
|
27
30
|
/**
|
|
28
31
|
* Load every `<dir>/process.ts` under the configured root. Each module
|
|
29
32
|
* must `export default defineProcess(...)`. Process ids must be unique
|
package/dist/process/discover.js
CHANGED
|
@@ -37,10 +37,18 @@ async function fileExists(path) {
|
|
|
37
37
|
* Resolve the root directory to scan for `<id>/process.ts` folders.
|
|
38
38
|
*
|
|
39
39
|
* Precedence:
|
|
40
|
-
* 1. `
|
|
41
|
-
* 2.
|
|
40
|
+
* 1. Explicit `--dir` (absolute or relative to cwd)
|
|
41
|
+
* 2. `LATTICE_PROCESSES_ROOT` env var (absolute or relative to cwd)
|
|
42
|
+
* 3. The current working directory (the typical case in an external repo)
|
|
42
43
|
*/
|
|
43
|
-
export async function findProcessRoot() {
|
|
44
|
+
export async function findProcessRoot({ directory } = {}) {
|
|
45
|
+
if (directory !== undefined) {
|
|
46
|
+
const resolved = resolve(directory);
|
|
47
|
+
if (!directory.trim() || !(await isDir(resolved))) {
|
|
48
|
+
throw new Error(`--dir is not a directory: ${resolved}`);
|
|
49
|
+
}
|
|
50
|
+
return resolved;
|
|
51
|
+
}
|
|
44
52
|
const envRoot = process.env['LATTICE_PROCESSES_ROOT']?.trim();
|
|
45
53
|
if (envRoot) {
|
|
46
54
|
const resolved = resolve(envRoot);
|
package/dist/process/lint.d.ts
CHANGED
|
@@ -36,6 +36,20 @@ export interface LintInput {
|
|
|
36
36
|
suppressUnavailableAgentWarnings?: boolean;
|
|
37
37
|
}
|
|
38
38
|
export declare function lintProcesses(input: LintInput): Promise<LintResult>;
|
|
39
|
+
/**
|
|
40
|
+
* Static graph-shape limits (LAT-148), measured by the SDK's shared walker —
|
|
41
|
+
* exactly what registration measures. Two tiers, because the CLI does not
|
|
42
|
+
* know the target deployment's profile:
|
|
43
|
+
*
|
|
44
|
+
* - over a platform HARD CEILING → error: no deployment can be configured
|
|
45
|
+
* to accept it, so `apply` would fail everywhere.
|
|
46
|
+
* - over the PUBLISHED DEFAULT (but under the ceiling) → warning: the
|
|
47
|
+
* default deployment rejects it, a deployment with a raised
|
|
48
|
+
* `LATTICE_SAFETY_PROFILE` may accept it. The server is authoritative.
|
|
49
|
+
*/
|
|
50
|
+
export declare function lintBundleStaticGraphLimits({ bundle }: {
|
|
51
|
+
bundle: LatticeBundle;
|
|
52
|
+
}): LintResult;
|
|
39
53
|
export declare function lintSerializedAgentContracts({ bundle, loadAgentSchemaEdgeIdEnum, includeStaticValidation, }: {
|
|
40
54
|
bundle: LatticeBundle;
|
|
41
55
|
loadAgentSchemaEdgeIdEnum?: LintInput['loadAgentSchemaEdgeIdEnum'];
|