@inkeep/agents-core 0.0.0-dev-20250910233133 → 0.0.0-dev-20250910233441

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 (279) hide show
  1. package/dist/chunk-BIIFENNH.js +11 -0
  2. package/dist/chunk-H2F72PDA.js +15 -0
  3. package/dist/chunk-MKBO26DX.js +9 -0
  4. package/dist/chunk-RFWSE64N.js +665 -0
  5. package/dist/chunk-TSPWAF64.js +821 -0
  6. package/dist/client-exports.cjs +232 -0
  7. package/dist/client-exports.d.cts +302 -0
  8. package/dist/client-exports.d.ts +46 -43
  9. package/dist/client-exports.js +200 -247
  10. package/dist/db/schema.cjs +818 -0
  11. package/dist/db/schema.d.cts +7 -0
  12. package/dist/db/schema.d.ts +7 -4335
  13. package/dist/db/schema.js +1 -696
  14. package/dist/index.cjs +9809 -0
  15. package/dist/index.d.cts +3992 -0
  16. package/dist/index.d.ts +3992 -12
  17. package/dist/index.js +7807 -13
  18. package/dist/schema-B5YbTpz8.d.ts +4382 -0
  19. package/dist/schema-E0ulMd3k.d.cts +4382 -0
  20. package/dist/types/index.cjs +29 -0
  21. package/dist/types/index.d.cts +123 -0
  22. package/dist/types/index.d.ts +123 -5
  23. package/dist/types/index.js +2 -6
  24. package/dist/{validation/schemas.d.ts → utility-D2Lb-YAS.d.cts} +1350 -617
  25. package/dist/utility-D2Lb-YAS.d.ts +7946 -0
  26. package/dist/validation/index.cjs +1617 -0
  27. package/dist/validation/index.d.cts +63 -0
  28. package/dist/validation/index.d.ts +63 -4
  29. package/dist/validation/index.js +1 -5
  30. package/package.json +2 -2
  31. package/dist/__tests__/integration/helpers.d.ts +0 -5
  32. package/dist/__tests__/integration/helpers.d.ts.map +0 -1
  33. package/dist/__tests__/integration/helpers.js +0 -37
  34. package/dist/__tests__/integration/helpers.js.map +0 -1
  35. package/dist/__tests__/setup.d.ts +0 -3
  36. package/dist/__tests__/setup.d.ts.map +0 -1
  37. package/dist/__tests__/setup.js +0 -29
  38. package/dist/__tests__/setup.js.map +0 -1
  39. package/dist/client-exports.d.ts.map +0 -1
  40. package/dist/client-exports.js.map +0 -1
  41. package/dist/context/ContextConfig.d.ts +0 -54
  42. package/dist/context/ContextConfig.d.ts.map +0 -1
  43. package/dist/context/ContextConfig.js +0 -302
  44. package/dist/context/ContextConfig.js.map +0 -1
  45. package/dist/context/ContextFetcher.d.ts +0 -64
  46. package/dist/context/ContextFetcher.d.ts.map +0 -1
  47. package/dist/context/ContextFetcher.js +0 -325
  48. package/dist/context/ContextFetcher.js.map +0 -1
  49. package/dist/context/ContextResolver.d.ts +0 -52
  50. package/dist/context/ContextResolver.d.ts.map +0 -1
  51. package/dist/context/ContextResolver.js +0 -298
  52. package/dist/context/ContextResolver.js.map +0 -1
  53. package/dist/context/TemplateEngine.d.ts +0 -46
  54. package/dist/context/TemplateEngine.d.ts.map +0 -1
  55. package/dist/context/TemplateEngine.js +0 -175
  56. package/dist/context/TemplateEngine.js.map +0 -1
  57. package/dist/context/context.d.ts +0 -8
  58. package/dist/context/context.d.ts.map +0 -1
  59. package/dist/context/context.js +0 -157
  60. package/dist/context/context.js.map +0 -1
  61. package/dist/context/contextCache.d.ts +0 -50
  62. package/dist/context/contextCache.d.ts.map +0 -1
  63. package/dist/context/contextCache.js +0 -175
  64. package/dist/context/contextCache.js.map +0 -1
  65. package/dist/context/index.d.ts +0 -11
  66. package/dist/context/index.d.ts.map +0 -1
  67. package/dist/context/index.js +0 -8
  68. package/dist/context/index.js.map +0 -1
  69. package/dist/credential-stores/CredentialStoreRegistry.d.ts +0 -39
  70. package/dist/credential-stores/CredentialStoreRegistry.d.ts.map +0 -1
  71. package/dist/credential-stores/CredentialStoreRegistry.js +0 -65
  72. package/dist/credential-stores/CredentialStoreRegistry.js.map +0 -1
  73. package/dist/credential-stores/defaults.d.ts +0 -6
  74. package/dist/credential-stores/defaults.d.ts.map +0 -1
  75. package/dist/credential-stores/defaults.js +0 -22
  76. package/dist/credential-stores/defaults.js.map +0 -1
  77. package/dist/credential-stores/index.d.ts +0 -6
  78. package/dist/credential-stores/index.d.ts.map +0 -1
  79. package/dist/credential-stores/index.js +0 -6
  80. package/dist/credential-stores/index.js.map +0 -1
  81. package/dist/credential-stores/keychain-store.d.ts +0 -100
  82. package/dist/credential-stores/keychain-store.d.ts.map +0 -1
  83. package/dist/credential-stores/keychain-store.js +0 -225
  84. package/dist/credential-stores/keychain-store.js.map +0 -1
  85. package/dist/credential-stores/memory-store.d.ts +0 -39
  86. package/dist/credential-stores/memory-store.d.ts.map +0 -1
  87. package/dist/credential-stores/memory-store.js +0 -58
  88. package/dist/credential-stores/memory-store.js.map +0 -1
  89. package/dist/credential-stores/nango-store.d.ts +0 -59
  90. package/dist/credential-stores/nango-store.d.ts.map +0 -1
  91. package/dist/credential-stores/nango-store.js +0 -264
  92. package/dist/credential-stores/nango-store.js.map +0 -1
  93. package/dist/credential-stuffer/CredentialStuffer.d.ts +0 -80
  94. package/dist/credential-stuffer/CredentialStuffer.d.ts.map +0 -1
  95. package/dist/credential-stuffer/CredentialStuffer.js +0 -186
  96. package/dist/credential-stuffer/CredentialStuffer.js.map +0 -1
  97. package/dist/credential-stuffer/index.d.ts +0 -2
  98. package/dist/credential-stuffer/index.d.ts.map +0 -1
  99. package/dist/credential-stuffer/index.js +0 -2
  100. package/dist/credential-stuffer/index.js.map +0 -1
  101. package/dist/data-access/agentDataComponents.d.ts +0 -1
  102. package/dist/data-access/agentDataComponents.d.ts.map +0 -1
  103. package/dist/data-access/agentDataComponents.js +0 -2
  104. package/dist/data-access/agentDataComponents.js.map +0 -1
  105. package/dist/data-access/agentGraphs.d.ts +0 -399
  106. package/dist/data-access/agentGraphs.d.ts.map +0 -1
  107. package/dist/data-access/agentGraphs.js +0 -551
  108. package/dist/data-access/agentGraphs.js.map +0 -1
  109. package/dist/data-access/agentRelations.d.ts +0 -456
  110. package/dist/data-access/agentRelations.d.ts.map +0 -1
  111. package/dist/data-access/agentRelations.js +0 -471
  112. package/dist/data-access/agentRelations.js.map +0 -1
  113. package/dist/data-access/agents.d.ts +0 -218
  114. package/dist/data-access/agents.d.ts.map +0 -1
  115. package/dist/data-access/agents.js +0 -130
  116. package/dist/data-access/agents.js.map +0 -1
  117. package/dist/data-access/apiKeys.d.ts +0 -114
  118. package/dist/data-access/apiKeys.d.ts.map +0 -1
  119. package/dist/data-access/apiKeys.js +0 -185
  120. package/dist/data-access/apiKeys.js.map +0 -1
  121. package/dist/data-access/artifactComponents.d.ts +0 -152
  122. package/dist/data-access/artifactComponents.d.ts.map +0 -1
  123. package/dist/data-access/artifactComponents.js +0 -214
  124. package/dist/data-access/artifactComponents.js.map +0 -1
  125. package/dist/data-access/contextCache.d.ts +0 -68
  126. package/dist/data-access/contextCache.d.ts.map +0 -1
  127. package/dist/data-access/contextCache.js +0 -135
  128. package/dist/data-access/contextCache.js.map +0 -1
  129. package/dist/data-access/contextConfigs.d.ts +0 -110
  130. package/dist/data-access/contextConfigs.d.ts.map +0 -1
  131. package/dist/data-access/contextConfigs.js +0 -156
  132. package/dist/data-access/contextConfigs.js.map +0 -1
  133. package/dist/data-access/conversations.d.ts +0 -125
  134. package/dist/data-access/conversations.d.ts.map +0 -1
  135. package/dist/data-access/conversations.js +0 -244
  136. package/dist/data-access/conversations.js.map +0 -1
  137. package/dist/data-access/credentialReferences.d.ts +0 -86
  138. package/dist/data-access/credentialReferences.d.ts.map +0 -1
  139. package/dist/data-access/credentialReferences.js +0 -175
  140. package/dist/data-access/credentialReferences.js.map +0 -1
  141. package/dist/data-access/dataComponents.d.ts +0 -129
  142. package/dist/data-access/dataComponents.d.ts.map +0 -1
  143. package/dist/data-access/dataComponents.js +0 -213
  144. package/dist/data-access/dataComponents.js.map +0 -1
  145. package/dist/data-access/externalAgents.d.ts +0 -83
  146. package/dist/data-access/externalAgents.d.ts.map +0 -1
  147. package/dist/data-access/externalAgents.js +0 -163
  148. package/dist/data-access/externalAgents.js.map +0 -1
  149. package/dist/data-access/graphFull.d.ts +0 -32
  150. package/dist/data-access/graphFull.d.ts.map +0 -1
  151. package/dist/data-access/graphFull.js +0 -996
  152. package/dist/data-access/graphFull.js.map +0 -1
  153. package/dist/data-access/index.d.ts +0 -21
  154. package/dist/data-access/index.d.ts.map +0 -1
  155. package/dist/data-access/index.js +0 -22
  156. package/dist/data-access/index.js.map +0 -1
  157. package/dist/data-access/ledgerArtifacts.d.ts +0 -49
  158. package/dist/data-access/ledgerArtifacts.d.ts.map +0 -1
  159. package/dist/data-access/ledgerArtifacts.js +0 -112
  160. package/dist/data-access/ledgerArtifacts.js.map +0 -1
  161. package/dist/data-access/messages.d.ts +0 -209
  162. package/dist/data-access/messages.d.ts.map +0 -1
  163. package/dist/data-access/messages.js +0 -100
  164. package/dist/data-access/messages.js.map +0 -1
  165. package/dist/data-access/projects.d.ts +0 -67
  166. package/dist/data-access/projects.d.ts.map +0 -1
  167. package/dist/data-access/projects.js +0 -337
  168. package/dist/data-access/projects.js.map +0 -1
  169. package/dist/data-access/tasks.d.ts +0 -37
  170. package/dist/data-access/tasks.d.ts.map +0 -1
  171. package/dist/data-access/tasks.js +0 -40
  172. package/dist/data-access/tasks.js.map +0 -1
  173. package/dist/data-access/tools.d.ts +0 -277
  174. package/dist/data-access/tools.d.ts.map +0 -1
  175. package/dist/data-access/tools.js +0 -183
  176. package/dist/data-access/tools.js.map +0 -1
  177. package/dist/data-access/validation.d.ts +0 -17
  178. package/dist/data-access/validation.d.ts.map +0 -1
  179. package/dist/data-access/validation.js +0 -52
  180. package/dist/data-access/validation.js.map +0 -1
  181. package/dist/db/clean.d.ts +0 -6
  182. package/dist/db/clean.d.ts.map +0 -1
  183. package/dist/db/clean.js +0 -81
  184. package/dist/db/clean.js.map +0 -1
  185. package/dist/db/client.d.ts +0 -19
  186. package/dist/db/client.d.ts.map +0 -1
  187. package/dist/db/client.js +0 -24
  188. package/dist/db/client.js.map +0 -1
  189. package/dist/db/schema.d.ts.map +0 -1
  190. package/dist/db/schema.js.map +0 -1
  191. package/dist/db/test-client.d.ts +0 -25
  192. package/dist/db/test-client.d.ts.map +0 -1
  193. package/dist/db/test-client.js +0 -136
  194. package/dist/db/test-client.js.map +0 -1
  195. package/dist/env.d.ts +0 -19
  196. package/dist/env.d.ts.map +0 -1
  197. package/dist/env.js +0 -49
  198. package/dist/env.js.map +0 -1
  199. package/dist/index.d.ts.map +0 -1
  200. package/dist/index.js.map +0 -1
  201. package/dist/middleware/contextValidation.d.ts +0 -49
  202. package/dist/middleware/contextValidation.d.ts.map +0 -1
  203. package/dist/middleware/contextValidation.js +0 -473
  204. package/dist/middleware/contextValidation.js.map +0 -1
  205. package/dist/middleware/index.d.ts +0 -2
  206. package/dist/middleware/index.d.ts.map +0 -1
  207. package/dist/middleware/index.js +0 -2
  208. package/dist/middleware/index.js.map +0 -1
  209. package/dist/types/a2a.d.ts +0 -373
  210. package/dist/types/a2a.d.ts.map +0 -1
  211. package/dist/types/a2a.js +0 -14
  212. package/dist/types/a2a.js.map +0 -1
  213. package/dist/types/entities.d.ts +0 -147
  214. package/dist/types/entities.d.ts.map +0 -1
  215. package/dist/types/entities.js +0 -2
  216. package/dist/types/entities.js.map +0 -1
  217. package/dist/types/index.d.ts.map +0 -1
  218. package/dist/types/index.js.map +0 -1
  219. package/dist/types/server.d.ts +0 -116
  220. package/dist/types/server.d.ts.map +0 -1
  221. package/dist/types/server.js +0 -2
  222. package/dist/types/server.js.map +0 -1
  223. package/dist/types/utility.d.ts +0 -213
  224. package/dist/types/utility.d.ts.map +0 -1
  225. package/dist/types/utility.js +0 -9
  226. package/dist/types/utility.js.map +0 -1
  227. package/dist/utils/apiKeys.d.ts +0 -32
  228. package/dist/utils/apiKeys.d.ts.map +0 -1
  229. package/dist/utils/apiKeys.js +0 -117
  230. package/dist/utils/apiKeys.js.map +0 -1
  231. package/dist/utils/auth-detection.d.ts +0 -23
  232. package/dist/utils/auth-detection.d.ts.map +0 -1
  233. package/dist/utils/auth-detection.js +0 -148
  234. package/dist/utils/auth-detection.js.map +0 -1
  235. package/dist/utils/credential-store-utils.d.ts +0 -11
  236. package/dist/utils/credential-store-utils.d.ts.map +0 -1
  237. package/dist/utils/credential-store-utils.js +0 -19
  238. package/dist/utils/credential-store-utils.js.map +0 -1
  239. package/dist/utils/error.d.ts +0 -526
  240. package/dist/utils/error.d.ts.map +0 -1
  241. package/dist/utils/error.js +0 -282
  242. package/dist/utils/error.js.map +0 -1
  243. package/dist/utils/execution.d.ts +0 -18
  244. package/dist/utils/execution.d.ts.map +0 -1
  245. package/dist/utils/execution.js +0 -25
  246. package/dist/utils/execution.js.map +0 -1
  247. package/dist/utils/index.d.ts +0 -9
  248. package/dist/utils/index.d.ts.map +0 -1
  249. package/dist/utils/index.js +0 -9
  250. package/dist/utils/index.js.map +0 -1
  251. package/dist/utils/logger.d.ts +0 -79
  252. package/dist/utils/logger.d.ts.map +0 -1
  253. package/dist/utils/logger.js +0 -102
  254. package/dist/utils/logger.js.map +0 -1
  255. package/dist/utils/logging.d.ts +0 -11
  256. package/dist/utils/logging.d.ts.map +0 -1
  257. package/dist/utils/logging.js +0 -6
  258. package/dist/utils/logging.js.map +0 -1
  259. package/dist/utils/mcp-client.d.ts +0 -48
  260. package/dist/utils/mcp-client.d.ts.map +0 -1
  261. package/dist/utils/mcp-client.js +0 -174
  262. package/dist/utils/mcp-client.js.map +0 -1
  263. package/dist/utils/tracer.d.ts +0 -24
  264. package/dist/utils/tracer.d.ts.map +0 -1
  265. package/dist/utils/tracer.js +0 -110
  266. package/dist/utils/tracer.js.map +0 -1
  267. package/dist/validation/graphFull.d.ts +0 -36
  268. package/dist/validation/graphFull.d.ts.map +0 -1
  269. package/dist/validation/graphFull.js +0 -128
  270. package/dist/validation/graphFull.js.map +0 -1
  271. package/dist/validation/id-validation.d.ts +0 -38
  272. package/dist/validation/id-validation.d.ts.map +0 -1
  273. package/dist/validation/id-validation.js +0 -60
  274. package/dist/validation/id-validation.js.map +0 -1
  275. package/dist/validation/index.d.ts.map +0 -1
  276. package/dist/validation/index.js.map +0 -1
  277. package/dist/validation/schemas.d.ts.map +0 -1
  278. package/dist/validation/schemas.js +0 -576
  279. package/dist/validation/schemas.js.map +0 -1
