@iblai/web-containers 1.56.1 → 1.58.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.
Files changed (127) hide show
  1. package/dist/cjs/_virtual/index2.js +2 -2
  2. package/dist/cjs/_virtual/index3.js +2 -2
  3. package/dist/cjs/components/chat/hooks/use-chat-file-drag-drop.js +13 -3
  4. package/dist/cjs/components/chat/hooks/use-chat-file-drag-drop.js.map +1 -1
  5. package/dist/cjs/components/chat/hooks/use-chat-file-upload.js +12 -16
  6. package/dist/cjs/components/chat/hooks/use-chat-file-upload.js.map +1 -1
  7. package/dist/cjs/components/chat/index.js +2 -2
  8. package/dist/cjs/components/chat/index.js.map +1 -1
  9. package/dist/cjs/components/chat/not-allowed-files-notice.js +62 -0
  10. package/dist/cjs/components/chat/not-allowed-files-notice.js.map +1 -0
  11. package/dist/cjs/components/chat/ui/button.js +4 -4
  12. package/dist/cjs/components/chat/ui/button.js.map +1 -1
  13. package/dist/cjs/components/chat-input-form/composer-plus-menu.js +94 -17
  14. package/dist/cjs/components/chat-input-form/composer-plus-menu.js.map +1 -1
  15. package/dist/cjs/components/chat-input-form/mcp-connect-explainer-dialog.js +29 -0
  16. package/dist/cjs/components/chat-input-form/mcp-connect-explainer-dialog.js.map +1 -0
  17. package/dist/cjs/components/chat-input-form/mcp-servers-menu.js +199 -0
  18. package/dist/cjs/components/chat-input-form/mcp-servers-menu.js.map +1 -0
  19. package/dist/cjs/components/chat-input-form/use-mcp-active-count.js +56 -0
  20. package/dist/cjs/components/chat-input-form/use-mcp-active-count.js.map +1 -0
  21. package/dist/cjs/components/chat-input-form.js +19 -6
  22. package/dist/cjs/components/chat-input-form.js.map +1 -1
  23. package/dist/cjs/components/modals/edit-mentor-modal/tabs/mcp-tab/connector-dialogs.js +755 -90
  24. package/dist/cjs/components/modals/edit-mentor-modal/tabs/mcp-tab/connector-dialogs.js.map +1 -1
  25. package/dist/cjs/components/modals/edit-mentor-modal/tabs/mcp-tab/connector-management-content.js +386 -984
  26. package/dist/cjs/components/modals/edit-mentor-modal/tabs/mcp-tab/connector-management-content.js.map +1 -1
  27. package/dist/cjs/components/modals/edit-mentor-modal/tabs/mcp-tab/field-info.js +16 -0
  28. package/dist/cjs/components/modals/edit-mentor-modal/tabs/mcp-tab/field-info.js.map +1 -0
  29. package/dist/cjs/components/modals/edit-mentor-modal/tabs/mcp-tab/index.js +6 -3
  30. package/dist/cjs/components/modals/edit-mentor-modal/tabs/mcp-tab/index.js.map +1 -1
  31. package/dist/cjs/components/modals/edit-mentor-modal/tabs/mcp-tab/mcp-connector-helpers.js +463 -0
  32. package/dist/cjs/components/modals/edit-mentor-modal/tabs/mcp-tab/mcp-connector-helpers.js.map +1 -0
  33. package/dist/cjs/components/modals/edit-mentor-modal/tabs/mcp-tab/oauth-app-fields.js +329 -0
  34. package/dist/cjs/components/modals/edit-mentor-modal/tabs/mcp-tab/oauth-app-fields.js.map +1 -0
  35. package/dist/cjs/components/modals/edit-mentor-modal/tabs/mcp-tab/remove-connector-dialog.js +20 -0
  36. package/dist/cjs/components/modals/edit-mentor-modal/tabs/mcp-tab/remove-connector-dialog.js.map +1 -0
  37. package/dist/cjs/components/modals/edit-mentor-modal/tabs/mcp-tab/use-mcp-server-actions.js +744 -0
  38. package/dist/cjs/components/modals/edit-mentor-modal/tabs/mcp-tab/use-mcp-server-actions.js.map +1 -0
  39. package/dist/cjs/components/modals/user-profile-modal.js +2 -0
  40. package/dist/cjs/components/modals/user-profile-modal.js.map +1 -1
  41. package/dist/cjs/components/ui/accordion.js +40 -0
  42. package/dist/cjs/components/ui/accordion.js.map +1 -0
  43. package/dist/cjs/i18n/messages/en.json.js +165 -20
  44. package/dist/cjs/i18n/messages/en.json.js.map +1 -1
  45. package/dist/cjs/i18n/messages/es.json.js +165 -20
  46. package/dist/cjs/i18n/messages/es.json.js.map +1 -1
  47. package/dist/cjs/i18n/messages/fr.json.js +165 -20
  48. package/dist/cjs/i18n/messages/fr.json.js.map +1 -1
  49. package/dist/cjs/i18n/messages/zh.json.js +165 -20
  50. package/dist/cjs/i18n/messages/zh.json.js.map +1 -1
  51. package/dist/cjs/index.js +2 -0
  52. package/dist/cjs/index.js.map +1 -1
  53. package/dist/cjs/node_modules/.pnpm/@radix-ui_react-accordion@1.2.8_@types_react-dom@19.2.1_@types_react@19.1.17__@types_re_b91476821b9fe8f172a947f727875267/node_modules/@radix-ui/react-accordion/dist/index.js +317 -0
  54. package/dist/cjs/node_modules/.pnpm/@radix-ui_react-accordion@1.2.8_@types_react-dom@19.2.1_@types_react@19.1.17__@types_re_b91476821b9fe8f172a947f727875267/node_modules/@radix-ui/react-accordion/dist/index.js.map +1 -0
  55. package/dist/cjs/node_modules/.pnpm/@radix-ui_react-collapsible@1.1.8_@types_react-dom@19.2.1_@types_react@19.1.17__@types__d84e28844e8116e61b459b615fab358a/node_modules/@radix-ui/react-collapsible/dist/index.js +173 -0
  56. package/dist/cjs/node_modules/.pnpm/@radix-ui_react-collapsible@1.1.8_@types_react-dom@19.2.1_@types_react@19.1.17__@types__d84e28844e8116e61b459b615fab358a/node_modules/@radix-ui/react-collapsible/dist/index.js.map +1 -0
  57. package/dist/cjs/node_modules/.pnpm/@radix-ui_react-collection@1.1.4_@types_react-dom@19.2.1_@types_react@19.1.17__@types_r_7047fbfe61c39c77a2126486502acdb6/node_modules/@radix-ui/react-collection/dist/index.js +73 -0
  58. package/dist/cjs/node_modules/.pnpm/@radix-ui_react-collection@1.1.4_@types_react-dom@19.2.1_@types_react@19.1.17__@types_r_7047fbfe61c39c77a2126486502acdb6/node_modules/@radix-ui/react-collection/dist/index.js.map +1 -0
  59. package/dist/cjs/node_modules/.pnpm/css-mediaquery@0.1.2/node_modules/css-mediaquery/index.js +1 -1
  60. package/dist/cjs/node_modules/.pnpm/matchmediaquery@0.4.2/node_modules/matchmediaquery/index.js +1 -1
  61. package/dist/cjs/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/index.js +1 -1
  62. package/dist/cjs/web-containers/tsconfig.build.tsbuildinfo +1 -0
  63. package/dist/esm/_virtual/index2.js +2 -2
  64. package/dist/esm/_virtual/index3.js +2 -2
  65. package/dist/esm/components/chat/hooks/use-chat-file-drag-drop.js +14 -4
  66. package/dist/esm/components/chat/hooks/use-chat-file-drag-drop.js.map +1 -1
  67. package/dist/esm/components/chat/hooks/use-chat-file-upload.js +13 -17
  68. package/dist/esm/components/chat/hooks/use-chat-file-upload.js.map +1 -1
  69. package/dist/esm/components/chat/index.js +2 -2
  70. package/dist/esm/components/chat/index.js.map +1 -1
  71. package/dist/esm/components/chat/not-allowed-files-notice.js +60 -0
  72. package/dist/esm/components/chat/not-allowed-files-notice.js.map +1 -0
  73. package/dist/esm/components/chat-input-form/composer-plus-menu.js +94 -17
  74. package/dist/esm/components/chat-input-form/composer-plus-menu.js.map +1 -1
  75. package/dist/esm/components/chat-input-form/mcp-connect-explainer-dialog.js +27 -0
  76. package/dist/esm/components/chat-input-form/mcp-connect-explainer-dialog.js.map +1 -0
  77. package/dist/esm/components/chat-input-form/mcp-servers-menu.js +197 -0
  78. package/dist/esm/components/chat-input-form/mcp-servers-menu.js.map +1 -0
  79. package/dist/esm/components/chat-input-form/use-mcp-active-count.js +54 -0
  80. package/dist/esm/components/chat-input-form/use-mcp-active-count.js.map +1 -0
  81. package/dist/esm/components/chat-input-form.js +19 -6
  82. package/dist/esm/components/chat-input-form.js.map +1 -1
  83. package/dist/esm/components/modals/edit-mentor-modal/tabs/mcp-tab/connector-dialogs.js +755 -92
  84. package/dist/esm/components/modals/edit-mentor-modal/tabs/mcp-tab/connector-dialogs.js.map +1 -1
  85. package/dist/esm/components/modals/edit-mentor-modal/tabs/mcp-tab/connector-management-content.js +361 -968
  86. package/dist/esm/components/modals/edit-mentor-modal/tabs/mcp-tab/connector-management-content.js.map +1 -1
  87. package/dist/esm/components/modals/edit-mentor-modal/tabs/mcp-tab/field-info.js +14 -0
  88. package/dist/esm/components/modals/edit-mentor-modal/tabs/mcp-tab/field-info.js.map +1 -0
  89. package/dist/esm/components/modals/edit-mentor-modal/tabs/mcp-tab/index.js +6 -3
  90. package/dist/esm/components/modals/edit-mentor-modal/tabs/mcp-tab/index.js.map +1 -1
  91. package/dist/esm/components/modals/edit-mentor-modal/tabs/mcp-tab/mcp-connector-helpers.js +431 -0
  92. package/dist/esm/components/modals/edit-mentor-modal/tabs/mcp-tab/mcp-connector-helpers.js.map +1 -0
  93. package/dist/esm/components/modals/edit-mentor-modal/tabs/mcp-tab/oauth-app-fields.js +313 -0
  94. package/dist/esm/components/modals/edit-mentor-modal/tabs/mcp-tab/oauth-app-fields.js.map +1 -0
  95. package/dist/esm/components/modals/edit-mentor-modal/tabs/mcp-tab/remove-connector-dialog.js +18 -0
  96. package/dist/esm/components/modals/edit-mentor-modal/tabs/mcp-tab/remove-connector-dialog.js.map +1 -0
  97. package/dist/esm/components/modals/edit-mentor-modal/tabs/mcp-tab/use-mcp-server-actions.js +742 -0
  98. package/dist/esm/components/modals/edit-mentor-modal/tabs/mcp-tab/use-mcp-server-actions.js.map +1 -0
  99. package/dist/esm/components/modals/user-profile-modal.js +2 -0
  100. package/dist/esm/components/modals/user-profile-modal.js.map +1 -1
  101. package/dist/esm/components/ui/accordion.js +16 -0
  102. package/dist/esm/components/ui/accordion.js.map +1 -0
  103. package/dist/esm/i18n/messages/en.json.js +163 -21
  104. package/dist/esm/i18n/messages/en.json.js.map +1 -1
  105. package/dist/esm/i18n/messages/es.json.js +163 -21
  106. package/dist/esm/i18n/messages/es.json.js.map +1 -1
  107. package/dist/esm/i18n/messages/fr.json.js +163 -21
  108. package/dist/esm/i18n/messages/fr.json.js.map +1 -1
  109. package/dist/esm/i18n/messages/zh.json.js +163 -21
  110. package/dist/esm/i18n/messages/zh.json.js.map +1 -1
  111. package/dist/esm/index.js +1 -0
  112. package/dist/esm/index.js.map +1 -1
  113. package/dist/esm/node_modules/.pnpm/@radix-ui_react-accordion@1.2.8_@types_react-dom@19.2.1_@types_react@19.1.17__@types_re_b91476821b9fe8f172a947f727875267/node_modules/@radix-ui/react-accordion/dist/index.js +306 -0
  114. package/dist/esm/node_modules/.pnpm/@radix-ui_react-accordion@1.2.8_@types_react-dom@19.2.1_@types_react@19.1.17__@types_re_b91476821b9fe8f172a947f727875267/node_modules/@radix-ui/react-accordion/dist/index.js.map +1 -0
  115. package/dist/esm/node_modules/.pnpm/@radix-ui_react-collapsible@1.1.8_@types_react-dom@19.2.1_@types_react@19.1.17__@types__d84e28844e8116e61b459b615fab358a/node_modules/@radix-ui/react-collapsible/dist/index.js +146 -0
  116. package/dist/esm/node_modules/.pnpm/@radix-ui_react-collapsible@1.1.8_@types_react-dom@19.2.1_@types_react@19.1.17__@types__d84e28844e8116e61b459b615fab358a/node_modules/@radix-ui/react-collapsible/dist/index.js.map +1 -0
  117. package/dist/esm/node_modules/.pnpm/@radix-ui_react-collection@1.1.4_@types_react-dom@19.2.1_@types_react@19.1.17__@types_r_7047fbfe61c39c77a2126486502acdb6/node_modules/@radix-ui/react-collection/dist/index.js +71 -0
  118. package/dist/esm/node_modules/.pnpm/@radix-ui_react-collection@1.1.4_@types_react-dom@19.2.1_@types_react@19.1.17__@types_r_7047fbfe61c39c77a2126486502acdb6/node_modules/@radix-ui/react-collection/dist/index.js.map +1 -0
  119. package/dist/esm/node_modules/.pnpm/css-mediaquery@0.1.2/node_modules/css-mediaquery/index.js +1 -1
  120. package/dist/esm/node_modules/.pnpm/matchmediaquery@0.4.2/node_modules/matchmediaquery/index.js +1 -1
  121. package/dist/esm/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/index.js +1 -1
  122. package/dist/esm/web-containers/tsconfig.build.tsbuildinfo +1 -0
  123. package/dist/index.d.ts +31 -2
  124. package/dist/package.json +1 -1
  125. package/package.json +3 -3
  126. package/dist/cjs/web-containers/tsconfig.tsbuildinfo +0 -1
  127. package/dist/esm/web-containers/tsconfig.tsbuildinfo +0 -1
