@inkeep/agents-core 0.7.1 → 0.8.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.
@@ -436,6 +436,7 @@ var agentToolRelations = sqliteTable(
436
436
  id: text("id").notNull(),
437
437
  toolId: text("tool_id").notNull(),
438
438
  selectedTools: blob("selected_tools", { mode: "json" }).$type(),
439
+ headers: blob("headers", { mode: "json" }).$type(),
439
440
  createdAt: text("created_at").notNull().default(sql`CURRENT_TIMESTAMP`),
440
441
  updatedAt: text("updated_at").notNull().default(sql`CURRENT_TIMESTAMP`)
441
442
  },
@@ -1,4 +1,4 @@
1
- import { agents, agentRelations, agentGraph, tasks, taskRelations, tools, conversations, messages, contextCache, dataComponents, agentDataComponents, artifactComponents, agentArtifactComponents, externalAgents, apiKeys, credentialReferences, contextConfigs, agentToolRelations, ledgerArtifacts, projects } from './chunk-Y2L44YJB.js';
1
+ import { agents, agentRelations, agentGraph, tasks, taskRelations, tools, conversations, messages, contextCache, dataComponents, agentDataComponents, artifactComponents, agentArtifactComponents, externalAgents, apiKeys, credentialReferences, contextConfigs, agentToolRelations, ledgerArtifacts, projects } from './chunk-E4ZLV4GU.js';
2
2
  import { VALID_RELATION_TYPES, MCPTransportType, TOOL_STATUS_VALUES, CredentialStoreType, MCPServerType } from './chunk-YFHT5M2R.js';
3
3
  import { z } from '@hono/zod-openapi';
4
4
  import { createSelectSchema, createInsertSchema } from 'drizzle-zod';
@@ -416,7 +416,8 @@ var AgentToolRelationInsertSchema = createInsertSchema(agentToolRelations).exten
416
416
  id: resourceIdSchema,
417
417
  agentId: resourceIdSchema,
418
418
  toolId: resourceIdSchema,
419
- selectedTools: z.array(z.string()).nullish()
419
+ selectedTools: z.array(z.string()).nullish(),
420
+ headers: z.record(z.string(), z.string()).nullish()
420
421
  });
421
422
  var AgentToolRelationUpdateSchema = AgentToolRelationInsertSchema.partial();
