@inkeep/agents-api 0.0.0-dev-20260212083055 → 0.0.0-dev-20260212085218

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 (39) hide show
  1. package/dist/.well-known/workflow/v1/manifest.debug.json +19 -19
  2. package/dist/.well-known/workflow/v1/step.cjs +390 -220
  3. package/dist/createApp.d.ts +2 -2
  4. package/dist/createApp.js +12 -1
  5. package/dist/domains/evals/routes/datasetTriggers.d.ts +2 -2
  6. package/dist/domains/evals/services/EvaluationService.d.ts +0 -5
  7. package/dist/domains/evals/services/EvaluationService.js +2 -51
  8. package/dist/domains/evals/workflow/routes.d.ts +2 -2
  9. package/dist/domains/manage/routes/availableAgents.d.ts +2 -2
  10. package/dist/domains/manage/routes/conversations.d.ts +2 -2
  11. package/dist/domains/manage/routes/index.d.ts +2 -2
  12. package/dist/domains/manage/routes/invitations.d.ts +2 -2
  13. package/dist/domains/manage/routes/mcp.d.ts +2 -2
  14. package/dist/domains/manage/routes/signoz.d.ts +2 -2
  15. package/dist/domains/mcp/routes/mcp.d.ts +2 -2
  16. package/dist/domains/work-apps/index.d.ts +13 -0
  17. package/dist/domains/work-apps/index.js +23 -0
  18. package/dist/env.d.ts +2 -2
  19. package/dist/factory.d.ts +21 -21
  20. package/dist/index.d.ts +20 -20
  21. package/dist/middleware/cors.d.ts +6 -1
  22. package/dist/middleware/cors.js +27 -1
  23. package/dist/middleware/evalsAuth.d.ts +2 -2
  24. package/dist/middleware/index.d.ts +3 -2
  25. package/dist/middleware/index.js +3 -2
  26. package/dist/middleware/manageAuth.d.ts +2 -2
  27. package/dist/middleware/manageAuth.js +16 -1
  28. package/dist/middleware/projectAccess.d.ts +2 -2
  29. package/dist/middleware/requirePermission.d.ts +2 -2
  30. package/dist/middleware/runAuth.d.ts +4 -4
  31. package/dist/middleware/runAuth.js +71 -1
  32. package/dist/middleware/sessionAuth.d.ts +3 -3
  33. package/dist/middleware/tenantAccess.d.ts +2 -2
  34. package/dist/middleware/tracing.d.ts +3 -3
  35. package/dist/middleware/workAppsAuth.d.ts +7 -0
  36. package/dist/middleware/workAppsAuth.js +52 -0
  37. package/dist/openapi.d.ts +5 -0
  38. package/dist/openapi.js +6 -1
  39. package/package.json +5 -5
@@ -1,5 +1,5 @@
1
1
  import { BaseExecutionContext } from "@inkeep/agents-core";
2
- import * as hono7 from "hono";
2
+ import * as hono1 from "hono";
3
3
  import { createAuth } from "@inkeep/agents-core/auth";
4
4
 
5
5
  //#region src/middleware/manageAuth.d.ts
@@ -12,7 +12,7 @@ import { createAuth } from "@inkeep/agents-core/auth";
12
12
  * 3. Database API key
13
13
  * 4. Internal service token
14
14
  */
