@opengeni/api-router 0.12.12 → 0.14.4
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.d.ts +18 -38
- package/dist/app.js +3 -1
- package/dist/auth/managed-auth.d.ts +35 -0
- package/dist/{chunk-5TULDPWX.js → chunk-36PW33ND.js} +4111 -1277
- package/dist/chunk-36PW33ND.js.map +1 -0
- package/dist/codex-redemption-security.d.ts +15 -0
- package/dist/github-access.d.ts +12 -0
- package/dist/github-browser-flow.d.ts +14 -0
- package/dist/http/auth.d.ts +3 -0
- package/dist/http/common.d.ts +3 -0
- package/dist/http/sse.d.ts +70 -0
- package/dist/index.d.ts +11 -13
- package/dist/index.js +1 -1
- package/dist/integrations/google-drive.d.ts +76 -0
- package/dist/integrations/oauth-client.d.ts +42 -0
- package/dist/integrations/provider-domain.d.ts +7 -0
- package/dist/integrations/slack-bot.d.ts +343 -0
- package/dist/mcp/documents.d.ts +8 -0
- package/dist/mcp/files.d.ts +5 -0
- package/dist/mcp/server.d.ts +107 -0
- package/dist/mcp/session-view.d.ts +191 -0
- package/dist/mcp/toolspace.d.ts +61 -0
- package/dist/model-catalog.d.ts +39 -0
- package/dist/observability.d.ts +3 -0
- package/dist/routes/api-keys.d.ts +3 -0
- package/dist/routes/billing.d.ts +16 -0
- package/dist/routes/capabilities.d.ts +3 -0
- package/dist/routes/catalog-assets.d.ts +5 -0
- package/dist/routes/codex.d.ts +10 -0
- package/dist/routes/connections.d.ts +3 -0
- package/dist/routes/documents.d.ts +3 -0
- package/dist/routes/enrollments.d.ts +3 -0
- package/dist/routes/environments.d.ts +5 -0
- package/dist/routes/files.d.ts +4 -0
- package/dist/routes/github.d.ts +3 -0
- package/dist/routes/insights.d.ts +3 -0
- package/dist/routes/install.d.ts +5 -0
- package/dist/routes/machines.d.ts +3 -0
- package/dist/routes/packs.d.ts +3 -0
- package/dist/routes/preference-registry.d.ts +5 -0
- package/dist/routes/rigs.d.ts +3 -0
- package/dist/routes/scheduled-tasks.d.ts +3 -0
- package/dist/routes/sessions.d.ts +15 -0
- package/dist/routes/social.d.ts +3 -0
- package/dist/routes/transcriptions.d.ts +3 -0
- package/dist/routes/workspace-capture.d.ts +59 -0
- package/dist/routes/workspace-instruction-policies.d.ts +3 -0
- package/dist/routes/workspace-state.d.ts +3 -0
- package/dist/routes/workspaces.d.ts +5 -0
- package/dist/sandbox/access.d.ts +21 -0
- package/dist/sandbox/auth-callout.d.ts +30 -0
- package/dist/sandbox/channel-a.d.ts +37 -0
- package/dist/sandbox/enrollment.d.ts +120 -0
- package/dist/sandbox/machines.d.ts +29 -0
- package/dist/sandbox/metrics-ingestion.d.ts +128 -0
- package/dist/sandbox/rematerialize.d.ts +24 -0
- package/dist/sandbox/viewer.d.ts +251 -0
- package/dist/transcription/providers/azure-openai.d.ts +9 -0
- package/dist/transcription/providers/codex-subscription.d.ts +9 -0
- package/dist/transcription/providers/openai.d.ts +9 -0
- package/dist/transcription/service.d.ts +10 -0
- package/dist/workspace-state-projection.d.ts +16 -0
- package/package.json +13 -13
- package/src/app.ts +67 -5
- package/src/integrations/google-drive.ts +869 -0
- package/src/integrations/oauth-client.ts +41 -6
- package/src/integrations/slack-bot.ts +756 -26
- package/src/mcp/server.ts +200 -3
- package/src/mcp/session-view.ts +1 -0
- package/src/mcp/toolspace.ts +17 -9
- package/src/routes/connections.ts +137 -7
- package/src/routes/documents.ts +13 -2
- package/src/routes/github.ts +7 -5
- package/src/routes/insights.ts +30 -0
- package/src/routes/preference-registry.ts +482 -0
- package/src/routes/sessions.ts +10 -0
- package/src/routes/transcriptions.ts +155 -0
- package/src/routes/workspace-state.ts +61 -0
- package/src/sandbox/channel-a.ts +2 -0
- package/src/sandbox/rematerialize.ts +111 -4
- package/src/sandbox/viewer.ts +29 -12
- package/src/transcription/providers/azure-openai.ts +45 -0
- package/src/transcription/providers/codex-subscription.ts +100 -0
- package/src/transcription/providers/openai.ts +93 -0
- package/src/transcription/service.ts +121 -0
- package/src/workspace-state-projection.ts +244 -0
- package/dist/chunk-5TULDPWX.js.map +0 -1
|
@@ -2,7 +2,11 @@ import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
|
2
2
|
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
3
3
|
import type { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
|
|
4
4
|
import { parseIntegrationsOauthClientsJson, type Settings } from "@opengeni/config";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
OPENGENI_PERSONAL_SLACK_MCP_URL,
|
|
7
|
+
OAuthStartResponse,
|
|
8
|
+
type OAuthStartRequest,
|
|
9
|
+
} from "@opengeni/contracts";
|
|
6
10
|
import { hasPermission, requireEnvironmentEncryption } from "@opengeni/core";
|
|
7
11
|
import type { Observability } from "@opengeni/observability";
|
|
8
12
|
import {
|
|
@@ -34,8 +38,9 @@ import { HTTPException } from "hono/http-exception";
|
|
|
34
38
|
import { canonicalProviderDomain } from "./provider-domain";
|
|
35
39
|
|
|
36
40
|
export const oauthStateTtlMs = 10 * 60 * 1000;
|
|
37
|
-
export const OFFICIAL_SLACK_MCP_URL =
|
|
41
|
+
export const OFFICIAL_SLACK_MCP_URL = OPENGENI_PERSONAL_SLACK_MCP_URL;
|
|
38
42
|
const SLACK_OAUTH_ORIGIN = "https://slack.com";
|
|
43
|
+
const SLACK_MCP_ORIGIN = "https://mcp.slack.com";
|
|
39
44
|
export { OAUTH_MAX_RESPONSE_BYTES } from "@opengeni/network";
|
|
40
45
|
|
|
41
46
|
type OAuthClientDeps = {
|
|
@@ -410,8 +415,14 @@ function assertPersonalSlackOAuthStart(
|
|
|
410
415
|
}
|
|
411
416
|
|
|
412
417
|
export function assertSlackAuthorizationServer(as: AuthorizationServerMetadata): void {
|
|
413
|
-
const
|
|
414
|
-
|
|
418
|
+
const issuerOrigins = [as.issuer, as.authorizationServer].map((value) => new URL(value).origin);
|
|
419
|
+
const endpointOrigins = [as.authorizationEndpoint, as.tokenEndpoint].map(
|
|
420
|
+
(value) => new URL(value).origin,
|
|
421
|
+
);
|
|
422
|
+
if (
|
|
423
|
+
issuerOrigins.some((origin) => origin !== SLACK_OAUTH_ORIGIN && origin !== SLACK_MCP_ORIGIN) ||
|
|
424
|
+
endpointOrigins.some((origin) => origin !== SLACK_OAUTH_ORIGIN)
|
|
425
|
+
) {
|
|
415
426
|
throw new HTTPException(422, {
|
|
416
427
|
message: "Slack MCP authorization metadata did not remain bound to slack.com",
|
|
417
428
|
});
|
|
@@ -508,9 +519,14 @@ async function discoverAuthorizationServerMetadata(
|
|
|
508
519
|
"OAuth authorization server",
|
|
509
520
|
).replace(/\/+$/, "");
|
|
510
521
|
const candidates = uniqueStrings([
|
|
511
|
-
|
|
522
|
+
// Prefer the RFC metadata locations before probing the issuer itself. Some
|
|
523
|
+
// providers (including Linear) redirect their issuer root to a human docs
|
|
524
|
+
// page; following that redirect can leave discovery waiting on an unrelated
|
|
525
|
+
// streaming response even though the well-known metadata is immediately
|
|
526
|
+
// available.
|
|
512
527
|
...wellKnownCandidates(safeAuthorizationServer, "oauth-authorization-server"),
|
|
513
528
|
...wellKnownCandidates(safeAuthorizationServer, "openid-configuration"),
|
|
529
|
+
safeAuthorizationServer,
|
|
514
530
|
]);
|
|
515
531
|
for (const candidate of candidates) {
|
|
516
532
|
const payload = await fetchJsonObject(candidate, settings).catch((error) => {
|
|
@@ -572,6 +588,12 @@ async function registerOAuthClient(
|
|
|
572
588
|
if (operator) {
|
|
573
589
|
return operator;
|
|
574
590
|
}
|
|
591
|
+
// Linear currently advertises CIMD but rejects its client metadata URL at
|
|
592
|
+
// the authorization endpoint. Its documented interactive setup uses DCR,
|
|
593
|
+
// so prefer the simultaneously advertised registration endpoint.
|
|
594
|
+
if (prefersDynamicClientRegistration(as)) {
|
|
595
|
+
return await getOrCreateDynamicClientRegistration(db, settings, as, redirectUri, scopes);
|
|
596
|
+
}
|
|
575
597
|
if (as.clientIdMetadataDocumentSupported) {
|
|
576
598
|
return {
|
|
577
599
|
method: "cimd",
|
|
@@ -597,6 +619,12 @@ async function registerOAuthClient(
|
|
|
597
619
|
return await getOrCreateDynamicClientRegistration(db, settings, as, redirectUri, scopes);
|
|
598
620
|
}
|
|
599
621
|
|
|
622
|
+
function prefersDynamicClientRegistration(as: AuthorizationServerMetadata): boolean {
|
|
623
|
+
return Boolean(
|
|
624
|
+
as.registrationEndpoint && normalizedIssuerKey(as.issuer) === "https://mcp.linear.app",
|
|
625
|
+
);
|
|
626
|
+
}
|
|
627
|
+
|
|
600
628
|
async function getOrCreateDynamicClientRegistration(
|
|
601
629
|
db: Database,
|
|
602
630
|
settings: Settings,
|
|
@@ -720,7 +748,14 @@ function operatorClientEntryFor(
|
|
|
720
748
|
): ReturnType<typeof parseIntegrationsOauthClientsJson>[string] | null {
|
|
721
749
|
const normalizedCandidates = new Set(candidates.map(normalizedIssuerKey));
|
|
722
750
|
if (
|
|
723
|
-
|
|
751
|
+
candidates.some((candidate) => {
|
|
752
|
+
try {
|
|
753
|
+
const origin = new URL(candidate).origin;
|
|
754
|
+
return origin === SLACK_OAUTH_ORIGIN || origin === SLACK_MCP_ORIGIN;
|
|
755
|
+
} catch {
|
|
756
|
+
return false;
|
|
757
|
+
}
|
|
758
|
+
}) &&
|
|
724
759
|
settings.slackClientId?.trim() &&
|
|
725
760
|
settings.slackClientSecret?.trim()
|
|
726
761
|
) {
|