@inkeep/agents-run-api 0.37.2 → 0.38.0

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
- import { flushBatchProcessor } from './chunk-QOUOKHYQ.js';
2
- import { getFormattedConversationHistory, createDefaultConversationHistoryConfig, saveA2AMessageResponse } from './chunk-BQB27EXW.js';
3
- import { dbClient_default } from './chunk-W6UIBREL.js';
4
- import { env } from './chunk-CDYXP4BN.js';
1
+ import { defaultSDK, flushBatchProcessor } from './chunk-UC2EPLSW.js';
2
+ import { getFormattedConversationHistory, createDefaultConversationHistoryConfig, saveA2AMessageResponse } from './chunk-KCJWSIDZ.js';
3
+ import { dbClient_default } from './chunk-EVOISBFH.js';
4
+ import { env } from './chunk-KBZIYCPJ.js';
5
5
  import { getLogger } from './chunk-A2S7GSHL.js';
6
- import { SESSION_CLEANUP_INTERVAL_MS, AGENT_EXECUTION_MAX_CONSECUTIVE_ERRORS, SESSION_TOOL_RESULT_CACHE_TIMEOUT_MS, STREAM_MAX_LIFETIME_MS, STREAM_BUFFER_MAX_SIZE_BYTES, STREAM_TEXT_GAP_THRESHOLD_MS, ARTIFACT_GENERATION_MAX_RETRIES, ARTIFACT_SESSION_MAX_PENDING, STATUS_UPDATE_DEFAULT_INTERVAL_SECONDS, STATUS_UPDATE_DEFAULT_NUM_EVENTS, ARTIFACT_SESSION_MAX_PREVIOUS_SUMMARIES, AGENT_EXECUTION_MAX_GENERATION_STEPS, FUNCTION_TOOL_SANDBOX_VCPUS_DEFAULT, FUNCTION_TOOL_EXECUTION_TIMEOUT_MS_DEFAULT, LLM_GENERATION_MAX_ALLOWED_TIMEOUT_MS, ARTIFACT_GENERATION_BACKOFF_INITIAL_MS, ARTIFACT_GENERATION_BACKOFF_MAX_MS, LLM_GENERATION_FIRST_CALL_TIMEOUT_MS_STREAMING, LLM_GENERATION_FIRST_CALL_TIMEOUT_MS_NON_STREAMING, LLM_GENERATION_SUBSEQUENT_CALL_TIMEOUT_MS, DELEGATION_TOOL_BACKOFF_MAX_ELAPSED_TIME_MS, DELEGATION_TOOL_BACKOFF_EXPONENT, DELEGATION_TOOL_BACKOFF_MAX_INTERVAL_MS, DELEGATION_TOOL_BACKOFF_INITIAL_INTERVAL_MS, STREAM_PARSER_MAX_SNAPSHOT_SIZE, STREAM_PARSER_MAX_STREAMED_SIZE, STREAM_PARSER_MAX_COLLECTED_PARTS } from './chunk-SUUSOBLI.js';
7
- import { getTracer, HeadersScopeSchema, getRequestExecutionContext, createApiError, getAgentWithDefaultSubAgent, contextValidationMiddleware, getConversationId, getFullAgent, createOrGetConversation, getActiveAgentForConversation, setActiveAgentForConversation, getSubAgentById, handleContextResolution, createMessage, generateId, commonGetErrorResponses, loggerFactory, getConversation, createDefaultCredentialStores, CredentialStoreRegistry, createTask, getTask, updateTask, setSpanWithError, AGENT_EXECUTION_TRANSFER_COUNT_DEFAULT, updateConversation, handleApiError, TaskState, getAgentById, getProject, setActiveAgentForThread, getRelatedAgentsForAgent, getExternalAgentsForSubAgent, getTeamAgentsForSubAgent, getToolsForAgent, getDataComponentsForAgent, getArtifactComponentsForAgent, dbResultToMcpTool, CONVERSATION_HISTORY_MAX_OUTPUT_TOKENS_DEFAULT, CONVERSATION_HISTORY_DEFAULT_LIMIT, ModelFactory, verifyTempToken, validateAndGetApiKey, verifyServiceToken, validateTargetAgent, ContextResolver, CredentialStuffer, MCPServerType, getCredentialReference, McpClient, getFunctionToolsForSubAgent, getFunction, getContextConfigById, getFullAgentDefinition, TemplateEngine, listTaskIdsByContextId, getLedgerArtifacts, agentHasArtifactComponents, upsertLedgerArtifact, MCPTransportType, SPAN_KEYS, headers, generateServiceToken } from '@inkeep/agents-core';
6
+ import { SESSION_CLEANUP_INTERVAL_MS, AGENT_EXECUTION_MAX_CONSECUTIVE_ERRORS, SESSION_TOOL_RESULT_CACHE_TIMEOUT_MS, STREAM_MAX_LIFETIME_MS, STREAM_BUFFER_MAX_SIZE_BYTES, STREAM_TEXT_GAP_THRESHOLD_MS, ARTIFACT_GENERATION_MAX_RETRIES, ARTIFACT_SESSION_MAX_PENDING, STATUS_UPDATE_DEFAULT_INTERVAL_SECONDS, STATUS_UPDATE_DEFAULT_NUM_EVENTS, ARTIFACT_SESSION_MAX_PREVIOUS_SUMMARIES, AGENT_EXECUTION_MAX_GENERATION_STEPS, FUNCTION_TOOL_SANDBOX_VCPUS_DEFAULT, FUNCTION_TOOL_EXECUTION_TIMEOUT_MS_DEFAULT, LLM_GENERATION_MAX_ALLOWED_TIMEOUT_MS, ARTIFACT_GENERATION_BACKOFF_INITIAL_MS, ARTIFACT_GENERATION_BACKOFF_MAX_MS, LLM_GENERATION_FIRST_CALL_TIMEOUT_MS_STREAMING, LLM_GENERATION_FIRST_CALL_TIMEOUT_MS_NON_STREAMING, LLM_GENERATION_SUBSEQUENT_CALL_TIMEOUT_MS, DELEGATION_TOOL_BACKOFF_MAX_ELAPSED_TIME_MS, DELEGATION_TOOL_BACKOFF_EXPONENT, DELEGATION_TOOL_BACKOFF_MAX_INTERVAL_MS, DELEGATION_TOOL_BACKOFF_INITIAL_INTERVAL_MS, STREAM_PARSER_MAX_SNAPSHOT_SIZE, STREAM_PARSER_MAX_STREAMED_SIZE, STREAM_PARSER_MAX_COLLECTED_PARTS } from './chunk-THWNUGWP.js';
7
+ import { getTracer, HeadersScopeSchema, getRequestExecutionContext, createApiError, getAgentWithDefaultSubAgent, contextValidationMiddleware, getConversationId, getFullAgent, createOrGetConversation, getActiveAgentForConversation, setActiveAgentForConversation, getSubAgentById, handleContextResolution, createMessage, generateId, commonGetErrorResponses, loggerFactory, getConversation, createDefaultCredentialStores, CredentialStoreRegistry, createTask, getTask, updateTask, setSpanWithError, AGENT_EXECUTION_TRANSFER_COUNT_DEFAULT, updateConversation, handleApiError, TaskState, getAgentById, getProject, setActiveAgentForThread, getRelatedAgentsForAgent, getExternalAgentsForSubAgent, getTeamAgentsForSubAgent, getToolsForAgent, getDataComponentsForAgent, getArtifactComponentsForAgent, dbResultToMcpTool, CONVERSATION_HISTORY_MAX_OUTPUT_TOKENS_DEFAULT, CONVERSATION_HISTORY_DEFAULT_LIMIT, ModelFactory, verifyTempToken, validateAndGetApiKey, verifyServiceToken, validateTargetAgent, ContextResolver, CredentialStuffer, MCPServerType, getUserScopedCredentialReference, getCredentialReference, McpClient, getFunctionToolsForSubAgent, getFunction, jsonSchemaToZod, getContextConfigById, getFullAgentDefinition, TemplateEngine, listTaskIdsByContextId, getLedgerArtifacts, agentHasArtifactComponents, upsertLedgerArtifact, MCPTransportType, SPAN_KEYS, headers, generateServiceToken } from '@inkeep/agents-core';
8
8
  import { otel } from '@hono/otel';
9
9
  import { OpenAPIHono, createRoute, z } from '@hono/zod-openapi';
10
10
  import { trace, propagation, context, SpanStatusCode } from '@opentelemetry/api';
@@ -25,6 +25,10 @@ import { StreamableHTTPServerTransport } from '@alcyone-labs/modelcontextprotoco
25
25
  import { toReqRes, toFetchResponse } from 'fetch-to-node';
26
26
 
27
27
  // src/types/execution-context.ts
