@inkeep/agents-core 0.24.2 → 0.25.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.
package/dist/index.js CHANGED
@@ -1,20 +1,20 @@
1
1
  import { detectAuthenticationRequired } from './chunk-NJZ3ICNP.js';
2
2
  export { ACTIVITY_NAMES, ACTIVITY_STATUS, ACTIVITY_TYPES, AGENT_IDS, AGGREGATE_OPERATORS, AI_OPERATIONS, AI_TOOL_TYPES, DATA_SOURCES, DATA_TYPES, DELEGATION_FROM_SUB_AGENT_ID, DELEGATION_ID, DELEGATION_TO_SUB_AGENT_ID, FIELD_TYPES, OPERATORS, ORDER_DIRECTIONS, PANEL_TYPES, QUERY_DEFAULTS, QUERY_EXPRESSIONS, QUERY_FIELD_CONFIGS, QUERY_TYPES, REDUCE_OPERATIONS, SPAN_KEYS, SPAN_NAMES, TRANSFER_FROM_SUB_AGENT_ID, TRANSFER_TO_SUB_AGENT_ID, UNKNOWN_VALUE, detectAuthenticationRequired, exchangeMcpAuthorizationCode, initiateMcpOAuthFlow } from './chunk-NJZ3ICNP.js';
3
3
  export { ANTHROPIC_MODELS, GOOGLE_MODELS, OPENAI_MODELS } from './chunk-MQTANAMG.js';
4
+ export { TaskState } from './chunk-H2F72PDA.js';
4
5
  import { getLogger, convertZodToJsonSchema } from './chunk-YECQCT5N.js';
5
6
  export { PinoLogger, convertZodToJsonSchema, convertZodToJsonSchemaWithPreview, extractPreviewFields, getLogger, isZodSchema, loggerFactory, preview } from './chunk-YECQCT5N.js';
6
- import { validatePreview, validateAndTypeAgentData, validateAgentStructure, isInternalAgent, isExternalAgent } from './chunk-ZGJI6UNK.js';
7
- export { A2AMessageMetadataSchema, DataOperationDetailsSchema, DataOperationEventSchema, DelegationReturnedDataSchema, DelegationSentDataSchema, TransferDataSchema, generateIdFromName, isExternalAgent, isInternalAgent, isValidResourceId, validateAgentRelationships, validateAgentStructure, validateAndTypeAgentData, validateArtifactComponentReferences, validateDataComponentReferences, validatePreview, validateToolReferences } from './chunk-ZGJI6UNK.js';
8
- import { ContextConfigApiUpdateSchema, validatePropsAsJsonSchema } from './chunk-HN77JIDP.js';
9
- export { AgentApiInsertSchema, AgentApiSelectSchema, AgentApiUpdateSchema, AgentInsertSchema, AgentListResponse, AgentResponse, AgentSelectSchema, AgentStopWhenSchema, AgentUpdateSchema, AgentWithinContextOfProjectSchema, AllAgentSchema, ApiKeyApiCreationResponseSchema, ApiKeyApiInsertSchema, ApiKeyApiSelectSchema, ApiKeyApiUpdateSchema, ApiKeyInsertSchema, ApiKeyListResponse, ApiKeyResponse, ApiKeySelectSchema, ApiKeyUpdateSchema, ArtifactComponentApiInsertSchema, ArtifactComponentApiSelectSchema, ArtifactComponentApiUpdateSchema, ArtifactComponentInsertSchema, ArtifactComponentListResponse, ArtifactComponentResponse, ArtifactComponentSelectSchema, ArtifactComponentUpdateSchema, CanUseItemSchema, ContextCacheApiInsertSchema, ContextCacheApiSelectSchema, ContextCacheApiUpdateSchema, ContextCacheInsertSchema, ContextCacheSelectSchema, ContextCacheUpdateSchema, ContextConfigApiInsertSchema, ContextConfigApiSelectSchema, ContextConfigApiUpdateSchema, ContextConfigInsertSchema, ContextConfigListResponse, ContextConfigResponse, ContextConfigSelectSchema, ContextConfigUpdateSchema, ConversationApiInsertSchema, ConversationApiSelectSchema, ConversationApiUpdateSchema, ConversationInsertSchema, ConversationListResponse, ConversationResponse, ConversationSelectSchema, ConversationUpdateSchema, CredentialReferenceApiInsertSchema, CredentialReferenceApiSelectSchema, CredentialReferenceApiUpdateSchema, CredentialReferenceInsertSchema, CredentialReferenceListResponse, CredentialReferenceResponse, CredentialReferenceSelectSchema, CredentialReferenceUpdateSchema, DataComponentApiInsertSchema, DataComponentApiSelectSchema, DataComponentApiUpdateSchema, DataComponentBaseSchema, DataComponentInsertSchema, DataComponentListResponse, DataComponentResponse, DataComponentSelectSchema, DataComponentUpdateSchema, ErrorResponseSchema, ExistsResponseSchema, ExternalAgentApiInsertSchema, ExternalAgentApiSelectSchema, ExternalAgentApiUpdateSchema, ExternalAgentInsertSchema, ExternalAgentListResponse, ExternalAgentResponse, ExternalAgentSelectSchema, ExternalAgentUpdateSchema, ExternalSubAgentRelationApiInsertSchema, ExternalSubAgentRelationInsertSchema, FetchConfigSchema, FetchDefinitionSchema, FullAgentAgentInsertSchema, FullProjectDefinitionSchema, FunctionApiInsertSchema, FunctionApiSelectSchema, FunctionApiUpdateSchema, FunctionInsertSchema, FunctionListResponse, FunctionResponse, FunctionSelectSchema, FunctionToolApiInsertSchema, FunctionToolApiSelectSchema, FunctionToolApiUpdateSchema, FunctionToolConfigSchema, FunctionToolInsertSchema, FunctionToolListResponse, FunctionToolResponse, FunctionToolSelectSchema, FunctionToolUpdateSchema, FunctionUpdateSchema, HeadersScopeSchema, LedgerArtifactApiInsertSchema, LedgerArtifactApiSelectSchema, LedgerArtifactApiUpdateSchema, LedgerArtifactInsertSchema, LedgerArtifactSelectSchema, LedgerArtifactUpdateSchema, ListResponseSchema, MAX_ID_LENGTH, MCPToolConfigSchema, MIN_ID_LENGTH, McpToolDefinitionSchema, McpToolSchema, McpTransportConfigSchema, MessageApiInsertSchema, MessageApiSelectSchema, MessageApiUpdateSchema, MessageInsertSchema, MessageListResponse, MessageResponse, MessageSelectSchema, MessageUpdateSchema, ModelSchema, ModelSettingsSchema, PaginationQueryParamsSchema, PaginationSchema, ProjectApiInsertSchema, ProjectApiSelectSchema, ProjectApiUpdateSchema, ProjectInsertSchema, ProjectListResponse, ProjectModelSchema, ProjectResponse, ProjectSelectSchema, ProjectUpdateSchema, RemovedResponseSchema, SingleResponseSchema, StatusComponentSchema, StatusUpdateSchema, StopWhenSchema, SubAgentApiInsertSchema, SubAgentApiSelectSchema, SubAgentApiUpdateSchema, SubAgentArtifactComponentApiInsertSchema, SubAgentArtifactComponentApiSelectSchema, SubAgentArtifactComponentApiUpdateSchema, SubAgentArtifactComponentInsertSchema, SubAgentArtifactComponentListResponse, SubAgentArtifactComponentResponse, SubAgentArtifactComponentSelectSchema, SubAgentArtifactComponentUpdateSchema, SubAgentDataComponentApiInsertSchema, SubAgentDataComponentApiSelectSchema, SubAgentDataComponentApiUpdateSchema, SubAgentDataComponentInsertSchema, SubAgentDataComponentListResponse, SubAgentDataComponentResponse, SubAgentDataComponentSelectSchema, SubAgentDataComponentUpdateSchema, SubAgentInsertSchema, SubAgentListResponse, SubAgentRelationApiInsertSchema, SubAgentRelationApiSelectSchema, SubAgentRelationApiUpdateSchema, SubAgentRelationInsertSchema, SubAgentRelationListResponse, SubAgentRelationQuerySchema, SubAgentRelationResponse, SubAgentRelationSelectSchema, SubAgentRelationUpdateSchema, SubAgentResponse, SubAgentSelectSchema, SubAgentStopWhenSchema, SubAgentToolRelationApiInsertSchema, SubAgentToolRelationApiSelectSchema, SubAgentToolRelationApiUpdateSchema, SubAgentToolRelationInsertSchema, SubAgentToolRelationListResponse, SubAgentToolRelationResponse, SubAgentToolRelationSelectSchema, SubAgentToolRelationUpdateSchema, SubAgentUpdateSchema, TaskApiInsertSchema, TaskApiSelectSchema, TaskApiUpdateSchema, TaskInsertSchema, TaskRelationApiInsertSchema, TaskRelationApiSelectSchema, TaskRelationApiUpdateSchema, TaskRelationInsertSchema, TaskRelationSelectSchema, TaskRelationUpdateSchema, TaskSelectSchema, TaskUpdateSchema, TenantIdParamsSchema, TenantParamsSchema, TenantProjectAgentIdParamsSchema, TenantProjectAgentParamsSchema, TenantProjectAgentSubAgentIdParamsSchema, TenantProjectAgentSubAgentParamsSchema, TenantProjectIdParamsSchema, TenantProjectParamsSchema, ToolApiInsertSchema, ToolApiSelectSchema, ToolApiUpdateSchema, ToolInsertSchema, ToolListResponse, ToolResponse, ToolSelectSchema, ToolStatusSchema, ToolUpdateSchema, URL_SAFE_ID_PATTERN, resourceIdSchema, validatePropsAsJsonSchema } from './chunk-HN77JIDP.js';
10
- import { schema_exports, contextConfigs, externalAgents, functions, functionTools, subAgentFunctionToolRelations, subAgentRelations, subAgents, subAgentToolRelations, tools, credentialReferences, agents, subAgentDataComponents, subAgentArtifactComponents, dataComponents, artifactComponents, projects, apiKeys, contextCache, conversations, messages, ledgerArtifacts, tasks, taskRelations } from './chunk-5B6IOJZY.js';
11
- export { agentRelations, agentToolRelationsRelations, agents, apiKeys, apiKeysRelations, artifactComponents, artifactComponentsRelations, contextCache, contextCacheRelations, contextConfigs, contextConfigsRelations, conversations, conversationsRelations, credentialReferences, credentialReferencesRelations, dataComponents, dataComponentsRelations, externalAgents, externalAgentsRelations, functionTools, functionToolsRelations, functions, functionsRelations, ledgerArtifacts, ledgerArtifactsRelations, messages, messagesRelations, projects, projectsRelations, subAgentArtifactComponents, subAgentArtifactComponentsRelations, subAgentDataComponents, subAgentDataComponentsRelations, subAgentFunctionToolRelations, subAgentFunctionToolRelationsRelations, subAgentRelations, subAgentRelationsRelations, subAgentToolRelations, subAgents, subAgentsRelations, taskRelations, taskRelationsRelations, tasks, tasksRelations, tools, toolsRelations } from './chunk-5B6IOJZY.js';
12
- export { TaskState } from './chunk-H2F72PDA.js';
7
+ import { validatePreview, validateAndTypeAgentData, validateAgentStructure } from './chunk-HMVAAUTK.js';
8
+ export { A2AMessageMetadataSchema, DataOperationDetailsSchema, DataOperationEventSchema, DelegationReturnedDataSchema, DelegationSentDataSchema, TransferDataSchema, generateIdFromName, isValidResourceId, validateAgentRelationships, validateAgentStructure, validateAndTypeAgentData, validateArtifactComponentReferences, validateDataComponentReferences, validatePreview, validateSubAgentExternalAgentRelations, validateToolReferences } from './chunk-HMVAAUTK.js';
9
+ import { ContextConfigApiUpdateSchema, validatePropsAsJsonSchema } from './chunk-NXC2HZQL.js';
10
+ export { AgentApiInsertSchema, AgentApiSelectSchema, AgentApiUpdateSchema, AgentInsertSchema, AgentListResponse, AgentResponse, AgentSelectSchema, AgentStopWhenSchema, AgentUpdateSchema, AgentWithinContextOfProjectSchema, AllAgentSchema, ApiKeyApiCreationResponseSchema, ApiKeyApiInsertSchema, ApiKeyApiSelectSchema, ApiKeyApiUpdateSchema, ApiKeyInsertSchema, ApiKeyListResponse, ApiKeyResponse, ApiKeySelectSchema, ApiKeyUpdateSchema, ArtifactComponentApiInsertSchema, ArtifactComponentApiSelectSchema, ArtifactComponentApiUpdateSchema, ArtifactComponentInsertSchema, ArtifactComponentListResponse, ArtifactComponentResponse, ArtifactComponentSelectSchema, ArtifactComponentUpdateSchema, CanUseItemSchema, ContextCacheApiInsertSchema, ContextCacheApiSelectSchema, ContextCacheApiUpdateSchema, ContextCacheInsertSchema, ContextCacheSelectSchema, ContextCacheUpdateSchema, ContextConfigApiInsertSchema, ContextConfigApiSelectSchema, ContextConfigApiUpdateSchema, ContextConfigInsertSchema, ContextConfigListResponse, ContextConfigResponse, ContextConfigSelectSchema, ContextConfigUpdateSchema, ConversationApiInsertSchema, ConversationApiSelectSchema, ConversationApiUpdateSchema, ConversationInsertSchema, ConversationListResponse, ConversationResponse, ConversationSelectSchema, ConversationUpdateSchema, CredentialReferenceApiInsertSchema, CredentialReferenceApiSelectSchema, CredentialReferenceApiUpdateSchema, CredentialReferenceInsertSchema, CredentialReferenceListResponse, CredentialReferenceResponse, CredentialReferenceSelectSchema, CredentialReferenceUpdateSchema, DataComponentApiInsertSchema, DataComponentApiSelectSchema, DataComponentApiUpdateSchema, DataComponentBaseSchema, DataComponentInsertSchema, DataComponentListResponse, DataComponentResponse, DataComponentSelectSchema, DataComponentUpdateSchema, ErrorResponseSchema, ExistsResponseSchema, ExternalAgentApiInsertSchema, ExternalAgentApiSelectSchema, ExternalAgentApiUpdateSchema, ExternalAgentInsertSchema, ExternalAgentListResponse, ExternalAgentResponse, ExternalAgentSelectSchema, ExternalAgentUpdateSchema, ExternalSubAgentRelationApiInsertSchema, ExternalSubAgentRelationInsertSchema, FetchConfigSchema, FetchDefinitionSchema, FullAgentAgentInsertSchema, FullProjectDefinitionSchema, FunctionApiInsertSchema, FunctionApiSelectSchema, FunctionApiUpdateSchema, FunctionInsertSchema, FunctionListResponse, FunctionResponse, FunctionSelectSchema, FunctionToolApiInsertSchema, FunctionToolApiSelectSchema, FunctionToolApiUpdateSchema, FunctionToolConfigSchema, FunctionToolInsertSchema, FunctionToolListResponse, FunctionToolResponse, FunctionToolSelectSchema, FunctionToolUpdateSchema, FunctionUpdateSchema, HeadersScopeSchema, LedgerArtifactApiInsertSchema, LedgerArtifactApiSelectSchema, LedgerArtifactApiUpdateSchema, LedgerArtifactInsertSchema, LedgerArtifactSelectSchema, LedgerArtifactUpdateSchema, ListResponseSchema, MAX_ID_LENGTH, MCPToolConfigSchema, MIN_ID_LENGTH, McpToolDefinitionSchema, McpToolSchema, McpTransportConfigSchema, MessageApiInsertSchema, MessageApiSelectSchema, MessageApiUpdateSchema, MessageInsertSchema, MessageListResponse, MessageResponse, MessageSelectSchema, MessageUpdateSchema, ModelSchema, ModelSettingsSchema, PaginationQueryParamsSchema, PaginationSchema, ProjectApiInsertSchema, ProjectApiSelectSchema, ProjectApiUpdateSchema, ProjectInsertSchema, ProjectListResponse, ProjectModelSchema, ProjectResponse, ProjectSelectSchema, ProjectUpdateSchema, RemovedResponseSchema, SingleResponseSchema, StatusComponentSchema, StatusUpdateSchema, StopWhenSchema, SubAgentApiInsertSchema, SubAgentApiSelectSchema, SubAgentApiUpdateSchema, SubAgentArtifactComponentApiInsertSchema, SubAgentArtifactComponentApiSelectSchema, SubAgentArtifactComponentApiUpdateSchema, SubAgentArtifactComponentInsertSchema, SubAgentArtifactComponentListResponse, SubAgentArtifactComponentResponse, SubAgentArtifactComponentSelectSchema, SubAgentArtifactComponentUpdateSchema, SubAgentDataComponentApiInsertSchema, SubAgentDataComponentApiSelectSchema, SubAgentDataComponentApiUpdateSchema, SubAgentDataComponentInsertSchema, SubAgentDataComponentListResponse, SubAgentDataComponentResponse, SubAgentDataComponentSelectSchema, SubAgentDataComponentUpdateSchema, SubAgentExternalAgentRelationApiInsertSchema, SubAgentExternalAgentRelationApiSelectSchema, SubAgentExternalAgentRelationApiUpdateSchema, SubAgentExternalAgentRelationInsertSchema, SubAgentExternalAgentRelationSelectSchema, SubAgentExternalAgentRelationUpdateSchema, SubAgentInsertSchema, SubAgentListResponse, SubAgentRelationApiInsertSchema, SubAgentRelationApiSelectSchema, SubAgentRelationApiUpdateSchema, SubAgentRelationInsertSchema, SubAgentRelationListResponse, SubAgentRelationQuerySchema, SubAgentRelationResponse, SubAgentRelationSelectSchema, SubAgentRelationUpdateSchema, SubAgentResponse, SubAgentSelectSchema, SubAgentStopWhenSchema, SubAgentToolRelationApiInsertSchema, SubAgentToolRelationApiSelectSchema, SubAgentToolRelationApiUpdateSchema, SubAgentToolRelationInsertSchema, SubAgentToolRelationListResponse, SubAgentToolRelationResponse, SubAgentToolRelationSelectSchema, SubAgentToolRelationUpdateSchema, SubAgentUpdateSchema, TaskApiInsertSchema, TaskApiSelectSchema, TaskApiUpdateSchema, TaskInsertSchema, TaskRelationApiInsertSchema, TaskRelationApiSelectSchema, TaskRelationApiUpdateSchema, TaskRelationInsertSchema, TaskRelationSelectSchema, TaskRelationUpdateSchema, TaskSelectSchema, TaskUpdateSchema, TenantIdParamsSchema, TenantParamsSchema, TenantProjectAgentIdParamsSchema, TenantProjectAgentParamsSchema, TenantProjectAgentSubAgentIdParamsSchema, TenantProjectAgentSubAgentParamsSchema, TenantProjectIdParamsSchema, TenantProjectParamsSchema, ToolApiInsertSchema, ToolApiSelectSchema, ToolApiUpdateSchema, ToolInsertSchema, ToolListResponse, ToolResponse, ToolSelectSchema, ToolStatusSchema, ToolUpdateSchema, URL_SAFE_ID_PATTERN, canDelegateToExternalAgentSchema, resourceIdSchema, validatePropsAsJsonSchema } from './chunk-NXC2HZQL.js';
11
+ import { schema_exports, contextConfigs, externalAgents, functions, functionTools, subAgentFunctionToolRelations, subAgentExternalAgentRelations, subAgents, subAgentRelations, subAgentToolRelations, tools, credentialReferences, agents, subAgentDataComponents, subAgentArtifactComponents, dataComponents, artifactComponents, projects, apiKeys, contextCache, conversations, messages, ledgerArtifacts, tasks, taskRelations } from './chunk-ALZI4IXB.js';
12
+ export { agentRelations, agentToolRelationsRelations, agents, apiKeys, apiKeysRelations, artifactComponents, artifactComponentsRelations, contextCache, contextCacheRelations, contextConfigs, contextConfigsRelations, conversations, conversationsRelations, credentialReferences, credentialReferencesRelations, dataComponents, dataComponentsRelations, externalAgents, externalAgentsRelations, functionTools, functionToolsRelations, functions, functionsRelations, ledgerArtifacts, ledgerArtifactsRelations, messages, messagesRelations, projects, projectsRelations, subAgentArtifactComponents, subAgentArtifactComponentsRelations, subAgentDataComponents, subAgentDataComponentsRelations, subAgentExternalAgentRelations, subAgentExternalAgentRelationsRelations, subAgentFunctionToolRelations, subAgentFunctionToolRelationsRelations, subAgentRelations, subAgentRelationsRelations, subAgentToolRelations, subAgents, subAgentsRelations, taskRelations, taskRelationsRelations, tasks, tasksRelations, tools, toolsRelations } from './chunk-ALZI4IXB.js';
13
13
  import { CredentialStoreType, MCPServerType, MCPTransportType } from './chunk-YFHT5M2R.js';
