@inkeep/agents-cli 0.0.0-dev-20251021164445 → 0.0.0-dev-20251021181503

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +821 -558
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -21,11 +21,11 @@ var __export = (target, all) => {
21
21
  for (var name in all)
22
22
  __defProp(target, name, { get: all[name], enumerable: true });
23
23
  };
24
- var __copyProps = (to, from, except, desc15) => {
24
+ var __copyProps = (to, from, except, desc16) => {
25
25
  if (from && typeof from === "object" || typeof from === "function") {
26
26
  for (let key of __getOwnPropNames(from))
27
27
  if (!__hasOwnProp.call(to, key) && key !== except)
28
- __defProp(to, key, { get: () => from[key], enumerable: !(desc15 = __getOwnPropDesc(from, key)) || desc15.enumerable });
28
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc16 = __getOwnPropDesc(from, key)) || desc16.enumerable });
29
29
  }
30
30
  return to;
31
31
  };
@@ -1584,7 +1584,7 @@ import {
1584
1584
  text,
1585
1585
  unique
1586
1586
  } from "drizzle-orm/sqlite-core";
1587
- var tenantScoped, projectScoped, agentScoped, subAgentScoped, uiProperties, timestamps, projects, agents, contextConfigs, contextCache, subAgents, subAgentRelations, externalAgents, tasks, taskRelations, dataComponents, subAgentDataComponents, artifactComponents, subAgentArtifactComponents, tools, functionTools, functions, subAgentToolRelations, subAgentFunctionToolRelations, conversations, messages, ledgerArtifacts, apiKeys, credentialReferences, tasksRelations, projectsRelations, taskRelationsRelations, contextConfigsRelations, contextCacheRelations, subAgentsRelations, agentRelations, externalAgentsRelations, apiKeysRelations, agentToolRelationsRelations, credentialReferencesRelations, toolsRelations, conversationsRelations, messagesRelations, artifactComponentsRelations, subAgentArtifactComponentsRelations, dataComponentsRelations, subAgentDataComponentsRelations, ledgerArtifactsRelations, functionsRelations, subAgentRelationsRelations, functionToolsRelations, subAgentFunctionToolRelationsRelations;
1587
+ var tenantScoped, projectScoped, agentScoped, subAgentScoped, uiProperties, timestamps, projects, agents, contextConfigs, contextCache, subAgents, subAgentRelations, externalAgents, tasks, taskRelations, dataComponents, subAgentDataComponents, artifactComponents, subAgentArtifactComponents, tools, functionTools, functions, subAgentToolRelations, subAgentExternalAgentRelations, subAgentFunctionToolRelations, conversations, messages, ledgerArtifacts, apiKeys, credentialReferences, tasksRelations, projectsRelations, taskRelationsRelations, contextConfigsRelations, contextCacheRelations, subAgentsRelations, agentRelations, externalAgentsRelations, apiKeysRelations, agentToolRelationsRelations, credentialReferencesRelations, toolsRelations, conversationsRelations, messagesRelations, artifactComponentsRelations, subAgentArtifactComponentsRelations, dataComponentsRelations, subAgentDataComponentsRelations, ledgerArtifactsRelations, functionsRelations, subAgentRelationsRelations, functionToolsRelations, subAgentFunctionToolRelationsRelations, subAgentExternalAgentRelationsRelations;
1588
1588
  var init_schema = __esm({
1589
1589
  "../packages/agents-core/src/db/schema.ts"() {
1590
1590
  "use strict";
@@ -1720,7 +1720,6 @@ var init_schema = __esm({
1720
1720
  ...agentScoped,
1721
1721
  sourceSubAgentId: text("source_sub_agent_id").notNull(),
1722
1722
  targetSubAgentId: text("target_sub_agent_id"),
1723
- externalSubAgentId: text("external_sub_agent_id"),
1724
1723
  relationType: text("relation_type"),
1725
1724
  ...timestamps
1726
1725
  },
@@ -1736,19 +1735,18 @@ var init_schema = __esm({
1736
1735
  externalAgents = sqliteTable(
1737
1736
  "external_agents",
1738
1737
  {
1739
- ...agentScoped,
1738
+ ...projectScoped,
1740
1739
  ...uiProperties,
1741
1740
  baseUrl: text("base_url").notNull(),
1742
1741
  credentialReferenceId: text("credential_reference_id"),
1743
- headers: blob("headers", { mode: "json" }).$type(),
1744
1742
  ...timestamps
1745
1743
  },
1746
1744
  (table) => [
1747
- primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
1745
+ primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
1748
1746
  foreignKey({
1749
- columns: [table.tenantId, table.projectId, table.agentId],
1750
- foreignColumns: [agents.tenantId, agents.projectId, agents.id],
1751
- name: "external_agents_agent_fk"
1747
+ columns: [table.tenantId, table.projectId],
1748
+ foreignColumns: [projects.tenantId, projects.id],
1749
+ name: "external_agents_project_fk"
1752
1750
  }).onDelete("cascade"),
1753
1751
  foreignKey({
1754
1752
  columns: [table.tenantId, table.projectId, table.credentialReferenceId],
@@ -1967,6 +1965,28 @@ var init_schema = __esm({
1967
1965
  }).onDelete("cascade")
1968
1966
  ]
1969
1967
  );
1968
+ subAgentExternalAgentRelations = sqliteTable(
1969
+ "sub_agent_external_agent_relations",
1970
+ {
1971
+ ...subAgentScoped,
1972
+ externalAgentId: text("external_agent_id").notNull(),
1973
+ headers: blob("headers", { mode: "json" }).$type(),
1974
+ ...timestamps
1975
+ },
1976
+ (table) => [
1977
+ primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
1978
+ foreignKey({
1979
+ columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
1980
+ foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
1981
+ name: "sub_agent_external_agent_relations_sub_agent_fk"
1982
+ }).onDelete("cascade"),
1983
+ foreignKey({
1984
+ columns: [table.tenantId, table.projectId, table.externalAgentId],
1985
+ foreignColumns: [externalAgents.tenantId, externalAgents.projectId, externalAgents.id],
1986
+ name: "sub_agent_external_agent_relations_external_agent_fk"
1987
+ }).onDelete("cascade")
1988
+ ]
1989
+ );
1970
1990
  subAgentFunctionToolRelations = sqliteTable(
1971
1991
  "sub_agent_function_tool_relations",
1972
1992
  {
@@ -2228,7 +2248,7 @@ var init_schema = __esm({
2228
2248
  fields: [externalAgents.tenantId, externalAgents.projectId],
2229
2249
  references: [projects.tenantId, projects.id]
2230
2250
  }),
2231
- subAgentRelations: many(subAgentRelations),
2251
+ subAgentExternalAgentRelations: many(subAgentExternalAgentRelations),
2232
2252
  credentialReference: one(credentialReferences, {
2233
2253
  fields: [externalAgents.credentialReferenceId],
2234
2254
  references: [credentialReferences.id]
@@ -2300,13 +2320,13 @@ var init_schema = __esm({
2300
2320
  relationName: "receivedMessages"
2301
2321
  }),
2302
2322
  fromExternalAgent: one(externalAgents, {
2303
- fields: [messages.fromExternalAgentId],
2304
- references: [externalAgents.id],
2323
+ fields: [messages.tenantId, messages.projectId, messages.fromExternalAgentId],
2324
+ references: [externalAgents.tenantId, externalAgents.projectId, externalAgents.id],
2305
2325
  relationName: "receivedExternalMessages"
2306
2326
  }),
2307
2327
  toExternalAgent: one(externalAgents, {
2308
- fields: [messages.toExternalAgentId],
2309
- references: [externalAgents.id],
2328
+ fields: [messages.tenantId, messages.projectId, messages.toExternalAgentId],
2329
+ references: [externalAgents.tenantId, externalAgents.projectId, externalAgents.id],
2310
2330
  relationName: "sentExternalMessages"
2311
2331
  }),
2312
2332
  task: one(tasks, {
@@ -2390,10 +2410,6 @@ var init_schema = __esm({
2390
2410
  fields: [subAgentRelations.targetSubAgentId],
2391
2411
  references: [subAgents.id],
2392
2412
  relationName: "targetRelations"
2393
- }),
2394
- externalAgent: one(externalAgents, {
2395
- fields: [subAgentRelations.externalSubAgentId],
2396
- references: [externalAgents.id]
2397
2413
  })
2398
2414
  }));
2399
2415
  functionToolsRelations = relations(functionTools, ({ one, many }) => ({
@@ -2424,6 +2440,28 @@ var init_schema = __esm({
2424
2440
  })
2425
2441
  })
2426
2442
  );
2443
+ subAgentExternalAgentRelationsRelations = relations(
2444
+ subAgentExternalAgentRelations,
2445
+ ({ one }) => ({
2446
+ subAgent: one(subAgents, {
2447
+ fields: [
2448
+ subAgentExternalAgentRelations.tenantId,
2449
+ subAgentExternalAgentRelations.projectId,
2450
+ subAgentExternalAgentRelations.agentId,
2451
+ subAgentExternalAgentRelations.subAgentId
2452
+ ],
2453
+ references: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id]
2454
+ }),
2455
+ externalAgent: one(externalAgents, {
2456
+ fields: [
2457
+ subAgentExternalAgentRelations.tenantId,
2458
+ subAgentExternalAgentRelations.projectId,
2459
+ subAgentExternalAgentRelations.externalAgentId
2460
+ ],
2461
+ references: [externalAgents.tenantId, externalAgents.projectId, externalAgents.id]
2462
+ })
2463
+ })
2464
+ );
2427
2465
  }
2428
2466
  });
2429
2467
 
@@ -2452,7 +2490,7 @@ var init_utility = __esm({
2452
2490
  });
2453
2491
 
2454
2492
  // ../packages/agents-core/src/validation/schemas.ts
2455
- var StopWhenSchema, AgentStopWhenSchema, SubAgentStopWhenSchema, MIN_ID_LENGTH, MAX_ID_LENGTH, URL_SAFE_ID_PATTERN, resourceIdSchema, ModelSettingsSchema, ModelSchema, ProjectModelSchema, FunctionToolConfigSchema, createApiSchema, createApiInsertSchema, createApiUpdateSchema, createAgentScopedApiSchema, createAgentScopedApiInsertSchema, createAgentScopedApiUpdateSchema, SubAgentSelectSchema, SubAgentInsertSchema, SubAgentUpdateSchema, SubAgentApiSelectSchema, SubAgentApiInsertSchema, SubAgentApiUpdateSchema, SubAgentRelationSelectSchema, SubAgentRelationInsertSchema, SubAgentRelationUpdateSchema, SubAgentRelationApiSelectSchema, SubAgentRelationApiInsertSchema, SubAgentRelationApiUpdateSchema, SubAgentRelationQuerySchema, ExternalSubAgentRelationInsertSchema, ExternalSubAgentRelationApiInsertSchema, AgentSelectSchema, AgentInsertSchema, AgentUpdateSchema, AgentApiSelectSchema, AgentApiInsertSchema, AgentApiUpdateSchema, TaskSelectSchema, TaskInsertSchema, TaskUpdateSchema, TaskApiSelectSchema, TaskApiInsertSchema, TaskApiUpdateSchema, TaskRelationSelectSchema, TaskRelationInsertSchema, TaskRelationUpdateSchema, TaskRelationApiSelectSchema, TaskRelationApiInsertSchema, TaskRelationApiUpdateSchema, imageUrlSchema, McpTransportConfigSchema, ToolStatusSchema, McpToolDefinitionSchema, ToolSelectSchema, ToolInsertSchema, ConversationSelectSchema, ConversationInsertSchema, ConversationUpdateSchema, ConversationApiSelectSchema, ConversationApiInsertSchema, ConversationApiUpdateSchema, MessageSelectSchema, MessageInsertSchema, MessageUpdateSchema, MessageApiSelectSchema, MessageApiInsertSchema, MessageApiUpdateSchema, ContextCacheSelectSchema, ContextCacheInsertSchema, ContextCacheUpdateSchema, ContextCacheApiSelectSchema, ContextCacheApiInsertSchema, ContextCacheApiUpdateSchema, DataComponentSelectSchema, DataComponentInsertSchema, DataComponentBaseSchema, DataComponentUpdateSchema, DataComponentApiSelectSchema, DataComponentApiInsertSchema, DataComponentApiUpdateSchema, SubAgentDataComponentSelectSchema, SubAgentDataComponentInsertSchema, SubAgentDataComponentUpdateSchema, SubAgentDataComponentApiSelectSchema, SubAgentDataComponentApiInsertSchema, SubAgentDataComponentApiUpdateSchema, ArtifactComponentSelectSchema, ArtifactComponentInsertSchema, ArtifactComponentUpdateSchema, ArtifactComponentApiSelectSchema, ArtifactComponentApiInsertSchema, ArtifactComponentApiUpdateSchema, SubAgentArtifactComponentSelectSchema, SubAgentArtifactComponentInsertSchema, SubAgentArtifactComponentUpdateSchema, SubAgentArtifactComponentApiSelectSchema, SubAgentArtifactComponentApiInsertSchema, SubAgentArtifactComponentApiUpdateSchema, ExternalAgentSelectSchema, ExternalAgentInsertSchema, ExternalAgentUpdateSchema, ExternalAgentApiSelectSchema, ExternalAgentApiInsertSchema, ExternalAgentApiUpdateSchema, AllAgentSchema, ApiKeySelectSchema, ApiKeyInsertSchema, ApiKeyUpdateSchema, ApiKeyApiSelectSchema, ApiKeyApiCreationResponseSchema, ApiKeyApiInsertSchema, ApiKeyApiUpdateSchema, CredentialReferenceSelectSchema, CredentialReferenceInsertSchema, CredentialReferenceUpdateSchema, CredentialReferenceApiSelectSchema, CredentialReferenceApiInsertSchema, CredentialReferenceApiUpdateSchema, McpToolSchema, MCPToolConfigSchema, ToolUpdateSchema, ToolApiSelectSchema, ToolApiInsertSchema, ToolApiUpdateSchema, FunctionToolSelectSchema, FunctionToolInsertSchema, FunctionToolUpdateSchema, FunctionToolApiSelectSchema, FunctionToolApiInsertSchema, FunctionToolApiUpdateSchema, FunctionSelectSchema, FunctionInsertSchema, FunctionUpdateSchema, FunctionApiSelectSchema, FunctionApiInsertSchema, FunctionApiUpdateSchema, FetchConfigSchema, FetchDefinitionSchema, ContextConfigSelectSchema, ContextConfigInsertSchema, ContextConfigUpdateSchema, ContextConfigApiSelectSchema, ContextConfigApiInsertSchema, ContextConfigApiUpdateSchema, SubAgentToolRelationSelectSchema, SubAgentToolRelationInsertSchema, SubAgentToolRelationUpdateSchema, SubAgentToolRelationApiSelectSchema, SubAgentToolRelationApiInsertSchema, SubAgentToolRelationApiUpdateSchema, LedgerArtifactSelectSchema, LedgerArtifactInsertSchema, LedgerArtifactUpdateSchema, LedgerArtifactApiSelectSchema, LedgerArtifactApiInsertSchema, LedgerArtifactApiUpdateSchema, StatusComponentSchema, StatusUpdateSchema, CanUseItemSchema, FullAgentAgentInsertSchema, AgentWithinContextOfProjectSchema, PaginationSchema, ErrorResponseSchema, ExistsResponseSchema, RemovedResponseSchema, ProjectSelectSchema, ProjectInsertSchema, ProjectUpdateSchema, ProjectApiSelectSchema, ProjectApiInsertSchema, ProjectApiUpdateSchema, FullProjectDefinitionSchema, ProjectResponse, SubAgentResponse, AgentResponse, ToolResponse, ExternalAgentResponse, ContextConfigResponse, ApiKeyResponse, CredentialReferenceResponse, FunctionResponse, FunctionToolResponse, DataComponentResponse, ArtifactComponentResponse, SubAgentRelationResponse, SubAgentToolRelationResponse, ConversationResponse, MessageResponse, ProjectListResponse, SubAgentListResponse, AgentListResponse, ToolListResponse, ExternalAgentListResponse, ContextConfigListResponse, ApiKeyListResponse, CredentialReferenceListResponse, FunctionListResponse, FunctionToolListResponse, DataComponentListResponse, ArtifactComponentListResponse, SubAgentRelationListResponse, SubAgentToolRelationListResponse, ConversationListResponse, MessageListResponse, SubAgentDataComponentResponse, SubAgentArtifactComponentResponse, SubAgentDataComponentListResponse, SubAgentArtifactComponentListResponse, HeadersScopeSchema, TenantId, ProjectId, AgentId, SubAgentId, TenantParamsSchema, TenantIdParamsSchema, TenantProjectParamsSchema, TenantProjectIdParamsSchema, TenantProjectAgentParamsSchema, TenantProjectAgentIdParamsSchema, TenantProjectAgentSubAgentParamsSchema, TenantProjectAgentSubAgentIdParamsSchema, PaginationQueryParamsSchema;
2493
+ var StopWhenSchema, AgentStopWhenSchema, SubAgentStopWhenSchema, MIN_ID_LENGTH, MAX_ID_LENGTH, URL_SAFE_ID_PATTERN, resourceIdSchema, ModelSettingsSchema, ModelSchema, ProjectModelSchema, FunctionToolConfigSchema, createApiSchema, createApiInsertSchema, createApiUpdateSchema, createAgentScopedApiSchema, createAgentScopedApiInsertSchema, createAgentScopedApiUpdateSchema, SubAgentSelectSchema, SubAgentInsertSchema, SubAgentUpdateSchema, SubAgentApiSelectSchema, SubAgentApiInsertSchema, SubAgentApiUpdateSchema, SubAgentRelationSelectSchema, SubAgentRelationInsertSchema, SubAgentRelationUpdateSchema, SubAgentRelationApiSelectSchema, SubAgentRelationApiInsertSchema, SubAgentRelationApiUpdateSchema, SubAgentRelationQuerySchema, ExternalSubAgentRelationInsertSchema, ExternalSubAgentRelationApiInsertSchema, AgentSelectSchema, AgentInsertSchema, AgentUpdateSchema, AgentApiSelectSchema, AgentApiInsertSchema, AgentApiUpdateSchema, TaskSelectSchema, TaskInsertSchema, TaskUpdateSchema, TaskApiSelectSchema, TaskApiInsertSchema, TaskApiUpdateSchema, TaskRelationSelectSchema, TaskRelationInsertSchema, TaskRelationUpdateSchema, TaskRelationApiSelectSchema, TaskRelationApiInsertSchema, TaskRelationApiUpdateSchema, imageUrlSchema, McpTransportConfigSchema, ToolStatusSchema, McpToolDefinitionSchema, ToolSelectSchema, ToolInsertSchema, ConversationSelectSchema, ConversationInsertSchema, ConversationUpdateSchema, ConversationApiSelectSchema, ConversationApiInsertSchema, ConversationApiUpdateSchema, MessageSelectSchema, MessageInsertSchema, MessageUpdateSchema, MessageApiSelectSchema, MessageApiInsertSchema, MessageApiUpdateSchema, ContextCacheSelectSchema, ContextCacheInsertSchema, ContextCacheUpdateSchema, ContextCacheApiSelectSchema, ContextCacheApiInsertSchema, ContextCacheApiUpdateSchema, DataComponentSelectSchema, DataComponentInsertSchema, DataComponentBaseSchema, DataComponentUpdateSchema, DataComponentApiSelectSchema, DataComponentApiInsertSchema, DataComponentApiUpdateSchema, SubAgentDataComponentSelectSchema, SubAgentDataComponentInsertSchema, SubAgentDataComponentUpdateSchema, SubAgentDataComponentApiSelectSchema, SubAgentDataComponentApiInsertSchema, SubAgentDataComponentApiUpdateSchema, ArtifactComponentSelectSchema, ArtifactComponentInsertSchema, ArtifactComponentUpdateSchema, ArtifactComponentApiSelectSchema, ArtifactComponentApiInsertSchema, ArtifactComponentApiUpdateSchema, SubAgentArtifactComponentSelectSchema, SubAgentArtifactComponentInsertSchema, SubAgentArtifactComponentUpdateSchema, SubAgentArtifactComponentApiSelectSchema, SubAgentArtifactComponentApiInsertSchema, SubAgentArtifactComponentApiUpdateSchema, ExternalAgentSelectSchema, ExternalAgentInsertSchema, ExternalAgentUpdateSchema, ExternalAgentApiSelectSchema, ExternalAgentApiInsertSchema, ExternalAgentApiUpdateSchema, AllAgentSchema, ApiKeySelectSchema, ApiKeyInsertSchema, ApiKeyUpdateSchema, ApiKeyApiSelectSchema, ApiKeyApiCreationResponseSchema, ApiKeyApiInsertSchema, ApiKeyApiUpdateSchema, CredentialReferenceSelectSchema, CredentialReferenceInsertSchema, CredentialReferenceUpdateSchema, CredentialReferenceApiSelectSchema, CredentialReferenceApiInsertSchema, CredentialReferenceApiUpdateSchema, McpToolSchema, MCPToolConfigSchema, ToolUpdateSchema, ToolApiSelectSchema, ToolApiInsertSchema, ToolApiUpdateSchema, FunctionToolSelectSchema, FunctionToolInsertSchema, FunctionToolUpdateSchema, FunctionToolApiSelectSchema, FunctionToolApiInsertSchema, FunctionToolApiUpdateSchema, FunctionSelectSchema, FunctionInsertSchema, FunctionUpdateSchema, FunctionApiSelectSchema, FunctionApiInsertSchema, FunctionApiUpdateSchema, FetchConfigSchema, FetchDefinitionSchema, ContextConfigSelectSchema, ContextConfigInsertSchema, ContextConfigUpdateSchema, ContextConfigApiSelectSchema, ContextConfigApiInsertSchema, ContextConfigApiUpdateSchema, SubAgentToolRelationSelectSchema, SubAgentToolRelationInsertSchema, SubAgentToolRelationUpdateSchema, SubAgentToolRelationApiSelectSchema, SubAgentToolRelationApiInsertSchema, SubAgentToolRelationApiUpdateSchema, SubAgentExternalAgentRelationSelectSchema, SubAgentExternalAgentRelationInsertSchema, SubAgentExternalAgentRelationUpdateSchema, SubAgentExternalAgentRelationApiSelectSchema, SubAgentExternalAgentRelationApiInsertSchema, SubAgentExternalAgentRelationApiUpdateSchema, LedgerArtifactSelectSchema, LedgerArtifactInsertSchema, LedgerArtifactUpdateSchema, LedgerArtifactApiSelectSchema, LedgerArtifactApiInsertSchema, LedgerArtifactApiUpdateSchema, StatusComponentSchema, StatusUpdateSchema, CanUseItemSchema, canDelegateToExternalAgentSchema, FullAgentAgentInsertSchema, AgentWithinContextOfProjectSchema, PaginationSchema, ErrorResponseSchema, ExistsResponseSchema, RemovedResponseSchema, ProjectSelectSchema, ProjectInsertSchema, ProjectUpdateSchema, ProjectApiSelectSchema, ProjectApiInsertSchema, ProjectApiUpdateSchema, FullProjectDefinitionSchema, ProjectResponse, SubAgentResponse, AgentResponse, ToolResponse, ExternalAgentResponse, ContextConfigResponse, ApiKeyResponse, CredentialReferenceResponse, FunctionResponse, FunctionToolResponse, DataComponentResponse, ArtifactComponentResponse, SubAgentRelationResponse, SubAgentToolRelationResponse, ConversationResponse, MessageResponse, ProjectListResponse, SubAgentListResponse, AgentListResponse, ToolListResponse, ExternalAgentListResponse, ContextConfigListResponse, ApiKeyListResponse, CredentialReferenceListResponse, FunctionListResponse, FunctionToolListResponse, DataComponentListResponse, ArtifactComponentListResponse, SubAgentRelationListResponse, SubAgentToolRelationListResponse, ConversationListResponse, MessageListResponse, SubAgentDataComponentResponse, SubAgentArtifactComponentResponse, SubAgentDataComponentListResponse, SubAgentArtifactComponentListResponse, HeadersScopeSchema, TenantId, ProjectId, AgentId, SubAgentId, TenantParamsSchema, TenantIdParamsSchema, TenantProjectParamsSchema, TenantProjectIdParamsSchema, TenantProjectAgentParamsSchema, TenantProjectAgentIdParamsSchema, TenantProjectAgentSubAgentParamsSchema, TenantProjectAgentSubAgentIdParamsSchema, PaginationQueryParamsSchema;
2456
2494
  var init_schemas = __esm({
2457
2495
  "../packages/agents-core/src/validation/schemas.ts"() {
2458
2496
  "use strict";
@@ -2754,16 +2792,15 @@ var init_schemas = __esm({
2754
2792
  SubAgentArtifactComponentUpdateSchema
2755
2793
  );
2756
2794
  ExternalAgentSelectSchema = createSelectSchema(externalAgents).extend({
2757
- credentialReferenceId: z2.string().nullable().optional(),
2758
- headers: z2.record(z2.string(), z2.string()).nullable().optional()
2795
+ credentialReferenceId: z2.string().nullable().optional()
2759
2796
  });
2760
2797
  ExternalAgentInsertSchema = createInsertSchema(externalAgents).extend({
2761
2798
  id: resourceIdSchema
2762
2799
  });
2763
2800
  ExternalAgentUpdateSchema = ExternalAgentInsertSchema.partial();
2764
- ExternalAgentApiSelectSchema = createAgentScopedApiSchema(ExternalAgentSelectSchema).openapi("ExternalAgent");
2765
- ExternalAgentApiInsertSchema = createAgentScopedApiInsertSchema(ExternalAgentInsertSchema).openapi("ExternalAgentCreate");
2766
- ExternalAgentApiUpdateSchema = createAgentScopedApiUpdateSchema(ExternalAgentUpdateSchema).openapi("ExternalAgentUpdate");
2801
+ ExternalAgentApiSelectSchema = createApiSchema(ExternalAgentSelectSchema).openapi("ExternalAgent");
2802
+ ExternalAgentApiInsertSchema = createApiInsertSchema(ExternalAgentInsertSchema).openapi("ExternalAgentCreate");
2803
+ ExternalAgentApiUpdateSchema = createApiUpdateSchema(ExternalAgentUpdateSchema).openapi("ExternalAgentUpdate");
2767
2804
  AllAgentSchema = z2.discriminatedUnion("type", [
2768
2805
  SubAgentApiSelectSchema.extend({ type: z2.literal("internal") }),
2769
2806
  ExternalAgentApiSelectSchema.extend({ type: z2.literal("external") })
@@ -2828,7 +2865,8 @@ var init_schemas = __esm({
2828
2865
  CredentialReferenceUpdateSchema = CredentialReferenceInsertSchema.partial();
2829
2866
  CredentialReferenceApiSelectSchema = createApiSchema(CredentialReferenceSelectSchema).extend({
2830
2867
  type: z2.enum(CredentialStoreType),
2831
- tools: z2.array(ToolSelectSchema).optional()
2868
+ tools: z2.array(ToolSelectSchema).optional(),
2869
+ externalAgents: z2.array(ExternalAgentSelectSchema).optional()
2832
2870
  }).openapi("CredentialReference");
2833
2871
  CredentialReferenceApiInsertSchema = createApiInsertSchema(
2834
2872
  CredentialReferenceInsertSchema
@@ -2957,6 +2995,27 @@ var init_schemas = __esm({
2957
2995
  SubAgentToolRelationApiUpdateSchema = createAgentScopedApiUpdateSchema(
2958
2996
  SubAgentToolRelationUpdateSchema
2959
2997
  ).openapi("SubAgentToolRelationUpdate");
2998
+ SubAgentExternalAgentRelationSelectSchema = createSelectSchema(
2999
+ subAgentExternalAgentRelations
3000
+ );
3001
+ SubAgentExternalAgentRelationInsertSchema = createInsertSchema(
3002
+ subAgentExternalAgentRelations
3003
+ ).extend({
3004
+ id: resourceIdSchema,
3005
+ subAgentId: resourceIdSchema,
3006
+ externalAgentId: resourceIdSchema,
3007
+ headers: z2.record(z2.string(), z2.string()).nullish()
3008
+ });
3009
+ SubAgentExternalAgentRelationUpdateSchema = SubAgentExternalAgentRelationInsertSchema.partial();
3010
+ SubAgentExternalAgentRelationApiSelectSchema = createAgentScopedApiSchema(
3011
+ SubAgentExternalAgentRelationSelectSchema
3012
+ ).openapi("SubAgentExternalAgentRelation");
3013
+ SubAgentExternalAgentRelationApiInsertSchema = createAgentScopedApiInsertSchema(
3014
+ SubAgentExternalAgentRelationInsertSchema
3015
+ ).omit({ id: true, subAgentId: true }).openapi("SubAgentExternalAgentRelationCreate");
3016
+ SubAgentExternalAgentRelationApiUpdateSchema = createAgentScopedApiUpdateSchema(
3017
+ SubAgentExternalAgentRelationUpdateSchema
3018
+ ).openapi("SubAgentExternalAgentRelationUpdate");
2960
3019
  LedgerArtifactSelectSchema = createSelectSchema(ledgerArtifacts);
2961
3020
  LedgerArtifactInsertSchema = createInsertSchema(ledgerArtifacts);
2962
3021
  LedgerArtifactUpdateSchema = LedgerArtifactInsertSchema.partial();
@@ -2985,6 +3044,11 @@ var init_schemas = __esm({
2985
3044
  toolSelection: z2.array(z2.string()).nullish(),
2986
3045
  headers: z2.record(z2.string(), z2.string()).nullish()
2987
3046
  }).openapi("CanUseItem");
3047
+ canDelegateToExternalAgentSchema = z2.object({
3048
+ externalAgentId: z2.string(),
3049
+ subAgentExternalAgentRelationId: z2.string().optional(),
3050
+ headers: z2.record(z2.string(), z2.string()).nullish()
3051
+ });
2988
3052
  FullAgentAgentInsertSchema = SubAgentApiInsertSchema.extend({
2989
3053
  type: z2.literal("internal"),
2990
3054
  canUse: z2.array(CanUseItemSchema),
@@ -2992,16 +3056,22 @@ var init_schemas = __esm({
2992
3056
  dataComponents: z2.array(z2.string()).optional(),
2993
3057
  artifactComponents: z2.array(z2.string()).optional(),
2994
3058
  canTransferTo: z2.array(z2.string()).optional(),
2995
- canDelegateTo: z2.array(z2.string()).optional()
3059
+ canDelegateTo: z2.array(
3060
+ z2.union([
3061
+ z2.string(),
3062
+ // Internal subAgent ID
3063
+ canDelegateToExternalAgentSchema
3064
+ // External agent with headers
3065
+ ])
3066
+ ).optional()
2996
3067
  });
2997
3068
  AgentWithinContextOfProjectSchema = AgentApiInsertSchema.extend({
2998
- subAgents: z2.record(
2999
- z2.string(),
3000
- z2.union([FullAgentAgentInsertSchema, ExternalAgentApiInsertSchema])
3001
- ),
3069
+ subAgents: z2.record(z2.string(), FullAgentAgentInsertSchema),
3002
3070
  // Lookup maps for UI to resolve canUse items
3003
3071
  tools: z2.record(z2.string(), ToolApiInsertSchema).optional(),
3004
3072
  // MCP tools (project-scoped)
3073
+ externalAgents: z2.record(z2.string(), ExternalAgentApiInsertSchema).optional(),
3074
+ // External agents (project-scoped)
3005
3075
  functionTools: z2.record(z2.string(), FunctionToolApiInsertSchema).optional(),
3006
3076
  // Function tools (agent-scoped)
3007
3077
  functions: z2.record(z2.string(), FunctionApiInsertSchema).optional(),
@@ -3056,6 +3126,7 @@ var init_schemas = __esm({
3056
3126
  functions: z2.record(z2.string(), FunctionApiInsertSchema).optional(),
3057
3127
  dataComponents: z2.record(z2.string(), DataComponentApiInsertSchema).optional(),
3058
3128
  artifactComponents: z2.record(z2.string(), ArtifactComponentApiInsertSchema).optional(),
3129
+ externalAgents: z2.record(z2.string(), ExternalAgentApiInsertSchema).optional(),
3059
3130
  statusUpdates: z2.optional(StatusUpdateSchema),
3060
3131
  credentialReferences: z2.record(z2.string(), CredentialReferenceApiInsertSchema).optional(),
3061
3132
  createdAt: z2.string().optional(),
@@ -7147,11 +7218,11 @@ var require_typescript = __commonJS({
7147
7218
  for (var name in all)
7148
7219
  __defProp2(target, name, { get: all[name], enumerable: true });
7149
7220
  };
7150
- var __copyProps2 = (to, from, except, desc15) => {
7221
+ var __copyProps2 = (to, from, except, desc16) => {
7151
7222
  if (from && typeof from === "object" || typeof from === "function") {
7152
7223
  for (let key of __getOwnPropNames2(from))
7153
7224
  if (!__hasOwnProp2.call(to, key) && key !== except)
7154
- __defProp2(to, key, { get: () => from[key], enumerable: !(desc15 = __getOwnPropDesc2(from, key)) || desc15.enumerable });
7225
+ __defProp2(to, key, { get: () => from[key], enumerable: !(desc16 = __getOwnPropDesc2(from, key)) || desc16.enumerable });
7155
7226
  }
7156
7227
  return to;
7157
7228
  };
@@ -7335,7 +7406,7 @@ var require_typescript = __commonJS({
7335
7406
  affectsEmitOptionDeclarations: () => affectsEmitOptionDeclarations,
7336
7407
  allKeysStartWithDot: () => allKeysStartWithDot,
7337
7408
  altDirectorySeparator: () => altDirectorySeparator,
7338
- and: () => and20,
7409
+ and: () => and21,
7339
7410
  append: () => append,
7340
7411
  appendIfUnique: () => appendIfUnique,
7341
7412
  arrayFrom: () => arrayFrom,
@@ -9557,16 +9628,16 @@ var require_typescript = __commonJS({
9557
9628
  return -1;
9558
9629
  }
9559
9630
  function countWhere(array, predicate) {
9560
- let count16 = 0;
9631
+ let count17 = 0;
9561
9632
  if (array !== void 0) {
9562
9633
  for (let i2 = 0; i2 < array.length; i2++) {
9563
9634
  const v2 = array[i2];
9564
9635
  if (predicate(v2, i2)) {
9565
- count16++;
9636
+ count17++;
9566
9637
  }
9567
9638
  }
9568
9639
  }
9569
- return count16;
9640
+ return count17;
9570
9641
  }
9571
9642
  function filter(array, f) {
9572
9643
  if (array !== void 0) {
@@ -10119,12 +10190,12 @@ var require_typescript = __commonJS({
10119
10190
  }
10120
10191
  return ~low;
10121
10192
  }
10122
- function reduceLeft(array, f, initial, start, count16) {
10193
+ function reduceLeft(array, f, initial, start, count17) {
10123
10194
  if (array && array.length > 0) {
10124
10195
  const size = array.length;
10125
10196
  if (size > 0) {
10126
10197
  let pos = start === void 0 || start < 0 ? 0 : start;
10127
- const end = count16 === void 0 || pos + count16 > size - 1 ? size - 1 : pos + count16;
10198
+ const end = count17 === void 0 || pos + count17 > size - 1 ? size - 1 : pos + count17;
10128
10199
  let result;
10129
10200
  if (arguments.length <= 2) {
10130
10201
  result = array[pos];
@@ -10176,9 +10247,9 @@ var require_typescript = __commonJS({
10176
10247
  }
10177
10248
  return values;
10178
10249
  }
10179
- function arrayOf(count16, f) {
10180
- const result = new Array(count16);
10181
- for (let i2 = 0; i2 < count16; i2++) {
10250
+ function arrayOf(count17, f) {
10251
+ const result = new Array(count17);
10252
+ for (let i2 = 0; i2 < count17; i2++) {
10182
10253
  result[i2] = f(i2);
10183
10254
  }
10184
10255
  return result;
@@ -10786,7 +10857,7 @@ var require_typescript = __commonJS({
10786
10857
  function isPatternMatch({ prefix, suffix }, candidate) {
10787
10858
  return candidate.length >= prefix.length + suffix.length && startsWith(candidate, prefix) && endsWith(candidate, suffix);
10788
10859
  }
10789
- function and20(f, g) {
10860
+ function and21(f, g) {
10790
10861
  return (arg) => f(arg) && g(arg);
10791
10862
  }
10792
10863
  function or(...fs5) {
@@ -12293,8 +12364,8 @@ ${lanes.join("\n")}
12293
12364
  var durations = /* @__PURE__ */ new Map();
12294
12365
  function mark(markName) {
12295
12366
  if (enabled) {
12296
- const count16 = counts.get(markName) ?? 0;
12297
- counts.set(markName, count16 + 1);
12367
+ const count17 = counts.get(markName) ?? 0;
12368
+ counts.set(markName, count17 + 1);
12298
12369
  marks.set(markName, timestamp());
12299
12370
  performanceImpl == null ? void 0 : performanceImpl.mark(markName);
12300
12371
  if (typeof onProfilerEvent === "function") {
@@ -19805,20 +19876,20 @@ ${lanes.join("\n")}
19805
19876
  tokenValue = text4.substring(start2, pos);
19806
19877
  return isOctal;
19807
19878
  }
19808
- function scanExactNumberOfHexDigits(count16, canHaveSeparators) {
19879
+ function scanExactNumberOfHexDigits(count17, canHaveSeparators) {
19809
19880
  const valueString = scanHexDigits(
19810
19881
  /*minCount*/
19811
- count16,
19882
+ count17,
19812
19883
  /*scanAsManyAsPossible*/
19813
19884
  false,
19814
19885
  canHaveSeparators
19815
19886
  );
19816
19887
  return valueString ? parseInt(valueString, 16) : -1;
19817
19888
  }
19818
- function scanMinimumNumberOfHexDigits(count16, canHaveSeparators) {
19889
+ function scanMinimumNumberOfHexDigits(count17, canHaveSeparators) {
19819
19890
  return scanHexDigits(
19820
19891
  /*minCount*/
19821
- count16,
19892
+ count17,
19822
19893
  /*scanAsManyAsPossible*/
19823
19894
  true,
19824
19895
  canHaveSeparators
@@ -38644,13 +38715,13 @@ ${lanes.join("\n")}
38644
38715
  [expression]
38645
38716
  );
38646
38717
  }
38647
- function createReadHelper(iteratorRecord, count16) {
38718
+ function createReadHelper(iteratorRecord, count17) {
38648
38719
  context.requestEmitHelper(readHelper);
38649
38720
  return factory2.createCallExpression(
38650
38721
  getUnscopedHelperName("__read"),
38651
38722
  /*typeArguments*/
38652
38723
  void 0,
38653
- count16 !== void 0 ? [iteratorRecord, factory2.createNumericLiteral(count16 + "")] : [iteratorRecord]
38724
+ count17 !== void 0 ? [iteratorRecord, factory2.createNumericLiteral(count17 + "")] : [iteratorRecord]
38654
38725
  );
38655
38726
  }
38656
38727
  function createGeneratorHelper(body) {
@@ -60960,11 +61031,11 @@ ${lanes.join("\n")}
60960
61031
  return comparePaths(a, b2, ignoreCase) === 0;
60961
61032
  }
60962
61033
  function countPathComponents(path4) {
60963
- let count16 = 0;
61034
+ let count17 = 0;
60964
61035
  for (let i2 = startsWith(path4, "./") ? 2 : 0; i2 < path4.length; i2++) {
60965
- if (path4.charCodeAt(i2) === 47) count16++;
61036
+ if (path4.charCodeAt(i2) === 47) count17++;
60966
61037
  }
60967
- return count16;
61038
+ return count17;
60968
61039
  }
60969
61040
  function comparePathsByRedirectAndNumberOfDirectorySeparators(a, b2) {
60970
61041
  return compareBooleans(b2.isRedirect, a.isRedirect) || compareNumberOfDirectorySeparators(a.path, b2.path);
@@ -61799,7 +61870,7 @@ ${lanes.join("\n")}
61799
61870
  SignatureCheckMode3[SignatureCheckMode3["Callback"] = 3] = "Callback";
61800
61871
  return SignatureCheckMode3;
61801
61872
  })(SignatureCheckMode || {});
61802
- var isNotOverloadAndNotAccessor = and20(isNotOverload, isNotAccessor);
61873
+ var isNotOverloadAndNotAccessor = and21(isNotOverload, isNotAccessor);
61803
61874
  var intrinsicTypeKinds = new Map(Object.entries({
61804
61875
  Uppercase: 0,
61805
61876
  Lowercase: 1,
@@ -67539,7 +67610,7 @@ ${lanes.join("\n")}
67539
67610
  deepCloneOrReuseNode
67540
67611
  )), node);
67541
67612
  }
67542
- function deepCloneOrReuseNodes(nodes, visitor, test, start, count16) {
67613
+ function deepCloneOrReuseNodes(nodes, visitor, test, start, count17) {
67543
67614
  if (nodes && nodes.length === 0) {
67544
67615
  return setTextRange(factory.createNodeArray(
67545
67616
  /*elements*/
@@ -67547,7 +67618,7 @@ ${lanes.join("\n")}
67547
67618
  nodes.hasTrailingComma
67548
67619
  ), nodes);
67549
67620
  }
67550
- return visitNodes2(nodes, visitor, test, start, count16);
67621
+ return visitNodes2(nodes, visitor, test, start, count17);
67551
67622
  }
67552
67623
  }
67553
67624
  function createTypeNodeFromObjectType(type2) {
@@ -71504,10 +71575,10 @@ ${lanes.join("\n")}
71504
71575
  if (t2.flags & 512 || !expandingEnum && t2.flags | 1056) {
71505
71576
  const baseType = t2.flags & 512 ? booleanType : getBaseTypeOfEnumLikeType(t2);
71506
71577
  if (baseType.flags & 1048576) {
71507
- const count16 = baseType.types.length;
71508
- if (i2 + count16 <= types.length && getRegularTypeOfLiteralType(types[i2 + count16 - 1]) === getRegularTypeOfLiteralType(baseType.types[count16 - 1])) {
71578
+ const count17 = baseType.types.length;
71579
+ if (i2 + count17 <= types.length && getRegularTypeOfLiteralType(types[i2 + count17 - 1]) === getRegularTypeOfLiteralType(baseType.types[count17 - 1])) {
71509
71580
  result.push(baseType);
71510
- i2 += count16 - 1;
71581
+ i2 += count17 - 1;
71511
71582
  continue;
71512
71583
  }
71513
71584
  }
@@ -76473,18 +76544,18 @@ ${lanes.join("\n")}
76473
76544
  let i2 = 0;
76474
76545
  while (i2 < length2) {
76475
76546
  const startId = types[i2].id;
76476
- let count16 = 1;
76477
- while (i2 + count16 < length2 && types[i2 + count16].id === startId + count16) {
76478
- count16++;
76547
+ let count17 = 1;
76548
+ while (i2 + count17 < length2 && types[i2 + count17].id === startId + count17) {
76549
+ count17++;
76479
76550
  }
76480
76551
  if (result.length) {
76481
76552
  result += ",";
76482
76553
  }
76483
76554
  result += startId;
76484
- if (count16 > 1) {
76485
- result += ":" + count16;
76555
+ if (count17 > 1) {
76556
+ result += ":" + count17;
76486
76557
  }
76487
- i2 += count16;
76558
+ i2 += count17;
76488
76559
  }
76489
76560
  }
76490
76561
  return result;
@@ -77764,7 +77835,7 @@ ${lanes.join("\n")}
77764
77835
  const hasEmptyObject = hasObjectTypes && some(types, (t2) => !!(t2.flags & 524288) && !isGenericMappedType(t2) && isEmptyResolvedType(resolveStructuredTypeMembers(t2)));
77765
77836
  const len = types.length;
77766
77837
  let i2 = len;
77767
- let count16 = 0;
77838
+ let count17 = 0;
77768
77839
  while (i2 > 0) {
77769
77840
  i2--;
77770
77841
  const source = types[i2];
@@ -77779,15 +77850,15 @@ ${lanes.join("\n")}
77779
77850
  const keyPropertyType = keyProperty && getRegularTypeOfLiteralType(getTypeOfSymbol(keyProperty));
77780
77851
  for (const target of types) {
77781
77852
  if (source !== target) {
77782
- if (count16 === 1e5) {
77783
- const estimatedCount = count16 / (len - i2) * len;
77853
+ if (count17 === 1e5) {
77854
+ const estimatedCount = count17 / (len - i2) * len;
77784
77855
  if (estimatedCount > 1e6) {
77785
77856
  (_a = tracing) == null ? void 0 : _a.instant(tracing.Phase.CheckTypes, "removeSubtypes_DepthLimit", { typeIds: types.map((t2) => t2.id) });
77786
77857
  error2(currentNode, Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent);
77787
77858
  return void 0;
77788
77859
  }
77789
77860
  }
77790
- count16++;
77861
+ count17++;
77791
77862
  if (keyProperty && target.flags & (524288 | 2097152 | 58982400)) {
77792
77863
  const t2 = getTypeOfPropertyOfType(target, keyProperty.escapedName);
77793
77864
  if (t2 && isUnitType(t2) && getRegularTypeOfLiteralType(t2) !== keyPropertyType) {
@@ -78288,9 +78359,9 @@ ${lanes.join("\n")}
78288
78359
  return true;
78289
78360
  }
78290
78361
  function getCrossProductIntersections(types, flags) {
78291
- const count16 = getCrossProductUnionSize(types);
78362
+ const count17 = getCrossProductUnionSize(types);
78292
78363
  const intersections = [];
78293
- for (let i2 = 0; i2 < count16; i2++) {
78364
+ for (let i2 = 0; i2 < count17; i2++) {
78294
78365
  const constituents = types.slice();
78295
78366
  let n2 = i2;
78296
78367
  for (let j2 = types.length - 1; j2 >= 0; j2--) {
@@ -84157,14 +84228,14 @@ ${lanes.join("\n")}
84157
84228
  return some(type.types, (t2) => isDeeplyNestedType(t2, stack, depth, maxDepth));
84158
84229
  }
84159
84230
  const identity2 = getRecursionIdentity(type);
84160
- let count16 = 0;
84231
+ let count17 = 0;
84161
84232
  let lastTypeId = 0;
84162
84233
  for (let i2 = 0; i2 < depth; i2++) {
84163
84234
  const t2 = stack[i2];
84164
84235
  if (hasMatchingRecursionIdentity(t2, identity2)) {
84165
84236
  if (t2.id >= lastTypeId) {
84166
- count16++;
84167
- if (count16 >= maxDepth) {
84237
+ count17++;
84238
+ if (count17 >= maxDepth) {
84168
84239
  return true;
84169
84240
  }
84170
84241
  }
@@ -85624,8 +85695,8 @@ ${lanes.join("\n")}
85624
85695
  ];
85625
85696
  }
85626
85697
  function inferFromTypeArguments(sourceTypes, targetTypes, variances) {
85627
- const count16 = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length;
85628
- for (let i2 = 0; i2 < count16; i2++) {
85698
+ const count17 = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length;
85699
+ for (let i2 = 0; i2 < count17; i2++) {
85629
85700
  if (i2 < variances.length && (variances[i2] & 7) === 2) {
85630
85701
  inferFromContravariantTypes(sourceTypes[i2], targetTypes[i2]);
85631
85702
  } else {
@@ -86369,7 +86440,7 @@ ${lanes.join("\n")}
86369
86440
  }
86370
86441
  function mapTypesByKeyProperty(types, name) {
86371
86442
  const map2 = /* @__PURE__ */ new Map();
86372
- let count16 = 0;
86443
+ let count17 = 0;
86373
86444
  for (const type of types) {
86374
86445
  if (type.flags & (524288 | 2097152 | 58982400)) {
86375
86446
  const discriminant = getTypeOfPropertyOfType(type, name);
@@ -86388,11 +86459,11 @@ ${lanes.join("\n")}
86388
86459
  duplicate = true;
86389
86460
  }
86390
86461
  });
86391
- if (!duplicate) count16++;
86462
+ if (!duplicate) count17++;
86392
86463
  }
86393
86464
  }
86394
86465
  }
86395
- return count16 >= 10 && count16 * 2 >= types.length ? map2 : void 0;
86466
+ return count17 >= 10 && count17 * 2 >= types.length ? map2 : void 0;
86396
86467
  }
86397
86468
  function getKeyPropertyName(unionType) {
86398
86469
  const types = unionType.types;
@@ -104619,7 +104690,7 @@ ${lanes.join("\n")}
104619
104690
  if (flags & (1920 | 384)) {
104620
104691
  return;
104621
104692
  }
104622
- const exportedDeclarationsCount = countWhere(declarations, and20(isNotOverloadAndNotAccessor, not2(isInterfaceDeclaration)));
104693
+ const exportedDeclarationsCount = countWhere(declarations, and21(isNotOverloadAndNotAccessor, not2(isInterfaceDeclaration)));
104623
104694
  if (flags & 524288 && exportedDeclarationsCount <= 2) {
104624
104695
  return;
104625
104696
  }
@@ -109008,7 +109079,7 @@ ${lanes.join("\n")}
109008
109079
  Debug.assertNode(visitedNode, test);
109009
109080
  return visitedNode;
109010
109081
  }
109011
- function visitNodes2(nodes, visitor, test, start, count16) {
109082
+ function visitNodes2(nodes, visitor, test, start, count17) {
109012
109083
  if (nodes === void 0) {
109013
109084
  return nodes;
109014
109085
  }
@@ -109016,20 +109087,20 @@ ${lanes.join("\n")}
109016
109087
  if (start === void 0 || start < 0) {
109017
109088
  start = 0;
109018
109089
  }
109019
- if (count16 === void 0 || count16 > length2 - start) {
109020
- count16 = length2 - start;
109090
+ if (count17 === void 0 || count17 > length2 - start) {
109091
+ count17 = length2 - start;
109021
109092
  }
109022
109093
  let hasTrailingComma;
109023
109094
  let pos = -1;
109024
109095
  let end = -1;
109025
- if (start > 0 || count16 < length2) {
109026
- hasTrailingComma = nodes.hasTrailingComma && start + count16 === length2;
109096
+ if (start > 0 || count17 < length2) {
109097
+ hasTrailingComma = nodes.hasTrailingComma && start + count17 === length2;
109027
109098
  } else {
109028
109099
  pos = nodes.pos;
109029
109100
  end = nodes.end;
109030
109101
  hasTrailingComma = nodes.hasTrailingComma;
109031
109102
  }
109032
- const updated = visitArrayWorker(nodes, visitor, test, start, count16);
109103
+ const updated = visitArrayWorker(nodes, visitor, test, start, count17);
109033
109104
  if (updated !== nodes) {
109034
109105
  const updatedArray = factory.createNodeArray(updated, hasTrailingComma);
109035
109106
  setTextRangePosEnd(updatedArray, pos, end);
@@ -109037,7 +109108,7 @@ ${lanes.join("\n")}
109037
109108
  }
109038
109109
  return nodes;
109039
109110
  }
109040
- function visitArray(nodes, visitor, test, start, count16) {
109111
+ function visitArray(nodes, visitor, test, start, count17) {
109041
109112
  if (nodes === void 0) {
109042
109113
  return nodes;
109043
109114
  }
@@ -109045,18 +109116,18 @@ ${lanes.join("\n")}
109045
109116
  if (start === void 0 || start < 0) {
109046
109117
  start = 0;
109047
109118
  }
109048
- if (count16 === void 0 || count16 > length2 - start) {
109049
- count16 = length2 - start;
109119
+ if (count17 === void 0 || count17 > length2 - start) {
109120
+ count17 = length2 - start;
109050
109121
  }
109051
- return visitArrayWorker(nodes, visitor, test, start, count16);
109122
+ return visitArrayWorker(nodes, visitor, test, start, count17);
109052
109123
  }
109053
- function visitArrayWorker(nodes, visitor, test, start, count16) {
109124
+ function visitArrayWorker(nodes, visitor, test, start, count17) {
109054
109125
  let updated;
109055
109126
  const length2 = nodes.length;
109056
- if (start > 0 || count16 < length2) {
109127
+ if (start > 0 || count17 < length2) {
109057
109128
  updated = [];
109058
109129
  }
109059
- for (let i2 = 0; i2 < count16; i2++) {
109130
+ for (let i2 = 0; i2 < count17; i2++) {
109060
109131
  const node = nodes[i2 + start];
109061
109132
  const visited = node !== void 0 ? visitor ? visitor(node) : node : void 0;
109062
109133
  if (updated !== void 0 || visited === void 0 || visited !== node) {
@@ -140432,7 +140503,7 @@ ${lanes.join("\n")}
140432
140503
  break;
140433
140504
  }
140434
140505
  }
140435
- function emitList(parentNode, children, format, parenthesizerRule, start, count16) {
140506
+ function emitList(parentNode, children, format, parenthesizerRule, start, count17) {
140436
140507
  emitNodeList(
140437
140508
  emit,
140438
140509
  parentNode,
@@ -140440,18 +140511,18 @@ ${lanes.join("\n")}
140440
140511
  format | (parentNode && getEmitFlags(parentNode) & 2 ? 65536 : 0),
140441
140512
  parenthesizerRule,
140442
140513
  start,
140443
- count16
140514
+ count17
140444
140515
  );
140445
140516
  }
140446
- function emitExpressionList(parentNode, children, format, parenthesizerRule, start, count16) {
140447
- emitNodeList(emitExpression, parentNode, children, format, parenthesizerRule, start, count16);
140517
+ function emitExpressionList(parentNode, children, format, parenthesizerRule, start, count17) {
140518
+ emitNodeList(emitExpression, parentNode, children, format, parenthesizerRule, start, count17);
140448
140519
  }
140449
- function emitNodeList(emit2, parentNode, children, format, parenthesizerRule, start = 0, count16 = children ? children.length - start : 0) {
140520
+ function emitNodeList(emit2, parentNode, children, format, parenthesizerRule, start = 0, count17 = children ? children.length - start : 0) {
140450
140521
  const isUndefined2 = children === void 0;
140451
140522
  if (isUndefined2 && format & 16384) {
140452
140523
  return;
140453
140524
  }
140454
- const isEmpty = children === void 0 || start >= children.length || count16 === 0;
140525
+ const isEmpty = children === void 0 || start >= children.length || count17 === 0;
140455
140526
  if (isEmpty && format & 32768) {
140456
140527
  onBeforeEmitNodeArray == null ? void 0 : onBeforeEmitNodeArray(children);
140457
140528
  onAfterEmitNodeArray == null ? void 0 : onAfterEmitNodeArray(children);
@@ -140475,7 +140546,7 @@ ${lanes.join("\n")}
140475
140546
  writeSpace();
140476
140547
  }
140477
140548
  } else {
140478
- emitNodeListItems(emit2, parentNode, children, format, parenthesizerRule, start, count16, children.hasTrailingComma, children);
140549
+ emitNodeListItems(emit2, parentNode, children, format, parenthesizerRule, start, count17, children.hasTrailingComma, children);
140479
140550
  }
140480
140551
  onAfterEmitNodeArray == null ? void 0 : onAfterEmitNodeArray(children);
140481
140552
  if (format & 15360) {
@@ -140485,7 +140556,7 @@ ${lanes.join("\n")}
140485
140556
  writePunctuation(getClosingBracket(format));
140486
140557
  }
140487
140558
  }
140488
- function emitNodeListItems(emit2, parentNode, children, format, parenthesizerRule, start, count16, hasTrailingComma, childrenTextRange) {
140559
+ function emitNodeListItems(emit2, parentNode, children, format, parenthesizerRule, start, count17, hasTrailingComma, childrenTextRange) {
140489
140560
  const mayEmitInterveningComments = (format & 262144) === 0;
140490
140561
  let shouldEmitInterveningComments = mayEmitInterveningComments;
140491
140562
  const leadingLineTerminatorCount = getLeadingLineTerminatorCount(parentNode, children[start], format);
@@ -140501,7 +140572,7 @@ ${lanes.join("\n")}
140501
140572
  const emitListItem = getEmitListItem(emit2, parenthesizerRule);
140502
140573
  let previousSibling;
140503
140574
  let shouldDecreaseIndentAfterEmit = false;
140504
- for (let i2 = 0; i2 < count16; i2++) {
140575
+ for (let i2 = 0; i2 < count17; i2++) {
140505
140576
  const child = children[start + i2];
140506
140577
  if (format & 32) {
140507
140578
  writeLine();
@@ -140566,7 +140637,7 @@ ${lanes.join("\n")}
140566
140637
  if (format & 128) {
140567
140638
  decreaseIndent();
140568
140639
  }
140569
- const closingLineTerminatorCount = getClosingLineTerminatorCount(parentNode, children[start + count16 - 1], format, childrenTextRange);
140640
+ const closingLineTerminatorCount = getClosingLineTerminatorCount(parentNode, children[start + count17 - 1], format, childrenTextRange);
140570
140641
  if (closingLineTerminatorCount) {
140571
140642
  writeLine(closingLineTerminatorCount);
140572
140643
  } else if (format & (2097152 | 256)) {
@@ -140616,8 +140687,8 @@ ${lanes.join("\n")}
140616
140687
  writer.write(s2);
140617
140688
  }
140618
140689
  }
140619
- function writeLine(count16 = 1) {
140620
- for (let i2 = 0; i2 < count16; i2++) {
140690
+ function writeLine(count17 = 1) {
140691
+ for (let i2 = 0; i2 < count17; i2++) {
140621
140692
  writer.writeLine(i2 > 0);
140622
140693
  }
140623
140694
  }
@@ -141146,10 +141217,10 @@ ${lanes.join("\n")}
141146
141217
  }
141147
141218
  }
141148
141219
  while (true) {
141149
- const count16 = tempFlags2 & 268435455;
141220
+ const count17 = tempFlags2 & 268435455;
141150
141221
  tempFlags2++;
141151
- if (count16 !== 8 && count16 !== 13) {
141152
- const name = count16 < 26 ? "_" + String.fromCharCode(97 + count16) : "_" + (count16 - 26);
141222
+ if (count17 !== 8 && count17 !== 13) {
141223
+ const name = count17 < 26 ? "_" + String.fromCharCode(97 + count17) : "_" + (count17 - 26);
141153
141224
  const fullName = formatGeneratedName(privateName, prefix, name, suffix);
141154
141225
  if (isUniqueName(fullName, privateName)) {
141155
141226
  if (privateName) {
@@ -153232,12 +153303,12 @@ ${lanes.join("\n")}
153232
153303
  for (const line of output) {
153233
153304
  sys2.write(line);
153234
153305
  }
153235
- function example(ex, desc15) {
153306
+ function example(ex, desc16) {
153236
153307
  const examples = typeof ex === "string" ? [ex] : ex;
153237
153308
  for (const example2 of examples) {
153238
153309
  output.push(" " + colors.blue(example2) + sys2.newLine);
153239
153310
  }
153240
- output.push(" " + getDiagnosticText(desc15) + sys2.newLine + sys2.newLine);
153311
+ output.push(" " + getDiagnosticText(desc16) + sys2.newLine + sys2.newLine);
153241
153312
  }
153242
153313
  }
153243
153314
  function printAllHelp(sys2, compilerOptions, buildOptions, watchOptions) {
@@ -153889,7 +153960,7 @@ ${lanes.join("\n")}
153889
153960
  reportCountStatistic("Lines of " + key, value);
153890
153961
  }
153891
153962
  } else {
153892
- reportCountStatistic("Lines", reduceLeftIterator(lineCounts.values(), (sum, count16) => sum + count16, 0));
153963
+ reportCountStatistic("Lines", reduceLeftIterator(lineCounts.values(), (sum, count17) => sum + count17, 0));
153893
153964
  }
153894
153965
  reportCountStatistic("Identifiers", program2.getIdentifierCount());
153895
153966
  reportCountStatistic("Symbols", program2.getSymbolCount());
@@ -153994,11 +154065,11 @@ ${lanes.join("\n")}
153994
154065
  statistics.push(s2);
153995
154066
  if (aggregate) solutionPerformance == null ? void 0 : solutionPerformance.addAggregateStatistic(s2);
153996
154067
  }
153997
- function reportCountStatistic(name, count16) {
154068
+ function reportCountStatistic(name, count17) {
153998
154069
  reportStatisticalValue(
153999
154070
  {
154000
154071
  name,
154001
- value: count16,
154072
+ value: count17,
154002
154073
  type: 1
154003
154074
  /* count */
154004
154075
  },
@@ -154499,8 +154570,8 @@ ${lanes.join("\n")}
154499
154570
  nonlocalNode ? visitNodesWithoutCopyingPositions : void 0
154500
154571
  );
154501
154572
  }
154502
- function visitNodesWithoutCopyingPositions(nodes, visitor, test, start, count16) {
154503
- let result = visitNodes2(nodes, visitor, test, start, count16);
154573
+ function visitNodesWithoutCopyingPositions(nodes, visitor, test, start, count17) {
154574
+ let result = visitNodes2(nodes, visitor, test, start, count17);
154504
154575
  if (result) {
154505
154576
  if (result.pos !== -1 || result.end !== -1) {
154506
154577
  if (result === nodes) {
@@ -157394,9 +157465,9 @@ ${lanes.join("\n")}
157394
157465
  function getSnapshotText(snap) {
157395
157466
  return snap.getText(0, snap.getLength());
157396
157467
  }
157397
- function repeatString(str, count16) {
157468
+ function repeatString(str, count17) {
157398
157469
  let result = "";
157399
- for (let i2 = 0; i2 < count16; i2++) {
157470
+ for (let i2 = 0; i2 < count17; i2++) {
157400
157471
  result += str;
157401
157472
  }
157402
157473
  return result;
@@ -175528,7 +175599,7 @@ ${newComment.split("\n").map((c2) => ` * ${c2}`).join("\n")}
175528
175599
  const maybeHeritageClauseSymbol = getHeritageClauseSymbolTable(classDeclaration, checker);
175529
175600
  const implementedType = checker.getTypeAtLocation(implementedTypeNode);
175530
175601
  const implementedTypeSymbols = checker.getPropertiesOfType(implementedType);
175531
- const nonPrivateAndNotExistedInHeritageClauseMembers = implementedTypeSymbols.filter(and20(symbolPointsToNonPrivateMember, (symbol) => !maybeHeritageClauseSymbol.has(symbol.escapedName)));
175602
+ const nonPrivateAndNotExistedInHeritageClauseMembers = implementedTypeSymbols.filter(and21(symbolPointsToNonPrivateMember, (symbol) => !maybeHeritageClauseSymbol.has(symbol.escapedName)));
175532
175603
  const classType = checker.getTypeAtLocation(classDeclaration);
175533
175604
  const constructor = find(classDeclaration.members, (m2) => isConstructorDeclaration(m2));
175534
175605
  if (!classType.getNumberIndexType()) {
@@ -190203,8 +190274,8 @@ ${newComment.split("\n").map((c2) => ` * ${c2}`).join("\n")}
190203
190274
  function isAmbientModuleDeclaration(node) {
190204
190275
  return node.kind === 268 && node.name.kind === 11;
190205
190276
  }
190206
- function isExternalModuleImportEquals(eq20) {
190207
- return eq20.moduleReference.kind === 284 && eq20.moduleReference.expression.kind === 11;
190277
+ function isExternalModuleImportEquals(eq21) {
190278
+ return eq21.moduleReference.kind === 284 && eq21.moduleReference.expression.kind === 11;
190208
190279
  }
190209
190280
  var DefinitionKind = /* @__PURE__ */ ((DefinitionKind2) => {
190210
190281
  DefinitionKind2[DefinitionKind2["Symbol"] = 0] = "Symbol";
@@ -195853,13 +195924,13 @@ ${content}
195853
195924
  if (candidates[i2] === resolvedSignature) {
195854
195925
  selectedItemIndex = itemsSeen;
195855
195926
  if (item.length > 1) {
195856
- let count16 = 0;
195927
+ let count17 = 0;
195857
195928
  for (const i22 of item) {
195858
195929
  if (i22.isVariadic || i22.parameters.length >= argumentCount) {
195859
- selectedItemIndex = itemsSeen + count16;
195930
+ selectedItemIndex = itemsSeen + count17;
195860
195931
  break;
195861
195932
  }
195862
- count16++;
195933
+ count17++;
195863
195934
  }
195864
195935
  }
195865
195936
  }
@@ -198160,8 +198231,8 @@ ${options.prefix}` : "\n" : options.prefix
198160
198231
  setTextRangePosEnd(newNode, getPos2(node), getEnd(node));
198161
198232
  return newNode;
198162
198233
  }
198163
- function assignPositionsToNodeArray(nodes, visitor, test, start, count16) {
198164
- const visited = visitNodes2(nodes, visitor, test, start, count16);
198234
+ function assignPositionsToNodeArray(nodes, visitor, test, start, count17) {
198235
+ const visited = visitNodes2(nodes, visitor, test, start, count17);
198165
198236
  if (!visited) {
198166
198237
  return visited;
198167
198238
  }
@@ -202838,7 +202909,7 @@ ${options.prefix}` : "\n" : options.prefix
202838
202909
  affectsEmitOptionDeclarations: () => affectsEmitOptionDeclarations,
202839
202910
  allKeysStartWithDot: () => allKeysStartWithDot,
202840
202911
  altDirectorySeparator: () => altDirectorySeparator,
202841
- and: () => and20,
202912
+ and: () => and21,
202842
202913
  append: () => append,
202843
202914
  appendIfUnique: () => appendIfUnique,
202844
202915
  arrayFrom: () => arrayFrom,
@@ -217916,19 +217987,29 @@ var init_functionTools = __esm({
217916
217987
  }
217917
217988
  });
217918
217989
 
217990
+ // ../packages/agents-core/src/data-access/subAgentExternalAgentRelations.ts
217991
+ import { and as and5, count as count4, desc as desc4, eq as eq5 } from "drizzle-orm";
217992
+ var init_subAgentExternalAgentRelations = __esm({
217993
+ "../packages/agents-core/src/data-access/subAgentExternalAgentRelations.ts"() {
217994
+ "use strict";
217995
+ init_esm_shims();
217996
+ init_schema();
217997
+ }
217998
+ });
217999
+
217919
218000
  // ../packages/agents-core/src/data-access/subAgentRelations.ts
217920
- import { and as and5, count as count4, desc as desc4, eq as eq5, isNotNull } from "drizzle-orm";
218001
+ import { and as and6, count as count5, desc as desc5, eq as eq6, isNotNull } from "drizzle-orm";
217921
218002
  var init_subAgentRelations = __esm({
217922
218003
  "../packages/agents-core/src/data-access/subAgentRelations.ts"() {
217923
218004
  "use strict";
217924
218005
  init_esm_shims();
217925
- init_conversations();
217926
218006
  init_schema();
218007
+ init_conversations();
217927
218008
  }
217928
218009
  });
217929
218010
 
217930
218011
  // ../packages/agents-core/src/data-access/subAgents.ts
217931
- import { and as and6, count as count5, desc as desc5, eq as eq6, inArray } from "drizzle-orm";
218012
+ import { and as and7, count as count6, desc as desc6, eq as eq7, inArray } from "drizzle-orm";
217932
218013
  var init_subAgents = __esm({
217933
218014
  "../packages/agents-core/src/data-access/subAgents.ts"() {
217934
218015
  "use strict";
@@ -220879,26 +220960,26 @@ var require_resolve = __commonJS({
220879
220960
  return true;
220880
220961
  }
220881
220962
  function countKeys(schema) {
220882
- var count16 = 0, item;
220963
+ var count17 = 0, item;
220883
220964
  if (Array.isArray(schema)) {
220884
220965
  for (var i2 = 0; i2 < schema.length; i2++) {
220885
220966
  item = schema[i2];
220886
- if (typeof item == "object") count16 += countKeys(item);
220887
- if (count16 == Infinity) return Infinity;
220967
+ if (typeof item == "object") count17 += countKeys(item);
220968
+ if (count17 == Infinity) return Infinity;
220888
220969
  }
220889
220970
  } else {
220890
220971
  for (var key in schema) {
220891
220972
  if (key == "$ref") return Infinity;
220892
220973
  if (SIMPLE_INLINED[key]) {
220893
- count16++;
220974
+ count17++;
220894
220975
  } else {
220895
220976
  item = schema[key];
220896
- if (typeof item == "object") count16 += countKeys(item) + 1;
220897
- if (count16 == Infinity) return Infinity;
220977
+ if (typeof item == "object") count17 += countKeys(item) + 1;
220978
+ if (count17 == Infinity) return Infinity;
220898
220979
  }
220899
220980
  }
220900
220981
  }
220901
- return count16;
220982
+ return count17;
220902
220983
  }
220903
220984
  function getFullPath(id, normalize) {
220904
220985
  if (normalize !== false) id = normalizeId(id);
@@ -226828,7 +226909,7 @@ var init_utils = __esm({
226828
226909
  });
226829
226910
 
226830
226911
  // ../packages/agents-core/src/data-access/credentialReferences.ts
226831
- import { and as and7, count as count6, desc as desc6, eq as eq7, sql as sql3 } from "drizzle-orm";
226912
+ import { and as and8, count as count7, desc as desc7, eq as eq8, sql as sql3 } from "drizzle-orm";
226832
226913
  var init_credentialReferences = __esm({
226833
226914
  "../packages/agents-core/src/data-access/credentialReferences.ts"() {
226834
226915
  "use strict";
@@ -226838,7 +226919,7 @@ var init_credentialReferences = __esm({
226838
226919
  });
226839
226920
 
226840
226921
  // ../packages/agents-core/src/data-access/tools.ts
226841
- import { and as and8, count as count7, desc as desc7, eq as eq8 } from "drizzle-orm";
226922
+ import { and as and9, count as count8, desc as desc8, eq as eq9 } from "drizzle-orm";
226842
226923
  var logger7;
226843
226924
  var init_tools = __esm({
226844
226925
  "../packages/agents-core/src/data-access/tools.ts"() {
@@ -226859,7 +226940,7 @@ var init_tools = __esm({
226859
226940
  });
226860
226941
 
226861
226942
  // ../packages/agents-core/src/data-access/agents.ts
226862
- import { and as and9, count as count8, desc as desc8, eq as eq9, inArray as inArray2 } from "drizzle-orm";
226943
+ import { and as and10, count as count9, desc as desc9, eq as eq10, inArray as inArray2 } from "drizzle-orm";
226863
226944
  var init_agents = __esm({
226864
226945
  "../packages/agents-core/src/data-access/agents.ts"() {
226865
226946
  "use strict";
@@ -226870,6 +226951,7 @@ var init_agents = __esm({
226870
226951
  init_externalAgents();
226871
226952
  init_functions();
226872
226953
  init_functionTools();
226954
+ init_subAgentExternalAgentRelations();
226873
226955
  init_subAgentRelations();
226874
226956
  init_subAgents();
226875
226957
  init_tools();
@@ -226877,7 +226959,7 @@ var init_agents = __esm({
226877
226959
  });
226878
226960
 
226879
226961
  // ../packages/agents-core/src/data-access/apiKeys.ts
226880
- import { and as and10, count as count9, desc as desc9, eq as eq10 } from "drizzle-orm";
226962
+ import { and as and11, count as count10, desc as desc10, eq as eq11 } from "drizzle-orm";
226881
226963
  var init_apiKeys2 = __esm({
226882
226964
  "../packages/agents-core/src/data-access/apiKeys.ts"() {
226883
226965
  "use strict";
@@ -227891,10 +227973,10 @@ var require_codegen = __commonJS({
227891
227973
  }
227892
227974
  exports.not = not2;
227893
227975
  var andCode = mappend(exports.operators.AND);
227894
- function and20(...args) {
227976
+ function and21(...args) {
227895
227977
  return args.reduce(andCode);
227896
227978
  }
227897
- exports.and = and20;
227979
+ exports.and = and21;
227898
227980
  var orCode = mappend(exports.operators.OR);
227899
227981
  function or(...args) {
227900
227982
  return args.reduce(orCode);
@@ -229055,20 +229137,20 @@ var require_resolve2 = __commonJS({
229055
229137
  return false;
229056
229138
  }
229057
229139
  function countKeys(schema) {
229058
- let count16 = 0;
229140
+ let count17 = 0;
229059
229141
  for (const key in schema) {
229060
229142
  if (key === "$ref")
229061
229143
  return Infinity;
229062
- count16++;
229144
+ count17++;
229063
229145
  if (SIMPLE_INLINED.has(key))
229064
229146
  continue;
229065
229147
  if (typeof schema[key] == "object") {
229066
- (0, util_1.eachItem)(schema[key], (sch) => count16 += countKeys(sch));
229148
+ (0, util_1.eachItem)(schema[key], (sch) => count17 += countKeys(sch));
229067
229149
  }
229068
- if (count16 === Infinity)
229150
+ if (count17 === Infinity)
229069
229151
  return Infinity;
229070
229152
  }
229071
- return count16;
229153
+ return count17;
229072
229154
  }
229073
229155
  function getFullPath(resolver, id = "", normalize) {
229074
229156
  if (normalize !== false)
@@ -232174,8 +232256,8 @@ var require_contains2 = __commonJS({
232174
232256
  cxt.result(valid, () => cxt.reset());
232175
232257
  function validateItemsWithCount() {
232176
232258
  const schValid = gen.name("_valid");
232177
- const count16 = gen.let("count", 0);
232178
- validateItems(schValid, () => gen.if(schValid, () => checkLimits(count16)));
232259
+ const count17 = gen.let("count", 0);
232260
+ validateItems(schValid, () => gen.if(schValid, () => checkLimits(count17)));
232179
232261
  }
232180
232262
  function validateItems(_valid, block) {
232181
232263
  gen.forRange("i", 0, len, (i2) => {
@@ -232188,16 +232270,16 @@ var require_contains2 = __commonJS({
232188
232270
  block();
232189
232271
  });
232190
232272
  }
232191
- function checkLimits(count16) {
232192
- gen.code((0, codegen_1._)`${count16}++`);
232273
+ function checkLimits(count17) {
232274
+ gen.code((0, codegen_1._)`${count17}++`);
232193
232275
  if (max === void 0) {
232194
- gen.if((0, codegen_1._)`${count16} >= ${min}`, () => gen.assign(valid, true).break());
232276
+ gen.if((0, codegen_1._)`${count17} >= ${min}`, () => gen.assign(valid, true).break());
232195
232277
  } else {
232196
- gen.if((0, codegen_1._)`${count16} > ${max}`, () => gen.assign(valid, false).break());
232278
+ gen.if((0, codegen_1._)`${count17} > ${max}`, () => gen.assign(valid, false).break());
232197
232279
  if (min === 1)
232198
232280
  gen.assign(valid, true);
232199
232281
  else
232200
- gen.if((0, codegen_1._)`${count16} >= ${min}`, () => gen.assign(valid, true));
232282
+ gen.if((0, codegen_1._)`${count17} >= ${min}`, () => gen.assign(valid, true));
232201
232283
  }
232202
232284
  }
232203
232285
  }
@@ -233371,7 +233453,7 @@ var init_props_validation = __esm({
233371
233453
  });
233372
233454
 
233373
233455
  // ../packages/agents-core/src/data-access/artifactComponents.ts
233374
- import { and as and11, count as count10, desc as desc10, eq as eq11 } from "drizzle-orm";
233456
+ import { and as and12, count as count11, desc as desc11, eq as eq12 } from "drizzle-orm";
233375
233457
  var init_artifactComponents = __esm({
233376
233458
  "../packages/agents-core/src/data-access/artifactComponents.ts"() {
233377
233459
  "use strict";
@@ -233383,7 +233465,7 @@ var init_artifactComponents = __esm({
233383
233465
  });
233384
233466
 
233385
233467
  // ../packages/agents-core/src/data-access/contextCache.ts
233386
- import { and as and12, eq as eq12 } from "drizzle-orm";
233468
+ import { and as and13, eq as eq13 } from "drizzle-orm";
233387
233469
  var init_contextCache = __esm({
233388
233470
  "../packages/agents-core/src/data-access/contextCache.ts"() {
233389
233471
  "use strict";
@@ -233394,7 +233476,7 @@ var init_contextCache = __esm({
233394
233476
  });
233395
233477
 
233396
233478
  // ../packages/agents-core/src/data-access/conversations.ts
233397
- import { and as and13, count as count11, desc as desc11, eq as eq13 } from "drizzle-orm";
233479
+ import { and as and14, count as count12, desc as desc12, eq as eq14 } from "drizzle-orm";
233398
233480
  var init_conversations2 = __esm({
233399
233481
  "../packages/agents-core/src/data-access/conversations.ts"() {
233400
233482
  "use strict";
@@ -233413,7 +233495,7 @@ var init_preview_validation = __esm({
233413
233495
  });
233414
233496
 
233415
233497
  // ../packages/agents-core/src/data-access/dataComponents.ts
233416
- import { and as and14, count as count12, desc as desc12, eq as eq14 } from "drizzle-orm";
233498
+ import { and as and15, count as count13, desc as desc13, eq as eq15 } from "drizzle-orm";
233417
233499
  var init_dataComponents = __esm({
233418
233500
  "../packages/agents-core/src/data-access/dataComponents.ts"() {
233419
233501
  "use strict";
@@ -233435,21 +233517,21 @@ var init_agentFull = __esm({
233435
233517
  });
233436
233518
 
233437
233519
  // ../packages/agents-core/src/data-access/agentFull.ts
233438
- import { and as and15, eq as eq15, inArray as inArray3, not } from "drizzle-orm";
233520
+ import { and as and16, eq as eq16, inArray as inArray3, not } from "drizzle-orm";
233439
233521
  var init_agentFull2 = __esm({
233440
233522
  "../packages/agents-core/src/data-access/agentFull.ts"() {
233441
233523
  "use strict";
233442
233524
  init_esm_shims();
233443
- init_conversations();
233444
233525
  init_schema();
233526
+ init_conversations();
233445
233527
  init_agentFull();
233446
233528
  init_agents();
233447
233529
  init_artifactComponents();
233448
233530
  init_contextConfigs();
233449
233531
  init_dataComponents();
233450
- init_externalAgents();
233451
233532
  init_functions();
233452
233533
  init_functionTools();
233534
+ init_subAgentExternalAgentRelations();
233453
233535
  init_subAgentRelations();
233454
233536
  init_subAgents();
233455
233537
  init_tools();
@@ -233457,7 +233539,7 @@ var init_agentFull2 = __esm({
233457
233539
  });
233458
233540
 
233459
233541
  // ../packages/agents-core/src/data-access/ledgerArtifacts.ts
233460
- import { and as and16, count as count13, eq as eq16 } from "drizzle-orm";
233542
+ import { and as and17, count as count14, eq as eq17 } from "drizzle-orm";
233461
233543
  var init_ledgerArtifacts = __esm({
233462
233544
  "../packages/agents-core/src/data-access/ledgerArtifacts.ts"() {
233463
233545
  "use strict";
@@ -233468,7 +233550,7 @@ var init_ledgerArtifacts = __esm({
233468
233550
  });
233469
233551
 
233470
233552
  // ../packages/agents-core/src/data-access/messages.ts
233471
- import { and as and17, asc as asc2, count as count14, desc as desc13, eq as eq17, inArray as inArray4 } from "drizzle-orm";
233553
+ import { and as and18, asc as asc2, count as count15, desc as desc14, eq as eq18, inArray as inArray4 } from "drizzle-orm";
233472
233554
  var init_messages = __esm({
233473
233555
  "../packages/agents-core/src/data-access/messages.ts"() {
233474
233556
  "use strict";
@@ -233478,7 +233560,7 @@ var init_messages = __esm({
233478
233560
  });
233479
233561
 
233480
233562
  // ../packages/agents-core/src/data-access/projects.ts
233481
- import { and as and18, count as count15, desc as desc14, eq as eq18 } from "drizzle-orm";
233563
+ import { and as and19, count as count16, desc as desc15, eq as eq19 } from "drizzle-orm";
233482
233564
  var init_projects = __esm({
233483
233565
  "../packages/agents-core/src/data-access/projects.ts"() {
233484
233566
  "use strict";
@@ -233499,6 +233581,7 @@ var init_projectFull = __esm({
233499
233581
  init_artifactComponents();
233500
233582
  init_credentialReferences();
233501
233583
  init_dataComponents();
233584
+ init_externalAgents();
233502
233585
  init_functions();
233503
233586
  init_projects();
233504
233587
  init_tools();
@@ -233507,7 +233590,7 @@ var init_projectFull = __esm({
233507
233590
  });
233508
233591
 
233509
233592
  // ../packages/agents-core/src/data-access/tasks.ts
233510
- import { and as and19, eq as eq19 } from "drizzle-orm";
233593
+ import { and as and20, eq as eq20 } from "drizzle-orm";
233511
233594
  var init_tasks = __esm({
233512
233595
  "../packages/agents-core/src/data-access/tasks.ts"() {
233513
233596
  "use strict";
@@ -233547,6 +233630,7 @@ var init_data_access = __esm({
233547
233630
  init_messages();
233548
233631
  init_projectFull();
233549
233632
  init_projects();
233633
+ init_subAgentExternalAgentRelations();
233550
233634
  init_subAgentRelations();
233551
233635
  init_subAgents();
233552
233636
  init_tasks();
@@ -234301,6 +234385,338 @@ var init_config = __esm({
234301
234385
  }
234302
234386
  });
234303
234387
 
234388
+ // src/codegen/variable-name-registry.ts
234389
+ var variable_name_registry_exports = {};
234390
+ __export(variable_name_registry_exports, {
234391
+ DEFAULT_NAMING_CONVENTIONS: () => DEFAULT_NAMING_CONVENTIONS,
234392
+ VariableNameGenerator: () => VariableNameGenerator,
234393
+ collectAllEntities: () => collectAllEntities
234394
+ });
234395
+ function collectAllEntities(projectData) {
234396
+ const entities = [];
234397
+ entities.push({ id: projectData.id, type: "project", data: projectData });
234398
+ if (projectData.agents) {
234399
+ for (const [agentId, agentData] of Object.entries(projectData.agents)) {
234400
+ entities.push({ id: agentId, type: "agent", data: agentData });
234401
+ const agentObj = agentData;
234402
+ if (agentObj.subAgents) {
234403
+ for (const [subAgentId, subAgentData] of Object.entries(agentObj.subAgents)) {
234404
+ entities.push({ id: subAgentId, type: "subAgent", data: subAgentData });
234405
+ }
234406
+ }
234407
+ }
234408
+ }
234409
+ if (projectData.tools) {
234410
+ for (const [toolId, toolData] of Object.entries(projectData.tools)) {
234411
+ entities.push({ id: toolId, type: "tool", data: toolData });
234412
+ }
234413
+ }
234414
+ if (projectData.dataComponents) {
234415
+ for (const [compId, compData] of Object.entries(projectData.dataComponents)) {
234416
+ entities.push({ id: compId, type: "dataComponent", data: compData });
234417
+ }
234418
+ }
234419
+ if (projectData.artifactComponents) {
234420
+ for (const [compId, compData] of Object.entries(projectData.artifactComponents)) {
234421
+ entities.push({ id: compId, type: "artifactComponent", data: compData });
234422
+ }
234423
+ }
234424
+ if (projectData.externalAgents) {
234425
+ for (const [agentId, agentData] of Object.entries(projectData.externalAgents)) {
234426
+ entities.push({ id: agentId, type: "externalAgent", data: agentData });
234427
+ }
234428
+ }
234429
+ if (projectData.agents) {
234430
+ for (const [_agentId, agentData] of Object.entries(projectData.agents)) {
234431
+ const agentObj = agentData;
234432
+ if (agentObj.statusUpdates?.statusComponents) {
234433
+ for (const statusComp of agentObj.statusUpdates.statusComponents) {
234434
+ if (statusComp.type) {
234435
+ entities.push({ id: statusComp.type, type: "statusComponent" });
234436
+ }
234437
+ }
234438
+ }
234439
+ }
234440
+ }
234441
+ const credentialReferences2 = /* @__PURE__ */ new Set();
234442
+ if (projectData.credentialReferences) {
234443
+ for (const credId of Object.keys(projectData.credentialReferences)) {
234444
+ credentialReferences2.add(credId);
234445
+ }
234446
+ }
234447
+ if (projectData.tools) {
234448
+ for (const [_toolId, toolData] of Object.entries(projectData.tools)) {
234449
+ const tool2 = toolData;
234450
+ if (tool2.credentialReferenceId) {
234451
+ credentialReferences2.add(tool2.credentialReferenceId);
234452
+ }
234453
+ }
234454
+ }
234455
+ if (projectData.externalAgents) {
234456
+ for (const [_agentId, agentData] of Object.entries(projectData.externalAgents)) {
234457
+ const agent = agentData;
234458
+ if (agent.credentialReferenceId) {
234459
+ credentialReferences2.add(agent.credentialReferenceId);
234460
+ }
234461
+ }
234462
+ }
234463
+ if (projectData.agents) {
234464
+ for (const [_agentId, agentData] of Object.entries(projectData.agents)) {
234465
+ const agent = agentData;
234466
+ if (agent.contextConfig?.headers?.credentialReferenceId) {
234467
+ credentialReferences2.add(agent.contextConfig.headers.credentialReferenceId);
234468
+ }
234469
+ if (agent.contextConfig?.contextVariables) {
234470
+ for (const [_varId, varData] of Object.entries(agent.contextConfig.contextVariables)) {
234471
+ const contextVar = varData;
234472
+ if (contextVar.credentialReferenceId) {
234473
+ credentialReferences2.add(contextVar.credentialReferenceId);
234474
+ }
234475
+ }
234476
+ }
234477
+ if (agent.subAgents) {
234478
+ for (const [_subAgentId, subAgentData] of Object.entries(agent.subAgents)) {
234479
+ const subAgent = subAgentData;
234480
+ if (subAgent.contextConfig?.headers?.credentialReferenceId) {
234481
+ credentialReferences2.add(subAgent.contextConfig.headers.credentialReferenceId);
234482
+ }
234483
+ if (subAgent.contextConfig?.contextVariables) {
234484
+ for (const [_varId, varData] of Object.entries(
234485
+ subAgent.contextConfig.contextVariables
234486
+ )) {
234487
+ const contextVar = varData;
234488
+ if (contextVar.credentialReferenceId) {
234489
+ credentialReferences2.add(contextVar.credentialReferenceId);
234490
+ }
234491
+ }
234492
+ }
234493
+ }
234494
+ }
234495
+ }
234496
+ }
234497
+ return entities;
234498
+ }
234499
+ var DEFAULT_NAMING_CONVENTIONS, VariableNameGenerator;
234500
+ var init_variable_name_registry = __esm({
234501
+ "src/codegen/variable-name-registry.ts"() {
234502
+ "use strict";
234503
+ init_esm_shims();
234504
+ DEFAULT_NAMING_CONVENTIONS = {
234505
+ projectSuffix: "Project",
234506
+ agentSuffix: "Agent",
234507
+ subAgentSuffix: "SubAgent",
234508
+ toolSuffix: null,
234509
+ // Usually no suffix needed
234510
+ dataComponentSuffix: null,
234511
+ artifactComponentSuffix: null,
234512
+ statusComponentSuffix: null,
234513
+ credentialSuffix: null,
234514
+ environmentSuffix: null,
234515
+ // No suffix needed for environments
234516
+ externalAgentSuffix: null
234517
+ };
234518
+ VariableNameGenerator = class {
234519
+ registry;
234520
+ conventions;
234521
+ conflicts;
234522
+ constructor(conventions = DEFAULT_NAMING_CONVENTIONS) {
234523
+ this.registry = {
234524
+ projects: /* @__PURE__ */ new Map(),
234525
+ agents: /* @__PURE__ */ new Map(),
234526
+ subAgents: /* @__PURE__ */ new Map(),
234527
+ tools: /* @__PURE__ */ new Map(),
234528
+ dataComponents: /* @__PURE__ */ new Map(),
234529
+ artifactComponents: /* @__PURE__ */ new Map(),
234530
+ statusComponents: /* @__PURE__ */ new Map(),
234531
+ credentials: /* @__PURE__ */ new Map(),
234532
+ environments: /* @__PURE__ */ new Map(),
234533
+ externalAgents: /* @__PURE__ */ new Map(),
234534
+ usedNames: /* @__PURE__ */ new Map()
234535
+ };
234536
+ this.conventions = conventions;
234537
+ this.conflicts = [];
234538
+ }
234539
+ /**
234540
+ * Generate unique variable name for an entity
234541
+ * Ensures no conflicts across all entity types
234542
+ */
234543
+ generateVariableName(id, entityType, entityData) {
234544
+ const registryMap = this.getRegistryMap(entityType);
234545
+ const existing = registryMap.get(id);
234546
+ if (existing) {
234547
+ return existing;
234548
+ }
234549
+ let baseName;
234550
+ if (entityType === "tool" && entityData?.name && this.isRandomId(id)) {
234551
+ baseName = this.idToVariableName(entityData.name);
234552
+ } else {
234553
+ baseName = this.idToVariableName(id);
234554
+ }
234555
+ if (!this.registry.usedNames.has(baseName)) {
234556
+ this.register(id, baseName, entityType);
234557
+ return baseName;
234558
+ }
234559
+ const existingEntity = this.registry.usedNames.get(baseName);
234560
+ if (existingEntity) {
234561
+ const existingConflict = this.conflicts.find((c2) => c2.id === id);
234562
+ if (existingConflict) {
234563
+ existingConflict.types.push(entityType);
234564
+ } else {
234565
+ this.conflicts.push({
234566
+ id,
234567
+ types: [existingEntity.type, entityType],
234568
+ resolvedNames: {
234569
+ [existingEntity.type]: baseName
234570
+ }
234571
+ });
234572
+ }
234573
+ }
234574
+ const suffix = this.getSuffixForType(entityType);
234575
+ const uniqueName = baseName + suffix;
234576
+ let finalName = uniqueName;
234577
+ let counter = 2;
234578
+ while (this.registry.usedNames.has(finalName)) {
234579
+ finalName = `${uniqueName}${counter}`;
234580
+ counter++;
234581
+ }
234582
+ this.register(id, finalName, entityType);
234583
+ const conflict = this.conflicts.find((c2) => c2.id === id);
234584
+ if (conflict) {
234585
+ conflict.resolvedNames[entityType] = finalName;
234586
+ }
234587
+ return finalName;
234588
+ }
234589
+ /**
234590
+ * Register an existing variable name (from detected patterns)
234591
+ */
234592
+ register(id, variableName, entityType) {
234593
+ const registryMap = this.getRegistryMap(entityType);
234594
+ registryMap.set(id, variableName);
234595
+ this.registry.usedNames.set(variableName, { id, type: entityType });
234596
+ }
234597
+ /**
234598
+ * Get the registry for lookup
234599
+ */
234600
+ getRegistry() {
234601
+ return this.registry;
234602
+ }
234603
+ /**
234604
+ * Get all conflicts that were resolved
234605
+ */
234606
+ getConflicts() {
234607
+ return this.conflicts;
234608
+ }
234609
+ /**
234610
+ * Convert ID to camelCase variable name
234611
+ */
234612
+ idToVariableName(id) {
234613
+ if (this.isRandomId(id)) {
234614
+ return id;
234615
+ }
234616
+ const parts = id.split(/[-_]/);
234617
+ const camelCase = parts.map((part, index2) => {
234618
+ if (index2 === 0) {
234619
+ return part.toLowerCase();
234620
+ }
234621
+ return part.charAt(0).toUpperCase() + part.slice(1).toLowerCase();
234622
+ }).join("");
234623
+ return camelCase;
234624
+ }
234625
+ /**
234626
+ * Check if an ID looks random/UUID-like
234627
+ */
234628
+ isRandomId(id) {
234629
+ if (!id.includes("-") && !id.includes("_")) {
234630
+ return /[0-9]/.test(id) || /[A-Z]/.test(id);
234631
+ }
234632
+ return false;
234633
+ }
234634
+ /**
234635
+ * Generate filename from entity data (for file naming)
234636
+ */
234637
+ generateFileName(id, entityType, entityData) {
234638
+ let baseName;
234639
+ if (entityType === "tool" && entityData?.name && this.isRandomId(id)) {
234640
+ baseName = this.nameToFileName(entityData.name);
234641
+ } else {
234642
+ baseName = this.idToFileName(id);
234643
+ }
234644
+ return baseName;
234645
+ }
234646
+ /**
234647
+ * Convert name to kebab-case filename
234648
+ */
234649
+ nameToFileName(name) {
234650
+ return name.replace(/[^\w\s-]/g, "").trim().replace(/\s+/g, "-").replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
234651
+ }
234652
+ /**
234653
+ * Convert ID to kebab-case filename
234654
+ */
234655
+ idToFileName(id) {
234656
+ return id.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
234657
+ }
234658
+ /**
234659
+ * Get appropriate suffix for entity type
234660
+ */
234661
+ getSuffixForType(entityType) {
234662
+ switch (entityType) {
234663
+ case "project":
234664
+ return this.conventions.projectSuffix;
234665
+ case "agent":
234666
+ return this.conventions.agentSuffix;
234667
+ case "subAgent":
234668
+ return this.conventions.subAgentSuffix;
234669
+ case "tool":
234670
+ return this.conventions.toolSuffix || "";
234671
+ case "dataComponent":
234672
+ return this.conventions.dataComponentSuffix || "";
234673
+ case "artifactComponent":
234674
+ return this.conventions.artifactComponentSuffix || "";
234675
+ case "statusComponent":
234676
+ return this.conventions.statusComponentSuffix || "";
234677
+ case "credential":
234678
+ return this.conventions.credentialSuffix || "";
234679
+ case "environment":
234680
+ return this.conventions.environmentSuffix || "";
234681
+ case "externalAgent":
234682
+ return this.conventions.externalAgentSuffix || "";
234683
+ default:
234684
+ return "";
234685
+ }
234686
+ }
234687
+ /**
234688
+ * Get the appropriate registry map for an entity type
234689
+ */
234690
+ getRegistryMap(entityType) {
234691
+ switch (entityType) {
234692
+ case "project":
234693
+ return this.registry.projects;
234694
+ case "agent":
234695
+ return this.registry.agents;
234696
+ case "subAgent":
234697
+ return this.registry.subAgents;
234698
+ case "tool":
234699
+ return this.registry.tools;
234700
+ case "dataComponent":
234701
+ return this.registry.dataComponents;
234702
+ case "artifactComponent":
234703
+ return this.registry.artifactComponents;
234704
+ case "statusComponent":
234705
+ return this.registry.statusComponents;
234706
+ case "credential":
234707
+ return this.registry.credentials;
234708
+ case "environment":
234709
+ return this.registry.environments;
234710
+ case "externalAgent":
234711
+ return this.registry.externalAgents;
234712
+ default:
234713
+ throw new Error(`Unknown entity type: ${entityType}`);
234714
+ }
234715
+ }
234716
+ };
234717
+ }
234718
+ });
234719
+
234304
234720
  // src/commands/pull.placeholder-system.ts
234305
234721
  import { randomBytes as randomBytes2 } from "crypto";
234306
234722
  import { jsonSchemaToZod } from "json-schema-to-zod";
@@ -234503,6 +234919,7 @@ __export(pull_llm_generate_exports, {
234503
234919
  generateDataComponentFile: () => generateDataComponentFile,
234504
234920
  generateEnvironmentFileTemplate: () => generateEnvironmentFileTemplate,
234505
234921
  generateEnvironmentFiles: () => generateEnvironmentFiles,
234922
+ generateExternalAgentFile: () => generateExternalAgentFile,
234506
234923
  generateIndexFile: () => generateIndexFile,
234507
234924
  generateStatusComponentFile: () => generateStatusComponentFile,
234508
234925
  generateTextWithPlaceholders: () => generateTextWithPlaceholders,
@@ -234554,7 +234971,9 @@ function detectAvailableProvider() {
234554
234971
  if (googleKey) {
234555
234972
  return "google";
234556
234973
  }
234557
- throw new Error("No LLM provider API key found. Please set ANTHROPIC_API_KEY, OPENAI_API_KEY, or GOOGLE_API_KEY");
234974
+ throw new Error(
234975
+ "No LLM provider API key found. Please set ANTHROPIC_API_KEY, OPENAI_API_KEY, or GOOGLE_API_KEY"
234976
+ );
234558
234977
  }
234559
234978
  function getDefaultModelForProvider(provider) {
234560
234979
  switch (provider) {
@@ -234726,7 +235145,7 @@ Generate ONLY the TypeScript code without any markdown or explanations.`;
234726
235145
  );
234727
235146
  writeFileSync3(outputPath, cleanGeneratedCode(text4));
234728
235147
  }
234729
- function generateImportMappings(toolFilenames, componentFilenames) {
235148
+ function generateImportMappings(toolFilenames, componentFilenames, externalAgentFilenames) {
234730
235149
  let result = "";
234731
235150
  if (toolFilenames && toolFilenames.size > 0) {
234732
235151
  result += "TOOLS (use exact import paths):\n";
@@ -234751,9 +235170,18 @@ function generateImportMappings(toolFilenames, componentFilenames) {
234751
235170
  `;
234752
235171
  }
234753
235172
  }
235173
+ if (externalAgentFilenames && externalAgentFilenames.size > 0) {
235174
+ result += "EXTERNAL AGENTS (use exact import paths):\n";
235175
+ for (const [externalAgentId, fileName] of externalAgentFilenames.entries()) {
235176
+ result += ` - External Agent ID: "${externalAgentId}" \u2192 Import: "../external-agents/${fileName.replace(".ts", "")}"
235177
+ `;
235178
+ }
235179
+ result += "\n";
235180
+ }
235181
+ console.log("result", result);
234754
235182
  return result;
234755
235183
  }
234756
- async function generateAgentFile(agentData, agentId, outputPath, modelSettings, toolFilenames, componentFilenames, debug = false, reasoningConfig) {
235184
+ async function generateAgentFile(agentData, agentId, outputPath, modelSettings, toolFilenames, componentFilenames, externalAgentFilenames, debug = false, reasoningConfig) {
234757
235185
  const model = createModel(modelSettings);
234758
235186
  const promptTemplate = `Generate a TypeScript file for an Inkeep agent.
234759
235187
 
@@ -234763,7 +235191,7 @@ AGENT DATA:
234763
235191
  AGENT ID: ${agentId}
234764
235192
 
234765
235193
  ${toolFilenames || componentFilenames ? `IMPORT PATH MAPPINGS (CRITICAL - USE EXACT PATHS):
234766
- ${generateImportMappings(toolFilenames, componentFilenames)}
235194
+ ${generateImportMappings(toolFilenames, componentFilenames, externalAgentFilenames)}
234767
235195
 
234768
235196
  !!! WARNING: Entity IDs \u2260 File Paths !!!
234769
235197
  - Entity IDs may use underscores or different naming
@@ -234796,6 +235224,7 @@ REQUIREMENTS:
234796
235224
  2. Define each agent using the agent() function following the type definitions provided above
234797
235225
  3. Create the agent using agent() with proper structure
234798
235226
  - IMPORTANT: If description is null, undefined, or empty string, omit the description field entirely
235227
+ 4. External agents live within the agents directory, import them using the import { externalAgent } from '../agents/external-agent'; syntax.
234799
235228
  4. CRITICAL: Template Literals vs Raw Code:
234800
235229
  - For STRING VALUES: ALWAYS use template literals with backticks: \`string content\`
234801
235230
  - This includes: prompt, description, query, url, method, body, defaultValue, etc.
@@ -234839,12 +235268,13 @@ prompt: \`<{{subAgents.facts.prompt.abc12345}}>\`
234839
235268
  prompt: '<{{subAgents.facts.prompt.abc12345}}>'
234840
235269
 
234841
235270
  FULL EXAMPLE:
234842
- import { agent, agent } from '@inkeep/agents-sdk';
235271
+ import { agent } from '@inkeep/agents-sdk';
234843
235272
  import { contextConfig, fetchDefinition, headers } from '@inkeep/agents-core';
234844
235273
  import { userProfile } from '../data-components/user-profile';
234845
235274
  import { searchTool } from '../tools/search-tool';
234846
235275
  import { weatherTool } from '../tools/weather-tool';
234847
235276
  import { toolSummary } from '../status-components/tool-summary';
235277
+ import { externalHelperAgent } from '../agents/external-helper-agent';
234848
235278
  import { progressStatus } from '../status-components/progress-status';
234849
235279
  import { z } from 'zod';
234850
235280
 
@@ -234885,6 +235315,7 @@ const routerAgent = agent({
234885
235315
  name: 'Router Agent',
234886
235316
  prompt: \`Route requests to appropriate agents using \${supportAgentContext.toTemplate('supportDescription.description')} for the user \${supportAgentHeaders.toTemplate('userId')}\`,
234887
235317
  canTransferTo: () => [qaAgent]
235318
+ canDelegateTo: () => [externalHelperAgent.with({ headers: { 'X-API-Key': '123' } })],
234888
235319
  });
234889
235320
 
234890
235321
  const qaAgent = agent({
@@ -234898,6 +235329,7 @@ Follow these rules:
234898
235329
  - Use the user's name \${supportAgentHeaders.toTemplate('userId')} when applicable
234899
235330
  - Use available tools\`,
234900
235331
  canUse: () => [searchTool, weatherTool],
235332
+ canDelegateTo: () => [externalHelperAgent],
234901
235333
  selectedTools: {
234902
235334
  [searchTool.id]: ['search_web', 'search_docs'],
234903
235335
  [weatherTool.id]: ['get_forecast']
@@ -235321,6 +235753,61 @@ Generate ONLY the TypeScript code without any markdown or explanations.`;
235321
235753
  );
235322
235754
  writeFileSync3(outputPath, cleanGeneratedCode(text4));
235323
235755
  }
235756
+ async function generateExternalAgentFile(externalAgentData, externalAgentId, outputPath, modelSettings, reasoningConfig) {
235757
+ const model = createModel(modelSettings);
235758
+ const promptTemplate = `Generate a TypeScript file for an Inkeep external agent.
235759
+
235760
+ EXTERNAL AGENT DATA:
235761
+ {{DATA}}
235762
+
235763
+ EXTERNAL AGENT ID: ${externalAgentId}
235764
+
235765
+ ${getTypeDefinitions()}
235766
+
235767
+ ${NAMING_CONVENTION_RULES}
235768
+
235769
+ ${IMPORT_INSTRUCTIONS}
235770
+
235771
+ REQUIREMENTS:
235772
+ 1. Import externalAgent from '@inkeep/agents-sdk'
235773
+ 3. Create the external agent using externalAgent()
235774
+ 4. Export following naming convention rules (camelCase version of ID)
235775
+ 5. Include all properties from the external agent data INCLUDING the 'id' property
235776
+ 6. CRITICAL: All imports must be alphabetically sorted to comply with Biome linting
235777
+ 7. CRITICAL: Use template literals with backticks for all STRING values (url, description, etc.)
235778
+
235779
+ EXAMPLE:
235780
+ import { externalAgent } from '@inkeep/agents-sdk';
235781
+ import { }
235782
+
235783
+ export const externalHelper = externalAgent({
235784
+ id: 'external-helper',
235785
+ name: 'External Helper',
235786
+ url: \`https://api.example.com/agent\`,
235787
+ credentialReference: 'my-credential-reference',
235788
+ });
235789
+
235790
+
235791
+ Generate ONLY the TypeScript code without any markdown or explanations.`;
235792
+ const text4 = await generateTextWithPlaceholders(
235793
+ model,
235794
+ externalAgentData,
235795
+ promptTemplate,
235796
+ {
235797
+ temperature: 0.1,
235798
+ maxOutputTokens: 4e3,
235799
+ abortSignal: AbortSignal.timeout(9e4)
235800
+ // 90 second timeout (increased for reasoning)
235801
+ },
235802
+ false,
235803
+ // debug
235804
+ { fileType: "external_agent" },
235805
+ // context - for Langfuse metadata
235806
+ reasoningConfig
235807
+ // reasoning config
235808
+ );
235809
+ writeFileSync3(outputPath, cleanGeneratedCode(text4));
235810
+ }
235324
235811
  function generateEnvironmentFileTemplate(environmentsDir, environment, credentials) {
235325
235812
  const { writeFileSync: writeFileSync7 } = require3("node:fs");
235326
235813
  const { join: join14 } = require3("node:path");
@@ -235341,9 +235828,11 @@ function generateEnvironmentFileTemplate(environmentsDir, environment, credentia
235341
235828
  `retrievalParams: ${JSON.stringify(cred.retrievalParams, null, 6).replace(/\n/g, "\n ")}`
235342
235829
  );
235343
235830
  }
235344
- credentialEntries.push(` ${varName}: credential({
235831
+ credentialEntries.push(
235832
+ ` ${varName}: credential({
235345
235833
  ${params.join(",\n ")}
235346
- })`);
235834
+ })`
235835
+ );
235347
235836
  }
235348
235837
  credentialsCode = `
235349
235838
  ${credentialEntries.join(",\n")}
@@ -235504,7 +235993,7 @@ export const myProject = project({
235504
235993
  });
235505
235994
  `;
235506
235995
  break;
235507
- case "agent":
235996
+ case "agent": {
235508
235997
  const importMappings = spec.toolFilenames || spec.componentFilenames ? `IMPORT PATH MAPPINGS (CRITICAL - USE EXACT PATHS):
235509
235998
  ${generateImportMappings(spec.toolFilenames, spec.componentFilenames)}
235510
235999
 
@@ -235546,6 +236035,7 @@ ${importMappings}REQUIREMENTS FOR AGENT FILE:
235546
236035
  6. If you are writing zod schemas make them clean. For example if you see z.union([z.string(), z.null()]) write it as z.string().nullable()
235547
236036
  `;
235548
236037
  break;
236038
+ }
235549
236039
  case "tool":
235550
236040
  fileSpecificInstructions = `
235551
236041
  REQUIREMENTS FOR TOOL FILE:
@@ -235557,6 +236047,16 @@ REQUIREMENTS FOR TOOL FILE:
235557
236047
  6. Convert credentialReferenceId to credential key format by replacing hyphens with underscores for the getEnvironmentSetting() call (e.g., 'inkeep-api-credential' becomes 'inkeep_api_credential')
235558
236048
  7. TRANSPORT CONFIG: If config.mcp.transport exists, extract it as a transport property (not nested in config)
235559
236049
  8. NO CONFIG OBJECT: mcpTool does not accept a 'config' property - use individual properties only
236050
+ `;
236051
+ break;
236052
+ case "external_agent":
236053
+ fileSpecificInstructions = `
236054
+ REQUIREMENTS FOR EXTERNAL AGENT FILE:
236055
+ 1. Import externalAgent from '@inkeep/agents-sdk'
236056
+ 2. Create the external agent using externalAgent()
236057
+ 3. Export following naming convention rules (camelCase version of ID)
236058
+ 5. CRITICAL: If credentialReferenceId exists in external agent data, add it as a credential property using envSettings.getEnvironmentSetting()
236059
+ 6. Convert credentialReferenceId to credential key format by replacing hyphens with underscores for the getEnvironmentSetting() call (e.g., 'inkeep-api-credential' becomes 'inkeep_api_credential')
235560
236060
  `;
235561
236061
  break;
235562
236062
  case "data_component":
@@ -236067,325 +236567,6 @@ import { weatherAgent } from './agent/weather-agent';
236067
236567
  }
236068
236568
  });
236069
236569
 
236070
- // src/codegen/variable-name-registry.ts
236071
- var variable_name_registry_exports = {};
236072
- __export(variable_name_registry_exports, {
236073
- DEFAULT_NAMING_CONVENTIONS: () => DEFAULT_NAMING_CONVENTIONS,
236074
- VariableNameGenerator: () => VariableNameGenerator,
236075
- collectAllEntities: () => collectAllEntities
236076
- });
236077
- function collectAllEntities(projectData) {
236078
- const entities = [];
236079
- entities.push({ id: projectData.id, type: "project", data: projectData });
236080
- if (projectData.agents) {
236081
- for (const [agentId, agentData] of Object.entries(projectData.agents)) {
236082
- entities.push({ id: agentId, type: "agent", data: agentData });
236083
- const agentObj = agentData;
236084
- if (agentObj.subAgents) {
236085
- for (const [subAgentId, subAgentData] of Object.entries(agentObj.subAgents)) {
236086
- entities.push({ id: subAgentId, type: "subAgent", data: subAgentData });
236087
- }
236088
- }
236089
- }
236090
- }
236091
- if (projectData.tools) {
236092
- for (const [toolId, toolData] of Object.entries(projectData.tools)) {
236093
- entities.push({ id: toolId, type: "tool", data: toolData });
236094
- }
236095
- }
236096
- if (projectData.dataComponents) {
236097
- for (const [compId, compData] of Object.entries(projectData.dataComponents)) {
236098
- entities.push({ id: compId, type: "dataComponent", data: compData });
236099
- }
236100
- }
236101
- if (projectData.artifactComponents) {
236102
- for (const [compId, compData] of Object.entries(projectData.artifactComponents)) {
236103
- entities.push({ id: compId, type: "artifactComponent", data: compData });
236104
- }
236105
- }
236106
- if (projectData.agents) {
236107
- for (const [_agentId, agentData] of Object.entries(projectData.agents)) {
236108
- const agentObj = agentData;
236109
- if (agentObj.statusUpdates?.statusComponents) {
236110
- for (const statusComp of agentObj.statusUpdates.statusComponents) {
236111
- if (statusComp.type) {
236112
- entities.push({ id: statusComp.type, type: "statusComponent" });
236113
- }
236114
- }
236115
- }
236116
- }
236117
- }
236118
- const credentialReferences2 = /* @__PURE__ */ new Set();
236119
- if (projectData.credentialReferences) {
236120
- for (const credId of Object.keys(projectData.credentialReferences)) {
236121
- credentialReferences2.add(credId);
236122
- }
236123
- }
236124
- if (projectData.tools) {
236125
- for (const [_toolId, toolData] of Object.entries(projectData.tools)) {
236126
- const tool2 = toolData;
236127
- if (tool2.credentialReferenceId) {
236128
- credentialReferences2.add(tool2.credentialReferenceId);
236129
- }
236130
- }
236131
- }
236132
- if (projectData.externalAgents) {
236133
- for (const [_agentId, agentData] of Object.entries(projectData.externalAgents)) {
236134
- const agent = agentData;
236135
- if (agent.credentialReferenceId) {
236136
- credentialReferences2.add(agent.credentialReferenceId);
236137
- }
236138
- }
236139
- }
236140
- if (projectData.agents) {
236141
- for (const [_agentId, agentData] of Object.entries(projectData.agents)) {
236142
- const agent = agentData;
236143
- if (agent.contextConfig?.headers?.credentialReferenceId) {
236144
- credentialReferences2.add(agent.contextConfig.headers.credentialReferenceId);
236145
- }
236146
- if (agent.contextConfig?.contextVariables) {
236147
- for (const [_varId, varData] of Object.entries(agent.contextConfig.contextVariables)) {
236148
- const contextVar = varData;
236149
- if (contextVar.credentialReferenceId) {
236150
- credentialReferences2.add(contextVar.credentialReferenceId);
236151
- }
236152
- }
236153
- }
236154
- if (agent.subAgents) {
236155
- for (const [_subAgentId, subAgentData] of Object.entries(agent.subAgents)) {
236156
- const subAgent = subAgentData;
236157
- if (subAgent.contextConfig?.headers?.credentialReferenceId) {
236158
- credentialReferences2.add(subAgent.contextConfig.headers.credentialReferenceId);
236159
- }
236160
- if (subAgent.contextConfig?.contextVariables) {
236161
- for (const [_varId, varData] of Object.entries(subAgent.contextConfig.contextVariables)) {
236162
- const contextVar = varData;
236163
- if (contextVar.credentialReferenceId) {
236164
- credentialReferences2.add(contextVar.credentialReferenceId);
236165
- }
236166
- }
236167
- }
236168
- }
236169
- }
236170
- }
236171
- }
236172
- return entities;
236173
- }
236174
- var DEFAULT_NAMING_CONVENTIONS, VariableNameGenerator;
236175
- var init_variable_name_registry = __esm({
236176
- "src/codegen/variable-name-registry.ts"() {
236177
- "use strict";
236178
- init_esm_shims();
236179
- DEFAULT_NAMING_CONVENTIONS = {
236180
- projectSuffix: "Project",
236181
- agentSuffix: "Agent",
236182
- subAgentSuffix: "SubAgent",
236183
- toolSuffix: null,
236184
- // Usually no suffix needed
236185
- dataComponentSuffix: null,
236186
- artifactComponentSuffix: null,
236187
- statusComponentSuffix: null,
236188
- credentialSuffix: null,
236189
- environmentSuffix: null
236190
- // No suffix needed for environments
236191
- };
236192
- VariableNameGenerator = class {
236193
- registry;
236194
- conventions;
236195
- conflicts;
236196
- constructor(conventions = DEFAULT_NAMING_CONVENTIONS) {
236197
- this.registry = {
236198
- projects: /* @__PURE__ */ new Map(),
236199
- agents: /* @__PURE__ */ new Map(),
236200
- subAgents: /* @__PURE__ */ new Map(),
236201
- tools: /* @__PURE__ */ new Map(),
236202
- dataComponents: /* @__PURE__ */ new Map(),
236203
- artifactComponents: /* @__PURE__ */ new Map(),
236204
- statusComponents: /* @__PURE__ */ new Map(),
236205
- credentials: /* @__PURE__ */ new Map(),
236206
- environments: /* @__PURE__ */ new Map(),
236207
- usedNames: /* @__PURE__ */ new Map()
236208
- };
236209
- this.conventions = conventions;
236210
- this.conflicts = [];
236211
- }
236212
- /**
236213
- * Generate unique variable name for an entity
236214
- * Ensures no conflicts across all entity types
236215
- */
236216
- generateVariableName(id, entityType, entityData) {
236217
- const registryMap = this.getRegistryMap(entityType);
236218
- const existing = registryMap.get(id);
236219
- if (existing) {
236220
- return existing;
236221
- }
236222
- let baseName;
236223
- if (entityType === "tool" && entityData?.name && this.isRandomId(id)) {
236224
- baseName = this.idToVariableName(entityData.name);
236225
- } else {
236226
- baseName = this.idToVariableName(id);
236227
- }
236228
- if (!this.registry.usedNames.has(baseName)) {
236229
- this.register(id, baseName, entityType);
236230
- return baseName;
236231
- }
236232
- const existingEntity = this.registry.usedNames.get(baseName);
236233
- if (existingEntity) {
236234
- const existingConflict = this.conflicts.find((c2) => c2.id === id);
236235
- if (existingConflict) {
236236
- existingConflict.types.push(entityType);
236237
- } else {
236238
- this.conflicts.push({
236239
- id,
236240
- types: [existingEntity.type, entityType],
236241
- resolvedNames: {
236242
- [existingEntity.type]: baseName
236243
- }
236244
- });
236245
- }
236246
- }
236247
- const suffix = this.getSuffixForType(entityType);
236248
- const uniqueName = baseName + suffix;
236249
- let finalName = uniqueName;
236250
- let counter = 2;
236251
- while (this.registry.usedNames.has(finalName)) {
236252
- finalName = `${uniqueName}${counter}`;
236253
- counter++;
236254
- }
236255
- this.register(id, finalName, entityType);
236256
- const conflict = this.conflicts.find((c2) => c2.id === id);
236257
- if (conflict) {
236258
- conflict.resolvedNames[entityType] = finalName;
236259
- }
236260
- return finalName;
236261
- }
236262
- /**
236263
- * Register an existing variable name (from detected patterns)
236264
- */
236265
- register(id, variableName, entityType) {
236266
- const registryMap = this.getRegistryMap(entityType);
236267
- registryMap.set(id, variableName);
236268
- this.registry.usedNames.set(variableName, { id, type: entityType });
236269
- }
236270
- /**
236271
- * Get the registry for lookup
236272
- */
236273
- getRegistry() {
236274
- return this.registry;
236275
- }
236276
- /**
236277
- * Get all conflicts that were resolved
236278
- */
236279
- getConflicts() {
236280
- return this.conflicts;
236281
- }
236282
- /**
236283
- * Convert ID to camelCase variable name
236284
- */
236285
- idToVariableName(id) {
236286
- if (this.isRandomId(id)) {
236287
- return id;
236288
- }
236289
- const parts = id.split(/[-_]/);
236290
- const camelCase = parts.map((part, index2) => {
236291
- if (index2 === 0) {
236292
- return part.toLowerCase();
236293
- }
236294
- return part.charAt(0).toUpperCase() + part.slice(1).toLowerCase();
236295
- }).join("");
236296
- return camelCase;
236297
- }
236298
- /**
236299
- * Check if an ID looks random/UUID-like
236300
- */
236301
- isRandomId(id) {
236302
- if (!id.includes("-") && !id.includes("_")) {
236303
- return /[0-9]/.test(id) || /[A-Z]/.test(id);
236304
- }
236305
- return false;
236306
- }
236307
- /**
236308
- * Generate filename from entity data (for file naming)
236309
- */
236310
- generateFileName(id, entityType, entityData) {
236311
- let baseName;
236312
- if (entityType === "tool" && entityData?.name && this.isRandomId(id)) {
236313
- baseName = this.nameToFileName(entityData.name);
236314
- } else {
236315
- baseName = this.idToFileName(id);
236316
- }
236317
- return baseName;
236318
- }
236319
- /**
236320
- * Convert name to kebab-case filename
236321
- */
236322
- nameToFileName(name) {
236323
- return name.replace(/[^\w\s-]/g, "").trim().replace(/\s+/g, "-").replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
236324
- }
236325
- /**
236326
- * Convert ID to kebab-case filename
236327
- */
236328
- idToFileName(id) {
236329
- return id.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
236330
- }
236331
- /**
236332
- * Get appropriate suffix for entity type
236333
- */
236334
- getSuffixForType(entityType) {
236335
- switch (entityType) {
236336
- case "project":
236337
- return this.conventions.projectSuffix;
236338
- case "agent":
236339
- return this.conventions.agentSuffix;
236340
- case "subAgent":
236341
- return this.conventions.subAgentSuffix;
236342
- case "tool":
236343
- return this.conventions.toolSuffix || "";
236344
- case "dataComponent":
236345
- return this.conventions.dataComponentSuffix || "";
236346
- case "artifactComponent":
236347
- return this.conventions.artifactComponentSuffix || "";
236348
- case "statusComponent":
236349
- return this.conventions.statusComponentSuffix || "";
236350
- case "credential":
236351
- return this.conventions.credentialSuffix || "";
236352
- case "environment":
236353
- return this.conventions.environmentSuffix || "";
236354
- default:
236355
- return "";
236356
- }
236357
- }
236358
- /**
236359
- * Get the appropriate registry map for an entity type
236360
- */
236361
- getRegistryMap(entityType) {
236362
- switch (entityType) {
236363
- case "project":
236364
- return this.registry.projects;
236365
- case "agent":
236366
- return this.registry.agents;
236367
- case "subAgent":
236368
- return this.registry.subAgents;
236369
- case "tool":
236370
- return this.registry.tools;
236371
- case "dataComponent":
236372
- return this.registry.dataComponents;
236373
- case "artifactComponent":
236374
- return this.registry.artifactComponents;
236375
- case "statusComponent":
236376
- return this.registry.statusComponents;
236377
- case "credential":
236378
- return this.registry.credentials;
236379
- case "environment":
236380
- return this.registry.environments;
236381
- default:
236382
- throw new Error(`Unknown entity type: ${entityType}`);
236383
- }
236384
- }
236385
- };
236386
- }
236387
- });
236388
-
236389
236570
  // src/codegen/pattern-analyzer.ts
236390
236571
  var pattern_analyzer_exports = {};
236391
236572
  __export(pattern_analyzer_exports, {
@@ -236422,6 +236603,7 @@ function analyzeFileStructure(projectDir) {
236422
236603
  const hasDataComponentsDirectory = existsSync7(join8(projectDir, "data-components"));
236423
236604
  const hasArtifactComponentsDirectory = existsSync7(join8(projectDir, "artifact-components"));
236424
236605
  const hasEnvironmentsDirectory = existsSync7(join8(projectDir, "environments"));
236606
+ const hasExternalAgentsDirectory = existsSync7(join8(projectDir, "external-agents"));
236425
236607
  let toolsLocation = "unknown";
236426
236608
  if (hasToolsDirectory) {
236427
236609
  toolsLocation = "separate";
@@ -236448,7 +236630,8 @@ function analyzeFileStructure(projectDir) {
236448
236630
  hasAgentsDirectory,
236449
236631
  hasDataComponentsDirectory,
236450
236632
  hasArtifactComponentsDirectory,
236451
- hasEnvironmentsDirectory
236633
+ hasEnvironmentsDirectory,
236634
+ hasExternalAgentsDirectory
236452
236635
  };
236453
236636
  }
236454
236637
  function detectFileNamingConvention(files) {
@@ -236531,7 +236714,8 @@ function extractVariableMappings(code, filePath) {
236531
236714
  "tool",
236532
236715
  "tool",
236533
236716
  "dataComponent",
236534
- "artifactComponent"
236717
+ "artifactComponent",
236718
+ "externalAgent"
236535
236719
  ];
236536
236720
  patterns.forEach((pattern, index2) => {
236537
236721
  const matches = code.matchAll(pattern);
@@ -236625,9 +236809,9 @@ function mostCommon(arr) {
236625
236809
  }
236626
236810
  let maxCount = 0;
236627
236811
  let mostCommonItem = null;
236628
- for (const [item, count16] of counts.entries()) {
236629
- if (count16 > maxCount) {
236630
- maxCount = count16;
236812
+ for (const [item, count17] of counts.entries()) {
236813
+ if (count17 > maxCount) {
236814
+ maxCount = count17;
236631
236815
  mostCommonItem = item;
236632
236816
  }
236633
236817
  }
@@ -236693,6 +236877,7 @@ function displayPlanSummary(plan) {
236693
236877
  dataComponent: [],
236694
236878
  artifactComponent: [],
236695
236879
  statusComponent: [],
236880
+ externalAgent: [],
236696
236881
  environment: []
236697
236882
  };
236698
236883
  for (const file of plan.files) {
@@ -236727,6 +236912,12 @@ function displayPlanSummary(plan) {
236727
236912
  }
236728
236913
  }
236729
236914
  }
236915
+ if (filesByType.externalAgent.length > 0) {
236916
+ console.log(chalk8.gray("\n External Agents:"));
236917
+ for (const file of filesByType.externalAgent) {
236918
+ console.log(chalk8.gray(` \u2022 ${file.path}`));
236919
+ }
236920
+ }
236730
236921
  if (filesByType.dataComponent.length > 0) {
236731
236922
  console.log(chalk8.gray("\n Data Components:"));
236732
236923
  for (const file of filesByType.dataComponent) {
@@ -236889,7 +237080,12 @@ async function generatePlan(projectData, patterns, modelSettings, createModel2,
236889
237080
  fileNameMappings.set(entity.id, fileName);
236890
237081
  }
236891
237082
  const model = createModel2(modelSettings);
236892
- const promptTemplate = createPlanningPromptTemplate(nameGenerator.getRegistry(), allEntities, fileNameMappings, targetEnvironment);
237083
+ const promptTemplate = createPlanningPromptTemplate(
237084
+ nameGenerator.getRegistry(),
237085
+ allEntities,
237086
+ fileNameMappings,
237087
+ targetEnvironment
237088
+ );
236893
237089
  const promptData = {
236894
237090
  projectData,
236895
237091
  patterns
@@ -236943,7 +237139,7 @@ CRITICAL RULES:
236943
237139
  1. TOOL TYPES - VERY IMPORTANT:
236944
237140
  - **Function Tools** (type: "function"): ALWAYS define INLINE within agent files using "inlineContent" array
236945
237141
  - **MCP Tools** (type: "mcp"): Create separate files in tools/ directory
236946
- - VALID FILE TYPES: Only use these exact types: "agent", "tool", "dataComponent", "artifactComponent", "statusComponent", "environment", "index"
237142
+ - VALID FILE TYPES: Only use these exact types: "agent", "tool", "dataComponent", "artifactComponent", "externalAgent", "statusComponent", "environment", "index"
236947
237143
  - NEVER create file type "functionTool" - function tools go in "inlineContent" of agent files
236948
237144
 
236949
237145
  2. STATUS COMPONENTS - VERY IMPORTANT:
@@ -236976,6 +237172,7 @@ CRITICAL RULES:
236976
237172
  - data-components/ directory: Data component files
236977
237173
  - artifact-components/ directory: Artifact component files
236978
237174
  - status-components/ directory: Status component files
237175
+ - external-agents/ directory: External agent files
236979
237176
  - environments/ directory: Environment/credential files
236980
237177
  - index.ts: Main project file
236981
237178
 
@@ -237016,6 +237213,11 @@ OUTPUT FORMAT (JSON):
237016
237213
  "fromPath": "../tools/weather-api",
237017
237214
  "entityType": "tool"
237018
237215
  }
237216
+ {
237217
+ "variableName": "externalHelper",
237218
+ "fromPath": "../external-agents/external-helper",
237219
+ "entityType": "externalAgent"
237220
+ }
237019
237221
  ],
237020
237222
  "inlineContent": [
237021
237223
  {
@@ -237040,6 +237242,20 @@ OUTPUT FORMAT (JSON):
237040
237242
  "dependencies": [],
237041
237243
  "inlineContent": null
237042
237244
  },
237245
+ {
237246
+ "path": "external-agents/external-helper.ts",
237247
+ "type": "externalAgent",
237248
+ "entities": [
237249
+ {
237250
+ "id": "external-helper",
237251
+ "variableName": "externalHelper",
237252
+ "entityType": "externalAgent",
237253
+ "exportName": "externalHelper"
237254
+ }
237255
+ ],
237256
+ "dependencies": [],
237257
+ "inlineContent": null
237258
+ },
237043
237259
  {
237044
237260
  "path": "status-components/tool-summary.ts",
237045
237261
  "type": "statusComponent",
@@ -237127,6 +237343,7 @@ function formatVariableMappings(registry2, allEntities) {
237127
237343
  dataComponent: [],
237128
237344
  artifactComponent: [],
237129
237345
  statusComponent: [],
237346
+ externalAgent: [],
237130
237347
  credential: [],
237131
237348
  environment: []
237132
237349
  };
@@ -237161,6 +237378,7 @@ function formatFileNameMappings(fileNameMappings, allEntities) {
237161
237378
  artifactComponent: [],
237162
237379
  statusComponent: [],
237163
237380
  credential: [],
237381
+ externalAgent: [],
237164
237382
  environment: []
237165
237383
  };
237166
237384
  for (const entity of allEntities) {
@@ -237208,6 +237426,8 @@ function getRegistryMap(registry2, entityType) {
237208
237426
  return registry2.artifactComponents;
237209
237427
  case "statusComponent":
237210
237428
  return registry2.statusComponents;
237429
+ case "externalAgent":
237430
+ return registry2.externalAgents;
237211
237431
  case "credential":
237212
237432
  return registry2.credentials;
237213
237433
  case "environment":
@@ -237366,6 +237586,9 @@ async function generateFilesFromPlan(plan, projectData, dirs, modelSettings, deb
237366
237586
  case "statusComponent":
237367
237587
  batchType = "status_component";
237368
237588
  break;
237589
+ case "externalAgent":
237590
+ batchType = "external_agent";
237591
+ break;
237369
237592
  default:
237370
237593
  throw new Error(`Unknown file type for batch generation: ${fileInfo.type}`);
237371
237594
  }
@@ -237385,7 +237608,9 @@ async function generateFilesFromPlan(plan, projectData, dirs, modelSettings, deb
237385
237608
  await generateAllFilesInBatch(fileSpecs, modelSettings, debug, reasoningConfig);
237386
237609
  }
237387
237610
  if (debug && environmentFiles.length > 0) {
237388
- console.log(`[DEBUG] Generating ${environmentFiles.length} environment files using templates (no LLM)...`);
237611
+ console.log(
237612
+ `[DEBUG] Generating ${environmentFiles.length} environment files using templates (no LLM)...`
237613
+ );
237389
237614
  }
237390
237615
  for (const envFile of environmentFiles) {
237391
237616
  const envStartTime = Date.now();
@@ -237431,6 +237656,13 @@ function extractDataForFile(fileInfo, projectData) {
237431
237656
  }
237432
237657
  return {};
237433
237658
  }
237659
+ case "externalAgent": {
237660
+ const agentId = fileInfo.entities[0]?.id;
237661
+ if (agentId && projectData.externalAgents) {
237662
+ return projectData.externalAgents[agentId];
237663
+ }
237664
+ return {};
237665
+ }
237434
237666
  case "dataComponent": {
237435
237667
  const compId = fileInfo.entities[0]?.id;
237436
237668
  if (compId && projectData.dataComponents) {
@@ -237567,7 +237799,9 @@ function extractDataForFile(fileInfo, projectData) {
237567
237799
  }
237568
237800
  }
237569
237801
  if (subAgent.contextConfig?.contextVariables) {
237570
- for (const [varId, varData] of Object.entries(subAgent.contextConfig.contextVariables)) {
237802
+ for (const [varId, varData] of Object.entries(
237803
+ subAgent.contextConfig.contextVariables
237804
+ )) {
237571
237805
  const contextVar = varData;
237572
237806
  if (contextVar.credentialReferenceId) {
237573
237807
  const credId = contextVar.credentialReferenceId;
@@ -238946,45 +239180,9 @@ ${table.toString()}`);
238946
239180
  init_esm_shims();
238947
239181
  import { existsSync as existsSync9, mkdirSync as mkdirSync2, readFileSync as readFileSync6, writeFileSync as writeFileSync6 } from "fs";
238948
239182
  import { dirname as dirname5, join as join10, resolve as resolve4 } from "path";
238949
- import chalk9 from "chalk";
238950
239183
  import * as p7 from "@clack/prompts";
238951
- init_config();
238952
-
238953
- // src/utils/project-directory.ts
238954
- init_esm_shims();
238955
- import { existsSync as existsSync5 } from "fs";
238956
- import { join as join5, resolve as resolve3 } from "path";
238957
- import { findUp as findUp2 } from "find-up";
238958
- async function findProjectDirectory(projectId, configPath) {
238959
- if (configPath) {
238960
- const absoluteConfigPath = resolve3(process.cwd(), configPath);
238961
- if (existsSync5(absoluteConfigPath)) {
238962
- return resolve3(absoluteConfigPath, "..");
238963
- }
238964
- }
238965
- if (projectId) {
238966
- if (projectId.includes("/") || projectId.includes("\\")) {
238967
- const projectPath = resolve3(process.cwd(), projectId);
238968
- if (existsSync5(join5(projectPath, "inkeep.config.ts"))) {
238969
- return projectPath;
238970
- }
238971
- } else {
238972
- const projectPath = join5(process.cwd(), projectId);
238973
- if (existsSync5(join5(projectPath, "inkeep.config.ts"))) {
238974
- return projectPath;
238975
- }
238976
- }
238977
- return null;
238978
- }
238979
- const foundConfigPath = await findUp2("inkeep.config.ts");
238980
- if (foundConfigPath) {
238981
- return resolve3(foundConfigPath, "..");
238982
- }
238983
- return null;
238984
- }
238985
-
238986
- // src/commands/pull.ts
238987
- init_tsx_loader();
239184
+ import chalk9 from "chalk";
239185
+ init_variable_name_registry();
238988
239186
 
238989
239187
  // src/utils/background-version-check.ts
238990
239188
  init_esm_shims();
@@ -238992,16 +239190,16 @@ import chalk7 from "chalk";
238992
239190
 
238993
239191
  // src/utils/version-check.ts
238994
239192
  init_esm_shims();
238995
- import { existsSync as existsSync6, readFileSync as readFileSync2 } from "fs";
238996
- import { dirname as dirname4, join as join6 } from "path";
239193
+ import { existsSync as existsSync5, readFileSync as readFileSync2 } from "fs";
239194
+ import { dirname as dirname4, join as join5 } from "path";
238997
239195
  import { fileURLToPath as fileURLToPath2 } from "url";
238998
239196
  var __filename2 = fileURLToPath2(import.meta.url);
238999
239197
  var __dirname2 = dirname4(__filename2);
239000
239198
  var DEFAULT_PACKAGE_NAME = "@inkeep/agents-cli";
239001
239199
  function getCurrentVersion() {
239002
- let packageJsonPath2 = join6(__dirname2, "..", "package.json");
239003
- if (!existsSync6(packageJsonPath2)) {
239004
- packageJsonPath2 = join6(__dirname2, "..", "..", "package.json");
239200
+ let packageJsonPath2 = join5(__dirname2, "..", "package.json");
239201
+ if (!existsSync5(packageJsonPath2)) {
239202
+ packageJsonPath2 = join5(__dirname2, "..", "..", "package.json");
239005
239203
  }
239006
239204
  const packageJson2 = JSON.parse(readFileSync2(packageJsonPath2, "utf-8"));
239007
239205
  return packageJson2.version;
@@ -239073,8 +239271,43 @@ function performBackgroundVersionCheck() {
239073
239271
  }
239074
239272
 
239075
239273
  // src/commands/pull.ts
239076
- init_pull_llm_generate();
239077
- init_variable_name_registry();
239274
+ init_config();
239275
+
239276
+ // src/utils/project-directory.ts
239277
+ init_esm_shims();
239278
+ import { existsSync as existsSync6 } from "fs";
239279
+ import { join as join6, resolve as resolve3 } from "path";
239280
+ import { findUp as findUp2 } from "find-up";
239281
+ async function findProjectDirectory(projectId, configPath) {
239282
+ if (configPath) {
239283
+ const absoluteConfigPath = resolve3(process.cwd(), configPath);
239284
+ if (existsSync6(absoluteConfigPath)) {
239285
+ return resolve3(absoluteConfigPath, "..");
239286
+ }
239287
+ }
239288
+ if (projectId) {
239289
+ if (projectId.includes("/") || projectId.includes("\\")) {
239290
+ const projectPath = resolve3(process.cwd(), projectId);
239291
+ if (existsSync6(join6(projectPath, "inkeep.config.ts"))) {
239292
+ return projectPath;
239293
+ }
239294
+ } else {
239295
+ const projectPath = join6(process.cwd(), projectId);
239296
+ if (existsSync6(join6(projectPath, "inkeep.config.ts"))) {
239297
+ return projectPath;
239298
+ }
239299
+ }
239300
+ return null;
239301
+ }
239302
+ const foundConfigPath = await findUp2("inkeep.config.ts");
239303
+ if (foundConfigPath) {
239304
+ return resolve3(foundConfigPath, "..");
239305
+ }
239306
+ return null;
239307
+ }
239308
+
239309
+ // src/commands/pull.ts
239310
+ init_tsx_loader();
239078
239311
  async function detectCurrentProject(debug = false) {
239079
239312
  const indexPath = join10(process.cwd(), "index.ts");
239080
239313
  if (debug) {
@@ -239294,6 +239527,7 @@ function createProjectStructure(projectDir, projectId, useCurrentDirectory = fal
239294
239527
  const artifactComponentsDir = join10(projectRoot, "artifact-components");
239295
239528
  const statusComponentsDir = join10(projectRoot, "status-components");
239296
239529
  const environmentsDir = join10(projectRoot, "environments");
239530
+ const externalAgentsDir = join10(projectRoot, "external-agents");
239297
239531
  ensureDirectoryExists(projectRoot);
239298
239532
  ensureDirectoryExists(agentsDir);
239299
239533
  ensureDirectoryExists(toolsDir);
@@ -239301,6 +239535,7 @@ function createProjectStructure(projectDir, projectId, useCurrentDirectory = fal
239301
239535
  ensureDirectoryExists(artifactComponentsDir);
239302
239536
  ensureDirectoryExists(statusComponentsDir);
239303
239537
  ensureDirectoryExists(environmentsDir);
239538
+ ensureDirectoryExists(externalAgentsDir);
239304
239539
  return {
239305
239540
  projectRoot,
239306
239541
  agentsDir,
@@ -239308,7 +239543,8 @@ function createProjectStructure(projectDir, projectId, useCurrentDirectory = fal
239308
239543
  dataComponentsDir,
239309
239544
  artifactComponentsDir,
239310
239545
  statusComponentsDir,
239311
- environmentsDir
239546
+ environmentsDir,
239547
+ externalAgentsDir
239312
239548
  };
239313
239549
  }
239314
239550
  async function pullProjectCommand(options) {
@@ -239317,12 +239553,14 @@ async function pullProjectCommand(options) {
239317
239553
  try {
239318
239554
  const { detectAvailableProvider: detectAvailableProvider2 } = await Promise.resolve().then(() => (init_pull_llm_generate(), pull_llm_generate_exports));
239319
239555
  provider = detectAvailableProvider2();
239320
- console.log(chalk9.gray(`
239321
- \u{1F916} Using ${provider.charAt(0).toUpperCase() + provider.slice(1)} for code generation`));
239322
- } catch (error) {
239323
- console.error(
239324
- chalk9.red("\n\u274C Error: No LLM provider API key found")
239556
+ console.log(
239557
+ chalk9.gray(
239558
+ `
239559
+ \u{1F916} Using ${provider.charAt(0).toUpperCase() + provider.slice(1)} for code generation`
239560
+ )
239325
239561
  );
239562
+ } catch (error) {
239563
+ console.error(chalk9.red("\n\u274C Error: No LLM provider API key found"));
239326
239564
  console.error(
239327
239565
  chalk9.yellow(
239328
239566
  "\nThe pull command requires AI to generate TypeScript files from your project configuration."
@@ -239506,6 +239744,13 @@ async function pullProjectCommand(options) {
239506
239744
  const statusComponents = agentObj.statusUpdates?.statusComponents || [];
239507
239745
  return total + statusComponents.length;
239508
239746
  }, 0);
239747
+ const externalAgentCount = Object.keys(projectData.externalAgents || {}).reduce(
239748
+ (total, agent) => {
239749
+ const agentObj = agent;
239750
+ return total + Object.keys(agentObj.subAgents || {}).length;
239751
+ },
239752
+ 0
239753
+ );
239509
239754
  console.log(chalk9.cyan("\n\u{1F4CA} Project Summary:"));
239510
239755
  console.log(chalk9.gray(` \u2022 Name: ${projectData.name}`));
239511
239756
  console.log(chalk9.gray(` \u2022 Description: ${projectData.description || "No description"}`));
@@ -239521,6 +239766,9 @@ async function pullProjectCommand(options) {
239521
239766
  if (statusComponentCount > 0) {
239522
239767
  console.log(chalk9.gray(` \u2022 Status Components: ${statusComponentCount}`));
239523
239768
  }
239769
+ if (externalAgentCount > 0) {
239770
+ console.log(chalk9.gray(` \u2022 External Agents: ${externalAgentCount}`));
239771
+ }
239524
239772
  const credentialReferences2 = projectData.credentialReferences || {};
239525
239773
  const credentialCount = Object.keys(credentialReferences2).length;
239526
239774
  if (credentialCount > 0) {
@@ -239536,7 +239784,7 @@ async function pullProjectCommand(options) {
239536
239784
  for (const usage of usageInfo) {
239537
239785
  usageByType[usage.type] = (usageByType[usage.type] || 0) + 1;
239538
239786
  }
239539
- const usageSummary = Object.entries(usageByType).map(([type, count16]) => `${count16} ${type}${count16 > 1 ? "s" : ""}`).join(", ");
239787
+ const usageSummary = Object.entries(usageByType).map(([type, count17]) => `${count17} ${type}${count17 > 1 ? "s" : ""}`).join(", ");
239540
239788
  console.log(chalk9.gray(` Used by: ${usageSummary}`));
239541
239789
  }
239542
239790
  }
@@ -239576,6 +239824,7 @@ async function pullProjectCommand(options) {
239576
239824
  hasAgentsDirectory: true,
239577
239825
  hasDataComponentsDirectory: true,
239578
239826
  hasArtifactComponentsDirectory: true,
239827
+ hasExternalAgentsDirectory: true,
239579
239828
  hasEnvironmentsDirectory: true
239580
239829
  },
239581
239830
  namingConventions: DEFAULT_NAMING_CONVENTIONS2,
@@ -239605,10 +239854,20 @@ async function pullProjectCommand(options) {
239605
239854
  if (options.debug) {
239606
239855
  console.log(chalk9.gray(`
239607
239856
  \u{1F4CD} Debug: Model selected: ${selectedModel}`));
239608
- console.log(chalk9.gray(`\u{1F4CD} Debug: Reasoning enabled: ${Object.keys(reasoningConfig).length > 0 ? "Yes" : "No"}`));
239857
+ console.log(
239858
+ chalk9.gray(
239859
+ `\u{1F4CD} Debug: Reasoning enabled: ${Object.keys(reasoningConfig).length > 0 ? "Yes" : "No"}`
239860
+ )
239861
+ );
239609
239862
  }
239610
239863
  const targetEnvironment = options.env || "development";
239611
- const plan = await generatePlan2(projectData, patterns, modelSettings, createModel2, targetEnvironment);
239864
+ const plan = await generatePlan2(
239865
+ projectData,
239866
+ patterns,
239867
+ modelSettings,
239868
+ createModel2,
239869
+ targetEnvironment
239870
+ );
239612
239871
  s2.stop("Generation plan created");
239613
239872
  const { displayPlanSummary: displayPlanSummary2, displayConflictWarning: displayConflictWarning2 } = await Promise.resolve().then(() => (init_display_utils(), display_utils_exports));
239614
239873
  displayPlanSummary2(plan);
@@ -239645,9 +239904,10 @@ async function pullProjectCommand(options) {
239645
239904
  tools: Object.keys(projectData.tools || {}).length,
239646
239905
  dataComponents: Object.keys(projectData.dataComponents || {}).length,
239647
239906
  artifactComponents: Object.keys(projectData.artifactComponents || {}).length,
239907
+ externalAgents: Object.keys(projectData.externalAgents || {}).length,
239648
239908
  statusComponents: statusComponentsCount
239649
239909
  };
239650
- const totalFiles = fileCount.agents + fileCount.tools + fileCount.dataComponents + fileCount.artifactComponents + fileCount.statusComponents + 5;
239910
+ const totalFiles = fileCount.agents + fileCount.tools + fileCount.dataComponents + fileCount.artifactComponents + fileCount.externalAgents + fileCount.statusComponents + 5;
239651
239911
  s2.stop(`Project files generated (${totalFiles} files created)`);
239652
239912
  s2.start("Verifying generated files...");
239653
239913
  try {
@@ -239698,6 +239958,9 @@ async function pullProjectCommand(options) {
239698
239958
  if (fileCount.tools > 0) {
239699
239959
  console.log(chalk9.gray(` \u251C\u2500\u2500 tools/ (${fileCount.tools} files)`));
239700
239960
  }
239961
+ if (fileCount.externalAgents > 0) {
239962
+ console.log(chalk9.gray(` \u251C\u2500\u2500 external-agents/ (${fileCount.externalAgents} files)`));
239963
+ }
239701
239964
  if (fileCount.dataComponents > 0) {
239702
239965
  console.log(chalk9.gray(` \u251C\u2500\u2500 data-components/ (${fileCount.dataComponents} files)`));
239703
239966
  }
@@ -239926,7 +240189,7 @@ async function pushCommand(options) {
239926
240189
  for (const usage of usageInfo) {
239927
240190
  usageByType[usage.type] = (usageByType[usage.type] || 0) + 1;
239928
240191
  }
239929
- const usageSummary = Object.entries(usageByType).map(([type, count16]) => `${count16} ${type}${count16 > 1 ? "s" : ""}`).join(", ");
240192
+ const usageSummary = Object.entries(usageByType).map(([type, count17]) => `${count17} ${type}${count17 > 1 ? "s" : ""}`).join(", ");
239930
240193
  console.log(chalk10.gray(` Used by: ${usageSummary}`));
239931
240194
  }
239932
240195
  }