@hexabot-ai/api 3.2.2-alpha.14 → 3.2.2-alpha.15

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 (66) hide show
  1. package/dist/mcp/mcp-api.module.js +2 -2
  2. package/dist/mcp/mcp-api.module.js.map +1 -1
  3. package/dist/mcp/tools/catalog-mcp.tools.d.ts +63 -0
  4. package/dist/mcp/tools/catalog-mcp.tools.js +135 -0
  5. package/dist/mcp/tools/catalog-mcp.tools.js.map +1 -0
  6. package/dist/mcp/tools/cms-mcp.tools.d.ts +128 -0
  7. package/dist/mcp/tools/cms-mcp.tools.js +242 -0
  8. package/dist/mcp/tools/cms-mcp.tools.js.map +1 -0
  9. package/dist/mcp/tools/credential-mcp.tools.d.ts +19 -0
  10. package/dist/mcp/tools/credential-mcp.tools.js +82 -0
  11. package/dist/mcp/tools/credential-mcp.tools.js.map +1 -0
  12. package/dist/mcp/tools/hexabot-mcp-tool.base.d.ts +22 -0
  13. package/dist/mcp/tools/hexabot-mcp-tool.base.js +48 -0
  14. package/dist/mcp/tools/hexabot-mcp-tool.base.js.map +1 -0
  15. package/dist/mcp/tools/hexabot-mcp.schemas.d.ts +41 -0
  16. package/dist/mcp/tools/hexabot-mcp.schemas.js +36 -0
  17. package/dist/mcp/tools/hexabot-mcp.schemas.js.map +1 -0
  18. package/dist/mcp/tools/hexabot-mcp.tools.d.ts +1 -1329
  19. package/dist/mcp/tools/hexabot-mcp.tools.js +14 -1097
  20. package/dist/mcp/tools/hexabot-mcp.tools.js.map +1 -1
  21. package/dist/mcp/tools/hexabot-mcp.utils.d.ts +1 -0
  22. package/dist/mcp/tools/hexabot-mcp.utils.js +9 -0
  23. package/dist/mcp/tools/hexabot-mcp.utils.js.map +1 -0
  24. package/dist/mcp/tools/index.d.ts +22 -0
  25. package/dist/mcp/tools/index.js +50 -0
  26. package/dist/mcp/tools/index.js.map +1 -0
  27. package/dist/mcp/tools/mcp-server-mcp.tools.d.ts +77 -0
  28. package/dist/mcp/tools/mcp-server-mcp.tools.js +130 -0
  29. package/dist/mcp/tools/mcp-server-mcp.tools.js.map +1 -0
  30. package/dist/mcp/tools/memory-definition-mcp.tools.d.ts +57 -0
  31. package/dist/mcp/tools/memory-definition-mcp.tools.js +128 -0
  32. package/dist/mcp/tools/memory-definition-mcp.tools.js.map +1 -0
  33. package/dist/mcp/tools/workflow-mcp.helper.d.ts +141 -0
  34. package/dist/mcp/tools/workflow-mcp.helper.js +108 -0
  35. package/dist/mcp/tools/workflow-mcp.helper.js.map +1 -0
  36. package/dist/mcp/tools/workflow-mcp.tools.d.ts +468 -0
  37. package/dist/mcp/tools/workflow-mcp.tools.js +222 -0
  38. package/dist/mcp/tools/workflow-mcp.tools.js.map +1 -0
  39. package/dist/mcp/tools/workflow-run-mcp.tools.d.ts +347 -0
  40. package/dist/mcp/tools/workflow-run-mcp.tools.js +229 -0
  41. package/dist/mcp/tools/workflow-run-mcp.tools.js.map +1 -0
  42. package/dist/mcp/tools/workflow-version-mcp.tools.d.ts +230 -0
  43. package/dist/mcp/tools/workflow-version-mcp.tools.js +211 -0
  44. package/dist/mcp/tools/workflow-version-mcp.tools.js.map +1 -0
  45. package/dist/tsconfig.build.tsbuildinfo +1 -1
  46. package/dist/workflow/services/workflow.service.d.ts +7 -7
  47. package/dist/workflow/services/workflow.service.js +40 -35
  48. package/dist/workflow/services/workflow.service.js.map +1 -1
  49. package/package.json +4 -4
  50. package/src/mcp/README.md +12 -2
  51. package/src/mcp/mcp-api.module.ts +2 -2
  52. package/src/mcp/tools/catalog-mcp.tools.ts +122 -0
  53. package/src/mcp/tools/cms-mcp.tools.ts +239 -0
  54. package/src/mcp/tools/credential-mcp.tools.ts +81 -0
  55. package/src/mcp/tools/hexabot-mcp-tool.base.ts +74 -0
  56. package/src/mcp/tools/hexabot-mcp.schemas.ts +55 -0
  57. package/src/mcp/tools/hexabot-mcp.tools.ts +1 -1194
  58. package/src/mcp/tools/hexabot-mcp.utils.ts +13 -0
  59. package/src/mcp/tools/index.ts +51 -0
  60. package/src/mcp/tools/mcp-server-mcp.tools.ts +135 -0
  61. package/src/mcp/tools/memory-definition-mcp.tools.ts +125 -0
  62. package/src/mcp/tools/workflow-mcp.helper.ts +166 -0
  63. package/src/mcp/tools/workflow-mcp.tools.ts +254 -0
  64. package/src/mcp/tools/workflow-run-mcp.tools.ts +274 -0
  65. package/src/mcp/tools/workflow-version-mcp.tools.ts +226 -0
  66. package/src/workflow/services/workflow.service.ts +49 -29
