@inkeep/agents-run-api 0.0.0-dev-20250915190940 → 0.0.0-dev-20250916015245

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 +376 -294
  2. package/dist/index.js +375 -293
  3. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -858,6 +858,127 @@ async function handleTasksResubscribe(c, agent, request) {
858
858
  });
859
859
  }
860
860
  }
861
+ getLogger("agents");
862
+ function createAgentCard({
863
+ dbAgent,
864
+ baseUrl
865
+ }) {
866
+ const description = dbAgent.description || "AI Agent";
867
+ return {
868
+ name: dbAgent.name,
869
+ description,
870
+ url: baseUrl ? `${baseUrl}/a2a` : "",
871
+ version: "1.0.0",
872
+ capabilities: {
873
+ streaming: true,
874
+ // Enable streaming for A2A compliance
875
+ pushNotifications: false,
876
+ stateTransitionHistory: false
877
+ },
878
+ defaultInputModes: ["text", "text/plain"],
879
+ defaultOutputModes: ["text", "text/plain"],
880
+ skills: [],
881
+ // Add provider info if available
882
+ ...baseUrl && {
883
+ provider: {
884
+ organization: "Inkeep",
885
+ url: baseUrl
886
+ }
887
+ }
888
+ };
889
+ }
890
+ function generateDescriptionWithTransfers(baseDescription, internalRelations, externalRelations) {
891
+ const transfers = [
892
+ ...internalRelations.filter((rel) => rel.relationType === "transfer"),
893
+ ...externalRelations.filter((rel) => rel.relationType === "transfer")
894
+ ];
895
+ const delegates = [
896
+ ...internalRelations.filter((rel) => rel.relationType === "delegate"),
897
+ ...externalRelations.filter((rel) => rel.relationType === "delegate")
898
+ ];
899
+ if (transfers.length === 0 && delegates.length === 0) {
900
+ return baseDescription;
901
+ }
902
+ let enhancedDescription = baseDescription;
903
+ if (transfers.length > 0) {
904
+ const transferList = transfers.map((rel) => {
905
+ const name = rel.externalAgent?.name || rel.name;
906
+ const desc = rel.externalAgent?.description || rel.description || "";
907
+ return `- ${name}: ${desc}`;
908
+ }).join("\n");
909
+ enhancedDescription += `
910
+
911
+ Can transfer to:
912
+ ${transferList}`;
913
+ }
914
+ if (delegates.length > 0) {
915
+ const delegateList = delegates.map((rel) => {
916
+ const name = rel.externalAgent?.name || rel.name;
917
+ const desc = rel.externalAgent?.description || rel.description || "";
918
+ return `- ${name}: ${desc}`;
919
+ }).join("\n");
920
+ enhancedDescription += `
921
+
922
+ Can delegate to:
923
+ ${delegateList}`;
924
+ }
925
+ return enhancedDescription;
926
+ }
927
+ async function hydrateAgent({
928
+ dbAgent,
929
+ graphId,
930
+ baseUrl,
931
+ apiKey,
932
+ credentialStoreRegistry
933
+ }) {
934
+ try {
935
+ const taskHandlerConfig = await createTaskHandlerConfig({
936
+ tenantId: dbAgent.tenantId,
937
+ projectId: dbAgent.projectId,
938
+ graphId,
939
+ agentId: dbAgent.id,
940
+ baseUrl,
941
+ apiKey
942
+ });
943
+ const taskHandler = createTaskHandler(taskHandlerConfig, credentialStoreRegistry);
944
+ const agentCard = createAgentCard({
945
+ dbAgent,
946
+ baseUrl
947
+ });
948
+ return {
949
+ agentId: dbAgent.id,
950
+ tenantId: dbAgent.tenantId,
951
+ projectId: dbAgent.projectId,
952
+ graphId,
953
+ agentCard,
954
+ taskHandler
955
+ };
956
+ } catch (error) {
957
+ console.error(`\u274C Failed to hydrate agent ${dbAgent.id}:`, error);
958
+ throw error;
959
+ }
960
+ }
961
+ async function getRegisteredAgent(executionContext, credentialStoreRegistry) {
962
+ const { tenantId, projectId, graphId, agentId, baseUrl, apiKey } = executionContext;
963
+ if (!agentId) {
964
+ throw new Error("Agent ID is required");
965
+ }
966
+ const dbAgent = await getAgentById(dbClient_default)({
967
+ scopes: { tenantId, projectId },
968
+ agentId
969
+ });
970
+ if (!dbAgent) {
971
+ return null;
972
+ }
973
+ const agentFrameworkBaseUrl = `${baseUrl}/agents`;
974
+ return hydrateAgent({
975
+ dbAgent,
976
+ graphId,
977
+ baseUrl: agentFrameworkBaseUrl,
978
+ credentialStoreRegistry,
979
+ apiKey
980
+ });
981
+ }
861
982
  function agentInitializingOp(sessionId, graphId) {
862
983
  return {
863
984
  type: "agent_initializing",
@@ -894,10 +1015,10 @@ function statusUpdateOp(ctx) {
894
1015
  ctx
895
1016
  };
896
1017
  }
897
- var logger3 = getLogger("DataComponentSchema");
1018
+ var logger4 = getLogger("DataComponentSchema");
898
1019
  function jsonSchemaToZod(jsonSchema) {
899
1020
  if (!jsonSchema || typeof jsonSchema !== "object") {
900
- logger3.warn({ jsonSchema }, "Invalid JSON schema provided, using string fallback");
1021
+ logger4.warn({ jsonSchema }, "Invalid JSON schema provided, using string fallback");
901
1022
  return z.string();
902
1023
  }
903
1024
  switch (jsonSchema.type) {
@@ -924,7 +1045,7 @@ function jsonSchemaToZod(jsonSchema) {
924
1045
  case "null":
925
1046
  return z.null();
926
1047
  default:
927
- logger3.warn(
1048
+ logger4.warn(
928
1049
  {
929
1050
  unsupportedType: jsonSchema.type,
930
1051
  schema: jsonSchema
@@ -978,7 +1099,7 @@ __publicField(_ArtifactReferenceSchema, "ARTIFACT_PROPS_SCHEMA", {
978
1099
  required: ["artifact_id", "task_id"]
979
1100
  });
980
1101
  var ArtifactReferenceSchema = _ArtifactReferenceSchema;
981
- var logger4 = getLogger("ModelFactory");
1102
+ var logger5 = getLogger("ModelFactory");
982
1103
  var _ModelFactory = class _ModelFactory {
983
1104
  /**
984
1105
  * Create a language model instance from configuration
@@ -993,7 +1114,7 @@ var _ModelFactory = class _ModelFactory {
993
1114
  const modelSettings = config;
994
1115
  const modelString = modelSettings.model.trim();
995
1116
  const { provider, modelName } = _ModelFactory.parseModelString(modelString);
996
- logger4.debug(
1117
+ logger5.debug(
997
1118
  {
998
1119
  provider,
999
1120
  model: modelName,
@@ -1014,7 +1135,7 @@ var _ModelFactory = class _ModelFactory {
1014
1135
  );
1015
1136
  }
1016
1137
  } catch (error) {
1017
- logger4.error(
1138
+ logger5.error(
1018
1139
  {
1019
1140
  provider,
1020
1141
  model: modelName,
@@ -1037,7 +1158,7 @@ var _ModelFactory = class _ModelFactory {
1037
1158
  const [provider, ...modelParts] = modelString.split("/");
1038
1159
  const normalizedProvider = provider.toLowerCase();
1039
1160
  if (!_ModelFactory.SUPPORTED_PROVIDERS.includes(normalizedProvider)) {
1040
- logger4.warn(
1161
+ logger5.warn(
1041
1162
  { provider: normalizedProvider, modelName: modelParts.join("/") },
1042
1163
  "Unsupported provider detected, falling back to anthropic"
1043
1164
  );
@@ -1066,14 +1187,14 @@ var _ModelFactory = class _ModelFactory {
1066
1187
  anthropicConfig.baseURL = providerOptions.baseUrl || providerOptions.baseURL;
1067
1188
  }
1068
1189
  if (providerOptions?.gateway) {
1069
- logger4.info(
1190
+ logger5.info(
1070
1191
  { gateway: providerOptions.gateway },
1071
1192
  "Setting up AI Gateway for Anthropic model"
1072
1193
  );
1073
1194
  Object.assign(anthropicConfig, providerOptions.gateway);
1074
1195
  }
1075
1196
  if (Object.keys(anthropicConfig).length > 0) {
1076
- logger4.info({ config: anthropicConfig }, "Applying custom Anthropic provider configuration");
1197
+ logger5.info({ config: anthropicConfig }, "Applying custom Anthropic provider configuration");
1077
1198
  const provider = createAnthropic(anthropicConfig);
1078
1199
  return provider(modelName);
1079
1200
  }
@@ -1088,11 +1209,11 @@ var _ModelFactory = class _ModelFactory {
1088
1209
  openaiConfig.baseURL = providerOptions.baseUrl || providerOptions.baseURL;
1089
1210
  }
1090
1211
  if (providerOptions?.gateway) {
1091
- logger4.info({ gateway: providerOptions.gateway }, "Setting up AI Gateway for OpenAI model");
1212
+ logger5.info({ gateway: providerOptions.gateway }, "Setting up AI Gateway for OpenAI model");
1092
1213
  Object.assign(openaiConfig, providerOptions.gateway);
1093
1214
  }
1094
1215
  if (Object.keys(openaiConfig).length > 0) {
1095
- logger4.info({ config: openaiConfig }, "Applying custom OpenAI provider configuration");
1216
+ logger5.info({ config: openaiConfig }, "Applying custom OpenAI provider configuration");
1096
1217
  const provider = createOpenAI(openaiConfig);
1097
1218
  return provider(modelName);
1098
1219
  }
@@ -1182,7 +1303,7 @@ function unregisterStreamHelper(requestId2) {
1182
1303
  }
1183
1304
 
1184
1305
  // src/utils/graph-session.ts
1185
- var logger5 = getLogger("GraphSession");
1306
+ var logger6 = getLogger("GraphSession");
1186
1307
  var GraphSession = class {
1187
1308
  // Track scheduled timeouts for cleanup
1188
1309
  constructor(sessionId, messageId, graphId, tenantId, projectId) {
@@ -1206,7 +1327,7 @@ var GraphSession = class {
1206
1327
  __publicField(this, "MAX_PENDING_ARTIFACTS", 100);
1207
1328
  // Prevent unbounded growth
1208
1329
  __publicField(this, "scheduledTimeouts");
1209
- logger5.debug({ sessionId, messageId, graphId }, "GraphSession created");
1330
+ logger6.debug({ sessionId, messageId, graphId }, "GraphSession created");
1210
1331
  }
1211
1332
  /**
1212
1333
  * Initialize status updates for this session
@@ -1220,15 +1341,15 @@ var GraphSession = class {
1220
1341
  summarizerModel,
1221
1342
  baseModel,
1222
1343
  config: {
1223
- numEvents: config.numEvents || 10,
1224
- timeInSeconds: config.timeInSeconds || 30,
1344
+ numEvents: config.numEvents || 1,
1345
+ timeInSeconds: config.timeInSeconds || 2,
1225
1346
  ...config
1226
1347
  }
1227
1348
  };
1228
1349
  if (this.statusUpdateState.config.timeInSeconds) {
1229
1350
  this.statusUpdateTimer = setInterval(async () => {
1230
1351
  if (!this.statusUpdateState || this.isEnded) {
1231
- logger5.debug(
1352
+ logger6.debug(
1232
1353
  { sessionId: this.sessionId },
1233
1354
  "Timer triggered but session already cleaned up or ended"
1234
1355
  );
@@ -1240,7 +1361,7 @@ var GraphSession = class {
1240
1361
  }
1241
1362
  await this.checkAndSendTimeBasedUpdate();
1242
1363
  }, this.statusUpdateState.config.timeInSeconds * 1e3);
1243
- logger5.info(
1364
+ logger6.info(
1244
1365
  {
1245
1366
  sessionId: this.sessionId,
1246
1367
  intervalMs: this.statusUpdateState.config.timeInSeconds * 1e3
@@ -1254,7 +1375,7 @@ var GraphSession = class {
1254
1375
  */
1255
1376
  recordEvent(eventType, agentId, data) {
1256
1377
  if (this.isEnded) {
1257
- logger5.debug(
1378
+ logger6.debug(
1258
1379
  {
1259
1380
  sessionId: this.sessionId,
1260
1381
  eventType,
@@ -1274,7 +1395,7 @@ var GraphSession = class {
1274
1395
  if (eventType === "artifact_saved" && data.pendingGeneration) {
1275
1396
  const artifactId = data.artifactId;
1276
1397
  if (this.pendingArtifacts.size >= this.MAX_PENDING_ARTIFACTS) {
1277
- logger5.warn(
1398
+ logger6.warn(
1278
1399
  {
1279
1400
  sessionId: this.sessionId,
1280
1401
  artifactId,
@@ -1295,7 +1416,7 @@ var GraphSession = class {
1295
1416
  this.artifactProcessingErrors.set(artifactId, errorCount);
1296
1417
  if (errorCount >= this.MAX_ARTIFACT_RETRIES) {
1297
1418
  this.pendingArtifacts.delete(artifactId);
1298
- logger5.error(
1419
+ logger6.error(
1299
1420
  {
1300
1421
  sessionId: this.sessionId,
1301
1422
  artifactId,
@@ -1307,7 +1428,7 @@ var GraphSession = class {
1307
1428
  "Artifact processing failed after max retries, giving up"
1308
1429
  );
1309
1430
  } else {
1310
- logger5.warn(
1431
+ logger6.warn(
1311
1432
  {
1312
1433
  sessionId: this.sessionId,
1313
1434
  artifactId,
@@ -1329,14 +1450,14 @@ var GraphSession = class {
1329
1450
  */
1330
1451
  checkStatusUpdates() {
1331
1452
  if (this.isEnded) {
1332
- logger5.debug(
1453
+ logger6.debug(
1333
1454
  { sessionId: this.sessionId },
1334
1455
  "Session has ended - skipping status update check"
1335
1456
  );
1336
1457
  return;
1337
1458
  }
1338
1459
  if (!this.statusUpdateState) {
1339
- logger5.debug({ sessionId: this.sessionId }, "No status update state - skipping check");
1460
+ logger6.debug({ sessionId: this.sessionId }, "No status update state - skipping check");
1340
1461
  return;
1341
1462
  }
1342
1463
  const statusUpdateState = this.statusUpdateState;
@@ -1347,11 +1468,11 @@ var GraphSession = class {
1347
1468
  */
1348
1469
  async checkAndSendTimeBasedUpdate() {
1349
1470
  if (this.isEnded) {
1350
- logger5.debug({ sessionId: this.sessionId }, "Session has ended - skipping time-based update");
1471
+ logger6.debug({ sessionId: this.sessionId }, "Session has ended - skipping time-based update");
1351
1472
  return;
1352
1473
  }
1353
1474
  if (!this.statusUpdateState) {
1354
- logger5.debug(
1475
+ logger6.debug(
1355
1476
  { sessionId: this.sessionId },
1356
1477
  "No status updates configured for time-based check"
1357
1478
  );
@@ -1364,7 +1485,7 @@ var GraphSession = class {
1364
1485
  try {
1365
1486
  await this.generateAndSendUpdate();
1366
1487
  } catch (error) {
1367
- logger5.error(
1488
+ logger6.error(
1368
1489
  {
1369
1490
  sessionId: this.sessionId,
1370
1491
  error: error instanceof Error ? error.message : "Unknown error"
@@ -1457,29 +1578,29 @@ var GraphSession = class {
1457
1578
  */
1458
1579
  async generateAndSendUpdate() {
1459
1580
  if (this.isEnded) {
1460
- logger5.debug({ sessionId: this.sessionId }, "Session has ended - not generating update");
1581
+ logger6.debug({ sessionId: this.sessionId }, "Session has ended - not generating update");
1461
1582
  return;
1462
1583
  }
1463
1584
  if (this.isTextStreaming) {
1464
- logger5.debug(
1585
+ logger6.debug(
1465
1586
  { sessionId: this.sessionId },
1466
1587
  "Text is currently streaming - skipping status update"
1467
1588
  );
1468
1589
  return;
1469
1590
  }
1470
1591
  if (this.isGeneratingUpdate) {
1471
- logger5.debug(
1592
+ logger6.debug(
1472
1593
  { sessionId: this.sessionId },
1473
1594
  "Update already in progress - skipping duplicate generation"
1474
1595
  );
1475
1596
  return;
1476
1597
  }
1477
1598
  if (!this.statusUpdateState) {
1478
- logger5.warn({ sessionId: this.sessionId }, "No status update state - cannot generate update");
1599
+ logger6.warn({ sessionId: this.sessionId }, "No status update state - cannot generate update");
1479
1600
  return;
1480
1601
  }
1481
1602
  if (!this.graphId) {
1482
- logger5.warn({ sessionId: this.sessionId }, "No graph ID - cannot generate update");
1603
+ logger6.warn({ sessionId: this.sessionId }, "No graph ID - cannot generate update");
1483
1604
  return;
1484
1605
  }
1485
1606
  const newEventCount = this.events.length - this.statusUpdateState.lastEventCount;
@@ -1492,7 +1613,7 @@ var GraphSession = class {
1492
1613
  try {
1493
1614
  const streamHelper = getStreamHelper(this.sessionId);
1494
1615
  if (!streamHelper) {
1495
- logger5.warn(
1616
+ logger6.warn(
1496
1617
  { sessionId: this.sessionId },
1497
1618
  "No stream helper found - cannot send status update"
1498
1619
  );
@@ -1513,7 +1634,7 @@ var GraphSession = class {
1513
1634
  if (result.operations && result.operations.length > 0) {
1514
1635
  for (const op of result.operations) {
1515
1636
  if (!op || !op.type || !op.data || Object.keys(op.data).length === 0) {
1516
- logger5.warn(
1637
+ logger6.warn(
1517
1638
  {
1518
1639
  sessionId: this.sessionId,
1519
1640
  operation: op
@@ -1566,7 +1687,7 @@ var GraphSession = class {
1566
1687
  this.previousSummaries.shift();
1567
1688
  }
1568
1689
  if (!operation || !operation.type || !operation.ctx) {
1569
- logger5.warn(
1690
+ logger6.warn(
1570
1691
  {
1571
1692
  sessionId: this.sessionId,
1572
1693
  operation
@@ -1581,7 +1702,7 @@ var GraphSession = class {
1581
1702
  this.statusUpdateState.lastEventCount = this.events.length;
1582
1703
  }
1583
1704
  } catch (error) {
1584
- logger5.error(
1705
+ logger6.error(
1585
1706
  {
1586
1707
  sessionId: this.sessionId,
1587
1708
  error: error instanceof Error ? error.message : "Unknown error",
@@ -1619,7 +1740,7 @@ var GraphSession = class {
1619
1740
  this.releaseUpdateLock();
1620
1741
  }
1621
1742
  } catch (error) {
1622
- logger5.error(
1743
+ logger6.error(
1623
1744
  {
1624
1745
  sessionId: this.sessionId,
1625
1746
  error: error instanceof Error ? error.message : "Unknown error"
@@ -1696,7 +1817,7 @@ User's Question/Context:
1696
1817
  ${conversationHistory}
1697
1818
  ` : "";
1698
1819
  } catch (error) {
1699
- logger5.warn(
1820
+ logger6.warn(
1700
1821
  { sessionId: this.sessionId, error },
1701
1822
  "Failed to fetch conversation history for status update"
1702
1823
  );
@@ -1748,7 +1869,7 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
1748
1869
  return text.trim();
1749
1870
  } catch (error) {
1750
1871
  setSpanWithError(span, error);
1751
- logger5.error({ error }, "Failed to generate summary, using fallback");
1872
+ logger6.error({ error }, "Failed to generate summary, using fallback");
1752
1873
  return this.generateFallbackSummary(newEvents, elapsedTime);
1753
1874
  } finally {
1754
1875
  span.end();
@@ -1794,7 +1915,7 @@ User's Question/Context:
1794
1915
  ${conversationHistory}
1795
1916
  ` : "";
1796
1917
  } catch (error) {
1797
- logger5.warn(
1918
+ logger6.warn(
1798
1919
  { sessionId: this.sessionId, error },
1799
1920
  "Failed to fetch conversation history for structured status update"
1800
1921
  );
@@ -1837,9 +1958,11 @@ Rules:
1837
1958
  - Labels MUST contain the ACTUAL information discovered ("Found X", "Learned Y", "Discovered Z requires A")
1838
1959
  - DO NOT use action words like "Searching", "Processing", "Analyzing" - state what was FOUND
1839
1960
  - Include specific details, numbers, requirements, or insights discovered
1840
- - You are ONE AI (no agents/delegations)
1841
- - Anonymize all internal operations so that the information appears descriptive and USER FRIENDLY. HIDE INTERNAL OPERATIONS!
1842
- - 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"
1961
+ - You are ONE unified AI system - NEVER mention agents, transfers, delegations, or routing
1962
+ - CRITICAL: NEVER use the words "transfer", "delegation", "agent", "routing", or any internal system terminology in labels
1963
+ - Present all operations as seamless actions by a single system
1964
+ - Anonymize all internal operations so that the information appears descriptive and USER FRIENDLY. HIDE ALL INTERNAL OPERATIONS!
1965
+ - Bad examples: "Transferring to search agent", "Delegating task", "Routing request", "Processing request", or not using the no_relevant_updates
1843
1966
  - 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.
1844
1967
 
1845
1968
  REMEMBER YOU CAN ONLY USE 'no_relevant_updates' ALONE! IT CANNOT BE CONCATENATED WITH OTHER STATUS UPDATES!
@@ -1893,7 +2016,7 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
1893
2016
  return { operations };
1894
2017
  } catch (error) {
1895
2018
  setSpanWithError(span, error);
1896
- logger5.error({ error }, "Failed to generate structured update, using fallback");
2019
+ logger6.error({ error }, "Failed to generate structured update, using fallback");
1897
2020
  return { operations: [] };
1898
2021
  } finally {
1899
2022
  span.end();
@@ -2000,8 +2123,7 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
2000
2123
  case "transfer": {
2001
2124
  const data = event.data;
2002
2125
  activities.push(
2003
- `\u{1F504} **Transfer**: ${data.fromAgent} \u2192 ${data.targetAgent}
2004
- ${data.reason ? `Reason: ${data.reason}` : "Control transfer"}
2126
+ `\u{1F504} **Continuing**: ${data.reason || "Processing request"}
2005
2127
  ${data.context ? `Context: ${JSON.stringify(data.context, null, 2)}` : ""}`
2006
2128
  );
2007
2129
  break;
@@ -2009,8 +2131,7 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
2009
2131
  case "delegation_sent": {
2010
2132
  const data = event.data;
2011
2133
  activities.push(
2012
- `\u{1F4E4} **Delegation Sent** [${data.delegationId}]: ${data.fromAgent} \u2192 ${data.targetAgent}
2013
- Task: ${data.taskDescription}
2134
+ `\u{1F4E4} **Processing**: ${data.taskDescription}
2014
2135
  ${data.context ? `Context: ${JSON.stringify(data.context, null, 2)}` : ""}`
2015
2136
  );
2016
2137
  break;
@@ -2018,7 +2139,7 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
2018
2139
  case "delegation_returned": {
2019
2140
  const data = event.data;
2020
2141
  activities.push(
2021
- `\u{1F4E5} **Delegation Returned** [${data.delegationId}]: ${data.fromAgent} \u2190 ${data.targetAgent}
2142
+ `\u{1F4E5} **Completed subtask**
2022
2143
  Result: ${JSON.stringify(data.result, null, 2)}`
2023
2144
  );
2024
2145
  break;
@@ -2037,16 +2158,16 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
2037
2158
  case "agent_reasoning": {
2038
2159
  const data = event.data;
2039
2160
  activities.push(
2040
- `\u2699\uFE0F **Reasoning**: reasoning
2041
- Full Details: ${JSON.stringify(data.parts, null, 2)}`
2161
+ `\u2699\uFE0F **Analyzing request**
2162
+ Details: ${JSON.stringify(data.parts, null, 2)}`
2042
2163
  );
2043
2164
  break;
2044
2165
  }
2045
2166
  case "agent_generate": {
2046
2167
  const data = event.data;
2047
2168
  activities.push(
2048
- `\u2699\uFE0F **Generation**: ${data.generationType}
2049
- Full Details: ${JSON.stringify(data.parts, null, 2)}`
2169
+ `\u2699\uFE0F **Preparing response**
2170
+ Details: ${JSON.stringify(data.parts, null, 2)}`
2050
2171
  );
2051
2172
  break;
2052
2173
  }
@@ -2220,7 +2341,7 @@ Make it specific and relevant.`;
2220
2341
  taskId: artifactData.taskId,
2221
2342
  artifacts: [artifactToSave]
2222
2343
  });
2223
- logger5.info(
2344
+ logger6.info(
2224
2345
  {
2225
2346
  sessionId: this.sessionId,
2226
2347
  artifactId: artifactData.artifactId,
@@ -2237,7 +2358,7 @@ Make it specific and relevant.`;
2237
2358
  span.setStatus({ code: SpanStatusCode.OK });
2238
2359
  } catch (error) {
2239
2360
  setSpanWithError(span, error);
2240
- logger5.error(
2361
+ logger6.error(
2241
2362
  {
2242
2363
  sessionId: this.sessionId,
2243
2364
  artifactId: artifactData.artifactId,
@@ -2273,7 +2394,7 @@ Make it specific and relevant.`;
2273
2394
  taskId: artifactData.taskId,
2274
2395
  artifacts: [fallbackArtifact]
2275
2396
  });
2276
- logger5.info(
2397
+ logger6.info(
2277
2398
  {
2278
2399
  sessionId: this.sessionId,
2279
2400
  artifactId: artifactData.artifactId
@@ -2282,7 +2403,7 @@ Make it specific and relevant.`;
2282
2403
  );
2283
2404
  }
2284
2405
  } catch (fallbackError) {
2285
- logger5.error(
2406
+ logger6.error(
2286
2407
  {
2287
2408
  sessionId: this.sessionId,
2288
2409
  artifactId: artifactData.artifactId,
@@ -2309,7 +2430,7 @@ var GraphSessionManager = class {
2309
2430
  const sessionId = messageId;
2310
2431
  const session = new GraphSession(sessionId, messageId, graphId, tenantId, projectId);
2311
2432
  this.sessions.set(sessionId, session);
2312
- logger5.info({ sessionId, messageId, graphId, tenantId, projectId }, "GraphSession created");
2433
+ logger6.info({ sessionId, messageId, graphId, tenantId, projectId }, "GraphSession created");
2313
2434
  return sessionId;
2314
2435
  }
2315
2436
  /**
@@ -2320,7 +2441,7 @@ var GraphSessionManager = class {
2320
2441
  if (session) {
2321
2442
  session.initializeStatusUpdates(config, summarizerModel);
2322
2443
  } else {
2323
- logger5.error(
2444
+ logger6.error(
2324
2445
  {
2325
2446
  sessionId,
2326
2447
  availableSessions: Array.from(this.sessions.keys())
@@ -2341,7 +2462,7 @@ var GraphSessionManager = class {
2341
2462
  recordEvent(sessionId, eventType, agentId, data) {
2342
2463
  const session = this.sessions.get(sessionId);
2343
2464
  if (!session) {
2344
- logger5.warn({ sessionId }, "Attempted to record event in non-existent session");
2465
+ logger6.warn({ sessionId }, "Attempted to record event in non-existent session");
2345
2466
  return;
2346
2467
  }
2347
2468
  session.recordEvent(eventType, agentId, data);
@@ -2352,12 +2473,12 @@ var GraphSessionManager = class {
2352
2473
  endSession(sessionId) {
2353
2474
  const session = this.sessions.get(sessionId);
2354
2475
  if (!session) {
2355
- logger5.warn({ sessionId }, "Attempted to end non-existent session");
2476
+ logger6.warn({ sessionId }, "Attempted to end non-existent session");
2356
2477
  return [];
2357
2478
  }
2358
2479
  const events = session.getEvents();
2359
2480
  const summary = session.getSummary();
2360
- logger5.info({ sessionId, summary }, "GraphSession ended");
2481
+ logger6.info({ sessionId, summary }, "GraphSession ended");
2361
2482
  session.cleanup();
2362
2483
  this.sessions.delete(sessionId);
2363
2484
  return events;
@@ -2383,7 +2504,7 @@ var GraphSessionManager = class {
2383
2504
  }
2384
2505
  };
2385
2506
  var graphSessionManager = new GraphSessionManager();
2386
- var logger6 = getLogger("ArtifactParser");
2507
+ var logger7 = getLogger("ArtifactParser");
2387
2508
  var _ArtifactParser = class _ArtifactParser {
2388
2509
  constructor(tenantId) {
2389
2510
  this.tenantId = tenantId;
@@ -2399,9 +2520,7 @@ var _ArtifactParser = class _ArtifactParser {
2399
2520
  * More robust detection that handles streaming fragments
2400
2521
  */
2401
2522
  hasIncompleteArtifact(text) {
2402
- return /^.*<(?:artifact(?::ref)?|a(?:r(?:t(?:i(?:f(?:a(?:c(?:t(?::(?:r(?:e(?:f)?)?)?)?)?)?)?)?)?)?)?)?$/.test(
2403
- text
2404
- ) || /^.*<artifact:ref(?:[^>]*)$/.test(text) || // Incomplete artifact:ref at end
2523
+ return /<(a(r(t(i(f(a(c(t(:?(r(e(f)?)?)?)?)?)?)?)?)?)?)?)?$/.test(text) || /<artifact:ref[^>]+$/.test(text) || // Incomplete artifact ref at end
2405
2524
  this.findSafeTextBoundary(text) < text.length;
2406
2525
  }
2407
2526
  /**
@@ -2410,10 +2529,10 @@ var _ArtifactParser = class _ArtifactParser {
2410
2529
  */
2411
2530
  findSafeTextBoundary(text) {
2412
2531
  const endPatterns = [
2413
- /^.*<artifact:ref(?:[^/>]+(?:[^>]*[^/])?)?$/,
2532
+ /<artifact:ref(?![^>]*\/>).*$/,
2414
2533
  // artifact:ref that doesn't end with />
2415
- /^.*<(?:artifact(?::ref)?|a(?:r(?:t(?:i(?:f(?:a(?:c(?:t(?::(?:r(?:e(?:f)?)?)?)?)?)?)?)?)?)?)?)?$/
2416
- // Safe partial artifact pattern
2534
+ /<(a(r(t(i(f(a(c(t(:?(r(e(f)?)?)?)?)?)?)?)?)?)?)?)?$/
2535
+ // Any partial artifact pattern at end
2417
2536
  ];
2418
2537
  for (const pattern of endPatterns) {
2419
2538
  const match = text.match(pattern);
@@ -2449,7 +2568,7 @@ var _ArtifactParser = class _ArtifactParser {
2449
2568
  id: taskId
2450
2569
  });
2451
2570
  if (!task) {
2452
- logger6.warn({ taskId }, "Task not found when fetching artifacts");
2571
+ logger7.warn({ taskId }, "Task not found when fetching artifacts");
2453
2572
  continue;
2454
2573
  }
2455
2574
  const taskArtifacts = await getLedgerArtifacts(dbClient_default)({
@@ -2461,9 +2580,9 @@ var _ArtifactParser = class _ArtifactParser {
2461
2580
  artifacts.set(key, artifact);
2462
2581
  }
2463
2582
  }
2464
- logger6.debug({ contextId, count: artifacts.size }, "Loaded context artifacts");
2583
+ logger7.debug({ contextId, count: artifacts.size }, "Loaded context artifacts");
2465
2584
  } catch (error) {
2466
- logger6.error({ error, contextId }, "Error loading context artifacts");
2585
+ logger7.error({ error, contextId }, "Error loading context artifacts");
2467
2586
  }
2468
2587
  return artifacts;
2469
2588
  }
@@ -2566,7 +2685,7 @@ var _ArtifactParser = class _ArtifactParser {
2566
2685
  id: taskId
2567
2686
  });
2568
2687
  if (!task) {
2569
- logger6.warn({ taskId }, "Task not found when fetching artifact");
2688
+ logger7.warn({ taskId }, "Task not found when fetching artifact");
2570
2689
  return null;
2571
2690
  }
2572
2691
  const artifacts = await getLedgerArtifacts(dbClient_default)({
@@ -2578,7 +2697,7 @@ var _ArtifactParser = class _ArtifactParser {
2578
2697
  return this.formatArtifactData(artifacts[0], artifactId, taskId);
2579
2698
  }
2580
2699
  } catch (error) {
2581
- logger6.warn({ artifactId, taskId, error }, "Failed to fetch artifact");
2700
+ logger7.warn({ artifactId, taskId, error }, "Failed to fetch artifact");
2582
2701
  }
2583
2702
  return null;
2584
2703
  }
@@ -2614,11 +2733,11 @@ var _ArtifactParser = class _ArtifactParser {
2614
2733
  __publicField(_ArtifactParser, "ARTIFACT_REGEX", /<artifact:ref\s+id="([^"]*?)"\s+task="([^"]*?)"\s*\/>/gs);
2615
2734
  __publicField(_ArtifactParser, "ARTIFACT_CHECK_REGEX", /<artifact:ref\s+(?=.*id="[^"]+")(?=.*task="[^"]+")[^>]*\/>/);
2616
2735
  // Regex for catching any partial artifact pattern (< + any prefix of "artifact:ref")
2617
- __publicField(_ArtifactParser, "INCOMPLETE_ARTIFACT_REGEX", /<(a(r(t(i(f(a(c(t(:(r(e(f?)?)?)?)?)?)?)?)?)?)?)?)?$/g);
2736
+ __publicField(_ArtifactParser, "INCOMPLETE_ARTIFACT_REGEX", /<(a(r(t(i(f(a(c(t(:?(r(e(f)?)?)?)?)?)?)?)?)?)?)?)?$/g);
2618
2737
  var ArtifactParser = _ArtifactParser;
2619
2738
 
2620
2739
  // src/utils/incremental-stream-parser.ts
2621
- var logger7 = getLogger("IncrementalStreamParser");
2740
+ var logger8 = getLogger("IncrementalStreamParser");
2622
2741
  var IncrementalStreamParser = class {
2623
2742
  constructor(streamHelper, tenantId, contextId) {
2624
2743
  __publicField(this, "buffer", "");
@@ -2678,13 +2797,19 @@ var IncrementalStreamParser = class {
2678
2797
  if (part.type === "tool-call-delta" && part.toolName === targetToolName) {
2679
2798
  const delta = part.argsTextDelta || "";
2680
2799
  if (jsonBuffer.length + delta.length > MAX_BUFFER_SIZE) {
2681
- logger7.warn({ bufferSize: jsonBuffer.length + delta.length, maxSize: MAX_BUFFER_SIZE }, "JSON buffer exceeded maximum size, truncating");
2800
+ logger8.warn(
2801
+ { bufferSize: jsonBuffer.length + delta.length, maxSize: MAX_BUFFER_SIZE },
2802
+ "JSON buffer exceeded maximum size, truncating"
2803
+ );
2682
2804
  jsonBuffer = jsonBuffer.slice(-MAX_BUFFER_SIZE / 2);
2683
2805
  }
2684
2806
  jsonBuffer += delta;
2685
2807
  for (const char of delta) {
2686
2808
  if (componentBuffer.length > MAX_BUFFER_SIZE) {
2687
- logger7.warn({ bufferSize: componentBuffer.length, maxSize: MAX_BUFFER_SIZE }, "Component buffer exceeded maximum size, resetting");
2809
+ logger8.warn(
2810
+ { bufferSize: componentBuffer.length, maxSize: MAX_BUFFER_SIZE },
2811
+ "Component buffer exceeded maximum size, resetting"
2812
+ );
2688
2813
  componentBuffer = "";
2689
2814
  depth = 0;
2690
2815
  continue;
@@ -2699,7 +2824,7 @@ var IncrementalStreamParser = class {
2699
2824
  if (componentMatch) {
2700
2825
  const MAX_COMPONENT_SIZE = 1024 * 1024;
2701
2826
  if (componentMatch[0].length > MAX_COMPONENT_SIZE) {
2702
- logger7.warn(
2827
+ logger8.warn(
2703
2828
  {
2704
2829
  size: componentMatch[0].length,
2705
2830
  maxSize: MAX_COMPONENT_SIZE
@@ -2712,7 +2837,7 @@ var IncrementalStreamParser = class {
2712
2837
  try {
2713
2838
  const component = JSON.parse(componentMatch[0]);
2714
2839
  if (typeof component !== "object" || !component.id) {
2715
- logger7.warn({ component }, "Invalid component structure, skipping");
2840
+ logger8.warn({ component }, "Invalid component structure, skipping");
2716
2841
  componentBuffer = "";
2717
2842
  continue;
2718
2843
  }
@@ -2725,7 +2850,7 @@ var IncrementalStreamParser = class {
2725
2850
  componentsStreamed++;
2726
2851
  componentBuffer = "";
2727
2852
  } catch (e) {
2728
- logger7.debug({ error: e }, "Failed to parse component, continuing to accumulate");
2853
+ logger8.debug({ error: e }, "Failed to parse component, continuing to accumulate");
2729
2854
  }
2730
2855
  }
2731
2856
  }
@@ -2742,7 +2867,7 @@ var IncrementalStreamParser = class {
2742
2867
  break;
2743
2868
  }
2744
2869
  }
2745
- logger7.debug({ componentsStreamed }, "Finished streaming components");
2870
+ logger8.debug({ componentsStreamed }, "Finished streaming components");
2746
2871
  }
2747
2872
  /**
2748
2873
  * Legacy method for backward compatibility - defaults to text processing
@@ -2886,7 +3011,7 @@ var IncrementalStreamParser = class {
2886
3011
  };
2887
3012
 
2888
3013
  // src/utils/response-formatter.ts
2889
- var logger8 = getLogger("ResponseFormatter");
3014
+ var logger9 = getLogger("ResponseFormatter");
2890
3015
  var ResponseFormatter = class {
2891
3016
  constructor(tenantId) {
2892
3017
  __publicField(this, "artifactParser");
@@ -2917,7 +3042,7 @@ var ResponseFormatter = class {
2917
3042
  return { parts };
2918
3043
  } catch (error) {
2919
3044
  setSpanWithError(span, error);
2920
- logger8.error({ error, responseObject }, "Error formatting object response");
3045
+ logger9.error({ error, responseObject }, "Error formatting object response");
2921
3046
  return {
2922
3047
  parts: [{ kind: "data", data: responseObject }]
2923
3048
  };
@@ -2968,7 +3093,7 @@ var ResponseFormatter = class {
2968
3093
  return { parts };
2969
3094
  } catch (error) {
2970
3095
  setSpanWithError(span, error);
2971
- logger8.error({ error, responseText }, "Error formatting response");
3096
+ logger9.error({ error, responseText }, "Error formatting response");
2972
3097
  return { text: responseText };
2973
3098
  } finally {
2974
3099
  span.end();
@@ -3013,7 +3138,7 @@ var ResponseFormatter = class {
3013
3138
  }
3014
3139
  }
3015
3140
  };
3016
- var logger9 = getLogger("ToolSessionManager");
3141
+ var logger10 = getLogger("ToolSessionManager");
3017
3142
  var _ToolSessionManager = class _ToolSessionManager {
3018
3143
  // 5 minutes
3019
3144
  constructor() {
@@ -3042,7 +3167,7 @@ var _ToolSessionManager = class _ToolSessionManager {
3042
3167
  createdAt: Date.now()
3043
3168
  };
3044
3169
  this.sessions.set(sessionId, session);
3045
- logger9.debug({ sessionId, tenantId, contextId, taskId }, "Created tool session");
3170
+ logger10.debug({ sessionId, tenantId, contextId, taskId }, "Created tool session");
3046
3171
  return sessionId;
3047
3172
  }
3048
3173
  /**
@@ -3051,7 +3176,7 @@ var _ToolSessionManager = class _ToolSessionManager {
3051
3176
  recordToolResult(sessionId, toolResult) {
3052
3177
  const session = this.sessions.get(sessionId);
3053
3178
  if (!session) {
3054
- logger9.warn(
3179
+ logger10.warn(
3055
3180
  { sessionId, toolCallId: toolResult.toolCallId },
3056
3181
  "Tool result recorded for unknown session"
3057
3182
  );
@@ -3065,12 +3190,12 @@ var _ToolSessionManager = class _ToolSessionManager {
3065
3190
  getToolResult(sessionId, toolCallId) {
3066
3191
  const session = this.sessions.get(sessionId);
3067
3192
  if (!session) {
3068
- logger9.warn({ sessionId, toolCallId }, "Requested tool result for unknown session");
3193
+ logger10.warn({ sessionId, toolCallId }, "Requested tool result for unknown session");
3069
3194
  return void 0;
3070
3195
  }
3071
3196
  const result = session.toolResults.get(toolCallId);
3072
3197
  if (!result) {
3073
- logger9.warn(
3198
+ logger10.warn(
3074
3199
  {
3075
3200
  sessionId,
3076
3201
  toolCallId,
@@ -3109,10 +3234,10 @@ var _ToolSessionManager = class _ToolSessionManager {
3109
3234
  }
3110
3235
  for (const sessionId of expiredSessions) {
3111
3236
  this.sessions.delete(sessionId);
3112
- logger9.debug({ sessionId }, "Cleaned up expired tool session");
3237
+ logger10.debug({ sessionId }, "Cleaned up expired tool session");
3113
3238
  }
3114
3239
  if (expiredSessions.length > 0) {
3115
- logger9.info({ expiredCount: expiredSessions.length }, "Cleaned up expired tool sessions");
3240
+ logger10.info({ expiredCount: expiredSessions.length }, "Cleaned up expired tool sessions");
3116
3241
  }
3117
3242
  }
3118
3243
  };
@@ -3121,7 +3246,7 @@ var ToolSessionManager = _ToolSessionManager;
3121
3246
  var toolSessionManager = ToolSessionManager.getInstance();
3122
3247
 
3123
3248
  // src/agents/artifactTools.ts
3124
- var logger10 = getLogger("artifactTools");
3249
+ var logger11 = getLogger("artifactTools");
3125
3250
  function buildKeyNestingMap(data, prefix = "", map = /* @__PURE__ */ new Map()) {
3126
3251
  if (typeof data === "object" && data !== null) {
3127
3252
  if (Array.isArray(data)) {
@@ -3342,7 +3467,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
3342
3467
  execute: async ({ toolCallId, baseSelector, propSelectors, ...rest }, _context) => {
3343
3468
  const artifactType = "artifactType" in rest ? rest.artifactType : void 0;
3344
3469
  if (!sessionId) {
3345
- logger10.warn({ toolCallId }, "No session ID provided to save_tool_result");
3470
+ logger11.warn({ toolCallId }, "No session ID provided to save_tool_result");
3346
3471
  return {
3347
3472
  saved: false,
3348
3473
  error: `[toolCallId: ${toolCallId}] No session context available`,
@@ -3352,7 +3477,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
3352
3477
  }
3353
3478
  const toolResult = toolSessionManager.getToolResult(sessionId, toolCallId);
3354
3479
  if (!toolResult) {
3355
- logger10.warn({ toolCallId, sessionId }, "Tool result not found in session");
3480
+ logger11.warn({ toolCallId, sessionId }, "Tool result not found in session");
3356
3481
  return {
3357
3482
  saved: false,
3358
3483
  error: `[toolCallId: ${toolCallId}] Tool result not found`,
@@ -3365,7 +3490,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
3365
3490
  const baseData = jmespath.search(parsedResult, baseSelector);
3366
3491
  if (!baseData || Array.isArray(baseData) && baseData.length === 0) {
3367
3492
  const debugInfo = analyzeSelectorFailure(parsedResult, baseSelector);
3368
- logger10.warn(
3493
+ logger11.warn(
3369
3494
  {
3370
3495
  baseSelector,
3371
3496
  toolCallId,
@@ -3408,7 +3533,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
3408
3533
  const fallbackValue = item[propName];
3409
3534
  if (fallbackValue !== null && fallbackValue !== void 0) {
3410
3535
  extractedItem[propName] = fallbackValue;
3411
- logger10.info(
3536
+ logger11.info(
3412
3537
  { propName, propSelector, context },
3413
3538
  `PropSelector failed, used fallback direct property access`
3414
3539
  );
@@ -3420,7 +3545,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
3420
3545
  const fallbackValue = item[propName];
3421
3546
  if (fallbackValue !== null && fallbackValue !== void 0) {
3422
3547
  extractedItem[propName] = fallbackValue;
3423
- logger10.warn(
3548
+ logger11.warn(
3424
3549
  { propName, propSelector, context, error: error.message },
3425
3550
  `PropSelector syntax error, used fallback direct property access`
3426
3551
  );
@@ -3533,7 +3658,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
3533
3658
  warnings
3534
3659
  };
3535
3660
  } catch (error) {
3536
- logger10.error({ error, toolCallId, sessionId }, "Error processing save_tool_result");
3661
+ logger11.error({ error, toolCallId, sessionId }, "Error processing save_tool_result");
3537
3662
  return {
3538
3663
  saved: false,
3539
3664
  error: `[toolCallId: ${toolCallId}] ${error instanceof Error ? error.message : "Unknown error"}`,
@@ -3545,7 +3670,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
3545
3670
  }
3546
3671
 
3547
3672
  // src/a2a/client.ts
3548
- var logger11 = getLogger("a2aClient");
3673
+ var logger12 = getLogger("a2aClient");
3549
3674
  var DEFAULT_BACKOFF = {
3550
3675
  initialInterval: 500,
3551
3676
  maxInterval: 6e4,
@@ -3751,7 +3876,7 @@ var A2AClient = class {
3751
3876
  try {
3752
3877
  const res = await fn();
3753
3878
  if (attempt > 0) {
3754
- logger11.info(
3879
+ logger12.info(
3755
3880
  {
3756
3881
  attempts: attempt + 1,
3757
3882
  elapsedTime: Date.now() - start
@@ -3766,7 +3891,7 @@ var A2AClient = class {
3766
3891
  }
3767
3892
  const elapsed = Date.now() - start;
3768
3893
  if (elapsed > maxElapsedTime) {
3769
- logger11.warn(
3894
+ logger12.warn(
3770
3895
  {
3771
3896
  attempts: attempt + 1,
3772
3897
  elapsedTime: elapsed,
@@ -3787,7 +3912,7 @@ var A2AClient = class {
3787
3912
  retryInterval = initialInterval * attempt ** exponent + Math.random() * 1e3;
3788
3913
  }
3789
3914
  const delayMs = Math.min(retryInterval, maxInterval);
3790
- logger11.info(
3915
+ logger12.info(
3791
3916
  {
3792
3917
  attempt: attempt + 1,
3793
3918
  delayMs,
@@ -3872,7 +3997,7 @@ var A2AClient = class {
3872
3997
  }
3873
3998
  const rpcResponse = await httpResponse.json();
3874
3999
  if (rpcResponse.id !== requestId2) {
3875
- logger11.warn(
4000
+ logger12.warn(
3876
4001
  {
3877
4002
  method,
3878
4003
  expectedId: requestId2,
@@ -4071,7 +4196,7 @@ var A2AClient = class {
4071
4196
  try {
4072
4197
  while (true) {
4073
4198
  const { done, value } = await reader.read();
4074
- logger11.info({ done, value }, "parseA2ASseStream");
4199
+ logger12.info({ done, value }, "parseA2ASseStream");
4075
4200
  if (done) {
4076
4201
  if (eventDataBuffer.trim()) {
4077
4202
  const result = this._processSseEventData(
@@ -4158,7 +4283,7 @@ var A2AClient = class {
4158
4283
  };
4159
4284
 
4160
4285
  // src/agents/relationTools.ts
4161
- var logger12 = getLogger("relationships Tools");
4286
+ var logger13 = getLogger("relationships Tools");
4162
4287
  var generateTransferToolDescription = (config) => {
4163
4288
  return `Hand off the conversation to agent ${config.id}.
4164
4289
 
@@ -4196,7 +4321,7 @@ var createTransferToAgentTool = ({
4196
4321
  "transfer.to_agent_id": transferConfig.id ?? "unknown"
4197
4322
  });
4198
4323
  }
4199
- logger12.info(
4324
+ logger13.info(
4200
4325
  {
4201
4326
  transferTo: transferConfig.id ?? "unknown",
4202
4327
  fromAgent: callingAgentId
@@ -4344,7 +4469,7 @@ function createDelegateToAgentTool({
4344
4469
  ...isInternal ? { fromAgentId: callingAgentId } : { fromExternalAgentId: callingAgentId }
4345
4470
  }
4346
4471
  };
4347
- logger12.info({ messageToSend }, "messageToSend");
4472
+ logger13.info({ messageToSend }, "messageToSend");
4348
4473
  await createMessage(dbClient_default)({
4349
4474
  id: nanoid(),
4350
4475
  tenantId,
@@ -4406,7 +4531,7 @@ function createDelegateToAgentTool({
4406
4531
  }
4407
4532
 
4408
4533
  // src/agents/SystemPromptBuilder.ts
4409
- var logger13 = getLogger("SystemPromptBuilder");
4534
+ var logger14 = getLogger("SystemPromptBuilder");
4410
4535
  var SystemPromptBuilder = class {
4411
4536
  constructor(version, versionConfig) {
4412
4537
  this.version = version;
@@ -4422,9 +4547,12 @@ var SystemPromptBuilder = class {
4422
4547
  this.templates.set(name, content);
4423
4548
  }
4424
4549
  this.loaded = true;
4425
- logger13.debug({ templateCount: this.templates.size, version: this.version }, `Loaded ${this.templates.size} templates for version ${this.version}`);
4550
+ logger14.debug(
4551
+ { templateCount: this.templates.size, version: this.version },
4552
+ `Loaded ${this.templates.size} templates for version ${this.version}`
4553
+ );
4426
4554
  } catch (error) {
4427
- logger13.error({ error }, `Failed to load templates for version ${this.version}`);
4555
+ logger14.error({ error }, `Failed to load templates for version ${this.version}`);
4428
4556
  throw new Error(`Template loading failed: ${error}`);
4429
4557
  }
4430
4558
  }
@@ -4826,7 +4954,7 @@ function hasToolCallWithPrefix(prefix) {
4826
4954
  return false;
4827
4955
  };
4828
4956
  }
4829
- var logger14 = getLogger("Agent");
4957
+ var logger15 = getLogger("Agent");
4830
4958
  var CONSTANTS = {
4831
4959
  MAX_GENERATION_STEPS: 12,
4832
4960
  PHASE_1_TIMEOUT_MS: 27e4,
@@ -5079,14 +5207,14 @@ var Agent = class {
5079
5207
  for (const toolSet of tools) {
5080
5208
  for (const [toolName, originalTool] of Object.entries(toolSet)) {
5081
5209
  if (!isValidTool(originalTool)) {
5082
- logger14.error({ toolName }, "Invalid MCP tool structure - missing required properties");
5210
+ logger15.error({ toolName }, "Invalid MCP tool structure - missing required properties");
5083
5211
  continue;
5084
5212
  }
5085
5213
  const sessionWrappedTool = tool({
5086
5214
  description: originalTool.description,
5087
5215
  inputSchema: originalTool.inputSchema,
5088
5216
  execute: async (args, { toolCallId }) => {
5089
- logger14.debug({ toolName, toolCallId }, "MCP Tool Called");
5217
+ logger15.debug({ toolName, toolCallId }, "MCP Tool Called");
5090
5218
  try {
5091
5219
  const result = await originalTool.execute(args, { toolCallId });
5092
5220
  toolSessionManager.recordToolResult(sessionId, {
@@ -5098,7 +5226,7 @@ var Agent = class {
5098
5226
  });
5099
5227
  return { result, toolCallId };
5100
5228
  } catch (error) {
5101
- logger14.error({ toolName, toolCallId, error }, "MCP tool execution failed");
5229
+ logger15.error({ toolName, toolCallId, error }, "MCP tool execution failed");
5102
5230
  throw error;
5103
5231
  }
5104
5232
  }
@@ -5183,7 +5311,7 @@ var Agent = class {
5183
5311
  selectedTools
5184
5312
  };
5185
5313
  }
5186
- logger14.info(
5314
+ logger15.info(
5187
5315
  {
5188
5316
  toolName: tool4.name,
5189
5317
  credentialReferenceId,
@@ -5223,7 +5351,7 @@ var Agent = class {
5223
5351
  async getResolvedContext(conversationId, requestContext) {
5224
5352
  try {
5225
5353
  if (!this.config.contextConfigId) {
5226
- logger14.debug({ graphId: this.config.graphId }, "No context config found for graph");
5354
+ logger15.debug({ graphId: this.config.graphId }, "No context config found for graph");
5227
5355
  return null;
5228
5356
  }
5229
5357
  const contextConfig = await getContextConfigById(dbClient_default)({
@@ -5231,7 +5359,7 @@ var Agent = class {
5231
5359
  id: this.config.contextConfigId
5232
5360
  });
5233
5361
  if (!contextConfig) {
5234
- logger14.warn({ contextConfigId: this.config.contextConfigId }, "Context config not found");
5362
+ logger15.warn({ contextConfigId: this.config.contextConfigId }, "Context config not found");
5235
5363
  return null;
5236
5364
  }
5237
5365
  if (!this.contextResolver) {
@@ -5248,7 +5376,7 @@ var Agent = class {
5248
5376
  $now: (/* @__PURE__ */ new Date()).toISOString(),
5249
5377
  $env: process.env
5250
5378
  };
5251
- logger14.debug(
5379
+ logger15.debug(
5252
5380
  {
5253
5381
  conversationId,
5254
5382
  contextConfigId: contextConfig.id,
@@ -5262,7 +5390,7 @@ var Agent = class {
5262
5390
  );
5263
5391
  return contextWithBuiltins;
5264
5392
  } catch (error) {
5265
- logger14.error(
5393
+ logger15.error(
5266
5394
  {
5267
5395
  conversationId,
5268
5396
  error: error instanceof Error ? error.message : "Unknown error"
@@ -5286,7 +5414,7 @@ var Agent = class {
5286
5414
  });
5287
5415
  return graphDefinition?.graphPrompt || void 0;
5288
5416
  } catch (error) {
5289
- logger14.warn(
5417
+ logger15.warn(
5290
5418
  {
5291
5419
  graphId: this.config.graphId,
5292
5420
  error: error instanceof Error ? error.message : "Unknown error"
@@ -5313,7 +5441,7 @@ var Agent = class {
5313
5441
  }
5314
5442
  return !!(graphDefinition.artifactComponents && Object.keys(graphDefinition.artifactComponents).length > 0);
5315
5443
  } catch (error) {
5316
- logger14.warn(
5444
+ logger15.warn(
5317
5445
  {
5318
5446
  graphId: this.config.graphId,
5319
5447
  tenantId: this.config.tenantId,
@@ -5373,7 +5501,7 @@ Key requirements:
5373
5501
  preserveUnresolved: false
5374
5502
  });
5375
5503
  } catch (error) {
5376
- logger14.error(
5504
+ logger15.error(
5377
5505
  {
5378
5506
  conversationId,
5379
5507
  error: error instanceof Error ? error.message : "Unknown error"
@@ -5418,7 +5546,7 @@ Key requirements:
5418
5546
  preserveUnresolved: false
5419
5547
  });
5420
5548
  } catch (error) {
5421
- logger14.error(
5549
+ logger15.error(
5422
5550
  {
5423
5551
  conversationId,
5424
5552
  error: error instanceof Error ? error.message : "Unknown error"
@@ -5446,7 +5574,7 @@ Key requirements:
5446
5574
  artifactId: z.string().describe("The unique identifier of the artifact to get.")
5447
5575
  }),
5448
5576
  execute: async ({ artifactId }) => {
5449
- logger14.info({ artifactId }, "get_artifact executed");
5577
+ logger15.info({ artifactId }, "get_artifact executed");
5450
5578
  const artifact = await getLedgerArtifacts(dbClient_default)({
5451
5579
  scopes: {
5452
5580
  tenantId: this.config.tenantId,
@@ -5513,7 +5641,7 @@ Key requirements:
5513
5641
  graphId: this.config.graphId
5514
5642
  });
5515
5643
  } catch (error) {
5516
- logger14.error(
5644
+ logger15.error(
5517
5645
  { error, graphId: this.config.graphId },
5518
5646
  "Failed to check graph artifact components"
5519
5647
  );
@@ -5617,7 +5745,7 @@ Key requirements:
5617
5745
  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;
5618
5746
  const timeoutMs = Math.min(configuredTimeout, MAX_ALLOWED_TIMEOUT_MS);
5619
5747
  if (modelSettings.maxDuration && modelSettings.maxDuration * 1e3 > MAX_ALLOWED_TIMEOUT_MS) {
5620
- logger14.warn(
5748
+ logger15.warn(
5621
5749
  {
5622
5750
  requestedTimeout: modelSettings.maxDuration * 1e3,
5623
5751
  appliedTimeout: timeoutMs,
@@ -5659,7 +5787,7 @@ Key requirements:
5659
5787
  }
5660
5788
  );
5661
5789
  } catch (error) {
5662
- logger14.debug({ error }, "Failed to track agent reasoning");
5790
+ logger15.debug({ error }, "Failed to track agent reasoning");
5663
5791
  }
5664
5792
  }
5665
5793
  if (last && "toolCalls" in last && last.toolCalls) {
@@ -5742,7 +5870,7 @@ Key requirements:
5742
5870
  }
5743
5871
  );
5744
5872
  } catch (error) {
5745
- logger14.debug({ error }, "Failed to track agent reasoning");
5873
+ logger15.debug({ error }, "Failed to track agent reasoning");
5746
5874
  }
5747
5875
  }
5748
5876
  if (last && "toolCalls" in last && last.toolCalls) {
@@ -5787,7 +5915,7 @@ Key requirements:
5787
5915
  return;
5788
5916
  }
5789
5917
  if (toolName === "save_artifact_tool" || toolName === "save_tool_result") {
5790
- logger14.info({ result }, "save_artifact_tool or save_tool_result");
5918
+ logger15.info({ result }, "save_artifact_tool or save_tool_result");
5791
5919
  if (result.output.artifacts) {
5792
5920
  for (const artifact of result.output.artifacts) {
5793
5921
  const artifactId = artifact?.artifactId || "N/A";
@@ -5958,7 +6086,9 @@ async function resolveModelConfig(graphId, agent) {
5958
6086
  summarizer: agent.models?.summarizer || project.models.summarizer || project.models.base
5959
6087
  };
5960
6088
  }
5961
- throw new Error("Base model configuration is required. Please configure models at the project level.");
6089
+ throw new Error(
6090
+ "Base model configuration is required. Please configure models at the project level."
6091
+ );
5962
6092
  }
5963
6093
 
5964
6094
  // src/agents/generateTaskHandler.ts
@@ -5972,7 +6102,7 @@ function parseEmbeddedJson(data) {
5972
6102
  }
5973
6103
  });
5974
6104
  }
5975
- var logger15 = getLogger("generateTaskHandler");
6105
+ var logger16 = getLogger("generateTaskHandler");
5976
6106
  var createTaskHandler = (config, credentialStoreRegistry) => {
5977
6107
  return async (task) => {
5978
6108
  try {
@@ -6022,7 +6152,33 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
6022
6152
  agentId: config.agentId
6023
6153
  })
6024
6154
  ]);
6025
- logger15.info({ toolsForAgent, internalRelations, externalRelations }, "agent stuff");
6155
+ logger16.info({ toolsForAgent, internalRelations, externalRelations }, "agent stuff");
6156
+ const enhancedInternalRelations = await Promise.all(
6157
+ internalRelations.map(async (relation) => {
6158
+ try {
6159
+ const relatedAgent = await getAgentById(dbClient_default)({
6160
+ scopes: { tenantId: config.tenantId, projectId: config.projectId },
6161
+ agentId: relation.id
6162
+ });
6163
+ if (relatedAgent) {
6164
+ const relatedAgentRelations = await getRelatedAgentsForGraph(dbClient_default)({
6165
+ scopes: { tenantId: config.tenantId, projectId: config.projectId },
6166
+ graphId: config.graphId,
6167
+ agentId: relation.id
6168
+ });
6169
+ const enhancedDescription = generateDescriptionWithTransfers(
6170
+ relation.description || "",
6171
+ relatedAgentRelations.internalRelations,
6172
+ relatedAgentRelations.externalRelations
6173
+ );
6174
+ return { ...relation, description: enhancedDescription };
6175
+ }
6176
+ } catch (error) {
6177
+ logger16.warn({ agentId: relation.id, error }, "Failed to enhance agent description");
6178
+ }
6179
+ return relation;
6180
+ })
6181
+ );
6026
6182
  const agentPrompt = "prompt" in config.agentSchema ? config.agentSchema.prompt : "";
6027
6183
  const models = "models" in config.agentSchema ? config.agentSchema.models : void 0;
6028
6184
  const stopWhen = "stopWhen" in config.agentSchema ? config.agentSchema.stopWhen : void 0;
@@ -6039,7 +6195,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
6039
6195
  agentPrompt,
6040
6196
  models: models || void 0,
6041
6197
  stopWhen: stopWhen || void 0,
6042
- agentRelations: internalRelations.map((relation) => ({
6198
+ agentRelations: enhancedInternalRelations.map((relation) => ({
6043
6199
  id: relation.id,
6044
6200
  tenantId: config.tenantId,
6045
6201
  projectId: config.projectId,
@@ -6053,7 +6209,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
6053
6209
  agentRelations: [],
6054
6210
  transferRelations: []
6055
6211
  })),
6056
- transferRelations: internalRelations.filter((relation) => relation.relationType === "transfer").map((relation) => ({
6212
+ transferRelations: enhancedInternalRelations.filter((relation) => relation.relationType === "transfer").map((relation) => ({
6057
6213
  baseUrl: config.baseUrl,
6058
6214
  apiKey: config.apiKey,
6059
6215
  id: relation.id,
@@ -6069,7 +6225,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
6069
6225
  })),
6070
6226
  delegateRelations: [
6071
6227
  // Internal delegate relations
6072
- ...internalRelations.filter((relation) => relation.relationType === "delegate").map((relation) => ({
6228
+ ...enhancedInternalRelations.filter((relation) => relation.relationType === "delegate").map((relation) => ({
6073
6229
  type: "internal",
6074
6230
  config: {
6075
6231
  id: relation.id,
@@ -6122,7 +6278,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
6122
6278
  const taskIdMatch = task.id.match(/^task_([^-]+-[^-]+-\d+)-/);
6123
6279
  if (taskIdMatch) {
6124
6280
  contextId = taskIdMatch[1];
6125
- logger15.info(
6281
+ logger16.info(
6126
6282
  {
6127
6283
  taskId: task.id,
6128
6284
  extractedContextId: contextId,
@@ -6138,7 +6294,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
6138
6294
  const isDelegation = task.context?.metadata?.isDelegation === true;
6139
6295
  agent.setDelegationStatus(isDelegation);
6140
6296
  if (isDelegation) {
6141
- logger15.info(
6297
+ logger16.info(
6142
6298
  { agentId: config.agentId, taskId: task.id },
6143
6299
  "Delegated agent - streaming disabled"
6144
6300
  );
@@ -6343,84 +6499,10 @@ async function getRegisteredGraph(executionContext) {
6343
6499
  const agentFrameworkBaseUrl = `${baseUrl}/agents`;
6344
6500
  return hydrateGraph({ dbGraph, baseUrl: agentFrameworkBaseUrl, apiKey });
6345
6501
  }
6346
- getLogger("agents");
6347
- async function hydrateAgent({
6348
- dbAgent,
6349
- graphId,
6350
- baseUrl,
6351
- apiKey,
6352
- credentialStoreRegistry
6353
- }) {
6354
- try {
6355
- const taskHandlerConfig = await createTaskHandlerConfig({
6356
- tenantId: dbAgent.tenantId,
6357
- projectId: dbAgent.projectId,
6358
- graphId,
6359
- agentId: dbAgent.id,
6360
- baseUrl,
6361
- apiKey
6362
- });
6363
- const taskHandler = createTaskHandler(taskHandlerConfig, credentialStoreRegistry);
6364
- const agentCard = {
6365
- name: dbAgent.name,
6366
- description: dbAgent.description || "AI Agent",
6367
- url: baseUrl ? `${baseUrl}/a2a` : "",
6368
- version: "1.0.0",
6369
- capabilities: {
6370
- streaming: true,
6371
- // Enable streaming for A2A compliance
6372
- pushNotifications: false,
6373
- stateTransitionHistory: false
6374
- },
6375
- defaultInputModes: ["text", "text/plain"],
6376
- defaultOutputModes: ["text", "text/plain"],
6377
- skills: [],
6378
- // Add provider info if available
6379
- ...baseUrl && {
6380
- provider: {
6381
- organization: "Inkeep",
6382
- url: baseUrl
6383
- }
6384
- }
6385
- };
6386
- return {
6387
- agentId: dbAgent.id,
6388
- tenantId: dbAgent.tenantId,
6389
- projectId: dbAgent.projectId,
6390
- graphId,
6391
- agentCard,
6392
- taskHandler
6393
- };
6394
- } catch (error) {
6395
- console.error(`\u274C Failed to hydrate agent ${dbAgent.id}:`, error);
6396
- throw error;
6397
- }
6398
- }
6399
- async function getRegisteredAgent(executionContext, credentialStoreRegistry) {
6400
- const { tenantId, projectId, graphId, agentId, baseUrl, apiKey } = executionContext;
6401
- if (!agentId) {
6402
- throw new Error("Agent ID is required");
6403
- }
6404
- const dbAgent = await getAgentById(dbClient_default)({
6405
- scopes: { tenantId, projectId },
6406
- agentId
6407
- });
6408
- if (!dbAgent) {
6409
- return null;
6410
- }
6411
- const agentFrameworkBaseUrl = `${baseUrl}/agents`;
6412
- return hydrateAgent({
6413
- dbAgent,
6414
- graphId,
6415
- baseUrl: agentFrameworkBaseUrl,
6416
- credentialStoreRegistry,
6417
- apiKey
6418
- });
6419
- }
6420
6502
 
6421
6503
  // src/routes/agents.ts
6422
6504
  var app = new OpenAPIHono();
6423
- var logger16 = getLogger("agents");
6505
+ var logger17 = getLogger("agents");
6424
6506
  app.openapi(
6425
6507
  createRoute({
6426
6508
  method: "get",
@@ -6458,7 +6540,7 @@ app.openapi(
6458
6540
  tracestate: c.req.header("tracestate"),
6459
6541
  baggage: c.req.header("baggage")
6460
6542
  };
6461
- logger16.info(
6543
+ logger17.info(
6462
6544
  {
6463
6545
  otelHeaders,
6464
6546
  path: c.req.path,
@@ -6469,7 +6551,7 @@ app.openapi(
6469
6551
  const executionContext = getRequestExecutionContext(c);
6470
6552
  const { tenantId, projectId, graphId, agentId } = executionContext;
6471
6553
  if (agentId) {
6472
- logger16.info(
6554
+ logger17.info(
6473
6555
  {
6474
6556
  message: "getRegisteredAgent (agent-level)",
6475
6557
  tenantId,
@@ -6481,13 +6563,13 @@ app.openapi(
6481
6563
  );
6482
6564
  const credentialStores = c.get("credentialStores");
6483
6565
  const agent = await getRegisteredAgent(executionContext, credentialStores);
6484
- logger16.info({ agent }, "agent registered: well-known agent.json");
6566
+ logger17.info({ agent }, "agent registered: well-known agent.json");
6485
6567
  if (!agent) {
6486
6568
  return c.json({ error: "Agent not found" }, 404);
6487
6569
  }
6488
6570
  return c.json(agent.agentCard);
6489
6571
  } else {
6490
- logger16.info(
6572
+ logger17.info(
6491
6573
  {
6492
6574
  message: "getRegisteredGraph (graph-level)",
6493
6575
  tenantId,
@@ -6510,7 +6592,7 @@ app.post("/a2a", async (c) => {
6510
6592
  tracestate: c.req.header("tracestate"),
6511
6593
  baggage: c.req.header("baggage")
6512
6594
  };
6513
- logger16.info(
6595
+ logger17.info(
6514
6596
  {
6515
6597
  otelHeaders,
6516
6598
  path: c.req.path,
@@ -6521,7 +6603,7 @@ app.post("/a2a", async (c) => {
6521
6603
  const executionContext = getRequestExecutionContext(c);
6522
6604
  const { tenantId, projectId, graphId, agentId } = executionContext;
6523
6605
  if (agentId) {
6524
- logger16.info(
6606
+ logger17.info(
6525
6607
  {
6526
6608
  message: "a2a (agent-level)",
6527
6609
  tenantId,
@@ -6545,7 +6627,7 @@ app.post("/a2a", async (c) => {
6545
6627
  }
6546
6628
  return a2aHandler(c, agent);
6547
6629
  } else {
6548
- logger16.info(
6630
+ logger17.info(
6549
6631
  {
6550
6632
  message: "a2a (graph-level)",
6551
6633
  tenantId,
@@ -6585,14 +6667,14 @@ app.post("/a2a", async (c) => {
6585
6667
  }
6586
6668
  });
6587
6669
  var agents_default = app;
6588
- var logger17 = getLogger("Transfer");
6670
+ var logger18 = getLogger("Transfer");
6589
6671
  async function executeTransfer({
6590
6672
  tenantId,
6591
6673
  threadId,
6592
6674
  projectId,
6593
6675
  targetAgentId
6594
6676
  }) {
6595
- logger17.info({ targetAgent: targetAgentId }, "Executing transfer to agent");
6677
+ logger18.info({ targetAgent: targetAgentId }, "Executing transfer to agent");
6596
6678
  await setActiveAgentForThread(dbClient_default)({
6597
6679
  scopes: { tenantId, projectId },
6598
6680
  threadId,
@@ -6787,7 +6869,7 @@ var _VercelDataStreamHelper = class _VercelDataStreamHelper {
6787
6869
  __publicField(this, "queuedOperations", []);
6788
6870
  // Timing tracking for text sequences (text-end to text-start gap)
6789
6871
  __publicField(this, "lastTextEndTimestamp", 0);
6790
- __publicField(this, "TEXT_GAP_THRESHOLD", 1e3);
6872
+ __publicField(this, "TEXT_GAP_THRESHOLD", 50);
6791
6873
  // milliseconds - if gap between text sequences is less than this, queue operations
6792
6874
  // Connection management and forced cleanup
6793
6875
  __publicField(this, "connectionDropTimer");
@@ -7133,7 +7215,7 @@ var MCPStreamHelper = class {
7133
7215
  function createMCPStreamHelper() {
7134
7216
  return new MCPStreamHelper();
7135
7217
  }
7136
- var logger18 = getLogger("ExecutionHandler");
7218
+ var logger19 = getLogger("ExecutionHandler");
7137
7219
  var ExecutionHandler = class {
7138
7220
  constructor() {
7139
7221
  // Hardcoded error limit - separate from configurable stopWhen
@@ -7158,7 +7240,7 @@ var ExecutionHandler = class {
7158
7240
  const { tenantId, projectId, graphId, apiKey, baseUrl } = executionContext;
7159
7241
  registerStreamHelper(requestId2, sseHelper);
7160
7242
  graphSessionManager.createSession(requestId2, graphId, tenantId, projectId);
7161
- logger18.info({ sessionId: requestId2, graphId }, "Created GraphSession for message execution");
7243
+ logger19.info({ sessionId: requestId2, graphId }, "Created GraphSession for message execution");
7162
7244
  let graphConfig = null;
7163
7245
  try {
7164
7246
  graphConfig = await getFullGraph(dbClient_default)({ scopes: { tenantId, projectId }, graphId });
@@ -7170,7 +7252,7 @@ var ExecutionHandler = class {
7170
7252
  );
7171
7253
  }
7172
7254
  } catch (error) {
7173
- logger18.error(
7255
+ logger19.error(
7174
7256
  {
7175
7257
  error: error instanceof Error ? error.message : "Unknown error",
7176
7258
  stack: error instanceof Error ? error.stack : void 0
@@ -7186,7 +7268,7 @@ var ExecutionHandler = class {
7186
7268
  try {
7187
7269
  await sseHelper.writeOperation(agentInitializingOp(requestId2, graphId));
7188
7270
  const taskId = `task_${conversationId}-${requestId2}`;
7189
- logger18.info(
7271
+ logger19.info(
7190
7272
  { taskId, currentAgentId, conversationId, requestId: requestId2 },
7191
7273
  "Attempting to create or reuse existing task"
7192
7274
  );
@@ -7209,7 +7291,7 @@ var ExecutionHandler = class {
7209
7291
  agent_id: currentAgentId
7210
7292
  }
7211
7293
  });
7212
- logger18.info(
7294
+ logger19.info(
7213
7295
  {
7214
7296
  taskId,
7215
7297
  createdTaskMetadata: Array.isArray(task) ? task[0]?.metadata : task?.metadata
@@ -7218,27 +7300,27 @@ var ExecutionHandler = class {
7218
7300
  );
7219
7301
  } catch (error) {
7220
7302
  if (error?.message?.includes("UNIQUE constraint failed") || error?.message?.includes("PRIMARY KEY constraint failed") || error?.code === "SQLITE_CONSTRAINT_PRIMARYKEY") {
7221
- logger18.info(
7303
+ logger19.info(
7222
7304
  { taskId, error: error.message },
7223
7305
  "Task already exists, fetching existing task"
7224
7306
  );
7225
7307
  const existingTask = await getTask(dbClient_default)({ id: taskId });
7226
7308
  if (existingTask) {
7227
7309
  task = existingTask;
7228
- logger18.info(
7310
+ logger19.info(
7229
7311
  { taskId, existingTask },
7230
7312
  "Successfully reused existing task from race condition"
7231
7313
  );
7232
7314
  } else {
7233
- logger18.error({ taskId, error }, "Task constraint failed but task not found");
7315
+ logger19.error({ taskId, error }, "Task constraint failed but task not found");
7234
7316
  throw error;
7235
7317
  }
7236
7318
  } else {
7237
- logger18.error({ taskId, error }, "Failed to create task due to non-constraint error");
7319
+ logger19.error({ taskId, error }, "Failed to create task due to non-constraint error");
7238
7320
  throw error;
7239
7321
  }
7240
7322
  }
7241
- logger18.debug(
7323
+ logger19.debug(
7242
7324
  {
7243
7325
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
7244
7326
  executionType: "create_initial_task",
@@ -7256,7 +7338,7 @@ var ExecutionHandler = class {
7256
7338
  const maxTransfers = graphConfig?.stopWhen?.transferCountIs ?? 10;
7257
7339
  while (iterations < maxTransfers) {
7258
7340
  iterations++;
7259
- logger18.info(
7341
+ logger19.info(
7260
7342
  { iterations, currentAgentId, graphId, conversationId, fromAgentId },
7261
7343
  `Execution loop iteration ${iterations} with agent ${currentAgentId}, transfer from: ${fromAgentId || "none"}`
7262
7344
  );
@@ -7264,10 +7346,10 @@ var ExecutionHandler = class {
7264
7346
  scopes: { tenantId, projectId },
7265
7347
  conversationId
7266
7348
  });
7267
- logger18.info({ activeAgent }, "activeAgent");
7349
+ logger19.info({ activeAgent }, "activeAgent");
7268
7350
  if (activeAgent && activeAgent.activeAgentId !== currentAgentId) {
7269
7351
  currentAgentId = activeAgent.activeAgentId;
7270
- logger18.info({ currentAgentId }, `Updated current agent to: ${currentAgentId}`);
7352
+ logger19.info({ currentAgentId }, `Updated current agent to: ${currentAgentId}`);
7271
7353
  }
7272
7354
  const agentBaseUrl = `${baseUrl}/agents`;
7273
7355
  const a2aClient = new A2AClient(agentBaseUrl, {
@@ -7308,13 +7390,13 @@ var ExecutionHandler = class {
7308
7390
  });
7309
7391
  if (!messageResponse?.result) {
7310
7392
  errorCount++;
7311
- logger18.error(
7393
+ logger19.error(
7312
7394
  { currentAgentId, iterations, errorCount },
7313
7395
  `No response from agent ${currentAgentId} on iteration ${iterations} (error ${errorCount}/${this.MAX_ERRORS})`
7314
7396
  );
7315
7397
  if (errorCount >= this.MAX_ERRORS) {
7316
7398
  const errorMessage2 = `Maximum error limit (${this.MAX_ERRORS}) reached`;
7317
- logger18.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
7399
+ logger19.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
7318
7400
  await sseHelper.writeError(errorMessage2);
7319
7401
  await sseHelper.writeOperation(errorOp(errorMessage2, currentAgentId || "system"));
7320
7402
  if (task) {
@@ -7340,7 +7422,7 @@ var ExecutionHandler = class {
7340
7422
  const transferResponse = messageResponse.result;
7341
7423
  const targetAgentId = transferResponse.artifacts?.[0]?.parts?.[0]?.data?.targetAgentId;
7342
7424
  const transferReason = transferResponse.artifacts?.[0]?.parts?.[1]?.text;
7343
- logger18.info({ targetAgentId, transferReason }, "transfer response");
7425
+ logger19.info({ targetAgentId, transferReason }, "transfer response");
7344
7426
  currentMessage = `<transfer_context> ${transferReason} </transfer_context>`;
7345
7427
  const { success, targetAgentId: newAgentId } = await executeTransfer({
7346
7428
  projectId,
@@ -7351,7 +7433,7 @@ var ExecutionHandler = class {
7351
7433
  if (success) {
7352
7434
  fromAgentId = currentAgentId;
7353
7435
  currentAgentId = newAgentId;
7354
- logger18.info(
7436
+ logger19.info(
7355
7437
  {
7356
7438
  transferFrom: fromAgentId,
7357
7439
  transferTo: currentAgentId,
@@ -7369,7 +7451,7 @@ var ExecutionHandler = class {
7369
7451
  const graphSessionData = graphSessionManager.getSession(requestId2);
7370
7452
  if (graphSessionData) {
7371
7453
  const sessionSummary = graphSessionData.getSummary();
7372
- logger18.info(sessionSummary, "GraphSession data after completion");
7454
+ logger19.info(sessionSummary, "GraphSession data after completion");
7373
7455
  }
7374
7456
  let textContent = "";
7375
7457
  for (const part of responseParts) {
@@ -7423,22 +7505,22 @@ var ExecutionHandler = class {
7423
7505
  }
7424
7506
  });
7425
7507
  const updateTaskEnd = Date.now();
7426
- logger18.info(
7508
+ logger19.info(
7427
7509
  { duration: updateTaskEnd - updateTaskStart },
7428
7510
  "Completed updateTask operation"
7429
7511
  );
7430
7512
  await sseHelper.writeOperation(completionOp(currentAgentId, iterations));
7431
7513
  await sseHelper.complete();
7432
- logger18.info({}, "Ending GraphSession and cleaning up");
7514
+ logger19.info({}, "Ending GraphSession and cleaning up");
7433
7515
  graphSessionManager.endSession(requestId2);
7434
- logger18.info({}, "Cleaning up streamHelper");
7516
+ logger19.info({}, "Cleaning up streamHelper");
7435
7517
  unregisterStreamHelper(requestId2);
7436
7518
  let response;
7437
7519
  if (sseHelper instanceof MCPStreamHelper) {
7438
7520
  const captured = sseHelper.getCapturedResponse();
7439
7521
  response = captured.text || "No response content";
7440
7522
  }
7441
- logger18.info({}, "ExecutionHandler returning success");
7523
+ logger19.info({}, "ExecutionHandler returning success");
7442
7524
  return { success: true, iterations, response };
7443
7525
  } catch (error) {
7444
7526
  setSpanWithError(span, error);
@@ -7449,13 +7531,13 @@ var ExecutionHandler = class {
7449
7531
  });
7450
7532
  }
7451
7533
  errorCount++;
7452
- logger18.warn(
7534
+ logger19.warn(
7453
7535
  { iterations, errorCount },
7454
7536
  `No valid response or transfer on iteration ${iterations} (error ${errorCount}/${this.MAX_ERRORS})`
7455
7537
  );
7456
7538
  if (errorCount >= this.MAX_ERRORS) {
7457
7539
  const errorMessage2 = `Maximum error limit (${this.MAX_ERRORS}) reached`;
7458
- logger18.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
7540
+ logger19.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
7459
7541
  await sseHelper.writeError(errorMessage2);
7460
7542
  await sseHelper.writeOperation(errorOp(errorMessage2, currentAgentId || "system"));
7461
7543
  if (task) {
@@ -7477,7 +7559,7 @@ var ExecutionHandler = class {
7477
7559
  }
7478
7560
  }
7479
7561
  const errorMessage = `Maximum transfer limit (${maxTransfers}) reached without completion`;
7480
- logger18.error({ maxTransfers, iterations }, errorMessage);
7562
+ logger19.error({ maxTransfers, iterations }, errorMessage);
7481
7563
  await sseHelper.writeError(errorMessage);
7482
7564
  await sseHelper.writeOperation(errorOp(errorMessage, currentAgentId || "system"));
7483
7565
  if (task) {
@@ -7497,7 +7579,7 @@ var ExecutionHandler = class {
7497
7579
  unregisterStreamHelper(requestId2);
7498
7580
  return { success: false, error: errorMessage, iterations };
7499
7581
  } catch (error) {
7500
- logger18.error({ error }, "Error in execution handler");
7582
+ logger19.error({ error }, "Error in execution handler");
7501
7583
  const errorMessage = error instanceof Error ? error.message : "Unknown execution error";
7502
7584
  await sseHelper.writeError(`Execution error: ${errorMessage}`);
7503
7585
  await sseHelper.writeOperation(errorOp(errorMessage, currentAgentId || "system"));
@@ -7523,7 +7605,7 @@ var ExecutionHandler = class {
7523
7605
 
7524
7606
  // src/routes/chat.ts
7525
7607
  var app2 = new OpenAPIHono();
7526
- var logger19 = getLogger("completionsHandler");
7608
+ var logger20 = getLogger("completionsHandler");
7527
7609
  var chatCompletionsRoute = createRoute({
7528
7610
  method: "post",
7529
7611
  path: "/completions",
@@ -7641,7 +7723,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
7641
7723
  tracestate: c.req.header("tracestate"),
7642
7724
  baggage: c.req.header("baggage")
7643
7725
  };
7644
- logger19.info(
7726
+ logger20.info(
7645
7727
  {
7646
7728
  otelHeaders,
7647
7729
  path: c.req.path,
@@ -7727,7 +7809,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
7727
7809
  dbClient_default,
7728
7810
  credentialStores
7729
7811
  );
7730
- logger19.info(
7812
+ logger20.info(
7731
7813
  {
7732
7814
  tenantId,
7733
7815
  graphId,
@@ -7773,7 +7855,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
7773
7855
  return streamSSE(c, async (stream2) => {
7774
7856
  const sseHelper = createSSEStreamHelper(stream2, requestId2, timestamp);
7775
7857
  await sseHelper.writeRole();
7776
- logger19.info({ agentId }, "Starting execution");
7858
+ logger20.info({ agentId }, "Starting execution");
7777
7859
  const executionHandler = new ExecutionHandler();
7778
7860
  const result = await executionHandler.execute({
7779
7861
  executionContext,
@@ -7783,7 +7865,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
7783
7865
  requestId: requestId2,
7784
7866
  sseHelper
7785
7867
  });
7786
- logger19.info(
7868
+ logger20.info(
7787
7869
  { result },
7788
7870
  `Execution completed: ${result.success ? "success" : "failed"} after ${result.iterations} iterations`
7789
7871
  );
@@ -7816,7 +7898,7 @@ var getMessageText = (content) => {
7816
7898
  };
7817
7899
  var chat_default = app2;
7818
7900
  var app3 = new OpenAPIHono();
7819
- var logger20 = getLogger("chatDataStream");
7901
+ var logger21 = getLogger("chatDataStream");
7820
7902
  var chatDataStreamRoute = createRoute({
7821
7903
  method: "post",
7822
7904
  path: "/chat",
@@ -7921,7 +8003,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
7921
8003
  );
7922
8004
  const lastUserMessage = body.messages.filter((m) => m.role === "user").slice(-1)[0];
7923
8005
  const userText = typeof lastUserMessage?.content === "string" ? lastUserMessage.content : lastUserMessage?.parts?.map((p) => p.text).join("") || "";
7924
- logger20.info({ userText, lastUserMessage }, "userText");
8006
+ logger21.info({ userText, lastUserMessage }, "userText");
7925
8007
  const messageSpan = trace.getActiveSpan();
7926
8008
  if (messageSpan) {
7927
8009
  messageSpan.setAttributes({
@@ -7963,7 +8045,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
7963
8045
  await streamHelper.writeError("Unable to process request");
7964
8046
  }
7965
8047
  } catch (err) {
7966
- logger20.error({ err }, "Streaming error");
8048
+ logger21.error({ err }, "Streaming error");
7967
8049
  await streamHelper.writeError("Internal server error");
7968
8050
  } finally {
7969
8051
  if ("cleanup" in streamHelper && typeof streamHelper.cleanup === "function") {
@@ -7984,7 +8066,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
7984
8066
  )
7985
8067
  );
7986
8068
  } catch (error) {
7987
- logger20.error({ error }, "chatDataStream error");
8069
+ logger21.error({ error }, "chatDataStream error");
7988
8070
  return c.json({ error: "Failed to process chat completion" }, 500);
7989
8071
  }
7990
8072
  });
@@ -7992,7 +8074,7 @@ var chatDataStream_default = app3;
7992
8074
  function createMCPSchema(schema) {
7993
8075
  return schema;
7994
8076
  }
7995
- var logger21 = getLogger("mcp");
8077
+ var logger22 = getLogger("mcp");
7996
8078
  var _MockResponseSingleton = class _MockResponseSingleton {
7997
8079
  constructor() {
7998
8080
  __publicField(this, "mockRes");
@@ -8047,21 +8129,21 @@ var createSpoofInitMessage = (mcpProtocolVersion) => ({
8047
8129
  id: 0
8048
8130
  });
8049
8131
  var spoofTransportInitialization = async (transport, req, sessionId, mcpProtocolVersion) => {
8050
- logger21.info({ sessionId }, "Spoofing initialization message to set transport state");
8132
+ logger22.info({ sessionId }, "Spoofing initialization message to set transport state");
8051
8133
  const spoofInitMessage = createSpoofInitMessage(mcpProtocolVersion);
8052
8134
  const mockRes = MockResponseSingleton.getInstance().getMockResponse();
8053
8135
  try {
8054
8136
  await transport.handleRequest(req, mockRes, spoofInitMessage);
8055
- logger21.info({ sessionId }, "Successfully spoofed initialization");
8137
+ logger22.info({ sessionId }, "Successfully spoofed initialization");
8056
8138
  } catch (spoofError) {
8057
- logger21.warn({ sessionId, error: spoofError }, "Spoof initialization failed, continuing anyway");
8139
+ logger22.warn({ sessionId, error: spoofError }, "Spoof initialization failed, continuing anyway");
8058
8140
  }
8059
8141
  };
8060
8142
  var validateSession = async (req, res, body, tenantId, projectId, graphId) => {
8061
8143
  const sessionId = req.headers["mcp-session-id"];
8062
- logger21.info({ sessionId }, "Received MCP session ID");
8144
+ logger22.info({ sessionId }, "Received MCP session ID");
8063
8145
  if (!sessionId) {
8064
- logger21.info({ body }, "Missing session ID");
8146
+ logger22.info({ body }, "Missing session ID");
8065
8147
  res.writeHead(400).end(
8066
8148
  JSON.stringify({
8067
8149
  jsonrpc: "2.0",
@@ -8087,7 +8169,7 @@ var validateSession = async (req, res, body, tenantId, projectId, graphId) => {
8087
8169
  scopes: { tenantId, projectId },
8088
8170
  conversationId: sessionId
8089
8171
  });
8090
- logger21.info(
8172
+ logger22.info(
8091
8173
  {
8092
8174
  sessionId,
8093
8175
  conversationFound: !!conversation,
@@ -8098,7 +8180,7 @@ var validateSession = async (req, res, body, tenantId, projectId, graphId) => {
8098
8180
  "Conversation lookup result"
8099
8181
  );
8100
8182
  if (!conversation || conversation.metadata?.sessionData?.sessionType !== "mcp" || conversation.metadata?.sessionData?.graphId !== graphId) {
8101
- logger21.info(
8183
+ logger22.info(
8102
8184
  { sessionId, conversationId: conversation?.id },
8103
8185
  "MCP session not found or invalid"
8104
8186
  );
@@ -8159,7 +8241,7 @@ var executeAgentQuery = async (executionContext, conversationId, query, defaultA
8159
8241
  requestId: requestId2,
8160
8242
  sseHelper: mcpStreamHelper
8161
8243
  });
8162
- logger21.info(
8244
+ logger22.info(
8163
8245
  { result },
8164
8246
  `Execution completed: ${result.success ? "success" : "failed"} after ${result.iterations} iterations`
8165
8247
  );
@@ -8233,7 +8315,7 @@ var getServer = async (requestContext, executionContext, conversationId, credent
8233
8315
  dbClient_default,
8234
8316
  credentialStores
8235
8317
  );
8236
- logger21.info(
8318
+ logger22.info(
8237
8319
  {
8238
8320
  tenantId,
8239
8321
  graphId,
@@ -8294,7 +8376,7 @@ var validateRequestParameters = (c) => {
8294
8376
  };
8295
8377
  var handleInitializationRequest = async (body, executionContext, validatedContext, req, res, c, credentialStores) => {
8296
8378
  const { tenantId, projectId, graphId } = executionContext;
8297
- logger21.info({ body }, "Received initialization request");
8379
+ logger22.info({ body }, "Received initialization request");
8298
8380
  const sessionId = nanoid();
8299
8381
  const agentGraph = await getAgentGraphWithDefaultAgent(dbClient_default)({
8300
8382
  scopes: { tenantId, projectId },
@@ -8325,7 +8407,7 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
8325
8407
  }
8326
8408
  }
8327
8409
  });
8328
- logger21.info(
8410
+ logger22.info(
8329
8411
  { sessionId, conversationId: conversation.id },
8330
8412
  "Created MCP session as conversation"
8331
8413
  );
@@ -8334,9 +8416,9 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
8334
8416
  });
8335
8417
  const server = await getServer(validatedContext, executionContext, sessionId, credentialStores);
8336
8418
  await server.connect(transport);
8337
- logger21.info({ sessionId }, "Server connected for initialization");
8419
+ logger22.info({ sessionId }, "Server connected for initialization");
8338
8420
  res.setHeader("Mcp-Session-Id", sessionId);
8339
- logger21.info(
8421
+ logger22.info(
8340
8422
  {
8341
8423
  sessionId,
8342
8424
  bodyMethod: body?.method,
@@ -8345,7 +8427,7 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
8345
8427
  "About to handle initialization request"
8346
8428
  );
8347
8429
  await transport.handleRequest(req, res, body);
8348
- logger21.info({ sessionId }, "Successfully handled initialization request");
8430
+ logger22.info({ sessionId }, "Successfully handled initialization request");
8349
8431
  return toFetchResponse(res);
8350
8432
  };
8351
8433
  var handleExistingSessionRequest = async (body, executionContext, validatedContext, req, res, credentialStores) => {
@@ -8373,8 +8455,8 @@ var handleExistingSessionRequest = async (body, executionContext, validatedConte
8373
8455
  sessionId,
8374
8456
  conversation.metadata?.session_data?.mcpProtocolVersion
8375
8457
  );
8376
- logger21.info({ sessionId }, "Server connected and transport initialized");
8377
- logger21.info(
8458
+ logger22.info({ sessionId }, "Server connected and transport initialized");
8459
+ logger22.info(
8378
8460
  {
8379
8461
  sessionId,
8380
8462
  bodyKeys: Object.keys(body || {}),
@@ -8388,9 +8470,9 @@ var handleExistingSessionRequest = async (body, executionContext, validatedConte
8388
8470
  );
8389
8471
  try {
8390
8472
  await transport.handleRequest(req, res, body);
8391
- logger21.info({ sessionId }, "Successfully handled MCP request");
8473
+ logger22.info({ sessionId }, "Successfully handled MCP request");
8392
8474
  } catch (transportError) {
8393
- logger21.error(
8475
+ logger22.error(
8394
8476
  {
8395
8477
  sessionId,
8396
8478
  error: transportError,
@@ -8441,13 +8523,13 @@ app4.openapi(
8441
8523
  }
8442
8524
  const { executionContext } = paramValidation;
8443
8525
  const body = c.get("requestBody") || {};
8444
- logger21.info({ body, bodyKeys: Object.keys(body || {}) }, "Parsed request body");
8526
+ logger22.info({ body, bodyKeys: Object.keys(body || {}) }, "Parsed request body");
8445
8527
  const isInitRequest = body.method === "initialize";
8446
8528
  const { req, res } = toReqRes(c.req.raw);
8447
8529
  const validatedContext = c.get("validatedContext") || {};
8448
8530
  const credentialStores = c.get("credentialStores");
8449
- logger21.info({ validatedContext }, "Validated context");
8450
- logger21.info({ req }, "request");
8531
+ logger22.info({ validatedContext }, "Validated context");
8532
+ logger22.info({ req }, "request");
8451
8533
  if (isInitRequest) {
8452
8534
  return await handleInitializationRequest(
8453
8535
  body,
@@ -8469,7 +8551,7 @@ app4.openapi(
8469
8551
  );
8470
8552
  }
8471
8553
  } catch (e) {
8472
- logger21.error(
8554
+ logger22.error(
8473
8555
  {
8474
8556
  error: e instanceof Error ? e.message : e,
8475
8557
  stack: e instanceof Error ? e.stack : void 0
@@ -8481,7 +8563,7 @@ app4.openapi(
8481
8563
  }
8482
8564
  );
8483
8565
  app4.get("/", async (c) => {
8484
- logger21.info({}, "Received GET MCP request");
8566
+ logger22.info({}, "Received GET MCP request");
8485
8567
  return c.json(
8486
8568
  {
8487
8569
  jsonrpc: "2.0",
@@ -8495,7 +8577,7 @@ app4.get("/", async (c) => {
8495
8577
  );
8496
8578
  });
8497
8579
  app4.delete("/", async (c) => {
8498
- logger21.info({}, "Received DELETE MCP request");
8580
+ logger22.info({}, "Received DELETE MCP request");
8499
8581
  return c.json(
8500
8582
  {
8501
8583
  jsonrpc: "2.0",
@@ -8506,7 +8588,7 @@ app4.delete("/", async (c) => {
8506
8588
  );
8507
8589
  });
8508
8590
  var mcp_default = app4;
8509
- var logger22 = getLogger("agents-run-api");
8591
+ var logger23 = getLogger("agents-run-api");
8510
8592
  function createExecutionHono(serverConfig, credentialStores) {
8511
8593
  const app6 = new OpenAPIHono();
8512
8594
  app6.use("*", otel());
@@ -8522,7 +8604,7 @@ function createExecutionHono(serverConfig, credentialStores) {
8522
8604
  const body = await c.req.json();
8523
8605
  c.set("requestBody", body);
8524
8606
  } catch (error) {
8525
- logger22.debug({ error }, "Failed to parse JSON body, continuing without parsed body");
8607
+ logger23.debug({ error }, "Failed to parse JSON body, continuing without parsed body");
8526
8608
  }
8527
8609
  }
8528
8610
  return next();
@@ -8573,8 +8655,8 @@ function createExecutionHono(serverConfig, credentialStores) {
8573
8655
  if (!isExpectedError) {
8574
8656
  const errorMessage = err instanceof Error ? err.message : String(err);
8575
8657
  const errorStack = err instanceof Error ? err.stack : void 0;
8576
- if (logger22) {
8577
- logger22.error(
8658
+ if (logger23) {
8659
+ logger23.error(
8578
8660
  {
8579
8661
  error: err,
8580
8662
  message: errorMessage,
@@ -8586,8 +8668,8 @@ function createExecutionHono(serverConfig, credentialStores) {
8586
8668
  );
8587
8669
  }
8588
8670
  } else {
8589
- if (logger22) {
8590
- logger22.error(
8671
+ if (logger23) {
8672
+ logger23.error(
8591
8673
  {
8592
8674
  error: err,
8593
8675
  path: c.req.path,
@@ -8604,8 +8686,8 @@ function createExecutionHono(serverConfig, credentialStores) {
8604
8686
  const response = err.getResponse();
8605
8687
  return response;
8606
8688
  } catch (responseError) {
8607
- if (logger22) {
8608
- logger22.error({ error: responseError }, "Error while handling HTTPException response");
8689
+ if (logger23) {
8690
+ logger23.error({ error: responseError }, "Error while handling HTTPException response");
8609
8691
  }
8610
8692
  }
8611
8693
  }
@@ -8639,7 +8721,7 @@ function createExecutionHono(serverConfig, credentialStores) {
8639
8721
  app6.use("*", async (c, next) => {
8640
8722
  const executionContext = c.get("executionContext");
8641
8723
  if (!executionContext) {
8642
- logger22.debug({}, "Empty execution context");
8724
+ logger23.debug({}, "Empty execution context");
8643
8725
  return next();
8644
8726
  }
8645
8727
  const { tenantId, projectId, graphId } = executionContext;
@@ -8648,7 +8730,7 @@ function createExecutionHono(serverConfig, credentialStores) {
8648
8730
  if (requestBody) {
8649
8731
  conversationId = requestBody.conversationId;
8650
8732
  if (!conversationId) {
8651
- logger22.debug({ requestBody }, "No conversation ID found in request body");
8733
+ logger23.debug({ requestBody }, "No conversation ID found in request body");
8652
8734
  }
8653
8735
  }
8654
8736
  const entries = Object.fromEntries(
@@ -8663,7 +8745,7 @@ function createExecutionHono(serverConfig, credentialStores) {
8663
8745
  })
8664
8746
  );
8665
8747
  if (!Object.keys(entries).length) {
8666
- logger22.debug({}, "Empty entries for baggage");
8748
+ logger23.debug({}, "Empty entries for baggage");
8667
8749
  return next();
8668
8750
  }
8669
8751
  const bag = Object.entries(entries).reduce(