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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.cjs +215 -250
  2. package/dist/index.js +211 -243
  3. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-base';
7
7
  import { ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions';
8
8
  import { resourceFromAttributes } from '@opentelemetry/resources';
9
9
  import { AsyncLocalStorageContextManager } from '@opentelemetry/context-async-hooks';
10
- import { getLogger as getLogger$1, getTracer, HeadersScopeSchema, getRequestExecutionContext, getAgentGraphWithDefaultAgent, contextValidationMiddleware, getFullGraph, createOrGetConversation, getActiveAgentForConversation, setActiveAgentForConversation, getAgentById, handleContextResolution, createMessage, commonGetErrorResponses, createDefaultCredentialStores, CredentialStoreRegistry, listTaskIdsByContextId, getTask, getLedgerArtifacts, getAgentGraph, createTask, updateTask, updateConversation, handleApiError, setSpanWithError, TaskState, setActiveAgentForThread, getConversation, getRelatedAgentsForGraph, getToolsForAgent, getDataComponentsForAgent, getArtifactComponentsForAgent, validateAndGetApiKey, getProject, ContextResolver, CredentialStuffer, MCPServerType, getCredentialReference, McpClient, getContextConfigById, getFullGraphDefinition, TemplateEngine, graphHasArtifactComponents, MCPTransportType, getExternalAgent } from '@inkeep/agents-core';
10
+ import { getLogger, getTracer, HeadersScopeSchema, getRequestExecutionContext, getAgentGraphWithDefaultAgent, contextValidationMiddleware, getFullGraph, createOrGetConversation, getActiveAgentForConversation, setActiveAgentForConversation, getAgentById, handleContextResolution, createMessage, commonGetErrorResponses, createDefaultCredentialStores, CredentialStoreRegistry, listTaskIdsByContextId, getTask, getLedgerArtifacts, getAgentGraph, createTask, updateTask, updateConversation, handleApiError, setSpanWithError, TaskState, setActiveAgentForThread, getConversation, getRelatedAgentsForGraph, getToolsForAgent, getDataComponentsForAgent, getArtifactComponentsForAgent, validateAndGetApiKey, getProject, ContextResolver, CredentialStuffer, MCPServerType, getCredentialReference, McpClient, getContextConfigById, getFullGraphDefinition, TemplateEngine, graphHasArtifactComponents, MCPTransportType, getExternalAgent } from '@inkeep/agents-core';
11
11
  import { Hono } from 'hono';
12
12
  import { OpenAPIHono, createRoute, z as z$1 } from '@hono/zod-openapi';
13
13
  import { trace, propagation, context, SpanStatusCode } from '@opentelemetry/api';
@@ -16,7 +16,6 @@ import { HTTPException } from 'hono/http-exception';
16
16
  import { requestId } from 'hono/request-id';
17
17
  import { pinoLogger } from 'hono-pino';
18
18
  import { pino } from 'pino';
19
- import { AsyncLocalStorage } from 'async_hooks';
20
19
  import { createMiddleware } from 'hono/factory';
21
20
  import { swaggerUI } from '@hono/swagger-ui';
22
21
  import z4, { z } from 'zod';
@@ -69,37 +68,6 @@ var sdk = new NodeSDK({
69
68
  ]
70
69
  });
71
70
  sdk.start();
72
- var isDevelopment = env.ENVIRONMENT === "development";
73
- var loggerConfig = {
74
- level: env.LOG_LEVEL,
75
- serializers: {
76
- obj: (value) => ({ ...value })
77
- },
78
- redact: ["req.headers.authorization", 'req.headers["x-inkeep-admin-authentication"]'],
79
- // Only use pino-pretty in development
80
- ...isDevelopment && {
81
- transport: {
82
- target: "pino-pretty",
83
- options: {
84
- sync: true,
85
- destination: 1,
86
- // stdout
87
- colorize: true,
88
- translateTime: "SYS:standard"
89
- }
90
- }
91
- }
92
- };
93
- var logger = pino(loggerConfig);
94
- var asyncLocalStorage = new AsyncLocalStorage();
95
- function getLogger(name) {
96
- const store = asyncLocalStorage.getStore();
97
- const reqId = store?.get("requestId") || void 0;
98
- if (!reqId) {
99
- return logger.child({ name });
100
- }
101
- return logger.child({ reqId, name });
102
- }
103
71
 
104
72
  // src/types/execution-context.ts
