@inkeep/agents-api 0.0.0-dev-20260302211942 → 0.0.0-dev-20260302234522

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 (34) hide show
  1. package/dist/.well-known/workflow/v1/manifest.json +14 -14
  2. package/dist/createApp.js +2 -2
  3. package/dist/data/db/manageDbClient.d.ts +2 -2
  4. package/dist/data/db/runDbClient.d.ts +2 -2
  5. package/dist/domains/evals/routes/datasetTriggers.d.ts +2 -2
  6. package/dist/domains/evals/routes/index.d.ts +2 -2
  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/passwordResetLinks.d.ts +2 -2
  13. package/dist/domains/manage/routes/users.d.ts +2 -2
  14. package/dist/domains/mcp/routes/mcp.d.ts +2 -2
  15. package/dist/domains/run/agents/relationTools.d.ts +2 -2
  16. package/dist/domains/run/tools/distill-conversation-history-tool.d.ts +1 -1
  17. package/dist/domains/run/types/chat.d.ts +4 -4
  18. package/dist/domains/run/workflow/steps/scheduledTriggerSteps.d.ts +5 -5
  19. package/dist/factory.d.ts +322 -322
  20. package/dist/index.d.ts +322 -322
  21. package/dist/middleware/index.d.ts +2 -2
  22. package/dist/middleware/index.js +2 -2
  23. package/dist/middleware/manageAuth.d.ts +10 -6
  24. package/dist/middleware/manageAuth.js +13 -19
  25. package/dist/middleware/projectConfig.d.ts +3 -3
  26. package/dist/middleware/requirePermission.d.ts +2 -2
  27. package/dist/middleware/runAuth.d.ts +4 -4
  28. package/dist/middleware/runAuth.js +5 -0
  29. package/dist/middleware/sessionAuth.d.ts +3 -3
  30. package/dist/middleware/tenantAccess.d.ts +2 -2
  31. package/dist/middleware/tracing.d.ts +3 -3
  32. package/dist/middleware/workAppsAuth.js +4 -4
  33. package/dist/routes/capabilities.js +2 -2
  34. package/package.json +4 -4
@@ -1,8 +1,8 @@
1
1
  import { authCorsConfig, defaultCorsConfig, getBaseDomain, isOriginAllowed, playgroundCorsConfig, runCorsConfig, signozCorsConfig, workAppsCorsConfig } from "./cors.js";
2
2
  import { errorHandler } from "./errorHandler.js";
3
- import { manageApiKeyAuth, manageApiKeyOrSessionAuth } from "./manageAuth.js";
3
+ import { manageBearerAuth, manageBearerOrSessionAuth } from "./manageAuth.js";
4
4
  import { runApiKeyAuth, runApiKeyAuthExcept, runOptionalAuth } from "./runAuth.js";
5
5
  import { sessionAuth } from "./sessionAuth.js";
6
6
  import { requireTenantAccess } from "./tenantAccess.js";
7
7
  import { workAppsAuth } from "./workAppsAuth.js";
8
- export { authCorsConfig, defaultCorsConfig, errorHandler, getBaseDomain, isOriginAllowed, manageApiKeyAuth, manageApiKeyOrSessionAuth, playgroundCorsConfig, requireTenantAccess, runApiKeyAuth, runApiKeyAuthExcept, runCorsConfig, runOptionalAuth, sessionAuth, signozCorsConfig, workAppsAuth, workAppsCorsConfig };
8
+ export { authCorsConfig, defaultCorsConfig, errorHandler, getBaseDomain, isOriginAllowed, manageBearerAuth, manageBearerOrSessionAuth, playgroundCorsConfig, requireTenantAccess, runApiKeyAuth, runApiKeyAuthExcept, runCorsConfig, runOptionalAuth, sessionAuth, signozCorsConfig, workAppsAuth, workAppsCorsConfig };
@@ -1,9 +1,9 @@
1
1
  import { authCorsConfig, defaultCorsConfig, getBaseDomain, isOriginAllowed, playgroundCorsConfig, runCorsConfig, signozCorsConfig, workAppsCorsConfig } from "./cors.js";
2
2
  import { errorHandler } from "./errorHandler.js";
3
3
  import { sessionAuth } from "./sessionAuth.js";
4
- import { manageApiKeyAuth, manageApiKeyOrSessionAuth } from "./manageAuth.js";
4
+ import { manageBearerAuth, manageBearerOrSessionAuth } from "./manageAuth.js";
5
5
  import { runApiKeyAuth, runApiKeyAuthExcept, runOptionalAuth } from "./runAuth.js";
