@xemahq/dsl 0.1.1
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/LICENSE +201 -0
- package/dist/deliverable-spec/index.d.ts +3 -0
- package/dist/deliverable-spec/index.d.ts.map +1 -0
- package/dist/deliverable-spec/index.js +19 -0
- package/dist/deliverable-spec/index.js.map +1 -0
- package/dist/deliverable-spec/lib/schema.d.ts +151 -0
- package/dist/deliverable-spec/lib/schema.d.ts.map +1 -0
- package/dist/deliverable-spec/lib/schema.js +139 -0
- package/dist/deliverable-spec/lib/schema.js.map +1 -0
- package/dist/deliverable-spec/lib/types.d.ts +8 -0
- package/dist/deliverable-spec/lib/types.d.ts.map +1 -0
- package/dist/deliverable-spec/lib/types.js +3 -0
- package/dist/deliverable-spec/lib/types.js.map +1 -0
- package/dist/payload-codec/index.d.ts +8 -0
- package/dist/payload-codec/index.d.ts.map +1 -0
- package/dist/payload-codec/index.js +27 -0
- package/dist/payload-codec/index.js.map +1 -0
- package/dist/payload-codec/lib/blob-store.d.ts +37 -0
- package/dist/payload-codec/lib/blob-store.d.ts.map +1 -0
- package/dist/payload-codec/lib/blob-store.js +0 -0
- package/dist/payload-codec/lib/blob-store.js.map +1 -0
- package/dist/payload-codec/lib/codec-context.d.ts +6 -0
- package/dist/payload-codec/lib/codec-context.d.ts.map +1 -0
- package/dist/payload-codec/lib/codec-context.js +16 -0
- package/dist/payload-codec/lib/codec-context.js.map +1 -0
- package/dist/payload-codec/lib/codec.d.ts +51 -0
- package/dist/payload-codec/lib/codec.d.ts.map +1 -0
- package/dist/payload-codec/lib/codec.js +330 -0
- package/dist/payload-codec/lib/codec.js.map +1 -0
- package/dist/payload-codec/lib/enums.d.ts +18 -0
- package/dist/payload-codec/lib/enums.d.ts.map +1 -0
- package/dist/payload-codec/lib/enums.js +23 -0
- package/dist/payload-codec/lib/enums.js.map +1 -0
- package/dist/payload-codec/lib/errors.d.ts +18 -0
- package/dist/payload-codec/lib/errors.d.ts.map +1 -0
- package/dist/payload-codec/lib/errors.js +39 -0
- package/dist/payload-codec/lib/errors.js.map +1 -0
- package/dist/payload-codec/lib/http-blob-store.d.ts +21 -0
- package/dist/payload-codec/lib/http-blob-store.d.ts.map +1 -0
- package/dist/payload-codec/lib/http-blob-store.js +139 -0
- package/dist/payload-codec/lib/http-blob-store.js.map +1 -0
- package/dist/payload-codec/lib/lru-cache.d.ts +12 -0
- package/dist/payload-codec/lib/lru-cache.d.ts.map +1 -0
- package/dist/payload-codec/lib/lru-cache.js +59 -0
- package/dist/payload-codec/lib/lru-cache.js.map +1 -0
- package/dist/schema/action.schema.json +181 -0
- package/dist/schema/reusable-workflow.schema.json +46 -0
- package/dist/schema/workflow.schema.json +373 -0
- package/dist/workflow/index.d.ts +14 -0
- package/dist/workflow/index.d.ts.map +1 -0
- package/dist/workflow/index.js +49 -0
- package/dist/workflow/index.js.map +1 -0
- package/dist/workflow/lib/action-input-validator.d.ts +10 -0
- package/dist/workflow/lib/action-input-validator.d.ts.map +1 -0
- package/dist/workflow/lib/action-input-validator.js +69 -0
- package/dist/workflow/lib/action-input-validator.js.map +1 -0
- package/dist/workflow/lib/compiler/action-shape.d.ts +5 -0
- package/dist/workflow/lib/compiler/action-shape.d.ts.map +1 -0
- package/dist/workflow/lib/compiler/action-shape.js +43 -0
- package/dist/workflow/lib/compiler/action-shape.js.map +1 -0
- package/dist/workflow/lib/compiler/canonical-json.d.ts +3 -0
- package/dist/workflow/lib/compiler/canonical-json.d.ts.map +1 -0
- package/dist/workflow/lib/compiler/canonical-json.js +45 -0
- package/dist/workflow/lib/compiler/canonical-json.js.map +1 -0
- package/dist/workflow/lib/compiler/compile.d.ts +4 -0
- package/dist/workflow/lib/compiler/compile.d.ts.map +1 -0
- package/dist/workflow/lib/compiler/compile.js +794 -0
- package/dist/workflow/lib/compiler/compile.js.map +1 -0
- package/dist/workflow/lib/compiler/concurrency.d.ts +5 -0
- package/dist/workflow/lib/compiler/concurrency.d.ts.map +1 -0
- package/dist/workflow/lib/compiler/concurrency.js +104 -0
- package/dist/workflow/lib/compiler/concurrency.js.map +1 -0
- package/dist/workflow/lib/compiler/dag.d.ts +10 -0
- package/dist/workflow/lib/compiler/dag.d.ts.map +1 -0
- package/dist/workflow/lib/compiler/dag.js +74 -0
- package/dist/workflow/lib/compiler/dag.js.map +1 -0
- package/dist/workflow/lib/compiler/index.d.ts +6 -0
- package/dist/workflow/lib/compiler/index.d.ts.map +1 -0
- package/dist/workflow/lib/compiler/index.js +14 -0
- package/dist/workflow/lib/compiler/index.js.map +1 -0
- package/dist/workflow/lib/compiler/inputs.d.ts +4 -0
- package/dist/workflow/lib/compiler/inputs.d.ts.map +1 -0
- package/dist/workflow/lib/compiler/inputs.js +108 -0
- package/dist/workflow/lib/compiler/inputs.js.map +1 -0
- package/dist/workflow/lib/compiler/installation-resource-validator.d.ts +9 -0
- package/dist/workflow/lib/compiler/installation-resource-validator.d.ts.map +1 -0
- package/dist/workflow/lib/compiler/installation-resource-validator.js +76 -0
- package/dist/workflow/lib/compiler/installation-resource-validator.js.map +1 -0
- package/dist/workflow/lib/compiler/manifest-source.d.ts +4 -0
- package/dist/workflow/lib/compiler/manifest-source.d.ts.map +1 -0
- package/dist/workflow/lib/compiler/manifest-source.js +100 -0
- package/dist/workflow/lib/compiler/manifest-source.js.map +1 -0
- package/dist/workflow/lib/compiler/matrix.d.ts +4 -0
- package/dist/workflow/lib/compiler/matrix.d.ts.map +1 -0
- package/dist/workflow/lib/compiler/matrix.js +76 -0
- package/dist/workflow/lib/compiler/matrix.js.map +1 -0
- package/dist/workflow/lib/compiler/mount-plan.d.ts +4 -0
- package/dist/workflow/lib/compiler/mount-plan.d.ts.map +1 -0
- package/dist/workflow/lib/compiler/mount-plan.js +96 -0
- package/dist/workflow/lib/compiler/mount-plan.js.map +1 -0
- package/dist/workflow/lib/compiler/payload-reach-in.d.ts +14 -0
- package/dist/workflow/lib/compiler/payload-reach-in.d.ts.map +1 -0
- package/dist/workflow/lib/compiler/payload-reach-in.js +273 -0
- package/dist/workflow/lib/compiler/payload-reach-in.js.map +1 -0
- package/dist/workflow/lib/compiler/permissions.d.ts +6 -0
- package/dist/workflow/lib/compiler/permissions.d.ts.map +1 -0
- package/dist/workflow/lib/compiler/permissions.js +43 -0
- package/dist/workflow/lib/compiler/permissions.js.map +1 -0
- package/dist/workflow/lib/compiler/retry-timeout.d.ts +6 -0
- package/dist/workflow/lib/compiler/retry-timeout.d.ts.map +1 -0
- package/dist/workflow/lib/compiler/retry-timeout.js +64 -0
- package/dist/workflow/lib/compiler/retry-timeout.js.map +1 -0
- package/dist/workflow/lib/compiler/review-step.d.ts +18 -0
- package/dist/workflow/lib/compiler/review-step.d.ts.map +1 -0
- package/dist/workflow/lib/compiler/review-step.js +247 -0
- package/dist/workflow/lib/compiler/review-step.js.map +1 -0
- package/dist/workflow/lib/compiler/types.d.ts +42 -0
- package/dist/workflow/lib/compiler/types.d.ts.map +1 -0
- package/dist/workflow/lib/compiler/types.js +3 -0
- package/dist/workflow/lib/compiler/types.js.map +1 -0
- package/dist/workflow/lib/compiler/variable-requirements.d.ts +5 -0
- package/dist/workflow/lib/compiler/variable-requirements.d.ts.map +1 -0
- package/dist/workflow/lib/compiler/variable-requirements.js +119 -0
- package/dist/workflow/lib/compiler/variable-requirements.js.map +1 -0
- package/dist/workflow/lib/deliverable-spec-keys.d.ts +3 -0
- package/dist/workflow/lib/deliverable-spec-keys.d.ts.map +1 -0
- package/dist/workflow/lib/deliverable-spec-keys.js +90 -0
- package/dist/workflow/lib/deliverable-spec-keys.js.map +1 -0
- package/dist/workflow/lib/dispatch-inputs/index.d.ts +23 -0
- package/dist/workflow/lib/dispatch-inputs/index.d.ts.map +1 -0
- package/dist/workflow/lib/dispatch-inputs/index.js +106 -0
- package/dist/workflow/lib/dispatch-inputs/index.js.map +1 -0
- package/dist/workflow/lib/dispatch-inputs/to-json-schema.d.ts +3 -0
- package/dist/workflow/lib/dispatch-inputs/to-json-schema.d.ts.map +1 -0
- package/dist/workflow/lib/dispatch-inputs/to-json-schema.js +43 -0
- package/dist/workflow/lib/dispatch-inputs/to-json-schema.js.map +1 -0
- package/dist/workflow/lib/duration.d.ts +2 -0
- package/dist/workflow/lib/duration.d.ts.map +1 -0
- package/dist/workflow/lib/duration.js +26 -0
- package/dist/workflow/lib/duration.js.map +1 -0
- package/dist/workflow/lib/errors.d.ts +9 -0
- package/dist/workflow/lib/errors.d.ts.map +1 -0
- package/dist/workflow/lib/errors.js +28 -0
- package/dist/workflow/lib/errors.js.map +1 -0
- package/dist/workflow/lib/expression/ast.d.ts +61 -0
- package/dist/workflow/lib/expression/ast.d.ts.map +1 -0
- package/dist/workflow/lib/expression/ast.js +34 -0
- package/dist/workflow/lib/expression/ast.js.map +1 -0
- package/dist/workflow/lib/expression/context.d.ts +63 -0
- package/dist/workflow/lib/expression/context.d.ts.map +1 -0
- package/dist/workflow/lib/expression/context.js +32 -0
- package/dist/workflow/lib/expression/context.js.map +1 -0
- package/dist/workflow/lib/expression/evaluator.d.ts +5 -0
- package/dist/workflow/lib/expression/evaluator.d.ts.map +1 -0
- package/dist/workflow/lib/expression/evaluator.js +291 -0
- package/dist/workflow/lib/expression/evaluator.js.map +1 -0
- package/dist/workflow/lib/expression/index.d.ts +9 -0
- package/dist/workflow/lib/expression/index.d.ts.map +1 -0
- package/dist/workflow/lib/expression/index.js +26 -0
- package/dist/workflow/lib/expression/index.js.map +1 -0
- package/dist/workflow/lib/expression/interpolation.d.ts +9 -0
- package/dist/workflow/lib/expression/interpolation.d.ts.map +1 -0
- package/dist/workflow/lib/expression/interpolation.js +51 -0
- package/dist/workflow/lib/expression/interpolation.js.map +1 -0
- package/dist/workflow/lib/expression/parser.d.ts +4 -0
- package/dist/workflow/lib/expression/parser.d.ts.map +1 -0
- package/dist/workflow/lib/expression/parser.js +203 -0
- package/dist/workflow/lib/expression/parser.js.map +1 -0
- package/dist/workflow/lib/expression/template.d.ts +18 -0
- package/dist/workflow/lib/expression/template.d.ts.map +1 -0
- package/dist/workflow/lib/expression/template.js +63 -0
- package/dist/workflow/lib/expression/template.js.map +1 -0
- package/dist/workflow/lib/expression/tokenizer.d.ts +3 -0
- package/dist/workflow/lib/expression/tokenizer.d.ts.map +1 -0
- package/dist/workflow/lib/expression/tokenizer.js +153 -0
- package/dist/workflow/lib/expression/tokenizer.js.map +1 -0
- package/dist/workflow/lib/expression/tokens.d.ts +25 -0
- package/dist/workflow/lib/expression/tokens.d.ts.map +1 -0
- package/dist/workflow/lib/expression/tokens.js +24 -0
- package/dist/workflow/lib/expression/tokens.js.map +1 -0
- package/dist/workflow/lib/expression/walk-artifact-refs.d.ts +5 -0
- package/dist/workflow/lib/expression/walk-artifact-refs.d.ts.map +1 -0
- package/dist/workflow/lib/expression/walk-artifact-refs.js +138 -0
- package/dist/workflow/lib/expression/walk-artifact-refs.js.map +1 -0
- package/dist/workflow/lib/installation-resource-kind.d.ts +14 -0
- package/dist/workflow/lib/installation-resource-kind.d.ts.map +1 -0
- package/dist/workflow/lib/installation-resource-kind.js +59 -0
- package/dist/workflow/lib/installation-resource-kind.js.map +1 -0
- package/dist/workflow/lib/schemas-loader.d.ts +4 -0
- package/dist/workflow/lib/schemas-loader.d.ts.map +1 -0
- package/dist/workflow/lib/schemas-loader.js +36 -0
- package/dist/workflow/lib/schemas-loader.js.map +1 -0
- package/dist/workflow/lib/serializer.d.ts +3 -0
- package/dist/workflow/lib/serializer.d.ts.map +1 -0
- package/dist/workflow/lib/serializer.js +15 -0
- package/dist/workflow/lib/serializer.js.map +1 -0
- package/dist/workflow/lib/types.d.ts +179 -0
- package/dist/workflow/lib/types.d.ts.map +1 -0
- package/dist/workflow/lib/types.js +3 -0
- package/dist/workflow/lib/types.js.map +1 -0
- package/dist/workflow/lib/validate.d.ts +8 -0
- package/dist/workflow/lib/validate.d.ts.map +1 -0
- package/dist/workflow/lib/validate.js +119 -0
- package/dist/workflow/lib/validate.js.map +1 -0
- package/dist/workspace-manifest/index.d.ts +6 -0
- package/dist/workspace-manifest/index.d.ts.map +1 -0
- package/dist/workspace-manifest/index.js +22 -0
- package/dist/workspace-manifest/index.js.map +1 -0
- package/dist/workspace-manifest/lib/compile.d.ts +8 -0
- package/dist/workspace-manifest/lib/compile.d.ts.map +1 -0
- package/dist/workspace-manifest/lib/compile.js +439 -0
- package/dist/workspace-manifest/lib/compile.js.map +1 -0
- package/dist/workspace-manifest/lib/interpolate.d.ts +12 -0
- package/dist/workspace-manifest/lib/interpolate.d.ts.map +1 -0
- package/dist/workspace-manifest/lib/interpolate.js +81 -0
- package/dist/workspace-manifest/lib/interpolate.js.map +1 -0
- package/dist/workspace-manifest/lib/resolve-extends.d.ts +10 -0
- package/dist/workspace-manifest/lib/resolve-extends.d.ts.map +1 -0
- package/dist/workspace-manifest/lib/resolve-extends.js +108 -0
- package/dist/workspace-manifest/lib/resolve-extends.js.map +1 -0
- package/dist/workspace-manifest/lib/schema.d.ts +710 -0
- package/dist/workspace-manifest/lib/schema.d.ts.map +1 -0
- package/dist/workspace-manifest/lib/schema.js +355 -0
- package/dist/workspace-manifest/lib/schema.js.map +1 -0
- package/dist/workspace-manifest/lib/types.d.ts +153 -0
- package/dist/workspace-manifest/lib/types.d.ts.map +1 -0
- package/dist/workspace-manifest/lib/types.js +10 -0
- package/dist/workspace-manifest/lib/types.js.map +1 -0
- package/package.json +79 -0
- package/schema/action.schema.json +181 -0
- package/schema/reusable-workflow.schema.json +46 -0
- package/schema/workflow.schema.json +373 -0
- package/src/deliverable-spec/index.ts +19 -0
- package/src/deliverable-spec/lib/schema.ts +248 -0
- package/src/deliverable-spec/lib/types.ts +26 -0
- package/src/payload-codec/index.ts +40 -0
- package/src/payload-codec/lib/blob-store.ts +0 -0
- package/src/payload-codec/lib/codec-context.ts +38 -0
- package/src/payload-codec/lib/codec.ts +593 -0
- package/src/payload-codec/lib/enums.ts +58 -0
- package/src/payload-codec/lib/errors.ts +54 -0
- package/src/payload-codec/lib/http-blob-store.ts +257 -0
- package/src/payload-codec/lib/lru-cache.ts +81 -0
- package/src/workflow/index.ts +98 -0
- package/src/workflow/lib/action-input-validator.ts +160 -0
- package/src/workflow/lib/compiler/action-shape.ts +71 -0
- package/src/workflow/lib/compiler/canonical-json.ts +53 -0
- package/src/workflow/lib/compiler/compile.ts +1518 -0
- package/src/workflow/lib/compiler/concurrency.ts +223 -0
- package/src/workflow/lib/compiler/dag.ts +108 -0
- package/src/workflow/lib/compiler/index.ts +10 -0
- package/src/workflow/lib/compiler/inputs.ts +199 -0
- package/src/workflow/lib/compiler/installation-resource-validator.ts +114 -0
- package/src/workflow/lib/compiler/manifest-source.ts +176 -0
- package/src/workflow/lib/compiler/matrix.ts +135 -0
- package/src/workflow/lib/compiler/mount-plan.ts +202 -0
- package/src/workflow/lib/compiler/payload-reach-in.ts +497 -0
- package/src/workflow/lib/compiler/permissions.ts +64 -0
- package/src/workflow/lib/compiler/retry-timeout.ts +105 -0
- package/src/workflow/lib/compiler/review-step.ts +517 -0
- package/src/workflow/lib/compiler/types.ts +170 -0
- package/src/workflow/lib/compiler/variable-requirements.ts +208 -0
- package/src/workflow/lib/deliverable-spec-keys.ts +109 -0
- package/src/workflow/lib/dispatch-inputs/index.ts +160 -0
- package/src/workflow/lib/dispatch-inputs/to-json-schema.ts +60 -0
- package/src/workflow/lib/duration.ts +48 -0
- package/src/workflow/lib/errors.ts +37 -0
- package/src/workflow/lib/expression/ast.ts +108 -0
- package/src/workflow/lib/expression/context.ts +148 -0
- package/src/workflow/lib/expression/evaluator.ts +492 -0
- package/src/workflow/lib/expression/index.ts +28 -0
- package/src/workflow/lib/expression/interpolation.ts +84 -0
- package/src/workflow/lib/expression/parser.ts +264 -0
- package/src/workflow/lib/expression/template.ts +117 -0
- package/src/workflow/lib/expression/tokenizer.ts +200 -0
- package/src/workflow/lib/expression/tokens.ts +30 -0
- package/src/workflow/lib/expression/walk-artifact-refs.ts +232 -0
- package/src/workflow/lib/installation-resource-kind.ts +107 -0
- package/src/workflow/lib/schemas-loader.ts +64 -0
- package/src/workflow/lib/serializer.ts +30 -0
- package/src/workflow/lib/types.ts +361 -0
- package/src/workflow/lib/validate.ts +199 -0
- package/src/workspace-manifest/index.ts +27 -0
- package/src/workspace-manifest/lib/compile.ts +608 -0
- package/src/workspace-manifest/lib/interpolate.ts +140 -0
- package/src/workspace-manifest/lib/resolve-extends.ts +260 -0
- package/src/workspace-manifest/lib/schema.ts +612 -0
- package/src/workspace-manifest/lib/types.ts +392 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HttpBlobStore = void 0;
|
|
4
|
+
const enums_1 = require("./enums");
|
|
5
|
+
const errors_1 = require("./errors");
|
|
6
|
+
const blob_store_1 = require("./blob-store");
|
|
7
|
+
const DEFAULT_REQUEST_TIMEOUT_MS = 30_000;
|
|
8
|
+
const PUT_PATH = '/blobs';
|
|
9
|
+
const GET_PATH_PREFIX = '/blobs/';
|
|
10
|
+
class HttpBlobStore {
|
|
11
|
+
options;
|
|
12
|
+
kind = enums_1.BlobStoreKind.ARTIFACT_STORE;
|
|
13
|
+
constructor(options) {
|
|
14
|
+
this.options = options;
|
|
15
|
+
if (!options.baseUrl) {
|
|
16
|
+
throw new Error('HttpBlobStore: baseUrl is required.');
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
async put(bytes, contentType, orgId) {
|
|
20
|
+
assertOrgId(orgId);
|
|
21
|
+
const token = await this.options.tokenProvider();
|
|
22
|
+
const controller = new AbortController();
|
|
23
|
+
const timer = setTimeout(() => controller.abort(), this.options.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS);
|
|
24
|
+
try {
|
|
25
|
+
const response = (await fetch(this.resolveUrl(PUT_PATH), {
|
|
26
|
+
method: 'POST',
|
|
27
|
+
headers: this.buildHeaders(token, contentType, orgId),
|
|
28
|
+
body: Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength),
|
|
29
|
+
signal: controller.signal,
|
|
30
|
+
}));
|
|
31
|
+
if (!response.ok) {
|
|
32
|
+
throw new errors_1.PayloadCodecError(errors_1.PayloadCodecErrorCode.BLOB_PUT_FAILED, `artifact-store-api POST /blobs failed: ${response.status} ${response.statusText}`, { status: response.status, orgId });
|
|
33
|
+
}
|
|
34
|
+
const parsed = (await response.json());
|
|
35
|
+
const data = parsed.data;
|
|
36
|
+
if (!data || typeof data.sha256 !== 'string') {
|
|
37
|
+
throw new errors_1.PayloadCodecError(errors_1.PayloadCodecErrorCode.BLOB_PUT_FAILED, 'artifact-store-api POST /blobs: malformed response envelope.', { received: parsed });
|
|
38
|
+
}
|
|
39
|
+
const expectedSha = (0, blob_store_1.sha256Hex)(bytes);
|
|
40
|
+
if (data.sha256 !== expectedSha) {
|
|
41
|
+
throw new errors_1.PayloadCodecError(errors_1.PayloadCodecErrorCode.SHA256_MISMATCH, 'artifact-store-api returned a different sha256 than the client computed.', { expected: expectedSha, received: data.sha256 });
|
|
42
|
+
}
|
|
43
|
+
const uri = typeof data.uri === 'string' && data.uri.length > 0
|
|
44
|
+
? data.uri
|
|
45
|
+
: `artifact-store://${orgId}/${data.sha256}`;
|
|
46
|
+
const sizeBytes = typeof data.sizeBytes === 'number' ? data.sizeBytes : bytes.byteLength;
|
|
47
|
+
const contentTypeOut = typeof data.contentType === 'string' ? data.contentType : contentType;
|
|
48
|
+
const createdAt = typeof data.createdAt === 'string'
|
|
49
|
+
? data.createdAt
|
|
50
|
+
: new Date().toISOString();
|
|
51
|
+
return {
|
|
52
|
+
store: this.kind,
|
|
53
|
+
uri,
|
|
54
|
+
sha256: data.sha256,
|
|
55
|
+
orgId,
|
|
56
|
+
sizeBytes,
|
|
57
|
+
contentType: contentTypeOut,
|
|
58
|
+
createdAt,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
finally {
|
|
62
|
+
clearTimeout(timer);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
async get(ref) {
|
|
66
|
+
if (ref.store !== this.kind) {
|
|
67
|
+
throw new errors_1.PayloadCodecError(errors_1.PayloadCodecErrorCode.UNKNOWN_STORE_KIND, `HttpBlobStore cannot read blobs from store '${ref.store}'.`, { expected: this.kind, received: ref.store });
|
|
68
|
+
}
|
|
69
|
+
assertOrgId(ref.orgId);
|
|
70
|
+
const token = await this.options.tokenProvider();
|
|
71
|
+
const controller = new AbortController();
|
|
72
|
+
const timer = setTimeout(() => controller.abort(), this.options.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS);
|
|
73
|
+
try {
|
|
74
|
+
const response = (await fetch(this.resolveUrl(`${GET_PATH_PREFIX}${encodeURIComponent(ref.sha256)}`), {
|
|
75
|
+
method: 'GET',
|
|
76
|
+
headers: this.buildHeaders(token, 'application/octet-stream', ref.orgId),
|
|
77
|
+
signal: controller.signal,
|
|
78
|
+
}));
|
|
79
|
+
if (!response.ok) {
|
|
80
|
+
throw new errors_1.PayloadCodecError(errors_1.PayloadCodecErrorCode.BLOB_GET_FAILED, `artifact-store-api GET /blobs/${ref.sha256} failed: ${response.status} ${response.statusText}`, { status: response.status, sha256: ref.sha256, orgId: ref.orgId });
|
|
81
|
+
}
|
|
82
|
+
const buffer = new Uint8Array(await response.arrayBuffer());
|
|
83
|
+
const actualSha = (0, blob_store_1.sha256Hex)(buffer);
|
|
84
|
+
if (actualSha !== ref.sha256) {
|
|
85
|
+
throw new errors_1.PayloadCodecError(errors_1.PayloadCodecErrorCode.SHA256_MISMATCH, 'Blob fetched from artifact-store-api does not match the requested sha256.', { expected: ref.sha256, actual: actualSha });
|
|
86
|
+
}
|
|
87
|
+
return buffer;
|
|
88
|
+
}
|
|
89
|
+
finally {
|
|
90
|
+
clearTimeout(timer);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
async delete(ref) {
|
|
94
|
+
assertOrgId(ref.orgId);
|
|
95
|
+
const token = await this.options.tokenProvider();
|
|
96
|
+
const controller = new AbortController();
|
|
97
|
+
const timer = setTimeout(() => controller.abort(), this.options.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS);
|
|
98
|
+
try {
|
|
99
|
+
const response = (await fetch(this.resolveUrl(`${GET_PATH_PREFIX}${encodeURIComponent(ref.sha256)}`), {
|
|
100
|
+
method: 'DELETE',
|
|
101
|
+
headers: this.buildHeaders(token, 'application/octet-stream', ref.orgId),
|
|
102
|
+
signal: controller.signal,
|
|
103
|
+
}));
|
|
104
|
+
if (response.status === 204) {
|
|
105
|
+
return { deleted: true };
|
|
106
|
+
}
|
|
107
|
+
if (response.status === 404) {
|
|
108
|
+
return { deleted: false };
|
|
109
|
+
}
|
|
110
|
+
throw new errors_1.PayloadCodecError(errors_1.PayloadCodecErrorCode.BLOB_GET_FAILED, `artifact-store-api DELETE /blobs/${ref.sha256} failed: ${response.status} ${response.statusText}`, { status: response.status, sha256: ref.sha256, orgId: ref.orgId });
|
|
111
|
+
}
|
|
112
|
+
finally {
|
|
113
|
+
clearTimeout(timer);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
resolveUrl(path) {
|
|
117
|
+
const base = this.options.baseUrl.replace(/\/+$/, '');
|
|
118
|
+
return `${base}${path}`;
|
|
119
|
+
}
|
|
120
|
+
buildHeaders(token, contentType, orgId) {
|
|
121
|
+
const headers = new Headers({
|
|
122
|
+
Authorization: `Bearer ${token}`,
|
|
123
|
+
'Content-Type': contentType,
|
|
124
|
+
'X-Org-Id': orgId,
|
|
125
|
+
});
|
|
126
|
+
const correlationId = this.options.correlationIdProvider?.();
|
|
127
|
+
if (correlationId) {
|
|
128
|
+
headers.set('X-Correlation-Id', correlationId);
|
|
129
|
+
}
|
|
130
|
+
return headers;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
exports.HttpBlobStore = HttpBlobStore;
|
|
134
|
+
function assertOrgId(orgId) {
|
|
135
|
+
if (typeof orgId !== 'string' || orgId.length === 0) {
|
|
136
|
+
throw new errors_1.PayloadCodecError(errors_1.PayloadCodecErrorCode.ORG_ID_REQUIRED, 'HttpBlobStore operations require a non-empty orgId for X-Org-Id.');
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=http-blob-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-blob-store.js","sourceRoot":"","sources":["../../../src/payload-codec/lib/http-blob-store.ts"],"names":[],"mappings":";;;AAEA,mCAAwC;AACxC,qCAAoE;AACpE,6CAKsB;AAgBtB,MAAM,0BAA0B,GAAG,MAAM,CAAC;AAC1C,MAAM,QAAQ,GAAG,QAAQ,CAAC;AAC1B,MAAM,eAAe,GAAG,SAAS,CAAC;AAuBlC,MAAa,aAAa;IAGK;IAFpB,IAAI,GAAG,qBAAa,CAAC,cAAc,CAAC;IAE7C,YAA6B,OAA6B;QAA7B,YAAO,GAAP,OAAO,CAAsB;QACxD,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;QACzD,CAAC;IACH,CAAC;IAED,KAAK,CAAC,GAAG,CACP,KAAiB,EACjB,WAAmB,EACnB,KAAa;QAEb,WAAW,CAAC,KAAK,CAAC,CAAC;QACnB,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;QACjD,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;QACzC,MAAM,KAAK,GAAG,UAAU,CACtB,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,EACxB,IAAI,CAAC,OAAO,CAAC,gBAAgB,IAAI,0BAA0B,CAC5D,CAAC;QACF,IAAI,CAAC;YAIH,MAAM,QAAQ,GAAG,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE;gBACvD,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,WAAW,EAAE,KAAK,CAAC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C;QACJ,CAAC;gBAAS,CAAC;YACT,YAAY,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC;IACH,CAAC;IAEO,UAAU,CAAC,IAAY;QAC7B,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QACtD,OAAO,GAAG,IAAI,GAAG,IAAI,EAAE,CAAC;IAC1B,CAAC;IAEO,YAAY,CAAC,KAAa,EAAE,WAAmB,EAAE,KAAa;QACpE,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC;YAC1B,aAAa,EAAE,UAAU,KAAK,EAAE;YAChC,cAAc,EAAE,WAAW;YAC3B,UAAU,EAAE,KAAK;SAClB,CAAC,CAAC;QACH,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE,EAAE,CAAC;QAC7D,IAAI,aAAa,EAAE,CAAC;YAClB,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,aAAa,CAAC,CAAC;QACjD,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AArMD,sCAqMC;AAED,SAAS,WAAW,CAAC,KAAa;IAChC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACpD,MAAM,IAAI,0BAAiB,CACzB,8BAAqB,CAAC,eAAe,EACrC,kEAAkE,CACnE,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare class BytesLruCache {
|
|
2
|
+
private readonly capacityBytes;
|
|
3
|
+
private readonly entries;
|
|
4
|
+
private totalBytes;
|
|
5
|
+
constructor(capacityBytes: number);
|
|
6
|
+
get(key: string): Uint8Array | null;
|
|
7
|
+
put(key: string, value: Uint8Array): void;
|
|
8
|
+
clear(): void;
|
|
9
|
+
get size(): number;
|
|
10
|
+
get count(): number;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=lru-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lru-cache.d.ts","sourceRoot":"","sources":["../../../src/payload-codec/lib/lru-cache.ts"],"names":[],"mappings":"AAUA,qBAAa,aAAa;IAIZ,OAAO,CAAC,QAAQ,CAAC,aAAa;IAH1C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiC;IACzD,OAAO,CAAC,UAAU,CAAK;gBAEM,aAAa,EAAE,MAAM;IAUlD,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI;IAgBnC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI;IA0BzC,KAAK,IAAI,IAAI;IAMb,IAAI,IAAI,IAAI,MAAM,CAEjB;IAGD,IAAI,KAAK,IAAI,MAAM,CAElB;CACF"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BytesLruCache = void 0;
|
|
4
|
+
class BytesLruCache {
|
|
5
|
+
capacityBytes;
|
|
6
|
+
entries = new Map();
|
|
7
|
+
totalBytes = 0;
|
|
8
|
+
constructor(capacityBytes) {
|
|
9
|
+
this.capacityBytes = capacityBytes;
|
|
10
|
+
if (!Number.isFinite(capacityBytes) || capacityBytes < 0) {
|
|
11
|
+
throw new Error(`BytesLruCache: capacityBytes must be a non-negative finite number, got ${capacityBytes}.`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
get(key) {
|
|
15
|
+
const found = this.entries.get(key);
|
|
16
|
+
if (found === undefined) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
this.entries.delete(key);
|
|
20
|
+
this.entries.set(key, found);
|
|
21
|
+
return found;
|
|
22
|
+
}
|
|
23
|
+
put(key, value) {
|
|
24
|
+
if (value.byteLength > this.capacityBytes) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (this.entries.has(key)) {
|
|
28
|
+
const prev = this.entries.get(key);
|
|
29
|
+
this.totalBytes -= prev.byteLength;
|
|
30
|
+
this.entries.delete(key);
|
|
31
|
+
}
|
|
32
|
+
this.entries.set(key, value);
|
|
33
|
+
this.totalBytes += value.byteLength;
|
|
34
|
+
while (this.totalBytes > this.capacityBytes) {
|
|
35
|
+
const oldest = this.entries.keys().next();
|
|
36
|
+
if (oldest.done === true) {
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
const evicted = this.entries.get(oldest.value);
|
|
40
|
+
if (evicted === undefined) {
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
this.totalBytes -= evicted.byteLength;
|
|
44
|
+
this.entries.delete(oldest.value);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
clear() {
|
|
48
|
+
this.entries.clear();
|
|
49
|
+
this.totalBytes = 0;
|
|
50
|
+
}
|
|
51
|
+
get size() {
|
|
52
|
+
return this.totalBytes;
|
|
53
|
+
}
|
|
54
|
+
get count() {
|
|
55
|
+
return this.entries.size;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.BytesLruCache = BytesLruCache;
|
|
59
|
+
//# sourceMappingURL=lru-cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lru-cache.js","sourceRoot":"","sources":["../../../src/payload-codec/lib/lru-cache.ts"],"names":[],"mappings":";;;AAUA,MAAa,aAAa;IAIK;IAHZ,OAAO,GAAG,IAAI,GAAG,EAAsB,CAAC;IACjD,UAAU,GAAG,CAAC,CAAC;IAEvB,YAA6B,aAAqB;QAArB,kBAAa,GAAb,aAAa,CAAQ;QAChD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,aAAa,GAAG,CAAC,EAAE,CAAC;YACzD,MAAM,IAAI,KAAK,CAAC,0EAA0E,aAAa,GAAG,CAAC,CAAC;QAC9G,CAAC;IACH,CAAC;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E,CAAC;gBAC1B,MAAM;YACR,CAAC;YACD,IAAI,CAAC,UAAU,IAAI,OAAO,CAAC,UAAU,CAAC;YACtC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;IAGD,KAAK;QACH,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC;IACtB,CAAC;IAGD,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAGD,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;IAC3B,CAAC;CACF;AAtED,sCAsEC"}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://xema.dev/schemas/workflow/v1alpha1/Action.json",
|
|
4
|
+
"title": "Xema Action Manifest",
|
|
5
|
+
"description": "Declarative manifest for a single action version. Manifests live in plugins/software-dev/workflow-config/actions/ and are seeded into the workflow-engine action registry.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"required": ["apiVersion", "kind", "metadata", "spec"],
|
|
8
|
+
"additionalProperties": false,
|
|
9
|
+
"properties": {
|
|
10
|
+
"apiVersion": { "type": "string", "const": "xema.dev/workflow/v1alpha1" },
|
|
11
|
+
"kind": { "type": "string", "const": "Action" },
|
|
12
|
+
"metadata": { "$ref": "#/$defs/Metadata" },
|
|
13
|
+
"spec": { "$ref": "#/$defs/Spec" }
|
|
14
|
+
},
|
|
15
|
+
"$defs": {
|
|
16
|
+
"Metadata": {
|
|
17
|
+
"type": "object",
|
|
18
|
+
"required": ["id", "version"],
|
|
19
|
+
"additionalProperties": false,
|
|
20
|
+
"properties": {
|
|
21
|
+
"id": {
|
|
22
|
+
"type": "string",
|
|
23
|
+
"pattern": "^[a-z][a-z0-9-]*/[a-z][a-z0-9-]{0,62}$",
|
|
24
|
+
"description": "Canonical action id as `<namespace>/<actionId>`, e.g. `xema/agent` or `software-dev/scm-checkout`."
|
|
25
|
+
},
|
|
26
|
+
"version": {
|
|
27
|
+
"type": "string",
|
|
28
|
+
"pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+(-[A-Za-z0-9.-]+)?$"
|
|
29
|
+
},
|
|
30
|
+
"title": { "type": "string", "maxLength": 120 },
|
|
31
|
+
"description": { "type": "string", "maxLength": 4000 }
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"Spec": {
|
|
35
|
+
"type": "object",
|
|
36
|
+
"required": ["executionKind", "taskQueue", "inputs", "outputs", "permissions", "retryDefaults", "timeoutDefaults"],
|
|
37
|
+
"additionalProperties": false,
|
|
38
|
+
"properties": {
|
|
39
|
+
"executionKind": { "type": "string", "enum": ["activity", "child_workflow"] },
|
|
40
|
+
"taskQueue": { "type": "string", "enum": ["xema_default", "xema_agent", "xema_human"] },
|
|
41
|
+
"actionKind": {
|
|
42
|
+
"type": "string",
|
|
43
|
+
"description": "Semantic category — drives consumer presentation (FE canvas shape, badge icon). Optional; omitted manifests are treated as 'generic'. Closed list mirrors `ActionKind` in `@xemahq/workflow-contracts`.",
|
|
44
|
+
"enum": [
|
|
45
|
+
"agent",
|
|
46
|
+
"review",
|
|
47
|
+
"wait",
|
|
48
|
+
"timer",
|
|
49
|
+
"aggregate",
|
|
50
|
+
"dispatch",
|
|
51
|
+
"branch",
|
|
52
|
+
"loop",
|
|
53
|
+
"publish",
|
|
54
|
+
"notify",
|
|
55
|
+
"inquiry",
|
|
56
|
+
"fetch",
|
|
57
|
+
"transform",
|
|
58
|
+
"validate",
|
|
59
|
+
"terminate",
|
|
60
|
+
"generic"
|
|
61
|
+
]
|
|
62
|
+
},
|
|
63
|
+
"inputs": {
|
|
64
|
+
"type": "object",
|
|
65
|
+
"description": "JSON Schema (Draft 2020-12) for the action's `with:` arguments."
|
|
66
|
+
},
|
|
67
|
+
"outputs": {
|
|
68
|
+
"type": "object",
|
|
69
|
+
"description": "JSON Schema (Draft 2020-12) for the action's emitted outputs."
|
|
70
|
+
},
|
|
71
|
+
"outputBindings": {
|
|
72
|
+
"type": "object",
|
|
73
|
+
"description": "Optional per-output deliverable-spec bindings. Keys are output names declared in `outputs`. Each entry pins the output's payload shape to a deliverable spec; the DSL compiler reads this first for typed reach-in validation, falling back to the job-level `with.deliverableSpecRef` when absent.",
|
|
74
|
+
"additionalProperties": {
|
|
75
|
+
"type": "object",
|
|
76
|
+
"additionalProperties": false,
|
|
77
|
+
"properties": {
|
|
78
|
+
"deliverableSpecRef": {
|
|
79
|
+
"type": "string",
|
|
80
|
+
"description": "Canonical `<slug>@<version>` (e.g. `metrics-snapshot@1.0.0`).",
|
|
81
|
+
"pattern": "^[a-z][a-z0-9-]*@[0-9]+\\.[0-9]+\\.[0-9]+$"
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
"permissions": {
|
|
87
|
+
"type": "object",
|
|
88
|
+
"description": "Minimum permission scope this action requires.",
|
|
89
|
+
"additionalProperties": false,
|
|
90
|
+
"properties": {
|
|
91
|
+
"repos": { "type": "string", "enum": ["none", "read", "limited", "write"] },
|
|
92
|
+
"kb": { "type": "string", "enum": ["none", "read", "limited", "write"] },
|
|
93
|
+
"backlog": { "type": "string", "enum": ["none", "read", "limited", "write"] },
|
|
94
|
+
"integrations": { "type": "string", "enum": ["none", "read", "limited", "write"] },
|
|
95
|
+
"artifacts": { "type": "string", "enum": ["none", "read", "limited", "write"] }
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
"allowedMounts": {
|
|
99
|
+
"type": "array",
|
|
100
|
+
"items": { "type": "string", "pattern": "^[a-z][a-z0-9-]*$" },
|
|
101
|
+
"uniqueItems": true
|
|
102
|
+
},
|
|
103
|
+
"retryDefaults": {
|
|
104
|
+
"type": "object",
|
|
105
|
+
"required": ["maxAttempts", "initialInterval", "backoffCoefficient", "maximumInterval"],
|
|
106
|
+
"additionalProperties": false,
|
|
107
|
+
"properties": {
|
|
108
|
+
"maxAttempts": { "type": "integer", "minimum": 1, "maximum": 20 },
|
|
109
|
+
"initialInterval": { "type": "string", "pattern": "^([1-9][0-9]*)(s|m|h)$" },
|
|
110
|
+
"backoffCoefficient": { "type": "number", "minimum": 1.0, "maximum": 10.0 },
|
|
111
|
+
"maximumInterval": { "type": "string", "pattern": "^([1-9][0-9]*)(s|m|h)$" },
|
|
112
|
+
"nonRetryableErrorTypes": {
|
|
113
|
+
"type": "array",
|
|
114
|
+
"items": { "type": "string", "minLength": 1 }
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
"timeoutDefaults": {
|
|
119
|
+
"type": "object",
|
|
120
|
+
"required": ["startToClose"],
|
|
121
|
+
"additionalProperties": false,
|
|
122
|
+
"properties": {
|
|
123
|
+
"startToClose": { "type": "string", "pattern": "^([1-9][0-9]*)(s|m|h)$" },
|
|
124
|
+
"heartbeat": { "type": "string", "pattern": "^([1-9][0-9]*)(s|m|h)$" }
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
"auditEventMapping": {
|
|
128
|
+
"type": "object",
|
|
129
|
+
"description": "Mapping from step lifecycle to audit-log-api event code.",
|
|
130
|
+
"additionalProperties": false,
|
|
131
|
+
"properties": {
|
|
132
|
+
"started": { "type": "string", "minLength": 1 },
|
|
133
|
+
"succeeded": { "type": "string", "minLength": 1 },
|
|
134
|
+
"failed": { "type": "string", "minLength": 1 }
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
"consumes": {
|
|
138
|
+
"type": "array",
|
|
139
|
+
"description": "Declarative contracts the action opts into. The DSL compiler reads this list to decide which validation lanes apply — e.g. the `workspace-manifest@v1` entry enables the manifest-source triplet and the frontend canvas Inspector renders the manifest picker.",
|
|
140
|
+
"items": { "$ref": "#/$defs/ActionContract" }
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
"ActionContract": {
|
|
145
|
+
"description": "Versioned consume-contract declaration. Kinds: `workspace-manifest@v1` (manifest-source triplet) and `agent-composition@v1` (`with.composition` slug@version reference).",
|
|
146
|
+
"oneOf": [
|
|
147
|
+
{ "$ref": "#/$defs/WorkspaceManifestActionContract" },
|
|
148
|
+
{ "$ref": "#/$defs/AgentCompositionActionContract" }
|
|
149
|
+
]
|
|
150
|
+
},
|
|
151
|
+
"WorkspaceManifestActionContract": {
|
|
152
|
+
"type": "object",
|
|
153
|
+
"required": ["kind", "version"],
|
|
154
|
+
"additionalProperties": false,
|
|
155
|
+
"properties": {
|
|
156
|
+
"kind": { "type": "string", "const": "workspace-manifest" },
|
|
157
|
+
"version": { "type": "string", "const": "v1" },
|
|
158
|
+
"surfaces": {
|
|
159
|
+
"type": "array",
|
|
160
|
+
"description": "Restricts the surfaces the action can be invoked on. Must intersect the manifest's `metadata.surfaceCompat`.",
|
|
161
|
+
"items": { "type": "string", "enum": ["workflow", "agent-session"] },
|
|
162
|
+
"uniqueItems": true
|
|
163
|
+
},
|
|
164
|
+
"roleHint": {
|
|
165
|
+
"type": "string",
|
|
166
|
+
"description": "Pins the manifest's `spec.agent.role` to a closed `AgentRunRole`. Compile-time fail when a workflow points the action at a manifest whose role doesn't match."
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
"AgentCompositionActionContract": {
|
|
171
|
+
"type": "object",
|
|
172
|
+
"required": ["kind", "version"],
|
|
173
|
+
"additionalProperties": false,
|
|
174
|
+
"description": "Opts the action into the `with.composition` field — a `slug@version` reference to an Agent Composition resolved at dispatch time by the runtime.",
|
|
175
|
+
"properties": {
|
|
176
|
+
"kind": { "type": "string", "const": "agent-composition" },
|
|
177
|
+
"version": { "type": "string", "const": "v1" }
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://xema.dev/schemas/workflow/v1alpha1/ReusableWorkflow.json",
|
|
4
|
+
"title": "Xema Reusable Workflow",
|
|
5
|
+
"description": "A workflow invoked via `workflow_call` from another workflow. Must declare `on.workflow_call`.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"required": ["apiVersion", "kind", "metadata", "on", "jobs"],
|
|
8
|
+
"additionalProperties": false,
|
|
9
|
+
"properties": {
|
|
10
|
+
"apiVersion": { "type": "string", "const": "xema.dev/workflow/v1alpha1" },
|
|
11
|
+
"kind": { "type": "string", "const": "Workflow" },
|
|
12
|
+
"metadata": {
|
|
13
|
+
"$ref": "https://xema.dev/schemas/workflow/v1alpha1/Workflow.json#/$defs/Metadata"
|
|
14
|
+
},
|
|
15
|
+
"on": {
|
|
16
|
+
"type": "object",
|
|
17
|
+
"required": ["workflow_call"],
|
|
18
|
+
"additionalProperties": false,
|
|
19
|
+
"properties": {
|
|
20
|
+
"workflow_call": {
|
|
21
|
+
"$ref": "https://xema.dev/schemas/workflow/v1alpha1/Workflow.json#/$defs/WorkflowCallTrigger"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"concurrency": {
|
|
26
|
+
"$ref": "https://xema.dev/schemas/workflow/v1alpha1/Workflow.json#/$defs/Concurrency"
|
|
27
|
+
},
|
|
28
|
+
"defaults": {
|
|
29
|
+
"$ref": "https://xema.dev/schemas/workflow/v1alpha1/Workflow.json#/$defs/Defaults"
|
|
30
|
+
},
|
|
31
|
+
"permissions": {
|
|
32
|
+
"$ref": "https://xema.dev/schemas/workflow/v1alpha1/Workflow.json#/$defs/Permissions"
|
|
33
|
+
},
|
|
34
|
+
"vars": { "type": "object", "additionalProperties": true },
|
|
35
|
+
"jobs": {
|
|
36
|
+
"type": "object",
|
|
37
|
+
"minProperties": 1,
|
|
38
|
+
"additionalProperties": {
|
|
39
|
+
"$ref": "https://xema.dev/schemas/workflow/v1alpha1/Workflow.json#/$defs/Job"
|
|
40
|
+
},
|
|
41
|
+
"propertyNames": {
|
|
42
|
+
"$ref": "https://xema.dev/schemas/workflow/v1alpha1/Workflow.json#/$defs/JobKey"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|