@inkeep/agents-api 0.0.0-dev-20260202060901 → 0.0.0-dev-20260203023016
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 +16 -16
- package/dist/.well-known/workflow/v1/step.cjs +57211 -56922
- package/dist/createApp.d.ts +2 -2
- package/dist/createApp.js +3 -3
- 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/evals/evaluationResults.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/tools.js +4 -2
- package/dist/domains/mcp/routes/mcp.d.ts +2 -2
- package/dist/domains/run/agents/Agent.js +7 -1
- 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/services/AgentSession.js +5 -1
- package/dist/domains/run/services/BaseCompressor.js +1 -1
- package/dist/domains/run/types/executionContext.js +3 -1
- package/dist/env.d.ts +12 -0
- package/dist/env.js +7 -1
- package/dist/factory.d.ts +261 -261
- package/dist/index.d.ts +261 -261
- package/dist/middleware/evalsAuth.d.ts +2 -2
- package/dist/middleware/manageAuth.d.ts +2 -2
- package/dist/middleware/projectAccess.d.ts +2 -2
- package/dist/middleware/projectConfig.d.ts +3 -3
- package/dist/middleware/requirePermission.d.ts +2 -2
- package/dist/middleware/runAuth.d.ts +4 -4
- package/dist/middleware/sessionAuth.d.ts +3 -3
- 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
|
@@ -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 };
|
|
@@ -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,7 +1,7 @@
|
|
|
1
1
|
import { Hono } from "hono";
|
|
2
|
-
import * as
|
|
2
|
+
import * as hono_types9 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_types9.BlankEnv, hono_types9.BlankSchema, "/">;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { app as default };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getLogger as getLogger$1 } from "../../../logger.js";
|
|
2
|
+
import { env } from "../../../env.js";
|
|
2
3
|
import manageDbPool_default from "../../../data/db/manageDbPool.js";
|
|
3
4
|
import runDbClient_default from "../../../data/db/runDbClient.js";
|
|
4
5
|
import { AGENT_EXECUTION_MAX_GENERATION_STEPS, FUNCTION_TOOL_EXECUTION_TIMEOUT_MS_DEFAULT, FUNCTION_TOOL_SANDBOX_VCPUS_DEFAULT, LLM_GENERATION_FIRST_CALL_TIMEOUT_MS_NON_STREAMING, LLM_GENERATION_FIRST_CALL_TIMEOUT_MS_STREAMING, LLM_GENERATION_MAX_ALLOWED_TIMEOUT_MS, LLM_GENERATION_SUBSEQUENT_CALL_TIMEOUT_MS } from "../constants/execution-limits/index.js";
|
|
@@ -26,7 +27,7 @@ import { SystemPromptBuilder } from "./SystemPromptBuilder.js";
|
|
|
26
27
|
import { Phase1Config, V1_BREAKDOWN_SCHEMA } from "./versions/v1/Phase1Config.js";
|
|
27
28
|
import { Phase2Config } from "./versions/v1/Phase2Config.js";
|
|
28
29
|
import { z } from "@hono/zod-openapi";
|
|
29
|
-
import { CredentialStuffer, JsonTransformer, MCPServerType, MCPTransportType, McpClient, ModelFactory, TemplateEngine, buildComposioMCPUrl, createMessage, generateId, getFunctionToolsForSubAgent, getLedgerArtifacts, listTaskIdsByContextId, parseEmbeddedJson, withRef } from "@inkeep/agents-core";
|
|
30
|
+
import { CredentialStuffer, JsonTransformer, MCPServerType, MCPTransportType, McpClient, ModelFactory, TemplateEngine, buildComposioMCPUrl, createMessage, generateId, getFunctionToolsForSubAgent, getLedgerArtifacts, isGithubWorkAppTool, listTaskIdsByContextId, parseEmbeddedJson, withRef } from "@inkeep/agents-core";
|
|
30
31
|
import { Output, generateText, streamText, tool } from "ai";
|
|
31
32
|
import { SpanStatusCode, trace } from "@opentelemetry/api";
|
|
32
33
|
|
|
@@ -681,6 +682,11 @@ var Agent = class {
|
|
|
681
682
|
headers: agentToolRelationHeaders
|
|
682
683
|
};
|
|
683
684
|
}
|
|
685
|
+
if (isGithubWorkAppTool(tool$1)) serverConfig.headers = {
|
|
686
|
+
...serverConfig.headers,
|
|
687
|
+
"x-inkeep-tool-id": tool$1.id,
|
|
688
|
+
Authorization: `Bearer ${env.GITHUB_MCP_API_KEY}`
|
|
689
|
+
};
|
|
684
690
|
if (serverConfig.url) serverConfig.url = buildComposioMCPUrl(serverConfig.url.toString(), this.config.tenantId, this.config.projectId, isUserScoped ? "user" : "project", userId);
|
|
685
691
|
if (this.config.forwardedHeaders && Object.keys(this.config.forwardedHeaders).length > 0) serverConfig.headers = {
|
|
686
692
|
...serverConfig.headers,
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
declare const executionLimitsDefaults: {
|
|
7
7
|
readonly AGENT_EXECUTION_MAX_CONSECUTIVE_ERRORS: 3;
|
|
8
|
-
readonly AGENT_EXECUTION_MAX_GENERATION_STEPS:
|
|
8
|
+
readonly AGENT_EXECUTION_MAX_GENERATION_STEPS: 50;
|
|
9
9
|
readonly LLM_GENERATION_FIRST_CALL_TIMEOUT_MS_STREAMING: 270000;
|
|
10
10
|
readonly LLM_GENERATION_FIRST_CALL_TIMEOUT_MS_NON_STREAMING: 90000;
|
|
11
11
|
readonly LLM_GENERATION_SUBSEQUENT_CALL_TIMEOUT_MS: 90000;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
const executionLimitsDefaults = {
|
|
7
7
|
AGENT_EXECUTION_MAX_CONSECUTIVE_ERRORS: 3,
|
|
8
|
-
AGENT_EXECUTION_MAX_GENERATION_STEPS:
|
|
8
|
+
AGENT_EXECUTION_MAX_GENERATION_STEPS: 50,
|
|
9
9
|
LLM_GENERATION_FIRST_CALL_TIMEOUT_MS_STREAMING: 27e4,
|
|
10
10
|
LLM_GENERATION_FIRST_CALL_TIMEOUT_MS_NON_STREAMING: 9e4,
|
|
11
11
|
LLM_GENERATION_SUBSEQUENT_CALL_TIMEOUT_MS: 9e4,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { executionLimitsDefaults } from "./defaults.js";
|
|
2
2
|
|
|
3
3
|
//#region src/domains/run/constants/execution-limits/index.d.ts
|
|
4
|
-
declare const AGENT_EXECUTION_MAX_CONSECUTIVE_ERRORS: 3, AGENT_EXECUTION_MAX_GENERATION_STEPS:
|
|
4
|
+
declare const AGENT_EXECUTION_MAX_CONSECUTIVE_ERRORS: 3, AGENT_EXECUTION_MAX_GENERATION_STEPS: 50, LLM_GENERATION_FIRST_CALL_TIMEOUT_MS_STREAMING: 270000, LLM_GENERATION_FIRST_CALL_TIMEOUT_MS_NON_STREAMING: 90000, LLM_GENERATION_SUBSEQUENT_CALL_TIMEOUT_MS: 90000, LLM_GENERATION_MAX_ALLOWED_TIMEOUT_MS: 600000, FUNCTION_TOOL_EXECUTION_TIMEOUT_MS_DEFAULT: 30000, FUNCTION_TOOL_SANDBOX_VCPUS_DEFAULT: 4, FUNCTION_TOOL_SANDBOX_POOL_TTL_MS: 300000, FUNCTION_TOOL_SANDBOX_MAX_USE_COUNT: 50, FUNCTION_TOOL_SANDBOX_MAX_OUTPUT_SIZE_BYTES: 1048576, FUNCTION_TOOL_SANDBOX_QUEUE_WAIT_TIMEOUT_MS: 30000, FUNCTION_TOOL_SANDBOX_CLEANUP_INTERVAL_MS: 60000, MCP_TOOL_REQUEST_TIMEOUT_MS_DEFAULT: 60000, DELEGATION_TOOL_BACKOFF_INITIAL_INTERVAL_MS: 100, DELEGATION_TOOL_BACKOFF_MAX_INTERVAL_MS: 10000, DELEGATION_TOOL_BACKOFF_EXPONENT: 2, DELEGATION_TOOL_BACKOFF_MAX_ELAPSED_TIME_MS: 20000, A2A_BACKOFF_INITIAL_INTERVAL_MS: 500, A2A_BACKOFF_MAX_INTERVAL_MS: 60000, A2A_BACKOFF_EXPONENT: 1.5, A2A_BACKOFF_MAX_ELAPSED_TIME_MS: 30000, ARTIFACT_GENERATION_MAX_RETRIES: 3, ARTIFACT_SESSION_MAX_PENDING: 100, ARTIFACT_SESSION_MAX_PREVIOUS_SUMMARIES: 3, ARTIFACT_GENERATION_BACKOFF_INITIAL_MS: 1000, ARTIFACT_GENERATION_BACKOFF_MAX_MS: 10000, SESSION_TOOL_RESULT_CACHE_TIMEOUT_MS: 300000, SESSION_CLEANUP_INTERVAL_MS: 60000, STATUS_UPDATE_DEFAULT_NUM_EVENTS: 1, STATUS_UPDATE_DEFAULT_INTERVAL_SECONDS: 2, STREAM_PARSER_MAX_SNAPSHOT_SIZE: 100, STREAM_PARSER_MAX_STREAMED_SIZE: 1000, STREAM_PARSER_MAX_COLLECTED_PARTS: 10000, STREAM_BUFFER_MAX_SIZE_BYTES: 5242880, STREAM_TEXT_GAP_THRESHOLD_MS: 2000, STREAM_MAX_LIFETIME_MS: 600000, CONVERSATION_HISTORY_DEFAULT_LIMIT: 50, CONVERSATION_ARTIFACTS_LIMIT: 12, COMPRESSION_HARD_LIMIT: 120000, COMPRESSION_SAFETY_BUFFER: 20000, COMPRESSION_ENABLED: true;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { A2A_BACKOFF_EXPONENT, A2A_BACKOFF_INITIAL_INTERVAL_MS, A2A_BACKOFF_MAX_ELAPSED_TIME_MS, A2A_BACKOFF_MAX_INTERVAL_MS, AGENT_EXECUTION_MAX_CONSECUTIVE_ERRORS, AGENT_EXECUTION_MAX_GENERATION_STEPS, ARTIFACT_GENERATION_BACKOFF_INITIAL_MS, ARTIFACT_GENERATION_BACKOFF_MAX_MS, ARTIFACT_GENERATION_MAX_RETRIES, ARTIFACT_SESSION_MAX_PENDING, ARTIFACT_SESSION_MAX_PREVIOUS_SUMMARIES, COMPRESSION_ENABLED, COMPRESSION_HARD_LIMIT, COMPRESSION_SAFETY_BUFFER, CONVERSATION_ARTIFACTS_LIMIT, CONVERSATION_HISTORY_DEFAULT_LIMIT, DELEGATION_TOOL_BACKOFF_EXPONENT, DELEGATION_TOOL_BACKOFF_INITIAL_INTERVAL_MS, DELEGATION_TOOL_BACKOFF_MAX_ELAPSED_TIME_MS, DELEGATION_TOOL_BACKOFF_MAX_INTERVAL_MS, FUNCTION_TOOL_EXECUTION_TIMEOUT_MS_DEFAULT, FUNCTION_TOOL_SANDBOX_CLEANUP_INTERVAL_MS, FUNCTION_TOOL_SANDBOX_MAX_OUTPUT_SIZE_BYTES, FUNCTION_TOOL_SANDBOX_MAX_USE_COUNT, FUNCTION_TOOL_SANDBOX_POOL_TTL_MS, FUNCTION_TOOL_SANDBOX_QUEUE_WAIT_TIMEOUT_MS, FUNCTION_TOOL_SANDBOX_VCPUS_DEFAULT, LLM_GENERATION_FIRST_CALL_TIMEOUT_MS_NON_STREAMING, LLM_GENERATION_FIRST_CALL_TIMEOUT_MS_STREAMING, LLM_GENERATION_MAX_ALLOWED_TIMEOUT_MS, LLM_GENERATION_SUBSEQUENT_CALL_TIMEOUT_MS, MCP_TOOL_REQUEST_TIMEOUT_MS_DEFAULT, SESSION_CLEANUP_INTERVAL_MS, SESSION_TOOL_RESULT_CACHE_TIMEOUT_MS, STATUS_UPDATE_DEFAULT_INTERVAL_SECONDS, STATUS_UPDATE_DEFAULT_NUM_EVENTS, STREAM_BUFFER_MAX_SIZE_BYTES, STREAM_MAX_LIFETIME_MS, STREAM_PARSER_MAX_COLLECTED_PARTS, STREAM_PARSER_MAX_SNAPSHOT_SIZE, STREAM_PARSER_MAX_STREAMED_SIZE, STREAM_TEXT_GAP_THRESHOLD_MS, executionLimitsDefaults };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ContextCache } from "./contextCache.js";
|
|
2
2
|
import { ContextFetcher, MissingRequiredVariableError } from "./ContextFetcher.js";
|
|
3
3
|
import { getLogger, getTracer, setSpanWithError } from "@inkeep/agents-core";
|
|
4
|
-
import crypto from "node:crypto";
|
|
5
4
|
import { SpanStatusCode } from "@opentelemetry/api";
|
|
5
|
+
import crypto from "node:crypto";
|
|
6
6
|
|
|
7
7
|
//#region src/domains/run/context/ContextResolver.ts
|
|
8
8
|
const logger = getLogger("context-resolver");
|
|
@@ -1129,7 +1129,11 @@ var AgentSessionManager = class {
|
|
|
1129
1129
|
recordEvent(sessionId, eventType, subAgentId, data) {
|
|
1130
1130
|
const session = this.sessions.get(sessionId);
|
|
1131
1131
|
if (!session) {
|
|
1132
|
-
logger.warn({
|
|
1132
|
+
logger.warn({
|
|
1133
|
+
sessionId,
|
|
1134
|
+
eventType,
|
|
1135
|
+
subAgentId
|
|
1136
|
+
}, "Attempted to record event in non-existent session (likely session already ended)");
|
|
1133
1137
|
return;
|
|
1134
1138
|
}
|
|
1135
1139
|
session.recordEvent(eventType, subAgentId, data);
|
|
@@ -5,8 +5,8 @@ import { getCompressionConfigForModel } from "../utils/model-context-utils.js";
|
|
|
5
5
|
import { tracer } from "../utils/tracer.js";
|
|
6
6
|
import { agentSessionManager } from "./AgentSession.js";
|
|
7
7
|
import { getLedgerArtifacts } from "@inkeep/agents-core";
|
|
8
|
-
import { randomUUID } from "node:crypto";
|
|
9
8
|
import { SpanStatusCode } from "@opentelemetry/api";
|
|
9
|
+
import { randomUUID } from "node:crypto";
|
|
10
10
|
|
|
11
11
|
//#region src/domains/run/services/BaseCompressor.ts
|
|
12
12
|
const logger = getLogger$1("BaseCompressor");
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { env } from "../../../env.js";
|
|
2
|
+
|
|
1
3
|
//#region src/domains/run/types/executionContext.ts
|
|
2
4
|
/**
|
|
3
5
|
* Extract userId from execution context metadata (when available)
|
|
@@ -16,7 +18,7 @@ function createBaseExecutionContext(params) {
|
|
|
16
18
|
tenantId: params.tenantId,
|
|
17
19
|
projectId: params.projectId,
|
|
18
20
|
agentId: params.agentId,
|
|
19
|
-
baseUrl: params.baseUrl ||
|
|
21
|
+
baseUrl: params.baseUrl || env.INKEEP_AGENTS_API_URL,
|
|
20
22
|
apiKeyId: params.apiKeyId,
|
|
21
23
|
subAgentId: params.subAgentId,
|
|
22
24
|
ref: params.ref,
|
package/dist/env.d.ts
CHANGED
|
@@ -48,6 +48,12 @@ declare const envSchema: z.ZodObject<{
|
|
|
48
48
|
WORKFLOW_POSTGRES_URL: z.ZodOptional<z.ZodString>;
|
|
49
49
|
WORKFLOW_POSTGRES_JOB_PREFIX: z.ZodOptional<z.ZodString>;
|
|
50
50
|
WORKFLOW_POSTGRES_WORKER_CONCURRENCY: z.ZodOptional<z.ZodString>;
|
|
51
|
+
GITHUB_APP_ID: z.ZodOptional<z.ZodString>;
|
|
52
|
+
GITHUB_APP_PRIVATE_KEY: z.ZodOptional<z.ZodString>;
|
|
53
|
+
GITHUB_WEBHOOK_SECRET: z.ZodOptional<z.ZodString>;
|
|
54
|
+
GITHUB_STATE_SIGNING_SECRET: z.ZodOptional<z.ZodString>;
|
|
55
|
+
GITHUB_APP_NAME: z.ZodOptional<z.ZodString>;
|
|
56
|
+
GITHUB_MCP_API_KEY: z.ZodOptional<z.ZodString>;
|
|
51
57
|
}, z.core.$strip>;
|
|
52
58
|
declare const env: {
|
|
53
59
|
NODE_ENV: "development" | "production" | "test";
|
|
@@ -81,6 +87,12 @@ declare const env: {
|
|
|
81
87
|
WORKFLOW_POSTGRES_URL?: string | undefined;
|
|
82
88
|
WORKFLOW_POSTGRES_JOB_PREFIX?: string | undefined;
|
|
83
89
|
WORKFLOW_POSTGRES_WORKER_CONCURRENCY?: string | undefined;
|
|
90
|
+
GITHUB_APP_ID?: string | undefined;
|
|
91
|
+
GITHUB_APP_PRIVATE_KEY?: string | undefined;
|
|
92
|
+
GITHUB_WEBHOOK_SECRET?: string | undefined;
|
|
93
|
+
GITHUB_STATE_SIGNING_SECRET?: string | undefined;
|
|
94
|
+
GITHUB_APP_NAME?: string | undefined;
|
|
95
|
+
GITHUB_MCP_API_KEY?: string | undefined;
|
|
84
96
|
};
|
|
85
97
|
type Env = z.infer<typeof envSchema>;
|
|
86
98
|
//#endregion
|
package/dist/env.js
CHANGED
|
@@ -49,7 +49,13 @@ const envSchema = z.object({
|
|
|
49
49
|
WORKFLOW_TARGET_WORLD: z.string().optional(),
|
|
50
50
|
WORKFLOW_POSTGRES_URL: z.string().optional(),
|
|
51
51
|
WORKFLOW_POSTGRES_JOB_PREFIX: z.string().optional(),
|
|
52
|
-
WORKFLOW_POSTGRES_WORKER_CONCURRENCY: z.string().optional()
|
|
52
|
+
WORKFLOW_POSTGRES_WORKER_CONCURRENCY: z.string().optional(),
|
|
53
|
+
GITHUB_APP_ID: z.string().optional(),
|
|
54
|
+
GITHUB_APP_PRIVATE_KEY: z.string().optional(),
|
|
55
|
+
GITHUB_WEBHOOK_SECRET: z.string().optional(),
|
|
56
|
+
GITHUB_STATE_SIGNING_SECRET: z.string().min(32, "GITHUB_STATE_SIGNING_SECRET must be at least 32 characters").optional(),
|
|
57
|
+
GITHUB_APP_NAME: z.string().optional(),
|
|
58
|
+
GITHUB_MCP_API_KEY: z.string().optional().describe("API key for the GitHub MCP")
|
|
53
59
|
});
|
|
54
60
|
const parseEnv = () => {
|
|
55
61
|
try {
|