6
6
  import { requireTenantAccess } from "./tenantAccess.js";
7
7
  import { workAppsAuth } from "./workAppsAuth.js";
8
8
 
9
- export { authCorsConfig, defaultCorsConfig, errorHandler, getBaseDomain, isOriginAllowed, manageApiKeyAuth, manageApiKeyOrSessionAuth, playgroundCorsConfig, requireTenantAccess, runApiKeyAuth, runApiKeyAuthExcept, runCorsConfig, runOptionalAuth, sessionAuth, signozCorsConfig, workAppsAuth, workAppsCorsConfig };
9
+ export { authCorsConfig, defaultCorsConfig, errorHandler, getBaseDomain, isOriginAllowed, manageBearerAuth, manageBearerOrSessionAuth, playgroundCorsConfig, requireTenantAccess, runApiKeyAuth, runApiKeyAuthExcept, runCorsConfig, runOptionalAuth, sessionAuth, signozCorsConfig, workAppsAuth, workAppsCorsConfig };
@@ -1,5 +1,5 @@
1
1
  import { BaseExecutionContext } from "@inkeep/agents-core";
2
- import * as hono4 from "hono";
2
+ import * as hono16 from "hono";
3
3
  import { createAuth } from "@inkeep/agents-core/auth";
4
4
 
5
5
  //#region src/middleware/manageAuth.d.ts
@@ -9,10 +9,13 @@ import { createAuth } from "@inkeep/agents-core/auth";
9
9
  * Authentication priority:
10
10
  * 1. Bypass secret (INKEEP_AGENTS_MANAGE_API_BYPASS_SECRET)
11
11
  * 2. Better-auth session token (from device authorization flow)
12
- * 3. Database API key
12
+ * 3. Slack user JWT token (for Slack work app delegation)
13
13
  * 4. Internal service token
14
+ *
15
+ * NOTE: Database API keys are intentionally NOT accepted on manage endpoints.
16
+ * API keys are restricted to the run domain only (chat, agent execution).
14
17
  */
