@inkeep/agents-core 0.41.2 → 0.42.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.
Files changed (228) hide show
  1. package/dist/api-client/base-client.d.ts +87 -8
  2. package/dist/api-client/base-client.js +174 -1
  3. package/dist/api-client/eval-api-client.d.ts +47 -0
  4. package/dist/api-client/eval-api-client.js +65 -0
  5. package/dist/api-client/index.d.ts +4 -0
  6. package/dist/api-client/index.js +5 -0
  7. package/dist/api-client/manage-api-client.d.ts +34 -0
  8. package/dist/api-client/manage-api-client.js +104 -0
  9. package/dist/auth/auth.d.ts +86 -20
  10. package/dist/auth/auth.js +55 -1
  11. package/dist/auth/authz/client.d.ts +81 -0
  12. package/dist/auth/authz/client.js +189 -0
  13. package/dist/auth/authz/config.d.ts +76 -0
  14. package/dist/auth/authz/config.js +76 -0
  15. package/dist/auth/authz/index.d.ts +5 -0
  16. package/dist/auth/authz/index.js +6 -0
  17. package/dist/auth/authz/permissions.d.ts +57 -0
  18. package/dist/auth/authz/permissions.js +83 -0
  19. package/dist/auth/authz/sync.d.ts +85 -0
  20. package/dist/auth/authz/sync.js +237 -0
  21. package/dist/auth/permissions.d.ts +13 -13
  22. package/dist/auth/permissions.js +2 -181
  23. package/dist/client-exports.d.ts +8 -3
  24. package/dist/client-exports.js +3 -2
  25. package/dist/constants/context-breakdown.d.ts +61 -0
  26. package/dist/constants/context-breakdown.js +124 -0
  27. package/dist/constants/otel-attributes.d.ts +4 -0
  28. package/dist/constants/otel-attributes.js +4 -0
  29. package/dist/context/ContextConfig.d.ts +2 -2
  30. package/dist/context/ContextConfig.js +3 -3
  31. package/dist/context/TemplateEngine.js +0 -1
  32. package/dist/context/index.d.ts +1 -5
  33. package/dist/context/index.js +1 -5
  34. package/dist/credential-stuffer/CredentialStuffer.d.ts +1 -1
  35. package/dist/data-access/index.d.ts +34 -26
  36. package/dist/data-access/index.js +34 -26
  37. package/dist/data-access/manage/agentFull.d.ts +36 -0
  38. package/dist/data-access/{agentFull.js → manage/agentFull.js} +205 -7
  39. package/dist/data-access/{agents.d.ts → manage/agents.d.ts} +23 -22
  40. package/dist/data-access/{agents.js → manage/agents.js} +52 -7
  41. package/dist/data-access/{artifactComponents.d.ts → manage/artifactComponents.d.ts} +21 -21
  42. package/dist/data-access/{artifactComponents.js → manage/artifactComponents.js} +5 -5
  43. package/dist/data-access/{contextConfigs.d.ts → manage/contextConfigs.d.ts} +14 -14
  44. package/dist/data-access/{contextConfigs.js → manage/contextConfigs.js} +3 -3
  45. package/dist/data-access/{credentialReferences.d.ts → manage/credentialReferences.d.ts} +17 -17
  46. package/dist/data-access/{credentialReferences.js → manage/credentialReferences.js} +2 -2
  47. package/dist/data-access/{dataComponents.d.ts → manage/dataComponents.d.ts} +20 -20
  48. package/dist/data-access/{dataComponents.js → manage/dataComponents.js} +7 -7
  49. package/dist/data-access/manage/evalConfig.d.ts +221 -0
  50. package/dist/data-access/manage/evalConfig.js +275 -0
  51. package/dist/data-access/{externalAgents.d.ts → manage/externalAgents.d.ts} +16 -16
  52. package/dist/data-access/{externalAgents.js → manage/externalAgents.js} +2 -2
  53. package/dist/data-access/{functionTools.d.ts → manage/functionTools.d.ts} +65 -15
  54. package/dist/data-access/{functionTools.js → manage/functionTools.js} +90 -8
  55. package/dist/data-access/{functions.d.ts → manage/functions.d.ts} +9 -9
  56. package/dist/data-access/{functions.js → manage/functions.js} +3 -3
  57. package/dist/data-access/manage/projectFull.d.ts +38 -0
  58. package/dist/data-access/{projectFull.js → manage/projectFull.js} +64 -65
  59. package/dist/data-access/manage/projectLifecycle.d.ts +119 -0
  60. package/dist/data-access/manage/projectLifecycle.js +234 -0
  61. package/dist/data-access/manage/projects.d.ts +75 -0
  62. package/dist/data-access/{projects.js → manage/projects.js} +15 -16
  63. package/dist/data-access/{subAgentExternalAgentRelations.d.ts → manage/subAgentExternalAgentRelations.d.ts} +19 -19
  64. package/dist/data-access/{subAgentExternalAgentRelations.js → manage/subAgentExternalAgentRelations.js} +2 -2
  65. package/dist/data-access/{subAgentRelations.d.ts → manage/subAgentRelations.d.ts} +29 -29
  66. package/dist/data-access/{subAgentRelations.js → manage/subAgentRelations.js} +3 -3
  67. package/dist/data-access/{subAgentTeamAgentRelations.d.ts → manage/subAgentTeamAgentRelations.d.ts} +19 -19
  68. package/dist/data-access/{subAgentTeamAgentRelations.js → manage/subAgentTeamAgentRelations.js} +2 -2
  69. package/dist/data-access/{subAgents.d.ts → manage/subAgents.d.ts} +13 -13
  70. package/dist/data-access/{subAgents.js → manage/subAgents.js} +4 -4
  71. package/dist/data-access/{tools.d.ts → manage/tools.d.ts} +26 -19
  72. package/dist/data-access/{tools.js → manage/tools.js} +57 -35
  73. package/dist/data-access/manage/triggers.d.ts +80 -0
  74. package/dist/data-access/manage/triggers.js +81 -0
  75. package/dist/data-access/{apiKeys.d.ts → runtime/apiKeys.d.ts} +17 -17
  76. package/dist/data-access/{apiKeys.js → runtime/apiKeys.js} +3 -3
  77. package/dist/data-access/runtime/cascade-delete.d.ts +77 -0
  78. package/dist/data-access/runtime/cascade-delete.js +111 -0
  79. package/dist/data-access/{contextCache.d.ts → runtime/contextCache.d.ts} +13 -13
  80. package/dist/data-access/{contextCache.js → runtime/contextCache.js} +5 -5
  81. package/dist/data-access/{conversations.d.ts → runtime/conversations.d.ts} +68 -19
  82. package/dist/data-access/{conversations.js → runtime/conversations.js} +13 -7
  83. package/dist/data-access/runtime/evalRuns.d.ts +120 -0
  84. package/dist/data-access/runtime/evalRuns.js +168 -0
  85. package/dist/data-access/{ledgerArtifacts.d.ts → runtime/ledgerArtifacts.d.ts} +13 -13
  86. package/dist/data-access/{ledgerArtifacts.js → runtime/ledgerArtifacts.js} +3 -3
  87. package/dist/data-access/{messages.d.ts → runtime/messages.d.ts} +15 -15
  88. package/dist/data-access/{messages.js → runtime/messages.js} +2 -2
  89. package/dist/data-access/{organizations.d.ts → runtime/organizations.d.ts} +16 -7
  90. package/dist/data-access/{organizations.js → runtime/organizations.js} +15 -3
  91. package/dist/data-access/runtime/projects.d.ts +62 -0
  92. package/dist/data-access/runtime/projects.js +90 -0
  93. package/dist/data-access/runtime/tasks.d.ts +55 -0
  94. package/dist/data-access/{tasks.js → runtime/tasks.js} +2 -2
  95. package/dist/data-access/runtime/triggerInvocations.d.ts +62 -0
  96. package/dist/data-access/runtime/triggerInvocations.js +54 -0
  97. package/dist/data-access/runtime/users.d.ts +19 -0
  98. package/dist/data-access/{users.js → runtime/users.js} +2 -2
  99. package/dist/data-access/validation.d.ts +4 -4
  100. package/dist/data-access/validation.js +1 -1
  101. package/dist/db/clean.d.ts +8 -4
  102. package/dist/db/clean.js +14 -105
  103. package/dist/db/delete.d.ts +1 -1
  104. package/dist/db/delete.js +7 -10
  105. package/dist/db/manage/dolt-cleanup.d.ts +51 -0
  106. package/dist/db/manage/dolt-cleanup.js +132 -0
  107. package/dist/db/manage/manage-client.d.ts +26 -0
  108. package/dist/db/manage/manage-client.js +68 -0
  109. package/dist/db/{schema.d.ts → manage/manage-schema.d.ts} +1459 -1285
  110. package/dist/db/{schema.js → manage/manage-schema.js} +433 -341
  111. package/dist/db/manage/test-manage-client.d.ts +27 -0
  112. package/dist/db/manage/test-manage-client.js +68 -0
  113. package/dist/db/runtime/runtime-client.d.ts +20 -0
  114. package/dist/db/runtime/runtime-client.js +30 -0
  115. package/dist/db/runtime/runtime-schema.d.ts +2834 -0
  116. package/dist/db/runtime/runtime-schema.js +483 -0
  117. package/dist/db/runtime/test-runtime-client.d.ts +27 -0
  118. package/dist/db/{test-client.js → runtime/test-runtime-client.js} +11 -25
  119. package/dist/dolt/branch.d.ts +62 -0
  120. package/dist/dolt/branch.js +82 -0
  121. package/dist/dolt/branches-api.d.ts +108 -0
  122. package/dist/dolt/branches-api.js +162 -0
  123. package/dist/dolt/commit.d.ts +94 -0
  124. package/dist/dolt/commit.js +103 -0
  125. package/dist/dolt/diff.d.ts +27 -0
  126. package/dist/dolt/diff.js +21 -0
  127. package/dist/dolt/index.d.ts +10 -0
  128. package/dist/dolt/index.js +11 -0
  129. package/dist/dolt/merge.d.ts +63 -0
  130. package/dist/dolt/merge.js +81 -0
  131. package/dist/dolt/migrate-all-branches.d.ts +4 -0
  132. package/dist/dolt/migrate-all-branches.js +78 -0
  133. package/dist/dolt/migrate-dolt.d.ts +1 -0
  134. package/dist/dolt/migrate-dolt.js +22 -0
  135. package/dist/dolt/ref-helpers.d.ts +19 -0
  136. package/dist/dolt/ref-helpers.js +65 -0
  137. package/dist/dolt/ref-middleware.d.ts +82 -0
  138. package/dist/dolt/ref-middleware.js +217 -0
  139. package/dist/dolt/ref-scope.d.ts +101 -0
  140. package/dist/dolt/ref-scope.js +231 -0
  141. package/dist/dolt/schema-sync.d.ts +134 -0
  142. package/dist/dolt/schema-sync.js +246 -0
  143. package/dist/env.d.ts +6 -4
  144. package/dist/env.js +3 -2
  145. package/dist/index.d.ts +71 -44
  146. package/dist/index.js +74 -47
  147. package/dist/types/entities.d.ts +81 -2
  148. package/dist/types/index.d.ts +3 -3
  149. package/dist/types/utility.d.ts +45 -4
  150. package/dist/utils/JsonTransformer.d.ts +44 -0
  151. package/dist/utils/JsonTransformer.js +112 -0
  152. package/dist/utils/apiKeys.d.ts +5 -1
  153. package/dist/utils/apiKeys.js +11 -1
  154. package/dist/utils/colors.d.ts +34 -0
  155. package/dist/utils/colors.js +49 -0
  156. package/dist/utils/credential-store-utils.d.ts +1 -1
  157. package/dist/utils/format-messages.d.ts +1 -1
  158. package/dist/utils/index.d.ts +7 -3
  159. package/dist/utils/index.js +7 -3
  160. package/dist/utils/internal-service-auth.d.ts +79 -0
  161. package/dist/utils/internal-service-auth.js +140 -0
  162. package/dist/utils/jwt-helpers.d.ts +56 -0
  163. package/dist/utils/jwt-helpers.js +90 -0
  164. package/dist/utils/service-token-auth.d.ts +9 -27
  165. package/dist/utils/service-token-auth.js +48 -96
  166. package/dist/utils/template-interpolation.d.ts +22 -0
  167. package/dist/utils/template-interpolation.js +62 -0
  168. package/dist/utils/third-party-mcp-servers/composio-client.js +23 -23
  169. package/dist/utils/trigger-auth.d.ts +62 -0
  170. package/dist/utils/trigger-auth.js +125 -0
  171. package/dist/validation/agentFull.js +2 -4
  172. package/dist/validation/dolt-schemas.d.ts +49 -0
  173. package/dist/validation/dolt-schemas.js +44 -0
  174. package/dist/validation/drizzle-schema-helpers.d.ts +4 -26
  175. package/dist/validation/drizzle-schema-helpers.js +5 -151
  176. package/dist/validation/index.d.ts +4 -3
  177. package/dist/validation/index.js +3 -2
  178. package/dist/validation/schemas.d.ts +17647 -4789
  179. package/dist/validation/schemas.js +328 -11
  180. package/drizzle/manage/0000_tearful_rhodey.sql +414 -0
  181. package/drizzle/manage/0001_broken_wendell_vaughn.sql +19 -0
  182. package/drizzle/manage/0002_bent_sunfire.sql +1 -0
  183. package/drizzle/manage/meta/0000_snapshot.json +2987 -0
  184. package/drizzle/manage/meta/0001_snapshot.json +3115 -0
  185. package/drizzle/manage/meta/0002_snapshot.json +3115 -0
  186. package/drizzle/manage/meta/_journal.json +27 -0
  187. package/drizzle/runtime/0008_silly_preak.sql +127 -0
  188. package/drizzle/runtime/0009_freezing_leo.sql +17 -0
  189. package/drizzle/runtime/meta/0008_snapshot.json +2263 -0
  190. package/drizzle/runtime/meta/0009_snapshot.json +2397 -0
  191. package/drizzle/{meta → runtime/meta}/_journal.json +14 -0
  192. package/package.json +48 -15
  193. package/dist/context/ContextFetcher.d.ts +0 -73
  194. package/dist/context/ContextFetcher.js +0 -291
  195. package/dist/context/ContextResolver.d.ts +0 -60
  196. package/dist/context/ContextResolver.js +0 -278
  197. package/dist/context/context.d.ts +0 -27
  198. package/dist/context/context.js +0 -128
  199. package/dist/context/contextCache.d.ts +0 -58
  200. package/dist/context/contextCache.js +0 -177
  201. package/dist/data-access/agentFull.d.ts +0 -33
  202. package/dist/data-access/projectFull.d.ts +0 -32
  203. package/dist/data-access/projects.d.ts +0 -71
  204. package/dist/data-access/tasks.d.ts +0 -45
  205. package/dist/data-access/users.d.ts +0 -19
  206. package/dist/db/client.d.ts +0 -20
  207. package/dist/db/client.js +0 -28
  208. package/dist/db/test-client.d.ts +0 -31
  209. package/dist/middleware/contextValidation.d.ts +0 -46
  210. package/dist/middleware/contextValidation.js +0 -280
  211. package/dist/middleware/index.d.ts +0 -2
  212. package/dist/middleware/index.js +0 -3
  213. package/dist/utils/execution.d.ts +0 -22
  214. package/dist/utils/execution.js +0 -25
  215. /package/drizzle/{0000_exotic_mysterio.sql → runtime/0000_exotic_mysterio.sql} +0 -0
  216. /package/drizzle/{0001_calm_sheva_callister.sql → runtime/0001_calm_sheva_callister.sql} +0 -0
  217. /package/drizzle/{0002_puzzling_goblin_queen.sql → runtime/0002_puzzling_goblin_queen.sql} +0 -0
  218. /package/drizzle/{0003_sweet_human_robot.sql → runtime/0003_sweet_human_robot.sql} +0 -0
  219. /package/drizzle/{0004_cuddly_shooting_star.sql → runtime/0004_cuddly_shooting_star.sql} +0 -0
  220. /package/drizzle/{0005_reflective_starfox.sql → runtime/0005_reflective_starfox.sql} +0 -0
  221. /package/drizzle/{0006_stale_thaddeus_ross.sql → runtime/0006_stale_thaddeus_ross.sql} +0 -0
  222. /package/drizzle/{0007_slim_karma.sql → runtime/0007_slim_karma.sql} +0 -0
  223. /package/drizzle/{meta → runtime/meta}/0000_snapshot.json +0 -0
  224. /package/drizzle/{meta → runtime/meta}/0001_snapshot.json +0 -0
  225. /package/drizzle/{meta → runtime/meta}/0003_snapshot.json +0 -0
  226. /package/drizzle/{meta → runtime/meta}/0005_snapshot.json +0 -0
  227. /package/drizzle/{meta → runtime/meta}/0006_snapshot.json +0 -0
  228. /package/drizzle/{meta → runtime/meta}/0007_snapshot.json +0 -0
