@inkeep/agents-cli 0.26.1 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +985 -522
  2. package/package.json +3 -3
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, desc16) => {
24
+ var __copyProps = (to, from, except, desc17) => {
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: !(desc16 = __getOwnPropDesc(from, key)) || desc16.enumerable });
28
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc17 = __getOwnPropDesc(from, key)) || desc17.enumerable });
29
29
  }
30
30
  return to;
31
31
  };
@@ -375,22 +375,22 @@ var init_logger = __esm({
375
375
  */
376
376
  getLogger(name) {
377
377
  if (this.loggers.has(name)) {
378
- const logger16 = this.loggers.get(name);
379
- if (!logger16) {
378
+ const logger17 = this.loggers.get(name);
379
+ if (!logger17) {
380
380
  throw new Error(`Logger '${name}' not found in cache`);
381
381
  }
382
- return logger16;
382
+ return logger17;
383
383
  }
384
- let logger15;
384
+ let logger16;
385
385
  if (this.config.loggerFactory) {
386
- logger15 = this.config.loggerFactory(name);
386
+ logger16 = this.config.loggerFactory(name);
387
387
  } else if (this.config.defaultLogger) {
388
- logger15 = this.config.defaultLogger;
388
+ logger16 = this.config.defaultLogger;
389
389
  } else {
390
- logger15 = new PinoLogger(name, this.config.pinoConfig);
390
+ logger16 = new PinoLogger(name, this.config.pinoConfig);
391
391
  }
392
- this.loggers.set(name, logger15);
393
- return logger15;
392
+ this.loggers.set(name, logger16);
393
+ return logger16;
394
394
  }
395
395
  /**
396
396
  * Reset factory to default state
@@ -1607,7 +1607,7 @@ import {
1607
1607
  text,
1608
1608
  unique
1609
1609
  } from "drizzle-orm/sqlite-core";
1610
- 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;
1610
+ 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, subAgentTeamAgentRelations, 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, subAgentTeamAgentRelationsRelations;
1611
1611
  var init_schema = __esm({
1612
1612
  "../packages/agents-core/src/db/schema.ts"() {
1613
1613
  "use strict";
@@ -2010,6 +2010,28 @@ var init_schema = __esm({
2010
2010
  }).onDelete("cascade")
2011
2011
  ]
2012
2012
  );
2013
+ subAgentTeamAgentRelations = sqliteTable(
2014
+ "sub_agent_team_agent_relations",
2015
+ {
2016
+ ...subAgentScoped,
2017
+ targetAgentId: text("target_agent_id").notNull(),
2018
+ headers: blob("headers", { mode: "json" }).$type(),
2019
+ ...timestamps
2020
+ },
2021
+ (table) => [
2022
+ primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
2023
+ foreignKey({
2024
+ columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
2025
+ foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
2026
+ name: "sub_agent_team_agent_relations_sub_agent_fk"
2027
+ }).onDelete("cascade"),
2028
+ foreignKey({
2029
+ columns: [table.tenantId, table.projectId, table.targetAgentId],
2030
+ foreignColumns: [agents.tenantId, agents.projectId, agents.id],
2031
+ name: "sub_agent_team_agent_relations_target_agent_fk"
2032
+ }).onDelete("cascade")
2033
+ ]
2034
+ );
2013
2035
  subAgentFunctionToolRelations = sqliteTable(
2014
2036
  "sub_agent_function_tool_relations",
2015
2037
  {
@@ -2066,6 +2088,8 @@ var init_schema = __esm({
2066
2088
  toSubAgentId: text("to_sub_agent_id"),
2067
2089
  fromExternalAgentId: text("from_external_sub_agent_id"),
2068
2090
  toExternalAgentId: text("to_external_sub_agent_id"),
2091
+ fromTeamAgentId: text("from_team_agent_id"),
2092
+ toTeamAgentId: text("to_team_agent_id"),
2069
2093
  content: blob("content", { mode: "json" }).$type().notNull(),
2070
2094
  visibility: text("visibility").notNull().default("user-facing"),
2071
2095
  messageType: text("message_type").notNull().default("chat"),
@@ -2342,6 +2366,16 @@ var init_schema = __esm({
2342
2366
  references: [subAgents.id],
2343
2367
  relationName: "receivedMessages"
2344
2368
  }),
2369
+ fromTeamAgent: one(agents, {
2370
+ fields: [messages.fromTeamAgentId],
2371
+ references: [agents.id],
2372
+ relationName: "receivedTeamMessages"
2373
+ }),
2374
+ toTeamAgent: one(agents, {
2375
+ fields: [messages.toTeamAgentId],
2376
+ references: [agents.id],
2377
+ relationName: "sentTeamMessages"
2378
+ }),
2345
2379
  fromExternalAgent: one(externalAgents, {
2346
2380
  fields: [messages.tenantId, messages.projectId, messages.fromExternalAgentId],
2347
2381
  references: [externalAgents.tenantId, externalAgents.projectId, externalAgents.id],
@@ -2485,6 +2519,28 @@ var init_schema = __esm({
2485
2519
  })
2486
2520
  })
2487
2521
  );
2522
+ subAgentTeamAgentRelationsRelations = relations(
2523
+ subAgentTeamAgentRelations,
2524
+ ({ one }) => ({
2525
+ subAgent: one(subAgents, {
2526
+ fields: [
2527
+ subAgentTeamAgentRelations.tenantId,
2528
+ subAgentTeamAgentRelations.projectId,
2529
+ subAgentTeamAgentRelations.agentId,
2530
+ subAgentTeamAgentRelations.subAgentId
2531
+ ],
2532
+ references: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id]
2533
+ }),
2534
+ targetAgent: one(agents, {
2535
+ fields: [
2536
+ subAgentTeamAgentRelations.tenantId,
2537
+ subAgentTeamAgentRelations.projectId,
2538
+ subAgentTeamAgentRelations.targetAgentId
2539
+ ],
2540
+ references: [agents.tenantId, agents.projectId, agents.id]
2541
+ })
2542
+ })
2543
+ );
2488
2544
  }
2489
2545
  });
2490
2546
 
@@ -2513,7 +2569,7 @@ var init_utility = __esm({
2513
2569
  });
2514
2570
 
2515
2571
  // ../packages/agents-core/src/validation/schemas.ts
2516
- 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;
2572
+ 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, SubAgentTeamAgentRelationSelectSchema, SubAgentTeamAgentRelationInsertSchema, SubAgentTeamAgentRelationUpdateSchema, SubAgentTeamAgentRelationApiSelectSchema, SubAgentTeamAgentRelationApiInsertSchema, SubAgentTeamAgentRelationApiUpdateSchema, LedgerArtifactSelectSchema, LedgerArtifactInsertSchema, LedgerArtifactUpdateSchema, LedgerArtifactApiSelectSchema, LedgerArtifactApiInsertSchema, LedgerArtifactApiUpdateSchema, StatusComponentSchema, StatusUpdateSchema, CanUseItemSchema, canDelegateToExternalAgentSchema, canDelegateToTeamAgentSchema, TeamAgentSchema, 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;
2517
2573
  var init_schemas = __esm({
2518
2574
  "../packages/agents-core/src/validation/schemas.ts"() {
2519
2575
  "use strict";
@@ -2583,7 +2639,8 @@ var init_schemas = __esm({
2583
2639
  agentId: resourceIdSchema,
2584
2640
  sourceSubAgentId: resourceIdSchema,
2585
2641
  targetSubAgentId: resourceIdSchema.optional(),
2586
- externalSubAgentId: resourceIdSchema.optional()
2642
+ externalSubAgentId: resourceIdSchema.optional(),
2643
+ teamSubAgentId: resourceIdSchema.optional()
2587
2644
  });
2588
2645
  SubAgentRelationUpdateSchema = SubAgentRelationInsertSchema.partial();
2589
2646
  SubAgentRelationApiSelectSchema = createAgentScopedApiSchema(
@@ -2597,11 +2654,13 @@ var init_schemas = __esm({
2597
2654
  (data) => {
2598
2655
  const hasTarget = data.targetSubAgentId != null;
2599
2656
  const hasExternal = data.externalSubAgentId != null;
2600
- return hasTarget !== hasExternal;
2657
+ const hasTeam = data.teamSubAgentId != null;
2658
+ const count18 = [hasTarget, hasExternal, hasTeam].filter(Boolean).length;
2659
+ return count18 === 1;
2601
2660
  },
2602
2661
  {
2603
- message: "Must specify exactly one of targetSubAgentId or externalSubAgentId",
2604
- path: ["targetSubAgentId", "externalSubAgentId"]
2662
+ message: "Must specify exactly one of targetSubAgentId, externalSubAgentId, or teamSubAgentId",
2663
+ path: ["targetSubAgentId", "externalSubAgentId", "teamSubAgentId"]
2605
2664
  }
2606
2665
  ).openapi("SubAgentRelationCreate");
2607
2666
  SubAgentRelationApiUpdateSchema = createAgentScopedApiUpdateSchema(
@@ -2612,20 +2671,23 @@ var init_schemas = __esm({
2612
2671
  (data) => {
2613
2672
  const hasTarget = data.targetSubAgentId != null;
2614
2673
  const hasExternal = data.externalSubAgentId != null;
2615
- if (!hasTarget && !hasExternal) {
2674
+ const hasTeam = data.teamSubAgentId != null;
2675
+ const count18 = [hasTarget, hasExternal, hasTeam].filter(Boolean).length;
2676
+ if (count18 === 0) {
2616
2677
  return true;
2617
2678
  }
2618
- return hasTarget !== hasExternal;
2679
+ return count18 === 1;
2619
2680
  },
2620
2681
  {
2621
- message: "Must specify exactly one of targetSubAgentId or externalSubAgentId when updating sub-agent relationships",
2622
- path: ["targetSubAgentId", "externalSubAgentId"]
2682
+ message: "Must specify exactly one of targetSubAgentId, externalSubAgentId, or teamSubAgentId when updating sub-agent relationships",
2683
+ path: ["targetSubAgentId", "externalSubAgentId", "teamSubAgentId"]
2623
2684
  }
2624
2685
  ).openapi("SubAgentRelationUpdate");
2625
2686
  SubAgentRelationQuerySchema = z2.object({
2626
2687
  sourceSubAgentId: z2.string().optional(),
2627
2688
  targetSubAgentId: z2.string().optional(),
2628
- externalSubAgentId: z2.string().optional()
2689
+ externalSubAgentId: z2.string().optional(),
2690
+ teamSubAgentId: z2.string().optional()
2629
2691
  });
2630
2692
  ExternalSubAgentRelationInsertSchema = createInsertSchema(subAgentRelations).extend({
2631
2693
  id: resourceIdSchema,
@@ -3039,6 +3101,25 @@ var init_schemas = __esm({
3039
3101
  SubAgentExternalAgentRelationApiUpdateSchema = createAgentScopedApiUpdateSchema(
3040
3102
  SubAgentExternalAgentRelationUpdateSchema
3041
3103
  ).openapi("SubAgentExternalAgentRelationUpdate");
3104
+ SubAgentTeamAgentRelationSelectSchema = createSelectSchema(subAgentTeamAgentRelations);
3105
+ SubAgentTeamAgentRelationInsertSchema = createInsertSchema(
3106
+ subAgentTeamAgentRelations
3107
+ ).extend({
3108
+ id: resourceIdSchema,
3109
+ subAgentId: resourceIdSchema,
3110
+ targetAgentId: resourceIdSchema,
3111
+ headers: z2.record(z2.string(), z2.string()).nullish()
3112
+ });
3113
+ SubAgentTeamAgentRelationUpdateSchema = SubAgentTeamAgentRelationInsertSchema.partial();
3114
+ SubAgentTeamAgentRelationApiSelectSchema = createAgentScopedApiSchema(
3115
+ SubAgentTeamAgentRelationSelectSchema
3116
+ ).openapi("SubAgentTeamAgentRelation");
3117
+ SubAgentTeamAgentRelationApiInsertSchema = createAgentScopedApiInsertSchema(
3118
+ SubAgentTeamAgentRelationInsertSchema
3119
+ ).omit({ id: true, subAgentId: true }).openapi("SubAgentTeamAgentRelationCreate");
3120
+ SubAgentTeamAgentRelationApiUpdateSchema = createAgentScopedApiUpdateSchema(
3121
+ SubAgentTeamAgentRelationUpdateSchema
3122
+ ).openapi("SubAgentTeamAgentRelationUpdate");
3042
3123
  LedgerArtifactSelectSchema = createSelectSchema(ledgerArtifacts);
3043
3124
  LedgerArtifactInsertSchema = createInsertSchema(ledgerArtifacts);
3044
3125
  LedgerArtifactUpdateSchema = LedgerArtifactInsertSchema.partial();
@@ -3072,6 +3153,16 @@ var init_schemas = __esm({
3072
3153
  subAgentExternalAgentRelationId: z2.string().optional(),
3073
3154
  headers: z2.record(z2.string(), z2.string()).nullish()
3074
3155
  });
3156
+ canDelegateToTeamAgentSchema = z2.object({
3157
+ agentId: z2.string(),
3158
+ subAgentTeamAgentRelationId: z2.string().optional(),
3159
+ headers: z2.record(z2.string(), z2.string()).nullish()
3160
+ });
3161
+ TeamAgentSchema = z2.object({
3162
+ id: z2.string(),
3163
+ name: z2.string(),
3164
+ description: z2.string()
3165
+ });
3075
3166
  FullAgentAgentInsertSchema = SubAgentApiInsertSchema.extend({
3076
3167
  type: z2.literal("internal"),
3077
3168
  canUse: z2.array(CanUseItemSchema),
@@ -3083,8 +3174,10 @@ var init_schemas = __esm({
3083
3174
  z2.union([
3084
3175
  z2.string(),
3085
3176
  // Internal subAgent ID
3086
- canDelegateToExternalAgentSchema
3177
+ canDelegateToExternalAgentSchema,
3087
3178
  // External agent with headers
3179
+ canDelegateToTeamAgentSchema
3180
+ // Team agent with headers
3088
3181
  ])
3089
3182
  ).optional()
3090
3183
  });
@@ -3095,6 +3188,8 @@ var init_schemas = __esm({
3095
3188
  // MCP tools (project-scoped)
3096
3189
  externalAgents: z2.record(z2.string(), ExternalAgentApiInsertSchema).optional(),
3097
3190
  // External agents (project-scoped)
3191
+ teamAgents: z2.record(z2.string(), TeamAgentSchema).optional(),
3192
+ // Team agents contain basic metadata for the agent to be delegated to
3098
3193
  functionTools: z2.record(z2.string(), FunctionToolApiInsertSchema).optional(),
3099
3194
  // Function tools (agent-scoped)
3100
3195
  functions: z2.record(z2.string(), FunctionApiInsertSchema).optional(),
@@ -4912,6 +5007,15 @@ var init_client = __esm({
4912
5007
  }
4913
5008
  });
4914
5009
 
5010
+ // ../packages/agents-core/src/validation/agentFull.ts
5011
+ var init_agentFull = __esm({
5012
+ "../packages/agents-core/src/validation/agentFull.ts"() {
5013
+ "use strict";
5014
+ init_esm_shims();
5015
+ init_schemas();
5016
+ }
5017
+ });
5018
+
4915
5019
  // ../packages/agents-core/src/data-access/contextConfigs.ts
4916
5020
  import { and, count, desc, eq, sql as sql2 } from "drizzle-orm";
4917
5021
  var init_contextConfigs = __esm({
@@ -5122,7 +5226,7 @@ var require_util = __commonJS({
5122
5226
  return path4;
5123
5227
  }
5124
5228
  exports.normalize = normalize;
5125
- function join14(aRoot, aPath) {
5229
+ function join15(aRoot, aPath) {
5126
5230
  if (aRoot === "") {
5127
5231
  aRoot = ".";
5128
5232
  }
@@ -5154,7 +5258,7 @@ var require_util = __commonJS({
5154
5258
  }
5155
5259
  return joined;
5156
5260
  }
5157
- exports.join = join14;
5261
+ exports.join = join15;
5158
5262
  exports.isAbsolute = function(aPath) {
5159
5263
  return aPath.charAt(0) === "/" || urlRegexp.test(aPath);
5160
5264
  };
@@ -5327,7 +5431,7 @@ var require_util = __commonJS({
5327
5431
  parsed.path = parsed.path.substring(0, index2 + 1);
5328
5432
  }
5329
5433
  }
5330
- sourceURL = join14(urlGenerate(parsed), sourceURL);
5434
+ sourceURL = join15(urlGenerate(parsed), sourceURL);
5331
5435
  }
5332
5436
  return normalize(sourceURL);
5333
5437
  }
@@ -7241,11 +7345,11 @@ var require_typescript = __commonJS({
7241
7345
  for (var name in all)
7242
7346
  __defProp2(target, name, { get: all[name], enumerable: true });
7243
7347
  };
7244
- var __copyProps2 = (to, from, except, desc16) => {
7348
+ var __copyProps2 = (to, from, except, desc17) => {
7245
7349
  if (from && typeof from === "object" || typeof from === "function") {
7246
7350
  for (let key of __getOwnPropNames2(from))
7247
7351
  if (!__hasOwnProp2.call(to, key) && key !== except)
7248
- __defProp2(to, key, { get: () => from[key], enumerable: !(desc16 = __getOwnPropDesc2(from, key)) || desc16.enumerable });
7352
+ __defProp2(to, key, { get: () => from[key], enumerable: !(desc17 = __getOwnPropDesc2(from, key)) || desc17.enumerable });
7249
7353
  }
7250
7354
  return to;
7251
7355
  };
@@ -7429,7 +7533,7 @@ var require_typescript = __commonJS({
7429
7533
  affectsEmitOptionDeclarations: () => affectsEmitOptionDeclarations,
7430
7534
  allKeysStartWithDot: () => allKeysStartWithDot,
7431
7535
  altDirectorySeparator: () => altDirectorySeparator,
7432
- and: () => and21,
7536
+ and: () => and22,
7433
7537
  append: () => append,
7434
7538
  appendIfUnique: () => appendIfUnique,
7435
7539
  arrayFrom: () => arrayFrom,
@@ -9651,16 +9755,16 @@ var require_typescript = __commonJS({
9651
9755
  return -1;
9652
9756
  }
9653
9757
  function countWhere(array, predicate) {
9654
- let count17 = 0;
9758
+ let count18 = 0;
9655
9759
  if (array !== void 0) {
9656
9760
  for (let i2 = 0; i2 < array.length; i2++) {
9657
9761
  const v2 = array[i2];
9658
9762
  if (predicate(v2, i2)) {
9659
- count17++;
9763
+ count18++;
9660
9764
  }
9661
9765
  }
9662
9766
  }
9663
- return count17;
9767
+ return count18;
9664
9768
  }
9665
9769
  function filter(array, f) {
9666
9770
  if (array !== void 0) {
@@ -10213,12 +10317,12 @@ var require_typescript = __commonJS({
10213
10317
  }
10214
10318
  return ~low;
10215
10319
  }
10216
- function reduceLeft(array, f, initial, start, count17) {
10320
+ function reduceLeft(array, f, initial, start, count18) {
10217
10321
  if (array && array.length > 0) {
10218
10322
  const size = array.length;
10219
10323
  if (size > 0) {
10220
10324
  let pos = start === void 0 || start < 0 ? 0 : start;
10221
- const end = count17 === void 0 || pos + count17 > size - 1 ? size - 1 : pos + count17;
10325
+ const end = count18 === void 0 || pos + count18 > size - 1 ? size - 1 : pos + count18;
10222
10326
  let result;
10223
10327
  if (arguments.length <= 2) {
10224
10328
  result = array[pos];
@@ -10270,9 +10374,9 @@ var require_typescript = __commonJS({
10270
10374
  }
10271
10375
  return values;
10272
10376
  }
10273
- function arrayOf(count17, f) {
10274
- const result = new Array(count17);
10275
- for (let i2 = 0; i2 < count17; i2++) {
10377
+ function arrayOf(count18, f) {
10378
+ const result = new Array(count18);
10379
+ for (let i2 = 0; i2 < count18; i2++) {
10276
10380
  result[i2] = f(i2);
10277
10381
  }
10278
10382
  return result;
@@ -10880,7 +10984,7 @@ var require_typescript = __commonJS({
10880
10984
  function isPatternMatch({ prefix, suffix }, candidate) {
10881
10985
  return candidate.length >= prefix.length + suffix.length && startsWith(candidate, prefix) && endsWith(candidate, suffix);
10882
10986
  }
10883
- function and21(f, g) {
10987
+ function and22(f, g) {
10884
10988
  return (arg) => f(arg) && g(arg);
10885
10989
  }
10886
10990
  function or(...fs5) {
@@ -12387,8 +12491,8 @@ ${lanes.join("\n")}
12387
12491
  var durations = /* @__PURE__ */ new Map();
12388
12492
  function mark(markName) {
12389
12493
  if (enabled) {
12390
- const count17 = counts.get(markName) ?? 0;
12391
- counts.set(markName, count17 + 1);
12494
+ const count18 = counts.get(markName) ?? 0;
12495
+ counts.set(markName, count18 + 1);
12392
12496
  marks.set(markName, timestamp());
12393
12497
  performanceImpl == null ? void 0 : performanceImpl.mark(markName);
12394
12498
  if (typeof onProfilerEvent === "function") {
@@ -15145,8 +15249,8 @@ ${lanes.join("\n")}
15145
15249
  function sysLog(s2) {
15146
15250
  return curSysLog(s2);
15147
15251
  }
15148
- function setSysLog(logger15) {
15149
- curSysLog = logger15;
15252
+ function setSysLog(logger16) {
15253
+ curSysLog = logger16;
15150
15254
  }
15151
15255
  function createDirectoryWatcherSupportingRecursive({
15152
15256
  watchDirectory,
@@ -19899,20 +20003,20 @@ ${lanes.join("\n")}
19899
20003
  tokenValue = text4.substring(start2, pos);
19900
20004
  return isOctal;
19901
20005
  }
19902
- function scanExactNumberOfHexDigits(count17, canHaveSeparators) {
20006
+ function scanExactNumberOfHexDigits(count18, canHaveSeparators) {
19903
20007
  const valueString = scanHexDigits(
19904
20008
  /*minCount*/
19905
- count17,
20009
+ count18,
19906
20010
  /*scanAsManyAsPossible*/
19907
20011
  false,
19908
20012
  canHaveSeparators
19909
20013
  );
19910
20014
  return valueString ? parseInt(valueString, 16) : -1;
19911
20015
  }
19912
- function scanMinimumNumberOfHexDigits(count17, canHaveSeparators) {
20016
+ function scanMinimumNumberOfHexDigits(count18, canHaveSeparators) {
19913
20017
  return scanHexDigits(
19914
20018
  /*minCount*/
19915
- count17,
20019
+ count18,
19916
20020
  /*scanAsManyAsPossible*/
19917
20021
  true,
19918
20022
  canHaveSeparators
@@ -38738,13 +38842,13 @@ ${lanes.join("\n")}
38738
38842
  [expression]
38739
38843
  );
38740
38844
  }
38741
- function createReadHelper(iteratorRecord, count17) {
38845
+ function createReadHelper(iteratorRecord, count18) {
38742
38846
  context.requestEmitHelper(readHelper);
38743
38847
  return factory2.createCallExpression(
38744
38848
  getUnscopedHelperName("__read"),
38745
38849
  /*typeArguments*/
38746
38850
  void 0,
38747
- count17 !== void 0 ? [iteratorRecord, factory2.createNumericLiteral(count17 + "")] : [iteratorRecord]
38851
+ count18 !== void 0 ? [iteratorRecord, factory2.createNumericLiteral(count18 + "")] : [iteratorRecord]
38748
38852
  );
38749
38853
  }
38750
38854
  function createGeneratorHelper(body) {
@@ -61054,11 +61158,11 @@ ${lanes.join("\n")}
61054
61158
  return comparePaths(a, b2, ignoreCase) === 0;
61055
61159
  }
61056
61160
  function countPathComponents(path4) {
61057
- let count17 = 0;
61161
+ let count18 = 0;
61058
61162
  for (let i2 = startsWith(path4, "./") ? 2 : 0; i2 < path4.length; i2++) {
61059
- if (path4.charCodeAt(i2) === 47) count17++;
61163
+ if (path4.charCodeAt(i2) === 47) count18++;
61060
61164
  }
61061
- return count17;
61165
+ return count18;
61062
61166
  }
61063
61167
  function comparePathsByRedirectAndNumberOfDirectorySeparators(a, b2) {
61064
61168
  return compareBooleans(b2.isRedirect, a.isRedirect) || compareNumberOfDirectorySeparators(a.path, b2.path);
@@ -61893,7 +61997,7 @@ ${lanes.join("\n")}
61893
61997
  SignatureCheckMode3[SignatureCheckMode3["Callback"] = 3] = "Callback";
61894
61998
  return SignatureCheckMode3;
61895
61999
  })(SignatureCheckMode || {});
61896
- var isNotOverloadAndNotAccessor = and21(isNotOverload, isNotAccessor);
62000
+ var isNotOverloadAndNotAccessor = and22(isNotOverload, isNotAccessor);
61897
62001
  var intrinsicTypeKinds = new Map(Object.entries({
61898
62002
  Uppercase: 0,
61899
62003
  Lowercase: 1,
@@ -67633,7 +67737,7 @@ ${lanes.join("\n")}
67633
67737
  deepCloneOrReuseNode
67634
67738
  )), node);
67635
67739
  }
67636
- function deepCloneOrReuseNodes(nodes, visitor, test, start, count17) {
67740
+ function deepCloneOrReuseNodes(nodes, visitor, test, start, count18) {
67637
67741
  if (nodes && nodes.length === 0) {
67638
67742
  return setTextRange(factory.createNodeArray(
67639
67743
  /*elements*/
@@ -67641,7 +67745,7 @@ ${lanes.join("\n")}
67641
67745
  nodes.hasTrailingComma
67642
67746
  ), nodes);
67643
67747
  }
67644
- return visitNodes2(nodes, visitor, test, start, count17);
67748
+ return visitNodes2(nodes, visitor, test, start, count18);
67645
67749
  }
67646
67750
  }
67647
67751
  function createTypeNodeFromObjectType(type2) {
@@ -71598,10 +71702,10 @@ ${lanes.join("\n")}
71598
71702
  if (t2.flags & 512 || !expandingEnum && t2.flags | 1056) {
71599
71703
  const baseType = t2.flags & 512 ? booleanType : getBaseTypeOfEnumLikeType(t2);
71600
71704
  if (baseType.flags & 1048576) {
71601
- const count17 = baseType.types.length;
71602
- if (i2 + count17 <= types.length && getRegularTypeOfLiteralType(types[i2 + count17 - 1]) === getRegularTypeOfLiteralType(baseType.types[count17 - 1])) {
71705
+ const count18 = baseType.types.length;
71706
+ if (i2 + count18 <= types.length && getRegularTypeOfLiteralType(types[i2 + count18 - 1]) === getRegularTypeOfLiteralType(baseType.types[count18 - 1])) {
71603
71707
  result.push(baseType);
71604
- i2 += count17 - 1;
71708
+ i2 += count18 - 1;
71605
71709
  continue;
71606
71710
  }
71607
71711
  }
@@ -76567,18 +76671,18 @@ ${lanes.join("\n")}
76567
76671
  let i2 = 0;
76568
76672
  while (i2 < length2) {
76569
76673
  const startId = types[i2].id;
76570
- let count17 = 1;
76571
- while (i2 + count17 < length2 && types[i2 + count17].id === startId + count17) {
76572
- count17++;
76674
+ let count18 = 1;
76675
+ while (i2 + count18 < length2 && types[i2 + count18].id === startId + count18) {
76676
+ count18++;
76573
76677
  }
76574
76678
  if (result.length) {
76575
76679
  result += ",";
76576
76680
  }
76577
76681
  result += startId;
76578
- if (count17 > 1) {
76579
- result += ":" + count17;
76682
+ if (count18 > 1) {
76683
+ result += ":" + count18;
76580
76684
  }
76581
- i2 += count17;
76685
+ i2 += count18;
76582
76686
  }
76583
76687
  }
76584
76688
  return result;
@@ -77858,7 +77962,7 @@ ${lanes.join("\n")}
77858
77962
  const hasEmptyObject = hasObjectTypes && some(types, (t2) => !!(t2.flags & 524288) && !isGenericMappedType(t2) && isEmptyResolvedType(resolveStructuredTypeMembers(t2)));
77859
77963
  const len = types.length;
77860
77964
  let i2 = len;
77861
- let count17 = 0;
77965
+ let count18 = 0;
77862
77966
  while (i2 > 0) {
77863
77967
  i2--;
77864
77968
  const source = types[i2];
@@ -77873,15 +77977,15 @@ ${lanes.join("\n")}
77873
77977
  const keyPropertyType = keyProperty && getRegularTypeOfLiteralType(getTypeOfSymbol(keyProperty));
77874
77978
  for (const target of types) {
77875
77979
  if (source !== target) {
77876
- if (count17 === 1e5) {
77877
- const estimatedCount = count17 / (len - i2) * len;
77980
+ if (count18 === 1e5) {
77981
+ const estimatedCount = count18 / (len - i2) * len;
77878
77982
  if (estimatedCount > 1e6) {
77879
77983
  (_a = tracing) == null ? void 0 : _a.instant(tracing.Phase.CheckTypes, "removeSubtypes_DepthLimit", { typeIds: types.map((t2) => t2.id) });
77880
77984
  error2(currentNode, Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent);
77881
77985
  return void 0;
77882
77986
  }
77883
77987
  }
77884
- count17++;
77988
+ count18++;
77885
77989
  if (keyProperty && target.flags & (524288 | 2097152 | 58982400)) {
77886
77990
  const t2 = getTypeOfPropertyOfType(target, keyProperty.escapedName);
77887
77991
  if (t2 && isUnitType(t2) && getRegularTypeOfLiteralType(t2) !== keyPropertyType) {
@@ -78382,9 +78486,9 @@ ${lanes.join("\n")}
78382
78486
  return true;
78383
78487
  }
78384
78488
  function getCrossProductIntersections(types, flags) {
78385
- const count17 = getCrossProductUnionSize(types);
78489
+ const count18 = getCrossProductUnionSize(types);
78386
78490
  const intersections = [];
78387
- for (let i2 = 0; i2 < count17; i2++) {
78491
+ for (let i2 = 0; i2 < count18; i2++) {
78388
78492
  const constituents = types.slice();
78389
78493
  let n2 = i2;
78390
78494
  for (let j2 = types.length - 1; j2 >= 0; j2--) {
@@ -84251,14 +84355,14 @@ ${lanes.join("\n")}
84251
84355
  return some(type.types, (t2) => isDeeplyNestedType(t2, stack, depth, maxDepth));
84252
84356
  }
84253
84357
  const identity2 = getRecursionIdentity(type);
84254
- let count17 = 0;
84358
+ let count18 = 0;
84255
84359
  let lastTypeId = 0;
84256
84360
  for (let i2 = 0; i2 < depth; i2++) {
84257
84361
  const t2 = stack[i2];
84258
84362
  if (hasMatchingRecursionIdentity(t2, identity2)) {
84259
84363
  if (t2.id >= lastTypeId) {
84260
- count17++;
84261
- if (count17 >= maxDepth) {
84364
+ count18++;
84365
+ if (count18 >= maxDepth) {
84262
84366
  return true;
84263
84367
  }
84264
84368
  }
@@ -85718,8 +85822,8 @@ ${lanes.join("\n")}
85718
85822
  ];
85719
85823
  }
85720
85824
  function inferFromTypeArguments(sourceTypes, targetTypes, variances) {
85721
- const count17 = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length;
85722
- for (let i2 = 0; i2 < count17; i2++) {
85825
+ const count18 = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length;
85826
+ for (let i2 = 0; i2 < count18; i2++) {
85723
85827
  if (i2 < variances.length && (variances[i2] & 7) === 2) {
85724
85828
  inferFromContravariantTypes(sourceTypes[i2], targetTypes[i2]);
85725
85829
  } else {
@@ -86463,7 +86567,7 @@ ${lanes.join("\n")}
86463
86567
  }
86464
86568
  function mapTypesByKeyProperty(types, name) {
86465
86569
  const map2 = /* @__PURE__ */ new Map();
86466
- let count17 = 0;
86570
+ let count18 = 0;
86467
86571
  for (const type of types) {
86468
86572
  if (type.flags & (524288 | 2097152 | 58982400)) {
86469
86573
  const discriminant = getTypeOfPropertyOfType(type, name);
@@ -86482,11 +86586,11 @@ ${lanes.join("\n")}
86482
86586
  duplicate = true;
86483
86587
  }
86484
86588
  });
86485
- if (!duplicate) count17++;
86589
+ if (!duplicate) count18++;
86486
86590
  }
86487
86591
  }
86488
86592
  }
86489
- return count17 >= 10 && count17 * 2 >= types.length ? map2 : void 0;
86593
+ return count18 >= 10 && count18 * 2 >= types.length ? map2 : void 0;
86490
86594
  }
86491
86595
  function getKeyPropertyName(unionType) {
86492
86596
  const types = unionType.types;
@@ -104713,7 +104817,7 @@ ${lanes.join("\n")}
104713
104817
  if (flags & (1920 | 384)) {
104714
104818
  return;
104715
104819
  }
104716
- const exportedDeclarationsCount = countWhere(declarations, and21(isNotOverloadAndNotAccessor, not2(isInterfaceDeclaration)));
104820
+ const exportedDeclarationsCount = countWhere(declarations, and22(isNotOverloadAndNotAccessor, not2(isInterfaceDeclaration)));
104717
104821
  if (flags & 524288 && exportedDeclarationsCount <= 2) {
104718
104822
  return;
104719
104823
  }
@@ -109102,7 +109206,7 @@ ${lanes.join("\n")}
109102
109206
  Debug.assertNode(visitedNode, test);
109103
109207
  return visitedNode;
109104
109208
  }
109105
- function visitNodes2(nodes, visitor, test, start, count17) {
109209
+ function visitNodes2(nodes, visitor, test, start, count18) {
109106
109210
  if (nodes === void 0) {
109107
109211
  return nodes;
109108
109212
  }
@@ -109110,20 +109214,20 @@ ${lanes.join("\n")}
109110
109214
  if (start === void 0 || start < 0) {
109111
109215
  start = 0;
109112
109216
  }
109113
- if (count17 === void 0 || count17 > length2 - start) {
109114
- count17 = length2 - start;
109217
+ if (count18 === void 0 || count18 > length2 - start) {
109218
+ count18 = length2 - start;
109115
109219
  }
109116
109220
  let hasTrailingComma;
109117
109221
  let pos = -1;
109118
109222
  let end = -1;
109119
- if (start > 0 || count17 < length2) {
109120
- hasTrailingComma = nodes.hasTrailingComma && start + count17 === length2;
109223
+ if (start > 0 || count18 < length2) {
109224
+ hasTrailingComma = nodes.hasTrailingComma && start + count18 === length2;
109121
109225
  } else {
109122
109226
  pos = nodes.pos;
109123
109227
  end = nodes.end;
109124
109228
  hasTrailingComma = nodes.hasTrailingComma;
109125
109229
  }
109126
- const updated = visitArrayWorker(nodes, visitor, test, start, count17);
109230
+ const updated = visitArrayWorker(nodes, visitor, test, start, count18);
109127
109231
  if (updated !== nodes) {
109128
109232
  const updatedArray = factory.createNodeArray(updated, hasTrailingComma);
109129
109233
  setTextRangePosEnd(updatedArray, pos, end);
@@ -109131,7 +109235,7 @@ ${lanes.join("\n")}
109131
109235
  }
109132
109236
  return nodes;
109133
109237
  }
109134
- function visitArray(nodes, visitor, test, start, count17) {
109238
+ function visitArray(nodes, visitor, test, start, count18) {
109135
109239
  if (nodes === void 0) {
109136
109240
  return nodes;
109137
109241
  }
@@ -109139,18 +109243,18 @@ ${lanes.join("\n")}
109139
109243
  if (start === void 0 || start < 0) {
109140
109244
  start = 0;
109141
109245
  }
109142
- if (count17 === void 0 || count17 > length2 - start) {
109143
- count17 = length2 - start;
109246
+ if (count18 === void 0 || count18 > length2 - start) {
109247
+ count18 = length2 - start;
109144
109248
  }
109145
- return visitArrayWorker(nodes, visitor, test, start, count17);
109249
+ return visitArrayWorker(nodes, visitor, test, start, count18);
109146
109250
  }
109147
- function visitArrayWorker(nodes, visitor, test, start, count17) {
109251
+ function visitArrayWorker(nodes, visitor, test, start, count18) {
109148
109252
  let updated;
109149
109253
  const length2 = nodes.length;
109150
- if (start > 0 || count17 < length2) {
109254
+ if (start > 0 || count18 < length2) {
109151
109255
  updated = [];
109152
109256
  }
109153
- for (let i2 = 0; i2 < count17; i2++) {
109257
+ for (let i2 = 0; i2 < count18; i2++) {
109154
109258
  const node = nodes[i2 + start];
109155
109259
  const visited = node !== void 0 ? visitor ? visitor(node) : node : void 0;
109156
109260
  if (updated !== void 0 || visited === void 0 || visited !== node) {
@@ -140526,7 +140630,7 @@ ${lanes.join("\n")}
140526
140630
  break;
140527
140631
  }
140528
140632
  }
140529
- function emitList(parentNode, children, format, parenthesizerRule, start, count17) {
140633
+ function emitList(parentNode, children, format, parenthesizerRule, start, count18) {
140530
140634
  emitNodeList(
140531
140635
  emit,
140532
140636
  parentNode,
@@ -140534,18 +140638,18 @@ ${lanes.join("\n")}
140534
140638
  format | (parentNode && getEmitFlags(parentNode) & 2 ? 65536 : 0),
140535
140639
  parenthesizerRule,
140536
140640
  start,
140537
- count17
140641
+ count18
140538
140642
  );
140539
140643
  }
140540
- function emitExpressionList(parentNode, children, format, parenthesizerRule, start, count17) {
140541
- emitNodeList(emitExpression, parentNode, children, format, parenthesizerRule, start, count17);
140644
+ function emitExpressionList(parentNode, children, format, parenthesizerRule, start, count18) {
140645
+ emitNodeList(emitExpression, parentNode, children, format, parenthesizerRule, start, count18);
140542
140646
  }
140543
- function emitNodeList(emit2, parentNode, children, format, parenthesizerRule, start = 0, count17 = children ? children.length - start : 0) {
140647
+ function emitNodeList(emit2, parentNode, children, format, parenthesizerRule, start = 0, count18 = children ? children.length - start : 0) {
140544
140648
  const isUndefined2 = children === void 0;
140545
140649
  if (isUndefined2 && format & 16384) {
140546
140650
  return;
140547
140651
  }
140548
- const isEmpty = children === void 0 || start >= children.length || count17 === 0;
140652
+ const isEmpty = children === void 0 || start >= children.length || count18 === 0;
140549
140653
  if (isEmpty && format & 32768) {
140550
140654
  onBeforeEmitNodeArray == null ? void 0 : onBeforeEmitNodeArray(children);
140551
140655
  onAfterEmitNodeArray == null ? void 0 : onAfterEmitNodeArray(children);
@@ -140569,7 +140673,7 @@ ${lanes.join("\n")}
140569
140673
  writeSpace();
140570
140674
  }
140571
140675
  } else {
140572
- emitNodeListItems(emit2, parentNode, children, format, parenthesizerRule, start, count17, children.hasTrailingComma, children);
140676
+ emitNodeListItems(emit2, parentNode, children, format, parenthesizerRule, start, count18, children.hasTrailingComma, children);
140573
140677
  }
140574
140678
  onAfterEmitNodeArray == null ? void 0 : onAfterEmitNodeArray(children);
140575
140679
  if (format & 15360) {
@@ -140579,7 +140683,7 @@ ${lanes.join("\n")}
140579
140683
  writePunctuation(getClosingBracket(format));
140580
140684
  }
140581
140685
  }
140582
- function emitNodeListItems(emit2, parentNode, children, format, parenthesizerRule, start, count17, hasTrailingComma, childrenTextRange) {
140686
+ function emitNodeListItems(emit2, parentNode, children, format, parenthesizerRule, start, count18, hasTrailingComma, childrenTextRange) {
140583
140687
  const mayEmitInterveningComments = (format & 262144) === 0;
140584
140688
  let shouldEmitInterveningComments = mayEmitInterveningComments;
140585
140689
  const leadingLineTerminatorCount = getLeadingLineTerminatorCount(parentNode, children[start], format);
@@ -140595,7 +140699,7 @@ ${lanes.join("\n")}
140595
140699
  const emitListItem = getEmitListItem(emit2, parenthesizerRule);
140596
140700
  let previousSibling;
140597
140701
  let shouldDecreaseIndentAfterEmit = false;
140598
- for (let i2 = 0; i2 < count17; i2++) {
140702
+ for (let i2 = 0; i2 < count18; i2++) {
140599
140703
  const child = children[start + i2];
140600
140704
  if (format & 32) {
140601
140705
  writeLine();
@@ -140660,7 +140764,7 @@ ${lanes.join("\n")}
140660
140764
  if (format & 128) {
140661
140765
  decreaseIndent();
140662
140766
  }
140663
- const closingLineTerminatorCount = getClosingLineTerminatorCount(parentNode, children[start + count17 - 1], format, childrenTextRange);
140767
+ const closingLineTerminatorCount = getClosingLineTerminatorCount(parentNode, children[start + count18 - 1], format, childrenTextRange);
140664
140768
  if (closingLineTerminatorCount) {
140665
140769
  writeLine(closingLineTerminatorCount);
140666
140770
  } else if (format & (2097152 | 256)) {
@@ -140710,8 +140814,8 @@ ${lanes.join("\n")}
140710
140814
  writer.write(s2);
140711
140815
  }
140712
140816
  }
140713
- function writeLine(count17 = 1) {
140714
- for (let i2 = 0; i2 < count17; i2++) {
140817
+ function writeLine(count18 = 1) {
140818
+ for (let i2 = 0; i2 < count18; i2++) {
140715
140819
  writer.writeLine(i2 > 0);
140716
140820
  }
140717
140821
  }
@@ -141240,10 +141344,10 @@ ${lanes.join("\n")}
141240
141344
  }
141241
141345
  }
141242
141346
  while (true) {
141243
- const count17 = tempFlags2 & 268435455;
141347
+ const count18 = tempFlags2 & 268435455;
141244
141348
  tempFlags2++;
141245
- if (count17 !== 8 && count17 !== 13) {
141246
- const name = count17 < 26 ? "_" + String.fromCharCode(97 + count17) : "_" + (count17 - 26);
141349
+ if (count18 !== 8 && count18 !== 13) {
141350
+ const name = count18 < 26 ? "_" + String.fromCharCode(97 + count18) : "_" + (count18 - 26);
141247
141351
  const fullName = formatGeneratedName(privateName, prefix, name, suffix);
141248
141352
  if (isUniqueName(fullName, privateName)) {
141249
141353
  if (privateName) {
@@ -153326,12 +153430,12 @@ ${lanes.join("\n")}
153326
153430
  for (const line of output) {
153327
153431
  sys2.write(line);
153328
153432
  }
153329
- function example(ex, desc16) {
153433
+ function example(ex, desc17) {
153330
153434
  const examples = typeof ex === "string" ? [ex] : ex;
153331
153435
  for (const example2 of examples) {
153332
153436
  output.push(" " + colors.blue(example2) + sys2.newLine);
153333
153437
  }
153334
- output.push(" " + getDiagnosticText(desc16) + sys2.newLine + sys2.newLine);
153438
+ output.push(" " + getDiagnosticText(desc17) + sys2.newLine + sys2.newLine);
153335
153439
  }
153336
153440
  }
153337
153441
  function printAllHelp(sys2, compilerOptions, buildOptions, watchOptions) {
@@ -153983,7 +154087,7 @@ ${lanes.join("\n")}
153983
154087
  reportCountStatistic("Lines of " + key, value);
153984
154088
  }
153985
154089
  } else {
153986
- reportCountStatistic("Lines", reduceLeftIterator(lineCounts.values(), (sum, count17) => sum + count17, 0));
154090
+ reportCountStatistic("Lines", reduceLeftIterator(lineCounts.values(), (sum, count18) => sum + count18, 0));
153987
154091
  }
153988
154092
  reportCountStatistic("Identifiers", program2.getIdentifierCount());
153989
154093
  reportCountStatistic("Symbols", program2.getSymbolCount());
@@ -154088,11 +154192,11 @@ ${lanes.join("\n")}
154088
154192
  statistics.push(s2);
154089
154193
  if (aggregate) solutionPerformance == null ? void 0 : solutionPerformance.addAggregateStatistic(s2);
154090
154194
  }
154091
- function reportCountStatistic(name, count17) {
154195
+ function reportCountStatistic(name, count18) {
154092
154196
  reportStatisticalValue(
154093
154197
  {
154094
154198
  name,
154095
- value: count17,
154199
+ value: count18,
154096
154200
  type: 1
154097
154201
  /* count */
154098
154202
  },
@@ -154593,8 +154697,8 @@ ${lanes.join("\n")}
154593
154697
  nonlocalNode ? visitNodesWithoutCopyingPositions : void 0
154594
154698
  );
154595
154699
  }
154596
- function visitNodesWithoutCopyingPositions(nodes, visitor, test, start, count17) {
154597
- let result = visitNodes2(nodes, visitor, test, start, count17);
154700
+ function visitNodesWithoutCopyingPositions(nodes, visitor, test, start, count18) {
154701
+ let result = visitNodes2(nodes, visitor, test, start, count18);
154598
154702
  if (result) {
154599
154703
  if (result.pos !== -1 || result.end !== -1) {
154600
154704
  if (result === nodes) {
@@ -157488,9 +157592,9 @@ ${lanes.join("\n")}
157488
157592
  function getSnapshotText(snap) {
157489
157593
  return snap.getText(0, snap.getLength());
157490
157594
  }
157491
- function repeatString(str, count17) {
157595
+ function repeatString(str, count18) {
157492
157596
  let result = "";
157493
- for (let i2 = 0; i2 < count17; i2++) {
157597
+ for (let i2 = 0; i2 < count18; i2++) {
157494
157598
  result += str;
157495
157599
  }
157496
157600
  return result;
@@ -175622,7 +175726,7 @@ ${newComment.split("\n").map((c2) => ` * ${c2}`).join("\n")}
175622
175726
  const maybeHeritageClauseSymbol = getHeritageClauseSymbolTable(classDeclaration, checker);
175623
175727
  const implementedType = checker.getTypeAtLocation(implementedTypeNode);
175624
175728
  const implementedTypeSymbols = checker.getPropertiesOfType(implementedType);
175625
- const nonPrivateAndNotExistedInHeritageClauseMembers = implementedTypeSymbols.filter(and21(symbolPointsToNonPrivateMember, (symbol) => !maybeHeritageClauseSymbol.has(symbol.escapedName)));
175729
+ const nonPrivateAndNotExistedInHeritageClauseMembers = implementedTypeSymbols.filter(and22(symbolPointsToNonPrivateMember, (symbol) => !maybeHeritageClauseSymbol.has(symbol.escapedName)));
175626
175730
  const classType = checker.getTypeAtLocation(classDeclaration);
175627
175731
  const constructor = find(classDeclaration.members, (m2) => isConstructorDeclaration(m2));
175628
175732
  if (!classType.getNumberIndexType()) {
@@ -190297,8 +190401,8 @@ ${newComment.split("\n").map((c2) => ` * ${c2}`).join("\n")}
190297
190401
  function isAmbientModuleDeclaration(node) {
190298
190402
  return node.kind === 268 && node.name.kind === 11;
190299
190403
  }
190300
- function isExternalModuleImportEquals(eq21) {
190301
- return eq21.moduleReference.kind === 284 && eq21.moduleReference.expression.kind === 11;
190404
+ function isExternalModuleImportEquals(eq22) {
190405
+ return eq22.moduleReference.kind === 284 && eq22.moduleReference.expression.kind === 11;
190302
190406
  }
190303
190407
  var DefinitionKind = /* @__PURE__ */ ((DefinitionKind2) => {
190304
190408
  DefinitionKind2[DefinitionKind2["Symbol"] = 0] = "Symbol";
@@ -195947,13 +196051,13 @@ ${content}
195947
196051
  if (candidates[i2] === resolvedSignature) {
195948
196052
  selectedItemIndex = itemsSeen;
195949
196053
  if (item.length > 1) {
195950
- let count17 = 0;
196054
+ let count18 = 0;
195951
196055
  for (const i22 of item) {
195952
196056
  if (i22.isVariadic || i22.parameters.length >= argumentCount) {
195953
- selectedItemIndex = itemsSeen + count17;
196057
+ selectedItemIndex = itemsSeen + count18;
195954
196058
  break;
195955
196059
  }
195956
- count17++;
196060
+ count18++;
195957
196061
  }
195958
196062
  }
195959
196063
  }
@@ -198254,8 +198358,8 @@ ${options.prefix}` : "\n" : options.prefix
198254
198358
  setTextRangePosEnd(newNode, getPos2(node), getEnd(node));
198255
198359
  return newNode;
198256
198360
  }
198257
- function assignPositionsToNodeArray(nodes, visitor, test, start, count17) {
198258
- const visited = visitNodes2(nodes, visitor, test, start, count17);
198361
+ function assignPositionsToNodeArray(nodes, visitor, test, start, count18) {
198362
+ const visited = visitNodes2(nodes, visitor, test, start, count18);
198259
198363
  if (!visited) {
198260
198364
  return visited;
198261
198365
  }
@@ -202932,7 +203036,7 @@ ${options.prefix}` : "\n" : options.prefix
202932
203036
  affectsEmitOptionDeclarations: () => affectsEmitOptionDeclarations,
202933
203037
  allKeysStartWithDot: () => allKeysStartWithDot,
202934
203038
  altDirectorySeparator: () => altDirectorySeparator,
202935
- and: () => and21,
203039
+ and: () => and22,
202936
203040
  append: () => append,
202937
203041
  appendIfUnique: () => appendIfUnique,
202938
203042
  arrayFrom: () => arrayFrom,
@@ -205701,13 +205805,13 @@ ${options.prefix}` : "\n" : options.prefix
205701
205805
  return [];
205702
205806
  }
205703
205807
  var ThrottledOperations = class _ThrottledOperations {
205704
- constructor(host, logger15) {
205808
+ constructor(host, logger16) {
205705
205809
  this.host = host;
205706
205810
  this.pendingTimeouts = /* @__PURE__ */ new Map();
205707
- this.logger = logger15.hasLevel(
205811
+ this.logger = logger16.hasLevel(
205708
205812
  3
205709
205813
  /* verbose */
205710
- ) ? logger15 : void 0;
205814
+ ) ? logger16 : void 0;
205711
205815
  }
205712
205816
  /**
205713
205817
  * Wait `number` milliseconds and then invoke `cb`. If, while waiting, schedule
@@ -205740,10 +205844,10 @@ ${options.prefix}` : "\n" : options.prefix
205740
205844
  }
205741
205845
  };
205742
205846
  var GcTimer = class _GcTimer {
205743
- constructor(host, delay, logger15) {
205847
+ constructor(host, delay, logger16) {
205744
205848
  this.host = host;
205745
205849
  this.delay = delay;
205746
- this.logger = logger15;
205850
+ this.logger = logger16;
205747
205851
  }
205748
205852
  scheduleCollect() {
205749
205853
  if (!this.host.gc || this.timerId !== void 0) {
@@ -213105,14 +213209,14 @@ Dynamic files must always be opened with service's current directory or service
213105
213209
  return edits.every((edit) => textSpanEnd(edit.span) < pos);
213106
213210
  }
213107
213211
  var CommandNames = CommandTypes;
213108
- function formatMessage2(msg, logger15, byteLength, newLine) {
213109
- const verboseLogging = logger15.hasLevel(
213212
+ function formatMessage2(msg, logger16, byteLength, newLine) {
213213
+ const verboseLogging = logger16.hasLevel(
213110
213214
  3
213111
213215
  /* verbose */
213112
213216
  );
213113
213217
  const json = JSON.stringify(msg);
213114
213218
  if (verboseLogging) {
213115
- logger15.info(`${msg.type}:${stringifyIndented(msg)}`);
213219
+ logger16.info(`${msg.type}:${stringifyIndented(msg)}`);
213116
213220
  }
213117
213221
  const len = byteLength(json, "utf8");
213118
213222
  return `Content-Length: ${1 + len}\r
@@ -213267,7 +213371,7 @@ ${json}${newLine}`;
213267
213371
  const info = infos && firstOrUndefined(infos);
213268
213372
  return info && !info.isLocal ? { fileName: info.fileName, pos: info.textSpan.start } : void 0;
213269
213373
  }
213270
- function getReferencesWorker(projects2, defaultProject, initialLocation, useCaseSensitiveFileNames2, logger15) {
213374
+ function getReferencesWorker(projects2, defaultProject, initialLocation, useCaseSensitiveFileNames2, logger16) {
213271
213375
  var _a, _b;
213272
213376
  const perProjectResults = getPerProjectReferences(
213273
213377
  projects2,
@@ -213281,7 +213385,7 @@ ${json}${newLine}`;
213281
213385
  ),
213282
213386
  mapDefinitionInProject,
213283
213387
  (project, position) => {
213284
- logger15.info(`Finding references to ${position.fileName} position ${position.pos} in project ${project.getProjectName()}`);
213388
+ logger16.info(`Finding references to ${position.fileName} position ${position.pos} in project ${project.getProjectName()}`);
213285
213389
  return project.getLanguageService().findReferences(position.fileName, position.pos);
213286
213390
  },
213287
213391
  (referencedSymbol, cb) => {
@@ -217657,9 +217761,9 @@ Additional information: BADCLIENT: Bad error code, ${badCode} not found in range
217657
217761
  }
217658
217762
  };
217659
217763
  var _TypingsInstallerAdapter = class _TypingsInstallerAdapter2 {
217660
- constructor(telemetryEnabled, logger15, host, globalTypingsCacheLocation, event, maxActiveRequestCount) {
217764
+ constructor(telemetryEnabled, logger16, host, globalTypingsCacheLocation, event, maxActiveRequestCount) {
217661
217765
  this.telemetryEnabled = telemetryEnabled;
217662
- this.logger = logger15;
217766
+ this.logger = logger16;
217663
217767
  this.host = host;
217664
217768
  this.globalTypingsCacheLocation = globalTypingsCacheLocation;
217665
217769
  this.event = event;
@@ -218041,6 +218145,16 @@ var init_subAgents = __esm({
218041
218145
  }
218042
218146
  });
218043
218147
 
218148
+ // ../packages/agents-core/src/data-access/subAgentTeamAgentRelations.ts
218149
+ import { and as and8, count as count7, desc as desc7, eq as eq8 } from "drizzle-orm";
218150
+ var init_subAgentTeamAgentRelations = __esm({
218151
+ "../packages/agents-core/src/data-access/subAgentTeamAgentRelations.ts"() {
218152
+ "use strict";
218153
+ init_esm_shims();
218154
+ init_schema();
218155
+ }
218156
+ });
218157
+
218044
218158
  // ../packages/agents-core/src/credential-stuffer/index.ts
218045
218159
  var init_credential_stuffer = __esm({
218046
218160
  "../packages/agents-core/src/credential-stuffer/index.ts"() {
@@ -220984,26 +221098,26 @@ var require_resolve = __commonJS({
220984
221098
  return true;
220985
221099
  }
220986
221100
  function countKeys(schema) {
220987
- var count17 = 0, item;
221101
+ var count18 = 0, item;
220988
221102
  if (Array.isArray(schema)) {
220989
221103
  for (var i2 = 0; i2 < schema.length; i2++) {
220990
221104
  item = schema[i2];
220991
- if (typeof item == "object") count17 += countKeys(item);
220992
- if (count17 == Infinity) return Infinity;
221105
+ if (typeof item == "object") count18 += countKeys(item);
221106
+ if (count18 == Infinity) return Infinity;
220993
221107
  }
220994
221108
  } else {
220995
221109
  for (var key in schema) {
220996
221110
  if (key == "$ref") return Infinity;
220997
221111
  if (SIMPLE_INLINED[key]) {
220998
- count17++;
221112
+ count18++;
220999
221113
  } else {
221000
221114
  item = schema[key];
221001
- if (typeof item == "object") count17 += countKeys(item) + 1;
221002
- if (count17 == Infinity) return Infinity;
221115
+ if (typeof item == "object") count18 += countKeys(item) + 1;
221116
+ if (count18 == Infinity) return Infinity;
221003
221117
  }
221004
221118
  }
221005
221119
  }
221006
- return count17;
221120
+ return count18;
221007
221121
  }
221008
221122
  function getFullPath(id, normalize) {
221009
221123
  if (normalize !== false) id = normalizeId(id);
@@ -225725,14 +225839,14 @@ var require_ajv = __commonJS({
225725
225839
  return metaOpts;
225726
225840
  }
225727
225841
  function setLogger(self) {
225728
- var logger15 = self._opts.logger;
225729
- if (logger15 === false) {
225842
+ var logger16 = self._opts.logger;
225843
+ if (logger16 === false) {
225730
225844
  self.logger = { log: noop, warn: noop, error: noop };
225731
225845
  } else {
225732
- if (logger15 === void 0) logger15 = console;
225733
- if (!(typeof logger15 == "object" && logger15.log && logger15.warn && logger15.error))
225846
+ if (logger16 === void 0) logger16 = console;
225847
+ if (!(typeof logger16 == "object" && logger16.log && logger16.warn && logger16.error))
225734
225848
  throw new Error("logger must implement log, warn and error methods");
225735
- self.logger = logger15;
225849
+ self.logger = logger16;
225736
225850
  }
225737
225851
  }
225738
225852
  function noop() {
@@ -225932,6 +226046,156 @@ var init_mcp_client = __esm({
225932
226046
  }
225933
226047
  });
225934
226048
 
226049
+ // ../node_modules/.pnpm/dotenv-expand@12.0.3/node_modules/dotenv-expand/lib/main.js
226050
+ var require_main = __commonJS({
226051
+ "../node_modules/.pnpm/dotenv-expand@12.0.3/node_modules/dotenv-expand/lib/main.js"(exports, module) {
226052
+ "use strict";
226053
+ init_esm_shims();
226054
+ function _resolveEscapeSequences(value) {
226055
+ return value.replace(/\\\$/g, "$");
226056
+ }
226057
+ function expandValue(value, processEnv, runningParsed) {
226058
+ const env3 = { ...runningParsed, ...processEnv };
226059
+ const regex = /(?<!\\)\${([^{}]+)}|(?<!\\)\$([A-Za-z_][A-Za-z0-9_]*)/g;
226060
+ let result = value;
226061
+ let match2;
226062
+ const seen = /* @__PURE__ */ new Set();
226063
+ while ((match2 = regex.exec(result)) !== null) {
226064
+ seen.add(result);
226065
+ const [template, bracedExpression, unbracedExpression] = match2;
226066
+ const expression = bracedExpression || unbracedExpression;
226067
+ const opRegex = /(:\+|\+|:-|-)/;
226068
+ const opMatch = expression.match(opRegex);
226069
+ const splitter = opMatch ? opMatch[0] : null;
226070
+ const r2 = expression.split(splitter);
226071
+ let defaultValue;
226072
+ let value2;
226073
+ const key = r2.shift();
226074
+ if ([":+", "+"].includes(splitter)) {
226075
+ defaultValue = env3[key] ? r2.join(splitter) : "";
226076
+ value2 = null;
226077
+ } else {
226078
+ defaultValue = r2.join(splitter);
226079
+ value2 = env3[key];
226080
+ }
226081
+ if (value2) {
226082
+ if (seen.has(value2)) {
226083
+ result = result.replace(template, defaultValue);
226084
+ } else {
226085
+ result = result.replace(template, value2);
226086
+ }
226087
+ } else {
226088
+ result = result.replace(template, defaultValue);
226089
+ }
226090
+ if (result === runningParsed[key]) {
226091
+ break;
226092
+ }
226093
+ regex.lastIndex = 0;
226094
+ }
226095
+ return result;
226096
+ }
226097
+ function expand2(options) {
226098
+ const runningParsed = {};
226099
+ let processEnv = process.env;
226100
+ if (options && options.processEnv != null) {
226101
+ processEnv = options.processEnv;
226102
+ }
226103
+ for (const key in options.parsed) {
226104
+ let value = options.parsed[key];
226105
+ if (processEnv[key] && processEnv[key] !== value) {
226106
+ value = processEnv[key];
226107
+ } else {
226108
+ value = expandValue(value, processEnv, runningParsed);
226109
+ }
226110
+ options.parsed[key] = _resolveEscapeSequences(value);
226111
+ runningParsed[key] = _resolveEscapeSequences(value);
226112
+ }
226113
+ for (const processKey in options.parsed) {
226114
+ processEnv[processKey] = options.parsed[processKey];
226115
+ }
226116
+ return options;
226117
+ }
226118
+ module.exports.expand = expand2;
226119
+ }
226120
+ });
226121
+
226122
+ // ../packages/agents-core/src/env.ts
226123
+ import fs from "fs";
226124
+ import os from "os";
226125
+ import path2 from "path";
226126
+ import dotenv from "dotenv";
226127
+ import { findUpSync } from "find-up";
226128
+ import { z as z9 } from "zod";
226129
+ var import_dotenv_expand, loadEnvironmentFiles, envSchema, parseEnv, env;
226130
+ var init_env = __esm({
226131
+ "../packages/agents-core/src/env.ts"() {
226132
+ "use strict";
226133
+ init_esm_shims();
226134
+ import_dotenv_expand = __toESM(require_main(), 1);
226135
+ loadEnvironmentFiles = () => {
226136
+ const environmentFiles = [];
226137
+ const currentEnv = path2.resolve(process.cwd(), ".env");
226138
+ if (fs.existsSync(currentEnv)) {
226139
+ environmentFiles.push(currentEnv);
226140
+ }
226141
+ const rootEnv = findUpSync(".env", { cwd: path2.dirname(process.cwd()) });
226142
+ if (rootEnv) {
226143
+ if (rootEnv !== currentEnv) {
226144
+ environmentFiles.push(rootEnv);
226145
+ }
226146
+ }
226147
+ const userConfigPath = path2.join(os.homedir(), ".inkeep", "config");
226148
+ if (fs.existsSync(userConfigPath)) {
226149
+ dotenv.config({ path: userConfigPath, override: true, quiet: true });
226150
+ }
226151
+ if (environmentFiles.length > 0) {
226152
+ dotenv.config({
226153
+ path: environmentFiles,
226154
+ override: false,
226155
+ quiet: true
226156
+ });
226157
+ (0, import_dotenv_expand.expand)({ processEnv: process.env });
226158
+ }
226159
+ };
226160
+ loadEnvironmentFiles();
226161
+ envSchema = z9.object({
226162
+ ENVIRONMENT: z9.enum(["development", "production", "pentest", "test"]).optional(),
226163
+ DB_FILE_NAME: z9.string().optional(),
226164
+ TURSO_DATABASE_URL: z9.string().optional(),
226165
+ TURSO_AUTH_TOKEN: z9.string().optional(),
226166
+ INKEEP_AGENTS_JWT_SIGNING_SECRET: z9.string().min(32, "INKEEP_AGENTS_JWT_SIGNING_SECRET must be at least 32 characters").optional()
226167
+ });
226168
+ parseEnv = () => {
226169
+ try {
226170
+ const parsedEnv = envSchema.parse(process.env);
226171
+ return parsedEnv;
226172
+ } catch (error) {
226173
+ if (error instanceof z9.ZodError) {
226174
+ const missingVars = error.issues.map((issue) => issue.path.join("."));
226175
+ throw new Error(
226176
+ `\u274C Invalid environment variables: ${missingVars.join(", ")}
226177
+ ${error.message}`
226178
+ );
226179
+ }
226180
+ throw error;
226181
+ }
226182
+ };
226183
+ env = parseEnv();
226184
+ }
226185
+ });
226186
+
226187
+ // ../packages/agents-core/src/utils/service-token-auth.ts
226188
+ var logger6;
226189
+ var init_service_token_auth = __esm({
226190
+ "../packages/agents-core/src/utils/service-token-auth.ts"() {
226191
+ "use strict";
226192
+ init_esm_shims();
226193
+ init_env();
226194
+ init_logger();
226195
+ logger6 = getLogger("service-token-auth");
226196
+ }
226197
+ });
226198
+
225935
226199
  // ../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/platform/node/globalThis.js
225936
226200
  var _globalThis;
225937
226201
  var init_globalThis = __esm({
@@ -226099,12 +226363,12 @@ var init_global_utils = __esm({
226099
226363
 
226100
226364
  // ../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/diag/ComponentLogger.js
226101
226365
  function logProxy(funcName, namespace, args) {
226102
- var logger15 = getGlobal("diag");
226103
- if (!logger15) {
226366
+ var logger16 = getGlobal("diag");
226367
+ if (!logger16) {
226104
226368
  return;
226105
226369
  }
226106
226370
  args.unshift(namespace);
226107
- return logger15[funcName].apply(logger15, __spreadArray([], __read(args), false));
226371
+ return logger16[funcName].apply(logger16, __spreadArray([], __read(args), false));
226108
226372
  }
226109
226373
  var __read, __spreadArray, DiagComponentLogger;
226110
226374
  var init_ComponentLogger = __esm({
@@ -226202,17 +226466,17 @@ var init_types3 = __esm({
226202
226466
  });
226203
226467
 
226204
226468
  // ../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/diag/internal/logLevelLogger.js
226205
- function createLogLevelDiagLogger(maxLevel, logger15) {
226469
+ function createLogLevelDiagLogger(maxLevel, logger16) {
226206
226470
  if (maxLevel < DiagLogLevel.NONE) {
226207
226471
  maxLevel = DiagLogLevel.NONE;
226208
226472
  } else if (maxLevel > DiagLogLevel.ALL) {
226209
226473
  maxLevel = DiagLogLevel.ALL;
226210
226474
  }
226211
- logger15 = logger15 || {};
226475
+ logger16 = logger16 || {};
226212
226476
  function _filterFunc(funcName, theLevel) {
226213
- var theFunc = logger15[funcName];
226477
+ var theFunc = logger16[funcName];
226214
226478
  if (typeof theFunc === "function" && maxLevel >= theLevel) {
226215
- return theFunc.bind(logger15);
226479
+ return theFunc.bind(logger16);
226216
226480
  }
226217
226481
  return function() {
226218
226482
  };
@@ -226279,19 +226543,19 @@ var init_diag = __esm({
226279
226543
  for (var _i = 0; _i < arguments.length; _i++) {
226280
226544
  args[_i] = arguments[_i];
226281
226545
  }
226282
- var logger15 = getGlobal("diag");
226283
- if (!logger15)
226546
+ var logger16 = getGlobal("diag");
226547
+ if (!logger16)
226284
226548
  return;
226285
- return logger15[funcName].apply(logger15, __spreadArray2([], __read2(args), false));
226549
+ return logger16[funcName].apply(logger16, __spreadArray2([], __read2(args), false));
226286
226550
  };
226287
226551
  }
226288
226552
  var self = this;
226289
- var setLogger = function(logger15, optionsOrLogLevel) {
226553
+ var setLogger = function(logger16, optionsOrLogLevel) {
226290
226554
  var _a, _b, _c;
226291
226555
  if (optionsOrLogLevel === void 0) {
226292
226556
  optionsOrLogLevel = { logLevel: DiagLogLevel.INFO };
226293
226557
  }
226294
- if (logger15 === self) {
226558
+ if (logger16 === self) {
226295
226559
  var err = new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
226296
226560
  self.error((_a = err.stack) !== null && _a !== void 0 ? _a : err.message);
226297
226561
  return false;
@@ -226302,7 +226566,7 @@ var init_diag = __esm({
226302
226566
  };
226303
226567
  }
226304
226568
  var oldLogger = getGlobal("diag");
226305
- var newLogger = createLogLevelDiagLogger((_b = optionsOrLogLevel.logLevel) !== null && _b !== void 0 ? _b : DiagLogLevel.INFO, logger15);
226569
+ var newLogger = createLogLevelDiagLogger((_b = optionsOrLogLevel.logLevel) !== null && _b !== void 0 ? _b : DiagLogLevel.INFO, logger16);
226306
226570
  if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
226307
226571
  var stack = (_c = new Error().stack) !== null && _c !== void 0 ? _c : "<failed to generate stacktrace>";
226308
226572
  oldLogger.warn("Current logger will be overwritten from " + stack);
@@ -226871,18 +227135,18 @@ function getTracer(serviceName, serviceVersion) {
226871
227135
  try {
226872
227136
  return trace.getTracer(serviceName, serviceVersion);
226873
227137
  } catch (_error) {
226874
- logger6.debug({}, "OpenTelemetry tracer not available, using no-op tracer");
227138
+ logger7.debug({}, "OpenTelemetry tracer not available, using no-op tracer");
226875
227139
  return noopTracer;
226876
227140
  }
226877
227141
  }
226878
- var logger6, createNoOpSpan, noopTracer;
227142
+ var logger7, createNoOpSpan, noopTracer;
226879
227143
  var init_tracer_factory = __esm({
226880
227144
  "../packages/agents-core/src/utils/tracer-factory.ts"() {
226881
227145
  "use strict";
226882
227146
  init_esm_shims();
226883
227147
  init_esm();
226884
227148
  init_utils();
226885
- logger6 = getLogger("tracer");
227149
+ logger7 = getLogger("tracer");
226886
227150
  createNoOpSpan = () => ({
226887
227151
  setAttributes: () => ({}),
226888
227152
  recordException: () => ({}),
@@ -226928,12 +227192,13 @@ var init_utils = __esm({
226928
227192
  init_logger();
226929
227193
  init_mcp_client();
226930
227194
  init_schema_conversion();
227195
+ init_service_token_auth();
226931
227196
  init_tracer_factory();
226932
227197
  }
226933
227198
  });
226934
227199
 
226935
227200
  // ../packages/agents-core/src/data-access/credentialReferences.ts
226936
- import { and as and8, count as count7, desc as desc7, eq as eq8, sql as sql3 } from "drizzle-orm";
227201
+ import { and as and9, count as count8, desc as desc8, eq as eq9, sql as sql3 } from "drizzle-orm";
226937
227202
  var init_credentialReferences = __esm({
226938
227203
  "../packages/agents-core/src/data-access/credentialReferences.ts"() {
226939
227204
  "use strict";
@@ -226943,8 +227208,8 @@ var init_credentialReferences = __esm({
226943
227208
  });
226944
227209
 
226945
227210
  // ../packages/agents-core/src/data-access/tools.ts
226946
- import { and as and9, count as count8, desc as desc8, eq as eq9 } from "drizzle-orm";
226947
- var logger7;
227211
+ import { and as and10, count as count9, desc as desc9, eq as eq10 } from "drizzle-orm";
227212
+ var logger8;
226948
227213
  var init_tools = __esm({
226949
227214
  "../packages/agents-core/src/data-access/tools.ts"() {
226950
227215
  "use strict";
@@ -226959,18 +227224,18 @@ var init_tools = __esm({
226959
227224
  init_mcp_client();
226960
227225
  init_credentialReferences();
226961
227226
  init_subAgentRelations();
226962
- logger7 = getLogger("tools");
227227
+ logger8 = getLogger("tools");
226963
227228
  }
226964
227229
  });
226965
227230
 
226966
227231
  // ../packages/agents-core/src/data-access/agents.ts
226967
- import { and as and10, count as count9, desc as desc9, eq as eq10, inArray as inArray2 } from "drizzle-orm";
227232
+ import { and as and11, count as count10, desc as desc10, eq as eq11, inArray as inArray2 } from "drizzle-orm";
226968
227233
  var init_agents = __esm({
226969
227234
  "../packages/agents-core/src/data-access/agents.ts"() {
226970
227235
  "use strict";
226971
227236
  init_esm_shims();
226972
- init_conversations();
226973
227237
  init_schema();
227238
+ init_conversations();
226974
227239
  init_contextConfigs();
226975
227240
  init_externalAgents();
226976
227241
  init_functions();
@@ -226978,21 +227243,11 @@ var init_agents = __esm({
226978
227243
  init_subAgentExternalAgentRelations();
226979
227244
  init_subAgentRelations();
226980
227245
  init_subAgents();
227246
+ init_subAgentTeamAgentRelations();
226981
227247
  init_tools();
226982
227248
  }
226983
227249
  });
226984
227250
 
226985
- // ../packages/agents-core/src/data-access/apiKeys.ts
226986
- import { and as and11, count as count10, desc as desc10, eq as eq11 } from "drizzle-orm";
226987
- var init_apiKeys2 = __esm({
226988
- "../packages/agents-core/src/data-access/apiKeys.ts"() {
226989
- "use strict";
226990
- init_esm_shims();
226991
- init_schema();
226992
- init_apiKeys();
226993
- }
226994
- });
226995
-
226996
227251
  // ../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/compile/codegen/code.js
226997
227252
  var require_code = __commonJS({
226998
227253
  "../node_modules/.pnpm/ajv@8.17.1/node_modules/ajv/dist/compile/codegen/code.js"(exports) {
@@ -227997,10 +228252,10 @@ var require_codegen = __commonJS({
227997
228252
  }
227998
228253
  exports.not = not2;
227999
228254
  var andCode = mappend(exports.operators.AND);
228000
- function and21(...args) {
228255
+ function and22(...args) {
228001
228256
  return args.reduce(andCode);
228002
228257
  }
228003
- exports.and = and21;
228258
+ exports.and = and22;
228004
228259
  var orCode = mappend(exports.operators.OR);
228005
228260
  function or(...args) {
228006
228261
  return args.reduce(orCode);
@@ -229161,20 +229416,20 @@ var require_resolve2 = __commonJS({
229161
229416
  return false;
229162
229417
  }
229163
229418
  function countKeys(schema) {
229164
- let count17 = 0;
229419
+ let count18 = 0;
229165
229420
  for (const key in schema) {
229166
229421
  if (key === "$ref")
229167
229422
  return Infinity;
229168
- count17++;
229423
+ count18++;
229169
229424
  if (SIMPLE_INLINED.has(key))
229170
229425
  continue;
229171
229426
  if (typeof schema[key] == "object") {
229172
- (0, util_1.eachItem)(schema[key], (sch) => count17 += countKeys(sch));
229427
+ (0, util_1.eachItem)(schema[key], (sch) => count18 += countKeys(sch));
229173
229428
  }
229174
- if (count17 === Infinity)
229429
+ if (count18 === Infinity)
229175
229430
  return Infinity;
229176
229431
  }
229177
- return count17;
229432
+ return count18;
229178
229433
  }
229179
229434
  function getFullPath(resolver, id = "", normalize) {
229180
229435
  if (normalize !== false)
@@ -231318,13 +231573,13 @@ var require_core = __commonJS({
231318
231573
  }, warn() {
231319
231574
  }, error() {
231320
231575
  } };
231321
- function getLogger2(logger15) {
231322
- if (logger15 === false)
231576
+ function getLogger2(logger16) {
231577
+ if (logger16 === false)
231323
231578
  return noLogs;
231324
- if (logger15 === void 0)
231579
+ if (logger16 === void 0)
231325
231580
  return console;
231326
- if (logger15.log && logger15.warn && logger15.error)
231327
- return logger15;
231581
+ if (logger16.log && logger16.warn && logger16.error)
231582
+ return logger16;
231328
231583
  throw new Error("logger must implement log, warn and error methods");
231329
231584
  }
231330
231585
  var KEYWORD_NAME = /^[a-z_$][a-z0-9_$:-]*$/i;
@@ -232280,8 +232535,8 @@ var require_contains2 = __commonJS({
232280
232535
  cxt.result(valid, () => cxt.reset());
232281
232536
  function validateItemsWithCount() {
232282
232537
  const schValid = gen.name("_valid");
232283
- const count17 = gen.let("count", 0);
232284
- validateItems(schValid, () => gen.if(schValid, () => checkLimits(count17)));
232538
+ const count18 = gen.let("count", 0);
232539
+ validateItems(schValid, () => gen.if(schValid, () => checkLimits(count18)));
232285
232540
  }
232286
232541
  function validateItems(_valid, block) {
232287
232542
  gen.forRange("i", 0, len, (i2) => {
@@ -232294,16 +232549,16 @@ var require_contains2 = __commonJS({
232294
232549
  block();
232295
232550
  });
232296
232551
  }
232297
- function checkLimits(count17) {
232298
- gen.code((0, codegen_1._)`${count17}++`);
232552
+ function checkLimits(count18) {
232553
+ gen.code((0, codegen_1._)`${count18}++`);
232299
232554
  if (max === void 0) {
232300
- gen.if((0, codegen_1._)`${count17} >= ${min}`, () => gen.assign(valid, true).break());
232555
+ gen.if((0, codegen_1._)`${count18} >= ${min}`, () => gen.assign(valid, true).break());
232301
232556
  } else {
232302
- gen.if((0, codegen_1._)`${count17} > ${max}`, () => gen.assign(valid, false).break());
232557
+ gen.if((0, codegen_1._)`${count18} > ${max}`, () => gen.assign(valid, false).break());
232303
232558
  if (min === 1)
232304
232559
  gen.assign(valid, true);
232305
232560
  else
232306
- gen.if((0, codegen_1._)`${count17} >= ${min}`, () => gen.assign(valid, true));
232561
+ gen.if((0, codegen_1._)`${count18} >= ${min}`, () => gen.assign(valid, true));
232307
232562
  }
232308
232563
  }
232309
232564
  }
@@ -233488,28 +233743,6 @@ var init_artifactComponents = __esm({
233488
233743
  }
233489
233744
  });
233490
233745
 
233491
- // ../packages/agents-core/src/data-access/contextCache.ts
233492
- import { and as and13, eq as eq13 } from "drizzle-orm";
233493
- var init_contextCache = __esm({
233494
- "../packages/agents-core/src/data-access/contextCache.ts"() {
233495
- "use strict";
233496
- init_esm_shims();
233497
- init_conversations();
233498
- init_schema();
233499
- }
233500
- });
233501
-
233502
- // ../packages/agents-core/src/data-access/conversations.ts
233503
- import { and as and14, count as count12, desc as desc12, eq as eq14 } from "drizzle-orm";
233504
- var init_conversations2 = __esm({
233505
- "../packages/agents-core/src/data-access/conversations.ts"() {
233506
- "use strict";
233507
- init_esm_shims();
233508
- init_schema();
233509
- init_conversations();
233510
- }
233511
- });
233512
-
233513
233746
  // ../packages/agents-core/src/validation/preview-validation.ts
233514
233747
  var init_preview_validation = __esm({
233515
233748
  "../packages/agents-core/src/validation/preview-validation.ts"() {
@@ -233519,7 +233752,7 @@ var init_preview_validation = __esm({
233519
233752
  });
233520
233753
 
233521
233754
  // ../packages/agents-core/src/data-access/dataComponents.ts
233522
- import { and as and15, count as count13, desc as desc13, eq as eq15 } from "drizzle-orm";
233755
+ import { and as and13, count as count12, desc as desc12, eq as eq13 } from "drizzle-orm";
233523
233756
  var init_dataComponents = __esm({
233524
233757
  "../packages/agents-core/src/data-access/dataComponents.ts"() {
233525
233758
  "use strict";
@@ -233531,17 +233764,8 @@ var init_dataComponents = __esm({
233531
233764
  }
233532
233765
  });
233533
233766
 
233534
- // ../packages/agents-core/src/validation/agentFull.ts
233535
- var init_agentFull = __esm({
233536
- "../packages/agents-core/src/validation/agentFull.ts"() {
233537
- "use strict";
233538
- init_esm_shims();
233539
- init_schemas();
233540
- }
233541
- });
233542
-
233543
233767
  // ../packages/agents-core/src/data-access/agentFull.ts
233544
- import { and as and16, eq as eq16, inArray as inArray3, not } from "drizzle-orm";
233768
+ import { and as and14, eq as eq14, inArray as inArray3, not } from "drizzle-orm";
233545
233769
  var init_agentFull2 = __esm({
233546
233770
  "../packages/agents-core/src/data-access/agentFull.ts"() {
233547
233771
  "use strict";
@@ -233558,12 +233782,46 @@ var init_agentFull2 = __esm({
233558
233782
  init_subAgentExternalAgentRelations();
233559
233783
  init_subAgentRelations();
233560
233784
  init_subAgents();
233785
+ init_subAgentTeamAgentRelations();
233561
233786
  init_tools();
233562
233787
  }
233563
233788
  });
233564
233789
 
233790
+ // ../packages/agents-core/src/data-access/apiKeys.ts
233791
+ import { and as and15, count as count13, desc as desc13, eq as eq15 } from "drizzle-orm";
233792
+ var init_apiKeys2 = __esm({
233793
+ "../packages/agents-core/src/data-access/apiKeys.ts"() {
233794
+ "use strict";
233795
+ init_esm_shims();
233796
+ init_schema();
233797
+ init_apiKeys();
233798
+ }
233799
+ });
233800
+
233801
+ // ../packages/agents-core/src/data-access/contextCache.ts
233802
+ import { and as and16, eq as eq16 } from "drizzle-orm";
233803
+ var init_contextCache = __esm({
233804
+ "../packages/agents-core/src/data-access/contextCache.ts"() {
233805
+ "use strict";
233806
+ init_esm_shims();
233807
+ init_conversations();
233808
+ init_schema();
233809
+ }
233810
+ });
233811
+
233812
+ // ../packages/agents-core/src/data-access/conversations.ts
233813
+ import { and as and17, count as count14, desc as desc14, eq as eq17 } from "drizzle-orm";
233814
+ var init_conversations2 = __esm({
233815
+ "../packages/agents-core/src/data-access/conversations.ts"() {
233816
+ "use strict";
233817
+ init_esm_shims();
233818
+ init_schema();
233819
+ init_conversations();
233820
+ }
233821
+ });
233822
+
233565
233823
  // ../packages/agents-core/src/data-access/ledgerArtifacts.ts
233566
- import { and as and17, count as count14, eq as eq17 } from "drizzle-orm";
233824
+ import { and as and18, count as count15, eq as eq18 } from "drizzle-orm";
233567
233825
  var init_ledgerArtifacts = __esm({
233568
233826
  "../packages/agents-core/src/data-access/ledgerArtifacts.ts"() {
233569
233827
  "use strict";
@@ -233574,7 +233832,7 @@ var init_ledgerArtifacts = __esm({
233574
233832
  });
233575
233833
 
233576
233834
  // ../packages/agents-core/src/data-access/messages.ts
233577
- import { and as and18, asc as asc2, count as count15, desc as desc14, eq as eq18, inArray as inArray4 } from "drizzle-orm";
233835
+ import { and as and19, asc as asc2, count as count16, desc as desc15, eq as eq19, inArray as inArray4 } from "drizzle-orm";
233578
233836
  var init_messages = __esm({
233579
233837
  "../packages/agents-core/src/data-access/messages.ts"() {
233580
233838
  "use strict";
@@ -233584,7 +233842,7 @@ var init_messages = __esm({
233584
233842
  });
233585
233843
 
233586
233844
  // ../packages/agents-core/src/data-access/projects.ts
233587
- import { and as and19, count as count16, desc as desc15, eq as eq19 } from "drizzle-orm";
233845
+ import { and as and20, count as count17, desc as desc16, eq as eq20 } from "drizzle-orm";
233588
233846
  var init_projects = __esm({
233589
233847
  "../packages/agents-core/src/data-access/projects.ts"() {
233590
233848
  "use strict";
@@ -233614,7 +233872,7 @@ var init_projectFull = __esm({
233614
233872
  });
233615
233873
 
233616
233874
  // ../packages/agents-core/src/data-access/tasks.ts
233617
- import { and as and20, eq as eq20 } from "drizzle-orm";
233875
+ import { and as and21, eq as eq21 } from "drizzle-orm";
233618
233876
  var init_tasks = __esm({
233619
233877
  "../packages/agents-core/src/data-access/tasks.ts"() {
233620
233878
  "use strict";
@@ -233638,6 +233896,7 @@ var init_data_access = __esm({
233638
233896
  "use strict";
233639
233897
  init_esm_shims();
233640
233898
  init_client();
233899
+ init_agentFull2();
233641
233900
  init_agents();
233642
233901
  init_apiKeys2();
233643
233902
  init_artifactComponents();
@@ -233649,7 +233908,6 @@ var init_data_access = __esm({
233649
233908
  init_externalAgents();
233650
233909
  init_functions();
233651
233910
  init_functionTools();
233652
- init_agentFull2();
233653
233911
  init_ledgerArtifacts();
233654
233912
  init_messages();
233655
233913
  init_projectFull();
@@ -233657,6 +233915,7 @@ var init_data_access = __esm({
233657
233915
  init_subAgentExternalAgentRelations();
233658
233916
  init_subAgentRelations();
233659
233917
  init_subAgents();
233918
+ init_subAgentTeamAgentRelations();
233660
233919
  init_tasks();
233661
233920
  init_tools();
233662
233921
  init_validation();
@@ -233676,7 +233935,7 @@ var init_tracer = __esm({
233676
233935
  });
233677
233936
 
233678
233937
  // ../packages/agents-core/src/context/contextCache.ts
233679
- var logger8;
233938
+ var logger9;
233680
233939
  var init_contextCache2 = __esm({
233681
233940
  "../packages/agents-core/src/context/contextCache.ts"() {
233682
233941
  "use strict";
@@ -233684,13 +233943,13 @@ var init_contextCache2 = __esm({
233684
233943
  init_data_access();
233685
233944
  init_conversations();
233686
233945
  init_logger();
233687
- logger8 = getLogger("context-cache");
233946
+ logger9 = getLogger("context-cache");
233688
233947
  }
233689
233948
  });
233690
233949
 
233691
233950
  // ../packages/agents-core/src/context/ContextResolver.ts
233692
233951
  import crypto4 from "crypto";
233693
- var logger9;
233952
+ var logger10;
233694
233953
  var init_ContextResolver = __esm({
233695
233954
  "../packages/agents-core/src/context/ContextResolver.ts"() {
233696
233955
  "use strict";
@@ -233699,12 +233958,12 @@ var init_ContextResolver = __esm({
233699
233958
  init_tracer();
233700
233959
  init_ContextFetcher();
233701
233960
  init_contextCache2();
233702
- logger9 = getLogger("context-resolver");
233961
+ logger10 = getLogger("context-resolver");
233703
233962
  }
233704
233963
  });
233705
233964
 
233706
233965
  // ../packages/agents-core/src/middleware/contextValidation.ts
233707
- var import_ajv3, logger10, ajv;
233966
+ var import_ajv3, logger11, ajv;
233708
233967
  var init_contextValidation = __esm({
233709
233968
  "../packages/agents-core/src/middleware/contextValidation.ts"() {
233710
233969
  "use strict";
@@ -233716,7 +233975,7 @@ var init_contextValidation = __esm({
233716
233975
  init_error();
233717
233976
  init_execution();
233718
233977
  init_logger();
233719
- logger10 = getLogger("context-validation");
233978
+ logger11 = getLogger("context-validation");
233720
233979
  ajv = new import_ajv3.default({ allErrors: true, strict: false });
233721
233980
  }
233722
233981
  });
@@ -233731,7 +233990,7 @@ var init_middleware = __esm({
233731
233990
  });
233732
233991
 
233733
233992
  // ../packages/agents-core/src/context/ContextFetcher.ts
233734
- var import_jmespath2, logger11;
233993
+ var import_jmespath2, logger12;
233735
233994
  var init_ContextFetcher = __esm({
233736
233995
  "../packages/agents-core/src/context/ContextFetcher.ts"() {
233737
233996
  "use strict";
@@ -233742,12 +234001,12 @@ var init_ContextFetcher = __esm({
233742
234001
  init_middleware();
233743
234002
  init_logger();
233744
234003
  init_TemplateEngine();
233745
- logger11 = getLogger("context-fetcher");
234004
+ logger12 = getLogger("context-fetcher");
233746
234005
  }
233747
234006
  });
233748
234007
 
233749
234008
  // ../packages/agents-core/src/context/context.ts
233750
- var logger12;
234009
+ var logger13;
233751
234010
  var init_context4 = __esm({
233752
234011
  "../packages/agents-core/src/context/context.ts"() {
233753
234012
  "use strict";
@@ -233756,7 +234015,7 @@ var init_context4 = __esm({
233756
234015
  init_utils();
233757
234016
  init_tracer();
233758
234017
  init_ContextResolver();
233759
- logger12 = getLogger("context");
234018
+ logger13 = getLogger("context");
233760
234019
  }
233761
234020
  });
233762
234021
 
@@ -233848,8 +234107,8 @@ var init_dist6 = __esm({
233848
234107
  });
233849
234108
 
233850
234109
  // ../packages/agents-core/src/credential-stores/nango-store.ts
233851
- import { z as z9 } from "zod";
233852
- var logger13, CredentialKeySchema;
234110
+ import { z as z10 } from "zod";
234111
+ var logger14, CredentialKeySchema;
233853
234112
  var init_nango_store = __esm({
233854
234113
  "../packages/agents-core/src/credential-stores/nango-store.ts"() {
233855
234114
  "use strict";
@@ -233857,10 +234116,10 @@ var init_nango_store = __esm({
233857
234116
  init_dist6();
233858
234117
  init_types();
233859
234118
  init_logger();
233860
- logger13 = getLogger("nango-credential-store");
233861
- CredentialKeySchema = z9.object({
233862
- connectionId: z9.string().min(1, "connectionId must be a non-empty string"),
233863
- providerConfigKey: z9.string().min(1, "providerConfigKey must be a non-empty string")
234119
+ logger14 = getLogger("nango-credential-store");
234120
+ CredentialKeySchema = z10.object({
234121
+ connectionId: z10.string().min(1, "connectionId must be a non-empty string"),
234122
+ providerConfigKey: z10.string().min(1, "providerConfigKey must be a non-empty string")
233864
234123
  });
233865
234124
  }
233866
234125
  });
@@ -233889,143 +234148,6 @@ var init_credential_stores = __esm({
233889
234148
  }
233890
234149
  });
233891
234150
 
233892
- // ../node_modules/.pnpm/dotenv-expand@12.0.3/node_modules/dotenv-expand/lib/main.js
233893
- var require_main = __commonJS({
233894
- "../node_modules/.pnpm/dotenv-expand@12.0.3/node_modules/dotenv-expand/lib/main.js"(exports, module) {
233895
- "use strict";
233896
- init_esm_shims();
233897
- function _resolveEscapeSequences(value) {
233898
- return value.replace(/\\\$/g, "$");
233899
- }
233900
- function expandValue(value, processEnv, runningParsed) {
233901
- const env3 = { ...runningParsed, ...processEnv };
233902
- const regex = /(?<!\\)\${([^{}]+)}|(?<!\\)\$([A-Za-z_][A-Za-z0-9_]*)/g;
233903
- let result = value;
233904
- let match2;
233905
- const seen = /* @__PURE__ */ new Set();
233906
- while ((match2 = regex.exec(result)) !== null) {
233907
- seen.add(result);
233908
- const [template, bracedExpression, unbracedExpression] = match2;
233909
- const expression = bracedExpression || unbracedExpression;
233910
- const opRegex = /(:\+|\+|:-|-)/;
233911
- const opMatch = expression.match(opRegex);
233912
- const splitter = opMatch ? opMatch[0] : null;
233913
- const r2 = expression.split(splitter);
233914
- let defaultValue;
233915
- let value2;
233916
- const key = r2.shift();
233917
- if ([":+", "+"].includes(splitter)) {
233918
- defaultValue = env3[key] ? r2.join(splitter) : "";
233919
- value2 = null;
233920
- } else {
233921
- defaultValue = r2.join(splitter);
233922
- value2 = env3[key];
233923
- }
233924
- if (value2) {
233925
- if (seen.has(value2)) {
233926
- result = result.replace(template, defaultValue);
233927
- } else {
233928
- result = result.replace(template, value2);
233929
- }
233930
- } else {
233931
- result = result.replace(template, defaultValue);
233932
- }
233933
- if (result === runningParsed[key]) {
233934
- break;
233935
- }
233936
- regex.lastIndex = 0;
233937
- }
233938
- return result;
233939
- }
233940
- function expand2(options) {
233941
- const runningParsed = {};
233942
- let processEnv = process.env;
233943
- if (options && options.processEnv != null) {
233944
- processEnv = options.processEnv;
233945
- }
233946
- for (const key in options.parsed) {
233947
- let value = options.parsed[key];
233948
- if (processEnv[key] && processEnv[key] !== value) {
233949
- value = processEnv[key];
233950
- } else {
233951
- value = expandValue(value, processEnv, runningParsed);
233952
- }
233953
- options.parsed[key] = _resolveEscapeSequences(value);
233954
- runningParsed[key] = _resolveEscapeSequences(value);
233955
- }
233956
- for (const processKey in options.parsed) {
233957
- processEnv[processKey] = options.parsed[processKey];
233958
- }
233959
- return options;
233960
- }
233961
- module.exports.expand = expand2;
233962
- }
233963
- });
233964
-
233965
- // ../packages/agents-core/src/env.ts
233966
- import fs from "fs";
233967
- import os from "os";
233968
- import path2 from "path";
233969
- import dotenv from "dotenv";
233970
- import { findUpSync } from "find-up";
233971
- import { z as z10 } from "zod";
233972
- var import_dotenv_expand, loadEnvironmentFiles, envSchema, parseEnv, env;
233973
- var init_env = __esm({
233974
- "../packages/agents-core/src/env.ts"() {
233975
- "use strict";
233976
- init_esm_shims();
233977
- import_dotenv_expand = __toESM(require_main(), 1);
233978
- loadEnvironmentFiles = () => {
233979
- const environmentFiles = [];
233980
- const currentEnv = path2.resolve(process.cwd(), ".env");
233981
- if (fs.existsSync(currentEnv)) {
233982
- environmentFiles.push(currentEnv);
233983
- }
233984
- const rootEnv = findUpSync(".env", { cwd: path2.dirname(process.cwd()) });
233985
- if (rootEnv) {
233986
- if (rootEnv !== currentEnv) {
233987
- environmentFiles.push(rootEnv);
233988
- }
233989
- }
233990
- const userConfigPath = path2.join(os.homedir(), ".inkeep", "config");
233991
- if (fs.existsSync(userConfigPath)) {
233992
- dotenv.config({ path: userConfigPath, override: true, quiet: true });
233993
- }
233994
- if (environmentFiles.length > 0) {
233995
- dotenv.config({
233996
- path: environmentFiles,
233997
- override: false,
233998
- quiet: true
233999
- });
234000
- (0, import_dotenv_expand.expand)({ processEnv: process.env });
234001
- }
234002
- };
234003
- loadEnvironmentFiles();
234004
- envSchema = z10.object({
234005
- ENVIRONMENT: z10.enum(["development", "production", "pentest", "test"]).optional(),
234006
- DB_FILE_NAME: z10.string().optional(),
234007
- TURSO_DATABASE_URL: z10.string().optional(),
234008
- TURSO_AUTH_TOKEN: z10.string().optional()
234009
- });
234010
- parseEnv = () => {
234011
- try {
234012
- const parsedEnv = envSchema.parse(process.env);
234013
- return parsedEnv;
234014
- } catch (error) {
234015
- if (error instanceof z10.ZodError) {
234016
- const missingVars = error.issues.map((issue) => issue.path.join("."));
234017
- throw new Error(
234018
- `\u274C Invalid environment variables: ${missingVars.join(", ")}
234019
- ${error.message}`
234020
- );
234021
- }
234022
- throw error;
234023
- }
234024
- };
234025
- env = parseEnv();
234026
- }
234027
- });
234028
-
234029
234151
  // ../packages/agents-core/src/validation/event-schemas.ts
234030
234152
  import { z as z11 } from "zod";
234031
234153
  var TransferDataSchema, DelegationSentDataSchema, DelegationReturnedDataSchema, DataOperationDetailsSchema, DataOperationEventSchema, A2AMessageMetadataSchema;
@@ -234303,7 +234425,7 @@ function findConfigFile(startPath = process.cwd()) {
234303
234425
  return null;
234304
234426
  }
234305
234427
  async function loadConfigFromFile(configPath) {
234306
- logger14.info({ fromPath: configPath }, `Loading config file`);
234428
+ logger15.info({ fromPath: configPath }, `Loading config file`);
234307
234429
  let resolvedPath;
234308
234430
  if (configPath) {
234309
234431
  resolvedPath = resolve2(process.cwd(), configPath);
@@ -234323,7 +234445,7 @@ async function loadConfigFromFile(configPath) {
234323
234445
  throw new Error(`No config exported from ${resolvedPath}`);
234324
234446
  }
234325
234447
  const config = normalizeConfig(rawConfig);
234326
- logger14.info({ config: maskSensitiveConfig(config) }, `Loaded config values`);
234448
+ logger15.info({ config: maskSensitiveConfig(config) }, `Loaded config values`);
234327
234449
  return config;
234328
234450
  } catch (error) {
234329
234451
  console.warn(`Warning: Failed to load config file ${resolvedPath}:`, error);
@@ -234344,9 +234466,9 @@ async function loadConfig(configPath) {
234344
234466
  config[key] = value;
234345
234467
  }
234346
234468
  });
234347
- logger14.info({ mergedConfig: maskSensitiveConfig(config) }, `Config loaded from file`);
234469
+ logger15.info({ mergedConfig: maskSensitiveConfig(config) }, `Config loaded from file`);
234348
234470
  } else {
234349
- logger14.info(
234471
+ logger15.info(
234350
234472
  { config: maskSensitiveConfig(config) },
234351
234473
  `Using default config (no config file found)`
234352
234474
  );
@@ -234398,14 +234520,14 @@ Please add agentsRunApiUrl to your configuration file`
234398
234520
  sources
234399
234521
  };
234400
234522
  }
234401
- var logger14;
234523
+ var logger15;
234402
234524
  var init_config = __esm({
234403
234525
  "src/utils/config.ts"() {
234404
234526
  "use strict";
234405
234527
  init_esm_shims();
234406
234528
  init_src();
234407
234529
  init_tsx_loader();
234408
- logger14 = getLogger("config");
234530
+ logger15 = getLogger("config");
234409
234531
  }
234410
234532
  });
234411
234533
 
@@ -234741,6 +234863,234 @@ var init_variable_name_registry = __esm({
234741
234863
  }
234742
234864
  });
234743
234865
 
234866
+ // src/utils/project-loader.ts
234867
+ var project_loader_exports = {};
234868
+ __export(project_loader_exports, {
234869
+ loadProject: () => loadProject
234870
+ });
234871
+ import { existsSync as existsSync7 } from "fs";
234872
+ import { join as join7 } from "path";
234873
+ async function loadProject(projectDir) {
234874
+ const indexPath = join7(projectDir, "index.ts");
234875
+ if (!existsSync7(indexPath)) {
234876
+ throw new Error(`index.ts not found in project directory: ${projectDir}`);
234877
+ }
234878
+ const module = await importWithTypeScriptSupport(indexPath);
234879
+ const exports = Object.keys(module);
234880
+ for (const exportKey of exports) {
234881
+ const value = module[exportKey];
234882
+ if (value && typeof value === "object" && value.__type === "project") {
234883
+ return value;
234884
+ }
234885
+ }
234886
+ throw new Error(
234887
+ 'No project export found in index.ts. Expected an export with __type = "project"'
234888
+ );
234889
+ }
234890
+ var init_project_loader = __esm({
234891
+ "src/utils/project-loader.ts"() {
234892
+ "use strict";
234893
+ init_esm_shims();
234894
+ init_tsx_loader();
234895
+ }
234896
+ });
234897
+
234898
+ // src/utils/json-comparison.ts
234899
+ var json_comparison_exports = {};
234900
+ __export(json_comparison_exports, {
234901
+ compareProjectDefinitions: () => compareProjectDefinitions
234902
+ });
234903
+ function compareProjectDefinitions(original, generated) {
234904
+ const differences = [];
234905
+ const warnings = [];
234906
+ const comparePrimitive = (path4, a, b2) => {
234907
+ if (a === b2) return true;
234908
+ if (typeof a !== typeof b2) {
234909
+ differences.push(`Type mismatch at ${path4}: ${typeof a} vs ${typeof b2}`);
234910
+ return false;
234911
+ }
234912
+ if (a !== b2) {
234913
+ differences.push(`Value mismatch at ${path4}: "${a}" vs "${b2}"`);
234914
+ return false;
234915
+ }
234916
+ return true;
234917
+ };
234918
+ const compareArrays = (path4, a, b2) => {
234919
+ if (a.length !== b2.length) {
234920
+ differences.push(`Array length mismatch at ${path4}: ${a.length} vs ${b2.length}`);
234921
+ return false;
234922
+ }
234923
+ let allMatch = true;
234924
+ for (let i2 = 0; i2 < a.length; i2++) {
234925
+ if (!compareValues(`${path4}[${i2}]`, a[i2], b2[i2])) {
234926
+ allMatch = false;
234927
+ }
234928
+ }
234929
+ return allMatch;
234930
+ };
234931
+ const compareObjects = (path4, a, b2) => {
234932
+ const aKeys = Object.keys(a || {}).filter((k2) => !["createdAt", "updatedAt"].includes(k2));
234933
+ const bKeys = Object.keys(b2 || {}).filter((k2) => !["createdAt", "updatedAt"].includes(k2));
234934
+ const missingInB = aKeys.filter((k2) => !bKeys.includes(k2));
234935
+ const extraInB = bKeys.filter((k2) => !aKeys.includes(k2));
234936
+ if (missingInB.length > 0) {
234937
+ differences.push(`Missing keys in generated at ${path4}: ${missingInB.join(", ")}`);
234938
+ }
234939
+ if (extraInB.length > 0) {
234940
+ warnings.push(`Extra keys in generated at ${path4}: ${extraInB.join(", ")}`);
234941
+ }
234942
+ let allMatch = true;
234943
+ for (const key of aKeys) {
234944
+ if (bKeys.includes(key)) {
234945
+ if (!compareValues(`${path4}.${key}`, a[key], b2[key])) {
234946
+ allMatch = false;
234947
+ }
234948
+ }
234949
+ }
234950
+ return allMatch && missingInB.length === 0;
234951
+ };
234952
+ const compareValues = (path4, a, b2) => {
234953
+ if (a === null && b2 === null) return true;
234954
+ if (a === void 0 && b2 === void 0) return true;
234955
+ if ((a === null || a === void 0) !== (b2 === null || b2 === void 0)) {
234956
+ differences.push(`Null/undefined mismatch at ${path4}`);
234957
+ return false;
234958
+ }
234959
+ if (Array.isArray(a) && Array.isArray(b2)) {
234960
+ return compareArrays(path4, a, b2);
234961
+ }
234962
+ if (Array.isArray(a) !== Array.isArray(b2)) {
234963
+ differences.push(`Array type mismatch at ${path4}`);
234964
+ return false;
234965
+ }
234966
+ if (typeof a === "object" && typeof b2 === "object") {
234967
+ return compareObjects(path4, a, b2);
234968
+ }
234969
+ return comparePrimitive(path4, a, b2);
234970
+ };
234971
+ comparePrimitive("id", original.id, generated.id);
234972
+ comparePrimitive("name", original.name, generated.name);
234973
+ if (original.description || generated.description) {
234974
+ const origDesc = original.description || "";
234975
+ const genDesc = generated.description || "";
234976
+ if (origDesc !== genDesc) {
234977
+ comparePrimitive("description", origDesc, genDesc);
234978
+ }
234979
+ }
234980
+ if (original.models || generated.models) {
234981
+ compareValues("models", original.models, generated.models);
234982
+ }
234983
+ if (original.stopWhen || generated.stopWhen) {
234984
+ compareValues("stopWhen", original.stopWhen, generated.stopWhen);
234985
+ }
234986
+ const originalAgentIds = Object.keys(original.agents || {});
234987
+ const generatedAgentIds = Object.keys(generated.agents || {});
234988
+ if (originalAgentIds.length !== generatedAgentIds.length) {
234989
+ differences.push(
234990
+ `Agent count mismatch: ${originalAgentIds.length} vs ${generatedAgentIds.length}`
234991
+ );
234992
+ }
234993
+ for (const agentId of originalAgentIds) {
234994
+ if (!generatedAgentIds.includes(agentId)) {
234995
+ differences.push(`Missing agent in generated: ${agentId}`);
234996
+ } else {
234997
+ compareValues(
234998
+ `agents.${agentId}`,
234999
+ original.agents?.[agentId],
235000
+ generated.agents?.[agentId]
235001
+ );
235002
+ }
235003
+ }
235004
+ for (const agentId of generatedAgentIds) {
235005
+ if (!originalAgentIds.includes(agentId)) {
235006
+ warnings.push(`Extra agent in generated: ${agentId}`);
235007
+ }
235008
+ }
235009
+ const originalToolIds = Object.keys(original.tools || {});
235010
+ const generatedToolIds = Object.keys(generated.tools || {});
235011
+ if (originalToolIds.length !== generatedToolIds.length) {
235012
+ differences.push(`Tool count mismatch: ${originalToolIds.length} vs ${generatedToolIds.length}`);
235013
+ }
235014
+ for (const toolId of originalToolIds) {
235015
+ if (!generatedToolIds.includes(toolId)) {
235016
+ differences.push(`Missing tool in generated: ${toolId}`);
235017
+ } else {
235018
+ compareValues(`tools.${toolId}`, original.tools?.[toolId], generated.tools?.[toolId]);
235019
+ }
235020
+ }
235021
+ if (original.functions || generated.functions) {
235022
+ const originalFunctionIds = Object.keys(original.functions || {});
235023
+ const generatedFunctionIds = Object.keys(generated.functions || {});
235024
+ for (const functionId of originalFunctionIds) {
235025
+ if (!generatedFunctionIds.includes(functionId)) {
235026
+ differences.push(`Missing function in generated: ${functionId}`);
235027
+ } else {
235028
+ compareValues(
235029
+ `functions.${functionId}`,
235030
+ original.functions?.[functionId],
235031
+ generated.functions?.[functionId]
235032
+ );
235033
+ }
235034
+ }
235035
+ }
235036
+ if (original.dataComponents || generated.dataComponents) {
235037
+ const originalComponentIds = Object.keys(original.dataComponents || {});
235038
+ const generatedComponentIds = Object.keys(generated.dataComponents || {});
235039
+ for (const componentId of originalComponentIds) {
235040
+ if (!generatedComponentIds.includes(componentId)) {
235041
+ differences.push(`Missing data component in generated: ${componentId}`);
235042
+ } else {
235043
+ compareValues(
235044
+ `dataComponents.${componentId}`,
235045
+ original.dataComponents?.[componentId],
235046
+ generated.dataComponents?.[componentId]
235047
+ );
235048
+ }
235049
+ }
235050
+ }
235051
+ if (original.artifactComponents || generated.artifactComponents) {
235052
+ const originalArtifactIds = Object.keys(original.artifactComponents || {});
235053
+ const generatedArtifactIds = Object.keys(generated.artifactComponents || {});
235054
+ for (const artifactId of originalArtifactIds) {
235055
+ if (!generatedArtifactIds.includes(artifactId)) {
235056
+ differences.push(`Missing artifact component in generated: ${artifactId}`);
235057
+ } else {
235058
+ compareValues(
235059
+ `artifactComponents.${artifactId}`,
235060
+ original.artifactComponents?.[artifactId],
235061
+ generated.artifactComponents?.[artifactId]
235062
+ );
235063
+ }
235064
+ }
235065
+ }
235066
+ if (original.credentialReferences || generated.credentialReferences) {
235067
+ const originalCredIds = Object.keys(original.credentialReferences || {});
235068
+ const generatedCredIds = Object.keys(generated.credentialReferences || {});
235069
+ for (const credId of originalCredIds) {
235070
+ if (!generatedCredIds.includes(credId)) {
235071
+ differences.push(`Missing credential reference in generated: ${credId}`);
235072
+ } else {
235073
+ const origCred = { ...original.credentialReferences?.[credId] || {} };
235074
+ const genCred = { ...generated.credentialReferences?.[credId] || {} };
235075
+ delete origCred.usedBy;
235076
+ delete genCred.usedBy;
235077
+ compareValues(`credentialReferences.${credId}`, origCred, genCred);
235078
+ }
235079
+ }
235080
+ }
235081
+ return {
235082
+ matches: differences.length === 0,
235083
+ differences,
235084
+ warnings
235085
+ };
235086
+ }
235087
+ var init_json_comparison = __esm({
235088
+ "src/utils/json-comparison.ts"() {
235089
+ "use strict";
235090
+ init_esm_shims();
235091
+ }
235092
+ });
235093
+
234744
235094
  // src/commands/pull.placeholder-system.ts
234745
235095
  import { randomBytes as randomBytes2 } from "crypto";
234746
235096
  import { jsonSchemaToZod } from "json-schema-to-zod";
@@ -234955,7 +235305,7 @@ __export(pull_llm_generate_exports, {
234955
235305
  });
234956
235306
  import { readFileSync as readFileSync3, writeFileSync as writeFileSync3 } from "fs";
234957
235307
  import { createRequire as createRequire2 } from "module";
234958
- import { join as join7 } from "path";
235308
+ import { join as join8 } from "path";
234959
235309
  import { anthropic, createAnthropic } from "@ai-sdk/anthropic";
234960
235310
  import { google } from "@ai-sdk/google";
234961
235311
  import { createOpenAI, openai } from "@ai-sdk/openai";
@@ -234963,8 +235313,8 @@ import { generateText } from "ai";
234963
235313
  function getTypeDefinitions() {
234964
235314
  try {
234965
235315
  const sdkPackagePath = require3.resolve("@inkeep/agents-sdk/package.json");
234966
- const sdkPackageDir = join7(sdkPackagePath, "..");
234967
- const sdkDtsPath = join7(sdkPackageDir, "dist/index.d.ts");
235316
+ const sdkPackageDir = join8(sdkPackagePath, "..");
235317
+ const sdkDtsPath = join8(sdkPackageDir, "dist/index.d.ts");
234968
235318
  const dtsContent = readFileSync3(sdkDtsPath, "utf-8");
234969
235319
  return `
234970
235320
  TYPESCRIPT TYPE DEFINITIONS (from @inkeep/agents-sdk):
@@ -235834,7 +236184,7 @@ Generate ONLY the TypeScript code without any markdown or explanations.`;
235834
236184
  }
235835
236185
  function generateEnvironmentFileTemplate(environmentsDir, environment, credentials) {
235836
236186
  const { writeFileSync: writeFileSync7 } = require3("node:fs");
235837
- const { join: join14 } = require3("node:path");
236187
+ const { join: join15 } = require3("node:path");
235838
236188
  let credentialsCode = "";
235839
236189
  const hasCredentials = credentials && Object.keys(credentials).length > 0;
235840
236190
  if (hasCredentials) {
@@ -235871,15 +236221,15 @@ export const ${environment} = registerEnvironmentSettings({
235871
236221
  credentials: {${credentialsCode}}
235872
236222
  });
235873
236223
  `;
235874
- writeFileSync7(join14(environmentsDir, `${environment}.env.ts`), envContent);
236224
+ writeFileSync7(join15(environmentsDir, `${environment}.env.ts`), envContent);
235875
236225
  updateEnvironmentIndexTemplate(environmentsDir, environment);
235876
236226
  }
235877
236227
  function updateEnvironmentIndexTemplate(environmentsDir, newEnvironment) {
235878
- const { writeFileSync: writeFileSync7, existsSync: existsSync12, readFileSync: readFileSync8 } = require3("node:fs");
235879
- const { join: join14 } = require3("node:path");
235880
- const indexPath = join14(environmentsDir, "index.ts");
236228
+ const { writeFileSync: writeFileSync7, existsSync: existsSync13, readFileSync: readFileSync8 } = require3("node:fs");
236229
+ const { join: join15 } = require3("node:path");
236230
+ const indexPath = join15(environmentsDir, "index.ts");
235881
236231
  const existingEnvironments = [];
235882
- if (existsSync12(indexPath)) {
236232
+ if (existsSync13(indexPath)) {
235883
236233
  const existingContent = readFileSync8(indexPath, "utf-8");
235884
236234
  const importRegex = /import\s+{\s*(\w+)\s*}\s+from\s+['"]\.\/([\w-]+)\.env['"];?/g;
235885
236235
  let match2;
@@ -235943,15 +236293,15 @@ export const ${environment} = registerEnvironmentSettings({
235943
236293
  credentials: {${credentialsCode}}
235944
236294
  });
235945
236295
  `;
235946
- writeFileSync3(join7(environmentsDir, `${environment}.env.ts`), envContent);
236296
+ writeFileSync3(join8(environmentsDir, `${environment}.env.ts`), envContent);
235947
236297
  await updateEnvironmentIndex(environmentsDir, environment);
235948
236298
  }
235949
236299
  async function updateEnvironmentIndex(environmentsDir, environment) {
235950
- const indexPath = join7(environmentsDir, "index.ts");
235951
- const { readFileSync: readFileSync8, existsSync: existsSync12 } = await import("fs");
236300
+ const indexPath = join8(environmentsDir, "index.ts");
236301
+ const { readFileSync: readFileSync8, existsSync: existsSync13 } = await import("fs");
235952
236302
  const existingEnvironments = [];
235953
236303
  let existingContent = "";
235954
- if (existsSync12(indexPath)) {
236304
+ if (existsSync13(indexPath)) {
235955
236305
  existingContent = readFileSync8(indexPath, "utf-8");
235956
236306
  const importRegex = /import\s+{\s*(\w+)\s*}\s+from\s+['"]\.\/([\w-]+)\.env['"];?/g;
235957
236307
  let match2;
@@ -236596,11 +236946,11 @@ var pattern_analyzer_exports = {};
236596
236946
  __export(pattern_analyzer_exports, {
236597
236947
  analyzeExistingPatterns: () => analyzeExistingPatterns
236598
236948
  });
236599
- import { existsSync as existsSync7, readdirSync as readdirSync2, readFileSync as readFileSync4, statSync } from "fs";
236600
- import { join as join8 } from "path";
236949
+ import { existsSync as existsSync8, readdirSync as readdirSync2, readFileSync as readFileSync4, statSync } from "fs";
236950
+ import { join as join9 } from "path";
236601
236951
  async function analyzeExistingPatterns(projectDir) {
236602
- const indexPath = join8(projectDir, "index.ts");
236603
- if (!existsSync7(indexPath)) {
236952
+ const indexPath = join9(projectDir, "index.ts");
236953
+ if (!existsSync8(indexPath)) {
236604
236954
  return null;
236605
236955
  }
236606
236956
  const fileStructure = analyzeFileStructure(projectDir);
@@ -236622,17 +236972,17 @@ async function analyzeExistingPatterns(projectDir) {
236622
236972
  };
236623
236973
  }
236624
236974
  function analyzeFileStructure(projectDir) {
236625
- const hasAgentsDirectory = existsSync7(join8(projectDir, "agents"));
236626
- const hasToolsDirectory = existsSync7(join8(projectDir, "tools"));
236627
- const hasDataComponentsDirectory = existsSync7(join8(projectDir, "data-components"));
236628
- const hasArtifactComponentsDirectory = existsSync7(join8(projectDir, "artifact-components"));
236629
- const hasEnvironmentsDirectory = existsSync7(join8(projectDir, "environments"));
236630
- const hasExternalAgentsDirectory = existsSync7(join8(projectDir, "external-agents"));
236975
+ const hasAgentsDirectory = existsSync8(join9(projectDir, "agents"));
236976
+ const hasToolsDirectory = existsSync8(join9(projectDir, "tools"));
236977
+ const hasDataComponentsDirectory = existsSync8(join9(projectDir, "data-components"));
236978
+ const hasArtifactComponentsDirectory = existsSync8(join9(projectDir, "artifact-components"));
236979
+ const hasEnvironmentsDirectory = existsSync8(join9(projectDir, "environments"));
236980
+ const hasExternalAgentsDirectory = existsSync8(join9(projectDir, "external-agents"));
236631
236981
  let toolsLocation = "unknown";
236632
236982
  if (hasToolsDirectory) {
236633
236983
  toolsLocation = "separate";
236634
236984
  } else if (hasAgentsDirectory) {
236635
- const agentFiles = getFilesInDirectory(join8(projectDir, "agents"), ".ts");
236985
+ const agentFiles = getFilesInDirectory(join9(projectDir, "agents"), ".ts");
236636
236986
  const hasInlineTools = agentFiles.some((file) => {
236637
236987
  const content = readFileSync4(file, "utf-8");
236638
236988
  return content.includes("functionTool(");
@@ -236642,8 +236992,8 @@ function analyzeFileStructure(projectDir) {
236642
236992
  const agentsLocation = hasAgentsDirectory ? "flat" : "unknown";
236643
236993
  const allFiles = [
236644
236994
  ...getFilesInDirectory(projectDir, ".ts"),
236645
- ...hasAgentsDirectory ? getFilesInDirectory(join8(projectDir, "agents"), ".ts") : [],
236646
- ...hasToolsDirectory ? getFilesInDirectory(join8(projectDir, "tools"), ".ts") : []
236995
+ ...hasAgentsDirectory ? getFilesInDirectory(join9(projectDir, "agents"), ".ts") : [],
236996
+ ...hasToolsDirectory ? getFilesInDirectory(join9(projectDir, "tools"), ".ts") : []
236647
236997
  ];
236648
236998
  const preferredFileNaming = detectFileNamingConvention(allFiles);
236649
236999
  return {
@@ -236689,7 +237039,7 @@ function collectCodeExamples(projectDir, fileStructure) {
236689
237039
  mappings: []
236690
237040
  };
236691
237041
  if (fileStructure.hasAgentsDirectory) {
236692
- const agentDir = join8(projectDir, "agents");
237042
+ const agentDir = join9(projectDir, "agents");
236693
237043
  const agentFiles = getFilesInDirectory(agentDir, ".ts");
236694
237044
  for (const file of agentFiles.slice(0, 3)) {
236695
237045
  const content = readFileSync4(file, "utf-8");
@@ -236701,7 +237051,7 @@ function collectCodeExamples(projectDir, fileStructure) {
236701
237051
  }
236702
237052
  }
236703
237053
  if (fileStructure.hasToolsDirectory) {
236704
- const toolsDir = join8(projectDir, "tools");
237054
+ const toolsDir = join9(projectDir, "tools");
236705
237055
  const toolFiles = getFilesInDirectory(toolsDir, ".ts");
236706
237056
  for (const file of toolFiles.slice(0, 3)) {
236707
237057
  const content = readFileSync4(file, "utf-8");
@@ -236710,8 +237060,8 @@ function collectCodeExamples(projectDir, fileStructure) {
236710
237060
  examples.mappings.push(...mappings);
236711
237061
  }
236712
237062
  }
236713
- const indexPath = join8(projectDir, "index.ts");
236714
- if (existsSync7(indexPath)) {
237063
+ const indexPath = join9(projectDir, "index.ts");
237064
+ if (existsSync8(indexPath)) {
236715
237065
  const content = readFileSync4(indexPath, "utf-8");
236716
237066
  const imports = extractImports(content);
236717
237067
  examples.imports.push(...imports);
@@ -236833,22 +237183,22 @@ function mostCommon(arr) {
236833
237183
  }
236834
237184
  let maxCount = 0;
236835
237185
  let mostCommonItem = null;
236836
- for (const [item, count17] of counts.entries()) {
236837
- if (count17 > maxCount) {
236838
- maxCount = count17;
237186
+ for (const [item, count18] of counts.entries()) {
237187
+ if (count18 > maxCount) {
237188
+ maxCount = count18;
236839
237189
  mostCommonItem = item;
236840
237190
  }
236841
237191
  }
236842
237192
  return mostCommonItem;
236843
237193
  }
236844
237194
  function getFilesInDirectory(dir, extension) {
236845
- if (!existsSync7(dir)) {
237195
+ if (!existsSync8(dir)) {
236846
237196
  return [];
236847
237197
  }
236848
237198
  const files = [];
236849
237199
  const entries = readdirSync2(dir);
236850
237200
  for (const entry of entries) {
236851
- const fullPath = join8(dir, entry);
237201
+ const fullPath = join9(dir, entry);
236852
237202
  const stat = statSync(fullPath);
236853
237203
  if (stat.isDirectory()) {
236854
237204
  files.push(...getFilesInDirectory(fullPath, extension));
@@ -237898,11 +238248,11 @@ __export(plan_storage_exports, {
237898
238248
  planExists: () => planExists,
237899
238249
  savePlan: () => savePlan
237900
238250
  });
237901
- import { existsSync as existsSync8, mkdirSync, readFileSync as readFileSync5, writeFileSync as writeFileSync5 } from "fs";
237902
- import { join as join9 } from "path";
238251
+ import { existsSync as existsSync9, mkdirSync, readFileSync as readFileSync5, writeFileSync as writeFileSync5 } from "fs";
238252
+ import { join as join10 } from "path";
237903
238253
  function savePlan(projectRoot, plan) {
237904
- const inkeepDir = join9(projectRoot, ".inkeep");
237905
- if (!existsSync8(inkeepDir)) {
238254
+ const inkeepDir = join10(projectRoot, ".inkeep");
238255
+ if (!existsSync9(inkeepDir)) {
237906
238256
  mkdirSync(inkeepDir, { recursive: true });
237907
238257
  }
237908
238258
  const gitCommit = getGitCommit(projectRoot);
@@ -237915,15 +238265,15 @@ function savePlan(projectRoot, plan) {
237915
238265
  },
237916
238266
  plan
237917
238267
  };
237918
- const planPath = join9(inkeepDir, "generation-plan.json");
238268
+ const planPath = join10(inkeepDir, "generation-plan.json");
237919
238269
  writeFileSync5(planPath, JSON.stringify(storedPlan, null, 2));
237920
- const backupPath = join9(inkeepDir, `generation-plan-${Date.now()}.json`);
238270
+ const backupPath = join10(inkeepDir, `generation-plan-${Date.now()}.json`);
237921
238271
  writeFileSync5(backupPath, JSON.stringify(storedPlan, null, 2));
237922
238272
  cleanupOldBackups(inkeepDir);
237923
238273
  }
237924
238274
  function loadPlan(projectRoot) {
237925
- const planPath = join9(projectRoot, ".inkeep", "generation-plan.json");
237926
- if (!existsSync8(planPath)) {
238275
+ const planPath = join10(projectRoot, ".inkeep", "generation-plan.json");
238276
+ if (!existsSync9(planPath)) {
237927
238277
  return null;
237928
238278
  }
237929
238279
  try {
@@ -237935,8 +238285,8 @@ function loadPlan(projectRoot) {
237935
238285
  }
237936
238286
  }
237937
238287
  function planExists(projectRoot) {
237938
- const planPath = join9(projectRoot, ".inkeep", "generation-plan.json");
237939
- return existsSync8(planPath);
238288
+ const planPath = join10(projectRoot, ".inkeep", "generation-plan.json");
238289
+ return existsSync9(planPath);
237940
238290
  }
237941
238291
  function getGitCommit(projectRoot) {
237942
238292
  try {
@@ -237955,8 +238305,8 @@ function cleanupOldBackups(inkeepDir) {
237955
238305
  const { readdirSync: readdirSync3, unlinkSync, statSync: statSync2 } = __require("fs");
237956
238306
  const files = readdirSync3(inkeepDir).filter((f) => f.startsWith("generation-plan-") && f.endsWith(".json")).map((f) => ({
237957
238307
  name: f,
237958
- path: join9(inkeepDir, f),
237959
- mtime: statSync2(join9(inkeepDir, f)).mtime.getTime()
238308
+ path: join10(inkeepDir, f),
238309
+ mtime: statSync2(join10(inkeepDir, f)).mtime.getTime()
237960
238310
  })).sort((a, b2) => b2.mtime - a.mtime);
237961
238311
  for (let i2 = 5; i2 < files.length; i2++) {
237962
238312
  unlinkSync(files[i2].path);
@@ -238065,9 +238415,9 @@ function displayPlanDiff(diff) {
238065
238415
  }
238066
238416
  }
238067
238417
  function ensureGitignore(projectRoot) {
238068
- const gitignorePath = join9(projectRoot, ".gitignore");
238418
+ const gitignorePath = join10(projectRoot, ".gitignore");
238069
238419
  let content = "";
238070
- if (existsSync8(gitignorePath)) {
238420
+ if (existsSync9(gitignorePath)) {
238071
238421
  content = readFileSync5(gitignorePath, "utf-8");
238072
238422
  }
238073
238423
  if (content.includes(".inkeep")) {
@@ -238088,7 +238438,7 @@ init_esm_shims();
238088
238438
  init_env2();
238089
238439
  init_instrumentation();
238090
238440
  import { readFileSync as readFileSync7 } from "fs";
238091
- import { dirname as dirname6, join as join13 } from "path";
238441
+ import { dirname as dirname6, join as join14 } from "path";
238092
238442
  import { fileURLToPath as fileURLToPath3 } from "url";
238093
238443
  import { Command } from "commander";
238094
238444
 
@@ -239202,8 +239552,8 @@ ${table.toString()}`);
239202
239552
 
239203
239553
  // src/commands/pull.ts
239204
239554
  init_esm_shims();
239205
- import { existsSync as existsSync9, mkdirSync as mkdirSync2, readFileSync as readFileSync6, writeFileSync as writeFileSync6 } from "fs";
239206
- import { dirname as dirname5, join as join10, resolve as resolve4 } from "path";
239555
+ import { existsSync as existsSync10, mkdirSync as mkdirSync2, readFileSync as readFileSync6, writeFileSync as writeFileSync6 } from "fs";
239556
+ import { dirname as dirname5, join as join11, resolve as resolve4 } from "path";
239207
239557
  import * as p7 from "@clack/prompts";
239208
239558
  import chalk9 from "chalk";
239209
239559
  init_variable_name_registry();
@@ -239333,14 +239683,14 @@ async function findProjectDirectory(projectId, configPath) {
239333
239683
  // src/commands/pull.ts
239334
239684
  init_tsx_loader();
239335
239685
  async function detectCurrentProject(debug = false) {
239336
- const indexPath = join10(process.cwd(), "index.ts");
239686
+ const indexPath = join11(process.cwd(), "index.ts");
239337
239687
  if (debug) {
239338
239688
  console.log(chalk9.gray(`
239339
239689
  [DEBUG] Detecting project in current directory...`));
239340
239690
  console.log(chalk9.gray(` \u2022 Current directory: ${process.cwd()}`));
239341
239691
  console.log(chalk9.gray(` \u2022 Looking for: ${indexPath}`));
239342
239692
  }
239343
- if (!existsSync9(indexPath)) {
239693
+ if (!existsSync10(indexPath)) {
239344
239694
  if (debug) {
239345
239695
  console.log(chalk9.gray(` \u2022 index.ts not found`));
239346
239696
  }
@@ -239405,8 +239755,8 @@ async function verifyGeneratedFiles(projectDir, originalProjectData, debug = fal
239405
239755
  const errors = [];
239406
239756
  const warnings = [];
239407
239757
  try {
239408
- const indexPath = join10(projectDir, "index.ts");
239409
- if (!existsSync9(indexPath)) {
239758
+ const indexPath = join11(projectDir, "index.ts");
239759
+ if (!existsSync10(indexPath)) {
239410
239760
  errors.push("Generated index.ts file not found");
239411
239761
  return { success: false, errors, warnings };
239412
239762
  }
@@ -239429,35 +239779,35 @@ async function verifyGeneratedFiles(projectDir, originalProjectData, debug = fal
239429
239779
  } else {
239430
239780
  warnings.push("Could not extract project ID from index.ts");
239431
239781
  }
239432
- const agentsDir = join10(projectDir, "agents");
239782
+ const agentsDir = join11(projectDir, "agents");
239433
239783
  const expectedAgents = Object.keys(originalProjectData.agents || {});
239434
239784
  for (const agentId of expectedAgents) {
239435
239785
  const kebabCaseId = agentId.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
239436
- const agentPath = join10(agentsDir, `${kebabCaseId}.ts`);
239437
- if (!existsSync9(agentPath)) {
239786
+ const agentPath = join11(agentsDir, `${kebabCaseId}.ts`);
239787
+ if (!existsSync10(agentPath)) {
239438
239788
  errors.push(`Agent file not found: agents/${kebabCaseId}.ts`);
239439
239789
  } else if (debug) {
239440
239790
  console.log(chalk9.gray(` \u2713 Agent file exists: agents/${kebabCaseId}.ts`));
239441
239791
  }
239442
239792
  }
239443
- const toolsDir = join10(projectDir, "tools");
239793
+ const toolsDir = join11(projectDir, "tools");
239444
239794
  const expectedTools = Object.entries(originalProjectData.tools || {});
239445
239795
  const filenameGenerator = new VariableNameGenerator(DEFAULT_NAMING_CONVENTIONS);
239446
239796
  for (const [toolId, toolData] of expectedTools) {
239447
239797
  const fileName = filenameGenerator.generateFileName(toolId, "tool", toolData);
239448
- const toolPath = join10(toolsDir, `${fileName}.ts`);
239449
- if (!existsSync9(toolPath)) {
239798
+ const toolPath = join11(toolsDir, `${fileName}.ts`);
239799
+ if (!existsSync10(toolPath)) {
239450
239800
  errors.push(`Tool file not found: tools/${fileName}.ts`);
239451
239801
  } else if (debug) {
239452
239802
  console.log(chalk9.gray(` \u2713 Tool file exists: tools/${fileName}.ts`));
239453
239803
  }
239454
239804
  }
239455
- const dataComponentsDir = join10(projectDir, "data-components");
239805
+ const dataComponentsDir = join11(projectDir, "data-components");
239456
239806
  const expectedDataComponents = Object.keys(originalProjectData.dataComponents || {});
239457
239807
  for (const componentId of expectedDataComponents) {
239458
239808
  const kebabCaseId = componentId.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
239459
- const componentPath = join10(dataComponentsDir, `${kebabCaseId}.ts`);
239460
- if (!existsSync9(componentPath)) {
239809
+ const componentPath = join11(dataComponentsDir, `${kebabCaseId}.ts`);
239810
+ if (!existsSync10(componentPath)) {
239461
239811
  errors.push(`Data component file not found: data-components/${kebabCaseId}.ts`);
239462
239812
  } else if (debug) {
239463
239813
  console.log(
@@ -239465,17 +239815,17 @@ async function verifyGeneratedFiles(projectDir, originalProjectData, debug = fal
239465
239815
  );
239466
239816
  }
239467
239817
  }
239468
- const environmentsDir = join10(projectDir, "environments");
239818
+ const environmentsDir = join11(projectDir, "environments");
239469
239819
  const hasCredentials = Object.keys(originalProjectData.credentialReferences || {}).length > 0;
239470
- if (!existsSync9(environmentsDir)) {
239820
+ if (!existsSync10(environmentsDir)) {
239471
239821
  if (hasCredentials) {
239472
239822
  errors.push("Environments directory not found (expected with credentials)");
239473
239823
  } else {
239474
239824
  warnings.push("Environments directory not found (no credentials defined)");
239475
239825
  }
239476
239826
  } else {
239477
- const envIndexPath = join10(environmentsDir, "index.ts");
239478
- if (!existsSync9(envIndexPath)) {
239827
+ const envIndexPath = join11(environmentsDir, "index.ts");
239828
+ if (!existsSync10(envIndexPath)) {
239479
239829
  if (hasCredentials) {
239480
239830
  errors.push("Environment index.ts not found (expected with credentials)");
239481
239831
  } else {
@@ -239487,7 +239837,7 @@ async function verifyGeneratedFiles(projectDir, originalProjectData, debug = fal
239487
239837
  }
239488
239838
  if (debug) {
239489
239839
  console.log(chalk9.gray("\n\u{1F50D} Verification Summary:"));
239490
- console.log(chalk9.gray(` \u2022 index.ts: ${existsSync9(indexPath) ? "\u2713" : "\u2717"}`));
239840
+ console.log(chalk9.gray(` \u2022 index.ts: ${existsSync10(indexPath) ? "\u2713" : "\u2717"}`));
239491
239841
  console.log(
239492
239842
  chalk9.gray(` \u2022 Agent files: ${expectedAgents.length}/${expectedAgents.length} found`)
239493
239843
  );
@@ -239506,9 +239856,87 @@ async function verifyGeneratedFiles(projectDir, originalProjectData, debug = fal
239506
239856
  return { success: false, errors, warnings };
239507
239857
  }
239508
239858
  }
239859
+ async function roundTripValidation(projectDir, originalProjectData, config, debug = false) {
239860
+ const errors = [];
239861
+ const warnings = [];
239862
+ try {
239863
+ if (debug) {
239864
+ console.log(chalk9.gray("\n[DEBUG] Starting round-trip validation..."));
239865
+ console.log(chalk9.gray(` \u2022 Loading project from: ${projectDir}`));
239866
+ }
239867
+ const { loadProject: loadProject2 } = await Promise.resolve().then(() => (init_project_loader(), project_loader_exports));
239868
+ const { compareProjectDefinitions: compareProjectDefinitions2 } = await Promise.resolve().then(() => (init_json_comparison(), json_comparison_exports));
239869
+ const originalTenantId = process.env.INKEEP_TENANT_ID;
239870
+ const originalApiUrl = process.env.INKEEP_API_URL;
239871
+ process.env.INKEEP_TENANT_ID = config.tenantId;
239872
+ process.env.INKEEP_API_URL = config.agentsManageApiUrl;
239873
+ let project;
239874
+ try {
239875
+ project = await loadProject2(projectDir);
239876
+ if (debug) {
239877
+ console.log(chalk9.gray(` \u2022 Project loaded successfully: ${project.getId()}`));
239878
+ }
239879
+ } catch (loadError) {
239880
+ errors.push(`Failed to load generated project: ${loadError.message}`);
239881
+ return { success: false, errors, warnings };
239882
+ } finally {
239883
+ if (originalTenantId !== void 0) {
239884
+ process.env.INKEEP_TENANT_ID = originalTenantId;
239885
+ } else {
239886
+ delete process.env.INKEEP_TENANT_ID;
239887
+ }
239888
+ if (originalApiUrl !== void 0) {
239889
+ process.env.INKEEP_API_URL = originalApiUrl;
239890
+ } else {
239891
+ delete process.env.INKEEP_API_URL;
239892
+ }
239893
+ }
239894
+ if (typeof project.setConfig === "function") {
239895
+ project.setConfig(
239896
+ config.tenantId,
239897
+ config.agentsManageApiUrl,
239898
+ void 0,
239899
+ // models - come from project definition
239900
+ config.agentsManageApiKey
239901
+ );
239902
+ }
239903
+ let generatedDefinition;
239904
+ try {
239905
+ generatedDefinition = await project.getFullDefinition();
239906
+ if (debug) {
239907
+ console.log(chalk9.gray(` \u2022 Generated definition serialized successfully`));
239908
+ console.log(chalk9.gray(` - Agents: ${Object.keys(generatedDefinition.agents || {}).length}`));
239909
+ console.log(chalk9.gray(` - Tools: ${Object.keys(generatedDefinition.tools || {}).length}`));
239910
+ }
239911
+ } catch (serializeError) {
239912
+ errors.push(`Failed to serialize generated project: ${serializeError.message}`);
239913
+ return { success: false, errors, warnings };
239914
+ }
239915
+ const comparisonResult = compareProjectDefinitions2(originalProjectData, generatedDefinition);
239916
+ if (debug) {
239917
+ console.log(chalk9.gray(` \u2022 Comparison complete:`));
239918
+ console.log(chalk9.gray(` - Matches: ${comparisonResult.matches}`));
239919
+ console.log(chalk9.gray(` - Differences: ${comparisonResult.differences.length}`));
239920
+ console.log(chalk9.gray(` - Warnings: ${comparisonResult.warnings.length}`));
239921
+ }
239922
+ errors.push(...comparisonResult.differences);
239923
+ warnings.push(...comparisonResult.warnings);
239924
+ return {
239925
+ success: comparisonResult.matches && errors.length === 0,
239926
+ errors,
239927
+ warnings
239928
+ };
239929
+ } catch (error) {
239930
+ errors.push(`Round-trip validation failed: ${error.message}`);
239931
+ if (debug) {
239932
+ console.log(chalk9.red(`[DEBUG] Round-trip validation error: ${error.stack}`));
239933
+ }
239934
+ return { success: false, errors, warnings };
239935
+ }
239936
+ }
239509
239937
  async function loadProjectConfig(projectDir, configPathOverride) {
239510
- const configPath = configPathOverride ? resolve4(process.cwd(), configPathOverride) : join10(projectDir, "inkeep.config.ts");
239511
- if (!existsSync9(configPath)) {
239938
+ const configPath = configPathOverride ? resolve4(process.cwd(), configPathOverride) : join11(projectDir, "inkeep.config.ts");
239939
+ if (!existsSync10(configPath)) {
239512
239940
  throw new Error(`Configuration file not found: ${configPath}`);
239513
239941
  }
239514
239942
  try {
@@ -239533,7 +239961,7 @@ async function loadProjectConfig(projectDir, configPathOverride) {
239533
239961
  }
239534
239962
  }
239535
239963
  function ensureDirectoryExists(dirPath) {
239536
- if (!existsSync9(dirPath)) {
239964
+ if (!existsSync10(dirPath)) {
239537
239965
  mkdirSync2(dirPath, { recursive: true });
239538
239966
  }
239539
239967
  }
@@ -239543,15 +239971,15 @@ function createProjectStructure(projectDir, projectId, useCurrentDirectory = fal
239543
239971
  projectRoot = projectDir;
239544
239972
  } else {
239545
239973
  const dirName = projectDir.split("/").pop() || projectDir;
239546
- projectRoot = dirName === projectId ? projectDir : join10(projectDir, projectId);
239547
- }
239548
- const agentsDir = join10(projectRoot, "agents");
239549
- const toolsDir = join10(projectRoot, "tools");
239550
- const dataComponentsDir = join10(projectRoot, "data-components");
239551
- const artifactComponentsDir = join10(projectRoot, "artifact-components");
239552
- const statusComponentsDir = join10(projectRoot, "status-components");
239553
- const environmentsDir = join10(projectRoot, "environments");
239554
- const externalAgentsDir = join10(projectRoot, "external-agents");
239974
+ projectRoot = dirName === projectId ? projectDir : join11(projectDir, projectId);
239975
+ }
239976
+ const agentsDir = join11(projectRoot, "agents");
239977
+ const toolsDir = join11(projectRoot, "tools");
239978
+ const dataComponentsDir = join11(projectRoot, "data-components");
239979
+ const artifactComponentsDir = join11(projectRoot, "artifact-components");
239980
+ const statusComponentsDir = join11(projectRoot, "status-components");
239981
+ const environmentsDir = join11(projectRoot, "environments");
239982
+ const externalAgentsDir = join11(projectRoot, "external-agents");
239555
239983
  ensureDirectoryExists(projectRoot);
239556
239984
  ensureDirectoryExists(agentsDir);
239557
239985
  ensureDirectoryExists(toolsDir);
@@ -239610,7 +240038,7 @@ async function pullProjectCommand(options) {
239610
240038
  const searchDir = process.cwd();
239611
240039
  if (options.config) {
239612
240040
  const configPath = resolve4(process.cwd(), options.config);
239613
- if (existsSync9(configPath)) {
240041
+ if (existsSync10(configPath)) {
239614
240042
  try {
239615
240043
  config = await loadProjectConfig(dirname5(configPath), options.config);
239616
240044
  configFound = true;
@@ -239628,8 +240056,8 @@ async function pullProjectCommand(options) {
239628
240056
  }
239629
240057
  }
239630
240058
  if (!configFound) {
239631
- const currentConfigPath = join10(searchDir, "inkeep.config.ts");
239632
- if (existsSync9(currentConfigPath)) {
240059
+ const currentConfigPath = join11(searchDir, "inkeep.config.ts");
240060
+ if (existsSync10(currentConfigPath)) {
239633
240061
  try {
239634
240062
  config = await loadProjectConfig(searchDir);
239635
240063
  configFound = true;
@@ -239639,10 +240067,10 @@ async function pullProjectCommand(options) {
239639
240067
  }
239640
240068
  }
239641
240069
  if (!configFound) {
239642
- const parentConfigPath = join10(searchDir, "..", "inkeep.config.ts");
239643
- if (existsSync9(parentConfigPath)) {
240070
+ const parentConfigPath = join11(searchDir, "..", "inkeep.config.ts");
240071
+ if (existsSync10(parentConfigPath)) {
239644
240072
  try {
239645
- config = await loadProjectConfig(join10(searchDir, ".."));
240073
+ config = await loadProjectConfig(join11(searchDir, ".."));
239646
240074
  configFound = true;
239647
240075
  configLocation = parentConfigPath;
239648
240076
  } catch (_error) {
@@ -239672,7 +240100,7 @@ async function pullProjectCommand(options) {
239672
240100
  );
239673
240101
  console.log(chalk9.gray("Searched in:"));
239674
240102
  console.log(chalk9.gray(` \u2022 Current directory: ${searchDir}`));
239675
- console.log(chalk9.gray(` \u2022 Parent directory: ${join10(searchDir, "..")}`));
240103
+ console.log(chalk9.gray(` \u2022 Parent directory: ${join11(searchDir, "..")}`));
239676
240104
  console.log(chalk9.gray(` \u2022 Parent directories up to root`));
239677
240105
  process.exit(1);
239678
240106
  }
@@ -239686,8 +240114,8 @@ async function pullProjectCommand(options) {
239686
240114
  } else {
239687
240115
  const projectRoot = await findProjectDirectory();
239688
240116
  if (projectRoot) {
239689
- const srcPath = join10(projectRoot, "src");
239690
- baseDir = existsSync9(srcPath) ? srcPath : projectRoot;
240117
+ const srcPath = join11(projectRoot, "src");
240118
+ baseDir = existsSync10(srcPath) ? srcPath : projectRoot;
239691
240119
  } else {
239692
240120
  baseDir = process.cwd();
239693
240121
  }
@@ -239808,7 +240236,7 @@ async function pullProjectCommand(options) {
239808
240236
  for (const usage of usageInfo) {
239809
240237
  usageByType[usage.type] = (usageByType[usage.type] || 0) + 1;
239810
240238
  }
239811
- const usageSummary = Object.entries(usageByType).map(([type, count17]) => `${count17} ${type}${count17 > 1 ? "s" : ""}`).join(", ");
240239
+ const usageSummary = Object.entries(usageByType).map(([type, count18]) => `${count18} ${type}${count18 > 1 ? "s" : ""}`).join(", ");
239812
240240
  console.log(chalk9.gray(` Used by: ${usageSummary}`));
239813
240241
  }
239814
240242
  }
@@ -239822,7 +240250,7 @@ async function pullProjectCommand(options) {
239822
240250
  const dirs = createProjectStructure(baseDir, finalConfig.projectId, useCurrentDirectory);
239823
240251
  s2.stop("Project structure created");
239824
240252
  if (options.json) {
239825
- const jsonFilePath = join10(dirs.projectRoot, `${finalConfig.projectId}.json`);
240253
+ const jsonFilePath = join11(dirs.projectRoot, `${finalConfig.projectId}.json`);
239826
240254
  writeFileSync6(jsonFilePath, JSON.stringify(projectData, null, 2));
239827
240255
  s2.stop(`Project data saved to ${jsonFilePath}`);
239828
240256
  console.log(chalk9.green(`\u2705 JSON file created: ${jsonFilePath}`));
@@ -239943,11 +240371,63 @@ async function pullProjectCommand(options) {
239943
240371
  if (verificationResult.success) {
239944
240372
  s2.stop("Generated files verified successfully");
239945
240373
  if (options.debug && verificationResult.warnings.length > 0) {
239946
- console.log(chalk9.yellow("\n\u26A0\uFE0F Verification warnings:"));
240374
+ console.log(chalk9.yellow("\n\u26A0\uFE0F File verification warnings:"));
239947
240375
  verificationResult.warnings.forEach((warning) => {
239948
240376
  console.log(chalk9.gray(` \u2022 ${warning}`));
239949
240377
  });
239950
240378
  }
240379
+ s2.start("Performing round-trip validation...");
240380
+ try {
240381
+ const roundTripResult = await roundTripValidation(
240382
+ dirs.projectRoot,
240383
+ projectData,
240384
+ {
240385
+ tenantId: finalConfig.tenantId,
240386
+ agentsManageApiUrl: finalConfig.agentsManageApiUrl,
240387
+ agentsManageApiKey: finalConfig.agentsManageApiKey
240388
+ },
240389
+ options.debug || false
240390
+ );
240391
+ if (roundTripResult.success) {
240392
+ s2.stop("Round-trip validation passed - generated TS matches backend data");
240393
+ if (options.debug && roundTripResult.warnings.length > 0) {
240394
+ console.log(chalk9.yellow("\n\u26A0\uFE0F Round-trip validation warnings:"));
240395
+ roundTripResult.warnings.forEach((warning) => {
240396
+ console.log(chalk9.gray(` \u2022 ${warning}`));
240397
+ });
240398
+ }
240399
+ } else {
240400
+ s2.stop("Round-trip validation failed");
240401
+ console.error(chalk9.red("\n\u274C Round-trip validation errors:"));
240402
+ console.error(
240403
+ chalk9.gray(
240404
+ " The generated TypeScript does not serialize back to match the original backend data."
240405
+ )
240406
+ );
240407
+ roundTripResult.errors.forEach((error) => {
240408
+ console.error(chalk9.red(` \u2022 ${error}`));
240409
+ });
240410
+ if (roundTripResult.warnings.length > 0) {
240411
+ console.log(chalk9.yellow("\n\u26A0\uFE0F Round-trip validation warnings:"));
240412
+ roundTripResult.warnings.forEach((warning) => {
240413
+ console.log(chalk9.gray(` \u2022 ${warning}`));
240414
+ });
240415
+ }
240416
+ console.log(
240417
+ chalk9.yellow(
240418
+ "\n\u26A0\uFE0F This indicates an issue with LLM generation or schema mappings."
240419
+ )
240420
+ );
240421
+ console.log(chalk9.gray("The generated files may not work correctly with `inkeep push`."));
240422
+ }
240423
+ } catch (roundTripError) {
240424
+ s2.stop("Round-trip validation could not be completed");
240425
+ console.error(chalk9.yellow(`
240426
+ Round-trip validation error: ${roundTripError.message}`));
240427
+ if (options.debug && roundTripError.stack) {
240428
+ console.error(chalk9.gray(roundTripError.stack));
240429
+ }
240430
+ }
239951
240431
  } else {
239952
240432
  s2.stop("Generated files verification failed");
239953
240433
  console.error(chalk9.red("\n\u274C Verification errors:"));
@@ -239955,7 +240435,7 @@ async function pullProjectCommand(options) {
239955
240435
  console.error(chalk9.red(` \u2022 ${error}`));
239956
240436
  });
239957
240437
  if (verificationResult.warnings.length > 0) {
239958
- console.log(chalk9.yellow("\n\u26A0\uFE0F Verification warnings:"));
240438
+ console.log(chalk9.yellow("\n\u26A0\uFE0F File verification warnings:"));
239959
240439
  verificationResult.warnings.forEach((warning) => {
239960
240440
  console.log(chalk9.gray(` \u2022 ${warning}`));
239961
240441
  });
@@ -240012,20 +240492,20 @@ async function pullProjectCommand(options) {
240012
240492
  // src/commands/push.ts
240013
240493
  init_esm_shims();
240014
240494
  init_env2();
240015
- import { existsSync as existsSync11 } from "fs";
240016
- import { join as join12, resolve as resolve5 } from "path";
240495
+ import { existsSync as existsSync12 } from "fs";
240496
+ import { join as join13, resolve as resolve5 } from "path";
240017
240497
  import chalk10 from "chalk";
240018
240498
  import * as p8 from "@clack/prompts";
240019
240499
 
240020
240500
  // src/utils/environment-loader.ts
240021
240501
  init_esm_shims();
240022
240502
  init_tsx_loader();
240023
- import { existsSync as existsSync10 } from "fs";
240024
- import { join as join11 } from "path";
240503
+ import { existsSync as existsSync11 } from "fs";
240504
+ import { join as join12 } from "path";
240025
240505
  async function loadEnvironmentCredentials(projectDir, env3) {
240026
- const environmentsDir = join11(projectDir, "environments");
240027
- const envFilePath = join11(environmentsDir, `${env3}.env.ts`);
240028
- if (!existsSync10(envFilePath)) {
240506
+ const environmentsDir = join12(projectDir, "environments");
240507
+ const envFilePath = join12(environmentsDir, `${env3}.env.ts`);
240508
+ if (!existsSync11(envFilePath)) {
240029
240509
  throw new Error(
240030
240510
  `Environment file not found: ${envFilePath}
240031
240511
  Make sure you have a ${env3}.env.ts file in the environments directory.`
@@ -240051,24 +240531,7 @@ Make sure you have a ${env3}.env.ts file in the environments directory.`
240051
240531
  }
240052
240532
 
240053
240533
  // src/commands/push.ts
240054
- init_tsx_loader();
240055
- async function loadProject(projectDir) {
240056
- const indexPath = join12(projectDir, "index.ts");
240057
- if (!existsSync11(indexPath)) {
240058
- throw new Error(`index.ts not found in project directory: ${projectDir}`);
240059
- }
240060
- const module = await importWithTypeScriptSupport(indexPath);
240061
- const exports = Object.keys(module);
240062
- for (const exportKey of exports) {
240063
- const value = module[exportKey];
240064
- if (value && typeof value === "object" && value.__type === "project") {
240065
- return value;
240066
- }
240067
- }
240068
- throw new Error(
240069
- 'No project export found in index.ts. Expected an export with __type = "project"'
240070
- );
240071
- }
240534
+ init_project_loader();
240072
240535
  async function pushCommand(options) {
240073
240536
  performBackgroundVersionCheck();
240074
240537
  const { config } = await initializeCommand({
@@ -240083,13 +240546,13 @@ async function pushCommand(options) {
240083
240546
  let projectDir;
240084
240547
  if (options.project) {
240085
240548
  projectDir = resolve5(process.cwd(), options.project);
240086
- if (!existsSync11(join12(projectDir, "index.ts"))) {
240549
+ if (!existsSync12(join13(projectDir, "index.ts"))) {
240087
240550
  s2.stop(`No index.ts found in specified project directory: ${projectDir}`);
240088
240551
  process.exit(1);
240089
240552
  }
240090
240553
  } else {
240091
240554
  const currentDir = process.cwd();
240092
- if (existsSync11(join12(currentDir, "index.ts"))) {
240555
+ if (existsSync12(join13(currentDir, "index.ts"))) {
240093
240556
  projectDir = currentDir;
240094
240557
  } else {
240095
240558
  s2.stop("No index.ts found in current directory");
@@ -240150,7 +240613,7 @@ async function pushCommand(options) {
240150
240613
  s2.start("Generating project data JSON...");
240151
240614
  try {
240152
240615
  const projectDefinition = await project.getFullDefinition();
240153
- const jsonFilePath = join12(projectDir, `project.json`);
240616
+ const jsonFilePath = join13(projectDir, `project.json`);
240154
240617
  const fs5 = await import("fs/promises");
240155
240618
  await fs5.writeFile(jsonFilePath, JSON.stringify(projectDefinition, null, 2));
240156
240619
  s2.stop(`Project data saved to ${jsonFilePath}`);
@@ -240213,7 +240676,7 @@ async function pushCommand(options) {
240213
240676
  for (const usage of usageInfo) {
240214
240677
  usageByType[usage.type] = (usageByType[usage.type] || 0) + 1;
240215
240678
  }
240216
- const usageSummary = Object.entries(usageByType).map(([type, count17]) => `${count17} ${type}${count17 > 1 ? "s" : ""}`).join(", ");
240679
+ const usageSummary = Object.entries(usageByType).map(([type, count18]) => `${count18} ${type}${count18 > 1 ? "s" : ""}`).join(", ");
240217
240680
  console.log(chalk10.gray(` Used by: ${usageSummary}`));
240218
240681
  }
240219
240682
  }
@@ -240386,7 +240849,7 @@ async function updateCommand(options = {}) {
240386
240849
  // src/index.ts
240387
240850
  var __filename3 = fileURLToPath3(import.meta.url);
240388
240851
  var __dirname3 = dirname6(__filename3);
240389
- var packageJsonPath = join13(__dirname3, "..", "package.json");
240852
+ var packageJsonPath = join14(__dirname3, "..", "package.json");
240390
240853
  var packageJson = JSON.parse(readFileSync7(packageJsonPath, "utf-8"));
240391
240854
  var program = new Command();
240392
240855
  program.name("inkeep").description("CLI tool for Inkeep Agent Framework").version(packageJson.version);