@inkeep/agents-core 0.1.6 → 0.1.7

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.
package/dist/index.js CHANGED
@@ -1,10 +1,12 @@
1
1
  export { TaskState } from './chunk-H2F72PDA.js';
2
- import { ContextConfigApiUpdateSchema, validateAndTypeGraphData, validateGraphStructure, isInternalAgent, isExternalAgent } from './chunk-RZPLS4MU.js';
3
- 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, 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, 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, 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, generateIdFromName, isExternalAgent, isInternalAgent, isValidResourceId, resourceIdSchema, validateAgentRelationships, validateAndTypeGraphData, validateArtifactComponentReferences, validateDataComponentReferences, validateGraphStructure, validateToolReferences } from './chunk-RZPLS4MU.js';
2
+ import { validateAndTypeGraphData, validateGraphStructure, isInternalAgent, isExternalAgent } from './chunk-BMKWVKI2.js';
3
+ export { generateIdFromName, isExternalAgent, isInternalAgent, isValidResourceId, validateAgentRelationships, validateAndTypeGraphData, validateArtifactComponentReferences, validateDataComponentReferences, validateGraphStructure, validateToolReferences } from './chunk-BMKWVKI2.js';
4
+ import { ContextConfigApiUpdateSchema } from './chunk-R3VVJXX7.js';
5
+ 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 } from './chunk-R3VVJXX7.js';
6
+ import { schema_exports, agentRelations, agents, externalAgents, agentToolRelations, tools, contextConfigs, agentGraph, agentDataComponents, agentArtifactComponents, dataComponents, artifactComponents, projects, apiKeys, contextCache, conversations, messages, credentialReferences, ledgerArtifacts, tasks, taskRelations } from './chunk-MXQKLGQK.js';
7
+ export { agentArtifactComponents, agentArtifactComponentsRelations, agentDataComponents, agentGraph, agentGraphRelations, agentRelations, agentRelationsRelations, agentToolRelations, agentToolRelationsRelations, agents, agentsRelations, apiKeys, apiKeysRelations, artifactComponents, artifactComponentsRelations, contextCache, contextCacheRelations, contextConfigs, contextConfigsRelations, conversations, conversationsRelations, credentialReferences, credentialReferencesRelations, dataComponents, externalAgents, externalAgentsRelations, ledgerArtifacts, ledgerArtifactsContextIdIdx, ledgerArtifactsTaskContextNameUnique, ledgerArtifactsTaskIdIdx, messages, messagesRelations, projects, projectsRelations, taskRelations, taskRelationsRelations, tasks, tasksRelations, tools, toolsRelations } from './chunk-MXQKLGQK.js';
4
8
  import { CredentialStoreType, MCPServerType, MCPTransportType } from './chunk-SVGQSPW4.js';
5
9
  export { CredentialStoreType, MCPServerType, MCPTransportType, TOOL_STATUS_VALUES, VALID_RELATION_TYPES } from './chunk-SVGQSPW4.js';
6
- import { schema_exports, agentRelations, agents, externalAgents, agentToolRelations, tools, contextConfigs, agentGraph, agentDataComponents, agentArtifactComponents, dataComponents, artifactComponents, projects, apiKeys, contextCache, conversations, messages, credentialReferences, ledgerArtifacts, tasks, taskRelations } from './chunk-M4JXMAG7.js';
7
- export { agentArtifactComponents, agentArtifactComponentsRelations, agentDataComponents, agentGraph, agentGraphRelations, agentRelations, agentRelationsRelations, agentToolRelations, agentToolRelationsRelations, agents, agentsRelations, apiKeys, apiKeysRelations, artifactComponents, artifactComponentsRelations, contextCache, contextCacheRelations, contextConfigs, contextConfigsRelations, conversations, conversationsRelations, credentialReferences, credentialReferencesRelations, dataComponents, externalAgents, externalAgentsRelations, ledgerArtifacts, ledgerArtifactsContextIdIdx, ledgerArtifactsTaskContextNameUnique, ledgerArtifactsTaskIdIdx, messages, messagesRelations, projects, projectsRelations, taskRelations, taskRelationsRelations, tasks, tasksRelations, tools, toolsRelations } from './chunk-M4JXMAG7.js';
8
10
  import { __publicField } from './chunk-MKBO26DX.js';
9
11
  import { z as z$2 } from 'zod/v4';
