@inkeep/agents-run-api 0.1.10 → 0.2.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.cjs +549 -463
- package/dist/index.js +549 -463
- package/package.json +6 -3
package/dist/index.cjs
CHANGED
|
@@ -10,12 +10,13 @@ var agentsCore = require('@inkeep/agents-core');
|
|
|
10
10
|
var nanoid = require('nanoid');
|
|
11
11
|
var autoInstrumentationsNode = require('@opentelemetry/auto-instrumentations-node');
|
|
12
12
|
var baggageSpanProcessor = require('@opentelemetry/baggage-span-processor');
|
|
13
|
+
var contextAsyncHooks = require('@opentelemetry/context-async-hooks');
|
|
14
|
+
var core = require('@opentelemetry/core');
|
|
13
15
|
var exporterTraceOtlpHttp = require('@opentelemetry/exporter-trace-otlp-http');
|
|
16
|
+
var resources = require('@opentelemetry/resources');
|
|
14
17
|
var sdkNode = require('@opentelemetry/sdk-node');
|
|
15
18
|
var sdkTraceBase = require('@opentelemetry/sdk-trace-base');
|
|
16
19
|
var semanticConventions = require('@opentelemetry/semantic-conventions');
|
|
17
|
-
var resources = require('@opentelemetry/resources');
|
|
18
|
-
var contextAsyncHooks = require('@opentelemetry/context-async-hooks');
|
|
19
20
|
var zodOpenapi = require('@hono/zod-openapi');
|
|
20
21
|
var api = require('@opentelemetry/api');
|
|
21
22
|
var hono = require('hono');
|
|
@@ -29,12 +30,14 @@ var destr = require('destr');
|
|
|
29
30
|
var traverse = require('traverse');
|
|
30
31
|
var ai = require('ai');
|
|
31
32
|
var anthropic = require('@ai-sdk/anthropic');
|
|
33
|
+
var google = require('@ai-sdk/google');
|
|
32
34
|
var openai = require('@ai-sdk/openai');
|
|
33
35
|
var jmespath = require('jmespath');
|
|
34
36
|
var mcp_js = require('@modelcontextprotocol/sdk/server/mcp.js');
|
|
35
37
|
var streamableHttp_js = require('@modelcontextprotocol/sdk/server/streamableHttp.js');
|
|
36
38
|
var v3 = require('zod/v3');
|
|
37
39
|
var fetchToNode = require('fetch-to-node');
|
|
40
|
+
var otel = require('@hono/otel');
|
|
38
41
|
|
|
39
42
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
40
43
|
|
|
@@ -334,6 +337,9 @@ var resource = resources.resourceFromAttributes({
|
|
|
334
337
|
var sdk = new sdkNode.NodeSDK({
|
|
335
338
|
resource,
|
|
336
339
|
contextManager: new contextAsyncHooks.AsyncLocalStorageContextManager(),
|
|
340
|
+
textMapPropagator: new core.CompositePropagator({
|
|
341
|
+
propagators: [new core.W3CTraceContextPropagator(), new core.W3CBaggagePropagator()]
|
|
342
|
+
}),
|
|
337
343
|
spanProcessors: [new baggageSpanProcessor.BaggageSpanProcessor(baggageSpanProcessor.ALLOW_ALL_BAGGAGE_KEYS), batchProcessor],
|
|
338
344
|
instrumentations: [
|
|
339
345
|
autoInstrumentationsNode.getNodeAutoInstrumentations({
|
|
@@ -456,6 +462,7 @@ var apiKeyAuth = () => factory.createMiddleware(async (c, next) => {
|
|
|
456
462
|
return;
|
|
457
463
|
} else if (apiKey) {
|
|
458
464
|
const executionContext = await extractContextFromApiKey(apiKey);
|
|
465
|
+
executionContext.agentId = agentId;
|
|
459
466
|
c.set("executionContext", executionContext);
|
|
460
467
|
logger.info({}, "API key authenticated successfully");
|
|
461
468
|
await next();
|
|
@@ -473,12 +480,14 @@ var apiKeyAuth = () => factory.createMiddleware(async (c, next) => {
|
|
|
473
480
|
}
|
|
474
481
|
try {
|
|
475
482
|
const executionContext = await extractContextFromApiKey(apiKey);
|
|
483
|
+
executionContext.agentId = agentId;
|
|
476
484
|
c.set("executionContext", executionContext);
|
|
477
485
|
logger.debug(
|
|
478
486
|
{
|
|
479
487
|
tenantId: executionContext.tenantId,
|
|
480
488
|
projectId: executionContext.projectId,
|
|
481
|
-
graphId: executionContext.graphId
|
|
489
|
+
graphId: executionContext.graphId,
|
|
490
|
+
agentId: executionContext.agentId
|
|
482
491
|
},
|
|
483
492
|
"API key authenticated successfully"
|
|
484
493
|
);
|
|
@@ -1151,6 +1160,128 @@ async function handleTasksResubscribe(c, agent, request) {
|
|
|
1151
1160
|
});
|
|
1152
1161
|
}
|
|
1153
1162
|
}
|
|
1163
|
+
init_dbClient();
|
|
1164
|
+
agentsCore.getLogger("agents");
|
|
1165
|
+
function createAgentCard({
|
|
1166
|
+
dbAgent,
|
|
1167
|
+
baseUrl
|
|
1168
|
+
}) {
|
|
1169
|
+
const description = dbAgent.description || "AI Agent";
|
|
1170
|
+
return {
|
|
1171
|
+
name: dbAgent.name,
|
|
1172
|
+
description,
|
|
1173
|
+
url: baseUrl ? `${baseUrl}/a2a` : "",
|
|
1174
|
+
version: "1.0.0",
|
|
1175
|
+
capabilities: {
|
|
1176
|
+
streaming: true,
|
|
1177
|
+
// Enable streaming for A2A compliance
|
|
1178
|
+
pushNotifications: false,
|
|
1179
|
+
stateTransitionHistory: false
|
|
1180
|
+
},
|
|
1181
|
+
defaultInputModes: ["text", "text/plain"],
|
|
1182
|
+
defaultOutputModes: ["text", "text/plain"],
|
|
1183
|
+
skills: [],
|
|
1184
|
+
// Add provider info if available
|
|
1185
|
+
...baseUrl && {
|
|
1186
|
+
provider: {
|
|
1187
|
+
organization: "Inkeep",
|
|
1188
|
+
url: baseUrl
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
};
|
|
1192
|
+
}
|
|
1193
|
+
function generateDescriptionWithTransfers(baseDescription, internalRelations, externalRelations) {
|
|
1194
|
+
const transfers = [
|
|
1195
|
+
...internalRelations.filter((rel) => rel.relationType === "transfer"),
|
|
1196
|
+
...externalRelations.filter((rel) => rel.relationType === "transfer")
|
|
1197
|
+
];
|
|
1198
|
+
const delegates = [
|
|
1199
|
+
...internalRelations.filter((rel) => rel.relationType === "delegate"),
|
|
1200
|
+
...externalRelations.filter((rel) => rel.relationType === "delegate")
|
|
1201
|
+
];
|
|
1202
|
+
if (transfers.length === 0 && delegates.length === 0) {
|
|
1203
|
+
return baseDescription;
|
|
1204
|
+
}
|
|
1205
|
+
let enhancedDescription = baseDescription;
|
|
1206
|
+
if (transfers.length > 0) {
|
|
1207
|
+
const transferList = transfers.map((rel) => {
|
|
1208
|
+
const name = rel.externalAgent?.name || rel.name;
|
|
1209
|
+
const desc = rel.externalAgent?.description || rel.description || "";
|
|
1210
|
+
return `- ${name}: ${desc}`;
|
|
1211
|
+
}).join("\n");
|
|
1212
|
+
enhancedDescription += `
|
|
1213
|
+
|
|
1214
|
+
Can transfer to:
|
|
1215
|
+
${transferList}`;
|
|
1216
|
+
}
|
|
1217
|
+
if (delegates.length > 0) {
|
|
1218
|
+
const delegateList = delegates.map((rel) => {
|
|
1219
|
+
const name = rel.externalAgent?.name || rel.name;
|
|
1220
|
+
const desc = rel.externalAgent?.description || rel.description || "";
|
|
1221
|
+
return `- ${name}: ${desc}`;
|
|
1222
|
+
}).join("\n");
|
|
1223
|
+
enhancedDescription += `
|
|
1224
|
+
|
|
1225
|
+
Can delegate to:
|
|
1226
|
+
${delegateList}`;
|
|
1227
|
+
}
|
|
1228
|
+
return enhancedDescription;
|
|
1229
|
+
}
|
|
1230
|
+
async function hydrateAgent({
|
|
1231
|
+
dbAgent,
|
|
1232
|
+
graphId,
|
|
1233
|
+
baseUrl,
|
|
1234
|
+
apiKey,
|
|
1235
|
+
credentialStoreRegistry
|
|
1236
|
+
}) {
|
|
1237
|
+
try {
|
|
1238
|
+
const taskHandlerConfig = await createTaskHandlerConfig({
|
|
1239
|
+
tenantId: dbAgent.tenantId,
|
|
1240
|
+
projectId: dbAgent.projectId,
|
|
1241
|
+
graphId,
|
|
1242
|
+
agentId: dbAgent.id,
|
|
1243
|
+
baseUrl,
|
|
1244
|
+
apiKey
|
|
1245
|
+
});
|
|
1246
|
+
const taskHandler = createTaskHandler(taskHandlerConfig, credentialStoreRegistry);
|
|
1247
|
+
const agentCard = createAgentCard({
|
|
1248
|
+
dbAgent,
|
|
1249
|
+
baseUrl
|
|
1250
|
+
});
|
|
1251
|
+
return {
|
|
1252
|
+
agentId: dbAgent.id,
|
|
1253
|
+
tenantId: dbAgent.tenantId,
|
|
1254
|
+
projectId: dbAgent.projectId,
|
|
1255
|
+
graphId,
|
|
1256
|
+
agentCard,
|
|
1257
|
+
taskHandler
|
|
1258
|
+
};
|
|
1259
|
+
} catch (error) {
|
|
1260
|
+
console.error(`\u274C Failed to hydrate agent ${dbAgent.id}:`, error);
|
|
1261
|
+
throw error;
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
async function getRegisteredAgent(executionContext, credentialStoreRegistry) {
|
|
1265
|
+
const { tenantId, projectId, graphId, agentId, baseUrl, apiKey } = executionContext;
|
|
1266
|
+
if (!agentId) {
|
|
1267
|
+
throw new Error("Agent ID is required");
|
|
1268
|
+
}
|
|
1269
|
+
const dbAgent = await agentsCore.getAgentById(dbClient_default)({
|
|
1270
|
+
scopes: { tenantId, projectId },
|
|
1271
|
+
agentId
|
|
1272
|
+
});
|
|
1273
|
+
if (!dbAgent) {
|
|
1274
|
+
return null;
|
|
1275
|
+
}
|
|
1276
|
+
const agentFrameworkBaseUrl = `${baseUrl}/agents`;
|
|
1277
|
+
return hydrateAgent({
|
|
1278
|
+
dbAgent,
|
|
1279
|
+
graphId,
|
|
1280
|
+
baseUrl: agentFrameworkBaseUrl,
|
|
1281
|
+
credentialStoreRegistry,
|
|
1282
|
+
apiKey
|
|
1283
|
+
});
|
|
1284
|
+
}
|
|
1154
1285
|
|
|
1155
1286
|
// src/agents/generateTaskHandler.ts
|
|
1156
1287
|
init_dbClient();
|
|
@@ -1194,10 +1325,10 @@ function statusUpdateOp(ctx) {
|
|
|
1194
1325
|
ctx
|
|
1195
1326
|
};
|
|
1196
1327
|
}
|
|
1197
|
-
var
|
|
1328
|
+
var logger4 = agentsCore.getLogger("DataComponentSchema");
|
|
1198
1329
|
function jsonSchemaToZod(jsonSchema) {
|
|
1199
1330
|
if (!jsonSchema || typeof jsonSchema !== "object") {
|
|
1200
|
-
|
|
1331
|
+
logger4.warn({ jsonSchema }, "Invalid JSON schema provided, using string fallback");
|
|
1201
1332
|
return z5.z.string();
|
|
1202
1333
|
}
|
|
1203
1334
|
switch (jsonSchema.type) {
|
|
@@ -1224,7 +1355,7 @@ function jsonSchemaToZod(jsonSchema) {
|
|
|
1224
1355
|
case "null":
|
|
1225
1356
|
return z5.z.null();
|
|
1226
1357
|
default:
|
|
1227
|
-
|
|
1358
|
+
logger4.warn(
|
|
1228
1359
|
{
|
|
1229
1360
|
unsupportedType: jsonSchema.type,
|
|
1230
1361
|
schema: jsonSchema
|
|
@@ -1278,8 +1409,40 @@ __publicField(_ArtifactReferenceSchema, "ARTIFACT_PROPS_SCHEMA", {
|
|
|
1278
1409
|
required: ["artifact_id", "task_id"]
|
|
1279
1410
|
});
|
|
1280
1411
|
var ArtifactReferenceSchema = _ArtifactReferenceSchema;
|
|
1281
|
-
var
|
|
1412
|
+
var logger5 = agentsCore.getLogger("ModelFactory");
|
|
1282
1413
|
var _ModelFactory = class _ModelFactory {
|
|
1414
|
+
/**
|
|
1415
|
+
* Create a provider instance with custom configuration
|
|
1416
|
+
*/
|
|
1417
|
+
static createProvider(provider, config2) {
|
|
1418
|
+
switch (provider) {
|
|
1419
|
+
case "anthropic":
|
|
1420
|
+
return anthropic.createAnthropic(config2);
|
|
1421
|
+
case "openai":
|
|
1422
|
+
return openai.createOpenAI(config2);
|
|
1423
|
+
case "google":
|
|
1424
|
+
return google.createGoogleGenerativeAI(config2);
|
|
1425
|
+
default:
|
|
1426
|
+
throw new Error(`Unsupported provider: ${provider}`);
|
|
1427
|
+
}
|
|
1428
|
+
}
|
|
1429
|
+
/**
|
|
1430
|
+
* Extract provider configuration from providerOptions
|
|
1431
|
+
* Only includes settings that go to the provider constructor (baseURL, apiKey, etc.)
|
|
1432
|
+
*/
|
|
1433
|
+
static extractProviderConfig(providerOptions) {
|
|
1434
|
+
if (!providerOptions) {
|
|
1435
|
+
return {};
|
|
1436
|
+
}
|
|
1437
|
+
const providerConfig = {};
|
|
1438
|
+
if (providerOptions.baseUrl || providerOptions.baseURL) {
|
|
1439
|
+
providerConfig.baseURL = providerOptions.baseUrl || providerOptions.baseURL;
|
|
1440
|
+
}
|
|
1441
|
+
if (providerOptions.gateway) {
|
|
1442
|
+
Object.assign(providerConfig, providerOptions.gateway);
|
|
1443
|
+
}
|
|
1444
|
+
return providerConfig;
|
|
1445
|
+
}
|
|
1283
1446
|
/**
|
|
1284
1447
|
* Create a language model instance from configuration
|
|
1285
1448
|
* Throws error if no config provided - models must be configured at project level
|
|
@@ -1293,7 +1456,7 @@ var _ModelFactory = class _ModelFactory {
|
|
|
1293
1456
|
const modelSettings = config2;
|
|
1294
1457
|
const modelString = modelSettings.model.trim();
|
|
1295
1458
|
const { provider, modelName } = _ModelFactory.parseModelString(modelString);
|
|
1296
|
-
|
|
1459
|
+
logger5.debug(
|
|
1297
1460
|
{
|
|
1298
1461
|
provider,
|
|
1299
1462
|
model: modelName,
|
|
@@ -1302,49 +1465,40 @@ var _ModelFactory = class _ModelFactory {
|
|
|
1302
1465
|
},
|
|
1303
1466
|
"Creating language model from config"
|
|
1304
1467
|
);
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
model: modelName,
|
|
1321
|
-
error: error instanceof Error ? error.message : "Unknown error"
|
|
1322
|
-
},
|
|
1323
|
-
"Failed to create model"
|
|
1324
|
-
);
|
|
1325
|
-
throw new Error(
|
|
1326
|
-
`Failed to create model ${modelString}: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
1327
|
-
);
|
|
1468
|
+
const providerConfig = _ModelFactory.extractProviderConfig(modelSettings.providerOptions);
|
|
1469
|
+
if (Object.keys(providerConfig).length > 0) {
|
|
1470
|
+
logger5.info({ config: providerConfig }, `Applying custom ${provider} provider configuration`);
|
|
1471
|
+
const customProvider = _ModelFactory.createProvider(provider, providerConfig);
|
|
1472
|
+
return customProvider.languageModel(modelName);
|
|
1473
|
+
}
|
|
1474
|
+
switch (provider) {
|
|
1475
|
+
case "anthropic":
|
|
1476
|
+
return anthropic.anthropic(modelName);
|
|
1477
|
+
case "openai":
|
|
1478
|
+
return openai.openai(modelName);
|
|
1479
|
+
case "google":
|
|
1480
|
+
return google.google(modelName);
|
|
1481
|
+
default:
|
|
1482
|
+
throw new Error(`Unsupported provider: ${provider}`);
|
|
1328
1483
|
}
|
|
1329
1484
|
}
|
|
1330
1485
|
/**
|
|
1331
1486
|
* Parse model string to extract provider and model name
|
|
1332
|
-
* Examples: "anthropic/claude-4
|
|
1333
|
-
* "claude-4
|
|
1487
|
+
* Examples: "anthropic/claude-sonnet-4" -> { provider: "anthropic", modelName: "claude-sonnet-4" }
|
|
1488
|
+
* "claude-sonnet-4" -> { provider: "anthropic", modelName: "claude-sonnet-4" } (default to anthropic)
|
|
1334
1489
|
*/
|
|
1335
1490
|
static parseModelString(modelString) {
|
|
1336
1491
|
if (modelString.includes("/")) {
|
|
1337
1492
|
const [provider, ...modelParts] = modelString.split("/");
|
|
1338
1493
|
const normalizedProvider = provider.toLowerCase();
|
|
1339
1494
|
if (!_ModelFactory.SUPPORTED_PROVIDERS.includes(normalizedProvider)) {
|
|
1340
|
-
|
|
1495
|
+
logger5.error(
|
|
1341
1496
|
{ provider: normalizedProvider, modelName: modelParts.join("/") },
|
|
1342
1497
|
"Unsupported provider detected, falling back to anthropic"
|
|
1343
1498
|
);
|
|
1344
|
-
|
|
1345
|
-
provider:
|
|
1346
|
-
|
|
1347
|
-
};
|
|
1499
|
+
throw new Error(
|
|
1500
|
+
`Unsupported provider: ${normalizedProvider}. Please provide a model in the format of provider/model-name.`
|
|
1501
|
+
);
|
|
1348
1502
|
}
|
|
1349
1503
|
return {
|
|
1350
1504
|
provider: normalizedProvider,
|
|
@@ -1352,51 +1506,9 @@ var _ModelFactory = class _ModelFactory {
|
|
|
1352
1506
|
// In case model name has slashes
|
|
1353
1507
|
};
|
|
1354
1508
|
}
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
};
|
|
1359
|
-
}
|
|
1360
|
-
/**
|
|
1361
|
-
* Create an Anthropic model instance
|
|
1362
|
-
*/
|
|
1363
|
-
static createAnthropicModel(modelName, providerOptions) {
|
|
1364
|
-
const anthropicConfig = {};
|
|
1365
|
-
if (providerOptions?.baseUrl || providerOptions?.baseURL) {
|
|
1366
|
-
anthropicConfig.baseURL = providerOptions.baseUrl || providerOptions.baseURL;
|
|
1367
|
-
}
|
|
1368
|
-
if (providerOptions?.gateway) {
|
|
1369
|
-
logger4.info(
|
|
1370
|
-
{ gateway: providerOptions.gateway },
|
|
1371
|
-
"Setting up AI Gateway for Anthropic model"
|
|
1372
|
-
);
|
|
1373
|
-
Object.assign(anthropicConfig, providerOptions.gateway);
|
|
1374
|
-
}
|
|
1375
|
-
if (Object.keys(anthropicConfig).length > 0) {
|
|
1376
|
-
logger4.info({ config: anthropicConfig }, "Applying custom Anthropic provider configuration");
|
|
1377
|
-
const provider = anthropic.createAnthropic(anthropicConfig);
|
|
1378
|
-
return provider(modelName);
|
|
1379
|
-
}
|
|
1380
|
-
return anthropic.anthropic(modelName);
|
|
1381
|
-
}
|
|
1382
|
-
/**
|
|
1383
|
-
* Create an OpenAI model instance
|
|
1384
|
-
*/
|
|
1385
|
-
static createOpenAIModel(modelName, providerOptions) {
|
|
1386
|
-
const openaiConfig = {};
|
|
1387
|
-
if (providerOptions?.baseUrl || providerOptions?.baseURL) {
|
|
1388
|
-
openaiConfig.baseURL = providerOptions.baseUrl || providerOptions.baseURL;
|
|
1389
|
-
}
|
|
1390
|
-
if (providerOptions?.gateway) {
|
|
1391
|
-
logger4.info({ gateway: providerOptions.gateway }, "Setting up AI Gateway for OpenAI model");
|
|
1392
|
-
Object.assign(openaiConfig, providerOptions.gateway);
|
|
1393
|
-
}
|
|
1394
|
-
if (Object.keys(openaiConfig).length > 0) {
|
|
1395
|
-
logger4.info({ config: openaiConfig }, "Applying custom OpenAI provider configuration");
|
|
1396
|
-
const provider = openai.createOpenAI(openaiConfig);
|
|
1397
|
-
return provider(modelName);
|
|
1398
|
-
}
|
|
1399
|
-
return openai.openai(modelName);
|
|
1509
|
+
throw new Error(
|
|
1510
|
+
`Invalid model provided: ${modelString}. Please provide a model in the format of provider/model-name.`
|
|
1511
|
+
);
|
|
1400
1512
|
}
|
|
1401
1513
|
/**
|
|
1402
1514
|
* Get generation parameters from provider options
|
|
@@ -1421,7 +1533,7 @@ var _ModelFactory = class _ModelFactory {
|
|
|
1421
1533
|
* Includes maxDuration if specified in provider options (in seconds, following Vercel standard)
|
|
1422
1534
|
*/
|
|
1423
1535
|
static prepareGenerationConfig(modelSettings) {
|
|
1424
|
-
const modelString = modelSettings?.model?.trim()
|
|
1536
|
+
const modelString = modelSettings?.model?.trim();
|
|
1425
1537
|
const model = _ModelFactory.createModel({
|
|
1426
1538
|
model: modelString,
|
|
1427
1539
|
providerOptions: modelSettings?.providerOptions
|
|
@@ -1462,7 +1574,7 @@ var _ModelFactory = class _ModelFactory {
|
|
|
1462
1574
|
/**
|
|
1463
1575
|
* Supported providers for security validation
|
|
1464
1576
|
*/
|
|
1465
|
-
__publicField(_ModelFactory, "SUPPORTED_PROVIDERS", ["anthropic", "openai"]);
|
|
1577
|
+
__publicField(_ModelFactory, "SUPPORTED_PROVIDERS", ["anthropic", "openai", "google"]);
|
|
1466
1578
|
var ModelFactory = _ModelFactory;
|
|
1467
1579
|
|
|
1468
1580
|
// src/utils/graph-session.ts
|
|
@@ -1486,7 +1598,7 @@ function unregisterStreamHelper(requestId2) {
|
|
|
1486
1598
|
}
|
|
1487
1599
|
|
|
1488
1600
|
// src/utils/graph-session.ts
|
|
1489
|
-
var
|
|
1601
|
+
var logger6 = agentsCore.getLogger("GraphSession");
|
|
1490
1602
|
var GraphSession = class {
|
|
1491
1603
|
// Track scheduled timeouts for cleanup
|
|
1492
1604
|
constructor(sessionId, messageId, graphId, tenantId, projectId) {
|
|
@@ -1510,7 +1622,7 @@ var GraphSession = class {
|
|
|
1510
1622
|
__publicField(this, "MAX_PENDING_ARTIFACTS", 100);
|
|
1511
1623
|
// Prevent unbounded growth
|
|
1512
1624
|
__publicField(this, "scheduledTimeouts");
|
|
1513
|
-
|
|
1625
|
+
logger6.debug({ sessionId, messageId, graphId }, "GraphSession created");
|
|
1514
1626
|
}
|
|
1515
1627
|
/**
|
|
1516
1628
|
* Initialize status updates for this session
|
|
@@ -1524,15 +1636,15 @@ var GraphSession = class {
|
|
|
1524
1636
|
summarizerModel,
|
|
1525
1637
|
baseModel,
|
|
1526
1638
|
config: {
|
|
1527
|
-
numEvents: config2.numEvents ||
|
|
1528
|
-
timeInSeconds: config2.timeInSeconds ||
|
|
1639
|
+
numEvents: config2.numEvents || 1,
|
|
1640
|
+
timeInSeconds: config2.timeInSeconds || 2,
|
|
1529
1641
|
...config2
|
|
1530
1642
|
}
|
|
1531
1643
|
};
|
|
1532
1644
|
if (this.statusUpdateState.config.timeInSeconds) {
|
|
1533
1645
|
this.statusUpdateTimer = setInterval(async () => {
|
|
1534
1646
|
if (!this.statusUpdateState || this.isEnded) {
|
|
1535
|
-
|
|
1647
|
+
logger6.debug(
|
|
1536
1648
|
{ sessionId: this.sessionId },
|
|
1537
1649
|
"Timer triggered but session already cleaned up or ended"
|
|
1538
1650
|
);
|
|
@@ -1544,7 +1656,7 @@ var GraphSession = class {
|
|
|
1544
1656
|
}
|
|
1545
1657
|
await this.checkAndSendTimeBasedUpdate();
|
|
1546
1658
|
}, this.statusUpdateState.config.timeInSeconds * 1e3);
|
|
1547
|
-
|
|
1659
|
+
logger6.info(
|
|
1548
1660
|
{
|
|
1549
1661
|
sessionId: this.sessionId,
|
|
1550
1662
|
intervalMs: this.statusUpdateState.config.timeInSeconds * 1e3
|
|
@@ -1558,7 +1670,7 @@ var GraphSession = class {
|
|
|
1558
1670
|
*/
|
|
1559
1671
|
recordEvent(eventType, agentId, data) {
|
|
1560
1672
|
if (this.isEnded) {
|
|
1561
|
-
|
|
1673
|
+
logger6.debug(
|
|
1562
1674
|
{
|
|
1563
1675
|
sessionId: this.sessionId,
|
|
1564
1676
|
eventType,
|
|
@@ -1578,7 +1690,7 @@ var GraphSession = class {
|
|
|
1578
1690
|
if (eventType === "artifact_saved" && data.pendingGeneration) {
|
|
1579
1691
|
const artifactId = data.artifactId;
|
|
1580
1692
|
if (this.pendingArtifacts.size >= this.MAX_PENDING_ARTIFACTS) {
|
|
1581
|
-
|
|
1693
|
+
logger6.warn(
|
|
1582
1694
|
{
|
|
1583
1695
|
sessionId: this.sessionId,
|
|
1584
1696
|
artifactId,
|
|
@@ -1599,7 +1711,7 @@ var GraphSession = class {
|
|
|
1599
1711
|
this.artifactProcessingErrors.set(artifactId, errorCount);
|
|
1600
1712
|
if (errorCount >= this.MAX_ARTIFACT_RETRIES) {
|
|
1601
1713
|
this.pendingArtifacts.delete(artifactId);
|
|
1602
|
-
|
|
1714
|
+
logger6.error(
|
|
1603
1715
|
{
|
|
1604
1716
|
sessionId: this.sessionId,
|
|
1605
1717
|
artifactId,
|
|
@@ -1611,7 +1723,7 @@ var GraphSession = class {
|
|
|
1611
1723
|
"Artifact processing failed after max retries, giving up"
|
|
1612
1724
|
);
|
|
1613
1725
|
} else {
|
|
1614
|
-
|
|
1726
|
+
logger6.warn(
|
|
1615
1727
|
{
|
|
1616
1728
|
sessionId: this.sessionId,
|
|
1617
1729
|
artifactId,
|
|
@@ -1633,14 +1745,14 @@ var GraphSession = class {
|
|
|
1633
1745
|
*/
|
|
1634
1746
|
checkStatusUpdates() {
|
|
1635
1747
|
if (this.isEnded) {
|
|
1636
|
-
|
|
1748
|
+
logger6.debug(
|
|
1637
1749
|
{ sessionId: this.sessionId },
|
|
1638
1750
|
"Session has ended - skipping status update check"
|
|
1639
1751
|
);
|
|
1640
1752
|
return;
|
|
1641
1753
|
}
|
|
1642
1754
|
if (!this.statusUpdateState) {
|
|
1643
|
-
|
|
1755
|
+
logger6.debug({ sessionId: this.sessionId }, "No status update state - skipping check");
|
|
1644
1756
|
return;
|
|
1645
1757
|
}
|
|
1646
1758
|
const statusUpdateState = this.statusUpdateState;
|
|
@@ -1651,11 +1763,11 @@ var GraphSession = class {
|
|
|
1651
1763
|
*/
|
|
1652
1764
|
async checkAndSendTimeBasedUpdate() {
|
|
1653
1765
|
if (this.isEnded) {
|
|
1654
|
-
|
|
1766
|
+
logger6.debug({ sessionId: this.sessionId }, "Session has ended - skipping time-based update");
|
|
1655
1767
|
return;
|
|
1656
1768
|
}
|
|
1657
1769
|
if (!this.statusUpdateState) {
|
|
1658
|
-
|
|
1770
|
+
logger6.debug(
|
|
1659
1771
|
{ sessionId: this.sessionId },
|
|
1660
1772
|
"No status updates configured for time-based check"
|
|
1661
1773
|
);
|
|
@@ -1668,7 +1780,7 @@ var GraphSession = class {
|
|
|
1668
1780
|
try {
|
|
1669
1781
|
await this.generateAndSendUpdate();
|
|
1670
1782
|
} catch (error) {
|
|
1671
|
-
|
|
1783
|
+
logger6.error(
|
|
1672
1784
|
{
|
|
1673
1785
|
sessionId: this.sessionId,
|
|
1674
1786
|
error: error instanceof Error ? error.message : "Unknown error"
|
|
@@ -1761,29 +1873,29 @@ var GraphSession = class {
|
|
|
1761
1873
|
*/
|
|
1762
1874
|
async generateAndSendUpdate() {
|
|
1763
1875
|
if (this.isEnded) {
|
|
1764
|
-
|
|
1876
|
+
logger6.debug({ sessionId: this.sessionId }, "Session has ended - not generating update");
|
|
1765
1877
|
return;
|
|
1766
1878
|
}
|
|
1767
1879
|
if (this.isTextStreaming) {
|
|
1768
|
-
|
|
1880
|
+
logger6.debug(
|
|
1769
1881
|
{ sessionId: this.sessionId },
|
|
1770
1882
|
"Text is currently streaming - skipping status update"
|
|
1771
1883
|
);
|
|
1772
1884
|
return;
|
|
1773
1885
|
}
|
|
1774
1886
|
if (this.isGeneratingUpdate) {
|
|
1775
|
-
|
|
1887
|
+
logger6.debug(
|
|
1776
1888
|
{ sessionId: this.sessionId },
|
|
1777
1889
|
"Update already in progress - skipping duplicate generation"
|
|
1778
1890
|
);
|
|
1779
1891
|
return;
|
|
1780
1892
|
}
|
|
1781
1893
|
if (!this.statusUpdateState) {
|
|
1782
|
-
|
|
1894
|
+
logger6.warn({ sessionId: this.sessionId }, "No status update state - cannot generate update");
|
|
1783
1895
|
return;
|
|
1784
1896
|
}
|
|
1785
1897
|
if (!this.graphId) {
|
|
1786
|
-
|
|
1898
|
+
logger6.warn({ sessionId: this.sessionId }, "No graph ID - cannot generate update");
|
|
1787
1899
|
return;
|
|
1788
1900
|
}
|
|
1789
1901
|
const newEventCount = this.events.length - this.statusUpdateState.lastEventCount;
|
|
@@ -1796,7 +1908,7 @@ var GraphSession = class {
|
|
|
1796
1908
|
try {
|
|
1797
1909
|
const streamHelper = getStreamHelper(this.sessionId);
|
|
1798
1910
|
if (!streamHelper) {
|
|
1799
|
-
|
|
1911
|
+
logger6.warn(
|
|
1800
1912
|
{ sessionId: this.sessionId },
|
|
1801
1913
|
"No stream helper found - cannot send status update"
|
|
1802
1914
|
);
|
|
@@ -1817,7 +1929,7 @@ var GraphSession = class {
|
|
|
1817
1929
|
if (result.operations && result.operations.length > 0) {
|
|
1818
1930
|
for (const op of result.operations) {
|
|
1819
1931
|
if (!op || !op.type || !op.data || Object.keys(op.data).length === 0) {
|
|
1820
|
-
|
|
1932
|
+
logger6.warn(
|
|
1821
1933
|
{
|
|
1822
1934
|
sessionId: this.sessionId,
|
|
1823
1935
|
operation: op
|
|
@@ -1870,7 +1982,7 @@ var GraphSession = class {
|
|
|
1870
1982
|
this.previousSummaries.shift();
|
|
1871
1983
|
}
|
|
1872
1984
|
if (!operation || !operation.type || !operation.ctx) {
|
|
1873
|
-
|
|
1985
|
+
logger6.warn(
|
|
1874
1986
|
{
|
|
1875
1987
|
sessionId: this.sessionId,
|
|
1876
1988
|
operation
|
|
@@ -1885,7 +1997,7 @@ var GraphSession = class {
|
|
|
1885
1997
|
this.statusUpdateState.lastEventCount = this.events.length;
|
|
1886
1998
|
}
|
|
1887
1999
|
} catch (error) {
|
|
1888
|
-
|
|
2000
|
+
logger6.error(
|
|
1889
2001
|
{
|
|
1890
2002
|
sessionId: this.sessionId,
|
|
1891
2003
|
error: error instanceof Error ? error.message : "Unknown error",
|
|
@@ -1923,7 +2035,7 @@ var GraphSession = class {
|
|
|
1923
2035
|
this.releaseUpdateLock();
|
|
1924
2036
|
}
|
|
1925
2037
|
} catch (error) {
|
|
1926
|
-
|
|
2038
|
+
logger6.error(
|
|
1927
2039
|
{
|
|
1928
2040
|
sessionId: this.sessionId,
|
|
1929
2041
|
error: error instanceof Error ? error.message : "Unknown error"
|
|
@@ -2000,7 +2112,7 @@ User's Question/Context:
|
|
|
2000
2112
|
${conversationHistory}
|
|
2001
2113
|
` : "";
|
|
2002
2114
|
} catch (error) {
|
|
2003
|
-
|
|
2115
|
+
logger6.warn(
|
|
2004
2116
|
{ sessionId: this.sessionId, error },
|
|
2005
2117
|
"Failed to fetch conversation history for status update"
|
|
2006
2118
|
);
|
|
@@ -2052,7 +2164,7 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
|
|
|
2052
2164
|
return text.trim();
|
|
2053
2165
|
} catch (error) {
|
|
2054
2166
|
agentsCore.setSpanWithError(span, error);
|
|
2055
|
-
|
|
2167
|
+
logger6.error({ error }, "Failed to generate summary, using fallback");
|
|
2056
2168
|
return this.generateFallbackSummary(newEvents, elapsedTime);
|
|
2057
2169
|
} finally {
|
|
2058
2170
|
span.end();
|
|
@@ -2098,7 +2210,7 @@ User's Question/Context:
|
|
|
2098
2210
|
${conversationHistory}
|
|
2099
2211
|
` : "";
|
|
2100
2212
|
} catch (error) {
|
|
2101
|
-
|
|
2213
|
+
logger6.warn(
|
|
2102
2214
|
{ sessionId: this.sessionId, error },
|
|
2103
2215
|
"Failed to fetch conversation history for structured status update"
|
|
2104
2216
|
);
|
|
@@ -2141,9 +2253,11 @@ Rules:
|
|
|
2141
2253
|
- Labels MUST contain the ACTUAL information discovered ("Found X", "Learned Y", "Discovered Z requires A")
|
|
2142
2254
|
- DO NOT use action words like "Searching", "Processing", "Analyzing" - state what was FOUND
|
|
2143
2255
|
- Include specific details, numbers, requirements, or insights discovered
|
|
2144
|
-
- You are ONE AI
|
|
2145
|
-
-
|
|
2146
|
-
-
|
|
2256
|
+
- You are ONE unified AI system - NEVER mention agents, transfers, delegations, or routing
|
|
2257
|
+
- CRITICAL: NEVER use the words "transfer", "delegation", "agent", "routing", or any internal system terminology in labels
|
|
2258
|
+
- Present all operations as seamless actions by a single system
|
|
2259
|
+
- Anonymize all internal operations so that the information appears descriptive and USER FRIENDLY. HIDE ALL INTERNAL OPERATIONS!
|
|
2260
|
+
- Bad examples: "Transferring to search agent", "Delegating task", "Routing request", "Processing request", or not using the no_relevant_updates
|
|
2147
2261
|
- Good examples: "Slack bot needs admin privileges", "Found 3-step OAuth flow required", "Channel limit is 500 per workspace", or use the no_relevant_updates component if nothing new to report.
|
|
2148
2262
|
|
|
2149
2263
|
REMEMBER YOU CAN ONLY USE 'no_relevant_updates' ALONE! IT CANNOT BE CONCATENATED WITH OTHER STATUS UPDATES!
|
|
@@ -2197,7 +2311,7 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
|
|
|
2197
2311
|
return { operations };
|
|
2198
2312
|
} catch (error) {
|
|
2199
2313
|
agentsCore.setSpanWithError(span, error);
|
|
2200
|
-
|
|
2314
|
+
logger6.error({ error }, "Failed to generate structured update, using fallback");
|
|
2201
2315
|
return { operations: [] };
|
|
2202
2316
|
} finally {
|
|
2203
2317
|
span.end();
|
|
@@ -2304,8 +2418,7 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
|
|
|
2304
2418
|
case "transfer": {
|
|
2305
2419
|
const data = event.data;
|
|
2306
2420
|
activities.push(
|
|
2307
|
-
`\u{1F504} **
|
|
2308
|
-
${data.reason ? `Reason: ${data.reason}` : "Control transfer"}
|
|
2421
|
+
`\u{1F504} **Continuing**: ${data.reason || "Processing request"}
|
|
2309
2422
|
${data.context ? `Context: ${JSON.stringify(data.context, null, 2)}` : ""}`
|
|
2310
2423
|
);
|
|
2311
2424
|
break;
|
|
@@ -2313,8 +2426,7 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
|
|
|
2313
2426
|
case "delegation_sent": {
|
|
2314
2427
|
const data = event.data;
|
|
2315
2428
|
activities.push(
|
|
2316
|
-
`\u{1F4E4} **
|
|
2317
|
-
Task: ${data.taskDescription}
|
|
2429
|
+
`\u{1F4E4} **Processing**: ${data.taskDescription}
|
|
2318
2430
|
${data.context ? `Context: ${JSON.stringify(data.context, null, 2)}` : ""}`
|
|
2319
2431
|
);
|
|
2320
2432
|
break;
|
|
@@ -2322,7 +2434,7 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
|
|
|
2322
2434
|
case "delegation_returned": {
|
|
2323
2435
|
const data = event.data;
|
|
2324
2436
|
activities.push(
|
|
2325
|
-
`\u{1F4E5} **
|
|
2437
|
+
`\u{1F4E5} **Completed subtask**
|
|
2326
2438
|
Result: ${JSON.stringify(data.result, null, 2)}`
|
|
2327
2439
|
);
|
|
2328
2440
|
break;
|
|
@@ -2341,16 +2453,16 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
|
|
|
2341
2453
|
case "agent_reasoning": {
|
|
2342
2454
|
const data = event.data;
|
|
2343
2455
|
activities.push(
|
|
2344
|
-
`\u2699\uFE0F **
|
|
2345
|
-
|
|
2456
|
+
`\u2699\uFE0F **Analyzing request**
|
|
2457
|
+
Details: ${JSON.stringify(data.parts, null, 2)}`
|
|
2346
2458
|
);
|
|
2347
2459
|
break;
|
|
2348
2460
|
}
|
|
2349
2461
|
case "agent_generate": {
|
|
2350
2462
|
const data = event.data;
|
|
2351
2463
|
activities.push(
|
|
2352
|
-
`\u2699\uFE0F **
|
|
2353
|
-
|
|
2464
|
+
`\u2699\uFE0F **Preparing response**
|
|
2465
|
+
Details: ${JSON.stringify(data.parts, null, 2)}`
|
|
2354
2466
|
);
|
|
2355
2467
|
break;
|
|
2356
2468
|
}
|
|
@@ -2524,7 +2636,7 @@ Make it specific and relevant.`;
|
|
|
2524
2636
|
taskId: artifactData.taskId,
|
|
2525
2637
|
artifacts: [artifactToSave]
|
|
2526
2638
|
});
|
|
2527
|
-
|
|
2639
|
+
logger6.info(
|
|
2528
2640
|
{
|
|
2529
2641
|
sessionId: this.sessionId,
|
|
2530
2642
|
artifactId: artifactData.artifactId,
|
|
@@ -2541,7 +2653,7 @@ Make it specific and relevant.`;
|
|
|
2541
2653
|
span.setStatus({ code: api.SpanStatusCode.OK });
|
|
2542
2654
|
} catch (error) {
|
|
2543
2655
|
agentsCore.setSpanWithError(span, error);
|
|
2544
|
-
|
|
2656
|
+
logger6.error(
|
|
2545
2657
|
{
|
|
2546
2658
|
sessionId: this.sessionId,
|
|
2547
2659
|
artifactId: artifactData.artifactId,
|
|
@@ -2577,7 +2689,7 @@ Make it specific and relevant.`;
|
|
|
2577
2689
|
taskId: artifactData.taskId,
|
|
2578
2690
|
artifacts: [fallbackArtifact]
|
|
2579
2691
|
});
|
|
2580
|
-
|
|
2692
|
+
logger6.info(
|
|
2581
2693
|
{
|
|
2582
2694
|
sessionId: this.sessionId,
|
|
2583
2695
|
artifactId: artifactData.artifactId
|
|
@@ -2586,7 +2698,7 @@ Make it specific and relevant.`;
|
|
|
2586
2698
|
);
|
|
2587
2699
|
}
|
|
2588
2700
|
} catch (fallbackError) {
|
|
2589
|
-
|
|
2701
|
+
logger6.error(
|
|
2590
2702
|
{
|
|
2591
2703
|
sessionId: this.sessionId,
|
|
2592
2704
|
artifactId: artifactData.artifactId,
|
|
@@ -2613,7 +2725,7 @@ var GraphSessionManager = class {
|
|
|
2613
2725
|
const sessionId = messageId;
|
|
2614
2726
|
const session = new GraphSession(sessionId, messageId, graphId, tenantId, projectId);
|
|
2615
2727
|
this.sessions.set(sessionId, session);
|
|
2616
|
-
|
|
2728
|
+
logger6.info({ sessionId, messageId, graphId, tenantId, projectId }, "GraphSession created");
|
|
2617
2729
|
return sessionId;
|
|
2618
2730
|
}
|
|
2619
2731
|
/**
|
|
@@ -2624,7 +2736,7 @@ var GraphSessionManager = class {
|
|
|
2624
2736
|
if (session) {
|
|
2625
2737
|
session.initializeStatusUpdates(config2, summarizerModel);
|
|
2626
2738
|
} else {
|
|
2627
|
-
|
|
2739
|
+
logger6.error(
|
|
2628
2740
|
{
|
|
2629
2741
|
sessionId,
|
|
2630
2742
|
availableSessions: Array.from(this.sessions.keys())
|
|
@@ -2645,7 +2757,7 @@ var GraphSessionManager = class {
|
|
|
2645
2757
|
recordEvent(sessionId, eventType, agentId, data) {
|
|
2646
2758
|
const session = this.sessions.get(sessionId);
|
|
2647
2759
|
if (!session) {
|
|
2648
|
-
|
|
2760
|
+
logger6.warn({ sessionId }, "Attempted to record event in non-existent session");
|
|
2649
2761
|
return;
|
|
2650
2762
|
}
|
|
2651
2763
|
session.recordEvent(eventType, agentId, data);
|
|
@@ -2656,12 +2768,12 @@ var GraphSessionManager = class {
|
|
|
2656
2768
|
endSession(sessionId) {
|
|
2657
2769
|
const session = this.sessions.get(sessionId);
|
|
2658
2770
|
if (!session) {
|
|
2659
|
-
|
|
2771
|
+
logger6.warn({ sessionId }, "Attempted to end non-existent session");
|
|
2660
2772
|
return [];
|
|
2661
2773
|
}
|
|
2662
2774
|
const events = session.getEvents();
|
|
2663
2775
|
const summary = session.getSummary();
|
|
2664
|
-
|
|
2776
|
+
logger6.info({ sessionId, summary }, "GraphSession ended");
|
|
2665
2777
|
session.cleanup();
|
|
2666
2778
|
this.sessions.delete(sessionId);
|
|
2667
2779
|
return events;
|
|
@@ -2690,7 +2802,7 @@ var graphSessionManager = new GraphSessionManager();
|
|
|
2690
2802
|
|
|
2691
2803
|
// src/utils/artifact-parser.ts
|
|
2692
2804
|
init_dbClient();
|
|
2693
|
-
var
|
|
2805
|
+
var logger7 = agentsCore.getLogger("ArtifactParser");
|
|
2694
2806
|
var _ArtifactParser = class _ArtifactParser {
|
|
2695
2807
|
constructor(tenantId) {
|
|
2696
2808
|
this.tenantId = tenantId;
|
|
@@ -2706,9 +2818,7 @@ var _ArtifactParser = class _ArtifactParser {
|
|
|
2706
2818
|
* More robust detection that handles streaming fragments
|
|
2707
2819
|
*/
|
|
2708
2820
|
hasIncompleteArtifact(text) {
|
|
2709
|
-
return
|
|
2710
|
-
text
|
|
2711
|
-
) || /^.*<artifact:ref(?:[^>]*)$/.test(text) || // Incomplete artifact:ref at end
|
|
2821
|
+
return /<(a(r(t(i(f(a(c(t(:?(r(e(f)?)?)?)?)?)?)?)?)?)?)?)?$/.test(text) || /<artifact:ref[^>]+$/.test(text) || // Incomplete artifact ref at end
|
|
2712
2822
|
this.findSafeTextBoundary(text) < text.length;
|
|
2713
2823
|
}
|
|
2714
2824
|
/**
|
|
@@ -2717,10 +2827,10 @@ var _ArtifactParser = class _ArtifactParser {
|
|
|
2717
2827
|
*/
|
|
2718
2828
|
findSafeTextBoundary(text) {
|
|
2719
2829
|
const endPatterns = [
|
|
2720
|
-
|
|
2830
|
+
/<artifact:ref(?![^>]*\/>).*$/,
|
|
2721
2831
|
// artifact:ref that doesn't end with />
|
|
2722
|
-
|
|
2723
|
-
//
|
|
2832
|
+
/<(a(r(t(i(f(a(c(t(:?(r(e(f)?)?)?)?)?)?)?)?)?)?)?)?$/
|
|
2833
|
+
// Any partial artifact pattern at end
|
|
2724
2834
|
];
|
|
2725
2835
|
for (const pattern of endPatterns) {
|
|
2726
2836
|
const match = text.match(pattern);
|
|
@@ -2756,7 +2866,7 @@ var _ArtifactParser = class _ArtifactParser {
|
|
|
2756
2866
|
id: taskId
|
|
2757
2867
|
});
|
|
2758
2868
|
if (!task) {
|
|
2759
|
-
|
|
2869
|
+
logger7.warn({ taskId }, "Task not found when fetching artifacts");
|
|
2760
2870
|
continue;
|
|
2761
2871
|
}
|
|
2762
2872
|
const taskArtifacts = await agentsCore.getLedgerArtifacts(dbClient_default)({
|
|
@@ -2768,9 +2878,9 @@ var _ArtifactParser = class _ArtifactParser {
|
|
|
2768
2878
|
artifacts.set(key, artifact);
|
|
2769
2879
|
}
|
|
2770
2880
|
}
|
|
2771
|
-
|
|
2881
|
+
logger7.debug({ contextId, count: artifacts.size }, "Loaded context artifacts");
|
|
2772
2882
|
} catch (error) {
|
|
2773
|
-
|
|
2883
|
+
logger7.error({ error, contextId }, "Error loading context artifacts");
|
|
2774
2884
|
}
|
|
2775
2885
|
return artifacts;
|
|
2776
2886
|
}
|
|
@@ -2873,7 +2983,7 @@ var _ArtifactParser = class _ArtifactParser {
|
|
|
2873
2983
|
id: taskId
|
|
2874
2984
|
});
|
|
2875
2985
|
if (!task) {
|
|
2876
|
-
|
|
2986
|
+
logger7.warn({ taskId }, "Task not found when fetching artifact");
|
|
2877
2987
|
return null;
|
|
2878
2988
|
}
|
|
2879
2989
|
const artifacts = await agentsCore.getLedgerArtifacts(dbClient_default)({
|
|
@@ -2885,7 +2995,7 @@ var _ArtifactParser = class _ArtifactParser {
|
|
|
2885
2995
|
return this.formatArtifactData(artifacts[0], artifactId, taskId);
|
|
2886
2996
|
}
|
|
2887
2997
|
} catch (error) {
|
|
2888
|
-
|
|
2998
|
+
logger7.warn({ artifactId, taskId, error }, "Failed to fetch artifact");
|
|
2889
2999
|
}
|
|
2890
3000
|
return null;
|
|
2891
3001
|
}
|
|
@@ -2921,11 +3031,11 @@ var _ArtifactParser = class _ArtifactParser {
|
|
|
2921
3031
|
__publicField(_ArtifactParser, "ARTIFACT_REGEX", /<artifact:ref\s+id="([^"]*?)"\s+task="([^"]*?)"\s*\/>/gs);
|
|
2922
3032
|
__publicField(_ArtifactParser, "ARTIFACT_CHECK_REGEX", /<artifact:ref\s+(?=.*id="[^"]+")(?=.*task="[^"]+")[^>]*\/>/);
|
|
2923
3033
|
// Regex for catching any partial artifact pattern (< + any prefix of "artifact:ref")
|
|
2924
|
-
__publicField(_ArtifactParser, "INCOMPLETE_ARTIFACT_REGEX", /<(a(r(t(i(f(a(c(t(
|
|
3034
|
+
__publicField(_ArtifactParser, "INCOMPLETE_ARTIFACT_REGEX", /<(a(r(t(i(f(a(c(t(:?(r(e(f)?)?)?)?)?)?)?)?)?)?)?)?$/g);
|
|
2925
3035
|
var ArtifactParser = _ArtifactParser;
|
|
2926
3036
|
|
|
2927
3037
|
// src/utils/incremental-stream-parser.ts
|
|
2928
|
-
var
|
|
3038
|
+
var logger8 = agentsCore.getLogger("IncrementalStreamParser");
|
|
2929
3039
|
var IncrementalStreamParser = class {
|
|
2930
3040
|
constructor(streamHelper, tenantId, contextId) {
|
|
2931
3041
|
__publicField(this, "buffer", "");
|
|
@@ -2985,13 +3095,19 @@ var IncrementalStreamParser = class {
|
|
|
2985
3095
|
if (part.type === "tool-call-delta" && part.toolName === targetToolName) {
|
|
2986
3096
|
const delta = part.argsTextDelta || "";
|
|
2987
3097
|
if (jsonBuffer.length + delta.length > MAX_BUFFER_SIZE) {
|
|
2988
|
-
|
|
3098
|
+
logger8.warn(
|
|
3099
|
+
{ bufferSize: jsonBuffer.length + delta.length, maxSize: MAX_BUFFER_SIZE },
|
|
3100
|
+
"JSON buffer exceeded maximum size, truncating"
|
|
3101
|
+
);
|
|
2989
3102
|
jsonBuffer = jsonBuffer.slice(-MAX_BUFFER_SIZE / 2);
|
|
2990
3103
|
}
|
|
2991
3104
|
jsonBuffer += delta;
|
|
2992
3105
|
for (const char of delta) {
|
|
2993
3106
|
if (componentBuffer.length > MAX_BUFFER_SIZE) {
|
|
2994
|
-
|
|
3107
|
+
logger8.warn(
|
|
3108
|
+
{ bufferSize: componentBuffer.length, maxSize: MAX_BUFFER_SIZE },
|
|
3109
|
+
"Component buffer exceeded maximum size, resetting"
|
|
3110
|
+
);
|
|
2995
3111
|
componentBuffer = "";
|
|
2996
3112
|
depth = 0;
|
|
2997
3113
|
continue;
|
|
@@ -3006,7 +3122,7 @@ var IncrementalStreamParser = class {
|
|
|
3006
3122
|
if (componentMatch) {
|
|
3007
3123
|
const MAX_COMPONENT_SIZE = 1024 * 1024;
|
|
3008
3124
|
if (componentMatch[0].length > MAX_COMPONENT_SIZE) {
|
|
3009
|
-
|
|
3125
|
+
logger8.warn(
|
|
3010
3126
|
{
|
|
3011
3127
|
size: componentMatch[0].length,
|
|
3012
3128
|
maxSize: MAX_COMPONENT_SIZE
|
|
@@ -3019,7 +3135,7 @@ var IncrementalStreamParser = class {
|
|
|
3019
3135
|
try {
|
|
3020
3136
|
const component = JSON.parse(componentMatch[0]);
|
|
3021
3137
|
if (typeof component !== "object" || !component.id) {
|
|
3022
|
-
|
|
3138
|
+
logger8.warn({ component }, "Invalid component structure, skipping");
|
|
3023
3139
|
componentBuffer = "";
|
|
3024
3140
|
continue;
|
|
3025
3141
|
}
|
|
@@ -3032,7 +3148,7 @@ var IncrementalStreamParser = class {
|
|
|
3032
3148
|
componentsStreamed++;
|
|
3033
3149
|
componentBuffer = "";
|
|
3034
3150
|
} catch (e) {
|
|
3035
|
-
|
|
3151
|
+
logger8.debug({ error: e }, "Failed to parse component, continuing to accumulate");
|
|
3036
3152
|
}
|
|
3037
3153
|
}
|
|
3038
3154
|
}
|
|
@@ -3049,7 +3165,7 @@ var IncrementalStreamParser = class {
|
|
|
3049
3165
|
break;
|
|
3050
3166
|
}
|
|
3051
3167
|
}
|
|
3052
|
-
|
|
3168
|
+
logger8.debug({ componentsStreamed }, "Finished streaming components");
|
|
3053
3169
|
}
|
|
3054
3170
|
/**
|
|
3055
3171
|
* Legacy method for backward compatibility - defaults to text processing
|
|
@@ -3193,7 +3309,7 @@ var IncrementalStreamParser = class {
|
|
|
3193
3309
|
};
|
|
3194
3310
|
|
|
3195
3311
|
// src/utils/response-formatter.ts
|
|
3196
|
-
var
|
|
3312
|
+
var logger9 = agentsCore.getLogger("ResponseFormatter");
|
|
3197
3313
|
var ResponseFormatter = class {
|
|
3198
3314
|
constructor(tenantId) {
|
|
3199
3315
|
__publicField(this, "artifactParser");
|
|
@@ -3224,7 +3340,7 @@ var ResponseFormatter = class {
|
|
|
3224
3340
|
return { parts };
|
|
3225
3341
|
} catch (error) {
|
|
3226
3342
|
agentsCore.setSpanWithError(span, error);
|
|
3227
|
-
|
|
3343
|
+
logger9.error({ error, responseObject }, "Error formatting object response");
|
|
3228
3344
|
return {
|
|
3229
3345
|
parts: [{ kind: "data", data: responseObject }]
|
|
3230
3346
|
};
|
|
@@ -3275,7 +3391,7 @@ var ResponseFormatter = class {
|
|
|
3275
3391
|
return { parts };
|
|
3276
3392
|
} catch (error) {
|
|
3277
3393
|
agentsCore.setSpanWithError(span, error);
|
|
3278
|
-
|
|
3394
|
+
logger9.error({ error, responseText }, "Error formatting response");
|
|
3279
3395
|
return { text: responseText };
|
|
3280
3396
|
} finally {
|
|
3281
3397
|
span.end();
|
|
@@ -3320,7 +3436,7 @@ var ResponseFormatter = class {
|
|
|
3320
3436
|
}
|
|
3321
3437
|
}
|
|
3322
3438
|
};
|
|
3323
|
-
var
|
|
3439
|
+
var logger10 = agentsCore.getLogger("ToolSessionManager");
|
|
3324
3440
|
var _ToolSessionManager = class _ToolSessionManager {
|
|
3325
3441
|
// 5 minutes
|
|
3326
3442
|
constructor() {
|
|
@@ -3349,7 +3465,7 @@ var _ToolSessionManager = class _ToolSessionManager {
|
|
|
3349
3465
|
createdAt: Date.now()
|
|
3350
3466
|
};
|
|
3351
3467
|
this.sessions.set(sessionId, session);
|
|
3352
|
-
|
|
3468
|
+
logger10.debug({ sessionId, tenantId, contextId, taskId }, "Created tool session");
|
|
3353
3469
|
return sessionId;
|
|
3354
3470
|
}
|
|
3355
3471
|
/**
|
|
@@ -3358,7 +3474,7 @@ var _ToolSessionManager = class _ToolSessionManager {
|
|
|
3358
3474
|
recordToolResult(sessionId, toolResult) {
|
|
3359
3475
|
const session = this.sessions.get(sessionId);
|
|
3360
3476
|
if (!session) {
|
|
3361
|
-
|
|
3477
|
+
logger10.warn(
|
|
3362
3478
|
{ sessionId, toolCallId: toolResult.toolCallId },
|
|
3363
3479
|
"Tool result recorded for unknown session"
|
|
3364
3480
|
);
|
|
@@ -3372,12 +3488,12 @@ var _ToolSessionManager = class _ToolSessionManager {
|
|
|
3372
3488
|
getToolResult(sessionId, toolCallId) {
|
|
3373
3489
|
const session = this.sessions.get(sessionId);
|
|
3374
3490
|
if (!session) {
|
|
3375
|
-
|
|
3491
|
+
logger10.warn({ sessionId, toolCallId }, "Requested tool result for unknown session");
|
|
3376
3492
|
return void 0;
|
|
3377
3493
|
}
|
|
3378
3494
|
const result = session.toolResults.get(toolCallId);
|
|
3379
3495
|
if (!result) {
|
|
3380
|
-
|
|
3496
|
+
logger10.warn(
|
|
3381
3497
|
{
|
|
3382
3498
|
sessionId,
|
|
3383
3499
|
toolCallId,
|
|
@@ -3416,10 +3532,10 @@ var _ToolSessionManager = class _ToolSessionManager {
|
|
|
3416
3532
|
}
|
|
3417
3533
|
for (const sessionId of expiredSessions) {
|
|
3418
3534
|
this.sessions.delete(sessionId);
|
|
3419
|
-
|
|
3535
|
+
logger10.debug({ sessionId }, "Cleaned up expired tool session");
|
|
3420
3536
|
}
|
|
3421
3537
|
if (expiredSessions.length > 0) {
|
|
3422
|
-
|
|
3538
|
+
logger10.info({ expiredCount: expiredSessions.length }, "Cleaned up expired tool sessions");
|
|
3423
3539
|
}
|
|
3424
3540
|
}
|
|
3425
3541
|
};
|
|
@@ -3428,7 +3544,7 @@ var ToolSessionManager = _ToolSessionManager;
|
|
|
3428
3544
|
var toolSessionManager = ToolSessionManager.getInstance();
|
|
3429
3545
|
|
|
3430
3546
|
// src/agents/artifactTools.ts
|
|
3431
|
-
var
|
|
3547
|
+
var logger11 = agentsCore.getLogger("artifactTools");
|
|
3432
3548
|
function buildKeyNestingMap(data, prefix = "", map = /* @__PURE__ */ new Map()) {
|
|
3433
3549
|
if (typeof data === "object" && data !== null) {
|
|
3434
3550
|
if (Array.isArray(data)) {
|
|
@@ -3531,7 +3647,7 @@ function createPropSelectorsSchema(artifactComponents) {
|
|
|
3531
3647
|
Object.entries(summaryProps.properties).forEach(([propName, propDef]) => {
|
|
3532
3648
|
const propDescription = propDef?.description || propDef?.title || `${propName} property`;
|
|
3533
3649
|
propSchema[propName] = z5__default.default.string().describe(
|
|
3534
|
-
`JMESPath selector for ${propName} (${propDescription}) - summary version, relative to
|
|
3650
|
+
`JMESPath selector for ${propName} (${propDescription}) - summary version, MUST be relative to your baseSelector target level. Access fields WITHIN the items your baseSelector returns.`
|
|
3535
3651
|
);
|
|
3536
3652
|
});
|
|
3537
3653
|
}
|
|
@@ -3543,7 +3659,7 @@ function createPropSelectorsSchema(artifactComponents) {
|
|
|
3543
3659
|
if (!propSchema[propName]) {
|
|
3544
3660
|
const propDescription = propDef?.description || propDef?.title || `${propName} property`;
|
|
3545
3661
|
propSchema[propName] = z5__default.default.string().describe(
|
|
3546
|
-
`JMESPath selector for ${propName} (${propDescription}) -
|
|
3662
|
+
`JMESPath selector for ${propName} (${propDescription}) - MUST be relative to your baseSelector target level. If baseSelector stops at a document, this accesses fields WITHIN that document. Examples: "title", "content.body", "metadata.author"`
|
|
3547
3663
|
);
|
|
3548
3664
|
}
|
|
3549
3665
|
});
|
|
@@ -3557,7 +3673,26 @@ function createPropSelectorsSchema(artifactComponents) {
|
|
|
3557
3673
|
return z5__default.default.union(propSelectorSchemas);
|
|
3558
3674
|
}
|
|
3559
3675
|
return z5__default.default.record(z5__default.default.string(), z5__default.default.string()).describe(
|
|
3560
|
-
|
|
3676
|
+
`Prop selectors mapping schema properties to JMESPath expressions relative to base selector. Each path is relative to the item(s) your baseSelector returns.
|
|
3677
|
+
|
|
3678
|
+
\u{1F3AF} CRITICAL: PropSelectors work ONLY on the data your baseSelector returns!
|
|
3679
|
+
If baseSelector = "result.docs[0]" \u2192 propSelectors access fields INSIDE that doc
|
|
3680
|
+
If baseSelector = "result.docs[0].content[0]" \u2192 propSelectors access fields INSIDE that content item
|
|
3681
|
+
|
|
3682
|
+
\u2705 CORRECT EXAMPLES (paths relative to baseSelector target):
|
|
3683
|
+
\u2022 baseSelector: "result.documents[?type=='article']" \u2192 propSelectors: {"title": "title", "url": "url"}
|
|
3684
|
+
\u2022 baseSelector: "result.content[0].text" \u2192 propSelectors: {"content": "content[0].text", "source": "content[0].source"}
|
|
3685
|
+
\u2022 baseSelector: "result.items" \u2192 propSelectors: {"name": "profile.name", "email": "contact.email"}
|
|
3686
|
+
|
|
3687
|
+
\u274C WRONG EXAMPLES (accessing data not at baseSelector level):
|
|
3688
|
+
\u2022 baseSelector: "result.docs[0].content[0]" \u2192 propSelectors: {"title": "title"} \u2190 title is at doc level, not content level!
|
|
3689
|
+
\u2022 baseSelector: "result.source.content" \u2192 propSelectors: {"title": "content[4].text"} \u2190 baseSelector ends at array, can't index into it!
|
|
3690
|
+
\u2022 baseSelector: "result.items" \u2192 propSelectors: {"title": "documents[0].title"} \u2190 going deeper when baseSelector should handle depth
|
|
3691
|
+
|
|
3692
|
+
\u274C NEVER USE LITERAL VALUES:
|
|
3693
|
+
{"title": "Robert Tran", "url": "https://linkedin.com/..."}
|
|
3694
|
+
|
|
3695
|
+
\u{1F4A1} TIP: Match your baseSelector depth to where the properties you need actually exist!`
|
|
3561
3696
|
);
|
|
3562
3697
|
}
|
|
3563
3698
|
function createInputSchema(artifactComponents) {
|
|
@@ -3566,7 +3701,18 @@ function createInputSchema(artifactComponents) {
|
|
|
3566
3701
|
"EXACT toolCallId from a previous tool execution - copy it exactly from the tool call result. NEVER invent or make up tool call IDs."
|
|
3567
3702
|
),
|
|
3568
3703
|
baseSelector: z5__default.default.string().describe(
|
|
3569
|
-
`JMESPath selector to get to the main data array/object. ALWAYS start with "result."
|
|
3704
|
+
`JMESPath selector to get to the main data array/object. ALWAYS start with "result." That is a mandatory prefix.
|
|
3705
|
+
|
|
3706
|
+
Data structures are COMPLEX and NESTED. Examples:
|
|
3707
|
+
\u2022 "result.content[0].text.content[2]" - parsed JSON in text field
|
|
3708
|
+
\u2022 "result.structuredContent.content[1]" - direct structured data
|
|
3709
|
+
\u2022 "result.data.items[?type=='doc']" - filtered array
|
|
3710
|
+
|
|
3711
|
+
\u{1F6A8} CRITICAL: If you need data from array[4], your baseSelector must END at array[4], NOT at the array itself!
|
|
3712
|
+
\u2705 CORRECT: "result.source.content[4]" \u2192 propSelectors can access fields in that item
|
|
3713
|
+
\u274C WRONG: "result.source.content" \u2192 propSelectors can't use content[4] because baseSelector already selected the array
|
|
3714
|
+
|
|
3715
|
+
\u{1F525} IF YOUR PATH FAILS: READ THE ERROR MESSAGE! It tells you the correct path! \u{1F525}`
|
|
3570
3716
|
),
|
|
3571
3717
|
propSelectors: createPropSelectorsSchema(artifactComponents)
|
|
3572
3718
|
});
|
|
@@ -3585,6 +3731,9 @@ function createSaveToolResultTool(sessionId, streamRequestId, agentId, artifactC
|
|
|
3585
3731
|
return ai.tool({
|
|
3586
3732
|
description: `Save tool results as structured artifacts. Each artifact should represent ONE SPECIFIC, IMPORTANT, and UNIQUE document or data item.
|
|
3587
3733
|
|
|
3734
|
+
\u26A1 CRITICAL: JSON-like text content in tool results is AUTOMATICALLY PARSED into proper JSON objects - treat all data as structured, not text strings.
|
|
3735
|
+
\u{1F6A8} CRITICAL: Data structures are deeply nested. When your path fails, READ THE ERROR MESSAGE - it shows the correct path!
|
|
3736
|
+
|
|
3588
3737
|
AVAILABLE ARTIFACT TYPES:
|
|
3589
3738
|
${availableTypesWithDescriptions}
|
|
3590
3739
|
|
|
@@ -3596,26 +3745,6 @@ Each artifact you save becomes a SEPARATE DATA COMPONENT in the structured respo
|
|
|
3596
3745
|
\u2705 UNIQUE with distinct value from other artifacts
|
|
3597
3746
|
\u2705 RENDERED AS INDIVIDUAL DATA COMPONENT in the UI
|
|
3598
3747
|
|
|
3599
|
-
\u274C DO NOT save multiple different items in one artifact unless they are EXTREMELY SIMILAR
|
|
3600
|
-
\u274C DO NOT batch unrelated items together - each item becomes its own data component
|
|
3601
|
-
\u274C DO NOT save generic collections - break them into individual data components
|
|
3602
|
-
|
|
3603
|
-
\u{1F3AF} STRUCTURED DATA COMPONENT PRINCIPLE:
|
|
3604
|
-
Each artifact save creates ONE data component that will be rendered separately in the UI. If you have 5 important items, save them as 5 separate artifacts to create 5 separate data components for better user experience.
|
|
3605
|
-
|
|
3606
|
-
THINK: "What is the ONE most important piece of information here that deserves its own data component?"
|
|
3607
|
-
|
|
3608
|
-
EXAMPLES OF GOOD INDIVIDUAL ARTIFACTS (SEPARATE DATA COMPONENTS):
|
|
3609
|
-
- Nick Gomez's founder profile (specific person) \u2192 Individual data component
|
|
3610
|
-
- The /users/create API endpoint documentation (specific endpoint) \u2192 Individual data component
|
|
3611
|
-
- Error message for authentication failure (specific error type) \u2192 Individual data component
|
|
3612
|
-
- Configuration for Redis caching (specific config topic) \u2192 Individual data component
|
|
3613
|
-
|
|
3614
|
-
EXAMPLES OF BAD BATCHING:
|
|
3615
|
-
\u274C "All team members" \u2192 Should be separate artifacts for each important member (separate data components)
|
|
3616
|
-
\u274C "All API endpoints" \u2192 Should be separate artifacts for each distinct endpoint (separate data components)
|
|
3617
|
-
\u274C "All error types" \u2192 Should be separate artifacts for each error category (separate data components)
|
|
3618
|
-
|
|
3619
3748
|
USAGE PATTERN:
|
|
3620
3749
|
1. baseSelector: Navigate through nested structures to target ONE SPECIFIC item
|
|
3621
3750
|
- Navigate through all necessary levels: "result.data.items.nested[?condition]"
|
|
@@ -3625,9 +3754,11 @@ USAGE PATTERN:
|
|
|
3625
3754
|
- NOT: "result.items[*]" (too broad, gets everything)
|
|
3626
3755
|
|
|
3627
3756
|
2. propSelectors: Extract properties relative to your selected item
|
|
3628
|
-
- Always relative to the single item that baseSelector returns
|
|
3629
|
-
-
|
|
3630
|
-
-
|
|
3757
|
+
- \u{1F3AF} CRITICAL: Always relative to the single item that baseSelector returns
|
|
3758
|
+
- If baseSelector ends at a document \u2192 propSelectors access document fields
|
|
3759
|
+
- If baseSelector ends at content[0] \u2192 propSelectors access content[0] fields
|
|
3760
|
+
- Simple paths from that exact level: { prop1: "field_x", prop2: "nested.field_y" }
|
|
3761
|
+
- \u274C DON'T try to go back up or deeper - adjust your baseSelector instead!
|
|
3631
3762
|
|
|
3632
3763
|
3. Result: ONE artifact representing ONE important, unique item \u2192 ONE data component
|
|
3633
3764
|
|
|
@@ -3636,20 +3767,12 @@ USAGE PATTERN:
|
|
|
3636
3767
|
- Focus on getting to the right level with baseSelector, then keep propSelectors simple
|
|
3637
3768
|
- Test your baseSelector: Does it return exactly the items you want?
|
|
3638
3769
|
|
|
3639
|
-
|
|
3640
|
-
- ALWAYS ask: "Is this ONE specific, important thing that deserves its own data component?"
|
|
3641
|
-
- If the answer is no, don't save it or find a more specific selector
|
|
3642
|
-
- Multiple similar items = Multiple separate artifact saves (use the tool multiple times) \u2192 Multiple data components
|
|
3643
|
-
- Each artifact should be independently valuable and uniquely identifiable \u2192 Each data component stands alone
|
|
3644
|
-
- BETTER to save 3 individual, specific artifacts (3 data components) than 1 generic collection (1 data component)
|
|
3645
|
-
|
|
3646
|
-
\u{1F504} MULTIPLE ARTIFACTS = MULTIPLE DATA COMPONENTS:
|
|
3647
|
-
Remember: Each time you call this tool, you create a separate data component. Call it multiple times for multiple items to create a rich, structured response with individual data components for each important piece of information.`,
|
|
3770
|
+
Please use Error Messages to Debug when there is an error in the tool call.`,
|
|
3648
3771
|
inputSchema,
|
|
3649
3772
|
execute: async ({ toolCallId, baseSelector, propSelectors, ...rest }, _context) => {
|
|
3650
3773
|
const artifactType = "artifactType" in rest ? rest.artifactType : void 0;
|
|
3651
3774
|
if (!sessionId) {
|
|
3652
|
-
|
|
3775
|
+
logger11.warn({ toolCallId }, "No session ID provided to save_tool_result");
|
|
3653
3776
|
return {
|
|
3654
3777
|
saved: false,
|
|
3655
3778
|
error: `[toolCallId: ${toolCallId}] No session context available`,
|
|
@@ -3659,7 +3782,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
|
|
|
3659
3782
|
}
|
|
3660
3783
|
const toolResult = toolSessionManager.getToolResult(sessionId, toolCallId);
|
|
3661
3784
|
if (!toolResult) {
|
|
3662
|
-
|
|
3785
|
+
logger11.warn({ toolCallId, sessionId }, "Tool result not found in session");
|
|
3663
3786
|
return {
|
|
3664
3787
|
saved: false,
|
|
3665
3788
|
error: `[toolCallId: ${toolCallId}] Tool result not found`,
|
|
@@ -3672,7 +3795,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
|
|
|
3672
3795
|
const baseData = jmespath__default.default.search(parsedResult, baseSelector);
|
|
3673
3796
|
if (!baseData || Array.isArray(baseData) && baseData.length === 0) {
|
|
3674
3797
|
const debugInfo = analyzeSelectorFailure(parsedResult, baseSelector);
|
|
3675
|
-
|
|
3798
|
+
logger11.warn(
|
|
3676
3799
|
{
|
|
3677
3800
|
baseSelector,
|
|
3678
3801
|
toolCallId,
|
|
@@ -3715,7 +3838,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
|
|
|
3715
3838
|
const fallbackValue = item[propName];
|
|
3716
3839
|
if (fallbackValue !== null && fallbackValue !== void 0) {
|
|
3717
3840
|
extractedItem[propName] = fallbackValue;
|
|
3718
|
-
|
|
3841
|
+
logger11.info(
|
|
3719
3842
|
{ propName, propSelector, context },
|
|
3720
3843
|
`PropSelector failed, used fallback direct property access`
|
|
3721
3844
|
);
|
|
@@ -3727,7 +3850,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
|
|
|
3727
3850
|
const fallbackValue = item[propName];
|
|
3728
3851
|
if (fallbackValue !== null && fallbackValue !== void 0) {
|
|
3729
3852
|
extractedItem[propName] = fallbackValue;
|
|
3730
|
-
|
|
3853
|
+
logger11.warn(
|
|
3731
3854
|
{ propName, propSelector, context, error: error.message },
|
|
3732
3855
|
`PropSelector syntax error, used fallback direct property access`
|
|
3733
3856
|
);
|
|
@@ -3840,7 +3963,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
|
|
|
3840
3963
|
warnings
|
|
3841
3964
|
};
|
|
3842
3965
|
} catch (error) {
|
|
3843
|
-
|
|
3966
|
+
logger11.error({ error, toolCallId, sessionId }, "Error processing save_tool_result");
|
|
3844
3967
|
return {
|
|
3845
3968
|
saved: false,
|
|
3846
3969
|
error: `[toolCallId: ${toolCallId}] ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
@@ -3852,7 +3975,7 @@ Remember: Each time you call this tool, you create a separate data component. Ca
|
|
|
3852
3975
|
}
|
|
3853
3976
|
|
|
3854
3977
|
// src/a2a/client.ts
|
|
3855
|
-
var
|
|
3978
|
+
var logger12 = agentsCore.getLogger("a2aClient");
|
|
3856
3979
|
var DEFAULT_BACKOFF = {
|
|
3857
3980
|
initialInterval: 500,
|
|
3858
3981
|
maxInterval: 6e4,
|
|
@@ -4058,7 +4181,7 @@ var A2AClient = class {
|
|
|
4058
4181
|
try {
|
|
4059
4182
|
const res = await fn();
|
|
4060
4183
|
if (attempt > 0) {
|
|
4061
|
-
|
|
4184
|
+
logger12.info(
|
|
4062
4185
|
{
|
|
4063
4186
|
attempts: attempt + 1,
|
|
4064
4187
|
elapsedTime: Date.now() - start
|
|
@@ -4073,7 +4196,7 @@ var A2AClient = class {
|
|
|
4073
4196
|
}
|
|
4074
4197
|
const elapsed = Date.now() - start;
|
|
4075
4198
|
if (elapsed > maxElapsedTime) {
|
|
4076
|
-
|
|
4199
|
+
logger12.warn(
|
|
4077
4200
|
{
|
|
4078
4201
|
attempts: attempt + 1,
|
|
4079
4202
|
elapsedTime: elapsed,
|
|
@@ -4094,7 +4217,7 @@ var A2AClient = class {
|
|
|
4094
4217
|
retryInterval = initialInterval * attempt ** exponent + Math.random() * 1e3;
|
|
4095
4218
|
}
|
|
4096
4219
|
const delayMs = Math.min(retryInterval, maxInterval);
|
|
4097
|
-
|
|
4220
|
+
logger12.info(
|
|
4098
4221
|
{
|
|
4099
4222
|
attempt: attempt + 1,
|
|
4100
4223
|
delayMs,
|
|
@@ -4179,7 +4302,7 @@ var A2AClient = class {
|
|
|
4179
4302
|
}
|
|
4180
4303
|
const rpcResponse = await httpResponse.json();
|
|
4181
4304
|
if (rpcResponse.id !== requestId2) {
|
|
4182
|
-
|
|
4305
|
+
logger12.warn(
|
|
4183
4306
|
{
|
|
4184
4307
|
method,
|
|
4185
4308
|
expectedId: requestId2,
|
|
@@ -4378,7 +4501,7 @@ var A2AClient = class {
|
|
|
4378
4501
|
try {
|
|
4379
4502
|
while (true) {
|
|
4380
4503
|
const { done, value } = await reader.read();
|
|
4381
|
-
|
|
4504
|
+
logger12.info({ done, value }, "parseA2ASseStream");
|
|
4382
4505
|
if (done) {
|
|
4383
4506
|
if (eventDataBuffer.trim()) {
|
|
4384
4507
|
const result = this._processSseEventData(
|
|
@@ -4467,7 +4590,7 @@ var A2AClient = class {
|
|
|
4467
4590
|
// src/agents/relationTools.ts
|
|
4468
4591
|
init_conversations();
|
|
4469
4592
|
init_dbClient();
|
|
4470
|
-
var
|
|
4593
|
+
var logger13 = agentsCore.getLogger("relationships Tools");
|
|
4471
4594
|
var generateTransferToolDescription = (config2) => {
|
|
4472
4595
|
return `Hand off the conversation to agent ${config2.id}.
|
|
4473
4596
|
|
|
@@ -4505,7 +4628,7 @@ var createTransferToAgentTool = ({
|
|
|
4505
4628
|
"transfer.to_agent_id": transferConfig.id ?? "unknown"
|
|
4506
4629
|
});
|
|
4507
4630
|
}
|
|
4508
|
-
|
|
4631
|
+
logger13.info(
|
|
4509
4632
|
{
|
|
4510
4633
|
transferTo: transferConfig.id ?? "unknown",
|
|
4511
4634
|
fromAgent: callingAgentId
|
|
@@ -4615,7 +4738,7 @@ function createDelegateToAgentTool({
|
|
|
4615
4738
|
}
|
|
4616
4739
|
} else {
|
|
4617
4740
|
resolvedHeaders = {
|
|
4618
|
-
Authorization: `Bearer ${
|
|
4741
|
+
Authorization: `Bearer ${metadata.apiKey}`,
|
|
4619
4742
|
"x-inkeep-tenant-id": tenantId,
|
|
4620
4743
|
"x-inkeep-project-id": projectId,
|
|
4621
4744
|
"x-inkeep-graph-id": graphId,
|
|
@@ -4653,7 +4776,7 @@ function createDelegateToAgentTool({
|
|
|
4653
4776
|
...isInternal ? { fromAgentId: callingAgentId } : { fromExternalAgentId: callingAgentId }
|
|
4654
4777
|
}
|
|
4655
4778
|
};
|
|
4656
|
-
|
|
4779
|
+
logger13.info({ messageToSend }, "messageToSend");
|
|
4657
4780
|
await agentsCore.createMessage(dbClient_default)({
|
|
4658
4781
|
id: nanoid.nanoid(),
|
|
4659
4782
|
tenantId,
|
|
@@ -4715,7 +4838,7 @@ function createDelegateToAgentTool({
|
|
|
4715
4838
|
}
|
|
4716
4839
|
|
|
4717
4840
|
// src/agents/SystemPromptBuilder.ts
|
|
4718
|
-
var
|
|
4841
|
+
var logger14 = agentsCore.getLogger("SystemPromptBuilder");
|
|
4719
4842
|
var SystemPromptBuilder = class {
|
|
4720
4843
|
constructor(version, versionConfig) {
|
|
4721
4844
|
this.version = version;
|
|
@@ -4731,9 +4854,12 @@ var SystemPromptBuilder = class {
|
|
|
4731
4854
|
this.templates.set(name, content);
|
|
4732
4855
|
}
|
|
4733
4856
|
this.loaded = true;
|
|
4734
|
-
|
|
4857
|
+
logger14.debug(
|
|
4858
|
+
{ templateCount: this.templates.size, version: this.version },
|
|
4859
|
+
`Loaded ${this.templates.size} templates for version ${this.version}`
|
|
4860
|
+
);
|
|
4735
4861
|
} catch (error) {
|
|
4736
|
-
|
|
4862
|
+
logger14.error({ error }, `Failed to load templates for version ${this.version}`);
|
|
4737
4863
|
throw new Error(`Template loading failed: ${error}`);
|
|
4738
4864
|
}
|
|
4739
4865
|
}
|
|
@@ -5135,7 +5261,7 @@ function hasToolCallWithPrefix(prefix) {
|
|
|
5135
5261
|
return false;
|
|
5136
5262
|
};
|
|
5137
5263
|
}
|
|
5138
|
-
var
|
|
5264
|
+
var logger15 = agentsCore.getLogger("Agent");
|
|
5139
5265
|
var CONSTANTS = {
|
|
5140
5266
|
MAX_GENERATION_STEPS: 12,
|
|
5141
5267
|
PHASE_1_TIMEOUT_MS: 27e4,
|
|
@@ -5388,14 +5514,14 @@ var Agent = class {
|
|
|
5388
5514
|
for (const toolSet of tools) {
|
|
5389
5515
|
for (const [toolName, originalTool] of Object.entries(toolSet)) {
|
|
5390
5516
|
if (!isValidTool(originalTool)) {
|
|
5391
|
-
|
|
5517
|
+
logger15.error({ toolName }, "Invalid MCP tool structure - missing required properties");
|
|
5392
5518
|
continue;
|
|
5393
5519
|
}
|
|
5394
5520
|
const sessionWrappedTool = ai.tool({
|
|
5395
5521
|
description: originalTool.description,
|
|
5396
5522
|
inputSchema: originalTool.inputSchema,
|
|
5397
5523
|
execute: async (args, { toolCallId }) => {
|
|
5398
|
-
|
|
5524
|
+
logger15.debug({ toolName, toolCallId }, "MCP Tool Called");
|
|
5399
5525
|
try {
|
|
5400
5526
|
const result = await originalTool.execute(args, { toolCallId });
|
|
5401
5527
|
toolSessionManager.recordToolResult(sessionId, {
|
|
@@ -5407,7 +5533,7 @@ var Agent = class {
|
|
|
5407
5533
|
});
|
|
5408
5534
|
return { result, toolCallId };
|
|
5409
5535
|
} catch (error) {
|
|
5410
|
-
|
|
5536
|
+
logger15.error({ toolName, toolCallId, error }, "MCP tool execution failed");
|
|
5411
5537
|
throw error;
|
|
5412
5538
|
}
|
|
5413
5539
|
}
|
|
@@ -5492,7 +5618,7 @@ var Agent = class {
|
|
|
5492
5618
|
selectedTools
|
|
5493
5619
|
};
|
|
5494
5620
|
}
|
|
5495
|
-
|
|
5621
|
+
logger15.info(
|
|
5496
5622
|
{
|
|
5497
5623
|
toolName: tool4.name,
|
|
5498
5624
|
credentialReferenceId,
|
|
@@ -5532,7 +5658,7 @@ var Agent = class {
|
|
|
5532
5658
|
async getResolvedContext(conversationId, requestContext) {
|
|
5533
5659
|
try {
|
|
5534
5660
|
if (!this.config.contextConfigId) {
|
|
5535
|
-
|
|
5661
|
+
logger15.debug({ graphId: this.config.graphId }, "No context config found for graph");
|
|
5536
5662
|
return null;
|
|
5537
5663
|
}
|
|
5538
5664
|
const contextConfig = await agentsCore.getContextConfigById(dbClient_default)({
|
|
@@ -5540,7 +5666,7 @@ var Agent = class {
|
|
|
5540
5666
|
id: this.config.contextConfigId
|
|
5541
5667
|
});
|
|
5542
5668
|
if (!contextConfig) {
|
|
5543
|
-
|
|
5669
|
+
logger15.warn({ contextConfigId: this.config.contextConfigId }, "Context config not found");
|
|
5544
5670
|
return null;
|
|
5545
5671
|
}
|
|
5546
5672
|
if (!this.contextResolver) {
|
|
@@ -5557,7 +5683,7 @@ var Agent = class {
|
|
|
5557
5683
|
$now: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5558
5684
|
$env: process.env
|
|
5559
5685
|
};
|
|
5560
|
-
|
|
5686
|
+
logger15.debug(
|
|
5561
5687
|
{
|
|
5562
5688
|
conversationId,
|
|
5563
5689
|
contextConfigId: contextConfig.id,
|
|
@@ -5571,7 +5697,7 @@ var Agent = class {
|
|
|
5571
5697
|
);
|
|
5572
5698
|
return contextWithBuiltins;
|
|
5573
5699
|
} catch (error) {
|
|
5574
|
-
|
|
5700
|
+
logger15.error(
|
|
5575
5701
|
{
|
|
5576
5702
|
conversationId,
|
|
5577
5703
|
error: error instanceof Error ? error.message : "Unknown error"
|
|
@@ -5595,7 +5721,7 @@ var Agent = class {
|
|
|
5595
5721
|
});
|
|
5596
5722
|
return graphDefinition?.graphPrompt || void 0;
|
|
5597
5723
|
} catch (error) {
|
|
5598
|
-
|
|
5724
|
+
logger15.warn(
|
|
5599
5725
|
{
|
|
5600
5726
|
graphId: this.config.graphId,
|
|
5601
5727
|
error: error instanceof Error ? error.message : "Unknown error"
|
|
@@ -5622,7 +5748,7 @@ var Agent = class {
|
|
|
5622
5748
|
}
|
|
5623
5749
|
return !!(graphDefinition.artifactComponents && Object.keys(graphDefinition.artifactComponents).length > 0);
|
|
5624
5750
|
} catch (error) {
|
|
5625
|
-
|
|
5751
|
+
logger15.warn(
|
|
5626
5752
|
{
|
|
5627
5753
|
graphId: this.config.graphId,
|
|
5628
5754
|
tenantId: this.config.tenantId,
|
|
@@ -5682,7 +5808,7 @@ Key requirements:
|
|
|
5682
5808
|
preserveUnresolved: false
|
|
5683
5809
|
});
|
|
5684
5810
|
} catch (error) {
|
|
5685
|
-
|
|
5811
|
+
logger15.error(
|
|
5686
5812
|
{
|
|
5687
5813
|
conversationId,
|
|
5688
5814
|
error: error instanceof Error ? error.message : "Unknown error"
|
|
@@ -5727,7 +5853,7 @@ Key requirements:
|
|
|
5727
5853
|
preserveUnresolved: false
|
|
5728
5854
|
});
|
|
5729
5855
|
} catch (error) {
|
|
5730
|
-
|
|
5856
|
+
logger15.error(
|
|
5731
5857
|
{
|
|
5732
5858
|
conversationId,
|
|
5733
5859
|
error: error instanceof Error ? error.message : "Unknown error"
|
|
@@ -5755,7 +5881,7 @@ Key requirements:
|
|
|
5755
5881
|
artifactId: z5.z.string().describe("The unique identifier of the artifact to get.")
|
|
5756
5882
|
}),
|
|
5757
5883
|
execute: async ({ artifactId }) => {
|
|
5758
|
-
|
|
5884
|
+
logger15.info({ artifactId }, "get_artifact executed");
|
|
5759
5885
|
const artifact = await agentsCore.getLedgerArtifacts(dbClient_default)({
|
|
5760
5886
|
scopes: {
|
|
5761
5887
|
tenantId: this.config.tenantId,
|
|
@@ -5822,7 +5948,7 @@ Key requirements:
|
|
|
5822
5948
|
graphId: this.config.graphId
|
|
5823
5949
|
});
|
|
5824
5950
|
} catch (error) {
|
|
5825
|
-
|
|
5951
|
+
logger15.error(
|
|
5826
5952
|
{ error, graphId: this.config.graphId },
|
|
5827
5953
|
"Failed to check graph artifact components"
|
|
5828
5954
|
);
|
|
@@ -5926,7 +6052,7 @@ Key requirements:
|
|
|
5926
6052
|
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;
|
|
5927
6053
|
const timeoutMs = Math.min(configuredTimeout, MAX_ALLOWED_TIMEOUT_MS);
|
|
5928
6054
|
if (modelSettings.maxDuration && modelSettings.maxDuration * 1e3 > MAX_ALLOWED_TIMEOUT_MS) {
|
|
5929
|
-
|
|
6055
|
+
logger15.warn(
|
|
5930
6056
|
{
|
|
5931
6057
|
requestedTimeout: modelSettings.maxDuration * 1e3,
|
|
5932
6058
|
appliedTimeout: timeoutMs,
|
|
@@ -5968,7 +6094,7 @@ Key requirements:
|
|
|
5968
6094
|
}
|
|
5969
6095
|
);
|
|
5970
6096
|
} catch (error) {
|
|
5971
|
-
|
|
6097
|
+
logger15.debug({ error }, "Failed to track agent reasoning");
|
|
5972
6098
|
}
|
|
5973
6099
|
}
|
|
5974
6100
|
if (last && "toolCalls" in last && last.toolCalls) {
|
|
@@ -6051,7 +6177,7 @@ Key requirements:
|
|
|
6051
6177
|
}
|
|
6052
6178
|
);
|
|
6053
6179
|
} catch (error) {
|
|
6054
|
-
|
|
6180
|
+
logger15.debug({ error }, "Failed to track agent reasoning");
|
|
6055
6181
|
}
|
|
6056
6182
|
}
|
|
6057
6183
|
if (last && "toolCalls" in last && last.toolCalls) {
|
|
@@ -6096,7 +6222,7 @@ Key requirements:
|
|
|
6096
6222
|
return;
|
|
6097
6223
|
}
|
|
6098
6224
|
if (toolName === "save_artifact_tool" || toolName === "save_tool_result") {
|
|
6099
|
-
|
|
6225
|
+
logger15.info({ result }, "save_artifact_tool or save_tool_result");
|
|
6100
6226
|
if (result.output.artifacts) {
|
|
6101
6227
|
for (const artifact of result.output.artifacts) {
|
|
6102
6228
|
const artifactId = artifact?.artifactId || "N/A";
|
|
@@ -6171,7 +6297,7 @@ ${output}`;
|
|
|
6171
6297
|
{ role: "user", content: userMessage },
|
|
6172
6298
|
...reasoningFlow,
|
|
6173
6299
|
{
|
|
6174
|
-
role: "
|
|
6300
|
+
role: "user",
|
|
6175
6301
|
content: await this.buildPhase2SystemPrompt()
|
|
6176
6302
|
}
|
|
6177
6303
|
],
|
|
@@ -6270,7 +6396,9 @@ async function resolveModelConfig(graphId, agent) {
|
|
|
6270
6396
|
summarizer: agent.models?.summarizer || project.models.summarizer || project.models.base
|
|
6271
6397
|
};
|
|
6272
6398
|
}
|
|
6273
|
-
throw new Error(
|
|
6399
|
+
throw new Error(
|
|
6400
|
+
"Base model configuration is required. Please configure models at the project level."
|
|
6401
|
+
);
|
|
6274
6402
|
}
|
|
6275
6403
|
|
|
6276
6404
|
// src/agents/generateTaskHandler.ts
|
|
@@ -6284,7 +6412,7 @@ function parseEmbeddedJson(data) {
|
|
|
6284
6412
|
}
|
|
6285
6413
|
});
|
|
6286
6414
|
}
|
|
6287
|
-
var
|
|
6415
|
+
var logger16 = agentsCore.getLogger("generateTaskHandler");
|
|
6288
6416
|
var createTaskHandler = (config2, credentialStoreRegistry) => {
|
|
6289
6417
|
return async (task) => {
|
|
6290
6418
|
try {
|
|
@@ -6334,7 +6462,33 @@ var createTaskHandler = (config2, credentialStoreRegistry) => {
|
|
|
6334
6462
|
agentId: config2.agentId
|
|
6335
6463
|
})
|
|
6336
6464
|
]);
|
|
6337
|
-
|
|
6465
|
+
logger16.info({ toolsForAgent, internalRelations, externalRelations }, "agent stuff");
|
|
6466
|
+
const enhancedInternalRelations = await Promise.all(
|
|
6467
|
+
internalRelations.map(async (relation) => {
|
|
6468
|
+
try {
|
|
6469
|
+
const relatedAgent = await agentsCore.getAgentById(dbClient_default)({
|
|
6470
|
+
scopes: { tenantId: config2.tenantId, projectId: config2.projectId },
|
|
6471
|
+
agentId: relation.id
|
|
6472
|
+
});
|
|
6473
|
+
if (relatedAgent) {
|
|
6474
|
+
const relatedAgentRelations = await agentsCore.getRelatedAgentsForGraph(dbClient_default)({
|
|
6475
|
+
scopes: { tenantId: config2.tenantId, projectId: config2.projectId },
|
|
6476
|
+
graphId: config2.graphId,
|
|
6477
|
+
agentId: relation.id
|
|
6478
|
+
});
|
|
6479
|
+
const enhancedDescription = generateDescriptionWithTransfers(
|
|
6480
|
+
relation.description || "",
|
|
6481
|
+
relatedAgentRelations.internalRelations,
|
|
6482
|
+
relatedAgentRelations.externalRelations
|
|
6483
|
+
);
|
|
6484
|
+
return { ...relation, description: enhancedDescription };
|
|
6485
|
+
}
|
|
6486
|
+
} catch (error) {
|
|
6487
|
+
logger16.warn({ agentId: relation.id, error }, "Failed to enhance agent description");
|
|
6488
|
+
}
|
|
6489
|
+
return relation;
|
|
6490
|
+
})
|
|
6491
|
+
);
|
|
6338
6492
|
const agentPrompt = "prompt" in config2.agentSchema ? config2.agentSchema.prompt : "";
|
|
6339
6493
|
const models = "models" in config2.agentSchema ? config2.agentSchema.models : void 0;
|
|
6340
6494
|
const stopWhen = "stopWhen" in config2.agentSchema ? config2.agentSchema.stopWhen : void 0;
|
|
@@ -6351,7 +6505,7 @@ var createTaskHandler = (config2, credentialStoreRegistry) => {
|
|
|
6351
6505
|
agentPrompt,
|
|
6352
6506
|
models: models || void 0,
|
|
6353
6507
|
stopWhen: stopWhen || void 0,
|
|
6354
|
-
agentRelations:
|
|
6508
|
+
agentRelations: enhancedInternalRelations.map((relation) => ({
|
|
6355
6509
|
id: relation.id,
|
|
6356
6510
|
tenantId: config2.tenantId,
|
|
6357
6511
|
projectId: config2.projectId,
|
|
@@ -6365,7 +6519,7 @@ var createTaskHandler = (config2, credentialStoreRegistry) => {
|
|
|
6365
6519
|
agentRelations: [],
|
|
6366
6520
|
transferRelations: []
|
|
6367
6521
|
})),
|
|
6368
|
-
transferRelations:
|
|
6522
|
+
transferRelations: enhancedInternalRelations.filter((relation) => relation.relationType === "transfer").map((relation) => ({
|
|
6369
6523
|
baseUrl: config2.baseUrl,
|
|
6370
6524
|
apiKey: config2.apiKey,
|
|
6371
6525
|
id: relation.id,
|
|
@@ -6381,7 +6535,7 @@ var createTaskHandler = (config2, credentialStoreRegistry) => {
|
|
|
6381
6535
|
})),
|
|
6382
6536
|
delegateRelations: [
|
|
6383
6537
|
// Internal delegate relations
|
|
6384
|
-
...
|
|
6538
|
+
...enhancedInternalRelations.filter((relation) => relation.relationType === "delegate").map((relation) => ({
|
|
6385
6539
|
type: "internal",
|
|
6386
6540
|
config: {
|
|
6387
6541
|
id: relation.id,
|
|
@@ -6434,7 +6588,7 @@ var createTaskHandler = (config2, credentialStoreRegistry) => {
|
|
|
6434
6588
|
const taskIdMatch = task.id.match(/^task_([^-]+-[^-]+-\d+)-/);
|
|
6435
6589
|
if (taskIdMatch) {
|
|
6436
6590
|
contextId = taskIdMatch[1];
|
|
6437
|
-
|
|
6591
|
+
logger16.info(
|
|
6438
6592
|
{
|
|
6439
6593
|
taskId: task.id,
|
|
6440
6594
|
extractedContextId: contextId,
|
|
@@ -6450,7 +6604,7 @@ var createTaskHandler = (config2, credentialStoreRegistry) => {
|
|
|
6450
6604
|
const isDelegation = task.context?.metadata?.isDelegation === true;
|
|
6451
6605
|
agent.setDelegationStatus(isDelegation);
|
|
6452
6606
|
if (isDelegation) {
|
|
6453
|
-
|
|
6607
|
+
logger16.info(
|
|
6454
6608
|
{ agentId: config2.agentId, taskId: task.id },
|
|
6455
6609
|
"Delegated agent - streaming disabled"
|
|
6456
6610
|
);
|
|
@@ -6462,7 +6616,8 @@ var createTaskHandler = (config2, credentialStoreRegistry) => {
|
|
|
6462
6616
|
taskId: task.id,
|
|
6463
6617
|
threadId: contextId,
|
|
6464
6618
|
// using conversationId as threadId for now
|
|
6465
|
-
streamRequestId
|
|
6619
|
+
streamRequestId,
|
|
6620
|
+
...config2.apiKey ? { apiKey: config2.apiKey } : {}
|
|
6466
6621
|
}
|
|
6467
6622
|
});
|
|
6468
6623
|
const stepContents = response.steps && Array.isArray(response.steps) ? response.steps.flatMap((step) => {
|
|
@@ -6655,85 +6810,11 @@ async function getRegisteredGraph(executionContext) {
|
|
|
6655
6810
|
const agentFrameworkBaseUrl = `${baseUrl}/agents`;
|
|
6656
6811
|
return hydrateGraph({ dbGraph, baseUrl: agentFrameworkBaseUrl, apiKey });
|
|
6657
6812
|
}
|
|
6658
|
-
init_dbClient();
|
|
6659
|
-
agentsCore.getLogger("agents");
|
|
6660
|
-
async function hydrateAgent({
|
|
6661
|
-
dbAgent,
|
|
6662
|
-
graphId,
|
|
6663
|
-
baseUrl,
|
|
6664
|
-
apiKey,
|
|
6665
|
-
credentialStoreRegistry
|
|
6666
|
-
}) {
|
|
6667
|
-
try {
|
|
6668
|
-
const taskHandlerConfig = await createTaskHandlerConfig({
|
|
6669
|
-
tenantId: dbAgent.tenantId,
|
|
6670
|
-
projectId: dbAgent.projectId,
|
|
6671
|
-
graphId,
|
|
6672
|
-
agentId: dbAgent.id,
|
|
6673
|
-
baseUrl,
|
|
6674
|
-
apiKey
|
|
6675
|
-
});
|
|
6676
|
-
const taskHandler = createTaskHandler(taskHandlerConfig, credentialStoreRegistry);
|
|
6677
|
-
const agentCard = {
|
|
6678
|
-
name: dbAgent.name,
|
|
6679
|
-
description: dbAgent.description || "AI Agent",
|
|
6680
|
-
url: baseUrl ? `${baseUrl}/a2a` : "",
|
|
6681
|
-
version: "1.0.0",
|
|
6682
|
-
capabilities: {
|
|
6683
|
-
streaming: true,
|
|
6684
|
-
// Enable streaming for A2A compliance
|
|
6685
|
-
pushNotifications: false,
|
|
6686
|
-
stateTransitionHistory: false
|
|
6687
|
-
},
|
|
6688
|
-
defaultInputModes: ["text", "text/plain"],
|
|
6689
|
-
defaultOutputModes: ["text", "text/plain"],
|
|
6690
|
-
skills: [],
|
|
6691
|
-
// Add provider info if available
|
|
6692
|
-
...baseUrl && {
|
|
6693
|
-
provider: {
|
|
6694
|
-
organization: "Inkeep",
|
|
6695
|
-
url: baseUrl
|
|
6696
|
-
}
|
|
6697
|
-
}
|
|
6698
|
-
};
|
|
6699
|
-
return {
|
|
6700
|
-
agentId: dbAgent.id,
|
|
6701
|
-
tenantId: dbAgent.tenantId,
|
|
6702
|
-
projectId: dbAgent.projectId,
|
|
6703
|
-
graphId,
|
|
6704
|
-
agentCard,
|
|
6705
|
-
taskHandler
|
|
6706
|
-
};
|
|
6707
|
-
} catch (error) {
|
|
6708
|
-
console.error(`\u274C Failed to hydrate agent ${dbAgent.id}:`, error);
|
|
6709
|
-
throw error;
|
|
6710
|
-
}
|
|
6711
|
-
}
|
|
6712
|
-
async function getRegisteredAgent(executionContext, credentialStoreRegistry) {
|
|
6713
|
-
const { tenantId, projectId, graphId, agentId, baseUrl } = executionContext;
|
|
6714
|
-
if (!agentId) {
|
|
6715
|
-
throw new Error("Agent ID is required");
|
|
6716
|
-
}
|
|
6717
|
-
const dbAgent = await agentsCore.getAgentById(dbClient_default)({
|
|
6718
|
-
scopes: { tenantId, projectId },
|
|
6719
|
-
agentId
|
|
6720
|
-
});
|
|
6721
|
-
if (!dbAgent) {
|
|
6722
|
-
return null;
|
|
6723
|
-
}
|
|
6724
|
-
const agentFrameworkBaseUrl = `${baseUrl}/agents`;
|
|
6725
|
-
return hydrateAgent({
|
|
6726
|
-
dbAgent,
|
|
6727
|
-
graphId,
|
|
6728
|
-
baseUrl: agentFrameworkBaseUrl,
|
|
6729
|
-
credentialStoreRegistry
|
|
6730
|
-
});
|
|
6731
|
-
}
|
|
6732
6813
|
|
|
6733
6814
|
// src/routes/agents.ts
|
|
6734
6815
|
init_dbClient();
|
|
6735
6816
|
var app = new zodOpenapi.OpenAPIHono();
|
|
6736
|
-
var
|
|
6817
|
+
var logger17 = agentsCore.getLogger("agents");
|
|
6737
6818
|
app.openapi(
|
|
6738
6819
|
zodOpenapi.createRoute({
|
|
6739
6820
|
method: "get",
|
|
@@ -6771,7 +6852,7 @@ app.openapi(
|
|
|
6771
6852
|
tracestate: c.req.header("tracestate"),
|
|
6772
6853
|
baggage: c.req.header("baggage")
|
|
6773
6854
|
};
|
|
6774
|
-
|
|
6855
|
+
logger17.info(
|
|
6775
6856
|
{
|
|
6776
6857
|
otelHeaders,
|
|
6777
6858
|
path: c.req.path,
|
|
@@ -6782,7 +6863,7 @@ app.openapi(
|
|
|
6782
6863
|
const executionContext = agentsCore.getRequestExecutionContext(c);
|
|
6783
6864
|
const { tenantId, projectId, graphId, agentId } = executionContext;
|
|
6784
6865
|
if (agentId) {
|
|
6785
|
-
|
|
6866
|
+
logger17.info(
|
|
6786
6867
|
{
|
|
6787
6868
|
message: "getRegisteredAgent (agent-level)",
|
|
6788
6869
|
tenantId,
|
|
@@ -6794,13 +6875,13 @@ app.openapi(
|
|
|
6794
6875
|
);
|
|
6795
6876
|
const credentialStores = c.get("credentialStores");
|
|
6796
6877
|
const agent = await getRegisteredAgent(executionContext, credentialStores);
|
|
6797
|
-
|
|
6878
|
+
logger17.info({ agent }, "agent registered: well-known agent.json");
|
|
6798
6879
|
if (!agent) {
|
|
6799
6880
|
return c.json({ error: "Agent not found" }, 404);
|
|
6800
6881
|
}
|
|
6801
6882
|
return c.json(agent.agentCard);
|
|
6802
6883
|
} else {
|
|
6803
|
-
|
|
6884
|
+
logger17.info(
|
|
6804
6885
|
{
|
|
6805
6886
|
message: "getRegisteredGraph (graph-level)",
|
|
6806
6887
|
tenantId,
|
|
@@ -6823,7 +6904,7 @@ app.post("/a2a", async (c) => {
|
|
|
6823
6904
|
tracestate: c.req.header("tracestate"),
|
|
6824
6905
|
baggage: c.req.header("baggage")
|
|
6825
6906
|
};
|
|
6826
|
-
|
|
6907
|
+
logger17.info(
|
|
6827
6908
|
{
|
|
6828
6909
|
otelHeaders,
|
|
6829
6910
|
path: c.req.path,
|
|
@@ -6834,7 +6915,7 @@ app.post("/a2a", async (c) => {
|
|
|
6834
6915
|
const executionContext = agentsCore.getRequestExecutionContext(c);
|
|
6835
6916
|
const { tenantId, projectId, graphId, agentId } = executionContext;
|
|
6836
6917
|
if (agentId) {
|
|
6837
|
-
|
|
6918
|
+
logger17.info(
|
|
6838
6919
|
{
|
|
6839
6920
|
message: "a2a (agent-level)",
|
|
6840
6921
|
tenantId,
|
|
@@ -6858,7 +6939,7 @@ app.post("/a2a", async (c) => {
|
|
|
6858
6939
|
}
|
|
6859
6940
|
return a2aHandler(c, agent);
|
|
6860
6941
|
} else {
|
|
6861
|
-
|
|
6942
|
+
logger17.info(
|
|
6862
6943
|
{
|
|
6863
6944
|
message: "a2a (graph-level)",
|
|
6864
6945
|
tenantId,
|
|
@@ -6904,14 +6985,14 @@ init_dbClient();
|
|
|
6904
6985
|
|
|
6905
6986
|
// src/a2a/transfer.ts
|
|
6906
6987
|
init_dbClient();
|
|
6907
|
-
var
|
|
6988
|
+
var logger18 = agentsCore.getLogger("Transfer");
|
|
6908
6989
|
async function executeTransfer({
|
|
6909
6990
|
tenantId,
|
|
6910
6991
|
threadId,
|
|
6911
6992
|
projectId,
|
|
6912
6993
|
targetAgentId
|
|
6913
6994
|
}) {
|
|
6914
|
-
|
|
6995
|
+
logger18.info({ targetAgent: targetAgentId }, "Executing transfer to agent");
|
|
6915
6996
|
await agentsCore.setActiveAgentForThread(dbClient_default)({
|
|
6916
6997
|
scopes: { tenantId, projectId },
|
|
6917
6998
|
threadId,
|
|
@@ -7106,7 +7187,7 @@ var _VercelDataStreamHelper = class _VercelDataStreamHelper {
|
|
|
7106
7187
|
__publicField(this, "queuedOperations", []);
|
|
7107
7188
|
// Timing tracking for text sequences (text-end to text-start gap)
|
|
7108
7189
|
__publicField(this, "lastTextEndTimestamp", 0);
|
|
7109
|
-
__publicField(this, "TEXT_GAP_THRESHOLD",
|
|
7190
|
+
__publicField(this, "TEXT_GAP_THRESHOLD", 50);
|
|
7110
7191
|
// milliseconds - if gap between text sequences is less than this, queue operations
|
|
7111
7192
|
// Connection management and forced cleanup
|
|
7112
7193
|
__publicField(this, "connectionDropTimer");
|
|
@@ -7455,7 +7536,7 @@ function createMCPStreamHelper() {
|
|
|
7455
7536
|
|
|
7456
7537
|
// src/handlers/executionHandler.ts
|
|
7457
7538
|
init_dbClient();
|
|
7458
|
-
var
|
|
7539
|
+
var logger19 = agentsCore.getLogger("ExecutionHandler");
|
|
7459
7540
|
var ExecutionHandler = class {
|
|
7460
7541
|
constructor() {
|
|
7461
7542
|
// Hardcoded error limit - separate from configurable stopWhen
|
|
@@ -7480,7 +7561,7 @@ var ExecutionHandler = class {
|
|
|
7480
7561
|
const { tenantId, projectId, graphId, apiKey, baseUrl } = executionContext;
|
|
7481
7562
|
registerStreamHelper(requestId2, sseHelper);
|
|
7482
7563
|
graphSessionManager.createSession(requestId2, graphId, tenantId, projectId);
|
|
7483
|
-
|
|
7564
|
+
logger19.info({ sessionId: requestId2, graphId }, "Created GraphSession for message execution");
|
|
7484
7565
|
let graphConfig = null;
|
|
7485
7566
|
try {
|
|
7486
7567
|
graphConfig = await agentsCore.getFullGraph(dbClient_default)({ scopes: { tenantId, projectId }, graphId });
|
|
@@ -7492,7 +7573,7 @@ var ExecutionHandler = class {
|
|
|
7492
7573
|
);
|
|
7493
7574
|
}
|
|
7494
7575
|
} catch (error) {
|
|
7495
|
-
|
|
7576
|
+
logger19.error(
|
|
7496
7577
|
{
|
|
7497
7578
|
error: error instanceof Error ? error.message : "Unknown error",
|
|
7498
7579
|
stack: error instanceof Error ? error.stack : void 0
|
|
@@ -7508,7 +7589,7 @@ var ExecutionHandler = class {
|
|
|
7508
7589
|
try {
|
|
7509
7590
|
await sseHelper.writeOperation(agentInitializingOp(requestId2, graphId));
|
|
7510
7591
|
const taskId = `task_${conversationId}-${requestId2}`;
|
|
7511
|
-
|
|
7592
|
+
logger19.info(
|
|
7512
7593
|
{ taskId, currentAgentId, conversationId, requestId: requestId2 },
|
|
7513
7594
|
"Attempting to create or reuse existing task"
|
|
7514
7595
|
);
|
|
@@ -7531,7 +7612,7 @@ var ExecutionHandler = class {
|
|
|
7531
7612
|
agent_id: currentAgentId
|
|
7532
7613
|
}
|
|
7533
7614
|
});
|
|
7534
|
-
|
|
7615
|
+
logger19.info(
|
|
7535
7616
|
{
|
|
7536
7617
|
taskId,
|
|
7537
7618
|
createdTaskMetadata: Array.isArray(task) ? task[0]?.metadata : task?.metadata
|
|
@@ -7540,27 +7621,27 @@ var ExecutionHandler = class {
|
|
|
7540
7621
|
);
|
|
7541
7622
|
} catch (error) {
|
|
7542
7623
|
if (error?.message?.includes("UNIQUE constraint failed") || error?.message?.includes("PRIMARY KEY constraint failed") || error?.code === "SQLITE_CONSTRAINT_PRIMARYKEY") {
|
|
7543
|
-
|
|
7624
|
+
logger19.info(
|
|
7544
7625
|
{ taskId, error: error.message },
|
|
7545
7626
|
"Task already exists, fetching existing task"
|
|
7546
7627
|
);
|
|
7547
7628
|
const existingTask = await agentsCore.getTask(dbClient_default)({ id: taskId });
|
|
7548
7629
|
if (existingTask) {
|
|
7549
7630
|
task = existingTask;
|
|
7550
|
-
|
|
7631
|
+
logger19.info(
|
|
7551
7632
|
{ taskId, existingTask },
|
|
7552
7633
|
"Successfully reused existing task from race condition"
|
|
7553
7634
|
);
|
|
7554
7635
|
} else {
|
|
7555
|
-
|
|
7636
|
+
logger19.error({ taskId, error }, "Task constraint failed but task not found");
|
|
7556
7637
|
throw error;
|
|
7557
7638
|
}
|
|
7558
7639
|
} else {
|
|
7559
|
-
|
|
7640
|
+
logger19.error({ taskId, error }, "Failed to create task due to non-constraint error");
|
|
7560
7641
|
throw error;
|
|
7561
7642
|
}
|
|
7562
7643
|
}
|
|
7563
|
-
|
|
7644
|
+
logger19.debug(
|
|
7564
7645
|
{
|
|
7565
7646
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
7566
7647
|
executionType: "create_initial_task",
|
|
@@ -7578,7 +7659,7 @@ var ExecutionHandler = class {
|
|
|
7578
7659
|
const maxTransfers = graphConfig?.stopWhen?.transferCountIs ?? 10;
|
|
7579
7660
|
while (iterations < maxTransfers) {
|
|
7580
7661
|
iterations++;
|
|
7581
|
-
|
|
7662
|
+
logger19.info(
|
|
7582
7663
|
{ iterations, currentAgentId, graphId, conversationId, fromAgentId },
|
|
7583
7664
|
`Execution loop iteration ${iterations} with agent ${currentAgentId}, transfer from: ${fromAgentId || "none"}`
|
|
7584
7665
|
);
|
|
@@ -7586,10 +7667,10 @@ var ExecutionHandler = class {
|
|
|
7586
7667
|
scopes: { tenantId, projectId },
|
|
7587
7668
|
conversationId
|
|
7588
7669
|
});
|
|
7589
|
-
|
|
7670
|
+
logger19.info({ activeAgent }, "activeAgent");
|
|
7590
7671
|
if (activeAgent && activeAgent.activeAgentId !== currentAgentId) {
|
|
7591
7672
|
currentAgentId = activeAgent.activeAgentId;
|
|
7592
|
-
|
|
7673
|
+
logger19.info({ currentAgentId }, `Updated current agent to: ${currentAgentId}`);
|
|
7593
7674
|
}
|
|
7594
7675
|
const agentBaseUrl = `${baseUrl}/agents`;
|
|
7595
7676
|
const a2aClient = new A2AClient(agentBaseUrl, {
|
|
@@ -7630,13 +7711,13 @@ var ExecutionHandler = class {
|
|
|
7630
7711
|
});
|
|
7631
7712
|
if (!messageResponse?.result) {
|
|
7632
7713
|
errorCount++;
|
|
7633
|
-
|
|
7714
|
+
logger19.error(
|
|
7634
7715
|
{ currentAgentId, iterations, errorCount },
|
|
7635
7716
|
`No response from agent ${currentAgentId} on iteration ${iterations} (error ${errorCount}/${this.MAX_ERRORS})`
|
|
7636
7717
|
);
|
|
7637
7718
|
if (errorCount >= this.MAX_ERRORS) {
|
|
7638
7719
|
const errorMessage2 = `Maximum error limit (${this.MAX_ERRORS}) reached`;
|
|
7639
|
-
|
|
7720
|
+
logger19.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
|
|
7640
7721
|
await sseHelper.writeError(errorMessage2);
|
|
7641
7722
|
await sseHelper.writeOperation(errorOp(errorMessage2, currentAgentId || "system"));
|
|
7642
7723
|
if (task) {
|
|
@@ -7662,7 +7743,7 @@ var ExecutionHandler = class {
|
|
|
7662
7743
|
const transferResponse = messageResponse.result;
|
|
7663
7744
|
const targetAgentId = transferResponse.artifacts?.[0]?.parts?.[0]?.data?.targetAgentId;
|
|
7664
7745
|
const transferReason = transferResponse.artifacts?.[0]?.parts?.[1]?.text;
|
|
7665
|
-
|
|
7746
|
+
logger19.info({ targetAgentId, transferReason }, "transfer response");
|
|
7666
7747
|
currentMessage = `<transfer_context> ${transferReason} </transfer_context>`;
|
|
7667
7748
|
const { success, targetAgentId: newAgentId } = await executeTransfer({
|
|
7668
7749
|
projectId,
|
|
@@ -7673,7 +7754,7 @@ var ExecutionHandler = class {
|
|
|
7673
7754
|
if (success) {
|
|
7674
7755
|
fromAgentId = currentAgentId;
|
|
7675
7756
|
currentAgentId = newAgentId;
|
|
7676
|
-
|
|
7757
|
+
logger19.info(
|
|
7677
7758
|
{
|
|
7678
7759
|
transferFrom: fromAgentId,
|
|
7679
7760
|
transferTo: currentAgentId,
|
|
@@ -7691,7 +7772,7 @@ var ExecutionHandler = class {
|
|
|
7691
7772
|
const graphSessionData = graphSessionManager.getSession(requestId2);
|
|
7692
7773
|
if (graphSessionData) {
|
|
7693
7774
|
const sessionSummary = graphSessionData.getSummary();
|
|
7694
|
-
|
|
7775
|
+
logger19.info(sessionSummary, "GraphSession data after completion");
|
|
7695
7776
|
}
|
|
7696
7777
|
let textContent = "";
|
|
7697
7778
|
for (const part of responseParts) {
|
|
@@ -7700,78 +7781,84 @@ var ExecutionHandler = class {
|
|
|
7700
7781
|
textContent += part.text;
|
|
7701
7782
|
}
|
|
7702
7783
|
}
|
|
7703
|
-
|
|
7704
|
-
|
|
7705
|
-
|
|
7706
|
-
|
|
7707
|
-
|
|
7708
|
-
|
|
7709
|
-
|
|
7710
|
-
|
|
7711
|
-
|
|
7712
|
-
|
|
7713
|
-
|
|
7714
|
-
|
|
7715
|
-
|
|
7716
|
-
|
|
7717
|
-
|
|
7718
|
-
|
|
7719
|
-
|
|
7720
|
-
|
|
7721
|
-
|
|
7722
|
-
|
|
7723
|
-
|
|
7724
|
-
|
|
7725
|
-
|
|
7726
|
-
|
|
7727
|
-
|
|
7728
|
-
|
|
7729
|
-
|
|
7730
|
-
|
|
7731
|
-
|
|
7732
|
-
|
|
7733
|
-
|
|
7734
|
-
|
|
7735
|
-
|
|
7736
|
-
|
|
7737
|
-
|
|
7738
|
-
|
|
7739
|
-
|
|
7740
|
-
|
|
7741
|
-
|
|
7742
|
-
|
|
7743
|
-
|
|
7784
|
+
return tracer.startActiveSpan("execution_handler.execute", {}, async (span) => {
|
|
7785
|
+
try {
|
|
7786
|
+
span.setAttributes({
|
|
7787
|
+
"ai.response.content": textContent || "No response content",
|
|
7788
|
+
"ai.response.timestamp": (/* @__PURE__ */ new Date()).toISOString(),
|
|
7789
|
+
"ai.agent.name": currentAgentId
|
|
7790
|
+
});
|
|
7791
|
+
await agentsCore.createMessage(dbClient_default)({
|
|
7792
|
+
id: nanoid.nanoid(),
|
|
7793
|
+
tenantId,
|
|
7794
|
+
projectId,
|
|
7795
|
+
conversationId,
|
|
7796
|
+
role: "agent",
|
|
7797
|
+
content: {
|
|
7798
|
+
text: textContent || void 0,
|
|
7799
|
+
parts: responseParts.map((part) => ({
|
|
7800
|
+
type: part.kind === "text" ? "text" : "data",
|
|
7801
|
+
text: part.kind === "text" ? part.text : void 0,
|
|
7802
|
+
data: part.kind === "data" ? JSON.stringify(part.data) : void 0
|
|
7803
|
+
}))
|
|
7804
|
+
},
|
|
7805
|
+
visibility: "user-facing",
|
|
7806
|
+
messageType: "chat",
|
|
7807
|
+
agentId: currentAgentId,
|
|
7808
|
+
fromAgentId: currentAgentId,
|
|
7809
|
+
taskId: task.id
|
|
7810
|
+
});
|
|
7811
|
+
const updateTaskStart = Date.now();
|
|
7812
|
+
await agentsCore.updateTask(dbClient_default)({
|
|
7813
|
+
taskId: task.id,
|
|
7814
|
+
data: {
|
|
7815
|
+
status: "completed",
|
|
7816
|
+
metadata: {
|
|
7817
|
+
...task.metadata,
|
|
7818
|
+
completed_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
7819
|
+
response: {
|
|
7820
|
+
text: textContent,
|
|
7821
|
+
parts: responseParts,
|
|
7822
|
+
hasText: !!textContent,
|
|
7823
|
+
hasData: responseParts.some((p) => p.kind === "data")
|
|
7824
|
+
}
|
|
7825
|
+
}
|
|
7744
7826
|
}
|
|
7827
|
+
});
|
|
7828
|
+
const updateTaskEnd = Date.now();
|
|
7829
|
+
logger19.info(
|
|
7830
|
+
{ duration: updateTaskEnd - updateTaskStart },
|
|
7831
|
+
"Completed updateTask operation"
|
|
7832
|
+
);
|
|
7833
|
+
await sseHelper.writeOperation(completionOp(currentAgentId, iterations));
|
|
7834
|
+
await sseHelper.complete();
|
|
7835
|
+
logger19.info({}, "Ending GraphSession and cleaning up");
|
|
7836
|
+
graphSessionManager.endSession(requestId2);
|
|
7837
|
+
logger19.info({}, "Cleaning up streamHelper");
|
|
7838
|
+
unregisterStreamHelper(requestId2);
|
|
7839
|
+
let response;
|
|
7840
|
+
if (sseHelper instanceof MCPStreamHelper) {
|
|
7841
|
+
const captured = sseHelper.getCapturedResponse();
|
|
7842
|
+
response = captured.text || "No response content";
|
|
7745
7843
|
}
|
|
7844
|
+
logger19.info({}, "ExecutionHandler returning success");
|
|
7845
|
+
return { success: true, iterations, response };
|
|
7846
|
+
} catch (error) {
|
|
7847
|
+
agentsCore.setSpanWithError(span, error);
|
|
7848
|
+
throw error;
|
|
7849
|
+
} finally {
|
|
7850
|
+
span.end();
|
|
7746
7851
|
}
|
|
7747
7852
|
});
|
|
7748
|
-
const updateTaskEnd = Date.now();
|
|
7749
|
-
logger18.info(
|
|
7750
|
-
{ duration: updateTaskEnd - updateTaskStart },
|
|
7751
|
-
"Completed updateTask operation"
|
|
7752
|
-
);
|
|
7753
|
-
await sseHelper.writeOperation(completionOp(currentAgentId, iterations));
|
|
7754
|
-
await sseHelper.complete();
|
|
7755
|
-
logger18.info({}, "Ending GraphSession and cleaning up");
|
|
7756
|
-
graphSessionManager.endSession(requestId2);
|
|
7757
|
-
logger18.info({}, "Cleaning up streamHelper");
|
|
7758
|
-
unregisterStreamHelper(requestId2);
|
|
7759
|
-
let response;
|
|
7760
|
-
if (sseHelper instanceof MCPStreamHelper) {
|
|
7761
|
-
const captured = sseHelper.getCapturedResponse();
|
|
7762
|
-
response = captured.text || "No response content";
|
|
7763
|
-
}
|
|
7764
|
-
logger18.info({}, "ExecutionHandler returning success");
|
|
7765
|
-
return { success: true, iterations, response };
|
|
7766
7853
|
}
|
|
7767
7854
|
errorCount++;
|
|
7768
|
-
|
|
7855
|
+
logger19.warn(
|
|
7769
7856
|
{ iterations, errorCount },
|
|
7770
7857
|
`No valid response or transfer on iteration ${iterations} (error ${errorCount}/${this.MAX_ERRORS})`
|
|
7771
7858
|
);
|
|
7772
7859
|
if (errorCount >= this.MAX_ERRORS) {
|
|
7773
7860
|
const errorMessage2 = `Maximum error limit (${this.MAX_ERRORS}) reached`;
|
|
7774
|
-
|
|
7861
|
+
logger19.error({ maxErrors: this.MAX_ERRORS, errorCount }, errorMessage2);
|
|
7775
7862
|
await sseHelper.writeError(errorMessage2);
|
|
7776
7863
|
await sseHelper.writeOperation(errorOp(errorMessage2, currentAgentId || "system"));
|
|
7777
7864
|
if (task) {
|
|
@@ -7793,7 +7880,7 @@ var ExecutionHandler = class {
|
|
|
7793
7880
|
}
|
|
7794
7881
|
}
|
|
7795
7882
|
const errorMessage = `Maximum transfer limit (${maxTransfers}) reached without completion`;
|
|
7796
|
-
|
|
7883
|
+
logger19.error({ maxTransfers, iterations }, errorMessage);
|
|
7797
7884
|
await sseHelper.writeError(errorMessage);
|
|
7798
7885
|
await sseHelper.writeOperation(errorOp(errorMessage, currentAgentId || "system"));
|
|
7799
7886
|
if (task) {
|
|
@@ -7813,7 +7900,7 @@ var ExecutionHandler = class {
|
|
|
7813
7900
|
unregisterStreamHelper(requestId2);
|
|
7814
7901
|
return { success: false, error: errorMessage, iterations };
|
|
7815
7902
|
} catch (error) {
|
|
7816
|
-
|
|
7903
|
+
logger19.error({ error }, "Error in execution handler");
|
|
7817
7904
|
const errorMessage = error instanceof Error ? error.message : "Unknown execution error";
|
|
7818
7905
|
await sseHelper.writeError(`Execution error: ${errorMessage}`);
|
|
7819
7906
|
await sseHelper.writeOperation(errorOp(errorMessage, currentAgentId || "system"));
|
|
@@ -7839,7 +7926,7 @@ var ExecutionHandler = class {
|
|
|
7839
7926
|
|
|
7840
7927
|
// src/routes/chat.ts
|
|
7841
7928
|
var app2 = new zodOpenapi.OpenAPIHono();
|
|
7842
|
-
var
|
|
7929
|
+
var logger20 = agentsCore.getLogger("completionsHandler");
|
|
7843
7930
|
var chatCompletionsRoute = zodOpenapi.createRoute({
|
|
7844
7931
|
method: "post",
|
|
7845
7932
|
path: "/completions",
|
|
@@ -7957,7 +8044,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
|
|
|
7957
8044
|
tracestate: c.req.header("tracestate"),
|
|
7958
8045
|
baggage: c.req.header("baggage")
|
|
7959
8046
|
};
|
|
7960
|
-
|
|
8047
|
+
logger20.info(
|
|
7961
8048
|
{
|
|
7962
8049
|
otelHeaders,
|
|
7963
8050
|
path: c.req.path,
|
|
@@ -8043,7 +8130,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
|
|
|
8043
8130
|
dbClient_default,
|
|
8044
8131
|
credentialStores
|
|
8045
8132
|
);
|
|
8046
|
-
|
|
8133
|
+
logger20.info(
|
|
8047
8134
|
{
|
|
8048
8135
|
tenantId,
|
|
8049
8136
|
graphId,
|
|
@@ -8089,7 +8176,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
|
|
|
8089
8176
|
return streaming.streamSSE(c, async (stream2) => {
|
|
8090
8177
|
const sseHelper = createSSEStreamHelper(stream2, requestId2, timestamp);
|
|
8091
8178
|
await sseHelper.writeRole();
|
|
8092
|
-
|
|
8179
|
+
logger20.info({ agentId }, "Starting execution");
|
|
8093
8180
|
const executionHandler = new ExecutionHandler();
|
|
8094
8181
|
const result = await executionHandler.execute({
|
|
8095
8182
|
executionContext,
|
|
@@ -8099,7 +8186,7 @@ app2.openapi(chatCompletionsRoute, async (c) => {
|
|
|
8099
8186
|
requestId: requestId2,
|
|
8100
8187
|
sseHelper
|
|
8101
8188
|
});
|
|
8102
|
-
|
|
8189
|
+
logger20.info(
|
|
8103
8190
|
{ result },
|
|
8104
8191
|
`Execution completed: ${result.success ? "success" : "failed"} after ${result.iterations} iterations`
|
|
8105
8192
|
);
|
|
@@ -8135,7 +8222,7 @@ var chat_default = app2;
|
|
|
8135
8222
|
// src/routes/chatDataStream.ts
|
|
8136
8223
|
init_dbClient();
|
|
8137
8224
|
var app3 = new zodOpenapi.OpenAPIHono();
|
|
8138
|
-
var
|
|
8225
|
+
var logger21 = agentsCore.getLogger("chatDataStream");
|
|
8139
8226
|
var chatDataStreamRoute = zodOpenapi.createRoute({
|
|
8140
8227
|
method: "post",
|
|
8141
8228
|
path: "/chat",
|
|
@@ -8240,7 +8327,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
|
|
|
8240
8327
|
);
|
|
8241
8328
|
const lastUserMessage = body.messages.filter((m) => m.role === "user").slice(-1)[0];
|
|
8242
8329
|
const userText = typeof lastUserMessage?.content === "string" ? lastUserMessage.content : lastUserMessage?.parts?.map((p) => p.text).join("") || "";
|
|
8243
|
-
|
|
8330
|
+
logger21.info({ userText, lastUserMessage }, "userText");
|
|
8244
8331
|
const messageSpan = api.trace.getActiveSpan();
|
|
8245
8332
|
if (messageSpan) {
|
|
8246
8333
|
messageSpan.setAttributes({
|
|
@@ -8282,7 +8369,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
|
|
|
8282
8369
|
await streamHelper.writeError("Unable to process request");
|
|
8283
8370
|
}
|
|
8284
8371
|
} catch (err) {
|
|
8285
|
-
|
|
8372
|
+
logger21.error({ err }, "Streaming error");
|
|
8286
8373
|
await streamHelper.writeError("Internal server error");
|
|
8287
8374
|
} finally {
|
|
8288
8375
|
if ("cleanup" in streamHelper && typeof streamHelper.cleanup === "function") {
|
|
@@ -8303,7 +8390,7 @@ app3.openapi(chatDataStreamRoute, async (c) => {
|
|
|
8303
8390
|
)
|
|
8304
8391
|
);
|
|
8305
8392
|
} catch (error) {
|
|
8306
|
-
|
|
8393
|
+
logger21.error({ error }, "chatDataStream error");
|
|
8307
8394
|
return c.json({ error: "Failed to process chat completion" }, 500);
|
|
8308
8395
|
}
|
|
8309
8396
|
});
|
|
@@ -8314,7 +8401,7 @@ init_dbClient();
|
|
|
8314
8401
|
function createMCPSchema(schema) {
|
|
8315
8402
|
return schema;
|
|
8316
8403
|
}
|
|
8317
|
-
var
|
|
8404
|
+
var logger22 = agentsCore.getLogger("mcp");
|
|
8318
8405
|
var _MockResponseSingleton = class _MockResponseSingleton {
|
|
8319
8406
|
constructor() {
|
|
8320
8407
|
__publicField(this, "mockRes");
|
|
@@ -8369,21 +8456,21 @@ var createSpoofInitMessage = (mcpProtocolVersion) => ({
|
|
|
8369
8456
|
id: 0
|
|
8370
8457
|
});
|
|
8371
8458
|
var spoofTransportInitialization = async (transport, req, sessionId, mcpProtocolVersion) => {
|
|
8372
|
-
|
|
8459
|
+
logger22.info({ sessionId }, "Spoofing initialization message to set transport state");
|
|
8373
8460
|
const spoofInitMessage = createSpoofInitMessage(mcpProtocolVersion);
|
|
8374
8461
|
const mockRes = MockResponseSingleton.getInstance().getMockResponse();
|
|
8375
8462
|
try {
|
|
8376
8463
|
await transport.handleRequest(req, mockRes, spoofInitMessage);
|
|
8377
|
-
|
|
8464
|
+
logger22.info({ sessionId }, "Successfully spoofed initialization");
|
|
8378
8465
|
} catch (spoofError) {
|
|
8379
|
-
|
|
8466
|
+
logger22.warn({ sessionId, error: spoofError }, "Spoof initialization failed, continuing anyway");
|
|
8380
8467
|
}
|
|
8381
8468
|
};
|
|
8382
8469
|
var validateSession = async (req, res, body, tenantId, projectId, graphId) => {
|
|
8383
8470
|
const sessionId = req.headers["mcp-session-id"];
|
|
8384
|
-
|
|
8471
|
+
logger22.info({ sessionId }, "Received MCP session ID");
|
|
8385
8472
|
if (!sessionId) {
|
|
8386
|
-
|
|
8473
|
+
logger22.info({ body }, "Missing session ID");
|
|
8387
8474
|
res.writeHead(400).end(
|
|
8388
8475
|
JSON.stringify({
|
|
8389
8476
|
jsonrpc: "2.0",
|
|
@@ -8409,7 +8496,7 @@ var validateSession = async (req, res, body, tenantId, projectId, graphId) => {
|
|
|
8409
8496
|
scopes: { tenantId, projectId },
|
|
8410
8497
|
conversationId: sessionId
|
|
8411
8498
|
});
|
|
8412
|
-
|
|
8499
|
+
logger22.info(
|
|
8413
8500
|
{
|
|
8414
8501
|
sessionId,
|
|
8415
8502
|
conversationFound: !!conversation,
|
|
@@ -8420,7 +8507,7 @@ var validateSession = async (req, res, body, tenantId, projectId, graphId) => {
|
|
|
8420
8507
|
"Conversation lookup result"
|
|
8421
8508
|
);
|
|
8422
8509
|
if (!conversation || conversation.metadata?.sessionData?.sessionType !== "mcp" || conversation.metadata?.sessionData?.graphId !== graphId) {
|
|
8423
|
-
|
|
8510
|
+
logger22.info(
|
|
8424
8511
|
{ sessionId, conversationId: conversation?.id },
|
|
8425
8512
|
"MCP session not found or invalid"
|
|
8426
8513
|
);
|
|
@@ -8481,7 +8568,7 @@ var executeAgentQuery = async (executionContext, conversationId, query, defaultA
|
|
|
8481
8568
|
requestId: requestId2,
|
|
8482
8569
|
sseHelper: mcpStreamHelper
|
|
8483
8570
|
});
|
|
8484
|
-
|
|
8571
|
+
logger22.info(
|
|
8485
8572
|
{ result },
|
|
8486
8573
|
`Execution completed: ${result.success ? "success" : "failed"} after ${result.iterations} iterations`
|
|
8487
8574
|
);
|
|
@@ -8555,7 +8642,7 @@ var getServer = async (requestContext, executionContext, conversationId, credent
|
|
|
8555
8642
|
dbClient_default,
|
|
8556
8643
|
credentialStores
|
|
8557
8644
|
);
|
|
8558
|
-
|
|
8645
|
+
logger22.info(
|
|
8559
8646
|
{
|
|
8560
8647
|
tenantId,
|
|
8561
8648
|
graphId,
|
|
@@ -8616,7 +8703,7 @@ var validateRequestParameters = (c) => {
|
|
|
8616
8703
|
};
|
|
8617
8704
|
var handleInitializationRequest = async (body, executionContext, validatedContext, req, res, c, credentialStores) => {
|
|
8618
8705
|
const { tenantId, projectId, graphId } = executionContext;
|
|
8619
|
-
|
|
8706
|
+
logger22.info({ body }, "Received initialization request");
|
|
8620
8707
|
const sessionId = nanoid.nanoid();
|
|
8621
8708
|
const agentGraph = await agentsCore.getAgentGraphWithDefaultAgent(dbClient_default)({
|
|
8622
8709
|
scopes: { tenantId, projectId },
|
|
@@ -8647,7 +8734,7 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
|
|
|
8647
8734
|
}
|
|
8648
8735
|
}
|
|
8649
8736
|
});
|
|
8650
|
-
|
|
8737
|
+
logger22.info(
|
|
8651
8738
|
{ sessionId, conversationId: conversation.id },
|
|
8652
8739
|
"Created MCP session as conversation"
|
|
8653
8740
|
);
|
|
@@ -8656,9 +8743,9 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
|
|
|
8656
8743
|
});
|
|
8657
8744
|
const server = await getServer(validatedContext, executionContext, sessionId, credentialStores);
|
|
8658
8745
|
await server.connect(transport);
|
|
8659
|
-
|
|
8746
|
+
logger22.info({ sessionId }, "Server connected for initialization");
|
|
8660
8747
|
res.setHeader("Mcp-Session-Id", sessionId);
|
|
8661
|
-
|
|
8748
|
+
logger22.info(
|
|
8662
8749
|
{
|
|
8663
8750
|
sessionId,
|
|
8664
8751
|
bodyMethod: body?.method,
|
|
@@ -8667,7 +8754,7 @@ var handleInitializationRequest = async (body, executionContext, validatedContex
|
|
|
8667
8754
|
"About to handle initialization request"
|
|
8668
8755
|
);
|
|
8669
8756
|
await transport.handleRequest(req, res, body);
|
|
8670
|
-
|
|
8757
|
+
logger22.info({ sessionId }, "Successfully handled initialization request");
|
|
8671
8758
|
return fetchToNode.toFetchResponse(res);
|
|
8672
8759
|
};
|
|
8673
8760
|
var handleExistingSessionRequest = async (body, executionContext, validatedContext, req, res, credentialStores) => {
|
|
@@ -8695,8 +8782,8 @@ var handleExistingSessionRequest = async (body, executionContext, validatedConte
|
|
|
8695
8782
|
sessionId,
|
|
8696
8783
|
conversation.metadata?.session_data?.mcpProtocolVersion
|
|
8697
8784
|
);
|
|
8698
|
-
|
|
8699
|
-
|
|
8785
|
+
logger22.info({ sessionId }, "Server connected and transport initialized");
|
|
8786
|
+
logger22.info(
|
|
8700
8787
|
{
|
|
8701
8788
|
sessionId,
|
|
8702
8789
|
bodyKeys: Object.keys(body || {}),
|
|
@@ -8710,9 +8797,9 @@ var handleExistingSessionRequest = async (body, executionContext, validatedConte
|
|
|
8710
8797
|
);
|
|
8711
8798
|
try {
|
|
8712
8799
|
await transport.handleRequest(req, res, body);
|
|
8713
|
-
|
|
8800
|
+
logger22.info({ sessionId }, "Successfully handled MCP request");
|
|
8714
8801
|
} catch (transportError) {
|
|
8715
|
-
|
|
8802
|
+
logger22.error(
|
|
8716
8803
|
{
|
|
8717
8804
|
sessionId,
|
|
8718
8805
|
error: transportError,
|
|
@@ -8763,13 +8850,13 @@ app4.openapi(
|
|
|
8763
8850
|
}
|
|
8764
8851
|
const { executionContext } = paramValidation;
|
|
8765
8852
|
const body = c.get("requestBody") || {};
|
|
8766
|
-
|
|
8853
|
+
logger22.info({ body, bodyKeys: Object.keys(body || {}) }, "Parsed request body");
|
|
8767
8854
|
const isInitRequest = body.method === "initialize";
|
|
8768
8855
|
const { req, res } = fetchToNode.toReqRes(c.req.raw);
|
|
8769
8856
|
const validatedContext = c.get("validatedContext") || {};
|
|
8770
8857
|
const credentialStores = c.get("credentialStores");
|
|
8771
|
-
|
|
8772
|
-
|
|
8858
|
+
logger22.info({ validatedContext }, "Validated context");
|
|
8859
|
+
logger22.info({ req }, "request");
|
|
8773
8860
|
if (isInitRequest) {
|
|
8774
8861
|
return await handleInitializationRequest(
|
|
8775
8862
|
body,
|
|
@@ -8791,7 +8878,7 @@ app4.openapi(
|
|
|
8791
8878
|
);
|
|
8792
8879
|
}
|
|
8793
8880
|
} catch (e) {
|
|
8794
|
-
|
|
8881
|
+
logger22.error(
|
|
8795
8882
|
{
|
|
8796
8883
|
error: e instanceof Error ? e.message : e,
|
|
8797
8884
|
stack: e instanceof Error ? e.stack : void 0
|
|
@@ -8803,7 +8890,7 @@ app4.openapi(
|
|
|
8803
8890
|
}
|
|
8804
8891
|
);
|
|
8805
8892
|
app4.get("/", async (c) => {
|
|
8806
|
-
|
|
8893
|
+
logger22.info({}, "Received GET MCP request");
|
|
8807
8894
|
return c.json(
|
|
8808
8895
|
{
|
|
8809
8896
|
jsonrpc: "2.0",
|
|
@@ -8817,7 +8904,7 @@ app4.get("/", async (c) => {
|
|
|
8817
8904
|
);
|
|
8818
8905
|
});
|
|
8819
8906
|
app4.delete("/", async (c) => {
|
|
8820
|
-
|
|
8907
|
+
logger22.info({}, "Received DELETE MCP request");
|
|
8821
8908
|
return c.json(
|
|
8822
8909
|
{
|
|
8823
8910
|
jsonrpc: "2.0",
|
|
@@ -8828,11 +8915,10 @@ app4.delete("/", async (c) => {
|
|
|
8828
8915
|
);
|
|
8829
8916
|
});
|
|
8830
8917
|
var mcp_default = app4;
|
|
8831
|
-
|
|
8832
|
-
// src/app.ts
|
|
8833
|
-
var logger22 = agentsCore.getLogger("agents-run-api");
|
|
8918
|
+
var logger23 = agentsCore.getLogger("agents-run-api");
|
|
8834
8919
|
function createExecutionHono(serverConfig, credentialStores) {
|
|
8835
8920
|
const app6 = new zodOpenapi.OpenAPIHono();
|
|
8921
|
+
app6.use("*", otel.otel());
|
|
8836
8922
|
app6.use("*", requestId.requestId());
|
|
8837
8923
|
app6.use("*", async (c, next) => {
|
|
8838
8924
|
c.set("serverConfig", serverConfig);
|
|
@@ -8845,7 +8931,7 @@ function createExecutionHono(serverConfig, credentialStores) {
|
|
|
8845
8931
|
const body = await c.req.json();
|
|
8846
8932
|
c.set("requestBody", body);
|
|
8847
8933
|
} catch (error) {
|
|
8848
|
-
|
|
8934
|
+
logger23.debug({ error }, "Failed to parse JSON body, continuing without parsed body");
|
|
8849
8935
|
}
|
|
8850
8936
|
}
|
|
8851
8937
|
return next();
|
|
@@ -8896,8 +8982,8 @@ function createExecutionHono(serverConfig, credentialStores) {
|
|
|
8896
8982
|
if (!isExpectedError) {
|
|
8897
8983
|
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
8898
8984
|
const errorStack = err instanceof Error ? err.stack : void 0;
|
|
8899
|
-
if (
|
|
8900
|
-
|
|
8985
|
+
if (logger23) {
|
|
8986
|
+
logger23.error(
|
|
8901
8987
|
{
|
|
8902
8988
|
error: err,
|
|
8903
8989
|
message: errorMessage,
|
|
@@ -8909,8 +8995,8 @@ function createExecutionHono(serverConfig, credentialStores) {
|
|
|
8909
8995
|
);
|
|
8910
8996
|
}
|
|
8911
8997
|
} else {
|
|
8912
|
-
if (
|
|
8913
|
-
|
|
8998
|
+
if (logger23) {
|
|
8999
|
+
logger23.error(
|
|
8914
9000
|
{
|
|
8915
9001
|
error: err,
|
|
8916
9002
|
path: c.req.path,
|
|
@@ -8927,8 +9013,8 @@ function createExecutionHono(serverConfig, credentialStores) {
|
|
|
8927
9013
|
const response = err.getResponse();
|
|
8928
9014
|
return response;
|
|
8929
9015
|
} catch (responseError) {
|
|
8930
|
-
if (
|
|
8931
|
-
|
|
9016
|
+
if (logger23) {
|
|
9017
|
+
logger23.error({ error: responseError }, "Error while handling HTTPException response");
|
|
8932
9018
|
}
|
|
8933
9019
|
}
|
|
8934
9020
|
}
|
|
@@ -8962,7 +9048,7 @@ function createExecutionHono(serverConfig, credentialStores) {
|
|
|
8962
9048
|
app6.use("*", async (c, next) => {
|
|
8963
9049
|
const executionContext = c.get("executionContext");
|
|
8964
9050
|
if (!executionContext) {
|
|
8965
|
-
|
|
9051
|
+
logger23.debug({}, "Empty execution context");
|
|
8966
9052
|
return next();
|
|
8967
9053
|
}
|
|
8968
9054
|
const { tenantId, projectId, graphId } = executionContext;
|
|
@@ -8971,7 +9057,7 @@ function createExecutionHono(serverConfig, credentialStores) {
|
|
|
8971
9057
|
if (requestBody) {
|
|
8972
9058
|
conversationId = requestBody.conversationId;
|
|
8973
9059
|
if (!conversationId) {
|
|
8974
|
-
|
|
9060
|
+
logger23.debug({ requestBody }, "No conversation ID found in request body");
|
|
8975
9061
|
}
|
|
8976
9062
|
}
|
|
8977
9063
|
const entries = Object.fromEntries(
|
|
@@ -8986,7 +9072,7 @@ function createExecutionHono(serverConfig, credentialStores) {
|
|
|
8986
9072
|
})
|
|
8987
9073
|
);
|
|
8988
9074
|
if (!Object.keys(entries).length) {
|
|
8989
|
-
|
|
9075
|
+
logger23.debug({}, "Empty entries for baggage");
|
|
8990
9076
|
return next();
|
|
8991
9077
|
}
|
|
8992
9078
|
const bag = Object.entries(entries).reduce(
|