@inkeep/agents-run-api 0.31.7 → 0.32.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,10 +1,11 @@
1
- import { flushBatchProcessor } from './chunk-DWEFKQTA.js';
2
- import { getFormattedConversationHistory, createDefaultConversationHistoryConfig, saveA2AMessageResponse } from './chunk-IMJLQGAX.js';
3
- import { dbClient_default } from './chunk-TRNLEUK2.js';
4
- import { env } from './chunk-Z4TYO3W3.js';
1
+ import { flushBatchProcessor } from './chunk-YBBSNUL3.js';
2
+ import { getFormattedConversationHistory, createDefaultConversationHistoryConfig, saveA2AMessageResponse } from './chunk-54Z7AOV4.js';
3
+ import { dbClient_default } from './chunk-BYF2SHLS.js';
4
+ import { env } from './chunk-N2FZD53W.js';
5
5
  import { getLogger } from './chunk-A2S7GSHL.js';
6
+ import { STREAM_PARSER_MAX_SNAPSHOT_SIZE, STREAM_PARSER_MAX_STREAMED_SIZE, STREAM_PARSER_MAX_COLLECTED_PARTS, STREAM_BUFFER_MAX_SIZE_BYTES, SESSION_CLEANUP_INTERVAL_MS, STREAM_MAX_LIFETIME_MS, STREAM_TEXT_GAP_THRESHOLD_MS, AGENT_EXECUTION_MAX_CONSECUTIVE_ERRORS, SESSION_TOOL_RESULT_CACHE_TIMEOUT_MS, ARTIFACT_GENERATION_MAX_RETRIES, ARTIFACT_SESSION_MAX_PENDING, STATUS_UPDATE_DEFAULT_INTERVAL_SECONDS, STATUS_UPDATE_DEFAULT_NUM_EVENTS, ARTIFACT_SESSION_MAX_PREVIOUS_SUMMARIES, ARTIFACT_GENERATION_BACKOFF_INITIAL_MS, ARTIFACT_GENERATION_BACKOFF_MAX_MS, AGENT_EXECUTION_MAX_GENERATION_STEPS, FUNCTION_TOOL_SANDBOX_VCPUS_DEFAULT, FUNCTION_TOOL_EXECUTION_TIMEOUT_MS_DEFAULT, LLM_GENERATION_MAX_ALLOWED_TIMEOUT_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 } from './chunk-IVALDC72.js';
6
7
  import { __publicField } from './chunk-PKBMQBKP.js';
7
- import { getTracer, HeadersScopeSchema, getRequestExecutionContext, createApiError, getAgentWithDefaultSubAgent, contextValidationMiddleware, getConversationId, getFullAgent, createOrGetConversation, getActiveAgentForConversation, setActiveAgentForConversation, getSubAgentById, handleContextResolution, createMessage, generateId, commonGetErrorResponses, loggerFactory, createDefaultCredentialStores, CredentialStoreRegistry, listTaskIdsByContextId, getTask, getLedgerArtifacts, upsertLedgerArtifact, createTask, updateTask, setSpanWithError, updateConversation, handleApiError, TaskState, setActiveAgentForThread, getConversation, getAgentById, getRelatedAgentsForAgent, getExternalAgentsForSubAgent, getTeamAgentsForSubAgent, getToolsForAgent, getDataComponentsForAgent, getArtifactComponentsForAgent, dbResultToMcpTool, validateAndGetApiKey, verifyServiceToken, validateTargetAgent, getProject, ContextResolver, CredentialStuffer, MCPServerType, getCredentialReference, McpClient, getFunctionToolsForSubAgent, getFunction, getContextConfigById, getFullAgentDefinition, TemplateEngine, agentHasArtifactComponents, MCPTransportType, SPAN_KEYS, headers, generateServiceToken } from '@inkeep/agents-core';
8
+ import { getTracer, HeadersScopeSchema, getRequestExecutionContext, createApiError, getAgentWithDefaultSubAgent, contextValidationMiddleware, getConversationId, getFullAgent, createOrGetConversation, getActiveAgentForConversation, setActiveAgentForConversation, getSubAgentById, handleContextResolution, createMessage, generateId, commonGetErrorResponses, loggerFactory, createDefaultCredentialStores, CredentialStoreRegistry, listTaskIdsByContextId, getTask, getLedgerArtifacts, upsertLedgerArtifact, createTask, updateTask, setSpanWithError, AGENT_EXECUTION_TRANSFER_COUNT_DEFAULT, updateConversation, handleApiError, CONVERSATION_HISTORY_MAX_OUTPUT_TOKENS_DEFAULT, CONVERSATION_HISTORY_DEFAULT_LIMIT, TaskState, setActiveAgentForThread, getConversation, getAgentById, getRelatedAgentsForAgent, getExternalAgentsForSubAgent, getTeamAgentsForSubAgent, getToolsForAgent, getDataComponentsForAgent, getArtifactComponentsForAgent, dbResultToMcpTool, validateAndGetApiKey, verifyServiceToken, validateTargetAgent, getProject, ContextResolver, CredentialStuffer, MCPServerType, getCredentialReference, McpClient, getFunctionToolsForSubAgent, getFunction, getContextConfigById, getFullAgentDefinition, TemplateEngine, agentHasArtifactComponents, MCPTransportType, SPAN_KEYS, headers, generateServiceToken } from '@inkeep/agents-core';
8
9
  import { otel } from '@hono/otel';
