@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.
Files changed (288) hide show
  1. package/LICENSE +201 -0
  2. package/dist/deliverable-spec/index.d.ts +3 -0
  3. package/dist/deliverable-spec/index.d.ts.map +1 -0
  4. package/dist/deliverable-spec/index.js +19 -0
  5. package/dist/deliverable-spec/index.js.map +1 -0
  6. package/dist/deliverable-spec/lib/schema.d.ts +151 -0
  7. package/dist/deliverable-spec/lib/schema.d.ts.map +1 -0
  8. package/dist/deliverable-spec/lib/schema.js +139 -0
  9. package/dist/deliverable-spec/lib/schema.js.map +1 -0
  10. package/dist/deliverable-spec/lib/types.d.ts +8 -0
  11. package/dist/deliverable-spec/lib/types.d.ts.map +1 -0
  12. package/dist/deliverable-spec/lib/types.js +3 -0
  13. package/dist/deliverable-spec/lib/types.js.map +1 -0
  14. package/dist/payload-codec/index.d.ts +8 -0
  15. package/dist/payload-codec/index.d.ts.map +1 -0
  16. package/dist/payload-codec/index.js +27 -0
  17. package/dist/payload-codec/index.js.map +1 -0
  18. package/dist/payload-codec/lib/blob-store.d.ts +37 -0
  19. package/dist/payload-codec/lib/blob-store.d.ts.map +1 -0
  20. package/dist/payload-codec/lib/blob-store.js +0 -0
  21. package/dist/payload-codec/lib/blob-store.js.map +1 -0
  22. package/dist/payload-codec/lib/codec-context.d.ts +6 -0
  23. package/dist/payload-codec/lib/codec-context.d.ts.map +1 -0
  24. package/dist/payload-codec/lib/codec-context.js +16 -0
  25. package/dist/payload-codec/lib/codec-context.js.map +1 -0
  26. package/dist/payload-codec/lib/codec.d.ts +51 -0
  27. package/dist/payload-codec/lib/codec.d.ts.map +1 -0
  28. package/dist/payload-codec/lib/codec.js +330 -0
  29. package/dist/payload-codec/lib/codec.js.map +1 -0
  30. package/dist/payload-codec/lib/enums.d.ts +18 -0
  31. package/dist/payload-codec/lib/enums.d.ts.map +1 -0
  32. package/dist/payload-codec/lib/enums.js +23 -0
  33. package/dist/payload-codec/lib/enums.js.map +1 -0
  34. package/dist/payload-codec/lib/errors.d.ts +18 -0
  35. package/dist/payload-codec/lib/errors.d.ts.map +1 -0
  36. package/dist/payload-codec/lib/errors.js +39 -0
  37. package/dist/payload-codec/lib/errors.js.map +1 -0
  38. package/dist/payload-codec/lib/http-blob-store.d.ts +21 -0
  39. package/dist/payload-codec/lib/http-blob-store.d.ts.map +1 -0
  40. package/dist/payload-codec/lib/http-blob-store.js +139 -0
  41. package/dist/payload-codec/lib/http-blob-store.js.map +1 -0
  42. package/dist/payload-codec/lib/lru-cache.d.ts +12 -0
  43. package/dist/payload-codec/lib/lru-cache.d.ts.map +1 -0
  44. package/dist/payload-codec/lib/lru-cache.js +59 -0
  45. package/dist/payload-codec/lib/lru-cache.js.map +1 -0
  46. package/dist/schema/action.schema.json +181 -0
  47. package/dist/schema/reusable-workflow.schema.json +46 -0
  48. package/dist/schema/workflow.schema.json +373 -0
  49. package/dist/workflow/index.d.ts +14 -0
  50. package/dist/workflow/index.d.ts.map +1 -0
  51. package/dist/workflow/index.js +49 -0
  52. package/dist/workflow/index.js.map +1 -0
  53. package/dist/workflow/lib/action-input-validator.d.ts +10 -0
  54. package/dist/workflow/lib/action-input-validator.d.ts.map +1 -0
  55. package/dist/workflow/lib/action-input-validator.js +69 -0
  56. package/dist/workflow/lib/action-input-validator.js.map +1 -0
  57. package/dist/workflow/lib/compiler/action-shape.d.ts +5 -0
  58. package/dist/workflow/lib/compiler/action-shape.d.ts.map +1 -0
  59. package/dist/workflow/lib/compiler/action-shape.js +43 -0
  60. package/dist/workflow/lib/compiler/action-shape.js.map +1 -0
  61. package/dist/workflow/lib/compiler/canonical-json.d.ts +3 -0
  62. package/dist/workflow/lib/compiler/canonical-json.d.ts.map +1 -0
  63. package/dist/workflow/lib/compiler/canonical-json.js +45 -0
  64. package/dist/workflow/lib/compiler/canonical-json.js.map +1 -0
  65. package/dist/workflow/lib/compiler/compile.d.ts +4 -0
  66. package/dist/workflow/lib/compiler/compile.d.ts.map +1 -0
  67. package/dist/workflow/lib/compiler/compile.js +794 -0
  68. package/dist/workflow/lib/compiler/compile.js.map +1 -0
  69. package/dist/workflow/lib/compiler/concurrency.d.ts +5 -0
  70. package/dist/workflow/lib/compiler/concurrency.d.ts.map +1 -0
  71. package/dist/workflow/lib/compiler/concurrency.js +104 -0
  72. package/dist/workflow/lib/compiler/concurrency.js.map +1 -0
  73. package/dist/workflow/lib/compiler/dag.d.ts +10 -0
  74. package/dist/workflow/lib/compiler/dag.d.ts.map +1 -0
  75. package/dist/workflow/lib/compiler/dag.js +74 -0
  76. package/dist/workflow/lib/compiler/dag.js.map +1 -0
  77. package/dist/workflow/lib/compiler/index.d.ts +6 -0
  78. package/dist/workflow/lib/compiler/index.d.ts.map +1 -0
  79. package/dist/workflow/lib/compiler/index.js +14 -0
  80. package/dist/workflow/lib/compiler/index.js.map +1 -0
  81. package/dist/workflow/lib/compiler/inputs.d.ts +4 -0
  82. package/dist/workflow/lib/compiler/inputs.d.ts.map +1 -0
  83. package/dist/workflow/lib/compiler/inputs.js +108 -0
  84. package/dist/workflow/lib/compiler/inputs.js.map +1 -0
  85. package/dist/workflow/lib/compiler/installation-resource-validator.d.ts +9 -0
  86. package/dist/workflow/lib/compiler/installation-resource-validator.d.ts.map +1 -0
  87. package/dist/workflow/lib/compiler/installation-resource-validator.js +76 -0
  88. package/dist/workflow/lib/compiler/installation-resource-validator.js.map +1 -0
  89. package/dist/workflow/lib/compiler/manifest-source.d.ts +4 -0
  90. package/dist/workflow/lib/compiler/manifest-source.d.ts.map +1 -0
  91. package/dist/workflow/lib/compiler/manifest-source.js +100 -0
  92. package/dist/workflow/lib/compiler/manifest-source.js.map +1 -0
  93. package/dist/workflow/lib/compiler/matrix.d.ts +4 -0
  94. package/dist/workflow/lib/compiler/matrix.d.ts.map +1 -0
  95. package/dist/workflow/lib/compiler/matrix.js +76 -0
  96. package/dist/workflow/lib/compiler/matrix.js.map +1 -0
  97. package/dist/workflow/lib/compiler/mount-plan.d.ts +4 -0
  98. package/dist/workflow/lib/compiler/mount-plan.d.ts.map +1 -0
  99. package/dist/workflow/lib/compiler/mount-plan.js +96 -0
  100. package/dist/workflow/lib/compiler/mount-plan.js.map +1 -0
  101. package/dist/workflow/lib/compiler/payload-reach-in.d.ts +14 -0
  102. package/dist/workflow/lib/compiler/payload-reach-in.d.ts.map +1 -0
  103. package/dist/workflow/lib/compiler/payload-reach-in.js +273 -0
  104. package/dist/workflow/lib/compiler/payload-reach-in.js.map +1 -0
  105. package/dist/workflow/lib/compiler/permissions.d.ts +6 -0
  106. package/dist/workflow/lib/compiler/permissions.d.ts.map +1 -0
  107. package/dist/workflow/lib/compiler/permissions.js +43 -0
  108. package/dist/workflow/lib/compiler/permissions.js.map +1 -0
  109. package/dist/workflow/lib/compiler/retry-timeout.d.ts +6 -0
  110. package/dist/workflow/lib/compiler/retry-timeout.d.ts.map +1 -0
  111. package/dist/workflow/lib/compiler/retry-timeout.js +64 -0
  112. package/dist/workflow/lib/compiler/retry-timeout.js.map +1 -0
  113. package/dist/workflow/lib/compiler/review-step.d.ts +18 -0
  114. package/dist/workflow/lib/compiler/review-step.d.ts.map +1 -0
  115. package/dist/workflow/lib/compiler/review-step.js +247 -0
  116. package/dist/workflow/lib/compiler/review-step.js.map +1 -0
  117. package/dist/workflow/lib/compiler/types.d.ts +42 -0
  118. package/dist/workflow/lib/compiler/types.d.ts.map +1 -0
  119. package/dist/workflow/lib/compiler/types.js +3 -0
  120. package/dist/workflow/lib/compiler/types.js.map +1 -0
  121. package/dist/workflow/lib/compiler/variable-requirements.d.ts +5 -0
  122. package/dist/workflow/lib/compiler/variable-requirements.d.ts.map +1 -0
  123. package/dist/workflow/lib/compiler/variable-requirements.js +119 -0
  124. package/dist/workflow/lib/compiler/variable-requirements.js.map +1 -0
  125. package/dist/workflow/lib/deliverable-spec-keys.d.ts +3 -0
  126. package/dist/workflow/lib/deliverable-spec-keys.d.ts.map +1 -0
  127. package/dist/workflow/lib/deliverable-spec-keys.js +90 -0
  128. package/dist/workflow/lib/deliverable-spec-keys.js.map +1 -0
  129. package/dist/workflow/lib/dispatch-inputs/index.d.ts +23 -0
  130. package/dist/workflow/lib/dispatch-inputs/index.d.ts.map +1 -0
  131. package/dist/workflow/lib/dispatch-inputs/index.js +106 -0
  132. package/dist/workflow/lib/dispatch-inputs/index.js.map +1 -0
  133. package/dist/workflow/lib/dispatch-inputs/to-json-schema.d.ts +3 -0
  134. package/dist/workflow/lib/dispatch-inputs/to-json-schema.d.ts.map +1 -0
  135. package/dist/workflow/lib/dispatch-inputs/to-json-schema.js +43 -0
  136. package/dist/workflow/lib/dispatch-inputs/to-json-schema.js.map +1 -0
  137. package/dist/workflow/lib/duration.d.ts +2 -0
  138. package/dist/workflow/lib/duration.d.ts.map +1 -0
  139. package/dist/workflow/lib/duration.js +26 -0
  140. package/dist/workflow/lib/duration.js.map +1 -0
  141. package/dist/workflow/lib/errors.d.ts +9 -0
  142. package/dist/workflow/lib/errors.d.ts.map +1 -0
  143. package/dist/workflow/lib/errors.js +28 -0
  144. package/dist/workflow/lib/errors.js.map +1 -0
  145. package/dist/workflow/lib/expression/ast.d.ts +61 -0
  146. package/dist/workflow/lib/expression/ast.d.ts.map +1 -0
  147. package/dist/workflow/lib/expression/ast.js +34 -0
  148. package/dist/workflow/lib/expression/ast.js.map +1 -0
  149. package/dist/workflow/lib/expression/context.d.ts +63 -0
  150. package/dist/workflow/lib/expression/context.d.ts.map +1 -0
  151. package/dist/workflow/lib/expression/context.js +32 -0
  152. package/dist/workflow/lib/expression/context.js.map +1 -0
  153. package/dist/workflow/lib/expression/evaluator.d.ts +5 -0
  154. package/dist/workflow/lib/expression/evaluator.d.ts.map +1 -0
  155. package/dist/workflow/lib/expression/evaluator.js +291 -0
  156. package/dist/workflow/lib/expression/evaluator.js.map +1 -0
  157. package/dist/workflow/lib/expression/index.d.ts +9 -0
  158. package/dist/workflow/lib/expression/index.d.ts.map +1 -0
  159. package/dist/workflow/lib/expression/index.js +26 -0
  160. package/dist/workflow/lib/expression/index.js.map +1 -0
  161. package/dist/workflow/lib/expression/interpolation.d.ts +9 -0
  162. package/dist/workflow/lib/expression/interpolation.d.ts.map +1 -0
  163. package/dist/workflow/lib/expression/interpolation.js +51 -0
  164. package/dist/workflow/lib/expression/interpolation.js.map +1 -0
  165. package/dist/workflow/lib/expression/parser.d.ts +4 -0
  166. package/dist/workflow/lib/expression/parser.d.ts.map +1 -0
  167. package/dist/workflow/lib/expression/parser.js +203 -0
  168. package/dist/workflow/lib/expression/parser.js.map +1 -0
  169. package/dist/workflow/lib/expression/template.d.ts +18 -0
  170. package/dist/workflow/lib/expression/template.d.ts.map +1 -0
  171. package/dist/workflow/lib/expression/template.js +63 -0
  172. package/dist/workflow/lib/expression/template.js.map +1 -0
  173. package/dist/workflow/lib/expression/tokenizer.d.ts +3 -0
  174. package/dist/workflow/lib/expression/tokenizer.d.ts.map +1 -0
  175. package/dist/workflow/lib/expression/tokenizer.js +153 -0
  176. package/dist/workflow/lib/expression/tokenizer.js.map +1 -0
  177. package/dist/workflow/lib/expression/tokens.d.ts +25 -0
  178. package/dist/workflow/lib/expression/tokens.d.ts.map +1 -0
  179. package/dist/workflow/lib/expression/tokens.js +24 -0
  180. package/dist/workflow/lib/expression/tokens.js.map +1 -0
  181. package/dist/workflow/lib/expression/walk-artifact-refs.d.ts +5 -0
  182. package/dist/workflow/lib/expression/walk-artifact-refs.d.ts.map +1 -0
  183. package/dist/workflow/lib/expression/walk-artifact-refs.js +138 -0
  184. package/dist/workflow/lib/expression/walk-artifact-refs.js.map +1 -0
  185. package/dist/workflow/lib/installation-resource-kind.d.ts +14 -0
  186. package/dist/workflow/lib/installation-resource-kind.d.ts.map +1 -0
  187. package/dist/workflow/lib/installation-resource-kind.js +59 -0
  188. package/dist/workflow/lib/installation-resource-kind.js.map +1 -0
  189. package/dist/workflow/lib/schemas-loader.d.ts +4 -0
  190. package/dist/workflow/lib/schemas-loader.d.ts.map +1 -0
  191. package/dist/workflow/lib/schemas-loader.js +36 -0
  192. package/dist/workflow/lib/schemas-loader.js.map +1 -0
  193. package/dist/workflow/lib/serializer.d.ts +3 -0
  194. package/dist/workflow/lib/serializer.d.ts.map +1 -0
  195. package/dist/workflow/lib/serializer.js +15 -0
  196. package/dist/workflow/lib/serializer.js.map +1 -0
  197. package/dist/workflow/lib/types.d.ts +179 -0
  198. package/dist/workflow/lib/types.d.ts.map +1 -0
  199. package/dist/workflow/lib/types.js +3 -0
  200. package/dist/workflow/lib/types.js.map +1 -0
  201. package/dist/workflow/lib/validate.d.ts +8 -0
  202. package/dist/workflow/lib/validate.d.ts.map +1 -0
  203. package/dist/workflow/lib/validate.js +119 -0
  204. package/dist/workflow/lib/validate.js.map +1 -0
  205. package/dist/workspace-manifest/index.d.ts +6 -0
  206. package/dist/workspace-manifest/index.d.ts.map +1 -0
  207. package/dist/workspace-manifest/index.js +22 -0
  208. package/dist/workspace-manifest/index.js.map +1 -0
  209. package/dist/workspace-manifest/lib/compile.d.ts +8 -0
  210. package/dist/workspace-manifest/lib/compile.d.ts.map +1 -0
  211. package/dist/workspace-manifest/lib/compile.js +439 -0
  212. package/dist/workspace-manifest/lib/compile.js.map +1 -0
  213. package/dist/workspace-manifest/lib/interpolate.d.ts +12 -0
  214. package/dist/workspace-manifest/lib/interpolate.d.ts.map +1 -0
  215. package/dist/workspace-manifest/lib/interpolate.js +81 -0
  216. package/dist/workspace-manifest/lib/interpolate.js.map +1 -0
  217. package/dist/workspace-manifest/lib/resolve-extends.d.ts +10 -0
  218. package/dist/workspace-manifest/lib/resolve-extends.d.ts.map +1 -0
  219. package/dist/workspace-manifest/lib/resolve-extends.js +108 -0
  220. package/dist/workspace-manifest/lib/resolve-extends.js.map +1 -0
  221. package/dist/workspace-manifest/lib/schema.d.ts +710 -0
  222. package/dist/workspace-manifest/lib/schema.d.ts.map +1 -0
  223. package/dist/workspace-manifest/lib/schema.js +355 -0
  224. package/dist/workspace-manifest/lib/schema.js.map +1 -0
  225. package/dist/workspace-manifest/lib/types.d.ts +153 -0
  226. package/dist/workspace-manifest/lib/types.d.ts.map +1 -0
  227. package/dist/workspace-manifest/lib/types.js +10 -0
  228. package/dist/workspace-manifest/lib/types.js.map +1 -0
  229. package/package.json +79 -0
  230. package/schema/action.schema.json +181 -0
  231. package/schema/reusable-workflow.schema.json +46 -0
  232. package/schema/workflow.schema.json +373 -0
  233. package/src/deliverable-spec/index.ts +19 -0
  234. package/src/deliverable-spec/lib/schema.ts +248 -0
  235. package/src/deliverable-spec/lib/types.ts +26 -0
  236. package/src/payload-codec/index.ts +40 -0
  237. package/src/payload-codec/lib/blob-store.ts +0 -0
  238. package/src/payload-codec/lib/codec-context.ts +38 -0
  239. package/src/payload-codec/lib/codec.ts +593 -0
  240. package/src/payload-codec/lib/enums.ts +58 -0
  241. package/src/payload-codec/lib/errors.ts +54 -0
  242. package/src/payload-codec/lib/http-blob-store.ts +257 -0
  243. package/src/payload-codec/lib/lru-cache.ts +81 -0
  244. package/src/workflow/index.ts +98 -0
  245. package/src/workflow/lib/action-input-validator.ts +160 -0
  246. package/src/workflow/lib/compiler/action-shape.ts +71 -0
  247. package/src/workflow/lib/compiler/canonical-json.ts +53 -0
  248. package/src/workflow/lib/compiler/compile.ts +1518 -0
  249. package/src/workflow/lib/compiler/concurrency.ts +223 -0
  250. package/src/workflow/lib/compiler/dag.ts +108 -0
  251. package/src/workflow/lib/compiler/index.ts +10 -0
  252. package/src/workflow/lib/compiler/inputs.ts +199 -0
  253. package/src/workflow/lib/compiler/installation-resource-validator.ts +114 -0
  254. package/src/workflow/lib/compiler/manifest-source.ts +176 -0
  255. package/src/workflow/lib/compiler/matrix.ts +135 -0
  256. package/src/workflow/lib/compiler/mount-plan.ts +202 -0
  257. package/src/workflow/lib/compiler/payload-reach-in.ts +497 -0
  258. package/src/workflow/lib/compiler/permissions.ts +64 -0
  259. package/src/workflow/lib/compiler/retry-timeout.ts +105 -0
  260. package/src/workflow/lib/compiler/review-step.ts +517 -0
  261. package/src/workflow/lib/compiler/types.ts +170 -0
  262. package/src/workflow/lib/compiler/variable-requirements.ts +208 -0
  263. package/src/workflow/lib/deliverable-spec-keys.ts +109 -0
  264. package/src/workflow/lib/dispatch-inputs/index.ts +160 -0
  265. package/src/workflow/lib/dispatch-inputs/to-json-schema.ts +60 -0
  266. package/src/workflow/lib/duration.ts +48 -0
  267. package/src/workflow/lib/errors.ts +37 -0
  268. package/src/workflow/lib/expression/ast.ts +108 -0
  269. package/src/workflow/lib/expression/context.ts +148 -0
  270. package/src/workflow/lib/expression/evaluator.ts +492 -0
  271. package/src/workflow/lib/expression/index.ts +28 -0
  272. package/src/workflow/lib/expression/interpolation.ts +84 -0
  273. package/src/workflow/lib/expression/parser.ts +264 -0
  274. package/src/workflow/lib/expression/template.ts +117 -0
  275. package/src/workflow/lib/expression/tokenizer.ts +200 -0
  276. package/src/workflow/lib/expression/tokens.ts +30 -0
  277. package/src/workflow/lib/expression/walk-artifact-refs.ts +232 -0
  278. package/src/workflow/lib/installation-resource-kind.ts +107 -0
  279. package/src/workflow/lib/schemas-loader.ts +64 -0
  280. package/src/workflow/lib/serializer.ts +30 -0
  281. package/src/workflow/lib/types.ts +361 -0
  282. package/src/workflow/lib/validate.ts +199 -0
  283. package/src/workspace-manifest/index.ts +27 -0
  284. package/src/workspace-manifest/lib/compile.ts +608 -0
  285. package/src/workspace-manifest/lib/interpolate.ts +140 -0
  286. package/src/workspace-manifest/lib/resolve-extends.ts +260 -0
  287. package/src/workspace-manifest/lib/schema.ts +612 -0
  288. 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,0B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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-cod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AU,CAAC;QACpC,OAAO,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;YAC5C,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;YAC1C,IAAI,MAAM,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;gBACzB,MAAM;YACR,CAAC;YACD,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC/C,IAAI,OAAO,KAAK,SAAS,EAAE,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
+ }