@opengeni/capabilities 0.1.1 → 0.3.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/index.js CHANGED
@@ -397,13 +397,13 @@ function compileGraphqlRevision(introspection, options) {
397
397
  return {
398
398
  id,
399
399
  protocol: "graphql",
400
- integrationId: options.integrationId,
400
+ definitionId: options.definitionId,
401
401
  contentSha256,
402
402
  source: {
403
403
  url: options.sourceUrl ?? endpoint,
404
404
  ...options.provider ? { provider: options.provider } : {}
405
405
  },
406
- title: options.name?.trim() || options.integrationId,
406
+ title: options.name?.trim() || options.definitionId,
407
407
  tools,
408
408
  bindings
409
409
  };
@@ -463,7 +463,7 @@ async function fetchGraphqlIntrospection(options) {
463
463
  var GraphqlMcpServer = class {
464
464
  constructor(options) {
465
465
  this.options = options;
466
- this.name = `graphql:${stableToolId(options.revision.integrationId)}`;
466
+ this.name = `graphql:${stableToolId(options.revision.definitionId)}`;
467
467
  }
468
468
  cacheToolsList = true;
469
469
  useStructuredContent = true;
@@ -534,7 +534,7 @@ async function invokeGraphqlOperation(options, toolId, args, signal) {
534
534
  const request = { query, variables, operationName: binding.operationName };
535
535
  const firstCredential = await resolveGraphqlCredential(
536
536
  options,
537
- options.revision.integrationId,
537
+ options.revision.definitionId,
538
538
  options.revision.id,
539
539
  toolId,
540
540
  false
@@ -543,7 +543,7 @@ async function invokeGraphqlOperation(options, toolId, args, signal) {
543
543
  if (response.status === 401 && options.credentialResolver && options.authority.connectionRef) {
544
544
  const refreshed = await resolveGraphqlCredential(
545
545
  options,
546
- options.revision.integrationId,
546
+ options.revision.definitionId,
547
547
  options.revision.id,
548
548
  toolId,
549
549
  true
@@ -592,12 +592,12 @@ async function invokeGraphqlOperation(options, toolId, args, signal) {
592
592
  errors: graph.errors ?? null
593
593
  };
594
594
  }
595
- async function resolveGraphqlCredential(options, integrationId, revisionId, operationKey, forceRefresh) {
595
+ async function resolveGraphqlCredential(options, definitionId, revisionId, operationKey, forceRefresh) {
596
596
  if (!options.credentialResolver || !options.authority.connectionRef) return null;
597
597
  const credential = await options.credentialResolver.resolve({
598
598
  ...options.authority,
599
599
  protocol: "graphql",
600
- integrationId,
600
+ definitionId,
601
601
  revisionId,
602
602
  operationKey,
603
603
  destinationUrl: graphqlEndpoint(options).toString(),
@@ -619,6 +619,22 @@ async function sendGraphqlRequest(options, request, credential, signal) {
619
619
  headers.set("accept", "application/json");
620
620
  headers.set("content-type", "application/json");
621
621
  if (credential) applyCredentialPlacements(endpoint, headers, credential);
622
+ if (credential?.authorizeProviderRequest) {
623
+ let authorized = false;
624
+ try {
625
+ authorized = await credential.authorizeProviderRequest();
626
+ } catch {
627
+ authorized = false;
628
+ }
629
+ if (!authorized) {
630
+ throw new IntegrationInvocationError(
631
+ "authorization_rejected",
632
+ "The connected account is no longer authorized for this operation",
633
+ "not_started",
634
+ false
635
+ );
636
+ }
637
+ }
622
638
  return await fetchWithDeadline(
623
639
  options.transport,
624
640
  endpoint,
@@ -830,6 +846,63 @@ function basename(value) {
830
846
  return value?.trim().split(/[\\/]/).pop() ?? "";
831
847
  }
832
848
 
849
+ // src/mcp-bridge.ts
850
+ var LOCAL_MCP_BRIDGE_CONTRACT_VERSION = 1;
851
+ function defineLocalMcpBridgeDescriptor(input) {
852
+ const adapterId = boundedIdentity(input.adapterId, "adapterId");
853
+ const providerId = boundedIdentity(input.providerId, "providerId");
854
+ const catalogIdentity = boundedIdentity(input.catalogIdentity, "catalogIdentity", 512);
855
+ if (input.destinations.length === 0 || input.destinations.length > 32) {
856
+ throw new Error("Local MCP bridge must declare 1-32 provider destinations");
857
+ }
858
+ const destinations = input.destinations.map((destination) => {
859
+ const url = new URL(destination.origin);
860
+ if (url.protocol !== "https:" || url.origin !== destination.origin) {
861
+ throw new Error("Local MCP bridge destinations must be exact HTTPS origins");
862
+ }
863
+ if (!destination.pathPrefix.startsWith("/") || destination.pathPrefix.includes("\\") || destination.pathPrefix.includes("?") || destination.pathPrefix.includes("#") || new URL(destination.pathPrefix, url.origin).pathname !== destination.pathPrefix) {
864
+ throw new Error("Local MCP bridge destination pathPrefix must be an absolute URL path");
865
+ }
866
+ return Object.freeze({ origin: url.origin, pathPrefix: destination.pathPrefix });
867
+ });
868
+ return Object.freeze({
869
+ contractVersion: LOCAL_MCP_BRIDGE_CONTRACT_VERSION,
870
+ adapterId,
871
+ providerId,
872
+ catalogIdentity,
873
+ transport: "in_process",
874
+ authority: input.authority,
875
+ toolSurface: input.toolSurface,
876
+ mutationReplay: input.mutationReplay,
877
+ destinations: Object.freeze(destinations)
878
+ });
879
+ }
880
+ function isLocalMcpBridgeServer(server) {
881
+ const bridge = server.bridge;
882
+ return bridge?.contractVersion === LOCAL_MCP_BRIDGE_CONTRACT_VERSION && bridge.transport === "in_process";
883
+ }
884
+ function createLocalMcpBridgeFromAdapters(adapters, config, context) {
885
+ const matches = adapters.filter((adapter2) => adapter2.matches(config));
886
+ if (matches.length === 0) return null;
887
+ if (matches.length > 1) {
888
+ throw new Error(
889
+ `Multiple local MCP bridge adapters matched: ${matches.map((entry) => entry.adapterId).join(", ")}`
890
+ );
891
+ }
892
+ const adapter = matches[0];
893
+ const server = adapter.create(config, context);
894
+ if (server.bridge.adapterId !== adapter.adapterId) {
895
+ throw new Error(`Local MCP bridge adapter ${adapter.adapterId} returned mismatched metadata`);
896
+ }
897
+ return server;
898
+ }
899
+ function boundedIdentity(value, name, max = 128) {
900
+ if (value.length === 0 || value.length > max || /[\u0000-\u001f\u007f]/u.test(value)) {
901
+ throw new Error(`Local MCP bridge ${name} is invalid`);
902
+ }
903
+ return value;
904
+ }
905
+
833
906
  // src/openapi.ts
834
907
  import { load as parseYaml } from "js-yaml";
835
908
  var methods = /* @__PURE__ */ new Set([
@@ -947,13 +1020,13 @@ function compileOpenApiRevision(source, options) {
947
1020
  return {
948
1021
  id: revisionId,
949
1022
  protocol: "openapi",
950
- integrationId: options.integrationId,
1023
+ definitionId: options.definitionId,
951
1024
  contentSha256,
952
1025
  source: {
953
1026
  ...options.sourceUrl ? { url: options.sourceUrl } : {},
954
1027
  ...options.provider ? { provider: options.provider } : {}
955
1028
  },
956
- title: stringValue(info.title) ?? options.integrationId,
1029
+ title: stringValue(info.title) ?? options.definitionId,
957
1030
  ...stringValue(info.description) ? { description: stringValue(info.description) } : {},
958
1031
  ...stringValue(info.version) ? { version: stringValue(info.version) } : {},
959
1032
  tools,
@@ -986,7 +1059,7 @@ function discoverOpenApiAuth(document) {
986
1059
  var OpenApiMcpServer = class {
987
1060
  constructor(options) {
988
1061
  this.options = options;
989
- this.name = `openapi:${stableToolId(options.revision.integrationId)}`;
1062
+ this.name = `openapi:${stableToolId(options.revision.definitionId)}`;
990
1063
  }
991
1064
  cacheToolsList = true;
992
1065
  useStructuredContent = true;
@@ -1103,7 +1176,7 @@ async function resolveOpenApiCredential(options, binding, toolId, args, forceRef
1103
1176
  const credential = await options.credentialResolver.resolve({
1104
1177
  ...options.authority,
1105
1178
  protocol: "openapi",
1106
- integrationId: options.revision.integrationId,
1179
+ definitionId: options.revision.definitionId,
1107
1180
  revisionId: options.revision.id,
1108
1181
  operationKey: toolId,
1109
1182
  destinationUrl,
@@ -1125,6 +1198,22 @@ async function sendOpenApiRequest(options, binding, args, credential, signal) {
1125
1198
  const headers = buildOperationHeaders(binding, args);
1126
1199
  const body = buildOperationBody(binding, args, headers);
1127
1200
  if (credential) applyCredentialPlacements(url, headers, credential);
1201
+ if (credential?.authorizeProviderRequest) {
1202
+ let authorized = false;
1203
+ try {
1204
+ authorized = await credential.authorizeProviderRequest();
1205
+ } catch {
1206
+ authorized = false;
1207
+ }
1208
+ if (!authorized) {
1209
+ throw new IntegrationInvocationError(
1210
+ "authorization_rejected",
1211
+ "The connected account is no longer authorized for this operation",
1212
+ "not_started",
1213
+ false
1214
+ );
1215
+ }
1216
+ }
1128
1217
  return await fetchWithDeadline(
1129
1218
  options.transport,
1130
1219
  url,
@@ -1435,9 +1524,9 @@ function isRecord2(value) {
1435
1524
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
1436
1525
  }
1437
1526
 
1438
- // src/providers.ts
1439
- var accountIdentityFeature = (provider) => ({
1440
- featureKey: "account-identity",
1527
+ // src/integration-definitions.ts
1528
+ var accountIdentityFacet = (provider) => ({
1529
+ facetKey: "account-identity",
1441
1530
  kind: "identity_link",
1442
1531
  configSchema: { type: "object", properties: {}, additionalProperties: false },
1443
1532
  capabilities: {
@@ -1446,8 +1535,8 @@ var accountIdentityFeature = (provider) => ({
1446
1535
  identity: "connected_account"
1447
1536
  }
1448
1537
  });
1449
- var driveKnowledgeFeature = (provider) => ({
1450
- featureKey: "drive-content",
1538
+ var driveKnowledgeFacet = (provider) => ({
1539
+ facetKey: "drive-content",
1451
1540
  kind: "knowledge_source",
1452
1541
  configSchema: {
1453
1542
  type: "object",
@@ -1501,9 +1590,9 @@ var driveKnowledgeFeature = (provider) => ({
1501
1590
  cursor: provider === "google-drive" ? "page_token" : "delta_link"
1502
1591
  }
1503
1592
  });
1504
- var mailboxFeatures = (provider) => [
1593
+ var mailboxFacets = (provider) => [
1505
1594
  {
1506
- featureKey: "mail-inbox",
1595
+ facetKey: "mail-inbox",
1507
1596
  kind: "inbound_trigger",
1508
1597
  configSchema: {
1509
1598
  type: "object",
@@ -1517,11 +1606,11 @@ var mailboxFeatures = (provider) => [
1517
1606
  provider,
1518
1607
  connectionRequired: true,
1519
1608
  delivery: "poll",
1520
- cursor: provider === "google-gmail" ? "history_id" : "delta_link"
1609
+ cursor: "delta_link"
1521
1610
  }
1522
1611
  },
1523
1612
  {
1524
- featureKey: "mail-delivery",
1613
+ facetKey: "mail-delivery",
1525
1614
  kind: "delivery_destination",
1526
1615
  configSchema: {
1527
1616
  type: "object",
@@ -1537,90 +1626,89 @@ var mailboxFeatures = (provider) => [
1537
1626
  delivery: "email"
1538
1627
  }
1539
1628
  },
1540
- accountIdentityFeature(provider === "google-gmail" ? "google" : "microsoft")
1629
+ accountIdentityFacet("microsoft")
1541
1630
  ];
1542
1631
  var googleDiscoveryUrl = (service, version) => `https://www.googleapis.com/discovery/v1/apis/${service}/${version}/rest`;
1543
1632
  var googleOAuth = (scopes) => ({
1633
+ kind: "oauth2",
1634
+ provider: "google",
1544
1635
  authorizationUrl: "https://accounts.google.com/o/oauth2/v2/auth",
1545
1636
  tokenUrl: "https://oauth2.googleapis.com/token",
1546
1637
  scopes: ["openid", "email", "profile", ...scopes],
1547
1638
  tokenPlacement: { carrier: "header", name: "Authorization", prefix: "Bearer " }
1548
1639
  });
1549
- var GOOGLE_DRIVE_PRESET = {
1640
+ var GOOGLE_DRIVE_INTEGRATION_DEFINITION = {
1550
1641
  id: "google-drive",
1551
1642
  name: "Google Drive",
1552
1643
  summary: "Files, folders, permissions, and shared drives.",
1553
- family: "google",
1554
- sourceFormat: "google-discovery",
1555
- sourceUrl: googleDiscoveryUrl("drive", "v3"),
1644
+ protocol: "openapi",
1645
+ provider: { id: "google", domain: "www.googleapis.com" },
1646
+ source: { kind: "google_discovery", url: googleDiscoveryUrl("drive", "v3") },
1556
1647
  baseUrl: "https://www.googleapis.com/drive/v3/",
1557
- oauth: googleOAuth(["https://www.googleapis.com/auth/drive"]),
1558
- healthOperation: "drive.about.get",
1559
- healthArgs: { query: { fields: "user" } },
1560
- features: [driveKnowledgeFeature("google-drive"), accountIdentityFeature("google")]
1561
- };
1562
- var GOOGLE_GMAIL_PRESET = {
1563
- id: "google-gmail",
1564
- name: "Gmail",
1565
- summary: "Messages, threads, labels, drafts, and sending mail.",
1566
- family: "google",
1567
- sourceFormat: "google-discovery",
1568
- sourceUrl: googleDiscoveryUrl("gmail", "v1"),
1569
- baseUrl: "https://gmail.googleapis.com/",
1570
- oauth: googleOAuth(["https://mail.google.com/"]),
1571
- healthOperation: "gmail.users.labels.list",
1572
- healthArgs: { path: { userId: "me" } },
1573
- features: mailboxFeatures("google-gmail")
1648
+ authentication: googleOAuth(["https://www.googleapis.com/auth/drive"]),
1649
+ healthCheck: {
1650
+ operationKey: "drive.about.get",
1651
+ arguments: { query: { fields: "user" } }
1652
+ },
1653
+ facets: [driveKnowledgeFacet("google-drive"), accountIdentityFacet("google")]
1574
1654
  };
1575
1655
  var MICROSOFT_GRAPH_OPENAPI_URL = "https://raw.githubusercontent.com/microsoftgraph/msgraph-metadata/master/openapi/v1.0/openapi.yaml";
1576
1656
  var MICROSOFT_GRAPH_BASE_URL = "https://graph.microsoft.com/v1.0";
1577
1657
  var microsoftOAuth = (scopes) => ({
1658
+ kind: "oauth2",
1659
+ provider: "microsoft",
1578
1660
  authorizationUrl: "https://login.microsoftonline.com/common/oauth2/v2.0/authorize",
1579
1661
  tokenUrl: "https://login.microsoftonline.com/common/oauth2/v2.0/token",
1580
1662
  scopes: ["offline_access", "User.Read", ...scopes],
1581
1663
  tokenPlacement: { carrier: "header", name: "Authorization", prefix: "Bearer " }
1582
1664
  });
1583
- var MICROSOFT_OUTLOOK_MAIL_PRESET = {
1665
+ var MICROSOFT_OUTLOOK_MAIL_INTEGRATION_DEFINITION = {
1584
1666
  id: "microsoft-outlook-mail",
1585
1667
  name: "Outlook Mail",
1586
1668
  summary: "Messages, folders, attachments, settings, and sending mail.",
1587
- family: "microsoft",
1588
- sourceFormat: "openapi",
1589
- sourceUrl: MICROSOFT_GRAPH_OPENAPI_URL,
1669
+ protocol: "openapi",
1670
+ provider: { id: "microsoft", domain: "graph.microsoft.com" },
1671
+ source: {
1672
+ kind: "openapi",
1673
+ url: MICROSOFT_GRAPH_OPENAPI_URL,
1674
+ operationPathPrefixes: [
1675
+ "/me/messages",
1676
+ "/me/mailFolders",
1677
+ "/me/sendMail",
1678
+ "/me/getMailTips",
1679
+ "/me/inferenceClassification",
1680
+ "/me/mailboxSettings",
1681
+ "/me/outlook"
1682
+ ]
1683
+ },
1590
1684
  baseUrl: MICROSOFT_GRAPH_BASE_URL,
1591
- oauth: microsoftOAuth(["Mail.ReadWrite", "Mail.Send", "MailboxSettings.ReadWrite"]),
1592
- pathPrefixes: [
1593
- "/me/messages",
1594
- "/me/mailFolders",
1595
- "/me/sendMail",
1596
- "/me/getMailTips",
1597
- "/me/inferenceClassification",
1598
- "/me/mailboxSettings",
1599
- "/me/outlook"
1600
- ],
1601
- features: mailboxFeatures("microsoft-outlook-mail")
1685
+ authentication: microsoftOAuth(["Mail.ReadWrite", "Mail.Send", "MailboxSettings.ReadWrite"]),
1686
+ facets: mailboxFacets("microsoft-outlook-mail")
1602
1687
  };
1603
- var MICROSOFT_OUTLOOK_CALENDAR_PRESET = {
1688
+ var MICROSOFT_OUTLOOK_CALENDAR_INTEGRATION_DEFINITION = {
1604
1689
  id: "microsoft-outlook-calendar",
1605
1690
  name: "Outlook Calendar",
1606
1691
  summary: "Calendars, events, availability, and scheduling.",
1607
- family: "microsoft",
1608
- sourceFormat: "openapi",
1609
- sourceUrl: MICROSOFT_GRAPH_OPENAPI_URL,
1692
+ protocol: "openapi",
1693
+ provider: { id: "microsoft", domain: "graph.microsoft.com" },
1694
+ source: {
1695
+ kind: "openapi",
1696
+ url: MICROSOFT_GRAPH_OPENAPI_URL,
1697
+ operationPathPrefixes: [
1698
+ "/me/calendar",
1699
+ "/me/calendars",
1700
+ "/me/calendarGroups",
1701
+ "/me/calendarView",
1702
+ "/me/events",
1703
+ "/me/findMeetingTimes",
1704
+ "/me/reminderView"
1705
+ ]
1706
+ },
1610
1707
  baseUrl: MICROSOFT_GRAPH_BASE_URL,
1611
- oauth: microsoftOAuth(["Calendars.ReadWrite"]),
1612
- pathPrefixes: [
1613
- "/me/calendar",
1614
- "/me/calendars",
1615
- "/me/calendarGroups",
1616
- "/me/calendarView",
1617
- "/me/events",
1618
- "/me/findMeetingTimes",
1619
- "/me/reminderView"
1620
- ],
1621
- features: [
1708
+ authentication: microsoftOAuth(["Calendars.ReadWrite"]),
1709
+ facets: [
1622
1710
  {
1623
- featureKey: "calendar-events",
1711
+ facetKey: "calendar-events",
1624
1712
  kind: "inbound_trigger",
1625
1713
  configSchema: {
1626
1714
  type: "object",
@@ -1638,7 +1726,7 @@ var MICROSOFT_OUTLOOK_CALENDAR_PRESET = {
1638
1726
  }
1639
1727
  },
1640
1728
  {
1641
- featureKey: "calendar-delivery",
1729
+ facetKey: "calendar-delivery",
1642
1730
  kind: "delivery_destination",
1643
1731
  configSchema: {
1644
1732
  type: "object",
@@ -1653,70 +1741,78 @@ var MICROSOFT_OUTLOOK_CALENDAR_PRESET = {
1653
1741
  delivery: "calendar_event"
1654
1742
  }
1655
1743
  },
1656
- accountIdentityFeature("microsoft")
1744
+ accountIdentityFacet("microsoft")
1657
1745
  ]
1658
1746
  };
1659
- var MICROSOFT_OUTLOOK_CONTACTS_PRESET = {
1747
+ var MICROSOFT_OUTLOOK_CONTACTS_INTEGRATION_DEFINITION = {
1660
1748
  id: "microsoft-outlook-contacts",
1661
1749
  name: "Outlook Contacts",
1662
1750
  summary: "Contacts, contact folders, and people suggestions.",
1663
- family: "microsoft",
1664
- sourceFormat: "openapi",
1665
- sourceUrl: MICROSOFT_GRAPH_OPENAPI_URL,
1751
+ protocol: "openapi",
1752
+ provider: { id: "microsoft", domain: "graph.microsoft.com" },
1753
+ source: {
1754
+ kind: "openapi",
1755
+ url: MICROSOFT_GRAPH_OPENAPI_URL,
1756
+ operationPathPrefixes: ["/me/contacts", "/me/contactFolders", "/me/people"]
1757
+ },
1666
1758
  baseUrl: MICROSOFT_GRAPH_BASE_URL,
1667
- oauth: microsoftOAuth(["Contacts.ReadWrite", "People.Read.All"]),
1668
- pathPrefixes: ["/me/contacts", "/me/contactFolders", "/me/people"],
1669
- features: [accountIdentityFeature("microsoft")]
1759
+ authentication: microsoftOAuth(["Contacts.ReadWrite", "People.Read.All"]),
1760
+ facets: [accountIdentityFacet("microsoft")]
1670
1761
  };
1671
- var MICROSOFT_ONEDRIVE_PRESET = {
1762
+ var MICROSOFT_ONEDRIVE_INTEGRATION_DEFINITION = {
1672
1763
  id: "microsoft-onedrive",
1673
1764
  name: "OneDrive",
1674
1765
  summary: "Drives, files, folders, sharing links, and permissions.",
1675
- family: "microsoft",
1676
- sourceFormat: "openapi",
1677
- sourceUrl: MICROSOFT_GRAPH_OPENAPI_URL,
1766
+ protocol: "openapi",
1767
+ provider: { id: "microsoft", domain: "graph.microsoft.com" },
1768
+ source: {
1769
+ kind: "openapi",
1770
+ url: MICROSOFT_GRAPH_OPENAPI_URL,
1771
+ operationPathPrefixes: ["/me/drive", "/me/drives", "/me/followedSites", "/drives", "/shares"]
1772
+ },
1678
1773
  baseUrl: MICROSOFT_GRAPH_BASE_URL,
1679
- oauth: microsoftOAuth(["Files.ReadWrite.All", "Sites.ReadWrite.All"]),
1680
- pathPrefixes: ["/me/drive", "/me/drives", "/me/followedSites", "/drives", "/shares"],
1681
- features: [driveKnowledgeFeature("microsoft-onedrive"), accountIdentityFeature("microsoft")]
1774
+ authentication: microsoftOAuth(["Files.ReadWrite.All", "Sites.ReadWrite.All"]),
1775
+ facets: [driveKnowledgeFacet("microsoft-onedrive"), accountIdentityFacet("microsoft")]
1682
1776
  };
1683
- var CORE_PROVIDER_PRESETS = [
1684
- GOOGLE_DRIVE_PRESET,
1685
- GOOGLE_GMAIL_PRESET,
1686
- MICROSOFT_OUTLOOK_MAIL_PRESET,
1687
- MICROSOFT_OUTLOOK_CALENDAR_PRESET,
1688
- MICROSOFT_OUTLOOK_CONTACTS_PRESET,
1689
- MICROSOFT_ONEDRIVE_PRESET
1777
+ var CORE_INTEGRATION_DEFINITIONS = [
1778
+ GOOGLE_DRIVE_INTEGRATION_DEFINITION,
1779
+ MICROSOFT_OUTLOOK_MAIL_INTEGRATION_DEFINITION,
1780
+ MICROSOFT_OUTLOOK_CALENDAR_INTEGRATION_DEFINITION,
1781
+ MICROSOFT_OUTLOOK_CONTACTS_INTEGRATION_DEFINITION,
1782
+ MICROSOFT_ONEDRIVE_INTEGRATION_DEFINITION
1690
1783
  ];
1691
- function providerPresetById(id) {
1692
- return CORE_PROVIDER_PRESETS.find((preset) => preset.id === id);
1784
+ function integrationDefinitionById(id) {
1785
+ return CORE_INTEGRATION_DEFINITIONS.find((definition) => definition.id === id);
1693
1786
  }
1694
- function providerDomainForPreset(preset) {
1695
- return new URL(preset.baseUrl).hostname.toLowerCase();
1787
+ function integrationDefinitionProviderDomain(definition) {
1788
+ return definition.provider.domain;
1696
1789
  }
1697
- function integrationFeaturesForPreset(presetId) {
1698
- return presetId ? providerPresetById(presetId)?.features ?? [] : [];
1790
+ function integrationFacetDefinitions(definitionId) {
1791
+ return definitionId ? integrationDefinitionById(definitionId)?.facets ?? [] : [];
1699
1792
  }
1700
- function filterOpenApiDocumentForPreset(document, preset) {
1701
- if (!preset.pathPrefixes?.length) return document;
1793
+ function filterOpenApiDocumentForDefinition(document, definition) {
1794
+ if (definition.source.kind !== "openapi" || !definition.source.operationPathPrefixes?.length) {
1795
+ return document;
1796
+ }
1797
+ const operationPathPrefixes = definition.source.operationPathPrefixes;
1702
1798
  if (!isRecord3(document.paths)) {
1703
1799
  throw new IntegrationProtocolError("openapi_paths", "OpenAPI document has no paths object");
1704
1800
  }
1705
1801
  const paths = Object.fromEntries(
1706
1802
  Object.entries(document.paths).filter(
1707
- ([path]) => preset.pathPrefixes.some((prefix) => path === prefix || path.startsWith(`${prefix}/`))
1803
+ ([path]) => operationPathPrefixes.some((prefix) => path === prefix || path.startsWith(`${prefix}/`))
1708
1804
  )
1709
1805
  );
1710
1806
  if (Object.keys(paths).length === 0) {
1711
1807
  throw new IntegrationProtocolError(
1712
- "provider_preset_empty",
1713
- `${preset.name} did not match any operations in the supplied OpenAPI document`
1808
+ "integration_definition_empty",
1809
+ `${definition.name} did not match any operations in the supplied OpenAPI document`
1714
1810
  );
1715
1811
  }
1716
1812
  return {
1717
1813
  ...document,
1718
1814
  paths,
1719
- ...preset.baseUrl ? { servers: [{ url: preset.baseUrl }] } : {}
1815
+ servers: [{ url: definition.baseUrl }]
1720
1816
  };
1721
1817
  }
1722
1818
  function googleDiscoveryToOpenApi(discovery) {
@@ -1796,9 +1892,7 @@ function collectGoogleMethods(document, value, paths) {
1796
1892
  const path = stringValue2(rawMethod.path);
1797
1893
  const httpMethod = stringValue2(rawMethod.httpMethod)?.toLowerCase();
1798
1894
  if (!path || !httpMethod) continue;
1799
- const parameters = Object.entries(
1800
- isRecord3(rawMethod.parameters) ? rawMethod.parameters : {}
1801
- ).flatMap(([name, rawParameter]) => {
1895
+ const parameters = Object.entries(isRecord3(rawMethod.parameters) ? rawMethod.parameters : {}).sort(([left], [right]) => left.localeCompare(right)).flatMap(([name, rawParameter]) => {
1802
1896
  if (!isRecord3(rawParameter)) return [];
1803
1897
  const location = rawParameter.location === "path" ? "path" : "query";
1804
1898
  return [
@@ -1815,7 +1909,10 @@ function collectGoogleMethods(document, value, paths) {
1815
1909
  const responseRef = isRecord3(rawMethod.response) ? stringValue2(rawMethod.response.$ref) : void 0;
1816
1910
  const operation = {
1817
1911
  operationId: stringValue2(rawMethod.id) ?? fallbackId,
1818
- summary: stringValue2(rawMethod.description) ?? stringValue2(rawMethod.id) ?? fallbackId,
1912
+ // Discovery descriptions are often full documentation paragraphs. Keep
1913
+ // them as descriptions and use the stable method identity for the short
1914
+ // OpenGeni tool display name.
1915
+ summary: stringValue2(rawMethod.id) ?? fallbackId,
1819
1916
  description: stringValue2(rawMethod.description),
1820
1917
  parameters,
1821
1918
  responses: {
@@ -1894,23 +1991,174 @@ function stringValue2(value) {
1894
1991
  function isRecord3(value) {
1895
1992
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
1896
1993
  }
1994
+
1995
+ // src/integration-presentations.ts
1996
+ var INTEGRATION_DEFINITION_PRESENTATIONS = {
1997
+ "google-drive": {
1998
+ providerName: "Google",
1999
+ icon: "files",
2000
+ introduction: "Let agents work with files in the Google Drive account you choose.",
2001
+ capabilities: [
2002
+ {
2003
+ title: "Find files and folders",
2004
+ description: "Browse and search content in My Drive and shared drives."
2005
+ },
2006
+ {
2007
+ title: "Create and update content",
2008
+ description: "Work with files and folders through the reviewed Drive tools."
2009
+ },
2010
+ {
2011
+ title: "Manage sharing",
2012
+ description: "Review and update links, permissions, and shared-drive content."
2013
+ }
2014
+ ],
2015
+ permissionSummary: "Google asks for access to the Drive account you approve, including files shared with that account.",
2016
+ scopeLabels: {
2017
+ "https://www.googleapis.com/auth/drive": {
2018
+ label: "Work with Google Drive files",
2019
+ description: "See, create, edit, organize, and share files available to this account."
2020
+ }
2021
+ }
2022
+ },
2023
+ "microsoft-outlook-mail": {
2024
+ providerName: "Microsoft",
2025
+ icon: "mail",
2026
+ introduction: "Let agents work with mail in the Microsoft account you choose.",
2027
+ capabilities: [
2028
+ {
2029
+ title: "Find and understand mail",
2030
+ description: "Search messages, folders, and attachments for useful context."
2031
+ },
2032
+ {
2033
+ title: "Draft and send messages",
2034
+ description: "Prepare, update, and send mail through the reviewed Outlook tools."
2035
+ },
2036
+ {
2037
+ title: "Manage mailbox settings",
2038
+ description: "Work with supported folders, classifications, and mailbox preferences."
2039
+ }
2040
+ ],
2041
+ permissionSummary: "Microsoft asks for mail and mailbox-setting access for the account you approve.",
2042
+ scopeLabels: {
2043
+ "Mail.ReadWrite": {
2044
+ label: "Read and update mail",
2045
+ description: "Work with messages, folders, and attachments in this mailbox."
2046
+ },
2047
+ "Mail.Send": {
2048
+ label: "Send mail",
2049
+ description: "Send messages as the connected Microsoft account."
2050
+ },
2051
+ "MailboxSettings.ReadWrite": {
2052
+ label: "Manage mailbox settings",
2053
+ description: "Read and update supported Outlook mailbox preferences."
2054
+ }
2055
+ }
2056
+ },
2057
+ "microsoft-outlook-calendar": {
2058
+ providerName: "Microsoft",
2059
+ icon: "calendar",
2060
+ introduction: "Let agents help coordinate the calendars in your Microsoft account.",
2061
+ capabilities: [
2062
+ {
2063
+ title: "Understand your schedule",
2064
+ description: "Review calendars, events, availability, and reminders."
2065
+ },
2066
+ {
2067
+ title: "Plan meetings",
2068
+ description: "Find suitable times and coordinate calendar activity."
2069
+ },
2070
+ {
2071
+ title: "Manage events",
2072
+ description: "Create and update events through the reviewed calendar tools."
2073
+ }
2074
+ ],
2075
+ permissionSummary: "Microsoft asks for permission to view and manage calendars for the account you approve.",
2076
+ scopeLabels: {
2077
+ "Calendars.ReadWrite": {
2078
+ label: "View and manage calendars",
2079
+ description: "Read, create, update, and organize calendar events."
2080
+ }
2081
+ }
2082
+ },
2083
+ "microsoft-outlook-contacts": {
2084
+ providerName: "Microsoft",
2085
+ icon: "contacts",
2086
+ introduction: "Let agents work with contacts in your Microsoft account.",
2087
+ capabilities: [
2088
+ {
2089
+ title: "Find people",
2090
+ description: "Look up contacts and relevant people suggestions."
2091
+ },
2092
+ {
2093
+ title: "Organize contacts",
2094
+ description: "Work with contacts and contact folders."
2095
+ },
2096
+ {
2097
+ title: "Keep details current",
2098
+ description: "Create or update contact information through reviewed tools."
2099
+ }
2100
+ ],
2101
+ permissionSummary: "Microsoft asks for contact access and people suggestions for the account you approve.",
2102
+ scopeLabels: {
2103
+ "Contacts.ReadWrite": {
2104
+ label: "View and manage contacts",
2105
+ description: "Read, create, update, and organize contacts and contact folders."
2106
+ },
2107
+ "People.Read.All": {
2108
+ label: "Find relevant people",
2109
+ description: "Use people suggestions available to the connected account."
2110
+ }
2111
+ }
2112
+ },
2113
+ "microsoft-onedrive": {
2114
+ providerName: "Microsoft",
2115
+ icon: "cloud",
2116
+ introduction: "Let agents work with files in the Microsoft account you choose.",
2117
+ capabilities: [
2118
+ {
2119
+ title: "Find files and folders",
2120
+ description: "Browse drives, folders, shared items, and sites available to the account."
2121
+ },
2122
+ {
2123
+ title: "Create and update content",
2124
+ description: "Work with OneDrive and SharePoint files through reviewed tools."
2125
+ },
2126
+ {
2127
+ title: "Manage sharing",
2128
+ description: "Review and update sharing links and permissions."
2129
+ }
2130
+ ],
2131
+ permissionSummary: "Microsoft asks for file and site access anywhere the connected account already has access.",
2132
+ scopeLabels: {
2133
+ "Files.ReadWrite.All": {
2134
+ label: "Work with accessible files",
2135
+ description: "Read, create, update, and organize files available to this account."
2136
+ },
2137
+ "Sites.ReadWrite.All": {
2138
+ label: "Work with accessible sites",
2139
+ description: "Read and update files in SharePoint sites available to this account."
2140
+ }
2141
+ }
2142
+ }
2143
+ };
1897
2144
  export {
1898
- CORE_PROVIDER_PRESETS,
2145
+ CORE_INTEGRATION_DEFINITIONS,
1899
2146
  DEFAULT_INTEGRATION_RESPONSE_BYTES,
1900
2147
  DEFAULT_INTEGRATION_TIMEOUT_MS,
1901
- GOOGLE_DRIVE_PRESET,
1902
- GOOGLE_GMAIL_PRESET,
2148
+ GOOGLE_DRIVE_INTEGRATION_DEFINITION,
1903
2149
  GraphqlMcpServer,
2150
+ INTEGRATION_DEFINITION_PRESENTATIONS,
1904
2151
  IntegrationInvocationError,
1905
2152
  IntegrationProtocolError,
2153
+ LOCAL_MCP_BRIDGE_CONTRACT_VERSION,
1906
2154
  MAX_INTEGRATION_SPEC_BYTES,
1907
2155
  MAX_INTEGRATION_TOOLS,
1908
2156
  MICROSOFT_GRAPH_BASE_URL,
1909
2157
  MICROSOFT_GRAPH_OPENAPI_URL,
1910
- MICROSOFT_ONEDRIVE_PRESET,
1911
- MICROSOFT_OUTLOOK_CALENDAR_PRESET,
1912
- MICROSOFT_OUTLOOK_CONTACTS_PRESET,
1913
- MICROSOFT_OUTLOOK_MAIL_PRESET,
2158
+ MICROSOFT_ONEDRIVE_INTEGRATION_DEFINITION,
2159
+ MICROSOFT_OUTLOOK_CALENDAR_INTEGRATION_DEFINITION,
2160
+ MICROSOFT_OUTLOOK_CONTACTS_INTEGRATION_DEFINITION,
2161
+ MICROSOFT_OUTLOOK_MAIL_INTEGRATION_DEFINITION,
1914
2162
  OpenApiMcpServer,
1915
2163
  applyCredentialPlacements,
1916
2164
  assertCredentialAudience,
@@ -1918,8 +2166,10 @@ export {
1918
2166
  compileGraphqlRevision,
1919
2167
  compileOpenApiRevision,
1920
2168
  createGraphqlMcpServer,
2169
+ createLocalMcpBridgeFromAdapters,
1921
2170
  createOpenApiMcpServer,
1922
2171
  createPinnedIntegrationTransport,
2172
+ defineLocalMcpBridgeDescriptor,
1923
2173
  deriveMcpNamespace,
1924
2174
  directIntegrationTransport,
1925
2175
  discoverOpenApiAuth,
@@ -1927,15 +2177,16 @@ export {
1927
2177
  fetchGraphqlIntrospection,
1928
2178
  fetchIntegrationSourceDocument,
1929
2179
  fetchWithDeadline,
1930
- filterOpenApiDocumentForPreset,
2180
+ filterOpenApiDocumentForDefinition,
1931
2181
  googleDiscoveryToOpenApi,
1932
2182
  immutableRevisionId,
1933
- integrationFeaturesForPreset,
2183
+ integrationDefinitionById,
2184
+ integrationDefinitionProviderDomain,
2185
+ integrationFacetDefinitions,
1934
2186
  invokeGraphqlOperation,
1935
2187
  invokeOpenApiOperation,
2188
+ isLocalMcpBridgeServer,
1936
2189
  parseOpenApiDocument,
1937
- providerDomainForPreset,
1938
- providerPresetById,
1939
2190
  readIntegrationResponse,
1940
2191
  sha256Hex,
1941
2192
  stableToolId,