@igoruehara/canvas-flow 0.1.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.
- package/LICENSE +21 -0
- package/README.md +152 -0
- package/bin/canvas-flow.js +1132 -0
- package/package.json +68 -0
- package/public/assets/index-PCQkqMUe.css +1 -0
- package/public/assets/index-qV8twxcq.js +767 -0
- package/public/index.html +13 -0
- package/server/api-key/api-key-connect-provider.d.ts +104 -0
- package/server/api-key/api-key-connect-provider.js +14 -0
- package/server/api-key/api-key-connect-provider.js.map +1 -0
- package/server/api-key/api-key-constants-model.d.ts +2 -0
- package/server/api-key/api-key-constants-model.js +6 -0
- package/server/api-key/api-key-constants-model.js.map +1 -0
- package/server/api-key/api-key-controller.d.ts +12 -0
- package/server/api-key/api-key-controller.js +86 -0
- package/server/api-key/api-key-controller.js.map +1 -0
- package/server/api-key/api-key-module.d.ts +2 -0
- package/server/api-key/api-key-module.js +27 -0
- package/server/api-key/api-key-module.js.map +1 -0
- package/server/api-key/api-key-schema.d.ts +72 -0
- package/server/api-key/api-key-schema.js +98 -0
- package/server/api-key/api-key-schema.js.map +1 -0
- package/server/api-key/api-key-service.d.ts +45 -0
- package/server/api-key/api-key-service.js +151 -0
- package/server/api-key/api-key-service.js.map +1 -0
- package/server/api-key/dto/create-api-key.dto.d.ts +8 -0
- package/server/api-key/dto/create-api-key.dto.js +7 -0
- package/server/api-key/dto/create-api-key.dto.js.map +1 -0
- package/server/app.module.d.ts +2 -0
- package/server/app.module.js +53 -0
- package/server/app.module.js.map +1 -0
- package/server/auth/auth-connect-provider.d.ts +140 -0
- package/server/auth/auth-connect-provider.js +20 -0
- package/server/auth/auth-connect-provider.js.map +1 -0
- package/server/auth/auth-constants-model.d.ts +4 -0
- package/server/auth/auth-constants-model.js +8 -0
- package/server/auth/auth-constants-model.js.map +1 -0
- package/server/auth/auth-controller.d.ts +25 -0
- package/server/auth/auth-controller.js +96 -0
- package/server/auth/auth-controller.js.map +1 -0
- package/server/auth/auth-module.d.ts +2 -0
- package/server/auth/auth-module.js +26 -0
- package/server/auth/auth-module.js.map +1 -0
- package/server/auth/auth-organization-schema.d.ts +44 -0
- package/server/auth/auth-organization-schema.js +62 -0
- package/server/auth/auth-organization-schema.js.map +1 -0
- package/server/auth/auth-schema.d.ts +56 -0
- package/server/auth/auth-schema.js +77 -0
- package/server/auth/auth-schema.js.map +1 -0
- package/server/auth/auth-service.d.ts +64 -0
- package/server/auth/auth-service.js +343 -0
- package/server/auth/auth-service.js.map +1 -0
- package/server/canvas-flow/canvas-flow-connect-provider.d.ts +278 -0
- package/server/canvas-flow/canvas-flow-connect-provider.js +24 -0
- package/server/canvas-flow/canvas-flow-connect-provider.js.map +1 -0
- package/server/canvas-flow/canvas-flow-constants-model.d.ts +6 -0
- package/server/canvas-flow/canvas-flow-constants-model.js +10 -0
- package/server/canvas-flow/canvas-flow-constants-model.js.map +1 -0
- package/server/canvas-flow/canvas-flow-controller.d.ts +98 -0
- package/server/canvas-flow/canvas-flow-controller.js +423 -0
- package/server/canvas-flow/canvas-flow-controller.js.map +1 -0
- package/server/canvas-flow/canvas-flow-module.d.ts +2 -0
- package/server/canvas-flow/canvas-flow-module.js +27 -0
- package/server/canvas-flow/canvas-flow-module.js.map +1 -0
- package/server/canvas-flow/canvas-flow-schema.d.ts +192 -0
- package/server/canvas-flow/canvas-flow-schema.js +239 -0
- package/server/canvas-flow/canvas-flow-schema.js.map +1 -0
- package/server/canvas-flow/canvas-flow-service.d.ts +250 -0
- package/server/canvas-flow/canvas-flow-service.js +1681 -0
- package/server/canvas-flow/canvas-flow-service.js.map +1 -0
- package/server/canvas-flow/dto/create-canvas-flow.dto.d.ts +11 -0
- package/server/canvas-flow/dto/create-canvas-flow.dto.js +61 -0
- package/server/canvas-flow/dto/create-canvas-flow.dto.js.map +1 -0
- package/server/canvas-flow/dto/update-canvas-flow.dto.d.ts +10 -0
- package/server/canvas-flow/dto/update-canvas-flow.dto.js +56 -0
- package/server/canvas-flow/dto/update-canvas-flow.dto.js.map +1 -0
- package/server/constants-global.d.ts +1 -0
- package/server/constants-global.js +5 -0
- package/server/constants-global.js.map +1 -0
- package/server/database/database.module.d.ts +2 -0
- package/server/database/database.module.js +23 -0
- package/server/database/database.module.js.map +1 -0
- package/server/database/database.providers.d.ts +7 -0
- package/server/database/database.providers.js +26 -0
- package/server/database/database.providers.js.map +1 -0
- package/server/documents/documents-connect-provider.d.ts +140 -0
- package/server/documents/documents-connect-provider.js +14 -0
- package/server/documents/documents-connect-provider.js.map +1 -0
- package/server/documents/documents-constants-model.d.ts +2 -0
- package/server/documents/documents-constants-model.js +6 -0
- package/server/documents/documents-constants-model.js.map +1 -0
- package/server/documents/documents-controller.d.ts +16 -0
- package/server/documents/documents-controller.js +117 -0
- package/server/documents/documents-controller.js.map +1 -0
- package/server/documents/documents-module.d.ts +2 -0
- package/server/documents/documents-module.js +27 -0
- package/server/documents/documents-module.js.map +1 -0
- package/server/documents/documents-schema.d.ts +96 -0
- package/server/documents/documents-schema.js +38 -0
- package/server/documents/documents-schema.js.map +1 -0
- package/server/documents/documents-service.d.ts +164 -0
- package/server/documents/documents-service.js +1417 -0
- package/server/documents/documents-service.js.map +1 -0
- package/server/flow-tag/flow-tag-connect-provider.d.ts +146 -0
- package/server/flow-tag/flow-tag-connect-provider.js +14 -0
- package/server/flow-tag/flow-tag-connect-provider.js.map +1 -0
- package/server/flow-tag/flow-tag-constants-model.d.ts +2 -0
- package/server/flow-tag/flow-tag-constants-model.js +6 -0
- package/server/flow-tag/flow-tag-constants-model.js.map +1 -0
- package/server/flow-tag/flow-tag-module.d.ts +2 -0
- package/server/flow-tag/flow-tag-module.js +24 -0
- package/server/flow-tag/flow-tag-module.js.map +1 -0
- package/server/flow-tag/flow-tag-schema.d.ts +100 -0
- package/server/flow-tag/flow-tag-schema.js +131 -0
- package/server/flow-tag/flow-tag-schema.js.map +1 -0
- package/server/flow-tag/flow-tag-service.d.ts +77 -0
- package/server/flow-tag/flow-tag-service.js +156 -0
- package/server/flow-tag/flow-tag-service.js.map +1 -0
- package/server/health.controller.d.ts +7 -0
- package/server/health.controller.js +33 -0
- package/server/health.controller.js.map +1 -0
- package/server/http-batch/http-batch-controller.d.ts +345 -0
- package/server/http-batch/http-batch-controller.js +40 -0
- package/server/http-batch/http-batch-controller.js.map +1 -0
- package/server/http-batch/http-batch-module.d.ts +2 -0
- package/server/http-batch/http-batch-module.js +25 -0
- package/server/http-batch/http-batch-module.js.map +1 -0
- package/server/http-batch/http-batch-service.d.ts +381 -0
- package/server/http-batch/http-batch-service.js +268 -0
- package/server/http-batch/http-batch-service.js.map +1 -0
- package/server/lambda.d.ts +2 -0
- package/server/lambda.js +115 -0
- package/server/lambda.js.map +1 -0
- package/server/llm/openai-provider.d.ts +8 -0
- package/server/llm/openai-provider.js +256 -0
- package/server/llm/openai-provider.js.map +1 -0
- package/server/main.d.ts +1 -0
- package/server/main.js +80 -0
- package/server/main.js.map +1 -0
- package/server/mcp-oauth/mcp-oauth-connect-provider.d.ts +164 -0
- package/server/mcp-oauth/mcp-oauth-connect-provider.js +14 -0
- package/server/mcp-oauth/mcp-oauth-connect-provider.js.map +1 -0
- package/server/mcp-oauth/mcp-oauth-constants-model.d.ts +2 -0
- package/server/mcp-oauth/mcp-oauth-constants-model.js +6 -0
- package/server/mcp-oauth/mcp-oauth-constants-model.js.map +1 -0
- package/server/mcp-oauth/mcp-oauth-controller.d.ts +66 -0
- package/server/mcp-oauth/mcp-oauth-controller.js +166 -0
- package/server/mcp-oauth/mcp-oauth-controller.js.map +1 -0
- package/server/mcp-oauth/mcp-oauth-module.d.ts +2 -0
- package/server/mcp-oauth/mcp-oauth-module.js +27 -0
- package/server/mcp-oauth/mcp-oauth-module.js.map +1 -0
- package/server/mcp-oauth/mcp-oauth-schema.d.ts +112 -0
- package/server/mcp-oauth/mcp-oauth-schema.js +148 -0
- package/server/mcp-oauth/mcp-oauth-schema.js.map +1 -0
- package/server/mcp-oauth/mcp-oauth-service.d.ts +189 -0
- package/server/mcp-oauth/mcp-oauth-service.js +545 -0
- package/server/mcp-oauth/mcp-oauth-service.js.map +1 -0
- package/server/memory/memory-connect-provider.d.ts +200 -0
- package/server/memory/memory-connect-provider.js +26 -0
- package/server/memory/memory-connect-provider.js.map +1 -0
- package/server/memory/memory-constants-model.d.ts +6 -0
- package/server/memory/memory-constants-model.js +10 -0
- package/server/memory/memory-constants-model.js.map +1 -0
- package/server/memory/memory-controller.d.ts +15 -0
- package/server/memory/memory-controller.js +53 -0
- package/server/memory/memory-controller.js.map +1 -0
- package/server/memory/memory-history-schema.d.ts +48 -0
- package/server/memory/memory-history-schema.js +62 -0
- package/server/memory/memory-history-schema.js.map +1 -0
- package/server/memory/memory-module.d.ts +2 -0
- package/server/memory/memory-module.js +26 -0
- package/server/memory/memory-module.js.map +1 -0
- package/server/memory/memory-schema.d.ts +48 -0
- package/server/memory/memory-schema.js +62 -0
- package/server/memory/memory-schema.js.map +1 -0
- package/server/memory/memory-service.d.ts +134 -0
- package/server/memory/memory-service.js +317 -0
- package/server/memory/memory-service.js.map +1 -0
- package/server/memory/memory-trace-history-schema.d.ts +48 -0
- package/server/memory/memory-trace-history-schema.js +62 -0
- package/server/memory/memory-trace-history-schema.js.map +1 -0
- package/server/observability/observability.d.ts +3 -0
- package/server/observability/observability.js +62 -0
- package/server/observability/observability.js.map +1 -0
- package/server/production-guard.d.ts +9 -0
- package/server/production-guard.js +105 -0
- package/server/production-guard.js.map +1 -0
- package/server/provider-config/provider-config-connect-provider.d.ts +44 -0
- package/server/provider-config/provider-config-connect-provider.js +14 -0
- package/server/provider-config/provider-config-connect-provider.js.map +1 -0
- package/server/provider-config/provider-config-constants-model.d.ts +3 -0
- package/server/provider-config/provider-config-constants-model.js +7 -0
- package/server/provider-config/provider-config-constants-model.js.map +1 -0
- package/server/provider-config/provider-config-controller.d.ts +23 -0
- package/server/provider-config/provider-config-controller.js +80 -0
- package/server/provider-config/provider-config-controller.js.map +1 -0
- package/server/provider-config/provider-config-module.d.ts +2 -0
- package/server/provider-config/provider-config-module.js +27 -0
- package/server/provider-config/provider-config-module.js.map +1 -0
- package/server/provider-config/provider-config-schema.d.ts +32 -0
- package/server/provider-config/provider-config-schema.js +46 -0
- package/server/provider-config/provider-config-schema.js.map +1 -0
- package/server/provider-config/provider-config-service.d.ts +178 -0
- package/server/provider-config/provider-config-service.js +689 -0
- package/server/provider-config/provider-config-service.js.map +1 -0
- package/server/queue/queue-job-connect-provider.d.ts +128 -0
- package/server/queue/queue-job-connect-provider.js +14 -0
- package/server/queue/queue-job-connect-provider.js.map +1 -0
- package/server/queue/queue-job-constants-model.d.ts +2 -0
- package/server/queue/queue-job-constants-model.js +6 -0
- package/server/queue/queue-job-constants-model.js.map +1 -0
- package/server/queue/queue-job-schema.d.ts +88 -0
- package/server/queue/queue-job-schema.js +119 -0
- package/server/queue/queue-job-schema.js.map +1 -0
- package/server/queue/queue-lock-connect-provider.d.ts +44 -0
- package/server/queue/queue-lock-connect-provider.js +14 -0
- package/server/queue/queue-lock-connect-provider.js.map +1 -0
- package/server/queue/queue-lock-constants-model.d.ts +2 -0
- package/server/queue/queue-lock-constants-model.js +6 -0
- package/server/queue/queue-lock-constants-model.js.map +1 -0
- package/server/queue/queue-lock-schema.d.ts +32 -0
- package/server/queue/queue-lock-schema.js +47 -0
- package/server/queue/queue-lock-schema.js.map +1 -0
- package/server/queue/queue-message-dedupe-connect-provider.d.ts +116 -0
- package/server/queue/queue-message-dedupe-connect-provider.js +14 -0
- package/server/queue/queue-message-dedupe-connect-provider.js.map +1 -0
- package/server/queue/queue-message-dedupe-constants-model.d.ts +2 -0
- package/server/queue/queue-message-dedupe-constants-model.js +6 -0
- package/server/queue/queue-message-dedupe-constants-model.js.map +1 -0
- package/server/queue/queue-message-dedupe-schema.d.ts +80 -0
- package/server/queue/queue-message-dedupe-schema.js +108 -0
- package/server/queue/queue-message-dedupe-schema.js.map +1 -0
- package/server/queue/queue-module.d.ts +2 -0
- package/server/queue/queue-module.js +33 -0
- package/server/queue/queue-module.js.map +1 -0
- package/server/queue/queue-rate-limit-connect-provider.d.ts +56 -0
- package/server/queue/queue-rate-limit-connect-provider.js +14 -0
- package/server/queue/queue-rate-limit-connect-provider.js.map +1 -0
- package/server/queue/queue-rate-limit-constants-model.d.ts +2 -0
- package/server/queue/queue-rate-limit-constants-model.js +6 -0
- package/server/queue/queue-rate-limit-constants-model.js.map +1 -0
- package/server/queue/queue-rate-limit-schema.d.ts +40 -0
- package/server/queue/queue-rate-limit-schema.js +57 -0
- package/server/queue/queue-rate-limit-schema.js.map +1 -0
- package/server/queue/sqs-transition-service.d.ts +123 -0
- package/server/queue/sqs-transition-service.js +442 -0
- package/server/queue/sqs-transition-service.js.map +1 -0
- package/server/rag/rag-controller.d.ts +167 -0
- package/server/rag/rag-controller.js +232 -0
- package/server/rag/rag-controller.js.map +1 -0
- package/server/rag/rag-module.d.ts +2 -0
- package/server/rag/rag-module.js +30 -0
- package/server/rag/rag-module.js.map +1 -0
- package/server/rag/rag-service.d.ts +361 -0
- package/server/rag/rag-service.js +2864 -0
- package/server/rag/rag-service.js.map +1 -0
- package/server/runner/flow-templates.d.ts +55 -0
- package/server/runner/flow-templates.js +388 -0
- package/server/runner/flow-templates.js.map +1 -0
- package/server/runner/langgraph-runtime.service.d.ts +77 -0
- package/server/runner/langgraph-runtime.service.js +221 -0
- package/server/runner/langgraph-runtime.service.js.map +1 -0
- package/server/runner/runner-controller.d.ts +1044 -0
- package/server/runner/runner-controller.js +751 -0
- package/server/runner/runner-controller.js.map +1 -0
- package/server/runner/runner-module.d.ts +2 -0
- package/server/runner/runner-module.js +37 -0
- package/server/runner/runner-module.js.map +1 -0
- package/server/runner/runner-queue-processor.d.ts +29 -0
- package/server/runner/runner-queue-processor.js +259 -0
- package/server/runner/runner-queue-processor.js.map +1 -0
- package/server/runner/runner-service.d.ts +1761 -0
- package/server/runner/runner-service.js +14256 -0
- package/server/runner/runner-service.js.map +1 -0
- package/server/scripts/migrate-canvas-flow-versions.d.ts +1 -0
- package/server/scripts/migrate-canvas-flow-versions.js +72 -0
- package/server/scripts/migrate-canvas-flow-versions.js.map +1 -0
- package/server/scripts/migrate-mcp-oauth-user-scope.d.ts +1 -0
- package/server/scripts/migrate-mcp-oauth-user-scope.js +95 -0
- package/server/scripts/migrate-mcp-oauth-user-scope.js.map +1 -0
- package/templates/config.example.json +204 -0
- package/templates/config.production.example.json +206 -0
- package/templates/docker-compose.yml +60 -0
|
@@ -0,0 +1,751 @@
|
|
|
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
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.RunnerController = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
18
|
+
const crypto_1 = require("crypto");
|
|
19
|
+
const api_key_service_1 = require("../api-key/api-key-service");
|
|
20
|
+
const auth_service_1 = require("../auth/auth-service");
|
|
21
|
+
const sqs_transition_service_1 = require("../queue/sqs-transition-service");
|
|
22
|
+
const flow_templates_1 = require("./flow-templates");
|
|
23
|
+
const runner_queue_processor_1 = require("./runner-queue-processor");
|
|
24
|
+
const runner_service_1 = require("./runner-service");
|
|
25
|
+
let RunnerController = class RunnerController {
|
|
26
|
+
constructor(service, apiKeyService, authService, sqsTransitionService, runnerQueueProcessor) {
|
|
27
|
+
this.service = service;
|
|
28
|
+
this.apiKeyService = apiKeyService;
|
|
29
|
+
this.authService = authService;
|
|
30
|
+
this.sqsTransitionService = sqsTransitionService;
|
|
31
|
+
this.runnerQueueProcessor = runnerQueueProcessor;
|
|
32
|
+
}
|
|
33
|
+
async assertApiToken(body, authorization, headerToken, xApiKey) {
|
|
34
|
+
if (this.authService.isLoginRequired()) {
|
|
35
|
+
const user = await this.authService.resolveUserFromHeaders(authorization, headerToken, xApiKey);
|
|
36
|
+
if (user)
|
|
37
|
+
return { organizationId: user.organizationId, userId: user.id };
|
|
38
|
+
}
|
|
39
|
+
const expected = this.apiKeyService.getMasterToken();
|
|
40
|
+
if (!expected && !authorization && !headerToken && !xApiKey)
|
|
41
|
+
return;
|
|
42
|
+
const received = this.apiKeyService.extractToken(authorization, headerToken, xApiKey);
|
|
43
|
+
const validation = await this.apiKeyService.validateRunToken(received, {
|
|
44
|
+
flowId: body?.flowId,
|
|
45
|
+
agentId: body?.agentId,
|
|
46
|
+
});
|
|
47
|
+
if (!validation.valid) {
|
|
48
|
+
throw new common_1.UnauthorizedException('Invalid Canvas Flow API token');
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
organizationId: validation.kind === 'generated' ? validation.key?.organizationId : undefined,
|
|
52
|
+
userId: validation.kind === 'generated' ? validation.key?.createdBy : undefined,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
async test(body, authorization, headerToken, xApiKey) {
|
|
56
|
+
const auth = await this.assertApiToken(body, authorization, headerToken, xApiKey);
|
|
57
|
+
const runBody = {
|
|
58
|
+
...body,
|
|
59
|
+
_organizationId: auth?.organizationId,
|
|
60
|
+
_oauthUserId: auth?.userId,
|
|
61
|
+
_conversationOwnerId: auth?.userId || '',
|
|
62
|
+
_langGraphRunId: (0, crypto_1.randomUUID)(),
|
|
63
|
+
};
|
|
64
|
+
const channel = runBody.channel || runBody.config?.channel || 'webWidget';
|
|
65
|
+
await this.sqsTransitionService.assertRateLimit({
|
|
66
|
+
scope: [
|
|
67
|
+
auth?.organizationId || 'global',
|
|
68
|
+
runBody.agentId || 'default-agent',
|
|
69
|
+
channel || 'api',
|
|
70
|
+
].join(':'),
|
|
71
|
+
limit: this.sqsTransitionService.getRateLimit(channel === 'webWidget' ? 'webwidget' : 'api'),
|
|
72
|
+
});
|
|
73
|
+
if (this.sqsTransitionService.isEnabled() && (body?.queue === true || body?.async === true)) {
|
|
74
|
+
return await this.sqsTransitionService.enqueue('canvas-flow.run', { ...runBody, skipQueue: true }, { trackResult: true });
|
|
75
|
+
}
|
|
76
|
+
return await this.service.run(runBody);
|
|
77
|
+
}
|
|
78
|
+
async templates(authorization, headerToken, xApiKey) {
|
|
79
|
+
await this.assertApiToken({}, authorization, headerToken, xApiKey);
|
|
80
|
+
return { templates: (0, flow_templates_1.getCanvasFlowTemplates)() };
|
|
81
|
+
}
|
|
82
|
+
async agentOpsDashboard(body, authorization, headerToken, xApiKey) {
|
|
83
|
+
const auth = await this.assertApiToken(body, authorization, headerToken, xApiKey);
|
|
84
|
+
return await this.service.getAgentOpsDashboard({ ...body, _organizationId: auth?.organizationId });
|
|
85
|
+
}
|
|
86
|
+
async mcpTools(agentId, authorization, headerToken, xApiKey) {
|
|
87
|
+
const auth = await this.assertApiToken({ agentId }, authorization, headerToken, xApiKey);
|
|
88
|
+
const tools = await this.service.listMcpTools(agentId, auth?.organizationId);
|
|
89
|
+
return {
|
|
90
|
+
name: `canvas-flow-${agentId || 'default-agent'}`,
|
|
91
|
+
protocol: 'mcp-json-rpc',
|
|
92
|
+
transport: 'http-json-rpc-post',
|
|
93
|
+
endpoint: `/api/canvas-flow/mcp/${encodeURIComponent(agentId || 'default-agent')}`,
|
|
94
|
+
authentication: {
|
|
95
|
+
headers: {
|
|
96
|
+
Authorization: 'Bearer <CANVAS_FLOW_API_KEY>',
|
|
97
|
+
'x-api-key': '<CANVAS_FLOW_API_KEY>',
|
|
98
|
+
},
|
|
99
|
+
note: 'Use uma API Key gerada no Canvas Flow. O token master deve ficar reservado para administracao.',
|
|
100
|
+
},
|
|
101
|
+
consumption: {
|
|
102
|
+
description: 'Este endpoint e um MCP server HTTP: envie JSON-RPC 2.0 por POST para initialize, tools/list e tools/call.',
|
|
103
|
+
sequence: ['initialize', 'tools/list', 'tools/call'],
|
|
104
|
+
toolNameSource: 'Sempre chame tools/list primeiro e use o campo result.tools[].name no tools/call.',
|
|
105
|
+
callArguments: {
|
|
106
|
+
text: 'Mensagem ou tarefa de entrada para executar o flow.',
|
|
107
|
+
conversationId: 'Opcional. Reutilize para preservar memoria entre chamadas.',
|
|
108
|
+
slots: 'Opcional. Objeto usado como context.slots inicial.',
|
|
109
|
+
flowVersion: 'Opcional. Versao especifica do flow.',
|
|
110
|
+
agentRelease: 'Opcional. Release especifico do agente.',
|
|
111
|
+
approvals: 'Opcional. Decisoes humanas pre-aprovadas por stepId ou responseName.',
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
clientExample: {
|
|
115
|
+
initialize: {
|
|
116
|
+
jsonrpc: '2.0',
|
|
117
|
+
id: 1,
|
|
118
|
+
method: 'initialize',
|
|
119
|
+
params: { protocolVersion: '2025-06-18', capabilities: {}, clientInfo: { name: 'meu-mcp-client', version: '1.0.0' } },
|
|
120
|
+
},
|
|
121
|
+
listTools: { jsonrpc: '2.0', id: 2, method: 'tools/list', params: {} },
|
|
122
|
+
callTool: {
|
|
123
|
+
jsonrpc: '2.0',
|
|
124
|
+
id: 3,
|
|
125
|
+
method: 'tools/call',
|
|
126
|
+
params: {
|
|
127
|
+
name: tools?.[0]?.name || '<NOME_RETORNADO_EM_TOOLS_LIST>',
|
|
128
|
+
arguments: { text: 'Preciso de ajuda', conversationId: 'mcp-cliente-123', slots: {} },
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
tools,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
async mcpJsonRpc(agentId, body, authorization, headerToken, xApiKey) {
|
|
136
|
+
const auth = await this.assertApiToken({ agentId }, authorization, headerToken, xApiKey);
|
|
137
|
+
return await this.service.handleMcpJsonRpc(agentId, body, auth?.organizationId, auth?.userId);
|
|
138
|
+
}
|
|
139
|
+
async listExternalMcpTools(body, authorization, headerToken, xApiKey) {
|
|
140
|
+
const auth = await this.assertApiToken(body, authorization, headerToken, xApiKey);
|
|
141
|
+
return await this.service.listExternalMcpTools({ ...body, _organizationId: auth?.organizationId, _oauthUserId: auth?.userId });
|
|
142
|
+
}
|
|
143
|
+
async replaySimulation(body, authorization, headerToken, xApiKey) {
|
|
144
|
+
const auth = await this.assertApiToken(body, authorization, headerToken, xApiKey);
|
|
145
|
+
return await this.service.replaySimulation({ ...body, _organizationId: auth?.organizationId, _oauthUserId: auth?.userId });
|
|
146
|
+
}
|
|
147
|
+
async testStream(body, res, authorization, headerToken, xApiKey) {
|
|
148
|
+
const auth = await this.assertApiToken(body, authorization, headerToken, xApiKey);
|
|
149
|
+
res.setHeader('Content-Type', 'application/x-ndjson; charset=utf-8');
|
|
150
|
+
res.setHeader('Cache-Control', 'no-cache, no-transform');
|
|
151
|
+
res.setHeader('X-Accel-Buffering', 'no');
|
|
152
|
+
const write = (event, payload) => {
|
|
153
|
+
res.write(`${JSON.stringify({ event, ...payload })}\n`);
|
|
154
|
+
if (typeof res.flush === 'function')
|
|
155
|
+
res.flush();
|
|
156
|
+
};
|
|
157
|
+
try {
|
|
158
|
+
const result = await this.service.run({
|
|
159
|
+
...body,
|
|
160
|
+
_organizationId: auth?.organizationId,
|
|
161
|
+
_oauthUserId: auth?.userId,
|
|
162
|
+
_conversationOwnerId: auth?.userId || '',
|
|
163
|
+
_langGraphRunId: (0, crypto_1.randomUUID)(),
|
|
164
|
+
_onMessage: (message) => write('message', { message }),
|
|
165
|
+
});
|
|
166
|
+
write('result', { result: { ...result, messages: [] } });
|
|
167
|
+
res.end();
|
|
168
|
+
}
|
|
169
|
+
catch (error) {
|
|
170
|
+
write('error', { message: error?.message || String(error) });
|
|
171
|
+
res.end();
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
async generateContextScript(body, authorization, headerToken, xApiKey) {
|
|
175
|
+
const auth = await this.assertApiToken(body, authorization, headerToken, xApiKey);
|
|
176
|
+
return await this.service.generateContextScriptWithLlm({ ...body, _organizationId: auth?.organizationId });
|
|
177
|
+
}
|
|
178
|
+
async generateMongoConfig(body, authorization, headerToken, xApiKey) {
|
|
179
|
+
const auth = await this.assertApiToken(body, authorization, headerToken, xApiKey);
|
|
180
|
+
return await this.service.generateMongoConfigWithLlm({ ...body, _organizationId: auth?.organizationId });
|
|
181
|
+
}
|
|
182
|
+
async generateFlowWithAssistant(body, authorization, headerToken, xApiKey) {
|
|
183
|
+
const auth = await this.assertApiToken(body, authorization, headerToken, xApiKey);
|
|
184
|
+
return await this.service.generateFlowConfigWithLlm({ ...body, _organizationId: auth?.organizationId });
|
|
185
|
+
}
|
|
186
|
+
async generatePromptField(body, authorization, headerToken, xApiKey) {
|
|
187
|
+
const auth = await this.assertApiToken(body, authorization, headerToken, xApiKey);
|
|
188
|
+
return await this.service.generatePromptFieldWithLlm({ ...body, _organizationId: auth?.organizationId });
|
|
189
|
+
}
|
|
190
|
+
async createWhatsappFlow(body, authorization, headerToken, xApiKey) {
|
|
191
|
+
const auth = await this.assertApiToken(body, authorization, headerToken, xApiKey);
|
|
192
|
+
return await this.service.createWhatsappFlow({ ...body, _organizationId: auth?.organizationId });
|
|
193
|
+
}
|
|
194
|
+
async listWhatsappFlows(body, authorization, headerToken, xApiKey) {
|
|
195
|
+
const auth = await this.assertApiToken(body, authorization, headerToken, xApiKey);
|
|
196
|
+
return await this.service.listWhatsappFlows({ ...body, _organizationId: auth?.organizationId });
|
|
197
|
+
}
|
|
198
|
+
async deleteWhatsappFlow(flowId, body, authorization, headerToken, xApiKey) {
|
|
199
|
+
const auth = await this.assertApiToken({ ...body, flowId }, authorization, headerToken, xApiKey);
|
|
200
|
+
return await this.service.deleteWhatsappFlow({ ...body, flowId, _organizationId: auth?.organizationId });
|
|
201
|
+
}
|
|
202
|
+
async uploadWhatsappFlowJson(flowId, body, authorization, headerToken, xApiKey) {
|
|
203
|
+
const auth = await this.assertApiToken({ ...body, flowId }, authorization, headerToken, xApiKey);
|
|
204
|
+
return await this.service.uploadWhatsappFlowJson({ ...body, flowId, _organizationId: auth?.organizationId });
|
|
205
|
+
}
|
|
206
|
+
async publishWhatsappFlow(flowId, body, authorization, headerToken, xApiKey) {
|
|
207
|
+
const auth = await this.assertApiToken({ ...body, flowId }, authorization, headerToken, xApiKey);
|
|
208
|
+
return await this.service.publishWhatsappFlow({ ...body, flowId, _organizationId: auth?.organizationId });
|
|
209
|
+
}
|
|
210
|
+
async tagDashboard(body, authorization, headerToken, xApiKey) {
|
|
211
|
+
const auth = await this.assertApiToken(body, authorization, headerToken, xApiKey);
|
|
212
|
+
return await this.service.getTagDashboard({ ...body, _organizationId: auth?.organizationId });
|
|
213
|
+
}
|
|
214
|
+
async runDueCron(body, authorization, headerToken, xApiKey) {
|
|
215
|
+
await this.assertApiToken(body, authorization, headerToken, xApiKey);
|
|
216
|
+
return await this.service.runDueCronFlows({
|
|
217
|
+
agentId: body?.agentId,
|
|
218
|
+
dryRun: body?.dryRun === true,
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
async consumeSqsMessages(body, authorization, headerToken, xApiKey) {
|
|
222
|
+
await this.assertApiToken(body, authorization, headerToken, xApiKey);
|
|
223
|
+
const records = Array.isArray(body?.Records) ? body.Records : [body];
|
|
224
|
+
return await this.runnerQueueProcessor.processRecords(records);
|
|
225
|
+
}
|
|
226
|
+
async getSqsJob(jobId, agentId, flowId, authorization, headerToken, xApiKey) {
|
|
227
|
+
const auth = await this.assertApiToken({ agentId, flowId }, authorization, headerToken, xApiKey);
|
|
228
|
+
return await this.sqsTransitionService.getJob(jobId, auth?.organizationId);
|
|
229
|
+
}
|
|
230
|
+
async retrySqsJob(jobId, body, authorization, headerToken, xApiKey) {
|
|
231
|
+
const auth = await this.assertApiToken(body || {}, authorization, headerToken, xApiKey);
|
|
232
|
+
return await this.sqsTransitionService.retryJob(jobId, auth?.organizationId);
|
|
233
|
+
}
|
|
234
|
+
async getSqsHealth(authorization, headerToken, xApiKey) {
|
|
235
|
+
await this.assertApiToken({}, authorization, headerToken, xApiKey);
|
|
236
|
+
return await this.sqsTransitionService.getQueueHealth();
|
|
237
|
+
}
|
|
238
|
+
async getReport(fileName, res) {
|
|
239
|
+
const filePath = this.service.getReportFilePath(fileName);
|
|
240
|
+
return res.download(filePath, fileName);
|
|
241
|
+
}
|
|
242
|
+
async getWhatsappMedia(flowId, mediaId, expiresAt, signature, res) {
|
|
243
|
+
const media = await this.service.downloadWhatsappMedia(flowId, mediaId, expiresAt, signature);
|
|
244
|
+
res.setHeader('Content-Type', media.mimeType || 'application/octet-stream');
|
|
245
|
+
res.setHeader('Content-Disposition', `inline; filename="${media.fileName}"`);
|
|
246
|
+
res.setHeader('Cache-Control', 'private, max-age=300');
|
|
247
|
+
return res.status(200).send(media.buffer);
|
|
248
|
+
}
|
|
249
|
+
async receiveCustomWebhookGet(flowId, webhookId, query, headers) {
|
|
250
|
+
await this.sqsTransitionService.assertRateLimit({
|
|
251
|
+
scope: ['custom-webhook', flowId, webhookId].join(':'),
|
|
252
|
+
limit: this.sqsTransitionService.getRateLimit('api'),
|
|
253
|
+
});
|
|
254
|
+
return await this.service.runCustomWebhook(flowId, webhookId, {
|
|
255
|
+
method: 'GET',
|
|
256
|
+
query,
|
|
257
|
+
headers,
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
async receiveCustomWebhookPost(flowId, webhookId, body, query, headers) {
|
|
261
|
+
await this.sqsTransitionService.assertRateLimit({
|
|
262
|
+
scope: ['custom-webhook', flowId, webhookId].join(':'),
|
|
263
|
+
limit: this.sqsTransitionService.getRateLimit('api'),
|
|
264
|
+
});
|
|
265
|
+
return await this.service.runCustomWebhook(flowId, webhookId, {
|
|
266
|
+
method: 'POST',
|
|
267
|
+
body,
|
|
268
|
+
query,
|
|
269
|
+
headers,
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
async verifyWhatsappWebhook(flowId, mode, verifyToken, challenge, res) {
|
|
273
|
+
const verifiedChallenge = await this.service.verifyWhatsappWebhook(flowId, mode, verifyToken, challenge);
|
|
274
|
+
return res.status(200).send(verifiedChallenge);
|
|
275
|
+
}
|
|
276
|
+
async verifyWhatsappMainWebhook(agentId, mode, verifyToken, challenge, res) {
|
|
277
|
+
const verifiedChallenge = await this.service.verifyWhatsappMainWebhook(agentId, mode, verifyToken, challenge);
|
|
278
|
+
return res.status(200).send(verifiedChallenge);
|
|
279
|
+
}
|
|
280
|
+
async receiveWhatsappWebhook(flowId, body) {
|
|
281
|
+
await this.sqsTransitionService.assertRateLimit({
|
|
282
|
+
scope: ['whatsapp', flowId].join(':'),
|
|
283
|
+
limit: this.sqsTransitionService.getRateLimit('whatsapp'),
|
|
284
|
+
});
|
|
285
|
+
if (this.sqsTransitionService.isEnabled() && body?.skipQueue !== true) {
|
|
286
|
+
return await this.sqsTransitionService.enqueue('canvas-flow.whatsapp', { flowId, body, skipQueue: true }, { trackResult: true });
|
|
287
|
+
}
|
|
288
|
+
return await this.service.runWhatsappWebhook(flowId, body);
|
|
289
|
+
}
|
|
290
|
+
async receiveWhatsappMainWebhook(agentId, body) {
|
|
291
|
+
await this.sqsTransitionService.assertRateLimit({
|
|
292
|
+
scope: ['whatsapp-main', agentId].join(':'),
|
|
293
|
+
limit: this.sqsTransitionService.getRateLimit('whatsapp'),
|
|
294
|
+
});
|
|
295
|
+
if (this.sqsTransitionService.isEnabled() && body?.skipQueue !== true) {
|
|
296
|
+
return await this.sqsTransitionService.enqueue('canvas-flow.whatsapp-main', { agentId, body, skipQueue: true }, { trackResult: true });
|
|
297
|
+
}
|
|
298
|
+
return await this.service.runWhatsappMainWebhook(agentId, body);
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
exports.RunnerController = RunnerController;
|
|
302
|
+
__decorate([
|
|
303
|
+
(0, common_1.Post)('test'),
|
|
304
|
+
__param(0, (0, common_1.Body)()),
|
|
305
|
+
__param(1, (0, common_1.Headers)('authorization')),
|
|
306
|
+
__param(2, (0, common_1.Headers)('x-canvas-flow-token')),
|
|
307
|
+
__param(3, (0, common_1.Headers)('x-api-key')),
|
|
308
|
+
__metadata("design:type", Function),
|
|
309
|
+
__metadata("design:paramtypes", [Object, String, String, String]),
|
|
310
|
+
__metadata("design:returntype", Promise)
|
|
311
|
+
], RunnerController.prototype, "test", null);
|
|
312
|
+
__decorate([
|
|
313
|
+
(0, common_1.Get)('templates'),
|
|
314
|
+
__param(0, (0, common_1.Headers)('authorization')),
|
|
315
|
+
__param(1, (0, common_1.Headers)('x-canvas-flow-token')),
|
|
316
|
+
__param(2, (0, common_1.Headers)('x-api-key')),
|
|
317
|
+
__metadata("design:type", Function),
|
|
318
|
+
__metadata("design:paramtypes", [String, String, String]),
|
|
319
|
+
__metadata("design:returntype", Promise)
|
|
320
|
+
], RunnerController.prototype, "templates", null);
|
|
321
|
+
__decorate([
|
|
322
|
+
(0, common_1.Post)('agentops/dashboard'),
|
|
323
|
+
__param(0, (0, common_1.Body)()),
|
|
324
|
+
__param(1, (0, common_1.Headers)('authorization')),
|
|
325
|
+
__param(2, (0, common_1.Headers)('x-canvas-flow-token')),
|
|
326
|
+
__param(3, (0, common_1.Headers)('x-api-key')),
|
|
327
|
+
__metadata("design:type", Function),
|
|
328
|
+
__metadata("design:paramtypes", [Object, String, String, String]),
|
|
329
|
+
__metadata("design:returntype", Promise)
|
|
330
|
+
], RunnerController.prototype, "agentOpsDashboard", null);
|
|
331
|
+
__decorate([
|
|
332
|
+
(0, common_1.Get)('mcp/:agentId'),
|
|
333
|
+
(0, swagger_1.ApiOperation)({
|
|
334
|
+
summary: 'Descreve o MCP server HTTP de um agente',
|
|
335
|
+
description: [
|
|
336
|
+
'Retorna metadados para um MCP client consumir os flows salvos do agente.',
|
|
337
|
+
'O transporte exposto e JSON-RPC 2.0 sobre HTTP POST no mesmo endpoint.',
|
|
338
|
+
'Cada flow salvo com steps vira uma tool MCP retornada em tools/list.',
|
|
339
|
+
].join(' '),
|
|
340
|
+
}),
|
|
341
|
+
(0, swagger_1.ApiParam)({ name: 'agentId', description: 'Agente cujos flows serao expostos como tools MCP.' }),
|
|
342
|
+
(0, swagger_1.ApiHeader)({
|
|
343
|
+
name: 'Authorization',
|
|
344
|
+
required: false,
|
|
345
|
+
description: 'Bearer <CANVAS_FLOW_API_KEY>. Alternativas aceitas: x-api-key ou x-canvas-flow-token.',
|
|
346
|
+
}),
|
|
347
|
+
(0, swagger_1.ApiResponse)({
|
|
348
|
+
status: 200,
|
|
349
|
+
description: 'Metadados do MCP server e catalogo inicial de tools.',
|
|
350
|
+
schema: {
|
|
351
|
+
example: {
|
|
352
|
+
name: 'canvas-flow-default-agent',
|
|
353
|
+
protocol: 'mcp-json-rpc',
|
|
354
|
+
transport: 'http-json-rpc-post',
|
|
355
|
+
endpoint: '/api/canvas-flow/mcp/default-agent',
|
|
356
|
+
authentication: {
|
|
357
|
+
headers: {
|
|
358
|
+
Authorization: 'Bearer <CANVAS_FLOW_API_KEY>',
|
|
359
|
+
'x-api-key': '<CANVAS_FLOW_API_KEY>',
|
|
360
|
+
},
|
|
361
|
+
},
|
|
362
|
+
consumption: {
|
|
363
|
+
sequence: ['initialize', 'tools/list', 'tools/call'],
|
|
364
|
+
toolNameSource: 'Use result.tools[].name retornado por tools/list.',
|
|
365
|
+
callArguments: {
|
|
366
|
+
text: 'Mensagem ou tarefa para executar o flow.',
|
|
367
|
+
conversationId: 'Opcional, preserva memoria entre chamadas.',
|
|
368
|
+
slots: 'Opcional, contexto inicial em context.slots.',
|
|
369
|
+
},
|
|
370
|
+
},
|
|
371
|
+
tools: [
|
|
372
|
+
{
|
|
373
|
+
name: 'atendimento_inicial',
|
|
374
|
+
title: 'Atendimento inicial',
|
|
375
|
+
description: 'Executa o fluxo "Atendimento inicial".',
|
|
376
|
+
inputSchema: { type: 'object', required: ['text'] },
|
|
377
|
+
},
|
|
378
|
+
],
|
|
379
|
+
},
|
|
380
|
+
},
|
|
381
|
+
}),
|
|
382
|
+
__param(0, (0, common_1.Param)('agentId')),
|
|
383
|
+
__param(1, (0, common_1.Headers)('authorization')),
|
|
384
|
+
__param(2, (0, common_1.Headers)('x-canvas-flow-token')),
|
|
385
|
+
__param(3, (0, common_1.Headers)('x-api-key')),
|
|
386
|
+
__metadata("design:type", Function),
|
|
387
|
+
__metadata("design:paramtypes", [String, String, String, String]),
|
|
388
|
+
__metadata("design:returntype", Promise)
|
|
389
|
+
], RunnerController.prototype, "mcpTools", null);
|
|
390
|
+
__decorate([
|
|
391
|
+
(0, common_1.Post)('mcp/:agentId'),
|
|
392
|
+
(0, swagger_1.ApiOperation)({
|
|
393
|
+
summary: 'Executa chamadas MCP JSON-RPC para o agente',
|
|
394
|
+
description: [
|
|
395
|
+
'Endpoint de consumo para MCP clients.',
|
|
396
|
+
'Aceita JSON-RPC 2.0 simples ou batch por HTTP POST.',
|
|
397
|
+
'Metodos suportados: initialize, ping, notifications/initialized, tools/list e tools/call.',
|
|
398
|
+
].join(' '),
|
|
399
|
+
}),
|
|
400
|
+
(0, swagger_1.ApiParam)({ name: 'agentId', description: 'Agente cujos flows serao expostos como tools MCP.' }),
|
|
401
|
+
(0, swagger_1.ApiHeader)({
|
|
402
|
+
name: 'Authorization',
|
|
403
|
+
required: false,
|
|
404
|
+
description: 'Bearer <CANVAS_FLOW_API_KEY>. Alternativas aceitas: x-api-key ou x-canvas-flow-token.',
|
|
405
|
+
}),
|
|
406
|
+
(0, swagger_1.ApiBody)({
|
|
407
|
+
description: 'Requisicao MCP JSON-RPC 2.0. Para tools/call, use params.name vindo de tools/list.',
|
|
408
|
+
schema: {
|
|
409
|
+
oneOf: [
|
|
410
|
+
{
|
|
411
|
+
type: 'object',
|
|
412
|
+
properties: {
|
|
413
|
+
jsonrpc: { type: 'string', example: '2.0' },
|
|
414
|
+
id: { oneOf: [{ type: 'string' }, { type: 'number' }], example: 2 },
|
|
415
|
+
method: { type: 'string', example: 'tools/call' },
|
|
416
|
+
params: {
|
|
417
|
+
type: 'object',
|
|
418
|
+
example: {
|
|
419
|
+
name: 'atendimento_inicial',
|
|
420
|
+
arguments: {
|
|
421
|
+
text: 'Preciso de ajuda',
|
|
422
|
+
conversationId: 'mcp-cliente-123',
|
|
423
|
+
slots: {},
|
|
424
|
+
},
|
|
425
|
+
},
|
|
426
|
+
},
|
|
427
|
+
},
|
|
428
|
+
required: ['jsonrpc', 'method'],
|
|
429
|
+
},
|
|
430
|
+
{ type: 'array', items: { type: 'object' } },
|
|
431
|
+
],
|
|
432
|
+
},
|
|
433
|
+
examples: {
|
|
434
|
+
initialize: {
|
|
435
|
+
summary: 'Inicializar cliente MCP',
|
|
436
|
+
value: { jsonrpc: '2.0', id: 1, method: 'initialize', params: { protocolVersion: '2025-06-18', capabilities: {}, clientInfo: { name: 'meu-mcp-client', version: '1.0.0' } } },
|
|
437
|
+
},
|
|
438
|
+
listTools: {
|
|
439
|
+
summary: 'Listar tools expostas pelos flows',
|
|
440
|
+
value: { jsonrpc: '2.0', id: 2, method: 'tools/list', params: {} },
|
|
441
|
+
},
|
|
442
|
+
callTool: {
|
|
443
|
+
summary: 'Chamar uma tool retornada por tools/list',
|
|
444
|
+
value: { jsonrpc: '2.0', id: 3, method: 'tools/call', params: { name: 'atendimento_inicial', arguments: { text: 'Preciso de ajuda', conversationId: 'mcp-cliente-123', slots: {} } } },
|
|
445
|
+
},
|
|
446
|
+
},
|
|
447
|
+
}),
|
|
448
|
+
(0, swagger_1.ApiResponse)({
|
|
449
|
+
status: 200,
|
|
450
|
+
description: 'Resposta MCP JSON-RPC.',
|
|
451
|
+
schema: {
|
|
452
|
+
example: {
|
|
453
|
+
jsonrpc: '2.0',
|
|
454
|
+
id: 3,
|
|
455
|
+
result: {
|
|
456
|
+
content: [{ type: 'text', text: 'assistant: Ola, como posso ajudar?' }],
|
|
457
|
+
structuredContent: {
|
|
458
|
+
messages: [{ role: 'assistant', text: 'Ola, como posso ajudar?' }],
|
|
459
|
+
slots: {},
|
|
460
|
+
ended: false,
|
|
461
|
+
conversationId: 'mcp-cliente-123',
|
|
462
|
+
flowId: '665f...',
|
|
463
|
+
flowName: 'Atendimento inicial',
|
|
464
|
+
},
|
|
465
|
+
},
|
|
466
|
+
},
|
|
467
|
+
},
|
|
468
|
+
}),
|
|
469
|
+
__param(0, (0, common_1.Param)('agentId')),
|
|
470
|
+
__param(1, (0, common_1.Body)()),
|
|
471
|
+
__param(2, (0, common_1.Headers)('authorization')),
|
|
472
|
+
__param(3, (0, common_1.Headers)('x-canvas-flow-token')),
|
|
473
|
+
__param(4, (0, common_1.Headers)('x-api-key')),
|
|
474
|
+
__metadata("design:type", Function),
|
|
475
|
+
__metadata("design:paramtypes", [String, Object, String, String, String]),
|
|
476
|
+
__metadata("design:returntype", Promise)
|
|
477
|
+
], RunnerController.prototype, "mcpJsonRpc", null);
|
|
478
|
+
__decorate([
|
|
479
|
+
(0, common_1.Post)('mcp-external/tools'),
|
|
480
|
+
__param(0, (0, common_1.Body)()),
|
|
481
|
+
__param(1, (0, common_1.Headers)('authorization')),
|
|
482
|
+
__param(2, (0, common_1.Headers)('x-canvas-flow-token')),
|
|
483
|
+
__param(3, (0, common_1.Headers)('x-api-key')),
|
|
484
|
+
__metadata("design:type", Function),
|
|
485
|
+
__metadata("design:paramtypes", [Object, String, String, String]),
|
|
486
|
+
__metadata("design:returntype", Promise)
|
|
487
|
+
], RunnerController.prototype, "listExternalMcpTools", null);
|
|
488
|
+
__decorate([
|
|
489
|
+
(0, common_1.Post)('simulations/replay'),
|
|
490
|
+
__param(0, (0, common_1.Body)()),
|
|
491
|
+
__param(1, (0, common_1.Headers)('authorization')),
|
|
492
|
+
__param(2, (0, common_1.Headers)('x-canvas-flow-token')),
|
|
493
|
+
__param(3, (0, common_1.Headers)('x-api-key')),
|
|
494
|
+
__metadata("design:type", Function),
|
|
495
|
+
__metadata("design:paramtypes", [Object, String, String, String]),
|
|
496
|
+
__metadata("design:returntype", Promise)
|
|
497
|
+
], RunnerController.prototype, "replaySimulation", null);
|
|
498
|
+
__decorate([
|
|
499
|
+
(0, common_1.Post)('test/stream'),
|
|
500
|
+
__param(0, (0, common_1.Body)()),
|
|
501
|
+
__param(1, (0, common_1.Res)()),
|
|
502
|
+
__param(2, (0, common_1.Headers)('authorization')),
|
|
503
|
+
__param(3, (0, common_1.Headers)('x-canvas-flow-token')),
|
|
504
|
+
__param(4, (0, common_1.Headers)('x-api-key')),
|
|
505
|
+
__metadata("design:type", Function),
|
|
506
|
+
__metadata("design:paramtypes", [Object, Object, String, String, String]),
|
|
507
|
+
__metadata("design:returntype", Promise)
|
|
508
|
+
], RunnerController.prototype, "testStream", null);
|
|
509
|
+
__decorate([
|
|
510
|
+
(0, common_1.Post)('context/script/generate'),
|
|
511
|
+
__param(0, (0, common_1.Body)()),
|
|
512
|
+
__param(1, (0, common_1.Headers)('authorization')),
|
|
513
|
+
__param(2, (0, common_1.Headers)('x-canvas-flow-token')),
|
|
514
|
+
__param(3, (0, common_1.Headers)('x-api-key')),
|
|
515
|
+
__metadata("design:type", Function),
|
|
516
|
+
__metadata("design:paramtypes", [Object, String, String, String]),
|
|
517
|
+
__metadata("design:returntype", Promise)
|
|
518
|
+
], RunnerController.prototype, "generateContextScript", null);
|
|
519
|
+
__decorate([
|
|
520
|
+
(0, common_1.Post)('mongodb/config/generate'),
|
|
521
|
+
__param(0, (0, common_1.Body)()),
|
|
522
|
+
__param(1, (0, common_1.Headers)('authorization')),
|
|
523
|
+
__param(2, (0, common_1.Headers)('x-canvas-flow-token')),
|
|
524
|
+
__param(3, (0, common_1.Headers)('x-api-key')),
|
|
525
|
+
__metadata("design:type", Function),
|
|
526
|
+
__metadata("design:paramtypes", [Object, String, String, String]),
|
|
527
|
+
__metadata("design:returntype", Promise)
|
|
528
|
+
], RunnerController.prototype, "generateMongoConfig", null);
|
|
529
|
+
__decorate([
|
|
530
|
+
(0, common_1.Post)('assistant/generate-flow'),
|
|
531
|
+
__param(0, (0, common_1.Body)()),
|
|
532
|
+
__param(1, (0, common_1.Headers)('authorization')),
|
|
533
|
+
__param(2, (0, common_1.Headers)('x-canvas-flow-token')),
|
|
534
|
+
__param(3, (0, common_1.Headers)('x-api-key')),
|
|
535
|
+
__metadata("design:type", Function),
|
|
536
|
+
__metadata("design:paramtypes", [Object, String, String, String]),
|
|
537
|
+
__metadata("design:returntype", Promise)
|
|
538
|
+
], RunnerController.prototype, "generateFlowWithAssistant", null);
|
|
539
|
+
__decorate([
|
|
540
|
+
(0, common_1.Post)('prompt-field/generate'),
|
|
541
|
+
__param(0, (0, common_1.Body)()),
|
|
542
|
+
__param(1, (0, common_1.Headers)('authorization')),
|
|
543
|
+
__param(2, (0, common_1.Headers)('x-canvas-flow-token')),
|
|
544
|
+
__param(3, (0, common_1.Headers)('x-api-key')),
|
|
545
|
+
__metadata("design:type", Function),
|
|
546
|
+
__metadata("design:paramtypes", [Object, String, String, String]),
|
|
547
|
+
__metadata("design:returntype", Promise)
|
|
548
|
+
], RunnerController.prototype, "generatePromptField", null);
|
|
549
|
+
__decorate([
|
|
550
|
+
(0, common_1.Post)('whatsapp-flows'),
|
|
551
|
+
__param(0, (0, common_1.Body)()),
|
|
552
|
+
__param(1, (0, common_1.Headers)('authorization')),
|
|
553
|
+
__param(2, (0, common_1.Headers)('x-canvas-flow-token')),
|
|
554
|
+
__param(3, (0, common_1.Headers)('x-api-key')),
|
|
555
|
+
__metadata("design:type", Function),
|
|
556
|
+
__metadata("design:paramtypes", [Object, String, String, String]),
|
|
557
|
+
__metadata("design:returntype", Promise)
|
|
558
|
+
], RunnerController.prototype, "createWhatsappFlow", null);
|
|
559
|
+
__decorate([
|
|
560
|
+
(0, common_1.Post)('whatsapp-flows/list'),
|
|
561
|
+
__param(0, (0, common_1.Body)()),
|
|
562
|
+
__param(1, (0, common_1.Headers)('authorization')),
|
|
563
|
+
__param(2, (0, common_1.Headers)('x-canvas-flow-token')),
|
|
564
|
+
__param(3, (0, common_1.Headers)('x-api-key')),
|
|
565
|
+
__metadata("design:type", Function),
|
|
566
|
+
__metadata("design:paramtypes", [Object, String, String, String]),
|
|
567
|
+
__metadata("design:returntype", Promise)
|
|
568
|
+
], RunnerController.prototype, "listWhatsappFlows", null);
|
|
569
|
+
__decorate([
|
|
570
|
+
(0, common_1.Delete)('whatsapp-flows/:flowId'),
|
|
571
|
+
__param(0, (0, common_1.Param)('flowId')),
|
|
572
|
+
__param(1, (0, common_1.Body)()),
|
|
573
|
+
__param(2, (0, common_1.Headers)('authorization')),
|
|
574
|
+
__param(3, (0, common_1.Headers)('x-canvas-flow-token')),
|
|
575
|
+
__param(4, (0, common_1.Headers)('x-api-key')),
|
|
576
|
+
__metadata("design:type", Function),
|
|
577
|
+
__metadata("design:paramtypes", [String, Object, String, String, String]),
|
|
578
|
+
__metadata("design:returntype", Promise)
|
|
579
|
+
], RunnerController.prototype, "deleteWhatsappFlow", null);
|
|
580
|
+
__decorate([
|
|
581
|
+
(0, common_1.Post)('whatsapp-flows/:flowId/assets'),
|
|
582
|
+
__param(0, (0, common_1.Param)('flowId')),
|
|
583
|
+
__param(1, (0, common_1.Body)()),
|
|
584
|
+
__param(2, (0, common_1.Headers)('authorization')),
|
|
585
|
+
__param(3, (0, common_1.Headers)('x-canvas-flow-token')),
|
|
586
|
+
__param(4, (0, common_1.Headers)('x-api-key')),
|
|
587
|
+
__metadata("design:type", Function),
|
|
588
|
+
__metadata("design:paramtypes", [String, Object, String, String, String]),
|
|
589
|
+
__metadata("design:returntype", Promise)
|
|
590
|
+
], RunnerController.prototype, "uploadWhatsappFlowJson", null);
|
|
591
|
+
__decorate([
|
|
592
|
+
(0, common_1.Post)('whatsapp-flows/:flowId/publish'),
|
|
593
|
+
__param(0, (0, common_1.Param)('flowId')),
|
|
594
|
+
__param(1, (0, common_1.Body)()),
|
|
595
|
+
__param(2, (0, common_1.Headers)('authorization')),
|
|
596
|
+
__param(3, (0, common_1.Headers)('x-canvas-flow-token')),
|
|
597
|
+
__param(4, (0, common_1.Headers)('x-api-key')),
|
|
598
|
+
__metadata("design:type", Function),
|
|
599
|
+
__metadata("design:paramtypes", [String, Object, String, String, String]),
|
|
600
|
+
__metadata("design:returntype", Promise)
|
|
601
|
+
], RunnerController.prototype, "publishWhatsappFlow", null);
|
|
602
|
+
__decorate([
|
|
603
|
+
(0, common_1.Post)('tags/dashboard'),
|
|
604
|
+
__param(0, (0, common_1.Body)()),
|
|
605
|
+
__param(1, (0, common_1.Headers)('authorization')),
|
|
606
|
+
__param(2, (0, common_1.Headers)('x-canvas-flow-token')),
|
|
607
|
+
__param(3, (0, common_1.Headers)('x-api-key')),
|
|
608
|
+
__metadata("design:type", Function),
|
|
609
|
+
__metadata("design:paramtypes", [Object, String, String, String]),
|
|
610
|
+
__metadata("design:returntype", Promise)
|
|
611
|
+
], RunnerController.prototype, "tagDashboard", null);
|
|
612
|
+
__decorate([
|
|
613
|
+
(0, common_1.Post)('cron/run-due'),
|
|
614
|
+
__param(0, (0, common_1.Body)()),
|
|
615
|
+
__param(1, (0, common_1.Headers)('authorization')),
|
|
616
|
+
__param(2, (0, common_1.Headers)('x-canvas-flow-token')),
|
|
617
|
+
__param(3, (0, common_1.Headers)('x-api-key')),
|
|
618
|
+
__metadata("design:type", Function),
|
|
619
|
+
__metadata("design:paramtypes", [Object, String, String, String]),
|
|
620
|
+
__metadata("design:returntype", Promise)
|
|
621
|
+
], RunnerController.prototype, "runDueCron", null);
|
|
622
|
+
__decorate([
|
|
623
|
+
(0, common_1.Post)('sqs/consume'),
|
|
624
|
+
__param(0, (0, common_1.Body)()),
|
|
625
|
+
__param(1, (0, common_1.Headers)('authorization')),
|
|
626
|
+
__param(2, (0, common_1.Headers)('x-canvas-flow-token')),
|
|
627
|
+
__param(3, (0, common_1.Headers)('x-api-key')),
|
|
628
|
+
__metadata("design:type", Function),
|
|
629
|
+
__metadata("design:paramtypes", [Object, String, String, String]),
|
|
630
|
+
__metadata("design:returntype", Promise)
|
|
631
|
+
], RunnerController.prototype, "consumeSqsMessages", null);
|
|
632
|
+
__decorate([
|
|
633
|
+
(0, common_1.Get)('sqs/jobs/:jobId'),
|
|
634
|
+
__param(0, (0, common_1.Param)('jobId')),
|
|
635
|
+
__param(1, (0, common_1.Query)('agentId')),
|
|
636
|
+
__param(2, (0, common_1.Query)('flowId')),
|
|
637
|
+
__param(3, (0, common_1.Headers)('authorization')),
|
|
638
|
+
__param(4, (0, common_1.Headers)('x-canvas-flow-token')),
|
|
639
|
+
__param(5, (0, common_1.Headers)('x-api-key')),
|
|
640
|
+
__metadata("design:type", Function),
|
|
641
|
+
__metadata("design:paramtypes", [String, String, String, String, String, String]),
|
|
642
|
+
__metadata("design:returntype", Promise)
|
|
643
|
+
], RunnerController.prototype, "getSqsJob", null);
|
|
644
|
+
__decorate([
|
|
645
|
+
(0, common_1.Post)('sqs/jobs/:jobId/retry'),
|
|
646
|
+
__param(0, (0, common_1.Param)('jobId')),
|
|
647
|
+
__param(1, (0, common_1.Body)()),
|
|
648
|
+
__param(2, (0, common_1.Headers)('authorization')),
|
|
649
|
+
__param(3, (0, common_1.Headers)('x-canvas-flow-token')),
|
|
650
|
+
__param(4, (0, common_1.Headers)('x-api-key')),
|
|
651
|
+
__metadata("design:type", Function),
|
|
652
|
+
__metadata("design:paramtypes", [String, Object, String, String, String]),
|
|
653
|
+
__metadata("design:returntype", Promise)
|
|
654
|
+
], RunnerController.prototype, "retrySqsJob", null);
|
|
655
|
+
__decorate([
|
|
656
|
+
(0, common_1.Get)('sqs/health'),
|
|
657
|
+
__param(0, (0, common_1.Headers)('authorization')),
|
|
658
|
+
__param(1, (0, common_1.Headers)('x-canvas-flow-token')),
|
|
659
|
+
__param(2, (0, common_1.Headers)('x-api-key')),
|
|
660
|
+
__metadata("design:type", Function),
|
|
661
|
+
__metadata("design:paramtypes", [String, String, String]),
|
|
662
|
+
__metadata("design:returntype", Promise)
|
|
663
|
+
], RunnerController.prototype, "getSqsHealth", null);
|
|
664
|
+
__decorate([
|
|
665
|
+
(0, common_1.Get)('reports/:fileName'),
|
|
666
|
+
__param(0, (0, common_1.Param)('fileName')),
|
|
667
|
+
__param(1, (0, common_1.Res)()),
|
|
668
|
+
__metadata("design:type", Function),
|
|
669
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
670
|
+
__metadata("design:returntype", Promise)
|
|
671
|
+
], RunnerController.prototype, "getReport", null);
|
|
672
|
+
__decorate([
|
|
673
|
+
(0, common_1.Get)('whatsapp-media/:flowId/:mediaId'),
|
|
674
|
+
__param(0, (0, common_1.Param)('flowId')),
|
|
675
|
+
__param(1, (0, common_1.Param)('mediaId')),
|
|
676
|
+
__param(2, (0, common_1.Query)('exp')),
|
|
677
|
+
__param(3, (0, common_1.Query)('sig')),
|
|
678
|
+
__param(4, (0, common_1.Res)()),
|
|
679
|
+
__metadata("design:type", Function),
|
|
680
|
+
__metadata("design:paramtypes", [String, String, String, String, Object]),
|
|
681
|
+
__metadata("design:returntype", Promise)
|
|
682
|
+
], RunnerController.prototype, "getWhatsappMedia", null);
|
|
683
|
+
__decorate([
|
|
684
|
+
(0, common_1.Get)('webhook/custom/:flowId/:webhookId'),
|
|
685
|
+
__param(0, (0, common_1.Param)('flowId')),
|
|
686
|
+
__param(1, (0, common_1.Param)('webhookId')),
|
|
687
|
+
__param(2, (0, common_1.Query)()),
|
|
688
|
+
__param(3, (0, common_1.Headers)()),
|
|
689
|
+
__metadata("design:type", Function),
|
|
690
|
+
__metadata("design:paramtypes", [String, String, Object, Object]),
|
|
691
|
+
__metadata("design:returntype", Promise)
|
|
692
|
+
], RunnerController.prototype, "receiveCustomWebhookGet", null);
|
|
693
|
+
__decorate([
|
|
694
|
+
(0, common_1.Post)('webhook/custom/:flowId/:webhookId'),
|
|
695
|
+
__param(0, (0, common_1.Param)('flowId')),
|
|
696
|
+
__param(1, (0, common_1.Param)('webhookId')),
|
|
697
|
+
__param(2, (0, common_1.Body)()),
|
|
698
|
+
__param(3, (0, common_1.Query)()),
|
|
699
|
+
__param(4, (0, common_1.Headers)()),
|
|
700
|
+
__metadata("design:type", Function),
|
|
701
|
+
__metadata("design:paramtypes", [String, String, Object, Object, Object]),
|
|
702
|
+
__metadata("design:returntype", Promise)
|
|
703
|
+
], RunnerController.prototype, "receiveCustomWebhookPost", null);
|
|
704
|
+
__decorate([
|
|
705
|
+
(0, common_1.Get)('webhook/whatsapp/:flowId'),
|
|
706
|
+
__param(0, (0, common_1.Param)('flowId')),
|
|
707
|
+
__param(1, (0, common_1.Query)('hub.mode')),
|
|
708
|
+
__param(2, (0, common_1.Query)('hub.verify_token')),
|
|
709
|
+
__param(3, (0, common_1.Query)('hub.challenge')),
|
|
710
|
+
__param(4, (0, common_1.Res)()),
|
|
711
|
+
__metadata("design:type", Function),
|
|
712
|
+
__metadata("design:paramtypes", [String, String, String, String, Object]),
|
|
713
|
+
__metadata("design:returntype", Promise)
|
|
714
|
+
], RunnerController.prototype, "verifyWhatsappWebhook", null);
|
|
715
|
+
__decorate([
|
|
716
|
+
(0, common_1.Get)('webhook/whatsapp-main/:agentId'),
|
|
717
|
+
__param(0, (0, common_1.Param)('agentId')),
|
|
718
|
+
__param(1, (0, common_1.Query)('hub.mode')),
|
|
719
|
+
__param(2, (0, common_1.Query)('hub.verify_token')),
|
|
720
|
+
__param(3, (0, common_1.Query)('hub.challenge')),
|
|
721
|
+
__param(4, (0, common_1.Res)()),
|
|
722
|
+
__metadata("design:type", Function),
|
|
723
|
+
__metadata("design:paramtypes", [String, String, String, String, Object]),
|
|
724
|
+
__metadata("design:returntype", Promise)
|
|
725
|
+
], RunnerController.prototype, "verifyWhatsappMainWebhook", null);
|
|
726
|
+
__decorate([
|
|
727
|
+
(0, common_1.Post)('webhook/whatsapp/:flowId'),
|
|
728
|
+
__param(0, (0, common_1.Param)('flowId')),
|
|
729
|
+
__param(1, (0, common_1.Body)()),
|
|
730
|
+
__metadata("design:type", Function),
|
|
731
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
732
|
+
__metadata("design:returntype", Promise)
|
|
733
|
+
], RunnerController.prototype, "receiveWhatsappWebhook", null);
|
|
734
|
+
__decorate([
|
|
735
|
+
(0, common_1.Post)('webhook/whatsapp-main/:agentId'),
|
|
736
|
+
__param(0, (0, common_1.Param)('agentId')),
|
|
737
|
+
__param(1, (0, common_1.Body)()),
|
|
738
|
+
__metadata("design:type", Function),
|
|
739
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
740
|
+
__metadata("design:returntype", Promise)
|
|
741
|
+
], RunnerController.prototype, "receiveWhatsappMainWebhook", null);
|
|
742
|
+
exports.RunnerController = RunnerController = __decorate([
|
|
743
|
+
(0, swagger_1.ApiTags)('runner'),
|
|
744
|
+
(0, common_1.Controller)('api/canvas-flow'),
|
|
745
|
+
__metadata("design:paramtypes", [runner_service_1.RunnerService,
|
|
746
|
+
api_key_service_1.ApiKeyService,
|
|
747
|
+
auth_service_1.AuthService,
|
|
748
|
+
sqs_transition_service_1.SqsTransitionService,
|
|
749
|
+
runner_queue_processor_1.RunnerQueueProcessor])
|
|
750
|
+
], RunnerController);
|
|
751
|
+
//# sourceMappingURL=runner-controller.js.map
|