@inkeep/agents-api 0.47.2 → 0.47.4
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 +44 -44
- package/dist/.well-known/workflow/v1/flow.cjs.debug.json +2 -2
- package/dist/.well-known/workflow/v1/step.cjs +180 -134
- package/dist/.well-known/workflow/v1/step.cjs.debug.json +2 -2
- package/dist/createApp.d.ts +2 -2
- package/dist/createApp.js +1 -1
- package/dist/domains/evals/routes/evaluationTriggers.js +1 -1
- package/dist/domains/evals/services/conversationEvaluation.js +21 -10
- package/dist/domains/evals/workflow/routes.d.ts +2 -2
- package/dist/domains/manage/routes/availableAgents.d.ts +2 -2
- package/dist/domains/manage/routes/conversations.d.ts +2 -2
- package/dist/domains/manage/routes/index.d.ts +2 -2
- package/dist/domains/manage/routes/invitations.d.ts +2 -2
- package/dist/domains/manage/routes/mcp.d.ts +2 -2
- package/dist/domains/manage/routes/passwordResetLinks.d.ts +2 -2
- package/dist/domains/manage/routes/signoz.d.ts +2 -2
- package/dist/domains/manage/routes/triggers.js +110 -1
- package/dist/domains/manage/routes/users.d.ts +2 -2
- package/dist/domains/mcp/routes/mcp.d.ts +2 -2
- package/dist/domains/run/agents/Agent.js +19 -15
- package/dist/domains/run/agents/generateTaskHandler.js +1 -1
- package/dist/domains/run/agents/relationTools.d.ts +2 -2
- package/dist/domains/run/agents/relationTools.js +1 -1
- package/dist/domains/run/constants/execution-limits/index.js +5 -1
- package/dist/domains/run/handlers/executionHandler.js +6 -6
- package/dist/domains/run/routes/chat.js +4 -4
- package/dist/domains/run/routes/chatDataStream.js +4 -4
- package/dist/domains/run/routes/mcp.js +2 -2
- package/dist/domains/run/services/PendingToolApprovalManager.js +1 -1
- package/dist/domains/run/services/ToolApprovalUiBus.d.ts +1 -0
- package/dist/domains/run/services/ToolApprovalUiBus.js +2 -1
- package/dist/domains/run/services/TriggerService.d.ts +16 -2
- package/dist/domains/run/services/TriggerService.js +2 -2
- package/dist/domains/run/utils/model-context-utils.js +4 -2
- package/dist/domains/run/utils/token-estimator.d.ts +2 -2
- package/dist/domains/run/utils/tool-result.d.ts +11 -0
- package/dist/domains/run/utils/tool-result.js +15 -0
- package/dist/factory.d.ts +263 -263
- package/dist/index.d.ts +260 -260
- package/dist/middleware/evalsAuth.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/package.json +5 -5
|
@@ -11,11 +11,28 @@ const logger = getLogger$1("ConversationEvaluation");
|
|
|
11
11
|
const triggerConversationEvaluation = async (params) => {
|
|
12
12
|
const { tenantId, projectId, conversationId, resolvedRef } = params;
|
|
13
13
|
try {
|
|
14
|
+
const runConfigs = (await withRef(manageDbPool_default, resolvedRef, (db) => listEvaluationRunConfigsWithSuiteConfigs(db)({ scopes: {
|
|
15
|
+
tenantId,
|
|
16
|
+
projectId
|
|
17
|
+
} }))).filter((config) => config.isActive);
|
|
18
|
+
if (runConfigs.length === 0) {
|
|
19
|
+
logger.debug({
|
|
20
|
+
tenantId,
|
|
21
|
+
projectId,
|
|
22
|
+
conversationId
|
|
23
|
+
}, "No active evaluation run configs found, skipping evaluation");
|
|
24
|
+
return {
|
|
25
|
+
success: true,
|
|
26
|
+
message: "No active evaluation run configs found",
|
|
27
|
+
evaluationsTriggered: 0
|
|
28
|
+
};
|
|
29
|
+
}
|
|
14
30
|
logger.info({
|
|
15
31
|
tenantId,
|
|
16
32
|
projectId,
|
|
17
|
-
conversationId
|
|
18
|
-
|
|
33
|
+
conversationId,
|
|
34
|
+
runConfigCount: runConfigs.length
|
|
35
|
+
}, "Triggering conversation evaluation");
|
|
19
36
|
if (!await getConversation(runDbClient_default)({
|
|
20
37
|
scopes: {
|
|
21
38
|
tenantId,
|
|
@@ -23,11 +40,6 @@ const triggerConversationEvaluation = async (params) => {
|
|
|
23
40
|
},
|
|
24
41
|
conversationId
|
|
25
42
|
})) throw new Error(`Conversation not found: ${conversationId}`);
|
|
26
|
-
const runConfigs = (await withRef(manageDbPool_default, resolvedRef, (db) => listEvaluationRunConfigsWithSuiteConfigs(db)({ scopes: {
|
|
27
|
-
tenantId,
|
|
28
|
-
projectId
|
|
29
|
-
} }))).filter((config) => config.isActive);
|
|
30
|
-
if (runConfigs.length === 0) throw new Error("No active evaluation run configs found");
|
|
31
43
|
let evaluationsTriggered = 0;
|
|
32
44
|
for (const runConfig of runConfigs) for (const suiteConfigId of runConfig.suiteConfigIds) {
|
|
33
45
|
const suiteConfig = await withRef(manageDbPool_default, resolvedRef, (db) => getEvaluationSuiteConfigById(db)({ scopes: {
|
|
@@ -87,13 +99,12 @@ const triggerConversationEvaluation = async (params) => {
|
|
|
87
99
|
};
|
|
88
100
|
} catch (error) {
|
|
89
101
|
logger.error({
|
|
90
|
-
error,
|
|
102
|
+
error: error?.message,
|
|
103
|
+
errorStack: error?.stack,
|
|
91
104
|
tenantId,
|
|
92
105
|
projectId,
|
|
93
106
|
conversationId
|
|
94
107
|
}, "Failed to trigger conversation evaluation");
|
|
95
|
-
logger.error({ error: error?.stack }, "Failed to trigger conversation evaluation");
|
|
96
|
-
logger.error({ error: error?.message }, "Failed to trigger conversation evaluation");
|
|
97
108
|
throw error;
|
|
98
109
|
}
|
|
99
110
|
};
|
|
@@ -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 };
|
|
@@ -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/availableAgents.d.ts
|
|
5
|
-
declare const app: OpenAPIHono<
|
|
5
|
+
declare const app: OpenAPIHono<hono16.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 hono17 from "hono";
|
|
3
3
|
|
|
4
4
|
//#region src/domains/manage/routes/conversations.d.ts
|
|
5
|
-
declare const app: OpenAPIHono<
|
|
5
|
+
declare const app: OpenAPIHono<hono17.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 hono18 from "hono";
|
|
3
3
|
|
|
4
4
|
//#region src/domains/manage/routes/index.d.ts
|
|
5
|
-
declare const app: OpenAPIHono<
|
|
5
|
+
declare const app: OpenAPIHono<hono18.Env, {}, "/">;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { app as default };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ManageAppVariables } from "../../../types/app.js";
|
|
2
2
|
import { Hono } from "hono";
|
|
3
|
-
import * as
|
|
3
|
+
import * as hono_types10 from "hono/types";
|
|
4
4
|
|
|
5
5
|
//#region src/domains/manage/routes/invitations.d.ts
|
|
6
6
|
declare const invitationsRoutes: Hono<{
|
|
7
7
|
Variables: ManageAppVariables;
|
|
8
|
-
},
|
|
8
|
+
}, hono_types10.BlankSchema, "/">;
|
|
9
9
|
//#endregion
|
|
10
10
|
export { invitationsRoutes as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Hono } from "hono";
|
|
2
|
-
import * as
|
|
2
|
+
import * as hono_types11 from "hono/types";
|
|
3
3
|
|
|
4
4
|
//#region src/domains/manage/routes/mcp.d.ts
|
|
5
|
-
declare const app: Hono<
|
|
5
|
+
declare const app: Hono<hono_types11.BlankEnv, hono_types11.BlankSchema, "/">;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { app as default };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ManageAppVariables } from "../../../types/app.js";
|
|
2
2
|
import { Hono } from "hono";
|
|
3
|
-
import * as
|
|
3
|
+
import * as hono_types13 from "hono/types";
|
|
4
4
|
|
|
5
5
|
//#region src/domains/manage/routes/passwordResetLinks.d.ts
|
|
6
6
|
declare const passwordResetLinksRoutes: Hono<{
|
|
7
7
|
Variables: ManageAppVariables;
|
|
8
|
-
},
|
|
8
|
+
}, hono_types13.BlankSchema, "/">;
|
|
9
9
|
//#endregion
|
|
10
10
|
export { passwordResetLinksRoutes as default };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ManageAppVariables } from "../../../types/app.js";
|
|
2
2
|
import { Hono } from "hono";
|
|
3
|
-
import * as
|
|
3
|
+
import * as hono_types14 from "hono/types";
|
|
4
4
|
|
|
5
5
|
//#region src/domains/manage/routes/signoz.d.ts
|
|
6
6
|
declare const app: Hono<{
|
|
7
7
|
Variables: ManageAppVariables;
|
|
8
|
-
},
|
|
8
|
+
}, hono_types14.BlankSchema, "/">;
|
|
9
9
|
//#endregion
|
|
10
10
|
export { app as default };
|
|
@@ -3,8 +3,9 @@ import { env } from "../../../env.js";
|
|
|
3
3
|
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
|
+
import { dispatchExecution } from "../../run/services/TriggerService.js";
|
|
6
7
|
import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
|
7
|
-
import { PaginationQueryParamsSchema, TenantProjectAgentIdParamsSchema, TenantProjectAgentParamsSchema, TriggerApiInsertSchema, TriggerApiUpdateSchema, TriggerInvocationListResponse, TriggerInvocationResponse, TriggerInvocationStatusEnum, TriggerWithWebhookUrlListResponse, TriggerWithWebhookUrlResponse, commonGetErrorResponses, createApiError, createTrigger, deleteTrigger, generateId, getCredentialReference, getTriggerById, getTriggerInvocationById, hashAuthenticationHeaders, listTriggerInvocationsPaginated, listTriggersPaginated, updateTrigger } from "@inkeep/agents-core";
|
|
8
|
+
import { PaginationQueryParamsSchema, PartSchema, TenantProjectAgentIdParamsSchema, TenantProjectAgentParamsSchema, TriggerApiInsertSchema, TriggerApiUpdateSchema, TriggerInvocationListResponse, TriggerInvocationResponse, TriggerInvocationStatusEnum, TriggerWithWebhookUrlListResponse, TriggerWithWebhookUrlResponse, commonGetErrorResponses, createApiError, createTrigger, deleteTrigger, errorSchemaFactory, generateId, getCredentialReference, getTriggerById, getTriggerInvocationById, hashAuthenticationHeaders, listTriggerInvocationsPaginated, listTriggersPaginated, updateTrigger } from "@inkeep/agents-core";
|
|
8
9
|
|
|
9
10
|
//#region src/domains/manage/routes/triggers.ts
|
|
10
11
|
const logger = getLogger$1("triggers");
|
|
@@ -474,6 +475,114 @@ app.openapi(createRoute({
|
|
|
474
475
|
const { tenantId: _tid, projectId: _pid, agentId: _aid, ...invocationWithoutScopes } = invocation;
|
|
475
476
|
return c.json({ data: invocationWithoutScopes });
|
|
476
477
|
});
|
|
478
|
+
/**
|
|
479
|
+
* Rerun Trigger
|
|
480
|
+
* Re-executes a trigger with the provided user message (from a previous trace).
|
|
481
|
+
*/
|
|
482
|
+
app.use("/:id/rerun", async (c, next) => {
|
|
483
|
+
if (c.req.method === "POST") return requireProjectPermission("use")(c, next);
|
|
484
|
+
return next();
|
|
485
|
+
});
|
|
486
|
+
app.openapi(createRoute({
|
|
487
|
+
method: "post",
|
|
488
|
+
path: "/{id}/rerun",
|
|
489
|
+
summary: "Rerun Trigger",
|
|
490
|
+
operationId: "rerun-trigger",
|
|
491
|
+
tags: ["Triggers"],
|
|
492
|
+
request: {
|
|
493
|
+
params: TenantProjectAgentIdParamsSchema,
|
|
494
|
+
body: { content: { "application/json": { schema: z.object({
|
|
495
|
+
userMessage: z.string().describe("The user message to send to the agent"),
|
|
496
|
+
messageParts: z.array(PartSchema).optional().describe("Optional structured message parts (from original trace)")
|
|
497
|
+
}) } } }
|
|
498
|
+
},
|
|
499
|
+
responses: {
|
|
500
|
+
202: {
|
|
501
|
+
description: "Trigger rerun accepted and dispatched",
|
|
502
|
+
content: { "application/json": { schema: z.object({
|
|
503
|
+
success: z.boolean(),
|
|
504
|
+
invocationId: z.string(),
|
|
505
|
+
conversationId: z.string()
|
|
506
|
+
}) } }
|
|
507
|
+
},
|
|
508
|
+
409: errorSchemaFactory("conflict", "Trigger is disabled"),
|
|
509
|
+
...commonGetErrorResponses
|
|
510
|
+
}
|
|
511
|
+
}), async (c) => {
|
|
512
|
+
const db = c.get("db");
|
|
513
|
+
const resolvedRef = c.get("resolvedRef");
|
|
514
|
+
const { tenantId, projectId, agentId, id: triggerId } = c.req.valid("param");
|
|
515
|
+
const { userMessage, messageParts: rawMessageParts } = c.req.valid("json");
|
|
516
|
+
logger.info({
|
|
517
|
+
tenantId,
|
|
518
|
+
projectId,
|
|
519
|
+
agentId,
|
|
520
|
+
triggerId
|
|
521
|
+
}, "Rerunning trigger");
|
|
522
|
+
const trigger = await getTriggerById(db)({
|
|
523
|
+
scopes: {
|
|
524
|
+
tenantId,
|
|
525
|
+
projectId,
|
|
526
|
+
agentId
|
|
527
|
+
},
|
|
528
|
+
triggerId
|
|
529
|
+
});
|
|
530
|
+
if (!trigger) throw createApiError({
|
|
531
|
+
code: "not_found",
|
|
532
|
+
message: "Trigger not found"
|
|
533
|
+
});
|
|
534
|
+
if (!trigger.enabled) throw createApiError({
|
|
535
|
+
code: "conflict",
|
|
536
|
+
message: "Trigger is disabled"
|
|
537
|
+
});
|
|
538
|
+
const messageParts = rawMessageParts ?? [{
|
|
539
|
+
kind: "text",
|
|
540
|
+
text: userMessage
|
|
541
|
+
}];
|
|
542
|
+
let invocationId;
|
|
543
|
+
let conversationId;
|
|
544
|
+
try {
|
|
545
|
+
({invocationId, conversationId} = await dispatchExecution({
|
|
546
|
+
tenantId,
|
|
547
|
+
projectId,
|
|
548
|
+
agentId,
|
|
549
|
+
triggerId,
|
|
550
|
+
resolvedRef,
|
|
551
|
+
payload: { _rerun: true },
|
|
552
|
+
transformedPayload: void 0,
|
|
553
|
+
messageParts,
|
|
554
|
+
userMessageText: userMessage
|
|
555
|
+
}));
|
|
556
|
+
} catch (error) {
|
|
557
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
558
|
+
const errorStack = error instanceof Error ? error.stack : void 0;
|
|
559
|
+
logger.error({
|
|
560
|
+
err: errorMessage,
|
|
561
|
+
errorStack,
|
|
562
|
+
tenantId,
|
|
563
|
+
projectId,
|
|
564
|
+
agentId,
|
|
565
|
+
triggerId
|
|
566
|
+
}, "Failed to dispatch trigger rerun execution");
|
|
567
|
+
throw createApiError({
|
|
568
|
+
code: "internal_server_error",
|
|
569
|
+
message: `Something went wrong. Please contact support.`
|
|
570
|
+
});
|
|
571
|
+
}
|
|
572
|
+
logger.info({
|
|
573
|
+
tenantId,
|
|
574
|
+
projectId,
|
|
575
|
+
agentId,
|
|
576
|
+
triggerId,
|
|
577
|
+
invocationId,
|
|
578
|
+
conversationId
|
|
579
|
+
}, "Trigger rerun dispatched");
|
|
580
|
+
return c.json({
|
|
581
|
+
success: true,
|
|
582
|
+
invocationId,
|
|
583
|
+
conversationId
|
|
584
|
+
}, 202);
|
|
585
|
+
});
|
|
477
586
|
var triggers_default = app;
|
|
478
587
|
|
|
479
588
|
//#endregion
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ManageAppVariables } from "../../../types/app.js";
|
|
2
2
|
import { Hono } from "hono";
|
|
3
|
-
import * as
|
|
3
|
+
import * as hono_types7 from "hono/types";
|
|
4
4
|
|
|
5
5
|
//#region src/domains/manage/routes/users.d.ts
|
|
6
6
|
declare const usersRoutes: Hono<{
|
|
7
7
|
Variables: ManageAppVariables;
|
|
8
|
-
},
|
|
8
|
+
}, hono_types7.BlankSchema, "/">;
|
|
9
9
|
//#endregion
|
|
10
10
|
export { usersRoutes as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Hono } from "hono";
|
|
2
|
-
import * as
|
|
2
|
+
import * as hono_types8 from "hono/types";
|
|
3
3
|
|
|
4
4
|
//#region src/domains/mcp/routes/mcp.d.ts
|
|
5
|
-
declare const app: Hono<
|
|
5
|
+
declare const app: Hono<hono_types8.BlankEnv, hono_types8.BlankSchema, "/">;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { app as default };
|
|
@@ -10,6 +10,7 @@ import { getModelAwareCompressionConfig } from "../services/BaseCompressor.js";
|
|
|
10
10
|
import { createDefaultConversationHistoryConfig, getConversationHistoryWithCompression } from "../data/conversations.js";
|
|
11
11
|
import { getStreamHelper } from "../utils/stream-registry.js";
|
|
12
12
|
import { agentSessionManager } from "../services/AgentSession.js";
|
|
13
|
+
import { generateToolId } from "../utils/agent-operations.js";
|
|
13
14
|
import { ContextResolver } from "../context/ContextResolver.js";
|
|
14
15
|
import "../context/index.js";
|
|
15
16
|
import { IncrementalStreamParser } from "../services/IncrementalStreamParser.js";
|
|
@@ -17,10 +18,10 @@ import { MidGenerationCompressor } from "../services/MidGenerationCompressor.js"
|
|
|
17
18
|
import { pendingToolApprovalManager } from "../services/PendingToolApprovalManager.js";
|
|
18
19
|
import { ResponseFormatter } from "../services/ResponseFormatter.js";
|
|
19
20
|
import { toolApprovalUiBus } from "../services/ToolApprovalUiBus.js";
|
|
20
|
-
import { generateToolId } from "../utils/agent-operations.js";
|
|
21
21
|
import { ArtifactCreateSchema, ArtifactReferenceSchema } from "../utils/artifact-component-schema.js";
|
|
22
22
|
import { withJsonPostProcessing } from "../utils/json-postprocessor.js";
|
|
23
23
|
import { calculateBreakdownTotal, estimateTokens } from "../utils/token-estimator.js";
|
|
24
|
+
import { createDeniedToolResult, isToolResultDenied } from "../utils/tool-result.js";
|
|
24
25
|
import { createDelegateToAgentTool, createTransferToAgentTool } from "./relationTools.js";
|
|
25
26
|
import { SystemPromptBuilder } from "./SystemPromptBuilder.js";
|
|
26
27
|
import { PromptConfig, V1_BREAKDOWN_SCHEMA } from "./versions/v1/PromptConfig.js";
|
|
@@ -354,7 +355,7 @@ var Agent = class {
|
|
|
354
355
|
needsApproval,
|
|
355
356
|
inDelegatedAgent: this.isDelegatedAgent
|
|
356
357
|
});
|
|
357
|
-
const isDeniedResult =
|
|
358
|
+
const isDeniedResult = isToolResultDenied(result);
|
|
358
359
|
if (streamRequestId && streamHelper && !isInternalToolForUi) if (isDeniedResult) await streamHelper.writeToolOutputDenied({ toolCallId });
|
|
359
360
|
else await streamHelper.writeToolOutputAvailable({
|
|
360
361
|
toolCallId,
|
|
@@ -508,14 +509,16 @@ var Agent = class {
|
|
|
508
509
|
if (streamRequestId$1) await toolApprovalUiBus.publish(streamRequestId$1, {
|
|
509
510
|
type: "approval-resolved",
|
|
510
511
|
toolCallId,
|
|
511
|
-
approved: false
|
|
512
|
+
approved: false,
|
|
513
|
+
reason: approvalResult.reason
|
|
512
514
|
});
|
|
513
515
|
}
|
|
514
516
|
return tracer.startActiveSpan("tool.approval_denied", { attributes: {
|
|
515
517
|
"tool.name": toolName,
|
|
516
518
|
"tool.callId": toolCallId,
|
|
517
519
|
"subAgent.id": this.config.id,
|
|
518
|
-
"subAgent.name": this.config.name
|
|
520
|
+
"subAgent.name": this.config.name,
|
|
521
|
+
"tool.approval.reason": approvalResult.reason
|
|
519
522
|
} }, (denialSpan) => {
|
|
520
523
|
logger.info({
|
|
521
524
|
toolName,
|
|
@@ -524,11 +527,7 @@ var Agent = class {
|
|
|
524
527
|
}, "Tool execution denied by user");
|
|
525
528
|
denialSpan.setStatus({ code: SpanStatusCode.OK });
|
|
526
529
|
denialSpan.end();
|
|
527
|
-
return
|
|
528
|
-
__inkeepToolDenied: true,
|
|
529
|
-
toolCallId,
|
|
530
|
-
reason: approvalResult.reason
|
|
531
|
-
};
|
|
530
|
+
return createDeniedToolResult(toolCallId, approvalResult.reason);
|
|
532
531
|
});
|
|
533
532
|
}
|
|
534
533
|
tracer.startActiveSpan("tool.approval_approved", { attributes: {
|
|
@@ -926,7 +925,8 @@ var Agent = class {
|
|
|
926
925
|
if (streamRequestId$1) await toolApprovalUiBus.publish(streamRequestId$1, {
|
|
927
926
|
type: "approval-resolved",
|
|
928
927
|
toolCallId,
|
|
929
|
-
approved: false
|
|
928
|
+
approved: false,
|
|
929
|
+
reason: approvalResult.reason
|
|
930
930
|
});
|
|
931
931
|
}
|
|
932
932
|
return tracer.startActiveSpan("tool.approval_denied", { attributes: {
|
|
@@ -942,11 +942,7 @@ var Agent = class {
|
|
|
942
942
|
}, "Function tool execution denied by user");
|
|
943
943
|
denialSpan.setStatus({ code: SpanStatusCode.OK });
|
|
944
944
|
denialSpan.end();
|
|
945
|
-
return
|
|
946
|
-
__inkeepToolDenied: true,
|
|
947
|
-
toolCallId,
|
|
948
|
-
reason: approvalResult.reason
|
|
949
|
-
};
|
|
945
|
+
return createDeniedToolResult(toolCallId, approvalResult.reason);
|
|
950
946
|
});
|
|
951
947
|
}
|
|
952
948
|
tracer.startActiveSpan("tool.approval_approved", { attributes: {
|
|
@@ -1445,6 +1441,14 @@ var Agent = class {
|
|
|
1445
1441
|
*/
|
|
1446
1442
|
formatToolResult(toolName, args, result, toolCallId) {
|
|
1447
1443
|
const input = args ? JSON.stringify(args, null, 2) : "No input";
|
|
1444
|
+
if (isToolResultDenied(result)) return [
|
|
1445
|
+
`## Tool: ${toolName}`,
|
|
1446
|
+
"",
|
|
1447
|
+
`### 🔧 TOOL_CALL_ID: ${toolCallId}`,
|
|
1448
|
+
"",
|
|
1449
|
+
`### Output`,
|
|
1450
|
+
result.reason
|
|
1451
|
+
].join("\n");
|
|
1448
1452
|
let parsedResult = result;
|
|
1449
1453
|
if (typeof result === "string") try {
|
|
1450
1454
|
parsedResult = JSON.parse(result);
|
|
@@ -2,8 +2,8 @@ import { getLogger as getLogger$1 } from "../../../logger.js";
|
|
|
2
2
|
import manageDbPool_default from "../../../data/db/manageDbPool.js";
|
|
3
3
|
import { toolSessionManager } from "./ToolSessionManager.js";
|
|
4
4
|
import { agentSessionManager } from "../services/AgentSession.js";
|
|
5
|
-
import { getUserIdFromContext } from "../types/executionContext.js";
|
|
6
5
|
import { resolveModelConfig } from "../utils/model-resolver.js";
|
|
6
|
+
import { getUserIdFromContext } from "../types/executionContext.js";
|
|
7
7
|
import { enhanceInternalRelation, enhanceTeamRelation, getArtifactComponentsForSubAgent, getDataComponentsForSubAgent, getSubAgentRelations, getToolsForSubAgent } from "../utils/project.js";
|
|
8
8
|
import { buildTransferRelationConfig } from "./relationTools.js";
|
|
9
9
|
import { Agent } from "./Agent.js";
|
|
@@ -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,6 +1,7 @@
|
|
|
1
1
|
import { getLogger as getLogger$1 } from "../../../logger.js";
|
|
2
2
|
import manageDbPool_default from "../../../data/db/manageDbPool.js";
|
|
3
3
|
import runDbClient_default from "../../../data/db/runDbClient.js";
|
|
4
|
+
import { A2AClient } from "../a2a/client.js";
|
|
4
5
|
import { DELEGATION_TOOL_BACKOFF_EXPONENT, DELEGATION_TOOL_BACKOFF_INITIAL_INTERVAL_MS, DELEGATION_TOOL_BACKOFF_MAX_ELAPSED_TIME_MS, DELEGATION_TOOL_BACKOFF_MAX_INTERVAL_MS } from "../constants/execution-limits/index.js";
|
|
5
6
|
import { toolSessionManager } from "./ToolSessionManager.js";
|
|
6
7
|
import { saveA2AMessageResponse } from "../data/conversations.js";
|
|
@@ -9,7 +10,6 @@ import { getUserIdFromContext } from "../types/executionContext.js";
|
|
|
9
10
|
import { getExternalAgentRelationsForTargetSubAgent, getToolsForSubAgent, getTransferRelationsForTargetSubAgent } from "../utils/project.js";
|
|
10
11
|
import { ContextResolver } from "../context/ContextResolver.js";
|
|
11
12
|
import "../context/index.js";
|
|
12
|
-
import { A2AClient } from "../a2a/client.js";
|
|
13
13
|
import { z } from "@hono/zod-openapi";
|
|
14
14
|
import { CredentialStuffer, SPAN_KEYS, TemplateEngine, createMessage, generateId, generateServiceToken, getMcpToolById, headers, withRef } from "@inkeep/agents-core";
|
|
15
15
|
import { tool } from "ai";
|
|
@@ -12,7 +12,11 @@ const constantsSchema = z.object(Object.fromEntries(Object.keys(executionLimitsD
|
|
|
12
12
|
})));
|
|
13
13
|
const parseConstants = () => {
|
|
14
14
|
const envOverrides = constantsSchema.parse(process.env);
|
|
15
|
-
return Object.fromEntries(Object.entries(executionLimitsDefaults).map(([key, defaultValue]) =>
|
|
15
|
+
return Object.fromEntries(Object.entries(executionLimitsDefaults).map(([key, defaultValue]) => {
|
|
16
|
+
const envKey = `AGENTS_${key}`;
|
|
17
|
+
if (process.env[envKey] === void 0) return [key, defaultValue];
|
|
18
|
+
return [key, envOverrides[envKey] ?? defaultValue];
|
|
19
|
+
}));
|
|
16
20
|
};
|
|
17
21
|
const constants = parseConstants();
|
|
18
22
|
const { AGENT_EXECUTION_MAX_CONSECUTIVE_ERRORS, AGENT_EXECUTION_MAX_GENERATION_STEPS, LLM_GENERATION_FIRST_CALL_TIMEOUT_MS_STREAMING, LLM_GENERATION_FIRST_CALL_TIMEOUT_MS_NON_STREAMING, LLM_GENERATION_SUBSEQUENT_CALL_TIMEOUT_MS, LLM_GENERATION_MAX_ALLOWED_TIMEOUT_MS, FUNCTION_TOOL_EXECUTION_TIMEOUT_MS_DEFAULT, FUNCTION_TOOL_SANDBOX_VCPUS_DEFAULT, FUNCTION_TOOL_SANDBOX_POOL_TTL_MS, FUNCTION_TOOL_SANDBOX_MAX_USE_COUNT, FUNCTION_TOOL_SANDBOX_MAX_OUTPUT_SIZE_BYTES, FUNCTION_TOOL_SANDBOX_QUEUE_WAIT_TIMEOUT_MS, FUNCTION_TOOL_SANDBOX_CLEANUP_INTERVAL_MS, MCP_TOOL_REQUEST_TIMEOUT_MS_DEFAULT, DELEGATION_TOOL_BACKOFF_INITIAL_INTERVAL_MS, DELEGATION_TOOL_BACKOFF_MAX_INTERVAL_MS, DELEGATION_TOOL_BACKOFF_EXPONENT, DELEGATION_TOOL_BACKOFF_MAX_ELAPSED_TIME_MS, A2A_BACKOFF_INITIAL_INTERVAL_MS, A2A_BACKOFF_MAX_INTERVAL_MS, A2A_BACKOFF_EXPONENT, A2A_BACKOFF_MAX_ELAPSED_TIME_MS, ARTIFACT_GENERATION_MAX_RETRIES, ARTIFACT_SESSION_MAX_PENDING, ARTIFACT_SESSION_MAX_PREVIOUS_SUMMARIES, ARTIFACT_GENERATION_BACKOFF_INITIAL_MS, ARTIFACT_GENERATION_BACKOFF_MAX_MS, SESSION_TOOL_RESULT_CACHE_TIMEOUT_MS, SESSION_CLEANUP_INTERVAL_MS, STATUS_UPDATE_DEFAULT_NUM_EVENTS, STATUS_UPDATE_DEFAULT_INTERVAL_SECONDS, STREAM_PARSER_MAX_SNAPSHOT_SIZE, STREAM_PARSER_MAX_STREAMED_SIZE, STREAM_PARSER_MAX_COLLECTED_PARTS, STREAM_BUFFER_MAX_SIZE_BYTES, STREAM_TEXT_GAP_THRESHOLD_MS, STREAM_MAX_LIFETIME_MS, CONVERSATION_HISTORY_DEFAULT_LIMIT, CONVERSATION_ARTIFACTS_LIMIT, COMPRESSION_HARD_LIMIT, COMPRESSION_SAFETY_BUFFER, COMPRESSION_ENABLED } = constants;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { getLogger as getLogger$1 } from "../../../logger.js";
|
|
2
2
|
import runDbClient_default from "../../../data/db/runDbClient.js";
|
|
3
|
+
import { flushBatchProcessor } from "../../../instrumentation.js";
|
|
4
|
+
import { triggerConversationEvaluation } from "../../evals/services/conversationEvaluation.js";
|
|
5
|
+
import { A2AClient } from "../a2a/client.js";
|
|
6
|
+
import { extractTransferData, isTransferTask } from "../a2a/types.js";
|
|
7
|
+
import { executeTransfer } from "../a2a/transfer.js";
|
|
3
8
|
import { AGENT_EXECUTION_MAX_CONSECUTIVE_ERRORS } from "../constants/execution-limits/index.js";
|
|
4
9
|
import { tracer } from "../utils/tracer.js";
|
|
5
10
|
import { registerStreamHelper, unregisterStreamHelper } from "../utils/stream-registry.js";
|
|
6
11
|
import { agentSessionManager } from "../services/AgentSession.js";
|
|
7
|
-
import { resolveModelConfig } from "../utils/model-resolver.js";
|
|
8
12
|
import { agentInitializingOp, completionOp, errorOp } from "../utils/agent-operations.js";
|
|
9
|
-
import {
|
|
10
|
-
import { flushBatchProcessor } from "../../../instrumentation.js";
|
|
11
|
-
import { triggerConversationEvaluation } from "../../evals/services/conversationEvaluation.js";
|
|
12
|
-
import { extractTransferData, isTransferTask } from "../a2a/types.js";
|
|
13
|
-
import { executeTransfer } from "../a2a/transfer.js";
|
|
13
|
+
import { resolveModelConfig } from "../utils/model-resolver.js";
|
|
14
14
|
import { BufferingStreamHelper } from "../utils/stream-helpers.js";
|
|
15
15
|
import { AGENT_EXECUTION_TRANSFER_COUNT_DEFAULT, createMessage, createTask, generateId, getActiveAgentForConversation, getTask, setSpanWithError, updateTask } from "@inkeep/agents-core";
|
|
16
16
|
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { getLogger as getLogger$1 } from "../../../logger.js";
|
|
2
2
|
import runDbClient_default from "../../../data/db/runDbClient.js";
|
|
3
|
+
import { errorOp } from "../utils/agent-operations.js";
|
|
4
|
+
import { createSSEStreamHelper } from "../utils/stream-helpers.js";
|
|
5
|
+
import { ExecutionHandler } from "../handlers/executionHandler.js";
|
|
3
6
|
import { contextValidationMiddleware } from "../context/validation.js";
|
|
4
7
|
import { handleContextResolution } from "../context/context.js";
|
|
5
8
|
import "../context/index.js";
|
|
6
9
|
import { toolApprovalUiBus } from "../services/ToolApprovalUiBus.js";
|
|
7
|
-
import { errorOp } from "../utils/agent-operations.js";
|
|
8
|
-
import { createSSEStreamHelper } from "../utils/stream-helpers.js";
|
|
9
|
-
import { ExecutionHandler } from "../handlers/executionHandler.js";
|
|
10
10
|
import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
|
11
11
|
import { createApiError, createMessage, createOrGetConversation, generateId, getActiveAgentForConversation, getConversationId, setActiveAgentForConversation } from "@inkeep/agents-core";
|
|
12
|
-
import { streamSSE } from "hono/streaming";
|
|
13
12
|
import { context, propagation, trace } from "@opentelemetry/api";
|
|
13
|
+
import { streamSSE } from "hono/streaming";
|
|
14
14
|
|
|
15
15
|
//#region src/domains/run/routes/chat.ts
|
|
16
16
|
const app = new OpenAPIHono();
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { getLogger as getLogger$1 } from "../../../logger.js";
|
|
2
2
|
import runDbClient_default from "../../../data/db/runDbClient.js";
|
|
3
|
+
import { errorOp } from "../utils/agent-operations.js";
|
|
4
|
+
import { createBufferingStreamHelper, createVercelStreamHelper } from "../utils/stream-helpers.js";
|
|
5
|
+
import { ExecutionHandler } from "../handlers/executionHandler.js";
|
|
3
6
|
import { contextValidationMiddleware } from "../context/validation.js";
|
|
4
7
|
import { handleContextResolution } from "../context/context.js";
|
|
5
8
|
import "../context/index.js";
|
|
6
9
|
import { pendingToolApprovalManager } from "../services/PendingToolApprovalManager.js";
|
|
7
10
|
import { toolApprovalUiBus } from "../services/ToolApprovalUiBus.js";
|
|
8
|
-
import { errorOp } from "../utils/agent-operations.js";
|
|
9
|
-
import { createBufferingStreamHelper, createVercelStreamHelper } from "../utils/stream-helpers.js";
|
|
10
|
-
import { ExecutionHandler } from "../handlers/executionHandler.js";
|
|
11
11
|
import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
|
12
12
|
import { commonGetErrorResponses, createApiError, createMessage, generateId, getActiveAgentForConversation, getConversation, getConversationId, loggerFactory, setActiveAgentForConversation } from "@inkeep/agents-core";
|
|
13
13
|
import { JsonToSseTransformStream, createUIMessageStream } from "ai";
|
|
14
|
-
import { stream } from "hono/streaming";
|
|
15
14
|
import { context, propagation, trace } from "@opentelemetry/api";
|
|
15
|
+
import { stream } from "hono/streaming";
|
|
16
16
|
|
|
17
17
|
//#region src/domains/run/routes/chatDataStream.ts
|
|
18
18
|
const app = new OpenAPIHono();
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { getLogger as getLogger$1 } from "../../../logger.js";
|
|
2
2
|
import runDbClient_default from "../../../data/db/runDbClient.js";
|
|
3
|
+
import { createMCPStreamHelper } from "../utils/stream-helpers.js";
|
|
4
|
+
import { ExecutionHandler } from "../handlers/executionHandler.js";
|
|
3
5
|
import { contextValidationMiddleware } from "../context/validation.js";
|
|
4
6
|
import { handleContextResolution } from "../context/context.js";
|
|
5
7
|
import "../context/index.js";
|
|
6
|
-
import { createMCPStreamHelper } from "../utils/stream-helpers.js";
|
|
7
|
-
import { ExecutionHandler } from "../handlers/executionHandler.js";
|
|
8
8
|
import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
|
9
9
|
import { HeadersScopeSchema, createMessage, createOrGetConversation, generateId, getConversation, getConversationId, updateConversation } from "@inkeep/agents-core";
|
|
10
10
|
import { context, propagation, trace } from "@opentelemetry/api";
|
|
@@ -89,7 +89,7 @@ var PendingToolApprovalManager = class PendingToolApprovalManager {
|
|
|
89
89
|
this.pendingApprovals.delete(toolCallId);
|
|
90
90
|
approval.resolve({
|
|
91
91
|
approved: false,
|
|
92
|
-
reason: reason
|
|
92
|
+
reason: `The user declined to run this tool. ${reason ? `Reason: ${reason}` : ""}`
|
|
93
93
|
});
|
|
94
94
|
return true;
|
|
95
95
|
}
|
|
@@ -33,7 +33,8 @@ var ToolApprovalUiBus = class {
|
|
|
33
33
|
streamRequestId,
|
|
34
34
|
eventType: event.type,
|
|
35
35
|
toolCallId: event.toolCallId,
|
|
36
|
-
error: error instanceof Error ? error.message : String(error)
|
|
36
|
+
error: error instanceof Error ? error.message : String(error),
|
|
37
|
+
reason: event.reason
|
|
37
38
|
}, "ToolApprovalUiBus listener failed");
|
|
38
39
|
}
|
|
39
40
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ResolvedRef } from "@inkeep/agents-core";
|
|
1
|
+
import { Part, ResolvedRef } from "@inkeep/agents-core";
|
|
2
2
|
import { Context } from "hono";
|
|
3
3
|
|
|
4
4
|
//#region src/domains/run/services/TriggerService.d.ts
|
|
@@ -27,5 +27,19 @@ type TriggerWebhookResult = {
|
|
|
27
27
|
* Handles validation, transformation, and dispatches async execution.
|
|
28
28
|
*/
|
|
29
29
|
declare function processWebhook(params: TriggerWebhookParams): Promise<TriggerWebhookResult>;
|
|
30
|
+
declare function dispatchExecution(params: {
|
|
31
|
+
tenantId: string;
|
|
32
|
+
projectId: string;
|
|
33
|
+
agentId: string;
|
|
34
|
+
triggerId: string;
|
|
35
|
+
resolvedRef: ResolvedRef;
|
|
36
|
+
payload: Record<string, unknown>;
|
|
37
|
+
transformedPayload: unknown;
|
|
38
|
+
messageParts: Part[];
|
|
39
|
+
userMessageText: string;
|
|
40
|
+
}): Promise<{
|
|
41
|
+
invocationId: string;
|
|
42
|
+
conversationId: string;
|
|
43
|
+
}>;
|
|
30
44
|
//#endregion
|
|
31
|
-
export { TriggerWebhookParams, TriggerWebhookResult, processWebhook };
|
|
45
|
+
export { TriggerWebhookParams, TriggerWebhookResult, dispatchExecution, processWebhook };
|
|
@@ -3,8 +3,8 @@ import { getLogger as getLogger$1 } from "../../../logger.js";
|
|
|
3
3
|
import { env } from "../../../env.js";
|
|
4
4
|
import manageDbPool_default from "../../../data/db/manageDbPool.js";
|
|
5
5
|
import runDbClient_default from "../../../data/db/runDbClient.js";
|
|
6
|
-
import { tracer } from "../utils/tracer.js";
|
|
7
6
|
import { flushBatchProcessor } from "../../../instrumentation.js";
|
|
7
|
+
import { tracer } from "../utils/tracer.js";
|
|
8
8
|
import { createSSEStreamHelper } from "../utils/stream-helpers.js";
|
|
9
9
|
import { ExecutionHandler } from "../handlers/executionHandler.js";
|
|
10
10
|
import { DEFAULT_NANGO_STORE_ID, JsonTransformer, createKeyChainStore, createMessage, createNangoCredentialStore, createOrGetConversation, createTriggerInvocation, generateId, getConversationId, getCredentialReference, getCredentialStoreLookupKeyFromRetrievalParams, getFullProjectWithRelationIds, getTriggerById, interpolateTemplate, setActiveAgentForConversation, updateTriggerInvocationStatus, verifySignatureWithConfig, verifyTriggerAuth, withRef } from "@inkeep/agents-core";
|
|
@@ -542,4 +542,4 @@ async function executeAgentAsync(params) {
|
|
|
542
542
|
}
|
|
543
543
|
|
|
544
544
|
//#endregion
|
|
545
|
-
export { processWebhook };
|
|
545
|
+
export { dispatchExecution, processWebhook };
|