@inkeep/agents-core 0.15.0 → 0.16.1
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/dist/{chunk-FLKAMXLV.js → chunk-L53XWAYG.js} +1 -1
- package/dist/chunk-R2EERZSW.js +223 -0
- package/dist/{chunk-FMCAYVO7.js → chunk-TO2HNKGP.js} +167 -10
- package/dist/{chunk-AHSEMW6N.js → chunk-VPJ6Z5QZ.js} +43 -7
- package/dist/client-exports.cjs +215 -21
- package/dist/client-exports.d.cts +16 -12
- package/dist/client-exports.d.ts +16 -12
- package/dist/client-exports.js +4 -10
- package/dist/db/schema.cjs +42 -6
- package/dist/db/schema.d.cts +2 -2
- package/dist/db/schema.d.ts +2 -2
- package/dist/db/schema.js +1 -1
- package/dist/index.cjs +3274 -2819
- package/dist/index.d.cts +365 -314
- package/dist/index.d.ts +365 -314
- package/dist/index.js +2519 -2494
- package/dist/props-validation-BMR1qNiy.d.cts +15 -0
- package/dist/props-validation-BMR1qNiy.d.ts +15 -0
- package/dist/{schema-D0E2bG9V.d.ts → schema-BtdvdyOA.d.ts} +253 -64
- package/dist/{schema-CTBfyt-o.d.cts → schema-DVnfWYwH.d.cts} +253 -64
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/{utility-BMAHFZX6.d.cts → utility-BaVsvScm.d.cts} +873 -326
- package/dist/{utility-BMAHFZX6.d.ts → utility-BaVsvScm.d.ts} +873 -326
- package/dist/utils/schema-conversion.cjs +236 -0
- package/dist/utils/schema-conversion.d.cts +26 -0
- package/dist/utils/schema-conversion.d.ts +26 -0
- package/dist/utils/schema-conversion.js +1 -0
- package/dist/validation/index.cjs +218 -14
- package/dist/validation/index.d.cts +3 -2
- package/dist/validation/index.d.ts +3 -2
- package/dist/validation/index.js +2 -2
- package/drizzle/0002_bumpy_romulus.sql +3 -0
- package/drizzle/0003_soft_forgotten_one.sql +39 -0
- package/drizzle/0004_melted_omega_flight.sql +3 -0
- package/drizzle/meta/0002_snapshot.json +2428 -0
- package/drizzle/meta/0003_snapshot.json +2559 -0
- package/drizzle/meta/0004_snapshot.json +2547 -0
- package/drizzle/meta/_journal.json +21 -0
- package/package.json +1 -1
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var zod = require('zod');
|
|
4
|
+
var pino = require('pino');
|
|
5
|
+
var pinoPretty = require('pino-pretty');
|
|
6
|
+
|
|
7
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
|
+
|
|
9
|
+
var pino__default = /*#__PURE__*/_interopDefault(pino);
|
|
10
|
+
var pinoPretty__default = /*#__PURE__*/_interopDefault(pinoPretty);
|
|
11
|
+
|
|
12
|
+
var __defProp = Object.defineProperty;
|
|
13
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
14
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
15
|
+
var PinoLogger = class {
|
|
16
|
+
constructor(name, config = {}) {
|
|
17
|
+
this.name = name;
|
|
18
|
+
__publicField(this, "transportConfigs", []);
|
|
19
|
+
__publicField(this, "pinoInstance");
|
|
20
|
+
__publicField(this, "options");
|
|
21
|
+
this.options = {
|
|
22
|
+
name: this.name,
|
|
23
|
+
level: process.env.LOG_LEVEL || (process.env.ENVIRONMENT === "test" ? "silent" : "info"),
|
|
24
|
+
serializers: {
|
|
25
|
+
obj: (value) => ({ ...value })
|
|
26
|
+
},
|
|
27
|
+
redact: ["req.headers.authorization", 'req.headers["x-inkeep-admin-authentication"]'],
|
|
28
|
+
...config.options
|
|
29
|
+
};
|
|
30
|
+
if (config.transportConfigs) {
|
|
31
|
+
this.transportConfigs = config.transportConfigs;
|
|
32
|
+
}
|
|
33
|
+
if (this.transportConfigs.length > 0) {
|
|
34
|
+
this.pinoInstance = pino__default.default(this.options, pino__default.default.transport({ targets: this.transportConfigs }));
|
|
35
|
+
} else {
|
|
36
|
+
try {
|
|
37
|
+
const prettyStream = pinoPretty__default.default({
|
|
38
|
+
colorize: true,
|
|
39
|
+
translateTime: "HH:MM:ss",
|
|
40
|
+
ignore: "pid,hostname"
|
|
41
|
+
});
|
|
42
|
+
this.pinoInstance = pino__default.default(this.options, prettyStream);
|
|
43
|
+
} catch (error) {
|
|
44
|
+
console.warn("Warning: pino-pretty failed, using standard JSON output:", error);
|
|
45
|
+
this.pinoInstance = pino__default.default(this.options);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Recreate the pino instance with current transports
|
|
51
|
+
*/
|
|
52
|
+
recreateInstance() {
|
|
53
|
+
if (this.pinoInstance && typeof this.pinoInstance.flush === "function") {
|
|
54
|
+
this.pinoInstance.flush();
|
|
55
|
+
}
|
|
56
|
+
if (this.transportConfigs.length === 0) {
|
|
57
|
+
try {
|
|
58
|
+
const prettyStream = pinoPretty__default.default({
|
|
59
|
+
colorize: true,
|
|
60
|
+
translateTime: "HH:MM:ss",
|
|
61
|
+
ignore: "pid,hostname"
|
|
62
|
+
});
|
|
63
|
+
this.pinoInstance = pino__default.default(this.options, prettyStream);
|
|
64
|
+
} catch (error) {
|
|
65
|
+
console.warn("Warning: pino-pretty failed, using standard JSON output:", error);
|
|
66
|
+
this.pinoInstance = pino__default.default(this.options);
|
|
67
|
+
}
|
|
68
|
+
} else {
|
|
69
|
+
const multiTransport = { targets: this.transportConfigs };
|
|
70
|
+
const pinoTransport = pino__default.default.transport(multiTransport);
|
|
71
|
+
this.pinoInstance = pino__default.default(this.options, pinoTransport);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Add a new transport to the logger
|
|
76
|
+
*/
|
|
77
|
+
addTransport(transportConfig) {
|
|
78
|
+
this.transportConfigs.push(transportConfig);
|
|
79
|
+
this.recreateInstance();
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Remove a transport by index
|
|
83
|
+
*/
|
|
84
|
+
removeTransport(index) {
|
|
85
|
+
if (index >= 0 && index < this.transportConfigs.length) {
|
|
86
|
+
this.transportConfigs.splice(index, 1);
|
|
87
|
+
this.recreateInstance();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Get current transports
|
|
92
|
+
*/
|
|
93
|
+
getTransports() {
|
|
94
|
+
return [...this.transportConfigs];
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Update logger options
|
|
98
|
+
*/
|
|
99
|
+
updateOptions(options) {
|
|
100
|
+
this.options = {
|
|
101
|
+
...this.options,
|
|
102
|
+
...options
|
|
103
|
+
};
|
|
104
|
+
this.recreateInstance();
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Get the underlying pino instance for advanced usage
|
|
108
|
+
*/
|
|
109
|
+
getPinoInstance() {
|
|
110
|
+
return this.pinoInstance;
|
|
111
|
+
}
|
|
112
|
+
error(data, message) {
|
|
113
|
+
this.pinoInstance.error(data, message);
|
|
114
|
+
}
|
|
115
|
+
warn(data, message) {
|
|
116
|
+
this.pinoInstance.warn(data, message);
|
|
117
|
+
}
|
|
118
|
+
info(data, message) {
|
|
119
|
+
this.pinoInstance.info(data, message);
|
|
120
|
+
}
|
|
121
|
+
debug(data, message) {
|
|
122
|
+
this.pinoInstance.debug(data, message);
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
var LoggerFactory = class {
|
|
126
|
+
constructor() {
|
|
127
|
+
__publicField(this, "config", {});
|
|
128
|
+
__publicField(this, "loggers", /* @__PURE__ */ new Map());
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Configure the logger factory
|
|
132
|
+
*/
|
|
133
|
+
configure(config) {
|
|
134
|
+
this.config = config;
|
|
135
|
+
this.loggers.clear();
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Get or create a logger instance
|
|
139
|
+
*/
|
|
140
|
+
getLogger(name) {
|
|
141
|
+
if (this.loggers.has(name)) {
|
|
142
|
+
const logger3 = this.loggers.get(name);
|
|
143
|
+
if (!logger3) {
|
|
144
|
+
throw new Error(`Logger '${name}' not found in cache`);
|
|
145
|
+
}
|
|
146
|
+
return logger3;
|
|
147
|
+
}
|
|
148
|
+
let logger2;
|
|
149
|
+
if (this.config.loggerFactory) {
|
|
150
|
+
logger2 = this.config.loggerFactory(name);
|
|
151
|
+
} else if (this.config.defaultLogger) {
|
|
152
|
+
logger2 = this.config.defaultLogger;
|
|
153
|
+
} else {
|
|
154
|
+
logger2 = new PinoLogger(name, this.config.pinoConfig);
|
|
155
|
+
}
|
|
156
|
+
this.loggers.set(name, logger2);
|
|
157
|
+
return logger2;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Reset factory to default state
|
|
161
|
+
*/
|
|
162
|
+
reset() {
|
|
163
|
+
this.config = {};
|
|
164
|
+
this.loggers.clear();
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
var loggerFactory = new LoggerFactory();
|
|
168
|
+
function getLogger(name) {
|
|
169
|
+
return loggerFactory.getLogger(name);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// src/utils/schema-conversion.ts
|
|
173
|
+
var logger = getLogger("schema-conversion");
|
|
174
|
+
function convertZodToJsonSchema(zodSchema) {
|
|
175
|
+
try {
|
|
176
|
+
const jsonSchema = zod.z.toJSONSchema(zodSchema);
|
|
177
|
+
if (jsonSchema.$schema) {
|
|
178
|
+
delete jsonSchema.$schema;
|
|
179
|
+
}
|
|
180
|
+
return jsonSchema;
|
|
181
|
+
} catch (error) {
|
|
182
|
+
logger.error(
|
|
183
|
+
{
|
|
184
|
+
error: error instanceof Error ? error.message : "Unknown error",
|
|
185
|
+
stack: error instanceof Error ? error.stack : void 0
|
|
186
|
+
},
|
|
187
|
+
"Failed to convert Zod schema to JSON Schema"
|
|
188
|
+
);
|
|
189
|
+
throw new Error("Failed to convert Zod schema to JSON Schema");
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
var preview = (schema) => {
|
|
193
|
+
schema._def.inPreview = true;
|
|
194
|
+
return schema;
|
|
195
|
+
};
|
|
196
|
+
function convertZodToJsonSchemaWithPreview(zodSchema) {
|
|
197
|
+
const jsonSchema = convertZodToJsonSchema(zodSchema);
|
|
198
|
+
if (zodSchema instanceof zod.z.ZodObject && jsonSchema.properties) {
|
|
199
|
+
const shape = zodSchema.shape;
|
|
200
|
+
for (const [key, fieldSchema] of Object.entries(shape)) {
|
|
201
|
+
if (fieldSchema?._def?.inPreview === true) {
|
|
202
|
+
jsonSchema.properties[key].inPreview = true;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return jsonSchema;
|
|
207
|
+
}
|
|
208
|
+
function isZodSchema(value) {
|
|
209
|
+
return value?._def?.type === "object";
|
|
210
|
+
}
|
|
211
|
+
function extractPreviewFields(schema) {
|
|
212
|
+
const previewFields = [];
|
|
213
|
+
if (schema instanceof zod.z.ZodObject) {
|
|
214
|
+
const shape = schema.shape;
|
|
215
|
+
for (const [key, fieldSchema] of Object.entries(shape)) {
|
|
216
|
+
if (fieldSchema?._def?.inPreview === true) {
|
|
217
|
+
previewFields.push(key);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return previewFields;
|
|
221
|
+
}
|
|
222
|
+
if (schema?.type === "object" && schema.properties) {
|
|
223
|
+
for (const [key, prop] of Object.entries(schema.properties)) {
|
|
224
|
+
if (prop.inPreview === true) {
|
|
225
|
+
previewFields.push(key);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return previewFields;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
exports.convertZodToJsonSchema = convertZodToJsonSchema;
|
|
233
|
+
exports.convertZodToJsonSchemaWithPreview = convertZodToJsonSchemaWithPreview;
|
|
234
|
+
exports.extractPreviewFields = extractPreviewFields;
|
|
235
|
+
exports.isZodSchema = isZodSchema;
|
|
236
|
+
exports.preview = preview;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Utility function for converting Zod schemas to JSON Schema
|
|
5
|
+
* Uses Zod's built-in toJSONSchema method
|
|
6
|
+
*/
|
|
7
|
+
declare function convertZodToJsonSchema(zodSchema: any): Record<string, unknown>;
|
|
8
|
+
/**
|
|
9
|
+
* Simple helper to mark a Zod schema field as a preview field
|
|
10
|
+
* Adds metadata to the schema definition without modifying Zod's core
|
|
11
|
+
*/
|
|
12
|
+
declare const preview: <T extends z.ZodTypeAny>(schema: T) => T;
|
|
13
|
+
/**
|
|
14
|
+
* Convert Zod schema to JSON Schema while preserving preview metadata
|
|
15
|
+
*/
|
|
16
|
+
declare function convertZodToJsonSchemaWithPreview(zodSchema: z.ZodTypeAny): Record<string, unknown>;
|
|
17
|
+
/**
|
|
18
|
+
* Type guard to check if a value is a Zod schema
|
|
19
|
+
*/
|
|
20
|
+
declare function isZodSchema(value: any): value is z.ZodObject<any>;
|
|
21
|
+
/**
|
|
22
|
+
* Extract preview fields from either JSON Schema or Zod schema
|
|
23
|
+
*/
|
|
24
|
+
declare function extractPreviewFields(schema: any): string[];
|
|
25
|
+
|
|
26
|
+
export { convertZodToJsonSchema, convertZodToJsonSchemaWithPreview, extractPreviewFields, isZodSchema, preview };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Utility function for converting Zod schemas to JSON Schema
|
|
5
|
+
* Uses Zod's built-in toJSONSchema method
|
|
6
|
+
*/
|
|
7
|
+
declare function convertZodToJsonSchema(zodSchema: any): Record<string, unknown>;
|
|
8
|
+
/**
|
|
9
|
+
* Simple helper to mark a Zod schema field as a preview field
|
|
10
|
+
* Adds metadata to the schema definition without modifying Zod's core
|
|
11
|
+
*/
|
|
12
|
+
declare const preview: <T extends z.ZodTypeAny>(schema: T) => T;
|
|
13
|
+
/**
|
|
14
|
+
* Convert Zod schema to JSON Schema while preserving preview metadata
|
|
15
|
+
*/
|
|
16
|
+
declare function convertZodToJsonSchemaWithPreview(zodSchema: z.ZodTypeAny): Record<string, unknown>;
|
|
17
|
+
/**
|
|
18
|
+
* Type guard to check if a value is a Zod schema
|
|
19
|
+
*/
|
|
20
|
+
declare function isZodSchema(value: any): value is z.ZodObject<any>;
|
|
21
|
+
/**
|
|
22
|
+
* Extract preview fields from either JSON Schema or Zod schema
|
|
23
|
+
*/
|
|
24
|
+
declare function extractPreviewFields(schema: any): string[];
|
|
25
|
+
|
|
26
|
+
export { convertZodToJsonSchema, convertZodToJsonSchemaWithPreview, extractPreviewFields, isZodSchema, preview };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { convertZodToJsonSchema, convertZodToJsonSchemaWithPreview, extractPreviewFields, isZodSchema, preview } from '../chunk-R2EERZSW.js';
|
|
@@ -4,6 +4,11 @@ var zodOpenapi = require('@hono/zod-openapi');
|
|
|
4
4
|
var drizzleZod = require('drizzle-zod');
|
|
5
5
|
var drizzleOrm = require('drizzle-orm');
|
|
6
6
|
var sqliteCore = require('drizzle-orm/sqlite-core');
|
|
7
|
+
var Ajv = require('ajv');
|
|
8
|
+
|
|
9
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
|
|
11
|
+
var Ajv__default = /*#__PURE__*/_interopDefault(Ajv);
|
|
7
12
|
|
|
8
13
|
// src/validation/schemas.ts
|
|
9
14
|
var tenantScoped = {
|
|
@@ -39,6 +44,8 @@ var projects = sqliteCore.sqliteTable(
|
|
|
39
44
|
models: sqliteCore.text("models", { mode: "json" }).$type(),
|
|
40
45
|
// Project-level stopWhen configuration that can be inherited by graphs and agents
|
|
41
46
|
stopWhen: sqliteCore.text("stop_when", { mode: "json" }).$type(),
|
|
47
|
+
// Project-level sandbox configuration for function execution
|
|
48
|
+
sandboxConfig: sqliteCore.text("sandbox_config", { mode: "json" }).$type(),
|
|
42
49
|
...timestamps
|
|
43
50
|
},
|
|
44
51
|
(table) => [sqliteCore.primaryKey({ columns: [table.tenantId, table.id] })]
|
|
@@ -76,9 +83,8 @@ var contextConfigs = sqliteCore.sqliteTable(
|
|
|
76
83
|
"context_configs",
|
|
77
84
|
{
|
|
78
85
|
...graphScoped,
|
|
79
|
-
...uiProperties,
|
|
80
86
|
// Developer-defined Zod schema for validating incoming request context
|
|
81
|
-
|
|
87
|
+
headersSchema: sqliteCore.blob("headers_schema", { mode: "json" }).$type(),
|
|
82
88
|
// Stores serialized Zod schema
|
|
83
89
|
// Object mapping template keys to fetch definitions that use request context data
|
|
84
90
|
contextVariables: sqliteCore.blob("context_variables", { mode: "json" }).$type(),
|
|
@@ -285,8 +291,7 @@ var artifactComponents = sqliteCore.sqliteTable(
|
|
|
285
291
|
{
|
|
286
292
|
...projectScoped,
|
|
287
293
|
...uiProperties,
|
|
288
|
-
|
|
289
|
-
fullProps: sqliteCore.blob("full_props", { mode: "json" }).$type(),
|
|
294
|
+
props: sqliteCore.blob("props", { mode: "json" }).$type(),
|
|
290
295
|
...timestamps
|
|
291
296
|
},
|
|
292
297
|
(table) => [
|
|
@@ -332,13 +337,16 @@ var tools = sqliteCore.sqliteTable(
|
|
|
332
337
|
{
|
|
333
338
|
...projectScoped,
|
|
334
339
|
name: sqliteCore.text("name").notNull(),
|
|
335
|
-
|
|
340
|
+
description: sqliteCore.text("description"),
|
|
341
|
+
// Tool configuration - supports both MCP and function tools
|
|
336
342
|
config: sqliteCore.blob("config", { mode: "json" }).$type().notNull(),
|
|
343
|
+
// For function tools, reference the global functions table
|
|
344
|
+
functionId: sqliteCore.text("function_id"),
|
|
337
345
|
credentialReferenceId: sqliteCore.text("credential_reference_id"),
|
|
338
346
|
headers: sqliteCore.blob("headers", { mode: "json" }).$type(),
|
|
339
347
|
// Image URL for custom tool icon (supports regular URLs and base64 encoded images)
|
|
340
348
|
imageUrl: sqliteCore.text("image_url"),
|
|
341
|
-
// Server capabilities and status
|
|
349
|
+
// Server capabilities and status (only for MCP tools)
|
|
342
350
|
capabilities: sqliteCore.blob("capabilities", { mode: "json" }).$type(),
|
|
343
351
|
lastError: sqliteCore.text("last_error"),
|
|
344
352
|
...timestamps
|
|
@@ -349,6 +357,30 @@ var tools = sqliteCore.sqliteTable(
|
|
|
349
357
|
columns: [table.tenantId, table.projectId],
|
|
350
358
|
foreignColumns: [projects.tenantId, projects.id],
|
|
351
359
|
name: "tools_project_fk"
|
|
360
|
+
}).onDelete("cascade"),
|
|
361
|
+
// Foreign key constraint to functions table (for function tools)
|
|
362
|
+
sqliteCore.foreignKey({
|
|
363
|
+
columns: [table.tenantId, table.projectId, table.functionId],
|
|
364
|
+
foreignColumns: [functions.tenantId, functions.projectId, functions.id],
|
|
365
|
+
name: "tools_function_fk"
|
|
366
|
+
}).onDelete("cascade")
|
|
367
|
+
]
|
|
368
|
+
);
|
|
369
|
+
var functions = sqliteCore.sqliteTable(
|
|
370
|
+
"functions",
|
|
371
|
+
{
|
|
372
|
+
...projectScoped,
|
|
373
|
+
inputSchema: sqliteCore.blob("input_schema", { mode: "json" }).$type(),
|
|
374
|
+
executeCode: sqliteCore.text("execute_code").notNull(),
|
|
375
|
+
dependencies: sqliteCore.blob("dependencies", { mode: "json" }).$type(),
|
|
376
|
+
...timestamps
|
|
377
|
+
},
|
|
378
|
+
(table) => [
|
|
379
|
+
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
380
|
+
sqliteCore.foreignKey({
|
|
381
|
+
columns: [table.tenantId, table.projectId],
|
|
382
|
+
foreignColumns: [projects.tenantId, projects.id],
|
|
383
|
+
name: "functions_project_fk"
|
|
352
384
|
}).onDelete("cascade")
|
|
353
385
|
]
|
|
354
386
|
);
|
|
@@ -683,6 +715,10 @@ drizzleOrm.relations(tools, ({ one, many }) => ({
|
|
|
683
715
|
credentialReference: one(credentialReferences, {
|
|
684
716
|
fields: [tools.credentialReferenceId],
|
|
685
717
|
references: [credentialReferences.id]
|
|
718
|
+
}),
|
|
719
|
+
function: one(functions, {
|
|
720
|
+
fields: [tools.functionId],
|
|
721
|
+
references: [functions.id]
|
|
686
722
|
})
|
|
687
723
|
}));
|
|
688
724
|
drizzleOrm.relations(conversations, ({ one, many }) => ({
|
|
@@ -780,6 +816,9 @@ drizzleOrm.relations(ledgerArtifacts, ({ one }) => ({
|
|
|
780
816
|
references: [tasks.id]
|
|
781
817
|
})
|
|
782
818
|
}));
|
|
819
|
+
drizzleOrm.relations(functions, ({ many }) => ({
|
|
820
|
+
tools: many(tools)
|
|
821
|
+
}));
|
|
783
822
|
drizzleOrm.relations(agentRelations, ({ one }) => ({
|
|
784
823
|
graph: one(agentGraph, {
|
|
785
824
|
fields: [agentRelations.graphId],
|
|
@@ -848,6 +887,19 @@ var ProjectModelSchema = zodOpenapi.z.object({
|
|
|
848
887
|
structuredOutput: ModelSettingsSchema.optional(),
|
|
849
888
|
summarizer: ModelSettingsSchema.optional()
|
|
850
889
|
});
|
|
890
|
+
var SandboxConfigSchema = zodOpenapi.z.object({
|
|
891
|
+
provider: zodOpenapi.z.enum(["vercel", "local"]),
|
|
892
|
+
runtime: zodOpenapi.z.enum(["node22", "typescript"]),
|
|
893
|
+
timeout: zodOpenapi.z.number().min(1e3).max(3e5).optional(),
|
|
894
|
+
vcpus: zodOpenapi.z.number().min(1).max(8).optional()
|
|
895
|
+
});
|
|
896
|
+
var FunctionToolConfigSchema = zodOpenapi.z.object({
|
|
897
|
+
name: zodOpenapi.z.string(),
|
|
898
|
+
description: zodOpenapi.z.string(),
|
|
899
|
+
inputSchema: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.unknown()),
|
|
900
|
+
dependencies: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.string()).optional(),
|
|
901
|
+
execute: zodOpenapi.z.union([zodOpenapi.z.function(), zodOpenapi.z.string()])
|
|
902
|
+
});
|
|
851
903
|
var createApiSchema = (schema) => schema.omit({ tenantId: true, projectId: true });
|
|
852
904
|
var createApiInsertSchema = (schema) => schema.omit({ tenantId: true, projectId: true });
|
|
853
905
|
var createApiUpdateSchema = (schema) => schema.omit({ tenantId: true, projectId: true }).partial();
|
|
@@ -984,7 +1036,33 @@ var McpToolDefinitionSchema = zodOpenapi.z.object({
|
|
|
984
1036
|
var ToolSelectSchema = drizzleZod.createSelectSchema(tools);
|
|
985
1037
|
var ToolInsertSchema = drizzleZod.createInsertSchema(tools).extend({
|
|
986
1038
|
id: resourceIdSchema,
|
|
987
|
-
imageUrl: imageUrlSchema
|
|
1039
|
+
imageUrl: imageUrlSchema,
|
|
1040
|
+
functionId: resourceIdSchema.optional(),
|
|
1041
|
+
// For function tools, reference to global functions table
|
|
1042
|
+
config: zodOpenapi.z.discriminatedUnion("type", [
|
|
1043
|
+
// MCP tools
|
|
1044
|
+
zodOpenapi.z.object({
|
|
1045
|
+
type: zodOpenapi.z.literal("mcp"),
|
|
1046
|
+
mcp: zodOpenapi.z.object({
|
|
1047
|
+
server: zodOpenapi.z.object({
|
|
1048
|
+
url: zodOpenapi.z.string().url()
|
|
1049
|
+
}),
|
|
1050
|
+
transport: zodOpenapi.z.object({
|
|
1051
|
+
type: zodOpenapi.z.enum(MCPTransportType),
|
|
1052
|
+
requestInit: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.unknown()).optional(),
|
|
1053
|
+
eventSourceInit: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.unknown()).optional(),
|
|
1054
|
+
reconnectionOptions: zodOpenapi.z.custom().optional(),
|
|
1055
|
+
sessionId: zodOpenapi.z.string().optional()
|
|
1056
|
+
}).optional(),
|
|
1057
|
+
activeTools: zodOpenapi.z.array(zodOpenapi.z.string()).optional()
|
|
1058
|
+
})
|
|
1059
|
+
}),
|
|
1060
|
+
// Function tools (reference-only, no inline duplication)
|
|
1061
|
+
zodOpenapi.z.object({
|
|
1062
|
+
type: zodOpenapi.z.literal("function")
|
|
1063
|
+
// No inline function details - they're in the functions table via functionId
|
|
1064
|
+
})
|
|
1065
|
+
])
|
|
988
1066
|
});
|
|
989
1067
|
var ConversationSelectSchema = drizzleZod.createSelectSchema(conversations);
|
|
990
1068
|
var ConversationInsertSchema = drizzleZod.createInsertSchema(conversations).extend({
|
|
@@ -1194,6 +1272,14 @@ var ToolUpdateSchema = ToolInsertSchema.partial();
|
|
|
1194
1272
|
var ToolApiSelectSchema = createApiSchema(ToolSelectSchema);
|
|
1195
1273
|
var ToolApiInsertSchema = createApiInsertSchema(ToolInsertSchema);
|
|
1196
1274
|
var ToolApiUpdateSchema = createApiUpdateSchema(ToolUpdateSchema);
|
|
1275
|
+
var FunctionSelectSchema = drizzleZod.createSelectSchema(functions);
|
|
1276
|
+
var FunctionInsertSchema = drizzleZod.createInsertSchema(functions).extend({
|
|
1277
|
+
id: resourceIdSchema
|
|
1278
|
+
});
|
|
1279
|
+
var FunctionUpdateSchema = FunctionInsertSchema.partial();
|
|
1280
|
+
var FunctionApiSelectSchema = createApiSchema(FunctionSelectSchema);
|
|
1281
|
+
var FunctionApiInsertSchema = createApiInsertSchema(FunctionInsertSchema);
|
|
1282
|
+
var FunctionApiUpdateSchema = createApiUpdateSchema(FunctionUpdateSchema);
|
|
1197
1283
|
var FetchConfigSchema = zodOpenapi.z.object({
|
|
1198
1284
|
url: zodOpenapi.z.string().min(1, "URL is required"),
|
|
1199
1285
|
method: zodOpenapi.z.enum(["GET", "POST", "PUT", "DELETE", "PATCH"]).optional().default("GET"),
|
|
@@ -1214,11 +1300,11 @@ var FetchDefinitionSchema = zodOpenapi.z.object({
|
|
|
1214
1300
|
credential: CredentialReferenceApiInsertSchema.optional()
|
|
1215
1301
|
});
|
|
1216
1302
|
var ContextConfigSelectSchema = drizzleZod.createSelectSchema(contextConfigs).extend({
|
|
1217
|
-
|
|
1303
|
+
headersSchema: zodOpenapi.z.unknown().optional()
|
|
1218
1304
|
});
|
|
1219
1305
|
var ContextConfigInsertSchema = drizzleZod.createInsertSchema(contextConfigs).extend({
|
|
1220
|
-
id: resourceIdSchema,
|
|
1221
|
-
|
|
1306
|
+
id: resourceIdSchema.optional(),
|
|
1307
|
+
headersSchema: zodOpenapi.z.unknown().optional()
|
|
1222
1308
|
}).omit({
|
|
1223
1309
|
createdAt: true,
|
|
1224
1310
|
updatedAt: true
|
|
@@ -1282,6 +1368,7 @@ var CanUseItemSchema = zodOpenapi.z.object({
|
|
|
1282
1368
|
var FullGraphAgentInsertSchema = AgentApiInsertSchema.extend({
|
|
1283
1369
|
type: zodOpenapi.z.literal("internal"),
|
|
1284
1370
|
canUse: zodOpenapi.z.array(CanUseItemSchema),
|
|
1371
|
+
// All tools (both MCP and function tools)
|
|
1285
1372
|
dataComponents: zodOpenapi.z.array(zodOpenapi.z.string()).optional(),
|
|
1286
1373
|
artifactComponents: zodOpenapi.z.array(zodOpenapi.z.string()).optional(),
|
|
1287
1374
|
canTransferTo: zodOpenapi.z.array(zodOpenapi.z.string()).optional(),
|
|
@@ -1289,9 +1376,11 @@ var FullGraphAgentInsertSchema = AgentApiInsertSchema.extend({
|
|
|
1289
1376
|
});
|
|
1290
1377
|
var FullGraphDefinitionSchema = AgentGraphApiInsertSchema.extend({
|
|
1291
1378
|
agents: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.union([FullGraphAgentInsertSchema, ExternalAgentApiInsertSchema])),
|
|
1292
|
-
//
|
|
1293
|
-
|
|
1294
|
-
//
|
|
1379
|
+
// Lookup maps for UI to resolve canUse items
|
|
1380
|
+
tools: zodOpenapi.z.record(zodOpenapi.z.string(), ToolApiInsertSchema).optional(),
|
|
1381
|
+
// Get tool name/description from toolId
|
|
1382
|
+
functions: zodOpenapi.z.record(zodOpenapi.z.string(), FunctionApiInsertSchema).optional(),
|
|
1383
|
+
// Get function code for function tools
|
|
1295
1384
|
contextConfig: zodOpenapi.z.optional(ContextConfigApiInsertSchema),
|
|
1296
1385
|
statusUpdates: zodOpenapi.z.optional(StatusUpdateSchema),
|
|
1297
1386
|
models: ModelSchema.optional(),
|
|
@@ -1340,7 +1429,8 @@ var RemovedResponseSchema = zodOpenapi.z.object({
|
|
|
1340
1429
|
var ProjectSelectSchema = drizzleZod.createSelectSchema(projects);
|
|
1341
1430
|
var ProjectInsertSchema = drizzleZod.createInsertSchema(projects).extend({
|
|
1342
1431
|
models: ProjectModelSchema,
|
|
1343
|
-
stopWhen: StopWhenSchema.optional()
|
|
1432
|
+
stopWhen: StopWhenSchema.optional(),
|
|
1433
|
+
sandboxConfig: SandboxConfigSchema.optional()
|
|
1344
1434
|
}).omit({
|
|
1345
1435
|
createdAt: true,
|
|
1346
1436
|
updatedAt: true
|
|
@@ -1352,6 +1442,9 @@ var ProjectApiUpdateSchema = ProjectUpdateSchema.omit({ tenantId: true });
|
|
|
1352
1442
|
var FullProjectDefinitionSchema = ProjectApiInsertSchema.extend({
|
|
1353
1443
|
graphs: zodOpenapi.z.record(zodOpenapi.z.string(), GraphWithinContextOfProjectSchema),
|
|
1354
1444
|
tools: zodOpenapi.z.record(zodOpenapi.z.string(), ToolApiInsertSchema),
|
|
1445
|
+
// Now includes both MCP and function tools
|
|
1446
|
+
functions: zodOpenapi.z.record(zodOpenapi.z.string(), FunctionApiInsertSchema).optional(),
|
|
1447
|
+
// Global functions
|
|
1355
1448
|
dataComponents: zodOpenapi.z.record(zodOpenapi.z.string(), DataComponentApiInsertSchema).optional(),
|
|
1356
1449
|
artifactComponents: zodOpenapi.z.record(zodOpenapi.z.string(), ArtifactComponentApiInsertSchema).optional(),
|
|
1357
1450
|
statusUpdates: zodOpenapi.z.optional(StatusUpdateSchema),
|
|
@@ -1574,6 +1667,108 @@ function generateIdFromName(name) {
|
|
|
1574
1667
|
}
|
|
1575
1668
|
return truncatedId;
|
|
1576
1669
|
}
|
|
1670
|
+
function validatePropsAsJsonSchema(props) {
|
|
1671
|
+
if (!props || typeof props === "object" && Object.keys(props).length === 0) {
|
|
1672
|
+
return {
|
|
1673
|
+
isValid: true,
|
|
1674
|
+
errors: []
|
|
1675
|
+
};
|
|
1676
|
+
}
|
|
1677
|
+
if (typeof props !== "object" || Array.isArray(props)) {
|
|
1678
|
+
return {
|
|
1679
|
+
isValid: false,
|
|
1680
|
+
errors: [
|
|
1681
|
+
{
|
|
1682
|
+
field: "props",
|
|
1683
|
+
message: "Props must be a valid JSON Schema object",
|
|
1684
|
+
value: props
|
|
1685
|
+
}
|
|
1686
|
+
]
|
|
1687
|
+
};
|
|
1688
|
+
}
|
|
1689
|
+
if (!props.type) {
|
|
1690
|
+
return {
|
|
1691
|
+
isValid: false,
|
|
1692
|
+
errors: [
|
|
1693
|
+
{
|
|
1694
|
+
field: "props.type",
|
|
1695
|
+
message: 'JSON Schema must have a "type" field'
|
|
1696
|
+
}
|
|
1697
|
+
]
|
|
1698
|
+
};
|
|
1699
|
+
}
|
|
1700
|
+
if (props.type !== "object") {
|
|
1701
|
+
return {
|
|
1702
|
+
isValid: false,
|
|
1703
|
+
errors: [
|
|
1704
|
+
{
|
|
1705
|
+
field: "props.type",
|
|
1706
|
+
message: 'JSON Schema type must be "object" for component props',
|
|
1707
|
+
value: props.type
|
|
1708
|
+
}
|
|
1709
|
+
]
|
|
1710
|
+
};
|
|
1711
|
+
}
|
|
1712
|
+
if (!props.properties || typeof props.properties !== "object") {
|
|
1713
|
+
return {
|
|
1714
|
+
isValid: false,
|
|
1715
|
+
errors: [
|
|
1716
|
+
{
|
|
1717
|
+
field: "props.properties",
|
|
1718
|
+
message: 'JSON Schema must have a "properties" object'
|
|
1719
|
+
}
|
|
1720
|
+
]
|
|
1721
|
+
};
|
|
1722
|
+
}
|
|
1723
|
+
if (props.required !== void 0 && !Array.isArray(props.required)) {
|
|
1724
|
+
return {
|
|
1725
|
+
isValid: false,
|
|
1726
|
+
errors: [
|
|
1727
|
+
{
|
|
1728
|
+
field: "props.required",
|
|
1729
|
+
message: 'If present, "required" must be an array'
|
|
1730
|
+
}
|
|
1731
|
+
]
|
|
1732
|
+
};
|
|
1733
|
+
}
|
|
1734
|
+
try {
|
|
1735
|
+
const schemaToValidate = { ...props };
|
|
1736
|
+
delete schemaToValidate.$schema;
|
|
1737
|
+
const schemaValidator = new Ajv__default.default({
|
|
1738
|
+
strict: false,
|
|
1739
|
+
// Allow unknown keywords like inPreview
|
|
1740
|
+
validateSchema: true,
|
|
1741
|
+
// Validate the schema itself
|
|
1742
|
+
addUsedSchema: false
|
|
1743
|
+
// Don't add schemas to the instance
|
|
1744
|
+
});
|
|
1745
|
+
const isValid = schemaValidator.validateSchema(schemaToValidate);
|
|
1746
|
+
if (!isValid) {
|
|
1747
|
+
const errors = schemaValidator.errors || [];
|
|
1748
|
+
return {
|
|
1749
|
+
isValid: false,
|
|
1750
|
+
errors: errors.map((error) => ({
|
|
1751
|
+
field: `props${error.instancePath || ""}`,
|
|
1752
|
+
message: error.message || "Invalid schema"
|
|
1753
|
+
}))
|
|
1754
|
+
};
|
|
1755
|
+
}
|
|
1756
|
+
return {
|
|
1757
|
+
isValid: true,
|
|
1758
|
+
errors: []
|
|
1759
|
+
};
|
|
1760
|
+
} catch (error) {
|
|
1761
|
+
return {
|
|
1762
|
+
isValid: false,
|
|
1763
|
+
errors: [
|
|
1764
|
+
{
|
|
1765
|
+
field: "props",
|
|
1766
|
+
message: `Schema validation failed: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
1767
|
+
}
|
|
1768
|
+
]
|
|
1769
|
+
};
|
|
1770
|
+
}
|
|
1771
|
+
}
|
|
1577
1772
|
|
|
1578
1773
|
exports.AgentApiInsertSchema = AgentApiInsertSchema;
|
|
1579
1774
|
exports.AgentApiSelectSchema = AgentApiSelectSchema;
|
|
@@ -1674,6 +1869,13 @@ exports.FetchDefinitionSchema = FetchDefinitionSchema;
|
|
|
1674
1869
|
exports.FullGraphAgentInsertSchema = FullGraphAgentInsertSchema;
|
|
1675
1870
|
exports.FullGraphDefinitionSchema = FullGraphDefinitionSchema;
|
|
1676
1871
|
exports.FullProjectDefinitionSchema = FullProjectDefinitionSchema;
|
|
1872
|
+
exports.FunctionApiInsertSchema = FunctionApiInsertSchema;
|
|
1873
|
+
exports.FunctionApiSelectSchema = FunctionApiSelectSchema;
|
|
1874
|
+
exports.FunctionApiUpdateSchema = FunctionApiUpdateSchema;
|
|
1875
|
+
exports.FunctionInsertSchema = FunctionInsertSchema;
|
|
1876
|
+
exports.FunctionSelectSchema = FunctionSelectSchema;
|
|
1877
|
+
exports.FunctionToolConfigSchema = FunctionToolConfigSchema;
|
|
1878
|
+
exports.FunctionUpdateSchema = FunctionUpdateSchema;
|
|
1677
1879
|
exports.GraphStopWhenSchema = GraphStopWhenSchema;
|
|
1678
1880
|
exports.GraphWithinContextOfProjectSchema = GraphWithinContextOfProjectSchema;
|
|
1679
1881
|
exports.HeadersScopeSchema = HeadersScopeSchema;
|
|
@@ -1709,6 +1911,7 @@ exports.ProjectModelSchema = ProjectModelSchema;
|
|
|
1709
1911
|
exports.ProjectSelectSchema = ProjectSelectSchema;
|
|
1710
1912
|
exports.ProjectUpdateSchema = ProjectUpdateSchema;
|
|
1711
1913
|
exports.RemovedResponseSchema = RemovedResponseSchema;
|
|
1914
|
+
exports.SandboxConfigSchema = SandboxConfigSchema;
|
|
1712
1915
|
exports.SingleResponseSchema = SingleResponseSchema;
|
|
1713
1916
|
exports.StatusComponentSchema = StatusComponentSchema;
|
|
1714
1917
|
exports.StatusUpdateSchema = StatusUpdateSchema;
|
|
@@ -1749,4 +1952,5 @@ exports.validateAndTypeGraphData = validateAndTypeGraphData;
|
|
|
1749
1952
|
exports.validateArtifactComponentReferences = validateArtifactComponentReferences;
|
|
1750
1953
|
exports.validateDataComponentReferences = validateDataComponentReferences;
|
|
1751
1954
|
exports.validateGraphStructure = validateGraphStructure;
|
|
1955
|
+
exports.validatePropsAsJsonSchema = validatePropsAsJsonSchema;
|
|
1752
1956
|
exports.validateToolReferences = validateToolReferences;
|