@inkeep/agents-api 0.47.1 → 0.47.3

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.
Files changed (33) hide show
  1. package/dist/.well-known/workflow/v1/manifest.debug.json +19 -19
  2. package/dist/.well-known/workflow/v1/step.cjs +2 -2
  3. package/dist/domains/evals/routes/datasetTriggers.d.ts +2 -2
  4. package/dist/domains/evals/routes/evaluationTriggers.js +1 -1
  5. package/dist/domains/evals/routes/index.d.ts +2 -2
  6. package/dist/domains/evals/services/conversationEvaluation.js +21 -10
  7. package/dist/domains/evals/workflow/routes.d.ts +2 -2
  8. package/dist/domains/manage/routes/availableAgents.d.ts +2 -2
  9. package/dist/domains/manage/routes/conversations.d.ts +2 -2
  10. package/dist/domains/manage/routes/index.d.ts +2 -2
  11. package/dist/domains/manage/routes/invitations.d.ts +2 -2
  12. package/dist/domains/manage/routes/mcp.d.ts +2 -2
  13. package/dist/domains/manage/routes/passwordResetLinks.d.ts +2 -2
  14. package/dist/domains/manage/routes/signoz.d.ts +2 -2
  15. package/dist/domains/manage/routes/users.d.ts +2 -2
  16. package/dist/domains/mcp/routes/mcp.d.ts +2 -2
  17. package/dist/domains/run/agents/Agent.js +18 -14
  18. package/dist/domains/run/constants/execution-limits/index.js +1 -1
  19. package/dist/domains/run/services/PendingToolApprovalManager.js +1 -1
  20. package/dist/domains/run/services/ToolApprovalUiBus.d.ts +1 -0
  21. package/dist/domains/run/services/ToolApprovalUiBus.js +2 -1
  22. package/dist/domains/run/utils/tool-result.d.ts +11 -0
  23. package/dist/domains/run/utils/tool-result.js +15 -0
  24. package/dist/factory.d.ts +263 -263
  25. package/dist/index.d.ts +262 -262
  26. package/dist/middleware/evalsAuth.d.ts +2 -2
  27. package/dist/middleware/manageAuth.d.ts +2 -2
  28. package/dist/middleware/projectAccess.d.ts +2 -2
  29. package/dist/middleware/projectConfig.d.ts +3 -3
  30. package/dist/middleware/requirePermission.d.ts +2 -2
  31. package/dist/middleware/runAuth.d.ts +4 -4
  32. package/dist/middleware/sessionAuth.d.ts +3 -3
  33. package/package.json +5 -5
@@ -11,20 +11,6 @@
11
11
  "stepId": "__builtin_response_text"
12
12
  }
13
13
  },
14
- "src/domains/evals/workflow/functions/evaluateConversation.ts": {
15
- "executeEvaluatorStep": {
16
- "stepId": "step//src/domains/evals/workflow/functions/evaluateConversation.ts//executeEvaluatorStep"
17
- },
18
- "getConversationStep": {
19
- "stepId": "step//src/domains/evals/workflow/functions/evaluateConversation.ts//getConversationStep"
20
- },
21
- "getEvaluatorsStep": {
22
- "stepId": "step//src/domains/evals/workflow/functions/evaluateConversation.ts//getEvaluatorsStep"
23
- },
24
- "logStep": {
25
- "stepId": "step//src/domains/evals/workflow/functions/evaluateConversation.ts//logStep"
26
- }
27
- },
28
14
  "src/domains/evals/workflow/functions/runDatasetItem.ts": {
29
15
  "callChatApiStep": {
30
16
  "stepId": "step//src/domains/evals/workflow/functions/runDatasetItem.ts//callChatApiStep"
@@ -38,18 +24,32 @@
38
24
  "logStep": {
39
25
  "stepId": "step//src/domains/evals/workflow/functions/runDatasetItem.ts//logStep"
40
26
  }
27
+ },
28
+ "src/domains/evals/workflow/functions/evaluateConversation.ts": {
29
+ "executeEvaluatorStep": {
30
+ "stepId": "step//src/domains/evals/workflow/functions/evaluateConversation.ts//executeEvaluatorStep"
31
+ },
32
+ "getConversationStep": {
33
+ "stepId": "step//src/domains/evals/workflow/functions/evaluateConversation.ts//getConversationStep"
34
+ },
35
+ "getEvaluatorsStep": {
36
+ "stepId": "step//src/domains/evals/workflow/functions/evaluateConversation.ts//getEvaluatorsStep"
37
+ },
38
+ "logStep": {
39
+ "stepId": "step//src/domains/evals/workflow/functions/evaluateConversation.ts//logStep"
40
+ }
41
41
  }
42
42
  },
