@inkeep/agents-run-api 0.0.0-dev-20250911192304 → 0.0.0-dev-20250911210702

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -2,17 +2,17 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var autoInstrumentationsNode = require('@opentelemetry/auto-instrumentations-node');
6
- var baggageSpanProcessor = require('@opentelemetry/baggage-span-processor');
7
- var exporterTraceOtlpProto = require('@opentelemetry/exporter-trace-otlp-proto');
8
- var sdkNode = require('@opentelemetry/sdk-node');
9
- var sdkTraceNode = require('@opentelemetry/sdk-trace-node');
10
5
  var fs = require('fs');
11
6
  var path = require('path');
12
7
  var dotenv = require('dotenv');
13
8
  var z5 = require('zod');
14
9
  var agentsCore = require('@inkeep/agents-core');
15
10
  var nanoid = require('nanoid');
11
+ var autoInstrumentationsNode = require('@opentelemetry/auto-instrumentations-node');
12
+ var baggageSpanProcessor = require('@opentelemetry/baggage-span-processor');
13
+ var exporterTraceOtlpProto = require('@opentelemetry/exporter-trace-otlp-proto');
14
+ var sdkNode = require('@opentelemetry/sdk-node');
15
+ var sdkTraceNode = require('@opentelemetry/sdk-trace-node');
16
16
  var hono = require('hono');
17
17
  var zodOpenapi = require('@hono/zod-openapi');
18
18
  var api = require('@opentelemetry/api');
@@ -78,79 +78,6 @@ var __export = (target, all) => {
78
78
  __defProp(target, name, { get: all[name], enumerable: true });
79
79
  };
80
80
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
81
-
82
- // src/instrumentation.ts
83
- var instrumentation_exports = {};
84
- __export(instrumentation_exports, {
85
- sdk: () => sdk,
86
- spanProcessor: () => spanProcessor
87
- });
88
- var otlpUrl, otlpExporter, FanOutSpanProcessor, spanProcessor, sdk;
89
- var init_instrumentation = __esm({
90
- "src/instrumentation.ts"() {
91
- otlpUrl = process.env.OTEL_EXPORTER_OTLP_ENDPOINT || "http://localhost:14318/v1/traces";
92
- otlpExporter = new exporterTraceOtlpProto.OTLPTraceExporter({ url: otlpUrl });
93
- FanOutSpanProcessor = class {
94
- constructor(inner) {
95
- this.inner = inner;
96
- }
97
- onStart(span, parent) {
98
- this.inner.forEach((p) => p.onStart(span, parent));
99
- }
100
- onEnd(span) {
101
- this.inner.forEach((p) => p.onEnd(span));
102
- }
103
- forceFlush() {
104
- return Promise.all(this.inner.map((p) => p.forceFlush?.())).then(() => {
105
- });
106
- }
107
- shutdown() {
108
- return Promise.all(this.inner.map((p) => p.shutdown?.())).then(() => {
109
- });
110
- }
111
- };
112
- spanProcessor = new FanOutSpanProcessor([
113
- new baggageSpanProcessor.BaggageSpanProcessor(baggageSpanProcessor.ALLOW_ALL_BAGGAGE_KEYS),
114
- new sdkTraceNode.BatchSpanProcessor(otlpExporter, {
115
- maxExportBatchSize: 1,
116
- // Send immediately (vs 512)
117
- scheduledDelayMillis: 100,
118
- // 100ms delay (vs 5000ms)
119
- exportTimeoutMillis: 5e3,
120
- // 5s timeout (vs 30s)
121
- maxQueueSize: 512
122
- // Smaller queue
123
- })
124
- ]);
125
- sdk = new sdkNode.NodeSDK({
126
- serviceName: "inkeep-chat",
127
- spanProcessor,
128
- instrumentations: [
129
- autoInstrumentationsNode.getNodeAutoInstrumentations({
130
- "@opentelemetry/instrumentation-http": {
131
- enabled: true,
132
- requestHook: (span, request) => {
133
- const url = request?.url ?? request?.path;
134
- if (!url) return;
135
- const u = new URL(url, "http://localhost");
136
- span.updateName(`${request?.method || "UNKNOWN"} ${u.pathname}`);
137
- }
138
- },
139
- "@opentelemetry/instrumentation-undici": {
140
- requestHook: (span) => {
141
- const method = span.attributes?.["http.request.method"];
142
- const host = span.attributes?.["server.address"];
143
- const path2 = span.attributes?.["url.path"];
144
- if (method && path2)
145
- span.updateName(host ? `${method} ${host}${path2}` : `${method} ${path2}`);
146
- }
147
- }
148
- })
149
- ]
150
- });
151
- sdk.start();
152
- }
153
- });
154
81
  var environmentSchema, criticalEnv, loadEnvFile, envSchema, parseEnv, env;