@@ -1,4 +1,4 @@
1
- import { getLogger } from "../utils/logger.js";
1
+ import { getLogger } from "../../utils/logger.js";
2
2
  import { deleteExternalAgent, listExternalAgents, upsertExternalAgent } from "./externalAgents.js";
3
3
  import { deleteFunction, listFunctions, upsertFunction } from "./functions.js";
4
4
  import { deleteCredentialReference, listCredentialReferences, upsertCredentialReference } from "./credentialReferences.js";
@@ -6,10 +6,10 @@ import { deleteTool, listTools, upsertTool } from "./tools.js";
6
6
  import { listAgents } from "./agents.js";
7
7
  import { deleteArtifactComponent, listArtifactComponents, upsertArtifactComponent } from "./artifactComponents.js";
8
8
  import { deleteDataComponent, listDataComponents, upsertDataComponent } from "./dataComponents.js";
9
- import { createFullAgentServerSide, deleteFullAgent, getFullAgent, updateFullAgentServerSide } from "./agentFull.js";
9
+ import { createFullAgentServerSide, deleteFullAgent, getFullAgent, getFullAgentWithRelationIds, updateFullAgentServerSide } from "./agentFull.js";
10
10
  import { createProject, deleteProject, getProject, updateProject } from "./projects.js";