9
10
  import { OpenAPIHono, createRoute, z as z$1 } from '@hono/zod-openapi';
10
11
  import { trace, propagation, context, SpanStatusCode } from '@opentelemetry/api';
@@ -1120,11 +1121,9 @@ __publicField(_ModelFactory, "BUILT_IN_PROVIDERS", [
1120
1121
  var ModelFactory = _ModelFactory;
1121
1122
  var logger4 = getLogger("ToolSessionManager");
1122
1123
  var _ToolSessionManager = class _ToolSessionManager {
1123
- // 5 minutes
1124
1124
  constructor() {
1125
1125
  __publicField(this, "sessions", /* @__PURE__ */ new Map());
1126
- __publicField(this, "SESSION_TIMEOUT", 5 * 60 * 1e3);
1127
- setInterval(() => this.cleanupExpiredSessions(), 6e4);
1126
+ setInterval(() => this.cleanupExpiredSessions(), SESSION_CLEANUP_INTERVAL_MS);
1128
1127
  }
1129
1128
  static getInstance() {
1130
1129
  if (!_ToolSessionManager.instance) {
@@ -1269,7 +1268,7 @@ var _ToolSessionManager = class _ToolSessionManager {
1269
1268
  const now = Date.now();
1270
1269
  const expiredSessions = [];
1271
1270
  for (const [sessionId, session] of this.sessions.entries()) {
1272
- if (now - session.createdAt > this.SESSION_TIMEOUT) {
1271
+ if (now - session.createdAt > SESSION_TOOL_RESULT_CACHE_TIMEOUT_MS) {
1273
1272
  expiredSessions.push(sessionId);
1274
1273
  }
1275
1274
  }
@@ -2441,8 +2440,8 @@ var AgentSession = class {
2441
2440
  // Track pending artifact processing
2442
2441
  __publicField(this, "artifactProcessingErrors", /* @__PURE__ */ new Map());
2443
2442
  // Track errors per artifact
2444
- __publicField(this, "MAX_ARTIFACT_RETRIES", 3);
2445
- __publicField(this, "MAX_PENDING_ARTIFACTS", 100);
2443
+ __publicField(this, "MAX_ARTIFACT_RETRIES", ARTIFACT_GENERATION_MAX_RETRIES);
2444
+ __publicField(this, "MAX_PENDING_ARTIFACTS", ARTIFACT_SESSION_MAX_PENDING);
2446
2445
  // Prevent unbounded growth
2447
2446
  __publicField(this, "scheduledTimeouts");
2448
2447
  // Track scheduled timeouts for cleanup
@@ -2562,8 +2561,8 @@ var AgentSession = class {
2562
2561
  summarizerModel,
2563
2562
  baseModel,
2564
2563
  config: {
2565
- numEvents: config.numEvents || 1,
2566
- timeInSeconds: config.timeInSeconds || 2,
2564
+ numEvents: config.numEvents || STATUS_UPDATE_DEFAULT_NUM_EVENTS,
2565
+ timeInSeconds: config.timeInSeconds || STATUS_UPDATE_DEFAULT_INTERVAL_SECONDS,
2567
2566
  ...config
2568
2567
  }
2569
2568
  };
@@ -2906,7 +2905,7 @@ var AgentSession = class {
2906
2905
  }
2907
2906
  return;
2908
2907
  }
2909
- if (this.previousSummaries.length > 3) {
2908
+ if (this.previousSummaries.length > ARTIFACT_SESSION_MAX_PREVIOUS_SUMMARIES) {
2910
2909
  this.previousSummaries.shift();
2911
2910
  }
2912
2911
  if (this.statusUpdateState) {
@@ -3019,9 +3018,8 @@ var AgentSession = class {
3019
3018
  projectId: this.projectId,
3020
3019
  conversationId: this.sessionId,
3021
3020
  options: {
3022
- limit: 10,
3023
- // Get recent conversation context
3024
- maxOutputTokens: 2e3
3021
+ limit: CONVERSATION_HISTORY_DEFAULT_LIMIT,
3022
+ maxOutputTokens: CONVERSATION_HISTORY_MAX_OUTPUT_TOKENS_DEFAULT
3025
3023
  },
3026
3024
  filters: {}
3027
3025
  });
@@ -3550,7 +3548,10 @@ Make it specific and relevant.`;
3550
3548
  `Artifact name/description generation failed, attempt ${attempt}/${maxRetries}`
3551
3549
  );
3552
3550
  if (attempt < maxRetries) {
3553
- const backoffMs = Math.min(1e3 * 2 ** (attempt - 1), 1e4);
3551
+ const backoffMs = Math.min(
3552
+ ARTIFACT_GENERATION_BACKOFF_INITIAL_MS * 2 ** (attempt - 1),
3553
+ ARTIFACT_GENERATION_BACKOFF_MAX_MS
3554
+ );
3554
3555
  await new Promise((resolve) => setTimeout(resolve, backoffMs));
3555
3556
  }
3556
3557
  }
@@ -4258,11 +4259,11 @@ ${chunk}`;
4258
4259
  }
4259
4260
  }
4260
4261
  };
4261
- __publicField(_IncrementalStreamParser, "MAX_SNAPSHOT_SIZE", 100);
4262
+ __publicField(_IncrementalStreamParser, "MAX_SNAPSHOT_SIZE", STREAM_PARSER_MAX_SNAPSHOT_SIZE);
4262
4263
  // Max number of snapshots to keep
4263
- __publicField(_IncrementalStreamParser, "MAX_STREAMED_SIZE", 1e3);
4264
+ __publicField(_IncrementalStreamParser, "MAX_STREAMED_SIZE", STREAM_PARSER_MAX_STREAMED_SIZE);
4264
4265
  // Max number of streamed component IDs to track
4265
- __publicField(_IncrementalStreamParser, "MAX_COLLECTED_PARTS", 1e4);
4266
+ __publicField(_IncrementalStreamParser, "MAX_COLLECTED_PARTS", STREAM_PARSER_MAX_COLLECTED_PARTS);
4266
4267
  var IncrementalStreamParser = _IncrementalStreamParser;
4267
4268
 
4268
4269
  // src/services/ResponseFormatter.ts
@@ -5467,6 +5468,7 @@ var A2AClient = class {
5467
5468
 
5468
5469
  // src/agents/relationTools.ts
5469
5470
  var logger13 = getLogger("relationships Tools");
5471
+ var A2A_RETRY_STATUS_CODES = ["429", "500", "502", "503", "504"];
5470
5472
  var generateTransferToolDescription = (config) => {
5471
5473
  let toolsSection = "";
5472
5474
  let transferSection = "";
@@ -5719,13 +5721,12 @@ function createDelegateToAgentTool({
5719
5721
  retryConfig: {
5720
5722
  strategy: "backoff",
5721
5723
  retryConnectionErrors: true,
5722
- statusCodes: ["429", "500", "502", "503", "504"],
5724
+ statusCodes: [...A2A_RETRY_STATUS_CODES],
5723
5725
  backoff: {
5724
- initialInterval: 100,
5725
- maxInterval: 1e4,
5726
- exponent: 2,
5727
- maxElapsedTime: 2e4
5728
- // 1 minute max retry time
5726
+ initialInterval: DELEGATION_TOOL_BACKOFF_INITIAL_INTERVAL_MS,
5727
+ maxInterval: DELEGATION_TOOL_BACKOFF_MAX_INTERVAL_MS,
5728
+ exponent: DELEGATION_TOOL_BACKOFF_EXPONENT,
5729
+ maxElapsedTime: DELEGATION_TOOL_BACKOFF_MAX_ELAPSED_TIME_MS
5729
5730
  }
5730
5731
  }
5731
5732
  });
@@ -6898,12 +6899,6 @@ function hasToolCallWithPrefix(prefix) {
6898
6899
  };
6899
6900
  }
6900
6901
  var logger15 = getLogger("Agent");
6901
- var CONSTANTS = {
6902
- MAX_GENERATION_STEPS: 12,
6903
- PHASE_1_TIMEOUT_MS: 27e4,
6904
- NON_STREAMING_PHASE_1_TIMEOUT_MS: 9e4,
6905
- PHASE_2_TIMEOUT_MS: 9e4
6906
- };
6907
6902
  function validateModel(modelString, modelType) {
6908
6903
  if (!modelString?.trim()) {
6909
6904
  throw new Error(
@@ -6972,10 +6967,10 @@ var Agent = class {
6972
6967
  }
6973
6968
  /**
6974
6969
  * Get the maximum number of generation steps for this agent
6975
- * Uses agent's stopWhen.stepCountIs config or defaults to CONSTANTS.MAX_GENERATION_STEPS
6970
+ * Uses agent's stopWhen.stepCountIs config or defaults to AGENT_EXECUTION_MAX_GENERATION_STEPS
6976
6971
  */
6977
6972
  getMaxGenerationSteps() {
6978
- return this.config.stopWhen?.stepCountIs ?? CONSTANTS.MAX_GENERATION_STEPS;
6973
+ return this.config.stopWhen?.stepCountIs ?? AGENT_EXECUTION_MAX_GENERATION_STEPS;
6979
6974
  }
6980
6975
  /**
6981
6976
  * Sanitizes tool names at runtime for AI SDK compatibility.
@@ -7493,7 +7488,7 @@ var Agent = class {
7493
7488
  if (functionToolsData.length === 0) {
7494
7489
  return functionTools;
7495
7490
  }
7496
- const { SandboxExecutorFactory } = await import('./SandboxExecutorFactory-QVNCS6YN.js');
7491
+ const { SandboxExecutorFactory } = await import('./SandboxExecutorFactory-D3OSN652.js');
7497
7492
  const sandboxExecutor = SandboxExecutorFactory.getInstance();
7498
7493
  for (const functionToolDef of functionToolsData) {
7499
7494
  const functionId = functionToolDef.functionId;
@@ -7531,8 +7526,8 @@ var Agent = class {
7531
7526
  const defaultSandboxConfig = {
7532
7527
  provider: "native",
7533
7528
  runtime: "node22",
7534
- timeout: 3e4,
7535
- vcpus: 4
7529
+ timeout: FUNCTION_TOOL_EXECUTION_TIMEOUT_MS_DEFAULT,
7530
+ vcpus: FUNCTION_TOOL_SANDBOX_VCPUS_DEFAULT
7536
7531
  };
7537
7532
  const result = await sandboxExecutor.executeFunctionTool(functionToolDef.id, args, {
7538
7533
  description: functionToolDef.description || functionToolDef.name,
@@ -7787,7 +7782,7 @@ var Agent = class {
7787
7782
  inputSchema: tool3.inputSchema || tool3.parameters || {},
7788
7783
  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."
7789
7784
  }));
7790
- const { getConversationScopedArtifacts } = await import('./conversations-V6DNH5MW.js');
7785
+ const { getConversationScopedArtifacts } = await import('./conversations-ZZI6XV2G.js');
7791
7786
  const historyConfig = this.config.conversationHistoryConfig ?? createDefaultConversationHistoryConfig();
7792
7787
  const referenceArtifacts = await getConversationScopedArtifacts({
7793
7788
  tenantId: this.config.tenantId,
@@ -8221,15 +8216,14 @@ var Agent = class {
8221
8216
  let textResponse;
8222
8217
  const hasStructuredOutput = this.config.dataComponents && this.config.dataComponents.length > 0;
8223
8218
  const shouldStreamPhase1 = this.getStreamingHelper() && !hasStructuredOutput;
8224
- const MAX_ALLOWED_TIMEOUT_MS = 6e5;
8225
- 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;
8226
- const timeoutMs = Math.min(configuredTimeout, MAX_ALLOWED_TIMEOUT_MS);
8227
- if (modelSettings.maxDuration && modelSettings.maxDuration * 1e3 > MAX_ALLOWED_TIMEOUT_MS) {
8219
+ 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;
8220
+ const timeoutMs = Math.min(configuredTimeout, LLM_GENERATION_MAX_ALLOWED_TIMEOUT_MS);
8221
+ if (modelSettings.maxDuration && modelSettings.maxDuration * 1e3 > LLM_GENERATION_MAX_ALLOWED_TIMEOUT_MS) {
8228
8222
  logger15.warn(
8229
8223
  {
8230
8224
  requestedTimeout: modelSettings.maxDuration * 1e3,
8231
8225
  appliedTimeout: timeoutMs,
8232
- maxAllowed: MAX_ALLOWED_TIMEOUT_MS
8226
+ maxAllowed: LLM_GENERATION_MAX_ALLOWED_TIMEOUT_MS
8233
8227
  },
8234
8228
  "Requested timeout exceeded maximum allowed, capping to 10 minutes"
8235
8229
  );
@@ -8531,7 +8525,25 @@ ${output}${structureHintsFormatted}`;
8531
8525
  const structuredModelSettings = ModelFactory.prepareGenerationConfig(
8532
8526
  this.getStructuredOutputModel()
8533
8527
  );
8534
- const phase2TimeoutMs = structuredModelSettings.maxDuration ? structuredModelSettings.maxDuration * 1e3 : CONSTANTS.PHASE_2_TIMEOUT_MS;
8528
+ const configuredPhase2Timeout = structuredModelSettings.maxDuration ? Math.min(
8529
+ structuredModelSettings.maxDuration * 1e3,
8530
+ LLM_GENERATION_MAX_ALLOWED_TIMEOUT_MS
8531
+ ) : LLM_GENERATION_SUBSEQUENT_CALL_TIMEOUT_MS;
8532
+ const phase2TimeoutMs = Math.min(
8533
+ configuredPhase2Timeout,
8534
+ LLM_GENERATION_MAX_ALLOWED_TIMEOUT_MS
8535
+ );
8536
+ if (structuredModelSettings.maxDuration && structuredModelSettings.maxDuration * 1e3 > LLM_GENERATION_MAX_ALLOWED_TIMEOUT_MS) {
8537
+ logger15.warn(
8538
+ {
8539
+ requestedTimeout: structuredModelSettings.maxDuration * 1e3,
8540
+ appliedTimeout: phase2TimeoutMs,
8541
+ maxAllowed: LLM_GENERATION_MAX_ALLOWED_TIMEOUT_MS,
8542
+ phase: "structured_generation"
8543
+ },
8544
+ "Phase 2 requested timeout exceeded maximum allowed, capping to 10 minutes"
8545
+ );
8546
+ }
8535
8547
  const shouldStreamPhase2 = this.getStreamingHelper();
8536
8548
  if (shouldStreamPhase2) {
8537
8549
  const phase2Messages = [
@@ -9865,7 +9877,6 @@ function createSSEStreamHelper(stream2, requestId2, timestamp) {
9865
9877
  return new SSEStreamHelper(stream2, requestId2, timestamp);
9866
9878
  }
9867
9879
  var _VercelDataStreamHelper = class _VercelDataStreamHelper {
9868
- // 10 minutes max lifetime
9869
9880
  constructor(writer) {
9870
9881
  this.writer = writer;
9871
9882
  __publicField(this, "textId", null);
@@ -9875,18 +9886,14 @@ var _VercelDataStreamHelper = class _VercelDataStreamHelper {
9875
9886
  __publicField(this, "completedItems", /* @__PURE__ */ new Set());
9876
9887
  // Track completed items
9877
9888
  __publicField(this, "sessionId");
9878
- // 5MB limit (more generous during request)
9879
9889
  __publicField(this, "isCompleted", false);
9880
9890
  __publicField(this, "isTextStreaming", false);
9881
9891
  __publicField(this, "queuedEvents", []);
9882
9892
  __publicField(this, "lastTextEndTimestamp", 0);
9883
- __publicField(this, "TEXT_GAP_THRESHOLD", 2e3);
9884
- // milliseconds - if gap between text sequences is less than this, queue operations
9885
9893
  __publicField(this, "connectionDropTimer");
9886
- __publicField(this, "MAX_LIFETIME_MS", 6e5);
9887
9894
  this.connectionDropTimer = setTimeout(() => {
9888
9895
  this.forceCleanup("Connection lifetime exceeded");
9889
- }, this.MAX_LIFETIME_MS);
9896
+ }, STREAM_MAX_LIFETIME_MS);
9890
9897
  }
9891
9898
  setSessionId(sessionId) {
9892
9899
  this.sessionId = sessionId;
@@ -9940,7 +9947,7 @@ var _VercelDataStreamHelper = class _VercelDataStreamHelper {
9940
9947
  const id = this.textId;
9941
9948
  const startTime = Date.now();
9942
9949
  const gapFromLastSequence = this.lastTextEndTimestamp > 0 ? startTime - this.lastTextEndTimestamp : Number.MAX_SAFE_INTEGER;
9943
- if (gapFromLastSequence >= this.TEXT_GAP_THRESHOLD) {
9950
+ if (gapFromLastSequence >= STREAM_TEXT_GAP_THRESHOLD_MS) {
9944
9951
  await this.flushQueuedOperations();
9945
9952
  }
9946
9953
  this.isTextStreaming = true;
@@ -9974,7 +9981,7 @@ var _VercelDataStreamHelper = class _VercelDataStreamHelper {
9974
9981
  if (type === "data-artifact") {
9975
9982
  const now = Date.now();
9976
9983
  const gapFromLastTextEnd = this.lastTextEndTimestamp > 0 ? now - this.lastTextEndTimestamp : Number.MAX_SAFE_INTEGER;
9977
- if (this.isTextStreaming || gapFromLastTextEnd < this.TEXT_GAP_THRESHOLD) {
9984
+ if (this.isTextStreaming || gapFromLastTextEnd < STREAM_TEXT_GAP_THRESHOLD_MS) {
9978
9985
  this.writer.write({
9979
9986
  type: `${type}`,
9980
9987
  data
@@ -10127,7 +10134,7 @@ var _VercelDataStreamHelper = class _VercelDataStreamHelper {
10127
10134
  }
10128
10135
  const now = Date.now();
10129
10136
  const gapFromLastTextEnd = this.lastTextEndTimestamp > 0 ? now - this.lastTextEndTimestamp : Number.MAX_SAFE_INTEGER;
10130
- if (this.isTextStreaming || gapFromLastTextEnd < this.TEXT_GAP_THRESHOLD) {
10137
+ if (this.isTextStreaming || gapFromLastTextEnd < STREAM_TEXT_GAP_THRESHOLD_MS) {
10131
10138
  this.queuedEvents.push({ type: "data-summary", event: summary });
10132
10139
  return;
10133
10140
  }
@@ -10145,7 +10152,7 @@ var _VercelDataStreamHelper = class _VercelDataStreamHelper {
10145
10152
  }
10146
10153
  const now = Date.now();
10147
10154
  const gapFromLastTextEnd = this.lastTextEndTimestamp > 0 ? now - this.lastTextEndTimestamp : Number.MAX_SAFE_INTEGER;
10148
- if (this.isTextStreaming || gapFromLastTextEnd < this.TEXT_GAP_THRESHOLD) {
10155
+ if (this.isTextStreaming || gapFromLastTextEnd < STREAM_TEXT_GAP_THRESHOLD_MS) {
10149
10156
  this.queuedEvents.push({ type: "data-operation", event: operation });
10150
10157
  return;
10151
10158
  }
@@ -10188,7 +10195,7 @@ var _VercelDataStreamHelper = class _VercelDataStreamHelper {
10188
10195
  this.cleanup();
10189
10196
  }
10190
10197
  };
10191
- __publicField(_VercelDataStreamHelper, "MAX_BUFFER_SIZE", 5 * 1024 * 1024);
10198
+ __publicField(_VercelDataStreamHelper, "MAX_BUFFER_SIZE", STREAM_BUFFER_MAX_SIZE_BYTES);
10192
10199
  var VercelDataStreamHelper = _VercelDataStreamHelper;
10193
10200
  function createVercelStreamHelper(writer) {
10194
10201
  return new VercelDataStreamHelper(writer);
@@ -10260,7 +10267,7 @@ var createMCPStreamHelper = createBufferingStreamHelper;
10260
10267
  var logger20 = getLogger("ExecutionHandler");
10261
10268
  var ExecutionHandler = class {
10262
10269
  constructor() {
10263
- __publicField(this, "MAX_ERRORS", 3);
10270
+ __publicField(this, "MAX_ERRORS", AGENT_EXECUTION_MAX_CONSECUTIVE_ERRORS);
10264
10271
  }
10265
10272
  /**
10266
10273
  * performs exeuction loop
@@ -10357,7 +10364,7 @@ var ExecutionHandler = class {
10357
10364
  "Task created with metadata"
10358
10365
  );
10359
10366
  } catch (error) {
10360
- if (error?.message?.includes("UNIQUE constraint failed") || error?.message?.includes("PRIMARY KEY constraint failed") || error?.code === "SQLITE_CONSTRAINT_PRIMARYKEY") {
10367
+ if (error?.cause?.code === "23505") {
10361
10368
  logger20.info(
10362
10369
  { taskId, error: error.message },
10363
10370
  "Task already exists, fetching existing task"
@@ -10380,7 +10387,7 @@ var ExecutionHandler = class {
10380
10387
  }
10381
10388
  logger20.debug(
10382
10389
  {
10383
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
10390
+ timestamp: /* @__PURE__ */ new Date(),
10384
10391
  executionType: "create_initial_task",
10385
10392
  conversationId,
10386
10393
  agentId,
@@ -10394,7 +10401,7 @@ var ExecutionHandler = class {
10394
10401
  );
10395
10402
  if (Array.isArray(task)) task = task[0];
10396
10403
  let currentMessage = userMessage;
10397
- const maxTransfers = agentConfig?.stopWhen?.transferCountIs ?? 10;
10404
+ const maxTransfers = agentConfig?.stopWhen?.transferCountIs ?? AGENT_EXECUTION_TRANSFER_COUNT_DEFAULT;
10398
10405
  while (iterations < maxTransfers) {
10399
10406
  iterations++;
10400
10407
  logger20.info(
@@ -10593,7 +10600,7 @@ var ExecutionHandler = class {
10593
10600
  status: "completed",
10594
10601
  metadata: {
10595
10602
  ...task.metadata,
10596
- completed_at: (/* @__PURE__ */ new Date()).toISOString(),
10603
+ completed_at: /* @__PURE__ */ new Date(),
10597
10604
  response: {
10598
10605
  text: textContent,
10599
10606
  parts: responseParts,
@@ -10645,7 +10652,7 @@ var ExecutionHandler = class {
10645
10652
  status: "failed",
10646
10653
  metadata: {
10647
10654
  ...task.metadata,
10648
- failed_at: (/* @__PURE__ */ new Date()).toISOString(),
10655
+ failed_at: /* @__PURE__ */ new Date(),
10649
10656
  error: errorMessage2
10650
10657
  }
10651
10658
  }
@@ -10666,7 +10673,7 @@ var ExecutionHandler = class {
10666
10673
  status: "failed",
10667
10674
  metadata: {
10668
10675
  ...task.metadata,
10669
- failed_at: (/* @__PURE__ */ new Date()).toISOString(),
10676
+ failed_at: /* @__PURE__ */ new Date(),
10670
10677
  error: errorMessage
10671
10678
  }
10672
10679
  }
@@ -10688,7 +10695,7 @@ var ExecutionHandler = class {
10688
10695
  status: "failed",
10689
10696
  metadata: {
10690
10697
  ...task.metadata,
10691
- failed_at: (/* @__PURE__ */ new Date()).toISOString(),
10698
+ failed_at: /* @__PURE__ */ new Date(),
10692
10699
  error: errorMessage
10693
10700
  }
10694
10701
  }
@@ -17,9 +17,7 @@ agentsCore.loadEnvironmentFiles();
17
17
  var envSchema = zod.z.object({
18
18
  NODE_ENV: zod.z.enum(["development", "production", "test"]).optional(),
19
19
  ENVIRONMENT: zod.z.enum(["development", "production", "pentest", "test"]).optional().default("development"),
20
- DB_FILE_NAME: zod.z.string().optional(),
21
- TURSO_DATABASE_URL: zod.z.string().optional(),
22
- TURSO_AUTH_TOKEN: zod.z.string().optional(),
20
+ DATABASE_URL: zod.z.string().optional(),
23
21
  AGENTS_RUN_API_URL: zod.z.string().optional().default("http://localhost:3003"),
24
22
  LOG_LEVEL: zod.z.enum(["trace", "debug", "info", "warn", "error"]).optional().default("debug"),
25
23
  NANGO_SERVER_URL: zod.z.string().optional().default("https://api.nango.dev"),
@@ -1 +1 @@
1
- export { defaultBatchProcessor, defaultContextManager, defaultInstrumentations, defaultResource, defaultSDK, defaultSpanProcessors, defaultTextMapPropagator, flushBatchProcessor } from './chunk-DWEFKQTA.js';
1
+ export { defaultBatchProcessor, defaultContextManager, defaultInstrumentations, defaultResource, defaultSDK, defaultSpanProcessors, defaultTextMapPropagator, flushBatchProcessor } from './chunk-YBBSNUL3.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inkeep/agents-run-api",
3
- "version": "0.31.7",
3
+ "version": "0.32.1",
4
4
  "description": "Agents Run API for Inkeep Agent Framework - handles chat, agent execution, and streaming",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -45,7 +45,7 @@
45
45
  "drizzle-orm": "^0.44.4",
46
46
  "exit-hook": "^4.0.0",
47
47
  "fetch-to-node": "^2.1.0",
48
- "hono": "^4.10.3",
48
+ "hono": "^4.10.4",
49
49
  "jmespath": "^0.16.0",
50
50
  "json-schema-to-zod": "^2.6.1",
51
51
  "nanoid": "^5.1.5",
@@ -53,7 +53,7 @@
53
53
  "traverse": "^0.6.11",
54
54
  "ts-pattern": "^5.7.1",
55
55
  "zod": "4.1.5",
56
- "@inkeep/agents-core": "^0.31.7"
56
+ "@inkeep/agents-core": "^0.32.1"
57
57
  },
58
58
  "optionalDependencies": {
59
59
  "keytar": "^7.9.0"
@@ -72,7 +72,8 @@
72
72
  "typescript": "^5.3.3",
73
73
  "vite": "^7.1.11",
74
74
  "vite-tsconfig-paths": "^5.1.4",
75
- "vitest": "^3.2.4"
75
+ "vitest": "^3.2.4",
76
+ "@electric-sql/pglite": "^0.3.13"
76
77
  },
77
78
  "engines": {
78
79
  "node": ">=22.0.0"
@@ -1,26 +0,0 @@
1
- import { env } from './chunk-Z4TYO3W3.js';
2
- import { createDatabaseClient } from '@inkeep/agents-core';
3
-
4
- var getDbConfig = () => {
5
- if (env.ENVIRONMENT === "test") {
6
- return { url: ":memory:" };
7
- }
8
- if (env.TURSO_DATABASE_URL && env.TURSO_AUTH_TOKEN) {
9
- return {
10
- url: env.TURSO_DATABASE_URL,
11
- authToken: env.TURSO_AUTH_TOKEN
12
- };
13
- }
14
- if (!env.DB_FILE_NAME) {
15
- throw new Error(
16
- "Database configuration error: DB_FILE_NAME must be set if Turso is not configured."
17
- );
18
- }
19
- return {
20
- url: env.DB_FILE_NAME
21
- };
22
- };
23
- var dbClient = createDatabaseClient(getDbConfig());
24
- var dbClient_default = dbClient;
25
-
26
- export { dbClient_default };
@@ -1 +0,0 @@
1
- export { dbClient_default as default } from './chunk-TRNLEUK2.js';