@@ -0,0 +1,226 @@
1
+ /*
2
+ * Hexabot — Fair Core License (FCL-1.0-ALv2)
3
+ * Copyright (c) 2026 Hexastack.
4
+ * Full terms: see LICENSE.md.
5
+ */
6
+
7
+ import { validateWorkflow } from '@hexabot-ai/agentic';
8
+ import { Action } from '@hexabot-ai/types';
9
+ import { Injectable, NotFoundException } from '@nestjs/common';
10
+ import { Tool, ToolGuards } from '@rekog/mcp-nest';
11
+ import { z } from 'zod';
12
+
13
+ import { ActionService } from '@/actions/actions.service';
14
+ import { RuntimeBindingsService } from '@/bindings/runtime-bindings.service';
15
+ import { WorkflowVersionOrmEntity } from '@/workflow/entities/workflow-version.entity';
16
+ import { WorkflowVersionService } from '@/workflow/services/workflow-version.service';
17
+ import { WorkflowVersionAction } from '@/workflow/types';
18
+
19
+ import { McpPermission } from '../decorators/mcp-permission.decorator';
20
+ import { McpPermissionGuard } from '../guards/mcp-permission.guard';
21
+ import { HexabotMcpRequest } from '../types';
22
+
23
+ import { HexabotMcpToolBase } from './hexabot-mcp-tool.base';
24
+ import {
25
+ PaginationArgs,
26
+ paginationSchema,
27
+ uuidSchema,
28
+ } from './hexabot-mcp.schemas';
29
+ import { HexabotWorkflowMcpHelper } from './workflow-mcp.helper';
30
+
31
+ @Injectable()
32
+ export class HexabotWorkflowVersionMcpTools extends HexabotMcpToolBase {
33
+ constructor(
34
+ private readonly workflowVersionService: WorkflowVersionService,
35
+ private readonly actionService: ActionService,
36
+ private readonly runtimeBindingsService: RuntimeBindingsService,
37
+ private readonly workflowHelper: HexabotWorkflowMcpHelper,
38
+ ) {
39
+ super();
40
+ }
41
+
42
+ @McpPermission('workflowversion', Action.CREATE)
43
+ @ToolGuards([McpPermissionGuard])
44
+ @Tool({
45
+ name: 'hexabot_workflow_yaml_commit',
46
+ description:
47
+ 'Validate and commit workflow definition YAML as a new version.',
48
+ parameters: z.object({
49
+ workflowId: uuidSchema,
50
+ definitionYml: z.string().min(1),
51
+ message: z.string().optional(),
52
+ parentVersion: uuidSchema.nullable().optional(),
53
+ action: z
54
+ .enum(WorkflowVersionAction)
55
+ .default(WorkflowVersionAction.update),
56
+ }),
57
+ })
58
+ async commitWorkflowYaml(
59
+ args: {
60
+ workflowId: string;
61
+ definitionYml: string;
62
+ message?: string;
63
+ parentVersion?: string | null;
64
+ action: WorkflowVersionAction;
65
+ },
66
+ _context: unknown,
67
+ request?: HexabotMcpRequest,
68
+ ) {
69
+ const actorId = this.getActorId(request);
70
+
71
+ return await this.workflowHelper.commitWorkflowDefinition({
72
+ ...args,
73
+ createdBy: actorId,
74
+ });
75
+ }
76
+
77
+ @McpPermission('workflow', Action.READ)
78
+ @ToolGuards([McpPermissionGuard])
79
+ @Tool({
80
+ name: 'hexabot_workflow_yaml_validate',
81
+ description:
82
+ 'Validate workflow definition YAML without creating a workflow version.',
83
+ parameters: z.object({
84
+ definitionYml: z.string().min(1),
85
+ validateActions: z.boolean().default(true),
86
+ }),
87
+ })
88
+ async validateWorkflowYaml(args: {
89
+ definitionYml: string;
90
+ validateActions?: boolean;
91
+ }) {
92
+ const validateActions = args.validateActions ?? true;
93
+ const validation = validateWorkflow(args.definitionYml, {
94
+ bindingKinds: this.runtimeBindingsService.getRegistry(),
95
+ ...(validateActions
96
+ ? { actions: this.getWorkflowValidationActions() }
97
+ : {}),
98
+ });
99
+
100
+ if (!validation.success) {
101
+ return { valid: false, errors: validation.errors };
102
+ }
103
+
104
+ return { valid: true, errors: [], definition: validation.data };
105
+ }
106
+
107
+ @McpPermission('workflowversion', Action.READ)
108
+ @ToolGuards([McpPermissionGuard])
109
+ @Tool({
110
+ name: 'hexabot_workflow_version_search',
111
+ description: 'List workflow definition YAML versions for a workflow.',
112
+ parameters: z.object({
113
+ workflowId: uuidSchema,
114
+ ...paginationSchema,
115
+ sortBy: z.string().default('version'),
116
+ sortDirection: z.enum(['ASC', 'DESC']).default('DESC'),
117
+ }),
118
+ })
119
+ async searchWorkflowVersions(args: { workflowId: string } & PaginationArgs) {
120
+ const where = { workflow: { id: args.workflowId } } as any;
121
+
122
+ return await this.listWithCount(
123
+ this.workflowVersionService,
124
+ this.findOptions<WorkflowVersionOrmEntity>(args, where),
125
+ );
126
+ }
127
+
128
+ @McpPermission('workflowversion', Action.READ)
129
+ @ToolGuards([McpPermissionGuard])
130
+ @Tool({
131
+ name: 'hexabot_workflow_version_get',
132
+ description: 'Read one workflow definition YAML version.',
133
+ parameters: z.object({
134
+ id: uuidSchema,
135
+ workflowId: uuidSchema.optional(),
136
+ }),
137
+ })
138
+ async getWorkflowVersion(args: { id: string; workflowId?: string }) {
139
+ const version = await this.workflowVersionService.findOneAndPopulate({
140
+ where: {
141
+ id: args.id,
142
+ ...(args.workflowId ? { workflow: { id: args.workflowId } } : {}),
143
+ } as any,
144
+ });
145
+
146
+ if (!version) {
147
+ throw new NotFoundException(`Workflow version ${args.id} not found`);
148
+ }
149
+
150
+ return version;
151
+ }
152
+
153
+ @McpPermission('workflowversion', Action.UPDATE)
154
+ @ToolGuards([McpPermissionGuard])
155
+ @Tool({
156
+ name: 'hexabot_workflow_version_update',
157
+ description:
158
+ 'Update workflow version metadata such as the version message.',
159
+ parameters: z.object({
160
+ id: uuidSchema,
161
+ message: z.string().nullable().optional(),
162
+ }),
163
+ })
164
+ async updateWorkflowVersion(args: { id: string; message?: string | null }) {
165
+ return await this.workflowVersionService.updateOne(args.id, {
166
+ message: args.message ?? undefined,
167
+ });
168
+ }
169
+
170
+ @McpPermission('workflowversion', Action.CREATE)
171
+ @ToolGuards([McpPermissionGuard])
172
+ @Tool({
173
+ name: 'hexabot_workflow_version_restore',
174
+ description:
175
+ 'Restore a workflow to a previous YAML version by creating a new restore snapshot.',
176
+ parameters: z.object({
177
+ workflowId: uuidSchema,
178
+ versionId: uuidSchema,
179
+ message: z.string().optional(),
180
+ }),
181
+ })
182
+ async restoreWorkflowVersion(
183
+ args: { workflowId: string; versionId: string; message?: string },
184
+ _context: unknown,
185
+ request?: HexabotMcpRequest,
186
+ ) {
187
+ return await this.workflowHelper.restoreWorkflowVersionSnapshot(
188
+ args,
189
+ this.getActorId(request),
190
+ );
191
+ }
192
+
193
+ @McpPermission('workflowversion', Action.CREATE)
194
+ @ToolGuards([McpPermissionGuard])
195
+ @Tool({
196
+ name: 'hexabot_workflow_rollback',
197
+ description:
198
+ 'Rollback a workflow to a previous YAML version by creating a new current restore snapshot.',
199
+ parameters: z.object({
200
+ workflowId: uuidSchema,
201
+ versionId: uuidSchema,
202
+ message: z.string().optional(),
203
+ }),
204
+ })
205
+ async rollbackWorkflowVersion(
206
+ args: { workflowId: string; versionId: string; message?: string },
207
+ _context: unknown,
208
+ request?: HexabotMcpRequest,
209
+ ) {
210
+ return await this.workflowHelper.restoreWorkflowVersionSnapshot(
211
+ args,
212
+ this.getActorId(request),
213
+ );
214
+ }
215
+
216
+ private getWorkflowValidationActions() {
217
+ return Object.fromEntries(
218
+ Object.entries(this.actionService.getRegistry()).map(
219
+ ([actionName, action]) => [
220
+ actionName,
221
+ { supportedBindings: action.supportedBindings ?? [] },
222
+ ],
223
+ ),
224
+ );
225
+ }
226
+ }
@@ -208,57 +208,77 @@ export class WorkflowService extends BaseOrmService<WorkflowOrmEntity> {
208
208
 
209
209
  return;
210
210
  }
