@inkeep/agents-run-api 0.0.0-dev-20250913012233 → 0.0.0-dev-20250913015248

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 +215 -250
  2. package/dist/index.js +211 -243
  3. package/package.json +2 -2
package/dist/index.cjs CHANGED
@@ -24,7 +24,6 @@ var httpException = require('hono/http-exception');
24
24
  var requestId = require('hono/request-id');
25
25
  var honoPino = require('hono-pino');
26
26
  var pino = require('pino');
27
- var async_hooks = require('async_hooks');
28
27
  var factory = require('hono/factory');
29
28
  var swaggerUi = require('@hono/swagger-ui');
30
29
  var streaming = require('hono/streaming');
@@ -363,40 +362,6 @@ var sdk = new sdkNode.NodeSDK({
363
362
  });
364
363
  sdk.start();
365
364
 
366
- // src/logger.ts
367
- init_env();
368
- var isDevelopment = env.ENVIRONMENT === "development";
369
- var loggerConfig = {
370
- level: env.LOG_LEVEL,
371
- serializers: {
372
- obj: (value) => ({ ...value })
373
- },
374
- redact: ["req.headers.authorization", 'req.headers["x-inkeep-admin-authentication"]'],
375
- // Only use pino-pretty in development
376
- ...isDevelopment && {
377
- transport: {
378
- target: "pino-pretty",
379
- options: {
380
- sync: true,
381
- destination: 1,
382
- // stdout
383
- colorize: true,
384
- translateTime: "SYS:standard"
385
- }
386
- }
387
- }
388
- };
389
- var logger = pino.pino(loggerConfig);
390
- var asyncLocalStorage = new async_hooks.AsyncLocalStorage();
391
- function getLogger(name) {
392
- const store = asyncLocalStorage.getStore();
393
- const reqId = store?.get("requestId") || void 0;
394
- if (!reqId) {
395
- return logger.child({ name });
396
- }
397
- return logger.child({ reqId, name });
398
- }
399
-
400
365
  // src/middleware/api-key-auth.ts
401
366
  init_dbClient();
402
367
  init_env();
@@ -415,7 +380,7 @@ function createExecutionContext(params) {
415
380
  }
416
381
 
417
382
  // src/middleware/api-key-auth.ts
