@inkeep/agents-run-api 0.0.0-dev-20250916192201 → 0.0.0-dev-20250917200022
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.
|
@@ -1,35 +1,15 @@
|
|
|
1
|
-
import { createDatabaseClient, createMessage, getConversationHistory } from '@inkeep/agents-core';
|
|
1
|
+
import { loadEnvironmentFiles, createDatabaseClient, createMessage, getConversationHistory } from '@inkeep/agents-core';
|
|
2
2
|
import { nanoid } from 'nanoid';
|
|
3
|
-
import fs from 'fs';
|
|
4
|
-
import path from 'path';
|
|
5
|
-
import * as dotenv from 'dotenv';
|
|
6
3
|
import { z } from 'zod';
|
|
7
4
|
|
|
8
5
|
var __defProp = Object.defineProperty;
|
|
9
6
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
7
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
11
|
-
|
|
12
|
-
z.enum(["development", "production"]).default("development");
|
|
13
|
-
var environmentSchema = z.enum(["development", "pentest", "production", "test"]);
|
|
14
|
-
var criticalEnv = z.object({
|
|
15
|
-
ENVIRONMENT: environmentSchema
|
|
16
|
-
}).parse(process.env);
|
|
17
|
-
var loadEnvFile = () => {
|
|
18
|
-
const envPath = path.resolve(process.cwd(), `.env.${criticalEnv.ENVIRONMENT}.nonsecret`);
|
|
19
|
-
if (fs.existsSync(envPath)) {
|
|
20
|
-
const envConfig = dotenv.parse(fs.readFileSync(envPath));
|
|
21
|
-
for (const k in envConfig) {
|
|
22
|
-
if (!(k in process.env)) {
|
|
23
|
-
process.env[k] = envConfig[k];
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
loadEnvFile();
|
|
8
|
+
loadEnvironmentFiles();
|
|
29
9
|
var envSchema = z.object({
|
|
30
10
|
NODE_ENV: z.enum(["development", "production", "test"]).optional(),
|
|
31
11
|
ENVIRONMENT: z.enum(["development", "production", "pentest", "test"]).optional().default("development"),
|
|
32
|
-
DB_FILE_NAME: z.string()
|
|
12
|
+
DB_FILE_NAME: z.string(),
|
|
33
13
|
AGENTS_RUN_API_URL: z.string().optional().default("http://localhost:3003"),
|
|
34
14
|
LOG_LEVEL: z.enum(["trace", "debug", "info", "warn", "error"]).optional().default("debug"),
|
|
35
15
|
NANGO_SECRET_KEY: z.string().optional(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { createDefaultConversationHistoryConfig, getFormattedConversationHistory, getFullConversationContext, getScopedHistory, getUserFacingHistory, saveA2AMessageResponse } from './chunk-
|
|
1
|
+
export { createDefaultConversationHistoryConfig, getFormattedConversationHistory, getFullConversationContext, getScopedHistory, getUserFacingHistory, saveA2AMessageResponse } from './chunk-7PHUFKNP.js';
|
package/dist/index.cjs
CHANGED
|
@@ -2,11 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var fs = require('fs');
|
|
6
|
-
var path = require('path');
|
|
7
|
-
var dotenv = require('dotenv');
|
|
8
|
-
var z5 = require('zod');
|
|
9
5
|
var agentsCore = require('@inkeep/agents-core');
|
|
6
|
+
var z5 = require('zod');
|
|
10
7
|
var nanoid = require('nanoid');
|
|
11
8
|
var autoInstrumentationsNode = require('@opentelemetry/auto-instrumentations-node');
|
|
12
9
|
var baggageSpanProcessor = require('@opentelemetry/baggage-span-processor');
|
|
@@ -41,27 +38,6 @@ var otel = require('@hono/otel');
|
|
|
41
38
|
|
|
42
39
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
43
40
|
|
|
44
|
-
function _interopNamespace(e) {
|
|
45
|
-
if (e && e.__esModule) return e;
|
|
46
|
-
var n = Object.create(null);
|
|
47
|
-
if (e) {
|
|
48
|
-
Object.keys(e).forEach(function (k) {
|
|
49
|
-
if (k !== 'default') {
|
|
50
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
51
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
52
|
-
enumerable: true,
|
|
53
|
-
get: function () { return e[k]; }
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
n.default = e;
|
|
59
|
-
return Object.freeze(n);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
63
|
-
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
64
|
-
var dotenv__namespace = /*#__PURE__*/_interopNamespace(dotenv);
|
|
65
41
|
var z5__default = /*#__PURE__*/_interopDefault(z5);
|
|
66
42
|
var destr__default = /*#__PURE__*/_interopDefault(destr);
|
|
67
43
|
var traverse__default = /*#__PURE__*/_interopDefault(traverse);
|
|
@@ -78,31 +54,14 @@ var __export = (target, all) => {
|
|
|
78
54
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
79
55
|
};
|
|
80
56
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
81
|
-
var
|
|
57
|
+
var envSchema, parseEnv, env;
|
|
82
58
|
var init_env = __esm({
|
|
83
59
|
"src/env.ts"() {
|
|
84
|
-
|
|
85
|
-
z5.z.enum(["development", "production"]).default("development");
|
|
86
|
-
environmentSchema = z5.z.enum(["development", "pentest", "production", "test"]);
|
|
87
|
-
criticalEnv = z5.z.object({
|
|
88
|
-
ENVIRONMENT: environmentSchema
|
|
89
|
-
}).parse(process.env);
|
|
90
|
-
loadEnvFile = () => {
|
|
91
|
-
const envPath = path__default.default.resolve(process.cwd(), `.env.${criticalEnv.ENVIRONMENT}.nonsecret`);
|
|
92
|
-
if (fs__default.default.existsSync(envPath)) {
|
|
93
|
-
const envConfig = dotenv__namespace.parse(fs__default.default.readFileSync(envPath));
|
|
94
|
-
for (const k in envConfig) {
|
|
95
|
-
if (!(k in process.env)) {
|
|
96
|
-
process.env[k] = envConfig[k];
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
loadEnvFile();
|
|
60
|
+
agentsCore.loadEnvironmentFiles();
|
|
102
61
|
envSchema = z5.z.object({
|
|
103
62
|
NODE_ENV: z5.z.enum(["development", "production", "test"]).optional(),
|
|
104
63
|
ENVIRONMENT: z5.z.enum(["development", "production", "pentest", "test"]).optional().default("development"),
|
|
105
|
-
DB_FILE_NAME: z5.z.string()
|
|
64
|
+
DB_FILE_NAME: z5.z.string(),
|
|
106
65
|
AGENTS_RUN_API_URL: z5.z.string().optional().default("http://localhost:3003"),
|
|
107
66
|
LOG_LEVEL: z5.z.enum(["trace", "debug", "info", "warn", "error"]).optional().default("debug"),
|
|
108
67
|
NANGO_SECRET_KEY: z5.z.string().optional(),
|
|
@@ -356,9 +315,9 @@ var sdk = new sdkNode.NodeSDK({
|
|
|
356
315
|
requestHook: (span) => {
|
|
357
316
|
const method = span.attributes?.["http.request.method"];
|
|
358
317
|
const host = span.attributes?.["server.address"];
|
|
359
|
-
const
|
|
360
|
-
if (method &&
|
|
361
|
-
span.updateName(host ? `${method} ${host}${
|
|
318
|
+
const path = span.attributes?.["url.path"];
|
|
319
|
+
if (method && path)
|
|
320
|
+
span.updateName(host ? `${method} ${host}${path}` : `${method} ${path}`);
|
|
362
321
|
}
|
|
363
322
|
}
|
|
364
323
|
})
|
|
@@ -1414,14 +1373,14 @@ var _ModelFactory = class _ModelFactory {
|
|
|
1414
1373
|
/**
|
|
1415
1374
|
* Create a provider instance with custom configuration
|
|
1416
1375
|
*/
|
|
1417
|
-
static createProvider(provider,
|
|
1376
|
+
static createProvider(provider, config) {
|
|
1418
1377
|
switch (provider) {
|
|
1419
1378
|
case "anthropic":
|
|
1420
|
-
return anthropic.createAnthropic(
|
|
1379
|
+
return anthropic.createAnthropic(config);
|
|
1421
1380
|
case "openai":
|
|
1422
|
-
return openai.createOpenAI(
|
|
1381
|
+
return openai.createOpenAI(config);
|
|
1423
1382
|
case "google":
|
|
1424
|
-
return google.createGoogleGenerativeAI(
|
|
1383
|
+
return google.createGoogleGenerativeAI(config);
|
|
1425
1384
|
default:
|
|
1426
1385
|
throw new Error(`Unsupported provider: ${provider}`);
|
|
1427
1386
|
}
|
|
@@ -1447,13 +1406,13 @@ var _ModelFactory = class _ModelFactory {
|
|
|
1447
1406
|
* Create a language model instance from configuration
|
|
1448
1407
|
* Throws error if no config provided - models must be configured at project level
|
|
1449
1408
|
*/
|
|
1450
|
-
static createModel(
|
|
1451
|
-
if (!
|
|
1409
|
+
static createModel(config) {
|
|
1410
|
+
if (!config?.model?.trim()) {
|
|
1452
1411
|
throw new Error(
|
|
1453
1412
|
"Model configuration is required. Please configure models at the project level."
|
|
1454
1413
|
);
|
|
1455
1414
|
}
|
|
1456
|
-
const modelSettings =
|
|
1415
|
+
const modelSettings = config;
|
|
1457
1416
|
const modelString = modelSettings.model.trim();
|
|
1458
1417
|
const { provider, modelName } = _ModelFactory.parseModelString(modelString);
|
|
1459
1418
|
logger5.debug(
|
|
@@ -1550,19 +1509,19 @@ var _ModelFactory = class _ModelFactory {
|
|
|
1550
1509
|
* Validate model settingsuration
|
|
1551
1510
|
* Basic validation only - let AI SDK handle parameter-specific validation
|
|
1552
1511
|
*/
|
|
1553
|
-
static validateConfig(
|
|
1512
|
+
static validateConfig(config) {
|
|
1554
1513
|
const errors = [];
|
|
1555
|
-
if (!
|
|
1514
|
+
if (!config.model) {
|
|
1556
1515
|
errors.push("Model name is required");
|
|
1557
1516
|
}
|
|
1558
|
-
if (
|
|
1559
|
-
if (
|
|
1517
|
+
if (config.providerOptions) {
|
|
1518
|
+
if (config.providerOptions.apiKey) {
|
|
1560
1519
|
errors.push(
|
|
1561
1520
|
"API keys should not be stored in provider options. Use environment variables (ANTHROPIC_API_KEY, OPENAI_API_KEY) or credential store instead."
|
|
1562
1521
|
);
|
|
1563
1522
|
}
|
|
1564
|
-
if (
|
|
1565
|
-
const maxDuration =
|
|
1523
|
+
if (config.providerOptions.maxDuration !== void 0) {
|
|
1524
|
+
const maxDuration = config.providerOptions.maxDuration;
|
|
1566
1525
|
if (typeof maxDuration !== "number" || maxDuration <= 0) {
|
|
1567
1526
|
errors.push("maxDuration must be a positive number (in seconds)");
|
|
1568
1527
|
}
|
|
@@ -1627,7 +1586,7 @@ var GraphSession = class {
|
|
|
1627
1586
|
/**
|
|
1628
1587
|
* Initialize status updates for this session
|
|
1629
1588
|
*/
|
|
1630
|
-
initializeStatusUpdates(
|
|
1589
|
+
initializeStatusUpdates(config, summarizerModel, baseModel) {
|
|
1631
1590
|
const now = Date.now();
|
|
1632
1591
|
this.statusUpdateState = {
|
|
1633
1592
|
lastUpdateTime: now,
|
|
@@ -1636,9 +1595,9 @@ var GraphSession = class {
|
|
|
1636
1595
|
summarizerModel,
|
|
1637
1596
|
baseModel,
|
|
1638
1597
|
config: {
|
|
1639
|
-
numEvents:
|
|
1640
|
-
timeInSeconds:
|
|
1641
|
-
...
|
|
1598
|
+
numEvents: config.numEvents || 1,
|
|
1599
|
+
timeInSeconds: config.timeInSeconds || 2,
|
|
1600
|
+
...config
|
|
1642
1601
|
}
|
|
1643
1602
|
};
|
|
1644
1603
|
if (this.statusUpdateState.config.timeInSeconds) {
|
|
@@ -2731,10 +2690,10 @@ var GraphSessionManager = class {
|
|
|
2731
2690
|
/**
|
|
2732
2691
|
* Initialize status updates for a session
|
|
2733
2692
|
*/
|
|
2734
|
-
initializeStatusUpdates(sessionId,
|
|
2693
|
+
initializeStatusUpdates(sessionId, config, summarizerModel) {
|
|
2735
2694
|
const session = this.sessions.get(sessionId);
|
|
2736
2695
|
if (session) {
|
|
2737
|
-
session.initializeStatusUpdates(
|
|
2696
|
+
session.initializeStatusUpdates(config, summarizerModel);
|
|
2738
2697
|
} else {
|
|
2739
2698
|
logger6.error(
|
|
2740
2699
|
{
|
|
@@ -3598,7 +3557,7 @@ function analyzeSelectorFailure(data, selector) {
|
|
|
3598
3557
|
if (keyNestingMap.has(part)) {
|
|
3599
3558
|
const allPaths = keyNestingMap.get(part);
|
|
3600
3559
|
const relevantPaths = allPaths.filter(
|
|
3601
|
-
(
|
|
3560
|
+
(path) => path.includes(validPath) || validPath === ""
|
|
3602
3561
|
);
|
|
3603
3562
|
if (relevantPaths.length > 0) {
|
|
3604
3563
|
suggestions.push(`"${part}" exists at: ${relevantPaths.slice(0, 3).join(", ")}`);
|
|
@@ -3615,7 +3574,7 @@ function analyzeSelectorFailure(data, selector) {
|
|
|
3615
3574
|
analysis.push("PATH VALID BUT FILTER FAILED");
|
|
3616
3575
|
const allPaths = keyNestingMap.get(targetKey);
|
|
3617
3576
|
const deeperPaths = allPaths.filter(
|
|
3618
|
-
(
|
|
3577
|
+
(path) => path.length > selector.replace(/\[.*?\]/g, "").length
|
|
3619
3578
|
);
|
|
3620
3579
|
if (deeperPaths.length > 0) {
|
|
3621
3580
|
suggestions.push(
|
|
@@ -4116,17 +4075,17 @@ var A2AClient = class {
|
|
|
4116
4075
|
* Retry utility functions
|
|
4117
4076
|
*/
|
|
4118
4077
|
async retry(fetchFn) {
|
|
4119
|
-
const
|
|
4120
|
-
if (!
|
|
4078
|
+
const config = this.options.retryConfig;
|
|
4079
|
+
if (!config || config.strategy === "none") {
|
|
4121
4080
|
return await fetchFn();
|
|
4122
4081
|
}
|
|
4123
|
-
const statusCodes =
|
|
4082
|
+
const statusCodes = config.statusCodes || DEFAULT_RETRY_STATUS_CODES;
|
|
4124
4083
|
return this.retryBackoff(
|
|
4125
4084
|
this.wrapFetcher(fetchFn, {
|
|
4126
4085
|
statusCodes,
|
|
4127
|
-
retryConnectionErrors: !!
|
|
4086
|
+
retryConnectionErrors: !!config.retryConnectionErrors
|
|
4128
4087
|
}),
|
|
4129
|
-
|
|
4088
|
+
config.backoff ?? DEFAULT_BACKOFF
|
|
4130
4089
|
);
|
|
4131
4090
|
}
|
|
4132
4091
|
wrapFetcher(fn, options) {
|
|
@@ -4591,25 +4550,25 @@ var A2AClient = class {
|
|
|
4591
4550
|
init_conversations();
|
|
4592
4551
|
init_dbClient();
|
|
4593
4552
|
var logger13 = agentsCore.getLogger("relationships Tools");
|
|
4594
|
-
var generateTransferToolDescription = (
|
|
4595
|
-
return `Hand off the conversation to agent ${
|
|
4553
|
+
var generateTransferToolDescription = (config) => {
|
|
4554
|
+
return `Hand off the conversation to agent ${config.id}.
|
|
4596
4555
|
|
|
4597
4556
|
Agent Information:
|
|
4598
|
-
- ID: ${
|
|
4599
|
-
- Name: ${
|
|
4600
|
-
- Description: ${
|
|
4557
|
+
- ID: ${config.id}
|
|
4558
|
+
- Name: ${config.name ?? "No name provided"}
|
|
4559
|
+
- Description: ${config.description ?? "No description provided"}
|
|
4601
4560
|
|
|
4602
|
-
Hand off the conversation to agent ${
|
|
4561
|
+
Hand off the conversation to agent ${config.id} when the user's request would be better handled by this specialized agent.`;
|
|
4603
4562
|
};
|
|
4604
|
-
var generateDelegateToolDescription = (
|
|
4563
|
+
var generateDelegateToolDescription = (config) => {
|
|
4605
4564
|
return `Delegate a specific task to another agent.
|
|
4606
4565
|
|
|
4607
4566
|
Agent Information:
|
|
4608
|
-
- ID: ${
|
|
4609
|
-
- Name: ${
|
|
4610
|
-
- Description: ${
|
|
4567
|
+
- ID: ${config.id}
|
|
4568
|
+
- Name: ${config.name}
|
|
4569
|
+
- Description: ${config.description || "No description provided"}
|
|
4611
4570
|
|
|
4612
|
-
Delegate a specific task to agent ${
|
|
4571
|
+
Delegate a specific task to agent ${config.id} when it seems like the agent can do relevant work.`;
|
|
4613
4572
|
};
|
|
4614
4573
|
var createTransferToAgentTool = ({
|
|
4615
4574
|
transferConfig,
|
|
@@ -4863,16 +4822,16 @@ var SystemPromptBuilder = class {
|
|
|
4863
4822
|
throw new Error(`Template loading failed: ${error}`);
|
|
4864
4823
|
}
|
|
4865
4824
|
}
|
|
4866
|
-
buildSystemPrompt(
|
|
4825
|
+
buildSystemPrompt(config) {
|
|
4867
4826
|
this.loadTemplates();
|
|
4868
|
-
this.validateTemplateVariables(
|
|
4869
|
-
return this.versionConfig.assemble(this.templates,
|
|
4827
|
+
this.validateTemplateVariables(config);
|
|
4828
|
+
return this.versionConfig.assemble(this.templates, config);
|
|
4870
4829
|
}
|
|
4871
|
-
validateTemplateVariables(
|
|
4872
|
-
if (!
|
|
4830
|
+
validateTemplateVariables(config) {
|
|
4831
|
+
if (!config) {
|
|
4873
4832
|
throw new Error("Configuration object is required");
|
|
4874
4833
|
}
|
|
4875
|
-
if (typeof
|
|
4834
|
+
if (typeof config !== "object") {
|
|
4876
4835
|
throw new Error("Configuration must be an object");
|
|
4877
4836
|
}
|
|
4878
4837
|
}
|
|
@@ -4985,20 +4944,20 @@ var V1Config = class _V1Config {
|
|
|
4985
4944
|
const firstItem = tools[0];
|
|
4986
4945
|
return "usageGuidelines" in firstItem && !("config" in firstItem);
|
|
4987
4946
|
}
|
|
4988
|
-
assemble(templates,
|
|
4947
|
+
assemble(templates, config) {
|
|
4989
4948
|
const systemPromptTemplate = templates.get("system-prompt");
|
|
4990
4949
|
if (!systemPromptTemplate) {
|
|
4991
4950
|
throw new Error("System prompt template not loaded");
|
|
4992
4951
|
}
|
|
4993
4952
|
let systemPrompt = systemPromptTemplate;
|
|
4994
|
-
systemPrompt = systemPrompt.replace("{{CORE_INSTRUCTIONS}}",
|
|
4995
|
-
const graphContextSection = this.generateGraphContextSection(
|
|
4953
|
+
systemPrompt = systemPrompt.replace("{{CORE_INSTRUCTIONS}}", config.corePrompt);
|
|
4954
|
+
const graphContextSection = this.generateGraphContextSection(config.graphPrompt);
|
|
4996
4955
|
systemPrompt = systemPrompt.replace("{{GRAPH_CONTEXT_SECTION}}", graphContextSection);
|
|
4997
|
-
const toolData = this.isToolDataArray(
|
|
4998
|
-
const hasDataComponents =
|
|
4956
|
+
const toolData = this.isToolDataArray(config.tools) ? config.tools : _V1Config.convertMcpToolsToToolData(config.tools);
|
|
4957
|
+
const hasDataComponents = config.dataComponents && config.dataComponents.length > 0;
|
|
4999
4958
|
const artifactsSection = this.generateArtifactsSection(
|
|
5000
4959
|
templates,
|
|
5001
|
-
|
|
4960
|
+
config.artifacts,
|
|
5002
4961
|
hasDataComponents
|
|
5003
4962
|
);
|
|
5004
4963
|
systemPrompt = systemPrompt.replace("{{ARTIFACTS_SECTION}}", artifactsSection);
|
|
@@ -5006,20 +4965,20 @@ var V1Config = class _V1Config {
|
|
|
5006
4965
|
systemPrompt = systemPrompt.replace("{{TOOLS_SECTION}}", toolsSection);
|
|
5007
4966
|
const dataComponentsSection = this.generateDataComponentsSection(
|
|
5008
4967
|
templates,
|
|
5009
|
-
|
|
4968
|
+
config.dataComponents
|
|
5010
4969
|
);
|
|
5011
4970
|
systemPrompt = systemPrompt.replace("{{DATA_COMPONENTS_SECTION}}", dataComponentsSection);
|
|
5012
4971
|
const thinkingPreparationSection = this.generateThinkingPreparationSection(
|
|
5013
4972
|
templates,
|
|
5014
|
-
|
|
4973
|
+
config.isThinkingPreparation
|
|
5015
4974
|
);
|
|
5016
4975
|
systemPrompt = systemPrompt.replace(
|
|
5017
4976
|
"{{THINKING_PREPARATION_INSTRUCTIONS}}",
|
|
5018
4977
|
thinkingPreparationSection
|
|
5019
4978
|
);
|
|
5020
|
-
const transferSection = this.generateTransferInstructions(
|
|
4979
|
+
const transferSection = this.generateTransferInstructions(config.hasTransferRelations);
|
|
5021
4980
|
systemPrompt = systemPrompt.replace("{{TRANSFER_INSTRUCTIONS}}", transferSection);
|
|
5022
|
-
const delegationSection = this.generateDelegationInstructions(
|
|
4981
|
+
const delegationSection = this.generateDelegationInstructions(config.hasDelegateRelations);
|
|
5023
4982
|
systemPrompt = systemPrompt.replace("{{DELEGATION_INSTRUCTIONS}}", delegationSection);
|
|
5024
4983
|
return systemPrompt;
|
|
5025
4984
|
}
|
|
@@ -5283,7 +5242,7 @@ function isValidTool(tool4) {
|
|
|
5283
5242
|
return tool4 && typeof tool4 === "object" && typeof tool4.description === "string" && tool4.inputSchema && typeof tool4.execute === "function";
|
|
5284
5243
|
}
|
|
5285
5244
|
var Agent = class {
|
|
5286
|
-
constructor(
|
|
5245
|
+
constructor(config, credentialStoreRegistry) {
|
|
5287
5246
|
__publicField(this, "config");
|
|
5288
5247
|
__publicField(this, "systemPromptBuilder", new SystemPromptBuilder("v1", new V1Config()));
|
|
5289
5248
|
__publicField(this, "responseFormatter");
|
|
@@ -5295,26 +5254,26 @@ var Agent = class {
|
|
|
5295
5254
|
__publicField(this, "isDelegatedAgent", false);
|
|
5296
5255
|
__publicField(this, "contextResolver");
|
|
5297
5256
|
__publicField(this, "credentialStoreRegistry");
|
|
5298
|
-
this.artifactComponents =
|
|
5299
|
-
let processedDataComponents =
|
|
5300
|
-
if (this.artifactComponents.length > 0 &&
|
|
5257
|
+
this.artifactComponents = config.artifactComponents || [];
|
|
5258
|
+
let processedDataComponents = config.dataComponents || [];
|
|
5259
|
+
if (this.artifactComponents.length > 0 && config.dataComponents && config.dataComponents.length > 0) {
|
|
5301
5260
|
processedDataComponents = [
|
|
5302
|
-
ArtifactReferenceSchema.getDataComponent(
|
|
5261
|
+
ArtifactReferenceSchema.getDataComponent(config.tenantId, config.projectId),
|
|
5303
5262
|
...processedDataComponents
|
|
5304
5263
|
];
|
|
5305
5264
|
}
|
|
5306
5265
|
this.config = {
|
|
5307
|
-
...
|
|
5266
|
+
...config,
|
|
5308
5267
|
dataComponents: processedDataComponents,
|
|
5309
5268
|
// Set default conversation history if not provided
|
|
5310
|
-
conversationHistoryConfig:
|
|
5269
|
+
conversationHistoryConfig: config.conversationHistoryConfig || createDefaultConversationHistoryConfig()
|
|
5311
5270
|
};
|
|
5312
|
-
this.responseFormatter = new ResponseFormatter(
|
|
5271
|
+
this.responseFormatter = new ResponseFormatter(config.tenantId);
|
|
5313
5272
|
this.credentialStoreRegistry = credentialStoreRegistry;
|
|
5314
5273
|
if (credentialStoreRegistry) {
|
|
5315
5274
|
this.contextResolver = new agentsCore.ContextResolver(
|
|
5316
|
-
|
|
5317
|
-
|
|
5275
|
+
config.tenantId,
|
|
5276
|
+
config.projectId,
|
|
5318
5277
|
dbClient_default,
|
|
5319
5278
|
credentialStoreRegistry
|
|
5320
5279
|
);
|
|
@@ -5862,7 +5821,7 @@ Key requirements:
|
|
|
5862
5821
|
);
|
|
5863
5822
|
}
|
|
5864
5823
|
}
|
|
5865
|
-
const
|
|
5824
|
+
const config = {
|
|
5866
5825
|
corePrompt: processedPrompt,
|
|
5867
5826
|
graphPrompt,
|
|
5868
5827
|
tools: toolDefinitions,
|
|
@@ -5872,7 +5831,7 @@ Key requirements:
|
|
|
5872
5831
|
hasTransferRelations: (this.config.transferRelations?.length ?? 0) > 0,
|
|
5873
5832
|
hasDelegateRelations: (this.config.delegateRelations?.length ?? 0) > 0
|
|
5874
5833
|
};
|
|
5875
|
-
return await this.systemPromptBuilder.buildSystemPrompt(
|
|
5834
|
+
return await this.systemPromptBuilder.buildSystemPrompt(config);
|
|
5876
5835
|
}
|
|
5877
5836
|
getArtifactTools() {
|
|
5878
5837
|
return ai.tool({
|
|
@@ -6413,7 +6372,7 @@ function parseEmbeddedJson(data) {
|
|
|
6413
6372
|
});
|
|
6414
6373
|
}
|
|
6415
6374
|
var logger16 = agentsCore.getLogger("generateTaskHandler");
|
|
6416
|
-
var createTaskHandler = (
|
|
6375
|
+
var createTaskHandler = (config, credentialStoreRegistry) => {
|
|
6417
6376
|
return async (task) => {
|
|
6418
6377
|
try {
|
|
6419
6378
|
const userMessage = task.input.parts.filter((part) => part.text).map((part) => part.text).join(" ");
|
|
@@ -6434,32 +6393,32 @@ var createTaskHandler = (config2, credentialStoreRegistry) => {
|
|
|
6434
6393
|
] = await Promise.all([
|
|
6435
6394
|
agentsCore.getRelatedAgentsForGraph(dbClient_default)({
|
|
6436
6395
|
scopes: {
|
|
6437
|
-
tenantId:
|
|
6438
|
-
projectId:
|
|
6396
|
+
tenantId: config.tenantId,
|
|
6397
|
+
projectId: config.projectId
|
|
6439
6398
|
},
|
|
6440
|
-
graphId:
|
|
6441
|
-
agentId:
|
|
6399
|
+
graphId: config.graphId,
|
|
6400
|
+
agentId: config.agentId
|
|
6442
6401
|
}),
|
|
6443
6402
|
agentsCore.getToolsForAgent(dbClient_default)({
|
|
6444
6403
|
scopes: {
|
|
6445
|
-
tenantId:
|
|
6446
|
-
projectId:
|
|
6404
|
+
tenantId: config.tenantId,
|
|
6405
|
+
projectId: config.projectId
|
|
6447
6406
|
},
|
|
6448
|
-
agentId:
|
|
6407
|
+
agentId: config.agentId
|
|
6449
6408
|
}),
|
|
6450
6409
|
agentsCore.getDataComponentsForAgent(dbClient_default)({
|
|
6451
6410
|
scopes: {
|
|
6452
|
-
tenantId:
|
|
6453
|
-
projectId:
|
|
6411
|
+
tenantId: config.tenantId,
|
|
6412
|
+
projectId: config.projectId
|
|
6454
6413
|
},
|
|
6455
|
-
agentId:
|
|
6414
|
+
agentId: config.agentId
|
|
6456
6415
|
}),
|
|
6457
6416
|
agentsCore.getArtifactComponentsForAgent(dbClient_default)({
|
|
6458
6417
|
scopes: {
|
|
6459
|
-
tenantId:
|
|
6460
|
-
projectId:
|
|
6418
|
+
tenantId: config.tenantId,
|
|
6419
|
+
projectId: config.projectId
|
|
6461
6420
|
},
|
|
6462
|
-
agentId:
|
|
6421
|
+
agentId: config.agentId
|
|
6463
6422
|
})
|
|
6464
6423
|
]);
|
|
6465
6424
|
logger16.info({ toolsForAgent, internalRelations, externalRelations }, "agent stuff");
|
|
@@ -6467,13 +6426,13 @@ var createTaskHandler = (config2, credentialStoreRegistry) => {
|
|
|
6467
6426
|
internalRelations.map(async (relation) => {
|
|
6468
6427
|
try {
|
|
6469
6428
|
const relatedAgent = await agentsCore.getAgentById(dbClient_default)({
|
|
6470
|
-
scopes: { tenantId:
|
|
6429
|
+
scopes: { tenantId: config.tenantId, projectId: config.projectId },
|
|
6471
6430
|
agentId: relation.id
|
|
6472
6431
|
});
|
|
6473
6432
|
if (relatedAgent) {
|
|
6474
6433
|
const relatedAgentRelations = await agentsCore.getRelatedAgentsForGraph(dbClient_default)({
|
|
6475
|
-
scopes: { tenantId:
|
|
6476
|
-
graphId:
|
|
6434
|
+
scopes: { tenantId: config.tenantId, projectId: config.projectId },
|
|
6435
|
+
graphId: config.graphId,
|
|
6477
6436
|
agentId: relation.id
|
|
6478
6437
|
});
|
|
6479
6438
|
const enhancedDescription = generateDescriptionWithTransfers(
|
|
@@ -6489,29 +6448,29 @@ var createTaskHandler = (config2, credentialStoreRegistry) => {
|
|
|
6489
6448
|
return relation;
|
|
6490
6449
|
})
|
|
6491
6450
|
);
|
|
6492
|
-
const agentPrompt = "prompt" in
|
|
6493
|
-
const models = "models" in
|
|
6494
|
-
const stopWhen = "stopWhen" in
|
|
6451
|
+
const agentPrompt = "prompt" in config.agentSchema ? config.agentSchema.prompt : "";
|
|
6452
|
+
const models = "models" in config.agentSchema ? config.agentSchema.models : void 0;
|
|
6453
|
+
const stopWhen = "stopWhen" in config.agentSchema ? config.agentSchema.stopWhen : void 0;
|
|
6495
6454
|
const agent = new Agent(
|
|
6496
6455
|
{
|
|
6497
|
-
id:
|
|
6498
|
-
tenantId:
|
|
6499
|
-
projectId:
|
|
6500
|
-
graphId:
|
|
6501
|
-
baseUrl:
|
|
6502
|
-
apiKey:
|
|
6503
|
-
name:
|
|
6504
|
-
description:
|
|
6456
|
+
id: config.agentId,
|
|
6457
|
+
tenantId: config.tenantId,
|
|
6458
|
+
projectId: config.projectId,
|
|
6459
|
+
graphId: config.graphId,
|
|
6460
|
+
baseUrl: config.baseUrl,
|
|
6461
|
+
apiKey: config.apiKey,
|
|
6462
|
+
name: config.name,
|
|
6463
|
+
description: config.description || "",
|
|
6505
6464
|
agentPrompt,
|
|
6506
6465
|
models: models || void 0,
|
|
6507
6466
|
stopWhen: stopWhen || void 0,
|
|
6508
6467
|
agentRelations: enhancedInternalRelations.map((relation) => ({
|
|
6509
6468
|
id: relation.id,
|
|
6510
|
-
tenantId:
|
|
6511
|
-
projectId:
|
|
6512
|
-
graphId:
|
|
6513
|
-
baseUrl:
|
|
6514
|
-
apiKey:
|
|
6469
|
+
tenantId: config.tenantId,
|
|
6470
|
+
projectId: config.projectId,
|
|
6471
|
+
graphId: config.graphId,
|
|
6472
|
+
baseUrl: config.baseUrl,
|
|
6473
|
+
apiKey: config.apiKey,
|
|
6515
6474
|
name: relation.name,
|
|
6516
6475
|
description: relation.description,
|
|
6517
6476
|
agentPrompt: "",
|
|
@@ -6520,12 +6479,12 @@ var createTaskHandler = (config2, credentialStoreRegistry) => {
|
|
|
6520
6479
|
transferRelations: []
|
|
6521
6480
|
})),
|
|
6522
6481
|
transferRelations: enhancedInternalRelations.filter((relation) => relation.relationType === "transfer").map((relation) => ({
|
|
6523
|
-
baseUrl:
|
|
6524
|
-
apiKey:
|
|
6482
|
+
baseUrl: config.baseUrl,
|
|
6483
|
+
apiKey: config.apiKey,
|
|
6525
6484
|
id: relation.id,
|
|
6526
|
-
tenantId:
|
|
6527
|
-
projectId:
|
|
6528
|
-
graphId:
|
|
6485
|
+
tenantId: config.tenantId,
|
|
6486
|
+
projectId: config.projectId,
|
|
6487
|
+
graphId: config.graphId,
|
|
6529
6488
|
name: relation.name,
|
|
6530
6489
|
description: relation.description,
|
|
6531
6490
|
agentPrompt: "",
|
|
@@ -6539,11 +6498,11 @@ var createTaskHandler = (config2, credentialStoreRegistry) => {
|
|
|
6539
6498
|
type: "internal",
|
|
6540
6499
|
config: {
|
|
6541
6500
|
id: relation.id,
|
|
6542
|
-
tenantId:
|
|
6543
|
-
projectId:
|
|
6544
|
-
graphId:
|
|
6545
|
-
baseUrl:
|
|
6546
|
-
apiKey:
|
|
6501
|
+
tenantId: config.tenantId,
|
|
6502
|
+
projectId: config.projectId,
|
|
6503
|
+
graphId: config.graphId,
|
|
6504
|
+
baseUrl: config.baseUrl,
|
|
6505
|
+
apiKey: config.apiKey,
|
|
6547
6506
|
name: relation.name,
|
|
6548
6507
|
description: relation.description,
|
|
6549
6508
|
agentPrompt: "",
|
|
@@ -6578,8 +6537,8 @@ var createTaskHandler = (config2, credentialStoreRegistry) => {
|
|
|
6578
6537
|
// All tools are now handled via MCP servers
|
|
6579
6538
|
dataComponents,
|
|
6580
6539
|
artifactComponents,
|
|
6581
|
-
contextConfigId:
|
|
6582
|
-
conversationHistoryConfig:
|
|
6540
|
+
contextConfigId: config.contextConfigId || void 0,
|
|
6541
|
+
conversationHistoryConfig: config.conversationHistoryConfig
|
|
6583
6542
|
},
|
|
6584
6543
|
credentialStoreRegistry
|
|
6585
6544
|
);
|
|
@@ -6592,7 +6551,7 @@ var createTaskHandler = (config2, credentialStoreRegistry) => {
|
|
|
6592
6551
|
{
|
|
6593
6552
|
taskId: task.id,
|
|
6594
6553
|
extractedContextId: contextId,
|
|
6595
|
-
agentId:
|
|
6554
|
+
agentId: config.agentId
|
|
6596
6555
|
},
|
|
6597
6556
|
"Extracted contextId from task ID for delegation"
|
|
6598
6557
|
);
|
|
@@ -6605,7 +6564,7 @@ var createTaskHandler = (config2, credentialStoreRegistry) => {
|
|
|
6605
6564
|
agent.setDelegationStatus(isDelegation);
|
|
6606
6565
|
if (isDelegation) {
|
|
6607
6566
|
logger16.info(
|
|
6608
|
-
{ agentId:
|
|
6567
|
+
{ agentId: config.agentId, taskId: task.id },
|
|
6609
6568
|
"Delegated agent - streaming disabled"
|
|
6610
6569
|
);
|
|
6611
6570
|
}
|
|
@@ -6617,7 +6576,7 @@ var createTaskHandler = (config2, credentialStoreRegistry) => {
|
|
|
6617
6576
|
threadId: contextId,
|
|
6618
6577
|
// using conversationId as threadId for now
|
|
6619
6578
|
streamRequestId,
|
|
6620
|
-
...
|
|
6579
|
+
...config.apiKey ? { apiKey: config.apiKey } : {}
|
|
6621
6580
|
}
|
|
6622
6581
|
});
|
|
6623
6582
|
const stepContents = response.steps && Array.isArray(response.steps) ? response.steps.flatMap((step) => {
|
|
@@ -9139,9 +9098,9 @@ var defaultStores = agentsCore.createDefaultCredentialStores();
|
|
|
9139
9098
|
var defaultRegistry = new agentsCore.CredentialStoreRegistry(defaultStores);
|
|
9140
9099
|
var app5 = createExecutionHono(defaultConfig, defaultRegistry);
|
|
9141
9100
|
var index_default = app5;
|
|
9142
|
-
function createExecutionApp(
|
|
9143
|
-
const serverConfig =
|
|
9144
|
-
const stores =
|
|
9101
|
+
function createExecutionApp(config) {
|
|
9102
|
+
const serverConfig = config?.serverConfig ?? defaultConfig;
|
|
9103
|
+
const stores = config?.credentialStores ?? defaultStores;
|
|
9145
9104
|
const registry = new agentsCore.CredentialStoreRegistry(stores);
|
|
9146
9105
|
return createExecutionHono(serverConfig, registry);
|
|
9147
9106
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { env, __publicField, dbClient_default, getFormattedConversationHistory, createDefaultConversationHistoryConfig, saveA2AMessageResponse } from './chunk-
|
|
1
|
+
import { env, __publicField, dbClient_default, getFormattedConversationHistory, createDefaultConversationHistoryConfig, saveA2AMessageResponse } from './chunk-7PHUFKNP.js';
|
|
2
2
|
import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';
|
|
3
3
|
import { BaggageSpanProcessor, ALLOW_ALL_BAGGAGE_KEYS } from '@opentelemetry/baggage-span-processor';
|
|
4
4
|
import { AsyncLocalStorageContextManager } from '@opentelemetry/context-async-hooks';
|
|
@@ -2212,7 +2212,7 @@ ${this.statusUpdateState?.config.prompt?.trim() || ""}`;
|
|
|
2212
2212
|
);
|
|
2213
2213
|
}
|
|
2214
2214
|
span.setAttributes({ "validation.passed": true });
|
|
2215
|
-
const { getFormattedConversationHistory: getFormattedConversationHistory2 } = await import('./conversations-
|
|
2215
|
+
const { getFormattedConversationHistory: getFormattedConversationHistory2 } = await import('./conversations-WDOIWO7W.js');
|
|
2216
2216
|
const conversationHistory = await getFormattedConversationHistory2({
|
|
2217
2217
|
tenantId: artifactData.tenantId,
|
|
2218
2218
|
projectId: artifactData.projectId,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/agents-run-api",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-20250917200022",
|
|
4
4
|
"description": "Agents Run API for Inkeep Agent Framework - handles chat, agent execution, and streaming",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"traverse": "^0.6.11",
|
|
46
46
|
"ts-pattern": "^5.7.1",
|
|
47
47
|
"zod": "^4.1.5",
|
|
48
|
-
"@inkeep/agents-core": "^0.0.0-dev-
|
|
48
|
+
"@inkeep/agents-core": "^0.0.0-dev-20250917200022"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@hono/vite-dev-server": "^0.20.1",
|