422
423
  var AgentToolRelationApiSelectSchema = createGraphScopedApiSchema(
@@ -452,7 +453,8 @@ var StatusUpdateSchema = z.object({
452
453
  });
453
454
  var CanUseItemSchema = z.object({
454
455
  toolId: z.string(),
455
- toolSelection: z.array(z.string()).nullable().optional()
456
+ toolSelection: z.array(z.string()).nullish(),
457
+ headers: z.record(z.string(), z.string()).nullish()
456
458
  });
457
459
  var FullGraphAgentInsertSchema = AgentApiInsertSchema.extend({
458
460
  type: z.literal("internal"),
@@ -1,4 +1,4 @@
1
- import { FullGraphDefinitionSchema, resourceIdSchema, MAX_ID_LENGTH } from './chunk-6LGKJVQN.js';
1
+ import { FullGraphDefinitionSchema, resourceIdSchema, MAX_ID_LENGTH } from './chunk-P5LTXXFH.js';
2
2
 
3
3
  // src/validation/graphFull.ts
4
4
  function isInternalAgent(agent) {
@@ -411,6 +411,7 @@ var agentToolRelations = sqliteCore.sqliteTable(
411
411
  id: sqliteCore.text("id").notNull(),
412
412
  toolId: sqliteCore.text("tool_id").notNull(),
413
413
  selectedTools: sqliteCore.blob("selected_tools", { mode: "json" }).$type(),
414
+ headers: sqliteCore.blob("headers", { mode: "json" }).$type(),
414
415
  createdAt: sqliteCore.text("created_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`),
415
416
  updatedAt: sqliteCore.text("updated_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
416
417
  },
@@ -1346,7 +1347,8 @@ var AgentToolRelationInsertSchema = drizzleZod.createInsertSchema(agentToolRelat
1346
1347
  id: resourceIdSchema,
1347
1348
  agentId: resourceIdSchema,
1348
1349
  toolId: resourceIdSchema,
1349
- selectedTools: zodOpenapi.z.array(zodOpenapi.z.string()).nullish()
1350
+ selectedTools: zodOpenapi.z.array(zodOpenapi.z.string()).nullish(),
1351
+ headers: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.string()).nullish()
1350
1352
  });
1351
1353
  var AgentToolRelationUpdateSchema = AgentToolRelationInsertSchema.partial();
1352
1354
  createGraphScopedApiSchema(
@@ -1382,7 +1384,8 @@ var StatusUpdateSchema = zodOpenapi.z.object({
1382
1384
  });
1383
1385
  var CanUseItemSchema = zodOpenapi.z.object({
1384
1386
  toolId: zodOpenapi.z.string(),
1385
- toolSelection: zodOpenapi.z.array(zodOpenapi.z.string()).nullable().optional()
1387
+ toolSelection: zodOpenapi.z.array(zodOpenapi.z.string()).nullish(),
1388
+ headers: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.string()).nullish()
1386
1389
  });
1387
1390
  var FullGraphAgentInsertSchema = AgentApiInsertSchema.extend({
1388
1391
  type: zodOpenapi.z.literal("internal"),
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
- import { C as ConversationHistoryConfig, F as FullGraphAgentInsertSchema } from './utility-DPZ_yTkY.cjs';
3
- export { c as AgentStopWhen, A as AgentStopWhenSchema, d as CredentialStoreType, b as GraphStopWhen, G as GraphStopWhenSchema, M as MCPTransportType, a as StopWhen, S as StopWhenSchema } from './utility-DPZ_yTkY.cjs';
2
+ import { C as ConversationHistoryConfig, F as FullGraphAgentInsertSchema } from './utility-CT2pq49U.cjs';
3
+ export { c as AgentStopWhen, A as AgentStopWhenSchema, d as CredentialStoreType, b as GraphStopWhen, G as GraphStopWhenSchema, M as MCPTransportType, a as StopWhen, S as StopWhenSchema } from './utility-CT2pq49U.cjs';
4
4
  import 'drizzle-zod';
5
5
  import 'drizzle-orm/sqlite-core';
6
6
  import '@hono/zod-openapi';
@@ -200,6 +200,7 @@ declare const FullGraphDefinitionSchema: z.ZodObject<{
200
200
  canUse: z.ZodArray<z.ZodObject<{
201
201
  toolId: z.ZodString;
202
202
  toolSelection: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
203
+ headers: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>>;
203
204
  }, z.core.$strip>>;
204
205
  dataComponents: z.ZodOptional<z.ZodArray<z.ZodString>>;
205
206
  artifactComponents: z.ZodOptional<z.ZodArray<z.ZodString>>;
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
- import { C as ConversationHistoryConfig, F as FullGraphAgentInsertSchema } from './utility-DPZ_yTkY.js';
3
- export { c as AgentStopWhen, A as AgentStopWhenSchema, d as CredentialStoreType, b as GraphStopWhen, G as GraphStopWhenSchema, M as MCPTransportType, a as StopWhen, S as StopWhenSchema } from './utility-DPZ_yTkY.js';
2
+ import { C as ConversationHistoryConfig, F as FullGraphAgentInsertSchema } from './utility-CT2pq49U.js';
3
+ export { c as AgentStopWhen, A as AgentStopWhenSchema, d as CredentialStoreType, b as GraphStopWhen, G as GraphStopWhenSchema, M as MCPTransportType, a as StopWhen, S as StopWhenSchema } from './utility-CT2pq49U.js';
4
4
  import 'drizzle-zod';
5
5
  import 'drizzle-orm/sqlite-core';
6
6
  import '@hono/zod-openapi';
@@ -200,6 +200,7 @@ declare const FullGraphDefinitionSchema: z.ZodObject<{
200
200
  canUse: z.ZodArray<z.ZodObject<{
201
201
  toolId: z.ZodString;
202
202
  toolSelection: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
203
+ headers: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>>;
203
204
  }, z.core.$strip>>;
204
205
  dataComponents: z.ZodOptional<z.ZodArray<z.ZodString>>;
205
206
  artifactComponents: z.ZodOptional<z.ZodArray<z.ZodString>>;
@@ -1,5 +1,5 @@
1
- import { FullGraphAgentInsertSchema } from './chunk-6LGKJVQN.js';
2
- export { AgentStopWhenSchema, GraphStopWhenSchema, StopWhenSchema } from './chunk-6LGKJVQN.js';
1
+ import { FullGraphAgentInsertSchema } from './chunk-P5LTXXFH.js';
2
+ export { AgentStopWhenSchema, GraphStopWhenSchema, StopWhenSchema } from './chunk-P5LTXXFH.js';
3
3
  import { CredentialStoreType } from './chunk-YFHT5M2R.js';
4
4
  export { CredentialStoreType, MCPTransportType } from './chunk-YFHT5M2R.js';
5
5
  import { z } from 'zod';
@@ -391,6 +391,7 @@ var agentToolRelations = sqliteCore.sqliteTable(
391
391
  id: sqliteCore.text("id").notNull(),
392
392
  toolId: sqliteCore.text("tool_id").notNull(),
393
393
  selectedTools: sqliteCore.blob("selected_tools", { mode: "json" }).$type(),
394
+ headers: sqliteCore.blob("headers", { mode: "json" }).$type(),
394
395
  createdAt: sqliteCore.text("created_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`),
395
396
  updatedAt: sqliteCore.text("updated_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
396
397
  },
@@ -1,7 +1,7 @@
1
1
  import 'drizzle-orm';
2
2
  import 'drizzle-orm/sqlite-core';
3
- import '../utility-DPZ_yTkY.cjs';
4
- export { k as agentArtifactComponents, N as agentArtifactComponentsRelations, i as agentDataComponents, P as agentDataComponentsRelations, a as agentGraph, E as agentGraphRelations, e as agentRelations, R as agentRelationsRelations, m as agentToolRelations, H as agentToolRelationsRelations, d as agents, D as agentsRelations, r as apiKeys, G as apiKeysRelations, j as artifactComponents, M as artifactComponentsRelations, b as contextCache, C as contextCacheRelations, c as contextConfigs, B as contextConfigsRelations, n as conversations, K as conversationsRelations, u as credentialReferences, I as credentialReferencesRelations, h as dataComponents, O as dataComponentsRelations, f as externalAgents, F as externalAgentsRelations, q as ledgerArtifacts, w as ledgerArtifactsContextIdIdx, Q as ledgerArtifactsRelations, x as ledgerArtifactsTaskContextNameUnique, v as ledgerArtifactsTaskIdIdx, o as messages, L as messagesRelations, p as projects, z as projectsRelations, g as taskRelations, A as taskRelationsRelations, t as tasks, y as tasksRelations, l as tools, J as toolsRelations } from '../schema-C138dGBf.cjs';
3
+ import '../utility-CT2pq49U.cjs';
4
+ export { k as agentArtifactComponents, N as agentArtifactComponentsRelations, i as agentDataComponents, P as agentDataComponentsRelations, a as agentGraph, E as agentGraphRelations, e as agentRelations, R as agentRelationsRelations, m as agentToolRelations, H as agentToolRelationsRelations, d as agents, D as agentsRelations, r as apiKeys, G as apiKeysRelations, j as artifactComponents, M as artifactComponentsRelations, b as contextCache, C as contextCacheRelations, c as contextConfigs, B as contextConfigsRelations, n as conversations, K as conversationsRelations, u as credentialReferences, I as credentialReferencesRelations, h as dataComponents, O as dataComponentsRelations, f as externalAgents, F as externalAgentsRelations, q as ledgerArtifacts, w as ledgerArtifactsContextIdIdx, Q as ledgerArtifactsRelations, x as ledgerArtifactsTaskContextNameUnique, v as ledgerArtifactsTaskIdIdx, o as messages, L as messagesRelations, p as projects, z as projectsRelations, g as taskRelations, A as taskRelationsRelations, t as tasks, y as tasksRelations, l as tools, J as toolsRelations } from '../schema-BF9NpAv5.cjs';
5
5
  import 'zod';
6
6
  import 'drizzle-zod';
7
7
  import '@hono/zod-openapi';
@@ -1,7 +1,7 @@
1
1
  import 'drizzle-orm';
2
2
  import 'drizzle-orm/sqlite-core';
3
- import '../utility-DPZ_yTkY.js';
4
- export { k as agentArtifactComponents, N as agentArtifactComponentsRelations, i as agentDataComponents, P as agentDataComponentsRelations, a as agentGraph, E as agentGraphRelations, e as agentRelations, R as agentRelationsRelations, m as agentToolRelations, H as agentToolRelationsRelations, d as agents, D as agentsRelations, r as apiKeys, G as apiKeysRelations, j as artifactComponents, M as artifactComponentsRelations, b as contextCache, C as contextCacheRelations, c as contextConfigs, B as contextConfigsRelations, n as conversations, K as conversationsRelations, u as credentialReferences, I as credentialReferencesRelations, h as dataComponents, O as dataComponentsRelations, f as externalAgents, F as externalAgentsRelations, q as ledgerArtifacts, w as ledgerArtifactsContextIdIdx, Q as ledgerArtifactsRelations, x as ledgerArtifactsTaskContextNameUnique, v as ledgerArtifactsTaskIdIdx, o as messages, L as messagesRelations, p as projects, z as projectsRelations, g as taskRelations, A as taskRelationsRelations, t as tasks, y as tasksRelations, l as tools, J as toolsRelations } from '../schema-DbxoPUgw.js';
3
+ import '../utility-CT2pq49U.js';
4
+ export { k as agentArtifactComponents, N as agentArtifactComponentsRelations, i as agentDataComponents, P as agentDataComponentsRelations, a as agentGraph, E as agentGraphRelations, e as agentRelations, R as agentRelationsRelations, m as agentToolRelations, H as agentToolRelationsRelations, d as agents, D as agentsRelations, r as apiKeys, G as apiKeysRelations, j as artifactComponents, M as artifactComponentsRelations, b as contextCache, C as contextCacheRelations, c as contextConfigs, B as contextConfigsRelations, n as conversations, K as conversationsRelations, u as credentialReferences, I as credentialReferencesRelations, h as dataComponents, O as dataComponentsRelations, f as externalAgents, F as externalAgentsRelations, q as ledgerArtifacts, w as ledgerArtifactsContextIdIdx, Q as ledgerArtifactsRelations, x as ledgerArtifactsTaskContextNameUnique, v as ledgerArtifactsTaskIdIdx, o as messages, L as messagesRelations, p as projects, z as projectsRelations, g as taskRelations, A as taskRelationsRelations, t as tasks, y as tasksRelations, l as tools, J as toolsRelations } from '../schema-78jVngGh.js';
5
5
  import 'zod';
6
6
  import 'drizzle-zod';
7
7
  import '@hono/zod-openapi';
package/dist/db/schema.js CHANGED
@@ -1 +1 @@
1
- export { agentArtifactComponents, agentArtifactComponentsRelations, agentDataComponents, agentDataComponentsRelations, agentGraph, agentGraphRelations, agentRelations, agentRelationsRelations, agentToolRelations, agentToolRelationsRelations, agents, agentsRelations, apiKeys, apiKeysRelations, artifactComponents, artifactComponentsRelations, contextCache, contextCacheRelations, contextConfigs, contextConfigsRelations, conversations, conversationsRelations, credentialReferences, credentialReferencesRelations, dataComponents, dataComponentsRelations, externalAgents, externalAgentsRelations, ledgerArtifacts, ledgerArtifactsContextIdIdx, ledgerArtifactsRelations, ledgerArtifactsTaskContextNameUnique, ledgerArtifactsTaskIdIdx, messages, messagesRelations, projects, projectsRelations, taskRelations, taskRelationsRelations, tasks, tasksRelations, tools, toolsRelations } from '../chunk-Y2L44YJB.js';
1
+ export { agentArtifactComponents, agentArtifactComponentsRelations, agentDataComponents, agentDataComponentsRelations, agentGraph, agentGraphRelations, agentRelations, agentRelationsRelations, agentToolRelations, agentToolRelationsRelations, agents, agentsRelations, apiKeys, apiKeysRelations, artifactComponents, artifactComponentsRelations, contextCache, contextCacheRelations, contextConfigs, contextConfigsRelations, conversations, conversationsRelations, credentialReferences, credentialReferencesRelations, dataComponents, dataComponentsRelations, externalAgents, externalAgentsRelations, ledgerArtifacts, ledgerArtifactsContextIdIdx, ledgerArtifactsRelations, ledgerArtifactsTaskContextNameUnique, ledgerArtifactsTaskIdIdx, messages, messagesRelations, projects, projectsRelations, taskRelations, taskRelationsRelations, tasks, tasksRelations, tools, toolsRelations } from '../chunk-E4ZLV4GU.js';
package/dist/index.cjs CHANGED
@@ -642,6 +642,7 @@ var agentToolRelations = sqliteCore.sqliteTable(
642
642
  id: sqliteCore.text("id").notNull(),
643
643
  toolId: sqliteCore.text("tool_id").notNull(),
644
644
  selectedTools: sqliteCore.blob("selected_tools", { mode: "json" }).$type(),
645
+ headers: sqliteCore.blob("headers", { mode: "json" }).$type(),
645
646
  createdAt: sqliteCore.text("created_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`),
646
647
  updatedAt: sqliteCore.text("updated_at").notNull().default(drizzleOrm.sql`CURRENT_TIMESTAMP`)
647
648
  },
@@ -1595,7 +1596,8 @@ var AgentToolRelationInsertSchema = drizzleZod.createInsertSchema(agentToolRelat
1595
1596
  id: resourceIdSchema,
1596
1597
  agentId: resourceIdSchema,
1597
1598
  toolId: resourceIdSchema,
1598
- selectedTools: zodOpenapi.z.array(zodOpenapi.z.string()).nullish()
1599
+ selectedTools: zodOpenapi.z.array(zodOpenapi.z.string()).nullish(),
1600
+ headers: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.string()).nullish()
1599
1601
  });
1600
1602
  var AgentToolRelationUpdateSchema = AgentToolRelationInsertSchema.partial();
1601
1603
  var AgentToolRelationApiSelectSchema = createGraphScopedApiSchema(
@@ -1631,7 +1633,8 @@ var StatusUpdateSchema = zodOpenapi.z.object({
1631
1633
  });
1632
1634
  var CanUseItemSchema = zodOpenapi.z.object({
1633
1635
  toolId: zodOpenapi.z.string(),
1634
- toolSelection: zodOpenapi.z.array(zodOpenapi.z.string()).nullable().optional()
1636
+ toolSelection: zodOpenapi.z.array(zodOpenapi.z.string()).nullish(),
1637
+ headers: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.string()).nullish()
1635
1638
  });
1636
1639
  var FullGraphAgentInsertSchema = AgentApiInsertSchema.extend({
1637
1640
  type: zodOpenapi.z.literal("internal"),
@@ -2139,13 +2142,25 @@ var _TemplateEngine = class _TemplateEngine {
2139
2142
  if (options.preserveUnresolved) {
2140
2143
  return match2;
2141
2144
  }
2142
- logger2.warn(
2143
- {
2144
- variable: trimmedPath,
2145
- availableKeys: Object.keys(context)
2146
- },
2147
- "Template variable not found in context"
2148
- );
2145
+ if (trimmedPath.startsWith("requestContext.")) {
2146
+ logger2.warn(
2147
+ {
2148
+ variable: trimmedPath,
2149
+ availableKeys: Object.keys(context),
2150
+ contextStructure: JSON.stringify(context, null, 2),
2151
+ requestContextContent: context.requestContext ? JSON.stringify(context.requestContext, null, 2) : "undefined"
2152
+ },
2153
+ "RequestContext template variable debugging"
2154
+ );
2155
+ } else {
2156
+ logger2.warn(
2157
+ {
2158
+ variable: trimmedPath,
2159
+ availableKeys: Object.keys(context)
2160
+ },
2161
+ "Template variable not found in context"
2162
+ );
2163
+ }
2149
2164
  return "";
2150
2165
  }
2151
2166
  if (typeof result === "object") {
@@ -2758,7 +2773,8 @@ var createAgentToolRelation = (db) => async (params) => {
2758
2773
  graphId: params.scopes.graphId,
2759
2774
  agentId: params.data.agentId,
2760
2775
  toolId: params.data.toolId,
2761
- selectedTools: params.data.selectedTools
2776
+ selectedTools: params.data.selectedTools,
2777
+ headers: params.data.headers
2762
2778
  }).returning();
2763
2779
  return relation[0];
2764
2780
  };
@@ -2903,6 +2919,7 @@ var getToolsForAgent = (db) => async (params) => {
2903
2919
  agentId: agentToolRelations.agentId,
2904
2920
  toolId: agentToolRelations.toolId,
2905
2921
  selectedTools: agentToolRelations.selectedTools,
2922
+ headers: agentToolRelations.headers,
2906
2923
  createdAt: agentToolRelations.createdAt,
2907
2924
  updatedAt: agentToolRelations.updatedAt,
2908
2925
  tool: {
@@ -2961,6 +2978,7 @@ var getAgentsForTool = (db) => async (params) => {
2961
2978
  agentId: agentToolRelations.agentId,
2962
2979
  toolId: agentToolRelations.toolId,
2963
2980
  selectedTools: agentToolRelations.selectedTools,
2981
+ headers: agentToolRelations.headers,
2964
2982
  createdAt: agentToolRelations.createdAt,
2965
2983
  updatedAt: agentToolRelations.updatedAt,
2966
2984
  agent: {
@@ -3668,9 +3686,9 @@ var getFullGraphDefinition = (db) => async ({
3668
3686
  credentialReferenceId: tools.credentialReferenceId,
3669
3687
  tenantId: tools.tenantId,
3670
3688
  projectId: tools.projectId,
3671
- headers: tools.headers,
3672
3689
  imageUrl: tools.imageUrl,
3673
- selectedTools: agentToolRelations.selectedTools
3690
+ selectedTools: agentToolRelations.selectedTools,
3691
+ headers: agentToolRelations.headers
3674
3692
  }).from(agentToolRelations).innerJoin(
3675
3693
  tools,
3676
3694
  drizzleOrm.and(
@@ -3704,7 +3722,8 @@ var getFullGraphDefinition = (db) => async ({
3704
3722
  );
3705
3723
  const canUse = agentTools.map((tool2) => ({
3706
3724
  toolId: tool2.id,
3707
- toolSelection: tool2.selectedTools || null
3725
+ toolSelection: tool2.selectedTools || null,
3726
+ headers: tool2.headers || null
3708
3727
  }));
3709
3728
  return {
3710
3729
  id: agent.id,
@@ -5250,9 +5269,8 @@ var detectAuthenticationRequired = async ({
5250
5269
  error,
5251
5270
  logger: logger12
5252
5271
  }) => {
5253
- let hasOAuthEndpoints = false;
5254
5272
  try {
5255
- hasOAuthEndpoints = await checkForOAuthEndpoints(serverUrl, logger12);
5273
+ const hasOAuthEndpoints = await checkForOAuthEndpoints(serverUrl, logger12);
5256
5274
  if (hasOAuthEndpoints) {
5257
5275
  logger12?.info(
5258
5276
  { toolId, serverUrl },
@@ -5276,27 +5294,30 @@ var detectAuthenticationRequired = async ({
5276
5294
  });
5277
5295
  if (response.status === 401) {
5278
5296
  const wwwAuth = response.headers.get("WWW-Authenticate");
5279
- if (wwwAuth && (wwwAuth.toLowerCase().includes("bearer") || wwwAuth.toLowerCase().includes("oauth") || wwwAuth.toLowerCase().includes("authorization_uri"))) {
5280
- logger12?.info(
5281
- { toolId, wwwAuth },
5282
- "OAuth authentication detected via WWW-Authenticate header"
5283
- );
5284
- return true;
5297
+ if (wwwAuth) {
5298
+ const authLower = wwwAuth.toLowerCase();
5299
+ const hasActiveOAuthFlow = authLower.includes("authorization_uri") || authLower.includes("as_uri=") || authLower.includes("bearer") && (authLower.includes("scope=") || authLower.includes("error_uri="));
5300
+ if (hasActiveOAuthFlow) {
5301
+ logger12?.info(
5302
+ { toolId, wwwAuth },
5303
+ "Active OAuth flow detected via WWW-Authenticate parameters"
5304
+ );
5305
+ return true;
5306
+ } else {
5307
+ logger12?.debug(
5308
+ { toolId, wwwAuth },
5309
+ "Bearer authentication detected - likely simple token auth, not OAuth"
5310
+ );
5311
+ }
5285
5312
  }
5286
5313
  }
5287
5314
  } catch (fetchError) {
5288
5315
  logger12?.debug({ toolId, fetchError }, "Direct fetch authentication check failed");
5289
5316
  }
5290
- if (error.message.includes("401") || error.message.toLowerCase().includes("unauthorized")) {
5291
- if (hasOAuthEndpoints) {
5292
- logger12?.info(
5293
- { toolId, error: error.message },
5294
- "OAuth required: 401 error + OAuth endpoints detected"
5295
- );
5296
- return true;
5297
- }
5298
- }
5299
- logger12?.debug({ toolId, error: error.message }, "No OAuth authentication requirement detected");
5317
+ logger12?.debug(
5318
+ { toolId, error: error.message },
5319
+ "No OAuth 2.1/PKCE authentication requirement detected"
5320
+ );
5300
5321
  return false;
5301
5322
  };
5302
5323
  var ErrorCode = zodOpenapi.z.enum([
@@ -6006,6 +6027,7 @@ var addToolToAgent = (db) => async (params) => {
6006
6027
  agentId: params.agentId,
6007
6028
  toolId: params.toolId,
6008
6029
  selectedTools: params.selectedTools,
6030
+ headers: params.headers,
6009
6031
  createdAt: now,
6010
6032
  updatedAt: now
6011
6033
  }).returning();
@@ -6042,7 +6064,8 @@ var upsertAgentToolRelation = (db) => async (params) => {
6042
6064
  data: {
6043
6065
  agentId: params.agentId,
6044
6066
  toolId: params.toolId,
6045
- selectedTools: params.selectedTools
6067
+ selectedTools: params.selectedTools,
6068
+ headers: params.headers
6046
6069
  }
6047
6070
  });
6048
6071
  };
@@ -6303,13 +6326,14 @@ var createFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6303
6326
  agentToolPromises.push(
6304
6327
  (async () => {
6305
6328
  try {
6306
- const { toolId, toolSelection } = canUseItem;
6329
+ const { toolId, toolSelection, headers } = canUseItem;
6307
6330
  logger12.info({ agentId, toolId }, "Processing agent-tool relation");
6308
6331
  await upsertAgentToolRelation(db)({
6309
6332
  scopes: { tenantId, projectId, graphId: finalGraphId },
6310
6333
  agentId,
6311
6334
  toolId,
6312
- selectedTools: toolSelection || void 0
6335
+ selectedTools: toolSelection || void 0,
6336
+ headers: headers || void 0
6313
6337
  });
6314
6338
  logger12.info({ agentId, toolId }, "Agent-tool relation processed successfully");
6315
6339
  } catch (error) {
@@ -6699,13 +6723,14 @@ var updateFullGraphServerSide = (db, logger12 = defaultLogger) => async (scopes,
6699
6723
  agentToolPromises.push(
6700
6724
  (async () => {
6701
6725
  try {
6702
- const { toolId, toolSelection } = canUseItem;
6726
+ const { toolId, toolSelection, headers } = canUseItem;
6703
6727
  await createAgentToolRelation(db)({
6704
6728
  scopes: { tenantId, projectId, graphId: finalGraphId },
6705
6729
  data: {
6706
6730
  agentId,
6707
6731
  toolId,
6708
- selectedTools: toolSelection || void 0
6732
+ selectedTools: toolSelection || void 0,
6733
+ headers: headers || void 0
6709
6734
  }
6710
6735
  });
6711
6736
  logger12.info({ agentId, toolId }, "Agent-tool relation created");