14
14
  export { CredentialStoreType, MCPServerType, MCPTransportType, TOOL_STATUS_VALUES, VALID_RELATION_TYPES } from './chunk-YFHT5M2R.js';
15
15
  import { __commonJS, __require, __publicField } from './chunk-E6R6PML7.js';
16
16
  import { z as z$1 } from 'zod';
17
- import { customAlphabet } from 'nanoid';
17
+ import { customAlphabet, nanoid } from 'nanoid';
18
18
  import jmespath from 'jmespath';
19
19
  import { createClient } from '@libsql/client';
20
20
  import { drizzle } from 'drizzle-orm/libsql';
@@ -2497,7 +2497,7 @@ var require_typescript = __commonJS({
2497
2497
  affectsEmitOptionDeclarations: () => affectsEmitOptionDeclarations,
2498
2498
  allKeysStartWithDot: () => allKeysStartWithDot,
2499
2499
  altDirectorySeparator: () => altDirectorySeparator,
2500
- and: () => and20,
2500
+ and: () => and21,
2501
2501
  append: () => append,
2502
2502
  appendIfUnique: () => appendIfUnique,
2503
2503
  arrayFrom: () => arrayFrom,
@@ -4719,16 +4719,16 @@ var require_typescript = __commonJS({
4719
4719
  return -1;
4720
4720
  }
4721
4721
  function countWhere(array, predicate) {
4722
- let count16 = 0;
4722
+ let count17 = 0;
4723
4723
  if (array !== void 0) {
4724
4724
  for (let i = 0; i < array.length; i++) {
4725
4725
  const v = array[i];
4726
4726
  if (predicate(v, i)) {
4727
- count16++;
4727
+ count17++;
4728
4728
  }
4729
4729
  }
4730
4730
  }
4731
- return count16;
4731
+ return count17;
4732
4732
  }
4733
4733
  function filter(array, f) {
4734
4734
  if (array !== void 0) {
@@ -5281,12 +5281,12 @@ var require_typescript = __commonJS({
5281
5281
  }
5282
5282
  return ~low;
5283
5283
  }
5284
- function reduceLeft(array, f, initial, start, count16) {
5284
+ function reduceLeft(array, f, initial, start, count17) {
5285
5285
  if (array && array.length > 0) {
5286
5286
  const size = array.length;
5287
5287
  if (size > 0) {
5288
5288
  let pos = start === void 0 || start < 0 ? 0 : start;
5289
- const end = count16 === void 0 || pos + count16 > size - 1 ? size - 1 : pos + count16;
5289
+ const end = count17 === void 0 || pos + count17 > size - 1 ? size - 1 : pos + count17;
5290
5290
  let result;
5291
5291
  if (arguments.length <= 2) {
5292
5292
  result = array[pos];
@@ -5338,9 +5338,9 @@ var require_typescript = __commonJS({
5338
5338
  }
5339
5339
  return values;
5340
5340
  }
5341
- function arrayOf(count16, f) {
5342
- const result = new Array(count16);
5343
- for (let i = 0; i < count16; i++) {
5341
+ function arrayOf(count17, f) {
5342
+ const result = new Array(count17);
5343
+ for (let i = 0; i < count17; i++) {
5344
5344
  result[i] = f(i);
5345
5345
  }
5346
5346
  return result;
@@ -5948,7 +5948,7 @@ var require_typescript = __commonJS({
5948
5948
  function isPatternMatch({ prefix, suffix }, candidate) {
5949
5949
  return candidate.length >= prefix.length + suffix.length && startsWith(candidate, prefix) && endsWith(candidate, suffix);
5950
5950
  }
5951
- function and20(f, g) {
5951
+ function and21(f, g) {
5952
5952
  return (arg) => f(arg) && g(arg);
5953
5953
  }
5954
5954
  function or(...fs2) {
@@ -7452,8 +7452,8 @@ ${lanes.join("\n")}
7452
7452
  var durations = /* @__PURE__ */ new Map();
7453
7453
  function mark(markName) {
7454
7454
  if (enabled) {
7455
- const count16 = counts.get(markName) ?? 0;
7456
- counts.set(markName, count16 + 1);
7455
+ const count17 = counts.get(markName) ?? 0;
7456
+ counts.set(markName, count17 + 1);
7457
7457
  marks.set(markName, timestamp());
7458
7458
  performanceImpl == null ? void 0 : performanceImpl.mark(markName);
7459
7459
  if (typeof onProfilerEvent === "function") {
@@ -14963,20 +14963,20 @@ ${lanes.join("\n")}
14963
14963
  tokenValue = text.substring(start2, pos);
14964
14964
  return isOctal;
14965
14965
  }
14966
- function scanExactNumberOfHexDigits(count16, canHaveSeparators) {
14966
+ function scanExactNumberOfHexDigits(count17, canHaveSeparators) {
14967
14967
  const valueString = scanHexDigits(
14968
14968
  /*minCount*/
14969
- count16,
14969
+ count17,
14970
14970
  /*scanAsManyAsPossible*/
14971
14971
  false,
14972
14972
  canHaveSeparators
14973
14973
  );
14974
14974
  return valueString ? parseInt(valueString, 16) : -1;
14975
14975
  }
14976
- function scanMinimumNumberOfHexDigits(count16, canHaveSeparators) {
14976
+ function scanMinimumNumberOfHexDigits(count17, canHaveSeparators) {
14977
14977
  return scanHexDigits(
14978
14978
  /*minCount*/
14979
- count16,
14979
+ count17,
14980
14980
  /*scanAsManyAsPossible*/
14981
14981
  true,
14982
14982
  canHaveSeparators
@@ -33793,13 +33793,13 @@ ${lanes.join("\n")}
33793
33793
  [expression]
33794
33794
  );
33795
33795
  }
33796
- function createReadHelper(iteratorRecord, count16) {
33796
+ function createReadHelper(iteratorRecord, count17) {
33797
33797
  context.requestEmitHelper(readHelper);
33798
33798
  return factory2.createCallExpression(
33799
33799
  getUnscopedHelperName("__read"),
33800
33800
  /*typeArguments*/
33801
33801
  void 0,
33802
- count16 !== void 0 ? [iteratorRecord, factory2.createNumericLiteral(count16 + "")] : [iteratorRecord]
33802
+ count17 !== void 0 ? [iteratorRecord, factory2.createNumericLiteral(count17 + "")] : [iteratorRecord]
33803
33803
  );
33804
33804
  }
33805
33805
  function createGeneratorHelper(body) {
@@ -56106,11 +56106,11 @@ ${lanes.join("\n")}
56106
56106
  return comparePaths(a, b, ignoreCase) === 0;
56107
56107
  }
56108
56108
  function countPathComponents(path2) {
56109
- let count16 = 0;
56109
+ let count17 = 0;
56110
56110
  for (let i = startsWith(path2, "./") ? 2 : 0; i < path2.length; i++) {
56111
- if (path2.charCodeAt(i) === 47) count16++;
56111
+ if (path2.charCodeAt(i) === 47) count17++;
56112
56112
  }
56113
- return count16;
56113
+ return count17;
56114
56114
  }
56115
56115
  function comparePathsByRedirectAndNumberOfDirectorySeparators(a, b) {
56116
56116
  return compareBooleans(b.isRedirect, a.isRedirect) || compareNumberOfDirectorySeparators(a.path, b.path);
@@ -56943,7 +56943,7 @@ ${lanes.join("\n")}
56943
56943
  SignatureCheckMode3[SignatureCheckMode3["Callback"] = 3] = "Callback";
56944
56944
  return SignatureCheckMode3;
56945
56945
  })(SignatureCheckMode || {});
56946
- var isNotOverloadAndNotAccessor = and20(isNotOverload, isNotAccessor);
56946
+ var isNotOverloadAndNotAccessor = and21(isNotOverload, isNotAccessor);
56947
56947
  var intrinsicTypeKinds = new Map(Object.entries({
56948
56948
  Uppercase: 0,
56949
56949
  Lowercase: 1,
@@ -62683,7 +62683,7 @@ ${lanes.join("\n")}
62683
62683
  deepCloneOrReuseNode
62684
62684
  )), node);
62685
62685
  }
62686
- function deepCloneOrReuseNodes(nodes, visitor, test, start, count16) {
62686
+ function deepCloneOrReuseNodes(nodes, visitor, test, start, count17) {
62687
62687
  if (nodes && nodes.length === 0) {
62688
62688
  return setTextRange(factory.createNodeArray(
62689
62689
  /*elements*/
@@ -62691,7 +62691,7 @@ ${lanes.join("\n")}
62691
62691
  nodes.hasTrailingComma
62692
62692
  ), nodes);
62693
62693
  }
62694
- return visitNodes2(nodes, visitor, test, start, count16);
62694
+ return visitNodes2(nodes, visitor, test, start, count17);
62695
62695
  }
62696
62696
  }
62697
62697
  function createTypeNodeFromObjectType(type2) {
@@ -66647,10 +66647,10 @@ ${lanes.join("\n")}
66647
66647
  if (t.flags & 512 || !expandingEnum && t.flags | 1056) {
66648
66648
  const baseType = t.flags & 512 ? booleanType : getBaseTypeOfEnumLikeType(t);
66649
66649
  if (baseType.flags & 1048576) {
66650
- const count16 = baseType.types.length;
66651
- if (i + count16 <= types.length && getRegularTypeOfLiteralType(types[i + count16 - 1]) === getRegularTypeOfLiteralType(baseType.types[count16 - 1])) {
66650
+ const count17 = baseType.types.length;
66651
+ if (i + count17 <= types.length && getRegularTypeOfLiteralType(types[i + count17 - 1]) === getRegularTypeOfLiteralType(baseType.types[count17 - 1])) {
66652
66652
  result.push(baseType);
66653
- i += count16 - 1;
66653
+ i += count17 - 1;
66654
66654
  continue;
66655
66655
  }
66656
66656
  }
@@ -71616,18 +71616,18 @@ ${lanes.join("\n")}
71616
71616
  let i = 0;
71617
71617
  while (i < length2) {
71618
71618
  const startId = types[i].id;
71619
- let count16 = 1;
71620
- while (i + count16 < length2 && types[i + count16].id === startId + count16) {
71621
- count16++;
71619
+ let count17 = 1;
71620
+ while (i + count17 < length2 && types[i + count17].id === startId + count17) {
71621
+ count17++;
71622
71622
  }
71623
71623
  if (result.length) {
71624
71624
  result += ",";
71625
71625
  }
71626
71626
  result += startId;
71627
- if (count16 > 1) {
71628
- result += ":" + count16;
71627
+ if (count17 > 1) {
71628
+ result += ":" + count17;
71629
71629
  }
71630
- i += count16;
71630
+ i += count17;
71631
71631
  }
71632
71632
  }
71633
71633
  return result;
@@ -72907,7 +72907,7 @@ ${lanes.join("\n")}
72907
72907
  const hasEmptyObject = hasObjectTypes && some(types, (t) => !!(t.flags & 524288) && !isGenericMappedType(t) && isEmptyResolvedType(resolveStructuredTypeMembers(t)));
72908
72908
  const len = types.length;
72909
72909
  let i = len;
72910
- let count16 = 0;
72910
+ let count17 = 0;
72911
72911
  while (i > 0) {
72912
72912
  i--;
72913
72913
  const source = types[i];
@@ -72922,15 +72922,15 @@ ${lanes.join("\n")}
72922
72922
  const keyPropertyType = keyProperty && getRegularTypeOfLiteralType(getTypeOfSymbol(keyProperty));
72923
72923
  for (const target of types) {
72924
72924
  if (source !== target) {
72925
- if (count16 === 1e5) {
72926
- const estimatedCount = count16 / (len - i) * len;
72925
+ if (count17 === 1e5) {
72926
+ const estimatedCount = count17 / (len - i) * len;
72927
72927
  if (estimatedCount > 1e6) {
72928
72928
  (_a = tracing) == null ? void 0 : _a.instant(tracing.Phase.CheckTypes, "removeSubtypes_DepthLimit", { typeIds: types.map((t) => t.id) });
72929
72929
  error2(currentNode, Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent);
72930
72930
  return void 0;
72931
72931
  }
72932
72932
  }
72933
- count16++;
72933
+ count17++;
72934
72934
  if (keyProperty && target.flags & (524288 | 2097152 | 58982400)) {
72935
72935
  const t = getTypeOfPropertyOfType(target, keyProperty.escapedName);
72936
72936
  if (t && isUnitType(t) && getRegularTypeOfLiteralType(t) !== keyPropertyType) {
@@ -73431,9 +73431,9 @@ ${lanes.join("\n")}
73431
73431
  return true;
73432
73432
  }
73433
73433
  function getCrossProductIntersections(types, flags) {
73434
- const count16 = getCrossProductUnionSize(types);
73434
+ const count17 = getCrossProductUnionSize(types);
73435
73435
  const intersections = [];
73436
- for (let i = 0; i < count16; i++) {
73436
+ for (let i = 0; i < count17; i++) {
73437
73437
  const constituents = types.slice();
73438
73438
  let n = i;
73439
73439
  for (let j = types.length - 1; j >= 0; j--) {
@@ -79295,14 +79295,14 @@ ${lanes.join("\n")}
79295
79295
  return some(type.types, (t) => isDeeplyNestedType(t, stack, depth, maxDepth));
79296
79296
  }
79297
79297
  const identity2 = getRecursionIdentity(type);
79298
- let count16 = 0;
79298
+ let count17 = 0;
79299
79299
  let lastTypeId = 0;
79300
79300
  for (let i = 0; i < depth; i++) {
79301
79301
  const t = stack[i];
79302
79302
  if (hasMatchingRecursionIdentity(t, identity2)) {
79303
79303
  if (t.id >= lastTypeId) {
79304
- count16++;
79305
- if (count16 >= maxDepth) {
79304
+ count17++;
79305
+ if (count17 >= maxDepth) {
79306
79306
  return true;
79307
79307
  }
79308
79308
  }
@@ -80762,8 +80762,8 @@ ${lanes.join("\n")}
80762
80762
  ];
80763
80763
  }
80764
80764
  function inferFromTypeArguments(sourceTypes, targetTypes, variances) {
80765
- const count16 = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length;
80766
- for (let i = 0; i < count16; i++) {
80765
+ const count17 = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length;
80766
+ for (let i = 0; i < count17; i++) {
80767
80767
  if (i < variances.length && (variances[i] & 7) === 2) {
80768
80768
  inferFromContravariantTypes(sourceTypes[i], targetTypes[i]);
80769
80769
  } else {
@@ -81507,7 +81507,7 @@ ${lanes.join("\n")}
81507
81507
  }
81508
81508
  function mapTypesByKeyProperty(types, name) {
81509
81509
  const map2 = /* @__PURE__ */ new Map();
81510
- let count16 = 0;
81510
+ let count17 = 0;
81511
81511
  for (const type of types) {
81512
81512
  if (type.flags & (524288 | 2097152 | 58982400)) {
81513
81513
  const discriminant = getTypeOfPropertyOfType(type, name);
@@ -81526,11 +81526,11 @@ ${lanes.join("\n")}
81526
81526
  duplicate = true;
81527
81527
  }
81528
81528
  });
81529
- if (!duplicate) count16++;
81529
+ if (!duplicate) count17++;
81530
81530
  }
81531
81531
  }
81532
81532
  }
81533
- return count16 >= 10 && count16 * 2 >= types.length ? map2 : void 0;
81533
+ return count17 >= 10 && count17 * 2 >= types.length ? map2 : void 0;
81534
81534
  }
81535
81535
  function getKeyPropertyName(unionType) {
81536
81536
  const types = unionType.types;
@@ -99754,7 +99754,7 @@ ${lanes.join("\n")}
99754
99754
  if (flags & (1920 | 384)) {
99755
99755
  return;
99756
99756
  }
99757
- const exportedDeclarationsCount = countWhere(declarations, and20(isNotOverloadAndNotAccessor, not2(isInterfaceDeclaration)));
99757
+ const exportedDeclarationsCount = countWhere(declarations, and21(isNotOverloadAndNotAccessor, not2(isInterfaceDeclaration)));
99758
99758
  if (flags & 524288 && exportedDeclarationsCount <= 2) {
99759
99759
  return;
99760
99760
  }
@@ -104142,7 +104142,7 @@ ${lanes.join("\n")}
104142
104142
  Debug.assertNode(visitedNode, test);
104143
104143
  return visitedNode;
104144
104144
  }
104145
- function visitNodes2(nodes, visitor, test, start, count16) {
104145
+ function visitNodes2(nodes, visitor, test, start, count17) {
104146
104146
  if (nodes === void 0) {
104147
104147
  return nodes;
104148
104148
  }
@@ -104150,20 +104150,20 @@ ${lanes.join("\n")}
104150
104150
  if (start === void 0 || start < 0) {
104151
104151
  start = 0;
104152
104152
  }
104153
- if (count16 === void 0 || count16 > length2 - start) {
104154
- count16 = length2 - start;
104153
+ if (count17 === void 0 || count17 > length2 - start) {
104154
+ count17 = length2 - start;
104155
104155
  }
104156
104156
  let hasTrailingComma;
104157
104157
  let pos = -1;
104158
104158
  let end = -1;
104159
- if (start > 0 || count16 < length2) {
104160
- hasTrailingComma = nodes.hasTrailingComma && start + count16 === length2;
104159
+ if (start > 0 || count17 < length2) {
104160
+ hasTrailingComma = nodes.hasTrailingComma && start + count17 === length2;
104161
104161
  } else {
104162
104162
  pos = nodes.pos;
104163
104163
  end = nodes.end;
104164
104164
  hasTrailingComma = nodes.hasTrailingComma;
104165
104165
  }
104166
- const updated = visitArrayWorker(nodes, visitor, test, start, count16);
104166
+ const updated = visitArrayWorker(nodes, visitor, test, start, count17);
104167
104167
  if (updated !== nodes) {
104168
104168
  const updatedArray = factory.createNodeArray(updated, hasTrailingComma);
104169
104169
  setTextRangePosEnd(updatedArray, pos, end);
@@ -104171,7 +104171,7 @@ ${lanes.join("\n")}
104171
104171
  }
104172
104172
  return nodes;
104173
104173
  }
104174
- function visitArray(nodes, visitor, test, start, count16) {
104174
+ function visitArray(nodes, visitor, test, start, count17) {
104175
104175
  if (nodes === void 0) {
104176
104176
  return nodes;
104177
104177
  }
@@ -104179,18 +104179,18 @@ ${lanes.join("\n")}
104179
104179
  if (start === void 0 || start < 0) {
104180
104180
  start = 0;
104181
104181
  }
104182
- if (count16 === void 0 || count16 > length2 - start) {
104183
- count16 = length2 - start;
104182
+ if (count17 === void 0 || count17 > length2 - start) {
104183
+ count17 = length2 - start;
104184
104184
  }
104185
- return visitArrayWorker(nodes, visitor, test, start, count16);
104185
+ return visitArrayWorker(nodes, visitor, test, start, count17);
104186
104186
  }
104187
- function visitArrayWorker(nodes, visitor, test, start, count16) {
104187
+ function visitArrayWorker(nodes, visitor, test, start, count17) {
104188
104188
  let updated;
104189
104189
  const length2 = nodes.length;
104190
- if (start > 0 || count16 < length2) {
104190
+ if (start > 0 || count17 < length2) {
104191
104191
  updated = [];
104192
104192
  }
104193
- for (let i = 0; i < count16; i++) {
104193
+ for (let i = 0; i < count17; i++) {
104194
104194
  const node = nodes[i + start];
104195
104195
  const visited = node !== void 0 ? visitor ? visitor(node) : node : void 0;
104196
104196
  if (updated !== void 0 || visited === void 0 || visited !== node) {
@@ -135474,7 +135474,7 @@ ${lanes.join("\n")}
135474
135474
  break;
135475
135475
  }
135476
135476
  }
135477
- function emitList(parentNode, children, format, parenthesizerRule, start, count16) {
135477
+ function emitList(parentNode, children, format, parenthesizerRule, start, count17) {
135478
135478
  emitNodeList(
135479
135479
  emit,
135480
135480
  parentNode,
@@ -135482,18 +135482,18 @@ ${lanes.join("\n")}
135482
135482
  format | (parentNode && getEmitFlags(parentNode) & 2 ? 65536 : 0),
135483
135483
  parenthesizerRule,
135484
135484
  start,
135485
- count16
135485
+ count17
135486
135486
  );
135487
135487
  }
135488
- function emitExpressionList(parentNode, children, format, parenthesizerRule, start, count16) {
135489
- emitNodeList(emitExpression, parentNode, children, format, parenthesizerRule, start, count16);
135488
+ function emitExpressionList(parentNode, children, format, parenthesizerRule, start, count17) {
135489
+ emitNodeList(emitExpression, parentNode, children, format, parenthesizerRule, start, count17);
135490
135490
  }
135491
- function emitNodeList(emit2, parentNode, children, format, parenthesizerRule, start = 0, count16 = children ? children.length - start : 0) {
135491
+ function emitNodeList(emit2, parentNode, children, format, parenthesizerRule, start = 0, count17 = children ? children.length - start : 0) {
135492
135492
  const isUndefined = children === void 0;
135493
135493
  if (isUndefined && format & 16384) {
135494
135494
  return;
135495
135495
  }
135496
- const isEmpty = children === void 0 || start >= children.length || count16 === 0;
135496
+ const isEmpty = children === void 0 || start >= children.length || count17 === 0;
135497
135497
  if (isEmpty && format & 32768) {
135498
135498
  onBeforeEmitNodeArray == null ? void 0 : onBeforeEmitNodeArray(children);
135499
135499
  onAfterEmitNodeArray == null ? void 0 : onAfterEmitNodeArray(children);
@@ -135517,7 +135517,7 @@ ${lanes.join("\n")}
135517
135517
  writeSpace();
135518
135518
  }
135519
135519
  } else {
135520
- emitNodeListItems(emit2, parentNode, children, format, parenthesizerRule, start, count16, children.hasTrailingComma, children);
135520
+ emitNodeListItems(emit2, parentNode, children, format, parenthesizerRule, start, count17, children.hasTrailingComma, children);
135521
135521
  }
135522
135522
  onAfterEmitNodeArray == null ? void 0 : onAfterEmitNodeArray(children);
135523
135523
  if (format & 15360) {
@@ -135527,7 +135527,7 @@ ${lanes.join("\n")}
135527
135527
  writePunctuation(getClosingBracket(format));
135528
135528
  }
135529
135529
  }
135530
- function emitNodeListItems(emit2, parentNode, children, format, parenthesizerRule, start, count16, hasTrailingComma, childrenTextRange) {
135530
+ function emitNodeListItems(emit2, parentNode, children, format, parenthesizerRule, start, count17, hasTrailingComma, childrenTextRange) {
135531
135531
  const mayEmitInterveningComments = (format & 262144) === 0;
135532
135532
  let shouldEmitInterveningComments = mayEmitInterveningComments;
135533
135533
  const leadingLineTerminatorCount = getLeadingLineTerminatorCount(parentNode, children[start], format);
@@ -135543,7 +135543,7 @@ ${lanes.join("\n")}
135543
135543
  const emitListItem = getEmitListItem(emit2, parenthesizerRule);
135544
135544
  let previousSibling;
135545
135545
  let shouldDecreaseIndentAfterEmit = false;
135546
- for (let i = 0; i < count16; i++) {
135546
+ for (let i = 0; i < count17; i++) {
135547
135547
  const child = children[start + i];
135548
135548
  if (format & 32) {
135549
135549
  writeLine();
@@ -135608,7 +135608,7 @@ ${lanes.join("\n")}
135608
135608
  if (format & 128) {
135609
135609
  decreaseIndent();
135610
135610
  }
135611
- const closingLineTerminatorCount = getClosingLineTerminatorCount(parentNode, children[start + count16 - 1], format, childrenTextRange);
135611
+ const closingLineTerminatorCount = getClosingLineTerminatorCount(parentNode, children[start + count17 - 1], format, childrenTextRange);
135612
135612
  if (closingLineTerminatorCount) {
135613
135613
  writeLine(closingLineTerminatorCount);
135614
135614
  } else if (format & (2097152 | 256)) {
@@ -135658,8 +135658,8 @@ ${lanes.join("\n")}
135658
135658
  writer.write(s);
135659
135659
  }
135660
135660
  }
135661
- function writeLine(count16 = 1) {
135662
- for (let i = 0; i < count16; i++) {
135661
+ function writeLine(count17 = 1) {
135662
+ for (let i = 0; i < count17; i++) {
135663
135663
  writer.writeLine(i > 0);
135664
135664
  }
135665
135665
  }
@@ -136188,10 +136188,10 @@ ${lanes.join("\n")}
136188
136188
  }
136189
136189
  }
136190
136190
  while (true) {
136191
- const count16 = tempFlags2 & 268435455;
136191
+ const count17 = tempFlags2 & 268435455;
136192
136192
  tempFlags2++;
136193
- if (count16 !== 8 && count16 !== 13) {
136194
- const name = count16 < 26 ? "_" + String.fromCharCode(97 + count16) : "_" + (count16 - 26);
136193
+ if (count17 !== 8 && count17 !== 13) {
136194
+ const name = count17 < 26 ? "_" + String.fromCharCode(97 + count17) : "_" + (count17 - 26);
136195
136195
  const fullName = formatGeneratedName(privateName, prefix, name, suffix);
136196
136196
  if (isUniqueName(fullName, privateName)) {
136197
136197
  if (privateName) {
@@ -148258,12 +148258,12 @@ ${lanes.join("\n")}
148258
148258
  for (const line of output) {
148259
148259
  sys2.write(line);
148260
148260
  }
148261
- function example(ex, desc15) {
148261
+ function example(ex, desc16) {
148262
148262
  const examples = typeof ex === "string" ? [ex] : ex;
148263
148263
  for (const example2 of examples) {
148264
148264
  output.push(" " + colors.blue(example2) + sys2.newLine);
148265
148265
  }
148266
- output.push(" " + getDiagnosticText(desc15) + sys2.newLine + sys2.newLine);
148266
+ output.push(" " + getDiagnosticText(desc16) + sys2.newLine + sys2.newLine);
148267
148267
  }
148268
148268
  }
148269
148269
  function printAllHelp(sys2, compilerOptions, buildOptions, watchOptions) {
@@ -148915,7 +148915,7 @@ ${lanes.join("\n")}
148915
148915
  reportCountStatistic("Lines of " + key, value);
148916
148916
  }
148917
148917
  } else {
148918
- reportCountStatistic("Lines", reduceLeftIterator(lineCounts.values(), (sum, count16) => sum + count16, 0));
148918
+ reportCountStatistic("Lines", reduceLeftIterator(lineCounts.values(), (sum, count17) => sum + count17, 0));
148919
148919
  }
148920
148920
  reportCountStatistic("Identifiers", program.getIdentifierCount());
148921
148921
  reportCountStatistic("Symbols", program.getSymbolCount());
@@ -149020,11 +149020,11 @@ ${lanes.join("\n")}
149020
149020
  statistics.push(s);
149021
149021
  if (aggregate) solutionPerformance == null ? void 0 : solutionPerformance.addAggregateStatistic(s);
149022
149022
  }
149023
- function reportCountStatistic(name, count16) {
149023
+ function reportCountStatistic(name, count17) {
149024
149024
  reportStatisticalValue(
149025
149025
  {
149026
149026
  name,
149027
- value: count16,
149027
+ value: count17,
149028
149028
  type: 1
149029
149029
  /* count */
149030
149030
  },
@@ -149525,8 +149525,8 @@ ${lanes.join("\n")}
149525
149525
  nonlocalNode ? visitNodesWithoutCopyingPositions : void 0
149526
149526
  );
149527
149527
  }
149528
- function visitNodesWithoutCopyingPositions(nodes, visitor, test, start, count16) {
149529
- let result = visitNodes2(nodes, visitor, test, start, count16);
149528
+ function visitNodesWithoutCopyingPositions(nodes, visitor, test, start, count17) {
149529
+ let result = visitNodes2(nodes, visitor, test, start, count17);
149530
149530
  if (result) {
149531
149531
  if (result.pos !== -1 || result.end !== -1) {
149532
149532
  if (result === nodes) {
@@ -152419,9 +152419,9 @@ ${lanes.join("\n")}
152419
152419
  function getSnapshotText(snap) {
152420
152420
  return snap.getText(0, snap.getLength());
152421
152421
  }
152422
- function repeatString(str, count16) {
152422
+ function repeatString(str, count17) {
152423
152423
  let result = "";
152424
- for (let i = 0; i < count16; i++) {
152424
+ for (let i = 0; i < count17; i++) {
152425
152425
  result += str;
152426
152426
  }
152427
152427
  return result;
@@ -170542,7 +170542,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
170542
170542
  const maybeHeritageClauseSymbol = getHeritageClauseSymbolTable(classDeclaration, checker);
170543
170543
  const implementedType = checker.getTypeAtLocation(implementedTypeNode);
170544
170544
  const implementedTypeSymbols = checker.getPropertiesOfType(implementedType);
170545
- const nonPrivateAndNotExistedInHeritageClauseMembers = implementedTypeSymbols.filter(and20(symbolPointsToNonPrivateMember, (symbol) => !maybeHeritageClauseSymbol.has(symbol.escapedName)));
170545
+ const nonPrivateAndNotExistedInHeritageClauseMembers = implementedTypeSymbols.filter(and21(symbolPointsToNonPrivateMember, (symbol) => !maybeHeritageClauseSymbol.has(symbol.escapedName)));
170546
170546
  const classType = checker.getTypeAtLocation(classDeclaration);
170547
170547
  const constructor = find(classDeclaration.members, (m) => isConstructorDeclaration(m));
170548
170548
  if (!classType.getNumberIndexType()) {
@@ -185199,8 +185199,8 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
185199
185199
  function isAmbientModuleDeclaration(node) {
185200
185200
  return node.kind === 268 && node.name.kind === 11;
185201
185201
  }
185202
- function isExternalModuleImportEquals(eq20) {
185203
- return eq20.moduleReference.kind === 284 && eq20.moduleReference.expression.kind === 11;
185202
+ function isExternalModuleImportEquals(eq21) {
185203
+ return eq21.moduleReference.kind === 284 && eq21.moduleReference.expression.kind === 11;
185204
185204
  }
185205
185205
  var DefinitionKind = /* @__PURE__ */ ((DefinitionKind2) => {
185206
185206
  DefinitionKind2[DefinitionKind2["Symbol"] = 0] = "Symbol";
@@ -190847,13 +190847,13 @@ ${content}
190847
190847
  if (candidates[i] === resolvedSignature) {
190848
190848
  selectedItemIndex = itemsSeen;
190849
190849
  if (item.length > 1) {
190850
- let count16 = 0;
190850
+ let count17 = 0;
190851
190851
  for (const i2 of item) {
190852
190852
  if (i2.isVariadic || i2.parameters.length >= argumentCount) {
190853
- selectedItemIndex = itemsSeen + count16;
190853
+ selectedItemIndex = itemsSeen + count17;
190854
190854
  break;
190855
190855
  }
190856
- count16++;
190856
+ count17++;
190857
190857
  }
190858
190858
  }
190859
190859
  }
@@ -193154,8 +193154,8 @@ ${options.prefix}` : "\n" : options.prefix
193154
193154
  setTextRangePosEnd(newNode, getPos2(node), getEnd(node));
193155
193155
  return newNode;
193156
193156
  }
193157
- function assignPositionsToNodeArray(nodes, visitor, test, start, count16) {
193158
- const visited = visitNodes2(nodes, visitor, test, start, count16);
193157
+ function assignPositionsToNodeArray(nodes, visitor, test, start, count17) {
193158
+ const visited = visitNodes2(nodes, visitor, test, start, count17);
193159
193159
  if (!visited) {
193160
193160
  return visited;
193161
193161
  }
@@ -197832,7 +197832,7 @@ ${options.prefix}` : "\n" : options.prefix
197832
197832
  affectsEmitOptionDeclarations: () => affectsEmitOptionDeclarations,
197833
197833
  allKeysStartWithDot: () => allKeysStartWithDot,
197834
197834
  altDirectorySeparator: () => altDirectorySeparator,
197835
- and: () => and20,
197835
+ and: () => and21,
197836
197836
  append: () => append,
197837
197837
  appendIfUnique: () => appendIfUnique,
197838
197838
  arrayFrom: () => arrayFrom,
@@ -213723,8 +213723,7 @@ var getExternalAgent = (db) => async (params) => {
213723
213723
  where: and(
213724
213724
  eq(externalAgents.tenantId, params.scopes.tenantId),
213725
213725
  eq(externalAgents.projectId, params.scopes.projectId),
213726
- eq(externalAgents.agentId, params.scopes.agentId),
213727
- eq(externalAgents.id, params.subAgentId)
213726
+ eq(externalAgents.id, params.externalAgentId)
213728
213727
  )
213729
213728
  });
213730
213729
  return result || null;
@@ -213734,7 +213733,6 @@ var getExternalAgentByUrl = (db) => async (params) => {
213734
213733
  where: and(
213735
213734
  eq(externalAgents.tenantId, params.scopes.tenantId),
213736
213735
  eq(externalAgents.projectId, params.scopes.projectId),
213737
- eq(externalAgents.agentId, params.scopes.agentId),
213738
213736
  eq(externalAgents.baseUrl, params.baseUrl)
213739
213737
  )
213740
213738
  });
@@ -213744,8 +213742,7 @@ var listExternalAgents = (db) => async (params) => {
213744
213742
  return await db.query.externalAgents.findMany({
213745
213743
  where: and(
213746
213744
  eq(externalAgents.tenantId, params.scopes.tenantId),
213747
- eq(externalAgents.projectId, params.scopes.projectId),
213748
- eq(externalAgents.agentId, params.scopes.agentId)
213745
+ eq(externalAgents.projectId, params.scopes.projectId)
213749
213746
  ),
213750
213747
  orderBy: [asc(externalAgents.name)]
213751
213748
  });
@@ -213758,15 +213755,13 @@ var listExternalAgentsPaginated = (db) => async (params) => {
213758
213755
  db.select().from(externalAgents).where(
213759
213756
  and(
213760
213757
  eq(externalAgents.tenantId, params.scopes.tenantId),
213761
- eq(externalAgents.projectId, params.scopes.projectId),
213762
- eq(externalAgents.agentId, params.scopes.agentId)
213758
+ eq(externalAgents.projectId, params.scopes.projectId)
213763
213759
  )
213764
213760
  ).limit(limit).offset(offset).orderBy(desc(externalAgents.createdAt)),
213765
213761
  db.select({ count: count() }).from(externalAgents).where(
213766
213762
  and(
213767
213763
  eq(externalAgents.tenantId, params.scopes.tenantId),
213768
- eq(externalAgents.projectId, params.scopes.projectId),
213769
- eq(externalAgents.agentId, params.scopes.agentId)
213764
+ eq(externalAgents.projectId, params.scopes.projectId)
213770
213765
  )
213771
213766
  )
213772
213767
  ]);
@@ -213785,9 +213780,6 @@ var updateExternalAgent = (db) => async (params) => {
213785
213780
  if (Object.keys(updateData).length === 1) {
213786
213781
  throw new Error("No fields to update");
213787
213782
  }
213788
- if (updateData.headers !== void 0 && (updateData.headers === null || Object.keys(updateData.headers || {}).length === 0)) {
213789
- updateData.headers = null;
213790
- }
213791
213783
  if (updateData.credentialReferenceId === void 0) {
213792
213784
  updateData.credentialReferenceId = null;
213793
213785
  }
@@ -213795,8 +213787,7 @@ var updateExternalAgent = (db) => async (params) => {
213795
213787
  and(
213796
213788
  eq(externalAgents.tenantId, params.scopes.tenantId),
213797
213789
  eq(externalAgents.projectId, params.scopes.projectId),
213798
- eq(externalAgents.agentId, params.scopes.agentId),
213799
- eq(externalAgents.id, params.subAgentId)
213790
+ eq(externalAgents.id, params.externalAgentId)
213800
213791
  )
213801
213792
  ).returning();
213802
213793
  return result[0] || null;
@@ -213804,23 +213795,21 @@ var updateExternalAgent = (db) => async (params) => {
213804
213795
  var upsertExternalAgent = (db) => async (params) => {
213805
213796
  const scopes = {
213806
213797
  tenantId: params.data.tenantId,
213807
- projectId: params.data.projectId,
213808
- agentId: params.data.agentId
213798
+ projectId: params.data.projectId
213809
213799
  };
213810
213800
  const existing = await getExternalAgent(db)({
213811
213801
  scopes,
213812
- subAgentId: params.data.id
213802
+ externalAgentId: params.data.id
213813
213803
  });
213814
213804
  if (existing) {
213815
213805
  const updated = await updateExternalAgent(db)({
213816
213806
  scopes,
213817
- subAgentId: params.data.id,
213807
+ externalAgentId: params.data.id,
213818
213808
  data: {
213819
213809
  name: params.data.name,
213820
213810
  description: params.data.description,
213821
213811
  baseUrl: params.data.baseUrl,
213822
- credentialReferenceId: params.data.credentialReferenceId,
213823
- headers: params.data.headers
213812
+ credentialReferenceId: params.data.credentialReferenceId
213824
213813
  }
213825
213814
  });
213826
213815
  if (!updated) {
@@ -213837,8 +213826,7 @@ var deleteExternalAgent = (db) => async (params) => {
213837
213826
  and(
213838
213827
  eq(externalAgents.tenantId, params.scopes.tenantId),
213839
213828
  eq(externalAgents.projectId, params.scopes.projectId),
213840
- eq(externalAgents.agentId, params.scopes.agentId),
213841
- eq(externalAgents.id, params.subAgentId)
213829
+ eq(externalAgents.id, params.externalAgentId)
213842
213830
  )
213843
213831
  ).returning();
213844
213832
  return result.length > 0;
@@ -213859,8 +213847,7 @@ var countExternalAgents = (db) => async (params) => {
213859
213847
  const result = await db.select({ count: count() }).from(externalAgents).where(
213860
213848
  and(
213861
213849
  eq(externalAgents.tenantId, params.scopes.tenantId),
213862
- eq(externalAgents.projectId, params.scopes.projectId),
213863
- eq(externalAgents.agentId, params.scopes.agentId)
213850
+ eq(externalAgents.projectId, params.scopes.projectId)
213864
213851
  )
213865
213852
  );
213866
213853
  const countValue = result[0]?.count;
@@ -214230,6 +214217,284 @@ var updateSubAgentFunctionToolRelation = (db) => {
214230
214217
  }
214231
214218
  };
214232
214219
  };
214220
+ var getSubAgentExternalAgentRelationById = (db) => async (params) => {
214221
+ return db.query.subAgentExternalAgentRelations.findFirst({
214222
+ where: and(
214223
+ eq(subAgentExternalAgentRelations.tenantId, params.scopes.tenantId),
214224
+ eq(subAgentExternalAgentRelations.projectId, params.scopes.projectId),
214225
+ eq(subAgentExternalAgentRelations.agentId, params.scopes.agentId),
214226
+ eq(subAgentExternalAgentRelations.subAgentId, params.scopes.subAgentId),
214227
+ eq(subAgentExternalAgentRelations.id, params.relationId)
214228
+ )
214229
+ });
214230
+ };
214231
+ var listSubAgentExternalAgentRelations = (db) => async (params) => {
214232
+ const page = params.pagination?.page || 1;
214233
+ const limit = Math.min(params.pagination?.limit || 10, 100);
214234
+ const offset = (page - 1) * limit;
214235
+ const whereClause = and(
214236
+ eq(subAgentExternalAgentRelations.tenantId, params.scopes.tenantId),
214237
+ eq(subAgentExternalAgentRelations.projectId, params.scopes.projectId),
214238
+ eq(subAgentExternalAgentRelations.agentId, params.scopes.agentId),
214239
+ eq(subAgentExternalAgentRelations.subAgentId, params.scopes.subAgentId)
214240
+ );
214241
+ const [data, totalResult] = await Promise.all([
214242
+ db.select().from(subAgentExternalAgentRelations).where(whereClause).limit(limit).offset(offset).orderBy(desc(subAgentExternalAgentRelations.createdAt)),
214243
+ db.select({ count: count() }).from(subAgentExternalAgentRelations).where(whereClause)
214244
+ ]);
214245
+ const total = totalResult[0]?.count || 0;
214246
+ const pages = Math.ceil(total / limit);
214247
+ return { data, pagination: { page, limit, total, pages } };
214248
+ };
214249
+ var getSubAgentExternalAgentRelations = (db) => async (params) => {
214250
+ return await db.query.subAgentExternalAgentRelations.findMany({
214251
+ where: and(
214252
+ eq(subAgentExternalAgentRelations.tenantId, params.scopes.tenantId),
214253
+ eq(subAgentExternalAgentRelations.projectId, params.scopes.projectId),
214254
+ eq(subAgentExternalAgentRelations.agentId, params.scopes.agentId),
214255
+ eq(subAgentExternalAgentRelations.subAgentId, params.scopes.subAgentId)
214256
+ )
214257
+ });
214258
+ };
214259
+ var getSubAgentExternalAgentRelationsByAgent = (db) => async (params) => {
214260
+ return await db.query.subAgentExternalAgentRelations.findMany({
214261
+ where: and(
214262
+ eq(subAgentExternalAgentRelations.tenantId, params.scopes.tenantId),
214263
+ eq(subAgentExternalAgentRelations.projectId, params.scopes.projectId),
214264
+ eq(subAgentExternalAgentRelations.agentId, params.scopes.agentId)
214265
+ )
214266
+ });
214267
+ };
214268
+ var getSubAgentExternalAgentRelationsByExternalAgent = (db) => async (params) => {
214269
+ const page = params.pagination?.page || 1;
214270
+ const limit = Math.min(params.pagination?.limit || 10, 100);
214271
+ const offset = (page - 1) * limit;
214272
+ const whereClause = and(
214273
+ eq(subAgentExternalAgentRelations.tenantId, params.scopes.tenantId),
214274
+ eq(subAgentExternalAgentRelations.projectId, params.scopes.projectId),
214275
+ eq(subAgentExternalAgentRelations.agentId, params.scopes.agentId),
214276
+ eq(subAgentExternalAgentRelations.externalAgentId, params.externalAgentId)
214277
+ );
214278
+ const [data, totalResult] = await Promise.all([
214279
+ db.select().from(subAgentExternalAgentRelations).where(whereClause).limit(limit).offset(offset).orderBy(desc(subAgentExternalAgentRelations.createdAt)),
214280
+ db.select({ count: count() }).from(subAgentExternalAgentRelations).where(whereClause)
214281
+ ]);
214282
+ const total = totalResult[0]?.count || 0;
214283
+ const pages = Math.ceil(total / limit);
214284
+ return {
214285
+ data,
214286
+ pagination: { page, limit, total, pages }
214287
+ };
214288
+ };
214289
+ var getExternalAgentsForSubAgent = (db) => async (params) => {
214290
+ const page = params.pagination?.page || 1;
214291
+ const limit = Math.min(params.pagination?.limit || 10, 100);
214292
+ const offset = (page - 1) * limit;
214293
+ const [data, totalResult] = await Promise.all([
214294
+ db.select({
214295
+ id: subAgentExternalAgentRelations.id,
214296
+ tenantId: subAgentExternalAgentRelations.tenantId,
214297
+ projectId: subAgentExternalAgentRelations.projectId,
214298
+ agentId: subAgentExternalAgentRelations.agentId,
214299
+ subAgentId: subAgentExternalAgentRelations.subAgentId,
214300
+ externalAgentId: subAgentExternalAgentRelations.externalAgentId,
214301
+ headers: subAgentExternalAgentRelations.headers,
214302
+ createdAt: subAgentExternalAgentRelations.createdAt,
214303
+ updatedAt: subAgentExternalAgentRelations.updatedAt,
214304
+ externalAgent: {
214305
+ id: externalAgents.id,
214306
+ name: externalAgents.name,
214307
+ description: externalAgents.description,
214308
+ baseUrl: externalAgents.baseUrl,
214309
+ credentialReferenceId: externalAgents.credentialReferenceId,
214310
+ tenantId: externalAgents.tenantId,
214311
+ projectId: externalAgents.projectId,
214312
+ createdAt: externalAgents.createdAt,
214313
+ updatedAt: externalAgents.updatedAt
214314
+ }
214315
+ }).from(subAgentExternalAgentRelations).innerJoin(
214316
+ externalAgents,
214317
+ and(
214318
+ eq(subAgentExternalAgentRelations.tenantId, externalAgents.tenantId),
214319
+ eq(subAgentExternalAgentRelations.projectId, externalAgents.projectId),
214320
+ eq(subAgentExternalAgentRelations.externalAgentId, externalAgents.id)
214321
+ )
214322
+ ).where(
214323
+ and(
214324
+ eq(subAgentExternalAgentRelations.tenantId, params.scopes.tenantId),
214325
+ eq(subAgentExternalAgentRelations.projectId, params.scopes.projectId),
214326
+ eq(subAgentExternalAgentRelations.agentId, params.scopes.agentId),
214327
+ eq(subAgentExternalAgentRelations.subAgentId, params.scopes.subAgentId)
214328
+ )
214329
+ ).limit(limit).offset(offset).orderBy(desc(subAgentExternalAgentRelations.createdAt)),
214330
+ db.select({ count: count() }).from(subAgentExternalAgentRelations).where(
214331
+ and(
214332
+ eq(subAgentExternalAgentRelations.tenantId, params.scopes.tenantId),
214333
+ eq(subAgentExternalAgentRelations.projectId, params.scopes.projectId),
214334
+ eq(subAgentExternalAgentRelations.agentId, params.scopes.agentId),
214335
+ eq(subAgentExternalAgentRelations.subAgentId, params.scopes.subAgentId)
214336
+ )
214337
+ )
214338
+ ]);
214339
+ const total = totalResult[0]?.count || 0;
214340
+ const pages = Math.ceil(total / limit);
214341
+ return {
214342
+ data,
214343
+ pagination: { page, limit, total, pages }
214344
+ };
214345
+ };
214346
+ var getSubAgentsForExternalAgent = (db) => async (params) => {
214347
+ const page = params.pagination?.page || 1;
214348
+ const limit = Math.min(params.pagination?.limit || 10, 100);
214349
+ const offset = (page - 1) * limit;
214350
+ const [data, totalResult] = await Promise.all([
214351
+ db.select({
214352
+ id: subAgentExternalAgentRelations.id,
214353
+ tenantId: subAgentExternalAgentRelations.tenantId,
214354
+ projectId: subAgentExternalAgentRelations.projectId,
214355
+ agentId: subAgentExternalAgentRelations.agentId,
214356
+ subAgentId: subAgentExternalAgentRelations.subAgentId,
214357
+ externalAgentId: subAgentExternalAgentRelations.externalAgentId,
214358
+ headers: subAgentExternalAgentRelations.headers,
214359
+ createdAt: subAgentExternalAgentRelations.createdAt,
214360
+ updatedAt: subAgentExternalAgentRelations.updatedAt,
214361
+ subAgent: {
214362
+ id: subAgents.id,
214363
+ name: subAgents.name,
214364
+ description: subAgents.description,
214365
+ prompt: subAgents.prompt,
214366
+ conversationHistoryConfig: subAgents.conversationHistoryConfig,
214367
+ models: subAgents.models,
214368
+ stopWhen: subAgents.stopWhen,
214369
+ createdAt: subAgents.createdAt,
214370
+ updatedAt: subAgents.updatedAt
214371
+ }
214372
+ }).from(subAgentExternalAgentRelations).innerJoin(
214373
+ subAgents,
214374
+ and(
214375
+ eq(subAgentExternalAgentRelations.subAgentId, subAgents.id),
214376
+ eq(subAgentExternalAgentRelations.tenantId, subAgents.tenantId),
214377
+ eq(subAgentExternalAgentRelations.projectId, subAgents.projectId),
214378
+ eq(subAgentExternalAgentRelations.agentId, subAgents.agentId)
214379
+ )
214380
+ ).where(
214381
+ and(
214382
+ eq(subAgentExternalAgentRelations.tenantId, params.scopes.tenantId),
214383
+ eq(subAgentExternalAgentRelations.projectId, params.scopes.projectId),
214384
+ eq(subAgentExternalAgentRelations.agentId, params.scopes.agentId),
214385
+ eq(subAgentExternalAgentRelations.externalAgentId, params.externalAgentId)
214386
+ )
214387
+ ).limit(limit).offset(offset).orderBy(desc(subAgentExternalAgentRelations.createdAt)),
214388
+ db.select({ count: count() }).from(subAgentExternalAgentRelations).where(
214389
+ and(
214390
+ eq(subAgentExternalAgentRelations.tenantId, params.scopes.tenantId),
214391
+ eq(subAgentExternalAgentRelations.projectId, params.scopes.projectId),
214392
+ eq(subAgentExternalAgentRelations.agentId, params.scopes.agentId),
214393
+ eq(subAgentExternalAgentRelations.externalAgentId, params.externalAgentId)
214394
+ )
214395
+ )
214396
+ ]);
214397
+ const total = totalResult[0]?.count || 0;
214398
+ const pages = Math.ceil(total / limit);
214399
+ return {
214400
+ data,
214401
+ pagination: { page, limit, total, pages }
214402
+ };
214403
+ };
214404
+ var createSubAgentExternalAgentRelation = (db) => async (params) => {
214405
+ const finalRelationId = params.relationId ?? nanoid();
214406
+ const relation = await db.insert(subAgentExternalAgentRelations).values({
214407
+ id: finalRelationId,
214408
+ tenantId: params.scopes.tenantId,
214409
+ projectId: params.scopes.projectId,
214410
+ agentId: params.scopes.agentId,
214411
+ subAgentId: params.scopes.subAgentId,
214412
+ externalAgentId: params.data.externalAgentId,
214413
+ headers: params.data.headers
214414
+ }).returning();
214415
+ return relation[0];
214416
+ };
214417
+ var getSubAgentExternalAgentRelationByParams = (db) => async (params) => {
214418
+ return db.query.subAgentExternalAgentRelations.findFirst({
214419
+ where: and(
214420
+ eq(subAgentExternalAgentRelations.tenantId, params.scopes.tenantId),
214421
+ eq(subAgentExternalAgentRelations.projectId, params.scopes.projectId),
214422
+ eq(subAgentExternalAgentRelations.agentId, params.scopes.agentId),
214423
+ eq(subAgentExternalAgentRelations.subAgentId, params.scopes.subAgentId),
214424
+ eq(subAgentExternalAgentRelations.externalAgentId, params.externalAgentId)
214425
+ )
214426
+ });
214427
+ };
214428
+ var upsertSubAgentExternalAgentRelation = (db) => async (params) => {
214429
+ if (params.relationId) {
214430
+ return await updateSubAgentExternalAgentRelation(db)({
214431
+ scopes: params.scopes,
214432
+ relationId: params.relationId,
214433
+ data: params.data
214434
+ });
214435
+ }
214436
+ const existing = await getSubAgentExternalAgentRelationByParams(db)({
214437
+ scopes: params.scopes,
214438
+ externalAgentId: params.data.externalAgentId
214439
+ });
214440
+ if (existing) {
214441
+ return await updateSubAgentExternalAgentRelation(db)({
214442
+ scopes: params.scopes,
214443
+ relationId: existing.id,
214444
+ data: params.data
214445
+ });
214446
+ }
214447
+ return await createSubAgentExternalAgentRelation(db)(params);
214448
+ };
214449
+ var updateSubAgentExternalAgentRelation = (db) => async (params) => {
214450
+ const updateData = {
214451
+ ...params.data,
214452
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
214453
+ };
214454
+ const relation = await db.update(subAgentExternalAgentRelations).set(updateData).where(
214455
+ and(
214456
+ eq(subAgentExternalAgentRelations.tenantId, params.scopes.tenantId),
214457
+ eq(subAgentExternalAgentRelations.projectId, params.scopes.projectId),
214458
+ eq(subAgentExternalAgentRelations.agentId, params.scopes.agentId),
214459
+ eq(subAgentExternalAgentRelations.subAgentId, params.scopes.subAgentId),
214460
+ eq(subAgentExternalAgentRelations.id, params.relationId)
214461
+ )
214462
+ ).returning();
214463
+ return relation[0];
214464
+ };
214465
+ var deleteSubAgentExternalAgentRelation = (db) => async (params) => {
214466
+ const result = await db.delete(subAgentExternalAgentRelations).where(
214467
+ and(
214468
+ eq(subAgentExternalAgentRelations.tenantId, params.scopes.tenantId),
214469
+ eq(subAgentExternalAgentRelations.projectId, params.scopes.projectId),
214470
+ eq(subAgentExternalAgentRelations.agentId, params.scopes.agentId),
214471
+ eq(subAgentExternalAgentRelations.subAgentId, params.scopes.subAgentId),
214472
+ eq(subAgentExternalAgentRelations.id, params.relationId)
214473
+ )
214474
+ );
214475
+ return (result.rowsAffected || 0) > 0;
214476
+ };
214477
+ var deleteSubAgentExternalAgentRelationsBySubAgent = (db) => async (params) => {
214478
+ const result = await db.delete(subAgentExternalAgentRelations).where(
214479
+ and(
214480
+ eq(subAgentExternalAgentRelations.tenantId, params.scopes.tenantId),
214481
+ eq(subAgentExternalAgentRelations.projectId, params.scopes.projectId),
214482
+ eq(subAgentExternalAgentRelations.agentId, params.scopes.agentId),
214483
+ eq(subAgentExternalAgentRelations.subAgentId, params.scopes.subAgentId)
214484
+ )
214485
+ );
214486
+ return (result.rowsAffected || 0) > 0;
214487
+ };
214488
+ var deleteSubAgentExternalAgentRelationsByAgent = (db) => async (params) => {
214489
+ const result = await db.delete(subAgentExternalAgentRelations).where(
214490
+ and(
214491
+ eq(subAgentExternalAgentRelations.tenantId, params.scopes.tenantId),
214492
+ eq(subAgentExternalAgentRelations.projectId, params.scopes.projectId),
214493
+ eq(subAgentExternalAgentRelations.agentId, params.scopes.agentId)
214494
+ )
214495
+ );
214496
+ return (result.rowsAffected || 0) > 0;
214497
+ };
214233
214498
  var getAgentRelationById = (db) => async (params) => {
214234
214499
  return db.query.subAgentRelations.findFirst({
214235
214500
  where: and(
@@ -214318,29 +214583,8 @@ var getSubAgentRelationsByTarget = (db) => async (params) => {
214318
214583
  pagination: { page, limit, total, pages }
214319
214584
  };
214320
214585
  };
214321
- var getExternalAgentRelations = (db) => async (params) => {
214322
- const page = params.pagination?.page || 1;
214323
- const limit = Math.min(params.pagination?.limit || 10, 100);
214324
- const offset = (page - 1) * limit;
214325
- const whereClause = and(
214326
- eq(subAgentRelations.tenantId, params.scopes.tenantId),
214327
- eq(subAgentRelations.projectId, params.scopes.projectId),
214328
- eq(subAgentRelations.agentId, params.scopes.agentId),
214329
- eq(subAgentRelations.externalSubAgentId, params.externalSubAgentId)
214330
- );
214331
- const [data, totalResult] = await Promise.all([
214332
- db.select().from(subAgentRelations).where(whereClause).limit(limit).offset(offset).orderBy(desc(subAgentRelations.createdAt)),
214333
- db.select({ count: count() }).from(subAgentRelations).where(whereClause)
214334
- ]);
214335
- const total = totalResult[0]?.count || 0;
214336
- const pages = Math.ceil(total / limit);
214337
- return {
214338
- data,
214339
- pagination: { page, limit, total, pages }
214340
- };
214341
- };
214342
214586
  var getRelatedAgentsForAgent = (db) => async (params) => {
214343
- const internalRelations = await db.select({
214587
+ const data = await db.select({
214344
214588
  id: subAgents.id,
214345
214589
  name: subAgents.name,
214346
214590
  description: subAgents.description,
@@ -214362,35 +214606,8 @@ var getRelatedAgentsForAgent = (db) => async (params) => {
214362
214606
  isNotNull(subAgentRelations.targetSubAgentId)
214363
214607
  )
214364
214608
  );
214365
- const externalRelations = await db.select({
214366
- id: subAgentRelations.id,
214367
- relationType: subAgentRelations.relationType,
214368
- externalAgent: {
214369
- id: externalAgents.id,
214370
- name: externalAgents.name,
214371
- description: externalAgents.description,
214372
- baseUrl: externalAgents.baseUrl
214373
- }
214374
- }).from(subAgentRelations).innerJoin(
214375
- externalAgents,
214376
- and(
214377
- eq(subAgentRelations.externalSubAgentId, externalAgents.id),
214378
- eq(subAgentRelations.tenantId, externalAgents.tenantId),
214379
- eq(subAgentRelations.projectId, externalAgents.projectId),
214380
- eq(subAgentRelations.agentId, externalAgents.agentId)
214381
- )
214382
- ).where(
214383
- and(
214384
- eq(subAgentRelations.tenantId, params.scopes.tenantId),
214385
- eq(subAgentRelations.projectId, params.scopes.projectId),
214386
- eq(subAgentRelations.agentId, params.scopes.agentId),
214387
- eq(subAgentRelations.sourceSubAgentId, params.subAgentId),
214388
- isNotNull(subAgentRelations.externalSubAgentId)
214389
- )
214390
- );
214391
214609
  return {
214392
- internalRelations,
214393
- externalRelations
214610
+ data
214394
214611
  };
214395
214612
  };
214396
214613
  var createSubAgentRelation = (db) => async (params) => {
@@ -214418,9 +214635,6 @@ var getAgentRelationByParams = (db) => async (params) => {
214418
214635
  if (params.targetSubAgentId) {
214419
214636
  whereConditions.push(eq(subAgentRelations.targetSubAgentId, params.targetSubAgentId));
214420
214637
  }
214421
- if (params.externalSubAgentId) {
214422
- whereConditions.push(eq(subAgentRelations.externalSubAgentId, params.externalSubAgentId));
214423
- }
214424
214638
  return db.query.subAgentRelations.findFirst({
214425
214639
  where: and(...whereConditions)
214426
214640
  });
@@ -214430,7 +214644,6 @@ var upsertSubAgentRelation = (db) => async (params) => {
214430
214644
  scopes: { tenantId: params.tenantId, projectId: params.projectId, agentId: params.agentId },
214431
214645
  sourceSubAgentId: params.sourceSubAgentId,
214432
214646
  targetSubAgentId: params.targetSubAgentId,
214433
- externalSubAgentId: params.externalSubAgentId,
214434
214647
  relationType: params.relationType ?? ""
214435
214648
  });
214436
214649
  if (!existing) {
@@ -214438,12 +214651,6 @@ var upsertSubAgentRelation = (db) => async (params) => {
214438
214651
  }
214439
214652
  return existing;
214440
214653
  };
214441
- var createExternalAgentRelation = (db) => async (params) => {
214442
- return await createSubAgentRelation(db)({
214443
- ...params,
214444
- targetSubAgentId: void 0
214445
- });
214446
- };
214447
214654
  var updateAgentRelation = (db) => async (params) => {
214448
214655
  const updateData = {
214449
214656
  ...params.data,
@@ -214740,7 +214947,7 @@ var getAgentsForTool = (db) => async (params) => {
214740
214947
  pagination: { page, limit, total, pages }
214741
214948
  };
214742
214949
  };
214743
- var validateInternalSubAgent = (db) => async (params) => {
214950
+ var validateSubAgent = (db) => async (params) => {
214744
214951
  const result = await db.select({ id: subAgents.id }).from(subAgents).where(
214745
214952
  and(
214746
214953
  eq(subAgents.tenantId, params.scopes.tenantId),
@@ -214751,17 +214958,6 @@ var validateInternalSubAgent = (db) => async (params) => {
214751
214958
  ).limit(1);
214752
214959
  return result.length > 0;
214753
214960
  };
214754
- var validateExternalAgent = (db) => async (params) => {
214755
- const result = await db.select({ id: externalAgents.id }).from(externalAgents).where(
214756
- and(
214757
- eq(externalAgents.tenantId, params.scopes.tenantId),
214758
- eq(externalAgents.projectId, params.scopes.projectId),
214759
- eq(externalAgents.agentId, params.scopes.agentId),
214760
- eq(externalAgents.id, params.scopes.subAgentId)
214761
- )
214762
- ).limit(1);
214763
- return result.length > 0;
214764
- };
214765
214961
  var getSubAgentById = (db) => async (params) => {
214766
214962
  const result = await db.query.subAgents.findFirst({
214767
214963
  where: and(
@@ -215468,8 +215664,8 @@ var getCredentialReference = (db) => async (params) => {
215468
215664
  )
215469
215665
  });
215470
215666
  };
215471
- var getCredentialReferenceWithTools = (db) => async (params) => {
215472
- const [credential, relatedTools] = await Promise.all([
215667
+ var getCredentialReferenceWithResources = (db) => async (params) => {
215668
+ const [credential, relatedTools, relatedExternalAgents] = await Promise.all([
215473
215669
  db.query.credentialReferences.findFirst({
215474
215670
  where: and(
215475
215671
  eq(credentialReferences.tenantId, params.scopes.tenantId),
@@ -215483,6 +215679,13 @@ var getCredentialReferenceWithTools = (db) => async (params) => {
215483
215679
  eq(tools.projectId, params.scopes.projectId),
215484
215680
  eq(tools.credentialReferenceId, params.id)
215485
215681
  )
215682
+ ),
215683
+ db.select().from(externalAgents).where(
215684
+ and(
215685
+ eq(externalAgents.tenantId, params.scopes.tenantId),
215686
+ eq(externalAgents.projectId, params.scopes.projectId),
215687
+ eq(externalAgents.credentialReferenceId, params.id)
215688
+ )
215486
215689
  )
215487
215690
  ]);
215488
215691
  if (!credential) {
@@ -215490,7 +215693,8 @@ var getCredentialReferenceWithTools = (db) => async (params) => {
215490
215693
  }
215491
215694
  return {
215492
215695
  ...credential,
215493
- tools: relatedTools
215696
+ tools: relatedTools,
215697
+ externalAgents: relatedExternalAgents
215494
215698
  };
215495
215699
  };
215496
215700
  var listCredentialReferences = (db) => async (params) => {
@@ -215542,7 +215746,7 @@ var updateCredentialReference = (db) => async (params) => {
215542
215746
  eq(credentialReferences.id, params.id)
215543
215747
  )
215544
215748
  );
215545
- return await getCredentialReferenceWithTools(db)({
215749
+ return await getCredentialReferenceWithResources(db)({
215546
215750
  scopes: params.scopes,
215547
215751
  id: params.id
215548
215752
  });
@@ -216118,11 +216322,12 @@ var getFullAgentDefinition = (db) => async ({
216118
216322
  eq(subAgents.agentId, agentId)
216119
216323
  )
216120
216324
  });
216325
+ const externalAgentRelations = await getSubAgentExternalAgentRelationsByAgent(db)({
216326
+ scopes: { tenantId, projectId, agentId }
216327
+ });
216121
216328
  const externalSubAgentIds = /* @__PURE__ */ new Set();
216122
- for (const relation of agentRelations2) {
216123
- if (relation.externalSubAgentId) {
216124
- externalSubAgentIds.add(relation.externalSubAgentId);
216125
- }
216329
+ for (const relation of externalAgentRelations) {
216330
+ externalSubAgentIds.add(relation.externalAgentId);
216126
216331
  }
216127
216332
  const processedSubAgents = await Promise.all(
216128
216333
  agentSubAgents.map(async (agent2) => {
@@ -216131,7 +216336,13 @@ var getFullAgentDefinition = (db) => async ({
216131
216336
  (relation) => relation.sourceSubAgentId === agent2.id
216132
216337
  );
216133
216338
  const canTransferTo = subAgentRelationsList.filter((rel) => rel.relationType === "transfer" || rel.relationType === "transfer_to").map((rel) => rel.targetSubAgentId).filter((id) => id !== null);
216134
- const canDelegateTo = subAgentRelationsList.filter((rel) => rel.relationType === "delegate" || rel.relationType === "delegate_to").map((rel) => rel.targetSubAgentId || rel.externalSubAgentId).filter((id) => id !== null);
216339
+ const canDelegateToInternal = subAgentRelationsList.filter((rel) => rel.relationType === "delegate" || rel.relationType === "delegate_to").map((rel) => rel.targetSubAgentId).filter((id) => id !== null);
216340
+ const canDelegateToExternal = externalAgentRelations.filter((rel) => rel.subAgentId === agent2.id).map((rel) => ({
216341
+ externalAgentId: rel.externalAgentId,
216342
+ subAgentExternalAgentRelationId: rel.id,
216343
+ headers: rel.headers
216344
+ }));
216345
+ const canDelegateTo = [...canDelegateToInternal, ...canDelegateToExternal];
216135
216346
  const subAgentTools = await db.select({
216136
216347
  id: tools.id,
216137
216348
  name: tools.name,
@@ -216236,10 +216447,10 @@ var getFullAgentDefinition = (db) => async ({
216236
216447
  })
216237
216448
  );
216238
216449
  const externalAgents2 = await Promise.all(
216239
- Array.from(externalSubAgentIds).map(async (subAgentId) => {
216450
+ Array.from(externalSubAgentIds).map(async (externalAgentId) => {
216240
216451
  const subAgent = await getExternalAgent(db)({
216241
- scopes: { tenantId, projectId, agentId },
216242
- subAgentId
216452
+ scopes: { tenantId, projectId },
216453
+ externalAgentId
216243
216454
  });
216244
216455
  if (!subAgent) return null;
216245
216456
  return {
@@ -216248,24 +216459,26 @@ var getFullAgentDefinition = (db) => async ({
216248
216459
  };
216249
216460
  })
216250
216461
  );
216251
- const validSubAgents = [...processedSubAgents, ...externalAgents2].filter(
216462
+ const validSubAgents = processedSubAgents.filter(
216463
+ (agent2) => agent2 !== null
216464
+ );
216465
+ const validExternalAgents = externalAgents2.filter(
216252
216466
  (agent2) => agent2 !== null
216253
216467
  );
216254
216468
  const agentsObject = {};
216469
+ const externalAgentsObject = {};
216255
216470
  for (const subAgent of validSubAgents) {
216256
- if ("baseUrl" in subAgent && subAgent.baseUrl) {
216257
- agentsObject[subAgent.id] = {
216258
- id: subAgent.id,
216259
- name: subAgent.name,
216260
- description: subAgent.description,
216261
- baseUrl: subAgent.baseUrl,
216262
- credentialReferenceId: subAgent.credentialReferenceId,
216263
- headers: subAgent.headers,
216264
- type: "external"
216265
- };
216266
- } else {
216267
- agentsObject[subAgent.id] = subAgent;
216268
- }
216471
+ agentsObject[subAgent.id] = subAgent;
216472
+ }
216473
+ for (const externalAgent of validExternalAgents) {
216474
+ externalAgentsObject[externalAgent.id] = {
216475
+ id: externalAgent.id,
216476
+ name: externalAgent.name,
216477
+ description: externalAgent.description,
216478
+ baseUrl: externalAgent.baseUrl,
216479
+ credentialReferenceId: externalAgent.credentialReferenceId,
216480
+ type: "external"
216481
+ };
216269
216482
  }
216270
216483
  let contextConfig2 = null;
216271
216484
  if (agent.contextConfigId) {
@@ -216325,6 +216538,9 @@ var getFullAgentDefinition = (db) => async ({
216325
216538
  createdAt: agent.createdAt && !Number.isNaN(new Date(agent.createdAt).getTime()) ? new Date(agent.createdAt).toISOString() : (/* @__PURE__ */ new Date()).toISOString(),
216326
216539
  updatedAt: agent.updatedAt && !Number.isNaN(new Date(agent.updatedAt).getTime()) ? new Date(agent.updatedAt).toISOString() : (/* @__PURE__ */ new Date()).toISOString()
216327
216540
  };
216541
+ if (Object.keys(externalAgentsObject).length > 0) {
216542
+ result.externalAgents = externalAgentsObject;
216543
+ }
216328
216544
  if (agent.models) {
216329
216545
  result.models = agent.models;
216330
216546
  }
@@ -217509,7 +217725,7 @@ async function applyExecutionLimitsInheritance(db, logger13, scopes, agentData)
217509
217725
  "Propagating stepCountIs to agents"
217510
217726
  );
217511
217727
  for (const [subAgentId, subAgentData] of Object.entries(agentData.subAgents)) {
217512
- if (isInternalAgent(subAgentData)) {
217728
+ if (subAgentData.canTransferTo && Array.isArray(subAgentData.canTransferTo)) {
217513
217729
  const agent = agentData;
217514
217730
  if (!agent.stopWhen) {
217515
217731
  agent.stopWhen = {};
@@ -217722,85 +217938,39 @@ var createFullAgentServerSide = (db, logger13 = defaultLogger) => async (scopes,
217722
217938
  "All function tools created successfully"
217723
217939
  );
217724
217940
  }
217725
- const internalAgentPromises = Object.entries(typed.subAgents).filter(([_, agentData2]) => isInternalAgent(agentData2)).map(async ([subAgentId, agentData2]) => {
217726
- const internalAgent = agentData2;
217727
- try {
217728
- logger13.info({ subAgentId }, "Processing internal agent");
217729
- await upsertSubAgent(db)({
217730
- data: {
217731
- id: subAgentId,
217732
- tenantId,
217733
- projectId,
217734
- agentId: finalAgentId,
217735
- name: internalAgent.name || "",
217736
- description: internalAgent.description || "",
217737
- prompt: internalAgent.prompt || "",
217738
- conversationHistoryConfig: internalAgent.conversationHistoryConfig,
217739
- models: internalAgent.models,
217740
- stopWhen: internalAgent.stopWhen
217741
- }
217742
- });
217743
- logger13.info({ subAgentId }, "Internal agent processed successfully");
217744
- } catch (error) {
217745
- logger13.error({ subAgentId, error }, "Failed to create/update internal agent");
217746
- throw error;
217747
- }
217748
- });
217749
- await Promise.all(internalAgentPromises);
217750
- const internalAgentCount = Object.entries(typed.subAgents).filter(
217751
- ([_, agentData2]) => isInternalAgent(agentData2)
217752
- ).length;
217753
- logger13.info({ internalAgentCount }, "All internal agents created/updated successfully");
217754
- const externalAgentPromises = Object.entries(typed.subAgents).filter(([_, agentData2]) => isExternalAgent(agentData2)).map(async ([subAgentId, agentData2]) => {
217755
- const externalAgent = agentData2;
217756
- try {
217757
- logger13.info({ subAgentId }, "Processing external agent");
217758
- await upsertExternalAgent(db)({
217759
- data: {
217760
- id: subAgentId,
217761
- tenantId,
217762
- projectId,
217763
- agentId: finalAgentId,
217764
- name: externalAgent.name,
217765
- description: externalAgent.description || "",
217766
- baseUrl: externalAgent.baseUrl,
217767
- credentialReferenceId: externalAgent.credentialReferenceId || void 0,
217768
- headers: externalAgent.headers || void 0
217769
- }
217770
- });
217771
- logger13.info({ subAgentId }, "External agent processed successfully");
217772
- } catch (error) {
217773
- logger13.error({ subAgentId, error }, "Failed to create/update external agent");
217774
- throw error;
217775
- }
217776
- });
217777
- await Promise.all(externalAgentPromises);
217778
- const externalAgentCount = Object.entries(typed.subAgents).filter(
217779
- ([_, agentData2]) => isExternalAgent(agentData2)
217780
- ).length;
217781
- logger13.info({ externalAgentCount }, "All external agents created/updated successfully");
217782
- if (contextConfigId) {
217783
- try {
217784
- logger13.info(
217785
- { agentId: finalAgentId, contextConfigId },
217786
- "Updating agent with context config"
217787
- );
217788
- await updateAgent(db)({
217789
- scopes: { tenantId, projectId, agentId: finalAgentId },
217790
- data: { contextConfigId }
217791
- });
217792
- logger13.info({ agentId: finalAgentId }, "Agent updated with context config");
217793
- } catch (error) {
217794
- logger13.error(
217795
- { agentId: finalAgentId, error },
217796
- "Failed to update agent with context config"
217797
- );
217798
- throw error;
217941
+ const subAgentPromises = Object.entries(typed.subAgents).map(
217942
+ async ([subAgentId, agentData2]) => {
217943
+ const subAgent = agentData2;
217944
+ try {
217945
+ logger13.info({ subAgentId }, "Processing sub-agent");
217946
+ await upsertSubAgent(db)({
217947
+ data: {
217948
+ id: subAgentId,
217949
+ tenantId,
217950
+ projectId,
217951
+ agentId: finalAgentId,
217952
+ name: subAgent.name || "",
217953
+ description: subAgent.description || "",
217954
+ prompt: subAgent.prompt || "",
217955
+ conversationHistoryConfig: subAgent.conversationHistoryConfig,
217956
+ models: subAgent.models,
217957
+ stopWhen: subAgent.stopWhen
217958
+ }
217959
+ });
217960
+ logger13.info({ subAgentId }, "Sub-agent processed successfully");
217961
+ } catch (error) {
217962
+ logger13.error({ subAgentId, error }, "Failed to create/update sub-agent");
217963
+ throw error;
217964
+ }
217799
217965
  }
217800
- }
217966
+ );
217967
+ await Promise.all(subAgentPromises);
217968
+ const subAgentCount = Object.entries(typed.subAgents).length;
217969
+ logger13.info({ subAgentCount }, "All sub-agents created/updated successfully");
217970
+ logger13.info({}, "External agents are project-scoped and managed at the project level.");
217801
217971
  const agentToolPromises = [];
217802
217972
  for (const [subAgentId, agentData2] of Object.entries(typed.subAgents)) {
217803
- if (isInternalAgent(agentData2) && agentData2.canUse && Array.isArray(agentData2.canUse)) {
217973
+ if (agentData2.canUse && Array.isArray(agentData2.canUse)) {
217804
217974
  for (const canUseItem of agentData2.canUse) {
217805
217975
  agentToolPromises.push(
217806
217976
  (async () => {
@@ -217862,7 +218032,7 @@ var createFullAgentServerSide = (db, logger13 = defaultLogger) => async (scopes,
217862
218032
  );
217863
218033
  const agentDataComponentPromises = [];
217864
218034
  for (const [subAgentId, agentData2] of Object.entries(typed.subAgents)) {
217865
- if (isInternalAgent(agentData2) && agentData2.dataComponents) {
218035
+ if (agentData2.dataComponents) {
217866
218036
  for (const dataComponentId of agentData2.dataComponents) {
217867
218037
  agentDataComponentPromises.push(
217868
218038
  (async () => {
@@ -217894,7 +218064,7 @@ var createFullAgentServerSide = (db, logger13 = defaultLogger) => async (scopes,
217894
218064
  logger13.info({}, "All agent-data component relations created");
217895
218065
  const agentArtifactComponentPromises = [];
217896
218066
  for (const [subAgentId, agentData2] of Object.entries(typed.subAgents)) {
217897
- if (isInternalAgent(agentData2) && agentData2.artifactComponents) {
218067
+ if (agentData2.artifactComponents) {
217898
218068
  for (const artifactComponentId of agentData2.artifactComponents) {
217899
218069
  agentArtifactComponentPromises.push(
217900
218070
  (async () => {
@@ -217925,8 +218095,9 @@ var createFullAgentServerSide = (db, logger13 = defaultLogger) => async (scopes,
217925
218095
  await Promise.all(agentArtifactComponentPromises);
217926
218096
  logger13.info({}, "All agent-artifact component relations created");
217927
218097
  const subAgentRelationPromises = [];
218098
+ const subAgentExternalAgentRelationPromises = [];
217928
218099
  for (const [subAgentId, agentData2] of Object.entries(typed.subAgents)) {
217929
- if (isInternalAgent(agentData2) && agentData2.canTransferTo) {
218100
+ if (agentData2.canTransferTo) {
217930
218101
  for (const targetSubAgentId of agentData2.canTransferTo) {
217931
218102
  subAgentRelationPromises.push(
217932
218103
  (async () => {
@@ -217957,48 +218128,98 @@ var createFullAgentServerSide = (db, logger13 = defaultLogger) => async (scopes,
217957
218128
  })()
217958
218129
  );
217959
218130
  }
217960
- }
217961
- if (isInternalAgent(agentData2) && agentData2.canDelegateTo) {
217962
- for (const targetSubAgentId of agentData2.canDelegateTo) {
217963
- const targetAgentData = typed.subAgents[targetSubAgentId];
217964
- const isTargetExternal = isExternalAgent(targetAgentData);
217965
- subAgentRelationPromises.push(
217966
- (async () => {
217967
- try {
217968
- logger13.info(
217969
- { subAgentId, targetSubAgentId, type: "delegate" },
217970
- "Processing agent delegation relation"
217971
- );
217972
- await upsertSubAgentRelation(db)({
217973
- id: generateId(),
217974
- tenantId,
217975
- projectId,
217976
- agentId: finalAgentId,
217977
- sourceSubAgentId: subAgentId,
217978
- targetSubAgentId: isTargetExternal ? void 0 : targetSubAgentId,
217979
- externalSubAgentId: isTargetExternal ? targetSubAgentId : void 0,
217980
- relationType: "delegate"
217981
- });
217982
- logger13.info(
217983
- { subAgentId, targetSubAgentId, type: "delegate" },
217984
- "Agent delegation relation processed successfully"
217985
- );
217986
- } catch (error) {
217987
- logger13.error(
217988
- { subAgentId, targetSubAgentId, type: "delegate", error },
217989
- "Failed to create delegation relation"
217990
- );
217991
- }
217992
- })()
217993
- );
218131
+ if (agentData2.canDelegateTo) {
218132
+ for (const targetItem of agentData2.canDelegateTo) {
218133
+ if (typeof targetItem === "string") {
218134
+ subAgentRelationPromises.push(
218135
+ (async () => {
218136
+ try {
218137
+ logger13.info(
218138
+ { subAgentId, targetSubAgentId: targetItem, type: "delegate" },
218139
+ "Processing sub-agent delegation relation"
218140
+ );
218141
+ await upsertSubAgentRelation(db)({
218142
+ id: generateId(),
218143
+ tenantId,
218144
+ projectId,
218145
+ agentId: finalAgentId,
218146
+ sourceSubAgentId: subAgentId,
218147
+ targetSubAgentId: targetItem,
218148
+ relationType: "delegate"
218149
+ });
218150
+ logger13.info(
218151
+ { subAgentId, targetSubAgentId: targetItem, type: "delegate" },
218152
+ "Sub-agent delegation relation processed successfully"
218153
+ );
218154
+ } catch (error) {
218155
+ logger13.error(
218156
+ { subAgentId, targetSubAgentId: targetItem, type: "delegate", error },
218157
+ "Failed to create sub-agent delegation relation"
218158
+ );
218159
+ }
218160
+ })()
218161
+ );
218162
+ } else {
218163
+ subAgentExternalAgentRelationPromises.push(
218164
+ (async () => {
218165
+ try {
218166
+ logger13.info(
218167
+ {
218168
+ subAgentId,
218169
+ externalAgentId: targetItem.externalAgentId,
218170
+ type: "delegate"
218171
+ },
218172
+ "Processing external agent delegation relation"
218173
+ );
218174
+ await upsertSubAgentExternalAgentRelation(db)({
218175
+ scopes: {
218176
+ tenantId,
218177
+ projectId,
218178
+ agentId: finalAgentId,
218179
+ subAgentId
218180
+ },
218181
+ relationId: targetItem.subAgentExternalAgentRelationId,
218182
+ data: {
218183
+ externalAgentId: targetItem.externalAgentId,
218184
+ headers: targetItem.headers || null
218185
+ }
218186
+ });
218187
+ logger13.info(
218188
+ {
218189
+ subAgentId,
218190
+ externalAgentId: targetItem.externalAgentId,
218191
+ type: "delegate"
218192
+ },
218193
+ "External agent delegation relation processed successfully"
218194
+ );
218195
+ } catch (error) {
218196
+ logger13.error(
218197
+ {
218198
+ subAgentId,
218199
+ externalAgentId: targetItem.externalAgentId,
218200
+ type: "delegate",
218201
+ error
218202
+ },
218203
+ "Failed to create external delegation relation"
218204
+ );
218205
+ }
218206
+ })()
218207
+ );
218208
+ }
218209
+ }
217994
218210
  }
217995
218211
  }
217996
218212
  }
217997
218213
  await Promise.all(subAgentRelationPromises);
218214
+ await Promise.all(subAgentExternalAgentRelationPromises);
217998
218215
  logger13.info(
217999
218216
  { subAgentRelationCount: subAgentRelationPromises.length },
218000
218217
  "All sub-agent relations created"
218001
218218
  );
218219
+ logger13.info(
218220
+ { subAgentExternalAgentRelationCount: subAgentExternalAgentRelationPromises.length },
218221
+ "All sub-agent external agent relations created"
218222
+ );
218002
218223
  const createdAgent = await getFullAgentDefinition(db)({
218003
218224
  scopes: { tenantId, projectId, agentId: finalAgentId }
218004
218225
  });
@@ -218230,151 +218451,147 @@ var updateFullAgentServerSide = (db, logger13 = defaultLogger) => async (scopes,
218230
218451
  "All function tools updated successfully"
218231
218452
  );
218232
218453
  }
218233
- const internalAgentPromises = Object.entries(typedAgentDefinition.subAgents).filter(([_, agentData2]) => isInternalAgent(agentData2)).map(async ([subAgentId, agentData2]) => {
218234
- const internalAgent = agentData2;
218235
- let existingSubAgent = null;
218236
- try {
218237
- existingSubAgent = await db.query.subAgents.findFirst({
218238
- where: and(
218239
- eq(subAgents.id, subAgentId),
218240
- eq(subAgents.tenantId, tenantId),
218241
- eq(subAgents.projectId, projectId)
218242
- ),
218243
- columns: {
218244
- models: true
218245
- }
218246
- });
218247
- } catch (_error) {
218248
- }
218249
- let finalModelSettings = internalAgent.models === void 0 ? void 0 : internalAgent.models;
218250
- if (existingSubAgent?.models && typedAgentDefinition.models) {
218251
- const subAgentModels = existingSubAgent.models;
218252
- const agentModels = typedAgentDefinition.models;
218253
- const modelTypes = ["base", "structuredOutput", "summarizer"];
218254
- const cascadedModels = { ...finalModelSettings };
218255
- for (const modelType of modelTypes) {
218256
- if (subAgentModels[modelType]?.model && existingAgentModels?.[modelType]?.model && subAgentModels[modelType].model === existingAgentModels[modelType].model && agentModels[modelType] && (agentModels[modelType].model !== existingAgentModels[modelType]?.model || JSON.stringify(agentModels[modelType].providerOptions) !== JSON.stringify(existingAgentModels[modelType]?.providerOptions))) {
218257
- cascadedModels[modelType] = agentModels[modelType];
218258
- logger13.info(
218259
- {
218260
- subAgentId,
218261
- modelType,
218262
- oldModel: existingAgentModels[modelType]?.model,
218263
- newModel: agentModels[modelType].model,
218264
- hasProviderOptions: !!agentModels[modelType].providerOptions
218265
- },
218266
- "Cascading model change from parent agent to subAgent"
218267
- );
218454
+ const subAgentPromises = Object.entries(typedAgentDefinition.subAgents).map(
218455
+ async ([subAgentId, agentData2]) => {
218456
+ const subAgent = agentData2;
218457
+ let existingSubAgent = null;
218458
+ try {
218459
+ existingSubAgent = await db.query.subAgents.findFirst({
218460
+ where: and(
218461
+ eq(subAgents.id, subAgentId),
218462
+ eq(subAgents.tenantId, tenantId),
218463
+ eq(subAgents.projectId, projectId)
218464
+ ),
218465
+ columns: {
218466
+ models: true
218467
+ }
218468
+ });
218469
+ } catch (_error) {
218470
+ }
218471
+ let finalModelSettings = subAgent.models === void 0 ? void 0 : subAgent.models;
218472
+ if (existingSubAgent?.models && typedAgentDefinition.models) {
218473
+ const subAgentModels = existingSubAgent.models;
218474
+ const agentModels = typedAgentDefinition.models;
218475
+ const modelTypes = ["base", "structuredOutput", "summarizer"];
218476
+ const cascadedModels = { ...finalModelSettings };
218477
+ for (const modelType of modelTypes) {
218478
+ if (subAgentModels[modelType]?.model && existingAgentModels?.[modelType]?.model && subAgentModels[modelType].model === existingAgentModels[modelType].model && agentModels[modelType] && (agentModels[modelType].model !== existingAgentModels[modelType]?.model || JSON.stringify(agentModels[modelType].providerOptions) !== JSON.stringify(existingAgentModels[modelType]?.providerOptions))) {
218479
+ cascadedModels[modelType] = agentModels[modelType];
218480
+ logger13.info(
218481
+ {
218482
+ subAgentId,
218483
+ modelType,
218484
+ oldModel: existingAgentModels[modelType]?.model,
218485
+ newModel: agentModels[modelType].model,
218486
+ hasProviderOptions: !!agentModels[modelType].providerOptions
218487
+ },
218488
+ "Cascading model change from parent agent to subAgent"
218489
+ );
218490
+ }
218268
218491
  }
218492
+ finalModelSettings = cascadedModels;
218493
+ }
218494
+ try {
218495
+ logger13.info({ subAgentId }, "Processing sub-agent");
218496
+ await upsertSubAgent(db)({
218497
+ data: {
218498
+ id: subAgentId,
218499
+ tenantId,
218500
+ projectId,
218501
+ agentId: finalAgentId,
218502
+ name: subAgent.name || "",
218503
+ description: subAgent.description || "",
218504
+ prompt: subAgent.prompt || "",
218505
+ conversationHistoryConfig: subAgent.conversationHistoryConfig,
218506
+ models: finalModelSettings,
218507
+ stopWhen: subAgent.stopWhen
218508
+ }
218509
+ });
218510
+ logger13.info({ subAgentId }, "Sub-agent processed successfully");
218511
+ } catch (error) {
218512
+ logger13.error({ subAgentId, error }, "Failed to create/update sub-agent");
218513
+ throw error;
218269
218514
  }
218270
- finalModelSettings = cascadedModels;
218271
- }
218272
- try {
218273
- logger13.info({ subAgentId }, "Processing internal agent");
218274
- await upsertSubAgent(db)({
218275
- data: {
218276
- id: subAgentId,
218277
- tenantId,
218278
- projectId,
218279
- agentId: finalAgentId,
218280
- name: internalAgent.name || "",
218281
- description: internalAgent.description || "",
218282
- prompt: internalAgent.prompt || "",
218283
- conversationHistoryConfig: internalAgent.conversationHistoryConfig,
218284
- models: finalModelSettings,
218285
- stopWhen: internalAgent.stopWhen
218286
- }
218287
- });
218288
- logger13.info({ subAgentId }, "Internal agent processed successfully");
218289
- } catch (error) {
218290
- logger13.error({ subAgentId, error }, "Failed to create/update internal agent");
218291
- throw error;
218292
- }
218293
- });
218294
- await Promise.all(internalAgentPromises);
218295
- const internalAgentCount = Object.entries(typedAgentDefinition.subAgents).filter(
218296
- ([_, agentData2]) => isInternalAgent(agentData2)
218297
- ).length;
218298
- logger13.info({ internalAgentCount }, "All internal agents created/updated successfully");
218299
- const externalAgentPromises = Object.entries(typedAgentDefinition.subAgents).filter(([_, agentData2]) => isExternalAgent(agentData2)).map(async ([subAgentId, agentData2]) => {
218300
- const externalAgent = agentData2;
218301
- try {
218302
- logger13.info({ subAgentId }, "Processing external agent");
218303
- await upsertExternalAgent(db)({
218304
- data: {
218305
- id: subAgentId,
218306
- tenantId,
218307
- projectId,
218308
- agentId: finalAgentId,
218309
- name: externalAgent.name,
218310
- description: externalAgent.description || "",
218311
- baseUrl: externalAgent.baseUrl,
218312
- credentialReferenceId: externalAgent.credentialReferenceId || void 0,
218313
- headers: externalAgent.headers || void 0
218314
- }
218315
- });
218316
- logger13.info({ subAgentId }, "External agent processed successfully");
218317
- } catch (error) {
218318
- logger13.error({ subAgentId, error }, "Failed to create/update external agent");
218319
- throw error;
218320
218515
  }
218321
- });
218322
- await Promise.all(externalAgentPromises);
218323
- const externalAgentCount = Object.entries(typedAgentDefinition.subAgents).filter(
218324
- ([_, agentData2]) => isExternalAgent(agentData2)
218325
- ).length;
218326
- logger13.info({ externalAgentCount }, "All external agents created/updated successfully");
218327
- const incomingAgentIds = new Set(Object.keys(typedAgentDefinition.subAgents));
218328
- const existingInternalAgents = await listSubAgents(db)({
218329
- scopes: { tenantId, projectId, agentId: finalAgentId }
218330
- });
218331
- const existingExternalAgents = await listExternalAgents(db)({
218516
+ );
218517
+ await Promise.all(subAgentPromises);
218518
+ const subAgentCount = Object.entries(typedAgentDefinition.subAgents).length;
218519
+ logger13.info({ subAgentCount }, "All sub-agents created/updated successfully");
218520
+ logger13.info({}, "External agents are project-scoped and managed at the project level.");
218521
+ const incomingSubAgentIds = new Set(Object.keys(typedAgentDefinition.subAgents));
218522
+ const existingSubAgents = await listSubAgents(db)({
218332
218523
  scopes: { tenantId, projectId, agentId: finalAgentId }
218333
218524
  });
218334
- let deletedInternalCount = 0;
218335
- for (const agent of existingInternalAgents) {
218336
- if (!incomingAgentIds.has(agent.id)) {
218525
+ let deletedSubAgentCount = 0;
218526
+ for (const subAgent of existingSubAgents) {
218527
+ if (!incomingSubAgentIds.has(subAgent.id)) {
218337
218528
  try {
218338
218529
  await deleteSubAgent(db)({
218339
218530
  scopes: { tenantId, projectId, agentId: finalAgentId },
218340
- subAgentId: agent.id
218531
+ subAgentId: subAgent.id
218341
218532
  });
218342
- deletedInternalCount++;
218343
- logger13.info({ subAgentId: agent.id }, "Deleted orphaned internal agent");
218533
+ deletedSubAgentCount++;
218534
+ logger13.info({ subAgentId: subAgent.id }, "Deleted orphaned sub-agent");
218344
218535
  } catch (error) {
218345
- logger13.error(
218346
- { subAgentId: agent.id, error },
218347
- "Failed to delete orphaned internal agent"
218348
- );
218536
+ logger13.error({ subAgentId: subAgent.id, error }, "Failed to delete orphaned sub-agent");
218349
218537
  }
218350
218538
  }
218351
218539
  }
218352
- let deletedExternalCount = 0;
218353
- for (const agent of existingExternalAgents) {
218354
- if (!incomingAgentIds.has(agent.id)) {
218540
+ if (deletedSubAgentCount > 0) {
218541
+ logger13.info(
218542
+ {
218543
+ deletedSubAgentCount
218544
+ },
218545
+ "Deleted orphaned sub-agents from agent"
218546
+ );
218547
+ }
218548
+ const incomingExternalAgentRelationIds = /* @__PURE__ */ new Set();
218549
+ for (const [_subAgentId, agentData2] of Object.entries(typedAgentDefinition.subAgents)) {
218550
+ if (agentData2.canDelegateTo && Array.isArray(agentData2.canDelegateTo)) {
218551
+ for (const delegateItem of agentData2.canDelegateTo) {
218552
+ if (typeof delegateItem === "object" && delegateItem.subAgentExternalAgentRelationId) {
218553
+ incomingExternalAgentRelationIds.add(delegateItem.subAgentExternalAgentRelationId);
218554
+ }
218555
+ }
218556
+ }
218557
+ }
218558
+ const existingExternalAgentRelations = await getSubAgentExternalAgentRelationsByAgent(db)({
218559
+ scopes: { tenantId, projectId, agentId: finalAgentId }
218560
+ });
218561
+ let deletedExternalAgentRelationCount = 0;
218562
+ for (const relation of existingExternalAgentRelations) {
218563
+ if (!incomingExternalAgentRelationIds.has(relation.id)) {
218355
218564
  try {
218356
- await deleteExternalAgent(db)({
218357
- scopes: { tenantId, projectId, agentId: finalAgentId },
218358
- subAgentId: agent.id
218565
+ await deleteSubAgentExternalAgentRelation(db)({
218566
+ scopes: {
218567
+ tenantId,
218568
+ projectId,
218569
+ agentId: finalAgentId,
218570
+ subAgentId: relation.subAgentId
218571
+ },
218572
+ relationId: relation.id
218359
218573
  });
218360
- deletedExternalCount++;
218361
- logger13.info({ subAgentId: agent.id }, "Deleted orphaned external agent");
218574
+ deletedExternalAgentRelationCount++;
218575
+ logger13.info(
218576
+ {
218577
+ relationId: relation.id,
218578
+ subAgentId: relation.subAgentId,
218579
+ externalAgentId: relation.externalAgentId
218580
+ },
218581
+ "Deleted orphaned external agent relation"
218582
+ );
218362
218583
  } catch (error) {
218363
218584
  logger13.error(
218364
- { subAgentId: agent.id, error },
218365
- "Failed to delete orphaned external agent"
218585
+ { relationId: relation.id, error },
218586
+ "Failed to delete orphaned external agent relation"
218366
218587
  );
218367
218588
  }
218368
218589
  }
218369
218590
  }
218370
- if (deletedInternalCount > 0 || deletedExternalCount > 0) {
218591
+ if (deletedExternalAgentRelationCount > 0) {
218371
218592
  logger13.info(
218372
- {
218373
- deletedInternalCount,
218374
- deletedExternalCount,
218375
- totalDeleted: deletedInternalCount + deletedExternalCount
218376
- },
218377
- "Deleted orphaned agents from agent"
218593
+ { deletedExternalAgentRelationCount },
218594
+ "Deleted orphaned external agent relations from agent"
218378
218595
  );
218379
218596
  }
218380
218597
  await updateAgent(db)({
@@ -218393,7 +218610,7 @@ var updateFullAgentServerSide = (db, logger13 = defaultLogger) => async (scopes,
218393
218610
  logger13.info({ agentId: typedAgentDefinition.id }, "Agent metadata updated");
218394
218611
  const incomingRelationshipIds = /* @__PURE__ */ new Set();
218395
218612
  for (const [_subAgentId, agentData2] of Object.entries(typedAgentDefinition.subAgents)) {
218396
- if (isInternalAgent(agentData2) && agentData2.canUse && Array.isArray(agentData2.canUse)) {
218613
+ if (agentData2.canUse && Array.isArray(agentData2.canUse)) {
218397
218614
  for (const canUseItem of agentData2.canUse) {
218398
218615
  if (canUseItem.agentToolRelationId) {
218399
218616
  incomingRelationshipIds.add(canUseItem.agentToolRelationId);
@@ -218433,17 +218650,20 @@ var updateFullAgentServerSide = (db, logger13 = defaultLogger) => async (scopes,
218433
218650
  logger13.error({ subAgentId, error }, "Failed to delete orphaned agent-tool relations");
218434
218651
  }
218435
218652
  }
218436
- const agentToolPromises = [];
218653
+ const subAgentToolPromises = [];
218437
218654
  for (const [subAgentId, agentData2] of Object.entries(typedAgentDefinition.subAgents)) {
218438
- if (isInternalAgent(agentData2) && agentData2.canUse && Array.isArray(agentData2.canUse)) {
218655
+ if (agentData2.canUse && Array.isArray(agentData2.canUse)) {
218439
218656
  for (const canUseItem of agentData2.canUse) {
218440
- agentToolPromises.push(
218657
+ subAgentToolPromises.push(
218441
218658
  (async () => {
218442
218659
  try {
218443
218660
  const { toolId, toolSelection, headers: headers2, agentToolRelationId } = canUseItem;
218444
218661
  const isFunctionTool = typedAgentDefinition.functionTools && toolId in typedAgentDefinition.functionTools;
218445
218662
  if (isFunctionTool) {
218446
- logger13.info({ subAgentId, toolId }, "Processing agent-function tool relation");
218663
+ logger13.info(
218664
+ { subAgentId, toolId },
218665
+ "Processing sub-agent-function tool relation"
218666
+ );
218447
218667
  await upsertSubAgentFunctionToolRelation(db)({
218448
218668
  scopes: { tenantId, projectId, agentId: finalAgentId },
218449
218669
  subAgentId,
@@ -218452,10 +218672,10 @@ var updateFullAgentServerSide = (db, logger13 = defaultLogger) => async (scopes,
218452
218672
  });
218453
218673
  logger13.info(
218454
218674
  { subAgentId, toolId, relationId: agentToolRelationId },
218455
- "Agent-function tool relation upserted"
218675
+ "Sub-agent-function tool relation upserted"
218456
218676
  );
218457
218677
  } else {
218458
- logger13.info({ subAgentId, toolId }, "Processing agent-MCP tool relation");
218678
+ logger13.info({ subAgentId, toolId }, "Processing sub-agent-MCP tool relation");
218459
218679
  await upsertSubAgentToolRelation(db)({
218460
218680
  scopes: { tenantId, projectId, agentId: finalAgentId },
218461
218681
  subAgentId,
@@ -218466,7 +218686,7 @@ var updateFullAgentServerSide = (db, logger13 = defaultLogger) => async (scopes,
218466
218686
  });
218467
218687
  logger13.info(
218468
218688
  { subAgentId, toolId, relationId: agentToolRelationId },
218469
- "Agent-MCP tool relation upserted"
218689
+ "Sub-agent-MCP tool relation upserted"
218470
218690
  );
218471
218691
  }
218472
218692
  } catch (error) {
@@ -218485,10 +218705,10 @@ var updateFullAgentServerSide = (db, logger13 = defaultLogger) => async (scopes,
218485
218705
  }
218486
218706
  }
218487
218707
  }
218488
- await Promise.all(agentToolPromises);
218708
+ await Promise.all(subAgentToolPromises);
218489
218709
  logger13.info(
218490
- { agentToolPromisesCount: agentToolPromises.length },
218491
- "All agent-tool relations updated"
218710
+ { subAgentToolPromisesCount: subAgentToolPromises.length },
218711
+ "All sub-agent-tool relations updated"
218492
218712
  );
218493
218713
  for (const subAgentId of Object.keys(typedAgentDefinition.subAgents)) {
218494
218714
  await deleteAgentDataComponentRelationByAgent(db)({
@@ -218497,7 +218717,7 @@ var updateFullAgentServerSide = (db, logger13 = defaultLogger) => async (scopes,
218497
218717
  }
218498
218718
  const agentDataComponentPromises = [];
218499
218719
  for (const [subAgentId, agentData2] of Object.entries(typedAgentDefinition.subAgents)) {
218500
- if (isInternalAgent(agentData2) && agentData2.dataComponents) {
218720
+ if (agentData2.dataComponents) {
218501
218721
  for (const dataComponentId of agentData2.dataComponents) {
218502
218722
  agentDataComponentPromises.push(
218503
218723
  (async () => {
@@ -218508,12 +218728,12 @@ var updateFullAgentServerSide = (db, logger13 = defaultLogger) => async (scopes,
218508
218728
  });
218509
218729
  logger13.info(
218510
218730
  { subAgentId, dataComponentId },
218511
- "Agent-dataComponent relation created"
218731
+ "Sub-agent-dataComponent relation created"
218512
218732
  );
218513
218733
  } catch (error) {
218514
218734
  logger13.error(
218515
218735
  { subAgentId, dataComponentId, error },
218516
- "Failed to create agent-dataComponent relation"
218736
+ "Failed to create sub-agent-dataComponent relation"
218517
218737
  );
218518
218738
  }
218519
218739
  })()
@@ -218524,7 +218744,7 @@ var updateFullAgentServerSide = (db, logger13 = defaultLogger) => async (scopes,
218524
218744
  await Promise.all(agentDataComponentPromises);
218525
218745
  logger13.info(
218526
218746
  { agentDataComponentPromisesCount: agentDataComponentPromises.length },
218527
- "All agent-dataComponent relations updated"
218747
+ "All sub-agent-dataComponent relations updated"
218528
218748
  );
218529
218749
  for (const subAgentId of Object.keys(typedAgentDefinition.subAgents)) {
218530
218750
  await deleteAgentArtifactComponentRelationByAgent(db)({
@@ -218533,7 +218753,7 @@ var updateFullAgentServerSide = (db, logger13 = defaultLogger) => async (scopes,
218533
218753
  }
218534
218754
  const agentArtifactComponentPromises = [];
218535
218755
  for (const [subAgentId, agentData2] of Object.entries(typedAgentDefinition.subAgents)) {
218536
- if (isInternalAgent(agentData2) && agentData2.artifactComponents) {
218756
+ if (agentData2.artifactComponents) {
218537
218757
  for (const artifactComponentId of agentData2.artifactComponents) {
218538
218758
  agentArtifactComponentPromises.push(
218539
218759
  (async () => {
@@ -218544,12 +218764,12 @@ var updateFullAgentServerSide = (db, logger13 = defaultLogger) => async (scopes,
218544
218764
  });
218545
218765
  logger13.info(
218546
218766
  { subAgentId, artifactComponentId },
218547
- "Agent-artifactComponent relation created"
218767
+ "Sub-agent-artifactComponent relation created"
218548
218768
  );
218549
218769
  } catch (error) {
218550
218770
  logger13.error(
218551
218771
  { subAgentId, artifactComponentId, error },
218552
- "Failed to create agent-artifactComponent relation"
218772
+ "Failed to create sub-agent-artifactComponent relation"
218553
218773
  );
218554
218774
  }
218555
218775
  })()
@@ -218560,83 +218780,110 @@ var updateFullAgentServerSide = (db, logger13 = defaultLogger) => async (scopes,
218560
218780
  await Promise.all(agentArtifactComponentPromises);
218561
218781
  logger13.info(
218562
218782
  { agentArtifactComponentPromisesCount: agentArtifactComponentPromises.length },
218563
- "All agent-artifactComponent relations updated"
218783
+ "All sub-agent-artifactComponent relations updated"
218564
218784
  );
218565
218785
  await deleteAgentRelationsByAgent(db)({
218566
218786
  scopes: { tenantId, projectId, agentId: typedAgentDefinition.id }
218567
218787
  });
218568
- const agentRelationPromises = [];
218788
+ const subAgentRelationPromises = [];
218789
+ const subAgentExternalAgentRelationPromises = [];
218569
218790
  for (const [subAgentId, agentData2] of Object.entries(typedAgentDefinition.subAgents)) {
218570
- if (isInternalAgent(agentData2) && agentData2.canTransferTo) {
218791
+ if (agentData2.canTransferTo) {
218571
218792
  for (const targetSubAgentId of agentData2.canTransferTo) {
218572
- agentRelationPromises.push(
218793
+ subAgentRelationPromises.push(
218573
218794
  (async () => {
218574
218795
  try {
218575
- const targetAgentData = typedAgentDefinition.subAgents[targetSubAgentId];
218576
- const isTargetExternal = isExternalAgent(targetAgentData);
218577
- const targetField = isTargetExternal ? "externalSubAgentId" : "targetSubAgentId";
218578
- const relationData = {
218579
- id: generateId(),
218580
- agentId: typedAgentDefinition.id || "",
218581
- sourceSubAgentId: subAgentId,
218582
- relationType: "transfer",
218583
- [targetField]: targetSubAgentId
218584
- };
218585
218796
  await createSubAgentRelation(db)({
218586
218797
  tenantId,
218587
218798
  projectId,
218588
- ...relationData
218589
- });
218590
- logger13.info(
218591
- { subAgentId, targetSubAgentId, isTargetExternal },
218592
- "Transfer relation created"
218593
- );
218594
- } catch (error) {
218595
- logger13.error(
218596
- { subAgentId, targetSubAgentId, error },
218597
- "Failed to create transfer relation"
218598
- );
218599
- }
218600
- })()
218601
- );
218602
- }
218603
- }
218604
- if (isInternalAgent(agentData2) && agentData2.canDelegateTo) {
218605
- for (const targetSubAgentId of agentData2.canDelegateTo) {
218606
- const targetAgentData = typedAgentDefinition.subAgents[targetSubAgentId];
218607
- const isTargetExternal = isExternalAgent(targetAgentData);
218608
- const targetField = isTargetExternal ? "externalSubAgentId" : "targetSubAgentId";
218609
- agentRelationPromises.push(
218610
- (async () => {
218611
- try {
218612
- const relationData = {
218613
218799
  id: generateId(),
218614
218800
  agentId: typedAgentDefinition.id || "",
218615
218801
  sourceSubAgentId: subAgentId,
218616
- relationType: "delegate",
218617
- [targetField]: targetSubAgentId
218618
- };
218619
- await createSubAgentRelation(db)({
218620
- tenantId,
218621
- projectId,
218622
- ...relationData
218802
+ targetSubAgentId,
218803
+ relationType: "transfer"
218623
218804
  });
218624
- logger13.info({ subAgentId, targetSubAgentId }, "Delegation relation created");
218805
+ logger13.info({ subAgentId, targetSubAgentId }, "Transfer relation created");
218625
218806
  } catch (error) {
218626
218807
  logger13.error(
218627
218808
  { subAgentId, targetSubAgentId, error },
218628
- "Failed to create delegation relation"
218809
+ "Failed to create transfer relation"
218629
218810
  );
218630
218811
  }
218631
218812
  })()
218632
218813
  );
218633
218814
  }
218634
218815
  }
218816
+ if (agentData2.canDelegateTo) {
218817
+ for (const targetItem of agentData2.canDelegateTo) {
218818
+ if (typeof targetItem === "string") {
218819
+ subAgentRelationPromises.push(
218820
+ (async () => {
218821
+ try {
218822
+ await createSubAgentRelation(db)({
218823
+ tenantId,
218824
+ projectId,
218825
+ id: generateId(),
218826
+ agentId: typedAgentDefinition.id || "",
218827
+ sourceSubAgentId: subAgentId,
218828
+ targetSubAgentId: targetItem,
218829
+ relationType: "delegate"
218830
+ });
218831
+ logger13.info(
218832
+ { subAgentId, targetSubAgentId: targetItem },
218833
+ "Sub-agent delegation relation created"
218834
+ );
218835
+ } catch (error) {
218836
+ logger13.error(
218837
+ { subAgentId, targetSubAgentId: targetItem, error },
218838
+ "Failed to create sub-agent delegation relation"
218839
+ );
218840
+ }
218841
+ })()
218842
+ );
218843
+ } else {
218844
+ subAgentExternalAgentRelationPromises.push(
218845
+ (async () => {
218846
+ try {
218847
+ await upsertSubAgentExternalAgentRelation(db)({
218848
+ scopes: {
218849
+ tenantId,
218850
+ projectId,
218851
+ agentId: typedAgentDefinition.id || "",
218852
+ subAgentId
218853
+ },
218854
+ relationId: targetItem.subAgentExternalAgentRelationId,
218855
+ data: {
218856
+ externalAgentId: targetItem.externalAgentId,
218857
+ headers: targetItem.headers || null
218858
+ }
218859
+ });
218860
+ logger13.info(
218861
+ { subAgentId, externalAgentId: targetItem.externalAgentId },
218862
+ "External delegation relation created"
218863
+ );
218864
+ } catch (error) {
218865
+ logger13.error(
218866
+ { subAgentId, externalAgentId: targetItem.externalAgentId, error },
218867
+ "Failed to create external delegation relation"
218868
+ );
218869
+ }
218870
+ })()
218871
+ );
218872
+ }
218873
+ }
218874
+ }
218635
218875
  }
218636
- await Promise.all(agentRelationPromises);
218876
+ await Promise.all(subAgentRelationPromises);
218877
+ logger13.info(
218878
+ { subAgentRelationPromisesCount: subAgentRelationPromises.length },
218879
+ "All sub-agent relations updated"
218880
+ );
218881
+ await Promise.all(subAgentExternalAgentRelationPromises);
218637
218882
  logger13.info(
218638
- { agentRelationPromisesCount: agentRelationPromises.length },
218639
- "All agent relations updated"
218883
+ {
218884
+ subAgentExternalAgentRelationPromisesCount: subAgentExternalAgentRelationPromises.length
218885
+ },
218886
+ "All sub-agent external agent relations updated"
218640
218887
  );
218641
218888
  const updatedAgent = await getFullAgentDefinition(db)({
218642
218889
  scopes: { tenantId, projectId, agentId: typedAgentDefinition.id }
@@ -219443,6 +219690,50 @@ var createFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
219443
219690
  "All project tools created successfully"
219444
219691
  );
219445
219692
  }
219693
+ if (typed.externalAgents && Object.keys(typed.externalAgents).length > 0) {
219694
+ logger13.info(
219695
+ {
219696
+ projectId: typed.id,
219697
+ count: Object.keys(typed.externalAgents).length
219698
+ },
219699
+ "Creating project externalAgents"
219700
+ );
219701
+ const externalAgentPromises = Object.entries(typed.externalAgents).map(
219702
+ async ([externalAgentId, externalAgentData]) => {
219703
+ try {
219704
+ logger13.info(
219705
+ { projectId: typed.id, externalAgentId },
219706
+ "Creating externalAgent in project"
219707
+ );
219708
+ await upsertExternalAgent(db)({
219709
+ data: {
219710
+ ...externalAgentData,
219711
+ tenantId,
219712
+ projectId: typed.id
219713
+ }
219714
+ });
219715
+ logger13.info(
219716
+ { projectId: typed.id, externalAgentId },
219717
+ "ExternalAgent created successfully"
219718
+ );
219719
+ } catch (error) {
219720
+ logger13.error(
219721
+ { projectId: typed.id, externalAgentId, error },
219722
+ "Failed to create externalAgent in project"
219723
+ );
219724
+ throw error;
219725
+ }
219726
+ }
219727
+ );
219728
+ await Promise.all(externalAgentPromises);
219729
+ logger13.info(
219730
+ {
219731
+ projectId: typed.id,
219732
+ count: Object.keys(typed.externalAgents).length
219733
+ },
219734
+ "All project externalAgents created successfully"
219735
+ );
219736
+ }
219446
219737
  if (typed.dataComponents && Object.keys(typed.dataComponents).length > 0) {
219447
219738
  logger13.info(
219448
219739
  {
@@ -219550,6 +219841,8 @@ var createFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
219550
219841
  // Pass project-level functions for validation
219551
219842
  dataComponents: typed.dataComponents || {},
219552
219843
  artifactComponents: typed.artifactComponents || {},
219844
+ externalAgents: typed.externalAgents || {},
219845
+ // Pass project-level external agents
219553
219846
  credentialReferences: typed.credentialReferences || {},
219554
219847
  statusUpdates: agentData.statusUpdates === null ? void 0 : agentData.statusUpdates
219555
219848
  };
@@ -219751,6 +220044,50 @@ var updateFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
219751
220044
  "All project tools updated successfully"
219752
220045
  );
219753
220046
  }
220047
+ if (typed.externalAgents && Object.keys(typed.externalAgents).length > 0) {
220048
+ logger13.info(
220049
+ {
220050
+ projectId: typed.id,
220051
+ count: Object.keys(typed.externalAgents).length
220052
+ },
220053
+ "Updating project externalAgents"
220054
+ );
220055
+ const externalAgentPromises = Object.entries(typed.externalAgents).map(
220056
+ async ([externalAgentId, externalAgentData]) => {
220057
+ try {
220058
+ logger13.info(
220059
+ { projectId: typed.id, externalAgentId },
220060
+ "Updating externalAgent in project"
220061
+ );
220062
+ await upsertExternalAgent(db)({
220063
+ data: {
220064
+ ...externalAgentData,
220065
+ tenantId,
220066
+ projectId: typed.id
220067
+ }
220068
+ });
220069
+ logger13.info(
220070
+ { projectId: typed.id, externalAgentId },
220071
+ "ExternalAgent updated successfully"
220072
+ );
220073
+ } catch (error) {
220074
+ logger13.error(
220075
+ { projectId: typed.id, externalAgentId, error },
220076
+ "Failed to update externalAgent in project"
220077
+ );
220078
+ throw error;
220079
+ }
220080
+ }
220081
+ );
220082
+ await Promise.all(externalAgentPromises);
220083
+ logger13.info(
220084
+ {
220085
+ projectId: typed.id,
220086
+ count: Object.keys(typed.externalAgents).length
220087
+ },
220088
+ "All project externalAgents updated successfully"
220089
+ );
220090
+ }
219754
220091
  if (typed.dataComponents && Object.keys(typed.dataComponents).length > 0) {
219755
220092
  logger13.info(
219756
220093
  {
@@ -219891,6 +220228,8 @@ var updateFullProjectServerSide = (db, logger13 = defaultLogger2) => async (scop
219891
220228
  // Pass project-level functions for validation
219892
220229
  dataComponents: typed.dataComponents || {},
219893
220230
  artifactComponents: typed.artifactComponents || {},
220231
+ externalAgents: typed.externalAgents || {},
220232
+ // Pass project-level external agents
219894
220233
  credentialReferences: typed.credentialReferences || {},
219895
220234
  statusUpdates: agentData.statusUpdates === null ? void 0 : agentData.statusUpdates
219896
220235
  };
@@ -219984,6 +220323,30 @@ var getFullProject = (db, logger13 = defaultLogger2) => async (params) => {
219984
220323
  } catch (error) {
219985
220324
  logger13.warn({ tenantId, projectId, error }, "Failed to retrieve tools for project");
219986
220325
  }
220326
+ const projectExternalAgents = {};
220327
+ try {
220328
+ const externalAgentsList = await listExternalAgents(db)({
220329
+ scopes: { tenantId, projectId }
220330
+ });
220331
+ for (const externalAgent of externalAgentsList) {
220332
+ projectExternalAgents[externalAgent.id] = {
220333
+ id: externalAgent.id,
220334
+ name: externalAgent.name,
220335
+ description: externalAgent.description,
220336
+ baseUrl: externalAgent.baseUrl,
220337
+ credentialReferenceId: externalAgent.credentialReferenceId || void 0
220338
+ };
220339
+ }
220340
+ logger13.info(
220341
+ { tenantId, projectId, count: Object.keys(projectExternalAgents).length },
220342
+ "ExternalAgents retrieved for project"
220343
+ );
220344
+ } catch (error) {
220345
+ logger13.warn(
220346
+ { tenantId, projectId, error },
220347
+ "Failed to retrieve externalAgents for project"
220348
+ );
220349
+ }
219987
220350
  const projectDataComponents = {};
219988
220351
  try {
219989
220352
  const dataComponentsList = await listDataComponents(db)({
@@ -220095,6 +220458,7 @@ var getFullProject = (db, logger13 = defaultLogger2) => async (params) => {
220095
220458
  stopWhen: project.stopWhen || void 0,
220096
220459
  agents: agents2,
220097
220460
  tools: projectTools,
220461
+ externalAgents: projectExternalAgents,
220098
220462
  dataComponents: projectDataComponents,
220099
220463
  artifactComponents: projectArtifactComponents,
220100
220464
  credentialReferences: projectCredentialReferences,
@@ -222536,4 +222900,4 @@ typescript/lib/typescript.js:
222536
222900
  ***************************************************************************** *)
222537
222901
  */
222538
222902
 
222539
- export { ContextCache, ContextConfigBuilder, ContextFetcher, ContextResolver, CredentialStoreRegistry, CredentialStuffer, ERROR_DOCS_BASE_URL, ErrorCode, HTTP_REQUEST_PARTS, InMemoryCredentialStore, KeyChainStore, McpClient, NangoCredentialStore, TemplateEngine, addFunctionToolToSubAgent, addLedgerArtifacts, addToolToAgent, agentHasArtifactComponents, apiFetch, associateArtifactComponentWithAgent, associateDataComponentWithAgent, cleanupTenantCache, clearContextConfigCache, clearConversationCache, commonCreateErrorResponses, commonDeleteErrorResponses, commonGetErrorResponses, commonUpdateErrorResponses, contextConfig, contextValidationMiddleware, countApiKeys, countArtifactComponents, countArtifactComponentsForAgent, countContextConfigs, countCredentialReferences, countDataComponents, countExternalAgents, countLedgerArtifactsByTask, countMessagesByConversation, countProjects, createAgent, createAgentToolRelation, createApiError, createApiKey, createArtifactComponent, createContextConfig, createConversation, createCredentialReference, createDataComponent, createDatabaseClient, createDefaultCredentialStores, createExecutionContext, createExternalAgent, createExternalAgentRelation, createFullAgentServerSide, createFullProjectServerSide, createFunctionTool, createInMemoryDatabaseClient, createKeyChainStore, createMessage, createNangoCredentialStore, createOrGetConversation, createProject, createSubAgent, createSubAgentRelation, createTask, createTool, createValidatedDataAccess, dbResultToMcpTool, deleteAgent, deleteAgentArtifactComponentRelationByAgent, deleteAgentDataComponentRelationByAgent, deleteAgentRelationsByAgent, deleteAgentToolRelation, deleteAgentToolRelationByAgent, deleteApiKey, deleteArtifactComponent, deleteContextConfig, deleteConversation, deleteCredentialReference, deleteDataComponent, deleteExternalAgent, deleteFullAgent, deleteFullProject, deleteFunction, deleteFunctionTool, deleteLedgerArtifactsByContext, deleteLedgerArtifactsByTask, deleteMessage, deleteProject, deleteSubAgent, deleteSubAgentRelation, deleteTool, determineContextTrigger, errorResponseSchema, errorSchemaFactory, externalAgentExists, externalAgentUrlExists, extractPublicId, fetchComponentRelationships, fetchDefinition, generateAndCreateApiKey, generateApiKey, generateId, getActiveAgentForConversation, getAgentById, getAgentRelationById, getAgentRelationByParams, getAgentRelations, getAgentRelationsByAgent, getAgentRelationsBySource, getAgentSubAgentInfos, getAgentToolRelationByAgent, getAgentToolRelationById, getAgentToolRelationByTool, getAgentWithDefaultSubAgent, getAgentsForTool, getAgentsUsingArtifactComponent, getAgentsUsingDataComponent, getApiKeyById, getApiKeyByPublicId, getArtifactComponentById, getArtifactComponentsForAgent, getCacheEntry, getCachedValidator, getContextConfigById, getContextConfigCacheEntries, getConversation, getConversationCacheEntries, getConversationHistory, getConversationId, getCredentialReference, getCredentialReferenceById, getCredentialReferenceWithTools, getCredentialStoreLookupKeyFromRetrievalParams, getDataComponent, getDataComponentsForAgent, getExternalAgent, getExternalAgentByUrl, getExternalAgentRelations, getFullAgent, getFullAgentDefinition, getFullProject, getFunction, getFunctionToolById, getFunctionToolsForSubAgent, getLedgerArtifacts, getLedgerArtifactsByContext, getMessageById, getMessagesByConversation, getMessagesByTask, getProject, getProjectResourceCounts, getRelatedAgentsForAgent, getRequestExecutionContext, getSubAgentById, getSubAgentRelationsByTarget, getSubAgentsByIds, getTask, getToolById, getToolsForAgent, getTracer, getVisibleMessages, handleApiError, handleContextConfigChange, handleContextResolution, hasApiKey, hasContextConfig, hasCredentialReference, hashApiKey, headers, invalidateHeadersCache, invalidateInvocationDefinitionsCache, isApiKeyExpired, isArtifactComponentAssociatedWithAgent, isDataComponentAssociatedWithAgent, isValidHttpRequest, listAgentRelations, listAgentToolRelations, listAgents, listAgentsPaginated, listApiKeys, listApiKeysPaginated, listArtifactComponents, listArtifactComponentsPaginated, listContextConfigs, listContextConfigsPaginated, listConversations, listCredentialReferences, listCredentialReferencesPaginated, listDataComponents, listDataComponentsPaginated, listExternalAgents, listExternalAgentsPaginated, listFunctionTools, listFunctions, listMessages, listProjects, listProjectsPaginated, listSubAgents, listSubAgentsPaginated, listTaskIdsByContextId, listTools, loadEnvironmentFiles, maskApiKey, problemDetailsSchema, projectExists, projectExistsInTable, projectHasResources, removeArtifactComponentFromAgent, removeDataComponentFromAgent, removeToolFromAgent, setActiveAgentForConversation, setActiveAgentForThread, setCacheEntry, setSpanWithError, updateAgent, updateAgentRelation, updateAgentToolRelation, updateApiKey, updateApiKeyLastUsed, updateArtifactComponent, updateContextConfig, updateConversation, updateConversationActiveAgent, updateCredentialReference, updateDataComponent, updateExternalAgent, updateFullAgentServerSide, updateFullProjectServerSide, updateFunctionTool, updateMessage, updateProject, updateSubAgent, updateSubAgentFunctionToolRelation, updateTask, updateTool, upsertAgent, upsertAgentArtifactComponentRelation, upsertAgentDataComponentRelation, upsertArtifactComponent, upsertContextConfig, upsertCredentialReference, upsertDataComponent, upsertExternalAgent, upsertFunction, upsertFunctionTool, upsertLedgerArtifact, upsertSubAgent, upsertSubAgentFunctionToolRelation, upsertSubAgentRelation, upsertSubAgentToolRelation, upsertTool, validateAgainstJsonSchema, validateAndGetApiKey, validateApiKey, validateExternalAgent, validateHeaders, validateHttpRequestHeaders, validateInternalSubAgent, validateProjectExists, validationHelper, withProjectValidation };
222903
+ export { ContextCache, ContextConfigBuilder, ContextFetcher, ContextResolver, CredentialStoreRegistry, CredentialStuffer, ERROR_DOCS_BASE_URL, ErrorCode, HTTP_REQUEST_PARTS, InMemoryCredentialStore, KeyChainStore, McpClient, NangoCredentialStore, TemplateEngine, addFunctionToolToSubAgent, addLedgerArtifacts, addToolToAgent, agentHasArtifactComponents, apiFetch, associateArtifactComponentWithAgent, associateDataComponentWithAgent, cleanupTenantCache, clearContextConfigCache, clearConversationCache, commonCreateErrorResponses, commonDeleteErrorResponses, commonGetErrorResponses, commonUpdateErrorResponses, contextConfig, contextValidationMiddleware, countApiKeys, countArtifactComponents, countArtifactComponentsForAgent, countContextConfigs, countCredentialReferences, countDataComponents, countExternalAgents, countLedgerArtifactsByTask, countMessagesByConversation, countProjects, createAgent, createAgentToolRelation, createApiError, createApiKey, createArtifactComponent, createContextConfig, createConversation, createCredentialReference, createDataComponent, createDatabaseClient, createDefaultCredentialStores, createExecutionContext, createExternalAgent, createFullAgentServerSide, createFullProjectServerSide, createFunctionTool, createInMemoryDatabaseClient, createKeyChainStore, createMessage, createNangoCredentialStore, createOrGetConversation, createProject, createSubAgent, createSubAgentExternalAgentRelation, createSubAgentRelation, createTask, createTool, createValidatedDataAccess, dbResultToMcpTool, deleteAgent, deleteAgentArtifactComponentRelationByAgent, deleteAgentDataComponentRelationByAgent, deleteAgentRelationsByAgent, deleteAgentToolRelation, deleteAgentToolRelationByAgent, deleteApiKey, deleteArtifactComponent, deleteContextConfig, deleteConversation, deleteCredentialReference, deleteDataComponent, deleteExternalAgent, deleteFullAgent, deleteFullProject, deleteFunction, deleteFunctionTool, deleteLedgerArtifactsByContext, deleteLedgerArtifactsByTask, deleteMessage, deleteProject, deleteSubAgent, deleteSubAgentExternalAgentRelation, deleteSubAgentExternalAgentRelationsByAgent, deleteSubAgentExternalAgentRelationsBySubAgent, deleteSubAgentRelation, deleteTool, determineContextTrigger, errorResponseSchema, errorSchemaFactory, externalAgentExists, externalAgentUrlExists, extractPublicId, fetchComponentRelationships, fetchDefinition, generateAndCreateApiKey, generateApiKey, generateId, getActiveAgentForConversation, getAgentById, getAgentRelationById, getAgentRelationByParams, getAgentRelations, getAgentRelationsByAgent, getAgentRelationsBySource, getAgentSubAgentInfos, getAgentToolRelationByAgent, getAgentToolRelationById, getAgentToolRelationByTool, getAgentWithDefaultSubAgent, getAgentsForTool, getAgentsUsingArtifactComponent, getAgentsUsingDataComponent, getApiKeyById, getApiKeyByPublicId, getArtifactComponentById, getArtifactComponentsForAgent, getCacheEntry, getCachedValidator, getContextConfigById, getContextConfigCacheEntries, getConversation, getConversationCacheEntries, getConversationHistory, getConversationId, getCredentialReference, getCredentialReferenceById, getCredentialReferenceWithResources, getCredentialStoreLookupKeyFromRetrievalParams, getDataComponent, getDataComponentsForAgent, getExternalAgent, getExternalAgentByUrl, getExternalAgentsForSubAgent, getFullAgent, getFullAgentDefinition, getFullProject, getFunction, getFunctionToolById, getFunctionToolsForSubAgent, getLedgerArtifacts, getLedgerArtifactsByContext, getMessageById, getMessagesByConversation, getMessagesByTask, getProject, getProjectResourceCounts, getRelatedAgentsForAgent, getRequestExecutionContext, getSubAgentById, getSubAgentExternalAgentRelationById, getSubAgentExternalAgentRelationByParams, getSubAgentExternalAgentRelations, getSubAgentExternalAgentRelationsByAgent, getSubAgentExternalAgentRelationsByExternalAgent, getSubAgentRelationsByTarget, getSubAgentsByIds, getSubAgentsForExternalAgent, getTask, getToolById, getToolsForAgent, getTracer, getVisibleMessages, handleApiError, handleContextConfigChange, handleContextResolution, hasApiKey, hasContextConfig, hasCredentialReference, hashApiKey, headers, invalidateHeadersCache, invalidateInvocationDefinitionsCache, isApiKeyExpired, isArtifactComponentAssociatedWithAgent, isDataComponentAssociatedWithAgent, isValidHttpRequest, listAgentRelations, listAgentToolRelations, listAgents, listAgentsPaginated, listApiKeys, listApiKeysPaginated, listArtifactComponents, listArtifactComponentsPaginated, listContextConfigs, listContextConfigsPaginated, listConversations, listCredentialReferences, listCredentialReferencesPaginated, listDataComponents, listDataComponentsPaginated, listExternalAgents, listExternalAgentsPaginated, listFunctionTools, listFunctions, listMessages, listProjects, listProjectsPaginated, listSubAgentExternalAgentRelations, listSubAgents, listSubAgentsPaginated, listTaskIdsByContextId, listTools, loadEnvironmentFiles, maskApiKey, problemDetailsSchema, projectExists, projectExistsInTable, projectHasResources, removeArtifactComponentFromAgent, removeDataComponentFromAgent, removeToolFromAgent, setActiveAgentForConversation, setActiveAgentForThread, setCacheEntry, setSpanWithError, updateAgent, updateAgentRelation, updateAgentToolRelation, updateApiKey, updateApiKeyLastUsed, updateArtifactComponent, updateContextConfig, updateConversation, updateConversationActiveAgent, updateCredentialReference, updateDataComponent, updateExternalAgent, updateFullAgentServerSide, updateFullProjectServerSide, updateFunctionTool, updateMessage, updateProject, updateSubAgent, updateSubAgentExternalAgentRelation, updateSubAgentFunctionToolRelation, updateTask, updateTool, upsertAgent, upsertAgentArtifactComponentRelation, upsertAgentDataComponentRelation, upsertArtifactComponent, upsertContextConfig, upsertCredentialReference, upsertDataComponent, upsertExternalAgent, upsertFunction, upsertFunctionTool, upsertLedgerArtifact, upsertSubAgent, upsertSubAgentExternalAgentRelation, upsertSubAgentFunctionToolRelation, upsertSubAgentRelation, upsertSubAgentToolRelation, upsertTool, validateAgainstJsonSchema, validateAndGetApiKey, validateApiKey, validateHeaders, validateHttpRequestHeaders, validateProjectExists, validateSubAgent, validationHelper, withProjectValidation };