@inkeep/agents-manage-api 0.0.0-dev-20250919020857 → 0.0.0-dev-20250919052931

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 (3) hide show
  1. package/dist/index.cjs +128 -151
  2. package/dist/index.js +129 -152
  3. package/package.json +2 -2
package/dist/index.cjs CHANGED
@@ -152,7 +152,7 @@ app.openapi(
152
152
  operationId: "get-artifact-components-for-agent",
153
153
  tags: ["CRUD Agent Artifact Component Relations"],
154
154
  request: {
155
- params: agentsCore.TenantProjectParamsSchema.extend({
155
+ params: agentsCore.TenantProjectGraphParamsSchema.extend({
156
156
  agentId: zod.z.string()
157
157
  })
158
158
  },
@@ -171,10 +171,9 @@ app.openapi(
171
171
  }
172
172
  }),
173
173
  async (c) => {
174
- const { tenantId, projectId, agentId } = c.req.valid("param");
174
+ const { tenantId, projectId, graphId, agentId } = c.req.valid("param");
175
175
  const artifactComponents = await agentsCore.getArtifactComponentsForAgent(dbClient_default)({
176
- scopes: { tenantId, projectId },
177
- agentId
176
+ scopes: { tenantId, projectId, graphId, agentId }
178
177
  });
179
178
  return c.json({
180
179
  data: artifactComponents
@@ -189,7 +188,7 @@ app.openapi(
189
188
  operationId: "get-agents-using-artifact-component",
190
189
  tags: ["CRUD Agent Artifact Component Relations"],
191
190
  request: {
192
- params: agentsCore.TenantProjectParamsSchema.extend({
191
+ params: agentsCore.TenantProjectGraphParamsSchema.extend({
193
192
  artifactComponentId: zod.z.string()
194
193
  })
195
194
  },
@@ -229,7 +228,7 @@ app.openapi(
229
228
  operationId: "associate-artifact-component-with-agent",
230
229
  tags: ["CRUD Agent Artifact Component Relations"],
231
230
  request: {
232
- params: agentsCore.TenantProjectParamsSchema,
231
+ params: agentsCore.TenantProjectGraphParamsSchema,
233
232
  body: {
234
233
  content: {
235
234
  "application/json": {
@@ -259,9 +258,12 @@ app.openapi(
259
258
  }
260
259
  }),
261
260
  async (c) => {
262
- const { tenantId, projectId } = c.req.valid("param");
261
+ const { tenantId, projectId, graphId } = c.req.valid("param");
263
262
  const { agentId, artifactComponentId } = c.req.valid("json");
264
- const agent = await agentsCore.getAgentById(dbClient_default)({ scopes: { tenantId, projectId }, agentId });
263
+ const agent = await agentsCore.getAgentById(dbClient_default)({
264
+ scopes: { tenantId, projectId, graphId },
265
+ agentId
266
+ });
265
267
  const artifactComponent = await agentsCore.getArtifactComponentById(dbClient_default)({
266
268
  scopes: { tenantId, projectId },
267
269
  id: artifactComponentId
@@ -279,8 +281,7 @@ app.openapi(
279
281
  });
280
282
  }
281
283
  const exists = await agentsCore.isArtifactComponentAssociatedWithAgent(dbClient_default)({
282
- scopes: { tenantId, projectId },
283
- agentId,
284
+ scopes: { tenantId, projectId, graphId, agentId },
284
285
  artifactComponentId
285
286
  });
286
287
  if (exists) {
@@ -290,8 +291,7 @@ app.openapi(
290
291
  });
291
292
  }
292
293
  const association = await agentsCore.associateArtifactComponentWithAgent(dbClient_default)({
293
- scopes: { tenantId, projectId },
294
- agentId,
294
+ scopes: { tenantId, projectId, graphId, agentId },
295
295
  artifactComponentId
296
296
  });
297
297
  return c.json({ data: association }, 201);
@@ -305,7 +305,7 @@ app.openapi(
305
305
  operationId: "remove-artifact-component-from-agent",
306
306
  tags: ["CRUD Agent Artifact Component Relations"],
307
307
  request: {
308
- params: agentsCore.TenantProjectParamsSchema.extend({
308
+ params: agentsCore.TenantProjectGraphParamsSchema.extend({
309
309
  agentId: zod.z.string(),
310
310
  artifactComponentId: zod.z.string()
311
311
  })
@@ -323,10 +323,9 @@ app.openapi(
323
323
  }
324
324
  }),
325
325
  async (c) => {
326
- const { tenantId, projectId, agentId, artifactComponentId } = c.req.valid("param");
326
+ const { tenantId, projectId, graphId, agentId, artifactComponentId } = c.req.valid("param");
327
327
  const removed = await agentsCore.removeArtifactComponentFromAgent(dbClient_default)({
328
- scopes: { tenantId, projectId },
329
- agentId,
328
+ scopes: { tenantId, projectId, graphId, agentId },
330
329
  artifactComponentId
331
330
  });
332
331
  if (!removed) {
@@ -349,7 +348,7 @@ app.openapi(
349
348
  operationId: "check-artifact-component-agent-association",
350
349
  tags: ["CRUD Agent Artifact Component Relations"],
351
350
  request: {
352
- params: agentsCore.TenantProjectParamsSchema.extend({
351
+ params: agentsCore.TenantProjectGraphParamsSchema.extend({
353
352
  agentId: zod.z.string(),
354
353
  artifactComponentId: zod.z.string()
355
354
  })
@@ -367,10 +366,9 @@ app.openapi(
367
366
  }
368
367
  }),
369
368
  async (c) => {
370
- const { tenantId, projectId, agentId, artifactComponentId } = c.req.valid("param");
369
+ const { tenantId, projectId, graphId, agentId, artifactComponentId } = c.req.valid("param");
371
370
  const exists = await agentsCore.isArtifactComponentAssociatedWithAgent(dbClient_default)({
372
- scopes: { tenantId, projectId },
373
- agentId,
371
+ scopes: { tenantId, projectId, graphId, agentId },
374
372
  artifactComponentId
375
373
  });
376
374
  return c.json({ exists });
@@ -386,7 +384,7 @@ app2.openapi(
386
384
  operationId: "get-data-components-for-agent",
387
385
  tags: ["CRUD Agent Data Component Relations"],
388
386
  request: {
389
- params: agentsCore.TenantProjectParamsSchema.extend({
387
+ params: agentsCore.TenantProjectGraphParamsSchema.extend({
390
388
  agentId: zod.z.string()
391
389
  })
392
390
  },
@@ -405,10 +403,9 @@ app2.openapi(
405
403
  }
406
404
  }),
407
405
  async (c) => {
408
- const { tenantId, projectId, agentId } = c.req.valid("param");
406
+ const { tenantId, projectId, graphId, agentId } = c.req.valid("param");
409
407
  const dataComponents = await agentsCore.getDataComponentsForAgent(dbClient_default)({
410
- scopes: { tenantId, projectId },
411
- agentId
408
+ scopes: { tenantId, projectId, graphId, agentId }
412
409
  });
413
410
  return c.json({ data: dataComponents });
414
411
  }
@@ -421,7 +418,7 @@ app2.openapi(
421
418
  operationId: "get-agents-using-data-component",
422
419
  tags: ["CRUD Agent Data Component Relations"],
423
420
  request: {
424
- params: agentsCore.TenantProjectParamsSchema.extend({
421
+ params: agentsCore.TenantProjectGraphParamsSchema.extend({
425
422
  dataComponentId: zod.z.string()
426
423
  })
427
424
  },
@@ -461,7 +458,7 @@ app2.openapi(
461
458
  operationId: "associate-data-component-with-agent",
462
459
  tags: ["CRUD Agent Data Component Relations"],
463
460
  request: {
464
- params: agentsCore.TenantProjectParamsSchema,
461
+ params: agentsCore.TenantProjectGraphParamsSchema,
465
462
  body: {
466
463
  content: {
467
464
  "application/json": {
@@ -491,10 +488,10 @@ app2.openapi(
491
488
  }
492
489
  }),
493
490
  async (c) => {
494
- const { tenantId, projectId } = c.req.valid("param");
491
+ const { tenantId, projectId, graphId } = c.req.valid("param");
495
492
  const { agentId, dataComponentId } = c.req.valid("json");
496
493
  const [agent, dataComponent] = await Promise.all([
497
- agentsCore.getAgentById(dbClient_default)({ scopes: { tenantId, projectId }, agentId }),
494
+ agentsCore.getAgentById(dbClient_default)({ scopes: { tenantId, projectId, graphId }, agentId }),
498
495
  agentsCore.getDataComponent(dbClient_default)({ scopes: { tenantId, projectId }, dataComponentId })
499
496
  ]);
500
497
  if (!agent) {
@@ -510,8 +507,7 @@ app2.openapi(
510
507
  });
511
508
  }
512
509
  const exists = await agentsCore.isDataComponentAssociatedWithAgent(dbClient_default)({
513
- scopes: { tenantId, projectId },
514
- agentId,
510
+ scopes: { tenantId, projectId, graphId, agentId },
515
511
  dataComponentId
516
512
  });
517
513
  if (exists) {
@@ -521,8 +517,7 @@ app2.openapi(
521
517
  });
522
518
  }
523
519
  const association = await agentsCore.associateDataComponentWithAgent(dbClient_default)({
524
- scopes: { tenantId, projectId },
525
- agentId,
520
+ scopes: { tenantId, projectId, graphId, agentId },
526
521
  dataComponentId
527
522
  });
528
523
  return c.json({ data: association }, 201);
@@ -536,7 +531,7 @@ app2.openapi(
536
531
  operationId: "remove-data-component-from-agent",
537
532
  tags: ["CRUD Agent Data Component Relations"],
538
533
  request: {
539
- params: agentsCore.TenantProjectParamsSchema.extend({
534
+ params: agentsCore.TenantProjectGraphParamsSchema.extend({
540
535
  agentId: zod.z.string(),
541
536
  dataComponentId: zod.z.string()
542
537
  })
@@ -554,10 +549,9 @@ app2.openapi(
554
549
  }
555
550
  }),
556
551
  async (c) => {
557
- const { tenantId, projectId, agentId, dataComponentId } = c.req.valid("param");
552
+ const { tenantId, projectId, graphId, agentId, dataComponentId } = c.req.valid("param");
558
553
  const removed = await agentsCore.removeDataComponentFromAgent(dbClient_default)({
559
- scopes: { tenantId, projectId },
560
- agentId,
554
+ scopes: { tenantId, projectId, graphId, agentId },
561
555
  dataComponentId
562
556
  });
563
557
  if (!removed) {
@@ -580,7 +574,7 @@ app2.openapi(
580
574
  operationId: "check-data-component-agent-association",
581
575
  tags: ["CRUD Agent Data Component Relations"],
582
576
  request: {
583
- params: agentsCore.TenantProjectParamsSchema.extend({
577
+ params: agentsCore.TenantProjectGraphParamsSchema.extend({
584
578
  agentId: zod.z.string(),
585
579
  dataComponentId: zod.z.string()
586
580
  })
@@ -598,10 +592,9 @@ app2.openapi(
598
592
  }
599
593
  }),
600
594
  async (c) => {
601
- const { tenantId, projectId, agentId, dataComponentId } = c.req.valid("param");
595
+ const { tenantId, projectId, graphId, agentId, dataComponentId } = c.req.valid("param");
602
596
  const exists = await agentsCore.isDataComponentAssociatedWithAgent(dbClient_default)({
603
- scopes: { tenantId, projectId },
604
- agentId,
597
+ scopes: { tenantId, projectId, graphId, agentId },
605
598
  dataComponentId
606
599
  });
607
600
  return c.json({ exists });
@@ -672,9 +665,8 @@ app3.openapi(
672
665
  }),
673
666
  async (c) => {
674
667
  const { tenantId, projectId, id } = c.req.valid("param");
675
- const graph = await agentsCore.getAgentGraph(dbClient_default)({
676
- scopes: { tenantId, projectId },
677
- graphId: id
668
+ const graph = await agentsCore.getAgentGraphById(dbClient_default)({
669
+ scopes: { tenantId, projectId, graphId: id }
678
670
  });
679
671
  if (!graph) {
680
672
  throw agentsCore.createApiError({
@@ -761,8 +753,7 @@ app3.openapi(
761
753
  async (c) => {
762
754
  const { tenantId, projectId, graphId } = c.req.valid("param");
763
755
  const fullGraph = await agentsCore.getFullGraphDefinition(dbClient_default)({
764
- scopes: { tenantId, projectId },
765
- graphId
756
+ scopes: { tenantId, projectId, graphId }
766
757
  });
767
758
  if (!fullGraph) {
768
759
  throw agentsCore.createApiError({
@@ -849,8 +840,7 @@ app3.openapi(
849
840
  const { tenantId, projectId, id } = c.req.valid("param");
850
841
  const validatedBody = c.req.valid("json");
851
842
  const updatedGraph = await agentsCore.updateAgentGraph(dbClient_default)({
852
- scopes: { tenantId, projectId },
853
- graphId: id,
843
+ scopes: { tenantId, projectId, graphId: id },
854
844
  data: {
855
845
  defaultAgentId: validatedBody.defaultAgentId,
856
846
  contextConfigId: validatedBody.contextConfigId ?? void 0
@@ -892,8 +882,7 @@ app3.openapi(
892
882
  async (c) => {
893
883
  const { tenantId, projectId, id } = c.req.valid("param");
894
884
  const deleted = await agentsCore.deleteAgentGraph(dbClient_default)({
895
- scopes: { tenantId, projectId },
896
- graphId: id
885
+ scopes: { tenantId, projectId, graphId: id }
897
886
  });
898
887
  if (!deleted) {
899
888
  throw agentsCore.createApiError({
@@ -914,7 +903,7 @@ app4.openapi(
914
903
  operationId: "list-agent-relations",
915
904
  tags: ["CRUD Agent Relations"],
916
905
  request: {
917
- params: agentsCore.TenantProjectParamsSchema,
906
+ params: agentsCore.TenantProjectGraphParamsSchema,
918
907
  query: agentsCore.PaginationQueryParamsSchema.merge(agentsCore.AgentRelationQuerySchema)
919
908
  },
920
909
  responses: {
@@ -930,7 +919,7 @@ app4.openapi(
930
919
  }
931
920
  }),
932
921
  async (c) => {
933
- const { tenantId, projectId } = c.req.valid("param");
922
+ const { tenantId, projectId, graphId } = c.req.valid("param");
934
923
  const {
935
924
  page = 1,
936
925
  limit = 10,
@@ -944,28 +933,28 @@ app4.openapi(
944
933
  let result;
945
934
  if (sourceAgentId) {
946
935
  const rawResult = await agentsCore.getAgentRelationsBySource(dbClient_default)({
947
- scopes: { tenantId, projectId },
936
+ scopes: { tenantId, projectId, graphId },
948
937
  sourceAgentId,
949
938
  pagination: { page: pageNum, limit: limitNum }
950
939
  });
951
940
  result = { ...rawResult, data: rawResult.data };
952
941
  } else if (targetAgentId) {
953
942
  const rawResult = await agentsCore.getAgentRelationsByTarget(dbClient_default)({
954
- scopes: { tenantId, projectId },
943
+ scopes: { tenantId, projectId, graphId },
955
944
  targetAgentId,
956
945
  pagination: { page: pageNum, limit: limitNum }
957
946
  });
958
947
  result = { ...rawResult, data: rawResult.data };
959
948
  } else if (externalAgentId) {
960
949
  const rawResult = await agentsCore.getExternalAgentRelations(dbClient_default)({
961
- scopes: { tenantId, projectId },
950
+ scopes: { tenantId, projectId, graphId },
962
951
  externalAgentId,
963
952
  pagination: { page: pageNum, limit: limitNum }
964
953
  });
965
954
  result = { ...rawResult, data: rawResult.data };
966
955
  } else {
967
956
  const rawResult = await agentsCore.listAgentRelations(dbClient_default)({
968
- scopes: { tenantId, projectId },
957
+ scopes: { tenantId, projectId, graphId },
969
958
  pagination: { page: pageNum, limit: limitNum }
970
959
  });
971
960
  result = { ...rawResult, data: rawResult.data };
@@ -987,7 +976,7 @@ app4.openapi(
987
976
  operationId: "get-agent-relation-by-id",
988
977
  tags: ["CRUD Agent Relations"],
989
978
  request: {
990
- params: agentsCore.TenantProjectParamsSchema.merge(agentsCore.IdParamsSchema)
979
+ params: agentsCore.TenantProjectGraphIdParamsSchema
991
980
  },
992
981
  responses: {
993
982
  200: {
@@ -1002,9 +991,9 @@ app4.openapi(
1002
991
  }
1003
992
  }),
1004
993
  async (c) => {
1005
- const { tenantId, projectId, id } = c.req.valid("param");
994
+ const { tenantId, projectId, graphId, id } = c.req.valid("param");
1006
995
  const agentRelation = await agentsCore.getAgentRelationById(dbClient_default)({
1007
- scopes: { tenantId, projectId },
996
+ scopes: { tenantId, projectId, graphId },
1008
997
  relationId: id
1009
998
  });
1010
999
  if (!agentRelation) {
@@ -1024,7 +1013,7 @@ app4.openapi(
1024
1013
  operationId: "create-agent-relation",
1025
1014
  tags: ["CRUD Agent Relations"],
1026
1015
  request: {
1027
- params: agentsCore.TenantProjectParamsSchema,
1016
+ params: agentsCore.TenantProjectGraphParamsSchema,
1028
1017
  body: {
1029
1018
  content: {
1030
1019
  "application/json": {
@@ -1046,13 +1035,12 @@ app4.openapi(
1046
1035
  }
1047
1036
  }),
1048
1037
  async (c) => {
1049
- const { tenantId, projectId } = c.req.valid("param");
1038
+ const { tenantId, projectId, graphId } = c.req.valid("param");
1050
1039
  const body = await c.req.valid("json");
1051
1040
  const isExternalAgent = body.externalAgentId != null;
1052
1041
  if (isExternalAgent && body.externalAgentId) {
1053
1042
  const externalAgentExists = await agentsCore.validateExternalAgent(dbClient_default)({
1054
- scopes: { tenantId, projectId },
1055
- agentId: body.externalAgentId
1043
+ scopes: { tenantId, projectId, graphId, agentId: body.externalAgentId }
1056
1044
  });
1057
1045
  if (!externalAgentExists) {
1058
1046
  throw agentsCore.createApiError({
@@ -1063,8 +1051,7 @@ app4.openapi(
1063
1051
  }
1064
1052
  if (!isExternalAgent && body.targetAgentId) {
1065
1053
  const internalAgentExists = await agentsCore.validateInternalAgent(dbClient_default)({
1066
- scopes: { tenantId, projectId },
1067
- agentId: body.targetAgentId
1054
+ scopes: { tenantId, projectId, graphId, agentId: body.targetAgentId }
1068
1055
  });
1069
1056
  if (!internalAgentExists) {
1070
1057
  throw agentsCore.createApiError({
@@ -1074,11 +1061,11 @@ app4.openapi(
1074
1061
  }
1075
1062
  }
1076
1063
  const existingRelations = await agentsCore.listAgentRelations(dbClient_default)({
1077
- scopes: { tenantId, projectId },
1064
+ scopes: { tenantId, projectId, graphId },
1078
1065
  pagination: { page: 1, limit: 1e3 }
1079
1066
  });
1080
1067
  const isDuplicate = existingRelations.data.some((relation) => {
1081
- if (relation.graphId !== body.graphId || relation.sourceAgentId !== body.sourceAgentId) {
1068
+ if (relation.graphId !== graphId || relation.sourceAgentId !== body.sourceAgentId) {
1082
1069
  return false;
1083
1070
  }
1084
1071
  if (isExternalAgent) {
@@ -1094,7 +1081,7 @@ app4.openapi(
1094
1081
  });
1095
1082
  }
1096
1083
  const relationData = {
1097
- graphId: body.graphId,
1084
+ graphId,
1098
1085
  tenantId,
1099
1086
  id: nanoid.nanoid(),
1100
1087
  projectId,
@@ -1117,7 +1104,7 @@ app4.openapi(
1117
1104
  operationId: "update-agent-relation",
1118
1105
  tags: ["CRUD Agent Relations"],
1119
1106
  request: {
1120
- params: agentsCore.TenantProjectParamsSchema.merge(agentsCore.IdParamsSchema),
1107
+ params: agentsCore.TenantProjectGraphIdParamsSchema,
1121
1108
  body: {
1122
1109
  content: {
1123
1110
  "application/json": {
@@ -1139,10 +1126,10 @@ app4.openapi(
1139
1126
  }
1140
1127
  }),
1141
1128
  async (c) => {
1142
- const { tenantId, projectId, id } = c.req.valid("param");
1129
+ const { tenantId, projectId, graphId, id } = c.req.valid("param");
1143
1130
  const body = await c.req.valid("json");
1144
1131
  const updatedAgentRelation = await agentsCore.updateAgentRelation(dbClient_default)({
1145
- scopes: { tenantId, projectId },
1132
+ scopes: { tenantId, projectId, graphId },
1146
1133
  relationId: id,
1147
1134
  data: body
1148
1135
  });
@@ -1163,7 +1150,7 @@ app4.openapi(
1163
1150
  operationId: "delete-agent-relation",
1164
1151
  tags: ["CRUD Agent Relations"],
1165
1152
  request: {
1166
- params: agentsCore.TenantProjectParamsSchema.merge(agentsCore.IdParamsSchema)
1153
+ params: agentsCore.TenantProjectGraphIdParamsSchema
1167
1154
  },
1168
1155
  responses: {
1169
1156
  204: {
@@ -1180,9 +1167,9 @@ app4.openapi(
1180
1167
  }
1181
1168
  }),
1182
1169
  async (c) => {
1183
- const { tenantId, projectId, id } = c.req.valid("param");
1170
+ const { tenantId, projectId, graphId, id } = c.req.valid("param");
1184
1171
  const deleted = await agentsCore.deleteAgentRelation(dbClient_default)({
1185
- scopes: { tenantId, projectId },
1172
+ scopes: { tenantId, projectId, graphId },
1186
1173
  relationId: id
1187
1174
  });
1188
1175
  if (!deleted) {
@@ -1204,7 +1191,7 @@ app5.openapi(
1204
1191
  operationId: "list-agents",
1205
1192
  tags: ["CRUD Agent"],
1206
1193
  request: {
1207
- params: agentsCore.TenantProjectParamsSchema,
1194
+ params: agentsCore.TenantProjectGraphParamsSchema,
1208
1195
  query: agentsCore.PaginationQueryParamsSchema
1209
1196
  },
1210
1197
  responses: {
@@ -1220,11 +1207,11 @@ app5.openapi(
1220
1207
  }
1221
1208
  }),
1222
1209
  async (c) => {
1223
- const { tenantId, projectId } = c.req.valid("param");
1210
+ const { tenantId, projectId, graphId } = c.req.valid("param");
1224
1211
  const page = Number(c.req.query("page")) || 1;
1225
1212
  const limit = Math.min(Number(c.req.query("limit")) || 10, 100);
1226
1213
  const result = await agentsCore.listAgentsPaginated(dbClient_default)({
1227
- scopes: { tenantId, projectId },
1214
+ scopes: { tenantId, projectId, graphId },
1228
1215
  pagination: { page, limit }
1229
1216
  });
1230
1217
  const dataWithType = {
@@ -1245,7 +1232,7 @@ app5.openapi(
1245
1232
  operationId: "get-agent-by-id",
1246
1233
  tags: ["CRUD Agent"],
1247
1234
  request: {
1248
- params: agentsCore.TenantProjectIdParamsSchema
1235
+ params: agentsCore.TenantProjectGraphIdParamsSchema
1249
1236
  },
1250
1237
  responses: {
1251
1238
  200: {
@@ -1260,9 +1247,9 @@ app5.openapi(
1260
1247
  }
1261
1248
  }),
1262
1249
  async (c) => {
1263
- const { tenantId, projectId, id } = c.req.valid("param");
1250
+ const { tenantId, projectId, graphId, id } = c.req.valid("param");
1264
1251
  const agent = await agentsCore.getAgentById(dbClient_default)({
1265
- scopes: { tenantId, projectId },
1252
+ scopes: { tenantId, projectId, graphId },
1266
1253
  agentId: id
1267
1254
  });
1268
1255
  if (!agent) {
@@ -1286,7 +1273,7 @@ app5.openapi(
1286
1273
  operationId: "create-agent",
1287
1274
  tags: ["CRUD Agent"],
1288
1275
  request: {
1289
- params: agentsCore.TenantProjectParamsSchema,
1276
+ params: agentsCore.TenantProjectGraphParamsSchema,
1290
1277
  body: {
1291
1278
  content: {
1292
1279
  "application/json": {
@@ -1308,14 +1295,15 @@ app5.openapi(
1308
1295
  }
1309
1296
  }),
1310
1297
  async (c) => {
1311
- const { tenantId, projectId } = c.req.valid("param");
1298
+ const { tenantId, projectId, graphId } = c.req.valid("param");
1312
1299
  const body = c.req.valid("json");
1313
1300
  const agentId = body.id ? String(body.id) : nanoid.nanoid();
1314
1301
  const agent = await agentsCore.createAgent(dbClient_default)({
1315
1302
  ...body,
1316
1303
  id: agentId,
1317
1304
  tenantId,
1318
- projectId
1305
+ projectId,
1306
+ graphId
1319
1307
  });
1320
1308
  const agentWithType = {
1321
1309
  ...agent,
@@ -1332,7 +1320,7 @@ app5.openapi(
1332
1320
  operationId: "update-agent",
1333
1321
  tags: ["CRUD Agent"],
1334
1322
  request: {
1335
- params: agentsCore.TenantProjectIdParamsSchema,
1323
+ params: agentsCore.TenantProjectGraphIdParamsSchema,
1336
1324
  body: {
1337
1325
  content: {
1338
1326
  "application/json": {
@@ -1354,10 +1342,10 @@ app5.openapi(
1354
1342
  }
1355
1343
  }),
1356
1344
  async (c) => {
1357
- const { tenantId, projectId, id } = c.req.valid("param");
1345
+ const { tenantId, projectId, graphId, id } = c.req.valid("param");
1358
1346
  const body = c.req.valid("json");
1359
1347
  const updatedAgent = await agentsCore.updateAgent(dbClient_default)({
1360
- scopes: { tenantId, projectId },
1348
+ scopes: { tenantId, projectId, graphId },
1361
1349
  agentId: id,
1362
1350
  data: body
1363
1351
  });
@@ -1382,7 +1370,7 @@ app5.openapi(
1382
1370
  operationId: "delete-agent",
1383
1371
  tags: ["CRUD Agent"],
1384
1372
  request: {
1385
- params: agentsCore.TenantProjectIdParamsSchema
1373
+ params: agentsCore.TenantProjectGraphIdParamsSchema
1386
1374
  },
1387
1375
  responses: {
1388
1376
  204: {
@@ -1399,9 +1387,9 @@ app5.openapi(
1399
1387
  }
1400
1388
  }),
1401
1389
  async (c) => {
1402
- const { tenantId, projectId, id } = c.req.valid("param");
1390
+ const { tenantId, projectId, graphId, id } = c.req.valid("param");
1403
1391
  const deleted = await agentsCore.deleteAgent(dbClient_default)({
1404
- scopes: { tenantId, projectId },
1392
+ scopes: { tenantId, projectId, graphId },
1405
1393
  agentId: id
1406
1394
  });
1407
1395
  if (!deleted) {
@@ -1423,7 +1411,7 @@ app6.openapi(
1423
1411
  operationId: "list-agent-tool-relations",
1424
1412
  tags: ["CRUD Agent Tool Relations"],
1425
1413
  request: {
1426
- params: agentsCore.TenantProjectParamsSchema,
1414
+ params: agentsCore.TenantProjectGraphParamsSchema,
1427
1415
  query: agentsCore.PaginationQueryParamsSchema.extend({
1428
1416
  agentId: zod.z.string().optional(),
1429
1417
  toolId: zod.z.string().optional()
@@ -1442,13 +1430,12 @@ app6.openapi(
1442
1430
  }
1443
1431
  }),
1444
1432
  async (c) => {
1445
- const { tenantId, projectId } = c.req.valid("param");
1433
+ const { tenantId, projectId, graphId } = c.req.valid("param");
1446
1434
  const { page, limit, agentId, toolId } = c.req.valid("query");
1447
1435
  let result;
1448
1436
  if (agentId) {
1449
1437
  const dbResult = await agentsCore.getAgentToolRelationByAgent(dbClient_default)({
1450
- scopes: { tenantId, projectId },
1451
- agentId,
1438
+ scopes: { tenantId, projectId, graphId, agentId },
1452
1439
  pagination: { page, limit }
1453
1440
  });
1454
1441
  result = {
@@ -1457,7 +1444,7 @@ app6.openapi(
1457
1444
  };
1458
1445
  } else if (toolId) {
1459
1446
  const dbResult = await agentsCore.getAgentToolRelationByTool(dbClient_default)({
1460
- scopes: { tenantId, projectId },
1447
+ scopes: { tenantId, projectId, graphId },
1461
1448
  toolId,
1462
1449
  pagination: { page, limit }
1463
1450
  });
@@ -1467,7 +1454,7 @@ app6.openapi(
1467
1454
  };
1468
1455
  } else {
1469
1456
  const dbResult = await agentsCore.listAgentToolRelations(dbClient_default)({
1470
- scopes: { tenantId, projectId },
1457
+ scopes: { tenantId, projectId, graphId },
1471
1458
  pagination: { page, limit }
1472
1459
  });
1473
1460
  result = {
@@ -1486,7 +1473,7 @@ app6.openapi(
1486
1473
  operationId: "get-agent-tool-relation",
1487
1474
  tags: ["CRUD Agent Tool Relations"],
1488
1475
  request: {
1489
- params: agentsCore.TenantProjectParamsSchema.merge(agentsCore.IdParamsSchema)
1476
+ params: agentsCore.TenantProjectGraphParamsSchema.merge(agentsCore.IdParamsSchema)
1490
1477
  },
1491
1478
  responses: {
1492
1479
  200: {
@@ -1501,9 +1488,9 @@ app6.openapi(
1501
1488
  }
1502
1489
  }),
1503
1490
  async (c) => {
1504
- const { tenantId, projectId, id } = c.req.valid("param");
1491
+ const { tenantId, projectId, graphId, id } = c.req.valid("param");
1505
1492
  const agentToolRelation = await agentsCore.getAgentToolRelationById(dbClient_default)({
1506
- scopes: { tenantId, projectId },
1493
+ scopes: { tenantId, projectId, graphId, agentId: id },
1507
1494
  relationId: id
1508
1495
  });
1509
1496
  if (!agentToolRelation) {
@@ -1523,7 +1510,7 @@ app6.openapi(
1523
1510
  operationId: "get-tools-for-agent",
1524
1511
  tags: ["CRUD Agent Tool Relations"],
1525
1512
  request: {
1526
- params: agentsCore.TenantProjectParamsSchema.extend({
1513
+ params: agentsCore.TenantProjectGraphParamsSchema.extend({
1527
1514
  agentId: zod.z.string()
1528
1515
  }),
1529
1516
  query: agentsCore.PaginationQueryParamsSchema
@@ -1541,11 +1528,10 @@ app6.openapi(
1541
1528
  }
1542
1529
  }),
1543
1530
  async (c) => {
1544
- const { tenantId, projectId, agentId } = c.req.valid("param");
1531
+ const { tenantId, projectId, graphId, agentId } = c.req.valid("param");
1545
1532
  const { page, limit } = c.req.valid("query");
1546
1533
  const dbResult = await agentsCore.getToolsForAgent(dbClient_default)({
1547
- scopes: { tenantId, projectId },
1548
- agentId,
1534
+ scopes: { tenantId, projectId, graphId, agentId },
1549
1535
  pagination: { page, limit }
1550
1536
  });
1551
1537
  const result = {
@@ -1563,7 +1549,7 @@ app6.openapi(
1563
1549
  operationId: "get-agents-for-tool",
1564
1550
  tags: ["CRUD Agent Tool Relations"],
1565
1551
  request: {
1566
- params: agentsCore.TenantProjectParamsSchema.extend({
1552
+ params: agentsCore.TenantProjectGraphParamsSchema.extend({
1567
1553
  toolId: zod.z.string()
1568
1554
  }),
1569
1555
  query: agentsCore.PaginationQueryParamsSchema
@@ -1581,18 +1567,14 @@ app6.openapi(
1581
1567
  }
1582
1568
  }),
1583
1569
  async (c) => {
1584
- const { tenantId, projectId, toolId } = c.req.valid("param");
1570
+ const { tenantId, projectId, graphId, toolId } = c.req.valid("param");
1585
1571
  const { page, limit } = c.req.valid("query");
1586
1572
  const dbResult = await agentsCore.getAgentsForTool(dbClient_default)({
1587
- scopes: { tenantId, projectId },
1573
+ scopes: { tenantId, projectId, graphId },
1588
1574
  toolId,
1589
1575
  pagination: { page, limit }
1590
1576
  });
1591
- const result = {
1592
- data: dbResult.data,
1593
- pagination: dbResult.pagination
1594
- };
1595
- return c.json(result);
1577
+ return c.json(dbResult);
1596
1578
  }
1597
1579
  );
1598
1580
  app6.openapi(
@@ -1603,7 +1585,7 @@ app6.openapi(
1603
1585
  operationId: "create-agent-tool-relation",
1604
1586
  tags: ["CRUD Agent Tool Relations"],
1605
1587
  request: {
1606
- params: agentsCore.TenantProjectParamsSchema,
1588
+ params: agentsCore.TenantProjectGraphParamsSchema,
1607
1589
  body: {
1608
1590
  content: {
1609
1591
  "application/json": {
@@ -1625,10 +1607,10 @@ app6.openapi(
1625
1607
  }
1626
1608
  }),
1627
1609
  async (c) => {
1628
- const { tenantId, projectId } = c.req.valid("param");
1610
+ const { tenantId, projectId, graphId } = c.req.valid("param");
1629
1611
  const body = c.req.valid("json");
1630
1612
  const existingRelations = await agentsCore.listAgentToolRelations(dbClient_default)({
1631
- scopes: { tenantId, projectId },
1613
+ scopes: { tenantId, projectId, graphId },
1632
1614
  pagination: { limit: 1e3 }
1633
1615
  });
1634
1616
  const isDuplicate = existingRelations.data.some((relation) => {
@@ -1643,7 +1625,7 @@ app6.openapi(
1643
1625
  }
1644
1626
  try {
1645
1627
  const agentToolRelation = await agentsCore.createAgentToolRelation(dbClient_default)({
1646
- scopes: { tenantId, projectId },
1628
+ scopes: { tenantId, projectId, graphId },
1647
1629
  data: body
1648
1630
  });
1649
1631
  return c.json({ data: agentToolRelation }, 201);
@@ -1666,7 +1648,7 @@ app6.openapi(
1666
1648
  operationId: "update-agent-tool-relation",
1667
1649
  tags: ["CRUD Agent Tool Relations"],
1668
1650
  request: {
1669
- params: agentsCore.TenantProjectParamsSchema.merge(agentsCore.IdParamsSchema),
1651
+ params: agentsCore.TenantProjectGraphParamsSchema.merge(agentsCore.IdParamsSchema),
1670
1652
  body: {
1671
1653
  content: {
1672
1654
  "application/json": {
@@ -1688,7 +1670,7 @@ app6.openapi(
1688
1670
  }
1689
1671
  }),
1690
1672
  async (c) => {
1691
- const { tenantId, projectId, id } = c.req.valid("param");
1673
+ const { tenantId, projectId, graphId, id } = c.req.valid("param");
1692
1674
  console.log("id", id);
1693
1675
  const body = await c.req.valid("json");
1694
1676
  if (Object.keys(body).length === 0) {
@@ -1698,7 +1680,7 @@ app6.openapi(
1698
1680
  });
1699
1681
  }
1700
1682
  const updatedAgentToolRelation = await agentsCore.updateAgentToolRelation(dbClient_default)({
1701
- scopes: { tenantId, projectId },
1683
+ scopes: { tenantId, projectId, graphId },
1702
1684
  relationId: id,
1703
1685
  data: body
1704
1686
  });
@@ -1719,7 +1701,7 @@ app6.openapi(
1719
1701
  operationId: "delete-agent-tool-relation",
1720
1702
  tags: ["CRUD Agent Tool Relations"],
1721
1703
  request: {
1722
- params: agentsCore.TenantProjectParamsSchema.merge(agentsCore.IdParamsSchema)
1704
+ params: agentsCore.TenantProjectGraphParamsSchema.merge(agentsCore.IdParamsSchema)
1723
1705
  },
1724
1706
  responses: {
1725
1707
  204: {
@@ -1736,9 +1718,9 @@ app6.openapi(
1736
1718
  }
1737
1719
  }),
1738
1720
  async (c) => {
1739
- const { tenantId, projectId, id } = c.req.valid("param");
1721
+ const { tenantId, projectId, graphId, id } = c.req.valid("param");
1740
1722
  const deleted = await agentsCore.deleteAgentToolRelation(dbClient_default)({
1741
- scopes: { tenantId, projectId },
1723
+ scopes: { tenantId, projectId, graphId },
1742
1724
  relationId: id
1743
1725
  });
1744
1726
  if (!deleted) {
@@ -2862,7 +2844,7 @@ app12.openapi(
2862
2844
  operationId: "list-external-agents",
2863
2845
  tags: ["CRUD External Agents"],
2864
2846
  request: {
2865
- params: agentsCore.TenantProjectParamsSchema,
2847
+ params: agentsCore.TenantProjectGraphParamsSchema,
2866
2848
  query: agentsCore.PaginationQueryParamsSchema
2867
2849
  },
2868
2850
  responses: {
@@ -2878,10 +2860,10 @@ app12.openapi(
2878
2860
  }
2879
2861
  }),
2880
2862
  async (c) => {
2881
- const { tenantId, projectId } = c.req.valid("param");
2863
+ const { tenantId, projectId, graphId } = c.req.valid("param");
2882
2864
  const { page, limit } = c.req.valid("query");
2883
2865
  const result = await agentsCore.listExternalAgentsPaginated(dbClient_default)({
2884
- scopes: { tenantId, projectId },
2866
+ scopes: { tenantId, projectId, graphId },
2885
2867
  pagination: { page, limit }
2886
2868
  });
2887
2869
  const dataWithType = {
@@ -2902,7 +2884,7 @@ app12.openapi(
2902
2884
  operationId: "get-external-agent-by-id",
2903
2885
  tags: ["CRUD External Agents"],
2904
2886
  request: {
2905
- params: agentsCore.TenantProjectParamsSchema.merge(agentsCore.IdParamsSchema)
2887
+ params: agentsCore.TenantProjectGraphIdParamsSchema
2906
2888
  },
2907
2889
  responses: {
2908
2890
  200: {
@@ -2917,9 +2899,9 @@ app12.openapi(
2917
2899
  }
2918
2900
  }),
2919
2901
  async (c) => {
2920
- const { tenantId, projectId, id } = c.req.valid("param");
2902
+ const { tenantId, projectId, graphId, id } = c.req.valid("param");
2921
2903
  const externalAgent = await agentsCore.getExternalAgent(dbClient_default)({
2922
- scopes: { tenantId, projectId },
2904
+ scopes: { tenantId, projectId, graphId },
2923
2905
  agentId: id
2924
2906
  });
2925
2907
  if (!externalAgent) {
@@ -2943,7 +2925,7 @@ app12.openapi(
2943
2925
  operationId: "create-external-agent",
2944
2926
  tags: ["CRUD External Agents"],
2945
2927
  request: {
2946
- params: agentsCore.TenantProjectParamsSchema,
2928
+ params: agentsCore.TenantProjectGraphParamsSchema,
2947
2929
  body: {
2948
2930
  content: {
2949
2931
  "application/json": {
@@ -2965,11 +2947,12 @@ app12.openapi(
2965
2947
  }
2966
2948
  }),
2967
2949
  async (c) => {
2968
- const { tenantId, projectId } = c.req.valid("param");
2950
+ const { tenantId, projectId, graphId } = c.req.valid("param");
2969
2951
  const body = c.req.valid("json");
2970
2952
  const externalAgentData = {
2971
2953
  tenantId,
2972
2954
  projectId,
2955
+ graphId,
2973
2956
  id: body.id ? String(body.id) : nanoid.nanoid(),
2974
2957
  name: body.name,
2975
2958
  description: body.description,
@@ -2993,7 +2976,7 @@ app12.openapi(
2993
2976
  operationId: "update-external-agent",
2994
2977
  tags: ["CRUD External Agents"],
2995
2978
  request: {
2996
- params: agentsCore.TenantProjectParamsSchema.merge(agentsCore.IdParamsSchema),
2979
+ params: agentsCore.TenantProjectGraphIdParamsSchema,
2997
2980
  body: {
2998
2981
  content: {
2999
2982
  "application/json": {
@@ -3015,10 +2998,10 @@ app12.openapi(
3015
2998
  }
3016
2999
  }),
3017
3000
  async (c) => {
3018
- const { tenantId, projectId, id } = c.req.valid("param");
3001
+ const { tenantId, projectId, graphId, id } = c.req.valid("param");
3019
3002
  const body = c.req.valid("json");
3020
3003
  const updatedExternalAgent = await agentsCore.updateExternalAgent(dbClient_default)({
3021
- scopes: { tenantId, projectId },
3004
+ scopes: { tenantId, projectId, graphId },
3022
3005
  agentId: id,
3023
3006
  data: body
3024
3007
  });
@@ -3043,7 +3026,7 @@ app12.openapi(
3043
3026
  operationId: "delete-external-agent",
3044
3027
  tags: ["CRUD External Agents"],
3045
3028
  request: {
3046
- params: agentsCore.TenantProjectParamsSchema.merge(agentsCore.IdParamsSchema)
3029
+ params: agentsCore.TenantProjectGraphIdParamsSchema
3047
3030
  },
3048
3031
  responses: {
3049
3032
  204: {
@@ -3060,9 +3043,9 @@ app12.openapi(
3060
3043
  }
3061
3044
  }),
3062
3045
  async (c) => {
3063
- const { tenantId, projectId, id } = c.req.valid("param");
3046
+ const { tenantId, projectId, graphId, id } = c.req.valid("param");
3064
3047
  const deleted = await agentsCore.deleteExternalAgent(dbClient_default)({
3065
- scopes: { tenantId, projectId },
3048
+ scopes: { tenantId, projectId, graphId },
3066
3049
  agentId: id
3067
3050
  });
3068
3051
  if (!deleted) {
@@ -3170,8 +3153,7 @@ app13.openapi(
3170
3153
  dbClient_default,
3171
3154
  logger3
3172
3155
  )({
3173
- scopes: { tenantId, projectId },
3174
- graphId
3156
+ scopes: { tenantId, projectId, graphId }
3175
3157
  });
3176
3158
  if (!graph) {
3177
3159
  throw agentsCore.createApiError({
@@ -3247,8 +3229,7 @@ app13.openapi(
3247
3229
  dbClient_default,
3248
3230
  logger3
3249
3231
  )({
3250
- scopes: { tenantId, projectId },
3251
- graphId
3232
+ scopes: { tenantId, projectId, graphId }
3252
3233
  });
3253
3234
  const isCreate = !existingGraph;
3254
3235
  const updatedGraph = isCreate ? await agentsCore.createFullGraphServerSide(dbClient_default, logger3)(
@@ -3304,8 +3285,7 @@ app13.openapi(
3304
3285
  dbClient_default,
3305
3286
  logger3
3306
3287
  )({
3307
- scopes: { tenantId, projectId },
3308
- graphId
3288
+ scopes: { tenantId, projectId, graphId }
3309
3289
  });
3310
3290
  if (!deleted) {
3311
3291
  throw agentsCore.createApiError({
@@ -4704,17 +4684,17 @@ var tools_default = app15;
4704
4684
  // src/routes/index.ts
4705
4685
  var app16 = new zodOpenapi.OpenAPIHono();
4706
4686
  app16.route("/projects", projects_default);
4707
- app16.route("/projects/:projectId/agents", agents_default);
4708
- app16.route("/projects/:projectId/agent-relations", agentRelations_default);
4687
+ app16.route("/projects/:projectId/graphs/:graphId/agents", agents_default);
4688
+ app16.route("/projects/:projectId/graphs/:graphId/agent-relations", agentRelations_default);
4709
4689
  app16.route("/projects/:projectId/agent-graphs", agentGraph_default);
4710
- app16.route("/projects/:projectId/agent-tool-relations", agentToolRelations_default);
4711
- app16.route("/projects/:projectId/agent-artifact-components", agentArtifactComponents_default);
4712
- app16.route("/projects/:projectId/agent-data-components", agentDataComponents_default);
4690
+ app16.route("/projects/:projectId/graphs/:graphId/agent-tool-relations", agentToolRelations_default);
4691
+ app16.route("/projects/:projectId/graphs/:graphId/agent-artifact-components", agentArtifactComponents_default);
4692
+ app16.route("/projects/:projectId/graphs/:graphId/agent-data-components", agentDataComponents_default);
4713
4693
  app16.route("/projects/:projectId/artifact-components", artifactComponents_default);
4714
4694
  app16.route("/projects/:projectId/context-configs", contextConfigs_default);
4715
4695
  app16.route("/projects/:projectId/credentials", credentials_default);
4716
4696
  app16.route("/projects/:projectId/data-components", dataComponents_default);
4717
- app16.route("/projects/:projectId/external-agents", externalAgents_default);
4697
+ app16.route("/projects/:projectId/graphs/:graphId/external-agents", externalAgents_default);
4718
4698
  app16.route("/projects/:projectId/tools", tools_default);
4719
4699
  app16.route("/projects/:projectId/api-keys", apiKeys_default);
4720
4700
  app16.route("/projects/:projectId/graph", graphFull_default);
@@ -4997,8 +4977,7 @@ app18.openapi(
4997
4977
  dbClient_default,
4998
4978
  logger8
4999
4979
  )({
5000
- scopes: { tenantId, projectId },
5001
- projectId
4980
+ scopes: { tenantId, projectId }
5002
4981
  });
5003
4982
  if (!project) {
5004
4983
  throw agentsCore.createApiError({
@@ -5074,8 +5053,7 @@ app18.openapi(
5074
5053
  dbClient_default,
5075
5054
  logger8
5076
5055
  )({
5077
- scopes: { tenantId, projectId },
5078
- projectId
5056
+ scopes: { tenantId, projectId }
5079
5057
  });
5080
5058
  const isCreate = !existingProject;
5081
5059
  const updatedProject = isCreate ? await agentsCore.createFullProjectServerSide(dbClient_default, logger8)(
@@ -5131,8 +5109,7 @@ app18.openapi(
5131
5109
  dbClient_default,
5132
5110
  logger8
5133
5111
  )({
5134
- scopes: { tenantId, projectId },
5135
- projectId
5112
+ scopes: { tenantId, projectId }
5136
5113
  });
5137
5114
  if (!deleted) {
5138
5115
  throw agentsCore.createApiError({