@ajna-inc/workflow 0.5.17

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 (139) hide show
  1. package/build/WorkflowEvents.d.ts +35 -0
  2. package/build/WorkflowEvents.js +10 -0
  3. package/build/WorkflowEvents.js.map +1 -0
  4. package/build/WorkflowModule.d.ts +13 -0
  5. package/build/WorkflowModule.js +459 -0
  6. package/build/WorkflowModule.js.map +1 -0
  7. package/build/WorkflowModuleConfig.d.ts +33 -0
  8. package/build/WorkflowModuleConfig.js +18 -0
  9. package/build/WorkflowModuleConfig.js.map +1 -0
  10. package/build/actions/ActionRegistry.d.ts +35 -0
  11. package/build/actions/ActionRegistry.js +193 -0
  12. package/build/actions/ActionRegistry.js.map +1 -0
  13. package/build/api/WorkflowApi.d.ts +57 -0
  14. package/build/api/WorkflowApi.js +50 -0
  15. package/build/api/WorkflowApi.js.map +1 -0
  16. package/build/engine/AttributePlanner.d.ts +7 -0
  17. package/build/engine/AttributePlanner.js +81 -0
  18. package/build/engine/AttributePlanner.js.map +1 -0
  19. package/build/engine/GuardEvaluator.d.ts +11 -0
  20. package/build/engine/GuardEvaluator.js +40 -0
  21. package/build/engine/GuardEvaluator.js.map +1 -0
  22. package/build/index.d.ts +45 -0
  23. package/build/index.js +69 -0
  24. package/build/index.js.map +1 -0
  25. package/build/model/TemplateValidation.d.ts +3 -0
  26. package/build/model/TemplateValidation.js +231 -0
  27. package/build/model/TemplateValidation.js.map +1 -0
  28. package/build/model/types.d.ts +116 -0
  29. package/build/model/types.js +15 -0
  30. package/build/model/types.js.map +1 -0
  31. package/build/protocol/WorkflowMessageTypes.d.ts +15 -0
  32. package/build/protocol/WorkflowMessageTypes.js +22 -0
  33. package/build/protocol/WorkflowMessageTypes.js.map +1 -0
  34. package/build/protocol/handlers/AdvanceHandler.d.ts +12 -0
  35. package/build/protocol/handlers/AdvanceHandler.js +113 -0
  36. package/build/protocol/handlers/AdvanceHandler.js.map +1 -0
  37. package/build/protocol/handlers/CancelHandler.d.ts +12 -0
  38. package/build/protocol/handlers/CancelHandler.js +116 -0
  39. package/build/protocol/handlers/CancelHandler.js.map +1 -0
  40. package/build/protocol/handlers/CompleteHandler.d.ts +12 -0
  41. package/build/protocol/handlers/CompleteHandler.js +117 -0
  42. package/build/protocol/handlers/CompleteHandler.js.map +1 -0
  43. package/build/protocol/handlers/DiscoverHandler.d.ts +11 -0
  44. package/build/protocol/handlers/DiscoverHandler.js +71 -0
  45. package/build/protocol/handlers/DiscoverHandler.js.map +1 -0
  46. package/build/protocol/handlers/FetchTemplateHandler.d.ts +12 -0
  47. package/build/protocol/handlers/FetchTemplateHandler.js +71 -0
  48. package/build/protocol/handlers/FetchTemplateHandler.js.map +1 -0
  49. package/build/protocol/handlers/PauseHandler.d.ts +12 -0
  50. package/build/protocol/handlers/PauseHandler.js +116 -0
  51. package/build/protocol/handlers/PauseHandler.js.map +1 -0
  52. package/build/protocol/handlers/ProblemReportHandler.d.ts +6 -0
  53. package/build/protocol/handlers/ProblemReportHandler.js +28 -0
  54. package/build/protocol/handlers/ProblemReportHandler.js.map +1 -0
  55. package/build/protocol/handlers/PublishTemplateHandler.d.ts +11 -0
  56. package/build/protocol/handlers/PublishTemplateHandler.js +53 -0
  57. package/build/protocol/handlers/PublishTemplateHandler.js.map +1 -0
  58. package/build/protocol/handlers/ResumeHandler.d.ts +12 -0
  59. package/build/protocol/handlers/ResumeHandler.js +116 -0
  60. package/build/protocol/handlers/ResumeHandler.js.map +1 -0
  61. package/build/protocol/handlers/StartHandler.d.ts +12 -0
  62. package/build/protocol/handlers/StartHandler.js +211 -0
  63. package/build/protocol/handlers/StartHandler.js.map +1 -0
  64. package/build/protocol/handlers/StatusHandler.d.ts +12 -0
  65. package/build/protocol/handlers/StatusHandler.js +100 -0
  66. package/build/protocol/handlers/StatusHandler.js.map +1 -0
  67. package/build/protocol/handlers/TemplateHandler.d.ts +9 -0
  68. package/build/protocol/handlers/TemplateHandler.js +43 -0
  69. package/build/protocol/handlers/TemplateHandler.js.map +1 -0
  70. package/build/protocol/messages/AdvanceMessage.d.ts +15 -0
  71. package/build/protocol/messages/AdvanceMessage.js +33 -0
  72. package/build/protocol/messages/AdvanceMessage.js.map +1 -0
  73. package/build/protocol/messages/CancelMessage.d.ts +14 -0
  74. package/build/protocol/messages/CancelMessage.js +33 -0
  75. package/build/protocol/messages/CancelMessage.js.map +1 -0
  76. package/build/protocol/messages/CompleteMessage.d.ts +14 -0
  77. package/build/protocol/messages/CompleteMessage.js +33 -0
  78. package/build/protocol/messages/CompleteMessage.js.map +1 -0
  79. package/build/protocol/messages/DiscoverMessage.d.ts +23 -0
  80. package/build/protocol/messages/DiscoverMessage.js +33 -0
  81. package/build/protocol/messages/DiscoverMessage.js.map +1 -0
  82. package/build/protocol/messages/FetchTemplateMessage.d.ts +15 -0
  83. package/build/protocol/messages/FetchTemplateMessage.js +33 -0
  84. package/build/protocol/messages/FetchTemplateMessage.js.map +1 -0
  85. package/build/protocol/messages/PauseMessage.d.ts +14 -0
  86. package/build/protocol/messages/PauseMessage.js +33 -0
  87. package/build/protocol/messages/PauseMessage.js.map +1 -0
  88. package/build/protocol/messages/ProblemReportMessage.d.ts +15 -0
  89. package/build/protocol/messages/ProblemReportMessage.js +33 -0
  90. package/build/protocol/messages/ProblemReportMessage.js.map +1 -0
  91. package/build/protocol/messages/PublishTemplateMessage.d.ts +17 -0
  92. package/build/protocol/messages/PublishTemplateMessage.js +31 -0
  93. package/build/protocol/messages/PublishTemplateMessage.js.map +1 -0
  94. package/build/protocol/messages/ResumeMessage.d.ts +14 -0
  95. package/build/protocol/messages/ResumeMessage.js +33 -0
  96. package/build/protocol/messages/ResumeMessage.js.map +1 -0
  97. package/build/protocol/messages/StartMessage.d.ts +21 -0
  98. package/build/protocol/messages/StartMessage.js +33 -0
  99. package/build/protocol/messages/StartMessage.js.map +1 -0
  100. package/build/protocol/messages/StatusMessage.d.ts +23 -0
  101. package/build/protocol/messages/StatusMessage.js +33 -0
  102. package/build/protocol/messages/StatusMessage.js.map +1 -0
  103. package/build/protocol/messages/StatusRequestMessage.d.ts +15 -0
  104. package/build/protocol/messages/StatusRequestMessage.js +33 -0
  105. package/build/protocol/messages/StatusRequestMessage.js.map +1 -0
  106. package/build/protocol/messages/TemplateMessage.d.ts +14 -0
  107. package/build/protocol/messages/TemplateMessage.js +33 -0
  108. package/build/protocol/messages/TemplateMessage.js.map +1 -0
  109. package/build/protocol/messages/WorkflowsMessage.d.ts +22 -0
  110. package/build/protocol/messages/WorkflowsMessage.js +33 -0
  111. package/build/protocol/messages/WorkflowsMessage.js.map +1 -0
  112. package/build/queue/CommandQueue.d.ts +17 -0
  113. package/build/queue/CommandQueue.js +8 -0
  114. package/build/queue/CommandQueue.js.map +1 -0
  115. package/build/queue/PersistentCommandQueue.d.ts +50 -0
  116. package/build/queue/PersistentCommandQueue.js +265 -0
  117. package/build/queue/PersistentCommandQueue.js.map +1 -0
  118. package/build/repository/WorkflowCommandRecord.d.ts +44 -0
  119. package/build/repository/WorkflowCommandRecord.js +38 -0
  120. package/build/repository/WorkflowCommandRecord.js.map +1 -0
  121. package/build/repository/WorkflowCommandRepository.d.ts +51 -0
  122. package/build/repository/WorkflowCommandRepository.js +135 -0
  123. package/build/repository/WorkflowCommandRepository.js.map +1 -0
  124. package/build/repository/WorkflowInstanceRecord.d.ts +61 -0
  125. package/build/repository/WorkflowInstanceRecord.js +43 -0
  126. package/build/repository/WorkflowInstanceRecord.js.map +1 -0
  127. package/build/repository/WorkflowInstanceRepository.d.ts +10 -0
  128. package/build/repository/WorkflowInstanceRepository.js +52 -0
  129. package/build/repository/WorkflowInstanceRepository.js.map +1 -0
  130. package/build/repository/WorkflowTemplateRecord.d.ts +23 -0
  131. package/build/repository/WorkflowTemplateRecord.js +28 -0
  132. package/build/repository/WorkflowTemplateRecord.js.map +1 -0
  133. package/build/repository/WorkflowTemplateRepository.d.ts +6 -0
  134. package/build/repository/WorkflowTemplateRepository.js +56 -0
  135. package/build/repository/WorkflowTemplateRepository.js.map +1 -0
  136. package/build/services/WorkflowService.d.ts +75 -0
  137. package/build/services/WorkflowService.js +566 -0
  138. package/build/services/WorkflowService.js.map +1 -0
  139. package/package.json +47 -0
