@inkeep/agents-run-api 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -2,11 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var fs = require('fs');
6
- var path = require('path');
7
- var dotenv = require('dotenv');
8
- var z5 = require('zod');
9
5
  var agentsCore = require('@inkeep/agents-core');
6
+ var z5 = require('zod');
10
7
  var nanoid = require('nanoid');
11
8
  var autoInstrumentationsNode = require('@opentelemetry/auto-instrumentations-node');
12
9
  var baggageSpanProcessor = require('@opentelemetry/baggage-span-processor');
@@ -30,6 +27,7 @@ var destr = require('destr');
30
27
  var traverse = require('traverse');
31
28
  var ai = require('ai');
32
29
  var anthropic = require('@ai-sdk/anthropic');
30
+ var google = require('@ai-sdk/google');
33
31
  var openai = require('@ai-sdk/openai');
34
32
  var jmespath = require('jmespath');
35
33
  var mcp_js = require('@modelcontextprotocol/sdk/server/mcp.js');
@@ -40,27 +38,6 @@ var otel = require('@hono/otel');
40
38
 
41
39
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
42
40
 
43
- function _interopNamespace(e) {
44
- if (e && e.__esModule) return e;
45
- var n = Object.create(null);
46
- if (e) {
47
- Object.keys(e).forEach(function (k) {
48
- if (k !== 'default') {
49
- var d = Object.getOwnPropertyDescriptor(e, k);
50
- Object.defineProperty(n, k, d.get ? d : {
51
- enumerable: true,
52
- get: function () { return e[k]; }
53
- });
54
- }
55
- });
56
- }
57
- n.default = e;
58
- return Object.freeze(n);
59
- }
60
-
61
- var fs__default = /*#__PURE__*/_interopDefault(fs);
62
- var path__default = /*#__PURE__*/_interopDefault(path);
63
- var dotenv__namespace = /*#__PURE__*/_interopNamespace(dotenv);
64
41
  var z5__default = /*#__PURE__*/_interopDefault(z5);
65
42
  var destr__default = /*#__PURE__*/_interopDefault(destr);
66
43
  var traverse__default = /*#__PURE__*/_interopDefault(traverse);
@@ -77,31 +54,14 @@ var __export = (target, all) => {
77
54
  __defProp(target, name, { get: all[name], enumerable: true });
78
55
  };
