@opengeni/api-router 0.12.7 → 0.12.12
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/app.js +1 -1
- package/dist/{chunk-SD5GJTZ4.js → chunk-5TULDPWX.js} +356 -84
- package/dist/chunk-5TULDPWX.js.map +1 -0
- package/dist/index.js +1 -1
- package/package.json +10 -10
- package/src/app.ts +8 -0
- package/src/github-access.ts +1 -0
- package/src/mcp/server.ts +26 -39
- package/src/routes/github.ts +325 -20
- package/src/routes/sessions.ts +12 -23
- package/src/routes/workspace-capture.ts +108 -8
- package/dist/chunk-SD5GJTZ4.js.map +0 -1
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opengeni/api-router",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.12",
|
|
4
4
|
"description": "OpenGeni HTTP surface: the Hono adapter/router (createApp), routes, MCP HTTP transport, and HTTP access adapters over @opengeni/core. An engine-distribution surface — its runtime closure includes engine-internal packages.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -44,17 +44,17 @@
|
|
|
44
44
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
45
45
|
"@opengeni/agent-proto": "^0.3.0",
|
|
46
46
|
"@opengeni/codex": "^0.2.7",
|
|
47
|
-
"@opengeni/config": "^0.7.
|
|
48
|
-
"@opengeni/contracts": "^0.
|
|
49
|
-
"@opengeni/core": "^0.12.
|
|
50
|
-
"@opengeni/db": "^0.14.
|
|
51
|
-
"@opengeni/documents": "^0.2.
|
|
52
|
-
"@opengeni/events": "^0.3.
|
|
53
|
-
"@opengeni/github": "^0.
|
|
47
|
+
"@opengeni/config": "^0.7.13",
|
|
48
|
+
"@opengeni/contracts": "^0.23.0",
|
|
49
|
+
"@opengeni/core": "^0.12.10",
|
|
50
|
+
"@opengeni/db": "^0.14.3",
|
|
51
|
+
"@opengeni/documents": "^0.2.45",
|
|
52
|
+
"@opengeni/events": "^0.3.36",
|
|
53
|
+
"@opengeni/github": "^0.4.0",
|
|
54
54
|
"@opengeni/network": "^0.1.1",
|
|
55
55
|
"@opengeni/observability": "^0.3.0",
|
|
56
|
-
"@opengeni/runtime": "^0.14.
|
|
57
|
-
"@opengeni/storage": "^0.2.
|
|
56
|
+
"@opengeni/runtime": "^0.14.3",
|
|
57
|
+
"@opengeni/storage": "^0.2.37",
|
|
58
58
|
"@temporalio/client": "^1.17.0",
|
|
59
59
|
"better-auth": "^1.6.14",
|
|
60
60
|
"hono": "^4.12.18",
|
package/src/app.ts
CHANGED
|
@@ -888,6 +888,14 @@ const routeLabelPatterns: Array<{ pattern: RegExp; label: string }> = [
|
|
|
888
888
|
pattern: /^\/v1\/workspaces\/[^/]+\/github\/connect$/,
|
|
889
889
|
label: "/v1/workspaces/:workspaceId/github/connect",
|
|
890
890
|
},
|
|
891
|
+
{
|
|
892
|
+
pattern: /^\/v1\/workspaces\/[^/]+\/github\/installations\/select$/,
|
|
893
|
+
label: "/v1/workspaces/:workspaceId/github/installations/select",
|
|
894
|
+
},
|
|
895
|
+
{
|
|
896
|
+
pattern: /^\/v1\/workspaces\/[^/]+\/github\/installations\/[^/]+\/configure$/,
|
|
897
|
+
label: "/v1/workspaces/:workspaceId/github/installations/:installationId/configure",
|
|
898
|
+
},
|
|
891
899
|
{
|
|
892
900
|
pattern: /^\/v1\/workspaces\/[^/]+\/github\/installations$/,
|
|
893
901
|
label: "/v1/workspaces/:workspaceId/github/installations",
|
package/src/github-access.ts
CHANGED
|
@@ -64,6 +64,7 @@ export async function listWorkspaceGitHubInstallationBindings(
|
|
|
64
64
|
),
|
|
65
65
|
repositoryScope: installation.repositoryScope,
|
|
66
66
|
repositoryCount: installation.repositoryIds.length,
|
|
67
|
+
configureUrl: null,
|
|
67
68
|
createdAt: installation.createdAt,
|
|
68
69
|
updatedAt: installation.updatedAt,
|
|
69
70
|
}));
|
package/src/mcp/server.ts
CHANGED
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
type Permission,
|
|
22
22
|
type ResourceRef,
|
|
23
23
|
type SessionAuthorizationOperation,
|
|
24
|
+
type SessionAuthorizationSurface,
|
|
24
25
|
type Session,
|
|
25
26
|
UpdateScheduledTaskRequest,
|
|
26
27
|
} from "@opengeni/contracts";
|
|
@@ -1567,6 +1568,7 @@ function registerRigTools(
|
|
|
1567
1568
|
function exactAgentCommandContext(
|
|
1568
1569
|
grant: AccessGrant,
|
|
1569
1570
|
callerSessionId: string,
|
|
1571
|
+
authorizationSurface?: SessionAuthorizationSurface,
|
|
1570
1572
|
): AgentSessionCommandContext {
|
|
1571
1573
|
const turnId = grant.metadata?.["turnId"];
|
|
1572
1574
|
const attemptId = grant.metadata?.["attemptId"];
|
|
@@ -1588,6 +1590,7 @@ function exactAgentCommandContext(
|
|
|
1588
1590
|
callerTurnId: turnId,
|
|
1589
1591
|
callerAttemptId: attemptId,
|
|
1590
1592
|
callerExecutionGeneration: executionGeneration,
|
|
1593
|
+
...(authorizationSurface ? { authorizationSurface } : {}),
|
|
1591
1594
|
};
|
|
1592
1595
|
}
|
|
1593
1596
|
|
|
@@ -1953,7 +1956,6 @@ function registerWorkspaceOrchestrationTools(
|
|
|
1953
1956
|
targetSessionId,
|
|
1954
1957
|
{
|
|
1955
1958
|
text,
|
|
1956
|
-
toolsProvided: false,
|
|
1957
1959
|
delivery: "send",
|
|
1958
1960
|
origin: "operator",
|
|
1959
1961
|
clientEventId: idempotencyKey,
|
|
@@ -1977,16 +1979,10 @@ function registerWorkspaceOrchestrationTools(
|
|
|
1977
1979
|
},
|
|
1978
1980
|
},
|
|
1979
1981
|
async ({ sessionId, idempotencyKey, reason }) => {
|
|
1980
|
-
const authorization = await authorizeFirstPartySession(
|
|
1981
|
-
deps,
|
|
1982
|
-
grant,
|
|
1983
|
-
sessionId,
|
|
1984
|
-
"session.control",
|
|
1985
|
-
);
|
|
1986
1982
|
if (callerSessionId !== null) {
|
|
1987
1983
|
const controlled = await controlAgentSessionWorkstream(
|
|
1988
1984
|
deps,
|
|
1989
|
-
exactAgentCommandContext(grant, callerSessionId),
|
|
1985
|
+
exactAgentCommandContext(grant, callerSessionId, "first_party_mcp"),
|
|
1990
1986
|
{
|
|
1991
1987
|
targetSessionId: sessionId,
|
|
1992
1988
|
action: "pause",
|
|
@@ -1999,7 +1995,7 @@ function registerWorkspaceOrchestrationTools(
|
|
|
1999
1995
|
effectiveControl: projectEffectiveControlForRelatedAccess(
|
|
2000
1996
|
serializeEffectiveSessionControl(controlled.control),
|
|
2001
1997
|
sessionId,
|
|
2002
|
-
authorization?.relatedSessionAccess ?? "root",
|
|
1998
|
+
controlled.authorization?.relatedSessionAccess ?? "root",
|
|
2003
1999
|
),
|
|
2004
2000
|
interruptionCount: controlled.interruptionCount,
|
|
2005
2001
|
replay: controlled.replay,
|
|
@@ -2012,6 +2008,7 @@ function registerWorkspaceOrchestrationTools(
|
|
|
2012
2008
|
workspaceId: grant.workspaceId,
|
|
2013
2009
|
sessionId,
|
|
2014
2010
|
subjectId: grant.subjectId,
|
|
2011
|
+
authorizationSurface: "first_party_mcp",
|
|
2015
2012
|
},
|
|
2016
2013
|
{
|
|
2017
2014
|
action: "pause",
|
|
@@ -2019,14 +2016,7 @@ function registerWorkspaceOrchestrationTools(
|
|
|
2019
2016
|
...(reason ? { reason } : {}),
|
|
2020
2017
|
},
|
|
2021
2018
|
);
|
|
2022
|
-
return json(
|
|
2023
|
-
...controlled,
|
|
2024
|
-
effectiveControl: projectEffectiveControlForRelatedAccess(
|
|
2025
|
-
controlled.effectiveControl,
|
|
2026
|
-
sessionId,
|
|
2027
|
-
authorization?.relatedSessionAccess ?? "root",
|
|
2028
|
-
),
|
|
2029
|
-
});
|
|
2019
|
+
return json(controlled);
|
|
2030
2020
|
},
|
|
2031
2021
|
);
|
|
2032
2022
|
|
|
@@ -2042,16 +2032,10 @@ function registerWorkspaceOrchestrationTools(
|
|
|
2042
2032
|
},
|
|
2043
2033
|
},
|
|
2044
2034
|
async ({ sessionId, idempotencyKey, reason }) => {
|
|
2045
|
-
const authorization = await authorizeFirstPartySession(
|
|
2046
|
-
deps,
|
|
2047
|
-
grant,
|
|
2048
|
-
sessionId,
|
|
2049
|
-
"session.control",
|
|
2050
|
-
);
|
|
2051
2035
|
if (callerSessionId !== null) {
|
|
2052
2036
|
const controlled = await controlAgentSessionWorkstream(
|
|
2053
2037
|
deps,
|
|
2054
|
-
exactAgentCommandContext(grant, callerSessionId),
|
|
2038
|
+
exactAgentCommandContext(grant, callerSessionId, "first_party_mcp"),
|
|
2055
2039
|
{
|
|
2056
2040
|
targetSessionId: sessionId,
|
|
2057
2041
|
action: "resume",
|
|
@@ -2064,7 +2048,7 @@ function registerWorkspaceOrchestrationTools(
|
|
|
2064
2048
|
effectiveControl: projectEffectiveControlForRelatedAccess(
|
|
2065
2049
|
serializeEffectiveSessionControl(controlled.control),
|
|
2066
2050
|
sessionId,
|
|
2067
|
-
authorization?.relatedSessionAccess ?? "root",
|
|
2051
|
+
controlled.authorization?.relatedSessionAccess ?? "root",
|
|
2068
2052
|
),
|
|
2069
2053
|
interruptionCount: controlled.interruptionCount,
|
|
2070
2054
|
replay: controlled.replay,
|
|
@@ -2077,6 +2061,7 @@ function registerWorkspaceOrchestrationTools(
|
|
|
2077
2061
|
workspaceId: grant.workspaceId,
|
|
2078
2062
|
sessionId,
|
|
2079
2063
|
subjectId: grant.subjectId,
|
|
2064
|
+
authorizationSurface: "first_party_mcp",
|
|
2080
2065
|
},
|
|
2081
2066
|
{
|
|
2082
2067
|
action: "resume",
|
|
@@ -2084,14 +2069,7 @@ function registerWorkspaceOrchestrationTools(
|
|
|
2084
2069
|
...(reason ? { reason } : {}),
|
|
2085
2070
|
},
|
|
2086
2071
|
);
|
|
2087
|
-
return json(
|
|
2088
|
-
...controlled,
|
|
2089
|
-
effectiveControl: projectEffectiveControlForRelatedAccess(
|
|
2090
|
-
controlled.effectiveControl,
|
|
2091
|
-
sessionId,
|
|
2092
|
-
authorization?.relatedSessionAccess ?? "root",
|
|
2093
|
-
),
|
|
2094
|
-
});
|
|
2072
|
+
return json(controlled);
|
|
2095
2073
|
},
|
|
2096
2074
|
);
|
|
2097
2075
|
|
|
@@ -2108,10 +2086,9 @@ function registerWorkspaceOrchestrationTools(
|
|
|
2108
2086
|
},
|
|
2109
2087
|
},
|
|
2110
2088
|
async ({ sessionId, instruction, idempotencyKey }) => {
|
|
2111
|
-
await authorizeFirstPartySession(deps, grant, sessionId, "session.steer");
|
|
2112
2089
|
const result = await steerAgentSession(
|
|
2113
2090
|
deps,
|
|
2114
|
-
exactAgentCommandContext(grant, callerSessionId),
|
|
2091
|
+
exactAgentCommandContext(grant, callerSessionId, "first_party_mcp"),
|
|
2115
2092
|
{ targetSessionId: sessionId, instruction, idempotencyKey },
|
|
2116
2093
|
);
|
|
2117
2094
|
return json({
|
|
@@ -2317,14 +2294,16 @@ function registerGitHubConnectTool(
|
|
|
2317
2294
|
const { settings } = deps;
|
|
2318
2295
|
const missing = githubAppMissingSettings(settings);
|
|
2319
2296
|
const slug = settings.githubAppSlug?.trim() || null;
|
|
2297
|
+
const setupMode = settings.productAccessMode === "managed" ? "platform" : "operator";
|
|
2320
2298
|
if (missing.length > 0 || !slug) {
|
|
2321
2299
|
return json({
|
|
2322
2300
|
configured: false,
|
|
2323
2301
|
status: "disabled",
|
|
2324
|
-
|
|
2302
|
+
setupMode,
|
|
2303
|
+
appSlug: setupMode === "operator" ? slug : null,
|
|
2325
2304
|
installUrl: null,
|
|
2326
2305
|
linkUrl: null,
|
|
2327
|
-
missing,
|
|
2306
|
+
missing: setupMode === "operator" ? missing : [],
|
|
2328
2307
|
});
|
|
2329
2308
|
}
|
|
2330
2309
|
const installations = await listWorkspaceGitHubInstallationBindings(deps, grant.workspaceId);
|
|
@@ -2342,13 +2321,21 @@ function registerGitHubConnectTool(
|
|
|
2342
2321
|
const connectUrl = state
|
|
2343
2322
|
? `${baseUrl}/v1/workspaces/${grant.workspaceId}/github/connect?state=${encodeURIComponent(state)}`
|
|
2344
2323
|
: null;
|
|
2324
|
+
const installationViews = installations.map((installation) => ({
|
|
2325
|
+
...installation,
|
|
2326
|
+
configureUrl:
|
|
2327
|
+
state && baseUrl
|
|
2328
|
+
? `${baseUrl}/v1/workspaces/${grant.workspaceId}/github/installations/${installation.installationId}/configure?state=${encodeURIComponent(state)}`
|
|
2329
|
+
: null,
|
|
2330
|
+
}));
|
|
2345
2331
|
return json({
|
|
2346
2332
|
configured: true,
|
|
2347
2333
|
status,
|
|
2348
|
-
|
|
2334
|
+
setupMode,
|
|
2335
|
+
appSlug: setupMode === "operator" ? slug : null,
|
|
2349
2336
|
installUrl: connectUrl,
|
|
2350
2337
|
linkUrl: connectUrl,
|
|
2351
|
-
installations,
|
|
2338
|
+
installations: installationViews,
|
|
2352
2339
|
missing: [],
|
|
2353
2340
|
});
|
|
2354
2341
|
},
|