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

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