155
82
  var init_env = __esm({
156
83
  "src/env.ts"() {
@@ -183,7 +110,8 @@ var init_env = __esm({
183
110
  OPENAI_API_KEY: z5.z.string().optional(),
184
111
  ANTHROPIC_API_KEY: z5.z.string(),
185
112
  INKEEP_AGENTS_RUN_BYPASS_SECRET: z5.z.string().optional(),
186
- OTEL_TRACES_FORCE_FLUSH_ENABLED: z5.z.stringbool().optional()
113
+ OTEL_MAX_EXPORT_BATCH_SIZE: z5.z.coerce.number().optional(),
114
+ OTEL_EXPORTER_OTLP_ENDPOINT: z5.z.string().optional().default("http://localhost:14318/v1/traces")
187
115
  });
188
116
  parseEnv = () => {
189
117
  try {
@@ -401,8 +329,63 @@ var init_conversations = __esm({
401
329
  }
402
330
  });
403
331
 
404
- // src/index.ts
405
- init_instrumentation();
332
+ // src/instrumentation.ts
333
+ init_env();
334
+ var otlpUrl = env.OTEL_EXPORTER_OTLP_ENDPOINT;
335
+ var otlpExporter = new exporterTraceOtlpProto.OTLPTraceExporter({ url: otlpUrl });
336
+ var FanOutSpanProcessor = class {
337
+ constructor(inner) {
338
+ this.inner = inner;
339
+ }
340
+ onStart(span, parent) {
341
+ this.inner.forEach((p) => p.onStart(span, parent));
342
+ }
343
+ onEnd(span) {
344
+ this.inner.forEach((p) => p.onEnd(span));
345
+ }
346
+ forceFlush() {
347
+ return Promise.all(this.inner.map((p) => p.forceFlush?.())).then(() => {
348
+ });
349
+ }
350
+ shutdown() {
351
+ return Promise.all(this.inner.map((p) => p.shutdown?.())).then(() => {
352
+ });
353
+ }
354
+ };
355
+ var maxExportBatchSize = env.OTEL_MAX_EXPORT_BATCH_SIZE ?? (env.ENVIRONMENT === "development" ? 1 : 512);
356
+ var spanProcessor = new FanOutSpanProcessor([
357
+ new baggageSpanProcessor.BaggageSpanProcessor(baggageSpanProcessor.ALLOW_ALL_BAGGAGE_KEYS),
358
+ new sdkTraceNode.BatchSpanProcessor(otlpExporter, {
359
+ maxExportBatchSize
360
+ })
361
+ ]);
362
+ var sdk = new sdkNode.NodeSDK({
363
+ serviceName: "inkeep-agents-run-api",
364
+ spanProcessor,
365
+ instrumentations: [
366
+ autoInstrumentationsNode.getNodeAutoInstrumentations({
367
+ "@opentelemetry/instrumentation-http": {
368
+ enabled: true,
369
+ requestHook: (span, request) => {
370
+ const url = request?.url ?? request?.path;
371
+ if (!url) return;
372
+ const u = new URL(url, "http://localhost");
373
+ span.updateName(`${request?.method || "UNKNOWN"} ${u.pathname}`);
374
+ }
375
+ },
376
+ "@opentelemetry/instrumentation-undici": {
377
+ requestHook: (span) => {
378
+ const method = span.attributes?.["http.request.method"];
379
+ const host = span.attributes?.["server.address"];
380
+ const path2 = span.attributes?.["url.path"];
381
+ if (method && path2)
382
+ span.updateName(host ? `${method} ${host}${path2}` : `${method} ${path2}`);
383
+ }
384
+ }
385
+ })
386
+ ]
387
+ });
388
+ sdk.start();
406
389
 
407
390
  // src/logger.ts
408
391
  init_env();
@@ -1235,81 +1218,10 @@ init_dbClient();
1235
1218
  init_conversations();
1236
1219
  init_dbClient();
1237
1220
 
1238
- // src/tracer.ts
1239
- init_env();
1240
- var FORCE_FLUSH_ENVIRONMENTS = ["development"];
1241
- var logger4 = getLogger("tracer");
1242
- var BASE = "inkeep-chat";
1243
- var SERVICE_NAME = "inkeep-chat";
1244
- var SERVICE_VERSION = "1.0.0";
1245
- var createSpanName = (suffix) => `${BASE}.${suffix}`;
1246
- var createNoOpSpan = () => ({
1247
- setAttributes: () => ({}),
1248
- recordException: () => ({}),
1249
- setStatus: () => ({}),
1250
- addEvent: () => ({}),
1251
- end: () => {
1252
- },
1253
- isRecording: () => false,
1254
- setAttribute: () => ({}),
1255
- updateName: () => ({}),
1256
- spanContext: () => ({
1257
- traceId: "00000000000000000000000000000000",
1258
- spanId: "0000000000000000",
1259
- traceFlags: 0
1260
- }),
1261
- addLink: () => ({}),
1262
- addLinks: () => ({})
1263
- });
1264
- var noopTracer = {
1265
- startActiveSpan(_name, arg1, arg2, arg3) {
1266
- const fn = typeof arg1 === "function" ? arg1 : typeof arg2 === "function" ? arg2 : arg3;
1267
- if (!fn) throw new Error("No callback function provided");
1268
- return fn(createNoOpSpan());
1269
- },
1270
- startSpan(_name, _options) {
1271
- return createNoOpSpan();
1272
- }
1273
- };
1274
- var globalTracerInstance = null;
1275
- function handleSpanError(span, error, logger24, logMessage) {
1276
- const errorMessage = error instanceof Error ? error.message : String(error);
1277
- span.recordException(error);
1278
- span.setStatus({
1279
- code: api.SpanStatusCode.ERROR,
1280
- message: errorMessage
1281
- });
1282
- }
1283
- function getGlobalTracer() {
1284
- if (!globalTracerInstance) {
1285
- try {
1286
- globalTracerInstance = api.trace.getTracer(SERVICE_NAME, SERVICE_VERSION);
1287
- } catch (_error) {
1288
- logger4.debug("OpenTelemetry tracer not available, using no-op tracer");
1289
- globalTracerInstance = noopTracer;
1290
- }
1291
- }
1292
- return globalTracerInstance;
1293
- }
1294
- async function forceFlushTracer() {
1295
- const isOtelTracesForceFlushEnabled = env.OTEL_TRACES_FORCE_FLUSH_ENABLED;
1296
- const isForceFlushEnvironment = env.ENVIRONMENT && FORCE_FLUSH_ENVIRONMENTS.includes(env.ENVIRONMENT);
1297
- const shouldForceFlush = isOtelTracesForceFlushEnabled === true || isOtelTracesForceFlushEnabled == null && isForceFlushEnvironment;
1298
- if (!shouldForceFlush) {
1299
- return;
1300
- }
1301
- try {
1302
- const { spanProcessor: spanProcessor2 } = await Promise.resolve().then(() => (init_instrumentation(), instrumentation_exports));
1303
- if (spanProcessor2 && typeof spanProcessor2.forceFlush === "function") {
1304
- await spanProcessor2.forceFlush();
1305
- logger4.debug("Span processor force flush completed");
1306
- } else {
1307
- logger4.debug("Span processor does not support force flush or is not available");
1308
- }
1309
- } catch (error) {
1310
- logger4.warn({ error }, "Failed to force flush tracer");
1311
- }
1312
- }
1221
+ // package.json
1222
+ var package_default = {
1223
+ version: "0.1.3"};
1224
+ var tracer = agentsCore.getTracer("agents-run-api", package_default.version);
1313
1225
  function agentInitializingOp(sessionId, graphId) {
1314
1226
  return {
1315
1227
  type: "agent_initializing",
@@ -1346,10 +1258,10 @@ function statusUpdateOp(ctx) {
1346
1258
  ctx
1347
1259
  };
1348
1260
  }
1349
- var logger5 = getLogger("DataComponentSchema");
1261
+ var logger4 = getLogger("DataComponentSchema");
1350
1262
  function jsonSchemaToZod(jsonSchema) {
1351
1263
  if (!jsonSchema || typeof jsonSchema !== "object") {
1352
- logger5.warn({ jsonSchema }, "Invalid JSON schema provided, using string fallback");
1264
+ logger4.warn({ jsonSchema }, "Invalid JSON schema provided, using string fallback");
1353
1265
  return z5.z.string();
1354
1266
  }
1355
1267
  switch (jsonSchema.type) {
@@ -1376,7 +1288,7 @@ function jsonSchemaToZod(jsonSchema) {
1376
1288
  case "null":
1377
1289
  return z5.z.null();
1378
1290
  default:
1379
- logger5.warn(
1291
+ logger4.warn(
1380
1292
  {
1381
1293
  unsupportedType: jsonSchema.type,
1382
1294
  schema: jsonSchema
@@ -1430,7 +1342,7 @@ __publicField(_ArtifactReferenceSchema, "ARTIFACT_PROPS_SCHEMA", {
1430
1342
  required: ["artifact_id", "task_id"]
1431
1343
  });
1432
1344
  var ArtifactReferenceSchema = _ArtifactReferenceSchema;
1433
- var logger6 = getLogger("ModelFactory");
1345
+ var logger5 = getLogger("ModelFactory");
1434
1346
  var _ModelFactory = class _ModelFactory {
1435
1347
  /**
1436
1348
  * Create a language model instance from configuration
@@ -1443,7 +1355,7 @@ var _ModelFactory = class _ModelFactory {
1443
1355
  const modelSettings = config2;
1444
1356
  const modelString = modelSettings.model.trim();
1445
1357
  const { provider, modelName } = _ModelFactory.parseModelString(modelString);
1446
- logger6.debug(
1358
+ logger5.debug(
1447
1359
  {
1448
1360
  provider,
1449
1361
  model: modelName,
@@ -1462,7 +1374,7 @@ var _ModelFactory = class _ModelFactory {
1462
1374
  throw new Error(`Unsupported provider: ${provider}. Supported providers are: ${_ModelFactory.SUPPORTED_PROVIDERS.join(", ")}`);
1463
1375
  }
1464
1376
  } catch (error) {
1465
- logger6.error(
1377
+ logger5.error(
1466
1378
  {
1467
1379
  provider,
1468
1380
  model: modelName,
@@ -1483,7 +1395,7 @@ var _ModelFactory = class _ModelFactory {
1483
1395
  const [provider, ...modelParts] = modelString.split("/");
1484
1396
  const normalizedProvider = provider.toLowerCase();
1485
1397
  if (!_ModelFactory.SUPPORTED_PROVIDERS.includes(normalizedProvider)) {
1486
- logger6.warn(
1398
+ logger5.warn(
1487
1399
  { provider: normalizedProvider, modelName: modelParts.join("/") },
1488
1400
  "Unsupported provider detected, falling back to anthropic"
1489
1401
  );
@@ -1512,14 +1424,14 @@ var _ModelFactory = class _ModelFactory {
1512
1424
  anthropicConfig.baseURL = providerOptions.baseUrl || providerOptions.baseURL;
1513
1425
  }
1514
1426
  if (providerOptions?.gateway) {
1515
- logger6.info(
1427
+ logger5.info(
1516
1428
  { gateway: providerOptions.gateway },
1517
1429
  "Setting up AI Gateway for Anthropic model"
1518
1430
  );
1519
1431
  Object.assign(anthropicConfig, providerOptions.gateway);
1520
1432
  }
1521
1433
  if (Object.keys(anthropicConfig).length > 0) {
1522
- logger6.info({ config: anthropicConfig }, "Applying custom Anthropic provider configuration");
1434
+ logger5.info({ config: anthropicConfig }, "Applying custom Anthropic provider configuration");
1523
1435
  const provider = anthropic.createAnthropic(anthropicConfig);
1524
1436
  return provider(modelName);
1525
1437
  }
@@ -1534,11 +1446,11 @@ var _ModelFactory = class _ModelFactory {
1534
1446
  openaiConfig.baseURL = providerOptions.baseUrl || providerOptions.baseURL;
1535
1447
  }
1536
1448
  if (providerOptions?.gateway) {
1537
- logger6.info({ gateway: providerOptions.gateway }, "Setting up AI Gateway for OpenAI model");
1449
+ logger5.info({ gateway: providerOptions.gateway }, "Setting up AI Gateway for OpenAI model");
1538
1450
  Object.assign(openaiConfig, providerOptions.gateway);
1539
1451
  }
1540
1452
  if (Object.keys(openaiConfig).length > 0) {
1541
- logger6.info({ config: openaiConfig }, "Applying custom OpenAI provider configuration");
1453
+ logger5.info({ config: openaiConfig }, "Applying custom OpenAI provider configuration");
1542
1454
  const provider = openai.createOpenAI(openaiConfig);
1543
1455
  return provider(modelName);
1544
1456
  }
@@ -1631,8 +1543,7 @@ function unregisterStreamHelper(requestId2) {
1631
1543
  }
1632
1544
 
1633
1545
  // src/utils/graph-session.ts
1634
- var logger7 = getLogger("GraphSession");
1635
- var tracer = getGlobalTracer();
1546
+ var logger6 = getLogger("GraphSession");
1636
1547
  var GraphSession = class {
1637
1548
  // Track scheduled timeouts for cleanup
1638
1549
  constructor(sessionId, messageId, graphId, tenantId, projectId) {
@@ -1656,7 +1567,7 @@ var GraphSession = class {
1656
1567
  __publicField(this, "MAX_PENDING_ARTIFACTS", 100);
1657
1568
  // Prevent unbounded growth
1658
1569
  __publicField(this, "scheduledTimeouts");
1659
- logger7.debug({ sessionId, messageId, graphId }, "GraphSession created");
1570
+ logger6.debug({ sessionId, messageId, graphId }, "GraphSession created");
1660
1571
  }
1661
1572
  /**
1662
1573
  * Initialize status updates for this session
@@ -1678,7 +1589,7 @@ var GraphSession = class {
1678
1589
  if (this.statusUpdateState.config.timeInSeconds) {
1679
1590
  this.statusUpdateTimer = setInterval(async () => {
1680
1591
  if (!this.statusUpdateState || this.isEnded) {
1681
- logger7.debug(
1592
+ logger6.debug(
1682
1593
  { sessionId: this.sessionId },
1683
1594
  "Timer triggered but session already cleaned up or ended"
1684
1595
  );
@@ -1690,7 +1601,7 @@ var GraphSession = class {
1690
1601
  }
1691
1602
  await this.checkAndSendTimeBasedUpdate();
1692
1603
  }, this.statusUpdateState.config.timeInSeconds * 1e3);
1693
- logger7.info(
1604
+ logger6.info(
1694
1605
  {
1695
1606
  sessionId: this.sessionId,
1696
1607
  intervalMs: this.statusUpdateState.config.timeInSeconds * 1e3
@@ -1704,7 +1615,7 @@ var GraphSession = class {
1704
1615
  */
1705
1616
  recordEvent(eventType, agentId, data) {
1706
1617
  if (this.isEnded) {
1707
- logger7.debug(
1618
+ logger6.debug(
1708
1619
  {
1709
1620
  sessionId: this.sessionId,
1710
1621
  eventType,
@@ -1724,7 +1635,7 @@ var GraphSession = class {
1724
1635
  if (eventType === "artifact_saved" && data.pendingGeneration) {
1725
1636
  const artifactId = data.artifactId;
1726
1637
  if (this.pendingArtifacts.size >= this.MAX_PENDING_ARTIFACTS) {
1727
- logger7.warn({
1638
+ logger6.warn({
1728
1639
  sessionId: this.sessionId,
1729
1640
  artifactId,
1730
1641
  pendingCount: this.pendingArtifacts.size,
@@ -1742,7 +1653,7 @@ var GraphSession = class {
1742
1653
  this.artifactProcessingErrors.set(artifactId, errorCount);
1743
1654
  if (errorCount >= this.MAX_ARTIFACT_RETRIES) {
1744
1655
  this.pendingArtifacts.delete(artifactId);
1745
- logger7.error({
1656
+ logger6.error({
1746
1657
  sessionId: this.sessionId,
1747
1658
  artifactId,
1748
1659
  errorCount,
@@ -1751,7 +1662,7 @@ var GraphSession = class {
1751
1662
  stack: error instanceof Error ? error.stack : void 0
1752
1663
  }, "Artifact processing failed after max retries, giving up");
1753
1664
  } else {
1754
- logger7.warn({
1665
+ logger6.warn({
1755
1666
  sessionId: this.sessionId,
1756
1667
  artifactId,
1757
1668
  errorCount,
@@ -1770,14 +1681,14 @@ var GraphSession = class {
1770
1681
  */
1771
1682
  checkStatusUpdates() {
1772
1683
  if (this.isEnded) {
1773
- logger7.debug(
1684
+ logger6.debug(
1774
1685
  { sessionId: this.sessionId },
1775
1686
  "Session has ended - skipping status update check"
1776
1687
  );
1777
1688
  return;
1778
1689
  }
1779
1690
  if (!this.statusUpdateState) {
1780
- logger7.debug({ sessionId: this.sessionId }, "No status update state - skipping check");
1691
+ logger6.debug({ sessionId: this.sessionId }, "No status update state - skipping check");
1781
1692
  return;
1782
1693
  }
1783
1694
  const statusUpdateState = this.statusUpdateState;
@@ -1788,11 +1699,11 @@ var GraphSession = class {
1788
1699
  */
1789
1700
  async checkAndSendTimeBasedUpdate() {
1790
1701
  if (this.isEnded) {
1791
- logger7.debug({ sessionId: this.sessionId }, "Session has ended - skipping time-based update");
1702
+ logger6.debug({ sessionId: this.sessionId }, "Session has ended - skipping time-based update");
1792
1703
  return;
1793
1704
  }
1794
1705
  if (!this.statusUpdateState) {
1795
- logger7.debug(
1706
+ logger6.debug(
1796
1707
  { sessionId: this.sessionId },
1797
1708
  "No status updates configured for time-based check"
1798
1709
  );
@@ -1805,7 +1716,7 @@ var GraphSession = class {
1805
1716
  try {
1806
1717
  await this.generateAndSendUpdate();
1807
1718
  } catch (error) {
1808
- logger7.error(
1719
+ logger6.error(
1809
1720
  {
1810
1721
  sessionId: this.sessionId,
1811
1722
  error: error instanceof Error ? error.message : "Unknown error"
@@ -1898,29 +1809,29 @@ var GraphSession = class {
1898
1809
  */
1899
1810
  async generateAndSendUpdate() {
1900
1811
  if (this.isEnded) {
1901
- logger7.debug({ sessionId: this.sessionId }, "Session has ended - not generating update");
1812
+ logger6.debug({ sessionId: this.sessionId }, "Session has ended - not generating update");
1902
1813
  return;
1903
1814
  }
1904
1815
  if (this.isTextStreaming) {
1905
- logger7.debug(
1816
+ logger6.debug(
1906
1817
  { sessionId: this.sessionId },
1907
1818
  "Text is currently streaming - skipping status update"
1908
1819
  );
1909
1820
  return;
1910
1821
  }
1911
1822
  if (this.isGeneratingUpdate) {
1912
- logger7.debug(
1823
+ logger6.debug(
1913
1824
  { sessionId: this.sessionId },
1914
1825
  "Update already in progress - skipping duplicate generation"
1915
1826
  );
1916
1827
  return;
1917
1828
  }
1918
1829
  if (!this.statusUpdateState) {
1919
- logger7.warn({ sessionId: this.sessionId }, "No status update state - cannot generate update");
1830
+ logger6.warn({ sessionId: this.sessionId }, "No status update state - cannot generate update");
1920
1831
  return;
1921
1832
  }
1922
1833
  if (!this.graphId) {
1923
- logger7.warn({ sessionId: this.sessionId }, "No graph ID - cannot generate update");
1834
+ logger6.warn({ sessionId: this.sessionId }, "No graph ID - cannot generate update");
1924
1835
  return;
1925
1836
  }
1926
1837
  const newEventCount = this.events.length - this.statusUpdateState.lastEventCount;
@@ -1933,7 +1844,7 @@ var GraphSession = class {
1933
1844
  try {
1934
1845
  const streamHelper = getStreamHelper(this.sessionId);
1935
1846
  if (!streamHelper) {
1936
- logger7.warn(
1847
+ logger6.warn(
1937
1848
  { sessionId: this.sessionId },
1938
1849
  "No stream helper found - cannot send status update"
1939
1850
  );
@@ -1954,7 +1865,7 @@ var GraphSession = class {
1954
1865
  if (result.operations && result.operations.length > 0) {
1955
1866
  for (const op of result.operations) {
1956
1867
  if (!op || !op.type || !op.data || Object.keys(op.data).length === 0) {
1957
- logger7.warn(
1868
+ logger6.warn(
1958
1869
  {
1959
1870
  sessionId: this.sessionId,
1960
1871
  operation: op
@@ -2007,7 +1918,7 @@ var GraphSession = class {
2007
1918
  this.previousSummaries.shift();
2008
1919
  }
2009
1920
  if (!operation || !operation.type || !operation.ctx) {
2010
- logger7.warn(
1921
+ logger6.warn(
2011
1922
  {
2012
1923
  sessionId: this.sessionId,
2013
1924
  operation
@@ -2022,7 +1933,7 @@ var GraphSession = class {
2022
1933
  this.statusUpdateState.lastEventCount = this.events.length;
2023
1934
  }
2024
1935
  } catch (error) {
2025
- logger7.error(
1936
+ logger6.error(
2026
1937
  {
2027
1938
  sessionId: this.sessionId,
2028
1939
  error: error instanceof Error ? error.message : "Unknown error",
@@ -2060,7 +1971,7 @@ var GraphSession = class {
2060
1971
  this.releaseUpdateLock();
2061
1972
  }
2062
1973
  } catch (error) {
2063
- logger7.error(
1974
+ logger6.error(
2064
1975
  {
2065
1976
  sessionId: this.sessionId,
2066
1977
  error: error instanceof Error ? error.message : "Unknown error"
@@ -2105,7 +2016,7 @@ var GraphSession = class {
2105
2016
  */
2106
2017
  async generateProgressSummary(newEvents, elapsedTime, summarizerModel, previousSummaries = []) {
2107
2018
  return tracer.startActiveSpan(
2108
- createSpanName("graph_session.generate_progress_summary"),
2019
+ "graph_session.generate_progress_summary",
2109
2020
  {
2110
2021
  attributes: {
2111
2022
  "graph_session.id": this.sessionId,
@@ -2137,7 +2048,7 @@ User's Question/Context:
2137
2048
  ${conversationHistory}
2138
2049
  ` : "";
2139
2050
  } catch (error) {
2140
- logger7.warn(
2051
+ logger6.warn(
2141
2052
  { sessionId: this.sessionId, error },
2142
2053
  "Failed to fetch conversation history for status update"
2143
2054
  );
@@ -2186,8 +2097,8 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
2186
2097
  span.setStatus({ code: api.SpanStatusCode.OK });
2187
2098
  return text.trim();
2188
2099
  } catch (error) {
2189
- handleSpanError(span, error);
2190
- logger7.error({ error }, "Failed to generate summary, using fallback");
2100
+ agentsCore.setSpanWithError(span, error);
2101
+ logger6.error({ error }, "Failed to generate summary, using fallback");
2191
2102
  return this.generateFallbackSummary(newEvents, elapsedTime);
2192
2103
  } finally {
2193
2104
  span.end();
@@ -2200,7 +2111,7 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
2200
2111
  */
2201
2112
  async generateStructuredStatusUpdate(newEvents, elapsedTime, statusComponents, summarizerModel, previousSummaries = []) {
2202
2113
  return tracer.startActiveSpan(
2203
- createSpanName("graph_session.generate_structured_update"),
2114
+ "graph_session.generate_structured_update",
2204
2115
  {
2205
2116
  attributes: {
2206
2117
  "graph_session.id": this.sessionId,
@@ -2233,7 +2144,7 @@ User's Question/Context:
2233
2144
  ${conversationHistory}
2234
2145
  ` : "";
2235
2146
  } catch (error) {
2236
- logger7.warn(
2147
+ logger6.warn(
2237
2148
  { sessionId: this.sessionId, error },
2238
2149
  "Failed to fetch conversation history for structured status update"
2239
2150
  );
@@ -2329,8 +2240,8 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
2329
2240
  span.setStatus({ code: api.SpanStatusCode.OK });
2330
2241
  return { operations };
2331
2242
  } catch (error) {
2332
- handleSpanError(span, error);
2333
- logger7.error({ error }, "Failed to generate structured update, using fallback");
2243
+ agentsCore.setSpanWithError(span, error);
2244
+ logger6.error({ error }, "Failed to generate structured update, using fallback");
2334
2245
  return { operations: [] };
2335
2246
  } finally {
2336
2247
  span.end();
@@ -2515,7 +2426,7 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
2515
2426
  */
2516
2427
  async processArtifact(artifactData) {
2517
2428
  return tracer.startActiveSpan(
2518
- createSpanName("graph_session.process_artifact"),
2429
+ "graph_session.process_artifact",
2519
2430
  {
2520
2431
  attributes: {
2521
2432
  "graph_session.id": this.sessionId,
@@ -2588,7 +2499,7 @@ Make it specific and relevant.`;
2588
2499
  description: z5.z.string().max(150).describe("Brief description of the artifact's relevance to the user's question")
2589
2500
  });
2590
2501
  const { object: result } = await tracer.startActiveSpan(
2591
- createSpanName("graph_session.generate_artifact_metadata"),
2502
+ "graph_session.generate_artifact_metadata",
2592
2503
  {
2593
2504
  attributes: {
2594
2505
  "llm.model": this.statusUpdateState?.summarizerModel?.model,
@@ -2621,7 +2532,7 @@ Make it specific and relevant.`;
2621
2532
  generationSpan.setStatus({ code: api.SpanStatusCode.OK });
2622
2533
  return result2;
2623
2534
  } catch (error) {
2624
- handleSpanError(generationSpan, error);
2535
+ agentsCore.setSpanWithError(generationSpan, error);
2625
2536
  throw error;
2626
2537
  } finally {
2627
2538
  generationSpan.end();
@@ -2655,7 +2566,7 @@ Make it specific and relevant.`;
2655
2566
  taskId: artifactData.taskId,
2656
2567
  artifacts: [artifactToSave]
2657
2568
  });
2658
- logger7.info(
2569
+ logger6.info(
2659
2570
  {
2660
2571
  sessionId: this.sessionId,
2661
2572
  artifactId: artifactData.artifactId,
@@ -2671,8 +2582,8 @@ Make it specific and relevant.`;
2671
2582
  });
2672
2583
  span.setStatus({ code: api.SpanStatusCode.OK });
2673
2584
  } catch (error) {
2674
- handleSpanError(span, error);
2675
- logger7.error(
2585
+ agentsCore.setSpanWithError(span, error);
2586
+ logger6.error(
2676
2587
  {
2677
2588
  sessionId: this.sessionId,
2678
2589
  artifactId: artifactData.artifactId,
@@ -2708,7 +2619,7 @@ Make it specific and relevant.`;
2708
2619
  taskId: artifactData.taskId,
2709
2620
  artifacts: [fallbackArtifact]
2710
2621
  });
2711
- logger7.info(
2622
+ logger6.info(
2712
2623
  {
2713
2624
  sessionId: this.sessionId,
2714
2625
  artifactId: artifactData.artifactId
@@ -2717,7 +2628,7 @@ Make it specific and relevant.`;
2717
2628
  );
2718
2629
  }
2719
2630
  } catch (fallbackError) {
2720
- logger7.error(
2631
+ logger6.error(
2721
2632
  {
2722
2633
  sessionId: this.sessionId,
2723
2634
  artifactId: artifactData.artifactId,
@@ -2744,7 +2655,7 @@ var GraphSessionManager = class {
2744
2655
  const sessionId = messageId;
2745
2656
  const session = new GraphSession(sessionId, messageId, graphId, tenantId, projectId);
2746
2657
  this.sessions.set(sessionId, session);
2747
- logger7.info({ sessionId, messageId, graphId, tenantId, projectId }, "GraphSession created");
2658
+ logger6.info({ sessionId, messageId, graphId, tenantId, projectId }, "GraphSession created");
2748
2659
  return sessionId;
2749
2660
  }
2750
2661
  /**
@@ -2755,7 +2666,7 @@ var GraphSessionManager = class {
2755
2666
  if (session) {
2756
2667
  session.initializeStatusUpdates(config2, summarizerModel);
2757
2668
  } else {
2758
- logger7.error(
2669
+ logger6.error(
2759
2670
  {
2760
2671
  sessionId,
2761
2672
  availableSessions: Array.from(this.sessions.keys())
@@ -2776,7 +2687,7 @@ var GraphSessionManager = class {
2776
2687
  recordEvent(sessionId, eventType, agentId, data) {
2777
2688
  const session = this.sessions.get(sessionId);
2778
2689
  if (!session) {
2779
- logger7.warn({ sessionId }, "Attempted to record event in non-existent session");
2690
+ logger6.warn({ sessionId }, "Attempted to record event in non-existent session");
2780
2691
  return;
2781
2692
  }
2782
2693
  session.recordEvent(eventType, agentId, data);
@@ -2787,12 +2698,12 @@ var GraphSessionManager = class {
2787
2698
  endSession(sessionId) {
2788
2699
  const session = this.sessions.get(sessionId);
2789
2700
  if (!session) {
2790
- logger7.warn({ sessionId }, "Attempted to end non-existent session");
2701
+ logger6.warn({ sessionId }, "Attempted to end non-existent session");
2791
2702
  return [];
2792
2703
  }
2793
2704
  const events = session.getEvents();
2794
2705
  const summary = session.getSummary();
2795
- logger7.info({ sessionId, summary }, "GraphSession ended");
2706
+ logger6.info({ sessionId, summary }, "GraphSession ended");
2796
2707
  session.cleanup();
2797
2708
  this.sessions.delete(sessionId);
2798
2709
  return events;
@@ -2821,7 +2732,7 @@ var graphSessionManager = new GraphSessionManager();
2821
2732
 
2822
2733
  // src/utils/artifact-parser.ts
2823
2734
  init_dbClient();
2824
- var logger8 = getLogger("ArtifactParser");
2735
+ var logger7 = getLogger("ArtifactParser");
2825
2736
  var _ArtifactParser = class _ArtifactParser {
2826
2737
  constructor(tenantId) {
2827
2738
  this.tenantId = tenantId;
@@ -2885,7 +2796,7 @@ var _ArtifactParser = class _ArtifactParser {
2885
2796
  id: taskId
2886
2797
  });
2887
2798
  if (!task) {
2888
- logger8.warn({ taskId }, "Task not found when fetching artifacts");
2799
+ logger7.warn({ taskId }, "Task not found when fetching artifacts");
2889
2800
  continue;
2890
2801
  }
2891
2802
  const taskArtifacts = await agentsCore.getLedgerArtifacts(dbClient_default)({
@@ -2897,9 +2808,9 @@ var _ArtifactParser = class _ArtifactParser {
2897
2808
  artifacts.set(key, artifact);
2898
2809
  }
2899
2810
  }
2900
- logger8.debug({ contextId, count: artifacts.size }, "Loaded context artifacts");
2811
+ logger7.debug({ contextId, count: artifacts.size }, "Loaded context artifacts");
2901
2812
  } catch (error) {
2902
- logger8.error({ error, contextId }, "Error loading context artifacts");
2813
+ logger7.error({ error, contextId }, "Error loading context artifacts");
2903
2814
  }
2904
2815
  return artifacts;
2905
2816
  }
@@ -3002,7 +2913,7 @@ var _ArtifactParser = class _ArtifactParser {
3002
2913
  id: taskId
3003
2914
  });
3004
2915
  if (!task) {
3005
- logger8.warn({ taskId }, "Task not found when fetching artifact");
2916
+ logger7.warn({ taskId }, "Task not found when fetching artifact");
3006
2917
  return null;
3007
2918
  }
3008
2919
  const artifacts = await agentsCore.getLedgerArtifacts(dbClient_default)({
@@ -3014,7 +2925,7 @@ var _ArtifactParser = class _ArtifactParser {
3014
2925
  return this.formatArtifactData(artifacts[0], artifactId, taskId);
3015
2926
  }
3016
2927
  } catch (error) {
3017
- logger8.warn({ artifactId, taskId, error }, "Failed to fetch artifact");
2928
+ logger7.warn({ artifactId, taskId, error }, "Failed to fetch artifact");
3018
2929
  }
3019
2930
  return null;
3020
2931
  }
@@ -3054,7 +2965,7 @@ __publicField(_ArtifactParser, "INCOMPLETE_ARTIFACT_REGEX", /<(a(r(t(i(f(a(c(t(:
3054
2965
  var ArtifactParser = _ArtifactParser;
3055
2966
 
3056
2967
  // src/utils/incremental-stream-parser.ts
3057
- var logger9 = getLogger("IncrementalStreamParser");
2968
+ var logger8 = getLogger("IncrementalStreamParser");
3058
2969
  var IncrementalStreamParser = class {
3059
2970
  constructor(streamHelper, tenantId, contextId) {
3060
2971
  __publicField(this, "buffer", "");
@@ -3114,13 +3025,13 @@ var IncrementalStreamParser = class {
3114
3025
  if (part.type === "tool-call-delta" && part.toolName === targetToolName) {
3115
3026
  const delta = part.argsTextDelta || "";
3116
3027
  if (jsonBuffer.length + delta.length > MAX_BUFFER_SIZE) {
3117
- logger9.warn("JSON buffer exceeded maximum size, truncating");
3028
+ logger8.warn("JSON buffer exceeded maximum size, truncating");
3118
3029
  jsonBuffer = jsonBuffer.slice(-MAX_BUFFER_SIZE / 2);
3119
3030
  }
3120
3031
  jsonBuffer += delta;
3121
3032
  for (const char of delta) {
3122
3033
  if (componentBuffer.length > MAX_BUFFER_SIZE) {
3123
- logger9.warn("Component buffer exceeded maximum size, resetting");
3034
+ logger8.warn("Component buffer exceeded maximum size, resetting");
3124
3035
  componentBuffer = "";
3125
3036
  depth = 0;
3126
3037
  continue;
@@ -3135,7 +3046,7 @@ var IncrementalStreamParser = class {
3135
3046
  if (componentMatch) {
3136
3047
  const MAX_COMPONENT_SIZE = 1024 * 1024;
3137
3048
  if (componentMatch[0].length > MAX_COMPONENT_SIZE) {
3138
- logger9.warn(
3049
+ logger8.warn(
3139
3050
  {
3140
3051
  size: componentMatch[0].length,
3141
3052
  maxSize: MAX_COMPONENT_SIZE
@@ -3148,7 +3059,7 @@ var IncrementalStreamParser = class {
3148
3059
  try {
3149
3060
  const component = JSON.parse(componentMatch[0]);
3150
3061
  if (typeof component !== "object" || !component.id) {
3151
- logger9.warn("Invalid component structure, skipping");
3062
+ logger8.warn("Invalid component structure, skipping");
3152
3063
  componentBuffer = "";
3153
3064
  continue;
3154
3065
  }
@@ -3161,7 +3072,7 @@ var IncrementalStreamParser = class {
3161
3072
  componentsStreamed++;
3162
3073
  componentBuffer = "";
3163
3074
  } catch (e) {
3164
- logger9.debug({ error: e }, "Failed to parse component, continuing to accumulate");
3075
+ logger8.debug({ error: e }, "Failed to parse component, continuing to accumulate");
3165
3076
  }
3166
3077
  }
3167
3078
  }
@@ -3178,7 +3089,7 @@ var IncrementalStreamParser = class {
3178
3089
  break;
3179
3090
  }
3180
3091
  }
3181
- logger9.debug({ componentsStreamed }, "Finished streaming components");
3092
+ logger8.debug({ componentsStreamed }, "Finished streaming components");
3182
3093
  }
3183
3094
  /**
3184
3095
  * Legacy method for backward compatibility - defaults to text processing
@@ -3320,12 +3231,9 @@ var IncrementalStreamParser = class {
3320
3231
  }
3321
3232
  }
3322
3233
  };
3323
- var logger10 = getLogger("ResponseFormatter");
3324
- var RESPONSE_FORMATTER_SERVICE = "responseFormatter";
3325
- function getResponseFormatterTracer() {
3326
- const tracerProvider = api.trace.getTracerProvider();
3327
- return tracerProvider.getTracer(RESPONSE_FORMATTER_SERVICE, SERVICE_VERSION);
3328
- }
3234
+
3235
+ // src/utils/response-formatter.ts
3236
+ var logger9 = getLogger("ResponseFormatter");
3329
3237
  var ResponseFormatter = class {
3330
3238
  constructor(tenantId) {
3331
3239
  __publicField(this, "artifactParser");
@@ -3335,8 +3243,7 @@ var ResponseFormatter = class {
3335
3243
  * Process structured object response and replace artifact markers with actual artifacts
3336
3244
  */
3337
3245
  async formatObjectResponse(responseObject, contextId) {
3338
- const tracer3 = getResponseFormatterTracer();
3339
- return tracer3.startActiveSpan("response.formatObject", async (span) => {
3246
+ return tracer.startActiveSpan("response.format_object_response", async (span) => {
3340
3247
  try {
3341
3248
  const artifactMap = await this.artifactParser.getContextArtifacts(contextId);
3342
3249
  span.setAttributes({
@@ -3356,8 +3263,8 @@ var ResponseFormatter = class {
3356
3263
  });
3357
3264
  return { parts };
3358
3265
  } catch (error) {
3359
- span.recordException(error);
3360
- logger10.error({ error, responseObject }, "Error formatting object response");
3266
+ agentsCore.setSpanWithError(span, error);
3267
+ logger9.error({ error, responseObject }, "Error formatting object response");
3361
3268
  return {
3362
3269
  parts: [{ kind: "data", data: responseObject }]
3363
3270
  };
@@ -3370,8 +3277,7 @@ var ResponseFormatter = class {
3370
3277
  * Process agent response and convert artifact markers to data parts
3371
3278
  */
3372
3279
  async formatResponse(responseText, contextId) {
3373
- const tracer3 = getResponseFormatterTracer();
3374
- return tracer3.startActiveSpan("response.format", async (span) => {
3280
+ return tracer.startActiveSpan("response.format_response", async (span) => {
3375
3281
  try {
3376
3282
  span.setAttributes({
3377
3283
  "response.hasArtifactMarkers": this.artifactParser.hasArtifactMarkers(responseText),
@@ -3408,9 +3314,8 @@ var ResponseFormatter = class {
3408
3314
  });
3409
3315
  return { parts };
3410
3316
  } catch (error) {
3411
- span.recordException(error);
3412
- span.setStatus({ code: 2, message: error.message });
3413
- logger10.error({ error, responseText }, "Error formatting response");
3317
+ agentsCore.setSpanWithError(span, error);
3318
+ logger9.error({ error, responseText }, "Error formatting response");
3414
3319
  return { text: responseText };
3415
3320
  } finally {
3416
3321
  span.end();
@@ -3455,7 +3360,7 @@ var ResponseFormatter = class {
3455
3360
  }
3456
3361
  }
3457
3362
  };
3458
- var logger11 = getLogger("ToolSessionManager");
3363
+ var logger10 = getLogger("ToolSessionManager");
3459
3364
  var _ToolSessionManager = class _ToolSessionManager {
3460
3365
  // 5 minutes
3461
3366
  constructor() {
@@ -3484,7 +3389,7 @@ var _ToolSessionManager = class _ToolSessionManager {
3484
3389
  createdAt: Date.now()
3485
3390
  };
3486
3391
  this.sessions.set(sessionId, session);
3487
- logger11.debug({ sessionId, tenantId, contextId, taskId }, "Created tool session");
3392
+ logger10.debug({ sessionId, tenantId, contextId, taskId }, "Created tool session");
3488
3393
  return sessionId;
3489
3394
  }
3490
3395
  /**
@@ -3493,7 +3398,7 @@ var _ToolSessionManager = class _ToolSessionManager {
3493
3398
  recordToolResult(sessionId, toolResult) {
3494
3399
  const session = this.sessions.get(sessionId);
3495
3400
  if (!session) {
3496
- logger11.warn(
3401
+ logger10.warn(
3497
3402
  { sessionId, toolCallId: toolResult.toolCallId },
3498
3403
  "Tool result recorded for unknown session"
3499
3404
  );
@@ -3507,12 +3412,12 @@ var _ToolSessionManager = class _ToolSessionManager {
3507
3412
  getToolResult(sessionId, toolCallId) {
3508
3413
  const session = this.sessions.get(sessionId);
3509
3414
  if (!session) {
3510
- logger11.warn({ sessionId, toolCallId }, "Requested tool result for unknown session");
3415
+ logger10.warn({ sessionId, toolCallId }, "Requested tool result for unknown session");
3511
3416
  return void 0;
3512
3417
  }
3513
3418
  const result = session.toolResults.get(toolCallId);
3514
3419
  if (!result) {
3515
- logger11.warn(
3420
+ logger10.warn(
3516
3421
  {
3517
3422
  sessionId,
3518
3423
  toolCallId,
@@ -3551,10 +3456,10 @@ var _ToolSessionManager = class _ToolSessionManager {
3551
3456
  }
3552
3457
  for (const sessionId of expiredSessions) {
3553
3458
  this.sessions.delete(sessionId);
3554
- logger11.debug({ sessionId }, "Cleaned up expired tool session");
3459
+ logger10.debug({ sessionId }, "Cleaned up expired tool session");
3555
3460
  }
3556
3461
  if (expiredSessions.length > 0) {
3557
- logger11.info({ expiredCount: expiredSessions.length }, "Cleaned up expired tool sessions");
3462
+ logger10.info({ expiredCount: expiredSessions.length }, "Cleaned up expired tool sessions");
3558
3463
  }
3559
3464
  }
3560
3465
  };
@@ -3563,7 +3468,7 @@ var ToolSessionManager = _ToolSessionManager;
3563
3468
  var toolSessionManager = ToolSessionManager.getInstance();
3564
3469
 
3565
3470
  // src/agents/artifactTools.ts
3566
- var logger12 = getLogger("artifactTools");
3471
+ var logger11 = getLogger("artifactTools");
3567
3472
  function buildKeyNestingMap(data, prefix = "", map = /* @__PURE__ */ new Map()) {
3568
3473
  if (typeof data === "object" && data !== null) {
3569
3474
  if (Array.isArray(data)) {
@@ -3784,7 +3689,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
3784
3689
  execute: async ({ toolCallId, baseSelector, propSelectors, ...rest }, _context) => {
3785
3690
  const artifactType = "artifactType" in rest ? rest.artifactType : void 0;
3786
3691
  if (!sessionId) {
3787
- logger12.warn({ toolCallId }, "No session ID provided to save_tool_result");
3692
+ logger11.warn({ toolCallId }, "No session ID provided to save_tool_result");
3788
3693
  return {
3789
3694
  saved: false,
3790
3695
  error: `[toolCallId: ${toolCallId}] No session context available`,
@@ -3794,7 +3699,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
3794
3699
  }
3795
3700
  const toolResult = toolSessionManager.getToolResult(sessionId, toolCallId);
3796
3701
  if (!toolResult) {
3797
- logger12.warn({ toolCallId, sessionId }, "Tool result not found in session");
3702
+ logger11.warn({ toolCallId, sessionId }, "Tool result not found in session");
3798
3703
  return {
3799
3704
  saved: false,
3800
3705
  error: `[toolCallId: ${toolCallId}] Tool result not found`,
@@ -3807,7 +3712,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
3807
3712
  const baseData = jmespath__default.default.search(parsedResult, baseSelector);
3808
3713
  if (!baseData || Array.isArray(baseData) && baseData.length === 0) {
3809
3714
  const debugInfo = analyzeSelectorFailure(parsedResult, baseSelector);
3810
- logger12.warn(
3715
+ logger11.warn(
3811
3716
  {
3812
3717
  baseSelector,
3813
3718
  toolCallId,
@@ -3850,7 +3755,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
3850
3755
  const fallbackValue = item[propName];
3851
3756
  if (fallbackValue !== null && fallbackValue !== void 0) {
3852
3757
  extractedItem[propName] = fallbackValue;
3853
- logger12.info(
3758
+ logger11.info(
3854
3759
  { propName, propSelector, context },
3855
3760
  `PropSelector failed, used fallback direct property access`
3856
3761
  );
@@ -3862,7 +3767,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
3862
3767
  const fallbackValue = item[propName];
3863
3768
  if (fallbackValue !== null && fallbackValue !== void 0) {
3864
3769
  extractedItem[propName] = fallbackValue;
3865
- logger12.warn(
3770
+ logger11.warn(
3866
3771
  { propName, propSelector, context, error: error.message },
3867
3772
  `PropSelector syntax error, used fallback direct property access`
3868
3773
  );
@@ -3975,7 +3880,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
3975
3880
  warnings
3976
3881
  };
3977
3882
  } catch (error) {
3978
- logger12.error({ error, toolCallId, sessionId }, "Error processing save_tool_result");
3883
+ logger11.error({ error, toolCallId, sessionId }, "Error processing save_tool_result");
3979
3884
  return {
3980
3885
  saved: false,
3981
3886
  error: `[toolCallId: ${toolCallId}] ${error instanceof Error ? error.message : "Unknown error"}`,
@@ -3987,7 +3892,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
3987
3892
  }
3988
3893
 
3989
3894
  // src/a2a/client.ts
3990
- var logger13 = getLogger("a2aClient");
3895
+ var logger12 = getLogger("a2aClient");
3991
3896
  var DEFAULT_BACKOFF = {
3992
3897
  initialInterval: 500,
3993
3898
  maxInterval: 6e4,
@@ -4193,7 +4098,7 @@ var A2AClient = class {
4193
4098
  try {
4194
4099
  const res = await fn();
4195
4100
  if (attempt > 0) {
4196
- logger13.info(
4101
+ logger12.info(
4197
4102
  {
4198
4103
  attempts: attempt + 1,
4199
4104
  elapsedTime: Date.now() - start
@@ -4208,7 +4113,7 @@ var A2AClient = class {
4208
4113
  }
4209
4114
  const elapsed = Date.now() - start;
4210
4115
  if (elapsed > maxElapsedTime) {
4211
- logger13.warn(
4116
+ logger12.warn(
4212
4117
  {
4213
4118
  attempts: attempt + 1,
4214
4119
  elapsedTime: elapsed,
@@ -4229,7 +4134,7 @@ var A2AClient = class {
4229
4134
  retryInterval = initialInterval * attempt ** exponent + Math.random() * 1e3;
4230
4135
  }
4231
4136
  const delayMs = Math.min(retryInterval, maxInterval);
4232
- logger13.info(
4137
+ logger12.info(
4233
4138
  {
4234
4139
  attempt: attempt + 1,
4235
4140
  delayMs,
@@ -4314,7 +4219,7 @@ var A2AClient = class {
4314
4219
  }
4315
4220
  const rpcResponse = await httpResponse.json();
4316
4221
  if (rpcResponse.id !== requestId2) {
4317
- logger13.warn(
4222
+ logger12.warn(
4318
4223
  {
4319
4224
  method,
4320
4225
  expectedId: requestId2,
@@ -4513,7 +4418,7 @@ var A2AClient = class {
4513
4418
  try {
4514
4419
  while (true) {
4515
4420
  const { done, value } = await reader.read();
4516
- logger13.info({ done, value }, "parseA2ASseStream");
4421
+ logger12.info({ done, value }, "parseA2ASseStream");
4517
4422
  if (done) {
4518
4423
  if (eventDataBuffer.trim()) {
4519
4424
  const result = this._processSseEventData(
@@ -4602,7 +4507,7 @@ var A2AClient = class {
4602
4507
  // src/agents/relationTools.ts
4603
4508
  init_conversations();
4604
4509
  init_dbClient();
4605
- var logger14 = getLogger("relationships Tools");
4510
+ var logger13 = getLogger("relationships Tools");
4606
4511
  var generateTransferToolDescription = (config2) => {
4607
4512
  return `Hand off the conversation to agent ${config2.id}.
4608
4513
 
@@ -4640,7 +4545,7 @@ var createTransferToAgentTool = ({
4640
4545
  "transfer.to_agent_id": transferConfig.id ?? "unknown"
4641
4546
  });
4642
4547
  }
4643
- logger14.info(
4548
+ logger13.info(
4644
4549
  {
4645
4550
  transferTo: transferConfig.id ?? "unknown",
4646
4551
  fromAgent: callingAgentId
@@ -4788,7 +4693,7 @@ function createDelegateToAgentTool({
4788
4693
  ...isInternal ? { fromAgentId: callingAgentId } : { fromExternalAgentId: callingAgentId }
4789
4694
  }
4790
4695
  };
4791
- logger14.info({ messageToSend }, "messageToSend");
4696
+ logger13.info({ messageToSend }, "messageToSend");
4792
4697
  await agentsCore.createMessage(dbClient_default)({
4793
4698
  id: nanoid.nanoid(),
4794
4699
  tenantId,
@@ -4848,7 +4753,7 @@ function createDelegateToAgentTool({
4848
4753
  }
4849
4754
  });
4850
4755
  }
4851
- var logger15 = getLogger("SystemPromptBuilder");
4756
+ var logger14 = getLogger("SystemPromptBuilder");
4852
4757
  var SystemPromptBuilder = class {
4853
4758
  constructor(version, versionConfig) {
4854
4759
  this.version = version;
@@ -4872,9 +4777,9 @@ var SystemPromptBuilder = class {
4872
4777
  this.templates.set(name, content);
4873
4778
  }
4874
4779
  this.loaded = true;
4875
- logger15.debug(`Loaded ${this.templates.size} templates for version ${this.version}`);
4780
+ logger14.debug(`Loaded ${this.templates.size} templates for version ${this.version}`);
4876
4781
  } catch (error) {
4877
- logger15.error({ error }, `Failed to load templates for version ${this.version}`);
4782
+ logger14.error({ error }, `Failed to load templates for version ${this.version}`);
4878
4783
  throw new Error(`Template loading failed: ${error}`);
4879
4784
  }
4880
4785
  }
@@ -5210,8 +5115,7 @@ function hasToolCallWithPrefix(prefix) {
5210
5115
  return false;
5211
5116
  };
5212
5117
  }
5213
- var logger16 = getLogger("Agent");
5214
- var tracer2 = getGlobalTracer();
5118
+ var logger15 = getLogger("Agent");
5215
5119
  var CONSTANTS = {
5216
5120
  MAX_GENERATION_STEPS: 12,
5217
5121
  PHASE_1_TIMEOUT_MS: 27e4,
@@ -5464,14 +5368,14 @@ var Agent = class {
5464
5368
  for (const toolSet of tools) {
5465
5369
  for (const [toolName, originalTool] of Object.entries(toolSet)) {
5466
5370
  if (!isValidTool(originalTool)) {
5467
- logger16.error({ toolName }, "Invalid MCP tool structure - missing required properties");
5371
+ logger15.error({ toolName }, "Invalid MCP tool structure - missing required properties");
5468
5372
  continue;
5469
5373
  }
5470
5374
  const sessionWrappedTool = ai.tool({
5471
5375
  description: originalTool.description,
5472
5376
  inputSchema: originalTool.inputSchema,
5473
5377
  execute: async (args, { toolCallId }) => {
5474
- logger16.debug({ toolName, toolCallId }, "MCP Tool Called");
5378
+ logger15.debug({ toolName, toolCallId }, "MCP Tool Called");
5475
5379
  try {
5476
5380
  const result = await originalTool.execute(args, { toolCallId });
5477
5381
  toolSessionManager.recordToolResult(sessionId, {
@@ -5483,7 +5387,7 @@ var Agent = class {
5483
5387
  });
5484
5388
  return { result, toolCallId };
5485
5389
  } catch (error) {
5486
- logger16.error({ toolName, toolCallId, error }, "MCP tool execution failed");
5390
+ logger15.error({ toolName, toolCallId, error }, "MCP tool execution failed");
5487
5391
  throw error;
5488
5392
  }
5489
5393
  }
@@ -5516,6 +5420,11 @@ var Agent = class {
5516
5420
  }
5517
5421
  async getMcpTool(tool4) {
5518
5422
  const credentialReferenceId = tool4.credentialReferenceId;
5423
+ const toolsForAgent = await agentsCore.getToolsForAgent(dbClient_default)({
5424
+ scopes: { tenantId: this.config.tenantId, projectId: this.config.projectId },
5425
+ agentId: this.config.id
5426
+ });
5427
+ const selectedTools = toolsForAgent.data.find((t) => t.toolId === tool4.id)?.selectedTools || void 0;
5519
5428
  let serverConfig;
5520
5429
  if (credentialReferenceId && this.credentialStuffer) {
5521
5430
  const credentialReference = await agentsCore.getCredentialReference(dbClient_default)({
@@ -5540,7 +5449,8 @@ var Agent = class {
5540
5449
  conversationId: this.conversationId || void 0
5541
5450
  },
5542
5451
  this.convertToMCPToolConfig(tool4),
5543
- storeReference
5452
+ storeReference,
5453
+ selectedTools
5544
5454
  );
5545
5455
  } else if (tool4.headers && this.credentialStuffer) {
5546
5456
  serverConfig = await this.credentialStuffer.buildMcpServerConfig(
@@ -5550,16 +5460,19 @@ var Agent = class {
5550
5460
  contextConfigId: this.config.contextConfigId || void 0,
5551
5461
  conversationId: this.conversationId || void 0
5552
5462
  },
5553
- this.convertToMCPToolConfig(tool4)
5463
+ this.convertToMCPToolConfig(tool4),
5464
+ void 0,
5465
+ selectedTools
5554
5466
  );
5555
5467
  } else {
5556
5468
  serverConfig = {
5557
5469
  type: tool4.config.mcp.transport?.type || agentsCore.MCPTransportType.streamableHttp,
5558
5470
  url: tool4.config.mcp.server.url,
5559
- activeTools: tool4.config.mcp.activeTools
5471
+ activeTools: tool4.config.mcp.activeTools,
5472
+ selectedTools
5560
5473
  };
5561
5474
  }
5562
- logger16.info(
5475
+ logger15.info(
5563
5476
  {
5564
5477
  toolName: tool4.name,
5565
5478
  credentialReferenceId,
@@ -5599,7 +5512,7 @@ var Agent = class {
5599
5512
  async getResolvedContext(conversationId, requestContext) {
5600
5513
  try {
5601
5514
  if (!this.config.contextConfigId) {
5602
- logger16.debug({ graphId: this.config.graphId }, "No context config found for graph");
5515
+ logger15.debug({ graphId: this.config.graphId }, "No context config found for graph");
5603
5516
  return null;
5604
5517
  }
5605
5518
  const contextConfig = await agentsCore.getContextConfigById(dbClient_default)({
@@ -5607,7 +5520,7 @@ var Agent = class {
5607
5520
  id: this.config.contextConfigId
5608
5521
  });
5609
5522
  if (!contextConfig) {
5610
- logger16.warn({ contextConfigId: this.config.contextConfigId }, "Context config not found");
5523
+ logger15.warn({ contextConfigId: this.config.contextConfigId }, "Context config not found");
5611
5524
  return null;
5612
5525
  }
5613
5526
  if (!this.contextResolver) {
@@ -5624,7 +5537,7 @@ var Agent = class {
5624
5537
  $now: (/* @__PURE__ */ new Date()).toISOString(),
5625
5538
  $env: process.env
5626
5539
  };
5627
- logger16.debug(
5540
+ logger15.debug(
5628
5541
  {
5629
5542
  conversationId,
5630
5543
  contextConfigId: contextConfig.id,
@@ -5638,7 +5551,7 @@ var Agent = class {
5638
5551
  );
5639
5552
  return contextWithBuiltins;
5640
5553
  } catch (error) {
5641
- logger16.error(
5554
+ logger15.error(
5642
5555
  {
5643
5556
  conversationId,
5644
5557
  error: error instanceof Error ? error.message : "Unknown error"
@@ -5662,7 +5575,7 @@ var Agent = class {
5662
5575
  });
5663
5576
  return graphDefinition?.graphPrompt || void 0;
5664
5577
  } catch (error) {
5665
- logger16.warn(
5578
+ logger15.warn(
5666
5579
  {
5667
5580
  graphId: this.config.graphId,
5668
5581
  error: error instanceof Error ? error.message : "Unknown error"
@@ -5689,7 +5602,7 @@ var Agent = class {
5689
5602
  }
5690
5603
  return !!(graphDefinition.artifactComponents && Object.keys(graphDefinition.artifactComponents).length > 0);
5691
5604
  } catch (error) {
5692
- logger16.warn(
5605
+ logger15.warn(
5693
5606
  {
5694
5607
  graphId: this.config.graphId,
5695
5608
  tenantId: this.config.tenantId,
@@ -5749,7 +5662,7 @@ Key requirements:
5749
5662
  preserveUnresolved: false
5750
5663
  });
5751
5664
  } catch (error) {
5752
- logger16.error(
5665
+ logger15.error(
5753
5666
  {
5754
5667
  conversationId,
5755
5668
  error: error instanceof Error ? error.message : "Unknown error"
@@ -5794,7 +5707,7 @@ Key requirements:
5794
5707
  preserveUnresolved: false
5795
5708
  });
5796
5709
  } catch (error) {
5797
- logger16.error(
5710
+ logger15.error(
5798
5711
  {
5799
5712
  conversationId,
5800
5713
  error: error instanceof Error ? error.message : "Unknown error"
@@ -5822,7 +5735,7 @@ Key requirements:
5822
5735
  artifactId: z5.z.string().describe("The unique identifier of the artifact to get.")
5823
5736
  }),
5824
5737
  execute: async ({ artifactId }) => {
5825
- logger16.info({ artifactId }, "get_artifact executed");
5738
+ logger15.info({ artifactId }, "get_artifact executed");
5826
5739
  const artifact = await agentsCore.getLedgerArtifacts(dbClient_default)({
5827
5740
  scopes: {
5828
5741
  tenantId: this.config.tenantId,
@@ -5889,7 +5802,7 @@ Key requirements:
5889
5802
  graphId: this.config.graphId
5890
5803
  });
5891
5804
  } catch (error) {
5892
- logger16.error(
5805
+ logger15.error(
5893
5806
  { error, graphId: this.config.graphId },
5894
5807
  "Failed to check graph artifact components"
5895
5808
  );
@@ -5897,7 +5810,7 @@ Key requirements:
5897
5810
  }
5898
5811
  }
5899
5812
  async generate(userMessage, runtimeContext) {
5900
- return tracer2.startActiveSpan(createSpanName("agent.generate"), async (span) => {
5813
+ return tracer.startActiveSpan("agent.generate", async (span) => {
5901
5814
  const contextId = runtimeContext?.contextId || "default";
5902
5815
  const taskId = runtimeContext?.metadata?.taskId || "unknown";
5903
5816
  const sessionId = toolSessionManager.createSession(
@@ -5921,8 +5834,8 @@ Key requirements:
5921
5834
  functionTools,
5922
5835
  relationTools,
5923
5836
  defaultTools
5924
- ] = await tracer2.startActiveSpan(
5925
- createSpanName("agent.load_tools"),
5837
+ ] = await tracer.startActiveSpan(
5838
+ "agent.load_tools",
5926
5839
  {
5927
5840
  attributes: {
5928
5841
  "agent.name": this.config.name,
@@ -5944,11 +5857,10 @@ Key requirements:
5944
5857
  childSpan.setStatus({ code: api.SpanStatusCode.OK });
5945
5858
  return result;
5946
5859
  } catch (err) {
5947
- handleSpanError(childSpan, err);
5860
+ agentsCore.setSpanWithError(childSpan, err);
5948
5861
  throw err;
5949
5862
  } finally {
5950
5863
  childSpan.end();
5951
- await forceFlushTracer();
5952
5864
  }
5953
5865
  }
5954
5866
  );
@@ -5994,7 +5906,7 @@ Key requirements:
5994
5906
  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;
5995
5907
  const timeoutMs = Math.min(configuredTimeout, MAX_ALLOWED_TIMEOUT_MS);
5996
5908
  if (modelSettings.maxDuration && modelSettings.maxDuration * 1e3 > MAX_ALLOWED_TIMEOUT_MS) {
5997
- logger16.warn(
5909
+ logger15.warn(
5998
5910
  {
5999
5911
  requestedTimeout: modelSettings.maxDuration * 1e3,
6000
5912
  appliedTimeout: timeoutMs,
@@ -6036,7 +5948,7 @@ Key requirements:
6036
5948
  }
6037
5949
  );
6038
5950
  } catch (error) {
6039
- logger16.debug("Failed to track agent reasoning");
5951
+ logger15.debug("Failed to track agent reasoning");
6040
5952
  }
6041
5953
  }
6042
5954
  if (last && "toolCalls" in last && last.toolCalls) {
@@ -6119,7 +6031,7 @@ Key requirements:
6119
6031
  }
6120
6032
  );
6121
6033
  } catch (error) {
6122
- logger16.debug("Failed to track agent reasoning");
6034
+ logger15.debug("Failed to track agent reasoning");
6123
6035
  }
6124
6036
  }
6125
6037
  if (last && "toolCalls" in last && last.toolCalls) {
@@ -6164,7 +6076,7 @@ Key requirements:
6164
6076
  return;
6165
6077
  }
6166
6078
  if (toolName === "save_artifact_tool" || toolName === "save_tool_result") {
6167
- logger16.info({ result }, "save_artifact_tool or save_tool_result");
6079
+ logger15.info({ result }, "save_artifact_tool or save_tool_result");
6168
6080
  if (result.output.artifacts) {
6169
6081
  for (const artifact of result.output.artifacts) {
6170
6082
  const artifactId = artifact?.artifactId || "N/A";
@@ -6270,7 +6182,6 @@ ${output}`;
6270
6182
  }
6271
6183
  span.setStatus({ code: api.SpanStatusCode.OK });
6272
6184
  span.end();
6273
- await forceFlushTracer();
6274
6185
  let formattedContent = response.formattedContent || null;
6275
6186
  if (!formattedContent) {
6276
6187
  if (response.object) {
@@ -6300,14 +6211,8 @@ ${output}`;
6300
6211
  return formattedResponse;
6301
6212
  } catch (error) {
6302
6213
  toolSessionManager.endSession(sessionId);
6303
- span.recordException(error);
6304
- span.setStatus({
6305
- code: api.SpanStatusCode.ERROR,
6306
- message: error.message
6307
- });
6214
+ agentsCore.setSpanWithError(span, error);
6308
6215
  span.end();
6309
- await forceFlushTracer();
6310
- getLogger("Agent").error(error, "Agent generate error");
6311
6216
  throw error;
6312
6217
  }
6313
6218
  });
@@ -6325,7 +6230,7 @@ function parseEmbeddedJson(data) {
6325
6230
  }
6326
6231
  });
6327
6232
  }
6328
- var logger17 = getLogger("generateTaskHandler");
6233
+ var logger16 = getLogger("generateTaskHandler");
6329
6234
  var createTaskHandler = (config2, credentialStoreRegistry) => {
6330
6235
  return async (task) => {
6331
6236
  try {
@@ -6375,7 +6280,7 @@ var createTaskHandler = (config2, credentialStoreRegistry) => {
6375
6280
  agentId: config2.agentId
6376
6281
  })
6377
6282
  ]);
6378
- logger17.info({ toolsForAgent, internalRelations, externalRelations }, "agent stuff");
6283
+ logger16.info({ toolsForAgent, internalRelations, externalRelations }, "agent stuff");
6379
6284
  const agentPrompt = "prompt" in config2.agentSchema ? config2.agentSchema.prompt : "";
6380
6285
  const models = "models" in config2.agentSchema ? config2.agentSchema.models : void 0;
6381
6286
  const stopWhen = "stopWhen" in config2.agentSchema ? config2.agentSchema.stopWhen : void 0;
@@ -6475,7 +6380,7 @@ var createTaskHandler = (config2, credentialStoreRegistry) => {
6475
6380
  const taskIdMatch = task.id.match(/^task_([^-]+-[^-]+-\d+)-/);
6476
6381
  if (taskIdMatch) {
6477
6382
  contextId = taskIdMatch[1];
6478
- logger17.info(
6383
+ logger16.info(
6479
6384
  {
6480
6385
  taskId: task.id,
6481
6386
  extractedContextId: contextId,
@@ -6491,7 +6396,7 @@ var createTaskHandler = (config2, credentialStoreRegistry) => {
6491
6396
  const isDelegation = task.context?.metadata?.isDelegation === true;
6492
6397
  agent.setDelegationStatus(isDelegation);
6493
6398
  if (isDelegation) {
6494
- logger17.info(
6399
+ logger16.info(
6495
6400
  { agentId: config2.agentId, taskId: task.id },
6496
6401
  "Delegated agent - streaming disabled"
6497
6402
  );
@@ -6774,7 +6679,7 @@ async function getRegisteredAgent(executionContext, credentialStoreRegistry) {
6774
6679
  // src/routes/agents.ts
6775
6680
  init_dbClient();
6776
6681
  var app = new zodOpenapi.OpenAPIHono();
6777
- var logger18 = getLogger("agents");
6682
+ var logger17 = getLogger("agents");
6778
6683
  app.openapi(
6779
6684
  zodOpenapi.createRoute({
6780
6685
  method: "get",
@@ -6812,7 +6717,7 @@ app.openapi(
6812
6717
  tracestate: c.req.header("tracestate"),
6813
6718
  baggage: c.req.header("baggage")
6814
6719
  };
6815
- logger18.info(
6720
+ logger17.info(
6816
6721
  {
6817
6722
  otelHeaders,
6818
6723
  path: c.req.path,
@@ -6823,7 +6728,7 @@ app.openapi(
6823
6728
  const executionContext = agentsCore.getRequestExecutionContext(c);
6824
6729
  const { tenantId, projectId, graphId, agentId } = executionContext;
6825
6730
  if (agentId) {
6826
- logger18.info(
6731
+ logger17.info(
6827
6732
  {
6828
6733
  message: "getRegisteredAgent (agent-level)",
6829
6734
  tenantId,
@@ -6835,13 +6740,13 @@ app.openapi(
6835
6740
  );
6836
6741
  const credentialStores = c.get("credentialStores");
6837
6742
  const agent = await getRegisteredAgent(executionContext, credentialStores);
6838
- logger18.info({ agent }, "agent registered: well-known agent.json");
6743
+ logger17.info({ agent }, "agent registered: well-known agent.json");
6839
6744
  if (!agent) {
6840
6745
  return c.json({ error: "Agent not found" }, 404);
6841
6746
  }
6842
6747
  return c.json(agent.agentCard);
6843
6748
  } else {
6844
- logger18.info(
6749
+ logger17.info(
6845
6750
  {
6846
6751
  message: "getRegisteredGraph (graph-level)",
6847
6752
  tenantId,
@@ -6864,7 +6769,7 @@ app.post("/a2a", async (c) => {
6864
6769
  tracestate: c.req.header("tracestate"),
6865
6770
  baggage: c.req.header("baggage")
6866
6771
  };
6867
- logger18.info(
6772
+ logger17.info(
6868
6773
  {
6869
6774
  otelHeaders,
6870
6775
  path: c.req.path,
@@ -6875,7 +6780,7 @@ app.post("/a2a", async (c) => {
6875
6780
  const executionContext = agentsCore.getRequestExecutionContext(c);
6876
6781
  const { tenantId, projectId, graphId, agentId } = executionContext;
6877
6782
  if (agentId) {
6878
- logger18.info(
6783
+ logger17.info(
6879
6784
  {
6880
6785
  message: "a2a (agent-level)",
6881
6786
  tenantId,
@@ -6899,7 +6804,7 @@ app.post("/a2a", async (c) => {
6899
6804
  }
6900
6805
  return a2aHandler(c, agent);
6901
6806
  } else {
6902
- logger18.info(
6807
+ logger17.info(
6903
6808
  {
6904
6809
  message: "a2a (graph-level)",
6905
6810
  tenantId,
@@ -6945,14 +6850,14 @@ init_dbClient();
6945
6850
 
6946
6851
  // src/a2a/transfer.ts
6947
6852
  init_dbClient();
6948
- var logger19 = getLogger("Transfer");
6853
+ var logger18 = getLogger("Transfer");
6949
6854
  async function executeTransfer({
6950
6855
  tenantId,
6951
6856
  threadId,
6952
6857
  projectId,
6953
6858
  targetAgentId
6954
6859
  }) {
6955
- logger19.info({ targetAgent: targetAgentId }, "Executing transfer to agent");
6860
+ logger18.info({ targetAgent: targetAgentId }, "Executing transfer to agent");
6956
6861
  await agentsCore.setActiveAgentForThread(dbClient_default)({
6957
6862
  scopes: { tenantId, projectId },
6958
6863
  threadId,
@@ -7494,7 +7399,7 @@ function createMCPStreamHelper() {
7494
7399
 
7495
7400
  // src/handlers/executionHandler.ts
7496
7401
  init_dbClient();
7497
- var logger20 = getLogger("ExecutionHandler");
7402
+ var logger19 = getLogger("ExecutionHandler");
7498
7403
  var ExecutionHandler = class {
7499
7404
  constructor() {
7500
7405
  // Hardcoded error limit - separate from configurable stopWhen
@@ -7519,7 +7424,7 @@ var ExecutionHandler = class {
7519
7424
  const { tenantId, projectId, graphId, apiKey, baseUrl } = executionContext;
7520
7425
  registerStreamHelper(requestId2, sseHelper);
7521
7426
  graphSessionManager.createSession(requestId2, graphId, tenantId, projectId);
7522
- logger20.info({ sessionId: requestId2, graphId }, "Created GraphSession for message execution");
7427
+ logger19.info({ sessionId: requestId2, graphId }, "Created GraphSession for message execution");
7523
7428
  let graphConfig = null;
7524
7429
  try {
7525
7430
  graphConfig = await agentsCore.getFullGraph(dbClient_default)({ scopes: { tenantId, projectId }, graphId });
@@ -7531,7 +7436,7 @@ var ExecutionHandler = class {
7531
7436
  );
7532
7437
  }
7533
7438
  } catch (error) {
7534
- logger20.error(
7439
+ logger19.error(
7535
7440
  {
7536
7441
  error: error instanceof Error ? error.message : "Unknown error",
7537
7442
  stack: error instanceof Error ? error.stack : void 0
@@ -7547,7 +7452,7 @@ var ExecutionHandler = class {
7547
7452
  try {
7548
7453
  await sseHelper.writeOperation(agentInitializingOp(requestId2, graphId));
7549
7454
  const taskId = `task_${conversationId}-${requestId2}`;
7550
- logger20.info(
7455
+ logger19.info(
7551
7456
  { taskId, currentAgentId, conversationId, requestId: requestId2 },
7552
7457
  "Attempting to create or reuse existing task"
7553
7458
  );
@@ -7570,7 +7475,7 @@ var ExecutionHandler = class {
7570
7475
  agent_id: currentAgentId
7571
7476
  }
7572
7477
  });
7573
- logger20.info(
7478
+ logger19.info(
7574
7479
  {
7575
7480
  taskId,
7576
7481
  createdTaskMetadata: Array.isArray(task) ? task[0]?.metadata : task?.metadata
@@ -7579,21 +7484,21 @@ var ExecutionHandler = class {
7579
7484
  );
7580
7485
  } catch (error) {
7581
7486
  if (error?.message?.includes("UNIQUE constraint failed") || error?.message?.includes("PRIMARY KEY constraint failed") || error?.code === "SQLITE_CONSTRAINT_PRIMARYKEY") {
7582
- logger20.info({ taskId, error: error.message }, "Task already exists, fetching existing task");
7487
+ logger19.info({ taskId, error: error.message }, "Task already exists, fetching existing task");
7583
7488
  const existingTask = await agentsCore.getTask(dbClient_default)({ id: taskId });
7584
7489
  if (existingTask) {
7585
7490
  task = existingTask;
7586
- logger20.info({ taskId, existingTask }, "Successfully reused existing task from race condition");
7491
+ logger19.info({ taskId, existingTask }, "Successfully reused existing task from race condition");
7587
7492
  } else {
7588
- logger20.error({ taskId, error }, "Task constraint failed but task not found");
7493
+ logger19.error({ taskId, error }, "Task constraint failed but task not found");
7589
7494
  throw error;
7590
7495
  }
7591
7496
  } else {
7592
- logger20.error({ taskId, error }, "Failed to create task due to non-constraint error");
7497
+ logger19.error({ taskId, error }, "Failed to create task due to non-constraint error");
7593
7498
  throw error;
7594
7499
  }
7595
7500
  }
7596
- logger20.debug(
7501
+ logger19.debug(
7597
7502
  {
7598
7503
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
7599
7504
  executionType: "create_initial_task",
@@ -7611,7 +7516,7 @@ var ExecutionHandler = class {
7611
7516
  const maxTransfers = graphConfig?.stopWhen?.transferCountIs ?? 10;
7612
7517
  while (iterations < maxTransfers) {
7613
7518
  iterations++;
7614
- logger20.info(
7519
+ logger19.info(
7615
7520
  { iterations, currentAgentId, graphId, conversationId, fromAgentId },
7616
7521
  `Execution loop iteration ${iterations} with agent ${currentAgentId}, transfer from: ${fromAgentId || "none"}`
7617
7522
  );
@@ -7619,10 +7524,10 @@ var ExecutionHandler = class {
7619
7524
  scopes: { tenantId, projectId },
7620
7525
  conversationId
7621
7526
  });
7622
- logger20.info({ activeAgent }, "activeAgent");
7527
+ logger19.info({ activeAgent }, "activeAgent");
7623
7528
  if (activeAgent && activeAgent.activeAgentId !== currentAgentId) {
7624
7529
  currentAgentId = activeAgent.activeAgentId;
7625
- logger20.info({ currentAgentId }, `Updated current agent to: ${currentAgentId}`);
7530
+ logger19.info({ currentAgentId }, `Updated current agent to: ${currentAgentId}`);
7626
7531
  }
7627
7532
  const agentBaseUrl = `${baseUrl}/agents`;
7628
7533
  const a2aClient = new A2AClient(agentBaseUrl, {
@@ -7663,13 +7568,13 @@ var ExecutionHandler = class {
7663
7568
  });
7664
7569
  if (!messageResponse?.result) {
7665
7570
  errorCount++;
7666
- logger20.error(
7571
+ logger19.error(
7667
7572
  { currentAgentId, iterations, errorCount },
7668
7573
  `No response from agent ${currentAgentId} on iteration ${iterations} (error ${errorCount}/${this.MAX_ERRORS})`
7669
7574
  );
7670
7575
  if (errorCount >= this.MAX_ERRORS) {
7671
7576
  const errorMessage2 = `Maximum error limit (${this.MAX_ERRORS}) reached`;
7672
- logger20.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
7577
+ logger19.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
7673
7578
  await sseHelper.writeError(errorMessage2);
7674
7579
  await sseHelper.writeOperation(errorOp(errorMessage2, currentAgentId || "system"));
7675
7580
  if (task) {
@@ -7695,7 +7600,7 @@ var ExecutionHandler = class {
7695
7600
  const transferResponse = messageResponse.result;
7696
7601
  const targetAgentId = transferResponse.artifacts?.[0]?.parts?.[0]?.data?.targetAgentId;
7697
7602
  const transferReason = transferResponse.artifacts?.[0]?.parts?.[1]?.text;
7698
- logger20.info({ targetAgentId, transferReason }, "transfer response");
7603
+ logger19.info({ targetAgentId, transferReason }, "transfer response");
7699
7604
  currentMessage = `<transfer_context> ${transferReason} </transfer_context>`;
7700
7605
  const { success, targetAgentId: newAgentId } = await executeTransfer({
7701
7606
  projectId,
@@ -7706,7 +7611,7 @@ var ExecutionHandler = class {
7706
7611
  if (success) {
7707
7612
  fromAgentId = currentAgentId;
7708
7613
  currentAgentId = newAgentId;
7709
- logger20.info(
7614
+ logger19.info(
7710
7615
  {
7711
7616
  transferFrom: fromAgentId,
7712
7617
  transferTo: currentAgentId,
@@ -7724,7 +7629,7 @@ var ExecutionHandler = class {
7724
7629
  const graphSessionData = graphSessionManager.getSession(requestId2);
7725
7630
  if (graphSessionData) {
7726
7631
  const sessionSummary = graphSessionData.getSummary();
7727
- logger20.info(sessionSummary, "GraphSession data after completion");
7632
+ logger19.info(sessionSummary, "GraphSession data after completion");
7728
7633
  }
7729
7634
  let textContent = "";
7730
7635
  for (const part of responseParts) {
@@ -7779,32 +7684,32 @@ var ExecutionHandler = class {
7779
7684
  }
7780
7685
  });
7781
7686
  const updateTaskEnd = Date.now();
7782
- logger20.info(
7687
+ logger19.info(
7783
7688
  { duration: updateTaskEnd - updateTaskStart },
7784
7689
  "Completed updateTask operation"
7785
7690
  );
7786
7691
  await sseHelper.writeOperation(completionOp(currentAgentId, iterations));
7787
7692
  await sseHelper.complete();
7788
- logger20.info("Ending GraphSession and cleaning up");
7693
+ logger19.info("Ending GraphSession and cleaning up");
7789
7694
  graphSessionManager.endSession(requestId2);
7790
- logger20.info("Cleaning up streamHelper");
7695
+ logger19.info("Cleaning up streamHelper");
7791
7696
  unregisterStreamHelper(requestId2);
7792
7697
  let response;
7793
7698
  if (sseHelper instanceof MCPStreamHelper) {
7794
7699
  const captured = sseHelper.getCapturedResponse();
7795
7700
  response = captured.text || "No response content";
7796
7701
  }
7797
- logger20.info("ExecutionHandler returning success");
7702
+ logger19.info("ExecutionHandler returning success");
7798
7703
  return { success: true, iterations, response };
7799
7704
  }
7800
7705
  errorCount++;
7801
- logger20.warn(
7706
+ logger19.warn(
7802
7707
  { iterations, errorCount },
7803
7708
  `No valid response or transfer on iteration ${iterations} (error ${errorCount}/${this.MAX_ERRORS})`
7804
7709
  );
7805
7710
  if (errorCount >= this.MAX_ERRORS) {
7806
7711
  const errorMessage2 = `Maximum error limit (${this.MAX_ERRORS}) reached`;
7807
- logger20.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
7712
+ logger19.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
7808
7713
  await sseHelper.writeError(errorMessage2);
7809
7714
  await sseHelper.writeOperation(errorOp(errorMessage2, currentAgentId || "system"));
7810
7715
  if (task) {
@@ -7826,7 +7731,7 @@ var ExecutionHandler = class {
7826
7731
  }
7827
7732
  }
7828
7733
  const errorMessage = `Maximum transfer limit (${maxTransfers}) reached without completion`;
7829
- logger20.error({ maxTransfers, iterations }, errorMessage);
7734
+ logger19.error({ maxTransfers, iterations }, errorMessage);
7830
7735
  await sseHelper.writeError(errorMessage);
7831
7736
  await sseHelper.writeOperation(errorOp(errorMessage, currentAgentId || "system"));
7832
7737
  if (task) {
@@ -7846,7 +7751,7 @@ var ExecutionHandler = class {
7846
7751
  unregisterStreamHelper(requestId2);
7847
7752
  return { success: false, error: errorMessage, iterations };
7848
7753
  } catch (error) {
7849
- logger20.error({ error }, "Error in execution handler");
7754
+ logger19.error({ error }, "Error in execution handler");
7850
7755
  const errorMessage = error instanceof Error ? error.message : "Unknown execution error";
7851
7756
  await sseHelper.writeError(`Execution error: ${errorMessage}`);
7852
7757
  await sseHelper.writeOperation(errorOp(errorMessage, currentAgentId || "system"));
@@ -7872,7 +7777,7 @@ var ExecutionHandler = class {
7872
7777
 
7873
7778
  // src/routes/chat.ts
7874
7779
  var app2 = new zodOpenapi.OpenAPIHono();
7875
- var logger21 = getLogger("completionsHandler");
7780
+ var logger20 = getLogger("completionsHandler");
7876
7781
  var chatCompletionsRoute = zodOpenapi.createRoute({
7877
7782
  method: "post",
7878
7783
  path: "/completions",
@@ -7990,7 +7895,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
7990
7895
  tracestate: c.req.header("tracestate"),
7991
7896
  baggage: c.req.header("baggage")
7992
7897
  };
7993
- logger21.info(
7898
+ logger20.info(
7994
7899
  {
7995
7900
  otelHeaders,
7996
7901
  path: c.req.path,
@@ -8076,7 +7981,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
8076
7981
  dbClient_default,
8077
7982
  credentialStores
8078
7983
  );
8079
- logger21.info(
7984
+ logger20.info(
8080
7985
  {
8081
7986
  tenantId,
8082
7987
  graphId,
@@ -8122,7 +8027,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
8122
8027
  return streaming.streamSSE(c, async (stream2) => {
8123
8028
  const sseHelper = createSSEStreamHelper(stream2, requestId2, timestamp);
8124
8029
  await sseHelper.writeRole();
8125
- logger21.info({ agentId }, "Starting execution");
8030
+ logger20.info({ agentId }, "Starting execution");
8126
8031
  const executionHandler = new ExecutionHandler();
8127
8032
  const result = await executionHandler.execute({
8128
8033
  executionContext,
@@ -8132,7 +8037,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
8132
8037
  requestId: requestId2,
8133
8038
  sseHelper
8134
8039
  });
8135
- logger21.info(
8040
+ logger20.info(
8136
8041
  { result },
8137
8042
  `Execution completed: ${result.success ? "success" : "failed"} after ${result.iterations} iterations`
8138
8043
  );
@@ -8168,7 +8073,7 @@ var chat_default = app2;
8168
8073
  // src/routes/chatDataStream.ts
8169
8074
  init_dbClient();
8170
8075
  var app3 = new zodOpenapi.OpenAPIHono();
8171
- var logger22 = getLogger("chatDataStream");
8076
+ var logger21 = getLogger("chatDataStream");
8172
8077
  var chatDataStreamRoute = zodOpenapi.createRoute({
8173
8078
  method: "post",
8174
8079
  path: "/chat",
@@ -8273,7 +8178,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
8273
8178
  );
8274
8179
  const lastUserMessage = body.messages.filter((m) => m.role === "user").slice(-1)[0];
8275
8180
  const userText = typeof lastUserMessage?.content === "string" ? lastUserMessage.content : lastUserMessage?.parts?.map((p) => p.text).join("") || "";
8276
- logger22.info({ userText, lastUserMessage }, "userText");
8181
+ logger21.info({ userText, lastUserMessage }, "userText");
8277
8182
  const messageSpan = api.trace.getActiveSpan();
8278
8183
  if (messageSpan) {
8279
8184
  messageSpan.setAttributes({
@@ -8315,7 +8220,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
8315
8220
  await streamHelper.writeError("Unable to process request");
8316
8221
  }
8317
8222
  } catch (err) {
8318
- logger22.error({ err }, "Streaming error");
8223
+ logger21.error({ err }, "Streaming error");
8319
8224
  await streamHelper.writeError("Internal server error");
8320
8225
  } finally {
8321
8226
  if ("cleanup" in streamHelper && typeof streamHelper.cleanup === "function") {
@@ -8336,7 +8241,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
8336
8241
  )
8337
8242
  );
8338
8243
  } catch (error) {
8339
- logger22.error({ error }, "chatDataStream error");
8244
+ logger21.error({ error }, "chatDataStream error");
8340
8245
  return c.json({ error: "Failed to process chat completion" }, 500);
8341
8246
  }
8342
8247
  });
@@ -8347,7 +8252,7 @@ init_dbClient();
8347
8252
  function createMCPSchema(schema) {
8348
8253
  return schema;
8349
8254
  }
8350
- var logger23 = getLogger("mcp");
8255
+ var logger22 = getLogger("mcp");
8351
8256
  var _MockResponseSingleton = class _MockResponseSingleton {
8352
8257
  constructor() {
8353
8258
  __publicField(this, "mockRes");
@@ -8402,21 +8307,21 @@ var createSpoofInitMessage = (mcpProtocolVersion) => ({
8402
8307
  id: 0
8403
8308
  });
8404
8309
  var spoofTransportInitialization = async (transport, req, sessionId, mcpProtocolVersion) => {
8405
- logger23.info({ sessionId }, "Spoofing initialization message to set transport state");
8310
+ logger22.info({ sessionId }, "Spoofing initialization message to set transport state");
8406
8311
  const spoofInitMessage = createSpoofInitMessage(mcpProtocolVersion);
8407
8312
  const mockRes = MockResponseSingleton.getInstance().getMockResponse();
8408
8313
  try {
8409
8314
  await transport.handleRequest(req, mockRes, spoofInitMessage);
8410
- logger23.info({ sessionId }, "Successfully spoofed initialization");
8315
+ logger22.info({ sessionId }, "Successfully spoofed initialization");
8411
8316
  } catch (spoofError) {
8412
- logger23.warn({ sessionId, error: spoofError }, "Spoof initialization failed, continuing anyway");
8317
+ logger22.warn({ sessionId, error: spoofError }, "Spoof initialization failed, continuing anyway");
8413
8318
  }
8414
8319
  };
8415
8320
  var validateSession = async (req, res, body, tenantId, projectId, graphId) => {
8416
8321
  const sessionId = req.headers["mcp-session-id"];
8417
- logger23.info({ sessionId }, "Received MCP session ID");
8322
+ logger22.info({ sessionId }, "Received MCP session ID");
8418
8323
  if (!sessionId) {
8419
- logger23.info({ body }, "Missing session ID");
8324
+ logger22.info({ body }, "Missing session ID");
8420
8325
  res.writeHead(400).end(
8421
8326
  JSON.stringify({
8422
8327
  jsonrpc: "2.0",
@@ -8442,7 +8347,7 @@ var validateSession = async (req, res, body, tenantId, projectId, graphId) => {
8442
8347
  scopes: { tenantId, projectId },
8443
8348
  conversationId: sessionId
8444
8349
  });
8445
- logger23.info(
8350
+ logger22.info(
8446
8351
  {
8447
8352
  sessionId,
8448
8353
  conversationFound: !!conversation,
@@ -8453,7 +8358,7 @@ var validateSession = async (req, res, body, tenantId, projectId, graphId) => {
8453
8358
  "Conversation lookup result"
8454
8359
  );
8455
8360
  if (!conversation || conversation.metadata?.sessionData?.sessionType !== "mcp" || conversation.metadata?.sessionData?.graphId !== graphId) {
8456
- logger23.info(
8361
+ logger22.info(
8457
8362
  { sessionId, conversationId: conversation?.id },
8458
8363
  "MCP session not found or invalid"
8459
8364
  );
@@ -8514,7 +8419,7 @@ var executeAgentQuery = async (executionContext, conversationId, query, defaultA
8514
8419
  requestId: requestId2,
8515
8420
  sseHelper: mcpStreamHelper
8516
8421
  });
8517
- logger23.info(
8422
+ logger22.info(
8518
8423
  { result },
8519
8424
  `Execution completed: ${result.success ? "success" : "failed"} after ${result.iterations} iterations`
8520
8425
  );
@@ -8588,7 +8493,7 @@ var getServer = async (requestContext, executionContext, conversationId, credent
8588
8493
  dbClient_default,
8589
8494
  credentialStores
8590
8495
  );
8591
- logger23.info(
8496
+ logger22.info(
8592
8497
  {
8593
8498
  tenantId,
8594
8499
  graphId,
@@ -8649,7 +8554,7 @@ var validateRequestParameters = (c) => {
8649
8554
  };
8650
8555
  var handleInitializationRequest = async (body, executionContext, validatedContext, req, res, c, credentialStores) => {
8651
8556
  const { tenantId, projectId, graphId } = executionContext;
8652
- logger23.info({ body }, "Received initialization request");
8557
+ logger22.info({ body }, "Received initialization request");
8653
8558
  const sessionId = nanoid.nanoid();
8654
8559
  const agentGraph = await agentsCore.getAgentGraphWithDefaultAgent(dbClient_default)({
8655
8560
  scopes: { tenantId, projectId },
@@ -8680,7 +8585,7 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
8680
8585
  }
8681
8586
  }
8682
8587
  });
8683
- logger23.info(
8588
+ logger22.info(
8684
8589
  { sessionId, conversationId: conversation.id },
8685
8590
  "Created MCP session as conversation"
8686
8591
  );
@@ -8689,9 +8594,9 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
8689
8594
  });
8690
8595
  const server = await getServer(validatedContext, executionContext, sessionId, credentialStores);
8691
8596
  await server.connect(transport);
8692
- logger23.info({ sessionId }, "Server connected for initialization");
8597
+ logger22.info({ sessionId }, "Server connected for initialization");
8693
8598
  res.setHeader("Mcp-Session-Id", sessionId);
8694
- logger23.info(
8599
+ logger22.info(
8695
8600
  {
8696
8601
  sessionId,
8697
8602
  bodyMethod: body?.method,
@@ -8700,7 +8605,7 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
8700
8605
  "About to handle initialization request"
8701
8606
  );
8702
8607
  await transport.handleRequest(req, res, body);
8703
- logger23.info({ sessionId }, "Successfully handled initialization request");
8608
+ logger22.info({ sessionId }, "Successfully handled initialization request");
8704
8609
  return fetchToNode.toFetchResponse(res);
8705
8610
  };
8706
8611
  var handleExistingSessionRequest = async (body, executionContext, validatedContext, req, res, credentialStores) => {
@@ -8728,8 +8633,8 @@ var handleExistingSessionRequest = async (body, executionContext, validatedConte
8728
8633
  sessionId,
8729
8634
  conversation.metadata?.session_data?.mcpProtocolVersion
8730
8635
  );
8731
- logger23.info({ sessionId }, "Server connected and transport initialized");
8732
- logger23.info(
8636
+ logger22.info({ sessionId }, "Server connected and transport initialized");
8637
+ logger22.info(
8733
8638
  {
8734
8639
  sessionId,
8735
8640
  bodyKeys: Object.keys(body || {}),
@@ -8743,9 +8648,9 @@ var handleExistingSessionRequest = async (body, executionContext, validatedConte
8743
8648
  );
8744
8649
  try {
8745
8650
  await transport.handleRequest(req, res, body);
8746
- logger23.info({ sessionId }, "Successfully handled MCP request");
8651
+ logger22.info({ sessionId }, "Successfully handled MCP request");
8747
8652
  } catch (transportError) {
8748
- logger23.error(
8653
+ logger22.error(
8749
8654
  {
8750
8655
  sessionId,
8751
8656
  error: transportError,
@@ -8796,13 +8701,13 @@ app4.openapi(
8796
8701
  }
8797
8702
  const { executionContext } = paramValidation;
8798
8703
  const body = await c.req.json();
8799
- logger23.info({ body, bodyKeys: Object.keys(body || {}) }, "Parsed request body");
8704
+ logger22.info({ body, bodyKeys: Object.keys(body || {}) }, "Parsed request body");
8800
8705
  const isInitRequest = body.method === "initialize";
8801
8706
  const { req, res } = fetchToNode.toReqRes(c.req.raw);
8802
8707
  const validatedContext = c.get("validatedContext") || {};
8803
8708
  const credentialStores = c.get("credentialStores");
8804
- logger23.info({ validatedContext }, "Validated context");
8805
- logger23.info({ req }, "request");
8709
+ logger22.info({ validatedContext }, "Validated context");
8710
+ logger22.info({ req }, "request");
8806
8711
  if (isInitRequest) {
8807
8712
  return await handleInitializationRequest(
8808
8713
  body,
@@ -8824,7 +8729,7 @@ app4.openapi(
8824
8729
  );
8825
8730
  }
8826
8731
  } catch (e) {
8827
- logger23.error(
8732
+ logger22.error(
8828
8733
  {
8829
8734
  error: e instanceof Error ? e.message : e,
8830
8735
  stack: e instanceof Error ? e.stack : void 0
@@ -8836,7 +8741,7 @@ app4.openapi(
8836
8741
  }
8837
8742
  );
8838
8743
  app4.get("/", async (c) => {
8839
- logger23.info("Received GET MCP request");
8744
+ logger22.info("Received GET MCP request");
8840
8745
  return c.json(
8841
8746
  {
8842
8747
  jsonrpc: "2.0",
@@ -8850,7 +8755,7 @@ app4.get("/", async (c) => {
8850
8755
  );
8851
8756
  });
8852
8757
  app4.delete("/", async (c) => {
8853
- logger23.info("Received DELETE MCP request");
8758
+ logger22.info("Received DELETE MCP request");
8854
8759
  return c.json(
8855
8760
  {
8856
8761
  jsonrpc: "2.0",
@@ -8930,9 +8835,9 @@ function createExecutionHono(serverConfig, credentialStores) {
8930
8835
  if (!isExpectedError) {
8931
8836
  const errorMessage = err instanceof Error ? err.message : String(err);
8932
8837
  const errorStack = err instanceof Error ? err.stack : void 0;
8933
- const logger24 = getLogger();
8934
- if (logger24) {
8935
- logger24.error(
8838
+ const logger23 = getLogger();
8839
+ if (logger23) {
8840
+ logger23.error(
8936
8841
  {
8937
8842
  error: err,
8938
8843
  message: errorMessage,
@@ -8944,9 +8849,9 @@ function createExecutionHono(serverConfig, credentialStores) {
8944
8849
  );
8945
8850
  }
8946
8851
  } else {
8947
- const logger24 = getLogger();
8948
- if (logger24) {
8949
- logger24.error(
8852
+ const logger23 = getLogger();
8853
+ if (logger23) {
8854
+ logger23.error(
8950
8855
  {
8951
8856
  error: err,
8952
8857
  path: c.req.path,
@@ -8963,9 +8868,9 @@ function createExecutionHono(serverConfig, credentialStores) {
8963
8868
  const response = err.getResponse();
8964
8869
  return response;
8965
8870
  } catch (responseError) {
8966
- const logger24 = getLogger();
8967
- if (logger24) {
8968
- logger24.error({ error: responseError }, "Error while handling HTTPException response");
8871
+ const logger23 = getLogger();
8872
+ if (logger23) {
8873
+ logger23.error({ error: responseError }, "Error while handling HTTPException response");
8969
8874
  }
8970
8875
  }
8971
8876
  }