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

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