@inkeep/agents-api 0.42.0 → 0.43.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.
Files changed (130) hide show
  1. package/dist/.well-known/workflow/v1/manifest.debug.json +15 -15
  2. package/dist/.well-known/workflow/v1/step.cjs +45672 -44470
  3. package/dist/_virtual/rolldown_runtime.js +7 -0
  4. package/dist/createApp.js +40 -12
  5. package/dist/domains/evals/api/.well-known/workflow/v1/flow.d.ts +4 -0
  6. package/dist/domains/evals/api/.well-known/workflow/v1/flow.js +12 -0
  7. package/dist/domains/evals/api/.well-known/workflow/v1/step.d.ts +4 -0
  8. package/dist/domains/evals/api/.well-known/workflow/v1/step.js +12 -0
  9. package/dist/domains/evals/routes/datasetTriggers.d.ts +2 -2
  10. package/dist/domains/evals/routes/index.d.ts +2 -2
  11. package/dist/domains/evals/scripts/build-workflow.js +2 -2
  12. package/dist/domains/evals/workflow/routes.d.ts +2 -2
  13. package/dist/domains/evals/workflow/world.js +3 -2
  14. package/dist/domains/github/config.d.ts +14 -0
  15. package/dist/domains/github/config.js +47 -0
  16. package/dist/domains/github/index.d.ts +12 -0
  17. package/dist/domains/github/index.js +18 -0
  18. package/dist/domains/github/installation.d.ts +34 -0
  19. package/dist/domains/github/installation.js +172 -0
  20. package/dist/domains/github/jwks.d.ts +20 -0
  21. package/dist/domains/github/jwks.js +85 -0
  22. package/dist/domains/github/oidcToken.d.ts +22 -0
  23. package/dist/domains/github/oidcToken.js +140 -0
  24. package/dist/domains/github/routes/tokenExchange.d.ts +7 -0
  25. package/dist/domains/github/routes/tokenExchange.js +130 -0
  26. package/dist/domains/manage/index.js +0 -2
  27. package/dist/domains/manage/routes/agent.js +7 -4
  28. package/dist/domains/manage/routes/agentFull.js +9 -6
  29. package/dist/domains/manage/routes/apiKeys.js +1 -2
  30. package/dist/domains/manage/routes/artifactComponents.js +5 -5
  31. package/dist/domains/manage/routes/cliAuth.js +3 -3
  32. package/dist/domains/manage/routes/contextConfigs.js +5 -5
  33. package/dist/domains/manage/routes/conversations.d.ts +2 -2
  34. package/dist/domains/manage/routes/credentialStores.js +2 -2
  35. package/dist/domains/manage/routes/credentials.js +6 -7
  36. package/dist/domains/manage/routes/dataComponents.js +6 -7
  37. package/dist/domains/manage/routes/externalAgents.js +1 -2
  38. package/dist/domains/manage/routes/index.d.ts +2 -2
  39. package/dist/domains/manage/routes/index.js +4 -0
  40. package/dist/domains/manage/routes/invitations.js +1 -1
  41. package/dist/domains/manage/routes/mcp.d.ts +2 -2
  42. package/dist/domains/manage/routes/playgroundToken.js +1 -2
  43. package/dist/domains/manage/routes/projectFull.js +33 -11
  44. package/dist/domains/manage/routes/projectMembers.js +16 -35
  45. package/dist/domains/manage/routes/projectPermissions.js +17 -10
  46. package/dist/domains/manage/routes/projects.js +4 -5
  47. package/dist/domains/manage/routes/signoz.d.ts +2 -2
  48. package/dist/domains/manage/routes/signoz.js +6 -3
  49. package/dist/domains/manage/routes/subAgentArtifactComponents.js +5 -5
  50. package/dist/domains/manage/routes/subAgentDataComponents.js +5 -5
  51. package/dist/domains/manage/routes/subAgentExternalAgentRelations.js +5 -5
  52. package/dist/domains/manage/routes/subAgentFunctionTools.js +5 -5
  53. package/dist/domains/manage/routes/subAgentRelations.js +6 -6
  54. package/dist/domains/manage/routes/subAgentTeamAgentRelations.js +6 -6
  55. package/dist/domains/manage/routes/subAgentToolRelations.js +6 -6
  56. package/dist/domains/manage/routes/subAgents.js +5 -5
  57. package/dist/domains/manage/routes/tools.js +24 -3
  58. package/dist/domains/manage/routes/triggers.js +49 -24
  59. package/dist/domains/manage/routes/userOrganizations.js +4 -4
  60. package/dist/domains/manage/routes/{agentToolRelations.d.ts → userProjectMemberships.d.ts} +1 -1
  61. package/dist/domains/manage/routes/userProjectMemberships.js +45 -0
  62. package/dist/domains/mcp/routes/mcp.d.ts +7 -0
  63. package/dist/domains/mcp/routes/mcp.js +45 -0
  64. package/dist/domains/run/agents/Agent.d.ts +1 -0
  65. package/dist/domains/run/agents/Agent.js +207 -44
  66. package/dist/domains/run/agents/relationTools.d.ts +2 -2
  67. package/dist/domains/run/context/ContextFetcher.js +8 -7
  68. package/dist/domains/run/context/ContextResolver.js +1 -1
  69. package/dist/domains/run/handlers/executionHandler.js +143 -79
  70. package/dist/domains/run/routes/agents.js +1 -1
  71. package/dist/domains/run/routes/chat.js +47 -1
  72. package/dist/domains/run/routes/chatDataStream.js +107 -14
  73. package/dist/domains/run/routes/webhooks.js +40 -348
  74. package/dist/domains/run/services/AgentSession.d.ts +3 -0
  75. package/dist/domains/run/services/AgentSession.js +9 -0
  76. package/dist/domains/run/services/BaseCompressor.js +1 -1
  77. package/dist/domains/run/services/ToolApprovalUiBus.d.ts +28 -0
  78. package/dist/domains/run/services/ToolApprovalUiBus.js +44 -0
  79. package/dist/domains/run/services/TriggerService.d.ts +31 -0
  80. package/dist/domains/run/services/TriggerService.js +543 -0
  81. package/dist/domains/run/tools/NativeSandboxExecutor.d.ts +3 -2
  82. package/dist/domains/run/tools/NativeSandboxExecutor.js +76 -48
  83. package/dist/domains/run/tools/SandboxExecutorFactory.d.ts +11 -1
  84. package/dist/domains/run/tools/SandboxExecutorFactory.js +27 -3
  85. package/dist/domains/run/tools/VercelSandboxExecutor.d.ts +3 -11
  86. package/dist/domains/run/tools/VercelSandboxExecutor.js +137 -127
  87. package/dist/domains/run/utils/stream-helpers.d.ts +134 -0
  88. package/dist/domains/run/utils/stream-helpers.js +182 -0
  89. package/dist/domains/run/utils/token-estimator.d.ts +2 -2
  90. package/dist/factory.d.ts +24 -24
  91. package/dist/index.d.ts +24 -24
  92. package/dist/initialization.js +9 -2
  93. package/dist/middleware/cors.js +1 -1
  94. package/dist/middleware/manageAuth.d.ts +2 -2
  95. package/dist/middleware/projectAccess.d.ts +4 -11
  96. package/dist/middleware/projectAccess.js +1 -17
  97. package/dist/middleware/projectConfig.d.ts +3 -3
  98. package/dist/middleware/requirePermission.d.ts +2 -2
  99. package/dist/middleware/runAuth.d.ts +4 -4
  100. package/dist/middleware/sessionAuth.d.ts +3 -3
  101. package/dist/middleware/tenantAccess.d.ts +2 -2
  102. package/dist/middleware/tenantAccess.js +4 -4
  103. package/dist/middleware/tracing.d.ts +3 -3
  104. package/dist/openapi.d.ts +35 -1
  105. package/dist/openapi.js +39 -95
  106. package/dist/routes/healthChecks.d.ts +10 -0
  107. package/dist/routes/healthChecks.js +75 -0
  108. package/dist/types/app.d.ts +2 -0
  109. package/dist/utils/healthChecks.d.ts +8 -0
  110. package/dist/utils/healthChecks.js +38 -0
  111. package/dist/utils/signozHelpers.d.ts +2 -2
  112. package/dist/utils/signozHelpers.js +15 -3
  113. package/package.json +7 -9
  114. package/dist/domains/evals/services/startEvaluation.d.ts +0 -19
  115. package/dist/domains/evals/services/startEvaluation.js +0 -18
  116. package/dist/domains/index.d.ts +0 -4
  117. package/dist/domains/index.js +0 -5
  118. package/dist/domains/manage/routes/agentToolRelations.js +0 -289
  119. package/dist/domains/run/agents/ModelFactory.d.ts +0 -63
  120. package/dist/domains/run/agents/ModelFactory.js +0 -194
  121. package/dist/domains/run/data/agent.d.ts +0 -7
  122. package/dist/domains/run/data/agent.js +0 -67
  123. package/dist/domains/run/services/evaluationRunConfigMatcher.d.ts +0 -4
  124. package/dist/domains/run/services/evaluationRunConfigMatcher.js +0 -7
  125. package/dist/domains/run/utils/cleanup.d.ts +0 -21
  126. package/dist/domains/run/utils/cleanup.js +0 -59
  127. package/dist/utils/tempApiKeys.d.ts +0 -17
  128. package/dist/utils/tempApiKeys.js +0 -26
  129. package/dist/utils/workflowApiHelpers.d.ts +0 -1
  130. package/dist/utils/workflowApiHelpers.js +0 -1