28
+ function getUserIdFromContext(ctx) {
29
+ const metadata = ctx.metadata;
30
+ return metadata?.initiatedBy?.type === "user" ? metadata.initiatedBy.id : void 0;
31
+ }
28
32
  function createExecutionContext(params) {
29
33
  return {
30
34
  apiKey: params.apiKey,
@@ -2659,13 +2663,30 @@ var AgentSession = class {
2659
2663
  /**
2660
2664
  * Clean up status update resources when session ends
2661
2665
  */
2662
- cleanup() {
2666
+ async cleanup() {
2663
2667
  this.isEnded = true;
2664
2668
  if (this.statusUpdateTimer) {
2665
2669
  clearInterval(this.statusUpdateTimer);
2666
2670
  this.statusUpdateTimer = void 0;
2667
2671
  }
2668
2672
  this.statusUpdateState = void 0;
2673
+ if (this.pendingArtifacts.size > 0) {
2674
+ const maxWaitTime = 1e4;
2675
+ const startTime = Date.now();
2676
+ while (this.pendingArtifacts.size > 0 && Date.now() - startTime < maxWaitTime) {
2677
+ await new Promise((resolve) => setTimeout(resolve, 100));
2678
+ }
2679
+ if (this.pendingArtifacts.size > 0) {
2680
+ logger7.warn(
2681
+ {
2682
+ sessionId: this.sessionId,
2683
+ pendingCount: this.pendingArtifacts.size,
2684
+ pendingIds: Array.from(this.pendingArtifacts)
2685
+ },
2686
+ "Cleanup proceeding with pending artifacts still processing"
2687
+ );
2688
+ }
2689
+ }
2669
2690
  this.pendingArtifacts.clear();
2670
2691
  this.artifactProcessingErrors.clear();
2671
2692
  this.artifactCache.clear();
@@ -3440,6 +3461,9 @@ Make it specific and relevant.`;
3440
3461
  result = object;
3441
3462
  }
3442
3463
  try {
3464
+ if (!this.artifactService) {
3465
+ throw new Error("ArtifactService is not initialized");
3466
+ }
3443
3467
  await this.artifactService.saveArtifact({
3444
3468
  artifactId: artifactData.artifactId,
3445
3469
  name: result.name,
@@ -3629,7 +3653,7 @@ var AgentSessionManager = class {
3629
3653
  /**
3630
3654
  * End a session and return the final event data
3631
3655
  */
3632
- endSession(sessionId) {
3656
+ async endSession(sessionId) {
3633
3657
  const session = this.sessions.get(sessionId);
3634
3658
  if (!session) {
3635
3659
  logger7.warn({ sessionId }, "Attempted to end non-existent session");
@@ -3638,7 +3662,7 @@ var AgentSessionManager = class {
3638
3662
  const events = session.getEvents();
3639
3663
  const summary = session.getSummary();
3640
3664
  logger7.info({ sessionId, summary }, "AgentSession ended");
3641
- session.cleanup();
3665
+ await session.cleanup();
3642
3666
  this.sessions.delete(sessionId);
3643
3667
  return events;
3644
3668
  }
@@ -4463,46 +4487,6 @@ function errorOp(message, subAgentId, severity = "error", code) {
4463
4487
  function generateToolId() {
4464
4488
  return `tool_${generateId(8)}`;
4465
4489
  }
4466
- var logger11 = getLogger("DataComponentSchema");
4467
- function jsonSchemaToZod(jsonSchema) {
4468
- if (!jsonSchema || typeof jsonSchema !== "object") {
4469
- logger11.warn({ jsonSchema }, "Invalid JSON schema provided, using string fallback");
4470
- return z.string();
4471
- }
4472
- switch (jsonSchema.type) {
4473
- case "object":
4474
- if (jsonSchema.properties) {
4475
- const shape = {};
4476
- for (const [key, prop] of Object.entries(jsonSchema.properties)) {
4477
- shape[key] = jsonSchemaToZod(prop);
4478
- }
4479
- return z.object(shape);
4480
- }
4481
- return z.record(z.string(), z.unknown());
4482
- case "array": {
4483
- const itemSchema = jsonSchema.items ? jsonSchemaToZod(jsonSchema.items) : z.unknown();
4484
- return z.array(itemSchema);
4485
- }
4486
- case "string":
4487
- return z.string();
4488
- case "number":
4489
- case "integer":
4490
- return z.number();
4491
- case "boolean":
4492
- return z.boolean();
4493
- case "null":
4494
- return z.null();
4495
- default:
4496
- logger11.warn(
4497
- {
4498
- unsupportedType: jsonSchema.type,
4499
- schema: jsonSchema
4500
- },
4501
- "Unsupported JSON schema type, using unknown validation"
4502
- );
4503
- return z.unknown();
4504
- }
4505
- }
4506
4490
  var SchemaProcessor = class _SchemaProcessor {
4507
4491
  static logger = getLogger("SchemaProcessor");
4508
4492
  /**
@@ -4859,7 +4843,7 @@ function parseEmbeddedJson(data) {
4859
4843
  }
4860
4844
 
4861
4845
  // src/a2a/client.ts
4862
- var logger12 = getLogger("a2aClient");
4846
+ var logger11 = getLogger("a2aClient");
4863
4847
  var DEFAULT_BACKOFF = {
4864
4848
  initialInterval: 500,
4865
4849
  maxInterval: 6e4,
@@ -5066,7 +5050,7 @@ var A2AClient = class {
5066
5050
  try {
5067
5051
  const res = await fn();
5068
5052
  if (attempt > 0) {
5069
- logger12.info(
5053
+ logger11.info(
5070
5054
  {
5071
5055
  attempts: attempt + 1,
5072
5056
  elapsedTime: Date.now() - start
@@ -5081,7 +5065,7 @@ var A2AClient = class {
5081
5065
  }
5082
5066
  const elapsed = Date.now() - start;
5083
5067
  if (elapsed > maxElapsedTime) {
5084
- logger12.warn(
5068
+ logger11.warn(
5085
5069
  {
5086
5070
  attempts: attempt + 1,
5087
5071
  elapsedTime: elapsed,
@@ -5102,7 +5086,7 @@ var A2AClient = class {
5102
5086
  retryInterval = initialInterval * attempt ** exponent + Math.random() * 1e3;
5103
5087
  }
5104
5088
  const delayMs = Math.min(retryInterval, maxInterval);
5105
- logger12.info(
5089
+ logger11.info(
5106
5090
  {
5107
5091
  attempt: attempt + 1,
5108
5092
  delayMs,
@@ -5193,7 +5177,7 @@ var A2AClient = class {
5193
5177
  });
5194
5178
  }
5195
5179
  if (rpcResponse.id !== requestId2) {
5196
- logger12.warn(
5180
+ logger11.warn(
5197
5181
  {
5198
5182
  method,
5199
5183
  expectedId: requestId2,
@@ -5390,7 +5374,7 @@ var A2AClient = class {
5390
5374
  try {
5391
5375
  while (true) {
5392
5376
  const { done, value } = await reader.read();
5393
- logger12.info({ done, value }, "parseA2ASseStream");
5377
+ logger11.info({ done, value }, "parseA2ASseStream");
5394
5378
  if (done) {
5395
5379
  if (eventDataBuffer.trim()) {
5396
5380
  const result = this._processSseEventData(
@@ -5477,7 +5461,7 @@ var A2AClient = class {
5477
5461
  };
5478
5462
 
5479
5463
  // src/agents/relationTools.ts
5480
- var logger13 = getLogger("relationships Tools");
5464
+ var logger12 = getLogger("relationships Tools");
5481
5465
  var A2A_RETRY_STATUS_CODES = ["429", "500", "502", "503", "504"];
5482
5466
  var generateTransferToolDescription = (config) => {
5483
5467
  let toolsSection = "";
@@ -5588,7 +5572,7 @@ var createTransferToAgentTool = ({
5588
5572
  [SPAN_KEYS.TRANSFER_TO_SUB_AGENT_ID]: transferConfig.id ?? "unknown"
5589
5573
  });
5590
5574
  }
5591
- logger13.info(
5575
+ logger12.info(
5592
5576
  {
5593
5577
  transferTo: transferConfig.id ?? "unknown",
5594
5578
  fromSubAgent: callingAgentId
@@ -5609,7 +5593,7 @@ var createTransferToAgentTool = ({
5609
5593
  fromSubAgentId: callingAgentId
5610
5594
  // Include the calling agent ID for tracking
5611
5595
  };
5612
- logger13.info(
5596
+ logger12.info(
5613
5597
  {
5614
5598
  transferResult,
5615
5599
  transferResultKeys: Object.keys(transferResult)
@@ -5756,7 +5740,7 @@ function createDelegateToAgentTool({
5756
5740
  ...isInternal ? { fromSubAgentId: callingAgentId } : { fromExternalAgentId: callingAgentId }
5757
5741
  }
5758
5742
  };
5759
- logger13.info({ messageToSend }, "messageToSend");
5743
+ logger12.info({ messageToSend }, "messageToSend");
5760
5744
  await createMessage(dbClient_default)({
5761
5745
  id: generateId(),
5762
5746
  tenantId,
@@ -5818,7 +5802,7 @@ function createDelegateToAgentTool({
5818
5802
  }
5819
5803
 
5820
5804
  // src/agents/SystemPromptBuilder.ts
5821
- var logger14 = getLogger("SystemPromptBuilder");
5805
+ var logger13 = getLogger("SystemPromptBuilder");
5822
5806
  var SystemPromptBuilder = class {
5823
5807
  constructor(version, versionConfig) {
5824
5808
  this.version = version;
@@ -5834,12 +5818,12 @@ var SystemPromptBuilder = class {
5834
5818
  this.templates.set(name, content);
5835
5819
  }
5836
5820
  this.loaded = true;
5837
- logger14.debug(
5821
+ logger13.debug(
5838
5822
  { templateCount: this.templates.size, version: this.version },
5839
5823
  `Loaded ${this.templates.size} templates for version ${this.version}`
5840
5824
  );
5841
5825
  } catch (error) {
5842
- logger14.error({ error }, `Failed to load templates for version ${this.version}`);
5826
+ logger13.error({ error }, `Failed to load templates for version ${this.version}`);
5843
5827
  throw new Error(`Template loading failed: ${error}`);
5844
5828
  }
5845
5829
  }
@@ -6079,7 +6063,14 @@ var Phase1Config = class _Phase1Config {
6079
6063
  throw new Error("System prompt template not loaded");
6080
6064
  }
6081
6065
  let systemPrompt = systemPromptTemplate;
6082
- systemPrompt = systemPrompt.replace("{{CORE_INSTRUCTIONS}}", config.corePrompt);
6066
+ if (config.corePrompt && config.corePrompt.trim()) {
6067
+ systemPrompt = systemPrompt.replace("{{CORE_INSTRUCTIONS}}", config.corePrompt);
6068
+ } else {
6069
+ systemPrompt = systemPrompt.replace(
6070
+ /<core_instructions>\s*\{\{CORE_INSTRUCTIONS\}\}\s*<\/core_instructions>/g,
6071
+ ""
6072
+ );
6073
+ }
6083
6074
  const agentContextSection = this.generateAgentContextSection(config.prompt);
6084
6075
  systemPrompt = systemPrompt.replace("{{AGENT_CONTEXT_SECTION}}", agentContextSection);
6085
6076
  const toolData = this.isToolDataArray(config.tools) ? config.tools : _Phase1Config.convertMcpToolsToToolData(config.tools);
@@ -6109,7 +6100,7 @@ var Phase1Config = class _Phase1Config {
6109
6100
  return systemPrompt;
6110
6101
  }
6111
6102
  generateAgentContextSection(prompt) {
6112
- if (!prompt) {
6103
+ if (!prompt || prompt.trim() === "") {
6113
6104
  return "";
6114
6105
  }
6115
6106
  return `
@@ -6246,6 +6237,8 @@ THE details PROPERTY MUST CONTAIN JMESPATH SELECTORS THAT EXTRACT DATA FROM THE
6246
6237
  \u274C NEVER: [?text ~ contains(@, 'word')] (~ with @ operator)
6247
6238
  \u274C NEVER: contains(@, 'text') (@ operator usage)
6248
6239
  \u274C NEVER: [?field=="value"] (double quotes in filters)
6240
+ \u274C NEVER: [?field=='value'] (escaped quotes in filters)
6241
+ \u274C NEVER: [?field=='"'"'value'"'"'] (nightmare quote mixing)
6249
6242
  \u274C NEVER: result.items[?type=='doc'][?status=='active'] (chained filters)
6250
6243
 
6251
6244
  \u2705 CORRECT JMESPATH SYNTAX:
@@ -6257,6 +6250,11 @@ THE details PROPERTY MUST CONTAIN JMESPATH SELECTORS THAT EXTRACT DATA FROM THE
6257
6250
  \u2705 [?contains(text, 'Founder')] (contains haystack, needle format)
6258
6251
  \u2705 source.content[?contains(text, 'Founder')].text (correct filter usage)
6259
6252
 
6253
+ \u{1F6A8} MANDATORY QUOTE PATTERN - FOLLOW EXACTLY:
6254
+ - ALWAYS: base="path[?field=='value']" (double quotes outside, single inside)
6255
+ - This is the ONLY allowed pattern - any other pattern WILL FAIL
6256
+ - NEVER escape quotes, NEVER mix quote types, NEVER use complex quoting
6257
+
6260
6258
  \u{1F6A8} CRITICAL: EXAMINE TOOL RESULTS BEFORE CREATING SELECTORS! \u{1F6A8}
6261
6259
 
6262
6260
  STEP 1: INSPECT THE ACTUAL DATA FIRST
@@ -6295,7 +6293,7 @@ Only use artifact:ref when you need to cite the SAME artifact again for a differ
6295
6293
  Format: <artifact:ref id="artifact-id" tool="tool_call_id" />
6296
6294
 
6297
6295
  EXAMPLE TEXT RESPONSE:
6298
- "I found the authentication documentation. <artifact:create id='auth-doc-1' tool='call_xyz789' type='APIDoc' base='result.documents[?type=="auth"]' details='{"title":"metadata.title","endpoint":"api.endpoint","description":"content.description","parameters":"spec.parameters","examples":"examples.sample_code"}' /> The documentation explains OAuth 2.0 implementation in detail.
6296
+ "I found the authentication documentation. <artifact:create id='auth-doc-1' tool='call_xyz789' type='APIDoc' base="result.documents[?type=='auth']" details='{"title":"metadata.title","endpoint":"api.endpoint","description":"content.description","parameters":"spec.parameters","examples":"examples.sample_code"}' /> The documentation explains OAuth 2.0 implementation in detail.
6299
6297
 
6300
6298
  The process involves three main steps: registration, token exchange, and API calls. As mentioned in the authentication documentation <artifact:ref id='auth-doc-1' tool='call_xyz789' />, you'll need to register your application first."
6301
6299
 
@@ -6793,7 +6791,7 @@ ${componentDescriptions}`;
6793
6791
  dataComponentXml = dataComponentXml.replace("{{COMPONENT_NAME}}", dataComponent.name);
6794
6792
  dataComponentXml = dataComponentXml.replace(
6795
6793
  "{{COMPONENT_DESCRIPTION}}",
6796
- dataComponent.description
6794
+ dataComponent.description || ""
6797
6795
  );
6798
6796
  dataComponentXml = dataComponentXml.replace(
6799
6797
  "{{COMPONENT_PROPS_SCHEMA}}",
@@ -6889,7 +6887,14 @@ ${artifact_retrieval_guidance_default}
6889
6887
  artifactComponents
6890
6888
  );
6891
6889
  let phase2Prompt = system_prompt_default2;
6892
- phase2Prompt = phase2Prompt.replace("{{CORE_INSTRUCTIONS}}", corePrompt);
6890
+ if (corePrompt && corePrompt.trim()) {
6891
+ phase2Prompt = phase2Prompt.replace("{{CORE_INSTRUCTIONS}}", corePrompt);
6892
+ } else {
6893
+ phase2Prompt = phase2Prompt.replace(
6894
+ /<core_instructions>\s*\{\{CORE_INSTRUCTIONS\}\}\s*<\/core_instructions>/g,
6895
+ ""
6896
+ );
6897
+ }
6893
6898
  phase2Prompt = phase2Prompt.replace("{{DATA_COMPONENTS_SECTION}}", dataComponentsSection);
6894
6899
  phase2Prompt = phase2Prompt.replace("{{ARTIFACTS_SECTION}}", artifactsSection);
6895
6900
  phase2Prompt = phase2Prompt.replace("{{ARTIFACT_GUIDANCE_SECTION}}", artifactGuidance);
@@ -6908,7 +6913,7 @@ function hasToolCallWithPrefix(prefix) {
6908
6913
  return false;
6909
6914
  };
6910
6915
  }
6911
- var logger15 = getLogger("Agent");
6916
+ var logger14 = getLogger("Agent");
6912
6917
  function validateModel(modelString, modelType) {
6913
6918
  if (!modelString?.trim()) {
6914
6919
  throw new Error(
@@ -7014,6 +7019,32 @@ var Agent = class {
7014
7019
  }
7015
7020
  return sanitizedTools;
7016
7021
  }
7022
+ #createRelationToolName(prefix, targetId) {
7023
+ return `${prefix}_to_${targetId.toLowerCase().replace(/\s+/g, "_")}`;
7024
+ }
7025
+ #getRelationshipIdForTool(toolName, toolType) {
7026
+ if (toolType === "mcp") {
7027
+ const matchingTool = this.config.tools?.find((tool3) => {
7028
+ if (tool3.config?.type !== "mcp") {
7029
+ return false;
7030
+ }
7031
+ if (tool3.availableTools?.some((available) => available.name === toolName)) {
7032
+ return true;
7033
+ }
7034
+ if (tool3.config.mcp.activeTools?.includes(toolName)) {
7035
+ return true;
7036
+ }
7037
+ return tool3.name === toolName;
7038
+ });
7039
+ return matchingTool?.relationshipId;
7040
+ }
7041
+ if (toolType === "delegation") {
7042
+ const relation = this.config.delegateRelations.find(
7043
+ (relation2) => this.#createRelationToolName("delegate", relation2.config.id) === toolName
7044
+ );
7045
+ return relation?.config.relationId;
7046
+ }
7047
+ }
7017
7048
  /**
7018
7049
  * Get the primary model settings for text generation and thinking
7019
7050
  * Requires model to be configured at project level
@@ -7082,10 +7113,11 @@ var Agent = class {
7082
7113
  /**
7083
7114
  * Wraps a tool with streaming lifecycle tracking (start, complete, error) and AgentSession recording
7084
7115
  */
7085
- wrapToolWithStreaming(toolName, toolDefinition, streamRequestId, toolType, relationshipId, options) {
7116
+ wrapToolWithStreaming(toolName, toolDefinition, streamRequestId, toolType, options) {
7086
7117
  if (!toolDefinition || typeof toolDefinition !== "object" || !("execute" in toolDefinition)) {
7087
7118
  return toolDefinition;
7088
7119
  }
7120
+ const relationshipId = this.#getRelationshipIdForTool(toolName, toolType);
7089
7121
  const originalExecute = toolDefinition.execute;
7090
7122
  return {
7091
7123
  ...toolDefinition,
@@ -7154,7 +7186,7 @@ var Agent = class {
7154
7186
  };
7155
7187
  await createMessage(dbClient_default)(messagePayload);
7156
7188
  } catch (error) {
7157
- logger15.warn(
7189
+ logger14.warn(
7158
7190
  { error, toolName, toolCallId, conversationId: toolResultConversationId },
7159
7191
  "Failed to store tool result in conversation history"
7160
7192
  );
@@ -7192,10 +7224,9 @@ var Agent = class {
7192
7224
  }
7193
7225
  getRelationTools(runtimeContext, sessionId) {
7194
7226
  const { transferRelations = [], delegateRelations = [] } = this.config;
7195
- const createToolName = (prefix, subAgentId) => `${prefix}_to_${subAgentId.toLowerCase().replace(/\s+/g, "_")}`;
7196
7227
  return Object.fromEntries([
7197
7228
  ...transferRelations.map((agentConfig) => {
7198
- const toolName = createToolName("transfer", agentConfig.id);
7229
+ const toolName = this.#createRelationToolName("transfer", agentConfig.id);
7199
7230
  return [
7200
7231
  toolName,
7201
7232
  this.wrapToolWithStreaming(
@@ -7212,7 +7243,7 @@ var Agent = class {
7212
7243
  ];
7213
7244
  }),
7214
7245
  ...delegateRelations.map((relation) => {
7215
- const toolName = createToolName("delegate", relation.config.id);
7246
+ const toolName = this.#createRelationToolName("delegate", relation.config.id);
7216
7247
  return [
7217
7248
  toolName,
7218
7249
  this.wrapToolWithStreaming(
@@ -7249,8 +7280,7 @@ var Agent = class {
7249
7280
  const tools = await Promise.all(mcpTools.map((tool3) => this.getMcpTool(tool3)) || []) || [];
7250
7281
  if (!sessionId) {
7251
7282
  const wrappedTools2 = {};
7252
- for (const [index, toolSet] of tools.entries()) {
7253
- const relationshipId = mcpTools[index]?.relationshipId;
7283
+ for (const toolSet of tools) {
7254
7284
  for (const [toolName, toolDef] of Object.entries(toolSet.tools)) {
7255
7285
  const needsApproval = toolSet.toolPolicies?.[toolName]?.needsApproval || false;
7256
7286
  const enhancedTool = {
@@ -7262,7 +7292,6 @@ var Agent = class {
7262
7292
  enhancedTool,
7263
7293
  streamRequestId,
7264
7294
  "mcp",
7265
- relationshipId,
7266
7295
  { needsApproval }
7267
7296
  );
7268
7297
  }
@@ -7270,15 +7299,14 @@ var Agent = class {
7270
7299
  return wrappedTools2;
7271
7300
  }
7272
7301
  const wrappedTools = {};
7273
- for (const [index, toolResult] of tools.entries()) {
7274
- const relationshipId = mcpTools[index]?.relationshipId;
7302
+ for (const toolResult of tools) {
7275
7303
  for (const [toolName, originalTool] of Object.entries(toolResult.tools)) {
7276
7304
  if (!isValidTool(originalTool)) {
7277
- logger15.error({ toolName }, "Invalid MCP tool structure - missing required properties");
7305
+ logger14.error({ toolName }, "Invalid MCP tool structure - missing required properties");
7278
7306
  continue;
7279
7307
  }
7280
7308
  const needsApproval = toolResult.toolPolicies?.[toolName]?.needsApproval || false;
7281
- logger15.debug(
7309
+ logger14.debug(
7282
7310
  {
7283
7311
  toolName,
7284
7312
  toolPolicies: toolResult.toolPolicies,
@@ -7292,7 +7320,7 @@ var Agent = class {
7292
7320
  inputSchema: originalTool.inputSchema,
7293
7321
  execute: async (args, { toolCallId }) => {
7294
7322
  if (needsApproval) {
7295
- logger15.info(
7323
+ logger14.info(
7296
7324
  { toolName, toolCallId, args },
7297
7325
  "Tool requires approval - waiting for user response"
7298
7326
  );
@@ -7338,7 +7366,7 @@ var Agent = class {
7338
7366
  }
7339
7367
  },
7340
7368
  (denialSpan) => {
7341
- logger15.info(
7369
+ logger14.info(
7342
7370
  { toolName, toolCallId, reason: approvalResult.reason },
7343
7371
  "Tool execution denied by user"
7344
7372
  );
@@ -7359,18 +7387,18 @@ var Agent = class {
7359
7387
  }
7360
7388
  },
7361
7389
  (approvedSpan) => {
7362
- logger15.info({ toolName, toolCallId }, "Tool approved, continuing with execution");
7390
+ logger14.info({ toolName, toolCallId }, "Tool approved, continuing with execution");
7363
7391
  approvedSpan.setStatus({ code: SpanStatusCode.OK });
7364
7392
  approvedSpan.end();
7365
7393
  }
7366
7394
  );
7367
7395
  }
7368
- logger15.debug({ toolName, toolCallId }, "MCP Tool Called");
7396
+ logger14.debug({ toolName, toolCallId }, "MCP Tool Called");
7369
7397
  try {
7370
7398
  const rawResult = await originalTool.execute(args, { toolCallId });
7371
7399
  if (rawResult && typeof rawResult === "object" && rawResult.isError) {
7372
7400
  const errorMessage = rawResult.content?.[0]?.text || "MCP tool returned an error";
7373
- logger15.error(
7401
+ logger14.error(
7374
7402
  { toolName, toolCallId, errorMessage, rawResult },
7375
7403
  "MCP tool returned error status"
7376
7404
  );
@@ -7382,6 +7410,7 @@ var Agent = class {
7382
7410
  timestamp: Date.now()
7383
7411
  });
7384
7412
  if (streamRequestId) {
7413
+ const relationshipId = this.#getRelationshipIdForTool(toolName, "mcp");
7385
7414
  agentSessionManager.recordEvent(streamRequestId, "error", this.config.id, {
7386
7415
  message: `MCP tool "${toolName}" failed: ${errorMessage}`,
7387
7416
  code: "mcp_tool_error",
@@ -7420,7 +7449,7 @@ var Agent = class {
7420
7449
  });
7421
7450
  return { result: enhancedResult, toolCallId };
7422
7451
  } catch (error) {
7423
- logger15.error({ toolName, toolCallId, error }, "MCP tool execution failed");
7452
+ logger14.error({ toolName, toolCallId, error }, "MCP tool execution failed");
7424
7453
  throw error;
7425
7454
  }
7426
7455
  }
@@ -7430,7 +7459,6 @@ var Agent = class {
7430
7459
  sessionWrappedTool,
7431
7460
  streamRequestId,
7432
7461
  "mcp",
7433
- relationshipId,
7434
7462
  { needsApproval }
7435
7463
  );
7436
7464
  }
@@ -7475,7 +7503,51 @@ var Agent = class {
7475
7503
  const selectedTools = toolRelation?.selectedTools || void 0;
7476
7504
  const toolPolicies = toolRelation?.toolPolicies || {};
7477
7505
  let serverConfig;
7478
- if (credentialReferenceId && this.credentialStuffer) {
7506
+ const isUserScoped = tool3.credentialScope === "user";
7507
+ const userId = this.config.userId;
7508
+ if (isUserScoped && userId && this.credentialStuffer) {
7509
+ const userCredentialReference = await getUserScopedCredentialReference(dbClient_default)({
7510
+ scopes: {
7511
+ tenantId: this.config.tenantId,
7512
+ projectId: this.config.projectId
7513
+ },
7514
+ toolId: tool3.id,
7515
+ userId
7516
+ });
7517
+ if (userCredentialReference) {
7518
+ const storeReference = {
7519
+ credentialStoreId: userCredentialReference.credentialStoreId,
7520
+ retrievalParams: userCredentialReference.retrievalParams || {}
7521
+ };
7522
+ serverConfig = await this.credentialStuffer.buildMcpServerConfig(
7523
+ {
7524
+ tenantId: this.config.tenantId,
7525
+ projectId: this.config.projectId,
7526
+ contextConfigId: this.config.contextConfigId || void 0,
7527
+ conversationId: this.conversationId || void 0
7528
+ },
7529
+ this.convertToMCPToolConfig(tool3, agentToolRelationHeaders),
7530
+ storeReference,
7531
+ selectedTools
7532
+ );
7533
+ } else {
7534
+ logger14.warn(
7535
+ { toolId: tool3.id, userId },
7536
+ "User-scoped tool has no credential connected for this user"
7537
+ );
7538
+ serverConfig = await this.credentialStuffer.buildMcpServerConfig(
7539
+ {
7540
+ tenantId: this.config.tenantId,
7541
+ projectId: this.config.projectId,
7542
+ contextConfigId: this.config.contextConfigId || void 0,
7543
+ conversationId: this.conversationId || void 0
7544
+ },
7545
+ this.convertToMCPToolConfig(tool3, agentToolRelationHeaders),
7546
+ void 0,
7547
+ selectedTools
7548
+ );
7549
+ }
7550
+ } else if (credentialReferenceId && this.credentialStuffer) {
7479
7551
  const credentialReference = await getCredentialReference(dbClient_default)({
7480
7552
  scopes: {
7481
7553
  tenantId: this.config.tenantId,
@@ -7525,7 +7597,7 @@ var Agent = class {
7525
7597
  headers: agentToolRelationHeaders
7526
7598
  };
7527
7599
  }
7528
- logger15.info(
7600
+ logger14.info(
7529
7601
  {
7530
7602
  toolName: tool3.name,
7531
7603
  credentialReferenceId,
@@ -7550,7 +7622,7 @@ var Agent = class {
7550
7622
  this.mcpClientCache.set(cacheKey, client);
7551
7623
  } catch (error) {
7552
7624
  this.mcpConnectionLocks.delete(cacheKey);
7553
- logger15.error(
7625
+ logger14.error(
7554
7626
  {
7555
7627
  toolName: tool3.name,
7556
7628
  subAgentId: this.config.id,
@@ -7615,7 +7687,7 @@ var Agent = class {
7615
7687
  await client.connect();
7616
7688
  return client;
7617
7689
  } catch (error) {
7618
- logger15.error(
7690
+ logger14.error(
7619
7691
  {
7620
7692
  toolName: tool3.name,
7621
7693
  subAgentId: this.config.id,
@@ -7652,12 +7724,12 @@ var Agent = class {
7652
7724
  if (functionToolsData.length === 0) {
7653
7725
  return functionTools;
7654
7726
  }
7655
- const { SandboxExecutorFactory } = await import('./SandboxExecutorFactory-A2LTPE2X.js');
7727
+ const { SandboxExecutorFactory } = await import('./SandboxExecutorFactory-2N27SE3B.js');
7656
7728
  const sandboxExecutor = SandboxExecutorFactory.getInstance();
7657
7729
  for (const functionToolDef of functionToolsData) {
7658
7730
  const functionId = functionToolDef.functionId;
7659
7731
  if (!functionId) {
7660
- logger15.warn(
7732
+ logger14.warn(
7661
7733
  { functionToolId: functionToolDef.id },
7662
7734
  "Function tool missing functionId reference"
7663
7735
  );
@@ -7671,7 +7743,7 @@ var Agent = class {
7671
7743
  }
7672
7744
  });
7673
7745
  if (!functionData) {
7674
- logger15.warn(
7746
+ logger14.warn(
7675
7747
  { functionId, functionToolId: functionToolDef.id },
7676
7748
  "Function not found in functions table"
7677
7749
  );
@@ -7682,7 +7754,7 @@ var Agent = class {
7682
7754
  description: functionToolDef.description || functionToolDef.name,
7683
7755
  inputSchema: zodSchema,
7684
7756
  execute: async (args, { toolCallId }) => {
7685
- logger15.debug(
7757
+ logger14.debug(
7686
7758
  { toolName: functionToolDef.name, toolCallId, args },
7687
7759
  "Function Tool Called"
7688
7760
  );
@@ -7709,7 +7781,7 @@ var Agent = class {
7709
7781
  });
7710
7782
  return { result, toolCallId };
7711
7783
  } catch (error) {
7712
- logger15.error(
7784
+ logger14.error(
7713
7785
  {
7714
7786
  toolName: functionToolDef.name,
7715
7787
  toolCallId,
@@ -7729,7 +7801,7 @@ var Agent = class {
7729
7801
  );
7730
7802
  }
7731
7803
  } catch (error) {
7732
- logger15.error({ error }, "Failed to load function tools from database");
7804
+ logger14.error({ error }, "Failed to load function tools from database");
7733
7805
  }
7734
7806
  return functionTools;
7735
7807
  }
@@ -7739,7 +7811,7 @@ var Agent = class {
7739
7811
  async getResolvedContext(conversationId, headers2) {
7740
7812
  try {
7741
7813
  if (!this.config.contextConfigId) {
7742
- logger15.debug({ agentId: this.config.agentId }, "No context config found for agent");
7814
+ logger14.debug({ agentId: this.config.agentId }, "No context config found for agent");
7743
7815
  return null;
7744
7816
  }
7745
7817
  const contextConfig = await getContextConfigById(dbClient_default)({
@@ -7751,7 +7823,7 @@ var Agent = class {
7751
7823
  id: this.config.contextConfigId
7752
7824
  });
7753
7825
  if (!contextConfig) {
7754
- logger15.warn({ contextConfigId: this.config.contextConfigId }, "Context config not found");
7826
+ logger14.warn({ contextConfigId: this.config.contextConfigId }, "Context config not found");
7755
7827
  return null;
7756
7828
  }
7757
7829
  if (!this.contextResolver) {
@@ -7767,7 +7839,7 @@ var Agent = class {
7767
7839
  ...result.resolvedContext,
7768
7840
  $env: process.env
7769
7841
  };
7770
- logger15.debug(
7842
+ logger14.debug(
7771
7843
  {
7772
7844
  conversationId,
7773
7845
  contextConfigId: contextConfig.id,
@@ -7781,7 +7853,7 @@ var Agent = class {
7781
7853
  );
7782
7854
  return contextWithBuiltins;
7783
7855
  } catch (error) {
7784
- logger15.error(
7856
+ logger14.error(
7785
7857
  {
7786
7858
  conversationId,
7787
7859
  error: error instanceof Error ? error.message : "Unknown error"
@@ -7805,7 +7877,7 @@ var Agent = class {
7805
7877
  });
7806
7878
  return agentDefinition?.prompt || void 0;
7807
7879
  } catch (error) {
7808
- logger15.warn(
7880
+ logger14.warn(
7809
7881
  {
7810
7882
  agentId: this.config.agentId,
7811
7883
  error: error instanceof Error ? error.message : "Unknown error"
@@ -7834,7 +7906,7 @@ var Agent = class {
7834
7906
  (subAgent) => "artifactComponents" in subAgent && subAgent.artifactComponents && subAgent.artifactComponents.length > 0
7835
7907
  );
7836
7908
  } catch (error) {
7837
- logger15.warn(
7909
+ logger14.warn(
7838
7910
  {
7839
7911
  agentId: this.config.agentId,
7840
7912
  tenantId: this.config.tenantId,
@@ -7855,15 +7927,15 @@ var Agent = class {
7855
7927
  const hasAgentArtifactComponents = await this.hasAgentArtifactComponents();
7856
7928
  const conversationId = runtimeContext?.metadata?.conversationId || runtimeContext?.contextId;
7857
7929
  const resolvedContext = conversationId ? await this.getResolvedContext(conversationId) : null;
7858
- let processedPrompt = this.config.prompt;
7859
- if (resolvedContext) {
7930
+ let processedPrompt = this.config.prompt || "";
7931
+ if (resolvedContext && this.config.prompt) {
7860
7932
  try {
7861
7933
  processedPrompt = TemplateEngine.render(this.config.prompt, resolvedContext, {
7862
7934
  strict: false,
7863
7935
  preserveUnresolved: false
7864
7936
  });
7865
7937
  } catch (error) {
7866
- logger15.error(
7938
+ logger14.error(
7867
7939
  {
7868
7940
  conversationId,
7869
7941
  error: error instanceof Error ? error.message : "Unknown error"
@@ -7902,15 +7974,15 @@ var Agent = class {
7902
7974
  this.setConversationId(conversationId);
7903
7975
  }
7904
7976
  const resolvedContext = conversationId ? await this.getResolvedContext(conversationId) : null;
7905
- let processedPrompt = this.config.prompt;
7906
- if (resolvedContext) {
7977
+ let processedPrompt = this.config.prompt || "";
7978
+ if (resolvedContext && this.config.prompt) {
7907
7979
  try {
7908
7980
  processedPrompt = TemplateEngine.render(this.config.prompt, resolvedContext, {
7909
7981
  strict: false,
7910
7982
  preserveUnresolved: false
7911
7983
  });
7912
7984
  } catch (error) {
7913
- logger15.error(
7985
+ logger14.error(
7914
7986
  {
7915
7987
  conversationId,
7916
7988
  error: error instanceof Error ? error.message : "Unknown error"
@@ -7925,7 +7997,7 @@ var Agent = class {
7925
7997
  const functionTools = await this.getFunctionTools(streamRequestId || "");
7926
7998
  const relationTools = this.getRelationTools(runtimeContext);
7927
7999
  const allTools = { ...mcpTools, ...functionTools, ...relationTools };
7928
- logger15.info(
8000
+ logger14.info(
7929
8001
  {
7930
8002
  mcpTools: Object.keys(mcpTools),
7931
8003
  functionTools: Object.keys(functionTools),
@@ -7946,7 +8018,7 @@ var Agent = class {
7946
8018
  inputSchema: tool3.inputSchema || tool3.parameters || {},
7947
8019
  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."
7948
8020
  }));
7949
- const { getConversationScopedArtifacts } = await import('./conversations-33GSAG2C.js');
8021
+ const { getConversationScopedArtifacts } = await import('./conversations-XPSTWUMK.js');
7950
8022
  const historyConfig = this.config.conversationHistoryConfig ?? createDefaultConversationHistoryConfig();
7951
8023
  const referenceArtifacts = await getConversationScopedArtifacts({
7952
8024
  tenantId: this.config.tenantId,
@@ -7964,7 +8036,7 @@ var Agent = class {
7964
8036
  preserveUnresolved: false
7965
8037
  });
7966
8038
  } catch (error) {
7967
- logger15.error(
8039
+ logger14.error(
7968
8040
  {
7969
8041
  conversationId,
7970
8042
  error: error instanceof Error ? error.message : "Unknown error"
@@ -7997,7 +8069,7 @@ var Agent = class {
7997
8069
  toolCallId: z.string().describe("The tool call ID associated with this artifact.")
7998
8070
  }),
7999
8071
  execute: async ({ artifactId, toolCallId }) => {
8000
- logger15.info({ artifactId, toolCallId }, "get_artifact_full executed");
8072
+ logger14.info({ artifactId, toolCallId }, "get_artifact_full executed");
8001
8073
  const streamRequestId = this.getStreamRequestId();
8002
8074
  const artifactService = agentSessionManager.getArtifactService(streamRequestId);
8003
8075
  if (!artifactService) {
@@ -8293,7 +8365,7 @@ ${output}`;
8293
8365
  };
8294
8366
  return enhanced;
8295
8367
  } catch (error) {
8296
- logger15.warn({ error }, "Failed to enhance tool result with structure hints");
8368
+ logger14.warn({ error }, "Failed to enhance tool result with structure hints");
8297
8369
  return result;
8298
8370
  }
8299
8371
  }
@@ -8308,7 +8380,7 @@ ${output}`;
8308
8380
  }
8309
8381
  });
8310
8382
  } catch (error) {
8311
- logger15.error(
8383
+ logger14.error(
8312
8384
  { error, agentId: this.config.agentId },
8313
8385
  "Failed to check agent artifact components"
8314
8386
  );
@@ -8425,7 +8497,7 @@ ${output}`;
8425
8497
  const configuredTimeout = modelSettings.maxDuration ? Math.min(modelSettings.maxDuration * 1e3, LLM_GENERATION_MAX_ALLOWED_TIMEOUT_MS) : shouldStreamPhase1 ? LLM_GENERATION_FIRST_CALL_TIMEOUT_MS_STREAMING : LLM_GENERATION_FIRST_CALL_TIMEOUT_MS_NON_STREAMING;
8426
8498
  const timeoutMs = Math.min(configuredTimeout, LLM_GENERATION_MAX_ALLOWED_TIMEOUT_MS);
8427
8499
  if (modelSettings.maxDuration && modelSettings.maxDuration * 1e3 > LLM_GENERATION_MAX_ALLOWED_TIMEOUT_MS) {
8428
- logger15.warn(
8500
+ logger14.warn(
8429
8501
  {
8430
8502
  requestedTimeout: modelSettings.maxDuration * 1e3,
8431
8503
  appliedTimeout: timeoutMs,
@@ -8467,7 +8539,7 @@ ${output}`;
8467
8539
  }
8468
8540
  );
8469
8541
  } catch (error) {
8470
- logger15.debug({ error }, "Failed to track agent reasoning");
8542
+ logger14.debug({ error }, "Failed to track agent reasoning");
8471
8543
  }
8472
8544
  }
8473
8545
  if (last && last["content"] && last["content"].length > 0) {
@@ -8602,7 +8674,7 @@ ${output}`;
8602
8674
  }
8603
8675
  );
8604
8676
  } catch (error) {
8605
- logger15.debug({ error }, "Failed to track agent reasoning");
8677
+ logger14.debug({ error }, "Failed to track agent reasoning");
8606
8678
  }
8607
8679
  }
8608
8680
  if (steps.length >= 2) {
@@ -8749,7 +8821,7 @@ ${output}${structureHintsFormatted}`;
8749
8821
  LLM_GENERATION_MAX_ALLOWED_TIMEOUT_MS
8750
8822
  );
8751
8823
  if (structuredModelSettings.maxDuration && structuredModelSettings.maxDuration * 1e3 > LLM_GENERATION_MAX_ALLOWED_TIMEOUT_MS) {
8752
- logger15.warn(
8824
+ logger14.warn(
8753
8825
  {
8754
8826
  requestedTimeout: structuredModelSettings.maxDuration * 1e3,
8755
8827
  appliedTimeout: phase2TimeoutMs,
@@ -8925,7 +8997,7 @@ ${output}${structureHintsFormatted}`;
8925
8997
  };
8926
8998
 
8927
8999
  // src/agents/generateTaskHandler.ts
8928
- var logger16 = getLogger("generateTaskHandler");
9000
+ var logger15 = getLogger("generateTaskHandler");
8929
9001
  var createTaskHandler = (config, credentialStoreRegistry) => {
8930
9002
  return async (task) => {
8931
9003
  try {
@@ -9043,7 +9115,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
9043
9115
  return { ...relation, description: enhancedDescription };
9044
9116
  }
9045
9117
  } catch (error) {
9046
- logger16.warn({ subAgentId: relation.id, error }, "Failed to enhance agent description");
9118
+ logger15.warn({ subAgentId: relation.id, error }, "Failed to enhance agent description");
9047
9119
  }
9048
9120
  return relation;
9049
9121
  })
@@ -9101,7 +9173,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
9101
9173
  };