43
43
  "workflows": {
44
- "src/domains/evals/workflow/functions/runDatasetItem.ts": {
45
- "_runDatasetItemWorkflow": {
46
- "workflowId": "workflow//src/domains/evals/workflow/functions/runDatasetItem.ts//_runDatasetItemWorkflow"
47
- }
48
- },
49
44
  "src/domains/evals/workflow/functions/evaluateConversation.ts": {
50
45
  "_evaluateConversationWorkflow": {
51
46
  "workflowId": "workflow//src/domains/evals/workflow/functions/evaluateConversation.ts//_evaluateConversationWorkflow"
52
47
  }
48
+ },
49
+ "src/domains/evals/workflow/functions/runDatasetItem.ts": {
50
+ "_runDatasetItemWorkflow": {
51
+ "workflowId": "workflow//src/domains/evals/workflow/functions/runDatasetItem.ts//_runDatasetItemWorkflow"
52
+ }
53
53
  }
54
54
  }
55
55
  }
@@ -143325,7 +143325,7 @@ var MAX_ID_LENGTH = 255;
143325
143325
  var URL_SAFE_ID_PATTERN = /^[a-zA-Z0-9\-_.]+$/;
143326
143326
  var ResourceIdSchema = external_exports.string().min(MIN_ID_LENGTH).max(MAX_ID_LENGTH).regex(URL_SAFE_ID_PATTERN, {
143327
143327
  message: "ID must contain only letters, numbers, hyphens, underscores, and dots"
143328
- }).refine((value) => value !== "new", 'Must not use a reserved name "new"').openapi({
143328
+ }).refine((value) => value !== "new", 'Must not use a reserved name "new"').openapi("ResourceId", {
143329
143329
  description: "Resource identifier",
143330
143330
  example: "resource_789"
143331
143331
  });
@@ -147113,7 +147113,7 @@ var envSchema = external_exports.object({
147113
147113
  GITHUB_MCP_API_KEY: external_exports.string().optional().describe("API key for the GitHub MCP"),
147114
147114
  SPICEDB_ENDPOINT: external_exports.string().optional().describe("SpiceDB endpoint"),
147115
147115
  SPICEDB_PRESHARED_KEY: external_exports.string().optional().describe("SpiceDB pre-shared key"),
147116
- SPICEDB_TLS_ENABLED: external_exports.coerce.boolean().optional().describe("SpiceDB TLS enabled")
147116
+ SPICEDB_TLS_ENABLED: external_exports.stringbool().optional().describe("SpiceDB TLS enabled")
147117
147117
  });
147118
147118
  var parseEnv = /* @__PURE__ */ __name(() => {
147119
147119
  try {
@@ -1,7 +1,7 @@
1
1
  import { OpenAPIHono } from "@hono/zod-openapi";
2
- import * as hono0 from "hono";
2
+ import * as hono12 from "hono";
3
3
 
4
4
  //#region src/domains/evals/routes/datasetTriggers.d.ts
5
- declare const app: OpenAPIHono<hono0.Env, {}, "/">;
5
+ declare const app: OpenAPIHono<hono12.Env, {}, "/">;
6
6
  //#endregion
7
7
  export { app as default };
@@ -43,7 +43,7 @@ app.openapi(createRoute({
43
43
  tenantId,
44
44
  projectId,
45
45
  conversationId
46
- }, "Triggering conversation evaluation (eval-api handling all logic)");
46
+ }, "Triggering conversation evaluation");
47
47
  if (!await getConversation(runDbClient_default)({
48
48
  scopes: {
49
49
  tenantId,
@@ -1,7 +1,7 @@
1
1
  import { OpenAPIHono } from "@hono/zod-openapi";
2
- import * as hono2 from "hono";
2
+ import * as hono16 from "hono";
3
3
 
4
4
  //#region src/domains/evals/routes/index.d.ts
5
- declare const app: OpenAPIHono<hono2.Env, {}, "/">;
5
+ declare const app: OpenAPIHono<hono16.Env, {}, "/">;
6
6
  //#endregion
7
7
  export { app as default };
@@ -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
- }, "Triggering conversation evaluation (eval-api handling all logic)");
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 hono_types5 from "hono/types";
2
+ import * as hono_types13 from "hono/types";
3
3
 
4
4
  //#region src/domains/evals/workflow/routes.d.ts
5
- declare const workflowRoutes: Hono<hono_types5.BlankEnv, hono_types5.BlankSchema, "/">;
5
+ declare const workflowRoutes: Hono<hono_types13.BlankEnv, hono_types13.BlankSchema, "/">;
6
6
  //#endregion
7
7
  export { workflowRoutes };
@@ -1,7 +1,7 @@
1
1
  import { OpenAPIHono } from "@hono/zod-openapi";
2
- import * as hono16 from "hono";
2
+ import * as hono18 from "hono";
3
3
 
4
4
  //#region src/domains/manage/routes/availableAgents.d.ts
5
- declare const app: OpenAPIHono<hono16.Env, {}, "/">;
5
+ declare const app: OpenAPIHono<hono18.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 hono17 from "hono";
2
+ import * as hono6 from "hono";
3
3
 
4
4
  //#region src/domains/manage/routes/conversations.d.ts
5
- declare const app: OpenAPIHono<hono17.Env, {}, "/">;
5
+ declare const app: OpenAPIHono<hono6.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 hono18 from "hono";
2
+ import * as hono17 from "hono";
3
3
 
4
4
  //#region src/domains/manage/routes/index.d.ts
5
- declare const app: OpenAPIHono<hono18.Env, {}, "/">;
5
+ declare const app: OpenAPIHono<hono17.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 hono_types12 from "hono/types";
3
+ import * as hono_types9 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
- }, hono_types12.BlankSchema, "/">;
8
+ }, hono_types9.BlankSchema, "/">;
9
9
  //#endregion
10
10
  export { invitationsRoutes as default };
@@ -1,7 +1,7 @@
1
1
  import { Hono } from "hono";
2
- import * as hono_types13 from "hono/types";
2
+ import * as hono_types10 from "hono/types";
3
3
 
4
4
  //#region src/domains/manage/routes/mcp.d.ts
5
- declare const app: Hono<hono_types13.BlankEnv, hono_types13.BlankSchema, "/">;
5
+ declare const app: Hono<hono_types10.BlankEnv, hono_types10.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 hono_types11 from "hono/types";
3
+ import * as hono_types8 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
- }, hono_types11.BlankSchema, "/">;
8
+ }, hono_types8.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 hono_types8 from "hono/types";
3
+ import * as hono_types12 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
- }, hono_types8.BlankSchema, "/">;
8
+ }, hono_types12.BlankSchema, "/">;
9
9
  //#endregion
