@inkeep/agents-manage-api 0.0.0-dev-20260113172432 → 0.0.0-dev-20260115183047
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/README.md +2 -1
- package/dist/create-app.d.ts +6 -4
- package/dist/create-app.js +11 -3
- package/dist/data/db/dbClient.d.ts +3 -3
- package/dist/data/db/dbClient.js +3 -11
- package/dist/data/db/runDbClient.d.ts +6 -0
- package/dist/data/db/runDbClient.js +9 -0
- package/dist/env.d.ts +6 -2
- package/dist/env.js +3 -1
- package/dist/factory.d.ts +1 -1
- package/dist/factory.js +2 -2
- package/dist/index.d.ts +18 -18
- package/dist/index.js +3 -3
- package/dist/initialization.js +7 -7
- package/dist/middleware/auth.d.ts +5 -4
- package/dist/middleware/auth.js +19 -3
- package/dist/middleware/branch-scoped-db.d.ts +31 -0
- package/dist/middleware/branch-scoped-db.js +137 -0
- package/dist/middleware/ref.d.ts +11 -0
- package/dist/middleware/ref.js +170 -0
- package/dist/middleware/require-permission.d.ts +7 -12
- package/dist/middleware/session-auth.d.ts +2 -2
- package/dist/middleware/tenant-access.d.ts +2 -2
- package/dist/middleware/tenant-access.js +2 -2
- package/dist/routes/agent.js +28 -9
- package/dist/routes/agentFull.js +27 -8
- package/dist/routes/agentToolRelations.js +15 -10
- package/dist/routes/apiKeys.js +7 -6
- package/dist/routes/artifactComponents.js +10 -6
- package/dist/routes/branches.d.ts +9 -0
- package/dist/routes/branches.js +182 -0
- package/dist/routes/cliAuth.js +2 -2
- package/dist/routes/contextConfigs.js +21 -7
- package/dist/routes/conversations.d.ts +2 -2
- package/dist/routes/conversations.js +2 -2
- package/dist/routes/credentials.js +10 -7
- package/dist/routes/dataComponents.js +10 -6
- package/dist/routes/evals/datasetItems.d.ts +9 -0
- package/dist/routes/evals/datasetItems.js +310 -0
- package/dist/routes/evals/datasetRunConfigs.d.ts +9 -0
- package/dist/routes/evals/datasetRunConfigs.js +402 -0
- package/dist/routes/evals/datasetRuns.d.ts +9 -0
- package/dist/routes/evals/datasetRuns.js +256 -0
- package/dist/routes/evals/datasets.d.ts +9 -0
- package/dist/routes/evals/datasets.js +238 -0
- package/dist/routes/evals/evaluationJobConfigEvaluatorRelations.d.ts +9 -0
- package/dist/routes/evals/evaluationJobConfigEvaluatorRelations.js +146 -0
- package/dist/routes/evals/evaluationJobConfigs.d.ts +9 -0
- package/dist/routes/evals/evaluationJobConfigs.js +361 -0
- package/dist/routes/evals/evaluationResults.d.ts +7 -0
- package/dist/routes/evals/evaluationResults.js +192 -0
- package/dist/routes/evals/evaluationRunConfigs.d.ts +9 -0
- package/dist/routes/evals/evaluationRunConfigs.js +462 -0
- package/dist/routes/evals/evaluationSuiteConfigEvaluatorRelations.d.ts +9 -0
- package/dist/routes/evals/evaluationSuiteConfigEvaluatorRelations.js +146 -0
- package/dist/routes/evals/evaluationSuiteConfigs.d.ts +9 -0
- package/dist/routes/evals/evaluationSuiteConfigs.js +246 -0
- package/dist/routes/evals/evaluators.d.ts +9 -0
- package/dist/routes/evals/evaluators.js +281 -0
- package/dist/routes/evals/index.d.ts +9 -0
- package/dist/routes/evals/index.js +26 -0
- package/dist/routes/externalAgents.js +10 -6
- package/dist/routes/functionTools.js +10 -6
- package/dist/routes/functions.js +14 -10
- package/dist/routes/index.js +6 -0
- package/dist/routes/invitations.js +2 -2
- package/dist/routes/mcp.d.ts +2 -2
- package/dist/routes/oauth.js +9 -8
- package/dist/routes/playgroundToken.js +3 -3
- package/dist/routes/projectFull.js +130 -20
- package/dist/routes/projects.js +65 -11
- package/dist/routes/ref.d.ts +9 -0
- package/dist/routes/ref.js +33 -0
- package/dist/routes/signoz.d.ts +2 -2
- package/dist/routes/signoz.js +3 -3
- package/dist/routes/subAgentArtifactComponents.js +13 -9
- package/dist/routes/subAgentDataComponents.js +13 -9
- package/dist/routes/subAgentExternalAgentRelations.js +11 -7
- package/dist/routes/subAgentFunctionTools.d.ts +9 -0
- package/dist/routes/subAgentFunctionTools.js +205 -0
- package/dist/routes/subAgentRelations.js +14 -10
- package/dist/routes/subAgentTeamAgentRelations.js +11 -7
- package/dist/routes/subAgentToolRelations.js +15 -10
- package/dist/routes/subAgents.js +17 -7
- package/dist/routes/tools.js +18 -13
- package/dist/routes/userOrganizations.js +3 -3
- package/dist/types/app.d.ts +4 -1
- package/dist/utils/temp-api-keys.d.ts +2 -2
- package/dist/utils/workflow-api-helpers.d.ts +1 -0
- package/dist/utils/workflow-api-helpers.js +1 -0
- package/package.json +10 -6
- package/dist/data/conversations.d.ts +0 -77
- package/dist/data/conversations.js +0 -152
package/README.md
CHANGED
package/dist/create-app.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
import * as _inkeep_agents_core0 from "@inkeep/agents-core";
|
|
2
|
+
import { CredentialStoreRegistry, ServerConfig } from "@inkeep/agents-core";
|
|
1
3
|
import { Hono } from "hono";
|
|
2
|
-
import { ServerConfig } from "@inkeep/agents-core";
|
|
3
4
|
import { auth, createAuth } from "@inkeep/agents-core/auth";
|
|
4
5
|
import * as hono_types0 from "hono/types";
|
|
5
|
-
import { CredentialStoreRegistry as CredentialStoreRegistry$1 } from "@inkeep/agents-core/credential-stores";
|
|
6
6
|
|
|
7
7
|
//#region src/create-app.d.ts
|
|
8
8
|
type AppVariables = {
|
|
9
9
|
serverConfig: ServerConfig;
|
|
10
|
-
credentialStores: CredentialStoreRegistry
|
|
10
|
+
credentialStores: CredentialStoreRegistry;
|
|
11
11
|
auth: ReturnType<typeof createAuth> | null;
|
|
12
12
|
user: typeof auth.$Infer.Session.user | null;
|
|
13
13
|
session: typeof auth.$Infer.Session.session | null;
|
|
@@ -15,7 +15,9 @@ type AppVariables = {
|
|
|
15
15
|
userEmail?: string;
|
|
16
16
|
tenantId?: string;
|
|
17
17
|
tenantRole?: string;
|
|
18
|
+
isInternalService?: boolean;
|
|
19
|
+
internalServicePayload?: _inkeep_agents_core0.InternalServiceTokenPayload;
|
|
18
20
|
};
|
|
19
|
-
declare function createManagementHono(serverConfig: ServerConfig, credentialStores: CredentialStoreRegistry
|
|
21
|
+
declare function createManagementHono(serverConfig: ServerConfig, credentialStores: CredentialStoreRegistry, auth: ReturnType<typeof createAuth> | null): Hono<hono_types0.BlankEnv, hono_types0.BlankSchema, "/">;
|
|
20
22
|
//#endregion
|
|
21
23
|
export { AppVariables, createManagementHono };
|
package/dist/create-app.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { env } from "./env.js";
|
|
2
|
-
import { getLogger } from "./logger.js";
|
|
2
|
+
import { getLogger as getLogger$1 } from "./logger.js";
|
|
3
3
|
import { apiKeyAuth } from "./middleware/auth.js";
|
|
4
|
+
import { branchScopedDbMiddleware } from "./middleware/branch-scoped-db.js";
|
|
4
5
|
import { errorHandler } from "./middleware/error-handler.js";
|
|
6
|
+
import { refMiddleware, writeProtectionMiddleware } from "./middleware/ref.js";
|
|
5
7
|
import { sessionAuth } from "./middleware/session-auth.js";
|
|
6
8
|
import { requireTenantAccess } from "./middleware/tenant-access.js";
|
|
7
9
|
import { setupOpenAPIRoutes } from "./openapi.js";
|
|
8
10
|
import cliAuth_default from "./routes/cliAuth.js";
|
|
11
|
+
import evals_default from "./routes/evals/index.js";
|
|
9
12
|
import routes_default from "./routes/index.js";
|
|
10
13
|
import invitations_default from "./routes/invitations.js";
|
|
11
14
|
import mcp_default from "./routes/mcp.js";
|
|
@@ -16,13 +19,14 @@ import signoz_default from "./routes/signoz.js";
|
|
|
16
19
|
import userOrganizations_default from "./routes/userOrganizations.js";
|
|
17
20
|
import { authCorsConfig, defaultCorsConfig, isOriginAllowed, playgroundCorsConfig } from "./utils/cors.js";
|
|
18
21
|
import { OpenAPIHono, createRoute } from "@hono/zod-openapi";
|
|
22
|
+
import { handleApiError } from "@inkeep/agents-core";
|
|
19
23
|
import { Hono } from "hono";
|
|
20
24
|
import { cors } from "hono/cors";
|
|
21
25
|
import { requestId } from "hono/request-id";
|
|
22
26
|
import { pinoLogger } from "hono-pino";
|
|
23
27
|
|
|
24
28
|
//#region src/create-app.ts
|
|
25
|
-
const logger = getLogger("agents-manage-api");
|
|
29
|
+
const logger = getLogger$1("agents-manage-api");
|
|
26
30
|
logger.info({ logger: logger.getTransports() }, "Logger initialized");
|
|
27
31
|
const isTestEnvironment = () => process.env.ENVIRONMENT === "test";
|
|
28
32
|
function createManagementHono(serverConfig, credentialStores, auth) {
|
|
@@ -35,7 +39,7 @@ function createManagementHono(serverConfig, credentialStores, auth) {
|
|
|
35
39
|
return next();
|
|
36
40
|
});
|
|
37
41
|
app.use(pinoLogger({
|
|
38
|
-
pino: getLogger("agents-manage-api").getPinoInstance(),
|
|
42
|
+
pino: getLogger$1("agents-manage-api").getPinoInstance(),
|
|
39
43
|
http: { onResLevel(c) {
|
|
40
44
|
if (c.res.status >= 500) return "error";
|
|
41
45
|
return "info";
|
|
@@ -125,6 +129,9 @@ function createManagementHono(serverConfig, credentialStores, auth) {
|
|
|
125
129
|
await next();
|
|
126
130
|
});
|
|
127
131
|
else app.use("/tenants/:tenantId/*", requireTenantAccess());
|
|
132
|
+
app.use("/tenants/*", async (c, next) => refMiddleware(c, next));
|
|
133
|
+
app.use("/tenants/*", (c, next) => writeProtectionMiddleware(c, next));
|
|
134
|
+
app.use("/tenants/*", async (c, next) => branchScopedDbMiddleware(c, next));
|
|
128
135
|
app.route("/api/users/:userId/organizations", userOrganizations_default);
|
|
129
136
|
app.route("/api/cli", cliAuth_default);
|
|
130
137
|
app.route("/api/invitations", invitations_default);
|
|
@@ -132,6 +139,7 @@ function createManagementHono(serverConfig, credentialStores, auth) {
|
|
|
132
139
|
app.route("/tenants/:tenantId/playground/token", playgroundToken_default);
|
|
133
140
|
app.route("/tenants/:tenantId/signoz", signoz_default);
|
|
134
141
|
app.route("/tenants/:tenantId", projectFull_default);
|
|
142
|
+
app.route("/tenants/:tenantId/projects/:projectId/evals", evals_default);
|
|
135
143
|
app.route("/oauth", oauth_default);
|
|
136
144
|
app.route("/mcp", mcp_default);
|
|
137
145
|
setupOpenAPIRoutes(app);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _inkeep_agents_core0 from "@inkeep/agents-core";
|
|
2
2
|
|
|
3
3
|
//#region src/data/db/dbClient.d.ts
|
|
4
|
-
declare
|
|
4
|
+
declare const manageDbClient: _inkeep_agents_core0.AgentsManageDatabaseClient;
|
|
5
5
|
//#endregion
|
|
6
|
-
export {
|
|
6
|
+
export { manageDbClient as default };
|
package/dist/data/db/dbClient.js
CHANGED
|
@@ -1,17 +1,9 @@
|
|
|
1
1
|
import { env } from "../../env.js";
|
|
2
|
-
import {
|
|
3
|
-
import { PGlite } from "@electric-sql/pglite";
|
|
4
|
-
import * as schema from "@inkeep/agents-core/db/schema";
|
|
5
|
-
import { drizzle } from "drizzle-orm/pglite";
|
|
2
|
+
import { createAgentsManageDatabaseClient } from "@inkeep/agents-core";
|
|
6
3
|
|
|
7
4
|
//#region src/data/db/dbClient.ts
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
client: new PGlite(),
|
|
11
|
-
schema
|
|
12
|
-
});
|
|
13
|
-
else dbClient = createDatabaseClient({ connectionString: env.DATABASE_URL });
|
|
14
|
-
var dbClient_default = dbClient;
|
|
5
|
+
const manageDbClient = createAgentsManageDatabaseClient({ connectionString: env.INKEEP_AGENTS_MANAGE_DATABASE_URL });
|
|
6
|
+
var dbClient_default = manageDbClient;
|
|
15
7
|
|
|
16
8
|
//#endregion
|
|
17
9
|
export { dbClient_default as default };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { env } from "../../env.js";
|
|
2
|
+
import { createAgentsRunDatabaseClient } from "@inkeep/agents-core";
|
|
3
|
+
|
|
4
|
+
//#region src/data/db/runDbClient.ts
|
|
5
|
+
const runDbClient = createAgentsRunDatabaseClient({ connectionString: env.INKEEP_AGENTS_RUN_DATABASE_URL });
|
|
6
|
+
var runDbClient_default = runDbClient;
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
export { runDbClient_default as default };
|
package/dist/env.d.ts
CHANGED
|
@@ -15,7 +15,9 @@ declare const envSchema: z.ZodObject<{
|
|
|
15
15
|
}>>;
|
|
16
16
|
INKEEP_AGENTS_MANAGE_API_URL: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
17
17
|
INKEEP_AGENTS_MANAGE_UI_URL: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
18
|
-
|
|
18
|
+
INKEEP_AGENTS_EVAL_API_URL: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
19
|
+
INKEEP_AGENTS_MANAGE_DATABASE_URL: z.ZodOptional<z.ZodString>;
|
|
20
|
+
INKEEP_AGENTS_RUN_DATABASE_URL: z.ZodOptional<z.ZodString>;
|
|
19
21
|
LOG_LEVEL: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
20
22
|
trace: "trace";
|
|
21
23
|
debug: "debug";
|
|
@@ -39,13 +41,15 @@ declare const envSchema: z.ZodObject<{
|
|
|
39
41
|
declare const env: {
|
|
40
42
|
INKEEP_AGENTS_MANAGE_API_URL: string;
|
|
41
43
|
INKEEP_AGENTS_MANAGE_UI_URL: string;
|
|
44
|
+
INKEEP_AGENTS_EVAL_API_URL: string;
|
|
42
45
|
LOG_LEVEL: "trace" | "debug" | "info" | "warn" | "error";
|
|
43
46
|
NANGO_SERVER_URL: string;
|
|
44
47
|
TENANT_ID: string;
|
|
45
48
|
DISABLE_AUTH: boolean;
|
|
46
49
|
NODE_ENV?: "development" | "production" | "test" | undefined;
|
|
47
50
|
ENVIRONMENT?: "development" | "production" | "test" | "pentest" | undefined;
|
|
48
|
-
|
|
51
|
+
INKEEP_AGENTS_MANAGE_DATABASE_URL?: string | undefined;
|
|
52
|
+
INKEEP_AGENTS_RUN_DATABASE_URL?: string | undefined;
|
|
49
53
|
NANGO_SECRET_KEY?: string | undefined;
|
|
50
54
|
INKEEP_AGENTS_MANAGE_API_BYPASS_SECRET?: string | undefined;
|
|
51
55
|
BETTER_AUTH_SECRET?: string | undefined;
|
package/dist/env.js
CHANGED
|
@@ -17,7 +17,9 @@ const envSchema = z.object({
|
|
|
17
17
|
]).optional(),
|
|
18
18
|
INKEEP_AGENTS_MANAGE_API_URL: z.string().optional().default("http://localhost:3002"),
|
|
19
19
|
INKEEP_AGENTS_MANAGE_UI_URL: z.string().optional().default("http://localhost:3000"),
|
|
20
|
-
|
|
20
|
+
INKEEP_AGENTS_EVAL_API_URL: z.string().optional().default("http://localhost:3005"),
|
|
21
|
+
INKEEP_AGENTS_MANAGE_DATABASE_URL: z.string().optional(),
|
|
22
|
+
INKEEP_AGENTS_RUN_DATABASE_URL: z.string().optional(),
|
|
21
23
|
LOG_LEVEL: z.enum([
|
|
22
24
|
"trace",
|
|
23
25
|
"debug",
|
package/dist/factory.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createManagementHono } from "./create-app.js";
|
|
2
2
|
import { initializeDefaultUser } from "./initialization.js";
|
|
3
3
|
import { createAuth0Provider, createOIDCProvider } from "./sso-helpers.js";
|
|
4
|
-
import * as hono0 from "hono";
|
|
5
4
|
import { CredentialStore, ServerConfig } from "@inkeep/agents-core";
|
|
5
|
+
import * as hono0 from "hono";
|
|
6
6
|
import { SSOProviderConfig, UserAuthConfig } from "@inkeep/agents-core/auth";
|
|
7
7
|
import * as hono_types1 from "hono/types";
|
|
8
8
|
|
package/dist/factory.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { env } from "./env.js";
|
|
2
|
-
import
|
|
2
|
+
import runDbClient_default from "./data/db/runDbClient.js";
|
|
3
3
|
import { createManagementHono } from "./create-app.js";
|
|
4
4
|
import { initializeDefaultUser } from "./initialization.js";
|
|
5
5
|
import { createAuth0Provider, createOIDCProvider } from "./sso-helpers.js";
|
|
@@ -20,7 +20,7 @@ function createManagementAuth(userAuthConfig) {
|
|
|
20
20
|
return createAuth({
|
|
21
21
|
baseURL: env.INKEEP_AGENTS_MANAGE_API_URL || "http://localhost:3002",
|
|
22
22
|
secret: env.BETTER_AUTH_SECRET || "development-secret-change-in-production",
|
|
23
|
-
dbClient:
|
|
23
|
+
dbClient: runDbClient_default,
|
|
24
24
|
...userAuthConfig?.ssoProviders && { ssoProviders: userAuthConfig.ssoProviders },
|
|
25
25
|
...userAuthConfig?.socialProviders && { socialProviders: userAuthConfig.socialProviders }
|
|
26
26
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -785,25 +785,25 @@ declare const auth: better_auth0.Auth<{
|
|
|
785
785
|
ac: better_auth_plugins0.AccessControl;
|
|
786
786
|
roles: {
|
|
787
787
|
member: {
|
|
788
|
-
authorize<K_1 extends "function" | "
|
|
789
|
-
actions: better_auth_plugins0.Subset<"function" | "
|
|
788
|
+
authorize<K_1 extends "function" | "invitation" | "member" | "organization" | "ac" | "project" | "agent" | "sub_agent" | "tool" | "api_key" | "credential" | "data_component" | "artifact_component" | "external_agent" | "context_config" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"function" | "invitation" | "member" | "organization" | "ac" | "project" | "agent" | "sub_agent" | "tool" | "api_key" | "credential" | "data_component" | "artifact_component" | "external_agent" | "context_config" | "team", better_auth_plugins0.Statements>[key] | {
|
|
789
|
+
actions: better_auth_plugins0.Subset<"function" | "invitation" | "member" | "organization" | "ac" | "project" | "agent" | "sub_agent" | "tool" | "api_key" | "credential" | "data_component" | "artifact_component" | "external_agent" | "context_config" | "team", better_auth_plugins0.Statements>[key];
|
|
790
790
|
connector: "OR" | "AND";
|
|
791
791
|
} | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins0.AuthorizeResponse;
|
|
792
|
-
statements: better_auth_plugins0.Subset<"function" | "
|
|
792
|
+
statements: better_auth_plugins0.Subset<"function" | "invitation" | "member" | "organization" | "ac" | "project" | "agent" | "sub_agent" | "tool" | "api_key" | "credential" | "data_component" | "artifact_component" | "external_agent" | "context_config" | "team", better_auth_plugins0.Statements>;
|
|
793
793
|
};
|
|
794
794
|
admin: {
|
|
795
|
-
authorize<K_1 extends "function" | "
|
|
796
|
-
actions: better_auth_plugins0.Subset<"function" | "
|
|
795
|
+
authorize<K_1 extends "function" | "invitation" | "member" | "organization" | "ac" | "project" | "agent" | "sub_agent" | "tool" | "api_key" | "credential" | "data_component" | "artifact_component" | "external_agent" | "context_config" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"function" | "invitation" | "member" | "organization" | "ac" | "project" | "agent" | "sub_agent" | "tool" | "api_key" | "credential" | "data_component" | "artifact_component" | "external_agent" | "context_config" | "team", better_auth_plugins0.Statements>[key] | {
|
|
796
|
+
actions: better_auth_plugins0.Subset<"function" | "invitation" | "member" | "organization" | "ac" | "project" | "agent" | "sub_agent" | "tool" | "api_key" | "credential" | "data_component" | "artifact_component" | "external_agent" | "context_config" | "team", better_auth_plugins0.Statements>[key];
|
|
797
797
|
connector: "OR" | "AND";
|
|
798
798
|
} | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins0.AuthorizeResponse;
|
|
799
|
-
statements: better_auth_plugins0.Subset<"function" | "
|
|
799
|
+
statements: better_auth_plugins0.Subset<"function" | "invitation" | "member" | "organization" | "ac" | "project" | "agent" | "sub_agent" | "tool" | "api_key" | "credential" | "data_component" | "artifact_component" | "external_agent" | "context_config" | "team", better_auth_plugins0.Statements>;
|
|
800
800
|
};
|
|
801
801
|
owner: {
|
|
802
|
-
authorize<K_1 extends "function" | "
|
|
803
|
-
actions: better_auth_plugins0.Subset<"function" | "
|
|
802
|
+
authorize<K_1 extends "function" | "invitation" | "member" | "organization" | "ac" | "project" | "agent" | "sub_agent" | "tool" | "api_key" | "credential" | "data_component" | "artifact_component" | "external_agent" | "context_config" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"function" | "invitation" | "member" | "organization" | "ac" | "project" | "agent" | "sub_agent" | "tool" | "api_key" | "credential" | "data_component" | "artifact_component" | "external_agent" | "context_config" | "team", better_auth_plugins0.Statements>[key] | {
|
|
803
|
+
actions: better_auth_plugins0.Subset<"function" | "invitation" | "member" | "organization" | "ac" | "project" | "agent" | "sub_agent" | "tool" | "api_key" | "credential" | "data_component" | "artifact_component" | "external_agent" | "context_config" | "team", better_auth_plugins0.Statements>[key];
|
|
804
804
|
connector: "OR" | "AND";
|
|
805
805
|
} | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins0.AuthorizeResponse;
|
|
806
|
-
statements: better_auth_plugins0.Subset<"function" | "
|
|
806
|
+
statements: better_auth_plugins0.Subset<"function" | "invitation" | "member" | "organization" | "ac" | "project" | "agent" | "sub_agent" | "tool" | "api_key" | "credential" | "data_component" | "artifact_component" | "external_agent" | "context_config" | "team", better_auth_plugins0.Statements>;
|
|
807
807
|
};
|
|
808
808
|
};
|
|
809
809
|
membershipLimit: number;
|
|
@@ -1064,25 +1064,25 @@ declare const auth: better_auth0.Auth<{
|
|
|
1064
1064
|
ac: better_auth_plugins0.AccessControl;
|
|
1065
1065
|
roles: {
|
|
1066
1066
|
member: {
|
|
1067
|
-
authorize<K_1 extends "function" | "
|
|
1068
|
-
actions: better_auth_plugins0.Subset<"function" | "
|
|
1067
|
+
authorize<K_1 extends "function" | "invitation" | "member" | "organization" | "ac" | "project" | "agent" | "sub_agent" | "tool" | "api_key" | "credential" | "data_component" | "artifact_component" | "external_agent" | "context_config" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"function" | "invitation" | "member" | "organization" | "ac" | "project" | "agent" | "sub_agent" | "tool" | "api_key" | "credential" | "data_component" | "artifact_component" | "external_agent" | "context_config" | "team", better_auth_plugins0.Statements>[key] | {
|
|
1068
|
+
actions: better_auth_plugins0.Subset<"function" | "invitation" | "member" | "organization" | "ac" | "project" | "agent" | "sub_agent" | "tool" | "api_key" | "credential" | "data_component" | "artifact_component" | "external_agent" | "context_config" | "team", better_auth_plugins0.Statements>[key];
|
|
1069
1069
|
connector: "OR" | "AND";
|
|
1070
1070
|
} | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins0.AuthorizeResponse;
|
|
1071
|
-
statements: better_auth_plugins0.Subset<"function" | "
|
|
1071
|
+
statements: better_auth_plugins0.Subset<"function" | "invitation" | "member" | "organization" | "ac" | "project" | "agent" | "sub_agent" | "tool" | "api_key" | "credential" | "data_component" | "artifact_component" | "external_agent" | "context_config" | "team", better_auth_plugins0.Statements>;
|
|
1072
1072
|
};
|
|
1073
1073
|
admin: {
|
|
1074
|
-
authorize<K_1 extends "function" | "
|
|
1075
|
-
actions: better_auth_plugins0.Subset<"function" | "
|
|
1074
|
+
authorize<K_1 extends "function" | "invitation" | "member" | "organization" | "ac" | "project" | "agent" | "sub_agent" | "tool" | "api_key" | "credential" | "data_component" | "artifact_component" | "external_agent" | "context_config" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"function" | "invitation" | "member" | "organization" | "ac" | "project" | "agent" | "sub_agent" | "tool" | "api_key" | "credential" | "data_component" | "artifact_component" | "external_agent" | "context_config" | "team", better_auth_plugins0.Statements>[key] | {
|
|
1075
|
+
actions: better_auth_plugins0.Subset<"function" | "invitation" | "member" | "organization" | "ac" | "project" | "agent" | "sub_agent" | "tool" | "api_key" | "credential" | "data_component" | "artifact_component" | "external_agent" | "context_config" | "team", better_auth_plugins0.Statements>[key];
|
|
1076
1076
|
connector: "OR" | "AND";
|
|
1077
1077
|
} | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins0.AuthorizeResponse;
|
|
1078
|
-
statements: better_auth_plugins0.Subset<"function" | "
|
|
1078
|
+
statements: better_auth_plugins0.Subset<"function" | "invitation" | "member" | "organization" | "ac" | "project" | "agent" | "sub_agent" | "tool" | "api_key" | "credential" | "data_component" | "artifact_component" | "external_agent" | "context_config" | "team", better_auth_plugins0.Statements>;
|
|
1079
1079
|
};
|
|
1080
1080
|
owner: {
|
|
1081
|
-
authorize<K_1 extends "function" | "
|
|
1082
|
-
actions: better_auth_plugins0.Subset<"function" | "
|
|
1081
|
+
authorize<K_1 extends "function" | "invitation" | "member" | "organization" | "ac" | "project" | "agent" | "sub_agent" | "tool" | "api_key" | "credential" | "data_component" | "artifact_component" | "external_agent" | "context_config" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"function" | "invitation" | "member" | "organization" | "ac" | "project" | "agent" | "sub_agent" | "tool" | "api_key" | "credential" | "data_component" | "artifact_component" | "external_agent" | "context_config" | "team", better_auth_plugins0.Statements>[key] | {
|
|
1082
|
+
actions: better_auth_plugins0.Subset<"function" | "invitation" | "member" | "organization" | "ac" | "project" | "agent" | "sub_agent" | "tool" | "api_key" | "credential" | "data_component" | "artifact_component" | "external_agent" | "context_config" | "team", better_auth_plugins0.Statements>[key];
|
|
1083
1083
|
connector: "OR" | "AND";
|
|
1084
1084
|
} | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins0.AuthorizeResponse;
|
|
1085
|
-
statements: better_auth_plugins0.Subset<"function" | "
|
|
1085
|
+
statements: better_auth_plugins0.Subset<"function" | "invitation" | "member" | "organization" | "ac" | "project" | "agent" | "sub_agent" | "tool" | "api_key" | "credential" | "data_component" | "artifact_component" | "external_agent" | "context_config" | "team", better_auth_plugins0.Statements>;
|
|
1086
1086
|
};
|
|
1087
1087
|
};
|
|
1088
1088
|
membershipLimit: number;
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { env } from "./env.js";
|
|
2
|
-
import
|
|
2
|
+
import runDbClient_default from "./data/db/runDbClient.js";
|
|
3
3
|
import { createManagementHono } from "./create-app.js";
|
|
4
4
|
import { initializeDefaultUser } from "./initialization.js";
|
|
5
5
|
import { createAuth0Provider, createOIDCProvider } from "./sso-helpers.js";
|
|
6
6
|
import { createManagementApp } from "./factory.js";
|
|
7
|
-
import { Hono } from "hono";
|
|
8
7
|
import { CredentialStoreRegistry, createDefaultCredentialStores } from "@inkeep/agents-core";
|
|
8
|
+
import { Hono } from "hono";
|
|
9
9
|
import { createAuth } from "@inkeep/agents-core/auth";
|
|
10
10
|
|
|
11
11
|
//#region src/index.ts
|
|
@@ -23,7 +23,7 @@ function createManagementAuth(userAuthConfig) {
|
|
|
23
23
|
return createAuth({
|
|
24
24
|
baseURL: env.INKEEP_AGENTS_MANAGE_API_URL || "http://localhost:3002",
|
|
25
25
|
secret: env.BETTER_AUTH_SECRET || "development-secret-change-in-production",
|
|
26
|
-
dbClient:
|
|
26
|
+
dbClient: runDbClient_default,
|
|
27
27
|
...userAuthConfig?.ssoProviders && { ssoProviders: userAuthConfig.ssoProviders },
|
|
28
28
|
...userAuthConfig?.socialProviders && { socialProviders: userAuthConfig.socialProviders }
|
|
29
29
|
});
|
package/dist/initialization.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { env } from "./env.js";
|
|
2
2
|
import { getLogger as getLogger$1 } from "./logger.js";
|
|
3
|
-
import
|
|
3
|
+
import runDbClient_default from "./data/db/runDbClient.js";
|
|
4
4
|
import { generateId, getUserByEmail, member, organization } from "@inkeep/agents-core";
|
|
5
5
|
import { and, eq } from "drizzle-orm";
|
|
6
6
|
|
|
@@ -10,8 +10,8 @@ async function initializeDefaultUser(authInstance) {
|
|
|
10
10
|
const { INKEEP_AGENTS_MANAGE_UI_USERNAME, INKEEP_AGENTS_MANAGE_UI_PASSWORD, DISABLE_AUTH } = env;
|
|
11
11
|
const hasCredentials = INKEEP_AGENTS_MANAGE_UI_USERNAME && INKEEP_AGENTS_MANAGE_UI_PASSWORD;
|
|
12
12
|
const orgId = env.TENANT_ID;
|
|
13
|
-
if ((await
|
|
14
|
-
await
|
|
13
|
+
if ((await runDbClient_default.select().from(organization).where(eq(organization.id, orgId)).limit(1)).length === 0) {
|
|
14
|
+
await runDbClient_default.insert(organization).values({
|
|
15
15
|
id: orgId,
|
|
16
16
|
name: env.TENANT_ID,
|
|
17
17
|
slug: env.TENANT_ID,
|
|
@@ -26,7 +26,7 @@ async function initializeDefaultUser(authInstance) {
|
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
28
28
|
try {
|
|
29
|
-
let user = await getUserByEmail(
|
|
29
|
+
let user = await getUserByEmail(runDbClient_default)(INKEEP_AGENTS_MANAGE_UI_USERNAME);
|
|
30
30
|
if (user) logger.info({
|
|
31
31
|
email: INKEEP_AGENTS_MANAGE_UI_USERNAME,
|
|
32
32
|
userId: user.id
|
|
@@ -38,15 +38,15 @@ async function initializeDefaultUser(authInstance) {
|
|
|
38
38
|
password: INKEEP_AGENTS_MANAGE_UI_PASSWORD,
|
|
39
39
|
name: INKEEP_AGENTS_MANAGE_UI_USERNAME.split("@")[0]
|
|
40
40
|
} })).user) throw new Error("signUpEmail returned no user");
|
|
41
|
-
user = await getUserByEmail(
|
|
41
|
+
user = await getUserByEmail(runDbClient_default)(INKEEP_AGENTS_MANAGE_UI_USERNAME);
|
|
42
42
|
if (!user) throw new Error("User was created but could not be retrieved from database");
|
|
43
43
|
logger.info({
|
|
44
44
|
email: user.email,
|
|
45
45
|
id: user.id
|
|
46
46
|
}, "Default user created from INKEEP_AGENTS_MANAGE_UI_USERNAME/INKEEP_AGENTS_MANAGE_UI_PASSWORD");
|
|
47
47
|
}
|
|
48
|
-
if ((await
|
|
49
|
-
await
|
|
48
|
+
if ((await runDbClient_default.select().from(member).where(and(eq(member.userId, user.id), eq(member.organizationId, orgId))).limit(1)).length === 0) {
|
|
49
|
+
await runDbClient_default.insert(member).values({
|
|
50
50
|
id: generateId(),
|
|
51
51
|
userId: user.id,
|
|
52
52
|
organizationId: orgId,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { BaseExecutionContext } from "@inkeep/agents-core";
|
|
2
|
+
import * as hono6 from "hono";
|
|
3
3
|
import { createAuth } from "@inkeep/agents-core/auth";
|
|
4
4
|
|
|
5
5
|
//#region src/middleware/auth.d.ts
|
|
@@ -10,10 +10,11 @@ import { createAuth } from "@inkeep/agents-core/auth";
|
|
|
10
10
|
* 1. Bypass secret (INKEEP_AGENTS_MANAGE_API_BYPASS_SECRET)
|
|
11
11
|
* 2. Better-auth session token (from device authorization flow)
|
|
12
12
|
* 3. Database API key
|
|
13
|
+
* 4. Internal service token
|
|
13
14
|
*/
|
|
14
|
-
declare const apiKeyAuth: () =>
|
|
15
|
+
declare const apiKeyAuth: () => hono6.MiddlewareHandler<{
|
|
15
16
|
Variables: {
|
|
16
|
-
executionContext:
|
|
17
|
+
executionContext: BaseExecutionContext;
|
|
17
18
|
userId?: string;
|
|
18
19
|
userEmail?: string;
|
|
19
20
|
tenantId?: string;
|
package/dist/middleware/auth.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { env } from "../env.js";
|
|
2
|
-
import
|
|
3
|
-
import { getLogger, validateAndGetApiKey } from "@inkeep/agents-core";
|
|
2
|
+
import runDbClient_default from "../data/db/runDbClient.js";
|
|
3
|
+
import { getLogger, isInternalServiceToken, validateAndGetApiKey, verifyInternalServiceAuthHeader } from "@inkeep/agents-core";
|
|
4
4
|
import { createMiddleware } from "hono/factory";
|
|
5
5
|
import { HTTPException } from "hono/http-exception";
|
|
6
6
|
|
|
@@ -12,6 +12,7 @@ const logger = getLogger("env-key-auth");
|
|
|
12
12
|
* 1. Bypass secret (INKEEP_AGENTS_MANAGE_API_BYPASS_SECRET)
|
|
13
13
|
* 2. Better-auth session token (from device authorization flow)
|
|
14
14
|
* 3. Database API key
|
|
15
|
+
* 4. Internal service token
|
|
15
16
|
*/
|
|
16
17
|
const apiKeyAuth = () => createMiddleware(async (c, next) => {
|
|
17
18
|
const authHeader = c.req.header("Authorization");
|
|
@@ -48,7 +49,7 @@ const apiKeyAuth = () => createMiddleware(async (c, next) => {
|
|
|
48
49
|
} catch (error) {
|
|
49
50
|
logger.debug({ error }, "Better-auth session validation failed, trying API key");
|
|
50
51
|
}
|
|
51
|
-
const validatedKey = await validateAndGetApiKey(token,
|
|
52
|
+
const validatedKey = await validateAndGetApiKey(token, runDbClient_default);
|
|
52
53
|
if (validatedKey) {
|
|
53
54
|
logger.info({ keyId: validatedKey.id }, "API key authenticated successfully");
|
|
54
55
|
c.set("userId", `apikey:${validatedKey.id}`);
|
|
@@ -57,6 +58,21 @@ const apiKeyAuth = () => createMiddleware(async (c, next) => {
|
|
|
57
58
|
await next();
|
|
58
59
|
return;
|
|
59
60
|
}
|
|
61
|
+
if (isInternalServiceToken(token)) {
|
|
62
|
+
const result = await verifyInternalServiceAuthHeader(authHeader);
|
|
63
|
+
if (!result.valid || !result.payload) throw new HTTPException(401, { message: result.error || "Invalid internal service token" });
|
|
64
|
+
logger.info({
|
|
65
|
+
serviceId: result.payload.sub,
|
|
66
|
+
tenantId: result.payload.tenantId,
|
|
67
|
+
projectId: result.payload.projectId,
|
|
68
|
+
userId: result.payload.userId
|
|
69
|
+
}, "Internal service authenticated");
|
|
70
|
+
c.set("userId", result.payload.userId || `system`);
|
|
71
|
+
c.set("userEmail", `${result.payload.sub}@internal.inkeep`);
|
|
72
|
+
if (result.payload.tenantId) c.set("tenantId", result.payload.tenantId);
|
|
73
|
+
await next();
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
60
76
|
throw new HTTPException(401, { message: "Invalid Token" });
|
|
61
77
|
});
|
|
62
78
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { AgentsManageDatabaseClient } from "@inkeep/agents-core";
|
|
2
|
+
import { Context, Next } from "hono";
|
|
3
|
+
import { Pool } from "pg";
|
|
4
|
+
|
|
5
|
+
//#region src/middleware/branch-scoped-db.d.ts
|
|
6
|
+
declare function isProjectDeleteOperation(path: string, method: string): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Get the underlying connection pool from a Drizzle database client
|
|
9
|
+
*/
|
|
10
|
+
declare function getPoolFromClient(client: AgentsManageDatabaseClient): Pool | null;
|
|
11
|
+
/**
|
|
12
|
+
* Middleware that provides branch-scoped database connections
|
|
13
|
+
*
|
|
14
|
+
* Flow:
|
|
15
|
+
* 1. Get a dedicated connection from the pool
|
|
16
|
+
* 2. If ref is specified, checkout that branch/tag/commit on this connection
|
|
17
|
+
* 3. Create a Drizzle client wrapping this specific connection
|
|
18
|
+
* 4. Inject into context as 'db' (request-scoped database client)
|
|
19
|
+
* 5. Execute the route handler
|
|
20
|
+
* 6. For write operations on branches: auto-commit changes
|
|
21
|
+
* 7. Always cleanup: checkout main and release connection
|
|
22
|
+
*
|
|
23
|
+
* This ensures:
|
|
24
|
+
* - All operations in a request use the same connection (correct)
|
|
25
|
+
* - Only one checkout per request (performant)
|
|
26
|
+
* - Automatic commits for successful writes on branches
|
|
27
|
+
* - Proper connection cleanup
|
|
28
|
+
*/
|
|
29
|
+
declare const branchScopedDbMiddleware: (c: Context, next: Next) => Promise<void>;
|
|
30
|
+
//#endregion
|
|
31
|
+
export { branchScopedDbMiddleware, getPoolFromClient, isProjectDeleteOperation };
|