105
73
  function createExecutionContext(params) {
@@ -115,7 +83,7 @@ function createExecutionContext(params) {
115
83
  }
116
84
 
117
85
  // src/middleware/api-key-auth.ts
118
- var logger2 = getLogger$1("env-key-auth");
86
+ var logger = getLogger("env-key-auth");
119
87
  var apiKeyAuth = () => createMiddleware(async (c, next) => {
120
88
  if (c.req.method === "OPTIONS") {
121
89
  await next();
@@ -132,7 +100,7 @@ var apiKeyAuth = () => createMiddleware(async (c, next) => {
132
100
  if (authHeader?.startsWith("Bearer ")) {
133
101
  try {
134
102
  executionContext = await extractContextFromApiKey(authHeader.substring(7));
135
- logger2.info({}, "Development/test environment - API key authenticated successfully");
103
+ logger.info({}, "Development/test environment - API key authenticated successfully");
136
104
  } catch {
137
105
  executionContext = createExecutionContext({
138
106
  apiKey: "development",
@@ -143,7 +111,7 @@ var apiKeyAuth = () => createMiddleware(async (c, next) => {
143
111
  baseUrl,
144
112
  agentId
145
113
  });
146
- logger2.info(
114
+ logger.info(
147
115
  {},
148
116
  "Development/test environment - fallback to default context due to invalid API key"
149
117
  );
@@ -158,7 +126,7 @@ var apiKeyAuth = () => createMiddleware(async (c, next) => {
158
126
  baseUrl,
159
127
  agentId
160
128
  });
161
- logger2.info(
129
+ logger.info(
162
130
  {},
163
131
  "Development/test environment - no API key provided, using default context"
164
132
  );
@@ -190,13 +158,13 @@ var apiKeyAuth = () => createMiddleware(async (c, next) => {
190
158
  agentId
191
159
  });
192
160
  c.set("executionContext", executionContext);
193
- logger2.info({}, "Bypass secret authenticated successfully");
161
+ logger.info({}, "Bypass secret authenticated successfully");
194
162
  await next();
195
163
  return;
196
164
  } else if (apiKey) {
197
165
  const executionContext = await extractContextFromApiKey(apiKey);
198
166
  c.set("executionContext", executionContext);
199
- logger2.info({}, "API key authenticated successfully");
167
+ logger.info({}, "API key authenticated successfully");
200
168
  await next();
201
169
  return;
202
170
  } else {
@@ -213,7 +181,7 @@ var apiKeyAuth = () => createMiddleware(async (c, next) => {
213
181
  try {
214
182
  const executionContext = await extractContextFromApiKey(apiKey);
215
183
  c.set("executionContext", executionContext);
216
- logger2.debug(
184
+ logger.debug(
217
185
  {
218
186
  tenantId: executionContext.tenantId,
219
187
  projectId: executionContext.projectId,
@@ -226,7 +194,7 @@ var apiKeyAuth = () => createMiddleware(async (c, next) => {
226
194
  if (error instanceof HTTPException) {
227
195
  throw error;
228
196
  }
229
- logger2.error({ error }, "API key authentication error");
197
+ logger.error({ error }, "API key authentication error");
230
198
  throw new HTTPException(500, {
231
199
  message: "Authentication failed"
232
200
  });
@@ -279,7 +247,7 @@ function setupOpenAPIRoutes(app6) {
279
247
  })
280
248
  );
281
249
  }
282
- var logger3 = getLogger("a2aHandler");
250
+ var logger2 = getLogger("a2aHandler");
283
251
  async function a2aHandler(c, agent) {
284
252
  try {
285
253
  const rpcRequest = await c.req.json();
@@ -381,7 +349,7 @@ async function handleMessageSend(c, agent, request) {
381
349
  messageId: task.id,
382
350
  kind: "message"
383
351
  });
384
- logger3.warn(
352
+ logger2.warn(
385
353
  {
386
354
  taskId: task.id,
387
355
  agentId: agent.agentId,
@@ -391,7 +359,7 @@ async function handleMessageSend(c, agent, request) {
391
359
  );
392
360
  }
393
361
  } catch (error) {
394
- logger3.error({ error, taskId: task.id }, "Failed to serialize message");
362
+ logger2.error({ error, taskId: task.id }, "Failed to serialize message");
395
363
  JSON.stringify({
396
364
  error: "Failed to serialize message",
397
365
  taskId: task.id,
@@ -399,7 +367,7 @@ async function handleMessageSend(c, agent, request) {
399
367
  parts: [{ text: "Error in delegation", kind: "text" }]
400
368
  });
401
369
  }
402
- logger3.info(
370
+ logger2.info(
403
371
  {
404
372
  originalContextId: params.message.contextId,
405
373
  taskContextId: task.context?.conversationId,
@@ -428,7 +396,7 @@ async function handleMessageSend(c, agent, request) {
428
396
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
429
397
  updatedAt: (/* @__PURE__ */ new Date()).toISOString()
430
398
  });
431
- logger3.info({ metadata: params.message.metadata }, "message metadata");
399
+ logger2.info({ metadata: params.message.metadata }, "message metadata");
432
400
  if (params.message.metadata?.fromAgentId || params.message.metadata?.fromExternalAgentId) {
433
401
  const messageText = params.message.parts.filter((part) => part.kind === "text" && "text" in part && part.text).map((part) => part.text).join(" ");
434
402
  try {
@@ -453,7 +421,7 @@ async function handleMessageSend(c, agent, request) {
453
421
  messageData.toAgentId = agent.agentId;
454
422
  }
455
423
  await createMessage(dbClient_default)(messageData);
456
- logger3.info(
424
+ logger2.info(
457
425
  {
458
426
  fromAgentId: params.message.metadata.fromAgentId,
459
427
  fromExternalAgentId: params.message.metadata.fromExternalAgentId,
@@ -465,7 +433,7 @@ async function handleMessageSend(c, agent, request) {
465
433
  "A2A message stored in database"
466
434
  );
467
435
  } catch (error) {
468
- logger3.error(
436
+ logger2.error(
469
437
  {
470
438
  error,
471
439
  fromAgentId: params.message.metadata.fromAgentId,
@@ -502,7 +470,7 @@ async function handleMessageSend(c, agent, request) {
502
470
  (part) => part.kind === "data" && part.data && typeof part.data === "object" && part.data.type === "transfer"
503
471
  );
504
472
  if (transferPart && transferPart.kind === "data" && transferPart.data) {
505
- logger3.info({ transferPart }, "transferPart");
473
+ logger2.info({ transferPart }, "transferPart");
506
474
  return c.json({
507
475
  jsonrpc: "2.0",
508
476
  result: {
@@ -920,10 +888,10 @@ function statusUpdateOp(ctx) {
920
888
  ctx
921
889
  };
922
890
  }
923
- var logger4 = getLogger("DataComponentSchema");
891
+ var logger3 = getLogger("DataComponentSchema");
924
892
  function jsonSchemaToZod(jsonSchema) {
925
893
  if (!jsonSchema || typeof jsonSchema !== "object") {
926
- logger4.warn({ jsonSchema }, "Invalid JSON schema provided, using string fallback");
894
+ logger3.warn({ jsonSchema }, "Invalid JSON schema provided, using string fallback");
927
895
  return z.string();
928
896
  }
929
897
  switch (jsonSchema.type) {
@@ -950,7 +918,7 @@ function jsonSchemaToZod(jsonSchema) {
950
918
  case "null":
951
919
  return z.null();
952
920
  default:
953
- logger4.warn(
921
+ logger3.warn(
954
922
  {
955
923
  unsupportedType: jsonSchema.type,
956
924
  schema: jsonSchema
@@ -1004,7 +972,7 @@ __publicField(_ArtifactReferenceSchema, "ARTIFACT_PROPS_SCHEMA", {
1004
972
  required: ["artifact_id", "task_id"]
1005
973
  });
1006
974
  var ArtifactReferenceSchema = _ArtifactReferenceSchema;
1007
- var logger5 = getLogger("ModelFactory");
975
+ var logger4 = getLogger("ModelFactory");
1008
976
  var _ModelFactory = class _ModelFactory {
1009
977
  /**
1010
978
  * Create a language model instance from configuration
@@ -1019,7 +987,7 @@ var _ModelFactory = class _ModelFactory {
1019
987
  const modelSettings = config;
1020
988
  const modelString = modelSettings.model.trim();
1021
989
  const { provider, modelName } = _ModelFactory.parseModelString(modelString);
1022
- logger5.debug(
990
+ logger4.debug(
1023
991
  {
1024
992
  provider,
1025
993
  model: modelName,
@@ -1040,7 +1008,7 @@ var _ModelFactory = class _ModelFactory {
1040
1008
  );
1041
1009
  }
1042
1010
  } catch (error) {
1043
- logger5.error(
1011
+ logger4.error(
1044
1012
  {
1045
1013
  provider,
1046
1014
  model: modelName,
@@ -1063,7 +1031,7 @@ var _ModelFactory = class _ModelFactory {
1063
1031
  const [provider, ...modelParts] = modelString.split("/");
1064
1032
  const normalizedProvider = provider.toLowerCase();
1065
1033
  if (!_ModelFactory.SUPPORTED_PROVIDERS.includes(normalizedProvider)) {
1066
- logger5.warn(
1034
+ logger4.warn(
1067
1035
  { provider: normalizedProvider, modelName: modelParts.join("/") },
1068
1036
  "Unsupported provider detected, falling back to anthropic"
1069
1037
  );
@@ -1092,14 +1060,14 @@ var _ModelFactory = class _ModelFactory {
1092
1060
  anthropicConfig.baseURL = providerOptions.baseUrl || providerOptions.baseURL;
1093
1061
  }
1094
1062
  if (providerOptions?.gateway) {
1095
- logger5.info(
1063
+ logger4.info(
1096
1064
  { gateway: providerOptions.gateway },
1097
1065
  "Setting up AI Gateway for Anthropic model"
1098
1066
  );
1099
1067
  Object.assign(anthropicConfig, providerOptions.gateway);
1100
1068
  }
1101
1069
  if (Object.keys(anthropicConfig).length > 0) {
1102
- logger5.info({ config: anthropicConfig }, "Applying custom Anthropic provider configuration");
1070
+ logger4.info({ config: anthropicConfig }, "Applying custom Anthropic provider configuration");
1103
1071
  const provider = createAnthropic(anthropicConfig);
1104
1072
  return provider(modelName);
1105
1073
  }
@@ -1114,11 +1082,11 @@ var _ModelFactory = class _ModelFactory {
1114
1082
  openaiConfig.baseURL = providerOptions.baseUrl || providerOptions.baseURL;
1115
1083
  }
1116
1084
  if (providerOptions?.gateway) {
1117
- logger5.info({ gateway: providerOptions.gateway }, "Setting up AI Gateway for OpenAI model");
1085
+ logger4.info({ gateway: providerOptions.gateway }, "Setting up AI Gateway for OpenAI model");
1118
1086
  Object.assign(openaiConfig, providerOptions.gateway);
1119
1087
  }
1120
1088
  if (Object.keys(openaiConfig).length > 0) {
1121
- logger5.info({ config: openaiConfig }, "Applying custom OpenAI provider configuration");
1089
+ logger4.info({ config: openaiConfig }, "Applying custom OpenAI provider configuration");
1122
1090
  const provider = createOpenAI(openaiConfig);
1123
1091
  return provider(modelName);
1124
1092
  }
@@ -1208,7 +1176,7 @@ function unregisterStreamHelper(requestId2) {
1208
1176
  }
1209
1177
 
1210
1178
  // src/utils/graph-session.ts
1211
- var logger6 = getLogger("GraphSession");
1179
+ var logger5 = getLogger("GraphSession");
1212
1180
  var GraphSession = class {
1213
1181
  // Track scheduled timeouts for cleanup
1214
1182
  constructor(sessionId, messageId, graphId, tenantId, projectId) {
@@ -1232,7 +1200,7 @@ var GraphSession = class {
1232
1200
  __publicField(this, "MAX_PENDING_ARTIFACTS", 100);
1233
1201
  // Prevent unbounded growth
1234
1202
  __publicField(this, "scheduledTimeouts");
1235
- logger6.debug({ sessionId, messageId, graphId }, "GraphSession created");
1203
+ logger5.debug({ sessionId, messageId, graphId }, "GraphSession created");
1236
1204
  }
1237
1205
  /**
1238
1206
  * Initialize status updates for this session
@@ -1254,7 +1222,7 @@ var GraphSession = class {
1254
1222
  if (this.statusUpdateState.config.timeInSeconds) {
1255
1223
  this.statusUpdateTimer = setInterval(async () => {
1256
1224
  if (!this.statusUpdateState || this.isEnded) {
1257
- logger6.debug(
1225
+ logger5.debug(
1258
1226
  { sessionId: this.sessionId },
1259
1227
  "Timer triggered but session already cleaned up or ended"
1260
1228
  );
@@ -1266,7 +1234,7 @@ var GraphSession = class {
1266
1234
  }
1267
1235
  await this.checkAndSendTimeBasedUpdate();
1268
1236
  }, this.statusUpdateState.config.timeInSeconds * 1e3);
1269
- logger6.info(
1237
+ logger5.info(
1270
1238
  {
1271
1239
  sessionId: this.sessionId,
1272
1240
  intervalMs: this.statusUpdateState.config.timeInSeconds * 1e3
@@ -1280,7 +1248,7 @@ var GraphSession = class {
1280
1248
  */
1281
1249
  recordEvent(eventType, agentId, data) {
1282
1250
  if (this.isEnded) {
1283
- logger6.debug(
1251
+ logger5.debug(
1284
1252
  {
1285
1253
  sessionId: this.sessionId,
1286
1254
  eventType,
@@ -1300,7 +1268,7 @@ var GraphSession = class {
1300
1268
  if (eventType === "artifact_saved" && data.pendingGeneration) {
1301
1269
  const artifactId = data.artifactId;
1302
1270
  if (this.pendingArtifacts.size >= this.MAX_PENDING_ARTIFACTS) {
1303
- logger6.warn(
1271
+ logger5.warn(
1304
1272
  {
1305
1273
  sessionId: this.sessionId,
1306
1274
  artifactId,
@@ -1321,7 +1289,7 @@ var GraphSession = class {
1321
1289
  this.artifactProcessingErrors.set(artifactId, errorCount);
1322
1290
  if (errorCount >= this.MAX_ARTIFACT_RETRIES) {
1323
1291
  this.pendingArtifacts.delete(artifactId);
1324
- logger6.error(
1292
+ logger5.error(
1325
1293
  {
1326
1294
  sessionId: this.sessionId,
1327
1295
  artifactId,
@@ -1333,7 +1301,7 @@ var GraphSession = class {
1333
1301
  "Artifact processing failed after max retries, giving up"
1334
1302
  );
1335
1303
  } else {
1336
- logger6.warn(
1304
+ logger5.warn(
1337
1305
  {
1338
1306
  sessionId: this.sessionId,
1339
1307
  artifactId,
@@ -1355,14 +1323,14 @@ var GraphSession = class {
1355
1323
  */
1356
1324
  checkStatusUpdates() {
1357
1325
  if (this.isEnded) {
1358
- logger6.debug(
1326
+ logger5.debug(
1359
1327
  { sessionId: this.sessionId },
1360
1328
  "Session has ended - skipping status update check"
1361
1329
  );
1362
1330
  return;
1363
1331
  }
1364
1332
  if (!this.statusUpdateState) {
1365
- logger6.debug({ sessionId: this.sessionId }, "No status update state - skipping check");
1333
+ logger5.debug({ sessionId: this.sessionId }, "No status update state - skipping check");
1366
1334
  return;
1367
1335
  }
1368
1336
  const statusUpdateState = this.statusUpdateState;
@@ -1373,11 +1341,11 @@ var GraphSession = class {
1373
1341
  */
1374
1342
  async checkAndSendTimeBasedUpdate() {
1375
1343
  if (this.isEnded) {
1376
- logger6.debug({ sessionId: this.sessionId }, "Session has ended - skipping time-based update");
1344
+ logger5.debug({ sessionId: this.sessionId }, "Session has ended - skipping time-based update");
1377
1345
  return;
1378
1346
  }
1379
1347
  if (!this.statusUpdateState) {
1380
- logger6.debug(
1348
+ logger5.debug(
1381
1349
  { sessionId: this.sessionId },
1382
1350
  "No status updates configured for time-based check"
1383
1351
  );
@@ -1390,7 +1358,7 @@ var GraphSession = class {
1390
1358
  try {
1391
1359
  await this.generateAndSendUpdate();
1392
1360
  } catch (error) {
1393
- logger6.error(
1361
+ logger5.error(
1394
1362
  {
1395
1363
  sessionId: this.sessionId,
1396
1364
  error: error instanceof Error ? error.message : "Unknown error"
@@ -1483,29 +1451,29 @@ var GraphSession = class {
1483
1451
  */
1484
1452
  async generateAndSendUpdate() {
1485
1453
  if (this.isEnded) {
1486
- logger6.debug({ sessionId: this.sessionId }, "Session has ended - not generating update");
1454
+ logger5.debug({ sessionId: this.sessionId }, "Session has ended - not generating update");
1487
1455
  return;
1488
1456
  }
1489
1457
  if (this.isTextStreaming) {
1490
- logger6.debug(
1458
+ logger5.debug(
1491
1459
  { sessionId: this.sessionId },
1492
1460
  "Text is currently streaming - skipping status update"
1493
1461
  );
1494
1462
  return;
1495
1463
  }
1496
1464
  if (this.isGeneratingUpdate) {
1497
- logger6.debug(
1465
+ logger5.debug(
1498
1466
  { sessionId: this.sessionId },
1499
1467
  "Update already in progress - skipping duplicate generation"
1500
1468
  );
1501
1469
  return;
1502
1470
  }
1503
1471
  if (!this.statusUpdateState) {
1504
- logger6.warn({ sessionId: this.sessionId }, "No status update state - cannot generate update");
1472
+ logger5.warn({ sessionId: this.sessionId }, "No status update state - cannot generate update");
1505
1473
  return;
1506
1474
  }
1507
1475
  if (!this.graphId) {
1508
- logger6.warn({ sessionId: this.sessionId }, "No graph ID - cannot generate update");
1476
+ logger5.warn({ sessionId: this.sessionId }, "No graph ID - cannot generate update");
1509
1477
  return;
1510
1478
  }
1511
1479
  const newEventCount = this.events.length - this.statusUpdateState.lastEventCount;
@@ -1518,7 +1486,7 @@ var GraphSession = class {
1518
1486
  try {
1519
1487
  const streamHelper = getStreamHelper(this.sessionId);
1520
1488
  if (!streamHelper) {
1521
- logger6.warn(
1489
+ logger5.warn(
1522
1490
  { sessionId: this.sessionId },
1523
1491
  "No stream helper found - cannot send status update"
1524
1492
  );
@@ -1539,7 +1507,7 @@ var GraphSession = class {
1539
1507
  if (result.operations && result.operations.length > 0) {
1540
1508
  for (const op of result.operations) {
1541
1509
  if (!op || !op.type || !op.data || Object.keys(op.data).length === 0) {
1542
- logger6.warn(
1510
+ logger5.warn(
1543
1511
  {
1544
1512
  sessionId: this.sessionId,
1545
1513
  operation: op
@@ -1592,7 +1560,7 @@ var GraphSession = class {
1592
1560
  this.previousSummaries.shift();
1593
1561
  }
1594
1562
  if (!operation || !operation.type || !operation.ctx) {
1595
- logger6.warn(
1563
+ logger5.warn(
1596
1564
  {
1597
1565
  sessionId: this.sessionId,
1598
1566
  operation
@@ -1607,7 +1575,7 @@ var GraphSession = class {
1607
1575
  this.statusUpdateState.lastEventCount = this.events.length;
1608
1576
  }
1609
1577
  } catch (error) {
1610
- logger6.error(
1578
+ logger5.error(
1611
1579
  {
1612
1580
  sessionId: this.sessionId,
1613
1581
  error: error instanceof Error ? error.message : "Unknown error",
@@ -1645,7 +1613,7 @@ var GraphSession = class {
1645
1613
  this.releaseUpdateLock();
1646
1614
  }
1647
1615
  } catch (error) {
1648
- logger6.error(
1616
+ logger5.error(
1649
1617
  {
1650
1618
  sessionId: this.sessionId,
1651
1619
  error: error instanceof Error ? error.message : "Unknown error"
@@ -1722,7 +1690,7 @@ User's Question/Context:
1722
1690
  ${conversationHistory}
1723
1691
  ` : "";
1724
1692
  } catch (error) {
1725
- logger6.warn(
1693
+ logger5.warn(
1726
1694
  { sessionId: this.sessionId, error },
1727
1695
  "Failed to fetch conversation history for status update"
1728
1696
  );
@@ -1774,7 +1742,7 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
1774
1742
  return text.trim();
1775
1743
  } catch (error) {
1776
1744
  setSpanWithError(span, error);
1777
- logger6.error({ error }, "Failed to generate summary, using fallback");
1745
+ logger5.error({ error }, "Failed to generate summary, using fallback");
1778
1746
  return this.generateFallbackSummary(newEvents, elapsedTime);
1779
1747
  } finally {
1780
1748
  span.end();
@@ -1820,7 +1788,7 @@ User's Question/Context:
1820
1788
  ${conversationHistory}
1821
1789
  ` : "";
1822
1790
  } catch (error) {
1823
- logger6.warn(
1791
+ logger5.warn(
1824
1792
  { sessionId: this.sessionId, error },
1825
1793
  "Failed to fetch conversation history for structured status update"
1826
1794
  );
@@ -1919,7 +1887,7 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
1919
1887
  return { operations };
1920
1888
  } catch (error) {
1921
1889
  setSpanWithError(span, error);
1922
- logger6.error({ error }, "Failed to generate structured update, using fallback");
1890
+ logger5.error({ error }, "Failed to generate structured update, using fallback");
1923
1891
  return { operations: [] };
1924
1892
  } finally {
1925
1893
  span.end();
@@ -2246,7 +2214,7 @@ Make it specific and relevant.`;
2246
2214
  taskId: artifactData.taskId,
2247
2215
  artifacts: [artifactToSave]
2248
2216
  });
2249
- logger6.info(
2217
+ logger5.info(
2250
2218
  {
2251
2219
  sessionId: this.sessionId,
2252
2220
  artifactId: artifactData.artifactId,
@@ -2263,7 +2231,7 @@ Make it specific and relevant.`;
2263
2231
  span.setStatus({ code: SpanStatusCode.OK });
2264
2232
  } catch (error) {
2265
2233
  setSpanWithError(span, error);
2266
- logger6.error(
2234
+ logger5.error(
2267
2235
  {
2268
2236
  sessionId: this.sessionId,
2269
2237
  artifactId: artifactData.artifactId,
@@ -2299,7 +2267,7 @@ Make it specific and relevant.`;
2299
2267
  taskId: artifactData.taskId,
2300
2268
  artifacts: [fallbackArtifact]
2301
2269
  });
2302
- logger6.info(
2270
+ logger5.info(
2303
2271
  {
2304
2272
  sessionId: this.sessionId,
2305
2273
  artifactId: artifactData.artifactId
@@ -2308,7 +2276,7 @@ Make it specific and relevant.`;
2308
2276
  );
2309
2277
  }
2310
2278
  } catch (fallbackError) {
2311
- logger6.error(
2279
+ logger5.error(
2312
2280
  {
2313
2281
  sessionId: this.sessionId,
2314
2282
  artifactId: artifactData.artifactId,
@@ -2335,7 +2303,7 @@ var GraphSessionManager = class {
2335
2303
  const sessionId = messageId;
2336
2304
  const session = new GraphSession(sessionId, messageId, graphId, tenantId, projectId);
2337
2305
  this.sessions.set(sessionId, session);
2338
- logger6.info({ sessionId, messageId, graphId, tenantId, projectId }, "GraphSession created");
2306
+ logger5.info({ sessionId, messageId, graphId, tenantId, projectId }, "GraphSession created");
2339
2307
  return sessionId;
2340
2308
  }
2341
2309
  /**
@@ -2346,7 +2314,7 @@ var GraphSessionManager = class {
2346
2314
  if (session) {
2347
2315
  session.initializeStatusUpdates(config, summarizerModel);
2348
2316
  } else {
2349
- logger6.error(
2317
+ logger5.error(
2350
2318
  {
2351
2319
  sessionId,
2352
2320
  availableSessions: Array.from(this.sessions.keys())
@@ -2367,7 +2335,7 @@ var GraphSessionManager = class {
2367
2335
  recordEvent(sessionId, eventType, agentId, data) {
2368
2336
  const session = this.sessions.get(sessionId);
2369
2337
  if (!session) {
2370
- logger6.warn({ sessionId }, "Attempted to record event in non-existent session");
2338
+ logger5.warn({ sessionId }, "Attempted to record event in non-existent session");
2371
2339
  return;
2372
2340
  }
2373
2341
  session.recordEvent(eventType, agentId, data);
@@ -2378,12 +2346,12 @@ var GraphSessionManager = class {
2378
2346
  endSession(sessionId) {
2379
2347
  const session = this.sessions.get(sessionId);
2380
2348
  if (!session) {
2381
- logger6.warn({ sessionId }, "Attempted to end non-existent session");
2349
+ logger5.warn({ sessionId }, "Attempted to end non-existent session");
2382
2350
  return [];
2383
2351
  }
2384
2352
  const events = session.getEvents();
2385
2353
  const summary = session.getSummary();
2386
- logger6.info({ sessionId, summary }, "GraphSession ended");
2354
+ logger5.info({ sessionId, summary }, "GraphSession ended");
2387
2355
  session.cleanup();
2388
2356
  this.sessions.delete(sessionId);
2389
2357
  return events;
@@ -2409,7 +2377,7 @@ var GraphSessionManager = class {
2409
2377
  }
2410
2378
  };
2411
2379
  var graphSessionManager = new GraphSessionManager();
2412
- var logger7 = getLogger("ArtifactParser");
2380
+ var logger6 = getLogger("ArtifactParser");
2413
2381
  var _ArtifactParser = class _ArtifactParser {
2414
2382
  constructor(tenantId) {
2415
2383
  this.tenantId = tenantId;
@@ -2475,7 +2443,7 @@ var _ArtifactParser = class _ArtifactParser {
2475
2443
  id: taskId
2476
2444
  });
2477
2445
  if (!task) {
2478
- logger7.warn({ taskId }, "Task not found when fetching artifacts");
2446
+ logger6.warn({ taskId }, "Task not found when fetching artifacts");
2479
2447
  continue;
2480
2448
  }
2481
2449
  const taskArtifacts = await getLedgerArtifacts(dbClient_default)({
@@ -2487,9 +2455,9 @@ var _ArtifactParser = class _ArtifactParser {
2487
2455
  artifacts.set(key, artifact);
2488
2456
  }
2489
2457
  }
2490
- logger7.debug({ contextId, count: artifacts.size }, "Loaded context artifacts");
2458
+ logger6.debug({ contextId, count: artifacts.size }, "Loaded context artifacts");
2491
2459
  } catch (error) {
2492
- logger7.error({ error, contextId }, "Error loading context artifacts");
2460
+ logger6.error({ error, contextId }, "Error loading context artifacts");
2493
2461
  }
2494
2462
  return artifacts;
2495
2463
  }
@@ -2592,7 +2560,7 @@ var _ArtifactParser = class _ArtifactParser {
2592
2560
  id: taskId
2593
2561
  });
2594
2562
  if (!task) {
2595
- logger7.warn({ taskId }, "Task not found when fetching artifact");
2563
+ logger6.warn({ taskId }, "Task not found when fetching artifact");
2596
2564
  return null;
2597
2565
  }
2598
2566
  const artifacts = await getLedgerArtifacts(dbClient_default)({
@@ -2604,7 +2572,7 @@ var _ArtifactParser = class _ArtifactParser {
2604
2572
  return this.formatArtifactData(artifacts[0], artifactId, taskId);
2605
2573
  }
2606
2574
  } catch (error) {
2607
- logger7.warn({ artifactId, taskId, error }, "Failed to fetch artifact");
2575
+ logger6.warn({ artifactId, taskId, error }, "Failed to fetch artifact");
2608
2576
  }
2609
2577
  return null;
2610
2578
  }
@@ -2644,7 +2612,7 @@ __publicField(_ArtifactParser, "INCOMPLETE_ARTIFACT_REGEX", /<(a(r(t(i(f(a(c(t(:
2644
2612
  var ArtifactParser = _ArtifactParser;
2645
2613
 
2646
2614
  // src/utils/incremental-stream-parser.ts
2647
- var logger8 = getLogger("IncrementalStreamParser");
2615
+ var logger7 = getLogger("IncrementalStreamParser");
2648
2616
  var IncrementalStreamParser = class {
2649
2617
  constructor(streamHelper, tenantId, contextId) {
2650
2618
  __publicField(this, "buffer", "");
@@ -2704,13 +2672,13 @@ var IncrementalStreamParser = class {
2704
2672
  if (part.type === "tool-call-delta" && part.toolName === targetToolName) {
2705
2673
  const delta = part.argsTextDelta || "";
2706
2674
  if (jsonBuffer.length + delta.length > MAX_BUFFER_SIZE) {
2707
- logger8.warn("JSON buffer exceeded maximum size, truncating");
2675
+ logger7.warn("JSON buffer exceeded maximum size, truncating");
2708
2676
  jsonBuffer = jsonBuffer.slice(-MAX_BUFFER_SIZE / 2);
2709
2677
  }
2710
2678
  jsonBuffer += delta;
2711
2679
  for (const char of delta) {
2712
2680
  if (componentBuffer.length > MAX_BUFFER_SIZE) {
2713
- logger8.warn("Component buffer exceeded maximum size, resetting");
2681
+ logger7.warn("Component buffer exceeded maximum size, resetting");
2714
2682
  componentBuffer = "";
2715
2683
  depth = 0;
2716
2684
  continue;
@@ -2725,7 +2693,7 @@ var IncrementalStreamParser = class {
2725
2693
  if (componentMatch) {
2726
2694
  const MAX_COMPONENT_SIZE = 1024 * 1024;
2727
2695
  if (componentMatch[0].length > MAX_COMPONENT_SIZE) {
2728
- logger8.warn(
2696
+ logger7.warn(
2729
2697
  {
2730
2698
  size: componentMatch[0].length,
2731
2699
  maxSize: MAX_COMPONENT_SIZE
@@ -2738,7 +2706,7 @@ var IncrementalStreamParser = class {
2738
2706
  try {
2739
2707
  const component = JSON.parse(componentMatch[0]);
2740
2708
  if (typeof component !== "object" || !component.id) {
2741
- logger8.warn("Invalid component structure, skipping");
2709
+ logger7.warn("Invalid component structure, skipping");
2742
2710
  componentBuffer = "";
2743
2711
  continue;
2744
2712
  }
@@ -2751,7 +2719,7 @@ var IncrementalStreamParser = class {
2751
2719
  componentsStreamed++;
2752
2720
  componentBuffer = "";
2753
2721
  } catch (e) {
2754
- logger8.debug({ error: e }, "Failed to parse component, continuing to accumulate");
2722
+ logger7.debug({ error: e }, "Failed to parse component, continuing to accumulate");
2755
2723
  }
2756
2724
  }
2757
2725
  }
@@ -2768,7 +2736,7 @@ var IncrementalStreamParser = class {
2768
2736
  break;
2769
2737
  }
2770
2738
  }
2771
- logger8.debug({ componentsStreamed }, "Finished streaming components");
2739
+ logger7.debug({ componentsStreamed }, "Finished streaming components");
2772
2740
  }
2773
2741
  /**
2774
2742
  * Legacy method for backward compatibility - defaults to text processing
@@ -2912,7 +2880,7 @@ var IncrementalStreamParser = class {
2912
2880
  };
2913
2881
 
2914
2882
  // src/utils/response-formatter.ts
2915
- var logger9 = getLogger("ResponseFormatter");
2883
+ var logger8 = getLogger("ResponseFormatter");
2916
2884
  var ResponseFormatter = class {
2917
2885
  constructor(tenantId) {
2918
2886
  __publicField(this, "artifactParser");
@@ -2943,7 +2911,7 @@ var ResponseFormatter = class {
2943
2911
  return { parts };
2944
2912
  } catch (error) {
2945
2913
  setSpanWithError(span, error);
2946
- logger9.error({ error, responseObject }, "Error formatting object response");
2914
+ logger8.error({ error, responseObject }, "Error formatting object response");
2947
2915
  return {
2948
2916
  parts: [{ kind: "data", data: responseObject }]
2949
2917
  };
@@ -2994,7 +2962,7 @@ var ResponseFormatter = class {
2994
2962
  return { parts };
2995
2963
  } catch (error) {
2996
2964
  setSpanWithError(span, error);
2997
- logger9.error({ error, responseText }, "Error formatting response");
2965
+ logger8.error({ error, responseText }, "Error formatting response");
2998
2966
  return { text: responseText };
2999
2967
  } finally {
3000
2968
  span.end();
@@ -3039,7 +3007,7 @@ var ResponseFormatter = class {
3039
3007
  }
3040
3008
  }
3041
3009
  };
3042
- var logger10 = getLogger("ToolSessionManager");
3010
+ var logger9 = getLogger("ToolSessionManager");
3043
3011
  var _ToolSessionManager = class _ToolSessionManager {
3044
3012
  // 5 minutes
3045
3013
  constructor() {
@@ -3068,7 +3036,7 @@ var _ToolSessionManager = class _ToolSessionManager {
3068
3036
  createdAt: Date.now()
3069
3037
  };
3070
3038
  this.sessions.set(sessionId, session);
3071
- logger10.debug({ sessionId, tenantId, contextId, taskId }, "Created tool session");
3039
+ logger9.debug({ sessionId, tenantId, contextId, taskId }, "Created tool session");
3072
3040
  return sessionId;
3073
3041
  }
3074
3042
  /**
@@ -3077,7 +3045,7 @@ var _ToolSessionManager = class _ToolSessionManager {
3077
3045
  recordToolResult(sessionId, toolResult) {
3078
3046
  const session = this.sessions.get(sessionId);
3079
3047
  if (!session) {
3080
- logger10.warn(
3048
+ logger9.warn(
3081
3049
  { sessionId, toolCallId: toolResult.toolCallId },
3082
3050
  "Tool result recorded for unknown session"
3083
3051
  );
@@ -3091,12 +3059,12 @@ var _ToolSessionManager = class _ToolSessionManager {
3091
3059
  getToolResult(sessionId, toolCallId) {
3092
3060
  const session = this.sessions.get(sessionId);
3093
3061
  if (!session) {
3094
- logger10.warn({ sessionId, toolCallId }, "Requested tool result for unknown session");
3062
+ logger9.warn({ sessionId, toolCallId }, "Requested tool result for unknown session");
3095
3063
  return void 0;
3096
3064
  }
3097
3065
  const result = session.toolResults.get(toolCallId);
3098
3066
  if (!result) {
3099
- logger10.warn(
3067
+ logger9.warn(
3100
3068
  {
3101
3069
  sessionId,
3102
3070
  toolCallId,
@@ -3135,10 +3103,10 @@ var _ToolSessionManager = class _ToolSessionManager {
3135
3103
  }
3136
3104
  for (const sessionId of expiredSessions) {
3137
3105
  this.sessions.delete(sessionId);
3138
- logger10.debug({ sessionId }, "Cleaned up expired tool session");
3106
+ logger9.debug({ sessionId }, "Cleaned up expired tool session");
3139
3107
  }
3140
3108
  if (expiredSessions.length > 0) {
3141
- logger10.info({ expiredCount: expiredSessions.length }, "Cleaned up expired tool sessions");
3109
+ logger9.info({ expiredCount: expiredSessions.length }, "Cleaned up expired tool sessions");
3142
3110
  }
3143
3111
  }
3144
3112
  };
@@ -3147,7 +3115,7 @@ var ToolSessionManager = _ToolSessionManager;
3147
3115
  var toolSessionManager = ToolSessionManager.getInstance();
3148
3116
 
3149
3117
  // src/agents/artifactTools.ts
3150
- var logger11 = getLogger("artifactTools");
3118
+ var logger10 = getLogger("artifactTools");
3151
3119
  function buildKeyNestingMap(data, prefix = "", map = /* @__PURE__ */ new Map()) {
3152
3120
  if (typeof data === "object" && data !== null) {
3153
3121
  if (Array.isArray(data)) {
@@ -3368,7 +3336,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
3368
3336
  execute: async ({ toolCallId, baseSelector, propSelectors, ...rest }, _context) => {
3369
3337
  const artifactType = "artifactType" in rest ? rest.artifactType : void 0;
3370
3338
  if (!sessionId) {
3371
- logger11.warn({ toolCallId }, "No session ID provided to save_tool_result");
3339
+ logger10.warn({ toolCallId }, "No session ID provided to save_tool_result");
3372
3340
  return {
3373
3341
  saved: false,
3374
3342
  error: `[toolCallId: ${toolCallId}] No session context available`,
@@ -3378,7 +3346,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
3378
3346
  }
3379
3347
  const toolResult = toolSessionManager.getToolResult(sessionId, toolCallId);
3380
3348
  if (!toolResult) {
3381
- logger11.warn({ toolCallId, sessionId }, "Tool result not found in session");
3349
+ logger10.warn({ toolCallId, sessionId }, "Tool result not found in session");
3382
3350
  return {
3383
3351
  saved: false,
3384
3352
  error: `[toolCallId: ${toolCallId}] Tool result not found`,
@@ -3391,7 +3359,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
3391
3359
  const baseData = jmespath.search(parsedResult, baseSelector);
3392
3360
  if (!baseData || Array.isArray(baseData) && baseData.length === 0) {
3393
3361
  const debugInfo = analyzeSelectorFailure(parsedResult, baseSelector);
3394
- logger11.warn(
3362
+ logger10.warn(
3395
3363
  {
3396
3364
  baseSelector,
3397
3365
  toolCallId,
@@ -3434,7 +3402,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
3434
3402
  const fallbackValue = item[propName];
3435
3403
  if (fallbackValue !== null && fallbackValue !== void 0) {
3436
3404
  extractedItem[propName] = fallbackValue;
3437
- logger11.info(
3405
+ logger10.info(
3438
3406
  { propName, propSelector, context },
3439
3407
  `PropSelector failed, used fallback direct property access`
3440
3408
  );
@@ -3446,7 +3414,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
3446
3414
  const fallbackValue = item[propName];
3447
3415
  if (fallbackValue !== null && fallbackValue !== void 0) {
3448
3416
  extractedItem[propName] = fallbackValue;
3449
- logger11.warn(
3417
+ logger10.warn(
3450
3418
  { propName, propSelector, context, error: error.message },
3451
3419
  `PropSelector syntax error, used fallback direct property access`
3452
3420
  );
@@ -3559,7 +3527,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
3559
3527
  warnings
3560
3528
  };
3561
3529
  } catch (error) {
3562
- logger11.error({ error, toolCallId, sessionId }, "Error processing save_tool_result");
3530
+ logger10.error({ error, toolCallId, sessionId }, "Error processing save_tool_result");
3563
3531
  return {
3564
3532
  saved: false,
3565
3533
  error: `[toolCallId: ${toolCallId}] ${error instanceof Error ? error.message : "Unknown error"}`,
@@ -3571,7 +3539,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
3571
3539
  }
3572
3540
 
3573
3541
  // src/a2a/client.ts
3574
- var logger12 = getLogger("a2aClient");
3542
+ var logger11 = getLogger("a2aClient");
3575
3543
  var DEFAULT_BACKOFF = {
3576
3544
  initialInterval: 500,
3577
3545
  maxInterval: 6e4,
@@ -3777,7 +3745,7 @@ var A2AClient = class {
3777
3745
  try {
3778
3746
  const res = await fn();
3779
3747
  if (attempt > 0) {
3780
- logger12.info(
3748
+ logger11.info(
3781
3749
  {
3782
3750
  attempts: attempt + 1,
3783
3751
  elapsedTime: Date.now() - start
@@ -3792,7 +3760,7 @@ var A2AClient = class {
3792
3760
  }
3793
3761
  const elapsed = Date.now() - start;
3794
3762
  if (elapsed > maxElapsedTime) {
3795
- logger12.warn(
3763
+ logger11.warn(
3796
3764
  {
3797
3765
  attempts: attempt + 1,
3798
3766
  elapsedTime: elapsed,
@@ -3813,7 +3781,7 @@ var A2AClient = class {
3813
3781
  retryInterval = initialInterval * attempt ** exponent + Math.random() * 1e3;
3814
3782
  }
3815
3783
  const delayMs = Math.min(retryInterval, maxInterval);
3816
- logger12.info(
3784
+ logger11.info(
3817
3785
  {
3818
3786
  attempt: attempt + 1,
3819
3787
  delayMs,
@@ -3898,7 +3866,7 @@ var A2AClient = class {
3898
3866
  }
3899
3867
  const rpcResponse = await httpResponse.json();
3900
3868
  if (rpcResponse.id !== requestId2) {
3901
- logger12.warn(
3869
+ logger11.warn(
3902
3870
  {
3903
3871
  method,
3904
3872
  expectedId: requestId2,
@@ -4097,7 +4065,7 @@ var A2AClient = class {
4097
4065
  try {
4098
4066
  while (true) {
4099
4067
  const { done, value } = await reader.read();
4100
- logger12.info({ done, value }, "parseA2ASseStream");
4068
+ logger11.info({ done, value }, "parseA2ASseStream");
4101
4069
  if (done) {
4102
4070
  if (eventDataBuffer.trim()) {
4103
4071
  const result = this._processSseEventData(
@@ -4184,7 +4152,7 @@ var A2AClient = class {
4184
4152
  };
4185
4153
 
4186
4154
  // src/agents/relationTools.ts
4187
- var logger13 = getLogger("relationships Tools");
4155
+ var logger12 = getLogger("relationships Tools");
4188
4156
  var generateTransferToolDescription = (config) => {
4189
4157
  return `Hand off the conversation to agent ${config.id}.
4190
4158
 
@@ -4222,7 +4190,7 @@ var createTransferToAgentTool = ({
4222
4190
  "transfer.to_agent_id": transferConfig.id ?? "unknown"
4223
4191
  });
4224
4192
  }
4225
- logger13.info(
4193
+ logger12.info(
4226
4194
  {
4227
4195
  transferTo: transferConfig.id ?? "unknown",
4228
4196
  fromAgent: callingAgentId
@@ -4370,7 +4338,7 @@ function createDelegateToAgentTool({
4370
4338
  ...isInternal ? { fromAgentId: callingAgentId } : { fromExternalAgentId: callingAgentId }
4371
4339
  }
4372
4340
  };
4373
- logger13.info({ messageToSend }, "messageToSend");
4341
+ logger12.info({ messageToSend }, "messageToSend");
4374
4342
  await createMessage(dbClient_default)({
4375
4343
  id: nanoid(),
4376
4344
  tenantId,
@@ -4432,7 +4400,7 @@ function createDelegateToAgentTool({
4432
4400
  }
4433
4401
 
4434
4402
  // src/agents/SystemPromptBuilder.ts
4435
- var logger14 = getLogger("SystemPromptBuilder");
4403
+ var logger13 = getLogger("SystemPromptBuilder");
4436
4404
  var SystemPromptBuilder = class {
4437
4405
  constructor(version, versionConfig) {
4438
4406
  this.version = version;
@@ -4448,9 +4416,9 @@ var SystemPromptBuilder = class {
4448
4416
  this.templates.set(name, content);
4449
4417
  }
4450
4418
  this.loaded = true;
4451
- logger14.debug(`Loaded ${this.templates.size} templates for version ${this.version}`);
4419
+ logger13.debug(`Loaded ${this.templates.size} templates for version ${this.version}`);
4452
4420
  } catch (error) {
4453
- logger14.error({ error }, `Failed to load templates for version ${this.version}`);
4421
+ logger13.error({ error }, `Failed to load templates for version ${this.version}`);
4454
4422
  throw new Error(`Template loading failed: ${error}`);
4455
4423
  }
4456
4424
  }
@@ -4852,7 +4820,7 @@ function hasToolCallWithPrefix(prefix) {
4852
4820
  return false;
4853
4821
  };
4854
4822
  }
4855
- var logger15 = getLogger("Agent");
4823
+ var logger14 = getLogger("Agent");
4856
4824
  var CONSTANTS = {
4857
4825
  MAX_GENERATION_STEPS: 12,
4858
4826
  PHASE_1_TIMEOUT_MS: 27e4,
@@ -5105,14 +5073,14 @@ var Agent = class {
5105
5073
  for (const toolSet of tools) {
5106
5074
  for (const [toolName, originalTool] of Object.entries(toolSet)) {
5107
5075
  if (!isValidTool(originalTool)) {
5108
- logger15.error({ toolName }, "Invalid MCP tool structure - missing required properties");
5076
+ logger14.error({ toolName }, "Invalid MCP tool structure - missing required properties");
5109
5077
  continue;
5110
5078
  }
5111
5079
  const sessionWrappedTool = tool({
5112
5080
  description: originalTool.description,
5113
5081
  inputSchema: originalTool.inputSchema,
5114
5082
  execute: async (args, { toolCallId }) => {
5115
- logger15.debug({ toolName, toolCallId }, "MCP Tool Called");
5083
+ logger14.debug({ toolName, toolCallId }, "MCP Tool Called");
5116
5084
  try {
5117
5085
  const result = await originalTool.execute(args, { toolCallId });
5118
5086
  toolSessionManager.recordToolResult(sessionId, {
@@ -5124,7 +5092,7 @@ var Agent = class {
5124
5092
  });
5125
5093
  return { result, toolCallId };
5126
5094
  } catch (error) {
5127
- logger15.error({ toolName, toolCallId, error }, "MCP tool execution failed");
5095
+ logger14.error({ toolName, toolCallId, error }, "MCP tool execution failed");
5128
5096
  throw error;
5129
5097
  }
5130
5098
  }
@@ -5209,7 +5177,7 @@ var Agent = class {
5209
5177
  selectedTools
5210
5178
  };
5211
5179
  }
5212
- logger15.info(
5180
+ logger14.info(
5213
5181
  {
5214
5182
  toolName: tool4.name,
5215
5183
  credentialReferenceId,
@@ -5249,7 +5217,7 @@ var Agent = class {
5249
5217
  async getResolvedContext(conversationId, requestContext) {
5250
5218
  try {
5251
5219
  if (!this.config.contextConfigId) {
5252
- logger15.debug({ graphId: this.config.graphId }, "No context config found for graph");
5220
+ logger14.debug({ graphId: this.config.graphId }, "No context config found for graph");
5253
5221
  return null;
5254
5222
  }
5255
5223
  const contextConfig = await getContextConfigById(dbClient_default)({
@@ -5257,7 +5225,7 @@ var Agent = class {
5257
5225
  id: this.config.contextConfigId
5258
5226
  });
5259
5227
  if (!contextConfig) {
5260
- logger15.warn({ contextConfigId: this.config.contextConfigId }, "Context config not found");
5228
+ logger14.warn({ contextConfigId: this.config.contextConfigId }, "Context config not found");
5261
5229
  return null;
5262
5230
  }
5263
5231
  if (!this.contextResolver) {
@@ -5274,7 +5242,7 @@ var Agent = class {
5274
5242
  $now: (/* @__PURE__ */ new Date()).toISOString(),
5275
5243
  $env: process.env
5276
5244
  };
5277
- logger15.debug(
5245
+ logger14.debug(
5278
5246
  {
5279
5247
  conversationId,
5280
5248
  contextConfigId: contextConfig.id,
@@ -5288,7 +5256,7 @@ var Agent = class {
5288
5256
  );
5289
5257
  return contextWithBuiltins;
5290
5258
  } catch (error) {
5291
- logger15.error(
5259
+ logger14.error(
5292
5260
  {
5293
5261
  conversationId,
5294
5262
  error: error instanceof Error ? error.message : "Unknown error"
@@ -5312,7 +5280,7 @@ var Agent = class {
5312
5280
  });
5313
5281
  return graphDefinition?.graphPrompt || void 0;
5314
5282
  } catch (error) {
5315
- logger15.warn(
5283
+ logger14.warn(
5316
5284
  {
5317
5285
  graphId: this.config.graphId,
5318
5286
  error: error instanceof Error ? error.message : "Unknown error"
@@ -5339,7 +5307,7 @@ var Agent = class {
5339
5307
  }
5340
5308
  return !!(graphDefinition.artifactComponents && Object.keys(graphDefinition.artifactComponents).length > 0);
5341
5309
  } catch (error) {
5342
- logger15.warn(
5310
+ logger14.warn(
5343
5311
  {
5344
5312
  graphId: this.config.graphId,
5345
5313
  tenantId: this.config.tenantId,
@@ -5399,7 +5367,7 @@ Key requirements:
5399
5367
  preserveUnresolved: false
5400
5368
  });
5401
5369
  } catch (error) {
5402
- logger15.error(
5370
+ logger14.error(
5403
5371
  {
5404
5372
  conversationId,
5405
5373
  error: error instanceof Error ? error.message : "Unknown error"
@@ -5444,7 +5412,7 @@ Key requirements:
5444
5412
  preserveUnresolved: false
5445
5413
  });
5446
5414
  } catch (error) {
5447
- logger15.error(
5415
+ logger14.error(
5448
5416
  {
5449
5417
  conversationId,
5450
5418
  error: error instanceof Error ? error.message : "Unknown error"
@@ -5472,7 +5440,7 @@ Key requirements:
5472
5440
  artifactId: z.string().describe("The unique identifier of the artifact to get.")
5473
5441
  }),
5474
5442
  execute: async ({ artifactId }) => {
5475
- logger15.info({ artifactId }, "get_artifact executed");
5443
+ logger14.info({ artifactId }, "get_artifact executed");
5476
5444
  const artifact = await getLedgerArtifacts(dbClient_default)({
5477
5445
  scopes: {
5478
5446
  tenantId: this.config.tenantId,
@@ -5539,7 +5507,7 @@ Key requirements:
5539
5507
  graphId: this.config.graphId
5540
5508
  });
5541
5509
  } catch (error) {
5542
- logger15.error(
5510
+ logger14.error(
5543
5511
  { error, graphId: this.config.graphId },
5544
5512
  "Failed to check graph artifact components"
5545
5513
  );
@@ -5643,7 +5611,7 @@ Key requirements:
5643
5611
  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;
5644
5612
  const timeoutMs = Math.min(configuredTimeout, MAX_ALLOWED_TIMEOUT_MS);
5645
5613
  if (modelSettings.maxDuration && modelSettings.maxDuration * 1e3 > MAX_ALLOWED_TIMEOUT_MS) {
5646
- logger15.warn(
5614
+ logger14.warn(
5647
5615
  {
5648
5616
  requestedTimeout: modelSettings.maxDuration * 1e3,
5649
5617
  appliedTimeout: timeoutMs,
@@ -5685,7 +5653,7 @@ Key requirements:
5685
5653
  }
5686
5654
  );
5687
5655
  } catch (error) {
5688
- logger15.debug("Failed to track agent reasoning");
5656
+ logger14.debug("Failed to track agent reasoning");
5689
5657
  }
5690
5658
  }
5691
5659
  if (last && "toolCalls" in last && last.toolCalls) {
@@ -5768,7 +5736,7 @@ Key requirements:
5768
5736
  }
5769
5737
  );
5770
5738
  } catch (error) {
5771
- logger15.debug("Failed to track agent reasoning");
5739
+ logger14.debug("Failed to track agent reasoning");
5772
5740
  }
5773
5741
  }
5774
5742
  if (last && "toolCalls" in last && last.toolCalls) {
@@ -5813,7 +5781,7 @@ Key requirements:
5813
5781
  return;
5814
5782
  }
5815
5783
  if (toolName === "save_artifact_tool" || toolName === "save_tool_result") {
5816
- logger15.info({ result }, "save_artifact_tool or save_tool_result");
5784
+ logger14.info({ result }, "save_artifact_tool or save_tool_result");
5817
5785
  if (result.output.artifacts) {
5818
5786
  for (const artifact of result.output.artifacts) {
5819
5787
  const artifactId = artifact?.artifactId || "N/A";
@@ -5998,7 +5966,7 @@ function parseEmbeddedJson(data) {
5998
5966
  }
5999
5967
  });
6000
5968
  }
6001
- var logger16 = getLogger("generateTaskHandler");
5969
+ var logger15 = getLogger("generateTaskHandler");
6002
5970
  var createTaskHandler = (config, credentialStoreRegistry) => {
6003
5971
  return async (task) => {
6004
5972
  try {
@@ -6048,7 +6016,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
6048
6016
  agentId: config.agentId
6049
6017
  })
6050
6018
  ]);
6051
- logger16.info({ toolsForAgent, internalRelations, externalRelations }, "agent stuff");
6019
+ logger15.info({ toolsForAgent, internalRelations, externalRelations }, "agent stuff");
6052
6020
  const agentPrompt = "prompt" in config.agentSchema ? config.agentSchema.prompt : "";
6053
6021
  const models = "models" in config.agentSchema ? config.agentSchema.models : void 0;
6054
6022
  const stopWhen = "stopWhen" in config.agentSchema ? config.agentSchema.stopWhen : void 0;
@@ -6148,7 +6116,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
6148
6116
  const taskIdMatch = task.id.match(/^task_([^-]+-[^-]+-\d+)-/);
6149
6117
  if (taskIdMatch) {
6150
6118
  contextId = taskIdMatch[1];
6151
- logger16.info(
6119
+ logger15.info(
6152
6120
  {
6153
6121
  taskId: task.id,
6154
6122
  extractedContextId: contextId,
@@ -6164,7 +6132,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
6164
6132
  const isDelegation = task.context?.metadata?.isDelegation === true;
6165
6133
  agent.setDelegationStatus(isDelegation);
6166
6134
  if (isDelegation) {
6167
- logger16.info(
6135
+ logger15.info(
6168
6136
  { agentId: config.agentId, taskId: task.id },
6169
6137
  "Delegated agent - streaming disabled"
6170
6138
  );
@@ -6368,7 +6336,7 @@ async function getRegisteredGraph(executionContext) {
6368
6336
  const agentFrameworkBaseUrl = `${baseUrl}/agents`;
6369
6337
  return hydrateGraph({ dbGraph, baseUrl: agentFrameworkBaseUrl, apiKey });
6370
6338
  }
6371
- getLogger$1("agents");
6339
+ getLogger("agents");
6372
6340
  async function hydrateAgent({
6373
6341
  dbAgent,
6374
6342
  graphId,
@@ -6444,7 +6412,7 @@ async function getRegisteredAgent(executionContext, credentialStoreRegistry) {
6444
6412
 
6445
6413
  // src/routes/agents.ts
6446
6414
  var app = new OpenAPIHono();
6447
- var logger17 = getLogger("agents");
6415
+ var logger16 = getLogger("agents");
6448
6416
  app.openapi(
6449
6417
  createRoute({
6450
6418
  method: "get",
@@ -6482,7 +6450,7 @@ app.openapi(
6482
6450
  tracestate: c.req.header("tracestate"),
6483
6451
  baggage: c.req.header("baggage")
6484
6452
  };
6485
- logger17.info(
6453
+ logger16.info(
6486
6454
  {
6487
6455
  otelHeaders,
6488
6456
  path: c.req.path,
@@ -6493,7 +6461,7 @@ app.openapi(
6493
6461
  const executionContext = getRequestExecutionContext(c);
6494
6462
  const { tenantId, projectId, graphId, agentId } = executionContext;
6495
6463
  if (agentId) {
6496
- logger17.info(
6464
+ logger16.info(
6497
6465
  {
6498
6466
  message: "getRegisteredAgent (agent-level)",
6499
6467
  tenantId,
@@ -6505,13 +6473,13 @@ app.openapi(
6505
6473
  );
6506
6474
  const credentialStores = c.get("credentialStores");
6507
6475
  const agent = await getRegisteredAgent(executionContext, credentialStores);
6508
- logger17.info({ agent }, "agent registered: well-known agent.json");
6476
+ logger16.info({ agent }, "agent registered: well-known agent.json");
6509
6477
  if (!agent) {
6510
6478
  return c.json({ error: "Agent not found" }, 404);
6511
6479
  }
6512
6480
  return c.json(agent.agentCard);
6513
6481
  } else {
6514
- logger17.info(
6482
+ logger16.info(
6515
6483
  {
6516
6484
  message: "getRegisteredGraph (graph-level)",
6517
6485
  tenantId,
@@ -6534,7 +6502,7 @@ app.post("/a2a", async (c) => {
6534
6502
  tracestate: c.req.header("tracestate"),
6535
6503
  baggage: c.req.header("baggage")
6536
6504
  };
6537
- logger17.info(
6505
+ logger16.info(
6538
6506
  {
6539
6507
  otelHeaders,
6540
6508
  path: c.req.path,
@@ -6545,7 +6513,7 @@ app.post("/a2a", async (c) => {
6545
6513
  const executionContext = getRequestExecutionContext(c);
6546
6514
  const { tenantId, projectId, graphId, agentId } = executionContext;
6547
6515
  if (agentId) {
6548
- logger17.info(
6516
+ logger16.info(
6549
6517
  {
6550
6518
  message: "a2a (agent-level)",
6551
6519
  tenantId,
@@ -6569,7 +6537,7 @@ app.post("/a2a", async (c) => {
6569
6537
  }
6570
6538
  return a2aHandler(c, agent);
6571
6539
  } else {
6572
- logger17.info(
6540
+ logger16.info(
6573
6541
  {
6574
6542
  message: "a2a (graph-level)",
6575
6543
  tenantId,
@@ -6609,14 +6577,14 @@ app.post("/a2a", async (c) => {
6609
6577
  }
6610
6578
  });
6611
6579
  var agents_default = app;
6612
- var logger18 = getLogger("Transfer");
6580
+ var logger17 = getLogger("Transfer");
6613
6581
  async function executeTransfer({
6614
6582
  tenantId,
6615
6583
  threadId,
6616
6584
  projectId,
6617
6585
  targetAgentId
6618
6586
  }) {
6619
- logger18.info({ targetAgent: targetAgentId }, "Executing transfer to agent");
6587
+ logger17.info({ targetAgent: targetAgentId }, "Executing transfer to agent");
6620
6588
  await setActiveAgentForThread(dbClient_default)({
6621
6589
  scopes: { tenantId, projectId },
6622
6590
  threadId,
@@ -7157,7 +7125,7 @@ var MCPStreamHelper = class {
7157
7125
  function createMCPStreamHelper() {
7158
7126
  return new MCPStreamHelper();
7159
7127
  }
7160
- var logger19 = getLogger("ExecutionHandler");
7128
+ var logger18 = getLogger("ExecutionHandler");
7161
7129
  var ExecutionHandler = class {
7162
7130
  constructor() {
7163
7131
  // Hardcoded error limit - separate from configurable stopWhen
@@ -7182,7 +7150,7 @@ var ExecutionHandler = class {
7182
7150
  const { tenantId, projectId, graphId, apiKey, baseUrl } = executionContext;
7183
7151
  registerStreamHelper(requestId2, sseHelper);
7184
7152
  graphSessionManager.createSession(requestId2, graphId, tenantId, projectId);
7185
- logger19.info({ sessionId: requestId2, graphId }, "Created GraphSession for message execution");
7153
+ logger18.info({ sessionId: requestId2, graphId }, "Created GraphSession for message execution");
7186
7154
  let graphConfig = null;
7187
7155
  try {
7188
7156
  graphConfig = await getFullGraph(dbClient_default)({ scopes: { tenantId, projectId }, graphId });
@@ -7194,7 +7162,7 @@ var ExecutionHandler = class {
7194
7162
  );
7195
7163
  }
7196
7164
  } catch (error) {
7197
- logger19.error(
7165
+ logger18.error(
7198
7166
  {
7199
7167
  error: error instanceof Error ? error.message : "Unknown error",
7200
7168
  stack: error instanceof Error ? error.stack : void 0
@@ -7210,7 +7178,7 @@ var ExecutionHandler = class {
7210
7178
  try {
7211
7179
  await sseHelper.writeOperation(agentInitializingOp(requestId2, graphId));
7212
7180
  const taskId = `task_${conversationId}-${requestId2}`;
7213
- logger19.info(
7181
+ logger18.info(
7214
7182
  { taskId, currentAgentId, conversationId, requestId: requestId2 },
7215
7183
  "Attempting to create or reuse existing task"
7216
7184
  );
@@ -7233,7 +7201,7 @@ var ExecutionHandler = class {
7233
7201
  agent_id: currentAgentId
7234
7202
  }
7235
7203
  });
7236
- logger19.info(
7204
+ logger18.info(
7237
7205
  {
7238
7206
  taskId,
7239
7207
  createdTaskMetadata: Array.isArray(task) ? task[0]?.metadata : task?.metadata
@@ -7242,27 +7210,27 @@ var ExecutionHandler = class {
7242
7210
  );
7243
7211
  } catch (error) {
7244
7212
  if (error?.message?.includes("UNIQUE constraint failed") || error?.message?.includes("PRIMARY KEY constraint failed") || error?.code === "SQLITE_CONSTRAINT_PRIMARYKEY") {
7245
- logger19.info(
7213
+ logger18.info(
7246
7214
  { taskId, error: error.message },
7247
7215
  "Task already exists, fetching existing task"
7248
7216
  );
7249
7217
  const existingTask = await getTask(dbClient_default)({ id: taskId });
7250
7218
  if (existingTask) {
7251
7219
  task = existingTask;
7252
- logger19.info(
7220
+ logger18.info(
7253
7221
  { taskId, existingTask },
7254
7222
  "Successfully reused existing task from race condition"
7255
7223
  );
7256
7224
  } else {
7257
- logger19.error({ taskId, error }, "Task constraint failed but task not found");
7225
+ logger18.error({ taskId, error }, "Task constraint failed but task not found");
7258
7226
  throw error;
7259
7227
  }
7260
7228
  } else {
7261
- logger19.error({ taskId, error }, "Failed to create task due to non-constraint error");
7229
+ logger18.error({ taskId, error }, "Failed to create task due to non-constraint error");
7262
7230
  throw error;
7263
7231
  }
7264
7232
  }
7265
- logger19.debug(
7233
+ logger18.debug(
7266
7234
  {
7267
7235
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
7268
7236
  executionType: "create_initial_task",
@@ -7280,7 +7248,7 @@ var ExecutionHandler = class {
7280
7248
  const maxTransfers = graphConfig?.stopWhen?.transferCountIs ?? 10;
7281
7249
  while (iterations < maxTransfers) {
7282
7250
  iterations++;
7283
- logger19.info(
7251
+ logger18.info(
7284
7252
  { iterations, currentAgentId, graphId, conversationId, fromAgentId },
7285
7253
  `Execution loop iteration ${iterations} with agent ${currentAgentId}, transfer from: ${fromAgentId || "none"}`
7286
7254
  );
@@ -7288,10 +7256,10 @@ var ExecutionHandler = class {
7288
7256
  scopes: { tenantId, projectId },
7289
7257
  conversationId
7290
7258
  });
7291
- logger19.info({ activeAgent }, "activeAgent");
7259
+ logger18.info({ activeAgent }, "activeAgent");
7292
7260
  if (activeAgent && activeAgent.activeAgentId !== currentAgentId) {
7293
7261
  currentAgentId = activeAgent.activeAgentId;
7294
- logger19.info({ currentAgentId }, `Updated current agent to: ${currentAgentId}`);
7262
+ logger18.info({ currentAgentId }, `Updated current agent to: ${currentAgentId}`);
7295
7263
  }
7296
7264
  const agentBaseUrl = `${baseUrl}/agents`;
7297
7265
  const a2aClient = new A2AClient(agentBaseUrl, {
@@ -7332,13 +7300,13 @@ var ExecutionHandler = class {
7332
7300
  });
7333
7301
  if (!messageResponse?.result) {
7334
7302
  errorCount++;
7335
- logger19.error(
7303
+ logger18.error(
7336
7304
  { currentAgentId, iterations, errorCount },
7337
7305
  `No response from agent ${currentAgentId} on iteration ${iterations} (error ${errorCount}/${this.MAX_ERRORS})`
7338
7306
  );
7339
7307
  if (errorCount >= this.MAX_ERRORS) {
7340
7308
  const errorMessage2 = `Maximum error limit (${this.MAX_ERRORS}) reached`;
7341
- logger19.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
7309
+ logger18.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
7342
7310
  await sseHelper.writeError(errorMessage2);
7343
7311
  await sseHelper.writeOperation(errorOp(errorMessage2, currentAgentId || "system"));
7344
7312
  if (task) {
@@ -7364,7 +7332,7 @@ var ExecutionHandler = class {
7364
7332
  const transferResponse = messageResponse.result;
7365
7333
  const targetAgentId = transferResponse.artifacts?.[0]?.parts?.[0]?.data?.targetAgentId;
7366
7334
  const transferReason = transferResponse.artifacts?.[0]?.parts?.[1]?.text;
7367
- logger19.info({ targetAgentId, transferReason }, "transfer response");
7335
+ logger18.info({ targetAgentId, transferReason }, "transfer response");
7368
7336
  currentMessage = `<transfer_context> ${transferReason} </transfer_context>`;
7369
7337
  const { success, targetAgentId: newAgentId } = await executeTransfer({
7370
7338
  projectId,
@@ -7375,7 +7343,7 @@ var ExecutionHandler = class {
7375
7343
  if (success) {
7376
7344
  fromAgentId = currentAgentId;
7377
7345
  currentAgentId = newAgentId;
7378
- logger19.info(
7346
+ logger18.info(
7379
7347
  {
7380
7348
  transferFrom: fromAgentId,
7381
7349
  transferTo: currentAgentId,
@@ -7393,7 +7361,7 @@ var ExecutionHandler = class {
7393
7361
  const graphSessionData = graphSessionManager.getSession(requestId2);
7394
7362
  if (graphSessionData) {
7395
7363
  const sessionSummary = graphSessionData.getSummary();
7396
- logger19.info(sessionSummary, "GraphSession data after completion");
7364
+ logger18.info(sessionSummary, "GraphSession data after completion");
7397
7365
  }
7398
7366
  let textContent = "";
7399
7367
  for (const part of responseParts) {
@@ -7448,32 +7416,32 @@ var ExecutionHandler = class {
7448
7416
  }
7449
7417
  });
7450
7418
  const updateTaskEnd = Date.now();
7451
- logger19.info(
7419
+ logger18.info(
7452
7420
  { duration: updateTaskEnd - updateTaskStart },
7453
7421
  "Completed updateTask operation"
7454
7422
  );
7455
7423
  await sseHelper.writeOperation(completionOp(currentAgentId, iterations));
7456
7424
  await sseHelper.complete();
7457
- logger19.info("Ending GraphSession and cleaning up");
7425
+ logger18.info({}, "Ending GraphSession and cleaning up");
7458
7426
  graphSessionManager.endSession(requestId2);
7459
- logger19.info("Cleaning up streamHelper");
7427
+ logger18.info({}, "Cleaning up streamHelper");
7460
7428
  unregisterStreamHelper(requestId2);
7461
7429
  let response;
7462
7430
  if (sseHelper instanceof MCPStreamHelper) {
7463
7431
  const captured = sseHelper.getCapturedResponse();
7464
7432
  response = captured.text || "No response content";
7465
7433
  }
7466
- logger19.info("ExecutionHandler returning success");
7434
+ logger18.info({}, "ExecutionHandler returning success");
7467
7435
  return { success: true, iterations, response };
7468
7436
  }
7469
7437
  errorCount++;
7470
- logger19.warn(
7438
+ logger18.warn(
7471
7439
  { iterations, errorCount },
7472
7440
  `No valid response or transfer on iteration ${iterations} (error ${errorCount}/${this.MAX_ERRORS})`
7473
7441
  );
7474
7442
  if (errorCount >= this.MAX_ERRORS) {
7475
7443
  const errorMessage2 = `Maximum error limit (${this.MAX_ERRORS}) reached`;
7476
- logger19.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
7444
+ logger18.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
7477
7445
  await sseHelper.writeError(errorMessage2);
7478
7446
  await sseHelper.writeOperation(errorOp(errorMessage2, currentAgentId || "system"));
7479
7447
  if (task) {
@@ -7495,7 +7463,7 @@ var ExecutionHandler = class {
7495
7463
  }
7496
7464
  }
7497
7465
  const errorMessage = `Maximum transfer limit (${maxTransfers}) reached without completion`;
7498
- logger19.error({ maxTransfers, iterations }, errorMessage);
7466
+ logger18.error({ maxTransfers, iterations }, errorMessage);
7499
7467
  await sseHelper.writeError(errorMessage);
7500
7468
  await sseHelper.writeOperation(errorOp(errorMessage, currentAgentId || "system"));
7501
7469
  if (task) {
@@ -7515,7 +7483,7 @@ var ExecutionHandler = class {
7515
7483
  unregisterStreamHelper(requestId2);
7516
7484
  return { success: false, error: errorMessage, iterations };
7517
7485
  } catch (error) {
7518
- logger19.error({ error }, "Error in execution handler");
7486
+ logger18.error({ error }, "Error in execution handler");
7519
7487
  const errorMessage = error instanceof Error ? error.message : "Unknown execution error";
7520
7488
  await sseHelper.writeError(`Execution error: ${errorMessage}`);
7521
7489
  await sseHelper.writeOperation(errorOp(errorMessage, currentAgentId || "system"));
@@ -7541,7 +7509,7 @@ var ExecutionHandler = class {
7541
7509
 
7542
7510
  // src/routes/chat.ts
7543
7511
  var app2 = new OpenAPIHono();
7544
- var logger20 = getLogger("completionsHandler");
7512
+ var logger19 = getLogger("completionsHandler");
7545
7513
  var chatCompletionsRoute = createRoute({
7546
7514
  method: "post",
7547
7515
  path: "/completions",
@@ -7659,7 +7627,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
7659
7627
  tracestate: c.req.header("tracestate"),
7660
7628
  baggage: c.req.header("baggage")
7661
7629
  };
7662
- logger20.info(
7630
+ logger19.info(
7663
7631
  {
7664
7632
  otelHeaders,
7665
7633
  path: c.req.path,
@@ -7745,7 +7713,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
7745
7713
  dbClient_default,
7746
7714
  credentialStores
7747
7715
  );
7748
- logger20.info(
7716
+ logger19.info(
7749
7717
  {
7750
7718
  tenantId,
7751
7719
  graphId,
@@ -7791,7 +7759,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
7791
7759
  return streamSSE(c, async (stream2) => {
7792
7760
  const sseHelper = createSSEStreamHelper(stream2, requestId2, timestamp);
7793
7761
  await sseHelper.writeRole();
7794
- logger20.info({ agentId }, "Starting execution");
7762
+ logger19.info({ agentId }, "Starting execution");
7795
7763
  const executionHandler = new ExecutionHandler();
7796
7764
  const result = await executionHandler.execute({
7797
7765
  executionContext,
@@ -7801,7 +7769,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
7801
7769
  requestId: requestId2,
7802
7770
  sseHelper
7803
7771
  });
7804
- logger20.info(
7772
+ logger19.info(
7805
7773
  { result },
7806
7774
  `Execution completed: ${result.success ? "success" : "failed"} after ${result.iterations} iterations`
7807
7775
  );
@@ -7834,7 +7802,7 @@ var getMessageText = (content) => {
7834
7802
  };
7835
7803
  var chat_default = app2;
7836
7804
  var app3 = new OpenAPIHono();
7837
- var logger21 = getLogger("chatDataStream");
7805
+ var logger20 = getLogger("chatDataStream");
7838
7806
  var chatDataStreamRoute = createRoute({
7839
7807
  method: "post",
7840
7808
  path: "/chat",
@@ -7939,7 +7907,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
7939
7907
  );
7940
7908
  const lastUserMessage = body.messages.filter((m) => m.role === "user").slice(-1)[0];
7941
7909
  const userText = typeof lastUserMessage?.content === "string" ? lastUserMessage.content : lastUserMessage?.parts?.map((p) => p.text).join("") || "";
7942
- logger21.info({ userText, lastUserMessage }, "userText");
7910
+ logger20.info({ userText, lastUserMessage }, "userText");
7943
7911
  const messageSpan = trace.getActiveSpan();
7944
7912
  if (messageSpan) {
7945
7913
  messageSpan.setAttributes({
@@ -7981,7 +7949,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
7981
7949
  await streamHelper.writeError("Unable to process request");
7982
7950
  }
7983
7951
  } catch (err) {
7984
- logger21.error({ err }, "Streaming error");
7952
+ logger20.error({ err }, "Streaming error");
7985
7953
  await streamHelper.writeError("Internal server error");
7986
7954
  } finally {
7987
7955
  if ("cleanup" in streamHelper && typeof streamHelper.cleanup === "function") {
@@ -8002,7 +7970,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
8002
7970
  )
8003
7971
  );
8004
7972
  } catch (error) {
8005
- logger21.error({ error }, "chatDataStream error");
7973
+ logger20.error({ error }, "chatDataStream error");
8006
7974
  return c.json({ error: "Failed to process chat completion" }, 500);
8007
7975
  }
8008
7976
  });
@@ -8010,7 +7978,7 @@ var chatDataStream_default = app3;
8010
7978
  function createMCPSchema(schema) {
8011
7979
  return schema;
8012
7980
  }
8013
- var logger22 = getLogger("mcp");
7981
+ var logger21 = getLogger("mcp");
8014
7982
  var _MockResponseSingleton = class _MockResponseSingleton {
8015
7983
  constructor() {
8016
7984
  __publicField(this, "mockRes");
@@ -8065,21 +8033,21 @@ var createSpoofInitMessage = (mcpProtocolVersion) => ({
8065
8033
  id: 0
8066
8034
  });
8067
8035
  var spoofTransportInitialization = async (transport, req, sessionId, mcpProtocolVersion) => {
8068
- logger22.info({ sessionId }, "Spoofing initialization message to set transport state");
8036
+ logger21.info({ sessionId }, "Spoofing initialization message to set transport state");
8069
8037
  const spoofInitMessage = createSpoofInitMessage(mcpProtocolVersion);
8070
8038
  const mockRes = MockResponseSingleton.getInstance().getMockResponse();
8071
8039
  try {
8072
8040
  await transport.handleRequest(req, mockRes, spoofInitMessage);
8073
- logger22.info({ sessionId }, "Successfully spoofed initialization");
8041
+ logger21.info({ sessionId }, "Successfully spoofed initialization");
8074
8042
  } catch (spoofError) {
8075
- logger22.warn({ sessionId, error: spoofError }, "Spoof initialization failed, continuing anyway");
8043
+ logger21.warn({ sessionId, error: spoofError }, "Spoof initialization failed, continuing anyway");
8076
8044
  }
8077
8045
  };
8078
8046
  var validateSession = async (req, res, body, tenantId, projectId, graphId) => {
8079
8047
  const sessionId = req.headers["mcp-session-id"];
8080
- logger22.info({ sessionId }, "Received MCP session ID");
8048
+ logger21.info({ sessionId }, "Received MCP session ID");
8081
8049
  if (!sessionId) {
8082
- logger22.info({ body }, "Missing session ID");
8050
+ logger21.info({ body }, "Missing session ID");
8083
8051
  res.writeHead(400).end(
8084
8052
  JSON.stringify({
8085
8053
  jsonrpc: "2.0",
@@ -8105,7 +8073,7 @@ var validateSession = async (req, res, body, tenantId, projectId, graphId) => {
8105
8073
  scopes: { tenantId, projectId },
8106
8074
  conversationId: sessionId
8107
8075
  });
8108
- logger22.info(
8076
+ logger21.info(
8109
8077
  {
8110
8078
  sessionId,
8111
8079
  conversationFound: !!conversation,
@@ -8116,7 +8084,7 @@ var validateSession = async (req, res, body, tenantId, projectId, graphId) => {
8116
8084
  "Conversation lookup result"
8117
8085
  );
8118
8086
  if (!conversation || conversation.metadata?.sessionData?.sessionType !== "mcp" || conversation.metadata?.sessionData?.graphId !== graphId) {
8119
- logger22.info(
8087
+ logger21.info(
8120
8088
  { sessionId, conversationId: conversation?.id },
8121
8089
  "MCP session not found or invalid"
8122
8090
  );
@@ -8177,7 +8145,7 @@ var executeAgentQuery = async (executionContext, conversationId, query, defaultA
8177
8145
  requestId: requestId2,
8178
8146
  sseHelper: mcpStreamHelper
8179
8147
  });
8180
- logger22.info(
8148
+ logger21.info(
8181
8149
  { result },
8182
8150
  `Execution completed: ${result.success ? "success" : "failed"} after ${result.iterations} iterations`
8183
8151
  );
@@ -8251,7 +8219,7 @@ var getServer = async (requestContext, executionContext, conversationId, credent
8251
8219
  dbClient_default,
8252
8220
  credentialStores
8253
8221
  );
8254
- logger22.info(
8222
+ logger21.info(
8255
8223
  {
8256
8224
  tenantId,
8257
8225
  graphId,
@@ -8312,7 +8280,7 @@ var validateRequestParameters = (c) => {
8312
8280
  };
8313
8281
  var handleInitializationRequest = async (body, executionContext, validatedContext, req, res, c, credentialStores) => {
8314
8282
  const { tenantId, projectId, graphId } = executionContext;
8315
- logger22.info({ body }, "Received initialization request");
8283
+ logger21.info({ body }, "Received initialization request");
8316
8284
  const sessionId = nanoid();
8317
8285
  const agentGraph = await getAgentGraphWithDefaultAgent(dbClient_default)({
8318
8286
  scopes: { tenantId, projectId },
@@ -8343,7 +8311,7 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
8343
8311
  }
8344
8312
  }
8345
8313
  });
8346
- logger22.info(
8314
+ logger21.info(
8347
8315
  { sessionId, conversationId: conversation.id },
8348
8316
  "Created MCP session as conversation"
8349
8317
  );
@@ -8352,9 +8320,9 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
8352
8320
  });
8353
8321
  const server = await getServer(validatedContext, executionContext, sessionId, credentialStores);
8354
8322
  await server.connect(transport);
8355
- logger22.info({ sessionId }, "Server connected for initialization");
8323
+ logger21.info({ sessionId }, "Server connected for initialization");
8356
8324
  res.setHeader("Mcp-Session-Id", sessionId);
8357
- logger22.info(
8325
+ logger21.info(
8358
8326
  {
8359
8327
  sessionId,
8360
8328
  bodyMethod: body?.method,
@@ -8363,7 +8331,7 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
8363
8331
  "About to handle initialization request"
8364
8332
  );
8365
8333
  await transport.handleRequest(req, res, body);
8366
- logger22.info({ sessionId }, "Successfully handled initialization request");
8334
+ logger21.info({ sessionId }, "Successfully handled initialization request");
8367
8335
  return toFetchResponse(res);
8368
8336
  };
8369
8337
  var handleExistingSessionRequest = async (body, executionContext, validatedContext, req, res, credentialStores) => {
@@ -8391,8 +8359,8 @@ var handleExistingSessionRequest = async (body, executionContext, validatedConte
8391
8359
  sessionId,
8392
8360
  conversation.metadata?.session_data?.mcpProtocolVersion
8393
8361
  );
8394
- logger22.info({ sessionId }, "Server connected and transport initialized");
8395
- logger22.info(
8362
+ logger21.info({ sessionId }, "Server connected and transport initialized");
8363
+ logger21.info(
8396
8364
  {
8397
8365
  sessionId,
8398
8366
  bodyKeys: Object.keys(body || {}),
@@ -8406,9 +8374,9 @@ var handleExistingSessionRequest = async (body, executionContext, validatedConte
8406
8374
  );
8407
8375
  try {
8408
8376
  await transport.handleRequest(req, res, body);
8409
- logger22.info({ sessionId }, "Successfully handled MCP request");
8377
+ logger21.info({ sessionId }, "Successfully handled MCP request");
8410
8378
  } catch (transportError) {
8411
- logger22.error(
8379
+ logger21.error(
8412
8380
  {
8413
8381
  sessionId,
8414
8382
  error: transportError,
@@ -8459,13 +8427,13 @@ app4.openapi(
8459
8427
  }
8460
8428
  const { executionContext } = paramValidation;
8461
8429
  const body = await c.req.json();
8462
- logger22.info({ body, bodyKeys: Object.keys(body || {}) }, "Parsed request body");
8430
+ logger21.info({ body, bodyKeys: Object.keys(body || {}) }, "Parsed request body");
8463
8431
  const isInitRequest = body.method === "initialize";
8464
8432
  const { req, res } = toReqRes(c.req.raw);
8465
8433
  const validatedContext = c.get("validatedContext") || {};
8466
8434
  const credentialStores = c.get("credentialStores");
8467
- logger22.info({ validatedContext }, "Validated context");
8468
- logger22.info({ req }, "request");
8435
+ logger21.info({ validatedContext }, "Validated context");
8436
+ logger21.info({ req }, "request");
8469
8437
  if (isInitRequest) {
8470
8438
  return await handleInitializationRequest(
8471
8439
  body,
@@ -8487,7 +8455,7 @@ app4.openapi(
8487
8455
  );
8488
8456
  }
8489
8457
  } catch (e) {
8490
- logger22.error(
8458
+ logger21.error(
8491
8459
  {
8492
8460
  error: e instanceof Error ? e.message : e,
8493
8461
  stack: e instanceof Error ? e.stack : void 0
@@ -8499,7 +8467,7 @@ app4.openapi(
8499
8467
  }
8500
8468
  );
8501
8469
  app4.get("/", async (c) => {
8502
- logger22.info("Received GET MCP request");
8470
+ logger21.info({}, "Received GET MCP request");
8503
8471
  return c.json(
8504
8472
  {
8505
8473
  jsonrpc: "2.0",
@@ -8513,7 +8481,7 @@ app4.get("/", async (c) => {
8513
8481
  );
8514
8482
  });
8515
8483
  app4.delete("/", async (c) => {
8516
- logger22.info("Received DELETE MCP request");
8484
+ logger21.info({}, "Received DELETE MCP request");
8517
8485
  return c.json(
8518
8486
  {
8519
8487
  jsonrpc: "2.0",
@@ -8526,7 +8494,7 @@ app4.delete("/", async (c) => {
8526
8494
  var mcp_default = app4;
8527
8495
 
8528
8496
  // src/app.ts
8529
- var logger23 = getLogger("agents-run-api");
8497
+ var logger22 = getLogger("agents-run-api");
8530
8498
  function createExecutionHono(serverConfig, credentialStores) {
8531
8499
  const app6 = new OpenAPIHono();
8532
8500
  app6.use("*", requestId());
@@ -8550,7 +8518,7 @@ function createExecutionHono(serverConfig, credentialStores) {
8550
8518
  });
8551
8519
  app6.use(
8552
8520
  pinoLogger({
8553
- pino: logger23 || pino({ level: "debug" }),
8521
+ pino: logger22 || pino({ level: "debug" }),
8554
8522
  http: {
8555
8523
  onResLevel(c) {
8556
8524
  if (c.res.status >= 500) {
@@ -8594,8 +8562,8 @@ function createExecutionHono(serverConfig, credentialStores) {
8594
8562
  if (!isExpectedError) {
8595
8563
  const errorMessage = err instanceof Error ? err.message : String(err);
8596
8564
  const errorStack = err instanceof Error ? err.stack : void 0;
8597
- if (logger23) {
8598
- logger23.error(
8565
+ if (logger22) {
8566
+ logger22.error(
8599
8567
  {
8600
8568
  error: err,
8601
8569
  message: errorMessage,
@@ -8607,8 +8575,8 @@ function createExecutionHono(serverConfig, credentialStores) {
8607
8575
  );
8608
8576
  }
8609
8577
  } else {
8610
- if (logger23) {
8611
- logger23.error(
8578
+ if (logger22) {
8579
+ logger22.error(
8612
8580
  {
8613
8581
  error: err,
8614
8582
  path: c.req.path,
@@ -8625,8 +8593,8 @@ function createExecutionHono(serverConfig, credentialStores) {
8625
8593
  const response = err.getResponse();
8626
8594
  return response;
8627
8595
  } catch (responseError) {
8628
- if (logger23) {
8629
- logger23.error({ error: responseError }, "Error while handling HTTPException response");
8596
+ if (logger22) {
8597
+ logger22.error({ error: responseError }, "Error while handling HTTPException response");
8630
8598
  }
8631
8599
  }
8632
8600
  }
@@ -8660,7 +8628,7 @@ function createExecutionHono(serverConfig, credentialStores) {
8660
8628
  app6.use("*", async (c, next) => {
8661
8629
  const executionContext = c.get("executionContext");
8662
8630
  if (!executionContext) {
8663
- logger23.debug("Empty execution context");
8631
+ logger22.debug({}, "Empty execution context");
8664
8632
  return next();
8665
8633
  }
8666
8634
  const { tenantId, projectId, graphId } = executionContext;
@@ -8671,7 +8639,7 @@ function createExecutionHono(serverConfig, credentialStores) {
8671
8639
  const body = await cloned.json().catch(() => null);
8672
8640
  conversationId = body?.conversationId;
8673
8641
  } catch (_) {
8674
- logger23.debug("Conversation ID not found in JSON body");
8642
+ logger22.debug({}, "Conversation ID not found in JSON body");
8675
8643
  }
8676
8644
  }
8677
8645
  const entries = Object.fromEntries(
@@ -8686,7 +8654,7 @@ function createExecutionHono(serverConfig, credentialStores) {
8686
8654
  })
8687
8655
  );
8688
8656
  if (!Object.keys(entries).length) {
8689
- logger23.debug("Empty entries for baggage");
8657
+ logger22.debug({}, "Empty entries for baggage");
8690
8658
  return next();
8691
8659
  }
8692
8660
  const bag = Object.entries(entries).reduce(