@inkeep/agents-api 0.0.1 → 0.42.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.well-known/workflow/v1/flow.cjs +43 -106
- package/dist/.well-known/workflow/v1/flow.cjs.debug.json +2 -4
- package/dist/.well-known/workflow/v1/manifest.debug.json +16 -54
- package/dist/.well-known/workflow/v1/step.cjs +406 -1646
- package/dist/.well-known/workflow/v1/step.cjs.debug.json +2 -4
- package/dist/domains/evals/routes/datasetTriggers.d.ts +2 -2
- package/dist/domains/evals/routes/index.d.ts +2 -2
- package/dist/domains/evals/workflow/functions/evaluateConversation.d.ts +4 -1
- package/dist/domains/evals/workflow/functions/evaluateConversation.js +2 -1
- package/dist/domains/evals/workflow/functions/runDatasetItem.d.ts +4 -1
- package/dist/domains/evals/workflow/functions/runDatasetItem.js +2 -1
- package/dist/domains/evals/workflow/routes.d.ts +2 -2
- package/dist/domains/manage/routes/agent.js +2 -0
- package/dist/domains/manage/routes/index.d.ts +2 -2
- package/dist/domains/manage/routes/triggers.js +37 -5
- package/dist/domains/run/a2a/handlers.js +2 -10
- package/dist/domains/run/a2a/types.d.ts +2 -6
- package/dist/domains/run/agents/generateTaskHandler.js +14 -2
- package/dist/domains/run/agents/relationTools.d.ts +2 -2
- package/dist/domains/run/handlers/executionHandler.d.ts +3 -1
- package/dist/domains/run/handlers/executionHandler.js +6 -5
- package/dist/domains/run/routes/webhooks.js +24 -5
- package/dist/domains/run/types/xml.d.ts +1 -5
- package/dist/domains/run/utils/token-estimator.d.ts +2 -2
- package/dist/factory.d.ts +272 -266
- package/dist/index.d.ts +269 -263
- package/dist/index.js +16 -1
- package/dist/middleware/evalsAuth.d.ts +2 -2
- package/dist/middleware/manageAuth.d.ts +2 -2
- package/dist/middleware/projectAccess.d.ts +2 -2
- package/dist/middleware/projectConfig.d.ts +3 -3
- package/dist/middleware/requirePermission.d.ts +2 -2
- package/dist/middleware/runAuth.d.ts +4 -4
- package/dist/middleware/sessionAuth.d.ts +3 -3
- package/dist/middleware/tenantAccess.d.ts +2 -2
- package/dist/middleware/tracing.d.ts +3 -3
- package/dist/templates/v1/phase1/system-prompt.js +1 -1
- package/dist/templates/v1/phase1/thinking-preparation.js +1 -1
- package/dist/templates/v1/phase1/tool.js +1 -1
- package/dist/templates/v1/phase2/data-component.js +1 -1
- package/dist/templates/v1/phase2/data-components.js +1 -1
- package/dist/templates/v1/phase2/system-prompt.js +1 -1
- package/dist/templates/v1/shared/artifact-retrieval-guidance.js +1 -1
- package/dist/templates/v1/shared/artifact.js +1 -1
- package/package.json +21 -22
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"stepFiles": [
|
|
3
|
-
"/
|
|
4
|
-
"/
|
|
5
|
-
"/Users/andrew/Documents/code/agents/agents/agents-api/dist/domains/evals/workflow/functions/runDatasetItem.js",
|
|
6
|
-
"/Users/andrew/Documents/code/agents/agents/agents-api/src/domains/evals/workflow/functions/evaluateConversation.ts"
|
|
3
|
+
"/home/runner/work/agents/agents/agents-api/src/domains/evals/workflow/functions/evaluateConversation.ts",
|
|
4
|
+
"/home/runner/work/agents/agents/agents-api/src/domains/evals/workflow/functions/runDatasetItem.ts"
|
|
7
5
|
]
|
|
8
6
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
2
|
-
import * as
|
|
2
|
+
import * as hono14 from "hono";
|
|
3
3
|
|
|
4
4
|
//#region src/domains/evals/routes/datasetTriggers.d.ts
|
|
5
|
-
declare const app: OpenAPIHono<
|
|
5
|
+
declare const app: OpenAPIHono<hono14.Env, {}, "/">;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { app as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
2
|
-
import * as
|
|
2
|
+
import * as hono15 from "hono";
|
|
3
3
|
|
|
4
4
|
//#region src/domains/evals/routes/index.d.ts
|
|
5
|
-
declare const app: OpenAPIHono<
|
|
5
|
+
declare const app: OpenAPIHono<hono15.Env, {}, "/">;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { app as default };
|
|
@@ -13,7 +13,7 @@ type EvaluationPayload = {
|
|
|
13
13
|
* - Do NOT call Node.js APIs directly here (no DB, no fs, etc.)
|
|
14
14
|
* - All side effects must happen in step functions
|
|
15
15
|
*/
|
|
16
|
-
declare function
|
|
16
|
+
declare function _evaluateConversationWorkflow(payload: EvaluationPayload): Promise<{
|
|
17
17
|
success: boolean;
|
|
18
18
|
reason: string;
|
|
19
19
|
conversationId?: undefined;
|
|
@@ -24,5 +24,8 @@ declare function evaluateConversationWorkflow(payload: EvaluationPayload): Promi
|
|
|
24
24
|
resultCount: number;
|
|
25
25
|
reason?: undefined;
|
|
26
26
|
}>;
|
|
27
|
+
declare const evaluateConversationWorkflow: typeof _evaluateConversationWorkflow & {
|
|
28
|
+
workflowId: string;
|
|
29
|
+
};
|
|
27
30
|
//#endregion
|
|
28
31
|
export { evaluateConversationWorkflow };
|
|
@@ -102,7 +102,7 @@ async function logStep(message, data) {
|
|
|
102
102
|
* - Do NOT call Node.js APIs directly here (no DB, no fs, etc.)
|
|
103
103
|
* - All side effects must happen in step functions
|
|
104
104
|
*/
|
|
105
|
-
async function
|
|
105
|
+
async function _evaluateConversationWorkflow(payload) {
|
|
106
106
|
"use workflow";
|
|
107
107
|
const { conversationId, evaluatorIds } = payload;
|
|
108
108
|
await logStep("Starting conversation evaluation", payload);
|
|
@@ -129,6 +129,7 @@ async function evaluateConversationWorkflow(payload) {
|
|
|
129
129
|
resultCount: results.length
|
|
130
130
|
};
|
|
131
131
|
}
|
|
132
|
+
const evaluateConversationWorkflow = Object.assign(_evaluateConversationWorkflow, { workflowId: "workflow//src/domains/evals/workflow/functions/evaluateConversation.ts//_evaluateConversationWorkflow" });
|
|
132
133
|
|
|
133
134
|
//#endregion
|
|
134
135
|
export { evaluateConversationWorkflow };
|
|
@@ -25,12 +25,15 @@ type RunDatasetItemPayload = {
|
|
|
25
25
|
* Main workflow function - processes a single dataset item through the chat API.
|
|
26
26
|
* Optionally runs evaluators on the resulting conversation.
|
|
27
27
|
*/
|
|
28
|
-
declare function
|
|
28
|
+
declare function _runDatasetItemWorkflow(payload: RunDatasetItemPayload): Promise<{
|
|
29
29
|
success: boolean;
|
|
30
30
|
datasetItemId: string;
|
|
31
31
|
datasetRunId: string;
|
|
32
32
|
conversationId: string | null;
|
|
33
33
|
error: string | null;
|
|
34
34
|
}>;
|
|
35
|
+
declare const runDatasetItemWorkflow: typeof _runDatasetItemWorkflow & {
|
|
36
|
+
workflowId: string;
|
|
37
|
+
};
|
|
35
38
|
//#endregion
|
|
36
39
|
export { runDatasetItemWorkflow };
|
|
@@ -173,7 +173,7 @@ async function logStep(message, data) {
|
|
|
173
173
|
* Main workflow function - processes a single dataset item through the chat API.
|
|
174
174
|
* Optionally runs evaluators on the resulting conversation.
|
|
175
175
|
*/
|
|
176
|
-
async function
|
|
176
|
+
async function _runDatasetItemWorkflow(payload) {
|
|
177
177
|
"use workflow";
|
|
178
178
|
const { datasetItemId, datasetRunId, agentId, evaluatorIds, evaluationRunId } = payload;
|
|
179
179
|
await logStep("Starting dataset item processing", {
|
|
@@ -199,6 +199,7 @@ async function runDatasetItemWorkflow(payload) {
|
|
|
199
199
|
error: result.error || null
|
|
200
200
|
};
|
|
201
201
|
}
|
|
202
|
+
const runDatasetItemWorkflow = Object.assign(_runDatasetItemWorkflow, { workflowId: "workflow//src/domains/evals/workflow/functions/runDatasetItem.ts//_runDatasetItemWorkflow" });
|
|
202
203
|
|
|
203
204
|
//#endregion
|
|
204
205
|
export { runDatasetItemWorkflow };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Hono } from "hono";
|
|
2
|
-
import * as
|
|
2
|
+
import * as hono_types5 from "hono/types";
|
|
3
3
|
|
|
4
4
|
//#region src/domains/evals/workflow/routes.d.ts
|
|
5
|
-
declare const workflowRoutes: Hono<
|
|
5
|
+
declare const workflowRoutes: Hono<hono_types5.BlankEnv, hono_types5.BlankSchema, "/">;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { workflowRoutes };
|
|
@@ -206,6 +206,8 @@ app.openapi(createRoute({
|
|
|
206
206
|
agentId: id
|
|
207
207
|
},
|
|
208
208
|
data: {
|
|
209
|
+
name: validatedBody.name,
|
|
210
|
+
description: validatedBody.description,
|
|
209
211
|
defaultSubAgentId: validatedBody.defaultSubAgentId,
|
|
210
212
|
contextConfigId: validatedBody.contextConfigId ?? void 0
|
|
211
213
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
2
|
-
import * as
|
|
2
|
+
import * as hono16 from "hono";
|
|
3
3
|
|
|
4
4
|
//#region src/domains/manage/routes/index.d.ts
|
|
5
|
-
declare const app: OpenAPIHono<
|
|
5
|
+
declare const app: OpenAPIHono<hono16.Env, {}, "/">;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { app as default };
|
|
@@ -4,7 +4,7 @@ import runDbClient_default from "../../../data/db/runDbClient.js";
|
|
|
4
4
|
import { requireProjectPermission } from "../../../middleware/projectAccess.js";
|
|
5
5
|
import { speakeasyOffsetLimitPagination } from "../../../utils/speakeasy.js";
|
|
6
6
|
import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
|
7
|
-
import { PaginationQueryParamsSchema, TenantProjectAgentIdParamsSchema, TenantProjectAgentParamsSchema, TriggerApiInsertSchema, TriggerApiSelectSchema, TriggerApiUpdateSchema, TriggerInvocationListResponse, TriggerInvocationResponse, TriggerInvocationStatusEnum, commonGetErrorResponses, createApiError, createTrigger, deleteTrigger, generateId, getTriggerById, getTriggerInvocationById, listTriggerInvocationsPaginated, listTriggersPaginated, updateTrigger } from "@inkeep/agents-core";
|
|
7
|
+
import { PaginationQueryParamsSchema, TenantProjectAgentIdParamsSchema, TenantProjectAgentParamsSchema, TriggerApiInsertSchema, TriggerApiSelectSchema, TriggerApiUpdateSchema, TriggerInvocationListResponse, TriggerInvocationResponse, TriggerInvocationStatusEnum, commonGetErrorResponses, createApiError, createTrigger, deleteTrigger, generateId, getTriggerById, getTriggerInvocationById, hashAuthenticationHeaders, listTriggerInvocationsPaginated, listTriggersPaginated, updateTrigger } from "@inkeep/agents-core";
|
|
8
8
|
|
|
9
9
|
//#region src/domains/manage/routes/triggers.ts
|
|
10
10
|
const logger = getLogger$1("triggers");
|
|
@@ -167,6 +167,9 @@ app.openapi(createRoute({
|
|
|
167
167
|
agentId,
|
|
168
168
|
triggerId: id
|
|
169
169
|
}, "Creating trigger");
|
|
170
|
+
let hashedAuthentication;
|
|
171
|
+
const authInput = body.authentication;
|
|
172
|
+
if (authInput?.headers && authInput.headers.length > 0) hashedAuthentication = { headers: await hashAuthenticationHeaders(authInput.headers) };
|
|
170
173
|
const trigger = await createTrigger(db)({
|
|
171
174
|
id,
|
|
172
175
|
tenantId,
|
|
@@ -178,7 +181,7 @@ app.openapi(createRoute({
|
|
|
178
181
|
inputSchema: body.inputSchema,
|
|
179
182
|
outputTransform: body.outputTransform,
|
|
180
183
|
messageTemplate: body.messageTemplate,
|
|
181
|
-
authentication:
|
|
184
|
+
authentication: hashedAuthentication,
|
|
182
185
|
signingSecret: body.signingSecret
|
|
183
186
|
});
|
|
184
187
|
const { tenantId: _tid, projectId: _pid, agentId: _aid, ...triggerWithoutScopes } = trigger;
|
|
@@ -218,7 +221,7 @@ app.openapi(createRoute({
|
|
|
218
221
|
const { tenantId, projectId, agentId, id } = c.req.valid("param");
|
|
219
222
|
const body = c.req.valid("json");
|
|
220
223
|
const apiBaseUrl = env.INKEEP_AGENTS_API_URL;
|
|
221
|
-
if (!(body.name !== void 0 || body.description !== void 0 || body.enabled !== void 0 || body.inputSchema !== void 0 || body.outputTransform !== void 0 || body.messageTemplate !== void 0 || body.authentication !== void 0 || body.signingSecret !== void 0)) throw createApiError({
|
|
224
|
+
if (!(body.name !== void 0 || body.description !== void 0 || body.enabled !== void 0 || body.inputSchema !== void 0 || body.outputTransform !== void 0 || body.messageTemplate !== void 0 || body.authentication !== void 0 || body.signingSecret !== void 0 || body.keepExistingSigningSecret !== void 0)) throw createApiError({
|
|
222
225
|
code: "bad_request",
|
|
223
226
|
message: "No fields to update"
|
|
224
227
|
});
|
|
@@ -228,6 +231,35 @@ app.openapi(createRoute({
|
|
|
228
231
|
agentId,
|
|
229
232
|
triggerId: id
|
|
230
233
|
}, "Updating trigger");
|
|
234
|
+
let hashedAuthentication;
|
|
235
|
+
const authInput = body.authentication;
|
|
236
|
+
if (authInput?.headers && authInput.headers.length > 0) {
|
|
237
|
+
const existingAuth = (await getTriggerById(db)({
|
|
238
|
+
scopes: {
|
|
239
|
+
tenantId,
|
|
240
|
+
projectId,
|
|
241
|
+
agentId
|
|
242
|
+
},
|
|
243
|
+
triggerId: id
|
|
244
|
+
}))?.authentication;
|
|
245
|
+
const hashedHeaders = [];
|
|
246
|
+
for (const header of authInput.headers) if (header.keepExisting) {
|
|
247
|
+
const existingHeader = existingAuth?.headers?.find((h) => h.name === header.name);
|
|
248
|
+
if (existingHeader) hashedHeaders.push({
|
|
249
|
+
name: header.name,
|
|
250
|
+
valueHash: existingHeader.valueHash,
|
|
251
|
+
valuePrefix: existingHeader.valuePrefix
|
|
252
|
+
});
|
|
253
|
+
} else if (header.value) {
|
|
254
|
+
const hashed = await hashAuthenticationHeaders([{
|
|
255
|
+
name: header.name,
|
|
256
|
+
value: header.value
|
|
257
|
+
}]);
|
|
258
|
+
hashedHeaders.push(hashed[0]);
|
|
259
|
+
}
|
|
260
|
+
hashedAuthentication = hashedHeaders.length > 0 ? { headers: hashedHeaders } : void 0;
|
|
261
|
+
} else if (body.authentication !== void 0) hashedAuthentication = body.authentication;
|
|
262
|
+
const signingSecretUpdate = body.keepExistingSigningSecret ? void 0 : body.signingSecret;
|
|
231
263
|
const updatedTrigger = await updateTrigger(db)({
|
|
232
264
|
scopes: {
|
|
233
265
|
tenantId,
|
|
@@ -242,8 +274,8 @@ app.openapi(createRoute({
|
|
|
242
274
|
inputSchema: body.inputSchema,
|
|
243
275
|
outputTransform: body.outputTransform,
|
|
244
276
|
messageTemplate: body.messageTemplate,
|
|
245
|
-
authentication:
|
|
246
|
-
signingSecret:
|
|
277
|
+
authentication: hashedAuthentication,
|
|
278
|
+
signingSecret: signingSecretUpdate
|
|
247
279
|
}
|
|
248
280
|
});
|
|
249
281
|
if (!updatedTrigger) throw createApiError({
|
|
@@ -61,11 +61,7 @@ async function handleMessageSend(c, agent, request) {
|
|
|
61
61
|
};
|
|
62
62
|
const task = {
|
|
63
63
|
id: generateId(),
|
|
64
|
-
input: { parts: params.message.parts
|
|
65
|
-
kind: part.kind,
|
|
66
|
-
text: part.kind === "text" ? part.text : void 0,
|
|
67
|
-
data: part.kind === "data" ? part.data : void 0
|
|
68
|
-
})) },
|
|
64
|
+
input: { parts: params.message.parts },
|
|
69
65
|
context: {
|
|
70
66
|
conversationId: params.message.contextId,
|
|
71
67
|
metadata: {
|
|
@@ -320,11 +316,7 @@ async function handleMessageStream(c, agent, request) {
|
|
|
320
316
|
else if (cookie) forwardedHeaders["x-forwarded-cookie"] = cookie;
|
|
321
317
|
const task = {
|
|
322
318
|
id: generateId(),
|
|
323
|
-
input: { parts: params.message.parts
|
|
324
|
-
kind: part.kind,
|
|
325
|
-
text: part.kind === "text" ? part.text : void 0,
|
|
326
|
-
data: part.kind === "data" ? part.data : void 0
|
|
327
|
-
})) },
|
|
319
|
+
input: { parts: params.message.parts },
|
|
328
320
|
context: {
|
|
329
321
|
conversationId: params.message.contextId,
|
|
330
322
|
metadata: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AgentCard, Artifact, Message, Task, TaskState } from "@inkeep/agents-core";
|
|
1
|
+
import { AgentCard, Artifact, Message, Part, Task, TaskState } from "@inkeep/agents-core";
|
|
2
2
|
|
|
3
3
|
//#region src/domains/run/a2a/types.d.ts
|
|
4
4
|
interface RegisteredAgent {
|
|
@@ -12,11 +12,7 @@ interface RegisteredAgent {
|
|
|
12
12
|
interface A2ATask {
|
|
13
13
|
id: string;
|
|
14
14
|
input: {
|
|
15
|
-
parts:
|
|
16
|
-
kind: string;
|
|
17
|
-
text?: string;
|
|
18
|
-
data?: any;
|
|
19
|
-
}>;
|
|
15
|
+
parts: Part[];
|
|
20
16
|
};
|
|
21
17
|
context?: {
|
|
22
18
|
conversationId?: string;
|
|
@@ -15,7 +15,13 @@ const createTaskHandler = (config, credentialStoreRegistry) => {
|
|
|
15
15
|
return async (task) => {
|
|
16
16
|
let agent;
|
|
17
17
|
try {
|
|
18
|
-
const
|
|
18
|
+
const textParts = task.input.parts.filter((part) => part.kind === "text").map((part) => part.text).join(" ");
|
|
19
|
+
const dataParts = task.input.parts.filter((part) => part.kind === "data" && part.data != null);
|
|
20
|
+
let userMessage = textParts;
|
|
21
|
+
if (dataParts.length > 0) userMessage = `${textParts}${dataParts.map((part) => {
|
|
22
|
+
const metadata = part.metadata;
|
|
23
|
+
return `\n\n<structured_data${metadata?.source ? ` (source: ${metadata.source})` : ""}>\n${JSON.stringify(part.data, null, 2)}\n</structured_data>`;
|
|
24
|
+
}).join("")}`;
|
|
19
25
|
if (!userMessage.trim()) return {
|
|
20
26
|
status: {
|
|
21
27
|
state: TaskState.Failed,
|
|
@@ -224,7 +230,13 @@ const createTaskHandler = (config, credentialStoreRegistry) => {
|
|
|
224
230
|
if (streamRequestId && tenantId && projectId) toolSessionManager.ensureAgentSession(streamRequestId, tenantId, projectId, contextId, task.id);
|
|
225
231
|
}
|
|
226
232
|
logger.info({ contextId }, "Context ID");
|
|
227
|
-
logger.info({
|
|
233
|
+
logger.info({
|
|
234
|
+
userMessage: userMessage.substring(0, 500),
|
|
235
|
+
inputPartsCount: task.input.parts.length,
|
|
236
|
+
textPartsCount: task.input.parts.filter((p) => p.kind === "text").length,
|
|
237
|
+
dataPartsCount: task.input.parts.filter((p) => p.kind === "data").length,
|
|
238
|
+
hasDataParts: task.input.parts.some((p) => p.kind === "data")
|
|
239
|
+
}, "User Message with parts breakdown");
|
|
228
240
|
const response = await agent.generate(userMessage, {
|
|
229
241
|
contextId,
|
|
230
242
|
metadata: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AgentConfig, DelegateRelation } from "./Agent.js";
|
|
2
2
|
import { InternalRelation } from "../utils/project.js";
|
|
3
|
-
import * as
|
|
3
|
+
import * as _inkeep_agents_core1 from "@inkeep/agents-core";
|
|
4
4
|
import { CredentialStoreRegistry, FullExecutionContext } from "@inkeep/agents-core";
|
|
5
5
|
import * as ai0 from "ai";
|
|
6
6
|
|
|
@@ -44,7 +44,7 @@ declare function createDelegateToAgentTool({
|
|
|
44
44
|
message: string;
|
|
45
45
|
}, {
|
|
46
46
|
toolCallId: any;
|
|
47
|
-
result:
|
|
47
|
+
result: _inkeep_agents_core1.Message | _inkeep_agents_core1.Task;
|
|
48
48
|
}>;
|
|
49
49
|
/**
|
|
50
50
|
* Parameters for building a transfer relation config
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { StreamHelper } from "../utils/stream-helpers.js";
|
|
2
|
-
import { FullExecutionContext } from "@inkeep/agents-core";
|
|
2
|
+
import { FullExecutionContext, Part } from "@inkeep/agents-core";
|
|
3
3
|
|
|
4
4
|
//#region src/domains/run/handlers/executionHandler.d.ts
|
|
5
5
|
interface ExecutionHandlerParams {
|
|
6
6
|
executionContext: FullExecutionContext;
|
|
7
7
|
conversationId: string;
|
|
8
8
|
userMessage: string;
|
|
9
|
+
/** Optional message parts for rich content (text + data). Used on first iteration only. */
|
|
10
|
+
messageParts?: Part[];
|
|
9
11
|
initialAgentId: string;
|
|
10
12
|
requestId: string;
|
|
11
13
|
sseHelper: StreamHelper;
|
|
@@ -33,7 +33,7 @@ var ExecutionHandler = class {
|
|
|
33
33
|
* @returns
|
|
34
34
|
*/
|
|
35
35
|
async execute(params) {
|
|
36
|
-
const { executionContext, conversationId, userMessage, initialAgentId, requestId, sseHelper, emitOperations, forwardedHeaders } = params;
|
|
36
|
+
const { executionContext, conversationId, userMessage, messageParts, initialAgentId, requestId, sseHelper, emitOperations, forwardedHeaders } = params;
|
|
37
37
|
const { tenantId, projectId, project, agentId, apiKey, baseUrl, resolvedRef } = executionContext;
|
|
38
38
|
registerStreamHelper(requestId, sseHelper);
|
|
39
39
|
agentSessionManager.createSession(requestId, executionContext, conversationId);
|
|
@@ -178,13 +178,14 @@ var ExecutionHandler = class {
|
|
|
178
178
|
forwardedHeaders
|
|
179
179
|
};
|
|
180
180
|
if (fromSubAgentId) messageMetadata.fromSubAgentId = fromSubAgentId;
|
|
181
|
+
const partsToSend = iterations === 1 && messageParts && messageParts.length > 0 ? messageParts : [{
|
|
182
|
+
kind: "text",
|
|
183
|
+
text: currentMessage
|
|
184
|
+
}];
|
|
181
185
|
messageResponse = await a2aClient.sendMessage({
|
|
182
186
|
message: {
|
|
183
187
|
role: "user",
|
|
184
|
-
parts:
|
|
185
|
-
kind: "text",
|
|
186
|
-
text: currentMessage
|
|
187
|
-
}],
|
|
188
|
+
parts: partsToSend,
|
|
188
189
|
messageId: `${requestId}-iter-${iterations}`,
|
|
189
190
|
kind: "message",
|
|
190
191
|
contextId: conversationId,
|
|
@@ -94,7 +94,7 @@ app.openapi(triggerWebhookRoute, async (c) => {
|
|
|
94
94
|
const bodyText = await c.req.text();
|
|
95
95
|
const payload = bodyText ? JSON.parse(bodyText) : {};
|
|
96
96
|
if (trigger.authentication) {
|
|
97
|
-
const authResult = verifyTriggerAuth(c, trigger.authentication);
|
|
97
|
+
const authResult = await verifyTriggerAuth(c, trigger.authentication);
|
|
98
98
|
if (!authResult.success) {
|
|
99
99
|
if (authResult.status === 401) return c.json({ error: authResult.message || "Unauthorized" }, 401);
|
|
100
100
|
return c.json({ error: authResult.message || "Forbidden" }, 403);
|
|
@@ -132,7 +132,23 @@ app.openapi(triggerWebhookRoute, async (c) => {
|
|
|
132
132
|
}, "Payload transformation failed");
|
|
133
133
|
return c.json({ error: `Payload transformation failed: ${errorMessage}` }, 422);
|
|
134
134
|
}
|
|
135
|
-
const
|
|
135
|
+
const messageParts = [];
|
|
136
|
+
if (trigger.messageTemplate) {
|
|
137
|
+
const interpolatedMessage = interpolateTemplate(trigger.messageTemplate, transformedPayload);
|
|
138
|
+
messageParts.push({
|
|
139
|
+
kind: "text",
|
|
140
|
+
text: interpolatedMessage
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
if (transformedPayload != null) messageParts.push({
|
|
144
|
+
kind: "data",
|
|
145
|
+
data: transformedPayload,
|
|
146
|
+
metadata: {
|
|
147
|
+
source: "trigger",
|
|
148
|
+
triggerId
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
const userMessageText = trigger.messageTemplate ? interpolateTemplate(trigger.messageTemplate, transformedPayload) : JSON.stringify(transformedPayload);
|
|
136
152
|
const conversationId = getConversationId();
|
|
137
153
|
const invocationId = generateId();
|
|
138
154
|
await createTriggerInvocation(runDbClient_default)({
|
|
@@ -161,7 +177,8 @@ app.openapi(triggerWebhookRoute, async (c) => {
|
|
|
161
177
|
triggerId,
|
|
162
178
|
invocationId,
|
|
163
179
|
conversationId,
|
|
164
|
-
userMessage:
|
|
180
|
+
userMessage: userMessageText,
|
|
181
|
+
messageParts,
|
|
165
182
|
resolvedRef
|
|
166
183
|
}).catch((error) => {
|
|
167
184
|
logger.error({
|
|
@@ -203,7 +220,7 @@ app.openapi(triggerWebhookRoute, async (c) => {
|
|
|
203
220
|
* It updates the trigger invocation status based on success/failure.
|
|
204
221
|
*/
|
|
205
222
|
async function invokeAgentAsync(params) {
|
|
206
|
-
const { tenantId, projectId, agentId, triggerId, invocationId, conversationId, userMessage, resolvedRef } = params;
|
|
223
|
+
const { tenantId, projectId, agentId, triggerId, invocationId, conversationId, userMessage, messageParts, resolvedRef } = params;
|
|
207
224
|
return await trace.getTracer("trigger-invocation").startActiveSpan("trigger.invocation", { attributes: {
|
|
208
225
|
"conversation.id": conversationId,
|
|
209
226
|
"tenant.id": tenantId,
|
|
@@ -213,6 +230,7 @@ async function invokeAgentAsync(params) {
|
|
|
213
230
|
"trigger.id": triggerId,
|
|
214
231
|
"trigger.invocation.id": invocationId,
|
|
215
232
|
"message.content": userMessage,
|
|
233
|
+
"message.parts": JSON.stringify(messageParts),
|
|
216
234
|
"message.timestamp": (/* @__PURE__ */ new Date()).toISOString()
|
|
217
235
|
} }, async (span) => {
|
|
218
236
|
let currentBag = propagation.getBaggage(context.active());
|
|
@@ -308,7 +326,7 @@ async function invokeAgentAsync(params) {
|
|
|
308
326
|
projectId,
|
|
309
327
|
conversationId,
|
|
310
328
|
role: "user",
|
|
311
|
-
content: {
|
|
329
|
+
content: { parts: messageParts },
|
|
312
330
|
visibility: "user-facing",
|
|
313
331
|
messageType: "chat"
|
|
314
332
|
});
|
|
@@ -325,6 +343,7 @@ async function invokeAgentAsync(params) {
|
|
|
325
343
|
executionContext,
|
|
326
344
|
conversationId,
|
|
327
345
|
userMessage,
|
|
346
|
+
messageParts,
|
|
328
347
|
initialAgentId: agentId,
|
|
329
348
|
requestId,
|
|
330
349
|
sseHelper: noOpStreamHelper,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _inkeep_agents_core3 from "@inkeep/agents-core";
|
|
2
2
|
import { BreakdownComponentDef, ContextBreakdown, calculateBreakdownTotal, createEmptyBreakdown } from "@inkeep/agents-core";
|
|
3
3
|
|
|
4
4
|
//#region src/domains/run/utils/token-estimator.d.ts
|
|
@@ -17,7 +17,7 @@ interface AssembleResult {
|
|
|
17
17
|
/** The assembled prompt string */
|
|
18
18
|
prompt: string;
|
|
19
19
|
/** Token breakdown for each component */
|
|
20
|
-
breakdown:
|
|
20
|
+
breakdown: _inkeep_agents_core3.ContextBreakdown;
|
|
21
21
|
}
|
|
22
22
|
//#endregion
|
|
23
23
|
export { AssembleResult, type BreakdownComponentDef, type ContextBreakdown, calculateBreakdownTotal, createEmptyBreakdown, estimateTokens };
|