79
56
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
80
- var environmentSchema, criticalEnv, loadEnvFile, envSchema, parseEnv, env;
57
+ var envSchema, parseEnv, env;
81
58
  var init_env = __esm({
82
59
  "src/env.ts"() {
83
- dotenv__namespace.config({ quiet: true });
84
- z5.z.enum(["development", "production"]).default("development");
85
- environmentSchema = z5.z.enum(["development", "pentest", "production", "test"]);
86
- criticalEnv = z5.z.object({
87
- ENVIRONMENT: environmentSchema
88
- }).parse(process.env);
89
- loadEnvFile = () => {
90
- const envPath = path__default.default.resolve(process.cwd(), `.env.${criticalEnv.ENVIRONMENT}.nonsecret`);
91
- if (fs__default.default.existsSync(envPath)) {
92
- const envConfig = dotenv__namespace.parse(fs__default.default.readFileSync(envPath));
93
- for (const k in envConfig) {
94
- if (!(k in process.env)) {
95
- process.env[k] = envConfig[k];
96
- }
97
- }
98
- }
99
- };
100
- loadEnvFile();
60
+ agentsCore.loadEnvironmentFiles();
101
61
  envSchema = z5.z.object({
102
62
  NODE_ENV: z5.z.enum(["development", "production", "test"]).optional(),
103
63
  ENVIRONMENT: z5.z.enum(["development", "production", "pentest", "test"]).optional().default("development"),
104
- DB_FILE_NAME: z5.z.string().default("file:../local.db"),
64
+ DB_FILE_NAME: z5.z.string(),
105
65
  AGENTS_RUN_API_URL: z5.z.string().optional().default("http://localhost:3003"),
106
66
  LOG_LEVEL: z5.z.enum(["trace", "debug", "info", "warn", "error"]).optional().default("debug"),
107
67
  NANGO_SECRET_KEY: z5.z.string().optional(),
@@ -355,9 +315,9 @@ var sdk = new sdkNode.NodeSDK({
355
315
  requestHook: (span) => {
356
316
  const method = span.attributes?.["http.request.method"];
357
317
  const host = span.attributes?.["server.address"];
358
- const path2 = span.attributes?.["url.path"];
359
- if (method && path2)
360
- span.updateName(host ? `${method} ${host}${path2}` : `${method} ${path2}`);
318
+ const path = span.attributes?.["url.path"];
319
+ if (method && path)
320
+ span.updateName(host ? `${method} ${host}${path}` : `${method} ${path}`);
361
321
  }
362
322
  }
363
323
  })
@@ -461,6 +421,7 @@ var apiKeyAuth = () => factory.createMiddleware(async (c, next) => {
461
421
  return;
462
422
  } else if (apiKey) {
463
423
  const executionContext = await extractContextFromApiKey(apiKey);
424
+ executionContext.agentId = agentId;
464
425
  c.set("executionContext", executionContext);
465
426
  logger.info({}, "API key authenticated successfully");
466
427
  await next();
@@ -478,12 +439,14 @@ var apiKeyAuth = () => factory.createMiddleware(async (c, next) => {
478
439
  }
479
440
  try {
480
441
  const executionContext = await extractContextFromApiKey(apiKey);
442
+ executionContext.agentId = agentId;
481
443
  c.set("executionContext", executionContext);
482
444
  logger.debug(
483
445
  {
484
446
  tenantId: executionContext.tenantId,
485
447
  projectId: executionContext.projectId,
486
- graphId: executionContext.graphId
448
+ graphId: executionContext.graphId,
449
+ agentId: executionContext.agentId
487
450
  },
488
451
  "API key authenticated successfully"
489
452
  );
@@ -1156,6 +1119,128 @@ async function handleTasksResubscribe(c, agent, request) {
1156
1119
  });
1157
1120
  }
1158
1121
  }
1122
+ init_dbClient();
1123
+ agentsCore.getLogger("agents");
1124
+ function createAgentCard({
1125
+ dbAgent,
1126
+ baseUrl
1127
+ }) {
1128
+ const description = dbAgent.description || "AI Agent";
1129
+ return {
1130
+ name: dbAgent.name,
1131
+ description,
1132
+ url: baseUrl ? `${baseUrl}/a2a` : "",
1133
+ version: "1.0.0",
1134
+ capabilities: {
1135
+ streaming: true,
1136
+ // Enable streaming for A2A compliance
1137
+ pushNotifications: false,
1138
+ stateTransitionHistory: false
1139
+ },
1140
+ defaultInputModes: ["text", "text/plain"],
1141
+ defaultOutputModes: ["text", "text/plain"],
1142
+ skills: [],
1143
+ // Add provider info if available
1144
+ ...baseUrl && {
1145
+ provider: {
1146
+ organization: "Inkeep",
1147
+ url: baseUrl
1148
+ }
1149
+ }
1150
+ };
1151
+ }
1152
+ function generateDescriptionWithTransfers(baseDescription, internalRelations, externalRelations) {
1153
+ const transfers = [
1154
+ ...internalRelations.filter((rel) => rel.relationType === "transfer"),
1155
+ ...externalRelations.filter((rel) => rel.relationType === "transfer")
1156
+ ];
1157
+ const delegates = [
1158
+ ...internalRelations.filter((rel) => rel.relationType === "delegate"),
1159
+ ...externalRelations.filter((rel) => rel.relationType === "delegate")
1160
+ ];
1161
+ if (transfers.length === 0 && delegates.length === 0) {
1162
+ return baseDescription;
1163
+ }
1164
+ let enhancedDescription = baseDescription;
1165
+ if (transfers.length > 0) {
1166
+ const transferList = transfers.map((rel) => {
1167
+ const name = rel.externalAgent?.name || rel.name;
1168
+ const desc = rel.externalAgent?.description || rel.description || "";
1169
+ return `- ${name}: ${desc}`;
1170
+ }).join("\n");
1171
+ enhancedDescription += `
1172
+
1173
+ Can transfer to:
1174
+ ${transferList}`;
1175
+ }
1176
+ if (delegates.length > 0) {
1177
+ const delegateList = delegates.map((rel) => {
1178
+ const name = rel.externalAgent?.name || rel.name;
1179
+ const desc = rel.externalAgent?.description || rel.description || "";
1180
+ return `- ${name}: ${desc}`;
1181
+ }).join("\n");
1182
+ enhancedDescription += `
1183
+
1184
+ Can delegate to:
1185
+ ${delegateList}`;
1186
+ }
1187
+ return enhancedDescription;
1188
+ }
1189
+ async function hydrateAgent({
1190
+ dbAgent,
1191
+ graphId,
1192
+ baseUrl,
1193
+ apiKey,
1194
+ credentialStoreRegistry
1195
+ }) {
1196
+ try {
1197
+ const taskHandlerConfig = await createTaskHandlerConfig({
1198
+ tenantId: dbAgent.tenantId,
1199
+ projectId: dbAgent.projectId,
1200
+ graphId,
1201
+ agentId: dbAgent.id,
1202
+ baseUrl,
1203
+ apiKey
1204
+ });
1205
+ const taskHandler = createTaskHandler(taskHandlerConfig, credentialStoreRegistry);
1206
+ const agentCard = createAgentCard({
1207
+ dbAgent,
1208
+ baseUrl
1209
+ });
1210
+ return {
1211
+ agentId: dbAgent.id,
1212
+ tenantId: dbAgent.tenantId,
1213
+ projectId: dbAgent.projectId,
1214
+ graphId,
1215
+ agentCard,
1216
+ taskHandler
1217
+ };
1218
+ } catch (error) {
1219
+ console.error(`\u274C Failed to hydrate agent ${dbAgent.id}:`, error);
1220
+ throw error;
1221
+ }
1222
+ }
1223
+ async function getRegisteredAgent(executionContext, credentialStoreRegistry) {
1224
+ const { tenantId, projectId, graphId, agentId, baseUrl, apiKey } = executionContext;
1225
+ if (!agentId) {
1226
+ throw new Error("Agent ID is required");
1227
+ }
1228
+ const dbAgent = await agentsCore.getAgentById(dbClient_default)({
1229
+ scopes: { tenantId, projectId },
1230
+ agentId
1231
+ });
1232
+ if (!dbAgent) {
1233
+ return null;
1234
+ }
1235
+ const agentFrameworkBaseUrl = `${baseUrl}/agents`;
1236
+ return hydrateAgent({
1237
+ dbAgent,
1238
+ graphId,
1239
+ baseUrl: agentFrameworkBaseUrl,
1240
+ credentialStoreRegistry,
1241
+ apiKey
1242
+ });
1243
+ }
1159
1244
 
1160
1245
  // src/agents/generateTaskHandler.ts
1161
1246
  init_dbClient();
@@ -1199,10 +1284,10 @@ function statusUpdateOp(ctx) {
1199
1284
  ctx
1200
1285
  };
1201
1286
  }
1202
- var logger3 = agentsCore.getLogger("DataComponentSchema");
1287
+ var logger4 = agentsCore.getLogger("DataComponentSchema");
1203
1288
  function jsonSchemaToZod(jsonSchema) {
1204
1289
  if (!jsonSchema || typeof jsonSchema !== "object") {
1205
- logger3.warn({ jsonSchema }, "Invalid JSON schema provided, using string fallback");
1290
+ logger4.warn({ jsonSchema }, "Invalid JSON schema provided, using string fallback");
1206
1291
  return z5.z.string();
1207
1292
  }
1208
1293
  switch (jsonSchema.type) {
@@ -1229,7 +1314,7 @@ function jsonSchemaToZod(jsonSchema) {
1229
1314
  case "null":
1230
1315
  return z5.z.null();
1231
1316
  default:
1232
- logger3.warn(
1317
+ logger4.warn(
1233
1318
  {
1234
1319
  unsupportedType: jsonSchema.type,
1235
1320
  schema: jsonSchema
@@ -1283,22 +1368,54 @@ __publicField(_ArtifactReferenceSchema, "ARTIFACT_PROPS_SCHEMA", {
1283
1368
  required: ["artifact_id", "task_id"]
1284
1369
  });
1285
1370
  var ArtifactReferenceSchema = _ArtifactReferenceSchema;
1286
- var logger4 = agentsCore.getLogger("ModelFactory");
1371
+ var logger5 = agentsCore.getLogger("ModelFactory");
1287
1372
  var _ModelFactory = class _ModelFactory {
1373
+ /**
1374
+ * Create a provider instance with custom configuration
1375
+ */
1376
+ static createProvider(provider, config) {
1377
+ switch (provider) {
1378
+ case "anthropic":
1379
+ return anthropic.createAnthropic(config);
1380
+ case "openai":
1381
+ return openai.createOpenAI(config);
1382
+ case "google":
1383
+ return google.createGoogleGenerativeAI(config);
1384
+ default:
1385
+ throw new Error(`Unsupported provider: ${provider}`);
1386
+ }
1387
+ }
1388
+ /**
1389
+ * Extract provider configuration from providerOptions
1390
+ * Only includes settings that go to the provider constructor (baseURL, apiKey, etc.)
1391
+ */
1392
+ static extractProviderConfig(providerOptions) {
1393
+ if (!providerOptions) {
1394
+ return {};
1395
+ }
1396
+ const providerConfig = {};
1397
+ if (providerOptions.baseUrl || providerOptions.baseURL) {
1398
+ providerConfig.baseURL = providerOptions.baseUrl || providerOptions.baseURL;
1399
+ }
1400
+ if (providerOptions.gateway) {
1401
+ Object.assign(providerConfig, providerOptions.gateway);
1402
+ }
1403
+ return providerConfig;
1404
+ }
1288
1405
  /**
1289
1406
  * Create a language model instance from configuration
1290
1407
  * Throws error if no config provided - models must be configured at project level
1291
1408
  */
1292
- static createModel(config2) {
1293
- if (!config2?.model?.trim()) {
1409
+ static createModel(config) {
1410
+ if (!config?.model?.trim()) {
1294
1411
  throw new Error(
1295
1412
  "Model configuration is required. Please configure models at the project level."
1296
1413
  );
1297
1414
  }
1298
- const modelSettings = config2;
1415
+ const modelSettings = config;
1299
1416
  const modelString = modelSettings.model.trim();
1300
1417
  const { provider, modelName } = _ModelFactory.parseModelString(modelString);
1301
- logger4.debug(
1418
+ logger5.debug(
1302
1419
  {
1303
1420
  provider,
1304
1421
  model: modelName,
@@ -1307,49 +1424,40 @@ var _ModelFactory = class _ModelFactory {
1307
1424
  },
1308
1425
  "Creating language model from config"
1309
1426
  );
1310
- try {
1311
- switch (provider) {
1312
- case "anthropic":
1313
- return _ModelFactory.createAnthropicModel(modelName, modelSettings.providerOptions);
1314
- case "openai":
1315
- return _ModelFactory.createOpenAIModel(modelName, modelSettings.providerOptions);
1316
- default:
1317
- throw new Error(
1318
- `Unsupported provider: ${provider}. Supported providers are: ${_ModelFactory.SUPPORTED_PROVIDERS.join(", ")}`
1319
- );
1320
- }
1321
- } catch (error) {
1322
- logger4.error(
1323
- {
1324
- provider,
1325
- model: modelName,
1326
- error: error instanceof Error ? error.message : "Unknown error"
1327
- },
1328
- "Failed to create model"
1329
- );
1330
- throw new Error(
1331
- `Failed to create model ${modelString}: ${error instanceof Error ? error.message : "Unknown error"}`
1332
- );
1427
+ const providerConfig = _ModelFactory.extractProviderConfig(modelSettings.providerOptions);
1428
+ if (Object.keys(providerConfig).length > 0) {
1429
+ logger5.info({ config: providerConfig }, `Applying custom ${provider} provider configuration`);
1430
+ const customProvider = _ModelFactory.createProvider(provider, providerConfig);
1431
+ return customProvider.languageModel(modelName);
1432
+ }
1433
+ switch (provider) {
1434
+ case "anthropic":
1435
+ return anthropic.anthropic(modelName);
1436
+ case "openai":
1437
+ return openai.openai(modelName);
1438
+ case "google":
1439
+ return google.google(modelName);
1440
+ default:
1441
+ throw new Error(`Unsupported provider: ${provider}`);
1333
1442
  }
1334
1443
  }
1335
1444
  /**
1336
1445
  * Parse model string to extract provider and model name
1337
- * Examples: "anthropic/claude-4-sonnet" -> { provider: "anthropic", modelName: "claude-4-sonnet" }
1338
- * "claude-4-sonnet" -> { provider: "anthropic", modelName: "claude-4-sonnet" } (default to anthropic)
1446
+ * Examples: "anthropic/claude-sonnet-4" -> { provider: "anthropic", modelName: "claude-sonnet-4" }
1447
+ * "claude-sonnet-4" -> { provider: "anthropic", modelName: "claude-sonnet-4" } (default to anthropic)
1339
1448
  */
1340
1449
  static parseModelString(modelString) {
1341
1450
  if (modelString.includes("/")) {
1342
1451
  const [provider, ...modelParts] = modelString.split("/");
1343
1452
  const normalizedProvider = provider.toLowerCase();
1344
1453
  if (!_ModelFactory.SUPPORTED_PROVIDERS.includes(normalizedProvider)) {
1345
- logger4.warn(
1454
+ logger5.error(
1346
1455
  { provider: normalizedProvider, modelName: modelParts.join("/") },
1347
1456
  "Unsupported provider detected, falling back to anthropic"
1348
1457
  );
1349
- return {
1350
- provider: "anthropic",
1351
- modelName: modelParts.join("/")
1352
- };
1458
+ throw new Error(
1459
+ `Unsupported provider: ${normalizedProvider}. Please provide a model in the format of provider/model-name.`
1460
+ );
1353
1461
  }
1354
1462
  return {
1355
1463
  provider: normalizedProvider,
@@ -1357,51 +1465,9 @@ var _ModelFactory = class _ModelFactory {
1357
1465
  // In case model name has slashes
1358
1466
  };
1359
1467
  }
1360
- return {
1361
- provider: "anthropic",
1362
- modelName: modelString
1363
- };
1364
- }
1365
- /**
1366
- * Create an Anthropic model instance
1367
- */
1368
- static createAnthropicModel(modelName, providerOptions) {
1369
- const anthropicConfig = {};
1370
- if (providerOptions?.baseUrl || providerOptions?.baseURL) {
1371
- anthropicConfig.baseURL = providerOptions.baseUrl || providerOptions.baseURL;
1372
- }
1373
- if (providerOptions?.gateway) {
1374
- logger4.info(
1375
- { gateway: providerOptions.gateway },
1376
- "Setting up AI Gateway for Anthropic model"
1377
- );
1378
- Object.assign(anthropicConfig, providerOptions.gateway);
1379
- }
1380
- if (Object.keys(anthropicConfig).length > 0) {
1381
- logger4.info({ config: anthropicConfig }, "Applying custom Anthropic provider configuration");
1382
- const provider = anthropic.createAnthropic(anthropicConfig);
1383
- return provider(modelName);
1384
- }
1385
- return anthropic.anthropic(modelName);
1386
- }
1387
- /**
1388
- * Create an OpenAI model instance
1389
- */
1390
- static createOpenAIModel(modelName, providerOptions) {
1391
- const openaiConfig = {};
1392
- if (providerOptions?.baseUrl || providerOptions?.baseURL) {
1393
- openaiConfig.baseURL = providerOptions.baseUrl || providerOptions.baseURL;
1394
- }
1395
- if (providerOptions?.gateway) {
1396
- logger4.info({ gateway: providerOptions.gateway }, "Setting up AI Gateway for OpenAI model");
1397
- Object.assign(openaiConfig, providerOptions.gateway);
1398
- }
1399
- if (Object.keys(openaiConfig).length > 0) {
1400
- logger4.info({ config: openaiConfig }, "Applying custom OpenAI provider configuration");
1401
- const provider = openai.createOpenAI(openaiConfig);
1402
- return provider(modelName);
1403
- }
1404
- return openai.openai(modelName);
1468
+ throw new Error(
1469
+ `Invalid model provided: ${modelString}. Please provide a model in the format of provider/model-name.`
1470
+ );
1405
1471
  }
1406
1472
  /**
1407
1473
  * Get generation parameters from provider options
@@ -1426,7 +1492,7 @@ var _ModelFactory = class _ModelFactory {
1426
1492
  * Includes maxDuration if specified in provider options (in seconds, following Vercel standard)
1427
1493
  */
1428
1494
  static prepareGenerationConfig(modelSettings) {
1429
- const modelString = modelSettings?.model?.trim() || "anthropic/claude-4-sonnet-20250514";
1495
+ const modelString = modelSettings?.model?.trim();
1430
1496
  const model = _ModelFactory.createModel({
1431
1497
  model: modelString,
1432
1498
  providerOptions: modelSettings?.providerOptions
@@ -1443,19 +1509,19 @@ var _ModelFactory = class _ModelFactory {
1443
1509
  * Validate model settingsuration
1444
1510
  * Basic validation only - let AI SDK handle parameter-specific validation
1445
1511
  */
1446
- static validateConfig(config2) {
1512
+ static validateConfig(config) {
1447
1513
  const errors = [];
1448
- if (!config2.model) {
1514
+ if (!config.model) {
1449
1515
  errors.push("Model name is required");
1450
1516
  }
1451
- if (config2.providerOptions) {
1452
- if (config2.providerOptions.apiKey) {
1517
+ if (config.providerOptions) {
1518
+ if (config.providerOptions.apiKey) {
1453
1519
  errors.push(
1454
1520
  "API keys should not be stored in provider options. Use environment variables (ANTHROPIC_API_KEY, OPENAI_API_KEY) or credential store instead."
1455
1521
  );
1456
1522
  }
1457
- if (config2.providerOptions.maxDuration !== void 0) {
1458
- const maxDuration = config2.providerOptions.maxDuration;
1523
+ if (config.providerOptions.maxDuration !== void 0) {
1524
+ const maxDuration = config.providerOptions.maxDuration;
1459
1525
  if (typeof maxDuration !== "number" || maxDuration <= 0) {
1460
1526
  errors.push("maxDuration must be a positive number (in seconds)");
1461
1527
  }
@@ -1467,7 +1533,7 @@ var _ModelFactory = class _ModelFactory {
1467
1533
  /**
1468
1534
  * Supported providers for security validation
1469
1535
  */
1470
- __publicField(_ModelFactory, "SUPPORTED_PROVIDERS", ["anthropic", "openai"]);
1536
+ __publicField(_ModelFactory, "SUPPORTED_PROVIDERS", ["anthropic", "openai", "google"]);
1471
1537
  var ModelFactory = _ModelFactory;
1472
1538
 
1473
1539
  // src/utils/graph-session.ts
@@ -1491,7 +1557,7 @@ function unregisterStreamHelper(requestId2) {
1491
1557
  }
1492
1558
 
1493
1559
  // src/utils/graph-session.ts
1494
- var logger5 = agentsCore.getLogger("GraphSession");
1560
+ var logger6 = agentsCore.getLogger("GraphSession");
1495
1561
  var GraphSession = class {
1496
1562
  // Track scheduled timeouts for cleanup
1497
1563
  constructor(sessionId, messageId, graphId, tenantId, projectId) {
@@ -1515,12 +1581,12 @@ var GraphSession = class {
1515
1581
  __publicField(this, "MAX_PENDING_ARTIFACTS", 100);
1516
1582
  // Prevent unbounded growth
1517
1583
  __publicField(this, "scheduledTimeouts");
1518
- logger5.debug({ sessionId, messageId, graphId }, "GraphSession created");
1584
+ logger6.debug({ sessionId, messageId, graphId }, "GraphSession created");
1519
1585
  }
1520
1586
  /**
1521
1587
  * Initialize status updates for this session
1522
1588
  */
1523
- initializeStatusUpdates(config2, summarizerModel, baseModel) {
1589
+ initializeStatusUpdates(config, summarizerModel, baseModel) {
1524
1590
  const now = Date.now();
1525
1591
  this.statusUpdateState = {
1526
1592
  lastUpdateTime: now,
@@ -1529,15 +1595,15 @@ var GraphSession = class {
1529
1595
  summarizerModel,
1530
1596
  baseModel,
1531
1597
  config: {
1532
- numEvents: config2.numEvents || 10,
1533
- timeInSeconds: config2.timeInSeconds || 30,
1534
- ...config2
1598
+ numEvents: config.numEvents || 1,
1599
+ timeInSeconds: config.timeInSeconds || 2,
1600
+ ...config
1535
1601
  }
1536
1602
  };
1537
1603
  if (this.statusUpdateState.config.timeInSeconds) {
1538
1604
  this.statusUpdateTimer = setInterval(async () => {
1539
1605
  if (!this.statusUpdateState || this.isEnded) {
1540
- logger5.debug(
1606
+ logger6.debug(
1541
1607
  { sessionId: this.sessionId },
1542
1608
  "Timer triggered but session already cleaned up or ended"
1543
1609
  );
@@ -1549,7 +1615,7 @@ var GraphSession = class {
1549
1615
  }
1550
1616
  await this.checkAndSendTimeBasedUpdate();
1551
1617
  }, this.statusUpdateState.config.timeInSeconds * 1e3);
1552
- logger5.info(
1618
+ logger6.info(
1553
1619
  {
1554
1620
  sessionId: this.sessionId,
1555
1621
  intervalMs: this.statusUpdateState.config.timeInSeconds * 1e3
@@ -1563,7 +1629,7 @@ var GraphSession = class {
1563
1629
  */
1564
1630
  recordEvent(eventType, agentId, data) {
1565
1631
  if (this.isEnded) {
1566
- logger5.debug(
1632
+ logger6.debug(
1567
1633
  {
1568
1634
  sessionId: this.sessionId,
1569
1635
  eventType,
@@ -1583,7 +1649,7 @@ var GraphSession = class {
1583
1649
  if (eventType === "artifact_saved" && data.pendingGeneration) {
1584
1650
  const artifactId = data.artifactId;
1585
1651
  if (this.pendingArtifacts.size >= this.MAX_PENDING_ARTIFACTS) {
1586
- logger5.warn(
1652
+ logger6.warn(
1587
1653
  {
1588
1654
  sessionId: this.sessionId,
1589
1655
  artifactId,
@@ -1604,7 +1670,7 @@ var GraphSession = class {
1604
1670
  this.artifactProcessingErrors.set(artifactId, errorCount);
1605
1671
  if (errorCount >= this.MAX_ARTIFACT_RETRIES) {
1606
1672
  this.pendingArtifacts.delete(artifactId);
1607
- logger5.error(
1673
+ logger6.error(
1608
1674
  {
1609
1675
  sessionId: this.sessionId,
1610
1676
  artifactId,
@@ -1616,7 +1682,7 @@ var GraphSession = class {
1616
1682
  "Artifact processing failed after max retries, giving up"
1617
1683
  );
1618
1684
  } else {
1619
- logger5.warn(
1685
+ logger6.warn(
1620
1686
  {
1621
1687
  sessionId: this.sessionId,
1622
1688
  artifactId,
@@ -1638,14 +1704,14 @@ var GraphSession = class {
1638
1704
  */
1639
1705
  checkStatusUpdates() {
1640
1706
  if (this.isEnded) {
1641
- logger5.debug(
1707
+ logger6.debug(
1642
1708
  { sessionId: this.sessionId },
1643
1709
  "Session has ended - skipping status update check"
1644
1710
  );
1645
1711
  return;
1646
1712
  }
1647
1713
  if (!this.statusUpdateState) {
1648
- logger5.debug({ sessionId: this.sessionId }, "No status update state - skipping check");
1714
+ logger6.debug({ sessionId: this.sessionId }, "No status update state - skipping check");
1649
1715
  return;
1650
1716
  }
1651
1717
  const statusUpdateState = this.statusUpdateState;
@@ -1656,11 +1722,11 @@ var GraphSession = class {
1656
1722
  */
1657
1723
  async checkAndSendTimeBasedUpdate() {
1658
1724
  if (this.isEnded) {
1659
- logger5.debug({ sessionId: this.sessionId }, "Session has ended - skipping time-based update");
1725
+ logger6.debug({ sessionId: this.sessionId }, "Session has ended - skipping time-based update");
1660
1726
  return;
1661
1727
  }
1662
1728
  if (!this.statusUpdateState) {
1663
- logger5.debug(
1729
+ logger6.debug(
1664
1730
  { sessionId: this.sessionId },
1665
1731
  "No status updates configured for time-based check"
1666
1732
  );
@@ -1673,7 +1739,7 @@ var GraphSession = class {
1673
1739
  try {
1674
1740
  await this.generateAndSendUpdate();
1675
1741
  } catch (error) {
1676
- logger5.error(
1742
+ logger6.error(
1677
1743
  {
1678
1744
  sessionId: this.sessionId,
1679
1745
  error: error instanceof Error ? error.message : "Unknown error"
@@ -1766,29 +1832,29 @@ var GraphSession = class {
1766
1832
  */
1767
1833
  async generateAndSendUpdate() {
1768
1834
  if (this.isEnded) {
1769
- logger5.debug({ sessionId: this.sessionId }, "Session has ended - not generating update");
1835
+ logger6.debug({ sessionId: this.sessionId }, "Session has ended - not generating update");
1770
1836
  return;
1771
1837
  }
1772
1838
  if (this.isTextStreaming) {
1773
- logger5.debug(
1839
+ logger6.debug(
1774
1840
  { sessionId: this.sessionId },
1775
1841
  "Text is currently streaming - skipping status update"
1776
1842
  );
1777
1843
  return;
1778
1844
  }
1779
1845
  if (this.isGeneratingUpdate) {
1780
- logger5.debug(
1846
+ logger6.debug(
1781
1847
  { sessionId: this.sessionId },
1782
1848
  "Update already in progress - skipping duplicate generation"
1783
1849
  );
1784
1850
  return;
1785
1851
  }
1786
1852
  if (!this.statusUpdateState) {
1787
- logger5.warn({ sessionId: this.sessionId }, "No status update state - cannot generate update");
1853
+ logger6.warn({ sessionId: this.sessionId }, "No status update state - cannot generate update");
1788
1854
  return;
1789
1855
  }
1790
1856
  if (!this.graphId) {
1791
- logger5.warn({ sessionId: this.sessionId }, "No graph ID - cannot generate update");
1857
+ logger6.warn({ sessionId: this.sessionId }, "No graph ID - cannot generate update");
1792
1858
  return;
1793
1859
  }
1794
1860
  const newEventCount = this.events.length - this.statusUpdateState.lastEventCount;
@@ -1801,7 +1867,7 @@ var GraphSession = class {
1801
1867
  try {
1802
1868
  const streamHelper = getStreamHelper(this.sessionId);
1803
1869
  if (!streamHelper) {
1804
- logger5.warn(
1870
+ logger6.warn(
1805
1871
  { sessionId: this.sessionId },
1806
1872
  "No stream helper found - cannot send status update"
1807
1873
  );
@@ -1822,7 +1888,7 @@ var GraphSession = class {
1822
1888
  if (result.operations && result.operations.length > 0) {
1823
1889
  for (const op of result.operations) {
1824
1890
  if (!op || !op.type || !op.data || Object.keys(op.data).length === 0) {
1825
- logger5.warn(
1891
+ logger6.warn(
1826
1892
  {
1827
1893
  sessionId: this.sessionId,
1828
1894
  operation: op
@@ -1875,7 +1941,7 @@ var GraphSession = class {
1875
1941
  this.previousSummaries.shift();
1876
1942
  }
1877
1943
  if (!operation || !operation.type || !operation.ctx) {
1878
- logger5.warn(
1944
+ logger6.warn(
1879
1945
  {
1880
1946
  sessionId: this.sessionId,
1881
1947
  operation
@@ -1890,7 +1956,7 @@ var GraphSession = class {
1890
1956
  this.statusUpdateState.lastEventCount = this.events.length;
1891
1957
  }
1892
1958
  } catch (error) {
1893
- logger5.error(
1959
+ logger6.error(
1894
1960
  {
1895
1961
  sessionId: this.sessionId,
1896
1962
  error: error instanceof Error ? error.message : "Unknown error",
@@ -1928,7 +1994,7 @@ var GraphSession = class {
1928
1994
  this.releaseUpdateLock();
1929
1995
  }
1930
1996
  } catch (error) {
1931
- logger5.error(
1997
+ logger6.error(
1932
1998
  {
1933
1999
  sessionId: this.sessionId,
1934
2000
  error: error instanceof Error ? error.message : "Unknown error"
@@ -2005,7 +2071,7 @@ User's Question/Context:
2005
2071
  ${conversationHistory}
2006
2072
  ` : "";
2007
2073
  } catch (error) {
2008
- logger5.warn(
2074
+ logger6.warn(
2009
2075
  { sessionId: this.sessionId, error },
2010
2076
  "Failed to fetch conversation history for status update"
2011
2077
  );
@@ -2057,7 +2123,7 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
2057
2123
  return text.trim();
2058
2124
  } catch (error) {
2059
2125
  agentsCore.setSpanWithError(span, error);
2060
- logger5.error({ error }, "Failed to generate summary, using fallback");
2126
+ logger6.error({ error }, "Failed to generate summary, using fallback");
2061
2127
  return this.generateFallbackSummary(newEvents, elapsedTime);
2062
2128
  } finally {
2063
2129
  span.end();
@@ -2103,7 +2169,7 @@ User's Question/Context:
2103
2169
  ${conversationHistory}
2104
2170
  ` : "";
2105
2171
  } catch (error) {
2106
- logger5.warn(
2172
+ logger6.warn(
2107
2173
  { sessionId: this.sessionId, error },
2108
2174
  "Failed to fetch conversation history for structured status update"
2109
2175
  );
@@ -2146,9 +2212,11 @@ Rules:
2146
2212
  - Labels MUST contain the ACTUAL information discovered ("Found X", "Learned Y", "Discovered Z requires A")
2147
2213
  - DO NOT use action words like "Searching", "Processing", "Analyzing" - state what was FOUND
2148
2214
  - Include specific details, numbers, requirements, or insights discovered
2149
- - You are ONE AI (no agents/delegations)
2150
- - Anonymize all internal operations so that the information appears descriptive and USER FRIENDLY. HIDE INTERNAL OPERATIONS!
2151
- - Bad examples: "Searching docs", "Processing request", "Status update", or not using the no_relevant_updates: e.g. "No New Updates", "No new info to report"
2215
+ - You are ONE unified AI system - NEVER mention agents, transfers, delegations, or routing
2216
+ - CRITICAL: NEVER use the words "transfer", "delegation", "agent", "routing", or any internal system terminology in labels
2217
+ - Present all operations as seamless actions by a single system
2218
+ - Anonymize all internal operations so that the information appears descriptive and USER FRIENDLY. HIDE ALL INTERNAL OPERATIONS!
2219
+ - Bad examples: "Transferring to search agent", "Delegating task", "Routing request", "Processing request", or not using the no_relevant_updates
2152
2220
  - Good examples: "Slack bot needs admin privileges", "Found 3-step OAuth flow required", "Channel limit is 500 per workspace", or use the no_relevant_updates component if nothing new to report.
2153
2221
 
2154
2222
  REMEMBER YOU CAN ONLY USE 'no_relevant_updates' ALONE! IT CANNOT BE CONCATENATED WITH OTHER STATUS UPDATES!
@@ -2202,7 +2270,7 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
2202
2270
  return { operations };
2203
2271
  } catch (error) {
2204
2272
  agentsCore.setSpanWithError(span, error);
2205
- logger5.error({ error }, "Failed to generate structured update, using fallback");
2273
+ logger6.error({ error }, "Failed to generate structured update, using fallback");
2206
2274
  return { operations: [] };
2207
2275
  } finally {
2208
2276
  span.end();
@@ -2309,8 +2377,7 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
2309
2377
  case "transfer": {
2310
2378
  const data = event.data;
2311
2379
  activities.push(
2312
- `\u{1F504} **Transfer**: ${data.fromAgent} \u2192 ${data.targetAgent}
2313
- ${data.reason ? `Reason: ${data.reason}` : "Control transfer"}
2380
+ `\u{1F504} **Continuing**: ${data.reason || "Processing request"}
2314
2381
  ${data.context ? `Context: ${JSON.stringify(data.context, null, 2)}` : ""}`
2315
2382
  );
2316
2383
  break;
@@ -2318,8 +2385,7 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
2318
2385
  case "delegation_sent": {
2319
2386
  const data = event.data;
2320
2387
  activities.push(
2321
- `\u{1F4E4} **Delegation Sent** [${data.delegationId}]: ${data.fromAgent} \u2192 ${data.targetAgent}
2322
- Task: ${data.taskDescription}
2388
+ `\u{1F4E4} **Processing**: ${data.taskDescription}
2323
2389
  ${data.context ? `Context: ${JSON.stringify(data.context, null, 2)}` : ""}`
2324
2390
  );
2325
2391
  break;
@@ -2327,7 +2393,7 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
2327
2393
  case "delegation_returned": {
2328
2394
  const data = event.data;
2329
2395
  activities.push(
2330
- `\u{1F4E5} **Delegation Returned** [${data.delegationId}]: ${data.fromAgent} \u2190 ${data.targetAgent}
2396
+ `\u{1F4E5} **Completed subtask**
2331
2397
  Result: ${JSON.stringify(data.result, null, 2)}`
2332
2398
  );
2333
2399
  break;
@@ -2346,16 +2412,16 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
2346
2412
  case "agent_reasoning": {
2347
2413
  const data = event.data;
2348
2414
  activities.push(
2349
- `\u2699\uFE0F **Reasoning**: reasoning
2350
- Full Details: ${JSON.stringify(data.parts, null, 2)}`
2415
+ `\u2699\uFE0F **Analyzing request**
2416
+ Details: ${JSON.stringify(data.parts, null, 2)}`
2351
2417
  );
2352
2418
  break;
2353
2419
  }
2354
2420
  case "agent_generate": {
2355
2421
  const data = event.data;
2356
2422
  activities.push(
2357
- `\u2699\uFE0F **Generation**: ${data.generationType}
2358
- Full Details: ${JSON.stringify(data.parts, null, 2)}`
2423
+ `\u2699\uFE0F **Preparing response**
2424
+ Details: ${JSON.stringify(data.parts, null, 2)}`
2359
2425
  );
2360
2426
  break;
2361
2427
  }
@@ -2529,7 +2595,7 @@ Make it specific and relevant.`;
2529
2595
  taskId: artifactData.taskId,
2530
2596
  artifacts: [artifactToSave]
2531
2597
  });
2532
- logger5.info(
2598
+ logger6.info(
2533
2599
  {
2534
2600
  sessionId: this.sessionId,
2535
2601
  artifactId: artifactData.artifactId,
@@ -2546,7 +2612,7 @@ Make it specific and relevant.`;
2546
2612
  span.setStatus({ code: api.SpanStatusCode.OK });
2547
2613
  } catch (error) {
2548
2614
  agentsCore.setSpanWithError(span, error);
2549
- logger5.error(
2615
+ logger6.error(
2550
2616
  {
2551
2617
  sessionId: this.sessionId,
2552
2618
  artifactId: artifactData.artifactId,
@@ -2582,7 +2648,7 @@ Make it specific and relevant.`;
2582
2648
  taskId: artifactData.taskId,
2583
2649
  artifacts: [fallbackArtifact]
2584
2650
  });
2585
- logger5.info(
2651
+ logger6.info(
2586
2652
  {
2587
2653
  sessionId: this.sessionId,
2588
2654
  artifactId: artifactData.artifactId
@@ -2591,7 +2657,7 @@ Make it specific and relevant.`;
2591
2657
  );
2592
2658
  }
2593
2659
  } catch (fallbackError) {
2594
- logger5.error(
2660
+ logger6.error(
2595
2661
  {
2596
2662
  sessionId: this.sessionId,
2597
2663
  artifactId: artifactData.artifactId,
@@ -2618,18 +2684,18 @@ var GraphSessionManager = class {
2618
2684
  const sessionId = messageId;
2619
2685
  const session = new GraphSession(sessionId, messageId, graphId, tenantId, projectId);
2620
2686
  this.sessions.set(sessionId, session);
2621
- logger5.info({ sessionId, messageId, graphId, tenantId, projectId }, "GraphSession created");
2687
+ logger6.info({ sessionId, messageId, graphId, tenantId, projectId }, "GraphSession created");
2622
2688
  return sessionId;
2623
2689
  }
2624
2690
  /**
2625
2691
  * Initialize status updates for a session
2626
2692
  */
2627
- initializeStatusUpdates(sessionId, config2, summarizerModel) {
2693
+ initializeStatusUpdates(sessionId, config, summarizerModel) {
2628
2694
  const session = this.sessions.get(sessionId);
2629
2695
  if (session) {
2630
- session.initializeStatusUpdates(config2, summarizerModel);
2696
+ session.initializeStatusUpdates(config, summarizerModel);
2631
2697
  } else {
2632
- logger5.error(
2698
+ logger6.error(
2633
2699
  {
2634
2700
  sessionId,
2635
2701
  availableSessions: Array.from(this.sessions.keys())
@@ -2650,7 +2716,7 @@ var GraphSessionManager = class {
2650
2716
  recordEvent(sessionId, eventType, agentId, data) {
2651
2717
  const session = this.sessions.get(sessionId);
2652
2718
  if (!session) {
2653
- logger5.warn({ sessionId }, "Attempted to record event in non-existent session");
2719
+ logger6.warn({ sessionId }, "Attempted to record event in non-existent session");
2654
2720
  return;
2655
2721
  }
2656
2722
  session.recordEvent(eventType, agentId, data);
@@ -2661,12 +2727,12 @@ var GraphSessionManager = class {
2661
2727
  endSession(sessionId) {
2662
2728
  const session = this.sessions.get(sessionId);
2663
2729
  if (!session) {
2664
- logger5.warn({ sessionId }, "Attempted to end non-existent session");
2730
+ logger6.warn({ sessionId }, "Attempted to end non-existent session");
2665
2731
  return [];
2666
2732
  }
2667
2733
  const events = session.getEvents();
2668
2734
  const summary = session.getSummary();
2669
- logger5.info({ sessionId, summary }, "GraphSession ended");
2735
+ logger6.info({ sessionId, summary }, "GraphSession ended");
2670
2736
  session.cleanup();
2671
2737
  this.sessions.delete(sessionId);
2672
2738
  return events;
@@ -2695,7 +2761,7 @@ var graphSessionManager = new GraphSessionManager();
2695
2761
 
2696
2762
  // src/utils/artifact-parser.ts
2697
2763
  init_dbClient();
2698
- var logger6 = agentsCore.getLogger("ArtifactParser");
2764
+ var logger7 = agentsCore.getLogger("ArtifactParser");
2699
2765
  var _ArtifactParser = class _ArtifactParser {
2700
2766
  constructor(tenantId) {
2701
2767
  this.tenantId = tenantId;
@@ -2711,9 +2777,7 @@ var _ArtifactParser = class _ArtifactParser {
2711
2777
  * More robust detection that handles streaming fragments
2712
2778
  */
2713
2779
  hasIncompleteArtifact(text) {
2714
- return /^.*<(?:artifact(?::ref)?|a(?:r(?:t(?:i(?:f(?:a(?:c(?:t(?::(?:r(?:e(?:f)?)?)?)?)?)?)?)?)?)?)?)?$/.test(
2715
- text
2716
- ) || /^.*<artifact:ref(?:[^>]*)$/.test(text) || // Incomplete artifact:ref at end
2780
+ return /<(a(r(t(i(f(a(c(t(:?(r(e(f)?)?)?)?)?)?)?)?)?)?)?)?$/.test(text) || /<artifact:ref[^>]+$/.test(text) || // Incomplete artifact ref at end
2717
2781
  this.findSafeTextBoundary(text) < text.length;
2718
2782
  }
2719
2783
  /**
@@ -2722,10 +2786,10 @@ var _ArtifactParser = class _ArtifactParser {
2722
2786
  */
2723
2787
  findSafeTextBoundary(text) {
2724
2788
  const endPatterns = [
2725
- /^.*<artifact:ref(?:[^/>]+(?:[^>]*[^/])?)?$/,
2789
+ /<artifact:ref(?![^>]*\/>).*$/,
2726
2790
  // artifact:ref that doesn't end with />
2727
- /^.*<(?:artifact(?::ref)?|a(?:r(?:t(?:i(?:f(?:a(?:c(?:t(?::(?:r(?:e(?:f)?)?)?)?)?)?)?)?)?)?)?)?$/
2728
- // Safe partial artifact pattern
2791
+ /<(a(r(t(i(f(a(c(t(:?(r(e(f)?)?)?)?)?)?)?)?)?)?)?)?$/
2792
+ // Any partial artifact pattern at end
2729
2793
  ];
2730
2794
  for (const pattern of endPatterns) {
2731
2795
  const match = text.match(pattern);
@@ -2761,7 +2825,7 @@ var _ArtifactParser = class _ArtifactParser {
2761
2825
  id: taskId
2762
2826
  });
2763
2827
  if (!task) {
2764
- logger6.warn({ taskId }, "Task not found when fetching artifacts");
2828
+ logger7.warn({ taskId }, "Task not found when fetching artifacts");
2765
2829
  continue;
2766
2830
  }
2767
2831
  const taskArtifacts = await agentsCore.getLedgerArtifacts(dbClient_default)({
@@ -2773,9 +2837,9 @@ var _ArtifactParser = class _ArtifactParser {
2773
2837
  artifacts.set(key, artifact);
2774
2838
  }
2775
2839
  }
2776
- logger6.debug({ contextId, count: artifacts.size }, "Loaded context artifacts");
2840
+ logger7.debug({ contextId, count: artifacts.size }, "Loaded context artifacts");
2777
2841
  } catch (error) {
2778
- logger6.error({ error, contextId }, "Error loading context artifacts");
2842
+ logger7.error({ error, contextId }, "Error loading context artifacts");
2779
2843
  }
2780
2844
  return artifacts;
2781
2845
  }
@@ -2878,7 +2942,7 @@ var _ArtifactParser = class _ArtifactParser {
2878
2942
  id: taskId
2879
2943
  });
2880
2944
  if (!task) {
2881
- logger6.warn({ taskId }, "Task not found when fetching artifact");
2945
+ logger7.warn({ taskId }, "Task not found when fetching artifact");
2882
2946
  return null;
2883
2947
  }
2884
2948
  const artifacts = await agentsCore.getLedgerArtifacts(dbClient_default)({
@@ -2890,7 +2954,7 @@ var _ArtifactParser = class _ArtifactParser {
2890
2954
  return this.formatArtifactData(artifacts[0], artifactId, taskId);
2891
2955
  }
2892
2956
  } catch (error) {
2893
- logger6.warn({ artifactId, taskId, error }, "Failed to fetch artifact");
2957
+ logger7.warn({ artifactId, taskId, error }, "Failed to fetch artifact");
2894
2958
  }
2895
2959
  return null;
2896
2960
  }
@@ -2926,11 +2990,11 @@ var _ArtifactParser = class _ArtifactParser {
2926
2990
  __publicField(_ArtifactParser, "ARTIFACT_REGEX", /<artifact:ref\s+id="([^"]*?)"\s+task="([^"]*?)"\s*\/>/gs);
2927
2991
  __publicField(_ArtifactParser, "ARTIFACT_CHECK_REGEX", /<artifact:ref\s+(?=.*id="[^"]+")(?=.*task="[^"]+")[^>]*\/>/);
2928
2992
  // Regex for catching any partial artifact pattern (< + any prefix of "artifact:ref")
2929
- __publicField(_ArtifactParser, "INCOMPLETE_ARTIFACT_REGEX", /<(a(r(t(i(f(a(c(t(:(r(e(f?)?)?)?)?)?)?)?)?)?)?)?)?$/g);
2993
+ __publicField(_ArtifactParser, "INCOMPLETE_ARTIFACT_REGEX", /<(a(r(t(i(f(a(c(t(:?(r(e(f)?)?)?)?)?)?)?)?)?)?)?)?$/g);
2930
2994
  var ArtifactParser = _ArtifactParser;
2931
2995
 
2932
2996
  // src/utils/incremental-stream-parser.ts
2933
- var logger7 = agentsCore.getLogger("IncrementalStreamParser");
2997
+ var logger8 = agentsCore.getLogger("IncrementalStreamParser");
2934
2998
  var IncrementalStreamParser = class {
2935
2999
  constructor(streamHelper, tenantId, contextId) {
2936
3000
  __publicField(this, "buffer", "");
@@ -2990,13 +3054,19 @@ var IncrementalStreamParser = class {
2990
3054
  if (part.type === "tool-call-delta" && part.toolName === targetToolName) {
2991
3055
  const delta = part.argsTextDelta || "";
2992
3056
  if (jsonBuffer.length + delta.length > MAX_BUFFER_SIZE) {
2993
- logger7.warn({ bufferSize: jsonBuffer.length + delta.length, maxSize: MAX_BUFFER_SIZE }, "JSON buffer exceeded maximum size, truncating");
3057
+ logger8.warn(
3058
+ { bufferSize: jsonBuffer.length + delta.length, maxSize: MAX_BUFFER_SIZE },
3059
+ "JSON buffer exceeded maximum size, truncating"
3060
+ );
2994
3061
  jsonBuffer = jsonBuffer.slice(-MAX_BUFFER_SIZE / 2);
2995
3062
  }
2996
3063
  jsonBuffer += delta;
2997
3064
  for (const char of delta) {
2998
3065
  if (componentBuffer.length > MAX_BUFFER_SIZE) {
2999
- logger7.warn({ bufferSize: componentBuffer.length, maxSize: MAX_BUFFER_SIZE }, "Component buffer exceeded maximum size, resetting");
3066
+ logger8.warn(
3067
+ { bufferSize: componentBuffer.length, maxSize: MAX_BUFFER_SIZE },
3068
+ "Component buffer exceeded maximum size, resetting"
3069
+ );
3000
3070
  componentBuffer = "";
3001
3071
  depth = 0;
3002
3072
  continue;
@@ -3011,7 +3081,7 @@ var IncrementalStreamParser = class {
3011
3081
  if (componentMatch) {
3012
3082
  const MAX_COMPONENT_SIZE = 1024 * 1024;
3013
3083
  if (componentMatch[0].length > MAX_COMPONENT_SIZE) {
3014
- logger7.warn(
3084
+ logger8.warn(
3015
3085
  {
3016
3086
  size: componentMatch[0].length,
3017
3087
  maxSize: MAX_COMPONENT_SIZE
@@ -3024,7 +3094,7 @@ var IncrementalStreamParser = class {
3024
3094
  try {
3025
3095
  const component = JSON.parse(componentMatch[0]);
3026
3096
  if (typeof component !== "object" || !component.id) {
3027
- logger7.warn({ component }, "Invalid component structure, skipping");
3097
+ logger8.warn({ component }, "Invalid component structure, skipping");
3028
3098
  componentBuffer = "";
3029
3099
  continue;
3030
3100
  }
@@ -3037,7 +3107,7 @@ var IncrementalStreamParser = class {
3037
3107
  componentsStreamed++;
3038
3108
  componentBuffer = "";
3039
3109
  } catch (e) {
3040
- logger7.debug({ error: e }, "Failed to parse component, continuing to accumulate");
3110
+ logger8.debug({ error: e }, "Failed to parse component, continuing to accumulate");
3041
3111
  }
3042
3112
  }
3043
3113
  }
@@ -3054,7 +3124,7 @@ var IncrementalStreamParser = class {
3054
3124
  break;
3055
3125
  }
3056
3126
  }
3057
- logger7.debug({ componentsStreamed }, "Finished streaming components");
3127
+ logger8.debug({ componentsStreamed }, "Finished streaming components");
3058
3128
  }
3059
3129
  /**
3060
3130
  * Legacy method for backward compatibility - defaults to text processing
@@ -3198,7 +3268,7 @@ var IncrementalStreamParser = class {
3198
3268
  };
3199
3269
 
3200
3270
  // src/utils/response-formatter.ts
3201
- var logger8 = agentsCore.getLogger("ResponseFormatter");
3271
+ var logger9 = agentsCore.getLogger("ResponseFormatter");
3202
3272
  var ResponseFormatter = class {
3203
3273
  constructor(tenantId) {
3204
3274
  __publicField(this, "artifactParser");
@@ -3229,7 +3299,7 @@ var ResponseFormatter = class {
3229
3299
  return { parts };
3230
3300
  } catch (error) {
3231
3301
  agentsCore.setSpanWithError(span, error);
3232
- logger8.error({ error, responseObject }, "Error formatting object response");
3302
+ logger9.error({ error, responseObject }, "Error formatting object response");
3233
3303
  return {
3234
3304
  parts: [{ kind: "data", data: responseObject }]
3235
3305
  };
@@ -3280,7 +3350,7 @@ var ResponseFormatter = class {
3280
3350
  return { parts };
3281
3351
  } catch (error) {
3282
3352
  agentsCore.setSpanWithError(span, error);
3283
- logger8.error({ error, responseText }, "Error formatting response");
3353
+ logger9.error({ error, responseText }, "Error formatting response");
3284
3354
  return { text: responseText };
3285
3355
  } finally {
3286
3356
  span.end();
@@ -3325,7 +3395,7 @@ var ResponseFormatter = class {
3325
3395
  }
3326
3396
  }
3327
3397
  };
3328
- var logger9 = agentsCore.getLogger("ToolSessionManager");
3398
+ var logger10 = agentsCore.getLogger("ToolSessionManager");
3329
3399
  var _ToolSessionManager = class _ToolSessionManager {
3330
3400
  // 5 minutes
3331
3401
  constructor() {
@@ -3354,7 +3424,7 @@ var _ToolSessionManager = class _ToolSessionManager {
3354
3424
  createdAt: Date.now()
3355
3425
  };
3356
3426
  this.sessions.set(sessionId, session);
3357
- logger9.debug({ sessionId, tenantId, contextId, taskId }, "Created tool session");
3427
+ logger10.debug({ sessionId, tenantId, contextId, taskId }, "Created tool session");
3358
3428
  return sessionId;
3359
3429
  }
3360
3430
  /**
@@ -3363,7 +3433,7 @@ var _ToolSessionManager = class _ToolSessionManager {
3363
3433
  recordToolResult(sessionId, toolResult) {
3364
3434
  const session = this.sessions.get(sessionId);
3365
3435
  if (!session) {
3366
- logger9.warn(
3436
+ logger10.warn(
3367
3437
  { sessionId, toolCallId: toolResult.toolCallId },
3368
3438
  "Tool result recorded for unknown session"
3369
3439
  );
@@ -3377,12 +3447,12 @@ var _ToolSessionManager = class _ToolSessionManager {
3377
3447
  getToolResult(sessionId, toolCallId) {
3378
3448
  const session = this.sessions.get(sessionId);
3379
3449
  if (!session) {
3380
- logger9.warn({ sessionId, toolCallId }, "Requested tool result for unknown session");
3450
+ logger10.warn({ sessionId, toolCallId }, "Requested tool result for unknown session");
3381
3451
  return void 0;
3382
3452
  }
3383
3453
  const result = session.toolResults.get(toolCallId);
3384
3454
  if (!result) {
3385
- logger9.warn(
3455
+ logger10.warn(
3386
3456
  {
3387
3457
  sessionId,
3388
3458
  toolCallId,
@@ -3421,10 +3491,10 @@ var _ToolSessionManager = class _ToolSessionManager {
3421
3491
  }
3422
3492
  for (const sessionId of expiredSessions) {
3423
3493
  this.sessions.delete(sessionId);
3424
- logger9.debug({ sessionId }, "Cleaned up expired tool session");
3494
+ logger10.debug({ sessionId }, "Cleaned up expired tool session");
3425
3495
  }
3426
3496
  if (expiredSessions.length > 0) {
3427
- logger9.info({ expiredCount: expiredSessions.length }, "Cleaned up expired tool sessions");
3497
+ logger10.info({ expiredCount: expiredSessions.length }, "Cleaned up expired tool sessions");
3428
3498
  }
3429
3499
  }
3430
3500
  };
@@ -3433,7 +3503,7 @@ var ToolSessionManager = _ToolSessionManager;
3433
3503
  var toolSessionManager = ToolSessionManager.getInstance();
3434
3504
 
3435
3505
  // src/agents/artifactTools.ts
3436
- var logger10 = agentsCore.getLogger("artifactTools");
3506
+ var logger11 = agentsCore.getLogger("artifactTools");
3437
3507
  function buildKeyNestingMap(data, prefix = "", map = /* @__PURE__ */ new Map()) {
3438
3508
  if (typeof data === "object" && data !== null) {
3439
3509
  if (Array.isArray(data)) {
@@ -3487,7 +3557,7 @@ function analyzeSelectorFailure(data, selector) {
3487
3557
  if (keyNestingMap.has(part)) {
3488
3558
  const allPaths = keyNestingMap.get(part);
3489
3559
  const relevantPaths = allPaths.filter(
3490
- (path2) => path2.includes(validPath) || validPath === ""
3560
+ (path) => path.includes(validPath) || validPath === ""
3491
3561
  );
3492
3562
  if (relevantPaths.length > 0) {
3493
3563
  suggestions.push(`"${part}" exists at: ${relevantPaths.slice(0, 3).join(", ")}`);
@@ -3504,7 +3574,7 @@ function analyzeSelectorFailure(data, selector) {
3504
3574
  analysis.push("PATH VALID BUT FILTER FAILED");
3505
3575
  const allPaths = keyNestingMap.get(targetKey);
3506
3576
  const deeperPaths = allPaths.filter(
3507
- (path2) => path2.length > selector.replace(/\[.*?\]/g, "").length
3577
+ (path) => path.length > selector.replace(/\[.*?\]/g, "").length
3508
3578
  );
3509
3579
  if (deeperPaths.length > 0) {
3510
3580
  suggestions.push(
@@ -3536,7 +3606,7 @@ function createPropSelectorsSchema(artifactComponents) {
3536
3606
  Object.entries(summaryProps.properties).forEach(([propName, propDef]) => {
3537
3607
  const propDescription = propDef?.description || propDef?.title || `${propName} property`;
3538
3608
  propSchema[propName] = z5__default.default.string().describe(
3539
- `JMESPath selector for ${propName} (${propDescription}) - summary version, relative to base selector`
3609
+ `JMESPath selector for ${propName} (${propDescription}) - summary version, MUST be relative to your baseSelector target level. Access fields WITHIN the items your baseSelector returns.`
3540
3610
  );
3541
3611
  });
3542
3612
  }
@@ -3548,7 +3618,7 @@ function createPropSelectorsSchema(artifactComponents) {
3548
3618
  if (!propSchema[propName]) {
3549
3619
  const propDescription = propDef?.description || propDef?.title || `${propName} property`;
3550
3620
  propSchema[propName] = z5__default.default.string().describe(
3551
- `JMESPath selector for ${propName} (${propDescription}) - full version, relative to base selector`
3621
+ `JMESPath selector for ${propName} (${propDescription}) - MUST be relative to your baseSelector target level. If baseSelector stops at a document, this accesses fields WITHIN that document. Examples: "title", "content.body", "metadata.author"`
3552
3622
  );
3553
3623
  }
3554
3624
  });
@@ -3562,7 +3632,26 @@ function createPropSelectorsSchema(artifactComponents) {
3562
3632
  return z5__default.default.union(propSelectorSchemas);
3563
3633
  }
3564
3634
  return z5__default.default.record(z5__default.default.string(), z5__default.default.string()).describe(
3565
- "Prop selectors mapping schema properties to JMESPath expressions relative to base selector"
3635
+ `Prop selectors mapping schema properties to JMESPath expressions relative to base selector. Each path is relative to the item(s) your baseSelector returns.
3636
+
3637
+ \u{1F3AF} CRITICAL: PropSelectors work ONLY on the data your baseSelector returns!
3638
+ If baseSelector = "result.docs[0]" \u2192 propSelectors access fields INSIDE that doc
3639
+ If baseSelector = "result.docs[0].content[0]" \u2192 propSelectors access fields INSIDE that content item
3640
+
3641
+ \u2705 CORRECT EXAMPLES (paths relative to baseSelector target):
3642
+ \u2022 baseSelector: "result.documents[?type=='article']" \u2192 propSelectors: {"title": "title", "url": "url"}
3643
+ \u2022 baseSelector: "result.content[0].text" \u2192 propSelectors: {"content": "content[0].text", "source": "content[0].source"}
3644
+ \u2022 baseSelector: "result.items" \u2192 propSelectors: {"name": "profile.name", "email": "contact.email"}
3645
+
3646
+ \u274C WRONG EXAMPLES (accessing data not at baseSelector level):
3647
+ \u2022 baseSelector: "result.docs[0].content[0]" \u2192 propSelectors: {"title": "title"} \u2190 title is at doc level, not content level!
3648
+ \u2022 baseSelector: "result.source.content" \u2192 propSelectors: {"title": "content[4].text"} \u2190 baseSelector ends at array, can't index into it!
3649
+ \u2022 baseSelector: "result.items" \u2192 propSelectors: {"title": "documents[0].title"} \u2190 going deeper when baseSelector should handle depth
3650
+
3651
+ \u274C NEVER USE LITERAL VALUES:
3652
+ {"title": "Robert Tran", "url": "https://linkedin.com/..."}
3653
+
3654
+ \u{1F4A1} TIP: Match your baseSelector depth to where the properties you need actually exist!`
3566
3655
  );
3567
3656
  }
3568
3657
  function createInputSchema(artifactComponents) {
@@ -3571,7 +3660,18 @@ function createInputSchema(artifactComponents) {
3571
3660
  "EXACT toolCallId from a previous tool execution - copy it exactly from the tool call result. NEVER invent or make up tool call IDs."
3572
3661
  ),
3573
3662
  baseSelector: z5__default.default.string().describe(
3574
- `JMESPath selector to get to the main data array/object. ALWAYS start with "result." Example: "result.content[?type=='text']"`
3663
+ `JMESPath selector to get to the main data array/object. ALWAYS start with "result." That is a mandatory prefix.
3664
+
3665
+ Data structures are COMPLEX and NESTED. Examples:
3666
+ \u2022 "result.content[0].text.content[2]" - parsed JSON in text field
3667
+ \u2022 "result.structuredContent.content[1]" - direct structured data
3668
+ \u2022 "result.data.items[?type=='doc']" - filtered array
3669
+
3670
+ \u{1F6A8} CRITICAL: If you need data from array[4], your baseSelector must END at array[4], NOT at the array itself!
3671
+ \u2705 CORRECT: "result.source.content[4]" \u2192 propSelectors can access fields in that item
3672
+ \u274C WRONG: "result.source.content" \u2192 propSelectors can't use content[4] because baseSelector already selected the array
3673
+
3674
+ \u{1F525} IF YOUR PATH FAILS: READ THE ERROR MESSAGE! It tells you the correct path! \u{1F525}`
3575
3675
  ),
3576
3676
  propSelectors: createPropSelectorsSchema(artifactComponents)
3577
3677
  });
@@ -3590,6 +3690,9 @@ function createSaveToolResultTool(sessionId, streamRequestId, agentId, artifactC
3590
3690
  return ai.tool({
3591
3691
  description: `Save tool results as structured artifacts. Each artifact should represent ONE SPECIFIC, IMPORTANT, and UNIQUE document or data item.
3592
3692
 
3693
+ \u26A1 CRITICAL: JSON-like text content in tool results is AUTOMATICALLY PARSED into proper JSON objects - treat all data as structured, not text strings.
3694
+ \u{1F6A8} CRITICAL: Data structures are deeply nested. When your path fails, READ THE ERROR MESSAGE - it shows the correct path!
3695
+
3593
3696
  AVAILABLE ARTIFACT TYPES:
3594
3697
  ${availableTypesWithDescriptions}
3595
3698
 
@@ -3601,26 +3704,6 @@ Each artifact you save becomes a SEPARATE DATA COMPONENT in the structured respo
3601
3704
  \u2705 UNIQUE with distinct value from other artifacts
3602
3705
  \u2705 RENDERED AS INDIVIDUAL DATA COMPONENT in the UI
3603
3706
 
3604
- \u274C DO NOT save multiple different items in one artifact unless they are EXTREMELY SIMILAR
3605
- \u274C DO NOT batch unrelated items together - each item becomes its own data component
3606
- \u274C DO NOT save generic collections - break them into individual data components
3607
-
3608
- \u{1F3AF} STRUCTURED DATA COMPONENT PRINCIPLE:
3609
- Each artifact save creates ONE data component that will be rendered separately in the UI. If you have 5 important items, save them as 5 separate artifacts to create 5 separate data components for better user experience.
3610
-
3611
- THINK: "What is the ONE most important piece of information here that deserves its own data component?"
3612
-
3613
- EXAMPLES OF GOOD INDIVIDUAL ARTIFACTS (SEPARATE DATA COMPONENTS):
3614
- - Nick Gomez's founder profile (specific person) \u2192 Individual data component
3615
- - The /users/create API endpoint documentation (specific endpoint) \u2192 Individual data component
3616
- - Error message for authentication failure (specific error type) \u2192 Individual data component
3617
- - Configuration for Redis caching (specific config topic) \u2192 Individual data component
3618
-
3619
- EXAMPLES OF BAD BATCHING:
3620
- \u274C "All team members" \u2192 Should be separate artifacts for each important member (separate data components)
3621
- \u274C "All API endpoints" \u2192 Should be separate artifacts for each distinct endpoint (separate data components)
3622
- \u274C "All error types" \u2192 Should be separate artifacts for each error category (separate data components)
3623
-
3624
3707
  USAGE PATTERN:
3625
3708
  1. baseSelector: Navigate through nested structures to target ONE SPECIFIC item
3626
3709
  - Navigate through all necessary levels: "result.data.items.nested[?condition]"
@@ -3630,9 +3713,11 @@ USAGE PATTERN:
3630
3713
  - NOT: "result.items[*]" (too broad, gets everything)
3631
3714
 
3632
3715
  2. propSelectors: Extract properties relative to your selected item
3633
- - Always relative to the single item that baseSelector returns
3634
- - Simple paths from that item: { prop1: "field_x", prop2: "nested.field_y", prop3: "deep.nested.field_z" }
3635
- - The tool handles array iteration - your selectors work on individual items
3716
+ - \u{1F3AF} CRITICAL: Always relative to the single item that baseSelector returns
3717
+ - If baseSelector ends at a document \u2192 propSelectors access document fields
3718
+ - If baseSelector ends at content[0] \u2192 propSelectors access content[0] fields
3719
+ - Simple paths from that exact level: { prop1: "field_x", prop2: "nested.field_y" }
3720
+ - \u274C DON'T try to go back up or deeper - adjust your baseSelector instead!
3636
3721
 
3637
3722
  3. Result: ONE artifact representing ONE important, unique item \u2192 ONE data component
3638
3723
 
@@ -3641,20 +3726,12 @@ USAGE PATTERN:
3641
3726
  - Focus on getting to the right level with baseSelector, then keep propSelectors simple
3642
3727
  - Test your baseSelector: Does it return exactly the items you want?
3643
3728
 
3644
- \u26A0\uFE0F STRICT SELECTIVITY RULES FOR DATA COMPONENTS:
3645
- - ALWAYS ask: "Is this ONE specific, important thing that deserves its own data component?"
3646
- - If the answer is no, don't save it or find a more specific selector
3647
- - Multiple similar items = Multiple separate artifact saves (use the tool multiple times) \u2192 Multiple data components
3648
- - Each artifact should be independently valuable and uniquely identifiable \u2192 Each data component stands alone
3649
- - BETTER to save 3 individual, specific artifacts (3 data components) than 1 generic collection (1 data component)
3650
-
3651
- \u{1F504} MULTIPLE ARTIFACTS = MULTIPLE DATA COMPONENTS:
3652
- Remember: Each time you call this tool, you create a separate data component. Call it multiple times for multiple items to create a rich, structured response with individual data components for each important piece of information.`,
3729
+ Please use Error Messages to Debug when there is an error in the tool call.`,
3653
3730
  inputSchema,
3654
3731
  execute: async ({ toolCallId, baseSelector, propSelectors, ...rest }, _context) => {
3655
3732
  const artifactType = "artifactType" in rest ? rest.artifactType : void 0;
3656
3733
  if (!sessionId) {
3657
- logger10.warn({ toolCallId }, "No session ID provided to save_tool_result");
3734
+ logger11.warn({ toolCallId }, "No session ID provided to save_tool_result");
3658
3735
  return {
3659
3736
  saved: false,
3660
3737
  error: `[toolCallId: ${toolCallId}] No session context available`,
@@ -3664,7 +3741,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
3664
3741
  }
3665
3742
  const toolResult = toolSessionManager.getToolResult(sessionId, toolCallId);
3666
3743
  if (!toolResult) {
3667
- logger10.warn({ toolCallId, sessionId }, "Tool result not found in session");
3744
+ logger11.warn({ toolCallId, sessionId }, "Tool result not found in session");
3668
3745
  return {
3669
3746
  saved: false,
3670
3747
  error: `[toolCallId: ${toolCallId}] Tool result not found`,
@@ -3677,7 +3754,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
3677
3754
  const baseData = jmespath__default.default.search(parsedResult, baseSelector);
3678
3755
  if (!baseData || Array.isArray(baseData) && baseData.length === 0) {
3679
3756
  const debugInfo = analyzeSelectorFailure(parsedResult, baseSelector);
3680
- logger10.warn(
3757
+ logger11.warn(
3681
3758
  {
3682
3759
  baseSelector,
3683
3760
  toolCallId,
@@ -3720,7 +3797,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
3720
3797
  const fallbackValue = item[propName];
3721
3798
  if (fallbackValue !== null && fallbackValue !== void 0) {
3722
3799
  extractedItem[propName] = fallbackValue;
3723
- logger10.info(
3800
+ logger11.info(
3724
3801
  { propName, propSelector, context },
3725
3802
  `PropSelector failed, used fallback direct property access`
3726
3803
  );
@@ -3732,7 +3809,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
3732
3809
  const fallbackValue = item[propName];
3733
3810
  if (fallbackValue !== null && fallbackValue !== void 0) {
3734
3811
  extractedItem[propName] = fallbackValue;
3735
- logger10.warn(
3812
+ logger11.warn(
3736
3813
  { propName, propSelector, context, error: error.message },
3737
3814
  `PropSelector syntax error, used fallback direct property access`
3738
3815
  );
@@ -3845,7 +3922,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
3845
3922
  warnings
3846
3923
  };
3847
3924
  } catch (error) {
3848
- logger10.error({ error, toolCallId, sessionId }, "Error processing save_tool_result");
3925
+ logger11.error({ error, toolCallId, sessionId }, "Error processing save_tool_result");
3849
3926
  return {
3850
3927
  saved: false,
3851
3928
  error: `[toolCallId: ${toolCallId}] ${error instanceof Error ? error.message : "Unknown error"}`,
@@ -3857,7 +3934,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
3857
3934
  }
3858
3935
 
3859
3936
  // src/a2a/client.ts
3860
- var logger11 = agentsCore.getLogger("a2aClient");
3937
+ var logger12 = agentsCore.getLogger("a2aClient");
3861
3938
  var DEFAULT_BACKOFF = {
3862
3939
  initialInterval: 500,
3863
3940
  maxInterval: 6e4,
@@ -3998,17 +4075,17 @@ var A2AClient = class {
3998
4075
  * Retry utility functions
3999
4076
  */
4000
4077
  async retry(fetchFn) {
4001
- const config2 = this.options.retryConfig;
4002
- if (!config2 || config2.strategy === "none") {
4078
+ const config = this.options.retryConfig;
4079
+ if (!config || config.strategy === "none") {
4003
4080
  return await fetchFn();
4004
4081
  }
4005
- const statusCodes = config2.statusCodes || DEFAULT_RETRY_STATUS_CODES;
4082
+ const statusCodes = config.statusCodes || DEFAULT_RETRY_STATUS_CODES;
4006
4083
  return this.retryBackoff(
4007
4084
  this.wrapFetcher(fetchFn, {
4008
4085
  statusCodes,
4009
- retryConnectionErrors: !!config2.retryConnectionErrors
4086
+ retryConnectionErrors: !!config.retryConnectionErrors
4010
4087
  }),
4011
- config2.backoff ?? DEFAULT_BACKOFF
4088
+ config.backoff ?? DEFAULT_BACKOFF
4012
4089
  );
4013
4090
  }
4014
4091
  wrapFetcher(fn, options) {
@@ -4063,7 +4140,7 @@ var A2AClient = class {
4063
4140
  try {
4064
4141
  const res = await fn();
4065
4142
  if (attempt > 0) {
4066
- logger11.info(
4143
+ logger12.info(
4067
4144
  {
4068
4145
  attempts: attempt + 1,
4069
4146
  elapsedTime: Date.now() - start
@@ -4078,7 +4155,7 @@ var A2AClient = class {
4078
4155
  }
4079
4156
  const elapsed = Date.now() - start;
4080
4157
  if (elapsed > maxElapsedTime) {
4081
- logger11.warn(
4158
+ logger12.warn(
4082
4159
  {
4083
4160
  attempts: attempt + 1,
4084
4161
  elapsedTime: elapsed,
@@ -4099,7 +4176,7 @@ var A2AClient = class {
4099
4176
  retryInterval = initialInterval * attempt ** exponent + Math.random() * 1e3;
4100
4177
  }
4101
4178
  const delayMs = Math.min(retryInterval, maxInterval);
4102
- logger11.info(
4179
+ logger12.info(
4103
4180
  {
4104
4181
  attempt: attempt + 1,
4105
4182
  delayMs,
@@ -4184,7 +4261,7 @@ var A2AClient = class {
4184
4261
  }
4185
4262
  const rpcResponse = await httpResponse.json();
4186
4263
  if (rpcResponse.id !== requestId2) {
4187
- logger11.warn(
4264
+ logger12.warn(
4188
4265
  {
4189
4266
  method,
4190
4267
  expectedId: requestId2,
@@ -4383,7 +4460,7 @@ var A2AClient = class {
4383
4460
  try {
4384
4461
  while (true) {
4385
4462
  const { done, value } = await reader.read();
4386
- logger11.info({ done, value }, "parseA2ASseStream");
4463
+ logger12.info({ done, value }, "parseA2ASseStream");
4387
4464
  if (done) {
4388
4465
  if (eventDataBuffer.trim()) {
4389
4466
  const result = this._processSseEventData(
@@ -4472,26 +4549,26 @@ var A2AClient = class {
4472
4549
  // src/agents/relationTools.ts
4473
4550
  init_conversations();
4474
4551
  init_dbClient();
4475
- var logger12 = agentsCore.getLogger("relationships Tools");
4476
- var generateTransferToolDescription = (config2) => {
4477
- return `Hand off the conversation to agent ${config2.id}.
4552
+ var logger13 = agentsCore.getLogger("relationships Tools");
4553
+ var generateTransferToolDescription = (config) => {
4554
+ return `Hand off the conversation to agent ${config.id}.
4478
4555
 
4479
4556
  Agent Information:
4480
- - ID: ${config2.id}
4481
- - Name: ${config2.name ?? "No name provided"}
4482
- - Description: ${config2.description ?? "No description provided"}
4557
+ - ID: ${config.id}
4558
+ - Name: ${config.name ?? "No name provided"}
4559
+ - Description: ${config.description ?? "No description provided"}
4483
4560
 
4484
- Hand off the conversation to agent ${config2.id} when the user's request would be better handled by this specialized agent.`;
4561
+ Hand off the conversation to agent ${config.id} when the user's request would be better handled by this specialized agent.`;
4485
4562
  };
4486
- var generateDelegateToolDescription = (config2) => {
4563
+ var generateDelegateToolDescription = (config) => {
4487
4564
  return `Delegate a specific task to another agent.
4488
4565
 
4489
4566
  Agent Information:
4490
- - ID: ${config2.id}
4491
- - Name: ${config2.name}
4492
- - Description: ${config2.description || "No description provided"}
4567
+ - ID: ${config.id}
4568
+ - Name: ${config.name}
4569
+ - Description: ${config.description || "No description provided"}
4493
4570
 
4494
- Delegate a specific task to agent ${config2.id} when it seems like the agent can do relevant work.`;
4571
+ Delegate a specific task to agent ${config.id} when it seems like the agent can do relevant work.`;
4495
4572
  };
4496
4573
  var createTransferToAgentTool = ({
4497
4574
  transferConfig,
@@ -4510,7 +4587,7 @@ var createTransferToAgentTool = ({
4510
4587
  "transfer.to_agent_id": transferConfig.id ?? "unknown"
4511
4588
  });
4512
4589
  }
4513
- logger12.info(
4590
+ logger13.info(
4514
4591
  {
4515
4592
  transferTo: transferConfig.id ?? "unknown",
4516
4593
  fromAgent: callingAgentId
@@ -4658,7 +4735,7 @@ function createDelegateToAgentTool({
4658
4735
  ...isInternal ? { fromAgentId: callingAgentId } : { fromExternalAgentId: callingAgentId }
4659
4736
  }
4660
4737
  };
4661
- logger12.info({ messageToSend }, "messageToSend");
4738
+ logger13.info({ messageToSend }, "messageToSend");
4662
4739
  await agentsCore.createMessage(dbClient_default)({
4663
4740
  id: nanoid.nanoid(),
4664
4741
  tenantId,
@@ -4720,7 +4797,7 @@ function createDelegateToAgentTool({
4720
4797
  }
4721
4798
 
4722
4799
  // src/agents/SystemPromptBuilder.ts
4723
- var logger13 = agentsCore.getLogger("SystemPromptBuilder");
4800
+ var logger14 = agentsCore.getLogger("SystemPromptBuilder");
4724
4801
  var SystemPromptBuilder = class {
4725
4802
  constructor(version, versionConfig) {
4726
4803
  this.version = version;
@@ -4736,22 +4813,25 @@ var SystemPromptBuilder = class {
4736
4813
  this.templates.set(name, content);
4737
4814
  }
4738
4815
  this.loaded = true;
4739
- logger13.debug({ templateCount: this.templates.size, version: this.version }, `Loaded ${this.templates.size} templates for version ${this.version}`);
4816
+ logger14.debug(
4817
+ { templateCount: this.templates.size, version: this.version },
4818
+ `Loaded ${this.templates.size} templates for version ${this.version}`
4819
+ );
4740
4820
  } catch (error) {
4741
- logger13.error({ error }, `Failed to load templates for version ${this.version}`);
4821
+ logger14.error({ error }, `Failed to load templates for version ${this.version}`);
4742
4822
  throw new Error(`Template loading failed: ${error}`);
4743
4823
  }
4744
4824
  }
4745
- buildSystemPrompt(config2) {
4825
+ buildSystemPrompt(config) {
4746
4826
  this.loadTemplates();
4747
- this.validateTemplateVariables(config2);
4748
- return this.versionConfig.assemble(this.templates, config2);
4827
+ this.validateTemplateVariables(config);
4828
+ return this.versionConfig.assemble(this.templates, config);
4749
4829
  }
4750
- validateTemplateVariables(config2) {
4751
- if (!config2) {
4830
+ validateTemplateVariables(config) {
4831
+ if (!config) {
4752
4832
  throw new Error("Configuration object is required");
4753
4833
  }
4754
- if (typeof config2 !== "object") {
4834
+ if (typeof config !== "object") {
4755
4835
  throw new Error("Configuration must be an object");
4756
4836
  }
4757
4837
  }
@@ -4864,20 +4944,20 @@ var V1Config = class _V1Config {
4864
4944
  const firstItem = tools[0];
4865
4945
  return "usageGuidelines" in firstItem && !("config" in firstItem);
4866
4946
  }
4867
- assemble(templates, config2) {
4947
+ assemble(templates, config) {
4868
4948
  const systemPromptTemplate = templates.get("system-prompt");
4869
4949
  if (!systemPromptTemplate) {
4870
4950
  throw new Error("System prompt template not loaded");
4871
4951
  }
4872
4952
  let systemPrompt = systemPromptTemplate;
4873
- systemPrompt = systemPrompt.replace("{{CORE_INSTRUCTIONS}}", config2.corePrompt);
4874
- const graphContextSection = this.generateGraphContextSection(config2.graphPrompt);
4953
+ systemPrompt = systemPrompt.replace("{{CORE_INSTRUCTIONS}}", config.corePrompt);
4954
+ const graphContextSection = this.generateGraphContextSection(config.graphPrompt);
4875
4955
  systemPrompt = systemPrompt.replace("{{GRAPH_CONTEXT_SECTION}}", graphContextSection);
4876
- const toolData = this.isToolDataArray(config2.tools) ? config2.tools : _V1Config.convertMcpToolsToToolData(config2.tools);
4877
- const hasDataComponents = config2.dataComponents && config2.dataComponents.length > 0;
4956
+ const toolData = this.isToolDataArray(config.tools) ? config.tools : _V1Config.convertMcpToolsToToolData(config.tools);
4957
+ const hasDataComponents = config.dataComponents && config.dataComponents.length > 0;
4878
4958
  const artifactsSection = this.generateArtifactsSection(
4879
4959
  templates,
4880
- config2.artifacts,
4960
+ config.artifacts,
4881
4961
  hasDataComponents
4882
4962
  );
4883
4963
  systemPrompt = systemPrompt.replace("{{ARTIFACTS_SECTION}}", artifactsSection);
@@ -4885,20 +4965,20 @@ var V1Config = class _V1Config {
4885
4965
  systemPrompt = systemPrompt.replace("{{TOOLS_SECTION}}", toolsSection);
4886
4966
  const dataComponentsSection = this.generateDataComponentsSection(
4887
4967
  templates,
4888
- config2.dataComponents
4968
+ config.dataComponents
4889
4969
  );
4890
4970
  systemPrompt = systemPrompt.replace("{{DATA_COMPONENTS_SECTION}}", dataComponentsSection);
4891
4971
  const thinkingPreparationSection = this.generateThinkingPreparationSection(
4892
4972
  templates,
4893
- config2.isThinkingPreparation
4973
+ config.isThinkingPreparation
4894
4974
  );
4895
4975
  systemPrompt = systemPrompt.replace(
4896
4976
  "{{THINKING_PREPARATION_INSTRUCTIONS}}",
4897
4977
  thinkingPreparationSection
4898
4978
  );
4899
- const transferSection = this.generateTransferInstructions(config2.hasTransferRelations);
4979
+ const transferSection = this.generateTransferInstructions(config.hasTransferRelations);
4900
4980
  systemPrompt = systemPrompt.replace("{{TRANSFER_INSTRUCTIONS}}", transferSection);
4901
- const delegationSection = this.generateDelegationInstructions(config2.hasDelegateRelations);
4981
+ const delegationSection = this.generateDelegationInstructions(config.hasDelegateRelations);
4902
4982
  systemPrompt = systemPrompt.replace("{{DELEGATION_INSTRUCTIONS}}", delegationSection);
4903
4983
  return systemPrompt;
4904
4984
  }
@@ -5140,7 +5220,7 @@ function hasToolCallWithPrefix(prefix) {
5140
5220
  return false;
5141
5221
  };
5142
5222
  }
5143
- var logger14 = agentsCore.getLogger("Agent");
5223
+ var logger15 = agentsCore.getLogger("Agent");
5144
5224
  var CONSTANTS = {
5145
5225
  MAX_GENERATION_STEPS: 12,
5146
5226
  PHASE_1_TIMEOUT_MS: 27e4,
@@ -5162,7 +5242,7 @@ function isValidTool(tool4) {
5162
5242
  return tool4 && typeof tool4 === "object" && typeof tool4.description === "string" && tool4.inputSchema && typeof tool4.execute === "function";
5163
5243
  }
5164
5244
  var Agent = class {
5165
- constructor(config2, credentialStoreRegistry) {
5245
+ constructor(config, credentialStoreRegistry) {
5166
5246
  __publicField(this, "config");
5167
5247
  __publicField(this, "systemPromptBuilder", new SystemPromptBuilder("v1", new V1Config()));
5168
5248
  __publicField(this, "responseFormatter");
@@ -5174,26 +5254,26 @@ var Agent = class {
5174
5254
  __publicField(this, "isDelegatedAgent", false);
5175
5255
  __publicField(this, "contextResolver");
5176
5256
  __publicField(this, "credentialStoreRegistry");
5177
- this.artifactComponents = config2.artifactComponents || [];
5178
- let processedDataComponents = config2.dataComponents || [];
5179
- if (this.artifactComponents.length > 0 && config2.dataComponents && config2.dataComponents.length > 0) {
5257
+ this.artifactComponents = config.artifactComponents || [];
5258
+ let processedDataComponents = config.dataComponents || [];
5259
+ if (this.artifactComponents.length > 0 && config.dataComponents && config.dataComponents.length > 0) {
5180
5260
  processedDataComponents = [
5181
- ArtifactReferenceSchema.getDataComponent(config2.tenantId, config2.projectId),
5261
+ ArtifactReferenceSchema.getDataComponent(config.tenantId, config.projectId),
5182
5262
  ...processedDataComponents
5183
5263
  ];
5184
5264
  }
5185
5265
  this.config = {
5186
- ...config2,
5266
+ ...config,
5187
5267
  dataComponents: processedDataComponents,
5188
5268
  // Set default conversation history if not provided
5189
- conversationHistoryConfig: config2.conversationHistoryConfig || createDefaultConversationHistoryConfig()
5269
+ conversationHistoryConfig: config.conversationHistoryConfig || createDefaultConversationHistoryConfig()
5190
5270
  };
5191
- this.responseFormatter = new ResponseFormatter(config2.tenantId);
5271
+ this.responseFormatter = new ResponseFormatter(config.tenantId);
5192
5272
  this.credentialStoreRegistry = credentialStoreRegistry;
5193
5273
  if (credentialStoreRegistry) {
5194
5274
  this.contextResolver = new agentsCore.ContextResolver(
5195
- config2.tenantId,
5196
- config2.projectId,
5275
+ config.tenantId,
5276
+ config.projectId,
5197
5277
  dbClient_default,
5198
5278
  credentialStoreRegistry
5199
5279
  );
@@ -5393,14 +5473,14 @@ var Agent = class {
5393
5473
  for (const toolSet of tools) {
5394
5474
  for (const [toolName, originalTool] of Object.entries(toolSet)) {
5395
5475
  if (!isValidTool(originalTool)) {
5396
- logger14.error({ toolName }, "Invalid MCP tool structure - missing required properties");
5476
+ logger15.error({ toolName }, "Invalid MCP tool structure - missing required properties");
5397
5477
  continue;
5398
5478
  }
5399
5479
  const sessionWrappedTool = ai.tool({
5400
5480
  description: originalTool.description,
5401
5481
  inputSchema: originalTool.inputSchema,
5402
5482
  execute: async (args, { toolCallId }) => {
5403
- logger14.debug({ toolName, toolCallId }, "MCP Tool Called");
5483
+ logger15.debug({ toolName, toolCallId }, "MCP Tool Called");
5404
5484
  try {
5405
5485
  const result = await originalTool.execute(args, { toolCallId });
5406
5486
  toolSessionManager.recordToolResult(sessionId, {
@@ -5412,7 +5492,7 @@ var Agent = class {
5412
5492
  });
5413
5493
  return { result, toolCallId };
5414
5494
  } catch (error) {
5415
- logger14.error({ toolName, toolCallId, error }, "MCP tool execution failed");
5495
+ logger15.error({ toolName, toolCallId, error }, "MCP tool execution failed");
5416
5496
  throw error;
5417
5497
  }
5418
5498
  }
@@ -5497,7 +5577,7 @@ var Agent = class {
5497
5577
  selectedTools
5498
5578
  };
5499
5579
  }
5500
- logger14.info(
5580
+ logger15.info(
5501
5581
  {
5502
5582
  toolName: tool4.name,
5503
5583
  credentialReferenceId,
@@ -5537,7 +5617,7 @@ var Agent = class {
5537
5617
  async getResolvedContext(conversationId, requestContext) {
5538
5618
  try {
5539
5619
  if (!this.config.contextConfigId) {
5540
- logger14.debug({ graphId: this.config.graphId }, "No context config found for graph");
5620
+ logger15.debug({ graphId: this.config.graphId }, "No context config found for graph");
5541
5621
  return null;
5542
5622
  }
5543
5623
  const contextConfig = await agentsCore.getContextConfigById(dbClient_default)({
@@ -5545,7 +5625,7 @@ var Agent = class {
5545
5625
  id: this.config.contextConfigId
5546
5626
  });
5547
5627
  if (!contextConfig) {
5548
- logger14.warn({ contextConfigId: this.config.contextConfigId }, "Context config not found");
5628
+ logger15.warn({ contextConfigId: this.config.contextConfigId }, "Context config not found");
5549
5629
  return null;
5550
5630
  }
5551
5631
  if (!this.contextResolver) {
@@ -5562,7 +5642,7 @@ var Agent = class {
5562
5642
  $now: (/* @__PURE__ */ new Date()).toISOString(),
5563
5643
  $env: process.env
5564
5644
  };
5565
- logger14.debug(
5645
+ logger15.debug(
5566
5646
  {
5567
5647
  conversationId,
5568
5648
  contextConfigId: contextConfig.id,
@@ -5576,7 +5656,7 @@ var Agent = class {
5576
5656
  );
5577
5657
  return contextWithBuiltins;
5578
5658
  } catch (error) {
5579
- logger14.error(
5659
+ logger15.error(
5580
5660
  {
5581
5661
  conversationId,
5582
5662
  error: error instanceof Error ? error.message : "Unknown error"
@@ -5600,7 +5680,7 @@ var Agent = class {
5600
5680
  });
5601
5681
  return graphDefinition?.graphPrompt || void 0;
5602
5682
  } catch (error) {
5603
- logger14.warn(
5683
+ logger15.warn(
5604
5684
  {
5605
5685
  graphId: this.config.graphId,
5606
5686
  error: error instanceof Error ? error.message : "Unknown error"
@@ -5627,7 +5707,7 @@ var Agent = class {
5627
5707
  }
5628
5708
  return !!(graphDefinition.artifactComponents && Object.keys(graphDefinition.artifactComponents).length > 0);
5629
5709
  } catch (error) {
5630
- logger14.warn(
5710
+ logger15.warn(
5631
5711
  {
5632
5712
  graphId: this.config.graphId,
5633
5713
  tenantId: this.config.tenantId,
@@ -5687,7 +5767,7 @@ Key requirements:
5687
5767
  preserveUnresolved: false
5688
5768
  });
5689
5769
  } catch (error) {
5690
- logger14.error(
5770
+ logger15.error(
5691
5771
  {
5692
5772
  conversationId,
5693
5773
  error: error instanceof Error ? error.message : "Unknown error"
@@ -5732,7 +5812,7 @@ Key requirements:
5732
5812
  preserveUnresolved: false
5733
5813
  });
5734
5814
  } catch (error) {
5735
- logger14.error(
5815
+ logger15.error(
5736
5816
  {
5737
5817
  conversationId,
5738
5818
  error: error instanceof Error ? error.message : "Unknown error"
@@ -5741,7 +5821,7 @@ Key requirements:
5741
5821
  );
5742
5822
  }
5743
5823
  }
5744
- const config2 = {
5824
+ const config = {
5745
5825
  corePrompt: processedPrompt,
5746
5826
  graphPrompt,
5747
5827
  tools: toolDefinitions,
@@ -5751,7 +5831,7 @@ Key requirements:
5751
5831
  hasTransferRelations: (this.config.transferRelations?.length ?? 0) > 0,
5752
5832
  hasDelegateRelations: (this.config.delegateRelations?.length ?? 0) > 0
5753
5833
  };
5754
- return await this.systemPromptBuilder.buildSystemPrompt(config2);
5834
+ return await this.systemPromptBuilder.buildSystemPrompt(config);
5755
5835
  }
5756
5836
  getArtifactTools() {
5757
5837
  return ai.tool({
@@ -5760,7 +5840,7 @@ Key requirements:
5760
5840
  artifactId: z5.z.string().describe("The unique identifier of the artifact to get.")
5761
5841
  }),
5762
5842
  execute: async ({ artifactId }) => {
5763
- logger14.info({ artifactId }, "get_artifact executed");
5843
+ logger15.info({ artifactId }, "get_artifact executed");
5764
5844
  const artifact = await agentsCore.getLedgerArtifacts(dbClient_default)({
5765
5845
  scopes: {
5766
5846
  tenantId: this.config.tenantId,
@@ -5827,7 +5907,7 @@ Key requirements:
5827
5907
  graphId: this.config.graphId
5828
5908
  });
5829
5909
  } catch (error) {
5830
- logger14.error(
5910
+ logger15.error(
5831
5911
  { error, graphId: this.config.graphId },
5832
5912
  "Failed to check graph artifact components"
5833
5913
  );
@@ -5931,7 +6011,7 @@ Key requirements:
5931
6011
  const configuredTimeout = modelSettings.maxDuration ? Math.min(modelSettings.maxDuration * 1e3, MAX_ALLOWED_TIMEOUT_MS) : shouldStreamPhase1 ? CONSTANTS.PHASE_1_TIMEOUT_MS : CONSTANTS.NON_STREAMING_PHASE_1_TIMEOUT_MS;
5932
6012
  const timeoutMs = Math.min(configuredTimeout, MAX_ALLOWED_TIMEOUT_MS);
5933
6013
  if (modelSettings.maxDuration && modelSettings.maxDuration * 1e3 > MAX_ALLOWED_TIMEOUT_MS) {
5934
- logger14.warn(
6014
+ logger15.warn(
5935
6015
  {
5936
6016
  requestedTimeout: modelSettings.maxDuration * 1e3,
5937
6017
  appliedTimeout: timeoutMs,
@@ -5973,7 +6053,7 @@ Key requirements:
5973
6053
  }
5974
6054
  );
5975
6055
  } catch (error) {
5976
- logger14.debug({ error }, "Failed to track agent reasoning");
6056
+ logger15.debug({ error }, "Failed to track agent reasoning");
5977
6057
  }
5978
6058
  }
5979
6059
  if (last && "toolCalls" in last && last.toolCalls) {
@@ -6056,7 +6136,7 @@ Key requirements:
6056
6136
  }
6057
6137
  );
6058
6138
  } catch (error) {
6059
- logger14.debug({ error }, "Failed to track agent reasoning");
6139
+ logger15.debug({ error }, "Failed to track agent reasoning");
6060
6140
  }
6061
6141
  }
6062
6142
  if (last && "toolCalls" in last && last.toolCalls) {
@@ -6101,7 +6181,7 @@ Key requirements:
6101
6181
  return;
6102
6182
  }
6103
6183
  if (toolName === "save_artifact_tool" || toolName === "save_tool_result") {
6104
- logger14.info({ result }, "save_artifact_tool or save_tool_result");
6184
+ logger15.info({ result }, "save_artifact_tool or save_tool_result");
6105
6185
  if (result.output.artifacts) {
6106
6186
  for (const artifact of result.output.artifacts) {
6107
6187
  const artifactId = artifact?.artifactId || "N/A";
@@ -6176,7 +6256,7 @@ ${output}`;
6176
6256
  { role: "user", content: userMessage },
6177
6257
  ...reasoningFlow,
6178
6258
  {
6179
- role: "system",
6259
+ role: "user",
6180
6260
  content: await this.buildPhase2SystemPrompt()
6181
6261
  }
6182
6262
  ],
@@ -6275,7 +6355,9 @@ async function resolveModelConfig(graphId, agent) {
6275
6355
  summarizer: agent.models?.summarizer || project.models.summarizer || project.models.base
6276
6356
  };
6277
6357
  }
6278
- throw new Error("Base model configuration is required. Please configure models at the project level.");
6358
+ throw new Error(
6359
+ "Base model configuration is required. Please configure models at the project level."
6360
+ );
6279
6361
  }
6280
6362
 
6281
6363
  // src/agents/generateTaskHandler.ts
@@ -6289,8 +6371,8 @@ function parseEmbeddedJson(data) {
6289
6371
  }
6290
6372
  });
6291
6373
  }
6292
- var logger15 = agentsCore.getLogger("generateTaskHandler");
6293
- var createTaskHandler = (config2, credentialStoreRegistry) => {
6374
+ var logger16 = agentsCore.getLogger("generateTaskHandler");
6375
+ var createTaskHandler = (config, credentialStoreRegistry) => {
6294
6376
  return async (task) => {
6295
6377
  try {
6296
6378
  const userMessage = task.input.parts.filter((part) => part.text).map((part) => part.text).join(" ");
@@ -6311,58 +6393,84 @@ var createTaskHandler = (config2, credentialStoreRegistry) => {
6311
6393
  ] = await Promise.all([
6312
6394
  agentsCore.getRelatedAgentsForGraph(dbClient_default)({
6313
6395
  scopes: {
6314
- tenantId: config2.tenantId,
6315
- projectId: config2.projectId
6396
+ tenantId: config.tenantId,
6397
+ projectId: config.projectId
6316
6398
  },
6317
- graphId: config2.graphId,
6318
- agentId: config2.agentId
6399
+ graphId: config.graphId,
6400
+ agentId: config.agentId
6319
6401
  }),
6320
6402
  agentsCore.getToolsForAgent(dbClient_default)({
6321
6403
  scopes: {
6322
- tenantId: config2.tenantId,
6323
- projectId: config2.projectId
6404
+ tenantId: config.tenantId,
6405
+ projectId: config.projectId
6324
6406
  },
6325
- agentId: config2.agentId
6407
+ agentId: config.agentId
6326
6408
  }),
6327
6409
  agentsCore.getDataComponentsForAgent(dbClient_default)({
6328
6410
  scopes: {
6329
- tenantId: config2.tenantId,
6330
- projectId: config2.projectId
6411
+ tenantId: config.tenantId,
6412
+ projectId: config.projectId
6331
6413
  },
6332
- agentId: config2.agentId
6414
+ agentId: config.agentId
6333
6415
  }),
6334
6416
  agentsCore.getArtifactComponentsForAgent(dbClient_default)({
6335
6417
  scopes: {
6336
- tenantId: config2.tenantId,
6337
- projectId: config2.projectId
6418
+ tenantId: config.tenantId,
6419
+ projectId: config.projectId
6338
6420
  },
6339
- agentId: config2.agentId
6421
+ agentId: config.agentId
6340
6422
  })
6341
6423
  ]);
6342
- logger15.info({ toolsForAgent, internalRelations, externalRelations }, "agent stuff");
6343
- const agentPrompt = "prompt" in config2.agentSchema ? config2.agentSchema.prompt : "";
6344
- const models = "models" in config2.agentSchema ? config2.agentSchema.models : void 0;
6345
- const stopWhen = "stopWhen" in config2.agentSchema ? config2.agentSchema.stopWhen : void 0;
6424
+ logger16.info({ toolsForAgent, internalRelations, externalRelations }, "agent stuff");
6425
+ const enhancedInternalRelations = await Promise.all(
6426
+ internalRelations.map(async (relation) => {
6427
+ try {
6428
+ const relatedAgent = await agentsCore.getAgentById(dbClient_default)({
6429
+ scopes: { tenantId: config.tenantId, projectId: config.projectId },
6430
+ agentId: relation.id
6431
+ });
6432
+ if (relatedAgent) {
6433
+ const relatedAgentRelations = await agentsCore.getRelatedAgentsForGraph(dbClient_default)({
6434
+ scopes: { tenantId: config.tenantId, projectId: config.projectId },
6435
+ graphId: config.graphId,
6436
+ agentId: relation.id
6437
+ });
6438
+ const enhancedDescription = generateDescriptionWithTransfers(
6439
+ relation.description || "",
6440
+ relatedAgentRelations.internalRelations,
6441
+ relatedAgentRelations.externalRelations
6442
+ );
6443
+ return { ...relation, description: enhancedDescription };
6444
+ }
6445
+ } catch (error) {
6446
+ logger16.warn({ agentId: relation.id, error }, "Failed to enhance agent description");
6447
+ }
6448
+ return relation;
6449
+ })
6450
+ );
6451
+ const agentPrompt = "prompt" in config.agentSchema ? config.agentSchema.prompt : "";
6452
+ const models = "models" in config.agentSchema ? config.agentSchema.models : void 0;
6453
+ const stopWhen = "stopWhen" in config.agentSchema ? config.agentSchema.stopWhen : void 0;
6346
6454
  const agent = new Agent(
6347
6455
  {
6348
- id: config2.agentId,
6349
- tenantId: config2.tenantId,
6350
- projectId: config2.projectId,
6351
- graphId: config2.graphId,
6352
- baseUrl: config2.baseUrl,
6353
- apiKey: config2.apiKey,
6354
- name: config2.name,
6355
- description: config2.description || "",
6456
+ id: config.agentId,
6457
+ tenantId: config.tenantId,
6458
+ projectId: config.projectId,
6459
+ graphId: config.graphId,
6460
+ baseUrl: config.baseUrl,
6461
+ apiKey: config.apiKey,
6462
+ name: config.name,
6463
+ description: config.description || "",
6356
6464
  agentPrompt,
6357
6465
  models: models || void 0,
6358
6466
  stopWhen: stopWhen || void 0,
6359
- agentRelations: internalRelations.map((relation) => ({
6467
+ agentRelations: enhancedInternalRelations.map((relation) => ({
6360
6468
  id: relation.id,
6361
- tenantId: config2.tenantId,
6362
- projectId: config2.projectId,
6363
- graphId: config2.graphId,
6364
- baseUrl: config2.baseUrl,
6365
- apiKey: config2.apiKey,
6469
+ tenantId: config.tenantId,
6470
+ projectId: config.projectId,
6471
+ graphId: config.graphId,
6472
+ baseUrl: config.baseUrl,
6473
+ apiKey: config.apiKey,
6366
6474
  name: relation.name,
6367
6475
  description: relation.description,
6368
6476
  agentPrompt: "",
@@ -6370,13 +6478,13 @@ var createTaskHandler = (config2, credentialStoreRegistry) => {
6370
6478
  agentRelations: [],
6371
6479
  transferRelations: []
6372
6480
  })),
6373
- transferRelations: internalRelations.filter((relation) => relation.relationType === "transfer").map((relation) => ({
6374
- baseUrl: config2.baseUrl,
6375
- apiKey: config2.apiKey,
6481
+ transferRelations: enhancedInternalRelations.filter((relation) => relation.relationType === "transfer").map((relation) => ({
6482
+ baseUrl: config.baseUrl,
6483
+ apiKey: config.apiKey,
6376
6484
  id: relation.id,
6377
- tenantId: config2.tenantId,
6378
- projectId: config2.projectId,
6379
- graphId: config2.graphId,
6485
+ tenantId: config.tenantId,
6486
+ projectId: config.projectId,
6487
+ graphId: config.graphId,
6380
6488
  name: relation.name,
6381
6489
  description: relation.description,
6382
6490
  agentPrompt: "",
@@ -6386,15 +6494,15 @@ var createTaskHandler = (config2, credentialStoreRegistry) => {
6386
6494
  })),
6387
6495
  delegateRelations: [
6388
6496
  // Internal delegate relations
6389
- ...internalRelations.filter((relation) => relation.relationType === "delegate").map((relation) => ({
6497
+ ...enhancedInternalRelations.filter((relation) => relation.relationType === "delegate").map((relation) => ({
6390
6498
  type: "internal",
6391
6499
  config: {
6392
6500
  id: relation.id,
6393
- tenantId: config2.tenantId,
6394
- projectId: config2.projectId,
6395
- graphId: config2.graphId,
6396
- baseUrl: config2.baseUrl,
6397
- apiKey: config2.apiKey,
6501
+ tenantId: config.tenantId,
6502
+ projectId: config.projectId,
6503
+ graphId: config.graphId,
6504
+ baseUrl: config.baseUrl,
6505
+ apiKey: config.apiKey,
6398
6506
  name: relation.name,
6399
6507
  description: relation.description,
6400
6508
  agentPrompt: "",
@@ -6429,8 +6537,8 @@ var createTaskHandler = (config2, credentialStoreRegistry) => {
6429
6537
  // All tools are now handled via MCP servers
6430
6538
  dataComponents,
6431
6539
  artifactComponents,
6432
- contextConfigId: config2.contextConfigId || void 0,
6433
- conversationHistoryConfig: config2.conversationHistoryConfig
6540
+ contextConfigId: config.contextConfigId || void 0,
6541
+ conversationHistoryConfig: config.conversationHistoryConfig
6434
6542
  },
6435
6543
  credentialStoreRegistry
6436
6544
  );
@@ -6439,11 +6547,11 @@ var createTaskHandler = (config2, credentialStoreRegistry) => {
6439
6547
  const taskIdMatch = task.id.match(/^task_([^-]+-[^-]+-\d+)-/);
6440
6548
  if (taskIdMatch) {
6441
6549
  contextId = taskIdMatch[1];
6442
- logger15.info(
6550
+ logger16.info(
6443
6551
  {
6444
6552
  taskId: task.id,
6445
6553
  extractedContextId: contextId,
6446
- agentId: config2.agentId
6554
+ agentId: config.agentId
6447
6555
  },
6448
6556
  "Extracted contextId from task ID for delegation"
6449
6557
  );
@@ -6455,8 +6563,8 @@ var createTaskHandler = (config2, credentialStoreRegistry) => {
6455
6563
  const isDelegation = task.context?.metadata?.isDelegation === true;
6456
6564
  agent.setDelegationStatus(isDelegation);
6457
6565
  if (isDelegation) {
6458
- logger15.info(
6459
- { agentId: config2.agentId, taskId: task.id },
6566
+ logger16.info(
6567
+ { agentId: config.agentId, taskId: task.id },
6460
6568
  "Delegated agent - streaming disabled"
6461
6569
  );
6462
6570
  }
@@ -6468,7 +6576,7 @@ var createTaskHandler = (config2, credentialStoreRegistry) => {
6468
6576
  threadId: contextId,
6469
6577
  // using conversationId as threadId for now
6470
6578
  streamRequestId,
6471
- ...config2.apiKey ? { apiKey: config2.apiKey } : {}
6579
+ ...config.apiKey ? { apiKey: config.apiKey } : {}
6472
6580
  }
6473
6581
  });
6474
6582
  const stepContents = response.steps && Array.isArray(response.steps) ? response.steps.flatMap((step) => {
@@ -6661,86 +6769,11 @@ async function getRegisteredGraph(executionContext) {
6661
6769
  const agentFrameworkBaseUrl = `${baseUrl}/agents`;
6662
6770
  return hydrateGraph({ dbGraph, baseUrl: agentFrameworkBaseUrl, apiKey });
6663
6771
  }
6664
- init_dbClient();
6665
- agentsCore.getLogger("agents");
6666
- async function hydrateAgent({
6667
- dbAgent,
6668
- graphId,
6669
- baseUrl,
6670
- apiKey,
6671
- credentialStoreRegistry
6672
- }) {
6673
- try {
6674
- const taskHandlerConfig = await createTaskHandlerConfig({
6675
- tenantId: dbAgent.tenantId,
6676
- projectId: dbAgent.projectId,
6677
- graphId,
6678
- agentId: dbAgent.id,
6679
- baseUrl,
6680
- apiKey
6681
- });
6682
- const taskHandler = createTaskHandler(taskHandlerConfig, credentialStoreRegistry);
6683
- const agentCard = {
6684
- name: dbAgent.name,
6685
- description: dbAgent.description || "AI Agent",
6686
- url: baseUrl ? `${baseUrl}/a2a` : "",
6687
- version: "1.0.0",
6688
- capabilities: {
6689
- streaming: true,
6690
- // Enable streaming for A2A compliance
6691
- pushNotifications: false,
6692
- stateTransitionHistory: false
6693
- },
6694
- defaultInputModes: ["text", "text/plain"],
6695
- defaultOutputModes: ["text", "text/plain"],
6696
- skills: [],
6697
- // Add provider info if available
6698
- ...baseUrl && {
6699
- provider: {
6700
- organization: "Inkeep",
6701
- url: baseUrl
6702
- }
6703
- }
6704
- };
6705
- return {
6706
- agentId: dbAgent.id,
6707
- tenantId: dbAgent.tenantId,
6708
- projectId: dbAgent.projectId,
6709
- graphId,
6710
- agentCard,
6711
- taskHandler
6712
- };
6713
- } catch (error) {
6714
- console.error(`\u274C Failed to hydrate agent ${dbAgent.id}:`, error);
6715
- throw error;
6716
- }
6717
- }
6718
- async function getRegisteredAgent(executionContext, credentialStoreRegistry) {
6719
- const { tenantId, projectId, graphId, agentId, baseUrl, apiKey } = executionContext;
6720
- if (!agentId) {
6721
- throw new Error("Agent ID is required");
6722
- }
6723
- const dbAgent = await agentsCore.getAgentById(dbClient_default)({
6724
- scopes: { tenantId, projectId },
6725
- agentId
6726
- });
6727
- if (!dbAgent) {
6728
- return null;
6729
- }
6730
- const agentFrameworkBaseUrl = `${baseUrl}/agents`;
6731
- return hydrateAgent({
6732
- dbAgent,
6733
- graphId,
6734
- baseUrl: agentFrameworkBaseUrl,
6735
- credentialStoreRegistry,
6736
- apiKey
6737
- });
6738
- }
6739
6772
 
6740
6773
  // src/routes/agents.ts
6741
6774
  init_dbClient();
6742
6775
  var app = new zodOpenapi.OpenAPIHono();
6743
- var logger16 = agentsCore.getLogger("agents");
6776
+ var logger17 = agentsCore.getLogger("agents");
6744
6777
  app.openapi(
6745
6778
  zodOpenapi.createRoute({
6746
6779
  method: "get",
@@ -6778,7 +6811,7 @@ app.openapi(
6778
6811
  tracestate: c.req.header("tracestate"),
6779
6812
  baggage: c.req.header("baggage")
6780
6813
  };
6781
- logger16.info(
6814
+ logger17.info(
6782
6815
  {
6783
6816
  otelHeaders,
6784
6817
  path: c.req.path,
@@ -6789,7 +6822,7 @@ app.openapi(
6789
6822
  const executionContext = agentsCore.getRequestExecutionContext(c);
6790
6823
  const { tenantId, projectId, graphId, agentId } = executionContext;
6791
6824
  if (agentId) {
6792
- logger16.info(
6825
+ logger17.info(
6793
6826
  {
6794
6827
  message: "getRegisteredAgent (agent-level)",
6795
6828
  tenantId,
@@ -6801,13 +6834,13 @@ app.openapi(
6801
6834
  );
6802
6835
  const credentialStores = c.get("credentialStores");
6803
6836
  const agent = await getRegisteredAgent(executionContext, credentialStores);
6804
- logger16.info({ agent }, "agent registered: well-known agent.json");
6837
+ logger17.info({ agent }, "agent registered: well-known agent.json");
6805
6838
  if (!agent) {
6806
6839
  return c.json({ error: "Agent not found" }, 404);
6807
6840
  }
6808
6841
  return c.json(agent.agentCard);
6809
6842
  } else {
6810
- logger16.info(
6843
+ logger17.info(
6811
6844
  {
6812
6845
  message: "getRegisteredGraph (graph-level)",
6813
6846
  tenantId,
@@ -6830,7 +6863,7 @@ app.post("/a2a", async (c) => {
6830
6863
  tracestate: c.req.header("tracestate"),
6831
6864
  baggage: c.req.header("baggage")
6832
6865
  };
6833
- logger16.info(
6866
+ logger17.info(
6834
6867
  {
6835
6868
  otelHeaders,
6836
6869
  path: c.req.path,
@@ -6841,7 +6874,7 @@ app.post("/a2a", async (c) => {
6841
6874
  const executionContext = agentsCore.getRequestExecutionContext(c);
6842
6875
  const { tenantId, projectId, graphId, agentId } = executionContext;
6843
6876
  if (agentId) {
6844
- logger16.info(
6877
+ logger17.info(
6845
6878
  {
6846
6879
  message: "a2a (agent-level)",
6847
6880
  tenantId,
@@ -6865,7 +6898,7 @@ app.post("/a2a", async (c) => {
6865
6898
  }
6866
6899
  return a2aHandler(c, agent);
6867
6900
  } else {
6868
- logger16.info(
6901
+ logger17.info(
6869
6902
  {
6870
6903
  message: "a2a (graph-level)",
6871
6904
  tenantId,
@@ -6911,14 +6944,14 @@ init_dbClient();
6911
6944
 
6912
6945
  // src/a2a/transfer.ts
6913
6946
  init_dbClient();
6914
- var logger17 = agentsCore.getLogger("Transfer");
6947
+ var logger18 = agentsCore.getLogger("Transfer");
6915
6948
  async function executeTransfer({
6916
6949
  tenantId,
6917
6950
  threadId,
6918
6951
  projectId,
6919
6952
  targetAgentId
6920
6953
  }) {
6921
- logger17.info({ targetAgent: targetAgentId }, "Executing transfer to agent");
6954
+ logger18.info({ targetAgent: targetAgentId }, "Executing transfer to agent");
6922
6955
  await agentsCore.setActiveAgentForThread(dbClient_default)({
6923
6956
  scopes: { tenantId, projectId },
6924
6957
  threadId,
@@ -7113,7 +7146,7 @@ var _VercelDataStreamHelper = class _VercelDataStreamHelper {
7113
7146
  __publicField(this, "queuedOperations", []);
7114
7147
  // Timing tracking for text sequences (text-end to text-start gap)
7115
7148
  __publicField(this, "lastTextEndTimestamp", 0);
7116
- __publicField(this, "TEXT_GAP_THRESHOLD", 1e3);
7149
+ __publicField(this, "TEXT_GAP_THRESHOLD", 50);
7117
7150
  // milliseconds - if gap between text sequences is less than this, queue operations
7118
7151
  // Connection management and forced cleanup
7119
7152
  __publicField(this, "connectionDropTimer");
@@ -7462,7 +7495,7 @@ function createMCPStreamHelper() {
7462
7495
 
7463
7496
  // src/handlers/executionHandler.ts
7464
7497
  init_dbClient();
7465
- var logger18 = agentsCore.getLogger("ExecutionHandler");
7498
+ var logger19 = agentsCore.getLogger("ExecutionHandler");
7466
7499
  var ExecutionHandler = class {
7467
7500
  constructor() {
7468
7501
  // Hardcoded error limit - separate from configurable stopWhen
@@ -7487,7 +7520,7 @@ var ExecutionHandler = class {
7487
7520
  const { tenantId, projectId, graphId, apiKey, baseUrl } = executionContext;
7488
7521
  registerStreamHelper(requestId2, sseHelper);
7489
7522
  graphSessionManager.createSession(requestId2, graphId, tenantId, projectId);
7490
- logger18.info({ sessionId: requestId2, graphId }, "Created GraphSession for message execution");
7523
+ logger19.info({ sessionId: requestId2, graphId }, "Created GraphSession for message execution");
7491
7524
  let graphConfig = null;
7492
7525
  try {
7493
7526
  graphConfig = await agentsCore.getFullGraph(dbClient_default)({ scopes: { tenantId, projectId }, graphId });
@@ -7499,7 +7532,7 @@ var ExecutionHandler = class {
7499
7532
  );
7500
7533
  }
7501
7534
  } catch (error) {
7502
- logger18.error(
7535
+ logger19.error(
7503
7536
  {
7504
7537
  error: error instanceof Error ? error.message : "Unknown error",
7505
7538
  stack: error instanceof Error ? error.stack : void 0
@@ -7515,7 +7548,7 @@ var ExecutionHandler = class {
7515
7548
  try {
7516
7549
  await sseHelper.writeOperation(agentInitializingOp(requestId2, graphId));
7517
7550
  const taskId = `task_${conversationId}-${requestId2}`;
7518
- logger18.info(
7551
+ logger19.info(
7519
7552
  { taskId, currentAgentId, conversationId, requestId: requestId2 },
7520
7553
  "Attempting to create or reuse existing task"
7521
7554
  );
@@ -7538,7 +7571,7 @@ var ExecutionHandler = class {
7538
7571
  agent_id: currentAgentId
7539
7572
  }
7540
7573
  });
7541
- logger18.info(
7574
+ logger19.info(
7542
7575
  {
7543
7576
  taskId,
7544
7577
  createdTaskMetadata: Array.isArray(task) ? task[0]?.metadata : task?.metadata
@@ -7547,27 +7580,27 @@ var ExecutionHandler = class {
7547
7580
  );
7548
7581
  } catch (error) {
7549
7582
  if (error?.message?.includes("UNIQUE constraint failed") || error?.message?.includes("PRIMARY KEY constraint failed") || error?.code === "SQLITE_CONSTRAINT_PRIMARYKEY") {
7550
- logger18.info(
7583
+ logger19.info(
7551
7584
  { taskId, error: error.message },
7552
7585
  "Task already exists, fetching existing task"
7553
7586
  );
7554
7587
  const existingTask = await agentsCore.getTask(dbClient_default)({ id: taskId });
7555
7588
  if (existingTask) {
7556
7589
  task = existingTask;
7557
- logger18.info(
7590
+ logger19.info(
7558
7591
  { taskId, existingTask },
7559
7592
  "Successfully reused existing task from race condition"
7560
7593
  );
7561
7594
  } else {
7562
- logger18.error({ taskId, error }, "Task constraint failed but task not found");
7595
+ logger19.error({ taskId, error }, "Task constraint failed but task not found");
7563
7596
  throw error;
7564
7597
  }
7565
7598
  } else {
7566
- logger18.error({ taskId, error }, "Failed to create task due to non-constraint error");
7599
+ logger19.error({ taskId, error }, "Failed to create task due to non-constraint error");
7567
7600
  throw error;
7568
7601
  }
7569
7602
  }
7570
- logger18.debug(
7603
+ logger19.debug(
7571
7604
  {
7572
7605
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
7573
7606
  executionType: "create_initial_task",
@@ -7585,7 +7618,7 @@ var ExecutionHandler = class {
7585
7618
  const maxTransfers = graphConfig?.stopWhen?.transferCountIs ?? 10;
7586
7619
  while (iterations < maxTransfers) {
7587
7620
  iterations++;
7588
- logger18.info(
7621
+ logger19.info(
7589
7622
  { iterations, currentAgentId, graphId, conversationId, fromAgentId },
7590
7623
  `Execution loop iteration ${iterations} with agent ${currentAgentId}, transfer from: ${fromAgentId || "none"}`
7591
7624
  );
@@ -7593,10 +7626,10 @@ var ExecutionHandler = class {
7593
7626
  scopes: { tenantId, projectId },
7594
7627
  conversationId
7595
7628
  });
7596
- logger18.info({ activeAgent }, "activeAgent");
7629
+ logger19.info({ activeAgent }, "activeAgent");
7597
7630
  if (activeAgent && activeAgent.activeAgentId !== currentAgentId) {
7598
7631
  currentAgentId = activeAgent.activeAgentId;
7599
- logger18.info({ currentAgentId }, `Updated current agent to: ${currentAgentId}`);
7632
+ logger19.info({ currentAgentId }, `Updated current agent to: ${currentAgentId}`);
7600
7633
  }
7601
7634
  const agentBaseUrl = `${baseUrl}/agents`;
7602
7635
  const a2aClient = new A2AClient(agentBaseUrl, {
@@ -7637,13 +7670,13 @@ var ExecutionHandler = class {
7637
7670
  });
7638
7671
  if (!messageResponse?.result) {
7639
7672
  errorCount++;
7640
- logger18.error(
7673
+ logger19.error(
7641
7674
  { currentAgentId, iterations, errorCount },
7642
7675
  `No response from agent ${currentAgentId} on iteration ${iterations} (error ${errorCount}/${this.MAX_ERRORS})`
7643
7676
  );
7644
7677
  if (errorCount >= this.MAX_ERRORS) {
7645
7678
  const errorMessage2 = `Maximum error limit (${this.MAX_ERRORS}) reached`;
7646
- logger18.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
7679
+ logger19.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
7647
7680
  await sseHelper.writeError(errorMessage2);
7648
7681
  await sseHelper.writeOperation(errorOp(errorMessage2, currentAgentId || "system"));
7649
7682
  if (task) {
@@ -7669,7 +7702,7 @@ var ExecutionHandler = class {
7669
7702
  const transferResponse = messageResponse.result;
7670
7703
  const targetAgentId = transferResponse.artifacts?.[0]?.parts?.[0]?.data?.targetAgentId;
7671
7704
  const transferReason = transferResponse.artifacts?.[0]?.parts?.[1]?.text;
7672
- logger18.info({ targetAgentId, transferReason }, "transfer response");
7705
+ logger19.info({ targetAgentId, transferReason }, "transfer response");
7673
7706
  currentMessage = `<transfer_context> ${transferReason} </transfer_context>`;
7674
7707
  const { success, targetAgentId: newAgentId } = await executeTransfer({
7675
7708
  projectId,
@@ -7680,7 +7713,7 @@ var ExecutionHandler = class {
7680
7713
  if (success) {
7681
7714
  fromAgentId = currentAgentId;
7682
7715
  currentAgentId = newAgentId;
7683
- logger18.info(
7716
+ logger19.info(
7684
7717
  {
7685
7718
  transferFrom: fromAgentId,
7686
7719
  transferTo: currentAgentId,
@@ -7698,7 +7731,7 @@ var ExecutionHandler = class {
7698
7731
  const graphSessionData = graphSessionManager.getSession(requestId2);
7699
7732
  if (graphSessionData) {
7700
7733
  const sessionSummary = graphSessionData.getSummary();
7701
- logger18.info(sessionSummary, "GraphSession data after completion");
7734
+ logger19.info(sessionSummary, "GraphSession data after completion");
7702
7735
  }
7703
7736
  let textContent = "";
7704
7737
  for (const part of responseParts) {
@@ -7707,78 +7740,84 @@ var ExecutionHandler = class {
7707
7740
  textContent += part.text;
7708
7741
  }
7709
7742
  }
7710
- const activeSpan = api.trace.getActiveSpan();
7711
- if (activeSpan) {
7712
- activeSpan.setAttributes({
7713
- "ai.response.content": textContent || "No response content",
7714
- "ai.response.timestamp": (/* @__PURE__ */ new Date()).toISOString(),
7715
- "ai.agent.name": currentAgentId
7716
- });
7717
- }
7718
- await agentsCore.createMessage(dbClient_default)({
7719
- id: nanoid.nanoid(),
7720
- tenantId,
7721
- projectId,
7722
- conversationId,
7723
- role: "agent",
7724
- content: {
7725
- text: textContent || void 0,
7726
- parts: responseParts.map((part) => ({
7727
- type: part.kind === "text" ? "text" : "data",
7728
- text: part.kind === "text" ? part.text : void 0,
7729
- data: part.kind === "data" ? JSON.stringify(part.data) : void 0
7730
- }))
7731
- },
7732
- visibility: "user-facing",
7733
- messageType: "chat",
7734
- agentId: currentAgentId,
7735
- fromAgentId: currentAgentId,
7736
- taskId: task.id
7737
- });
7738
- const updateTaskStart = Date.now();
7739
- await agentsCore.updateTask(dbClient_default)({
7740
- taskId: task.id,
7741
- data: {
7742
- status: "completed",
7743
- metadata: {
7744
- ...task.metadata,
7745
- completed_at: (/* @__PURE__ */ new Date()).toISOString(),
7746
- response: {
7747
- text: textContent,
7748
- parts: responseParts,
7749
- hasText: !!textContent,
7750
- hasData: responseParts.some((p) => p.kind === "data")
7743
+ return tracer.startActiveSpan("execution_handler.execute", {}, async (span) => {
7744
+ try {
7745
+ span.setAttributes({
7746
+ "ai.response.content": textContent || "No response content",
7747
+ "ai.response.timestamp": (/* @__PURE__ */ new Date()).toISOString(),
7748
+ "ai.agent.name": currentAgentId
7749
+ });
7750
+ await agentsCore.createMessage(dbClient_default)({
7751
+ id: nanoid.nanoid(),
7752
+ tenantId,
7753
+ projectId,
7754
+ conversationId,
7755
+ role: "agent",
7756
+ content: {
7757
+ text: textContent || void 0,
7758
+ parts: responseParts.map((part) => ({
7759
+ type: part.kind === "text" ? "text" : "data",
7760
+ text: part.kind === "text" ? part.text : void 0,
7761
+ data: part.kind === "data" ? JSON.stringify(part.data) : void 0
7762
+ }))
7763
+ },
7764
+ visibility: "user-facing",
7765
+ messageType: "chat",
7766
+ agentId: currentAgentId,
7767
+ fromAgentId: currentAgentId,
7768
+ taskId: task.id
7769
+ });
7770
+ const updateTaskStart = Date.now();
7771
+ await agentsCore.updateTask(dbClient_default)({
7772
+ taskId: task.id,
7773
+ data: {
7774
+ status: "completed",
7775
+ metadata: {
7776
+ ...task.metadata,
7777
+ completed_at: (/* @__PURE__ */ new Date()).toISOString(),
7778
+ response: {
7779
+ text: textContent,
7780
+ parts: responseParts,
7781
+ hasText: !!textContent,
7782
+ hasData: responseParts.some((p) => p.kind === "data")
7783
+ }
7784
+ }
7751
7785
  }
7786
+ });
7787
+ const updateTaskEnd = Date.now();
7788
+ logger19.info(
7789
+ { duration: updateTaskEnd - updateTaskStart },
7790
+ "Completed updateTask operation"
7791
+ );
7792
+ await sseHelper.writeOperation(completionOp(currentAgentId, iterations));
7793
+ await sseHelper.complete();
7794
+ logger19.info({}, "Ending GraphSession and cleaning up");
7795
+ graphSessionManager.endSession(requestId2);
7796
+ logger19.info({}, "Cleaning up streamHelper");
7797
+ unregisterStreamHelper(requestId2);
7798
+ let response;
7799
+ if (sseHelper instanceof MCPStreamHelper) {
7800
+ const captured = sseHelper.getCapturedResponse();
7801
+ response = captured.text || "No response content";
7752
7802
  }
7803
+ logger19.info({}, "ExecutionHandler returning success");
7804
+ return { success: true, iterations, response };
7805
+ } catch (error) {
7806
+ agentsCore.setSpanWithError(span, error);
7807
+ throw error;
7808
+ } finally {
7809
+ span.end();
7753
7810
  }
7754
7811
  });
7755
- const updateTaskEnd = Date.now();
7756
- logger18.info(
7757
- { duration: updateTaskEnd - updateTaskStart },
7758
- "Completed updateTask operation"
7759
- );
7760
- await sseHelper.writeOperation(completionOp(currentAgentId, iterations));
7761
- await sseHelper.complete();
7762
- logger18.info({}, "Ending GraphSession and cleaning up");
7763
- graphSessionManager.endSession(requestId2);
7764
- logger18.info({}, "Cleaning up streamHelper");
7765
- unregisterStreamHelper(requestId2);
7766
- let response;
7767
- if (sseHelper instanceof MCPStreamHelper) {
7768
- const captured = sseHelper.getCapturedResponse();
7769
- response = captured.text || "No response content";
7770
- }
7771
- logger18.info({}, "ExecutionHandler returning success");
7772
- return { success: true, iterations, response };
7773
7812
  }
7774
7813
  errorCount++;
7775
- logger18.warn(
7814
+ logger19.warn(
7776
7815
  { iterations, errorCount },
7777
7816
  `No valid response or transfer on iteration ${iterations} (error ${errorCount}/${this.MAX_ERRORS})`
7778
7817
  );
7779
7818
  if (errorCount >= this.MAX_ERRORS) {
7780
7819
  const errorMessage2 = `Maximum error limit (${this.MAX_ERRORS}) reached`;
7781
- logger18.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
7820
+ logger19.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
7782
7821
  await sseHelper.writeError(errorMessage2);
7783
7822
  await sseHelper.writeOperation(errorOp(errorMessage2, currentAgentId || "system"));
7784
7823
  if (task) {
@@ -7800,7 +7839,7 @@ var ExecutionHandler = class {
7800
7839
  }
7801
7840
  }
7802
7841
  const errorMessage = `Maximum transfer limit (${maxTransfers}) reached without completion`;
7803
- logger18.error({ maxTransfers, iterations }, errorMessage);
7842
+ logger19.error({ maxTransfers, iterations }, errorMessage);
7804
7843
  await sseHelper.writeError(errorMessage);
7805
7844
  await sseHelper.writeOperation(errorOp(errorMessage, currentAgentId || "system"));
7806
7845
  if (task) {
@@ -7820,7 +7859,7 @@ var ExecutionHandler = class {
7820
7859
  unregisterStreamHelper(requestId2);
7821
7860
  return { success: false, error: errorMessage, iterations };
7822
7861
  } catch (error) {
7823
- logger18.error({ error }, "Error in execution handler");
7862
+ logger19.error({ error }, "Error in execution handler");
7824
7863
  const errorMessage = error instanceof Error ? error.message : "Unknown execution error";
7825
7864
  await sseHelper.writeError(`Execution error: ${errorMessage}`);
7826
7865
  await sseHelper.writeOperation(errorOp(errorMessage, currentAgentId || "system"));
@@ -7846,7 +7885,7 @@ var ExecutionHandler = class {
7846
7885
 
7847
7886
  // src/routes/chat.ts
7848
7887
  var app2 = new zodOpenapi.OpenAPIHono();
7849
- var logger19 = agentsCore.getLogger("completionsHandler");
7888
+ var logger20 = agentsCore.getLogger("completionsHandler");
7850
7889
  var chatCompletionsRoute = zodOpenapi.createRoute({
7851
7890
  method: "post",
7852
7891
  path: "/completions",
@@ -7964,7 +8003,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
7964
8003
  tracestate: c.req.header("tracestate"),
7965
8004
  baggage: c.req.header("baggage")
7966
8005
  };
7967
- logger19.info(
8006
+ logger20.info(
7968
8007
  {
7969
8008
  otelHeaders,
7970
8009
  path: c.req.path,
@@ -8050,7 +8089,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
8050
8089
  dbClient_default,
8051
8090
  credentialStores
8052
8091
  );
8053
- logger19.info(
8092
+ logger20.info(
8054
8093
  {
8055
8094
  tenantId,
8056
8095
  graphId,
@@ -8096,7 +8135,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
8096
8135
  return streaming.streamSSE(c, async (stream2) => {
8097
8136
  const sseHelper = createSSEStreamHelper(stream2, requestId2, timestamp);
8098
8137
  await sseHelper.writeRole();
8099
- logger19.info({ agentId }, "Starting execution");
8138
+ logger20.info({ agentId }, "Starting execution");
8100
8139
  const executionHandler = new ExecutionHandler();
8101
8140
  const result = await executionHandler.execute({
8102
8141
  executionContext,
@@ -8106,7 +8145,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
8106
8145
  requestId: requestId2,
8107
8146
  sseHelper
8108
8147
  });
8109
- logger19.info(
8148
+ logger20.info(
8110
8149
  { result },
8111
8150
  `Execution completed: ${result.success ? "success" : "failed"} after ${result.iterations} iterations`
8112
8151
  );
@@ -8142,7 +8181,7 @@ var chat_default = app2;
8142
8181
  // src/routes/chatDataStream.ts
8143
8182
  init_dbClient();
8144
8183
  var app3 = new zodOpenapi.OpenAPIHono();
8145
- var logger20 = agentsCore.getLogger("chatDataStream");
8184
+ var logger21 = agentsCore.getLogger("chatDataStream");
8146
8185
  var chatDataStreamRoute = zodOpenapi.createRoute({
8147
8186
  method: "post",
8148
8187
  path: "/chat",
@@ -8247,7 +8286,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
8247
8286
  );
8248
8287
  const lastUserMessage = body.messages.filter((m) => m.role === "user").slice(-1)[0];
8249
8288
  const userText = typeof lastUserMessage?.content === "string" ? lastUserMessage.content : lastUserMessage?.parts?.map((p) => p.text).join("") || "";
8250
- logger20.info({ userText, lastUserMessage }, "userText");
8289
+ logger21.info({ userText, lastUserMessage }, "userText");
8251
8290
  const messageSpan = api.trace.getActiveSpan();
8252
8291
  if (messageSpan) {
8253
8292
  messageSpan.setAttributes({
@@ -8289,7 +8328,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
8289
8328
  await streamHelper.writeError("Unable to process request");
8290
8329
  }
8291
8330
  } catch (err) {
8292
- logger20.error({ err }, "Streaming error");
8331
+ logger21.error({ err }, "Streaming error");
8293
8332
  await streamHelper.writeError("Internal server error");
8294
8333
  } finally {
8295
8334
  if ("cleanup" in streamHelper && typeof streamHelper.cleanup === "function") {
@@ -8310,7 +8349,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
8310
8349
  )
8311
8350
  );
8312
8351
  } catch (error) {
8313
- logger20.error({ error }, "chatDataStream error");
8352
+ logger21.error({ error }, "chatDataStream error");
8314
8353
  return c.json({ error: "Failed to process chat completion" }, 500);
8315
8354
  }
8316
8355
  });
@@ -8321,7 +8360,7 @@ init_dbClient();
8321
8360
  function createMCPSchema(schema) {
8322
8361
  return schema;
8323
8362
  }
8324
- var logger21 = agentsCore.getLogger("mcp");
8363
+ var logger22 = agentsCore.getLogger("mcp");
8325
8364
  var _MockResponseSingleton = class _MockResponseSingleton {
8326
8365
  constructor() {
8327
8366
  __publicField(this, "mockRes");
@@ -8376,21 +8415,21 @@ var createSpoofInitMessage = (mcpProtocolVersion) => ({
8376
8415
  id: 0
8377
8416
  });
8378
8417
  var spoofTransportInitialization = async (transport, req, sessionId, mcpProtocolVersion) => {
8379
- logger21.info({ sessionId }, "Spoofing initialization message to set transport state");
8418
+ logger22.info({ sessionId }, "Spoofing initialization message to set transport state");
8380
8419
  const spoofInitMessage = createSpoofInitMessage(mcpProtocolVersion);
8381
8420
  const mockRes = MockResponseSingleton.getInstance().getMockResponse();
8382
8421
  try {
8383
8422
  await transport.handleRequest(req, mockRes, spoofInitMessage);
8384
- logger21.info({ sessionId }, "Successfully spoofed initialization");
8423
+ logger22.info({ sessionId }, "Successfully spoofed initialization");
8385
8424
  } catch (spoofError) {
8386
- logger21.warn({ sessionId, error: spoofError }, "Spoof initialization failed, continuing anyway");
8425
+ logger22.warn({ sessionId, error: spoofError }, "Spoof initialization failed, continuing anyway");
8387
8426
  }
8388
8427
  };
8389
8428
  var validateSession = async (req, res, body, tenantId, projectId, graphId) => {
8390
8429
  const sessionId = req.headers["mcp-session-id"];
8391
- logger21.info({ sessionId }, "Received MCP session ID");
8430
+ logger22.info({ sessionId }, "Received MCP session ID");
8392
8431
  if (!sessionId) {
8393
- logger21.info({ body }, "Missing session ID");
8432
+ logger22.info({ body }, "Missing session ID");
8394
8433
  res.writeHead(400).end(
8395
8434
  JSON.stringify({
8396
8435
  jsonrpc: "2.0",
@@ -8416,7 +8455,7 @@ var validateSession = async (req, res, body, tenantId, projectId, graphId) => {
8416
8455
  scopes: { tenantId, projectId },
8417
8456
  conversationId: sessionId
8418
8457
  });
8419
- logger21.info(
8458
+ logger22.info(
8420
8459
  {
8421
8460
  sessionId,
8422
8461
  conversationFound: !!conversation,
@@ -8427,7 +8466,7 @@ var validateSession = async (req, res, body, tenantId, projectId, graphId) => {
8427
8466
  "Conversation lookup result"
8428
8467
  );
8429
8468
  if (!conversation || conversation.metadata?.sessionData?.sessionType !== "mcp" || conversation.metadata?.sessionData?.graphId !== graphId) {
8430
- logger21.info(
8469
+ logger22.info(
8431
8470
  { sessionId, conversationId: conversation?.id },
8432
8471
  "MCP session not found or invalid"
8433
8472
  );
@@ -8488,7 +8527,7 @@ var executeAgentQuery = async (executionContext, conversationId, query, defaultA
8488
8527
  requestId: requestId2,
8489
8528
  sseHelper: mcpStreamHelper
8490
8529
  });
8491
- logger21.info(
8530
+ logger22.info(
8492
8531
  { result },
8493
8532
  `Execution completed: ${result.success ? "success" : "failed"} after ${result.iterations} iterations`
8494
8533
  );
@@ -8562,7 +8601,7 @@ var getServer = async (requestContext, executionContext, conversationId, credent
8562
8601
  dbClient_default,
8563
8602
  credentialStores
8564
8603
  );
8565
- logger21.info(
8604
+ logger22.info(
8566
8605
  {
8567
8606
  tenantId,
8568
8607
  graphId,
@@ -8623,7 +8662,7 @@ var validateRequestParameters = (c) => {
8623
8662
  };
8624
8663
  var handleInitializationRequest = async (body, executionContext, validatedContext, req, res, c, credentialStores) => {
8625
8664
  const { tenantId, projectId, graphId } = executionContext;
8626
- logger21.info({ body }, "Received initialization request");
8665
+ logger22.info({ body }, "Received initialization request");
8627
8666
  const sessionId = nanoid.nanoid();
8628
8667
  const agentGraph = await agentsCore.getAgentGraphWithDefaultAgent(dbClient_default)({
8629
8668
  scopes: { tenantId, projectId },
@@ -8654,7 +8693,7 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
8654
8693
  }
8655
8694
  }
8656
8695
  });
8657
- logger21.info(
8696
+ logger22.info(
8658
8697
  { sessionId, conversationId: conversation.id },
8659
8698
  "Created MCP session as conversation"
8660
8699
  );
@@ -8663,9 +8702,9 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
8663
8702
  });
8664
8703
  const server = await getServer(validatedContext, executionContext, sessionId, credentialStores);
8665
8704
  await server.connect(transport);
8666
- logger21.info({ sessionId }, "Server connected for initialization");
8705
+ logger22.info({ sessionId }, "Server connected for initialization");
8667
8706
  res.setHeader("Mcp-Session-Id", sessionId);
8668
- logger21.info(
8707
+ logger22.info(
8669
8708
  {
8670
8709
  sessionId,
8671
8710
  bodyMethod: body?.method,
@@ -8674,7 +8713,7 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
8674
8713
  "About to handle initialization request"
8675
8714
  );
8676
8715
  await transport.handleRequest(req, res, body);
8677
- logger21.info({ sessionId }, "Successfully handled initialization request");
8716
+ logger22.info({ sessionId }, "Successfully handled initialization request");
8678
8717
  return fetchToNode.toFetchResponse(res);
8679
8718
  };
8680
8719
  var handleExistingSessionRequest = async (body, executionContext, validatedContext, req, res, credentialStores) => {
@@ -8702,8 +8741,8 @@ var handleExistingSessionRequest = async (body, executionContext, validatedConte
8702
8741
  sessionId,
8703
8742
  conversation.metadata?.session_data?.mcpProtocolVersion
8704
8743
  );
8705
- logger21.info({ sessionId }, "Server connected and transport initialized");
8706
- logger21.info(
8744
+ logger22.info({ sessionId }, "Server connected and transport initialized");
8745
+ logger22.info(
8707
8746
  {
8708
8747
  sessionId,
8709
8748
  bodyKeys: Object.keys(body || {}),
@@ -8717,9 +8756,9 @@ var handleExistingSessionRequest = async (body, executionContext, validatedConte
8717
8756
  );
8718
8757
  try {
8719
8758
  await transport.handleRequest(req, res, body);
8720
- logger21.info({ sessionId }, "Successfully handled MCP request");
8759
+ logger22.info({ sessionId }, "Successfully handled MCP request");
8721
8760
  } catch (transportError) {
8722
- logger21.error(
8761
+ logger22.error(
8723
8762
  {
8724
8763
  sessionId,
8725
8764
  error: transportError,
@@ -8770,13 +8809,13 @@ app4.openapi(
8770
8809
  }
8771
8810
  const { executionContext } = paramValidation;
8772
8811
  const body = c.get("requestBody") || {};
8773
- logger21.info({ body, bodyKeys: Object.keys(body || {}) }, "Parsed request body");
8812
+ logger22.info({ body, bodyKeys: Object.keys(body || {}) }, "Parsed request body");
8774
8813
  const isInitRequest = body.method === "initialize";
8775
8814
  const { req, res } = fetchToNode.toReqRes(c.req.raw);
8776
8815
  const validatedContext = c.get("validatedContext") || {};
8777
8816
  const credentialStores = c.get("credentialStores");
8778
- logger21.info({ validatedContext }, "Validated context");
8779
- logger21.info({ req }, "request");
8817
+ logger22.info({ validatedContext }, "Validated context");
8818
+ logger22.info({ req }, "request");
8780
8819
  if (isInitRequest) {
8781
8820
  return await handleInitializationRequest(
8782
8821
  body,
@@ -8798,7 +8837,7 @@ app4.openapi(
8798
8837
  );
8799
8838
  }
8800
8839
  } catch (e) {
8801
- logger21.error(
8840
+ logger22.error(
8802
8841
  {
8803
8842
  error: e instanceof Error ? e.message : e,
8804
8843
  stack: e instanceof Error ? e.stack : void 0
@@ -8810,7 +8849,7 @@ app4.openapi(
8810
8849
  }
8811
8850
  );
8812
8851
  app4.get("/", async (c) => {
8813
- logger21.info({}, "Received GET MCP request");
8852
+ logger22.info({}, "Received GET MCP request");
8814
8853
  return c.json(
8815
8854
  {
8816
8855
  jsonrpc: "2.0",
@@ -8824,7 +8863,7 @@ app4.get("/", async (c) => {
8824
8863
  );
8825
8864
  });
8826
8865
  app4.delete("/", async (c) => {
8827
- logger21.info({}, "Received DELETE MCP request");
8866
+ logger22.info({}, "Received DELETE MCP request");
8828
8867
  return c.json(
8829
8868
  {
8830
8869
  jsonrpc: "2.0",
@@ -8835,7 +8874,7 @@ app4.delete("/", async (c) => {
8835
8874
  );
8836
8875
  });
8837
8876
  var mcp_default = app4;
8838
- var logger22 = agentsCore.getLogger("agents-run-api");
8877
+ var logger23 = agentsCore.getLogger("agents-run-api");
8839
8878
  function createExecutionHono(serverConfig, credentialStores) {
8840
8879
  const app6 = new zodOpenapi.OpenAPIHono();
8841
8880
  app6.use("*", otel.otel());
@@ -8851,7 +8890,7 @@ function createExecutionHono(serverConfig, credentialStores) {
8851
8890
  const body = await c.req.json();
8852
8891
  c.set("requestBody", body);
8853
8892
  } catch (error) {
8854
- logger22.debug({ error }, "Failed to parse JSON body, continuing without parsed body");
8893
+ logger23.debug({ error }, "Failed to parse JSON body, continuing without parsed body");
8855
8894
  }
8856
8895
  }
8857
8896
  return next();
@@ -8902,8 +8941,8 @@ function createExecutionHono(serverConfig, credentialStores) {
8902
8941
  if (!isExpectedError) {
8903
8942
  const errorMessage = err instanceof Error ? err.message : String(err);
8904
8943
  const errorStack = err instanceof Error ? err.stack : void 0;
8905
- if (logger22) {
8906
- logger22.error(
8944
+ if (logger23) {
8945
+ logger23.error(
8907
8946
  {
8908
8947
  error: err,
8909
8948
  message: errorMessage,
@@ -8915,8 +8954,8 @@ function createExecutionHono(serverConfig, credentialStores) {
8915
8954
  );
8916
8955
  }
8917
8956
  } else {
8918
- if (logger22) {
8919
- logger22.error(
8957
+ if (logger23) {
8958
+ logger23.error(
8920
8959
  {
8921
8960
  error: err,
8922
8961
  path: c.req.path,
@@ -8933,8 +8972,8 @@ function createExecutionHono(serverConfig, credentialStores) {
8933
8972
  const response = err.getResponse();
8934
8973
  return response;
8935
8974
  } catch (responseError) {
8936
- if (logger22) {
8937
- logger22.error({ error: responseError }, "Error while handling HTTPException response");
8975
+ if (logger23) {
8976
+ logger23.error({ error: responseError }, "Error while handling HTTPException response");
8938
8977
  }
8939
8978
  }
8940
8979
  }
@@ -8968,7 +9007,7 @@ function createExecutionHono(serverConfig, credentialStores) {
8968
9007
  app6.use("*", async (c, next) => {
8969
9008
  const executionContext = c.get("executionContext");
8970
9009
  if (!executionContext) {
8971
- logger22.debug({}, "Empty execution context");
9010
+ logger23.debug({}, "Empty execution context");
8972
9011
  return next();
8973
9012
  }
8974
9013
  const { tenantId, projectId, graphId } = executionContext;
@@ -8977,7 +9016,7 @@ function createExecutionHono(serverConfig, credentialStores) {
8977
9016
  if (requestBody) {
8978
9017
  conversationId = requestBody.conversationId;
8979
9018
  if (!conversationId) {
8980
- logger22.debug({ requestBody }, "No conversation ID found in request body");
9019
+ logger23.debug({ requestBody }, "No conversation ID found in request body");
8981
9020
  }
8982
9021
  }
8983
9022
  const entries = Object.fromEntries(
@@ -8992,7 +9031,7 @@ function createExecutionHono(serverConfig, credentialStores) {
8992
9031
  })
8993
9032
  );
8994
9033
  if (!Object.keys(entries).length) {
8995
- logger22.debug({}, "Empty entries for baggage");
9034
+ logger23.debug({}, "Empty entries for baggage");
8996
9035
  return next();
8997
9036
  }
8998
9037
  const bag = Object.entries(entries).reduce(
@@ -9059,9 +9098,9 @@ var defaultStores = agentsCore.createDefaultCredentialStores();
9059
9098
  var defaultRegistry = new agentsCore.CredentialStoreRegistry(defaultStores);
9060
9099
  var app5 = createExecutionHono(defaultConfig, defaultRegistry);
9061
9100
  var index_default = app5;
9062
- function createExecutionApp(config2) {
9063
- const serverConfig = config2?.serverConfig ?? defaultConfig;
9064
- const stores = config2?.credentialStores ?? defaultStores;
9101
+ function createExecutionApp(config) {
9102
+ const serverConfig = config?.serverConfig ?? defaultConfig;
9103
+ const stores = config?.credentialStores ?? defaultStores;
9065
9104
  const registry = new agentsCore.CredentialStoreRegistry(stores);
9066
9105
  return createExecutionHono(serverConfig, registry);
9067
9106
  }