10
10
  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 hono_types7 from "hono/types";
3
+ import * as hono_types5 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
- }, hono_types7.BlankSchema, "/">;
8
+ }, hono_types5.BlankSchema, "/">;
9
9
  //#endregion
10
10
  export { usersRoutes as default };
@@ -1,7 +1,7 @@
1
1
  import { Hono } from "hono";
2
- import * as hono_types9 from "hono/types";
2
+ import * as hono_types6 from "hono/types";
3
3
 
4
4
  //#region src/domains/mcp/routes/mcp.d.ts
5
- declare const app: Hono<hono_types9.BlankEnv, hono_types9.BlankSchema, "/">;
5
+ declare const app: Hono<hono_types6.BlankEnv, hono_types6.BlankSchema, "/">;
6
6
  //#endregion
7
7
  export { app as default };
@@ -21,6 +21,7 @@ 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 = !!result && typeof result === "object" && "__inkeepToolDenied" in result && result.__inkeepToolDenied === true;
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);
@@ -7,7 +7,7 @@ loadEnvironmentFiles();
7
7
  const constantsSchema = z.object(Object.fromEntries(Object.keys(executionLimitsDefaults).map((key) => {
8
8
  const defaultValue = executionLimitsDefaults[key];
9
9
  const envKey = `AGENTS_${key}`;
10
- if (typeof defaultValue === "boolean") return [envKey, z.coerce.boolean().optional()];
10
+ if (typeof defaultValue === "boolean") return [envKey, z.stringbool().optional()];
11
11
  return [envKey, z.coerce.number().optional()];
12
12
  })));
13
13
  const parseConstants = () => {
@@ -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 || "User denied approval"
92
+ reason: `The user declined to run this tool. ${reason ? `Reason: ${reason}` : ""}`
93
93
  });
94
94
  return true;
95
95
  }
@@ -10,6 +10,7 @@ type ToolApprovalUiEvent = {
10
10
  type: 'approval-resolved';
11
11
  toolCallId: string;
12
12
  approved: boolean;
13
+ reason?: string;
13
14
  };
14
15
  type Listener = (event: ToolApprovalUiEvent) => void | Promise<void>;
15
16
  /**
@@ -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
  }
@@ -0,0 +1,11 @@
1
+ //#region src/domains/run/utils/tool-result.d.ts
2
+ declare const INKEEP_TOOL_DENIED_KEY = "__inkeepToolDenied";
3
+ interface DeniedToolResult {
4
+ [INKEEP_TOOL_DENIED_KEY]: true;
5
+ toolCallId: string;
6
+ reason?: string;
7
+ }
8
+ declare function isToolResultDenied(result: unknown): result is DeniedToolResult;
9
+ declare function createDeniedToolResult(toolCallId: string, reason?: string): DeniedToolResult;
10
+ //#endregion
11
+ export { DeniedToolResult, INKEEP_TOOL_DENIED_KEY, createDeniedToolResult, isToolResultDenied };
@@ -0,0 +1,15 @@
1
+ //#region src/domains/run/utils/tool-result.ts
2
+ const INKEEP_TOOL_DENIED_KEY = "__inkeepToolDenied";
3
+ function isToolResultDenied(result) {
4
+ return !!result && typeof result === "object" && INKEEP_TOOL_DENIED_KEY in result && result[INKEEP_TOOL_DENIED_KEY] === true;
5
+ }
6
+ function createDeniedToolResult(toolCallId, reason) {
7
+ return {
8
+ [INKEEP_TOOL_DENIED_KEY]: true,
9
+ toolCallId,
10
+ reason
11
+ };
12
+ }
13
+
14
+ //#endregion
15
+ export { INKEEP_TOOL_DENIED_KEY, createDeniedToolResult, isToolResultDenied };