@@ -1,8 +1,8 @@
1
- import * as hono6 from "hono";
1
+ import * as hono5 from "hono";
2
2
  import { BaseExecutionContext } from "@inkeep/agents-core";
3
3
 
4
4
  //#region src/middleware/runAuth.d.ts
5
- declare const runApiKeyAuth: () => hono6.MiddlewareHandler<{
5
+ declare const runApiKeyAuth: () => hono5.MiddlewareHandler<{
6
6
  Variables: {
7
7
  executionContext: BaseExecutionContext;
8
8
  };
@@ -11,7 +11,7 @@ declare const runApiKeyAuth: () => hono6.MiddlewareHandler<{
11
11
  * Creates a middleware that applies API key authentication except for specified route patterns
12
12
  * @param skipRouteCheck - Function that returns true if the route should skip authentication
13
13
  */
14
- declare const runApiKeyAuthExcept: (skipRouteCheck: (path: string) => boolean) => hono6.MiddlewareHandler<{
14
+ declare const runApiKeyAuthExcept: (skipRouteCheck: (path: string) => boolean) => hono5.MiddlewareHandler<{
15
15
  Variables: {
16
16
  executionContext: BaseExecutionContext;
17
17
  };
@@ -20,7 +20,7 @@ declare const runApiKeyAuthExcept: (skipRouteCheck: (path: string) => boolean) =
20
20
  * Helper middleware for endpoints that optionally support API key authentication
21
21
  * If no auth header is present, it continues without setting the executionContext
22
22
  */
23
- declare const runOptionalAuth: () => hono6.MiddlewareHandler<{
23
+ declare const runOptionalAuth: () => hono5.MiddlewareHandler<{
24
24
  Variables: {
25
25
  executionContext?: BaseExecutionContext;
26
26
  };
@@ -1,4 +1,4 @@
1
- import * as hono9 from "hono";
1
+ import * as hono8 from "hono";
2
2
 
3
3
  //#region src/middleware/sessionAuth.d.ts
4
4
 
@@ -7,11 +7,11 @@ import * as hono9 from "hono";
7
7
  * Requires that a user has already been authenticated via Better Auth session.
8
8
  * Used primarily for manage routes that require an active user session.
9
9
  */
10
- declare const sessionAuth: () => hono9.MiddlewareHandler<any, string, {}, Response>;
10
+ declare const sessionAuth: () => hono8.MiddlewareHandler<any, string, {}, Response>;
11
11
  /**
12
12
  * Global session middleware - sets user and session in context for all routes
13
13
  * Used for all routes that require an active user session.
14
14
  */
15
- declare const sessionContext: () => hono9.MiddlewareHandler<any, string, {}, Response>;
15
+ declare const sessionContext: () => hono8.MiddlewareHandler<any, string, {}, Response>;
16
16
  //#endregion
17
17
  export { sessionAuth, sessionContext };
@@ -1,4 +1,4 @@
1
- import * as hono11 from "hono";
1
+ import * as hono15 from "hono";
2
2
 
3
3
  //#region src/middleware/tenantAccess.d.ts
4
4
 
@@ -11,7 +11,7 @@ import * as hono11 from "hono";
11
11
  * - API key user: Access only to the tenant associated with the API key
12
12
  * - Session user: Access based on organization membership
13
13
  */
14
- declare const requireTenantAccess: () => hono11.MiddlewareHandler<{
14
+ declare const requireTenantAccess: () => hono15.MiddlewareHandler<{
15
15
  Variables: {
16
16
  userId: string;
17
17
  tenantId: string;
@@ -1,5 +1,5 @@
1
1
  import runDbClient_default from "../data/db/runDbClient.js";
2
- import { createApiError, getUserOrganizations } from "@inkeep/agents-core";
2
+ import { OrgRoles, createApiError, getUserOrganizationsFromDb } from "@inkeep/agents-core";
3
3
  import { createMiddleware } from "hono/factory";
4
4
  import { HTTPException } from "hono/http-exception";
5
5
 
@@ -26,7 +26,7 @@ const requireTenantAccess = () => createMiddleware(async (c, next) => {
26
26
  });
27
27
  if (userId === "system") {
28
28
  c.set("tenantId", tenantId);
29
- c.set("tenantRole", "owner");
29
+ c.set("tenantRole", OrgRoles.OWNER);
30
30
  await next();
31
31
  return;
32
32
  }
@@ -37,12 +37,12 @@ const requireTenantAccess = () => createMiddleware(async (c, next) => {
37
37
  message: "API key does not have access to this organization"
38
38
  });
39
39
  c.set("tenantId", tenantId);
40
- c.set("tenantRole", "owner");
40
+ c.set("tenantRole", OrgRoles.OWNER);
41
41
  await next();
42
42
  return;
43
43
  }
44
44
  try {
45
- const organizationAccess = (await getUserOrganizations(runDbClient_default)(userId)).find((org) => org.organizationId === tenantId);
45
+ const organizationAccess = (await getUserOrganizationsFromDb(runDbClient_default)(userId)).find((org) => org.organizationId === tenantId);
46
46
  if (!organizationAccess) throw createApiError({
47
47
  code: "forbidden",
48
48
  message: "Access denied to this organization"
@@ -1,7 +1,7 @@
1
- import * as hono12 from "hono";
1
+ import * as hono10 from "hono";
2
2
 
3
3
  //#region src/middleware/tracing.d.ts
4
- declare const otelBaggageMiddleware: () => hono12.MiddlewareHandler<any, string, {}, Response>;
5
- declare const executionBaggageMiddleware: () => hono12.MiddlewareHandler<any, string, {}, Response>;
4
+ declare const otelBaggageMiddleware: () => hono10.MiddlewareHandler<any, string, {}, Response>;
5
+ declare const executionBaggageMiddleware: () => hono10.MiddlewareHandler<any, string, {}, Response>;
6
6
  //#endregion
7
7
  export { executionBaggageMiddleware, otelBaggageMiddleware };
package/dist/openapi.d.ts CHANGED
@@ -2,6 +2,40 @@ import { OpenAPIHono } from "@hono/zod-openapi";
2
2
  import { Env } from "hono";
3
3
 
4
4
  //#region src/openapi.d.ts
5
+ declare const TagToDescription: {
6
+ A2A: string;
7
+ 'API Keys': string;
8
+ Agents: string;
9
+ 'Artifact Components': string;
10
+ Branches: string;
11
+ CLI: string;
12
+ Chat: string;
13
+ 'Context Configs': string;
14
+ Conversations: string;
15
+ Credentials: string;
16
+ 'Credential Stores': string;
17
+ 'Data Components': string;
18
+ Evaluations: string;
19
+ 'External Agents': string;
20
+ 'Function Tools': string;
21
+ Functions: string;
22
+ Invitations: string;
23
+ MCP: string;
24
+ 'MCP Catalog': string;
25
+ OAuth: string;
26
+ 'Project Members': string;
27
+ 'Project Permissions': string;
28
+ Projects: string;
29
+ Refs: string;
30
+ SubAgents: string;
31
+ 'Third-Party MCP Servers': string;
32
+ Tools: string;
33
+ Triggers: string;
34
+ 'User Organizations': string;
35
+ 'User Project Memberships': string;
36
+ Webhooks: string;
37
+ Workflows: string;
38
+ };
5
39
  declare function setupOpenAPIRoutes<E extends Env = Env>(app: OpenAPIHono<E>): void;
6
40
  //#endregion
7
- export { setupOpenAPIRoutes };
41
+ export { TagToDescription, setupOpenAPIRoutes };
package/dist/openapi.js CHANGED
@@ -1,6 +1,40 @@
1
1
  import { swaggerUI } from "@hono/swagger-ui";
2
2
 
3
3
  //#region src/openapi.ts
4
+ const TagToDescription = {
5
+ A2A: "Agent-to-Agent communication endpoints",
6
+ "API Keys": "Operations for managing API keys",
7
+ Agents: "Operations for managing agents",
8
+ "Artifact Components": "Operations for managing artifact components",
9
+ Branches: "Operations for managing branches",
10
+ CLI: "CLI authentication endpoints",
11
+ Chat: "Chat completions endpoints",
12
+ "Context Configs": "Operations for managing context configurations",
13
+ Conversations: "Operations for managing conversations",
14
+ Credentials: "Operations for managing credentials",
15
+ "Credential Stores": "Operations for managing credential stores",
16
+ "Data Components": "Operations for managing data components",
17
+ Evaluations: "Operations for managing evaluations",
18
+ "External Agents": "Operations for managing external agents",
19
+ "Function Tools": "Operations for managing function tools",
20
+ Functions: "Operations for managing functions",
21
+ Invitations: "Operations for managing invitations",
22
+ MCP: "MCP (Model Context Protocol) endpoints",
23
+ "MCP Catalog": "Operations for MCP catalog",
24
+ OAuth: "OAuth authentication endpoints",
25
+ "Project Members": "Operations for managing project members",
26
+ "Project Permissions": "Operations for managing project permissions",
27
+ Projects: "Operations for managing projects",
28
+ Refs: "Operations for the resolved ref (branch name, tag name, or commit hash)",
29
+ SubAgents: "Operations for managing sub agents",
30
+ "Third-Party MCP Servers": "Operations for managing third-party MCP servers",
31
+ Tools: "Operations for managing MCP tools",
32
+ Triggers: "Operations for managing triggers",
33
+ "User Organizations": "Operations for managing user organizations",
34
+ "User Project Memberships": "Operations for managing user project memberships",
35
+ Webhooks: "Webhook endpoints",
36
+ Workflows: "Workflow trigger endpoints"
37
+ };
4
38
  function setupOpenAPIRoutes(app) {
5
39
  app.get("/openapi.json", (c) => {
6
40
  try {
@@ -16,100 +50,10 @@ function setupOpenAPIRoutes(app) {
16
50
  url: serverUrl,
17
51
  description: "API Server"
18
52
  }],
19
- tags: [
20
- {
21
- name: "Agent",
22
- description: "Operations for managing individual agents"
23
- },
24
- {
25
- name: "Agent Artifact Component Relations",
26
- description: "Operations for managing agent artifact component relationships"
27
- },
28
- {
29
- name: "Agent Data Component Relations",
30
- description: "Operations for managing agent data component relationships"
31
- },
32
- {
33
- name: "Agents",
34
- description: "Operations for managing agents"
35
- },
36
- {
37
- name: "API Keys",
38
- description: "Operations for managing API keys"
39
- },
40
- {
41
- name: "Artifact Component",
42
- description: "Operations for managing artifact components"
43
- },
44
- {
45
- name: "Context Config",
46
- description: "Operations for managing context configurations"
47
- },
48
- {
49
- name: "Credential",
50
- description: "Operations for managing credentials"
51
- },
52
- {
53
- name: "Credential Store",
54
- description: "Operations for managing credential stores"
55
- },
56
- {
57
- name: "Data Component",
58
- description: "Operations for managing data components"
59
- },
60
- {
61
- name: "External Agents",
62
- description: "Operations for managing external agents"
63
- },
64
- {
65
- name: "Full Agent",
66
- description: "Operations for managing complete agent definitions"
67
- },
68
- {
69
- name: "Full Project",
70
- description: "Operations for managing complete project definitions"
71
- },
72
- {
73
- name: "Function Tools",
74
- description: "Operations for managing function tools"
75
- },
76
- {
77
- name: "Functions",
78
- description: "Operations for managing functions"
79
- },
80
- {
81
- name: "OAuth",
82
- description: "OAuth authentication endpoints for MCP tools"
83
- },
84
- {
85
- name: "Projects",
86
- description: "Operations for managing projects"
87
- },
88
- {
89
- name: "Sub Agent External Agent Relations",
90
- description: "Operations for managing sub agent external agent relationships"
91
- },
92
- {
93
- name: "Sub Agent Relations",
94
- description: "Operations for managing sub agent relationships"
95
- },
96
- {
97
- name: "Sub Agent Team Agent Relations",
98
- description: "Operations for managing sub agent team agent relationships"
99
- },
100
- {
101
- name: "SubAgent",
102
- description: "Operations for managing sub agents"
103
- },
104
- {
105
- name: "SubAgent Tool Relations",
106
- description: "Operations for managing sub agent tool relationships"
107
- },
108
- {
109
- name: "Tools",
110
- description: "Operations for managing MCP tools"
111
- }
112
- ]
53
+ tags: Object.entries(TagToDescription).map(([key, value]) => ({
54
+ name: key,
55
+ description: value
56
+ }))
113
57
  });
114
58
  document.components = {
115
59
  ...document.components,
@@ -153,4 +97,4 @@ function setupOpenAPIRoutes(app) {
153
97
  }
154
98
 
155
99
  //#endregion
156
- export { setupOpenAPIRoutes };
100
+ export { TagToDescription, setupOpenAPIRoutes };
@@ -0,0 +1,10 @@
1
+ import { AppVariables } from "../types/app.js";
2
+ import "../types/index.js";
3
+ import { OpenAPIHono } from "@hono/zod-openapi";
4
+
5
+ //#region src/routes/healthChecks.d.ts
6
+ declare const healthChecksHandler: OpenAPIHono<{
7
+ Variables: AppVariables;
8
+ }, {}, "/">;
9
+ //#endregion
10
+ export { healthChecksHandler };
@@ -0,0 +1,75 @@
1
+ import manageDbPool_default from "../data/db/manageDbPool.js";
2
+ import runDbClient_default from "../data/db/runDbClient.js";
3
+ import { checkManageDb, checkRunDb } from "../utils/healthChecks.js";
4
+ import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
5
+
6
+ //#region src/routes/healthChecks.ts
7
+ const healthChecksHandler = new OpenAPIHono();
8
+ healthChecksHandler.openapi(createRoute({
9
+ method: "get",
10
+ path: "/health",
11
+ operationId: "health",
12
+ tags: ["Health"],
13
+ summary: "Health check",
14
+ description: "Check if the management service is healthy",
15
+ responses: { 204: { description: "Service is healthy" } }
16
+ }), (c) => {
17
+ return c.body(null, 204);
18
+ });
19
+ const ReadyResponseSchema = z.object({
20
+ status: z.literal("ok"),
21
+ manageDb: z.boolean().describe("Whether the manage database is reachable"),
22
+ runDb: z.boolean().describe("Whether the run database is reachable")
23
+ }).openapi("ReadyResponse");
24
+ const ReadyErrorChecksSchema = z.object({
25
+ manageDb: z.boolean().describe("Whether the manage database check passed"),
26
+ runDb: z.boolean().describe("Whether the run database check passed")
27
+ }).openapi("ReadyErrorChecks");
28
+ const ReadyErrorResponseSchema = z.object({
29
+ type: z.string().describe("A URI reference that identifies the problem type"),
30
+ title: z.string().describe("A short, human-readable summary of the problem type"),
31
+ status: z.number().describe("The HTTP status code"),
32
+ detail: z.string().describe("A human-readable explanation specific to this occurrence"),
33
+ checks: ReadyErrorChecksSchema
34
+ }).openapi("ReadyErrorResponse");
35
+ healthChecksHandler.openapi(createRoute({
36
+ method: "get",
37
+ path: "/ready",
38
+ operationId: "ready",
39
+ tags: ["Health"],
40
+ summary: "Readiness check",
41
+ description: "Check if the service is ready to serve traffic by verifying database connectivity",
42
+ responses: {
43
+ 200: {
44
+ description: "Service is ready - all health checks passed",
45
+ content: { "application/json": { schema: ReadyResponseSchema } }
46
+ },
47
+ 503: {
48
+ description: "Service is not ready - one or more health checks failed",
49
+ content: { "application/problem+json": { schema: ReadyErrorResponseSchema } }
50
+ }
51
+ }
52
+ }), async (c) => {
53
+ const [manageDbHealthy, runDbHealthy] = await Promise.all([checkManageDb(manageDbPool_default), checkRunDb(runDbClient_default)]);
54
+ if (manageDbHealthy && runDbHealthy) return c.json({
55
+ status: "ok",
56
+ manageDb: true,
57
+ runDb: true
58
+ });
59
+ const failedChecks = [];
60
+ if (!manageDbHealthy) failedChecks.push("manage database");
61
+ if (!runDbHealthy) failedChecks.push("run database");
62
+ return c.json({
63
+ type: "https://httpstatuses.com/503",
64
+ title: "Service Unavailable",
65
+ status: 503,
66
+ detail: `Health checks failed: ${failedChecks.join(", ")}`,
67
+ checks: {
68
+ manageDb: manageDbHealthy,
69
+ runDb: runDbHealthy
70
+ }
71
+ }, 503, { "Content-Type": "application/problem+json" });
72
+ });
73
+
74
+ //#endregion
75
+ export { healthChecksHandler };
@@ -38,6 +38,8 @@ type ManageAppVariables = AppVariables & {
38
38
  db: AgentsManageDatabaseClient;
39
39
  auth: ReturnType<typeof createAuth> | null;
40
40
  resolvedRef: ResolvedRef;
41
+ /** Cached by projectFull middleware to avoid duplicate DB lookup for PUT upsert */
42
+ isProjectCreate?: boolean;
41
43
  };
42
44
  type AppConfig = {
43
45
  serverConfig: ServerConfig;
@@ -0,0 +1,8 @@
1
+ import { AgentsRunDatabaseClient } from "@inkeep/agents-core";
2
+ import { Pool } from "pg";
3
+
4
+ //#region src/utils/healthChecks.d.ts
5
+ declare function checkManageDb(pool: Pool): Promise<boolean>;
6
+ declare function checkRunDb(client: AgentsRunDatabaseClient): Promise<boolean>;
7
+ //#endregion
8
+ export { checkManageDb, checkRunDb };
@@ -0,0 +1,38 @@
1
+ //#region src/utils/healthChecks.ts
2
+ const HEALTH_CHECK_TIMEOUT_MS = 5e3;
3
+ async function withTimeout(promise, timeoutMs) {
4
+ let timeoutId;
5
+ const timeoutPromise = new Promise((_, reject) => {
6
+ timeoutId = setTimeout(() => {
7
+ reject(/* @__PURE__ */ new Error(`Health check timed out after ${timeoutMs}ms`));
8
+ }, timeoutMs);
9
+ });
10
+ try {
11
+ return await Promise.race([promise, timeoutPromise]);
12
+ } finally {
13
+ if (timeoutId !== void 0) clearTimeout(timeoutId);
14
+ }
15
+ }
16
+ async function checkManageDb(pool) {
17
+ try {
18
+ await withTimeout(pool.query("SELECT 1"), HEALTH_CHECK_TIMEOUT_MS);
19
+ return true;
20
+ } catch {
21
+ return false;
22
+ }
23
+ }
24
+ async function checkRunDb(client) {
25
+ try {
26
+ if ("$client" in client && client.$client) {
27
+ const pool = client.$client;
28
+ await withTimeout(pool.query("SELECT 1"), HEALTH_CHECK_TIMEOUT_MS);
29
+ return true;
30
+ }
31
+ return false;
32
+ } catch {
33
+ return false;
34
+ }
35
+ }
36
+
37
+ //#endregion
38
+ export { checkManageDb, checkRunDb };
@@ -4,6 +4,6 @@
4
4
  * This modifies the query payload to ensure all builder queries include
5
5
  * a server-side project.id filter, preventing client-side filter bypass.
6
6
  */
7
- declare function enforceProjectFilter(payload: any, projectId: string): any;
7
+ declare function enforceSecurityFilters(payload: any, tenantId: string, projectId?: string): any;
8
8
  //#endregion
9
- export { enforceProjectFilter };
9
+ export { enforceSecurityFilters };
@@ -4,7 +4,7 @@
4
4
  * This modifies the query payload to ensure all builder queries include
5
5
  * a server-side project.id filter, preventing client-side filter bypass.
6
6
  */
7
- function enforceProjectFilter(payload, projectId) {
7
+ function enforceSecurityFilters(payload, tenantId, projectId) {
8
8
  const modifiedPayload = JSON.parse(JSON.stringify(payload));
9
9
  if (modifiedPayload.compositeQuery?.builderQueries) for (const queryKey in modifiedPayload.compositeQuery.builderQueries) {
10
10
  const query = modifiedPayload.compositeQuery.builderQueries[queryKey];
@@ -12,8 +12,20 @@ function enforceProjectFilter(payload, projectId) {
12
12
  op: "AND",
13
13
  items: []
14
14
  };
15
- query.filters.items = query.filters.items.filter((item) => item.key?.key !== "project.id");
15
+ query.filters.items = query.filters.items.filter((item) => item.key?.key !== "tenant.id" && item.key?.key !== "project.id");
16
16
  query.filters.items.push({
17
+ key: {
18
+ key: "tenant.id",
19
+ dataType: "string",
20
+ type: "tag",
21
+ isColumn: false,
22
+ isJSON: false,
23
+ id: "false"
24
+ },
25
+ op: "=",
26
+ value: tenantId
27
+ });
28
+ if (projectId) query.filters.items.push({
17
29
  key: {
18
30
  key: "project.id",
19
31
  dataType: "string",
@@ -30,4 +42,4 @@ function enforceProjectFilter(payload, projectId) {
30
42
  }
31
43
 
32
44
  //#endregion
33
- export { enforceProjectFilter };
45
+ export { enforceSecurityFilters };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inkeep/agents-api",
3
- "version": "0.42.0",
3
+ "version": "0.43.0",
4
4
  "description": "Unified Inkeep Agents API - combines management, runtime, and evaluation capabilities",
5
5
  "types": "dist/index.d.ts",
6
6
  "exports": {
@@ -32,17 +32,11 @@
32
32
  "type": "module",
33
33
  "license": "SEE LICENSE IN LICENSE.md",
34
34
  "dependencies": {
35
- "@ai-sdk/anthropic": "3.0.7",
36
- "@ai-sdk/gateway": "3.0.9",
37
35
  "@ai-sdk/google": "3.0.4",
38
- "@ai-sdk/openai": "3.0.7",
39
- "@ai-sdk/openai-compatible": "2.0.4",
40
36
  "@hono/mcp": "^0.1.5",
41
- "@hono/otel": "^0.4.0",
42
37
  "@hono/swagger-ui": "^0.5.1",
43
38
  "@hono/zod-openapi": "^1.1.5",
44
39
  "@modelcontextprotocol/sdk": "^1.25.2",
45
- "@openrouter/ai-sdk-provider": "^1.2.0",
46
40
  "@opentelemetry/api": "^1.9.0",
47
41
  "@opentelemetry/auto-instrumentations-node": "^0.64.1",
48
42
  "@opentelemetry/baggage-span-processor": "^0.4.0",
@@ -53,6 +47,7 @@
53
47
  "@opentelemetry/sdk-node": "^0.205.0",
54
48
  "@opentelemetry/sdk-trace-base": "^2.1.0",
55
49
  "@opentelemetry/semantic-conventions": "^1.37.0",
50
+ "@vercel/functions": "^1.4.0",
56
51
  "@vercel/sandbox": "^0.0.24",
57
52
  "@workflow/builders": "4.0.1-beta.27",
58
53
  "@workflow/world-local": "4.0.1-beta.19",
@@ -66,12 +61,14 @@
66
61
  "hono": "^4.10.4",
67
62
  "hono-pino": "^0.10.1",
68
63
  "jmespath": "^0.16.0",
64
+ "jose": "^6.1.0",
69
65
  "llm-info": "^1.0.69",
70
66
  "openid-client": "^6.8.1",
71
67
  "pg": "^8.16.3",
72
68
  "workflow": "4.0.1-beta.33",
73
- "@inkeep/agents-core": "^0.42.0",
74
- "@inkeep/agents-manage-mcp": "^0.42.0"
69
+ "@inkeep/agents-core": "^0.43.0",
70
+ "@inkeep/agents-mcp": "^0.43.0",
71
+ "@inkeep/agents-manage-mcp": "^0.43.0"
75
72
  },
76
73
  "peerDependencies": {
77
74
  "@hono/zod-openapi": "^1.1.5",
@@ -107,6 +104,7 @@
107
104
  "directory": "agents-api"
108
105
  },
109
106
  "scripts": {
107
+ "knip": "knip --directory .. --workspace agents-api --config agents-api/knip.config.ts --dependencies --files",
110
108
  "workflow:build": "tsx src/domains/evals/scripts/build-workflow.ts",
111
109
  "well-known:copy": "tsx scripts/copy-well-known.ts",
112
110
  "dev": "pnpm workflow:build && vite",
@@ -1,19 +0,0 @@
1
- //#region src/domains/evals/services/startEvaluation.d.ts
2
- /**
3
- * Service to start evaluation workflows.
4
- * This encapsulates the workflow logic so consumers don't need to import workflow packages.
5
- */
6
- interface StartEvaluationParams {
7
- tenantId: string;
8
- projectId: string;
9
- conversationId: string;
10
- evaluatorIds: string[];
11
- evaluationRunId: string;
12
- }
13
- /**
14
- * Start an evaluation workflow for a conversation.
15
- * This is a convenience wrapper that handles workflow initialization internally.
16
- */
17
- declare function startConversationEvaluation(params: StartEvaluationParams): Promise<void>;
18
- //#endregion
19
- export { StartEvaluationParams, startConversationEvaluation };
@@ -1,18 +0,0 @@
1
- import { evaluateConversationWorkflow } from "../workflow/functions/evaluateConversation.js";
2
- import { start } from "workflow/api";
3
-
4
- //#region src/domains/evals/services/startEvaluation.ts
5
- /**
6
- * Service to start evaluation workflows.
7
- * This encapsulates the workflow logic so consumers don't need to import workflow packages.
8
- */
9
- /**
10
- * Start an evaluation workflow for a conversation.
11
- * This is a convenience wrapper that handles workflow initialization internally.
12
- */
13
- async function startConversationEvaluation(params) {
14
- await start(evaluateConversationWorkflow, [params]);
15
- }
16
-
17
- //#endregion
18
- export { startConversationEvaluation };
@@ -1,4 +0,0 @@
1
- import { createEvalRoutes, evalRoutes } from "./evals/index.js";
2
- import { createManageRoutes, manageRoutes } from "./manage/index.js";
3
- import { createRunRoutes, runRoutes } from "./run/index.js";
4
- export { createEvalRoutes, createManageRoutes, createRunRoutes, evalRoutes, manageRoutes, runRoutes };
@@ -1,5 +0,0 @@
1
- import { createEvalRoutes, evalRoutes } from "./evals/index.js";
2
- import { createManageRoutes, manageRoutes } from "./manage/index.js";
3
- import { createRunRoutes, runRoutes } from "./run/index.js";
4
-
5
- export { createEvalRoutes, createManageRoutes, createRunRoutes, evalRoutes, manageRoutes, runRoutes };