10
12
  import jmespath from 'jmespath';
@@ -3656,7 +3658,7 @@ var createFullGraphServerSide = (db, logger11 = defaultLogger) => async (scopes,
3656
3658
  "All credential references created/updated successfully"
3657
3659
  );
3658
3660
  }
3659
- const toolPromises = Object.entries(typed.tools).map(async ([toolId, toolData]) => {
3661
+ const toolPromises = Object.entries(typed.tools || {}).map(async ([toolId, toolData]) => {
3660
3662
  try {
3661
3663
  logger11.info({ toolId }, "Processing tool");
3662
3664
  await upsertTool(db)({
@@ -3674,7 +3676,7 @@ var createFullGraphServerSide = (db, logger11 = defaultLogger) => async (scopes,
3674
3676
  });
3675
3677
  await Promise.all(toolPromises);
3676
3678
  logger11.info(
3677
- { toolCount: Object.keys(typed.tools).length },
3679
+ { toolCount: Object.keys(typed.tools || {}).length },
3678
3680
  "All tools created/updated successfully"
3679
3681
  );
3680
3682
  let contextConfigId;
@@ -4033,7 +4035,7 @@ var updateFullGraphServerSide = (db, logger11 = defaultLogger) => async (scopes,
4033
4035
  tenantId,
4034
4036
  graphId: typedGraphDefinition.id,
4035
4037
  agentCount: Object.keys(typedGraphDefinition.agents).length,
4036
- toolCount: Object.keys(typedGraphDefinition.tools).length
4038
+ toolCount: Object.keys(typedGraphDefinition.tools || {}).length
4037
4039
  },
4038
4040
  "Updating full graph in database"
4039
4041
  );
@@ -4089,7 +4091,7 @@ var updateFullGraphServerSide = (db, logger11 = defaultLogger) => async (scopes,
4089
4091
  "All credential references created/updated successfully"
4090
4092
  );
4091
4093
  }
4092
- const toolPromises = Object.entries(typedGraphDefinition.tools).map(
4094
+ const toolPromises = Object.entries(typedGraphDefinition.tools || {}).map(
4093
4095
  async ([toolId, toolData]) => {
4094
4096
  try {
4095
4097
  logger11.info({ toolId }, "Processing tool");
@@ -4109,7 +4111,7 @@ var updateFullGraphServerSide = (db, logger11 = defaultLogger) => async (scopes,
4109
4111
  );
4110
4112
  await Promise.all(toolPromises);
4111
4113
  logger11.info(
4112
- { toolCount: Object.keys(typedGraphDefinition.tools).length },
4114
+ { toolCount: Object.keys(typedGraphDefinition.tools || {}).length },
4113
4115
  "All tools created/updated successfully"
4114
4116
  );
4115
4117
  let contextConfigId;
@@ -4939,10 +4941,6 @@ var deleteProject = (db) => async (params) => {
4939
4941
  if (!projectExistsInTableResult) {
4940
4942
  return false;
4941
4943
  }
4942
- const hasResources = await projectExists(db)(params.scopes);
4943
- if (hasResources) {
4944
- throw new Error("Cannot delete project with existing resources");
4945
- }
4946
4944
  await db.delete(projects).where(
4947
4945
  and(eq(projects.tenantId, params.scopes.tenantId), eq(projects.id, params.scopes.projectId))
4948
4946
  );
@@ -4999,6 +4997,353 @@ async function cascadeStopWhenUpdates(db, scopes, oldStopWhen, newStopWhen) {
4999
4997
  }
5000
4998
  }
5001
4999
  }
5000
+
5001
+ // src/data-access/projectFull.ts
5002
+ var defaultLogger2 = getLogger("projectFull");
5003
+ function validateAndTypeProjectData(projectData) {
5004
+ return projectData;
5005
+ }
5006
+ var createFullProjectServerSide = (db, logger11 = defaultLogger2) => async (scopes, projectData) => {
5007
+ const { tenantId } = scopes;
5008
+ const typed = validateAndTypeProjectData(projectData);
5009
+ logger11.info(
5010
+ {
5011
+ tenantId,
5012
+ projectId: typed.id,
5013
+ graphCount: Object.keys(typed.graphs || {}).length
5014
+ },
5015
+ "Creating full project in database"
5016
+ );
5017
+ try {
5018
+ const projectPayload = {
5019
+ id: typed.id,
5020
+ name: typed.name,
5021
+ description: typed.description || "",
5022
+ models: typed.models,
5023
+ stopWhen: typed.stopWhen,
5024
+ tenantId,
5025
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
5026
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
5027
+ };
5028
+ logger11.info({ projectId: typed.id }, "Creating project metadata");
5029
+ await createProject(db)(projectPayload);
5030
+ logger11.info({ projectId: typed.id }, "Project metadata created successfully");
5031
+ if (typed.graphs && Object.keys(typed.graphs).length > 0) {
5032
+ logger11.info(
5033
+ {
5034
+ projectId: typed.id,
5035
+ graphCount: Object.keys(typed.graphs).length
5036
+ },
5037
+ "Creating project graphs"
5038
+ );
5039
+ const graphPromises = Object.entries(typed.graphs).map(async ([graphId, graphData]) => {
5040
+ try {
5041
+ logger11.info({ projectId: typed.id, graphId }, "Creating graph in project");
5042
+ const graphDataWithUndefined = {
5043
+ ...graphData,
5044
+ statusUpdates: graphData.statusUpdates === null ? void 0 : graphData.statusUpdates
5045
+ };
5046
+ await createFullGraphServerSide(db, logger11)(
5047
+ { tenantId, projectId: typed.id },
5048
+ graphDataWithUndefined
5049
+ );
5050
+ logger11.info({ projectId: typed.id, graphId }, "Graph created successfully in project");
5051
+ } catch (error) {
5052
+ logger11.error(
5053
+ { projectId: typed.id, graphId, error },
5054
+ "Failed to create graph in project"
5055
+ );
5056
+ throw error;
5057
+ }
5058
+ });
5059
+ await Promise.all(graphPromises);
5060
+ logger11.info(
5061
+ {
5062
+ projectId: typed.id,
5063
+ graphCount: Object.keys(typed.graphs).length
5064
+ },
5065
+ "All project graphs created successfully"
5066
+ );
5067
+ }
5068
+ logger11.info({ projectId: typed.id }, "Full project created successfully");
5069
+ return await getFullProject(
5070
+ db,
5071
+ logger11
5072
+ )({
5073
+ scopes: { tenantId, projectId: typed.id },
5074
+ projectId: typed.id
5075
+ });
5076
+ } catch (error) {
5077
+ logger11.error(
5078
+ {
5079
+ tenantId,
5080
+ projectId: typed.id,
5081
+ error
5082
+ },
5083
+ "Failed to create full project"
5084
+ );
5085
+ throw error;
5086
+ }
5087
+ };
5088
+ var updateFullProjectServerSide = (db, logger11 = defaultLogger2) => async (scopes, projectData) => {
5089
+ const { tenantId } = scopes;
5090
+ const typed = validateAndTypeProjectData(projectData);
5091
+ if (!typed.id) {
5092
+ throw new Error("Project ID is required");
5093
+ }
5094
+ logger11.info(
5095
+ {
5096
+ tenantId,
5097
+ projectId: typed.id,
5098
+ graphCount: Object.keys(typed.graphs || {}).length
5099
+ },
5100
+ "Updating full project in database"
5101
+ );
5102
+ try {
5103
+ const existingProject = await getProject(db)({
5104
+ scopes: { tenantId, projectId: typed.id }
5105
+ });
5106
+ if (!existingProject) {
5107
+ logger11.info({ projectId: typed.id }, "Project not found, creating new project");
5108
+ return await createFullProjectServerSide(db, logger11)(
5109
+ { tenantId, projectId: typed.id },
5110
+ projectData
5111
+ );
5112
+ }
5113
+ const projectUpdatePayload = {
5114
+ name: typed.name,
5115
+ description: typed.description || "",
5116
+ models: typed.models,
5117
+ stopWhen: typed.stopWhen
5118
+ };
5119
+ logger11.info({ projectId: typed.id }, "Updating project metadata");
5120
+ await updateProject(db)({
5121
+ scopes: { tenantId, projectId: typed.id },
5122
+ data: projectUpdatePayload
5123
+ });
5124
+ logger11.info({ projectId: typed.id }, "Project metadata updated successfully");
5125
+ if (typed.graphs && Object.keys(typed.graphs).length > 0) {
5126
+ logger11.info(
5127
+ {
5128
+ projectId: typed.id,
5129
+ graphCount: Object.keys(typed.graphs).length
5130
+ },
5131
+ "Updating project graphs"
5132
+ );
5133
+ const graphPromises = Object.entries(typed.graphs).map(async ([graphId, graphData]) => {
5134
+ try {
5135
+ logger11.info({ projectId: typed.id, graphId }, "Updating graph in project");
5136
+ const graphDataWithUndefined = {
5137
+ ...graphData,
5138
+ statusUpdates: graphData.statusUpdates === null ? void 0 : graphData.statusUpdates
5139
+ };
5140
+ await updateFullGraphServerSide(db, logger11)(
5141
+ { tenantId, projectId: typed.id },
5142
+ graphDataWithUndefined
5143
+ );
5144
+ logger11.info({ projectId: typed.id, graphId }, "Graph updated successfully in project");
5145
+ } catch (error) {
5146
+ logger11.error(
5147
+ { projectId: typed.id, graphId, error },
5148
+ "Failed to update graph in project"
5149
+ );
5150
+ throw error;
5151
+ }
5152
+ });
5153
+ await Promise.all(graphPromises);
5154
+ logger11.info(
5155
+ {
5156
+ projectId: typed.id,
5157
+ graphCount: Object.keys(typed.graphs).length
5158
+ },
5159
+ "All project graphs updated successfully"
5160
+ );
5161
+ }
5162
+ logger11.info({ projectId: typed.id }, "Full project updated successfully");
5163
+ return await getFullProject(
5164
+ db,
5165
+ logger11
5166
+ )({
5167
+ scopes: { tenantId, projectId: typed.id },
5168
+ projectId: typed.id
5169
+ });
5170
+ } catch (error) {
5171
+ logger11.error(
5172
+ {
5173
+ tenantId,
5174
+ projectId: typed.id,
5175
+ error
5176
+ },
5177
+ "Failed to update full project"
5178
+ );
5179
+ throw error;
5180
+ }
5181
+ };
5182
+ var getFullProject = (db, logger11 = defaultLogger2) => async (params) => {
5183
+ const { scopes, projectId } = params;
5184
+ const { tenantId } = scopes;
5185
+ logger11.info({ tenantId, projectId }, "Retrieving full project definition");
5186
+ try {
5187
+ const project = await getProject(db)({
5188
+ scopes: { tenantId, projectId }
5189
+ });
5190
+ if (!project) {
5191
+ logger11.info({ tenantId, projectId }, "Project not found");
5192
+ return null;
5193
+ }
5194
+ logger11.info({ tenantId, projectId }, "Project metadata retrieved");
5195
+ const graphList = await listAgentGraphs(db)({
5196
+ scopes: { tenantId, projectId }
5197
+ });
5198
+ logger11.info(
5199
+ {
5200
+ tenantId,
5201
+ projectId,
5202
+ graphCount: graphList.length
5203
+ },
5204
+ "Found graphs for project"
5205
+ );
5206
+ const graphs = {};
5207
+ if (graphList.length > 0) {
5208
+ const graphPromises = graphList.map(async (graph) => {
5209
+ try {
5210
+ logger11.info(
5211
+ { tenantId, projectId, graphId: graph.id },
5212
+ "Retrieving full graph definition"
5213
+ );
5214
+ const fullGraph = await getFullGraph(db)({
5215
+ scopes: { tenantId, projectId },
5216
+ graphId: graph.id
5217
+ });
5218
+ if (fullGraph) {
5219
+ graphs[graph.id] = fullGraph;
5220
+ logger11.info(
5221
+ { tenantId, projectId, graphId: graph.id },
5222
+ "Full graph definition retrieved"
5223
+ );
5224
+ } else {
5225
+ logger11.warn({ tenantId, projectId, graphId: graph.id }, "Graph definition not found");
5226
+ }
5227
+ } catch (error) {
5228
+ logger11.error(
5229
+ { tenantId, projectId, graphId: graph.id, error },
5230
+ "Failed to retrieve full graph definition"
5231
+ );
5232
+ }
5233
+ });
5234
+ await Promise.all(graphPromises);
5235
+ }
5236
+ const fullProjectDefinition = {
5237
+ id: project.id,
5238
+ name: project.name,
5239
+ description: project.description,
5240
+ models: project.models || void 0,
5241
+ stopWhen: project.stopWhen || void 0,
5242
+ graphs,
5243
+ tools: {},
5244
+ // TODO: Implement proper tools retrieval
5245
+ createdAt: project.createdAt,
5246
+ updatedAt: project.updatedAt
5247
+ };
5248
+ logger11.info(
5249
+ {
5250
+ tenantId,
5251
+ projectId,
5252
+ graphCount: Object.keys(fullProjectDefinition.graphs).length
5253
+ },
5254
+ "Full project definition retrieved"
5255
+ );
5256
+ return fullProjectDefinition;
5257
+ } catch (error) {
5258
+ logger11.error(
5259
+ {
5260
+ tenantId,
5261
+ projectId,
5262
+ error
5263
+ },
5264
+ "Failed to retrieve full project"
5265
+ );
5266
+ throw error;
5267
+ }
5268
+ };
5269
+ var deleteFullProject = (db, logger11 = defaultLogger2) => async (params) => {
5270
+ const { scopes, projectId } = params;
5271
+ const { tenantId } = scopes;
5272
+ logger11.info({ tenantId, projectId }, "Deleting full project and related entities");
5273
+ try {
5274
+ const project = await getFullProject(
5275
+ db,
5276
+ logger11
5277
+ )({
5278
+ scopes: { tenantId, projectId },
5279
+ projectId
5280
+ });
5281
+ if (!project) {
5282
+ logger11.info({ tenantId, projectId }, "Project not found for deletion");
5283
+ return false;
5284
+ }
5285
+ if (project.graphs && Object.keys(project.graphs).length > 0) {
5286
+ logger11.info(
5287
+ {
5288
+ tenantId,
5289
+ projectId,
5290
+ graphCount: Object.keys(project.graphs).length
5291
+ },
5292
+ "Deleting project graphs"
5293
+ );
5294
+ const graphPromises = Object.keys(project.graphs).map(async (graphId) => {
5295
+ try {
5296
+ logger11.info({ tenantId, projectId, graphId }, "Deleting graph from project");
5297
+ await deleteFullGraph(
5298
+ db,
5299
+ logger11
5300
+ )({
5301
+ scopes: { tenantId, projectId },
5302
+ graphId
5303
+ });
5304
+ logger11.info(
5305
+ { tenantId, projectId, graphId },
5306
+ "Graph deleted successfully from project"
5307
+ );
5308
+ } catch (error) {
5309
+ logger11.error(
5310
+ { tenantId, projectId, graphId, error },
5311
+ "Failed to delete graph from project"
5312
+ );
5313
+ throw error;
5314
+ }
5315
+ });
5316
+ await Promise.all(graphPromises);
5317
+ logger11.info(
5318
+ {
5319
+ tenantId,
5320
+ projectId,
5321
+ graphCount: Object.keys(project.graphs).length
5322
+ },
5323
+ "All project graphs deleted successfully"
5324
+ );
5325
+ }
5326
+ const deleted = await deleteProject(db)({
5327
+ scopes: { tenantId, projectId }
5328
+ });
5329
+ if (!deleted) {
5330
+ logger11.warn({ tenantId, projectId }, "Project deletion returned false");
5331
+ return false;
5332
+ }
5333
+ logger11.info({ tenantId, projectId }, "Full project deleted successfully");
5334
+ return true;
5335
+ } catch (error) {
5336
+ logger11.error(
5337
+ {
5338
+ tenantId,
5339
+ projectId,
5340
+ error
5341
+ },
5342
+ "Failed to delete full project"
5343
+ );
5344
+ throw error;
5345
+ }
5346
+ };
5002
5347
  var createTask = (db) => async (params) => {
5003
5348
  const now = (/* @__PURE__ */ new Date()).toISOString();
5004
5349
  const [created] = await db.insert(tasks).values({
@@ -5360,6 +5705,8 @@ function getTitleFromCode(code) {
5360
5705
  return "Forbidden";
5361
5706
  case "not_found":
5362
5707
  return "Not Found";
5708
+ case "conflict":
5709
+ return "Conflict";
5363
5710
  case "unprocessable_entity":
5364
5711
  return "Unprocessable Entity";
5365
5712
  case "internal_server_error":
@@ -5674,12 +6021,8 @@ function getTracer(serviceName, serviceVersion) {
5674
6021
  }
5675
6022
  }
5676
6023
 
5677
- // package.json
5678
- var package_default = {
5679
- version: "0.1.6"};
5680
-
5681
6024
  // src/utils/tracer.ts
5682
- var tracer = getTracer("agents-core", package_default.version);
6025
+ var tracer = getTracer("agents-core");
5683
6026
  var logger5 = getLogger("context-cache");
5684
6027
  var ContextCache = class {
5685
6028
  constructor(tenantId, projectId, dbClient) {
@@ -7643,4 +7986,4 @@ function createDefaultCredentialStores() {
7643
7986
  return stores;
7644
7987
  }
7645
7988
 
7646
- export { ConsoleLogger, ContextCache, ContextConfigBuilder, ContextFetcher, ContextResolver, CredentialStoreRegistry, CredentialStuffer, ERROR_DOCS_BASE_URL, ErrorCode, HTTP_REQUEST_PARTS, InMemoryCredentialStore, KeyChainStore, McpClient, NangoCredentialStore, NoOpLogger, TemplateEngine, addLedgerArtifacts, addToolToAgent, associateArtifactComponentWithAgent, associateDataComponentWithAgent, cleanupTenantCache, clearContextConfigCache, clearConversationCache, commonCreateErrorResponses, commonDeleteErrorResponses, commonGetErrorResponses, commonUpdateErrorResponses, configureLogging, contextConfig, contextValidationMiddleware, countApiKeys, countArtifactComponents, countArtifactComponentsForAgent, countContextConfigs, countCredentialReferences, countDataComponents, countExternalAgents, countLedgerArtifactsByTask, countMessagesByConversation, countProjects, createAgent, createAgentGraph, createAgentRelation, createAgentToolRelation, createApiError, createApiKey, createArtifactComponent, createContextConfig, createConversation, createCredentialReference, createDataComponent, createDatabaseClient, createDefaultCredentialStores, createExecutionContext, createExternalAgent, createExternalAgentRelation, createFullGraphServerSide, createInMemoryDatabaseClient, createKeyChainStore, createMessage, createNangoCredentialStore, createOrGetConversation, createProject, createTask, createTool, createValidatedDataAccess, dbResultToMcpTool, deleteAgent, deleteAgentArtifactComponentRelationByAgent, deleteAgentDataComponentRelationByAgent, deleteAgentGraph, deleteAgentRelation, deleteAgentRelationsByGraph, deleteAgentToolRelation, deleteAgentToolRelationByAgent, deleteApiKey, deleteArtifactComponent, deleteContextConfig, deleteConversation, deleteCredentialReference, deleteDataComponent, deleteExternalAgent, deleteFullGraph, deleteLedgerArtifactsByContext, deleteLedgerArtifactsByTask, deleteMessage, deleteProject, deleteTool, detectAuthenticationRequired, determineContextTrigger, discoverOAuthEndpoints, errorResponseSchema, errorSchemaFactory, externalAgentExists, externalAgentUrlExists, extractPublicId, fetchComponentRelationships, fetchDefinition, generateAndCreateApiKey, generateApiKey, getActiveAgentForConversation, getAgentById, getAgentGraph, getAgentGraphById, getAgentGraphWithDefaultAgent, getAgentInGraphContext, getAgentRelationById, getAgentRelationByParams, getAgentRelations, getAgentRelationsByGraph, getAgentRelationsBySource, getAgentRelationsByTarget, getAgentToolRelationByAgent, getAgentToolRelationById, getAgentToolRelationByTool, getAgentsByIds, getAgentsForTool, getAgentsUsingArtifactComponent, getAgentsUsingDataComponent, getApiKeyById, getApiKeyByPublicId, getArtifactComponentById, getArtifactComponentsForAgent, getCacheEntry, getCachedValidator, getContextConfigById, getContextConfigCacheEntries, getContextConfigsByName, getConversation, getConversationCacheEntries, getConversationHistory, getCredentialReference, getCredentialReferenceById, getCredentialReferenceWithTools, getCredentialStoreLookupKeyFromRetrievalParams, getDataComponent, getDataComponentsForAgent, getExternalAgent, getExternalAgentByUrl, getExternalAgentRelations, getFullGraph, getFullGraphDefinition, getGraphAgentInfos, getHealthyToolsForAgent, getLedgerArtifacts, getLedgerArtifactsByContext, getLogger, getMessageById, getMessagesByConversation, getMessagesByTask, getProject, getProjectResourceCounts, getRelatedAgentsForGraph, getRequestExecutionContext, getTask, getToolById, getToolsByStatus, getToolsForAgent, getTracer, getVisibleMessages, graphHasArtifactComponents, handleApiError, handleContextConfigChange, handleContextResolution, hasApiKey, hasContextConfig, hasCredentialReference, hashApiKey, invalidateInvocationDefinitionsCache, invalidateRequestContextCache, isApiKeyExpired, isArtifactComponentAssociatedWithAgent, isDataComponentAssociatedWithAgent, isValidHttpRequest, listAgentGraphs, listAgentGraphsPaginated, listAgentRelations, listAgentToolRelations, listAgentToolRelationsByAgent, listAgents, listAgentsPaginated, listApiKeys, listApiKeysPaginated, listArtifactComponents, listArtifactComponentsPaginated, listContextConfigs, listContextConfigsPaginated, listConversations, listCredentialReferences, listCredentialReferencesPaginated, listDataComponents, listDataComponentsPaginated, listExternalAgents, listExternalAgentsPaginated, listMessages, listProjects, listProjectsPaginated, listTaskIdsByContextId, listTools, listToolsByStatus, loggerFactory, maskApiKey, problemDetailsSchema, projectExists, projectExistsInTable, projectHasResources, removeArtifactComponentFromAgent, removeDataComponentFromAgent, removeToolFromAgent, setActiveAgentForConversation, setActiveAgentForThread, setCacheEntry, setSpanWithError, updateAgent, updateAgentGraph, updateAgentRelation, updateAgentToolRelation, updateApiKey, updateApiKeyLastUsed, updateArtifactComponent, updateContextConfig, updateConversation, updateConversationActiveAgent, updateCredentialReference, updateDataComponent, updateExternalAgent, updateFullGraphServerSide, updateMessage, updateProject, updateTask, updateTool, updateToolStatus, upsertAgent, upsertAgentArtifactComponentRelation, upsertAgentDataComponentRelation, upsertAgentGraph, upsertAgentRelation, upsertAgentToolRelation, upsertArtifactComponent, upsertContextConfig, upsertCredentialReference, upsertDataComponent, upsertExternalAgent, upsertTool, validateAgainstJsonSchema, validateAndGetApiKey, validateApiKey, validateExternalAgent, validateHttpRequestHeaders, validateInternalAgent, validateProjectExists, validateRequestContext, validationHelper, withProjectValidation };
7989
+ export { ConsoleLogger, ContextCache, ContextConfigBuilder, ContextFetcher, ContextResolver, CredentialStoreRegistry, CredentialStuffer, ERROR_DOCS_BASE_URL, ErrorCode, HTTP_REQUEST_PARTS, InMemoryCredentialStore, KeyChainStore, McpClient, NangoCredentialStore, NoOpLogger, TemplateEngine, addLedgerArtifacts, addToolToAgent, associateArtifactComponentWithAgent, associateDataComponentWithAgent, cleanupTenantCache, clearContextConfigCache, clearConversationCache, commonCreateErrorResponses, commonDeleteErrorResponses, commonGetErrorResponses, commonUpdateErrorResponses, configureLogging, contextConfig, contextValidationMiddleware, countApiKeys, countArtifactComponents, countArtifactComponentsForAgent, countContextConfigs, countCredentialReferences, countDataComponents, countExternalAgents, countLedgerArtifactsByTask, countMessagesByConversation, countProjects, createAgent, createAgentGraph, createAgentRelation, createAgentToolRelation, createApiError, createApiKey, createArtifactComponent, createContextConfig, createConversation, createCredentialReference, createDataComponent, createDatabaseClient, createDefaultCredentialStores, createExecutionContext, createExternalAgent, createExternalAgentRelation, createFullGraphServerSide, createFullProjectServerSide, createInMemoryDatabaseClient, createKeyChainStore, createMessage, createNangoCredentialStore, createOrGetConversation, createProject, createTask, createTool, createValidatedDataAccess, dbResultToMcpTool, deleteAgent, deleteAgentArtifactComponentRelationByAgent, deleteAgentDataComponentRelationByAgent, deleteAgentGraph, deleteAgentRelation, deleteAgentRelationsByGraph, deleteAgentToolRelation, deleteAgentToolRelationByAgent, deleteApiKey, deleteArtifactComponent, deleteContextConfig, deleteConversation, deleteCredentialReference, deleteDataComponent, deleteExternalAgent, deleteFullGraph, deleteFullProject, deleteLedgerArtifactsByContext, deleteLedgerArtifactsByTask, deleteMessage, deleteProject, deleteTool, detectAuthenticationRequired, determineContextTrigger, discoverOAuthEndpoints, errorResponseSchema, errorSchemaFactory, externalAgentExists, externalAgentUrlExists, extractPublicId, fetchComponentRelationships, fetchDefinition, generateAndCreateApiKey, generateApiKey, getActiveAgentForConversation, getAgentById, getAgentGraph, getAgentGraphById, getAgentGraphWithDefaultAgent, getAgentInGraphContext, getAgentRelationById, getAgentRelationByParams, getAgentRelations, getAgentRelationsByGraph, getAgentRelationsBySource, getAgentRelationsByTarget, getAgentToolRelationByAgent, getAgentToolRelationById, getAgentToolRelationByTool, getAgentsByIds, getAgentsForTool, getAgentsUsingArtifactComponent, getAgentsUsingDataComponent, getApiKeyById, getApiKeyByPublicId, getArtifactComponentById, getArtifactComponentsForAgent, getCacheEntry, getCachedValidator, getContextConfigById, getContextConfigCacheEntries, getContextConfigsByName, getConversation, getConversationCacheEntries, getConversationHistory, getCredentialReference, getCredentialReferenceById, getCredentialReferenceWithTools, getCredentialStoreLookupKeyFromRetrievalParams, getDataComponent, getDataComponentsForAgent, getExternalAgent, getExternalAgentByUrl, getExternalAgentRelations, getFullGraph, getFullGraphDefinition, getFullProject, getGraphAgentInfos, getHealthyToolsForAgent, getLedgerArtifacts, getLedgerArtifactsByContext, getLogger, getMessageById, getMessagesByConversation, getMessagesByTask, getProject, getProjectResourceCounts, getRelatedAgentsForGraph, getRequestExecutionContext, getTask, getToolById, getToolsByStatus, getToolsForAgent, getTracer, getVisibleMessages, graphHasArtifactComponents, handleApiError, handleContextConfigChange, handleContextResolution, hasApiKey, hasContextConfig, hasCredentialReference, hashApiKey, invalidateInvocationDefinitionsCache, invalidateRequestContextCache, isApiKeyExpired, isArtifactComponentAssociatedWithAgent, isDataComponentAssociatedWithAgent, isValidHttpRequest, listAgentGraphs, listAgentGraphsPaginated, listAgentRelations, listAgentToolRelations, listAgentToolRelationsByAgent, listAgents, listAgentsPaginated, listApiKeys, listApiKeysPaginated, listArtifactComponents, listArtifactComponentsPaginated, listContextConfigs, listContextConfigsPaginated, listConversations, listCredentialReferences, listCredentialReferencesPaginated, listDataComponents, listDataComponentsPaginated, listExternalAgents, listExternalAgentsPaginated, listMessages, listProjects, listProjectsPaginated, listTaskIdsByContextId, listTools, listToolsByStatus, loggerFactory, maskApiKey, problemDetailsSchema, projectExists, projectExistsInTable, projectHasResources, removeArtifactComponentFromAgent, removeDataComponentFromAgent, removeToolFromAgent, setActiveAgentForConversation, setActiveAgentForThread, setCacheEntry, setSpanWithError, updateAgent, updateAgentGraph, updateAgentRelation, updateAgentToolRelation, updateApiKey, updateApiKeyLastUsed, updateArtifactComponent, updateContextConfig, updateConversation, updateConversationActiveAgent, updateCredentialReference, updateDataComponent, updateExternalAgent, updateFullGraphServerSide, updateFullProjectServerSide, updateMessage, updateProject, updateTask, updateTool, updateToolStatus, upsertAgent, upsertAgentArtifactComponentRelation, upsertAgentDataComponentRelation, upsertAgentGraph, upsertAgentRelation, upsertAgentToolRelation, upsertArtifactComponent, upsertContextConfig, upsertCredentialReference, upsertDataComponent, upsertExternalAgent, upsertTool, validateAgainstJsonSchema, validateAndGetApiKey, validateApiKey, validateExternalAgent, validateHttpRequestHeaders, validateInternalAgent, validateProjectExists, validateRequestContext, validationHelper, withProjectValidation };