@inkeep/agents-run-api 0.34.1 → 0.35.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/{SandboxExecutorFactory-D3OSN652.js → SandboxExecutorFactory-NUNGK35F.js} +17 -21
- package/dist/{chunk-7GZGZNDA.js → chunk-7C3GUAQD.js} +4 -4
- package/dist/chunk-CWFQPSTI.js +5070 -0
- package/dist/chunk-SBJLXGYG.js +592 -0
- package/dist/{conversations-WAUHDR5J.js → conversations-ZCZG5434.js} +1 -1
- package/dist/dbClient-XO7KFTE7.js +1 -0
- package/dist/index.cjs +6752 -806
- package/dist/index.js +165 -181
- package/dist/nodefs-ZHXQGWPG.js +21 -0
- package/dist/opfs-ahp-CJXSQU3E.js +318 -0
- package/package.json +2 -2
- package/dist/chunk-4HDXSU6S.js +0 -13
- package/dist/chunk-PKBMQBKP.js +0 -5
- package/dist/dbClient-6HPZ2V7Y.js +0 -1
- /package/dist/{json-postprocessor-VOMU4E5L.js → json-postprocessor-IGYTSWFB.js} +0 -0
- /package/dist/{logger-6JGMWF6F.js → logger-3EE6BUSU.js} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { flushBatchProcessor } from './chunk-H2IQDFCM.js';
|
|
2
|
-
import { getFormattedConversationHistory, createDefaultConversationHistoryConfig, saveA2AMessageResponse } from './chunk-
|
|
3
|
-
import { dbClient_default } from './chunk-
|
|
2
|
+
import { getFormattedConversationHistory, createDefaultConversationHistoryConfig, saveA2AMessageResponse } from './chunk-7C3GUAQD.js';
|
|
3
|
+
import { dbClient_default } from './chunk-CWFQPSTI.js';
|
|
4
4
|
import { env } from './chunk-UZXC6MEO.js';
|
|
5
5
|
import { getLogger } from './chunk-A2S7GSHL.js';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
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, getAgentById, getProject, setActiveAgentForThread, getConversation, getRelatedAgentsForAgent, getExternalAgentsForSubAgent, getTeamAgentsForSubAgent, getToolsForAgent, getDataComponentsForAgent, getArtifactComponentsForAgent, dbResultToMcpTool, validateAndGetApiKey, verifyServiceToken, validateTargetAgent, ContextResolver, CredentialStuffer, MCPServerType, getCredentialReference, McpClient, getFunctionToolsForSubAgent, getFunction, getContextConfigById, getFullAgentDefinition, TemplateEngine, agentHasArtifactComponents, 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-IVALDC72.js';
|
|
7
|
+
import { getTracer, HeadersScopeSchema, getRequestExecutionContext, createApiError, getAgentWithDefaultSubAgent, contextValidationMiddleware, getConversationId, getFullAgent, createOrGetConversation, getActiveAgentForConversation, setActiveAgentForConversation, getSubAgentById, handleContextResolution, createMessage, generateId, commonGetErrorResponses, loggerFactory, createDefaultCredentialStores, CredentialStoreRegistry, createTask, getTask, updateTask, setSpanWithError, AGENT_EXECUTION_TRANSFER_COUNT_DEFAULT, updateConversation, handleApiError, TaskState, getAgentById, getProject, setActiveAgentForThread, getConversation, getRelatedAgentsForAgent, getExternalAgentsForSubAgent, getTeamAgentsForSubAgent, getToolsForAgent, getDataComponentsForAgent, getArtifactComponentsForAgent, dbResultToMcpTool, CONVERSATION_HISTORY_MAX_OUTPUT_TOKENS_DEFAULT, CONVERSATION_HISTORY_DEFAULT_LIMIT, 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';
|
|
9
8
|
import { otel } from '@hono/otel';
|
|
10
9
|
import { OpenAPIHono, createRoute, z as z$1 } from '@hono/zod-openapi';
|
|
11
10
|
import { trace, propagation, context, SpanStatusCode } from '@opentelemetry/api';
|
|
@@ -940,7 +939,7 @@ var nimDefault = createOpenAICompatible({
|
|
|
940
939
|
Authorization: `Bearer ${process.env.NIM_API_KEY}`
|
|
941
940
|
}
|
|
942
941
|
});
|
|
943
|
-
var
|
|
942
|
+
var ModelFactory = class _ModelFactory {
|
|
944
943
|
/**
|
|
945
944
|
* Create a provider instance with custom configuration
|
|
946
945
|
*/
|
|
@@ -1089,6 +1088,18 @@ var _ModelFactory = class _ModelFactory {
|
|
|
1089
1088
|
);
|
|
1090
1089
|
}
|
|
1091
1090
|
}
|
|
1091
|
+
/**
|
|
1092
|
+
* Built-in providers that have special handling
|
|
1093
|
+
*/
|
|
1094
|
+
static BUILT_IN_PROVIDERS = [
|
|
1095
|
+
"anthropic",
|
|
1096
|
+
"openai",
|
|
1097
|
+
"google",
|
|
1098
|
+
"openrouter",
|
|
1099
|
+
"gateway",
|
|
1100
|
+
"nim",
|
|
1101
|
+
"custom"
|
|
1102
|
+
];
|
|
1092
1103
|
/**
|
|
1093
1104
|
* Parse model string to extract provider and model name
|
|
1094
1105
|
* Examples: "anthropic/claude-sonnet-4" -> { provider: "anthropic", modelName: "claude-sonnet-4" }
|
|
@@ -1182,23 +1193,11 @@ var _ModelFactory = class _ModelFactory {
|
|
|
1182
1193
|
return errors;
|
|
1183
1194
|
}
|
|
1184
1195
|
};
|
|
1185
|
-
/**
|
|
1186
|
-
* Built-in providers that have special handling
|
|
1187
|
-
*/
|
|
1188
|
-
__publicField(_ModelFactory, "BUILT_IN_PROVIDERS", [
|
|
1189
|
-
"anthropic",
|
|
1190
|
-
"openai",
|
|
1191
|
-
"google",
|
|
1192
|
-
"openrouter",
|
|
1193
|
-
"gateway",
|
|
1194
|
-
"nim",
|
|
1195
|
-
"custom"
|
|
1196
|
-
]);
|
|
1197
|
-
var ModelFactory = _ModelFactory;
|
|
1198
1196
|
var logger4 = getLogger("ToolSessionManager");
|
|
1199
|
-
var
|
|
1197
|
+
var ToolSessionManager = class _ToolSessionManager {
|
|
1198
|
+
static instance;
|
|
1199
|
+
sessions = /* @__PURE__ */ new Map();
|
|
1200
1200
|
constructor() {
|
|
1201
|
-
__publicField(this, "sessions", /* @__PURE__ */ new Map());
|
|
1202
1201
|
setInterval(() => this.cleanupExpiredSessions(), SESSION_CLEANUP_INTERVAL_MS);
|
|
1203
1202
|
}
|
|
1204
1203
|
static getInstance() {
|
|
@@ -1357,8 +1356,6 @@ var _ToolSessionManager = class _ToolSessionManager {
|
|
|
1357
1356
|
}
|
|
1358
1357
|
}
|
|
1359
1358
|
};
|
|
1360
|
-
__publicField(_ToolSessionManager, "instance");
|
|
1361
|
-
var ToolSessionManager = _ToolSessionManager;
|
|
1362
1359
|
var toolSessionManager = ToolSessionManager.getInstance();
|
|
1363
1360
|
|
|
1364
1361
|
// src/utils/default-status-schemas.ts
|
|
@@ -1424,11 +1421,12 @@ function extractFullFields(schema) {
|
|
|
1424
1421
|
|
|
1425
1422
|
// src/services/ArtifactService.ts
|
|
1426
1423
|
var logger6 = getLogger("ArtifactService");
|
|
1427
|
-
var
|
|
1424
|
+
var ArtifactService = class _ArtifactService {
|
|
1428
1425
|
constructor(context) {
|
|
1429
1426
|
this.context = context;
|
|
1430
|
-
__publicField(this, "createdArtifacts", /* @__PURE__ */ new Map());
|
|
1431
1427
|
}
|
|
1428
|
+
createdArtifacts = /* @__PURE__ */ new Map();
|
|
1429
|
+
static selectorCache = /* @__PURE__ */ new Map();
|
|
1432
1430
|
/**
|
|
1433
1431
|
* Clear static caches to prevent memory leaks between sessions
|
|
1434
1432
|
*/
|
|
@@ -2119,14 +2117,35 @@ var _ArtifactService = class _ArtifactService {
|
|
|
2119
2117
|
return filtered;
|
|
2120
2118
|
}
|
|
2121
2119
|
};
|
|
2122
|
-
__publicField(_ArtifactService, "selectorCache", /* @__PURE__ */ new Map());
|
|
2123
|
-
var ArtifactService = _ArtifactService;
|
|
2124
2120
|
|
|
2125
2121
|
// src/services/ArtifactParser.ts
|
|
2126
2122
|
var logger7 = getLogger("ArtifactParser");
|
|
2127
|
-
var
|
|
2123
|
+
var ArtifactParser = class _ArtifactParser {
|
|
2124
|
+
static ARTIFACT_CHECK_REGEX = /<artifact:ref\s+(?=.*id=['"][^'"]+['"])(?=.*tool=['"][^'"]+['"])[^>]*\/>/;
|
|
2125
|
+
static ATTR_REGEX = /(\w+)="([^"]*)"|(\w+)='([^']*)'|(\w+)=({[^}]+})/g;
|
|
2126
|
+
static ARTIFACT_PATTERNS = [
|
|
2127
|
+
"<a",
|
|
2128
|
+
"<ar",
|
|
2129
|
+
"<art",
|
|
2130
|
+
"<arti",
|
|
2131
|
+
"<artif",
|
|
2132
|
+
"<artifa",
|
|
2133
|
+
"<artifac",
|
|
2134
|
+
"<artifact",
|
|
2135
|
+
"<artifact:",
|
|
2136
|
+
"<artifact:r",
|
|
2137
|
+
"<artifact:re",
|
|
2138
|
+
"<artifact:ref",
|
|
2139
|
+
"<artifact:c",
|
|
2140
|
+
"<artifact:cr",
|
|
2141
|
+
"<artifact:cre",
|
|
2142
|
+
"<artifact:crea",
|
|
2143
|
+
"<artifact:creat",
|
|
2144
|
+
"<artifact:create"
|
|
2145
|
+
];
|
|
2146
|
+
static INCOMPLETE_CREATE_REGEX = /<artifact:create(?![^>]*(?:\/>|<\/artifact:create>))/;
|
|
2147
|
+
artifactService;
|
|
2128
2148
|
constructor(tenantId, options) {
|
|
2129
|
-
__publicField(this, "artifactService");
|
|
2130
2149
|
if (options?.artifactService) {
|
|
2131
2150
|
this.artifactService = options.artifactService;
|
|
2132
2151
|
} else {
|
|
@@ -2469,30 +2488,6 @@ var _ArtifactParser = class _ArtifactParser {
|
|
|
2469
2488
|
return await this.artifactService.getArtifactSummary(artifactId, toolCallId, artifactMap);
|
|
2470
2489
|
}
|
|
2471
2490
|
};
|
|
2472
|
-
__publicField(_ArtifactParser, "ARTIFACT_CHECK_REGEX", /<artifact:ref\s+(?=.*id=['"][^'"]+['"])(?=.*tool=['"][^'"]+['"])[^>]*\/>/);
|
|
2473
|
-
__publicField(_ArtifactParser, "ATTR_REGEX", /(\w+)="([^"]*)"|(\w+)='([^']*)'|(\w+)=({[^}]+})/g);
|
|
2474
|
-
__publicField(_ArtifactParser, "ARTIFACT_PATTERNS", [
|
|
2475
|
-
"<a",
|
|
2476
|
-
"<ar",
|
|
2477
|
-
"<art",
|
|
2478
|
-
"<arti",
|
|
2479
|
-
"<artif",
|
|
2480
|
-
"<artifa",
|
|
2481
|
-
"<artifac",
|
|
2482
|
-
"<artifact",
|
|
2483
|
-
"<artifact:",
|
|
2484
|
-
"<artifact:r",
|
|
2485
|
-
"<artifact:re",
|
|
2486
|
-
"<artifact:ref",
|
|
2487
|
-
"<artifact:c",
|
|
2488
|
-
"<artifact:cr",
|
|
2489
|
-
"<artifact:cre",
|
|
2490
|
-
"<artifact:crea",
|
|
2491
|
-
"<artifact:creat",
|
|
2492
|
-
"<artifact:create"
|
|
2493
|
-
]);
|
|
2494
|
-
__publicField(_ArtifactParser, "INCOMPLETE_CREATE_REGEX", /<artifact:create(?![^>]*(?:\/>|<\/artifact:create>))/);
|
|
2495
|
-
var ArtifactParser = _ArtifactParser;
|
|
2496
2491
|
|
|
2497
2492
|
// src/services/AgentSession.ts
|
|
2498
2493
|
var logger8 = getLogger("AgentSession");
|
|
@@ -2505,29 +2500,6 @@ var AgentSession = class {
|
|
|
2505
2500
|
this.tenantId = tenantId;
|
|
2506
2501
|
this.projectId = projectId;
|
|
2507
2502
|
this.contextId = contextId;
|
|
2508
|
-
__publicField(this, "events", []);
|
|
2509
|
-
__publicField(this, "statusUpdateState");
|
|
2510
|
-
__publicField(this, "statusUpdateTimer");
|
|
2511
|
-
__publicField(this, "previousSummaries", []);
|
|
2512
|
-
__publicField(this, "isEnded", false);
|
|
2513
|
-
__publicField(this, "isTextStreaming", false);
|
|
2514
|
-
__publicField(this, "isGeneratingUpdate", false);
|
|
2515
|
-
__publicField(this, "pendingArtifacts", /* @__PURE__ */ new Set());
|
|
2516
|
-
// Track pending artifact processing
|
|
2517
|
-
__publicField(this, "artifactProcessingErrors", /* @__PURE__ */ new Map());
|
|
2518
|
-
// Track errors per artifact
|
|
2519
|
-
__publicField(this, "MAX_ARTIFACT_RETRIES", ARTIFACT_GENERATION_MAX_RETRIES);
|
|
2520
|
-
__publicField(this, "MAX_PENDING_ARTIFACTS", ARTIFACT_SESSION_MAX_PENDING);
|
|
2521
|
-
// Prevent unbounded growth
|
|
2522
|
-
__publicField(this, "scheduledTimeouts");
|
|
2523
|
-
// Track scheduled timeouts for cleanup
|
|
2524
|
-
__publicField(this, "artifactCache", /* @__PURE__ */ new Map());
|
|
2525
|
-
// Cache artifacts created in this session
|
|
2526
|
-
__publicField(this, "artifactService");
|
|
2527
|
-
// Session-scoped ArtifactService instance
|
|
2528
|
-
__publicField(this, "artifactParser");
|
|
2529
|
-
// Session-scoped ArtifactParser instance
|
|
2530
|
-
__publicField(this, "isEmitOperations", false);
|
|
2531
2503
|
logger8.debug({ sessionId, messageId, agentId }, "AgentSession created");
|
|
2532
2504
|
if (tenantId && projectId) {
|
|
2533
2505
|
toolSessionManager.createSessionWithId(
|
|
@@ -2557,6 +2529,29 @@ var AgentSession = class {
|
|
|
2557
2529
|
});
|
|
2558
2530
|
}
|
|
2559
2531
|
}
|
|
2532
|
+
events = [];
|
|
2533
|
+
statusUpdateState;
|
|
2534
|
+
statusUpdateTimer;
|
|
2535
|
+
previousSummaries = [];
|
|
2536
|
+
isEnded = false;
|
|
2537
|
+
isTextStreaming = false;
|
|
2538
|
+
isGeneratingUpdate = false;
|
|
2539
|
+
pendingArtifacts = /* @__PURE__ */ new Set();
|
|
2540
|
+
// Track pending artifact processing
|
|
2541
|
+
artifactProcessingErrors = /* @__PURE__ */ new Map();
|
|
2542
|
+
// Track errors per artifact
|
|
2543
|
+
MAX_ARTIFACT_RETRIES = ARTIFACT_GENERATION_MAX_RETRIES;
|
|
2544
|
+
MAX_PENDING_ARTIFACTS = ARTIFACT_SESSION_MAX_PENDING;
|
|
2545
|
+
// Prevent unbounded growth
|
|
2546
|
+
scheduledTimeouts;
|
|
2547
|
+
// Track scheduled timeouts for cleanup
|
|
2548
|
+
artifactCache = /* @__PURE__ */ new Map();
|
|
2549
|
+
// Cache artifacts created in this session
|
|
2550
|
+
artifactService;
|
|
2551
|
+
// Session-scoped ArtifactService instance
|
|
2552
|
+
artifactParser;
|
|
2553
|
+
// Session-scoped ArtifactParser instance
|
|
2554
|
+
isEmitOperations = false;
|
|
2560
2555
|
/**
|
|
2561
2556
|
* Enable emit operations to send data operations
|
|
2562
2557
|
*/
|
|
@@ -3768,9 +3763,7 @@ Make it specific and relevant.`;
|
|
|
3768
3763
|
}
|
|
3769
3764
|
};
|
|
3770
3765
|
var AgentSessionManager = class {
|
|
3771
|
-
|
|
3772
|
-
__publicField(this, "sessions", /* @__PURE__ */ new Map());
|
|
3773
|
-
}
|
|
3766
|
+
sessions = /* @__PURE__ */ new Map();
|
|
3774
3767
|
/**
|
|
3775
3768
|
* Create a new session for a message
|
|
3776
3769
|
*/
|
|
@@ -3947,23 +3940,28 @@ async function resolveModelConfig(agentId, subAgent) {
|
|
|
3947
3940
|
|
|
3948
3941
|
// src/services/IncrementalStreamParser.ts
|
|
3949
3942
|
var logger9 = getLogger("IncrementalStreamParser");
|
|
3950
|
-
var
|
|
3943
|
+
var IncrementalStreamParser = class _IncrementalStreamParser {
|
|
3944
|
+
buffer = "";
|
|
3945
|
+
pendingTextBuffer = "";
|
|
3946
|
+
streamHelper;
|
|
3947
|
+
artifactParser;
|
|
3948
|
+
hasStartedRole = false;
|
|
3949
|
+
collectedParts = [];
|
|
3950
|
+
contextId;
|
|
3951
|
+
lastChunkWasToolResult = false;
|
|
3952
|
+
componentAccumulator = {};
|
|
3953
|
+
lastStreamedComponents = /* @__PURE__ */ new Map();
|
|
3954
|
+
componentSnapshots = /* @__PURE__ */ new Map();
|
|
3955
|
+
artifactMap;
|
|
3956
|
+
subAgentId;
|
|
3957
|
+
allStreamedContent = [];
|
|
3958
|
+
static MAX_SNAPSHOT_SIZE = STREAM_PARSER_MAX_SNAPSHOT_SIZE;
|
|
3959
|
+
// Max number of snapshots to keep
|
|
3960
|
+
static MAX_STREAMED_SIZE = STREAM_PARSER_MAX_STREAMED_SIZE;
|
|
3961
|
+
// Max number of streamed component IDs to track
|
|
3962
|
+
static MAX_COLLECTED_PARTS = STREAM_PARSER_MAX_COLLECTED_PARTS;
|
|
3951
3963
|
// Max number of collected parts to prevent unbounded growth
|
|
3952
3964
|
constructor(streamHelper, tenantId, contextId, artifactParserOptions) {
|
|
3953
|
-
__publicField(this, "buffer", "");
|
|
3954
|
-
__publicField(this, "pendingTextBuffer", "");
|
|
3955
|
-
__publicField(this, "streamHelper");
|
|
3956
|
-
__publicField(this, "artifactParser");
|
|
3957
|
-
__publicField(this, "hasStartedRole", false);
|
|
3958
|
-
__publicField(this, "collectedParts", []);
|
|
3959
|
-
__publicField(this, "contextId");
|
|
3960
|
-
__publicField(this, "lastChunkWasToolResult", false);
|
|
3961
|
-
__publicField(this, "componentAccumulator", {});
|
|
3962
|
-
__publicField(this, "lastStreamedComponents", /* @__PURE__ */ new Map());
|
|
3963
|
-
__publicField(this, "componentSnapshots", /* @__PURE__ */ new Map());
|
|
3964
|
-
__publicField(this, "artifactMap");
|
|
3965
|
-
__publicField(this, "subAgentId");
|
|
3966
|
-
__publicField(this, "allStreamedContent", []);
|
|
3967
3965
|
this.streamHelper = streamHelper;
|
|
3968
3966
|
this.contextId = contextId;
|
|
3969
3967
|
this.subAgentId = artifactParserOptions?.subAgentId;
|
|
@@ -4339,19 +4337,13 @@ ${chunk}`;
|
|
|
4339
4337
|
}
|
|
4340
4338
|
}
|
|
4341
4339
|
};
|
|
4342
|
-
__publicField(_IncrementalStreamParser, "MAX_SNAPSHOT_SIZE", STREAM_PARSER_MAX_SNAPSHOT_SIZE);
|
|
4343
|
-
// Max number of snapshots to keep
|
|
4344
|
-
__publicField(_IncrementalStreamParser, "MAX_STREAMED_SIZE", STREAM_PARSER_MAX_STREAMED_SIZE);
|
|
4345
|
-
// Max number of streamed component IDs to track
|
|
4346
|
-
__publicField(_IncrementalStreamParser, "MAX_COLLECTED_PARTS", STREAM_PARSER_MAX_COLLECTED_PARTS);
|
|
4347
|
-
var IncrementalStreamParser = _IncrementalStreamParser;
|
|
4348
4340
|
|
|
4349
4341
|
// src/services/ResponseFormatter.ts
|
|
4350
4342
|
var logger10 = getLogger("ResponseFormatter");
|
|
4351
4343
|
var ResponseFormatter = class {
|
|
4344
|
+
artifactParser;
|
|
4345
|
+
subAgentId;
|
|
4352
4346
|
constructor(tenantId, artifactParserOptions) {
|
|
4353
|
-
__publicField(this, "artifactParser");
|
|
4354
|
-
__publicField(this, "subAgentId");
|
|
4355
4347
|
this.subAgentId = artifactParserOptions?.subAgentId;
|
|
4356
4348
|
if (artifactParserOptions?.streamRequestId) {
|
|
4357
4349
|
const sessionParser = agentSessionManager.getArtifactParser(
|
|
@@ -4578,7 +4570,8 @@ function jsonSchemaToZod(jsonSchema) {
|
|
|
4578
4570
|
return z.unknown();
|
|
4579
4571
|
}
|
|
4580
4572
|
}
|
|
4581
|
-
var
|
|
4573
|
+
var SchemaProcessor = class _SchemaProcessor {
|
|
4574
|
+
static logger = getLogger("SchemaProcessor");
|
|
4582
4575
|
/**
|
|
4583
4576
|
* Transform complex schema types to strings for JMESPath compatibility
|
|
4584
4577
|
*/
|
|
@@ -4795,12 +4788,25 @@ var _SchemaProcessor = class _SchemaProcessor {
|
|
|
4795
4788
|
return transformToSelectorSchema(schema);
|
|
4796
4789
|
}
|
|
4797
4790
|
};
|
|
4798
|
-
__publicField(_SchemaProcessor, "logger", getLogger("SchemaProcessor"));
|
|
4799
|
-
var SchemaProcessor = _SchemaProcessor;
|
|
4800
4791
|
|
|
4801
4792
|
// src/utils/artifact-component-schema.ts
|
|
4802
4793
|
getLogger("ArtifactComponentSchema");
|
|
4803
|
-
var
|
|
4794
|
+
var ArtifactReferenceSchema = class _ArtifactReferenceSchema {
|
|
4795
|
+
// Standard artifact props schema - single source of truth
|
|
4796
|
+
static ARTIFACT_PROPS_SCHEMA = {
|
|
4797
|
+
type: "object",
|
|
4798
|
+
properties: {
|
|
4799
|
+
artifact_id: {
|
|
4800
|
+
type: "string",
|
|
4801
|
+
description: "The artifact_id from your artifact:create tag. Must match exactly."
|
|
4802
|
+
},
|
|
4803
|
+
tool_call_id: {
|
|
4804
|
+
type: "string",
|
|
4805
|
+
description: "The EXACT tool_call_id from tool execution (call_xyz789 or toolu_abc123). NEVER invent or make up IDs."
|
|
4806
|
+
}
|
|
4807
|
+
},
|
|
4808
|
+
required: ["artifact_id", "tool_call_id"]
|
|
4809
|
+
};
|
|
4804
4810
|
/**
|
|
4805
4811
|
* Get the standard Zod schema for artifact reference components
|
|
4806
4812
|
*/
|
|
@@ -4825,22 +4831,6 @@ var _ArtifactReferenceSchema = class _ArtifactReferenceSchema {
|
|
|
4825
4831
|
};
|
|
4826
4832
|
}
|
|
4827
4833
|
};
|
|
4828
|
-
// Standard artifact props schema - single source of truth
|
|
4829
|
-
__publicField(_ArtifactReferenceSchema, "ARTIFACT_PROPS_SCHEMA", {
|
|
4830
|
-
type: "object",
|
|
4831
|
-
properties: {
|
|
4832
|
-
artifact_id: {
|
|
4833
|
-
type: "string",
|
|
4834
|
-
description: "The artifact_id from your artifact:create tag. Must match exactly."
|
|
4835
|
-
},
|
|
4836
|
-
tool_call_id: {
|
|
4837
|
-
type: "string",
|
|
4838
|
-
description: "The EXACT tool_call_id from tool execution (call_xyz789 or toolu_abc123). NEVER invent or make up IDs."
|
|
4839
|
-
}
|
|
4840
|
-
},
|
|
4841
|
-
required: ["artifact_id", "tool_call_id"]
|
|
4842
|
-
});
|
|
4843
|
-
var ArtifactReferenceSchema = _ArtifactReferenceSchema;
|
|
4844
4834
|
var ArtifactCreateSchema = class {
|
|
4845
4835
|
/**
|
|
4846
4836
|
* Generate artifact create schemas - one for each artifact component type
|
|
@@ -4946,13 +4936,13 @@ var DEFAULT_BACKOFF = {
|
|
|
4946
4936
|
};
|
|
4947
4937
|
var DEFAULT_RETRY_STATUS_CODES = ["429", "500", "502", "503", "504"];
|
|
4948
4938
|
var PermanentError = class _PermanentError extends Error {
|
|
4939
|
+
cause;
|
|
4949
4940
|
constructor(message, options) {
|
|
4950
4941
|
let msg = message;
|
|
4951
4942
|
if (options?.cause) {
|
|
4952
4943
|
msg += `: ${options.cause}`;
|
|
4953
4944
|
}
|
|
4954
4945
|
super(msg, options);
|
|
4955
|
-
__publicField(this, "cause");
|
|
4956
4946
|
this.name = "PermanentError";
|
|
4957
4947
|
if (typeof this.cause === "undefined") {
|
|
4958
4948
|
this.cause = options?.cause;
|
|
@@ -4961,15 +4951,21 @@ var PermanentError = class _PermanentError extends Error {
|
|
|
4961
4951
|
}
|
|
4962
4952
|
};
|
|
4963
4953
|
var TemporaryError = class _TemporaryError extends Error {
|
|
4954
|
+
response;
|
|
4964
4955
|
constructor(message, response) {
|
|
4965
4956
|
super(message);
|
|
4966
|
-
__publicField(this, "response");
|
|
4967
4957
|
this.response = response;
|
|
4968
4958
|
this.name = "TemporaryError";
|
|
4969
4959
|
Object.setPrototypeOf(this, _TemporaryError.prototype);
|
|
4970
4960
|
}
|
|
4971
4961
|
};
|
|
4972
4962
|
var A2AClient = class {
|
|
4963
|
+
agentBaseUrl;
|
|
4964
|
+
agentCardPromise;
|
|
4965
|
+
requestIdCounter = 1;
|
|
4966
|
+
serviceEndpointUrl;
|
|
4967
|
+
// To be populated from AgentCard after fetching
|
|
4968
|
+
options;
|
|
4973
4969
|
/**
|
|
4974
4970
|
* Constructs an A2AClient instance.
|
|
4975
4971
|
* It initiates fetching the agent card from the provided agent baseUrl.
|
|
@@ -4979,12 +4975,6 @@ var A2AClient = class {
|
|
|
4979
4975
|
* @param options Optional configuration including retry behavior.
|
|
4980
4976
|
*/
|
|
4981
4977
|
constructor(agentBaseUrl, options) {
|
|
4982
|
-
__publicField(this, "agentBaseUrl");
|
|
4983
|
-
__publicField(this, "agentCardPromise");
|
|
4984
|
-
__publicField(this, "requestIdCounter", 1);
|
|
4985
|
-
__publicField(this, "serviceEndpointUrl");
|
|
4986
|
-
// To be populated from AgentCard after fetching
|
|
4987
|
-
__publicField(this, "options");
|
|
4988
4978
|
this.agentBaseUrl = agentBaseUrl.replace(/\/$/, "");
|
|
4989
4979
|
this.options = {
|
|
4990
4980
|
retryConfig: {
|
|
@@ -5893,9 +5883,9 @@ var SystemPromptBuilder = class {
|
|
|
5893
5883
|
constructor(version, versionConfig) {
|
|
5894
5884
|
this.version = version;
|
|
5895
5885
|
this.versionConfig = versionConfig;
|
|
5896
|
-
__publicField(this, "templates", /* @__PURE__ */ new Map());
|
|
5897
|
-
__publicField(this, "loaded", false);
|
|
5898
5886
|
}
|
|
5887
|
+
templates = /* @__PURE__ */ new Map();
|
|
5888
|
+
loaded = false;
|
|
5899
5889
|
loadTemplates() {
|
|
5900
5890
|
if (this.loaded) return;
|
|
5901
5891
|
try {
|
|
@@ -6991,20 +6981,20 @@ function isValidTool(tool3) {
|
|
|
6991
6981
|
return tool3 && typeof tool3 === "object" && typeof tool3.description === "string" && tool3.inputSchema && typeof tool3.execute === "function";
|
|
6992
6982
|
}
|
|
6993
6983
|
var Agent = class {
|
|
6984
|
+
config;
|
|
6985
|
+
systemPromptBuilder = new SystemPromptBuilder("v1", new Phase1Config());
|
|
6986
|
+
credentialStuffer;
|
|
6987
|
+
streamHelper;
|
|
6988
|
+
streamRequestId;
|
|
6989
|
+
conversationId;
|
|
6990
|
+
delegationId;
|
|
6991
|
+
artifactComponents = [];
|
|
6992
|
+
isDelegatedAgent = false;
|
|
6993
|
+
contextResolver;
|
|
6994
|
+
credentialStoreRegistry;
|
|
6995
|
+
mcpClientCache = /* @__PURE__ */ new Map();
|
|
6996
|
+
mcpConnectionLocks = /* @__PURE__ */ new Map();
|
|
6994
6997
|
constructor(config, credentialStoreRegistry) {
|
|
6995
|
-
__publicField(this, "config");
|
|
6996
|
-
__publicField(this, "systemPromptBuilder", new SystemPromptBuilder("v1", new Phase1Config()));
|
|
6997
|
-
__publicField(this, "credentialStuffer");
|
|
6998
|
-
__publicField(this, "streamHelper");
|
|
6999
|
-
__publicField(this, "streamRequestId");
|
|
7000
|
-
__publicField(this, "conversationId");
|
|
7001
|
-
__publicField(this, "delegationId");
|
|
7002
|
-
__publicField(this, "artifactComponents", []);
|
|
7003
|
-
__publicField(this, "isDelegatedAgent", false);
|
|
7004
|
-
__publicField(this, "contextResolver");
|
|
7005
|
-
__publicField(this, "credentialStoreRegistry");
|
|
7006
|
-
__publicField(this, "mcpClientCache", /* @__PURE__ */ new Map());
|
|
7007
|
-
__publicField(this, "mcpConnectionLocks", /* @__PURE__ */ new Map());
|
|
7008
6998
|
this.artifactComponents = config.artifactComponents || [];
|
|
7009
6999
|
let processedDataComponents = config.dataComponents || [];
|
|
7010
7000
|
if (processedDataComponents.length > 0) {
|
|
@@ -7616,7 +7606,7 @@ var Agent = class {
|
|
|
7616
7606
|
if (functionToolsData.length === 0) {
|
|
7617
7607
|
return functionTools;
|
|
7618
7608
|
}
|
|
7619
|
-
const { SandboxExecutorFactory } = await import('./SandboxExecutorFactory-
|
|
7609
|
+
const { SandboxExecutorFactory } = await import('./SandboxExecutorFactory-NUNGK35F.js');
|
|
7620
7610
|
const sandboxExecutor = SandboxExecutorFactory.getInstance();
|
|
7621
7611
|
for (const functionToolDef of functionToolsData) {
|
|
7622
7612
|
const functionId = functionToolDef.functionId;
|
|
@@ -7910,7 +7900,7 @@ var Agent = class {
|
|
|
7910
7900
|
inputSchema: tool3.inputSchema || tool3.parameters || {},
|
|
7911
7901
|
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."
|
|
7912
7902
|
}));
|
|
7913
|
-
const { getConversationScopedArtifacts } = await import('./conversations-
|
|
7903
|
+
const { getConversationScopedArtifacts } = await import('./conversations-ZCZG5434.js');
|
|
7914
7904
|
const historyConfig = this.config.conversationHistoryConfig ?? createDefaultConversationHistoryConfig();
|
|
7915
7905
|
const referenceArtifacts = await getConversationScopedArtifacts({
|
|
7916
7906
|
tenantId: this.config.tenantId,
|
|
@@ -8788,7 +8778,7 @@ ${output}${structureHintsFormatted}`;
|
|
|
8788
8778
|
};
|
|
8789
8779
|
textResponse = JSON.stringify(structuredResponse.object, null, 2);
|
|
8790
8780
|
} else {
|
|
8791
|
-
const { withJsonPostProcessing } = await import('./json-postprocessor-
|
|
8781
|
+
const { withJsonPostProcessing } = await import('./json-postprocessor-IGYTSWFB.js');
|
|
8792
8782
|
const phase2Messages = [
|
|
8793
8783
|
{ role: "system", content: await this.buildPhase2SystemPrompt(runtimeContext) }
|
|
8794
8784
|
];
|
|
@@ -9863,9 +9853,9 @@ var SSEStreamHelper = class {
|
|
|
9863
9853
|
this.stream = stream2;
|
|
9864
9854
|
this.requestId = requestId2;
|
|
9865
9855
|
this.timestamp = timestamp;
|
|
9866
|
-
__publicField(this, "isTextStreaming", false);
|
|
9867
|
-
__publicField(this, "queuedEvents", []);
|
|
9868
9856
|
}
|
|
9857
|
+
isTextStreaming = false;
|
|
9858
|
+
queuedEvents = [];
|
|
9869
9859
|
/**
|
|
9870
9860
|
* Write the initial role message
|
|
9871
9861
|
*/
|
|
@@ -10029,25 +10019,26 @@ ${errorMessage}`);
|
|
|
10029
10019
|
function createSSEStreamHelper(stream2, requestId2, timestamp) {
|
|
10030
10020
|
return new SSEStreamHelper(stream2, requestId2, timestamp);
|
|
10031
10021
|
}
|
|
10032
|
-
var
|
|
10022
|
+
var VercelDataStreamHelper = class _VercelDataStreamHelper {
|
|
10033
10023
|
constructor(writer) {
|
|
10034
10024
|
this.writer = writer;
|
|
10035
|
-
__publicField(this, "textId", null);
|
|
10036
|
-
__publicField(this, "jsonBuffer", "");
|
|
10037
|
-
__publicField(this, "sentItems", /* @__PURE__ */ new Map());
|
|
10038
|
-
// Track what we've sent for each index
|
|
10039
|
-
__publicField(this, "completedItems", /* @__PURE__ */ new Set());
|
|
10040
|
-
// Track completed items
|
|
10041
|
-
__publicField(this, "sessionId");
|
|
10042
|
-
__publicField(this, "isCompleted", false);
|
|
10043
|
-
__publicField(this, "isTextStreaming", false);
|
|
10044
|
-
__publicField(this, "queuedEvents", []);
|
|
10045
|
-
__publicField(this, "lastTextEndTimestamp", 0);
|
|
10046
|
-
__publicField(this, "connectionDropTimer");
|
|
10047
10025
|
this.connectionDropTimer = setTimeout(() => {
|
|
10048
10026
|
this.forceCleanup("Connection lifetime exceeded");
|
|
10049
10027
|
}, STREAM_MAX_LIFETIME_MS);
|
|
10050
10028
|
}
|
|
10029
|
+
textId = null;
|
|
10030
|
+
jsonBuffer = "";
|
|
10031
|
+
sentItems = /* @__PURE__ */ new Map();
|
|
10032
|
+
// Track what we've sent for each index
|
|
10033
|
+
completedItems = /* @__PURE__ */ new Set();
|
|
10034
|
+
// Track completed items
|
|
10035
|
+
sessionId;
|
|
10036
|
+
static MAX_BUFFER_SIZE = STREAM_BUFFER_MAX_SIZE_BYTES;
|
|
10037
|
+
isCompleted = false;
|
|
10038
|
+
isTextStreaming = false;
|
|
10039
|
+
queuedEvents = [];
|
|
10040
|
+
lastTextEndTimestamp = 0;
|
|
10041
|
+
connectionDropTimer;
|
|
10051
10042
|
setSessionId(sessionId) {
|
|
10052
10043
|
this.sessionId = sessionId;
|
|
10053
10044
|
}
|
|
@@ -10348,21 +10339,17 @@ var _VercelDataStreamHelper = class _VercelDataStreamHelper {
|
|
|
10348
10339
|
this.cleanup();
|
|
10349
10340
|
}
|
|
10350
10341
|
};
|
|
10351
|
-
__publicField(_VercelDataStreamHelper, "MAX_BUFFER_SIZE", STREAM_BUFFER_MAX_SIZE_BYTES);
|
|
10352
|
-
var VercelDataStreamHelper = _VercelDataStreamHelper;
|
|
10353
10342
|
function createVercelStreamHelper(writer) {
|
|
10354
10343
|
return new VercelDataStreamHelper(writer);
|
|
10355
10344
|
}
|
|
10356
10345
|
var BufferingStreamHelper = class {
|
|
10357
|
-
|
|
10358
|
-
|
|
10359
|
-
|
|
10360
|
-
|
|
10361
|
-
|
|
10362
|
-
|
|
10363
|
-
|
|
10364
|
-
__publicField(this, "sessionId");
|
|
10365
|
-
}
|
|
10346
|
+
capturedText = "";
|
|
10347
|
+
capturedData = [];
|
|
10348
|
+
capturedOperations = [];
|
|
10349
|
+
capturedSummaries = [];
|
|
10350
|
+
hasError = false;
|
|
10351
|
+
errorMessage = "";
|
|
10352
|
+
sessionId;
|
|
10366
10353
|
setSessionId(sessionId) {
|
|
10367
10354
|
this.sessionId = sessionId;
|
|
10368
10355
|
}
|
|
@@ -10419,9 +10406,7 @@ var createMCPStreamHelper = createBufferingStreamHelper;
|
|
|
10419
10406
|
// src/handlers/executionHandler.ts
|
|
10420
10407
|
var logger20 = getLogger("ExecutionHandler");
|
|
10421
10408
|
var ExecutionHandler = class {
|
|
10422
|
-
|
|
10423
|
-
__publicField(this, "MAX_ERRORS", AGENT_EXECUTION_MAX_CONSECUTIVE_ERRORS);
|
|
10424
|
-
}
|
|
10409
|
+
MAX_ERRORS = AGENT_EXECUTION_MAX_CONSECUTIVE_ERRORS;
|
|
10425
10410
|
/**
|
|
10426
10411
|
* performs exeuction loop
|
|
10427
10412
|
*
|
|
@@ -11484,9 +11469,10 @@ app3.openapi(chatDataStreamRoute, async (c) => {
|
|
|
11484
11469
|
});
|
|
11485
11470
|
var chatDataStream_default = app3;
|
|
11486
11471
|
var logger23 = getLogger("mcp");
|
|
11487
|
-
var
|
|
11472
|
+
var MockResponseSingleton = class _MockResponseSingleton {
|
|
11473
|
+
static instance;
|
|
11474
|
+
mockRes;
|
|
11488
11475
|
constructor() {
|
|
11489
|
-
__publicField(this, "mockRes");
|
|
11490
11476
|
this.mockRes = {
|
|
11491
11477
|
statusCode: 200,
|
|
11492
11478
|
headers: {},
|
|
@@ -11516,8 +11502,6 @@ var _MockResponseSingleton = class _MockResponseSingleton {
|
|
|
11516
11502
|
return this.mockRes;
|
|
11517
11503
|
}
|
|
11518
11504
|
};
|
|
11519
|
-
__publicField(_MockResponseSingleton, "instance");
|
|
11520
|
-
var MockResponseSingleton = _MockResponseSingleton;
|
|
11521
11505
|
var createSpoofInitMessage = (mcpProtocolVersion) => ({
|
|
11522
11506
|
method: "initialize",
|
|
11523
11507
|
params: {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { u, ur, C } from './chunk-SBJLXGYG.js';
|
|
2
|
+
import * as s from 'fs';
|
|
3
|
+
import * as o from 'path';
|
|
4
|
+
|
|
5
|
+
u();
|
|
6
|
+
var m = class extends ur {
|
|
7
|
+
constructor(t) {
|
|
8
|
+
super(t), this.rootDir = o.resolve(t), s.existsSync(o.join(this.rootDir)) || s.mkdirSync(this.rootDir);
|
|
9
|
+
}
|
|
10
|
+
async init(t, e) {
|
|
11
|
+
return this.pg = t, { emscriptenOpts: { ...e, preRun: [...e.preRun || [], (r) => {
|
|
12
|
+
let c = r.FS.filesystems.NODEFS;
|
|
13
|
+
r.FS.mkdir(C), r.FS.mount(c, { root: this.rootDir }, C);
|
|
14
|
+
}] } };
|
|
15
|
+
}
|
|
16
|
+
async closeFs() {
|
|
17
|
+
this.pg.Module.FS.quit();
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { m as NodeFS };
|