@inkeep/agents-core 0.14.16 → 0.16.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.
Files changed (40) hide show
  1. package/dist/{chunk-SPN4Y2C3.js → chunk-L53XWAYG.js} +1 -1
  2. package/dist/chunk-R2EERZSW.js +223 -0
  3. package/dist/{chunk-423XYZ6F.js → chunk-TO2HNKGP.js} +176 -13
  4. package/dist/{chunk-AHSEMW6N.js → chunk-VPJ6Z5QZ.js} +43 -7
  5. package/dist/client-exports.cjs +224 -24
  6. package/dist/client-exports.d.cts +12 -8
  7. package/dist/client-exports.d.ts +12 -8
  8. package/dist/client-exports.js +4 -10
  9. package/dist/db/schema.cjs +42 -6
  10. package/dist/db/schema.d.cts +2 -2
  11. package/dist/db/schema.d.ts +2 -2
  12. package/dist/db/schema.js +1 -1
  13. package/dist/index.cjs +3310 -2859
  14. package/dist/index.d.cts +148 -97
  15. package/dist/index.d.ts +148 -97
  16. package/dist/index.js +2589 -2574
  17. package/dist/props-validation-BMR1qNiy.d.cts +15 -0
  18. package/dist/props-validation-BMR1qNiy.d.ts +15 -0
  19. package/dist/{schema-NJiTVcbN.d.ts → schema-BQk_FMBV.d.ts} +253 -64
  20. package/dist/{schema-Mdt3_61i.d.cts → schema-Ct2NlO81.d.cts} +253 -64
  21. package/dist/types/index.d.cts +2 -2
  22. package/dist/types/index.d.ts +2 -2
  23. package/dist/{utility-CfjwCzr_.d.cts → utility-s9c5CVOe.d.cts} +708 -167
  24. package/dist/{utility-CfjwCzr_.d.ts → utility-s9c5CVOe.d.ts} +708 -167
  25. package/dist/utils/schema-conversion.cjs +236 -0
  26. package/dist/utils/schema-conversion.d.cts +26 -0
  27. package/dist/utils/schema-conversion.d.ts +26 -0
  28. package/dist/utils/schema-conversion.js +1 -0
  29. package/dist/validation/index.cjs +227 -17
  30. package/dist/validation/index.d.cts +3 -2
  31. package/dist/validation/index.d.ts +3 -2
  32. package/dist/validation/index.js +2 -2
  33. package/drizzle/0002_bumpy_romulus.sql +3 -0
  34. package/drizzle/0003_soft_forgotten_one.sql +39 -0
  35. package/drizzle/0004_melted_omega_flight.sql +3 -0
  36. package/drizzle/meta/0002_snapshot.json +2428 -0
  37. package/drizzle/meta/0003_snapshot.json +2559 -0
  38. package/drizzle/meta/0004_snapshot.json +2547 -0
  39. package/drizzle/meta/_journal.json +21 -0
  40. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { FullGraphDefinitionSchema, resourceIdSchema, MAX_ID_LENGTH } from './chunk-423XYZ6F.js';
1
+ import { FullGraphDefinitionSchema, resourceIdSchema, MAX_ID_LENGTH } from './chunk-TO2HNKGP.js';
2
2
 
3
3
  // src/validation/graphFull.ts