@@ -0,0 +1,821 @@
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
+ createdAt: text("created_at").notNull().default(sql`CURRENT_TIMESTAMP`),
381
+ updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
382
+ },
383
+ (table) => [
384
+ primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
385
+ // Foreign key constraint to agents table
386
+ foreignKey({
387
+ columns: [table.tenantId, table.projectId, table.agentId],
388
+ foreignColumns: [agents.tenantId, agents.projectId, agents.id],
389
+ name: "agent_tool_relations_agent_fk"
390
+ }).onDelete("cascade"),
391
+ // Foreign key constraint to tools table
392
+ foreignKey({
393
+ columns: [table.tenantId, table.projectId, table.toolId],
394
+ foreignColumns: [tools.tenantId, tools.projectId, tools.id],
395
+ name: "agent_tool_relations_tool_fk"
396
+ }).onDelete("cascade")
397
+ ]
398
+ );
399
+ var conversations = sqliteTable(
400
+ "conversations",
401
+ {
402
+ tenantId: text("tenant_id").notNull(),
403
+ projectId: text("project_id").notNull(),
404
+ id: text("id").notNull(),
405
+ userId: text("user_id"),
406
+ activeAgentId: text("active_agent_id").notNull(),
407
+ title: text("title"),
408
+ lastContextResolution: text("last_context_resolution"),
409
+ metadata: blob("metadata", { mode: "json" }).$type(),
410
+ createdAt: text("created_at").notNull().default(sql`CURRENT_TIMESTAMP`),
411
+ updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
412
+ },
413
+ (table) => [primaryKey({ columns: [table.tenantId, table.projectId, table.id] })]
414
+ );
415
+ var messages = sqliteTable(
416
+ "messages",
417
+ {
418
+ tenantId: text("tenant_id").notNull(),
419
+ projectId: text("project_id").notNull(),
420
+ id: text("id").notNull(),
421
+ conversationId: text("conversation_id").notNull(),
422
+ // Role mapping: user, agent, system (unified for both formats)
423
+ role: text("role").notNull(),
424
+ // 'user' | 'agent' | 'system'
425
+ // Agent sender/recipient tracking (nullable - only populated when relevant)
426
+ fromAgentId: text("from_agent_id"),
427
+ // Populated when message is from an agent
428
+ toAgentId: text("to_agent_id"),
429
+ // Populated when message is directed to a specific agent (e.g., transfers/delegations)
430
+ // External agent sender tracking
431
+ fromExternalAgentId: text("from_external_agent_id"),
432
+ // Populated when message is directed from an external agent
433
+ // External agent recipient tracking
434
+ toExternalAgentId: text("to_external_agent_id"),
435
+ // Populated when message is directed to an external agent
436
+ // Message content stored as JSON to support both formats
437
+ content: blob("content", { mode: "json" }).$type().notNull(),
438
+ // Message classification and filtering
439
+ visibility: text("visibility").notNull().default("user-facing"),
440
+ // 'user-facing' | 'internal' | 'system' | 'external'
441
+ messageType: text("message_type").notNull().default("chat"),
442
+ // 'chat' | 'a2a-request' | 'a2a-response' | 'task-update' | 'tool-call'
443
+ // Legacy agent association (consider deprecating in favor of fromAgentId/toAgentId)
444
+ agentId: text("agent_id"),
445
+ taskId: text("task_id"),
446
+ parentMessageId: text("parent_message_id"),
447
+ // Remove self-reference constraint here
448
+ // A2A specific fields
449
+ a2aTaskId: text("a2a_task_id"),
450
+ // Links to A2A task when relevant
451
+ a2aSessionId: text("a2a_session_id"),
452
+ // A2A session identifier
453
+ // Metadata for extensions
454
+ metadata: blob("metadata", { mode: "json" }).$type(),
455
+ createdAt: text("created_at").notNull().default(sql`CURRENT_TIMESTAMP`),
456
+ updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
457
+ },
458
+ (table) => [primaryKey({ columns: [table.tenantId, table.projectId, table.id] })]
459
+ );
460
+ var ledgerArtifacts = sqliteTable(
461
+ "ledger_artifacts",
462
+ {
463
+ // Primary identifier (maps to `artifactId`)
464
+ tenantId: text("tenant_id").notNull(),
465
+ projectId: text("project_id").notNull(),
466
+ id: text("id").notNull(),
467
+ // Links
468
+ taskId: text("task_id"),
469
+ contextId: text("context_id").notNull(),
470
+ // Core Artifact fields
471
+ type: text("type").notNull().default("source"),
472
+ name: text("name"),
473
+ description: text("description"),
474
+ parts: blob("parts", { mode: "json" }).$type(),
475
+ metadata: blob("metadata", { mode: "json" }).$type(),
476
+ // Extra ledger information (not part of the Artifact spec – kept optional)
477
+ summary: text("summary"),
478
+ mime: blob("mime", { mode: "json" }).$type(),
479
+ visibility: text("visibility").default("context"),
480
+ allowedAgents: blob("allowed_agents", { mode: "json" }).$type(),
481
+ derivedFrom: text("derived_from"),
482
+ // Timestamps
483
+ createdAt: text("created_at").notNull().default(sql`CURRENT_TIMESTAMP`),
484
+ updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
485
+ },
486
+ (table) => [primaryKey({ columns: [table.tenantId, table.projectId, table.id] })]
487
+ );
488
+ var apiKeys = sqliteTable(
489
+ "api_keys",
490
+ {
491
+ id: text("id").primaryKey(),
492
+ tenantId: text("tenant_id").notNull(),
493
+ projectId: text("project_id").notNull(),
494
+ graphId: text("graph_id").notNull(),
495
+ publicId: text("public_id").notNull().unique(),
496
+ // Public ID for O(1) lookup (e.g., "abc123def456")
497
+ keyHash: text("key_hash").notNull(),
498
+ // Hashed API key (never store plaintext)
499
+ keyPrefix: text("key_prefix").notNull(),
500
+ // First 8 chars for identification (e.g., "sk_live_abc...")
501
+ lastUsedAt: text("last_used_at"),
502
+ expiresAt: text("expires_at"),
503
+ createdAt: text("created_at").notNull().default(sql`CURRENT_TIMESTAMP`),
504
+ updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
505
+ },
506
+ (t) => [
507
+ foreignKey({
508
+ columns: [t.tenantId, t.projectId, t.graphId],
509
+ foreignColumns: [agentGraph.tenantId, agentGraph.projectId, agentGraph.id],
510
+ name: "api_keys_graph_fk"
511
+ }).onDelete("cascade"),
512
+ index("api_keys_tenant_graph_idx").on(t.tenantId, t.graphId),
513
+ index("api_keys_prefix_idx").on(t.keyPrefix),
514
+ index("api_keys_public_id_idx").on(t.publicId)
515
+ ]
516
+ );
517
+ var credentialReferences = sqliteTable(
518
+ "credential_references",
519
+ {
520
+ tenantId: text("tenant_id").notNull(),
521
+ projectId: text("project_id").notNull(),
522
+ id: text("id").notNull(),
523
+ type: text("type").notNull(),
524
+ // Implementation type: 'vault', 'nango', 'inmemory', etc.
525
+ credentialStoreId: text("credential_store_id").notNull(),
526
+ // Maps to framework.getCredentialStore(id)
527
+ retrievalParams: blob("retrieval_params", { mode: "json" }).$type(),
528
+ createdAt: text("created_at").notNull().default(sql`CURRENT_TIMESTAMP`),
529
+ updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
530
+ },
531
+ (t) => [primaryKey({ columns: [t.tenantId, t.projectId, t.id] })]
532
+ );
533
+ var ledgerArtifactsTaskIdIdx = index("ledger_artifacts_task_id_idx").on(
534
+ ledgerArtifacts.taskId
535
+ );
536
+ var ledgerArtifactsContextIdIdx = index("ledger_artifacts_context_id_idx").on(
537
+ ledgerArtifacts.contextId
538
+ );
539
+ var ledgerArtifactsTaskContextNameUnique = unique(
540
+ "ledger_artifacts_task_context_name_unique"
541
+ ).on(ledgerArtifacts.taskId, ledgerArtifacts.contextId, ledgerArtifacts.name);
542
+ var tasksRelations = relations(tasks, ({ one, many }) => ({
543
+ // A task belongs to one project
544
+ project: one(projects, {
545
+ fields: [tasks.tenantId, tasks.projectId],
546
+ references: [projects.tenantId, projects.id]
547
+ }),
548
+ // A task can have many parent relationships (where it's the child)
549
+ parentRelations: many(taskRelations, {
550
+ relationName: "childTask"
551
+ }),
552
+ // A task can have many child relationships (where it's the parent)
553
+ childRelations: many(taskRelations, {
554
+ relationName: "parentTask"
555
+ }),
556
+ // A task belongs to one agent
557
+ agent: one(agents, {
558
+ fields: [tasks.agentId],
559
+ references: [agents.id]
560
+ }),
561
+ // A task can have many messages associated with it
562
+ messages: many(messages)
563
+ }));
564
+ var projectsRelations = relations(projects, ({ many }) => ({
565
+ // A project can have many agents
566
+ agents: many(agents),
567
+ // A project can have many agent graphs
568
+ agentGraphs: many(agentGraph),
569
+ // A project can have many tools
570
+ tools: many(tools),
571
+ // A project can have many context configs
572
+ contextConfigs: many(contextConfigs),
573
+ // A project can have many external agents
574
+ externalAgents: many(externalAgents),
575
+ // A project can have many conversations
576
+ conversations: many(conversations),
577
+ // A project can have many tasks
578
+ tasks: many(tasks)
579
+ }));
580
+ var taskRelationsRelations = relations(taskRelations, ({ one }) => ({
581
+ // Each relation has one parent task
582
+ parentTask: one(tasks, {
583
+ fields: [taskRelations.parentTaskId],
584
+ references: [tasks.id],
585
+ relationName: "parentTask"
586
+ }),
587
+ // Each relation has one child task
588
+ childTask: one(tasks, {
589
+ fields: [taskRelations.childTaskId],
590
+ references: [tasks.id],
591
+ relationName: "childTask"
592
+ })
593
+ }));
594
+ var contextConfigsRelations = relations(contextConfigs, ({ many, one }) => ({
595
+ // A context config belongs to one project
596
+ project: one(projects, {
597
+ fields: [contextConfigs.tenantId, contextConfigs.projectId],
598
+ references: [projects.tenantId, projects.id]
599
+ }),
600
+ // A context config can be used by many agent graphs
601
+ graphs: many(agentGraph),
602
+ // A context config can have many cached entries
603
+ cache: many(contextCache)
604
+ }));
605
+ var contextCacheRelations = relations(contextCache, ({ one }) => ({
606
+ // Each cache entry belongs to one context config
607
+ contextConfig: one(contextConfigs, {
608
+ fields: [contextCache.contextConfigId],
609
+ references: [contextConfigs.id]
610
+ })
611
+ }));
612
+ var agentsRelations = relations(agents, ({ many, one }) => ({
613
+ // A context config belongs to one project
614
+ project: one(projects, {
615
+ fields: [agents.tenantId, agents.projectId],
616
+ references: [projects.tenantId, projects.id]
617
+ }),
618
+ // An agent can have many tasks
619
+ tasks: many(tasks),
620
+ // An agent can be the default agent for many graphs
621
+ defaultForGraphs: many(agentGraph),
622
+ // Agent relation tracking
623
+ sourceRelations: many(agentRelations, {
624
+ relationName: "sourceRelations"
625
+ }),
626
+ targetRelations: many(agentRelations, {
627
+ relationName: "targetRelations"
628
+ }),
629
+ // Message tracking relations
630
+ sentMessages: many(messages, {
631
+ relationName: "sentMessages"
632
+ }),
633
+ receivedMessages: many(messages, {
634
+ relationName: "receivedMessages"
635
+ }),
636
+ // Legacy message association (consider deprecating)
637
+ associatedMessages: many(messages, {
638
+ relationName: "associatedAgent"
639
+ }),
640
+ toolRelations: many(agentToolRelations)
641
+ }));
642
+ var agentGraphRelations = relations(agentGraph, ({ one }) => ({
643
+ // An agent graph belongs to one project
644
+ project: one(projects, {
645
+ fields: [agentGraph.tenantId, agentGraph.projectId],
646
+ references: [projects.tenantId, projects.id]
647
+ }),
648
+ // An agent graph belongs to one default agent
649
+ defaultAgent: one(agents, {
650
+ fields: [agentGraph.defaultAgentId],
651
+ references: [agents.id]
652
+ }),
653
+ // An agent graph can reference one context config
654
+ contextConfig: one(contextConfigs, {
655
+ fields: [agentGraph.contextConfigId],
656
+ references: [contextConfigs.id]
657
+ })
658
+ }));
659
+ var externalAgentsRelations = relations(externalAgents, ({ one, many }) => ({
660
+ // An external agent belongs to one project
661
+ project: one(projects, {
662
+ fields: [externalAgents.tenantId, externalAgents.projectId],
663
+ references: [projects.tenantId, projects.id]
664
+ }),
665
+ // An external agent can be referenced by many agent relations
666
+ agentRelations: many(agentRelations),
667
+ // An external agent may have one credential reference
668
+ credentialReference: one(credentialReferences, {
669
+ fields: [externalAgents.credentialReferenceId],
670
+ references: [credentialReferences.id]
671
+ })
672
+ }));
673
+ var apiKeysRelations = relations(apiKeys, ({ one }) => ({
674
+ // An API key belongs to one project
675
+ project: one(projects, {
676
+ fields: [apiKeys.tenantId, apiKeys.projectId],
677
+ references: [projects.tenantId, projects.id]
678
+ }),
679
+ // An API key belongs to one tenant and graph
680
+ graph: one(agentGraph, {
681
+ fields: [apiKeys.graphId],
682
+ references: [agentGraph.id]
683
+ })
684
+ }));
685
+ var agentToolRelationsRelations = relations(agentToolRelations, ({ one }) => ({
686
+ // An agent-tool relation belongs to one agent
687
+ agent: one(agents, {
688
+ fields: [agentToolRelations.agentId],
689
+ references: [agents.id]
690
+ }),
691
+ // An agent-tool relation belongs to one tool
692
+ tool: one(tools, {
693
+ fields: [agentToolRelations.toolId],
694
+ references: [tools.id]
695
+ })
696
+ }));
697
+ var credentialReferencesRelations = relations(credentialReferences, ({ many }) => ({
698
+ tools: many(tools)
699
+ }));
700
+ var toolsRelations = relations(tools, ({ one, many }) => ({
701
+ // A tool belongs to one project
702
+ project: one(projects, {
703
+ fields: [tools.tenantId, tools.projectId],
704
+ references: [projects.tenantId, projects.id]
705
+ }),
706
+ // A tool can be used by many agents through agent-tool relations
707
+ agentRelations: many(agentToolRelations),
708
+ // A tool may have one credential reference
709
+ credentialReference: one(credentialReferences, {
710
+ fields: [tools.credentialReferenceId],
711
+ references: [credentialReferences.id]
712
+ })
713
+ }));
714
+ var conversationsRelations = relations(conversations, ({ one, many }) => ({
715
+ // A conversation belongs to one project
716
+ project: one(projects, {
717
+ fields: [conversations.tenantId, conversations.projectId],
718
+ references: [projects.tenantId, projects.id]
719
+ }),
720
+ // A conversation has many messages
721
+ messages: many(messages),
722
+ // A conversation has one active agent
723
+ activeAgent: one(agents, {
724
+ fields: [conversations.activeAgentId],
725
+ references: [agents.id]
726
+ })
727
+ }));
728
+ var messagesRelations = relations(messages, ({ one, many }) => ({
729
+ // A message belongs to one conversation
730
+ conversation: one(conversations, {
731
+ fields: [messages.conversationId],
732
+ references: [conversations.id]
733
+ }),
734
+ // Legacy agent association (consider deprecating)
735
+ agent: one(agents, {
736
+ fields: [messages.agentId],
737
+ references: [agents.id],
738
+ relationName: "associatedAgent"
739
+ }),
740
+ // Sender tracking relations
741
+ fromAgent: one(agents, {
742
+ fields: [messages.fromAgentId],
743
+ references: [agents.id],
744
+ relationName: "sentMessages"
745
+ }),
746
+ // Recipient tracking relations
747
+ toAgent: one(agents, {
748
+ fields: [messages.toAgentId],
749
+ references: [agents.id],
750
+ relationName: "receivedMessages"
751
+ }),
752
+ // External agent sender tracking relations
753
+ fromExternalAgent: one(externalAgents, {
754
+ fields: [messages.fromExternalAgentId],
755
+ references: [externalAgents.id],
756
+ relationName: "receivedExternalMessages"
757
+ }),
758
+ // External agent recipient tracking relations
759
+ toExternalAgent: one(externalAgents, {
760
+ fields: [messages.toExternalAgentId],
761
+ references: [externalAgents.id],
762
+ relationName: "sentExternalMessages"
763
+ }),
764
+ // A message may be associated with a task
765
+ task: one(tasks, {
766
+ fields: [messages.taskId],
767
+ references: [tasks.id]
768
+ }),
769
+ // A message may have a parent message (for threading)
770
+ parentMessage: one(messages, {
771
+ fields: [messages.parentMessageId],
772
+ references: [messages.id],
773
+ relationName: "parentChild"
774
+ }),
775
+ // A message may have child messages
776
+ childMessages: many(messages, {
777
+ relationName: "parentChild"
778
+ })
779
+ }));
780
+ var artifactComponentsRelations = relations(artifactComponents, ({ many }) => ({
781
+ // An artifact component can be associated with many agents
782
+ agentRelations: many(agentArtifactComponents)
783
+ }));
784
+ var agentArtifactComponentsRelations = relations(agentArtifactComponents, ({ one }) => ({
785
+ // An agent-artifact component relation belongs to one agent
786
+ agent: one(agents, {
787
+ fields: [agentArtifactComponents.agentId],
788
+ references: [agents.id]
789
+ }),
790
+ // An agent-artifact component relation belongs to one artifact component
791
+ artifactComponent: one(artifactComponents, {
792
+ fields: [agentArtifactComponents.artifactComponentId],
793
+ references: [artifactComponents.id]
794
+ })
795
+ }));
796
+ var agentRelationsRelations = relations(agentRelations, ({ one }) => ({
797
+ // An agent relation belongs to one graph
798
+ graph: one(agentGraph, {
799
+ fields: [agentRelations.graphId],
800
+ references: [agentGraph.id]
801
+ }),
802
+ // An agent relation has one source agent
803
+ sourceAgent: one(agents, {
804
+ fields: [agentRelations.sourceAgentId],
805
+ references: [agents.id],
806
+ relationName: "sourceRelations"
807
+ }),
808
+ // An agent relation may have one target agent (for internal relations)
809
+ targetAgent: one(agents, {
810
+ fields: [agentRelations.targetAgentId],
811
+ references: [agents.id],
812
+ relationName: "targetRelations"
813
+ }),
814
+ // An agent relation may have one external agent (for external relations)
815
+ externalAgent: one(externalAgents, {
816
+ fields: [agentRelations.externalAgentId],
817
+ references: [externalAgents.id]
818
+ })
819
+ }));
820
+
821
+ 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 };