langmart-gateway-type3 3.0.45 → 3.0.46

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 (57) hide show
  1. package/dist/admin-tools.d.ts +46 -0
  2. package/dist/admin-tools.d.ts.map +1 -0
  3. package/dist/admin-tools.js +933 -0
  4. package/dist/admin-tools.js.map +1 -0
  5. package/dist/agent-tools.d.ts +38 -0
  6. package/dist/agent-tools.d.ts.map +1 -0
  7. package/dist/agent-tools.js +813 -0
  8. package/dist/agent-tools.js.map +1 -0
  9. package/dist/billing-tools.d.ts +25 -0
  10. package/dist/billing-tools.d.ts.map +1 -0
  11. package/dist/billing-tools.js +283 -0
  12. package/dist/billing-tools.js.map +1 -0
  13. package/dist/cli.d.ts +2 -0
  14. package/dist/cli.d.ts.map +1 -0
  15. package/dist/cli.js +792 -0
  16. package/dist/cli.js.map +1 -0
  17. package/dist/collection-tools.d.ts +26 -0
  18. package/dist/collection-tools.d.ts.map +1 -0
  19. package/dist/collection-tools.js +347 -0
  20. package/dist/collection-tools.js.map +1 -0
  21. package/dist/lib/tool-schema-validator.d.ts +35 -0
  22. package/dist/lib/tool-schema-validator.d.ts.map +1 -0
  23. package/dist/lib/tool-schema-validator.js +146 -0
  24. package/dist/lib/tool-schema-validator.js.map +1 -0
  25. package/dist/marketplace-tools.d.ts +116 -0
  26. package/dist/marketplace-tools.d.ts.map +1 -0
  27. package/dist/marketplace-tools.js +3089 -0
  28. package/dist/marketplace-tools.js.map +1 -0
  29. package/dist/organization-tools.d.ts +37 -0
  30. package/dist/organization-tools.d.ts.map +1 -0
  31. package/dist/organization-tools.js +609 -0
  32. package/dist/organization-tools.js.map +1 -0
  33. package/dist/seller-tools.d.ts +28 -0
  34. package/dist/seller-tools.d.ts.map +1 -0
  35. package/dist/seller-tools.js +437 -0
  36. package/dist/seller-tools.js.map +1 -0
  37. package/dist/support-tools.d.ts +23 -0
  38. package/dist/support-tools.d.ts.map +1 -0
  39. package/dist/support-tools.js +292 -0
  40. package/dist/support-tools.js.map +1 -0
  41. package/dist/test-key-redaction-integration.d.ts +7 -0
  42. package/dist/test-key-redaction-integration.d.ts.map +1 -0
  43. package/dist/test-key-redaction-integration.js +80 -0
  44. package/dist/test-key-redaction-integration.js.map +1 -0
  45. package/dist/test-key-redaction.d.ts +6 -0
  46. package/dist/test-key-redaction.d.ts.map +1 -0
  47. package/dist/test-key-redaction.js +115 -0
  48. package/dist/test-key-redaction.js.map +1 -0
  49. package/dist/test-vault-migration.d.ts +2 -0
  50. package/dist/test-vault-migration.d.ts.map +1 -0
  51. package/dist/test-vault-migration.js +130 -0
  52. package/dist/test-vault-migration.js.map +1 -0
  53. package/dist/user-tools.d.ts +40 -0
  54. package/dist/user-tools.d.ts.map +1 -0
  55. package/dist/user-tools.js +685 -0
  56. package/dist/user-tools.js.map +1 -0
  57. package/package.json +2 -70
