@inkeep/agents-api 0.43.0 → 0.44.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.well-known/workflow/v1/manifest.debug.json +20 -20
- package/dist/.well-known/workflow/v1/step.cjs +211763 -195914
- package/dist/createApp.js +11 -9
- package/dist/domains/evals/routes/datasetTriggers.d.ts +2 -2
- package/dist/domains/evals/routes/index.d.ts +2 -2
- package/dist/domains/evals/workflow/routes.d.ts +2 -2
- package/dist/domains/manage/index.js +6 -0
- package/dist/domains/manage/routes/conversations.d.ts +2 -2
- package/dist/domains/manage/routes/github.d.ts +16 -0
- package/dist/domains/manage/routes/github.js +511 -0
- 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/mcpToolGithubAccess.d.ts +9 -0
- package/dist/domains/manage/routes/mcpToolGithubAccess.js +205 -0
- package/dist/domains/manage/routes/projectGithubAccess.d.ts +9 -0
- package/dist/domains/manage/routes/projectGithubAccess.js +167 -0
- 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/tools.js +4 -2
- package/dist/domains/manage/routes/userProjectMemberships.js +1 -2
- package/dist/domains/mcp/routes/mcp.d.ts +2 -2
- package/dist/domains/run/agents/Agent.js +29 -2
- package/dist/domains/run/constants/execution-limits/defaults.d.ts +1 -1
- package/dist/domains/run/constants/execution-limits/defaults.js +1 -1
- package/dist/domains/run/constants/execution-limits/index.d.ts +1 -1
- package/dist/domains/run/context/ContextResolver.js +1 -1
- package/dist/domains/run/context/validation.d.ts +1 -1
- package/dist/domains/run/services/AgentSession.js +5 -1
- package/dist/domains/run/services/BaseCompressor.js +1 -1
- package/dist/domains/run/services/TriggerService.d.ts +1 -1
- package/dist/domains/run/services/TriggerService.js +15 -13
- package/dist/domains/run/tools/sandbox-utils.js +1 -1
- package/dist/domains/run/types/executionContext.js +3 -1
- package/dist/env.d.ts +12 -2
- package/dist/env.js +37 -32
- package/dist/factory.d.ts +7 -7
- package/dist/factory.js +4 -10
- package/dist/index.d.ts +6 -5
- 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/dist/openapi.d.ts +1 -0
- package/dist/openapi.js +1 -0
- package/dist/types/runExecutionContext.js +3 -1
- package/package.json +5 -4
- package/dist/domains/github/config.d.ts +0 -14
- package/dist/domains/github/config.js +0 -47
- package/dist/domains/github/index.d.ts +0 -12
- package/dist/domains/github/index.js +0 -18
- package/dist/domains/github/installation.d.ts +0 -34
- package/dist/domains/github/installation.js +0 -172
- package/dist/domains/github/jwks.d.ts +0 -20
- package/dist/domains/github/jwks.js +0 -85
- package/dist/domains/github/oidcToken.d.ts +0 -22
- package/dist/domains/github/oidcToken.js +0 -140
- package/dist/domains/github/routes/tokenExchange.d.ts +0 -7
- package/dist/domains/github/routes/tokenExchange.js +0 -130
- package/dist/initialization.d.ts +0 -6
- package/dist/initialization.js +0 -72
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
2
|
-
import * as
|
|
2
|
+
import * as hono1 from "hono";
|
|
3
3
|
|
|
4
4
|
//#region src/domains/manage/routes/index.d.ts
|
|
5
|
-
declare const app: OpenAPIHono<
|
|
5
|
+
declare const app: OpenAPIHono<hono1.Env, {}, "/">;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { app as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Hono } from "hono";
|
|
2
|
-
import * as
|
|
2
|
+
import * as hono_types10 from "hono/types";
|
|
3
3
|
|
|
4
4
|
//#region src/domains/manage/routes/mcp.d.ts
|
|
5
|
-
declare const app: Hono<
|
|
5
|
+
declare const app: Hono<hono_types10.BlankEnv, hono_types10.BlankSchema, "/">;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { app as default };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ManageAppVariables } from "../../../types/app.js";
|
|
2
|
+
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
3
|
+
|
|
4
|
+
//#region src/domains/manage/routes/mcpToolGithubAccess.d.ts
|
|
5
|
+
declare const app: OpenAPIHono<{
|
|
6
|
+
Variables: ManageAppVariables;
|
|
7
|
+
}, {}, "/">;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { app as default };
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { getLogger as getLogger$1 } from "../../../logger.js";
|
|
2
|
+
import runDbClient_default from "../../../data/db/runDbClient.js";
|
|
3
|
+
import { requireProjectPermission } from "../../../middleware/projectAccess.js";
|
|
4
|
+
import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
|
5
|
+
import { TenantProjectParamsSchema, WorkAppGitHubAccessModeSchema, WorkAppGitHubAccessSetRequestSchema, WorkAppGitHubAccessSetResponseSchema, WorkAppGitHubRepositorySelectSchema, commonGetErrorResponses, commonUpdateErrorResponses, createApiError, getMcpToolAccessMode, getMcpToolRepositoryAccessWithDetails, getToolById, setMcpToolAccessMode, setMcpToolRepositoryAccess, validateRepositoryOwnership } from "@inkeep/agents-core";
|
|
6
|
+
|
|
7
|
+
//#region src/domains/manage/routes/mcpToolGithubAccess.ts
|
|
8
|
+
const logger = getLogger$1("mcp-tool-github-access");
|
|
9
|
+
const app = new OpenAPIHono();
|
|
10
|
+
const TenantProjectToolParamsSchema = TenantProjectParamsSchema.extend({ toolId: z.string().min(1).describe("The tool ID") });
|
|
11
|
+
const McpToolGitHubAccessModeSchema = WorkAppGitHubAccessModeSchema.describe("Access mode: \"all\" means the MCP tool has access to all project repositories, \"selected\" means the tool is scoped to specific repositories");
|
|
12
|
+
const SetGitHubAccessRequestSchema = WorkAppGitHubAccessSetRequestSchema.extend({ mode: McpToolGitHubAccessModeSchema });
|
|
13
|
+
const GetGitHubAccessResponseSchema = z.object({
|
|
14
|
+
mode: McpToolGitHubAccessModeSchema,
|
|
15
|
+
repositories: z.array(WorkAppGitHubRepositorySelectSchema.extend({ installationAccountLogin: z.string().describe("The GitHub account login for the installation") })).describe("List of repositories the MCP tool has access to (only populated when mode=\"selected\")")
|
|
16
|
+
});
|
|
17
|
+
const SetGitHubAccessResponseSchema = WorkAppGitHubAccessSetResponseSchema.extend({
|
|
18
|
+
mode: McpToolGitHubAccessModeSchema,
|
|
19
|
+
repositoryCount: z.number().describe("Number of repositories the MCP tool now has access to (0 when mode=\"all\")")
|
|
20
|
+
});
|
|
21
|
+
async function validateGitHubWorkappTool(db, tenantId, projectId, toolId) {
|
|
22
|
+
const tool = await getToolById(db)({
|
|
23
|
+
scopes: {
|
|
24
|
+
tenantId,
|
|
25
|
+
projectId
|
|
26
|
+
},
|
|
27
|
+
toolId
|
|
28
|
+
});
|
|
29
|
+
if (!tool) throw createApiError({
|
|
30
|
+
code: "not_found",
|
|
31
|
+
message: `Tool not found: ${toolId}`
|
|
32
|
+
});
|
|
33
|
+
if (!tool.isWorkApp) throw createApiError({
|
|
34
|
+
code: "bad_request",
|
|
35
|
+
message: "GitHub access can only be configured for workapp MCP tools"
|
|
36
|
+
});
|
|
37
|
+
if (!tool.config.mcp.server.url?.includes("/github")) throw createApiError({
|
|
38
|
+
code: "bad_request",
|
|
39
|
+
message: "GitHub access can only be configured for GitHub MCP tools"
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
app.use("/", requireProjectPermission("edit"));
|
|
43
|
+
app.openapi(createRoute({
|
|
44
|
+
method: "get",
|
|
45
|
+
path: "/",
|
|
46
|
+
summary: "Get MCP tool GitHub repository access",
|
|
47
|
+
operationId: "get-mcp-tool-github-access",
|
|
48
|
+
tags: ["Tools"],
|
|
49
|
+
description: "Returns the current GitHub repository access configuration for an MCP tool. If mode is \"all\", the tool has access to all repositories the project can access. If mode is \"selected\", the tool is scoped to specific repositories. ",
|
|
50
|
+
request: { params: TenantProjectToolParamsSchema },
|
|
51
|
+
responses: {
|
|
52
|
+
200: {
|
|
53
|
+
description: "GitHub access configuration retrieved successfully",
|
|
54
|
+
content: { "application/json": { schema: GetGitHubAccessResponseSchema } }
|
|
55
|
+
},
|
|
56
|
+
...commonGetErrorResponses
|
|
57
|
+
}
|
|
58
|
+
}), async (c) => {
|
|
59
|
+
const { tenantId, projectId, toolId } = c.req.valid("param");
|
|
60
|
+
const db = c.get("db");
|
|
61
|
+
logger.info({
|
|
62
|
+
tenantId,
|
|
63
|
+
projectId,
|
|
64
|
+
toolId
|
|
65
|
+
}, "Getting MCP tool GitHub access configuration");
|
|
66
|
+
await validateGitHubWorkappTool(db, tenantId, projectId, toolId);
|
|
67
|
+
if (await getMcpToolAccessMode(runDbClient_default)(toolId) === "all") {
|
|
68
|
+
logger.info({
|
|
69
|
+
tenantId,
|
|
70
|
+
projectId,
|
|
71
|
+
toolId
|
|
72
|
+
}, "MCP tool has access to all project repositories (mode=all)");
|
|
73
|
+
return c.json({
|
|
74
|
+
mode: "all",
|
|
75
|
+
repositories: []
|
|
76
|
+
}, 200);
|
|
77
|
+
}
|
|
78
|
+
const repositoriesWithDetails = await getMcpToolRepositoryAccessWithDetails(runDbClient_default)(toolId);
|
|
79
|
+
logger.info({
|
|
80
|
+
tenantId,
|
|
81
|
+
projectId,
|
|
82
|
+
toolId,
|
|
83
|
+
repositoryCount: repositoriesWithDetails.length
|
|
84
|
+
}, "Got MCP tool GitHub access configuration (mode=selected)");
|
|
85
|
+
return c.json({
|
|
86
|
+
mode: "selected",
|
|
87
|
+
repositories: repositoriesWithDetails.map((repo) => ({
|
|
88
|
+
id: repo.id,
|
|
89
|
+
installationDbId: repo.installationDbId,
|
|
90
|
+
repositoryId: repo.repositoryId,
|
|
91
|
+
repositoryName: repo.repositoryName,
|
|
92
|
+
repositoryFullName: repo.repositoryFullName,
|
|
93
|
+
private: repo.private,
|
|
94
|
+
createdAt: repo.createdAt,
|
|
95
|
+
updatedAt: repo.updatedAt,
|
|
96
|
+
installationAccountLogin: repo.installationAccountLogin
|
|
97
|
+
}))
|
|
98
|
+
}, 200);
|
|
99
|
+
});
|
|
100
|
+
app.openapi(createRoute({
|
|
101
|
+
method: "put",
|
|
102
|
+
path: "/",
|
|
103
|
+
summary: "Set MCP tool GitHub repository access",
|
|
104
|
+
operationId: "set-mcp-tool-github-access",
|
|
105
|
+
tags: ["Tools"],
|
|
106
|
+
description: "Configures which GitHub repositories an MCP tool can access. When mode is \"all\", the tool has access to all repositories the project can access. When mode is \"selected\", the tool is scoped to specific repositories (repositoryIds required). This replaces any existing access configuration. This endpoint only works for GitHub workapp MCP tools (isWorkApp=true and URL contains /github).",
|
|
107
|
+
request: {
|
|
108
|
+
params: TenantProjectToolParamsSchema,
|
|
109
|
+
body: { content: { "application/json": { schema: SetGitHubAccessRequestSchema } } }
|
|
110
|
+
},
|
|
111
|
+
responses: {
|
|
112
|
+
200: {
|
|
113
|
+
description: "GitHub access configuration updated successfully",
|
|
114
|
+
content: { "application/json": { schema: SetGitHubAccessResponseSchema } }
|
|
115
|
+
},
|
|
116
|
+
...commonUpdateErrorResponses
|
|
117
|
+
}
|
|
118
|
+
}), async (c) => {
|
|
119
|
+
const { tenantId, projectId, toolId } = c.req.valid("param");
|
|
120
|
+
const { mode, repositoryIds } = c.req.valid("json");
|
|
121
|
+
const db = c.get("db");
|
|
122
|
+
logger.info({
|
|
123
|
+
tenantId,
|
|
124
|
+
projectId,
|
|
125
|
+
toolId,
|
|
126
|
+
mode
|
|
127
|
+
}, "Setting MCP tool GitHub access configuration");
|
|
128
|
+
await validateGitHubWorkappTool(db, tenantId, projectId, toolId);
|
|
129
|
+
if (mode === "selected") {
|
|
130
|
+
if (!repositoryIds || repositoryIds.length === 0) {
|
|
131
|
+
logger.warn({
|
|
132
|
+
tenantId,
|
|
133
|
+
projectId,
|
|
134
|
+
toolId
|
|
135
|
+
}, "repositoryIds required when mode is selected");
|
|
136
|
+
throw createApiError({
|
|
137
|
+
code: "bad_request",
|
|
138
|
+
message: "repositoryIds is required when mode is \"selected\""
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
const invalidRepoIds = await validateRepositoryOwnership(runDbClient_default)({
|
|
142
|
+
tenantId,
|
|
143
|
+
repositoryIds
|
|
144
|
+
});
|
|
145
|
+
if (invalidRepoIds.length > 0) {
|
|
146
|
+
logger.warn({
|
|
147
|
+
tenantId,
|
|
148
|
+
projectId,
|
|
149
|
+
toolId,
|
|
150
|
+
invalidRepoIds
|
|
151
|
+
}, "Some repository IDs do not belong to tenant installations");
|
|
152
|
+
throw createApiError({
|
|
153
|
+
code: "bad_request",
|
|
154
|
+
message: `Invalid repository IDs: ${invalidRepoIds.join(", ")}. Repositories must belong to GitHub installations owned by this tenant.`
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
await setMcpToolAccessMode(runDbClient_default)({
|
|
158
|
+
toolId,
|
|
159
|
+
tenantId,
|
|
160
|
+
projectId,
|
|
161
|
+
mode: "selected"
|
|
162
|
+
});
|
|
163
|
+
await setMcpToolRepositoryAccess(runDbClient_default)({
|
|
164
|
+
toolId,
|
|
165
|
+
tenantId,
|
|
166
|
+
projectId,
|
|
167
|
+
repositoryIds
|
|
168
|
+
});
|
|
169
|
+
logger.info({
|
|
170
|
+
tenantId,
|
|
171
|
+
projectId,
|
|
172
|
+
toolId,
|
|
173
|
+
repositoryCount: repositoryIds.length
|
|
174
|
+
}, "MCP tool GitHub access set to selected repositories");
|
|
175
|
+
return c.json({
|
|
176
|
+
mode: "selected",
|
|
177
|
+
repositoryCount: repositoryIds.length
|
|
178
|
+
}, 200);
|
|
179
|
+
}
|
|
180
|
+
await setMcpToolAccessMode(runDbClient_default)({
|
|
181
|
+
toolId,
|
|
182
|
+
tenantId,
|
|
183
|
+
projectId,
|
|
184
|
+
mode: "all"
|
|
185
|
+
});
|
|
186
|
+
await setMcpToolRepositoryAccess(runDbClient_default)({
|
|
187
|
+
toolId,
|
|
188
|
+
tenantId,
|
|
189
|
+
projectId,
|
|
190
|
+
repositoryIds: []
|
|
191
|
+
});
|
|
192
|
+
logger.info({
|
|
193
|
+
tenantId,
|
|
194
|
+
projectId,
|
|
195
|
+
toolId
|
|
196
|
+
}, "MCP tool GitHub access set to all project repositories");
|
|
197
|
+
return c.json({
|
|
198
|
+
mode: "all",
|
|
199
|
+
repositoryCount: 0
|
|
200
|
+
}, 200);
|
|
201
|
+
});
|
|
202
|
+
var mcpToolGithubAccess_default = app;
|
|
203
|
+
|
|
204
|
+
//#endregion
|
|
205
|
+
export { mcpToolGithubAccess_default as default };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ManageAppVariables } from "../../../types/app.js";
|
|
2
|
+
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
3
|
+
|
|
4
|
+
//#region src/domains/manage/routes/projectGithubAccess.d.ts
|
|
5
|
+
declare const app: OpenAPIHono<{
|
|
6
|
+
Variables: ManageAppVariables;
|
|
7
|
+
}, {}, "/">;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { app as default };
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { getLogger as getLogger$1 } from "../../../logger.js";
|
|
2
|
+
import runDbClient_default from "../../../data/db/runDbClient.js";
|
|
3
|
+
import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
|
4
|
+
import { TenantProjectParamsSchema, WorkAppGitHubAccessGetResponseSchema, WorkAppGitHubAccessModeSchema, WorkAppGitHubAccessSetRequestSchema, WorkAppGitHubAccessSetResponseSchema, commonGetErrorResponses, commonUpdateErrorResponses, createApiError, getProjectAccessMode, getProjectRepositoryAccessWithDetails, setProjectAccessMode, setProjectRepositoryAccess, validateRepositoryOwnership } from "@inkeep/agents-core";
|
|
5
|
+
|
|
6
|
+
//#region src/domains/manage/routes/projectGithubAccess.ts
|
|
7
|
+
const logger = getLogger$1("project-github-access");
|
|
8
|
+
const app = new OpenAPIHono();
|
|
9
|
+
const ProjectGitHubAccessModeSchema = WorkAppGitHubAccessModeSchema.describe("Access mode: \"all\" means project has access to all tenant repositories, \"selected\" means project is scoped to specific repositories");
|
|
10
|
+
const SetGitHubAccessRequestSchema = WorkAppGitHubAccessSetRequestSchema.extend({ mode: ProjectGitHubAccessModeSchema });
|
|
11
|
+
const GetGitHubAccessResponseSchema = WorkAppGitHubAccessGetResponseSchema.extend({ mode: ProjectGitHubAccessModeSchema }).describe("GitHub access configuration for a project");
|
|
12
|
+
const SetGitHubAccessResponseSchema = WorkAppGitHubAccessSetResponseSchema.extend({
|
|
13
|
+
mode: ProjectGitHubAccessModeSchema,
|
|
14
|
+
repositoryCount: z.number().describe("Number of repositories the project now has access to (0 when mode=\"all\")")
|
|
15
|
+
});
|
|
16
|
+
app.openapi(createRoute({
|
|
17
|
+
method: "get",
|
|
18
|
+
path: "/",
|
|
19
|
+
summary: "Get project GitHub repository access",
|
|
20
|
+
operationId: "get-project-github-access",
|
|
21
|
+
tags: ["Projects"],
|
|
22
|
+
description: "Returns the current GitHub repository access configuration for a project. If mode is \"all\", the project has access to all repositories from tenant GitHub installations. If mode is \"selected\", the project is scoped to specific repositories.",
|
|
23
|
+
request: { params: TenantProjectParamsSchema },
|
|
24
|
+
responses: {
|
|
25
|
+
200: {
|
|
26
|
+
description: "GitHub access configuration retrieved successfully",
|
|
27
|
+
content: { "application/json": { schema: GetGitHubAccessResponseSchema } }
|
|
28
|
+
},
|
|
29
|
+
...commonGetErrorResponses
|
|
30
|
+
}
|
|
31
|
+
}), async (c) => {
|
|
32
|
+
const { tenantId, projectId } = c.req.valid("param");
|
|
33
|
+
logger.info({
|
|
34
|
+
tenantId,
|
|
35
|
+
projectId
|
|
36
|
+
}, "Getting project GitHub access configuration");
|
|
37
|
+
if (await getProjectAccessMode(runDbClient_default)({
|
|
38
|
+
tenantId,
|
|
39
|
+
projectId
|
|
40
|
+
}) === "all") {
|
|
41
|
+
logger.info({
|
|
42
|
+
tenantId,
|
|
43
|
+
projectId
|
|
44
|
+
}, "Project has access to all repositories (mode=all)");
|
|
45
|
+
return c.json({
|
|
46
|
+
mode: "all",
|
|
47
|
+
repositories: []
|
|
48
|
+
}, 200);
|
|
49
|
+
}
|
|
50
|
+
const repositoriesWithDetails = await getProjectRepositoryAccessWithDetails(runDbClient_default)({
|
|
51
|
+
tenantId,
|
|
52
|
+
projectId
|
|
53
|
+
});
|
|
54
|
+
logger.info({
|
|
55
|
+
tenantId,
|
|
56
|
+
projectId,
|
|
57
|
+
repositoryCount: repositoriesWithDetails.length
|
|
58
|
+
}, "Got project GitHub access configuration (mode=selected)");
|
|
59
|
+
return c.json({
|
|
60
|
+
mode: "selected",
|
|
61
|
+
repositories: repositoriesWithDetails.map((repo) => ({
|
|
62
|
+
id: repo.id,
|
|
63
|
+
installationDbId: repo.installationDbId,
|
|
64
|
+
repositoryId: repo.repositoryId,
|
|
65
|
+
repositoryName: repo.repositoryName,
|
|
66
|
+
repositoryFullName: repo.repositoryFullName,
|
|
67
|
+
private: repo.private,
|
|
68
|
+
createdAt: repo.createdAt,
|
|
69
|
+
updatedAt: repo.updatedAt
|
|
70
|
+
}))
|
|
71
|
+
}, 200);
|
|
72
|
+
});
|
|
73
|
+
app.openapi(createRoute({
|
|
74
|
+
method: "put",
|
|
75
|
+
path: "/",
|
|
76
|
+
summary: "Set project GitHub repository access",
|
|
77
|
+
operationId: "set-project-github-access",
|
|
78
|
+
tags: ["Projects"],
|
|
79
|
+
description: "Configures which GitHub repositories a project can access. When mode is \"all\", the project has access to all repositories from tenant GitHub installations. When mode is \"selected\", the project is scoped to specific repositories (repositoryIds required). This replaces any existing access configuration.",
|
|
80
|
+
request: {
|
|
81
|
+
params: TenantProjectParamsSchema,
|
|
82
|
+
body: { content: { "application/json": { schema: SetGitHubAccessRequestSchema } } }
|
|
83
|
+
},
|
|
84
|
+
responses: {
|
|
85
|
+
200: {
|
|
86
|
+
description: "GitHub access configuration updated successfully",
|
|
87
|
+
content: { "application/json": { schema: SetGitHubAccessResponseSchema } }
|
|
88
|
+
},
|
|
89
|
+
...commonUpdateErrorResponses
|
|
90
|
+
}
|
|
91
|
+
}), async (c) => {
|
|
92
|
+
const { tenantId, projectId } = c.req.valid("param");
|
|
93
|
+
const { mode, repositoryIds } = c.req.valid("json");
|
|
94
|
+
logger.info({
|
|
95
|
+
tenantId,
|
|
96
|
+
projectId,
|
|
97
|
+
mode
|
|
98
|
+
}, "Setting project GitHub access configuration");
|
|
99
|
+
if (mode === "selected") {
|
|
100
|
+
if (!repositoryIds || repositoryIds.length === 0) {
|
|
101
|
+
logger.warn({
|
|
102
|
+
tenantId,
|
|
103
|
+
projectId
|
|
104
|
+
}, "repositoryIds required when mode is selected");
|
|
105
|
+
throw createApiError({
|
|
106
|
+
code: "bad_request",
|
|
107
|
+
message: "repositoryIds is required when mode is \"selected\""
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
const invalidRepoIds = await validateRepositoryOwnership(runDbClient_default)({
|
|
111
|
+
tenantId,
|
|
112
|
+
repositoryIds
|
|
113
|
+
});
|
|
114
|
+
if (invalidRepoIds.length > 0) {
|
|
115
|
+
logger.warn({
|
|
116
|
+
tenantId,
|
|
117
|
+
projectId,
|
|
118
|
+
invalidRepoIds
|
|
119
|
+
}, "Some repository IDs do not belong to tenant installations");
|
|
120
|
+
throw createApiError({
|
|
121
|
+
code: "bad_request",
|
|
122
|
+
message: `Invalid repository IDs: ${invalidRepoIds.join(", ")}. Repositories must belong to GitHub installations owned by this tenant.`
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
await setProjectAccessMode(runDbClient_default)({
|
|
126
|
+
tenantId,
|
|
127
|
+
projectId,
|
|
128
|
+
mode: "selected"
|
|
129
|
+
});
|
|
130
|
+
await setProjectRepositoryAccess(runDbClient_default)({
|
|
131
|
+
tenantId,
|
|
132
|
+
projectId,
|
|
133
|
+
repositoryIds
|
|
134
|
+
});
|
|
135
|
+
logger.info({
|
|
136
|
+
tenantId,
|
|
137
|
+
projectId,
|
|
138
|
+
repositoryCount: repositoryIds.length
|
|
139
|
+
}, "Project GitHub access set to selected repositories");
|
|
140
|
+
return c.json({
|
|
141
|
+
mode: "selected",
|
|
142
|
+
repositoryCount: repositoryIds.length
|
|
143
|
+
}, 200);
|
|
144
|
+
}
|
|
145
|
+
await setProjectAccessMode(runDbClient_default)({
|
|
146
|
+
tenantId,
|
|
147
|
+
projectId,
|
|
148
|
+
mode: "all"
|
|
149
|
+
});
|
|
150
|
+
await setProjectRepositoryAccess(runDbClient_default)({
|
|
151
|
+
tenantId,
|
|
152
|
+
projectId,
|
|
153
|
+
repositoryIds: []
|
|
154
|
+
});
|
|
155
|
+
logger.info({
|
|
156
|
+
tenantId,
|
|
157
|
+
projectId
|
|
158
|
+
}, "Project GitHub access set to all repositories");
|
|
159
|
+
return c.json({
|
|
160
|
+
mode: "all",
|
|
161
|
+
repositoryCount: 0
|
|
162
|
+
}, 200);
|
|
163
|
+
});
|
|
164
|
+
var projectGithubAccess_default = app;
|
|
165
|
+
|
|
166
|
+
//#endregion
|
|
167
|
+
export { projectGithubAccess_default as default };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { requireProjectPermission } from "../../../middleware/projectAccess.js";
|
|
2
2
|
import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
|
3
|
-
import { ProjectRoles, changeProjectRole, commonGetErrorResponses, createApiError, grantProjectAccess,
|
|
3
|
+
import { ProjectRoles, changeProjectRole, commonGetErrorResponses, createApiError, grantProjectAccess, listProjectMembers, revokeProjectAccess } from "@inkeep/agents-core";
|
|
4
4
|
|
|
5
5
|
//#region src/domains/manage/routes/projectMembers.ts
|
|
6
6
|
const app = new OpenAPIHono();
|
|
@@ -51,7 +51,6 @@ app.openapi(createRoute({
|
|
|
51
51
|
}
|
|
52
52
|
}), async (c) => {
|
|
53
53
|
const { projectId, tenantId } = c.req.valid("param");
|
|
54
|
-
if (!isAuthzEnabled()) return c.json({ data: [] });
|
|
55
54
|
const members = await listProjectMembers({
|
|
56
55
|
tenantId,
|
|
57
56
|
projectId
|
|
@@ -83,10 +82,6 @@ app.openapi(createRoute({
|
|
|
83
82
|
}), async (c) => {
|
|
84
83
|
const { projectId, tenantId } = c.req.valid("param");
|
|
85
84
|
const { userId, role } = c.req.valid("json");
|
|
86
|
-
if (!isAuthzEnabled()) throw createApiError({
|
|
87
|
-
code: "bad_request",
|
|
88
|
-
message: "Project member management requires authorization to be enabled (ENABLE_AUTHZ=true)"
|
|
89
|
-
});
|
|
90
85
|
await grantProjectAccess({
|
|
91
86
|
tenantId,
|
|
92
87
|
projectId,
|
|
@@ -120,10 +115,6 @@ app.openapi(createRoute({
|
|
|
120
115
|
}), async (c) => {
|
|
121
116
|
const { projectId, userId, tenantId } = c.req.valid("param");
|
|
122
117
|
const { role: newRole, previousRole } = c.req.valid("json");
|
|
123
|
-
if (!isAuthzEnabled()) throw createApiError({
|
|
124
|
-
code: "bad_request",
|
|
125
|
-
message: "Project member management requires authorization to be enabled (ENABLE_AUTHZ=true)"
|
|
126
|
-
});
|
|
127
118
|
if (!previousRole) throw createApiError({
|
|
128
119
|
code: "bad_request",
|
|
129
120
|
message: "previousRole is required to update a member role"
|
|
@@ -164,10 +155,6 @@ app.openapi(createRoute({
|
|
|
164
155
|
}), async (c) => {
|
|
165
156
|
const { projectId, userId, tenantId } = c.req.valid("param");
|
|
166
157
|
const { role } = c.req.valid("query");
|
|
167
|
-
if (!isAuthzEnabled()) throw createApiError({
|
|
168
|
-
code: "bad_request",
|
|
169
|
-
message: "Project member management requires authorization to be enabled (ENABLE_AUTHZ=true)"
|
|
170
|
-
});
|
|
171
158
|
await revokeProjectAccess({
|
|
172
159
|
tenantId,
|
|
173
160
|
projectId,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { env } from "../../../env.js";
|
|
2
1
|
import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
|
3
|
-
import { OrgRoles, SpiceDbProjectPermissions, SpiceDbResourceTypes, checkBulkPermissions, commonGetErrorResponses, createApiError
|
|
2
|
+
import { OrgRoles, SpiceDbProjectPermissions, SpiceDbResourceTypes, checkBulkPermissions, commonGetErrorResponses, createApiError } from "@inkeep/agents-core";
|
|
4
3
|
|
|
5
4
|
//#region src/domains/manage/routes/projectPermissions.ts
|
|
6
5
|
const app = new OpenAPIHono();
|
|
@@ -32,8 +31,7 @@ app.openapi(createRoute({
|
|
|
32
31
|
const { projectId } = c.req.valid("param");
|
|
33
32
|
const userId = c.get("userId");
|
|
34
33
|
const tenantRole = c.get("tenantRole");
|
|
35
|
-
|
|
36
|
-
if (env.DISABLE_AUTH || isTestEnvironment) return c.json({ data: {
|
|
34
|
+
if (process.env.ENVIRONMENT === "test") return c.json({ data: {
|
|
37
35
|
canView: true,
|
|
38
36
|
canUse: true,
|
|
39
37
|
canEdit: true
|
|
@@ -43,11 +41,6 @@ app.openapi(createRoute({
|
|
|
43
41
|
canUse: true,
|
|
44
42
|
canEdit: true
|
|
45
43
|
} });
|
|
46
|
-
if (!isAuthzEnabled()) return c.json({ data: {
|
|
47
|
-
canView: true,
|
|
48
|
-
canUse: true,
|
|
49
|
-
canEdit: false
|
|
50
|
-
} });
|
|
51
44
|
if (!userId) throw createApiError({
|
|
52
45
|
code: "unauthorized",
|
|
53
46
|
message: "User not found"
|
|
@@ -4,7 +4,7 @@ import { requireProjectPermission } from "../../../middleware/projectAccess.js";
|
|
|
4
4
|
import { speakeasyOffsetLimitPagination } from "../../../utils/speakeasy.js";
|
|
5
5
|
import { requirePermission } from "../../../middleware/requirePermission.js";
|
|
6
6
|
import { OpenAPIHono, createRoute } from "@hono/zod-openapi";
|
|
7
|
-
import { ErrorResponseSchema, PaginationQueryParamsSchema, ProjectApiInsertSchema, ProjectApiUpdateSchema, ProjectListResponse, ProjectResponse, TenantIdParamsSchema, TenantParamsSchema, cascadeDeleteByProject, commonGetErrorResponses, createApiError, createProject, createProjectMetadataAndBranch, deleteProject, deleteProjectWithBranch, doltCheckout, getProject, getProjectMainBranchName,
|
|
7
|
+
import { ErrorResponseSchema, PaginationQueryParamsSchema, ProjectApiInsertSchema, ProjectApiUpdateSchema, ProjectListResponse, ProjectResponse, TenantIdParamsSchema, TenantParamsSchema, cascadeDeleteByProject, commonGetErrorResponses, createApiError, createProject, createProjectMetadataAndBranch, deleteProject, deleteProjectWithBranch, doltCheckout, getProject, getProjectMainBranchName, listAccessibleProjectIds, listProjectsWithMetadataPaginated, removeProjectFromSpiceDb, syncProjectToSpiceDb, updateProject } from "@inkeep/agents-core";
|
|
8
8
|
|
|
9
9
|
//#region src/domains/manage/routes/projects.ts
|
|
10
10
|
const app = new OpenAPIHono();
|
|
@@ -45,7 +45,7 @@ app.openapi(createRoute({
|
|
|
45
45
|
const page = Number(c.req.query("page")) || 1;
|
|
46
46
|
const limit = Math.min(Number(c.req.query("limit")) || 10, 100);
|
|
47
47
|
let accessibleIds;
|
|
48
|
-
if (
|
|
48
|
+
if (userId) {
|
|
49
49
|
const result$1 = await listAccessibleProjectIds({
|
|
50
50
|
userId,
|
|
51
51
|
orgRole: tenantRole
|
|
@@ -148,20 +148,18 @@ app.openapi(createRoute({
|
|
|
148
148
|
tenantId,
|
|
149
149
|
...body
|
|
150
150
|
});
|
|
151
|
-
if (
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
151
|
+
if (!userId) throw createApiError({
|
|
152
|
+
code: "unauthorized",
|
|
153
|
+
message: "User not found"
|
|
154
|
+
});
|
|
155
|
+
try {
|
|
156
|
+
await syncProjectToSpiceDb({
|
|
157
|
+
tenantId,
|
|
158
|
+
projectId: body.id,
|
|
159
|
+
creatorUserId: userId
|
|
155
160
|
});
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
tenantId,
|
|
159
|
-
projectId: body.id,
|
|
160
|
-
creatorUserId: userId
|
|
161
|
-
});
|
|
162
|
-
} catch (syncError) {
|
|
163
|
-
console.warn("Failed to sync project to SpiceDB:", syncError);
|
|
164
|
-
}
|
|
161
|
+
} catch (syncError) {
|
|
162
|
+
console.warn("Failed to sync project to SpiceDB:", syncError);
|
|
165
163
|
}
|
|
166
164
|
return c.json({ data: {
|
|
167
165
|
...projectConfig,
|
|
@@ -255,7 +253,7 @@ app.openapi(createRoute({
|
|
|
255
253
|
code: "not_found",
|
|
256
254
|
message: "Project not found"
|
|
257
255
|
});
|
|
258
|
-
|
|
256
|
+
try {
|
|
259
257
|
await removeProjectFromSpiceDb({
|
|
260
258
|
tenantId,
|
|
261
259
|
projectId: id
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ManageAppVariables } from "../../../types/app.js";
|
|
2
2
|
import { Hono } from "hono";
|
|
3
|
-
import * as
|
|
3
|
+
import * as hono_types7 from "hono/types";
|
|
4
4
|
|
|
5
5
|
//#region src/domains/manage/routes/signoz.d.ts
|
|
6
6
|
declare const app: Hono<{
|
|
7
7
|
Variables: ManageAppVariables;
|
|
8
|
-
},
|
|
8
|
+
}, hono_types7.BlankSchema, "/">;
|
|
9
9
|
//#endregion
|
|
10
10
|
export { app as default };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getLogger as getLogger$1 } from "../../../logger.js";
|
|
2
2
|
import { env } from "../../../env.js";
|
|
3
3
|
import { enforceSecurityFilters } from "../../../utils/signozHelpers.js";
|
|
4
|
-
import { Hono } from "hono";
|
|
5
4
|
import { createApiError, projectExists } from "@inkeep/agents-core";
|
|
5
|
+
import { Hono } from "hono";
|
|
6
6
|
import axios from "axios";
|
|
7
7
|
|
|
8
8
|
//#region src/domains/manage/routes/signoz.ts
|
|
@@ -161,7 +161,8 @@ app.openapi(createRoute({
|
|
|
161
161
|
credentialReferenceId: body.credentialReferenceId,
|
|
162
162
|
credentialScope: body.credentialScope,
|
|
163
163
|
imageUrl: body.imageUrl,
|
|
164
|
-
headers: body.headers
|
|
164
|
+
headers: body.headers,
|
|
165
|
+
isWorkApp: body.isWorkApp
|
|
165
166
|
});
|
|
166
167
|
return c.json({ data: await dbResultToMcpTool(tool, db, credentialStores, void 0, userId) }, 201);
|
|
167
168
|
});
|
|
@@ -204,7 +205,8 @@ app.openapi(createRoute({
|
|
|
204
205
|
credentialReferenceId: body.credentialReferenceId,
|
|
205
206
|
credentialScope: body.credentialScope,
|
|
206
207
|
imageUrl: body.imageUrl,
|
|
207
|
-
headers: body.headers
|
|
208
|
+
headers: body.headers,
|
|
209
|
+
isWorkApp: body.isWorkApp
|
|
208
210
|
}
|
|
209
211
|
});
|
|
210
212
|
if (!updatedTool) throw createApiError({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
|
2
|
-
import { ProjectRoles, commonGetErrorResponses,
|
|
2
|
+
import { ProjectRoles, commonGetErrorResponses, listUserProjectMembershipsInSpiceDb } from "@inkeep/agents-core";
|
|
3
3
|
|
|
4
4
|
//#region src/domains/manage/routes/userProjectMemberships.ts
|
|
5
5
|
const app = new OpenAPIHono();
|
|
@@ -32,7 +32,6 @@ app.openapi(createRoute({
|
|
|
32
32
|
}
|
|
33
33
|
}), async (c) => {
|
|
34
34
|
const { tenantId, userId } = c.req.valid("param");
|
|
35
|
-
if (!isAuthzEnabled()) return c.json({ data: [] });
|
|
36
35
|
const memberships = await listUserProjectMembershipsInSpiceDb({
|
|
37
36
|
tenantId,
|
|
38
37
|
userId
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Hono } from "hono";
|
|
2
|
-
import * as
|
|
2
|
+
import * as hono_types8 from "hono/types";
|
|
3
3
|
|
|
4
4
|
//#region src/domains/mcp/routes/mcp.d.ts
|
|
5
|
-
declare const app: Hono<
|
|
5
|
+
declare const app: Hono<hono_types8.BlankEnv, hono_types8.BlankSchema, "/">;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { app as default };
|