@inkeep/agents-run-api 0.17.0 → 0.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { flushBatchProcessor } from './chunk-XO4RG36I.js';
2
2
  import { getLogger } from './chunk-A2S7GSHL.js';
3
- import { getFormattedConversationHistory, createDefaultConversationHistoryConfig, saveA2AMessageResponse } from './chunk-5GUNCN5X.js';
3
+ import { getFormattedConversationHistory, createDefaultConversationHistoryConfig, saveA2AMessageResponse } from './chunk-DQQRVSJS.js';
4
4
  import { dbClient_default } from './chunk-7IMXW4RD.js';
5
5
  import { env } from './chunk-NZHNG4A3.js';
6
6
  import { __publicField } from './chunk-PKBMQBKP.js';
7
- import { getLogger as getLogger$1, getTracer, HeadersScopeSchema, getRequestExecutionContext, createApiError, getAgentGraphWithDefaultAgent, contextValidationMiddleware, getConversationId, getFullGraph, createOrGetConversation, getActiveAgentForConversation, setActiveAgentForConversation, getAgentById, handleContextResolution, createMessage, commonGetErrorResponses, loggerFactory, createDefaultCredentialStores, CredentialStoreRegistry, listTaskIdsByContextId, getTask, getLedgerArtifacts, upsertLedgerArtifact, getAgentGraphById, createTask, updateTask, setSpanWithError, updateConversation, handleApiError, TaskState, setActiveAgentForThread, getConversation, getRelatedAgentsForGraph, getToolsForAgent, getDataComponentsForAgent, getArtifactComponentsForAgent, dbResultToMcpTool, validateAndGetApiKey, getProject, ContextResolver, CredentialStuffer, MCPServerType, getCredentialReference, McpClient, getFunction, getContextConfigById, getFullGraphDefinition, TemplateEngine, graphHasArtifactComponents, MCPTransportType, getExternalAgent } from '@inkeep/agents-core';
7
+ import { getTracer, HeadersScopeSchema, getRequestExecutionContext, createApiError, getAgentGraphWithDefaultSubAgent, contextValidationMiddleware, getConversationId, getFullGraph, createOrGetConversation, getActiveAgentForConversation, setActiveAgentForConversation, getSubAgentById, handleContextResolution, createMessage, commonGetErrorResponses, loggerFactory, createDefaultCredentialStores, CredentialStoreRegistry, listTaskIdsByContextId, getTask, getLedgerArtifacts, upsertLedgerArtifact, getAgentGraphById, createTask, updateTask, setSpanWithError, updateConversation, handleApiError, TaskState, setActiveAgentForThread, getConversation, getRelatedAgentsForGraph, getToolsForAgent, getDataComponentsForAgent, getArtifactComponentsForAgent, dbResultToMcpTool, validateAndGetApiKey, getProject, ContextResolver, CredentialStuffer, MCPServerType, getCredentialReference, McpClient, getFunctionToolsForSubAgent, getFunction, getContextConfigById, getFullGraphDefinition, TemplateEngine, graphHasArtifactComponents, MCPTransportType, SPAN_KEYS, getExternalAgent } from '@inkeep/agents-core';
8
8
  import { otel } from '@hono/otel';
9
9
  import { OpenAPIHono, createRoute, z as z$1 } from '@hono/zod-openapi';
10
10
  import { trace, propagation, context, SpanStatusCode } from '@opentelemetry/api';
@@ -41,7 +41,7 @@ function createExecutionContext(params) {
41
41
  graphId: params.graphId,
42
42
  baseUrl: params.baseUrl || process.env.API_URL || "http://localhost:3003",
43
43
  apiKeyId: params.apiKeyId,
44
- agentId: params.agentId
44
+ subAgentId: params.subAgentId
45
45
  };
46
46
  }
47
47
 