211
- const { initiatorId, workflowId, threadId } = workflowRun?.context;
211
+ const { initiatorId, workflowId, threadId } = workflowRun.context;
212
+ if (
213
+ typeof initiatorId !== 'string' ||
214
+ !initiatorId ||
215
+ typeof workflowId !== 'string' ||
216
+ !workflowId
217
+ ) {
218
+ this.logger.error(
219
+ 'workflowRun context requires initiatorId and workflowId',
220
+ );
221
+
222
+ return;
223
+ }
224
+
212
225
  const workflow = await this.findOne(workflowId);
213
- const canBroadcastEvents =
214
- initiatorId &&
215
- workflow?.type &&
216
- [WorkflowType.conversational].includes(workflow.type);
217
-
218
- if (canBroadcastEvents) {
219
- this.gateway.broadcastWorkflowEvent({
220
- ...payload,
221
- t,
222
- workflowId,
223
- initiatorId,
224
- threadId: typeof threadId === 'string' ? threadId : undefined,
225
- workflowEvent: workflowEvent.replace('hook:', ''),
226
- });
226
+ if (!workflow?.type) {
227
+ this.logger.error('workflow is required');
228
+
229
+ return;
227
230
  }
231
+
232
+ this.gateway.broadcastWorkflowEvent({
233
+ ...payload,
234
+ t,
235
+ workflowId,
236
+ initiatorId,
237
+ threadId: typeof threadId === 'string' ? threadId : undefined,
238
+ workflowEvent: workflowEvent.replace('hook:', ''),
239
+ });
228
240
  }