@@ -0,0 +1,431 @@
1
+ import { TransportEnum } from '@iblai/iblai-api';
2
+ import { toast } from 'sonner';
3
+
4
+ const MCP_SERVER_PERMISSION_NAME = 'server';
5
+ // The MCP tab's brand blue on a radio: its ring and, through the icon, its dot
6
+ // (the base item paints the dot with `fill-primary`, which a text colour cannot reach).
7
+ const MCP_RADIO_ITEM_CLASS = 'data-[state=checked]:border-[#38A1E5] data-[state=checked]:text-[#38A1E5] [&_svg]:fill-[#38A1E5]';
8
+ const TRANSPORT_OPTIONS = [
9
+ { value: '', label: 'All Transports' },
10
+ { value: TransportEnum.SSE, label: 'SSE' },
11
+ { value: TransportEnum.WEBSOCKET, label: 'WebSocket' },
12
+ { value: TransportEnum.STREAMABLE_HTTP, label: 'Streamable HTTP' },
13
+ ];
14
+ const TRANSPORT_LABEL_KEYS = {
15
+ '': 'mcpTabConnectorManagementContent.transportLabelAllTransports',
16
+ [TransportEnum.SSE]: 'mcpTabConnectorManagementContent.transportLabelSSE',
17
+ [TransportEnum.WEBSOCKET]: 'mcpTabConnectorManagementContent.transportLabelWebSocket',
18
+ [TransportEnum.STREAMABLE_HTTP]: 'mcpTabConnectorManagementContent.transportLabelStreamableHTTP',
19
+ };
20
+ /**
21
+ * A connector's logo: its own image (stored for directory connectors too, guide
22
+ * §5.1), else its sign-in service's, else the directory's icon while older rows
23
+ * are backfilled.
24
+ */
25
+ const connectorImage = (server) => { var _a, _b; return server.image || ((_a = server.oauth_service_data) === null || _a === void 0 ? void 0 : _a.image) || ((_b = server.registry) === null || _b === void 0 ? void 0 : _b.icon_url) || undefined; };
26
+ /** The sign-in scope in force for the agent: its own choice, else the connector's. */
27
+ const currentSignInScope = (server) => (server.effective_auth_scope || server.auth_scope || 'user');
28
+ /** The app's own sign-in callback page, on the site the user is on. */
29
+ const oauthCallbackUrl = () => typeof window === 'undefined' ? '' : `${window.location.origin}/google-oauth-callback/`;
30
+ const getTransportLabelKey = (value) => { var _a; return (_a = TRANSPORT_LABEL_KEYS[value]) !== null && _a !== void 0 ? _a : 'mcpTabConnectorManagementContent.transportLabelStreamableHTTP'; };
31
+ const normalizeTransportValue = (transport) => {
32
+ const normalized = transport === null || transport === void 0 ? void 0 : transport.toString().toLowerCase();
33
+ if (normalized === TransportEnum.SSE)
34
+ return TransportEnum.SSE;
35
+ if (normalized === TransportEnum.WEBSOCKET)
36
+ return TransportEnum.WEBSOCKET;
37
+ return TransportEnum.STREAMABLE_HTTP;
38
+ };
39
+ // The backend names the shared scope "platform"; "tenant" is the legacy spelling
40
+ // still present on older connection records.
41
+ const SHARED_CONNECTION_SCOPES = new Set(['platform', 'tenant']);
42
+ /**
43
+ * Finds the active MCP server connection for a given server, accounting for scope rules.
44
+ * - platform (legacy: tenant) scope: any connection for this server ID means connected
45
+ * - user scope: connection must match the current user
46
+ * - mentor scope: connection must match the current mentor being edited
47
+ */
48
+ /**
49
+ * Whether an active connection satisfies `scope` for this server: a shared one for
50
+ * the tenant, this agent's own for the agent, the person's own for user scope.
51
+ * (`findMCPServerConnection` answers "any connection that applies to me", which
52
+ * counts the admin's own sign-in even when the server now signs in for everyone.)
53
+ */
54
+ // For a sign-in (OAuth) server. Deleting a sign-in keeps its MCP connection with
55
+ // no connected service (the backend's SET_NULL), and that signs nobody in.
56
+ const connectionHasSignIn = (connection) => connection.connected_service != null;
57
+ const connectionForScopeExists = (connections, serverId, scope, currentUser, currentMentorId) => {
58
+ const active = (connections !== null && connections !== void 0 ? connections : []).filter((c) => c.server === serverId && c.is_active && connectionHasSignIn(c));
59
+ if (scope === 'user')
60
+ return active.some((c) => c.scope === 'user' && c.user === currentUser);
61
+ if (scope === 'mentor') {
62
+ return active.some((c) => c.scope === 'mentor' && c.mentor === currentMentorId);
63
+ }
64
+ return active.some((c) => SHARED_CONNECTION_SCOPES.has(c.scope));
65
+ };
66
+ const findMCPServerConnection = (connections, serverId, currentUser, currentMentorId) => {
67
+ var _a, _b;
68
+ if (!(connections === null || connections === void 0 ? void 0 : connections.length))
69
+ return null;
70
+ const applicable = connections.filter((conn) => conn.server === serverId &&
71
+ conn.is_active &&
72
+ (SHARED_CONNECTION_SCOPES.has(conn.scope) ||
73
+ (conn.scope === 'user' && conn.user === currentUser) ||
74
+ (conn.scope === 'mentor' && conn.mentor === currentMentorId)));
75
+ // A sign-in made after a Disconnect is a new connection beside the emptied
76
+ // one; the one that still signs in wins, whatever order the list comes in.
77
+ return (_b = (_a = applicable.find(connectionHasSignIn)) !== null && _a !== void 0 ? _a : applicable[0]) !== null && _b !== void 0 ? _b : null;
78
+ };
79
+ /**
80
+ * Whether a server is usable by this person as far as their own sign-in goes: a
81
+ * server each person signs in to (for this agent) needs their own connection that
82
+ * still signs in, or their own sign-in. Shared (agent or organization) sign-ins are
83
+ * not judged: the connection list hides them from everyone but tenant admins. The
84
+ * chat's switch and its "N on" count both read this.
85
+ */
86
+ const mcpServerSignedIn = (server, { connections, connectedServices, username, mentorId, }) => {
87
+ var _a;
88
+ const oauth = server.oauth_service_data;
89
+ if (((_a = server.auth_type) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== 'oauth2' || !oauth)
90
+ return true;
91
+ const scope = server.effective_auth_scope || server.auth_scope || 'user';
92
+ if (scope !== 'user')
93
+ return true;
94
+ return (connectionForScopeExists(connections, server.id, 'user', username, mentorId) ||
95
+ !!(connectedServices === null || connectedServices === void 0 ? void 0 : connectedServices.some((service) => service.provider === oauth.oauth_provider && service.service === oauth.name)));
96
+ };
97
+ const createMCPServerFormData = (data) => {
98
+ var _a;
99
+ const formData = new FormData();
100
+ formData.append('name', data.name);
101
+ formData.append('url', data.url);
102
+ formData.append('transport', data.transport);
103
+ if (data.description)
104
+ formData.append('description', data.description);
105
+ if (data.auth_type)
106
+ formData.append('auth_type', data.auth_type);
107
+ if (data.auth_scope)
108
+ formData.append('auth_scope', data.auth_scope);
109
+ if (data.credentials)
110
+ formData.append('credentials', data.credentials);
111
+ if (data.image)
112
+ formData.append('image', data.image);
113
+ if (data.mentor !== undefined)
114
+ formData.append('mentor', (_a = data.mentor) !== null && _a !== void 0 ? _a : '');
115
+ if (data.user_can_disable !== undefined) {
116
+ formData.append('user_can_disable', String(data.user_can_disable));
117
+ }
118
+ return formData;
119
+ };
120
+ /**
121
+ * The ids of the servers an agent uses, from its settings response, or `null`
122
+ * when they cannot be known: field-level RBAC blanks `mcp_servers` to `[]` for
123
+ * users who may not read it (`permissions.field.mcp_servers.read === false`),
124
+ * so an empty list alone does not mean "no servers attached".
125
+ */
126
+ /**
127
+ * The servers the agent uses, as rows: the settings' own `mcp_servers` rows
128
+ * (complete objects when the API sends them) overlaid with the matching rows of
129
+ * a server list fetched for the conversation, which carry this chat's
130
+ * `user_enabled`. Null while the attachments are not readable. Ids the settings
131
+ * list without a row anywhere are left out (nothing could be shown for them).
132
+ */
133
+ const attachedMcpServers = (settings, listed) => {
134
+ var _a;
135
+ const ids = readAttachedMcpServerIds(settings);
136
+ if (!ids)
137
+ return null;
138
+ const own = new Map();
139
+ for (const entry of (_a = settings.mcp_servers) !== null && _a !== void 0 ? _a : []) {
140
+ if (entry && typeof entry === 'object' && typeof entry.id === 'number') {
141
+ own.set(entry.id, entry);
142
+ }
143
+ }
144
+ const fresh = new Map((listed !== null && listed !== void 0 ? listed : []).map((server) => [server.id, server]));
145
+ return ids.flatMap((id) => {
146
+ const row = own.get(id);
147
+ const page = fresh.get(id);
148
+ if (!row && !page)
149
+ return [];
150
+ return [{ ...(row !== null && row !== void 0 ? row : {}), ...(page !== null && page !== void 0 ? page : {}) }];
151
+ });
152
+ };
153
+ const readAttachedMcpServerIds = (settings) => {
154
+ var _a, _b;
155
+ if (!settings || typeof settings !== 'object')
156
+ return null;
157
+ const { mcp_servers: servers, permissions } = settings;
158
+ if (!Array.isArray(servers) || ((_b = (_a = permissions === null || permissions === void 0 ? void 0 : permissions.field) === null || _a === void 0 ? void 0 : _a.mcp_servers) === null || _b === void 0 ? void 0 : _b.read) === false)
159
+ return null;
160
+ return servers
161
+ .map((entry) => typeof entry === 'number'
162
+ ? entry
163
+ : typeof entry === 'object' &&
164
+ entry !== null &&
165
+ typeof entry.id === 'number'
166
+ ? entry.id
167
+ : null)
168
+ .filter((id) => typeof id === 'number' && Number.isFinite(id));
169
+ };
170
+ // iblFetchBaseQuery throws its error, so RTK's unwrap() rejects with `{}` and the status
171
+ // is lost; only a status that is present and not 403 proves a non-permission failure.
172
+ const isPermissionRejection = (error) => {
173
+ const status = error === null || error === void 0 ? void 0 : error.status;
174
+ return status === undefined || status === 403;
175
+ };
176
+ const createOAuthConnection = async (params, onSuccess, onError) => {
177
+ var _a;
178
+ const { connectedServiceId, isCreatingConnection, createMCPServerConnection, tenantKey, username, serverId, authScope, mentorId, oauthDisplayName, refetchFeatured, refetchMy, refetchConnected, refetchMCPServerConnections, refetchMentorSettings, softCreateFailureMessage, successMessage, formatErrorMessage, } = params;
179
+ if (isCreatingConnection || !connectedServiceId || !Number.isFinite(connectedServiceId)) {
180
+ return false;
181
+ }
182
+ const scope = authScope || 'user';
183
+ let connectionCreated = false;
184
+ try {
185
+ await createMCPServerConnection({
186
+ org: tenantKey,
187
+ userId: username,
188
+ server: serverId,
189
+ scope,
190
+ auth_type: 'oauth2',
191
+ ...(scope !== 'mentor' ? { user: username } : {}),
192
+ connected_service: connectedServiceId,
193
+ ...(scope === 'mentor' && mentorId ? { mentor: mentorId } : {}),
194
+ }).unwrap();
195
+ connectionCreated = true;
196
+ await Promise.all([
197
+ refetchFeatured(),
198
+ refetchMy(),
199
+ refetchConnected(),
200
+ refetchMCPServerConnections(),
201
+ refetchMentorSettings(),
202
+ ]);
203
+ toast.success(successMessage !== null && successMessage !== void 0 ? successMessage : `${oauthDisplayName} connected successfully`);
204
+ onSuccess();
205
+ return true;
206
+ }
207
+ catch (error) {
208
+ if (!connectionCreated && softCreateFailureMessage && isPermissionRejection(error)) {
209
+ await Promise.allSettled([
210
+ refetchFeatured(),
211
+ refetchMy(),
212
+ refetchConnected(),
213
+ refetchMCPServerConnections(),
214
+ refetchMentorSettings(),
215
+ ]);
216
+ toast.info(softCreateFailureMessage);
217
+ onSuccess();
218
+ return true;
219
+ }
220
+ const detail = (_a = error === null || error === void 0 ? void 0 : error.data) === null || _a === void 0 ? void 0 : _a.detail;
221
+ toast.error(formatErrorMessage
222
+ ? formatErrorMessage(detail)
223
+ : `Failed to create connection: ${detail || 'Unknown error'}`);
224
+ onError(error);
225
+ return false;
226
+ }
227
+ };
228
+ const processOAuthStorageEvent = (event, expectedProvider, expectedServiceName) => {
229
+ if (event.key !== 'oauth_connection_complete') {
230
+ return null;
231
+ }
232
+ try {
233
+ const data = JSON.parse(event.newValue || '{}');
234
+ if (data.connectedServiceId) {
235
+ const isMatch = data.provider === expectedProvider && data.serviceName === expectedServiceName;
236
+ return { connectedServiceId: data.connectedServiceId, isMatch };
237
+ }
238
+ }
239
+ catch (_a) {
240
+ // A malformed payload falls through to null, which makes the caller poll instead.
241
+ }
242
+ return null;
243
+ };
244
+ const processOAuthMessageEvent = (event, expectedOrigin, expectedProvider, expectedServiceName) => {
245
+ var _a, _b;
246
+ if (event.origin !== expectedOrigin) {
247
+ return null;
248
+ }
249
+ if (((_a = event.data) === null || _a === void 0 ? void 0 : _a.type) === 'GOOGLE_AUTH_SUCCESS' && ((_b = event.data) === null || _b === void 0 ? void 0 : _b.connectedServiceId)) {
250
+ if (event.data.provider === expectedProvider &&
251
+ event.data.serviceName === expectedServiceName) {
252
+ return event.data.connectedServiceId;
253
+ }
254
+ }
255
+ return null;
256
+ };
257
+ const checkOAuthConnectionComplete = async (refetchConnected, provider, serviceName) => {
258
+ try {
259
+ const updated = await refetchConnected();
260
+ if (updated === null || updated === void 0 ? void 0 : updated.data) {
261
+ const connService = updated.data.find((cs) => cs.provider === provider && cs.service === serviceName);
262
+ if (connService === null || connService === void 0 ? void 0 : connService.id) {
263
+ return connService.id;
264
+ }
265
+ }
266
+ }
267
+ catch (_a) {
268
+ // The next poll retries.
269
+ }
270
+ return null;
271
+ };
272
+ const handleOAuthMessageResult = (event, expectedOrigin, expectedProvider, expectedServiceName) => {
273
+ const connectedServiceId = processOAuthMessageEvent(event, expectedOrigin, expectedProvider, expectedServiceName);
274
+ return {
275
+ shouldCreate: connectedServiceId !== null && connectedServiceId > 0,
276
+ connectedServiceId,
277
+ };
278
+ };
279
+ const validateDisconnectOAuthParams = (tenantKey, username, connectedServiceId) => {
280
+ if (!tenantKey || !username) {
281
+ return {
282
+ isValid: false,
283
+ error: 'Missing required parameters',
284
+ connectedServiceId: null,
285
+ };
286
+ }
287
+ if (!connectedServiceId) {
288
+ return {
289
+ isValid: false,
290
+ error: 'No connected service to disconnect',
291
+ connectedServiceId: null,
292
+ };
293
+ }
294
+ return {
295
+ isValid: true,
296
+ error: null,
297
+ connectedServiceId,
298
+ };
299
+ };
300
+ const determineCheckConnectionAction = (isCreatingConnection, connectedServiceId, createConnectionSuccess, pollCount, maxPolls) => {
301
+ if (isCreatingConnection) {
302
+ return { action: 'skip', connectedServiceId: null };
303
+ }
304
+ if (pollCount >= maxPolls) {
305
+ return { action: 'max_polls_cleanup', connectedServiceId: null };
306
+ }
307
+ return { action: 'continue_polling', connectedServiceId };
308
+ };
309
+ const determineMessageEventAction = (shouldCreate, connectedServiceId) => {
310
+ if (shouldCreate && connectedServiceId) {
311
+ return { action: 'create_and_cleanup', connectedServiceId };
312
+ }
313
+ return { action: 'ignore', connectedServiceId: null };
314
+ };
315
+ const shouldExecuteMessageAction = (actionResult) => {
316
+ return actionResult.action === 'create_and_cleanup' && actionResult.connectedServiceId !== null;
317
+ };
318
+ const executeCheckConnectionFlowLogic = (connectedServiceId, createConnectionSuccess, pollCount, maxPolls) => {
319
+ if (connectedServiceId && createConnectionSuccess) {
320
+ return {
321
+ executed: true,
322
+ action: 'create_and_cleanup',
323
+ connectedServiceId,
324
+ };
325
+ }
326
+ if (pollCount >= maxPolls) {
327
+ return {
328
+ executed: true,
329
+ action: 'max_polls_cleanup',
330
+ connectedServiceId: null,
331
+ };
332
+ }
333
+ return {
334
+ executed: false,
335
+ action: 'continue_polling',
336
+ connectedServiceId: null,
337
+ };
338
+ };
339
+ const executeMessageEventFlowLogic = (event, expectedOrigin, expectedProvider, expectedServiceName) => {
340
+ const { shouldCreate, connectedServiceId } = handleOAuthMessageResult(event, expectedOrigin, expectedProvider, expectedServiceName);
341
+ const actionResult = determineMessageEventAction(shouldCreate, connectedServiceId);
342
+ if (shouldExecuteMessageAction(actionResult)) {
343
+ return {
344
+ executed: true,
345
+ action: 'create_and_cleanup',
346
+ connectedServiceId: actionResult.connectedServiceId,
347
+ };
348
+ }
349
+ return {
350
+ executed: false,
351
+ action: 'ignore',
352
+ connectedServiceId: null,
353
+ };
354
+ };
355
+ const executeHandleMessageCallback = async (params) => {
356
+ const flowResult = executeMessageEventFlowLogic(params.event, params.expectedOrigin, params.provider, params.serviceName);
357
+ if (flowResult.executed && flowResult.connectedServiceId) {
358
+ params.cleanup();
359
+ await params.doCreateConnection(flowResult.connectedServiceId);
360
+ return {
361
+ executed: true,
362
+ connectedServiceId: flowResult.connectedServiceId,
363
+ };
364
+ }
365
+ return { executed: false, connectedServiceId: null };
366
+ };
367
+ const executeMaxPollsCleanup = (params) => {
368
+ const maxPollsFlowResult = executeCheckConnectionFlowLogic(null, false, params.pollCount, params.maxPolls);
369
+ if (maxPollsFlowResult.executed) {
370
+ params.cleanup();
371
+ return true;
372
+ }
373
+ return false;
374
+ };
375
+ const executeConnectionFoundCleanup = async (params) => {
376
+ const success = await params.doCreateConnection(params.connectedServiceId);
377
+ const flowResult = executeCheckConnectionFlowLogic(params.connectedServiceId, success, params.pollCount, params.maxPolls);
378
+ if (flowResult.executed) {
379
+ params.cleanup();
380
+ return { cleaned: true, success };
381
+ }
382
+ return { cleaned: false, success };
383
+ };
384
+ /**
385
+ * Whether the user may change which servers the agent uses. Without a readable
386
+ * attachment list there is no way to tell what a change would do.
387
+ */
388
+ const canManageMcpServers = ({ attachmentsKnown, fieldPermissions, enableRbac, }) => attachmentsKnown &&
389
+ ((fieldPermissions === null || fieldPermissions === void 0 ? void 0 : fieldPermissions.mcp_servers) ? !!fieldPermissions.mcp_servers.write : !enableRbac);
390
+ /**
391
+ * The one Connect/Disconnect rule for OAuth servers, shared by the agent settings MCP
392
+ * tab and the chat MCP menu:
393
+ * - A per-user sign-in counts as connected before its MCP connection exists (the backend
394
+ * creates that connection on the user's next chat turn).
395
+ * - Shared (tenant/agent) servers can only be connected by someone who manages the agent;
396
+ * a per-user server by anyone, but only where the agent uses it when that is readable.
397
+ * - Only the user who signed in can remove a sign-in, and removing a shared one also takes
398
+ * the server off the agent.
399
+ */
400
+ const getMcpConnectionState = (server, ctx) => {
401
+ var _a, _b;
402
+ // The agent's own override, else the connector's.
403
+ const scope = server.effective_auth_scope || server.auth_scope || 'user';
404
+ const isUserScope = scope === 'user';
405
+ const isOAuth2 = ((_a = server.auth_type) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'oauth2';
406
+ const isAttached = ctx.activeMcpServerIds.includes(server.id);
407
+ const signedInServiceId = isOAuth2 && isUserScope ? ctx.getSignedInServiceId(server) : null;
408
+ const isConnected = isOAuth2 && (ctx.isOAuthServerConnected(server) || signedInServiceId !== null);
409
+ const disconnectServiceId = (_b = ctx.getConnectedServiceId(server)) !== null && _b !== void 0 ? _b : signedInServiceId;
410
+ const userCanConnect = isOAuth2 &&
411
+ !!server.oauth_service_data &&
412
+ (ctx.canManage || (isUserScope && (!ctx.attachmentsKnown || isAttached)));
413
+ const showDisconnect = isConnected &&
414
+ disconnectServiceId !== null &&
415
+ (isUserScope || (ctx.canManage && ctx.ownsConnectedService(disconnectServiceId)));
416
+ return {
417
+ scope,
418
+ isUserScope,
419
+ isConnected,
420
+ signedInServiceId,
421
+ showConnect: !isConnected && userCanConnect,
422
+ showDisconnect,
423
+ disconnectOptions: {
424
+ detachFromAgent: ctx.canManage && !isUserScope,
425
+ connectedServiceId: signedInServiceId,
426
+ },
427
+ };
428
+ };
429
+
430
+ export { MCP_RADIO_ITEM_CLASS, MCP_SERVER_PERMISSION_NAME, TRANSPORT_OPTIONS, attachedMcpServers, canManageMcpServers, checkOAuthConnectionComplete, connectionForScopeExists, connectionHasSignIn, connectorImage, createMCPServerFormData, createOAuthConnection, currentSignInScope, determineCheckConnectionAction, determineMessageEventAction, executeCheckConnectionFlowLogic, executeConnectionFoundCleanup, executeHandleMessageCallback, executeMaxPollsCleanup, executeMessageEventFlowLogic, findMCPServerConnection, getMcpConnectionState, getTransportLabelKey, handleOAuthMessageResult, mcpServerSignedIn, normalizeTransportValue, oauthCallbackUrl, processOAuthMessageEvent, processOAuthStorageEvent, readAttachedMcpServerIds, shouldExecuteMessageAction, validateDisconnectOAuthParams };
431
+ //# sourceMappingURL=mcp-connector-helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-connector-helpers.js","sources":["../../../../../../../../../../src/components/modals/edit-mentor-modal/tabs/mcp-tab/mcp-connector-helpers.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAgBO,MAAM,0BAA0B,GAAG;AAE1C;AACA;AACO,MAAM,oBAAoB,GAC/B;AAEK,MAAM,iBAAiB,GAGzB;AACH,IAAA,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,gBAAgB,EAAE;IACtC,EAAE,KAAK,EAAE,aAAa,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE;IAC1C,EAAE,KAAK,EAAE,aAAa,CAAC,SAAS,EAAE,KAAK,EAAE,WAAW,EAAE;IACtD,EAAE,KAAK,EAAE,aAAa,CAAC,eAAe,EAAE,KAAK,EAAE,iBAAiB,EAAE;;AAGpE,MAAM,oBAAoB,GAA2B;AACnD,IAAA,EAAE,EAAE,8DAA8D;AAClE,IAAA,CAAC,aAAa,CAAC,GAAG,GAAG,oDAAoD;AACzE,IAAA,CAAC,aAAa,CAAC,SAAS,GAAG,0DAA0D;AACrF,IAAA,CAAC,aAAa,CAAC,eAAe,GAAG,+DAA+D;CACjG;AAED;;;;AAIG;AACI,MAAM,cAAc,GAAG,CAAC,MAAiB,KAAwB,EAAA,IAAA,EAAA,EAAA,EAAA,CAAA,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