15
- declare const manageApiKeyAuth: () => hono4.MiddlewareHandler<{
18
+ declare const manageBearerAuth: () => hono16.MiddlewareHandler<{
16
19
  Variables: {
17
20
  executionContext: BaseExecutionContext;
18
21
  userId?: string;
@@ -23,8 +26,9 @@ declare const manageApiKeyAuth: () => hono4.MiddlewareHandler<{
23
26
  }, string, {}, Response>;
24
27
  /**
25
28
  * Middleware that gates a route with manage-domain authentication.
26
- * Uses Bearer token → API key auth, otherwise falls back to session auth.
29
+ * Uses Bearer token → manage bearer auth (bypass secret, session, Slack JWT, internal service),
30
+ * otherwise falls back to session auth.
27
31
  */
28
- declare const manageApiKeyOrSessionAuth: () => hono4.MiddlewareHandler<any, string, {}, Response>;
32
+ declare const manageBearerOrSessionAuth: () => hono16.MiddlewareHandler<any, string, {}, Response>;
29
33
  //#endregion
30
- export { manageApiKeyAuth, manageApiKeyOrSessionAuth };
34
+ export { manageBearerAuth, manageBearerOrSessionAuth };
@@ -1,7 +1,6 @@
1
1
  import { env } from "../env.js";
2
- import runDbClient_default from "../data/db/runDbClient.js";
3
2
  import { sessionAuth } from "./sessionAuth.js";
4
- import { getLogger, isInternalServiceToken, isSlackUserToken, validateAndGetApiKey, verifyInternalServiceAuthHeader, verifySlackUserToken } from "@inkeep/agents-core";
3
+ import { getLogger, isInternalServiceToken, isSlackUserToken, verifyInternalServiceAuthHeader, verifySlackUserToken } from "@inkeep/agents-core";
5
4
  import { registerAuthzMeta } from "@inkeep/agents-core/middleware";
6
5
  import { createMiddleware } from "hono/factory";
7
6
  import { HTTPException } from "hono/http-exception";
@@ -13,10 +12,13 @@ const logger = getLogger("env-key-auth");
13
12
  * Authentication priority:
14
13
  * 1. Bypass secret (INKEEP_AGENTS_MANAGE_API_BYPASS_SECRET)
15
14
  * 2. Better-auth session token (from device authorization flow)
16
- * 3. Database API key
15
+ * 3. Slack user JWT token (for Slack work app delegation)
17
16
  * 4. Internal service token
17
+ *
18
+ * NOTE: Database API keys are intentionally NOT accepted on manage endpoints.
19
+ * API keys are restricted to the run domain only (chat, agent execution).
18
20
  */
19
- const manageApiKeyAuth = () => createMiddleware(async (c, next) => {
21
+ const manageBearerAuth = () => createMiddleware(async (c, next) => {
20
22
  const authHeader = c.req.header("Authorization");
21
23
  if (!authHeader || !authHeader.startsWith("Bearer ")) throw new HTTPException(401, { message: "Missing or invalid authorization header. Expected: Bearer <api_key>" });
22
24
  const token = authHeader.substring(7);
@@ -49,16 +51,7 @@ const manageApiKeyAuth = () => createMiddleware(async (c, next) => {
49
51
  return;
50
52
  }
51
53
  } catch (error) {
52
- logger.debug({ error }, "Better-auth session validation failed, trying API key");
53
- }
54
- const validatedKey = await validateAndGetApiKey(token, runDbClient_default);
55
- if (validatedKey) {
56
- logger.info({ keyId: validatedKey.id }, "API key authenticated successfully");
57
- c.set("userId", `apikey:${validatedKey.id}`);
58
- c.set("userEmail", `apikey-${validatedKey.id}@internal`);
59
- c.set("tenantId", validatedKey.tenantId);
60
- await next();
61
- return;
54
+ logger.debug({ error }, "Better-auth session validation failed, trying other auth methods");
62
55
  }
63
56
  if (isSlackUserToken(token)) {
64
57
  const result = await verifySlackUserToken(token);
@@ -94,24 +87,25 @@ const manageApiKeyAuth = () => createMiddleware(async (c, next) => {
94
87
  });
95
88
  /**
96
89
  * Middleware that gates a route with manage-domain authentication.
97
- * Uses Bearer token → API key auth, otherwise falls back to session auth.
90
+ * Uses Bearer token → manage bearer auth (bypass secret, session, Slack JWT, internal service),
91
+ * otherwise falls back to session auth.
98
92
  */
99
- const manageApiKeyOrSessionAuth = () => {
93
+ const manageBearerOrSessionAuth = () => {
100
94
  const mw = createMiddleware(async (c, next) => {
101
95
  if (env.ENVIRONMENT === "test") {
102
96
  await next();
103
97
  return;
104
98
  }
105
- if (c.req.header("Authorization")?.startsWith("Bearer ")) return manageApiKeyAuth()(c, next);
99
+ if (c.req.header("Authorization")?.startsWith("Bearer ")) return manageBearerAuth()(c, next);
106
100
  return sessionAuth()(c, next);
107
101
  });
108
102
  registerAuthzMeta(mw, {
109
103
  resource: "organization",
110
104
  permission: "member",
111
- description: "Requires session cookie or API key authentication"
105
+ description: "Requires session cookie authentication"
112
106
  });
113
107
  return mw;
114
108
  };
115
109
 
116
110
  //#endregion
117
- export { manageApiKeyAuth, manageApiKeyOrSessionAuth };
111
+ export { manageBearerAuth, manageBearerOrSessionAuth };
@@ -1,11 +1,11 @@
1
1
  import { BaseExecutionContext, ResolvedRef } from "@inkeep/agents-core";
2
- import * as hono1 from "hono";
2
+ import * as hono3 from "hono";
3
3
 
4
4
  //#region src/middleware/projectConfig.d.ts
5
5
  /**
6
6
  * Middleware that fetches the full project definition from the Management API
7
7
  */
8
- declare const projectConfigMiddleware: hono1.MiddlewareHandler<{
8
+ declare const projectConfigMiddleware: hono3.MiddlewareHandler<{
9
9
  Variables: {
10
10
  executionContext: BaseExecutionContext;
11
11
  resolvedRef: ResolvedRef;
@@ -15,7 +15,7 @@ declare const projectConfigMiddleware: hono1.MiddlewareHandler<{
15
15
  * Creates a middleware that applies project config fetching except for specified route patterns
16
16
  * @param skipRouteCheck - Function that returns true if the route should skip the middleware
17
17
  */
18
- declare const projectConfigMiddlewareExcept: (skipRouteCheck: (path: string) => boolean) => hono1.MiddlewareHandler<{
18
+ declare const projectConfigMiddlewareExcept: (skipRouteCheck: (path: string) => boolean) => hono3.MiddlewareHandler<{
19
19
  Variables: {
20
20
  executionContext: BaseExecutionContext;
21
21
  resolvedRef: ResolvedRef;
@@ -1,5 +1,5 @@
1
1
  import { ManageAppVariables } from "../types/app.js";
2
- import * as hono3 from "hono";
2
+ import * as hono5 from "hono";
3
3
 
4
4
  //#region src/middleware/requirePermission.d.ts
5
5
  type Permission = {
@@ -9,6 +9,6 @@ declare const requirePermission: <Env$1 extends {
9
9
  Variables: ManageAppVariables;
10
10
  } = {
11
11
  Variables: ManageAppVariables;
12
- }>(permissions: Permission) => hono3.MiddlewareHandler<Env$1, string, {}, Response>;
12
+ }>(permissions: Permission) => hono5.MiddlewareHandler<Env$1, string, {}, Response>;
13
13
  //#endregion
14
14
  export { requirePermission };
@@ -1,8 +1,8 @@
1
1
  import { BaseExecutionContext } from "@inkeep/agents-core";
2
- import * as hono7 from "hono";
2
+ import * as hono6 from "hono";
3
3
 
4
4
  //#region src/middleware/runAuth.d.ts
5
- declare const runApiKeyAuth: () => hono7.MiddlewareHandler<{
5
+ declare const runApiKeyAuth: () => hono6.MiddlewareHandler<{
6
6
  Variables: {
7
7
  executionContext: BaseExecutionContext;
8
8
  };
@@ -11,7 +11,7 @@ declare const runApiKeyAuth: () => hono7.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) => hono7.MiddlewareHandler<{
14
+ declare const runApiKeyAuthExcept: (skipRouteCheck: (path: string) => boolean) => hono6.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: () => hono7.MiddlewareHandler<{
23
+ declare const runOptionalAuth: () => hono6.MiddlewareHandler<{
24
24
  Variables: {
25
25
  executionContext?: BaseExecutionContext;
26
26
  };
@@ -40,6 +40,11 @@ function extractRequestData(c) {
40
40
  */
41
41
  function buildExecutionContext(authResult, reqData) {
42
42
  const agentId = authResult.metadata?.teamDelegation && reqData.agentId ? reqData.agentId : authResult.agentId;
43
+ if (!authResult.metadata?.teamDelegation && reqData.agentId && reqData.agentId !== authResult.agentId && authResult.apiKeyId && !authResult.apiKeyId.startsWith("temp-") && authResult.apiKeyId !== "bypass" && authResult.apiKeyId !== "slack-user-token" && authResult.apiKeyId !== "team-agent-token" && authResult.apiKeyId !== "test-key") logger.warn({
44
+ requestedAgentId: reqData.agentId,
45
+ apiKeyAgentId: authResult.agentId,
46
+ apiKeyId: authResult.apiKeyId
47
+ }, "API key agent scope mismatch: ignoring x-inkeep-agent-id header, using key-bound agent");
43
48
  return createBaseExecutionContext({
44
49
  apiKey: authResult.apiKey,
45
50
  tenantId: authResult.tenantId,
@@ -1,4 +1,4 @@
1
- import * as hono10 from "hono";
1
+ import * as hono11 from "hono";
2
2
 
3
3
  //#region src/middleware/sessionAuth.d.ts
4
4
 
@@ -7,11 +7,11 @@ import * as hono10 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: () => hono10.MiddlewareHandler<any, string, {}, Response>;
10
+ declare const sessionAuth: () => hono11.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: () => hono10.MiddlewareHandler<any, string, {}, Response>;
15
+ declare const sessionContext: () => hono11.MiddlewareHandler<any, string, {}, Response>;
16
16
  //#endregion
17
17
  export { sessionAuth, sessionContext };
@@ -1,4 +1,4 @@
1
- import * as hono13 from "hono";
1
+ import * as hono15 from "hono";
2
2
 
3
3
  //#region src/middleware/tenantAccess.d.ts
4
4
 
@@ -12,7 +12,7 @@ import * as hono13 from "hono";
12
12
  * - API key user: Access only to the tenant associated with the API key
13
13
  * - Session user: Access based on organization membership
14
14
  */
15
- declare const requireTenantAccess: () => hono13.MiddlewareHandler<{
15
+ declare const requireTenantAccess: () => hono15.MiddlewareHandler<{
16
16
  Variables: {
17
17
  userId: string;
18
18
  tenantId: string;
@@ -1,7 +1,7 @@
1
- import * as hono14 from "hono";
1
+ import * as hono13 from "hono";
2
2
 
3
3
  //#region src/middleware/tracing.d.ts
4
- declare const otelBaggageMiddleware: () => hono14.MiddlewareHandler<any, string, {}, Response>;
5
- declare const executionBaggageMiddleware: () => hono14.MiddlewareHandler<any, string, {}, Response>;
4
+ declare const otelBaggageMiddleware: () => hono13.MiddlewareHandler<any, string, {}, Response>;
5
+ declare const executionBaggageMiddleware: () => hono13.MiddlewareHandler<any, string, {}, Response>;
6
6
  //#endregion
7
7
  export { executionBaggageMiddleware, otelBaggageMiddleware };
@@ -1,20 +1,20 @@
1
1
  import { env } from "../env.js";
2
2
  import { sessionAuth } from "./sessionAuth.js";
3
- import { manageApiKeyAuth } from "./manageAuth.js";
3
+ import { manageBearerAuth } from "./manageAuth.js";
4
4
  import { createApiError } from "@inkeep/agents-core";
5
5
 
6
6
  //#region src/middleware/workAppsAuth.ts
7
7
  /**
8
8
  * Work Apps Authentication Middleware
9
9
  *
10
- * Shared session/API key auth for protected work app routes (Slack, GitHub, etc.).
10
+ * Shared session/bearer token auth for protected work app routes (Slack, GitHub, etc.).
11
11
  * Most work app routes are unauthenticated (events, commands, webhooks),
12
12
  * but workspace management and user endpoints require session auth.
13
13
  *
14
14
  * Auth flow:
15
15
  * 1. Test environment → bypass
16
16
  * 2. Dev localhost → bypass with dev-user context
17
- * 3. Bearer token → manageApiKeyAuth
17
+ * 3. Bearer token → manageBearerAuth (bypass secret, session, Slack JWT, internal service)
18
18
  * 4. Session cookie → sessionAuth
19
19
  */
20
20
  const isTestEnvironment = () => env.ENVIRONMENT === "test";
@@ -45,7 +45,7 @@ const workAppsAuth = async (c, next) => {
45
45
  }
46
46
  } catch {}
47
47
  }
48
- if (c.req.header("Authorization")?.startsWith("Bearer ")) return manageApiKeyAuth()(c, next);
48
+ if (c.req.header("Authorization")?.startsWith("Bearer ")) return manageBearerAuth()(c, next);
49
49
  await sessionAuth()(c, async () => {
50
50
  const session = c.get("session");
51
51
  if (!session?.activeOrganizationId) throw createApiError({
@@ -1,4 +1,4 @@
1
- import { manageApiKeyOrSessionAuth } from "../middleware/manageAuth.js";
1
+ import { manageBearerOrSessionAuth } from "../middleware/manageAuth.js";
2
2
  import "../middleware/index.js";
3
3
  import { OpenAPIHono, z } from "@hono/zod-openapi";
4
4
  import { createProtectedRoute } from "@inkeep/agents-core/middleware";
@@ -16,7 +16,7 @@ capabilitiesHandler.openapi(createProtectedRoute({
16
16
  operationId: "capabilities",
17
17
  summary: "Get server capabilities",
18
18
  description: "Get information about optional server-side capabilities and configuration.",
19
- permission: manageApiKeyOrSessionAuth(),
19
+ permission: manageBearerOrSessionAuth(),
20
20
  responses: { 200: {
21
21
  description: "Server capabilities",
22
22
  content: { "application/json": { schema: CapabilitiesResponseSchema } }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inkeep/agents-api",
3
- "version": "0.0.0-dev-20260302211942",
3
+ "version": "0.0.0-dev-20260302234522",
4
4
  "description": "Unified Inkeep Agents API - combines management, runtime, and evaluation capabilities",
5
5
  "types": "dist/index.d.ts",
6
6
  "exports": {
@@ -70,9 +70,9 @@
70
70
  "openid-client": "^6.8.1",
71
71
  "pg": "^8.16.3",
72
72
  "workflow": "^4.1.0-beta.54",
73
- "@inkeep/agents-core": "^0.0.0-dev-20260302211942",
74
- "@inkeep/agents-mcp": "^0.0.0-dev-20260302211942",
75
- "@inkeep/agents-work-apps": "^0.0.0-dev-20260302211942"
73
+ "@inkeep/agents-core": "^0.0.0-dev-20260302234522",
74
+ "@inkeep/agents-mcp": "^0.0.0-dev-20260302234522",
75
+ "@inkeep/agents-work-apps": "^0.0.0-dev-20260302234522"
76
76
  },
77
77
  "peerDependencies": {
78
78
  "@hono/zod-openapi": "^1.1.5",