@inkeep/agents-core 0.2.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import { __export } from './chunk-MKBO26DX.js';
2
2
  import { relations, sql } from 'drizzle-orm';
3
- import { sqliteTable, index, unique, text, primaryKey, blob, foreignKey, integer } from 'drizzle-orm/sqlite-core';
3
+ import { sqliteTable, index, unique, text, primaryKey, foreignKey, blob, integer } from 'drizzle-orm/sqlite-core';
4
4
 
5
5
  // src/db/schema.ts
6
6
  var schema_exports = {};
@@ -8,6 +8,7 @@ __export(schema_exports, {
8
8
  agentArtifactComponents: () => agentArtifactComponents,
9
9
  agentArtifactComponentsRelations: () => agentArtifactComponentsRelations,
10
10
  agentDataComponents: () => agentDataComponents,
11
+ agentDataComponentsRelations: () => agentDataComponentsRelations,
11
12
  agentGraph: () => agentGraph,
12
13
  agentGraphRelations: () => agentGraphRelations,
13
14
  agentRelations: () => agentRelations,
@@ -29,10 +30,12 @@ __export(schema_exports, {
29
30
  credentialReferences: () => credentialReferences,
30
31
  credentialReferencesRelations: () => credentialReferencesRelations,
31
32
  dataComponents: () => dataComponents,
33
+ dataComponentsRelations: () => dataComponentsRelations,
32
34
  externalAgents: () => externalAgents,
33
35
  externalAgentsRelations: () => externalAgentsRelations,
34
36
  ledgerArtifacts: () => ledgerArtifacts,
35
37
  ledgerArtifactsContextIdIdx: () => ledgerArtifactsContextIdIdx,
38
+ ledgerArtifactsRelations: () => ledgerArtifactsRelations,
36
39
  ledgerArtifactsTaskContextNameUnique: () => ledgerArtifactsTaskContextNameUnique,
37
40
  ledgerArtifactsTaskIdIdx: () => ledgerArtifactsTaskIdIdx,
38
41
  messages: () => messages,
@@ -63,11 +66,44 @@ var projects = sqliteTable(
63
66
  },
64
67
  (table) => [primaryKey({ columns: [table.tenantId, table.id] })]
65
68
  );
69
+ var agentGraph = sqliteTable(
70
+ "agent_graph",
71
+ {
72
+ tenantId: text("tenant_id").notNull(),
73
+ projectId: text("project_id").notNull(),
74
+ id: text("id").notNull(),
75
+ name: text("name").notNull(),
76
+ description: text("description"),
77
+ defaultAgentId: text("default_agent_id"),
78
+ // Reference to shared context configuration for all agents in this graph
79
+ contextConfigId: text("context_config_id"),
80
+ // add fk relationship
81
+ // Graph-level model settingsuration that can be inherited by agents
82
+ models: text("models", { mode: "json" }).$type(),
83
+ // Status updates configuration for intelligent progress summaries
84
+ statusUpdates: text("status_updates", { mode: "json" }).$type(),
85
+ // Graph-level prompt that can be used as additional context for agents
86
+ graphPrompt: text("graph_prompt"),
87
+ // Graph-level stopWhen configuration that can be inherited by agents
88
+ stopWhen: text("stop_when", { mode: "json" }).$type(),
89
+ createdAt: text("created_at").notNull().default(sql`CURRENT_TIMESTAMP`),
90
+ updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
91
+ },
92
+ (table) => [
93
+ primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
94
+ foreignKey({
95
+ columns: [table.tenantId, table.projectId],
96
+ foreignColumns: [projects.tenantId, projects.id],
97
+ name: "agent_graph_project_fk"
98
+ }).onDelete("cascade")
99
+ ]
100
+ );
66
101
  var contextConfigs = sqliteTable(
67
102
  "context_configs",
68
103
  {
69
104
  tenantId: text("tenant_id").notNull(),
70
105
  projectId: text("project_id").notNull(),
106
+ // Add graph level scoping
71
107
  id: text("id").notNull(),
72
108
  name: text("name").notNull(),
73
109
  description: text("description").notNull(),
@@ -132,6 +168,7 @@ var agents = sqliteTable(
132
168
  {
133
169
  tenantId: text("tenant_id").notNull(),
134
170
  projectId: text("project_id").notNull(),
171
+ graphId: text("graph_id").notNull(),
135
172
  id: text("id").notNull(),
136
173
  name: text("name").notNull(),
137
174
  description: text("description").notNull(),
@@ -146,11 +183,11 @@ var agents = sqliteTable(
146
183
  updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
147
184
  },
148
185
  (table) => [
149
- primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
186
+ primaryKey({ columns: [table.tenantId, table.projectId, table.graphId, table.id] }),
150
187
  foreignKey({
151
- columns: [table.tenantId, table.projectId],
152
- foreignColumns: [projects.tenantId, projects.id],
153
- name: "agents_project_fk"
188
+ columns: [table.tenantId, table.projectId, table.graphId],
189
+ foreignColumns: [agentGraph.tenantId, agentGraph.projectId, agentGraph.id],
190
+ name: "agents_graph_fk"
154
191
  }).onDelete("cascade")
155
192
  ]
156
193
  );
@@ -159,8 +196,8 @@ var agentRelations = sqliteTable(
159
196
  {
160
197
  tenantId: text("tenant_id").notNull(),
161
198
  projectId: text("project_id").notNull(),
162
- id: text("id").notNull(),
163
199
  graphId: text("graph_id").notNull(),
200
+ id: text("id").notNull(),
164
201
  sourceAgentId: text("source_agent_id").notNull(),
165
202
  // For internal relationships
166
203
  targetAgentId: text("target_agent_id"),
@@ -172,11 +209,11 @@ var agentRelations = sqliteTable(
172
209
  updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
173
210
  },
174
211
  (table) => [
175
- primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
212
+ primaryKey({ columns: [table.tenantId, table.projectId, table.graphId, table.id] }),
176
213
  foreignKey({
177
- columns: [table.tenantId, table.projectId],
178
- foreignColumns: [projects.tenantId, projects.id],
179
- name: "agent_relations_project_fk"
214
+ columns: [table.tenantId, table.projectId, table.graphId],
215
+ foreignColumns: [agentGraph.tenantId, agentGraph.projectId, agentGraph.id],
216
+ name: "agent_relations_graph_fk"
180
217
  }).onDelete("cascade")
181
218
  ]
182
219
  );
@@ -185,6 +222,7 @@ var externalAgents = sqliteTable(
185
222
  {
186
223
  tenantId: text("tenant_id").notNull(),
187
224
  projectId: text("project_id").notNull(),
225
+ graphId: text("graph_id").notNull(),
188
226
  id: text("id").notNull(),
189
227
  name: text("name").notNull(),
190
228
  description: text("description").notNull(),
@@ -196,11 +234,11 @@ var externalAgents = sqliteTable(
196
234
  updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
197
235
  },
198
236
  (table) => [
199
- primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
237
+ primaryKey({ columns: [table.tenantId, table.projectId, table.graphId, table.id] }),
200
238
  foreignKey({
201
- columns: [table.tenantId, table.projectId],
202
- foreignColumns: [projects.tenantId, projects.id],
203
- name: "external_agents_project_fk"
239
+ columns: [table.tenantId, table.projectId, table.graphId],
240
+ foreignColumns: [agentGraph.tenantId, agentGraph.projectId, agentGraph.id],
241
+ name: "external_agents_graph_fk"
204
242
  }).onDelete("cascade"),
205
243
  foreignKey({
206
244
  columns: [table.tenantId, table.projectId, table.credentialReferenceId],
@@ -213,37 +251,6 @@ var externalAgents = sqliteTable(
213
251
  }).onDelete("set null")
214
252
  ]
215
253
  );
216
- var agentGraph = sqliteTable(
217
- "agent_graph",
218
- {
219
- tenantId: text("tenant_id").notNull(),
220
- projectId: text("project_id").notNull(),
221
- id: text("id").notNull(),
222
- name: text("name").notNull(),
223
- description: text("description"),
224
- defaultAgentId: text("default_agent_id").notNull(),
225
- // Reference to shared context configuration for all agents in this graph
226
- contextConfigId: text("context_config_id"),
227
- // Graph-level model settingsuration that can be inherited by agents
228
- models: text("models", { mode: "json" }).$type(),
229
- // Status updates configuration for intelligent progress summaries
230
- statusUpdates: text("status_updates", { mode: "json" }).$type(),
231
- // Graph-level prompt that can be used as additional context for agents
232
- graphPrompt: text("graph_prompt"),
233
- // Graph-level stopWhen configuration that can be inherited by agents
234
- stopWhen: text("stop_when", { mode: "json" }).$type(),
235
- createdAt: text("created_at").notNull().default(sql`CURRENT_TIMESTAMP`),
236
- updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
237
- },
238
- (table) => [
239
- primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
240
- foreignKey({
241
- columns: [table.tenantId, table.projectId],
242
- foreignColumns: [projects.tenantId, projects.id],
243
- name: "agent_graph_project_fk"
244
- }).onDelete("cascade")
245
- ]
246
- );
247
254
  var tasks = sqliteTable(
248
255
  "tasks",
249
256
  {
@@ -314,23 +321,18 @@ var agentDataComponents = sqliteTable(
314
321
  {
315
322
  tenantId: text("tenant_id").notNull(),
316
323
  projectId: text("project_id").notNull(),
317
- id: text("id").notNull(),
324
+ graphId: text("graph_id").notNull(),
318
325
  agentId: text("agent_id").notNull(),
326
+ id: text("id").notNull(),
319
327
  dataComponentId: text("data_component_id").notNull(),
320
328
  createdAt: text("created_at").notNull().default(sql`CURRENT_TIMESTAMP`)
321
329
  },
322
330
  (table) => [
323
331
  primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
324
- // Foreign key constraint to projects table
325
- foreignKey({
326
- columns: [table.tenantId, table.projectId],
327
- foreignColumns: [projects.tenantId, projects.id],
328
- name: "agent_data_components_project_fk"
329
- }).onDelete("cascade"),
330
- // Foreign key constraint to agents table
332
+ // Foreign key constraint to agents table (ensures graph and project exist via cascade)
331
333
  foreignKey({
332
- columns: [table.tenantId, table.projectId, table.agentId],
333
- foreignColumns: [agents.tenantId, agents.projectId, agents.id],
334
+ columns: [table.tenantId, table.projectId, table.graphId, table.agentId],
335
+ foreignColumns: [agents.tenantId, agents.projectId, agents.graphId, agents.id],
334
336
  name: "agent_data_components_agent_fk"
335
337
  }).onDelete("cascade"),
336
338
  // Foreign key constraint to data_components table
@@ -368,23 +370,20 @@ var agentArtifactComponents = sqliteTable(
368
370
  {
369
371
  tenantId: text("tenant_id").notNull(),
370
372
  projectId: text("project_id").notNull(),
371
- id: text("id").notNull(),
373
+ graphId: text("graph_id").notNull(),
372
374
  agentId: text("agent_id").notNull(),
375
+ id: text("id").notNull(),
373
376
  artifactComponentId: text("artifact_component_id").notNull(),
374
377
  createdAt: text("created_at").notNull().default(sql`CURRENT_TIMESTAMP`)
375
378
  },
376
379
  (table) => [
377
- primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
378
- // Foreign key constraint to projects table
379
- foreignKey({
380
- columns: [table.tenantId, table.projectId],
381
- foreignColumns: [projects.tenantId, projects.id],
382
- name: "agent_artifact_components_project_fk"
383
- }).onDelete("cascade"),
384
- // Foreign key constraint to agents table
380
+ primaryKey({
381
+ columns: [table.tenantId, table.projectId, table.graphId, table.agentId, table.id]
382
+ }),
383
+ // Foreign key constraint to agents table (ensures graph and project exist via cascade)
385
384
  foreignKey({
386
- columns: [table.tenantId, table.projectId, table.agentId],
387
- foreignColumns: [agents.tenantId, agents.projectId, agents.id],
385
+ columns: [table.tenantId, table.projectId, table.graphId, table.agentId],
386
+ foreignColumns: [agents.tenantId, agents.projectId, agents.graphId, agents.id],
388
387
  name: "agent_artifact_components_agent_fk"
389
388
  }).onDelete("cascade"),
390
389
  // Foreign key constraint to artifact_components table
@@ -438,25 +437,20 @@ var agentToolRelations = sqliteTable(
438
437
  {
439
438
  tenantId: text("tenant_id").notNull(),
440
439
  projectId: text("project_id").notNull(),
441
- id: text("id").notNull(),
440
+ graphId: text("graph_id").notNull(),
442
441
  agentId: text("agent_id").notNull(),
442
+ id: text("id").notNull(),
443
443
  toolId: text("tool_id").notNull(),
444
444
  selectedTools: blob("selected_tools", { mode: "json" }).$type(),
445
445
  createdAt: text("created_at").notNull().default(sql`CURRENT_TIMESTAMP`),
446
446
  updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
447
447
  },
448
448
  (table) => [
449
- primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
450
- // Foreign key constraint to projects table
449
+ primaryKey({ columns: [table.tenantId, table.projectId, table.graphId, table.id] }),
450
+ // Foreign key constraint to agents table (which includes project and graph scope)
451
451
  foreignKey({
452
- columns: [table.tenantId, table.projectId],
453
- foreignColumns: [projects.tenantId, projects.id],
454
- name: "agent_tool_relations_project_fk"
455
- }).onDelete("cascade"),
456
- // Foreign key constraint to agents table
457
- foreignKey({
458
- columns: [table.tenantId, table.projectId, table.agentId],
459
- foreignColumns: [agents.tenantId, agents.projectId, agents.id],
452
+ columns: [table.tenantId, table.projectId, table.graphId, table.agentId],
453
+ foreignColumns: [agents.tenantId, agents.projectId, agents.graphId, agents.id],
460
454
  name: "agent_tool_relations_agent_fk"
461
455
  }).onDelete("cascade"),
462
456
  // Foreign key constraint to tools table
@@ -663,7 +657,9 @@ var tasksRelations = relations(tasks, ({ one, many }) => ({
663
657
  references: [agents.id]
664
658
  }),
665
659
  // A task can have many messages associated with it
666
- messages: many(messages)
660
+ messages: many(messages),
661
+ // A task can have many ledger artifacts
662
+ ledgerArtifacts: many(ledgerArtifacts)
667
663
  }));
668
664
  var projectsRelations = relations(projects, ({ many }) => ({
669
665
  // A project can have many agents
@@ -679,7 +675,15 @@ var projectsRelations = relations(projects, ({ many }) => ({
679
675
  // A project can have many conversations
680
676
  conversations: many(conversations),
681
677
  // A project can have many tasks
682
- tasks: many(tasks)
678
+ tasks: many(tasks),
679
+ // A project can have many data components
680
+ dataComponents: many(dataComponents),
681
+ // A project can have many artifact components
682
+ artifactComponents: many(artifactComponents),
683
+ // A project can have many ledger artifacts
684
+ ledgerArtifacts: many(ledgerArtifacts),
685
+ // A project can have many credential references
686
+ credentialReferences: many(credentialReferences)
683
687
  }));
684
688
  var taskRelationsRelations = relations(taskRelations, ({ one }) => ({
685
689
  // Each relation has one parent task
@@ -741,7 +745,11 @@ var agentsRelations = relations(agents, ({ many, one }) => ({
741
745
  associatedMessages: many(messages, {
742
746
  relationName: "associatedAgent"
743
747
  }),
744
- toolRelations: many(agentToolRelations)
748
+ toolRelations: many(agentToolRelations),
749
+ // Data component relations
750
+ dataComponentRelations: many(agentDataComponents),
751
+ // Artifact component relations
752
+ artifactComponentRelations: many(agentArtifactComponents)
745
753
  }));
746
754
  var agentGraphRelations = relations(agentGraph, ({ one }) => ({
747
755
  // An agent graph belongs to one project
@@ -749,7 +757,7 @@ var agentGraphRelations = relations(agentGraph, ({ one }) => ({
749
757
  fields: [agentGraph.tenantId, agentGraph.projectId],
750
758
  references: [projects.tenantId, projects.id]
751
759
  }),
752
- // An agent graph belongs to one default agent
760
+ // An agent graph may have one default agent (optional)
753
761
  defaultAgent: one(agents, {
754
762
  fields: [agentGraph.defaultAgentId],
755
763
  references: [agents.id]
@@ -897,6 +905,39 @@ var agentArtifactComponentsRelations = relations(agentArtifactComponents, ({ one
897
905
  references: [artifactComponents.id]
898
906
  })
899
907
  }));
908
+ var dataComponentsRelations = relations(dataComponents, ({ many, one }) => ({
909
+ // A data component belongs to one project
910
+ project: one(projects, {
911
+ fields: [dataComponents.tenantId, dataComponents.projectId],
912
+ references: [projects.tenantId, projects.id]
913
+ }),
914
+ // A data component can be associated with many agents
915
+ agentRelations: many(agentDataComponents)
916
+ }));
917
+ var agentDataComponentsRelations = relations(agentDataComponents, ({ one }) => ({
918
+ // An agent-data component relation belongs to one agent
919
+ agent: one(agents, {
920
+ fields: [agentDataComponents.agentId],
921
+ references: [agents.id]
922
+ }),
923
+ // An agent-data component relation belongs to one data component
924
+ dataComponent: one(dataComponents, {
925
+ fields: [agentDataComponents.dataComponentId],
926
+ references: [dataComponents.id]
927
+ })
928
+ }));
929
+ var ledgerArtifactsRelations = relations(ledgerArtifacts, ({ one }) => ({
930
+ // A ledger artifact belongs to one project
931
+ project: one(projects, {
932
+ fields: [ledgerArtifacts.tenantId, ledgerArtifacts.projectId],
933
+ references: [projects.tenantId, projects.id]
934
+ }),
935
+ // A ledger artifact may be associated with one task
936
+ task: one(tasks, {
937
+ fields: [ledgerArtifacts.taskId],
938
+ references: [tasks.id]
939
+ })
940
+ }));
900
941
  var agentRelationsRelations = relations(agentRelations, ({ one }) => ({
901
942
  // An agent relation belongs to one graph
902
943
  graph: one(agentGraph, {
@@ -922,4 +963,4 @@ var agentRelationsRelations = relations(agentRelations, ({ one }) => ({
922
963
  })
923
964
  }));
924
965
 
925
- 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 };
966
+ export { agentArtifactComponents, agentArtifactComponentsRelations, agentDataComponents, agentDataComponentsRelations, agentGraph, agentGraphRelations, agentRelations, agentRelationsRelations, agentToolRelations, agentToolRelationsRelations, agents, agentsRelations, apiKeys, apiKeysRelations, artifactComponents, artifactComponentsRelations, contextCache, contextCacheRelations, contextConfigs, contextConfigsRelations, conversations, conversationsRelations, credentialReferences, credentialReferencesRelations, dataComponents, dataComponentsRelations, externalAgents, externalAgentsRelations, ledgerArtifacts, ledgerArtifactsContextIdIdx, ledgerArtifactsRelations, ledgerArtifactsTaskContextNameUnique, ledgerArtifactsTaskIdIdx, messages, messagesRelations, projects, projectsRelations, schema_exports, taskRelations, taskRelationsRelations, tasks, tasksRelations, tools, toolsRelations };
@@ -1,5 +1,5 @@
1
- import { agents, agentRelations, agentGraph, tasks, taskRelations, tools, conversations, messages, contextCache, dataComponents, agentDataComponents, artifactComponents, agentArtifactComponents, externalAgents, apiKeys, contextConfigs, agentToolRelations, ledgerArtifacts, projects } from './chunk-MXQKLGQK.js';
2
1
  import { VALID_RELATION_TYPES, MCPTransportType, TOOL_STATUS_VALUES, CredentialStoreType, MCPServerType } from './chunk-SVGQSPW4.js';
2
+ import { agents, agentRelations, agentGraph, tasks, taskRelations, tools, conversations, messages, contextCache, dataComponents, agentDataComponents, artifactComponents, agentArtifactComponents, externalAgents, apiKeys, credentialReferences, contextConfigs, agentToolRelations, ledgerArtifacts, projects } from './chunk-LFWFXR4O.js';
3
3
  import { z } from '@hono/zod-openapi';
4
4
  import { createSelectSchema, createInsertSchema } from 'drizzle-zod';
5
5
 
@@ -35,15 +35,18 @@ var ProjectModelSchema = z.object({
35
35
  var createApiSchema = (schema) => schema.omit({ tenantId: true, projectId: true });
36
36
  var createApiInsertSchema = (schema) => schema.omit({ tenantId: true, projectId: true });
37
37
  var createApiUpdateSchema = (schema) => schema.omit({ tenantId: true, projectId: true }).partial();
38
+ var createGraphScopedApiSchema = (schema) => schema.omit({ tenantId: true, projectId: true, graphId: true });
39
+ var createGraphScopedApiInsertSchema = (schema) => schema.omit({ tenantId: true, projectId: true, graphId: true });
40
+ var createGraphScopedApiUpdateSchema = (schema) => schema.omit({ tenantId: true, projectId: true, graphId: true }).partial();
38
41
  var AgentSelectSchema = createSelectSchema(agents);
39
42
  var AgentInsertSchema = createInsertSchema(agents).extend({
40
43
  id: resourceIdSchema,
41
44
  models: ModelSchema.optional()
42
45
  });
43
46
  var AgentUpdateSchema = AgentInsertSchema.partial();
44
- var AgentApiSelectSchema = createApiSchema(AgentSelectSchema);
45
- var AgentApiInsertSchema = createApiInsertSchema(AgentInsertSchema);
46
- var AgentApiUpdateSchema = createApiUpdateSchema(AgentUpdateSchema);
47
+ var AgentApiSelectSchema = createGraphScopedApiSchema(AgentSelectSchema);
48
+ var AgentApiInsertSchema = createGraphScopedApiInsertSchema(AgentInsertSchema);
49
+ var AgentApiUpdateSchema = createGraphScopedApiUpdateSchema(AgentUpdateSchema);
47
50
  var AgentRelationSelectSchema = createSelectSchema(agentRelations);
48
51
  var AgentRelationInsertSchema = createInsertSchema(agentRelations).extend({
49
52
  id: resourceIdSchema,
@@ -53,8 +56,10 @@ var AgentRelationInsertSchema = createInsertSchema(agentRelations).extend({
53
56
  externalAgentId: resourceIdSchema.optional()
54
57
  });
55
58
  var AgentRelationUpdateSchema = AgentRelationInsertSchema.partial();
56
- var AgentRelationApiSelectSchema = createApiSchema(AgentRelationSelectSchema);
57
- var AgentRelationApiInsertSchema = createApiInsertSchema(AgentRelationInsertSchema).extend({
59
+ var AgentRelationApiSelectSchema = createGraphScopedApiSchema(AgentRelationSelectSchema);
60
+ var AgentRelationApiInsertSchema = createGraphScopedApiInsertSchema(
61
+ AgentRelationInsertSchema
62
+ ).extend({
58
63
  relationType: z.enum(VALID_RELATION_TYPES)
59
64
  }).refine(
60
65
  (data) => {
@@ -67,7 +72,9 @@ var AgentRelationApiInsertSchema = createApiInsertSchema(AgentRelationInsertSche
67
72
  path: ["targetAgentId", "externalAgentId"]
68
73
  }
69
74
  );
70
- var AgentRelationApiUpdateSchema = createApiUpdateSchema(AgentRelationUpdateSchema).extend({
75
+ var AgentRelationApiUpdateSchema = createGraphScopedApiUpdateSchema(
76
+ AgentRelationUpdateSchema
77
+ ).extend({
71
78
  relationType: z.enum(VALID_RELATION_TYPES).optional()
72
79
  }).refine(
73
80
  (data) => {
@@ -104,7 +111,7 @@ var AgentGraphInsertSchema = createInsertSchema(agentGraph).extend({
104
111
  var AgentGraphUpdateSchema = AgentGraphInsertSchema.partial();
105
112
  var AgentGraphApiSelectSchema = createApiSchema(AgentGraphSelectSchema);
106
113
  var AgentGraphApiInsertSchema = createApiInsertSchema(AgentGraphInsertSchema).extend({
107
- id: resourceIdSchema.optional()
114
+ id: resourceIdSchema
108
115
  });
109
116
  var AgentGraphApiUpdateSchema = createApiUpdateSchema(AgentGraphUpdateSchema);
110
117
  var TaskSelectSchema = createSelectSchema(tasks);
@@ -203,11 +210,16 @@ var DataComponentApiUpdateSchema = createApiUpdateSchema(DataComponentUpdateSche
203
210
  var AgentDataComponentSelectSchema = createSelectSchema(agentDataComponents);
204
211
  var AgentDataComponentInsertSchema = createInsertSchema(agentDataComponents);
205
212
  var AgentDataComponentUpdateSchema = AgentDataComponentInsertSchema.partial();
206
- var AgentDataComponentApiSelectSchema = createApiSchema(AgentDataComponentSelectSchema);
207
- var AgentDataComponentApiInsertSchema = createApiInsertSchema(
208
- AgentDataComponentInsertSchema
213
+ var AgentDataComponentApiSelectSchema = createGraphScopedApiSchema(
214
+ AgentDataComponentSelectSchema
209
215
  );
210
- var AgentDataComponentApiUpdateSchema = createApiUpdateSchema(
216
+ var AgentDataComponentApiInsertSchema = AgentDataComponentInsertSchema.omit({
217
+ tenantId: true,
218
+ projectId: true,
219
+ id: true,
220
+ createdAt: true
221
+ });
222
+ var AgentDataComponentApiUpdateSchema = createGraphScopedApiUpdateSchema(
211
223
  AgentDataComponentUpdateSchema
212
224
  );
213
225
  var ArtifactComponentSelectSchema = createSelectSchema(artifactComponents);
@@ -236,7 +248,7 @@ var AgentArtifactComponentInsertSchema = createInsertSchema(
236
248
  artifactComponentId: resourceIdSchema
237
249
  });
238
250
  var AgentArtifactComponentUpdateSchema = AgentArtifactComponentInsertSchema.partial();
239
- var AgentArtifactComponentApiSelectSchema = createApiSchema(
251
+ var AgentArtifactComponentApiSelectSchema = createGraphScopedApiSchema(
240
252
  AgentArtifactComponentSelectSchema
241
253
  );
242
254
  var AgentArtifactComponentApiInsertSchema = AgentArtifactComponentInsertSchema.omit({
@@ -245,7 +257,7 @@ var AgentArtifactComponentApiInsertSchema = AgentArtifactComponentInsertSchema.o
245
257
  id: true,
246
258
  createdAt: true
247
259
  });
248
- var AgentArtifactComponentApiUpdateSchema = createApiUpdateSchema(
260
+ var AgentArtifactComponentApiUpdateSchema = createGraphScopedApiUpdateSchema(
249
261
  AgentArtifactComponentUpdateSchema
250
262
  );
251
263
  var ExternalAgentSelectSchema = createSelectSchema(externalAgents).extend({
@@ -256,9 +268,9 @@ var ExternalAgentInsertSchema = createInsertSchema(externalAgents).extend({
256
268
  id: resourceIdSchema
257
269
  });
258
270
  var ExternalAgentUpdateSchema = ExternalAgentInsertSchema.partial();
259
- var ExternalAgentApiSelectSchema = createApiSchema(ExternalAgentSelectSchema);
260
- var ExternalAgentApiInsertSchema = createApiInsertSchema(ExternalAgentInsertSchema);
261
- var ExternalAgentApiUpdateSchema = createApiUpdateSchema(ExternalAgentUpdateSchema);
271
+ var ExternalAgentApiSelectSchema = createGraphScopedApiSchema(ExternalAgentSelectSchema);
272
+ var ExternalAgentApiInsertSchema = createGraphScopedApiInsertSchema(ExternalAgentInsertSchema);
273
+ var ExternalAgentApiUpdateSchema = createGraphScopedApiUpdateSchema(ExternalAgentUpdateSchema);
262
274
  var AllAgentSchema = z.discriminatedUnion("type", [
263
275
  AgentApiSelectSchema.extend({ type: z.literal("internal") }),
264
276
  ExternalAgentApiSelectSchema.extend({ type: z.literal("external") })
@@ -314,10 +326,8 @@ var CredentialReferenceSelectSchema = z.object({
314
326
  createdAt: z.string(),
315
327
  updatedAt: z.string()
316
328
  });
317
- var CredentialReferenceInsertSchema = z.object({
329
+ var CredentialReferenceInsertSchema = createInsertSchema(credentialReferences).extend({
318
330
  id: resourceIdSchema,
319
- tenantId: z.string(),
320
- projectId: z.string(),
321
331
  type: z.string(),
322
332
  credentialStoreId: resourceIdSchema,
323
333
  retrievalParams: z.record(z.string(), z.unknown()).nullish()
@@ -413,11 +423,13 @@ var AgentToolRelationInsertSchema = createInsertSchema(agentToolRelations).exten
413
423
  selectedTools: z.array(z.string()).nullish()
414
424
  });
415
425
  var AgentToolRelationUpdateSchema = AgentToolRelationInsertSchema.partial();
416
- var AgentToolRelationApiSelectSchema = createApiSchema(AgentToolRelationSelectSchema);
417
- var AgentToolRelationApiInsertSchema = createApiInsertSchema(
426
+ var AgentToolRelationApiSelectSchema = createGraphScopedApiSchema(
427
+ AgentToolRelationSelectSchema
428
+ );
429
+ var AgentToolRelationApiInsertSchema = createGraphScopedApiInsertSchema(
418
430
  AgentToolRelationInsertSchema
419
431
  );
420
- var AgentToolRelationApiUpdateSchema = createApiUpdateSchema(
432
+ var AgentToolRelationApiUpdateSchema = createGraphScopedApiUpdateSchema(
421
433
  AgentToolRelationUpdateSchema
422
434
  );
423
435
  var LedgerArtifactSelectSchema = createSelectSchema(ledgerArtifacts);
@@ -443,6 +455,7 @@ var StatusUpdateSchema = z.object({
443
455
  statusComponents: z.array(StatusComponentSchema).optional()
444
456
  });
445
457
  var FullGraphAgentInsertSchema = AgentApiInsertSchema.extend({
458
+ type: z.literal("internal"),
446
459
  tools: z.array(z.string()),
447
460
  selectedTools: z.record(z.string(), z.array(z.string())).optional(),
448
461
  dataComponents: z.array(z.string()).optional(),
@@ -452,10 +465,9 @@ var FullGraphAgentInsertSchema = AgentApiInsertSchema.extend({
452
465
  });
453
466
  var FullGraphDefinitionSchema = AgentGraphApiInsertSchema.extend({
454
467
  agents: z.record(z.string(), z.union([FullGraphAgentInsertSchema, ExternalAgentApiInsertSchema])),
455
- tools: z.record(z.string(), ToolApiInsertSchema).optional(),
456
- credentialReferences: z.record(z.string(), CredentialReferenceApiInsertSchema).optional(),
457
- dataComponents: z.record(z.string(), DataComponentApiInsertSchema).optional(),
458
- artifactComponents: z.record(z.string(), ArtifactComponentApiInsertSchema).optional(),
468
+ // Removed project-scoped resources - these are now managed at project level:
469
+ // tools, credentialReferences, dataComponents, artifactComponents
470
+ // Agent relationships to these resources are maintained via agent.tools, agent.dataComponents, etc.
459
471
  contextConfig: z.optional(ContextConfigApiInsertSchema),
460
472
  statusUpdates: z.optional(StatusUpdateSchema),
461
473
  models: ModelSchema.optional(),
@@ -463,7 +475,13 @@ var FullGraphDefinitionSchema = AgentGraphApiInsertSchema.extend({
463
475
  graphPrompt: z.string().max(5e3, "Graph prompt cannot exceed 5000 characters").optional()
464
476
  });
465
477
  var GraphWithinContextOfProjectSchema = AgentGraphApiInsertSchema.extend({
466
- agents: z.record(z.string(), z.union([FullGraphAgentInsertSchema, ExternalAgentApiInsertSchema])),
478
+ agents: z.record(
479
+ z.string(),
480
+ z.discriminatedUnion("type", [
481
+ FullGraphAgentInsertSchema,
482
+ ExternalAgentApiInsertSchema.extend({ type: z.literal("external") })
483
+ ])
484
+ ),
467
485
  models: ModelSchema.optional(),
468
486
  stopWhen: GraphStopWhenSchema.optional(),
469
487
  graphPrompt: z.string().max(5e3, "Graph prompt cannot exceed 5000 characters").optional()
@@ -546,6 +564,35 @@ var TenantProjectParamsSchema = z.object({
546
564
  example: "project_456"
547
565
  })
548
566
  }).openapi("TenantProjectParams");
567
+ var TenantProjectGraphParamsSchema = z.object({
568
+ tenantId: z.string().openapi({
569
+ description: "Tenant identifier",
570
+ example: "tenant_123"
571
+ }),
572
+ projectId: z.string().openapi({
573
+ description: "Project identifier",
574
+ example: "project_456"
575
+ }),
576
+ graphId: z.string().openapi({
577
+ description: "Graph identifier",
578
+ example: "graph_789"
579
+ })
580
+ }).openapi("TenantProjectGraphParams");
581
+ var TenantProjectGraphIdParamsSchema = z.object({
582
+ tenantId: z.string().openapi({
583
+ description: "Tenant identifier",
584
+ example: "tenant_123"
585
+ }),
586
+ projectId: z.string().openapi({
587
+ description: "Project identifier",
588
+ example: "project_456"
589
+ }),
590
+ graphId: z.string().openapi({
591
+ description: "Graph identifier",
592
+ example: "graph_789"
593
+ }),
594
+ id: resourceIdSchema
595
+ }).openapi("TenantProjectGraphIdParams");
549
596
  var TenantProjectIdParamsSchema = z.object({
550
597
  tenantId: z.string().openapi({
551
598
  description: "Tenant identifier",
@@ -572,4 +619,4 @@ var PaginationQueryParamsSchema = z.object({
572
619
  limit: z.coerce.number().min(1).max(100).default(10)
573
620
  });
574
621
 
575
- export { AgentApiInsertSchema, AgentApiSelectSchema, AgentApiUpdateSchema, AgentArtifactComponentApiInsertSchema, AgentArtifactComponentApiSelectSchema, AgentArtifactComponentApiUpdateSchema, AgentArtifactComponentInsertSchema, AgentArtifactComponentSelectSchema, AgentArtifactComponentUpdateSchema, AgentDataComponentApiInsertSchema, AgentDataComponentApiSelectSchema, AgentDataComponentApiUpdateSchema, AgentDataComponentInsertSchema, AgentDataComponentSelectSchema, AgentDataComponentUpdateSchema, AgentGraphApiInsertSchema, AgentGraphApiSelectSchema, AgentGraphApiUpdateSchema, AgentGraphInsertSchema, AgentGraphSelectSchema, AgentGraphUpdateSchema, AgentInsertSchema, AgentRelationApiInsertSchema, AgentRelationApiSelectSchema, AgentRelationApiUpdateSchema, AgentRelationInsertSchema, AgentRelationQuerySchema, AgentRelationSelectSchema, AgentRelationUpdateSchema, AgentSelectSchema, AgentStopWhenSchema, AgentToolRelationApiInsertSchema, AgentToolRelationApiSelectSchema, AgentToolRelationApiUpdateSchema, AgentToolRelationInsertSchema, AgentToolRelationSelectSchema, AgentToolRelationUpdateSchema, AgentUpdateSchema, AllAgentSchema, ApiKeyApiCreationResponseSchema, ApiKeyApiInsertSchema, ApiKeyApiSelectSchema, ApiKeyApiUpdateSchema, ApiKeyInsertSchema, ApiKeySelectSchema, ApiKeyUpdateSchema, ArtifactComponentApiInsertSchema, ArtifactComponentApiSelectSchema, ArtifactComponentApiUpdateSchema, ArtifactComponentInsertSchema, ArtifactComponentSelectSchema, ArtifactComponentUpdateSchema, ContextCacheApiInsertSchema, ContextCacheApiSelectSchema, ContextCacheApiUpdateSchema, ContextCacheInsertSchema, ContextCacheSelectSchema, ContextCacheUpdateSchema, ContextConfigApiInsertSchema, ContextConfigApiSelectSchema, ContextConfigApiUpdateSchema, ContextConfigInsertSchema, ContextConfigSelectSchema, ContextConfigUpdateSchema, ConversationApiInsertSchema, ConversationApiSelectSchema, ConversationApiUpdateSchema, ConversationInsertSchema, ConversationSelectSchema, ConversationUpdateSchema, CredentialReferenceApiInsertSchema, CredentialReferenceApiSelectSchema, CredentialReferenceApiUpdateSchema, CredentialReferenceInsertSchema, CredentialReferenceSelectSchema, CredentialReferenceUpdateSchema, DataComponentApiInsertSchema, DataComponentApiSelectSchema, DataComponentApiUpdateSchema, DataComponentBaseSchema, DataComponentInsertSchema, DataComponentSelectSchema, DataComponentUpdateSchema, ErrorResponseSchema, ExistsResponseSchema, ExternalAgentApiInsertSchema, ExternalAgentApiSelectSchema, ExternalAgentApiUpdateSchema, ExternalAgentInsertSchema, ExternalAgentRelationApiInsertSchema, ExternalAgentRelationInsertSchema, ExternalAgentSelectSchema, ExternalAgentUpdateSchema, FetchConfigSchema, FetchDefinitionSchema, FullGraphAgentInsertSchema, FullGraphDefinitionSchema, FullProjectDefinitionSchema, GraphStopWhenSchema, GraphWithinContextOfProjectSchema, HeadersScopeSchema, IdParamsSchema, LedgerArtifactApiInsertSchema, LedgerArtifactApiSelectSchema, LedgerArtifactApiUpdateSchema, LedgerArtifactInsertSchema, LedgerArtifactSelectSchema, LedgerArtifactUpdateSchema, ListResponseSchema, MAX_ID_LENGTH, MCPToolConfigSchema, MIN_ID_LENGTH, McpToolDefinitionSchema, McpToolSchema, McpTransportConfigSchema, MessageApiInsertSchema, MessageApiSelectSchema, MessageApiUpdateSchema, MessageInsertSchema, MessageSelectSchema, MessageUpdateSchema, ModelSchema, ModelSettingsSchema, PaginationQueryParamsSchema, PaginationSchema, ProjectApiInsertSchema, ProjectApiSelectSchema, ProjectApiUpdateSchema, ProjectInsertSchema, ProjectModelSchema, ProjectSelectSchema, ProjectUpdateSchema, RemovedResponseSchema, SingleResponseSchema, StatusComponentSchema, StatusUpdateSchema, StopWhenSchema, TaskApiInsertSchema, TaskApiSelectSchema, TaskApiUpdateSchema, TaskInsertSchema, TaskRelationApiInsertSchema, TaskRelationApiSelectSchema, TaskRelationApiUpdateSchema, TaskRelationInsertSchema, TaskRelationSelectSchema, TaskRelationUpdateSchema, TaskSelectSchema, TaskUpdateSchema, TenantIdParamsSchema, TenantParamsSchema, TenantProjectIdParamsSchema, TenantProjectParamsSchema, ToolApiInsertSchema, ToolApiSelectSchema, ToolApiUpdateSchema, ToolInsertSchema, ToolSelectSchema, ToolStatusSchema, ToolUpdateSchema, URL_SAFE_ID_PATTERN, resourceIdSchema };
622
+ export { AgentApiInsertSchema, AgentApiSelectSchema, AgentApiUpdateSchema, AgentArtifactComponentApiInsertSchema, AgentArtifactComponentApiSelectSchema, AgentArtifactComponentApiUpdateSchema, AgentArtifactComponentInsertSchema, AgentArtifactComponentSelectSchema, AgentArtifactComponentUpdateSchema, AgentDataComponentApiInsertSchema, AgentDataComponentApiSelectSchema, AgentDataComponentApiUpdateSchema, AgentDataComponentInsertSchema, AgentDataComponentSelectSchema, AgentDataComponentUpdateSchema, AgentGraphApiInsertSchema, AgentGraphApiSelectSchema, AgentGraphApiUpdateSchema, AgentGraphInsertSchema, AgentGraphSelectSchema, AgentGraphUpdateSchema, AgentInsertSchema, AgentRelationApiInsertSchema, AgentRelationApiSelectSchema, AgentRelationApiUpdateSchema, AgentRelationInsertSchema, AgentRelationQuerySchema, AgentRelationSelectSchema, AgentRelationUpdateSchema, AgentSelectSchema, AgentStopWhenSchema, AgentToolRelationApiInsertSchema, AgentToolRelationApiSelectSchema, AgentToolRelationApiUpdateSchema, AgentToolRelationInsertSchema, AgentToolRelationSelectSchema, AgentToolRelationUpdateSchema, AgentUpdateSchema, AllAgentSchema, ApiKeyApiCreationResponseSchema, ApiKeyApiInsertSchema, ApiKeyApiSelectSchema, ApiKeyApiUpdateSchema, ApiKeyInsertSchema, ApiKeySelectSchema, ApiKeyUpdateSchema, ArtifactComponentApiInsertSchema, ArtifactComponentApiSelectSchema, ArtifactComponentApiUpdateSchema, ArtifactComponentInsertSchema, ArtifactComponentSelectSchema, ArtifactComponentUpdateSchema, ContextCacheApiInsertSchema, ContextCacheApiSelectSchema, ContextCacheApiUpdateSchema, ContextCacheInsertSchema, ContextCacheSelectSchema, ContextCacheUpdateSchema, ContextConfigApiInsertSchema, ContextConfigApiSelectSchema, ContextConfigApiUpdateSchema, ContextConfigInsertSchema, ContextConfigSelectSchema, ContextConfigUpdateSchema, ConversationApiInsertSchema, ConversationApiSelectSchema, ConversationApiUpdateSchema, ConversationInsertSchema, ConversationSelectSchema, ConversationUpdateSchema, CredentialReferenceApiInsertSchema, CredentialReferenceApiSelectSchema, CredentialReferenceApiUpdateSchema, CredentialReferenceInsertSchema, CredentialReferenceSelectSchema, CredentialReferenceUpdateSchema, DataComponentApiInsertSchema, DataComponentApiSelectSchema, DataComponentApiUpdateSchema, DataComponentBaseSchema, DataComponentInsertSchema, DataComponentSelectSchema, DataComponentUpdateSchema, ErrorResponseSchema, ExistsResponseSchema, ExternalAgentApiInsertSchema, ExternalAgentApiSelectSchema, ExternalAgentApiUpdateSchema, ExternalAgentInsertSchema, ExternalAgentRelationApiInsertSchema, ExternalAgentRelationInsertSchema, ExternalAgentSelectSchema, ExternalAgentUpdateSchema, FetchConfigSchema, FetchDefinitionSchema, FullGraphAgentInsertSchema, FullGraphDefinitionSchema, FullProjectDefinitionSchema, GraphStopWhenSchema, GraphWithinContextOfProjectSchema, HeadersScopeSchema, IdParamsSchema, LedgerArtifactApiInsertSchema, LedgerArtifactApiSelectSchema, LedgerArtifactApiUpdateSchema, LedgerArtifactInsertSchema, LedgerArtifactSelectSchema, LedgerArtifactUpdateSchema, ListResponseSchema, MAX_ID_LENGTH, MCPToolConfigSchema, MIN_ID_LENGTH, McpToolDefinitionSchema, McpToolSchema, McpTransportConfigSchema, MessageApiInsertSchema, MessageApiSelectSchema, MessageApiUpdateSchema, MessageInsertSchema, MessageSelectSchema, MessageUpdateSchema, ModelSchema, ModelSettingsSchema, PaginationQueryParamsSchema, PaginationSchema, ProjectApiInsertSchema, ProjectApiSelectSchema, ProjectApiUpdateSchema, ProjectInsertSchema, ProjectModelSchema, ProjectSelectSchema, ProjectUpdateSchema, RemovedResponseSchema, SingleResponseSchema, StatusComponentSchema, StatusUpdateSchema, StopWhenSchema, TaskApiInsertSchema, TaskApiSelectSchema, TaskApiUpdateSchema, TaskInsertSchema, TaskRelationApiInsertSchema, TaskRelationApiSelectSchema, TaskRelationApiUpdateSchema, TaskRelationInsertSchema, TaskRelationSelectSchema, TaskRelationUpdateSchema, TaskSelectSchema, TaskUpdateSchema, TenantIdParamsSchema, TenantParamsSchema, TenantProjectGraphIdParamsSchema, TenantProjectGraphParamsSchema, TenantProjectIdParamsSchema, TenantProjectParamsSchema, ToolApiInsertSchema, ToolApiSelectSchema, ToolApiUpdateSchema, ToolInsertSchema, ToolSelectSchema, ToolStatusSchema, ToolUpdateSchema, URL_SAFE_ID_PATTERN, resourceIdSchema };