229
241
 
230
242
  @OnEvent('hook:workflow:start')
231
- sendWorkflowStart(payload: WorkflowEventMap[keyof WorkflowEventMap]) {
232
- this.sendWorkflowEvent('hook:workflow:start', payload);
243
+ async sendWorkflowStart(payload: WorkflowEventMap[keyof WorkflowEventMap]) {
244
+ await this.sendWorkflowEvent('hook:workflow:start', payload);
233
245
  }
234
246
 
235
247
  @OnEvent('hook:workflow:finish')
236
- sendWorkflowFinish(payload: WorkflowEventMap[keyof WorkflowEventMap]) {
237
- this.sendWorkflowEvent('hook:workflow:finish', payload);
248
+ async sendWorkflowFinish(payload: WorkflowEventMap[keyof WorkflowEventMap]) {
249
+ await this.sendWorkflowEvent('hook:workflow:finish', payload);
238
250
  }
239
251
 
240
252
  @OnEvent('hook:workflow:failure')
241
- sendWorkflowFailure(payload: WorkflowEventMap[keyof WorkflowEventMap]) {
242
- this.sendWorkflowEvent('hook:workflow:failure', payload);
253
+ async sendWorkflowFailure(payload: WorkflowEventMap[keyof WorkflowEventMap]) {
254
+ await this.sendWorkflowEvent('hook:workflow:failure', payload);
243
255
  }
244
256
 
245
257
  @OnEvent('hook:step:start')
246
- sendWorkflowStepStart(payload: WorkflowEventMap[keyof WorkflowEventMap]) {
247
- this.sendWorkflowEvent('hook:step:start', payload);
258
+ async sendWorkflowStepStart(
259
+ payload: WorkflowEventMap[keyof WorkflowEventMap],
260
+ ) {
261
+ await this.sendWorkflowEvent('hook:step:start', payload);
248
262
  }
249
263
 
250
264
  @OnEvent('hook:step:suspended')
251
- sendWorkflowStepSuspended(payload: WorkflowEventMap[keyof WorkflowEventMap]) {
252
- this.sendWorkflowEvent('hook:step:suspended', payload);
265
+ async sendWorkflowStepSuspended(
266
+ payload: WorkflowEventMap[keyof WorkflowEventMap],
267
+ ) {
268
+ await this.sendWorkflowEvent('hook:step:suspended', payload);
253
269
  }
254
270
 
255
271
  @OnEvent('hook:step:success')
256
- sendWorkflowStepSuccess(payload: WorkflowEventMap[keyof WorkflowEventMap]) {
257
- this.sendWorkflowEvent('hook:step:success', payload);
272
+ async sendWorkflowStepSuccess(
273
+ payload: WorkflowEventMap[keyof WorkflowEventMap],
274
+ ) {
275
+ await this.sendWorkflowEvent('hook:step:success', payload);
258
276
  }
259
277
 
260
278
  @OnEvent('hook:step:error')
261
- sendWorkflowStepError(payload: WorkflowEventMap[keyof WorkflowEventMap]) {
262
- this.sendWorkflowEvent('hook:step:error', payload);
279
+ async sendWorkflowStepError(
280
+ payload: WorkflowEventMap[keyof WorkflowEventMap],
281
+ ) {
282
+ await this.sendWorkflowEvent('hook:step:error', payload);
263
283
  }
264
284
  }