@@ -0,0 +1,813 @@
1
+ "use strict";
2
+ /**
3
+ * Agent Tools - MCP Tools for Agent Management
4
+ *
5
+ * Provides tools for:
6
+ * - Agent Definitions (templates)
7
+ * - Agent Instances (running deployments)
8
+ * - Agent Workflows (graphs with nodes and edges)
9
+ * - Workflow Executions (execution history and traces)
10
+ */
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.AgentTools = exports.agentToolDefinitions = void 0;
16
+ const axios_1 = __importDefault(require("axios"));
17
+ // ============= TOOL DEFINITIONS =============
18
+ exports.agentToolDefinitions = [
19
+ // ===== DEFINITIONS =====
20
+ {
21
+ type: 'function',
22
+ function: {
23
+ name: 'agents_definitions_list',
24
+ description: 'List all available agent definitions (templates). These are reusable agent configurations that can be instantiated. Response contains definition IDs that can be used with agents_definitions_get for full details, or agents_instances_list to see running instances of each definition.',
25
+ parameters: {
26
+ type: 'object',
27
+ properties: {
28
+ category: {
29
+ type: 'string',
30
+ description: 'Filter by category (e.g., "general", "coding", "analysis")'
31
+ }
32
+ },
33
+ required: []
34
+ }
35
+ },
36
+ metadata: {
37
+ category: 'automation',
38
+ defaultEnabled: true,
39
+ adminOnly: false,
40
+ destructive: false,
41
+ requiresConfirmation: false,
42
+ apiEndpoint: '/api/agents/definitions',
43
+ apiMethod: 'GET',
44
+ tags: ['agents', 'definitions', 'list']
45
+ }
46
+ },
47
+ {
48
+ type: 'function',
49
+ function: {
50
+ name: 'agents_definitions_get',
51
+ description: 'Get details of a specific agent definition including its system prompt, tools, and configuration.',
52
+ parameters: {
53
+ type: 'object',
54
+ properties: {
55
+ definition_id: {
56
+ type: 'string',
57
+ description: 'Agent definition ID. Use agents_definitions_list first to find available definition IDs.'
58
+ }
59
+ },
60
+ required: ['definition_id']
61
+ }
62
+ },
63
+ metadata: {
64
+ category: 'automation',
65
+ defaultEnabled: true,
66
+ adminOnly: false,
67
+ destructive: false,
68
+ requiresConfirmation: false,
69
+ apiEndpoint: '/api/agents/definitions/:id',
70
+ apiMethod: 'GET',
71
+ tags: ['agents', 'definitions', 'get']
72
+ }
73
+ },
74
+ {
75
+ type: 'function',
76
+ function: {
77
+ name: 'agents_definitions_create',
78
+ description: 'Create a new agent definition (template).',
79
+ parameters: {
80
+ type: 'object',
81
+ properties: {
82
+ name: {
83
+ type: 'string',
84
+ description: 'Agent name'
85
+ },
86
+ description: {
87
+ type: 'string',
88
+ description: 'Agent description'
89
+ },
90
+ category: {
91
+ type: 'string',
92
+ description: 'Category (e.g., "general", "coding", "analysis")'
93
+ },
94
+ system_prompt: {
95
+ type: 'string',
96
+ description: 'System prompt for the agent'
97
+ },
98
+ default_model: {
99
+ type: 'string',
100
+ description: 'Default model to use (e.g., "openai/gpt-4o")'
101
+ },
102
+ icon: {
103
+ type: 'string',
104
+ description: 'Emoji icon for the agent'
105
+ }
106
+ },
107
+ required: ['name']
108
+ }
109
+ },
110
+ metadata: {
111
+ category: 'automation',
112
+ defaultEnabled: true,
113
+ adminOnly: false,
114
+ destructive: false,
115
+ requiresConfirmation: false,
116
+ apiEndpoint: '/api/agents/definitions',
117
+ apiMethod: 'POST',
118
+ tags: ['agents', 'definitions', 'create']
119
+ }
120
+ },
121
+ // ===== INSTANCES =====
122
+ {
123
+ type: 'function',
124
+ function: {
125
+ name: 'agents_instances_list',
126
+ description: 'List all agent instances (running or stopped deployments). Response includes: definition_id (use agents_definitions_get for template details), workflow_id (use agents_workflows_get for workflow details), node_id (position in workflow graph).',
127
+ parameters: {
128
+ type: 'object',
129
+ properties: {
130
+ workflow_id: {
131
+ type: 'string',
132
+ description: 'Filter by workflow ID'
133
+ },
134
+ status: {
135
+ type: 'string',
136
+ description: 'Filter by status',
137
+ enum: ['ACTIVE', 'STOPPED', 'FAILED', 'COMPLETED', 'all']
138
+ }
139
+ },
140
+ required: []
141
+ }
142
+ },
143
+ metadata: {
144
+ category: 'automation',
145
+ defaultEnabled: true,
146
+ adminOnly: false,
147
+ destructive: false,
148
+ requiresConfirmation: false,
149
+ apiEndpoint: '/api/agents/instances',
150
+ apiMethod: 'GET',
151
+ tags: ['agents', 'instances', 'list']
152
+ }
153
+ },
154
+ {
155
+ type: 'function',
156
+ function: {
157
+ name: 'agents_instances_get',
158
+ description: 'Get details of a specific agent instance including its status and configuration.',
159
+ parameters: {
160
+ type: 'object',
161
+ properties: {
162
+ instance_id: {
163
+ type: 'string',
164
+ description: 'Agent instance ID. Use agents_instances_list first to find available instance IDs.'
165
+ }
166
+ },
167
+ required: ['instance_id']
168
+ }
169
+ },
170
+ metadata: {
171
+ category: 'automation',
172
+ defaultEnabled: true,
173
+ adminOnly: false,
174
+ destructive: false,
175
+ requiresConfirmation: false,
176
+ apiEndpoint: '/api/agents/instances/:id',
177
+ apiMethod: 'GET',
178
+ tags: ['agents', 'instances', 'get']
179
+ }
180
+ },
181
+ {
182
+ type: 'function',
183
+ function: {
184
+ name: 'agents_instances_trace',
185
+ description: 'Get the execution trace for an agent instance, showing the flow and status of execution.',
186
+ parameters: {
187
+ type: 'object',
188
+ properties: {
189
+ instance_id: {
190
+ type: 'string',
191
+ description: 'Agent instance ID. Use agents_instances_list first to find available instance IDs.'
192
+ }
193
+ },
194
+ required: ['instance_id']
195
+ }
196
+ },
197
+ metadata: {
198
+ category: 'automation',
199
+ defaultEnabled: true,
200
+ adminOnly: false,
201
+ destructive: false,
202
+ requiresConfirmation: false,
203
+ apiEndpoint: '/api/agents/instances/:id/trace',
204
+ apiMethod: 'GET',
205
+ tags: ['agents', 'instances', 'trace']
206
+ }
207
+ },
208
+ // ===== WORKFLOWS =====
209
+ {
210
+ type: 'function',
211
+ function: {
212
+ name: 'agents_workflows_list',
213
+ description: 'List all agent workflows. Workflows define how agents connect and orchestrate. Response contains workflow IDs - use agents_workflows_get for details, agents_workflows_graph for node/edge visualization, agents_executions_list to see execution history.',
214
+ parameters: {
215
+ type: 'object',
216
+ properties: {},
217
+ required: []
218
+ }
219
+ },
220
+ metadata: {
221
+ category: 'automation',
222
+ defaultEnabled: true,
223
+ adminOnly: false,
224
+ destructive: false,
225
+ requiresConfirmation: false,
226
+ apiEndpoint: '/api/agents/workflows',
227
+ apiMethod: 'GET',
228
+ tags: ['agents', 'workflows', 'list']
229
+ }
230
+ },
231
+ {
232
+ type: 'function',
233
+ function: {
234
+ name: 'agents_workflows_get',
235
+ description: 'Get details of a specific workflow.',
236
+ parameters: {
237
+ type: 'object',
238
+ properties: {
239
+ workflow_id: {
240
+ type: 'string',
241
+ description: 'Workflow ID. Use agents_workflows_list first to find available workflow IDs.'
242
+ }
243
+ },
244
+ required: ['workflow_id']
245
+ }
246
+ },
247
+ metadata: {
248
+ category: 'automation',
249
+ defaultEnabled: true,
250
+ adminOnly: false,
251
+ destructive: false,
252
+ requiresConfirmation: false,
253
+ apiEndpoint: '/api/agents/workflows/:id',
254
+ apiMethod: 'GET',
255
+ tags: ['agents', 'workflows', 'get']
256
+ }
257
+ },
258
+ {
259
+ type: 'function',
260
+ function: {
261
+ name: 'agents_workflows_graph',
262
+ description: 'Get the full workflow graph with all nodes and edges for visualization.',
263
+ parameters: {
264
+ type: 'object',
265
+ properties: {
266
+ workflow_id: {
267
+ type: 'string',
268
+ description: 'Workflow ID. Use agents_workflows_list first to find available workflow IDs.'
269
+ }
270
+ },
271
+ required: ['workflow_id']
272
+ }
273
+ },
274
+ metadata: {
275
+ category: 'automation',
276
+ defaultEnabled: true,
277
+ adminOnly: false,
278
+ destructive: false,
279
+ requiresConfirmation: false,
280
+ apiEndpoint: '/api/agents/workflows/:id/graph',
281
+ apiMethod: 'GET',
282
+ tags: ['agents', 'workflows', 'graph']
283
+ }
284
+ },
285
+ {
286
+ type: 'function',
287
+ function: {
288
+ name: 'agents_workflows_create',
289
+ description: 'Create a new workflow.',
290
+ parameters: {
291
+ type: 'object',
292
+ properties: {
293
+ name: {
294
+ type: 'string',
295
+ description: 'Workflow name'
296
+ },
297
+ description: {
298
+ type: 'string',
299
+ description: 'Workflow description'
300
+ }
301
+ },
302
+ required: ['name']
303
+ }
304
+ },
305
+ metadata: {
306
+ category: 'automation',
307
+ defaultEnabled: true,
308
+ adminOnly: false,
309
+ destructive: false,
310
+ requiresConfirmation: false,
311
+ apiEndpoint: '/api/agents/workflows',
312
+ apiMethod: 'POST',
313
+ tags: ['agents', 'workflows', 'create']
314
+ }
315
+ },
316
+ {
317
+ type: 'function',
318
+ function: {
319
+ name: 'agents_workflows_assign',
320
+ description: 'Assign an agent definition or instance to a workflow, adding it as a node.',
321
+ parameters: {
322
+ type: 'object',
323
+ properties: {
324
+ workflow_id: {
325
+ type: 'string',
326
+ description: 'Workflow ID. Use agents_workflows_list to find workflow IDs.'
327
+ },
328
+ definition_id: {
329
+ type: 'string',
330
+ description: 'Agent definition ID to assign. Use agents_definitions_list to find definition IDs.'
331
+ },
332
+ instance_id: {
333
+ type: 'string',
334
+ description: 'Agent instance ID to assign (alternative to definition_id). Use agents_instances_list to find instance IDs.'
335
+ }
336
+ },
337
+ required: ['workflow_id']
338
+ }
339
+ },
340
+ metadata: {
341
+ category: 'automation',
342
+ defaultEnabled: true,
343
+ adminOnly: false,
344
+ destructive: false,
345
+ requiresConfirmation: false,
346
+ apiEndpoint: '/api/agents/workflows/:id/assign',
347
+ apiMethod: 'POST',
348
+ tags: ['agents', 'workflows', 'assign']
349
+ }
350
+ },
351
+ {
352
+ type: 'function',
353
+ function: {
354
+ name: 'agents_workflows_ready',
355
+ description: 'Check if a workflow is ready to execute (all required nodes connected).',
356
+ parameters: {
357
+ type: 'object',
358
+ properties: {
359
+ workflow_id: {
360
+ type: 'string',
361
+ description: 'Workflow ID. Use agents_workflows_list first to find workflow IDs.'
362
+ }
363
+ },
364
+ required: ['workflow_id']
365
+ }
366
+ },
367
+ metadata: {
368
+ category: 'automation',
369
+ defaultEnabled: true,
370
+ adminOnly: false,
371
+ destructive: false,
372
+ requiresConfirmation: false,
373
+ apiEndpoint: '/api/agents/workflows/:id/ready',
374
+ apiMethod: 'GET',
375
+ tags: ['agents', 'workflows', 'ready']
376
+ }
377
+ },
378
+ {
379
+ type: 'function',
380
+ function: {
381
+ name: 'agents_workflows_execute',
382
+ description: 'Execute a workflow with the given input. This starts all agents in the workflow.',
383
+ parameters: {
384
+ type: 'object',
385
+ properties: {
386
+ workflow_id: {
387
+ type: 'string',
388
+ description: 'Workflow ID to execute. Use agents_workflows_list to find IDs, then agents_workflows_ready to check if ready.'
389
+ },
390
+ prompt: {
391
+ type: 'string',
392
+ description: 'Input prompt to start the workflow'
393
+ },
394
+ variables: {
395
+ type: 'object',
396
+ description: 'Variables to pass to the workflow'
397
+ }
398
+ },
399
+ required: ['workflow_id', 'prompt']
400
+ }
401
+ },
402
+ metadata: {
403
+ category: 'automation',
404
+ defaultEnabled: true,
405
+ adminOnly: false,
406
+ destructive: false,
407
+ requiresConfirmation: true,
408
+ apiEndpoint: '/api/agents/workflows/:id/execute',
409
+ apiMethod: 'POST',
410
+ tags: ['agents', 'workflows', 'execute']
411
+ }
412
+ },
413
+ {
414
+ type: 'function',
415
+ function: {
416
+ name: 'agents_workflows_delete',
417
+ description: 'Delete a workflow and all its edges.',
418
+ parameters: {
419
+ type: 'object',
420
+ properties: {
421
+ workflow_id: {
422
+ type: 'string',
423
+ description: 'Workflow ID to delete. Use agents_workflows_list to find workflow IDs.'
424
+ }
425
+ },
426
+ required: ['workflow_id']
427
+ }
428
+ },
429
+ metadata: {
430
+ category: 'automation',
431
+ defaultEnabled: true,
432
+ adminOnly: false,
433
+ destructive: true,
434
+ requiresConfirmation: true,
435
+ apiEndpoint: '/api/agents/workflows/:id',
436
+ apiMethod: 'DELETE',
437
+ tags: ['agents', 'workflows', 'delete']
438
+ }
439
+ },
440
+ // ===== EXECUTIONS =====
441
+ {
442
+ type: 'function',
443
+ function: {
444
+ name: 'agents_executions_list',
445
+ description: 'List all workflow executions (past runs). Response includes: trace_id (use agents_executions_trace for step-by-step trace), workflow_id (use agents_workflows_get for workflow details). Each execution shows status, duration, and result.',
446
+ parameters: {
447
+ type: 'object',
448
+ properties: {
449
+ limit: {
450
+ type: 'number',
451
+ description: 'Maximum number of executions to return',
452
+ default: 50
453
+ }
454
+ },
455
+ required: []
456
+ }
457
+ },
458
+ metadata: {
459
+ category: 'automation',
460
+ defaultEnabled: true,
461
+ adminOnly: false,
462
+ destructive: false,
463
+ requiresConfirmation: false,
464
+ apiEndpoint: '/api/agents/executions',
465
+ apiMethod: 'GET',
466
+ tags: ['agents', 'executions', 'list']
467
+ }
468
+ },
469
+ {
470
+ type: 'function',
471
+ function: {
472
+ name: 'agents_executions_get',
473
+ description: 'Get details of a specific workflow execution.',
474
+ parameters: {
475
+ type: 'object',
476
+ properties: {
477
+ execution_id: {
478
+ type: 'string',
479
+ description: 'Execution ID (trace_id). Use agents_executions_list first to find execution IDs.'
480
+ }
481
+ },
482
+ required: ['execution_id']
483
+ }
484
+ },
485
+ metadata: {
486
+ category: 'automation',
487
+ defaultEnabled: true,
488
+ adminOnly: false,
489
+ destructive: false,
490
+ requiresConfirmation: false,
491
+ apiEndpoint: '/api/agents/executions/:id',
492
+ apiMethod: 'GET',
493
+ tags: ['agents', 'executions', 'get']
494
+ }
495
+ },
496
+ {
497
+ type: 'function',
498
+ function: {
499
+ name: 'agents_executions_trace',
500
+ description: 'Get the complete execution trace with all agent instances and their status.',
501
+ parameters: {
502
+ type: 'object',
503
+ properties: {
504
+ trace_id: {
505
+ type: 'string',
506
+ description: 'Trace ID of the execution. Use agents_executions_list first to find trace IDs.'
507
+ }
508
+ },
509
+ required: ['trace_id']
510
+ }
511
+ },
512
+ metadata: {
513
+ category: 'automation',
514
+ defaultEnabled: true,
515
+ adminOnly: false,
516
+ destructive: false,
517
+ requiresConfirmation: false,
518
+ apiEndpoint: '/api/agents/executions/:traceId/trace',
519
+ apiMethod: 'GET',
520
+ tags: ['agents', 'executions', 'trace']
521
+ }
522
+ }
523
+ ];
524
+ // ============= TOOL EXECUTOR =============
525
+ class AgentTools {
526
+ constructor(registryUrl, apiKey) {
527
+ this.client = axios_1.default.create({
528
+ baseURL: registryUrl,
529
+ timeout: 60000,
530
+ headers: {
531
+ 'Authorization': `Bearer ${apiKey}`,
532
+ 'Content-Type': 'application/json'
533
+ }
534
+ });
535
+ }
536
+ static getInstance(registryUrl, apiKey) {
537
+ if (!AgentTools.instance && registryUrl && apiKey) {
538
+ AgentTools.instance = new AgentTools(registryUrl, apiKey);
539
+ }
540
+ if (!AgentTools.instance) {
541
+ throw new Error('AgentTools not initialized.');
542
+ }
543
+ return AgentTools.instance;
544
+ }
545
+ getTools() {
546
+ return exports.agentToolDefinitions;
547
+ }
548
+ async executeTool(toolName, args) {
549
+ try {
550
+ switch (toolName) {
551
+ // Definitions
552
+ case 'agents_definitions_list':
553
+ return await this.listDefinitions(args);
554
+ case 'agents_definitions_get':
555
+ return await this.getDefinition(args.definition_id);
556
+ case 'agents_definitions_create':
557
+ return await this.createDefinition(args);
558
+ // Instances
559
+ case 'agents_instances_list':
560
+ return await this.listInstances(args);
561
+ case 'agents_instances_get':
562
+ return await this.getInstance(args.instance_id);
563
+ case 'agents_instances_trace':
564
+ return await this.getInstanceTrace(args.instance_id);
565
+ // Workflows
566
+ case 'agents_workflows_list':
567
+ return await this.listWorkflows();
568
+ case 'agents_workflows_get':
569
+ return await this.getWorkflow(args.workflow_id);
570
+ case 'agents_workflows_graph':
571
+ return await this.getWorkflowGraph(args.workflow_id);
572
+ case 'agents_workflows_create':
573
+ return await this.createWorkflow(args);
574
+ case 'agents_workflows_assign':
575
+ return await this.assignToWorkflow(args);
576
+ case 'agents_workflows_ready':
577
+ return await this.checkWorkflowReady(args.workflow_id);
578
+ case 'agents_workflows_execute':
579
+ return await this.executeWorkflow(args);
580
+ case 'agents_workflows_delete':
581
+ return await this.deleteWorkflow(args.workflow_id);
582
+ // Executions
583
+ case 'agents_executions_list':
584
+ return await this.listExecutions(args);
585
+ case 'agents_executions_get':
586
+ return await this.getExecution(args.execution_id);
587
+ case 'agents_executions_trace':
588
+ return await this.getExecutionTrace(args.trace_id);
589
+ default:
590
+ return { success: false, error: `Unknown agent tool: ${toolName}` };
591
+ }
592
+ }
593
+ catch (error) {
594
+ return { success: false, error: error.response?.data?.error?.message || error.message };
595
+ }
596
+ }
597
+ // ===== DEFINITIONS =====
598
+ async listDefinitions(args) {
599
+ const params = {};
600
+ if (args.category)
601
+ params.category = args.category;
602
+ const response = await this.client.get('/api/agents/definitions', { params });
603
+ const defs = response.data.definitions || response.data;
604
+ if (!defs || defs.length === 0) {
605
+ return { success: true, output: 'No agent definitions found.' };
606
+ }
607
+ const lines = ['**Agent Definitions:**', ''];
608
+ defs.forEach((d, i) => {
609
+ lines.push(`[${i + 1}] ${d.icon || '🤖'} ${d.name}`);
610
+ lines.push(` ID: ${d.id}`);
611
+ if (d.description)
612
+ lines.push(` Description: ${d.description}`);
613
+ lines.push(` Category: ${d.category || 'general'}`);
614
+ lines.push('');
615
+ });
616
+ return { success: true, output: JSON.stringify(response.data, null, 2), data: response.data };
617
+ }
618
+ async getDefinition(definitionId) {
619
+ const response = await this.client.get(`/api/agents/definitions/${definitionId}`);
620
+ const d = response.data.definition || response.data;
621
+ const lines = [`**Agent: ${d.icon || '🤖'} ${d.name}**`, ''];
622
+ lines.push(`ID: ${d.id}`);
623
+ if (d.description)
624
+ lines.push(`Description: ${d.description}`);
625
+ lines.push(`Category: ${d.category || 'general'}`);
626
+ if (d.default_model)
627
+ lines.push(`Default Model: ${d.default_model}`);
628
+ if (d.system_prompt)
629
+ lines.push(`System Prompt: ${d.system_prompt.substring(0, 200)}...`);
630
+ return { success: true, output: JSON.stringify(response.data, null, 2), data: response.data };
631
+ }
632
+ async createDefinition(args) {
633
+ const response = await this.client.post('/api/agents/definitions', args);
634
+ const def = response.data.definition || response.data;
635
+ return { success: true, output: `✅ Agent definition "${args.name}" created (ID: ${def.id})`, data: response.data };
636
+ }
637
+ // ===== INSTANCES =====
638
+ async listInstances(args) {
639
+ const params = {};
640
+ if (args.workflow_id)
641
+ params.workflow_id = args.workflow_id;
642
+ const response = await this.client.get('/api/agents/instances', { params });
643
+ const instances = response.data;
644
+ if (!instances || instances.length === 0) {
645
+ return { success: true, output: 'No agent instances found.' };
646
+ }
647
+ const lines = ['**Agent Instances:**', ''];
648
+ instances.forEach((inst, i) => {
649
+ lines.push(`[${i + 1}] ${inst.icon || '🤖'} ${inst.definition_name || inst.name}`);
650
+ lines.push(` ID: ${inst.id}`);
651
+ lines.push(` Status: ${inst.status || 'UNKNOWN'}`);
652
+ if (inst.workflow_name)
653
+ lines.push(` Workflow: ${inst.workflow_name}`);
654
+ lines.push('');
655
+ });
656
+ return { success: true, output: JSON.stringify(response.data, null, 2), data: response.data };
657
+ }
658
+ async getInstance(instanceId) {
659
+ const response = await this.client.get(`/api/agents/instances/${instanceId}`);
660
+ const inst = response.data;
661
+ const lines = [`**Instance: ${inst.icon || '🤖'} ${inst.definition_name || inst.name}**`, ''];
662
+ lines.push(`ID: ${inst.id}`);
663
+ lines.push(`Status: ${inst.status || 'UNKNOWN'}`);
664
+ if (inst.workflow_name)
665
+ lines.push(`Workflow: ${inst.workflow_name}`);
666
+ if (inst.created_at)
667
+ lines.push(`Created: ${new Date(inst.created_at).toLocaleString()}`);
668
+ return { success: true, output: JSON.stringify(response.data, null, 2), data: response.data };
669
+ }
670
+ async getInstanceTrace(instanceId) {
671
+ const response = await this.client.get(`/api/agents/instances/${instanceId}/trace`);
672
+ const data = response.data;
673
+ const lines = ['**Instance Trace:**', ''];
674
+ if (data.nodes) {
675
+ lines.push(`Nodes: ${data.nodes.length}`);
676
+ lines.push(`Edges: ${data.edges?.length || 0}`);
677
+ }
678
+ return { success: true, output: lines.join('\n'), data };
679
+ }
680
+ // ===== WORKFLOWS =====
681
+ async listWorkflows() {
682
+ const response = await this.client.get('/api/agents/workflows');
683
+ const workflows = response.data.workflows || response.data;
684
+ if (!workflows || workflows.length === 0) {
685
+ return { success: true, output: 'No workflows found.' };
686
+ }
687
+ const lines = ['**Workflows:**', ''];
688
+ workflows.forEach((w, i) => {
689
+ lines.push(`[${i + 1}] ${w.name}`);
690
+ lines.push(` ID: ${w.id}`);
691
+ if (w.description)
692
+ lines.push(` Description: ${w.description}`);
693
+ lines.push(` Nodes: ${w.node_count || 0}, Edges: ${w.edge_count || 0}`);
694
+ lines.push('');
695
+ });
696
+ return { success: true, output: JSON.stringify(response.data, null, 2), data: response.data };
697
+ }
698
+ async getWorkflow(workflowId) {
699
+ const response = await this.client.get(`/api/agents/workflows/${workflowId}`);
700
+ const w = response.data.workflow || response.data;
701
+ const lines = [`**Workflow: ${w.name}**`, ''];
702
+ lines.push(`ID: ${w.id}`);
703
+ if (w.description)
704
+ lines.push(`Description: ${w.description}`);
705
+ lines.push(`Nodes: ${w.node_count || 0}, Edges: ${w.edge_count || 0}`);
706
+ return { success: true, output: JSON.stringify(response.data, null, 2), data: response.data };
707
+ }
708
+ async getWorkflowGraph(workflowId) {
709
+ const response = await this.client.get(`/api/agents/workflows/${workflowId}/graph`);
710
+ const data = response.data;
711
+ const lines = ['**Workflow Graph:**', ''];
712
+ lines.push(`Nodes: ${data.nodes?.length || 0}`);
713
+ lines.push(`Edges: ${data.edges?.length || 0}`);
714
+ if (data.nodes && data.nodes.length > 0) {
715
+ lines.push('', '**Nodes:**');
716
+ data.nodes.forEach((n) => {
717
+ lines.push(` - ${n.data?.icon || '📍'} ${n.data?.label || n.id} (${n.type})`);
718
+ });
719
+ }
720
+ return { success: true, output: lines.join('\n'), data };
721
+ }
722
+ async createWorkflow(args) {
723
+ const response = await this.client.post('/api/agents/workflows', args);
724
+ const wf = response.data.workflow || response.data;
725
+ return { success: true, output: `✅ Workflow "${args.name}" created (ID: ${wf.id})` };
726
+ }
727
+ async assignToWorkflow(args) {
728
+ const response = await this.client.post(`/api/agents/workflows/${args.workflow_id}/assign`, {
729
+ definition_id: args.definition_id,
730
+ instance_id: args.instance_id
731
+ });
732
+ return { success: true, output: `✅ Agent assigned to workflow.`, data: response.data };
733
+ }
734
+ async checkWorkflowReady(workflowId) {
735
+ const response = await this.client.get(`/api/agents/workflows/${workflowId}/ready`);
736
+ const data = response.data;
737
+ if (data.ready) {
738
+ return { success: true, output: `✅ Workflow is ready to execute.` };
739
+ }
740
+ else {
741
+ return { success: true, output: `⚠️ Workflow not ready: ${data.reason || 'Missing required connections'}` };
742
+ }
743
+ }
744
+ async executeWorkflow(args) {
745
+ const response = await this.client.post(`/api/agents/workflows/${args.workflow_id}/execute`, {
746
+ prompt: args.prompt,
747
+ variables: args.variables
748
+ });
749
+ const data = response.data;
750
+ return {
751
+ success: true,
752
+ output: `✅ Workflow execution started!\n\nTrace ID: ${data.trace_id || data.id}`,
753
+ data
754
+ };
755
+ }
756
+ async deleteWorkflow(workflowId) {
757
+ await this.client.delete(`/api/agents/workflows/${workflowId}`);
758
+ return { success: true, output: `✅ Workflow deleted.` };
759
+ }
760
+ // ===== EXECUTIONS =====
761
+ async listExecutions(args) {
762
+ const response = await this.client.get('/api/agents/executions', {
763
+ params: { limit: args.limit || 50 }
764
+ });
765
+ const executions = response.data.executions || response.data;
766
+ if (!executions || executions.length === 0) {
767
+ return { success: true, output: 'No workflow executions found.' };
768
+ }
769
+ const lines = ['**Workflow Executions:**', ''];
770
+ executions.forEach((e, i) => {
771
+ lines.push(`[${i + 1}] ${e.name || 'Execution'}`);
772
+ lines.push(` Trace ID: ${e.trace_id || e.id}`);
773
+ lines.push(` Status: ${e.status || 'UNKNOWN'}`);
774
+ lines.push(` Created: ${new Date(e.created_at).toLocaleString()}`);
775
+ lines.push('');
776
+ });
777
+ return { success: true, output: lines.join('\n') };
778
+ }
779
+ async getExecution(executionId) {
780
+ const response = await this.client.get(`/api/agents/executions/${executionId}`);
781
+ const e = response.data;
782
+ const lines = [`**Execution: ${e.name || 'Workflow Execution'}**`, ''];
783
+ lines.push(`Trace ID: ${e.trace_id || e.id}`);
784
+ lines.push(`Status: ${e.status || 'UNKNOWN'}`);
785
+ if (e.workflow_name)
786
+ lines.push(`Workflow: ${e.workflow_name}`);
787
+ if (e.created_at)
788
+ lines.push(`Started: ${new Date(e.created_at).toLocaleString()}`);
789
+ if (e.completed_at)
790
+ lines.push(`Completed: ${new Date(e.completed_at).toLocaleString()}`);
791
+ return { success: true, output: lines.join('\n') };
792
+ }
793
+ async getExecutionTrace(traceId) {
794
+ const response = await this.client.get(`/api/agents/executions/${traceId}/trace`);
795
+ const data = response.data;
796
+ const lines = ['**Execution Trace:**', ''];
797
+ lines.push(`Nodes: ${data.nodes?.length || 0}`);
798
+ lines.push(`Edges: ${data.edges?.length || 0}`);
799
+ if (data.nodes && data.nodes.length > 0) {
800
+ lines.push('', '**Agent Nodes:**');
801
+ data.nodes.forEach((n) => {
802
+ const status = n.data?.status || 'PENDING';
803
+ const icon = status === 'COMPLETED' ? '✅' : status === 'FAILED' ? '❌' : status === 'RUNNING' ? '🔄' : '⏳';
804
+ lines.push(` ${icon} ${n.data?.label || n.id} - ${status}`);
805
+ });
806
+ }
807
+ return { success: true, output: lines.join('\n'), data };
808
+ }
809
+ }
810
+ exports.AgentTools = AgentTools;
811
+ AgentTools.instance = null;
812
+ exports.default = AgentTools;
813
+ //# sourceMappingURL=agent-tools.js.map