@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,116 @@
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.CancelHandler = void 0;
13
+ const core_1 = require("@credo-ts/core");
14
+ const WorkflowModuleConfig_1 = require("../../WorkflowModuleConfig");
15
+ const CommandQueue_1 = require("../../queue/CommandQueue");
16
+ const WorkflowService_1 = require("../../services/WorkflowService");
17
+ const CancelMessage_1 = require("../messages/CancelMessage");
18
+ const ProblemReportMessage_1 = require("../messages/ProblemReportMessage");
19
+ const StatusMessage_1 = require("../messages/StatusMessage");
20
+ const WorkflowInstanceRepository_1 = require("../../repository/WorkflowInstanceRepository");
21
+ let CancelHandler = class CancelHandler {
22
+ constructor(service) {
23
+ this.service = service;
24
+ this.supportedMessages = [CancelMessage_1.CancelMessage];
25
+ }
26
+ async handle(messageContext) {
27
+ const dm = messageContext.agentContext.dependencyManager;
28
+ const logger = dm.resolve(core_1.AgentConfig).logger;
29
+ const config = dm.resolve(WorkflowModuleConfig_1.WorkflowModuleConfig);
30
+ const instId = messageContext.message.body?.instance_id;
31
+ const thid = messageContext.message.threadId || messageContext.message.id;
32
+ logger.info('[Workflow] cancel received', { instance_id: instId, thid });
33
+ // Strict correlation: thid MUST equal instance_id
34
+ try {
35
+ const _id = messageContext.message.body?.instance_id;
36
+ if (_id && thid && _id !== thid) {
37
+ throw Object.assign(new Error('threadId does not match instance_id'), { code: 'correlation_mismatch' });
38
+ }
39
+ }
40
+ catch (_e) {
41
+ void 0;
42
+ }
43
+ try {
44
+ // Enforce inbound connection matches instance binding
45
+ const inboundConnId = messageContext.connection?.id;
46
+ const instIdBody = messageContext.message.body?.instance_id;
47
+ if (!inboundConnId || !instIdBody) {
48
+ throw Object.assign(new Error('missing inbound connection'), { code: 'forbidden' });
49
+ }
50
+ const repo = messageContext.agentContext.dependencyManager.resolve(WorkflowInstanceRepository_1.WorkflowInstanceRepository);
51
+ const instRec = await repo.getByInstanceId(messageContext.agentContext, instIdBody);
52
+ if (!instRec) {
53
+ throw Object.assign(new Error('instance not found'), { code: 'invalid_event' });
54
+ }
55
+ if (instRec.connectionId && instRec.connectionId !== inboundConnId) {
56
+ throw Object.assign(new Error('connection mismatch'), { code: 'forbidden' });
57
+ }
58
+ // Enqueue command for async processing (always async now)
59
+ const queue = dm.resolve(CommandQueue_1.CommandQueueService);
60
+ if (queue && typeof queue.enqueue === 'function' && typeof queue.isReady === 'function') {
61
+ const ready = await queue.isReady();
62
+ if (ready) {
63
+ await queue.enqueue(messageContext.agentContext, {
64
+ cmd: 'cancel',
65
+ thid: instIdBody,
66
+ connectionId: inboundConnId,
67
+ payload: messageContext.message.body,
68
+ contextCorrelationId: messageContext.agentContext.contextCorrelationId,
69
+ });
70
+ // Immediate response with CURRENT state
71
+ const status = await this.service.status(messageContext.agentContext, { instance_id: instIdBody }, instRec);
72
+ const reply = new StatusMessage_1.StatusMessage({ thid, body: status });
73
+ return new core_1.OutboundMessageContext(reply, {
74
+ agentContext: messageContext.agentContext,
75
+ inboundMessageContext: messageContext,
76
+ connection: messageContext.connection,
77
+ });
78
+ }
79
+ }
80
+ // Fallback: queue not available, process synchronously
81
+ logger.warn('[Workflow] Queue not available for cancel, processing synchronously');
82
+ const updated = await this.service.cancel(messageContext.agentContext, messageContext.message.body, instRec);
83
+ const status = await this.service.status(messageContext.agentContext, { instance_id: instId }, updated);
84
+ const reply = new StatusMessage_1.StatusMessage({ thid, body: status });
85
+ return new core_1.OutboundMessageContext(reply, {
86
+ agentContext: messageContext.agentContext,
87
+ inboundMessageContext: messageContext,
88
+ connection: messageContext.connection,
89
+ });
90
+ }
91
+ catch (e) {
92
+ if (e?.code === 'invalid_event') {
93
+ logger.info('[Workflow] cancel ignored (no local instance)', { instance_id: instId });
94
+ return undefined;
95
+ }
96
+ if (config.enableProblemReport && messageContext.connection) {
97
+ const pr = new ProblemReportMessage_1.ProblemReportMessage({
98
+ thid: messageContext.message.threadId || messageContext.message.id,
99
+ body: { code: e.code || 'action_error', comment: e.message },
100
+ });
101
+ return new core_1.OutboundMessageContext(pr, {
102
+ agentContext: messageContext.agentContext,
103
+ inboundMessageContext: messageContext,
104
+ connection: messageContext.connection,
105
+ });
106
+ }
107
+ throw e;
108
+ }
109
+ }
110
+ };
111
+ exports.CancelHandler = CancelHandler;
112
+ exports.CancelHandler = CancelHandler = __decorate([
113
+ (0, core_1.injectable)(),
114
+ __metadata("design:paramtypes", [WorkflowService_1.WorkflowService])
115
+ ], CancelHandler);
116
+ //# sourceMappingURL=CancelHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CancelHandler.js","sourceRoot":"","sources":["../../../src/protocol/handlers/CancelHandler.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,yCAAgF;AAEhF,qEAAiE;AACjE,2DAA8D;AAC9D,oEAAgE;AAChE,6DAAyD;AACzD,2EAAuE;AACvE,6DAAyD;AACzD,4FAAwF;AAGjF,IAAM,aAAa,GAAnB,MAAM,aAAa;IAExB,YAAoC,OAAwB;QAAxB,YAAO,GAAP,OAAO,CAAiB;QADrD,sBAAiB,GAAG,CAAC,6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,CAAC,mBAAmB,IAAI,cAAc,CAAC,UAAU,EAAE,CAAC;gBAC5D,MAAM,EAAE,GAAG,IAAI,2CAAoB,CAAC;oBAClC,IAAI,EAAE,cAAc,CAAC,OAAO,CAAC,QAAQ,IAAI,cAAc,CAAC,OAAO,CAAC,EAAE;oBAClE,IAAI,EAAE,EAAE,IAAI,EAAG,CAAuB,CAAC,IAAI,IAAI,cAAc,EAAE,OAAO,EAAG,CAAW,CAAC,OAAO,EAAE;iBAC/F,CAAC,CAAA;gBACF,OAAO,IAAI,6BAAsB,CAAC,EAAE,EAAE;oBACpC,YAAY,EAAE,cAAc,CAAC,YAAY;oBACzC,qBAAqB,EAAE,cAAc;oBACrC,UAAU,EAAE,cAAc,CAAC,UAAU;iBACtC,CAAC,CAAA;YACJ,CAAC;YACD,MAAM,CAAC,CAAA;QACT,CAAC;IACH,CAAC;CACF,CAAA;AA5FY,sCAAa;wBAAb,aAAa;IADzB,IAAA,iBAAU,GAAE;qCAGkC,iCAAe;GAFjD,aAAa,CA4FzB"}
@@ -0,0 +1,12 @@
1
+ import type { MessageHandler, MessageHandlerInboundMessage } from '@credo-ts/core';
2
+ import { OutboundMessageContext } from '@credo-ts/core';
3
+ import { WorkflowService } from '../../services/WorkflowService';
4
+ import { CompleteMessage } from '../messages/CompleteMessage';
5
+ import { ProblemReportMessage } from '../messages/ProblemReportMessage';
6
+ import { StatusMessage } from '../messages/StatusMessage';
7
+ export declare class CompleteHandler implements MessageHandler {
8
+ private readonly service;
9
+ supportedMessages: (typeof CompleteMessage)[];
10
+ constructor(service: WorkflowService);
11
+ handle(messageContext: MessageHandlerInboundMessage<CompleteHandler>): Promise<OutboundMessageContext<StatusMessage> | OutboundMessageContext<ProblemReportMessage> | undefined>;
12
+ }
@@ -0,0 +1,117 @@
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.CompleteHandler = void 0;
13
+ const core_1 = require("@credo-ts/core");
14
+ const WorkflowModuleConfig_1 = require("../../WorkflowModuleConfig");
15
+ const CommandQueue_1 = require("../../queue/CommandQueue");
16
+ const WorkflowService_1 = require("../../services/WorkflowService");
17
+ const CompleteMessage_1 = require("../messages/CompleteMessage");
18
+ const ProblemReportMessage_1 = require("../messages/ProblemReportMessage");
19
+ const StatusMessage_1 = require("../messages/StatusMessage");
20
+ const WorkflowInstanceRepository_1 = require("../../repository/WorkflowInstanceRepository");
21
+ let CompleteHandler = class CompleteHandler {
22
+ constructor(service) {
23
+ this.service = service;
24
+ this.supportedMessages = [CompleteMessage_1.CompleteMessage];
25
+ }
26
+ async handle(messageContext) {
27
+ const dm = messageContext.agentContext.dependencyManager;
28
+ const logger = dm.resolve(core_1.AgentConfig).logger;
29
+ const config = dm.resolve(WorkflowModuleConfig_1.WorkflowModuleConfig);
30
+ const instId = messageContext.message.body?.instance_id;
31
+ const thid = messageContext.message.threadId || messageContext.message.id;
32
+ logger.info('[Workflow] complete received', { instance_id: instId, thid });
33
+ // Strict correlation: thid MUST equal instance_id
34
+ try {
35
+ const _id = messageContext.message.body?.instance_id;
36
+ if (_id && thid && _id !== thid) {
37
+ throw Object.assign(new Error('threadId does not match instance_id'), { code: 'correlation_mismatch' });
38
+ }
39
+ }
40
+ catch (_e) {
41
+ void 0;
42
+ }
43
+ try {
44
+ // Enforce inbound connection matches instance binding
45
+ const inboundConnId = messageContext.connection?.id;
46
+ const instIdBody = messageContext.message.body?.instance_id;
47
+ if (!inboundConnId || !instIdBody) {
48
+ throw Object.assign(new Error('missing inbound connection'), { code: 'forbidden' });
49
+ }
50
+ const repo = messageContext.agentContext.dependencyManager.resolve(WorkflowInstanceRepository_1.WorkflowInstanceRepository);
51
+ const instRec = await repo.getByInstanceId(messageContext.agentContext, instIdBody);
52
+ if (!instRec) {
53
+ throw Object.assign(new Error('instance not found'), { code: 'invalid_event' });
54
+ }
55
+ if (instRec.connectionId && instRec.connectionId !== inboundConnId) {
56
+ throw Object.assign(new Error('connection mismatch'), { code: 'forbidden' });
57
+ }
58
+ // Enqueue command for async processing (always async now)
59
+ const queue = dm.resolve(CommandQueue_1.CommandQueueService);
60
+ if (queue && typeof queue.enqueue === 'function' && typeof queue.isReady === 'function') {
61
+ const ready = await queue.isReady();
62
+ if (ready) {
63
+ await queue.enqueue(messageContext.agentContext, {
64
+ cmd: 'complete',
65
+ thid: instIdBody,
66
+ connectionId: inboundConnId,
67
+ payload: messageContext.message.body,
68
+ contextCorrelationId: messageContext.agentContext.contextCorrelationId,
69
+ });
70
+ // Immediate response with CURRENT state
71
+ const status = await this.service.status(messageContext.agentContext, { instance_id: instIdBody }, instRec);
72
+ const reply = new StatusMessage_1.StatusMessage({ thid, body: status });
73
+ return new core_1.OutboundMessageContext(reply, {
74
+ agentContext: messageContext.agentContext,
75
+ inboundMessageContext: messageContext,
76
+ connection: messageContext.connection,
77
+ });
78
+ }
79
+ }
80
+ // Fallback: queue not available, process synchronously
81
+ logger.warn('[Workflow] Queue not available for complete, processing synchronously');
82
+ const updated = await this.service.complete(messageContext.agentContext, messageContext.message.body, instRec);
83
+ const status = await this.service.status(messageContext.agentContext, { instance_id: instId }, updated);
84
+ const reply = new StatusMessage_1.StatusMessage({ thid, body: status });
85
+ return new core_1.OutboundMessageContext(reply, {
86
+ agentContext: messageContext.agentContext,
87
+ inboundMessageContext: messageContext,
88
+ connection: messageContext.connection,
89
+ });
90
+ }
91
+ catch (e) {
92
+ // If the receiving agent doesn't host the instance, ignore silently (no problem-report)
93
+ if (e?.code === 'invalid_event') {
94
+ logger.info('[Workflow] complete ignored (no local instance)', { instance_id: instId });
95
+ return undefined;
96
+ }
97
+ if (config.enableProblemReport && messageContext.connection) {
98
+ const pr = new ProblemReportMessage_1.ProblemReportMessage({
99
+ thid,
100
+ body: { code: e.code || 'action_error', comment: e.message },
101
+ });
102
+ return new core_1.OutboundMessageContext(pr, {
103
+ agentContext: messageContext.agentContext,
104
+ inboundMessageContext: messageContext,
105
+ connection: messageContext.connection,
106
+ });
107
+ }
108
+ throw e;
109
+ }
110
+ }
111
+ };
112
+ exports.CompleteHandler = CompleteHandler;
113
+ exports.CompleteHandler = CompleteHandler = __decorate([
114
+ (0, core_1.injectable)(),
115
+ __metadata("design:paramtypes", [WorkflowService_1.WorkflowService])
116
+ ], CompleteHandler);
117
+ //# sourceMappingURL=CompleteHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CompleteHandler.js","sourceRoot":"","sources":["../../../src/protocol/handlers/CompleteHandler.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,yCAAgF;AAEhF,qEAAiE;AACjE,2DAA8D;AAC9D,oEAAgE;AAChE,iEAA6D;AAC7D,2EAAuE;AACvE,6DAAyD;AACzD,4FAAwF;AAGjF,IAAM,eAAe,GAArB,MAAM,eAAe;IAE1B,YAAoC,OAAwB;QAAxB,YAAO,GAAP,OAAO,CAAiB;QADrD,sBAAiB,GAAG,CAAC,iCAAe,CAAC,CAAA;IACmB,CAAC;IACzD,KAAK,CAAC,MAAM,CAAC,cAA6D;QAC/E,MAAM,EAAE,GAAG,cAAc,CAAC,YAAY,CAAC,iBAAiB,CAAA;QACxD,MAAM,MAAM,GAAG,EAAE,CAAC,OAAO,CAAC,kBAAW,CAAC,CAAC,MAAM,CAAA;QAC7C,MAAM,MAAM,GAAG,EAAE,CAAC,OAAO,CAAC,2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ACF,OAAO,IAAI,6BAAsB,CAAC,EAAE,EAAE;oBACpC,YAAY,EAAE,cAAc,CAAC,YAAY;oBACzC,qBAAqB,EAAE,cAAc;oBACrC,UAAU,EAAE,cAAc,CAAC,UAAU;iBACtC,CAAC,CAAA;YACJ,CAAC;YACD,MAAM,CAAC,CAAA;QACT,CAAC;IACH,CAAC;CACF,CAAA;AA7FY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,iBAAU,GAAE;qCAGkC,iCAAe;GAFjD,eAAe,CA6F3B"}
@@ -0,0 +1,11 @@
1
+ import type { MessageHandler, MessageHandlerInboundMessage } from '@credo-ts/core';
2
+ import { OutboundMessageContext } from '@credo-ts/core';
3
+ import { WorkflowTemplateRepository } from '../../repository/WorkflowTemplateRepository';
4
+ import { DiscoverMessage } from '../messages/DiscoverMessage';
5
+ import { WorkflowsMessage } from '../messages/WorkflowsMessage';
6
+ export declare class DiscoverHandler implements MessageHandler {
7
+ private readonly templateRepo;
8
+ supportedMessages: (typeof DiscoverMessage)[];
9
+ constructor(templateRepo: WorkflowTemplateRepository);
10
+ handle(messageContext: MessageHandlerInboundMessage<DiscoverHandler>): Promise<OutboundMessageContext<WorkflowsMessage>>;
11
+ }
@@ -0,0 +1,71 @@
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.DiscoverHandler = void 0;
13
+ const core_1 = require("@credo-ts/core");
14
+ const WorkflowTemplateRepository_1 = require("../../repository/WorkflowTemplateRepository");
15
+ const DiscoverMessage_1 = require("../messages/DiscoverMessage");
16
+ const WorkflowsMessage_1 = require("../messages/WorkflowsMessage");
17
+ let DiscoverHandler = class DiscoverHandler {
18
+ constructor(templateRepo) {
19
+ this.templateRepo = templateRepo;
20
+ this.supportedMessages = [DiscoverMessage_1.DiscoverMessage];
21
+ }
22
+ async handle(messageContext) {
23
+ const dm = messageContext.agentContext.dependencyManager;
24
+ const logger = dm.resolve(core_1.AgentConfig).logger;
25
+ const { filters, paging, include_hash } = messageContext.message.body || {};
26
+ logger.info('[Workflow] discover received', { filters, include_hash });
27
+ const all = await this.templateRepo.getAll(messageContext.agentContext);
28
+ const filtered = all.filter((r) => {
29
+ const matchesId = !filters?.template_id || r.template.template_id === filters?.template_id;
30
+ const matchesVer = !filters?.version || r.template.version === filters?.version;
31
+ return matchesId && matchesVer;
32
+ });
33
+ const byId = new Map();
34
+ for (const rec of filtered) {
35
+ const arr = byId.get(rec.template.template_id) || [];
36
+ arr.push(rec);
37
+ byId.set(rec.template.template_id, arr);
38
+ }
39
+ const items = [];
40
+ for (const [templateId, recs] of byId.entries()) {
41
+ const versions = recs.map((r) => r.template.version).sort((a, b) => b.localeCompare(a));
42
+ const title = recs[0]?.template?.title;
43
+ let hash;
44
+ if (include_hash && versions.length === 1) {
45
+ hash = recs[0]?.hash;
46
+ }
47
+ items.push({ template_id: templateId, versions, title, ...(hash ? { hash } : {}) });
48
+ }
49
+ // Simple paging
50
+ const offset = paging?.offset ?? 0;
51
+ const limit = paging?.limit ?? items.length;
52
+ const pageItems = items.slice(offset, offset + limit);
53
+ const body = { workflows: pageItems, paging: { total: items.length, next_offset: offset + pageItems.length } };
54
+ const reply = new WorkflowsMessage_1.WorkflowsMessage({
55
+ thid: messageContext.message.threadId || messageContext.message.id,
56
+ body,
57
+ });
58
+ return new core_1.OutboundMessageContext(reply, {
59
+ agentContext: messageContext.agentContext,
60
+ // reply over the same inbound session when available for faster turnaround
61
+ inboundMessageContext: messageContext,
62
+ connection: messageContext.connection,
63
+ });
64
+ }
65
+ };
66
+ exports.DiscoverHandler = DiscoverHandler;
67
+ exports.DiscoverHandler = DiscoverHandler = __decorate([
68
+ (0, core_1.injectable)(),
69
+ __metadata("design:paramtypes", [WorkflowTemplateRepository_1.WorkflowTemplateRepository])
70
+ ], DiscoverHandler);
71
+ //# sourceMappingURL=DiscoverHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DiscoverHandler.js","sourceRoot":"","sources":["../../../src/protocol/handlers/DiscoverHandler.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,yCAAgF;AAEhF,4FAAwF;AACxF,iEAA6D;AAC7D,mEAA+D;AAGxD,IAAM,eAAe,GAArB,MAAM,eAAe;IAG1B,YAAoC,YAAwC;QAAxC,iBAAY,GAAZ,YAAY,CAA4B;QAFrE,sBAAiB,GAAG,CAAC,iCAAe,CAAC,CAAA;IAEmC,CAAC;IAEzE,KAAK,CAAC,MAAM,CAAC,cAA6D;QAC/E,MAAM,EAAE,GAAG,cAAc,CAAC,YAAY,CAAC,iBAAiB,CAAA;QACxD,MAAM,MAAM,GAAG,EAAE,CAAC,OAAO,CAAC,kBAAW,CAAC,CAAC,MAAM,CAAA;QAC7C,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,cAAc,CAAC,OAAO,CAAC,IAAI,IAAI,EAAE,CAAA;QAC3E,MAAM,CAAC,IAAI,CAAC,8BAA8B,EAAE,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC,CAAA;QAEtE,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,cAAc,CAAC,YAAY,CAAC,CAAA;QACvE,MAAM,QAAQ,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE;YAChC,MA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YACD,KAAK,CAAC,IAAI,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAA;QACrF,CAAC;QACD,gBAAgB;QAChB,MAAM,MAAM,GAAG,MAAM,EAAE,MAAM,IAAI,CAAC,CAAA;QAClC,MAAM,KAAK,GAAG,MAAM,EAAE,KAAK,IAAI,KAAK,CAAC,MAAM,CAAA;QAC3C,MAAM,SAAS,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,KAAK,CAAC,CAAA;QACrD,MAAM,IAAI,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,EAAE,CAAA;QAC9G,MAAM,KAAK,GAAG,IAAI,mCAAgB,CAAC;YACjC,IAAI,EAAE,cAAc,CAAC,OAAO,CAAC,QAAQ,IAAI,cAAc,CAAC,OAAO,CAAC,EAAE;YAClE,IAAI;SACL,CAAC,CAAA;QACF,OAAO,IAAI,6BAAsB,CAAC,KAAK,EAAE;YACvC,YAAY,EAAE,cAAc,CAAC,YAAY;YACzC,2EAA2E;YAC3E,qBAAqB,EAAE,cAAc;YACrC,UAAU,EAAE,cAAc,CAAC,UAAU;SACtC,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AAjDY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,iBAAU,GAAE;qCAIuC,uDAA0B;GAHjE,eAAe,CAiD3B"}
@@ -0,0 +1,12 @@
1
+ import type { MessageHandler, MessageHandlerInboundMessage } from '@credo-ts/core';
2
+ import { OutboundMessageContext } from '@credo-ts/core';
3
+ import { WorkflowTemplateRepository } from '../../repository/WorkflowTemplateRepository';
4
+ import { FetchTemplateMessage } from '../messages/FetchTemplateMessage';
5
+ import { ProblemReportMessage } from '../messages/ProblemReportMessage';
6
+ import { TemplateMessage } from '../messages/TemplateMessage';
7
+ export declare class FetchTemplateHandler implements MessageHandler {
8
+ private readonly templateRepo;
9
+ supportedMessages: (typeof FetchTemplateMessage)[];
10
+ constructor(templateRepo: WorkflowTemplateRepository);
11
+ handle(messageContext: MessageHandlerInboundMessage<FetchTemplateHandler>): Promise<OutboundMessageContext<ProblemReportMessage> | OutboundMessageContext<TemplateMessage>>;
12
+ }
@@ -0,0 +1,71 @@
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.FetchTemplateHandler = void 0;
13
+ const core_1 = require("@credo-ts/core");
14
+ const WorkflowModuleConfig_1 = require("../../WorkflowModuleConfig");
15
+ const WorkflowTemplateRepository_1 = require("../../repository/WorkflowTemplateRepository");
16
+ const FetchTemplateMessage_1 = require("../messages/FetchTemplateMessage");
17
+ const ProblemReportMessage_1 = require("../messages/ProblemReportMessage");
18
+ const TemplateMessage_1 = require("../messages/TemplateMessage");
19
+ let FetchTemplateHandler = class FetchTemplateHandler {
20
+ constructor(templateRepo) {
21
+ this.templateRepo = templateRepo;
22
+ this.supportedMessages = [FetchTemplateMessage_1.FetchTemplateMessage];
23
+ }
24
+ async handle(messageContext) {
25
+ const dm = messageContext.agentContext.dependencyManager;
26
+ const logger = dm.resolve(core_1.AgentConfig).logger;
27
+ const config = dm.resolve(WorkflowModuleConfig_1.WorkflowModuleConfig);
28
+ const { template_id, template_version, prefer_hash } = messageContext.message.body || {};
29
+ const thid = messageContext.message.threadId || messageContext.message.id;
30
+ logger.info('[Workflow] fetch-template received', { template_id, template_version, thid });
31
+ try {
32
+ const rec = await this.templateRepo.findByTemplateIdAndVersion(messageContext.agentContext, template_id, template_version);
33
+ if (!rec)
34
+ throw Object.assign(new Error('template not found'), { code: 'not_found_remote_template' });
35
+ if (prefer_hash && rec.hash && prefer_hash !== rec.hash) {
36
+ throw Object.assign(new Error('template hash mismatch'), { code: 'not_found_remote_template' });
37
+ }
38
+ const reply = new TemplateMessage_1.TemplateMessage({
39
+ thid,
40
+ body: { template: rec.template },
41
+ });
42
+ return new core_1.OutboundMessageContext(reply, {
43
+ agentContext: messageContext.agentContext,
44
+ // reply over the same inbound session when available for faster turnaround
45
+ inboundMessageContext: messageContext,
46
+ connection: messageContext.connection,
47
+ });
48
+ }
49
+ catch (e) {
50
+ if (config.enableProblemReport && messageContext.connection) {
51
+ const pr = new ProblemReportMessage_1.ProblemReportMessage({
52
+ thid,
53
+ body: { code: e.code || 'not_found_remote_template', comment: e.message },
54
+ });
55
+ return new core_1.OutboundMessageContext(pr, {
56
+ agentContext: messageContext.agentContext,
57
+ // reply over the same inbound session when available for faster turnaround
58
+ inboundMessageContext: messageContext,
59
+ connection: messageContext.connection,
60
+ });
61
+ }
62
+ throw e;
63
+ }
64
+ }
65
+ };
66
+ exports.FetchTemplateHandler = FetchTemplateHandler;
67
+ exports.FetchTemplateHandler = FetchTemplateHandler = __decorate([
68
+ (0, core_1.injectable)(),
69
+ __metadata("design:paramtypes", [WorkflowTemplateRepository_1.WorkflowTemplateRepository])
70
+ ], FetchTemplateHandler);
71
+ //# sourceMappingURL=FetchTemplateHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FetchT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from '@credo-ts/core';
3
+ import { WorkflowService } from '../../services/WorkflowService';
4
+ import { PauseMessage } from '../messages/PauseMessage';
5
+ import { ProblemReportMessage } from '../messages/ProblemReportMessage';
6
+ import { StatusMessage } from '../messages/StatusMessage';
7
+ export declare class PauseHandler implements MessageHandler {
8
+ private readonly service;
9
+ supportedMessages: (typeof PauseMessage)[];
10
+ constructor(service: WorkflowService);
11
+ handle(messageContext: MessageHandlerInboundMessage<PauseHandler>): Promise<OutboundMessageContext<StatusMessage> | OutboundMessageContext<ProblemReportMessage> | undefined>;
12
+ }
@@ -0,0 +1,116 @@
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.PauseHandler = void 0;
13
+ const core_1 = require("@credo-ts/core");
14
+ const WorkflowModuleConfig_1 = require("../../WorkflowModuleConfig");
15
+ const CommandQueue_1 = require("../../queue/CommandQueue");
16
+ const WorkflowService_1 = require("../../services/WorkflowService");
17
+ const PauseMessage_1 = require("../messages/PauseMessage");
18
+ const ProblemReportMessage_1 = require("../messages/ProblemReportMessage");
19
+ const StatusMessage_1 = require("../messages/StatusMessage");
20
+ const WorkflowInstanceRepository_1 = require("../../repository/WorkflowInstanceRepository");
21
+ let PauseHandler = class PauseHandler {
22
+ constructor(service) {
23
+ this.service = service;
24
+ this.supportedMessages = [PauseMessage_1.PauseMessage];
25
+ }
26
+ async handle(messageContext) {
27
+ const dm = messageContext.agentContext.dependencyManager;
28
+ const logger = dm.resolve(core_1.AgentConfig).logger;
29
+ const config = dm.resolve(WorkflowModuleConfig_1.WorkflowModuleConfig);
30
+ const instId = messageContext.message.body?.instance_id;
31
+ const thid = messageContext.message.threadId || messageContext.message.id;
32
+ logger.info('[Workflow] pause received', { instance_id: instId, thid });
33
+ // Strict correlation: thid MUST equal instance_id
34
+ try {
35
+ const _id = messageContext.message.body?.instance_id;
36
+ if (_id && thid && _id !== thid) {
37
+ throw Object.assign(new Error('threadId does not match instance_id'), { code: 'correlation_mismatch' });
38
+ }
39
+ }
40
+ catch (_e) {
41
+ void 0;
42
+ }
43
+ try {
44
+ // Enforce inbound connection matches instance binding
45
+ const inboundConnId = messageContext.connection?.id;
46
+ const instIdBody = messageContext.message.body?.instance_id;
47
+ if (!inboundConnId || !instIdBody) {
48
+ throw Object.assign(new Error('missing inbound connection'), { code: 'forbidden' });
49
+ }
50
+ const repo = messageContext.agentContext.dependencyManager.resolve(WorkflowInstanceRepository_1.WorkflowInstanceRepository);
51
+ const instRec = await repo.getByInstanceId(messageContext.agentContext, instIdBody);
52
+ if (!instRec) {
53
+ throw Object.assign(new Error('instance not found'), { code: 'invalid_event' });
54
+ }
55
+ if (instRec.connectionId && instRec.connectionId !== inboundConnId) {
56
+ throw Object.assign(new Error('connection mismatch'), { code: 'forbidden' });
57
+ }
58
+ // Enqueue command for async processing (always async now)
59
+ const queue = dm.resolve(CommandQueue_1.CommandQueueService);
60
+ if (queue && typeof queue.enqueue === 'function' && typeof queue.isReady === 'function') {
61
+ const ready = await queue.isReady();
62
+ if (ready) {
63
+ await queue.enqueue(messageContext.agentContext, {
64
+ cmd: 'pause',
65
+ thid: instIdBody,
66
+ connectionId: inboundConnId,
67
+ payload: messageContext.message.body,
68
+ contextCorrelationId: messageContext.agentContext.contextCorrelationId,
69
+ });
70
+ // Immediate response with CURRENT state
71
+ const status = await this.service.status(messageContext.agentContext, { instance_id: instIdBody }, instRec);
72
+ const reply = new StatusMessage_1.StatusMessage({ thid, body: status });
73
+ return new core_1.OutboundMessageContext(reply, {
74
+ agentContext: messageContext.agentContext,
75
+ inboundMessageContext: messageContext,
76
+ connection: messageContext.connection,
77
+ });
78
+ }
79
+ }
80
+ // Fallback: queue not available, process synchronously
81
+ logger.warn('[Workflow] Queue not available for pause, processing synchronously');
82
+ const updated = await this.service.pause(messageContext.agentContext, messageContext.message.body, instRec);
83
+ const status = await this.service.status(messageContext.agentContext, { instance_id: instId }, updated);
84
+ const reply = new StatusMessage_1.StatusMessage({ thid, body: status });
85
+ return new core_1.OutboundMessageContext(reply, {
86
+ agentContext: messageContext.agentContext,
87
+ inboundMessageContext: messageContext,
88
+ connection: messageContext.connection,
89
+ });
90
+ }
91
+ catch (e) {
92
+ if (e?.code === 'invalid_event') {
93
+ logger.info('[Workflow] pause ignored (no local instance)', { instance_id: instId });
94
+ return undefined;
95
+ }
96
+ if (config.enableProblemReport && messageContext.connection) {
97
+ const pr = new ProblemReportMessage_1.ProblemReportMessage({
98
+ thid: messageContext.message.threadId || messageContext.message.id,
99
+ body: { code: e.code || 'action_error', comment: e.message },
100
+ });
101
+ return new core_1.OutboundMessageContext(pr, {
102
+ agentContext: messageContext.agentContext,
103
+ inboundMessageContext: messageContext,
104
+ connection: messageContext.connection,
105
+ });
106
+ }
107
+ throw e;
108
+ }
109
+ }
110
+ };
111
+ exports.PauseHandler = PauseHandler;
112
+ exports.PauseHandler = PauseHandler = __decorate([
113
+ (0, core_1.injectable)(),
114
+ __metadata("design:paramtypes", [WorkflowService_1.WorkflowService])
115
+ ], PauseHandler);
116
+ //# sourceMappingURL=PauseHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PauseHandler.js","sourceRoot":"","sources":["../../../src/protocol/handlers/PauseHandler.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,yCAAgF;AAEhF,qEAAiE;AACjE,2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CAAC;YACX,IAAK,CAAuB,EAAE,IAAI,KAAK,eAAe,EAAE,CAAC;gBACvD,MAAM,CAAC,IAAI,CAAC,8CAA8C,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,CAAA;gBACpF,OAAO,SAAS,CAAA;YAClB,CAAC;YACD,IAAI,MAAM,CAAC,mBAAmB,IAAI,cAAc,CAAC,UAAU,EAAE,CAAC;gBAC5D,MAAM,EAAE,GAAG,IAAI,2CAAoB,CAAC;oBAClC,IAAI,EAAE,cAAc,CAAC,OAAO,CAAC,QAAQ,IAAI,cAAc,CAAC,OAAO,CAAC,EAAE;oBAClE,IAAI,EAAE,EAAE,IAAI,EAAG,CAAuB,CAAC,IAAI,IAAI,cAAc,EAAE,OAAO,EAAG,CAAW,CAAC,OAAO,EAAE;iBAC/F,CAAC,CAAA;gBACF,OAAO,IAAI,6BAAsB,CAAC,EAAE,EAAE;oBACpC,YAAY,EAAE,cAAc,CAAC,YAAY;oBACzC,qBAAqB,EAAE,cAAc;oBACrC,UAAU,EAAE,cAAc,CAAC,UAAU;iBACtC,CAAC,CAAA;YACJ,CAAC;YACD,MAAM,CAAC,CAAA;QACT,CAAC;IACH,CAAC;CACF,CAAA;AA5FY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,iBAAU,GAAE;qCAGkC,iCAAe;GAFjD,YAAY,CA4FxB"}
@@ -0,0 +1,6 @@
1
+ import type { MessageHandler, MessageHandlerInboundMessage } from '@credo-ts/core';
2
+ import { ProblemReportMessage } from '../messages/ProblemReportMessage';
3
+ export declare class ProblemReportHandler implements MessageHandler {
4
+ supportedMessages: (typeof ProblemReportMessage)[];
5
+ handle(messageContext: MessageHandlerInboundMessage<ProblemReportHandler>): Promise<undefined>;
6
+ }
@@ -0,0 +1,28 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.ProblemReportHandler = void 0;
10
+ const core_1 = require("@credo-ts/core");
11
+ const ProblemReportMessage_1 = require("../messages/ProblemReportMessage");
12
+ let ProblemReportHandler = class ProblemReportHandler {
13
+ constructor() {
14
+ this.supportedMessages = [ProblemReportMessage_1.ProblemReportMessage];
15
+ }
16
+ async handle(messageContext) {
17
+ const logger = messageContext.agentContext.dependencyManager.resolve(core_1.AgentConfig).logger;
18
+ const body = messageContext.message.body;
19
+ const thid = messageContext.message.threadId || messageContext.message.id;
20
+ logger.warn('[Workflow] problem-report received', { thid, code: body?.code, comment: body?.comment });
21
+ return undefined;
22
+ }
23
+ };
24
+ exports.ProblemReportHandler = ProblemReportHandler;
25
+ exports.ProblemReportHandler = ProblemReportHandler = __decorate([
26
+ (0, core_1.injectable)()
27
+ ], ProblemReportHandler);
28
+ //# sourceMappingURL=ProblemReportHandler.js.map