@inkeep/agents-run-api 0.0.0-dev-20250915163022 → 0.0.0-dev-20250915202938

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.cjs +425 -348
  2. package/dist/index.js +425 -348
  3. package/package.json +2 -2
package/dist/index.cjs CHANGED
@@ -1159,6 +1159,128 @@ async function handleTasksResubscribe(c, agent, request) {
1159
1159
  });
1160
1160
  }
1161
1161
  }
1162
+ init_dbClient();
1163
+ agentsCore.getLogger("agents");
1164
+ function createAgentCard({
1165
+ dbAgent,
1166
+ baseUrl
1167
+ }) {
1168
+ const description = dbAgent.description || "AI Agent";
1169
+ return {
1170
+ name: dbAgent.name,
1171
+ description,
1172
+ url: baseUrl ? `${baseUrl}/a2a` : "",
1173
+ version: "1.0.0",
1174
+ capabilities: {
1175
+ streaming: true,
1176
+ // Enable streaming for A2A compliance
1177
+ pushNotifications: false,
1178
+ stateTransitionHistory: false
1179
+ },
1180
+ defaultInputModes: ["text", "text/plain"],
1181
+ defaultOutputModes: ["text", "text/plain"],
1182
+ skills: [],
1183
+ // Add provider info if available
1184
+ ...baseUrl && {
1185
+ provider: {
1186
+ organization: "Inkeep",
1187
+ url: baseUrl
1188
+ }
1189
+ }
1190
+ };
1191
+ }
1192
+ function generateDescriptionWithTransfers(baseDescription, internalRelations, externalRelations) {
1193
+ const transfers = [
1194
+ ...internalRelations.filter((rel) => rel.relationType === "transfer"),
1195
+ ...externalRelations.filter((rel) => rel.relationType === "transfer")
1196
+ ];
1197
+ const delegates = [
1198
+ ...internalRelations.filter((rel) => rel.relationType === "delegate"),
1199
+ ...externalRelations.filter((rel) => rel.relationType === "delegate")
1200
+ ];
1201
+ if (transfers.length === 0 && delegates.length === 0) {
1202
+ return baseDescription;
1203
+ }
1204
+ let enhancedDescription = baseDescription;
1205
+ if (transfers.length > 0) {
1206
+ const transferList = transfers.map((rel) => {
1207
+ const name = rel.externalAgent?.name || rel.name;
1208
+ const desc = rel.externalAgent?.description || rel.description || "";
1209
+ return `- ${name}: ${desc}`;
1210
+ }).join("\n");
1211
+ enhancedDescription += `
1212
+
1213
+ Can transfer to:
1214
+ ${transferList}`;
1215
+ }
1216
+ if (delegates.length > 0) {
1217
+ const delegateList = delegates.map((rel) => {
1218
+ const name = rel.externalAgent?.name || rel.name;
1219
+ const desc = rel.externalAgent?.description || rel.description || "";
1220
+ return `- ${name}: ${desc}`;
1221
+ }).join("\n");
1222
+ enhancedDescription += `
1223
+
1224
+ Can delegate to:
1225
+ ${delegateList}`;
1226
+ }
1227
+ return enhancedDescription;
1228
+ }
1229
+ async function hydrateAgent({
1230
+ dbAgent,
1231
+ graphId,
1232
+ baseUrl,
1233
+ apiKey,
1234
+ credentialStoreRegistry
1235
+ }) {
1236
+ try {
1237
+ const taskHandlerConfig = await createTaskHandlerConfig({
1238
+ tenantId: dbAgent.tenantId,
1239
+ projectId: dbAgent.projectId,
1240
+ graphId,
1241
+ agentId: dbAgent.id,
1242
+ baseUrl,
1243
+ apiKey
1244
+ });
1245
+ const taskHandler = createTaskHandler(taskHandlerConfig, credentialStoreRegistry);
1246
+ const agentCard = createAgentCard({
1247
+ dbAgent,
1248
+ baseUrl
1249
+ });
1250
+ return {
1251
+ agentId: dbAgent.id,
1252
+ tenantId: dbAgent.tenantId,
1253
+ projectId: dbAgent.projectId,
1254
+ graphId,
1255
+ agentCard,
1256
+ taskHandler
1257
+ };
1258
+ } catch (error) {
1259
+ console.error(`\u274C Failed to hydrate agent ${dbAgent.id}:`, error);
1260
+ throw error;
1261
+ }
1262
+ }
1263
+ async function getRegisteredAgent(executionContext, credentialStoreRegistry) {
1264
+ const { tenantId, projectId, graphId, agentId, baseUrl, apiKey } = executionContext;
1265
+ if (!agentId) {
1266
+ throw new Error("Agent ID is required");
1267
+ }
1268
+ const dbAgent = await agentsCore.getAgentById(dbClient_default)({
1269
+ scopes: { tenantId, projectId },
1270
+ agentId
1271
+ });
1272
+ if (!dbAgent) {
1273
+ return null;
1274
+ }
1275
+ const agentFrameworkBaseUrl = `${baseUrl}/agents`;
1276
+ return hydrateAgent({
1277
+ dbAgent,
1278
+ graphId,
1279
+ baseUrl: agentFrameworkBaseUrl,
1280
+ credentialStoreRegistry,
1281
+ apiKey
1282
+ });
1283
+ }
1162
1284
 
1163
1285
  // src/agents/generateTaskHandler.ts
1164
1286
  init_dbClient();
@@ -1202,10 +1324,10 @@ function statusUpdateOp(ctx) {
1202
1324
  ctx
1203
1325
  };
1204
1326
  }
