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

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 +214 -266
  2. package/dist/index.js +210 -257
  3. package/package.json +2 -5
package/dist/index.cjs CHANGED
@@ -22,9 +22,6 @@ var api = require('@opentelemetry/api');
22
22
  var cors = require('hono/cors');
23
23
  var httpException = require('hono/http-exception');
24
24
  var requestId = require('hono/request-id');
25
- var honoPino = require('hono-pino');
26
- var pino = require('pino');
27
- var async_hooks = require('async_hooks');
28
25
  var factory = require('hono/factory');
29
26
  var swaggerUi = require('@hono/swagger-ui');
30
27
  var streaming = require('hono/streaming');
@@ -362,42 +359,6 @@ var sdk = new sdkNode.NodeSDK({
362
359
  ]
363
360
  });
364
361
  sdk.start();
365
-
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
- // src/middleware/api-key-auth.ts
401
362
  init_dbClient();
402
363
  init_env();
403
364
 
@@ -415,7 +376,7 @@ function createExecutionContext(params) {
415
376
  }
416
377
 
417
378
  // src/middleware/api-key-auth.ts
418
- var logger2 = agentsCore.getLogger("env-key-auth");
379
+ var logger = agentsCore.getLogger("env-key-auth");
419
380
  var apiKeyAuth = () => factory.createMiddleware(async (c, next) => {
420
381
  if (c.req.method === "OPTIONS") {
421
382
  await next();
@@ -432,7 +393,7 @@ var apiKeyAuth = () => factory.createMiddleware(async (c, next) => {
432
393
  if (authHeader?.startsWith("Bearer ")) {
433
394
  try {
434
395
  executionContext = await extractContextFromApiKey(authHeader.substring(7));
435
- logger2.info({}, "Development/test environment - API key authenticated successfully");
396
+ logger.info({}, "Development/test environment - API key authenticated successfully");
436
397
  } catch {
437
398
  executionContext = createExecutionContext({
438
399
  apiKey: "development",
@@ -443,7 +404,7 @@ var apiKeyAuth = () => factory.createMiddleware(async (c, next) => {
443
404
  baseUrl,
444
405
  agentId
445
406
  });
446
- logger2.info(
407
+ logger.info(
447
408
  {},
448
409
  "Development/test environment - fallback to default context due to invalid API key"
449
410
  );
@@ -458,7 +419,7 @@ var apiKeyAuth = () => factory.createMiddleware(async (c, next) => {
458
419
  baseUrl,
459
420
  agentId
460
421
  });
461
- logger2.info(
422
+ logger.info(
462
423
  {},
463
424
  "Development/test environment - no API key provided, using default context"
464
425
  );
@@ -490,13 +451,13 @@ var apiKeyAuth = () => factory.createMiddleware(async (c, next) => {
490
451
  agentId
491
452
  });
492
453
  c.set("executionContext", executionContext);
493
- logger2.info({}, "Bypass secret authenticated successfully");
454
+ logger.info({}, "Bypass secret authenticated successfully");
494
455
  await next();
495
456
  return;
496
457
  } else if (apiKey) {
497
458
  const executionContext = await extractContextFromApiKey(apiKey);
498
459
  c.set("executionContext", executionContext);
499
- logger2.info({}, "API key authenticated successfully");
460
+ logger.info({}, "API key authenticated successfully");
500
461
  await next();
501
462
  return;
502
463
  } else {
@@ -513,7 +474,7 @@ var apiKeyAuth = () => factory.createMiddleware(async (c, next) => {
513
474
  try {
514
475
  const executionContext = await extractContextFromApiKey(apiKey);
515
476
  c.set("executionContext", executionContext);
516
- logger2.debug(
477
+ logger.debug(
517
478
  {
518
479
  tenantId: executionContext.tenantId,
519
480
  projectId: executionContext.projectId,
@@ -526,7 +487,7 @@ var apiKeyAuth = () => factory.createMiddleware(async (c, next) => {
526
487
  if (error instanceof httpException.HTTPException) {
527
488
  throw error;
528
489
  }
529
- logger2.error({ error }, "API key authentication error");
490
+ logger.error({ error }, "API key authentication error");
530
491
  throw new httpException.HTTPException(500, {
531
492
  message: "Authentication failed"
532
493
  });
@@ -585,7 +546,7 @@ function setupOpenAPIRoutes(app6) {
585
546
 
586
547
  // src/a2a/handlers.ts
587
548
  init_dbClient();
588
- var logger3 = getLogger("a2aHandler");
549
+ var logger2 = agentsCore.getLogger("a2aHandler");
589
550
  async function a2aHandler(c, agent) {
590
551
  try {
591
552
  const rpcRequest = await c.req.json();
@@ -687,7 +648,7 @@ async function handleMessageSend(c, agent, request) {
687
648
  messageId: task.id,
688
649
  kind: "message"
689
650
  });
690
- logger3.warn(
651
+ logger2.warn(
691
652
  {
692
653
  taskId: task.id,
693
654
  agentId: agent.agentId,
@@ -697,7 +658,7 @@ async function handleMessageSend(c, agent, request) {
697
658
  );
698
659
  }
699
660
  } catch (error) {
700
- logger3.error({ error, taskId: task.id }, "Failed to serialize message");
661
+ logger2.error({ error, taskId: task.id }, "Failed to serialize message");
701
662
  JSON.stringify({
702
663
  error: "Failed to serialize message",
703
664
  taskId: task.id,
@@ -705,7 +666,7 @@ async function handleMessageSend(c, agent, request) {
705
666
  parts: [{ text: "Error in delegation", kind: "text" }]
706
667
  });
707
668
  }
708
- logger3.info(
669
+ logger2.info(
709
670
  {
710
671
  originalContextId: params.message.contextId,
711
672
  taskContextId: task.context?.conversationId,
@@ -734,7 +695,7 @@ async function handleMessageSend(c, agent, request) {
734
695
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
735
696
  updatedAt: (/* @__PURE__ */ new Date()).toISOString()
736
697
  });
737
- logger3.info({ metadata: params.message.metadata }, "message metadata");
698
+ logger2.info({ metadata: params.message.metadata }, "message metadata");
738
699
  if (params.message.metadata?.fromAgentId || params.message.metadata?.fromExternalAgentId) {
739
700
  const messageText = params.message.parts.filter((part) => part.kind === "text" && "text" in part && part.text).map((part) => part.text).join(" ");
740
701
  try {
@@ -759,7 +720,7 @@ async function handleMessageSend(c, agent, request) {
759
720
  messageData.toAgentId = agent.agentId;
760
721
  }
761
722
  await agentsCore.createMessage(dbClient_default)(messageData);
762
- logger3.info(
723
+ logger2.info(
763
724
  {
764
725
  fromAgentId: params.message.metadata.fromAgentId,
765
726
  fromExternalAgentId: params.message.metadata.fromExternalAgentId,
@@ -771,7 +732,7 @@ async function handleMessageSend(c, agent, request) {
771
732
  "A2A message stored in database"
772
733
  );
773
734
  } catch (error) {
774
- logger3.error(
735
+ logger2.error(
775
736
  {
776
737
  error,
777
738
  fromAgentId: params.message.metadata.fromAgentId,
@@ -808,7 +769,7 @@ async function handleMessageSend(c, agent, request) {
808
769
  (part) => part.kind === "data" && part.data && typeof part.data === "object" && part.data.type === "transfer"
809
770
  );
810
771
  if (transferPart && transferPart.kind === "data" && transferPart.data) {
811
- logger3.info({ transferPart }, "transferPart");
772
+ logger2.info({ transferPart }, "transferPart");
812
773
  return c.json({
813
774
  jsonrpc: "2.0",
814
775
  result: {
@@ -1233,10 +1194,10 @@ function statusUpdateOp(ctx) {
1233
1194
  ctx
1234
1195
  };
1235
1196
  }
1236
- var logger4 = getLogger("DataComponentSchema");
1197
+ var logger3 = agentsCore.getLogger("DataComponentSchema");
1237
1198
  function jsonSchemaToZod(jsonSchema) {
1238
1199
  if (!jsonSchema || typeof jsonSchema !== "object") {
1239
- logger4.warn({ jsonSchema }, "Invalid JSON schema provided, using string fallback");
1200
+ logger3.warn({ jsonSchema }, "Invalid JSON schema provided, using string fallback");
1240
1201
  return z5.z.string();
1241
1202
  }
1242
1203
  switch (jsonSchema.type) {
@@ -1263,7 +1224,7 @@ function jsonSchemaToZod(jsonSchema) {
1263
1224
  case "null":
1264
1225
  return z5.z.null();
1265
1226
  default:
1266
- logger4.warn(
1227
+ logger3.warn(
1267
1228
  {
1268
1229
  unsupportedType: jsonSchema.type,
1269
1230
  schema: jsonSchema
@@ -1275,7 +1236,7 @@ function jsonSchemaToZod(jsonSchema) {
1275
1236
  }
1276
1237
 
1277
1238
  // src/utils/artifact-component-schema.ts
1278
- getLogger("ArtifactComponentSchema");
1239
+ agentsCore.getLogger("ArtifactComponentSchema");
1279
1240
  var _ArtifactReferenceSchema = class _ArtifactReferenceSchema {
1280
1241
  /**
1281
1242
  * Get the standard Zod schema for artifact reference components
@@ -1317,7 +1278,7 @@ __publicField(_ArtifactReferenceSchema, "ARTIFACT_PROPS_SCHEMA", {
1317
1278
  required: ["artifact_id", "task_id"]
1318
1279
  });
1319
1280
  var ArtifactReferenceSchema = _ArtifactReferenceSchema;
1320
- var logger5 = getLogger("ModelFactory");
1281
+ var logger4 = agentsCore.getLogger("ModelFactory");
1321
1282
  var _ModelFactory = class _ModelFactory {
1322
1283
  /**
1323
1284
  * Create a language model instance from configuration
@@ -1332,7 +1293,7 @@ var _ModelFactory = class _ModelFactory {
1332
1293
  const modelSettings = config2;
1333
1294
  const modelString = modelSettings.model.trim();
1334
1295
  const { provider, modelName } = _ModelFactory.parseModelString(modelString);
1335
- logger5.debug(
1296
+ logger4.debug(
1336
1297
  {
1337
1298
  provider,
1338
1299
  model: modelName,
@@ -1353,7 +1314,7 @@ var _ModelFactory = class _ModelFactory {
1353
1314
  );
1354
1315
  }
1355
1316
  } catch (error) {
1356
- logger5.error(
1317
+ logger4.error(
1357
1318
  {
1358
1319
  provider,
1359
1320
  model: modelName,
@@ -1376,7 +1337,7 @@ var _ModelFactory = class _ModelFactory {
1376
1337
  const [provider, ...modelParts] = modelString.split("/");
1377
1338
  const normalizedProvider = provider.toLowerCase();
1378
1339
  if (!_ModelFactory.SUPPORTED_PROVIDERS.includes(normalizedProvider)) {
1379
- logger5.warn(
1340
+ logger4.warn(
1380
1341
  { provider: normalizedProvider, modelName: modelParts.join("/") },
1381
1342
  "Unsupported provider detected, falling back to anthropic"
1382
1343
  );
@@ -1405,14 +1366,14 @@ var _ModelFactory = class _ModelFactory {
1405
1366
  anthropicConfig.baseURL = providerOptions.baseUrl || providerOptions.baseURL;
1406
1367
  }
1407
1368
  if (providerOptions?.gateway) {
1408
- logger5.info(
1369
+ logger4.info(
1409
1370
  { gateway: providerOptions.gateway },
1410
1371
  "Setting up AI Gateway for Anthropic model"
1411
1372
  );
1412
1373
  Object.assign(anthropicConfig, providerOptions.gateway);
1413
1374
  }
1414
1375
  if (Object.keys(anthropicConfig).length > 0) {
1415
- logger5.info({ config: anthropicConfig }, "Applying custom Anthropic provider configuration");
1376
+ logger4.info({ config: anthropicConfig }, "Applying custom Anthropic provider configuration");
1416
1377
  const provider = anthropic.createAnthropic(anthropicConfig);
1417
1378
  return provider(modelName);
1418
1379
  }
@@ -1427,11 +1388,11 @@ var _ModelFactory = class _ModelFactory {
1427
1388
  openaiConfig.baseURL = providerOptions.baseUrl || providerOptions.baseURL;
1428
1389
  }
1429
1390
  if (providerOptions?.gateway) {
1430
- logger5.info({ gateway: providerOptions.gateway }, "Setting up AI Gateway for OpenAI model");
1391
+ logger4.info({ gateway: providerOptions.gateway }, "Setting up AI Gateway for OpenAI model");
1431
1392
  Object.assign(openaiConfig, providerOptions.gateway);
1432
1393
  }
1433
1394
  if (Object.keys(openaiConfig).length > 0) {
1434
- logger5.info({ config: openaiConfig }, "Applying custom OpenAI provider configuration");
1395
+ logger4.info({ config: openaiConfig }, "Applying custom OpenAI provider configuration");
1435
1396
  const provider = openai.createOpenAI(openaiConfig);
1436
1397
  return provider(modelName);
1437
1398
  }
@@ -1525,7 +1486,7 @@ function unregisterStreamHelper(requestId2) {
1525
1486
  }
1526
1487
 
1527
1488
  // src/utils/graph-session.ts
1528
- var logger6 = getLogger("GraphSession");
1489
+ var logger5 = agentsCore.getLogger("GraphSession");
1529
1490
  var GraphSession = class {
1530
1491
  // Track scheduled timeouts for cleanup
1531
1492
  constructor(sessionId, messageId, graphId, tenantId, projectId) {
@@ -1549,7 +1510,7 @@ var GraphSession = class {
1549
1510
  __publicField(this, "MAX_PENDING_ARTIFACTS", 100);
1550
1511
  // Prevent unbounded growth
1551
1512
  __publicField(this, "scheduledTimeouts");
1552
- logger6.debug({ sessionId, messageId, graphId }, "GraphSession created");
1513
+ logger5.debug({ sessionId, messageId, graphId }, "GraphSession created");
1553
1514
  }
1554
1515
  /**
1555
1516
  * Initialize status updates for this session
@@ -1571,7 +1532,7 @@ var GraphSession = class {
1571
1532
  if (this.statusUpdateState.config.timeInSeconds) {
1572
1533
  this.statusUpdateTimer = setInterval(async () => {
1573
1534
  if (!this.statusUpdateState || this.isEnded) {
1574
- logger6.debug(
1535
+ logger5.debug(
1575
1536
  { sessionId: this.sessionId },
1576
1537
  "Timer triggered but session already cleaned up or ended"
1577
1538
  );
@@ -1583,7 +1544,7 @@ var GraphSession = class {
1583
1544
  }
1584
1545
  await this.checkAndSendTimeBasedUpdate();
1585
1546
  }, this.statusUpdateState.config.timeInSeconds * 1e3);
1586
- logger6.info(
1547
+ logger5.info(
1587
1548
  {
1588
1549
  sessionId: this.sessionId,
1589
1550
  intervalMs: this.statusUpdateState.config.timeInSeconds * 1e3
@@ -1597,7 +1558,7 @@ var GraphSession = class {
1597
1558
  */
1598
1559
  recordEvent(eventType, agentId, data) {
1599
1560
  if (this.isEnded) {
1600
- logger6.debug(
1561
+ logger5.debug(
1601
1562
  {
1602
1563
  sessionId: this.sessionId,
1603
1564
  eventType,
@@ -1617,7 +1578,7 @@ var GraphSession = class {
1617
1578
  if (eventType === "artifact_saved" && data.pendingGeneration) {
1618
1579
  const artifactId = data.artifactId;
1619
1580
  if (this.pendingArtifacts.size >= this.MAX_PENDING_ARTIFACTS) {
1620
- logger6.warn(
1581
+ logger5.warn(
1621
1582
  {
1622
1583
  sessionId: this.sessionId,
1623
1584
  artifactId,
@@ -1638,7 +1599,7 @@ var GraphSession = class {
1638
1599
  this.artifactProcessingErrors.set(artifactId, errorCount);
1639
1600
  if (errorCount >= this.MAX_ARTIFACT_RETRIES) {
1640
1601
  this.pendingArtifacts.delete(artifactId);
1641
- logger6.error(
1602
+ logger5.error(
1642
1603
  {
1643
1604
  sessionId: this.sessionId,
1644
1605
  artifactId,
@@ -1650,7 +1611,7 @@ var GraphSession = class {
1650
1611
  "Artifact processing failed after max retries, giving up"
1651
1612
  );
1652
1613
  } else {
1653
- logger6.warn(
1614
+ logger5.warn(
1654
1615
  {
1655
1616
  sessionId: this.sessionId,
1656
1617
  artifactId,
@@ -1672,14 +1633,14 @@ var GraphSession = class {
1672
1633
  */
1673
1634
  checkStatusUpdates() {
1674
1635
  if (this.isEnded) {
1675
- logger6.debug(
1636
+ logger5.debug(
1676
1637
  { sessionId: this.sessionId },
1677
1638
  "Session has ended - skipping status update check"
1678
1639
  );
1679
1640
  return;
1680
1641
  }
1681
1642
  if (!this.statusUpdateState) {
1682
- logger6.debug({ sessionId: this.sessionId }, "No status update state - skipping check");
1643
+ logger5.debug({ sessionId: this.sessionId }, "No status update state - skipping check");
1683
1644
  return;
1684
1645
  }
1685
1646
  const statusUpdateState = this.statusUpdateState;
@@ -1690,11 +1651,11 @@ var GraphSession = class {
1690
1651
  */
1691
1652
  async checkAndSendTimeBasedUpdate() {
1692
1653
  if (this.isEnded) {
1693
- logger6.debug({ sessionId: this.sessionId }, "Session has ended - skipping time-based update");
1654
+ logger5.debug({ sessionId: this.sessionId }, "Session has ended - skipping time-based update");
1694
1655
  return;
1695
1656
  }
1696
1657
  if (!this.statusUpdateState) {
1697
- logger6.debug(
1658
+ logger5.debug(
1698
1659
  { sessionId: this.sessionId },
1699
1660
  "No status updates configured for time-based check"
1700
1661
  );
@@ -1707,7 +1668,7 @@ var GraphSession = class {
1707
1668
  try {
1708
1669
  await this.generateAndSendUpdate();
1709
1670
  } catch (error) {
1710
- logger6.error(
1671
+ logger5.error(
1711
1672
  {
1712
1673
  sessionId: this.sessionId,
1713
1674
  error: error instanceof Error ? error.message : "Unknown error"
@@ -1800,29 +1761,29 @@ var GraphSession = class {
1800
1761
  */
1801
1762
  async generateAndSendUpdate() {
1802
1763
  if (this.isEnded) {
1803
- logger6.debug({ sessionId: this.sessionId }, "Session has ended - not generating update");
1764
+ logger5.debug({ sessionId: this.sessionId }, "Session has ended - not generating update");
1804
1765
  return;
1805
1766
  }
1806
1767
  if (this.isTextStreaming) {
1807
- logger6.debug(
1768
+ logger5.debug(
1808
1769
  { sessionId: this.sessionId },
1809
1770
  "Text is currently streaming - skipping status update"
1810
1771
  );
1811
1772
  return;
1812
1773
  }
1813
1774
  if (this.isGeneratingUpdate) {
1814
- logger6.debug(
1775
+ logger5.debug(
1815
1776
  { sessionId: this.sessionId },
1816
1777
  "Update already in progress - skipping duplicate generation"
1817
1778
  );
1818
1779
  return;
1819
1780
  }
1820
1781
  if (!this.statusUpdateState) {
1821
- logger6.warn({ sessionId: this.sessionId }, "No status update state - cannot generate update");
1782
+ logger5.warn({ sessionId: this.sessionId }, "No status update state - cannot generate update");
1822
1783
  return;
1823
1784
  }
1824
1785
  if (!this.graphId) {
1825
- logger6.warn({ sessionId: this.sessionId }, "No graph ID - cannot generate update");
1786
+ logger5.warn({ sessionId: this.sessionId }, "No graph ID - cannot generate update");
1826
1787
  return;
1827
1788
  }
1828
1789
  const newEventCount = this.events.length - this.statusUpdateState.lastEventCount;
@@ -1835,7 +1796,7 @@ var GraphSession = class {
1835
1796
  try {
1836
1797
  const streamHelper = getStreamHelper(this.sessionId);
1837
1798
  if (!streamHelper) {
1838
- logger6.warn(
1799
+ logger5.warn(
1839
1800
  { sessionId: this.sessionId },
1840
1801
  "No stream helper found - cannot send status update"
1841
1802
  );
@@ -1856,7 +1817,7 @@ var GraphSession = class {
1856
1817
  if (result.operations && result.operations.length > 0) {
1857
1818
  for (const op of result.operations) {
1858
1819
  if (!op || !op.type || !op.data || Object.keys(op.data).length === 0) {
1859
- logger6.warn(
1820
+ logger5.warn(
1860
1821
  {
1861
1822
  sessionId: this.sessionId,
1862
1823
  operation: op
@@ -1909,7 +1870,7 @@ var GraphSession = class {
1909
1870
  this.previousSummaries.shift();
1910
1871
  }
1911
1872
  if (!operation || !operation.type || !operation.ctx) {
1912
- logger6.warn(
1873
+ logger5.warn(
1913
1874
  {
1914
1875
  sessionId: this.sessionId,
1915
1876
  operation
@@ -1924,7 +1885,7 @@ var GraphSession = class {
1924
1885
  this.statusUpdateState.lastEventCount = this.events.length;
1925
1886
  }
1926
1887
  } catch (error) {
1927
- logger6.error(
1888
+ logger5.error(
1928
1889
  {
1929
1890
  sessionId: this.sessionId,
1930
1891
  error: error instanceof Error ? error.message : "Unknown error",
@@ -1962,7 +1923,7 @@ var GraphSession = class {
1962
1923
  this.releaseUpdateLock();
1963
1924
  }
1964
1925
  } catch (error) {
1965
- logger6.error(
1926
+ logger5.error(
1966
1927
  {
1967
1928
  sessionId: this.sessionId,
1968
1929
  error: error instanceof Error ? error.message : "Unknown error"
@@ -2039,7 +2000,7 @@ User's Question/Context:
2039
2000
  ${conversationHistory}
2040
2001
  ` : "";
2041
2002
  } catch (error) {
2042
- logger6.warn(
2003
+ logger5.warn(
2043
2004
  { sessionId: this.sessionId, error },
2044
2005
  "Failed to fetch conversation history for status update"
2045
2006
  );
@@ -2091,7 +2052,7 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
2091
2052
  return text.trim();
2092
2053
  } catch (error) {
2093
2054
  agentsCore.setSpanWithError(span, error);
2094
- logger6.error({ error }, "Failed to generate summary, using fallback");
2055
+ logger5.error({ error }, "Failed to generate summary, using fallback");
2095
2056
  return this.generateFallbackSummary(newEvents, elapsedTime);
2096
2057
  } finally {
2097
2058
  span.end();
@@ -2137,7 +2098,7 @@ User's Question/Context:
2137
2098
  ${conversationHistory}
2138
2099
  ` : "";
2139
2100
  } catch (error) {
2140
- logger6.warn(
2101
+ logger5.warn(
2141
2102
  { sessionId: this.sessionId, error },
2142
2103
  "Failed to fetch conversation history for structured status update"
2143
2104
  );
@@ -2236,7 +2197,7 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
2236
2197
  return { operations };
2237
2198
  } catch (error) {
2238
2199
  agentsCore.setSpanWithError(span, error);
2239
- logger6.error({ error }, "Failed to generate structured update, using fallback");
2200
+ logger5.error({ error }, "Failed to generate structured update, using fallback");
2240
2201
  return { operations: [] };
2241
2202
  } finally {
2242
2203
  span.end();
@@ -2563,7 +2524,7 @@ Make it specific and relevant.`;
2563
2524
  taskId: artifactData.taskId,
2564
2525
  artifacts: [artifactToSave]
2565
2526
  });
2566
- logger6.info(
2527
+ logger5.info(
2567
2528
  {
2568
2529
  sessionId: this.sessionId,
2569
2530
  artifactId: artifactData.artifactId,
@@ -2580,7 +2541,7 @@ Make it specific and relevant.`;
2580
2541
  span.setStatus({ code: api.SpanStatusCode.OK });
2581
2542
  } catch (error) {
2582
2543
  agentsCore.setSpanWithError(span, error);
2583
- logger6.error(
2544
+ logger5.error(
2584
2545
  {
2585
2546
  sessionId: this.sessionId,
2586
2547
  artifactId: artifactData.artifactId,
@@ -2616,7 +2577,7 @@ Make it specific and relevant.`;
2616
2577
  taskId: artifactData.taskId,
2617
2578
  artifacts: [fallbackArtifact]
2618
2579
  });
2619
- logger6.info(
2580
+ logger5.info(
2620
2581
  {
2621
2582
  sessionId: this.sessionId,
2622
2583
  artifactId: artifactData.artifactId
@@ -2625,7 +2586,7 @@ Make it specific and relevant.`;
2625
2586
  );
2626
2587
  }
2627
2588
  } catch (fallbackError) {
2628
- logger6.error(
2589
+ logger5.error(
2629
2590
  {
2630
2591
  sessionId: this.sessionId,
2631
2592
  artifactId: artifactData.artifactId,
@@ -2652,7 +2613,7 @@ var GraphSessionManager = class {
2652
2613
  const sessionId = messageId;
2653
2614
  const session = new GraphSession(sessionId, messageId, graphId, tenantId, projectId);
2654
2615
  this.sessions.set(sessionId, session);
2655
- logger6.info({ sessionId, messageId, graphId, tenantId, projectId }, "GraphSession created");
2616
+ logger5.info({ sessionId, messageId, graphId, tenantId, projectId }, "GraphSession created");
2656
2617
  return sessionId;
2657
2618
  }
2658
2619
  /**
@@ -2663,7 +2624,7 @@ var GraphSessionManager = class {
2663
2624
  if (session) {
2664
2625
  session.initializeStatusUpdates(config2, summarizerModel);
2665
2626
  } else {
2666
- logger6.error(
2627
+ logger5.error(
2667
2628
  {
2668
2629
  sessionId,
2669
2630
  availableSessions: Array.from(this.sessions.keys())
@@ -2684,7 +2645,7 @@ var GraphSessionManager = class {
2684
2645
  recordEvent(sessionId, eventType, agentId, data) {
2685
2646
  const session = this.sessions.get(sessionId);
2686
2647
  if (!session) {
2687
- logger6.warn({ sessionId }, "Attempted to record event in non-existent session");
2648
+ logger5.warn({ sessionId }, "Attempted to record event in non-existent session");
2688
2649
  return;
2689
2650
  }
2690
2651
  session.recordEvent(eventType, agentId, data);
@@ -2695,12 +2656,12 @@ var GraphSessionManager = class {
2695
2656
  endSession(sessionId) {
2696
2657
  const session = this.sessions.get(sessionId);
2697
2658
  if (!session) {
2698
- logger6.warn({ sessionId }, "Attempted to end non-existent session");
2659
+ logger5.warn({ sessionId }, "Attempted to end non-existent session");
2699
2660
  return [];
2700
2661
  }
2701
2662
  const events = session.getEvents();
2702
2663
  const summary = session.getSummary();
2703
- logger6.info({ sessionId, summary }, "GraphSession ended");
2664
+ logger5.info({ sessionId, summary }, "GraphSession ended");
2704
2665
  session.cleanup();
2705
2666
  this.sessions.delete(sessionId);
2706
2667
  return events;
@@ -2729,7 +2690,7 @@ var graphSessionManager = new GraphSessionManager();
2729
2690
 
2730
2691
  // src/utils/artifact-parser.ts
2731
2692
  init_dbClient();
2732
- var logger7 = getLogger("ArtifactParser");
2693
+ var logger6 = agentsCore.getLogger("ArtifactParser");
2733
2694
  var _ArtifactParser = class _ArtifactParser {
2734
2695
  constructor(tenantId) {
2735
2696
  this.tenantId = tenantId;
@@ -2795,7 +2756,7 @@ var _ArtifactParser = class _ArtifactParser {
2795
2756
  id: taskId
2796
2757
  });
2797
2758
  if (!task) {
2798
- logger7.warn({ taskId }, "Task not found when fetching artifacts");
2759
+ logger6.warn({ taskId }, "Task not found when fetching artifacts");
2799
2760
  continue;
2800
2761
  }
2801
2762
  const taskArtifacts = await agentsCore.getLedgerArtifacts(dbClient_default)({
@@ -2807,9 +2768,9 @@ var _ArtifactParser = class _ArtifactParser {
2807
2768
  artifacts.set(key, artifact);
2808
2769
  }
2809
2770
  }
2810
- logger7.debug({ contextId, count: artifacts.size }, "Loaded context artifacts");
2771
+ logger6.debug({ contextId, count: artifacts.size }, "Loaded context artifacts");
2811
2772
  } catch (error) {
2812
- logger7.error({ error, contextId }, "Error loading context artifacts");
2773
+ logger6.error({ error, contextId }, "Error loading context artifacts");
2813
2774
  }
2814
2775
  return artifacts;
2815
2776
  }
@@ -2912,7 +2873,7 @@ var _ArtifactParser = class _ArtifactParser {
2912
2873
  id: taskId
2913
2874
  });
2914
2875
  if (!task) {
2915
- logger7.warn({ taskId }, "Task not found when fetching artifact");
2876
+ logger6.warn({ taskId }, "Task not found when fetching artifact");
2916
2877
  return null;
2917
2878
  }
2918
2879
  const artifacts = await agentsCore.getLedgerArtifacts(dbClient_default)({
@@ -2924,7 +2885,7 @@ var _ArtifactParser = class _ArtifactParser {
2924
2885
  return this.formatArtifactData(artifacts[0], artifactId, taskId);
2925
2886
  }
2926
2887
  } catch (error) {
2927
- logger7.warn({ artifactId, taskId, error }, "Failed to fetch artifact");
2888
+ logger6.warn({ artifactId, taskId, error }, "Failed to fetch artifact");
2928
2889
  }
2929
2890
  return null;
2930
2891
  }
@@ -2964,7 +2925,7 @@ __publicField(_ArtifactParser, "INCOMPLETE_ARTIFACT_REGEX", /<(a(r(t(i(f(a(c(t(:
2964
2925
  var ArtifactParser = _ArtifactParser;
2965
2926
 
2966
2927
  // src/utils/incremental-stream-parser.ts
2967
- var logger8 = getLogger("IncrementalStreamParser");
2928
+ var logger7 = agentsCore.getLogger("IncrementalStreamParser");
2968
2929
  var IncrementalStreamParser = class {
2969
2930
  constructor(streamHelper, tenantId, contextId) {
2970
2931
  __publicField(this, "buffer", "");
@@ -3024,13 +2985,13 @@ var IncrementalStreamParser = class {
3024
2985
  if (part.type === "tool-call-delta" && part.toolName === targetToolName) {
3025
2986
  const delta = part.argsTextDelta || "";
3026
2987
  if (jsonBuffer.length + delta.length > MAX_BUFFER_SIZE) {
3027
- logger8.warn("JSON buffer exceeded maximum size, truncating");
2988
+ logger7.warn("JSON buffer exceeded maximum size, truncating");
3028
2989
  jsonBuffer = jsonBuffer.slice(-MAX_BUFFER_SIZE / 2);
3029
2990
  }
3030
2991
  jsonBuffer += delta;
3031
2992
  for (const char of delta) {
3032
2993
  if (componentBuffer.length > MAX_BUFFER_SIZE) {
3033
- logger8.warn("Component buffer exceeded maximum size, resetting");
2994
+ logger7.warn("Component buffer exceeded maximum size, resetting");
3034
2995
  componentBuffer = "";
3035
2996
  depth = 0;
3036
2997
  continue;
@@ -3045,7 +3006,7 @@ var IncrementalStreamParser = class {
3045
3006
  if (componentMatch) {
3046
3007
  const MAX_COMPONENT_SIZE = 1024 * 1024;
3047
3008
  if (componentMatch[0].length > MAX_COMPONENT_SIZE) {
3048
- logger8.warn(
3009
+ logger7.warn(
3049
3010
  {
3050
3011
  size: componentMatch[0].length,
3051
3012
  maxSize: MAX_COMPONENT_SIZE
@@ -3058,7 +3019,7 @@ var IncrementalStreamParser = class {
3058
3019
  try {
3059
3020
  const component = JSON.parse(componentMatch[0]);
3060
3021
  if (typeof component !== "object" || !component.id) {
3061
- logger8.warn("Invalid component structure, skipping");
3022
+ logger7.warn("Invalid component structure, skipping");
3062
3023
  componentBuffer = "";
3063
3024
  continue;
3064
3025
  }
@@ -3071,7 +3032,7 @@ var IncrementalStreamParser = class {
3071
3032
  componentsStreamed++;
3072
3033
  componentBuffer = "";
3073
3034
  } catch (e) {
3074
- logger8.debug({ error: e }, "Failed to parse component, continuing to accumulate");
3035
+ logger7.debug({ error: e }, "Failed to parse component, continuing to accumulate");
3075
3036
  }
3076
3037
  }
3077
3038
  }
@@ -3088,7 +3049,7 @@ var IncrementalStreamParser = class {
3088
3049
  break;
3089
3050
  }
3090
3051
  }
3091
- logger8.debug({ componentsStreamed }, "Finished streaming components");
3052
+ logger7.debug({ componentsStreamed }, "Finished streaming components");
3092
3053
  }
3093
3054
  /**
3094
3055
  * Legacy method for backward compatibility - defaults to text processing
@@ -3232,7 +3193,7 @@ var IncrementalStreamParser = class {
3232
3193
  };
3233
3194
 
3234
3195
  // src/utils/response-formatter.ts
3235
- var logger9 = getLogger("ResponseFormatter");
3196
+ var logger8 = agentsCore.getLogger("ResponseFormatter");
3236
3197
  var ResponseFormatter = class {
3237
3198
  constructor(tenantId) {
3238
3199
  __publicField(this, "artifactParser");
@@ -3263,7 +3224,7 @@ var ResponseFormatter = class {
3263
3224
  return { parts };
3264
3225
  } catch (error) {
3265
3226
  agentsCore.setSpanWithError(span, error);
3266
- logger9.error({ error, responseObject }, "Error formatting object response");
3227
+ logger8.error({ error, responseObject }, "Error formatting object response");
3267
3228
  return {
3268
3229
  parts: [{ kind: "data", data: responseObject }]
3269
3230
  };
@@ -3314,7 +3275,7 @@ var ResponseFormatter = class {
3314
3275
  return { parts };
3315
3276
  } catch (error) {
3316
3277
  agentsCore.setSpanWithError(span, error);
3317
- logger9.error({ error, responseText }, "Error formatting response");
3278
+ logger8.error({ error, responseText }, "Error formatting response");
3318
3279
  return { text: responseText };
3319
3280
  } finally {
3320
3281
  span.end();
@@ -3359,7 +3320,7 @@ var ResponseFormatter = class {
3359
3320
  }
3360
3321
  }
3361
3322
  };
3362
- var logger10 = getLogger("ToolSessionManager");
3323
+ var logger9 = agentsCore.getLogger("ToolSessionManager");
3363
3324
  var _ToolSessionManager = class _ToolSessionManager {
3364
3325
  // 5 minutes
3365
3326
  constructor() {
@@ -3388,7 +3349,7 @@ var _ToolSessionManager = class _ToolSessionManager {
3388
3349
  createdAt: Date.now()
3389
3350
  };
3390
3351
  this.sessions.set(sessionId, session);
3391
- logger10.debug({ sessionId, tenantId, contextId, taskId }, "Created tool session");
3352
+ logger9.debug({ sessionId, tenantId, contextId, taskId }, "Created tool session");
3392
3353
  return sessionId;
3393
3354
  }
3394
3355
  /**
@@ -3397,7 +3358,7 @@ var _ToolSessionManager = class _ToolSessionManager {
3397
3358
  recordToolResult(sessionId, toolResult) {
3398
3359
  const session = this.sessions.get(sessionId);
3399
3360
  if (!session) {
3400
- logger10.warn(
3361
+ logger9.warn(
3401
3362
  { sessionId, toolCallId: toolResult.toolCallId },
3402
3363
  "Tool result recorded for unknown session"
3403
3364
  );
@@ -3411,12 +3372,12 @@ var _ToolSessionManager = class _ToolSessionManager {
3411
3372
  getToolResult(sessionId, toolCallId) {
3412
3373
  const session = this.sessions.get(sessionId);
3413
3374
  if (!session) {
3414
- logger10.warn({ sessionId, toolCallId }, "Requested tool result for unknown session");
3375
+ logger9.warn({ sessionId, toolCallId }, "Requested tool result for unknown session");
3415
3376
  return void 0;
3416
3377
  }
3417
3378
  const result = session.toolResults.get(toolCallId);
3418
3379
  if (!result) {
3419
- logger10.warn(
3380
+ logger9.warn(
3420
3381
  {
3421
3382
  sessionId,
3422
3383
  toolCallId,
@@ -3455,10 +3416,10 @@ var _ToolSessionManager = class _ToolSessionManager {
3455
3416
  }
3456
3417
  for (const sessionId of expiredSessions) {
3457
3418
  this.sessions.delete(sessionId);
3458
- logger10.debug({ sessionId }, "Cleaned up expired tool session");
3419
+ logger9.debug({ sessionId }, "Cleaned up expired tool session");
3459
3420
  }
3460
3421
  if (expiredSessions.length > 0) {
3461
- logger10.info({ expiredCount: expiredSessions.length }, "Cleaned up expired tool sessions");
3422
+ logger9.info({ expiredCount: expiredSessions.length }, "Cleaned up expired tool sessions");
3462
3423
  }
3463
3424
  }
3464
3425
  };
@@ -3467,7 +3428,7 @@ var ToolSessionManager = _ToolSessionManager;
3467
3428
  var toolSessionManager = ToolSessionManager.getInstance();
3468
3429
 
3469
3430
  // src/agents/artifactTools.ts
3470
- var logger11 = getLogger("artifactTools");
3431
+ var logger10 = agentsCore.getLogger("artifactTools");
3471
3432
  function buildKeyNestingMap(data, prefix = "", map = /* @__PURE__ */ new Map()) {
3472
3433
  if (typeof data === "object" && data !== null) {
3473
3434
  if (Array.isArray(data)) {
@@ -3688,7 +3649,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
3688
3649
  execute: async ({ toolCallId, baseSelector, propSelectors, ...rest }, _context) => {
3689
3650
  const artifactType = "artifactType" in rest ? rest.artifactType : void 0;
3690
3651
  if (!sessionId) {
3691
- logger11.warn({ toolCallId }, "No session ID provided to save_tool_result");
3652
+ logger10.warn({ toolCallId }, "No session ID provided to save_tool_result");
3692
3653
  return {
3693
3654
  saved: false,
3694
3655
  error: `[toolCallId: ${toolCallId}] No session context available`,
@@ -3698,7 +3659,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
3698
3659
  }
3699
3660
  const toolResult = toolSessionManager.getToolResult(sessionId, toolCallId);
3700
3661
  if (!toolResult) {
3701
- logger11.warn({ toolCallId, sessionId }, "Tool result not found in session");
3662
+ logger10.warn({ toolCallId, sessionId }, "Tool result not found in session");
3702
3663
  return {
3703
3664
  saved: false,
3704
3665
  error: `[toolCallId: ${toolCallId}] Tool result not found`,
@@ -3711,7 +3672,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
3711
3672
  const baseData = jmespath__default.default.search(parsedResult, baseSelector);
3712
3673
  if (!baseData || Array.isArray(baseData) && baseData.length === 0) {
3713
3674
  const debugInfo = analyzeSelectorFailure(parsedResult, baseSelector);
3714
- logger11.warn(
3675
+ logger10.warn(
3715
3676
  {
3716
3677
  baseSelector,
3717
3678
  toolCallId,
@@ -3754,7 +3715,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
3754
3715
  const fallbackValue = item[propName];
3755
3716
  if (fallbackValue !== null && fallbackValue !== void 0) {
3756
3717
  extractedItem[propName] = fallbackValue;
3757
- logger11.info(
3718
+ logger10.info(
3758
3719
  { propName, propSelector, context },
3759
3720
  `PropSelector failed, used fallback direct property access`
3760
3721
  );
@@ -3766,7 +3727,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
3766
3727
  const fallbackValue = item[propName];
3767
3728
  if (fallbackValue !== null && fallbackValue !== void 0) {
3768
3729
  extractedItem[propName] = fallbackValue;
3769
- logger11.warn(
3730
+ logger10.warn(
3770
3731
  { propName, propSelector, context, error: error.message },
3771
3732
  `PropSelector syntax error, used fallback direct property access`
3772
3733
  );
@@ -3879,7 +3840,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
3879
3840
  warnings
3880
3841
  };
3881
3842
  } catch (error) {
3882
- logger11.error({ error, toolCallId, sessionId }, "Error processing save_tool_result");
3843
+ logger10.error({ error, toolCallId, sessionId }, "Error processing save_tool_result");
3883
3844
  return {
3884
3845
  saved: false,
3885
3846
  error: `[toolCallId: ${toolCallId}] ${error instanceof Error ? error.message : "Unknown error"}`,
@@ -3891,7 +3852,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
3891
3852
  }
3892
3853
 
3893
3854
  // src/a2a/client.ts
3894
- var logger12 = getLogger("a2aClient");
3855
+ var logger11 = agentsCore.getLogger("a2aClient");
3895
3856
  var DEFAULT_BACKOFF = {
3896
3857
  initialInterval: 500,
3897
3858
  maxInterval: 6e4,
@@ -3959,7 +3920,7 @@ var A2AClient = class {
3959
3920
  */
3960
3921
  async _fetchAndCacheAgentCard() {
3961
3922
  const agentCardUrl = `${this.agentBaseUrl}/.well-known/agent.json`;
3962
- getLogger("a2a").info({ agentCardUrl, agentBaseUrl: this.agentBaseUrl }, "agentCardUrl");
3923
+ agentsCore.getLogger("a2a").info({ agentCardUrl, agentBaseUrl: this.agentBaseUrl }, "agentCardUrl");
3963
3924
  try {
3964
3925
  const response = await fetch(agentCardUrl, {
3965
3926
  headers: {
@@ -4097,7 +4058,7 @@ var A2AClient = class {
4097
4058
  try {
4098
4059
  const res = await fn();
4099
4060
  if (attempt > 0) {
4100
- logger12.info(
4061
+ logger11.info(
4101
4062
  {
4102
4063
  attempts: attempt + 1,
4103
4064
  elapsedTime: Date.now() - start
@@ -4112,7 +4073,7 @@ var A2AClient = class {
4112
4073
  }
4113
4074
  const elapsed = Date.now() - start;
4114
4075
  if (elapsed > maxElapsedTime) {
4115
- logger12.warn(
4076
+ logger11.warn(
4116
4077
  {
4117
4078
  attempts: attempt + 1,
4118
4079
  elapsedTime: elapsed,
@@ -4133,7 +4094,7 @@ var A2AClient = class {
4133
4094
  retryInterval = initialInterval * attempt ** exponent + Math.random() * 1e3;
4134
4095
  }
4135
4096
  const delayMs = Math.min(retryInterval, maxInterval);
4136
- logger12.info(
4097
+ logger11.info(
4137
4098
  {
4138
4099
  attempt: attempt + 1,
4139
4100
  delayMs,
@@ -4218,7 +4179,7 @@ var A2AClient = class {
4218
4179
  }
4219
4180
  const rpcResponse = await httpResponse.json();
4220
4181
  if (rpcResponse.id !== requestId2) {
4221
- logger12.warn(
4182
+ logger11.warn(
4222
4183
  {
4223
4184
  method,
4224
4185
  expectedId: requestId2,
@@ -4417,7 +4378,7 @@ var A2AClient = class {
4417
4378
  try {
4418
4379
  while (true) {
4419
4380
  const { done, value } = await reader.read();
4420
- logger12.info({ done, value }, "parseA2ASseStream");
4381
+ logger11.info({ done, value }, "parseA2ASseStream");
4421
4382
  if (done) {
4422
4383
  if (eventDataBuffer.trim()) {
4423
4384
  const result = this._processSseEventData(
@@ -4506,7 +4467,7 @@ var A2AClient = class {
4506
4467
  // src/agents/relationTools.ts
4507
4468
  init_conversations();
4508
4469
  init_dbClient();
4509
- var logger13 = getLogger("relationships Tools");
4470
+ var logger12 = agentsCore.getLogger("relationships Tools");
4510
4471
  var generateTransferToolDescription = (config2) => {
4511
4472
  return `Hand off the conversation to agent ${config2.id}.
4512
4473
 
@@ -4544,7 +4505,7 @@ var createTransferToAgentTool = ({
4544
4505
  "transfer.to_agent_id": transferConfig.id ?? "unknown"
4545
4506
  });
4546
4507
  }
4547
- logger13.info(
4508
+ logger12.info(
4548
4509
  {
4549
4510
  transferTo: transferConfig.id ?? "unknown",
4550
4511
  fromAgent: callingAgentId
@@ -4692,7 +4653,7 @@ function createDelegateToAgentTool({
4692
4653
  ...isInternal ? { fromAgentId: callingAgentId } : { fromExternalAgentId: callingAgentId }
4693
4654
  }
4694
4655
  };
4695
- logger13.info({ messageToSend }, "messageToSend");
4656
+ logger12.info({ messageToSend }, "messageToSend");
4696
4657
  await agentsCore.createMessage(dbClient_default)({
4697
4658
  id: nanoid.nanoid(),
4698
4659
  tenantId,
@@ -4754,7 +4715,7 @@ function createDelegateToAgentTool({
4754
4715
  }
4755
4716
 
4756
4717
  // src/agents/SystemPromptBuilder.ts
4757
- var logger14 = getLogger("SystemPromptBuilder");
4718
+ var logger13 = agentsCore.getLogger("SystemPromptBuilder");
4758
4719
  var SystemPromptBuilder = class {
4759
4720
  constructor(version, versionConfig) {
4760
4721
  this.version = version;
@@ -4770,9 +4731,9 @@ var SystemPromptBuilder = class {
4770
4731
  this.templates.set(name, content);
4771
4732
  }
4772
4733
  this.loaded = true;
4773
- logger14.debug(`Loaded ${this.templates.size} templates for version ${this.version}`);
4734
+ logger13.debug(`Loaded ${this.templates.size} templates for version ${this.version}`);
4774
4735
  } catch (error) {
4775
- logger14.error({ error }, `Failed to load templates for version ${this.version}`);
4736
+ logger13.error({ error }, `Failed to load templates for version ${this.version}`);
4776
4737
  throw new Error(`Template loading failed: ${error}`);
4777
4738
  }
4778
4739
  }
@@ -5174,7 +5135,7 @@ function hasToolCallWithPrefix(prefix) {
5174
5135
  return false;
5175
5136
  };
5176
5137
  }
5177
- var logger15 = getLogger("Agent");
5138
+ var logger14 = agentsCore.getLogger("Agent");
5178
5139
  var CONSTANTS = {
5179
5140
  MAX_GENERATION_STEPS: 12,
5180
5141
  PHASE_1_TIMEOUT_MS: 27e4,
@@ -5427,14 +5388,14 @@ var Agent = class {
5427
5388
  for (const toolSet of tools) {
5428
5389
  for (const [toolName, originalTool] of Object.entries(toolSet)) {
5429
5390
  if (!isValidTool(originalTool)) {
5430
- logger15.error({ toolName }, "Invalid MCP tool structure - missing required properties");
5391
+ logger14.error({ toolName }, "Invalid MCP tool structure - missing required properties");
5431
5392
  continue;
5432
5393
  }
5433
5394
  const sessionWrappedTool = ai.tool({
5434
5395
  description: originalTool.description,
5435
5396
  inputSchema: originalTool.inputSchema,
5436
5397
  execute: async (args, { toolCallId }) => {
5437
- logger15.debug({ toolName, toolCallId }, "MCP Tool Called");
5398
+ logger14.debug({ toolName, toolCallId }, "MCP Tool Called");
5438
5399
  try {
5439
5400
  const result = await originalTool.execute(args, { toolCallId });
5440
5401
  toolSessionManager.recordToolResult(sessionId, {
@@ -5446,7 +5407,7 @@ var Agent = class {
5446
5407
  });
5447
5408
  return { result, toolCallId };
5448
5409
  } catch (error) {
5449
- logger15.error({ toolName, toolCallId, error }, "MCP tool execution failed");
5410
+ logger14.error({ toolName, toolCallId, error }, "MCP tool execution failed");
5450
5411
  throw error;
5451
5412
  }
5452
5413
  }
@@ -5531,7 +5492,7 @@ var Agent = class {
5531
5492
  selectedTools
5532
5493
  };
5533
5494
  }
5534
- logger15.info(
5495
+ logger14.info(
5535
5496
  {
5536
5497
  toolName: tool4.name,
5537
5498
  credentialReferenceId,
@@ -5571,7 +5532,7 @@ var Agent = class {
5571
5532
  async getResolvedContext(conversationId, requestContext) {
5572
5533
  try {
5573
5534
  if (!this.config.contextConfigId) {
5574
- logger15.debug({ graphId: this.config.graphId }, "No context config found for graph");
5535
+ logger14.debug({ graphId: this.config.graphId }, "No context config found for graph");
5575
5536
  return null;
5576
5537
  }
5577
5538
  const contextConfig = await agentsCore.getContextConfigById(dbClient_default)({
@@ -5579,7 +5540,7 @@ var Agent = class {
5579
5540
  id: this.config.contextConfigId
5580
5541
  });
5581
5542
  if (!contextConfig) {
5582
- logger15.warn({ contextConfigId: this.config.contextConfigId }, "Context config not found");
5543
+ logger14.warn({ contextConfigId: this.config.contextConfigId }, "Context config not found");
5583
5544
  return null;
5584
5545
  }
5585
5546
  if (!this.contextResolver) {
@@ -5596,7 +5557,7 @@ var Agent = class {
5596
5557
  $now: (/* @__PURE__ */ new Date()).toISOString(),
5597
5558
  $env: process.env
5598
5559
  };
5599
- logger15.debug(
5560
+ logger14.debug(
5600
5561
  {
5601
5562
  conversationId,
5602
5563
  contextConfigId: contextConfig.id,
@@ -5610,7 +5571,7 @@ var Agent = class {
5610
5571
  );
5611
5572
  return contextWithBuiltins;
5612
5573
  } catch (error) {
5613
- logger15.error(
5574
+ logger14.error(
5614
5575
  {
5615
5576
  conversationId,
5616
5577
  error: error instanceof Error ? error.message : "Unknown error"
@@ -5634,7 +5595,7 @@ var Agent = class {
5634
5595
  });
5635
5596
  return graphDefinition?.graphPrompt || void 0;
5636
5597
  } catch (error) {
5637
- logger15.warn(
5598
+ logger14.warn(
5638
5599
  {
5639
5600
  graphId: this.config.graphId,
5640
5601
  error: error instanceof Error ? error.message : "Unknown error"
@@ -5661,7 +5622,7 @@ var Agent = class {
5661
5622
  }
5662
5623
  return !!(graphDefinition.artifactComponents && Object.keys(graphDefinition.artifactComponents).length > 0);
5663
5624
  } catch (error) {
5664
- logger15.warn(
5625
+ logger14.warn(
5665
5626
  {
5666
5627
  graphId: this.config.graphId,
5667
5628
  tenantId: this.config.tenantId,
@@ -5721,7 +5682,7 @@ Key requirements:
5721
5682
  preserveUnresolved: false
5722
5683
  });
5723
5684
  } catch (error) {
5724
- logger15.error(
5685
+ logger14.error(
5725
5686
  {
5726
5687
  conversationId,
5727
5688
  error: error instanceof Error ? error.message : "Unknown error"
@@ -5766,7 +5727,7 @@ Key requirements:
5766
5727
  preserveUnresolved: false
5767
5728
  });
5768
5729
  } catch (error) {
5769
- logger15.error(
5730
+ logger14.error(
5770
5731
  {
5771
5732
  conversationId,
5772
5733
  error: error instanceof Error ? error.message : "Unknown error"
@@ -5794,7 +5755,7 @@ Key requirements:
5794
5755
  artifactId: z5.z.string().describe("The unique identifier of the artifact to get.")
5795
5756
  }),
5796
5757
  execute: async ({ artifactId }) => {
5797
- logger15.info({ artifactId }, "get_artifact executed");
5758
+ logger14.info({ artifactId }, "get_artifact executed");
5798
5759
  const artifact = await agentsCore.getLedgerArtifacts(dbClient_default)({
5799
5760
  scopes: {
5800
5761
  tenantId: this.config.tenantId,
@@ -5861,7 +5822,7 @@ Key requirements:
5861
5822
  graphId: this.config.graphId
5862
5823
  });
5863
5824
  } catch (error) {
5864
- logger15.error(
5825
+ logger14.error(
5865
5826
  { error, graphId: this.config.graphId },
5866
5827
  "Failed to check graph artifact components"
5867
5828
  );
@@ -5965,7 +5926,7 @@ Key requirements:
5965
5926
  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
5927
  const timeoutMs = Math.min(configuredTimeout, MAX_ALLOWED_TIMEOUT_MS);
5967
5928
  if (modelSettings.maxDuration && modelSettings.maxDuration * 1e3 > MAX_ALLOWED_TIMEOUT_MS) {
5968
- logger15.warn(
5929
+ logger14.warn(
5969
5930
  {
5970
5931
  requestedTimeout: modelSettings.maxDuration * 1e3,
5971
5932
  appliedTimeout: timeoutMs,
@@ -6007,7 +5968,7 @@ Key requirements:
6007
5968
  }
6008
5969
  );
6009
5970
  } catch (error) {
6010
- logger15.debug("Failed to track agent reasoning");
5971
+ logger14.debug("Failed to track agent reasoning");
6011
5972
  }
6012
5973
  }
6013
5974
  if (last && "toolCalls" in last && last.toolCalls) {
@@ -6090,7 +6051,7 @@ Key requirements:
6090
6051
  }
6091
6052
  );
6092
6053
  } catch (error) {
6093
- logger15.debug("Failed to track agent reasoning");
6054
+ logger14.debug("Failed to track agent reasoning");
6094
6055
  }
6095
6056
  }
6096
6057
  if (last && "toolCalls" in last && last.toolCalls) {
@@ -6135,7 +6096,7 @@ Key requirements:
6135
6096
  return;
6136
6097
  }
6137
6098
  if (toolName === "save_artifact_tool" || toolName === "save_tool_result") {
6138
- logger15.info({ result }, "save_artifact_tool or save_tool_result");
6099
+ logger14.info({ result }, "save_artifact_tool or save_tool_result");
6139
6100
  if (result.output.artifacts) {
6140
6101
  for (const artifact of result.output.artifacts) {
6141
6102
  const artifactId = artifact?.artifactId || "N/A";
@@ -6323,7 +6284,7 @@ function parseEmbeddedJson(data) {
6323
6284
  }
6324
6285
  });
6325
6286
  }
6326
- var logger16 = getLogger("generateTaskHandler");
6287
+ var logger15 = agentsCore.getLogger("generateTaskHandler");
6327
6288
  var createTaskHandler = (config2, credentialStoreRegistry) => {
6328
6289
  return async (task) => {
6329
6290
  try {
@@ -6373,7 +6334,7 @@ var createTaskHandler = (config2, credentialStoreRegistry) => {
6373
6334
  agentId: config2.agentId
6374
6335
  })
6375
6336
  ]);
6376
- logger16.info({ toolsForAgent, internalRelations, externalRelations }, "agent stuff");
6337
+ logger15.info({ toolsForAgent, internalRelations, externalRelations }, "agent stuff");
6377
6338
  const agentPrompt = "prompt" in config2.agentSchema ? config2.agentSchema.prompt : "";
6378
6339
  const models = "models" in config2.agentSchema ? config2.agentSchema.models : void 0;
6379
6340
  const stopWhen = "stopWhen" in config2.agentSchema ? config2.agentSchema.stopWhen : void 0;
@@ -6473,7 +6434,7 @@ var createTaskHandler = (config2, credentialStoreRegistry) => {
6473
6434
  const taskIdMatch = task.id.match(/^task_([^-]+-[^-]+-\d+)-/);
6474
6435
  if (taskIdMatch) {
6475
6436
  contextId = taskIdMatch[1];
6476
- logger16.info(
6437
+ logger15.info(
6477
6438
  {
6478
6439
  taskId: task.id,
6479
6440
  extractedContextId: contextId,
@@ -6489,7 +6450,7 @@ var createTaskHandler = (config2, credentialStoreRegistry) => {
6489
6450
  const isDelegation = task.context?.metadata?.isDelegation === true;
6490
6451
  agent.setDelegationStatus(isDelegation);
6491
6452
  if (isDelegation) {
6492
- logger16.info(
6453
+ logger15.info(
6493
6454
  { agentId: config2.agentId, taskId: task.id },
6494
6455
  "Delegated agent - streaming disabled"
6495
6456
  );
@@ -6772,7 +6733,7 @@ async function getRegisteredAgent(executionContext, credentialStoreRegistry) {
6772
6733
  // src/routes/agents.ts
6773
6734
  init_dbClient();
6774
6735
  var app = new zodOpenapi.OpenAPIHono();
6775
- var logger17 = getLogger("agents");
6736
+ var logger16 = agentsCore.getLogger("agents");
6776
6737
  app.openapi(
6777
6738
  zodOpenapi.createRoute({
6778
6739
  method: "get",
@@ -6810,7 +6771,7 @@ app.openapi(
6810
6771
  tracestate: c.req.header("tracestate"),
6811
6772
  baggage: c.req.header("baggage")
6812
6773
  };
6813
- logger17.info(
6774
+ logger16.info(
6814
6775
  {
6815
6776
  otelHeaders,
6816
6777
  path: c.req.path,
@@ -6821,7 +6782,7 @@ app.openapi(
6821
6782
  const executionContext = agentsCore.getRequestExecutionContext(c);
6822
6783
  const { tenantId, projectId, graphId, agentId } = executionContext;
6823
6784
  if (agentId) {
6824
- logger17.info(
6785
+ logger16.info(
6825
6786
  {
6826
6787
  message: "getRegisteredAgent (agent-level)",
6827
6788
  tenantId,
@@ -6833,13 +6794,13 @@ app.openapi(
6833
6794
  );
6834
6795
  const credentialStores = c.get("credentialStores");
6835
6796
  const agent = await getRegisteredAgent(executionContext, credentialStores);
6836
- logger17.info({ agent }, "agent registered: well-known agent.json");
6797
+ logger16.info({ agent }, "agent registered: well-known agent.json");
6837
6798
  if (!agent) {
6838
6799
  return c.json({ error: "Agent not found" }, 404);
6839
6800
  }
6840
6801
  return c.json(agent.agentCard);
6841
6802
  } else {
6842
- logger17.info(
6803
+ logger16.info(
6843
6804
  {
6844
6805
  message: "getRegisteredGraph (graph-level)",
6845
6806
  tenantId,
@@ -6862,7 +6823,7 @@ app.post("/a2a", async (c) => {
6862
6823
  tracestate: c.req.header("tracestate"),
6863
6824
  baggage: c.req.header("baggage")
6864
6825
  };
6865
- logger17.info(
6826
+ logger16.info(
6866
6827
  {
6867
6828
  otelHeaders,
6868
6829
  path: c.req.path,
@@ -6873,7 +6834,7 @@ app.post("/a2a", async (c) => {
6873
6834
  const executionContext = agentsCore.getRequestExecutionContext(c);
6874
6835
  const { tenantId, projectId, graphId, agentId } = executionContext;
6875
6836
  if (agentId) {
6876
- logger17.info(
6837
+ logger16.info(
6877
6838
  {
6878
6839
  message: "a2a (agent-level)",
6879
6840
  tenantId,
@@ -6897,7 +6858,7 @@ app.post("/a2a", async (c) => {
6897
6858
  }
6898
6859
  return a2aHandler(c, agent);
6899
6860
  } else {
6900
- logger17.info(
6861
+ logger16.info(
6901
6862
  {
6902
6863
  message: "a2a (graph-level)",
6903
6864
  tenantId,
@@ -6943,14 +6904,14 @@ init_dbClient();
6943
6904
 
6944
6905
  // src/a2a/transfer.ts
6945
6906
  init_dbClient();
6946
- var logger18 = getLogger("Transfer");
6907
+ var logger17 = agentsCore.getLogger("Transfer");
6947
6908
  async function executeTransfer({
6948
6909
  tenantId,
6949
6910
  threadId,
6950
6911
  projectId,
6951
6912
  targetAgentId
6952
6913
  }) {
6953
- logger18.info({ targetAgent: targetAgentId }, "Executing transfer to agent");
6914
+ logger17.info({ targetAgent: targetAgentId }, "Executing transfer to agent");
6954
6915
  await agentsCore.setActiveAgentForThread(dbClient_default)({
6955
6916
  scopes: { tenantId, projectId },
6956
6917
  threadId,
@@ -7494,7 +7455,7 @@ function createMCPStreamHelper() {
7494
7455
 
7495
7456
  // src/handlers/executionHandler.ts
7496
7457
  init_dbClient();
7497
- var logger19 = getLogger("ExecutionHandler");
7458
+ var logger18 = agentsCore.getLogger("ExecutionHandler");
7498
7459
  var ExecutionHandler = class {
7499
7460
  constructor() {
7500
7461
  // Hardcoded error limit - separate from configurable stopWhen
@@ -7519,7 +7480,7 @@ var ExecutionHandler = class {
7519
7480
  const { tenantId, projectId, graphId, apiKey, baseUrl } = executionContext;
7520
7481
  registerStreamHelper(requestId2, sseHelper);
7521
7482
  graphSessionManager.createSession(requestId2, graphId, tenantId, projectId);
7522
- logger19.info({ sessionId: requestId2, graphId }, "Created GraphSession for message execution");
7483
+ logger18.info({ sessionId: requestId2, graphId }, "Created GraphSession for message execution");
7523
7484
  let graphConfig = null;
7524
7485
  try {
7525
7486
  graphConfig = await agentsCore.getFullGraph(dbClient_default)({ scopes: { tenantId, projectId }, graphId });
@@ -7531,7 +7492,7 @@ var ExecutionHandler = class {
7531
7492
  );
7532
7493
  }
7533
7494
  } catch (error) {
7534
- logger19.error(
7495
+ logger18.error(
7535
7496
  {
7536
7497
  error: error instanceof Error ? error.message : "Unknown error",
7537
7498
  stack: error instanceof Error ? error.stack : void 0
@@ -7547,7 +7508,7 @@ var ExecutionHandler = class {
7547
7508
  try {
7548
7509
  await sseHelper.writeOperation(agentInitializingOp(requestId2, graphId));
7549
7510
  const taskId = `task_${conversationId}-${requestId2}`;
7550
- logger19.info(
7511
+ logger18.info(
7551
7512
  { taskId, currentAgentId, conversationId, requestId: requestId2 },
7552
7513
  "Attempting to create or reuse existing task"
7553
7514
  );
@@ -7570,7 +7531,7 @@ var ExecutionHandler = class {
7570
7531
  agent_id: currentAgentId
7571
7532
  }
7572
7533
  });
7573
- logger19.info(
7534
+ logger18.info(
7574
7535
  {
7575
7536
  taskId,
7576
7537
  createdTaskMetadata: Array.isArray(task) ? task[0]?.metadata : task?.metadata
@@ -7579,27 +7540,27 @@ var ExecutionHandler = class {
7579
7540
  );
7580
7541
  } catch (error) {
7581
7542
  if (error?.message?.includes("UNIQUE constraint failed") || error?.message?.includes("PRIMARY KEY constraint failed") || error?.code === "SQLITE_CONSTRAINT_PRIMARYKEY") {
7582
- logger19.info(
7543
+ logger18.info(
7583
7544
  { taskId, error: error.message },
7584
7545
  "Task already exists, fetching existing task"
7585
7546
  );
7586
7547
  const existingTask = await agentsCore.getTask(dbClient_default)({ id: taskId });
7587
7548
  if (existingTask) {
7588
7549
  task = existingTask;
7589
- logger19.info(
7550
+ logger18.info(
7590
7551
  { taskId, existingTask },
7591
7552
  "Successfully reused existing task from race condition"
7592
7553
  );
7593
7554
  } else {
7594
- logger19.error({ taskId, error }, "Task constraint failed but task not found");
7555
+ logger18.error({ taskId, error }, "Task constraint failed but task not found");
7595
7556
  throw error;
7596
7557
  }
7597
7558
  } else {
7598
- logger19.error({ taskId, error }, "Failed to create task due to non-constraint error");
7559
+ logger18.error({ taskId, error }, "Failed to create task due to non-constraint error");
7599
7560
  throw error;
7600
7561
  }
7601
7562
  }
7602
- logger19.debug(
7563
+ logger18.debug(
7603
7564
  {
7604
7565
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
7605
7566
  executionType: "create_initial_task",
@@ -7617,7 +7578,7 @@ var ExecutionHandler = class {
7617
7578
  const maxTransfers = graphConfig?.stopWhen?.transferCountIs ?? 10;
7618
7579
  while (iterations < maxTransfers) {
7619
7580
  iterations++;
7620
- logger19.info(
7581
+ logger18.info(
7621
7582
  { iterations, currentAgentId, graphId, conversationId, fromAgentId },
7622
7583
  `Execution loop iteration ${iterations} with agent ${currentAgentId}, transfer from: ${fromAgentId || "none"}`
7623
7584
  );
@@ -7625,10 +7586,10 @@ var ExecutionHandler = class {
7625
7586
  scopes: { tenantId, projectId },
7626
7587
  conversationId
7627
7588
  });
7628
- logger19.info({ activeAgent }, "activeAgent");
7589
+ logger18.info({ activeAgent }, "activeAgent");
7629
7590
  if (activeAgent && activeAgent.activeAgentId !== currentAgentId) {
7630
7591
  currentAgentId = activeAgent.activeAgentId;
7631
- logger19.info({ currentAgentId }, `Updated current agent to: ${currentAgentId}`);
7592
+ logger18.info({ currentAgentId }, `Updated current agent to: ${currentAgentId}`);
7632
7593
  }
7633
7594
  const agentBaseUrl = `${baseUrl}/agents`;
7634
7595
  const a2aClient = new A2AClient(agentBaseUrl, {
@@ -7669,13 +7630,13 @@ var ExecutionHandler = class {
7669
7630
  });
7670
7631
  if (!messageResponse?.result) {
7671
7632
  errorCount++;
7672
- logger19.error(
7633
+ logger18.error(
7673
7634
  { currentAgentId, iterations, errorCount },
7674
7635
  `No response from agent ${currentAgentId} on iteration ${iterations} (error ${errorCount}/${this.MAX_ERRORS})`
7675
7636
  );
7676
7637
  if (errorCount >= this.MAX_ERRORS) {
7677
7638
  const errorMessage2 = `Maximum error limit (${this.MAX_ERRORS}) reached`;
7678
- logger19.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
7639
+ logger18.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
7679
7640
  await sseHelper.writeError(errorMessage2);
7680
7641
  await sseHelper.writeOperation(errorOp(errorMessage2, currentAgentId || "system"));
7681
7642
  if (task) {
@@ -7701,7 +7662,7 @@ var ExecutionHandler = class {
7701
7662
  const transferResponse = messageResponse.result;
7702
7663
  const targetAgentId = transferResponse.artifacts?.[0]?.parts?.[0]?.data?.targetAgentId;
7703
7664
  const transferReason = transferResponse.artifacts?.[0]?.parts?.[1]?.text;
7704
- logger19.info({ targetAgentId, transferReason }, "transfer response");
7665
+ logger18.info({ targetAgentId, transferReason }, "transfer response");
7705
7666
  currentMessage = `<transfer_context> ${transferReason} </transfer_context>`;
7706
7667
  const { success, targetAgentId: newAgentId } = await executeTransfer({
7707
7668
  projectId,
@@ -7712,7 +7673,7 @@ var ExecutionHandler = class {
7712
7673
  if (success) {
7713
7674
  fromAgentId = currentAgentId;
7714
7675
  currentAgentId = newAgentId;
7715
- logger19.info(
7676
+ logger18.info(
7716
7677
  {
7717
7678
  transferFrom: fromAgentId,
7718
7679
  transferTo: currentAgentId,
@@ -7730,7 +7691,7 @@ var ExecutionHandler = class {
7730
7691
  const graphSessionData = graphSessionManager.getSession(requestId2);
7731
7692
  if (graphSessionData) {
7732
7693
  const sessionSummary = graphSessionData.getSummary();
7733
- logger19.info(sessionSummary, "GraphSession data after completion");
7694
+ logger18.info(sessionSummary, "GraphSession data after completion");
7734
7695
  }
7735
7696
  let textContent = "";
7736
7697
  for (const part of responseParts) {
@@ -7785,32 +7746,32 @@ var ExecutionHandler = class {
7785
7746
  }
7786
7747
  });
7787
7748
  const updateTaskEnd = Date.now();
7788
- logger19.info(
7749
+ logger18.info(
7789
7750
  { duration: updateTaskEnd - updateTaskStart },
7790
7751
  "Completed updateTask operation"
7791
7752
  );
7792
7753
  await sseHelper.writeOperation(completionOp(currentAgentId, iterations));
7793
7754
  await sseHelper.complete();
7794
- logger19.info("Ending GraphSession and cleaning up");
7755
+ logger18.info({}, "Ending GraphSession and cleaning up");
7795
7756
  graphSessionManager.endSession(requestId2);
7796
- logger19.info("Cleaning up streamHelper");
7757
+ logger18.info({}, "Cleaning up streamHelper");
7797
7758
  unregisterStreamHelper(requestId2);
7798
7759
  let response;
7799
7760
  if (sseHelper instanceof MCPStreamHelper) {
7800
7761
  const captured = sseHelper.getCapturedResponse();
7801
7762
  response = captured.text || "No response content";
7802
7763
  }
7803
- logger19.info("ExecutionHandler returning success");
7764
+ logger18.info({}, "ExecutionHandler returning success");
7804
7765
  return { success: true, iterations, response };
7805
7766
  }
7806
7767
  errorCount++;
7807
- logger19.warn(
7768
+ logger18.warn(
7808
7769
  { iterations, errorCount },
7809
7770
  `No valid response or transfer on iteration ${iterations} (error ${errorCount}/${this.MAX_ERRORS})`
7810
7771
  );
7811
7772
  if (errorCount >= this.MAX_ERRORS) {
7812
7773
  const errorMessage2 = `Maximum error limit (${this.MAX_ERRORS}) reached`;
7813
- logger19.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
7774
+ logger18.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
7814
7775
  await sseHelper.writeError(errorMessage2);
7815
7776
  await sseHelper.writeOperation(errorOp(errorMessage2, currentAgentId || "system"));
7816
7777
  if (task) {
@@ -7832,7 +7793,7 @@ var ExecutionHandler = class {
7832
7793
  }
7833
7794
  }
7834
7795
  const errorMessage = `Maximum transfer limit (${maxTransfers}) reached without completion`;
7835
- logger19.error({ maxTransfers, iterations }, errorMessage);
7796
+ logger18.error({ maxTransfers, iterations }, errorMessage);
7836
7797
  await sseHelper.writeError(errorMessage);
7837
7798
  await sseHelper.writeOperation(errorOp(errorMessage, currentAgentId || "system"));
7838
7799
  if (task) {
@@ -7852,7 +7813,7 @@ var ExecutionHandler = class {
7852
7813
  unregisterStreamHelper(requestId2);
7853
7814
  return { success: false, error: errorMessage, iterations };
7854
7815
  } catch (error) {
7855
- logger19.error({ error }, "Error in execution handler");
7816
+ logger18.error({ error }, "Error in execution handler");
7856
7817
  const errorMessage = error instanceof Error ? error.message : "Unknown execution error";
7857
7818
  await sseHelper.writeError(`Execution error: ${errorMessage}`);
7858
7819
  await sseHelper.writeOperation(errorOp(errorMessage, currentAgentId || "system"));
@@ -7878,7 +7839,7 @@ var ExecutionHandler = class {
7878
7839
 
7879
7840
  // src/routes/chat.ts
7880
7841
  var app2 = new zodOpenapi.OpenAPIHono();
7881
- var logger20 = getLogger("completionsHandler");
7842
+ var logger19 = agentsCore.getLogger("completionsHandler");
7882
7843
  var chatCompletionsRoute = zodOpenapi.createRoute({
7883
7844
  method: "post",
7884
7845
  path: "/completions",
@@ -7983,7 +7944,7 @@ var chatCompletionsRoute = zodOpenapi.createRoute({
7983
7944
  });
7984
7945
  app2.use("/completions", agentsCore.contextValidationMiddleware(dbClient_default));
7985
7946
  app2.openapi(chatCompletionsRoute, async (c) => {
7986
- getLogger("chat").info(
7947
+ agentsCore.getLogger("chat").info(
7987
7948
  {
7988
7949
  path: c.req.path,
7989
7950
  method: c.req.method,
@@ -7996,7 +7957,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
7996
7957
  tracestate: c.req.header("tracestate"),
7997
7958
  baggage: c.req.header("baggage")
7998
7959
  };
7999
- logger20.info(
7960
+ logger19.info(
8000
7961
  {
8001
7962
  otelHeaders,
8002
7963
  path: c.req.path,
@@ -8007,7 +7968,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
8007
7968
  try {
8008
7969
  const executionContext = agentsCore.getRequestExecutionContext(c);
8009
7970
  const { tenantId, projectId, graphId } = executionContext;
8010
- getLogger("chat").debug(
7971
+ agentsCore.getLogger("chat").debug(
8011
7972
  {
8012
7973
  tenantId,
8013
7974
  graphId
@@ -8082,7 +8043,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
8082
8043
  dbClient_default,
8083
8044
  credentialStores
8084
8045
  );
8085
- logger20.info(
8046
+ logger19.info(
8086
8047
  {
8087
8048
  tenantId,
8088
8049
  graphId,
@@ -8128,7 +8089,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
8128
8089
  return streaming.streamSSE(c, async (stream2) => {
8129
8090
  const sseHelper = createSSEStreamHelper(stream2, requestId2, timestamp);
8130
8091
  await sseHelper.writeRole();
8131
- logger20.info({ agentId }, "Starting execution");
8092
+ logger19.info({ agentId }, "Starting execution");
8132
8093
  const executionHandler = new ExecutionHandler();
8133
8094
  const result = await executionHandler.execute({
8134
8095
  executionContext,
@@ -8138,7 +8099,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
8138
8099
  requestId: requestId2,
8139
8100
  sseHelper
8140
8101
  });
8141
- logger20.info(
8102
+ logger19.info(
8142
8103
  { result },
8143
8104
  `Execution completed: ${result.success ? "success" : "failed"} after ${result.iterations} iterations`
8144
8105
  );
@@ -8174,7 +8135,7 @@ var chat_default = app2;
8174
8135
  // src/routes/chatDataStream.ts
8175
8136
  init_dbClient();
8176
8137
  var app3 = new zodOpenapi.OpenAPIHono();
8177
- var logger21 = getLogger("chatDataStream");
8138
+ var logger20 = agentsCore.getLogger("chatDataStream");
8178
8139
  var chatDataStreamRoute = zodOpenapi.createRoute({
8179
8140
  method: "post",
8180
8141
  path: "/chat",
@@ -8279,7 +8240,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
8279
8240
  );
8280
8241
  const lastUserMessage = body.messages.filter((m) => m.role === "user").slice(-1)[0];
8281
8242
  const userText = typeof lastUserMessage?.content === "string" ? lastUserMessage.content : lastUserMessage?.parts?.map((p) => p.text).join("") || "";
8282
- logger21.info({ userText, lastUserMessage }, "userText");
8243
+ logger20.info({ userText, lastUserMessage }, "userText");
8283
8244
  const messageSpan = api.trace.getActiveSpan();
8284
8245
  if (messageSpan) {
8285
8246
  messageSpan.setAttributes({
@@ -8321,7 +8282,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
8321
8282
  await streamHelper.writeError("Unable to process request");
8322
8283
  }
8323
8284
  } catch (err) {
8324
- logger21.error({ err }, "Streaming error");
8285
+ logger20.error({ err }, "Streaming error");
8325
8286
  await streamHelper.writeError("Internal server error");
8326
8287
  } finally {
8327
8288
  if ("cleanup" in streamHelper && typeof streamHelper.cleanup === "function") {
@@ -8342,7 +8303,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
8342
8303
  )
8343
8304
  );
8344
8305
  } catch (error) {
8345
- logger21.error({ error }, "chatDataStream error");
8306
+ logger20.error({ error }, "chatDataStream error");
8346
8307
  return c.json({ error: "Failed to process chat completion" }, 500);
8347
8308
  }
8348
8309
  });
@@ -8353,7 +8314,7 @@ init_dbClient();
8353
8314
  function createMCPSchema(schema) {
8354
8315
  return schema;
8355
8316
  }
8356
- var logger22 = getLogger("mcp");
8317
+ var logger21 = agentsCore.getLogger("mcp");
8357
8318
  var _MockResponseSingleton = class _MockResponseSingleton {
8358
8319
  constructor() {
8359
8320
  __publicField(this, "mockRes");
@@ -8408,21 +8369,21 @@ var createSpoofInitMessage = (mcpProtocolVersion) => ({
8408
8369
  id: 0
8409
8370
  });
8410
8371
  var spoofTransportInitialization = async (transport, req, sessionId, mcpProtocolVersion) => {
8411
- logger22.info({ sessionId }, "Spoofing initialization message to set transport state");
8372
+ logger21.info({ sessionId }, "Spoofing initialization message to set transport state");
8412
8373
  const spoofInitMessage = createSpoofInitMessage(mcpProtocolVersion);
8413
8374
  const mockRes = MockResponseSingleton.getInstance().getMockResponse();
8414
8375
  try {
8415
8376
  await transport.handleRequest(req, mockRes, spoofInitMessage);
8416
- logger22.info({ sessionId }, "Successfully spoofed initialization");
8377
+ logger21.info({ sessionId }, "Successfully spoofed initialization");
8417
8378
  } catch (spoofError) {
8418
- logger22.warn({ sessionId, error: spoofError }, "Spoof initialization failed, continuing anyway");
8379
+ logger21.warn({ sessionId, error: spoofError }, "Spoof initialization failed, continuing anyway");
8419
8380
  }
8420
8381
  };
8421
8382
  var validateSession = async (req, res, body, tenantId, projectId, graphId) => {
8422
8383
  const sessionId = req.headers["mcp-session-id"];
8423
- logger22.info({ sessionId }, "Received MCP session ID");
8384
+ logger21.info({ sessionId }, "Received MCP session ID");
8424
8385
  if (!sessionId) {
8425
- logger22.info({ body }, "Missing session ID");
8386
+ logger21.info({ body }, "Missing session ID");
8426
8387
  res.writeHead(400).end(
8427
8388
  JSON.stringify({
8428
8389
  jsonrpc: "2.0",
@@ -8448,7 +8409,7 @@ var validateSession = async (req, res, body, tenantId, projectId, graphId) => {
8448
8409
  scopes: { tenantId, projectId },
8449
8410
  conversationId: sessionId
8450
8411
  });
8451
- logger22.info(
8412
+ logger21.info(
8452
8413
  {
8453
8414
  sessionId,
8454
8415
  conversationFound: !!conversation,
@@ -8459,7 +8420,7 @@ var validateSession = async (req, res, body, tenantId, projectId, graphId) => {
8459
8420
  "Conversation lookup result"
8460
8421
  );
8461
8422
  if (!conversation || conversation.metadata?.sessionData?.sessionType !== "mcp" || conversation.metadata?.sessionData?.graphId !== graphId) {
8462
- logger22.info(
8423
+ logger21.info(
8463
8424
  { sessionId, conversationId: conversation?.id },
8464
8425
  "MCP session not found or invalid"
8465
8426
  );
@@ -8520,7 +8481,7 @@ var executeAgentQuery = async (executionContext, conversationId, query, defaultA
8520
8481
  requestId: requestId2,
8521
8482
  sseHelper: mcpStreamHelper
8522
8483
  });
8523
- logger22.info(
8484
+ logger21.info(
8524
8485
  { result },
8525
8486
  `Execution completed: ${result.success ? "success" : "failed"} after ${result.iterations} iterations`
8526
8487
  );
@@ -8594,7 +8555,7 @@ var getServer = async (requestContext, executionContext, conversationId, credent
8594
8555
  dbClient_default,
8595
8556
  credentialStores
8596
8557
  );
8597
- logger22.info(
8558
+ logger21.info(
8598
8559
  {
8599
8560
  tenantId,
8600
8561
  graphId,
@@ -8633,10 +8594,10 @@ var validateRequestParameters = (c) => {
8633
8594
  try {
8634
8595
  const executionContext = agentsCore.getRequestExecutionContext(c);
8635
8596
  const { tenantId, projectId, graphId } = executionContext;
8636
- getLogger("mcp").debug({ tenantId, projectId, graphId }, "Extracted MCP entity parameters");
8597
+ agentsCore.getLogger("mcp").debug({ tenantId, projectId, graphId }, "Extracted MCP entity parameters");
8637
8598
  return { valid: true, executionContext };
8638
8599
  } catch (error) {
8639
- getLogger("chat").warn(
8600
+ agentsCore.getLogger("chat").warn(
8640
8601
  { error: error instanceof Error ? error.message : "Unknown error" },
8641
8602
  "Failed to get execution context"
8642
8603
  );
@@ -8655,7 +8616,7 @@ var validateRequestParameters = (c) => {
8655
8616
  };
8656
8617
  var handleInitializationRequest = async (body, executionContext, validatedContext, req, res, c, credentialStores) => {
8657
8618
  const { tenantId, projectId, graphId } = executionContext;
8658
- logger22.info({ body }, "Received initialization request");
8619
+ logger21.info({ body }, "Received initialization request");
8659
8620
  const sessionId = nanoid.nanoid();
8660
8621
  const agentGraph = await agentsCore.getAgentGraphWithDefaultAgent(dbClient_default)({
8661
8622
  scopes: { tenantId, projectId },
@@ -8686,7 +8647,7 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
8686
8647
  }
8687
8648
  }
8688
8649
  });
8689
- logger22.info(
8650
+ logger21.info(
8690
8651
  { sessionId, conversationId: conversation.id },
8691
8652
  "Created MCP session as conversation"
8692
8653
  );
@@ -8695,9 +8656,9 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
8695
8656
  });
8696
8657
  const server = await getServer(validatedContext, executionContext, sessionId, credentialStores);
8697
8658
  await server.connect(transport);
8698
- logger22.info({ sessionId }, "Server connected for initialization");
8659
+ logger21.info({ sessionId }, "Server connected for initialization");
8699
8660
  res.setHeader("Mcp-Session-Id", sessionId);
8700
- logger22.info(
8661
+ logger21.info(
8701
8662
  {
8702
8663
  sessionId,
8703
8664
  bodyMethod: body?.method,
@@ -8706,7 +8667,7 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
8706
8667
  "About to handle initialization request"
8707
8668
  );
8708
8669
  await transport.handleRequest(req, res, body);
8709
- logger22.info({ sessionId }, "Successfully handled initialization request");
8670
+ logger21.info({ sessionId }, "Successfully handled initialization request");
8710
8671
  return fetchToNode.toFetchResponse(res);
8711
8672
  };
8712
8673
  var handleExistingSessionRequest = async (body, executionContext, validatedContext, req, res, credentialStores) => {
@@ -8734,8 +8695,8 @@ var handleExistingSessionRequest = async (body, executionContext, validatedConte
8734
8695
  sessionId,
8735
8696
  conversation.metadata?.session_data?.mcpProtocolVersion
8736
8697
  );
8737
- logger22.info({ sessionId }, "Server connected and transport initialized");
8738
- logger22.info(
8698
+ logger21.info({ sessionId }, "Server connected and transport initialized");
8699
+ logger21.info(
8739
8700
  {
8740
8701
  sessionId,
8741
8702
  bodyKeys: Object.keys(body || {}),
@@ -8749,9 +8710,9 @@ var handleExistingSessionRequest = async (body, executionContext, validatedConte
8749
8710
  );
8750
8711
  try {
8751
8712
  await transport.handleRequest(req, res, body);
8752
- logger22.info({ sessionId }, "Successfully handled MCP request");
8713
+ logger21.info({ sessionId }, "Successfully handled MCP request");
8753
8714
  } catch (transportError) {
8754
- logger22.error(
8715
+ logger21.error(
8755
8716
  {
8756
8717
  sessionId,
8757
8718
  error: transportError,
@@ -8802,13 +8763,13 @@ app4.openapi(
8802
8763
  }
8803
8764
  const { executionContext } = paramValidation;
8804
8765
  const body = await c.req.json();
8805
- logger22.info({ body, bodyKeys: Object.keys(body || {}) }, "Parsed request body");
8766
+ logger21.info({ body, bodyKeys: Object.keys(body || {}) }, "Parsed request body");
8806
8767
  const isInitRequest = body.method === "initialize";
8807
8768
  const { req, res } = fetchToNode.toReqRes(c.req.raw);
8808
8769
  const validatedContext = c.get("validatedContext") || {};
8809
8770
  const credentialStores = c.get("credentialStores");
8810
- logger22.info({ validatedContext }, "Validated context");
8811
- logger22.info({ req }, "request");
8771
+ logger21.info({ validatedContext }, "Validated context");
8772
+ logger21.info({ req }, "request");
8812
8773
  if (isInitRequest) {
8813
8774
  return await handleInitializationRequest(
8814
8775
  body,
@@ -8830,7 +8791,7 @@ app4.openapi(
8830
8791
  );
8831
8792
  }
8832
8793
  } catch (e) {
8833
- logger22.error(
8794
+ logger21.error(
8834
8795
  {
8835
8796
  error: e instanceof Error ? e.message : e,
8836
8797
  stack: e instanceof Error ? e.stack : void 0
@@ -8842,7 +8803,7 @@ app4.openapi(
8842
8803
  }
8843
8804
  );
8844
8805
  app4.get("/", async (c) => {
8845
- logger22.info("Received GET MCP request");
8806
+ logger21.info({}, "Received GET MCP request");
8846
8807
  return c.json(
8847
8808
  {
8848
8809
  jsonrpc: "2.0",
@@ -8856,7 +8817,7 @@ app4.get("/", async (c) => {
8856
8817
  );
8857
8818
  });
8858
8819
  app4.delete("/", async (c) => {
8859
- logger22.info("Received DELETE MCP request");
8820
+ logger21.info({}, "Received DELETE MCP request");
8860
8821
  return c.json(
8861
8822
  {
8862
8823
  jsonrpc: "2.0",
@@ -8869,7 +8830,7 @@ app4.delete("/", async (c) => {
8869
8830
  var mcp_default = app4;
8870
8831
 
8871
8832
  // src/app.ts
8872
- var logger23 = getLogger("agents-run-api");
8833
+ var logger22 = agentsCore.getLogger("agents-run-api");
8873
8834
  function createExecutionHono(serverConfig, credentialStores) {
8874
8835
  const app6 = new zodOpenapi.OpenAPIHono();
8875
8836
  app6.use("*", requestId.requestId());
@@ -8891,19 +8852,6 @@ function createExecutionHono(serverConfig, credentialStores) {
8891
8852
  }
8892
8853
  return next();
8893
8854
  });
8894
- app6.use(
8895
- honoPino.pinoLogger({
8896
- pino: logger23 || pino.pino({ level: "debug" }),
8897
- http: {
8898
- onResLevel(c) {
8899
- if (c.res.status >= 500) {
8900
- return "error";
8901
- }
8902
- return "info";
8903
- }
8904
- }
8905
- })
8906
- );
8907
8855
  app6.onError(async (err, c) => {
8908
8856
  const isExpectedError = err instanceof httpException.HTTPException;
8909
8857
  const status = isExpectedError ? err.status : 500;
@@ -8937,8 +8885,8 @@ function createExecutionHono(serverConfig, credentialStores) {
8937
8885
  if (!isExpectedError) {
8938
8886
  const errorMessage = err instanceof Error ? err.message : String(err);
8939
8887
  const errorStack = err instanceof Error ? err.stack : void 0;
8940
- if (logger23) {
8941
- logger23.error(
8888
+ if (logger22) {
8889
+ logger22.error(
8942
8890
  {
8943
8891
  error: err,
8944
8892
  message: errorMessage,
@@ -8950,8 +8898,8 @@ function createExecutionHono(serverConfig, credentialStores) {
8950
8898
  );
8951
8899
  }
8952
8900
  } else {
8953
- if (logger23) {
8954
- logger23.error(
8901
+ if (logger22) {
8902
+ logger22.error(
8955
8903
  {
8956
8904
  error: err,
8957
8905
  path: c.req.path,
@@ -8968,8 +8916,8 @@ function createExecutionHono(serverConfig, credentialStores) {
8968
8916
  const response = err.getResponse();
8969
8917
  return response;
8970
8918
  } catch (responseError) {
8971
- if (logger23) {
8972
- logger23.error({ error: responseError }, "Error while handling HTTPException response");
8919
+ if (logger22) {
8920
+ logger22.error({ error: responseError }, "Error while handling HTTPException response");
8973
8921
  }
8974
8922
  }
8975
8923
  }
@@ -9003,7 +8951,7 @@ function createExecutionHono(serverConfig, credentialStores) {
9003
8951
  app6.use("*", async (c, next) => {
9004
8952
  const executionContext = c.get("executionContext");
9005
8953
  if (!executionContext) {
9006
- logger23.debug("Empty execution context");
8954
+ logger22.debug({}, "Empty execution context");
9007
8955
  return next();
9008
8956
  }
9009
8957
  const { tenantId, projectId, graphId } = executionContext;
@@ -9014,7 +8962,7 @@ function createExecutionHono(serverConfig, credentialStores) {
9014
8962
  const body = await cloned.json().catch(() => null);
9015
8963
  conversationId = body?.conversationId;
9016
8964
  } catch (_) {
9017
- logger23.debug("Conversation ID not found in JSON body");
8965
+ logger22.debug({}, "Conversation ID not found in JSON body");
9018
8966
  }
9019
8967
  }
9020
8968
  const entries = Object.fromEntries(
@@ -9029,7 +8977,7 @@ function createExecutionHono(serverConfig, credentialStores) {
9029
8977
  })
9030
8978
  );
9031
8979
  if (!Object.keys(entries).length) {
9032
- logger23.debug("Empty entries for baggage");
8980
+ logger22.debug({}, "Empty entries for baggage");
9033
8981
  return next();
9034
8982
  }
9035
8983
  const bag = Object.entries(entries).reduce(