11
11
 
12
- //#region src/data-access/projectFull.ts
12
+ //#region src/data-access/manage/projectFull.ts
13
13
  const defaultLogger = getLogger("projectFull");
14
14
  /**
15
15
  * Validate and type the project data
@@ -21,7 +21,8 @@ function validateAndTypeProjectData(projectData) {
21
21
  * Server-side implementation of createFullProject that performs actual database operations.
22
22
  * This function creates a complete project with all agent and their nested resources.
23
23
  */
24
- const createFullProjectServerSide = (db, logger = defaultLogger) => async (scopes, projectData) => {
24
+ const createFullProjectServerSide = (db, logger = defaultLogger) => async (params) => {
25
+ const { scopes, projectData } = params;
25
26
  const { tenantId } = scopes;
26
27
  const typed = validateAndTypeProjectData(projectData);
27
28
  logger.info({
@@ -336,10 +337,12 @@ const createFullProjectServerSide = (db, logger = defaultLogger) => async (scope
336
337
  }, "Phase 2 complete: All sub-agents added successfully");
337
338
  }
338
339
  logger.info({ projectId: typed.id }, "Full project created successfully");
339
- return await getFullProject(db, logger)({ scopes: {
340
+ const fullProject = await getFullProject(db, logger)({ scopes: {
340
341
  tenantId,
341
342
  projectId: typed.id
342
343
  } });
344
+ if (!fullProject) throw new Error(`Failed to retrieve created project ${typed.id}`);
345
+ return fullProject;
343
346
  } catch (error) {
344
347
  logger.error({
345
348
  tenantId,
@@ -353,7 +356,8 @@ const createFullProjectServerSide = (db, logger = defaultLogger) => async (scope
353
356
  * Server-side implementation of updateFullProject that performs actual database operations.
354
357
  * This function updates a complete project with all agent and their nested resources.
355
358
  */
356
- const updateFullProjectServerSide = (db, logger = defaultLogger) => async (scopes, projectData) => {
359
+ const updateFullProjectServerSide = (db, logger = defaultLogger) => async (params) => {
360
+ const { scopes, projectData } = params;
357
361
  const { tenantId } = scopes;
358
362
  const typed = validateAndTypeProjectData(projectData);
359
363
  if (!typed.id) throw new Error("Project ID is required");
@@ -369,9 +373,12 @@ const updateFullProjectServerSide = (db, logger = defaultLogger) => async (scope
369
373
  } })) {
370
374
  logger.info({ projectId: typed.id }, "Project not found, creating new project");
371
375
  return await createFullProjectServerSide(db, logger)({
372
- tenantId,
373
- projectId: typed.id
374
- }, projectData);
376
+ scopes: {
377
+ tenantId,
378
+ projectId: typed.id
379
+ },
380
+ projectData
381
+ });
375
382
  }
376
383
  const projectUpdatePayload = {
377
384
  name: typed.name,
@@ -831,10 +838,12 @@ const updateFullProjectServerSide = (db, logger = defaultLogger) => async (scope
831
838
  }, "All project agent updated successfully");
832
839
  }
833
840
  logger.info({ projectId: typed.id }, "Full project updated successfully");
834
- return await getFullProject(db, logger)({ scopes: {
841
+ const fullProject = await getFullProject(db, logger)({ scopes: {
835
842
  tenantId,
836
843
  projectId: typed.id
837
844
  } });
845
+ if (!fullProject) throw new Error("Failed to retrieve full project");
846
+ return fullProject;
838
847
  } catch (error) {
839
848
  logger.error({
840
849
  tenantId,
@@ -847,12 +856,13 @@ const updateFullProjectServerSide = (db, logger = defaultLogger) => async (scope
847
856
  /**
848
857
  * Get a complete project definition with all nested resources
849
858
  */
850
- const getFullProject = (db, logger = defaultLogger) => async (params) => {
851
- const { scopes } = params;
859
+ const getFullProjectInternal = (db, logger = defaultLogger) => async (params) => {
860
+ const { scopes, includeRelationIds = false } = params;
852
861
  const { tenantId, projectId } = scopes;
853
862
  logger.info({
854
863
  tenantId,
855
- projectId
864
+ projectId,
865
+ includeRelationIds
856
866
  }, "Retrieving full project definition");
857
867
  try {
858
868
  const project = await getProject(db)({ scopes: {
@@ -891,15 +901,7 @@ const getFullProject = (db, logger = defaultLogger) => async (params) => {
891
901
  limit: 1e3
892
902
  }
893
903
  });
894
- for (const tool of toolsList.data) projectTools[tool.id] = {
895
- id: tool.id,
896
- name: tool.name,
897
- config: tool.config,
898
- credentialReferenceId: tool.credentialReferenceId || void 0,
899
- imageUrl: tool.imageUrl || void 0,
900
- capabilities: tool.capabilities || void 0,
901
- lastError: tool.lastError || void 0
902
- };
904
+ for (const tool of toolsList.data) projectTools[tool.id] = tool;
903
905
  logger.info({
904
906
  tenantId,
905
907
  projectId,
@@ -918,13 +920,7 @@ const getFullProject = (db, logger = defaultLogger) => async (params) => {
918
920
  tenantId,
919
921
  projectId
920
922
  } });
921
- for (const externalAgent of externalAgentsList) projectExternalAgents[externalAgent.id] = {
922
- id: externalAgent.id,
923
- name: externalAgent.name,
924
- description: externalAgent.description,
925
- baseUrl: externalAgent.baseUrl,
926
- credentialReferenceId: externalAgent.credentialReferenceId || void 0
927
- };
923
+ for (const externalAgent of externalAgentsList) projectExternalAgents[externalAgent.id] = externalAgent;
928
924
  logger.info({
929
925
  tenantId,
930
926
  projectId,
@@ -943,13 +939,7 @@ const getFullProject = (db, logger = defaultLogger) => async (params) => {
943
939
  tenantId,
944
940
  projectId
945
941
  } });
946
- for (const component of dataComponentsList) projectDataComponents[component.id] = {
947
- id: component.id,
948
- name: component.name,
949
- description: component.description,
950
- props: component.props,
951
- render: component.render
952
- };
942
+ for (const component of dataComponentsList) projectDataComponents[component.id] = component;
953
943
  logger.info({
954
944
  tenantId,
955
945
  projectId,
@@ -968,12 +958,7 @@ const getFullProject = (db, logger = defaultLogger) => async (params) => {
968
958
  tenantId,
969
959
  projectId
970
960
  } });
971
- for (const component of artifactComponentsList) projectArtifactComponents[component.id] = {
972
- id: component.id,
973
- name: component.name,
974
- description: component.description,
975
- props: component.props
976
- };
961
+ for (const component of artifactComponentsList) projectArtifactComponents[component.id] = component;
977
962
  logger.info({
978
963
  tenantId,
979
964
  projectId,
@@ -992,13 +977,7 @@ const getFullProject = (db, logger = defaultLogger) => async (params) => {
992
977
  tenantId,
993
978
  projectId
994
979
  } });
995
- for (const credential of credentialReferencesList) projectCredentialReferences[credential.id] = {
996
- id: credential.id,
997
- name: credential.name,
998
- type: credential.type,
999
- credentialStoreId: credential.credentialStoreId,
1000
- retrievalParams: credential.retrievalParams
1001
- };
980
+ for (const credential of credentialReferencesList) projectCredentialReferences[credential.id] = credential;
1002
981
  logger.info({
1003
982
  tenantId,
1004
983
  projectId,
@@ -1017,12 +996,7 @@ const getFullProject = (db, logger = defaultLogger) => async (params) => {
1017
996
  tenantId,
1018
997
  projectId
1019
998
  } });
1020
- for (const func of functionsList) projectFunctions[func.id] = {
1021
- id: func.id,
1022
- inputSchema: func.inputSchema,
1023
- executeCode: func.executeCode,
1024
- dependencies: func.dependencies
1025
- };
999
+ for (const func of functionsList) projectFunctions[func.id] = func;
1026
1000
  logger.info({
1027
1001
  tenantId,
1028
1002
  projectId,
@@ -1037,6 +1011,7 @@ const getFullProject = (db, logger = defaultLogger) => async (params) => {
1037
1011
  }
1038
1012
  const agents = {};
1039
1013
  if (agentList.length > 0) {
1014
+ const getAgentFn = includeRelationIds ? getFullAgentWithRelationIds : getFullAgent;
1040
1015
  const agentPromises = agentList.map(async (agent) => {
1041
1016
  try {
1042
1017
  logger.info({
@@ -1044,7 +1019,7 @@ const getFullProject = (db, logger = defaultLogger) => async (params) => {
1044
1019
  projectId,
1045
1020
  agentId: agent.id
1046
1021
  }, "Retrieving full agent definition");
1047
- const fullAgent = await getFullAgent(db)({ scopes: {
1022
+ const fullAgent = await getAgentFn(db)({ scopes: {
1048
1023
  tenantId,
1049
1024
  projectId,
1050
1025
  agentId: agent.id
@@ -1072,20 +1047,30 @@ const getFullProject = (db, logger = defaultLogger) => async (params) => {
1072
1047
  });
1073
1048
  await Promise.all(agentPromises);
1074
1049
  }
1075
- if (!project.models) throw new Error(`Project ${project.id} is missing required models configuration. Please update the project to include a base model.`);
1050
+ const projectModels = project.models ?? {
1051
+ base: { model: "claude-sonnet-4-5" },
1052
+ structuredOutput: { model: "claude-sonnet-4-5" },
1053
+ summarizer: { model: "claude-sonnet-4-5" }
1054
+ };
1055
+ if (!projectModels.base) logger.warn({
1056
+ tenantId,
1057
+ projectId
1058
+ }, `Project ${project.id} is missing base model configuration. Using default: claude-sonnet-4-5`);
1076
1059
  const fullProjectDefinition = {
1077
1060
  id: project.id,
1078
1061
  name: project.name,
1079
1062
  description: project.description,
1080
- models: project.models,
1081
- stopWhen: project.stopWhen || void 0,
1063
+ models: projectModels,
1064
+ stopWhen: project.stopWhen ?? null,
1082
1065
  agents,
1083
1066
  tools: projectTools,
1084
- functions: projectFunctions,
1085
- externalAgents: projectExternalAgents,
1086
- dataComponents: projectDataComponents,
1087
- artifactComponents: projectArtifactComponents,
1088
- credentialReferences: projectCredentialReferences,
1067
+ functions: Object.keys(projectFunctions).length > 0 ? projectFunctions : null,
1068
+ externalAgents: Object.keys(projectExternalAgents).length > 0 ? projectExternalAgents : null,
1069
+ dataComponents: Object.keys(projectDataComponents).length > 0 ? projectDataComponents : null,
1070
+ artifactComponents: Object.keys(projectArtifactComponents).length > 0 ? projectArtifactComponents : null,
1071
+ credentialReferences: Object.keys(projectCredentialReferences).length > 0 ? projectCredentialReferences : null,
1072
+ statusUpdates: null,
1073
+ functionTools: null,
1089
1074
  createdAt: project.createdAt,
1090
1075
  updatedAt: project.updatedAt
1091
1076
  };
@@ -1104,6 +1089,20 @@ const getFullProject = (db, logger = defaultLogger) => async (params) => {
1104
1089
  throw error;
1105
1090
  }
1106
1091
  };
1092
+ const getFullProject = (db, logger = defaultLogger) => async (params) => {
1093
+ const { scopes } = params;
1094
+ return getFullProjectInternal(db, logger)({
1095
+ scopes,
1096
+ includeRelationIds: false
1097
+ });
1098
+ };
1099
+ const getFullProjectWithRelationIds = (db, logger = defaultLogger) => async (params) => {
1100
+ const { scopes } = params;
1101
+ return getFullProjectInternal(db, logger)({
1102
+ scopes,
1103
+ includeRelationIds: true
1104
+ });
1105
+ };
1107
1106
  /**
1108
1107
  * Delete a complete project and cascade to all related entities
1109
1108
  */
@@ -1192,4 +1191,4 @@ const deleteFullProject = (db, logger = defaultLogger) => async (params) => {
1192
1191
  };
1193
1192
 
1194
1193
  //#endregion
1195
- export { createFullProjectServerSide, deleteFullProject, getFullProject, updateFullProjectServerSide };
1194
+ export { createFullProjectServerSide, deleteFullProject, getFullProject, getFullProjectWithRelationIds, updateFullProjectServerSide };
@@ -0,0 +1,119 @@
1
+ import { PaginationConfig, PaginationResult, ProjectModels } from "../../types/utility.js";
2
+ import { AgentsManageDatabaseClient } from "../../db/manage/manage-client.js";
3
+ import { AgentsRunDatabaseClient } from "../../db/runtime/runtime-client.js";
4
+ import { StopWhen } from "../../validation/schemas.js";
5
+ import { ProjectMetadataSelect } from "../../types/entities.js";
6
+
7
+ //#region src/data-access/manage/projectLifecycle.d.ts
8
+ interface CreateProjectWithBranchParams {
9
+ tenantId: string;
10
+ projectId: string;
11
+ createdBy?: string;
12
+ }
13
+ interface CreateProjectWithBranchResult {
14
+ id: string;
15
+ tenantId: string;
16
+ mainBranchName: string;
17
+ createdAt: string;
18
+ createdBy: string | null;
19
+ }
20
+ interface DeleteProjectWithBranchParams {
21
+ tenantId: string;
22
+ projectId: string;
23
+ }
24
+ /**
25
+ * Generate the main branch name for a project
26
+ */
27
+ declare function getProjectMainBranchName(tenantId: string, projectId: string): string;
28
+ /**
29
+ * Create a project with its main branch
30
+ *
31
+ * This utility:
32
+ * 1. Creates the project record in the runtime DB (source of truth for existence)
33
+ * 2. Creates the project main branch in the config DB (Doltgres)
34
+ *
35
+ * @param runDb - Runtime database client (Postgres)
36
+ * @param configDb - Config database client (Doltgres)
37
+ */
38
+ declare const createProjectMetadataAndBranch: (runDb: AgentsRunDatabaseClient, configDb: AgentsManageDatabaseClient) => (params: CreateProjectWithBranchParams) => Promise<CreateProjectWithBranchResult>;
39
+ /**
40
+ * Delete a project and its branch
41
+ *
42
+ * This utility:
43
+ * 1. Gets the project from runtime DB to find the branch name
44
+ * 2. Deletes the project branch from config DB (Doltgres)
45
+ * 3. Deletes the project record from runtime DB
46
+ *
47
+ * Note: Callers should handle cascade deletion of runtime entities (conversations, etc.)
48
+ * before calling this function.
49
+ *
50
+ * @param runDb - Runtime database client (Postgres)
51
+ * @param configDb - Config database client (Doltgres)
52
+ */
53
+ declare const deleteProjectWithBranch: (runDb: AgentsRunDatabaseClient, configDb: AgentsManageDatabaseClient) => (params: DeleteProjectWithBranchParams) => Promise<boolean>;
54
+ /**
55
+ * Get project with branch info
56
+ *
57
+ * Returns the project from runtime DB including the main branch name
58
+ */
59
+ declare const getProjectWithBranchInfo: (runDb: AgentsRunDatabaseClient) => (params: {
60
+ tenantId: string;
61
+ projectId: string;
62
+ }) => Promise<ProjectMetadataSelect | null>;
63
+ /**
64
+ * Project metadata from the versioned config DB
65
+ */
66
+ interface ProjectConfigMetadata {
67
+ name: string;
68
+ description: string | null;
69
+ models: ProjectModels | null;
70
+ stopWhen: StopWhen | null;
71
+ createdAt: string;
72
+ updatedAt: string;
73
+ }
74
+ /**
75
+ * Combined project data from runtime + config DBs
76
+ */
77
+ interface ProjectWithMetadata {
78
+ id: string;
79
+ tenantId: string;
80
+ createdAt: string;
81
+ createdBy: string | null;
82
+ mainBranchName: string;
83
+ name: string | null;
84
+ description: string | null;
85
+ models: ProjectModels | null;
86
+ stopWhen: StopWhen | null;
87
+ configUpdatedAt: string | null;
88
+ }
89
+ interface ListProjectsWithMetadataResult {
90
+ data: ProjectWithMetadata[];
91
+ pagination: PaginationResult;
92
+ }
93
+ /**
94
+ * List projects with metadata from both runtime and config DBs
95
+ *
96
+ * This function:
97
+ * 1. Gets the list of projects from runtime DB (source of truth for existence)
98
+ * 2. For each project, queries the config DB at the project's main branch to get metadata
99
+ *
100
+ * @param runDb - Runtime database client (Postgres)
101
+ * @param configDb - Config database client (Doltgres)
102
+ */
103
+ declare const listProjectsWithMetadataPaginated: (runDb: AgentsRunDatabaseClient, configDb: AgentsManageDatabaseClient) => (params: {
104
+ tenantId: string;
105
+ pagination?: PaginationConfig;
106
+ projectIds?: string[];
107
+ }) => Promise<ListProjectsWithMetadataResult>;
108
+ /**
109
+ * Get a single project with metadata from both runtime and config DBs
110
+ *
111
+ * @param runDb - Runtime database client (Postgres)
112
+ * @param configDb - Config database client (Doltgres)
113
+ */
114
+ declare const getProjectWithMetadata: (runDb: AgentsRunDatabaseClient, configDb: AgentsManageDatabaseClient) => (params: {
115
+ tenantId: string;
116
+ projectId: string;
117
+ }) => Promise<ProjectWithMetadata | null>;
118
+ //#endregion
119
+ export { CreateProjectWithBranchParams, CreateProjectWithBranchResult, DeleteProjectWithBranchParams, ListProjectsWithMetadataResult, ProjectConfigMetadata, ProjectWithMetadata, createProjectMetadataAndBranch, deleteProjectWithBranch, getProjectMainBranchName, getProjectWithBranchInfo, getProjectWithMetadata, listProjectsWithMetadataPaginated };
@@ -0,0 +1,234 @@
1
+ import { getLogger } from "../../utils/logger.js";
2
+ import { doltBranch, doltBranchExists, doltCheckout, doltDeleteBranch } from "../../dolt/branch.js";
3
+ import { createProjectMetadata, deleteProjectMetadata, getProjectMetadata, listProjectsMetadataPaginated } from "../runtime/projects.js";
4
+ import { sql } from "drizzle-orm";
5
+
6
+ //#region src/data-access/manage/projectLifecycle.ts
7
+ const logger = getLogger("project-lifecycle");
8
+ /**
9
+ * Generate the main branch name for a project
10
+ */
11
+ function getProjectMainBranchName(tenantId, projectId) {
12
+ return `${tenantId}_${projectId}_main`;
13
+ }
14
+ /**
15
+ * Create a project with its main branch
16
+ *
17
+ * This utility:
18
+ * 1. Creates the project record in the runtime DB (source of truth for existence)
19
+ * 2. Creates the project main branch in the config DB (Doltgres)
20
+ *
21
+ * @param runDb - Runtime database client (Postgres)
22
+ * @param configDb - Config database client (Doltgres)
23
+ */
24
+ const createProjectMetadataAndBranch = (runDb, configDb) => async (params) => {
25
+ const { tenantId, projectId, createdBy } = params;
26
+ const mainBranchName = getProjectMainBranchName(tenantId, projectId);
27
+ logger.info({
28
+ tenantId,
29
+ projectId,
30
+ mainBranchName
31
+ }, "Creating project with branch");
32
+ const runtimeProject = await createProjectMetadata(runDb)({
33
+ id: projectId,
34
+ tenantId,
35
+ createdBy: createdBy ?? null,
36
+ mainBranchName
37
+ });
38
+ logger.debug({ projectId }, "Created project in runtime DB");
39
+ try {
40
+ if (!await doltBranchExists(configDb)({ name: mainBranchName })) {
41
+ await doltBranch(configDb)({ name: mainBranchName });
42
+ logger.debug({ mainBranchName }, "Created project main branch");
43
+ }
44
+ } catch (error) {
45
+ logger.error({
46
+ error,
47
+ mainBranchName
48
+ }, "Failed to create project branch, rolling back");
49
+ await deleteProjectMetadata(runDb)({
50
+ tenantId,
51
+ projectId
52
+ });
53
+ throw error;
54
+ }
55
+ logger.info({
56
+ tenantId,
57
+ projectId,
58
+ mainBranchName
59
+ }, "Successfully created project with branch");
60
+ return {
61
+ id: runtimeProject.id,
62
+ tenantId: runtimeProject.tenantId,
63
+ mainBranchName: runtimeProject.mainBranchName,
64
+ createdAt: runtimeProject.createdAt,
65
+ createdBy: runtimeProject.createdBy
66
+ };
67
+ };
68
+ /**
69
+ * Delete a project and its branch
70
+ *
71
+ * This utility:
72
+ * 1. Gets the project from runtime DB to find the branch name
73
+ * 2. Deletes the project branch from config DB (Doltgres)
74
+ * 3. Deletes the project record from runtime DB
75
+ *
76
+ * Note: Callers should handle cascade deletion of runtime entities (conversations, etc.)
77
+ * before calling this function.
78
+ *
79
+ * @param runDb - Runtime database client (Postgres)
80
+ * @param configDb - Config database client (Doltgres)
81
+ */
82
+ const deleteProjectWithBranch = (runDb, configDb) => async (params) => {
83
+ const { tenantId, projectId } = params;
84
+ logger.info({
85
+ tenantId,
86
+ projectId
87
+ }, "Deleting project with branch");
88
+ const project = await getProjectMetadata(runDb)({
89
+ tenantId,
90
+ projectId
91
+ });
92
+ if (!project) {
93
+ logger.warn({
94
+ tenantId,
95
+ projectId
96
+ }, "Project not found in runtime DB");
97
+ return false;
98
+ }
99
+ const { mainBranchName } = project;
100
+ try {
101
+ await doltCheckout(configDb)({ branch: "main" });
102
+ await doltDeleteBranch(configDb)({
103
+ name: mainBranchName,
104
+ force: true
105
+ });
106
+ logger.info({ mainBranchName }, "Deleted project branch");
107
+ } catch (error) {
108
+ logger.error({
109
+ error,
110
+ mainBranchName
111
+ }, "Failed to delete project branch, continuing with runtime cleanup");
112
+ }
113
+ const deleted = await deleteProjectMetadata(runDb)({
114
+ tenantId,
115
+ projectId
116
+ });
117
+ if (deleted) logger.info({
118
+ tenantId,
119
+ projectId,
120
+ mainBranchName
121
+ }, "Successfully deleted project with branch");
122
+ else logger.warn({
123
+ tenantId,
124
+ projectId
125
+ }, "Failed to delete project from runtime DB");
126
+ return deleted;
127
+ };
128
+ /**
129
+ * Get project with branch info
130
+ *
131
+ * Returns the project from runtime DB including the main branch name
132
+ */
133
+ const getProjectWithBranchInfo = (runDb) => async (params) => {
134
+ return await getProjectMetadata(runDb)(params);
135
+ };
136
+ /**
137
+ * Get project metadata from config DB at a specific branch using AS OF syntax
138
+ *
139
+ * This queries the projects table without checking out the branch
140
+ */
141
+ async function getProjectMetadataFromBranch(configDb, branchName, tenantId, projectId) {
142
+ try {
143
+ const result = await configDb.execute(sql.raw(`
144
+ SELECT name, description, models, stop_when, created_at, updated_at
145
+ FROM projects AS OF '${branchName}'
146
+ WHERE tenant_id = '${tenantId}' AND id = '${projectId}'
147
+ LIMIT 1
148
+ `));
149
+ if (result.rows.length === 0) return null;
150
+ const row = result.rows[0];
151
+ return {
152
+ name: row.name,
153
+ description: row.description,
154
+ models: row.models,
155
+ stopWhen: row.stop_when,
156
+ createdAt: row.created_at,
157
+ updatedAt: row.updated_at
158
+ };
159
+ } catch (error) {
160
+ logger.warn({
161
+ error,
162
+ branchName,
163
+ tenantId,
164
+ projectId
165
+ }, "Failed to get project metadata from branch");
166
+ return null;
167
+ }
168
+ }
169
+ /**
170
+ * List projects with metadata from both runtime and config DBs
171
+ *
172
+ * This function:
173
+ * 1. Gets the list of projects from runtime DB (source of truth for existence)
174
+ * 2. For each project, queries the config DB at the project's main branch to get metadata
175
+ *
176
+ * @param runDb - Runtime database client (Postgres)
177
+ * @param configDb - Config database client (Doltgres)
178
+ */
179
+ const listProjectsWithMetadataPaginated = (runDb, configDb) => async (params) => {
180
+ const { tenantId, pagination, projectIds } = params;
181
+ const projectMetadataResult = await listProjectsMetadataPaginated(runDb)({
182
+ tenantId,
183
+ pagination,
184
+ projectIds
185
+ });
186
+ return {
187
+ data: await Promise.all(projectMetadataResult.data.map(async (projectMetadata) => {
188
+ const metadata = await getProjectMetadataFromBranch(configDb, projectMetadata.mainBranchName, tenantId, projectMetadata.id);
189
+ return {
190
+ id: projectMetadata.id,
191
+ tenantId: projectMetadata.tenantId,
192
+ createdAt: projectMetadata.createdAt,
193
+ createdBy: projectMetadata.createdBy,
194
+ mainBranchName: projectMetadata.mainBranchName,
195
+ name: metadata?.name ?? null,
196
+ description: metadata?.description ?? null,
197
+ models: metadata?.models ?? null,
198
+ stopWhen: metadata?.stopWhen ?? null,
199
+ configUpdatedAt: metadata?.updatedAt ?? null
200
+ };
201
+ })),
202
+ pagination: projectMetadataResult.pagination
203
+ };
204
+ };
205
+ /**
206
+ * Get a single project with metadata from both runtime and config DBs
207
+ *
208
+ * @param runDb - Runtime database client (Postgres)
209
+ * @param configDb - Config database client (Doltgres)
210
+ */
211
+ const getProjectWithMetadata = (runDb, configDb) => async (params) => {
212
+ const { tenantId, projectId } = params;
213
+ const runtimeProject = await getProjectMetadata(runDb)({
214
+ tenantId,
215
+ projectId
216
+ });
217
+ if (!runtimeProject) return null;
218
+ const metadata = await getProjectMetadataFromBranch(configDb, runtimeProject.mainBranchName, tenantId, projectId);
219
+ return {
220
+ id: runtimeProject.id,
221
+ tenantId: runtimeProject.tenantId,
222
+ createdAt: runtimeProject.createdAt,
223
+ createdBy: runtimeProject.createdBy,
224
+ mainBranchName: runtimeProject.mainBranchName,
225
+ name: metadata?.name ?? null,
226
+ description: metadata?.description ?? null,
227
+ models: metadata?.models ?? null,
228
+ stopWhen: metadata?.stopWhen ?? null,
229
+ configUpdatedAt: metadata?.updatedAt ?? null
230
+ };
231
+ };
232
+
233
+ //#endregion
234
+ export { createProjectMetadataAndBranch, deleteProjectWithBranch, getProjectMainBranchName, getProjectWithBranchInfo, getProjectWithMetadata, listProjectsWithMetadataPaginated };
@@ -0,0 +1,75 @@
1
+ import { PaginationConfig, PaginationResult, ProjectInfo, ProjectResourceCounts, ProjectScopeConfig } from "../../types/utility.js";
2
+ import { AgentsManageDatabaseClient } from "../../db/manage/manage-client.js";
3
+ import { ProjectInsert, ProjectSelect, ProjectUpdate } from "../../types/entities.js";
4
+
5
+ //#region src/data-access/manage/projects.d.ts
6
+
7
+ /**
8
+ * List all unique project IDs within a tenant by scanning all resource tables
9
+ * @param projectIds - Optional array of project IDs to filter by. If undefined, returns all projects.
10
+ */
11
+ declare const listProjects: (db: AgentsManageDatabaseClient) => (params: {
12
+ tenantId: string;
13
+ projectIds?: string[];
14
+ }) => Promise<ProjectInfo[]>;
15
+ /**
16
+ * List all unique project IDs within a tenant with pagination
17
+ * Optionally filter by a list of project IDs (for access control)
18
+ */
19
+ declare const listProjectsPaginated: (db: AgentsManageDatabaseClient) => (params: {
20
+ tenantId: string;
21
+ pagination?: PaginationConfig;
22
+ projectIds?: string[];
23
+ }) => Promise<{
24
+ data: ProjectSelect[];
25
+ pagination: PaginationResult;
26
+ }>;
27
+ /**
28
+ * Get resource counts for a specific project
29
+ */
30
+ declare const getProjectResourceCounts: (db: AgentsManageDatabaseClient) => (params: ProjectScopeConfig) => Promise<ProjectResourceCounts>;
31
+ /**
32
+ * Check if a project exists (has any resources)
33
+ */
34
+ declare const projectExists: (db: AgentsManageDatabaseClient) => (params: ProjectScopeConfig) => Promise<boolean>;
35
+ /**
36
+ * Count total projects for a tenant
37
+ */
38
+ declare const countProjects: (db: AgentsManageDatabaseClient) => (params: {
39
+ tenantId: string;
40
+ }) => Promise<number>;
41
+ /**
42
+ * Get a single project by ID
43
+ */
44
+ declare const getProject: (db: AgentsManageDatabaseClient) => (params: {
45
+ scopes: ProjectScopeConfig;
46
+ }) => Promise<ProjectSelect | null>;
47
+ /**
48
+ * Create a new project
49
+ */
50
+ declare const createProject: (db: AgentsManageDatabaseClient) => (params: ProjectInsert) => Promise<ProjectSelect>;
51
+ /**
52
+ * Update an existing project
53
+ */
54
+ declare const updateProject: (db: AgentsManageDatabaseClient) => (params: {
55
+ scopes: ProjectScopeConfig;
56
+ data: ProjectUpdate;
57
+ }) => Promise<ProjectSelect | null>;
58
+ /**
59
+ * Check if a project exists in the projects table
60
+ */
61
+ declare const projectExistsInTable: (db: AgentsManageDatabaseClient) => (params: {
62
+ scopes: ProjectScopeConfig;
63
+ }) => Promise<boolean>;
64
+ /**
65
+ * Check if a project has any resources (used before deletion)
66
+ */
67
+ declare const projectHasResources: (db: AgentsManageDatabaseClient) => (params: ProjectScopeConfig) => Promise<boolean>;
68
+ /**
69
+ * Delete a project (with validation for existing resources)
70
+ */
71
+ declare const deleteProject: (db: AgentsManageDatabaseClient) => (params: {
72
+ scopes: ProjectScopeConfig;
73
+ }) => Promise<boolean>;
74
+ //#endregion
75
+ export { countProjects, createProject, deleteProject, getProject, getProjectResourceCounts, listProjects, listProjectsPaginated, projectExists, projectExistsInTable, projectHasResources, updateProject };