@runflow-ai/sdk 1.0.61 β 1.0.63
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 +36 -35
- package/dist/connectors/connector-creator.d.ts +20 -2
- package/dist/connectors/connector-creator.d.ts.map +1 -1
- package/dist/connectors/connector-creator.js +100 -19
- package/dist/connectors/connector-creator.js.map +1 -1
- package/dist/connectors/connector-helper.d.ts +8 -12
- package/dist/connectors/connector-helper.d.ts.map +1 -1
- package/dist/connectors/connector-helper.js +9 -13
- package/dist/connectors/connector-helper.js.map +1 -1
- package/dist/core/agent.d.ts.map +1 -1
- package/dist/core/agent.js +62 -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 +1 -2
- package/dist/core/api-client.js.map +1 -1
- package/dist/observability/trace-collector.d.ts.map +1 -1
- package/dist/observability/trace-collector.js +52 -18
- package/dist/observability/trace-collector.js.map +1 -1
- package/dist/types/all-types.d.ts +1 -1
- package/dist/types/all-types.d.ts.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1053,16 +1053,18 @@ const result = await agent.process({
|
|
|
1053
1053
|
|
|
1054
1054
|
Use connectors as tools that the LLM can call automatically
|
|
1055
1055
|
|
|
1056
|
+
> **π‘ Resource Identifier:** Use the **resource slug** (e.g., `get-customers`, `list-users`) which is auto-generated from the resource name.
|
|
1057
|
+
> Slugs are stable, URL-safe identifiers that won't break if you rename the resource display name.
|
|
1058
|
+
|
|
1056
1059
|
```typescript
|
|
1057
1060
|
import { createConnectorTool, Agent, openai } from '@runflow-ai/sdk';
|
|
1058
1061
|
|
|
1059
1062
|
// Basic connector tool (schema loaded from backend)
|
|
1060
1063
|
const getClienteTool = createConnectorTool({
|
|
1061
|
-
connector: 'api-contabil',
|
|
1062
|
-
resource: '
|
|
1063
|
-
action: 'get',
|
|
1064
|
+
connector: 'api-contabil', // Connector instance slug
|
|
1065
|
+
resource: 'get-customers', // Resource slug
|
|
1064
1066
|
description: 'Get customer by ID from accounting API',
|
|
1065
|
-
enableMock: true,
|
|
1067
|
+
enableMock: true, // Optional: enables mock mode
|
|
1066
1068
|
});
|
|
1067
1069
|
|
|
1068
1070
|
// Use with Agent
|
|
@@ -1074,8 +1076,7 @@ const agent = new Agent({
|
|
|
1074
1076
|
getCliente: getClienteTool,
|
|
1075
1077
|
listClientes: createConnectorTool({
|
|
1076
1078
|
connector: 'api-contabil',
|
|
1077
|
-
resource: '
|
|
1078
|
-
action: 'list',
|
|
1079
|
+
resource: 'list-customers', // Resource slug
|
|
1079
1080
|
}),
|
|
1080
1081
|
},
|
|
1081
1082
|
});
|
|
@@ -1094,15 +1095,18 @@ const result = await agent.process({
|
|
|
1094
1095
|
|
|
1095
1096
|
Invoke connectors directly without agent involvement:
|
|
1096
1097
|
|
|
1098
|
+
> **π‘ Identifiers:**
|
|
1099
|
+
> - **Connector:** Use the instance **slug** (e.g., `hubspot-prod`) - recommended over display name
|
|
1100
|
+
> - **Resource:** Use the resource **slug** (e.g., `create-contact`) - auto-generated from resource name
|
|
1101
|
+
|
|
1097
1102
|
```typescript
|
|
1098
1103
|
import { connector } from '@runflow-ai/sdk/connectors';
|
|
1099
1104
|
import type { ConnectorExecutionOptions } from '@runflow-ai/sdk';
|
|
1100
1105
|
|
|
1101
|
-
// Direct connector call
|
|
1106
|
+
// Direct connector call (using slugs - recommended)
|
|
1102
1107
|
const result = await connector(
|
|
1103
|
-
'hubspot',
|
|
1104
|
-
'
|
|
1105
|
-
'create', // action
|
|
1108
|
+
'hubspot-prod', // connector instance slug
|
|
1109
|
+
'create-contact', // resource slug
|
|
1106
1110
|
{ // data
|
|
1107
1111
|
email: 'john@example.com',
|
|
1108
1112
|
firstname: 'John',
|
|
@@ -1125,8 +1129,7 @@ const options: ConnectorExecutionOptions = {
|
|
|
1125
1129
|
|
|
1126
1130
|
const result = await connector(
|
|
1127
1131
|
'api-contabil',
|
|
1128
|
-
'
|
|
1129
|
-
'get',
|
|
1132
|
+
'get-customer', // Resource slug
|
|
1130
1133
|
{ id: 123 },
|
|
1131
1134
|
options
|
|
1132
1135
|
);
|
|
@@ -1142,8 +1145,7 @@ async function createContactForCustomer(customerId: string, contactData: any) {
|
|
|
1142
1145
|
|
|
1143
1146
|
return await connector(
|
|
1144
1147
|
'hubspot',
|
|
1145
|
-
'
|
|
1146
|
-
'create',
|
|
1148
|
+
'create-contact', // Resource slug
|
|
1147
1149
|
contactData,
|
|
1148
1150
|
{ credentialId }
|
|
1149
1151
|
);
|
|
@@ -1160,8 +1162,7 @@ await createContactForCustomer('customer-2', { email: 'jane@techcorp.com' });
|
|
|
1160
1162
|
// Custom headers have HIGHEST priority
|
|
1161
1163
|
const result = await connector(
|
|
1162
1164
|
'hubspot',
|
|
1163
|
-
'
|
|
1164
|
-
'create',
|
|
1165
|
+
'create-contact', // Resource slug
|
|
1165
1166
|
{ email: 'test@example.com' },
|
|
1166
1167
|
{
|
|
1167
1168
|
headers: {
|
|
@@ -1185,14 +1186,18 @@ const result = await connector(
|
|
|
1185
1186
|
|
|
1186
1187
|
```typescript
|
|
1187
1188
|
createConnectorTool({
|
|
1188
|
-
connector: string,
|
|
1189
|
-
resource: string, // Resource
|
|
1190
|
-
action: string, // Action name (e.g., 'get', 'list', 'create', 'update')
|
|
1189
|
+
connector: string, // Connector instance slug (e.g., 'hubspot-prod', 'api-contabil')
|
|
1190
|
+
resource: string, // Resource slug (e.g., 'get-contacts', 'list-customers', 'create-ticket')
|
|
1191
1191
|
description?: string, // Optional: Custom description (defaults to auto-generated)
|
|
1192
1192
|
enableMock?: boolean, // Optional: Enable mock mode (adds useMock parameter)
|
|
1193
1193
|
})
|
|
1194
1194
|
```
|
|
1195
1195
|
|
|
1196
|
+
**Important Notes:**
|
|
1197
|
+
- **`connector`**: Use the instance slug (e.g., `hubspot-prod`) instead of display name
|
|
1198
|
+
- **`resource`**: Use the resource slug (e.g., `get-users`, `create-order`) - auto-generated from resource name
|
|
1199
|
+
- Resource lookup priority: **slug first** β name fallback (backward compatibility)
|
|
1200
|
+
|
|
1196
1201
|
#### Multiple Connector Tools
|
|
1197
1202
|
|
|
1198
1203
|
```typescript
|
|
@@ -1200,22 +1205,19 @@ createConnectorTool({
|
|
|
1200
1205
|
const tools = {
|
|
1201
1206
|
listClientes: createConnectorTool({
|
|
1202
1207
|
connector: 'api-contabil',
|
|
1203
|
-
resource: '
|
|
1204
|
-
action: 'list',
|
|
1208
|
+
resource: 'list-customers', // Resource slug
|
|
1205
1209
|
enableMock: true,
|
|
1206
1210
|
}),
|
|
1207
1211
|
|
|
1208
1212
|
getCliente: createConnectorTool({
|
|
1209
1213
|
connector: 'api-contabil',
|
|
1210
|
-
resource: '
|
|
1211
|
-
action: 'get',
|
|
1214
|
+
resource: 'get-customer', // Resource slug
|
|
1212
1215
|
enableMock: true,
|
|
1213
1216
|
}),
|
|
1214
1217
|
|
|
1215
1218
|
createCliente: createConnectorTool({
|
|
1216
1219
|
connector: 'api-contabil',
|
|
1217
|
-
resource: '
|
|
1218
|
-
action: 'create',
|
|
1220
|
+
resource: 'create-customer', // Resource slug
|
|
1219
1221
|
enableMock: true,
|
|
1220
1222
|
}),
|
|
1221
1223
|
};
|
|
@@ -1249,10 +1251,11 @@ const agent = new Agent({
|
|
|
1249
1251
|
instructions: 'You manage accounting data.',
|
|
1250
1252
|
model: openai('gpt-4o'),
|
|
1251
1253
|
tools: {
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1254
|
+
// Using resource slugs
|
|
1255
|
+
listClientes: contabil.tool('list-customers'),
|
|
1256
|
+
getCliente: contabil.tool('get-customer'),
|
|
1257
|
+
createCliente: contabil.tool('create-customer'),
|
|
1258
|
+
updateCliente: contabil.tool('update-customer'),
|
|
1256
1259
|
},
|
|
1257
1260
|
});
|
|
1258
1261
|
```
|
|
@@ -1262,11 +1265,10 @@ const agent = new Agent({
|
|
|
1262
1265
|
Connectors automatically resolve path parameters from the resource URL:
|
|
1263
1266
|
|
|
1264
1267
|
```typescript
|
|
1265
|
-
// Resource defined in backend: /clientes/{id}/pedidos/{pedidoId}
|
|
1268
|
+
// Resource defined in backend with path: /clientes/{id}/pedidos/{pedidoId}
|
|
1266
1269
|
const getClientePedidoTool = createConnectorTool({
|
|
1267
1270
|
connector: 'api-contabil',
|
|
1268
|
-
resource: '
|
|
1269
|
-
action: 'get',
|
|
1271
|
+
resource: 'get-customer-order', // Resource slug
|
|
1270
1272
|
description: 'Get specific order from a customer',
|
|
1271
1273
|
});
|
|
1272
1274
|
|
|
@@ -1287,9 +1289,8 @@ Enable mock mode for development and testing:
|
|
|
1287
1289
|
```typescript
|
|
1288
1290
|
const tool = createConnectorTool({
|
|
1289
1291
|
connector: 'api-contabil',
|
|
1290
|
-
resource: '
|
|
1291
|
-
|
|
1292
|
-
enableMock: true, // Adds useMock parameter
|
|
1292
|
+
resource: 'list-customers', // Resource slug
|
|
1293
|
+
enableMock: true, // Adds useMock parameter
|
|
1293
1294
|
});
|
|
1294
1295
|
|
|
1295
1296
|
// Use mock mode in development
|
|
@@ -1,14 +1,32 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { RunflowTool } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Create a connector tool for agent use with lazy schema loading
|
|
5
|
+
*
|
|
6
|
+
* @param config - Configuration object
|
|
7
|
+
* @param config.connector - Connector instance slug (e.g., 'hubspot-prod', 'json-placeholder')
|
|
8
|
+
* @param config.resource - Resource slug (e.g., 'get-users', 'create-contact', 'list-todos')
|
|
9
|
+
* @param config.description - Optional custom description
|
|
10
|
+
* @param config.enableMock - Optional: enable mock mode (adds useMock parameter)
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const getUsersTool = createConnectorTool({
|
|
15
|
+
* connector: 'json-placeholder-default', // Instance slug
|
|
16
|
+
* resource: 'get-users', // Resource slug
|
|
17
|
+
* description: 'Get all users from JSON Placeholder API',
|
|
18
|
+
* enableMock: true,
|
|
19
|
+
* });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
3
22
|
export declare function createConnectorTool(config: {
|
|
4
23
|
connector: string;
|
|
5
24
|
resource: string;
|
|
6
|
-
action: string;
|
|
7
25
|
description?: string;
|
|
8
26
|
enableMock?: boolean;
|
|
9
27
|
}): RunflowTool;
|
|
10
28
|
export declare function loadConnector(name: string): {
|
|
11
|
-
tool(resource: string
|
|
29
|
+
tool(resource: string): RunflowTool;
|
|
12
30
|
};
|
|
13
31
|
export type ConnectorParameters = Record<string, ConnectorParameter>;
|
|
14
32
|
export type ConnectorParameter = 'string' | 'string?' | 'number' | 'number?' | 'boolean' | 'boolean?' | 'email' | 'email?' | 'url' | 'url?' | 'date' | 'date?' | {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connector-creator.d.ts","sourceRoot":"","sources":["../../src/connectors/connector-creator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAiBvC,wBAAgB,mBAAmB,CAAC,MAAM,EAAE;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,
|
|
1
|
+
{"version":3,"file":"connector-creator.d.ts","sourceRoot":"","sources":["../../src/connectors/connector-creator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAiBvC;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,GAAG,WAAW,CA0Hd;AAiPD,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM;mBAGvB,MAAM;EAQxB;AAMD,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;AAErE,MAAM,MAAM,kBAAkB,GAC1B,QAAQ,GACR,SAAS,GACT,QAAQ,GACR,SAAS,GACT,SAAS,GACT,UAAU,GACV,OAAO,GACP,QAAQ,GACR,KAAK,GACL,MAAM,GACN,MAAM,GACN,OAAO,GACP;IAAE,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,GAClB;IAAE,KAAK,EAAE,kBAAkB,CAAA;CAAE,CAAC;AAElC,MAAM,WAAW,oBAAoB;IACnC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC;CAC5B"}
|
|
@@ -11,12 +11,32 @@ const schemaCache = new Map();
|
|
|
11
11
|
// ============================================================================
|
|
12
12
|
// CREATE CONNECTOR TOOL (LAZY LOADING)
|
|
13
13
|
// ============================================================================
|
|
14
|
+
/**
|
|
15
|
+
* Create a connector tool for agent use with lazy schema loading
|
|
16
|
+
*
|
|
17
|
+
* @param config - Configuration object
|
|
18
|
+
* @param config.connector - Connector instance slug (e.g., 'hubspot-prod', 'json-placeholder')
|
|
19
|
+
* @param config.resource - Resource slug (e.g., 'get-users', 'create-contact', 'list-todos')
|
|
20
|
+
* @param config.description - Optional custom description
|
|
21
|
+
* @param config.enableMock - Optional: enable mock mode (adds useMock parameter)
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* const getUsersTool = createConnectorTool({
|
|
26
|
+
* connector: 'json-placeholder-default', // Instance slug
|
|
27
|
+
* resource: 'get-users', // Resource slug
|
|
28
|
+
* description: 'Get all users from JSON Placeholder API',
|
|
29
|
+
* enableMock: true,
|
|
30
|
+
* });
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
14
33
|
function createConnectorTool(config) {
|
|
15
|
-
|
|
34
|
+
// Use double hyphen to separate connector and resource (OpenAI requires ^[a-zA-Z0-9_-]+$)
|
|
35
|
+
const resourceKey = `${config.connector}--${config.resource}`;
|
|
16
36
|
// Create tool with temporary schema
|
|
17
37
|
const tool = (0, tool_creator_1.createTool)({
|
|
18
38
|
id: resourceKey,
|
|
19
|
-
description: config.description || `Execute ${config.
|
|
39
|
+
description: config.description || `Execute ${config.resource} on ${config.connector}`,
|
|
20
40
|
// Temporary schema (will be updated on lazy load)
|
|
21
41
|
inputSchema: zod_1.z.any(),
|
|
22
42
|
execute: async ({ context }) => {
|
|
@@ -24,8 +44,24 @@ function createConnectorTool(config) {
|
|
|
24
44
|
const { createRunflowAPIClient } = require('../core/api-client');
|
|
25
45
|
const api = createRunflowAPIClient();
|
|
26
46
|
const { useMock, ...params } = context;
|
|
27
|
-
const result = await api.connector(config.connector, config.resource,
|
|
28
|
-
|
|
47
|
+
const result = await api.connector(config.connector, config.resource, params, { useMock: useMock || false });
|
|
48
|
+
// Format result for LLM with helpful context
|
|
49
|
+
if (result.success === false) {
|
|
50
|
+
return `Error executing ${config.resource}: ${result.metadata?.error || 'Unknown error'}`;
|
|
51
|
+
}
|
|
52
|
+
const data = result.data || result;
|
|
53
|
+
// Add helpful context for LLM
|
|
54
|
+
if (Array.isArray(data)) {
|
|
55
|
+
return {
|
|
56
|
+
summary: `Found ${data.length} result(s) from ${config.resource}`,
|
|
57
|
+
count: data.length,
|
|
58
|
+
data: data.slice(0, 10), // Limit to first 10 items to avoid token overflow
|
|
59
|
+
...(data.length > 10 && {
|
|
60
|
+
note: `Showing first 10 of ${data.length} results. Use filters to narrow down.`
|
|
61
|
+
})
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
return data;
|
|
29
65
|
},
|
|
30
66
|
});
|
|
31
67
|
// Add metadata for identification and lazy loading
|
|
@@ -43,8 +79,10 @@ function createConnectorTool(config) {
|
|
|
43
79
|
try {
|
|
44
80
|
// Fetch schema from backend
|
|
45
81
|
const schema = await fetchResourceSchema(config);
|
|
82
|
+
// Sanitize schema before converting (remove invalid properties)
|
|
83
|
+
const sanitizedSchema = sanitizeJSONSchema(schema.inputSchema);
|
|
46
84
|
// Convert to Zod
|
|
47
|
-
let inputSchema = jsonSchemaToZod(
|
|
85
|
+
let inputSchema = jsonSchemaToZod(sanitizedSchema);
|
|
48
86
|
// Add useMock if enabled
|
|
49
87
|
if (config.enableMock && inputSchema instanceof zod_1.z.ZodObject) {
|
|
50
88
|
inputSchema = inputSchema.extend({
|
|
@@ -71,14 +109,17 @@ function createConnectorTool(config) {
|
|
|
71
109
|
catch (error) {
|
|
72
110
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
73
111
|
console.error(`β Failed to load schema for ${resourceKey}:`, errorMessage);
|
|
74
|
-
//
|
|
75
|
-
tool.
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
112
|
+
// Mark tool as unavailable
|
|
113
|
+
tool.description = `[UNAVAILABLE] ${config.description || resourceKey}. ` +
|
|
114
|
+
`Resource '${config.resource}' not found in connector '${config.connector}'. ` +
|
|
115
|
+
`Error: ${errorMessage}. ` +
|
|
116
|
+
`Please verify the resource slug exists or create it first.`;
|
|
117
|
+
// Empty parameters - LLM should not use this tool
|
|
118
|
+
tool.parameters = {};
|
|
119
|
+
// Add metadata for debugging
|
|
120
|
+
tool._unavailable = true;
|
|
121
|
+
tool._errorMessage = errorMessage;
|
|
122
|
+
tool._loadError = error;
|
|
82
123
|
}
|
|
83
124
|
};
|
|
84
125
|
return tool;
|
|
@@ -92,10 +133,7 @@ async function fetchResourceSchema(config) {
|
|
|
92
133
|
const baseUrl = api.baseUrl || process.env.RUNFLOW_API_URL || 'http://localhost:3001';
|
|
93
134
|
const apiKey = api.apiKey || process.env.RUNFLOW_API_KEY;
|
|
94
135
|
const tenantId = api.tenantId || process.env.RUNFLOW_TENANT_ID;
|
|
95
|
-
|
|
96
|
-
// In production, this should match your actual API structure
|
|
97
|
-
const resourceName = `${config.resource}.${config.action}`;
|
|
98
|
-
const response = await fetch(`${baseUrl}/api/v1/runtime/v1/connectors/${config.connector}/resources/${resourceName}/schema`, {
|
|
136
|
+
const response = await fetch(`${baseUrl}/api/v1/runtime/v1/connectors/${config.connector}/resources/${config.resource}/schema`, {
|
|
99
137
|
headers: {
|
|
100
138
|
'Content-Type': 'application/json',
|
|
101
139
|
'x-api-key': apiKey,
|
|
@@ -108,6 +146,50 @@ async function fetchResourceSchema(config) {
|
|
|
108
146
|
return await response.json();
|
|
109
147
|
}
|
|
110
148
|
// ============================================================================
|
|
149
|
+
// SANITIZE JSON SCHEMA
|
|
150
|
+
// ============================================================================
|
|
151
|
+
/**
|
|
152
|
+
* Sanitize JSON Schema to remove invalid properties
|
|
153
|
+
* - Removes properties with empty names
|
|
154
|
+
* - Adds default items to arrays without items
|
|
155
|
+
* - Cleans up malformed schemas
|
|
156
|
+
*/
|
|
157
|
+
function sanitizeJSONSchema(jsonSchema) {
|
|
158
|
+
if (!jsonSchema || jsonSchema.type !== 'object') {
|
|
159
|
+
return jsonSchema;
|
|
160
|
+
}
|
|
161
|
+
const properties = jsonSchema.properties || {};
|
|
162
|
+
const cleanProperties = {};
|
|
163
|
+
// Clean properties
|
|
164
|
+
Object.entries(properties).forEach(([key, prop]) => {
|
|
165
|
+
// Skip properties with empty or whitespace-only names
|
|
166
|
+
if (!key || key.trim() === '') {
|
|
167
|
+
console.warn(`β οΈ [Schema Sanitizer] Skipping property with empty name`);
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
// Fix array properties missing items
|
|
171
|
+
if (prop.type === 'array' && !prop.items) {
|
|
172
|
+
console.warn(`β οΈ [Schema Sanitizer] Array property '${key}' missing items, adding default`);
|
|
173
|
+
prop = {
|
|
174
|
+
...prop,
|
|
175
|
+
items: { type: 'object', description: 'Array item' }
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
// Recursively sanitize nested objects
|
|
179
|
+
if (prop.type === 'object' && prop.properties) {
|
|
180
|
+
prop = {
|
|
181
|
+
...prop,
|
|
182
|
+
...sanitizeJSONSchema(prop)
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
cleanProperties[key] = prop;
|
|
186
|
+
});
|
|
187
|
+
return {
|
|
188
|
+
...jsonSchema,
|
|
189
|
+
properties: cleanProperties
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
// ============================================================================
|
|
111
193
|
// CONVERT JSON SCHEMA TO ZOD
|
|
112
194
|
// ============================================================================
|
|
113
195
|
function jsonSchemaToZod(jsonSchema) {
|
|
@@ -243,11 +325,10 @@ function zodFieldToParameter(schema) {
|
|
|
243
325
|
function loadConnector(name) {
|
|
244
326
|
return {
|
|
245
327
|
// Returns proxy that creates tools on-demand
|
|
246
|
-
tool(resource
|
|
328
|
+
tool(resource) {
|
|
247
329
|
return createConnectorTool({
|
|
248
330
|
connector: name,
|
|
249
331
|
resource,
|
|
250
|
-
action,
|
|
251
332
|
enableMock: true,
|
|
252
333
|
});
|
|
253
334
|
},
|
|
@@ -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":";;AAsCA,kDA+HC;AAiPD,sCAWC;AAjaD,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;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,mBAAmB,CAAC,MAKnC;IACC,0FAA0F;IAC1F,MAA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9C,IAAI,GAAG,SAAS,CAAC;IACnB,CAAC;SAAM,IAAI,UAAU,YAAY,OAAC,CAAC,QAAQ,EAAE,CAAC;QAC5C,IAAI,GAAG,OAAO,CAAC;IACjB,CAAC;SAAM,IAAI,UAAU,YAAY,OAAC,CAAC,SAAS,EAAE,CAAC;QAC7C,IAAI,GAAG,QAAQ,CAAC;IAClB,CAAC;SAAM,IAAI,UAAU,YAAY,OAAC,CAAC,OAAO,EAAE,CAAC;QAC3C,IAAI,GAAG,QAAQ,CAAC;QAChB,UAAU,GAAG,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC;IACtC,CAAC;IAED,MAAM,KAAK,GAAQ;QACjB,IAAI;QACJ,WAAW;QACX,QAAQ;KACT,CAAC;IAEF,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;QAC/B,KAAK,CAAC,OAAO,GAAG,YAAY,CAAC;IAC/B,CAAC;IAED,IAAI,UAAU,EAAE,CAAC;QACf,KAAK,CAAC,IAAI,GAAG,UAAU,CAAC;IAC1B,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED,+EAA+E;AAC/E,mDAAmD;AACnD,+EAA+E;AAE/E,SAAgB,aAAa,CAAC,IAAY;IACxC,OAAO;QACL,6CAA6C;QAC7C,IAAI,CAAC,QAAgB;YACnB,OAAO,mBAAmB,CAAC;gBACzB,SAAS,EAAE,IAAI;gBACf,QAAQ;gBACR,UAAU,EAAE,IAAI;aACjB,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -5,9 +5,8 @@ import type { ConnectorExecutionOptions } from '../types';
|
|
|
5
5
|
* Use this when you want to invoke a connector programmatically,
|
|
6
6
|
* without agent involvement. For agent tools, use createConnectorTool.
|
|
7
7
|
*
|
|
8
|
-
* @param connectorName - Connector instance
|
|
9
|
-
* @param resource - Resource
|
|
10
|
-
* @param action - Action name (e.g., 'get', 'list', 'create', 'update')
|
|
8
|
+
* @param connectorName - Connector instance slug (e.g., 'hubspot-prod', 'api-contabil')
|
|
9
|
+
* @param resource - Resource slug (e.g., 'create-contact', 'get-customer', 'list-users')
|
|
11
10
|
* @param data - Data to send to the connector
|
|
12
11
|
* @param options - Optional execution options (credentialId, timeout, headers, etc.)
|
|
13
12
|
*
|
|
@@ -17,17 +16,15 @@ import type { ConnectorExecutionOptions } from '../types';
|
|
|
17
16
|
*
|
|
18
17
|
* // Basic usage
|
|
19
18
|
* const result = await connector(
|
|
20
|
-
* 'hubspot',
|
|
21
|
-
* '
|
|
22
|
-
* 'create',
|
|
19
|
+
* 'hubspot-prod', // Connector instance slug
|
|
20
|
+
* 'create-contact', // Resource slug
|
|
23
21
|
* { email: 'john@example.com', firstname: 'John' }
|
|
24
22
|
* );
|
|
25
23
|
*
|
|
26
24
|
* // With credential override (multi-tenant)
|
|
27
25
|
* const result = await connector(
|
|
28
|
-
* 'hubspot',
|
|
29
|
-
* '
|
|
30
|
-
* 'create',
|
|
26
|
+
* 'hubspot-prod',
|
|
27
|
+
* 'create-contact',
|
|
31
28
|
* { email: 'jane@example.com' },
|
|
32
29
|
* { credentialId: 'cred-customerB' }
|
|
33
30
|
* );
|
|
@@ -35,8 +32,7 @@ import type { ConnectorExecutionOptions } from '../types';
|
|
|
35
32
|
* // With custom headers
|
|
36
33
|
* const result = await connector(
|
|
37
34
|
* 'api-contabil',
|
|
38
|
-
* '
|
|
39
|
-
* 'get',
|
|
35
|
+
* 'get-customer', // Resource slug
|
|
40
36
|
* { id: 123 },
|
|
41
37
|
* {
|
|
42
38
|
* headers: { 'X-API-Key': 'temp-key' },
|
|
@@ -45,5 +41,5 @@ import type { ConnectorExecutionOptions } from '../types';
|
|
|
45
41
|
* );
|
|
46
42
|
* ```
|
|
47
43
|
*/
|
|
48
|
-
export declare function connector(connectorName: string, resource: string,
|
|
44
|
+
export declare function connector(connectorName: string, resource: string, data: any, options?: ConnectorExecutionOptions): Promise<any>;
|
|
49
45
|
//# sourceMappingURL=connector-helper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connector-helper.d.ts","sourceRoot":"","sources":["../../src/connectors/connector-helper.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAE1D
|
|
1
|
+
{"version":3,"file":"connector-helper.d.ts","sourceRoot":"","sources":["../../src/connectors/connector-helper.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAsB,SAAS,CAC7B,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,GAAG,EACT,OAAO,CAAC,EAAE,yBAAyB,GAClC,OAAO,CAAC,GAAG,CAAC,CAGd"}
|
|
@@ -8,9 +8,8 @@ const api_client_1 = require("../core/api-client");
|
|
|
8
8
|
* Use this when you want to invoke a connector programmatically,
|
|
9
9
|
* without agent involvement. For agent tools, use createConnectorTool.
|
|
10
10
|
*
|
|
11
|
-
* @param connectorName - Connector instance
|
|
12
|
-
* @param resource - Resource
|
|
13
|
-
* @param action - Action name (e.g., 'get', 'list', 'create', 'update')
|
|
11
|
+
* @param connectorName - Connector instance slug (e.g., 'hubspot-prod', 'api-contabil')
|
|
12
|
+
* @param resource - Resource slug (e.g., 'create-contact', 'get-customer', 'list-users')
|
|
14
13
|
* @param data - Data to send to the connector
|
|
15
14
|
* @param options - Optional execution options (credentialId, timeout, headers, etc.)
|
|
16
15
|
*
|
|
@@ -20,17 +19,15 @@ const api_client_1 = require("../core/api-client");
|
|
|
20
19
|
*
|
|
21
20
|
* // Basic usage
|
|
22
21
|
* const result = await connector(
|
|
23
|
-
* 'hubspot',
|
|
24
|
-
* '
|
|
25
|
-
* 'create',
|
|
22
|
+
* 'hubspot-prod', // Connector instance slug
|
|
23
|
+
* 'create-contact', // Resource slug
|
|
26
24
|
* { email: 'john@example.com', firstname: 'John' }
|
|
27
25
|
* );
|
|
28
26
|
*
|
|
29
27
|
* // With credential override (multi-tenant)
|
|
30
28
|
* const result = await connector(
|
|
31
|
-
* 'hubspot',
|
|
32
|
-
* '
|
|
33
|
-
* 'create',
|
|
29
|
+
* 'hubspot-prod',
|
|
30
|
+
* 'create-contact',
|
|
34
31
|
* { email: 'jane@example.com' },
|
|
35
32
|
* { credentialId: 'cred-customerB' }
|
|
36
33
|
* );
|
|
@@ -38,8 +35,7 @@ const api_client_1 = require("../core/api-client");
|
|
|
38
35
|
* // With custom headers
|
|
39
36
|
* const result = await connector(
|
|
40
37
|
* 'api-contabil',
|
|
41
|
-
* '
|
|
42
|
-
* 'get',
|
|
38
|
+
* 'get-customer', // Resource slug
|
|
43
39
|
* { id: 123 },
|
|
44
40
|
* {
|
|
45
41
|
* headers: { 'X-API-Key': 'temp-key' },
|
|
@@ -48,8 +44,8 @@ const api_client_1 = require("../core/api-client");
|
|
|
48
44
|
* );
|
|
49
45
|
* ```
|
|
50
46
|
*/
|
|
51
|
-
async function connector(connectorName, resource,
|
|
47
|
+
async function connector(connectorName, resource, data, options) {
|
|
52
48
|
const api = (0, api_client_1.createRunflowAPIClient)();
|
|
53
|
-
return api.connector(connectorName, resource,
|
|
49
|
+
return api.connector(connectorName, resource, data, options);
|
|
54
50
|
}
|
|
55
51
|
//# sourceMappingURL=connector-helper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connector-helper.js","sourceRoot":"","sources":["../../src/connectors/connector-helper.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"connector-helper.js","sourceRoot":"","sources":["../../src/connectors/connector-helper.ts"],"names":[],"mappings":";;AA6CA,8BAQC;AArDD,mDAA4D;AAG5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACI,KAAK,UAAU,SAAS,CAC7B,aAAqB,EACrB,QAAgB,EAChB,IAAS,EACT,OAAmC;IAEnC,MAAM,GAAG,GAAG,IAAA,mCAAsB,GAAE,CAAC;IACrC,OAAO,GAAG,CAAC,SAAS,CAAC,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AAC/D,CAAC"}
|
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,WAAW,EAAmD,MAAM,UAAU,CAAC;AA4BlK,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,gBAAgB,CAAC,CAAS;IAClC,OAAO,CAAC,gBAAgB,CAAC,CAAS;IAClC,OAAO,CAAC,qBAAqB,CAAkB;gBAEnC,MAAM,EAAE,WAAW;IAsE/B,aAAa,CAAC,SAAS,EAAE,gBAAgB,GAAG,IAAI;IAyBhD;;;OAGG;YACW,wBAAwB;
|
|
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,WAAW,EAAmD,MAAM,UAAU,CAAC;AA4BlK,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,gBAAgB,CAAC,CA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CAAC,KAAK,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;CAogBxG"}
|
package/dist/core/agent.js
CHANGED
|
@@ -119,6 +119,17 @@ class Agent {
|
|
|
119
119
|
this.logger.warn(`β οΈ Failed to load schema for ${toolName}: ${errorMessage}`);
|
|
120
120
|
}
|
|
121
121
|
}));
|
|
122
|
+
// Filter out unavailable tools
|
|
123
|
+
const unavailableTools = connectorTools.filter(([_, tool]) => tool._unavailable === true);
|
|
124
|
+
if (unavailableTools.length > 0) {
|
|
125
|
+
this.logger.warn(`Removing ${unavailableTools.length} unavailable tool(s) from agent`);
|
|
126
|
+
unavailableTools.forEach(([toolName, _]) => {
|
|
127
|
+
if (this.config.tools) {
|
|
128
|
+
delete this.config.tools[toolName];
|
|
129
|
+
this.logger.debug(`Removed unavailable tool: ${toolName}`);
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
}
|
|
122
133
|
const duration = Date.now() - startTime;
|
|
123
134
|
this.logger.info(`Connector tools initialized in ${duration}ms`);
|
|
124
135
|
this.connectorsInitialized = true;
|
|
@@ -139,6 +150,26 @@ class Agent {
|
|
|
139
150
|
provider: this.config.model.provider,
|
|
140
151
|
model: this.config.model.model
|
|
141
152
|
});
|
|
153
|
+
// π Trace: LLM Call
|
|
154
|
+
const llmStartTime = Date.now();
|
|
155
|
+
const llmSpan = this.traceCollector?.startSpan('llm_call', {
|
|
156
|
+
provider: this.config.model.provider,
|
|
157
|
+
model: this.config.model.model,
|
|
158
|
+
hasTools: false,
|
|
159
|
+
toolsCount: 0,
|
|
160
|
+
}, this.getCurrentAgentSpanId());
|
|
161
|
+
// π Input do trace
|
|
162
|
+
const obsConfig = (0, observability_helpers_1.normalizeObservabilityConfig)(this.config.observability);
|
|
163
|
+
const verboseLLM = (0, observability_helpers_1.shouldUseVerbose)(obsConfig, 'llm');
|
|
164
|
+
llmSpan?.setInput(verboseLLM ? {
|
|
165
|
+
messages: (0, observability_helpers_1.truncateMessages)(messages, obsConfig.maxInputLength),
|
|
166
|
+
temperature: this.config.modelConfig?.temperature,
|
|
167
|
+
maxTokens: this.config.modelConfig?.maxTokens,
|
|
168
|
+
} : {
|
|
169
|
+
messagesCount: messages.length,
|
|
170
|
+
temperature: this.config.modelConfig?.temperature,
|
|
171
|
+
maxTokens: this.config.modelConfig?.maxTokens,
|
|
172
|
+
});
|
|
142
173
|
const chatRequest = {
|
|
143
174
|
projectId: '', // SerΓ‘ injetado pela engine
|
|
144
175
|
provider: this.config.model.provider,
|
|
@@ -155,6 +186,35 @@ class Agent {
|
|
|
155
186
|
};
|
|
156
187
|
try {
|
|
157
188
|
const response = await this.apiClient.chat(chatRequest);
|
|
189
|
+
// π Output do trace
|
|
190
|
+
llmSpan?.setOutput(verboseLLM ? {
|
|
191
|
+
text: (0, observability_helpers_1.truncateData)(response.text, obsConfig.maxOutputLength),
|
|
192
|
+
hasToolCalls: false,
|
|
193
|
+
toolCallsCount: 0,
|
|
194
|
+
} : {
|
|
195
|
+
responseLength: response.text?.length || 0,
|
|
196
|
+
hasToolCalls: false,
|
|
197
|
+
toolCallsCount: 0,
|
|
198
|
+
});
|
|
199
|
+
llmSpan?.setMetadata({
|
|
200
|
+
provider: this.config.model.provider,
|
|
201
|
+
model: this.config.model.model,
|
|
202
|
+
processingTimeMs: Date.now() - llmStartTime,
|
|
203
|
+
promptTokens: response.usage?.promptTokens,
|
|
204
|
+
completionTokens: response.usage?.completionTokens,
|
|
205
|
+
totalTokens: response.usage?.totalTokens,
|
|
206
|
+
success: true,
|
|
207
|
+
});
|
|
208
|
+
if (response.usage) {
|
|
209
|
+
llmSpan?.setCosts({
|
|
210
|
+
tokens: {
|
|
211
|
+
input: response.usage.promptTokens,
|
|
212
|
+
output: response.usage.completionTokens,
|
|
213
|
+
total: response.usage.totalTokens,
|
|
214
|
+
},
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
llmSpan?.finish();
|
|
158
218
|
this.logger.debug('Generation completed', {
|
|
159
219
|
responseLength: response.text?.length || 0,
|
|
160
220
|
usage: response.usage
|
|
@@ -162,6 +222,8 @@ class Agent {
|
|
|
162
222
|
return { text: response.text };
|
|
163
223
|
}
|
|
164
224
|
catch (error) {
|
|
225
|
+
llmSpan?.setMetadata({ success: false, error: error instanceof Error ? error.message : 'Unknown error' });
|
|
226
|
+
llmSpan?.finish();
|
|
165
227
|
this.logger.error('Chat API failed', {
|
|
166
228
|
error: error instanceof Error ? error.message : 'Unknown error'
|
|
167
229
|
});
|