@inkeep/agents-core 0.1.10 → 0.2.1

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,12 +1,12 @@
1
1
  export { TaskState } from './chunk-H2F72PDA.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';
2
+ import { validateAndTypeGraphData, validateGraphStructure, isInternalAgent, isExternalAgent } from './chunk-GDVT5LPG.js';
3
+ export { generateIdFromName, isExternalAgent, isInternalAgent, isValidResourceId, validateAgentRelationships, validateAndTypeGraphData, validateArtifactComponentReferences, validateDataComponentReferences, validateGraphStructure, validateToolReferences } from './chunk-GDVT5LPG.js';
4
+ import { ContextConfigApiUpdateSchema } from './chunk-MY4NEHGT.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-MY4NEHGT.js';
8
6
  import { CredentialStoreType, MCPServerType, MCPTransportType } from './chunk-SVGQSPW4.js';
9
7
  export { CredentialStoreType, MCPServerType, MCPTransportType, TOOL_STATUS_VALUES, VALID_RELATION_TYPES } from './chunk-SVGQSPW4.js';
8
+ 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';
9
+ 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';
10
10
  import { __publicField } from './chunk-MKBO26DX.js';
11
11
  import { z as z$1 } from 'zod';
12
12
  import jmespath from 'jmespath';
@@ -3627,33 +3627,35 @@ var createFullGraphServerSide = (db, logger11 = defaultLogger) => async (scopes,
3627
3627
  validateGraphStructure(typed);
3628
3628
  await applyExecutionLimitsInheritance(db, logger11, { tenantId, projectId }, typed);
3629
3629
  try {
3630
- if (typed.credentialReferences) {
3630
+ if (typed.credentialReferences && Object.keys(typed.credentialReferences).length > 0) {
3631
3631
  logger11.info(
3632
- { credentialReferencesCount: typed.credentialReferences.length },
3632
+ { credentialReferencesCount: Object.keys(typed.credentialReferences).length },
3633
3633
  "Processing credential references"
3634
3634
  );
3635
- const credentialRefPromises = typed.credentialReferences.map(async (credData) => {
3636
- try {
3637
- logger11.info({ credId: credData.id }, "Processing credential reference");
3638
- await upsertCredentialReference(db)({
3639
- data: {
3640
- ...credData,
3641
- tenantId,
3642
- projectId
3643
- }
3644
- });
3645
- logger11.info({ credId: credData.id }, "Credential reference processed successfully");
3646
- } catch (error) {
3647
- logger11.error(
3648
- { credId: credData.id, error },
3649
- "Failed to create/update credential reference"
3650
- );
3651
- throw error;
3635
+ const credentialRefPromises = Object.entries(typed.credentialReferences).map(
3636
+ async ([_credId, credData]) => {
3637
+ try {
3638
+ logger11.info({ credId: credData.id }, "Processing credential reference");
3639
+ await upsertCredentialReference(db)({
3640
+ data: {
3641
+ ...credData,
3642
+ tenantId,
3643
+ projectId
3644
+ }
3645
+ });
3646
+ logger11.info({ credId: credData.id }, "Credential reference processed successfully");
3647
+ } catch (error) {
3648
+ logger11.error(
3649
+ { credId: credData.id, error },
3650
+ "Failed to create/update credential reference"
3651
+ );
3652
+ throw error;
3653
+ }
3652
3654
  }
3653
- });
3655
+ );
3654
3656
  await Promise.all(credentialRefPromises);
3655
3657
  logger11.info(
3656
- { credentialReferencesCount: typed.credentialReferences.length },
3658
+ { credentialReferencesCount: Object.keys(typed.credentialReferences).length },
3657
3659
  "All credential references created/updated successfully"
3658
3660
  );
3659
3661
  }
@@ -4058,13 +4060,15 @@ var updateFullGraphServerSide = (db, logger11 = defaultLogger) => async (scopes,
4058
4060
  return createFullGraphServerSide(db)(scopes, graphData);
4059
4061
  }
4060
4062
  const existingGraphModels = existingGraph.models;
4061
- if (typedGraphDefinition.credentialReferences) {
4063
+ if (typedGraphDefinition.credentialReferences && Object.keys(typedGraphDefinition.credentialReferences).length > 0) {
4062
4064
  logger11.info(
4063
- { credentialReferencesCount: typedGraphDefinition.credentialReferences.length },
4065
+ {
4066
+ credentialReferencesCount: Object.keys(typedGraphDefinition.credentialReferences).length
4067
+ },
4064
4068
  "Processing credential references"
4065
4069
  );
4066
- const credentialRefPromises = typedGraphDefinition.credentialReferences.map(
4067
- async (credData) => {
4070
+ const credentialRefPromises = Object.entries(typedGraphDefinition.credentialReferences).map(
4071
+ async ([_credId, credData]) => {
4068
4072
  try {
4069
4073
  logger11.info({ credId: credData.id }, "Processing credential reference");
4070
4074
  await upsertCredentialReference(db)({
@@ -4086,7 +4090,9 @@ var updateFullGraphServerSide = (db, logger11 = defaultLogger) => async (scopes,
4086
4090
  );
4087
4091
  await Promise.all(credentialRefPromises);
4088
4092
  logger11.info(
4089
- { credentialReferencesCount: typedGraphDefinition.credentialReferences.length },
4093
+ {
4094
+ credentialReferencesCount: Object.keys(typedGraphDefinition.credentialReferences).length
4095
+ },
4090
4096
  "All credential references created/updated successfully"
4091
4097
  );
4092
4098
  }
@@ -5027,6 +5033,213 @@ var createFullProjectServerSide = (db, logger11 = defaultLogger2) => async (scop
5027
5033
  logger11.info({ projectId: typed.id }, "Creating project metadata");
5028
5034
  await createProject(db)(projectPayload);
5029
5035
  logger11.info({ projectId: typed.id }, "Project metadata created successfully");
5036
+ if (typed.credentialReferences && Object.keys(typed.credentialReferences).length > 0) {
5037
+ logger11.info(
5038
+ {
5039
+ projectId: typed.id,
5040
+ count: Object.keys(typed.credentialReferences).length
5041
+ },
5042
+ "Creating project credentialReferences"
5043
+ );
5044
+ const credentialPromises = Object.entries(typed.credentialReferences).map(
5045
+ async ([_credId, credData]) => {
5046
+ try {
5047
+ logger11.info(
5048
+ { projectId: typed.id, credId: credData.id },
5049
+ "Creating credentialReference in project"
5050
+ );
5051
+ await upsertCredentialReference(db)({
5052
+ data: {
5053
+ ...credData,
5054
+ tenantId,
5055
+ projectId: typed.id
5056
+ }
5057
+ });
5058
+ logger11.info(
5059
+ { projectId: typed.id, credId: credData.id },
5060
+ "CredentialReference created successfully"
5061
+ );
5062
+ } catch (error) {
5063
+ logger11.error(
5064
+ { projectId: typed.id, credId: credData.id, error },
5065
+ "Failed to create credentialReference in project"
5066
+ );
5067
+ throw error;
5068
+ }
5069
+ }
5070
+ );
5071
+ await Promise.all(credentialPromises);
5072
+ logger11.info(
5073
+ {
5074
+ projectId: typed.id,
5075
+ count: Object.keys(typed.credentialReferences).length
5076
+ },
5077
+ "All project credentialReferences created successfully"
5078
+ );
5079
+ }
5080
+ if (typed.tools && Object.keys(typed.tools).length > 0) {
5081
+ logger11.info(
5082
+ {
5083
+ projectId: typed.id,
5084
+ toolCount: Object.keys(typed.tools).length
5085
+ },
5086
+ "Creating project tools"
5087
+ );
5088
+ const toolPromises = Object.entries(typed.tools).map(async ([toolId, toolData]) => {
5089
+ try {
5090
+ logger11.info({ projectId: typed.id, toolId }, "Creating tool in project");
5091
+ await upsertTool(db)({
5092
+ data: {
5093
+ tenantId,
5094
+ projectId: typed.id,
5095
+ ...toolData
5096
+ }
5097
+ });
5098
+ logger11.info({ projectId: typed.id, toolId }, "Tool created successfully");
5099
+ } catch (error) {
5100
+ logger11.error(
5101
+ { projectId: typed.id, toolId, error },
5102
+ "Failed to create tool in project"
5103
+ );
5104
+ throw error;
5105
+ }
5106
+ });
5107
+ await Promise.all(toolPromises);
5108
+ logger11.info(
5109
+ {
5110
+ projectId: typed.id,
5111
+ toolCount: Object.keys(typed.tools).length
5112
+ },
5113
+ "All project tools created successfully"
5114
+ );
5115
+ }
5116
+ if (typed.contextConfig && Object.keys(typed.contextConfig).length > 0) {
5117
+ logger11.info(
5118
+ {
5119
+ projectId: typed.id,
5120
+ count: Object.keys(typed.contextConfig).length
5121
+ },
5122
+ "Creating project contextConfigs"
5123
+ );
5124
+ const contextConfigPromises = Object.entries(typed.contextConfig).map(
5125
+ async ([configId, configData]) => {
5126
+ try {
5127
+ logger11.info({ projectId: typed.id, configId }, "Creating contextConfig in project");
5128
+ await upsertContextConfig(db)({
5129
+ data: {
5130
+ ...configData,
5131
+ tenantId,
5132
+ projectId: typed.id
5133
+ }
5134
+ });
5135
+ logger11.info({ projectId: typed.id, configId }, "ContextConfig created successfully");
5136
+ } catch (error) {
5137
+ logger11.error(
5138
+ { projectId: typed.id, configId, error },
5139
+ "Failed to create contextConfig in project"
5140
+ );
5141
+ throw error;
5142
+ }
5143
+ }
5144
+ );
5145
+ await Promise.all(contextConfigPromises);
5146
+ logger11.info(
5147
+ {
5148
+ projectId: typed.id,
5149
+ count: Object.keys(typed.contextConfig).length
5150
+ },
5151
+ "All project contextConfigs created successfully"
5152
+ );
5153
+ }
5154
+ if (typed.dataComponents && Object.keys(typed.dataComponents).length > 0) {
5155
+ logger11.info(
5156
+ {
5157
+ projectId: typed.id,
5158
+ count: Object.keys(typed.dataComponents).length
5159
+ },
5160
+ "Creating project dataComponents"
5161
+ );
5162
+ const dataComponentPromises = Object.entries(typed.dataComponents).map(
5163
+ async ([componentId, componentData]) => {
5164
+ try {
5165
+ logger11.info(
5166
+ { projectId: typed.id, componentId },
5167
+ "Creating dataComponent in project"
5168
+ );
5169
+ await upsertDataComponent(db)({
5170
+ data: {
5171
+ ...componentData,
5172
+ tenantId,
5173
+ projectId: typed.id
5174
+ }
5175
+ });
5176
+ logger11.info(
5177
+ { projectId: typed.id, componentId },
5178
+ "DataComponent created successfully"
5179
+ );
5180
+ } catch (error) {
5181
+ logger11.error(
5182
+ { projectId: typed.id, componentId, error },
5183
+ "Failed to create dataComponent in project"
5184
+ );
5185
+ throw error;
5186
+ }
5187
+ }
5188
+ );
5189
+ await Promise.all(dataComponentPromises);
5190
+ logger11.info(
5191
+ {
5192
+ projectId: typed.id,
5193
+ count: Object.keys(typed.dataComponents).length
5194
+ },
5195
+ "All project dataComponents created successfully"
5196
+ );
5197
+ }
5198
+ if (typed.artifactComponents && Object.keys(typed.artifactComponents).length > 0) {
5199
+ logger11.info(
5200
+ {
5201
+ projectId: typed.id,
5202
+ count: Object.keys(typed.artifactComponents).length
5203
+ },
5204
+ "Creating project artifactComponents"
5205
+ );
5206
+ const artifactComponentPromises = Object.entries(typed.artifactComponents).map(
5207
+ async ([componentId, componentData]) => {
5208
+ try {
5209
+ logger11.info(
5210
+ { projectId: typed.id, componentId },
5211
+ "Creating artifactComponent in project"
5212
+ );
5213
+ await upsertArtifactComponent(db)({
5214
+ data: {
5215
+ id: componentId,
5216
+ ...componentData,
5217
+ tenantId,
5218
+ projectId: typed.id
5219
+ }
5220
+ });
5221
+ logger11.info(
5222
+ { projectId: typed.id, componentId },
5223
+ "ArtifactComponent created successfully"
5224
+ );
5225
+ } catch (error) {
5226
+ logger11.error(
5227
+ { projectId: typed.id, componentId, error },
5228
+ "Failed to create artifactComponent in project"
5229
+ );
5230
+ throw error;
5231
+ }
5232
+ }
5233
+ );
5234
+ await Promise.all(artifactComponentPromises);
5235
+ logger11.info(
5236
+ {
5237
+ projectId: typed.id,
5238
+ count: Object.keys(typed.artifactComponents).length
5239
+ },
5240
+ "All project artifactComponents created successfully"
5241
+ );
5242
+ }
5030
5243
  if (typed.graphs && Object.keys(typed.graphs).length > 0) {
5031
5244
  logger11.info(
5032
5245
  {
@@ -5038,13 +5251,19 @@ var createFullProjectServerSide = (db, logger11 = defaultLogger2) => async (scop
5038
5251
  const graphPromises = Object.entries(typed.graphs).map(async ([graphId, graphData]) => {
5039
5252
  try {
5040
5253
  logger11.info({ projectId: typed.id, graphId }, "Creating graph in project");
5041
- const graphDataWithUndefined = {
5254
+ const graphDataWithProjectResources = {
5042
5255
  ...graphData,
5256
+ tools: typed.tools || {},
5257
+ // Pass project-level resources for validation
5258
+ dataComponents: typed.dataComponents || {},
5259
+ artifactComponents: typed.artifactComponents || {},
5260
+ contextConfig: typed.contextConfig?.[graphId] || void 0,
5261
+ credentialReferences: typed.credentialReferences || {},
5043
5262
  statusUpdates: graphData.statusUpdates === null ? void 0 : graphData.statusUpdates
5044
5263
  };
5045
5264
  await createFullGraphServerSide(db, logger11)(
5046
5265
  { tenantId, projectId: typed.id },
5047
- graphDataWithUndefined
5266
+ graphDataWithProjectResources
5048
5267
  );
5049
5268
  logger11.info({ projectId: typed.id, graphId }, "Graph created successfully in project");
5050
5269
  } catch (error) {
@@ -5121,6 +5340,213 @@ var updateFullProjectServerSide = (db, logger11 = defaultLogger2) => async (scop
5121
5340
  data: projectUpdatePayload
5122
5341
  });
5123
5342
  logger11.info({ projectId: typed.id }, "Project metadata updated successfully");
5343
+ if (typed.credentialReferences && Object.keys(typed.credentialReferences).length > 0) {
5344
+ logger11.info(
5345
+ {
5346
+ projectId: typed.id,
5347
+ count: Object.keys(typed.credentialReferences).length
5348
+ },
5349
+ "Updating project credentialReferences"
5350
+ );
5351
+ const credentialPromises = Object.entries(typed.credentialReferences).map(
5352
+ async ([_credId, credData]) => {
5353
+ try {
5354
+ logger11.info(
5355
+ { projectId: typed.id, credId: credData.id },
5356
+ "Updating credentialReference in project"
5357
+ );
5358
+ await upsertCredentialReference(db)({
5359
+ data: {
5360
+ ...credData,
5361
+ tenantId,
5362
+ projectId: typed.id
5363
+ }
5364
+ });
5365
+ logger11.info(
5366
+ { projectId: typed.id, credId: credData.id },
5367
+ "CredentialReference updated successfully"
5368
+ );
5369
+ } catch (error) {
5370
+ logger11.error(
5371
+ { projectId: typed.id, credId: credData.id, error },
5372
+ "Failed to update credentialReference in project"
5373
+ );
5374
+ throw error;
5375
+ }
5376
+ }
5377
+ );
5378
+ await Promise.all(credentialPromises);
5379
+ logger11.info(
5380
+ {
5381
+ projectId: typed.id,
5382
+ count: Object.keys(typed.credentialReferences).length
5383
+ },
5384
+ "All project credentialReferences updated successfully"
5385
+ );
5386
+ }
5387
+ if (typed.tools && Object.keys(typed.tools).length > 0) {
5388
+ logger11.info(
5389
+ {
5390
+ projectId: typed.id,
5391
+ toolCount: Object.keys(typed.tools).length
5392
+ },
5393
+ "Updating project tools"
5394
+ );
5395
+ const toolPromises = Object.entries(typed.tools).map(async ([toolId, toolData]) => {
5396
+ try {
5397
+ logger11.info({ projectId: typed.id, toolId }, "Updating tool in project");
5398
+ await upsertTool(db)({
5399
+ data: {
5400
+ tenantId,
5401
+ projectId: typed.id,
5402
+ ...toolData
5403
+ }
5404
+ });
5405
+ logger11.info({ projectId: typed.id, toolId }, "Tool updated successfully");
5406
+ } catch (error) {
5407
+ logger11.error(
5408
+ { projectId: typed.id, toolId, error },
5409
+ "Failed to update tool in project"
5410
+ );
5411
+ throw error;
5412
+ }
5413
+ });
5414
+ await Promise.all(toolPromises);
5415
+ logger11.info(
5416
+ {
5417
+ projectId: typed.id,
5418
+ toolCount: Object.keys(typed.tools).length
5419
+ },
5420
+ "All project tools updated successfully"
5421
+ );
5422
+ }
5423
+ if (typed.contextConfig && Object.keys(typed.contextConfig).length > 0) {
5424
+ logger11.info(
5425
+ {
5426
+ projectId: typed.id,
5427
+ count: Object.keys(typed.contextConfig).length
5428
+ },
5429
+ "Updating project contextConfigs"
5430
+ );
5431
+ const contextConfigPromises = Object.entries(typed.contextConfig).map(
5432
+ async ([configId, configData]) => {
5433
+ try {
5434
+ logger11.info({ projectId: typed.id, configId }, "Updating contextConfig in project");
5435
+ await upsertContextConfig(db)({
5436
+ data: {
5437
+ ...configData,
5438
+ tenantId,
5439
+ projectId: typed.id
5440
+ }
5441
+ });
5442
+ logger11.info({ projectId: typed.id, configId }, "ContextConfig updated successfully");
5443
+ } catch (error) {
5444
+ logger11.error(
5445
+ { projectId: typed.id, configId, error },
5446
+ "Failed to update contextConfig in project"
5447
+ );
5448
+ throw error;
5449
+ }
5450
+ }
5451
+ );
5452
+ await Promise.all(contextConfigPromises);
5453
+ logger11.info(
5454
+ {
5455
+ projectId: typed.id,
5456
+ count: Object.keys(typed.contextConfig).length
5457
+ },
5458
+ "All project contextConfigs updated successfully"
5459
+ );
5460
+ }
5461
+ if (typed.dataComponents && Object.keys(typed.dataComponents).length > 0) {
5462
+ logger11.info(
5463
+ {
5464
+ projectId: typed.id,
5465
+ count: Object.keys(typed.dataComponents).length
5466
+ },
5467
+ "Updating project dataComponents"
5468
+ );
5469
+ const dataComponentPromises = Object.entries(typed.dataComponents).map(
5470
+ async ([componentId, componentData]) => {
5471
+ try {
5472
+ logger11.info(
5473
+ { projectId: typed.id, componentId },
5474
+ "Updating dataComponent in project"
5475
+ );
5476
+ await upsertDataComponent(db)({
5477
+ data: {
5478
+ ...componentData,
5479
+ tenantId,
5480
+ projectId: typed.id
5481
+ }
5482
+ });
5483
+ logger11.info(
5484
+ { projectId: typed.id, componentId },
5485
+ "DataComponent updated successfully"
5486
+ );
5487
+ } catch (error) {
5488
+ logger11.error(
5489
+ { projectId: typed.id, componentId, error },
5490
+ "Failed to update dataComponent in project"
5491
+ );
5492
+ throw error;
5493
+ }
5494
+ }
5495
+ );
5496
+ await Promise.all(dataComponentPromises);
5497
+ logger11.info(
5498
+ {
5499
+ projectId: typed.id,
5500
+ count: Object.keys(typed.dataComponents).length
5501
+ },
5502
+ "All project dataComponents updated successfully"
5503
+ );
5504
+ }
5505
+ if (typed.artifactComponents && Object.keys(typed.artifactComponents).length > 0) {
5506
+ logger11.info(
5507
+ {
5508
+ projectId: typed.id,
5509
+ count: Object.keys(typed.artifactComponents).length
5510
+ },
5511
+ "Updating project artifactComponents"
5512
+ );
5513
+ const artifactComponentPromises = Object.entries(typed.artifactComponents).map(
5514
+ async ([componentId, componentData]) => {
5515
+ try {
5516
+ logger11.info(
5517
+ { projectId: typed.id, componentId },
5518
+ "Updating artifactComponent in project"
5519
+ );
5520
+ await upsertArtifactComponent(db)({
5521
+ data: {
5522
+ id: componentId,
5523
+ ...componentData,
5524
+ tenantId,
5525
+ projectId: typed.id
5526
+ }
5527
+ });
5528
+ logger11.info(
5529
+ { projectId: typed.id, componentId },
5530
+ "ArtifactComponent updated successfully"
5531
+ );
5532
+ } catch (error) {
5533
+ logger11.error(
5534
+ { projectId: typed.id, componentId, error },
5535
+ "Failed to update artifactComponent in project"
5536
+ );
5537
+ throw error;
5538
+ }
5539
+ }
5540
+ );
5541
+ await Promise.all(artifactComponentPromises);
5542
+ logger11.info(
5543
+ {
5544
+ projectId: typed.id,
5545
+ count: Object.keys(typed.artifactComponents).length
5546
+ },
5547
+ "All project artifactComponents updated successfully"
5548
+ );
5549
+ }
5124
5550
  if (typed.graphs && Object.keys(typed.graphs).length > 0) {
5125
5551
  logger11.info(
5126
5552
  {
@@ -5132,13 +5558,19 @@ var updateFullProjectServerSide = (db, logger11 = defaultLogger2) => async (scop
5132
5558
  const graphPromises = Object.entries(typed.graphs).map(async ([graphId, graphData]) => {
5133
5559
  try {
5134
5560
  logger11.info({ projectId: typed.id, graphId }, "Updating graph in project");
5135
- const graphDataWithUndefined = {
5561
+ const graphDataWithProjectResources = {
5136
5562
  ...graphData,
5563
+ tools: typed.tools || {},
5564
+ // Pass project-level resources for validation
5565
+ dataComponents: typed.dataComponents || {},
5566
+ artifactComponents: typed.artifactComponents || {},
5567
+ contextConfig: typed.contextConfig?.[graphId] || void 0,
5568
+ credentialReferences: typed.credentialReferences || {},
5137
5569
  statusUpdates: graphData.statusUpdates === null ? void 0 : graphData.statusUpdates
5138
5570
  };
5139
5571
  await updateFullGraphServerSide(db, logger11)(
5140
5572
  { tenantId, projectId: typed.id },
5141
- graphDataWithUndefined
5573
+ graphDataWithProjectResources
5142
5574
  );
5143
5575
  logger11.info({ projectId: typed.id, graphId }, "Graph updated successfully in project");
5144
5576
  } catch (error) {
@@ -5202,6 +5634,129 @@ var getFullProject = (db, logger11 = defaultLogger2) => async (params) => {
5202
5634
  },
5203
5635
  "Found graphs for project"
5204
5636
  );
5637
+ const projectTools = {};
5638
+ try {
5639
+ const toolsList = await listTools(db)({
5640
+ scopes: { tenantId, projectId },
5641
+ pagination: { page: 1, limit: 1e3 }
5642
+ // Get all tools
5643
+ });
5644
+ for (const tool2 of toolsList.data) {
5645
+ projectTools[tool2.id] = {
5646
+ id: tool2.id,
5647
+ name: tool2.name,
5648
+ config: tool2.config,
5649
+ imageUrl: tool2.imageUrl || void 0,
5650
+ status: tool2.status,
5651
+ capabilities: tool2.capabilities || void 0,
5652
+ lastHealthCheck: tool2.lastHealthCheck && !Number.isNaN(new Date(tool2.lastHealthCheck).getTime()) ? new Date(tool2.lastHealthCheck).toISOString() : void 0,
5653
+ lastError: tool2.lastError || void 0,
5654
+ availableTools: tool2.availableTools || void 0,
5655
+ activeTools: tool2.config?.mcp?.activeTools || void 0,
5656
+ lastToolsSync: tool2.lastToolsSync && !Number.isNaN(new Date(tool2.lastToolsSync).getTime()) ? new Date(tool2.lastToolsSync).toISOString() : void 0
5657
+ };
5658
+ }
5659
+ logger11.info(
5660
+ { tenantId, projectId, toolCount: Object.keys(projectTools).length },
5661
+ "Tools retrieved for project"
5662
+ );
5663
+ } catch (error) {
5664
+ logger11.warn({ tenantId, projectId, error }, "Failed to retrieve tools for project");
5665
+ }
5666
+ const projectDataComponents = {};
5667
+ try {
5668
+ const dataComponentsList = await listDataComponents(db)({
5669
+ scopes: { tenantId, projectId }
5670
+ });
5671
+ for (const component of dataComponentsList) {
5672
+ projectDataComponents[component.id] = {
5673
+ id: component.id,
5674
+ name: component.name,
5675
+ description: component.description,
5676
+ props: component.props
5677
+ };
5678
+ }
5679
+ logger11.info(
5680
+ { tenantId, projectId, count: Object.keys(projectDataComponents).length },
5681
+ "DataComponents retrieved for project"
5682
+ );
5683
+ } catch (error) {
5684
+ logger11.warn(
5685
+ { tenantId, projectId, error },
5686
+ "Failed to retrieve dataComponents for project"
5687
+ );
5688
+ }
5689
+ const projectArtifactComponents = {};
5690
+ try {
5691
+ const artifactComponentsList = await listArtifactComponents(db)({
5692
+ scopes: { tenantId, projectId }
5693
+ });
5694
+ for (const component of artifactComponentsList) {
5695
+ projectArtifactComponents[component.id] = {
5696
+ id: component.id,
5697
+ name: component.name,
5698
+ description: component.description,
5699
+ summaryProps: component.summaryProps,
5700
+ fullProps: component.fullProps
5701
+ };
5702
+ }
5703
+ logger11.info(
5704
+ { tenantId, projectId, count: Object.keys(projectArtifactComponents).length },
5705
+ "ArtifactComponents retrieved for project"
5706
+ );
5707
+ } catch (error) {
5708
+ logger11.warn(
5709
+ { tenantId, projectId, error },
5710
+ "Failed to retrieve artifactComponents for project"
5711
+ );
5712
+ }
5713
+ const projectContextConfigs = {};
5714
+ try {
5715
+ const contextConfigsList = await listContextConfigs(db)({
5716
+ scopes: { tenantId, projectId }
5717
+ });
5718
+ for (const config of contextConfigsList) {
5719
+ projectContextConfigs[config.id] = {
5720
+ id: config.id,
5721
+ name: config.name,
5722
+ description: config.description,
5723
+ requestContextSchema: config.requestContextSchema,
5724
+ contextVariables: config.contextVariables
5725
+ };
5726
+ }
5727
+ logger11.info(
5728
+ { tenantId, projectId, count: Object.keys(projectContextConfigs).length },
5729
+ "ContextConfigs retrieved for project"
5730
+ );
5731
+ } catch (error) {
5732
+ logger11.warn(
5733
+ { tenantId, projectId, error },
5734
+ "Failed to retrieve contextConfigs for project"
5735
+ );
5736
+ }
5737
+ const projectCredentialReferences = {};
5738
+ try {
5739
+ const credentialReferencesList = await listCredentialReferences(db)({
5740
+ scopes: { tenantId, projectId }
5741
+ });
5742
+ for (const credential of credentialReferencesList) {
5743
+ projectCredentialReferences[credential.id] = {
5744
+ id: credential.id,
5745
+ type: credential.type,
5746
+ credentialStoreId: credential.credentialStoreId,
5747
+ retrievalParams: credential.retrievalParams
5748
+ };
5749
+ }
5750
+ logger11.info(
5751
+ { tenantId, projectId, count: Object.keys(projectCredentialReferences).length },
5752
+ "CredentialReferences retrieved for project"
5753
+ );
5754
+ } catch (error) {
5755
+ logger11.warn(
5756
+ { tenantId, projectId, error },
5757
+ "Failed to retrieve credentialReferences for project"
5758
+ );
5759
+ }
5205
5760
  const graphs = {};
5206
5761
  if (graphList.length > 0) {
5207
5762
  const graphPromises = graphList.map(async (graph) => {
@@ -5215,7 +5770,15 @@ var getFullProject = (db, logger11 = defaultLogger2) => async (params) => {
5215
5770
  graphId: graph.id
5216
5771
  });
5217
5772
  if (fullGraph) {
5218
- graphs[graph.id] = fullGraph;
5773
+ const {
5774
+ tools: _tools,
5775
+ dataComponents: _dataComponents,
5776
+ artifactComponents: _artifactComponents,
5777
+ contextConfig: _contextConfig,
5778
+ credentialReferences: _credentialReferences,
5779
+ ...graphWithoutProjectResources
5780
+ } = fullGraph;
5781
+ graphs[graph.id] = graphWithoutProjectResources;
5219
5782
  logger11.info(
5220
5783
  { tenantId, projectId, graphId: graph.id },
5221
5784
  "Full graph definition retrieved"
@@ -5239,8 +5802,11 @@ var getFullProject = (db, logger11 = defaultLogger2) => async (params) => {
5239
5802
  models: project.models || void 0,
5240
5803
  stopWhen: project.stopWhen || void 0,
5241
5804
  graphs,
5242
- tools: {},
5243
- // TODO: Implement proper tools retrieval
5805
+ tools: projectTools,
5806
+ dataComponents: projectDataComponents,
5807
+ artifactComponents: projectArtifactComponents,
5808
+ contextConfig: projectContextConfigs,
5809
+ credentialReferences: projectCredentialReferences,
5244
5810
  createdAt: project.createdAt,
5245
5811
  updatedAt: project.updatedAt
5246
5812
  };
@@ -7742,11 +8308,11 @@ var NangoCredentialStore = class {
7742
8308
  switch (type) {
7743
8309
  case "API_KEY":
7744
8310
  return {
7745
- token: credentials.apiKey
8311
+ token: credentials.apiKey || credentials.api_key
7746
8312
  };
7747
8313
  case "APP":
7748
8314
  return {
7749
- token: credentials.access_token
8315
+ token: credentials.accessToken || credentials.access_token
7750
8316
  };
7751
8317
  case "BASIC":
7752
8318
  return {