@opengeni/api-router 2.6.4 → 2.10.0-canary.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/access-grant-rls.d.ts +3 -0
- package/dist/app.d.ts +2 -1
- package/dist/app.js +3 -1
- package/dist/auth/organization-user-setup.d.ts +23 -0
- package/dist/{chunk-XTLI3CBH.js → chunk-XXH7DW34.js} +6866 -3554
- package/dist/chunk-XXH7DW34.js.map +1 -0
- package/dist/codemode.d.ts +6 -0
- package/dist/github-access.d.ts +25 -2
- package/dist/http/request-source.d.ts +14 -0
- package/dist/index.js +19 -3
- package/dist/index.js.map +1 -1
- package/dist/integrations/oauth-client.d.ts +2 -11
- package/dist/integrations/personal-github-repositories.d.ts +41 -2
- package/dist/integrations/slack-interactions.d.ts +1 -1
- package/dist/mcp/server.d.ts +158 -1
- package/dist/mcp/session-view.d.ts +56 -2
- package/dist/mcp/session-wait.d.ts +1 -1
- package/dist/mcp-oauth.d.ts +19 -0
- package/dist/model-catalog.d.ts +5 -31
- package/dist/routes/codex.d.ts +27 -2
- package/dist/routes/github.d.ts +2 -0
- package/dist/routes/organization-model-providers.d.ts +3 -0
- package/dist/routes/workspace-artifacts.d.ts +2 -1
- package/dist/work-discovery-observability.d.ts +1 -1
- package/dist/workspace-artifact-content.d.ts +28 -0
- package/dist/workspace-artifact-provenance.d.ts +7 -0
- package/dist/workspace-deletion.d.ts +6 -0
- package/dist/workspace-tool-gateway-observability.d.ts +17 -0
- package/dist/workspace-tool-gateway.d.ts +118 -0
- package/package.json +19 -18
- package/src/access-grant-rls.ts +40 -0
- package/src/app.ts +296 -53
- package/src/auth/organization-user-setup.ts +95 -5
- package/src/codemode.ts +33 -4
- package/src/github-access.ts +117 -1
- package/src/http/auth.ts +11 -0
- package/src/http/request-source.ts +37 -0
- package/src/http/sse.ts +15 -7
- package/src/index.ts +18 -2
- package/src/integrations/oauth-client.ts +168 -203
- package/src/integrations/personal-github-repositories.ts +238 -9
- package/src/integrations/slack-app-home.ts +2 -2
- package/src/integrations/slack-interactions.ts +77 -37
- package/src/mcp/company-brain-governed-writes.ts +2 -2
- package/src/mcp/company-profile-agent-admin.ts +1 -1
- package/src/mcp/remember.ts +1 -1
- package/src/mcp/server.ts +504 -133
- package/src/mcp/session-view.ts +20 -1
- package/src/mcp/session-wait.ts +3 -0
- package/src/mcp-oauth.ts +539 -0
- package/src/model-catalog.ts +45 -337
- package/src/routes/automations.ts +178 -19
- package/src/routes/codex.ts +242 -73
- package/src/routes/connections.ts +271 -16
- package/src/routes/documents.ts +67 -19
- package/src/routes/files.ts +54 -6
- package/src/routes/github.ts +116 -15
- package/src/routes/organization-memberships.ts +59 -16
- package/src/routes/organization-model-providers.ts +231 -0
- package/src/routes/packs.ts +1 -0
- package/src/routes/personal-github.ts +39 -0
- package/src/routes/pr-review.ts +72 -4
- package/src/routes/scheduled-tasks.ts +40 -13
- package/src/routes/sessions.ts +153 -65
- package/src/routes/supergrok.ts +3 -2
- package/src/routes/workspace-artifacts.ts +176 -67
- package/src/routes/workspaces.ts +405 -62
- package/src/sandbox/channel-a.ts +17 -4
- package/src/work-discovery-observability.ts +3 -3
- package/src/workspace-artifact-content.ts +163 -0
- package/src/workspace-artifact-provenance.ts +104 -0
- package/src/workspace-deletion.ts +64 -0
- package/src/workspace-tool-gateway-observability.ts +100 -0
- package/src/workspace-tool-gateway.ts +691 -0
- package/dist/chunk-XTLI3CBH.js.map +0 -1
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
2
|
+
import type { Settings } from "@opengeni/config";
|
|
3
|
+
import { ToolGatewayDeclarationsResponse, type AccessGrant, type ToolGatewayCatalog, type ToolGatewayIdentity } from "@opengeni/contracts";
|
|
4
|
+
import { type AccessGrantAuthorization, type ApiRouteDeps } from "@opengeni/core";
|
|
5
|
+
import { consumeToolGatewayApproval, issueToolGatewayApproval } from "@opengeni/db";
|
|
6
|
+
import { type PreparedWorkspaceToolGatewayTools } from "@opengeni/runtime/workspace-tool-gateway";
|
|
7
|
+
import { type ToolGatewayDefinition } from "@opengeni/tool-gateway";
|
|
8
|
+
import type { Observability } from "@opengeni/observability";
|
|
9
|
+
export type PreparedWorkspaceToolGateway = Pick<PreparedWorkspaceToolGatewayTools, "toolGateway" | "toolGatewayCatalog" | "close"> & {
|
|
10
|
+
toolGateway: NonNullable<PreparedWorkspaceToolGatewayTools["toolGateway"]>;
|
|
11
|
+
toolGatewayCatalog: NonNullable<PreparedWorkspaceToolGatewayTools["toolGatewayCatalog"]>;
|
|
12
|
+
};
|
|
13
|
+
type WorkspaceSiteToolContext = {
|
|
14
|
+
siteArtifactId: string;
|
|
15
|
+
siteVersionId: string;
|
|
16
|
+
identity: {
|
|
17
|
+
serverId: string;
|
|
18
|
+
toolName: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
type AuthorizeWorkspaceSiteTool = (db: ApiRouteDeps["db"], grant: AccessGrant, context: WorkspaceSiteToolContext) => Promise<void>;
|
|
22
|
+
export declare function grantUsesAttemptScopedMcp(grant: AccessGrant): boolean;
|
|
23
|
+
export declare function requireWorkspaceToolGatewayGrant(grant: AccessGrant): void;
|
|
24
|
+
export declare function requireWorkspaceToolGatewayAuthorization(authorization: AccessGrantAuthorization): AccessGrant;
|
|
25
|
+
export declare function prepareWorkspaceToolGateway(routeDeps: ApiRouteDeps, authorization: AccessGrantAuthorization): Promise<PreparedWorkspaceToolGateway>;
|
|
26
|
+
export declare function prepareMcpOAuthWorkspaceToolGateway(routeDeps: ApiRouteDeps, grant: AccessGrant, allowedIdentities: readonly {
|
|
27
|
+
serverId: string;
|
|
28
|
+
toolName: string;
|
|
29
|
+
}[]): Promise<PreparedWorkspaceToolGateway>;
|
|
30
|
+
export declare function prepareWorkspaceToolGatewayForGrant(routeDeps: ApiRouteDeps, grant: AccessGrant, allowedIdentities?: readonly {
|
|
31
|
+
serverId: string;
|
|
32
|
+
toolName: string;
|
|
33
|
+
}[]): Promise<PreparedWorkspaceToolGateway>;
|
|
34
|
+
export declare function workspaceToolGatewayDefinitionFilter(settings: Pick<Settings, "allowedFirstPartyMcpTools">, allowedIdentities?: readonly ToolGatewayIdentity[]): (definition: ToolGatewayDefinition) => boolean;
|
|
35
|
+
export declare function workspaceToolGatewaySettingsForGrant(settings: Settings, grant: AccessGrant, allowedIdentities?: readonly {
|
|
36
|
+
serverId: string;
|
|
37
|
+
toolName: string;
|
|
38
|
+
}[]): Settings;
|
|
39
|
+
export declare function buildWorkspaceToolGatewayMcpServer(prepared: PreparedWorkspaceToolGateway, grant: AccessGrant, observability?: Observability): Server;
|
|
40
|
+
export declare function callWorkspaceToolGateway(prepared: PreparedWorkspaceToolGateway, grant: AccessGrant, input: unknown, db?: ApiRouteDeps["db"], consumeApproval?: typeof consumeToolGatewayApproval, observability?: Observability, authorizeSiteTool?: AuthorizeWorkspaceSiteTool): Promise<{
|
|
41
|
+
operationId: string;
|
|
42
|
+
catalogDigest: string;
|
|
43
|
+
result: {
|
|
44
|
+
[x: string]: unknown;
|
|
45
|
+
content: ({
|
|
46
|
+
[x: string]: unknown;
|
|
47
|
+
type: "text";
|
|
48
|
+
text: string;
|
|
49
|
+
annotations?: Record<string, import("zod").JSONType> | undefined;
|
|
50
|
+
_meta?: Record<string, import("zod").JSONType> | undefined;
|
|
51
|
+
} | {
|
|
52
|
+
[x: string]: unknown;
|
|
53
|
+
type: "image";
|
|
54
|
+
data: string;
|
|
55
|
+
mimeType: string;
|
|
56
|
+
annotations?: Record<string, import("zod").JSONType> | undefined;
|
|
57
|
+
_meta?: Record<string, import("zod").JSONType> | undefined;
|
|
58
|
+
} | {
|
|
59
|
+
[x: string]: unknown;
|
|
60
|
+
type: "audio";
|
|
61
|
+
data: string;
|
|
62
|
+
mimeType: string;
|
|
63
|
+
annotations?: Record<string, import("zod").JSONType> | undefined;
|
|
64
|
+
_meta?: Record<string, import("zod").JSONType> | undefined;
|
|
65
|
+
} | {
|
|
66
|
+
[x: string]: unknown;
|
|
67
|
+
type: "resource_link";
|
|
68
|
+
name: string;
|
|
69
|
+
title?: string | undefined;
|
|
70
|
+
uri: string;
|
|
71
|
+
description?: string | undefined;
|
|
72
|
+
mimeType?: string | undefined;
|
|
73
|
+
size?: number | undefined;
|
|
74
|
+
icons?: {
|
|
75
|
+
src: string;
|
|
76
|
+
mimeType?: string | undefined;
|
|
77
|
+
sizes?: string[] | undefined;
|
|
78
|
+
theme?: "dark" | "light" | undefined;
|
|
79
|
+
}[] | undefined;
|
|
80
|
+
annotations?: Record<string, import("zod").JSONType> | undefined;
|
|
81
|
+
_meta?: Record<string, import("zod").JSONType> | undefined;
|
|
82
|
+
} | {
|
|
83
|
+
[x: string]: unknown;
|
|
84
|
+
type: "resource";
|
|
85
|
+
resource: {
|
|
86
|
+
[x: string]: unknown;
|
|
87
|
+
uri: string;
|
|
88
|
+
mimeType?: string | undefined;
|
|
89
|
+
text: string;
|
|
90
|
+
_meta?: Record<string, import("zod").JSONType> | undefined;
|
|
91
|
+
} | {
|
|
92
|
+
[x: string]: unknown;
|
|
93
|
+
uri: string;
|
|
94
|
+
mimeType?: string | undefined;
|
|
95
|
+
blob: string;
|
|
96
|
+
_meta?: Record<string, import("zod").JSONType> | undefined;
|
|
97
|
+
};
|
|
98
|
+
annotations?: Record<string, import("zod").JSONType> | undefined;
|
|
99
|
+
_meta?: Record<string, import("zod").JSONType> | undefined;
|
|
100
|
+
})[];
|
|
101
|
+
structuredContent?: Record<string, import("zod").JSONType> | undefined;
|
|
102
|
+
isError?: boolean | undefined;
|
|
103
|
+
_meta?: Record<string, import("zod").JSONType> | undefined;
|
|
104
|
+
};
|
|
105
|
+
}>;
|
|
106
|
+
export declare function approveWorkspaceToolGatewayCall(prepared: PreparedWorkspaceToolGateway, grant: AccessGrant, db: ApiRouteDeps["db"], input: unknown, issueApproval?: typeof issueToolGatewayApproval, observability?: Observability): Promise<{
|
|
107
|
+
operationId: string;
|
|
108
|
+
catalogDigest: string;
|
|
109
|
+
identity: {
|
|
110
|
+
serverId: string;
|
|
111
|
+
toolName: string;
|
|
112
|
+
};
|
|
113
|
+
approvalToken: string;
|
|
114
|
+
expiresAt: string;
|
|
115
|
+
}>;
|
|
116
|
+
export declare function toolGatewayCatalogResponse(catalog: ToolGatewayCatalog): ToolGatewayCatalog;
|
|
117
|
+
export declare function workspaceToolGatewayDeclarations(prepared: PreparedWorkspaceToolGateway): ToolGatewayDeclarationsResponse;
|
|
118
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opengeni/api-router",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.10.0-canary.0",
|
|
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": {
|
|
@@ -43,23 +43,24 @@
|
|
|
43
43
|
"@hono/zod-validator": "^0.7.6",
|
|
44
44
|
"@llamaindex/liteparse": "2.14.2",
|
|
45
45
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
46
|
-
"@opengeni/agent-proto": "^0.5.1",
|
|
47
|
-
"@opengeni/artifact-tool": "^0.3.
|
|
48
|
-
"@opengeni/capabilities": "^0.3.
|
|
49
|
-
"@opengeni/codemode": "^0.4.
|
|
50
|
-
"@opengeni/codex": "^0.2.
|
|
51
|
-
"@opengeni/config": "^0.
|
|
52
|
-
"@opengeni/contracts": "^2.
|
|
53
|
-
"@opengeni/core": "^2.
|
|
54
|
-
"@opengeni/db": "^
|
|
55
|
-
"@opengeni/documents": "^0.8.
|
|
56
|
-
"@opengeni/events": "^0.4.
|
|
57
|
-
"@opengeni/github": "^0.
|
|
58
|
-
"@opengeni/network": "^0.
|
|
59
|
-
"@opengeni/observability": "^0.8.
|
|
60
|
-
"@opengeni/runtime": "^2.0.
|
|
61
|
-
"@opengeni/storage": "^0.2.
|
|
62
|
-
"@opengeni/
|
|
46
|
+
"@opengeni/agent-proto": "^0.5.1-canary.9",
|
|
47
|
+
"@opengeni/artifact-tool": "^0.3.19-canary.0",
|
|
48
|
+
"@opengeni/capabilities": "^0.3.2-canary.0",
|
|
49
|
+
"@opengeni/codemode": "^0.4.27-canary.0",
|
|
50
|
+
"@opengeni/codex": "^0.2.21-canary.0",
|
|
51
|
+
"@opengeni/config": "^1.0.0-canary.0",
|
|
52
|
+
"@opengeni/contracts": "^2.13.0-canary.0",
|
|
53
|
+
"@opengeni/core": "^2.7.5-canary.0",
|
|
54
|
+
"@opengeni/db": "^4.0.0-canary.0",
|
|
55
|
+
"@opengeni/documents": "^0.8.19-canary.0",
|
|
56
|
+
"@opengeni/events": "^0.4.17-canary.0",
|
|
57
|
+
"@opengeni/github": "^0.7.3-canary.0",
|
|
58
|
+
"@opengeni/network": "^0.3.0-canary.0",
|
|
59
|
+
"@opengeni/observability": "^0.8.19-canary.0",
|
|
60
|
+
"@opengeni/runtime": "^2.3.0-canary.0",
|
|
61
|
+
"@opengeni/storage": "^0.2.120-canary.0",
|
|
62
|
+
"@opengeni/tool-gateway": "^0.1.0-canary.0",
|
|
63
|
+
"@opengeni/xai-subscription": "^0.1.3-canary.0",
|
|
63
64
|
"@temporalio/client": "^1.17.0",
|
|
64
65
|
"better-auth": "^1.6.14",
|
|
65
66
|
"hono": "^4.12.18",
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { AccessGrant } from "@opengeni/contracts";
|
|
2
|
+
import {
|
|
3
|
+
requireLiveAgentAttemptAuthorization,
|
|
4
|
+
SessionAuthorizationDeniedError,
|
|
5
|
+
type ApiRouteDeps,
|
|
6
|
+
} from "@opengeni/core";
|
|
7
|
+
import { withSessionRlsActorContext } from "@opengeni/db";
|
|
8
|
+
import { HTTPException } from "hono/http-exception";
|
|
9
|
+
|
|
10
|
+
export async function withAccessGrantSessionRlsContext<T>(
|
|
11
|
+
deps: ApiRouteDeps,
|
|
12
|
+
grant: AccessGrant,
|
|
13
|
+
fn: () => Promise<T>,
|
|
14
|
+
): Promise<T> {
|
|
15
|
+
if (grant.principalKind !== "agent_attempt") {
|
|
16
|
+
return await withSessionRlsActorContext({ subjectId: grant.subjectId }, fn);
|
|
17
|
+
}
|
|
18
|
+
const callerSessionId = grant.metadata?.sessionId;
|
|
19
|
+
if (typeof callerSessionId !== "string") {
|
|
20
|
+
throw new HTTPException(403, { message: "agent attempt authority is invalid" });
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
const actor = await requireLiveAgentAttemptAuthorization(deps.db, grant, callerSessionId);
|
|
24
|
+
return await withSessionRlsActorContext(
|
|
25
|
+
{
|
|
26
|
+
subjectId: actor.subjectId,
|
|
27
|
+
initiatingHumanSubjectId: actor.initiatingHumanSubjectId,
|
|
28
|
+
},
|
|
29
|
+
fn,
|
|
30
|
+
);
|
|
31
|
+
} catch (error) {
|
|
32
|
+
if (error instanceof SessionAuthorizationDeniedError) {
|
|
33
|
+
throw new HTTPException(403, {
|
|
34
|
+
message: "agent attempt authority is invalid",
|
|
35
|
+
cause: error,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
throw error;
|
|
39
|
+
}
|
|
40
|
+
}
|