9102
9174
  }
9103
9175
  } catch (error) {
9104
- logger16.warn(
9176
+ logger15.warn(
9105
9177
  { targetAgentId: relation.targetAgentId, error },
9106
9178
  "Failed to enhance team agent description"
9107
9179
  );
@@ -9109,7 +9181,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
9109
9181
  return relation;
9110
9182
  })
9111
9183
  );
9112
- const prompt = "prompt" in config.agentSchema ? config.agentSchema.prompt : "";
9184
+ const prompt = "prompt" in config.agentSchema ? config.agentSchema.prompt || void 0 : "";
9113
9185
  const models = "models" in config.agentSchema ? config.agentSchema.models : void 0;
9114
9186
  const stopWhen = "stopWhen" in config.agentSchema ? config.agentSchema.stopWhen : void 0;
9115
9187
  const toolsForAgentResult = await Promise.all(
@@ -9118,7 +9190,8 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
9118
9190
  item.tool,
9119
9191
  dbClient_default,
9120
9192
  credentialStoreRegistry,
9121
- item.id
9193
+ item.id,
9194
+ config.userId
9122
9195
  );
9123
9196
  if (item.selectedTools && item.selectedTools.length > 0) {
9124
9197
  const selectedToolsSet = new Set(item.selectedTools);
@@ -9135,6 +9208,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
9135
9208
  agentId: config.agentId,
9136
9209
  baseUrl: config.baseUrl,
9137
9210
  apiKey: config.apiKey,
9211
+ userId: config.userId,
9138
9212
  name: config.name,
9139
9213
  description: config.description || "",
9140
9214
  prompt,
@@ -9148,7 +9222,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
9148
9222
  baseUrl: config.baseUrl,
9149
9223
  apiKey: config.apiKey,
9150
9224
  name: relation.name,
9151
- description: relation.description,
9225
+ description: relation.description || void 0,
9152
9226
  prompt: "",
9153
9227
  delegateRelations: [],
9154
9228
  subAgentRelations: [],
@@ -9188,7 +9262,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
9188
9262
  targetTransferRelations = transferRel;
9189
9263
  targetDelegateRelations = delegateRel;
9190
9264
  } catch (err) {
9191
- logger16.info(
9265
+ logger15.info(
9192
9266
  {
9193
9267
  agentId: relation.id,
9194
9268
  error: err?.message || "Unknown error"
@@ -9202,7 +9276,8 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
9202
9276
  item.tool,
9203
9277
  dbClient_default,
9204
9278
  credentialStoreRegistry,
9205
- item.id
9279
+ item.id,
9280
+ config.userId
9206
9281
  );
9207
9282
  if (item.selectedTools && item.selectedTools.length > 0) {
9208
9283
  const selectedToolsSet = new Set(item.selectedTools);
@@ -9251,7 +9326,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
9251
9326
  projectId: config.projectId,
9252
9327
  agentId: config.agentId,
9253
9328
  name: relation.name,
9254
- description: relation.description,
9329
+ description: relation.description || void 0,
9255
9330
  prompt: "",
9256
9331
  delegateRelations: targetDelegateRelationsConfig,
9257
9332
  subAgentRelations: [],
@@ -9266,13 +9341,14 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
9266
9341
  type: "internal",
9267
9342
  config: {
9268
9343
  id: relation.id,
9344
+ relationId: relation.relationId,
9269
9345
  tenantId: config.tenantId,
9270
9346
  projectId: config.projectId,
9271
9347
  agentId: config.agentId,
9272
9348
  baseUrl: config.baseUrl,
9273
9349
  apiKey: config.apiKey,
9274
9350
  name: relation.name,
9275
- description: relation.description,
9351
+ description: relation.description || void 0,
9276
9352
  prompt: "",
9277
9353
  delegateRelations: [],
9278
9354
  // Simplified - no nested relations
@@ -9327,7 +9403,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
9327
9403
  const taskIdMatch = task.id.match(/^task_([^-]+-[^-]+-\d+)-/);
9328
9404
  if (taskIdMatch) {
9329
9405
  contextId = taskIdMatch[1];
9330
- logger16.info(
9406
+ logger15.info(
9331
9407
  {
9332
9408
  taskId: task.id,
9333
9409
  extractedContextId: contextId,
@@ -9345,7 +9421,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
9345
9421
  agent.setDelegationStatus(isDelegation);
9346
9422
  agent.setDelegationId(delegationId);
9347
9423
  if (isDelegation) {
9348
- logger16.info(
9424
+ logger15.info(
9349
9425
  { subAgentId: config.subAgentId, taskId: task.id, delegationId },
9350
9426
  "Delegated agent - streaming disabled"
9351
9427
  );
@@ -9382,7 +9458,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
9382
9458
  const toolResult = allToolResults.find(
9383
9459
  (result) => result.toolCallId === toolCall.toolCallId
9384
9460
  );
9385
- logger16.info(
9461
+ logger15.info(
9386
9462
  {
9387
9463
  toolCallName: toolCall.toolName,
9388
9464
  toolCallId: toolCall.toolCallId,
@@ -9399,7 +9475,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
9399
9475
  const transferReason = responseText || allThoughts[allThoughts.length - 1]?.text || "Agent requested transfer. No reason provided.";
9400
9476
  if (toolResult?.output && isValidTransferResult(toolResult.output)) {
9401
9477
  const transferResult = toolResult.output;
9402
- logger16.info(
9478
+ logger15.info(
9403
9479
  {
9404
9480
  validationPassed: true,
9405
9481
  transferResult,
@@ -9416,7 +9492,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
9416
9492
  reason: transferReason,
9417
9493
  original_message: userMessage
9418
9494
  };
9419
- logger16.info(
9495
+ logger15.info(
9420
9496
  {
9421
9497
  artifactData,
9422
9498
  artifactDataKeys: Object.keys(artifactData)
@@ -9441,7 +9517,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
9441
9517
  ]
9442
9518
  };
9443
9519
  }
9444
- logger16.warn(
9520
+ logger15.warn(
9445
9521
  {
9446
9522
  hasToolResult: !!toolResult,
9447
9523
  hasOutput: !!toolResult?.output,
@@ -9470,7 +9546,9 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
9470
9546
  } catch (error) {
9471
9547
  console.error("Task handler error:", error);
9472
9548
  const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
9473
- const isConnectionRefused = errorMessage.includes("Connection refused. Please check if the MCP server is running.");
9549
+ const isConnectionRefused = errorMessage.includes(
9550
+ "Connection refused. Please check if the MCP server is running."
9551
+ );
9474
9552
  return {
9475
9553
  status: {
9476
9554
  state: TaskState.Failed,
@@ -9522,15 +9600,16 @@ var createTaskHandlerConfig = async (params) => {
9522
9600
  baseUrl: params.baseUrl,
9523
9601
  apiKey: params.apiKey,
9524
9602
  name: subAgent.name,
9525
- description: subAgent.description,
9603
+ description: subAgent.description || void 0,
9526
9604
  conversationHistoryConfig: effectiveConversationHistoryConfig,
9527
9605
  contextConfigId: agent?.contextConfigId || void 0,
9528
- sandboxConfig: params.sandboxConfig
9606
+ sandboxConfig: params.sandboxConfig,
9607
+ userId: params.userId
9529
9608
  };
9530
9609
  };
9531
9610
 
9532
9611
  // src/data/agents.ts
9533
- var logger17 = getLogger("agents");
9612
+ var logger16 = getLogger("agents");
9534
9613
  function createAgentCard({
9535
9614
  dbAgent,
9536
9615
  baseUrl
@@ -9600,7 +9679,8 @@ async function hydrateAgent({
9600
9679
  baseUrl,
9601
9680
  apiKey,
9602
9681
  credentialStoreRegistry,
9603
- sandboxConfig
9682
+ sandboxConfig,
9683
+ userId
9604
9684
  }) {
9605
9685
  try {
9606
9686
  const taskHandlerConfig = await createTaskHandlerConfig({
@@ -9610,7 +9690,8 @@ async function hydrateAgent({
9610
9690
  subAgentId: dbAgent.id,
9611
9691
  baseUrl,
9612
9692
  apiKey,
9613
- sandboxConfig
9693
+ sandboxConfig,
9694
+ userId
9614
9695
  });
9615
9696
  const taskHandler = createTaskHandler(taskHandlerConfig, credentialStoreRegistry);
9616
9697
  const agentCard = createAgentCard({
@@ -9633,12 +9714,13 @@ async function hydrateAgent({
9633
9714
  async function getRegisteredAgent(params) {
9634
9715
  const { executionContext, credentialStoreRegistry, sandboxConfig } = params;
9635
9716
  const { tenantId, projectId, agentId, subAgentId, baseUrl, apiKey } = executionContext;
9717
+ const userId = getUserIdFromContext(executionContext);
9636
9718
  let dbAgent;
9637
9719
  if (!subAgentId) {
9638
9720
  const agent = await getAgentWithDefaultSubAgent(dbClient_default)({
9639
9721
  scopes: { tenantId, projectId, agentId }
9640
9722
  });
9641
- logger17.info({ agent }, "agent with default sub agent");
9723
+ logger16.info({ agent }, "agent with default sub agent");
9642
9724
  if (!agent || !agent.defaultSubAgent) {
9643
9725
  return null;
9644
9726
  }
@@ -9663,13 +9745,14 @@ async function getRegisteredAgent(params) {
9663
9745
  baseUrl: agentFrameworkBaseUrl,
9664
9746
  credentialStoreRegistry,
9665
9747
  apiKey,
9666
- sandboxConfig
9748
+ sandboxConfig,
9749
+ userId
9667
9750
  });
9668
9751
  }
9669
9752
 
9670
9753
  // src/routes/agents.ts
9671
9754
  var app = new OpenAPIHono();
9672
- var logger18 = getLogger("agents");
9755
+ var logger17 = getLogger("agents");
9673
9756
  app.openapi(
9674
9757
  createRoute({
9675
9758
  method: "get",
@@ -9707,7 +9790,7 @@ app.openapi(
9707
9790
  tracestate: c.req.header("tracestate"),
9708
9791
  baggage: c.req.header("baggage")
9709
9792
  };
9710
- logger18.info(
9793
+ logger17.info(
9711
9794
  {
9712
9795
  otelHeaders,
9713
9796
  path: c.req.path,
@@ -9717,8 +9800,8 @@ app.openapi(
9717
9800
  );
9718
9801
  const executionContext = getRequestExecutionContext(c);
9719
9802
  const { tenantId, projectId, agentId, subAgentId } = executionContext;
9720
- logger18.info({ executionContext }, "executionContext");
9721
- logger18.info(
9803
+ logger17.info({ executionContext }, "executionContext");
9804
+ logger17.info(
9722
9805
  {
9723
9806
  message: "getRegisteredAgent (agent-level)",
9724
9807
  tenantId,
@@ -9735,7 +9818,7 @@ app.openapi(
9735
9818
  credentialStoreRegistry: credentialStores,
9736
9819
  sandboxConfig
9737
9820
  });
9738
- logger18.info({ agent }, "agent registered: well-known agent.json");
9821
+ logger17.info({ agent }, "agent registered: well-known agent.json");
9739
9822
  if (!agent) {
9740
9823
  throw createApiError({
9741
9824
  code: "not_found",
@@ -9751,7 +9834,7 @@ app.post("/a2a", async (c) => {
9751
9834
  tracestate: c.req.header("tracestate"),
9752
9835
  baggage: c.req.header("baggage")
9753
9836
  };
9754
- logger18.info(
9837
+ logger17.info(
9755
9838
  {
9756
9839
  otelHeaders,
9757
9840
  path: c.req.path,
@@ -9762,7 +9845,7 @@ app.post("/a2a", async (c) => {
9762
9845
  const executionContext = getRequestExecutionContext(c);
9763
9846
  const { tenantId, projectId, agentId, subAgentId } = executionContext;
9764
9847
  if (subAgentId) {
9765
- logger18.info(
9848
+ logger17.info(
9766
9849
  {
9767
9850
  message: "a2a (agent-level)",
9768
9851
  tenantId,
@@ -9791,7 +9874,7 @@ app.post("/a2a", async (c) => {
9791
9874
  }
9792
9875
  return a2aHandler(c, agent2);
9793
9876
  }
9794
- logger18.info(
9877
+ logger17.info(
9795
9878
  {
9796
9879
  message: "a2a (agent-level)",
9797
9880
  tenantId,
@@ -9869,14 +9952,14 @@ function extractTransferData(task) {
9869
9952
  }
9870
9953
 
9871
9954
  // src/a2a/transfer.ts
9872
- var logger19 = getLogger("Transfer");
9955
+ var logger18 = getLogger("Transfer");
9873
9956
  async function executeTransfer({
9874
9957
  tenantId,
9875
9958
  threadId,
9876
9959
  projectId,
9877
9960
  targetSubAgentId
9878
9961
  }) {
9879
- logger19.info(
9962
+ logger18.info(
9880
9963
  {
9881
9964
  targetAgent: targetSubAgentId,
9882
9965
  threadId,
@@ -9891,12 +9974,12 @@ async function executeTransfer({
9891
9974
  threadId,
9892
9975
  subAgentId: targetSubAgentId
9893
9976
  });
9894
- logger19.info(
9977
+ logger18.info(
9895
9978
  { targetAgent: targetSubAgentId, threadId },
9896
9979
  "Successfully updated active_sub_agent_id in database"
9897
9980
  );
9898
9981
  } catch (error) {
9899
- logger19.error(
9982
+ logger18.error(
9900
9983
  { error, targetAgent: targetSubAgentId, threadId },
9901
9984
  "Failed to update active_sub_agent_id"
9902
9985
  );
@@ -10460,7 +10543,7 @@ function createBufferingStreamHelper() {
10460
10543
  var createMCPStreamHelper = createBufferingStreamHelper;
10461
10544
 
10462
10545
  // src/handlers/executionHandler.ts
10463
- var logger20 = getLogger("ExecutionHandler");
10546
+ var logger19 = getLogger("ExecutionHandler");
10464
10547
  var ExecutionHandler = class {
10465
10548
  MAX_ERRORS = AGENT_EXECUTION_MAX_CONSECUTIVE_ERRORS;
10466
10549
  /**
@@ -10493,7 +10576,7 @@ var ExecutionHandler = class {
10493
10576
  if (emitOperations) {
10494
10577
  agentSessionManager.enableEmitOperations(requestId2);
10495
10578
  }
10496
- logger20.info(
10579
+ logger19.info(
10497
10580
  { sessionId: requestId2, agentId, conversationId, emitOperations },
10498
10581
  "Created AgentSession for message execution"
10499
10582
  );
@@ -10526,7 +10609,7 @@ var ExecutionHandler = class {
10526
10609
  );
10527
10610
  }
10528
10611
  } catch (modelError) {
10529
- logger20.warn(
10612
+ logger19.warn(
10530
10613
  {
10531
10614
  error: modelError instanceof Error ? modelError.message : "Unknown error",
10532
10615
  agentId
@@ -10541,7 +10624,7 @@ var ExecutionHandler = class {
10541
10624
  }
10542
10625
  }
10543
10626
  } catch (error) {
10544
- logger20.error(
10627
+ logger19.error(
10545
10628
  {
10546
10629
  error: error instanceof Error ? error.message : "Unknown error",
10547
10630
  stack: error instanceof Error ? error.stack : void 0
@@ -10557,7 +10640,7 @@ var ExecutionHandler = class {
10557
10640
  try {
10558
10641
  await sseHelper.writeOperation(agentInitializingOp(requestId2, agentId));
10559
10642
  const taskId = `task_${conversationId}-${requestId2}`;
10560
- logger20.info(
10643
+ logger19.info(
10561
10644
  { taskId, currentAgentId, conversationId, requestId: requestId2 },
10562
10645
  "Attempting to create or reuse existing task"
10563
10646
  );
@@ -10581,7 +10664,7 @@ var ExecutionHandler = class {
10581
10664
  sub_agent_id: currentAgentId
10582
10665
  }
10583
10666
  });
10584
- logger20.info(
10667
+ logger19.info(
10585
10668
  {
10586
10669
  taskId,
10587
10670
  createdTaskMetadata: Array.isArray(task) ? task[0]?.metadata : task?.metadata
@@ -10590,27 +10673,27 @@ var ExecutionHandler = class {
10590
10673
  );
10591
10674
  } catch (error) {
10592
10675
  if (error?.cause?.code === "23505") {
10593
- logger20.info(
10676
+ logger19.info(
10594
10677
  { taskId, error: error.message },
10595
10678
  "Task already exists, fetching existing task"
10596
10679
  );
10597
10680
  const existingTask = await getTask(dbClient_default)({ id: taskId });
10598
10681
  if (existingTask) {
10599
10682
  task = existingTask;
10600
- logger20.info(
10683
+ logger19.info(
10601
10684
  { taskId, existingTask },
10602
10685
  "Successfully reused existing task from race condition"
10603
10686
  );
10604
10687
  } else {
10605
- logger20.error({ taskId, error }, "Task constraint failed but task not found");
10688
+ logger19.error({ taskId, error }, "Task constraint failed but task not found");
10606
10689
  throw error;
10607
10690
  }
10608
10691
  } else {
10609
- logger20.error({ taskId, error }, "Failed to create task due to non-constraint error");
10692
+ logger19.error({ taskId, error }, "Failed to create task due to non-constraint error");
10610
10693
  throw error;
10611
10694
  }
10612
10695
  }
10613
- logger20.debug(
10696
+ logger19.debug(
10614
10697
  {
10615
10698
  timestamp: /* @__PURE__ */ new Date(),
10616
10699
  executionType: "create_initial_task",
@@ -10629,7 +10712,7 @@ var ExecutionHandler = class {
10629
10712
  const maxTransfers = agentConfig?.stopWhen?.transferCountIs ?? AGENT_EXECUTION_TRANSFER_COUNT_DEFAULT;
10630
10713
  while (iterations < maxTransfers) {
10631
10714
  iterations++;
10632
- logger20.info(
10715
+ logger19.info(
10633
10716
  { iterations, currentAgentId, agentId, conversationId, fromSubAgentId },
10634
10717
  `Execution loop iteration ${iterations} with agent ${currentAgentId}, transfer from: ${fromSubAgentId || "none"}`
10635
10718
  );
@@ -10637,10 +10720,10 @@ var ExecutionHandler = class {
10637
10720
  scopes: { tenantId, projectId },
10638
10721
  conversationId
10639
10722
  });
10640
- logger20.info({ activeAgent }, "activeAgent");
10723
+ logger19.info({ activeAgent }, "activeAgent");
10641
10724
  if (activeAgent && activeAgent.activeSubAgentId !== currentAgentId) {
10642
10725
  currentAgentId = activeAgent.activeSubAgentId;
10643
- logger20.info({ currentAgentId }, `Updated current agent to: ${currentAgentId}`);
10726
+ logger19.info({ currentAgentId }, `Updated current agent to: ${currentAgentId}`);
10644
10727
  }
10645
10728
  const agentBaseUrl = `${baseUrl}/agents`;
10646
10729
  const a2aClient = new A2AClient(agentBaseUrl, {
@@ -10681,13 +10764,13 @@ var ExecutionHandler = class {
10681
10764
  });
10682
10765
  if (!messageResponse?.result) {
10683
10766
  errorCount++;
10684
- logger20.error(
10767
+ logger19.error(
10685
10768
  { currentAgentId, iterations, errorCount },
10686
10769
  `No response from agent ${currentAgentId} on iteration ${iterations} (error ${errorCount}/${this.MAX_ERRORS})`
10687
10770
  );
10688
10771
  if (errorCount >= this.MAX_ERRORS) {
10689
10772
  const errorMessage2 = `Maximum error limit (${this.MAX_ERRORS}) reached`;
10690
- logger20.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
10773
+ logger19.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
10691
10774
  await sseHelper.writeOperation(errorOp(errorMessage2, currentAgentId || "system"));
10692
10775
  if (task) {
10693
10776
  await updateTask(dbClient_default)({
@@ -10702,7 +10785,7 @@ var ExecutionHandler = class {
10702
10785
  }
10703
10786
  });
10704
10787
  }
10705
- agentSessionManager.endSession(requestId2);
10788
+ await agentSessionManager.endSession(requestId2);
10706
10789
  unregisterStreamHelper(requestId2);
10707
10790
  return { success: false, error: errorMessage2, iterations };
10708
10791
  }
@@ -10711,7 +10794,7 @@ var ExecutionHandler = class {
10711
10794
  if (isTransferTask(messageResponse.result)) {
10712
10795
  const transferData = extractTransferData(messageResponse.result);
10713
10796
  if (!transferData) {
10714
- logger20.error(
10797
+ logger19.error(
10715
10798
  { result: messageResponse.result },
10716
10799
  "Transfer detected but no transfer data found"
10717
10800
  );
@@ -10720,7 +10803,7 @@ var ExecutionHandler = class {
10720
10803
  const { targetSubAgentId, fromSubAgentId: transferFromAgent } = transferData;
10721
10804
  const firstArtifact = messageResponse.result.artifacts[0];
10722
10805
  const transferReason = firstArtifact?.parts[1]?.kind === "text" ? firstArtifact.parts[1].text : "Transfer initiated";
10723
- logger20.info({ targetSubAgentId, transferReason, transferFromAgent }, "Transfer response");
10806
+ logger19.info({ targetSubAgentId, transferReason, transferFromAgent }, "Transfer response");
10724
10807
  await createMessage(dbClient_default)({
10725
10808
  id: generateId(),
10726
10809
  tenantId,
@@ -10751,7 +10834,7 @@ var ExecutionHandler = class {
10751
10834
  if (success) {
10752
10835
  fromSubAgentId = currentAgentId;
10753
10836
  currentAgentId = newAgentId;
10754
- logger20.info(
10837
+ logger19.info(
10755
10838
  {
10756
10839
  transferFrom: fromSubAgentId,
10757
10840
  transferTo: currentAgentId,
@@ -10765,7 +10848,7 @@ var ExecutionHandler = class {
10765
10848
  let responseParts = [];
10766
10849
  if (messageResponse.result.streamedContent?.parts) {
10767
10850
  responseParts = messageResponse.result.streamedContent.parts;
10768
- logger20.info(
10851
+ logger19.info(
10769
10852
  { partsCount: responseParts.length },
10770
10853
  "Using streamed content for conversation history"
10771
10854
  );
@@ -10773,7 +10856,7 @@ var ExecutionHandler = class {
10773
10856
  responseParts = messageResponse.result.artifacts?.flatMap(
10774
10857
  (artifact) => artifact.parts || []
10775
10858
  ) || [];
10776
- logger20.info(
10859
+ logger19.info(
10777
10860
  { partsCount: responseParts.length },
10778
10861
  "Using artifacts for conversation history (fallback)"
10779
10862
  );
@@ -10782,7 +10865,7 @@ var ExecutionHandler = class {
10782
10865
  const agentSessionData = agentSessionManager.getSession(requestId2);
10783
10866
  if (agentSessionData) {
10784
10867
  const sessionSummary = agentSessionData.getSummary();
10785
- logger20.info(sessionSummary, "AgentSession data after completion");
10868
+ logger19.info(sessionSummary, "AgentSession data after completion");
10786
10869
  }
10787
10870
  let textContent = "";
10788
10871
  for (const part of responseParts) {
@@ -10836,22 +10919,22 @@ var ExecutionHandler = class {
10836
10919
  }
10837
10920
  });
10838
10921
  const updateTaskEnd = Date.now();
10839
- logger20.info(
10922
+ logger19.info(
10840
10923
  { duration: updateTaskEnd - updateTaskStart },
10841
10924
  "Completed updateTask operation"
10842
10925
  );
10843
10926
  await sseHelper.writeOperation(completionOp(currentAgentId, iterations));
10844
10927
  await sseHelper.complete();
10845
- logger20.info({}, "Ending AgentSession and cleaning up");
10846
- agentSessionManager.endSession(requestId2);
10847
- logger20.info({}, "Cleaning up streamHelper");
10928
+ logger19.info({}, "Ending AgentSession and cleaning up");
10929
+ await agentSessionManager.endSession(requestId2);
10930
+ logger19.info({}, "Cleaning up streamHelper");
10848
10931
  unregisterStreamHelper(requestId2);
10849
10932
  let response;
10850
10933
  if (sseHelper instanceof BufferingStreamHelper) {
10851
10934
  const captured = sseHelper.getCapturedResponse();
10852
10935
  response = captured.text || "No response content";
10853
10936
  }
10854
- logger20.info({}, "ExecutionHandler returning success");
10937
+ logger19.info({}, "ExecutionHandler returning success");
10855
10938
  return { success: true, iterations, response };
10856
10939
  } catch (error) {
10857
10940
  setSpanWithError(span, error instanceof Error ? error : new Error(String(error)));
@@ -10862,13 +10945,13 @@ var ExecutionHandler = class {
10862
10945
  });
10863
10946
  }
10864
10947
  errorCount++;
10865
- logger20.warn(
10948
+ logger19.warn(
10866
10949
  { iterations, errorCount },
10867
10950
  `No valid response or transfer on iteration ${iterations} (error ${errorCount}/${this.MAX_ERRORS})`
10868
10951
  );
10869
10952
  if (errorCount >= this.MAX_ERRORS) {
10870
10953
  const errorMessage2 = `Maximum error limit (${this.MAX_ERRORS}) reached`;
10871
- logger20.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
10954
+ logger19.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
10872
10955
  await sseHelper.writeOperation(errorOp(errorMessage2, currentAgentId || "system"));
10873
10956
  if (task) {
10874
10957
  await updateTask(dbClient_default)({
@@ -10883,13 +10966,13 @@ var ExecutionHandler = class {
10883
10966
  }
10884
10967
  });
10885
10968
  }
10886
- agentSessionManager.endSession(requestId2);
10969
+ await agentSessionManager.endSession(requestId2);
10887
10970
  unregisterStreamHelper(requestId2);
10888
10971
  return { success: false, error: errorMessage2, iterations };
10889
10972
  }
10890
10973
  }
10891
10974
  const errorMessage = `Maximum transfer limit (${maxTransfers}) reached without completion`;
10892
- logger20.error({ maxTransfers, iterations }, errorMessage);
10975
+ logger19.error({ maxTransfers, iterations }, errorMessage);
10893
10976
  await sseHelper.writeOperation(errorOp(errorMessage, currentAgentId || "system"));
10894
10977
  if (task) {
10895
10978
  await updateTask(dbClient_default)({
@@ -10904,11 +10987,11 @@ var ExecutionHandler = class {
10904
10987
  }
10905
10988
  });
10906
10989
  }
10907
- agentSessionManager.endSession(requestId2);
10990
+ await agentSessionManager.endSession(requestId2);
10908
10991
  unregisterStreamHelper(requestId2);
10909
10992
  return { success: false, error: errorMessage, iterations };
10910
10993
  } catch (error) {
10911
- logger20.error({ error }, "Error in execution handler");
10994
+ logger19.error({ error }, "Error in execution handler");
10912
10995
  const errorMessage = error instanceof Error ? error.message : "Unknown execution error";
10913
10996
  await sseHelper.writeOperation(
10914
10997
  errorOp(`Execution error: ${errorMessage}`, currentAgentId || "system")
@@ -10926,7 +11009,7 @@ var ExecutionHandler = class {
10926
11009
  }
10927
11010
  });
10928
11011
  }
10929
- agentSessionManager.endSession(requestId2);
11012
+ await agentSessionManager.endSession(requestId2);
10930
11013
  unregisterStreamHelper(requestId2);
10931
11014
  return { success: false, error: errorMessage, iterations };
10932
11015
  }
@@ -10935,7 +11018,7 @@ var ExecutionHandler = class {
10935
11018
 
10936
11019
  // src/routes/chat.ts
10937
11020
  var app2 = new OpenAPIHono();
10938
- var logger21 = getLogger("completionsHandler");
11021
+ var logger20 = getLogger("completionsHandler");
10939
11022
  var chatCompletionsRoute = createRoute({
10940
11023
  method: "post",
10941
11024
  path: "/completions",
@@ -11053,7 +11136,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
11053
11136
  tracestate: c.req.header("tracestate"),
11054
11137
  baggage: c.req.header("baggage")
11055
11138
  };
11056
- logger21.info(
11139
+ logger20.info(
11057
11140
  {
11058
11141
  otelHeaders,
11059
11142
  path: c.req.path,
@@ -11162,7 +11245,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
11162
11245
  dbClient: dbClient_default,
11163
11246
  credentialStores
11164
11247
  });
11165
- logger21.info(
11248
+ logger20.info(
11166
11249
  {
11167
11250
  tenantId,
11168
11251
  projectId,
@@ -11210,7 +11293,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
11210
11293
  try {
11211
11294
  const sseHelper = createSSEStreamHelper(stream2, requestId2, timestamp);
11212
11295
  await sseHelper.writeRole();
11213
- logger21.info({ subAgentId }, "Starting execution");
11296
+ logger20.info({ subAgentId }, "Starting execution");
11214
11297
  const emitOperationsHeader = c.req.header("x-emit-operations");
11215
11298
  const emitOperations = emitOperationsHeader === "true";
11216
11299
  const executionHandler = new ExecutionHandler();
@@ -11223,7 +11306,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
11223
11306
  sseHelper,
11224
11307
  emitOperations
11225
11308
  });
11226
- logger21.info(
11309
+ logger20.info(
11227
11310
  { result },
11228
11311
  `Execution completed: ${result.success ? "success" : "failed"} after ${result.iterations} iterations`
11229
11312
  );
@@ -11237,7 +11320,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
11237
11320
  }
11238
11321
  await sseHelper.complete();
11239
11322
  } catch (error) {
11240
- logger21.error(
11323
+ logger20.error(
11241
11324
  {
11242
11325
  error: error instanceof Error ? error.message : error,
11243
11326
  stack: error instanceof Error ? error.stack : void 0
@@ -11254,13 +11337,13 @@ app2.openapi(chatCompletionsRoute, async (c) => {
11254
11337
  );
11255
11338
  await sseHelper.complete();
11256
11339
  } catch (streamError) {
11257
- logger21.error({ streamError }, "Failed to write error to stream");
11340
+ logger20.error({ streamError }, "Failed to write error to stream");
11258
11341
  }
11259
11342
  }
11260
11343
  });
11261
11344
  });
11262
11345
  } catch (error) {
11263
- logger21.error(
11346
+ logger20.error(
11264
11347
  {
11265
11348
  error: error instanceof Error ? error.message : error,
11266
11349
  stack: error instanceof Error ? error.stack : void 0
@@ -11284,7 +11367,7 @@ var getMessageText = (content) => {
11284
11367
  };
11285
11368
  var chat_default = app2;
11286
11369
  var app3 = new OpenAPIHono();
11287
- var logger22 = getLogger("chatDataStream");
11370
+ var logger21 = getLogger("chatDataStream");
11288
11371
  var chatDataStreamRoute = createRoute({
11289
11372
  method: "post",
11290
11373
  path: "/chat",
@@ -11411,7 +11494,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
11411
11494
  });
11412
11495
  const lastUserMessage = body.messages.filter((m) => m.role === "user").slice(-1)[0];
11413
11496
  const userText = typeof lastUserMessage?.content === "string" ? lastUserMessage.content : lastUserMessage?.parts?.map((p) => p.text).join("") || "";
11414
- logger22.info({ userText, lastUserMessage }, "userText");
11497
+ logger21.info({ userText, lastUserMessage }, "userText");
11415
11498
  const messageSpan = trace.getActiveSpan();
11416
11499
  if (messageSpan) {
11417
11500
  messageSpan.setAttributes({
@@ -11494,7 +11577,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
11494
11577
  await streamHelper.writeOperation(errorOp("Unable to process request", "system"));
11495
11578
  }
11496
11579
  } catch (err) {
11497
- logger22.error({ err }, "Streaming error");
11580
+ logger21.error({ err }, "Streaming error");
11498
11581
  await streamHelper.writeOperation(errorOp("Internal server error", "system"));
11499
11582
  } finally {
11500
11583
  if ("cleanup" in streamHelper && typeof streamHelper.cleanup === "function") {
@@ -11516,7 +11599,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
11516
11599
  );
11517
11600
  });
11518
11601
  } catch (error) {
11519
- logger22.error(
11602
+ logger21.error(
11520
11603
  {
11521
11604
  error,
11522
11605
  errorMessage: error instanceof Error ? error.message : String(error),
@@ -11605,7 +11688,7 @@ app3.openapi(toolApprovalRoute, async (c) => {
11605
11688
  const { tenantId, projectId } = executionContext;
11606
11689
  const requestBody = await c.req.json();
11607
11690
  const { conversationId, toolCallId, approved, reason } = requestBody;
11608
- logger22.info(
11691
+ logger21.info(
11609
11692
  {
11610
11693
  conversationId,
11611
11694
  toolCallId,
@@ -11634,7 +11717,7 @@ app3.openapi(toolApprovalRoute, async (c) => {
11634
11717
  span.setStatus({ code: 1, message: "Tool call not found" });
11635
11718
  return c.json({ error: "Tool call not found or already processed" }, 404);
11636
11719
  }
11637
- logger22.info({ conversationId, toolCallId, approved }, "Tool approval processed successfully");
11720
+ logger21.info({ conversationId, toolCallId, approved }, "Tool approval processed successfully");
11638
11721
  span.setStatus({ code: 1, message: "Success" });
11639
11722
  return c.json({
11640
11723
  success: true,
@@ -11642,7 +11725,7 @@ app3.openapi(toolApprovalRoute, async (c) => {
11642
11725
  });
11643
11726
  } catch (error) {
11644
11727
  const errorMessage = error instanceof Error ? error.message : "Unknown error";
11645
- logger22.error(
11728
+ logger21.error(
11646
11729
  {
11647
11730
  error: errorMessage,
11648
11731
  stack: error instanceof Error ? error.stack : void 0
@@ -11663,7 +11746,7 @@ app3.openapi(toolApprovalRoute, async (c) => {
11663
11746
  });
11664
11747
  });
11665
11748
  var chatDataStream_default = app3;
11666
- var logger23 = getLogger("mcp");
11749
+ var logger22 = getLogger("mcp");
11667
11750
  var MockResponseSingleton = class _MockResponseSingleton {
11668
11751
  static instance;
11669
11752
  mockRes;
@@ -11717,21 +11800,21 @@ var createSpoofInitMessage = (mcpProtocolVersion) => ({
11717
11800
  id: 0
11718
11801
  });
11719
11802
  var spoofTransportInitialization = async (transport, req, sessionId, mcpProtocolVersion) => {
11720
- logger23.info({ sessionId }, "Spoofing initialization message to set transport state");
11803
+ logger22.info({ sessionId }, "Spoofing initialization message to set transport state");
11721
11804
  const spoofInitMessage = createSpoofInitMessage(mcpProtocolVersion);
11722
11805
  const mockRes = MockResponseSingleton.getInstance().getMockResponse();
11723
11806
  try {
11724
11807
  await transport.handleRequest(req, mockRes, spoofInitMessage);
11725
- logger23.info({ sessionId }, "Successfully spoofed initialization");
11808
+ logger22.info({ sessionId }, "Successfully spoofed initialization");
11726
11809
  } catch (spoofError) {
11727
- logger23.warn({ sessionId, error: spoofError }, "Spoof initialization failed, continuing anyway");
11810
+ logger22.warn({ sessionId, error: spoofError }, "Spoof initialization failed, continuing anyway");
11728
11811
  }
11729
11812
  };
11730
11813
  var validateSession = async (req, res, body, tenantId, projectId, agentId) => {
11731
11814
  const sessionId = req.headers["mcp-session-id"];
11732
- logger23.info({ sessionId }, "Received MCP session ID");
11815
+ logger22.info({ sessionId }, "Received MCP session ID");
11733
11816
  if (!sessionId) {
11734
- logger23.info({ body }, "Missing session ID");
11817
+ logger22.info({ body }, "Missing session ID");
11735
11818
  res.writeHead(400).end(
11736
11819
  JSON.stringify({
11737
11820
  jsonrpc: "2.0",
@@ -11758,7 +11841,7 @@ var validateSession = async (req, res, body, tenantId, projectId, agentId) => {
11758
11841
  scopes: { tenantId, projectId },
11759
11842
  conversationId: sessionId
11760
11843
  });
11761
- logger23.info(
11844
+ logger22.info(
11762
11845
  {
11763
11846
  sessionId,
11764
11847
  conversationFound: !!conversation,
@@ -11769,7 +11852,7 @@ var validateSession = async (req, res, body, tenantId, projectId, agentId) => {
11769
11852
  "Conversation lookup result"
11770
11853
  );
11771
11854
  if (!conversation || conversation.metadata?.sessionData?.sessionType !== "mcp" || conversation.metadata?.sessionData?.agentId !== agentId) {
11772
- logger23.info(
11855
+ logger22.info(
11773
11856
  { sessionId, conversationId: conversation?.id },
11774
11857
  "MCP session not found or invalid"
11775
11858
  );
@@ -11830,7 +11913,7 @@ var executeAgentQuery = async (executionContext, conversationId, query, defaultS
11830
11913
  requestId: requestId2,
11831
11914
  sseHelper: mcpStreamHelper
11832
11915
  });
11833
- logger23.info(
11916
+ logger22.info(
11834
11917
  { result },
11835
11918
  `Execution completed: ${result.success ? "success" : "failed"} after ${result.iterations} iterations`
11836
11919
  );
@@ -11914,7 +11997,7 @@ var getServer = async (headers2, executionContext, conversationId, credentialSto
11914
11997
  dbClient: dbClient_default,
11915
11998
  credentialStores
11916
11999
  });
11917
- logger23.info(
12000
+ logger22.info(
11918
12001
  {
11919
12002
  tenantId,
11920
12003
  projectId,
@@ -11976,7 +12059,7 @@ var validateRequestParameters = (c) => {
11976
12059
  };
11977
12060
  var handleInitializationRequest = async (body, executionContext, validatedContext, req, res, c, credentialStores) => {
11978
12061
  const { tenantId, projectId, agentId } = executionContext;
11979
- logger23.info({ body }, "Received initialization request");
12062
+ logger22.info({ body }, "Received initialization request");
11980
12063
  const sessionId = getConversationId();
11981
12064
  const activeSpan = trace.getActiveSpan();
11982
12065
  if (activeSpan) {
@@ -12032,7 +12115,7 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
12032
12115
  }
12033
12116
  }
12034
12117
  });
12035
- logger23.info(
12118
+ logger22.info(
12036
12119
  { sessionId, conversationId: conversation.id },
12037
12120
  "Created MCP session as conversation"
12038
12121
  );
@@ -12041,9 +12124,9 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
12041
12124
  });
12042
12125
  const server = await getServer(validatedContext, executionContext, sessionId, credentialStores);
12043
12126
  await server.connect(transport);
12044
- logger23.info({ sessionId }, "Server connected for initialization");
12127
+ logger22.info({ sessionId }, "Server connected for initialization");
12045
12128
  res.setHeader("Mcp-Session-Id", sessionId);
12046
- logger23.info(
12129
+ logger22.info(
12047
12130
  {
12048
12131
  sessionId,
12049
12132
  bodyMethod: body?.method,
@@ -12052,7 +12135,7 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
12052
12135
  "About to handle initialization request"
12053
12136
  );
12054
12137
  await transport.handleRequest(req, res, body);
12055
- logger23.info({ sessionId }, "Successfully handled initialization request");
12138
+ logger22.info({ sessionId }, "Successfully handled initialization request");
12056
12139
  return toFetchResponse(res);
12057
12140
  });
12058
12141
  };
@@ -12079,8 +12162,8 @@ var handleExistingSessionRequest = async (body, executionContext, validatedConte
12079
12162
  sessionId,
12080
12163
  conversation.metadata?.session_data?.mcpProtocolVersion
12081
12164
  );
12082
- logger23.info({ sessionId }, "Server connected and transport initialized");
12083
- logger23.info(
12165
+ logger22.info({ sessionId }, "Server connected and transport initialized");
12166
+ logger22.info(
12084
12167
  {
12085
12168
  sessionId,
12086
12169
  bodyKeys: Object.keys(body || {}),
@@ -12094,9 +12177,9 @@ var handleExistingSessionRequest = async (body, executionContext, validatedConte
12094
12177
  );
12095
12178
  try {
12096
12179
  await transport.handleRequest(req, res, body);
12097
- logger23.info({ sessionId }, "Successfully handled MCP request");
12180
+ logger22.info({ sessionId }, "Successfully handled MCP request");
12098
12181
  } catch (transportError) {
12099
- logger23.error(
12182
+ logger22.error(
12100
12183
  {
12101
12184
  sessionId,
12102
12185
  error: transportError,
@@ -12147,13 +12230,13 @@ app4.openapi(
12147
12230
  }
12148
12231
  const { executionContext } = paramValidation;
12149
12232
  const body = c.get("requestBody") || {};
12150
- logger23.info({ body, bodyKeys: Object.keys(body || {}) }, "Parsed request body");
12233
+ logger22.info({ body, bodyKeys: Object.keys(body || {}) }, "Parsed request body");
12151
12234
  const isInitRequest = body.method === "initialize";
12152
12235
  const { req, res } = toReqRes(c.req.raw);
12153
12236
  const validatedContext = c.get("validatedContext") || {};
12154
12237
  const credentialStores = c.get("credentialStores");
12155
- logger23.info({ validatedContext }, "Validated context");
12156
- logger23.info({ req }, "request");
12238
+ logger22.info({ validatedContext }, "Validated context");
12239
+ logger22.info({ req }, "request");
12157
12240
  if (isInitRequest) {
12158
12241
  return await handleInitializationRequest(
12159
12242
  body,
@@ -12174,7 +12257,7 @@ app4.openapi(
12174
12257
  credentialStores
12175
12258
  );
12176
12259
  } catch (e) {
12177
- logger23.error(
12260
+ logger22.error(
12178
12261
  {
12179
12262
  error: e instanceof Error ? e.message : e,
12180
12263
  stack: e instanceof Error ? e.stack : void 0
@@ -12186,7 +12269,7 @@ app4.openapi(
12186
12269
  }
12187
12270
  );
12188
12271
  app4.get("/", async (c) => {
12189
- logger23.info({}, "Received GET MCP request");
12272
+ logger22.info({}, "Received GET MCP request");
12190
12273
  return c.json(
12191
12274
  {
12192
12275
  jsonrpc: "2.0",
@@ -12200,7 +12283,7 @@ app4.get("/", async (c) => {
12200
12283
  );
12201
12284
  });
12202
12285
  app4.delete("/", async (c) => {
12203
- logger23.info({}, "Received DELETE MCP request");
12286
+ logger22.info({}, "Received DELETE MCP request");
12204
12287
  return c.json(
12205
12288
  {
12206
12289
  jsonrpc: "2.0",
@@ -12213,7 +12296,7 @@ app4.delete("/", async (c) => {
12213
12296
  var mcp_default = app4;
12214
12297
 
12215
12298
  // src/app.ts
12216
- var logger24 = getLogger("agents-run-api");
12299
+ var logger23 = getLogger("agents-run-api");
12217
12300
  function createExecutionHono(serverConfig, credentialStores, sandboxConfig) {
12218
12301
  const app6 = new OpenAPIHono();
12219
12302
  app6.use("*", otel());
@@ -12232,7 +12315,7 @@ function createExecutionHono(serverConfig, credentialStores, sandboxConfig) {
12232
12315
  const body = await c.req.json();
12233
12316
  c.set("requestBody", body);
12234
12317
  } catch (error) {
12235
- logger24.debug({ error }, "Failed to parse JSON body, continuing without parsed body");
12318
+ logger23.debug({ error }, "Failed to parse JSON body, continuing without parsed body");
12236
12319
  }
12237
12320
  }
12238
12321
  return next();
@@ -12283,8 +12366,8 @@ function createExecutionHono(serverConfig, credentialStores, sandboxConfig) {
12283
12366
  if (!isExpectedError) {
12284
12367
  const errorMessage = err instanceof Error ? err.message : String(err);
12285
12368
  const errorStack = err instanceof Error ? err.stack : void 0;
12286
- if (logger24) {
12287
- logger24.error(
12369
+ if (logger23) {
12370
+ logger23.error(
12288
12371
  {
12289
12372
  error: err,
12290
12373
  message: errorMessage,
@@ -12296,8 +12379,8 @@ function createExecutionHono(serverConfig, credentialStores, sandboxConfig) {
12296
12379
  );
12297
12380
  }
12298
12381
  } else {
12299
- if (logger24) {
12300
- logger24.error(
12382
+ if (logger23) {
12383
+ logger23.error(
12301
12384
  {
12302
12385
  error: err,
12303
12386
  path: c.req.path,
@@ -12314,8 +12397,8 @@ function createExecutionHono(serverConfig, credentialStores, sandboxConfig) {
12314
12397
  const response = err.getResponse();
12315
12398
  return response;
12316
12399
  } catch (responseError) {
12317
- if (logger24) {
12318
- logger24.error({ error: responseError }, "Error while handling HTTPException response");
12400
+ if (logger23) {
12401
+ logger23.error({ error: responseError }, "Error while handling HTTPException response");
12319
12402
  }
12320
12403
  }
12321
12404
  }
@@ -12349,7 +12432,7 @@ function createExecutionHono(serverConfig, credentialStores, sandboxConfig) {
12349
12432
  app6.use("*", async (c, next) => {
12350
12433
  const executionContext = c.get("executionContext");
12351
12434
  if (!executionContext) {
12352
- logger24.debug({}, "Empty execution context");
12435
+ logger23.debug({}, "Empty execution context");
12353
12436
  return next();
12354
12437
  }
12355
12438
  const { tenantId, projectId, agentId } = executionContext;
@@ -12358,7 +12441,7 @@ function createExecutionHono(serverConfig, credentialStores, sandboxConfig) {
12358
12441
  if (requestBody) {
12359
12442
  conversationId = requestBody.conversationId;
12360
12443
  if (!conversationId) {
12361
- logger24.debug({ requestBody }, "No conversation ID found in request body");
12444
+ logger23.debug({ requestBody }, "No conversation ID found in request body");
12362
12445
  }
12363
12446
  }
12364
12447
  const entries = Object.fromEntries(
@@ -12373,7 +12456,7 @@ function createExecutionHono(serverConfig, credentialStores, sandboxConfig) {
12373
12456
  })
12374
12457
  );
12375
12458
  if (!Object.keys(entries).length) {
12376
- logger24.debug({}, "Empty entries for baggage");
12459
+ logger23.debug({}, "Empty entries for baggage");
12377
12460
  return next();
12378
12461
  }
12379
12462
  const bag = Object.entries(entries).reduce(
@@ -12427,6 +12510,7 @@ function createExecutionHono(serverConfig, credentialStores, sandboxConfig) {
12427
12510
  }
12428
12511
 
12429
12512
  // src/index.ts
12513
+ defaultSDK.start();
12430
12514
  var defaultConfig = {
12431
12515
  port: 3003,
12432
12516
  serverOptions: {