418
- var logger2 = agentsCore.getLogger("env-key-auth");
383
+ var logger = agentsCore.getLogger("env-key-auth");
419
384
  var apiKeyAuth = () => factory.createMiddleware(async (c, next) => {
420
385
  if (c.req.method === "OPTIONS") {
421
386
  await next();
@@ -432,7 +397,7 @@ var apiKeyAuth = () => factory.createMiddleware(async (c, next) => {
432
397
  if (authHeader?.startsWith("Bearer ")) {
433
398
  try {
434
399
  executionContext = await extractContextFromApiKey(authHeader.substring(7));
435
- logger2.info({}, "Development/test environment - API key authenticated successfully");
400
+ logger.info({}, "Development/test environment - API key authenticated successfully");
436
401
  } catch {
437
402
  executionContext = createExecutionContext({
438
403
  apiKey: "development",
@@ -443,7 +408,7 @@ var apiKeyAuth = () => factory.createMiddleware(async (c, next) => {
443
408
  baseUrl,
444
409
  agentId
445
410
  });
446
- logger2.info(
411
+ logger.info(
447
412
  {},
448
413
  "Development/test environment - fallback to default context due to invalid API key"
449
414
  );
@@ -458,7 +423,7 @@ var apiKeyAuth = () => factory.createMiddleware(async (c, next) => {
458
423
  baseUrl,
459
424
  agentId
460
425
  });
461
- logger2.info(
426
+ logger.info(
462
427
  {},
463
428
  "Development/test environment - no API key provided, using default context"
464
429
  );
@@ -490,13 +455,13 @@ var apiKeyAuth = () => factory.createMiddleware(async (c, next) => {
490
455
  agentId
491
456
  });
492
457
  c.set("executionContext", executionContext);
493
- logger2.info({}, "Bypass secret authenticated successfully");
458
+ logger.info({}, "Bypass secret authenticated successfully");
494
459
  await next();
495
460
  return;
496
461
  } else if (apiKey) {
497
462
  const executionContext = await extractContextFromApiKey(apiKey);
498
463
  c.set("executionContext", executionContext);
499
- logger2.info({}, "API key authenticated successfully");
464
+ logger.info({}, "API key authenticated successfully");
500
465
  await next();
501
466
  return;
502
467
  } else {
@@ -513,7 +478,7 @@ var apiKeyAuth = () => factory.createMiddleware(async (c, next) => {
513
478
  try {
514
479
  const executionContext = await extractContextFromApiKey(apiKey);
515
480
  c.set("executionContext", executionContext);
516
- logger2.debug(
481
+ logger.debug(
517
482
  {
518
483
  tenantId: executionContext.tenantId,
519
484
  projectId: executionContext.projectId,
@@ -526,7 +491,7 @@ var apiKeyAuth = () => factory.createMiddleware(async (c, next) => {
526
491
  if (error instanceof httpException.HTTPException) {
527
492
  throw error;
528
493
  }
529
- logger2.error({ error }, "API key authentication error");
494
+ logger.error({ error }, "API key authentication error");
530
495
  throw new httpException.HTTPException(500, {
531
496
  message: "Authentication failed"
532
497
  });
@@ -585,7 +550,7 @@ function setupOpenAPIRoutes(app6) {
585
550
 
586
551
  // src/a2a/handlers.ts
587
552
  init_dbClient();
588
- var logger3 = getLogger("a2aHandler");
553
+ var logger2 = agentsCore.getLogger("a2aHandler");
589
554
  async function a2aHandler(c, agent) {
590
555
  try {
591
556
  const rpcRequest = await c.req.json();
@@ -687,7 +652,7 @@ async function handleMessageSend(c, agent, request) {
687
652
  messageId: task.id,
688
653
  kind: "message"
689
654
  });
690
- logger3.warn(
655
+ logger2.warn(
691
656
  {
692
657
  taskId: task.id,
693
658
  agentId: agent.agentId,
@@ -697,7 +662,7 @@ async function handleMessageSend(c, agent, request) {
697
662
  );
698
663
  }
699
664
  } catch (error) {
700
- logger3.error({ error, taskId: task.id }, "Failed to serialize message");
665
+ logger2.error({ error, taskId: task.id }, "Failed to serialize message");
701
666
  JSON.stringify({
702
667
  error: "Failed to serialize message",
703
668
  taskId: task.id,
@@ -705,7 +670,7 @@ async function handleMessageSend(c, agent, request) {
705
670
  parts: [{ text: "Error in delegation", kind: "text" }]
706
671
  });
707
672
  }
708
- logger3.info(
673
+ logger2.info(
709
674
  {
710
675
  originalContextId: params.message.contextId,
711
676
  taskContextId: task.context?.conversationId,
@@ -734,7 +699,7 @@ async function handleMessageSend(c, agent, request) {
734
699
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
735
700
  updatedAt: (/* @__PURE__ */ new Date()).toISOString()
736
701
  });
737
- logger3.info({ metadata: params.message.metadata }, "message metadata");
702
+ logger2.info({ metadata: params.message.metadata }, "message metadata");
738
703
  if (params.message.metadata?.fromAgentId || params.message.metadata?.fromExternalAgentId) {
739
704
  const messageText = params.message.parts.filter((part) => part.kind === "text" && "text" in part && part.text).map((part) => part.text).join(" ");
740
705
  try {
@@ -759,7 +724,7 @@ async function handleMessageSend(c, agent, request) {
759
724
  messageData.toAgentId = agent.agentId;
760
725
  }
761
726
  await agentsCore.createMessage(dbClient_default)(messageData);
762
- logger3.info(
727
+ logger2.info(
763
728
  {
764
729
  fromAgentId: params.message.metadata.fromAgentId,
765
730
  fromExternalAgentId: params.message.metadata.fromExternalAgentId,
@@ -771,7 +736,7 @@ async function handleMessageSend(c, agent, request) {
771
736
  "A2A message stored in database"
772
737
  );
773
738
  } catch (error) {
774
- logger3.error(
739
+ logger2.error(
775
740
  {
776
741
  error,
777
742
  fromAgentId: params.message.metadata.fromAgentId,
@@ -808,7 +773,7 @@ async function handleMessageSend(c, agent, request) {
808
773
  (part) => part.kind === "data" && part.data && typeof part.data === "object" && part.data.type === "transfer"
809
774
  );
810
775
  if (transferPart && transferPart.kind === "data" && transferPart.data) {
811
- logger3.info({ transferPart }, "transferPart");
776
+ logger2.info({ transferPart }, "transferPart");
812
777
  return c.json({
813
778
  jsonrpc: "2.0",
814
779
  result: {
@@ -1233,10 +1198,10 @@ function statusUpdateOp(ctx) {
1233
1198
  ctx
1234
1199
  };
1235
1200
  }
1236
- var logger4 = getLogger("DataComponentSchema");
1201
+ var logger3 = agentsCore.getLogger("DataComponentSchema");
1237
1202
  function jsonSchemaToZod(jsonSchema) {
1238
1203
  if (!jsonSchema || typeof jsonSchema !== "object") {
1239
- logger4.warn({ jsonSchema }, "Invalid JSON schema provided, using string fallback");
1204
+ logger3.warn({ jsonSchema }, "Invalid JSON schema provided, using string fallback");
1240
1205
  return z5.z.string();
1241
1206
  }
1242
1207
  switch (jsonSchema.type) {
@@ -1263,7 +1228,7 @@ function jsonSchemaToZod(jsonSchema) {
1263
1228
  case "null":
1264
1229
  return z5.z.null();
1265
1230
  default:
1266
- logger4.warn(
1231
+ logger3.warn(
1267
1232
  {
1268
1233
  unsupportedType: jsonSchema.type,
1269
1234
  schema: jsonSchema
@@ -1275,7 +1240,7 @@ function jsonSchemaToZod(jsonSchema) {
1275
1240
  }
1276
1241
 
1277
1242
  // src/utils/artifact-component-schema.ts
1278
- getLogger("ArtifactComponentSchema");
1243
+ agentsCore.getLogger("ArtifactComponentSchema");
1279
1244
  var _ArtifactReferenceSchema = class _ArtifactReferenceSchema {
1280
1245
  /**
1281
1246
  * Get the standard Zod schema for artifact reference components
@@ -1317,7 +1282,7 @@ __publicField(_ArtifactReferenceSchema, "ARTIFACT_PROPS_SCHEMA", {
1317
1282
  required: ["artifact_id", "task_id"]
1318
1283
  });
1319
1284
  var ArtifactReferenceSchema = _ArtifactReferenceSchema;
1320
- var logger5 = getLogger("ModelFactory");
1285
+ var logger4 = agentsCore.getLogger("ModelFactory");
1321
1286
  var _ModelFactory = class _ModelFactory {
1322
1287
  /**
1323
1288
  * Create a language model instance from configuration
@@ -1332,7 +1297,7 @@ var _ModelFactory = class _ModelFactory {
1332
1297
  const modelSettings = config2;
1333
1298
  const modelString = modelSettings.model.trim();
1334
1299
  const { provider, modelName } = _ModelFactory.parseModelString(modelString);
1335
- logger5.debug(
1300
+ logger4.debug(
1336
1301
  {
1337
1302
  provider,
1338
1303
  model: modelName,
@@ -1353,7 +1318,7 @@ var _ModelFactory = class _ModelFactory {
1353
1318
  );
1354
1319
  }
1355
1320
  } catch (error) {
1356
- logger5.error(
1321
+ logger4.error(
1357
1322
  {
1358
1323
  provider,
1359
1324
  model: modelName,
@@ -1376,7 +1341,7 @@ var _ModelFactory = class _ModelFactory {
1376
1341
  const [provider, ...modelParts] = modelString.split("/");
1377
1342
  const normalizedProvider = provider.toLowerCase();
1378
1343
  if (!_ModelFactory.SUPPORTED_PROVIDERS.includes(normalizedProvider)) {
1379
- logger5.warn(
1344
+ logger4.warn(
1380
1345
  { provider: normalizedProvider, modelName: modelParts.join("/") },
1381
1346
  "Unsupported provider detected, falling back to anthropic"
1382
1347
  );
@@ -1405,14 +1370,14 @@ var _ModelFactory = class _ModelFactory {
1405
1370
  anthropicConfig.baseURL = providerOptions.baseUrl || providerOptions.baseURL;
1406
1371
  }
1407
1372
  if (providerOptions?.gateway) {
1408
- logger5.info(
1373
+ logger4.info(
1409
1374
  { gateway: providerOptions.gateway },
1410
1375
  "Setting up AI Gateway for Anthropic model"
1411
1376
  );
1412
1377
  Object.assign(anthropicConfig, providerOptions.gateway);
1413
1378
  }
1414
1379
  if (Object.keys(anthropicConfig).length > 0) {
1415
- logger5.info({ config: anthropicConfig }, "Applying custom Anthropic provider configuration");
1380
+ logger4.info({ config: anthropicConfig }, "Applying custom Anthropic provider configuration");
1416
1381
  const provider = anthropic.createAnthropic(anthropicConfig);
1417
1382
  return provider(modelName);
1418
1383
  }
@@ -1427,11 +1392,11 @@ var _ModelFactory = class _ModelFactory {
1427
1392
  openaiConfig.baseURL = providerOptions.baseUrl || providerOptions.baseURL;
1428
1393
  }
1429
1394
  if (providerOptions?.gateway) {
1430
- logger5.info({ gateway: providerOptions.gateway }, "Setting up AI Gateway for OpenAI model");
1395
+ logger4.info({ gateway: providerOptions.gateway }, "Setting up AI Gateway for OpenAI model");
1431
1396
  Object.assign(openaiConfig, providerOptions.gateway);
1432
1397
  }
1433
1398
  if (Object.keys(openaiConfig).length > 0) {
1434
- logger5.info({ config: openaiConfig }, "Applying custom OpenAI provider configuration");
1399
+ logger4.info({ config: openaiConfig }, "Applying custom OpenAI provider configuration");
1435
1400
  const provider = openai.createOpenAI(openaiConfig);
1436
1401
  return provider(modelName);
1437
1402
  }
@@ -1525,7 +1490,7 @@ function unregisterStreamHelper(requestId2) {
1525
1490
  }
1526
1491
 
1527
1492
  // src/utils/graph-session.ts
1528
- var logger6 = getLogger("GraphSession");
1493
+ var logger5 = agentsCore.getLogger("GraphSession");
1529
1494
  var GraphSession = class {
1530
1495
  // Track scheduled timeouts for cleanup
1531
1496
  constructor(sessionId, messageId, graphId, tenantId, projectId) {
@@ -1549,7 +1514,7 @@ var GraphSession = class {
1549
1514
  __publicField(this, "MAX_PENDING_ARTIFACTS", 100);
1550
1515
  // Prevent unbounded growth
1551
1516
  __publicField(this, "scheduledTimeouts");
1552
- logger6.debug({ sessionId, messageId, graphId }, "GraphSession created");
1517
+ logger5.debug({ sessionId, messageId, graphId }, "GraphSession created");
1553
1518
  }
1554
1519
  /**
1555
1520
  * Initialize status updates for this session
@@ -1571,7 +1536,7 @@ var GraphSession = class {
1571
1536
  if (this.statusUpdateState.config.timeInSeconds) {
1572
1537
  this.statusUpdateTimer = setInterval(async () => {
1573
1538
  if (!this.statusUpdateState || this.isEnded) {
1574
- logger6.debug(
1539
+ logger5.debug(
1575
1540
  { sessionId: this.sessionId },
1576
1541
  "Timer triggered but session already cleaned up or ended"
1577
1542
  );
@@ -1583,7 +1548,7 @@ var GraphSession = class {
1583
1548
  }
1584
1549
  await this.checkAndSendTimeBasedUpdate();
1585
1550
  }, this.statusUpdateState.config.timeInSeconds * 1e3);
1586
- logger6.info(
1551
+ logger5.info(
1587
1552
  {
1588
1553
  sessionId: this.sessionId,
1589
1554
  intervalMs: this.statusUpdateState.config.timeInSeconds * 1e3
@@ -1597,7 +1562,7 @@ var GraphSession = class {
1597
1562
  */
1598
1563
  recordEvent(eventType, agentId, data) {
1599
1564
  if (this.isEnded) {
1600
- logger6.debug(
1565
+ logger5.debug(
1601
1566
  {
1602
1567
  sessionId: this.sessionId,
1603
1568
  eventType,
@@ -1617,7 +1582,7 @@ var GraphSession = class {
1617
1582
  if (eventType === "artifact_saved" && data.pendingGeneration) {
1618
1583
  const artifactId = data.artifactId;
1619
1584
  if (this.pendingArtifacts.size >= this.MAX_PENDING_ARTIFACTS) {
1620
- logger6.warn(
1585
+ logger5.warn(
1621
1586
  {
1622
1587
  sessionId: this.sessionId,
1623
1588
  artifactId,
@@ -1638,7 +1603,7 @@ var GraphSession = class {
1638
1603
  this.artifactProcessingErrors.set(artifactId, errorCount);
1639
1604
  if (errorCount >= this.MAX_ARTIFACT_RETRIES) {
1640
1605
  this.pendingArtifacts.delete(artifactId);
1641
- logger6.error(
1606
+ logger5.error(
1642
1607
  {
1643
1608
  sessionId: this.sessionId,
1644
1609
  artifactId,
@@ -1650,7 +1615,7 @@ var GraphSession = class {
1650
1615
  "Artifact processing failed after max retries, giving up"
1651
1616
  );
1652
1617
  } else {
1653
- logger6.warn(
1618
+ logger5.warn(
1654
1619
  {
1655
1620
  sessionId: this.sessionId,
1656
1621
  artifactId,
@@ -1672,14 +1637,14 @@ var GraphSession = class {
1672
1637
  */
1673
1638
  checkStatusUpdates() {
1674
1639
  if (this.isEnded) {
1675
- logger6.debug(
1640
+ logger5.debug(
1676
1641
  { sessionId: this.sessionId },
1677
1642
  "Session has ended - skipping status update check"
1678
1643
  );
1679
1644
  return;
1680
1645
  }
1681
1646
  if (!this.statusUpdateState) {
1682
- logger6.debug({ sessionId: this.sessionId }, "No status update state - skipping check");
1647
+ logger5.debug({ sessionId: this.sessionId }, "No status update state - skipping check");
1683
1648
  return;
1684
1649
  }
1685
1650
  const statusUpdateState = this.statusUpdateState;
@@ -1690,11 +1655,11 @@ var GraphSession = class {
1690
1655
  */
1691
1656
  async checkAndSendTimeBasedUpdate() {
1692
1657
  if (this.isEnded) {
1693
- logger6.debug({ sessionId: this.sessionId }, "Session has ended - skipping time-based update");
1658
+ logger5.debug({ sessionId: this.sessionId }, "Session has ended - skipping time-based update");
1694
1659
  return;
1695
1660
  }
1696
1661
  if (!this.statusUpdateState) {
1697
- logger6.debug(
1662
+ logger5.debug(
1698
1663
  { sessionId: this.sessionId },
1699
1664
  "No status updates configured for time-based check"
1700
1665
  );
@@ -1707,7 +1672,7 @@ var GraphSession = class {
1707
1672
  try {
1708
1673
  await this.generateAndSendUpdate();
1709
1674
  } catch (error) {
1710
- logger6.error(
1675
+ logger5.error(
1711
1676
  {
1712
1677
  sessionId: this.sessionId,
1713
1678
  error: error instanceof Error ? error.message : "Unknown error"
@@ -1800,29 +1765,29 @@ var GraphSession = class {
1800
1765
  */
1801
1766
  async generateAndSendUpdate() {
1802
1767
  if (this.isEnded) {
1803
- logger6.debug({ sessionId: this.sessionId }, "Session has ended - not generating update");
1768
+ logger5.debug({ sessionId: this.sessionId }, "Session has ended - not generating update");
1804
1769
  return;
1805
1770
  }
1806
1771
  if (this.isTextStreaming) {
1807
- logger6.debug(
1772
+ logger5.debug(
1808
1773
  { sessionId: this.sessionId },
1809
1774
  "Text is currently streaming - skipping status update"
1810
1775
  );
1811
1776
  return;
1812
1777
  }
1813
1778
  if (this.isGeneratingUpdate) {
1814
- logger6.debug(
1779
+ logger5.debug(
1815
1780
  { sessionId: this.sessionId },
1816
1781
  "Update already in progress - skipping duplicate generation"
1817
1782
  );
1818
1783
  return;
1819
1784
  }
1820
1785
  if (!this.statusUpdateState) {
1821
- logger6.warn({ sessionId: this.sessionId }, "No status update state - cannot generate update");
1786
+ logger5.warn({ sessionId: this.sessionId }, "No status update state - cannot generate update");
1822
1787
  return;
1823
1788
  }
1824
1789
  if (!this.graphId) {
1825
- logger6.warn({ sessionId: this.sessionId }, "No graph ID - cannot generate update");
1790
+ logger5.warn({ sessionId: this.sessionId }, "No graph ID - cannot generate update");
1826
1791
  return;
1827
1792
  }
1828
1793
  const newEventCount = this.events.length - this.statusUpdateState.lastEventCount;
@@ -1835,7 +1800,7 @@ var GraphSession = class {
1835
1800
  try {
1836
1801
  const streamHelper = getStreamHelper(this.sessionId);
1837
1802
  if (!streamHelper) {
1838
- logger6.warn(
1803
+ logger5.warn(
1839
1804
  { sessionId: this.sessionId },
1840
1805
  "No stream helper found - cannot send status update"
1841
1806
  );
@@ -1856,7 +1821,7 @@ var GraphSession = class {
1856
1821
  if (result.operations && result.operations.length > 0) {
1857
1822
  for (const op of result.operations) {
1858
1823
  if (!op || !op.type || !op.data || Object.keys(op.data).length === 0) {
1859
- logger6.warn(
1824
+ logger5.warn(
1860
1825
  {
1861
1826
  sessionId: this.sessionId,
1862
1827
  operation: op
@@ -1909,7 +1874,7 @@ var GraphSession = class {
1909
1874
  this.previousSummaries.shift();
1910
1875
  }
1911
1876
  if (!operation || !operation.type || !operation.ctx) {
1912
- logger6.warn(
1877
+ logger5.warn(
1913
1878
  {
1914
1879
  sessionId: this.sessionId,
1915
1880
  operation
@@ -1924,7 +1889,7 @@ var GraphSession = class {
1924
1889
  this.statusUpdateState.lastEventCount = this.events.length;
1925
1890
  }
1926
1891
  } catch (error) {
1927
- logger6.error(
1892
+ logger5.error(
1928
1893
  {
1929
1894
  sessionId: this.sessionId,
1930
1895
  error: error instanceof Error ? error.message : "Unknown error",
@@ -1962,7 +1927,7 @@ var GraphSession = class {
1962
1927
  this.releaseUpdateLock();
1963
1928
  }
1964
1929
  } catch (error) {
1965
- logger6.error(
1930
+ logger5.error(
1966
1931
  {
1967
1932
  sessionId: this.sessionId,
1968
1933
  error: error instanceof Error ? error.message : "Unknown error"
@@ -2039,7 +2004,7 @@ User's Question/Context:
2039
2004
  ${conversationHistory}
2040
2005
  ` : "";
2041
2006
  } catch (error) {
2042
- logger6.warn(
2007
+ logger5.warn(
2043
2008
  { sessionId: this.sessionId, error },
2044
2009
  "Failed to fetch conversation history for status update"
2045
2010
  );
@@ -2091,7 +2056,7 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
2091
2056
  return text.trim();
2092
2057
  } catch (error) {
2093
2058
  agentsCore.setSpanWithError(span, error);
2094
- logger6.error({ error }, "Failed to generate summary, using fallback");
2059
+ logger5.error({ error }, "Failed to generate summary, using fallback");
2095
2060
  return this.generateFallbackSummary(newEvents, elapsedTime);
2096
2061
  } finally {
2097
2062
  span.end();
@@ -2137,7 +2102,7 @@ User's Question/Context:
2137
2102
  ${conversationHistory}
2138
2103
  ` : "";
2139
2104
  } catch (error) {
2140
- logger6.warn(
2105
+ logger5.warn(
2141
2106
  { sessionId: this.sessionId, error },
2142
2107
  "Failed to fetch conversation history for structured status update"
2143
2108
  );
@@ -2236,7 +2201,7 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
2236
2201
  return { operations };
2237
2202
  } catch (error) {
2238
2203
  agentsCore.setSpanWithError(span, error);
2239
- logger6.error({ error }, "Failed to generate structured update, using fallback");
2204
+ logger5.error({ error }, "Failed to generate structured update, using fallback");
2240
2205
  return { operations: [] };
2241
2206
  } finally {
2242
2207
  span.end();
@@ -2563,7 +2528,7 @@ Make it specific and relevant.`;
2563
2528
  taskId: artifactData.taskId,
2564
2529
  artifacts: [artifactToSave]
2565
2530
  });
2566
- logger6.info(
2531
+ logger5.info(
2567
2532
  {
2568
2533
  sessionId: this.sessionId,
2569
2534
  artifactId: artifactData.artifactId,
@@ -2580,7 +2545,7 @@ Make it specific and relevant.`;
2580
2545
  span.setStatus({ code: api.SpanStatusCode.OK });
2581
2546
  } catch (error) {
2582
2547
  agentsCore.setSpanWithError(span, error);
2583
- logger6.error(
2548
+ logger5.error(
2584
2549
  {
2585
2550
  sessionId: this.sessionId,
2586
2551
  artifactId: artifactData.artifactId,
@@ -2616,7 +2581,7 @@ Make it specific and relevant.`;
2616
2581
  taskId: artifactData.taskId,
2617
2582
  artifacts: [fallbackArtifact]
2618
2583
  });
2619
- logger6.info(
2584
+ logger5.info(
2620
2585
  {
2621
2586
  sessionId: this.sessionId,
2622
2587
  artifactId: artifactData.artifactId
@@ -2625,7 +2590,7 @@ Make it specific and relevant.`;
2625
2590
  );
2626
2591
  }
2627
2592
  } catch (fallbackError) {
2628
- logger6.error(
2593
+ logger5.error(
2629
2594
  {
2630
2595
  sessionId: this.sessionId,
2631
2596
  artifactId: artifactData.artifactId,
@@ -2652,7 +2617,7 @@ var GraphSessionManager = class {
2652
2617
  const sessionId = messageId;
2653
2618
  const session = new GraphSession(sessionId, messageId, graphId, tenantId, projectId);
2654
2619
  this.sessions.set(sessionId, session);
2655
- logger6.info({ sessionId, messageId, graphId, tenantId, projectId }, "GraphSession created");
2620
+ logger5.info({ sessionId, messageId, graphId, tenantId, projectId }, "GraphSession created");
2656
2621
  return sessionId;
2657
2622
  }
2658
2623
  /**
@@ -2663,7 +2628,7 @@ var GraphSessionManager = class {
2663
2628
  if (session) {
2664
2629
  session.initializeStatusUpdates(config2, summarizerModel);
2665
2630
  } else {
2666
- logger6.error(
2631
+ logger5.error(
2667
2632
  {
2668
2633
  sessionId,
2669
2634
  availableSessions: Array.from(this.sessions.keys())
@@ -2684,7 +2649,7 @@ var GraphSessionManager = class {
2684
2649
  recordEvent(sessionId, eventType, agentId, data) {
2685
2650
  const session = this.sessions.get(sessionId);
2686
2651
  if (!session) {
2687
- logger6.warn({ sessionId }, "Attempted to record event in non-existent session");
2652
+ logger5.warn({ sessionId }, "Attempted to record event in non-existent session");
2688
2653
  return;
2689
2654
  }
2690
2655
  session.recordEvent(eventType, agentId, data);
@@ -2695,12 +2660,12 @@ var GraphSessionManager = class {
2695
2660
  endSession(sessionId) {
2696
2661
  const session = this.sessions.get(sessionId);
2697
2662
  if (!session) {
2698
- logger6.warn({ sessionId }, "Attempted to end non-existent session");
2663
+ logger5.warn({ sessionId }, "Attempted to end non-existent session");
2699
2664
  return [];
2700
2665
  }
2701
2666
  const events = session.getEvents();
2702
2667
  const summary = session.getSummary();
2703
- logger6.info({ sessionId, summary }, "GraphSession ended");
2668
+ logger5.info({ sessionId, summary }, "GraphSession ended");
2704
2669
  session.cleanup();
2705
2670
  this.sessions.delete(sessionId);
2706
2671
  return events;
@@ -2729,7 +2694,7 @@ var graphSessionManager = new GraphSessionManager();
2729
2694
 
2730
2695
  // src/utils/artifact-parser.ts
2731
2696
  init_dbClient();
2732
- var logger7 = getLogger("ArtifactParser");
2697
+ var logger6 = agentsCore.getLogger("ArtifactParser");
2733
2698
  var _ArtifactParser = class _ArtifactParser {
2734
2699
  constructor(tenantId) {
2735
2700
  this.tenantId = tenantId;
@@ -2795,7 +2760,7 @@ var _ArtifactParser = class _ArtifactParser {
2795
2760
  id: taskId
2796
2761
  });
2797
2762
  if (!task) {
2798
- logger7.warn({ taskId }, "Task not found when fetching artifacts");
2763
+ logger6.warn({ taskId }, "Task not found when fetching artifacts");
2799
2764
  continue;
2800
2765
  }
2801
2766
  const taskArtifacts = await agentsCore.getLedgerArtifacts(dbClient_default)({
@@ -2807,9 +2772,9 @@ var _ArtifactParser = class _ArtifactParser {
2807
2772
  artifacts.set(key, artifact);
2808
2773
  }
2809
2774
  }
2810
- logger7.debug({ contextId, count: artifacts.size }, "Loaded context artifacts");
2775
+ logger6.debug({ contextId, count: artifacts.size }, "Loaded context artifacts");
2811
2776
  } catch (error) {
2812
- logger7.error({ error, contextId }, "Error loading context artifacts");
2777
+ logger6.error({ error, contextId }, "Error loading context artifacts");
2813
2778
  }
2814
2779
  return artifacts;
2815
2780
  }
@@ -2912,7 +2877,7 @@ var _ArtifactParser = class _ArtifactParser {
2912
2877
  id: taskId
2913
2878
  });
2914
2879
  if (!task) {
2915
- logger7.warn({ taskId }, "Task not found when fetching artifact");
2880
+ logger6.warn({ taskId }, "Task not found when fetching artifact");
2916
2881
  return null;
2917
2882
  }
2918
2883
  const artifacts = await agentsCore.getLedgerArtifacts(dbClient_default)({
@@ -2924,7 +2889,7 @@ var _ArtifactParser = class _ArtifactParser {
2924
2889
  return this.formatArtifactData(artifacts[0], artifactId, taskId);
2925
2890
  }
2926
2891
  } catch (error) {
2927
- logger7.warn({ artifactId, taskId, error }, "Failed to fetch artifact");
2892
+ logger6.warn({ artifactId, taskId, error }, "Failed to fetch artifact");
2928
2893
  }
2929
2894
  return null;
2930
2895
  }
@@ -2964,7 +2929,7 @@ __publicField(_ArtifactParser, "INCOMPLETE_ARTIFACT_REGEX", /<(a(r(t(i(f(a(c(t(:
2964
2929
  var ArtifactParser = _ArtifactParser;
2965
2930
 
2966
2931
  // src/utils/incremental-stream-parser.ts
2967
- var logger8 = getLogger("IncrementalStreamParser");
2932
+ var logger7 = agentsCore.getLogger("IncrementalStreamParser");
2968
2933
  var IncrementalStreamParser = class {
2969
2934
  constructor(streamHelper, tenantId, contextId) {
2970
2935
  __publicField(this, "buffer", "");
@@ -3024,13 +2989,13 @@ var IncrementalStreamParser = class {
3024
2989
  if (part.type === "tool-call-delta" && part.toolName === targetToolName) {
3025
2990
  const delta = part.argsTextDelta || "";
3026
2991
  if (jsonBuffer.length + delta.length > MAX_BUFFER_SIZE) {
3027
- logger8.warn("JSON buffer exceeded maximum size, truncating");
2992
+ logger7.warn("JSON buffer exceeded maximum size, truncating");
3028
2993
  jsonBuffer = jsonBuffer.slice(-MAX_BUFFER_SIZE / 2);
3029
2994
  }
3030
2995
  jsonBuffer += delta;
3031
2996
  for (const char of delta) {
3032
2997
  if (componentBuffer.length > MAX_BUFFER_SIZE) {
3033
- logger8.warn("Component buffer exceeded maximum size, resetting");
2998
+ logger7.warn("Component buffer exceeded maximum size, resetting");
3034
2999
  componentBuffer = "";
3035
3000
  depth = 0;
3036
3001
  continue;
@@ -3045,7 +3010,7 @@ var IncrementalStreamParser = class {
3045
3010
  if (componentMatch) {
3046
3011
  const MAX_COMPONENT_SIZE = 1024 * 1024;
3047
3012
  if (componentMatch[0].length > MAX_COMPONENT_SIZE) {
3048
- logger8.warn(
3013
+ logger7.warn(
3049
3014
  {
3050
3015
  size: componentMatch[0].length,
3051
3016
  maxSize: MAX_COMPONENT_SIZE
@@ -3058,7 +3023,7 @@ var IncrementalStreamParser = class {
3058
3023
  try {
3059
3024
  const component = JSON.parse(componentMatch[0]);
3060
3025
  if (typeof component !== "object" || !component.id) {
3061
- logger8.warn("Invalid component structure, skipping");
3026
+ logger7.warn("Invalid component structure, skipping");
3062
3027
  componentBuffer = "";
3063
3028
  continue;
3064
3029
  }
@@ -3071,7 +3036,7 @@ var IncrementalStreamParser = class {
3071
3036
  componentsStreamed++;
3072
3037
  componentBuffer = "";
3073
3038
  } catch (e) {
3074
- logger8.debug({ error: e }, "Failed to parse component, continuing to accumulate");
3039
+ logger7.debug({ error: e }, "Failed to parse component, continuing to accumulate");
3075
3040
  }
3076
3041
  }
3077
3042
  }
@@ -3088,7 +3053,7 @@ var IncrementalStreamParser = class {
3088
3053
  break;
3089
3054
  }
3090
3055
  }
3091
- logger8.debug({ componentsStreamed }, "Finished streaming components");
3056
+ logger7.debug({ componentsStreamed }, "Finished streaming components");
3092
3057
  }
3093
3058
  /**
3094
3059
  * Legacy method for backward compatibility - defaults to text processing
@@ -3232,7 +3197,7 @@ var IncrementalStreamParser = class {
3232
3197
  };
3233
3198
 
3234
3199
  // src/utils/response-formatter.ts
3235
- var logger9 = getLogger("ResponseFormatter");
3200
+ var logger8 = agentsCore.getLogger("ResponseFormatter");
3236
3201
  var ResponseFormatter = class {
3237
3202
  constructor(tenantId) {
3238
3203
  __publicField(this, "artifactParser");
@@ -3263,7 +3228,7 @@ var ResponseFormatter = class {
3263
3228
  return { parts };
3264
3229
  } catch (error) {
3265
3230
  agentsCore.setSpanWithError(span, error);
3266
- logger9.error({ error, responseObject }, "Error formatting object response");
3231
+ logger8.error({ error, responseObject }, "Error formatting object response");
3267
3232
  return {
3268
3233
  parts: [{ kind: "data", data: responseObject }]
3269
3234
  };
@@ -3314,7 +3279,7 @@ var ResponseFormatter = class {
3314
3279
  return { parts };
3315
3280
  } catch (error) {
3316
3281
  agentsCore.setSpanWithError(span, error);
3317
- logger9.error({ error, responseText }, "Error formatting response");
3282
+ logger8.error({ error, responseText }, "Error formatting response");
3318
3283
  return { text: responseText };
3319
3284
  } finally {
3320
3285
  span.end();
@@ -3359,7 +3324,7 @@ var ResponseFormatter = class {
3359
3324
  }
3360
3325
  }
3361
3326
  };
3362
- var logger10 = getLogger("ToolSessionManager");
3327
+ var logger9 = agentsCore.getLogger("ToolSessionManager");
3363
3328
  var _ToolSessionManager = class _ToolSessionManager {
3364
3329
  // 5 minutes
3365
3330
  constructor() {
@@ -3388,7 +3353,7 @@ var _ToolSessionManager = class _ToolSessionManager {
3388
3353
  createdAt: Date.now()
3389
3354
  };
3390
3355
  this.sessions.set(sessionId, session);
3391
- logger10.debug({ sessionId, tenantId, contextId, taskId }, "Created tool session");
3356
+ logger9.debug({ sessionId, tenantId, contextId, taskId }, "Created tool session");
3392
3357
  return sessionId;
3393
3358
  }
3394
3359
  /**
@@ -3397,7 +3362,7 @@ var _ToolSessionManager = class _ToolSessionManager {
3397
3362
  recordToolResult(sessionId, toolResult) {
3398
3363
  const session = this.sessions.get(sessionId);
3399
3364
  if (!session) {
3400
- logger10.warn(
3365
+ logger9.warn(
3401
3366
  { sessionId, toolCallId: toolResult.toolCallId },
3402
3367
  "Tool result recorded for unknown session"
3403
3368
  );
@@ -3411,12 +3376,12 @@ var _ToolSessionManager = class _ToolSessionManager {
3411
3376
  getToolResult(sessionId, toolCallId) {
3412
3377
  const session = this.sessions.get(sessionId);
3413
3378
  if (!session) {
3414
- logger10.warn({ sessionId, toolCallId }, "Requested tool result for unknown session");
3379
+ logger9.warn({ sessionId, toolCallId }, "Requested tool result for unknown session");
3415
3380
  return void 0;
3416
3381
  }
3417
3382
  const result = session.toolResults.get(toolCallId);
3418
3383
  if (!result) {
3419
- logger10.warn(
3384
+ logger9.warn(
3420
3385
  {
3421
3386
  sessionId,
3422
3387
  toolCallId,
@@ -3455,10 +3420,10 @@ var _ToolSessionManager = class _ToolSessionManager {
3455
3420
  }
3456
3421
  for (const sessionId of expiredSessions) {
3457
3422
  this.sessions.delete(sessionId);
3458
- logger10.debug({ sessionId }, "Cleaned up expired tool session");
3423
+ logger9.debug({ sessionId }, "Cleaned up expired tool session");
3459
3424
  }
3460
3425
  if (expiredSessions.length > 0) {
3461
- logger10.info({ expiredCount: expiredSessions.length }, "Cleaned up expired tool sessions");
3426
+ logger9.info({ expiredCount: expiredSessions.length }, "Cleaned up expired tool sessions");
3462
3427
  }
3463
3428
  }
3464
3429
  };
@@ -3467,7 +3432,7 @@ var ToolSessionManager = _ToolSessionManager;
3467
3432
  var toolSessionManager = ToolSessionManager.getInstance();
3468
3433
 
3469
3434
  // src/agents/artifactTools.ts
3470
- var logger11 = getLogger("artifactTools");
3435
+ var logger10 = agentsCore.getLogger("artifactTools");
3471
3436
  function buildKeyNestingMap(data, prefix = "", map = /* @__PURE__ */ new Map()) {
3472
3437
  if (typeof data === "object" && data !== null) {
3473
3438
  if (Array.isArray(data)) {
@@ -3688,7 +3653,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
3688
3653
  execute: async ({ toolCallId, baseSelector, propSelectors, ...rest }, _context) => {
3689
3654
  const artifactType = "artifactType" in rest ? rest.artifactType : void 0;
3690
3655
  if (!sessionId) {
3691
- logger11.warn({ toolCallId }, "No session ID provided to save_tool_result");
3656
+ logger10.warn({ toolCallId }, "No session ID provided to save_tool_result");
3692
3657
  return {
3693
3658
  saved: false,
3694
3659
  error: `[toolCallId: ${toolCallId}] No session context available`,
@@ -3698,7 +3663,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
3698
3663
  }
3699
3664
  const toolResult = toolSessionManager.getToolResult(sessionId, toolCallId);
3700
3665
  if (!toolResult) {
3701
- logger11.warn({ toolCallId, sessionId }, "Tool result not found in session");
3666
+ logger10.warn({ toolCallId, sessionId }, "Tool result not found in session");
3702
3667
  return {
3703
3668
  saved: false,
3704
3669
  error: `[toolCallId: ${toolCallId}] Tool result not found`,
@@ -3711,7 +3676,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
3711
3676
  const baseData = jmespath__default.default.search(parsedResult, baseSelector);
3712
3677
  if (!baseData || Array.isArray(baseData) && baseData.length === 0) {
3713
3678
  const debugInfo = analyzeSelectorFailure(parsedResult, baseSelector);
3714
- logger11.warn(
3679
+ logger10.warn(
3715
3680
  {
3716
3681
  baseSelector,
3717
3682
  toolCallId,
@@ -3754,7 +3719,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
3754
3719
  const fallbackValue = item[propName];
3755
3720
  if (fallbackValue !== null && fallbackValue !== void 0) {
3756
3721
  extractedItem[propName] = fallbackValue;
3757
- logger11.info(
3722
+ logger10.info(
3758
3723
  { propName, propSelector, context },
3759
3724
  `PropSelector failed, used fallback direct property access`
3760
3725
  );
@@ -3766,7 +3731,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
3766
3731
  const fallbackValue = item[propName];
3767
3732
  if (fallbackValue !== null && fallbackValue !== void 0) {
3768
3733
  extractedItem[propName] = fallbackValue;
3769
- logger11.warn(
3734
+ logger10.warn(
3770
3735
  { propName, propSelector, context, error: error.message },
3771
3736
  `PropSelector syntax error, used fallback direct property access`
3772
3737
  );
@@ -3879,7 +3844,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
3879
3844
  warnings
3880
3845
  };
3881
3846
  } catch (error) {
3882
- logger11.error({ error, toolCallId, sessionId }, "Error processing save_tool_result");
3847
+ logger10.error({ error, toolCallId, sessionId }, "Error processing save_tool_result");
3883
3848
  return {
3884
3849
  saved: false,
3885
3850
  error: `[toolCallId: ${toolCallId}] ${error instanceof Error ? error.message : "Unknown error"}`,
@@ -3891,7 +3856,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
3891
3856
  }
3892
3857
 
3893
3858
  // src/a2a/client.ts
3894
- var logger12 = getLogger("a2aClient");
3859
+ var logger11 = agentsCore.getLogger("a2aClient");
3895
3860
  var DEFAULT_BACKOFF = {
3896
3861
  initialInterval: 500,
3897
3862
  maxInterval: 6e4,
@@ -3959,7 +3924,7 @@ var A2AClient = class {
3959
3924
  */
3960
3925
  async _fetchAndCacheAgentCard() {
3961
3926
  const agentCardUrl = `${this.agentBaseUrl}/.well-known/agent.json`;
3962
- getLogger("a2a").info({ agentCardUrl, agentBaseUrl: this.agentBaseUrl }, "agentCardUrl");
3927
+ agentsCore.getLogger("a2a").info({ agentCardUrl, agentBaseUrl: this.agentBaseUrl }, "agentCardUrl");
3963
3928
  try {
3964
3929
  const response = await fetch(agentCardUrl, {
3965
3930
  headers: {
@@ -4097,7 +4062,7 @@ var A2AClient = class {
4097
4062
  try {
4098
4063
  const res = await fn();
4099
4064
  if (attempt > 0) {
4100
- logger12.info(
4065
+ logger11.info(
4101
4066
  {
4102
4067
  attempts: attempt + 1,
4103
4068
  elapsedTime: Date.now() - start
@@ -4112,7 +4077,7 @@ var A2AClient = class {
4112
4077
  }
4113
4078
  const elapsed = Date.now() - start;
4114
4079
  if (elapsed > maxElapsedTime) {
4115
- logger12.warn(
4080
+ logger11.warn(
4116
4081
  {
4117
4082
  attempts: attempt + 1,
4118
4083
  elapsedTime: elapsed,
@@ -4133,7 +4098,7 @@ var A2AClient = class {
4133
4098
  retryInterval = initialInterval * attempt ** exponent + Math.random() * 1e3;
4134
4099
  }
4135
4100
  const delayMs = Math.min(retryInterval, maxInterval);
4136
- logger12.info(
4101
+ logger11.info(
4137
4102
  {
4138
4103
  attempt: attempt + 1,
4139
4104
  delayMs,
@@ -4218,7 +4183,7 @@ var A2AClient = class {
4218
4183
  }
4219
4184
  const rpcResponse = await httpResponse.json();
4220
4185
  if (rpcResponse.id !== requestId2) {
4221
- logger12.warn(
4186
+ logger11.warn(
4222
4187
  {
4223
4188
  method,
4224
4189
  expectedId: requestId2,
@@ -4417,7 +4382,7 @@ var A2AClient = class {
4417
4382
  try {
4418
4383
  while (true) {
4419
4384
  const { done, value } = await reader.read();
4420
- logger12.info({ done, value }, "parseA2ASseStream");
4385
+ logger11.info({ done, value }, "parseA2ASseStream");
4421
4386
  if (done) {
4422
4387
  if (eventDataBuffer.trim()) {
4423
4388
  const result = this._processSseEventData(
@@ -4506,7 +4471,7 @@ var A2AClient = class {
4506
4471
  // src/agents/relationTools.ts
4507
4472
  init_conversations();
4508
4473
  init_dbClient();
4509
- var logger13 = getLogger("relationships Tools");
4474
+ var logger12 = agentsCore.getLogger("relationships Tools");
4510
4475
  var generateTransferToolDescription = (config2) => {
4511
4476
  return `Hand off the conversation to agent ${config2.id}.
4512
4477
 
@@ -4544,7 +4509,7 @@ var createTransferToAgentTool = ({
4544
4509
  "transfer.to_agent_id": transferConfig.id ?? "unknown"
4545
4510
  });
4546
4511
  }
4547
- logger13.info(
4512
+ logger12.info(
4548
4513
  {
4549
4514
  transferTo: transferConfig.id ?? "unknown",
4550
4515
  fromAgent: callingAgentId
@@ -4692,7 +4657,7 @@ function createDelegateToAgentTool({
4692
4657
  ...isInternal ? { fromAgentId: callingAgentId } : { fromExternalAgentId: callingAgentId }
4693
4658
  }
4694
4659
  };
4695
- logger13.info({ messageToSend }, "messageToSend");
4660
+ logger12.info({ messageToSend }, "messageToSend");
4696
4661
  await agentsCore.createMessage(dbClient_default)({
4697
4662
  id: nanoid.nanoid(),
4698
4663
  tenantId,
@@ -4754,7 +4719,7 @@ function createDelegateToAgentTool({
4754
4719
  }
4755
4720
 
4756
4721
  // src/agents/SystemPromptBuilder.ts
4757
- var logger14 = getLogger("SystemPromptBuilder");
4722
+ var logger13 = agentsCore.getLogger("SystemPromptBuilder");
4758
4723
  var SystemPromptBuilder = class {
4759
4724
  constructor(version, versionConfig) {
4760
4725
  this.version = version;
@@ -4770,9 +4735,9 @@ var SystemPromptBuilder = class {
4770
4735
  this.templates.set(name, content);
4771
4736
  }
4772
4737
  this.loaded = true;
4773
- logger14.debug(`Loaded ${this.templates.size} templates for version ${this.version}`);
4738
+ logger13.debug(`Loaded ${this.templates.size} templates for version ${this.version}`);
4774
4739
  } catch (error) {
4775
- logger14.error({ error }, `Failed to load templates for version ${this.version}`);
4740
+ logger13.error({ error }, `Failed to load templates for version ${this.version}`);
4776
4741
  throw new Error(`Template loading failed: ${error}`);
4777
4742
  }
4778
4743
  }
@@ -5174,7 +5139,7 @@ function hasToolCallWithPrefix(prefix) {
5174
5139
  return false;
5175
5140
  };
5176
5141
  }
5177
- var logger15 = getLogger("Agent");
5142
+ var logger14 = agentsCore.getLogger("Agent");
5178
5143
  var CONSTANTS = {
5179
5144
  MAX_GENERATION_STEPS: 12,
5180
5145
  PHASE_1_TIMEOUT_MS: 27e4,
@@ -5427,14 +5392,14 @@ var Agent = class {
5427
5392
  for (const toolSet of tools) {
5428
5393
  for (const [toolName, originalTool] of Object.entries(toolSet)) {
5429
5394
  if (!isValidTool(originalTool)) {
5430
- logger15.error({ toolName }, "Invalid MCP tool structure - missing required properties");
5395
+ logger14.error({ toolName }, "Invalid MCP tool structure - missing required properties");
5431
5396
  continue;
5432
5397
  }
5433
5398
  const sessionWrappedTool = ai.tool({
5434
5399
  description: originalTool.description,
5435
5400
  inputSchema: originalTool.inputSchema,
5436
5401
  execute: async (args, { toolCallId }) => {
5437
- logger15.debug({ toolName, toolCallId }, "MCP Tool Called");
5402
+ logger14.debug({ toolName, toolCallId }, "MCP Tool Called");
5438
5403
  try {
5439
5404
  const result = await originalTool.execute(args, { toolCallId });
5440
5405
  toolSessionManager.recordToolResult(sessionId, {
@@ -5446,7 +5411,7 @@ var Agent = class {
5446
5411
  });
5447
5412
  return { result, toolCallId };
5448
5413
  } catch (error) {
5449
- logger15.error({ toolName, toolCallId, error }, "MCP tool execution failed");
5414
+ logger14.error({ toolName, toolCallId, error }, "MCP tool execution failed");
5450
5415
  throw error;
5451
5416
  }
5452
5417
  }
@@ -5531,7 +5496,7 @@ var Agent = class {
5531
5496
  selectedTools
5532
5497
  };
5533
5498
  }
5534
- logger15.info(
5499
+ logger14.info(
5535
5500
  {
5536
5501
  toolName: tool4.name,
5537
5502
  credentialReferenceId,
@@ -5571,7 +5536,7 @@ var Agent = class {
5571
5536
  async getResolvedContext(conversationId, requestContext) {
5572
5537
  try {
5573
5538
  if (!this.config.contextConfigId) {
5574
- logger15.debug({ graphId: this.config.graphId }, "No context config found for graph");
5539
+ logger14.debug({ graphId: this.config.graphId }, "No context config found for graph");
5575
5540
  return null;
5576
5541
  }
5577
5542
  const contextConfig = await agentsCore.getContextConfigById(dbClient_default)({
@@ -5579,7 +5544,7 @@ var Agent = class {
5579
5544
  id: this.config.contextConfigId
5580
5545
  });
5581
5546
  if (!contextConfig) {
5582
- logger15.warn({ contextConfigId: this.config.contextConfigId }, "Context config not found");
5547
+ logger14.warn({ contextConfigId: this.config.contextConfigId }, "Context config not found");
5583
5548
  return null;
5584
5549
  }
5585
5550
  if (!this.contextResolver) {
@@ -5596,7 +5561,7 @@ var Agent = class {
5596
5561
  $now: (/* @__PURE__ */ new Date()).toISOString(),
5597
5562
  $env: process.env
5598
5563
  };
5599
- logger15.debug(
5564
+ logger14.debug(
5600
5565
  {
5601
5566
  conversationId,
5602
5567
  contextConfigId: contextConfig.id,
@@ -5610,7 +5575,7 @@ var Agent = class {
5610
5575
  );
5611
5576
  return contextWithBuiltins;
5612
5577
  } catch (error) {
5613
- logger15.error(
5578
+ logger14.error(
5614
5579
  {
5615
5580
  conversationId,
5616
5581
  error: error instanceof Error ? error.message : "Unknown error"
@@ -5634,7 +5599,7 @@ var Agent = class {
5634
5599
  });
5635
5600
  return graphDefinition?.graphPrompt || void 0;
5636
5601
  } catch (error) {
5637
- logger15.warn(
5602
+ logger14.warn(
5638
5603
  {
5639
5604
  graphId: this.config.graphId,
5640
5605
  error: error instanceof Error ? error.message : "Unknown error"
@@ -5661,7 +5626,7 @@ var Agent = class {
5661
5626
  }
5662
5627
  return !!(graphDefinition.artifactComponents && Object.keys(graphDefinition.artifactComponents).length > 0);
5663
5628
  } catch (error) {
5664
- logger15.warn(
5629
+ logger14.warn(
5665
5630
  {
5666
5631
  graphId: this.config.graphId,
5667
5632
  tenantId: this.config.tenantId,
@@ -5721,7 +5686,7 @@ Key requirements:
5721
5686
  preserveUnresolved: false
5722
5687
  });
5723
5688
  } catch (error) {
5724
- logger15.error(
5689
+ logger14.error(
5725
5690
  {
5726
5691
  conversationId,
5727
5692
  error: error instanceof Error ? error.message : "Unknown error"
@@ -5766,7 +5731,7 @@ Key requirements:
5766
5731
  preserveUnresolved: false
5767
5732
  });
5768
5733
  } catch (error) {
5769
- logger15.error(
5734
+ logger14.error(
5770
5735
  {
5771
5736
  conversationId,
5772
5737
  error: error instanceof Error ? error.message : "Unknown error"
@@ -5794,7 +5759,7 @@ Key requirements:
5794
5759
  artifactId: z5.z.string().describe("The unique identifier of the artifact to get.")
5795
5760
  }),
5796
5761
  execute: async ({ artifactId }) => {
5797
- logger15.info({ artifactId }, "get_artifact executed");
5762
+ logger14.info({ artifactId }, "get_artifact executed");
5798
5763
  const artifact = await agentsCore.getLedgerArtifacts(dbClient_default)({
5799
5764
  scopes: {
5800
5765
  tenantId: this.config.tenantId,
@@ -5861,7 +5826,7 @@ Key requirements:
5861
5826
  graphId: this.config.graphId
5862
5827
  });
5863
5828
  } catch (error) {
5864
- logger15.error(
5829
+ logger14.error(
5865
5830
  { error, graphId: this.config.graphId },
5866
5831
  "Failed to check graph artifact components"
5867
5832
  );
@@ -5965,7 +5930,7 @@ Key requirements:
5965
5930
  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;
5966
5931
  const timeoutMs = Math.min(configuredTimeout, MAX_ALLOWED_TIMEOUT_MS);
5967
5932
  if (modelSettings.maxDuration && modelSettings.maxDuration * 1e3 > MAX_ALLOWED_TIMEOUT_MS) {
5968
- logger15.warn(
5933
+ logger14.warn(
5969
5934
  {
5970
5935
  requestedTimeout: modelSettings.maxDuration * 1e3,
5971
5936
  appliedTimeout: timeoutMs,
@@ -6007,7 +5972,7 @@ Key requirements:
6007
5972
  }
6008
5973
  );
6009
5974
  } catch (error) {
6010
- logger15.debug("Failed to track agent reasoning");
5975
+ logger14.debug("Failed to track agent reasoning");
6011
5976
  }
6012
5977
  }
6013
5978
  if (last && "toolCalls" in last && last.toolCalls) {
@@ -6090,7 +6055,7 @@ Key requirements:
6090
6055
  }
6091
6056
  );
6092
6057
  } catch (error) {
6093
- logger15.debug("Failed to track agent reasoning");
6058
+ logger14.debug("Failed to track agent reasoning");
6094
6059
  }
6095
6060
  }
6096
6061
  if (last && "toolCalls" in last && last.toolCalls) {
@@ -6135,7 +6100,7 @@ Key requirements:
6135
6100
  return;
6136
6101
  }
6137
6102
  if (toolName === "save_artifact_tool" || toolName === "save_tool_result") {
6138
- logger15.info({ result }, "save_artifact_tool or save_tool_result");
6103
+ logger14.info({ result }, "save_artifact_tool or save_tool_result");
6139
6104
  if (result.output.artifacts) {
6140
6105
  for (const artifact of result.output.artifacts) {
6141
6106
  const artifactId = artifact?.artifactId || "N/A";
@@ -6323,7 +6288,7 @@ function parseEmbeddedJson(data) {
6323
6288
  }
6324
6289
  });
6325
6290
  }
6326
- var logger16 = getLogger("generateTaskHandler");
6291
+ var logger15 = agentsCore.getLogger("generateTaskHandler");
6327
6292
  var createTaskHandler = (config2, credentialStoreRegistry) => {
6328
6293
  return async (task) => {
6329
6294
  try {
@@ -6373,7 +6338,7 @@ var createTaskHandler = (config2, credentialStoreRegistry) => {
6373
6338
  agentId: config2.agentId
6374
6339
  })
6375
6340
  ]);
6376
- logger16.info({ toolsForAgent, internalRelations, externalRelations }, "agent stuff");
6341
+ logger15.info({ toolsForAgent, internalRelations, externalRelations }, "agent stuff");
6377
6342
  const agentPrompt = "prompt" in config2.agentSchema ? config2.agentSchema.prompt : "";
6378
6343
  const models = "models" in config2.agentSchema ? config2.agentSchema.models : void 0;
6379
6344
  const stopWhen = "stopWhen" in config2.agentSchema ? config2.agentSchema.stopWhen : void 0;
@@ -6473,7 +6438,7 @@ var createTaskHandler = (config2, credentialStoreRegistry) => {
6473
6438
  const taskIdMatch = task.id.match(/^task_([^-]+-[^-]+-\d+)-/);
6474
6439
  if (taskIdMatch) {
6475
6440
  contextId = taskIdMatch[1];
6476
- logger16.info(
6441
+ logger15.info(
6477
6442
  {
6478
6443
  taskId: task.id,
6479
6444
  extractedContextId: contextId,
@@ -6489,7 +6454,7 @@ var createTaskHandler = (config2, credentialStoreRegistry) => {
6489
6454
  const isDelegation = task.context?.metadata?.isDelegation === true;
6490
6455
  agent.setDelegationStatus(isDelegation);
6491
6456
  if (isDelegation) {
6492
- logger16.info(
6457
+ logger15.info(
6493
6458
  { agentId: config2.agentId, taskId: task.id },
6494
6459
  "Delegated agent - streaming disabled"
6495
6460
  );
@@ -6772,7 +6737,7 @@ async function getRegisteredAgent(executionContext, credentialStoreRegistry) {
6772
6737
  // src/routes/agents.ts
6773
6738
  init_dbClient();
6774
6739
  var app = new zodOpenapi.OpenAPIHono();
6775
- var logger17 = getLogger("agents");
6740
+ var logger16 = agentsCore.getLogger("agents");
6776
6741
  app.openapi(
6777
6742
  zodOpenapi.createRoute({
6778
6743
  method: "get",
@@ -6810,7 +6775,7 @@ app.openapi(
6810
6775
  tracestate: c.req.header("tracestate"),
6811
6776
  baggage: c.req.header("baggage")
6812
6777
  };
6813
- logger17.info(
6778
+ logger16.info(
6814
6779
  {
6815
6780
  otelHeaders,
6816
6781
  path: c.req.path,
@@ -6821,7 +6786,7 @@ app.openapi(
6821
6786
  const executionContext = agentsCore.getRequestExecutionContext(c);
6822
6787
  const { tenantId, projectId, graphId, agentId } = executionContext;
6823
6788
  if (agentId) {
6824
- logger17.info(
6789
+ logger16.info(
6825
6790
  {
6826
6791
  message: "getRegisteredAgent (agent-level)",
6827
6792
  tenantId,
@@ -6833,13 +6798,13 @@ app.openapi(
6833
6798
  );
6834
6799
  const credentialStores = c.get("credentialStores");
6835
6800
  const agent = await getRegisteredAgent(executionContext, credentialStores);
6836
- logger17.info({ agent }, "agent registered: well-known agent.json");
6801
+ logger16.info({ agent }, "agent registered: well-known agent.json");
6837
6802
  if (!agent) {
6838
6803
  return c.json({ error: "Agent not found" }, 404);
6839
6804
  }
6840
6805
  return c.json(agent.agentCard);
6841
6806
  } else {
6842
- logger17.info(
6807
+ logger16.info(
6843
6808
  {
6844
6809
  message: "getRegisteredGraph (graph-level)",
6845
6810
  tenantId,
@@ -6862,7 +6827,7 @@ app.post("/a2a", async (c) => {
6862
6827
  tracestate: c.req.header("tracestate"),
6863
6828
  baggage: c.req.header("baggage")
6864
6829
  };
6865
- logger17.info(
6830
+ logger16.info(
6866
6831
  {
6867
6832
  otelHeaders,
6868
6833
  path: c.req.path,
@@ -6873,7 +6838,7 @@ app.post("/a2a", async (c) => {
6873
6838
  const executionContext = agentsCore.getRequestExecutionContext(c);
6874
6839
  const { tenantId, projectId, graphId, agentId } = executionContext;
6875
6840
  if (agentId) {
6876
- logger17.info(
6841
+ logger16.info(
6877
6842
  {
6878
6843
  message: "a2a (agent-level)",
6879
6844
  tenantId,
@@ -6897,7 +6862,7 @@ app.post("/a2a", async (c) => {
6897
6862
  }
6898
6863
  return a2aHandler(c, agent);
6899
6864
  } else {
6900
- logger17.info(
6865
+ logger16.info(
6901
6866
  {
6902
6867
  message: "a2a (graph-level)",
6903
6868
  tenantId,
@@ -6943,14 +6908,14 @@ init_dbClient();
6943
6908
 
6944
6909
  // src/a2a/transfer.ts
6945
6910
  init_dbClient();
6946
- var logger18 = getLogger("Transfer");
6911
+ var logger17 = agentsCore.getLogger("Transfer");
6947
6912
  async function executeTransfer({
6948
6913
  tenantId,
6949
6914
  threadId,
6950
6915
  projectId,
6951
6916
  targetAgentId
6952
6917
  }) {
6953
- logger18.info({ targetAgent: targetAgentId }, "Executing transfer to agent");
6918
+ logger17.info({ targetAgent: targetAgentId }, "Executing transfer to agent");
6954
6919
  await agentsCore.setActiveAgentForThread(dbClient_default)({
6955
6920
  scopes: { tenantId, projectId },
6956
6921
  threadId,
@@ -7494,7 +7459,7 @@ function createMCPStreamHelper() {
7494
7459
 
7495
7460
  // src/handlers/executionHandler.ts
7496
7461
  init_dbClient();
7497
- var logger19 = getLogger("ExecutionHandler");
7462
+ var logger18 = agentsCore.getLogger("ExecutionHandler");
7498
7463
  var ExecutionHandler = class {
7499
7464
  constructor() {
7500
7465
  // Hardcoded error limit - separate from configurable stopWhen
@@ -7519,7 +7484,7 @@ var ExecutionHandler = class {
7519
7484
  const { tenantId, projectId, graphId, apiKey, baseUrl } = executionContext;
7520
7485
  registerStreamHelper(requestId2, sseHelper);
7521
7486
  graphSessionManager.createSession(requestId2, graphId, tenantId, projectId);
7522
- logger19.info({ sessionId: requestId2, graphId }, "Created GraphSession for message execution");
7487
+ logger18.info({ sessionId: requestId2, graphId }, "Created GraphSession for message execution");
7523
7488
  let graphConfig = null;
7524
7489
  try {
7525
7490
  graphConfig = await agentsCore.getFullGraph(dbClient_default)({ scopes: { tenantId, projectId }, graphId });
@@ -7531,7 +7496,7 @@ var ExecutionHandler = class {
7531
7496
  );
7532
7497
  }
7533
7498
  } catch (error) {
7534
- logger19.error(
7499
+ logger18.error(
7535
7500
  {
7536
7501
  error: error instanceof Error ? error.message : "Unknown error",
7537
7502
  stack: error instanceof Error ? error.stack : void 0
@@ -7547,7 +7512,7 @@ var ExecutionHandler = class {
7547
7512
  try {
7548
7513
  await sseHelper.writeOperation(agentInitializingOp(requestId2, graphId));
7549
7514
  const taskId = `task_${conversationId}-${requestId2}`;
7550
- logger19.info(
7515
+ logger18.info(
7551
7516
  { taskId, currentAgentId, conversationId, requestId: requestId2 },
7552
7517
  "Attempting to create or reuse existing task"
7553
7518
  );
@@ -7570,7 +7535,7 @@ var ExecutionHandler = class {
7570
7535
  agent_id: currentAgentId
7571
7536
  }
7572
7537
  });
7573
- logger19.info(
7538
+ logger18.info(
7574
7539
  {
7575
7540
  taskId,
7576
7541
  createdTaskMetadata: Array.isArray(task) ? task[0]?.metadata : task?.metadata
@@ -7579,27 +7544,27 @@ var ExecutionHandler = class {
7579
7544
  );
7580
7545
  } catch (error) {
7581
7546
  if (error?.message?.includes("UNIQUE constraint failed") || error?.message?.includes("PRIMARY KEY constraint failed") || error?.code === "SQLITE_CONSTRAINT_PRIMARYKEY") {
7582
- logger19.info(
7547
+ logger18.info(
7583
7548
  { taskId, error: error.message },
7584
7549
  "Task already exists, fetching existing task"
7585
7550
  );
7586
7551
  const existingTask = await agentsCore.getTask(dbClient_default)({ id: taskId });
7587
7552
  if (existingTask) {
7588
7553
  task = existingTask;
7589
- logger19.info(
7554
+ logger18.info(
7590
7555
  { taskId, existingTask },
7591
7556
  "Successfully reused existing task from race condition"
7592
7557
  );
7593
7558
  } else {
7594
- logger19.error({ taskId, error }, "Task constraint failed but task not found");
7559
+ logger18.error({ taskId, error }, "Task constraint failed but task not found");
7595
7560
  throw error;
7596
7561
  }
7597
7562
  } else {
7598
- logger19.error({ taskId, error }, "Failed to create task due to non-constraint error");
7563
+ logger18.error({ taskId, error }, "Failed to create task due to non-constraint error");
7599
7564
  throw error;
7600
7565
  }
7601
7566
  }
7602
- logger19.debug(
7567
+ logger18.debug(
7603
7568
  {
7604
7569
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
7605
7570
  executionType: "create_initial_task",
@@ -7617,7 +7582,7 @@ var ExecutionHandler = class {
7617
7582
  const maxTransfers = graphConfig?.stopWhen?.transferCountIs ?? 10;
7618
7583
  while (iterations < maxTransfers) {
7619
7584
  iterations++;
7620
- logger19.info(
7585
+ logger18.info(
7621
7586
  { iterations, currentAgentId, graphId, conversationId, fromAgentId },
7622
7587
  `Execution loop iteration ${iterations} with agent ${currentAgentId}, transfer from: ${fromAgentId || "none"}`
7623
7588
  );
@@ -7625,10 +7590,10 @@ var ExecutionHandler = class {
7625
7590
  scopes: { tenantId, projectId },
7626
7591
  conversationId
7627
7592
  });
7628
- logger19.info({ activeAgent }, "activeAgent");
7593
+ logger18.info({ activeAgent }, "activeAgent");
7629
7594
  if (activeAgent && activeAgent.activeAgentId !== currentAgentId) {
7630
7595
  currentAgentId = activeAgent.activeAgentId;
7631
- logger19.info({ currentAgentId }, `Updated current agent to: ${currentAgentId}`);
7596
+ logger18.info({ currentAgentId }, `Updated current agent to: ${currentAgentId}`);
7632
7597
  }
7633
7598
  const agentBaseUrl = `${baseUrl}/agents`;
7634
7599
  const a2aClient = new A2AClient(agentBaseUrl, {
@@ -7669,13 +7634,13 @@ var ExecutionHandler = class {
7669
7634
  });
7670
7635
  if (!messageResponse?.result) {
7671
7636
  errorCount++;
7672
- logger19.error(
7637
+ logger18.error(
7673
7638
  { currentAgentId, iterations, errorCount },
7674
7639
  `No response from agent ${currentAgentId} on iteration ${iterations} (error ${errorCount}/${this.MAX_ERRORS})`
7675
7640
  );
7676
7641
  if (errorCount >= this.MAX_ERRORS) {
7677
7642
  const errorMessage2 = `Maximum error limit (${this.MAX_ERRORS}) reached`;
7678
- logger19.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
7643
+ logger18.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
7679
7644
  await sseHelper.writeError(errorMessage2);
7680
7645
  await sseHelper.writeOperation(errorOp(errorMessage2, currentAgentId || "system"));
7681
7646
  if (task) {
@@ -7701,7 +7666,7 @@ var ExecutionHandler = class {
7701
7666
  const transferResponse = messageResponse.result;
7702
7667
  const targetAgentId = transferResponse.artifacts?.[0]?.parts?.[0]?.data?.targetAgentId;
7703
7668
  const transferReason = transferResponse.artifacts?.[0]?.parts?.[1]?.text;
7704
- logger19.info({ targetAgentId, transferReason }, "transfer response");
7669
+ logger18.info({ targetAgentId, transferReason }, "transfer response");
7705
7670
  currentMessage = `<transfer_context> ${transferReason} </transfer_context>`;
7706
7671
  const { success, targetAgentId: newAgentId } = await executeTransfer({
7707
7672
  projectId,
@@ -7712,7 +7677,7 @@ var ExecutionHandler = class {
7712
7677
  if (success) {
7713
7678
  fromAgentId = currentAgentId;
7714
7679
  currentAgentId = newAgentId;
7715
- logger19.info(
7680
+ logger18.info(
7716
7681
  {
7717
7682
  transferFrom: fromAgentId,
7718
7683
  transferTo: currentAgentId,
@@ -7730,7 +7695,7 @@ var ExecutionHandler = class {
7730
7695
  const graphSessionData = graphSessionManager.getSession(requestId2);
7731
7696
  if (graphSessionData) {
7732
7697
  const sessionSummary = graphSessionData.getSummary();
7733
- logger19.info(sessionSummary, "GraphSession data after completion");
7698
+ logger18.info(sessionSummary, "GraphSession data after completion");
7734
7699
  }
7735
7700
  let textContent = "";
7736
7701
  for (const part of responseParts) {
@@ -7785,32 +7750,32 @@ var ExecutionHandler = class {
7785
7750
  }
7786
7751
  });
7787
7752
  const updateTaskEnd = Date.now();
7788
- logger19.info(
7753
+ logger18.info(
7789
7754
  { duration: updateTaskEnd - updateTaskStart },
7790
7755
  "Completed updateTask operation"
7791
7756
  );
7792
7757
  await sseHelper.writeOperation(completionOp(currentAgentId, iterations));
7793
7758
  await sseHelper.complete();
7794
- logger19.info("Ending GraphSession and cleaning up");
7759
+ logger18.info({}, "Ending GraphSession and cleaning up");
7795
7760
  graphSessionManager.endSession(requestId2);
7796
- logger19.info("Cleaning up streamHelper");
7761
+ logger18.info({}, "Cleaning up streamHelper");
7797
7762
  unregisterStreamHelper(requestId2);
7798
7763
  let response;
7799
7764
  if (sseHelper instanceof MCPStreamHelper) {
7800
7765
  const captured = sseHelper.getCapturedResponse();
7801
7766
  response = captured.text || "No response content";
7802
7767
  }
7803
- logger19.info("ExecutionHandler returning success");
7768
+ logger18.info({}, "ExecutionHandler returning success");
7804
7769
  return { success: true, iterations, response };
7805
7770
  }
7806
7771
  errorCount++;
7807
- logger19.warn(
7772
+ logger18.warn(
7808
7773
  { iterations, errorCount },
7809
7774
  `No valid response or transfer on iteration ${iterations} (error ${errorCount}/${this.MAX_ERRORS})`
7810
7775
  );
7811
7776
  if (errorCount >= this.MAX_ERRORS) {
7812
7777
  const errorMessage2 = `Maximum error limit (${this.MAX_ERRORS}) reached`;
7813
- logger19.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
7778
+ logger18.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
7814
7779
  await sseHelper.writeError(errorMessage2);
7815
7780
  await sseHelper.writeOperation(errorOp(errorMessage2, currentAgentId || "system"));
7816
7781
  if (task) {
@@ -7832,7 +7797,7 @@ var ExecutionHandler = class {
7832
7797
  }
7833
7798
  }
7834
7799
  const errorMessage = `Maximum transfer limit (${maxTransfers}) reached without completion`;
7835
- logger19.error({ maxTransfers, iterations }, errorMessage);
7800
+ logger18.error({ maxTransfers, iterations }, errorMessage);
7836
7801
  await sseHelper.writeError(errorMessage);
7837
7802
  await sseHelper.writeOperation(errorOp(errorMessage, currentAgentId || "system"));
7838
7803
  if (task) {
@@ -7852,7 +7817,7 @@ var ExecutionHandler = class {
7852
7817
  unregisterStreamHelper(requestId2);
7853
7818
  return { success: false, error: errorMessage, iterations };
7854
7819
  } catch (error) {
7855
- logger19.error({ error }, "Error in execution handler");
7820
+ logger18.error({ error }, "Error in execution handler");
7856
7821
  const errorMessage = error instanceof Error ? error.message : "Unknown execution error";
7857
7822
  await sseHelper.writeError(`Execution error: ${errorMessage}`);
7858
7823
  await sseHelper.writeOperation(errorOp(errorMessage, currentAgentId || "system"));
@@ -7878,7 +7843,7 @@ var ExecutionHandler = class {
7878
7843
 
7879
7844
  // src/routes/chat.ts
7880
7845
  var app2 = new zodOpenapi.OpenAPIHono();
7881
- var logger20 = getLogger("completionsHandler");
7846
+ var logger19 = agentsCore.getLogger("completionsHandler");
7882
7847
  var chatCompletionsRoute = zodOpenapi.createRoute({
7883
7848
  method: "post",
7884
7849
  path: "/completions",
@@ -7983,7 +7948,7 @@ var chatCompletionsRoute = zodOpenapi.createRoute({
7983
7948
  });
7984
7949
  app2.use("/completions", agentsCore.contextValidationMiddleware(dbClient_default));
7985
7950
  app2.openapi(chatCompletionsRoute, async (c) => {
7986
- getLogger("chat").info(
7951
+ agentsCore.getLogger("chat").info(
7987
7952
  {
7988
7953
  path: c.req.path,
7989
7954
  method: c.req.method,
@@ -7996,7 +7961,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
7996
7961
  tracestate: c.req.header("tracestate"),
7997
7962
  baggage: c.req.header("baggage")
7998
7963
  };
7999
- logger20.info(
7964
+ logger19.info(
8000
7965
  {
8001
7966
  otelHeaders,
8002
7967
  path: c.req.path,
@@ -8007,7 +7972,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
8007
7972
  try {
8008
7973
  const executionContext = agentsCore.getRequestExecutionContext(c);
8009
7974
  const { tenantId, projectId, graphId } = executionContext;
8010
- getLogger("chat").debug(
7975
+ agentsCore.getLogger("chat").debug(
8011
7976
  {
8012
7977
  tenantId,
8013
7978
  graphId
@@ -8082,7 +8047,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
8082
8047
  dbClient_default,
8083
8048
  credentialStores
8084
8049
  );
8085
- logger20.info(
8050
+ logger19.info(
8086
8051
  {
8087
8052
  tenantId,
8088
8053
  graphId,
@@ -8128,7 +8093,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
8128
8093
  return streaming.streamSSE(c, async (stream2) => {
8129
8094
  const sseHelper = createSSEStreamHelper(stream2, requestId2, timestamp);
8130
8095
  await sseHelper.writeRole();
8131
- logger20.info({ agentId }, "Starting execution");
8096
+ logger19.info({ agentId }, "Starting execution");
8132
8097
  const executionHandler = new ExecutionHandler();
8133
8098
  const result = await executionHandler.execute({
8134
8099
  executionContext,
@@ -8138,7 +8103,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
8138
8103
  requestId: requestId2,
8139
8104
  sseHelper
8140
8105
  });
8141
- logger20.info(
8106
+ logger19.info(
8142
8107
  { result },
8143
8108
  `Execution completed: ${result.success ? "success" : "failed"} after ${result.iterations} iterations`
8144
8109
  );
@@ -8174,7 +8139,7 @@ var chat_default = app2;
8174
8139
  // src/routes/chatDataStream.ts
8175
8140
  init_dbClient();
8176
8141
  var app3 = new zodOpenapi.OpenAPIHono();
8177
- var logger21 = getLogger("chatDataStream");
8142
+ var logger20 = agentsCore.getLogger("chatDataStream");
8178
8143
  var chatDataStreamRoute = zodOpenapi.createRoute({
8179
8144
  method: "post",
8180
8145
  path: "/chat",
@@ -8279,7 +8244,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
8279
8244
  );
8280
8245
  const lastUserMessage = body.messages.filter((m) => m.role === "user").slice(-1)[0];
8281
8246
  const userText = typeof lastUserMessage?.content === "string" ? lastUserMessage.content : lastUserMessage?.parts?.map((p) => p.text).join("") || "";
8282
- logger21.info({ userText, lastUserMessage }, "userText");
8247
+ logger20.info({ userText, lastUserMessage }, "userText");
8283
8248
  const messageSpan = api.trace.getActiveSpan();
8284
8249
  if (messageSpan) {
8285
8250
  messageSpan.setAttributes({
@@ -8321,7 +8286,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
8321
8286
  await streamHelper.writeError("Unable to process request");
8322
8287
  }
8323
8288
  } catch (err) {
8324
- logger21.error({ err }, "Streaming error");
8289
+ logger20.error({ err }, "Streaming error");
8325
8290
  await streamHelper.writeError("Internal server error");
8326
8291
  } finally {
8327
8292
  if ("cleanup" in streamHelper && typeof streamHelper.cleanup === "function") {
@@ -8342,7 +8307,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
8342
8307
  )
8343
8308
  );
8344
8309
  } catch (error) {
8345
- logger21.error({ error }, "chatDataStream error");
8310
+ logger20.error({ error }, "chatDataStream error");
8346
8311
  return c.json({ error: "Failed to process chat completion" }, 500);
8347
8312
  }
8348
8313
  });
@@ -8353,7 +8318,7 @@ init_dbClient();
8353
8318
  function createMCPSchema(schema) {
8354
8319
  return schema;
8355
8320
  }
8356
- var logger22 = getLogger("mcp");
8321
+ var logger21 = agentsCore.getLogger("mcp");
8357
8322
  var _MockResponseSingleton = class _MockResponseSingleton {
8358
8323
  constructor() {
8359
8324
  __publicField(this, "mockRes");
@@ -8408,21 +8373,21 @@ var createSpoofInitMessage = (mcpProtocolVersion) => ({
8408
8373
  id: 0
8409
8374
  });
8410
8375
  var spoofTransportInitialization = async (transport, req, sessionId, mcpProtocolVersion) => {
8411
- logger22.info({ sessionId }, "Spoofing initialization message to set transport state");
8376
+ logger21.info({ sessionId }, "Spoofing initialization message to set transport state");
8412
8377
  const spoofInitMessage = createSpoofInitMessage(mcpProtocolVersion);
8413
8378
  const mockRes = MockResponseSingleton.getInstance().getMockResponse();
8414
8379
  try {
8415
8380
  await transport.handleRequest(req, mockRes, spoofInitMessage);
8416
- logger22.info({ sessionId }, "Successfully spoofed initialization");
8381
+ logger21.info({ sessionId }, "Successfully spoofed initialization");
8417
8382
  } catch (spoofError) {
8418
- logger22.warn({ sessionId, error: spoofError }, "Spoof initialization failed, continuing anyway");
8383
+ logger21.warn({ sessionId, error: spoofError }, "Spoof initialization failed, continuing anyway");
8419
8384
  }
8420
8385
  };
8421
8386
  var validateSession = async (req, res, body, tenantId, projectId, graphId) => {
8422
8387
  const sessionId = req.headers["mcp-session-id"];
8423
- logger22.info({ sessionId }, "Received MCP session ID");
8388
+ logger21.info({ sessionId }, "Received MCP session ID");
8424
8389
  if (!sessionId) {
8425
- logger22.info({ body }, "Missing session ID");
8390
+ logger21.info({ body }, "Missing session ID");
8426
8391
  res.writeHead(400).end(
8427
8392
  JSON.stringify({
8428
8393
  jsonrpc: "2.0",
@@ -8448,7 +8413,7 @@ var validateSession = async (req, res, body, tenantId, projectId, graphId) => {
8448
8413
  scopes: { tenantId, projectId },
8449
8414
  conversationId: sessionId
8450
8415
  });
8451
- logger22.info(
8416
+ logger21.info(
8452
8417
  {
8453
8418
  sessionId,
8454
8419
  conversationFound: !!conversation,
@@ -8459,7 +8424,7 @@ var validateSession = async (req, res, body, tenantId, projectId, graphId) => {
8459
8424
  "Conversation lookup result"
8460
8425
  );
8461
8426
  if (!conversation || conversation.metadata?.sessionData?.sessionType !== "mcp" || conversation.metadata?.sessionData?.graphId !== graphId) {
8462
- logger22.info(
8427
+ logger21.info(
8463
8428
  { sessionId, conversationId: conversation?.id },
8464
8429
  "MCP session not found or invalid"
8465
8430
  );
@@ -8520,7 +8485,7 @@ var executeAgentQuery = async (executionContext, conversationId, query, defaultA
8520
8485
  requestId: requestId2,
8521
8486
  sseHelper: mcpStreamHelper
8522
8487
  });
8523
- logger22.info(
8488
+ logger21.info(
8524
8489
  { result },
8525
8490
  `Execution completed: ${result.success ? "success" : "failed"} after ${result.iterations} iterations`
8526
8491
  );
@@ -8594,7 +8559,7 @@ var getServer = async (requestContext, executionContext, conversationId, credent
8594
8559
  dbClient_default,
8595
8560
  credentialStores
8596
8561
  );
8597
- logger22.info(
8562
+ logger21.info(
8598
8563
  {
8599
8564
  tenantId,
8600
8565
  graphId,
@@ -8633,10 +8598,10 @@ var validateRequestParameters = (c) => {
8633
8598
  try {
8634
8599
  const executionContext = agentsCore.getRequestExecutionContext(c);
8635
8600
  const { tenantId, projectId, graphId } = executionContext;
8636
- getLogger("mcp").debug({ tenantId, projectId, graphId }, "Extracted MCP entity parameters");
8601
+ agentsCore.getLogger("mcp").debug({ tenantId, projectId, graphId }, "Extracted MCP entity parameters");
8637
8602
  return { valid: true, executionContext };
8638
8603
  } catch (error) {
8639
- getLogger("chat").warn(
8604
+ agentsCore.getLogger("chat").warn(
8640
8605
  { error: error instanceof Error ? error.message : "Unknown error" },
8641
8606
  "Failed to get execution context"
8642
8607
  );
@@ -8655,7 +8620,7 @@ var validateRequestParameters = (c) => {
8655
8620
  };
8656
8621
  var handleInitializationRequest = async (body, executionContext, validatedContext, req, res, c, credentialStores) => {
8657
8622
  const { tenantId, projectId, graphId } = executionContext;
8658
- logger22.info({ body }, "Received initialization request");
8623
+ logger21.info({ body }, "Received initialization request");
8659
8624
  const sessionId = nanoid.nanoid();
8660
8625
  const agentGraph = await agentsCore.getAgentGraphWithDefaultAgent(dbClient_default)({
8661
8626
  scopes: { tenantId, projectId },
@@ -8686,7 +8651,7 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
8686
8651
  }
8687
8652
  }
8688
8653
  });
8689
- logger22.info(
8654
+ logger21.info(
8690
8655
  { sessionId, conversationId: conversation.id },
8691
8656
  "Created MCP session as conversation"
8692
8657
  );
@@ -8695,9 +8660,9 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
8695
8660
  });
8696
8661
  const server = await getServer(validatedContext, executionContext, sessionId, credentialStores);
8697
8662
  await server.connect(transport);
8698
- logger22.info({ sessionId }, "Server connected for initialization");
8663
+ logger21.info({ sessionId }, "Server connected for initialization");
8699
8664
  res.setHeader("Mcp-Session-Id", sessionId);
8700
- logger22.info(
8665
+ logger21.info(
8701
8666
  {
8702
8667
  sessionId,
8703
8668
  bodyMethod: body?.method,
@@ -8706,7 +8671,7 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
8706
8671
  "About to handle initialization request"
8707
8672
  );
8708
8673
  await transport.handleRequest(req, res, body);
8709
- logger22.info({ sessionId }, "Successfully handled initialization request");
8674
+ logger21.info({ sessionId }, "Successfully handled initialization request");
8710
8675
  return fetchToNode.toFetchResponse(res);
8711
8676
  };
8712
8677
  var handleExistingSessionRequest = async (body, executionContext, validatedContext, req, res, credentialStores) => {
@@ -8734,8 +8699,8 @@ var handleExistingSessionRequest = async (body, executionContext, validatedConte
8734
8699
  sessionId,
8735
8700
  conversation.metadata?.session_data?.mcpProtocolVersion
8736
8701
  );
8737
- logger22.info({ sessionId }, "Server connected and transport initialized");
8738
- logger22.info(
8702
+ logger21.info({ sessionId }, "Server connected and transport initialized");
8703
+ logger21.info(
8739
8704
  {
8740
8705
  sessionId,
8741
8706
  bodyKeys: Object.keys(body || {}),
@@ -8749,9 +8714,9 @@ var handleExistingSessionRequest = async (body, executionContext, validatedConte
8749
8714
  );
8750
8715
  try {
8751
8716
  await transport.handleRequest(req, res, body);
8752
- logger22.info({ sessionId }, "Successfully handled MCP request");
8717
+ logger21.info({ sessionId }, "Successfully handled MCP request");
8753
8718
  } catch (transportError) {
8754
- logger22.error(
8719
+ logger21.error(
8755
8720
  {
8756
8721
  sessionId,
8757
8722
  error: transportError,
@@ -8802,13 +8767,13 @@ app4.openapi(
8802
8767
  }
8803
8768
  const { executionContext } = paramValidation;
8804
8769
  const body = await c.req.json();
8805
- logger22.info({ body, bodyKeys: Object.keys(body || {}) }, "Parsed request body");
8770
+ logger21.info({ body, bodyKeys: Object.keys(body || {}) }, "Parsed request body");
8806
8771
  const isInitRequest = body.method === "initialize";
8807
8772
  const { req, res } = fetchToNode.toReqRes(c.req.raw);
8808
8773
  const validatedContext = c.get("validatedContext") || {};
8809
8774
  const credentialStores = c.get("credentialStores");
8810
- logger22.info({ validatedContext }, "Validated context");
8811
- logger22.info({ req }, "request");
8775
+ logger21.info({ validatedContext }, "Validated context");
8776
+ logger21.info({ req }, "request");
8812
8777
  if (isInitRequest) {
8813
8778
  return await handleInitializationRequest(
8814
8779
  body,
@@ -8830,7 +8795,7 @@ app4.openapi(
8830
8795
  );
8831
8796
  }
8832
8797
  } catch (e) {
8833
- logger22.error(
8798
+ logger21.error(
8834
8799
  {
8835
8800
  error: e instanceof Error ? e.message : e,
8836
8801
  stack: e instanceof Error ? e.stack : void 0
@@ -8842,7 +8807,7 @@ app4.openapi(
8842
8807
  }
8843
8808
  );
8844
8809
  app4.get("/", async (c) => {
8845
- logger22.info("Received GET MCP request");
8810
+ logger21.info({}, "Received GET MCP request");
8846
8811
  return c.json(
8847
8812
  {
8848
8813
  jsonrpc: "2.0",
@@ -8856,7 +8821,7 @@ app4.get("/", async (c) => {
8856
8821
  );
8857
8822
  });
8858
8823
  app4.delete("/", async (c) => {
8859
- logger22.info("Received DELETE MCP request");
8824
+ logger21.info({}, "Received DELETE MCP request");
8860
8825
  return c.json(
8861
8826
  {
8862
8827
  jsonrpc: "2.0",
@@ -8869,7 +8834,7 @@ app4.delete("/", async (c) => {
8869
8834
  var mcp_default = app4;
8870
8835
 
8871
8836
  // src/app.ts
8872
- var logger23 = getLogger("agents-run-api");
8837
+ var logger22 = agentsCore.getLogger("agents-run-api");
8873
8838
  function createExecutionHono(serverConfig, credentialStores) {
8874
8839
  const app6 = new zodOpenapi.OpenAPIHono();
8875
8840
  app6.use("*", requestId.requestId());
@@ -8893,7 +8858,7 @@ function createExecutionHono(serverConfig, credentialStores) {
8893
8858
  });
8894
8859
  app6.use(
8895
8860
  honoPino.pinoLogger({
8896
- pino: logger23 || pino.pino({ level: "debug" }),
8861
+ pino: logger22 || pino.pino({ level: "debug" }),
8897
8862
  http: {
8898
8863
  onResLevel(c) {
8899
8864
  if (c.res.status >= 500) {
@@ -8937,8 +8902,8 @@ function createExecutionHono(serverConfig, credentialStores) {
8937
8902
  if (!isExpectedError) {
8938
8903
  const errorMessage = err instanceof Error ? err.message : String(err);
8939
8904
  const errorStack = err instanceof Error ? err.stack : void 0;
8940
- if (logger23) {
8941
- logger23.error(
8905
+ if (logger22) {
8906
+ logger22.error(
8942
8907
  {
8943
8908
  error: err,
8944
8909
  message: errorMessage,
@@ -8950,8 +8915,8 @@ function createExecutionHono(serverConfig, credentialStores) {
8950
8915
  );
8951
8916
  }
8952
8917
  } else {
8953
- if (logger23) {
8954
- logger23.error(
8918
+ if (logger22) {
8919
+ logger22.error(
8955
8920
  {
8956
8921
  error: err,
8957
8922
  path: c.req.path,
@@ -8968,8 +8933,8 @@ function createExecutionHono(serverConfig, credentialStores) {
8968
8933
  const response = err.getResponse();
8969
8934
  return response;
8970
8935
  } catch (responseError) {
8971
- if (logger23) {
8972
- logger23.error({ error: responseError }, "Error while handling HTTPException response");
8936
+ if (logger22) {
8937
+ logger22.error({ error: responseError }, "Error while handling HTTPException response");
8973
8938
  }
8974
8939
  }
8975
8940
  }
@@ -9003,7 +8968,7 @@ function createExecutionHono(serverConfig, credentialStores) {
9003
8968
  app6.use("*", async (c, next) => {
9004
8969
  const executionContext = c.get("executionContext");
9005
8970
  if (!executionContext) {
9006
- logger23.debug("Empty execution context");
8971
+ logger22.debug({}, "Empty execution context");
9007
8972
  return next();
9008
8973
  }
9009
8974
  const { tenantId, projectId, graphId } = executionContext;
@@ -9014,7 +8979,7 @@ function createExecutionHono(serverConfig, credentialStores) {
9014
8979
  const body = await cloned.json().catch(() => null);
9015
8980
  conversationId = body?.conversationId;
9016
8981
  } catch (_) {
9017
- logger23.debug("Conversation ID not found in JSON body");
8982
+ logger22.debug({}, "Conversation ID not found in JSON body");
9018
8983
  }
9019
8984
  }
9020
8985
  const entries = Object.fromEntries(
@@ -9029,7 +8994,7 @@ function createExecutionHono(serverConfig, credentialStores) {
9029
8994
  })
9030
8995
  );
9031
8996
  if (!Object.keys(entries).length) {
9032
- logger23.debug("Empty entries for baggage");
8997
+ logger22.debug({}, "Empty entries for baggage");
9033
8998
  return next();
9034
8999
  }
9035
9000
  const bag = Object.entries(entries).reduce(