@veridid/workflow 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +43 -2
  3. package/build/WorkflowEvents.d.mts +40 -0
  4. package/build/WorkflowEvents.d.mts.map +1 -0
  5. package/build/WorkflowEvents.mjs +11 -0
  6. package/build/WorkflowEvents.mjs.map +1 -0
  7. package/build/WorkflowModule.d.mts +24 -0
  8. package/build/WorkflowModule.d.mts.map +1 -0
  9. package/build/WorkflowModule.mjs +479 -0
  10. package/build/WorkflowModule.mjs.map +1 -0
  11. package/build/WorkflowModuleConfig.d.mts +53 -0
  12. package/build/WorkflowModuleConfig.d.mts.map +1 -0
  13. package/build/WorkflowModuleConfig.mjs +21 -0
  14. package/build/WorkflowModuleConfig.mjs.map +1 -0
  15. package/build/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.mjs +14 -0
  16. package/build/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.mjs +11 -0
  17. package/build/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateParam.mjs +9 -0
  18. package/build/_virtual/_rolldown/runtime.mjs +41 -0
  19. package/build/actions/ActionRegistry.d.mts +65 -0
  20. package/build/actions/ActionRegistry.d.mts.map +1 -0
  21. package/build/actions/ActionRegistry.mjs +360 -0
  22. package/build/actions/ActionRegistry.mjs.map +1 -0
  23. package/build/api/WorkflowApi.d.mts +99 -0
  24. package/build/api/WorkflowApi.d.mts.map +1 -0
  25. package/build/api/WorkflowApi.mjs +228 -0
  26. package/build/api/WorkflowApi.mjs.map +1 -0
  27. package/build/engine/AttributePlanner.d.mts +12 -0
  28. package/build/engine/AttributePlanner.d.mts.map +1 -0
  29. package/build/engine/AttributePlanner.mjs +58 -0
  30. package/build/engine/AttributePlanner.mjs.map +1 -0
  31. package/build/engine/GuardEvaluator.d.mts +16 -0
  32. package/build/engine/GuardEvaluator.d.mts.map +1 -0
  33. package/build/engine/GuardEvaluator.mjs +38 -0
  34. package/build/engine/GuardEvaluator.mjs.map +1 -0
  35. package/build/index.d.mts +46 -0
  36. package/build/index.mjs +53 -0
  37. package/build/index.mjs.map +1 -0
  38. package/build/model/TemplateValidation.d.mts +8 -0
  39. package/build/model/TemplateValidation.d.mts.map +1 -0
  40. package/build/model/TemplateValidation.mjs +278 -0
  41. package/build/model/TemplateValidation.mjs.map +1 -0
  42. package/build/model/types.d.mts +120 -0
  43. package/build/model/types.d.mts.map +1 -0
  44. package/build/model/types.mjs +11 -0
  45. package/build/model/types.mjs.map +1 -0
  46. package/build/protocol/WorkflowMessageTypes.d.mts +19 -0
  47. package/build/protocol/WorkflowMessageTypes.d.mts.map +1 -0
  48. package/build/protocol/WorkflowMessageTypes.mjs +20 -0
  49. package/build/protocol/WorkflowMessageTypes.mjs.map +1 -0
  50. package/build/protocol/handlers/AdvanceHandler.d.mts +16 -0
  51. package/build/protocol/handlers/AdvanceHandler.d.mts.map +1 -0
  52. package/build/protocol/handlers/AdvanceHandler.mjs +181 -0
  53. package/build/protocol/handlers/AdvanceHandler.mjs.map +1 -0
  54. package/build/protocol/handlers/CancelHandler.d.mts +16 -0
  55. package/build/protocol/handlers/CancelHandler.d.mts.map +1 -0
  56. package/build/protocol/handlers/CancelHandler.mjs +103 -0
  57. package/build/protocol/handlers/CancelHandler.mjs.map +1 -0
  58. package/build/protocol/handlers/CompleteHandler.d.mts +16 -0
  59. package/build/protocol/handlers/CompleteHandler.d.mts.map +1 -0
  60. package/build/protocol/handlers/CompleteHandler.mjs +103 -0
  61. package/build/protocol/handlers/CompleteHandler.mjs.map +1 -0
  62. package/build/protocol/handlers/DiscoverHandler.d.mts +15 -0
  63. package/build/protocol/handlers/DiscoverHandler.d.mts.map +1 -0
  64. package/build/protocol/handlers/DiscoverHandler.mjs +73 -0
  65. package/build/protocol/handlers/DiscoverHandler.mjs.map +1 -0
  66. package/build/protocol/handlers/FetchTemplateHandler.d.mts +16 -0
  67. package/build/protocol/handlers/FetchTemplateHandler.d.mts.map +1 -0
  68. package/build/protocol/handlers/FetchTemplateHandler.mjs +64 -0
  69. package/build/protocol/handlers/FetchTemplateHandler.mjs.map +1 -0
  70. package/build/protocol/handlers/PauseHandler.d.mts +16 -0
  71. package/build/protocol/handlers/PauseHandler.d.mts.map +1 -0
  72. package/build/protocol/handlers/PauseHandler.mjs +103 -0
  73. package/build/protocol/handlers/PauseHandler.mjs.map +1 -0
  74. package/build/protocol/handlers/ProblemReportHandler.d.mts +11 -0
  75. package/build/protocol/handlers/ProblemReportHandler.d.mts.map +1 -0
  76. package/build/protocol/handlers/ProblemReportHandler.mjs +26 -0
  77. package/build/protocol/handlers/ProblemReportHandler.mjs.map +1 -0
  78. package/build/protocol/handlers/PublishTemplateHandler.d.mts +15 -0
  79. package/build/protocol/handlers/PublishTemplateHandler.d.mts.map +1 -0
  80. package/build/protocol/handlers/PublishTemplateHandler.mjs +47 -0
  81. package/build/protocol/handlers/PublishTemplateHandler.mjs.map +1 -0
  82. package/build/protocol/handlers/ResumeHandler.d.mts +16 -0
  83. package/build/protocol/handlers/ResumeHandler.d.mts.map +1 -0
  84. package/build/protocol/handlers/ResumeHandler.mjs +103 -0
  85. package/build/protocol/handlers/ResumeHandler.mjs.map +1 -0
  86. package/build/protocol/handlers/StartHandler.d.mts +16 -0
  87. package/build/protocol/handlers/StartHandler.d.mts.map +1 -0
  88. package/build/protocol/handlers/StartHandler.mjs +241 -0
  89. package/build/protocol/handlers/StartHandler.mjs.map +1 -0
  90. package/build/protocol/handlers/StatusHandler.d.mts +16 -0
  91. package/build/protocol/handlers/StatusHandler.d.mts.map +1 -0
  92. package/build/protocol/handlers/StatusHandler.mjs +174 -0
  93. package/build/protocol/handlers/StatusHandler.mjs.map +1 -0
  94. package/build/protocol/handlers/TemplateHandler.d.mts +14 -0
  95. package/build/protocol/handlers/TemplateHandler.d.mts.map +1 -0
  96. package/build/protocol/handlers/TemplateHandler.mjs +66 -0
  97. package/build/protocol/handlers/TemplateHandler.mjs.map +1 -0
  98. package/build/protocol/messages/AdvanceMessage.d.mts +24 -0
  99. package/build/protocol/messages/AdvanceMessage.d.mts.map +1 -0
  100. package/build/protocol/messages/AdvanceMessage.mjs +25 -0
  101. package/build/protocol/messages/AdvanceMessage.mjs.map +1 -0
  102. package/build/protocol/messages/CancelMessage.d.mts +20 -0
  103. package/build/protocol/messages/CancelMessage.d.mts.map +1 -0
  104. package/build/protocol/messages/CancelMessage.mjs +25 -0
  105. package/build/protocol/messages/CancelMessage.mjs.map +1 -0
  106. package/build/protocol/messages/CompleteMessage.d.mts +20 -0
  107. package/build/protocol/messages/CompleteMessage.d.mts.map +1 -0
  108. package/build/protocol/messages/CompleteMessage.mjs +25 -0
  109. package/build/protocol/messages/CompleteMessage.mjs.map +1 -0
  110. package/build/protocol/messages/DiscoverMessage.d.mts +29 -0
  111. package/build/protocol/messages/DiscoverMessage.d.mts.map +1 -0
  112. package/build/protocol/messages/DiscoverMessage.mjs +25 -0
  113. package/build/protocol/messages/DiscoverMessage.mjs.map +1 -0
  114. package/build/protocol/messages/FetchTemplateMessage.d.mts +21 -0
  115. package/build/protocol/messages/FetchTemplateMessage.d.mts.map +1 -0
  116. package/build/protocol/messages/FetchTemplateMessage.mjs +31 -0
  117. package/build/protocol/messages/FetchTemplateMessage.mjs.map +1 -0
  118. package/build/protocol/messages/PauseMessage.d.mts +20 -0
  119. package/build/protocol/messages/PauseMessage.d.mts.map +1 -0
  120. package/build/protocol/messages/PauseMessage.mjs +25 -0
  121. package/build/protocol/messages/PauseMessage.mjs.map +1 -0
  122. package/build/protocol/messages/ProblemReportMessage.d.mts +21 -0
  123. package/build/protocol/messages/ProblemReportMessage.d.mts.map +1 -0
  124. package/build/protocol/messages/ProblemReportMessage.mjs +25 -0
  125. package/build/protocol/messages/ProblemReportMessage.mjs.map +1 -0
  126. package/build/protocol/messages/PublishTemplateMessage.d.mts +23 -0
  127. package/build/protocol/messages/PublishTemplateMessage.d.mts.map +1 -0
  128. package/build/protocol/messages/PublishTemplateMessage.mjs +24 -0
  129. package/build/protocol/messages/PublishTemplateMessage.mjs.map +1 -0
  130. package/build/protocol/messages/ResumeMessage.d.mts +20 -0
  131. package/build/protocol/messages/ResumeMessage.d.mts.map +1 -0
  132. package/build/protocol/messages/ResumeMessage.mjs +25 -0
  133. package/build/protocol/messages/ResumeMessage.mjs.map +1 -0
  134. package/build/protocol/messages/StartMessage.d.mts +28 -0
  135. package/build/protocol/messages/StartMessage.d.mts.map +1 -0
  136. package/build/protocol/messages/StartMessage.mjs +25 -0
  137. package/build/protocol/messages/StartMessage.mjs.map +1 -0
  138. package/build/protocol/messages/StatusMessage.d.mts +35 -0
  139. package/build/protocol/messages/StatusMessage.d.mts.map +1 -0
  140. package/build/protocol/messages/StatusMessage.mjs +25 -0
  141. package/build/protocol/messages/StatusMessage.mjs.map +1 -0
  142. package/build/protocol/messages/StatusRequestMessage.d.mts +29 -0
  143. package/build/protocol/messages/StatusRequestMessage.d.mts.map +1 -0
  144. package/build/protocol/messages/StatusRequestMessage.mjs +25 -0
  145. package/build/protocol/messages/StatusRequestMessage.mjs.map +1 -0
  146. package/build/protocol/messages/TemplateMessage.d.mts +20 -0
  147. package/build/protocol/messages/TemplateMessage.d.mts.map +1 -0
  148. package/build/protocol/messages/TemplateMessage.mjs +25 -0
  149. package/build/protocol/messages/TemplateMessage.mjs.map +1 -0
  150. package/build/protocol/messages/WorkflowsMessage.d.mts +28 -0
  151. package/build/protocol/messages/WorkflowsMessage.d.mts.map +1 -0
  152. package/build/protocol/messages/WorkflowsMessage.mjs +25 -0
  153. package/build/protocol/messages/WorkflowsMessage.mjs.map +1 -0
  154. package/build/queue/CommandQueue.d.mts +22 -0
  155. package/build/queue/CommandQueue.d.mts.map +1 -0
  156. package/build/queue/CommandQueue.mjs +6 -0
  157. package/build/queue/CommandQueue.mjs.map +1 -0
  158. package/build/queue/PersistentCommandQueue.d.mts +56 -0
  159. package/build/queue/PersistentCommandQueue.d.mts.map +1 -0
  160. package/build/queue/PersistentCommandQueue.mjs +281 -0
  161. package/build/queue/PersistentCommandQueue.mjs.map +1 -0
  162. package/build/repository/WorkflowCommandRecord.d.mts +50 -0
  163. package/build/repository/WorkflowCommandRecord.d.mts.map +1 -0
  164. package/build/repository/WorkflowCommandRecord.mjs +48 -0
  165. package/build/repository/WorkflowCommandRecord.mjs.map +1 -0
  166. package/build/repository/WorkflowCommandRepository.d.mts +59 -0
  167. package/build/repository/WorkflowCommandRepository.d.mts.map +1 -0
  168. package/build/repository/WorkflowCommandRepository.mjs +136 -0
  169. package/build/repository/WorkflowCommandRepository.mjs.map +1 -0
  170. package/build/repository/WorkflowInstanceRecord.d.mts +65 -0
  171. package/build/repository/WorkflowInstanceRecord.d.mts.map +1 -0
  172. package/build/repository/WorkflowInstanceRecord.mjs +44 -0
  173. package/build/repository/WorkflowInstanceRecord.mjs.map +1 -0
  174. package/build/repository/WorkflowInstanceRepository.d.mts +15 -0
  175. package/build/repository/WorkflowInstanceRepository.d.mts.map +1 -0
  176. package/build/repository/WorkflowInstanceRepository.mjs +48 -0
  177. package/build/repository/WorkflowInstanceRepository.mjs.map +1 -0
  178. package/build/repository/WorkflowTemplateRecord.d.mts +27 -0
  179. package/build/repository/WorkflowTemplateRecord.d.mts.map +1 -0
  180. package/build/repository/WorkflowTemplateRecord.mjs +29 -0
  181. package/build/repository/WorkflowTemplateRecord.mjs.map +1 -0
  182. package/build/repository/WorkflowTemplateRepository.d.mts +11 -0
  183. package/build/repository/WorkflowTemplateRepository.d.mts.map +1 -0
  184. package/build/repository/WorkflowTemplateRepository.mjs +43 -0
  185. package/build/repository/WorkflowTemplateRepository.mjs.map +1 -0
  186. package/build/services/WorkflowService.d.mts +109 -0
  187. package/build/services/WorkflowService.d.mts.map +1 -0
  188. package/build/services/WorkflowService.mjs +640 -0
  189. package/build/services/WorkflowService.mjs.map +1 -0
  190. package/build/ui/UiFilter.mjs +144 -0
  191. package/build/ui/UiFilter.mjs.map +1 -0
  192. package/build/utils/peerMerge.mjs +49 -0
  193. package/build/utils/peerMerge.mjs.map +1 -0
  194. package/package.json +50 -3
