@inkeep/agents-run-api 0.0.0-dev-20260106234559 → 0.0.0-dev-20260107161316
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/a2a/handlers.js +18 -2
- package/dist/agents/Agent.d.ts +2 -0
- package/dist/agents/Agent.js +8 -2
- package/dist/agents/generateTaskHandler.js +3 -1
- package/dist/create-app.d.ts +2 -2
- package/dist/handlers/executionHandler.d.ts +2 -0
- package/dist/handlers/executionHandler.js +3 -2
- package/dist/index.d.ts +3 -3
- package/dist/routes/chat.js +7 -1
- package/dist/routes/chatDataStream.js +9 -2
- package/package.json +2 -2
package/dist/a2a/handlers.js
CHANGED
|
@@ -50,6 +50,13 @@ async function handleMessageSend(c, agent, request) {
|
|
|
50
50
|
try {
|
|
51
51
|
const params = request.params;
|
|
52
52
|
const { agentId } = getRequestExecutionContext(c);
|
|
53
|
+
const forwardedHeaders = {};
|
|
54
|
+
const xForwardedCookie = c.req.header("x-forwarded-cookie");
|
|
55
|
+
const authorization = c.req.header("authorization");
|
|
56
|
+
const cookie = c.req.header("cookie");
|
|
57
|
+
if (xForwardedCookie) forwardedHeaders["x-forwarded-cookie"] = xForwardedCookie;
|
|
58
|
+
else if (cookie) forwardedHeaders["x-forwarded-cookie"] = cookie;
|
|
59
|
+
if (authorization) forwardedHeaders.authorization = authorization;
|
|
53
60
|
const task = {
|
|
54
61
|
id: generateId(),
|
|
55
62
|
input: { parts: params.message.parts.map((part) => ({
|
|
@@ -62,7 +69,8 @@ async function handleMessageSend(c, agent, request) {
|
|
|
62
69
|
metadata: {
|
|
63
70
|
blocking: params.configuration?.blocking ?? false,
|
|
64
71
|
custom: { agent_id: agentId || "" },
|
|
65
|
-
...params.message.metadata
|
|
72
|
+
...params.message.metadata,
|
|
73
|
+
forwardedHeaders: Object.keys(forwardedHeaders).length > 0 ? forwardedHeaders : void 0
|
|
66
74
|
}
|
|
67
75
|
}
|
|
68
76
|
};
|
|
@@ -297,6 +305,13 @@ async function handleMessageStream(c, agent, request) {
|
|
|
297
305
|
},
|
|
298
306
|
id: request.id
|
|
299
307
|
});
|
|
308
|
+
const forwardedHeaders = {};
|
|
309
|
+
const xForwardedCookie = c.req.header("x-forwarded-cookie");
|
|
310
|
+
const authorization = c.req.header("authorization");
|
|
311
|
+
const cookie = c.req.header("cookie");
|
|
312
|
+
if (xForwardedCookie) forwardedHeaders["x-forwarded-cookie"] = xForwardedCookie;
|
|
313
|
+
else if (cookie) forwardedHeaders["x-forwarded-cookie"] = cookie;
|
|
314
|
+
if (authorization) forwardedHeaders.authorization = authorization;
|
|
300
315
|
const task = {
|
|
301
316
|
id: generateId(),
|
|
302
317
|
input: { parts: params.message.parts.map((part) => ({
|
|
@@ -308,7 +323,8 @@ async function handleMessageStream(c, agent, request) {
|
|
|
308
323
|
conversationId: params.message.contextId,
|
|
309
324
|
metadata: {
|
|
310
325
|
blocking: false,
|
|
311
|
-
custom: { agent_id: agentId || "" }
|
|
326
|
+
custom: { agent_id: agentId || "" },
|
|
327
|
+
forwardedHeaders: Object.keys(forwardedHeaders).length > 0 ? forwardedHeaders : void 0
|
|
312
328
|
}
|
|
313
329
|
}
|
|
314
330
|
};
|
package/dist/agents/Agent.d.ts
CHANGED
|
@@ -48,6 +48,8 @@ type AgentConfig = {
|
|
|
48
48
|
sandboxConfig?: SandboxConfig;
|
|
49
49
|
/** User ID for user-scoped credential lookup (from temp JWT) */
|
|
50
50
|
userId?: string;
|
|
51
|
+
/** Headers to forward to MCP servers (e.g., x-forwarded-cookie for user session auth) */
|
|
52
|
+
forwardedHeaders?: Record<string, string>;
|
|
51
53
|
};
|
|
52
54
|
type ExternalAgentRelationConfig = {
|
|
53
55
|
relationId: string;
|
package/dist/agents/Agent.js
CHANGED
|
@@ -539,7 +539,8 @@ var Agent = class {
|
|
|
539
539
|
};
|
|
540
540
|
}
|
|
541
541
|
async getMcpTool(tool$1) {
|
|
542
|
-
const
|
|
542
|
+
const forwardedHeadersHash = this.config.forwardedHeaders ? Object.keys(this.config.forwardedHeaders).sort().join(",") : "no-fwd";
|
|
543
|
+
const cacheKey = `${this.config.tenantId}-${this.config.projectId}-${tool$1.id}-${tool$1.credentialReferenceId || "no-cred"}-${forwardedHeadersHash}`;
|
|
543
544
|
const credentialReferenceId = tool$1.credentialReferenceId;
|
|
544
545
|
const toolRelation = (await getToolsForAgent(dbClient_default)({ scopes: {
|
|
545
546
|
tenantId: this.config.tenantId,
|
|
@@ -626,11 +627,16 @@ var Agent = class {
|
|
|
626
627
|
else urlObj.searchParams.set("user_id", `${this.config.tenantId}||${this.config.projectId}`);
|
|
627
628
|
serverConfig.url = urlObj.toString();
|
|
628
629
|
}
|
|
630
|
+
if (this.config.forwardedHeaders && Object.keys(this.config.forwardedHeaders).length > 0) serverConfig.headers = {
|
|
631
|
+
...serverConfig.headers,
|
|
632
|
+
...this.config.forwardedHeaders
|
|
633
|
+
};
|
|
629
634
|
logger.info({
|
|
630
635
|
toolName: tool$1.name,
|
|
631
636
|
credentialReferenceId,
|
|
632
637
|
transportType: serverConfig.type,
|
|
633
|
-
headers: tool$1.headers
|
|
638
|
+
headers: tool$1.headers,
|
|
639
|
+
hasForwardedHeaders: !!this.config.forwardedHeaders
|
|
634
640
|
}, "Built MCP server config with credentials");
|
|
635
641
|
let client = this.mcpClientCache.get(cacheKey);
|
|
636
642
|
if (client && !client.isConnected()) {
|
|
@@ -21,6 +21,7 @@ const createTaskHandler = (config, credentialStoreRegistry) => {
|
|
|
21
21
|
},
|
|
22
22
|
artifacts: []
|
|
23
23
|
};
|
|
24
|
+
const forwardedHeaders = task.context?.metadata?.forwardedHeaders;
|
|
24
25
|
const [internalRelations, externalRelations, teamRelations, toolsForAgent, dataComponents, artifactComponents] = await Promise.all([
|
|
25
26
|
getRelatedAgentsForAgent(dbClient_default)({
|
|
26
27
|
scopes: {
|
|
@@ -322,7 +323,8 @@ const createTaskHandler = (config, credentialStoreRegistry) => {
|
|
|
322
323
|
artifactComponents,
|
|
323
324
|
contextConfigId: config.contextConfigId || void 0,
|
|
324
325
|
conversationHistoryConfig: config.conversationHistoryConfig,
|
|
325
|
-
sandboxConfig: config.sandboxConfig
|
|
326
|
+
sandboxConfig: config.sandboxConfig,
|
|
327
|
+
forwardedHeaders
|
|
326
328
|
}, credentialStoreRegistry);
|
|
327
329
|
const artifactStreamRequestId = task.context?.metadata?.streamRequestId;
|
|
328
330
|
if (artifactStreamRequestId && artifactComponents.length > 0) agentSessionManager.updateArtifactComponents(artifactStreamRequestId, artifactComponents);
|
package/dist/create-app.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { SandboxConfig } from "./types/execution-context.js";
|
|
2
2
|
import { CredentialStoreRegistry, ServerConfig } from "@inkeep/agents-core";
|
|
3
3
|
import { Hono } from "hono";
|
|
4
|
-
import * as
|
|
4
|
+
import * as hono_types3 from "hono/types";
|
|
5
5
|
|
|
6
6
|
//#region src/create-app.d.ts
|
|
7
|
-
declare function createExecutionHono(serverConfig: ServerConfig, credentialStores: CredentialStoreRegistry, sandboxConfig?: SandboxConfig): Hono<
|
|
7
|
+
declare function createExecutionHono(serverConfig: ServerConfig, credentialStores: CredentialStoreRegistry, sandboxConfig?: SandboxConfig): Hono<hono_types3.BlankEnv, hono_types3.BlankSchema, "/">;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { createExecutionHono };
|
|
@@ -10,6 +10,8 @@ interface ExecutionHandlerParams {
|
|
|
10
10
|
requestId: string;
|
|
11
11
|
sseHelper: StreamHelper;
|
|
12
12
|
emitOperations?: boolean;
|
|
13
|
+
/** Headers to forward to MCP servers (e.g., x-forwarded-cookie for auth) */
|
|
14
|
+
forwardedHeaders?: Record<string, string>;
|
|
13
15
|
}
|
|
14
16
|
interface ExecutionResult {
|
|
15
17
|
success: boolean;
|
|
@@ -32,7 +32,7 @@ var ExecutionHandler = class {
|
|
|
32
32
|
* @returns
|
|
33
33
|
*/
|
|
34
34
|
async execute(params) {
|
|
35
|
-
const { executionContext, conversationId, userMessage, initialAgentId, requestId, sseHelper, emitOperations } = params;
|
|
35
|
+
const { executionContext, conversationId, userMessage, initialAgentId, requestId, sseHelper, emitOperations, forwardedHeaders } = params;
|
|
36
36
|
const { tenantId, projectId, agentId, apiKey, baseUrl } = executionContext;
|
|
37
37
|
registerStreamHelper(requestId, sseHelper);
|
|
38
38
|
agentSessionManager.createSession(requestId, agentId, tenantId, projectId, conversationId);
|
|
@@ -177,7 +177,8 @@ var ExecutionHandler = class {
|
|
|
177
177
|
"x-inkeep-tenant-id": tenantId,
|
|
178
178
|
"x-inkeep-project-id": projectId,
|
|
179
179
|
"x-inkeep-agent-id": agentId,
|
|
180
|
-
"x-inkeep-sub-agent-id": currentAgentId
|
|
180
|
+
"x-inkeep-sub-agent-id": currentAgentId,
|
|
181
|
+
...forwardedHeaders || {}
|
|
181
182
|
} });
|
|
182
183
|
let messageResponse = null;
|
|
183
184
|
const messageMetadata = { stream_request_id: requestId };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,14 +3,14 @@ import { createExecutionHono } from "./create-app.js";
|
|
|
3
3
|
import "./env.js";
|
|
4
4
|
import { CredentialStore, ServerConfig } from "@inkeep/agents-core";
|
|
5
5
|
import { Hono } from "hono";
|
|
6
|
-
import * as
|
|
6
|
+
import * as hono_types0 from "hono/types";
|
|
7
7
|
|
|
8
8
|
//#region src/index.d.ts
|
|
9
|
-
declare const app: Hono<
|
|
9
|
+
declare const app: Hono<hono_types0.BlankEnv, hono_types0.BlankSchema, "/">;
|
|
10
10
|
declare function createExecutionApp(config?: {
|
|
11
11
|
serverConfig?: ServerConfig;
|
|
12
12
|
credentialStores?: CredentialStore[];
|
|
13
13
|
sandboxConfig?: SandboxConfig;
|
|
14
|
-
}): Hono<
|
|
14
|
+
}): Hono<hono_types0.BlankEnv, hono_types0.BlankSchema, "/">;
|
|
15
15
|
//#endregion
|
|
16
16
|
export { Hono, type NativeSandboxConfig, type SandboxConfig, type VercelSandboxConfig, createExecutionApp, createExecutionHono, app as default };
|
package/dist/routes/chat.js
CHANGED
|
@@ -250,6 +250,11 @@ app.openapi(chatCompletionsRoute, async (c) => {
|
|
|
250
250
|
await sseHelper.writeRole();
|
|
251
251
|
logger.info({ subAgentId }, "Starting execution");
|
|
252
252
|
const emitOperations = c.req.header("x-emit-operations") === "true";
|
|
253
|
+
const forwardedHeaders = {};
|
|
254
|
+
const xForwardedCookie = c.req.header("x-forwarded-cookie");
|
|
255
|
+
const cookie = c.req.header("cookie");
|
|
256
|
+
if (xForwardedCookie) forwardedHeaders["x-forwarded-cookie"] = xForwardedCookie;
|
|
257
|
+
else if (cookie) forwardedHeaders["x-forwarded-cookie"] = cookie;
|
|
253
258
|
const result = await new ExecutionHandler().execute({
|
|
254
259
|
executionContext,
|
|
255
260
|
conversationId,
|
|
@@ -257,7 +262,8 @@ app.openapi(chatCompletionsRoute, async (c) => {
|
|
|
257
262
|
initialAgentId: subAgentId,
|
|
258
263
|
requestId,
|
|
259
264
|
sseHelper,
|
|
260
|
-
emitOperations
|
|
265
|
+
emitOperations,
|
|
266
|
+
forwardedHeaders
|
|
261
267
|
});
|
|
262
268
|
logger.info({ result }, `Execution completed: ${result.success ? "success" : "failed"} after ${result.iterations} iterations`);
|
|
263
269
|
if (!result.success) await sseHelper.writeOperation(errorOp("Sorry, I was unable to process your request at this time. Please try again.", "system"));
|
|
@@ -75,6 +75,11 @@ app.openapi(chatDataStreamRoute, async (c) => {
|
|
|
75
75
|
const targetTenantId = c.req.header("x-target-tenant-id");
|
|
76
76
|
const targetProjectId = c.req.header("x-target-project-id");
|
|
77
77
|
const targetAgentId = c.req.header("x-target-agent-id");
|
|
78
|
+
const forwardedHeaders = {};
|
|
79
|
+
const xForwardedCookie = c.req.header("x-forwarded-cookie");
|
|
80
|
+
const cookie = c.req.header("cookie");
|
|
81
|
+
if (xForwardedCookie) forwardedHeaders["x-forwarded-cookie"] = xForwardedCookie;
|
|
82
|
+
else if (cookie) forwardedHeaders["x-forwarded-cookie"] = cookie;
|
|
78
83
|
const activeSpan = trace.getActiveSpan();
|
|
79
84
|
if (activeSpan) activeSpan.setAttributes({
|
|
80
85
|
"conversation.id": conversationId,
|
|
@@ -183,7 +188,8 @@ app.openapi(chatDataStreamRoute, async (c) => {
|
|
|
183
188
|
initialAgentId: subAgentId,
|
|
184
189
|
requestId: `chat-${Date.now()}`,
|
|
185
190
|
sseHelper: bufferingHelper,
|
|
186
|
-
emitOperations
|
|
191
|
+
emitOperations,
|
|
192
|
+
forwardedHeaders
|
|
187
193
|
});
|
|
188
194
|
const captured = bufferingHelper.getCapturedResponse();
|
|
189
195
|
return c.json({
|
|
@@ -217,7 +223,8 @@ app.openapi(chatDataStreamRoute, async (c) => {
|
|
|
217
223
|
initialAgentId: subAgentId,
|
|
218
224
|
requestId: `chatds-${Date.now()}`,
|
|
219
225
|
sseHelper: streamHelper,
|
|
220
|
-
emitOperations
|
|
226
|
+
emitOperations,
|
|
227
|
+
forwardedHeaders
|
|
221
228
|
})).success) await streamHelper.writeOperation(errorOp("Unable to process request", "system"));
|
|
222
229
|
} catch (err) {
|
|
223
230
|
logger.error({ err }, "Streaming error");
|
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-20260107161316",
|
|
4
4
|
"description": "Agents Run API for Inkeep Agent Framework - handles chat, agent execution, and streaming",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"hono": "^4.10.4",
|
|
42
42
|
"jmespath": "^0.16.0",
|
|
43
43
|
"llm-info": "^1.0.69",
|
|
44
|
-
"@inkeep/agents-core": "^0.0.0-dev-
|
|
44
|
+
"@inkeep/agents-core": "^0.0.0-dev-20260107161316"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"@hono/zod-openapi": "^1.1.5",
|