@inkeep/agents-api 0.0.0-dev-20260129102805 → 0.0.0-dev-20260129143016
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/manifest.debug.json +14 -14
- package/dist/.well-known/workflow/v1/step.cjs +0 -1
- package/dist/createApp.d.ts +2 -2
- package/dist/createApp.js +8 -6
- package/dist/data/db/runDbClient.d.ts +2 -2
- package/dist/domains/evals/routes/datasetTriggers.d.ts +2 -2
- package/dist/domains/evals/routes/index.d.ts +2 -2
- package/dist/domains/github/index.d.ts +3 -3
- package/dist/domains/manage/routes/conversations.d.ts +2 -2
- package/dist/domains/manage/routes/evals/evaluationResults.d.ts +2 -2
- package/dist/domains/manage/routes/index.d.ts +2 -2
- package/dist/domains/manage/routes/mcp.d.ts +2 -2
- package/dist/domains/manage/routes/projectMembers.js +1 -14
- package/dist/domains/manage/routes/projectPermissions.js +2 -9
- package/dist/domains/manage/routes/projects.js +14 -16
- package/dist/domains/manage/routes/signoz.d.ts +2 -2
- package/dist/domains/manage/routes/signoz.js +1 -1
- package/dist/domains/manage/routes/userProjectMemberships.js +1 -2
- package/dist/domains/run/context/validation.d.ts +1 -1
- package/dist/domains/run/services/TriggerService.d.ts +1 -1
- package/dist/domains/run/utils/token-estimator.d.ts +2 -2
- package/dist/env.d.ts +0 -2
- package/dist/env.js +0 -1
- package/dist/factory.d.ts +29 -29
- package/dist/factory.js +4 -10
- package/dist/index.d.ts +30 -29
- package/dist/index.js +3 -5
- package/dist/middleware/branchScopedDb.d.ts +1 -1
- package/dist/middleware/evalsAuth.d.ts +2 -2
- package/dist/middleware/manageAuth.d.ts +2 -2
- package/dist/middleware/projectAccess.d.ts +2 -11
- package/dist/middleware/projectAccess.js +7 -33
- package/dist/middleware/projectConfig.d.ts +3 -3
- package/dist/middleware/ref.d.ts +1 -1
- package/dist/middleware/requirePermission.d.ts +2 -2
- package/dist/middleware/requirePermission.js +1 -2
- package/dist/middleware/runAuth.d.ts +4 -4
- package/dist/middleware/sessionAuth.d.ts +3 -3
- package/dist/middleware/sessionAuth.js +1 -2
- package/dist/middleware/tenantAccess.d.ts +2 -2
- package/dist/middleware/tracing.d.ts +3 -3
- package/package.json +4 -4
- package/dist/initialization.d.ts +0 -6
- package/dist/initialization.js +0 -72
package/dist/factory.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { env } from "./env.js";
|
|
2
2
|
import runDbClient_default from "./data/db/runDbClient.js";
|
|
3
3
|
import { createAgentsHono } from "./createApp.js";
|
|
4
|
-
import { initializeDefaultUser } from "./initialization.js";
|
|
5
4
|
import { createAuth0Provider, createOIDCProvider } from "./ssoHelpers.js";
|
|
6
5
|
import { CredentialStoreRegistry, createDefaultCredentialStores } from "@inkeep/agents-core";
|
|
7
6
|
import { createAuth } from "@inkeep/agents-core/auth";
|
|
@@ -16,7 +15,6 @@ const defaultConfig = {
|
|
|
16
15
|
}
|
|
17
16
|
};
|
|
18
17
|
function createAgentsAuth(userAuthConfig) {
|
|
19
|
-
if (env.DISABLE_AUTH) return null;
|
|
20
18
|
return createAuth({
|
|
21
19
|
baseURL: env.INKEEP_AGENTS_API_URL || `http://localhost:3002`,
|
|
22
20
|
secret: env.BETTER_AUTH_SECRET || "development-secret-change-in-production",
|
|
@@ -26,17 +24,13 @@ function createAgentsAuth(userAuthConfig) {
|
|
|
26
24
|
});
|
|
27
25
|
}
|
|
28
26
|
function createAgentsApp(config) {
|
|
29
|
-
const serverConfig = config?.serverConfig ?? defaultConfig;
|
|
30
|
-
const registry = new CredentialStoreRegistry(config?.credentialStores ?? createDefaultCredentialStores());
|
|
31
|
-
const auth$1 = createAgentsAuth(config?.auth);
|
|
32
|
-
if (!config?.skipInitialization && env.ENVIRONMENT !== "test") initializeDefaultUser(auth$1);
|
|
33
27
|
return createAgentsHono({
|
|
34
|
-
serverConfig,
|
|
35
|
-
credentialStores:
|
|
36
|
-
auth: auth
|
|
28
|
+
serverConfig: config?.serverConfig ?? defaultConfig,
|
|
29
|
+
credentialStores: new CredentialStoreRegistry(config?.credentialStores ?? createDefaultCredentialStores()),
|
|
30
|
+
auth: createAgentsAuth(config?.auth),
|
|
37
31
|
sandboxConfig: config?.sandboxConfig
|
|
38
32
|
});
|
|
39
33
|
}
|
|
40
34
|
|
|
41
35
|
//#endregion
|
|
42
|
-
export { createAgentsApp, createAgentsAuth, createAgentsHono, createAuth0Provider, createOIDCProvider
|
|
36
|
+
export { createAgentsApp, createAgentsAuth, createAgentsHono, createAuth0Provider, createOIDCProvider };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,12 +3,11 @@ import "./types/index.js";
|
|
|
3
3
|
import { createAgentsHono } from "./createApp.js";
|
|
4
4
|
import { NativeSandboxConfig, SandboxConfig, VercelSandboxConfig } from "./domains/run/types/executionContext.js";
|
|
5
5
|
import "./env.js";
|
|
6
|
-
import { initializeDefaultUser } from "./initialization.js";
|
|
7
6
|
import { createAuth0Provider, createOIDCProvider } from "./ssoHelpers.js";
|
|
8
7
|
import { SSOProviderConfig, UserAuthConfig, createAgentsApp } from "./factory.js";
|
|
9
8
|
import { Hono } from "hono";
|
|
10
9
|
import * as zod205 from "zod";
|
|
11
|
-
import * as
|
|
10
|
+
import * as hono_types1 from "hono/types";
|
|
12
11
|
import * as better_auth78 from "better-auth";
|
|
13
12
|
import * as better_auth_plugins69 from "better-auth/plugins";
|
|
14
13
|
import * as _better_auth_sso10 from "@better-auth/sso";
|
|
@@ -123,11 +122,11 @@ declare const auth: better_auth78.Auth<{
|
|
|
123
122
|
useSecureCookies?: boolean | undefined;
|
|
124
123
|
disableCSRFCheck?: boolean | undefined;
|
|
125
124
|
disableOriginCheck?: boolean | undefined;
|
|
126
|
-
crossSubDomainCookies
|
|
125
|
+
crossSubDomainCookies?: {
|
|
127
126
|
enabled: boolean;
|
|
128
127
|
additionalCookies?: string[];
|
|
129
128
|
domain?: string;
|
|
130
|
-
};
|
|
129
|
+
} | undefined;
|
|
131
130
|
cookies?: {
|
|
132
131
|
[key: string]: {
|
|
133
132
|
name?: string;
|
|
@@ -796,27 +795,28 @@ declare const auth: better_auth78.Auth<{
|
|
|
796
795
|
ac: better_auth_plugins69.AccessControl;
|
|
797
796
|
roles: {
|
|
798
797
|
member: {
|
|
799
|
-
authorize<K_1 extends "
|
|
800
|
-
actions: better_auth_plugins69.Subset<"
|
|
798
|
+
authorize<K_1 extends "project" | "organization" | "member" | "invitation" | "ac" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins69.Subset<"project" | "organization" | "member" | "invitation" | "ac" | "team", better_auth_plugins69.Statements>[key] | {
|
|
799
|
+
actions: better_auth_plugins69.Subset<"project" | "organization" | "member" | "invitation" | "ac" | "team", better_auth_plugins69.Statements>[key];
|
|
801
800
|
connector: "OR" | "AND";
|
|
802
801
|
} | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins69.AuthorizeResponse;
|
|
803
|
-
statements: better_auth_plugins69.Subset<"
|
|
802
|
+
statements: better_auth_plugins69.Subset<"project" | "organization" | "member" | "invitation" | "ac" | "team", better_auth_plugins69.Statements>;
|
|
804
803
|
};
|
|
805
804
|
admin: {
|
|
806
|
-
authorize<K_1 extends "
|
|
807
|
-
actions: better_auth_plugins69.Subset<"
|
|
805
|
+
authorize<K_1 extends "project" | "organization" | "member" | "invitation" | "ac" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins69.Subset<"project" | "organization" | "member" | "invitation" | "ac" | "team", better_auth_plugins69.Statements>[key] | {
|
|
806
|
+
actions: better_auth_plugins69.Subset<"project" | "organization" | "member" | "invitation" | "ac" | "team", better_auth_plugins69.Statements>[key];
|
|
808
807
|
connector: "OR" | "AND";
|
|
809
808
|
} | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins69.AuthorizeResponse;
|
|
810
|
-
statements: better_auth_plugins69.Subset<"
|
|
809
|
+
statements: better_auth_plugins69.Subset<"project" | "organization" | "member" | "invitation" | "ac" | "team", better_auth_plugins69.Statements>;
|
|
811
810
|
};
|
|
812
811
|
owner: {
|
|
813
|
-
authorize<K_1 extends "
|
|
814
|
-
actions: better_auth_plugins69.Subset<"
|
|
812
|
+
authorize<K_1 extends "project" | "organization" | "member" | "invitation" | "ac" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins69.Subset<"project" | "organization" | "member" | "invitation" | "ac" | "team", better_auth_plugins69.Statements>[key] | {
|
|
813
|
+
actions: better_auth_plugins69.Subset<"project" | "organization" | "member" | "invitation" | "ac" | "team", better_auth_plugins69.Statements>[key];
|
|
815
814
|
connector: "OR" | "AND";
|
|
816
815
|
} | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins69.AuthorizeResponse;
|
|
817
|
-
statements: better_auth_plugins69.Subset<"
|
|
816
|
+
statements: better_auth_plugins69.Subset<"project" | "organization" | "member" | "invitation" | "ac" | "team", better_auth_plugins69.Statements>;
|
|
818
817
|
};
|
|
819
818
|
};
|
|
819
|
+
creatorRole: "admin";
|
|
820
820
|
membershipLimit: number;
|
|
821
821
|
invitationLimit: number;
|
|
822
822
|
invitationExpiresIn: number;
|
|
@@ -988,7 +988,7 @@ declare const auth: better_auth78.Auth<{
|
|
|
988
988
|
id: string;
|
|
989
989
|
organizationId: string;
|
|
990
990
|
email: string;
|
|
991
|
-
role: "
|
|
991
|
+
role: "owner" | "admin" | "member";
|
|
992
992
|
status: better_auth_plugins69.InvitationStatus;
|
|
993
993
|
inviterId: string;
|
|
994
994
|
expiresAt: Date;
|
|
@@ -997,7 +997,7 @@ declare const auth: better_auth78.Auth<{
|
|
|
997
997
|
Member: {
|
|
998
998
|
id: string;
|
|
999
999
|
organizationId: string;
|
|
1000
|
-
role: "
|
|
1000
|
+
role: "owner" | "admin" | "member";
|
|
1001
1001
|
createdAt: Date;
|
|
1002
1002
|
userId: string;
|
|
1003
1003
|
user: {
|
|
@@ -1013,7 +1013,7 @@ declare const auth: better_auth78.Auth<{
|
|
|
1013
1013
|
members: {
|
|
1014
1014
|
id: string;
|
|
1015
1015
|
organizationId: string;
|
|
1016
|
-
role: "
|
|
1016
|
+
role: "owner" | "admin" | "member";
|
|
1017
1017
|
createdAt: Date;
|
|
1018
1018
|
userId: string;
|
|
1019
1019
|
user: {
|
|
@@ -1027,7 +1027,7 @@ declare const auth: better_auth78.Auth<{
|
|
|
1027
1027
|
id: string;
|
|
1028
1028
|
organizationId: string;
|
|
1029
1029
|
email: string;
|
|
1030
|
-
role: "
|
|
1030
|
+
role: "owner" | "admin" | "member";
|
|
1031
1031
|
status: better_auth_plugins69.InvitationStatus;
|
|
1032
1032
|
inviterId: string;
|
|
1033
1033
|
expiresAt: Date;
|
|
@@ -1105,27 +1105,28 @@ declare const auth: better_auth78.Auth<{
|
|
|
1105
1105
|
ac: better_auth_plugins69.AccessControl;
|
|
1106
1106
|
roles: {
|
|
1107
1107
|
member: {
|
|
1108
|
-
authorize<K_1 extends "
|
|
1109
|
-
actions: better_auth_plugins69.Subset<"
|
|
1108
|
+
authorize<K_1 extends "project" | "organization" | "member" | "invitation" | "ac" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins69.Subset<"project" | "organization" | "member" | "invitation" | "ac" | "team", better_auth_plugins69.Statements>[key] | {
|
|
1109
|
+
actions: better_auth_plugins69.Subset<"project" | "organization" | "member" | "invitation" | "ac" | "team", better_auth_plugins69.Statements>[key];
|
|
1110
1110
|
connector: "OR" | "AND";
|
|
1111
1111
|
} | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins69.AuthorizeResponse;
|
|
1112
|
-
statements: better_auth_plugins69.Subset<"
|
|
1112
|
+
statements: better_auth_plugins69.Subset<"project" | "organization" | "member" | "invitation" | "ac" | "team", better_auth_plugins69.Statements>;
|
|
1113
1113
|
};
|
|
1114
1114
|
admin: {
|
|
1115
|
-
authorize<K_1 extends "
|
|
1116
|
-
actions: better_auth_plugins69.Subset<"
|
|
1115
|
+
authorize<K_1 extends "project" | "organization" | "member" | "invitation" | "ac" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins69.Subset<"project" | "organization" | "member" | "invitation" | "ac" | "team", better_auth_plugins69.Statements>[key] | {
|
|
1116
|
+
actions: better_auth_plugins69.Subset<"project" | "organization" | "member" | "invitation" | "ac" | "team", better_auth_plugins69.Statements>[key];
|
|
1117
1117
|
connector: "OR" | "AND";
|
|
1118
1118
|
} | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins69.AuthorizeResponse;
|
|
1119
|
-
statements: better_auth_plugins69.Subset<"
|
|
1119
|
+
statements: better_auth_plugins69.Subset<"project" | "organization" | "member" | "invitation" | "ac" | "team", better_auth_plugins69.Statements>;
|
|
1120
1120
|
};
|
|
1121
1121
|
owner: {
|
|
1122
|
-
authorize<K_1 extends "
|
|
1123
|
-
actions: better_auth_plugins69.Subset<"
|
|
1122
|
+
authorize<K_1 extends "project" | "organization" | "member" | "invitation" | "ac" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins69.Subset<"project" | "organization" | "member" | "invitation" | "ac" | "team", better_auth_plugins69.Statements>[key] | {
|
|
1123
|
+
actions: better_auth_plugins69.Subset<"project" | "organization" | "member" | "invitation" | "ac" | "team", better_auth_plugins69.Statements>[key];
|
|
1124
1124
|
connector: "OR" | "AND";
|
|
1125
1125
|
} | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins69.AuthorizeResponse;
|
|
1126
|
-
statements: better_auth_plugins69.Subset<"
|
|
1126
|
+
statements: better_auth_plugins69.Subset<"project" | "organization" | "member" | "invitation" | "ac" | "team", better_auth_plugins69.Statements>;
|
|
1127
1127
|
};
|
|
1128
1128
|
};
|
|
1129
|
+
creatorRole: "admin";
|
|
1129
1130
|
membershipLimit: number;
|
|
1130
1131
|
invitationLimit: number;
|
|
1131
1132
|
invitationExpiresIn: number;
|
|
@@ -1530,7 +1531,7 @@ declare const auth: better_auth78.Auth<{
|
|
|
1530
1531
|
verificationUri?: string | undefined;
|
|
1531
1532
|
}>;
|
|
1532
1533
|
}];
|
|
1533
|
-
}
|
|
1534
|
-
declare const app: Hono<
|
|
1534
|
+
}>;
|
|
1535
|
+
declare const app: Hono<hono_types1.BlankEnv, hono_types1.BlankSchema, "/">;
|
|
1535
1536
|
//#endregion
|
|
1536
|
-
export { type AppConfig, type AppVariables, Hono, type NativeSandboxConfig, type SSOProviderConfig, type SandboxConfig, type UserAuthConfig, type VercelSandboxConfig, auth, createAgentsApp, createAgentsHono, createAuth0Provider, createOIDCProvider, app as default
|
|
1537
|
+
export { type AppConfig, type AppVariables, Hono, type NativeSandboxConfig, type SSOProviderConfig, type SandboxConfig, type UserAuthConfig, type VercelSandboxConfig, auth, createAgentsApp, createAgentsHono, createAuth0Provider, createOIDCProvider, app as default };
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "./env.js";
|
|
2
2
|
import { defaultSDK } from "./instrumentation.js";
|
|
3
3
|
import { createAgentsHono } from "./createApp.js";
|
|
4
|
-
import { initializeDefaultUser } from "./initialization.js";
|
|
5
4
|
import { createAuth0Provider, createOIDCProvider } from "./ssoHelpers.js";
|
|
6
5
|
import { createAgentsApp, createAgentsAuth } from "./factory.js";
|
|
7
|
-
import { Hono } from "hono";
|
|
8
6
|
import { CredentialStoreRegistry, createDefaultCredentialStores } from "@inkeep/agents-core";
|
|
7
|
+
import { Hono } from "hono";
|
|
9
8
|
|
|
10
9
|
//#region src/index.ts
|
|
11
10
|
defaultSDK.start();
|
|
@@ -52,8 +51,7 @@ const app = createAgentsHono({
|
|
|
52
51
|
auth,
|
|
53
52
|
sandboxConfig
|
|
54
53
|
});
|
|
55
|
-
if (env.ENVIRONMENT === "development") initializeDefaultUser(auth);
|
|
56
54
|
var src_default = app;
|
|
57
55
|
|
|
58
56
|
//#endregion
|
|
59
|
-
export { Hono, auth, createAgentsApp, createAgentsHono, createAuth0Provider, createOIDCProvider, src_default as default
|
|
57
|
+
export { Hono, auth, createAgentsApp, createAgentsHono, createAuth0Provider, createOIDCProvider, src_default as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as hono2 from "hono";
|
|
2
1
|
import { BaseExecutionContext } from "@inkeep/agents-core";
|
|
2
|
+
import * as hono15 from "hono";
|
|
3
3
|
|
|
4
4
|
//#region src/middleware/evalsAuth.d.ts
|
|
5
5
|
|
|
@@ -7,7 +7,7 @@ import { BaseExecutionContext } from "@inkeep/agents-core";
|
|
|
7
7
|
* Middleware to authenticate API requests using Bearer token authentication
|
|
8
8
|
* First checks if token matches INKEEP_AGENTS_EVAL_API_BYPASS_SECRET,
|
|
9
9
|
*/
|
|
10
|
-
declare const evalApiKeyAuth: () =>
|
|
10
|
+
declare const evalApiKeyAuth: () => hono15.MiddlewareHandler<{
|
|
11
11
|
Variables: {
|
|
12
12
|
executionContext: BaseExecutionContext;
|
|
13
13
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as hono12 from "hono";
|
|
2
1
|
import { BaseExecutionContext } from "@inkeep/agents-core";
|
|
2
|
+
import * as hono0 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: () =>
|
|
15
|
+
declare const manageApiKeyAuth: () => hono0.MiddlewareHandler<{
|
|
16
16
|
Variables: {
|
|
17
17
|
executionContext: BaseExecutionContext;
|
|
18
18
|
userId?: string;
|
|
@@ -1,24 +1,15 @@
|
|
|
1
1
|
import { ManageAppVariables } from "../types/app.js";
|
|
2
|
-
import * as hono14 from "hono";
|
|
3
2
|
import { ProjectPermissionLevel } from "@inkeep/agents-core";
|
|
3
|
+
import * as hono1 from "hono";
|
|
4
4
|
|
|
5
5
|
//#region src/middleware/projectAccess.d.ts
|
|
6
|
-
|
|
7
6
|
/**
|
|
8
7
|
* Middleware to check project-level access.
|
|
9
|
-
*
|
|
10
|
-
* When ENABLE_AUTHZ is false:
|
|
11
|
-
* - 'view' permission: all org members can view
|
|
12
|
-
* - 'edit': only org owner/admin
|
|
13
|
-
*
|
|
14
|
-
* When ENABLE_AUTHZ is true:
|
|
15
|
-
* - Uses SpiceDB to check permissions
|
|
16
|
-
* - Org owner/admin bypass (handled in canViewProject etc.)
|
|
17
8
|
*/
|
|
18
9
|
declare const requireProjectPermission: <Env$1 extends {
|
|
19
10
|
Variables: ManageAppVariables;
|
|
20
11
|
} = {
|
|
21
12
|
Variables: ManageAppVariables;
|
|
22
|
-
}>(permission?: ProjectPermissionLevel) =>
|
|
13
|
+
}>(permission?: ProjectPermissionLevel) => hono1.MiddlewareHandler<Env$1, string, {}, Response>;
|
|
23
14
|
//#endregion
|
|
24
15
|
export { requireProjectPermission };
|
|
@@ -1,23 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { canEditProject, canUseProject, canViewProject, createApiError, isAuthzEnabled } from "@inkeep/agents-core";
|
|
1
|
+
import { canEditProject, canUseProject, canViewProject, createApiError } from "@inkeep/agents-core";
|
|
3
2
|
import { createMiddleware } from "hono/factory";
|
|
4
3
|
import { HTTPException } from "hono/http-exception";
|
|
5
4
|
|
|
6
5
|
//#region src/middleware/projectAccess.ts
|
|
7
6
|
/**
|
|
8
7
|
* Middleware to check project-level access.
|
|
9
|
-
*
|
|
10
|
-
* When ENABLE_AUTHZ is false:
|
|
11
|
-
* - 'view' permission: all org members can view
|
|
12
|
-
* - 'edit': only org owner/admin
|
|
13
|
-
*
|
|
14
|
-
* When ENABLE_AUTHZ is true:
|
|
15
|
-
* - Uses SpiceDB to check permissions
|
|
16
|
-
* - Org owner/admin bypass (handled in canViewProject etc.)
|
|
17
8
|
*/
|
|
18
9
|
const requireProjectPermission = (permission = "view") => createMiddleware(async (c, next) => {
|
|
19
|
-
|
|
20
|
-
if (env.DISABLE_AUTH || isTestEnvironment) {
|
|
10
|
+
if (process.env.ENVIRONMENT === "test") {
|
|
21
11
|
await next();
|
|
22
12
|
return;
|
|
23
13
|
}
|
|
@@ -64,27 +54,11 @@ const requireProjectPermission = (permission = "view") => createMiddleware(async
|
|
|
64
54
|
});
|
|
65
55
|
break;
|
|
66
56
|
}
|
|
67
|
-
if (!hasAccess) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
});
|
|
73
|
-
throw createApiError({
|
|
74
|
-
code: "forbidden",
|
|
75
|
-
message: `Permission denied. Required: project:${permission}`,
|
|
76
|
-
instance: c.req.path,
|
|
77
|
-
extensions: {
|
|
78
|
-
requiredPermissions: [`project:${permission}`],
|
|
79
|
-
context: {
|
|
80
|
-
userId,
|
|
81
|
-
organizationId: tenantId,
|
|
82
|
-
projectId,
|
|
83
|
-
currentRole: tenantRole
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
}
|
|
57
|
+
if (!hasAccess) throw createApiError({
|
|
58
|
+
code: "not_found",
|
|
59
|
+
message: "Project not found",
|
|
60
|
+
instance: c.req.path
|
|
61
|
+
});
|
|
88
62
|
await next();
|
|
89
63
|
} catch (error) {
|
|
90
64
|
if (error instanceof HTTPException) throw error;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import * as hono10 from "hono";
|
|
2
1
|
import { BaseExecutionContext, ResolvedRef } from "@inkeep/agents-core";
|
|
2
|
+
import * as hono17 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:
|
|
8
|
+
declare const projectConfigMiddleware: hono17.MiddlewareHandler<{
|
|
9
9
|
Variables: {
|
|
10
10
|
executionContext: BaseExecutionContext;
|
|
11
11
|
resolvedRef: ResolvedRef;
|
|
@@ -15,7 +15,7 @@ declare const projectConfigMiddleware: hono10.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) =>
|
|
18
|
+
declare const projectConfigMiddlewareExcept: (skipRouteCheck: (path: string) => boolean) => hono17.MiddlewareHandler<{
|
|
19
19
|
Variables: {
|
|
20
20
|
executionContext: BaseExecutionContext;
|
|
21
21
|
resolvedRef: ResolvedRef;
|
package/dist/middleware/ref.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ManageAppVariables } from "../types/app.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as hono4 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) =>
|
|
12
|
+
}>(permissions: Permission) => hono4.MiddlewareHandler<Env$1, string, {}, Response>;
|
|
13
13
|
//#endregion
|
|
14
14
|
export { requirePermission };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { env } from "../env.js";
|
|
2
1
|
import { createApiError } from "@inkeep/agents-core";
|
|
3
2
|
import { createMiddleware } from "hono/factory";
|
|
4
3
|
import { HTTPException } from "hono/http-exception";
|
|
@@ -15,7 +14,7 @@ function formatPermissionsForDisplay(permissions) {
|
|
|
15
14
|
const requirePermission = (permissions) => createMiddleware(async (c, next) => {
|
|
16
15
|
const isTestEnvironment = process.env.ENVIRONMENT === "test";
|
|
17
16
|
const auth = c.get("auth");
|
|
18
|
-
if (
|
|
17
|
+
if (isTestEnvironment || !auth) {
|
|
19
18
|
await next();
|
|
20
19
|
return;
|
|
21
20
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import * as hono16 from "hono";
|
|
2
1
|
import { BaseExecutionContext } from "@inkeep/agents-core";
|
|
2
|
+
import * as hono5 from "hono";
|
|
3
3
|
|
|
4
4
|
//#region src/middleware/runAuth.d.ts
|
|
5
|
-
declare const runApiKeyAuth: () =>
|
|
5
|
+
declare const runApiKeyAuth: () => hono5.MiddlewareHandler<{
|
|
6
6
|
Variables: {
|
|
7
7
|
executionContext: BaseExecutionContext;
|
|
8
8
|
};
|
|
@@ -11,7 +11,7 @@ declare const runApiKeyAuth: () => hono16.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) =>
|
|
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: () =>
|
|
23
|
+
declare const runOptionalAuth: () => hono5.MiddlewareHandler<{
|
|
24
24
|
Variables: {
|
|
25
25
|
executionContext?: BaseExecutionContext;
|
|
26
26
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as hono8 from "hono";
|
|
2
2
|
|
|
3
3
|
//#region src/middleware/sessionAuth.d.ts
|
|
4
4
|
|
|
@@ -7,11 +7,11 @@ import * as hono0 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: () =>
|
|
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: () =>
|
|
15
|
+
declare const sessionContext: () => hono8.MiddlewareHandler<any, string, {}, Response>;
|
|
16
16
|
//#endregion
|
|
17
17
|
export { sessionAuth, sessionContext };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { env } from "../env.js";
|
|
2
1
|
import { createApiError } from "@inkeep/agents-core";
|
|
3
2
|
import { createMiddleware } from "hono/factory";
|
|
4
3
|
import { HTTPException } from "hono/http-exception";
|
|
@@ -33,7 +32,7 @@ const sessionAuth = () => createMiddleware(async (c, next) => {
|
|
|
33
32
|
*/
|
|
34
33
|
const sessionContext = () => createMiddleware(async (c, next) => {
|
|
35
34
|
const auth = c.get("auth");
|
|
36
|
-
if (
|
|
35
|
+
if (!auth) {
|
|
37
36
|
c.set("user", null);
|
|
38
37
|
c.set("session", null);
|
|
39
38
|
await next();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as hono10 from "hono";
|
|
2
2
|
|
|
3
3
|
//#region src/middleware/tenantAccess.d.ts
|
|
4
4
|
|
|
@@ -11,7 +11,7 @@ import * as hono15 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: () =>
|
|
14
|
+
declare const requireTenantAccess: () => hono10.MiddlewareHandler<{
|
|
15
15
|
Variables: {
|
|
16
16
|
userId: string;
|
|
17
17
|
tenantId: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as hono11 from "hono";
|
|
2
2
|
|
|
3
3
|
//#region src/middleware/tracing.d.ts
|
|
4
|
-
declare const otelBaggageMiddleware: () =>
|
|
5
|
-
declare const executionBaggageMiddleware: () =>
|
|
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 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/agents-api",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-20260129143016",
|
|
4
4
|
"description": "Unified Inkeep Agents API - combines management, runtime, and evaluation capabilities",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -66,9 +66,9 @@
|
|
|
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-
|
|
70
|
-
"@inkeep/agents-manage-mcp": "^0.0.0-dev-
|
|
71
|
-
"@inkeep/agents-mcp": "^0.0.0-dev-
|
|
69
|
+
"@inkeep/agents-core": "^0.0.0-dev-20260129143016",
|
|
70
|
+
"@inkeep/agents-manage-mcp": "^0.0.0-dev-20260129143016",
|
|
71
|
+
"@inkeep/agents-mcp": "^0.0.0-dev-20260129143016"
|
|
72
72
|
},
|
|
73
73
|
"peerDependencies": {
|
|
74
74
|
"@hono/zod-openapi": "^1.1.5",
|
package/dist/initialization.d.ts
DELETED
package/dist/initialization.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { getLogger as getLogger$1 } from "./logger.js";
|
|
2
|
-
import { env } from "./env.js";
|
|
3
|
-
import runDbClient_default from "./data/db/runDbClient.js";
|
|
4
|
-
import { OrgRoles, addUserToOrganization, getUserByEmail, syncOrgMemberToSpiceDb, upsertOrganization } from "@inkeep/agents-core";
|
|
5
|
-
|
|
6
|
-
//#region src/initialization.ts
|
|
7
|
-
const logger = getLogger$1("initialization");
|
|
8
|
-
async function initializeDefaultUser(authInstance) {
|
|
9
|
-
const { INKEEP_AGENTS_MANAGE_UI_USERNAME, INKEEP_AGENTS_MANAGE_UI_PASSWORD, DISABLE_AUTH } = env;
|
|
10
|
-
const hasCredentials = INKEEP_AGENTS_MANAGE_UI_USERNAME && INKEEP_AGENTS_MANAGE_UI_PASSWORD;
|
|
11
|
-
const orgId = env.TENANT_ID;
|
|
12
|
-
const { created } = await upsertOrganization(runDbClient_default)({
|
|
13
|
-
organizationId: orgId,
|
|
14
|
-
name: env.TENANT_ID,
|
|
15
|
-
slug: env.TENANT_ID,
|
|
16
|
-
logo: null,
|
|
17
|
-
metadata: null
|
|
18
|
-
});
|
|
19
|
-
if (created) logger.info({ organizationId: orgId }, "Created default organization");
|
|
20
|
-
else logger.info({ organizationId: orgId }, "Organization already exists");
|
|
21
|
-
if (!hasCredentials || DISABLE_AUTH || !authInstance) {
|
|
22
|
-
logger.info({ hasCredentials: false }, "Skipping default user creation");
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
try {
|
|
26
|
-
let user = await getUserByEmail(runDbClient_default)(INKEEP_AGENTS_MANAGE_UI_USERNAME);
|
|
27
|
-
if (user) logger.info({
|
|
28
|
-
email: INKEEP_AGENTS_MANAGE_UI_USERNAME,
|
|
29
|
-
userId: user.id
|
|
30
|
-
}, "Default user already exists");
|
|
31
|
-
else {
|
|
32
|
-
logger.info({ email: INKEEP_AGENTS_MANAGE_UI_USERNAME }, "Creating default user with Better Auth...");
|
|
33
|
-
if (!(await authInstance.api.signUpEmail({ body: {
|
|
34
|
-
email: INKEEP_AGENTS_MANAGE_UI_USERNAME,
|
|
35
|
-
password: INKEEP_AGENTS_MANAGE_UI_PASSWORD,
|
|
36
|
-
name: INKEEP_AGENTS_MANAGE_UI_USERNAME.split("@")[0]
|
|
37
|
-
} })).user) throw new Error("signUpEmail returned no user");
|
|
38
|
-
user = await getUserByEmail(runDbClient_default)(INKEEP_AGENTS_MANAGE_UI_USERNAME);
|
|
39
|
-
if (!user) throw new Error("User was created but could not be retrieved from database");
|
|
40
|
-
logger.info({
|
|
41
|
-
email: user.email,
|
|
42
|
-
id: user.id
|
|
43
|
-
}, "Default user created from INKEEP_AGENTS_MANAGE_UI_USERNAME/INKEEP_AGENTS_MANAGE_UI_PASSWORD");
|
|
44
|
-
}
|
|
45
|
-
await addUserToOrganization(runDbClient_default)({
|
|
46
|
-
userId: user.id,
|
|
47
|
-
organizationId: orgId,
|
|
48
|
-
role: OrgRoles.ADMIN
|
|
49
|
-
});
|
|
50
|
-
await syncOrgMemberToSpiceDb({
|
|
51
|
-
tenantId: orgId,
|
|
52
|
-
userId: user.id,
|
|
53
|
-
role: OrgRoles.ADMIN,
|
|
54
|
-
action: "add"
|
|
55
|
-
});
|
|
56
|
-
console.log(`🔐 SpiceDB: Synced member ${user.email} as ${OrgRoles.ADMIN} to org ${orgId}`);
|
|
57
|
-
logger.info({
|
|
58
|
-
organizationId: orgId,
|
|
59
|
-
organizationSlug: env.TENANT_ID,
|
|
60
|
-
userId: user.id,
|
|
61
|
-
email: INKEEP_AGENTS_MANAGE_UI_USERNAME
|
|
62
|
-
}, "Initialization complete - login with these credentials");
|
|
63
|
-
} catch (error) {
|
|
64
|
-
logger.error({
|
|
65
|
-
error,
|
|
66
|
-
email: INKEEP_AGENTS_MANAGE_UI_USERNAME
|
|
67
|
-
}, "Failed to create default user");
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
//#endregion
|
|
72
|
-
export { initializeDefaultUser };
|