@inkeep/agents-core 0.1.4 → 0.1.6
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/SUPPLEMENTAL_TERMS.md +40 -0
- package/dist/chunk-H2F72PDA.js +15 -0
- package/dist/chunk-M4JXMAG7.js +822 -0
- package/dist/chunk-MKBO26DX.js +9 -0
- package/dist/chunk-RZPLS4MU.js +676 -0
- package/dist/chunk-SVGQSPW4.js +24 -0
- package/dist/client-exports.cjs +246 -0
- package/dist/client-exports.d.cts +315 -0
- package/dist/client-exports.d.ts +64 -49
- package/dist/client-exports.js +201 -246
- package/dist/db/schema.cjs +819 -0
- package/dist/db/schema.d.cts +8 -0
- package/dist/db/schema.d.ts +8 -4337
- package/dist/db/schema.js +1 -696
- package/dist/entities-CNJaf-rG.d.cts +7849 -0
- package/dist/entities-CNJaf-rG.d.ts +7849 -0
- package/dist/index.cjs +9647 -0
- package/dist/index.d.cts +3991 -0
- package/dist/index.d.ts +3991 -12
- package/dist/index.js +7646 -13
- package/dist/schema-DFDqtBpV.d.ts +4401 -0
- package/dist/schema-Dbc3UMpd.d.cts +4401 -0
- package/dist/types/index.cjs +45 -0
- package/dist/types/index.d.cts +125 -0
- package/dist/types/index.d.ts +125 -5
- package/dist/types/index.js +2 -6
- package/dist/validation/index.cjs +1642 -0
- package/dist/validation/index.d.cts +64 -0
- package/dist/validation/index.d.ts +64 -4
- package/dist/validation/index.js +1 -5
- package/package.json +6 -4
- package/dist/__tests__/integration/helpers.d.ts +0 -5
- package/dist/__tests__/integration/helpers.d.ts.map +0 -1
- package/dist/__tests__/integration/helpers.js +0 -37
- package/dist/__tests__/integration/helpers.js.map +0 -1
- package/dist/__tests__/setup.d.ts +0 -3
- package/dist/__tests__/setup.d.ts.map +0 -1
- package/dist/__tests__/setup.js +0 -29
- package/dist/__tests__/setup.js.map +0 -1
- package/dist/client-exports.d.ts.map +0 -1
- package/dist/client-exports.js.map +0 -1
- package/dist/context/ContextConfig.d.ts +0 -54
- package/dist/context/ContextConfig.d.ts.map +0 -1
- package/dist/context/ContextConfig.js +0 -302
- package/dist/context/ContextConfig.js.map +0 -1
- package/dist/context/ContextFetcher.d.ts +0 -64
- package/dist/context/ContextFetcher.d.ts.map +0 -1
- package/dist/context/ContextFetcher.js +0 -325
- package/dist/context/ContextFetcher.js.map +0 -1
- package/dist/context/ContextResolver.d.ts +0 -52
- package/dist/context/ContextResolver.d.ts.map +0 -1
- package/dist/context/ContextResolver.js +0 -298
- package/dist/context/ContextResolver.js.map +0 -1
- package/dist/context/TemplateEngine.d.ts +0 -46
- package/dist/context/TemplateEngine.d.ts.map +0 -1
- package/dist/context/TemplateEngine.js +0 -175
- package/dist/context/TemplateEngine.js.map +0 -1
- package/dist/context/context.d.ts +0 -8
- package/dist/context/context.d.ts.map +0 -1
- package/dist/context/context.js +0 -157
- package/dist/context/context.js.map +0 -1
- package/dist/context/contextCache.d.ts +0 -50
- package/dist/context/contextCache.d.ts.map +0 -1
- package/dist/context/contextCache.js +0 -175
- package/dist/context/contextCache.js.map +0 -1
- package/dist/context/index.d.ts +0 -11
- package/dist/context/index.d.ts.map +0 -1
- package/dist/context/index.js +0 -8
- package/dist/context/index.js.map +0 -1
- package/dist/credential-stores/CredentialStoreRegistry.d.ts +0 -39
- package/dist/credential-stores/CredentialStoreRegistry.d.ts.map +0 -1
- package/dist/credential-stores/CredentialStoreRegistry.js +0 -65
- package/dist/credential-stores/CredentialStoreRegistry.js.map +0 -1
- package/dist/credential-stores/defaults.d.ts +0 -6
- package/dist/credential-stores/defaults.d.ts.map +0 -1
- package/dist/credential-stores/defaults.js +0 -22
- package/dist/credential-stores/defaults.js.map +0 -1
- package/dist/credential-stores/index.d.ts +0 -6
- package/dist/credential-stores/index.d.ts.map +0 -1
- package/dist/credential-stores/index.js +0 -6
- package/dist/credential-stores/index.js.map +0 -1
- package/dist/credential-stores/keychain-store.d.ts +0 -100
- package/dist/credential-stores/keychain-store.d.ts.map +0 -1
- package/dist/credential-stores/keychain-store.js +0 -225
- package/dist/credential-stores/keychain-store.js.map +0 -1
- package/dist/credential-stores/memory-store.d.ts +0 -39
- package/dist/credential-stores/memory-store.d.ts.map +0 -1
- package/dist/credential-stores/memory-store.js +0 -58
- package/dist/credential-stores/memory-store.js.map +0 -1
- package/dist/credential-stores/nango-store.d.ts +0 -59
- package/dist/credential-stores/nango-store.d.ts.map +0 -1
- package/dist/credential-stores/nango-store.js +0 -264
- package/dist/credential-stores/nango-store.js.map +0 -1
- package/dist/credential-stuffer/CredentialStuffer.d.ts +0 -80
- package/dist/credential-stuffer/CredentialStuffer.d.ts.map +0 -1
- package/dist/credential-stuffer/CredentialStuffer.js +0 -186
- package/dist/credential-stuffer/CredentialStuffer.js.map +0 -1
- package/dist/credential-stuffer/index.d.ts +0 -2
- package/dist/credential-stuffer/index.d.ts.map +0 -1
- package/dist/credential-stuffer/index.js +0 -2
- package/dist/credential-stuffer/index.js.map +0 -1
- package/dist/data-access/agentDataComponents.d.ts +0 -1
- package/dist/data-access/agentDataComponents.d.ts.map +0 -1
- package/dist/data-access/agentDataComponents.js +0 -2
- package/dist/data-access/agentDataComponents.js.map +0 -1
- package/dist/data-access/agentGraphs.d.ts +0 -406
- package/dist/data-access/agentGraphs.d.ts.map +0 -1
- package/dist/data-access/agentGraphs.js +0 -551
- package/dist/data-access/agentGraphs.js.map +0 -1
- package/dist/data-access/agentRelations.d.ts +0 -456
- package/dist/data-access/agentRelations.d.ts.map +0 -1
- package/dist/data-access/agentRelations.js +0 -471
- package/dist/data-access/agentRelations.js.map +0 -1
- package/dist/data-access/agents.d.ts +0 -218
- package/dist/data-access/agents.d.ts.map +0 -1
- package/dist/data-access/agents.js +0 -130
- package/dist/data-access/agents.js.map +0 -1
- package/dist/data-access/apiKeys.d.ts +0 -114
- package/dist/data-access/apiKeys.d.ts.map +0 -1
- package/dist/data-access/apiKeys.js +0 -185
- package/dist/data-access/apiKeys.js.map +0 -1
- package/dist/data-access/artifactComponents.d.ts +0 -152
- package/dist/data-access/artifactComponents.d.ts.map +0 -1
- package/dist/data-access/artifactComponents.js +0 -214
- package/dist/data-access/artifactComponents.js.map +0 -1
- package/dist/data-access/contextCache.d.ts +0 -68
- package/dist/data-access/contextCache.d.ts.map +0 -1
- package/dist/data-access/contextCache.js +0 -160
- package/dist/data-access/contextCache.js.map +0 -1
- package/dist/data-access/contextConfigs.d.ts +0 -110
- package/dist/data-access/contextConfigs.d.ts.map +0 -1
- package/dist/data-access/contextConfigs.js +0 -156
- package/dist/data-access/contextConfigs.js.map +0 -1
- package/dist/data-access/conversations.d.ts +0 -125
- package/dist/data-access/conversations.d.ts.map +0 -1
- package/dist/data-access/conversations.js +0 -244
- package/dist/data-access/conversations.js.map +0 -1
- package/dist/data-access/credentialReferences.d.ts +0 -86
- package/dist/data-access/credentialReferences.d.ts.map +0 -1
- package/dist/data-access/credentialReferences.js +0 -175
- package/dist/data-access/credentialReferences.js.map +0 -1
- package/dist/data-access/dataComponents.d.ts +0 -129
- package/dist/data-access/dataComponents.d.ts.map +0 -1
- package/dist/data-access/dataComponents.js +0 -213
- package/dist/data-access/dataComponents.js.map +0 -1
- package/dist/data-access/externalAgents.d.ts +0 -83
- package/dist/data-access/externalAgents.d.ts.map +0 -1
- package/dist/data-access/externalAgents.js +0 -163
- package/dist/data-access/externalAgents.js.map +0 -1
- package/dist/data-access/graphFull.d.ts +0 -32
- package/dist/data-access/graphFull.d.ts.map +0 -1
- package/dist/data-access/graphFull.js +0 -996
- package/dist/data-access/graphFull.js.map +0 -1
- package/dist/data-access/index.d.ts +0 -21
- package/dist/data-access/index.d.ts.map +0 -1
- package/dist/data-access/index.js +0 -22
- package/dist/data-access/index.js.map +0 -1
- package/dist/data-access/ledgerArtifacts.d.ts +0 -49
- package/dist/data-access/ledgerArtifacts.d.ts.map +0 -1
- package/dist/data-access/ledgerArtifacts.js +0 -112
- package/dist/data-access/ledgerArtifacts.js.map +0 -1
- package/dist/data-access/messages.d.ts +0 -209
- package/dist/data-access/messages.d.ts.map +0 -1
- package/dist/data-access/messages.js +0 -100
- package/dist/data-access/messages.js.map +0 -1
- package/dist/data-access/projects.d.ts +0 -67
- package/dist/data-access/projects.d.ts.map +0 -1
- package/dist/data-access/projects.js +0 -337
- package/dist/data-access/projects.js.map +0 -1
- package/dist/data-access/tasks.d.ts +0 -37
- package/dist/data-access/tasks.d.ts.map +0 -1
- package/dist/data-access/tasks.js +0 -40
- package/dist/data-access/tasks.js.map +0 -1
- package/dist/data-access/tools.d.ts +0 -277
- package/dist/data-access/tools.d.ts.map +0 -1
- package/dist/data-access/tools.js +0 -183
- package/dist/data-access/tools.js.map +0 -1
- package/dist/data-access/validation.d.ts +0 -17
- package/dist/data-access/validation.d.ts.map +0 -1
- package/dist/data-access/validation.js +0 -52
- package/dist/data-access/validation.js.map +0 -1
- package/dist/db/clean.d.ts +0 -6
- package/dist/db/clean.d.ts.map +0 -1
- package/dist/db/clean.js +0 -81
- package/dist/db/clean.js.map +0 -1
- package/dist/db/client.d.ts +0 -19
- package/dist/db/client.d.ts.map +0 -1
- package/dist/db/client.js +0 -24
- package/dist/db/client.js.map +0 -1
- package/dist/db/schema.d.ts.map +0 -1
- package/dist/db/schema.js.map +0 -1
- package/dist/db/test-client.d.ts +0 -25
- package/dist/db/test-client.d.ts.map +0 -1
- package/dist/db/test-client.js +0 -136
- package/dist/db/test-client.js.map +0 -1
- package/dist/env.d.ts +0 -19
- package/dist/env.d.ts.map +0 -1
- package/dist/env.js +0 -49
- package/dist/env.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/middleware/contextValidation.d.ts +0 -49
- package/dist/middleware/contextValidation.d.ts.map +0 -1
- package/dist/middleware/contextValidation.js +0 -473
- package/dist/middleware/contextValidation.js.map +0 -1
- package/dist/middleware/index.d.ts +0 -2
- package/dist/middleware/index.d.ts.map +0 -1
- package/dist/middleware/index.js +0 -2
- package/dist/middleware/index.js.map +0 -1
- package/dist/server/BaseServer.d.ts +0 -83
- package/dist/server/BaseServer.d.ts.map +0 -1
- package/dist/server/BaseServer.js +0 -218
- package/dist/server/BaseServer.js.map +0 -1
- package/dist/types/a2a.d.ts +0 -373
- package/dist/types/a2a.d.ts.map +0 -1
- package/dist/types/a2a.js +0 -14
- package/dist/types/a2a.js.map +0 -1
- package/dist/types/entities.d.ts +0 -147
- package/dist/types/entities.d.ts.map +0 -1
- package/dist/types/entities.js +0 -2
- package/dist/types/entities.js.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js.map +0 -1
- package/dist/types/server.d.ts +0 -116
- package/dist/types/server.d.ts.map +0 -1
- package/dist/types/server.js +0 -2
- package/dist/types/server.js.map +0 -1
- package/dist/types/utility.d.ts +0 -213
- package/dist/types/utility.d.ts.map +0 -1
- package/dist/types/utility.js +0 -9
- package/dist/types/utility.js.map +0 -1
- package/dist/utils/apiKeys.d.ts +0 -32
- package/dist/utils/apiKeys.d.ts.map +0 -1
- package/dist/utils/apiKeys.js +0 -117
- package/dist/utils/apiKeys.js.map +0 -1
- package/dist/utils/auth-detection.d.ts +0 -23
- package/dist/utils/auth-detection.d.ts.map +0 -1
- package/dist/utils/auth-detection.js +0 -148
- package/dist/utils/auth-detection.js.map +0 -1
- package/dist/utils/credential-store-utils.d.ts +0 -11
- package/dist/utils/credential-store-utils.d.ts.map +0 -1
- package/dist/utils/credential-store-utils.js +0 -19
- package/dist/utils/credential-store-utils.js.map +0 -1
- package/dist/utils/error.d.ts +0 -526
- package/dist/utils/error.d.ts.map +0 -1
- package/dist/utils/error.js +0 -282
- package/dist/utils/error.js.map +0 -1
- package/dist/utils/execution.d.ts +0 -18
- package/dist/utils/execution.d.ts.map +0 -1
- package/dist/utils/execution.js +0 -25
- package/dist/utils/execution.js.map +0 -1
- package/dist/utils/index.d.ts +0 -9
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -9
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/logger.d.ts +0 -79
- package/dist/utils/logger.d.ts.map +0 -1
- package/dist/utils/logger.js +0 -102
- package/dist/utils/logger.js.map +0 -1
- package/dist/utils/logging.d.ts +0 -11
- package/dist/utils/logging.d.ts.map +0 -1
- package/dist/utils/logging.js +0 -6
- package/dist/utils/logging.js.map +0 -1
- package/dist/utils/mcp-client.d.ts +0 -48
- package/dist/utils/mcp-client.d.ts.map +0 -1
- package/dist/utils/mcp-client.js +0 -174
- package/dist/utils/mcp-client.js.map +0 -1
- package/dist/utils/tracer.d.ts +0 -24
- package/dist/utils/tracer.d.ts.map +0 -1
- package/dist/utils/tracer.js +0 -110
- package/dist/utils/tracer.js.map +0 -1
- package/dist/validation/graphFull.d.ts +0 -36
- package/dist/validation/graphFull.d.ts.map +0 -1
- package/dist/validation/graphFull.js +0 -128
- package/dist/validation/graphFull.js.map +0 -1
- package/dist/validation/id-validation.d.ts +0 -38
- package/dist/validation/id-validation.d.ts.map +0 -1
- package/dist/validation/id-validation.js +0 -60
- package/dist/validation/id-validation.js.map +0 -1
- package/dist/validation/index.d.ts.map +0 -1
- package/dist/validation/index.js.map +0 -1
- package/dist/validation/schemas.d.ts +0 -7238
- package/dist/validation/schemas.d.ts.map +0 -1
- package/dist/validation/schemas.js +0 -575
- package/dist/validation/schemas.js.map +0 -1
|
@@ -0,0 +1,822 @@
|
|
|
1
|
+
import { __export } from './chunk-MKBO26DX.js';
|
|
2
|
+
import { relations, sql } from 'drizzle-orm';
|
|
3
|
+
import { sqliteTable, index, unique, text, primaryKey, blob, integer, foreignKey } from 'drizzle-orm/sqlite-core';
|
|
4
|
+
|
|
5
|
+
// src/db/schema.ts
|
|
6
|
+
var schema_exports = {};
|
|
7
|
+
__export(schema_exports, {
|
|
8
|
+
agentArtifactComponents: () => agentArtifactComponents,
|
|
9
|
+
agentArtifactComponentsRelations: () => agentArtifactComponentsRelations,
|
|
10
|
+
agentDataComponents: () => agentDataComponents,
|
|
11
|
+
agentGraph: () => agentGraph,
|
|
12
|
+
agentGraphRelations: () => agentGraphRelations,
|
|
13
|
+
agentRelations: () => agentRelations,
|
|
14
|
+
agentRelationsRelations: () => agentRelationsRelations,
|
|
15
|
+
agentToolRelations: () => agentToolRelations,
|
|
16
|
+
agentToolRelationsRelations: () => agentToolRelationsRelations,
|
|
17
|
+
agents: () => agents,
|
|
18
|
+
agentsRelations: () => agentsRelations,
|
|
19
|
+
apiKeys: () => apiKeys,
|
|
20
|
+
apiKeysRelations: () => apiKeysRelations,
|
|
21
|
+
artifactComponents: () => artifactComponents,
|
|
22
|
+
artifactComponentsRelations: () => artifactComponentsRelations,
|
|
23
|
+
contextCache: () => contextCache,
|
|
24
|
+
contextCacheRelations: () => contextCacheRelations,
|
|
25
|
+
contextConfigs: () => contextConfigs,
|
|
26
|
+
contextConfigsRelations: () => contextConfigsRelations,
|
|
27
|
+
conversations: () => conversations,
|
|
28
|
+
conversationsRelations: () => conversationsRelations,
|
|
29
|
+
credentialReferences: () => credentialReferences,
|
|
30
|
+
credentialReferencesRelations: () => credentialReferencesRelations,
|
|
31
|
+
dataComponents: () => dataComponents,
|
|
32
|
+
externalAgents: () => externalAgents,
|
|
33
|
+
externalAgentsRelations: () => externalAgentsRelations,
|
|
34
|
+
ledgerArtifacts: () => ledgerArtifacts,
|
|
35
|
+
ledgerArtifactsContextIdIdx: () => ledgerArtifactsContextIdIdx,
|
|
36
|
+
ledgerArtifactsTaskContextNameUnique: () => ledgerArtifactsTaskContextNameUnique,
|
|
37
|
+
ledgerArtifactsTaskIdIdx: () => ledgerArtifactsTaskIdIdx,
|
|
38
|
+
messages: () => messages,
|
|
39
|
+
messagesRelations: () => messagesRelations,
|
|
40
|
+
projects: () => projects,
|
|
41
|
+
projectsRelations: () => projectsRelations,
|
|
42
|
+
taskRelations: () => taskRelations,
|
|
43
|
+
taskRelationsRelations: () => taskRelationsRelations,
|
|
44
|
+
tasks: () => tasks,
|
|
45
|
+
tasksRelations: () => tasksRelations,
|
|
46
|
+
tools: () => tools,
|
|
47
|
+
toolsRelations: () => toolsRelations
|
|
48
|
+
});
|
|
49
|
+
var projects = sqliteTable(
|
|
50
|
+
"projects",
|
|
51
|
+
{
|
|
52
|
+
tenantId: text("tenant_id").notNull(),
|
|
53
|
+
id: text("id").notNull(),
|
|
54
|
+
// This IS the project ID
|
|
55
|
+
name: text("name").notNull(),
|
|
56
|
+
description: text("description").notNull(),
|
|
57
|
+
// Project-level default model settingsuration that can be inherited by graphs and agents
|
|
58
|
+
models: text("models", { mode: "json" }).$type(),
|
|
59
|
+
// Project-level stopWhen configuration that can be inherited by graphs and agents
|
|
60
|
+
stopWhen: text("stop_when", { mode: "json" }).$type(),
|
|
61
|
+
createdAt: text("created_at").notNull().default(sql`CURRENT_TIMESTAMP`),
|
|
62
|
+
updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
|
|
63
|
+
},
|
|
64
|
+
(table) => [primaryKey({ columns: [table.tenantId, table.id] })]
|
|
65
|
+
);
|
|
66
|
+
var contextConfigs = sqliteTable(
|
|
67
|
+
"context_configs",
|
|
68
|
+
{
|
|
69
|
+
tenantId: text("tenant_id").notNull(),
|
|
70
|
+
projectId: text("project_id").notNull(),
|
|
71
|
+
id: text("id").notNull(),
|
|
72
|
+
name: text("name").notNull(),
|
|
73
|
+
description: text("description").notNull(),
|
|
74
|
+
// Developer-defined Zod schema for validating incoming request context
|
|
75
|
+
requestContextSchema: blob("request_context_schema", { mode: "json" }).$type(),
|
|
76
|
+
// Stores serialized Zod schema
|
|
77
|
+
// Object mapping template keys to fetch definitions that use request context data
|
|
78
|
+
contextVariables: blob("context_variables", { mode: "json" }).$type(),
|
|
79
|
+
createdAt: text("created_at").notNull().default(sql`CURRENT_TIMESTAMP`),
|
|
80
|
+
updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
|
|
81
|
+
},
|
|
82
|
+
(table) => [primaryKey({ columns: [table.tenantId, table.projectId, table.id] })]
|
|
83
|
+
);
|
|
84
|
+
var contextCache = sqliteTable(
|
|
85
|
+
"context_cache",
|
|
86
|
+
{
|
|
87
|
+
tenantId: text("tenant_id").notNull(),
|
|
88
|
+
projectId: text("project_id").notNull(),
|
|
89
|
+
id: text("id").notNull(),
|
|
90
|
+
// Always scoped to conversation for complete data isolation
|
|
91
|
+
conversationId: text("conversation_id").notNull(),
|
|
92
|
+
// Reference to the context config and specific fetch definition
|
|
93
|
+
contextConfigId: text("context_config_id").notNull(),
|
|
94
|
+
contextVariableKey: text("context_variable_key").notNull(),
|
|
95
|
+
// Key from contextVariables object
|
|
96
|
+
// The actual cached context data
|
|
97
|
+
value: blob("value", { mode: "json" }).$type().notNull(),
|
|
98
|
+
// Request hash for cache invalidation based on context changes
|
|
99
|
+
requestHash: text("request_hash"),
|
|
100
|
+
// Hash of request context that triggered this cache
|
|
101
|
+
// Metadata for monitoring and debugging
|
|
102
|
+
fetchedAt: text("fetched_at").notNull(),
|
|
103
|
+
fetchSource: text("fetch_source"),
|
|
104
|
+
// URL or source identifier
|
|
105
|
+
fetchDurationMs: integer("fetch_duration_ms"),
|
|
106
|
+
createdAt: text("created_at").notNull().default(sql`CURRENT_TIMESTAMP`),
|
|
107
|
+
updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
|
|
108
|
+
},
|
|
109
|
+
(table) => [
|
|
110
|
+
primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
111
|
+
index("context_cache_lookup_idx").on(
|
|
112
|
+
table.conversationId,
|
|
113
|
+
table.contextConfigId,
|
|
114
|
+
table.contextVariableKey
|
|
115
|
+
)
|
|
116
|
+
]
|
|
117
|
+
);
|
|
118
|
+
var agents = sqliteTable(
|
|
119
|
+
"agents",
|
|
120
|
+
{
|
|
121
|
+
tenantId: text("tenant_id").notNull(),
|
|
122
|
+
projectId: text("project_id").notNull(),
|
|
123
|
+
id: text("id").notNull(),
|
|
124
|
+
name: text("name").notNull(),
|
|
125
|
+
description: text("description").notNull(),
|
|
126
|
+
prompt: text("prompt").notNull(),
|
|
127
|
+
conversationHistoryConfig: text("conversation_history_config", {
|
|
128
|
+
mode: "json"
|
|
129
|
+
}).$type(),
|
|
130
|
+
models: text("models", { mode: "json" }).$type(),
|
|
131
|
+
// Agent-level stopWhen configuration (inherited from project)
|
|
132
|
+
stopWhen: text("stop_when", { mode: "json" }).$type(),
|
|
133
|
+
createdAt: text("created_at").notNull().default(sql`CURRENT_TIMESTAMP`),
|
|
134
|
+
updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
|
|
135
|
+
},
|
|
136
|
+
(table) => [
|
|
137
|
+
primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
138
|
+
foreignKey({
|
|
139
|
+
columns: [table.tenantId, table.projectId],
|
|
140
|
+
foreignColumns: [projects.tenantId, projects.id],
|
|
141
|
+
name: "agents_project_fk"
|
|
142
|
+
})
|
|
143
|
+
]
|
|
144
|
+
);
|
|
145
|
+
var agentRelations = sqliteTable(
|
|
146
|
+
"agent_relations",
|
|
147
|
+
{
|
|
148
|
+
tenantId: text("tenant_id").notNull(),
|
|
149
|
+
projectId: text("project_id").notNull(),
|
|
150
|
+
id: text("id").notNull(),
|
|
151
|
+
graphId: text("graph_id").notNull(),
|
|
152
|
+
sourceAgentId: text("source_agent_id").notNull(),
|
|
153
|
+
// For internal relationships
|
|
154
|
+
targetAgentId: text("target_agent_id"),
|
|
155
|
+
// For external relationships
|
|
156
|
+
externalAgentId: text("external_agent_id"),
|
|
157
|
+
relationType: text("relation_type"),
|
|
158
|
+
// 'transfer' | 'delegate'
|
|
159
|
+
createdAt: text("created_at").notNull().default(sql`CURRENT_TIMESTAMP`),
|
|
160
|
+
updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
|
|
161
|
+
},
|
|
162
|
+
(table) => [
|
|
163
|
+
primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
164
|
+
foreignKey({
|
|
165
|
+
columns: [table.tenantId, table.projectId],
|
|
166
|
+
foreignColumns: [projects.tenantId, projects.id],
|
|
167
|
+
name: "agent_relations_project_fk"
|
|
168
|
+
})
|
|
169
|
+
]
|
|
170
|
+
);
|
|
171
|
+
var externalAgents = sqliteTable(
|
|
172
|
+
"external_agents",
|
|
173
|
+
{
|
|
174
|
+
tenantId: text("tenant_id").notNull(),
|
|
175
|
+
projectId: text("project_id").notNull(),
|
|
176
|
+
id: text("id").notNull(),
|
|
177
|
+
name: text("name").notNull(),
|
|
178
|
+
description: text("description").notNull(),
|
|
179
|
+
baseUrl: text("base_url").notNull(),
|
|
180
|
+
// A2A endpoint URL
|
|
181
|
+
credentialReferenceId: text("credential_reference_id"),
|
|
182
|
+
headers: blob("headers", { mode: "json" }).$type(),
|
|
183
|
+
createdAt: text("created_at").notNull().default(sql`CURRENT_TIMESTAMP`),
|
|
184
|
+
updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
|
|
185
|
+
},
|
|
186
|
+
(table) => [
|
|
187
|
+
primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
188
|
+
foreignKey({
|
|
189
|
+
columns: [table.tenantId, table.projectId, table.credentialReferenceId],
|
|
190
|
+
foreignColumns: [
|
|
191
|
+
credentialReferences.tenantId,
|
|
192
|
+
credentialReferences.projectId,
|
|
193
|
+
credentialReferences.id
|
|
194
|
+
],
|
|
195
|
+
name: "external_agents_credential_reference_fk"
|
|
196
|
+
}).onDelete("set null")
|
|
197
|
+
]
|
|
198
|
+
);
|
|
199
|
+
var agentGraph = sqliteTable(
|
|
200
|
+
"agent_graph",
|
|
201
|
+
{
|
|
202
|
+
tenantId: text("tenant_id").notNull(),
|
|
203
|
+
projectId: text("project_id").notNull(),
|
|
204
|
+
id: text("id").notNull(),
|
|
205
|
+
name: text("name").notNull(),
|
|
206
|
+
description: text("description"),
|
|
207
|
+
defaultAgentId: text("default_agent_id").notNull(),
|
|
208
|
+
// Reference to shared context configuration for all agents in this graph
|
|
209
|
+
contextConfigId: text("context_config_id"),
|
|
210
|
+
// Graph-level model settingsuration that can be inherited by agents
|
|
211
|
+
models: text("models", { mode: "json" }).$type(),
|
|
212
|
+
// Status updates configuration for intelligent progress summaries
|
|
213
|
+
statusUpdates: text("status_updates", { mode: "json" }).$type(),
|
|
214
|
+
// Graph-level prompt that can be used as additional context for agents
|
|
215
|
+
graphPrompt: text("graph_prompt"),
|
|
216
|
+
// Graph-level stopWhen configuration that can be inherited by agents
|
|
217
|
+
stopWhen: text("stop_when", { mode: "json" }).$type(),
|
|
218
|
+
createdAt: text("created_at").notNull().default(sql`CURRENT_TIMESTAMP`),
|
|
219
|
+
updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
|
|
220
|
+
},
|
|
221
|
+
(table) => [
|
|
222
|
+
primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
223
|
+
foreignKey({
|
|
224
|
+
columns: [table.tenantId, table.projectId],
|
|
225
|
+
foreignColumns: [projects.tenantId, projects.id],
|
|
226
|
+
name: "agent_graph_project_fk"
|
|
227
|
+
})
|
|
228
|
+
]
|
|
229
|
+
);
|
|
230
|
+
var tasks = sqliteTable(
|
|
231
|
+
"tasks",
|
|
232
|
+
{
|
|
233
|
+
tenantId: text("tenant_id").notNull(),
|
|
234
|
+
projectId: text("project_id").notNull(),
|
|
235
|
+
id: text("id").notNull(),
|
|
236
|
+
contextId: text("context_id").notNull(),
|
|
237
|
+
status: text("status").notNull(),
|
|
238
|
+
metadata: blob("metadata", { mode: "json" }).$type(),
|
|
239
|
+
agentId: text("agent_id").notNull(),
|
|
240
|
+
createdAt: text("created_at").notNull().default(sql`CURRENT_TIMESTAMP`),
|
|
241
|
+
updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
|
|
242
|
+
},
|
|
243
|
+
(table) => [primaryKey({ columns: [table.tenantId, table.projectId, table.id] })]
|
|
244
|
+
);
|
|
245
|
+
var taskRelations = sqliteTable(
|
|
246
|
+
"task_relations",
|
|
247
|
+
{
|
|
248
|
+
tenantId: text("tenant_id").notNull(),
|
|
249
|
+
projectId: text("project_id").notNull(),
|
|
250
|
+
id: text("id").notNull(),
|
|
251
|
+
parentTaskId: text("parent_task_id").notNull(),
|
|
252
|
+
childTaskId: text("child_task_id").notNull(),
|
|
253
|
+
relationType: text("relation_type").default("parent_child"),
|
|
254
|
+
// Could be extended for other relation types
|
|
255
|
+
createdAt: text("created_at").notNull().default(sql`CURRENT_TIMESTAMP`),
|
|
256
|
+
updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
|
|
257
|
+
},
|
|
258
|
+
(table) => [primaryKey({ columns: [table.tenantId, table.projectId, table.id] })]
|
|
259
|
+
);
|
|
260
|
+
var dataComponents = sqliteTable(
|
|
261
|
+
"data_components",
|
|
262
|
+
{
|
|
263
|
+
tenantId: text("tenant_id").notNull(),
|
|
264
|
+
projectId: text("project_id").notNull(),
|
|
265
|
+
id: text("id").notNull(),
|
|
266
|
+
name: text("name").notNull(),
|
|
267
|
+
description: text("description").notNull(),
|
|
268
|
+
props: blob("props", { mode: "json" }).$type(),
|
|
269
|
+
createdAt: text("created_at").notNull().default(sql`CURRENT_TIMESTAMP`),
|
|
270
|
+
updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
|
|
271
|
+
},
|
|
272
|
+
(table) => [primaryKey({ columns: [table.tenantId, table.projectId, table.id] })]
|
|
273
|
+
);
|
|
274
|
+
var agentDataComponents = sqliteTable(
|
|
275
|
+
"agent_data_components",
|
|
276
|
+
{
|
|
277
|
+
tenantId: text("tenant_id").notNull(),
|
|
278
|
+
projectId: text("project_id").notNull(),
|
|
279
|
+
id: text("id").notNull(),
|
|
280
|
+
agentId: text("agent_id").notNull(),
|
|
281
|
+
dataComponentId: text("data_component_id").notNull(),
|
|
282
|
+
createdAt: text("created_at").notNull().default(sql`CURRENT_TIMESTAMP`)
|
|
283
|
+
},
|
|
284
|
+
(table) => [
|
|
285
|
+
primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
286
|
+
// Foreign key constraint to agents table
|
|
287
|
+
foreignKey({
|
|
288
|
+
columns: [table.tenantId, table.projectId, table.agentId],
|
|
289
|
+
foreignColumns: [agents.tenantId, agents.projectId, agents.id],
|
|
290
|
+
name: "agent_data_components_agent_fk"
|
|
291
|
+
}).onDelete("cascade"),
|
|
292
|
+
// Foreign key constraint to data_components table
|
|
293
|
+
foreignKey({
|
|
294
|
+
columns: [table.tenantId, table.projectId, table.dataComponentId],
|
|
295
|
+
foreignColumns: [dataComponents.tenantId, dataComponents.projectId, dataComponents.id],
|
|
296
|
+
name: "agent_data_components_data_component_fk"
|
|
297
|
+
}).onDelete("cascade")
|
|
298
|
+
]
|
|
299
|
+
);
|
|
300
|
+
var artifactComponents = sqliteTable(
|
|
301
|
+
"artifact_components",
|
|
302
|
+
{
|
|
303
|
+
tenantId: text("tenant_id").notNull(),
|
|
304
|
+
projectId: text("project_id").notNull(),
|
|
305
|
+
id: text("id").notNull(),
|
|
306
|
+
name: text("name").notNull(),
|
|
307
|
+
description: text("description").notNull(),
|
|
308
|
+
summaryProps: blob("summary_props", { mode: "json" }).$type(),
|
|
309
|
+
fullProps: blob("full_props", { mode: "json" }).$type(),
|
|
310
|
+
createdAt: text("created_at").notNull().default(sql`CURRENT_TIMESTAMP`),
|
|
311
|
+
updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
|
|
312
|
+
},
|
|
313
|
+
(table) => [primaryKey({ columns: [table.tenantId, table.projectId, table.id] })]
|
|
314
|
+
);
|
|
315
|
+
var agentArtifactComponents = sqliteTable(
|
|
316
|
+
"agent_artifact_components",
|
|
317
|
+
{
|
|
318
|
+
tenantId: text("tenant_id").notNull(),
|
|
319
|
+
projectId: text("project_id").notNull(),
|
|
320
|
+
id: text("id").notNull(),
|
|
321
|
+
agentId: text("agent_id").notNull(),
|
|
322
|
+
artifactComponentId: text("artifact_component_id").notNull(),
|
|
323
|
+
createdAt: text("created_at").notNull().default(sql`CURRENT_TIMESTAMP`)
|
|
324
|
+
},
|
|
325
|
+
(table) => [
|
|
326
|
+
primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
327
|
+
// Foreign key constraint to agents table
|
|
328
|
+
foreignKey({
|
|
329
|
+
columns: [table.tenantId, table.projectId, table.agentId],
|
|
330
|
+
foreignColumns: [agents.tenantId, agents.projectId, agents.id],
|
|
331
|
+
name: "agent_artifact_components_agent_fk"
|
|
332
|
+
}).onDelete("cascade"),
|
|
333
|
+
// Foreign key constraint to artifact_components table
|
|
334
|
+
foreignKey({
|
|
335
|
+
columns: [table.tenantId, table.projectId, table.artifactComponentId],
|
|
336
|
+
foreignColumns: [
|
|
337
|
+
artifactComponents.tenantId,
|
|
338
|
+
artifactComponents.projectId,
|
|
339
|
+
artifactComponents.id
|
|
340
|
+
],
|
|
341
|
+
name: "agent_artifact_components_artifact_component_fk"
|
|
342
|
+
}).onDelete("cascade")
|
|
343
|
+
]
|
|
344
|
+
);
|
|
345
|
+
var tools = sqliteTable(
|
|
346
|
+
"tools",
|
|
347
|
+
{
|
|
348
|
+
tenantId: text("tenant_id").notNull(),
|
|
349
|
+
projectId: text("project_id").notNull(),
|
|
350
|
+
id: text("id").notNull(),
|
|
351
|
+
name: text("name").notNull(),
|
|
352
|
+
// Enhanced MCP configuration
|
|
353
|
+
config: blob("config", { mode: "json" }).$type().notNull(),
|
|
354
|
+
credentialReferenceId: text("credential_reference_id"),
|
|
355
|
+
headers: blob("headers", { mode: "json" }).$type(),
|
|
356
|
+
// Image URL for custom tool icon (supports regular URLs and base64 encoded images)
|
|
357
|
+
imageUrl: text("image_url"),
|
|
358
|
+
// Server capabilities and status
|
|
359
|
+
capabilities: blob("capabilities", { mode: "json" }).$type(),
|
|
360
|
+
// Connection health and monitoring
|
|
361
|
+
status: text("status").notNull().default("unknown"),
|
|
362
|
+
lastHealthCheck: text("last_health_check"),
|
|
363
|
+
lastError: text("last_error"),
|
|
364
|
+
// Tool discovery cache
|
|
365
|
+
availableTools: blob("available_tools", { mode: "json" }).$type(),
|
|
366
|
+
lastToolsSync: text("last_tools_sync"),
|
|
367
|
+
createdAt: text("created_at").notNull().default(sql`CURRENT_TIMESTAMP`),
|
|
368
|
+
updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
|
|
369
|
+
},
|
|
370
|
+
(table) => [primaryKey({ columns: [table.tenantId, table.projectId, table.id] })]
|
|
371
|
+
);
|
|
372
|
+
var agentToolRelations = sqliteTable(
|
|
373
|
+
"agent_tool_relations",
|
|
374
|
+
{
|
|
375
|
+
tenantId: text("tenant_id").notNull(),
|
|
376
|
+
projectId: text("project_id").notNull(),
|
|
377
|
+
id: text("id").notNull(),
|
|
378
|
+
agentId: text("agent_id").notNull(),
|
|
379
|
+
toolId: text("tool_id").notNull(),
|
|
380
|
+
selectedTools: blob("selected_tools", { mode: "json" }).$type(),
|
|
381
|
+
createdAt: text("created_at").notNull().default(sql`CURRENT_TIMESTAMP`),
|
|
382
|
+
updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
|
|
383
|
+
},
|
|
384
|
+
(table) => [
|
|
385
|
+
primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
386
|
+
// Foreign key constraint to agents table
|
|
387
|
+
foreignKey({
|
|
388
|
+
columns: [table.tenantId, table.projectId, table.agentId],
|
|
389
|
+
foreignColumns: [agents.tenantId, agents.projectId, agents.id],
|
|
390
|
+
name: "agent_tool_relations_agent_fk"
|
|
391
|
+
}).onDelete("cascade"),
|
|
392
|
+
// Foreign key constraint to tools table
|
|
393
|
+
foreignKey({
|
|
394
|
+
columns: [table.tenantId, table.projectId, table.toolId],
|
|
395
|
+
foreignColumns: [tools.tenantId, tools.projectId, tools.id],
|
|
396
|
+
name: "agent_tool_relations_tool_fk"
|
|
397
|
+
}).onDelete("cascade")
|
|
398
|
+
]
|
|
399
|
+
);
|
|
400
|
+
var conversations = sqliteTable(
|
|
401
|
+
"conversations",
|
|
402
|
+
{
|
|
403
|
+
tenantId: text("tenant_id").notNull(),
|
|
404
|
+
projectId: text("project_id").notNull(),
|
|
405
|
+
id: text("id").notNull(),
|
|
406
|
+
userId: text("user_id"),
|
|
407
|
+
activeAgentId: text("active_agent_id").notNull(),
|
|
408
|
+
title: text("title"),
|
|
409
|
+
lastContextResolution: text("last_context_resolution"),
|
|
410
|
+
metadata: blob("metadata", { mode: "json" }).$type(),
|
|
411
|
+
createdAt: text("created_at").notNull().default(sql`CURRENT_TIMESTAMP`),
|
|
412
|
+
updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
|
|
413
|
+
},
|
|
414
|
+
(table) => [primaryKey({ columns: [table.tenantId, table.projectId, table.id] })]
|
|
415
|
+
);
|
|
416
|
+
var messages = sqliteTable(
|
|
417
|
+
"messages",
|
|
418
|
+
{
|
|
419
|
+
tenantId: text("tenant_id").notNull(),
|
|
420
|
+
projectId: text("project_id").notNull(),
|
|
421
|
+
id: text("id").notNull(),
|
|
422
|
+
conversationId: text("conversation_id").notNull(),
|
|
423
|
+
// Role mapping: user, agent, system (unified for both formats)
|
|
424
|
+
role: text("role").notNull(),
|
|
425
|
+
// 'user' | 'agent' | 'system'
|
|
426
|
+
// Agent sender/recipient tracking (nullable - only populated when relevant)
|
|
427
|
+
fromAgentId: text("from_agent_id"),
|
|
428
|
+
// Populated when message is from an agent
|
|
429
|
+
toAgentId: text("to_agent_id"),
|
|
430
|
+
// Populated when message is directed to a specific agent (e.g., transfers/delegations)
|
|
431
|
+
// External agent sender tracking
|
|
432
|
+
fromExternalAgentId: text("from_external_agent_id"),
|
|
433
|
+
// Populated when message is directed from an external agent
|
|
434
|
+
// External agent recipient tracking
|
|
435
|
+
toExternalAgentId: text("to_external_agent_id"),
|
|
436
|
+
// Populated when message is directed to an external agent
|
|
437
|
+
// Message content stored as JSON to support both formats
|
|
438
|
+
content: blob("content", { mode: "json" }).$type().notNull(),
|
|
439
|
+
// Message classification and filtering
|
|
440
|
+
visibility: text("visibility").notNull().default("user-facing"),
|
|
441
|
+
// 'user-facing' | 'internal' | 'system' | 'external'
|
|
442
|
+
messageType: text("message_type").notNull().default("chat"),
|
|
443
|
+
// 'chat' | 'a2a-request' | 'a2a-response' | 'task-update' | 'tool-call'
|
|
444
|
+
// Legacy agent association (consider deprecating in favor of fromAgentId/toAgentId)
|
|
445
|
+
agentId: text("agent_id"),
|
|
446
|
+
taskId: text("task_id"),
|
|
447
|
+
parentMessageId: text("parent_message_id"),
|
|
448
|
+
// Remove self-reference constraint here
|
|
449
|
+
// A2A specific fields
|
|
450
|
+
a2aTaskId: text("a2a_task_id"),
|
|
451
|
+
// Links to A2A task when relevant
|
|
452
|
+
a2aSessionId: text("a2a_session_id"),
|
|
453
|
+
// A2A session identifier
|
|
454
|
+
// Metadata for extensions
|
|
455
|
+
metadata: blob("metadata", { mode: "json" }).$type(),
|
|
456
|
+
createdAt: text("created_at").notNull().default(sql`CURRENT_TIMESTAMP`),
|
|
457
|
+
updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
|
|
458
|
+
},
|
|
459
|
+
(table) => [primaryKey({ columns: [table.tenantId, table.projectId, table.id] })]
|
|
460
|
+
);
|
|
461
|
+
var ledgerArtifacts = sqliteTable(
|
|
462
|
+
"ledger_artifacts",
|
|
463
|
+
{
|
|
464
|
+
// Primary identifier (maps to `artifactId`)
|
|
465
|
+
tenantId: text("tenant_id").notNull(),
|
|
466
|
+
projectId: text("project_id").notNull(),
|
|
467
|
+
id: text("id").notNull(),
|
|
468
|
+
// Links
|
|
469
|
+
taskId: text("task_id"),
|
|
470
|
+
contextId: text("context_id").notNull(),
|
|
471
|
+
// Core Artifact fields
|
|
472
|
+
type: text("type").notNull().default("source"),
|
|
473
|
+
name: text("name"),
|
|
474
|
+
description: text("description"),
|
|
475
|
+
parts: blob("parts", { mode: "json" }).$type(),
|
|
476
|
+
metadata: blob("metadata", { mode: "json" }).$type(),
|
|
477
|
+
// Extra ledger information (not part of the Artifact spec – kept optional)
|
|
478
|
+
summary: text("summary"),
|
|
479
|
+
mime: blob("mime", { mode: "json" }).$type(),
|
|
480
|
+
visibility: text("visibility").default("context"),
|
|
481
|
+
allowedAgents: blob("allowed_agents", { mode: "json" }).$type(),
|
|
482
|
+
derivedFrom: text("derived_from"),
|
|
483
|
+
// Timestamps
|
|
484
|
+
createdAt: text("created_at").notNull().default(sql`CURRENT_TIMESTAMP`),
|
|
485
|
+
updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
|
|
486
|
+
},
|
|
487
|
+
(table) => [primaryKey({ columns: [table.tenantId, table.projectId, table.id] })]
|
|
488
|
+
);
|
|
489
|
+
var apiKeys = sqliteTable(
|
|
490
|
+
"api_keys",
|
|
491
|
+
{
|
|
492
|
+
id: text("id").primaryKey(),
|
|
493
|
+
tenantId: text("tenant_id").notNull(),
|
|
494
|
+
projectId: text("project_id").notNull(),
|
|
495
|
+
graphId: text("graph_id").notNull(),
|
|
496
|
+
publicId: text("public_id").notNull().unique(),
|
|
497
|
+
// Public ID for O(1) lookup (e.g., "abc123def456")
|
|
498
|
+
keyHash: text("key_hash").notNull(),
|
|
499
|
+
// Hashed API key (never store plaintext)
|
|
500
|
+
keyPrefix: text("key_prefix").notNull(),
|
|
501
|
+
// First 8 chars for identification (e.g., "sk_live_abc...")
|
|
502
|
+
lastUsedAt: text("last_used_at"),
|
|
503
|
+
expiresAt: text("expires_at"),
|
|
504
|
+
createdAt: text("created_at").notNull().default(sql`CURRENT_TIMESTAMP`),
|
|
505
|
+
updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
|
|
506
|
+
},
|
|
507
|
+
(t) => [
|
|
508
|
+
foreignKey({
|
|
509
|
+
columns: [t.tenantId, t.projectId, t.graphId],
|
|
510
|
+
foreignColumns: [agentGraph.tenantId, agentGraph.projectId, agentGraph.id],
|
|
511
|
+
name: "api_keys_graph_fk"
|
|
512
|
+
}).onDelete("cascade"),
|
|
513
|
+
index("api_keys_tenant_graph_idx").on(t.tenantId, t.graphId),
|
|
514
|
+
index("api_keys_prefix_idx").on(t.keyPrefix),
|
|
515
|
+
index("api_keys_public_id_idx").on(t.publicId)
|
|
516
|
+
]
|
|
517
|
+
);
|
|
518
|
+
var credentialReferences = sqliteTable(
|
|
519
|
+
"credential_references",
|
|
520
|
+
{
|
|
521
|
+
tenantId: text("tenant_id").notNull(),
|
|
522
|
+
projectId: text("project_id").notNull(),
|
|
523
|
+
id: text("id").notNull(),
|
|
524
|
+
type: text("type").notNull(),
|
|
525
|
+
// Implementation type: 'keychain', 'nango', 'memory', etc.
|
|
526
|
+
credentialStoreId: text("credential_store_id").notNull(),
|
|
527
|
+
// Maps to framework.getCredentialStore(id)
|
|
528
|
+
retrievalParams: blob("retrieval_params", { mode: "json" }).$type(),
|
|
529
|
+
createdAt: text("created_at").notNull().default(sql`CURRENT_TIMESTAMP`),
|
|
530
|
+
updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
|
|
531
|
+
},
|
|
532
|
+
(t) => [primaryKey({ columns: [t.tenantId, t.projectId, t.id] })]
|
|
533
|
+
);
|
|
534
|
+
var ledgerArtifactsTaskIdIdx = index("ledger_artifacts_task_id_idx").on(
|
|
535
|
+
ledgerArtifacts.taskId
|
|
536
|
+
);
|
|
537
|
+
var ledgerArtifactsContextIdIdx = index("ledger_artifacts_context_id_idx").on(
|
|
538
|
+
ledgerArtifacts.contextId
|
|
539
|
+
);
|
|
540
|
+
var ledgerArtifactsTaskContextNameUnique = unique(
|
|
541
|
+
"ledger_artifacts_task_context_name_unique"
|
|
542
|
+
).on(ledgerArtifacts.taskId, ledgerArtifacts.contextId, ledgerArtifacts.name);
|
|
543
|
+
var tasksRelations = relations(tasks, ({ one, many }) => ({
|
|
544
|
+
// A task belongs to one project
|
|
545
|
+
project: one(projects, {
|
|
546
|
+
fields: [tasks.tenantId, tasks.projectId],
|
|
547
|
+
references: [projects.tenantId, projects.id]
|
|
548
|
+
}),
|
|
549
|
+
// A task can have many parent relationships (where it's the child)
|
|
550
|
+
parentRelations: many(taskRelations, {
|
|
551
|
+
relationName: "childTask"
|
|
552
|
+
}),
|
|
553
|
+
// A task can have many child relationships (where it's the parent)
|
|
554
|
+
childRelations: many(taskRelations, {
|
|
555
|
+
relationName: "parentTask"
|
|
556
|
+
}),
|
|
557
|
+
// A task belongs to one agent
|
|
558
|
+
agent: one(agents, {
|
|
559
|
+
fields: [tasks.agentId],
|
|
560
|
+
references: [agents.id]
|
|
561
|
+
}),
|
|
562
|
+
// A task can have many messages associated with it
|
|
563
|
+
messages: many(messages)
|
|
564
|
+
}));
|
|
565
|
+
var projectsRelations = relations(projects, ({ many }) => ({
|
|
566
|
+
// A project can have many agents
|
|
567
|
+
agents: many(agents),
|
|
568
|
+
// A project can have many agent graphs
|
|
569
|
+
agentGraphs: many(agentGraph),
|
|
570
|
+
// A project can have many tools
|
|
571
|
+
tools: many(tools),
|
|
572
|
+
// A project can have many context configs
|
|
573
|
+
contextConfigs: many(contextConfigs),
|
|
574
|
+
// A project can have many external agents
|
|
575
|
+
externalAgents: many(externalAgents),
|
|
576
|
+
// A project can have many conversations
|
|
577
|
+
conversations: many(conversations),
|
|
578
|
+
// A project can have many tasks
|
|
579
|
+
tasks: many(tasks)
|
|
580
|
+
}));
|
|
581
|
+
var taskRelationsRelations = relations(taskRelations, ({ one }) => ({
|
|
582
|
+
// Each relation has one parent task
|
|
583
|
+
parentTask: one(tasks, {
|
|
584
|
+
fields: [taskRelations.parentTaskId],
|
|
585
|
+
references: [tasks.id],
|
|
586
|
+
relationName: "parentTask"
|
|
587
|
+
}),
|
|
588
|
+
// Each relation has one child task
|
|
589
|
+
childTask: one(tasks, {
|
|
590
|
+
fields: [taskRelations.childTaskId],
|
|
591
|
+
references: [tasks.id],
|
|
592
|
+
relationName: "childTask"
|
|
593
|
+
})
|
|
594
|
+
}));
|
|
595
|
+
var contextConfigsRelations = relations(contextConfigs, ({ many, one }) => ({
|
|
596
|
+
// A context config belongs to one project
|
|
597
|
+
project: one(projects, {
|
|
598
|
+
fields: [contextConfigs.tenantId, contextConfigs.projectId],
|
|
599
|
+
references: [projects.tenantId, projects.id]
|
|
600
|
+
}),
|
|
601
|
+
// A context config can be used by many agent graphs
|
|
602
|
+
graphs: many(agentGraph),
|
|
603
|
+
// A context config can have many cached entries
|
|
604
|
+
cache: many(contextCache)
|
|
605
|
+
}));
|
|
606
|
+
var contextCacheRelations = relations(contextCache, ({ one }) => ({
|
|
607
|
+
// Each cache entry belongs to one context config
|
|
608
|
+
contextConfig: one(contextConfigs, {
|
|
609
|
+
fields: [contextCache.contextConfigId],
|
|
610
|
+
references: [contextConfigs.id]
|
|
611
|
+
})
|
|
612
|
+
}));
|
|
613
|
+
var agentsRelations = relations(agents, ({ many, one }) => ({
|
|
614
|
+
// A context config belongs to one project
|
|
615
|
+
project: one(projects, {
|
|
616
|
+
fields: [agents.tenantId, agents.projectId],
|
|
617
|
+
references: [projects.tenantId, projects.id]
|
|
618
|
+
}),
|
|
619
|
+
// An agent can have many tasks
|
|
620
|
+
tasks: many(tasks),
|
|
621
|
+
// An agent can be the default agent for many graphs
|
|
622
|
+
defaultForGraphs: many(agentGraph),
|
|
623
|
+
// Agent relation tracking
|
|
624
|
+
sourceRelations: many(agentRelations, {
|
|
625
|
+
relationName: "sourceRelations"
|
|
626
|
+
}),
|
|
627
|
+
targetRelations: many(agentRelations, {
|
|
628
|
+
relationName: "targetRelations"
|
|
629
|
+
}),
|
|
630
|
+
// Message tracking relations
|
|
631
|
+
sentMessages: many(messages, {
|
|
632
|
+
relationName: "sentMessages"
|
|
633
|
+
}),
|
|
634
|
+
receivedMessages: many(messages, {
|
|
635
|
+
relationName: "receivedMessages"
|
|
636
|
+
}),
|
|
637
|
+
// Legacy message association (consider deprecating)
|
|
638
|
+
associatedMessages: many(messages, {
|
|
639
|
+
relationName: "associatedAgent"
|
|
640
|
+
}),
|
|
641
|
+
toolRelations: many(agentToolRelations)
|
|
642
|
+
}));
|
|
643
|
+
var agentGraphRelations = relations(agentGraph, ({ one }) => ({
|
|
644
|
+
// An agent graph belongs to one project
|
|
645
|
+
project: one(projects, {
|
|
646
|
+
fields: [agentGraph.tenantId, agentGraph.projectId],
|
|
647
|
+
references: [projects.tenantId, projects.id]
|
|
648
|
+
}),
|
|
649
|
+
// An agent graph belongs to one default agent
|
|
650
|
+
defaultAgent: one(agents, {
|
|
651
|
+
fields: [agentGraph.defaultAgentId],
|
|
652
|
+
references: [agents.id]
|
|
653
|
+
}),
|
|
654
|
+
// An agent graph can reference one context config
|
|
655
|
+
contextConfig: one(contextConfigs, {
|
|
656
|
+
fields: [agentGraph.contextConfigId],
|
|
657
|
+
references: [contextConfigs.id]
|
|
658
|
+
})
|
|
659
|
+
}));
|
|
660
|
+
var externalAgentsRelations = relations(externalAgents, ({ one, many }) => ({
|
|
661
|
+
// An external agent belongs to one project
|
|
662
|
+
project: one(projects, {
|
|
663
|
+
fields: [externalAgents.tenantId, externalAgents.projectId],
|
|
664
|
+
references: [projects.tenantId, projects.id]
|
|
665
|
+
}),
|
|
666
|
+
// An external agent can be referenced by many agent relations
|
|
667
|
+
agentRelations: many(agentRelations),
|
|
668
|
+
// An external agent may have one credential reference
|
|
669
|
+
credentialReference: one(credentialReferences, {
|
|
670
|
+
fields: [externalAgents.credentialReferenceId],
|
|
671
|
+
references: [credentialReferences.id]
|
|
672
|
+
})
|
|
673
|
+
}));
|
|
674
|
+
var apiKeysRelations = relations(apiKeys, ({ one }) => ({
|
|
675
|
+
// An API key belongs to one project
|
|
676
|
+
project: one(projects, {
|
|
677
|
+
fields: [apiKeys.tenantId, apiKeys.projectId],
|
|
678
|
+
references: [projects.tenantId, projects.id]
|
|
679
|
+
}),
|
|
680
|
+
// An API key belongs to one tenant and graph
|
|
681
|
+
graph: one(agentGraph, {
|
|
682
|
+
fields: [apiKeys.graphId],
|
|
683
|
+
references: [agentGraph.id]
|
|
684
|
+
})
|
|
685
|
+
}));
|
|
686
|
+
var agentToolRelationsRelations = relations(agentToolRelations, ({ one }) => ({
|
|
687
|
+
// An agent-tool relation belongs to one agent
|
|
688
|
+
agent: one(agents, {
|
|
689
|
+
fields: [agentToolRelations.agentId],
|
|
690
|
+
references: [agents.id]
|
|
691
|
+
}),
|
|
692
|
+
// An agent-tool relation belongs to one tool
|
|
693
|
+
tool: one(tools, {
|
|
694
|
+
fields: [agentToolRelations.toolId],
|
|
695
|
+
references: [tools.id]
|
|
696
|
+
})
|
|
697
|
+
}));
|
|
698
|
+
var credentialReferencesRelations = relations(credentialReferences, ({ many }) => ({
|
|
699
|
+
tools: many(tools)
|
|
700
|
+
}));
|
|
701
|
+
var toolsRelations = relations(tools, ({ one, many }) => ({
|
|
702
|
+
// A tool belongs to one project
|
|
703
|
+
project: one(projects, {
|
|
704
|
+
fields: [tools.tenantId, tools.projectId],
|
|
705
|
+
references: [projects.tenantId, projects.id]
|
|
706
|
+
}),
|
|
707
|
+
// A tool can be used by many agents through agent-tool relations
|
|
708
|
+
agentRelations: many(agentToolRelations),
|
|
709
|
+
// A tool may have one credential reference
|
|
710
|
+
credentialReference: one(credentialReferences, {
|
|
711
|
+
fields: [tools.credentialReferenceId],
|
|
712
|
+
references: [credentialReferences.id]
|
|
713
|
+
})
|
|
714
|
+
}));
|
|
715
|
+
var conversationsRelations = relations(conversations, ({ one, many }) => ({
|
|
716
|
+
// A conversation belongs to one project
|
|
717
|
+
project: one(projects, {
|
|
718
|
+
fields: [conversations.tenantId, conversations.projectId],
|
|
719
|
+
references: [projects.tenantId, projects.id]
|
|
720
|
+
}),
|
|
721
|
+
// A conversation has many messages
|
|
722
|
+
messages: many(messages),
|
|
723
|
+
// A conversation has one active agent
|
|
724
|
+
activeAgent: one(agents, {
|
|
725
|
+
fields: [conversations.activeAgentId],
|
|
726
|
+
references: [agents.id]
|
|
727
|
+
})
|
|
728
|
+
}));
|
|
729
|
+
var messagesRelations = relations(messages, ({ one, many }) => ({
|
|
730
|
+
// A message belongs to one conversation
|
|
731
|
+
conversation: one(conversations, {
|
|
732
|
+
fields: [messages.conversationId],
|
|
733
|
+
references: [conversations.id]
|
|
734
|
+
}),
|
|
735
|
+
// Legacy agent association (consider deprecating)
|
|
736
|
+
agent: one(agents, {
|
|
737
|
+
fields: [messages.agentId],
|
|
738
|
+
references: [agents.id],
|
|
739
|
+
relationName: "associatedAgent"
|
|
740
|
+
}),
|
|
741
|
+
// Sender tracking relations
|
|
742
|
+
fromAgent: one(agents, {
|
|
743
|
+
fields: [messages.fromAgentId],
|
|
744
|
+
references: [agents.id],
|
|
745
|
+
relationName: "sentMessages"
|
|
746
|
+
}),
|
|
747
|
+
// Recipient tracking relations
|
|
748
|
+
toAgent: one(agents, {
|
|
749
|
+
fields: [messages.toAgentId],
|
|
750
|
+
references: [agents.id],
|
|
751
|
+
relationName: "receivedMessages"
|
|
752
|
+
}),
|
|
753
|
+
// External agent sender tracking relations
|
|
754
|
+
fromExternalAgent: one(externalAgents, {
|
|
755
|
+
fields: [messages.fromExternalAgentId],
|
|
756
|
+
references: [externalAgents.id],
|
|
757
|
+
relationName: "receivedExternalMessages"
|
|
758
|
+
}),
|
|
759
|
+
// External agent recipient tracking relations
|
|
760
|
+
toExternalAgent: one(externalAgents, {
|
|
761
|
+
fields: [messages.toExternalAgentId],
|
|
762
|
+
references: [externalAgents.id],
|
|
763
|
+
relationName: "sentExternalMessages"
|
|
764
|
+
}),
|
|
765
|
+
// A message may be associated with a task
|
|
766
|
+
task: one(tasks, {
|
|
767
|
+
fields: [messages.taskId],
|
|
768
|
+
references: [tasks.id]
|
|
769
|
+
}),
|
|
770
|
+
// A message may have a parent message (for threading)
|
|
771
|
+
parentMessage: one(messages, {
|
|
772
|
+
fields: [messages.parentMessageId],
|
|
773
|
+
references: [messages.id],
|
|
774
|
+
relationName: "parentChild"
|
|
775
|
+
}),
|
|
776
|
+
// A message may have child messages
|
|
777
|
+
childMessages: many(messages, {
|
|
778
|
+
relationName: "parentChild"
|
|
779
|
+
})
|
|
780
|
+
}));
|
|
781
|
+
var artifactComponentsRelations = relations(artifactComponents, ({ many }) => ({
|
|
782
|
+
// An artifact component can be associated with many agents
|
|
783
|
+
agentRelations: many(agentArtifactComponents)
|
|
784
|
+
}));
|
|
785
|
+
var agentArtifactComponentsRelations = relations(agentArtifactComponents, ({ one }) => ({
|
|
786
|
+
// An agent-artifact component relation belongs to one agent
|
|
787
|
+
agent: one(agents, {
|
|
788
|
+
fields: [agentArtifactComponents.agentId],
|
|
789
|
+
references: [agents.id]
|
|
790
|
+
}),
|
|
791
|
+
// An agent-artifact component relation belongs to one artifact component
|
|
792
|
+
artifactComponent: one(artifactComponents, {
|
|
793
|
+
fields: [agentArtifactComponents.artifactComponentId],
|
|
794
|
+
references: [artifactComponents.id]
|
|
795
|
+
})
|
|
796
|
+
}));
|
|
797
|
+
var agentRelationsRelations = relations(agentRelations, ({ one }) => ({
|
|
798
|
+
// An agent relation belongs to one graph
|
|
799
|
+
graph: one(agentGraph, {
|
|
800
|
+
fields: [agentRelations.graphId],
|
|
801
|
+
references: [agentGraph.id]
|
|
802
|
+
}),
|
|
803
|
+
// An agent relation has one source agent
|
|
804
|
+
sourceAgent: one(agents, {
|
|
805
|
+
fields: [agentRelations.sourceAgentId],
|
|
806
|
+
references: [agents.id],
|
|
807
|
+
relationName: "sourceRelations"
|
|
808
|
+
}),
|
|
809
|
+
// An agent relation may have one target agent (for internal relations)
|
|
810
|
+
targetAgent: one(agents, {
|
|
811
|
+
fields: [agentRelations.targetAgentId],
|
|
812
|
+
references: [agents.id],
|
|
813
|
+
relationName: "targetRelations"
|
|
814
|
+
}),
|
|
815
|
+
// An agent relation may have one external agent (for external relations)
|
|
816
|
+
externalAgent: one(externalAgents, {
|
|
817
|
+
fields: [agentRelations.externalAgentId],
|
|
818
|
+
references: [externalAgents.id]
|
|
819
|
+
})
|
|
820
|
+
}));
|
|
821
|
+
|
|
822
|
+
export { agentArtifactComponents, agentArtifactComponentsRelations, agentDataComponents, agentGraph, agentGraphRelations, agentRelations, agentRelationsRelations, agentToolRelations, agentToolRelationsRelations, agents, agentsRelations, apiKeys, apiKeysRelations, artifactComponents, artifactComponentsRelations, contextCache, contextCacheRelations, contextConfigs, contextConfigsRelations, conversations, conversationsRelations, credentialReferences, credentialReferencesRelations, dataComponents, externalAgents, externalAgentsRelations, ledgerArtifacts, ledgerArtifactsContextIdIdx, ledgerArtifactsTaskContextNameUnique, ledgerArtifactsTaskIdIdx, messages, messagesRelations, projects, projectsRelations, schema_exports, taskRelations, taskRelationsRelations, tasks, tasksRelations, tools, toolsRelations };
|