15
- declare const manageApiKeyAuth: () => hono7.MiddlewareHandler<{
15
+ declare const manageApiKeyAuth: () => hono1.MiddlewareHandler<{
16
16
  Variables: {
17
17
  executionContext: BaseExecutionContext;
18
18
  userId?: string;
@@ -1,6 +1,6 @@
1
1
  import { env } from "../env.js";
2
2
  import runDbClient_default from "../data/db/runDbClient.js";
3
- import { getLogger, isInternalServiceToken, validateAndGetApiKey, verifyInternalServiceAuthHeader } from "@inkeep/agents-core";
3
+ import { getLogger, isInternalServiceToken, isSlackUserToken, validateAndGetApiKey, verifyInternalServiceAuthHeader, verifySlackUserToken } from "@inkeep/agents-core";
4
4
  import { createMiddleware } from "hono/factory";
5
5
  import { HTTPException } from "hono/http-exception";
6
6
 
@@ -58,6 +58,21 @@ const manageApiKeyAuth = () => createMiddleware(async (c, next) => {
58
58
  await next();
59
59
  return;
60
60
  }
61
+ if (isSlackUserToken(token)) {
62
+ const result = await verifySlackUserToken(token);
63
+ if (!result.valid || !result.payload) throw new HTTPException(401, { message: result.error || "Invalid Slack user token" });
64
+ logger.info({
65
+ inkeepUserId: result.payload.sub,
66
+ tenantId: result.payload.tenantId,
67
+ slackTeamId: result.payload.slack.teamId,
68
+ slackUserId: result.payload.slack.userId
69
+ }, "Slack user JWT authenticated successfully");
70
+ c.set("userId", result.payload.sub);
71
+ if (result.payload.slack.email) c.set("userEmail", result.payload.slack.email);
72
+ c.set("tenantId", result.payload.tenantId);
73
+ await next();
74
+ return;
75
+ }
61
76
  if (isInternalServiceToken(token)) {
62
77
  const result = await verifyInternalServiceAuthHeader(authHeader);
63
78
  if (!result.valid || !result.payload) throw new HTTPException(401, { message: result.error || "Invalid internal service token" });
@@ -1,6 +1,6 @@
1
1
  import { ManageAppVariables } from "../types/app.js";
2
2
  import { ProjectPermissionLevel } from "@inkeep/agents-core";
3
- import * as hono3 from "hono";
3
+ import * as hono0 from "hono";
4
4
 
5
5
  //#region src/middleware/projectAccess.d.ts
6
6
  /**
@@ -10,6 +10,6 @@ declare const requireProjectPermission: <Env$1 extends {
10
10
  Variables: ManageAppVariables;
11
11
  } = {
12
12
  Variables: ManageAppVariables;
13
- }>(permission?: ProjectPermissionLevel) => hono3.MiddlewareHandler<Env$1, string, {}, Response>;
13
+ }>(permission?: ProjectPermissionLevel) => hono0.MiddlewareHandler<Env$1, string, {}, Response>;
14
14
  //#endregion
15
15
  export { requireProjectPermission };
@@ -1,5 +1,5 @@
1
1
  import { ManageAppVariables } from "../types/app.js";
2
- import * as hono1 from "hono";
2
+ import * as hono6 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) => hono1.MiddlewareHandler<Env$1, string, {}, Response>;
12
+ }>(permissions: Permission) => hono6.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 hono11 from "hono";
2
+ import * as hono8 from "hono";
3
3
 
4
4
  //#region src/middleware/runAuth.d.ts
5
- declare const runApiKeyAuth: () => hono11.MiddlewareHandler<{
5
+ declare const runApiKeyAuth: () => hono8.MiddlewareHandler<{
6
6
  Variables: {
7
7
  executionContext: BaseExecutionContext;
8
8
  };
@@ -11,7 +11,7 @@ declare const runApiKeyAuth: () => hono11.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) => hono11.MiddlewareHandler<{
14
+ declare const runApiKeyAuthExcept: (skipRouteCheck: (path: string) => boolean) => hono8.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: () => hono11.MiddlewareHandler<{
23
+ declare const runOptionalAuth: () => hono8.MiddlewareHandler<{
24
24
  Variables: {
25
25
  executionContext?: BaseExecutionContext;
26
26
  };
@@ -2,7 +2,7 @@ import { getLogger as getLogger$1 } from "../logger.js";
2
2
  import { env } from "../env.js";
3
3
  import runDbClient_default from "../data/db/runDbClient.js";
4
4
  import { createBaseExecutionContext } from "../types/runExecutionContext.js";
5
- import { canUseProjectStrict, validateAndGetApiKey, validateTargetAgent, verifyServiceToken, verifyTempToken } from "@inkeep/agents-core";
5
+ import { canUseProjectStrict, isSlackUserToken, validateAndGetApiKey, validateTargetAgent, verifyServiceToken, verifySlackUserToken, verifyTempToken } from "@inkeep/agents-core";
6
6
  import { createMiddleware } from "hono/factory";
7
7
  import { HTTPException } from "hono/http-exception";
8
8
 
@@ -125,6 +125,73 @@ async function tryApiKeyAuth(apiKey) {
125
125
  };
126
126
  }
127
127
  /**
128
+ * Authenticate using a Slack user JWT token (for Slack work app delegation)
129
+ */
130
+ async function trySlackUserJwtAuth(token, reqData) {
131
+ if (!isSlackUserToken(token)) return { authResult: null };
132
+ const result = await verifySlackUserToken(token);
133
+ if (!result.valid || !result.payload) {
134
+ logger.warn({ error: result.error }, "Invalid Slack user JWT token");
135
+ return {
136
+ authResult: null,
137
+ failureMessage: `Invalid Slack user token: ${result.error || "Invalid token"}`
138
+ };
139
+ }
140
+ const payload = result.payload;
141
+ if (!reqData.projectId || !reqData.agentId) {
142
+ logger.warn({
143
+ hasProjectId: !!reqData.projectId,
144
+ hasAgentId: !!reqData.agentId
145
+ }, "Slack user JWT requires x-inkeep-project-id and x-inkeep-agent-id headers");
146
+ return {
147
+ authResult: null,
148
+ failureMessage: "Slack user token requires x-inkeep-project-id and x-inkeep-agent-id headers"
149
+ };
150
+ }
151
+ try {
152
+ if (!await canUseProjectStrict({
153
+ userId: payload.sub,
154
+ projectId: reqData.projectId
155
+ })) {
156
+ logger.warn({
157
+ userId: payload.sub,
158
+ tenantId: payload.tenantId,
159
+ projectId: reqData.projectId
160
+ }, "Slack user JWT: user does not have access to requested project");
161
+ return {
162
+ authResult: null,
163
+ failureMessage: "Access denied: insufficient permissions for the requested project"
164
+ };
165
+ }
166
+ } catch (error) {
167
+ logger.error({
168
+ error,
169
+ userId: payload.sub,
170
+ projectId: reqData.projectId
171
+ }, "SpiceDB permission check failed for Slack JWT");
172
+ throw new HTTPException(503, { message: "Authorization service temporarily unavailable" });
173
+ }
174
+ logger.info({
175
+ inkeepUserId: payload.sub,
176
+ tenantId: payload.tenantId,
177
+ slackTeamId: payload.slack.teamId,
178
+ slackUserId: payload.slack.userId,
179
+ projectId: reqData.projectId,
180
+ agentId: reqData.agentId
181
+ }, "Slack user JWT token authenticated successfully");
182
+ return { authResult: {
183
+ apiKey: "slack-user-jwt",
184
+ tenantId: payload.tenantId,
185
+ projectId: reqData.projectId,
186
+ agentId: reqData.agentId,
187
+ apiKeyId: "slack-user-token",
188
+ metadata: { initiatedBy: {
189
+ type: "user",
190
+ id: payload.sub
191
+ } }
192
+ } };
193
+ }
194
+ /**
128
195
  * Authenticate using a team agent JWT token (for intra-tenant delegation)
129
196
  */
130
197
  async function tryTeamAgentAuth(token, expectedSubAgentId) {
@@ -210,6 +277,9 @@ async function authenticateRequest(reqData) {
210
277
  if (jwtResult) return { authResult: jwtResult };
211
278
  const bypassResult = tryBypassAuth(apiKey, reqData);
212
279
  if (bypassResult) return { authResult: bypassResult };
280
+ const slackAttempt = await trySlackUserJwtAuth(apiKey, reqData);
281
+ if (slackAttempt.authResult) return { authResult: slackAttempt.authResult };
282
+ if (slackAttempt.failureMessage) return slackAttempt;
213
283
  const apiKeyResult = await tryApiKeyAuth(apiKey);
214
284
  if (apiKeyResult) return { authResult: apiKeyResult };
215
285
  const teamAttempt = await tryTeamAgentAuth(apiKey, subAgentId);
@@ -1,4 +1,4 @@
1
- import * as hono14 from "hono";
1
+ import * as hono2 from "hono";
2
2
 
3
3
  //#region src/middleware/sessionAuth.d.ts
4
4
 
@@ -7,11 +7,11 @@ import * as hono14 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: () => hono14.MiddlewareHandler<any, string, {}, Response>;
10
+ declare const sessionAuth: () => hono2.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: () => hono14.MiddlewareHandler<any, string, {}, Response>;
15
+ declare const sessionContext: () => hono2.MiddlewareHandler<any, string, {}, Response>;
16
16
  //#endregion
17
17
  export { sessionAuth, sessionContext };
@@ -1,4 +1,4 @@
1
- import * as hono10 from "hono";
1
+ import * as hono7 from "hono";
2
2
 
3
3
  //#region src/middleware/tenantAccess.d.ts
4
4
 
@@ -11,7 +11,7 @@ import * as hono10 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: () => hono10.MiddlewareHandler<{
14
+ declare const requireTenantAccess: () => hono7.MiddlewareHandler<{
15
15
  Variables: {
16
16
  userId: string;
17
17
  tenantId: string;
@@ -1,7 +1,7 @@
1
- import * as hono8 from "hono";
1
+ import * as hono11 from "hono";
2
2
 
3
3
  //#region src/middleware/tracing.d.ts
4
- declare const otelBaggageMiddleware: () => hono8.MiddlewareHandler<any, string, {}, Response>;
5
- declare const executionBaggageMiddleware: () => hono8.MiddlewareHandler<any, string, {}, Response>;
4
+ declare const otelBaggageMiddleware: () => hono11.MiddlewareHandler<any, string, {}, Response>;
5
+ declare const executionBaggageMiddleware: () => hono11.MiddlewareHandler<any, string, {}, Response>;
6
6
  //#endregion
7
7
  export { executionBaggageMiddleware, otelBaggageMiddleware };
@@ -0,0 +1,7 @@
1
+ import { Context, Next } from "hono";
2
+
3
+ //#region src/middleware/workAppsAuth.d.ts
4
+
5
+ declare const workAppsAuth: (c: Context, next: Next) => Promise<void | Response>;
6
+ //#endregion
7
+ export { workAppsAuth };
@@ -0,0 +1,52 @@
1
+ import { env } from "../env.js";
2
+ import { sessionAuth } from "./sessionAuth.js";
3
+ import { manageApiKeyAuth } from "./manageAuth.js";
4
+ import { createApiError } from "@inkeep/agents-core";
5
+
6
+ //#region src/middleware/workAppsAuth.ts
7
+ /**
8
+ * Work Apps Authentication Middleware
9
+ *
10
+ * Shared session/API key auth for protected work app routes (Slack, GitHub, etc.).
11
+ * Most work app routes are unauthenticated (events, commands, webhooks),
12
+ * but workspace management and user endpoints require session auth.
13
+ *
14
+ * Auth flow:
15
+ * 1. Test environment → bypass
16
+ * 2. Dev localhost → bypass with dev-user context
17
+ * 3. Bearer token → manageApiKeyAuth
18
+ * 4. Session cookie → sessionAuth
19
+ */
20
+ const isTestEnvironment = () => env.ENVIRONMENT === "test";
21
+ const workAppsAuth = async (c, next) => {
22
+ if (isTestEnvironment()) {
23
+ await next();
24
+ return;
25
+ }
26
+ if (env.ENVIRONMENT === "development") {
27
+ const origin = c.req.header("Origin");
28
+ if (origin) try {
29
+ const originUrl = new URL(origin);
30
+ if (originUrl.hostname === "localhost" || originUrl.hostname === "127.0.0.1") {
31
+ c.set("userId", "dev-user");
32
+ c.set("tenantId", "default");
33
+ c.set("tenantRole", "owner");
34
+ await next();
35
+ return;
36
+ }
37
+ } catch {}
38
+ }
39
+ if (c.req.header("Authorization")?.startsWith("Bearer ")) return manageApiKeyAuth()(c, next);
40
+ await sessionAuth()(c, async () => {
41
+ const session = c.get("session");
42
+ if (!session?.activeOrganizationId) throw createApiError({
43
+ code: "forbidden",
44
+ message: "No active organization selected. Please select an organization first."
45
+ });
46
+ c.set("tenantId", session.activeOrganizationId);
47
+ await next();
48
+ });
49
+ };
50
+
51
+ //#endregion
52
+ export { workAppsAuth };
package/dist/openapi.d.ts CHANGED
@@ -8,6 +8,7 @@ declare const TagToDescription: {
8
8
  Agents: string;
9
9
  'Artifact Components': string;
10
10
  Branches: string;
11
+ Channels: string;
11
12
  CLI: string;
12
13
  Chat: string;
13
14
  'Context Configs': string;
@@ -28,13 +29,17 @@ declare const TagToDescription: {
28
29
  Projects: string;
29
30
  Refs: string;
30
31
  Skills: string;
32
+ Slack: string;
31
33
  SubAgents: string;
32
34
  'Third-Party MCP Servers': string;
33
35
  Tools: string;
34
36
  Triggers: string;
35
37
  'User Project Memberships': string;
38
+ Users: string;
36
39
  Webhooks: string;
40
+ 'Work Apps': string;
37
41
  Workflows: string;
42
+ Workspaces: string;
38
43
  };
39
44
  declare function setupOpenAPIRoutes<E extends Env = Env>(app: OpenAPIHono<E>): void;
40
45
  //#endregion
package/dist/openapi.js CHANGED
@@ -7,6 +7,7 @@ const TagToDescription = {
7
7
  Agents: "Operations for managing agents",
8
8
  "Artifact Components": "Operations for managing artifact components",
9
9
  Branches: "Operations for managing branches",
10
+ Channels: "Operations for managing Slack channels",
10
11
  CLI: "CLI authentication endpoints",
11
12
  Chat: "Chat completions endpoints",
12
13
  "Context Configs": "Operations for managing context configurations",
@@ -27,13 +28,17 @@ const TagToDescription = {
27
28
  Projects: "Operations for managing projects",
28
29
  Refs: "Operations for the resolved ref (branch name, tag name, or commit hash)",
29
30
  Skills: "Reusable instruction blocks that can be attached to multiple sub-agents and ordered for priority",
31
+ Slack: "Slack App integration endpoints",
30
32
  SubAgents: "Operations for managing sub agents",
31
33
  "Third-Party MCP Servers": "Operations for managing third-party MCP servers",
32
34
  Tools: "Operations for managing MCP tools",
33
35
  Triggers: "Operations for managing triggers",
34
36
  "User Project Memberships": "Operations for managing user project memberships",
37
+ Users: "Operations for managing users",
35
38
  Webhooks: "Webhook endpoints",
36
- Workflows: "Workflow trigger endpoints"
39
+ "Work Apps": "Work app integrations (Slack, Teams, etc.)",
40
+ Workflows: "Workflow trigger endpoints",
41
+ Workspaces: "Operations for managing Slack workspaces"
37
42
  };
38
43
  function setupOpenAPIRoutes(app) {
39
44
  app.get("/openapi.json", (c) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inkeep/agents-api",
3
- "version": "0.0.0-dev-20260212083055",
3
+ "version": "0.0.0-dev-20260212085218",
4
4
  "description": "Unified Inkeep Agents API - combines management, runtime, and evaluation capabilities",
5
5
  "types": "dist/index.d.ts",
6
6
  "exports": {
@@ -66,10 +66,10 @@
66
66
  "openid-client": "^6.8.1",
67
67
  "pg": "^8.16.3",
68
68
  "workflow": "4.0.1-beta.33",
69
- "@inkeep/agents-core": "^0.0.0-dev-20260212083055",
70
- "@inkeep/agents-manage-mcp": "^0.0.0-dev-20260212083055",
71
- "@inkeep/agents-mcp": "^0.0.0-dev-20260212083055",
72
- "@inkeep/agents-work-apps": "^0.0.0-dev-20260212083055"
69
+ "@inkeep/agents-core": "^0.0.0-dev-20260212085218",
70
+ "@inkeep/agents-manage-mcp": "^0.0.0-dev-20260212085218",
71
+ "@inkeep/agents-mcp": "^0.0.0-dev-20260212085218",
72
+ "@inkeep/agents-work-apps": "^0.0.0-dev-20260212085218"
73
73
  },
74
74
  "peerDependencies": {
75
75
  "@hono/zod-openapi": "^1.1.5",