@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.
Files changed (87) hide show
  1. package/dist/app.d.ts +18 -38
  2. package/dist/app.js +3 -1
  3. package/dist/auth/managed-auth.d.ts +35 -0
  4. package/dist/{chunk-5TULDPWX.js → chunk-36PW33ND.js} +4111 -1277
  5. package/dist/chunk-36PW33ND.js.map +1 -0
  6. package/dist/codex-redemption-security.d.ts +15 -0
  7. package/dist/github-access.d.ts +12 -0
  8. package/dist/github-browser-flow.d.ts +14 -0
  9. package/dist/http/auth.d.ts +3 -0
  10. package/dist/http/common.d.ts +3 -0
  11. package/dist/http/sse.d.ts +70 -0
  12. package/dist/index.d.ts +11 -13
  13. package/dist/index.js +1 -1
  14. package/dist/integrations/google-drive.d.ts +76 -0
  15. package/dist/integrations/oauth-client.d.ts +42 -0
  16. package/dist/integrations/provider-domain.d.ts +7 -0
  17. package/dist/integrations/slack-bot.d.ts +343 -0
  18. package/dist/mcp/documents.d.ts +8 -0
  19. package/dist/mcp/files.d.ts +5 -0
  20. package/dist/mcp/server.d.ts +107 -0
  21. package/dist/mcp/session-view.d.ts +191 -0
  22. package/dist/mcp/toolspace.d.ts +61 -0
  23. package/dist/model-catalog.d.ts +39 -0
  24. package/dist/observability.d.ts +3 -0
  25. package/dist/routes/api-keys.d.ts +3 -0
  26. package/dist/routes/billing.d.ts +16 -0
  27. package/dist/routes/capabilities.d.ts +3 -0
  28. package/dist/routes/catalog-assets.d.ts +5 -0
  29. package/dist/routes/codex.d.ts +10 -0
  30. package/dist/routes/connections.d.ts +3 -0
  31. package/dist/routes/documents.d.ts +3 -0
  32. package/dist/routes/enrollments.d.ts +3 -0
  33. package/dist/routes/environments.d.ts +5 -0
  34. package/dist/routes/files.d.ts +4 -0
  35. package/dist/routes/github.d.ts +3 -0
  36. package/dist/routes/insights.d.ts +3 -0
  37. package/dist/routes/install.d.ts +5 -0
  38. package/dist/routes/machines.d.ts +3 -0
  39. package/dist/routes/packs.d.ts +3 -0
  40. package/dist/routes/preference-registry.d.ts +5 -0
  41. package/dist/routes/rigs.d.ts +3 -0
  42. package/dist/routes/scheduled-tasks.d.ts +3 -0
  43. package/dist/routes/sessions.d.ts +15 -0
  44. package/dist/routes/social.d.ts +3 -0
  45. package/dist/routes/transcriptions.d.ts +3 -0
  46. package/dist/routes/workspace-capture.d.ts +59 -0
  47. package/dist/routes/workspace-instruction-policies.d.ts +3 -0
  48. package/dist/routes/workspace-state.d.ts +3 -0
  49. package/dist/routes/workspaces.d.ts +5 -0
  50. package/dist/sandbox/access.d.ts +21 -0
  51. package/dist/sandbox/auth-callout.d.ts +30 -0
  52. package/dist/sandbox/channel-a.d.ts +37 -0
  53. package/dist/sandbox/enrollment.d.ts +120 -0
  54. package/dist/sandbox/machines.d.ts +29 -0
  55. package/dist/sandbox/metrics-ingestion.d.ts +128 -0
  56. package/dist/sandbox/rematerialize.d.ts +24 -0
  57. package/dist/sandbox/viewer.d.ts +251 -0
  58. package/dist/transcription/providers/azure-openai.d.ts +9 -0
  59. package/dist/transcription/providers/codex-subscription.d.ts +9 -0
  60. package/dist/transcription/providers/openai.d.ts +9 -0
  61. package/dist/transcription/service.d.ts +10 -0
  62. package/dist/workspace-state-projection.d.ts +16 -0
  63. package/package.json +13 -13
  64. package/src/app.ts +67 -5
  65. package/src/integrations/google-drive.ts +869 -0
  66. package/src/integrations/oauth-client.ts +41 -6
  67. package/src/integrations/slack-bot.ts +756 -26
  68. package/src/mcp/server.ts +200 -3
  69. package/src/mcp/session-view.ts +1 -0
  70. package/src/mcp/toolspace.ts +17 -9
  71. package/src/routes/connections.ts +137 -7
  72. package/src/routes/documents.ts +13 -2
  73. package/src/routes/github.ts +7 -5
  74. package/src/routes/insights.ts +30 -0
  75. package/src/routes/preference-registry.ts +482 -0
  76. package/src/routes/sessions.ts +10 -0
  77. package/src/routes/transcriptions.ts +155 -0
  78. package/src/routes/workspace-state.ts +61 -0
  79. package/src/sandbox/channel-a.ts +2 -0
  80. package/src/sandbox/rematerialize.ts +111 -4
  81. package/src/sandbox/viewer.ts +29 -12
  82. package/src/transcription/providers/azure-openai.ts +45 -0
  83. package/src/transcription/providers/codex-subscription.ts +100 -0
  84. package/src/transcription/providers/openai.ts +93 -0
  85. package/src/transcription/service.ts +121 -0
  86. package/src/workspace-state-projection.ts +244 -0
  87. 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 { OAuthStartResponse, type OAuthStartRequest } from "@opengeni/contracts";
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 = "https://mcp.slack.com/mcp";
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 urls = [as.issuer, as.authorizationServer, as.authorizationEndpoint, as.tokenEndpoint];
414
- if (urls.some((value) => new URL(value).origin !== SLACK_OAUTH_ORIGIN)) {
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
- safeAuthorizationServer,
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
- normalizedCandidates.has(SLACK_OAUTH_ORIGIN) &&
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
  ) {