@inkeep/agents-run-api 0.14.2 → 0.14.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -343,8 +343,8 @@ async function getConversationScopedArtifacts(params) {
343
343
  });
344
344
  referenceArtifacts.push(...artifacts);
345
345
  }
346
- const logger25 = (await Promise.resolve().then(() => (init_logger(), logger_exports))).getLogger("conversations");
347
- logger25.debug(
346
+ const logger26 = (await Promise.resolve().then(() => (init_logger(), logger_exports))).getLogger("conversations");
347
+ logger26.debug(
348
348
  {
349
349
  conversationId,
350
350
  visibleMessages: visibleMessages.length,
@@ -356,8 +356,8 @@ async function getConversationScopedArtifacts(params) {
356
356
  );
357
357
  return referenceArtifacts;
358
358
  } catch (error) {
359
- const logger25 = (await Promise.resolve().then(() => (init_logger(), logger_exports))).getLogger("conversations");
360
- logger25.error(
359
+ const logger26 = (await Promise.resolve().then(() => (init_logger(), logger_exports))).getLogger("conversations");
360
+ logger26.error(
361
361
  {
362
362
  error: error instanceof Error ? error.message : "Unknown error",
363
363
  conversationId
@@ -395,10 +395,22 @@ var init_json_postprocessor = __esm({
395
395
 
396
396
  // src/index.ts
397
397
  init_env();
398
+
399
+ // src/instrumentation.ts
400
+ init_logger();
398
401
  var otlpExporter = new exporterTraceOtlpHttp.OTLPTraceExporter();
399
- var defaultBatchProcessor = new sdkTraceBase.BatchSpanProcessor(otlpExporter, {
400
- scheduledDelayMillis: 1e3
401
- });
402
+ var logger = agentsCore.getLogger("instrumentation");
403
+ function createSafeBatchProcessor() {
404
+ try {
405
+ return new sdkTraceBase.BatchSpanProcessor(otlpExporter, {
406
+ scheduledDelayMillis: 1e3
407
+ });
408
+ } catch (error) {
409
+ logger.warn({ error }, "Failed to create batch processor");
410
+ return new sdkTraceBase.NoopSpanProcessor();
411
+ }
412
+ }
413
+ var defaultBatchProcessor = createSafeBatchProcessor();
402
414
  var defaultResource = resources.resourceFromAttributes({
403
415
  [semanticConventions.ATTR_SERVICE_NAME]: "inkeep-agents-run-api"
404
416
  });
@@ -462,7 +474,7 @@ function createExecutionContext(params) {
462
474
  }
463
475
 
464
476
  // src/middleware/api-key-auth.ts
465
- var logger = agentsCore.getLogger("env-key-auth");
477
+ var logger2 = agentsCore.getLogger("env-key-auth");
466
478
  var apiKeyAuth = () => factory.createMiddleware(async (c, next) => {
467
479
  if (c.req.method === "OPTIONS") {
468
480
  await next();
@@ -480,7 +492,7 @@ var apiKeyAuth = () => factory.createMiddleware(async (c, next) => {
480
492
  try {
481
493
  executionContext = await extractContextFromApiKey(authHeader.substring(7), baseUrl);
482
494
  executionContext.agentId = agentId;
483
- logger.info({}, "Development/test environment - API key authenticated successfully");
495
+ logger2.info({}, "Development/test environment - API key authenticated successfully");
484
496
  } catch {
485
497
  executionContext = createExecutionContext({
486
498
  apiKey: "development",
@@ -491,7 +503,7 @@ var apiKeyAuth = () => factory.createMiddleware(async (c, next) => {
491
503
  baseUrl,
492
504
  agentId
493
505
  });
494
- logger.info(
506
+ logger2.info(
495
507
  {},
496
508
  "Development/test environment - fallback to default context due to invalid API key"
497
509
  );
@@ -506,7 +518,7 @@ var apiKeyAuth = () => factory.createMiddleware(async (c, next) => {
506
518
  baseUrl,
507
519
  agentId
508
520
  });
509
- logger.info(
521
+ logger2.info(
510
522
  {},
511
523
  "Development/test environment - no API key provided, using default context"
512
524
  );
@@ -538,14 +550,14 @@ var apiKeyAuth = () => factory.createMiddleware(async (c, next) => {
538
550
  agentId
539
551
  });
540
552
  c.set("executionContext", executionContext);
541
- logger.info({}, "Bypass secret authenticated successfully");
553
+ logger2.info({}, "Bypass secret authenticated successfully");
542
554
  await next();
543
555
  return;
544
556
  } else if (apiKey) {
545
557
  const executionContext = await extractContextFromApiKey(apiKey, baseUrl);
546
558
  executionContext.agentId = agentId;
547
559
  c.set("executionContext", executionContext);
548
- logger.info({}, "API key authenticated successfully");
560
+ logger2.info({}, "API key authenticated successfully");
549
561
  await next();
550
562
  return;
551
563
  } else {
@@ -563,7 +575,7 @@ var apiKeyAuth = () => factory.createMiddleware(async (c, next) => {
563
575
  const executionContext = await extractContextFromApiKey(apiKey, baseUrl);
564
576
  executionContext.agentId = agentId;
565
577
  c.set("executionContext", executionContext);
566
- logger.debug(
578
+ logger2.debug(
567
579
  {
568
580
  tenantId: executionContext.tenantId,
569
581
  projectId: executionContext.projectId,
@@ -577,7 +589,7 @@ var apiKeyAuth = () => factory.createMiddleware(async (c, next) => {
577
589
  if (error instanceof httpException.HTTPException) {
578
590
  throw error;
579
591
  }
580
- logger.error({ error }, "API key authentication error");
592
+ logger2.error({ error }, "API key authentication error");
581
593
  throw new httpException.HTTPException(500, {
582
594
  message: "Authentication failed"
583
595
  });
@@ -638,7 +650,7 @@ function setupOpenAPIRoutes(app6) {
638
650
  // src/a2a/handlers.ts
639
651
  init_dbClient();
640
652
  init_logger();
641
- var logger2 = agentsCore.getLogger("a2aHandler");
653
+ var logger3 = agentsCore.getLogger("a2aHandler");
642
654
  async function a2aHandler(c, agent) {
643
655
  try {
644
656
  const rpcRequest = c.get("requestBody");
@@ -740,7 +752,7 @@ async function handleMessageSend(c, agent, request) {
740
752
  messageId: task.id,
741
753
  kind: "message"
742
754
  });
743
- logger2.warn(
755
+ logger3.warn(
744
756
  {
745
757
  taskId: task.id,
746
758
  agentId: agent.agentId,
@@ -750,7 +762,7 @@ async function handleMessageSend(c, agent, request) {
750
762
  );
751
763
  }
752
764
  } catch (error) {
753
- logger2.error({ error, taskId: task.id }, "Failed to serialize message");
765
+ logger3.error({ error, taskId: task.id }, "Failed to serialize message");
754
766
  JSON.stringify({
755
767
  error: "Failed to serialize message",
756
768
  taskId: task.id,
@@ -758,7 +770,7 @@ async function handleMessageSend(c, agent, request) {
758
770
  parts: [{ text: "Error in delegation", kind: "text" }]
759
771
  });
760
772
  }
761
- logger2.info(
773
+ logger3.info(
762
774
  {
763
775
  originalContextId: params.message.contextId,
764
776
  taskContextId: task.context?.conversationId,
@@ -788,7 +800,7 @@ async function handleMessageSend(c, agent, request) {
788
800
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
789
801
  updatedAt: (/* @__PURE__ */ new Date()).toISOString()
790
802
  });
791
- logger2.info({ metadata: params.message.metadata }, "message metadata");
803
+ logger3.info({ metadata: params.message.metadata }, "message metadata");
792
804
  if (params.message.metadata?.fromAgentId || params.message.metadata?.fromExternalAgentId) {
793
805
  const messageText = params.message.parts.filter((part) => part.kind === "text" && "text" in part && part.text).map((part) => part.text).join(" ");
794
806
  try {
@@ -813,7 +825,7 @@ async function handleMessageSend(c, agent, request) {
813
825
  messageData.toAgentId = agent.agentId;
814
826
  }
815
827
  await agentsCore.createMessage(dbClient_default)(messageData);
816
- logger2.info(
828
+ logger3.info(
817
829
  {
818
830
  fromAgentId: params.message.metadata.fromAgentId,
819
831
  fromExternalAgentId: params.message.metadata.fromExternalAgentId,
@@ -825,7 +837,7 @@ async function handleMessageSend(c, agent, request) {
825
837
  "A2A message stored in database"
826
838
  );
827
839
  } catch (error) {
828
- logger2.error(
840
+ logger3.error(
829
841
  {
830
842
  error,
831
843
  fromAgentId: params.message.metadata.fromAgentId,
@@ -862,7 +874,7 @@ async function handleMessageSend(c, agent, request) {
862
874
  (part) => part.kind === "data" && part.data && typeof part.data === "object" && part.data.type === "transfer"
863
875
  );
864
876
  if (transferPart && transferPart.kind === "data" && transferPart.data) {
865
- logger2.info({ transferPart }, "transferPart");
877
+ logger3.info({ transferPart }, "transferPart");
866
878
  return c.json({
867
879
  jsonrpc: "2.0",
868
880
  result: {
@@ -1413,7 +1425,7 @@ init_logger();
1413
1425
 
1414
1426
  // src/agents/ModelFactory.ts
1415
1427
  init_logger();
1416
- var logger4 = agentsCore.getLogger("ModelFactory");
1428
+ var logger5 = agentsCore.getLogger("ModelFactory");
1417
1429
  var _ModelFactory = class _ModelFactory {
1418
1430
  /**
1419
1431
  * Create a provider instance with custom configuration
@@ -1475,7 +1487,7 @@ var _ModelFactory = class _ModelFactory {
1475
1487
  }
1476
1488
  const modelString = modelSettings.model.trim();
1477
1489
  const { provider, modelName } = _ModelFactory.parseModelString(modelString);
1478
- logger4.debug(
1490
+ logger5.debug(
1479
1491
  {
1480
1492
  provider,
1481
1493
  model: modelName,
@@ -1486,7 +1498,7 @@ var _ModelFactory = class _ModelFactory {
1486
1498
  );
1487
1499
  const providerConfig = _ModelFactory.extractProviderConfig(modelSettings.providerOptions);
1488
1500
  if (Object.keys(providerConfig).length > 0) {
1489
- logger4.info({ config: providerConfig }, `Applying custom ${provider} provider configuration`);
1501
+ logger5.info({ config: providerConfig }, `Applying custom ${provider} provider configuration`);
1490
1502
  const customProvider = _ModelFactory.createProvider(provider, providerConfig);
1491
1503
  return customProvider.languageModel(modelName);
1492
1504
  }
@@ -1605,7 +1617,7 @@ var ModelFactory = _ModelFactory;
1605
1617
 
1606
1618
  // src/agents/ToolSessionManager.ts
1607
1619
  init_logger();
1608
- var logger5 = agentsCore.getLogger("ToolSessionManager");
1620
+ var logger6 = agentsCore.getLogger("ToolSessionManager");
1609
1621
  var _ToolSessionManager = class _ToolSessionManager {
1610
1622
  // 5 minutes
1611
1623
  constructor() {
@@ -1640,7 +1652,7 @@ var _ToolSessionManager = class _ToolSessionManager {
1640
1652
  createdAt: Date.now()
1641
1653
  };
1642
1654
  this.sessions.set(sessionId, session);
1643
- logger5.debug(
1655
+ logger6.debug(
1644
1656
  {
1645
1657
  sessionId,
1646
1658
  tenantId,
@@ -1658,10 +1670,10 @@ var _ToolSessionManager = class _ToolSessionManager {
1658
1670
  */
1659
1671
  ensureGraphSession(sessionId, tenantId, projectId, contextId, taskId) {
1660
1672
  if (this.sessions.has(sessionId)) {
1661
- logger5.debug({ sessionId }, "Graph session already exists, reusing");
1673
+ logger6.debug({ sessionId }, "Graph session already exists, reusing");
1662
1674
  return sessionId;
1663
1675
  }
1664
- logger5.debug(
1676
+ logger6.debug(
1665
1677
  { sessionId, tenantId, contextId, taskId },
1666
1678
  "Creating new graph-scoped tool session"
1667
1679
  );
@@ -1673,7 +1685,7 @@ var _ToolSessionManager = class _ToolSessionManager {
1673
1685
  recordToolResult(sessionId, toolResult) {
1674
1686
  const session = this.sessions.get(sessionId);
1675
1687
  if (!session) {
1676
- logger5.warn(
1688
+ logger6.warn(
1677
1689
  {
1678
1690
  sessionId,
1679
1691
  toolCallId: toolResult.toolCallId,
@@ -1685,7 +1697,7 @@ var _ToolSessionManager = class _ToolSessionManager {
1685
1697
  return;
1686
1698
  }
1687
1699
  session.toolResults.set(toolResult.toolCallId, toolResult);
1688
- logger5.debug(
1700
+ logger6.debug(
1689
1701
  {
1690
1702
  sessionId,
1691
1703
  toolCallId: toolResult.toolCallId,
@@ -1700,7 +1712,7 @@ var _ToolSessionManager = class _ToolSessionManager {
1700
1712
  getToolResult(sessionId, toolCallId) {
1701
1713
  const session = this.sessions.get(sessionId);
1702
1714
  if (!session) {
1703
- logger5.warn(
1715
+ logger6.warn(
1704
1716
  {
1705
1717
  sessionId,
1706
1718
  toolCallId,
@@ -1713,7 +1725,7 @@ var _ToolSessionManager = class _ToolSessionManager {
1713
1725
  }
1714
1726
  const result = session.toolResults.get(toolCallId);
1715
1727
  if (!result) {
1716
- logger5.warn(
1728
+ logger6.warn(
1717
1729
  {
1718
1730
  sessionId,
1719
1731
  toolCallId,
@@ -1723,7 +1735,7 @@ var _ToolSessionManager = class _ToolSessionManager {
1723
1735
  "Tool result not found"
1724
1736
  );
1725
1737
  } else {
1726
- logger5.debug(
1738
+ logger6.debug(
1727
1739
  {
1728
1740
  sessionId,
1729
1741
  toolCallId,
@@ -1762,10 +1774,10 @@ var _ToolSessionManager = class _ToolSessionManager {
1762
1774
  }
1763
1775
  for (const sessionId of expiredSessions) {
1764
1776
  this.sessions.delete(sessionId);
1765
- logger5.debug({ sessionId }, "Cleaned up expired tool session");
1777
+ logger6.debug({ sessionId }, "Cleaned up expired tool session");
1766
1778
  }
1767
1779
  if (expiredSessions.length > 0) {
1768
- logger5.info({ expiredCount: expiredSessions.length }, "Cleaned up expired tool sessions");
1780
+ logger6.info({ expiredCount: expiredSessions.length }, "Cleaned up expired tool sessions");
1769
1781
  }
1770
1782
  }
1771
1783
  };
@@ -1809,7 +1821,7 @@ var tracer = agentsCore.getTracer("agents-run-api");
1809
1821
  init_logger();
1810
1822
  init_dbClient();
1811
1823
  init_logger();
1812
- var logger6 = agentsCore.getLogger("ArtifactService");
1824
+ var logger7 = agentsCore.getLogger("ArtifactService");
1813
1825
  var _ArtifactService = class _ArtifactService {
1814
1826
  constructor(context) {
1815
1827
  this.context = context;
@@ -1835,7 +1847,7 @@ var _ArtifactService = class _ArtifactService {
1835
1847
  id: taskId
1836
1848
  });
1837
1849
  if (!task) {
1838
- logger6.warn({ taskId }, "Task not found when fetching artifacts");
1850
+ logger7.warn({ taskId }, "Task not found when fetching artifacts");
1839
1851
  continue;
1840
1852
  }
1841
1853
  const taskArtifacts = await agentsCore.getLedgerArtifacts(dbClient_default)({
@@ -1853,7 +1865,7 @@ var _ArtifactService = class _ArtifactService {
1853
1865
  }
1854
1866
  }
1855
1867
  } catch (error) {
1856
- logger6.error({ error, contextId }, "Error loading context artifacts");
1868
+ logger7.error({ error, contextId }, "Error loading context artifacts");
1857
1869
  }
1858
1870
  return artifacts;
1859
1871
  }
@@ -1862,12 +1874,12 @@ var _ArtifactService = class _ArtifactService {
1862
1874
  */
1863
1875
  async createArtifact(request, agentId) {
1864
1876
  if (!this.context.sessionId) {
1865
- logger6.warn({ request }, "No session ID available for artifact creation");
1877
+ logger7.warn({ request }, "No session ID available for artifact creation");
1866
1878
  return null;
1867
1879
  }
1868
1880
  const toolResult = toolSessionManager.getToolResult(this.context.sessionId, request.toolCallId);
1869
1881
  if (!toolResult) {
1870
- logger6.warn(
1882
+ logger7.warn(
1871
1883
  { request, sessionId: this.context.sessionId },
1872
1884
  "Tool result not found for artifact"
1873
1885
  );
@@ -1883,7 +1895,7 @@ var _ArtifactService = class _ArtifactService {
1883
1895
  selectedData = selectedData.length > 0 ? selectedData[0] : {};
1884
1896
  }
1885
1897
  if (!selectedData) {
1886
- logger6.warn(
1898
+ logger7.warn(
1887
1899
  {
1888
1900
  request,
1889
1901
  baseSelector: request.baseSelector
@@ -1920,7 +1932,7 @@ var _ArtifactService = class _ArtifactService {
1920
1932
  );
1921
1933
  return artifactData;
1922
1934
  } catch (error) {
1923
- logger6.error({ error, request }, "Failed to create artifact");
1935
+ logger7.error({ error, request }, "Failed to create artifact");
1924
1936
  const errorMessage = error instanceof Error ? error.message : "Unknown error";
1925
1937
  throw new Error(`Artifact creation failed for ${request.artifactId}: ${errorMessage}`);
1926
1938
  }
@@ -1949,7 +1961,7 @@ var _ArtifactService = class _ArtifactService {
1949
1961
  }
1950
1962
  try {
1951
1963
  if (!this.context.projectId || !this.context.taskId) {
1952
- logger6.warn(
1964
+ logger7.warn(
1953
1965
  { artifactId, toolCallId },
1954
1966
  "No projectId or taskId available for artifact lookup"
1955
1967
  );
@@ -1964,7 +1976,7 @@ var _ArtifactService = class _ArtifactService {
1964
1976
  return this.formatArtifactData(artifacts[0], artifactId, toolCallId);
1965
1977
  }
1966
1978
  } catch (error) {
1967
- logger6.warn(
1979
+ logger7.warn(
1968
1980
  { artifactId, toolCallId, taskId: this.context.taskId, error },
1969
1981
  "Failed to fetch artifact"
1970
1982
  );
@@ -2017,7 +2029,7 @@ var _ArtifactService = class _ArtifactService {
2017
2029
  }
2018
2030
  );
2019
2031
  } else {
2020
- logger6.warn({
2032
+ logger7.warn({
2021
2033
  artifactId: request.artifactId,
2022
2034
  hasStreamRequestId: !!this.context.streamRequestId,
2023
2035
  hasAgentId: !!effectiveAgentId,
@@ -2102,7 +2114,7 @@ var _ArtifactService = class _ArtifactService {
2102
2114
  artifact: artifactToSave
2103
2115
  });
2104
2116
  if (!result.created && result.existing) {
2105
- logger6.debug(
2117
+ logger7.debug(
2106
2118
  {
2107
2119
  artifactId: artifact.artifactId,
2108
2120
  taskId: this.context.taskId
@@ -2155,7 +2167,7 @@ var _ArtifactService = class _ArtifactService {
2155
2167
  extracted[propName] = this.cleanEscapedContent(rawValue);
2156
2168
  }
2157
2169
  } catch (error) {
2158
- logger6.warn(
2170
+ logger7.warn(
2159
2171
  { propName, selector, error: error instanceof Error ? error.message : "Unknown error" },
2160
2172
  "Failed to extract property"
2161
2173
  );
@@ -2185,7 +2197,7 @@ __publicField(_ArtifactService, "selectorCache", /* @__PURE__ */ new Map());
2185
2197
  var ArtifactService = _ArtifactService;
2186
2198
 
2187
2199
  // src/services/ArtifactParser.ts
2188
- var logger7 = agentsCore.getLogger("ArtifactParser");
2200
+ var logger8 = agentsCore.getLogger("ArtifactParser");
2189
2201
  var _ArtifactParser = class _ArtifactParser {
2190
2202
  constructor(tenantId, options) {
2191
2203
  __publicField(this, "artifactService");
@@ -2269,7 +2281,7 @@ var _ArtifactParser = class _ArtifactParser {
2269
2281
  attrs[key] = value;
2270
2282
  }
2271
2283
  if (!attrs.id || !attrs.tool || !attrs.type || !attrs.base) {
2272
- logger7.warn({ attrs, attrString }, "Missing required attributes in artifact annotation");
2284
+ logger8.warn({ attrs, attrString }, "Missing required attributes in artifact annotation");
2273
2285
  return null;
2274
2286
  }
2275
2287
  return {
@@ -2330,7 +2342,7 @@ var _ArtifactParser = class _ArtifactParser {
2330
2342
  } else if (annotation.raw) {
2331
2343
  failedAnnotations.push(`Failed to create artifact "${annotation.artifactId}": Missing or invalid data`);
2332
2344
  processedText = processedText.replace(annotation.raw, "");
2333
- logger7.warn({ annotation, artifactData }, "Removed failed artifact:create annotation from output");
2345
+ logger8.warn({ annotation, artifactData }, "Removed failed artifact:create annotation from output");
2334
2346
  }
2335
2347
  } catch (error) {
2336
2348
  const errorMsg = error instanceof Error ? error.message : "Unknown error";
@@ -2338,11 +2350,11 @@ var _ArtifactParser = class _ArtifactParser {
2338
2350
  if (annotation.raw) {
2339
2351
  processedText = processedText.replace(annotation.raw, "");
2340
2352
  }
2341
- logger7.error({ annotation, error }, "Failed to extract artifact from create annotation");
2353
+ logger8.error({ annotation, error }, "Failed to extract artifact from create annotation");
2342
2354
  }
2343
2355
  }
2344
2356
  if (failedAnnotations.length > 0) {
2345
- logger7.warn({
2357
+ logger8.warn({
2346
2358
  failedCount: failedAnnotations.length,
2347
2359
  failures: failedAnnotations
2348
2360
  }, "Some artifact creation attempts failed");
@@ -2499,7 +2511,7 @@ __publicField(_ArtifactParser, "INCOMPLETE_CREATE_REGEX", /<artifact:create(?![^
2499
2511
  var ArtifactParser = _ArtifactParser;
2500
2512
 
2501
2513
  // src/services/GraphSession.ts
2502
- var logger8 = agentsCore.getLogger("GraphSession");
2514
+ var logger9 = agentsCore.getLogger("GraphSession");
2503
2515
  var GraphSession = class {
2504
2516
  // Session-scoped ArtifactParser instance
2505
2517
  constructor(sessionId, messageId, graphId, tenantId, projectId, contextId) {
@@ -2530,7 +2542,7 @@ var GraphSession = class {
2530
2542
  __publicField(this, "artifactService");
2531
2543
  // Session-scoped ArtifactService instance
2532
2544
  __publicField(this, "artifactParser");
2533
- logger8.debug({ sessionId, messageId, graphId }, "GraphSession created");
2545
+ logger9.debug({ sessionId, messageId, graphId }, "GraphSession created");
2534
2546
  if (tenantId && projectId) {
2535
2547
  toolSessionManager.createSessionWithId(
2536
2548
  sessionId,
@@ -2578,7 +2590,7 @@ var GraphSession = class {
2578
2590
  if (this.statusUpdateState.config.timeInSeconds) {
2579
2591
  this.statusUpdateTimer = setInterval(async () => {
2580
2592
  if (!this.statusUpdateState || this.isEnded) {
2581
- logger8.debug(
2593
+ logger9.debug(
2582
2594
  { sessionId: this.sessionId },
2583
2595
  "Timer triggered but session already cleaned up or ended"
2584
2596
  );
@@ -2590,7 +2602,7 @@ var GraphSession = class {
2590
2602
  }
2591
2603
  await this.checkAndSendTimeBasedUpdate();
2592
2604
  }, this.statusUpdateState.config.timeInSeconds * 1e3);
2593
- logger8.info(
2605
+ logger9.info(
2594
2606
  {
2595
2607
  sessionId: this.sessionId,
2596
2608
  intervalMs: this.statusUpdateState.config.timeInSeconds * 1e3
@@ -2604,7 +2616,7 @@ var GraphSession = class {
2604
2616
  */
2605
2617
  recordEvent(eventType, agentId, data) {
2606
2618
  if (this.isEnded) {
2607
- logger8.debug(
2619
+ logger9.debug(
2608
2620
  {
2609
2621
  sessionId: this.sessionId,
2610
2622
  eventType,
@@ -2624,7 +2636,7 @@ var GraphSession = class {
2624
2636
  if (eventType === "artifact_saved" && data.pendingGeneration) {
2625
2637
  const artifactId = data.artifactId;
2626
2638
  if (this.pendingArtifacts.size >= this.MAX_PENDING_ARTIFACTS) {
2627
- logger8.warn(
2639
+ logger9.warn(
2628
2640
  {
2629
2641
  sessionId: this.sessionId,
2630
2642
  artifactId,
@@ -2646,7 +2658,7 @@ var GraphSession = class {
2646
2658
  this.artifactProcessingErrors.set(artifactId, errorCount);
2647
2659
  if (errorCount >= this.MAX_ARTIFACT_RETRIES) {
2648
2660
  this.pendingArtifacts.delete(artifactId);
2649
- logger8.error(
2661
+ logger9.error(
2650
2662
  {
2651
2663
  sessionId: this.sessionId,
2652
2664
  artifactId,
@@ -2658,7 +2670,7 @@ var GraphSession = class {
2658
2670
  "Artifact processing failed after max retries, giving up"
2659
2671
  );
2660
2672
  } else {
2661
- logger8.warn(
2673
+ logger9.warn(
2662
2674
  {
2663
2675
  sessionId: this.sessionId,
2664
2676
  artifactId,
@@ -2680,14 +2692,14 @@ var GraphSession = class {
2680
2692
  */
2681
2693
  checkStatusUpdates() {
2682
2694
  if (this.isEnded) {
2683
- logger8.debug(
2695
+ logger9.debug(
2684
2696
  { sessionId: this.sessionId },
2685
2697
  "Session has ended - skipping status update check"
2686
2698
  );
2687
2699
  return;
2688
2700
  }
2689
2701
  if (!this.statusUpdateState) {
2690
- logger8.debug({ sessionId: this.sessionId }, "No status update state - skipping check");
2702
+ logger9.debug({ sessionId: this.sessionId }, "No status update state - skipping check");
2691
2703
  return;
2692
2704
  }
2693
2705
  const statusUpdateState = this.statusUpdateState;
@@ -2698,11 +2710,11 @@ var GraphSession = class {
2698
2710
  */
2699
2711
  async checkAndSendTimeBasedUpdate() {
2700
2712
  if (this.isEnded) {
2701
- logger8.debug({ sessionId: this.sessionId }, "Session has ended - skipping time-based update");
2713
+ logger9.debug({ sessionId: this.sessionId }, "Session has ended - skipping time-based update");
2702
2714
  return;
2703
2715
  }
2704
2716
  if (!this.statusUpdateState) {
2705
- logger8.debug(
2717
+ logger9.debug(
2706
2718
  { sessionId: this.sessionId },
2707
2719
  "No status updates configured for time-based check"
2708
2720
  );
@@ -2715,7 +2727,7 @@ var GraphSession = class {
2715
2727
  try {
2716
2728
  await this.generateAndSendUpdate();
2717
2729
  } catch (error) {
2718
- logger8.error(
2730
+ logger9.error(
2719
2731
  {
2720
2732
  sessionId: this.sessionId,
2721
2733
  error: error instanceof Error ? error.message : "Unknown error"
@@ -2818,29 +2830,29 @@ var GraphSession = class {
2818
2830
  */
2819
2831
  async generateAndSendUpdate() {
2820
2832
  if (this.isEnded) {
2821
- logger8.debug({ sessionId: this.sessionId }, "Session has ended - not generating update");
2833
+ logger9.debug({ sessionId: this.sessionId }, "Session has ended - not generating update");
2822
2834
  return;
2823
2835
  }
2824
2836
  if (this.isTextStreaming) {
2825
- logger8.debug(
2837
+ logger9.debug(
2826
2838
  { sessionId: this.sessionId },
2827
2839
  "Text is currently streaming - skipping status update"
2828
2840
  );
2829
2841
  return;
2830
2842
  }
2831
2843
  if (this.isGeneratingUpdate) {
2832
- logger8.debug(
2844
+ logger9.debug(
2833
2845
  { sessionId: this.sessionId },
2834
2846
  "Update already in progress - skipping duplicate generation"
2835
2847
  );
2836
2848
  return;
2837
2849
  }
2838
2850
  if (!this.statusUpdateState) {
2839
- logger8.warn({ sessionId: this.sessionId }, "No status update state - cannot generate update");
2851
+ logger9.warn({ sessionId: this.sessionId }, "No status update state - cannot generate update");
2840
2852
  return;
2841
2853
  }
2842
2854
  if (!this.graphId) {
2843
- logger8.warn({ sessionId: this.sessionId }, "No graph ID - cannot generate update");
2855
+ logger9.warn({ sessionId: this.sessionId }, "No graph ID - cannot generate update");
2844
2856
  return;
2845
2857
  }
2846
2858
  const newEventCount = this.events.length - this.statusUpdateState.lastEventCount;
@@ -2852,7 +2864,7 @@ var GraphSession = class {
2852
2864
  try {
2853
2865
  const streamHelper = getStreamHelper(this.sessionId);
2854
2866
  if (!streamHelper) {
2855
- logger8.warn(
2867
+ logger9.warn(
2856
2868
  { sessionId: this.sessionId },
2857
2869
  "No stream helper found - cannot send status update"
2858
2870
  );
@@ -2872,7 +2884,7 @@ var GraphSession = class {
2872
2884
  if (result.summaries && result.summaries.length > 0) {
2873
2885
  for (const summary of result.summaries) {
2874
2886
  if (!summary || !summary.type || !summary.data || !summary.data.label || Object.keys(summary.data).length === 0) {
2875
- logger8.warn(
2887
+ logger9.warn(
2876
2888
  {
2877
2889
  sessionId: this.sessionId,
2878
2890
  summary
@@ -2909,7 +2921,7 @@ var GraphSession = class {
2909
2921
  this.statusUpdateState.lastEventCount = this.events.length;
2910
2922
  }
2911
2923
  } catch (error) {
2912
- logger8.error(
2924
+ logger9.error(
2913
2925
  {
2914
2926
  sessionId: this.sessionId,
2915
2927
  error: error instanceof Error ? error.message : "Unknown error",
@@ -2947,7 +2959,7 @@ var GraphSession = class {
2947
2959
  this.releaseUpdateLock();
2948
2960
  }
2949
2961
  } catch (error) {
2950
- logger8.error(
2962
+ logger9.error(
2951
2963
  {
2952
2964
  sessionId: this.sessionId,
2953
2965
  error: error instanceof Error ? error.message : "Unknown error"
@@ -3025,7 +3037,7 @@ User's Question/Context:
3025
3037
  ${conversationHistory}
3026
3038
  ` : "";
3027
3039
  } catch (error) {
3028
- logger8.warn(
3040
+ logger9.warn(
3029
3041
  { sessionId: this.sessionId, error },
3030
3042
  "Failed to fetch conversation history for structured status update"
3031
3043
  );
@@ -3159,7 +3171,7 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
3159
3171
  return { summaries };
3160
3172
  } catch (error) {
3161
3173
  agentsCore.setSpanWithError(span, error);
3162
- logger8.error({ error }, "Failed to generate structured update, using fallback");
3174
+ logger9.error({ error }, "Failed to generate structured update, using fallback");
3163
3175
  return { summaries: [] };
3164
3176
  } finally {
3165
3177
  span.end();
@@ -3374,7 +3386,7 @@ Make it specific and relevant.`;
3374
3386
  });
3375
3387
  if (agentData && "models" in agentData && agentData.models?.base?.model) {
3376
3388
  modelToUse = agentData.models.base;
3377
- logger8.info(
3389
+ logger9.info(
3378
3390
  {
3379
3391
  sessionId: this.sessionId,
3380
3392
  artifactId: artifactData.artifactId,
@@ -3385,7 +3397,7 @@ Make it specific and relevant.`;
3385
3397
  );
3386
3398
  }
3387
3399
  } catch (error) {
3388
- logger8.warn(
3400
+ logger9.warn(
3389
3401
  {
3390
3402
  sessionId: this.sessionId,
3391
3403
  artifactId: artifactData.artifactId,
@@ -3397,7 +3409,7 @@ Make it specific and relevant.`;
3397
3409
  }
3398
3410
  }
3399
3411
  if (!modelToUse?.model?.trim()) {
3400
- logger8.warn(
3412
+ logger9.warn(
3401
3413
  {
3402
3414
  sessionId: this.sessionId,
3403
3415
  artifactId: artifactData.artifactId
@@ -3471,7 +3483,7 @@ Make it specific and relevant.`;
3471
3483
  return result2;
3472
3484
  } catch (error) {
3473
3485
  lastError = error instanceof Error ? error : new Error(String(error));
3474
- logger8.warn(
3486
+ logger9.warn(
3475
3487
  {
3476
3488
  sessionId: this.sessionId,
3477
3489
  artifactId: artifactData.artifactId,
@@ -3520,7 +3532,7 @@ Make it specific and relevant.`;
3520
3532
  });
3521
3533
  span.setStatus({ code: api.SpanStatusCode.OK });
3522
3534
  } catch (saveError) {
3523
- logger8.error(
3535
+ logger9.error(
3524
3536
  {
3525
3537
  sessionId: this.sessionId,
3526
3538
  artifactId: artifactData.artifactId,
@@ -3548,7 +3560,7 @@ Make it specific and relevant.`;
3548
3560
  fullProps: artifactData.fullProps || {},
3549
3561
  metadata: artifactData.metadata || {}
3550
3562
  });
3551
- logger8.info(
3563
+ logger9.info(
3552
3564
  {
3553
3565
  sessionId: this.sessionId,
3554
3566
  artifactId: artifactData.artifactId
@@ -3559,7 +3571,7 @@ Make it specific and relevant.`;
3559
3571
  } catch (fallbackError) {
3560
3572
  const isDuplicateError = fallbackError instanceof Error && (fallbackError.message?.includes("UNIQUE") || fallbackError.message?.includes("duplicate"));
3561
3573
  if (isDuplicateError) ; else {
3562
- logger8.error(
3574
+ logger9.error(
3563
3575
  {
3564
3576
  sessionId: this.sessionId,
3565
3577
  artifactId: artifactData.artifactId,
@@ -3572,7 +3584,7 @@ Make it specific and relevant.`;
3572
3584
  }
3573
3585
  } catch (error) {
3574
3586
  agentsCore.setSpanWithError(span, error);
3575
- logger8.error(
3587
+ logger9.error(
3576
3588
  {
3577
3589
  sessionId: this.sessionId,
3578
3590
  artifactId: artifactData.artifactId,
@@ -3592,7 +3604,7 @@ Make it specific and relevant.`;
3592
3604
  */
3593
3605
  setArtifactCache(key, artifact) {
3594
3606
  this.artifactCache.set(key, artifact);
3595
- logger8.debug({ sessionId: this.sessionId, key }, "Artifact cached in session");
3607
+ logger9.debug({ sessionId: this.sessionId, key }, "Artifact cached in session");
3596
3608
  }
3597
3609
  /**
3598
3610
  * Get session-scoped ArtifactService instance
@@ -3611,7 +3623,7 @@ Make it specific and relevant.`;
3611
3623
  */
3612
3624
  getArtifactCache(key) {
3613
3625
  const artifact = this.artifactCache.get(key);
3614
- logger8.debug({ sessionId: this.sessionId, key, found: !!artifact }, "Artifact cache lookup");
3626
+ logger9.debug({ sessionId: this.sessionId, key, found: !!artifact }, "Artifact cache lookup");
3615
3627
  return artifact || null;
3616
3628
  }
3617
3629
  };
@@ -3626,7 +3638,7 @@ var GraphSessionManager = class {
3626
3638
  const sessionId = messageId;
3627
3639
  const session = new GraphSession(sessionId, messageId, graphId, tenantId, projectId, contextId);
3628
3640
  this.sessions.set(sessionId, session);
3629
- logger8.info(
3641
+ logger9.info(
3630
3642
  { sessionId, messageId, graphId, tenantId, projectId, contextId },
3631
3643
  "GraphSession created"
3632
3644
  );
@@ -3640,7 +3652,7 @@ var GraphSessionManager = class {
3640
3652
  if (session) {
3641
3653
  session.initializeStatusUpdates(config, summarizerModel);
3642
3654
  } else {
3643
- logger8.error(
3655
+ logger9.error(
3644
3656
  {
3645
3657
  sessionId,
3646
3658
  availableSessions: Array.from(this.sessions.keys())
@@ -3661,7 +3673,7 @@ var GraphSessionManager = class {
3661
3673
  recordEvent(sessionId, eventType, agentId, data) {
3662
3674
  const session = this.sessions.get(sessionId);
3663
3675
  if (!session) {
3664
- logger8.warn({ sessionId }, "Attempted to record event in non-existent session");
3676
+ logger9.warn({ sessionId }, "Attempted to record event in non-existent session");
3665
3677
  return;
3666
3678
  }
3667
3679
  session.recordEvent(eventType, agentId, data);
@@ -3672,12 +3684,12 @@ var GraphSessionManager = class {
3672
3684
  endSession(sessionId) {
3673
3685
  const session = this.sessions.get(sessionId);
3674
3686
  if (!session) {
3675
- logger8.warn({ sessionId }, "Attempted to end non-existent session");
3687
+ logger9.warn({ sessionId }, "Attempted to end non-existent session");
3676
3688
  return [];
3677
3689
  }
3678
3690
  const events = session.getEvents();
3679
3691
  const summary = session.getSummary();
3680
- logger8.info({ sessionId, summary }, "GraphSession ended");
3692
+ logger9.info({ sessionId, summary }, "GraphSession ended");
3681
3693
  session.cleanup();
3682
3694
  this.sessions.delete(sessionId);
3683
3695
  return events;
@@ -3736,7 +3748,7 @@ var graphSessionManager = new GraphSessionManager();
3736
3748
 
3737
3749
  // src/services/IncrementalStreamParser.ts
3738
3750
  init_logger();
3739
- var logger9 = agentsCore.getLogger("IncrementalStreamParser");
3751
+ var logger10 = agentsCore.getLogger("IncrementalStreamParser");
3740
3752
  var _IncrementalStreamParser = class _IncrementalStreamParser {
3741
3753
  // Max number of collected parts to prevent unbounded growth
3742
3754
  constructor(streamHelper, tenantId, contextId, artifactParserOptions) {
@@ -3777,7 +3789,7 @@ var _IncrementalStreamParser = class _IncrementalStreamParser {
3777
3789
  async initializeArtifactMap() {
3778
3790
  try {
3779
3791
  this.artifactMap = await this.artifactParser.getContextArtifacts(this.contextId);
3780
- logger9.debug(
3792
+ logger10.debug(
3781
3793
  {
3782
3794
  contextId: this.contextId,
3783
3795
  artifactMapSize: this.artifactMap.size
@@ -3785,7 +3797,7 @@ var _IncrementalStreamParser = class _IncrementalStreamParser {
3785
3797
  "Initialized artifact map for streaming"
3786
3798
  );
3787
3799
  } catch (error) {
3788
- logger9.warn({ error, contextId: this.contextId }, "Failed to initialize artifact map");
3800
+ logger10.warn({ error, contextId: this.contextId }, "Failed to initialize artifact map");
3789
3801
  this.artifactMap = /* @__PURE__ */ new Map();
3790
3802
  }
3791
3803
  }
@@ -4094,7 +4106,7 @@ var IncrementalStreamParser = _IncrementalStreamParser;
4094
4106
 
4095
4107
  // src/services/ResponseFormatter.ts
4096
4108
  init_logger();
4097
- var logger10 = agentsCore.getLogger("ResponseFormatter");
4109
+ var logger11 = agentsCore.getLogger("ResponseFormatter");
4098
4110
  var ResponseFormatter = class {
4099
4111
  constructor(tenantId, artifactParserOptions) {
4100
4112
  __publicField(this, "artifactParser");
@@ -4134,7 +4146,7 @@ var ResponseFormatter = class {
4134
4146
  return { parts };
4135
4147
  } catch (error) {
4136
4148
  agentsCore.setSpanWithError(span, error);
4137
- logger10.error({ error, responseObject }, "Error formatting object response");
4149
+ logger11.error({ error, responseObject }, "Error formatting object response");
4138
4150
  return {
4139
4151
  parts: [{ kind: "data", data: responseObject }]
4140
4152
  };
@@ -4187,7 +4199,7 @@ var ResponseFormatter = class {
4187
4199
  return { parts };
4188
4200
  } catch (error) {
4189
4201
  agentsCore.setSpanWithError(span, error);
4190
- logger10.error({ error, responseText }, "Error formatting response");
4202
+ logger11.error({ error, responseText }, "Error formatting response");
4191
4203
  return { text: responseText };
4192
4204
  } finally {
4193
4205
  span.end();
@@ -4270,10 +4282,10 @@ init_logger();
4270
4282
 
4271
4283
  // src/utils/data-component-schema.ts
4272
4284
  init_logger();
4273
- var logger11 = agentsCore.getLogger("DataComponentSchema");
4285
+ var logger12 = agentsCore.getLogger("DataComponentSchema");
4274
4286
  function jsonSchemaToZod(jsonSchema) {
4275
4287
  if (!jsonSchema || typeof jsonSchema !== "object") {
4276
- logger11.warn({ jsonSchema }, "Invalid JSON schema provided, using string fallback");
4288
+ logger12.warn({ jsonSchema }, "Invalid JSON schema provided, using string fallback");
4277
4289
  return z5.z.string();
4278
4290
  }
4279
4291
  switch (jsonSchema.type) {
@@ -4300,7 +4312,7 @@ function jsonSchemaToZod(jsonSchema) {
4300
4312
  case "null":
4301
4313
  return z5.z.null();
4302
4314
  default:
4303
- logger11.warn(
4315
+ logger12.warn(
4304
4316
  {
4305
4317
  unsupportedType: jsonSchema.type,
4306
4318
  schema: jsonSchema
@@ -4671,7 +4683,7 @@ function parseEmbeddedJson(data) {
4671
4683
 
4672
4684
  // src/a2a/client.ts
4673
4685
  init_logger();
4674
- var logger12 = agentsCore.getLogger("a2aClient");
4686
+ var logger13 = agentsCore.getLogger("a2aClient");
4675
4687
  var DEFAULT_BACKOFF = {
4676
4688
  initialInterval: 500,
4677
4689
  maxInterval: 6e4,
@@ -4877,7 +4889,7 @@ var A2AClient = class {
4877
4889
  try {
4878
4890
  const res = await fn();
4879
4891
  if (attempt > 0) {
4880
- logger12.info(
4892
+ logger13.info(
4881
4893
  {
4882
4894
  attempts: attempt + 1,
4883
4895
  elapsedTime: Date.now() - start
@@ -4892,7 +4904,7 @@ var A2AClient = class {
4892
4904
  }
4893
4905
  const elapsed = Date.now() - start;
4894
4906
  if (elapsed > maxElapsedTime) {
4895
- logger12.warn(
4907
+ logger13.warn(
4896
4908
  {
4897
4909
  attempts: attempt + 1,
4898
4910
  elapsedTime: elapsed,
@@ -4913,7 +4925,7 @@ var A2AClient = class {
4913
4925
  retryInterval = initialInterval * attempt ** exponent + Math.random() * 1e3;
4914
4926
  }
4915
4927
  const delayMs = Math.min(retryInterval, maxInterval);
4916
- logger12.info(
4928
+ logger13.info(
4917
4929
  {
4918
4930
  attempt: attempt + 1,
4919
4931
  delayMs,
@@ -4998,7 +5010,7 @@ var A2AClient = class {
4998
5010
  }
4999
5011
  const rpcResponse = await httpResponse.json();
5000
5012
  if (rpcResponse.id !== requestId2) {
5001
- logger12.warn(
5013
+ logger13.warn(
5002
5014
  {
5003
5015
  method,
5004
5016
  expectedId: requestId2,
@@ -5197,7 +5209,7 @@ var A2AClient = class {
5197
5209
  try {
5198
5210
  while (true) {
5199
5211
  const { done, value } = await reader.read();
5200
- logger12.info({ done, value }, "parseA2ASseStream");
5212
+ logger13.info({ done, value }, "parseA2ASseStream");
5201
5213
  if (done) {
5202
5214
  if (eventDataBuffer.trim()) {
5203
5215
  const result = this._processSseEventData(
@@ -5287,7 +5299,7 @@ var A2AClient = class {
5287
5299
  init_conversations();
5288
5300
  init_dbClient();
5289
5301
  init_logger();
5290
- var logger13 = agentsCore.getLogger("relationships Tools");
5302
+ var logger14 = agentsCore.getLogger("relationships Tools");
5291
5303
  var generateTransferToolDescription = (config) => {
5292
5304
  return `Hand off the conversation to agent ${config.id}.
5293
5305
 
@@ -5325,7 +5337,7 @@ var createTransferToAgentTool = ({
5325
5337
  "transfer.to_agent_id": transferConfig.id ?? "unknown"
5326
5338
  });
5327
5339
  }
5328
- logger13.info(
5340
+ logger14.info(
5329
5341
  {
5330
5342
  transferTo: transferConfig.id ?? "unknown",
5331
5343
  fromAgent: callingAgentId
@@ -5474,7 +5486,7 @@ function createDelegateToAgentTool({
5474
5486
  ...isInternal ? { fromAgentId: callingAgentId } : { fromExternalAgentId: callingAgentId }
5475
5487
  }
5476
5488
  };
5477
- logger13.info({ messageToSend }, "messageToSend");
5489
+ logger14.info({ messageToSend }, "messageToSend");
5478
5490
  await agentsCore.createMessage(dbClient_default)({
5479
5491
  id: nanoid.nanoid(),
5480
5492
  tenantId,
@@ -5537,7 +5549,7 @@ function createDelegateToAgentTool({
5537
5549
 
5538
5550
  // src/agents/SystemPromptBuilder.ts
5539
5551
  init_logger();
5540
- var logger14 = agentsCore.getLogger("SystemPromptBuilder");
5552
+ var logger15 = agentsCore.getLogger("SystemPromptBuilder");
5541
5553
  var SystemPromptBuilder = class {
5542
5554
  constructor(version, versionConfig) {
5543
5555
  this.version = version;
@@ -5553,12 +5565,12 @@ var SystemPromptBuilder = class {
5553
5565
  this.templates.set(name, content);
5554
5566
  }
5555
5567
  this.loaded = true;
5556
- logger14.debug(
5568
+ logger15.debug(
5557
5569
  { templateCount: this.templates.size, version: this.version },
5558
5570
  `Loaded ${this.templates.size} templates for version ${this.version}`
5559
5571
  );
5560
5572
  } catch (error) {
5561
- logger14.error({ error }, `Failed to load templates for version ${this.version}`);
5573
+ logger15.error({ error }, `Failed to load templates for version ${this.version}`);
5562
5574
  throw new Error(`Template loading failed: ${error}`);
5563
5575
  }
5564
5576
  }
@@ -6604,7 +6616,7 @@ function hasToolCallWithPrefix(prefix) {
6604
6616
  return false;
6605
6617
  };
6606
6618
  }
6607
- var logger16 = agentsCore.getLogger("Agent");
6619
+ var logger17 = agentsCore.getLogger("Agent");
6608
6620
  var CONSTANTS = {
6609
6621
  MAX_GENERATION_STEPS: 12,
6610
6622
  PHASE_1_TIMEOUT_MS: 27e4,
@@ -6903,14 +6915,14 @@ var Agent = class {
6903
6915
  for (const toolSet of tools) {
6904
6916
  for (const [toolName, originalTool] of Object.entries(toolSet)) {
6905
6917
  if (!isValidTool(originalTool)) {
6906
- logger16.error({ toolName }, "Invalid MCP tool structure - missing required properties");
6918
+ logger17.error({ toolName }, "Invalid MCP tool structure - missing required properties");
6907
6919
  continue;
6908
6920
  }
6909
6921
  const sessionWrappedTool = ai.tool({
6910
6922
  description: originalTool.description,
6911
6923
  inputSchema: originalTool.inputSchema,
6912
6924
  execute: async (args, { toolCallId }) => {
6913
- logger16.debug({ toolName, toolCallId }, "MCP Tool Called");
6925
+ logger17.debug({ toolName, toolCallId }, "MCP Tool Called");
6914
6926
  try {
6915
6927
  const rawResult = await originalTool.execute(args, { toolCallId });
6916
6928
  const parsedResult = parseEmbeddedJson(rawResult);
@@ -6924,7 +6936,7 @@ var Agent = class {
6924
6936
  });
6925
6937
  return { result: enhancedResult, toolCallId };
6926
6938
  } catch (error) {
6927
- logger16.error({ toolName, toolCallId, error }, "MCP tool execution failed");
6939
+ logger17.error({ toolName, toolCallId, error }, "MCP tool execution failed");
6928
6940
  throw error;
6929
6941
  }
6930
6942
  }
@@ -7018,7 +7030,7 @@ var Agent = class {
7018
7030
  headers: agentToolRelationHeaders
7019
7031
  };
7020
7032
  }
7021
- logger16.info(
7033
+ logger17.info(
7022
7034
  {
7023
7035
  toolName: tool3.name,
7024
7036
  credentialReferenceId,
@@ -7058,7 +7070,7 @@ var Agent = class {
7058
7070
  async getResolvedContext(conversationId, requestContext) {
7059
7071
  try {
7060
7072
  if (!this.config.contextConfigId) {
7061
- logger16.debug({ graphId: this.config.graphId }, "No context config found for graph");
7073
+ logger17.debug({ graphId: this.config.graphId }, "No context config found for graph");
7062
7074
  return null;
7063
7075
  }
7064
7076
  const contextConfig = await agentsCore.getContextConfigById(dbClient_default)({
@@ -7066,7 +7078,7 @@ var Agent = class {
7066
7078
  id: this.config.contextConfigId
7067
7079
  });
7068
7080
  if (!contextConfig) {
7069
- logger16.warn({ contextConfigId: this.config.contextConfigId }, "Context config not found");
7081
+ logger17.warn({ contextConfigId: this.config.contextConfigId }, "Context config not found");
7070
7082
  return null;
7071
7083
  }
7072
7084
  if (!this.contextResolver) {
@@ -7084,7 +7096,7 @@ var Agent = class {
7084
7096
  $now: (/* @__PURE__ */ new Date()).toISOString(),
7085
7097
  $env: process.env
7086
7098
  };
7087
- logger16.debug(
7099
+ logger17.debug(
7088
7100
  {
7089
7101
  conversationId,
7090
7102
  contextConfigId: contextConfig.id,
@@ -7098,7 +7110,7 @@ var Agent = class {
7098
7110
  );
7099
7111
  return contextWithBuiltins;
7100
7112
  } catch (error) {
7101
- logger16.error(
7113
+ logger17.error(
7102
7114
  {
7103
7115
  conversationId,
7104
7116
  error: error instanceof Error ? error.message : "Unknown error"
@@ -7122,7 +7134,7 @@ var Agent = class {
7122
7134
  });
7123
7135
  return graphDefinition?.graphPrompt || void 0;
7124
7136
  } catch (error) {
7125
- logger16.warn(
7137
+ logger17.warn(
7126
7138
  {
7127
7139
  graphId: this.config.graphId,
7128
7140
  error: error instanceof Error ? error.message : "Unknown error"
@@ -7151,7 +7163,7 @@ var Agent = class {
7151
7163
  (agent) => "artifactComponents" in agent && agent.artifactComponents && agent.artifactComponents.length > 0
7152
7164
  );
7153
7165
  } catch (error) {
7154
- logger16.warn(
7166
+ logger17.warn(
7155
7167
  {
7156
7168
  graphId: this.config.graphId,
7157
7169
  tenantId: this.config.tenantId,
@@ -7180,7 +7192,7 @@ var Agent = class {
7180
7192
  preserveUnresolved: false
7181
7193
  });
7182
7194
  } catch (error) {
7183
- logger16.error(
7195
+ logger17.error(
7184
7196
  {
7185
7197
  conversationId,
7186
7198
  error: error instanceof Error ? error.message : "Unknown error"
@@ -7227,7 +7239,7 @@ var Agent = class {
7227
7239
  preserveUnresolved: false
7228
7240
  });
7229
7241
  } catch (error) {
7230
- logger16.error(
7242
+ logger17.error(
7231
7243
  {
7232
7244
  conversationId,
7233
7245
  error: error instanceof Error ? error.message : "Unknown error"
@@ -7266,7 +7278,7 @@ var Agent = class {
7266
7278
  preserveUnresolved: false
7267
7279
  });
7268
7280
  } catch (error) {
7269
- logger16.error(
7281
+ logger17.error(
7270
7282
  {
7271
7283
  conversationId,
7272
7284
  error: error instanceof Error ? error.message : "Unknown error"
@@ -7298,7 +7310,7 @@ var Agent = class {
7298
7310
  artifactId: z5.z.string().describe("The unique identifier of the artifact to get.")
7299
7311
  }),
7300
7312
  execute: async ({ artifactId }) => {
7301
- logger16.info({ artifactId }, "get_artifact executed");
7313
+ logger17.info({ artifactId }, "get_artifact executed");
7302
7314
  const artifact = await agentsCore.getLedgerArtifacts(dbClient_default)({
7303
7315
  scopes: {
7304
7316
  tenantId: this.config.tenantId,
@@ -7548,7 +7560,7 @@ var Agent = class {
7548
7560
  };
7549
7561
  return enhanced;
7550
7562
  } catch (error) {
7551
- logger16.warn({ error }, "Failed to enhance tool result with structure hints");
7563
+ logger17.warn({ error }, "Failed to enhance tool result with structure hints");
7552
7564
  return result;
7553
7565
  }
7554
7566
  }
@@ -7563,7 +7575,7 @@ var Agent = class {
7563
7575
  }
7564
7576
  });
7565
7577
  } catch (error) {
7566
- logger16.error(
7578
+ logger17.error(
7567
7579
  { error, graphId: this.config.graphId },
7568
7580
  "Failed to check graph artifact components"
7569
7581
  );
@@ -7664,7 +7676,7 @@ var Agent = class {
7664
7676
  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;
7665
7677
  const timeoutMs = Math.min(configuredTimeout, MAX_ALLOWED_TIMEOUT_MS);
7666
7678
  if (modelSettings.maxDuration && modelSettings.maxDuration * 1e3 > MAX_ALLOWED_TIMEOUT_MS) {
7667
- logger16.warn(
7679
+ logger17.warn(
7668
7680
  {
7669
7681
  requestedTimeout: modelSettings.maxDuration * 1e3,
7670
7682
  appliedTimeout: timeoutMs,
@@ -7706,7 +7718,7 @@ var Agent = class {
7706
7718
  }
7707
7719
  );
7708
7720
  } catch (error) {
7709
- logger16.debug({ error }, "Failed to track agent reasoning");
7721
+ logger17.debug({ error }, "Failed to track agent reasoning");
7710
7722
  }
7711
7723
  }
7712
7724
  if (last && "toolCalls" in last && last.toolCalls) {
@@ -7803,7 +7815,7 @@ var Agent = class {
7803
7815
  }
7804
7816
  );
7805
7817
  } catch (error) {
7806
- logger16.debug({ error }, "Failed to track agent reasoning");
7818
+ logger17.debug({ error }, "Failed to track agent reasoning");
7807
7819
  }
7808
7820
  }
7809
7821
  if (last && "toolCalls" in last && last.toolCalls) {
@@ -8095,7 +8107,7 @@ ${output}${structureHintsFormatted}`;
8095
8107
  };
8096
8108
 
8097
8109
  // src/agents/generateTaskHandler.ts
8098
- var logger17 = agentsCore.getLogger("generateTaskHandler");
8110
+ var logger18 = agentsCore.getLogger("generateTaskHandler");
8099
8111
  var createTaskHandler = (config, credentialStoreRegistry) => {
8100
8112
  return async (task) => {
8101
8113
  try {
@@ -8148,7 +8160,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
8148
8160
  }
8149
8161
  })
8150
8162
  ]);
8151
- logger17.info({ toolsForAgent, internalRelations, externalRelations }, "agent stuff");
8163
+ logger18.info({ toolsForAgent, internalRelations, externalRelations }, "agent stuff");
8152
8164
  const enhancedInternalRelations = await Promise.all(
8153
8165
  internalRelations.map(async (relation) => {
8154
8166
  try {
@@ -8177,7 +8189,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
8177
8189
  return { ...relation, description: enhancedDescription };
8178
8190
  }
8179
8191
  } catch (error) {
8180
- logger17.warn({ agentId: relation.id, error }, "Failed to enhance agent description");
8192
+ logger18.warn({ agentId: relation.id, error }, "Failed to enhance agent description");
8181
8193
  }
8182
8194
  return relation;
8183
8195
  })
@@ -8277,7 +8289,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
8277
8289
  const taskIdMatch = task.id.match(/^task_([^-]+-[^-]+-\d+)-/);
8278
8290
  if (taskIdMatch) {
8279
8291
  contextId = taskIdMatch[1];
8280
- logger17.info(
8292
+ logger18.info(
8281
8293
  {
8282
8294
  taskId: task.id,
8283
8295
  extractedContextId: contextId,
@@ -8293,7 +8305,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
8293
8305
  const isDelegation = task.context?.metadata?.isDelegation === true;
8294
8306
  agent.setDelegationStatus(isDelegation);
8295
8307
  if (isDelegation) {
8296
- logger17.info(
8308
+ logger18.info(
8297
8309
  { agentId: config.agentId, taskId: task.id },
8298
8310
  "Delegated agent - streaming disabled"
8299
8311
  );
@@ -8518,7 +8530,7 @@ async function getRegisteredGraph(executionContext) {
8518
8530
  init_dbClient();
8519
8531
  init_logger();
8520
8532
  var app = new zodOpenapi.OpenAPIHono();
8521
- var logger18 = agentsCore.getLogger("agents");
8533
+ var logger19 = agentsCore.getLogger("agents");
8522
8534
  app.openapi(
8523
8535
  zodOpenapi.createRoute({
8524
8536
  method: "get",
@@ -8556,7 +8568,7 @@ app.openapi(
8556
8568
  tracestate: c.req.header("tracestate"),
8557
8569
  baggage: c.req.header("baggage")
8558
8570
  };
8559
- logger18.info(
8571
+ logger19.info(
8560
8572
  {
8561
8573
  otelHeaders,
8562
8574
  path: c.req.path,
@@ -8568,7 +8580,7 @@ app.openapi(
8568
8580
  const { tenantId, projectId, graphId, agentId } = executionContext;
8569
8581
  console.dir("executionContext", executionContext);
8570
8582
  if (agentId) {
8571
- logger18.info(
8583
+ logger19.info(
8572
8584
  {
8573
8585
  message: "getRegisteredAgent (agent-level)",
8574
8586
  tenantId,
@@ -8580,7 +8592,7 @@ app.openapi(
8580
8592
  );
8581
8593
  const credentialStores = c.get("credentialStores");
8582
8594
  const agent = await getRegisteredAgent(executionContext, credentialStores);
8583
- logger18.info({ agent }, "agent registered: well-known agent.json");
8595
+ logger19.info({ agent }, "agent registered: well-known agent.json");
8584
8596
  if (!agent) {
8585
8597
  throw agentsCore.createApiError({
8586
8598
  code: "not_found",
@@ -8589,7 +8601,7 @@ app.openapi(
8589
8601
  }
8590
8602
  return c.json(agent.agentCard);
8591
8603
  } else {
8592
- logger18.info(
8604
+ logger19.info(
8593
8605
  {
8594
8606
  message: "getRegisteredGraph (graph-level)",
8595
8607
  tenantId,
@@ -8615,7 +8627,7 @@ app.post("/a2a", async (c) => {
8615
8627
  tracestate: c.req.header("tracestate"),
8616
8628
  baggage: c.req.header("baggage")
8617
8629
  };
8618
- logger18.info(
8630
+ logger19.info(
8619
8631
  {
8620
8632
  otelHeaders,
8621
8633
  path: c.req.path,
@@ -8626,7 +8638,7 @@ app.post("/a2a", async (c) => {
8626
8638
  const executionContext = agentsCore.getRequestExecutionContext(c);
8627
8639
  const { tenantId, projectId, graphId, agentId } = executionContext;
8628
8640
  if (agentId) {
8629
- logger18.info(
8641
+ logger19.info(
8630
8642
  {
8631
8643
  message: "a2a (agent-level)",
8632
8644
  tenantId,
@@ -8650,7 +8662,7 @@ app.post("/a2a", async (c) => {
8650
8662
  }
8651
8663
  return a2aHandler(c, agent);
8652
8664
  } else {
8653
- logger18.info(
8665
+ logger19.info(
8654
8666
  {
8655
8667
  message: "a2a (graph-level)",
8656
8668
  tenantId,
@@ -8706,14 +8718,14 @@ init_dbClient();
8706
8718
  // src/a2a/transfer.ts
8707
8719
  init_dbClient();
8708
8720
  init_logger();
8709
- var logger19 = agentsCore.getLogger("Transfer");
8721
+ var logger20 = agentsCore.getLogger("Transfer");
8710
8722
  async function executeTransfer({
8711
8723
  tenantId,
8712
8724
  threadId,
8713
8725
  projectId,
8714
8726
  targetAgentId
8715
8727
  }) {
8716
- logger19.info({ targetAgent: targetAgentId }, "Executing transfer to agent");
8728
+ logger20.info({ targetAgent: targetAgentId }, "Executing transfer to agent");
8717
8729
  await agentsCore.setActiveAgentForThread(dbClient_default)({
8718
8730
  scopes: { tenantId, projectId },
8719
8731
  threadId,
@@ -9299,7 +9311,7 @@ function createMCPStreamHelper() {
9299
9311
  }
9300
9312
 
9301
9313
  // src/handlers/executionHandler.ts
9302
- var logger20 = agentsCore.getLogger("ExecutionHandler");
9314
+ var logger21 = agentsCore.getLogger("ExecutionHandler");
9303
9315
  var ExecutionHandler = class {
9304
9316
  constructor() {
9305
9317
  // Hardcoded error limit - separate from configurable stopWhen
@@ -9324,7 +9336,7 @@ var ExecutionHandler = class {
9324
9336
  const { tenantId, projectId, graphId, apiKey, baseUrl } = executionContext;
9325
9337
  registerStreamHelper(requestId2, sseHelper);
9326
9338
  graphSessionManager.createSession(requestId2, graphId, tenantId, projectId, conversationId);
9327
- logger20.info(
9339
+ logger21.info(
9328
9340
  { sessionId: requestId2, graphId, conversationId },
9329
9341
  "Created GraphSession for message execution"
9330
9342
  );
@@ -9339,7 +9351,7 @@ var ExecutionHandler = class {
9339
9351
  );
9340
9352
  }
9341
9353
  } catch (error) {
9342
- logger20.error(
9354
+ logger21.error(
9343
9355
  {
9344
9356
  error: error instanceof Error ? error.message : "Unknown error",
9345
9357
  stack: error instanceof Error ? error.stack : void 0
@@ -9355,7 +9367,7 @@ var ExecutionHandler = class {
9355
9367
  try {
9356
9368
  await sseHelper.writeOperation(agentInitializingOp(requestId2, graphId));
9357
9369
  const taskId = `task_${conversationId}-${requestId2}`;
9358
- logger20.info(
9370
+ logger21.info(
9359
9371
  { taskId, currentAgentId, conversationId, requestId: requestId2 },
9360
9372
  "Attempting to create or reuse existing task"
9361
9373
  );
@@ -9379,7 +9391,7 @@ var ExecutionHandler = class {
9379
9391
  agent_id: currentAgentId
9380
9392
  }
9381
9393
  });
9382
- logger20.info(
9394
+ logger21.info(
9383
9395
  {
9384
9396
  taskId,
9385
9397
  createdTaskMetadata: Array.isArray(task) ? task[0]?.metadata : task?.metadata
@@ -9388,27 +9400,27 @@ var ExecutionHandler = class {
9388
9400
  );
9389
9401
  } catch (error) {
9390
9402
  if (error?.message?.includes("UNIQUE constraint failed") || error?.message?.includes("PRIMARY KEY constraint failed") || error?.code === "SQLITE_CONSTRAINT_PRIMARYKEY") {
9391
- logger20.info(
9403
+ logger21.info(
9392
9404
  { taskId, error: error.message },
9393
9405
  "Task already exists, fetching existing task"
9394
9406
  );
9395
9407
  const existingTask = await agentsCore.getTask(dbClient_default)({ id: taskId });
9396
9408
  if (existingTask) {
9397
9409
  task = existingTask;
9398
- logger20.info(
9410
+ logger21.info(
9399
9411
  { taskId, existingTask },
9400
9412
  "Successfully reused existing task from race condition"
9401
9413
  );
9402
9414
  } else {
9403
- logger20.error({ taskId, error }, "Task constraint failed but task not found");
9415
+ logger21.error({ taskId, error }, "Task constraint failed but task not found");
9404
9416
  throw error;
9405
9417
  }
9406
9418
  } else {
9407
- logger20.error({ taskId, error }, "Failed to create task due to non-constraint error");
9419
+ logger21.error({ taskId, error }, "Failed to create task due to non-constraint error");
9408
9420
  throw error;
9409
9421
  }
9410
9422
  }
9411
- logger20.debug(
9423
+ logger21.debug(
9412
9424
  {
9413
9425
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
9414
9426
  executionType: "create_initial_task",
@@ -9426,7 +9438,7 @@ var ExecutionHandler = class {
9426
9438
  const maxTransfers = graphConfig?.stopWhen?.transferCountIs ?? 10;
9427
9439
  while (iterations < maxTransfers) {
9428
9440
  iterations++;
9429
- logger20.info(
9441
+ logger21.info(
9430
9442
  { iterations, currentAgentId, graphId, conversationId, fromAgentId },
9431
9443
  `Execution loop iteration ${iterations} with agent ${currentAgentId}, transfer from: ${fromAgentId || "none"}`
9432
9444
  );
@@ -9434,10 +9446,10 @@ var ExecutionHandler = class {
9434
9446
  scopes: { tenantId, projectId },
9435
9447
  conversationId
9436
9448
  });
9437
- logger20.info({ activeAgent }, "activeAgent");
9449
+ logger21.info({ activeAgent }, "activeAgent");
9438
9450
  if (activeAgent && activeAgent.activeAgentId !== currentAgentId) {
9439
9451
  currentAgentId = activeAgent.activeAgentId;
9440
- logger20.info({ currentAgentId }, `Updated current agent to: ${currentAgentId}`);
9452
+ logger21.info({ currentAgentId }, `Updated current agent to: ${currentAgentId}`);
9441
9453
  }
9442
9454
  const agentBaseUrl = `${baseUrl}/agents`;
9443
9455
  const a2aClient = new A2AClient(agentBaseUrl, {
@@ -9478,13 +9490,13 @@ var ExecutionHandler = class {
9478
9490
  });
9479
9491
  if (!messageResponse?.result) {
9480
9492
  errorCount++;
9481
- logger20.error(
9493
+ logger21.error(
9482
9494
  { currentAgentId, iterations, errorCount },
9483
9495
  `No response from agent ${currentAgentId} on iteration ${iterations} (error ${errorCount}/${this.MAX_ERRORS})`
9484
9496
  );
9485
9497
  if (errorCount >= this.MAX_ERRORS) {
9486
9498
  const errorMessage2 = `Maximum error limit (${this.MAX_ERRORS}) reached`;
9487
- logger20.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
9499
+ logger21.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
9488
9500
  await sseHelper.writeOperation(errorOp(errorMessage2, currentAgentId || "system"));
9489
9501
  if (task) {
9490
9502
  await agentsCore.updateTask(dbClient_default)({
@@ -9509,7 +9521,7 @@ var ExecutionHandler = class {
9509
9521
  const transferResponse = messageResponse.result;
9510
9522
  const targetAgentId = transferResponse.artifacts?.[0]?.parts?.[0]?.data?.targetAgentId;
9511
9523
  const transferReason = transferResponse.artifacts?.[0]?.parts?.[1]?.text;
9512
- logger20.info({ targetAgentId, transferReason }, "transfer response");
9524
+ logger21.info({ targetAgentId, transferReason }, "transfer response");
9513
9525
  currentMessage = `<transfer_context> ${transferReason} </transfer_context>`;
9514
9526
  const { success, targetAgentId: newAgentId } = await executeTransfer({
9515
9527
  projectId,
@@ -9520,7 +9532,7 @@ var ExecutionHandler = class {
9520
9532
  if (success) {
9521
9533
  fromAgentId = currentAgentId;
9522
9534
  currentAgentId = newAgentId;
9523
- logger20.info(
9535
+ logger21.info(
9524
9536
  {
9525
9537
  transferFrom: fromAgentId,
9526
9538
  transferTo: currentAgentId,
@@ -9538,7 +9550,7 @@ var ExecutionHandler = class {
9538
9550
  const graphSessionData = graphSessionManager.getSession(requestId2);
9539
9551
  if (graphSessionData) {
9540
9552
  const sessionSummary = graphSessionData.getSummary();
9541
- logger20.info(sessionSummary, "GraphSession data after completion");
9553
+ logger21.info(sessionSummary, "GraphSession data after completion");
9542
9554
  }
9543
9555
  let textContent = "";
9544
9556
  for (const part of responseParts) {
@@ -9592,22 +9604,22 @@ var ExecutionHandler = class {
9592
9604
  }
9593
9605
  });
9594
9606
  const updateTaskEnd = Date.now();
9595
- logger20.info(
9607
+ logger21.info(
9596
9608
  { duration: updateTaskEnd - updateTaskStart },
9597
9609
  "Completed updateTask operation"
9598
9610
  );
9599
9611
  await sseHelper.writeOperation(completionOp(currentAgentId, iterations));
9600
9612
  await sseHelper.complete();
9601
- logger20.info({}, "Ending GraphSession and cleaning up");
9613
+ logger21.info({}, "Ending GraphSession and cleaning up");
9602
9614
  graphSessionManager.endSession(requestId2);
9603
- logger20.info({}, "Cleaning up streamHelper");
9615
+ logger21.info({}, "Cleaning up streamHelper");
9604
9616
  unregisterStreamHelper(requestId2);
9605
9617
  let response;
9606
9618
  if (sseHelper instanceof MCPStreamHelper) {
9607
9619
  const captured = sseHelper.getCapturedResponse();
9608
9620
  response = captured.text || "No response content";
9609
9621
  }
9610
- logger20.info({}, "ExecutionHandler returning success");
9622
+ logger21.info({}, "ExecutionHandler returning success");
9611
9623
  return { success: true, iterations, response };
9612
9624
  } catch (error) {
9613
9625
  agentsCore.setSpanWithError(span, error);
@@ -9619,13 +9631,13 @@ var ExecutionHandler = class {
9619
9631
  });
9620
9632
  }
9621
9633
  errorCount++;
9622
- logger20.warn(
9634
+ logger21.warn(
9623
9635
  { iterations, errorCount },
9624
9636
  `No valid response or transfer on iteration ${iterations} (error ${errorCount}/${this.MAX_ERRORS})`
9625
9637
  );
9626
9638
  if (errorCount >= this.MAX_ERRORS) {
9627
9639
  const errorMessage2 = `Maximum error limit (${this.MAX_ERRORS}) reached`;
9628
- logger20.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
9640
+ logger21.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
9629
9641
  await sseHelper.writeOperation(errorOp(errorMessage2, currentAgentId || "system"));
9630
9642
  if (task) {
9631
9643
  await agentsCore.updateTask(dbClient_default)({
@@ -9646,7 +9658,7 @@ var ExecutionHandler = class {
9646
9658
  }
9647
9659
  }
9648
9660
  const errorMessage = `Maximum transfer limit (${maxTransfers}) reached without completion`;
9649
- logger20.error({ maxTransfers, iterations }, errorMessage);
9661
+ logger21.error({ maxTransfers, iterations }, errorMessage);
9650
9662
  await sseHelper.writeOperation(errorOp(errorMessage, currentAgentId || "system"));
9651
9663
  if (task) {
9652
9664
  await agentsCore.updateTask(dbClient_default)({
@@ -9665,7 +9677,7 @@ var ExecutionHandler = class {
9665
9677
  unregisterStreamHelper(requestId2);
9666
9678
  return { success: false, error: errorMessage, iterations };
9667
9679
  } catch (error) {
9668
- logger20.error({ error }, "Error in execution handler");
9680
+ logger21.error({ error }, "Error in execution handler");
9669
9681
  const errorMessage = error instanceof Error ? error.message : "Unknown execution error";
9670
9682
  await sseHelper.writeOperation(
9671
9683
  errorOp(`Execution error: ${errorMessage}`, currentAgentId || "system")
@@ -9693,7 +9705,7 @@ var ExecutionHandler = class {
9693
9705
  // src/routes/chat.ts
9694
9706
  init_logger();
9695
9707
  var app2 = new zodOpenapi.OpenAPIHono();
9696
- var logger21 = agentsCore.getLogger("completionsHandler");
9708
+ var logger22 = agentsCore.getLogger("completionsHandler");
9697
9709
  var chatCompletionsRoute = zodOpenapi.createRoute({
9698
9710
  method: "post",
9699
9711
  path: "/completions",
@@ -9811,7 +9823,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
9811
9823
  tracestate: c.req.header("tracestate"),
9812
9824
  baggage: c.req.header("baggage")
9813
9825
  };
9814
- logger21.info(
9826
+ logger22.info(
9815
9827
  {
9816
9828
  otelHeaders,
9817
9829
  path: c.req.path,
@@ -9904,7 +9916,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
9904
9916
  dbClient: dbClient_default,
9905
9917
  credentialStores
9906
9918
  });
9907
- logger21.info(
9919
+ logger22.info(
9908
9920
  {
9909
9921
  tenantId,
9910
9922
  projectId,
@@ -9952,7 +9964,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
9952
9964
  try {
9953
9965
  const sseHelper = createSSEStreamHelper(stream2, requestId2, timestamp);
9954
9966
  await sseHelper.writeRole();
9955
- logger21.info({ agentId }, "Starting execution");
9967
+ logger22.info({ agentId }, "Starting execution");
9956
9968
  const executionHandler = new ExecutionHandler();
9957
9969
  const result = await executionHandler.execute({
9958
9970
  executionContext,
@@ -9962,7 +9974,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
9962
9974
  requestId: requestId2,
9963
9975
  sseHelper
9964
9976
  });
9965
- logger21.info(
9977
+ logger22.info(
9966
9978
  { result },
9967
9979
  `Execution completed: ${result.success ? "success" : "failed"} after ${result.iterations} iterations`
9968
9980
  );
@@ -9976,7 +9988,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
9976
9988
  }
9977
9989
  await sseHelper.complete();
9978
9990
  } catch (error) {
9979
- logger21.error(
9991
+ logger22.error(
9980
9992
  {
9981
9993
  error: error instanceof Error ? error.message : error,
9982
9994
  stack: error instanceof Error ? error.stack : void 0
@@ -9993,12 +10005,12 @@ app2.openapi(chatCompletionsRoute, async (c) => {
9993
10005
  );
9994
10006
  await sseHelper.complete();
9995
10007
  } catch (streamError) {
9996
- logger21.error({ streamError }, "Failed to write error to stream");
10008
+ logger22.error({ streamError }, "Failed to write error to stream");
9997
10009
  }
9998
10010
  }
9999
10011
  });
10000
10012
  } catch (error) {
10001
- logger21.error(
10013
+ logger22.error(
10002
10014
  {
10003
10015
  error: error instanceof Error ? error.message : error,
10004
10016
  stack: error instanceof Error ? error.stack : void 0
@@ -10026,7 +10038,7 @@ var chat_default = app2;
10026
10038
  init_dbClient();
10027
10039
  init_logger();
10028
10040
  var app3 = new zodOpenapi.OpenAPIHono();
10029
- var logger22 = agentsCore.getLogger("chatDataStream");
10041
+ var logger23 = agentsCore.getLogger("chatDataStream");
10030
10042
  var chatDataStreamRoute = zodOpenapi.createRoute({
10031
10043
  method: "post",
10032
10044
  path: "/chat",
@@ -10144,7 +10156,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
10144
10156
  await defaultBatchProcessor.forceFlush();
10145
10157
  const lastUserMessage = body.messages.filter((m) => m.role === "user").slice(-1)[0];
10146
10158
  const userText = typeof lastUserMessage?.content === "string" ? lastUserMessage.content : lastUserMessage?.parts?.map((p) => p.text).join("") || "";
10147
- logger22.info({ userText, lastUserMessage }, "userText");
10159
+ logger23.info({ userText, lastUserMessage }, "userText");
10148
10160
  const messageSpan = api.trace.getActiveSpan();
10149
10161
  if (messageSpan) {
10150
10162
  messageSpan.setAttributes({
@@ -10186,7 +10198,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
10186
10198
  await streamHelper.writeOperation(errorOp("Unable to process request", "system"));
10187
10199
  }
10188
10200
  } catch (err) {
10189
- logger22.error({ err }, "Streaming error");
10201
+ logger23.error({ err }, "Streaming error");
10190
10202
  await streamHelper.writeOperation(errorOp("Internal server error", "system"));
10191
10203
  } finally {
10192
10204
  if ("cleanup" in streamHelper && typeof streamHelper.cleanup === "function") {
@@ -10207,7 +10219,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
10207
10219
  )
10208
10220
  );
10209
10221
  } catch (error) {
10210
- logger22.error({ error }, "chatDataStream error");
10222
+ logger23.error({ error }, "chatDataStream error");
10211
10223
  throw agentsCore.createApiError({
10212
10224
  code: "internal_server_error",
10213
10225
  message: "Failed to process chat completion"
@@ -10222,7 +10234,7 @@ init_logger();
10222
10234
  function createMCPSchema(schema) {
10223
10235
  return schema;
10224
10236
  }
10225
- var logger23 = agentsCore.getLogger("mcp");
10237
+ var logger24 = agentsCore.getLogger("mcp");
10226
10238
  var _MockResponseSingleton = class _MockResponseSingleton {
10227
10239
  constructor() {
10228
10240
  __publicField(this, "mockRes");
@@ -10277,21 +10289,21 @@ var createSpoofInitMessage = (mcpProtocolVersion) => ({
10277
10289
  id: 0
10278
10290
  });
10279
10291
  var spoofTransportInitialization = async (transport, req, sessionId, mcpProtocolVersion) => {
10280
- logger23.info({ sessionId }, "Spoofing initialization message to set transport state");
10292
+ logger24.info({ sessionId }, "Spoofing initialization message to set transport state");
10281
10293
  const spoofInitMessage = createSpoofInitMessage(mcpProtocolVersion);
10282
10294
  const mockRes = MockResponseSingleton.getInstance().getMockResponse();
10283
10295
  try {
10284
10296
  await transport.handleRequest(req, mockRes, spoofInitMessage);
10285
- logger23.info({ sessionId }, "Successfully spoofed initialization");
10297
+ logger24.info({ sessionId }, "Successfully spoofed initialization");
10286
10298
  } catch (spoofError) {
10287
- logger23.warn({ sessionId, error: spoofError }, "Spoof initialization failed, continuing anyway");
10299
+ logger24.warn({ sessionId, error: spoofError }, "Spoof initialization failed, continuing anyway");
10288
10300
  }
10289
10301
  };
10290
10302
  var validateSession = async (req, res, body, tenantId, projectId, graphId) => {
10291
10303
  const sessionId = req.headers["mcp-session-id"];
10292
- logger23.info({ sessionId }, "Received MCP session ID");
10304
+ logger24.info({ sessionId }, "Received MCP session ID");
10293
10305
  if (!sessionId) {
10294
- logger23.info({ body }, "Missing session ID");
10306
+ logger24.info({ body }, "Missing session ID");
10295
10307
  res.writeHead(400).end(
10296
10308
  JSON.stringify({
10297
10309
  jsonrpc: "2.0",
@@ -10317,7 +10329,7 @@ var validateSession = async (req, res, body, tenantId, projectId, graphId) => {
10317
10329
  scopes: { tenantId, projectId },
10318
10330
  conversationId: sessionId
10319
10331
  });
10320
- logger23.info(
10332
+ logger24.info(
10321
10333
  {
10322
10334
  sessionId,
10323
10335
  conversationFound: !!conversation,
@@ -10328,7 +10340,7 @@ var validateSession = async (req, res, body, tenantId, projectId, graphId) => {
10328
10340
  "Conversation lookup result"
10329
10341
  );
10330
10342
  if (!conversation || conversation.metadata?.sessionData?.sessionType !== "mcp" || conversation.metadata?.sessionData?.graphId !== graphId) {
10331
- logger23.info(
10343
+ logger24.info(
10332
10344
  { sessionId, conversationId: conversation?.id },
10333
10345
  "MCP session not found or invalid"
10334
10346
  );
@@ -10389,7 +10401,7 @@ var executeAgentQuery = async (executionContext, conversationId, query, defaultA
10389
10401
  requestId: requestId2,
10390
10402
  sseHelper: mcpStreamHelper
10391
10403
  });
10392
- logger23.info(
10404
+ logger24.info(
10393
10405
  { result },
10394
10406
  `Execution completed: ${result.success ? "success" : "failed"} after ${result.iterations} iterations`
10395
10407
  );
@@ -10473,7 +10485,7 @@ var getServer = async (requestContext, executionContext, conversationId, credent
10473
10485
  dbClient: dbClient_default,
10474
10486
  credentialStores
10475
10487
  });
10476
- logger23.info(
10488
+ logger24.info(
10477
10489
  {
10478
10490
  tenantId,
10479
10491
  projectId,
@@ -10535,7 +10547,7 @@ var validateRequestParameters = (c) => {
10535
10547
  };
10536
10548
  var handleInitializationRequest = async (body, executionContext, validatedContext, req, res, c, credentialStores) => {
10537
10549
  const { tenantId, projectId, graphId } = executionContext;
10538
- logger23.info({ body }, "Received initialization request");
10550
+ logger24.info({ body }, "Received initialization request");
10539
10551
  const sessionId = nanoid.nanoid();
10540
10552
  const agentGraph = await agentsCore.getAgentGraphWithDefaultAgent(dbClient_default)({
10541
10553
  scopes: { tenantId, projectId, graphId }
@@ -10575,7 +10587,7 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
10575
10587
  }
10576
10588
  }
10577
10589
  });
10578
- logger23.info(
10590
+ logger24.info(
10579
10591
  { sessionId, conversationId: conversation.id },
10580
10592
  "Created MCP session as conversation"
10581
10593
  );
@@ -10584,9 +10596,9 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
10584
10596
  });
10585
10597
  const server = await getServer(validatedContext, executionContext, sessionId, credentialStores);
10586
10598
  await server.connect(transport);
10587
- logger23.info({ sessionId }, "Server connected for initialization");
10599
+ logger24.info({ sessionId }, "Server connected for initialization");
10588
10600
  res.setHeader("Mcp-Session-Id", sessionId);
10589
- logger23.info(
10601
+ logger24.info(
10590
10602
  {
10591
10603
  sessionId,
10592
10604
  bodyMethod: body?.method,
@@ -10595,7 +10607,7 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
10595
10607
  "About to handle initialization request"
10596
10608
  );
10597
10609
  await transport.handleRequest(req, res, body);
10598
- logger23.info({ sessionId }, "Successfully handled initialization request");
10610
+ logger24.info({ sessionId }, "Successfully handled initialization request");
10599
10611
  return fetchToNode.toFetchResponse(res);
10600
10612
  };
10601
10613
  var handleExistingSessionRequest = async (body, executionContext, validatedContext, req, res, credentialStores) => {
@@ -10623,8 +10635,8 @@ var handleExistingSessionRequest = async (body, executionContext, validatedConte
10623
10635
  sessionId,
10624
10636
  conversation.metadata?.session_data?.mcpProtocolVersion
10625
10637
  );
10626
- logger23.info({ sessionId }, "Server connected and transport initialized");
10627
- logger23.info(
10638
+ logger24.info({ sessionId }, "Server connected and transport initialized");
10639
+ logger24.info(
10628
10640
  {
10629
10641
  sessionId,
10630
10642
  bodyKeys: Object.keys(body || {}),
@@ -10638,9 +10650,9 @@ var handleExistingSessionRequest = async (body, executionContext, validatedConte
10638
10650
  );
10639
10651
  try {
10640
10652
  await transport.handleRequest(req, res, body);
10641
- logger23.info({ sessionId }, "Successfully handled MCP request");
10653
+ logger24.info({ sessionId }, "Successfully handled MCP request");
10642
10654
  } catch (transportError) {
10643
- logger23.error(
10655
+ logger24.error(
10644
10656
  {
10645
10657
  sessionId,
10646
10658
  error: transportError,
@@ -10691,13 +10703,13 @@ app4.openapi(
10691
10703
  }
10692
10704
  const { executionContext } = paramValidation;
10693
10705
  const body = c.get("requestBody") || {};
10694
- logger23.info({ body, bodyKeys: Object.keys(body || {}) }, "Parsed request body");
10706
+ logger24.info({ body, bodyKeys: Object.keys(body || {}) }, "Parsed request body");
10695
10707
  const isInitRequest = body.method === "initialize";
10696
10708
  const { req, res } = fetchToNode.toReqRes(c.req.raw);
10697
10709
  const validatedContext = c.get("validatedContext") || {};
10698
10710
  const credentialStores = c.get("credentialStores");
10699
- logger23.info({ validatedContext }, "Validated context");
10700
- logger23.info({ req }, "request");
10711
+ logger24.info({ validatedContext }, "Validated context");
10712
+ logger24.info({ req }, "request");
10701
10713
  if (isInitRequest) {
10702
10714
  return await handleInitializationRequest(
10703
10715
  body,
@@ -10719,7 +10731,7 @@ app4.openapi(
10719
10731
  );
10720
10732
  }
10721
10733
  } catch (e) {
10722
- logger23.error(
10734
+ logger24.error(
10723
10735
  {
10724
10736
  error: e instanceof Error ? e.message : e,
10725
10737
  stack: e instanceof Error ? e.stack : void 0
@@ -10731,7 +10743,7 @@ app4.openapi(
10731
10743
  }
10732
10744
  );
10733
10745
  app4.get("/", async (c) => {
10734
- logger23.info({}, "Received GET MCP request");
10746
+ logger24.info({}, "Received GET MCP request");
10735
10747
  return c.json(
10736
10748
  {
10737
10749
  jsonrpc: "2.0",
@@ -10745,7 +10757,7 @@ app4.get("/", async (c) => {
10745
10757
  );
10746
10758
  });
10747
10759
  app4.delete("/", async (c) => {
10748
- logger23.info({}, "Received DELETE MCP request");
10760
+ logger24.info({}, "Received DELETE MCP request");
10749
10761
  return c.json(
10750
10762
  {
10751
10763
  jsonrpc: "2.0",
@@ -10758,7 +10770,7 @@ app4.delete("/", async (c) => {
10758
10770
  var mcp_default = app4;
10759
10771
 
10760
10772
  // src/app.ts
10761
- var logger24 = agentsCore.getLogger("agents-run-api");
10773
+ var logger25 = agentsCore.getLogger("agents-run-api");
10762
10774
  function createExecutionHono(serverConfig, credentialStores) {
10763
10775
  const app6 = new zodOpenapi.OpenAPIHono();
10764
10776
  app6.use("*", otel.otel());
@@ -10774,7 +10786,7 @@ function createExecutionHono(serverConfig, credentialStores) {
10774
10786
  const body = await c.req.json();
10775
10787
  c.set("requestBody", body);
10776
10788
  } catch (error) {
10777
- logger24.debug({ error }, "Failed to parse JSON body, continuing without parsed body");
10789
+ logger25.debug({ error }, "Failed to parse JSON body, continuing without parsed body");
10778
10790
  }
10779
10791
  }
10780
10792
  return next();
@@ -10825,8 +10837,8 @@ function createExecutionHono(serverConfig, credentialStores) {
10825
10837
  if (!isExpectedError) {
10826
10838
  const errorMessage = err instanceof Error ? err.message : String(err);
10827
10839
  const errorStack = err instanceof Error ? err.stack : void 0;
10828
- if (logger24) {
10829
- logger24.error(
10840
+ if (logger25) {
10841
+ logger25.error(
10830
10842
  {
10831
10843
  error: err,
10832
10844
  message: errorMessage,
@@ -10838,8 +10850,8 @@ function createExecutionHono(serverConfig, credentialStores) {
10838
10850
  );
10839
10851
  }
10840
10852
  } else {
10841
- if (logger24) {
10842
- logger24.error(
10853
+ if (logger25) {
10854
+ logger25.error(
10843
10855
  {
10844
10856
  error: err,
10845
10857
  path: c.req.path,
@@ -10856,8 +10868,8 @@ function createExecutionHono(serverConfig, credentialStores) {
10856
10868
  const response = err.getResponse();
10857
10869
  return response;
10858
10870
  } catch (responseError) {
10859
- if (logger24) {
10860
- logger24.error({ error: responseError }, "Error while handling HTTPException response");
10871
+ if (logger25) {
10872
+ logger25.error({ error: responseError }, "Error while handling HTTPException response");
10861
10873
  }
10862
10874
  }
10863
10875
  }
@@ -10891,7 +10903,7 @@ function createExecutionHono(serverConfig, credentialStores) {
10891
10903
  app6.use("*", async (c, next) => {
10892
10904
  const executionContext = c.get("executionContext");
10893
10905
  if (!executionContext) {
10894
- logger24.debug({}, "Empty execution context");
10906
+ logger25.debug({}, "Empty execution context");
10895
10907
  return next();
10896
10908
  }
10897
10909
  const { tenantId, projectId, graphId } = executionContext;
@@ -10900,7 +10912,7 @@ function createExecutionHono(serverConfig, credentialStores) {
10900
10912
  if (requestBody) {
10901
10913
  conversationId = requestBody.conversationId;
10902
10914
  if (!conversationId) {
10903
- logger24.debug({ requestBody }, "No conversation ID found in request body");
10915
+ logger25.debug({ requestBody }, "No conversation ID found in request body");
10904
10916
  }
10905
10917
  }
10906
10918
  const entries = Object.fromEntries(
@@ -10915,7 +10927,7 @@ function createExecutionHono(serverConfig, credentialStores) {
10915
10927
  })
10916
10928
  );
10917
10929
  if (!Object.keys(entries).length) {
10918
- logger24.debug({}, "Empty entries for baggage");
10930
+ logger25.debug({}, "Empty entries for baggage");
10919
10931
  return next();
10920
10932
  }
10921
10933
  const bag = Object.entries(entries).reduce(