4
4
  function isInternalAgent(agent) {
@@ -0,0 +1,223 @@
1
+ import { __publicField } from './chunk-MKBO26DX.js';
2
+ import { z } from 'zod';
3
+ import pino from 'pino';
4
+ import pinoPretty from 'pino-pretty';
5
+
6
+ var PinoLogger = class {
7
+ constructor(name, config = {}) {
8
+ this.name = name;
9
+ __publicField(this, "transportConfigs", []);
10
+ __publicField(this, "pinoInstance");
11
+ __publicField(this, "options");
12
+ this.options = {
13
+ name: this.name,
14
+ level: process.env.LOG_LEVEL || (process.env.ENVIRONMENT === "test" ? "silent" : "info"),
15
+ serializers: {
16
+ obj: (value) => ({ ...value })
17
+ },
18
+ redact: ["req.headers.authorization", 'req.headers["x-inkeep-admin-authentication"]'],
19
+ ...config.options
20
+ };
21
+ if (config.transportConfigs) {
22
+ this.transportConfigs = config.transportConfigs;
23
+ }
24
+ if (this.transportConfigs.length > 0) {
25
+ this.pinoInstance = pino(this.options, pino.transport({ targets: this.transportConfigs }));
26
+ } else {
27
+ try {
28
+ const prettyStream = pinoPretty({
29
+ colorize: true,
30
+ translateTime: "HH:MM:ss",
31
+ ignore: "pid,hostname"
32
+ });
33
+ this.pinoInstance = pino(this.options, prettyStream);
34
+ } catch (error) {
35
+ console.warn("Warning: pino-pretty failed, using standard JSON output:", error);
36
+ this.pinoInstance = pino(this.options);
37
+ }
38
+ }
39
+ }
40
+ /**
41
+ * Recreate the pino instance with current transports
42
+ */
43
+ recreateInstance() {
44
+ if (this.pinoInstance && typeof this.pinoInstance.flush === "function") {
45
+ this.pinoInstance.flush();
46
+ }
47
+ if (this.transportConfigs.length === 0) {
48
+ try {
49
+ const prettyStream = pinoPretty({
50
+ colorize: true,
51
+ translateTime: "HH:MM:ss",
52
+ ignore: "pid,hostname"
53
+ });
54
+ this.pinoInstance = pino(this.options, prettyStream);
55
+ } catch (error) {
56
+ console.warn("Warning: pino-pretty failed, using standard JSON output:", error);
57
+ this.pinoInstance = pino(this.options);
58
+ }
59
+ } else {
60
+ const multiTransport = { targets: this.transportConfigs };
61
+ const pinoTransport = pino.transport(multiTransport);
62
+ this.pinoInstance = pino(this.options, pinoTransport);
63
+ }
64
+ }
65
+ /**
66
+ * Add a new transport to the logger
67
+ */
68
+ addTransport(transportConfig) {
69
+ this.transportConfigs.push(transportConfig);
70
+ this.recreateInstance();
71
+ }
72
+ /**
73
+ * Remove a transport by index
74
+ */
75
+ removeTransport(index) {
76
+ if (index >= 0 && index < this.transportConfigs.length) {
77
+ this.transportConfigs.splice(index, 1);
78
+ this.recreateInstance();
79
+ }
80
+ }
81
+ /**
82
+ * Get current transports
83
+ */
84
+ getTransports() {
85
+ return [...this.transportConfigs];
86
+ }
87
+ /**
88
+ * Update logger options
89
+ */
90
+ updateOptions(options) {
91
+ this.options = {
92
+ ...this.options,
93
+ ...options
94
+ };
95
+ this.recreateInstance();
96
+ }
97
+ /**
98
+ * Get the underlying pino instance for advanced usage
99
+ */
100
+ getPinoInstance() {
101
+ return this.pinoInstance;
102
+ }
103
+ error(data, message) {
104
+ this.pinoInstance.error(data, message);
105
+ }
106
+ warn(data, message) {
107
+ this.pinoInstance.warn(data, message);
108
+ }
109
+ info(data, message) {
110
+ this.pinoInstance.info(data, message);
111
+ }
112
+ debug(data, message) {
113
+ this.pinoInstance.debug(data, message);
114
+ }
115
+ };
116
+ var LoggerFactory = class {
117
+ constructor() {
118
+ __publicField(this, "config", {});
119
+ __publicField(this, "loggers", /* @__PURE__ */ new Map());
120
+ }
121
+ /**
122
+ * Configure the logger factory
123
+ */
124
+ configure(config) {
125
+ this.config = config;
126
+ this.loggers.clear();
127
+ }
128
+ /**
129
+ * Get or create a logger instance
130
+ */
131
+ getLogger(name) {
132
+ if (this.loggers.has(name)) {
133
+ const logger3 = this.loggers.get(name);
134
+ if (!logger3) {
135
+ throw new Error(`Logger '${name}' not found in cache`);
136
+ }
137
+ return logger3;
138
+ }
139
+ let logger2;
140
+ if (this.config.loggerFactory) {
141
+ logger2 = this.config.loggerFactory(name);
142
+ } else if (this.config.defaultLogger) {
143
+ logger2 = this.config.defaultLogger;
144
+ } else {
145
+ logger2 = new PinoLogger(name, this.config.pinoConfig);
146
+ }
147
+ this.loggers.set(name, logger2);
148
+ return logger2;
149
+ }
150
+ /**
151
+ * Reset factory to default state
152
+ */
153
+ reset() {
154
+ this.config = {};
155
+ this.loggers.clear();
156
+ }
157
+ };
158
+ var loggerFactory = new LoggerFactory();
159
+ function getLogger(name) {
160
+ return loggerFactory.getLogger(name);
161
+ }
162
+
163
+ // src/utils/schema-conversion.ts
164
+ var logger = getLogger("schema-conversion");
165
+ function convertZodToJsonSchema(zodSchema) {
166
+ try {
167
+ const jsonSchema = z.toJSONSchema(zodSchema);
168
+ if (jsonSchema.$schema) {
169
+ delete jsonSchema.$schema;
170
+ }
171
+ return jsonSchema;
172
+ } catch (error) {
173
+ logger.error(
174
+ {
175
+ error: error instanceof Error ? error.message : "Unknown error",
176
+ stack: error instanceof Error ? error.stack : void 0
177
+ },
178
+ "Failed to convert Zod schema to JSON Schema"
179
+ );
180
+ throw new Error("Failed to convert Zod schema to JSON Schema");
181
+ }
182
+ }
183
+ var preview = (schema) => {
184
+ schema._def.inPreview = true;
185
+ return schema;
186
+ };
187
+ function convertZodToJsonSchemaWithPreview(zodSchema) {
188
+ const jsonSchema = convertZodToJsonSchema(zodSchema);
189
+ if (zodSchema instanceof z.ZodObject && jsonSchema.properties) {
190
+ const shape = zodSchema.shape;
191
+ for (const [key, fieldSchema] of Object.entries(shape)) {
192
+ if (fieldSchema?._def?.inPreview === true) {
193
+ jsonSchema.properties[key].inPreview = true;
194
+ }
195
+ }
196
+ }
197
+ return jsonSchema;
198
+ }
199
+ function isZodSchema(value) {
200
+ return value?._def?.type === "object";
201
+ }
202
+ function extractPreviewFields(schema) {
203
+ const previewFields = [];
204
+ if (schema instanceof z.ZodObject) {
205
+ const shape = schema.shape;
206
+ for (const [key, fieldSchema] of Object.entries(shape)) {
207
+ if (fieldSchema?._def?.inPreview === true) {
208
+ previewFields.push(key);
209
+ }
210
+ }
211
+ return previewFields;
212
+ }
213
+ if (schema?.type === "object" && schema.properties) {
214
+ for (const [key, prop] of Object.entries(schema.properties)) {
215
+ if (prop.inPreview === true) {
216
+ previewFields.push(key);
217
+ }
218
+ }
219
+ }
220
+ return previewFields;
221
+ }
222
+
223
+ export { PinoLogger, convertZodToJsonSchema, convertZodToJsonSchemaWithPreview, extractPreviewFields, getLogger, isZodSchema, loggerFactory, preview };
@@ -1,7 +1,8 @@
1
- import { agents, agentRelations, agentGraph, tasks, taskRelations, tools, conversations, messages, contextCache, dataComponents, agentDataComponents, artifactComponents, agentArtifactComponents, externalAgents, apiKeys, credentialReferences, contextConfigs, agentToolRelations, ledgerArtifacts, projects } from './chunk-AHSEMW6N.js';
1
+ import { agents, agentRelations, agentGraph, tasks, taskRelations, tools, conversations, messages, contextCache, dataComponents, agentDataComponents, artifactComponents, agentArtifactComponents, externalAgents, apiKeys, credentialReferences, functions, contextConfigs, agentToolRelations, ledgerArtifacts, projects } from './chunk-VPJ6Z5QZ.js';
2
2
  import { VALID_RELATION_TYPES, MCPTransportType, TOOL_STATUS_VALUES, CredentialStoreType, MCPServerType } from './chunk-YFHT5M2R.js';
3
3
  import { z } from '@hono/zod-openapi';
4
4
  import { createSelectSchema, createInsertSchema } from 'drizzle-zod';
5
+ import Ajv from 'ajv';
5
6
 
6
7
  var StopWhenSchema = z.object({
7
8
  transferCountIs: z.number().min(1).max(100).optional(),
@@ -32,6 +33,19 @@ var ProjectModelSchema = z.object({
32
33
  structuredOutput: ModelSettingsSchema.optional(),
33
34
  summarizer: ModelSettingsSchema.optional()
34
35
  });
36
+ var SandboxConfigSchema = z.object({
37
+ provider: z.enum(["vercel", "local"]),
38
+ runtime: z.enum(["node22", "typescript"]),
39
+ timeout: z.number().min(1e3).max(3e5).optional(),
40
+ vcpus: z.number().min(1).max(8).optional()
41
+ });
42
+ var FunctionToolConfigSchema = z.object({
43
+ name: z.string(),
44
+ description: z.string(),
45
+ inputSchema: z.record(z.string(), z.unknown()),
46
+ dependencies: z.record(z.string(), z.string()).optional(),
47
+ execute: z.union([z.function(), z.string()])
48
+ });
35
49
  var createApiSchema = (schema) => schema.omit({ tenantId: true, projectId: true });
36
50
  var createApiInsertSchema = (schema) => schema.omit({ tenantId: true, projectId: true });
37
51
  var createApiUpdateSchema = (schema) => schema.omit({ tenantId: true, projectId: true }).partial();
@@ -168,7 +182,33 @@ var McpToolDefinitionSchema = z.object({
168
182
  var ToolSelectSchema = createSelectSchema(tools);
169
183
  var ToolInsertSchema = createInsertSchema(tools).extend({
170
184
  id: resourceIdSchema,
171
- imageUrl: imageUrlSchema
185
+ imageUrl: imageUrlSchema,
186
+ functionId: resourceIdSchema.optional(),
187
+ // For function tools, reference to global functions table
188
+ config: z.discriminatedUnion("type", [
189
+ // MCP tools
190
+ z.object({
191
+ type: z.literal("mcp"),
192
+ mcp: z.object({
193
+ server: z.object({
194
+ url: z.string().url()
195
+ }),
196
+ transport: z.object({
197
+ type: z.enum(MCPTransportType),
198
+ requestInit: z.record(z.string(), z.unknown()).optional(),
199
+ eventSourceInit: z.record(z.string(), z.unknown()).optional(),
200
+ reconnectionOptions: z.custom().optional(),
201
+ sessionId: z.string().optional()
202
+ }).optional(),
203
+ activeTools: z.array(z.string()).optional()
204
+ })
205
+ }),
206
+ // Function tools (reference-only, no inline duplication)
207
+ z.object({
208
+ type: z.literal("function")
209
+ // No inline function details - they're in the functions table via functionId
210
+ })
211
+ ])
172
212
  });
173
213
  var ConversationSelectSchema = createSelectSchema(conversations);
174
214
  var ConversationInsertSchema = createInsertSchema(conversations).extend({
@@ -378,6 +418,14 @@ var ToolUpdateSchema = ToolInsertSchema.partial();
378
418
  var ToolApiSelectSchema = createApiSchema(ToolSelectSchema);
379
419
  var ToolApiInsertSchema = createApiInsertSchema(ToolInsertSchema);
380
420
  var ToolApiUpdateSchema = createApiUpdateSchema(ToolUpdateSchema);
421
+ var FunctionSelectSchema = createSelectSchema(functions);
422
+ var FunctionInsertSchema = createInsertSchema(functions).extend({
423
+ id: resourceIdSchema
424
+ });
425
+ var FunctionUpdateSchema = FunctionInsertSchema.partial();
426
+ var FunctionApiSelectSchema = createApiSchema(FunctionSelectSchema);
427
+ var FunctionApiInsertSchema = createApiInsertSchema(FunctionInsertSchema);
428
+ var FunctionApiUpdateSchema = createApiUpdateSchema(FunctionUpdateSchema);
381
429
  var FetchConfigSchema = z.object({
382
430
  url: z.string().min(1, "URL is required"),
383
431
  method: z.enum(["GET", "POST", "PUT", "DELETE", "PATCH"]).optional().default("GET"),
@@ -398,19 +446,25 @@ var FetchDefinitionSchema = z.object({
398
446
  credential: CredentialReferenceApiInsertSchema.optional()
399
447
  });
400
448
  var ContextConfigSelectSchema = createSelectSchema(contextConfigs).extend({
401
- requestContextSchema: z.unknown().optional()
449
+ headersSchema: z.unknown().optional()
402
450
  });
403
451
  var ContextConfigInsertSchema = createInsertSchema(contextConfigs).extend({
404
- id: resourceIdSchema,
405
- requestContextSchema: z.unknown().optional()
452
+ id: resourceIdSchema.optional(),
453
+ headersSchema: z.unknown().optional()
406
454
  }).omit({
407
455
  createdAt: true,
408
456
  updatedAt: true
409
457
  });
410
458
  var ContextConfigUpdateSchema = ContextConfigInsertSchema.partial();
411
- var ContextConfigApiSelectSchema = createApiSchema(ContextConfigSelectSchema);
412
- var ContextConfigApiInsertSchema = createApiInsertSchema(ContextConfigInsertSchema);
413
- var ContextConfigApiUpdateSchema = createApiUpdateSchema(ContextConfigUpdateSchema);
459
+ var ContextConfigApiSelectSchema = createApiSchema(ContextConfigSelectSchema).omit({
460
+ graphId: true
461
+ });
462
+ var ContextConfigApiInsertSchema = createApiInsertSchema(ContextConfigInsertSchema).omit({
463
+ graphId: true
464
+ });
465
+ var ContextConfigApiUpdateSchema = createApiUpdateSchema(ContextConfigUpdateSchema).omit({
466
+ graphId: true
467
+ });
414
468
  var AgentToolRelationSelectSchema = createSelectSchema(agentToolRelations);
415
469
  var AgentToolRelationInsertSchema = createInsertSchema(agentToolRelations).extend({
416
470
  id: resourceIdSchema,
@@ -460,6 +514,7 @@ var CanUseItemSchema = z.object({
460
514
  var FullGraphAgentInsertSchema = AgentApiInsertSchema.extend({
461
515
  type: z.literal("internal"),
462
516
  canUse: z.array(CanUseItemSchema),
517
+ // All tools (both MCP and function tools)
463
518
  dataComponents: z.array(z.string()).optional(),
464
519
  artifactComponents: z.array(z.string()).optional(),
465
520
  canTransferTo: z.array(z.string()).optional(),
@@ -467,9 +522,11 @@ var FullGraphAgentInsertSchema = AgentApiInsertSchema.extend({
467
522
  });
468
523
  var FullGraphDefinitionSchema = AgentGraphApiInsertSchema.extend({
469
524
  agents: z.record(z.string(), z.union([FullGraphAgentInsertSchema, ExternalAgentApiInsertSchema])),
470
- // Removed project-scoped resources - these are now managed at project level:
471
- // tools, credentialReferences, dataComponents, artifactComponents
472
- // Agent relationships to these resources are maintained via agent.tools, agent.dataComponents, etc.
525
+ // Lookup maps for UI to resolve canUse items
526
+ tools: z.record(z.string(), ToolApiInsertSchema).optional(),
527
+ // Get tool name/description from toolId
528
+ functions: z.record(z.string(), FunctionApiInsertSchema).optional(),
529
+ // Get function code for function tools
473
530
  contextConfig: z.optional(ContextConfigApiInsertSchema),
474
531
  statusUpdates: z.optional(StatusUpdateSchema),
475
532
  models: ModelSchema.optional(),
@@ -518,7 +575,8 @@ var RemovedResponseSchema = z.object({
518
575
  var ProjectSelectSchema = createSelectSchema(projects);
519
576
  var ProjectInsertSchema = createInsertSchema(projects).extend({
520
577
  models: ProjectModelSchema,
521
- stopWhen: StopWhenSchema.optional()
578
+ stopWhen: StopWhenSchema.optional(),
579
+ sandboxConfig: SandboxConfigSchema.optional()
522
580
  }).omit({
523
581
  createdAt: true,
524
582
  updatedAt: true
@@ -530,6 +588,9 @@ var ProjectApiUpdateSchema = ProjectUpdateSchema.omit({ tenantId: true });
530
588
  var FullProjectDefinitionSchema = ProjectApiInsertSchema.extend({
531
589
  graphs: z.record(z.string(), GraphWithinContextOfProjectSchema),
532
590
  tools: z.record(z.string(), ToolApiInsertSchema),
591
+ // Now includes both MCP and function tools
592
+ functions: z.record(z.string(), FunctionApiInsertSchema).optional(),
593
+ // Global functions
533
594
  dataComponents: z.record(z.string(), DataComponentApiInsertSchema).optional(),
534
595
  artifactComponents: z.record(z.string(), ArtifactComponentApiInsertSchema).optional(),
535
596
  statusUpdates: z.optional(StatusUpdateSchema),
@@ -621,5 +682,107 @@ var PaginationQueryParamsSchema = z.object({
621
682
  page: z.coerce.number().min(1).default(1),
622
683
  limit: z.coerce.number().min(1).max(100).default(10)
623
684
  });
685
+ function validatePropsAsJsonSchema(props) {
686
+ if (!props || typeof props === "object" && Object.keys(props).length === 0) {
687
+ return {
688
+ isValid: true,
689
+ errors: []
690
+ };
691
+ }
692
+ if (typeof props !== "object" || Array.isArray(props)) {
693
+ return {
694
+ isValid: false,
695
+ errors: [
696
+ {
697
+ field: "props",
698
+ message: "Props must be a valid JSON Schema object",
699
+ value: props
700
+ }
701
+ ]
702
+ };
703
+ }
704
+ if (!props.type) {
705
+ return {
706
+ isValid: false,
707
+ errors: [
708
+ {
709
+ field: "props.type",
710
+ message: 'JSON Schema must have a "type" field'
711
+ }
712
+ ]
713
+ };
714
+ }
715
+ if (props.type !== "object") {
716
+ return {
717
+ isValid: false,
718
+ errors: [
719
+ {
720
+ field: "props.type",
721
+ message: 'JSON Schema type must be "object" for component props',
722
+ value: props.type
723
+ }
724
+ ]
725
+ };
726
+ }
727
+ if (!props.properties || typeof props.properties !== "object") {
728
+ return {
729
+ isValid: false,
730
+ errors: [
731
+ {
732
+ field: "props.properties",
733
+ message: 'JSON Schema must have a "properties" object'
734
+ }
735
+ ]
736
+ };
737
+ }
738
+ if (props.required !== void 0 && !Array.isArray(props.required)) {
739
+ return {
740
+ isValid: false,
741
+ errors: [
742
+ {
743
+ field: "props.required",
744
+ message: 'If present, "required" must be an array'
745
+ }
746
+ ]
747
+ };
748
+ }
749
+ try {
750
+ const schemaToValidate = { ...props };
751
+ delete schemaToValidate.$schema;
752
+ const schemaValidator = new Ajv({
753
+ strict: false,
754
+ // Allow unknown keywords like inPreview
755
+ validateSchema: true,
756
+ // Validate the schema itself
757
+ addUsedSchema: false
758
+ // Don't add schemas to the instance
759
+ });
760
+ const isValid = schemaValidator.validateSchema(schemaToValidate);
761
+ if (!isValid) {
762
+ const errors = schemaValidator.errors || [];
763
+ return {
764
+ isValid: false,
765
+ errors: errors.map((error) => ({
766
+ field: `props${error.instancePath || ""}`,
767
+ message: error.message || "Invalid schema"
768
+ }))
769
+ };
770
+ }
771
+ return {
772
+ isValid: true,
773
+ errors: []
774
+ };
775
+ } catch (error) {
776
+ return {
777
+ isValid: false,
778
+ errors: [
779
+ {
780
+ field: "props",
781
+ message: `Schema validation failed: ${error instanceof Error ? error.message : "Unknown error"}`
782
+ }
783
+ ]
784
+ };
785
+ }
786
+ }
624
787
 
625
- export { AgentApiInsertSchema, AgentApiSelectSchema, AgentApiUpdateSchema, AgentArtifactComponentApiInsertSchema, AgentArtifactComponentApiSelectSchema, AgentArtifactComponentApiUpdateSchema, AgentArtifactComponentInsertSchema, AgentArtifactComponentSelectSchema, AgentArtifactComponentUpdateSchema, AgentDataComponentApiInsertSchema, AgentDataComponentApiSelectSchema, AgentDataComponentApiUpdateSchema, AgentDataComponentInsertSchema, AgentDataComponentSelectSchema, AgentDataComponentUpdateSchema, AgentGraphApiInsertSchema, AgentGraphApiSelectSchema, AgentGraphApiUpdateSchema, AgentGraphInsertSchema, AgentGraphSelectSchema, AgentGraphUpdateSchema, AgentInsertSchema, AgentRelationApiInsertSchema, AgentRelationApiSelectSchema, AgentRelationApiUpdateSchema, AgentRelationInsertSchema, AgentRelationQuerySchema, AgentRelationSelectSchema, AgentRelationUpdateSchema, AgentSelectSchema, AgentStopWhenSchema, AgentToolRelationApiInsertSchema, AgentToolRelationApiSelectSchema, AgentToolRelationApiUpdateSchema, AgentToolRelationInsertSchema, AgentToolRelationSelectSchema, AgentToolRelationUpdateSchema, AgentUpdateSchema, AllAgentSchema, ApiKeyApiCreationResponseSchema, ApiKeyApiInsertSchema, ApiKeyApiSelectSchema, ApiKeyApiUpdateSchema, ApiKeyInsertSchema, ApiKeySelectSchema, ApiKeyUpdateSchema, ArtifactComponentApiInsertSchema, ArtifactComponentApiSelectSchema, ArtifactComponentApiUpdateSchema, ArtifactComponentInsertSchema, ArtifactComponentSelectSchema, ArtifactComponentUpdateSchema, CanUseItemSchema, ContextCacheApiInsertSchema, ContextCacheApiSelectSchema, ContextCacheApiUpdateSchema, ContextCacheInsertSchema, ContextCacheSelectSchema, ContextCacheUpdateSchema, ContextConfigApiInsertSchema, ContextConfigApiSelectSchema, ContextConfigApiUpdateSchema, ContextConfigInsertSchema, ContextConfigSelectSchema, ContextConfigUpdateSchema, ConversationApiInsertSchema, ConversationApiSelectSchema, ConversationApiUpdateSchema, ConversationInsertSchema, ConversationSelectSchema, ConversationUpdateSchema, CredentialReferenceApiInsertSchema, CredentialReferenceApiSelectSchema, CredentialReferenceApiUpdateSchema, CredentialReferenceInsertSchema, CredentialReferenceSelectSchema, CredentialReferenceUpdateSchema, DataComponentApiInsertSchema, DataComponentApiSelectSchema, DataComponentApiUpdateSchema, DataComponentBaseSchema, DataComponentInsertSchema, DataComponentSelectSchema, DataComponentUpdateSchema, ErrorResponseSchema, ExistsResponseSchema, ExternalAgentApiInsertSchema, ExternalAgentApiSelectSchema, ExternalAgentApiUpdateSchema, ExternalAgentInsertSchema, ExternalAgentRelationApiInsertSchema, ExternalAgentRelationInsertSchema, ExternalAgentSelectSchema, ExternalAgentUpdateSchema, FetchConfigSchema, FetchDefinitionSchema, FullGraphAgentInsertSchema, FullGraphDefinitionSchema, FullProjectDefinitionSchema, GraphStopWhenSchema, GraphWithinContextOfProjectSchema, HeadersScopeSchema, IdParamsSchema, LedgerArtifactApiInsertSchema, LedgerArtifactApiSelectSchema, LedgerArtifactApiUpdateSchema, LedgerArtifactInsertSchema, LedgerArtifactSelectSchema, LedgerArtifactUpdateSchema, ListResponseSchema, MAX_ID_LENGTH, MCPToolConfigSchema, MIN_ID_LENGTH, McpToolDefinitionSchema, McpToolSchema, McpTransportConfigSchema, MessageApiInsertSchema, MessageApiSelectSchema, MessageApiUpdateSchema, MessageInsertSchema, MessageSelectSchema, MessageUpdateSchema, ModelSchema, ModelSettingsSchema, PaginationQueryParamsSchema, PaginationSchema, ProjectApiInsertSchema, ProjectApiSelectSchema, ProjectApiUpdateSchema, ProjectInsertSchema, ProjectModelSchema, ProjectSelectSchema, ProjectUpdateSchema, RemovedResponseSchema, SingleResponseSchema, StatusComponentSchema, StatusUpdateSchema, StopWhenSchema, TaskApiInsertSchema, TaskApiSelectSchema, TaskApiUpdateSchema, TaskInsertSchema, TaskRelationApiInsertSchema, TaskRelationApiSelectSchema, TaskRelationApiUpdateSchema, TaskRelationInsertSchema, TaskRelationSelectSchema, TaskRelationUpdateSchema, TaskSelectSchema, TaskUpdateSchema, TenantIdParamsSchema, TenantParamsSchema, TenantProjectGraphIdParamsSchema, TenantProjectGraphParamsSchema, TenantProjectIdParamsSchema, TenantProjectParamsSchema, ToolApiInsertSchema, ToolApiSelectSchema, ToolApiUpdateSchema, ToolInsertSchema, ToolSelectSchema, ToolStatusSchema, ToolUpdateSchema, URL_SAFE_ID_PATTERN, resourceIdSchema };
788
+ export { AgentApiInsertSchema, AgentApiSelectSchema, AgentApiUpdateSchema, AgentArtifactComponentApiInsertSchema, AgentArtifactComponentApiSelectSchema, AgentArtifactComponentApiUpdateSchema, AgentArtifactComponentInsertSchema, AgentArtifactComponentSelectSchema, AgentArtifactComponentUpdateSchema, AgentDataComponentApiInsertSchema, AgentDataComponentApiSelectSchema, AgentDataComponentApiUpdateSchema, AgentDataComponentInsertSchema, AgentDataComponentSelectSchema, AgentDataComponentUpdateSchema, AgentGraphApiInsertSchema, AgentGraphApiSelectSchema, AgentGraphApiUpdateSchema, AgentGraphInsertSchema, AgentGraphSelectSchema, AgentGraphUpdateSchema, AgentInsertSchema, AgentRelationApiInsertSchema, AgentRelationApiSelectSchema, AgentRelationApiUpdateSchema, AgentRelationInsertSchema, AgentRelationQuerySchema, AgentRelationSelectSchema, AgentRelationUpdateSchema, AgentSelectSchema, AgentStopWhenSchema, AgentToolRelationApiInsertSchema, AgentToolRelationApiSelectSchema, AgentToolRelationApiUpdateSchema, AgentToolRelationInsertSchema, AgentToolRelationSelectSchema, AgentToolRelationUpdateSchema, AgentUpdateSchema, AllAgentSchema, ApiKeyApiCreationResponseSchema, ApiKeyApiInsertSchema, ApiKeyApiSelectSchema, ApiKeyApiUpdateSchema, ApiKeyInsertSchema, ApiKeySelectSchema, ApiKeyUpdateSchema, ArtifactComponentApiInsertSchema, ArtifactComponentApiSelectSchema, ArtifactComponentApiUpdateSchema, ArtifactComponentInsertSchema, ArtifactComponentSelectSchema, ArtifactComponentUpdateSchema, CanUseItemSchema, ContextCacheApiInsertSchema, ContextCacheApiSelectSchema, ContextCacheApiUpdateSchema, ContextCacheInsertSchema, ContextCacheSelectSchema, ContextCacheUpdateSchema, ContextConfigApiInsertSchema, ContextConfigApiSelectSchema, ContextConfigApiUpdateSchema, ContextConfigInsertSchema, ContextConfigSelectSchema, ContextConfigUpdateSchema, ConversationApiInsertSchema, ConversationApiSelectSchema, ConversationApiUpdateSchema, ConversationInsertSchema, ConversationSelectSchema, ConversationUpdateSchema, CredentialReferenceApiInsertSchema, CredentialReferenceApiSelectSchema, CredentialReferenceApiUpdateSchema, CredentialReferenceInsertSchema, CredentialReferenceSelectSchema, CredentialReferenceUpdateSchema, DataComponentApiInsertSchema, DataComponentApiSelectSchema, DataComponentApiUpdateSchema, DataComponentBaseSchema, DataComponentInsertSchema, DataComponentSelectSchema, DataComponentUpdateSchema, ErrorResponseSchema, ExistsResponseSchema, ExternalAgentApiInsertSchema, ExternalAgentApiSelectSchema, ExternalAgentApiUpdateSchema, ExternalAgentInsertSchema, ExternalAgentRelationApiInsertSchema, ExternalAgentRelationInsertSchema, ExternalAgentSelectSchema, ExternalAgentUpdateSchema, FetchConfigSchema, FetchDefinitionSchema, FullGraphAgentInsertSchema, FullGraphDefinitionSchema, FullProjectDefinitionSchema, FunctionApiInsertSchema, FunctionApiSelectSchema, FunctionApiUpdateSchema, FunctionInsertSchema, FunctionSelectSchema, FunctionToolConfigSchema, FunctionUpdateSchema, GraphStopWhenSchema, GraphWithinContextOfProjectSchema, HeadersScopeSchema, IdParamsSchema, LedgerArtifactApiInsertSchema, LedgerArtifactApiSelectSchema, LedgerArtifactApiUpdateSchema, LedgerArtifactInsertSchema, LedgerArtifactSelectSchema, LedgerArtifactUpdateSchema, ListResponseSchema, MAX_ID_LENGTH, MCPToolConfigSchema, MIN_ID_LENGTH, McpToolDefinitionSchema, McpToolSchema, McpTransportConfigSchema, MessageApiInsertSchema, MessageApiSelectSchema, MessageApiUpdateSchema, MessageInsertSchema, MessageSelectSchema, MessageUpdateSchema, ModelSchema, ModelSettingsSchema, PaginationQueryParamsSchema, PaginationSchema, ProjectApiInsertSchema, ProjectApiSelectSchema, ProjectApiUpdateSchema, ProjectInsertSchema, ProjectModelSchema, ProjectSelectSchema, ProjectUpdateSchema, RemovedResponseSchema, SandboxConfigSchema, SingleResponseSchema, StatusComponentSchema, StatusUpdateSchema, StopWhenSchema, TaskApiInsertSchema, TaskApiSelectSchema, TaskApiUpdateSchema, TaskInsertSchema, TaskRelationApiInsertSchema, TaskRelationApiSelectSchema, TaskRelationApiUpdateSchema, TaskRelationInsertSchema, TaskRelationSelectSchema, TaskRelationUpdateSchema, TaskSelectSchema, TaskUpdateSchema, TenantIdParamsSchema, TenantParamsSchema, TenantProjectGraphIdParamsSchema, TenantProjectGraphParamsSchema, TenantProjectIdParamsSchema, TenantProjectParamsSchema, ToolApiInsertSchema, ToolApiSelectSchema, ToolApiUpdateSchema, ToolInsertSchema, ToolSelectSchema, ToolStatusSchema, ToolUpdateSchema, URL_SAFE_ID_PATTERN, resourceIdSchema, validatePropsAsJsonSchema };
@@ -33,6 +33,8 @@ __export(schema_exports, {
33
33
  dataComponentsRelations: () => dataComponentsRelations,
34
34
  externalAgents: () => externalAgents,
35
35
  externalAgentsRelations: () => externalAgentsRelations,
36
+ functions: () => functions,
37
+ functionsRelations: () => functionsRelations,
36
38
  ledgerArtifacts: () => ledgerArtifacts,
37
39
  ledgerArtifactsRelations: () => ledgerArtifactsRelations,
38
40
  messages: () => messages,
@@ -79,6 +81,8 @@ var projects = sqliteTable(
79
81
  models: text("models", { mode: "json" }).$type(),
80
82
  // Project-level stopWhen configuration that can be inherited by graphs and agents
81
83
  stopWhen: text("stop_when", { mode: "json" }).$type(),
84
+ // Project-level sandbox configuration for function execution
85
+ sandboxConfig: text("sandbox_config", { mode: "json" }).$type(),
82
86
  ...timestamps
83
87
  },
84
88
  (table) => [primaryKey({ columns: [table.tenantId, table.id] })]
@@ -116,9 +120,8 @@ var contextConfigs = sqliteTable(
116
120
  "context_configs",
117
121
  {
118
122
  ...graphScoped,
119
- ...uiProperties,
120
123
  // Developer-defined Zod schema for validating incoming request context
121
- requestContextSchema: blob("request_context_schema", { mode: "json" }).$type(),
124
+ headersSchema: blob("headers_schema", { mode: "json" }).$type(),
122
125
  // Stores serialized Zod schema
123
126
  // Object mapping template keys to fetch definitions that use request context data
124
127
  contextVariables: blob("context_variables", { mode: "json" }).$type(),
@@ -325,8 +328,7 @@ var artifactComponents = sqliteTable(
325
328
  {
326
329
  ...projectScoped,
327
330
  ...uiProperties,
328
- summaryProps: blob("summary_props", { mode: "json" }).$type(),
329
- fullProps: blob("full_props", { mode: "json" }).$type(),
331
+ props: blob("props", { mode: "json" }).$type(),
330
332
  ...timestamps
331
333
  },
332
334
  (table) => [
@@ -372,13 +374,16 @@ var tools = sqliteTable(
372
374
  {
373
375
  ...projectScoped,
374
376
  name: text("name").notNull(),
375
- // Enhanced MCP configuration
377
+ description: text("description"),
378
+ // Tool configuration - supports both MCP and function tools
376
379
  config: blob("config", { mode: "json" }).$type().notNull(),
380
+ // For function tools, reference the global functions table
381
+ functionId: text("function_id"),
377
382
  credentialReferenceId: text("credential_reference_id"),
378
383
  headers: blob("headers", { mode: "json" }).$type(),
379
384
  // Image URL for custom tool icon (supports regular URLs and base64 encoded images)
380
385
  imageUrl: text("image_url"),
381
- // Server capabilities and status
386
+ // Server capabilities and status (only for MCP tools)
382
387
  capabilities: blob("capabilities", { mode: "json" }).$type(),
383
388
  lastError: text("last_error"),
384
389
  ...timestamps
@@ -389,6 +394,30 @@ var tools = sqliteTable(
389
394
  columns: [table.tenantId, table.projectId],
390
395
  foreignColumns: [projects.tenantId, projects.id],
391
396
  name: "tools_project_fk"
397
+ }).onDelete("cascade"),
398
+ // Foreign key constraint to functions table (for function tools)
399
+ foreignKey({
400
+ columns: [table.tenantId, table.projectId, table.functionId],
401
+ foreignColumns: [functions.tenantId, functions.projectId, functions.id],
402
+ name: "tools_function_fk"
403
+ }).onDelete("cascade")
404
+ ]
405
+ );
406
+ var functions = sqliteTable(
407
+ "functions",
408
+ {
409
+ ...projectScoped,
410
+ inputSchema: blob("input_schema", { mode: "json" }).$type(),
411
+ executeCode: text("execute_code").notNull(),
412
+ dependencies: blob("dependencies", { mode: "json" }).$type(),
413
+ ...timestamps
414
+ },
415
+ (table) => [
416
+ primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
417
+ foreignKey({
418
+ columns: [table.tenantId, table.projectId],
419
+ foreignColumns: [projects.tenantId, projects.id],
420
+ name: "functions_project_fk"
392
421
  }).onDelete("cascade")
393
422
  ]
394
423
  );
@@ -723,6 +752,10 @@ var toolsRelations = relations(tools, ({ one, many }) => ({
723
752
  credentialReference: one(credentialReferences, {
724
753
  fields: [tools.credentialReferenceId],
725
754
  references: [credentialReferences.id]
755
+ }),
756
+ function: one(functions, {
757
+ fields: [tools.functionId],
758
+ references: [functions.id]
726
759
  })
727
760
  }));
728
761
  var conversationsRelations = relations(conversations, ({ one, many }) => ({
@@ -820,6 +853,9 @@ var ledgerArtifactsRelations = relations(ledgerArtifacts, ({ one }) => ({
820
853
  references: [tasks.id]
821
854
  })
822
855
  }));
856
+ var functionsRelations = relations(functions, ({ many }) => ({
857
+ tools: many(tools)
858
+ }));
823
859
  var agentRelationsRelations = relations(agentRelations, ({ one }) => ({
824
860
  graph: one(agentGraph, {
825
861
  fields: [agentRelations.graphId],
@@ -841,4 +877,4 @@ var agentRelationsRelations = relations(agentRelations, ({ one }) => ({
841
877
  })
842
878
  }));
843
879
 
844
- export { agentArtifactComponents, agentArtifactComponentsRelations, agentDataComponents, agentDataComponentsRelations, agentGraph, agentGraphRelations, agentRelations, agentRelationsRelations, agentToolRelations, agentToolRelationsRelations, agents, agentsRelations, apiKeys, apiKeysRelations, artifactComponents, artifactComponentsRelations, contextCache, contextCacheRelations, contextConfigs, contextConfigsRelations, conversations, conversationsRelations, credentialReferences, credentialReferencesRelations, dataComponents, dataComponentsRelations, externalAgents, externalAgentsRelations, ledgerArtifacts, ledgerArtifactsRelations, messages, messagesRelations, projects, projectsRelations, schema_exports, taskRelations, taskRelationsRelations, tasks, tasksRelations, tools, toolsRelations };
880
+ export { agentArtifactComponents, agentArtifactComponentsRelations, agentDataComponents, agentDataComponentsRelations, agentGraph, agentGraphRelations, agentRelations, agentRelationsRelations, agentToolRelations, agentToolRelationsRelations, agents, agentsRelations, apiKeys, apiKeysRelations, artifactComponents, artifactComponentsRelations, contextCache, contextCacheRelations, contextConfigs, contextConfigsRelations, conversations, conversationsRelations, credentialReferences, credentialReferencesRelations, dataComponents, dataComponentsRelations, externalAgents, externalAgentsRelations, functions, functionsRelations, ledgerArtifacts, ledgerArtifactsRelations, messages, messagesRelations, projects, projectsRelations, schema_exports, taskRelations, taskRelationsRelations, tasks, tasksRelations, tools, toolsRelations };