1205
- var logger3 = agentsCore.getLogger("DataComponentSchema");
1327
+ var logger4 = agentsCore.getLogger("DataComponentSchema");
1206
1328
  function jsonSchemaToZod(jsonSchema) {
1207
1329
  if (!jsonSchema || typeof jsonSchema !== "object") {
1208
- logger3.warn({ jsonSchema }, "Invalid JSON schema provided, using string fallback");
1330
+ logger4.warn({ jsonSchema }, "Invalid JSON schema provided, using string fallback");
1209
1331
  return z5.z.string();
1210
1332
  }
1211
1333
  switch (jsonSchema.type) {
@@ -1232,7 +1354,7 @@ function jsonSchemaToZod(jsonSchema) {
1232
1354
  case "null":
1233
1355
  return z5.z.null();
1234
1356
  default:
1235
- logger3.warn(
1357
+ logger4.warn(
1236
1358
  {
1237
1359
  unsupportedType: jsonSchema.type,
1238
1360
  schema: jsonSchema
@@ -1286,7 +1408,7 @@ __publicField(_ArtifactReferenceSchema, "ARTIFACT_PROPS_SCHEMA", {
1286
1408
  required: ["artifact_id", "task_id"]
1287
1409
  });
1288
1410
  var ArtifactReferenceSchema = _ArtifactReferenceSchema;
1289
- var logger4 = agentsCore.getLogger("ModelFactory");
1411
+ var logger5 = agentsCore.getLogger("ModelFactory");
1290
1412
  var _ModelFactory = class _ModelFactory {
1291
1413
  /**
1292
1414
  * Create a language model instance from configuration
@@ -1301,7 +1423,7 @@ var _ModelFactory = class _ModelFactory {
1301
1423
  const modelSettings = config2;
1302
1424
  const modelString = modelSettings.model.trim();
1303
1425
  const { provider, modelName } = _ModelFactory.parseModelString(modelString);
1304
- logger4.debug(
1426
+ logger5.debug(
1305
1427
  {
1306
1428
  provider,
1307
1429
  model: modelName,
@@ -1322,7 +1444,7 @@ var _ModelFactory = class _ModelFactory {
1322
1444
  );
1323
1445
  }
1324
1446
  } catch (error) {
1325
- logger4.error(
1447
+ logger5.error(
1326
1448
  {
1327
1449
  provider,
1328
1450
  model: modelName,
@@ -1345,7 +1467,7 @@ var _ModelFactory = class _ModelFactory {
1345
1467
  const [provider, ...modelParts] = modelString.split("/");
1346
1468
  const normalizedProvider = provider.toLowerCase();
1347
1469
  if (!_ModelFactory.SUPPORTED_PROVIDERS.includes(normalizedProvider)) {
1348
- logger4.warn(
1470
+ logger5.warn(
1349
1471
  { provider: normalizedProvider, modelName: modelParts.join("/") },
1350
1472
  "Unsupported provider detected, falling back to anthropic"
1351
1473
  );
@@ -1374,14 +1496,14 @@ var _ModelFactory = class _ModelFactory {
1374
1496
  anthropicConfig.baseURL = providerOptions.baseUrl || providerOptions.baseURL;
1375
1497
  }
1376
1498
  if (providerOptions?.gateway) {
1377
- logger4.info(
1499
+ logger5.info(
1378
1500
  { gateway: providerOptions.gateway },
1379
1501
  "Setting up AI Gateway for Anthropic model"
1380
1502
  );
1381
1503
  Object.assign(anthropicConfig, providerOptions.gateway);
1382
1504
  }
1383
1505
  if (Object.keys(anthropicConfig).length > 0) {
1384
- logger4.info({ config: anthropicConfig }, "Applying custom Anthropic provider configuration");
1506
+ logger5.info({ config: anthropicConfig }, "Applying custom Anthropic provider configuration");
1385
1507
  const provider = anthropic.createAnthropic(anthropicConfig);
1386
1508
  return provider(modelName);
1387
1509
  }
@@ -1396,11 +1518,11 @@ var _ModelFactory = class _ModelFactory {
1396
1518
  openaiConfig.baseURL = providerOptions.baseUrl || providerOptions.baseURL;
1397
1519
  }
1398
1520
  if (providerOptions?.gateway) {
1399
- logger4.info({ gateway: providerOptions.gateway }, "Setting up AI Gateway for OpenAI model");
1521
+ logger5.info({ gateway: providerOptions.gateway }, "Setting up AI Gateway for OpenAI model");
1400
1522
  Object.assign(openaiConfig, providerOptions.gateway);
1401
1523
  }
1402
1524
  if (Object.keys(openaiConfig).length > 0) {
1403
- logger4.info({ config: openaiConfig }, "Applying custom OpenAI provider configuration");
1525
+ logger5.info({ config: openaiConfig }, "Applying custom OpenAI provider configuration");
1404
1526
  const provider = openai.createOpenAI(openaiConfig);
1405
1527
  return provider(modelName);
1406
1528
  }
@@ -1494,7 +1616,7 @@ function unregisterStreamHelper(requestId2) {
1494
1616
  }
1495
1617
 
1496
1618
  // src/utils/graph-session.ts
1497
- var logger5 = agentsCore.getLogger("GraphSession");
1619
+ var logger6 = agentsCore.getLogger("GraphSession");
1498
1620
  var GraphSession = class {
1499
1621
  // Track scheduled timeouts for cleanup
1500
1622
  constructor(sessionId, messageId, graphId, tenantId, projectId) {
@@ -1518,7 +1640,7 @@ var GraphSession = class {
1518
1640
  __publicField(this, "MAX_PENDING_ARTIFACTS", 100);
1519
1641
  // Prevent unbounded growth
1520
1642
  __publicField(this, "scheduledTimeouts");
1521
- logger5.debug({ sessionId, messageId, graphId }, "GraphSession created");
1643
+ logger6.debug({ sessionId, messageId, graphId }, "GraphSession created");
1522
1644
  }
1523
1645
  /**
1524
1646
  * Initialize status updates for this session
@@ -1532,15 +1654,15 @@ var GraphSession = class {
1532
1654
  summarizerModel,
1533
1655
  baseModel,
1534
1656
  config: {
1535
- numEvents: config2.numEvents || 10,
1536
- timeInSeconds: config2.timeInSeconds || 30,
1657
+ numEvents: config2.numEvents || 1,
1658
+ timeInSeconds: config2.timeInSeconds || 2,
1537
1659
  ...config2
1538
1660
  }
1539
1661
  };
1540
1662
  if (this.statusUpdateState.config.timeInSeconds) {
1541
1663
  this.statusUpdateTimer = setInterval(async () => {
1542
1664
  if (!this.statusUpdateState || this.isEnded) {
1543
- logger5.debug(
1665
+ logger6.debug(
1544
1666
  { sessionId: this.sessionId },
1545
1667
  "Timer triggered but session already cleaned up or ended"
1546
1668
  );
@@ -1552,7 +1674,7 @@ var GraphSession = class {
1552
1674
  }
1553
1675
  await this.checkAndSendTimeBasedUpdate();
1554
1676
  }, this.statusUpdateState.config.timeInSeconds * 1e3);
1555
- logger5.info(
1677
+ logger6.info(
1556
1678
  {
1557
1679
  sessionId: this.sessionId,
1558
1680
  intervalMs: this.statusUpdateState.config.timeInSeconds * 1e3
@@ -1566,7 +1688,7 @@ var GraphSession = class {
1566
1688
  */
1567
1689
  recordEvent(eventType, agentId, data) {
1568
1690
  if (this.isEnded) {
1569
- logger5.debug(
1691
+ logger6.debug(
1570
1692
  {
1571
1693
  sessionId: this.sessionId,
1572
1694
  eventType,
@@ -1586,7 +1708,7 @@ var GraphSession = class {
1586
1708
  if (eventType === "artifact_saved" && data.pendingGeneration) {
1587
1709
  const artifactId = data.artifactId;
1588
1710
  if (this.pendingArtifacts.size >= this.MAX_PENDING_ARTIFACTS) {
1589
- logger5.warn(
1711
+ logger6.warn(
1590
1712
  {
1591
1713
  sessionId: this.sessionId,
1592
1714
  artifactId,
@@ -1607,7 +1729,7 @@ var GraphSession = class {
1607
1729
  this.artifactProcessingErrors.set(artifactId, errorCount);
1608
1730
  if (errorCount >= this.MAX_ARTIFACT_RETRIES) {
1609
1731
  this.pendingArtifacts.delete(artifactId);
1610
- logger5.error(
1732
+ logger6.error(
1611
1733
  {
1612
1734
  sessionId: this.sessionId,
1613
1735
  artifactId,
@@ -1619,7 +1741,7 @@ var GraphSession = class {
1619
1741
  "Artifact processing failed after max retries, giving up"
1620
1742
  );
1621
1743
  } else {
1622
- logger5.warn(
1744
+ logger6.warn(
1623
1745
  {
1624
1746
  sessionId: this.sessionId,
1625
1747
  artifactId,
@@ -1641,14 +1763,14 @@ var GraphSession = class {
1641
1763
  */
1642
1764
  checkStatusUpdates() {
1643
1765
  if (this.isEnded) {
1644
- logger5.debug(
1766
+ logger6.debug(
1645
1767
  { sessionId: this.sessionId },
1646
1768
  "Session has ended - skipping status update check"
1647
1769
  );
1648
1770
  return;
1649
1771
  }
1650
1772
  if (!this.statusUpdateState) {
1651
- logger5.debug({ sessionId: this.sessionId }, "No status update state - skipping check");
1773
+ logger6.debug({ sessionId: this.sessionId }, "No status update state - skipping check");
1652
1774
  return;
1653
1775
  }
1654
1776
  const statusUpdateState = this.statusUpdateState;
@@ -1659,11 +1781,11 @@ var GraphSession = class {
1659
1781
  */
1660
1782
  async checkAndSendTimeBasedUpdate() {
1661
1783
  if (this.isEnded) {
1662
- logger5.debug({ sessionId: this.sessionId }, "Session has ended - skipping time-based update");
1784
+ logger6.debug({ sessionId: this.sessionId }, "Session has ended - skipping time-based update");
1663
1785
  return;
1664
1786
  }
1665
1787
  if (!this.statusUpdateState) {
1666
- logger5.debug(
1788
+ logger6.debug(
1667
1789
  { sessionId: this.sessionId },
1668
1790
  "No status updates configured for time-based check"
1669
1791
  );
@@ -1676,7 +1798,7 @@ var GraphSession = class {
1676
1798
  try {
1677
1799
  await this.generateAndSendUpdate();
1678
1800
  } catch (error) {
1679
- logger5.error(
1801
+ logger6.error(
1680
1802
  {
1681
1803
  sessionId: this.sessionId,
1682
1804
  error: error instanceof Error ? error.message : "Unknown error"
@@ -1769,29 +1891,29 @@ var GraphSession = class {
1769
1891
  */
1770
1892
  async generateAndSendUpdate() {
1771
1893
  if (this.isEnded) {
1772
- logger5.debug({ sessionId: this.sessionId }, "Session has ended - not generating update");
1894
+ logger6.debug({ sessionId: this.sessionId }, "Session has ended - not generating update");
1773
1895
  return;
1774
1896
  }
1775
1897
  if (this.isTextStreaming) {
1776
- logger5.debug(
1898
+ logger6.debug(
1777
1899
  { sessionId: this.sessionId },
1778
1900
  "Text is currently streaming - skipping status update"
1779
1901
  );
1780
1902
  return;
1781
1903
  }
1782
1904
  if (this.isGeneratingUpdate) {
1783
- logger5.debug(
1905
+ logger6.debug(
1784
1906
  { sessionId: this.sessionId },
1785
1907
  "Update already in progress - skipping duplicate generation"
1786
1908
  );
1787
1909
  return;
1788
1910
  }
1789
1911
  if (!this.statusUpdateState) {
1790
- logger5.warn({ sessionId: this.sessionId }, "No status update state - cannot generate update");
1912
+ logger6.warn({ sessionId: this.sessionId }, "No status update state - cannot generate update");
1791
1913
  return;
1792
1914
  }
1793
1915
  if (!this.graphId) {
1794
- logger5.warn({ sessionId: this.sessionId }, "No graph ID - cannot generate update");
1916
+ logger6.warn({ sessionId: this.sessionId }, "No graph ID - cannot generate update");
1795
1917
  return;
1796
1918
  }
1797
1919
  const newEventCount = this.events.length - this.statusUpdateState.lastEventCount;
@@ -1804,7 +1926,7 @@ var GraphSession = class {
1804
1926
  try {
1805
1927
  const streamHelper = getStreamHelper(this.sessionId);
1806
1928
  if (!streamHelper) {
1807
- logger5.warn(
1929
+ logger6.warn(
1808
1930
  { sessionId: this.sessionId },
1809
1931
  "No stream helper found - cannot send status update"
1810
1932
  );
@@ -1825,7 +1947,7 @@ var GraphSession = class {
1825
1947
  if (result.operations && result.operations.length > 0) {
1826
1948
  for (const op of result.operations) {
1827
1949
  if (!op || !op.type || !op.data || Object.keys(op.data).length === 0) {
1828
- logger5.warn(
1950
+ logger6.warn(
1829
1951
  {
1830
1952
  sessionId: this.sessionId,
1831
1953
  operation: op
@@ -1878,7 +2000,7 @@ var GraphSession = class {
1878
2000
  this.previousSummaries.shift();
1879
2001
  }
1880
2002
  if (!operation || !operation.type || !operation.ctx) {
1881
- logger5.warn(
2003
+ logger6.warn(
1882
2004
  {
1883
2005
  sessionId: this.sessionId,
1884
2006
  operation
@@ -1893,7 +2015,7 @@ var GraphSession = class {
1893
2015
  this.statusUpdateState.lastEventCount = this.events.length;
1894
2016
  }
1895
2017
  } catch (error) {
1896
- logger5.error(
2018
+ logger6.error(
1897
2019
  {
1898
2020
  sessionId: this.sessionId,
1899
2021
  error: error instanceof Error ? error.message : "Unknown error",
@@ -1931,7 +2053,7 @@ var GraphSession = class {
1931
2053
  this.releaseUpdateLock();
1932
2054
  }
1933
2055
  } catch (error) {
1934
- logger5.error(
2056
+ logger6.error(
1935
2057
  {
1936
2058
  sessionId: this.sessionId,
1937
2059
  error: error instanceof Error ? error.message : "Unknown error"
@@ -2008,7 +2130,7 @@ User's Question/Context:
2008
2130
  ${conversationHistory}
2009
2131
  ` : "";
2010
2132
  } catch (error) {
2011
- logger5.warn(
2133
+ logger6.warn(
2012
2134
  { sessionId: this.sessionId, error },
2013
2135
  "Failed to fetch conversation history for status update"
2014
2136
  );
@@ -2060,7 +2182,7 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
2060
2182
  return text.trim();
2061
2183
  } catch (error) {
2062
2184
  agentsCore.setSpanWithError(span, error);
2063
- logger5.error({ error }, "Failed to generate summary, using fallback");
2185
+ logger6.error({ error }, "Failed to generate summary, using fallback");
2064
2186
  return this.generateFallbackSummary(newEvents, elapsedTime);
2065
2187
  } finally {
2066
2188
  span.end();
@@ -2106,7 +2228,7 @@ User's Question/Context:
2106
2228
  ${conversationHistory}
2107
2229
  ` : "";
2108
2230
  } catch (error) {
2109
- logger5.warn(
2231
+ logger6.warn(
2110
2232
  { sessionId: this.sessionId, error },
2111
2233
  "Failed to fetch conversation history for structured status update"
2112
2234
  );
@@ -2149,9 +2271,11 @@ Rules:
2149
2271
  - Labels MUST contain the ACTUAL information discovered ("Found X", "Learned Y", "Discovered Z requires A")
2150
2272
  - DO NOT use action words like "Searching", "Processing", "Analyzing" - state what was FOUND
2151
2273
  - Include specific details, numbers, requirements, or insights discovered
2152
- - You are ONE AI (no agents/delegations)
2153
- - Anonymize all internal operations so that the information appears descriptive and USER FRIENDLY. HIDE INTERNAL OPERATIONS!
2154
- - 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"
2274
+ - You are ONE unified AI system - NEVER mention agents, transfers, delegations, or routing
2275
+ - CRITICAL: NEVER use the words "transfer", "delegation", "agent", "routing", or any internal system terminology in labels
2276
+ - Present all operations as seamless actions by a single system
2277
+ - Anonymize all internal operations so that the information appears descriptive and USER FRIENDLY. HIDE ALL INTERNAL OPERATIONS!
2278
+ - Bad examples: "Transferring to search agent", "Delegating task", "Routing request", "Processing request", or not using the no_relevant_updates
2155
2279
  - 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.
2156
2280
 
2157
2281
  REMEMBER YOU CAN ONLY USE 'no_relevant_updates' ALONE! IT CANNOT BE CONCATENATED WITH OTHER STATUS UPDATES!
@@ -2205,7 +2329,7 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
2205
2329
  return { operations };
2206
2330
  } catch (error) {
2207
2331
  agentsCore.setSpanWithError(span, error);
2208
- logger5.error({ error }, "Failed to generate structured update, using fallback");
2332
+ logger6.error({ error }, "Failed to generate structured update, using fallback");
2209
2333
  return { operations: [] };
2210
2334
  } finally {
2211
2335
  span.end();
@@ -2312,8 +2436,7 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
2312
2436
  case "transfer": {
2313
2437
  const data = event.data;
2314
2438
  activities.push(
2315
- `\u{1F504} **Transfer**: ${data.fromAgent} \u2192 ${data.targetAgent}
2316
- ${data.reason ? `Reason: ${data.reason}` : "Control transfer"}
2439
+ `\u{1F504} **Continuing**: ${data.reason || "Processing request"}
2317
2440
  ${data.context ? `Context: ${JSON.stringify(data.context, null, 2)}` : ""}`
2318
2441
  );
2319
2442
  break;
@@ -2321,8 +2444,7 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
2321
2444
  case "delegation_sent": {
2322
2445
  const data = event.data;
2323
2446
  activities.push(
2324
- `\u{1F4E4} **Delegation Sent** [${data.delegationId}]: ${data.fromAgent} \u2192 ${data.targetAgent}
2325
- Task: ${data.taskDescription}
2447
+ `\u{1F4E4} **Processing**: ${data.taskDescription}
2326
2448
  ${data.context ? `Context: ${JSON.stringify(data.context, null, 2)}` : ""}`
2327
2449
  );
2328
2450
  break;
@@ -2330,7 +2452,7 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
2330
2452
  case "delegation_returned": {
2331
2453
  const data = event.data;
2332
2454
  activities.push(
2333
- `\u{1F4E5} **Delegation Returned** [${data.delegationId}]: ${data.fromAgent} \u2190 ${data.targetAgent}
2455
+ `\u{1F4E5} **Completed subtask**
2334
2456
  Result: ${JSON.stringify(data.result, null, 2)}`
2335
2457
  );
2336
2458
  break;
@@ -2349,16 +2471,16 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
2349
2471
  case "agent_reasoning": {
2350
2472
  const data = event.data;
2351
2473
  activities.push(
2352
- `\u2699\uFE0F **Reasoning**: reasoning
2353
- Full Details: ${JSON.stringify(data.parts, null, 2)}`
2474
+ `\u2699\uFE0F **Analyzing request**
2475
+ Details: ${JSON.stringify(data.parts, null, 2)}`
2354
2476
  );
2355
2477
  break;
2356
2478
  }
2357
2479
  case "agent_generate": {
2358
2480
  const data = event.data;
2359
2481
  activities.push(
2360
- `\u2699\uFE0F **Generation**: ${data.generationType}
2361
- Full Details: ${JSON.stringify(data.parts, null, 2)}`
2482
+ `\u2699\uFE0F **Preparing response**
2483
+ Details: ${JSON.stringify(data.parts, null, 2)}`
2362
2484
  );
2363
2485
  break;
2364
2486
  }
@@ -2532,7 +2654,7 @@ Make it specific and relevant.`;
2532
2654
  taskId: artifactData.taskId,
2533
2655
  artifacts: [artifactToSave]
2534
2656
  });
2535
- logger5.info(
2657
+ logger6.info(
2536
2658
  {
2537
2659
  sessionId: this.sessionId,
2538
2660
  artifactId: artifactData.artifactId,
@@ -2549,7 +2671,7 @@ Make it specific and relevant.`;
2549
2671
  span.setStatus({ code: api.SpanStatusCode.OK });
2550
2672
  } catch (error) {
2551
2673
  agentsCore.setSpanWithError(span, error);
2552
- logger5.error(
2674
+ logger6.error(
2553
2675
  {
2554
2676
  sessionId: this.sessionId,
2555
2677
  artifactId: artifactData.artifactId,
@@ -2585,7 +2707,7 @@ Make it specific and relevant.`;
2585
2707
  taskId: artifactData.taskId,
2586
2708
  artifacts: [fallbackArtifact]
2587
2709
  });
2588
- logger5.info(
2710
+ logger6.info(
2589
2711
  {
2590
2712
  sessionId: this.sessionId,
2591
2713
  artifactId: artifactData.artifactId
@@ -2594,7 +2716,7 @@ Make it specific and relevant.`;
2594
2716
  );
2595
2717
  }
2596
2718
  } catch (fallbackError) {
2597
- logger5.error(
2719
+ logger6.error(
2598
2720
  {
2599
2721
  sessionId: this.sessionId,
2600
2722
  artifactId: artifactData.artifactId,
@@ -2621,7 +2743,7 @@ var GraphSessionManager = class {
2621
2743
  const sessionId = messageId;
2622
2744
  const session = new GraphSession(sessionId, messageId, graphId, tenantId, projectId);
2623
2745
  this.sessions.set(sessionId, session);
2624
- logger5.info({ sessionId, messageId, graphId, tenantId, projectId }, "GraphSession created");
2746
+ logger6.info({ sessionId, messageId, graphId, tenantId, projectId }, "GraphSession created");
2625
2747
  return sessionId;
2626
2748
  }
2627
2749
  /**
@@ -2632,7 +2754,7 @@ var GraphSessionManager = class {
2632
2754
  if (session) {
2633
2755
  session.initializeStatusUpdates(config2, summarizerModel);
2634
2756
  } else {
2635
- logger5.error(
2757
+ logger6.error(
2636
2758
  {
2637
2759
  sessionId,
2638
2760
  availableSessions: Array.from(this.sessions.keys())
@@ -2653,7 +2775,7 @@ var GraphSessionManager = class {
2653
2775
  recordEvent(sessionId, eventType, agentId, data) {
2654
2776
  const session = this.sessions.get(sessionId);
2655
2777
  if (!session) {
2656
- logger5.warn({ sessionId }, "Attempted to record event in non-existent session");
2778
+ logger6.warn({ sessionId }, "Attempted to record event in non-existent session");
2657
2779
  return;
2658
2780
  }
2659
2781
  session.recordEvent(eventType, agentId, data);
@@ -2664,12 +2786,12 @@ var GraphSessionManager = class {
2664
2786
  endSession(sessionId) {
2665
2787
  const session = this.sessions.get(sessionId);
2666
2788
  if (!session) {
2667
- logger5.warn({ sessionId }, "Attempted to end non-existent session");
2789
+ logger6.warn({ sessionId }, "Attempted to end non-existent session");
2668
2790
  return [];
2669
2791
  }
2670
2792
  const events = session.getEvents();
2671
2793
  const summary = session.getSummary();
2672
- logger5.info({ sessionId, summary }, "GraphSession ended");
2794
+ logger6.info({ sessionId, summary }, "GraphSession ended");
2673
2795
  session.cleanup();
2674
2796
  this.sessions.delete(sessionId);
2675
2797
  return events;
@@ -2698,7 +2820,7 @@ var graphSessionManager = new GraphSessionManager();
2698
2820
 
2699
2821
  // src/utils/artifact-parser.ts
2700
2822
  init_dbClient();
2701
- var logger6 = agentsCore.getLogger("ArtifactParser");
2823
+ var logger7 = agentsCore.getLogger("ArtifactParser");
2702
2824
  var _ArtifactParser = class _ArtifactParser {
2703
2825
  constructor(tenantId) {
2704
2826
  this.tenantId = tenantId;
@@ -2714,9 +2836,7 @@ var _ArtifactParser = class _ArtifactParser {
2714
2836
  * More robust detection that handles streaming fragments
2715
2837
  */
2716
2838
  hasIncompleteArtifact(text) {
2717
- return /^.*<(?:artifact(?::ref)?|a(?:r(?:t(?:i(?:f(?:a(?:c(?:t(?::(?:r(?:e(?:f)?)?)?)?)?)?)?)?)?)?)?)?$/.test(
2718
- text
2719
- ) || /^.*<artifact:ref(?:[^>]*)$/.test(text) || // Incomplete artifact:ref at end
2839
+ return /<(a(r(t(i(f(a(c(t(:?(r(e(f)?)?)?)?)?)?)?)?)?)?)?)?$/.test(text) || /<artifact:ref[^>]+$/.test(text) || // Incomplete artifact ref at end
2720
2840
  this.findSafeTextBoundary(text) < text.length;
2721
2841
  }
2722
2842
  /**
@@ -2725,10 +2845,10 @@ var _ArtifactParser = class _ArtifactParser {
2725
2845
  */
2726
2846
  findSafeTextBoundary(text) {
2727
2847
  const endPatterns = [
2728
- /^.*<artifact:ref(?:[^/>]+(?:[^>]*[^/])?)?$/,
2848
+ /<artifact:ref(?![^>]*\/>).*$/,
2729
2849
  // artifact:ref that doesn't end with />
2730
- /^.*<(?:artifact(?::ref)?|a(?:r(?:t(?:i(?:f(?:a(?:c(?:t(?::(?:r(?:e(?:f)?)?)?)?)?)?)?)?)?)?)?)?$/
2731
- // Safe partial artifact pattern
2850
+ /<(a(r(t(i(f(a(c(t(:?(r(e(f)?)?)?)?)?)?)?)?)?)?)?)?$/
2851
+ // Any partial artifact pattern at end
2732
2852
  ];
2733
2853
  for (const pattern of endPatterns) {
2734
2854
  const match = text.match(pattern);
@@ -2764,7 +2884,7 @@ var _ArtifactParser = class _ArtifactParser {
2764
2884
  id: taskId
2765
2885
  });
2766
2886
  if (!task) {
2767
- logger6.warn({ taskId }, "Task not found when fetching artifacts");
2887
+ logger7.warn({ taskId }, "Task not found when fetching artifacts");
2768
2888
  continue;
2769
2889
  }
2770
2890
  const taskArtifacts = await agentsCore.getLedgerArtifacts(dbClient_default)({
@@ -2776,9 +2896,9 @@ var _ArtifactParser = class _ArtifactParser {
2776
2896
  artifacts.set(key, artifact);
2777
2897
  }
2778
2898
  }
2779
- logger6.debug({ contextId, count: artifacts.size }, "Loaded context artifacts");
2899
+ logger7.debug({ contextId, count: artifacts.size }, "Loaded context artifacts");
2780
2900
  } catch (error) {
2781
- logger6.error({ error, contextId }, "Error loading context artifacts");
2901
+ logger7.error({ error, contextId }, "Error loading context artifacts");
2782
2902
  }
2783
2903
  return artifacts;
2784
2904
  }
@@ -2881,7 +3001,7 @@ var _ArtifactParser = class _ArtifactParser {
2881
3001
  id: taskId
2882
3002
  });
2883
3003
  if (!task) {
2884
- logger6.warn({ taskId }, "Task not found when fetching artifact");
3004
+ logger7.warn({ taskId }, "Task not found when fetching artifact");
2885
3005
  return null;
2886
3006
  }
2887
3007
  const artifacts = await agentsCore.getLedgerArtifacts(dbClient_default)({
@@ -2893,7 +3013,7 @@ var _ArtifactParser = class _ArtifactParser {
2893
3013
  return this.formatArtifactData(artifacts[0], artifactId, taskId);
2894
3014
  }
2895
3015
  } catch (error) {
2896
- logger6.warn({ artifactId, taskId, error }, "Failed to fetch artifact");
3016
+ logger7.warn({ artifactId, taskId, error }, "Failed to fetch artifact");
2897
3017
  }
2898
3018
  return null;
2899
3019
  }
@@ -2929,11 +3049,11 @@ var _ArtifactParser = class _ArtifactParser {
2929
3049
  __publicField(_ArtifactParser, "ARTIFACT_REGEX", /<artifact:ref\s+id="([^"]*?)"\s+task="([^"]*?)"\s*\/>/gs);
2930
3050
  __publicField(_ArtifactParser, "ARTIFACT_CHECK_REGEX", /<artifact:ref\s+(?=.*id="[^"]+")(?=.*task="[^"]+")[^>]*\/>/);
2931
3051
  // Regex for catching any partial artifact pattern (< + any prefix of "artifact:ref")
2932
- __publicField(_ArtifactParser, "INCOMPLETE_ARTIFACT_REGEX", /<(a(r(t(i(f(a(c(t(:(r(e(f?)?)?)?)?)?)?)?)?)?)?)?)?$/g);
3052
+ __publicField(_ArtifactParser, "INCOMPLETE_ARTIFACT_REGEX", /<(a(r(t(i(f(a(c(t(:?(r(e(f)?)?)?)?)?)?)?)?)?)?)?)?$/g);
2933
3053
  var ArtifactParser = _ArtifactParser;
2934
3054
 
2935
3055
  // src/utils/incremental-stream-parser.ts
2936
- var logger7 = agentsCore.getLogger("IncrementalStreamParser");
3056
+ var logger8 = agentsCore.getLogger("IncrementalStreamParser");
2937
3057
  var IncrementalStreamParser = class {
2938
3058
  constructor(streamHelper, tenantId, contextId) {
2939
3059
  __publicField(this, "buffer", "");
@@ -2993,13 +3113,13 @@ var IncrementalStreamParser = class {
2993
3113
  if (part.type === "tool-call-delta" && part.toolName === targetToolName) {
2994
3114
  const delta = part.argsTextDelta || "";
2995
3115
  if (jsonBuffer.length + delta.length > MAX_BUFFER_SIZE) {
2996
- logger7.warn({ bufferSize: jsonBuffer.length + delta.length, maxSize: MAX_BUFFER_SIZE }, "JSON buffer exceeded maximum size, truncating");
3116
+ logger8.warn({ bufferSize: jsonBuffer.length + delta.length, maxSize: MAX_BUFFER_SIZE }, "JSON buffer exceeded maximum size, truncating");
2997
3117
  jsonBuffer = jsonBuffer.slice(-MAX_BUFFER_SIZE / 2);
2998
3118
  }
2999
3119
  jsonBuffer += delta;
3000
3120
  for (const char of delta) {
3001
3121
  if (componentBuffer.length > MAX_BUFFER_SIZE) {
3002
- logger7.warn({ bufferSize: componentBuffer.length, maxSize: MAX_BUFFER_SIZE }, "Component buffer exceeded maximum size, resetting");
3122
+ logger8.warn({ bufferSize: componentBuffer.length, maxSize: MAX_BUFFER_SIZE }, "Component buffer exceeded maximum size, resetting");
3003
3123
  componentBuffer = "";
3004
3124
  depth = 0;
3005
3125
  continue;
@@ -3014,7 +3134,7 @@ var IncrementalStreamParser = class {
3014
3134
  if (componentMatch) {
3015
3135
  const MAX_COMPONENT_SIZE = 1024 * 1024;
3016
3136
  if (componentMatch[0].length > MAX_COMPONENT_SIZE) {
3017
- logger7.warn(
3137
+ logger8.warn(
3018
3138
  {
3019
3139
  size: componentMatch[0].length,
3020
3140
  maxSize: MAX_COMPONENT_SIZE
@@ -3027,7 +3147,7 @@ var IncrementalStreamParser = class {
3027
3147
  try {
3028
3148
  const component = JSON.parse(componentMatch[0]);
3029
3149
  if (typeof component !== "object" || !component.id) {
3030
- logger7.warn({ component }, "Invalid component structure, skipping");
3150
+ logger8.warn({ component }, "Invalid component structure, skipping");
3031
3151
  componentBuffer = "";
3032
3152
  continue;
3033
3153
  }
@@ -3040,7 +3160,7 @@ var IncrementalStreamParser = class {
3040
3160
  componentsStreamed++;
3041
3161
  componentBuffer = "";
3042
3162
  } catch (e) {
3043
- logger7.debug({ error: e }, "Failed to parse component, continuing to accumulate");
3163
+ logger8.debug({ error: e }, "Failed to parse component, continuing to accumulate");
3044
3164
  }
3045
3165
  }
3046
3166
  }
@@ -3057,7 +3177,7 @@ var IncrementalStreamParser = class {
3057
3177
  break;
3058
3178
  }
3059
3179
  }
3060
- logger7.debug({ componentsStreamed }, "Finished streaming components");
3180
+ logger8.debug({ componentsStreamed }, "Finished streaming components");
3061
3181
  }
3062
3182
  /**
3063
3183
  * Legacy method for backward compatibility - defaults to text processing
@@ -3201,7 +3321,7 @@ var IncrementalStreamParser = class {
3201
3321
  };
3202
3322
 
3203
3323
  // src/utils/response-formatter.ts
3204
- var logger8 = agentsCore.getLogger("ResponseFormatter");
3324
+ var logger9 = agentsCore.getLogger("ResponseFormatter");
3205
3325
  var ResponseFormatter = class {
3206
3326
  constructor(tenantId) {
3207
3327
  __publicField(this, "artifactParser");
@@ -3232,7 +3352,7 @@ var ResponseFormatter = class {
3232
3352
  return { parts };
3233
3353
  } catch (error) {
3234
3354
  agentsCore.setSpanWithError(span, error);
3235
- logger8.error({ error, responseObject }, "Error formatting object response");
3355
+ logger9.error({ error, responseObject }, "Error formatting object response");
3236
3356
  return {
3237
3357
  parts: [{ kind: "data", data: responseObject }]
3238
3358
  };
@@ -3283,7 +3403,7 @@ var ResponseFormatter = class {
3283
3403
  return { parts };
3284
3404
  } catch (error) {
3285
3405
  agentsCore.setSpanWithError(span, error);
3286
- logger8.error({ error, responseText }, "Error formatting response");
3406
+ logger9.error({ error, responseText }, "Error formatting response");
3287
3407
  return { text: responseText };
3288
3408
  } finally {
3289
3409
  span.end();
@@ -3328,7 +3448,7 @@ var ResponseFormatter = class {
3328
3448
  }
3329
3449
  }
3330
3450
  };
3331
- var logger9 = agentsCore.getLogger("ToolSessionManager");
3451
+ var logger10 = agentsCore.getLogger("ToolSessionManager");
3332
3452
  var _ToolSessionManager = class _ToolSessionManager {
3333
3453
  // 5 minutes
3334
3454
  constructor() {
@@ -3357,7 +3477,7 @@ var _ToolSessionManager = class _ToolSessionManager {
3357
3477
  createdAt: Date.now()
3358
3478
  };
3359
3479
  this.sessions.set(sessionId, session);
3360
- logger9.debug({ sessionId, tenantId, contextId, taskId }, "Created tool session");
3480
+ logger10.debug({ sessionId, tenantId, contextId, taskId }, "Created tool session");
3361
3481
  return sessionId;
3362
3482
  }
3363
3483
  /**
@@ -3366,7 +3486,7 @@ var _ToolSessionManager = class _ToolSessionManager {
3366
3486
  recordToolResult(sessionId, toolResult) {
3367
3487
  const session = this.sessions.get(sessionId);
3368
3488
  if (!session) {
3369
- logger9.warn(
3489
+ logger10.warn(
3370
3490
  { sessionId, toolCallId: toolResult.toolCallId },
3371
3491
  "Tool result recorded for unknown session"
3372
3492
  );
@@ -3380,12 +3500,12 @@ var _ToolSessionManager = class _ToolSessionManager {
3380
3500
  getToolResult(sessionId, toolCallId) {
3381
3501
  const session = this.sessions.get(sessionId);
3382
3502
  if (!session) {
3383
- logger9.warn({ sessionId, toolCallId }, "Requested tool result for unknown session");
3503
+ logger10.warn({ sessionId, toolCallId }, "Requested tool result for unknown session");
3384
3504
  return void 0;
3385
3505
  }
3386
3506
  const result = session.toolResults.get(toolCallId);
3387
3507
  if (!result) {
3388
- logger9.warn(
3508
+ logger10.warn(
3389
3509
  {
3390
3510
  sessionId,
3391
3511
  toolCallId,
@@ -3424,10 +3544,10 @@ var _ToolSessionManager = class _ToolSessionManager {
3424
3544
  }
3425
3545
  for (const sessionId of expiredSessions) {
3426
3546
  this.sessions.delete(sessionId);
3427
- logger9.debug({ sessionId }, "Cleaned up expired tool session");
3547
+ logger10.debug({ sessionId }, "Cleaned up expired tool session");
3428
3548
  }
3429
3549
  if (expiredSessions.length > 0) {
3430
- logger9.info({ expiredCount: expiredSessions.length }, "Cleaned up expired tool sessions");
3550
+ logger10.info({ expiredCount: expiredSessions.length }, "Cleaned up expired tool sessions");
3431
3551
  }
3432
3552
  }
3433
3553
  };
@@ -3436,7 +3556,7 @@ var ToolSessionManager = _ToolSessionManager;
3436
3556
  var toolSessionManager = ToolSessionManager.getInstance();
3437
3557
 
3438
3558
  // src/agents/artifactTools.ts
3439
- var logger10 = agentsCore.getLogger("artifactTools");
3559
+ var logger11 = agentsCore.getLogger("artifactTools");
3440
3560
  function buildKeyNestingMap(data, prefix = "", map = /* @__PURE__ */ new Map()) {
3441
3561
  if (typeof data === "object" && data !== null) {
3442
3562
  if (Array.isArray(data)) {
@@ -3657,7 +3777,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
3657
3777
  execute: async ({ toolCallId, baseSelector, propSelectors, ...rest }, _context) => {
3658
3778
  const artifactType = "artifactType" in rest ? rest.artifactType : void 0;
3659
3779
  if (!sessionId) {
3660
- logger10.warn({ toolCallId }, "No session ID provided to save_tool_result");
3780
+ logger11.warn({ toolCallId }, "No session ID provided to save_tool_result");
3661
3781
  return {
3662
3782
  saved: false,
3663
3783
  error: `[toolCallId: ${toolCallId}] No session context available`,
@@ -3667,7 +3787,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
3667
3787
  }
3668
3788
  const toolResult = toolSessionManager.getToolResult(sessionId, toolCallId);
3669
3789
  if (!toolResult) {
3670
- logger10.warn({ toolCallId, sessionId }, "Tool result not found in session");
3790
+ logger11.warn({ toolCallId, sessionId }, "Tool result not found in session");
3671
3791
  return {
3672
3792
  saved: false,
3673
3793
  error: `[toolCallId: ${toolCallId}] Tool result not found`,
@@ -3680,7 +3800,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
3680
3800
  const baseData = jmespath__default.default.search(parsedResult, baseSelector);
3681
3801
  if (!baseData || Array.isArray(baseData) && baseData.length === 0) {
3682
3802
  const debugInfo = analyzeSelectorFailure(parsedResult, baseSelector);
3683
- logger10.warn(
3803
+ logger11.warn(
3684
3804
  {
3685
3805
  baseSelector,
3686
3806
  toolCallId,
@@ -3723,7 +3843,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
3723
3843
  const fallbackValue = item[propName];
3724
3844
  if (fallbackValue !== null && fallbackValue !== void 0) {
3725
3845
  extractedItem[propName] = fallbackValue;
3726
- logger10.info(
3846
+ logger11.info(
3727
3847
  { propName, propSelector, context },
3728
3848
  `PropSelector failed, used fallback direct property access`
3729
3849
  );
@@ -3735,7 +3855,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
3735
3855
  const fallbackValue = item[propName];
3736
3856
  if (fallbackValue !== null && fallbackValue !== void 0) {
3737
3857
  extractedItem[propName] = fallbackValue;
3738
- logger10.warn(
3858
+ logger11.warn(
3739
3859
  { propName, propSelector, context, error: error.message },
3740
3860
  `PropSelector syntax error, used fallback direct property access`
3741
3861
  );
@@ -3848,7 +3968,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
3848
3968
  warnings
3849
3969
  };
3850
3970
  } catch (error) {
3851
- logger10.error({ error, toolCallId, sessionId }, "Error processing save_tool_result");
3971
+ logger11.error({ error, toolCallId, sessionId }, "Error processing save_tool_result");
3852
3972
  return {
3853
3973
  saved: false,
3854
3974
  error: `[toolCallId: ${toolCallId}] ${error instanceof Error ? error.message : "Unknown error"}`,
@@ -3860,7 +3980,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
3860
3980
  }
3861
3981
 
3862
3982
  // src/a2a/client.ts
3863
- var logger11 = agentsCore.getLogger("a2aClient");
3983
+ var logger12 = agentsCore.getLogger("a2aClient");
3864
3984
  var DEFAULT_BACKOFF = {
3865
3985
  initialInterval: 500,
3866
3986
  maxInterval: 6e4,
@@ -4066,7 +4186,7 @@ var A2AClient = class {
4066
4186
  try {
4067
4187
  const res = await fn();
4068
4188
  if (attempt > 0) {
4069
- logger11.info(
4189
+ logger12.info(
4070
4190
  {
4071
4191
  attempts: attempt + 1,
4072
4192
  elapsedTime: Date.now() - start
@@ -4081,7 +4201,7 @@ var A2AClient = class {
4081
4201
  }
4082
4202
  const elapsed = Date.now() - start;
4083
4203
  if (elapsed > maxElapsedTime) {
4084
- logger11.warn(
4204
+ logger12.warn(
4085
4205
  {
4086
4206
  attempts: attempt + 1,
4087
4207
  elapsedTime: elapsed,
@@ -4102,7 +4222,7 @@ var A2AClient = class {
4102
4222
  retryInterval = initialInterval * attempt ** exponent + Math.random() * 1e3;
4103
4223
  }
4104
4224
  const delayMs = Math.min(retryInterval, maxInterval);
4105
- logger11.info(
4225
+ logger12.info(
4106
4226
  {
4107
4227
  attempt: attempt + 1,
4108
4228
  delayMs,
@@ -4187,7 +4307,7 @@ var A2AClient = class {
4187
4307
  }
4188
4308
  const rpcResponse = await httpResponse.json();
4189
4309
  if (rpcResponse.id !== requestId2) {
4190
- logger11.warn(
4310
+ logger12.warn(
4191
4311
  {
4192
4312
  method,
4193
4313
  expectedId: requestId2,
@@ -4386,7 +4506,7 @@ var A2AClient = class {
4386
4506
  try {
4387
4507
  while (true) {
4388
4508
  const { done, value } = await reader.read();
4389
- logger11.info({ done, value }, "parseA2ASseStream");
4509
+ logger12.info({ done, value }, "parseA2ASseStream");
4390
4510
  if (done) {
4391
4511
  if (eventDataBuffer.trim()) {
4392
4512
  const result = this._processSseEventData(
@@ -4475,7 +4595,7 @@ var A2AClient = class {
4475
4595
  // src/agents/relationTools.ts
4476
4596
  init_conversations();
4477
4597
  init_dbClient();
4478
- var logger12 = agentsCore.getLogger("relationships Tools");
4598
+ var logger13 = agentsCore.getLogger("relationships Tools");
4479
4599
  var generateTransferToolDescription = (config2) => {
4480
4600
  return `Hand off the conversation to agent ${config2.id}.
4481
4601
 
@@ -4513,7 +4633,7 @@ var createTransferToAgentTool = ({
4513
4633
  "transfer.to_agent_id": transferConfig.id ?? "unknown"
4514
4634
  });
4515
4635
  }
4516
- logger12.info(
4636
+ logger13.info(
4517
4637
  {
4518
4638
  transferTo: transferConfig.id ?? "unknown",
4519
4639
  fromAgent: callingAgentId
@@ -4661,7 +4781,7 @@ function createDelegateToAgentTool({
4661
4781
  ...isInternal ? { fromAgentId: callingAgentId } : { fromExternalAgentId: callingAgentId }
4662
4782
  }
4663
4783
  };
4664
- logger12.info({ messageToSend }, "messageToSend");
4784
+ logger13.info({ messageToSend }, "messageToSend");
4665
4785
  await agentsCore.createMessage(dbClient_default)({
4666
4786
  id: nanoid.nanoid(),
4667
4787
  tenantId,
@@ -4723,7 +4843,7 @@ function createDelegateToAgentTool({
4723
4843
  }
4724
4844
 
4725
4845
  // src/agents/SystemPromptBuilder.ts
4726
- var logger13 = agentsCore.getLogger("SystemPromptBuilder");
4846
+ var logger14 = agentsCore.getLogger("SystemPromptBuilder");
4727
4847
  var SystemPromptBuilder = class {
4728
4848
  constructor(version, versionConfig) {
4729
4849
  this.version = version;
@@ -4739,9 +4859,9 @@ var SystemPromptBuilder = class {
4739
4859
  this.templates.set(name, content);
4740
4860
  }
4741
4861
  this.loaded = true;
4742
- logger13.debug({ templateCount: this.templates.size, version: this.version }, `Loaded ${this.templates.size} templates for version ${this.version}`);
4862
+ logger14.debug({ templateCount: this.templates.size, version: this.version }, `Loaded ${this.templates.size} templates for version ${this.version}`);
4743
4863
  } catch (error) {
4744
- logger13.error({ error }, `Failed to load templates for version ${this.version}`);
4864
+ logger14.error({ error }, `Failed to load templates for version ${this.version}`);
4745
4865
  throw new Error(`Template loading failed: ${error}`);
4746
4866
  }
4747
4867
  }
@@ -5143,7 +5263,7 @@ function hasToolCallWithPrefix(prefix) {
5143
5263
  return false;
5144
5264
  };
5145
5265
  }
5146
- var logger14 = agentsCore.getLogger("Agent");
5266
+ var logger15 = agentsCore.getLogger("Agent");
5147
5267
  var CONSTANTS = {
5148
5268
  MAX_GENERATION_STEPS: 12,
5149
5269
  PHASE_1_TIMEOUT_MS: 27e4,
@@ -5396,14 +5516,14 @@ var Agent = class {
5396
5516
  for (const toolSet of tools) {
5397
5517
  for (const [toolName, originalTool] of Object.entries(toolSet)) {
5398
5518
  if (!isValidTool(originalTool)) {
5399
- logger14.error({ toolName }, "Invalid MCP tool structure - missing required properties");
5519
+ logger15.error({ toolName }, "Invalid MCP tool structure - missing required properties");
5400
5520
  continue;
5401
5521
  }
5402
5522
  const sessionWrappedTool = ai.tool({
5403
5523
  description: originalTool.description,
5404
5524
  inputSchema: originalTool.inputSchema,
5405
5525
  execute: async (args, { toolCallId }) => {
5406
- logger14.debug({ toolName, toolCallId }, "MCP Tool Called");
5526
+ logger15.debug({ toolName, toolCallId }, "MCP Tool Called");
5407
5527
  try {
5408
5528
  const result = await originalTool.execute(args, { toolCallId });
5409
5529
  toolSessionManager.recordToolResult(sessionId, {
@@ -5415,7 +5535,7 @@ var Agent = class {
5415
5535
  });
5416
5536
  return { result, toolCallId };
5417
5537
  } catch (error) {
5418
- logger14.error({ toolName, toolCallId, error }, "MCP tool execution failed");
5538
+ logger15.error({ toolName, toolCallId, error }, "MCP tool execution failed");
5419
5539
  throw error;
5420
5540
  }
5421
5541
  }
@@ -5500,7 +5620,7 @@ var Agent = class {
5500
5620
  selectedTools
5501
5621
  };
5502
5622
  }
5503
- logger14.info(
5623
+ logger15.info(
5504
5624
  {
5505
5625
  toolName: tool4.name,
5506
5626
  credentialReferenceId,
@@ -5540,7 +5660,7 @@ var Agent = class {
5540
5660
  async getResolvedContext(conversationId, requestContext) {
5541
5661
  try {
5542
5662
  if (!this.config.contextConfigId) {
5543
- logger14.debug({ graphId: this.config.graphId }, "No context config found for graph");
5663
+ logger15.debug({ graphId: this.config.graphId }, "No context config found for graph");
5544
5664
  return null;
5545
5665
  }
5546
5666
  const contextConfig = await agentsCore.getContextConfigById(dbClient_default)({
@@ -5548,7 +5668,7 @@ var Agent = class {
5548
5668
  id: this.config.contextConfigId
5549
5669
  });
5550
5670
  if (!contextConfig) {
5551
- logger14.warn({ contextConfigId: this.config.contextConfigId }, "Context config not found");
5671
+ logger15.warn({ contextConfigId: this.config.contextConfigId }, "Context config not found");
5552
5672
  return null;
5553
5673
  }
5554
5674
  if (!this.contextResolver) {
@@ -5565,7 +5685,7 @@ var Agent = class {
5565
5685
  $now: (/* @__PURE__ */ new Date()).toISOString(),
5566
5686
  $env: process.env
5567
5687
  };
5568
- logger14.debug(
5688
+ logger15.debug(
5569
5689
  {
5570
5690
  conversationId,
5571
5691
  contextConfigId: contextConfig.id,
@@ -5579,7 +5699,7 @@ var Agent = class {
5579
5699
  );
5580
5700
  return contextWithBuiltins;
5581
5701
  } catch (error) {
5582
- logger14.error(
5702
+ logger15.error(
5583
5703
  {
5584
5704
  conversationId,
5585
5705
  error: error instanceof Error ? error.message : "Unknown error"
@@ -5603,7 +5723,7 @@ var Agent = class {
5603
5723
  });
5604
5724
  return graphDefinition?.graphPrompt || void 0;
5605
5725
  } catch (error) {
5606
- logger14.warn(
5726
+ logger15.warn(
5607
5727
  {
5608
5728
  graphId: this.config.graphId,
5609
5729
  error: error instanceof Error ? error.message : "Unknown error"
@@ -5630,7 +5750,7 @@ var Agent = class {
5630
5750
  }
5631
5751
  return !!(graphDefinition.artifactComponents && Object.keys(graphDefinition.artifactComponents).length > 0);
5632
5752
  } catch (error) {
5633
- logger14.warn(
5753
+ logger15.warn(
5634
5754
  {
5635
5755
  graphId: this.config.graphId,
5636
5756
  tenantId: this.config.tenantId,
@@ -5690,7 +5810,7 @@ Key requirements:
5690
5810
  preserveUnresolved: false
5691
5811
  });
5692
5812
  } catch (error) {
5693
- logger14.error(
5813
+ logger15.error(
5694
5814
  {
5695
5815
  conversationId,
5696
5816
  error: error instanceof Error ? error.message : "Unknown error"
@@ -5735,7 +5855,7 @@ Key requirements:
5735
5855
  preserveUnresolved: false
5736
5856
  });
5737
5857
  } catch (error) {
5738
- logger14.error(
5858
+ logger15.error(
5739
5859
  {
5740
5860
  conversationId,
5741
5861
  error: error instanceof Error ? error.message : "Unknown error"
@@ -5763,7 +5883,7 @@ Key requirements:
5763
5883
  artifactId: z5.z.string().describe("The unique identifier of the artifact to get.")
5764
5884
  }),
5765
5885
  execute: async ({ artifactId }) => {
5766
- logger14.info({ artifactId }, "get_artifact executed");
5886
+ logger15.info({ artifactId }, "get_artifact executed");
5767
5887
  const artifact = await agentsCore.getLedgerArtifacts(dbClient_default)({
5768
5888
  scopes: {
5769
5889
  tenantId: this.config.tenantId,
@@ -5830,7 +5950,7 @@ Key requirements:
5830
5950
  graphId: this.config.graphId
5831
5951
  });
5832
5952
  } catch (error) {
5833
- logger14.error(
5953
+ logger15.error(
5834
5954
  { error, graphId: this.config.graphId },
5835
5955
  "Failed to check graph artifact components"
5836
5956
  );
@@ -5934,7 +6054,7 @@ Key requirements:
5934
6054
  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;
5935
6055
  const timeoutMs = Math.min(configuredTimeout, MAX_ALLOWED_TIMEOUT_MS);
5936
6056
  if (modelSettings.maxDuration && modelSettings.maxDuration * 1e3 > MAX_ALLOWED_TIMEOUT_MS) {
5937
- logger14.warn(
6057
+ logger15.warn(
5938
6058
  {
5939
6059
  requestedTimeout: modelSettings.maxDuration * 1e3,
5940
6060
  appliedTimeout: timeoutMs,
@@ -5976,7 +6096,7 @@ Key requirements:
5976
6096
  }
5977
6097
  );
5978
6098
  } catch (error) {
5979
- logger14.debug({ error }, "Failed to track agent reasoning");
6099
+ logger15.debug({ error }, "Failed to track agent reasoning");
5980
6100
  }
5981
6101
  }
5982
6102
  if (last && "toolCalls" in last && last.toolCalls) {
@@ -6059,7 +6179,7 @@ Key requirements:
6059
6179
  }
6060
6180
  );
6061
6181
  } catch (error) {
6062
- logger14.debug({ error }, "Failed to track agent reasoning");
6182
+ logger15.debug({ error }, "Failed to track agent reasoning");
6063
6183
  }
6064
6184
  }
6065
6185
  if (last && "toolCalls" in last && last.toolCalls) {
@@ -6104,7 +6224,7 @@ Key requirements:
6104
6224
  return;
6105
6225
  }
6106
6226
  if (toolName === "save_artifact_tool" || toolName === "save_tool_result") {
6107
- logger14.info({ result }, "save_artifact_tool or save_tool_result");
6227
+ logger15.info({ result }, "save_artifact_tool or save_tool_result");
6108
6228
  if (result.output.artifacts) {
6109
6229
  for (const artifact of result.output.artifacts) {
6110
6230
  const artifactId = artifact?.artifactId || "N/A";
@@ -6292,7 +6412,7 @@ function parseEmbeddedJson(data) {
6292
6412
  }
6293
6413
  });
6294
6414
  }
6295
- var logger15 = agentsCore.getLogger("generateTaskHandler");
6415
+ var logger16 = agentsCore.getLogger("generateTaskHandler");
6296
6416
  var createTaskHandler = (config2, credentialStoreRegistry) => {
6297
6417
  return async (task) => {
6298
6418
  try {
@@ -6342,7 +6462,33 @@ var createTaskHandler = (config2, credentialStoreRegistry) => {
6342
6462
  agentId: config2.agentId
6343
6463
  })
6344
6464
  ]);
6345
- logger15.info({ toolsForAgent, internalRelations, externalRelations }, "agent stuff");
6465
+ logger16.info({ toolsForAgent, internalRelations, externalRelations }, "agent stuff");
6466
+ const enhancedInternalRelations = await Promise.all(
6467
+ internalRelations.map(async (relation) => {
6468
+ try {
6469
+ const relatedAgent = await agentsCore.getAgentById(dbClient_default)({
6470
+ scopes: { tenantId: config2.tenantId, projectId: config2.projectId },
6471
+ agentId: relation.id
6472
+ });
6473
+ if (relatedAgent) {
6474
+ const relatedAgentRelations = await agentsCore.getRelatedAgentsForGraph(dbClient_default)({
6475
+ scopes: { tenantId: config2.tenantId, projectId: config2.projectId },
6476
+ graphId: config2.graphId,
6477
+ agentId: relation.id
6478
+ });
6479
+ const enhancedDescription = generateDescriptionWithTransfers(
6480
+ relation.description || "",
6481
+ relatedAgentRelations.internalRelations,
6482
+ relatedAgentRelations.externalRelations
6483
+ );
6484
+ return { ...relation, description: enhancedDescription };
6485
+ }
6486
+ } catch (error) {
6487
+ logger16.warn({ agentId: relation.id, error }, "Failed to enhance agent description");
6488
+ }
6489
+ return relation;
6490
+ })
6491
+ );
6346
6492
  const agentPrompt = "prompt" in config2.agentSchema ? config2.agentSchema.prompt : "";
6347
6493
  const models = "models" in config2.agentSchema ? config2.agentSchema.models : void 0;
6348
6494
  const stopWhen = "stopWhen" in config2.agentSchema ? config2.agentSchema.stopWhen : void 0;
@@ -6359,7 +6505,7 @@ var createTaskHandler = (config2, credentialStoreRegistry) => {
6359
6505
  agentPrompt,
6360
6506
  models: models || void 0,
6361
6507
  stopWhen: stopWhen || void 0,
6362
- agentRelations: internalRelations.map((relation) => ({
6508
+ agentRelations: enhancedInternalRelations.map((relation) => ({
6363
6509
  id: relation.id,
6364
6510
  tenantId: config2.tenantId,
6365
6511
  projectId: config2.projectId,
@@ -6373,7 +6519,7 @@ var createTaskHandler = (config2, credentialStoreRegistry) => {
6373
6519
  agentRelations: [],
6374
6520
  transferRelations: []
6375
6521
  })),
6376
- transferRelations: internalRelations.filter((relation) => relation.relationType === "transfer").map((relation) => ({
6522
+ transferRelations: enhancedInternalRelations.filter((relation) => relation.relationType === "transfer").map((relation) => ({
6377
6523
  baseUrl: config2.baseUrl,
6378
6524
  apiKey: config2.apiKey,
6379
6525
  id: relation.id,
@@ -6389,7 +6535,7 @@ var createTaskHandler = (config2, credentialStoreRegistry) => {
6389
6535
  })),
6390
6536
  delegateRelations: [
6391
6537
  // Internal delegate relations
6392
- ...internalRelations.filter((relation) => relation.relationType === "delegate").map((relation) => ({
6538
+ ...enhancedInternalRelations.filter((relation) => relation.relationType === "delegate").map((relation) => ({
6393
6539
  type: "internal",
6394
6540
  config: {
6395
6541
  id: relation.id,
@@ -6442,7 +6588,7 @@ var createTaskHandler = (config2, credentialStoreRegistry) => {
6442
6588
  const taskIdMatch = task.id.match(/^task_([^-]+-[^-]+-\d+)-/);
6443
6589
  if (taskIdMatch) {
6444
6590
  contextId = taskIdMatch[1];
6445
- logger15.info(
6591
+ logger16.info(
6446
6592
  {
6447
6593
  taskId: task.id,
6448
6594
  extractedContextId: contextId,
@@ -6458,7 +6604,7 @@ var createTaskHandler = (config2, credentialStoreRegistry) => {
6458
6604
  const isDelegation = task.context?.metadata?.isDelegation === true;
6459
6605
  agent.setDelegationStatus(isDelegation);
6460
6606
  if (isDelegation) {
6461
- logger15.info(
6607
+ logger16.info(
6462
6608
  { agentId: config2.agentId, taskId: task.id },
6463
6609
  "Delegated agent - streaming disabled"
6464
6610
  );
@@ -6664,86 +6810,11 @@ async function getRegisteredGraph(executionContext) {
6664
6810
  const agentFrameworkBaseUrl = `${baseUrl}/agents`;
6665
6811
  return hydrateGraph({ dbGraph, baseUrl: agentFrameworkBaseUrl, apiKey });
6666
6812
  }
6667
- init_dbClient();
6668
- agentsCore.getLogger("agents");
6669
- async function hydrateAgent({
6670
- dbAgent,
6671
- graphId,
6672
- baseUrl,
6673
- apiKey,
6674
- credentialStoreRegistry
6675
- }) {
6676
- try {
6677
- const taskHandlerConfig = await createTaskHandlerConfig({
6678
- tenantId: dbAgent.tenantId,
6679
- projectId: dbAgent.projectId,
6680
- graphId,
6681
- agentId: dbAgent.id,
6682
- baseUrl,
6683
- apiKey
6684
- });
6685
- const taskHandler = createTaskHandler(taskHandlerConfig, credentialStoreRegistry);
6686
- const agentCard = {
6687
- name: dbAgent.name,
6688
- description: dbAgent.description || "AI Agent",
6689
- url: baseUrl ? `${baseUrl}/a2a` : "",
6690
- version: "1.0.0",
6691
- capabilities: {
6692
- streaming: true,
6693
- // Enable streaming for A2A compliance
6694
- pushNotifications: false,
6695
- stateTransitionHistory: false
6696
- },
6697
- defaultInputModes: ["text", "text/plain"],
6698
- defaultOutputModes: ["text", "text/plain"],
6699
- skills: [],
6700
- // Add provider info if available
6701
- ...baseUrl && {
6702
- provider: {
6703
- organization: "Inkeep",
6704
- url: baseUrl
6705
- }
6706
- }
6707
- };
6708
- return {
6709
- agentId: dbAgent.id,
6710
- tenantId: dbAgent.tenantId,
6711
- projectId: dbAgent.projectId,
6712
- graphId,
6713
- agentCard,
6714
- taskHandler
6715
- };
6716
- } catch (error) {
6717
- console.error(`\u274C Failed to hydrate agent ${dbAgent.id}:`, error);
6718
- throw error;
6719
- }
6720
- }
6721
- async function getRegisteredAgent(executionContext, credentialStoreRegistry) {
6722
- const { tenantId, projectId, graphId, agentId, baseUrl, apiKey } = executionContext;
6723
- if (!agentId) {
6724
- throw new Error("Agent ID is required");
6725
- }
6726
- const dbAgent = await agentsCore.getAgentById(dbClient_default)({
6727
- scopes: { tenantId, projectId },
6728
- agentId
6729
- });
6730
- if (!dbAgent) {
6731
- return null;
6732
- }
6733
- const agentFrameworkBaseUrl = `${baseUrl}/agents`;
6734
- return hydrateAgent({
6735
- dbAgent,
6736
- graphId,
6737
- baseUrl: agentFrameworkBaseUrl,
6738
- credentialStoreRegistry,
6739
- apiKey
6740
- });
6741
- }
6742
6813
 
6743
6814
  // src/routes/agents.ts
6744
6815
  init_dbClient();
6745
6816
  var app = new zodOpenapi.OpenAPIHono();
6746
- var logger16 = agentsCore.getLogger("agents");
6817
+ var logger17 = agentsCore.getLogger("agents");
6747
6818
  app.openapi(
6748
6819
  zodOpenapi.createRoute({
6749
6820
  method: "get",
@@ -6781,7 +6852,7 @@ app.openapi(
6781
6852
  tracestate: c.req.header("tracestate"),
6782
6853
  baggage: c.req.header("baggage")
6783
6854
  };
6784
- logger16.info(
6855
+ logger17.info(
6785
6856
  {
6786
6857
  otelHeaders,
6787
6858
  path: c.req.path,
@@ -6792,7 +6863,7 @@ app.openapi(
6792
6863
  const executionContext = agentsCore.getRequestExecutionContext(c);
6793
6864
  const { tenantId, projectId, graphId, agentId } = executionContext;
6794
6865
  if (agentId) {
6795
- logger16.info(
6866
+ logger17.info(
6796
6867
  {
6797
6868
  message: "getRegisteredAgent (agent-level)",
6798
6869
  tenantId,
@@ -6804,13 +6875,13 @@ app.openapi(
6804
6875
  );
6805
6876
  const credentialStores = c.get("credentialStores");
6806
6877
  const agent = await getRegisteredAgent(executionContext, credentialStores);
6807
- logger16.info({ agent }, "agent registered: well-known agent.json");
6878
+ logger17.info({ agent }, "agent registered: well-known agent.json");
6808
6879
  if (!agent) {
6809
6880
  return c.json({ error: "Agent not found" }, 404);
6810
6881
  }
6811
6882
  return c.json(agent.agentCard);
6812
6883
  } else {
6813
- logger16.info(
6884
+ logger17.info(
6814
6885
  {
6815
6886
  message: "getRegisteredGraph (graph-level)",
6816
6887
  tenantId,
@@ -6833,7 +6904,7 @@ app.post("/a2a", async (c) => {
6833
6904
  tracestate: c.req.header("tracestate"),
6834
6905
  baggage: c.req.header("baggage")
6835
6906
  };
6836
- logger16.info(
6907
+ logger17.info(
6837
6908
  {
6838
6909
  otelHeaders,
6839
6910
  path: c.req.path,
@@ -6844,7 +6915,7 @@ app.post("/a2a", async (c) => {
6844
6915
  const executionContext = agentsCore.getRequestExecutionContext(c);
6845
6916
  const { tenantId, projectId, graphId, agentId } = executionContext;
6846
6917
  if (agentId) {
6847
- logger16.info(
6918
+ logger17.info(
6848
6919
  {
6849
6920
  message: "a2a (agent-level)",
6850
6921
  tenantId,
@@ -6868,7 +6939,7 @@ app.post("/a2a", async (c) => {
6868
6939
  }
6869
6940
  return a2aHandler(c, agent);
6870
6941
  } else {
6871
- logger16.info(
6942
+ logger17.info(
6872
6943
  {
6873
6944
  message: "a2a (graph-level)",
6874
6945
  tenantId,
@@ -6914,14 +6985,14 @@ init_dbClient();
6914
6985
 
6915
6986
  // src/a2a/transfer.ts
6916
6987
  init_dbClient();
6917
- var logger17 = agentsCore.getLogger("Transfer");
6988
+ var logger18 = agentsCore.getLogger("Transfer");
6918
6989
  async function executeTransfer({
6919
6990
  tenantId,
6920
6991
  threadId,
6921
6992
  projectId,
6922
6993
  targetAgentId
6923
6994
  }) {
6924
- logger17.info({ targetAgent: targetAgentId }, "Executing transfer to agent");
6995
+ logger18.info({ targetAgent: targetAgentId }, "Executing transfer to agent");
6925
6996
  await agentsCore.setActiveAgentForThread(dbClient_default)({
6926
6997
  scopes: { tenantId, projectId },
6927
6998
  threadId,
@@ -7116,7 +7187,7 @@ var _VercelDataStreamHelper = class _VercelDataStreamHelper {
7116
7187
  __publicField(this, "queuedOperations", []);
7117
7188
  // Timing tracking for text sequences (text-end to text-start gap)
7118
7189
  __publicField(this, "lastTextEndTimestamp", 0);
7119
- __publicField(this, "TEXT_GAP_THRESHOLD", 1e3);
7190
+ __publicField(this, "TEXT_GAP_THRESHOLD", 50);
7120
7191
  // milliseconds - if gap between text sequences is less than this, queue operations
7121
7192
  // Connection management and forced cleanup
7122
7193
  __publicField(this, "connectionDropTimer");
@@ -7465,7 +7536,7 @@ function createMCPStreamHelper() {
7465
7536
 
7466
7537
  // src/handlers/executionHandler.ts
7467
7538
  init_dbClient();
7468
- var logger18 = agentsCore.getLogger("ExecutionHandler");
7539
+ var logger19 = agentsCore.getLogger("ExecutionHandler");
7469
7540
  var ExecutionHandler = class {
7470
7541
  constructor() {
7471
7542
  // Hardcoded error limit - separate from configurable stopWhen
@@ -7490,7 +7561,7 @@ var ExecutionHandler = class {
7490
7561
  const { tenantId, projectId, graphId, apiKey, baseUrl } = executionContext;
7491
7562
  registerStreamHelper(requestId2, sseHelper);
7492
7563
  graphSessionManager.createSession(requestId2, graphId, tenantId, projectId);
7493
- logger18.info({ sessionId: requestId2, graphId }, "Created GraphSession for message execution");
7564
+ logger19.info({ sessionId: requestId2, graphId }, "Created GraphSession for message execution");
7494
7565
  let graphConfig = null;
7495
7566
  try {
7496
7567
  graphConfig = await agentsCore.getFullGraph(dbClient_default)({ scopes: { tenantId, projectId }, graphId });
@@ -7502,7 +7573,7 @@ var ExecutionHandler = class {
7502
7573
  );
7503
7574
  }
7504
7575
  } catch (error) {
7505
- logger18.error(
7576
+ logger19.error(
7506
7577
  {
7507
7578
  error: error instanceof Error ? error.message : "Unknown error",
7508
7579
  stack: error instanceof Error ? error.stack : void 0
@@ -7518,7 +7589,7 @@ var ExecutionHandler = class {
7518
7589
  try {
7519
7590
  await sseHelper.writeOperation(agentInitializingOp(requestId2, graphId));
7520
7591
  const taskId = `task_${conversationId}-${requestId2}`;
7521
- logger18.info(
7592
+ logger19.info(
7522
7593
  { taskId, currentAgentId, conversationId, requestId: requestId2 },
7523
7594
  "Attempting to create or reuse existing task"
7524
7595
  );
@@ -7541,7 +7612,7 @@ var ExecutionHandler = class {
7541
7612
  agent_id: currentAgentId
7542
7613
  }
7543
7614
  });
7544
- logger18.info(
7615
+ logger19.info(
7545
7616
  {
7546
7617
  taskId,
7547
7618
  createdTaskMetadata: Array.isArray(task) ? task[0]?.metadata : task?.metadata
@@ -7550,27 +7621,27 @@ var ExecutionHandler = class {
7550
7621
  );
7551
7622
  } catch (error) {
7552
7623
  if (error?.message?.includes("UNIQUE constraint failed") || error?.message?.includes("PRIMARY KEY constraint failed") || error?.code === "SQLITE_CONSTRAINT_PRIMARYKEY") {
7553
- logger18.info(
7624
+ logger19.info(
7554
7625
  { taskId, error: error.message },
7555
7626
  "Task already exists, fetching existing task"
7556
7627
  );
7557
7628
  const existingTask = await agentsCore.getTask(dbClient_default)({ id: taskId });
7558
7629
  if (existingTask) {
7559
7630
  task = existingTask;
7560
- logger18.info(
7631
+ logger19.info(
7561
7632
  { taskId, existingTask },
7562
7633
  "Successfully reused existing task from race condition"
7563
7634
  );
7564
7635
  } else {
7565
- logger18.error({ taskId, error }, "Task constraint failed but task not found");
7636
+ logger19.error({ taskId, error }, "Task constraint failed but task not found");
7566
7637
  throw error;
7567
7638
  }
7568
7639
  } else {
7569
- logger18.error({ taskId, error }, "Failed to create task due to non-constraint error");
7640
+ logger19.error({ taskId, error }, "Failed to create task due to non-constraint error");
7570
7641
  throw error;
7571
7642
  }
7572
7643
  }
7573
- logger18.debug(
7644
+ logger19.debug(
7574
7645
  {
7575
7646
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
7576
7647
  executionType: "create_initial_task",
@@ -7588,7 +7659,7 @@ var ExecutionHandler = class {
7588
7659
  const maxTransfers = graphConfig?.stopWhen?.transferCountIs ?? 10;
7589
7660
  while (iterations < maxTransfers) {
7590
7661
  iterations++;
7591
- logger18.info(
7662
+ logger19.info(
7592
7663
  { iterations, currentAgentId, graphId, conversationId, fromAgentId },
7593
7664
  `Execution loop iteration ${iterations} with agent ${currentAgentId}, transfer from: ${fromAgentId || "none"}`
7594
7665
  );
@@ -7596,10 +7667,10 @@ var ExecutionHandler = class {
7596
7667
  scopes: { tenantId, projectId },
7597
7668
  conversationId
7598
7669
  });
7599
- logger18.info({ activeAgent }, "activeAgent");
7670
+ logger19.info({ activeAgent }, "activeAgent");
7600
7671
  if (activeAgent && activeAgent.activeAgentId !== currentAgentId) {
7601
7672
  currentAgentId = activeAgent.activeAgentId;
7602
- logger18.info({ currentAgentId }, `Updated current agent to: ${currentAgentId}`);
7673
+ logger19.info({ currentAgentId }, `Updated current agent to: ${currentAgentId}`);
7603
7674
  }
7604
7675
  const agentBaseUrl = `${baseUrl}/agents`;
7605
7676
  const a2aClient = new A2AClient(agentBaseUrl, {
@@ -7640,13 +7711,13 @@ var ExecutionHandler = class {
7640
7711
  });
7641
7712
  if (!messageResponse?.result) {
7642
7713
  errorCount++;
7643
- logger18.error(
7714
+ logger19.error(
7644
7715
  { currentAgentId, iterations, errorCount },
7645
7716
  `No response from agent ${currentAgentId} on iteration ${iterations} (error ${errorCount}/${this.MAX_ERRORS})`
7646
7717
  );
7647
7718
  if (errorCount >= this.MAX_ERRORS) {
7648
7719
  const errorMessage2 = `Maximum error limit (${this.MAX_ERRORS}) reached`;
7649
- logger18.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
7720
+ logger19.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
7650
7721
  await sseHelper.writeError(errorMessage2);
7651
7722
  await sseHelper.writeOperation(errorOp(errorMessage2, currentAgentId || "system"));
7652
7723
  if (task) {
@@ -7672,7 +7743,7 @@ var ExecutionHandler = class {
7672
7743
  const transferResponse = messageResponse.result;
7673
7744
  const targetAgentId = transferResponse.artifacts?.[0]?.parts?.[0]?.data?.targetAgentId;
7674
7745
  const transferReason = transferResponse.artifacts?.[0]?.parts?.[1]?.text;
7675
- logger18.info({ targetAgentId, transferReason }, "transfer response");
7746
+ logger19.info({ targetAgentId, transferReason }, "transfer response");
7676
7747
  currentMessage = `<transfer_context> ${transferReason} </transfer_context>`;
7677
7748
  const { success, targetAgentId: newAgentId } = await executeTransfer({
7678
7749
  projectId,
@@ -7683,7 +7754,7 @@ var ExecutionHandler = class {
7683
7754
  if (success) {
7684
7755
  fromAgentId = currentAgentId;
7685
7756
  currentAgentId = newAgentId;
7686
- logger18.info(
7757
+ logger19.info(
7687
7758
  {
7688
7759
  transferFrom: fromAgentId,
7689
7760
  transferTo: currentAgentId,
@@ -7701,7 +7772,7 @@ var ExecutionHandler = class {
7701
7772
  const graphSessionData = graphSessionManager.getSession(requestId2);
7702
7773
  if (graphSessionData) {
7703
7774
  const sessionSummary = graphSessionData.getSummary();
7704
- logger18.info(sessionSummary, "GraphSession data after completion");
7775
+ logger19.info(sessionSummary, "GraphSession data after completion");
7705
7776
  }
7706
7777
  let textContent = "";
7707
7778
  for (const part of responseParts) {
@@ -7710,78 +7781,84 @@ var ExecutionHandler = class {
7710
7781
  textContent += part.text;
7711
7782
  }
7712
7783
  }
7713
- const activeSpan = api.trace.getActiveSpan();
7714
- if (activeSpan) {
7715
- activeSpan.setAttributes({
7716
- "ai.response.content": textContent || "No response content",
7717
- "ai.response.timestamp": (/* @__PURE__ */ new Date()).toISOString(),
7718
- "ai.agent.name": currentAgentId
7719
- });
7720
- }
7721
- await agentsCore.createMessage(dbClient_default)({
7722
- id: nanoid.nanoid(),
7723
- tenantId,
7724
- projectId,
7725
- conversationId,
7726
- role: "agent",
7727
- content: {
7728
- text: textContent || void 0,
7729
- parts: responseParts.map((part) => ({
7730
- type: part.kind === "text" ? "text" : "data",
7731
- text: part.kind === "text" ? part.text : void 0,
7732
- data: part.kind === "data" ? JSON.stringify(part.data) : void 0
7733
- }))
7734
- },
7735
- visibility: "user-facing",
7736
- messageType: "chat",
7737
- agentId: currentAgentId,
7738
- fromAgentId: currentAgentId,
7739
- taskId: task.id
7740
- });
7741
- const updateTaskStart = Date.now();
7742
- await agentsCore.updateTask(dbClient_default)({
7743
- taskId: task.id,
7744
- data: {
7745
- status: "completed",
7746
- metadata: {
7747
- ...task.metadata,
7748
- completed_at: (/* @__PURE__ */ new Date()).toISOString(),
7749
- response: {
7750
- text: textContent,
7751
- parts: responseParts,
7752
- hasText: !!textContent,
7753
- hasData: responseParts.some((p) => p.kind === "data")
7784
+ return tracer.startActiveSpan("execution_handler.execute", {}, async (span) => {
7785
+ try {
7786
+ span.setAttributes({
7787
+ "ai.response.content": textContent || "No response content",
7788
+ "ai.response.timestamp": (/* @__PURE__ */ new Date()).toISOString(),
7789
+ "ai.agent.name": currentAgentId
7790
+ });
7791
+ await agentsCore.createMessage(dbClient_default)({
7792
+ id: nanoid.nanoid(),
7793
+ tenantId,
7794
+ projectId,
7795
+ conversationId,
7796
+ role: "agent",
7797
+ content: {
7798
+ text: textContent || void 0,
7799
+ parts: responseParts.map((part) => ({
7800
+ type: part.kind === "text" ? "text" : "data",
7801
+ text: part.kind === "text" ? part.text : void 0,
7802
+ data: part.kind === "data" ? JSON.stringify(part.data) : void 0
7803
+ }))
7804
+ },
7805
+ visibility: "user-facing",
7806
+ messageType: "chat",
7807
+ agentId: currentAgentId,
7808
+ fromAgentId: currentAgentId,
7809
+ taskId: task.id
7810
+ });
7811
+ const updateTaskStart = Date.now();
7812
+ await agentsCore.updateTask(dbClient_default)({
7813
+ taskId: task.id,
7814
+ data: {
7815
+ status: "completed",
7816
+ metadata: {
7817
+ ...task.metadata,
7818
+ completed_at: (/* @__PURE__ */ new Date()).toISOString(),
7819
+ response: {
7820
+ text: textContent,
7821
+ parts: responseParts,
7822
+ hasText: !!textContent,
7823
+ hasData: responseParts.some((p) => p.kind === "data")
7824
+ }
7825
+ }
7754
7826
  }
7827
+ });
7828
+ const updateTaskEnd = Date.now();
7829
+ logger19.info(
7830
+ { duration: updateTaskEnd - updateTaskStart },
7831
+ "Completed updateTask operation"
7832
+ );
7833
+ await sseHelper.writeOperation(completionOp(currentAgentId, iterations));
7834
+ await sseHelper.complete();
7835
+ logger19.info({}, "Ending GraphSession and cleaning up");
7836
+ graphSessionManager.endSession(requestId2);
7837
+ logger19.info({}, "Cleaning up streamHelper");
7838
+ unregisterStreamHelper(requestId2);
7839
+ let response;
7840
+ if (sseHelper instanceof MCPStreamHelper) {
7841
+ const captured = sseHelper.getCapturedResponse();
7842
+ response = captured.text || "No response content";
7755
7843
  }
7844
+ logger19.info({}, "ExecutionHandler returning success");
7845
+ return { success: true, iterations, response };
7846
+ } catch (error) {
7847
+ agentsCore.setSpanWithError(span, error);
7848
+ throw error;
7849
+ } finally {
7850
+ span.end();
7756
7851
  }
7757
7852
  });
7758
- const updateTaskEnd = Date.now();
7759
- logger18.info(
7760
- { duration: updateTaskEnd - updateTaskStart },
7761
- "Completed updateTask operation"
7762
- );
7763
- await sseHelper.writeOperation(completionOp(currentAgentId, iterations));
7764
- await sseHelper.complete();
7765
- logger18.info({}, "Ending GraphSession and cleaning up");
7766
- graphSessionManager.endSession(requestId2);
7767
- logger18.info({}, "Cleaning up streamHelper");
7768
- unregisterStreamHelper(requestId2);
7769
- let response;
7770
- if (sseHelper instanceof MCPStreamHelper) {
7771
- const captured = sseHelper.getCapturedResponse();
7772
- response = captured.text || "No response content";
7773
- }
7774
- logger18.info({}, "ExecutionHandler returning success");
7775
- return { success: true, iterations, response };
7776
7853
  }
7777
7854
  errorCount++;
7778
- logger18.warn(
7855
+ logger19.warn(
7779
7856
  { iterations, errorCount },
7780
7857
  `No valid response or transfer on iteration ${iterations} (error ${errorCount}/${this.MAX_ERRORS})`
7781
7858
  );
7782
7859
  if (errorCount >= this.MAX_ERRORS) {
7783
7860
  const errorMessage2 = `Maximum error limit (${this.MAX_ERRORS}) reached`;
7784
- logger18.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
7861
+ logger19.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
7785
7862
  await sseHelper.writeError(errorMessage2);
7786
7863
  await sseHelper.writeOperation(errorOp(errorMessage2, currentAgentId || "system"));
7787
7864
  if (task) {
@@ -7803,7 +7880,7 @@ var ExecutionHandler = class {
7803
7880
  }
7804
7881
  }
7805
7882
  const errorMessage = `Maximum transfer limit (${maxTransfers}) reached without completion`;
7806
- logger18.error({ maxTransfers, iterations }, errorMessage);
7883
+ logger19.error({ maxTransfers, iterations }, errorMessage);
7807
7884
  await sseHelper.writeError(errorMessage);
7808
7885
  await sseHelper.writeOperation(errorOp(errorMessage, currentAgentId || "system"));
7809
7886
  if (task) {
@@ -7823,7 +7900,7 @@ var ExecutionHandler = class {
7823
7900
  unregisterStreamHelper(requestId2);
7824
7901
  return { success: false, error: errorMessage, iterations };
7825
7902
  } catch (error) {
7826
- logger18.error({ error }, "Error in execution handler");
7903
+ logger19.error({ error }, "Error in execution handler");
7827
7904
  const errorMessage = error instanceof Error ? error.message : "Unknown execution error";
7828
7905
  await sseHelper.writeError(`Execution error: ${errorMessage}`);
7829
7906
  await sseHelper.writeOperation(errorOp(errorMessage, currentAgentId || "system"));
@@ -7849,7 +7926,7 @@ var ExecutionHandler = class {
7849
7926
 
7850
7927
  // src/routes/chat.ts
7851
7928
  var app2 = new zodOpenapi.OpenAPIHono();
7852
- var logger19 = agentsCore.getLogger("completionsHandler");
7929
+ var logger20 = agentsCore.getLogger("completionsHandler");
7853
7930
  var chatCompletionsRoute = zodOpenapi.createRoute({
7854
7931
  method: "post",
7855
7932
  path: "/completions",
@@ -7967,7 +8044,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
7967
8044
  tracestate: c.req.header("tracestate"),
7968
8045
  baggage: c.req.header("baggage")
7969
8046
  };
7970
- logger19.info(
8047
+ logger20.info(
7971
8048
  {
7972
8049
  otelHeaders,
7973
8050
  path: c.req.path,
@@ -8053,7 +8130,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
8053
8130
  dbClient_default,
8054
8131
  credentialStores
8055
8132
  );
8056
- logger19.info(
8133
+ logger20.info(
8057
8134
  {
8058
8135
  tenantId,
8059
8136
  graphId,
@@ -8099,7 +8176,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
8099
8176
  return streaming.streamSSE(c, async (stream2) => {
8100
8177
  const sseHelper = createSSEStreamHelper(stream2, requestId2, timestamp);
8101
8178
  await sseHelper.writeRole();
8102
- logger19.info({ agentId }, "Starting execution");
8179
+ logger20.info({ agentId }, "Starting execution");
8103
8180
  const executionHandler = new ExecutionHandler();
8104
8181
  const result = await executionHandler.execute({
8105
8182
  executionContext,
@@ -8109,7 +8186,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
8109
8186
  requestId: requestId2,
8110
8187
  sseHelper
8111
8188
  });
8112
- logger19.info(
8189
+ logger20.info(
8113
8190
  { result },
8114
8191
  `Execution completed: ${result.success ? "success" : "failed"} after ${result.iterations} iterations`
8115
8192
  );
@@ -8145,7 +8222,7 @@ var chat_default = app2;
8145
8222
  // src/routes/chatDataStream.ts
8146
8223
  init_dbClient();
8147
8224
  var app3 = new zodOpenapi.OpenAPIHono();
8148
- var logger20 = agentsCore.getLogger("chatDataStream");
8225
+ var logger21 = agentsCore.getLogger("chatDataStream");
8149
8226
  var chatDataStreamRoute = zodOpenapi.createRoute({
8150
8227
  method: "post",
8151
8228
  path: "/chat",
@@ -8250,7 +8327,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
8250
8327
  );
8251
8328
  const lastUserMessage = body.messages.filter((m) => m.role === "user").slice(-1)[0];
8252
8329
  const userText = typeof lastUserMessage?.content === "string" ? lastUserMessage.content : lastUserMessage?.parts?.map((p) => p.text).join("") || "";
8253
- logger20.info({ userText, lastUserMessage }, "userText");
8330
+ logger21.info({ userText, lastUserMessage }, "userText");
8254
8331
  const messageSpan = api.trace.getActiveSpan();
8255
8332
  if (messageSpan) {
8256
8333
  messageSpan.setAttributes({
@@ -8292,7 +8369,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
8292
8369
  await streamHelper.writeError("Unable to process request");
8293
8370
  }
8294
8371
  } catch (err) {
8295
- logger20.error({ err }, "Streaming error");
8372
+ logger21.error({ err }, "Streaming error");
8296
8373
  await streamHelper.writeError("Internal server error");
8297
8374
  } finally {
8298
8375
  if ("cleanup" in streamHelper && typeof streamHelper.cleanup === "function") {
@@ -8313,7 +8390,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
8313
8390
  )
8314
8391
  );
8315
8392
  } catch (error) {
8316
- logger20.error({ error }, "chatDataStream error");
8393
+ logger21.error({ error }, "chatDataStream error");
8317
8394
  return c.json({ error: "Failed to process chat completion" }, 500);
8318
8395
  }
8319
8396
  });
@@ -8324,7 +8401,7 @@ init_dbClient();
8324
8401
  function createMCPSchema(schema) {
8325
8402
  return schema;
8326
8403
  }
8327
- var logger21 = agentsCore.getLogger("mcp");
8404
+ var logger22 = agentsCore.getLogger("mcp");
8328
8405
  var _MockResponseSingleton = class _MockResponseSingleton {
8329
8406
  constructor() {
8330
8407
  __publicField(this, "mockRes");
@@ -8379,21 +8456,21 @@ var createSpoofInitMessage = (mcpProtocolVersion) => ({
8379
8456
  id: 0
8380
8457
  });
8381
8458
  var spoofTransportInitialization = async (transport, req, sessionId, mcpProtocolVersion) => {
8382
- logger21.info({ sessionId }, "Spoofing initialization message to set transport state");
8459
+ logger22.info({ sessionId }, "Spoofing initialization message to set transport state");
8383
8460
  const spoofInitMessage = createSpoofInitMessage(mcpProtocolVersion);
8384
8461
  const mockRes = MockResponseSingleton.getInstance().getMockResponse();
8385
8462
  try {
8386
8463
  await transport.handleRequest(req, mockRes, spoofInitMessage);
8387
- logger21.info({ sessionId }, "Successfully spoofed initialization");
8464
+ logger22.info({ sessionId }, "Successfully spoofed initialization");
8388
8465
  } catch (spoofError) {
8389
- logger21.warn({ sessionId, error: spoofError }, "Spoof initialization failed, continuing anyway");
8466
+ logger22.warn({ sessionId, error: spoofError }, "Spoof initialization failed, continuing anyway");
8390
8467
  }
8391
8468
  };
8392
8469
  var validateSession = async (req, res, body, tenantId, projectId, graphId) => {
8393
8470
  const sessionId = req.headers["mcp-session-id"];
8394
- logger21.info({ sessionId }, "Received MCP session ID");
8471
+ logger22.info({ sessionId }, "Received MCP session ID");
8395
8472
  if (!sessionId) {
8396
- logger21.info({ body }, "Missing session ID");
8473
+ logger22.info({ body }, "Missing session ID");
8397
8474
  res.writeHead(400).end(
8398
8475
  JSON.stringify({
8399
8476
  jsonrpc: "2.0",
@@ -8419,7 +8496,7 @@ var validateSession = async (req, res, body, tenantId, projectId, graphId) => {
8419
8496
  scopes: { tenantId, projectId },
8420
8497
  conversationId: sessionId
8421
8498
  });
8422
- logger21.info(
8499
+ logger22.info(
8423
8500
  {
8424
8501
  sessionId,
8425
8502
  conversationFound: !!conversation,
@@ -8430,7 +8507,7 @@ var validateSession = async (req, res, body, tenantId, projectId, graphId) => {
8430
8507
  "Conversation lookup result"
8431
8508
  );
8432
8509
  if (!conversation || conversation.metadata?.sessionData?.sessionType !== "mcp" || conversation.metadata?.sessionData?.graphId !== graphId) {
8433
- logger21.info(
8510
+ logger22.info(
8434
8511
  { sessionId, conversationId: conversation?.id },
8435
8512
  "MCP session not found or invalid"
8436
8513
  );
@@ -8491,7 +8568,7 @@ var executeAgentQuery = async (executionContext, conversationId, query, defaultA
8491
8568
  requestId: requestId2,
8492
8569
  sseHelper: mcpStreamHelper
8493
8570
  });
8494
- logger21.info(
8571
+ logger22.info(
8495
8572
  { result },
8496
8573
  `Execution completed: ${result.success ? "success" : "failed"} after ${result.iterations} iterations`
8497
8574
  );
@@ -8565,7 +8642,7 @@ var getServer = async (requestContext, executionContext, conversationId, credent
8565
8642
  dbClient_default,
8566
8643
  credentialStores
8567
8644
  );
8568
- logger21.info(
8645
+ logger22.info(
8569
8646
  {
8570
8647
  tenantId,
8571
8648
  graphId,
@@ -8626,7 +8703,7 @@ var validateRequestParameters = (c) => {
8626
8703
  };
8627
8704
  var handleInitializationRequest = async (body, executionContext, validatedContext, req, res, c, credentialStores) => {
8628
8705
  const { tenantId, projectId, graphId } = executionContext;
8629
- logger21.info({ body }, "Received initialization request");
8706
+ logger22.info({ body }, "Received initialization request");
8630
8707
  const sessionId = nanoid.nanoid();
8631
8708
  const agentGraph = await agentsCore.getAgentGraphWithDefaultAgent(dbClient_default)({
8632
8709
  scopes: { tenantId, projectId },
@@ -8657,7 +8734,7 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
8657
8734
  }
8658
8735
  }
8659
8736
  });
8660
- logger21.info(
8737
+ logger22.info(
8661
8738
  { sessionId, conversationId: conversation.id },
8662
8739
  "Created MCP session as conversation"
8663
8740
  );
@@ -8666,9 +8743,9 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
8666
8743
  });
8667
8744
  const server = await getServer(validatedContext, executionContext, sessionId, credentialStores);
8668
8745
  await server.connect(transport);
8669
- logger21.info({ sessionId }, "Server connected for initialization");
8746
+ logger22.info({ sessionId }, "Server connected for initialization");
8670
8747
  res.setHeader("Mcp-Session-Id", sessionId);
8671
- logger21.info(
8748
+ logger22.info(
8672
8749
  {
8673
8750
  sessionId,
8674
8751
  bodyMethod: body?.method,
@@ -8677,7 +8754,7 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
8677
8754
  "About to handle initialization request"
8678
8755
  );
8679
8756
  await transport.handleRequest(req, res, body);
8680
- logger21.info({ sessionId }, "Successfully handled initialization request");
8757
+ logger22.info({ sessionId }, "Successfully handled initialization request");
8681
8758
  return fetchToNode.toFetchResponse(res);
8682
8759
  };
8683
8760
  var handleExistingSessionRequest = async (body, executionContext, validatedContext, req, res, credentialStores) => {
@@ -8705,8 +8782,8 @@ var handleExistingSessionRequest = async (body, executionContext, validatedConte
8705
8782
  sessionId,
8706
8783
  conversation.metadata?.session_data?.mcpProtocolVersion
8707
8784
  );
8708
- logger21.info({ sessionId }, "Server connected and transport initialized");
8709
- logger21.info(
8785
+ logger22.info({ sessionId }, "Server connected and transport initialized");
8786
+ logger22.info(
8710
8787
  {
8711
8788
  sessionId,
8712
8789
  bodyKeys: Object.keys(body || {}),
@@ -8720,9 +8797,9 @@ var handleExistingSessionRequest = async (body, executionContext, validatedConte
8720
8797
  );
8721
8798
  try {
8722
8799
  await transport.handleRequest(req, res, body);
8723
- logger21.info({ sessionId }, "Successfully handled MCP request");
8800
+ logger22.info({ sessionId }, "Successfully handled MCP request");
8724
8801
  } catch (transportError) {
8725
- logger21.error(
8802
+ logger22.error(
8726
8803
  {
8727
8804
  sessionId,
8728
8805
  error: transportError,
@@ -8773,13 +8850,13 @@ app4.openapi(
8773
8850
  }
8774
8851
  const { executionContext } = paramValidation;
8775
8852
  const body = c.get("requestBody") || {};
8776
- logger21.info({ body, bodyKeys: Object.keys(body || {}) }, "Parsed request body");
8853
+ logger22.info({ body, bodyKeys: Object.keys(body || {}) }, "Parsed request body");
8777
8854
  const isInitRequest = body.method === "initialize";
8778
8855
  const { req, res } = fetchToNode.toReqRes(c.req.raw);
8779
8856
  const validatedContext = c.get("validatedContext") || {};
8780
8857
  const credentialStores = c.get("credentialStores");
8781
- logger21.info({ validatedContext }, "Validated context");
8782
- logger21.info({ req }, "request");
8858
+ logger22.info({ validatedContext }, "Validated context");
8859
+ logger22.info({ req }, "request");
8783
8860
  if (isInitRequest) {
8784
8861
  return await handleInitializationRequest(
8785
8862
  body,
@@ -8801,7 +8878,7 @@ app4.openapi(
8801
8878
  );
8802
8879
  }
8803
8880
  } catch (e) {
8804
- logger21.error(
8881
+ logger22.error(
8805
8882
  {
8806
8883
  error: e instanceof Error ? e.message : e,
8807
8884
  stack: e instanceof Error ? e.stack : void 0
@@ -8813,7 +8890,7 @@ app4.openapi(
8813
8890
  }
8814
8891
  );
8815
8892
  app4.get("/", async (c) => {
8816
- logger21.info({}, "Received GET MCP request");
8893
+ logger22.info({}, "Received GET MCP request");
8817
8894
  return c.json(
8818
8895
  {
8819
8896
  jsonrpc: "2.0",
@@ -8827,7 +8904,7 @@ app4.get("/", async (c) => {
8827
8904
  );
8828
8905
  });
8829
8906
  app4.delete("/", async (c) => {
8830
- logger21.info({}, "Received DELETE MCP request");
8907
+ logger22.info({}, "Received DELETE MCP request");
8831
8908
  return c.json(
8832
8909
  {
8833
8910
  jsonrpc: "2.0",
@@ -8838,7 +8915,7 @@ app4.delete("/", async (c) => {
8838
8915
  );
8839
8916
  });
8840
8917
  var mcp_default = app4;
8841
- var logger22 = agentsCore.getLogger("agents-run-api");
8918
+ var logger23 = agentsCore.getLogger("agents-run-api");
8842
8919
  function createExecutionHono(serverConfig, credentialStores) {
8843
8920
  const app6 = new zodOpenapi.OpenAPIHono();
8844
8921
  app6.use("*", otel.otel());
@@ -8854,7 +8931,7 @@ function createExecutionHono(serverConfig, credentialStores) {
8854
8931
  const body = await c.req.json();
8855
8932
  c.set("requestBody", body);
8856
8933
  } catch (error) {
8857
- logger22.debug({ error }, "Failed to parse JSON body, continuing without parsed body");
8934
+ logger23.debug({ error }, "Failed to parse JSON body, continuing without parsed body");
8858
8935
  }
8859
8936
  }
8860
8937
  return next();
@@ -8905,8 +8982,8 @@ function createExecutionHono(serverConfig, credentialStores) {
8905
8982
  if (!isExpectedError) {
8906
8983
  const errorMessage = err instanceof Error ? err.message : String(err);
8907
8984
  const errorStack = err instanceof Error ? err.stack : void 0;
8908
- if (logger22) {
8909
- logger22.error(
8985
+ if (logger23) {
8986
+ logger23.error(
8910
8987
  {
8911
8988
  error: err,
8912
8989
  message: errorMessage,
@@ -8918,8 +8995,8 @@ function createExecutionHono(serverConfig, credentialStores) {
8918
8995
  );
8919
8996
  }
8920
8997
  } else {
8921
- if (logger22) {
8922
- logger22.error(
8998
+ if (logger23) {
8999
+ logger23.error(
8923
9000
  {
8924
9001
  error: err,
8925
9002
  path: c.req.path,
@@ -8936,8 +9013,8 @@ function createExecutionHono(serverConfig, credentialStores) {
8936
9013
  const response = err.getResponse();
8937
9014
  return response;
8938
9015
  } catch (responseError) {
8939
- if (logger22) {
8940
- logger22.error({ error: responseError }, "Error while handling HTTPException response");
9016
+ if (logger23) {
9017
+ logger23.error({ error: responseError }, "Error while handling HTTPException response");
8941
9018
  }
8942
9019
  }
8943
9020
  }
@@ -8971,7 +9048,7 @@ function createExecutionHono(serverConfig, credentialStores) {
8971
9048
  app6.use("*", async (c, next) => {
8972
9049
  const executionContext = c.get("executionContext");
8973
9050
  if (!executionContext) {
8974
- logger22.debug({}, "Empty execution context");
9051
+ logger23.debug({}, "Empty execution context");
8975
9052
  return next();
8976
9053
  }
8977
9054
  const { tenantId, projectId, graphId } = executionContext;
@@ -8980,7 +9057,7 @@ function createExecutionHono(serverConfig, credentialStores) {
8980
9057
  if (requestBody) {
8981
9058
  conversationId = requestBody.conversationId;
8982
9059
  if (!conversationId) {
8983
- logger22.debug({ requestBody }, "No conversation ID found in request body");
9060
+ logger23.debug({ requestBody }, "No conversation ID found in request body");
8984
9061
  }
8985
9062
  }
8986
9063
  const entries = Object.fromEntries(
@@ -8995,7 +9072,7 @@ function createExecutionHono(serverConfig, credentialStores) {
8995
9072
  })
8996
9073
  );
8997
9074
  if (!Object.keys(entries).length) {
8998
- logger22.debug({}, "Empty entries for baggage");
9075
+ logger23.debug({}, "Empty entries for baggage");
8999
9076
  return next();
9000
9077
  }
9001
9078
  const bag = Object.entries(entries).reduce(