@@ -0,0 +1,193 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PresentProofV2Action = exports.IssueCredentialV2Action = exports.LocalStateSetAction = exports.ActionRegistry = void 0;
4
+ const core_1 = require("@credo-ts/core");
5
+ const AttributePlanner_1 = require("../engine/AttributePlanner");
6
+ class ActionRegistry {
7
+ constructor() {
8
+ this.handlers = new Map();
9
+ }
10
+ register(handler) {
11
+ this.handlers.set(handler.typeUri, handler);
12
+ }
13
+ get(typeUri) {
14
+ return this.handlers.get(typeUri);
15
+ }
16
+ }
17
+ exports.ActionRegistry = ActionRegistry;
18
+ class LocalStateSetAction {
19
+ constructor() {
20
+ this.typeUri = 'https://didcomm.org/workflow/actions/state:set@1';
21
+ }
22
+ async execute(ctx) {
23
+ const mergeObj = ctx.action?.staticInput;
24
+ const mergeValue = typeof mergeObj === 'object' && mergeObj ? mergeObj.merge : mergeObj;
25
+ if (mergeValue && typeof mergeValue === 'object') {
26
+ const next = (0, AttributePlanner_1.deepMerge)({ ...(ctx.instance.context || {}) }, mergeValue);
27
+ return { contextMerge: next };
28
+ }
29
+ // if string with template, try basic input resolution: '{{ input.form }}'
30
+ if (typeof mergeValue === 'string' && ctx.input && mergeValue.includes('input.')) {
31
+ try {
32
+ const path = mergeValue
33
+ .replace(/\{\{|\}\}/g, '')
34
+ .trim()
35
+ .replace(/^input\./, '');
36
+ const value = path.split('.').reduce((acc, p) => {
37
+ if (acc === null || acc === undefined)
38
+ return undefined;
39
+ if (typeof acc !== 'object')
40
+ return undefined;
41
+ return acc[p];
42
+ }, ctx.input);
43
+ if (value && typeof value === 'object') {
44
+ const next = (0, AttributePlanner_1.deepMerge)({ ...(ctx.instance.context || {}) }, value);
45
+ return { contextMerge: next };
46
+ }
47
+ }
48
+ catch (_e) {
49
+ void 0;
50
+ }
51
+ }
52
+ return {};
53
+ }
54
+ }
55
+ exports.LocalStateSetAction = LocalStateSetAction;
56
+ class IssueCredentialV2Action {
57
+ constructor() {
58
+ this.typeUri = 'https://didcomm.org/issue-credential/2.0/offer-credential';
59
+ }
60
+ async execute(ctx) {
61
+ const act = ctx.action;
62
+ const ref = act.profile_ref;
63
+ if (!ref?.startsWith('cp.'))
64
+ throw Object.assign(new Error('invalid profile_ref'), { code: 'action_error' });
65
+ const key = ref.slice(3);
66
+ const profile = ctx.template.catalog?.credential_profiles?.[key];
67
+ if (!profile)
68
+ throw Object.assign(new Error('missing catalog profile'), { code: 'action_error' });
69
+ const attrs = AttributePlanner_1.AttributePlanner.materialize(profile.attribute_plan || {}, ctx.instance);
70
+ const attributes = Object.entries(attrs).map(([name, value]) => ({ name, value: String(value) }));
71
+ const connectionId = ctx.instance.connection_id;
72
+ if (!connectionId)
73
+ throw Object.assign(new Error('connectionId required'), { code: 'action_error' });
74
+ // Enforce to_ref recipient DID against connection counterparty DID (if available)
75
+ {
76
+ const toRef = profile.to_ref;
77
+ const expectedDid = toRef ? ctx.instance.participants?.[toRef]?.did : undefined;
78
+ if (expectedDid && ctx.instance.connection_id) {
79
+ const connSvc = ctx.agentContext.dependencyManager.resolve(core_1.ConnectionService);
80
+ const conn = await connSvc.getById(ctx.agentContext, ctx.instance.connection_id);
81
+ const theirDid = conn?.theirDid;
82
+ if (theirDid && theirDid !== expectedDid)
83
+ throw Object.assign(new Error('to_ref DID mismatch'), { code: 'forbidden' });
84
+ }
85
+ }
86
+ try {
87
+ const credsApi = ctx.agentContext.dependencyManager.resolve(core_1.CredentialsApi);
88
+ const record = await credsApi.offerCredential({
89
+ connectionId,
90
+ protocolVersion: 'v2',
91
+ credentialFormats: { anoncreds: { credentialDefinitionId: profile.cred_def_id, attributes } },
92
+ comment: profile.options?.comment,
93
+ });
94
+ let messageId = record?.id || record?.credentialRecord?.id;
95
+ try {
96
+ if (messageId) {
97
+ const found = (await credsApi.findOfferMessage(messageId));
98
+ if (found && typeof found === 'object') {
99
+ const f = found;
100
+ messageId = f.message?.id || f.id || messageId;
101
+ }
102
+ }
103
+ }
104
+ catch (_e) {
105
+ void 0;
106
+ }
107
+ return { artifacts: { issueRecordId: record?.id || record?.credentialRecord?.id }, messageId };
108
+ }
109
+ catch (e) {
110
+ throw Object.assign(new Error(`issue action error: ${e.message}`), { code: 'action_error' });
111
+ }
112
+ }
113
+ }
114
+ exports.IssueCredentialV2Action = IssueCredentialV2Action;
115
+ class PresentProofV2Action {
116
+ constructor() {
117
+ this.typeUri = 'https://didcomm.org/present-proof/2.0/request-presentation';
118
+ }
119
+ async execute(ctx) {
120
+ const act = ctx.action;
121
+ const ref = act.profile_ref;
122
+ if (!ref?.startsWith('pp.'))
123
+ throw Object.assign(new Error('invalid profile_ref'), { code: 'action_error' });
124
+ const key = ref.slice(3);
125
+ const profile = ctx.template.catalog?.proof_profiles?.[key];
126
+ if (!profile)
127
+ throw Object.assign(new Error('missing catalog profile'), { code: 'action_error' });
128
+ const connectionId = ctx.instance.connection_id;
129
+ if (!connectionId)
130
+ throw Object.assign(new Error('connectionId required'), { code: 'action_error' });
131
+ // Enforce to_ref recipient DID against connection counterparty DID (if available)
132
+ {
133
+ const toRef2 = profile.to_ref;
134
+ const expectedDid2 = toRef2 ? ctx.instance.participants?.[toRef2]?.did : undefined;
135
+ if (expectedDid2 && ctx.instance.connection_id) {
136
+ const connSvc = ctx.agentContext.dependencyManager.resolve(core_1.ConnectionService);
137
+ const conn = await connSvc.getById(ctx.agentContext, ctx.instance.connection_id);
138
+ const theirDid = conn?.theirDid;
139
+ if (theirDid && theirDid !== expectedDid2)
140
+ throw Object.assign(new Error('to_ref DID mismatch'), { code: 'forbidden' });
141
+ }
142
+ }
143
+ try {
144
+ const proofsApi = ctx.agentContext.dependencyManager.resolve(core_1.ProofsApi);
145
+ const credDefId = profile.cred_def_id;
146
+ const schemaId = profile.schema_id;
147
+ const restriction = credDefId ? { cred_def_id: credDefId } : schemaId ? { schema_id: schemaId } : undefined;
148
+ const reqAttrs = (profile.requested_attributes || []).reduce((acc, name, idx) => {
149
+ acc[`attr${idx + 1}`] = restriction ? { name, restrictions: [restriction] } : { name };
150
+ return acc;
151
+ }, {});
152
+ const reqPreds = (profile.requested_predicates || []).reduce((acc, p, idx) => {
153
+ acc[`pred${idx + 1}`] = restriction
154
+ ? { name: p.name, p_type: p.p_type, p_value: p.p_value, restrictions: [restriction] }
155
+ : { name: p.name, p_type: p.p_type, p_value: p.p_value };
156
+ return acc;
157
+ }, {});
158
+ const record = await proofsApi.requestProof({
159
+ connectionId,
160
+ protocolVersion: 'v2',
161
+ proofFormats: {
162
+ anoncreds: {
163
+ name: 'Workflow Proof Request',
164
+ version: '1.0',
165
+ requested_attributes: reqAttrs,
166
+ requested_predicates: reqPreds,
167
+ },
168
+ },
169
+ willConfirm: true,
170
+ comment: profile.options?.comment,
171
+ });
172
+ let messageId = record?.id || record?.proofRecord?.id;
173
+ try {
174
+ if (messageId) {
175
+ const found = (await proofsApi.findRequestMessage(messageId));
176
+ if (found && typeof found === 'object') {
177
+ const f = found;
178
+ messageId = f.message?.id || f.id || messageId;
179
+ }
180
+ }
181
+ }
182
+ catch (_e) {
183
+ void 0;
184
+ }
185
+ return { artifacts: { proofRecordId: record?.id || record?.proofRecord?.id }, messageId };
186
+ }
187
+ catch (e) {
188
+ throw Object.assign(new Error(`proof action error: ${e.message}`), { code: 'action_error' });
189
+ }
190
+ }
191
+ }
192
+ exports.PresentProofV2Action = PresentProofV2Action;
193
+ //# sourceMappingURL=ActionRegistry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActionRegistry.js","sourceRoot":"","sources":["../../src/actions/ActionRegistry.ts"],"names":[],"mappings":";;;AAGA,yCAA6E;AAE7E,iEAAwE;AAqBxE,MAAa,cAAc;IAA3B;QACU,aAAQ,GAAG,IAAI,GAAG,EAAiC,CAAA;IAO7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AAC,kBAAkB,CAAC,SAAS,CAAC,CAAY,CAAA;oBACxE,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;wBACvC,MAAM,CAAC,GAAG,KAAmD,CAAA;wBAC7D,SAAS,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,IAAI,CAAC,CAAC,EAAE,IAAI,SAAS,CAAA;oBAChD,CAAC;gBACH,CAAC;YACH,CAAC;YAAC,OAAO,EAAE,EAAE,CAAC;gBACZ,KAAK,CAAC,CAAA;YACR,CAAC;YACD,OAAO,EAAE,SAAS,EAAE,EAAE,aAAa,EAAE,MAAM,EAAE,EAAE,IAAI,MAAM,EAAE,WAAW,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,CAAA;QAC3F,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,uBAAwB,CAAW,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,CAAA;QACzG,CAAC;IACH,CAAC;CACF;AA/ED,oDA+EC"}
@@ -0,0 +1,57 @@
1
+ import type { Participants, WorkflowTemplate, UiItem } from '../model/types';
2
+ import { AgentContext } from '@credo-ts/core';
3
+ import { WorkflowInstanceRecord } from '../repository/WorkflowInstanceRecord';
4
+ import { WorkflowTemplateRecord } from '../repository/WorkflowTemplateRecord';
5
+ import { WorkflowService } from '../services/WorkflowService';
6
+ export declare class WorkflowApi {
7
+ private readonly service;
8
+ private readonly agentContext;
9
+ constructor(service: WorkflowService, agentContext: AgentContext);
10
+ publishTemplate(template: WorkflowTemplate): Promise<WorkflowTemplateRecord>;
11
+ start(opts: {
12
+ template_id: string;
13
+ template_version?: string;
14
+ instance_id?: string;
15
+ connection_id?: string;
16
+ participants?: Participants;
17
+ context?: Record<string, unknown>;
18
+ }): Promise<WorkflowInstanceRecord>;
19
+ advance(opts: {
20
+ instance_id: string;
21
+ event: string;
22
+ idempotency_key?: string;
23
+ input?: Record<string, unknown>;
24
+ }): Promise<WorkflowInstanceRecord>;
25
+ status(opts: {
26
+ instance_id: string;
27
+ include_actions?: boolean;
28
+ include_ui?: boolean;
29
+ }): Promise<{
30
+ instance_id: string;
31
+ state: string;
32
+ section?: string;
33
+ allowed_events: string[];
34
+ action_menu: Array<{
35
+ label?: string;
36
+ event: string;
37
+ }>;
38
+ artifacts: Record<string, unknown>;
39
+ ui?: UiItem[];
40
+ }>;
41
+ pause(opts: {
42
+ instance_id: string;
43
+ reason?: string;
44
+ }): Promise<WorkflowInstanceRecord>;
45
+ resume(opts: {
46
+ instance_id: string;
47
+ reason?: string;
48
+ }): Promise<WorkflowInstanceRecord>;
49
+ cancel(opts: {
50
+ instance_id: string;
51
+ reason?: string;
52
+ }): Promise<WorkflowInstanceRecord>;
53
+ complete(opts: {
54
+ instance_id: string;
55
+ reason?: string;
56
+ }): Promise<WorkflowInstanceRecord>;
57
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.WorkflowApi = void 0;
13
+ const core_1 = require("@credo-ts/core");
14
+ const WorkflowService_1 = require("../services/WorkflowService");
15
+ let WorkflowApi = class WorkflowApi {
16
+ constructor(service, agentContext) {
17
+ this.service = service;
18
+ this.agentContext = agentContext;
19
+ }
20
+ publishTemplate(template) {
21
+ return this.service.publishTemplate(this.agentContext, template);
22
+ }
23
+ start(opts) {
24
+ return this.service.start(this.agentContext, opts);
25
+ }
26
+ advance(opts) {
27
+ return this.service.advance(this.agentContext, opts);
28
+ }
29
+ status(opts) {
30
+ return this.service.status(this.agentContext, opts);
31
+ }
32
+ pause(opts) {
33
+ return this.service.pause(this.agentContext, opts);
34
+ }
35
+ resume(opts) {
36
+ return this.service.resume(this.agentContext, opts);
37
+ }
38
+ cancel(opts) {
39
+ return this.service.cancel(this.agentContext, opts);
40
+ }
41
+ complete(opts) {
42
+ return this.service.complete(this.agentContext, opts);
43
+ }
44
+ };
45
+ exports.WorkflowApi = WorkflowApi;
46
+ exports.WorkflowApi = WorkflowApi = __decorate([
47
+ (0, core_1.injectable)(),
48
+ __metadata("design:paramtypes", [WorkflowService_1.WorkflowService, core_1.AgentContext])
49
+ ], WorkflowApi);
50
+ //# sourceMappingURL=WorkflowApi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WorkflowApi.js","sourceRoot":"","sources":["../../src/api/WorkflowApi.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,yCAAyD;AAIzD,iEAA6D;AAGtD,IAAM,WAAW,GAAjB,MAAM,WAAW;IACtB,YAAoC,OAAwB,EAAmB,YAA0B;QAArE,YAAO,GAAP,OAAO,CAAiB;QAAmB,iBAAY,GAAZ,YAAY,CAAc;IAAG,CAAC;IAEtG,eAAe,CAAC,QAA0B;QAC/C,OAAO,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAA;IAClE,CAAC;IAEM,KAAK,CAAC,IAOZ;QACC,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,CAAA;IACpD,CAAC;IAEM,OAAO,CAAC,IAKd;QACC,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,CAAA;IACtD,CAAC;IAEM,MAAM,CAAC,IAA8E;QAS1F,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,CAAA;IACrD,CAAC;IAEM,KAAK,CAAC,IAA8C;QACzD,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,CAAA;IACpD,CAAC;IAEM,MAAM,CAAC,IAA8C;QAC1D,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,CAAA;IACrD,CAAC;IAEM,MAAM,CAAC,IAA8C;QAC1D,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,CAAA;IACrD,CAAC;IAEM,QAAQ,CAAC,IAA8C;QAC5D,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,CAAA;IACvD,CAAC;CACF,CAAA;AAtDY,kCAAW;sBAAX,WAAW;IADvB,IAAA,iBAAU,GAAE;qCAEkC,iCAAe,EAAiC,mBAAY;GAD9F,WAAW,CAsDvB"}
@@ -0,0 +1,7 @@
1
+ import type { AttributeSpec, WorkflowInstanceData } from '../model/types';
2
+ export declare class AttributePlanner {
3
+ static materialize(plan: Record<string, AttributeSpec>, instance: WorkflowInstanceData): Record<string, unknown>;
4
+ private static getByPath;
5
+ private static computeExpr;
6
+ }
7
+ export declare const deepMerge: (target: Record<string, unknown>, source: Record<string, unknown>) => Record<string, unknown>;
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.deepMerge = exports.AttributePlanner = void 0;
7
+ const jmespath_1 = __importDefault(require("jmespath"));
8
+ const isObject = (v) => v !== null && typeof v === 'object' && !Array.isArray(v);
9
+ // biome-ignore lint/complexity/noStaticOnlyClass: Utility holder class for attribute planning
10
+ class AttributePlanner {
11
+ static materialize(plan, instance) {
12
+ const out = {};
13
+ for (const [key, spec] of Object.entries(plan || {})) {
14
+ let value;
15
+ if (spec.source === 'context') {
16
+ const p = spec.path;
17
+ value = AttributePlanner.getByPath((instance.context || {}), p);
18
+ }
19
+ else if (spec.source === 'static') {
20
+ value = spec.value;
21
+ }
22
+ else if (spec.source === 'compute') {
23
+ value = AttributePlanner.computeExpr(spec.expr, instance);
24
+ }
25
+ if (spec.required && (value === undefined || value === null || value === '')) {
26
+ const err = new Error('missing_attributes');
27
+ err.code = 'missing_attributes';
28
+ err.attribute = key;
29
+ throw err;
30
+ }
31
+ if (value !== undefined)
32
+ out[key] = value;
33
+ }
34
+ return out;
35
+ }
36
+ static getByPath(obj, path) {
37
+ return path.split('.').reduce((acc, part) => {
38
+ if (acc === null || acc === undefined)
39
+ return undefined;
40
+ if (typeof acc !== 'object')
41
+ return undefined;
42
+ const rec = acc;
43
+ return rec[part];
44
+ }, obj);
45
+ }
46
+ static computeExpr(expr, instance) {
47
+ // Evaluate compute expressions using JMESPath over a pure env
48
+ // Expose a stable 'now' value as an ISO string for this evaluation
49
+ const env = {
50
+ context: instance.context || {},
51
+ participants: instance.participants || {},
52
+ artifacts: instance.artifacts || {},
53
+ now: new Date().toISOString(),
54
+ };
55
+ try {
56
+ const jpSearch = jmespath_1.default.search;
57
+ return jpSearch(env, expr);
58
+ }
59
+ catch {
60
+ return undefined;
61
+ }
62
+ }
63
+ }
64
+ exports.AttributePlanner = AttributePlanner;
65
+ const deepMerge = (target, source) => {
66
+ if (!isObject(target) || !isObject(source))
67
+ return source;
68
+ for (const [k, v] of Object.entries(source)) {
69
+ if (isObject(v)) {
70
+ if (!isObject(target[k]))
71
+ target[k] = {};
72
+ (0, exports.deepMerge)(target[k], v);
73
+ }
74
+ else {
75
+ target[k] = v;
76
+ }
77
+ }
78
+ return target;
79
+ };
80
+ exports.deepMerge = deepMerge;
81
+ //# sourceMappingURL=AttributePlanner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AttributePlanner.js","sourceRoot":"","sources":["../../src/engine/AttributePlanner.ts"],"names":[],"mappings":";;;;;;AAEA,wDAA+B;AAE/B,MAAM,QAAQ,GAAG,CAAC,CAAU,EAAgC,EAAE,CAAC,CAAC,KAAK,IAAI,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;AAEvH,8FAA8F;AAC9F,MAAa,gBAAgB;IACpB,MAAM,CAAC,WAAW,CACvB,IAAmC,EACnC,QAA8B;QAE9B,MAAM,GAAG,GAA4B,EAAE,CAAA;QACvC,KAAK,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC,EAAE,CAAC;YACrD,IAAI,KAAc,CAAA;YAClB,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;gBAC9B,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,CAAA;gBACnB,KAAK,GAAG,gBAAgB,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,OAAO,IAAI,EAAE,CAA4B,EAAE,CAAC,CAAC,CAAA;YAC5F,CAAC;iBAAM,IAAI,IAAI,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;gBACpC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAA;YACpB,CAAC;iBAAM,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;gBACrC,KAAK,GAAG,gBAAgB,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;YAC3D,CAAC;YACD,IAAI,IAAI,CAAC,QAAQ,IAAI,CAAC,KA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AAC,GAAG,EAAE,IAAI,CAAC,CAAA;QAC5B,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,SAAS,CAAA;QAClB,CAAC;IACH,CAAC;CACF;AApDD,4CAoDC;AAEM,MAAM,SAAS,GAAG,CACvB,MAA+B,EAC/B,MAA+B,EACN,EAAE;IAC3B,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAA;IACzD,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAC5C,IAAI,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;YAChB,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;gBAAE,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,CAAA;YACxC,IAAA,iBAAS,EAAC,MAAM,CAAC,CAAC,CAA4B,EAAE,CAAC,CAAC,CAAA;QACpD,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;QACf,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AAdY,QAAA,SAAS,aAcrB"}
@@ -0,0 +1,11 @@
1
+ import type { Participants, WorkflowInstanceData } from '../model/types';
2
+ export type GuardEnv = {
3
+ context: Record<string, unknown>;
4
+ participants: Participants;
5
+ artifacts: Record<string, unknown>;
6
+ };
7
+ export declare class GuardEvaluator {
8
+ static evalGuard(expression: string | undefined, env: GuardEnv): boolean;
9
+ static evalValue(expression: string, env: GuardEnv): unknown;
10
+ static envFromInstance(instance: WorkflowInstanceData): GuardEnv;
11
+ }
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.GuardEvaluator = void 0;
7
+ const jmespath_1 = __importDefault(require("jmespath"));
8
+ // biome-ignore lint/complexity/noStaticOnlyClass: Utility holder class for guard evaluation
9
+ class GuardEvaluator {
10
+ static evalGuard(expression, env) {
11
+ if (!expression)
12
+ return true;
13
+ try {
14
+ const jpSearch = jmespath_1.default.search;
15
+ const res = jpSearch(env, expression);
16
+ return !!res;
17
+ }
18
+ catch {
19
+ return false;
20
+ }
21
+ }
22
+ static evalValue(expression, env) {
23
+ try {
24
+ const jpSearch = jmespath_1.default.search;
25
+ return jpSearch(env, expression);
26
+ }
27
+ catch {
28
+ return undefined;
29
+ }
30
+ }
31
+ static envFromInstance(instance) {
32
+ return {
33
+ context: instance.context || {},
34
+ participants: instance.participants || {},
35
+ artifacts: instance.artifacts || {},
36
+ };
37
+ }
38
+ }
39
+ exports.GuardEvaluator = GuardEvaluator;
40
+ //# sourceMappingURL=GuardEvaluator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GuardEvaluator.js","sourceRoot":"","sources":["../../src/engine/GuardEvaluator.ts"],"names":[],"mappings":";;;;;;AAEA,wDAA+B;AAQ/B,4FAA4F;AAC5F,MAAa,cAAc;IAClB,MAAM,CAAC,SAAS,CAAC,UAA8B,EAAE,GAAa;QACnE,IAAI,CAAC,UAAU;YAAE,OAAO,IAAI,CAAA;QAC5B,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,kBAAQ,CAAC,MAA4D,CAAA;YACtF,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC,CAAA;YACrC,OAAO,CAAC,CAAC,GAAG,CAAA;QACd,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAA;QACd,CAAC;IACH,CAAC;IAEM,MAAM,CAAC,SAAS,CAAC,UAAkB,EAAE,GAAa;QACvD,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,kBAAQ,CAAC,MAA4D,CAAA;YACtF,OAAO,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC,CAAA;QAClC,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,SAAS,CAAA;QAClB,CAAC;IACH,CAAC;IAEM,MAAM,CAAC,eAAe,CAAC,QAA8B;QAC1D,OAAO;YACL,OAAO,EAAE,QAAQ,CAAC,OAAO,IAAI,EAAE;YAC/B,YAAY,EAAE,QAAQ,CAAC,YAAY,IAAI,EAAE;YACzC,SAAS,EAAE,QAAQ,CAAC,SAAS,IAAI,EAAE;SACpC,CAAA;IACH,CAAC;CACF;AA5BD,wCA4BC"}
@@ -0,0 +1,45 @@
1
+ export * from './WorkflowModule';
2
+ export * from './WorkflowModuleConfig';
3
+ export * from './api/WorkflowApi';
4
+ export * from './model/types';
5
+ export * from './model/TemplateValidation';
6
+ export * from './engine/AttributePlanner';
7
+ export * from './engine/GuardEvaluator';
8
+ export * from './services/WorkflowService';
9
+ export * from './WorkflowEvents';
10
+ export * from './protocol/WorkflowMessageTypes';
11
+ export * from './repository/WorkflowTemplateRecord';
12
+ export * from './repository/WorkflowTemplateRepository';
13
+ export * from './repository/WorkflowInstanceRecord';
14
+ export * from './repository/WorkflowInstanceRepository';
15
+ export * from './repository/WorkflowCommandRecord';
16
+ export * from './repository/WorkflowCommandRepository';
17
+ export * from './protocol/messages/PublishTemplateMessage';
18
+ export * from './protocol/messages/StartMessage';
19
+ export * from './protocol/messages/AdvanceMessage';
20
+ export * from './protocol/messages/StatusRequestMessage';
21
+ export * from './protocol/messages/StatusMessage';
22
+ export * from './protocol/messages/ProblemReportMessage';
23
+ export * from './protocol/messages/CancelMessage';
24
+ export * from './protocol/messages/PauseMessage';
25
+ export * from './protocol/messages/ResumeMessage';
26
+ export * from './protocol/messages/CompleteMessage';
27
+ export * from './protocol/messages/DiscoverMessage';
28
+ export * from './protocol/messages/WorkflowsMessage';
29
+ export * from './protocol/messages/FetchTemplateMessage';
30
+ export * from './protocol/messages/TemplateMessage';
31
+ export * from './protocol/handlers/PublishTemplateHandler';
32
+ export * from './protocol/handlers/StartHandler';
33
+ export * from './protocol/handlers/AdvanceHandler';
34
+ export * from './protocol/handlers/StatusHandler';
35
+ export * from './protocol/handlers/ProblemReportHandler';
36
+ export * from './protocol/handlers/PauseHandler';
37
+ export * from './protocol/handlers/ResumeHandler';
38
+ export * from './protocol/handlers/CancelHandler';
39
+ export * from './protocol/handlers/CompleteHandler';
40
+ export * from './protocol/handlers/DiscoverHandler';
41
+ export * from './protocol/handlers/FetchTemplateHandler';
42
+ export * from './protocol/handlers/TemplateHandler';
43
+ export * from './actions/ActionRegistry';
44
+ export * from './queue/CommandQueue';
45
+ export * from './queue/PersistentCommandQueue';
package/build/index.js ADDED
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./WorkflowModule"), exports);
18
+ __exportStar(require("./WorkflowModuleConfig"), exports);
19
+ __exportStar(require("./api/WorkflowApi"), exports);
20
+ __exportStar(require("./model/types"), exports);
21
+ __exportStar(require("./model/TemplateValidation"), exports);
22
+ // Engine utilities
23
+ __exportStar(require("./engine/AttributePlanner"), exports);
24
+ __exportStar(require("./engine/GuardEvaluator"), exports);
25
+ // Services
26
+ __exportStar(require("./services/WorkflowService"), exports);
27
+ __exportStar(require("./WorkflowEvents"), exports);
28
+ __exportStar(require("./protocol/WorkflowMessageTypes"), exports);
29
+ // Repository
30
+ __exportStar(require("./repository/WorkflowTemplateRecord"), exports);
31
+ __exportStar(require("./repository/WorkflowTemplateRepository"), exports);
32
+ __exportStar(require("./repository/WorkflowInstanceRecord"), exports);
33
+ __exportStar(require("./repository/WorkflowInstanceRepository"), exports);
34
+ __exportStar(require("./repository/WorkflowCommandRecord"), exports);
35
+ __exportStar(require("./repository/WorkflowCommandRepository"), exports);
36
+ // Protocol messages
37
+ __exportStar(require("./protocol/messages/PublishTemplateMessage"), exports);
38
+ __exportStar(require("./protocol/messages/StartMessage"), exports);
39
+ __exportStar(require("./protocol/messages/AdvanceMessage"), exports);
40
+ __exportStar(require("./protocol/messages/StatusRequestMessage"), exports);
41
+ __exportStar(require("./protocol/messages/StatusMessage"), exports);
42
+ __exportStar(require("./protocol/messages/ProblemReportMessage"), exports);
43
+ __exportStar(require("./protocol/messages/CancelMessage"), exports);
44
+ __exportStar(require("./protocol/messages/PauseMessage"), exports);
45
+ __exportStar(require("./protocol/messages/ResumeMessage"), exports);
46
+ __exportStar(require("./protocol/messages/CompleteMessage"), exports);
47
+ __exportStar(require("./protocol/messages/DiscoverMessage"), exports);
48
+ __exportStar(require("./protocol/messages/WorkflowsMessage"), exports);
49
+ __exportStar(require("./protocol/messages/FetchTemplateMessage"), exports);
50
+ __exportStar(require("./protocol/messages/TemplateMessage"), exports);
51
+ // Protocol handlers
52
+ __exportStar(require("./protocol/handlers/PublishTemplateHandler"), exports);
53
+ __exportStar(require("./protocol/handlers/StartHandler"), exports);
54
+ __exportStar(require("./protocol/handlers/AdvanceHandler"), exports);
55
+ __exportStar(require("./protocol/handlers/StatusHandler"), exports);
56
+ __exportStar(require("./protocol/handlers/ProblemReportHandler"), exports);
57
+ __exportStar(require("./protocol/handlers/PauseHandler"), exports);
58
+ __exportStar(require("./protocol/handlers/ResumeHandler"), exports);
59
+ __exportStar(require("./protocol/handlers/CancelHandler"), exports);
60
+ __exportStar(require("./protocol/handlers/CompleteHandler"), exports);
61
+ __exportStar(require("./protocol/handlers/DiscoverHandler"), exports);
62
+ __exportStar(require("./protocol/handlers/FetchTemplateHandler"), exports);
63
+ __exportStar(require("./protocol/handlers/TemplateHandler"), exports);
64
+ // Actions
65
+ __exportStar(require("./actions/ActionRegistry"), exports);
66
+ // Async commands queue
67
+ __exportStar(require("./queue/CommandQueue"), exports);
68
+ __exportStar(require("./queue/PersistentCommandQueue"), exports);
69
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAgC;AAChC,yDAAsC;AACtC,oDAAiC;AACjC,gDAA6B;AAC7B,6DAA0C;AAE1C,mBAAmB;AACnB,4DAAyC;AACzC,0DAAuC;AAEvC,WAAW;AACX,6DAA0C;AAC1C,mDAAgC;AAChC,kEAA+C;AAE/C,aAAa;AACb,sEAAmD;AACnD,0EAAuD;AACvD,sEAAmD;AACnD,0EAAuD;AACvD,qEAAkD;AAClD,yEAAsD;AAEtD,oBAAoB;AACpB,6EAA0D;AAC1D,mEAAgD;AAChD,qEAAkD;AAClD,2EAAwD;AACxD,oEAAiD;AACjD,2EAAwD;AACxD,oEAAiD;AACjD,mEAAgD;AAChD,oEAAiD;AACjD,sEAAmD;AACnD,sEAAmD;AACnD,uEAAoD;AACpD,2EAAwD;AACxD,sEAAmD;AAEnD,oBAAoB;AACpB,6EAA0D;AAC1D,mEAAgD;AAChD,qEAAkD;AAClD,oEAAiD;AACjD,2EAAwD;AACxD,mEAAgD;AAChD,oEAAiD;AACjD,oEAAiD;AACjD,sEAAmD;AACnD,sEAAmD;AACnD,2EAAwD;AACxD,sEAAmD;AAEnD,UAAU;AACV,2DAAwC;AACxC,uBAAuB;AACvB,uDAAoC;AACpC,iEAA8C"}
@@ -0,0 +1,3 @@
1
+ import type { WorkflowTemplate } from './types';
2
+ export declare function validateTemplateJson(tpl: unknown): void;
3
+ export declare function validateTemplateRefs(t: WorkflowTemplate): void;