@runflow-ai/sdk 1.0.39 → 1.0.40
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/README.md +170 -80
- package/dist/connectors/connector-creator.d.ts +18 -8
- package/dist/connectors/connector-creator.d.ts.map +1 -1
- package/dist/connectors/connector-creator.js +268 -86
- package/dist/connectors/connector-creator.js.map +1 -1
- package/dist/connectors/index.d.ts +1 -1
- package/dist/connectors/index.d.ts.map +1 -1
- package/dist/connectors/index.js +2 -1
- package/dist/connectors/index.js.map +1 -1
- package/dist/core/agent.d.ts +6 -0
- package/dist/core/agent.d.ts.map +1 -1
- package/dist/core/agent.js +42 -0
- package/dist/core/agent.js.map +1 -1
- package/dist/core/api-client.d.ts +1 -1
- package/dist/core/api-client.d.ts.map +1 -1
- package/dist/core/api-client.js +12 -8
- package/dist/core/api-client.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/types/all-types.d.ts +8 -1
- package/dist/types/all-types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -2,125 +2,307 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.slack = exports.email = exports.twilio = exports.hubspot = void 0;
|
|
4
4
|
exports.createConnectorTool = createConnectorTool;
|
|
5
|
+
exports.loadConnector = loadConnector;
|
|
5
6
|
const zod_1 = require("zod");
|
|
6
7
|
const tool_creator_1 = require("../tools/tool-creator");
|
|
7
8
|
// ============================================================================
|
|
8
|
-
//
|
|
9
|
+
// CACHE GLOBAL DE SCHEMAS
|
|
9
10
|
// ============================================================================
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
const schemaCache = new Map();
|
|
12
|
+
// ============================================================================
|
|
13
|
+
// CREATE CONNECTOR TOOL (LAZY LOADING)
|
|
14
|
+
// ============================================================================
|
|
15
|
+
function createConnectorTool(config) {
|
|
16
|
+
const resourceKey = `${config.connector}.${config.resource}.${config.action}`;
|
|
17
|
+
// Create tool with temporary schema
|
|
18
|
+
const tool = (0, tool_creator_1.createTool)({
|
|
19
|
+
id: resourceKey,
|
|
20
|
+
description: config.description || `Execute ${config.action} on ${config.resource}`,
|
|
21
|
+
// Temporary schema (will be updated on lazy load)
|
|
22
|
+
inputSchema: zod_1.z.any(),
|
|
23
|
+
execute: async ({ context }) => {
|
|
24
|
+
// Execute connector
|
|
20
25
|
const { createRunflowAPIClient } = require('../core/api-client');
|
|
21
26
|
const api = createRunflowAPIClient();
|
|
22
|
-
|
|
27
|
+
const { useMock, ...params } = context;
|
|
28
|
+
const result = await api.connector(config.connector, config.resource, config.action, params, { useMock: useMock || false });
|
|
29
|
+
return result.data || result;
|
|
23
30
|
},
|
|
24
31
|
});
|
|
32
|
+
// Add metadata for identification and lazy loading
|
|
33
|
+
tool._isConnectorTool = true;
|
|
34
|
+
tool._connectorConfig = config;
|
|
35
|
+
tool._resourceKey = resourceKey;
|
|
36
|
+
// Lazy loading function
|
|
37
|
+
tool._loadSchema = async () => {
|
|
38
|
+
if (schemaCache.has(resourceKey)) {
|
|
39
|
+
// Already loaded, update tool
|
|
40
|
+
const cached = schemaCache.get(resourceKey);
|
|
41
|
+
tool.parameters = cached.parameters;
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
// Fetch schema from backend
|
|
46
|
+
const schema = await fetchResourceSchema(config);
|
|
47
|
+
// Convert to Zod
|
|
48
|
+
let inputSchema = jsonSchemaToZod(schema.inputSchema);
|
|
49
|
+
// Add useMock if enabled
|
|
50
|
+
if (config.enableMock && inputSchema instanceof zod_1.z.ZodObject) {
|
|
51
|
+
inputSchema = inputSchema.extend({
|
|
52
|
+
useMock: zod_1.z.boolean().optional().default(false),
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
// Convert to parameters (for LLM)
|
|
56
|
+
const parameters = zodToParameters(inputSchema);
|
|
57
|
+
// Cache
|
|
58
|
+
schemaCache.set(resourceKey, {
|
|
59
|
+
inputSchema,
|
|
60
|
+
outputSchema: schema.outputSchema ? jsonSchemaToZod(schema.outputSchema) : undefined,
|
|
61
|
+
parameters,
|
|
62
|
+
metadata: schema.metadata || {},
|
|
63
|
+
});
|
|
64
|
+
// Update tool with real parameters
|
|
65
|
+
tool.parameters = parameters;
|
|
66
|
+
// Update description if from backend
|
|
67
|
+
if (schema.metadata?.documentation) {
|
|
68
|
+
tool.description = schema.metadata.documentation;
|
|
69
|
+
}
|
|
70
|
+
console.log(`✅ Loaded schema for ${resourceKey}`);
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
74
|
+
console.error(`❌ Failed to load schema for ${resourceKey}:`, errorMessage);
|
|
75
|
+
// Fallback: generic parameters
|
|
76
|
+
tool.parameters = {
|
|
77
|
+
params: {
|
|
78
|
+
type: 'object',
|
|
79
|
+
description: 'Parameters for this connector',
|
|
80
|
+
required: false,
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
return tool;
|
|
25
86
|
}
|
|
26
87
|
// ============================================================================
|
|
27
|
-
//
|
|
88
|
+
// FETCH RESOURCE SCHEMA FROM BACKEND
|
|
28
89
|
// ============================================================================
|
|
29
|
-
function
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
90
|
+
async function fetchResourceSchema(config) {
|
|
91
|
+
const { createRunflowAPIClient } = require('../core/api-client');
|
|
92
|
+
const api = createRunflowAPIClient();
|
|
93
|
+
const baseUrl = api.baseUrl || process.env.RUNFLOW_API_URL || 'http://localhost:3001';
|
|
94
|
+
const apiKey = api.apiKey || process.env.RUNFLOW_API_KEY;
|
|
95
|
+
const tenantId = api.tenantId || process.env.RUNFLOW_TENANT_ID;
|
|
96
|
+
// For now, we'll use a simple endpoint structure
|
|
97
|
+
// In production, this should match your actual API structure
|
|
98
|
+
const resourceName = `${config.resource}.${config.action}`;
|
|
99
|
+
const response = await fetch(`${baseUrl}/api/v1/connectors/instances/by-name/${config.connector}/resources/${resourceName}/schema`, {
|
|
100
|
+
headers: {
|
|
101
|
+
'Content-Type': 'application/json',
|
|
102
|
+
'x-api-key': apiKey,
|
|
103
|
+
'x-runflow-tenant-id': tenantId,
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
if (!response.ok) {
|
|
107
|
+
throw new Error(`Failed to fetch schema: ${response.statusText}`);
|
|
33
108
|
}
|
|
34
|
-
return
|
|
109
|
+
return await response.json();
|
|
35
110
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
case 'string':
|
|
43
|
-
schema = zod_1.z.string();
|
|
44
|
-
break;
|
|
45
|
-
case 'number':
|
|
46
|
-
schema = zod_1.z.number();
|
|
47
|
-
break;
|
|
48
|
-
case 'boolean':
|
|
49
|
-
schema = zod_1.z.boolean();
|
|
50
|
-
break;
|
|
51
|
-
case 'email':
|
|
52
|
-
schema = zod_1.z.string().email();
|
|
53
|
-
break;
|
|
54
|
-
case 'url':
|
|
55
|
-
schema = zod_1.z.string().url();
|
|
56
|
-
break;
|
|
57
|
-
case 'date':
|
|
58
|
-
schema = zod_1.z.string().datetime();
|
|
59
|
-
break;
|
|
60
|
-
default:
|
|
61
|
-
schema = zod_1.z.string();
|
|
62
|
-
}
|
|
63
|
-
return isOptional ? schema.optional() : schema;
|
|
111
|
+
// ============================================================================
|
|
112
|
+
// CONVERT JSON SCHEMA TO ZOD
|
|
113
|
+
// ============================================================================
|
|
114
|
+
function jsonSchemaToZod(jsonSchema) {
|
|
115
|
+
if (!jsonSchema || jsonSchema.type !== 'object') {
|
|
116
|
+
return zod_1.z.any();
|
|
64
117
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
118
|
+
const shape = {};
|
|
119
|
+
const properties = jsonSchema.properties || {};
|
|
120
|
+
const required = jsonSchema.required || [];
|
|
121
|
+
Object.entries(properties).forEach(([key, prop]) => {
|
|
122
|
+
let fieldSchema = jsonSchemaFieldToZod(prop);
|
|
123
|
+
// Optional if not in required
|
|
124
|
+
if (!required.includes(key)) {
|
|
125
|
+
fieldSchema = fieldSchema.optional();
|
|
126
|
+
}
|
|
127
|
+
// Default
|
|
128
|
+
if (prop.default !== undefined) {
|
|
129
|
+
fieldSchema = fieldSchema.default(prop.default);
|
|
68
130
|
}
|
|
69
|
-
|
|
70
|
-
|
|
131
|
+
// Description
|
|
132
|
+
if (prop.description) {
|
|
133
|
+
fieldSchema = fieldSchema.describe(prop.description);
|
|
71
134
|
}
|
|
135
|
+
shape[key] = fieldSchema;
|
|
136
|
+
});
|
|
137
|
+
return zod_1.z.object(shape);
|
|
138
|
+
}
|
|
139
|
+
function jsonSchemaFieldToZod(prop) {
|
|
140
|
+
switch (prop.type) {
|
|
141
|
+
case 'string':
|
|
142
|
+
if (prop.format === 'email')
|
|
143
|
+
return zod_1.z.string().email();
|
|
144
|
+
if (prop.format === 'uri' || prop.format === 'url')
|
|
145
|
+
return zod_1.z.string().url();
|
|
146
|
+
if (prop.format === 'date-time')
|
|
147
|
+
return zod_1.z.string().datetime();
|
|
148
|
+
if (prop.enum)
|
|
149
|
+
return zod_1.z.enum(prop.enum);
|
|
150
|
+
return zod_1.z.string();
|
|
151
|
+
case 'number':
|
|
152
|
+
case 'integer':
|
|
153
|
+
let num = zod_1.z.number();
|
|
154
|
+
if (prop.minimum !== undefined)
|
|
155
|
+
num = num.min(prop.minimum);
|
|
156
|
+
if (prop.maximum !== undefined)
|
|
157
|
+
num = num.max(prop.maximum);
|
|
158
|
+
return num;
|
|
159
|
+
case 'boolean':
|
|
160
|
+
return zod_1.z.boolean();
|
|
161
|
+
case 'array':
|
|
162
|
+
const itemSchema = prop.items ? jsonSchemaFieldToZod(prop.items) : zod_1.z.any();
|
|
163
|
+
return zod_1.z.array(itemSchema);
|
|
164
|
+
case 'object':
|
|
165
|
+
return jsonSchemaToZod(prop);
|
|
166
|
+
default:
|
|
167
|
+
return zod_1.z.any();
|
|
72
168
|
}
|
|
73
|
-
return zod_1.z.string();
|
|
74
169
|
}
|
|
75
170
|
// ============================================================================
|
|
76
|
-
//
|
|
171
|
+
// CONVERT ZOD TO PARAMETERS (FOR LLM)
|
|
77
172
|
// ============================================================================
|
|
78
|
-
|
|
173
|
+
function zodToParameters(schema) {
|
|
174
|
+
// If not ZodObject, return generic
|
|
175
|
+
if (!(schema instanceof zod_1.z.ZodObject)) {
|
|
176
|
+
return {
|
|
177
|
+
input: {
|
|
178
|
+
type: 'string',
|
|
179
|
+
description: 'Input parameter',
|
|
180
|
+
required: true,
|
|
181
|
+
},
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
const shape = schema.shape;
|
|
185
|
+
const parameters = {};
|
|
186
|
+
Object.entries(shape).forEach(([key, fieldSchema]) => {
|
|
187
|
+
parameters[key] = zodFieldToParameter(fieldSchema);
|
|
188
|
+
});
|
|
189
|
+
return parameters;
|
|
190
|
+
}
|
|
191
|
+
function zodFieldToParameter(schema) {
|
|
192
|
+
// Detect base type (unwrap optional/default)
|
|
193
|
+
let baseSchema = schema;
|
|
194
|
+
let required = true;
|
|
195
|
+
let defaultValue = undefined;
|
|
196
|
+
if (schema instanceof zod_1.z.ZodOptional) {
|
|
197
|
+
required = false;
|
|
198
|
+
baseSchema = schema._def.innerType;
|
|
199
|
+
}
|
|
200
|
+
if (schema instanceof zod_1.z.ZodDefault) {
|
|
201
|
+
defaultValue = schema._def.defaultValue();
|
|
202
|
+
baseSchema = schema._def.innerType;
|
|
203
|
+
}
|
|
204
|
+
// Extract description
|
|
205
|
+
const description = schema._def?.description || '';
|
|
206
|
+
// Determine type
|
|
207
|
+
let type = 'string';
|
|
208
|
+
let enumValues;
|
|
209
|
+
if (baseSchema instanceof zod_1.z.ZodString) {
|
|
210
|
+
type = 'string';
|
|
211
|
+
}
|
|
212
|
+
else if (baseSchema instanceof zod_1.z.ZodNumber) {
|
|
213
|
+
type = 'number';
|
|
214
|
+
}
|
|
215
|
+
else if (baseSchema instanceof zod_1.z.ZodBoolean) {
|
|
216
|
+
type = 'boolean';
|
|
217
|
+
}
|
|
218
|
+
else if (baseSchema instanceof zod_1.z.ZodArray) {
|
|
219
|
+
type = 'array';
|
|
220
|
+
}
|
|
221
|
+
else if (baseSchema instanceof zod_1.z.ZodObject) {
|
|
222
|
+
type = 'object';
|
|
223
|
+
}
|
|
224
|
+
else if (baseSchema instanceof zod_1.z.ZodEnum) {
|
|
225
|
+
type = 'string';
|
|
226
|
+
enumValues = baseSchema._def.values;
|
|
227
|
+
}
|
|
228
|
+
const param = {
|
|
229
|
+
type,
|
|
230
|
+
description,
|
|
231
|
+
required,
|
|
232
|
+
};
|
|
233
|
+
if (defaultValue !== undefined) {
|
|
234
|
+
param.default = defaultValue;
|
|
235
|
+
}
|
|
236
|
+
if (enumValues) {
|
|
237
|
+
param.enum = enumValues;
|
|
238
|
+
}
|
|
239
|
+
return param;
|
|
240
|
+
}
|
|
241
|
+
// ============================================================================
|
|
242
|
+
// HELPER: LOAD CONNECTOR (discovers all resources)
|
|
243
|
+
// ============================================================================
|
|
244
|
+
function loadConnector(name) {
|
|
245
|
+
return {
|
|
246
|
+
// Returns proxy that creates tools on-demand
|
|
247
|
+
tool(resource, action) {
|
|
248
|
+
return createConnectorTool({
|
|
249
|
+
connector: name,
|
|
250
|
+
resource,
|
|
251
|
+
action,
|
|
252
|
+
enableMock: true,
|
|
253
|
+
});
|
|
254
|
+
},
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
// Legacy built-in shortcuts (kept for backwards compatibility)
|
|
79
258
|
exports.hubspot = {
|
|
80
|
-
createContact: () => createConnectorTool(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
phone: 'string?',
|
|
259
|
+
createContact: () => createConnectorTool({
|
|
260
|
+
connector: 'hubspot',
|
|
261
|
+
resource: 'contacts',
|
|
262
|
+
action: 'create',
|
|
263
|
+
enableMock: true,
|
|
86
264
|
}),
|
|
87
|
-
getContact: () => createConnectorTool(
|
|
88
|
-
|
|
265
|
+
getContact: () => createConnectorTool({
|
|
266
|
+
connector: 'hubspot',
|
|
267
|
+
resource: 'contacts',
|
|
268
|
+
action: 'get',
|
|
269
|
+
enableMock: true,
|
|
89
270
|
}),
|
|
90
|
-
createTicket: () => createConnectorTool(
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
271
|
+
createTicket: () => createConnectorTool({
|
|
272
|
+
connector: 'hubspot',
|
|
273
|
+
resource: 'tickets',
|
|
274
|
+
action: 'create',
|
|
275
|
+
enableMock: true,
|
|
95
276
|
}),
|
|
96
277
|
};
|
|
97
278
|
exports.twilio = {
|
|
98
|
-
sendWhatsApp: () => createConnectorTool(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
279
|
+
sendWhatsApp: () => createConnectorTool({
|
|
280
|
+
connector: 'twilio',
|
|
281
|
+
resource: 'messages',
|
|
282
|
+
action: 'send-whatsapp',
|
|
283
|
+
enableMock: true,
|
|
102
284
|
}),
|
|
103
|
-
sendSMS: () => createConnectorTool(
|
|
104
|
-
|
|
105
|
-
|
|
285
|
+
sendSMS: () => createConnectorTool({
|
|
286
|
+
connector: 'twilio',
|
|
287
|
+
resource: 'messages',
|
|
288
|
+
action: 'send-sms',
|
|
289
|
+
enableMock: true,
|
|
106
290
|
}),
|
|
107
291
|
};
|
|
108
292
|
exports.email = {
|
|
109
|
-
send: () => createConnectorTool(
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
cc: { array: 'email' },
|
|
115
|
-
bcc: { array: 'email' },
|
|
293
|
+
send: () => createConnectorTool({
|
|
294
|
+
connector: 'email',
|
|
295
|
+
resource: 'messages',
|
|
296
|
+
action: 'send',
|
|
297
|
+
enableMock: true,
|
|
116
298
|
}),
|
|
117
299
|
};
|
|
118
300
|
exports.slack = {
|
|
119
|
-
sendMessage: () => createConnectorTool(
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
301
|
+
sendMessage: () => createConnectorTool({
|
|
302
|
+
connector: 'slack',
|
|
303
|
+
resource: 'messages',
|
|
304
|
+
action: 'send',
|
|
305
|
+
enableMock: true,
|
|
124
306
|
}),
|
|
125
307
|
};
|
|
126
308
|
//# sourceMappingURL=connector-creator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connector-creator.js","sourceRoot":"","sources":["../../src/connectors/connector-creator.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"connector-creator.js","sourceRoot":"","sources":["../../src/connectors/connector-creator.ts"],"names":[],"mappings":";;;AAmBA,kDAqGC;AAiMD,sCAYC;AArUD,6BAAwB;AACxB,wDAAmD;AAGnD,+EAA+E;AAC/E,0BAA0B;AAC1B,+EAA+E;AAE/E,MAAM,WAAW,GAAG,IAAI,GAAG,EAKvB,CAAC;AAEL,+EAA+E;AAC/E,uCAAuC;AACvC,+EAA+E;AAE/E,SAAgB,mBAAmB,CAAC,MAMnC;IACC,MAAM,WAAW,GAAG,GAAG,MAAM,CAAC,SAAS,IAAI,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;IAE9E,oCAAoC;IACpC,MAAM,IAAI,GAAG,IAAA,yBAAU,EAAC;QACtB,EAAE,EAAE,WAAW;QACf,WAAW,EAAE,MAAM,CAAC,WAAW,IAAI,WAAW,MAAM,CAAC,MAAM,OAAO,MAAM,CAAC,QAAQ,EAAE;QAEnF,kDAAkD;QAClD,WAAW,EAAE,OAAC,CAAC,GAAG,EAAE;QAEpB,OAAO,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;YAC7B,oBAAoB;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,EAAE,SAAS;QACpB,QAAQ,EAAE,UAAU;QACpB,MAAM,EAAE,KAAK;QACb,UAAU,EAAE,IAAI;KACjB,CAAC;IAEF,YAAY,EAAE,GAAG,EAAE,CAAC,mBAAmB,CAAC;QACtC,SAAS,EAAE,SAAS;QACpB,QAAQ,EAAE,SAAS;QACnB,MAAM,EAAE,QAAQ;QAChB,UAAU,EAAE,IAAI;KACjB,CAAC;CACH,CAAC;AAEW,QAAA,MAAM,GAAG;IACpB,YAAY,EAAE,GAAG,EAAE,CAAC,mBAAmB,CAAC;QACtC,SAAS,EAAE,QAAQ;QACnB,QAAQ,EAAE,UAAU;QACpB,MAAM,EAAE,eAAe;QACvB,UAAU,EAAE,IAAI;KACjB,CAAC;IAEF,OAAO,EAAE,GAAG,EAAE,CAAC,mBAAmB,CAAC;QACjC,SAAS,EAAE,QAAQ;QACnB,QAAQ,EAAE,UAAU;QACpB,MAAM,EAAE,UAAU;QAClB,UAAU,EAAE,IAAI;KACjB,CAAC;CACH,CAAC;AAEW,QAAA,KAAK,GAAG;IACnB,IAAI,EAAE,GAAG,EAAE,CAAC,mBAAmB,CAAC;QAC9B,SAAS,EAAE,OAAO;QAClB,QAAQ,EAAE,UAAU;QACpB,MAAM,EAAE,MAAM;QACd,UAAU,EAAE,IAAI;KACjB,CAAC;CACH,CAAC;AAEW,QAAA,KAAK,GAAG;IACnB,WAAW,EAAE,GAAG,EAAE,CAAC,mBAAmB,CAAC;QACrC,SAAS,EAAE,OAAO;QAClB,QAAQ,EAAE,UAAU;QACpB,MAAM,EAAE,MAAM;QACd,UAAU,EAAE,IAAI;KACjB,CAAC;CACH,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { createConnectorTool, hubspot, twilio, email, slack, } from './connector-creator';
|
|
1
|
+
export { createConnectorTool, loadConnector, hubspot, twilio, email, slack, } from './connector-creator';
|
|
2
2
|
export type { ConnectorParameters, ConnectorParameter, ConnectorToolOptions } from './connector-creator';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/connectors/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,mBAAmB,EACnB,OAAO,EACP,MAAM,EACN,KAAK,EACL,KAAK,GACN,MAAM,qBAAqB,CAAC;AAG7B,YAAY,EACV,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACrB,MAAM,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/connectors/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,OAAO,EACP,MAAM,EACN,KAAK,EACL,KAAK,GACN,MAAM,qBAAqB,CAAC;AAG7B,YAAY,EACV,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACrB,MAAM,qBAAqB,CAAC"}
|
package/dist/connectors/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.slack = exports.email = exports.twilio = exports.hubspot = exports.createConnectorTool = void 0;
|
|
3
|
+
exports.slack = exports.email = exports.twilio = exports.hubspot = exports.loadConnector = exports.createConnectorTool = void 0;
|
|
4
4
|
// Connector exports
|
|
5
5
|
var connector_creator_1 = require("./connector-creator");
|
|
6
6
|
Object.defineProperty(exports, "createConnectorTool", { enumerable: true, get: function () { return connector_creator_1.createConnectorTool; } });
|
|
7
|
+
Object.defineProperty(exports, "loadConnector", { enumerable: true, get: function () { return connector_creator_1.loadConnector; } });
|
|
7
8
|
Object.defineProperty(exports, "hubspot", { enumerable: true, get: function () { return connector_creator_1.hubspot; } });
|
|
8
9
|
Object.defineProperty(exports, "twilio", { enumerable: true, get: function () { return connector_creator_1.twilio; } });
|
|
9
10
|
Object.defineProperty(exports, "email", { enumerable: true, get: function () { return connector_creator_1.email; } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/connectors/index.ts"],"names":[],"mappings":";;;AAAA,oBAAoB;AACpB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/connectors/index.ts"],"names":[],"mappings":";;;AAAA,oBAAoB;AACpB,yDAO6B;AAN3B,wHAAA,mBAAmB,OAAA;AACnB,kHAAA,aAAa,OAAA;AACb,4GAAA,OAAO,OAAA;AACP,2GAAA,MAAM,OAAA;AACN,0GAAA,KAAK,OAAA;AACL,0GAAA,KAAK,OAAA"}
|
package/dist/core/agent.d.ts
CHANGED
|
@@ -7,8 +7,14 @@ export declare class Agent {
|
|
|
7
7
|
private currentAgentSpanId?;
|
|
8
8
|
private currentLLMSpanId?;
|
|
9
9
|
private currentCompanyId?;
|
|
10
|
+
private connectorsInitialized;
|
|
10
11
|
constructor(config: AgentConfig);
|
|
11
12
|
_setAPIClient(apiClient: RunflowAPIClient): void;
|
|
13
|
+
/**
|
|
14
|
+
* Initialize connector tools (load schemas from backend)
|
|
15
|
+
* Called automatically on first run() or process()
|
|
16
|
+
*/
|
|
17
|
+
private initializeConnectorTools;
|
|
12
18
|
generate(input: string | Array<{
|
|
13
19
|
role: string;
|
|
14
20
|
content: string;
|
package/dist/core/agent.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/core/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AA4BpG,qBAAa,KAAK;IAChB,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,SAAS,CAAC,CAAmB;IACrC,OAAO,CAAC,cAAc,CAAC,CAAM;IAC7B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,kBAAkB,CAAC,CAAS;IACpC,OAAO,CAAC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AO,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,WAAW,CAAC;YA8UpE,iBAAiB;IAiD/B,OAAO,CAAC,gBAAgB;IAYxB;;OAEG;IACH,OAAO,CAAC,eAAe;IAqBvB,OAAO,CAAC,qBAAqB;IAI7B,OAAO,CAAC,mBAAmB;IAK3B,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,YAAY,IAAI,MAAM,CAEzB;IAED,IAAI,KAAK,qCAER;IAED,IAAI,KAAK,mDAER;IAED,IAAI,YAAY,IAAI,OAAO,CAE1B;IAGK,aAAa,CAAC,KAAK,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,aAAa,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CAyI5H"}
|
package/dist/core/agent.js
CHANGED
|
@@ -16,6 +16,7 @@ const observability_helpers_1 = require("./helpers/observability-helpers");
|
|
|
16
16
|
// ============================================================================
|
|
17
17
|
class Agent {
|
|
18
18
|
constructor(config) {
|
|
19
|
+
this.connectorsInitialized = false; // Track connector tools initialization
|
|
19
20
|
// Merge environment observability config
|
|
20
21
|
if (!config.observability && process.env.RUNFLOW_VERBOSE_TRACING === 'true') {
|
|
21
22
|
config.observability = 'full';
|
|
@@ -85,6 +86,43 @@ class Agent {
|
|
|
85
86
|
// Store in global for standalone functions
|
|
86
87
|
global.__runflowTraceCollector = this.traceCollector;
|
|
87
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* Initialize connector tools (load schemas from backend)
|
|
91
|
+
* Called automatically on first run() or process()
|
|
92
|
+
*/
|
|
93
|
+
async initializeConnectorTools() {
|
|
94
|
+
if (this.connectorsInitialized) {
|
|
95
|
+
return; // Already initialized
|
|
96
|
+
}
|
|
97
|
+
if (!this.config.tools) {
|
|
98
|
+
this.connectorsInitialized = true;
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
this.logger.debug('Initializing connector tools...');
|
|
102
|
+
const startTime = Date.now();
|
|
103
|
+
// Identify connector tools
|
|
104
|
+
const connectorTools = Object.entries(this.config.tools).filter(([_, tool]) => tool._isConnectorTool === true);
|
|
105
|
+
if (connectorTools.length === 0) {
|
|
106
|
+
this.logger.debug('No connector tools found, skipping initialization');
|
|
107
|
+
this.connectorsInitialized = true;
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
this.logger.debug(`Found ${connectorTools.length} connector tools to initialize`);
|
|
111
|
+
// Load schemas in parallel
|
|
112
|
+
await Promise.all(connectorTools.map(async ([toolName, tool]) => {
|
|
113
|
+
try {
|
|
114
|
+
await tool._loadSchema?.();
|
|
115
|
+
this.logger.debug(`✅ Schema loaded for ${toolName}`);
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
119
|
+
this.logger.warn(`⚠️ Failed to load schema for ${toolName}: ${errorMessage}`);
|
|
120
|
+
}
|
|
121
|
+
}));
|
|
122
|
+
const duration = Date.now() - startTime;
|
|
123
|
+
this.logger.info(`Connector tools initialized in ${duration}ms`);
|
|
124
|
+
this.connectorsInitialized = true;
|
|
125
|
+
}
|
|
88
126
|
// Geração simples (aceita string ou array de messages)
|
|
89
127
|
async generate(input) {
|
|
90
128
|
const isMessagesArray = Array.isArray(input);
|
|
@@ -446,6 +484,10 @@ class Agent {
|
|
|
446
484
|
const processStartTime = Date.now();
|
|
447
485
|
performance_logger_1.performanceLogger.start('agent.process');
|
|
448
486
|
// ============================================================================
|
|
487
|
+
// INITIALIZE CONNECTOR TOOLS (lazy load schemas)
|
|
488
|
+
// ============================================================================
|
|
489
|
+
await this.initializeConnectorTools();
|
|
490
|
+
// ============================================================================
|
|
449
491
|
// INICIAR TRACE IMEDIATAMENTE (captura TODO o tempo de processamento)
|
|
450
492
|
// ============================================================================
|
|
451
493
|
const span = this.traceCollector?.startSpan('agent_execution', {
|