@xemahq/dsl 0.6.0 → 0.7.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.
- package/dist/schema/reusable-workflow.schema.json +9 -1
- package/dist/schema/workflow.schema.json +39 -13
- package/dist/workflow/lib/compiler/compile.d.ts.map +1 -1
- package/dist/workflow/lib/compiler/compile.js +105 -20
- package/dist/workflow/lib/compiler/compile.js.map +1 -1
- package/dist/workflow/lib/compiler/concurrency.js +1 -1
- package/dist/workflow/lib/compiler/concurrency.js.map +1 -1
- package/dist/workflow/lib/compiler/manifest-source.d.ts +2 -1
- package/dist/workflow/lib/compiler/manifest-source.d.ts.map +1 -1
- package/dist/workflow/lib/compiler/manifest-source.js +13 -4
- package/dist/workflow/lib/compiler/manifest-source.js.map +1 -1
- package/dist/workflow/lib/compiler/review-step.d.ts +2 -1
- package/dist/workflow/lib/compiler/review-step.d.ts.map +1 -1
- package/dist/workflow/lib/compiler/review-step.js +13 -1
- package/dist/workflow/lib/compiler/review-step.js.map +1 -1
- package/dist/workflow/lib/compiler/types.d.ts +3 -2
- package/dist/workflow/lib/compiler/types.d.ts.map +1 -1
- package/dist/workflow/lib/expression/context.d.ts +1 -1
- package/dist/workflow/lib/expression/context.d.ts.map +1 -1
- package/dist/workflow/lib/expression/context.js +1 -1
- package/dist/workflow/lib/expression/context.js.map +1 -1
- package/dist/workflow/lib/types.d.ts +1 -1
- package/dist/workflow/lib/types.d.ts.map +1 -1
- package/package.json +3 -3
- package/schema/reusable-workflow.schema.json +9 -1
- package/schema/workflow.schema.json +39 -13
- package/src/workflow/lib/compiler/compile.ts +302 -149
- package/src/workflow/lib/compiler/concurrency.ts +1 -1
- package/src/workflow/lib/compiler/manifest-source.ts +23 -8
- package/src/workflow/lib/compiler/review-step.ts +33 -2
- package/src/workflow/lib/compiler/types.ts +9 -9
- package/src/workflow/lib/expression/context.ts +2 -2
- package/src/workflow/lib/types.ts +38 -8
|
@@ -40,7 +40,10 @@
|
|
|
40
40
|
* worker's runtime contract — they intentionally diverge.
|
|
41
41
|
*/
|
|
42
42
|
|
|
43
|
-
import {
|
|
43
|
+
import {
|
|
44
|
+
WorkflowErrorCode,
|
|
45
|
+
type CompiledManifestSource,
|
|
46
|
+
} from '@xemahq/kernel-contracts/workflow';
|
|
44
47
|
|
|
45
48
|
import { WorkflowDslError } from '../errors';
|
|
46
49
|
import {
|
|
@@ -379,6 +382,7 @@ export function rewriteReviewStepWith(
|
|
|
379
382
|
jobKey: string,
|
|
380
383
|
payload: WorkflowJobDeclaration,
|
|
381
384
|
workflow: WorkflowDocument,
|
|
385
|
+
manifestSourcesByJob: Readonly<Record<string, CompiledManifestSource | null>>,
|
|
382
386
|
): Readonly<Record<string, unknown>> {
|
|
383
387
|
if (!isReviewActionRef(payload.uses)) {
|
|
384
388
|
return payload.with ?? {};
|
|
@@ -423,6 +427,11 @@ export function rewriteReviewStepWith(
|
|
|
423
427
|
step: shape.redraft.step,
|
|
424
428
|
uses: producer.uses,
|
|
425
429
|
with: producer.with ?? {},
|
|
430
|
+
manifestSource: requireRedraftManifestSource(
|
|
431
|
+
jobKey,
|
|
432
|
+
shape.redraft.step,
|
|
433
|
+
manifestSourcesByJob,
|
|
434
|
+
),
|
|
426
435
|
};
|
|
427
436
|
const strategy = compileRedraftStrategyIR(producer.strategy);
|
|
428
437
|
if (strategy !== null) {
|
|
@@ -437,6 +446,26 @@ export function rewriteReviewStepWith(
|
|
|
437
446
|
return out;
|
|
438
447
|
}
|
|
439
448
|
|
|
449
|
+
function requireRedraftManifestSource(
|
|
450
|
+
reviewJobKey: string,
|
|
451
|
+
producerJobKey: string,
|
|
452
|
+
manifestSourcesByJob: Readonly<Record<string, CompiledManifestSource | null>>,
|
|
453
|
+
): CompiledManifestSource {
|
|
454
|
+
const source = manifestSourcesByJob[producerJobKey];
|
|
455
|
+
if (source === undefined || source === null) {
|
|
456
|
+
throw new WorkflowDslError(
|
|
457
|
+
WorkflowErrorCode.DSL_SEMANTIC_INVALID,
|
|
458
|
+
`Job '${reviewJobKey}' redraft producer '${producerJobKey}' has no compiled Agent revision source.`,
|
|
459
|
+
{
|
|
460
|
+
jobKey: reviewJobKey,
|
|
461
|
+
fieldPath: 'with.redraft.step',
|
|
462
|
+
referencedJob: producerJobKey,
|
|
463
|
+
},
|
|
464
|
+
);
|
|
465
|
+
}
|
|
466
|
+
return source;
|
|
467
|
+
}
|
|
468
|
+
|
|
440
469
|
/**
|
|
441
470
|
* Pre-resolve a producer step's authored matrix strategy into a
|
|
442
471
|
* JSON-serializable IR descriptor the worker carries through the
|
|
@@ -513,5 +542,7 @@ function expandStaticMatrixAxes(
|
|
|
513
542
|
}
|
|
514
543
|
entries = next;
|
|
515
544
|
}
|
|
516
|
-
return entries.map(Object.freeze) as readonly Readonly<
|
|
545
|
+
return entries.map(Object.freeze) as readonly Readonly<
|
|
546
|
+
Record<string, unknown>
|
|
547
|
+
>[];
|
|
517
548
|
}
|
|
@@ -14,13 +14,13 @@ import type { ActionManifest, WorkflowDocument } from '../types';
|
|
|
14
14
|
*
|
|
15
15
|
* - `workflow` — validated WorkflowDocument (pass through
|
|
16
16
|
* `validateWorkflowDocument` first).
|
|
17
|
-
* - `workflowRef` — slug/
|
|
17
|
+
* - `workflowRef` — slug/revision/content-contract identity, resolved from the DB.
|
|
18
18
|
* - `trigger` — the payload that fired this run.
|
|
19
19
|
* - `resolvedRefs` — map of `uses:` strings to resolved refs, populated
|
|
20
20
|
* by looking up each job's `uses:` in the action-manifest registry
|
|
21
21
|
* (for `xema/...`) or the reusable-workflow registry (for
|
|
22
22
|
* `xema://workflow/...`).
|
|
23
|
-
* - `
|
|
23
|
+
* - `workflowDefinitionContentHash` — content hash of the immutable source revision the
|
|
24
24
|
* compiler is consuming. Emitted into CompiledRun for audit.
|
|
25
25
|
*/
|
|
26
26
|
export interface CompileInput {
|
|
@@ -29,11 +29,10 @@ export interface CompileInput {
|
|
|
29
29
|
readonly trigger: TriggerPayload;
|
|
30
30
|
readonly resolvedRefs: Readonly<Record<string, ResolvedRef>>;
|
|
31
31
|
/**
|
|
32
|
-
* Map of agent
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* parsing the bare slug off the `<slug>@<version>` ref before lookup.
|
|
32
|
+
* Map of authored literal agent ref → immutable Agent revision metadata.
|
|
33
|
+
* The engine resolves each exact ref through llm-registry-api before
|
|
34
|
+
* compilation. Literal refs are therefore compile-time selectors only:
|
|
35
|
+
* CompiledRun stores the immutable revision id + content hash.
|
|
37
36
|
* Expression-shaped refs (e.g. `${{ inputs.agentSlug }}`) are skipped
|
|
38
37
|
* — they resolve at dispatch and the activity's `AGENT_NOT_REGISTERED`
|
|
39
38
|
* preflight catches them at runtime.
|
|
@@ -53,7 +52,7 @@ export interface CompileInput {
|
|
|
53
52
|
readonly resolvedDeliverableSpecs?: Readonly<
|
|
54
53
|
Record<string, ResolvedDeliverableSpec>
|
|
55
54
|
>;
|
|
56
|
-
readonly
|
|
55
|
+
readonly workflowDefinitionContentHash: string;
|
|
57
56
|
/**
|
|
58
57
|
* Contents of every wallet referenced under `requires.wallets`, plus
|
|
59
58
|
* any additional wallets a dispatch caller asked for. The compiler
|
|
@@ -129,7 +128,8 @@ export interface InstallationCompileScope {
|
|
|
129
128
|
*/
|
|
130
129
|
export interface ResolvedAgentMeta {
|
|
131
130
|
readonly slug: string;
|
|
132
|
-
readonly
|
|
131
|
+
readonly agentRevisionId: string;
|
|
132
|
+
readonly agentContentHash: string;
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
/**
|
|
@@ -85,7 +85,7 @@ export interface XemaContext {
|
|
|
85
85
|
};
|
|
86
86
|
readonly workflow: {
|
|
87
87
|
readonly key: string;
|
|
88
|
-
readonly
|
|
88
|
+
readonly revisionNumber: number;
|
|
89
89
|
};
|
|
90
90
|
readonly job: {
|
|
91
91
|
readonly key: string;
|
|
@@ -142,7 +142,7 @@ export const EMPTY_CONTEXT_SEEDS = {
|
|
|
142
142
|
correlationId: '',
|
|
143
143
|
actor: Object.freeze({ subject: null, kind: XemaActorKind.System }),
|
|
144
144
|
}),
|
|
145
|
-
workflow: Object.freeze({ key: '',
|
|
145
|
+
workflow: Object.freeze({ key: '', revisionNumber: 0 }),
|
|
146
146
|
job: Object.freeze({ key: '', attempt: 0 }),
|
|
147
147
|
}) as XemaContext,
|
|
148
148
|
} as const;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
ConcurrencyMode,
|
|
3
|
+
PermissionScope,
|
|
4
|
+
} from '@xemahq/kernel-contracts/workflow';
|
|
2
5
|
|
|
3
6
|
/**
|
|
4
7
|
* Authored-shape TypeScript types for a Xema workflow document. These match
|
|
@@ -90,7 +93,8 @@ export interface WorkflowStructuredOutputDeclaration
|
|
|
90
93
|
readonly schemaRef?: string;
|
|
91
94
|
}
|
|
92
95
|
|
|
93
|
-
export interface WorkflowTextOutputDeclaration
|
|
96
|
+
export interface WorkflowTextOutputDeclaration
|
|
97
|
+
extends WorkflowOutputDeclarationBase {
|
|
94
98
|
readonly kind: 'text';
|
|
95
99
|
}
|
|
96
100
|
|
|
@@ -119,7 +123,12 @@ export interface WorkflowConnectorRequirement {
|
|
|
119
123
|
|
|
120
124
|
export interface WorkflowMetadata {
|
|
121
125
|
readonly name: string;
|
|
122
|
-
|
|
126
|
+
/**
|
|
127
|
+
* Compatibility version for an explicitly reusable public workflow API.
|
|
128
|
+
* Ordinary workflows omit this; their immutable revision is generated by
|
|
129
|
+
* the workflow registry.
|
|
130
|
+
*/
|
|
131
|
+
readonly contractVersion?: string;
|
|
123
132
|
readonly title?: string;
|
|
124
133
|
readonly description?: string;
|
|
125
134
|
readonly category?: string;
|
|
@@ -155,7 +164,13 @@ export interface WorkflowCallDeclaration {
|
|
|
155
164
|
}
|
|
156
165
|
|
|
157
166
|
export interface WorkflowInputDeclaration {
|
|
158
|
-
readonly type:
|
|
167
|
+
readonly type:
|
|
168
|
+
| 'string'
|
|
169
|
+
| 'number'
|
|
170
|
+
| 'integer'
|
|
171
|
+
| 'boolean'
|
|
172
|
+
| 'object'
|
|
173
|
+
| 'array';
|
|
159
174
|
readonly required?: boolean;
|
|
160
175
|
readonly default?: unknown;
|
|
161
176
|
readonly description?: string;
|
|
@@ -207,7 +222,12 @@ export interface WorkflowRetryDeclaration {
|
|
|
207
222
|
readonly nonRetryableErrorTypes?: readonly string[];
|
|
208
223
|
}
|
|
209
224
|
|
|
210
|
-
export type WorkflowPermissions = Partial<
|
|
225
|
+
export type WorkflowPermissions = Partial<
|
|
226
|
+
Record<
|
|
227
|
+
'repos' | 'kb' | 'backlog' | 'connectors' | 'artifacts' | 'memory',
|
|
228
|
+
PermissionScope
|
|
229
|
+
>
|
|
230
|
+
>;
|
|
211
231
|
|
|
212
232
|
export interface WorkflowJobDeclaration {
|
|
213
233
|
readonly title?: string;
|
|
@@ -224,8 +244,14 @@ export interface WorkflowJobDeclaration {
|
|
|
224
244
|
}
|
|
225
245
|
|
|
226
246
|
export type WorkflowStrategyDeclaration =
|
|
227
|
-
| {
|
|
228
|
-
|
|
247
|
+
| {
|
|
248
|
+
readonly matrix: Readonly<Record<string, readonly unknown[]>>;
|
|
249
|
+
readonly maxParallel?: number;
|
|
250
|
+
}
|
|
251
|
+
| {
|
|
252
|
+
readonly dynamic: WorkflowDynamicStrategyDeclaration;
|
|
253
|
+
readonly maxParallel?: number;
|
|
254
|
+
};
|
|
229
255
|
|
|
230
256
|
export interface WorkflowDynamicStrategyDeclaration {
|
|
231
257
|
readonly from: string;
|
|
@@ -307,7 +333,11 @@ export interface ActionManifestSpec {
|
|
|
307
333
|
readonly allowedMounts?: readonly string[];
|
|
308
334
|
readonly retryDefaults: ActionManifestRetryDefaults;
|
|
309
335
|
readonly timeoutDefaults: ActionManifestTimeoutDefaults;
|
|
310
|
-
readonly auditEventMapping?: Partial<{
|
|
336
|
+
readonly auditEventMapping?: Partial<{
|
|
337
|
+
started: string;
|
|
338
|
+
succeeded: string;
|
|
339
|
+
failed: string;
|
|
340
|
+
}>;
|
|
311
341
|
/**
|
|
312
342
|
* Declarative contracts the action opts into. The DSL compiler reads
|
|
313
343
|
* this list to decide which validation lanes apply — e.g. the
|