@inkeep/agents-run-api 0.22.0 → 0.22.2

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,8 +1,8 @@
1
- import { flushBatchProcessor } from './chunk-RZXPMRBA.js';
2
- import { getLogger } from './chunk-A2S7GSHL.js';
1
+ import { flushBatchProcessor } from './chunk-TVLDBLRZ.js';
3
2
  import { getFormattedConversationHistory, createDefaultConversationHistoryConfig, saveA2AMessageResponse } from './chunk-T5AYIGCU.js';
4
3
  import { dbClient_default } from './chunk-IBMWBEXH.js';
5
4
  import { env } from './chunk-LHCIBW34.js';
5
+ import { getLogger } from './chunk-A2S7GSHL.js';
6
6
  import { __publicField } from './chunk-PKBMQBKP.js';
7
7
  import { getTracer, HeadersScopeSchema, getRequestExecutionContext, createApiError, getAgentWithDefaultSubAgent, contextValidationMiddleware, getConversationId, getFullAgent, createOrGetConversation, getActiveAgentForConversation, setActiveAgentForConversation, getSubAgentById, handleContextResolution, createMessage, commonGetErrorResponses, loggerFactory, createDefaultCredentialStores, CredentialStoreRegistry, listTaskIdsByContextId, getTask, getLedgerArtifacts, upsertLedgerArtifact, createTask, updateTask, setSpanWithError, updateConversation, handleApiError, TaskState, setActiveAgentForThread, getConversation, getAgentById, getRelatedAgentsForAgent, getToolsForAgent, getDataComponentsForAgent, getArtifactComponentsForAgent, dbResultToMcpTool, validateAndGetApiKey, getProject, ContextResolver, CredentialStuffer, MCPServerType, getCredentialReference, McpClient, getFunctionToolsForSubAgent, getFunction, getContextConfigById, getFullAgentDefinition, TemplateEngine, agentHasArtifactComponents, MCPTransportType, SPAN_KEYS, getExternalAgent } from '@inkeep/agents-core';
8
8
  import { otel } from '@hono/otel';
@@ -1683,31 +1683,6 @@ var _ArtifactService = class _ArtifactService {
1683
1683
  }
1684
1684
  return value;
1685
1685
  }
1686
- /**
1687
- * Extract properties from data using prop selectors
1688
- */
1689
- extractProps(item, propSelectors) {
1690
- const extracted = {};
1691
- for (const [propName, selector] of Object.entries(propSelectors)) {
1692
- try {
1693
- const sanitizedSelector = this.sanitizeJMESPathSelector(selector);
1694
- const rawValue = sanitizedSelector ? jmespath.search(item, sanitizedSelector) : item[propName];
1695
- if (rawValue !== null && rawValue !== void 0) {
1696
- extracted[propName] = this.cleanEscapedContent(rawValue);
1697
- }
1698
- } catch (error) {
1699
- logger6.warn(
1700
- { propName, selector, error: error instanceof Error ? error.message : "Unknown error" },
1701
- "Failed to extract property"
1702
- );
1703
- const fallbackValue = item[propName];
1704
- if (fallbackValue !== null && fallbackValue !== void 0) {
1705
- extracted[propName] = this.cleanEscapedContent(fallbackValue);
1706
- }
1707
- }
1708
- }
1709
- return extracted;
1710
- }
1711
1686
  /**
1712
1687
  * Extract properties from data using schema-defined fields and custom selectors
1713
1688
  */
