@inkeep/agents-core 0.0.0-dev-20251008194140 → 0.0.0-dev-20251009000750
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-FMCAYVO7.js → chunk-HZZTBK7Y.js} +164 -7
- package/dist/{chunk-FLKAMXLV.js → chunk-MLKHAZVU.js} +1 -1
- package/dist/chunk-R2EERZSW.js +223 -0
- package/dist/{chunk-AHSEMW6N.js → chunk-TN5JDW2L.js} +42 -5
- package/dist/client-exports.cjs +211 -16
- package/dist/client-exports.d.cts +12 -8
- package/dist/client-exports.d.ts +12 -8
- package/dist/client-exports.js +4 -10
- package/dist/db/schema.cjs +41 -4
- 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 +3117 -2627
- package/dist/index.d.cts +106 -27
- package/dist/index.d.ts +106 -27
- package/dist/index.js +2428 -2371
- 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-DKTW_XSC.d.cts} +251 -24
- package/dist/{schema-CTBfyt-o.d.cts → schema-DfH0zjbm.d.ts} +251 -24
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/{utility-BMAHFZX6.d.cts → utility-BHDxGp6I.d.cts} +693 -128
- package/dist/{utility-BMAHFZX6.d.ts → utility-BHDxGp6I.d.ts} +693 -128
- 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 +214 -9
- 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_brown_marvel_apes.sql +16 -0
- package/drizzle/0002_bumpy_romulus.sql +3 -0
- package/drizzle/0003_gifted_doctor_spectrum.sql +343 -0
- package/drizzle/meta/{0001_snapshot.json → 0002_snapshot.json} +4 -11
- package/drizzle/meta/{0000_snapshot.json → 0003_snapshot.json} +150 -16
- package/drizzle/meta/_journal.json +14 -0
- package/package.json +1 -1
|
@@ -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-
|
|
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-TN5JDW2L.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"),
|
|
@@ -466,6 +514,7 @@ var CanUseItemSchema = z.object({
|
|
|
466
514
|
var FullGraphAgentInsertSchema = AgentApiInsertSchema.extend({
|
|
467
515
|
type: z.literal("internal"),
|
|
468
516
|
canUse: z.array(CanUseItemSchema),
|
|
517
|
+
// All tools (both MCP and function tools)
|
|
469
518
|
dataComponents: z.array(z.string()).optional(),
|
|
470
519
|
artifactComponents: z.array(z.string()).optional(),
|
|
471
520
|
canTransferTo: z.array(z.string()).optional(),
|
|
@@ -473,9 +522,11 @@ var FullGraphAgentInsertSchema = AgentApiInsertSchema.extend({
|
|
|
473
522
|
});
|
|
474
523
|
var FullGraphDefinitionSchema = AgentGraphApiInsertSchema.extend({
|
|
475
524
|
agents: z.record(z.string(), z.union([FullGraphAgentInsertSchema, ExternalAgentApiInsertSchema])),
|
|
476
|
-
//
|
|
477
|
-
|
|
478
|
-
//
|
|
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
|
|
479
530
|
contextConfig: z.optional(ContextConfigApiInsertSchema),
|
|
480
531
|
statusUpdates: z.optional(StatusUpdateSchema),
|
|
481
532
|
models: ModelSchema.optional(),
|
|
@@ -524,7 +575,8 @@ var RemovedResponseSchema = z.object({
|
|
|
524
575
|
var ProjectSelectSchema = createSelectSchema(projects);
|
|
525
576
|
var ProjectInsertSchema = createInsertSchema(projects).extend({
|
|
526
577
|
models: ProjectModelSchema,
|
|
527
|
-
stopWhen: StopWhenSchema.optional()
|
|
578
|
+
stopWhen: StopWhenSchema.optional(),
|
|
579
|
+
sandboxConfig: SandboxConfigSchema.optional()
|
|
528
580
|
}).omit({
|
|
529
581
|
createdAt: true,
|
|
530
582
|
updatedAt: true
|
|
@@ -536,6 +588,9 @@ var ProjectApiUpdateSchema = ProjectUpdateSchema.omit({ tenantId: true });
|
|
|
536
588
|
var FullProjectDefinitionSchema = ProjectApiInsertSchema.extend({
|
|
537
589
|
graphs: z.record(z.string(), GraphWithinContextOfProjectSchema),
|
|
538
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
|
|
539
594
|
dataComponents: z.record(z.string(), DataComponentApiInsertSchema).optional(),
|
|
540
595
|
artifactComponents: z.record(z.string(), ArtifactComponentApiInsertSchema).optional(),
|
|
541
596
|
statusUpdates: z.optional(StatusUpdateSchema),
|
|
@@ -627,5 +682,107 @@ var PaginationQueryParamsSchema = z.object({
|
|
|
627
682
|
page: z.coerce.number().min(1).default(1),
|
|
628
683
|
limit: z.coerce.number().min(1).max(100).default(10)
|
|
629
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
|
+
}
|
|
630
787
|
|
|
631
|
-
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 };
|
|
@@ -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 };
|
|
@@ -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] })]
|
|
@@ -325,8 +329,7 @@ var artifactComponents = sqliteTable(
|
|
|
325
329
|
{
|
|
326
330
|
...projectScoped,
|
|
327
331
|
...uiProperties,
|
|
328
|
-
|
|
329
|
-
fullProps: blob("full_props", { mode: "json" }).$type(),
|
|
332
|
+
props: blob("props", { mode: "json" }).$type(),
|
|
330
333
|
...timestamps
|
|
331
334
|
},
|
|
332
335
|
(table) => [
|
|
@@ -372,13 +375,16 @@ var tools = sqliteTable(
|
|
|
372
375
|
{
|
|
373
376
|
...projectScoped,
|
|
374
377
|
name: text("name").notNull(),
|
|
375
|
-
|
|
378
|
+
description: text("description"),
|
|
379
|
+
// Tool configuration - supports both MCP and function tools
|
|
376
380
|
config: blob("config", { mode: "json" }).$type().notNull(),
|
|
381
|
+
// For function tools, reference the global functions table
|
|
382
|
+
functionId: text("function_id"),
|
|
377
383
|
credentialReferenceId: text("credential_reference_id"),
|
|
378
384
|
headers: blob("headers", { mode: "json" }).$type(),
|
|
379
385
|
// Image URL for custom tool icon (supports regular URLs and base64 encoded images)
|
|
380
386
|
imageUrl: text("image_url"),
|
|
381
|
-
// Server capabilities and status
|
|
387
|
+
// Server capabilities and status (only for MCP tools)
|
|
382
388
|
capabilities: blob("capabilities", { mode: "json" }).$type(),
|
|
383
389
|
lastError: text("last_error"),
|
|
384
390
|
...timestamps
|
|
@@ -389,6 +395,30 @@ var tools = sqliteTable(
|
|
|
389
395
|
columns: [table.tenantId, table.projectId],
|
|
390
396
|
foreignColumns: [projects.tenantId, projects.id],
|
|
391
397
|
name: "tools_project_fk"
|
|
398
|
+
}).onDelete("cascade"),
|
|
399
|
+
// Foreign key constraint to functions table (for function tools)
|
|
400
|
+
foreignKey({
|
|
401
|
+
columns: [table.tenantId, table.projectId, table.functionId],
|
|
402
|
+
foreignColumns: [functions.tenantId, functions.projectId, functions.id],
|
|
403
|
+
name: "tools_function_fk"
|
|
404
|
+
}).onDelete("cascade")
|
|
405
|
+
]
|
|
406
|
+
);
|
|
407
|
+
var functions = sqliteTable(
|
|
408
|
+
"functions",
|
|
409
|
+
{
|
|
410
|
+
...projectScoped,
|
|
411
|
+
inputSchema: blob("input_schema", { mode: "json" }).$type(),
|
|
412
|
+
executeCode: text("execute_code").notNull(),
|
|
413
|
+
dependencies: blob("dependencies", { mode: "json" }).$type(),
|
|
414
|
+
...timestamps
|
|
415
|
+
},
|
|
416
|
+
(table) => [
|
|
417
|
+
primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
418
|
+
foreignKey({
|
|
419
|
+
columns: [table.tenantId, table.projectId],
|
|
420
|
+
foreignColumns: [projects.tenantId, projects.id],
|
|
421
|
+
name: "functions_project_fk"
|
|
392
422
|
}).onDelete("cascade")
|
|
393
423
|
]
|
|
394
424
|
);
|
|
@@ -723,6 +753,10 @@ var toolsRelations = relations(tools, ({ one, many }) => ({
|
|
|
723
753
|
credentialReference: one(credentialReferences, {
|
|
724
754
|
fields: [tools.credentialReferenceId],
|
|
725
755
|
references: [credentialReferences.id]
|
|
756
|
+
}),
|
|
757
|
+
function: one(functions, {
|
|
758
|
+
fields: [tools.functionId],
|
|
759
|
+
references: [functions.id]
|
|
726
760
|
})
|
|
727
761
|
}));
|
|
728
762
|
var conversationsRelations = relations(conversations, ({ one, many }) => ({
|
|
@@ -820,6 +854,9 @@ var ledgerArtifactsRelations = relations(ledgerArtifacts, ({ one }) => ({
|
|
|
820
854
|
references: [tasks.id]
|
|
821
855
|
})
|
|
822
856
|
}));
|
|
857
|
+
var functionsRelations = relations(functions, ({ many }) => ({
|
|
858
|
+
tools: many(tools)
|
|
859
|
+
}));
|
|
823
860
|
var agentRelationsRelations = relations(agentRelations, ({ one }) => ({
|
|
824
861
|
graph: one(agentGraph, {
|
|
825
862
|
fields: [agentRelations.graphId],
|
|
@@ -841,4 +878,4 @@ var agentRelationsRelations = relations(agentRelations, ({ one }) => ({
|
|
|
841
878
|
})
|
|
842
879
|
}));
|
|
843
880
|
|
|
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 };
|
|
881
|
+
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 };
|