@@ -56,7 +56,7 @@ var apiKeyAuth = () => createMiddleware(async (c, next) => {
56
56
  const tenantId = c.req.header("x-inkeep-tenant-id");
57
57
  const projectId = c.req.header("x-inkeep-project-id");
58
58
  const graphId = c.req.header("x-inkeep-graph-id");
59
- const agentId = c.req.header("x-inkeep-agent-id");
59
+ const subAgentId = c.req.header("x-inkeep-agent-id");
60
60
  const proto = c.req.header("x-forwarded-proto")?.split(",")[0].trim();
61
61
  const fwdHost = c.req.header("x-forwarded-host")?.split(",")[0].trim();
62
62
  const host = fwdHost ?? c.req.header("host");
@@ -67,7 +67,7 @@ var apiKeyAuth = () => createMiddleware(async (c, next) => {
67
67
  if (authHeader?.startsWith("Bearer ")) {
68
68
  try {
69
69
  executionContext = await extractContextFromApiKey(authHeader.substring(7), baseUrl);
70
- executionContext.agentId = agentId;
70
+ executionContext.subAgentId = subAgentId;
71
71
  logger.info({}, "Development/test environment - API key authenticated successfully");
72
72
  } catch {
73
73
  executionContext = createExecutionContext({
@@ -77,7 +77,7 @@ var apiKeyAuth = () => createMiddleware(async (c, next) => {
77
77
  graphId: graphId || "test-graph",
78
78
  apiKeyId: "test-key",
79
79
  baseUrl,
80
- agentId
80
+ subAgentId
81
81
  });
82
82
  logger.info(
83
83
  {},
@@ -92,7 +92,7 @@ var apiKeyAuth = () => createMiddleware(async (c, next) => {
92
92
  graphId: graphId || "test-graph",
93
93
  apiKeyId: "test-key",
94
94
  baseUrl,
95
- agentId
95
+ subAgentId
96
96
  });
97
97
  logger.info(
98
98
  {},
@@ -123,7 +123,7 @@ var apiKeyAuth = () => createMiddleware(async (c, next) => {
123
123
  graphId,
124
124
  apiKeyId: "bypass",
125
125
  baseUrl,
126
- agentId
126
+ subAgentId
127
127
  });
128
128
  c.set("executionContext", executionContext);
129
129
  logger.info({}, "Bypass secret authenticated successfully");
@@ -131,7 +131,7 @@ var apiKeyAuth = () => createMiddleware(async (c, next) => {
131
131
  return;
132
132
  } else if (apiKey) {
133
133
  const executionContext = await extractContextFromApiKey(apiKey, baseUrl);
134
- executionContext.agentId = agentId;
134
+ executionContext.subAgentId = subAgentId;
135
135
  c.set("executionContext", executionContext);
136
136
  logger.info({}, "API key authenticated successfully");
137
137
  await next();
@@ -149,14 +149,14 @@ var apiKeyAuth = () => createMiddleware(async (c, next) => {
149
149
  }
150
150
  try {
151
151
  const executionContext = await extractContextFromApiKey(apiKey, baseUrl);
152
- executionContext.agentId = agentId;
152
+ executionContext.subAgentId = subAgentId;
153
153
  c.set("executionContext", executionContext);
154
154
  logger.debug(
155
155
  {
156
156
  tenantId: executionContext.tenantId,
157
157
  projectId: executionContext.projectId,
158
158
  graphId: executionContext.graphId,
159
- agentId: executionContext.agentId
159
+ subAgentId: executionContext.subAgentId
160
160
  },
161
161
  "API key authenticated successfully"
162
162
  );
@@ -324,7 +324,7 @@ async function handleMessageSend(c, agent, request) {
324
324
  logger2.warn(
325
325
  {
326
326
  taskId: task.id,
327
- agentId: agent.agentId,
327
+ subAgentId: agent.subAgentId,
328
328
  originalMessage: params.message
329
329
  },
330
330
  "Created fallback message content for empty delegation message"
@@ -345,7 +345,7 @@ async function handleMessageSend(c, agent, request) {
345
345
  taskContextId: task.context?.conversationId,
346
346
  metadataContextId: params.message.metadata?.conversationId,
347
347
  finalContextId: effectiveContextId,
348
- agentId: agent.agentId
348
+ subAgentId: agent.subAgentId
349
349
  },
350
350
  "A2A contextId resolution for delegation"
351
351
  );
@@ -361,11 +361,11 @@ async function handleMessageSend(c, agent, request) {
361
361
  message_id: params.message.messageId || "",
362
362
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
363
363
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
364
- agent_id: agent.agentId,
364
+ agent_id: agent.subAgentId,
365
365
  graph_id: graphId || "",
366
366
  stream_request_id: params.message.metadata?.stream_request_id
367
367
  },
368
- agentId: agent.agentId,
368
+ subAgentId: agent.subAgentId,
369
369
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
370
370
  updatedAt: (/* @__PURE__ */ new Date()).toISOString()
371
371
  });
@@ -388,17 +388,17 @@ async function handleMessageSend(c, agent, request) {
388
388
  };
389
389
  if (params.message.metadata?.fromAgentId) {
390
390
  messageData.fromAgentId = params.message.metadata.fromAgentId;
391
- messageData.toAgentId = agent.agentId;
391
+ messageData.toAgentId = agent.subAgentId;
392
392
  } else if (params.message.metadata?.fromExternalAgentId) {
393
393
  messageData.fromExternalAgentId = params.message.metadata.fromExternalAgentId;
394
- messageData.toAgentId = agent.agentId;
394
+ messageData.toAgentId = agent.subAgentId;
395
395
  }
396
396
  await createMessage(dbClient_default)(messageData);
397
397
  logger2.info(
398
398
  {
399
399
  fromAgentId: params.message.metadata.fromAgentId,
400
400
  fromExternalAgentId: params.message.metadata.fromExternalAgentId,
401
- toAgentId: agent.agentId,
401
+ toAgentId: agent.subAgentId,
402
402
  conversationId: effectiveContextId,
403
403
  messageType: "a2a-request",
404
404
  taskId: task.id
@@ -411,7 +411,7 @@ async function handleMessageSend(c, agent, request) {
411
411
  error,
412
412
  fromAgentId: params.message.metadata.fromAgentId,
413
413
  fromExternalAgentId: params.message.metadata.fromExternalAgentId,
414
- toAgentId: agent.agentId,
414
+ toAgentId: agent.subAgentId,
415
415
  conversationId: effectiveContextId
416
416
  },
417
417
  "Failed to store A2A message in database"
@@ -428,7 +428,7 @@ async function handleMessageSend(c, agent, request) {
428
428
  message_id: params.message.messageId || "",
429
429
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
430
430
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
431
- agent_id: agent.agentId,
431
+ agent_id: agent.subAgentId,
432
432
  graph_id: graphId || ""
433
433
  }
434
434
  }
@@ -462,7 +462,7 @@ async function handleMessageSend(c, agent, request) {
462
462
  kind: "data",
463
463
  data: {
464
464
  type: "transfer",
465
- targetAgentId: transferPart.data.target
465
+ targetSubAgentId: transferPart.data.target
466
466
  }
467
467
  },
468
468
  {
@@ -762,7 +762,7 @@ async function handleGetCapabilities(c, agent, request) {
762
762
  async function handleGetStatus(c, agent, request) {
763
763
  return c.json({
764
764
  jsonrpc: "2.0",
765
- result: { status: "ready", agentId: agent.agentId },
765
+ result: { status: "ready", subAgentId: agent.subAgentId },
766
766
  id: request.id
767
767
  });
768
768
  }
@@ -825,7 +825,6 @@ async function handleTasksResubscribe(c, agent, request) {
825
825
  });
826
826
  }
827
827
  }
828
- getLogger$1("agents");
829
828
  function createAgentCard({
830
829
  dbAgent,
831
830
  baseUrl
@@ -903,7 +902,7 @@ async function hydrateAgent({
903
902
  tenantId: dbAgent.tenantId,
904
903
  projectId: dbAgent.projectId,
905
904
  graphId,
906
- agentId: dbAgent.id,
905
+ subAgentId: dbAgent.id,
907
906
  baseUrl,
908
907
  apiKey
909
908
  });
@@ -913,7 +912,7 @@ async function hydrateAgent({
913
912
  baseUrl
914
913
  });
915
914
  return {
916
- agentId: dbAgent.id,
915
+ subAgentId: dbAgent.id,
917
916
  tenantId: dbAgent.tenantId,
918
917
  projectId: dbAgent.projectId,
919
918
  graphId,
@@ -926,13 +925,13 @@ async function hydrateAgent({
926
925
  }
927
926
  }
928
927
  async function getRegisteredAgent(executionContext, credentialStoreRegistry) {
929
- const { tenantId, projectId, graphId, agentId, baseUrl, apiKey } = executionContext;
930
- if (!agentId) {
928
+ const { tenantId, projectId, graphId, subAgentId, baseUrl, apiKey } = executionContext;
929
+ if (!subAgentId) {
931
930
  throw new Error("Agent ID is required");
932
931
  }
933
- const dbAgent = await getAgentById(dbClient_default)({
932
+ const dbAgent = await getSubAgentById(dbClient_default)({
934
933
  scopes: { tenantId, projectId, graphId },
935
- agentId
934
+ subAgentId
936
935
  });
937
936
  if (!dbAgent) {
938
937
  return null;
@@ -946,7 +945,7 @@ async function getRegisteredAgent(executionContext, credentialStoreRegistry) {
946
945
  apiKey
947
946
  });
948
947
  }
949
- var logger4 = getLogger("ModelFactory");
948
+ var logger3 = getLogger("ModelFactory");
950
949
  var _ModelFactory = class _ModelFactory {
951
950
  /**
952
951
  * Create a provider instance with custom configuration
@@ -1008,7 +1007,7 @@ var _ModelFactory = class _ModelFactory {
1008
1007
  }
1009
1008
  const modelString = modelSettings.model.trim();
1010
1009
  const { provider, modelName } = _ModelFactory.parseModelString(modelString);
1011
- logger4.debug(
1010
+ logger3.debug(
1012
1011
  {
1013
1012
  provider,
1014
1013
  model: modelName,
@@ -1019,7 +1018,7 @@ var _ModelFactory = class _ModelFactory {
1019
1018
  );
1020
1019
  const providerConfig = _ModelFactory.extractProviderConfig(modelSettings.providerOptions);
1021
1020
  if (Object.keys(providerConfig).length > 0) {
1022
- logger4.info({ config: providerConfig }, `Applying custom ${provider} provider configuration`);
1021
+ logger3.info({ config: providerConfig }, `Applying custom ${provider} provider configuration`);
1023
1022
  const customProvider = _ModelFactory.createProvider(provider, providerConfig);
1024
1023
  return customProvider.languageModel(modelName);
1025
1024
  }
@@ -1135,7 +1134,7 @@ __publicField(_ModelFactory, "BUILT_IN_PROVIDERS", [
1135
1134
  "gateway"
1136
1135
  ]);
1137
1136
  var ModelFactory = _ModelFactory;
1138
- var logger5 = getLogger("ToolSessionManager");
1137
+ var logger4 = getLogger("ToolSessionManager");
1139
1138
  var _ToolSessionManager = class _ToolSessionManager {
1140
1139
  // 5 minutes
1141
1140
  constructor() {
@@ -1170,7 +1169,7 @@ var _ToolSessionManager = class _ToolSessionManager {
1170
1169
  createdAt: Date.now()
1171
1170
  };
1172
1171
  this.sessions.set(sessionId, session);
1173
- logger5.debug(
1172
+ logger4.debug(
1174
1173
  {
1175
1174
  sessionId,
1176
1175
  tenantId,
@@ -1188,10 +1187,10 @@ var _ToolSessionManager = class _ToolSessionManager {
1188
1187
  */
1189
1188
  ensureGraphSession(sessionId, tenantId, projectId, contextId, taskId) {
1190
1189
  if (this.sessions.has(sessionId)) {
1191
- logger5.debug({ sessionId }, "Graph session already exists, reusing");
1190
+ logger4.debug({ sessionId }, "Graph session already exists, reusing");
1192
1191
  return sessionId;
1193
1192
  }
1194
- logger5.debug(
1193
+ logger4.debug(
1195
1194
  { sessionId, tenantId, contextId, taskId },
1196
1195
  "Creating new graph-scoped tool session"
1197
1196
  );
@@ -1203,7 +1202,7 @@ var _ToolSessionManager = class _ToolSessionManager {
1203
1202
  recordToolResult(sessionId, toolResult) {
1204
1203
  const session = this.sessions.get(sessionId);
1205
1204
  if (!session) {
1206
- logger5.warn(
1205
+ logger4.warn(
1207
1206
  {
1208
1207
  sessionId,
1209
1208
  toolCallId: toolResult.toolCallId,
@@ -1215,7 +1214,7 @@ var _ToolSessionManager = class _ToolSessionManager {
1215
1214
  return;
1216
1215
  }
1217
1216
  session.toolResults.set(toolResult.toolCallId, toolResult);
1218
- logger5.debug(
1217
+ logger4.debug(
1219
1218
  {
1220
1219
  sessionId,
1221
1220
  toolCallId: toolResult.toolCallId,
@@ -1230,7 +1229,7 @@ var _ToolSessionManager = class _ToolSessionManager {
1230
1229
  getToolResult(sessionId, toolCallId) {
1231
1230
  const session = this.sessions.get(sessionId);
1232
1231
  if (!session) {
1233
- logger5.warn(
1232
+ logger4.warn(
1234
1233
  {
1235
1234
  sessionId,
1236
1235
  toolCallId,
@@ -1243,7 +1242,7 @@ var _ToolSessionManager = class _ToolSessionManager {
1243
1242
  }
1244
1243
  const result = session.toolResults.get(toolCallId);
1245
1244
  if (!result) {
1246
- logger5.warn(
1245
+ logger4.warn(
1247
1246
  {
1248
1247
  sessionId,
1249
1248
  toolCallId,
@@ -1253,7 +1252,7 @@ var _ToolSessionManager = class _ToolSessionManager {
1253
1252
  "Tool result not found"
1254
1253
  );
1255
1254
  } else {
1256
- logger5.debug(
1255
+ logger4.debug(
1257
1256
  {
1258
1257
  sessionId,
1259
1258
  toolCallId,
@@ -1292,10 +1291,10 @@ var _ToolSessionManager = class _ToolSessionManager {
1292
1291
  }
1293
1292
  for (const sessionId of expiredSessions) {
1294
1293
  this.sessions.delete(sessionId);
1295
- logger5.debug({ sessionId }, "Cleaned up expired tool session");
1294
+ logger4.debug({ sessionId }, "Cleaned up expired tool session");
1296
1295
  }
1297
1296
  if (expiredSessions.length > 0) {
1298
- logger5.info({ expiredCount: expiredSessions.length }, "Cleaned up expired tool sessions");
1297
+ logger4.info({ expiredCount: expiredSessions.length }, "Cleaned up expired tool sessions");
1299
1298
  }
1300
1299
  }
1301
1300
  };
@@ -1365,7 +1364,7 @@ function extractFullFields(schema) {
1365
1364
  }
1366
1365
 
1367
1366
  // src/services/ArtifactService.ts
1368
- var logger7 = getLogger("ArtifactService");
1367
+ var logger6 = getLogger("ArtifactService");
1369
1368
  var _ArtifactService = class _ArtifactService {
1370
1369
  constructor(context) {
1371
1370
  this.context = context;
@@ -1397,7 +1396,7 @@ var _ArtifactService = class _ArtifactService {
1397
1396
  id: taskId
1398
1397
  });
1399
1398
  if (!task) {
1400
- logger7.warn({ taskId }, "Task not found when fetching artifacts");
1399
+ logger6.warn({ taskId }, "Task not found when fetching artifacts");
1401
1400
  continue;
1402
1401
  }
1403
1402
  const taskArtifacts = await getLedgerArtifacts(dbClient_default)({
@@ -1415,21 +1414,21 @@ var _ArtifactService = class _ArtifactService {
1415
1414
  }
1416
1415
  }
1417
1416
  } catch (error) {
1418
- logger7.error({ error, contextId }, "Error loading context artifacts");
1417
+ logger6.error({ error, contextId }, "Error loading context artifacts");
1419
1418
  }
1420
1419
  return artifacts;
1421
1420
  }
1422
1421
  /**
1423
1422
  * Create artifact from tool result and request data
1424
1423
  */
1425
- async createArtifact(request, agentId) {
1424
+ async createArtifact(request, subAgentId) {
1426
1425
  if (!this.context.sessionId) {
1427
- logger7.warn({ request }, "No session ID available for artifact creation");
1426
+ logger6.warn({ request }, "No session ID available for artifact creation");
1428
1427
  return null;
1429
1428
  }
1430
1429
  const toolResult = toolSessionManager.getToolResult(this.context.sessionId, request.toolCallId);
1431
1430
  if (!toolResult) {
1432
- logger7.warn(
1431
+ logger6.warn(
1433
1432
  { request, sessionId: this.context.sessionId },
1434
1433
  "Tool result not found for artifact"
1435
1434
  );
@@ -1445,7 +1444,7 @@ var _ArtifactService = class _ArtifactService {
1445
1444
  selectedData = selectedData.length > 0 ? selectedData[0] : {};
1446
1445
  }
1447
1446
  if (!selectedData) {
1448
- logger7.warn(
1447
+ logger6.warn(
1449
1448
  {
1450
1449
  request,
1451
1450
  baseSelector: request.baseSelector
@@ -1490,7 +1489,7 @@ var _ArtifactService = class _ArtifactService {
1490
1489
  type: request.type,
1491
1490
  data: cleanedSummaryData
1492
1491
  };
1493
- await this.persistArtifact(request, cleanedSummaryData, cleanedFullData, agentId);
1492
+ await this.persistArtifact(request, cleanedSummaryData, cleanedFullData, subAgentId);
1494
1493
  await this.cacheArtifact(
1495
1494
  request.artifactId,
1496
1495
  request.toolCallId,
@@ -1499,7 +1498,7 @@ var _ArtifactService = class _ArtifactService {
1499
1498
  );
1500
1499
  return artifactData;
1501
1500
  } catch (error) {
1502
- logger7.error({ error, request }, "Failed to create artifact");
1501
+ logger6.error({ error, request }, "Failed to create artifact");
1503
1502
  const errorMessage = error instanceof Error ? error.message : "Unknown error";
1504
1503
  throw new Error(`Artifact creation failed for ${request.artifactId}: ${errorMessage}`);
1505
1504
  }
@@ -1528,7 +1527,7 @@ var _ArtifactService = class _ArtifactService {
1528
1527
  }
1529
1528
  try {
1530
1529
  if (!this.context.projectId || !this.context.taskId) {
1531
- logger7.warn(
1530
+ logger6.warn(
1532
1531
  { artifactId, toolCallId },
1533
1532
  "No projectId or taskId available for artifact lookup"
1534
1533
  );
@@ -1543,7 +1542,7 @@ var _ArtifactService = class _ArtifactService {
1543
1542
  return this.formatArtifactSummaryData(artifacts[0], artifactId, toolCallId);
1544
1543
  }
1545
1544
  } catch (error) {
1546
- logger7.warn(
1545
+ logger6.warn(
1547
1546
  { artifactId, toolCallId, taskId: this.context.taskId, error },
1548
1547
  "Failed to fetch artifact"
1549
1548
  );
@@ -1574,7 +1573,7 @@ var _ArtifactService = class _ArtifactService {
1574
1573
  }
1575
1574
  try {
1576
1575
  if (!this.context.projectId || !this.context.taskId) {
1577
- logger7.warn(
1576
+ logger6.warn(
1578
1577
  { artifactId, toolCallId },
1579
1578
  "No projectId or taskId available for artifact lookup"
1580
1579
  );
@@ -1589,7 +1588,7 @@ var _ArtifactService = class _ArtifactService {
1589
1588
  return this.formatArtifactFullData(artifacts[0], artifactId, toolCallId);
1590
1589
  }
1591
1590
  } catch (error) {
1592
- logger7.warn(
1591
+ logger6.warn(
1593
1592
  { artifactId, toolCallId, taskId: this.context.taskId, error },
1594
1593
  "Failed to fetch artifact"
1595
1594
  );
@@ -1625,8 +1624,8 @@ var _ArtifactService = class _ArtifactService {
1625
1624
  /**
1626
1625
  * Persist artifact to database via graph session
1627
1626
  */
1628
- async persistArtifact(request, summaryData, fullData, agentId) {
1629
- const effectiveAgentId = agentId || this.context.agentId;
1627
+ async persistArtifact(request, summaryData, fullData, subAgentId) {
1628
+ const effectiveAgentId = subAgentId || this.context.subAgentId;
1630
1629
  if (this.context.streamRequestId && effectiveAgentId && this.context.taskId) {
1631
1630
  await graphSessionManager.recordEvent(
1632
1631
  this.context.streamRequestId,
@@ -1639,7 +1638,7 @@ var _ArtifactService = class _ArtifactService {
1639
1638
  artifactType: request.type,
1640
1639
  summaryData,
1641
1640
  data: fullData,
1642
- agentId: effectiveAgentId,
1641
+ subAgentId: effectiveAgentId,
1643
1642
  metadata: {
1644
1643
  toolCallId: request.toolCallId,
1645
1644
  baseSelector: request.baseSelector,
@@ -1654,14 +1653,14 @@ var _ArtifactService = class _ArtifactService {
1654
1653
  }
1655
1654
  );
1656
1655
  } else {
1657
- logger7.warn(
1656
+ logger6.warn(
1658
1657
  {
1659
1658
  artifactId: request.artifactId,
1660
1659
  hasStreamRequestId: !!this.context.streamRequestId,
1661
1660
  hasAgentId: !!effectiveAgentId,
1662
1661
  hasTaskId: !!this.context.taskId,
1663
- passedAgentId: agentId,
1664
- contextAgentId: this.context.agentId
1662
+ passedAgentId: subAgentId,
1663
+ contextAgentId: this.context.subAgentId
1665
1664
  },
1666
1665
  "Skipping artifact_saved event - missing required context"
1667
1666
  );
@@ -1729,7 +1728,7 @@ var _ArtifactService = class _ArtifactService {
1729
1728
  summaryData = this.filterBySchema(artifact.data, previewSchema);
1730
1729
  fullData = this.filterBySchema(artifact.data, fullSchema);
1731
1730
  } catch (error) {
1732
- logger7.warn(
1731
+ logger6.warn(
1733
1732
  {
1734
1733
  artifactType: artifact.type,
1735
1734
  error: error instanceof Error ? error.message : "Unknown error"
@@ -1767,7 +1766,7 @@ var _ArtifactService = class _ArtifactService {
1767
1766
  artifact: artifactToSave
1768
1767
  });
1769
1768
  if (!result.created && result.existing) {
1770
- logger7.debug(
1769
+ logger6.debug(
1771
1770
  {
1772
1771
  artifactId: artifact.artifactId,
1773
1772
  taskId: this.context.taskId
@@ -1820,7 +1819,7 @@ var _ArtifactService = class _ArtifactService {
1820
1819
  extracted[propName] = this.cleanEscapedContent(rawValue);
1821
1820
  }
1822
1821
  } catch (error) {
1823
- logger7.warn(
1822
+ logger6.warn(
1824
1823
  { propName, selector, error: error instanceof Error ? error.message : "Unknown error" },
1825
1824
  "Failed to extract property"
1826
1825
  );
@@ -1852,7 +1851,7 @@ var _ArtifactService = class _ArtifactService {
1852
1851
  extracted[fieldName] = this.cleanEscapedContent(rawValue);
1853
1852
  }
1854
1853
  } catch (error) {
1855
- logger7.warn(
1854
+ logger6.warn(
1856
1855
  { fieldName, error: error instanceof Error ? error.message : "Unknown error" },
1857
1856
  "Failed to extract schema field"
1858
1857
  );
@@ -1883,7 +1882,7 @@ __publicField(_ArtifactService, "selectorCache", /* @__PURE__ */ new Map());
1883
1882
  var ArtifactService = _ArtifactService;
1884
1883
 
1885
1884
  // src/services/ArtifactParser.ts
1886
- var logger8 = getLogger("ArtifactParser");
1885
+ var logger7 = getLogger("ArtifactParser");
1887
1886
  var _ArtifactParser = class _ArtifactParser {
1888
1887
  constructor(tenantId, options) {
1889
1888
  __publicField(this, "artifactService");
@@ -1971,7 +1970,7 @@ var _ArtifactParser = class _ArtifactParser {
1971
1970
  attrs[key] = value;
1972
1971
  }
1973
1972
  if (!attrs.id || !attrs.tool || !attrs.type || !attrs.base) {
1974
- logger8.warn({ attrs, attrString }, "Missing required attributes in artifact annotation");
1973
+ logger7.warn({ attrs, attrString }, "Missing required attributes in artifact annotation");
1975
1974
  return null;
1976
1975
  }
1977
1976
  return {
@@ -2002,7 +2001,7 @@ var _ArtifactParser = class _ArtifactParser {
2002
2001
  /**
2003
2002
  * Extract artifact data from a create annotation - delegates to service
2004
2003
  */
2005
- async extractFromCreateAnnotation(annotation, agentId) {
2004
+ async extractFromCreateAnnotation(annotation, subAgentId) {
2006
2005
  const request = {
2007
2006
  artifactId: annotation.artifactId,
2008
2007
  toolCallId: annotation.toolCallId,
@@ -2010,21 +2009,21 @@ var _ArtifactParser = class _ArtifactParser {
2010
2009
  baseSelector: annotation.baseSelector,
2011
2010
  detailsSelector: annotation.detailsSelector
2012
2011
  };
2013
- return this.artifactService.createArtifact(request, agentId);
2012
+ return this.artifactService.createArtifact(request, subAgentId);
2014
2013
  }
2015
2014
  /**
2016
2015
  * Parse text with artifact markers into parts array
2017
2016
  * Handles both artifact:ref and artifact:create tags
2018
2017
  * Can work with or without pre-fetched artifact map
2019
2018
  */
2020
- async parseText(text, artifactMap, agentId) {
2019
+ async parseText(text, artifactMap, subAgentId) {
2021
2020
  let processedText = text;
2022
2021
  const createAnnotations = this.parseCreateAnnotations(text);
2023
2022
  const createdArtifactData = /* @__PURE__ */ new Map();
2024
2023
  const failedAnnotations = [];
2025
2024
  for (const annotation of createAnnotations) {
2026
2025
  try {
2027
- const artifactData = await this.extractFromCreateAnnotation(annotation, agentId);
2026
+ const artifactData = await this.extractFromCreateAnnotation(annotation, subAgentId);
2028
2027
  if (artifactData && annotation.raw) {
2029
2028
  createdArtifactData.set(annotation.raw, artifactData);
2030
2029
  } else if (annotation.raw) {
@@ -2032,7 +2031,7 @@ var _ArtifactParser = class _ArtifactParser {
2032
2031
  `Failed to create artifact "${annotation.artifactId}": Missing or invalid data`
2033
2032
  );
2034
2033
  processedText = processedText.replace(annotation.raw, "");
2035
- logger8.warn(
2034
+ logger7.warn(
2036
2035
  { annotation, artifactData },
2037
2036
  "Removed failed artifact:create annotation from output"
2038
2037
  );
@@ -2043,11 +2042,11 @@ var _ArtifactParser = class _ArtifactParser {
2043
2042
  if (annotation.raw) {
2044
2043
  processedText = processedText.replace(annotation.raw, "");
2045
2044
  }
2046
- logger8.error({ annotation, error }, "Failed to extract artifact from create annotation");
2045
+ logger7.error({ annotation, error }, "Failed to extract artifact from create annotation");
2047
2046
  }
2048
2047
  }
2049
2048
  if (failedAnnotations.length > 0) {
2050
- logger8.warn(
2049
+ logger7.warn(
2051
2050
  {
2052
2051
  failedCount: failedAnnotations.length,
2053
2052
  failures: failedAnnotations
@@ -2111,7 +2110,7 @@ var _ArtifactParser = class _ArtifactParser {
2111
2110
  /**
2112
2111
  * Process object/dataComponents for artifact components
2113
2112
  */
2114
- async parseObject(obj, artifactMap, agentId) {
2113
+ async parseObject(obj, artifactMap, subAgentId) {
2115
2114
  if (obj?.dataComponents && Array.isArray(obj.dataComponents)) {
2116
2115
  const parts = [];
2117
2116
  for (const component of obj.dataComponents) {
@@ -2135,7 +2134,7 @@ var _ArtifactParser = class _ArtifactParser {
2135
2134
  });
2136
2135
  }
2137
2136
  } else if (this.isArtifactCreateComponent(component)) {
2138
- const createData = await this.extractFromArtifactCreateComponent(component, agentId);
2137
+ const createData = await this.extractFromArtifactCreateComponent(component, subAgentId);
2139
2138
  if (createData) {
2140
2139
  parts.push({
2141
2140
  kind: "data",
@@ -2176,7 +2175,7 @@ var _ArtifactParser = class _ArtifactParser {
2176
2175
  ] : [];
2177
2176
  }
2178
2177
  if (this.isArtifactCreateComponent(obj)) {
2179
- const createData = await this.extractFromArtifactCreateComponent(obj, agentId);
2178
+ const createData = await this.extractFromArtifactCreateComponent(obj, subAgentId);
2180
2179
  return createData ? [
2181
2180
  {
2182
2181
  kind: "data",
@@ -2208,7 +2207,7 @@ var _ArtifactParser = class _ArtifactParser {
2208
2207
  /**
2209
2208
  * Extract artifact from ArtifactCreate component
2210
2209
  */
2211
- async extractFromArtifactCreateComponent(component, agentId) {
2210
+ async extractFromArtifactCreateComponent(component, subAgentId) {
2212
2211
  const props = component.props;
2213
2212
  if (!props) {
2214
2213
  return null;
@@ -2220,7 +2219,7 @@ var _ArtifactParser = class _ArtifactParser {
2220
2219
  baseSelector: props.base_selector,
2221
2220
  detailsSelector: props.details_selector || {}
2222
2221
  };
2223
- return await this.extractFromCreateAnnotation(annotation, agentId);
2222
+ return await this.extractFromCreateAnnotation(annotation, subAgentId);
2224
2223
  }
2225
2224
  /**
2226
2225
  * Get artifact data - delegates to service
@@ -2260,7 +2259,7 @@ __publicField(_ArtifactParser, "INCOMPLETE_CREATE_REGEX", /<artifact:create(?![^
2260
2259
  var ArtifactParser = _ArtifactParser;
2261
2260
 
2262
2261
  // src/services/GraphSession.ts
2263
- var logger9 = getLogger("GraphSession");
2262
+ var logger8 = getLogger("GraphSession");
2264
2263
  var GraphSession = class {
2265
2264
  // Whether to send data operations
2266
2265
  constructor(sessionId, messageId, graphId, tenantId, projectId, contextId) {
@@ -2293,7 +2292,7 @@ var GraphSession = class {
2293
2292
  __publicField(this, "artifactParser");
2294
2293
  // Session-scoped ArtifactParser instance
2295
2294
  __publicField(this, "isEmitOperations", false);
2296
- logger9.debug({ sessionId, messageId, graphId }, "GraphSession created");
2295
+ logger8.debug({ sessionId, messageId, graphId }, "GraphSession created");
2297
2296
  if (tenantId && projectId) {
2298
2297
  toolSessionManager.createSessionWithId(
2299
2298
  sessionId,
@@ -2307,7 +2306,6 @@ var GraphSession = class {
2307
2306
  tenantId,
2308
2307
  projectId,
2309
2308
  sessionId,
2310
- // Same ID as ToolSession
2311
2309
  contextId,
2312
2310
  taskId: `task_${contextId}-${messageId}`,
2313
2311
  streamRequestId: sessionId
@@ -2328,7 +2326,7 @@ var GraphSession = class {
2328
2326
  */
2329
2327
  enableEmitOperations() {
2330
2328
  this.isEmitOperations = true;
2331
- logger9.info(
2329
+ logger8.info(
2332
2330
  { sessionId: this.sessionId },
2333
2331
  "\u{1F50D} DEBUG: Emit operations enabled for GraphSession"
2334
2332
  );
@@ -2345,14 +2343,14 @@ var GraphSession = class {
2345
2343
  label: this.generateEventLabel(event),
2346
2344
  details: {
2347
2345
  timestamp: event.timestamp,
2348
- agentId: event.agentId,
2346
+ subAgentId: event.subAgentId,
2349
2347
  data: event.data
2350
2348
  }
2351
2349
  };
2352
2350
  await streamHelper.writeOperation(formattedOperation);
2353
2351
  }
2354
2352
  } catch (error) {
2355
- logger9.error(
2353
+ logger8.error(
2356
2354
  {
2357
2355
  sessionId: this.sessionId,
2358
2356
  eventType: event.eventType,
@@ -2368,29 +2366,19 @@ var GraphSession = class {
2368
2366
  generateEventLabel(event) {
2369
2367
  switch (event.eventType) {
2370
2368
  case "agent_generate":
2371
- return `Agent ${event.agentId} generating response`;
2369
+ return `Agent ${event.subAgentId} generating response`;
2372
2370
  case "agent_reasoning":
2373
- return `Agent ${event.agentId} reasoning through request`;
2374
- case "tool_execution": {
2375
- const toolData = event.data;
2376
- return `Tool execution: ${toolData.toolName || "unknown"}`;
2377
- }
2378
- case "transfer": {
2379
- const transferData = event.data;
2380
- return `Agent transfer: ${transferData.fromAgent} \u2192 ${transferData.targetAgent}`;
2381
- }
2382
- case "delegation_sent": {
2383
- const delegationData = event.data;
2384
- return `Task delegated: ${delegationData.fromAgent} \u2192 ${delegationData.targetAgent}`;
2385
- }
2386
- case "delegation_returned": {
2387
- const returnData = event.data;
2388
- return `Task completed: ${returnData.targetAgent} \u2192 ${returnData.fromAgent}`;
2389
- }
2390
- case "artifact_saved": {
2391
- const artifactData = event.data;
2392
- return `Artifact saved: ${artifactData.artifactType || "unknown type"}`;
2393
- }
2371
+ return `Agent ${event.subAgentId} reasoning through request`;
2372
+ case "tool_execution":
2373
+ return `Tool execution: ${event.data.toolName || "unknown"}`;
2374
+ case "transfer":
2375
+ return `Agent transfer: ${event.data.fromSubAgent} \u2192 ${event.data.targetSubAgent}`;
2376
+ case "delegation_sent":
2377
+ return `Task delegated: ${event.data.fromSubAgent} \u2192 ${event.data.targetSubAgent}`;
2378
+ case "delegation_returned":
2379
+ return `Task completed: ${event.data.targetSubAgent} \u2192 ${event.data.fromSubAgent}`;
2380
+ case "artifact_saved":
2381
+ return `Artifact saved: ${event.data.artifactType || "unknown type"}`;
2394
2382
  default:
2395
2383
  return `${event.eventType} event`;
2396
2384
  }
@@ -2415,7 +2403,7 @@ var GraphSession = class {
2415
2403
  if (this.statusUpdateState.config.timeInSeconds) {
2416
2404
  this.statusUpdateTimer = setInterval(async () => {
2417
2405
  if (!this.statusUpdateState || this.isEnded) {
2418
- logger9.debug(
2406
+ logger8.debug(
2419
2407
  { sessionId: this.sessionId },
2420
2408
  "Timer triggered but session already cleaned up or ended"
2421
2409
  );
@@ -2427,7 +2415,7 @@ var GraphSession = class {
2427
2415
  }
2428
2416
  await this.checkAndSendTimeBasedUpdate();
2429
2417
  }, this.statusUpdateState.config.timeInSeconds * 1e3);
2430
- logger9.info(
2418
+ logger8.info(
2431
2419
  {
2432
2420
  sessionId: this.sessionId,
2433
2421
  intervalMs: this.statusUpdateState.config.timeInSeconds * 1e3
@@ -2438,22 +2426,24 @@ var GraphSession = class {
2438
2426
  }
2439
2427
  /**
2440
2428
  * Record an event in the session and trigger status updates if configured
2429
+ * Generic type parameter T ensures eventType and data are correctly paired
2441
2430
  */
2442
- recordEvent(eventType, agentId, data) {
2431
+ recordEvent(eventType, subAgentId, data) {
2443
2432
  if (this.isEmitOperations) {
2444
- this.sendDataOperation({
2433
+ const dataOpEvent = {
2445
2434
  timestamp: Date.now(),
2446
2435
  eventType,
2447
- agentId,
2436
+ subAgentId,
2448
2437
  data
2449
- });
2438
+ };
2439
+ this.sendDataOperation(dataOpEvent);
2450
2440
  }
2451
2441
  if (this.isEnded) {
2452
- logger9.debug(
2442
+ logger8.debug(
2453
2443
  {
2454
2444
  sessionId: this.sessionId,
2455
2445
  eventType,
2456
- agentId
2446
+ subAgentId
2457
2447
  },
2458
2448
  "Event received after session ended - ignoring"
2459
2449
  );
@@ -2462,59 +2452,62 @@ var GraphSession = class {
2462
2452
  const event = {
2463
2453
  timestamp: Date.now(),
2464
2454
  eventType,
2465
- agentId,
2455
+ subAgentId,
2466
2456
  data
2467
2457
  };
2468
2458
  this.events.push(event);
2469
- if (eventType === "artifact_saved" && data.pendingGeneration) {
2470
- const artifactId = data.artifactId;
2471
- if (this.pendingArtifacts.size >= this.MAX_PENDING_ARTIFACTS) {
2472
- logger9.warn(
2473
- {
2474
- sessionId: this.sessionId,
2475
- artifactId,
2476
- pendingCount: this.pendingArtifacts.size,
2477
- maxAllowed: this.MAX_PENDING_ARTIFACTS
2478
- },
2479
- "Too many pending artifacts, skipping processing"
2480
- );
2481
- return;
2482
- }
2483
- this.pendingArtifacts.add(artifactId);
2484
- setImmediate(() => {
2485
- const artifactDataWithAgent = { ...data, agentId };
2486
- this.processArtifact(artifactDataWithAgent).then(() => {
2487
- this.pendingArtifacts.delete(artifactId);
2488
- this.artifactProcessingErrors.delete(artifactId);
2489
- }).catch((error) => {
2490
- const errorCount = (this.artifactProcessingErrors.get(artifactId) || 0) + 1;
2491
- this.artifactProcessingErrors.set(artifactId, errorCount);
2492
- if (errorCount >= this.MAX_ARTIFACT_RETRIES) {
2459
+ if (eventType === "artifact_saved") {
2460
+ const artifactData = data;
2461
+ if (artifactData.pendingGeneration) {
2462
+ const artifactId = artifactData.artifactId;
2463
+ if (this.pendingArtifacts.size >= this.MAX_PENDING_ARTIFACTS) {
2464
+ logger8.warn(
2465
+ {
2466
+ sessionId: this.sessionId,
2467
+ artifactId,
2468
+ pendingCount: this.pendingArtifacts.size,
2469
+ maxAllowed: this.MAX_PENDING_ARTIFACTS
2470
+ },
2471
+ "Too many pending artifacts, skipping processing"
2472
+ );
2473
+ return;
2474
+ }
2475
+ this.pendingArtifacts.add(artifactId);
2476
+ setImmediate(() => {
2477
+ const artifactDataWithAgent = { ...artifactData, subAgentId };
2478
+ this.processArtifact(artifactDataWithAgent).then(() => {
2493
2479
  this.pendingArtifacts.delete(artifactId);
2494
- logger9.error(
2495
- {
2496
- sessionId: this.sessionId,
2497
- artifactId,
2498
- errorCount,
2499
- maxRetries: this.MAX_ARTIFACT_RETRIES,
2500
- error: error instanceof Error ? error.message : "Unknown error",
2501
- stack: error instanceof Error ? error.stack : void 0
2502
- },
2503
- "Artifact processing failed after max retries, giving up"
2504
- );
2505
- } else {
2506
- logger9.warn(
2507
- {
2508
- sessionId: this.sessionId,
2509
- artifactId,
2510
- errorCount,
2511
- error: error instanceof Error ? error.message : "Unknown error"
2512
- },
2513
- "Artifact processing failed, may retry"
2514
- );
2515
- }
2480
+ this.artifactProcessingErrors.delete(artifactId);
2481
+ }).catch((error) => {
2482
+ const errorCount = (this.artifactProcessingErrors.get(artifactId) || 0) + 1;
2483
+ this.artifactProcessingErrors.set(artifactId, errorCount);
2484
+ if (errorCount >= this.MAX_ARTIFACT_RETRIES) {
2485
+ this.pendingArtifacts.delete(artifactId);
2486
+ logger8.error(
2487
+ {
2488
+ sessionId: this.sessionId,
2489
+ artifactId,
2490
+ errorCount,
2491
+ maxRetries: this.MAX_ARTIFACT_RETRIES,
2492
+ error: error instanceof Error ? error.message : "Unknown error",
2493
+ stack: error instanceof Error ? error.stack : void 0
2494
+ },
2495
+ "Artifact processing failed after max retries, giving up"
2496
+ );
2497
+ } else {
2498
+ logger8.warn(
2499
+ {
2500
+ sessionId: this.sessionId,
2501
+ artifactId,
2502
+ errorCount,
2503
+ error: error instanceof Error ? error.message : "Unknown error"
2504
+ },
2505
+ "Artifact processing failed, may retry"
2506
+ );
2507
+ }
2508
+ });
2516
2509
  });
2517
- });
2510
+ }
2518
2511
  }
2519
2512
  if (!this.isEnded) {
2520
2513
  this.checkStatusUpdates();
@@ -2525,14 +2518,14 @@ var GraphSession = class {
2525
2518
  */
2526
2519
  checkStatusUpdates() {
2527
2520
  if (this.isEnded) {
2528
- logger9.debug(
2521
+ logger8.debug(
2529
2522
  { sessionId: this.sessionId },
2530
2523
  "Session has ended - skipping status update check"
2531
2524
  );
2532
2525
  return;
2533
2526
  }
2534
2527
  if (!this.statusUpdateState) {
2535
- logger9.debug({ sessionId: this.sessionId }, "No status update state - skipping check");
2528
+ logger8.debug({ sessionId: this.sessionId }, "No status update state - skipping check");
2536
2529
  return;
2537
2530
  }
2538
2531
  const statusUpdateState = this.statusUpdateState;
@@ -2543,11 +2536,11 @@ var GraphSession = class {
2543
2536
  */
2544
2537
  async checkAndSendTimeBasedUpdate() {
2545
2538
  if (this.isEnded) {
2546
- logger9.debug({ sessionId: this.sessionId }, "Session has ended - skipping time-based update");
2539
+ logger8.debug({ sessionId: this.sessionId }, "Session has ended - skipping time-based update");
2547
2540
  return;
2548
2541
  }
2549
2542
  if (!this.statusUpdateState) {
2550
- logger9.debug(
2543
+ logger8.debug(
2551
2544
  { sessionId: this.sessionId },
2552
2545
  "No status updates configured for time-based check"
2553
2546
  );
@@ -2560,7 +2553,7 @@ var GraphSession = class {
2560
2553
  try {
2561
2554
  await this.generateAndSendUpdate();
2562
2555
  } catch (error) {
2563
- logger9.error(
2556
+ logger8.error(
2564
2557
  {
2565
2558
  sessionId: this.sessionId,
2566
2559
  error: error instanceof Error ? error.message : "Unknown error"
@@ -2584,8 +2577,8 @@ var GraphSession = class {
2584
2577
  /**
2585
2578
  * Get events filtered by agent
2586
2579
  */
2587
- getEventsByAgent(agentId) {
2588
- return this.events.filter((event) => event.agentId === agentId);
2580
+ getEventsByAgent(subAgentId) {
2581
+ return this.events.filter((event) => event.subAgentId === subAgentId);
2589
2582
  }
2590
2583
  /**
2591
2584
  * Get summary of session activity
@@ -2600,7 +2593,7 @@ var GraphSession = class {
2600
2593
  );
2601
2594
  const agentCounts = this.events.reduce(
2602
2595
  (counts, event) => {
2603
- counts[event.agentId] = (counts[event.agentId] || 0) + 1;
2596
+ counts[event.subAgentId] = (counts[event.subAgentId] || 0) + 1;
2604
2597
  return counts;
2605
2598
  },
2606
2599
  {}
@@ -2663,29 +2656,29 @@ var GraphSession = class {
2663
2656
  */
2664
2657
  async generateAndSendUpdate() {
2665
2658
  if (this.isEnded) {
2666
- logger9.debug({ sessionId: this.sessionId }, "Session has ended - not generating update");
2659
+ logger8.debug({ sessionId: this.sessionId }, "Session has ended - not generating update");
2667
2660
  return;
2668
2661
  }
2669
2662
  if (this.isTextStreaming) {
2670
- logger9.debug(
2663
+ logger8.debug(
2671
2664
  { sessionId: this.sessionId },
2672
2665
  "Text is currently streaming - skipping status update"
2673
2666
  );
2674
2667
  return;
2675
2668
  }
2676
2669
  if (this.isGeneratingUpdate) {
2677
- logger9.debug(
2670
+ logger8.debug(
2678
2671
  { sessionId: this.sessionId },
2679
2672
  "Update already in progress - skipping duplicate generation"
2680
2673
  );
2681
2674
  return;
2682
2675
  }
2683
2676
  if (!this.statusUpdateState) {
2684
- logger9.warn({ sessionId: this.sessionId }, "No status update state - cannot generate update");
2677
+ logger8.warn({ sessionId: this.sessionId }, "No status update state - cannot generate update");
2685
2678
  return;
2686
2679
  }
2687
2680
  if (!this.graphId) {
2688
- logger9.warn({ sessionId: this.sessionId }, "No graph ID - cannot generate update");
2681
+ logger8.warn({ sessionId: this.sessionId }, "No graph ID - cannot generate update");
2689
2682
  return;
2690
2683
  }
2691
2684
  const newEventCount = this.events.length - this.statusUpdateState.lastEventCount;
@@ -2697,7 +2690,7 @@ var GraphSession = class {
2697
2690
  try {
2698
2691
  const streamHelper = getStreamHelper(this.sessionId);
2699
2692
  if (!streamHelper) {
2700
- logger9.warn(
2693
+ logger8.warn(
2701
2694
  { sessionId: this.sessionId },
2702
2695
  "No stream helper found - cannot send status update"
2703
2696
  );
@@ -2717,7 +2710,7 @@ var GraphSession = class {
2717
2710
  if (result.summaries && result.summaries.length > 0) {
2718
2711
  for (const summary of result.summaries) {
2719
2712
  if (!summary || !summary.type || !summary.data || !summary.data.label || Object.keys(summary.data).length === 0) {
2720
- logger9.warn(
2713
+ logger8.warn(
2721
2714
  {
2722
2715
  sessionId: this.sessionId,
2723
2716
  summary
@@ -2754,7 +2747,7 @@ var GraphSession = class {
2754
2747
  this.statusUpdateState.lastEventCount = this.events.length;
2755
2748
  }
2756
2749
  } catch (error) {
2757
- logger9.error(
2750
+ logger8.error(
2758
2751
  {
2759
2752
  sessionId: this.sessionId,
2760
2753
  error: error instanceof Error ? error.message : "Unknown error",
@@ -2792,7 +2785,7 @@ var GraphSession = class {
2792
2785
  this.releaseUpdateLock();
2793
2786
  }
2794
2787
  } catch (error) {
2795
- logger9.error(
2788
+ logger8.error(
2796
2789
  {
2797
2790
  sessionId: this.sessionId,
2798
2791
  error: error instanceof Error ? error.message : "Unknown error"
@@ -2870,7 +2863,7 @@ User's Question/Context:
2870
2863
  ${conversationHistory}
2871
2864
  ` : "";
2872
2865
  } catch (error) {
2873
- logger9.warn(
2866
+ logger8.warn(
2874
2867
  { sessionId: this.sessionId, error },
2875
2868
  "Failed to fetch conversation history for structured status update"
2876
2869
  );
@@ -3004,7 +2997,7 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
3004
2997
  return { summaries };
3005
2998
  } catch (error) {
3006
2999
  setSpanWithError(span, error instanceof Error ? error : new Error(String(error)));
3007
- logger9.error({ error }, "Failed to generate structured update, using fallback");
3000
+ logger8.error({ error }, "Failed to generate structured update, using fallback");
3008
3001
  return { summaries: [] };
3009
3002
  } finally {
3010
3003
  span.end();
@@ -3030,7 +3023,7 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
3030
3023
  */
3031
3024
  buildZodSchemaFromJson(jsonSchema) {
3032
3025
  const properties = {};
3033
- properties["label"] = z.string().describe(
3026
+ properties.label = z.string().describe(
3034
3027
  'A short 3-5 word phrase, that is a descriptive label for the update component. This Label must be EXTREMELY unique to represent the UNIQUE update we are providing. The SPECIFIC finding, result, or insight discovered (e.g., "Slack bot needs workspace admin role", "Found ingestion requires 3 steps", "Channel history limited to 10k messages"). State the ACTUAL information found, not that you searched. What did you LEARN or DISCOVER? What specific detail is now known? CRITICAL: Only use facts explicitly found in the activities - NEVER invent names, people, organizations, or details that are not present in the actual tool results.'
3035
3028
  );
3036
3029
  for (const [key, value] of Object.entries(jsonSchema.properties)) {
@@ -3099,11 +3092,10 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
3099
3092
  for (const event of events) {
3100
3093
  switch (event.eventType) {
3101
3094
  case "tool_execution": {
3102
- const data = event.data;
3103
- const resultStr = JSON.stringify(data.result);
3095
+ const resultStr = JSON.stringify(event.data.result);
3104
3096
  activities.push(
3105
- `\u{1F527} **${data.toolName}** ${data.duration ? `(${data.duration}ms)` : ""}
3106
- \u{1F4E5} Input: ${JSON.stringify(data.args)}
3097
+ `\u{1F527} **${event.data.toolName}** ${event.data.duration ? `(${event.data.duration}ms)` : ""}
3098
+ \u{1F4E5} Input: ${JSON.stringify(event.data.args)}
3107
3099
  \u{1F4E4} Output: ${resultStr}`
3108
3100
  );
3109
3101
  break;
@@ -3115,23 +3107,24 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
3115
3107
  case "artifact_saved":
3116
3108
  break;
3117
3109
  case "agent_reasoning": {
3118
- const data = event.data;
3119
3110
  activities.push(
3120
3111
  `\u2699\uFE0F **Analyzing request**
3121
- Details: ${JSON.stringify(data.parts, null, 2)}`
3112
+ Details: ${JSON.stringify(event.data.parts, null, 2)}`
3122
3113
  );
3123
3114
  break;
3124
3115
  }
3125
3116
  case "agent_generate": {
3126
- const data = event.data;
3127
3117
  activities.push(
3128
3118
  `\u2699\uFE0F **Preparing response**
3129
- Details: ${JSON.stringify(data.parts, null, 2)}`
3119
+ Details: ${JSON.stringify(event.data.parts, null, 2)}`
3130
3120
  );
3131
3121
  break;
3132
3122
  }
3133
3123
  default: {
3134
- activities.push(`\u{1F4CB} **${event.eventType}**: ${JSON.stringify(event.data, null, 2)}`);
3124
+ const safeEvent = event;
3125
+ activities.push(
3126
+ `\u{1F4CB} **${safeEvent.eventType}**: ${JSON.stringify(safeEvent.data, null, 2)}`
3127
+ );
3135
3128
  break;
3136
3129
  }
3137
3130
  }
@@ -3149,7 +3142,7 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
3149
3142
  "graph_session.id": this.sessionId,
3150
3143
  "artifact.id": artifactData.artifactId,
3151
3144
  "artifact.type": artifactData.artifactType || "unknown",
3152
- "artifact.agent_id": artifactData.agentId || "unknown",
3145
+ "artifact.agent_id": artifactData.subAgentId || "unknown",
3153
3146
  "artifact.tool_call_id": artifactData.metadata?.toolCallId || "unknown",
3154
3147
  "artifact.data": JSON.stringify(artifactData.data, null, 2),
3155
3148
  "tenant.id": artifactData.tenantId || "unknown",
@@ -3208,34 +3201,34 @@ Make it specific and relevant.`;
3208
3201
  let modelToUse = this.statusUpdateState?.summarizerModel;
3209
3202
  if (!modelToUse?.model?.trim()) {
3210
3203
  if (!this.statusUpdateState?.baseModel?.model?.trim()) {
3211
- if (artifactData.agentId && artifactData.tenantId && artifactData.projectId) {
3204
+ if (artifactData.subAgentId && artifactData.tenantId && artifactData.projectId) {
3212
3205
  try {
3213
- const agentData = await getAgentById(dbClient_default)({
3206
+ const agentData = await getSubAgentById(dbClient_default)({
3214
3207
  scopes: {
3215
3208
  tenantId: artifactData.tenantId,
3216
3209
  projectId: artifactData.projectId,
3217
3210
  graphId: this.graphId || ""
3218
3211
  },
3219
- agentId: artifactData.agentId
3212
+ subAgentId: artifactData.subAgentId
3220
3213
  });
3221
3214
  if (agentData && "models" in agentData && agentData.models?.base?.model) {
3222
3215
  modelToUse = agentData.models.base;
3223
- logger9.info(
3216
+ logger8.info(
3224
3217
  {
3225
3218
  sessionId: this.sessionId,
3226
3219
  artifactId: artifactData.artifactId,
3227
- agentId: artifactData.agentId,
3220
+ subAgentId: artifactData.subAgentId,
3228
3221
  model: modelToUse.model
3229
3222
  },
3230
3223
  "Using agent model configuration for artifact name generation"
3231
3224
  );
3232
3225
  }
3233
3226
  } catch (error) {
3234
- logger9.warn(
3227
+ logger8.warn(
3235
3228
  {
3236
3229
  sessionId: this.sessionId,
3237
3230
  artifactId: artifactData.artifactId,
3238
- agentId: artifactData.agentId,
3231
+ subAgentId: artifactData.subAgentId,
3239
3232
  error: error instanceof Error ? error.message : "Unknown error"
3240
3233
  },
3241
3234
  "Failed to get agent model configuration"
@@ -3243,7 +3236,7 @@ Make it specific and relevant.`;
3243
3236
  }
3244
3237
  }
3245
3238
  if (!modelToUse?.model?.trim()) {
3246
- logger9.warn(
3239
+ logger8.warn(
3247
3240
  {
3248
3241
  sessionId: this.sessionId,
3249
3242
  artifactId: artifactData.artifactId
@@ -3325,7 +3318,7 @@ Make it specific and relevant.`;
3325
3318
  return result2;
3326
3319
  } catch (error) {
3327
3320
  lastError = error instanceof Error ? error : new Error(String(error));
3328
- logger9.warn(
3321
+ logger8.warn(
3329
3322
  {
3330
3323
  sessionId: this.sessionId,
3331
3324
  artifactId: artifactData.artifactId,
@@ -3377,7 +3370,7 @@ Make it specific and relevant.`;
3377
3370
  });
3378
3371
  span.setStatus({ code: SpanStatusCode.OK });
3379
3372
  } catch (saveError) {
3380
- logger9.error(
3373
+ logger8.error(
3381
3374
  {
3382
3375
  sessionId: this.sessionId,
3383
3376
  artifactId: artifactData.artifactId,
@@ -3405,7 +3398,7 @@ Make it specific and relevant.`;
3405
3398
  metadata: artifactData.metadata || {},
3406
3399
  toolCallId: artifactData.toolCallId
3407
3400
  });
3408
- logger9.info(
3401
+ logger8.info(
3409
3402
  {
3410
3403
  sessionId: this.sessionId,
3411
3404
  artifactId: artifactData.artifactId
@@ -3416,7 +3409,7 @@ Make it specific and relevant.`;
3416
3409
  } catch (fallbackError) {
3417
3410
  const isDuplicateError = fallbackError instanceof Error && (fallbackError.message?.includes("UNIQUE") || fallbackError.message?.includes("duplicate"));
3418
3411
  if (isDuplicateError) ; else {
3419
- logger9.error(
3412
+ logger8.error(
3420
3413
  {
3421
3414
  sessionId: this.sessionId,
3422
3415
  artifactId: artifactData.artifactId,
@@ -3429,7 +3422,7 @@ Make it specific and relevant.`;
3429
3422
  }
3430
3423
  } catch (error) {
3431
3424
  setSpanWithError(span, error instanceof Error ? error : new Error(String(error)));
3432
- logger9.error(
3425
+ logger8.error(
3433
3426
  {
3434
3427
  sessionId: this.sessionId,
3435
3428
  artifactId: artifactData.artifactId,
@@ -3448,7 +3441,7 @@ Make it specific and relevant.`;
3448
3441
  */
3449
3442
  setArtifactCache(key, artifact) {
3450
3443
  this.artifactCache.set(key, artifact);
3451
- logger9.debug({ sessionId: this.sessionId, key }, "Artifact cached in session");
3444
+ logger8.debug({ sessionId: this.sessionId, key }, "Artifact cached in session");
3452
3445
  }
3453
3446
  /**
3454
3447
  * Get session-scoped ArtifactService instance
@@ -3467,7 +3460,7 @@ Make it specific and relevant.`;
3467
3460
  */
3468
3461
  getArtifactCache(key) {
3469
3462
  const artifact = this.artifactCache.get(key);
3470
- logger9.debug({ sessionId: this.sessionId, key, found: !!artifact }, "Artifact cache lookup");
3463
+ logger8.debug({ sessionId: this.sessionId, key, found: !!artifact }, "Artifact cache lookup");
3471
3464
  return artifact || null;
3472
3465
  }
3473
3466
  /**
@@ -3490,7 +3483,7 @@ var GraphSessionManager = class {
3490
3483
  const sessionId = messageId;
3491
3484
  const session = new GraphSession(sessionId, messageId, graphId, tenantId, projectId, contextId);
3492
3485
  this.sessions.set(sessionId, session);
3493
- logger9.info(
3486
+ logger8.info(
3494
3487
  { sessionId, messageId, graphId, tenantId, projectId, contextId },
3495
3488
  "GraphSession created"
3496
3489
  );
@@ -3504,7 +3497,7 @@ var GraphSessionManager = class {
3504
3497
  if (session) {
3505
3498
  session.initializeStatusUpdates(config, summarizerModel);
3506
3499
  } else {
3507
- logger9.error(
3500
+ logger8.error(
3508
3501
  {
3509
3502
  sessionId,
3510
3503
  availableSessions: Array.from(this.sessions.keys())
@@ -3521,7 +3514,7 @@ var GraphSessionManager = class {
3521
3514
  if (session) {
3522
3515
  session.enableEmitOperations();
3523
3516
  } else {
3524
- logger9.error(
3517
+ logger8.error(
3525
3518
  {
3526
3519
  sessionId,
3527
3520
  availableSessions: Array.from(this.sessions.keys())
@@ -3538,14 +3531,15 @@ var GraphSessionManager = class {
3538
3531
  }
3539
3532
  /**
3540
3533
  * Record an event in a session
3534
+ * Generic type parameter T ensures eventType and data are correctly paired
3541
3535
  */
3542
- recordEvent(sessionId, eventType, agentId, data) {
3536
+ recordEvent(sessionId, eventType, subAgentId, data) {
3543
3537
  const session = this.sessions.get(sessionId);
3544
3538
  if (!session) {
3545
- logger9.warn({ sessionId }, "Attempted to record event in non-existent session");
3539
+ logger8.warn({ sessionId }, "Attempted to record event in non-existent session");
3546
3540
  return;
3547
3541
  }
3548
- session.recordEvent(eventType, agentId, data);
3542
+ session.recordEvent(eventType, subAgentId, data);
3549
3543
  }
3550
3544
  /**
3551
3545
  * End a session and return the final event data
@@ -3553,12 +3547,12 @@ var GraphSessionManager = class {
3553
3547
  endSession(sessionId) {
3554
3548
  const session = this.sessions.get(sessionId);
3555
3549
  if (!session) {
3556
- logger9.warn({ sessionId }, "Attempted to end non-existent session");
3550
+ logger8.warn({ sessionId }, "Attempted to end non-existent session");
3557
3551
  return [];
3558
3552
  }
3559
3553
  const events = session.getEvents();
3560
3554
  const summary = session.getSummary();
3561
- logger9.info({ sessionId, summary }, "GraphSession ended");
3555
+ logger8.info({ sessionId, summary }, "GraphSession ended");
3562
3556
  session.cleanup();
3563
3557
  this.sessions.delete(sessionId);
3564
3558
  return events;
@@ -3657,7 +3651,7 @@ async function resolveModelConfig(graphId, agent) {
3657
3651
  }
3658
3652
 
3659
3653
  // src/services/IncrementalStreamParser.ts
3660
- var logger10 = getLogger("IncrementalStreamParser");
3654
+ var logger9 = getLogger("IncrementalStreamParser");
3661
3655
  var _IncrementalStreamParser = class _IncrementalStreamParser {
3662
3656
  // Max number of collected parts to prevent unbounded growth
3663
3657
  constructor(streamHelper, tenantId, contextId, artifactParserOptions) {
@@ -3673,10 +3667,11 @@ var _IncrementalStreamParser = class _IncrementalStreamParser {
3673
3667
  __publicField(this, "lastStreamedComponents", /* @__PURE__ */ new Map());
3674
3668
  __publicField(this, "componentSnapshots", /* @__PURE__ */ new Map());
3675
3669
  __publicField(this, "artifactMap");
3676
- __publicField(this, "agentId");
3670
+ __publicField(this, "subAgentId");
3671
+ __publicField(this, "allStreamedContent", []);
3677
3672
  this.streamHelper = streamHelper;
3678
3673
  this.contextId = contextId;
3679
- this.agentId = artifactParserOptions?.agentId;
3674
+ this.subAgentId = artifactParserOptions?.subAgentId;
3680
3675
  if (artifactParserOptions?.streamRequestId) {
3681
3676
  const sessionParser = graphSessionManager.getArtifactParser(
3682
3677
  artifactParserOptions.streamRequestId
@@ -3709,7 +3704,7 @@ var _IncrementalStreamParser = class _IncrementalStreamParser {
3709
3704
  async initializeArtifactMap() {
3710
3705
  try {
3711
3706
  this.artifactMap = await this.artifactParser.getContextArtifacts(this.contextId);
3712
- logger10.debug(
3707
+ logger9.debug(
3713
3708
  {
3714
3709
  contextId: this.contextId,
3715
3710
  artifactMapSize: this.artifactMap.size
@@ -3717,7 +3712,7 @@ var _IncrementalStreamParser = class _IncrementalStreamParser {
3717
3712
  "Initialized artifact map for streaming"
3718
3713
  );
3719
3714
  } catch (error) {
3720
- logger10.warn({ error, contextId: this.contextId }, "Failed to initialize artifact map");
3715
+ logger9.warn({ error, contextId: this.contextId }, "Failed to initialize artifact map");
3721
3716
  this.artifactMap = /* @__PURE__ */ new Map();
3722
3717
  }
3723
3718
  }
@@ -3792,10 +3787,12 @@ var _IncrementalStreamParser = class _IncrementalStreamParser {
3792
3787
  this.hasStartedRole = true;
3793
3788
  }
3794
3789
  await this.streamHelper.streamText(newText, 50);
3795
- this.collectedParts.push({
3790
+ const textPart = {
3796
3791
  kind: "text",
3797
3792
  text: newText
3798
- });
3793
+ };
3794
+ this.collectedParts.push(textPart);
3795
+ this.allStreamedContent.push(textPart);
3799
3796
  }
3800
3797
  continue;
3801
3798
  }
@@ -3819,7 +3816,7 @@ var _IncrementalStreamParser = class _IncrementalStreamParser {
3819
3816
  dataComponents: [component]
3820
3817
  },
3821
3818
  this.artifactMap,
3822
- this.agentId
3819
+ this.subAgentId
3823
3820
  );
3824
3821
  if (!Array.isArray(parts)) {
3825
3822
  console.warn("parseObject returned non-array:", parts);
@@ -3895,7 +3892,7 @@ var _IncrementalStreamParser = class _IncrementalStreamParser {
3895
3892
  dataComponents: [component]
3896
3893
  },
3897
3894
  this.artifactMap,
3898
- this.agentId
3895
+ this.subAgentId
3899
3896
  );
3900
3897
  for (const part of parts) {
3901
3898
  await this.streamPart(part);
@@ -3921,10 +3918,12 @@ var _IncrementalStreamParser = class _IncrementalStreamParser {
3921
3918
  if (this.pendingTextBuffer) {
3922
3919
  const cleanedText = this.pendingTextBuffer.replace(/<\/?artifact:ref(?:\s[^>]*)?>\/?>/g, "").replace(/<\/?artifact(?:\s[^>]*)?>\/?>/g, "").replace(/<\/artifact:ref>/g, "").replace(/<\/(?:\w+:)?artifact>/g, "");
3923
3920
  if (cleanedText) {
3924
- this.collectedParts.push({
3921
+ const textPart = {
3925
3922
  kind: "text",
3926
3923
  text: cleanedText
3927
- });
3924
+ };
3925
+ this.collectedParts.push(textPart);
3926
+ this.allStreamedContent.push(textPart);
3928
3927
  await this.streamHelper.streamText(cleanedText, 50);
3929
3928
  }
3930
3929
  this.pendingTextBuffer = "";
@@ -3939,6 +3938,12 @@ var _IncrementalStreamParser = class _IncrementalStreamParser {
3939
3938
  getCollectedParts() {
3940
3939
  return [...this.collectedParts];
3941
3940
  }
3941
+ /**
3942
+ * Get all streamed content that was actually sent to the user
3943
+ */
3944
+ getAllStreamedContent() {
3945
+ return [...this.allStreamedContent];
3946
+ }
3942
3947
  /**
3943
3948
  * Parse buffer for complete artifacts and text parts (for text streaming)
3944
3949
  */
@@ -3949,7 +3954,11 @@ var _IncrementalStreamParser = class _IncrementalStreamParser {
3949
3954
  const safeEnd = this.artifactParser.findSafeTextBoundary(workingBuffer);
3950
3955
  if (safeEnd > 0) {
3951
3956
  const safeText = workingBuffer.slice(0, safeEnd);
3952
- const parts2 = await this.artifactParser.parseText(safeText, this.artifactMap, this.agentId);
3957
+ const parts2 = await this.artifactParser.parseText(
3958
+ safeText,
3959
+ this.artifactMap,
3960
+ this.subAgentId
3961
+ );
3953
3962
  completeParts.push(...parts2);
3954
3963
  return {
3955
3964
  completeParts,
@@ -3964,7 +3973,7 @@ var _IncrementalStreamParser = class _IncrementalStreamParser {
3964
3973
  const parts = await this.artifactParser.parseText(
3965
3974
  workingBuffer,
3966
3975
  this.artifactMap,
3967
- this.agentId
3976
+ this.subAgentId
3968
3977
  );
3969
3978
  if (parts.length > 0 && parts[parts.length - 1].kind === "text") {
3970
3979
  const lastPart = parts[parts.length - 1];
@@ -3994,10 +4003,15 @@ var _IncrementalStreamParser = class _IncrementalStreamParser {
3994
4003
  */
3995
4004
  async streamPart(part) {
3996
4005
  this.collectedParts.push({ ...part });
4006
+ this.allStreamedContent.push({ ...part });
3997
4007
  if (this.collectedParts.length > _IncrementalStreamParser.MAX_COLLECTED_PARTS) {
3998
4008
  const excess = this.collectedParts.length - _IncrementalStreamParser.MAX_COLLECTED_PARTS;
3999
4009
  this.collectedParts.splice(0, excess);
4000
4010
  }
4011
+ if (this.allStreamedContent.length > _IncrementalStreamParser.MAX_COLLECTED_PARTS) {
4012
+ const excess = this.allStreamedContent.length - _IncrementalStreamParser.MAX_COLLECTED_PARTS;
4013
+ this.allStreamedContent.splice(0, excess);
4014
+ }
4001
4015
  if (!this.hasStartedRole) {
4002
4016
  await this.streamHelper.writeRole("assistant");
4003
4017
  this.hasStartedRole = true;
@@ -4037,12 +4051,12 @@ __publicField(_IncrementalStreamParser, "MAX_COLLECTED_PARTS", 1e4);
4037
4051
  var IncrementalStreamParser = _IncrementalStreamParser;
4038
4052
 
4039
4053
  // src/services/ResponseFormatter.ts
4040
- var logger11 = getLogger("ResponseFormatter");
4054
+ var logger10 = getLogger("ResponseFormatter");
4041
4055
  var ResponseFormatter = class {
4042
4056
  constructor(tenantId, artifactParserOptions) {
4043
4057
  __publicField(this, "artifactParser");
4044
- __publicField(this, "agentId");
4045
- this.agentId = artifactParserOptions?.agentId;
4058
+ __publicField(this, "subAgentId");
4059
+ this.subAgentId = artifactParserOptions?.subAgentId;
4046
4060
  if (artifactParserOptions?.streamRequestId) {
4047
4061
  const sessionParser = graphSessionManager.getArtifactParser(
4048
4062
  artifactParserOptions.streamRequestId
@@ -4081,7 +4095,7 @@ var ResponseFormatter = class {
4081
4095
  const parts = await this.artifactParser.parseObject(
4082
4096
  responseObject,
4083
4097
  artifactMap,
4084
- this.agentId
4098
+ this.subAgentId
4085
4099
  );
4086
4100
  const uniqueArtifacts = this.countUniqueArtifacts(parts);
4087
4101
  span.setAttributes({
@@ -4096,7 +4110,7 @@ var ResponseFormatter = class {
4096
4110
  return { parts };
4097
4111
  } catch (error) {
4098
4112
  setSpanWithError(span, error instanceof Error ? error : new Error(String(error)));
4099
- logger11.error({ error, responseObject }, "Error formatting object response");
4113
+ logger10.error({ error, responseObject }, "Error formatting object response");
4100
4114
  return {
4101
4115
  parts: [{ kind: "data", data: responseObject }]
4102
4116
  };
@@ -4128,7 +4142,11 @@ var ResponseFormatter = class {
4128
4142
  "response.type": "text",
4129
4143
  "response.availableArtifacts": artifactMap.size
4130
4144
  });
4131
- const parts = await this.artifactParser.parseText(responseText, artifactMap, this.agentId);
4145
+ const parts = await this.artifactParser.parseText(
4146
+ responseText,
4147
+ artifactMap,
4148
+ this.subAgentId
4149
+ );
4132
4150
  if (parts.length === 1 && parts[0].kind === "text") {
4133
4151
  return { text: parts[0].text };
4134
4152
  }
@@ -4148,7 +4166,7 @@ var ResponseFormatter = class {
4148
4166
  return { parts };
4149
4167
  } catch (error) {
4150
4168
  setSpanWithError(span, error instanceof Error ? error : new Error(String(error)));
4151
- logger11.error({ error, responseText }, "Error formatting response");
4169
+ logger10.error({ error, responseText }, "Error formatting response");
4152
4170
  return { text: responseText };
4153
4171
  } finally {
4154
4172
  span.end();
@@ -4202,20 +4220,20 @@ function agentInitializingOp(sessionId, graphId) {
4202
4220
  }
4203
4221
  };
4204
4222
  }
4205
- function completionOp(agentId, iterations) {
4223
+ function completionOp(subAgentId, iterations) {
4206
4224
  return {
4207
4225
  type: "completion",
4208
4226
  details: {
4209
- agent: agentId,
4227
+ agent: subAgentId,
4210
4228
  iteration: iterations
4211
4229
  }
4212
4230
  };
4213
4231
  }
4214
- function errorOp(message, agentId, severity = "error", code) {
4232
+ function errorOp(message, subAgentId, severity = "error", code) {
4215
4233
  return {
4216
4234
  type: "error",
4217
4235
  message,
4218
- agent: agentId,
4236
+ agent: subAgentId,
4219
4237
  severity,
4220
4238
  code,
4221
4239
  timestamp: Date.now()
@@ -4224,10 +4242,10 @@ function errorOp(message, agentId, severity = "error", code) {
4224
4242
  function generateToolId() {
4225
4243
  return `tool_${nanoid(8)}`;
4226
4244
  }
4227
- var logger12 = getLogger("DataComponentSchema");
4245
+ var logger11 = getLogger("DataComponentSchema");
4228
4246
  function jsonSchemaToZod(jsonSchema) {
4229
4247
  if (!jsonSchema || typeof jsonSchema !== "object") {
4230
- logger12.warn({ jsonSchema }, "Invalid JSON schema provided, using string fallback");
4248
+ logger11.warn({ jsonSchema }, "Invalid JSON schema provided, using string fallback");
4231
4249
  return z.string();
4232
4250
  }
4233
4251
  switch (jsonSchema.type) {
@@ -4254,7 +4272,7 @@ function jsonSchemaToZod(jsonSchema) {
4254
4272
  case "null":
4255
4273
  return z.null();
4256
4274
  default:
4257
- logger12.warn(
4275
+ logger11.warn(
4258
4276
  {
4259
4277
  unsupportedType: jsonSchema.type,
4260
4278
  schema: jsonSchema
@@ -4617,7 +4635,7 @@ function parseEmbeddedJson(data) {
4617
4635
  }
4618
4636
 
4619
4637
  // src/a2a/client.ts
4620
- var logger13 = getLogger("a2aClient");
4638
+ var logger12 = getLogger("a2aClient");
4621
4639
  var DEFAULT_BACKOFF = {
4622
4640
  initialInterval: 500,
4623
4641
  maxInterval: 6e4,
@@ -4823,7 +4841,7 @@ var A2AClient = class {
4823
4841
  try {
4824
4842
  const res = await fn();
4825
4843
  if (attempt > 0) {
4826
- logger13.info(
4844
+ logger12.info(
4827
4845
  {
4828
4846
  attempts: attempt + 1,
4829
4847
  elapsedTime: Date.now() - start
@@ -4838,7 +4856,7 @@ var A2AClient = class {
4838
4856
  }
4839
4857
  const elapsed = Date.now() - start;
4840
4858
  if (elapsed > maxElapsedTime) {
4841
- logger13.warn(
4859
+ logger12.warn(
4842
4860
  {
4843
4861
  attempts: attempt + 1,
4844
4862
  elapsedTime: elapsed,
@@ -4859,7 +4877,7 @@ var A2AClient = class {
4859
4877
  retryInterval = initialInterval * attempt ** exponent + Math.random() * 1e3;
4860
4878
  }
4861
4879
  const delayMs = Math.min(retryInterval, maxInterval);
4862
- logger13.info(
4880
+ logger12.info(
4863
4881
  {
4864
4882
  attempt: attempt + 1,
4865
4883
  delayMs,
@@ -4944,7 +4962,7 @@ var A2AClient = class {
4944
4962
  }
4945
4963
  const rpcResponse = await httpResponse.json();
4946
4964
  if (rpcResponse.id !== requestId2) {
4947
- logger13.warn(
4965
+ logger12.warn(
4948
4966
  {
4949
4967
  method,
4950
4968
  expectedId: requestId2,
@@ -5143,7 +5161,7 @@ var A2AClient = class {
5143
5161
  try {
5144
5162
  while (true) {
5145
5163
  const { done, value } = await reader.read();
5146
- logger13.info({ done, value }, "parseA2ASseStream");
5164
+ logger12.info({ done, value }, "parseA2ASseStream");
5147
5165
  if (done) {
5148
5166
  if (eventDataBuffer.trim()) {
5149
5167
  const result = this._processSseEventData(
@@ -5230,7 +5248,7 @@ var A2AClient = class {
5230
5248
  };
5231
5249
 
5232
5250
  // src/agents/relationTools.ts
5233
- var logger14 = getLogger("relationships Tools");
5251
+ var logger13 = getLogger("relationships Tools");
5234
5252
  var generateTransferToolDescription = (config) => {
5235
5253
  return `Hand off the conversation to agent ${config.id}.
5236
5254
 
@@ -5254,7 +5272,7 @@ Delegate a specific task to agent ${config.id} when it seems like the agent can
5254
5272
  var createTransferToAgentTool = ({
5255
5273
  transferConfig,
5256
5274
  callingAgentId,
5257
- agent,
5275
+ subAgent,
5258
5276
  streamRequestId
5259
5277
  }) => {
5260
5278
  return tool({
@@ -5264,11 +5282,11 @@ var createTransferToAgentTool = ({
5264
5282
  const activeSpan = trace.getActiveSpan();
5265
5283
  if (activeSpan) {
5266
5284
  activeSpan.setAttributes({
5267
- "transfer.from_agent_id": callingAgentId,
5268
- "transfer.to_agent_id": transferConfig.id ?? "unknown"
5285
+ [SPAN_KEYS.TRANSFER_FROM_SUB_AGENT_ID]: callingAgentId,
5286
+ [SPAN_KEYS.TRANSFER_TO_SUB_AGENT_ID]: transferConfig.id ?? "unknown"
5269
5287
  });
5270
5288
  }
5271
- logger14.info(
5289
+ logger13.info(
5272
5290
  {
5273
5291
  transferTo: transferConfig.id ?? "unknown",
5274
5292
  fromAgent: callingAgentId
@@ -5277,8 +5295,8 @@ var createTransferToAgentTool = ({
5277
5295
  );
5278
5296
  if (streamRequestId) {
5279
5297
  graphSessionManager.recordEvent(streamRequestId, "transfer", callingAgentId, {
5280
- fromAgent: callingAgentId,
5281
- targetAgent: transferConfig.id ?? "unknown",
5298
+ fromSubAgent: callingAgentId,
5299
+ targetSubAgent: transferConfig.id ?? "unknown",
5282
5300
  reason: `Transfer to ${transferConfig.name || transferConfig.id}`
5283
5301
  });
5284
5302
  }
@@ -5300,7 +5318,7 @@ function createDelegateToAgentTool({
5300
5318
  contextId,
5301
5319
  metadata,
5302
5320
  sessionId,
5303
- agent,
5321
+ subAgent,
5304
5322
  credentialStoreRegistry
5305
5323
  }) {
5306
5324
  return tool({
@@ -5311,9 +5329,9 @@ function createDelegateToAgentTool({
5311
5329
  const activeSpan = trace.getActiveSpan();
5312
5330
  if (activeSpan) {
5313
5331
  activeSpan.setAttributes({
5314
- "delegation.from_agent_id": callingAgentId,
5315
- "delegation.to_agent_id": delegateConfig.config.id ?? "unknown",
5316
- "delegation.id": delegationId
5332
+ [SPAN_KEYS.DELEGATION_FROM_SUB_AGENT_ID]: callingAgentId,
5333
+ [SPAN_KEYS.DELEGATION_TO_SUB_AGENT_ID]: delegateConfig.config.id ?? "unknown",
5334
+ [SPAN_KEYS.DELEGATION_ID]: delegationId
5317
5335
  });
5318
5336
  }
5319
5337
  if (metadata.streamRequestId) {
@@ -5323,8 +5341,8 @@ function createDelegateToAgentTool({
5323
5341
  callingAgentId,
5324
5342
  {
5325
5343
  delegationId,
5326
- fromAgent: callingAgentId,
5327
- targetAgent: delegateConfig.config.id,
5344
+ fromSubAgent: callingAgentId,
5345
+ targetSubAgent: delegateConfig.config.id,
5328
5346
  taskDescription: input.message
5329
5347
  }
5330
5348
  );
@@ -5338,7 +5356,7 @@ function createDelegateToAgentTool({
5338
5356
  projectId,
5339
5357
  graphId
5340
5358
  },
5341
- agentId: delegateConfig.config.id
5359
+ subAgentId: delegateConfig.config.id
5342
5360
  });
5343
5361
  if (externalAgent && (externalAgent.credentialReferenceId || externalAgent.headers) && credentialStoreRegistry) {
5344
5362
  const contextResolver = new ContextResolver(
@@ -5417,7 +5435,7 @@ function createDelegateToAgentTool({
5417
5435
  ...isInternal ? { fromAgentId: callingAgentId } : { fromExternalAgentId: callingAgentId }
5418
5436
  }
5419
5437
  };
5420
- logger14.info({ messageToSend }, "messageToSend");
5438
+ logger13.info({ messageToSend }, "messageToSend");
5421
5439
  await createMessage(dbClient_default)({
5422
5440
  id: nanoid(),
5423
5441
  tenantId,
@@ -5429,7 +5447,7 @@ function createDelegateToAgentTool({
5429
5447
  },
5430
5448
  visibility: isInternal ? "internal" : "external",
5431
5449
  messageType: "a2a-request",
5432
- fromAgentId: callingAgentId,
5450
+ fromSubAgentId: callingAgentId,
5433
5451
  ...isInternal ? { toAgentId: delegateConfig.config.id } : { toExternalAgentId: delegateConfig.config.id }
5434
5452
  });
5435
5453
  const response = await a2aClient.sendMessage({
@@ -5444,8 +5462,8 @@ function createDelegateToAgentTool({
5444
5462
  conversationId: contextId,
5445
5463
  messageType: "a2a-response",
5446
5464
  visibility: isInternal ? "internal" : "external",
5447
- toAgentId: callingAgentId,
5448
- ...isInternal ? { fromAgentId: delegateConfig.config.id } : { fromExternalAgentId: delegateConfig.config.id }
5465
+ toSubAgentId: callingAgentId,
5466
+ ...isInternal ? { fromSubAgentId: delegateConfig.config.id } : { fromExternalAgentId: delegateConfig.config.id }
5449
5467
  });
5450
5468
  if (sessionId && context?.toolCallId) {
5451
5469
  const toolResult = {
@@ -5464,8 +5482,8 @@ function createDelegateToAgentTool({
5464
5482
  callingAgentId,
5465
5483
  {
5466
5484
  delegationId,
5467
- fromAgent: delegateConfig.config.id,
5468
- targetAgent: callingAgentId,
5485
+ fromSubAgent: delegateConfig.config.id,
5486
+ targetSubAgent: callingAgentId,
5469
5487
  result: response.result
5470
5488
  }
5471
5489
  );
@@ -5479,7 +5497,7 @@ function createDelegateToAgentTool({
5479
5497
  }
5480
5498
 
5481
5499
  // src/agents/SystemPromptBuilder.ts
5482
- var logger15 = getLogger("SystemPromptBuilder");
5500
+ var logger14 = getLogger("SystemPromptBuilder");
5483
5501
  var SystemPromptBuilder = class {
5484
5502
  constructor(version, versionConfig) {
5485
5503
  this.version = version;
@@ -5495,12 +5513,12 @@ var SystemPromptBuilder = class {
5495
5513
  this.templates.set(name, content);
5496
5514
  }
5497
5515
  this.loaded = true;
5498
- logger15.debug(
5516
+ logger14.debug(
5499
5517
  { templateCount: this.templates.size, version: this.version },
5500
5518
  `Loaded ${this.templates.size} templates for version ${this.version}`
5501
5519
  );
5502
5520
  } catch (error) {
5503
- logger15.error({ error }, `Failed to load templates for version ${this.version}`);
5521
+ logger14.error({ error }, `Failed to load templates for version ${this.version}`);
5504
5522
  throw new Error(`Template loading failed: ${error}`);
5505
5523
  }
5506
5524
  }
@@ -6560,7 +6578,7 @@ function hasToolCallWithPrefix(prefix) {
6560
6578
  return false;
6561
6579
  };
6562
6580
  }
6563
- var logger17 = getLogger("Agent");
6581
+ var logger16 = getLogger("Agent");
6564
6582
  var CONSTANTS = {
6565
6583
  MAX_GENERATION_STEPS: 12,
6566
6584
  PHASE_1_TIMEOUT_MS: 27e4,
@@ -6790,7 +6808,7 @@ var Agent = class {
6790
6808
  }
6791
6809
  getRelationTools(runtimeContext, sessionId) {
6792
6810
  const { transferRelations = [], delegateRelations = [] } = this.config;
6793
- const createToolName = (prefix, agentId) => `${prefix}_to_${agentId.toLowerCase().replace(/\s+/g, "_")}`;
6811
+ const createToolName = (prefix, subAgentId) => `${prefix}_to_${subAgentId.toLowerCase().replace(/\s+/g, "_")}`;
6794
6812
  return Object.fromEntries([
6795
6813
  ...transferRelations.map((agentConfig) => {
6796
6814
  const toolName = createToolName("transfer", agentConfig.id);
@@ -6801,7 +6819,7 @@ var Agent = class {
6801
6819
  createTransferToAgentTool({
6802
6820
  transferConfig: agentConfig,
6803
6821
  callingAgentId: this.config.id,
6804
- agent: this,
6822
+ subAgent: this,
6805
6823
  streamRequestId: runtimeContext?.metadata?.streamRequestId
6806
6824
  }),
6807
6825
  runtimeContext?.metadata?.streamRequestId,
@@ -6830,7 +6848,7 @@ var Agent = class {
6830
6848
  apiKey: runtimeContext?.metadata?.apiKey
6831
6849
  },
6832
6850
  sessionId,
6833
- agent: this,
6851
+ subAgent: this,
6834
6852
  credentialStoreRegistry: this.credentialStoreRegistry
6835
6853
  }),
6836
6854
  runtimeContext?.metadata?.streamRequestId,
@@ -6864,14 +6882,14 @@ var Agent = class {
6864
6882
  for (const toolSet of tools) {
6865
6883
  for (const [toolName, originalTool] of Object.entries(toolSet)) {
6866
6884
  if (!isValidTool(originalTool)) {
6867
- logger17.error({ toolName }, "Invalid MCP tool structure - missing required properties");
6885
+ logger16.error({ toolName }, "Invalid MCP tool structure - missing required properties");
6868
6886
  continue;
6869
6887
  }
6870
6888
  const sessionWrappedTool = tool({
6871
6889
  description: originalTool.description,
6872
6890
  inputSchema: originalTool.inputSchema,
6873
6891
  execute: async (args, { toolCallId }) => {
6874
- logger17.debug({ toolName, toolCallId }, "MCP Tool Called");
6892
+ logger16.debug({ toolName, toolCallId }, "MCP Tool Called");
6875
6893
  try {
6876
6894
  const rawResult = await originalTool.execute(args, { toolCallId });
6877
6895
  const parsedResult = parseEmbeddedJson(rawResult);
@@ -6885,7 +6903,7 @@ var Agent = class {
6885
6903
  });
6886
6904
  return { result: enhancedResult, toolCallId };
6887
6905
  } catch (error) {
6888
- logger17.error({ toolName, toolCallId, error }, "MCP tool execution failed");
6906
+ logger16.error({ toolName, toolCallId, error }, "MCP tool execution failed");
6889
6907
  throw error;
6890
6908
  }
6891
6909
  }
@@ -6930,7 +6948,7 @@ var Agent = class {
6930
6948
  tenantId: this.config.tenantId,
6931
6949
  projectId: this.config.projectId,
6932
6950
  graphId: this.config.graphId,
6933
- agentId: this.config.id
6951
+ subAgentId: this.config.id
6934
6952
  }
6935
6953
  });
6936
6954
  const agentToolRelationHeaders = toolsForAgent.data.find((t) => t.toolId === tool3.id)?.headers || void 0;
@@ -6986,7 +7004,7 @@ var Agent = class {
6986
7004
  headers: agentToolRelationHeaders
6987
7005
  };
6988
7006
  }
6989
- logger17.info(
7007
+ logger16.info(
6990
7008
  {
6991
7009
  toolName: tool3.name,
6992
7010
  credentialReferenceId,
@@ -7011,10 +7029,10 @@ var Agent = class {
7011
7029
  this.mcpClientCache.set(cacheKey, client);
7012
7030
  } catch (error) {
7013
7031
  this.mcpConnectionLocks.delete(cacheKey);
7014
- logger17.error(
7032
+ logger16.error(
7015
7033
  {
7016
7034
  toolName: tool3.name,
7017
- agentId: this.config.id,
7035
+ subAgentId: this.config.id,
7018
7036
  cacheKey,
7019
7037
  error: error instanceof Error ? error.message : String(error)
7020
7038
  },
@@ -7024,6 +7042,45 @@ var Agent = class {
7024
7042
  }
7025
7043
  }
7026
7044
  const tools = await client.tools();
7045
+ if (!tools || Object.keys(tools).length === 0) {
7046
+ const streamRequestId = this.getStreamRequestId();
7047
+ if (streamRequestId) {
7048
+ tracer.startActiveSpan(
7049
+ "ai.toolCall",
7050
+ {
7051
+ attributes: {
7052
+ "ai.toolCall.name": tool3.name,
7053
+ "ai.toolCall.args": JSON.stringify({ operation: "mcp_tool_discovery" }),
7054
+ "ai.toolCall.result": JSON.stringify({
7055
+ status: "no_tools_available",
7056
+ message: `MCP server has 0 effective tools. Double check the selected tools in your graph and the active tools in the MCP server configuration.`,
7057
+ serverUrl: tool3.config.type === "mcp" ? tool3.config.mcp.server.url : "unknown",
7058
+ originalToolName: tool3.name
7059
+ }),
7060
+ "ai.toolType": "mcp",
7061
+ "ai.agentName": this.config.name || "unknown",
7062
+ "conversation.id": this.conversationId || "unknown",
7063
+ "graph.id": this.config.graphId || "unknown",
7064
+ "tenant.id": this.config.tenantId || "unknown",
7065
+ "project.id": this.config.projectId || "unknown"
7066
+ }
7067
+ },
7068
+ (span) => {
7069
+ setSpanWithError(span, new Error(`0 effective tools available for ${tool3.name}`));
7070
+ graphSessionManager.recordEvent(streamRequestId, "tool_execution", this.config.id, {
7071
+ toolName: tool3.name,
7072
+ args: { operation: "mcp_tool_discovery" },
7073
+ result: {
7074
+ status: "no_tools_available",
7075
+ message: `MCP server has 0 effective tools. Double check the selected tools in your graph and the active tools in the MCP server configuration.`,
7076
+ serverUrl: tool3.config.type === "mcp" ? tool3.config.mcp.server.url : "unknown"
7077
+ }
7078
+ });
7079
+ span.end();
7080
+ }
7081
+ );
7082
+ }
7083
+ }
7027
7084
  return tools;
7028
7085
  }
7029
7086
  async createMcpConnection(tool3, serverConfig) {
@@ -7035,99 +7092,120 @@ var Agent = class {
7035
7092
  await client.connect();
7036
7093
  return client;
7037
7094
  } catch (error) {
7038
- logger17.error(
7095
+ logger16.error(
7039
7096
  {
7040
7097
  toolName: tool3.name,
7041
- agentId: this.config.id,
7098
+ subAgentId: this.config.id,
7042
7099
  error: error instanceof Error ? error.message : String(error)
7043
7100
  },
7044
7101
  "Agent failed to connect to MCP server"
7045
7102
  );
7103
+ if (error instanceof Error) {
7104
+ if (error?.cause && JSON.stringify(error.cause).includes("ECONNREFUSED")) {
7105
+ const errorMessage = "Connection refused. Please check if the MCP server is running.";
7106
+ throw new Error(errorMessage);
7107
+ } else if (error.message.includes("404")) {
7108
+ const errorMessage = "Error accessing endpoint (HTTP 404)";
7109
+ throw new Error(errorMessage);
7110
+ } else {
7111
+ throw new Error(`MCP server connection failed: ${error.message}`);
7112
+ }
7113
+ }
7046
7114
  throw error;
7047
7115
  }
7048
7116
  }
7049
7117
  async getFunctionTools(sessionId, streamRequestId) {
7050
7118
  const functionTools = {};
7051
7119
  try {
7052
- const toolsForAgent = await getToolsForAgent(dbClient_default)({
7120
+ const functionToolsForAgent = await getFunctionToolsForSubAgent(dbClient_default)({
7053
7121
  scopes: {
7054
- tenantId: this.config.tenantId || "default",
7055
- projectId: this.config.projectId || "default",
7056
- graphId: this.config.graphId,
7057
- agentId: this.config.id
7058
- }
7122
+ tenantId: this.config.tenantId,
7123
+ projectId: this.config.projectId,
7124
+ graphId: this.config.graphId
7125
+ },
7126
+ subAgentId: this.config.id
7059
7127
  });
7060
- const toolsData = toolsForAgent.data || [];
7061
- const functionToolDefs = toolsData.filter((tool3) => tool3.tool.config.type === "function");
7062
- if (functionToolDefs.length === 0) {
7128
+ const functionToolsData = functionToolsForAgent.data || [];
7129
+ if (functionToolsData.length === 0) {
7063
7130
  return functionTools;
7064
7131
  }
7065
- const { LocalSandboxExecutor } = await import('./LocalSandboxExecutor-JI4X2Z3N.js');
7132
+ const { LocalSandboxExecutor } = await import('./LocalSandboxExecutor-2UQ32ZZH.js');
7066
7133
  const sandboxExecutor = LocalSandboxExecutor.getInstance();
7067
- for (const toolDef of functionToolDefs) {
7068
- if (toolDef.tool.config?.type === "function") {
7069
- const functionId = toolDef.tool.functionId;
7070
- if (!functionId) {
7071
- logger17.warn({ toolId: toolDef.tool.id }, "Function tool missing functionId reference");
7072
- continue;
7134
+ for (const functionToolDef of functionToolsData) {
7135
+ const functionId = functionToolDef.functionId;
7136
+ if (!functionId) {
7137
+ logger16.warn(
7138
+ { functionToolId: functionToolDef.id },
7139
+ "Function tool missing functionId reference"
7140
+ );
7141
+ continue;
7142
+ }
7143
+ const functionData = await getFunction(dbClient_default)({
7144
+ functionId,
7145
+ scopes: {
7146
+ tenantId: this.config.tenantId || "default",
7147
+ projectId: this.config.projectId || "default"
7073
7148
  }
7074
- const functionData = await getFunction(dbClient_default)({
7075
- functionId,
7076
- scopes: {
7077
- tenantId: this.config.tenantId || "default",
7078
- projectId: this.config.projectId || "default"
7079
- }
7080
- });
7081
- if (!functionData) {
7082
- logger17.warn(
7083
- { functionId, toolId: toolDef.tool.id },
7084
- "Function not found in functions table"
7149
+ });
7150
+ if (!functionData) {
7151
+ logger16.warn(
7152
+ { functionId, functionToolId: functionToolDef.id },
7153
+ "Function not found in functions table"
7154
+ );
7155
+ continue;
7156
+ }
7157
+ const zodSchema = jsonSchemaToZod(functionData.inputSchema);
7158
+ const aiTool = tool({
7159
+ description: functionToolDef.description || functionToolDef.name,
7160
+ inputSchema: zodSchema,
7161
+ execute: async (args, { toolCallId }) => {
7162
+ logger16.debug(
7163
+ { toolName: functionToolDef.name, toolCallId, args },
7164
+ "Function Tool Called"
7085
7165
  );
7086
- continue;
7087
- }
7088
- const zodSchema = jsonSchemaToZod(functionData.inputSchema);
7089
- const aiTool = tool({
7090
- description: toolDef.tool.description || toolDef.tool.name,
7091
- inputSchema: zodSchema,
7092
- execute: async (args, { toolCallId }) => {
7093
- logger17.debug(
7094
- { toolName: toolDef.tool.name, toolCallId, args },
7095
- "Function Tool Called"
7166
+ try {
7167
+ const project = await getProject(dbClient_default)({
7168
+ scopes: { tenantId: this.config.tenantId, projectId: this.config.projectId }
7169
+ });
7170
+ const defaultSandboxConfig = {
7171
+ provider: "local",
7172
+ runtime: "node22",
7173
+ timeout: 3e4,
7174
+ vcpus: 1
7175
+ };
7176
+ const result = await sandboxExecutor.executeFunctionTool(functionToolDef.id, args, {
7177
+ description: functionToolDef.description || functionToolDef.name,
7178
+ inputSchema: functionData.inputSchema || {},
7179
+ executeCode: functionData.executeCode,
7180
+ dependencies: functionData.dependencies || {},
7181
+ sandboxConfig: project?.sandboxConfig || defaultSandboxConfig
7182
+ });
7183
+ toolSessionManager.recordToolResult(sessionId || "", {
7184
+ toolCallId,
7185
+ toolName: functionToolDef.name,
7186
+ args,
7187
+ result,
7188
+ timestamp: Date.now()
7189
+ });
7190
+ return { result, toolCallId };
7191
+ } catch (error) {
7192
+ logger16.error(
7193
+ { toolName: functionToolDef.name, toolCallId, error },
7194
+ "Function tool execution failed"
7096
7195
  );
7097
- try {
7098
- const result = await sandboxExecutor.executeFunctionTool(toolDef.tool.id, args, {
7099
- description: toolDef.tool.description || toolDef.tool.name,
7100
- inputSchema: functionData.inputSchema || {},
7101
- executeCode: functionData.executeCode,
7102
- dependencies: functionData.dependencies || {}
7103
- });
7104
- toolSessionManager.recordToolResult(sessionId || "", {
7105
- toolCallId,
7106
- toolName: toolDef.tool.name,
7107
- args,
7108
- result,
7109
- timestamp: Date.now()
7110
- });
7111
- return { result, toolCallId };
7112
- } catch (error) {
7113
- logger17.error(
7114
- { toolName: toolDef.tool.name, toolCallId, error },
7115
- "Function tool execution failed"
7116
- );
7117
- throw error;
7118
- }
7196
+ throw error;
7119
7197
  }
7120
- });
7121
- functionTools[toolDef.tool.name] = this.wrapToolWithStreaming(
7122
- toolDef.tool.name,
7123
- aiTool,
7124
- streamRequestId || "",
7125
- "tool"
7126
- );
7127
- }
7198
+ }
7199
+ });
7200
+ functionTools[functionToolDef.name] = this.wrapToolWithStreaming(
7201
+ functionToolDef.name,
7202
+ aiTool,
7203
+ streamRequestId || "",
7204
+ "tool"
7205
+ );
7128
7206
  }
7129
7207
  } catch (error) {
7130
- logger17.error({ error }, "Failed to load function tools from database");
7208
+ logger16.error({ error }, "Failed to load function tools from database");
7131
7209
  }
7132
7210
  return functionTools;
7133
7211
  }
@@ -7137,7 +7215,7 @@ var Agent = class {
7137
7215
  async getResolvedContext(conversationId, headers) {
7138
7216
  try {
7139
7217
  if (!this.config.contextConfigId) {
7140
- logger17.debug({ graphId: this.config.graphId }, "No context config found for graph");
7218
+ logger16.debug({ graphId: this.config.graphId }, "No context config found for graph");
7141
7219
  return null;
7142
7220
  }
7143
7221
  const contextConfig = await getContextConfigById(dbClient_default)({
@@ -7149,7 +7227,7 @@ var Agent = class {
7149
7227
  id: this.config.contextConfigId
7150
7228
  });
7151
7229
  if (!contextConfig) {
7152
- logger17.warn({ contextConfigId: this.config.contextConfigId }, "Context config not found");
7230
+ logger16.warn({ contextConfigId: this.config.contextConfigId }, "Context config not found");
7153
7231
  return null;
7154
7232
  }
7155
7233
  if (!this.contextResolver) {
@@ -7166,7 +7244,7 @@ var Agent = class {
7166
7244
  $now: (/* @__PURE__ */ new Date()).toISOString(),
7167
7245
  $env: process.env
7168
7246
  };
7169
- logger17.debug(
7247
+ logger16.debug(
7170
7248
  {
7171
7249
  conversationId,
7172
7250
  contextConfigId: contextConfig.id,
@@ -7180,7 +7258,7 @@ var Agent = class {
7180
7258
  );
7181
7259
  return contextWithBuiltins;
7182
7260
  } catch (error) {
7183
- logger17.error(
7261
+ logger16.error(
7184
7262
  {
7185
7263
  conversationId,
7186
7264
  error: error instanceof Error ? error.message : "Unknown error"
@@ -7204,7 +7282,7 @@ var Agent = class {
7204
7282
  });
7205
7283
  return graphDefinition?.graphPrompt || void 0;
7206
7284
  } catch (error) {
7207
- logger17.warn(
7285
+ logger16.warn(
7208
7286
  {
7209
7287
  graphId: this.config.graphId,
7210
7288
  error: error instanceof Error ? error.message : "Unknown error"
@@ -7229,11 +7307,11 @@ var Agent = class {
7229
7307
  if (!graphDefinition) {
7230
7308
  return false;
7231
7309
  }
7232
- return Object.values(graphDefinition.agents).some(
7233
- (agent) => "artifactComponents" in agent && agent.artifactComponents && agent.artifactComponents.length > 0
7310
+ return Object.values(graphDefinition.subAgents).some(
7311
+ (subAgent) => "artifactComponents" in subAgent && subAgent.artifactComponents && subAgent.artifactComponents.length > 0
7234
7312
  );
7235
7313
  } catch (error) {
7236
- logger17.warn(
7314
+ logger16.warn(
7237
7315
  {
7238
7316
  graphId: this.config.graphId,
7239
7317
  tenantId: this.config.tenantId,
@@ -7262,7 +7340,7 @@ var Agent = class {
7262
7340
  preserveUnresolved: false
7263
7341
  });
7264
7342
  } catch (error) {
7265
- logger17.error(
7343
+ logger16.error(
7266
7344
  {
7267
7345
  conversationId,
7268
7346
  error: error instanceof Error ? error.message : "Unknown error"
@@ -7309,7 +7387,7 @@ var Agent = class {
7309
7387
  preserveUnresolved: false
7310
7388
  });
7311
7389
  } catch (error) {
7312
- logger17.error(
7390
+ logger16.error(
7313
7391
  {
7314
7392
  conversationId,
7315
7393
  error: error instanceof Error ? error.message : "Unknown error"
@@ -7324,7 +7402,7 @@ var Agent = class {
7324
7402
  const functionTools = await this.getFunctionTools(streamRequestId || "");
7325
7403
  const relationTools = this.getRelationTools(runtimeContext);
7326
7404
  const allTools = { ...mcpTools, ...functionTools, ...relationTools };
7327
- logger17.info(
7405
+ logger16.info(
7328
7406
  {
7329
7407
  mcpTools: Object.keys(mcpTools),
7330
7408
  functionTools: Object.keys(functionTools),
@@ -7345,7 +7423,7 @@ var Agent = class {
7345
7423
  inputSchema: tool3.inputSchema || tool3.parameters || {},
7346
7424
  usageGuidelines: name.startsWith("transfer_to_") || name.startsWith("delegate_to_") ? `Use this tool to ${name.startsWith("transfer_to_") ? "transfer" : "delegate"} to another agent when appropriate.` : "Use this tool when appropriate for the task at hand."
7347
7425
  }));
7348
- const { getConversationScopedArtifacts } = await import('./conversations-6HJ4FX5F.js');
7426
+ const { getConversationScopedArtifacts } = await import('./conversations-JSORLLWS.js');
7349
7427
  const historyConfig = this.config.conversationHistoryConfig ?? createDefaultConversationHistoryConfig();
7350
7428
  const referenceArtifacts = await getConversationScopedArtifacts({
7351
7429
  tenantId: this.config.tenantId,
@@ -7363,7 +7441,7 @@ var Agent = class {
7363
7441
  preserveUnresolved: false
7364
7442
  });
7365
7443
  } catch (error) {
7366
- logger17.error(
7444
+ logger16.error(
7367
7445
  {
7368
7446
  conversationId,
7369
7447
  error: error instanceof Error ? error.message : "Unknown error"
@@ -7396,7 +7474,7 @@ var Agent = class {
7396
7474
  toolCallId: z.string().describe("The tool call ID associated with this artifact.")
7397
7475
  }),
7398
7476
  execute: async ({ artifactId, toolCallId }) => {
7399
- logger17.info({ artifactId, toolCallId }, "get_artifact_full executed");
7477
+ logger16.info({ artifactId, toolCallId }, "get_artifact_full executed");
7400
7478
  const streamRequestId = this.getStreamRequestId();
7401
7479
  const artifactService = graphSessionManager.getArtifactService(streamRequestId);
7402
7480
  if (!artifactService) {
@@ -7430,7 +7508,7 @@ var Agent = class {
7430
7508
  });
7431
7509
  }
7432
7510
  // Provide a default tool set that is always available to the agent.
7433
- async getDefaultTools(_sessionId, streamRequestId) {
7511
+ async getDefaultTools(streamRequestId) {
7434
7512
  const defaultTools = {};
7435
7513
  if (await this.graphHasArtifactComponents()) {
7436
7514
  defaultTools.get_reference_artifact = this.getArtifactTools();
@@ -7656,7 +7734,7 @@ var Agent = class {
7656
7734
  };
7657
7735
  return enhanced;
7658
7736
  } catch (error) {
7659
- logger17.warn({ error }, "Failed to enhance tool result with structure hints");
7737
+ logger16.warn({ error }, "Failed to enhance tool result with structure hints");
7660
7738
  return result;
7661
7739
  }
7662
7740
  }
@@ -7671,7 +7749,7 @@ var Agent = class {
7671
7749
  }
7672
7750
  });
7673
7751
  } catch (error) {
7674
- logger17.error(
7752
+ logger16.error(
7675
7753
  { error, graphId: this.config.graphId },
7676
7754
  "Failed to check graph artifact components"
7677
7755
  );
@@ -7716,7 +7794,7 @@ var Agent = class {
7716
7794
  // Thinking prompt without data components
7717
7795
  this.getFunctionTools(sessionId, streamRequestId),
7718
7796
  Promise.resolve(this.getRelationTools(runtimeContext, sessionId)),
7719
- this.getDefaultTools(sessionId, streamRequestId)
7797
+ this.getDefaultTools(streamRequestId)
7720
7798
  ]);
7721
7799
  childSpan.setStatus({ code: SpanStatusCode.OK });
7722
7800
  return result;
@@ -7756,7 +7834,7 @@ var Agent = class {
7756
7834
  currentMessage: userMessage,
7757
7835
  options: historyConfig,
7758
7836
  filters: {
7759
- agentId: this.config.id,
7837
+ subAgentId: this.config.id,
7760
7838
  taskId
7761
7839
  }
7762
7840
  });
@@ -7772,7 +7850,7 @@ var Agent = class {
7772
7850
  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;
7773
7851
  const timeoutMs = Math.min(configuredTimeout, MAX_ALLOWED_TIMEOUT_MS);
7774
7852
  if (modelSettings.maxDuration && modelSettings.maxDuration * 1e3 > MAX_ALLOWED_TIMEOUT_MS) {
7775
- logger17.warn(
7853
+ logger16.warn(
7776
7854
  {
7777
7855
  requestedTimeout: modelSettings.maxDuration * 1e3,
7778
7856
  appliedTimeout: timeoutMs,
@@ -7814,7 +7892,7 @@ var Agent = class {
7814
7892
  }
7815
7893
  );
7816
7894
  } catch (error) {
7817
- logger17.debug({ error }, "Failed to track agent reasoning");
7895
+ logger16.debug({ error }, "Failed to track agent reasoning");
7818
7896
  }
7819
7897
  }
7820
7898
  if (last && "toolCalls" in last && last.toolCalls) {
@@ -7841,7 +7919,7 @@ var Agent = class {
7841
7919
  projectId: session?.projectId,
7842
7920
  artifactComponents: this.artifactComponents,
7843
7921
  streamRequestId: this.getStreamRequestId(),
7844
- agentId: this.config.id
7922
+ subAgentId: this.config.id
7845
7923
  };
7846
7924
  const parser = new IncrementalStreamParser(
7847
7925
  streamHelper,
@@ -7886,6 +7964,16 @@ var Agent = class {
7886
7964
  }))
7887
7965
  };
7888
7966
  }
7967
+ const streamedContent = parser.getAllStreamedContent();
7968
+ if (streamedContent.length > 0) {
7969
+ response.streamedContent = {
7970
+ parts: streamedContent.map((part) => ({
7971
+ kind: part.kind,
7972
+ ...part.kind === "text" && { text: part.text },
7973
+ ...part.kind === "data" && { data: part.data }
7974
+ }))
7975
+ };
7976
+ }
7889
7977
  } else {
7890
7978
  let genConfig;
7891
7979
  if (hasStructuredOutput) {
@@ -7918,7 +8006,7 @@ var Agent = class {
7918
8006
  }
7919
8007
  );
7920
8008
  } catch (error) {
7921
- logger17.debug({ error }, "Failed to track agent reasoning");
8009
+ logger16.debug({ error }, "Failed to track agent reasoning");
7922
8010
  }
7923
8011
  }
7924
8012
  if (last && "toolCalls" in last && last.toolCalls) {
@@ -8090,7 +8178,7 @@ ${output}${structureHintsFormatted}`;
8090
8178
  projectId: session?.projectId,
8091
8179
  artifactComponents: this.artifactComponents,
8092
8180
  streamRequestId: this.getStreamRequestId(),
8093
- agentId: this.config.id
8181
+ subAgentId: this.config.id
8094
8182
  };
8095
8183
  const parser = new IncrementalStreamParser(
8096
8184
  streamHelper,
@@ -8173,7 +8261,7 @@ ${output}${structureHintsFormatted}`;
8173
8261
  contextId,
8174
8262
  artifactComponents: this.artifactComponents,
8175
8263
  streamRequestId: this.getStreamRequestId(),
8176
- agentId: this.config.id
8264
+ subAgentId: this.config.id
8177
8265
  });
8178
8266
  if (response.object) {
8179
8267
  formattedContent = await responseFormatter.formatObjectResponse(
@@ -8210,7 +8298,7 @@ ${output}${structureHintsFormatted}`;
8210
8298
  };
8211
8299
 
8212
8300
  // src/agents/generateTaskHandler.ts
8213
- var logger18 = getLogger("generateTaskHandler");
8301
+ var logger17 = getLogger("generateTaskHandler");
8214
8302
  var createTaskHandler = (config, credentialStoreRegistry) => {
8215
8303
  return async (task) => {
8216
8304
  try {
@@ -8236,14 +8324,14 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
8236
8324
  projectId: config.projectId,
8237
8325
  graphId: config.graphId
8238
8326
  },
8239
- agentId: config.agentId
8327
+ subAgentId: config.subAgentId
8240
8328
  }),
8241
8329
  getToolsForAgent(dbClient_default)({
8242
8330
  scopes: {
8243
8331
  tenantId: config.tenantId,
8244
8332
  projectId: config.projectId,
8245
8333
  graphId: config.graphId,
8246
- agentId: config.agentId
8334
+ subAgentId: config.subAgentId
8247
8335
  }
8248
8336
  }),
8249
8337
  getDataComponentsForAgent(dbClient_default)({
@@ -8251,7 +8339,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
8251
8339
  tenantId: config.tenantId,
8252
8340
  projectId: config.projectId,
8253
8341
  graphId: config.graphId,
8254
- agentId: config.agentId
8342
+ subAgentId: config.subAgentId
8255
8343
  }
8256
8344
  }),
8257
8345
  getArtifactComponentsForAgent(dbClient_default)({
@@ -8259,21 +8347,21 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
8259
8347
  tenantId: config.tenantId,
8260
8348
  projectId: config.projectId,
8261
8349
  graphId: config.graphId,
8262
- agentId: config.agentId
8350
+ subAgentId: config.subAgentId
8263
8351
  }
8264
8352
  })
8265
8353
  ]);
8266
- logger18.info({ toolsForAgent, internalRelations, externalRelations }, "agent stuff");
8354
+ logger17.info({ toolsForAgent, internalRelations, externalRelations }, "agent stuff");
8267
8355
  const enhancedInternalRelations = await Promise.all(
8268
8356
  internalRelations.map(async (relation) => {
8269
8357
  try {
8270
- const relatedAgent = await getAgentById(dbClient_default)({
8358
+ const relatedAgent = await getSubAgentById(dbClient_default)({
8271
8359
  scopes: {
8272
8360
  tenantId: config.tenantId,
8273
8361
  projectId: config.projectId,
8274
8362
  graphId: config.graphId
8275
8363
  },
8276
- agentId: relation.id
8364
+ subAgentId: relation.id
8277
8365
  });
8278
8366
  if (relatedAgent) {
8279
8367
  const relatedAgentRelations = await getRelatedAgentsForGraph(dbClient_default)({
@@ -8282,7 +8370,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
8282
8370
  projectId: config.projectId,
8283
8371
  graphId: config.graphId
8284
8372
  },
8285
- agentId: relation.id
8373
+ subAgentId: relation.id
8286
8374
  });
8287
8375
  const enhancedDescription = generateDescriptionWithTransfers(
8288
8376
  relation.description || "",
@@ -8292,7 +8380,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
8292
8380
  return { ...relation, description: enhancedDescription };
8293
8381
  }
8294
8382
  } catch (error) {
8295
- logger18.warn({ agentId: relation.id, error }, "Failed to enhance agent description");
8383
+ logger17.warn({ subAgentId: relation.id, error }, "Failed to enhance agent description");
8296
8384
  }
8297
8385
  return relation;
8298
8386
  })
@@ -8307,7 +8395,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
8307
8395
  ) ?? [];
8308
8396
  const agent = new Agent(
8309
8397
  {
8310
- id: config.agentId,
8398
+ id: config.subAgentId,
8311
8399
  tenantId: config.tenantId,
8312
8400
  projectId: config.projectId,
8313
8401
  graphId: config.graphId,
@@ -8318,7 +8406,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
8318
8406
  agentPrompt,
8319
8407
  models: models || void 0,
8320
8408
  stopWhen: stopWhen || void 0,
8321
- agentRelations: enhancedInternalRelations.map((relation) => ({
8409
+ subAgentRelations: enhancedInternalRelations.map((relation) => ({
8322
8410
  id: relation.id,
8323
8411
  tenantId: config.tenantId,
8324
8412
  projectId: config.projectId,
@@ -8329,7 +8417,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
8329
8417
  description: relation.description,
8330
8418
  agentPrompt: "",
8331
8419
  delegateRelations: [],
8332
- agentRelations: [],
8420
+ subAgentRelations: [],
8333
8421
  transferRelations: []
8334
8422
  })),
8335
8423
  transferRelations: enhancedInternalRelations.filter((relation) => relation.relationType === "transfer").map((relation) => ({
@@ -8343,7 +8431,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
8343
8431
  description: relation.description,
8344
8432
  agentPrompt: "",
8345
8433
  delegateRelations: [],
8346
- agentRelations: [],
8434
+ subAgentRelations: [],
8347
8435
  transferRelations: []
8348
8436
  })),
8349
8437
  delegateRelations: [
@@ -8361,7 +8449,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
8361
8449
  description: relation.description,
8362
8450
  agentPrompt: "",
8363
8451
  delegateRelations: [],
8364
- agentRelations: [],
8452
+ subAgentRelations: [],
8365
8453
  transferRelations: []
8366
8454
  }
8367
8455
  })),
@@ -8396,11 +8484,11 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
8396
8484
  const taskIdMatch = task.id.match(/^task_([^-]+-[^-]+-\d+)-/);
8397
8485
  if (taskIdMatch) {
8398
8486
  contextId = taskIdMatch[1];
8399
- logger18.info(
8487
+ logger17.info(
8400
8488
  {
8401
8489
  taskId: task.id,
8402
8490
  extractedContextId: contextId,
8403
- agentId: config.agentId
8491
+ subAgentId: config.subAgentId
8404
8492
  },
8405
8493
  "Extracted contextId from task ID for delegation"
8406
8494
  );
@@ -8412,8 +8500,8 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
8412
8500
  const isDelegation = task.context?.metadata?.isDelegation === true;
8413
8501
  agent.setDelegationStatus(isDelegation);
8414
8502
  if (isDelegation) {
8415
- logger18.info(
8416
- { agentId: config.agentId, taskId: task.id },
8503
+ logger17.info(
8504
+ { subAgentId: config.subAgentId, taskId: task.id },
8417
8505
  "Delegated agent - streaming disabled"
8418
8506
  );
8419
8507
  if (streamRequestId && config.tenantId && config.projectId) {
@@ -8510,13 +8598,13 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
8510
8598
  };
8511
8599
  };
8512
8600
  var createTaskHandlerConfig = async (params) => {
8513
- const agent = await getAgentById(dbClient_default)({
8601
+ const agent = await getSubAgentById(dbClient_default)({
8514
8602
  scopes: {
8515
8603
  tenantId: params.tenantId,
8516
8604
  projectId: params.projectId,
8517
8605
  graphId: params.graphId
8518
8606
  },
8519
- agentId: params.agentId
8607
+ subAgentId: params.subAgentId
8520
8608
  });
8521
8609
  const agentGraph = await getAgentGraphById(dbClient_default)({
8522
8610
  scopes: {
@@ -8526,7 +8614,7 @@ var createTaskHandlerConfig = async (params) => {
8526
8614
  }
8527
8615
  });
8528
8616
  if (!agent) {
8529
- throw new Error(`Agent not found: ${params.agentId}`);
8617
+ throw new Error(`Agent not found: ${params.subAgentId}`);
8530
8618
  }
8531
8619
  const effectiveModels = await resolveModelConfig(params.graphId, agent);
8532
8620
  const effectiveConversationHistoryConfig = agent.conversationHistoryConfig || { mode: "full" };
@@ -8534,7 +8622,7 @@ var createTaskHandlerConfig = async (params) => {
8534
8622
  tenantId: params.tenantId,
8535
8623
  projectId: params.projectId,
8536
8624
  graphId: params.graphId,
8537
- agentId: params.agentId,
8625
+ subAgentId: params.subAgentId,
8538
8626
  agentSchema: {
8539
8627
  id: agent.id,
8540
8628
  name: agent.name,
@@ -8562,25 +8650,27 @@ async function hydrateGraph({
8562
8650
  apiKey
8563
8651
  }) {
8564
8652
  try {
8565
- if (!dbGraph.defaultAgentId) {
8653
+ if (!dbGraph.defaultSubAgentId) {
8566
8654
  throw new Error(`Graph ${dbGraph.id} does not have a default agent configured`);
8567
8655
  }
8568
- const defaultAgent = await getAgentById(dbClient_default)({
8656
+ const defaultSubAgent = await getSubAgentById(dbClient_default)({
8569
8657
  scopes: {
8570
8658
  tenantId: dbGraph.tenantId,
8571
8659
  projectId: dbGraph.projectId,
8572
8660
  graphId: dbGraph.id
8573
8661
  },
8574
- agentId: dbGraph.defaultAgentId
8662
+ subAgentId: dbGraph.defaultSubAgentId
8575
8663
  });
8576
- if (!defaultAgent) {
8577
- throw new Error(`Default agent ${dbGraph.defaultAgentId} not found for graph ${dbGraph.id}`);
8664
+ if (!defaultSubAgent) {
8665
+ throw new Error(
8666
+ `Default agent ${dbGraph.defaultSubAgentId} not found for graph ${dbGraph.id}`
8667
+ );
8578
8668
  }
8579
8669
  const taskHandlerConfig = await createTaskHandlerConfig({
8580
8670
  tenantId: dbGraph.tenantId,
8581
8671
  projectId: dbGraph.projectId,
8582
8672
  graphId: dbGraph.id,
8583
- agentId: dbGraph.defaultAgentId,
8673
+ subAgentId: dbGraph.defaultSubAgentId,
8584
8674
  baseUrl,
8585
8675
  apiKey
8586
8676
  });
@@ -8609,7 +8699,7 @@ async function hydrateGraph({
8609
8699
  }
8610
8700
  };
8611
8701
  return {
8612
- agentId: dbGraph.id,
8702
+ subAgentId: dbGraph.id,
8613
8703
  // Use graph ID as agent ID for A2A purposes
8614
8704
  tenantId: dbGraph.tenantId,
8615
8705
  projectId: dbGraph.projectId,
@@ -8634,7 +8724,7 @@ async function getRegisteredGraph(executionContext) {
8634
8724
 
8635
8725
  // src/routes/agents.ts
8636
8726
  var app = new OpenAPIHono();
8637
- var logger19 = getLogger("agents");
8727
+ var logger18 = getLogger("agents");
8638
8728
  app.openapi(
8639
8729
  createRoute({
8640
8730
  method: "get",
@@ -8672,7 +8762,7 @@ app.openapi(
8672
8762
  tracestate: c.req.header("tracestate"),
8673
8763
  baggage: c.req.header("baggage")
8674
8764
  };
8675
- logger19.info(
8765
+ logger18.info(
8676
8766
  {
8677
8767
  otelHeaders,
8678
8768
  path: c.req.path,
@@ -8681,22 +8771,22 @@ app.openapi(
8681
8771
  "OpenTelemetry headers: well-known agent.json"
8682
8772
  );
8683
8773
  const executionContext = getRequestExecutionContext(c);
8684
- const { tenantId, projectId, graphId, agentId } = executionContext;
8774
+ const { tenantId, projectId, graphId, subAgentId } = executionContext;
8685
8775
  console.dir("executionContext", executionContext);
8686
- if (agentId) {
8687
- logger19.info(
8776
+ if (subAgentId) {
8777
+ logger18.info(
8688
8778
  {
8689
8779
  message: "getRegisteredAgent (agent-level)",
8690
8780
  tenantId,
8691
8781
  projectId,
8692
8782
  graphId,
8693
- agentId
8783
+ subAgentId
8694
8784
  },
8695
8785
  "agent-level well-known agent.json"
8696
8786
  );
8697
8787
  const credentialStores = c.get("credentialStores");
8698
8788
  const agent = await getRegisteredAgent(executionContext, credentialStores);
8699
- logger19.info({ agent }, "agent registered: well-known agent.json");
8789
+ logger18.info({ agent }, "agent registered: well-known agent.json");
8700
8790
  if (!agent) {
8701
8791
  throw createApiError({
8702
8792
  code: "not_found",
@@ -8705,7 +8795,7 @@ app.openapi(
8705
8795
  }
8706
8796
  return c.json(agent.agentCard);
8707
8797
  } else {
8708
- logger19.info(
8798
+ logger18.info(
8709
8799
  {
8710
8800
  message: "getRegisteredGraph (graph-level)",
8711
8801
  tenantId,
@@ -8731,7 +8821,7 @@ app.post("/a2a", async (c) => {
8731
8821
  tracestate: c.req.header("tracestate"),
8732
8822
  baggage: c.req.header("baggage")
8733
8823
  };
8734
- logger19.info(
8824
+ logger18.info(
8735
8825
  {
8736
8826
  otelHeaders,
8737
8827
  path: c.req.path,
@@ -8740,15 +8830,15 @@ app.post("/a2a", async (c) => {
8740
8830
  "OpenTelemetry headers: a2a"
8741
8831
  );
8742
8832
  const executionContext = getRequestExecutionContext(c);
8743
- const { tenantId, projectId, graphId, agentId } = executionContext;
8744
- if (agentId) {
8745
- logger19.info(
8833
+ const { tenantId, projectId, graphId, subAgentId } = executionContext;
8834
+ if (subAgentId) {
8835
+ logger18.info(
8746
8836
  {
8747
8837
  message: "a2a (agent-level)",
8748
8838
  tenantId,
8749
8839
  projectId,
8750
8840
  graphId,
8751
- agentId
8841
+ subAgentId
8752
8842
  },
8753
8843
  "agent-level a2a endpoint"
8754
8844
  );
@@ -8766,7 +8856,7 @@ app.post("/a2a", async (c) => {
8766
8856
  }
8767
8857
  return a2aHandler(c, agent);
8768
8858
  } else {
8769
- logger19.info(
8859
+ logger18.info(
8770
8860
  {
8771
8861
  message: "a2a (graph-level)",
8772
8862
  tenantId,
@@ -8775,7 +8865,7 @@ app.post("/a2a", async (c) => {
8775
8865
  },
8776
8866
  "graph-level a2a endpoint"
8777
8867
  );
8778
- const graph = await getAgentGraphWithDefaultAgent(dbClient_default)({
8868
+ const graph = await getAgentGraphWithDefaultSubAgent(dbClient_default)({
8779
8869
  scopes: { tenantId, projectId, graphId }
8780
8870
  });
8781
8871
  if (!graph) {
@@ -8788,7 +8878,7 @@ app.post("/a2a", async (c) => {
8788
8878
  404
8789
8879
  );
8790
8880
  }
8791
- if (!graph.defaultAgentId) {
8881
+ if (!graph.defaultSubAgentId) {
8792
8882
  return c.json(
8793
8883
  {
8794
8884
  jsonrpc: "2.0",
@@ -8798,10 +8888,10 @@ app.post("/a2a", async (c) => {
8798
8888
  400
8799
8889
  );
8800
8890
  }
8801
- executionContext.agentId = graph.defaultAgentId;
8891
+ executionContext.subAgentId = graph.defaultSubAgentId;
8802
8892
  const credentialStores = c.get("credentialStores");
8803
- const defaultAgent = await getRegisteredAgent(executionContext, credentialStores);
8804
- if (!defaultAgent) {
8893
+ const defaultSubAgent = await getRegisteredAgent(executionContext, credentialStores);
8894
+ if (!defaultSubAgent) {
8805
8895
  return c.json(
8806
8896
  {
8807
8897
  jsonrpc: "2.0",
@@ -8811,24 +8901,24 @@ app.post("/a2a", async (c) => {
8811
8901
  404
8812
8902
  );
8813
8903
  }
8814
- return a2aHandler(c, defaultAgent);
8904
+ return a2aHandler(c, defaultSubAgent);
8815
8905
  }
8816
8906
  });
8817
8907
  var agents_default = app;
8818
- var logger20 = getLogger("Transfer");
8908
+ var logger19 = getLogger("Transfer");
8819
8909
  async function executeTransfer({
8820
8910
  tenantId,
8821
8911
  threadId,
8822
8912
  projectId,
8823
- targetAgentId
8913
+ targetSubAgentId
8824
8914
  }) {
8825
- logger20.info({ targetAgent: targetAgentId }, "Executing transfer to agent");
8915
+ logger19.info({ targetAgent: targetSubAgentId }, "Executing transfer to agent");
8826
8916
  await setActiveAgentForThread(dbClient_default)({
8827
8917
  scopes: { tenantId, projectId },
8828
8918
  threadId,
8829
- agentId: targetAgentId
8919
+ subAgentId: targetSubAgentId
8830
8920
  });
8831
- return { success: true, targetAgentId };
8921
+ return { success: true, targetSubAgentId };
8832
8922
  }
8833
8923
  function isTransferResponse(result) {
8834
8924
  return result?.artifacts.some(
@@ -9404,7 +9494,7 @@ function createMCPStreamHelper() {
9404
9494
  }
9405
9495
 
9406
9496
  // src/handlers/executionHandler.ts
9407
- var logger21 = getLogger("ExecutionHandler");
9497
+ var logger20 = getLogger("ExecutionHandler");
9408
9498
  var ExecutionHandler = class {
9409
9499
  constructor() {
9410
9500
  // Hardcoded error limit - separate from configurable stopWhen
@@ -9440,7 +9530,7 @@ var ExecutionHandler = class {
9440
9530
  if (emitOperations) {
9441
9531
  graphSessionManager.enableEmitOperations(requestId2);
9442
9532
  }
9443
- logger21.info(
9533
+ logger20.info(
9444
9534
  { sessionId: requestId2, graphId, conversationId, emitOperations },
9445
9535
  "Created GraphSession for message execution"
9446
9536
  );
@@ -9455,7 +9545,7 @@ var ExecutionHandler = class {
9455
9545
  );
9456
9546
  }
9457
9547
  } catch (error) {
9458
- logger21.error(
9548
+ logger20.error(
9459
9549
  {
9460
9550
  error: error instanceof Error ? error.message : "Unknown error",
9461
9551
  stack: error instanceof Error ? error.stack : void 0
@@ -9471,7 +9561,7 @@ var ExecutionHandler = class {
9471
9561
  try {
9472
9562
  await sseHelper.writeOperation(agentInitializingOp(requestId2, graphId));
9473
9563
  const taskId = `task_${conversationId}-${requestId2}`;
9474
- logger21.info(
9564
+ logger20.info(
9475
9565
  { taskId, currentAgentId, conversationId, requestId: requestId2 },
9476
9566
  "Attempting to create or reuse existing task"
9477
9567
  );
@@ -9481,7 +9571,7 @@ var ExecutionHandler = class {
9481
9571
  tenantId,
9482
9572
  projectId,
9483
9573
  graphId,
9484
- agentId: currentAgentId,
9574
+ subAgentId: currentAgentId,
9485
9575
  contextId: conversationId,
9486
9576
  status: "pending",
9487
9577
  metadata: {
@@ -9495,7 +9585,7 @@ var ExecutionHandler = class {
9495
9585
  agent_id: currentAgentId
9496
9586
  }
9497
9587
  });
9498
- logger21.info(
9588
+ logger20.info(
9499
9589
  {
9500
9590
  taskId,
9501
9591
  createdTaskMetadata: Array.isArray(task) ? task[0]?.metadata : task?.metadata
@@ -9504,27 +9594,27 @@ var ExecutionHandler = class {
9504
9594
  );
9505
9595
  } catch (error) {
9506
9596
  if (error?.message?.includes("UNIQUE constraint failed") || error?.message?.includes("PRIMARY KEY constraint failed") || error?.code === "SQLITE_CONSTRAINT_PRIMARYKEY") {
9507
- logger21.info(
9597
+ logger20.info(
9508
9598
  { taskId, error: error.message },
9509
9599
  "Task already exists, fetching existing task"
9510
9600
  );
9511
9601
  const existingTask = await getTask(dbClient_default)({ id: taskId });
9512
9602
  if (existingTask) {
9513
9603
  task = existingTask;
9514
- logger21.info(
9604
+ logger20.info(
9515
9605
  { taskId, existingTask },
9516
9606
  "Successfully reused existing task from race condition"
9517
9607
  );
9518
9608
  } else {
9519
- logger21.error({ taskId, error }, "Task constraint failed but task not found");
9609
+ logger20.error({ taskId, error }, "Task constraint failed but task not found");
9520
9610
  throw error;
9521
9611
  }
9522
9612
  } else {
9523
- logger21.error({ taskId, error }, "Failed to create task due to non-constraint error");
9613
+ logger20.error({ taskId, error }, "Failed to create task due to non-constraint error");
9524
9614
  throw error;
9525
9615
  }
9526
9616
  }
9527
- logger21.debug(
9617
+ logger20.debug(
9528
9618
  {
9529
9619
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
9530
9620
  executionType: "create_initial_task",
@@ -9542,7 +9632,7 @@ var ExecutionHandler = class {
9542
9632
  const maxTransfers = graphConfig?.stopWhen?.transferCountIs ?? 10;
9543
9633
  while (iterations < maxTransfers) {
9544
9634
  iterations++;
9545
- logger21.info(
9635
+ logger20.info(
9546
9636
  { iterations, currentAgentId, graphId, conversationId, fromAgentId },
9547
9637
  `Execution loop iteration ${iterations} with agent ${currentAgentId}, transfer from: ${fromAgentId || "none"}`
9548
9638
  );
@@ -9550,10 +9640,10 @@ var ExecutionHandler = class {
9550
9640
  scopes: { tenantId, projectId },
9551
9641
  conversationId
9552
9642
  });
9553
- logger21.info({ activeAgent }, "activeAgent");
9554
- if (activeAgent && activeAgent.activeAgentId !== currentAgentId) {
9555
- currentAgentId = activeAgent.activeAgentId;
9556
- logger21.info({ currentAgentId }, `Updated current agent to: ${currentAgentId}`);
9643
+ logger20.info({ activeAgent }, "activeAgent");
9644
+ if (activeAgent && activeAgent.activeSubAgentId !== currentAgentId) {
9645
+ currentAgentId = activeAgent.activeSubAgentId;
9646
+ logger20.info({ currentAgentId }, `Updated current agent to: ${currentAgentId}`);
9557
9647
  }
9558
9648
  const agentBaseUrl = `${baseUrl}/agents`;
9559
9649
  const a2aClient = new A2AClient(agentBaseUrl, {
@@ -9594,13 +9684,13 @@ var ExecutionHandler = class {
9594
9684
  });
9595
9685
  if (!messageResponse?.result) {
9596
9686
  errorCount++;
9597
- logger21.error(
9687
+ logger20.error(
9598
9688
  { currentAgentId, iterations, errorCount },
9599
9689
  `No response from agent ${currentAgentId} on iteration ${iterations} (error ${errorCount}/${this.MAX_ERRORS})`
9600
9690
  );
9601
9691
  if (errorCount >= this.MAX_ERRORS) {
9602
9692
  const errorMessage2 = `Maximum error limit (${this.MAX_ERRORS}) reached`;
9603
- logger21.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
9693
+ logger20.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
9604
9694
  await sseHelper.writeOperation(errorOp(errorMessage2, currentAgentId || "system"));
9605
9695
  if (task) {
9606
9696
  await updateTask(dbClient_default)({
@@ -9623,20 +9713,20 @@ var ExecutionHandler = class {
9623
9713
  }
9624
9714
  if (isTransferResponse(messageResponse.result)) {
9625
9715
  const transferResponse = messageResponse.result;
9626
- const targetAgentId = transferResponse.artifacts?.[0]?.parts?.[0]?.data?.targetAgentId;
9716
+ const targetSubAgentId = transferResponse.artifacts?.[0]?.parts?.[0]?.data?.targetSubAgentId;
9627
9717
  const transferReason = transferResponse.artifacts?.[0]?.parts?.[1]?.text;
9628
- logger21.info({ targetAgentId, transferReason }, "transfer response");
9718
+ logger20.info({ targetSubAgentId, transferReason }, "transfer response");
9629
9719
  currentMessage = `<transfer_context> ${transferReason} </transfer_context>`;
9630
- const { success, targetAgentId: newAgentId } = await executeTransfer({
9720
+ const { success, targetSubAgentId: newAgentId } = await executeTransfer({
9631
9721
  projectId,
9632
9722
  tenantId,
9633
9723
  threadId: conversationId,
9634
- targetAgentId
9724
+ targetSubAgentId
9635
9725
  });
9636
9726
  if (success) {
9637
9727
  fromAgentId = currentAgentId;
9638
9728
  currentAgentId = newAgentId;
9639
- logger21.info(
9729
+ logger20.info(
9640
9730
  {
9641
9731
  transferFrom: fromAgentId,
9642
9732
  transferTo: currentAgentId,
@@ -9647,14 +9737,27 @@ var ExecutionHandler = class {
9647
9737
  }
9648
9738
  continue;
9649
9739
  }
9650
- const responseParts = messageResponse.result.artifacts?.flatMap(
9651
- (artifact) => artifact.parts || []
9652
- ) || [];
9740
+ let responseParts = [];
9741
+ if (messageResponse.result.streamedContent?.parts) {
9742
+ responseParts = messageResponse.result.streamedContent.parts;
9743
+ logger20.info(
9744
+ { partsCount: responseParts.length },
9745
+ "Using streamed content for conversation history"
9746
+ );
9747
+ } else {
9748
+ responseParts = messageResponse.result.artifacts?.flatMap(
9749
+ (artifact) => artifact.parts || []
9750
+ ) || [];
9751
+ logger20.info(
9752
+ { partsCount: responseParts.length },
9753
+ "Using artifacts for conversation history (fallback)"
9754
+ );
9755
+ }
9653
9756
  if (responseParts && responseParts.length > 0) {
9654
9757
  const graphSessionData = graphSessionManager.getSession(requestId2);
9655
9758
  if (graphSessionData) {
9656
9759
  const sessionSummary = graphSessionData.getSummary();
9657
- logger21.info(sessionSummary, "GraphSession data after completion");
9760
+ logger20.info(sessionSummary, "GraphSession data after completion");
9658
9761
  }
9659
9762
  let textContent = "";
9660
9763
  for (const part of responseParts) {
@@ -9686,8 +9789,7 @@ var ExecutionHandler = class {
9686
9789
  },
9687
9790
  visibility: "user-facing",
9688
9791
  messageType: "chat",
9689
- agentId: currentAgentId,
9690
- fromAgentId: currentAgentId,
9792
+ fromSubAgentId: currentAgentId,
9691
9793
  taskId: task.id
9692
9794
  });
9693
9795
  const updateTaskStart = Date.now();
@@ -9708,22 +9810,22 @@ var ExecutionHandler = class {
9708
9810
  }
9709
9811
  });
9710
9812
  const updateTaskEnd = Date.now();
9711
- logger21.info(
9813
+ logger20.info(
9712
9814
  { duration: updateTaskEnd - updateTaskStart },
9713
9815
  "Completed updateTask operation"
9714
9816
  );
9715
9817
  await sseHelper.writeOperation(completionOp(currentAgentId, iterations));
9716
9818
  await sseHelper.complete();
9717
- logger21.info({}, "Ending GraphSession and cleaning up");
9819
+ logger20.info({}, "Ending GraphSession and cleaning up");
9718
9820
  graphSessionManager.endSession(requestId2);
9719
- logger21.info({}, "Cleaning up streamHelper");
9821
+ logger20.info({}, "Cleaning up streamHelper");
9720
9822
  unregisterStreamHelper(requestId2);
9721
9823
  let response;
9722
9824
  if (sseHelper instanceof MCPStreamHelper) {
9723
9825
  const captured = sseHelper.getCapturedResponse();
9724
9826
  response = captured.text || "No response content";
9725
9827
  }
9726
- logger21.info({}, "ExecutionHandler returning success");
9828
+ logger20.info({}, "ExecutionHandler returning success");
9727
9829
  return { success: true, iterations, response };
9728
9830
  } catch (error) {
9729
9831
  setSpanWithError(span, error instanceof Error ? error : new Error(String(error)));
@@ -9734,13 +9836,13 @@ var ExecutionHandler = class {
9734
9836
  });
9735
9837
  }
9736
9838
  errorCount++;
9737
- logger21.warn(
9839
+ logger20.warn(
9738
9840
  { iterations, errorCount },
9739
9841
  `No valid response or transfer on iteration ${iterations} (error ${errorCount}/${this.MAX_ERRORS})`
9740
9842
  );
9741
9843
  if (errorCount >= this.MAX_ERRORS) {
9742
9844
  const errorMessage2 = `Maximum error limit (${this.MAX_ERRORS}) reached`;
9743
- logger21.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
9845
+ logger20.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
9744
9846
  await sseHelper.writeOperation(errorOp(errorMessage2, currentAgentId || "system"));
9745
9847
  if (task) {
9746
9848
  await updateTask(dbClient_default)({
@@ -9761,7 +9863,7 @@ var ExecutionHandler = class {
9761
9863
  }
9762
9864
  }
9763
9865
  const errorMessage = `Maximum transfer limit (${maxTransfers}) reached without completion`;
9764
- logger21.error({ maxTransfers, iterations }, errorMessage);
9866
+ logger20.error({ maxTransfers, iterations }, errorMessage);
9765
9867
  await sseHelper.writeOperation(errorOp(errorMessage, currentAgentId || "system"));
9766
9868
  if (task) {
9767
9869
  await updateTask(dbClient_default)({
@@ -9780,7 +9882,7 @@ var ExecutionHandler = class {
9780
9882
  unregisterStreamHelper(requestId2);
9781
9883
  return { success: false, error: errorMessage, iterations };
9782
9884
  } catch (error) {
9783
- logger21.error({ error }, "Error in execution handler");
9885
+ logger20.error({ error }, "Error in execution handler");
9784
9886
  const errorMessage = error instanceof Error ? error.message : "Unknown execution error";
9785
9887
  await sseHelper.writeOperation(
9786
9888
  errorOp(`Execution error: ${errorMessage}`, currentAgentId || "system")
@@ -9807,7 +9909,7 @@ var ExecutionHandler = class {
9807
9909
 
9808
9910
  // src/routes/chat.ts
9809
9911
  var app2 = new OpenAPIHono();
9810
- var logger22 = getLogger("completionsHandler");
9912
+ var logger21 = getLogger("completionsHandler");
9811
9913
  var chatCompletionsRoute = createRoute({
9812
9914
  method: "post",
9813
9915
  path: "/completions",
@@ -9925,7 +10027,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
9925
10027
  tracestate: c.req.header("tracestate"),
9926
10028
  baggage: c.req.header("baggage")
9927
10029
  };
9928
- logger22.info(
10030
+ logger21.info(
9929
10031
  {
9930
10032
  otelHeaders,
9931
10033
  path: c.req.path,
@@ -9949,20 +10051,20 @@ app2.openapi(chatCompletionsRoute, async (c) => {
9949
10051
  scopes: { tenantId, projectId, graphId }
9950
10052
  });
9951
10053
  let agentGraph;
9952
- let defaultAgentId;
10054
+ let defaultSubAgentId;
9953
10055
  if (fullGraph) {
9954
10056
  agentGraph = {
9955
10057
  id: fullGraph.id,
9956
10058
  name: fullGraph.name,
9957
10059
  tenantId,
9958
10060
  projectId,
9959
- defaultAgentId: fullGraph.defaultAgentId
10061
+ defaultSubAgentId: fullGraph.defaultSubAgentId
9960
10062
  };
9961
- const agentKeys = Object.keys(fullGraph.agents || {});
10063
+ const agentKeys = Object.keys(fullGraph.subAgents || {});
9962
10064
  const firstAgentId = agentKeys.length > 0 ? agentKeys[0] : "";
9963
- defaultAgentId = fullGraph.defaultAgentId || firstAgentId;
10065
+ defaultSubAgentId = fullGraph.defaultSubAgentId || firstAgentId;
9964
10066
  } else {
9965
- agentGraph = await getAgentGraphWithDefaultAgent(dbClient_default)({
10067
+ agentGraph = await getAgentGraphWithDefaultSubAgent(dbClient_default)({
9966
10068
  scopes: { tenantId, projectId, graphId }
9967
10069
  });
9968
10070
  if (!agentGraph) {
@@ -9971,9 +10073,9 @@ app2.openapi(chatCompletionsRoute, async (c) => {
9971
10073
  message: "Agent graph not found"
9972
10074
  });
9973
10075
  }
9974
- defaultAgentId = agentGraph.defaultAgentId || "";
10076
+ defaultSubAgentId = agentGraph.defaultSubAgentId || "";
9975
10077
  }
9976
- if (!defaultAgentId) {
10078
+ if (!defaultSubAgentId) {
9977
10079
  throw createApiError({
9978
10080
  code: "not_found",
9979
10081
  message: "No default agent found in graph"
@@ -9983,7 +10085,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
9983
10085
  tenantId,
9984
10086
  projectId,
9985
10087
  id: conversationId,
9986
- activeAgentId: defaultAgentId
10088
+ activeSubAgentId: defaultSubAgentId
9987
10089
  });
9988
10090
  const activeAgent = await getActiveAgentForConversation(dbClient_default)({
9989
10091
  scopes: { tenantId, projectId },
@@ -9993,13 +10095,13 @@ app2.openapi(chatCompletionsRoute, async (c) => {
9993
10095
  setActiveAgentForConversation(dbClient_default)({
9994
10096
  scopes: { tenantId, projectId },
9995
10097
  conversationId,
9996
- agentId: defaultAgentId
10098
+ subAgentId: defaultSubAgentId
9997
10099
  });
9998
10100
  }
9999
- const agentId = activeAgent?.activeAgentId || defaultAgentId;
10000
- const agentInfo = await getAgentById(dbClient_default)({
10101
+ const subAgentId = activeAgent?.activeSubAgentId || defaultSubAgentId;
10102
+ const agentInfo = await getSubAgentById(dbClient_default)({
10001
10103
  scopes: { tenantId, projectId, graphId },
10002
- agentId
10104
+ subAgentId
10003
10105
  });
10004
10106
  if (!agentInfo) {
10005
10107
  throw createApiError({
@@ -10018,14 +10120,14 @@ app2.openapi(chatCompletionsRoute, async (c) => {
10018
10120
  dbClient: dbClient_default,
10019
10121
  credentialStores
10020
10122
  });
10021
- logger22.info(
10123
+ logger21.info(
10022
10124
  {
10023
10125
  tenantId,
10024
10126
  projectId,
10025
10127
  graphId,
10026
10128
  conversationId,
10027
- defaultAgentId,
10028
- activeAgentId: activeAgent?.activeAgentId || "none",
10129
+ defaultSubAgentId,
10130
+ activeSubAgentId: activeAgent?.activeSubAgentId || "none",
10029
10131
  hasContextConfig: !!agentGraph.contextConfigId,
10030
10132
  hasHeaders: !!body.headers,
10031
10133
  hasValidatedContext: !!validatedContext,
@@ -10066,7 +10168,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
10066
10168
  try {
10067
10169
  const sseHelper = createSSEStreamHelper(stream2, requestId2, timestamp);
10068
10170
  await sseHelper.writeRole();
10069
- logger22.info({ agentId }, "Starting execution");
10171
+ logger21.info({ subAgentId }, "Starting execution");
10070
10172
  const emitOperationsHeader = c.req.header("x-emit-operations");
10071
10173
  const emitOperations = emitOperationsHeader === "true";
10072
10174
  const executionHandler = new ExecutionHandler();
@@ -10074,12 +10176,12 @@ app2.openapi(chatCompletionsRoute, async (c) => {
10074
10176
  executionContext,
10075
10177
  conversationId,
10076
10178
  userMessage,
10077
- initialAgentId: agentId,
10179
+ initialAgentId: subAgentId,
10078
10180
  requestId: requestId2,
10079
10181
  sseHelper,
10080
10182
  emitOperations
10081
10183
  });
10082
- logger22.info(
10184
+ logger21.info(
10083
10185
  { result },
10084
10186
  `Execution completed: ${result.success ? "success" : "failed"} after ${result.iterations} iterations`
10085
10187
  );
@@ -10093,7 +10195,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
10093
10195
  }
10094
10196
  await sseHelper.complete();
10095
10197
  } catch (error) {
10096
- logger22.error(
10198
+ logger21.error(
10097
10199
  {
10098
10200
  error: error instanceof Error ? error.message : error,
10099
10201
  stack: error instanceof Error ? error.stack : void 0
@@ -10110,12 +10212,12 @@ app2.openapi(chatCompletionsRoute, async (c) => {
10110
10212
  );
10111
10213
  await sseHelper.complete();
10112
10214
  } catch (streamError) {
10113
- logger22.error({ streamError }, "Failed to write error to stream");
10215
+ logger21.error({ streamError }, "Failed to write error to stream");
10114
10216
  }
10115
10217
  }
10116
10218
  });
10117
10219
  } catch (error) {
10118
- logger22.error(
10220
+ logger21.error(
10119
10221
  {
10120
10222
  error: error instanceof Error ? error.message : error,
10121
10223
  stack: error instanceof Error ? error.stack : void 0
@@ -10139,7 +10241,7 @@ var getMessageText = (content) => {
10139
10241
  };
10140
10242
  var chat_default = app2;
10141
10243
  var app3 = new OpenAPIHono();
10142
- var logger23 = getLogger("chatDataStream");
10244
+ var logger22 = getLogger("chatDataStream");
10143
10245
  var chatDataStreamRoute = createRoute({
10144
10246
  method: "post",
10145
10247
  path: "/chat",
@@ -10204,7 +10306,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
10204
10306
  "project.id": projectId
10205
10307
  });
10206
10308
  }
10207
- const agentGraph = await getAgentGraphWithDefaultAgent(dbClient_default)({
10309
+ const agentGraph = await getAgentGraphWithDefaultSubAgent(dbClient_default)({
10208
10310
  scopes: { tenantId, projectId, graphId }
10209
10311
  });
10210
10312
  if (!agentGraph) {
@@ -10213,9 +10315,9 @@ app3.openapi(chatDataStreamRoute, async (c) => {
10213
10315
  message: "Agent graph not found"
10214
10316
  });
10215
10317
  }
10216
- const defaultAgentId = agentGraph.defaultAgentId;
10318
+ const defaultSubAgentId = agentGraph.defaultSubAgentId;
10217
10319
  const graphName = agentGraph.name;
10218
- if (!defaultAgentId) {
10320
+ if (!defaultSubAgentId) {
10219
10321
  throw createApiError({
10220
10322
  code: "bad_request",
10221
10323
  message: "Graph does not have a default agent configured"
@@ -10229,13 +10331,13 @@ app3.openapi(chatDataStreamRoute, async (c) => {
10229
10331
  setActiveAgentForConversation(dbClient_default)({
10230
10332
  scopes: { tenantId, projectId },
10231
10333
  conversationId,
10232
- agentId: defaultAgentId
10334
+ subAgentId: defaultSubAgentId
10233
10335
  });
10234
10336
  }
10235
- const agentId = activeAgent?.activeAgentId || defaultAgentId;
10236
- const agentInfo = await getAgentById(dbClient_default)({
10337
+ const subAgentId = activeAgent?.activeSubAgentId || defaultSubAgentId;
10338
+ const agentInfo = await getSubAgentById(dbClient_default)({
10237
10339
  scopes: { tenantId, projectId, graphId },
10238
- agentId
10340
+ subAgentId
10239
10341
  });
10240
10342
  if (!agentInfo) {
10241
10343
  throw createApiError({
@@ -10256,7 +10358,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
10256
10358
  });
10257
10359
  const lastUserMessage = body.messages.filter((m) => m.role === "user").slice(-1)[0];
10258
10360
  const userText = typeof lastUserMessage?.content === "string" ? lastUserMessage.content : lastUserMessage?.parts?.map((p) => p.text).join("") || "";
10259
- logger23.info({ userText, lastUserMessage }, "userText");
10361
+ logger22.info({ userText, lastUserMessage }, "userText");
10260
10362
  const messageSpan = trace.getActiveSpan();
10261
10363
  if (messageSpan) {
10262
10364
  messageSpan.setAttributes({
@@ -10292,7 +10394,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
10292
10394
  executionContext,
10293
10395
  conversationId,
10294
10396
  userMessage: userText,
10295
- initialAgentId: agentId,
10397
+ initialAgentId: subAgentId,
10296
10398
  requestId: `chatds-${Date.now()}`,
10297
10399
  sseHelper: streamHelper,
10298
10400
  emitOperations
@@ -10301,7 +10403,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
10301
10403
  await streamHelper.writeOperation(errorOp("Unable to process request", "system"));
10302
10404
  }
10303
10405
  } catch (err) {
10304
- logger23.error({ err }, "Streaming error");
10406
+ logger22.error({ err }, "Streaming error");
10305
10407
  await streamHelper.writeOperation(errorOp("Internal server error", "system"));
10306
10408
  } finally {
10307
10409
  if ("cleanup" in streamHelper && typeof streamHelper.cleanup === "function") {
@@ -10322,7 +10424,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
10322
10424
  )
10323
10425
  );
10324
10426
  } catch (error) {
10325
- logger23.error({ error }, "chatDataStream error");
10427
+ logger22.error({ error }, "chatDataStream error");
10326
10428
  throw createApiError({
10327
10429
  code: "internal_server_error",
10328
10430
  message: "Failed to process chat completion"
@@ -10333,7 +10435,7 @@ var chatDataStream_default = app3;
10333
10435
  function createMCPSchema(schema) {
10334
10436
  return schema;
10335
10437
  }
10336
- var logger24 = getLogger("mcp");
10438
+ var logger23 = getLogger("mcp");
10337
10439
  var _MockResponseSingleton = class _MockResponseSingleton {
10338
10440
  constructor() {
10339
10441
  __publicField(this, "mockRes");
@@ -10388,21 +10490,21 @@ var createSpoofInitMessage = (mcpProtocolVersion) => ({
10388
10490
  id: 0
10389
10491
  });
10390
10492
  var spoofTransportInitialization = async (transport, req, sessionId, mcpProtocolVersion) => {
10391
- logger24.info({ sessionId }, "Spoofing initialization message to set transport state");
10493
+ logger23.info({ sessionId }, "Spoofing initialization message to set transport state");
10392
10494
  const spoofInitMessage = createSpoofInitMessage(mcpProtocolVersion);
10393
10495
  const mockRes = MockResponseSingleton.getInstance().getMockResponse();
10394
10496
  try {
10395
10497
  await transport.handleRequest(req, mockRes, spoofInitMessage);
10396
- logger24.info({ sessionId }, "Successfully spoofed initialization");
10498
+ logger23.info({ sessionId }, "Successfully spoofed initialization");
10397
10499
  } catch (spoofError) {
10398
- logger24.warn({ sessionId, error: spoofError }, "Spoof initialization failed, continuing anyway");
10500
+ logger23.warn({ sessionId, error: spoofError }, "Spoof initialization failed, continuing anyway");
10399
10501
  }
10400
10502
  };
10401
10503
  var validateSession = async (req, res, body, tenantId, projectId, graphId) => {
10402
10504
  const sessionId = req.headers["mcp-session-id"];
10403
- logger24.info({ sessionId }, "Received MCP session ID");
10505
+ logger23.info({ sessionId }, "Received MCP session ID");
10404
10506
  if (!sessionId) {
10405
- logger24.info({ body }, "Missing session ID");
10507
+ logger23.info({ body }, "Missing session ID");
10406
10508
  res.writeHead(400).end(
10407
10509
  JSON.stringify({
10408
10510
  jsonrpc: "2.0",
@@ -10428,7 +10530,7 @@ var validateSession = async (req, res, body, tenantId, projectId, graphId) => {
10428
10530
  scopes: { tenantId, projectId },
10429
10531
  conversationId: sessionId
10430
10532
  });
10431
- logger24.info(
10533
+ logger23.info(
10432
10534
  {
10433
10535
  sessionId,
10434
10536
  conversationFound: !!conversation,
@@ -10439,7 +10541,7 @@ var validateSession = async (req, res, body, tenantId, projectId, graphId) => {
10439
10541
  "Conversation lookup result"
10440
10542
  );
10441
10543
  if (!conversation || conversation.metadata?.sessionData?.sessionType !== "mcp" || conversation.metadata?.sessionData?.graphId !== graphId) {
10442
- logger24.info(
10544
+ logger23.info(
10443
10545
  { sessionId, conversationId: conversation?.id },
10444
10546
  "MCP session not found or invalid"
10445
10547
  );
@@ -10488,7 +10590,7 @@ var processUserMessage = async (tenantId, projectId, conversationId, query) => {
10488
10590
  messageType: "chat"
10489
10591
  });
10490
10592
  };
10491
- var executeAgentQuery = async (executionContext, conversationId, query, defaultAgentId) => {
10593
+ var executeAgentQuery = async (executionContext, conversationId, query, defaultSubAgentId) => {
10492
10594
  const requestId2 = `mcp-${Date.now()}`;
10493
10595
  const mcpStreamHelper = createMCPStreamHelper();
10494
10596
  const executionHandler = new ExecutionHandler();
@@ -10496,11 +10598,11 @@ var executeAgentQuery = async (executionContext, conversationId, query, defaultA
10496
10598
  executionContext,
10497
10599
  conversationId,
10498
10600
  userMessage: query,
10499
- initialAgentId: defaultAgentId,
10601
+ initialAgentId: defaultSubAgentId,
10500
10602
  requestId: requestId2,
10501
10603
  sseHelper: mcpStreamHelper
10502
10604
  });
10503
- logger24.info(
10605
+ logger23.info(
10504
10606
  { result },
10505
10607
  `Execution completed: ${result.success ? "success" : "failed"} after ${result.iterations} iterations`
10506
10608
  );
@@ -10527,7 +10629,7 @@ var executeAgentQuery = async (executionContext, conversationId, query, defaultA
10527
10629
  var getServer = async (headers, executionContext, conversationId, credentialStores) => {
10528
10630
  const { tenantId, projectId, graphId } = executionContext;
10529
10631
  setupTracing(conversationId, tenantId, graphId);
10530
- const agentGraph = await getAgentGraphWithDefaultAgent(dbClient_default)({
10632
+ const agentGraph = await getAgentGraphWithDefaultSubAgent(dbClient_default)({
10531
10633
  scopes: { tenantId, projectId, graphId }
10532
10634
  });
10533
10635
  if (!agentGraph) {
@@ -10548,7 +10650,7 @@ var getServer = async (headers, executionContext, conversationId, credentialStor
10548
10650
  },
10549
10651
  async ({ query }) => {
10550
10652
  try {
10551
- if (!agentGraph.defaultAgentId) {
10653
+ if (!agentGraph.defaultSubAgentId) {
10552
10654
  return {
10553
10655
  content: [
10554
10656
  {
@@ -10559,10 +10661,10 @@ var getServer = async (headers, executionContext, conversationId, credentialStor
10559
10661
  isError: true
10560
10662
  };
10561
10663
  }
10562
- const defaultAgentId = agentGraph.defaultAgentId;
10563
- const agentInfo = await getAgentById(dbClient_default)({
10664
+ const defaultSubAgentId = agentGraph.defaultSubAgentId;
10665
+ const agentInfo = await getSubAgentById(dbClient_default)({
10564
10666
  scopes: { tenantId, projectId, graphId },
10565
- agentId: defaultAgentId
10667
+ subAgentId: defaultSubAgentId
10566
10668
  });
10567
10669
  if (!agentInfo) {
10568
10670
  return {
@@ -10584,7 +10686,7 @@ var getServer = async (headers, executionContext, conversationId, credentialStor
10584
10686
  dbClient: dbClient_default,
10585
10687
  credentialStores
10586
10688
  });
10587
- logger24.info(
10689
+ logger23.info(
10588
10690
  {
10589
10691
  tenantId,
10590
10692
  projectId,
@@ -10597,7 +10699,7 @@ var getServer = async (headers, executionContext, conversationId, credentialStor
10597
10699
  "parameters"
10598
10700
  );
10599
10701
  await processUserMessage(tenantId, projectId, conversationId, query);
10600
- return executeAgentQuery(executionContext, conversationId, query, defaultAgentId);
10702
+ return executeAgentQuery(executionContext, conversationId, query, defaultSubAgentId);
10601
10703
  } catch (error) {
10602
10704
  return {
10603
10705
  content: [
@@ -10646,9 +10748,9 @@ var validateRequestParameters = (c) => {
10646
10748
  };
10647
10749
  var handleInitializationRequest = async (body, executionContext, validatedContext, req, res, c, credentialStores) => {
10648
10750
  const { tenantId, projectId, graphId } = executionContext;
10649
- logger24.info({ body }, "Received initialization request");
10751
+ logger23.info({ body }, "Received initialization request");
10650
10752
  const sessionId = getConversationId();
10651
- const agentGraph = await getAgentGraphWithDefaultAgent(dbClient_default)({
10753
+ const agentGraph = await getAgentGraphWithDefaultSubAgent(dbClient_default)({
10652
10754
  scopes: { tenantId, projectId, graphId }
10653
10755
  });
10654
10756
  if (!agentGraph) {
@@ -10661,7 +10763,7 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
10661
10763
  { status: 404 }
10662
10764
  );
10663
10765
  }
10664
- if (!agentGraph.defaultAgentId) {
10766
+ if (!agentGraph.defaultSubAgentId) {
10665
10767
  return c.json(
10666
10768
  {
10667
10769
  jsonrpc: "2.0",
@@ -10675,7 +10777,7 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
10675
10777
  id: sessionId,
10676
10778
  tenantId,
10677
10779
  projectId,
10678
- activeAgentId: agentGraph.defaultAgentId,
10780
+ activeSubAgentId: agentGraph.defaultSubAgentId,
10679
10781
  metadata: {
10680
10782
  sessionData: {
10681
10783
  graphId,
@@ -10686,7 +10788,7 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
10686
10788
  }
10687
10789
  }
10688
10790
  });
10689
- logger24.info(
10791
+ logger23.info(
10690
10792
  { sessionId, conversationId: conversation.id },
10691
10793
  "Created MCP session as conversation"
10692
10794
  );
@@ -10695,9 +10797,9 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
10695
10797
  });
10696
10798
  const server = await getServer(validatedContext, executionContext, sessionId, credentialStores);
10697
10799
  await server.connect(transport);
10698
- logger24.info({ sessionId }, "Server connected for initialization");
10800
+ logger23.info({ sessionId }, "Server connected for initialization");
10699
10801
  res.setHeader("Mcp-Session-Id", sessionId);
10700
- logger24.info(
10802
+ logger23.info(
10701
10803
  {
10702
10804
  sessionId,
10703
10805
  bodyMethod: body?.method,
@@ -10706,7 +10808,7 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
10706
10808
  "About to handle initialization request"
10707
10809
  );
10708
10810
  await transport.handleRequest(req, res, body);
10709
- logger24.info({ sessionId }, "Successfully handled initialization request");
10811
+ logger23.info({ sessionId }, "Successfully handled initialization request");
10710
10812
  return toFetchResponse(res);
10711
10813
  };
10712
10814
  var handleExistingSessionRequest = async (body, executionContext, validatedContext, req, res, credentialStores) => {
@@ -10734,8 +10836,8 @@ var handleExistingSessionRequest = async (body, executionContext, validatedConte
10734
10836
  sessionId,
10735
10837
  conversation.metadata?.session_data?.mcpProtocolVersion
10736
10838
  );
10737
- logger24.info({ sessionId }, "Server connected and transport initialized");
10738
- logger24.info(
10839
+ logger23.info({ sessionId }, "Server connected and transport initialized");
10840
+ logger23.info(
10739
10841
  {
10740
10842
  sessionId,
10741
10843
  bodyKeys: Object.keys(body || {}),
@@ -10749,9 +10851,9 @@ var handleExistingSessionRequest = async (body, executionContext, validatedConte
10749
10851
  );
10750
10852
  try {
10751
10853
  await transport.handleRequest(req, res, body);
10752
- logger24.info({ sessionId }, "Successfully handled MCP request");
10854
+ logger23.info({ sessionId }, "Successfully handled MCP request");
10753
10855
  } catch (transportError) {
10754
- logger24.error(
10856
+ logger23.error(
10755
10857
  {
10756
10858
  sessionId,
10757
10859
  error: transportError,
@@ -10802,13 +10904,13 @@ app4.openapi(
10802
10904
  }
10803
10905
  const { executionContext } = paramValidation;
10804
10906
  const body = c.get("requestBody") || {};
10805
- logger24.info({ body, bodyKeys: Object.keys(body || {}) }, "Parsed request body");
10907
+ logger23.info({ body, bodyKeys: Object.keys(body || {}) }, "Parsed request body");
10806
10908
  const isInitRequest = body.method === "initialize";
10807
10909
  const { req, res } = toReqRes(c.req.raw);
10808
10910
  const validatedContext = c.get("validatedContext") || {};
10809
10911
  const credentialStores = c.get("credentialStores");
10810
- logger24.info({ validatedContext }, "Validated context");
10811
- logger24.info({ req }, "request");
10912
+ logger23.info({ validatedContext }, "Validated context");
10913
+ logger23.info({ req }, "request");
10812
10914
  if (isInitRequest) {
10813
10915
  return await handleInitializationRequest(
10814
10916
  body,
@@ -10830,7 +10932,7 @@ app4.openapi(
10830
10932
  );
10831
10933
  }
10832
10934
  } catch (e) {
10833
- logger24.error(
10935
+ logger23.error(
10834
10936
  {
10835
10937
  error: e instanceof Error ? e.message : e,
10836
10938
  stack: e instanceof Error ? e.stack : void 0
@@ -10842,7 +10944,7 @@ app4.openapi(
10842
10944
  }
10843
10945
  );
10844
10946
  app4.get("/", async (c) => {
10845
- logger24.info({}, "Received GET MCP request");
10947
+ logger23.info({}, "Received GET MCP request");
10846
10948
  return c.json(
10847
10949
  {
10848
10950
  jsonrpc: "2.0",
@@ -10856,7 +10958,7 @@ app4.get("/", async (c) => {
10856
10958
  );
10857
10959
  });
10858
10960
  app4.delete("/", async (c) => {
10859
- logger24.info({}, "Received DELETE MCP request");
10961
+ logger23.info({}, "Received DELETE MCP request");
10860
10962
  return c.json(
10861
10963
  {
10862
10964
  jsonrpc: "2.0",
@@ -10869,7 +10971,7 @@ app4.delete("/", async (c) => {
10869
10971
  var mcp_default = app4;
10870
10972
 
10871
10973
  // src/app.ts
10872
- var logger25 = getLogger("agents-run-api");
10974
+ var logger24 = getLogger("agents-run-api");
10873
10975
  function createExecutionHono(serverConfig, credentialStores) {
10874
10976
  const app6 = new OpenAPIHono();
10875
10977
  app6.use("*", otel());
@@ -10885,7 +10987,7 @@ function createExecutionHono(serverConfig, credentialStores) {
10885
10987
  const body = await c.req.json();
10886
10988
  c.set("requestBody", body);
10887
10989
  } catch (error) {
10888
- logger25.debug({ error }, "Failed to parse JSON body, continuing without parsed body");
10990
+ logger24.debug({ error }, "Failed to parse JSON body, continuing without parsed body");
10889
10991
  }
10890
10992
  }
10891
10993
  return next();
@@ -10936,8 +11038,8 @@ function createExecutionHono(serverConfig, credentialStores) {
10936
11038
  if (!isExpectedError) {
10937
11039
  const errorMessage = err instanceof Error ? err.message : String(err);
10938
11040
  const errorStack = err instanceof Error ? err.stack : void 0;
10939
- if (logger25) {
10940
- logger25.error(
11041
+ if (logger24) {
11042
+ logger24.error(
10941
11043
  {
10942
11044
  error: err,
10943
11045
  message: errorMessage,
@@ -10949,8 +11051,8 @@ function createExecutionHono(serverConfig, credentialStores) {
10949
11051
  );
10950
11052
  }
10951
11053
  } else {
10952
- if (logger25) {
10953
- logger25.error(
11054
+ if (logger24) {
11055
+ logger24.error(
10954
11056
  {
10955
11057
  error: err,
10956
11058
  path: c.req.path,
@@ -10967,8 +11069,8 @@ function createExecutionHono(serverConfig, credentialStores) {
10967
11069
  const response = err.getResponse();
10968
11070
  return response;
10969
11071
  } catch (responseError) {
10970
- if (logger25) {
10971
- logger25.error({ error: responseError }, "Error while handling HTTPException response");
11072
+ if (logger24) {
11073
+ logger24.error({ error: responseError }, "Error while handling HTTPException response");
10972
11074
  }
10973
11075
  }
10974
11076
  }
@@ -11002,7 +11104,7 @@ function createExecutionHono(serverConfig, credentialStores) {
11002
11104
  app6.use("*", async (c, next) => {
11003
11105
  const executionContext = c.get("executionContext");
11004
11106
  if (!executionContext) {
11005
- logger25.debug({}, "Empty execution context");
11107
+ logger24.debug({}, "Empty execution context");
11006
11108
  return next();
11007
11109
  }
11008
11110
  const { tenantId, projectId, graphId } = executionContext;
@@ -11011,7 +11113,7 @@ function createExecutionHono(serverConfig, credentialStores) {
11011
11113
  if (requestBody) {
11012
11114
  conversationId = requestBody.conversationId;
11013
11115
  if (!conversationId) {
11014
- logger25.debug({ requestBody }, "No conversation ID found in request body");
11116
+ logger24.debug({ requestBody }, "No conversation ID found in request body");
11015
11117
  }
11016
11118
  }
11017
11119
  const entries = Object.fromEntries(
@@ -11026,7 +11128,7 @@ function createExecutionHono(serverConfig, credentialStores) {
11026
11128
  })
11027
11129
  );
11028
11130
  if (!Object.keys(entries).length) {
11029
- logger25.debug({}, "Empty entries for baggage");
11131
+ logger24.debug({}, "Empty entries for baggage");
11030
11132
  return next();
11031
11133
  }
11032
11134
  const bag = Object.entries(entries).reduce(