@@ -0,0 +1,29 @@
1
+ import * as _credo_ts_didcomm0 from "@credo-ts/didcomm";
2
+ import { DidCommMessage } from "@credo-ts/didcomm";
3
+
4
+ //#region src/protocol/messages/StatusRequestMessage.d.ts
5
+ declare class StatusRequestMessage extends DidCommMessage {
6
+ static readonly type: _credo_ts_didcomm0.ParsedMessageType;
7
+ type: string;
8
+ body: {
9
+ instance_id: string;
10
+ include_actions?: boolean;
11
+ include_ui?: boolean;
12
+ ui_profile?: string;
13
+ viewer?: {
14
+ role?: string;
15
+ connection_id?: string;
16
+ did?: string;
17
+ participantKey?: string;
18
+ };
19
+ capabilities?: string[];
20
+ };
21
+ constructor(options?: {
22
+ id?: string;
23
+ body: StatusRequestMessage['body'];
24
+ thid?: string;
25
+ });
26
+ }
27
+ //#endregion
28
+ export { StatusRequestMessage };
29
+ //# sourceMappingURL=StatusRequestMessage.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StatusRequestMessage.d.mts","names":[],"sources":["../../../src/protocol/messages/StatusRequestMessage.ts"],"mappings":";;;;cAEa,oBAAA,SAA6B,cAAA;EAAA,gBACjB,IAAA,EADS,kBAAA,CACL,iBAAA;EAGpB,IAAA;EAEA,IAAA;IACL,WAAA;IACA,eAAA;IACA,UAAA;IACA,UAAA;IACA,MAAA;MAAW,IAAA;MAAe,aAAA;MAAwB,GAAA;MAAc,cAAA;IAAA;IAChE,YAAA;EAAA;cAGiB,OAAA;IAAY,EAAA;IAAa,IAAA,EAAM,oBAAA;IAA8B,IAAA;EAAA;AAAA"}
@@ -0,0 +1,25 @@
1
+ import { __decorateMetadata, init_decorateMetadata } from "../../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.mjs";
2
+ import { __decorate, init_decorate } from "../../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.mjs";
3
+ import { DidCommMessage, IsValidMessageType, parseMessageType } from "@credo-ts/didcomm";
4
+
5
+ //#region src/protocol/messages/StatusRequestMessage.ts
6
+ init_decorateMetadata();
7
+ init_decorate();
8
+ var StatusRequestMessage = class StatusRequestMessage extends DidCommMessage {
9
+ constructor(options) {
10
+ super();
11
+ this.type = StatusRequestMessage.type.messageTypeUri;
12
+ this.type = StatusRequestMessage.type.messageTypeUri;
13
+ if (options) {
14
+ this.id = options.id || this.generateId();
15
+ this.body = options.body;
16
+ if (options.thid) this.setThread({ threadId: options.thid });
17
+ }
18
+ }
19
+ };
20
+ StatusRequestMessage.type = parseMessageType("https://didcomm.org/workflow/1.0/status");
21
+ __decorate([IsValidMessageType(StatusRequestMessage.type), __decorateMetadata("design:type", Object)], StatusRequestMessage.prototype, "type", void 0);
22
+
23
+ //#endregion
24
+ export { StatusRequestMessage };
25
+ //# sourceMappingURL=StatusRequestMessage.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StatusRequestMessage.mjs","names":[],"sources":["../../../src/protocol/messages/StatusRequestMessage.ts"],"sourcesContent":["import { DidCommMessage, IsValidMessageType, parseMessageType } from '@credo-ts/didcomm'\n\nexport class StatusRequestMessage extends DidCommMessage {\n public static readonly type = parseMessageType('https://didcomm.org/workflow/1.0/status')\n\n @IsValidMessageType(StatusRequestMessage.type)\n public type = StatusRequestMessage.type.messageTypeUri\n\n public body!: {\n instance_id: string\n include_actions?: boolean\n include_ui?: boolean\n ui_profile?: string\n viewer?: { role?: string; connection_id?: string; did?: string; participantKey?: string }\n capabilities?: string[]\n }\n\n public constructor(options?: { id?: string; body: StatusRequestMessage['body']; thid?: string }) {\n super()\n this.type = StatusRequestMessage.type.messageTypeUri\n if (options) {\n this.id = options.id || this.generateId()\n this.body = options.body\n if (options.thid) this.setThread({ threadId: options.thid })\n }\n }\n}\n"],"mappings":";;;;;;;AAEA,IAAa,uBAAb,MAAa,6BAA6B,eAAe;CAevD,AAAO,YAAY,SAA8E;AAC/F,SAAO;OAZF,OAAO,qBAAqB,KAAK;AAatC,OAAK,OAAO,qBAAqB,KAAK;AACtC,MAAI,SAAS;AACX,QAAK,KAAK,QAAQ,MAAM,KAAK,YAAY;AACzC,QAAK,OAAO,QAAQ;AACpB,OAAI,QAAQ,KAAM,MAAK,UAAU,EAAE,UAAU,QAAQ,MAAM,CAAC;;;;qBApBzC,OAAO,iBAAiB,0CAA0C;YAExF,mBAAmB,qBAAqB,KAAK"}
@@ -0,0 +1,20 @@
1
+ import { WorkflowTemplate } from "../../model/types.mjs";
2
+ import * as _credo_ts_didcomm0 from "@credo-ts/didcomm";
3
+ import { DidCommMessage } from "@credo-ts/didcomm";
4
+
5
+ //#region src/protocol/messages/TemplateMessage.d.ts
6
+ declare class TemplateMessage extends DidCommMessage {
7
+ static readonly type: _credo_ts_didcomm0.ParsedMessageType;
8
+ type: string;
9
+ body: {
10
+ template: WorkflowTemplate;
11
+ };
12
+ constructor(options?: {
13
+ id?: string;
14
+ body: TemplateMessage['body'];
15
+ thid?: string;
16
+ });
17
+ }
18
+ //#endregion
19
+ export { TemplateMessage };
20
+ //# sourceMappingURL=TemplateMessage.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TemplateMessage.d.mts","names":[],"sources":["../../../src/protocol/messages/TemplateMessage.ts"],"mappings":";;;;;cAIa,eAAA,SAAwB,cAAA;EAAA,gBACZ,IAAA,EADI,kBAAA,CACA,iBAAA;EAGpB,IAAA;EAEA,IAAA;IAAS,QAAA,EAAU,gBAAA;EAAA;cAEP,OAAA;IAAY,EAAA;IAAa,IAAA,EAAM,eAAA;IAAyB,IAAA;EAAA;AAAA"}
@@ -0,0 +1,25 @@
1
+ import { __decorateMetadata, init_decorateMetadata } from "../../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.mjs";
2
+ import { __decorate, init_decorate } from "../../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.mjs";
3
+ import { DidCommMessage, IsValidMessageType, parseMessageType } from "@credo-ts/didcomm";
4
+
5
+ //#region src/protocol/messages/TemplateMessage.ts
6
+ init_decorateMetadata();
7
+ init_decorate();
8
+ var TemplateMessage = class TemplateMessage extends DidCommMessage {
9
+ constructor(options) {
10
+ super();
11
+ this.type = TemplateMessage.type.messageTypeUri;
12
+ this.type = TemplateMessage.type.messageTypeUri;
13
+ if (options) {
14
+ this.id = options.id || this.generateId();
15
+ this.body = options.body;
16
+ if (options.thid) this.setThread({ threadId: options.thid });
17
+ }
18
+ }
19
+ };
20
+ TemplateMessage.type = parseMessageType("https://didcomm.org/workflow/1.0/template");
21
+ __decorate([IsValidMessageType(TemplateMessage.type), __decorateMetadata("design:type", Object)], TemplateMessage.prototype, "type", void 0);
22
+
23
+ //#endregion
24
+ export { TemplateMessage };
25
+ //# sourceMappingURL=TemplateMessage.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TemplateMessage.mjs","names":[],"sources":["../../../src/protocol/messages/TemplateMessage.ts"],"sourcesContent":["import type { WorkflowTemplate } from '../../model/types'\n\nimport { DidCommMessage, IsValidMessageType, parseMessageType } from '@credo-ts/didcomm'\n\nexport class TemplateMessage extends DidCommMessage {\n public static readonly type = parseMessageType('https://didcomm.org/workflow/1.0/template')\n\n @IsValidMessageType(TemplateMessage.type)\n public type = TemplateMessage.type.messageTypeUri\n\n public body!: { template: WorkflowTemplate }\n\n public constructor(options?: { id?: string; body: TemplateMessage['body']; thid?: string }) {\n super()\n this.type = TemplateMessage.type.messageTypeUri\n if (options) {\n this.id = options.id || this.generateId()\n this.body = options.body\n if (options.thid) this.setThread({ threadId: options.thid })\n }\n }\n}\n\n"],"mappings":";;;;;;;AAIA,IAAa,kBAAb,MAAa,wBAAwB,eAAe;CAQlD,AAAO,YAAY,SAAyE;AAC1F,SAAO;OALF,OAAO,gBAAgB,KAAK;AAMjC,OAAK,OAAO,gBAAgB,KAAK;AACjC,MAAI,SAAS;AACX,QAAK,KAAK,QAAQ,MAAM,KAAK,YAAY;AACzC,QAAK,OAAO,QAAQ;AACpB,OAAI,QAAQ,KAAM,MAAK,UAAU,EAAE,UAAU,QAAQ,MAAM,CAAC;;;;gBAbzC,OAAO,iBAAiB,4CAA4C;YAE1F,mBAAmB,gBAAgB,KAAK"}
@@ -0,0 +1,28 @@
1
+ import * as _credo_ts_didcomm0 from "@credo-ts/didcomm";
2
+ import { DidCommMessage } from "@credo-ts/didcomm";
3
+
4
+ //#region src/protocol/messages/WorkflowsMessage.d.ts
5
+ declare class WorkflowsMessage extends DidCommMessage {
6
+ static readonly type: _credo_ts_didcomm0.ParsedMessageType;
7
+ type: string;
8
+ body: {
9
+ workflows: Array<{
10
+ template_id: string;
11
+ versions: string[];
12
+ title?: string;
13
+ hash?: string;
14
+ }>;
15
+ paging?: {
16
+ total?: number;
17
+ next_offset?: number;
18
+ };
19
+ };
20
+ constructor(options?: {
21
+ id?: string;
22
+ body: WorkflowsMessage['body'];
23
+ thid?: string;
24
+ });
25
+ }
26
+ //#endregion
27
+ export { WorkflowsMessage };
28
+ //# sourceMappingURL=WorkflowsMessage.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WorkflowsMessage.d.mts","names":[],"sources":["../../../src/protocol/messages/WorkflowsMessage.ts"],"mappings":";;;;cAEa,gBAAA,SAAyB,cAAA;EAAA,gBACb,IAAA,EADK,kBAAA,CACD,iBAAA;EAGpB,IAAA;EAEA,IAAA;IACL,SAAA,EAAW,KAAA;MAAQ,WAAA;MAAqB,QAAA;MAAoB,KAAA;MAAgB,IAAA;IAAA;IAC5E,MAAA;MAAW,KAAA;MAAgB,WAAA;IAAA;EAAA;cAGV,OAAA;IAAY,EAAA;IAAa,IAAA,EAAM,gBAAA;IAA0B,IAAA;EAAA;AAAA"}
@@ -0,0 +1,25 @@
1
+ import { __decorateMetadata, init_decorateMetadata } from "../../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.mjs";
2
+ import { __decorate, init_decorate } from "../../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.mjs";
3
+ import { DidCommMessage, IsValidMessageType, parseMessageType } from "@credo-ts/didcomm";
4
+
5
+ //#region src/protocol/messages/WorkflowsMessage.ts
6
+ init_decorateMetadata();
7
+ init_decorate();
8
+ var WorkflowsMessage = class WorkflowsMessage extends DidCommMessage {
9
+ constructor(options) {
10
+ super();
11
+ this.type = WorkflowsMessage.type.messageTypeUri;
12
+ this.type = WorkflowsMessage.type.messageTypeUri;
13
+ if (options) {
14
+ this.id = options.id || this.generateId();
15
+ this.body = options.body;
16
+ if (options.thid) this.setThread({ threadId: options.thid });
17
+ }
18
+ }
19
+ };
20
+ WorkflowsMessage.type = parseMessageType("https://didcomm.org/workflow/1.0/workflows");
21
+ __decorate([IsValidMessageType(WorkflowsMessage.type), __decorateMetadata("design:type", Object)], WorkflowsMessage.prototype, "type", void 0);
22
+
23
+ //#endregion
24
+ export { WorkflowsMessage };
25
+ //# sourceMappingURL=WorkflowsMessage.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WorkflowsMessage.mjs","names":[],"sources":["../../../src/protocol/messages/WorkflowsMessage.ts"],"sourcesContent":["import { DidCommMessage, IsValidMessageType, parseMessageType } from '@credo-ts/didcomm'\n\nexport class WorkflowsMessage extends DidCommMessage {\n public static readonly type = parseMessageType('https://didcomm.org/workflow/1.0/workflows')\n\n @IsValidMessageType(WorkflowsMessage.type)\n public type = WorkflowsMessage.type.messageTypeUri\n\n public body!: {\n workflows: Array<{ template_id: string; versions: string[]; title?: string; hash?: string }>\n paging?: { total?: number; next_offset?: number }\n }\n\n public constructor(options?: { id?: string; body: WorkflowsMessage['body']; thid?: string }) {\n super()\n this.type = WorkflowsMessage.type.messageTypeUri\n if (options) {\n this.id = options.id || this.generateId()\n this.body = options.body\n if (options.thid) this.setThread({ threadId: options.thid })\n }\n }\n}\n\n"],"mappings":";;;;;;;AAEA,IAAa,mBAAb,MAAa,yBAAyB,eAAe;CAWnD,AAAO,YAAY,SAA0E;AAC3F,SAAO;OARF,OAAO,iBAAiB,KAAK;AASlC,OAAK,OAAO,iBAAiB,KAAK;AAClC,MAAI,SAAS;AACX,QAAK,KAAK,QAAQ,MAAM,KAAK,YAAY;AACzC,QAAK,OAAO,QAAQ;AACpB,OAAI,QAAQ,KAAM,MAAK,UAAU,EAAE,UAAU,QAAQ,MAAM,CAAC;;;;iBAhBzC,OAAO,iBAAiB,6CAA6C;YAE3F,mBAAmB,iBAAiB,KAAK"}
@@ -0,0 +1,22 @@
1
+ import { AgentContext } from "@credo-ts/core";
2
+
3
+ //#region src/queue/CommandQueue.d.ts
4
+ type WorkflowCommandJob = {
5
+ cmd: 'start' | 'advance' | 'pause' | 'resume' | 'cancel' | 'complete';
6
+ thid: string;
7
+ connectionId?: string;
8
+ idempotency_key?: string;
9
+ payload: Record<string, unknown>;
10
+ contextCorrelationId: string;
11
+ };
12
+ interface CommandQueue {
13
+ enqueue(agentContext: AgentContext, job: WorkflowCommandJob): Promise<void>;
14
+ startWorker(onJob: (job: WorkflowCommandJob) => Promise<void>): Promise<void>;
15
+ stop(): Promise<void>;
16
+ isReady(): Promise<boolean>;
17
+ triggerPoll?(): void;
18
+ }
19
+ declare class CommandQueueService {}
20
+ //#endregion
21
+ export { CommandQueue, CommandQueueService, WorkflowCommandJob };
22
+ //# sourceMappingURL=CommandQueue.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommandQueue.d.mts","names":[],"sources":["../../src/queue/CommandQueue.ts"],"mappings":";;;KAEY,kBAAA;EACV,GAAA;EACA,IAAA;EACA,YAAA;EACA,eAAA;EACA,OAAA,EAAS,MAAA;EACT,oBAAA;AAAA;AAAA,UAGe,YAAA;EACf,OAAA,CAAQ,YAAA,EAAc,YAAA,EAAc,GAAA,EAAK,kBAAA,GAAqB,OAAA;EAC9D,WAAA,CAAY,KAAA,GAAQ,GAAA,EAAK,kBAAA,KAAuB,OAAA,SAAgB,OAAA;EAChE,IAAA,IAAQ,OAAA;EACR,OAAA,IAAW,OAAA;EAEX,WAAA;AAAA;AAAA,cAIW,mBAAA"}
@@ -0,0 +1,6 @@
1
+ //#region src/queue/CommandQueue.ts
2
+ var CommandQueueService = class {};
3
+
4
+ //#endregion
5
+ export { CommandQueueService };
6
+ //# sourceMappingURL=CommandQueue.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommandQueue.mjs","names":[],"sources":["../../src/queue/CommandQueue.ts"],"sourcesContent":["import type { AgentContext } from '@credo-ts/core'\n\nexport type WorkflowCommandJob = {\n cmd: 'start' | 'advance' | 'pause' | 'resume' | 'cancel' | 'complete'\n thid: string\n connectionId?: string\n idempotency_key?: string\n payload: Record<string, unknown>\n contextCorrelationId: string\n}\n\nexport interface CommandQueue {\n enqueue(agentContext: AgentContext, job: WorkflowCommandJob): Promise<void>\n startWorker(onJob: (job: WorkflowCommandJob) => Promise<void>): Promise<void>\n stop(): Promise<void>\n isReady(): Promise<boolean>\n // Hint the queue to poll immediately (best-effort)\n triggerPoll?(): void\n}\n\n// DI token for the queue instance\nexport class CommandQueueService {}\n"],"mappings":";AAqBA,IAAa,sBAAb,MAAiC"}
@@ -0,0 +1,56 @@
1
+ import { WorkflowCommandRepository } from "../repository/WorkflowCommandRepository.mjs";
2
+ import { CommandQueue, WorkflowCommandJob } from "./CommandQueue.mjs";
3
+ import { AgentContext, AgentContextProvider } from "@credo-ts/core";
4
+
5
+ //#region src/queue/PersistentCommandQueue.d.ts
6
+ interface PersistentCommandQueueOptions {
7
+ pollIntervalMs?: number;
8
+ concurrency?: number;
9
+ processingTimeoutMs?: number;
10
+ staleCheckIntervalMs?: number;
11
+ cleanupIntervalMs?: number;
12
+ commandRetentionMs?: number;
13
+ failedRetentionMs?: number;
14
+ maxAttempts?: number;
15
+ }
16
+ declare class PersistentCommandQueue implements CommandQueue {
17
+ private readonly pollIntervalMs;
18
+ private readonly concurrency;
19
+ private readonly processingTimeoutMs;
20
+ private readonly staleCheckIntervalMs;
21
+ private readonly cleanupIntervalMs;
22
+ private readonly commandRetentionMs;
23
+ private readonly failedRetentionMs;
24
+ private readonly maxAttempts;
25
+ private running;
26
+ private activeCount;
27
+ private onJobHandler?;
28
+ private readonly repository;
29
+ private readonly contextProvider;
30
+ private readonly rootContext;
31
+ private readonly logger;
32
+ private readonly pendingSleeps;
33
+ constructor(repository: WorkflowCommandRepository, contextProvider: AgentContextProvider, rootContext: AgentContext, options?: PersistentCommandQueueOptions);
34
+ isReady(): Promise<boolean>;
35
+ enqueue(agentContext: AgentContext, job: WorkflowCommandJob): Promise<void>;
36
+ triggerPoll(): void;
37
+ startWorker(onJob: (job: WorkflowCommandJob) => Promise<void>): Promise<void>;
38
+ stop(): Promise<void>;
39
+ private pollLoop;
40
+ private poll;
41
+ private processCommand;
42
+ private staleCheckLoop;
43
+ private cleanupLoop;
44
+ private resolveContext;
45
+ private sleep;
46
+ getMetrics(): Promise<{
47
+ pending: number;
48
+ processing: number;
49
+ completed: number;
50
+ failed: number;
51
+ active: number;
52
+ }>;
53
+ }
54
+ //#endregion
55
+ export { PersistentCommandQueue, PersistentCommandQueueOptions };
56
+ //# sourceMappingURL=PersistentCommandQueue.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PersistentCommandQueue.d.mts","names":[],"sources":["../../src/queue/PersistentCommandQueue.ts"],"mappings":";;;;;UAOiB,6BAAA;EACf,cAAA;EACA,WAAA;EACA,mBAAA;EACA,oBAAA;EACA,iBAAA;EACA,kBAAA;EACA,iBAAA;EACA,WAAA;AAAA;AAAA,cAGW,sBAAA,YAAkC,YAAA;EAAA,iBAC5B,cAAA;EAAA,iBACA,WAAA;EAAA,iBACA,mBAAA;EAAA,iBACA,oBAAA;EAAA,iBACA,iBAAA;EAAA,iBACA,kBAAA;EAAA,iBACA,iBAAA;EAAA,iBACA,WAAA;EAAA,QAET,OAAA;EAAA,QACA,WAAA;EAAA,QACA,YAAA;EAAA,iBAES,UAAA;EAAA,iBACA,eAAA;EAAA,iBACA,WAAA;EAAA,iBACA,MAAA;EAAA,iBACA,aAAA;cAGf,UAAA,EAAY,yBAAA,EACZ,eAAA,EAAiB,oBAAA,EACjB,WAAA,EAAa,YAAA,EACb,OAAA,GAAU,6BAAA;EAiBC,OAAA,CAAA,GAAW,OAAA;EAIX,OAAA,CAAQ,YAAA,EAAc,YAAA,EAAc,GAAA,EAAK,kBAAA,GAAqB,OAAA;EAuCpE,WAAA,CAAA;EASM,WAAA,CAAY,KAAA,GAAQ,GAAA,EAAK,kBAAA,KAAuB,OAAA,SAAgB,OAAA;EAgBhE,IAAA,CAAA,GAAQ,OAAA;EAAA,QA6BP,QAAA;EAAA,QAaA,IAAA;EAAA,QAmCA,cAAA;EAAA,QA8FA,cAAA;EAAA,QA0BA,WAAA;EAAA,QAuBA,cAAA;EAAA,QAuCN,KAAA;EAgBK,UAAA,CAAA,GAAc,OAAA;IACzB,OAAA;IACA,UAAA;IACA,SAAA;IACA,MAAA;IACA,MAAA;EAAA;AAAA"}
@@ -0,0 +1,281 @@
1
+ import { WorkflowCommandRecord } from "../repository/WorkflowCommandRecord.mjs";
2
+ import "../repository/WorkflowCommandRepository.mjs";
3
+ import { AgentConfig, InjectionSymbols } from "@credo-ts/core";
4
+
5
+ //#region src/queue/PersistentCommandQueue.ts
6
+ var PersistentCommandQueue = class {
7
+ constructor(repository, contextProvider, rootContext, options) {
8
+ this.running = false;
9
+ this.activeCount = 0;
10
+ this.pendingSleeps = /* @__PURE__ */ new Set();
11
+ this.repository = repository;
12
+ this.contextProvider = contextProvider;
13
+ this.rootContext = rootContext;
14
+ this.logger = rootContext.dependencyManager.resolve(AgentConfig).logger;
15
+ this.pollIntervalMs = options?.pollIntervalMs ?? 100;
16
+ this.concurrency = Math.max(1, options?.concurrency ?? 3);
17
+ this.processingTimeoutMs = options?.processingTimeoutMs ?? 3e4;
18
+ this.staleCheckIntervalMs = options?.staleCheckIntervalMs ?? 5e3;
19
+ this.cleanupIntervalMs = options?.cleanupIntervalMs ?? 6e4;
20
+ this.commandRetentionMs = options?.commandRetentionMs ?? 36e5;
21
+ this.failedRetentionMs = options?.failedRetentionMs ?? 864e5;
22
+ this.maxAttempts = options?.maxAttempts ?? 3;
23
+ }
24
+ async isReady() {
25
+ return true;
26
+ }
27
+ async enqueue(agentContext, job) {
28
+ try {
29
+ if ((await this.repository.findByQuery(this.rootContext, { thid: job.thid }))?.some?.((r) => r.cmd === job.cmd && (r.status === "pending" || r.status === "processing"))) {
30
+ this.logger.debug(`[PersistentQueue] Dedup enqueue: command already queued (${job.cmd}) for ${job.thid}`);
31
+ return;
32
+ }
33
+ } catch {}
34
+ const record = new WorkflowCommandRecord({
35
+ cmd: job.cmd,
36
+ thid: job.thid,
37
+ connectionId: job.connectionId,
38
+ idempotencyKey: job.idempotency_key,
39
+ payload: job.payload,
40
+ contextCorrelationId: job.contextCorrelationId,
41
+ status: "pending",
42
+ attempts: 0,
43
+ createdAt: /* @__PURE__ */ new Date()
44
+ });
45
+ await this.repository.save(this.rootContext, record);
46
+ this.logger.debug(`[PersistentQueue] Enqueued command: ${job.cmd} for ${job.thid}`);
47
+ setImmediate(() => void this.poll());
48
+ }
49
+ triggerPoll() {
50
+ try {
51
+ setImmediate(() => void this.poll());
52
+ } catch {}
53
+ }
54
+ async startWorker(onJob) {
55
+ this.onJobHandler = onJob;
56
+ this.running = true;
57
+ this.logger.info("[PersistentQueue] Starting worker loops", {
58
+ pollIntervalMs: this.pollIntervalMs,
59
+ concurrency: this.concurrency,
60
+ processingTimeoutMs: this.processingTimeoutMs
61
+ });
62
+ this.pollLoop();
63
+ this.staleCheckLoop();
64
+ this.cleanupLoop();
65
+ }
66
+ async stop() {
67
+ this.logger.info("[PersistentQueue] Stopping worker...");
68
+ this.running = false;
69
+ for (const entry of Array.from(this.pendingSleeps)) {
70
+ try {
71
+ clearTimeout(entry.timer);
72
+ } catch {}
73
+ try {
74
+ entry.resolve();
75
+ } catch {}
76
+ this.pendingSleeps.delete(entry);
77
+ }
78
+ const maxWait = 1e4;
79
+ const start = Date.now();
80
+ while (this.activeCount > 0 && Date.now() - start < maxWait) await this.sleep(100);
81
+ if (this.activeCount > 0) this.logger.warn(`[PersistentQueue] Stopped with ${this.activeCount} active jobs`);
82
+ else this.logger.info("[PersistentQueue] Stopped cleanly");
83
+ }
84
+ async pollLoop() {
85
+ while (this.running) {
86
+ try {
87
+ await this.poll();
88
+ } catch (err) {
89
+ if (this.running && this.logger && typeof this.logger.error === "function") this.logger.error("[PersistentQueue] Poll error", { error: err.message });
90
+ }
91
+ await this.sleep(this.pollIntervalMs);
92
+ }
93
+ }
94
+ async poll() {
95
+ if (this.activeCount >= this.concurrency) return;
96
+ if (!this.onJobHandler) return;
97
+ const limit = this.concurrency - this.activeCount;
98
+ const pending = await this.repository.findPending(this.rootContext, limit);
99
+ if (pending.length > 0) try {
100
+ this.logger.info("[PersistentQueue] Pending commands fetched", { count: pending.length });
101
+ } catch {}
102
+ for (const record of pending) {
103
+ if (record.attempts >= this.maxAttempts) {
104
+ await this.repository.markFailed(this.rootContext, record, `Max attempts (${this.maxAttempts}) exceeded`);
105
+ this.logger.warn(`[PersistentQueue] Command ${record.id} failed after ${this.maxAttempts} attempts`);
106
+ continue;
107
+ }
108
+ await this.repository.markProcessing(this.rootContext, record);
109
+ this.activeCount++;
110
+ this.processCommand(record);
111
+ }
112
+ }
113
+ async processCommand(record) {
114
+ let scoped = null;
115
+ try {
116
+ scoped = await this.resolveContext(record.contextCorrelationId);
117
+ if (!scoped) throw new Error(`Unable to resolve context: ${record.contextCorrelationId}`);
118
+ const job = {
119
+ cmd: record.cmd,
120
+ thid: record.thid,
121
+ connectionId: record.connectionId,
122
+ idempotency_key: record.idempotencyKey,
123
+ payload: record.payload,
124
+ contextCorrelationId: record.contextCorrelationId
125
+ };
126
+ try {
127
+ this.logger.info("[PersistentQueue] Processing command", {
128
+ cmd: record.cmd,
129
+ thid: record.thid,
130
+ attempts: record.attempts
131
+ });
132
+ } catch {}
133
+ await this.onJobHandler(job);
134
+ await this.repository.markCompleted(this.rootContext, record);
135
+ try {
136
+ this.logger.info("[PersistentQueue] Completed command", {
137
+ cmd: record.cmd,
138
+ thid: record.thid
139
+ });
140
+ } catch {}
141
+ } catch (err) {
142
+ const errorMsg = err.message || "Unknown error";
143
+ const errCode = err?.code;
144
+ if (this.running && this.logger && typeof this.logger.error === "function") this.logger.error(`[PersistentQueue] Command processing failed: ${record.cmd} for ${record.thid}`, {
145
+ error: errorMsg,
146
+ attempts: record.attempts
147
+ });
148
+ if (errCode === "invalid_template") {
149
+ const maxTemplateFetches = 10;
150
+ if (record.attempts >= maxTemplateFetches) {
151
+ this.logger.error(`[PersistentQueue] Template fetch exhausted after ${record.attempts} attempts, marking failed`, {
152
+ cmd: record.cmd,
153
+ thid: record.thid
154
+ });
155
+ await this.repository.markFailed(this.rootContext, record, "Template not available after maximum fetch attempts");
156
+ return;
157
+ }
158
+ try {
159
+ await this.sleep(Math.min(200, this.pollIntervalMs * 2));
160
+ } catch {}
161
+ await this.repository.resetToPending(this.rootContext, record);
162
+ try {
163
+ this.logger.info("[PersistentQueue] Deferred command due to missing template; reset to pending", {
164
+ cmd: record.cmd,
165
+ thid: record.thid,
166
+ attempt: record.attempts,
167
+ maxAttempts: maxTemplateFetches
168
+ });
169
+ } catch {}
170
+ return;
171
+ }
172
+ if (record.attempts >= this.maxAttempts) await this.repository.markFailed(this.rootContext, record, errorMsg);
173
+ else {
174
+ await this.repository.resetToPending(this.rootContext, record);
175
+ try {
176
+ this.logger.info("[PersistentQueue] Resetting command to pending for retry", {
177
+ cmd: record.cmd,
178
+ thid: record.thid,
179
+ attempts: record.attempts
180
+ });
181
+ } catch {}
182
+ }
183
+ } finally {
184
+ try {
185
+ await scoped?.release?.();
186
+ } catch {}
187
+ this.activeCount--;
188
+ }
189
+ }
190
+ async staleCheckLoop() {
191
+ while (this.running) {
192
+ await this.sleep(this.staleCheckIntervalMs);
193
+ try {
194
+ const stale = await this.repository.findStale(this.rootContext, this.processingTimeoutMs);
195
+ for (const record of stale) {
196
+ this.logger.warn(`[PersistentQueue] Resetting stale command: ${record.cmd} for ${record.thid}`, {
197
+ attempts: record.attempts,
198
+ lastAttempt: record.lastAttemptAt?.toISOString()
199
+ });
200
+ if (record.attempts >= this.maxAttempts) await this.repository.markFailed(this.rootContext, record, "Stale after max attempts");
201
+ else await this.repository.resetToPending(this.rootContext, record);
202
+ }
203
+ } catch (err) {
204
+ if (this.running && this.logger && typeof this.logger.error === "function") this.logger.error("[PersistentQueue] Stale check error", { error: err.message });
205
+ }
206
+ }
207
+ }
208
+ async cleanupLoop() {
209
+ while (this.running) {
210
+ await this.sleep(this.cleanupIntervalMs);
211
+ try {
212
+ const completedCutoff = new Date(Date.now() - this.commandRetentionMs);
213
+ const failedCutoff = new Date(Date.now() - this.failedRetentionMs);
214
+ const [completedDeleted, failedDeleted] = await Promise.all([this.repository.deleteCompleted(this.rootContext, completedCutoff), this.repository.deleteFailed(this.rootContext, failedCutoff)]);
215
+ if (completedDeleted > 0 || failedDeleted > 0) this.logger.debug(`[PersistentQueue] Cleanup: deleted ${completedDeleted} completed, ${failedDeleted} failed`);
216
+ } catch (err) {
217
+ if (this.running && this.logger && typeof this.logger.error === "function") this.logger.error("[PersistentQueue] Cleanup error", { error: err.message });
218
+ }
219
+ }
220
+ }
221
+ async resolveContext(correlationId) {
222
+ const rootId = this.rootContext.contextCorrelationId;
223
+ if (!correlationId || correlationId === rootId) return {
224
+ context: this.rootContext,
225
+ release: async () => {}
226
+ };
227
+ try {
228
+ const scopedContext = await this.contextProvider.getAgentContextForContextCorrelationId(correlationId);
229
+ return {
230
+ context: scopedContext,
231
+ release: async () => {
232
+ try {
233
+ await this.contextProvider.endSessionForAgentContext(scopedContext);
234
+ } catch (error) {
235
+ this.logger.debug("[PersistentQueue] Failed to end tenant session", {
236
+ contextCorrelationId: correlationId,
237
+ error: error.message
238
+ });
239
+ }
240
+ }
241
+ };
242
+ } catch (error) {
243
+ if (this.running && this.logger && typeof this.logger.error === "function") this.logger.error("[PersistentQueue] Unable to resolve context, falling back to root", {
244
+ contextCorrelationId: correlationId,
245
+ error: error.message
246
+ });
247
+ return {
248
+ context: this.rootContext,
249
+ release: async () => {}
250
+ };
251
+ }
252
+ }
253
+ sleep(ms) {
254
+ return new Promise((outerResolve) => {
255
+ const entry = {
256
+ timer: void 0,
257
+ resolve: () => {}
258
+ };
259
+ const resolve = () => {
260
+ try {
261
+ outerResolve();
262
+ } finally {
263
+ this.pendingSleeps.delete(entry);
264
+ }
265
+ };
266
+ entry.resolve = resolve;
267
+ entry.timer = setTimeout(resolve, ms);
268
+ this.pendingSleeps.add(entry);
269
+ });
270
+ }
271
+ async getMetrics() {
272
+ return {
273
+ ...await this.repository.getMetrics(this.rootContext),
274
+ active: this.activeCount
275
+ };
276
+ }
277
+ };
278
+
279
+ //#endregion
280
+ export { PersistentCommandQueue };
281
+ //# sourceMappingURL=PersistentCommandQueue.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PersistentCommandQueue.mjs","names":[],"sources":["../../src/queue/PersistentCommandQueue.ts"],"sourcesContent":["import type { AgentContext, AgentContextProvider } from '@credo-ts/core'\nimport type { CommandQueue, WorkflowCommandJob } from './CommandQueue'\n\nimport { AgentConfig, InjectionSymbols } from '@credo-ts/core'\nimport { WorkflowCommandRecord } from '../repository/WorkflowCommandRecord'\nimport { WorkflowCommandRepository } from '../repository/WorkflowCommandRepository'\n\nexport interface PersistentCommandQueueOptions {\n pollIntervalMs?: number\n concurrency?: number\n processingTimeoutMs?: number\n staleCheckIntervalMs?: number\n cleanupIntervalMs?: number\n commandRetentionMs?: number\n failedRetentionMs?: number\n maxAttempts?: number\n}\n\nexport class PersistentCommandQueue implements CommandQueue {\n private readonly pollIntervalMs: number\n private readonly concurrency: number\n private readonly processingTimeoutMs: number\n private readonly staleCheckIntervalMs: number\n private readonly cleanupIntervalMs: number\n private readonly commandRetentionMs: number\n private readonly failedRetentionMs: number\n private readonly maxAttempts: number\n\n private running = false\n private activeCount = 0\n private onJobHandler?: (job: WorkflowCommandJob) => Promise<void>\n\n private readonly repository: WorkflowCommandRepository\n private readonly contextProvider: AgentContextProvider\n private readonly rootContext: AgentContext\n private readonly logger: AgentConfig['logger']\n private readonly pendingSleeps = new Set<{ timer: NodeJS.Timeout; resolve: () => void }>()\n\n public constructor(\n repository: WorkflowCommandRepository,\n contextProvider: AgentContextProvider,\n rootContext: AgentContext,\n options?: PersistentCommandQueueOptions\n ) {\n this.repository = repository\n this.contextProvider = contextProvider\n this.rootContext = rootContext\n this.logger = rootContext.dependencyManager.resolve(AgentConfig).logger\n\n this.pollIntervalMs = options?.pollIntervalMs ?? 100\n this.concurrency = Math.max(1, options?.concurrency ?? 3)\n this.processingTimeoutMs = options?.processingTimeoutMs ?? 30000\n this.staleCheckIntervalMs = options?.staleCheckIntervalMs ?? 5000\n this.cleanupIntervalMs = options?.cleanupIntervalMs ?? 60000\n this.commandRetentionMs = options?.commandRetentionMs ?? 3600000 // 1 hour\n this.failedRetentionMs = options?.failedRetentionMs ?? 86400000 // 24 hours\n this.maxAttempts = options?.maxAttempts ?? 3\n }\n\n public async isReady(): Promise<boolean> {\n return true // Always ready (uses existing storage)\n }\n\n public async enqueue(agentContext: AgentContext, job: WorkflowCommandJob): Promise<void> {\n // Always persist commands in the root context so a single worker can process\n // commands across tenants and resolve the proper context per job.\n // Deduplicate by (cmd, thid) when a command is already pending/processing\n try {\n const existing = await this.repository.findByQuery(this.rootContext, { thid: job.thid })\n if (\n existing?.some?.(\n (r) => r.cmd === job.cmd && (r.status === 'pending' || r.status === 'processing')\n )\n ) {\n this.logger.debug(\n `[PersistentQueue] Dedup enqueue: command already queued (${job.cmd}) for ${job.thid}`\n )\n return\n }\n } catch {\n // swallow and proceed to enqueue\n }\n\n const record = new WorkflowCommandRecord({\n cmd: job.cmd,\n thid: job.thid,\n connectionId: job.connectionId,\n idempotencyKey: job.idempotency_key,\n payload: job.payload,\n contextCorrelationId: job.contextCorrelationId,\n status: 'pending',\n attempts: 0,\n createdAt: new Date(),\n })\n\n await this.repository.save(this.rootContext, record)\n this.logger.debug(`[PersistentQueue] Enqueued command: ${job.cmd} for ${job.thid}`)\n\n // Trigger immediate poll (non-blocking)\n setImmediate(() => void this.poll())\n }\n\n public triggerPoll(): void {\n // Non-blocking immediate poll hint\n try {\n setImmediate(() => void this.poll())\n } catch {\n // best-effort only\n }\n }\n\n public async startWorker(onJob: (job: WorkflowCommandJob) => Promise<void>): Promise<void> {\n this.onJobHandler = onJob\n this.running = true\n\n this.logger.info('[PersistentQueue] Starting worker loops', {\n pollIntervalMs: this.pollIntervalMs,\n concurrency: this.concurrency,\n processingTimeoutMs: this.processingTimeoutMs,\n })\n\n // Start background loops (non-blocking)\n void this.pollLoop()\n void this.staleCheckLoop()\n void this.cleanupLoop()\n }\n\n public async stop(): Promise<void> {\n this.logger.info('[PersistentQueue] Stopping worker...')\n this.running = false\n\n // Cancel any pending sleep timers and resolve sleepers\n for (const entry of Array.from(this.pendingSleeps)) {\n try {\n clearTimeout(entry.timer)\n } catch {}\n try {\n entry.resolve()\n } catch {}\n this.pendingSleeps.delete(entry)\n }\n\n // Wait for active jobs to complete (with timeout)\n const maxWait = 10000\n const start = Date.now()\n while (this.activeCount > 0 && Date.now() - start < maxWait) {\n await this.sleep(100)\n }\n\n if (this.activeCount > 0) {\n this.logger.warn(`[PersistentQueue] Stopped with ${this.activeCount} active jobs`)\n } else {\n this.logger.info('[PersistentQueue] Stopped cleanly')\n }\n }\n\n private async pollLoop(): Promise<void> {\n while (this.running) {\n try {\n await this.poll()\n } catch (err) {\n if (this.running && this.logger && typeof this.logger.error === 'function') {\n this.logger.error('[PersistentQueue] Poll error', { error: (err as Error).message })\n }\n }\n await this.sleep(this.pollIntervalMs)\n }\n }\n\n private async poll(): Promise<void> {\n if (this.activeCount >= this.concurrency) return\n if (!this.onJobHandler) return\n\n const limit = this.concurrency - this.activeCount\n const pending = await this.repository.findPending(this.rootContext, limit)\n if (pending.length > 0) {\n try {\n this.logger.info('[PersistentQueue] Pending commands fetched', {\n count: pending.length,\n })\n } catch {}\n }\n\n for (const record of pending) {\n // Check max attempts before processing\n if (record.attempts >= this.maxAttempts) {\n await this.repository.markFailed(\n this.rootContext,\n record,\n `Max attempts (${this.maxAttempts}) exceeded`\n )\n this.logger.warn(`[PersistentQueue] Command ${record.id} failed after ${this.maxAttempts} attempts`)\n continue\n }\n\n // Mark as processing\n await this.repository.markProcessing(this.rootContext, record)\n this.activeCount++\n\n // Process in background\n void this.processCommand(record)\n }\n }\n\n private async processCommand(record: WorkflowCommandRecord): Promise<void> {\n let scoped: { context: AgentContext; release: () => Promise<void> } | null = null\n try {\n // Resolve tenant context\n scoped = await this.resolveContext(record.contextCorrelationId)\n\n if (!scoped) {\n throw new Error(`Unable to resolve context: ${record.contextCorrelationId}`)\n }\n\n const job: WorkflowCommandJob = {\n cmd: record.cmd,\n thid: record.thid,\n connectionId: record.connectionId,\n idempotency_key: record.idempotencyKey,\n payload: record.payload,\n contextCorrelationId: record.contextCorrelationId,\n }\n\n try {\n this.logger.info('[PersistentQueue] Processing command', {\n cmd: record.cmd,\n thid: record.thid,\n attempts: record.attempts,\n })\n } catch {}\n await this.onJobHandler!(job)\n\n // Mark as completed in root context (commands are stored centrally)\n await this.repository.markCompleted(this.rootContext, record)\n try {\n this.logger.info('[PersistentQueue] Completed command', {\n cmd: record.cmd,\n thid: record.thid,\n })\n } catch {}\n } catch (err) {\n const errorMsg = (err as Error).message || 'Unknown error'\n const errCode = (err as unknown as { code?: string })?.code\n if (this.running && this.logger && typeof this.logger.error === 'function') {\n this.logger.error(`[PersistentQueue] Command processing failed: ${record.cmd} for ${record.thid}`, {\n error: errorMsg,\n attempts: record.attempts,\n })\n }\n // Deferral for missing template: retry up to 10 times, then fail\n if (errCode === 'invalid_template') {\n const maxTemplateFetches = 10\n if (record.attempts >= maxTemplateFetches) {\n this.logger.error(`[PersistentQueue] Template fetch exhausted after ${record.attempts} attempts, marking failed`, {\n cmd: record.cmd,\n thid: record.thid,\n })\n await this.repository.markFailed(this.rootContext, record, 'Template not available after maximum fetch attempts')\n return\n }\n try {\n // Short backoff — template usually arrives within ~1s of fetch-template\n await this.sleep(Math.min(200, this.pollIntervalMs * 2))\n } catch {}\n await this.repository.resetToPending(this.rootContext, record)\n try {\n this.logger.info('[PersistentQueue] Deferred command due to missing template; reset to pending', {\n cmd: record.cmd,\n thid: record.thid,\n attempt: record.attempts,\n maxAttempts: maxTemplateFetches,\n })\n } catch {}\n return\n }\n\n // Mark as failed if max attempts reached, otherwise reset to pending for retry\n if (record.attempts >= this.maxAttempts) {\n await this.repository.markFailed(this.rootContext, record, errorMsg)\n } else {\n await this.repository.resetToPending(this.rootContext, record)\n try {\n this.logger.info('[PersistentQueue] Resetting command to pending for retry', {\n cmd: record.cmd,\n thid: record.thid,\n attempts: record.attempts,\n })\n } catch {}\n }\n } finally {\n // Always release scoped context if obtained\n try {\n await scoped?.release?.()\n } catch {}\n this.activeCount--\n }\n }\n\n private async staleCheckLoop(): Promise<void> {\n while (this.running) {\n await this.sleep(this.staleCheckIntervalMs)\n try {\n const stale = await this.repository.findStale(this.rootContext, this.processingTimeoutMs)\n\n for (const record of stale) {\n this.logger.warn(`[PersistentQueue] Resetting stale command: ${record.cmd} for ${record.thid}`, {\n attempts: record.attempts,\n lastAttempt: record.lastAttemptAt?.toISOString(),\n })\n\n if (record.attempts >= this.maxAttempts) {\n await this.repository.markFailed(this.rootContext, record, 'Stale after max attempts')\n } else {\n await this.repository.resetToPending(this.rootContext, record)\n }\n }\n } catch (err) {\n if (this.running && this.logger && typeof this.logger.error === 'function') {\n this.logger.error('[PersistentQueue] Stale check error', { error: (err as Error).message })\n }\n }\n }\n }\n\n private async cleanupLoop(): Promise<void> {\n while (this.running) {\n await this.sleep(this.cleanupIntervalMs)\n try {\n const completedCutoff = new Date(Date.now() - this.commandRetentionMs)\n const failedCutoff = new Date(Date.now() - this.failedRetentionMs)\n\n const [completedDeleted, failedDeleted] = await Promise.all([\n this.repository.deleteCompleted(this.rootContext, completedCutoff),\n this.repository.deleteFailed(this.rootContext, failedCutoff),\n ])\n\n if (completedDeleted > 0 || failedDeleted > 0) {\n this.logger.debug(`[PersistentQueue] Cleanup: deleted ${completedDeleted} completed, ${failedDeleted} failed`)\n }\n } catch (err) {\n if (this.running && this.logger && typeof this.logger.error === 'function') {\n this.logger.error('[PersistentQueue] Cleanup error', { error: (err as Error).message })\n }\n }\n }\n }\n\n private async resolveContext(\n correlationId: string\n ): Promise<{ context: AgentContext; release: () => Promise<void> } | null> {\n const rootId = this.rootContext.contextCorrelationId\n\n if (!correlationId || correlationId === rootId) {\n return { context: this.rootContext, release: async () => {} }\n }\n\n try {\n // Some inbound paths may enqueue with base context id (e.g., 'default').\n // If we can resolve it, do so; otherwise, fall back to root tenant context so\n // jobs in this queue are still processed under the tenant.\n const scopedContext = await this.contextProvider.getAgentContextForContextCorrelationId(correlationId)\n return {\n context: scopedContext,\n release: async () => {\n try {\n await this.contextProvider.endSessionForAgentContext(scopedContext)\n } catch (error) {\n this.logger.debug('[PersistentQueue] Failed to end tenant session', {\n contextCorrelationId: correlationId,\n error: (error as Error).message,\n })\n }\n },\n }\n } catch (error) {\n if (this.running && this.logger && typeof this.logger.error === 'function') {\n this.logger.error('[PersistentQueue] Unable to resolve context, falling back to root', {\n contextCorrelationId: correlationId,\n error: (error as Error).message,\n })\n }\n // Fallback: use the root agent context bound to this queue\n return { context: this.rootContext, release: async () => {} }\n }\n }\n\n private sleep(ms: number): Promise<void> {\n return new Promise((outerResolve) => {\n const entry = { timer: undefined as unknown as NodeJS.Timeout, resolve: () => {} }\n const resolve = () => {\n try {\n outerResolve()\n } finally {\n this.pendingSleeps.delete(entry)\n }\n }\n entry.resolve = resolve\n entry.timer = setTimeout(resolve, ms)\n this.pendingSleeps.add(entry)\n })\n }\n\n public async getMetrics(): Promise<{\n pending: number\n processing: number\n completed: number\n failed: number\n active: number\n }> {\n const repoMetrics = await this.repository.getMetrics(this.rootContext)\n return {\n ...repoMetrics,\n active: this.activeCount,\n }\n }\n}\n"],"mappings":";;;;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