@@ -1838,7 +1813,7 @@ var _ArtifactParser = class _ArtifactParser {
1838
1813
  while ((match = _ArtifactParser.ATTR_REGEX.exec(attrString)) !== null) {
1839
1814
  const key = match[1] || match[3] || match[5];
1840
1815
  let value = match[2] || match[4] || match[6];
1841
- if (value && value.startsWith("{")) {
1816
+ if (value?.startsWith("{")) {
1842
1817
  try {
1843
1818
  value = JSON.parse(value);
1844
1819
  } catch {
@@ -2105,9 +2080,7 @@ var _ArtifactParser = class _ArtifactParser {
2105
2080
  return await this.artifactService.getArtifactSummary(artifactId, toolCallId, artifactMap);
2106
2081
  }
2107
2082
  };
2108
- __publicField(_ArtifactParser, "ARTIFACT_REGEX", /<artifact:ref\s+id=(['"])([^'"]*?)\1\s+tool=(['"])([^'"]*?)\3\s*\/>/gs);
2109
2083
  __publicField(_ArtifactParser, "ARTIFACT_CHECK_REGEX", /<artifact:ref\s+(?=.*id=['"][^'"]+['"])(?=.*tool=['"][^'"]+['"])[^>]*\/>/);
2110
- __publicField(_ArtifactParser, "ARTIFACT_CREATE_REGEX", /<artifact:create\s+([^>]+?)(?:\s*\/)?>(?:(.*?)<\/artifact:create>)?/gs);
2111
2084
  __publicField(_ArtifactParser, "ATTR_REGEX", /(\w+)="([^"]*)"|(\w+)='([^']*)'|(\w+)=({[^}]+})/g);
2112
2085
  __publicField(_ArtifactParser, "ARTIFACT_PATTERNS", [
2113
2086
  "<a",
@@ -3578,7 +3551,7 @@ var _IncrementalStreamParser = class _IncrementalStreamParser {
3578
3551
  sharedArtifactService = agentSessionManager.getArtifactService(
3579
3552
  artifactParserOptions.streamRequestId
3580
3553
  );
3581
- } catch (error) {
3554
+ } catch (_error) {
3582
3555
  }
3583
3556
  }
3584
3557
  this.artifactParser = new ArtifactParser(tenantId, {
@@ -3618,7 +3591,9 @@ var _IncrementalStreamParser = class _IncrementalStreamParser {
3618
3591
  */
3619
3592
  async processTextChunk(chunk) {
3620
3593
  if (this.lastChunkWasToolResult && this.buffer === "" && chunk) {
3621
- chunk = "\n\n" + chunk;
3594
+ chunk = `
3595
+
3596
+ ${chunk}`;
3622
3597
  this.lastChunkWasToolResult = false;
3623
3598
  }
3624
3599
  this.buffer += chunk;
@@ -3649,7 +3624,7 @@ var _IncrementalStreamParser = class _IncrementalStreamParser {
3649
3624
  if (this.isComponentComplete(component)) {
3650
3625
  await this.streamComponent(component);
3651
3626
  }
3652
- } catch (e) {
3627
+ } catch (_e) {
3653
3628
  }
3654
3629
  }
3655
3630
  }
@@ -3962,7 +3937,7 @@ var ResponseFormatter = class {
3962
3937
  sharedArtifactService = agentSessionManager.getArtifactService(
3963
3938
  artifactParserOptions.streamRequestId
3964
3939
  );
3965
- } catch (error) {
3940
+ } catch (_error) {
3966
3941
  }
3967
3942
  }
3968
3943
  this.artifactParser = new ArtifactParser(tenantId, {
@@ -4172,7 +4147,7 @@ function jsonSchemaToZod(jsonSchema) {
4172
4147
  return z.unknown();
4173
4148
  }
4174
4149
  }
4175
- var SchemaProcessor = class {
4150
+ var _SchemaProcessor = class _SchemaProcessor {
4176
4151
  /**
4177
4152
  * Transform complex schema types to strings for JMESPath compatibility
4178
4153
  */
@@ -4203,13 +4178,13 @@ var SchemaProcessor = class {
4203
4178
  * Validate if a selector looks like a valid JMESPath expression
4204
4179
  */
4205
4180
  static validateJMESPathSelector(selector) {
4206
- if (this.isLiteralValue(selector)) {
4181
+ if (_SchemaProcessor.isLiteralValue(selector)) {
4207
4182
  return {
4208
4183
  isLiteral: true,
4209
4184
  isValidSelector: false
4210
4185
  };
4211
4186
  }
4212
- if (this.looksLikeJMESPath(selector)) {
4187
+ if (_SchemaProcessor.looksLikeJMESPath(selector)) {
4213
4188
  return {
4214
4189
  isLiteral: false,
4215
4190
  isValidSelector: true
@@ -4245,7 +4220,7 @@ var SchemaProcessor = class {
4245
4220
  * Check if a selector appears to be a literal value rather than a JMESPath expression
4246
4221
  */
4247
4222
  static isLiteralValue(selector) {
4248
- if (this.looksLikeJMESPath(selector)) {
4223
+ if (_SchemaProcessor.looksLikeJMESPath(selector)) {
4249
4224
  return false;
4250
4225
  }
4251
4226
  if (/^https?:\/\//.test(selector)) {
@@ -4267,18 +4242,21 @@ var SchemaProcessor = class {
4267
4242
  */
4268
4243
  static safeJMESPathSearch(data, selector, fallback = null) {
4269
4244
  try {
4270
- const validation = this.validateJMESPathSelector(selector);
4245
+ const validation = _SchemaProcessor.validateJMESPathSelector(selector);
4271
4246
  if (validation.isLiteral) {
4272
- this.logger.debug({ selector }, "Selector appears to be literal value, returning as-is");
4247
+ _SchemaProcessor.logger.debug(
4248
+ { selector },
4249
+ "Selector appears to be literal value, returning as-is"
4250
+ );
4273
4251
  return selector;
4274
4252
  }
4275
4253
  if (!validation.isValidSelector) {
4276
- this.logger.warn({ selector }, "Selector does not appear to be valid JMESPath");
4254
+ _SchemaProcessor.logger.warn({ selector }, "Selector does not appear to be valid JMESPath");
4277
4255
  return fallback;
4278
4256
  }
4279
4257
  return jmespath.search(data, selector) || fallback;
4280
4258
  } catch (error) {
4281
- this.logger.warn(
4259
+ _SchemaProcessor.logger.warn(
4282
4260
  { selector, error: error instanceof Error ? error.message : String(error) },
4283
4261
  "JMESPath search failed"
4284
4262
  );
@@ -4300,7 +4278,7 @@ var SchemaProcessor = class {
4300
4278
  if (!schema.properties || typeof schema.properties !== "object") {
4301
4279
  errors.push("Schema must have properties object");
4302
4280
  }
4303
- const transformedSchema = this.transformSchemaForJMESPath(schema);
4281
+ const transformedSchema = _SchemaProcessor.transformSchemaForJMESPath(schema);
4304
4282
  return {
4305
4283
  isValid: errors.length === 0,
4306
4284
  errors,
@@ -4310,8 +4288,8 @@ var SchemaProcessor = class {
4310
4288
  /**
4311
4289
  * Extract property value with proper type conversion and validation
4312
4290
  */
4313
- static extractPropertyValue(data, propName, selector, expectedType) {
4314
- const value = this.safeJMESPathSearch(data, selector);
4291
+ static extractPropertyValue(data, _propName, selector, expectedType) {
4292
+ const value = _SchemaProcessor.safeJMESPathSearch(data, selector);
4315
4293
  if (value === null || value === void 0) {
4316
4294
  return null;
4317
4295
  }
@@ -4319,9 +4297,10 @@ var SchemaProcessor = class {
4319
4297
  switch (expectedType) {
4320
4298
  case "string":
4321
4299
  return String(value);
4322
- case "number":
4300
+ case "number": {
4323
4301
  const num = Number(value);
4324
- return isNaN(num) ? null : num;
4302
+ return Number.isNaN(num) ? null : num;
4303
+ }
4325
4304
  case "boolean":
4326
4305
  return Boolean(value);
4327
4306
  case "array":
@@ -4385,7 +4364,8 @@ var SchemaProcessor = class {
4385
4364
  return transformToSelectorSchema(schema);
4386
4365
  }
4387
4366
  };
4388
- __publicField(SchemaProcessor, "logger", getLogger("SchemaProcessor"));
4367
+ __publicField(_SchemaProcessor, "logger", getLogger("SchemaProcessor"));
4368
+ var SchemaProcessor = _SchemaProcessor;
4389
4369
 
4390
4370
  // src/utils/artifact-component-schema.ts
4391
4371
  getLogger("ArtifactComponentSchema");
@@ -6474,7 +6454,7 @@ function hasToolCallWithPrefix(prefix) {
6474
6454
  return false;
6475
6455
  };
6476
6456
  }
6477
- var logger16 = getLogger("Agent");
6457
+ var logger15 = getLogger("Agent");
6478
6458
  var CONSTANTS = {
6479
6459
  MAX_GENERATION_STEPS: 12,
6480
6460
  PHASE_1_TIMEOUT_MS: 27e4,
@@ -6780,14 +6760,14 @@ var Agent = class {
6780
6760
  for (const toolSet of tools) {
6781
6761
  for (const [toolName, originalTool] of Object.entries(toolSet)) {
6782
6762
  if (!isValidTool(originalTool)) {
6783
- logger16.error({ toolName }, "Invalid MCP tool structure - missing required properties");
6763
+ logger15.error({ toolName }, "Invalid MCP tool structure - missing required properties");
6784
6764
  continue;
6785
6765
  }
6786
6766
  const sessionWrappedTool = tool({
6787
6767
  description: originalTool.description,
6788
6768
  inputSchema: originalTool.inputSchema,
6789
6769
  execute: async (args, { toolCallId }) => {
6790
- logger16.debug({ toolName, toolCallId }, "MCP Tool Called");
6770
+ logger15.debug({ toolName, toolCallId }, "MCP Tool Called");
6791
6771
  try {
6792
6772
  const rawResult = await originalTool.execute(args, { toolCallId });
6793
6773
  const parsedResult = parseEmbeddedJson(rawResult);
@@ -6801,7 +6781,7 @@ var Agent = class {
6801
6781
  });
6802
6782
  return { result: enhancedResult, toolCallId };
6803
6783
  } catch (error) {
6804
- logger16.error({ toolName, toolCallId, error }, "MCP tool execution failed");
6784
+ logger15.error({ toolName, toolCallId, error }, "MCP tool execution failed");
6805
6785
  throw error;
6806
6786
  }
6807
6787
  }
@@ -6902,7 +6882,7 @@ var Agent = class {
6902
6882
  headers: agentToolRelationHeaders
6903
6883
  };
6904
6884
  }
6905
- logger16.info(
6885
+ logger15.info(
6906
6886
  {
6907
6887
  toolName: tool3.name,
6908
6888
  credentialReferenceId,
@@ -6927,7 +6907,7 @@ var Agent = class {
6927
6907
  this.mcpClientCache.set(cacheKey, client);
6928
6908
  } catch (error) {
6929
6909
  this.mcpConnectionLocks.delete(cacheKey);
6930
- logger16.error(
6910
+ logger15.error(
6931
6911
  {
6932
6912
  toolName: tool3.name,
6933
6913
  subAgentId: this.config.id,
@@ -6991,7 +6971,7 @@ var Agent = class {
6991
6971
  await client.connect();
6992
6972
  return client;
6993
6973
  } catch (error) {
6994
- logger16.error(
6974
+ logger15.error(
6995
6975
  {
6996
6976
  toolName: tool3.name,
6997
6977
  subAgentId: this.config.id,
@@ -7028,12 +7008,12 @@ var Agent = class {
7028
7008
  if (functionToolsData.length === 0) {
7029
7009
  return functionTools;
7030
7010
  }
7031
- const { LocalSandboxExecutor } = await import('./LocalSandboxExecutor-TSOIXW7O.js');
7032
- const sandboxExecutor = LocalSandboxExecutor.getInstance();
7011
+ const { SandboxExecutorFactory } = await import('./SandboxExecutorFactory-FMNUKYDI.js');
7012
+ const sandboxExecutor = SandboxExecutorFactory.getInstance();
7033
7013
  for (const functionToolDef of functionToolsData) {
7034
7014
  const functionId = functionToolDef.functionId;
7035
7015
  if (!functionId) {
7036
- logger16.warn(
7016
+ logger15.warn(
7037
7017
  { functionToolId: functionToolDef.id },
7038
7018
  "Function tool missing functionId reference"
7039
7019
  );
@@ -7047,7 +7027,7 @@ var Agent = class {
7047
7027
  }
7048
7028
  });
7049
7029
  if (!functionData) {
7050
- logger16.warn(
7030
+ logger15.warn(
7051
7031
  { functionId, functionToolId: functionToolDef.id },
7052
7032
  "Function not found in functions table"
7053
7033
  );
@@ -7058,16 +7038,13 @@ var Agent = class {
7058
7038
  description: functionToolDef.description || functionToolDef.name,
7059
7039
  inputSchema: zodSchema,
7060
7040
  execute: async (args, { toolCallId }) => {
7061
- logger16.debug(
7041
+ logger15.debug(
7062
7042
  { toolName: functionToolDef.name, toolCallId, args },
7063
7043
  "Function Tool Called"
7064
7044
  );
7065
7045
  try {
7066
- const project = await getProject(dbClient_default)({
7067
- scopes: { tenantId: this.config.tenantId, projectId: this.config.projectId }
7068
- });
7069
7046
  const defaultSandboxConfig = {
7070
- provider: "local",
7047
+ provider: "native",
7071
7048
  runtime: "node22",
7072
7049
  timeout: 3e4,
7073
7050
  vcpus: 1
@@ -7077,7 +7054,7 @@ var Agent = class {
7077
7054
  inputSchema: functionData.inputSchema || {},
7078
7055
  executeCode: functionData.executeCode,
7079
7056
  dependencies: functionData.dependencies || {},
7080
- sandboxConfig: project?.sandboxConfig || defaultSandboxConfig
7057
+ sandboxConfig: this.config.sandboxConfig || defaultSandboxConfig
7081
7058
  });
7082
7059
  toolSessionManager.recordToolResult(sessionId || "", {
7083
7060
  toolCallId,
@@ -7088,8 +7065,12 @@ var Agent = class {
7088
7065
  });
7089
7066
  return { result, toolCallId };
7090
7067
  } catch (error) {
7091
- logger16.error(
7092
- { toolName: functionToolDef.name, toolCallId, error },
7068
+ logger15.error(
7069
+ {
7070
+ toolName: functionToolDef.name,
7071
+ toolCallId,
7072
+ error: error instanceof Error ? error.message : String(error)
7073
+ },
7093
7074
  "Function tool execution failed"
7094
7075
  );
7095
7076
  throw error;
@@ -7104,7 +7085,7 @@ var Agent = class {
7104
7085
  );
7105
7086
  }
7106
7087
  } catch (error) {
7107
- logger16.error({ error }, "Failed to load function tools from database");
7088
+ logger15.error({ error }, "Failed to load function tools from database");
7108
7089
  }
7109
7090
  return functionTools;
7110
7091
  }
@@ -7114,7 +7095,7 @@ var Agent = class {
7114
7095
  async getResolvedContext(conversationId, headers) {
7115
7096
  try {
7116
7097
  if (!this.config.contextConfigId) {
7117
- logger16.debug({ agentId: this.config.agentId }, "No context config found for agent");
7098
+ logger15.debug({ agentId: this.config.agentId }, "No context config found for agent");
7118
7099
  return null;
7119
7100
  }
7120
7101
  const contextConfig = await getContextConfigById(dbClient_default)({
@@ -7126,7 +7107,7 @@ var Agent = class {
7126
7107
  id: this.config.contextConfigId
7127
7108
  });
7128
7109
  if (!contextConfig) {
7129
- logger16.warn({ contextConfigId: this.config.contextConfigId }, "Context config not found");
7110
+ logger15.warn({ contextConfigId: this.config.contextConfigId }, "Context config not found");
7130
7111
  return null;
7131
7112
  }
7132
7113
  if (!this.contextResolver) {
@@ -7143,7 +7124,7 @@ var Agent = class {
7143
7124
  $now: (/* @__PURE__ */ new Date()).toISOString(),
7144
7125
  $env: process.env
7145
7126
  };
7146
- logger16.debug(
7127
+ logger15.debug(
7147
7128
  {
7148
7129
  conversationId,
7149
7130
  contextConfigId: contextConfig.id,
@@ -7157,7 +7138,7 @@ var Agent = class {
7157
7138
  );
7158
7139
  return contextWithBuiltins;
7159
7140
  } catch (error) {
7160
- logger16.error(
7141
+ logger15.error(
7161
7142
  {
7162
7143
  conversationId,
7163
7144
  error: error instanceof Error ? error.message : "Unknown error"
@@ -7181,7 +7162,7 @@ var Agent = class {
7181
7162
  });
7182
7163
  return agentDefinition?.prompt || void 0;
7183
7164
  } catch (error) {
7184
- logger16.warn(
7165
+ logger15.warn(
7185
7166
  {
7186
7167
  agentId: this.config.agentId,
7187
7168
  error: error instanceof Error ? error.message : "Unknown error"
@@ -7210,7 +7191,7 @@ var Agent = class {
7210
7191
  (subAgent) => "artifactComponents" in subAgent && subAgent.artifactComponents && subAgent.artifactComponents.length > 0
7211
7192
  );
7212
7193
  } catch (error) {
7213
- logger16.warn(
7194
+ logger15.warn(
7214
7195
  {
7215
7196
  agentId: this.config.agentId,
7216
7197
  tenantId: this.config.tenantId,
@@ -7239,7 +7220,7 @@ var Agent = class {
7239
7220
  preserveUnresolved: false
7240
7221
  });
7241
7222
  } catch (error) {
7242
- logger16.error(
7223
+ logger15.error(
7243
7224
  {
7244
7225
  conversationId,
7245
7226
  error: error instanceof Error ? error.message : "Unknown error"
@@ -7286,7 +7267,7 @@ var Agent = class {
7286
7267
  preserveUnresolved: false
7287
7268
  });
7288
7269
  } catch (error) {
7289
- logger16.error(
7270
+ logger15.error(
7290
7271
  {
7291
7272
  conversationId,
7292
7273
  error: error instanceof Error ? error.message : "Unknown error"
@@ -7301,7 +7282,7 @@ var Agent = class {
7301
7282
  const functionTools = await this.getFunctionTools(streamRequestId || "");
7302
7283
  const relationTools = this.getRelationTools(runtimeContext);
7303
7284
  const allTools = { ...mcpTools, ...functionTools, ...relationTools };
7304
- logger16.info(
7285
+ logger15.info(
7305
7286
  {
7306
7287
  mcpTools: Object.keys(mcpTools),
7307
7288
  functionTools: Object.keys(functionTools),
@@ -7340,7 +7321,7 @@ var Agent = class {
7340
7321
  preserveUnresolved: false
7341
7322
  });
7342
7323
  } catch (error) {
7343
- logger16.error(
7324
+ logger15.error(
7344
7325
  {
7345
7326
  conversationId,
7346
7327
  error: error instanceof Error ? error.message : "Unknown error"
@@ -7373,7 +7354,7 @@ var Agent = class {
7373
7354
  toolCallId: z.string().describe("The tool call ID associated with this artifact.")
7374
7355
  }),
7375
7356
  execute: async ({ artifactId, toolCallId }) => {
7376
- logger16.info({ artifactId, toolCallId }, "get_artifact_full executed");
7357
+ logger15.info({ artifactId, toolCallId }, "get_artifact_full executed");
7377
7358
  const streamRequestId = this.getStreamRequestId();
7378
7359
  const artifactService = agentSessionManager.getArtifactService(streamRequestId);
7379
7360
  if (!artifactService) {
@@ -7444,7 +7425,7 @@ var Agent = class {
7444
7425
  if (typeof result === "string") {
7445
7426
  try {
7446
7427
  parsedForAnalysis = parseEmbeddedJson(result);
7447
- } catch (error) {
7428
+ } catch (_error) {
7448
7429
  parsedForAnalysis = result;
7449
7430
  }
7450
7431
  }
@@ -7633,7 +7614,7 @@ var Agent = class {
7633
7614
  };
7634
7615
  return enhanced;
7635
7616
  } catch (error) {
7636
- logger16.warn({ error }, "Failed to enhance tool result with structure hints");
7617
+ logger15.warn({ error }, "Failed to enhance tool result with structure hints");
7637
7618
  return result;
7638
7619
  }
7639
7620
  }
@@ -7648,7 +7629,7 @@ var Agent = class {
7648
7629
  }
7649
7630
  });
7650
7631
  } catch (error) {
7651
- logger16.error(
7632
+ logger15.error(
7652
7633
  { error, agentId: this.config.agentId },
7653
7634
  "Failed to check agent artifact components"
7654
7635
  );
@@ -7749,7 +7730,7 @@ var Agent = class {
7749
7730
  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;
7750
7731
  const timeoutMs = Math.min(configuredTimeout, MAX_ALLOWED_TIMEOUT_MS);
7751
7732
  if (modelSettings.maxDuration && modelSettings.maxDuration * 1e3 > MAX_ALLOWED_TIMEOUT_MS) {
7752
- logger16.warn(
7733
+ logger15.warn(
7753
7734
  {
7754
7735
  requestedTimeout: modelSettings.maxDuration * 1e3,
7755
7736
  appliedTimeout: timeoutMs,
@@ -7791,7 +7772,7 @@ var Agent = class {
7791
7772
  }
7792
7773
  );
7793
7774
  } catch (error) {
7794
- logger16.debug({ error }, "Failed to track agent reasoning");
7775
+ logger15.debug({ error }, "Failed to track agent reasoning");
7795
7776
  }
7796
7777
  }
7797
7778
  if (steps.length >= 2) {
@@ -7913,7 +7894,7 @@ var Agent = class {
7913
7894
  }
7914
7895
  );
7915
7896
  } catch (error) {
7916
- logger16.debug({ error }, "Failed to track agent reasoning");
7897
+ logger15.debug({ error }, "Failed to track agent reasoning");
7917
7898
  }
7918
7899
  }
7919
7900
  if (steps.length >= 2) {
@@ -8211,7 +8192,7 @@ ${output}${structureHintsFormatted}`;
8211
8192
  };
8212
8193
 
8213
8194
  // src/agents/generateTaskHandler.ts
8214
- var logger17 = getLogger("generateTaskHandler");
8195
+ var logger16 = getLogger("generateTaskHandler");
8215
8196
  var createTaskHandler = (config, credentialStoreRegistry) => {
8216
8197
  return async (task) => {
8217
8198
  try {
@@ -8264,7 +8245,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
8264
8245
  }
8265
8246
  })
8266
8247
  ]);
8267
- logger17.info({ toolsForAgent, internalRelations, externalRelations }, "agent stuff");
8248
+ logger16.info({ toolsForAgent, internalRelations, externalRelations }, "agent stuff");
8268
8249
  const enhancedInternalRelations = await Promise.all(
8269
8250
  internalRelations.map(async (relation) => {
8270
8251
  try {
@@ -8293,7 +8274,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
8293
8274
  return { ...relation, description: enhancedDescription };
8294
8275
  }
8295
8276
  } catch (error) {
8296
- logger17.warn({ subAgentId: relation.id, error }, "Failed to enhance agent description");
8277
+ logger16.warn({ subAgentId: relation.id, error }, "Failed to enhance agent description");
8297
8278
  }
8298
8279
  return relation;
8299
8280
  })
@@ -8382,7 +8363,8 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
8382
8363
  dataComponents,
8383
8364
  artifactComponents,
8384
8365
  contextConfigId: config.contextConfigId || void 0,
8385
- conversationHistoryConfig: config.conversationHistoryConfig
8366
+ conversationHistoryConfig: config.conversationHistoryConfig,
8367
+ sandboxConfig: config.sandboxConfig
8386
8368
  },
8387
8369
  credentialStoreRegistry
8388
8370
  );
@@ -8395,7 +8377,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
8395
8377
  const taskIdMatch = task.id.match(/^task_([^-]+-[^-]+-\d+)-/);
8396
8378
  if (taskIdMatch) {
8397
8379
  contextId = taskIdMatch[1];
8398
- logger17.info(
8380
+ logger16.info(
8399
8381
  {
8400
8382
  taskId: task.id,
8401
8383
  extractedContextId: contextId,
@@ -8411,7 +8393,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
8411
8393
  const isDelegation = task.context?.metadata?.isDelegation === true;
8412
8394
  agent.setDelegationStatus(isDelegation);
8413
8395
  if (isDelegation) {
8414
- logger17.info(
8396
+ logger16.info(
8415
8397
  { subAgentId: config.subAgentId, taskId: task.id },
8416
8398
  "Delegated agent - streaming disabled"
8417
8399
  );
@@ -8448,7 +8430,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
8448
8430
  const toolResult = allToolResults.find(
8449
8431
  (result) => result.toolCallId === toolCall.toolCallId
8450
8432
  );
8451
- logger17.info(
8433
+ logger16.info(
8452
8434
  {
8453
8435
  toolCallName: toolCall.toolName,
8454
8436
  toolCallId: toolCall.toolCallId,
@@ -8465,7 +8447,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
8465
8447
  const transferReason = responseText || allThoughts[allThoughts.length - 1]?.text || "Agent requested transfer. No reason provided.";
8466
8448
  if (toolResult?.output && isValidTransferResult(toolResult.output)) {
8467
8449
  const transferResult = toolResult.output;
8468
- logger17.info(
8450
+ logger16.info(
8469
8451
  {
8470
8452
  validationPassed: true,
8471
8453
  transferResult,
@@ -8482,7 +8464,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
8482
8464
  reason: transferReason,
8483
8465
  original_message: userMessage
8484
8466
  };
8485
- logger17.info(
8467
+ logger16.info(
8486
8468
  {
8487
8469
  artifactData,
8488
8470
  artifactDataKeys: Object.keys(artifactData)
@@ -8507,7 +8489,7 @@ var createTaskHandler = (config, credentialStoreRegistry) => {
8507
8489
  ]
8508
8490
  };
8509
8491
  } else {
8510
- logger17.warn(
8492
+ logger16.warn(
8511
8493
  {
8512
8494
  hasToolResult: !!toolResult,
8513
8495
  hasOutput: !!toolResult?.output,
@@ -8588,7 +8570,8 @@ var createTaskHandlerConfig = async (params) => {
8588
8570
  name: subAgent.name,
8589
8571
  description: subAgent.description,
8590
8572
  conversationHistoryConfig: effectiveConversationHistoryConfig,
8591
- contextConfigId: agent?.contextConfigId || void 0
8573
+ contextConfigId: agent?.contextConfigId || void 0,
8574
+ sandboxConfig: params.sandboxConfig
8592
8575
  };
8593
8576
  };
8594
8577
 
@@ -8663,7 +8646,8 @@ async function hydrateAgent({
8663
8646
  agentId,
8664
8647
  baseUrl,
8665
8648
  apiKey,
8666
- credentialStoreRegistry
8649
+ credentialStoreRegistry,
8650
+ sandboxConfig
8667
8651
  }) {
8668
8652
  try {
8669
8653
  const taskHandlerConfig = await createTaskHandlerConfig({
@@ -8672,7 +8656,8 @@ async function hydrateAgent({
8672
8656
  agentId,
8673
8657
  subAgentId: dbAgent.id,
8674
8658
  baseUrl,
8675
- apiKey
8659
+ apiKey,
8660
+ sandboxConfig
8676
8661
  });
8677
8662
  const taskHandler = createTaskHandler(taskHandlerConfig, credentialStoreRegistry);
8678
8663
  const agentCard = createAgentCard({
@@ -8692,7 +8677,8 @@ async function hydrateAgent({
8692
8677
  throw error;
8693
8678
  }
8694
8679
  }
8695
- async function getRegisteredAgent(executionContext, credentialStoreRegistry) {
8680
+ async function getRegisteredAgent(params) {
8681
+ const { executionContext, credentialStoreRegistry, sandboxConfig } = params;
8696
8682
  const { tenantId, projectId, agentId, subAgentId, baseUrl, apiKey } = executionContext;
8697
8683
  if (!subAgentId) {
8698
8684
  throw new Error("Agent ID is required");
@@ -8710,13 +8696,14 @@ async function getRegisteredAgent(executionContext, credentialStoreRegistry) {
8710
8696
  agentId,
8711
8697
  baseUrl: agentFrameworkBaseUrl,
8712
8698
  credentialStoreRegistry,
8713
- apiKey
8699
+ apiKey,
8700
+ sandboxConfig
8714
8701
  });
8715
8702
  }
8716
8703
 
8717
8704
  // src/routes/agents.ts
8718
8705
  var app = new OpenAPIHono();
8719
- var logger18 = getLogger("agents");
8706
+ var logger17 = getLogger("agents");
8720
8707
  app.openapi(
8721
8708
  createRoute({
8722
8709
  method: "get",
@@ -8754,7 +8741,7 @@ app.openapi(
8754
8741
  tracestate: c.req.header("tracestate"),
8755
8742
  baggage: c.req.header("baggage")
8756
8743
  };
8757
- logger18.info(
8744
+ logger17.info(
8758
8745
  {
8759
8746
  otelHeaders,
8760
8747
  path: c.req.path,
@@ -8766,7 +8753,7 @@ app.openapi(
8766
8753
  const { tenantId, projectId, agentId, subAgentId } = executionContext;
8767
8754
  console.dir("executionContext", executionContext);
8768
8755
  if (subAgentId) {
8769
- logger18.info(
8756
+ logger17.info(
8770
8757
  {
8771
8758
  message: "getRegisteredAgent (agent-level)",
8772
8759
  tenantId,
@@ -8777,8 +8764,13 @@ app.openapi(
8777
8764
  "agent-level well-known agent.json"
8778
8765
  );
8779
8766
  const credentialStores = c.get("credentialStores");
8780
- const agent = await getRegisteredAgent(executionContext, credentialStores);
8781
- logger18.info({ agent }, "agent registered: well-known agent.json");
8767
+ const sandboxConfig = c.get("sandboxConfig");
8768
+ const agent = await getRegisteredAgent({
8769
+ executionContext,
8770
+ credentialStoreRegistry: credentialStores,
8771
+ sandboxConfig
8772
+ });
8773
+ logger17.info({ agent }, "agent registered: well-known agent.json");
8782
8774
  if (!agent) {
8783
8775
  throw createApiError({
8784
8776
  code: "not_found",
@@ -8787,7 +8779,7 @@ app.openapi(
8787
8779
  }
8788
8780
  return c.json(agent.agentCard);
8789
8781
  } else {
8790
- logger18.info(
8782
+ logger17.info(
8791
8783
  {
8792
8784
  message: "getRegisteredAgent (agent-level)",
8793
8785
  tenantId,
@@ -8796,7 +8788,11 @@ app.openapi(
8796
8788
  },
8797
8789
  "agent-level well-known agent.json"
8798
8790
  );
8799
- const agent = await getRegisteredAgent(executionContext);
8791
+ const sandboxConfig = c.get("sandboxConfig");
8792
+ const agent = await getRegisteredAgent({
8793
+ executionContext,
8794
+ sandboxConfig
8795
+ });
8800
8796
  if (!agent) {
8801
8797
  throw createApiError({
8802
8798
  code: "not_found",
@@ -8813,7 +8809,7 @@ app.post("/a2a", async (c) => {
8813
8809
  tracestate: c.req.header("tracestate"),
8814
8810
  baggage: c.req.header("baggage")
8815
8811
  };
8816
- logger18.info(
8812
+ logger17.info(
8817
8813
  {
8818
8814
  otelHeaders,
8819
8815
  path: c.req.path,
@@ -8824,7 +8820,7 @@ app.post("/a2a", async (c) => {
8824
8820
  const executionContext = getRequestExecutionContext(c);
8825
8821
  const { tenantId, projectId, agentId, subAgentId } = executionContext;
8826
8822
  if (subAgentId) {
8827
- logger18.info(
8823
+ logger17.info(
8828
8824
  {
8829
8825
  message: "a2a (agent-level)",
8830
8826
  tenantId,
@@ -8835,7 +8831,12 @@ app.post("/a2a", async (c) => {
8835
8831
  "agent-level a2a endpoint"
8836
8832
  );
8837
8833
  const credentialStores = c.get("credentialStores");
8838
- const agent = await getRegisteredAgent(executionContext, credentialStores);
8834
+ const sandboxConfig = c.get("sandboxConfig");
8835
+ const agent = await getRegisteredAgent({
8836
+ executionContext,
8837
+ credentialStoreRegistry: credentialStores,
8838
+ sandboxConfig
8839
+ });
8839
8840
  if (!agent) {
8840
8841
  return c.json(
8841
8842
  {
@@ -8848,7 +8849,7 @@ app.post("/a2a", async (c) => {
8848
8849
  }
8849
8850
  return a2aHandler(c, agent);
8850
8851
  } else {
8851
- logger18.info(
8852
+ logger17.info(
8852
8853
  {
8853
8854
  message: "a2a (agent-level)",
8854
8855
  tenantId,
@@ -8882,7 +8883,12 @@ app.post("/a2a", async (c) => {
8882
8883
  }
8883
8884
  executionContext.subAgentId = agent.defaultSubAgentId;
8884
8885
  const credentialStores = c.get("credentialStores");
8885
- const defaultSubAgent = await getRegisteredAgent(executionContext, credentialStores);
8886
+ const sandboxConfig = c.get("sandboxConfig");
8887
+ const defaultSubAgent = await getRegisteredAgent({
8888
+ executionContext,
8889
+ credentialStoreRegistry: credentialStores,
8890
+ sandboxConfig
8891
+ });
8886
8892
  if (!defaultSubAgent) {
8887
8893
  return c.json(
8888
8894
  {
@@ -8946,28 +8952,37 @@ function extractTransferData(task) {
8946
8952
  }
8947
8953
 
8948
8954
  // src/a2a/transfer.ts
8949
- var logger19 = getLogger("Transfer");
8955
+ var logger18 = getLogger("Transfer");
8950
8956
  async function executeTransfer({
8951
8957
  tenantId,
8952
8958
  threadId,
8953
8959
  projectId,
8954
8960
  targetSubAgentId
8955
8961
  }) {
8956
- logger19.info({
8957
- targetAgent: targetSubAgentId,
8958
- threadId,
8959
- tenantId,
8960
- projectId
8961
- }, "Executing transfer - calling setActiveAgentForThread");
8962
+ logger18.info(
8963
+ {
8964
+ targetAgent: targetSubAgentId,
8965
+ threadId,
8966
+ tenantId,
8967
+ projectId
8968
+ },
8969
+ "Executing transfer - calling setActiveAgentForThread"
8970
+ );
8962
8971
  try {
8963
8972
  await setActiveAgentForThread(dbClient_default)({
8964
8973
  scopes: { tenantId, projectId },
8965
8974
  threadId,
8966
8975
  subAgentId: targetSubAgentId
8967
8976
  });
8968
- logger19.info({ targetAgent: targetSubAgentId, threadId }, "Successfully updated active_sub_agent_id in database");
8977
+ logger18.info(
8978
+ { targetAgent: targetSubAgentId, threadId },
8979
+ "Successfully updated active_sub_agent_id in database"
8980
+ );
8969
8981
  } catch (error) {
8970
- logger19.error({ error, targetAgent: targetSubAgentId, threadId }, "Failed to update active_sub_agent_id");
8982
+ logger18.error(
8983
+ { error, targetAgent: targetSubAgentId, threadId },
8984
+ "Failed to update active_sub_agent_id"
8985
+ );
8971
8986
  throw error;
8972
8987
  }
8973
8988
  return { success: true, targetSubAgentId };
@@ -9379,7 +9394,7 @@ var _VercelDataStreamHelper = class _VercelDataStreamHelper {
9379
9394
  timestamp: Date.now()
9380
9395
  });
9381
9396
  }
9382
- } catch (e) {
9397
+ } catch (_e) {
9383
9398
  }
9384
9399
  }
9385
9400
  /**
@@ -9535,7 +9550,7 @@ function createMCPStreamHelper() {
9535
9550
  }
9536
9551
 
9537
9552
  // src/handlers/executionHandler.ts
9538
- var logger20 = getLogger("ExecutionHandler");
9553
+ var logger19 = getLogger("ExecutionHandler");
9539
9554
  var ExecutionHandler = class {
9540
9555
  constructor() {
9541
9556
  __publicField(this, "MAX_ERRORS", 3);
@@ -9570,7 +9585,7 @@ var ExecutionHandler = class {
9570
9585
  if (emitOperations) {
9571
9586
  agentSessionManager.enableEmitOperations(requestId2);
9572
9587
  }
9573
- logger20.info(
9588
+ logger19.info(
9574
9589
  { sessionId: requestId2, agentId, conversationId, emitOperations },
9575
9590
  "Created AgentSession for message execution"
9576
9591
  );
@@ -9587,7 +9602,7 @@ var ExecutionHandler = class {
9587
9602
  );
9588
9603
  }
9589
9604
  } catch (error) {
9590
- logger20.error(
9605
+ logger19.error(
9591
9606
  {
9592
9607
  error: error instanceof Error ? error.message : "Unknown error",
9593
9608
  stack: error instanceof Error ? error.stack : void 0
@@ -9603,7 +9618,7 @@ var ExecutionHandler = class {
9603
9618
  try {
9604
9619
  await sseHelper.writeOperation(agentInitializingOp(requestId2, agentId));
9605
9620
  const taskId = `task_${conversationId}-${requestId2}`;
9606
- logger20.info(
9621
+ logger19.info(
9607
9622
  { taskId, currentAgentId, conversationId, requestId: requestId2 },
9608
9623
  "Attempting to create or reuse existing task"
9609
9624
  );
@@ -9627,7 +9642,7 @@ var ExecutionHandler = class {
9627
9642
  sub_agent_id: currentAgentId
9628
9643
  }
9629
9644
  });
9630
- logger20.info(
9645
+ logger19.info(
9631
9646
  {
9632
9647
  taskId,
9633
9648
  createdTaskMetadata: Array.isArray(task) ? task[0]?.metadata : task?.metadata
@@ -9636,27 +9651,27 @@ var ExecutionHandler = class {
9636
9651
  );
9637
9652
  } catch (error) {
9638
9653
  if (error?.message?.includes("UNIQUE constraint failed") || error?.message?.includes("PRIMARY KEY constraint failed") || error?.code === "SQLITE_CONSTRAINT_PRIMARYKEY") {
9639
- logger20.info(
9654
+ logger19.info(
9640
9655
  { taskId, error: error.message },
9641
9656
  "Task already exists, fetching existing task"
9642
9657
  );
9643
9658
  const existingTask = await getTask(dbClient_default)({ id: taskId });
9644
9659
  if (existingTask) {
9645
9660
  task = existingTask;
9646
- logger20.info(
9661
+ logger19.info(
9647
9662
  { taskId, existingTask },
9648
9663
  "Successfully reused existing task from race condition"
9649
9664
  );
9650
9665
  } else {
9651
- logger20.error({ taskId, error }, "Task constraint failed but task not found");
9666
+ logger19.error({ taskId, error }, "Task constraint failed but task not found");
9652
9667
  throw error;
9653
9668
  }
9654
9669
  } else {
9655
- logger20.error({ taskId, error }, "Failed to create task due to non-constraint error");
9670
+ logger19.error({ taskId, error }, "Failed to create task due to non-constraint error");
9656
9671
  throw error;
9657
9672
  }
9658
9673
  }
9659
- logger20.debug(
9674
+ logger19.debug(
9660
9675
  {
9661
9676
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
9662
9677
  executionType: "create_initial_task",
@@ -9675,7 +9690,7 @@ var ExecutionHandler = class {
9675
9690
  const maxTransfers = agentConfig?.stopWhen?.transferCountIs ?? 10;
9676
9691
  while (iterations < maxTransfers) {
9677
9692
  iterations++;
9678
- logger20.info(
9693
+ logger19.info(
9679
9694
  { iterations, currentAgentId, agentId, conversationId, fromSubAgentId },
9680
9695
  `Execution loop iteration ${iterations} with agent ${currentAgentId}, transfer from: ${fromSubAgentId || "none"}`
9681
9696
  );
@@ -9683,10 +9698,10 @@ var ExecutionHandler = class {
9683
9698
  scopes: { tenantId, projectId },
9684
9699
  conversationId
9685
9700
  });
9686
- logger20.info({ activeAgent }, "activeAgent");
9701
+ logger19.info({ activeAgent }, "activeAgent");
9687
9702
  if (activeAgent && activeAgent.activeSubAgentId !== currentAgentId) {
9688
9703
  currentAgentId = activeAgent.activeSubAgentId;
9689
- logger20.info({ currentAgentId }, `Updated current agent to: ${currentAgentId}`);
9704
+ logger19.info({ currentAgentId }, `Updated current agent to: ${currentAgentId}`);
9690
9705
  }
9691
9706
  const agentBaseUrl = `${baseUrl}/agents`;
9692
9707
  const a2aClient = new A2AClient(agentBaseUrl, {
@@ -9727,13 +9742,13 @@ var ExecutionHandler = class {
9727
9742
  });
9728
9743
  if (!messageResponse?.result) {
9729
9744
  errorCount++;
9730
- logger20.error(
9745
+ logger19.error(
9731
9746
  { currentAgentId, iterations, errorCount },
9732
9747
  `No response from agent ${currentAgentId} on iteration ${iterations} (error ${errorCount}/${this.MAX_ERRORS})`
9733
9748
  );
9734
9749
  if (errorCount >= this.MAX_ERRORS) {
9735
9750
  const errorMessage2 = `Maximum error limit (${this.MAX_ERRORS}) reached`;
9736
- logger20.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
9751
+ logger19.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
9737
9752
  await sseHelper.writeOperation(errorOp(errorMessage2, currentAgentId || "system"));
9738
9753
  if (task) {
9739
9754
  await updateTask(dbClient_default)({
@@ -9757,7 +9772,7 @@ var ExecutionHandler = class {
9757
9772
  if (isTransferTask(messageResponse.result)) {
9758
9773
  const transferData = extractTransferData(messageResponse.result);
9759
9774
  if (!transferData) {
9760
- logger20.error(
9775
+ logger19.error(
9761
9776
  { result: messageResponse.result },
9762
9777
  "Transfer detected but no transfer data found"
9763
9778
  );
@@ -9766,10 +9781,7 @@ var ExecutionHandler = class {
9766
9781
  const { targetSubAgentId, fromSubAgentId: transferFromAgent } = transferData;
9767
9782
  const firstArtifact = messageResponse.result.artifacts[0];
9768
9783
  const transferReason = firstArtifact?.parts[1]?.kind === "text" ? firstArtifact.parts[1].text : "Transfer initiated";
9769
- logger20.info(
9770
- { targetSubAgentId, transferReason, transferFromAgent },
9771
- "Transfer response"
9772
- );
9784
+ logger19.info({ targetSubAgentId, transferReason, transferFromAgent }, "Transfer response");
9773
9785
  currentMessage = `<transfer_context> ${transferReason} </transfer_context>`;
9774
9786
  const { success, targetSubAgentId: newAgentId } = await executeTransfer({
9775
9787
  projectId,
@@ -9780,7 +9792,7 @@ var ExecutionHandler = class {
9780
9792
  if (success) {
9781
9793
  fromSubAgentId = currentAgentId;
9782
9794
  currentAgentId = newAgentId;
9783
- logger20.info(
9795
+ logger19.info(
9784
9796
  {
9785
9797
  transferFrom: fromSubAgentId,
9786
9798
  transferTo: currentAgentId,
@@ -9794,7 +9806,7 @@ var ExecutionHandler = class {
9794
9806
  let responseParts = [];
9795
9807
  if (messageResponse.result.streamedContent?.parts) {
9796
9808
  responseParts = messageResponse.result.streamedContent.parts;
9797
- logger20.info(
9809
+ logger19.info(
9798
9810
  { partsCount: responseParts.length },
9799
9811
  "Using streamed content for conversation history"
9800
9812
  );
@@ -9802,7 +9814,7 @@ var ExecutionHandler = class {
9802
9814
  responseParts = messageResponse.result.artifacts?.flatMap(
9803
9815
  (artifact) => artifact.parts || []
9804
9816
  ) || [];
9805
- logger20.info(
9817
+ logger19.info(
9806
9818
  { partsCount: responseParts.length },
9807
9819
  "Using artifacts for conversation history (fallback)"
9808
9820
  );
@@ -9811,7 +9823,7 @@ var ExecutionHandler = class {
9811
9823
  const agentSessionData = agentSessionManager.getSession(requestId2);
9812
9824
  if (agentSessionData) {
9813
9825
  const sessionSummary = agentSessionData.getSummary();
9814
- logger20.info(sessionSummary, "AgentSession data after completion");
9826
+ logger19.info(sessionSummary, "AgentSession data after completion");
9815
9827
  }
9816
9828
  let textContent = "";
9817
9829
  for (const part of responseParts) {
@@ -9864,22 +9876,22 @@ var ExecutionHandler = class {
9864
9876
  }
9865
9877
  });
9866
9878
  const updateTaskEnd = Date.now();
9867
- logger20.info(
9879
+ logger19.info(
9868
9880
  { duration: updateTaskEnd - updateTaskStart },
9869
9881
  "Completed updateTask operation"
9870
9882
  );
9871
9883
  await sseHelper.writeOperation(completionOp(currentAgentId, iterations));
9872
9884
  await sseHelper.complete();
9873
- logger20.info({}, "Ending AgentSession and cleaning up");
9885
+ logger19.info({}, "Ending AgentSession and cleaning up");
9874
9886
  agentSessionManager.endSession(requestId2);
9875
- logger20.info({}, "Cleaning up streamHelper");
9887
+ logger19.info({}, "Cleaning up streamHelper");
9876
9888
  unregisterStreamHelper(requestId2);
9877
9889
  let response;
9878
9890
  if (sseHelper instanceof MCPStreamHelper) {
9879
9891
  const captured = sseHelper.getCapturedResponse();
9880
9892
  response = captured.text || "No response content";
9881
9893
  }
9882
- logger20.info({}, "ExecutionHandler returning success");
9894
+ logger19.info({}, "ExecutionHandler returning success");
9883
9895
  return { success: true, iterations, response };
9884
9896
  } catch (error) {
9885
9897
  setSpanWithError(span, error instanceof Error ? error : new Error(String(error)));
@@ -9890,13 +9902,13 @@ var ExecutionHandler = class {
9890
9902
  });
9891
9903
  }
9892
9904
  errorCount++;
9893
- logger20.warn(
9905
+ logger19.warn(
9894
9906
  { iterations, errorCount },
9895
9907
  `No valid response or transfer on iteration ${iterations} (error ${errorCount}/${this.MAX_ERRORS})`
9896
9908
  );
9897
9909
  if (errorCount >= this.MAX_ERRORS) {
9898
9910
  const errorMessage2 = `Maximum error limit (${this.MAX_ERRORS}) reached`;
9899
- logger20.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
9911
+ logger19.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
9900
9912
  await sseHelper.writeOperation(errorOp(errorMessage2, currentAgentId || "system"));
9901
9913
  if (task) {
9902
9914
  await updateTask(dbClient_default)({
@@ -9917,7 +9929,7 @@ var ExecutionHandler = class {
9917
9929
  }
9918
9930
  }
9919
9931
  const errorMessage = `Maximum transfer limit (${maxTransfers}) reached without completion`;
9920
- logger20.error({ maxTransfers, iterations }, errorMessage);
9932
+ logger19.error({ maxTransfers, iterations }, errorMessage);
9921
9933
  await sseHelper.writeOperation(errorOp(errorMessage, currentAgentId || "system"));
9922
9934
  if (task) {
9923
9935
  await updateTask(dbClient_default)({
@@ -9936,7 +9948,7 @@ var ExecutionHandler = class {
9936
9948
  unregisterStreamHelper(requestId2);
9937
9949
  return { success: false, error: errorMessage, iterations };
9938
9950
  } catch (error) {
9939
- logger20.error({ error }, "Error in execution handler");
9951
+ logger19.error({ error }, "Error in execution handler");
9940
9952
  const errorMessage = error instanceof Error ? error.message : "Unknown execution error";
9941
9953
  await sseHelper.writeOperation(
9942
9954
  errorOp(`Execution error: ${errorMessage}`, currentAgentId || "system")
@@ -9963,7 +9975,7 @@ var ExecutionHandler = class {
9963
9975
 
9964
9976
  // src/routes/chat.ts
9965
9977
  var app2 = new OpenAPIHono();
9966
- var logger21 = getLogger("completionsHandler");
9978
+ var logger20 = getLogger("completionsHandler");
9967
9979
  var chatCompletionsRoute = createRoute({
9968
9980
  method: "post",
9969
9981
  path: "/completions",
@@ -10081,7 +10093,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
10081
10093
  tracestate: c.req.header("tracestate"),
10082
10094
  baggage: c.req.header("baggage")
10083
10095
  };
10084
- logger21.info(
10096
+ logger20.info(
10085
10097
  {
10086
10098
  otelHeaders,
10087
10099
  path: c.req.path,
@@ -10190,7 +10202,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
10190
10202
  dbClient: dbClient_default,
10191
10203
  credentialStores
10192
10204
  });
10193
- logger21.info(
10205
+ logger20.info(
10194
10206
  {
10195
10207
  tenantId,
10196
10208
  projectId,
@@ -10238,7 +10250,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
10238
10250
  try {
10239
10251
  const sseHelper = createSSEStreamHelper(stream2, requestId2, timestamp);
10240
10252
  await sseHelper.writeRole();
10241
- logger21.info({ subAgentId }, "Starting execution");
10253
+ logger20.info({ subAgentId }, "Starting execution");
10242
10254
  const emitOperationsHeader = c.req.header("x-emit-operations");
10243
10255
  const emitOperations = emitOperationsHeader === "true";
10244
10256
  const executionHandler = new ExecutionHandler();
@@ -10251,7 +10263,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
10251
10263
  sseHelper,
10252
10264
  emitOperations
10253
10265
  });
10254
- logger21.info(
10266
+ logger20.info(
10255
10267
  { result },
10256
10268
  `Execution completed: ${result.success ? "success" : "failed"} after ${result.iterations} iterations`
10257
10269
  );
@@ -10265,7 +10277,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
10265
10277
  }
10266
10278
  await sseHelper.complete();
10267
10279
  } catch (error) {
10268
- logger21.error(
10280
+ logger20.error(
10269
10281
  {
10270
10282
  error: error instanceof Error ? error.message : error,
10271
10283
  stack: error instanceof Error ? error.stack : void 0
@@ -10282,13 +10294,13 @@ app2.openapi(chatCompletionsRoute, async (c) => {
10282
10294
  );
10283
10295
  await sseHelper.complete();
10284
10296
  } catch (streamError) {
10285
- logger21.error({ streamError }, "Failed to write error to stream");
10297
+ logger20.error({ streamError }, "Failed to write error to stream");
10286
10298
  }
10287
10299
  }
10288
10300
  });
10289
10301
  });
10290
10302
  } catch (error) {
10291
- logger21.error(
10303
+ logger20.error(
10292
10304
  {
10293
10305
  error: error instanceof Error ? error.message : error,
10294
10306
  stack: error instanceof Error ? error.stack : void 0
@@ -10312,7 +10324,7 @@ var getMessageText = (content) => {
10312
10324
  };
10313
10325
  var chat_default = app2;
10314
10326
  var app3 = new OpenAPIHono();
10315
- var logger22 = getLogger("chatDataStream");
10327
+ var logger21 = getLogger("chatDataStream");
10316
10328
  var chatDataStreamRoute = createRoute({
10317
10329
  method: "post",
10318
10330
  path: "/chat",
@@ -10436,7 +10448,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
10436
10448
  });
10437
10449
  const lastUserMessage = body.messages.filter((m) => m.role === "user").slice(-1)[0];
10438
10450
  const userText = typeof lastUserMessage?.content === "string" ? lastUserMessage.content : lastUserMessage?.parts?.map((p) => p.text).join("") || "";
10439
- logger22.info({ userText, lastUserMessage }, "userText");
10451
+ logger21.info({ userText, lastUserMessage }, "userText");
10440
10452
  const messageSpan = trace.getActiveSpan();
10441
10453
  if (messageSpan) {
10442
10454
  messageSpan.setAttributes({
@@ -10481,7 +10493,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
10481
10493
  await streamHelper.writeOperation(errorOp("Unable to process request", "system"));
10482
10494
  }
10483
10495
  } catch (err) {
10484
- logger22.error({ err }, "Streaming error");
10496
+ logger21.error({ err }, "Streaming error");
10485
10497
  await streamHelper.writeOperation(errorOp("Internal server error", "system"));
10486
10498
  } finally {
10487
10499
  if ("cleanup" in streamHelper && typeof streamHelper.cleanup === "function") {
@@ -10503,7 +10515,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
10503
10515
  );
10504
10516
  });
10505
10517
  } catch (error) {
10506
- logger22.error({ error }, "chatDataStream error");
10518
+ logger21.error({ error }, "chatDataStream error");
10507
10519
  throw createApiError({
10508
10520
  code: "internal_server_error",
10509
10521
  message: "Failed to process chat completion"
@@ -10514,7 +10526,7 @@ var chatDataStream_default = app3;
10514
10526
  function createMCPSchema(schema) {
10515
10527
  return schema;
10516
10528
  }
10517
- var logger23 = getLogger("mcp");
10529
+ var logger22 = getLogger("mcp");
10518
10530
  var _MockResponseSingleton = class _MockResponseSingleton {
10519
10531
  constructor() {
10520
10532
  __publicField(this, "mockRes");
@@ -10569,21 +10581,21 @@ var createSpoofInitMessage = (mcpProtocolVersion) => ({
10569
10581
  id: 0
10570
10582
  });
10571
10583
  var spoofTransportInitialization = async (transport, req, sessionId, mcpProtocolVersion) => {
10572
- logger23.info({ sessionId }, "Spoofing initialization message to set transport state");
10584
+ logger22.info({ sessionId }, "Spoofing initialization message to set transport state");
10573
10585
  const spoofInitMessage = createSpoofInitMessage(mcpProtocolVersion);
10574
10586
  const mockRes = MockResponseSingleton.getInstance().getMockResponse();
10575
10587
  try {
10576
10588
  await transport.handleRequest(req, mockRes, spoofInitMessage);
10577
- logger23.info({ sessionId }, "Successfully spoofed initialization");
10589
+ logger22.info({ sessionId }, "Successfully spoofed initialization");
10578
10590
  } catch (spoofError) {
10579
- logger23.warn({ sessionId, error: spoofError }, "Spoof initialization failed, continuing anyway");
10591
+ logger22.warn({ sessionId, error: spoofError }, "Spoof initialization failed, continuing anyway");
10580
10592
  }
10581
10593
  };
10582
10594
  var validateSession = async (req, res, body, tenantId, projectId, agentId) => {
10583
10595
  const sessionId = req.headers["mcp-session-id"];
10584
- logger23.info({ sessionId }, "Received MCP session ID");
10596
+ logger22.info({ sessionId }, "Received MCP session ID");
10585
10597
  if (!sessionId) {
10586
- logger23.info({ body }, "Missing session ID");
10598
+ logger22.info({ body }, "Missing session ID");
10587
10599
  res.writeHead(400).end(
10588
10600
  JSON.stringify({
10589
10601
  jsonrpc: "2.0",
@@ -10609,7 +10621,7 @@ var validateSession = async (req, res, body, tenantId, projectId, agentId) => {
10609
10621
  scopes: { tenantId, projectId },
10610
10622
  conversationId: sessionId
10611
10623
  });
10612
- logger23.info(
10624
+ logger22.info(
10613
10625
  {
10614
10626
  sessionId,
10615
10627
  conversationFound: !!conversation,
@@ -10620,7 +10632,7 @@ var validateSession = async (req, res, body, tenantId, projectId, agentId) => {
10620
10632
  "Conversation lookup result"
10621
10633
  );
10622
10634
  if (!conversation || conversation.metadata?.sessionData?.sessionType !== "mcp" || conversation.metadata?.sessionData?.agentId !== agentId) {
10623
- logger23.info(
10635
+ logger22.info(
10624
10636
  { sessionId, conversationId: conversation?.id },
10625
10637
  "MCP session not found or invalid"
10626
10638
  );
@@ -10681,7 +10693,7 @@ var executeAgentQuery = async (executionContext, conversationId, query, defaultS
10681
10693
  requestId: requestId2,
10682
10694
  sseHelper: mcpStreamHelper
10683
10695
  });
10684
- logger23.info(
10696
+ logger22.info(
10685
10697
  { result },
10686
10698
  `Execution completed: ${result.success ? "success" : "failed"} after ${result.iterations} iterations`
10687
10699
  );
@@ -10765,7 +10777,7 @@ var getServer = async (headers, executionContext, conversationId, credentialStor
10765
10777
  dbClient: dbClient_default,
10766
10778
  credentialStores
10767
10779
  });
10768
- logger23.info(
10780
+ logger22.info(
10769
10781
  {
10770
10782
  tenantId,
10771
10783
  projectId,
@@ -10827,7 +10839,7 @@ var validateRequestParameters = (c) => {
10827
10839
  };
10828
10840
  var handleInitializationRequest = async (body, executionContext, validatedContext, req, res, c, credentialStores) => {
10829
10841
  const { tenantId, projectId, agentId } = executionContext;
10830
- logger23.info({ body }, "Received initialization request");
10842
+ logger22.info({ body }, "Received initialization request");
10831
10843
  const sessionId = getConversationId();
10832
10844
  const activeSpan = trace.getActiveSpan();
10833
10845
  if (activeSpan) {
@@ -10883,7 +10895,7 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
10883
10895
  }
10884
10896
  }
10885
10897
  });
10886
- logger23.info(
10898
+ logger22.info(
10887
10899
  { sessionId, conversationId: conversation.id },
10888
10900
  "Created MCP session as conversation"
10889
10901
  );
@@ -10892,9 +10904,9 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
10892
10904
  });
10893
10905
  const server = await getServer(validatedContext, executionContext, sessionId, credentialStores);
10894
10906
  await server.connect(transport);
10895
- logger23.info({ sessionId }, "Server connected for initialization");
10907
+ logger22.info({ sessionId }, "Server connected for initialization");
10896
10908
  res.setHeader("Mcp-Session-Id", sessionId);
10897
- logger23.info(
10909
+ logger22.info(
10898
10910
  {
10899
10911
  sessionId,
10900
10912
  bodyMethod: body?.method,
@@ -10903,7 +10915,7 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
10903
10915
  "About to handle initialization request"
10904
10916
  );
10905
10917
  await transport.handleRequest(req, res, body);
10906
- logger23.info({ sessionId }, "Successfully handled initialization request");
10918
+ logger22.info({ sessionId }, "Successfully handled initialization request");
10907
10919
  return toFetchResponse(res);
10908
10920
  });
10909
10921
  };
@@ -10930,8 +10942,8 @@ var handleExistingSessionRequest = async (body, executionContext, validatedConte
10930
10942
  sessionId,
10931
10943
  conversation.metadata?.session_data?.mcpProtocolVersion
10932
10944
  );
10933
- logger23.info({ sessionId }, "Server connected and transport initialized");
10934
- logger23.info(
10945
+ logger22.info({ sessionId }, "Server connected and transport initialized");
10946
+ logger22.info(
10935
10947
  {
10936
10948
  sessionId,
10937
10949
  bodyKeys: Object.keys(body || {}),
@@ -10945,9 +10957,9 @@ var handleExistingSessionRequest = async (body, executionContext, validatedConte
10945
10957
  );
10946
10958
  try {
10947
10959
  await transport.handleRequest(req, res, body);
10948
- logger23.info({ sessionId }, "Successfully handled MCP request");
10960
+ logger22.info({ sessionId }, "Successfully handled MCP request");
10949
10961
  } catch (transportError) {
10950
- logger23.error(
10962
+ logger22.error(
10951
10963
  {
10952
10964
  sessionId,
10953
10965
  error: transportError,
@@ -10998,13 +11010,13 @@ app4.openapi(
10998
11010
  }
10999
11011
  const { executionContext } = paramValidation;
11000
11012
  const body = c.get("requestBody") || {};
11001
- logger23.info({ body, bodyKeys: Object.keys(body || {}) }, "Parsed request body");
11013
+ logger22.info({ body, bodyKeys: Object.keys(body || {}) }, "Parsed request body");
11002
11014
  const isInitRequest = body.method === "initialize";
11003
11015
  const { req, res } = toReqRes(c.req.raw);
11004
11016
  const validatedContext = c.get("validatedContext") || {};
11005
11017
  const credentialStores = c.get("credentialStores");
11006
- logger23.info({ validatedContext }, "Validated context");
11007
- logger23.info({ req }, "request");
11018
+ logger22.info({ validatedContext }, "Validated context");
11019
+ logger22.info({ req }, "request");
11008
11020
  if (isInitRequest) {
11009
11021
  return await handleInitializationRequest(
11010
11022
  body,
@@ -11026,7 +11038,7 @@ app4.openapi(
11026
11038
  );
11027
11039
  }
11028
11040
  } catch (e) {
11029
- logger23.error(
11041
+ logger22.error(
11030
11042
  {
11031
11043
  error: e instanceof Error ? e.message : e,
11032
11044
  stack: e instanceof Error ? e.stack : void 0
@@ -11038,7 +11050,7 @@ app4.openapi(
11038
11050
  }
11039
11051
  );
11040
11052
  app4.get("/", async (c) => {
11041
- logger23.info({}, "Received GET MCP request");
11053
+ logger22.info({}, "Received GET MCP request");
11042
11054
  return c.json(
11043
11055
  {
11044
11056
  jsonrpc: "2.0",
@@ -11052,7 +11064,7 @@ app4.get("/", async (c) => {
11052
11064
  );
11053
11065
  });
11054
11066
  app4.delete("/", async (c) => {
11055
- logger23.info({}, "Received DELETE MCP request");
11067
+ logger22.info({}, "Received DELETE MCP request");
11056
11068
  return c.json(
11057
11069
  {
11058
11070
  jsonrpc: "2.0",
@@ -11065,14 +11077,17 @@ app4.delete("/", async (c) => {
11065
11077
  var mcp_default = app4;
11066
11078
 
11067
11079
  // src/app.ts
11068
- var logger24 = getLogger("agents-run-api");
11069
- function createExecutionHono(serverConfig, credentialStores) {
11080
+ var logger23 = getLogger("agents-run-api");
11081
+ function createExecutionHono(serverConfig, credentialStores, sandboxConfig) {
11070
11082
  const app6 = new OpenAPIHono();
11071
11083
  app6.use("*", otel());
11072
11084
  app6.use("*", requestId());
11073
11085
  app6.use("*", async (c, next) => {
11074
11086
  c.set("serverConfig", serverConfig);
11075
11087
  c.set("credentialStores", credentialStores);
11088
+ if (sandboxConfig) {
11089
+ c.set("sandboxConfig", sandboxConfig);
11090
+ }
11076
11091
  return next();
11077
11092
  });
11078
11093
  app6.use("*", async (c, next) => {
@@ -11081,7 +11096,7 @@ function createExecutionHono(serverConfig, credentialStores) {
11081
11096
  const body = await c.req.json();
11082
11097
  c.set("requestBody", body);
11083
11098
  } catch (error) {
11084
- logger24.debug({ error }, "Failed to parse JSON body, continuing without parsed body");
11099
+ logger23.debug({ error }, "Failed to parse JSON body, continuing without parsed body");
11085
11100
  }
11086
11101
  }
11087
11102
  return next();
@@ -11132,8 +11147,8 @@ function createExecutionHono(serverConfig, credentialStores) {
11132
11147
  if (!isExpectedError) {
11133
11148
  const errorMessage = err instanceof Error ? err.message : String(err);
11134
11149
  const errorStack = err instanceof Error ? err.stack : void 0;
11135
- if (logger24) {
11136
- logger24.error(
11150
+ if (logger23) {
11151
+ logger23.error(
11137
11152
  {
11138
11153
  error: err,
11139
11154
  message: errorMessage,
@@ -11145,8 +11160,8 @@ function createExecutionHono(serverConfig, credentialStores) {
11145
11160
  );
11146
11161
  }
11147
11162
  } else {
11148
- if (logger24) {
11149
- logger24.error(
11163
+ if (logger23) {
11164
+ logger23.error(
11150
11165
  {
11151
11166
  error: err,
11152
11167
  path: c.req.path,
@@ -11163,8 +11178,8 @@ function createExecutionHono(serverConfig, credentialStores) {
11163
11178
  const response = err.getResponse();
11164
11179
  return response;
11165
11180
  } catch (responseError) {
11166
- if (logger24) {
11167
- logger24.error({ error: responseError }, "Error while handling HTTPException response");
11181
+ if (logger23) {
11182
+ logger23.error({ error: responseError }, "Error while handling HTTPException response");
11168
11183
  }
11169
11184
  }
11170
11185
  }
@@ -11198,7 +11213,7 @@ function createExecutionHono(serverConfig, credentialStores) {
11198
11213
  app6.use("*", async (c, next) => {
11199
11214
  const executionContext = c.get("executionContext");
11200
11215
  if (!executionContext) {
11201
- logger24.debug({}, "Empty execution context");
11216
+ logger23.debug({}, "Empty execution context");
11202
11217
  return next();
11203
11218
  }
11204
11219
  const { tenantId, projectId, agentId } = executionContext;
@@ -11207,7 +11222,7 @@ function createExecutionHono(serverConfig, credentialStores) {
11207
11222
  if (requestBody) {
11208
11223
  conversationId = requestBody.conversationId;
11209
11224
  if (!conversationId) {
11210
- logger24.debug({ requestBody }, "No conversation ID found in request body");
11225
+ logger23.debug({ requestBody }, "No conversation ID found in request body");
11211
11226
  }
11212
11227
  }
11213
11228
  const entries = Object.fromEntries(
@@ -11222,7 +11237,7 @@ function createExecutionHono(serverConfig, credentialStores) {
11222
11237
  })
11223
11238
  );
11224
11239
  if (!Object.keys(entries).length) {
11225
- logger24.debug({}, "Empty entries for baggage");
11240
+ logger23.debug({}, "Empty entries for baggage");
11226
11241
  return next();
11227
11242
  }
11228
11243
  const bag = Object.entries(entries).reduce(
@@ -11293,7 +11308,7 @@ function createExecutionApp(config) {
11293
11308
  const serverConfig = config?.serverConfig ?? defaultConfig;
11294
11309
  const stores = config?.credentialStores ?? defaultStores;
11295
11310
  const registry = new CredentialStoreRegistry(stores);
11296
- return createExecutionHono(serverConfig, registry);
11311
+ return createExecutionHono(serverConfig, registry, config?.sandboxConfig);
11297
11312
  }
11298
11313
 
11299
11314
  export { createExecutionApp, createExecutionHono, index_default as default };